upload tizen1.0 source 12/12/1
authorSungho Park <chywoo.park@samsung.com>
Mon, 30 Apr 2012 09:06:10 +0000 (18:06 +0900)
committerSungho Park <chywoo.park@samsung.com>
Mon, 30 Apr 2012 09:06:10 +0000 (18:06 +0900)
Change-Id: If9d34c3bbac8587a220f920cce3092d39f6db943

1805 files changed:
org.eclipse.cdt.platform/.project [new file with mode: 0644]
org.eclipse.cdt.platform/build.properties [new file with mode: 0644]
org.eclipse.cdt.platform/eclipse_update_120.jpg [new file with mode: 0644]
org.eclipse.cdt.platform/epl-v10.html [new file with mode: 0644]
org.eclipse.cdt.platform/feature.properties [new file with mode: 0644]
org.eclipse.cdt.platform/feature.xml [new file with mode: 0644]
org.eclipse.cdt.platform/license.html [new file with mode: 0644]
org.eclipse.cdt.ui/.classpath [new file with mode: 0644]
org.eclipse.cdt.ui/.options [new file with mode: 0644]
org.eclipse.cdt.ui/.project [new file with mode: 0644]
org.eclipse.cdt.ui/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
org.eclipse.cdt.ui/ChangeLog-browser [new file with mode: 0644]
org.eclipse.cdt.ui/META-INF/MANIFEST.MF [new file with mode: 0644]
org.eclipse.cdt.ui/META-INF/eclipse.inf [new file with mode: 0644]
org.eclipse.cdt.ui/META-INF/maven/org.eclipse.cdt/org.eclipse.cdt.ui/pom.properties [new file with mode: 0644]
org.eclipse.cdt.ui/META-INF/maven/org.eclipse.cdt/org.eclipse.cdt.ui/pom.xml [new file with mode: 0644]
org.eclipse.cdt.ui/about.html [new file with mode: 0644]
org.eclipse.cdt.ui/about_files/ispell-license.txt [new file with mode: 0644]
org.eclipse.cdt.ui/build.properties [new file with mode: 0644]
org.eclipse.cdt.ui/dictionaries/en_GB.dictionary [new file with mode: 0644]
org.eclipse.cdt.ui/dictionaries/en_US.dictionary [new file with mode: 0644]
org.eclipse.cdt.ui/doxygenTags.csv [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/action-editconfig.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/alphab_sort_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/build_exec.png [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/ch_callees.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/ch_callers.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/clear_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/collapseall.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/config-tool.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/configure_annotations.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/definingtype_sort_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/fields_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/filterDefines.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/filterInactive.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/filterSystem.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/group_include.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/hierarchy_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/history_list.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/impl_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/inher_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/list-add.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/list-delete.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/list-edit.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/list-movedown.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/list-moveup.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/lock_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/metharg_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/open_incl.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/open_include.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/progress_stop.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/public_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/refresh_nav.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/save_console.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/search_next.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/search_prev.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/search_sortmatch.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/segment_edit.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/shift_l_edit.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/shift_r_edit.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/static_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/sub_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/super_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/synced.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/th_automatic.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/th_horizontal.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/th_showqualified.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/th_single.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/th_vertical.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dlcl16/view_menu.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/action-buildconfig.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/action-deleteconfig.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/action-editconfig.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/action-newconfig.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/build_configs.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/config-category.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/config-compiler.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/config-debug.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/config-librarian.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/config-linker.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/config-preprocessor.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/config-profile.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/config-release.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/config-tool.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/convert-normal.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/exportzip_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/mark_occurrences.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/newc_app.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/newc_lib.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/newcc_app.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/newcc_lib.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/newcfile_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/newclass_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/newcprj_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/newfile_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/newfolder_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/newhfile_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/newmngc_app.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/newmngcc_app.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/newsrcfldr_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/next_error_nav.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/opentype.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/prev_error_nav.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/prj_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/dtool16/prop_edt.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/action-editconfig.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/alphab_sort_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/backward_nav.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/build_exec.png [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/ch_callees.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/ch_callers.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/clear_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/codeassist_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/collapseall.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/config-tool.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/configure_annotations.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/definingtype_sort_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/fields_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/filterDefines.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/filterInactive.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/filterSystem.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/forward_nav.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/goto_input.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/group_include.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/helpprop_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/hierarchy_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/history_list.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/impl_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/inher_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/list-add.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/list-delete.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/list-edit.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/list-movedown.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/list-moveup.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/lock_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/metharg_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/newmngc_app.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/newmngcc_app.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/open_incl.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/open_include.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/progress_stop.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/public_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/refresh_nav.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/save_console.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/search_next.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/search_prev.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/search_sortmatch.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/segment_edit.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/shift_l_edit.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/shift_r_edit.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/static_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/sub_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/super_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/synced.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/templateprop_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/th_automatic.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/th_horizontal.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/th_showqualified.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/th_single.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/th_vertical.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/view_menu.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/elcl16/wordassist_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/action-buildconfig.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/action-deleteconfig.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/action-editconfig.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/action-newconfig.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/build_configs.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/config-category.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/config-compiler.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/config-debug.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/config-librarian.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/config-linker.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/config-preprocessor.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/config-profile.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/config-release.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/config-tool.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/convert-normal.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/exportzip_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/mark_occurrences.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/newc_app.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/newc_lib.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/newcc_app.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/newcc_lib.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/newcfile_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/newclass_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/newcprj_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/newfile_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/newfolder_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/newhfile_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/newmngc_app.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/newmngcc_app.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/newsrcfldr_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/next_error_nav.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/opentype.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/prev_error_nav.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/prj_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/etool16/prop_edt.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/ar_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/archives_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/asm_resource_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/bin_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/binaries_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/breakpoint.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/breakpoint_active.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/breakpoint_disabled.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/build_menu.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/c_file_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/c_resource_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/cdeclaration_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/cfolder_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/ch_resource_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/change.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/class_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/classfo_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/composite_change.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/config.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/container_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/core_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/correction_add.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/correction_change.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/correction_linked_rename.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/correction_rename.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/cp_order_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/cprojects.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/csearch_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/cu_change.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/debugt_obj_b.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/debugt_obj_g.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/debugt_obj_r.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/debugts_obj_b.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/debugts_obj_g.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/debugts_obj_r.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/define_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/enum_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/enumerator_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/enumfo_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/environment.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/error_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/exclusion_filter_attrib.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/exec_dbg_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/exec_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/export_settings_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/extension_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/fatalerror_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/field_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/field_private_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/field_protected_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/field_public_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/file_change.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/filesyst.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/flask.png [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/fldr_lib_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/fldr_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/fldr_sys_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/function_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/h_file_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/hfolder_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/hfolder_prj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/hfolder_quote_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/implm_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/import_settings_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/incc_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/include_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/includes_container.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/info_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/keyword_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/label_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/lib_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/macros_file.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/method_private_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/method_protected_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/method_public_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/namespace_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/never_translate.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/opentype.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/output_folder_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/output_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/over_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/person-me.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/quickassist_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/quickfix_error_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/quickfix_warning_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/s_file_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/search_decl_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/search_ref_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/search_sortmatch.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/searchm_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/shad_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/shlib_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/source_attach_attrib.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/sroot2_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/sroot_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/struct_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/structfo_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/tc_empty.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/tc_preferred.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/template_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/text_edit.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/thread_obj_b.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/thread_obj_g.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/thread_obj_r.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/threads_obj_b.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/threads_obj_g.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/threads_obj_r.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/toolbar_pinned.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/toolbar_pinned_b.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/toolbar_pinned_g.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/toolbar_pinned_multi.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/toolbar_pinned_r.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/typedef_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/typedeffo_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/union_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/unionfo_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/unknown_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/unknown_type_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/using_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/var_declaration_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/variable_local_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/variable_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/warning_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/workspace.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/obj16/wsp_includefolder.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/ovr16/c_ovr.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/ovr16/defines_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/ovr16/error_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/ovr16/external_file.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/ovr16/inactive_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/ovr16/indexedFile.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/ovr16/path_inherit_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/ovr16/read.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/ovr16/readwrite.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/ovr16/rec_referencedby_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/ovr16/rec_relatesto_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/ovr16/referencedby_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/ovr16/relatestoMultiple_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/ovr16/relatesto_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/ovr16/setting_nav.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/ovr16/static_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/ovr16/systeminclude_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/ovr16/template_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/ovr16/volatile_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/ovr16/warning_co.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/ovr16/write.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/view16/buildconsole.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/view16/c_pers.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/view16/call_hierarchy.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/view16/cbrowsing_pers.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/view16/chierch_pers.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/view16/class_hi.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/view16/cprojects.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/view16/cview.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/view16/includeBrowser.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/view16/members.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/view16/namespaces.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/view16/templates.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/view16/types.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/wizban/addpath_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/wizban/c_app_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/wizban/exportzip_wiz.png [new file with mode: 0644]
org.eclipse.cdt.ui/icons/wizban/fieldrefact_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/wizban/methrefact_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/wizban/newcfile_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/wizban/newclass_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/wizban/newcprj_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/wizban/newfile_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/wizban/newfolder_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/wizban/newhfile_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/wizban/newmngc_app.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/wizban/newmngcc_app.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/wizban/newsrcfldr_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/wizban/prj_obj.gif [new file with mode: 0644]
org.eclipse.cdt.ui/icons/wizban/typerefact_wiz.gif [new file with mode: 0644]
org.eclipse.cdt.ui/plugin.properties [new file with mode: 0644]
org.eclipse.cdt.ui/plugin.xml [new file with mode: 0644]
org.eclipse.cdt.ui/schema/CDTWizard.exsd [new file with mode: 0644]
org.eclipse.cdt.ui/schema/CHelpProvider.exsd [new file with mode: 0644]
org.eclipse.cdt.ui/schema/ConfigManager.exsd [new file with mode: 0644]
org.eclipse.cdt.ui/schema/DocCommentOwner.exsd [new file with mode: 0644]
org.eclipse.cdt.ui/schema/HelpInfo.exsd [new file with mode: 0644]
org.eclipse.cdt.ui/schema/IndexerPage.exsd [new file with mode: 0644]
org.eclipse.cdt.ui/schema/PathContainerPage.exsd [new file with mode: 0644]
org.eclipse.cdt.ui/schema/ProposalFilter.exsd [new file with mode: 0644]
org.eclipse.cdt.ui/schema/RefreshExclusionContributor.exsd [new file with mode: 0644]
org.eclipse.cdt.ui/schema/cPropertyTab.exsd [new file with mode: 0644]
org.eclipse.cdt.ui/schema/completionProposalComputer.exsd [new file with mode: 0644]
org.eclipse.cdt.ui/schema/foldingStructureProviders.exsd [new file with mode: 0644]
org.eclipse.cdt.ui/schema/newCfgDialog.exsd [new file with mode: 0644]
org.eclipse.cdt.ui/schema/quickAssistProcessors.exsd [new file with mode: 0644]
org.eclipse.cdt.ui/schema/quickFixProcessors.exsd [new file with mode: 0644]
org.eclipse.cdt.ui/schema/textHovers.exsd [new file with mode: 0644]
org.eclipse.cdt.ui/schema/workingSetConfigurations.exsd [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/CorextMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/CorextMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/AddIncludesOperation.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/StubUtility.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/fix/LinkedProposalModel.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/fix/LinkedProposalPositionGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CContext.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CContextType.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CFormatter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CodeTemplateContext.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CodeTemplateContextType.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CommentContext.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CommentContextType.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/DocCommentContextType.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/ExclusivePositionUpdater.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/FileTemplateContext.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/FileTemplateContextType.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TemplateMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TemplateMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TranslationUnitContext.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TranslationUnitContextType.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CModelUtil.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CodeFormatterUtil.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/Messages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/Resources.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/SimplePositionTracker.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/Strings.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BinaryPropertySource.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CActionFilter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementPropertySource.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CHelpProviderManager.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPerspectiveFactory.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CProjectAdapterFactory.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CStatusConstants.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIException.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIStatus.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DeferredCWorkbenchAdapter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DocumentInputStream.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICElementPropertyConstants.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICStatusConstants.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICThemeConstants.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/IContextMenuConstants.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/LineBackgroundPainter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/MacrosGrouping.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/MembersGrouping.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/PersistableCElementFactory.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ResourceAdapterFactory.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractToggleLinkingAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractUpdateIndexAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionUtil.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AddBlockCommentAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/BlockCommentAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CDTQuickMenuCreator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CompositeActionGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CopyTreeAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/DeleteResConfigsHandler.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ExcludeFromBuildHandler.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FindWordAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingActionGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FreshenIndexAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GoToNextPreviousMemberAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GotoNextBookmarkAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/IndentAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/OpenActionUtil.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RebuildIndexAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RemoveBlockCommentAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SelectAllAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SelectionConverter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectEnclosingAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectHistoryAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectNextAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectPreviousAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectionAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithActionGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/UpdateIndexWithModifiedFilesAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/WorkbenchRunnableAdapter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/BuildPreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsole.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleDocument.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleFactory.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePageParticipant.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartition.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleStreamDecorator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleViewer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildOutputStream.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CBuildConsole.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleEvent.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleOutputTextStore.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CopyBuildLogAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/DocumentMarkerManager.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/GlobalBuildConsole.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/GlobalBuildConsoleManager.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/MultiBuildConsoleAdapter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/NextErrorAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/PreviousErrorAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ScrollLockAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ShowErrorAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CElementSet.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHDropTargetListener.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryDropDownAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHLabelProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefChildNode.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefNode.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHNode.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHReferenceInfo.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CalledByResult.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallsToResult.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/OpenCallHierarchyAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/OpenElementInCallHierarchyAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/ReferenceVisitor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AbstractMergeViewer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AsmContentViewerCreator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AsmMergeViewer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CContentViewerCreator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CMergeViewer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CNode.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreatorVisitor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/BuildGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewActionGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewContentProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewElementComparer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewFrameSource.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMoveAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewRenameAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CollapseAllAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CopyAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/DefaultAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/GotoActionGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/IncludeRefContainer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/IncludeReferenceProxy.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/LibraryRefContainer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/MainActionGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/OpenFileGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/OpenProjectGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/PasteAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/RefactorActionGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/SelectionTransferDragAdapter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/SelectionTransferDropAdapter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/ToggleLinkingAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/AbstractElementListSelectionDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ElementListSelectionDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ISelectionValidator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/IStatusChangeListener.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/MessageLine.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/OptionalMessageDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionList.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionStatusDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusInfo.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusTool.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusUtil.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TypedElementSelectionValidator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TypedViewerFilter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/AbstractPathOptionBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ArchiveFileFilter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElement.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementAttribute.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementFilter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementLabelProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementSorter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPListImageDescriptor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathBasePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerDefaultPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerDescriptor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerEntryPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerSelectionPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathEntryMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathEntryMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathFilterPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathFilterPathPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryBasePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryPerFilePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathLibraryEntryPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathOrderExportPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathOutputEntryPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathProjectsEntryPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathPropertyPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathSourceEntryPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathTabBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ExclusionPatternDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ExclusionPatternEntryDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/FolderSelectionDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/IContainerDescriptor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/IncludesSymbolsPropertyPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/MultipleFolderSelectionDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/NewIncludesSymbolsTabBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/NewSourceFolderDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ProjectContainerDescriptor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ProjectContainerPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/SourceAttachmentBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/SourceAttachmentDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/BasicSelectionTransferDragAdapter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/CDTViewerDragAdapter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/CDTViewerDropAdapter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/DelegatingDragAdapter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/DelegatingDropAdapter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/FileTransferDragAdapter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/FileTransferDropAdapter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/PluginTransferDropAdapter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDragAdapter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDropAdapter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/TextViewerDragAdapter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/TransferDragSourceListener.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/TransferDropTargetListener.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ASTProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CAnnotationIterator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinerProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentSetupParticipant.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorActionContributor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorErrorTickUpdater.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementHyperlink.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementHyperlinkDetector.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CMarkerAnnotation.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSourceViewer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSourceViewerDecorationSupport.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CStorageDocumentProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CTemplatesPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ConstructedCEditorMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ConstructedCEditorMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CustomBufferFactory.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/DefaultBinaryFileEditor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/DocumentAdapter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/EclipsePreferencesAdapter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/EditorHighlightingSynchronizer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ExternalSearchAnnotationModel.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ExternalSearchDocumentProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/GotoAnnotationAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/GotoMatchingBracketAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICAnnotation.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICEditorActionDefinitionIds.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IProblemAnnotation.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ITranslationUnitEditorInput.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/InactiveCodeHighlighting.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IndentUtil.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/LexicalSortingAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OverrideIndicatorImageProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OverrideIndicatorManager.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ProblemAnnotationIterator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SelectionHistory.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlighting.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingManager.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingPresenter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconciler.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticToken.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SortLinesAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SourceHeaderPartnerFinder.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SpecificContentAssistAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SpecificContentAssistExecutor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ToggleCommentAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ToggleMarkOccurrencesAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/TogglePresentationAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ToggleSourceAndHeaderAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/TranslationUnitAnnotationModelEvent.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/WorkingCopyManager.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/ASMEditorActionContributor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmCodeScanner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmContentOutlinePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmDocumentSetupParticipant.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmLabelRule.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmPreprocessorScanner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmReconcilingStrategy.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextEditor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextTools.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmWordDetector.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ArchiveFilter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ClosedProjectFilter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/CustomFiltersDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ExecutableFilter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/FilterDescriptor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/FilterMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/FilterMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ForwardDeclarationFilter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/MacroDirectiveFilter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/NamePatternFilter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/NonCElementFilter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/NonCProjectsFilter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ObjectFilter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/SharedFilter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/UsingDirectiveFilter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CFunctionSummary.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpBook.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpEntry.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpTopic.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBContentProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBConversions.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBDragSourceListener.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBDropTargetListener.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBFile.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryDropDownAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBLabelProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBNode.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBSetInputJob.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBViewPart.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBWorkingSetFilter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IncludeBrowserUI.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/OpenIncludeBrowserAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/CountNodeAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/DiscardExternalDefsAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindDeclarationsAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindReferencesAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexLabelProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexNode.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexView.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexViewSearchQuery.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/OpenDefinitionAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/ToggleLinkingAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ContentTypeMappingDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/FileLanguageMappingPropertyPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageMappingLinkListener.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageMappingWidget.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageVerifier.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectContentTypeMappingDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingPropertyPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingWidget.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceContentTypeMappingDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingPreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingWidget.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/AbstractCNavigatorActionGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorContentProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDragAdapterAssistant.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDropAdapterAssistant.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorEditActionGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorEditActionProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorLabelProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorLinkHelper.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenActionProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenEditorActionGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenViewActionProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorProblemsLabelDecorator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorRefactorActionGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorRefactorActionProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorSearchActionProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/OpenCElementAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/Messages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/Messages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlockPreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractMixedPreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractPreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AppearancePreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildConsolePreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildLogPreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringPreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverPreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypeAssociation.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypeDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CParserPreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CSourcePreviewerUpdater.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CTemplatePreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedPreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistPreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeFormatterPreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplatePreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateSourceViewerConfiguration.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ColorSettingPreviewCode.txt [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingPreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/GlobalBuildLogPreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IPreferenceConfigurationBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerPreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerStrategyBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesConfigurationBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesPreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/NameStyleBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/NameStylePreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OverlayPreferenceStore.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariableDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariablePreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariablesGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesAccess.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreviewSourceViewer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProjectSelectionDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PropertyAndPreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProposalFilterPreferencesUtil.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SaveActionsPreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ScalabilityPreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ScrolledPageContent.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SmartTypingConfigurationBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SmartTypingPreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SpellingConfigurationBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SpellingPreferenceBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskInputDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskPreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/WorkInProgressPreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/AlreadyExistsDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/BracesTabPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CPreview.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CodeFormatterConfigurationBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CommentsTabPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ControlStatementsTabPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CreateProfileDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CustomCodeFormatterBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterModifyDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterProfileManager.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterProfileStore.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterTabPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/IModifyDialogTabPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/IProfileVersioner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/IndentationTabPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/LineWrappingTabPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialogTabPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/NewLinesTabPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileConfigurationBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileManager.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileStore.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileVersioner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/SnippetPreview.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/TranslationUnitPreview.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceOptions.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceTabPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/AddDeclarationNodeToClassChange.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CCompositeChange.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring2.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringContribution.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringDescription.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CTextFileChangeFactory.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeExceptionHandler.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeTreeSet.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Container.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CreateFileChange.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/DeleteFileChange.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/DocumentAdapter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/EqualityChecker.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/IScheduledRefactoring.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/IndexToASTNameHelper.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Messages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Messages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/MethodContext.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ModificationCollector.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NameNVisibilityInformation.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NodeContainer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringASTCache.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringAvailabilityTester.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringExecutionHelper.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringRunner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringRunner2.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringSaveHelper.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringSavePreferences.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringStarter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/UndoCTextFileChange.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Visibility.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/CTextEditChangePreviewViewer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/CreateFileChangePreview.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/ExtractInputPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/LabeledTextField.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/Messages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/Messages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/NameAndVisibilityComposite.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/ValidatingLabeledTextField.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/VisibilitySelectionPanel.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantInfo.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoring.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringContribution.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringDescription.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringRunner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/InputPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/Messages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/Messages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ChooserComposite.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractExpression.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionComposite.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionInformation.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionInputPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringContribution.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringDescription.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringRunner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractStatement.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractedFunctionConstructionHelper.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/Messages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/Messages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/NonExtractableStmtFinder.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ReturnStatementFinder.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/SimilarFinderVisitor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailName.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailNodeEqualityChecker.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoring.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringContribution.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringDescription.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringRunner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/InputPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/Messages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/Messages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/FunctionFactory.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersInputPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoring.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoringRunner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoringWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterContext.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterInsertEditProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterLabelProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterNameGenerator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoring.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringContribution.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringDescription.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringRunner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/Messages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/Messages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodData.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodInputPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoringRunner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoringWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/InsertLocation.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/Messages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/Messages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/MethodDefinitionInsertLocationFinder.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/MethodToImplementConfig.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterHandler.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterInfo.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterNamesInputPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTNameVisitor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTSpecificNameVisitor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringArgument.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatch.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatchStore.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringUtils.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactory.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameClassProcessor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameGlobalProcessor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameIncludeProcessor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMacroProcessor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoring.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringPreferences.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameTypeProcessor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameCSourceFolderChange.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformationPopup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameLinkedMode.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSourceFolder.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSupport.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/TextSearchWrapper.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/DeclaratorFinder.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/EmptyRefactoringDescription.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/IToggleRefactoringStrategy.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/InsertionPointFinder.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/Messages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/Messages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/NotSupportedException.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/RefactoringJob.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFileCreator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromClassToInHeaderStrategy.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromImplementationToHeaderOrClassStrategy.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromInHeaderToClassStrategy.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromInHeaderToImplementationStrategy.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleNodeHelper.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleRefactoring.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleRefactoringContext.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleRefactoringRunner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleStrategyFactory.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/TogglingActionDelegate.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/ASTHelper.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/CPPASTAllVisitor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/Checks.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/DeclarationFinder.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/DeclarationFinderDO.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/DefinitionFinder.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/EclipseObjects.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/ExpressionFinder.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/FileContentHelper.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/FileHelper.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/IdentifierHelper.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/IdentifierResult.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/Messages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/Messages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NameHelper.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NamespaceHelper.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NodeHelper.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/PseudoNameGenerator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/SelectionHelper.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/TranslationUnitHelper.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/VisibilityEnum.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/resources/ResourceExclusionContributor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchUtil.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CountLabelProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/HidePolymorphicCalls.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/IOccurrencesFinder.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/IPDOMSearchContentProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LRUWorkingSets.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LineSearchElement.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LinkedNamesFinder.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OccurrencesFinder.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OpenCSearchPageAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchElement.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchElementQuery.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchLabelProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchListContentProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchListLabelProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchMatch.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPatternQuery.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchResult.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTreeContentProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTreeLabelProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchUnresolvedIncludesQuery.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchViewPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/ProblemSearchElement.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/TypeInfoSearchElement.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/DeclarationsSearchGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsInWorkingSetAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsProjectAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindInWorkingSetAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsInWorkingSetAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsProjectAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindUnresolvedIncludesProjectAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/ReferencesSearchGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionParseAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionSearchGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/WorkingSetFindAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCompareViewerInformationControl.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractInformationControl.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractSourceViewerInformationControl.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/BufferedDocumentScanner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CAutoIndentStrategy.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CBraceRule.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CBreakIterator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeReader.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeScanner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCommentScanner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCompositeReconcilingStrategy.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CDoubleClickSelector.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CFormattingStrategy.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeaderRule.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpBookDescriptor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpProviderDescriptor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpSettings.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeuristicScanner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COperatorRule.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPairMatcher.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CParameterListValidator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPreprocessorScanner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPresentationReconciler.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconciler.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconcilingStrategy.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerScalableConfiguration.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CStringAutoIndentStrategy.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CStringDoubleClickSelector.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CTextTools.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CWhitespaceRule.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CWordFinder.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CWordIterator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CombinedWordRule.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CompositeReconcilingStrategy.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/DocumentCharacterIterator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitionScanner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitioner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLAnnotationHover.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLPrinter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/ICReconcilingListener.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IHtmlTagConstants.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IProblemRequestorExtension.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/LineComparator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/NumberRule.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/PartitionDamager.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/PreprocessorRule.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SequenceCharacterIterator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SimpleCSourceViewerConfiguration.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleCharReader.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleCharRule.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleTokenCScanner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SubstitutionTextReader.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/Symbols.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TabsToSpacesConverter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TaskTagRule.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TokenStore.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/asm/AsmPartitionScanner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AbstractAnnotationHover.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AbstractCEditorTextHover.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AnnotationHover.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/BestMatchHover.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CDocHover.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CEditorTextHoverDescriptor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CEditorTextHoverProxy.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CHoverMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CHoverMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CInformationProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroCompareViewer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionControl.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionExplorationControl.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionHover.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionInformationProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionInput.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CTypeHover.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/ProblemHover.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/SourceViewerInformationControl.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposal.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposalComparator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistInvocationContext.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistProcessor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CProposalContextInformation.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalCategory.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerDescriptor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerRegistry.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistComputerParameter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistHandler.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPreference.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistProcessor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DefaultProposalFilter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HelpCompletionProposalComputer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HippieProposalComputer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/InclusionProposalComputer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/KeywordCompletionProposalComputer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParsingBasedProposalComputer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/RelevanceConstants.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/TemplateCompletionProposalComputer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionAssistant.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionProcessor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CSelectAnnotationRulerAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CSelectRulerAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ContributedProcessorDescriptor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandHandler.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandInstaller.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionContext.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ICommandAccess.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/IStatusLineProposal.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/MarkerResolutionProposal.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ProblemLocation.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistLightBulbUpdater.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistProcessor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/ASTRewriteCorrectionProposal.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/ChangeCorrectionProposal.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedCorrectionProposal.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedNamesAssistProposal.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/RenameRefactoringProposal.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/TUCorrectionProposal.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/AbstractDocCommentProposalComputer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentMultilineProposalComputer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentOwner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentOwnerManager.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentSinglelineProposalComputer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentSpellDictionary.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/EditorReopener.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/Messages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/NullDocCommentOwner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/NullDocCommentViewerConfiguration.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/ProjectMap.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/messages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/CFoldingStructureProviderDescriptor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/CFoldingStructureProviderRegistry.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingPreferenceBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructureProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/EmptyCFoldingPreferenceBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/FoldingMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/FoldingMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/AddWordProposal.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingEngine.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingProblem.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingReconcileStrategy.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingService.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/ChangeCaseProposal.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CoreSpellingProblem.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/DisableSpellCheckingProposal.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/HtmlTagDictionary.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/Messages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/Messages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckEngine.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckIterator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingEngine.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingEngineDispatcher.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingPreferences.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/TaskTagDictionary.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/TextSpellingEngine.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordCompletionProposalComputer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordCorrectionProposal.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordIgnoreProposal.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordQuickFixProcessor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/AbstractSpellDictionary.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultPhoneticDistanceAlgorithm.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultPhoneticHashProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultSpellChecker.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/IPhoneticDistanceAlgorithm.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/IPhoneticHashProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellCheckEngine.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellCheckIterator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellChecker.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellDictionary.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellEvent.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellEventListener.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/LocaleSensitiveSpellDictionary.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/PersistentSpellDictionary.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/RankedWordProposal.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/SpellEvent.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateEngine.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProcessor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProposal.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CColorManager.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CWhitespaceDetector.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CWordDetector.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/ITHModelPresenter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/Messages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/OpenTypeHierarchyAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/OpenTypeInHierarchyAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THContentProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THDropTargetListener.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraph.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraphEdge.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraphNode.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHierarchyModel.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryDropDownAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryListAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THInformationControl.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THInformationProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THLabelProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THMemberContentProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THNode.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THSchedulingRule.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THViewPart.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/TypeHierarchyUI.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/messages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/BusyIndicatorRunnableContext.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CHelpDisplayContext.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CUIHelp.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CoreUtility.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/DeleteIProblemMarkerAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/DeleteTaskAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExceptionHandler.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExternalEditorInput.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExternalEditorInputFactory.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/IDebugLogConstants.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/IProblemChangedListener.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ImageDescriptorRegistry.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/Messages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/Messages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/NameComposer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/OpenExternalProblemAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/PendingUpdateAdapter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemMarkerManager.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemTableViewer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemTreeViewer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/RemoteTreeContentManager.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/RemoteTreeViewer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ResourceToItemsMapper.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/RowLayouter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SWTUtil.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SelectionUtil.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/StatusLineHandler.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/StringMatcher.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/TableLayoutComposite.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/TwoArrayQuickSort.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/Util.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ViewerPane.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AdaptingSelectionProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AppearanceAwareLabelProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AsyncTreeContentProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AsyncTreeWorkInProgressNode.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/BasicElementLabels.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CDTContextActivator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabelComposer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabels.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CUILabelProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ColoredViewersManager.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ColoringLabelProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/DecoratingCLabelProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/EditorOpener.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ExcludedFileDecorator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ExtendedTreeViewer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ISelectionListenerWithAST.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IViewPartInputProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ImageImageDescriptor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesCache.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesLabelProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/LinkedProposalModelPresenter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ListContentProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilterAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/Messages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProblemsLabelDecorator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProjectTemplateStore.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionListenerWithASTManager.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionProviderMediator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StandardCElementLabelProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StatusBarUpdater.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StorageLabelProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/TreeNavigator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/WorkingSetFilter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/WorkingSetFilterUI.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/messages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/AbstractOpenWizardAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/AbstractWizardDropDownAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/CWizardRegistry.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/ICDTCommonProjectWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewClassCreationWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewElementWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewElementWizardPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewFileDropDownAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewFolderDropDownAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewProjectDropDownAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewTypeDropDownAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewWizardMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewWizardMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/OpenNewWizardAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/SourceFolderSelectionDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/AbstractMethodStub.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassInfo.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesLabelProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesListDialogField.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/ConstructorMethodStub.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/DestructorMethodStub.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/EnclosingClassSelectionDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/IBaseClassInfo.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/IMethodStub.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsLabelProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsListDialogField.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NamespaceSelectionDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewBaseClassSelectionDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardPrefs.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/SourceFileSelectionDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/CheckedListDialogField.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ComboDialogField.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/DialogField.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IDialogFieldListener.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IListAdapter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IStringButtonAdapter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ITreeListAdapter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LayoutUtil.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LinkToFileGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogField.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogFieldGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/Separator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringButtonDialogField.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringDialogField.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/TreeListDialogField.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizardPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileFromTemplateWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileWizardMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileWizardMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewHeaderFileCreationWizardPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileCreationWizardPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileGenerator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/WizardNewFileFromTemplateCreationPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewFolderWizardMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewFolderWizardMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewSourceFolderWizardPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/Messages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/StringVariableLabelProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/StringVariableSelectionDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectIndexExportWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectIndexExportWizardPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/messages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IProjectSettingsWizardPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IProjectSettingsWizardPageStrategy.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ISettingsProcessor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IncludePathsSettingsProcessor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/MacroSettingsProcessor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/Messages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsExportStrategy.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsExportWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsImportStrategy.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsImportWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsWizardPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/SettingsImportExportException.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/SettingsProcessor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/XMLUtils.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/messages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/AbstractWorkingSetConfigsContribution.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/AbstractWorkingSetsContribution.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ActivateWorkingSetConfigsContribution.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ActivateWorkingSetsContribution.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/BuildJob.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/BuildWorkingSetConfigsContribution.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/BuildWorkingSetsContribution.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetPageContentProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetUpdater.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetConfiguration.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetConfigurationElement.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfiguration.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfigurationController.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfigurationFactory.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProxy.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ProjectConfigsController.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ProjectConfigurationController.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigsController.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfiguration.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationManager.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationsPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetProjectConfiguration.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetPropertyTester.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetProxy.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkspaceSnapshot.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTSharedImages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTUIImages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTUITools.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementContentProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementGrouping.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementImageDescriptor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementLabelProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementSorter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPreferenceInitializer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CodeGeneration.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/FunctionPrototypeSummary.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IBuildConsoleEvent.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IBuildConsoleListener.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IBuildConsoleManager.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICDTConstants.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpBook.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpResourceDescriptor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IEditorInputDelegate.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IFunctionSummary.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ILanguageUI.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IPropertyChangeParticipant.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IRequiredInclude.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IWorkingCopyManager.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IWorkingCopyManagerExtension.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IncludesGrouping.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/Messages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/Messages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/NamespacesGrouping.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/BuildActiveConfigMenuAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/BuildConfigAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/CdtActionConstants.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigActionBase.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigContextAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigMenuAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeConfigAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/CustomFiltersActionGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/DeleteResConfigsAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ExcludeFromBuildAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/FormatAllAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/GenerateActionGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ManageConfigsAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/MemberFilterActionGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/OpenAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/OpenViewActionGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/SelectionDispatchAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ShowInCViewAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/WorkingSetConfigAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoLabelProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractBinaryParserPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractCOptionPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractErrorParserBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractGNUBinaryParserPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractIndexerPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/BinaryParserBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CHelpConfigurationPropertyPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CacheSizeBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CygwinPEBinaryParserPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DOMSourceIndexerBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerCombo.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerComposite.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/FastIndexerBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/GNUElfBinaryParserPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/GNUSomBinaryParserPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/GNUXCoffBinaryParserPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ICOptionContainer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ICOptionContainerExtension.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ICOptionPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IInputStatusValidator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerOptionPropertyPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/InputStatusDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/MachOBinaryParserPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/NullIndexerBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/PreferenceScopeBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ReferenceBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/RegularExpressionStatusDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/TabFolderOptionBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/internal/templateengine/wizard/TemplateCNewWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractExportTab.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPrefPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPropertyDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractSinglePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/BinaryParsTab.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/BuildVarListDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTHelpContextIds.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTPrefUtil.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTPropertyManager.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTStatusInfo.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTUIListComparator.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationOutputTab.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationSourceTab.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationTab.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ConfigMultiSelectionDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvironmentTab.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ErrorParsTab.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternEntryDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpIncludeFileTab.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpIncludeTab.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpLibraryPathTab.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpLibraryTab.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpSymbolTab.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyTab.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IConfigManager.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/INewCfgDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ImportExportWizardButtons.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeFileTab.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeTab.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryPathTab.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryTab.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigRunner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigSelector.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/MultiCfgContributedEnvironment.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/MultiLineTextFieldEditor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/NewConfigurationDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PageLayout.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_head_general.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PrefPage_Abstract.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ProjectContentsArea.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PropertyTester.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RefsTab.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RenameConfigurationDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/StringListModeControl.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/StructureTreeTab.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolTab.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/TypedCDTViewerFilter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/UIMessages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/CTextFileChange.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/CRefactoringActionGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/CRenameAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractConstantAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractFunctionAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractLocalVariableAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/GettersAndSettersAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/HideMethodAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ImplementMethodAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/Messages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/RefactoringAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ToggleFunctionAction.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/messages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/resources/Messages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/resources/RefreshExclusionContributionManager.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/resources/RefreshExclusionContributor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/resources/messages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/AbstractWizardDataPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/FormBrowser.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/IPagesAfterTemplateSelectionProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/ITemplatesListProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/IWizardDataPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/Messages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/ProjectSelectionPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/SimpleElementException.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/Template.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/TemplateClassWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/TemplateDrivenWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/TemplateEngineUI.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/TemplateEngineUIUtil.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/TemplateListSelectionPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/TemplatesChoiceWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/WizardNode.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/event/PatternEvent.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/event/PatternEventListener.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/messages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/pages/Messages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/pages/NewProjectCreationPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/pages/TemplateInputDialog.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/pages/TemplatePreferencePage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/pages/UIPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/pages/UIPagesProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/pages/UIWizardPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/pages/messages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/processes/Messages.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/processes/OpenFiles.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/processes/messages.properties [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/GenericUIElementGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/IPageTypeConstants.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/IPatternMatchingTable.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/IUIElementTreeBuilderHelper.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/IUIElementTreeBuilderManager.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/InputUIElement.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/SimpleUIElementGroup.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/UIAttributes.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/UIElement.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/UIElementTreeBuilderHelper.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/UIElementTreeBuilderManager.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/UIGroupTypeEnum.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UIBooleanWidget.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UIBrowseWidget.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UIComposite.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UISelectWidget.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UISpecialListWidget.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UIStringListWidget.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UITextWidget.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/AbstractCScanner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/AsmSourceViewerConfiguration.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/CSourceViewerConfiguration.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICColorConstants.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICCompletionProposal.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICHelpInvocationContext.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICPartitions.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICTokenScanner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IColorManager.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IContentAssistHelpInvocationContext.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IHoverHelpInvocationContext.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IInvocationContext.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IProblemLocation.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IQuickAssistProcessor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IQuickFixProcessor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ITokenStore.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ITokenStoreFactory.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/SharedASTJob.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/TaskTagRule.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/c/hover/ICEditorTextHover.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ContentAssistInvocationContext.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICEditorContentAssistInvocationContext.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICompletionContributor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICompletionProposalComputer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/IProposalFilter.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/DefaultMultilineCommentAutoEditStrategy.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentDictionary.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentOwner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentOwnershipListener.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentSimpleDictionary.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentViewerConfiguration.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenHelper.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineAutoEditStrategy.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineConfiguration.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenSingleConfiguration.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/AbstractGenericTagDocCommentViewerConfiguration.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericDocTag.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagCommentScanner.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagCompletionProposalComputer.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagDoubleClickStrategy.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagSimpleDictionary.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/folding/ICFoldingPreferenceBlock.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/folding/ICFoldingStructureProvider.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CCProjectWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTCommonProjectWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTMainWizardPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTProjectWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CNewWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CProjectWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CWizardHandler.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/EntryDescriptor.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/ICPathContainerPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/IPathEntryContainerPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/IWizardItemsListListener.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/IWizardWithMemory.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCCProjectWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizardOptionPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizardPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewFileCreationWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewFolderCreationWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewHeaderFileCreationWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewSourceFileCreationWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewSourceFolderCreationWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConversionWizard.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConvertProjectWizardPage.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/utils/ui/controls/ControlFactory.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/utils/ui/controls/FileListControl.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/utils/ui/controls/IFileListChangeListener.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/utils/ui/controls/RadioButtonsArea.java [new file with mode: 0644]
org.eclipse.cdt.ui/src/org/eclipse/cdt/utils/ui/controls/TabFolderLayout.java [new file with mode: 0644]
org.eclipse.cdt.ui/templates/default-codetemplates.xml [new file with mode: 0644]
org.eclipse.cdt.ui/templates/default-filetemplates.xml [new file with mode: 0644]
org.eclipse.cdt.ui/templates/default-templates.properties [new file with mode: 0644]
org.eclipse.cdt.ui/templates/default-templates.xml [new file with mode: 0644]
org.eclipse.jst.pagedesigner.patch/src/org/eclipse/jst/pagedesigner/editors/HTMLEditor.java [new file with mode: 0755]
org.eclipse.jst.pagedesigner/icons/PD_Toolbar_designer.gif
org.eclipse.jst.pagedesigner/icons/PD_Toolbar_hsplit.gif
org.eclipse.jst.pagedesigner/icons/PD_Toolbar_source.gif
org.eclipse.jst.pagedesigner/icons/PD_Toolbar_vsplit.gif
org.tizen.base.feature/feature.xml
org.tizen.base.feature/rootfiles_for_linux/startup.sh [changed mode: 0644->0755]
org.tizen.base.platform/META-INF/MANIFEST.MF
org.tizen.base.platform/OSGI-INF/l10n/bundle.properties
org.tizen.base.platform/TizenIDE_base_linux.product
org.tizen.base.platform/TizenIDE_base_windows.product
org.tizen.base.platform/about.ini
org.tizen.base.platform/about.mappings
org.tizen.base.platform/about.properties
org.tizen.base.platform/content/home.html
org.tizen.base.platform/plugin.xml
package/base-ide-product.install.linux
package/base-ide-product.install.windows
package/base-ide-product.remove.linux
package/base-ide-product.remove.windows
package/build.linux
package/pkginfo.manifest

diff --git a/org.eclipse.cdt.platform/.project b/org.eclipse.cdt.platform/.project
new file mode 100644 (file)
index 0000000..658edcf
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.eclipse.cdt.platform</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.pde.FeatureBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.FeatureNature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.eclipse.cdt.platform/build.properties b/org.eclipse.cdt.platform/build.properties
new file mode 100644 (file)
index 0000000..60e19e5
--- /dev/null
@@ -0,0 +1,5 @@
+bin.includes = eclipse_update_120.jpg,\
+               epl-v10.html,\
+               feature.properties,\
+               feature.xml,\
+               license.html
diff --git a/org.eclipse.cdt.platform/eclipse_update_120.jpg b/org.eclipse.cdt.platform/eclipse_update_120.jpg
new file mode 100644 (file)
index 0000000..bfdf708
Binary files /dev/null and b/org.eclipse.cdt.platform/eclipse_update_120.jpg differ
diff --git a/org.eclipse.cdt.platform/epl-v10.html b/org.eclipse.cdt.platform/epl-v10.html
new file mode 100644 (file)
index 0000000..ed4b196
--- /dev/null
@@ -0,0 +1,328 @@
+<html xmlns:o="urn:schemas-microsoft-com:office:office"
+xmlns:w="urn:schemas-microsoft-com:office:word"
+xmlns="http://www.w3.org/TR/REC-html40">
+
+<head>
+<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
+<meta name=ProgId content=Word.Document>
+<meta name=Generator content="Microsoft Word 9">
+<meta name=Originator content="Microsoft Word 9">
+<link rel=File-List
+href="./Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml">
+<title>Eclipse Public License - Version 1.0</title>
+<!--[if gte mso 9]><xml>
+ <o:DocumentProperties>
+  <o:Revision>2</o:Revision>
+  <o:TotalTime>3</o:TotalTime>
+  <o:Created>2004-03-05T23:03:00Z</o:Created>
+  <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved>
+  <o:Pages>4</o:Pages>
+  <o:Words>1626</o:Words>
+  <o:Characters>9270</o:Characters>
+   <o:Lines>77</o:Lines>
+  <o:Paragraphs>18</o:Paragraphs>
+  <o:CharactersWithSpaces>11384</o:CharactersWithSpaces>
+  <o:Version>9.4402</o:Version>
+ </o:DocumentProperties>
+</xml><![endif]--><!--[if gte mso 9]><xml>
+ <w:WordDocument>
+  <w:TrackRevisions/>
+ </w:WordDocument>
+</xml><![endif]-->
+<style>
+<!--
+ /* Font Definitions */
+@font-face
+       {font-family:Tahoma;
+       panose-1:2 11 6 4 3 5 4 4 2 4;
+       mso-font-charset:0;
+       mso-generic-font-family:swiss;
+       mso-font-pitch:variable;
+       mso-font-signature:553679495 -2147483648 8 0 66047 0;}
+ /* Style Definitions */
+p.MsoNormal, li.MsoNormal, div.MsoNormal
+       {mso-style-parent:"";
+       margin:0in;
+       margin-bottom:.0001pt;
+       mso-pagination:widow-orphan;
+       font-size:12.0pt;
+       font-family:"Times New Roman";
+       mso-fareast-font-family:"Times New Roman";}
+p
+       {margin-right:0in;
+       mso-margin-top-alt:auto;
+       mso-margin-bottom-alt:auto;
+       margin-left:0in;
+       mso-pagination:widow-orphan;
+       font-size:12.0pt;
+       font-family:"Times New Roman";
+       mso-fareast-font-family:"Times New Roman";}
+p.BalloonText, li.BalloonText, div.BalloonText
+       {mso-style-name:"Balloon Text";
+       margin:0in;
+       margin-bottom:.0001pt;
+       mso-pagination:widow-orphan;
+       font-size:8.0pt;
+       font-family:Tahoma;
+       mso-fareast-font-family:"Times New Roman";}
+@page Section1
+       {size:8.5in 11.0in;
+       margin:1.0in 1.25in 1.0in 1.25in;
+       mso-header-margin:.5in;
+       mso-footer-margin:.5in;
+       mso-paper-source:0;}
+div.Section1
+       {page:Section1;}
+-->
+</style>
+</head>
+
+<body lang=EN-US style='tab-interval:.5in'>
+
+<div class=Section1>
+
+<p align=center style='text-align:center'><b>Eclipse Public License - v 1.0</b>
+</p>
+
+<p><span style='font-size:10.0pt'>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
+THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE,
+REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
+OF THIS AGREEMENT.</span> </p>
+
+<p><b><span style='font-size:10.0pt'>1. DEFINITIONS</span></b> </p>
+
+<p><span style='font-size:10.0pt'>&quot;Contribution&quot; means:</span> </p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
+in the case of the initial Contributor, the initial code and documentation
+distributed under this Agreement, and<br clear=left>
+b) in the case of each subsequent Contributor:</span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
+changes to the Program, and</span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
+additions to the Program;</span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>where
+such changes and/or additions to the Program originate from and are distributed
+by that particular Contributor. A Contribution 'originates' from a Contributor
+if it was added to the Program by such Contributor itself or anyone acting on
+such Contributor's behalf. Contributions do not include additions to the
+Program which: (i) are separate modules of software distributed in conjunction
+with the Program under their own license agreement, and (ii) are not derivative
+works of the Program. </span></p>
+
+<p><span style='font-size:10.0pt'>&quot;Contributor&quot; means any person or
+entity that distributes the Program.</span> </p>
+
+<p><span style='font-size:10.0pt'>&quot;Licensed Patents &quot; mean patent
+claims licensable by a Contributor which are necessarily infringed by the use
+or sale of its Contribution alone or when combined with the Program. </span></p>
+
+<p><span style='font-size:10.0pt'>&quot;Program&quot; means the Contributions
+distributed in accordance with this Agreement.</span> </p>
+
+<p><span style='font-size:10.0pt'>&quot;Recipient&quot; means anyone who
+receives the Program under this Agreement, including all Contributors.</span> </p>
+
+<p><b><span style='font-size:10.0pt'>2. GRANT OF RIGHTS</span></b> </p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
+Subject to the terms of this Agreement, each Contributor hereby grants Recipient
+a non-exclusive, worldwide, royalty-free copyright license to<span
+style='color:red'> </span>reproduce, prepare derivative works of, publicly
+display, publicly perform, distribute and sublicense the Contribution of such
+Contributor, if any, and such derivative works, in source code and object code
+form.</span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
+Subject to the terms of this Agreement, each Contributor hereby grants
+Recipient a non-exclusive, worldwide,<span style='color:green'> </span>royalty-free
+patent license under Licensed Patents to make, use, sell, offer to sell, import
+and otherwise transfer the Contribution of such Contributor, if any, in source
+code and object code form. This patent license shall apply to the combination
+of the Contribution and the Program if, at the time the Contribution is added
+by the Contributor, such addition of the Contribution causes such combination
+to be covered by the Licensed Patents. The patent license shall not apply to
+any other combinations which include the Contribution. No hardware per se is
+licensed hereunder. </span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>c)
+Recipient understands that although each Contributor grants the licenses to its
+Contributions set forth herein, no assurances are provided by any Contributor
+that the Program does not infringe the patent or other intellectual property
+rights of any other entity. Each Contributor disclaims any liability to Recipient
+for claims brought by any other entity based on infringement of intellectual
+property rights or otherwise. As a condition to exercising the rights and
+licenses granted hereunder, each Recipient hereby assumes sole responsibility
+to secure any other intellectual property rights needed, if any. For example,
+if a third party patent license is required to allow Recipient to distribute
+the Program, it is Recipient's responsibility to acquire that license before
+distributing the Program.</span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>d)
+Each Contributor represents that to its knowledge it has sufficient copyright
+rights in its Contribution, if any, to grant the copyright license set forth in
+this Agreement. </span></p>
+
+<p><b><span style='font-size:10.0pt'>3. REQUIREMENTS</span></b> </p>
+
+<p><span style='font-size:10.0pt'>A Contributor may choose to distribute the
+Program in object code form under its own license agreement, provided that:</span>
+</p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
+it complies with the terms and conditions of this Agreement; and</span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
+its license agreement:</span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
+effectively disclaims on behalf of all Contributors all warranties and
+conditions, express and implied, including warranties or conditions of title
+and non-infringement, and implied warranties or conditions of merchantability
+and fitness for a particular purpose; </span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
+effectively excludes on behalf of all Contributors all liability for damages,
+including direct, indirect, special, incidental and consequential damages, such
+as lost profits; </span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iii)
+states that any provisions which differ from this Agreement are offered by that
+Contributor alone and not by any other party; and</span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iv)
+states that source code for the Program is available from such Contributor, and
+informs licensees how to obtain it in a reasonable manner on or through a
+medium customarily used for software exchange.<span style='color:blue'> </span></span></p>
+
+<p><span style='font-size:10.0pt'>When the Program is made available in source
+code form:</span> </p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
+it must be made available under this Agreement; and </span></p>
+
+<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) a
+copy of this Agreement must be included with each copy of the Program. </span></p>
+
+<p><span style='font-size:10.0pt'>Contributors may not remove or alter any
+copyright notices contained within the Program. </span></p>
+
+<p><span style='font-size:10.0pt'>Each Contributor must identify itself as the
+originator of its Contribution, if any, in a manner that reasonably allows
+subsequent Recipients to identify the originator of the Contribution. </span></p>
+
+<p><b><span style='font-size:10.0pt'>4. COMMERCIAL DISTRIBUTION</span></b> </p>
+
+<p><span style='font-size:10.0pt'>Commercial distributors of software may
+accept certain responsibilities with respect to end users, business partners
+and the like. While this license is intended to facilitate the commercial use
+of the Program, the Contributor who includes the Program in a commercial
+product offering should do so in a manner which does not create potential
+liability for other Contributors. Therefore, if a Contributor includes the
+Program in a commercial product offering, such Contributor (&quot;Commercial
+Contributor&quot;) hereby agrees to defend and indemnify every other
+Contributor (&quot;Indemnified Contributor&quot;) against any losses, damages and
+costs (collectively &quot;Losses&quot;) arising from claims, lawsuits and other
+legal actions brought by a third party against the Indemnified Contributor to
+the extent caused by the acts or omissions of such Commercial Contributor in
+connection with its distribution of the Program in a commercial product
+offering. The obligations in this section do not apply to any claims or Losses
+relating to any actual or alleged intellectual property infringement. In order
+to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
+Contributor in writing of such claim, and b) allow the Commercial Contributor
+to control, and cooperate with the Commercial Contributor in, the defense and
+any related settlement negotiations. The Indemnified Contributor may participate
+in any such claim at its own expense.</span> </p>
+
+<p><span style='font-size:10.0pt'>For example, a Contributor might include the
+Program in a commercial product offering, Product X. That Contributor is then a
+Commercial Contributor. If that Commercial Contributor then makes performance
+claims, or offers warranties related to Product X, those performance claims and
+warranties are such Commercial Contributor's responsibility alone. Under this
+section, the Commercial Contributor would have to defend claims against the
+other Contributors related to those performance claims and warranties, and if a
+court requires any other Contributor to pay any damages as a result, the
+Commercial Contributor must pay those damages.</span> </p>
+
+<p><b><span style='font-size:10.0pt'>5. NO WARRANTY</span></b> </p>
+
+<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
+AGREEMENT, THE PROGRAM IS PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
+WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
+MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
+responsible for determining the appropriateness of using and distributing the
+Program and assumes all risks associated with its exercise of rights under this
+Agreement , including but not limited to the risks and costs of program errors,
+compliance with applicable laws, damage to or loss of data, programs or
+equipment, and unavailability or interruption of operations. </span></p>
+
+<p><b><span style='font-size:10.0pt'>6. DISCLAIMER OF LIABILITY</span></b> </p>
+
+<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
+AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
+THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGES.</span> </p>
+
+<p><b><span style='font-size:10.0pt'>7. GENERAL</span></b> </p>
+
+<p><span style='font-size:10.0pt'>If any provision of this Agreement is invalid
+or unenforceable under applicable law, it shall not affect the validity or
+enforceability of the remainder of the terms of this Agreement, and without
+further action by the parties hereto, such provision shall be reformed to the
+minimum extent necessary to make such provision valid and enforceable.</span> </p>
+
+<p><span style='font-size:10.0pt'>If Recipient institutes patent litigation
+against any entity (including a cross-claim or counterclaim in a lawsuit)
+alleging that the Program itself (excluding combinations of the Program with
+other software or hardware) infringes such Recipient's patent(s), then such
+Recipient's rights granted under Section 2(b) shall terminate as of the date
+such litigation is filed. </span></p>
+
+<p><span style='font-size:10.0pt'>All Recipient's rights under this Agreement
+shall terminate if it fails to comply with any of the material terms or
+conditions of this Agreement and does not cure such failure in a reasonable
+period of time after becoming aware of such noncompliance. If all Recipient's
+rights under this Agreement terminate, Recipient agrees to cease use and
+distribution of the Program as soon as reasonably practicable. However,
+Recipient's obligations under this Agreement and any licenses granted by
+Recipient relating to the Program shall continue and survive. </span></p>
+
+<p><span style='font-size:10.0pt'>Everyone is permitted to copy and distribute
+copies of this Agreement, but in order to avoid inconsistency the Agreement is
+copyrighted and may only be modified in the following manner. The Agreement
+Steward reserves the right to publish new versions (including revisions) of
+this Agreement from time to time. No one other than the Agreement Steward has
+the right to modify this Agreement. The Eclipse Foundation is the initial
+Agreement Steward. The Eclipse Foundation may assign the responsibility to
+serve as the Agreement Steward to a suitable separate entity. Each new version
+of the Agreement will be given a distinguishing version number. The Program
+(including Contributions) may always be distributed subject to the version of
+the Agreement under which it was received. In addition, after a new version of
+the Agreement is published, Contributor may elect to distribute the Program
+(including its Contributions) under the new version. Except as expressly stated
+in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
+the intellectual property of any Contributor under this Agreement, whether
+expressly, by implication, estoppel or otherwise. All rights in the Program not
+expressly granted under this Agreement are reserved.</span> </p>
+
+<p><span style='font-size:10.0pt'>This Agreement is governed by the laws of the
+State of New York and the intellectual property laws of the United States of
+America. No party to this Agreement will bring a legal action under this
+Agreement more than one year after the cause of action arose. Each party waives
+its rights to a jury trial in any resulting litigation.</span> </p>
+
+<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
+
+</div>
+
+</body>
+
+</html>
\ No newline at end of file
diff --git a/org.eclipse.cdt.platform/feature.properties b/org.eclipse.cdt.platform/feature.properties
new file mode 100644 (file)
index 0000000..8e5dfa7
--- /dev/null
@@ -0,0 +1,167 @@
+###############################################################################
+#  Copyright (c) 2005, 2011 IBM Corporation and others.
+#  All rights reserved. This program and the accompanying materials
+#  are made available under the terms of the Eclipse Public License v1.0
+#  which accompanies this distribution, and is available at
+#  http://www.eclipse.org/legal/epl-v10.html
+# 
+#  Contributors:
+#     IBM Corporation - initial API and implementation
+###############################################################################
+# features.properties
+# contains externalized strings for feature.xml
+# "%foo" in feature.xml corresponds to the key "foo" in this file
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# This file should be translated.
+
+# "featureName" property - name of the feature
+featureName=C/C++ Development Platform
+
+# "providerName" property - name of the company that provides the feature
+providerName=Eclipse CDT
+
+# "updateSiteName" property - label for the update site
+updateSiteName=Eclipse CDT Update Site
+
+# "description" property - description of the feature
+description=Eclipse C/C++ development platform. Contains no toolchain integrations. Included in C/C++ Development Tools.
+
+# copyright
+copyright=\
+Copyright (c) 2002, 2011 QNX Software Systems and others.\n\
+All rights reserved. This program and the accompanying materials\n\
+are made available under the terms of the Eclipse Public License v1.0\n\
+which accompanies this distribution, and is available at\n\
+http://www.eclipse.org/legal/epl-v10.html
+
+# "licenseURL" property - URL of the "Feature License"
+# do not translate value - just change to point to a locale-specific HTML page
+licenseURL=license.html
+
+# "license" property - text of the "Feature Update License"
+# should be plain text version of license agreement pointed to be "licenseURL"
+license=\
+Eclipse Foundation Software User Agreement\n\
+February 1, 2011\n\
+\n\
+Usage Of Content\n\
+\n\
+THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\
+OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\
+USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\
+AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\
+NOTICES INDICATED OR REFERENCED BELOW.  BY USING THE CONTENT, YOU\n\
+AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\
+AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\
+OR NOTICES INDICATED OR REFERENCED BELOW.  IF YOU DO NOT AGREE TO THE\n\
+TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\
+OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\
+BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\
+\n\
+Applicable Licenses\n\
+\n\
+Unless otherwise indicated, all Content made available by the\n\
+Eclipse Foundation is provided to you under the terms and conditions of\n\
+the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is\n\
+provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\
+For purposes of the EPL, "Program" will mean the Content.\n\
+\n\
+Content includes, but is not limited to, source code, object code,\n\
+documentation and other files maintained in the Eclipse Foundation source code\n\
+repository ("Repository") in software modules ("Modules") and made available\n\
+as downloadable archives ("Downloads").\n\
+\n\
+       - Content may be structured and packaged into modules to facilitate delivering,\n\
+         extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\
+         plug-in fragments ("Fragments"), and features ("Features").\n\
+       - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java(TM) ARchive)\n\
+         in a directory named "plugins".\n\
+       - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\
+         Each Feature may be packaged as a sub-directory in a directory named "features".\n\
+         Within a Feature, files named "feature.xml" may contain a list of the names and version\n\
+         numbers of the Plug-ins and/or Fragments associated with that Feature.\n\
+       - Features may also include other Features ("Included Features"). Within a Feature, files\n\
+         named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\
+\n\
+The terms and conditions governing Plug-ins and Fragments should be\n\
+contained in files named "about.html" ("Abouts"). The terms and\n\
+conditions governing Features and Included Features should be contained\n\
+in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\
+Licenses may be located in any directory of a Download or Module\n\
+including, but not limited to the following locations:\n\
+\n\
+       - The top-level (root) directory\n\
+       - Plug-in and Fragment directories\n\
+       - Inside Plug-ins and Fragments packaged as JARs\n\
+       - Sub-directories of the directory named "src" of certain Plug-ins\n\
+       - Feature directories\n\
+\n\
+Note: if a Feature made available by the Eclipse Foundation is installed using the\n\
+Provisioning Technology (as defined below), you must agree to a license ("Feature \n\
+Update License") during the installation process. If the Feature contains\n\
+Included Features, the Feature Update License should either provide you\n\
+with the terms and conditions governing the Included Features or inform\n\
+you where you can locate them. Feature Update Licenses may be found in\n\
+the "license" property of files named "feature.properties" found within a Feature.\n\
+Such Abouts, Feature Licenses, and Feature Update Licenses contain the\n\
+terms and conditions (or references to such terms and conditions) that\n\
+govern your use of the associated Content in that directory.\n\
+\n\
+THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER\n\
+TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\
+SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\
+\n\
+       - Eclipse Distribution License Version 1.0 (available at http://www.eclipse.org/licenses/edl-v1.0.html)\n\
+       - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\
+       - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\
+       - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\
+       - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\
+       - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\
+\n\
+IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\
+TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License\n\
+is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\
+govern that particular Content.\n\
+\n\
+\n\Use of Provisioning Technology\n\
+\n\
+The Eclipse Foundation makes available provisioning software, examples of which include,\n\
+but are not limited to, p2 and the Eclipse Update Manager ("Provisioning Technology") for\n\
+the purpose of allowing users to install software, documentation, information and/or\n\
+other materials (collectively "Installable Software"). This capability is provided with\n\
+the intent of allowing such users to install, extend and update Eclipse-based products.\n\
+Information about packaging Installable Software is available at\n\
+http://eclipse.org/equinox/p2/repository_packaging.html ("Specification").\n\
+\n\
+You may use Provisioning Technology to allow other parties to install Installable Software.\n\
+You shall be responsible for enabling the applicable license agreements relating to the\n\
+Installable Software to be presented to, and accepted by, the users of the Provisioning Technology\n\
+in accordance with the Specification. By using Provisioning Technology in such a manner and\n\
+making it available in accordance with the Specification, you further acknowledge your\n\
+agreement to, and the acquisition of all necessary rights to permit the following:\n\
+\n\
+       1. A series of actions may occur ("Provisioning Process") in which a user may execute\n\
+          the Provisioning Technology on a machine ("Target Machine") with the intent of installing,\n\
+          extending or updating the functionality of an Eclipse-based product.\n\
+       2. During the Provisioning Process, the Provisioning Technology may cause third party\n\
+          Installable Software or a portion thereof to be accessed and copied to the Target Machine.\n\
+       3. Pursuant to the Specification, you will provide to the user the terms and conditions that\n\
+          govern the use of the Installable Software ("Installable Software Agreement") and such\n\
+          Installable Software Agreement shall be accessed from the Target Machine in accordance\n\
+          with the Specification. Such Installable Software Agreement must inform the user of the\n\
+          terms and conditions that govern the Installable Software and must solicit acceptance by\n\
+          the end user in the manner prescribed in such Installable Software Agreement. Upon such\n\
+          indication of agreement by the user, the provisioning Technology will complete installation\n\
+          of the Installable Software.\n\
+\n\
+Cryptography\n\
+\n\
+Content may contain encryption software. The country in which you are\n\
+currently may have restrictions on the import, possession, and use,\n\
+and/or re-export to another country, of encryption software. BEFORE\n\
+using any encryption software, please check the country's laws,\n\
+regulations and policies concerning the import, possession, or use, and\n\
+re-export of encryption software, to see if this is permitted.\n\
+\n\
+Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.\n
+########### end of license property ##########################################
diff --git a/org.eclipse.cdt.platform/feature.xml b/org.eclipse.cdt.platform/feature.xml
new file mode 100644 (file)
index 0000000..d081dfe
--- /dev/null
@@ -0,0 +1,273 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+      id="org.eclipse.cdt.platform"
+      label="%featureName"
+      version="8.0.0.201109151620_patch"
+      provider-name="%providerName">
+
+   <description>
+      %description
+   </description>
+
+   <copyright>
+      %copyright
+   </copyright>
+
+   <license url="%licenseURL">
+      %license
+   </license>
+
+   <url>
+      <update label="%updateSiteName" url="http://download.eclipse.org/tools/cdt/releases/indigo"/>
+   </url>
+
+   <plugin
+         id="org.eclipse.cdt"
+         download-size="71"
+         install-size="77"
+         version="8.0.0.201109151620"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.cdt.core"
+         download-size="4281"
+         install-size="9476"
+         version="5.3.1.201109151620"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.cdt.core.aix"
+         os="aix"
+         download-size="17"
+         install-size="45"
+         version="5.1.0.201109151620"
+         fragment="true"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.cdt.core.linux"
+         os="linux"
+         download-size="6"
+         install-size="7"
+         version="5.2.0.201109151620"
+         fragment="true"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.cdt.core.linux.ia64"
+         os="linux"
+         arch="ia64"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         fragment="true"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.cdt.core.linux.ppc"
+         os="linux"
+         arch="ppc"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         fragment="true"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.cdt.core.linux.ppc64"
+         os="linux"
+         arch="ppc64"
+         download-size="15"
+         install-size="48"
+         version="5.1.0.201109151620"
+         fragment="true"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.cdt.core.linux.x86"
+         os="linux"
+         arch="x86"
+         download-size="12"
+         install-size="27"
+         version="5.2.0.201109151620"
+         fragment="true"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.cdt.core.linux.x86_64"
+         os="linux"
+         arch="x86_64"
+         download-size="13"
+         install-size="33"
+         version="5.2.0.201109151620"
+         fragment="true"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.cdt.core.macosx"
+         os="macosx"
+         download-size="28"
+         install-size="88"
+         version="5.2.0.201109151620"
+         fragment="true"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.cdt.core.qnx"
+         os="qnx"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         fragment="true"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.cdt.core.solaris"
+         os="solaris"
+         arch="sparc"
+         download-size="17"
+         install-size="37"
+         version="5.2.0.201109151620"
+         fragment="true"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.cdt.core.win32"
+         os="win32"
+         download-size="6"
+         install-size="7"
+         version="5.2.0.201109151620"
+         fragment="true"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.cdt.codan.core"
+         download-size="117"
+         install-size="231"
+         version="2.0.0.201109151620"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.cdt.codan.ui"
+         download-size="99"
+         install-size="205"
+         version="2.0.0.201109151620"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.cdt.codan.core.cxx"
+         download-size="36"
+         install-size="73"
+         version="1.0.0.201109151620"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.cdt.codan.ui.cxx"
+         download-size="15"
+         install-size="28"
+         version="2.0.0.201109151620"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.cdt.codan.checkers"
+         download-size="68"
+         install-size="161"
+         version="1.0.0.201109151620"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.cdt.codan.checkers.ui"
+         download-size="23"
+         install-size="44"
+         version="1.0.0.201109151620"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.cdt.debug.core"
+         download-size="475"
+         install-size="955"
+         version="7.1.0.201109151620"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.cdt.debug.ui"
+         download-size="988"
+         install-size="2004"
+         version="7.1.1.201109151620"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.cdt.make.core"
+         download-size="391"
+         install-size="831"
+         version="7.1.1.201109151620"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.cdt.make.ui"
+         download-size="431"
+         install-size="852"
+         version="7.1.1.201109151620"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.cdt.managedbuilder.core"
+         download-size="1131"
+         install-size="2692"
+         version="8.0.1.201109151620"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.cdt.managedbuilder.ui"
+         download-size="399"
+         install-size="827"
+         version="8.0.0.201109151620"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.cdt.doc.user"
+         download-size="13839"
+         install-size="15280"
+         version="5.1.0.201109151620"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.cdt.dsf"
+         download-size="276"
+         install-size="548"
+         version="2.2.0.201109151620"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.cdt.dsf.ui"
+         download-size="1197"
+         install-size="2649"
+         version="2.2.0.201109151620"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.cdt.core.win32.x86"
+         os="win32"
+         arch="x86"
+         download-size="76"
+         install-size="193"
+         version="5.2.0.201109151620"
+         fragment="true"/>
+
+   <plugin
+         id="org.eclipse.cdt.core.win32.x86_64"
+         os="win32"
+         arch="x86_64"
+         download-size="156"
+         install-size="329"
+         version="5.2.0.201109151620"
+         fragment="true"/>
+
+   <plugin
+         id="org.eclipse.cdt.ui"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+</feature>
diff --git a/org.eclipse.cdt.platform/license.html b/org.eclipse.cdt.platform/license.html
new file mode 100644 (file)
index 0000000..f19c483
--- /dev/null
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+<title>Eclipse Foundation Software User Agreement</title>
+</head>
+
+<body lang="EN-US">
+<h2>Eclipse Foundation Software User Agreement</h2>
+<p>February 1, 2011</p>
+
+<h3>Usage Of Content</h3>
+
+<p>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS
+   (COLLECTIVELY &quot;CONTENT&quot;).  USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND
+   CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW.  BY USING THE CONTENT, YOU AGREE THAT YOUR USE
+   OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR
+   NOTICES INDICATED OR REFERENCED BELOW.  IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND
+   CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.</p>
+
+<h3>Applicable Licenses</h3>
+
+<p>Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0
+   (&quot;EPL&quot;).  A copy of the EPL is provided with this Content and is also available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+   For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse Foundation source code
+   repository (&quot;Repository&quot;) in software modules (&quot;Modules&quot;) and made available as downloadable archives (&quot;Downloads&quot;).</p>
+
+<ul>
+       <li>Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content.  Typical modules may include plug-ins (&quot;Plug-ins&quot;), plug-in fragments (&quot;Fragments&quot;), and features (&quot;Features&quot;).</li>
+       <li>Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java&trade; ARchive) in a directory named &quot;plugins&quot;.</li>
+       <li>A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.  Each Feature may be packaged as a sub-directory in a directory named &quot;features&quot;.  Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of the Plug-ins
+      and/or Fragments associated with that Feature.</li>
+       <li>Features may also include other Features (&quot;Included Features&quot;). Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of Included Features.</li>
+</ul>
+
+<p>The terms and conditions governing Plug-ins and Fragments should be contained in files named &quot;about.html&quot; (&quot;Abouts&quot;). The terms and conditions governing Features and
+Included Features should be contained in files named &quot;license.html&quot; (&quot;Feature Licenses&quot;).  Abouts and Feature Licenses may be located in any directory of a Download or Module
+including, but not limited to the following locations:</p>
+
+<ul>
+       <li>The top-level (root) directory</li>
+       <li>Plug-in and Fragment directories</li>
+       <li>Inside Plug-ins and Fragments packaged as JARs</li>
+       <li>Sub-directories of the directory named &quot;src&quot; of certain Plug-ins</li>
+       <li>Feature directories</li>
+</ul>
+
+<p>Note: if a Feature made available by the Eclipse Foundation is installed using the Provisioning Technology (as defined below), you must agree to a license (&quot;Feature Update License&quot;) during the
+installation process.  If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or
+inform you where you can locate them.  Feature Update Licenses may be found in the &quot;license&quot; property of files named &quot;feature.properties&quot; found within a Feature.
+Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in
+that directory.</p>
+
+<p>THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.  SOME OF THESE
+OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</p>
+
+<ul>
+       <li>Eclipse Distribution License Version 1.0 (available at <a href="http://www.eclipse.org/licenses/edl-v10.html">http://www.eclipse.org/licenses/edl-v1.0.html</a>)</li>
+       <li>Common Public License Version 1.0 (available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>)</li>
+       <li>Apache Software License 1.1 (available at <a href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</a>)</li>
+       <li>Apache Software License 2.0 (available at <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>)</li>
+       <li>Metro Link Public License 1.00 (available at <a href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</a>)</li>
+       <li>Mozilla Public License Version 1.1 (available at <a href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</a>)</li>
+</ul>
+
+<p>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT.  If no About, Feature License, or Feature Update License is provided, please
+contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.</p>
+
+
+<h3>Use of Provisioning Technology</h3>
+
+<p>The Eclipse Foundation makes available provisioning software, examples of which include, but are not limited to, p2 and the Eclipse
+   Update Manager (&quot;Provisioning Technology&quot;) for the purpose of allowing users to install software, documentation, information and/or
+   other materials (collectively &quot;Installable Software&quot;). This capability is provided with the intent of allowing such users to
+   install, extend and update Eclipse-based products. Information about packaging Installable Software is available at <a
+       href="http://eclipse.org/equinox/p2/repository_packaging.html">http://eclipse.org/equinox/p2/repository_packaging.html</a>
+   (&quot;Specification&quot;).</p>
+
+<p>You may use Provisioning Technology to allow other parties to install Installable Software. You shall be responsible for enabling the
+   applicable license agreements relating to the Installable Software to be presented to, and accepted by, the users of the Provisioning Technology
+   in accordance with the Specification. By using Provisioning Technology in such a manner and making it available in accordance with the
+   Specification, you further acknowledge your agreement to, and the acquisition of all necessary rights to permit the following:</p>
+
+<ol>
+       <li>A series of actions may occur (&quot;Provisioning Process&quot;) in which a user may execute the Provisioning Technology
+       on a machine (&quot;Target Machine&quot;) with the intent of installing, extending or updating the functionality of an Eclipse-based
+       product.</li>
+       <li>During the Provisioning Process, the Provisioning Technology may cause third party Installable Software or a portion thereof to be
+       accessed and copied to the Target Machine.</li>
+       <li>Pursuant to the Specification, you will provide to the user the terms and conditions that govern the use of the Installable
+       Software (&quot;Installable Software Agreement&quot;) and such Installable Software Agreement shall be accessed from the Target
+       Machine in accordance with the Specification. Such Installable Software Agreement must inform the user of the terms and conditions that govern
+       the Installable Software and must solicit acceptance by the end user in the manner prescribed in such Installable Software Agreement. Upon such
+       indication of agreement by the user, the provisioning Technology will complete installation of the Installable Software.</li>
+</ol>
+
+<h3>Cryptography</h3>
+
+<p>Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to
+   another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import,
+   possession, or use, and re-export of encryption software, to see if this is permitted.</p>
+
+<p><small>Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.</small></p>
+</body>
+</html>
diff --git a/org.eclipse.cdt.ui/.classpath b/org.eclipse.cdt.ui/.classpath
new file mode 100644 (file)
index 0000000..e721d0c
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src/"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.cdt.ui/.options b/org.eclipse.cdt.ui/.options
new file mode 100644 (file)
index 0000000..d28d8af
--- /dev/null
@@ -0,0 +1,10 @@
+org.eclipse.cdt.ui/debug=false
+
+# Reports contentAssist activity
+org.eclipse.cdt.ui/debug/contentassist=false
+
+# Enables all semantic highlighting types
+org.eclipse.cdt.ui/debug/SemanticHighlighting=false
+
+# Enables debug information related to folding
+org.eclipse.cdt.ui/debug/folding=false
diff --git a/org.eclipse.cdt.ui/.project b/org.eclipse.cdt.ui/.project
new file mode 100644 (file)
index 0000000..7219002
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.eclipse.cdt.ui</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/org.eclipse.cdt.ui/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.cdt.ui/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..96179a4
--- /dev/null
@@ -0,0 +1,8 @@
+#Tue Oct 25 20:04:11 KST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/org.eclipse.cdt.ui/ChangeLog-browser b/org.eclipse.cdt.ui/ChangeLog-browser
new file mode 100644 (file)
index 0000000..0a0bae5
--- /dev/null
@@ -0,0 +1,106 @@
+2005-02-01 Alain Magloire
+       Code From Chris:
+       Fix PR 83866
+       Fix PR 83869
+       * browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyAction.java
+       * browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpentTypeInHierarchyAction.java
+       * browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypoeInHierarchDialog.java
+       * browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyMessages.properties
+       
+2004-11-24 Chris Wiebe
+
+       fix exception in OpenTypeInHierarchyAction
+       * browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeInHierarchyAction.java
+
+2004-11-08 Chris Wiebe
+
+       fix for 68883
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingContentProvider.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPart.java
+
+2004-09-15 Chris Wiebe
+
+       fixed selection
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesView.java
+
+2004-09-15 Chris Wiebe
+
+       fixed element navigation problems
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingContentProvider.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingElementFilter.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingLabelProvider.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingMessages.properties
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPart.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingViewerSorter.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/LexicalSortingAction.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersView.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersViewContentProvider.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesView.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesViewContentProvider.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesViewLabelProvider.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectsView.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectsViewContentProvider.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypeInfoSorter.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesView.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesViewContentProvider.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesViewLabelProvider.java
+       * browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyUtil.java
+       * browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyViewPart.java
+
+2004-09-02 Chris Wiebe
+
+       fix editor/view selection problems
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingElementComparer.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPart.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersView.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesView.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesView.java
+
+2004-09-01 Chris Wiebe
+
+       Fix for 68883
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingContentProvider.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPart.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ElementTableViewer.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ElementTreeViewer.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersView.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesView.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesView.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectsView.java
+
+2004-09-01 Chris Wiebe
+
+       replace deprecated SearchUI.SEARCH_RESULT_VIEW_ID w/ NewSearchUI.SEARCH_VIEW_ID
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPerspectiveFactory.java
+
+2004-08-31 Chris Wiebe
+
+       Fix for 68883
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingContentProvider.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingElementComparer.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPart.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPerspectiveFactory.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersView.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersViewContentProvider.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesView.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectsView.java
+       * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesView.java
+       * browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/FocusOnTypeAction.java
+       * browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HierarchyViewerSorter.java
+       * browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsLabelProvider.java
+       * browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyAction.java
+       * browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyUtil.java
+       * browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyContentProvider.java
+       * browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyViewPart.java
+       
+2004-06-21 Chris Wiebe
+
+       This mini-patch gets rid of unnecessary "could not locate type" error
+       dialogs.
+
+2004-06-21 Chris Wiebe
+
+       - fix for bug #66108 (C++ browser cannot show members of class)
+       - all types now visible in the types view (ie not just classes & structs)
+       - runnables now use IProgressService.busyCursorWhile (prevents progress
+       dialog from being displayed during short operations)
diff --git a/org.eclipse.cdt.ui/META-INF/MANIFEST.MF b/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..daa4c1a
--- /dev/null
@@ -0,0 +1,10979 @@
+Manifest-Version: 1.0\r
+Bundle-Localization: plugin\r
+Bundle-RequiredExecutionEnvironment: J2SE-1.5\r
+Built-By: hudsonbuild\r
+Bundle-SymbolicName: org.eclipse.cdt.ui; singleton:=true\r
+Bundle-Activator: org.eclipse.cdt.ui.CUIPlugin\r
+Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.3.0,4.0.0)",org.\r
+ eclipse.ui.views;bundle-version="[3.2.0,4.0.0)",org.eclipse.jface.tex\r
+ t;bundle-version="[3.4.0,4.0.0)",org.eclipse.ui.workbench.texteditor;\r
+ bundle-version="[3.5.0,4.0.0)",org.eclipse.ui.editors;bundle-version=\r
+ "[3.3.0,4.0.0)",org.eclipse.ui;bundle-version="[3.3.0,4.0.0)",org.ecl\r
+ ipse.ui.forms;bundle-version="[3.2.0,4.0.0)",org.eclipse.core.resourc\r
+ es;bundle-version="[3.2.0,4.0.0)",org.eclipse.search;bundle-version="\r
+ [3.2.0,4.0.0)",org.eclipse.compare;bundle-version="[3.3.0,4.0.0)",org\r
+ .eclipse.cdt.core;bundle-version="[5.2.0,6.0.0)",org.eclipse.ui.conso\r
+ le;bundle-version="[3.1.100,4.0.0)",org.eclipse.core.runtime;bundle-v\r
+ ersion="[3.7.0,4.0.0)",org.eclipse.help;bundle-version="[3.2.0,4.0.0)\r
+ ",org.eclipse.ui.navigator;bundle-version="[3.2.0,4.0.0)",org.eclipse\r
+ .core.filesystem;bundle-version="[1.1.0,2.0.0)",org.eclipse.core.vari\r
+ ables;bundle-version="[3.1.100,4.0.0)",org.eclipse.ltk.core.refactori\r
+ ng;bundle-version="3.4.0",org.eclipse.ltk.ui.refactoring;bundle-versi\r
+ on="3.4.0",org.eclipse.ui.navigator.resources;bundle-version="3.3.100\r
+ "\r
+Bundle-Version: 5.3.1.201109151620_patch\r
+Export-Package: org.eclipse.cdt.internal.corext;x-internal:=true,org.e\r
+ clipse.cdt.internal.corext.codemanipulation;x-internal:=true,org.ecli\r
+ pse.cdt.internal.corext.fix;x-internal:=true,org.eclipse.cdt.internal\r
+ .corext.template.c;x-internal:=true,org.eclipse.cdt.internal.corext.u\r
+ til;x-internal:=true,org.eclipse.cdt.internal.ui;x-friends:="org.ecli\r
+ pse.cdt.debug.edc.tests",org.eclipse.cdt.internal.ui.actions;x-intern\r
+ al:=true,org.eclipse.cdt.internal.ui.browser.opentype;x-internal:=tru\r
+ e,org.eclipse.cdt.internal.ui.build;x-internal:=true,org.eclipse.cdt.\r
+ internal.ui.buildconsole;x-internal:=true,org.eclipse.cdt.internal.ui\r
+ .callhierarchy;x-internal:=true,org.eclipse.cdt.internal.ui.compare;x\r
+ -internal:=true,org.eclipse.cdt.internal.ui.cview;x-internal:=true,or\r
+ g.eclipse.cdt.internal.ui.dialogs;x-internal:=true,org.eclipse.cdt.in\r
+ ternal.ui.dialogs.cpaths;x-internal:=true,org.eclipse.cdt.internal.ui\r
+ .dnd;x-internal:=true,org.eclipse.cdt.internal.ui.editor;x-internal:=\r
+ true,org.eclipse.cdt.internal.ui.editor.asm;x-internal:=true,org.ecli\r
+ pse.cdt.internal.ui.filters;x-internal:=true,org.eclipse.cdt.internal\r
+ .ui.help;x-internal:=true,org.eclipse.cdt.internal.ui.includebrowser;\r
+ x-internal:=true,org.eclipse.cdt.internal.ui.indexview;x-internal:=tr\r
+ ue,org.eclipse.cdt.internal.ui.language;x-internal:=true,org.eclipse.\r
+ cdt.internal.ui.navigator;x-internal:=true,org.eclipse.cdt.internal.u\r
+ i.newui;x-internal:=true,org.eclipse.cdt.internal.ui.preferences;x-in\r
+ ternal:=true,org.eclipse.cdt.internal.ui.preferences.formatter;x-inte\r
+ rnal:=true,org.eclipse.cdt.internal.ui.refactoring;x-friends:="org.ec\r
+ lipse.cdt.ui.tests",org.eclipse.cdt.internal.ui.refactoring.dialogs;x\r
+ -internal:=true,org.eclipse.cdt.internal.ui.refactoring.extractconsta\r
+ nt;x-friends:="org.eclipse.cdt.ui.tests",org.eclipse.cdt.internal.ui.\r
+ refactoring.extractfunction;x-friends:="org.eclipse.cdt.ui.tests",org\r
+ .eclipse.cdt.internal.ui.refactoring.extractlocalvariable;x-friends:=\r
+ "org.eclipse.cdt.ui.tests",org.eclipse.cdt.internal.ui.refactoring.ge\r
+ ttersandsetters;x-friends:="org.eclipse.cdt.ui.tests",org.eclipse.cdt\r
+ .internal.ui.refactoring.hidemethod;x-friends:="org.eclipse.cdt.ui.te\r
+ sts",org.eclipse.cdt.internal.ui.refactoring.implementmethod;x-friend\r
+ s:="org.eclipse.cdt.ui.tests",org.eclipse.cdt.internal.ui.refactoring\r
+ .rename;x-friends:="org.eclipse.cdt.ui.tests",org.eclipse.cdt.interna\r
+ l.ui.refactoring.togglefunction;x-friends:="org.eclipse.cdt.ui.tests"\r
+ ,org.eclipse.cdt.internal.ui.refactoring.utils;x-friends:="org.eclips\r
+ e.cdt.ui.tests",org.eclipse.cdt.internal.ui.resources,org.eclipse.cdt\r
+ .internal.ui.search;x-internal:=true,org.eclipse.cdt.internal.ui.sear\r
+ ch.actions;x-internal:=true,org.eclipse.cdt.internal.ui.text;x-intern\r
+ al:=true,org.eclipse.cdt.internal.ui.text.asm;x-internal:=true,org.ec\r
+ lipse.cdt.internal.ui.text.c.hover;x-internal:=true,org.eclipse.cdt.i\r
+ nternal.ui.text.contentassist;x-internal:=true,org.eclipse.cdt.intern\r
+ al.ui.text.correction;x-friends:="org.eclipse.cdt.ui.tests",org.eclip\r
+ se.cdt.internal.ui.text.correction.proposals;x-friends:="org.eclipse.\r
+ cdt.ui.tests",org.eclipse.cdt.internal.ui.text.doctools;x-internal:=t\r
+ rue,org.eclipse.cdt.internal.ui.text.folding;x-internal:=true,org.ecl\r
+ ipse.cdt.internal.ui.text.spelling;x-internal:=true,org.eclipse.cdt.i\r
+ nternal.ui.text.spelling.engine;x-internal:=true,org.eclipse.cdt.inte\r
+ rnal.ui.text.template;x-internal:=true,org.eclipse.cdt.internal.ui.te\r
+ xt.util;x-internal:=true,org.eclipse.cdt.internal.ui.typehierarchy;x-\r
+ internal:=true,org.eclipse.cdt.internal.ui.util;x-friends:="org.eclip\r
+ se.cdt.debug.ui,org.eclipse.cdt.debug.edc.tests",org.eclipse.cdt.inte\r
+ rnal.ui.viewsupport;x-internal:=true,org.eclipse.cdt.internal.ui.wiza\r
+ rds;x-internal:=true,org.eclipse.cdt.internal.ui.wizards.classwizard;\r
+ x-internal:=true,org.eclipse.cdt.internal.ui.wizards.dialogfields;x-i\r
+ nternal:=true,org.eclipse.cdt.internal.ui.wizards.filewizard;x-intern\r
+ al:=true,org.eclipse.cdt.internal.ui.wizards.folderwizard;x-internal:\r
+ =true,org.eclipse.cdt.internal.ui.wizards.indexwizards;x-internal:=tr\r
+ ue,org.eclipse.cdt.internal.ui.wizards.settingswizards;x-internal:=tr\r
+ ue,org.eclipse.cdt.internal.ui.workingsets;x-internal:=true,org.eclip\r
+ se.cdt.ui,org.eclipse.cdt.ui.actions,org.eclipse.cdt.ui.browser.typei\r
+ nfo,org.eclipse.cdt.ui.dialogs,org.eclipse.cdt.ui.internal.templateen\r
+ gine.wizard;x-internal:=true,org.eclipse.cdt.ui.newui,org.eclipse.cdt\r
+ .ui.refactoring,org.eclipse.cdt.ui.refactoring.actions,org.eclipse.cd\r
+ t.ui.resources,org.eclipse.cdt.ui.templateengine,org.eclipse.cdt.ui.t\r
+ emplateengine.event,org.eclipse.cdt.ui.templateengine.pages,org.eclip\r
+ se.cdt.ui.templateengine.processes,org.eclipse.cdt.ui.templateengine.\r
+ uitree,org.eclipse.cdt.ui.templateengine.uitree.uiwidgets,org.eclipse\r
+ .cdt.ui.text,org.eclipse.cdt.ui.text.c.hover,org.eclipse.cdt.ui.text.\r
+ contentassist,org.eclipse.cdt.ui.text.doctools,org.eclipse.cdt.ui.tex\r
+ t.doctools.doxygen,org.eclipse.cdt.ui.text.doctools.generic,org.eclip\r
+ se.cdt.ui.text.folding,org.eclipse.cdt.ui.wizards,org.eclipse.cdt.ui.\r
+ wizards.conversion,org.eclipse.cdt.utils.ui.controls\r
+Build-Jdk: 1.6.0_21\r
+Bundle-ActivationPolicy: lazy\r
+Bundle-Vendor: %providerName\r
+Bundle-Name: %pluginName\r
+Archiver-Version: Plexus Archiver\r
+Created-By: Apache Maven\r
+Import-Package: com.ibm.icu.text\r
+Bundle-ManifestVersion: 2\r
+\r
+Name: icons/obj16/config.gif\r
+SHA1-Digest: GMPYVJJSFAuzmXjT+4nXLCyHmxc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/AbstractCEditorTextHove\r
+ r$1.class\r
+SHA1-Digest: yDz+6Yk6hDV4yd8RyhllOHIhnPo=\r
+\r
+Name: icons/etool16/config-librarian.gif\r
+SHA1-Digest: bg6S3lCyi7Pj5E38CForpidSXec=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/TemplateListSelectionPage.clas\r
+ s\r
+SHA1-Digest: mZ7vOq9M2S7OdKhDA9oKAVRt2/4=\r
+\r
+Name: org/eclipse/cdt/ui/refactoring/actions/messages.properties\r
+SHA1-Digest: ERvjlx9cABt5mMVBy8p9q1334TA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dnd/DelegatingDropAdapter$2.class\r
+SHA1-Digest: 8/Hm2E7xJ0lUegalBfbuKfZXiTo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/StringMatcher$Position.class\r
+SHA1-Digest: TVdKMEtjYTjAkquxX+WBVnoovp8=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ProjectContentsArea$1.class\r
+SHA1-Digest: JLUDvpf0ILLojdegHNO3OM0EHUE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDia\r
+ log$UpdateJobListener.class\r
+SHA1-Digest: qxkzsu2mghPmnKBehuJ7OZ92Zhg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/IncludesSymbolsProper\r
+ tyPage.class\r
+SHA1-Digest: Cpp87mf0w6yk9Gt1BmCpzegQ5Is=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dnd/DelegatingDragAdapter.class\r
+SHA1-Digest: mrKK+8SaQhs9eV/09w0RRfJP1U8=\r
+\r
+Name: org/eclipse/cdt/ui/newui/CDTPrefUtil.class\r
+SHA1-Digest: G8AeWzmynmZVv3YmUM+Ryj7nbgc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDia\r
+ log$UpdateJobListener$2.class\r
+SHA1-Digest: h3j7Dq3WE3N2YBQdWC92tL26vVs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/filters/CustomFiltersDialog$5.class\r
+SHA1-Digest: NNVFGSDkvrn7O+l4+/icABLktuk=\r
+\r
+Name: icons/obj16/composite_change.gif\r
+SHA1-Digest: Ea9L8XyJpHuHivtrNRRkbSwmQ2c=\r
+\r
+Name: org/eclipse/cdt/ui/newui/SymbolDialog.class\r
+SHA1-Digest: ApkIVTK0M+lNtWh02GnxVj8ROJA=\r
+\r
+Name: icons/etool16/config-release.gif\r
+SHA1-Digest: kpl/IUL2CNd242VDWOjM6vSl13E=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.clas\r
+ s\r
+SHA1-Digest: iQOKW1uUz74QWkJuEvMPjRyXODk=\r
+\r
+Name: org/eclipse/cdt/ui/newui/EnvironmentTab$2.class\r
+SHA1-Digest: 6nlePtrBZ49esOn8+BjZ5fSqu9w=\r
+\r
+Name: icons/elcl16/fields_co.gif\r
+SHA1-Digest: +Qm9iCoSepPKMWbROQB0mLkaNVY=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/CNewWizard.class\r
+SHA1-Digest: UM0Pi9MoTtozNkN4tZRaFnMdMCw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/ResourceToItemsMapper.class\r
+SHA1-Digest: W7PxZyCHIkwPXPFJMfksP0j/tEI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/WordCorrectionProposal\r
+ .class\r
+SHA1-Digest: LaJQnEYC3sl9q09dS496oBJHt8A=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/PasteAction.class\r
+SHA1-Digest: 3WTcHXPQbv/gPiQWTssbIgEp/pM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGene\r
+ rator$CodeGeneratorException.class\r
+SHA1-Digest: zBVnJmQOnyOcIV5WnhMXznv5XDs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/FileLanguageMappingProperty\r
+ Page$2.class\r
+SHA1-Digest: z7oWkNSeSLkE9QvPRK9l5XxX2r0=\r
+\r
+Name: icons/dtool16/convert-normal.gif\r
+SHA1-Digest: +zWSddGIHOIp9fBBOC7hUz+pVqk=\r
+\r
+Name: icons/elcl16/th_automatic.gif\r
+SHA1-Digest: 3+mrjrauoMlp+Sc9l4zBw6JgU4o=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialogTa\r
+ bPage$2.class\r
+SHA1-Digest: AvUSbrD8dqPqsORUcdnlntfOS/M=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/LinkedNamesFinder$SubclassFin\r
+ der.class\r
+SHA1-Digest: OyI5Ir87+q1qMdF7znvCUGs68kU=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/uitree/SimpleUIElementGroup.cl\r
+ ass\r
+SHA1-Digest: DrbmSYq9G0vTjnB9IlWaGReiqhI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog$2.cla\r
+ ss\r
+SHA1-Digest: xcAuU6mMETppLQXvpoVNEU31krQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfiguratio\r
+ nBlock$CEditorTextHoverDescriptorContentProvider.class\r
+SHA1-Digest: Goss5BBHkg9XLL/vQebUrSF5DfQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/SpellingConfigurationBlo\r
+ ck$4.class\r
+SHA1-Digest: iOvEEuuJrkpF7DZF/ZATL+YGjz8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/indexview/IndexView$3.class\r
+SHA1-Digest: SOf8o2uTZTE+4AG0vY45WB9YCSk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ProfileManager\r
+ $SharedProfile.class\r
+SHA1-Digest: in4iFGn33oZMl6zabNCg8lYnWj0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/TaskTagDictionary.clas\r
+ s\r
+SHA1-Digest: 5YZ94yrPlfNSML2nV8eW7Da7dPg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CalledByResult.class\r
+SHA1-Digest: mnic7HvmpxG79qZwGKqNAFZ2lrg=\r
+\r
+Name: org/eclipse/cdt/ui/CElementContentProvider.class\r
+SHA1-Digest: HAU9LzRbkwJ5yeAZgPG8Ms7s/nQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/ModificationCollector.cl\r
+ ass\r
+SHA1-Digest: 6IPSTG8/x5wOZ51AVUmwjCru7q4=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ExpDialog$5.class\r
+SHA1-Digest: RQ2XM3ln+PJCrl/7/po7WvIc6ls=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractCPropertyTab$1.class\r
+SHA1-Digest: S1jkkNXV7uGZTH3bmFv4vy89yT8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/HtmlTagDictionary.clas\r
+ s\r
+SHA1-Digest: TWTZjakUWSzfVOsdMyJql6Kba+g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/OpenTypeHierarchyActio\r
+ n.class\r
+SHA1-Digest: OAGURDn3VnjyAREHFXZ5UiwhQcY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/SelectionList$2.class\r
+SHA1-Digest: hDxk4dGWdQn9EaptCsfR6vj1kEw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/GoToNextPreviousMemberAction\r
+ .class\r
+SHA1-Digest: BRlnSkYjsBNYepCB3GYcmmVX9KA=\r
+\r
+Name: org/eclipse/cdt/ui/refactoring/actions/CRenameAction.class\r
+SHA1-Digest: Fb2QuwVD2qQaAr0LpO8u44Tx9/c=\r
+\r
+Name: icons/dlcl16/inher_co.gif\r
+SHA1-Digest: vNcrPXXnRxWQUzhLL0agq89aFe0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/LinkToFileGroup\r
+ $2.class\r
+SHA1-Digest: hvxzZl2C2pgTOAzdBVvE75vgXJg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/ExtendedTreeViewer$1.cla\r
+ ss\r
+SHA1-Digest: WMt8NJFXj+xVBE61m38vb6RhnZY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailNam\r
+ e.class\r
+SHA1-Digest: Wx9Uxn9uXWRH0yNGFs+pmCrs0lI=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UIBooleanWidg\r
+ et$1.class\r
+SHA1-Digest: wRcZykWCfHT6eriWqJgdMTmV7Bg=\r
+\r
+Name: org/eclipse/cdt/ui/actions/CustomFiltersActionGroup.class\r
+SHA1-Digest: SUi6UjmSPI0KehsNjF8TZbw48oo=\r
+\r
+Name: icons/obj16/struct_obj.gif\r
+SHA1-Digest: W0gmVbCDj+HTFDlkzTW/W1eJ6LQ=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/uitree/UIElementTreeBuilderMan\r
+ ager.class\r
+SHA1-Digest: dUadj8PNTPh7H0+MtZpr3nwHoy4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/dialogs/ExtractInputPage\r
+ .class\r
+SHA1-Digest: K6I9p3KhE7/1Qx+MEUV2Ai6feRM=\r
+\r
+Name: org/eclipse/cdt/ui/actions/CdtActionConstants.class\r
+SHA1-Digest: D0gOvdy9X6+OEZjzS5tLW+B74wE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDia\r
+ log.class\r
+SHA1-Digest: k85kJQDSn3GsMEPLeJe2Q6C9eDI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/StatusBarUpdater.class\r
+SHA1-Digest: yI0kQLASrCb2dUVsZg7iKvI8IKg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/actions/FindRefsInWorkingSetA\r
+ ction.class\r
+SHA1-Digest: 3PqO4WRHrUTV/GTudvOJx2OlYBk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/Visibility$1.class\r
+SHA1-Digest: 4JutWdVpAdwxx4Px8gM7JMqrZa4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRef\r
+ actoringContribution.class\r
+SHA1-Digest: VVVAXHe1wTQ8bWX62wv2qe5LdKY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/DefaultBinaryFileEditor$Binar\r
+ yFileDocumentProvider.class\r
+SHA1-Digest: R1taMBZes5I0+GaJhrJi41KAyVs=\r
+\r
+Name: icons/etool16/config-profile.gif\r
+SHA1-Digest: GMPYVJJSFAuzmXjT+4nXLCyHmxc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$AdaptedSourceViewer.c\r
+ lass\r
+SHA1-Digest: btsHciB8IcMcBLWjteizRraOBV0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractF\r
+ unctionRefactoringDescription.class\r
+SHA1-Digest: kjHhrORI6OtM3YGfXNqCewWjWwo=\r
+\r
+Name: org/eclipse/cdt/ui/internal/templateengine/wizard/TemplateCNewWi\r
+ zard.class\r
+SHA1-Digest: 44v/UyxljIXqM2OteP5sYm6up8E=\r
+\r
+Name: org/eclipse/cdt/ui/text/IColorManager.class\r
+SHA1-Digest: BfwLZXhQ29Rrv5MEFIVizXBAYuI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectInde\r
+ xExportWizardPage.class\r
+SHA1-Digest: StwRNGUr5eN6ESOvQyvq2A/hf/g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/proposals/TUCorrecti\r
+ onProposal$1EditAnnotator.class\r
+SHA1-Digest: F41kzA1byLxvQt/r+j1xkQjaguc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightings$Paramet\r
+ erVariableHighlighting.class\r
+SHA1-Digest: RNpCXnG0/kXfTR5B2BuEDkuzQvs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/indexview/IndexView.class\r
+SHA1-Digest: yKr9aJoPNXCCSmy3CSY0Ixza7Ng=\r
+\r
+Name: org/eclipse/cdt/ui/refactoring/actions/ExtractLocalVariableActio\r
+ n.class\r
+SHA1-Digest: z+ziLXQx0oQJQ4723XdV8yRnWjY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CElementHyperlinkDetector.cla\r
+ ss\r
+SHA1-Digest: DK2MBvGWZKtVMXuDDN2n8WmW1Jg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/ConsoleOutputTextStore.\r
+ class\r
+SHA1-Digest: GDW7y537pRQFhNJTop/Y32Wo5w8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/IContextMenuConstants.class\r
+SHA1-Digest: ShfGR3GQWmcUNpUCE3VwsFwEtUk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/ExclusionPatternDialo\r
+ g.class\r
+SHA1-Digest: 14hXav5PtJVGxtMWtyLe45Popys=\r
+\r
+Name: org/eclipse/cdt/ui/newui/CLocationTab$3.class\r
+SHA1-Digest: MTv25UaoJy0AU001XqdJBlVyK6Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEnt\r
+ ryPerFilePage.class\r
+SHA1-Digest: CtNfX3vKf6pXH32nS3vwgFs2dW0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CReconciler$SingletonJob.class\r
+SHA1-Digest: x9Q71zVn6mTM+o9JBAsgoYJLKV4=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/BinaryParserBlock$BinaryParserLabelPr\r
+ ovider.class\r
+SHA1-Digest: KGCoNlU0VzrvqW66+OnmvLuP31E=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightings$Problem\r
+ Highlighting.class\r
+SHA1-Digest: lsZgUa0YC7MSIxdB/RDjDQNXA70=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightings$MethodH\r
+ ighlighting.class\r
+SHA1-Digest: bFdxOUZEcJgHh0d6f9195SxChjA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart$6.class\r
+SHA1-Digest: yBKx6gPzxzUd5orjXdX4SrU8zUw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleStreamDecor\r
+ ator.class\r
+SHA1-Digest: IEoR/9FAo15IsFfzhFFt+Gu+yZk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/CElementAdapterFactory.class\r
+SHA1-Digest: TMJQdSjxFfh72X2OSzR8zFDHsus=\r
+\r
+Name: icons/etool16/prev_error_nav.gif\r
+SHA1-Digest: YNfnoHIzL7VVaUwEo0L3oNIdBkU=\r
+\r
+Name: icons/view16/c_pers.gif\r
+SHA1-Digest: N2qFkomglU3hV1IkxEzX2bm5vss=\r
+\r
+Name: org/eclipse/cdt/ui/actions/FormatAllAction$2.class\r
+SHA1-Digest: zI6+VE2m6sano7D1ndBsbHFrLHo=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/DocCommentOwnerBlock.class\r
+SHA1-Digest: tXfML2gCrGwLlJL8Vm5B3l3FIlQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructur\r
+ eProvider$Counter.class\r
+SHA1-Digest: niAEkwlHhvamUpBnFR1jhbslgKE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/Messages.cla\r
+ ss\r
+SHA1-Digest: dwCSya/J3y5J7lHzZcq+iMyCfDc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/CPreview.class\r
+SHA1-Digest: 6dFOGUxarIz/mOWI505p42duplk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CombinedWordRule$WordMatcher.cl\r
+ ass\r
+SHA1-Digest: HLGsanXo0ybMbtfqucxq7CpMR60=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/ASTSpecificNameVi\r
+ sitor.class\r
+SHA1-Digest: 1XyQBDZE3ijZq5mRPS+AGu/hVXk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractconstant/Messages\r
+ .properties\r
+SHA1-Digest: SPxjgojN5zb54hF1bPUqiARufYk=\r
+\r
+Name: icons/obj16/over_co.gif\r
+SHA1-Digest: KDXEkxrj3cdRhNP0UO9f3ztxPQc=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage$SourceFold\r
+ erFieldAdapter.class\r
+SHA1-Digest: pzE8RJpV7+VwlFeDAIx+SP3VPM8=\r
+\r
+Name: org/eclipse/cdt/internal/corext/util/SimplePositionTracker.class\r
+SHA1-Digest: Bn7bnIdFfT+JPvikeviqby/JGOg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/PathEntryVariableDialog.\r
+ class\r
+SHA1-Digest: F87umOwclwTy6i5vQ6SMECFXrYg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/IStatusChangeListener.class\r
+SHA1-Digest: nE9SYFnbdxDaGQdsatZfp3H65SY=\r
+\r
+Name: org/eclipse/cdt/ui/CDTSharedImages.class\r
+SHA1-Digest: sgEn197TDgJxkOsJGPUonizFFVE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigura\r
+ tionBlock$3.class\r
+SHA1-Digest: q8SC2T0H3gQcRdv1LrHvGOJN9zY=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/ProjectSelectionPage.class\r
+SHA1-Digest: 5rffIY3YUczwvj/h8KVZKbYAiBE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/ExternalSearchDocumentProvide\r
+ r.class\r
+SHA1-Digest: u4WmQHj3Hc9E7pDtOSsUN3jEhi0=\r
+\r
+Name: org/eclipse/cdt/ui/newui/EnvironmentTab$EnvironmentLabelProvider\r
+ .class\r
+SHA1-Digest: tUT6Ctk4sHqKR28qkUf9dFlzOtE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/BuildLogPreferencePage.c\r
+ lass\r
+SHA1-Digest: mmJXm9IacEObtN7GZx1fhRLzPiQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CSourcePreviewerUpdater$\r
+ 2.class\r
+SHA1-Digest: ScOuC+RPB7HVdfDqgU7fSI+h9ww=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigura\r
+ tionBlock$SemanticHighlightingColorListItem.class\r
+SHA1-Digest: Azq3ptfn3JdH5t1uZ6Mqis38tV4=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/conversion/ConvertProjectWizardPage$2\r
+ .class\r
+SHA1-Digest: cjSF44uHORpwVJ4Qe4mAXGuGjtE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/SourceViewerInformation\r
+ Control$1.class\r
+SHA1-Digest: 432Adb5s7LTtcwXzjDwpQZtiYuc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSetti\r
+ ngsWizardPage$4.class\r
+SHA1-Digest: ivbSUFFM1ZERSzBHVW2z/Ioh588=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/ToggleSourceAndHeaderAction.c\r
+ lass\r
+SHA1-Digest: Gr+uURKQdhJwwpdd9+tf/Qj1oIc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/CopyAction.class\r
+SHA1-Digest: 3kimFLty1C7NvH7VsdgDXB35Vdo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/CorrectionContext.cl\r
+ ass\r
+SHA1-Digest: bA8uVfPgqgCH4cM2Z4Ok2XXR1B8=\r
+\r
+Name: org/eclipse/cdt/ui/CElementLabelProvider$1.class\r
+SHA1-Digest: eG8ycqUHqHDmd1/tUvSCKtRVHjU=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ErrorParsTab$5.class\r
+SHA1-Digest: rqnh2zda5bVlaiYajur6bd1zwrM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/ExcludeFromBuildHandler.clas\r
+ s\r
+SHA1-Digest: qtWUjIHrTaIKqBafA+R45qGmb7o=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/implementmethod/Paramete\r
+ rNamesInputPage$2.class\r
+SHA1-Digest: i9Cw0fRNCtugj+ldykqHyyFG1ZU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/ProjectConfigsController\r
+ .class\r
+SHA1-Digest: 5MTohlQoHvbgJ/dCAP87m7DZ88M=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/MultiBuildConsoleAdapte\r
+ r.class\r
+SHA1-Digest: b9CjK8l+9rEpTt473DQUHggDvz8=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ICPropertyTab.class\r
+SHA1-Digest: C8Pg9iySEgMBS+dLONHxam0DkZk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/SourceFileSelect\r
+ ionDialog$2.class\r
+SHA1-Digest: BtxmWZWicQWRV08JTVRr45Da5l4=\r
+\r
+Name: org/eclipse/cdt/ui/text/SharedASTJob$1.class\r
+SHA1-Digest: lT780CpggUETVV+w8o6i3K3PIwo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/RefactorActionGroup.class\r
+SHA1-Digest: nHZfHv0fs/r+zXkumXcF50eUrFs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$4.class\r
+SHA1-Digest: xkjKyjmWFV3Gcifn8J4sp7ZHIvY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/OpenActionUtil.class\r
+SHA1-Digest: v+gb0lOQYH/VE9E4Jsw/3EF5MYg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Genera\r
+ teGettersAndSettersRefactoringWizard.class\r
+SHA1-Digest: KazXClCFFkRwpNBK43Ai/DZTsHg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/HidePolymorphicCalls.class\r
+SHA1-Digest: ZUfMQAx8j8lE3G/CTLunHLoGoTw=\r
+\r
+Name: icons/obj16/fatalerror_obj.gif\r
+SHA1-Digest: wECu0FNAXJQ2RdiWNXxPdPgnm8k=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage$14.class\r
+SHA1-Digest: GRZptrgSB8DQl5x+7p+/5iMkJzU=\r
+\r
+Name: org/eclipse/cdt/ui/CElementContentProvider$RefreshProjectState.c\r
+ lass\r
+SHA1-Digest: QAlC3FbGltdHvXC91O0iiRkoRgg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Getter\r
+ SetterContext.class\r
+SHA1-Digest: D07W0UXSEtYwYxfUcIlxrvF/c8E=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/TextSearchWrapper\r
+ .class\r
+SHA1-Digest: rKtaFJmiSJ1R464h0x4XWX/8/Yw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/RefactoringStarter.class\r
+SHA1-Digest: 0zw9w8QInuhjlnXUsc4tvpb+D8I=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetPage$3\r
+ $1.class\r
+SHA1-Digest: vn0WgeBQ4ESixMhGk5a8CP0SqTI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/AbstractCompareViewerInformatio\r
+ nControl.class\r
+SHA1-Digest: S3IQim32Qdq0PUg+dncb0BXi8OQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/CElementLabelComposer.cl\r
+ ass\r
+SHA1-Digest: Jq/Rvuc2MR4EvKYikbQg4UxK838=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformation\r
+ Popup$1$1.class\r
+SHA1-Digest: 2Yb3GyoylAN4N7+uPcFOQZYqy8k=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/engine/IPhoneticHashPr\r
+ ovider.class\r
+SHA1-Digest: MVOC9mdlEExkqpxe/s6v2QrK6+Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/QuickAssistLightBulb\r
+ Updater$2.class\r
+SHA1-Digest: 0fd/19S1A/fvDD1+u33o5E/a02w=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/ScalabilityPreferencePag\r
+ e.class\r
+SHA1-Digest: Dz7i8FqflbutKUDJ92Wa3wBSlWM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CDocumentProvider$GlobalAnnot\r
+ ationModelListener.class\r
+SHA1-Digest: GRVdYaCbdh9qFiRYsJScH4a5AOE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/CompositeActionGroup.class\r
+SHA1-Digest: ftl1VSQFSjuRoxAsZ0rUqKc0CDs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction$I\r
+ ncludeCandidate.class\r
+SHA1-Digest: 3KKw9DJjgqRirWeZwMyEV2xEND0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/RefactoringExecutionHelp\r
+ er.class\r
+SHA1-Digest: 2cxIMjBmi89ErDrCBufhaQ3+M1E=\r
+\r
+Name: org/eclipse/cdt/ui/newui/NewConfigurationDialog$1.class\r
+SHA1-Digest: MUAXExWfyA2VDAHNswhx6ty+U2U=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/template/TemplateEngine$CTempla\r
+ teProposal.class\r
+SHA1-Digest: MBV5So2d/eDDxOT8sVQFCG3b4d4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/FoldingActionGroup.class\r
+SHA1-Digest: CJ5ds0NW2YDU/dYvaWh77nRS+Pc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/AlreadyExistsD\r
+ ialog$1.class\r
+SHA1-Digest: NxN6skA3qNrdtscPRuOneSCciDw=\r
+\r
+Name: icons/view16/templates.gif\r
+SHA1-Digest: sg0amGsP6xpwOtQREvtgql81P3I=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/PathEntryVariablesGroup$\r
+ 4.class\r
+SHA1-Digest: WTF++JdvkRAC85iViFOGOVQWs3s=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/AbstractErrorParserBlock.class\r
+SHA1-Digest: baUB2/9gM/1BeF4mOE9khDwoFGY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/CView$10.class\r
+SHA1-Digest: lZY7N4l6gsMw1CkXBPbLqfmZ6PQ=\r
+\r
+Name: org/eclipse/cdt/ui/newui/EnvDialog$2.class\r
+SHA1-Digest: hek5NPwY0PZtN+vK0OsSjmBpHo8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/CSpellingService.class\r
+SHA1-Digest: zS+QKZ8OcDlpI4hCuv+mdP+SHkQ=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage$4.class\r
+SHA1-Digest: GsiUN6UwokjQXomlHrj4E2l98lU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/AbstractPreferencePage$6\r
+ .class\r
+SHA1-Digest: Zr6aFfj9pyNJ4JULS8hKCECT64c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/filters/UsingDirectiveFilter.class\r
+SHA1-Digest: q4U0F5Al5Jiu8ftjbyD1/Qqh5wY=\r
+\r
+Name: org/eclipse/cdt/ui/IFunctionSummary.class\r
+SHA1-Digest: 5ecdIt3qNa46eRLXTVGhi9QYyKA=\r
+\r
+Name: icons/etool16/opentype.gif\r
+SHA1-Digest: C6QxIalu+c0nwvdQc/taH2lWlcY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkingSetProjectConfigu\r
+ ration$Snapshot.class\r
+SHA1-Digest: x3X7qP48fe8Z1Ni+BR3tm03iUuU=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/ProjectSelectionPage$1.class\r
+SHA1-Digest: 6UIBCBaPkLKpNhsZLitnh9Gi4JM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingPrope\r
+ rtyPage$1$2.class\r
+SHA1-Digest: iGIB5ARZtsHa9W53HuCv8S1UiU0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/dialogs/CTextEditChangeP\r
+ reviewViewer.class\r
+SHA1-Digest: SDnLkFBIa/xAZUhhD1SKTQoSE/Y=\r
+\r
+Name: icons/etool16/config-linker.gif\r
+SHA1-Digest: KMfMEM2NLdzgGRX+VIQI1rlSh9A=\r
+\r
+Name: icons/obj16/include_obj.gif\r
+SHA1-Digest: torGTf0k3nn12ONa1poxzVWfTCg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Getter\r
+ SetterContext$FieldWrapper.class\r
+SHA1-Digest: JxEU0AfOTiSrU+hK8zytywlmWBs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/RemoteTreeViewer.class\r
+SHA1-Digest: jS/9fyrFVaiggnXdWJRiLLjnSrk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THHistoryListAction$Hi\r
+ storyListDialog$1.class\r
+SHA1-Digest: NPTQLaGqM34aeKlbC2hmtoNZoG0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/ActionMessages.class\r
+SHA1-Digest: wIgdrPvFWonuNcRDIoVAB8IOJ4E=\r
+\r
+Name: icons/obj16/fldr_sys_obj.gif\r
+SHA1-Digest: DQZ72f/RyEQDXiPl3vw831LsQSg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/Symbols.class\r
+SHA1-Digest: N9lajRuZrFrJR5saoQ4nOef0hL8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDia\r
+ log$2.class\r
+SHA1-Digest: 5e+c9IGADXqHF+oTKjuIFywNRkg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/CSelectRulerAction.c\r
+ lass\r
+SHA1-Digest: zC1W6xIOdP2unze76JHdBR5vS2c=\r
+\r
+Name: icons/dtool16/newmngcc_app.gif\r
+SHA1-Digest: /S3AManCmOCLVqzgLpTgo+Hxzzc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/RemoteTreeViewer$1.class\r
+SHA1-Digest: VvSfH0Usier4gIC3YuQmelnIuiU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/NonExtra\r
+ ctableStmtFinder.class\r
+SHA1-Digest: SgCRk7nZzrQTRgJoNii2vho5yiM=\r
+\r
+Name: icons/dlcl16/history_list.gif\r
+SHA1-Digest: SCeVr68Cq8tQcs0kY5zKkmjpE9c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/ExternalEditorInput.class\r
+SHA1-Digest: SYY3j2kDvZk4jGyE2dpwXSxmfZc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/DocumentAdapter$DocumentSetCo\r
+ mmand.class\r
+SHA1-Digest: cOJcSNhDALlw+hj8lOQq/Z9g3UY=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/CommentContext.class\r
+SHA1-Digest: CI3ipaIXPjSn3FRjQrEm/aoUTG4=\r
+\r
+Name: org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.class\r
+SHA1-Digest: POrUebEFgLaVx544nDXKpgf6KJE=\r
+\r
+Name: icons/elcl16/hierarchy_co.gif\r
+SHA1-Digest: FFNUDZHFCK4MHDCdDjzXil+Wiws=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetPage$3\r
+ .class\r
+SHA1-Digest: WSe4Ewq9MecS9yFkP+JztbJBikM=\r
+\r
+Name: icons/obj16/output_obj.gif\r
+SHA1-Digest: vgF/59HXxpTFFwkrAJ3CTXkpL3c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField\r
+ $2.class\r
+SHA1-Digest: hH5RQskGlOjmsXRolb8p18sCwxY=\r
+\r
+Name: org/eclipse/cdt/ui/newui/MultiLineTextFieldEditor.class\r
+SHA1-Digest: 3jElbrSod2Z37plV9oShDX02kSw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart$11.class\r
+SHA1-Digest: EWdEKQ5KqMAAAJKPwjBvEUqF9s0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHNode.class\r
+SHA1-Digest: 2jKRQVRNj+G5MhlrZ2L3wsOGs7Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/StatusLineHandler$1.class\r
+SHA1-Digest: 9/WBwgfcNzc5dP7PxUtwTW25F2s=\r
+\r
+Name: icons/dlcl16/progress_stop.gif\r
+SHA1-Digest: a1fk9sjTOUwC9n/6ZwqIMX9TiMA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/FileLanguageMappingProperty\r
+ Page.class\r
+SHA1-Digest: Ll4hwHf8deHBkabi1GVpwZHvmWQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/ChangeExceptionHandler$1\r
+ .class\r
+SHA1-Digest: v9d9qF2mdGcc/FRUYYwQcqBhsSA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleNod\r
+ eHelper.class\r
+SHA1-Digest: YqToy8NiijHsfuV00MGl+gdQwA0=\r
+\r
+Name: org/eclipse/cdt/ui/text/IProblemLocation.class\r
+SHA1-Digest: tkbmglRBLE5gULyXrw6eaqZQ2qM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlo\r
+ ck$SectionManager.class\r
+SHA1-Digest: 60f3D90c9xdUgjPUU3hHiA/MbJg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/SurroundWithActionGroup$1.cl\r
+ ass\r
+SHA1-Digest: AnqURcTwjqNe2qAcoutEzpsZNYw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsLabel\r
+ Provider.class\r
+SHA1-Digest: 3dT0JH0cinVPNCMuPVPA1/og9Rw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/DestructorMethod\r
+ Stub.class\r
+SHA1-Digest: xgkyOvY/eAZLCZKBOirpWtQmUzU=\r
+\r
+Name: icons/obj16/field_obj.gif\r
+SHA1-Digest: mQkXRhY1qk9A0Uv7XxliqGgjAmQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/NameStyleBlock$FilenameV\r
+ alidator.class\r
+SHA1-Digest: BtPCJ32VFOG67pq+GnpZcwtwV5I=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionExplorat\r
+ ionControl.class\r
+SHA1-Digest: F1KOPsT2SN48iKc8R8zAFSy2fUQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/LanguageMappingWidget$1.cla\r
+ ss\r
+SHA1-Digest: vRXxgZeIpSRFpCvIp0U/U3Vcy0M=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/LineWrappingTa\r
+ bPage$5.class\r
+SHA1-Digest: DUMnNwJXW1aubeHvwz5lry8vg3I=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/ColorSettingPreviewCode.\r
+ txt\r
+SHA1-Digest: AA0KPE9jfBIBYI9ovxR18uNxJe8=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/AbstractGNUBinaryParserPage$1.class\r
+SHA1-Digest: y5jRIAEo/Qoz448bd71J4wp1aus=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ProfileStore$P\r
+ rofileDefaultHandler.class\r
+SHA1-Digest: eYEc4bmbpyL0gB51fKZF+He4XCg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuActi\r
+ on.class\r
+SHA1-Digest: AWcXAD/io+hmyPXyeORAh3/auMI=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/CDTMainWizardPage$1.class\r
+SHA1-Digest: E/Uwvg2IIBa8PeBNuvalXDfA6+Q=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/CustomCodeForm\r
+ atterBlock$1.class\r
+SHA1-Digest: waG0o5wmer+VU7/y3RvbG0z/TmI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/ConsoleMessages.propert\r
+ ies\r
+SHA1-Digest: xwMIrz9oTywXllxFfS4Md3bY8dw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider$2.cl\r
+ ass\r
+SHA1-Digest: /lFplqUVCRpJm/VBlJSMzwfu7kA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEnt\r
+ ryPerFilePage$1.class\r
+SHA1-Digest: uFlr4IFXscYvNyLrfljQ/02Uc+0=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractLangsListTab$4.class\r
+SHA1-Digest: bfabSSM2KGfK0PWXcPd2hmHHzA8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractS\r
+ tatement.class\r
+SHA1-Digest: 4ADxSbDARDDrWqoV5nfbwTAD3wQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlo\r
+ ck$TaskTagAdapter.class\r
+SHA1-Digest: d9twIYmJe/XfOykpOczSjZDSVuA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$25.class\r
+SHA1-Digest: znfOrqn3ITPASACMAlAJF7yWJP4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/UndoCTextFileChange.clas\r
+ s\r
+SHA1-Digest: A4HZLg2JBsM0v+xhRGT87xvL3DA=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ExPatternEntryDialog$ExPatternAdapter.c\r
+ lass\r
+SHA1-Digest: bNPaGlh/wA8GQVIyw7U0oGbXJ/o=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/StructureSelectPreviousActio\r
+ n.class\r
+SHA1-Digest: agthWcmmVRuPXwBkCHcr3s3cMUI=\r
+\r
+Name: icons/dlcl16/search_next.gif\r
+SHA1-Digest: 0h0HOynRlbXGQMjIqXF58mcDuiA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/SmartTypingConfiguration\r
+ Block$2.class\r
+SHA1-Digest: PL2mrMT12ACUO3g7Bl7v4suEUEo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlo\r
+ ck$2.class\r
+SHA1-Digest: 6Uwyd9wsCmbCulQR4i1RD6h/ivA=\r
+\r
+Name: icons/view16/chierch_pers.gif\r
+SHA1-Digest: J2um07jhhBc2bPlNBLzMWket5KM=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/CContext.class\r
+SHA1-Digest: QuYAfdFHOQew3qfdefOIWFlIgQU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsListD\r
+ ialogField$CellHandler.class\r
+SHA1-Digest: ahNlbDY3keL7B89uF/+F2plcK2o=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/CUIHelp.class\r
+SHA1-Digest: JxjOh2GFf9Z1LCE5j7eOqyjXEWg=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/AbstractErrorParserBlock$1.class\r
+SHA1-Digest: I7g5JbT4VXKt/xE3qZ8aA0ZtK2U=\r
+\r
+Name: org/eclipse/cdt/ui/refactoring/actions/HideMethodAction.class\r
+SHA1-Digest: u4Ugc19Y1+2+w73h7wVDRkm4Yko=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/IndexerBlock$1.class\r
+SHA1-Digest: jXkhBYWUKJ8D4EvfeCZhRF4KW90=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfiguratio\r
+ nBlock$HoverConfig.class\r
+SHA1-Digest: HAKqxiPqDH/ouWmyksK3oQFSv+k=\r
+\r
+Name: icons/elcl16/inher_co.gif\r
+SHA1-Digest: 2ZN81EaulECr8AIlKyQGtcHJi18=\r
+\r
+Name: org/eclipse/cdt/ui/newui/MultiCfgContributedEnvironment.class\r
+SHA1-Digest: N+LCTKgRZ8/d51Mj4HQaCyd+6eQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/BusyIndicatorRunnableContext.cl\r
+ ass\r
+SHA1-Digest: G72gKVFnUVJQWieD/9U32eSpObA=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/CygwinPEBinaryParserPage$8.class\r
+SHA1-Digest: XCtyaq9QzevhW+RKwHGMGo8NxC4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/asm/AsmLabelRule.class\r
+SHA1-Digest: B/k0yIWymG7U5257LP9UrwzRe2c=\r
+\r
+Name: org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog$2.class\r
+SHA1-Digest: AeH/icuqpcAhL+HK2LASzbbKxkM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$19.class\r
+SHA1-Digest: z5l5cYQ7ZQeUo3swAVCp51JsJwM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileCrea\r
+ tionWizardPage$1.class\r
+SHA1-Digest: mbkNhywTwIFXMbZUoR9MxSxXWHU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBloc\r
+ k$1.class\r
+SHA1-Digest: UCJ+NqpoPrI5U19vedFVT5wwzls=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/IPDOMSearchContentProvider.cl\r
+ ass\r
+SHA1-Digest: LNWvdvMwmCLWDLcytmEjGK+F/gg=\r
+\r
+Name: org/eclipse/cdt/ui/newui/CLocationTab$_Filter.class\r
+SHA1-Digest: bNeDxLMqHKJtaHwgkdZ++xm1S+w=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationM\r
+ anager$2.class\r
+SHA1-Digest: Pb4FwywXU0F4Ik0Kz4Rw8WNXGQo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THHistoryListAction$Hi\r
+ storyListDialog.class\r
+SHA1-Digest: am4SAVsbtwEg01fG4QQ90r7zq9g=\r
+\r
+Name: org/eclipse/cdt/ui/text/doctools/generic/GenericTagCommentScanne\r
+ r$1TagDetector.class\r
+SHA1-Digest: beSFt/D5sgzVq85FL5aevRsbKhc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob$1\r
+ .class\r
+SHA1-Digest: vHG6LEG5drER22fWVKj37SFI0cE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathFilterPage.class\r
+SHA1-Digest: QgnjqSGmq+1p0wGJ+43J8glucmY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightingManager$H\r
+ ighlightedPosition.class\r
+SHA1-Digest: KuTz8FXHNrpQNTbyzGcAHPHG7ig=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/DecoratingCLabelProvider\r
+ .class\r
+SHA1-Digest: LMwG9uUKi4lC7m3dJnduOXFIaiE=\r
+\r
+Name: icons/elcl16/config-tool.gif\r
+SHA1-Digest: GMPYVJJSFAuzmXjT+4nXLCyHmxc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/QuickAssistProcessor\r
+ $2.class\r
+SHA1-Digest: QSa0F0FQ5ww3T78DYD/nj9Xmt4Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/implementmethod/Implemen\r
+ tMethodInputPage$2.class\r
+SHA1-Digest: fuEIqUC/5v6qVWxiDG7NqxXKGZQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceTabP\r
+ age$SyntaxComponent$1.class\r
+SHA1-Digest: XiExwNpBB+NNiD72e3NYCWefGEc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceTabP\r
+ age$SwitchComponent.class\r
+SHA1-Digest: FnprV+R2HnwD3RtdpgeW4+G0PM8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerDefault\r
+ Page$1.class\r
+SHA1-Digest: ewJGQAWuns6nkV3HUVQ/jxx0SzE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationB\r
+ lock$3.class\r
+SHA1-Digest: cqzRQSEt4Ri2otpnXlicAdvaXd4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/MessageLine.class\r
+SHA1-Digest: nLsf+JdMtfq+Ix2E6FtXE6jTR3U=\r
+\r
+Name: icons/dlcl16/super_co.gif\r
+SHA1-Digest: TdtBKpwk7WFxFvxdQZH6wmRXIK0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/SimpleCSourceViewerConfiguratio\r
+ n.class\r
+SHA1-Digest: 3Z5l7P/Aq0uoEGmVGay8bT13vyg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/togglefunction/Insertion\r
+ PointFinder.class\r
+SHA1-Digest: C7zgnwSSVEy1K+YbMbs1pKQTYW4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingWid\r
+ get.class\r
+SHA1-Digest: Edi10N1TujUQDAelNYu7RIVGPHc=\r
+\r
+Name: org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog$StringCo\r
+ mparator.class\r
+SHA1-Digest: Plt1+7WE+lHC6Grm1sPd6zV7RK8=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/TranslationUnitContex\r
+ tType$EnclosingCElement.class\r
+SHA1-Digest: /fFMpIMbqGyvBNlf5jo11lqzdZ8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/TranslationUnitAnnotationMode\r
+ lEvent.class\r
+SHA1-Digest: bU4/b40GqdM45Vo96JV37i2+vWU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/PathEntryVariableDialog$\r
+ 2.class\r
+SHA1-Digest: ZVKkvM578nmNEoWITS88eYUkTJU=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/PreferenceScopeBlock$2.class\r
+SHA1-Digest: eZwBsAX+YoNbd0pV3sp0RfjdUwc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/filters/NonCProjectsFilter.class\r
+SHA1-Digest: vjxe5aPhp/nwQHYNks54CEhRcsI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover$2.class\r
+SHA1-Digest: TSUKZSMw/tP3ljqnvvX3SWVgjrg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkingSetMessages.prope\r
+ rties\r
+SHA1-Digest: h+TW3bao5ARCxAp10D2fDBELAy4=\r
+\r
+Name: icons/ovr16/static_co.gif\r
+SHA1-Digest: 3BscdGswbpsjoLPlTMssi/qyEhc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposa\r
+ lComputerRegistry$1$1.class\r
+SHA1-Digest: 1uFQAPDVhpmaP8qgTIk9gGJFQyI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/NameStyleBlock$Identifie\r
+ rValidator.class\r
+SHA1-Digest: 5Yuttkj/24XE6BtuWiL4cErB7lg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformation\r
+ Popup$8.class\r
+SHA1-Digest: s+cdj5tRl7/oJtFSpNDaGqzJidM=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ExPatternDialog.class\r
+SHA1-Digest: phnzX1d+3sgh/3bUZBwPGfEu5+8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/NameNVisibilityInformati\r
+ on.class\r
+SHA1-Digest: dwrmaq5TGWfjCZ9AE/KxkR75MxI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField\r
+ $ListViewerAdapter.class\r
+SHA1-Digest: j/k1Sy1vubBP8RQAiLybqJ1F2/Q=\r
+\r
+Name: icons/obj16/text_edit.gif\r
+SHA1-Digest: ZE6lBeZSol/uR9TJZFYf5PELdfo=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/InputStatusDialog$1.class\r
+SHA1-Digest: sNZw7tAMhmp4y/kQvXU56ja/ejs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/compare/CContentViewerCreator.class\r
+SHA1-Digest: 8YjC9N3dxbKxQbgdgrj/k6IG6H4=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/uitree/IUIElementTreeBuilderMa\r
+ nager.class\r
+SHA1-Digest: Ku8oElM9NfZvjAdngQHvWGudMjU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBloc\r
+ k.class\r
+SHA1-Digest: VJgXTtmKuKwzcoT2tUBpgcexkVw=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractPage$4.class\r
+SHA1-Digest: BadyE2aRVF6d/BD6LsSOiLWwUO0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/CHelpDisplayContext$1.class\r
+SHA1-Digest: 4onTNNMeFnEIwy0yasFPlKFAwic=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CContentOutlinerProvider$1.cl\r
+ ass\r
+SHA1-Digest: 3KsnKWloXS3SdCQou8i2RwtTyDs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/StructureSelectNextAction.cl\r
+ ass\r
+SHA1-Digest: vCfsdpf2paJc0WSXxLXq+vg+5bg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/dialogs/ExtractInputPage\r
+ $1.class\r
+SHA1-Digest: ImRR5Na+hVnXea/3HoBcmL8GnAg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/IWorkingSetConfiguration\r
+ Element.class\r
+SHA1-Digest: UWxI2VNQSjr6jm9u91qmKsDzeLc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractconstant/Messages\r
+ .class\r
+SHA1-Digest: NLSIyXb81CdB9UiSl0xOPCcGEDE=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/DocCommentOwnerBlock$2.class\r
+SHA1-Digest: 5FrYCmPOVv1kxvIZqmAiC/OPkc8=\r
+\r
+Name: org/eclipse/cdt/ui/resources/Messages.class\r
+SHA1-Digest: 5VqusBHQ5AHj1228kxJMBH1wzow=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/PDOMSearchListContentProvider\r
+ .class\r
+SHA1-Digest: OOaW9LFDx8R0a7Z2jULnieI+azY=\r
+\r
+Name: org/eclipse/cdt/ui/IWorkingCopyManager.class\r
+SHA1-Digest: S2TnxVBJC0GseKpyAgbQvTIEJLU=\r
+\r
+Name: org/eclipse/cdt/ui/actions/ChangeBuildConfigMenuAction$1.class\r
+SHA1-Digest: 0UojY+lDYPDZqiQ+yZj84gBkL3c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractC\r
+ onstantRefactoring.class\r
+SHA1-Digest: bbU1os0mC7KlSdH/hZ2aaeB1IEI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBConversions.class\r
+SHA1-Digest: XWQyGyFrJ83508tQpMOm9uzgP1s=\r
+\r
+Name: icons/etool16/config-tool.gif\r
+SHA1-Digest: GMPYVJJSFAuzmXjT+4nXLCyHmxc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/ListContentProvider.clas\r
+ s\r
+SHA1-Digest: xta8ddv61oML6PeC1R4ORsFO5a8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/util/CWordDetector.class\r
+SHA1-Digest: 1jBv1hSfu5f2h6/UCahXQEq9Ezg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBHistoryAction.class\r
+SHA1-Digest: grs6AYnDYahT6bkEnTlVCQPr918=\r
+\r
+Name: icons/obj16/quickfix_error_obj.gif\r
+SHA1-Digest: syy/dePAYAEfMNGOGwFWBBH993s=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/TranslationUnitContex\r
+ tType.class\r
+SHA1-Digest: PWwot5csD8mXZeIxKLJxN8UX4DA=\r
+\r
+Name: org/eclipse/cdt/utils/ui/controls/FileListControl$4.class\r
+SHA1-Digest: 9zwB0I2gE1yBn3662oXd/Tw1shg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/AppearanceAwareLabelProv\r
+ ider.class\r
+SHA1-Digest: FT4c6U17irUtJzGyd1OT/Y75gUQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/ChangeTreeSet.class\r
+SHA1-Digest: XVL6cruVOsUHjs8rgj2IO1azY7U=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/processes/messages.properties\r
+SHA1-Digest: Ri5Mf0ehkx4EjxwOg7Q6mXqUKig=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/SelectionTransferDropAdapter$1\r
+ .class\r
+SHA1-Digest: FHUnfNnv/2+h9WeSOm9FisOJt5Q=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ManageConfigRunner$1$1.class\r
+SHA1-Digest: ZLolNtN1WTblF/xVxrE3PG28uiE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/CView$4.class\r
+SHA1-Digest: Azpcsj6X3xjbH0XifAbwTpLjxh4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/doctools/EditorReopener.class\r
+SHA1-Digest: B9yTSEUUfVOF4ndlbqAvodMwYY4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/indexview/ToggleLinkingAction.class\r
+SHA1-Digest: lHXVB5KC3kgBe3q02WXAv8U9EQI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/resources/ResourceExclusionContribut\r
+ or.class\r
+SHA1-Digest: Qv3If55LZ8ZDsMMqfKf/nq9qxnM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationM\r
+ anager$WorkingSetChangeTracker.class\r
+SHA1-Digest: t21mvngg4q4kGpDLz9/vaXuGE9g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBViewPart$17.class\r
+SHA1-Digest: 68oetoGK1iY82NamgpCKb6KgVCg=\r
+\r
+Name: icons/dlcl16/open_include.gif\r
+SHA1-Digest: 5uorTPM3yjxrRe97ZyoIACFwGG4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/filewizard/WizardNewFileFrom\r
+ TemplateCreationPage$2.class\r
+SHA1-Digest: Q9DEGx3CBL1kVNWwCSHbJYatltA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/PDOMSearchPage$5.class\r
+SHA1-Digest: /HiY9KWVuVzkLr+RrMpPm9D/iPw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/CUIMessages.properties\r
+SHA1-Digest: qIpkvzGBkNhxLKvK065sW0xvX4U=\r
+\r
+Name: icons/obj16/shlib_obj.gif\r
+SHA1-Digest: uqKGs7aLWGUlYdm4m19+YLQCxD8=\r
+\r
+Name: icons/obj16/incc_obj.gif\r
+SHA1-Digest: fzP1836Z0sa/slwGPCRZtfLCIy4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/togglefunction/Insertion\r
+ PointFinder$3.class\r
+SHA1-Digest: Lr7nFfbQGM2qCKeK3TYglvj6+lg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleFactory.cla\r
+ ss\r
+SHA1-Digest: h65WXkm1N/1O6XRRSqn6oCyhKJY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CDocumentProvider$2.class\r
+SHA1-Digest: q1aedTtdu+TkB/heJpEaVpI0Fkk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSetti\r
+ ngsWizardPage$11.class\r
+SHA1-Digest: twEEGrY9JWj45RtbdTkHHa4qlsg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionInput.cl\r
+ ass\r
+SHA1-Digest: B7md3MNhYW/0Kjpw9C8tIQTyY2M=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/Inp\r
+ utPage$InputForm.class\r
+SHA1-Digest: daHCsShGX413RmlngoKcn3TF680=\r
+\r
+Name: icons/ovr16/error_co.gif\r
+SHA1-Digest: 837WZOYq5P1nCsjer7IptxeeAX0=\r
+\r
+Name: org/eclipse/cdt/ui/ICHelpResourceDescriptor.class\r
+SHA1-Digest: Imgyxp3IfdyfkEZNUnS2cJMKXQg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRef\r
+ actoringDescription.class\r
+SHA1-Digest: PEM82DolGy6DjvteM2523Vnp29w=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringArgum\r
+ ent.class\r
+SHA1-Digest: sdtv1e0KyDXhc/XgR6dVvx8Gw9E=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/ColoringLabelProvider.cl\r
+ ass\r
+SHA1-Digest: bYXgoXVIXAy98icB5IgthsOFfvo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Genera\r
+ teGettersAndSettersInputPage$3.class\r
+SHA1-Digest: /+21woPFdD7mITSbde9j3i7QAmo=\r
+\r
+Name: icons/dtool16/build_configs.gif\r
+SHA1-Digest: FgSfgP7vEGZZ/a2a6BN1roPzq1g=\r
+\r
+Name: icons/dtool16/prj_obj.gif\r
+SHA1-Digest: PhGG9JETsxO0xOQzu9UGYjvEDvU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/CreateProfileD\r
+ ialog$2.class\r
+SHA1-Digest: uL+XOqoXBit0NlXW1eMKohpOkrU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/filters/FilterMessages.class\r
+SHA1-Digest: nzWcYIBh7lgnHzR8R9bR+j1QkyA=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ConfigMultiSelectionDialog$3.class\r
+SHA1-Digest: oK1B6i4pYhO//CDqANgBlZejQBg=\r
+\r
+Name: icons/etool16/newc_app.gif\r
+SHA1-Digest: ZSD+UgNPsIZsh86caD2ZLOxwA+U=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/utils/NodeHelper.class\r
+SHA1-Digest: jZZ5lsWp8v7ApY0WxTJ7LvksF9w=\r
+\r
+Name: icons/dtool16/config-debug.gif\r
+SHA1-Digest: fLIS8zeWfmn8PU7157Txh/8aXws=\r
+\r
+Name: org/eclipse/cdt/ui/newui/IncludeFileTab.class\r
+SHA1-Digest: tGC+2/WVSvOhS4rvFLsnNexWKbc=\r
+\r
+Name: icons/dtool16/newc_lib.gif\r
+SHA1-Digest: aEavYs278NYGyEVyOSn3V1v5JS4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/CPerspectiveFactory.class\r
+SHA1-Digest: 2JG1+O8Gul3kodJ25L2x+2yg2oI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CDocumentProvider$Translation\r
+ UnitAnnotationModel$ProblemRequestorState.class\r
+SHA1-Digest: eUdRghornCONsxyu2Ui0m7QsjVE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CompositeReconcilingStrategy.cl\r
+ ass\r
+SHA1-Digest: 83uXCVaF25Zi41d2rBtPajie+1c=\r
+\r
+Name: icons/obj16/search_ref_obj.gif\r
+SHA1-Digest: rOF5wB6iqgilQvLuCPenOgSqBYU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBloc\r
+ k.class\r
+SHA1-Digest: ZzEKRElWarOEfrcSApaU1J67qXE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractF\r
+ unctionInputPage$1.class\r
+SHA1-Digest: XCb0Dxhq9SJBJRpuls+jw20jbQ0=\r
+\r
+Name: icons/dlcl16/action-editconfig.gif\r
+SHA1-Digest: dj4LtYYqWOTaI+VQES8fHEI6cFI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectInde\r
+ xExportWizardPage$2.class\r
+SHA1-Digest: ZJ020wo+/gPm4GF3XMpFL4RWehs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Genera\r
+ teGettersAndSettersRefactoring$1.class\r
+SHA1-Digest: 9PV1C0bjvEHpT3sUvu8Nr1kAIDw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesPreferenc\r
+ ePage.class\r
+SHA1-Digest: CcdoZzT4LDsj+6fsRAjgN0Ilw7w=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/PropertyAndPreferencePag\r
+ e.class\r
+SHA1-Digest: H/XTeaEoSZhBZjGgOD02iKr/+hM=\r
+\r
+Name: icons/etool16/mark_occurrences.gif\r
+SHA1-Digest: sbwSYFv55QQkp6B1B/tka8FhwRg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/UpdateIndexWithModifiedFiles\r
+ Action.class\r
+SHA1-Digest: MIV3olVSCsmLu61cV/MWu6MHh5E=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/WorkingSetFilter.class\r
+SHA1-Digest: uZPPTEPTlIKDd7FhHrt35JhVdns=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$EditorSelectionChange\r
+ dListener.class\r
+SHA1-Digest: HTNGUBG4lOrjR5kdX5hXG2Zaa54=\r
+\r
+Name: org/eclipse/cdt/ui/text/doctools/IDocCommentViewerConfiguration.\r
+ class\r
+SHA1-Digest: vq9cOKAW9Bn7kkrIhr328pBx664=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/MethodContext$ContextTyp\r
+ e.class\r
+SHA1-Digest: Lm1ArgLvthd5xha1o0JSyJQOpc4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/StringButtonDia\r
+ logField$1.class\r
+SHA1-Digest: 2WV6bjiCwWmycGCqXQeTXlKvpIk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerDefault\r
+ Page.class\r
+SHA1-Digest: thih6m/7FX/EUTZHNZJqrcpj3EA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathFilterPage$1.cla\r
+ ss\r
+SHA1-Digest: WZIC0Zte5H0S4pyixYxJT12F2Mk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THHierarchyModel.class\r
+SHA1-Digest: hPYINtvdhGjRq2ZO2ex/yv87o0c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceOpti\r
+ ons$Node.class\r
+SHA1-Digest: zHSCjzHvskxdVNci+ooq0FwcfAw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistPro\r
+ cessor$ActivationSet.class\r
+SHA1-Digest: eqLVLbR3BBuFWW2QuoLQoc4/phM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CDocHover$1.class\r
+SHA1-Digest: sJA6jcCVtLIEyNmAHs3+nOcfmLY=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/CygwinPEBinaryParserPage$1.class\r
+SHA1-Digest: +Nd6eys8NgaDGabeb3zAZV96f9g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$12.class\r
+SHA1-Digest: n5yFL0Xn+RsHIPivEaw0YxKXQew=\r
+\r
+Name: icons/obj16/typedeffo_obj.gif\r
+SHA1-Digest: dlyW/nFR9HyqyBZUF+VajsvlaKk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/DocumentInputStream.class\r
+SHA1-Digest: Eino/qQ7tqM3UPawv1eqqQIRJDo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$6.class\r
+SHA1-Digest: CAoKursEshvd/XIz3N4Wvwk49fc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/ProjectSelectionDialog$3\r
+ .class\r
+SHA1-Digest: 4J3Om9V4R8IF+O5NSFgd2YGVVwI=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ManageConfigRunner.class\r
+SHA1-Digest: rb8EI8bCeu3MQ9OK7eh1slLjz7A=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage.cla\r
+ ss\r
+SHA1-Digest: G/tT+0XXxhPJX9E5PQNKEwi8ix0=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/TabFolderOptionBlock.class\r
+SHA1-Digest: q2x8SWrtpGIK4+IABznD0bZbxBE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/IPreferenceConfiguration\r
+ Block.class\r
+SHA1-Digest: icQrKyqZigYGmn1us3pUwhjuiQI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/utils/FileHelper.class\r
+SHA1-Digest: NcVu0/MgGZiS1csB4A9BfJtsFPo=\r
+\r
+Name: org/eclipse/cdt/ui/actions/DeleteResConfigsAction.class\r
+SHA1-Digest: VvebcBzn7Wa957aH841eB2fy0IU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage$5.c\r
+ lass\r
+SHA1-Digest: QZYpgFC2rNP1Igl0xqB+ZGA9hZ4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractF\r
+ unctionRefactoringRunner.class\r
+SHA1-Digest: sqadHUulwW15PnEvpUx7vGfVtOA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/proposals/ChangeCorr\r
+ ectionProposal.class\r
+SHA1-Digest: PqXQNWcICzV0KSEIpMTp0hgMcfA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightings$ClassHi\r
+ ghlighting.class\r
+SHA1-Digest: Vsnx2gpcR4KPTt5/H9PccQwtzsE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/indexview/FindDeclarationsAction.cla\r
+ ss\r
+SHA1-Digest: R6ls4UWreFS7HQ5rT8pUZI/5MfE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/PreviousErrorAction.cla\r
+ ss\r
+SHA1-Digest: HIUSFWAnxiFNFFuVbv7HCzp5c48=\r
+\r
+Name: org/eclipse/cdt/ui/newui/StructureTreeTab$5.class\r
+SHA1-Digest: Se6Mady5KPu+lugcQiSD1SheS3U=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/ProjectConfigurationCont\r
+ roller$LabelProvider.class\r
+SHA1-Digest: SXUag68dCk6jaPKjw/6weBXAOWo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigsControl\r
+ ler$1.class\r
+SHA1-Digest: B4ORDcBGBb5Yd5Z6TA5uEsISTYk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/BuildWorkingSetConfigsCo\r
+ ntribution.class\r
+SHA1-Digest: UpUvppzRx0t1CegKdCth9uaLe1w=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog$8.cla\r
+ ss\r
+SHA1-Digest: 9usLjdC59qWeMLTys+KD6ZcbRJk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathOrderExportPage.\r
+ class\r
+SHA1-Digest: ofSzMdrJmSP/ya/4NCPL7jXRgFg=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage$1.class\r
+SHA1-Digest: P2qn5jFprQpfu/j/6BdXpajlsIQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/AbstractAnnotationHover\r
+ $AnnotationInformationControl$3.class\r
+SHA1-Digest: oq8owtlZWcHfHU7QwuZJVJvUBhk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/CRefactoring$1.class\r
+SHA1-Digest: 0/YKYW2AhveazRxxlMYrFj8v5Xo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBNode.class\r
+SHA1-Digest: nCRmFysMPartRabP6RC2PDEcydY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformation\r
+ Popup$1.class\r
+SHA1-Digest: zL0RtlPzLLzDM8wgl3zttGP2HoY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/TreeListDialogF\r
+ ield$2.class\r
+SHA1-Digest: 9SXr29NR5T/tplRd9so9x5s72pI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/RemoteTreeContentManager$Collec\r
+ tor.class\r
+SHA1-Digest: ZOcLGa6T2nh0ml89F1AlhQvfK/4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfig\r
+ urationController$IControllerContext.class\r
+SHA1-Digest: 9wAGJS2AXEsATw2yWT+2cySJ4Hs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/indexview/OpenDefinitionAction.class\r
+SHA1-Digest: aDS8L0RkWs/pIBs7dEi5UKyzOCU=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractExportTab$1.class\r
+SHA1-Digest: cwgjWpd94Sp81iU2yRZb4JIkcRc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CAutoIndentStrategy.class\r
+SHA1-Digest: lOJhtoOwMiYaCSczEL4kgMgzZu4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI$2.clas\r
+ s\r
+SHA1-Digest: HlPrYYB712lL2/56uHD1ngeM6Fc=\r
+\r
+Name: org/eclipse/cdt/ui/text/CSourceViewerConfiguration$5.class\r
+SHA1-Digest: QkUpBN8tYMqCX7wdh7dQTjZQ+38=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$SelectNextSubWordActi\r
+ on.class\r
+SHA1-Digest: Ez8o1ttgqCPw8pun9OqPZvBqJwQ=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/uitree/GenericUIElementGroup.c\r
+ lass\r
+SHA1-Digest: Ut7qxz3tvJaq2kEWR9LFjTykB4c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/SelectionListenerWithAST\r
+ Manager$PartListenerGroup$4.class\r
+SHA1-Digest: ow/ZhK4ku+bhsT2cyhYnln5Ddr8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage$COu\r
+ tlineLabelProvider.class\r
+SHA1-Digest: cRMotZHPL2s2mmQrh1i+M34+UGk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CHeaderRule.class\r
+SHA1-Digest: Lj+CtzjMQrR/Uyl08p/1haAMq2Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/BusyIndicatorRunnableContext$Bu\r
+ syRunnable.class\r
+SHA1-Digest: 74/hK2hXGsykauxkiqg3NsqQkhc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/Messages\r
+ .class\r
+SHA1-Digest: LK3nlq3nx1rt7cmyDoTdMlblqGg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfig\r
+ urationBlock$3.class\r
+SHA1-Digest: 9LB8tJ0dp6TgWr1a10fq3HefNGg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingWidge\r
+ t$1.class\r
+SHA1-Digest: R7YKuXwMbfxUziTiYjIbQcxn5sI=\r
+\r
+Name: icons/wizban/exportzip_wiz.png\r
+SHA1-Digest: IUCiNqVh4GynS98m6tiUjvIRaCQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/CViewMessages.class\r
+SHA1-Digest: AoSXlMndwWDtunPCiHsFBWGlHD0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/NameStyleBlock$NameStyle\r
+ Adapter.class\r
+SHA1-Digest: xM2PB2FazluQwkaR+W86A7+4TS0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CEditorTextHoverDescrip\r
+ tor.class\r
+SHA1-Digest: qIlTUAoR2a1voaXGhQekFYGXtps=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBViewPart$4.class\r
+SHA1-Digest: 8FTvViLiC91HAHjPf0VCgKizWTA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage$2.\r
+ class\r
+SHA1-Digest: ozV1eO2lWpZSr8Y+Rglz1jCgVP0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/implementmethod/Messages\r
+ .properties\r
+SHA1-Digest: yaCkORxEIXW2gNEsu03DvQawLwg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/Visibility.class\r
+SHA1-Digest: MzGXYujaylIsG4syNtcdFgiXpEU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/RemoteTreeContentManager$3.clas\r
+ s\r
+SHA1-Digest: uOC7tnsKyhaUnHh8/NriadPtl7Q=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ExpDialog.class\r
+SHA1-Digest: 4hWmCoAQonHmVFGeIYr5RV+AajM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/filters/FilterDescriptor$1.class\r
+SHA1-Digest: OX2Qe/VMgDzEgL5MNZGunoTYr3g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction$3\r
+ .class\r
+SHA1-Digest: EzEG8gGTxBSXor8/7t1WAJ4WfVw=\r
+\r
+Name: icons/elcl16/shift_r_edit.gif\r
+SHA1-Digest: Xr1jTQX3qaABFpjlYytDMqo2ovs=\r
+\r
+Name: icons/elcl16/save_console.gif\r
+SHA1-Digest: BQj4tejI4JOaUmsTDqxo2Z/4Zn4=\r
+\r
+Name: icons/dlcl16/shift_l_edit.gif\r
+SHA1-Digest: qE/5fs0zmY1QF4eIoJB4MxgDP4o=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuActi\r
+ on$3.class\r
+SHA1-Digest: S84U0RIw/SHTJROEVVYd6UfDxEc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/ICElementPropertyConstants.class\r
+SHA1-Digest: YkfdVGnBvtf9F95F5Cch6dMISqY=\r
+\r
+Name: icons/obj16/implm_co.gif\r
+SHA1-Digest: sOKzgCom3+ilNaVH7zNeEnnGHTw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/SelectionListenerWithAST\r
+ Manager.class\r
+SHA1-Digest: b5FvsLVmeaAh9/iMoYINQX6pkF0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SortLinesAction$LineInfo.clas\r
+ s\r
+SHA1-Digest: p7GdCDC7inLpL7TXm8lUES1LDuo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBViewPart$10.class\r
+SHA1-Digest: h/IOaqqz66ZAelizQAxyaHFDEUk=\r
+\r
+Name: icons/elcl16/super_co.gif\r
+SHA1-Digest: tV6Ej/bdlr4Mvydpo0tTH8d2ETI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/ProblemsLabelDecorator.c\r
+ lass\r
+SHA1-Digest: lyGUHqQVKf8QLl319SJwvUqhD+Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/ChooserC\r
+ omposite$3.class\r
+SHA1-Digest: u88LxsJZNEL96gfWoyBbhznZYXA=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/CHelpConfigurationPropertyPage$CHelpS\r
+ ettingsDisplay.class\r
+SHA1-Digest: 8ZZEjtZPQr3F29j4yypmbwt2gV8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/IndentAction$1.class\r
+SHA1-Digest: 9+A0E570FW7W0TD6HNCfQ8xvfpQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/ActivateWorkingSetsContr\r
+ ibution.class\r
+SHA1-Digest: b3+fL3AUKFp4rnMpFt+js0iqtHI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/AsyncTreeContentProvider\r
+ $1.class\r
+SHA1-Digest: JHKz+0CLa63zRR63JFmcBdRVcpA=\r
+\r
+Name: org/eclipse/cdt/ui/newui/RefsTab$2.class\r
+SHA1-Digest: TOrV2McPAMm7hUdKtsdEvj2/6lE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/BlockCommentAction$Edit.clas\r
+ s\r
+SHA1-Digest: Z4sCTTwGvQy9gqc7lqU+W9GYpac=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/CheckedListDial\r
+ ogField.class\r
+SHA1-Digest: MleTe5ZzWtdfnb7Ewc78SI0oRQ0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/CViewElementComparer.class\r
+SHA1-Digest: efmvq2Jqp0vPRMpi6sNxOYPAC3k=\r
+\r
+Name: icons/obj16/cu_change.gif\r
+SHA1-Digest: ygabeZXsRGKj2BnDvCu003CwSU8=\r
+\r
+Name: icons/dlcl16/list-edit.gif\r
+SHA1-Digest: zD8FQOeLG9MItP16EKJK279TXqY=\r
+\r
+Name: org/eclipse/cdt/ui/newui/PrefPage_Abstract.class\r
+SHA1-Digest: gJjF21Pb0U0MP+41HvMxSBsZluI=\r
+\r
+Name: icons/obj16/output_folder_obj.gif\r
+SHA1-Digest: EzkIQlIPn0dKehN1uM3J7/p1d6Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner\r
+ $StreamEntry.class\r
+SHA1-Digest: kT41HGtkSN+psOAtP+p8gb5DKjA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditorMessages.class\r
+SHA1-Digest: WRTNmTACUTg1hCg+nVJdINCdidY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messag\r
+ es.properties\r
+SHA1-Digest: aZ59/Z9nYitF9cfxjof0RfWiz84=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/TemplateMessages.prop\r
+ erties\r
+SHA1-Digest: Y5O/t6AJwmn3WVt+VwN56TIZgng=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEnt\r
+ ryPerFilePage$SelectPathInputDialog.class\r
+SHA1-Digest: zTGDAjM5CwEYi0SbqVSJ3PYxTRE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/indexview/CountNodeAction$1.class\r
+SHA1-Digest: KomJf5bzlEoO3/61JrFAiPiKNsE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/CoreUtility$1.class\r
+SHA1-Digest: +xJOUEvtV/N7A5t1UmnSKbi07iw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/navigator/CNavigatorContentProvider.\r
+ class\r
+SHA1-Digest: sCGhAGltAm+dAr6tCy8PqE7f8Hw=\r
+\r
+Name: org/eclipse/cdt/ui/CElementGrouping.class\r
+SHA1-Digest: 2kQOfT0c+l2RM/9B59nziDX6qvA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesConfigura\r
+ tionBlock$2.class\r
+SHA1-Digest: VFtkiK0C6g3g+gVqY/EsZVC+mbk=\r
+\r
+Name: org/eclipse/cdt/utils/ui/controls/RadioButtonsArea$2.class\r
+SHA1-Digest: /0LcwS76hZGHEbqgcIvneHV+T+A=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigura\r
+ tionBlock$9.class\r
+SHA1-Digest: XLVt9SzVvX1f1leX2HxZVLiKshY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CMacroCompareViewer$Rep\r
+ laceEditsHighlighter.class\r
+SHA1-Digest: q/VX0JUyCx3+61CA3XPubedbhXA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightingPresenter\r
+ $1.class\r
+SHA1-Digest: ZRzDVMuSfNZCHoQ1fhtR06av1fk=\r
+\r
+Name: icons/elcl16/newmngcc_app.gif\r
+SHA1-Digest: 9fMfZW/0oFAkEsLdLitr6hquteI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/IndexerPreferencePage.cl\r
+ ass\r
+SHA1-Digest: ab4JupqI3+MgQYNfh28KZccDcSs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.class\r
+SHA1-Digest: ccKk2FkBmWamiKNlGo42f4bLdUM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dnd/DelegatingDropAdapter$1.class\r
+SHA1-Digest: 8Tjztvn3WUdIs2fr5YfTx4o3yvE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/OptionalMessageDialog$1.clas\r
+ s\r
+SHA1-Digest: 30ZEYsLdiu4B3wrxgt0qDngkECc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBloc\r
+ k$ErrorPreferences.class\r
+SHA1-Digest: iNnaKzFzJyr6cIQR8XCImBOijuE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CStringDoubleClickSelector.clas\r
+ s\r
+SHA1-Digest: fOx9EV25rKvMoVCJ8mvji1NU6IE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/actions/FindAction.class\r
+SHA1-Digest: TZrvDVs3pwynvNFpZTQsuvS3IBA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDia\r
+ log$UpdateJobListener$1.class\r
+SHA1-Digest: Z0O/milJYwmOl29eslAt6SlfzwA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/filters/CustomFiltersDialog$4.class\r
+SHA1-Digest: p/L2dBoti9YBUH8NxeC4iTEH/ek=\r
+\r
+Name: org/eclipse/cdt/ui/newui/CLocationTab$LocDialog$3.class\r
+SHA1-Digest: ms9M0bH8aF746sqAUYr2N/OEGSU=\r
+\r
+Name: org/eclipse/cdt/ui/ICHelpProvider.class\r
+SHA1-Digest: p3C2ahZ+peN8P612akbdNBRZBu4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeMessages.pr\r
+ operties\r
+SHA1-Digest: lMey/e1RcshpHLwKR1++qB5jlUM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/BuildOutputStream.class\r
+SHA1-Digest: LKqOp45YyQvIJJ/bZDY3qlipcEA=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/ICOptionContainer.class\r
+SHA1-Digest: JvBRrRKRubBt8XMg53mr0iFlk8U=\r
+\r
+Name: icons/dlcl16/list-delete.gif\r
+SHA1-Digest: EhUkgMU4L0mKFDaeXU6pSJWjEcg=\r
+\r
+Name: icons/dlcl16/list-add.gif\r
+SHA1-Digest: no67ftwqAMaLEdNXNcwV6HjQL3Q=\r
+\r
+Name: org/eclipse/cdt/ui/newui/BuildVarListDialog.class\r
+SHA1-Digest: hv3CiiyJyeRjh4oXcFv15NqXjZA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlo\r
+ ck$TodoTaskLabelProvider.class\r
+SHA1-Digest: T4Er+dS/EAIVqMilVHWI6ITqtXI=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ExpIncludeFileTab.class\r
+SHA1-Digest: N2o/fWObK4Ca0xm3iZLl+d5arrI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerSelecti\r
+ onPage$2.class\r
+SHA1-Digest: UMLGviGpf7Qje3rWNWcW5pyr3ng=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/AsyncTreeContentProvider\r
+ .class\r
+SHA1-Digest: plJenvWZchpuENcJjZ97gKZOHPE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreat\r
+ ionWizard.class\r
+SHA1-Digest: 1zU6NOWSkcXYaSZQqBWu7WXcjmA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/doctools/DocCommentSpellDiction\r
+ ary.class\r
+SHA1-Digest: eP3bnaIp/d8i6rQwEFsXCKpMhac=\r
+\r
+Name: org/eclipse/cdt/ui/newui/EnvironmentTab$1.class\r
+SHA1-Digest: 586vckzt54P5jd35lsLH+dlJwaY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfig\r
+ urationFactory$Registry$1.class\r
+SHA1-Digest: qcFV1RQGgh2Awy/90nJfQNNis3o=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THInformationControl$1\r
+ .class\r
+SHA1-Digest: YY0UH+NPQCqGQcMDPm0C0D4qu2o=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner\r
+ .class\r
+SHA1-Digest: p5E0u447ieodqoU9rt1W+B+/i1o=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/MachOBinaryParserPage$2.class\r
+SHA1-Digest: nH4ldBAnPoHPaaFc2qrPXZpfzL8=\r
+\r
+Name: icons/obj16/toolbar_pinned_multi.gif\r
+SHA1-Digest: XCPrX+fFYYWzRpXplsTtCc2I8Z8=\r
+\r
+Name: icons/etool16/prj_obj.gif\r
+SHA1-Digest: G29KWnwtIu+V/F0RhlEGvOa5dC8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/FileLanguageMappingProperty\r
+ Page$1.class\r
+SHA1-Digest: tePrtVAuWr3bMd8HtjAVTcioB6M=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/TypeHierarchyUI$1.clas\r
+ s\r
+SHA1-Digest: HXwtuYe3sF77+VfbGDYoEuBduM4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/asm/AsmPreprocessorScanner.cl\r
+ ass\r
+SHA1-Digest: oJAfnjOPpL6n93TOi8zIu6Cnh7M=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialogTa\r
+ bPage$1.class\r
+SHA1-Digest: /ymcUH9cbq2euPQErphRJPq05mc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THNode.class\r
+SHA1-Digest: ojqohONMze4OmFyWIyRCXN4VaIc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/QuickAssistLightBulb\r
+ Updater$AssistAnnotation.class\r
+SHA1-Digest: S4tZ7AjbLW26Fo/pHkro66HDhMw=\r
+\r
+Name: icons/obj16/error_obj.gif\r
+SHA1-Digest: vhQhHrZFQ3T4igJW/aQb6NQEwmQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog$1.cla\r
+ ss\r
+SHA1-Digest: RBV1LgyXntMGPbDC6L7/wnIACpY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsListD\r
+ ialogField$1.class\r
+SHA1-Digest: 0ujf3LicA57U1Ofif/ssBmYCxmc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlo\r
+ ck$TodoTaskSorter.class\r
+SHA1-Digest: J2Mdu6ZYfN9BGw9/I7B4EWlpeOM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/utils/ASTHelper.class\r
+SHA1-Digest: KKm7DYWlO24pExJGaIyPFH6as8w=\r
+\r
+Name: org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenEditorAction\r
+ Group.class\r
+SHA1-Digest: zAXZvp5e25/MGPCC7qnYAas8AC4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/SpellingConfigurationBlo\r
+ ck$3.class\r
+SHA1-Digest: FCRU+dwsJPyiqsqpvRAYtKqFwQI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/PreprocessorRule.class\r
+SHA1-Digest: HHi4nZJxQ9LjNwo9VB1TbFh2tqM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/indexview/IndexView$2.class\r
+SHA1-Digest: EA/Nx5mVrJrRTBn6gFvZYfcHPBU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/SnippetPreview\r
+ $PreviewSnippet.class\r
+SHA1-Digest: +e0ypUGc5J0tGyc26Y0Vfk40YEs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/QuickAssistProcessor\r
+ .class\r
+SHA1-Digest: VViZWkaOeUL6QWrXeD/wHTTTvTU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/SpellingEngine.class\r
+SHA1-Digest: DV/SjrpFe7cYI+z30RShfOyXgxs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/Messages.class\r
+SHA1-Digest: GgAPm6KuGEJOa6meqUxrhEeKDMQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/SourceFolderSelectionDialog.\r
+ class\r
+SHA1-Digest: r5kua+AOoYivGeVZFilj+erfh5Q=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ExpDialog$4.class\r
+SHA1-Digest: uitGfApaYyMqV4jhzK2NnrS1dNE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/filters/ExecutableFilter.class\r
+SHA1-Digest: an+/SwcUHotWl/kyt4sJag5QEEQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/StatusUtil.class\r
+SHA1-Digest: sRUrILr8xmcneD3X3vZ54diG31Y=\r
+\r
+Name: org/eclipse/cdt/ui/IPropertyChangeParticipant.class\r
+SHA1-Digest: y4dcIfTNPJZKQ0lJnASMxJhkaiI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/AddWordProposal.class\r
+SHA1-Digest: ULPAp6rB2QW7UqhJo0WzOY/vtEw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/IndentUtil$IndentResult.class\r
+SHA1-Digest: +N0i4rqOUqYEaNqxJkW5YcYvT7E=\r
+\r
+Name: org/eclipse/cdt/internal/corext/fix/LinkedProposalPositionGroup$\r
+ Proposal.class\r
+SHA1-Digest: fgXpX+y6LvK8e8MA+r0HXcAjeV8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/PDOMSearchPage.class\r
+SHA1-Digest: o824SOSh52Oa3FFmH5fSorGlV3k=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/CRenameGlobalProc\r
+ essor.class\r
+SHA1-Digest: 6BLA9lFA4ZAE+q4f82tnWjsBoD4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/SelectionList$1.class\r
+SHA1-Digest: FjeKJyVSNpsOCZUQGIfZ2wIdkCQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/OverrideIndicatorManager$1Met\r
+ hodDefinitionFinder.class\r
+SHA1-Digest: vMDC73v5S97Fgv2hn5lCEMPykNE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/PDOMSearchViewPage.class\r
+SHA1-Digest: lVpX65mIXWhNAon4D6ZAvlfoS5I=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/ConstructorMetho\r
+ dStub.class\r
+SHA1-Digest: sIJBbxxVdQjEwqw8znJZ6i7twRs=\r
+\r
+Name: icons/elcl16/synced.gif\r
+SHA1-Digest: Ghj9SQaJ6vJj8hRCpmwiAfHF1uI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/LinkToFileGroup\r
+ $1.class\r
+SHA1-Digest: iUxQ2eJcAB7uXHUnWp5Hz5Fw3L0=\r
+\r
+Name: org/eclipse/cdt/ui/newui/BuildVarListDialog$2.class\r
+SHA1-Digest: F56NPnOgxODSb+G48TCa+7bPsX0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/CPreview$CSour\r
+ cePreviewerUpdater$3.class\r
+SHA1-Digest: Zz8bm3drv0gkTc6U/9dt+k679f4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigura\r
+ tionBlock$ColorListContentProvider.class\r
+SHA1-Digest: cqcb4HhlB2mvJtAQ9nWFPg+pXXU=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/TemplateEngineUI.class\r
+SHA1-Digest: bEZ3fiav6F3rfAXtjkY0sC9Rhkg=\r
+\r
+Name: icons/obj16/environment.gif\r
+SHA1-Digest: chz73ec4u76FqlmlNmJl9BdJau0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeDialog.clas\r
+ s\r
+SHA1-Digest: ZG3ttEWFQNztcahM+qccxOnywxc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightings$StaticM\r
+ ethodInvocationHighlighting.class\r
+SHA1-Digest: alhYg6GHeHmoEOE5IQiexOBU+wE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/IProblemChangedListener.class\r
+SHA1-Digest: iruoAFI8Jx/R0eGFMLVQFmiWNR8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/ProjectConfigsController\r
+ $DelegatingContentProvider.class\r
+SHA1-Digest: u9/JoeZzJD8DgihrnUfbB0aMk4c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementLabelProvide\r
+ r.class\r
+SHA1-Digest: 9VY0f28kVwfWI1D8ST1rj/J4cis=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CHeuristicScanner.class\r
+SHA1-Digest: qfXHav9BQeHbG0so+0pmhG3AyAM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover$ComputeSou\r
+ rceRunnable.class\r
+SHA1-Digest: +J2yoHC9oFpphk4VaDoE2sPpzgY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/CCorrectionProcessor\r
+ $SafeHasCorrections.class\r
+SHA1-Digest: t0x5x2oqW0rBnXRaCi/ekUE4+7E=\r
+\r
+Name: org/eclipse/cdt/ui/newui/IncludeDialog$2.class\r
+SHA1-Digest: WdVr8uS13aIfqXKCBrSbpNqEsYY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/WorkingSetFilterUI.class\r
+SHA1-Digest: /hKoPcO30z7YeZw9wq1t/1AuEM4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/Ext\r
+ ractLocalVariableRefactoringWizard.class\r
+SHA1-Digest: UezarrHu0yGd9eOQxBJiPN6Zlc0=\r
+\r
+Name: org/eclipse/cdt/ui/actions/ManageConfigsAction.class\r
+SHA1-Digest: hCyCHX93jya20jvBBVNx7pU46qk=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/pages/TemplateInputDialog.clas\r
+ s\r
+SHA1-Digest: BwtwZk8msF5wViKC73DRr2Orqw0=\r
+\r
+Name: org/eclipse/cdt/utils/ui/controls/ControlFactory$2.class\r
+SHA1-Digest: NxLSrnqq4KKR4/1KI0AAYhyK8xs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/RefactoringRunner2.class\r
+SHA1-Digest: 0G9gAvC4ksy+xneFvm6bSnnuKBY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/LinkedNamesFinder$BindingFind\r
+ er.class\r
+SHA1-Digest: 06EyhNqhVW/3+BdMLVK/3/S+PfE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameLinkedMode$\r
+ FocusEditingSupport.class\r
+SHA1-Digest: c7NrPtjwpQzPfcS+8IO90fiZlT8=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/DialogsMessages.properties\r
+SHA1-Digest: lp5X8a1OnbiEn7efOm/b+AIYn5Q=\r
+\r
+Name: org/eclipse/cdt/ui/newui/CLocationTab$2.class\r
+SHA1-Digest: GzJixhdjcUHgiY11pXUMLGGNFJI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SelectionHistory.class\r
+SHA1-Digest: Csn8GDPMxwj2zi9m3N2PmW4DmeA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/navigator/CNavigatorSearchActionProv\r
+ ider.class\r
+SHA1-Digest: ZB6c/ufefeFPnV1Ej0RRtAaBaLQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBloc\r
+ k$4.class\r
+SHA1-Digest: 6kq6Apfqq3g9j8dWk0kDJv1yUcI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/DeleteTaskAction.class\r
+SHA1-Digest: t5mb4wGKJLe6GcysGeyiZNqX7jo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/CommentsTabPag\r
+ e.class\r
+SHA1-Digest: PndsXEUkA7sAR5feRYVAvhG0KsI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart$5.class\r
+SHA1-Digest: 29ViQ1cmLMuKMSAtQYMg/lmFfsc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/CBuildConsole.class\r
+SHA1-Digest: lSH5Aan3HcFN2uFDf3MfNkwvRzQ=\r
+\r
+Name: dictionaries/en_US.dictionary\r
+SHA1-Digest: DHZeEIaxm+epAEKLTIz/JF5ooFI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager$2.clas\r
+ s\r
+SHA1-Digest: 6FYOFe36IVTspVV+SvK8AW/M+gg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/filters/CustomFiltersDialog.class\r
+SHA1-Digest: exOS/u+K2v4aQZuB5BohIz9uQFg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/OverlayPreferenceStore$T\r
+ ypeDescriptor.class\r
+SHA1-Digest: okBA0oycrrZSYy4d2V5OilCPU6E=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/AbstractOpenWizardAction.cla\r
+ ss\r
+SHA1-Digest: 3dPvG+1OTS5Vc2HNlEBWscVJU3g=\r
+\r
+Name: org/eclipse/cdt/ui/actions/FormatAllAction$1.class\r
+SHA1-Digest: /vSxp9asYJ15f4UZsoa4LZ7iUBM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionControl.\r
+ class\r
+SHA1-Digest: dejzQOmNVbGMkl15WtcfTcb0nqY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesConfigura\r
+ tionBlock.class\r
+SHA1-Digest: 72chdPWd0QtmQuVeKQo/PnaPBiE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/template/TemplateVariableProces\r
+ sor$1.class\r
+SHA1-Digest: CfN0M04cXT8oXf6dvzycnY9coBo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.class\r
+SHA1-Digest: N9aFwMa+V57Gcdbin16irrhc1/s=\r
+\r
+Name: icons/obj16/h_file_obj.gif\r
+SHA1-Digest: 5uorTPM3yjxrRe97ZyoIACFwGG4=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/WizardNode$1.class\r
+SHA1-Digest: b+8A41rKalAD6QHWOI3J7Tw19Pk=\r
+\r
+Name: icons/dtool16/config-preprocessor.gif\r
+SHA1-Digest: sp94adK6g5eKgNT8EoEpcLS0MI4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/ExcludeFromBuildHandler$2.cl\r
+ ass\r
+SHA1-Digest: O83aNgh45ar/23rOzFevpYF/jac=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigura\r
+ tionBlock$2.class\r
+SHA1-Digest: HDzSKSYFXckw6x0MiqmxLpa6uhQ=\r
+\r
+Name: icons/ovr16/indexedFile.gif\r
+SHA1-Digest: pKcWE4Ge5GKvBJVR7NEFt6v39W0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/CPreview$CSour\r
+ cePreviewerUpdater.class\r
+SHA1-Digest: Zb7U6mTpJUhnKHtrjizmqRsGHWg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfiguration$\r
+ Snapshot.class\r
+SHA1-Digest: 5O5+eVEl8M8QvrNpg9nNa+tN8Dg=\r
+\r
+Name: org/eclipse/cdt/ui/newui/RefsTab.class\r
+SHA1-Digest: X5ljuw2vIR3JgemIzWUcBdMvEhU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBloc\r
+ k$AssocContentProvider.class\r
+SHA1-Digest: NGD5UPaW6S9l2nPVNcZde/Q87ps=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CSourcePreviewerUpdater$\r
+ 1.class\r
+SHA1-Digest: YROQLS9AQyVAm2toxANrw9HNKBc=\r
+\r
+Name: icons/obj16/sroot_obj.gif\r
+SHA1-Digest: EeFgNixEJi/bCc+z09WrtNt60e0=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/conversion/ConvertProjectWizardPage$1\r
+ .class\r
+SHA1-Digest: gCXmfZqiXMS2f0wbz/3kfaroQ+c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CCodeScanner.class\r
+SHA1-Digest: 0EqFtOlSWgkxyiusGW62qq8aYJs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSetti\r
+ ngsWizardPage$3.class\r
+SHA1-Digest: yGCPSRrNWdh8gIYTJSsSYb3/Oh0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/Messages.properties\r
+SHA1-Digest: v4CbgdBly5jTygCvGOKxbzSJLNc=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ErrorParsTab.class\r
+SHA1-Digest: B/YIDqzVxtxQvuI7fQpJkvRuONE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHReferenceInfo.class\r
+SHA1-Digest: ktnCYTAEnh0fTr9JzmyoFNZePGA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage$Tog\r
+ gleLinkingAction.class\r
+SHA1-Digest: ygPTdBtqsd8g3Im/UEP8HLyu+rI=\r
+\r
+Name: icons/elcl16/newmngc_app.gif\r
+SHA1-Digest: ZSD+UgNPsIZsh86caD2ZLOxwA+U=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CContentOutlinerProvider$Prop\r
+ ertyListener.class\r
+SHA1-Digest: b5WMaQFGWYAJwf42k+FQmeFraWo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CBreakIterator$Whitespace.class\r
+SHA1-Digest: YJDAmWiXD+k8x5FGikieKa1i+Hc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/CSpellingProblem.class\r
+SHA1-Digest: OHU3ibhQMOPNWZIhVH4gwGnI/Zw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/IMethodStub.clas\r
+ s\r
+SHA1-Digest: +pF1c+xJOBB/L17fwO+Jf+Whq4M=\r
+\r
+Name: icons/obj16/label_obj.gif\r
+SHA1-Digest: AYgHfG+qaIgfCPmNnxscdlNQ8gg=\r
+\r
+Name: org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenHelper.class\r
+SHA1-Digest: fV9nbQV+/uI6o3FYOOtXxxQbudc=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ErrorParsTab$4.class\r
+SHA1-Digest: wBgJucaTFVehTE7NWMC3Gcdfw7o=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/implementmethod/Paramete\r
+ rNamesInputPage$1.class\r
+SHA1-Digest: m/KWuSsI+PCsYewkzTeOz3anzHQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/actions/DeclarationsSearchGro\r
+ up.class\r
+SHA1-Digest: knDkopEZG/KfmCsdIH8sVdRsvYg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/SourceFileSelect\r
+ ionDialog$1.class\r
+SHA1-Digest: +HaebNqpWD4y5/Rl7ZG73LpN24A=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor.class\r
+SHA1-Digest: JG9u7P2p+6j8pGmOgfir+QTvkAE=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ManageConfigDialog$5.class\r
+SHA1-Digest: e/oE8FitiDvi5XnMaFBCq2+NC+s=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$3.class\r
+SHA1-Digest: 6Rslub4oGS9HLWNCk8fzjeBzGEw=\r
+\r
+Name: icons/dlcl16/lock_co.gif\r
+SHA1-Digest: O4momrUoy8YDmmKMWZk7i6sItgQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFil\r
+ eCreator$1.class\r
+SHA1-Digest: hZlH8B0d6GSR6ZDOLWvaspKbsUw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dnd/DelegatingDropAdapter.class\r
+SHA1-Digest: R74YgSwp3sGW1IqPI/qscMLvOFU=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage$13.class\r
+SHA1-Digest: z6L7UEoAfUYhAimE66iQoKUa+us=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/Messages.class\r
+SHA1-Digest: E0GgtF3p9ZeHvew2imDw67B2Rm4=\r
+\r
+Name: org/eclipse/cdt/ui/actions/ExcludeFromBuildAction.class\r
+SHA1-Digest: 3F9H2M84hfY6bVX+zCV5czz8HNQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/ASTProvider$ActivationListene\r
+ r.class\r
+SHA1-Digest: msakAff9//QWbsIUyOnFJawBlYQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/QuickAssistLightBulb\r
+ Updater$1.class\r
+SHA1-Digest: 2lEuQ48gdFJbUtHFSgDmS8f2R0M=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/ProblemMarkerManager.class\r
+SHA1-Digest: l6gDSeW38Jk9gqN869iOxaZ9TEw=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage$NamespaceF\r
+ ieldAdapter.class\r
+SHA1-Digest: Byau49jKJMzKtgp648+aXjIAz3I=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/MainActionGroup.class\r
+SHA1-Digest: BsHwSwb37q0IeL6EuHXizeTyTu8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/PathEntryVariablesGroup$\r
+ 3.class\r
+SHA1-Digest: btxqoBDPDNdS9o09kLL6PsbgG7g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/IndexUI$1.class\r
+SHA1-Digest: iLB7mwBQvOhGjRJTu9+JWi1dNBE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/EditorUtility$1.class\r
+SHA1-Digest: A0REKyN93iWYRcmz7CRd2H/0ISg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfig\r
+ urationFactory.class\r
+SHA1-Digest: 4UpNpf58bIqRecH0wyvYhCvZohc=\r
+\r
+Name: icons/dtool16/action-newconfig.gif\r
+SHA1-Digest: vGcKQdxTQIOPZA5tA0a3sKvQ4IE=\r
+\r
+Name: org/eclipse/cdt/ui/newui/EnvDialog$1.class\r
+SHA1-Digest: Gu1Ig1Yd3AZdHxP/mI2G9Lup+0s=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfig\r
+ urationBlock.class\r
+SHA1-Digest: JJr98p9+iaua7HaLbStyXkDuHmY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/LineWrappingTa\r
+ bPage.class\r
+SHA1-Digest: AQr8CUxffRM02vC8tFjvQItWSMM=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage$3.class\r
+SHA1-Digest: NsERWOL+vTTM/4vIexN2xvTo/OQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CDocumentProvider.class\r
+SHA1-Digest: /OkJbBDbOphIBDe97k4fZd9Q+0I=\r
+\r
+Name: icons/etool16/newmngc_app.gif\r
+SHA1-Digest: ZSD+UgNPsIZsh86caD2ZLOxwA+U=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/AbstractPreferencePage$5\r
+ .class\r
+SHA1-Digest: 7kdcEUnBwPV0ebrjQL7OMPy1edM=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/NewSourceFileCreationWizard.class\r
+SHA1-Digest: 62e7siBs8nzjL47spkNaVLN+/xE=\r
+\r
+Name: icons/etool16/newsrcfldr_wiz.gif\r
+SHA1-Digest: /+TmdeB74M4LcnLDBIibGf8jjFo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingPrope\r
+ rtyPage$1$1.class\r
+SHA1-Digest: 5RDlyySPX+tCCh2MRkkT1Hy7NH4=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/Template.class\r
+SHA1-Digest: mhZNTGqNCdkVHQTRpXjnmU72ewA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/utils/FileContentHelper.\r
+ class\r
+SHA1-Digest: rxHeyry5i0VgGCLyX6quyOdU4v0=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/TranslationUnitContex\r
+ tType$Todo.class\r
+SHA1-Digest: xScPEtF+nlVvJPIUJd8PiwsivYk=\r
+\r
+Name: icons/elcl16/public_co.gif\r
+SHA1-Digest: 0UjXk/7AurK0Ox+m9qfjDQMhs4Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingPreferen\r
+ ceBlock.class\r
+SHA1-Digest: FnEimX3tds7588evZzw85pOcv6U=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/CWizardRegistry.class\r
+SHA1-Digest: AW1sZcDMwcuZW85kcEdAhYl+nF0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CodeTemplateBlock$CodeTe\r
+ mplateLabelProvider.class\r
+SHA1-Digest: eZ3lgt/KE++Byf3jIbC5hxbnWL0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDia\r
+ log$1.class\r
+SHA1-Digest: mrVkYBG5lyY8ojYF/XaMVNTG/ac=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBloc\r
+ k$3.class\r
+SHA1-Digest: NGOsF4IAjYJlQCE0ppcJib1mNUc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditorErrorTickUpdater$CEdit\r
+ orImageProvider.class\r
+SHA1-Digest: 9d+Y+tJLKcJL/0Vn/xGH9qsxcX8=\r
+\r
+Name: icons/obj16/debugts_obj_g.gif\r
+SHA1-Digest: Amf3WS6LGDdRb6glgcJN/R74EK8=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/CodeTemplateContext.c\r
+ lass\r
+SHA1-Digest: cyNxcD3fmlvpft8tfYUEa9SQzlA=\r
+\r
+Name: META-INF/eclipse.inf\r
+SHA1-Digest: 09gN05tobgS/MdtqyTNQhOhB73M=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetUpdate\r
+ r$WorkingSetDelta.class\r
+SHA1-Digest: LcxO7To8QlGxow4YAHKW3bfBqJ4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/DialogField.cla\r
+ ss\r
+SHA1-Digest: kPz4mSYqrJXp3n2LXSY2XqNLpzc=\r
+\r
+Name: icons/elcl16/list-add.gif\r
+SHA1-Digest: cKaoAEv6e3IakGpoK7nxzj0ZPRI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THHistoryDropDownActio\r
+ n$ClearHistoryAction.class\r
+SHA1-Digest: nhcKDR4qot+R6uuot3lFRcUmX+U=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetPage$2\r
+ .class\r
+SHA1-Digest: HRnW0MgoWEzfxZAZfbKOzAckFys=\r
+\r
+Name: icons/dtool16/next_error_nav.gif\r
+SHA1-Digest: U6f9xBZGfY//ATfZRabVuS1k0i8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/ExclusionPatternDialo\r
+ g$ExclusionPatternLabelProvider.class\r
+SHA1-Digest: XdLkrKytBXh/QIXxv9nyNve5txo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField\r
+ $1.class\r
+SHA1-Digest: 98iDgW2rS6yMIcE1nxBH98mEYW0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart$10.class\r
+SHA1-Digest: P+7mD8pQvWoDnSSsN35Esb+FfmA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/FreshenIndexAction.class\r
+SHA1-Digest: klibfAwWMmYu6M4vkLQ9+wpgZlE=\r
+\r
+Name: org/eclipse/cdt/ui/text/ICColorConstants.class\r
+SHA1-Digest: crRkrO7xlQ6gTgEC6xmV9/0fiqY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/TypeInfoSearchElement.class\r
+SHA1-Digest: fkRZUekED0ep0176URubUtTFyFQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfig\r
+ uration.class\r
+SHA1-Digest: ATy7DvlUJd/qpz/LRfuhlIsBgZI=\r
+\r
+Name: icons/etool16/config-category.gif\r
+SHA1-Digest: t7MYFpRyTBFra/clT8mA6qUq+bA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/CDTQuickMenuCreator$1.class\r
+SHA1-Digest: 59MEiCcUU+BLieK+IbbmmYNKrmc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerDescrip\r
+ tor$PathEntryContainerPageAdapter.class\r
+SHA1-Digest: 5XXnXdtBrb2xkeAkArncsHc9fCw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CHelpProviderDescriptor.class\r
+SHA1-Digest: PBiGL/huN1+UjI9wFv/YWgfjq3Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/ImageDescriptorRegistry$1.class\r
+SHA1-Digest: yy2QWebkgdY7Ou1sRFZlw7PsFF8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreat\r
+ ionWizardPage$SourceFolderFieldAdapter.class\r
+SHA1-Digest: s0Pde4wE6Nde5dcuF9aQoS7cTr0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CEditorTextHoverProxy.c\r
+ lass\r
+SHA1-Digest: X5Xx1ErzDw+Lbm1SjRO9sIzpRtM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkspaceSnapshot$Projec\r
+ tState.class\r
+SHA1-Digest: 9vSMA6LVqvNnamMpuUFJsOGSG7U=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistPro\r
+ cessor$CCompletionProposalWrapper.class\r
+SHA1-Digest: VfyBmM1QbdS8ki53DJQFGa8ivCE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingPrope\r
+ rtyPage$1.class\r
+SHA1-Digest: G0UomEnOnNzu0HBoGn2tPVsNmUI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/LineWrappingTa\r
+ bPage$4.class\r
+SHA1-Digest: jk9xRmuRPyWnUTDusJiUg55QOiA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlo\r
+ ckPreferencePage.class\r
+SHA1-Digest: aZrqnLyJLlravoTlXkcxjzaz2Oo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingWid\r
+ get$3.class\r
+SHA1-Digest: w1mTNr10ElvFHqLy4G2Mv+b8YFY=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/TemplateMessages.clas\r
+ s\r
+SHA1-Digest: MT5WmT0j97WAz+VH36Z0zMnBz30=\r
+\r
+Name: icons/obj16/unknown_type_obj.gif\r
+SHA1-Digest: rPmovBGARoDY4DIO6eJwtboVz8Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/FoldingPreferencePage.cl\r
+ ass\r
+SHA1-Digest: VU8SypRBFTNVYnMQJRUzjA83ETk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.class\r
+SHA1-Digest: dNMJL91LHIQVn2Uqd4e1PG6Oe0Q=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetUpdate\r
+ r$SingletonRule.class\r
+SHA1-Digest: JsXpmb9ncxlw188C/L7GHR4DAAU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider$1.cl\r
+ ass\r
+SHA1-Digest: NFBVxScdMSuuxav/hVJu0Ujaj/4=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/NewCProjectWizard$1$1.class\r
+SHA1-Digest: mxJLXKCly1XDgU0KTH6zeklTMks=\r
+\r
+Name: org/eclipse/cdt/ui/text/doctools/IDocCommentOwnershipListener.cl\r
+ ass\r
+SHA1-Digest: wn9Bu5Fje5MogD6NQewZIINyVzc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/InactiveCodeHighlighting$High\r
+ lightPosition.class\r
+SHA1-Digest: 7Dhqg1Lcchn2h0HzSjERm3iDJ1o=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractLangsListTab$3.class\r
+SHA1-Digest: tCyTqPTYBobGWJ1Nmp/UqGmuWKA=\r
+\r
+Name: icons/ovr16/setting_nav.gif\r
+SHA1-Digest: Al/LxrksMFY1R2fj1ukK0/DitJM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner\r
+ $2.class\r
+SHA1-Digest: hw6/j2zsmXKOjwQwAJ4MmLcHHpw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$24.class\r
+SHA1-Digest: LCclictxMCEA4ykUDQaSyhn0rG4=\r
+\r
+Name: icons/dlcl16/th_automatic.gif\r
+SHA1-Digest: bVxNcrH7WNUBCruGNH9uQ8onUcg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/DeleteResConfigsHandler$2.cl\r
+ ass\r
+SHA1-Digest: JNG/zwPgCsG+SFWYt2kka4cNebE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/SmartTypingConfiguration\r
+ Block$1.class\r
+SHA1-Digest: 5TYMAheU/C20eQp0OEKokm1dTFA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlo\r
+ ck$1.class\r
+SHA1-Digest: wgJOGGwbxMzglxMoHmFFeiE7z7Y=\r
+\r
+Name: icons/dlcl16/build_exec.png\r
+SHA1-Digest: VmZGzV3ST+ESl4alT+thL/XFD10=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfig\r
+ uration$ISnapshot.class\r
+SHA1-Digest: ikFUejihbsVud2i8GCrKbyOWo70=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ProfileConfigu\r
+ rationBlock$StoreUpdater.class\r
+SHA1-Digest: waqNeVQml0VcxJcRrRXyE0iPg9M=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/FoldingActionGroup$2.class\r
+SHA1-Digest: YhouIpJgEGcSIBbHbXJyblz5MkA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/AbstractAnnotationHover\r
+ $AnnotationInformationControl.class\r
+SHA1-Digest: BdG4iOXkC50/g4SC+8T8Fd7+qR8=\r
+\r
+Name: icons/dlcl16/alphab_sort_co.gif\r
+SHA1-Digest: 0s8394QVKoPvyWAYcmVLU8X/Jp4=\r
+\r
+Name: icons/obj16/bin_obj.gif\r
+SHA1-Digest: ib6Gm3+lrR9rm+kQUt0fCgYTU6I=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfig\r
+ urationFactory$Registry$Default.class\r
+SHA1-Digest: 96UOVl9cDWiVQEuPR1RlTYKU7TY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformation\r
+ Popup.class\r
+SHA1-Digest: aQ8du2paUgTW9tdy3dFqKPzMGGg=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/CygwinPEBinaryParserPage$7.class\r
+SHA1-Digest: JH8de8FujyUpN/qdbgIIBMhYKcI=\r
+\r
+Name: org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog$1.class\r
+SHA1-Digest: kYbbjW88uW4BUW+R9kjNZvCK/vo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$18.class\r
+SHA1-Digest: uTpUB8UGbT34WQYLbJn1vz23lyI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/TypedElementSelectionValidat\r
+ or.class\r
+SHA1-Digest: WLtkqiJsNhM4zXK4JqIMoGwt3G4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/PDOMSearchElementQuery.class\r
+SHA1-Digest: S/o9tS37akXXcZcAkZEFn6S8URg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/CCorrectionProcessor\r
+ $SafeCorrectionCollector.class\r
+SHA1-Digest: NfGF22zEFnbOkLaMTP3ByNU5cf0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationM\r
+ anager$1.class\r
+SHA1-Digest: d1gFf4OQzcdSwmVS6oWgl7JRbGo=\r
+\r
+Name: icons/dtool16/exportzip_wiz.gif\r
+SHA1-Digest: fa3gNIDCgl16hoKtMVj+HZID+fM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/QuickAssistProcessor\r
+ $1.class\r
+SHA1-Digest: oXX01z6IIS7u4XhPLVRcCxa3gxk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/implementmethod/Implemen\r
+ tMethodInputPage$1.class\r
+SHA1-Digest: T3KmbBhf7Vuou2FjAKghBrw/4pc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/compare/AsmContentViewerCreator.clas\r
+ s\r
+SHA1-Digest: G5YeVTlyigd8SWRDasVfzGGAYaw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFro\r
+ mInHeaderToImplementationStrategy$2.class\r
+SHA1-Digest: K2Pta/x8b3o4tk41v6IRhCkzT4U=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationB\r
+ lock$2.class\r
+SHA1-Digest: nE96KarAmukbUnkMJp2zmthdUuk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/newui/Messages.class\r
+SHA1-Digest: uJLV7Bj3p22K7Sq9WVERUOmRJAU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/Messages.class\r
+SHA1-Digest: cHPsoGcKm5TPQRdGZ2dvyp9xioU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/SingleCharRule.class\r
+SHA1-Digest: Q5DkoBeKnrVuNqDBcMvtEgtf8Ls=\r
+\r
+Name: icons/dlcl16/synced.gif\r
+SHA1-Digest: Ghj9SQaJ6vJj8hRCpmwiAfHF1uI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/PathEntryVariableDialog$\r
+ 1.class\r
+SHA1-Digest: mHUxsqMpnB22ylZmhpEFEMoZv4I=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkingSetProxy$Snapshot\r
+ .class\r
+SHA1-Digest: J6k/UpSpWaCVc+USlae2HmzCHeE=\r
+\r
+Name: icons/etool16/newcc_lib.gif\r
+SHA1-Digest: qAA76UsQe70wiHx9D1p4pWH9LO4=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/PreferenceScopeBlock$1.class\r
+SHA1-Digest: o4+ksqJhg4X6BM5y5OcyrHrm3oo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover$1.class\r
+SHA1-Digest: 8Ssi2VWF27jS7LoSyZxMatmoypg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSetti\r
+ ngsImportStrategy$ImporterSectionPair.class\r
+SHA1-Digest: GlM/CdAM6NcZ46wMlLf4cD0pG/g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/CElementLabelComposer$Fl\r
+ exibleStyledString.class\r
+SHA1-Digest: Y1q9/qMXQbhGrOdieuyOGkfXUl8=\r
+\r
+Name: org/eclipse/cdt/ui/IBuildConsoleListener.class\r
+SHA1-Digest: Rp2W738hDgZB9UoH7xHwf8ZnqHE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformation\r
+ Popup$7.class\r
+SHA1-Digest: qYxT8z58Q7EZaOcTQoAb+9M6y50=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/RefactoringExecutionHelp\r
+ er$Operation$1.class\r
+SHA1-Digest: 8O9EeZZm47PSgmoVExUmrkfpb1Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSetti\r
+ ngsWizard.class\r
+SHA1-Digest: O+VP/Fw7GKHIc0Ty8cptkLjyZLw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/ResourceAdapterFactory.class\r
+SHA1-Digest: SpZ3LKRoJ6gbILz/wd2nfrcwmGE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractF\r
+ unctionRefactoring.class\r
+SHA1-Digest: N1f5Ppds/Gnb0hbkToY+biFHC50=\r
+\r
+Name: org/eclipse/cdt/ui/IEditorInputDelegate.class\r
+SHA1-Digest: G7zyPuPBYMjnyuiyCOvFLvbS52I=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractPage$3.class\r
+SHA1-Digest: SAaFH0ocric33fesFxjxsTd5kVU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CWordFinder.class\r
+SHA1-Digest: YorAFQf0342E25BlrDs3lwWFtW0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/NewIncludesSymbolsTab\r
+ Block.class\r
+SHA1-Digest: wZj6flnvGyWs2N1TbOP20LMhf58=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/template/TemplateMessages.class\r
+SHA1-Digest: 0o+2haWsFuZX2NkfpbZoh69SRxQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CWhitespaceRule.class\r
+SHA1-Digest: jL84r74r9at93xdlPlsOrKZKlrs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CombinedWordRule.class\r
+SHA1-Digest: fZuZ84ZZH8DfXbpQmt84d8Nxllc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/DisableSpellCheckingPr\r
+ oposal.class\r
+SHA1-Digest: GilrXHm2Matbml5/8X1CdIwceQI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/indexview/CountNodeAction.class\r
+SHA1-Digest: SgHb0G7iF+4r8DSz9pTYmncVVXw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSetti\r
+ ngsImportStrategy$1.class\r
+SHA1-Digest: +QyE/7qJy00s6epQsgGnnlRRpks=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/Extracte\r
+ dFunctionConstructionHelper.class\r
+SHA1-Digest: 4+nsRg45iPIyM+90CAuAlszP3Gc=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/DocCommentOwnerBlock$1.class\r
+SHA1-Digest: lyjSw+havve0r3p0kgNG1+0NTbY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/SnippetPreview\r
+ .class\r
+SHA1-Digest: Bqg6Fe7w/s7V0eKawHZky17AH2Q=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/doctools/EditorReopener$1.class\r
+SHA1-Digest: D1CSGFwGJMr2NufGJjAUmc8cV2Q=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/CorrectionMessages.p\r
+ roperties\r
+SHA1-Digest: Rjc6st11GaIZddPjDqfaTG3Xlnw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ProfileStore.c\r
+ lass\r
+SHA1-Digest: K9stlNmeSgDxlbDS2fhEED9YZRg=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/BinaryParserBlock$4.class\r
+SHA1-Digest: zmUYisd7svQ/GroURNMProG075M=\r
+\r
+Name: org/eclipse/cdt/ui/CUIPlugin$3.class\r
+SHA1-Digest: dU8QnS2OPfKB+uW0Oi9J83yZ+PY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/CUIException.class\r
+SHA1-Digest: 44aBuHVkxZLQVxkAIqjwhTpNdJg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigura\r
+ tionBlock$ColorListLabelProvider.class\r
+SHA1-Digest: MV1nldDLtB+ykrSxoZeKjGfwsi4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/CopyTreeAction.class\r
+SHA1-Digest: CChhoCkseMA6ACbcjVsQ21lUcIE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/CElementLabels.class\r
+SHA1-Digest: yc6vHf5kBcDFrXVSfckfW8uRkpg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/togglefunction/Refactori\r
+ ngJob.class\r
+SHA1-Digest: HHpJZWpX4mUZwzGIfdFISaw2Nik=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/utils/IdentifierHelper.c\r
+ lass\r
+SHA1-Digest: +xjh5Fq1kJiHtN4alKaK0E3ieqQ=\r
+\r
+Name: icons/obj16/flask.png\r
+SHA1-Digest: FuPMADNDzchuZpVIw2/lz9Q+T7k=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/CSearchUtil.class\r
+SHA1-Digest: 0kd8W/qUHrtIOnWDfAUC+U57h+4=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/event/PatternEvent.class\r
+SHA1-Digest: a0djndcRqT4VG9oi281oa0vBUvQ=\r
+\r
+Name: org/eclipse/cdt/utils/ui/controls/FileListControl$3.class\r
+SHA1-Digest: LhcnXDupNuzK8mDCq0C80Fxq27A=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformation\r
+ Popup$PopupVisibilityManager.class\r
+SHA1-Digest: C8GlOP7CMNH9QqE+84qUy6QLzf8=\r
+\r
+Name: org/eclipse/cdt/ui/newui/CDTStatusInfo.class\r
+SHA1-Digest: ztOMxYEyF7gdG1fBTlfjUlpi4Dc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THGraphNode.class\r
+SHA1-Digest: 5UEo7b1iSUmbwgJSXH4IYdcT8wc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBLabelProvider.class\r
+SHA1-Digest: w7xEL6+zGWX9NoH8S/2ks2c0aNc=\r
+\r
+Name: org/eclipse/cdt/ui/actions/CustomFiltersActionGroup$FilterAction\r
+ MenuContributionItem.class\r
+SHA1-Digest: SArunEO8ffJryrvogWngfJgQRRA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/CView$3.class\r
+SHA1-Digest: MK+sl3KifYnk7Bcj/dB3PkmW4uo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformation\r
+ Popup$PopupVisibilityManager$1.class\r
+SHA1-Digest: wADCFn7+D/32hdrivbm8iaaj4RA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/TypeHierarchyUI$1$1.cl\r
+ ass\r
+SHA1-Digest: 4g1/zRpoC9ORNh+Z92iqPaiDSZo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CIndenter$CorePrefs.class\r
+SHA1-Digest: jq1c+FQSDt68d4UPnuVo6SO+lt8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBViewPart$16.class\r
+SHA1-Digest: 7/URMpGCiVPrLNuckjFzcs+HMoQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/engine/PersistentSpell\r
+ Dictionary.class\r
+SHA1-Digest: j/uTE+MUW57EJsKozYmPapApOxE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/NewElementWizard.class\r
+SHA1-Digest: 45rLkQ9cXEusgxOQAUx0nKbMcdA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/filewizard/WizardNewFileFrom\r
+ TemplateCreationPage$1.class\r
+SHA1-Digest: YRagdy6YsjkD9nQ/GNvRfIsEdM8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/PDOMSearchPage$4.class\r
+SHA1-Digest: c/+LX+ofrxiAuKZFsQLZftn/Rzw=\r
+\r
+Name: icons/dlcl16/config-tool.gif\r
+SHA1-Digest: NGq558VCMOLL7EercFXmtJmz49Q=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBFile.class\r
+SHA1-Digest: 98v0sL1ORXXMa7pnKNBXQMZQ7jc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/AbstractInformationControl$6.cl\r
+ ass\r
+SHA1-Digest: pRBypvFvjrPkv6SeK/zSycEg1MY=\r
+\r
+Name: icons/wizban/newfolder_wiz.gif\r
+SHA1-Digest: BLPDoUtRiN4o9GAvj/0zjmpRQkU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/togglefunction/Insertion\r
+ PointFinder$2.class\r
+SHA1-Digest: T9hguB8fVSr/UhLVxsgOucpkw0U=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CDocumentProvider$1.class\r
+SHA1-Digest: Kttimh7uS2/DuM9Vs4Cj7BGVNDU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSetti\r
+ ngsWizardPage$10.class\r
+SHA1-Digest: R93ikHW2wYZ64MJGai6svb0js1w=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistMess\r
+ ages.class\r
+SHA1-Digest: mpWoYl7IjiD8n9C4B4Nd0w/4fsA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/doctools/AbstractDocCommentProp\r
+ osalComputer.class\r
+SHA1-Digest: +dBJopQhpqbdDNZ1FMwDjqnd9xw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractE\r
+ xpression.class\r
+SHA1-Digest: lAWFjVlpmElOHhyB4bch5MkkqwA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SelectionHistory$1.class\r
+SHA1-Digest: 9vHfO8NTepcK+Irj7NGCPLR8z7o=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfig\r
+ urationBlock$SeparateTableLabelProvider.class\r
+SHA1-Digest: p8MntvFql/lzwhItp6bZncy5rxg=\r
+\r
+Name: icons/dlcl16/search_sortmatch.gif\r
+SHA1-Digest: FlilAoSuraEP/kEltOv8CRoRnLQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/SingleTokenCScanner.class\r
+SHA1-Digest: pGOFzo04ofKuuqPbg6F/NNW/1vc=\r
+\r
+Name: org/eclipse/cdt/ui/newui/NewConfigurationDialog.class\r
+SHA1-Digest: SbtYKAV/9quAD6wLD42bOFPxLzo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Genera\r
+ teGettersAndSettersInputPage$2.class\r
+SHA1-Digest: rhiwEWK/Wulp9/58QXcDCI7K+OE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/CreateProfileD\r
+ ialog$1.class\r
+SHA1-Digest: pUyF5TgW3dXvAlHA2KLdx8dHN44=\r
+\r
+Name: org/eclipse/cdt/ui/text/IQuickAssistProcessor.class\r
+SHA1-Digest: fp+7gA2nKjLszbM85FQcaopmQNI=\r
+\r
+Name: icons/dlcl16/group_include.gif\r
+SHA1-Digest: fzP1836Z0sa/slwGPCRZtfLCIy4=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UIStringListW\r
+ idget.class\r
+SHA1-Digest: 9V25bmwG4hpB2ENgQqvipaDDphk=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ConfigMultiSelectionDialog$2.class\r
+SHA1-Digest: NVz2HUx9AiDh02kuQN2kFgTpU/o=\r
+\r
+Name: org/eclipse/cdt/ui/text/SharedASTJob.class\r
+SHA1-Digest: wnfiJCSudcabEPobtppzosP/WLw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/Util.class\r
+SHA1-Digest: R0kp+W/Gj1rZJS1j/RNHMkRyImg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/ExternalSearchAnnotationModel\r
+ .class\r
+SHA1-Digest: tDjA3vAQRBw/ms7Put0OI0aH4rU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMacroProce\r
+ ssor.class\r
+SHA1-Digest: QDKH8sW2RhMVy7iKe8g3ccRo/lc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingPrope\r
+ rtyPage.class\r
+SHA1-Digest: rY1U7Uhvv4geOzDtoncIIBsPH4w=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/dialogs/Messages.propert\r
+ ies\r
+SHA1-Digest: FadVIsywz3mBQlxyM7Mh0NDy/wc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/SelectionTransferDragAdapter.c\r
+ lass\r
+SHA1-Digest: 8u6yOxyeCCN0Fos5Vefc6+Pc468=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/XMLUtils.cla\r
+ ss\r
+SHA1-Digest: c832tLHIBk15JzzfpVNN43WIOgw=\r
+\r
+Name: org/eclipse/cdt/ui/actions/ChangeConfigAction.class\r
+SHA1-Digest: BgvHTC2sgPOmMW6WtkYV2oCOXGc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/SourceViewerInformation\r
+ Control.class\r
+SHA1-Digest: Pm7M4q5J0ScYz1jeO9O8u2clrkA=\r
+\r
+Name: org/eclipse/cdt/ui/browser/typeinfo/TypeInfoLabelProvider.class\r
+SHA1-Digest: GHheppiN8k2IMPnFuAVYbgTv2p0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructur\r
+ eProvider$ProjectionListener.class\r
+SHA1-Digest: et2jARhkZp6CWG427Y/QJKk+k98=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/ASTNameVisitor.cl\r
+ ass\r
+SHA1-Digest: PG2XqUxcGaU5K2ggZnl0rKI6C9c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectInde\r
+ xExportWizardPage$1.class\r
+SHA1-Digest: Y10fSYIo9F4QIbcRNOiEQ7G0zZo=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/BinaryParserBlock$BinaryParserConfigu\r
+ ration.class\r
+SHA1-Digest: CZyKwJ/5jA0R6PcpT/OjmRI8Bao=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionExplorat\r
+ ionControl$5.class\r
+SHA1-Digest: epu8SUgh/BWX6HiPvDctUfjqkdE=\r
+\r
+Name: icons/wizban/fieldrefact_wiz.gif\r
+SHA1-Digest: SuLUhIeqKr8fwti3WNh7rl2FhEs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/WordCompletionProposal\r
+ Computer.class\r
+SHA1-Digest: 2tcwL9jTaiXdA4Z4ZQ3pIU10lXA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerEntryPa\r
+ ge.class\r
+SHA1-Digest: uSA2d3IDBvH3JhoBxXb6I51MLiM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CContentOutlinerProvider.clas\r
+ s\r
+SHA1-Digest: E8REXlGWkVAwQ33y+KBxxPdK1xU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/compare/CNode.class\r
+SHA1-Digest: MW4BBE2OAJeibhf5W5RLJFWdX7k=\r
+\r
+Name: icons/elcl16/lock_co.gif\r
+SHA1-Digest: +/bEu81XF635b9u2CD63ALJEtK0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/SelectionStatusDialog.class\r
+SHA1-Digest: Mn0Rpo5zuIMApGxFrcgjThlyc84=\r
+\r
+Name: org/eclipse/cdt/ui/text/doctools/generic/GenericDocTag.class\r
+SHA1-Digest: EUs5JCzEw7YE3aNG5JuqvTGV+C4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFro\r
+ mInHeaderToImplementationStrategy.class\r
+SHA1-Digest: kJKAh1VzdvABaa12sr9EM06Ch9o=\r
+\r
+Name: META-INF/maven/org.eclipse.cdt/org.eclipse.cdt.ui/pom.properties\r
+SHA1-Digest: RMNknza+A3xtxwOyALiUt7lWYIo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/OpenCallHierarchyActio\r
+ n.class\r
+SHA1-Digest: j0B7gyacT+oY5ZKiopzbGAeA3E8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/CSpellingEngine.class\r
+SHA1-Digest: a1XOrrqP0etLmR7apM9YHBLTscA=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/GNUXCoffBinaryParserPage.class\r
+SHA1-Digest: aoVh1KPRq6AkaG3V6c7U5jjgSCQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/CRefactoring2$1.class\r
+SHA1-Digest: xTrqmBbym2z7VAHBefZsXY2LGJA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMe\r
+ ssages.properties\r
+SHA1-Digest: 7Z/LDsapb3BN3Nfk2pHEYpn0Mpk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/implementmethod/Messages\r
+ .class\r
+SHA1-Digest: i1kCXsn7RO1Tn9JG8VHONj4xTj8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/BestMatchHover.class\r
+SHA1-Digest: 6DwPuHN976dughPX2dw+f36y264=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$11.class\r
+SHA1-Digest: WGk56n6Yxv+dd2kedBf5imUZB1w=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/EclipsePreferencesAdapter$Pre\r
+ ferenceChangeListener.class\r
+SHA1-Digest: cng7m0olBU61HUzthBuZkdI63OA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/NewElementWizard$2.class\r
+SHA1-Digest: owsuCu4HmhGzU6WZhBfBf1x1WPA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$5.class\r
+SHA1-Digest: Mpf760cc0pzk0bvZA8oPJp1t8a0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/ProjectSelectionDialog$2\r
+ .class\r
+SHA1-Digest: YI4o4wu6MJAQSgxhpctS6aFj0Yc=\r
+\r
+Name: org/eclipse/cdt/utils/ui/controls/FileListControl.class\r
+SHA1-Digest: jqDy64eiUH9Z3R4orpHHOzy1bSM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties\r
+SHA1-Digest: wlkT2JSHcg6vdm3j666dncjDqq4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/CUIHelp$CUIHelpListener.class\r
+SHA1-Digest: 0/xy0f23wPaYWlV0+9qnSEDys6g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/ProjectContentTypeMappingDi\r
+ alog$3.class\r
+SHA1-Digest: OLBMCSwYTYmj2yv7abALJeLF134=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/PreferencesAccess.class\r
+SHA1-Digest: PDeepCcZry11G8Z4oIKvG/5CX0A=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposa\r
+ lComputerDescriptor.class\r
+SHA1-Digest: txXjJCmWztbV/Nku6jGuqP1uRRQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage$4.c\r
+ lass\r
+SHA1-Digest: jSTilgcVCLab75EfKkN61hlpScg=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/TemplateDrivenWizard.class\r
+SHA1-Digest: 6RLJsM0Ps2miV41DhoNeNqvBXAA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProp\r
+ osalComputer.class\r
+SHA1-Digest: 9qa6V0vyHIt6do1VPOHT8ehn5Rc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.cl\r
+ ass\r
+SHA1-Digest: mN2PV0XuXQxAyFHSVhpsATdE6AA=\r
+\r
+Name: org/eclipse/cdt/ui/newui/StructureTreeTab$4.class\r
+SHA1-Digest: yTdwa2ab9QuXlY3oxGwLUMWRM+Q=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/WorkbenchRunnableAdapter.cla\r
+ ss\r
+SHA1-Digest: mD0DbgSRx/PxbthDg6qlSmVCmeA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFro\r
+ mClassToInHeaderStrategy.class\r
+SHA1-Digest: aN01Z+5Nao/zVnZ2jFRVSYd13d8=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/CygwinPEBinaryParserPage.class\r
+SHA1-Digest: WQoE8ngtiDkeuMf2ZTK2wF7imO8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameLinkedMode.\r
+ class\r
+SHA1-Digest: PKA8fW+9GVDlBre4FOyEGghDxcc=\r
+\r
+Name: icons/dlcl16/hierarchy_co.gif\r
+SHA1-Digest: IrCD/kydEUV1cUePbnXGPtN17Js=\r
+\r
+Name: icons/obj16/define_obj.gif\r
+SHA1-Digest: fzzG1weRtHCiIUs3Tod4A4u0ISY=\r
+\r
+Name: org/eclipse/cdt/internal/corext/util/Messages.class\r
+SHA1-Digest: 6iD6LBR79h2AQK8s0gsdiZ6cIvw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog$7.cla\r
+ ss\r
+SHA1-Digest: CPIRxyJ0MyUf0eYg21sw7DV4kB8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/AbstractAnnotationHover\r
+ $AnnotationInformationControl$2.class\r
+SHA1-Digest: CrF/9ojZiqAQ427jYFwqPAOpzNw=\r
+\r
+Name: org/eclipse/cdt/ui/newui/StringListModeControl$1.class\r
+SHA1-Digest: dP+CXhbHfYxAWTP850++/ypPABg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferencePage\r
+ .class\r
+SHA1-Digest: OFIuw3Gqr5+DOI1XYcNF9Sla4H8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/TreeListDialogF\r
+ ield$1.class\r
+SHA1-Digest: EttOz/hz/7Y2XCxHujij3qdl8P8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/ConsoleMessages.class\r
+SHA1-Digest: PB2wOkQ+vTBLvni0PDZmiCBQ6+4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/AbstractAnnotationHover\r
+ $ConfigureAnnotationsAction.class\r
+SHA1-Digest: WUrIOZyXT7+nw5hKdtprxaoRDsY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.c\r
+ lass\r
+SHA1-Digest: 2Qrf1+Ev8/1ZDp5/q7ad+TULU9I=\r
+\r
+Name: icons/obj16/warning_obj.gif\r
+SHA1-Digest: o7rIZbWYUFTVKY+zhkR76OAQ13I=\r
+\r
+Name: org/eclipse/cdt/ui/ICDTConstants.class\r
+SHA1-Digest: JMRBwIvxePYN8pfCtdtqWHbCN/4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/ChangeCaseProposal.cla\r
+ ss\r
+SHA1-Digest: 2M/Y78IztQS5/vUz/9xGcPwpsuw=\r
+\r
+Name: icons/obj16/search_sortmatch.gif\r
+SHA1-Digest: pTObLzuuU8ywWkVXFUFuHdBy12I=\r
+\r
+Name: org/eclipse/cdt/ui/newui/MultiLineTextFieldEditor$5.class\r
+SHA1-Digest: QoIaEubC6/6hROaISGRa+cui4V0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistProc\r
+ essor.class\r
+SHA1-Digest: QsrIBQYa3Q/D/5GYiDF4dC5Cb4w=\r
+\r
+Name: org/eclipse/cdt/ui/newui/UIMessages.class\r
+SHA1-Digest: Es5PSYWlM145Qmf0xI6UeKtLjrw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI$1.clas\r
+ s\r
+SHA1-Digest: 0SLE1wwiJehTYXDSN4+vFCqk29s=\r
+\r
+Name: icons/ovr16/external_file.gif\r
+SHA1-Digest: xjWtz/BjpfB8oT+2FZ+NZ5GuxvQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/AbstractPathOptionBlo\r
+ ck.class\r
+SHA1-Digest: V/+be99egighUq3WlSPJ1xDxRIg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CCodeReader.class\r
+SHA1-Digest: iOWyHfr9wqP2EvVcZmgQ7pIS++8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/doctools/DocCommentOwner.class\r
+SHA1-Digest: qugcPKHSUrIPPmXaGdFKJvSMw5w=\r
+\r
+Name: org/eclipse/cdt/ui/text/CSourceViewerConfiguration$4.class\r
+SHA1-Digest: 5xX+/mY143iLUu8zNZr0G3COffQ=\r
+\r
+Name: org/eclipse/cdt/ui/IRequiredInclude.class\r
+SHA1-Digest: iy2CAstknPO3iD2xLeJZ7VYXL8g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CHelpBookDescriptor.class\r
+SHA1-Digest: UROQSb9SErvtLmnXoPqyKIabFqA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/IncludeRefContainer.class\r
+SHA1-Digest: sH7B0k1yhCX4RkGaDpITA5tAWt4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/SelectionListenerWithAST\r
+ Manager$PartListenerGroup$3.class\r
+SHA1-Digest: /bmUDk+L901QLOHdwyw+WDhzpU8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SpecificContentAssistExecutor\r
+ .class\r
+SHA1-Digest: oGv+/Ga4FRew43bA7qTK4t5Ip4k=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THInformationProvider.\r
+ class\r
+SHA1-Digest: iOEDdkI3Gn2iHHJFQr8piKns0hE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBSetInputJob.class\r
+SHA1-Digest: 56hJ/WqtmYjSW9uhxbb25NJMZWQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/PDOMSearchViewPage$1.class\r
+SHA1-Digest: 0UJn/bk/yY0Tj+tNQPV2impdZGo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfig\r
+ urationBlock$2.class\r
+SHA1-Digest: tihi4gUQdnYQIrrMla2jaB6WahA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/NameStyleBlock$Category.\r
+ class\r
+SHA1-Digest: Y435JVvlB+ci+SOaxYT16xx/YfA=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/InputStatusDialog.class\r
+SHA1-Digest: 7g8KUHRMzIyXmo5Pxb5gkfOOXvE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameCSourceFold\r
+ erChange.class\r
+SHA1-Digest: rrcNfjAnSki24HDpKMDXw6uaaSE=\r
+\r
+Name: icons/obj16/unionfo_obj.gif\r
+SHA1-Digest: FL5wJ5r9NWrqm1E2Ry4rGCfhfdU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBViewPart$3.class\r
+SHA1-Digest: zM1y2LyUgyY/ULIp9VgNYSHYqEc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage$1.\r
+ class\r
+SHA1-Digest: p37iy8uNVPUHXhBRtKG8Wn3Ev6Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/RemoteTreeContentManager$2.clas\r
+ s\r
+SHA1-Digest: 6oKBl0q5UazqwAIM2kg9V/Ig794=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/StatusInfo.class\r
+SHA1-Digest: gyIz56UK/IuyUBMUMT9lAwkMjSE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CHelpSettings.class\r
+SHA1-Digest: l1wjLGYbT+bNBh+NaHcexB4VH+A=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/folding/EmptyCFoldingPreference\r
+ Block.class\r
+SHA1-Digest: 3kyjih8EAk9g7j9NhksUZbsLT+s=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction$2\r
+ .class\r
+SHA1-Digest: xzld9GI4O87wuTdVpUDZdw9tvm0=\r
+\r
+Name: icons/elcl16/refresh_nav.gif\r
+SHA1-Digest: 3NWUc5UjsZeI5q6NCFvfEyeUB1I=\r
+\r
+Name: org/eclipse/cdt/ui/newui/BinaryParsTab$4.class\r
+SHA1-Digest: VGtPUfMyXxVz6q44wpMlGwKNRAE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuActi\r
+ on$2.class\r
+SHA1-Digest: rctGupErmLSGbUaLNePEiYjLNxc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/CRefactory$1.clas\r
+ s\r
+SHA1-Digest: X96STwNelTqLvXXk2tSZmRnYCWg=\r
+\r
+Name: icons/obj16/method_private_obj.gif\r
+SHA1-Digest: NSQB1QuQCOwYBOnFVuXgg9NuZ7c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/GotoAnnotationAction.class\r
+SHA1-Digest: nDnr0kOaXVh03ZmE4uUyMUiUcD4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/FormatterModif\r
+ yDialog.class\r
+SHA1-Digest: U2G1GdYt5JGvG4rodPlpfnGGAsg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/ScalabilityPreferencePag\r
+ e$2.class\r
+SHA1-Digest: gNqyovkwzySTstvntANuyVw1otE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CDoubleClickSelector.class\r
+SHA1-Digest: B+NJ6tCZvI8yse6y9foXYiTyIpc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/actions/WorkingSetFindAction.\r
+ class\r
+SHA1-Digest: Nsx825YRrrJ0vZWvoC3bekJ0NJw=\r
+\r
+Name: icons/obj16/debugts_obj_r.gif\r
+SHA1-Digest: vJkCtmx6uvbRk2Ff2F8RoFQuG9c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/LRUWorkingSets.class\r
+SHA1-Digest: lzbJwG//n3cwr+FTP0RbWJzETI8=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/pages/TemplatePreferencePage$2\r
+ .class\r
+SHA1-Digest: sI/w5+873KIBK0KBjeYxQihHonY=\r
+\r
+Name: icons/ovr16/rec_referencedby_co.gif\r
+SHA1-Digest: 1IgaDOu1/qP7P44ONvH4/6HIlY8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/WorkingSetFilterUI$2.cla\r
+ ss\r
+SHA1-Digest: +16wkH0/xBJjKO3MAJj6SUdJBm0=\r
+\r
+Name: icons/dtool16/prop_edt.gif\r
+SHA1-Digest: hlP4DXgvmZdPPN6sbIZr6VjHuwM=\r
+\r
+Name: icons/elcl16/open_incl.gif\r
+SHA1-Digest: G/EzdXVxHf2ec2uA1BzhYMbbGEo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.class\r
+SHA1-Digest: TLohmZ8X+C+tdBHoxyfv2S81ORA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionProvi\r
+ der.class\r
+SHA1-Digest: LfeD3bUEF2wStKqRnWVq7b2dtBY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathOutputEntryPage$\r
+ OutputContainerAdapter.class\r
+SHA1-Digest: DRAa/wi46HchZRmeKZiO9473Mr8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/ChooserC\r
+ omposite$2.class\r
+SHA1-Digest: N27bnxrnNG10eee4zrC4BRIg1Nc=\r
+\r
+Name: org/eclipse/cdt/ui/newui/RefsTab$1.class\r
+SHA1-Digest: 8Dp6a3cAhPFEvKZNX2YpJdheKf0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/asm/AsmReconcilingStrategy.cl\r
+ ass\r
+SHA1-Digest: P9eiTCyH91bDBAOi+vc5HSg14sE=\r
+\r
+Name: icons/obj16/includes_container.gif\r
+SHA1-Digest: YZeBZU37ACyx/pxSZQroBgJs88c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/CreateParserLogAction$2.clas\r
+ s\r
+SHA1-Digest: Yb4fggMhuya6xr8cFzgRSL2oZ3s=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/ITranslationUnitEditorInput.c\r
+ lass\r
+SHA1-Digest: AFmT6CLxXgNfNhMayGBiHGwbkZY=\r
+\r
+Name: org/eclipse/cdt/ui/text/folding/ICFoldingPreferenceBlock.class\r
+SHA1-Digest: NWAcqlhJfvA3LN0t2hS3lY95XT4=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/DocCommentOwnerCombo.class\r
+SHA1-Digest: QallCA8wLp5GHW+6FBWJX439e4c=\r
+\r
+Name: org/eclipse/cdt/ui/resources/RefreshExclusionContributor.class\r
+SHA1-Digest: m2YOzvvaUt88Oomp00TBPblyrRU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/togglefunction/IToggleRe\r
+ factoringStrategy.class\r
+SHA1-Digest: Tq8UmaKO4RioAPYCpQWqtCrn7fc=\r
+\r
+Name: org/eclipse/cdt/ui/newui/PropertyTester.class\r
+SHA1-Digest: aONLrWRSzF61L/V3MgW7/nZTDd4=\r
+\r
+Name: icons/obj16/change.gif\r
+SHA1-Digest: XE/eqf3/rS6p8ULZG2itHXEv4d4=\r
+\r
+Name: icons/elcl16/th_showqualified.gif\r
+SHA1-Digest: dnWksgvFQSudK3lk7HV4q5VBr9Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/filewizard/NewHeaderFileCrea\r
+ tionWizardPage$1.class\r
+SHA1-Digest: djKQTUjsNW7RG9BeBy15cPPUjMQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesConfigura\r
+ tionBlock$1.class\r
+SHA1-Digest: C+W4+L7zCVZXZYuR6WYPEHmKSwQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigura\r
+ tionBlock$8.class\r
+SHA1-Digest: Ev/07Sw0bYqxLS4JWMfOctCNmdM=\r
+\r
+Name: org/eclipse/cdt/utils/ui/controls/RadioButtonsArea$1.class\r
+SHA1-Digest: BMsg+AIsVo2sfUGaUBzxcm+T4ys=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/actions/ReferencesSearchGroup\r
+ .class\r
+SHA1-Digest: BB6QWZ3XhsPowvTx3Vo/NI+iNtQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/IDebugLogConstants$DebugLogCons\r
+ tant.class\r
+SHA1-Digest: qepUuErYW8gXvkFxeb9TQGx9Y5k=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/CWizardHandler.class\r
+SHA1-Digest: nsTxgR6CWOnAcb5a9SdaVb38Xow=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.clas\r
+ s\r
+SHA1-Digest: ZpvFQbG0MH2IBE2aZYj7H1tExgU=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/conversion/ConvertProjectWizardPage$7\r
+ .class\r
+SHA1-Digest: dTIEIvycnPGfRV7jyELGo0ozwU8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/SaveActionsPreferencePag\r
+ e.class\r
+SHA1-Digest: huYoP1yDMW3xjyWTGEe4SbFvVxk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionHover$2.\r
+ class\r
+SHA1-Digest: s9PhAJYN/22x9Y4MDJjt3hrzbe0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSetti\r
+ ngsWizardPage$9.class\r
+SHA1-Digest: tN/R1T9NBAjV5rHE0EnesqNXOYI=\r
+\r
+Name: org/eclipse/cdt/ui/newui/CLocationTab$LocDialog.class\r
+SHA1-Digest: WXZb7qhuqKbWREkeS1AYmf73S5Q=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/DocCommentOwnerComposite.class\r
+SHA1-Digest: t6OQJutTyRq5luH/Ug01bQJ6ixw=\r
+\r
+Name: org/eclipse/cdt/ui/newui/CDTPropertyManager.class\r
+SHA1-Digest: qykM0hJXUTYFcCS+cULWYj/BjM8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellEventList\r
+ ener.class\r
+SHA1-Digest: RbuUjsjh+AKDUdo+CIdMpCh01DM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesListD\r
+ ialogField$CellHandler.class\r
+SHA1-Digest: +eOqytZounc1zemzrqd625O5uJE=\r
+\r
+Name: org/eclipse/cdt/ui/text/contentassist/ICompletionProposalCompute\r
+ r.class\r
+SHA1-Digest: Ysb8PeHPIJ/z34VeQqdqg8MILrI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CFileTypeDialog.class\r
+SHA1-Digest: 7cprSoZEknDo9fc4znrtSSzM4eA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/filters/CustomFiltersDialog$3.class\r
+SHA1-Digest: DGP1U/j0WuZy/EUy1w9BkjLvc3U=\r
+\r
+Name: org/eclipse/cdt/ui/newui/CLocationTab$LocDialog$2.class\r
+SHA1-Digest: 6umwvskrUacAatWCaKti/jz1z3A=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/AbstractSourceViewerInformation\r
+ Control$1.class\r
+SHA1-Digest: mS75X1PrSpzQEmBFmEpclX6bZEU=\r
+\r
+Name: org/eclipse/cdt/utils/ui/controls/ControlFactory.class\r
+SHA1-Digest: APcyF8GVLxqkaBPZGzsb53R+d7I=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/TodoTaskInputDialog$Comp\r
+ ilerTodoTaskInputAdapter.class\r
+SHA1-Digest: w2+WfBrFwujc4LtpswNgp6mFk6k=\r
+\r
+Name: org/eclipse/cdt/ui/newui/LibraryPathTab.class\r
+SHA1-Digest: b3vjBUPL9vBizYleEIQ+VbmEc34=\r
+\r
+Name: icons/obj16/exclusion_filter_attrib.gif\r
+SHA1-Digest: tXA5enrkzcz8qTzJJFYZ/dDMzxk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerSelecti\r
+ onPage$1.class\r
+SHA1-Digest: kdoZbgffeD5V754mKwdxXTGHVVM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/DocumentAdapter$Document\r
+ ReplaceCommand.class\r
+SHA1-Digest: 7cy3Fa7FNDB33yIfit/NE/kIhx8=\r
+\r
+Name: icons/dtool16/config-tool.gif\r
+SHA1-Digest: NGq558VCMOLL7EercFXmtJmz49Q=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$9.class\r
+SHA1-Digest: QEW2QcqB5QzCQzXkHFv6dRwBfJs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction$H\r
+ istoryListDialog.class\r
+SHA1-Digest: mj4KPT00C1Ay7fBMgZsv1Kzg5mU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/utils/Checks.class\r
+SHA1-Digest: klXDtGAuVPB1oz740aJaERSSj5k=\r
+\r
+Name: icons/dtool16/newcfile_wiz.gif\r
+SHA1-Digest: JulF/LXiZFPLmThHRXf/0y8Qtv4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/CActionFilter.class\r
+SHA1-Digest: atwu1goJrVWzNLbU2sNn524Vdw8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/QuickAssistLightBulb\r
+ Updater.class\r
+SHA1-Digest: pU3W3bPt+znPEW+ULjDepb67yio=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/CommentContextType.cl\r
+ ass\r
+SHA1-Digest: Q35iRVZlR3UMXTRN44dJdyBjwYk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesCache.class\r
+SHA1-Digest: 6myWpgDZXtLAsqVUDb7Igkj0BFQ=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/MachOBinaryParserPage$1.class\r
+SHA1-Digest: 242Oxz4tq7lkFeLFE1pmtXU84ho=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CDocumentProvider$ReverseMap$\r
+ Entry.class\r
+SHA1-Digest: q8hG5ANilW9993O2+0a3JcBQjao=\r
+\r
+Name: org/eclipse/cdt/internal/ui/BinaryPropertySource.class\r
+SHA1-Digest: AoMwzj9JFrF9NZxCHzHvCb23PDE=\r
+\r
+Name: icons/elcl16/metharg_obj.gif\r
+SHA1-Digest: xPwsUNmOZLXXgUNtQjaSOcESYGI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBHistoryDropDownActi\r
+ on.class\r
+SHA1-Digest: PHC4OGmADdBglrvjGNhEmHFpCWw=\r
+\r
+Name: org/eclipse/cdt/ui/newui/CLocationTab$Holder.class\r
+SHA1-Digest: d70iFafcplWKsTNpYY+LMDKDay8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/actions/SelectionSearchGroup.\r
+ class\r
+SHA1-Digest: 274vL92ph+hUUtSV7cjouwYiyLw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/CreateFileChange.class\r
+SHA1-Digest: WE4/iBZeJ3yRFSQTtUP67UekErE=\r
+\r
+Name: icons/wizban/methrefact_wiz.gif\r
+SHA1-Digest: 0bj5Af4OaaSU16D/oHQf6wR/UG4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellChecker.c\r
+ lass\r
+SHA1-Digest: UXTZYUwe8M/0BOeB/rmqyRZap14=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage$MethodStub\r
+ sFieldAdapter.class\r
+SHA1-Digest: +lxZitjti+S32vI7XNuk5vH0PN0=\r
+\r
+Name: icons/wizban/prj_obj.gif\r
+SHA1-Digest: wYKoCZPOld/s6u/All9KfNDD4PY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CombinedWordRule$CharacterBuffe\r
+ r.class\r
+SHA1-Digest: 2RCPacnGsH7IIzXfbcqsp1YB6mA=\r
+\r
+Name: icons/dlcl16/fields_co.gif\r
+SHA1-Digest: wqiBaDqG9cdr6aM6YFyH+uorTcg=\r
+\r
+Name: org/eclipse/cdt/ui/CUIPlugin.class\r
+SHA1-Digest: lmyp4gRIG/+MMJyOCDUpyqEMu9k=\r
+\r
+Name: icons/obj16/csearch_obj.gif\r
+SHA1-Digest: 9txD47ToCX3X9yL5HTCvnqYkodQ=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage$9.class\r
+SHA1-Digest: pZhaccf0uFoEm9qdwAnxx7W5R60=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingPre\r
+ ferencePage.class\r
+SHA1-Digest: 5cUzML/rQPsUcvvSbl0FXyJaQSo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/SpellingConfigurationBlo\r
+ ck$2.class\r
+SHA1-Digest: yujwvJotgcUi9119kCVBtFassU8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameSourceFolde\r
+ r.class\r
+SHA1-Digest: 7ZQzPrtEclFDsBTZ1kq0DcEY884=\r
+\r
+Name: org/eclipse/cdt/internal/ui/indexview/IndexView$1.class\r
+SHA1-Digest: NTnAhVV/9k7mK+eJnjxCXkanXpo=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/NewCCProjectWizard.class\r
+SHA1-Digest: JfIoEbyDf9C9lIOvFlodTQcHSb0=\r
+\r
+Name: org/eclipse/cdt/ui/newui/RenameConfigurationDialog.class\r
+SHA1-Digest: 4+V68ri863aiBrP4jah6eRw704k=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/asm/ASMEditorActionContributo\r
+ r.class\r
+SHA1-Digest: Tg0c3f2ra/69KGBAIPFYtX3mJEE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurations\r
+ Page.class\r
+SHA1-Digest: In+ZKiCeRczSUnRJszvf3/fCdTs=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractPage$InternalTab.class\r
+SHA1-Digest: Dwz3xRxQ+L+Q7kNtoQngI5zBKPw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/IProblemRequestorExtension.clas\r
+ s\r
+SHA1-Digest: 965jh6I4YRMiWKxljwjkgAFwoh4=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ExpDialog$3.class\r
+SHA1-Digest: 7N4fz1jtCOJDuWA+xapxbX6wUm0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/SelectionList.class\r
+SHA1-Digest: wZMYZwEUEDs6pmWChswb13CE4fo=\r
+\r
+Name: org/eclipse/cdt/ui/newui/CLocationTab$_Entry.class\r
+SHA1-Digest: QhkqzPQ4NLjEBBtJdmEMIAOPFDY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/IndentUtil.class\r
+SHA1-Digest: JIlF9jYFzubqQbZclNSJFxIggqg=\r
+\r
+Name: icons/view16/includeBrowser.gif\r
+SHA1-Digest: 5qSec08HF5y7adnTBwinSPoGH1k=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/CSpellingEngine$1.clas\r
+ s\r
+SHA1-Digest: xcQXjwxCV+0aaOzBAWdrKIAlvkM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathSourceEntryPage.\r
+ class\r
+SHA1-Digest: xJBxQ6HFcIl4YMLL6Ac6iC4C2/8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/PDOMSearchResult.class\r
+SHA1-Digest: EhTS0ZGGVCiPx6bbxc8qq7TsAl8=\r
+\r
+Name: org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineAutoEdi\r
+ tStrategy$1Entry.class\r
+SHA1-Digest: grghDwUbh0ekyhyG2P1P5j0ooxc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CodeAssistPreferencePage\r
+ .class\r
+SHA1-Digest: vuJVujwbERRqZz5XFDNXI2K4qXc=\r
+\r
+Name: icons/ovr16/warning_co.gif\r
+SHA1-Digest: 76fAklsFV/Jw7hyoXj0qFN8pgPQ=\r
+\r
+Name: org/eclipse/cdt/ui/text/TaskTagRule$TaskTagDetector.class\r
+SHA1-Digest: qZyAI19ac11thJbKqQX5c5SYhD4=\r
+\r
+Name: org/eclipse/cdt/ui/newui/BuildVarListDialog$1.class\r
+SHA1-Digest: 42KpYr9KD/K0Q1xVKrLdnG5HbKo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/ComboDialogFiel\r
+ d.class\r
+SHA1-Digest: +K0i64YRrAMQNF6dLD8TLgxwV3g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/CPreview$CSour\r
+ cePreviewerUpdater$2.class\r
+SHA1-Digest: Srl/MoQGi1X8QCgQQzp0O1PG3hU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage$2\r
+ .class\r
+SHA1-Digest: gHkBlugbCeqPGc2tocqAaaLQaUM=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractPrefPage.class\r
+SHA1-Digest: tKXYGTp4dGcADEai+swDpFv6lM0=\r
+\r
+Name: icons/dtool16/newhfile_wiz.gif\r
+SHA1-Digest: DcTIegejbFuKiQNcFKzOJ6GvLPg=\r
+\r
+Name: org/eclipse/cdt/ui/newui/LibraryTab.class\r
+SHA1-Digest: zBL5nQlFTnniN3XQfop/TsMM2r0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/DocumentAdapter$NullBuffer.cl\r
+ ass\r
+SHA1-Digest: 1w8Y9bpLB467lodxT4W7Z3XyKzo=\r
+\r
+Name: icons/obj16/cprojects.gif\r
+SHA1-Digest: +D6xBcIfGIa+PdzlPE8LJyy2EEE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/navigator/CNavigatorDragAdapterAssis\r
+ tant.class\r
+SHA1-Digest: 9Jw3Z32hmUgpwYIM6aPEfyhd79M=\r
+\r
+Name: icons/etool16/action-buildconfig.gif\r
+SHA1-Digest: FgSfgP7vEGZZ/a2a6BN1roPzq1g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/TwoArrayQuickSort.class\r
+SHA1-Digest: I9g2HUkJA88k8UcRO+EirDmJKbM=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/CFormatter$VariableTr\r
+ acker.class\r
+SHA1-Digest: SFLysHf/TQYjK2Mco9yVEBvIFgw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenActionProvid\r
+ er.class\r
+SHA1-Digest: wWxttCQMLpUx/QEjg/Fa8DWr/1I=\r
+\r
+Name: org/eclipse/cdt/ui/newui/IncludeDialog$1.class\r
+SHA1-Digest: 9F3bPr30DcsG0QKVS+ky25vGwxs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/implementmethod/MethodTo\r
+ ImplementConfig.class\r
+SHA1-Digest: olp31jsbsdA2Cn9pffkAUzQVkfA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/Ext\r
+ ractLocalVariableRefactoring.class\r
+SHA1-Digest: ZH8NxwbFvM5KmL4+1sdDSwGcrTE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/FormatterTabPa\r
+ ge$1.class\r
+SHA1-Digest: YTav85usX5XGq/jsc5gwRmkmtQ4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/utils/NameHelper.class\r
+SHA1-Digest: esHZqYU1+lb0lJoThZ7p/Rrcudc=\r
+\r
+Name: icons/elcl16/goto_input.gif\r
+SHA1-Digest: 8tWEPMPi/LtyjhbnZcUAU5UgZfU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/PartitionDamager.class\r
+SHA1-Digest: 3JlbIvuxLD0BQlksspDnt/bNWkI=\r
+\r
+Name: org/eclipse/cdt/utils/ui/controls/ControlFactory$1.class\r
+SHA1-Digest: S5omdq7sw8mvSYVxtpLWB9FiG9Q=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/OverlayPreferenceStore$O\r
+ verlayKey.class\r
+SHA1-Digest: h5vl8HRj06mTScJDLHpSNBFSBTU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEnt\r
+ ryPerFilePage$CPElementPerFileFilter.class\r
+SHA1-Digest: +Xi0NCsF8sADzEFsUrN2O2lwnLA=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage$RegexPatte\r
+ rnEditingSupport.class\r
+SHA1-Digest: OfaF46jOcu+pUf9OPM8MgjWAajw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathPropertyPage$1.c\r
+ lass\r
+SHA1-Digest: RkF1hEdjvD5FV6KT0Q5Pwacvh9c=\r
+\r
+Name: org/eclipse/cdt/ui/newui/CLocationTab$1.class\r
+SHA1-Digest: L6Xtfn/ZJQ6Zp5CIRLH4Lva0WUw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBSetInputJob$1.class\r
+SHA1-Digest: pKLFiqkDgFsM00jbhOt9XOtjn1E=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/CTextFileChangeFactory.c\r
+ lass\r
+SHA1-Digest: FICnHGeFTdOHxLmNoX6EVsCyVP4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/SubstitutionTextReader.class\r
+SHA1-Digest: X+hgDGYXxyfov5YHnCoIwf3YEHM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBloc\r
+ k$3.class\r
+SHA1-Digest: sYXtOzBYgcP5AXK0KKN2QpprjN0=\r
+\r
+Name: icons/elcl16/filterSystem.gif\r
+SHA1-Digest: ZkY8Vlpk19mMjw8PWw2+AmGuT4c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeMessages.cl\r
+ ass\r
+SHA1-Digest: H1DM5VVyPYGNh6RtxafoyUvEjUk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart$4.class\r
+SHA1-Digest: d9rWrNuSsw/XYFE7fcEX1XSyLhA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager$1.clas\r
+ s\r
+SHA1-Digest: HJU4wbBqnNWI64KcVHikGZ+KD68=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/FoldingMessages.class\r
+SHA1-Digest: or2Tj24FK8C+G7KpQVR0nNZjYqM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/help/CHelpEntry.class\r
+SHA1-Digest: lYW0AUDBTBSOqsGrxjiatYmjiEM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/utils/PseudoNameGenerato\r
+ r.class\r
+SHA1-Digest: CMGlQhOxYNT+zomirvUmyUqYZt8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/WorkspaceContentTypeMapping\r
+ Dialog$2.class\r
+SHA1-Digest: TwulW79gkrCg6xrwyIpPmc/UA6k=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage$BaseClasse\r
+ sFieldAdapter.class\r
+SHA1-Digest: 9GukINU3Dc3o7nLdvsVN4y9/JPE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/StatusDialog.class\r
+SHA1-Digest: NEejHnGSa6EZW/+qv5VzvYyfjEg=\r
+\r
+Name: icons/obj16/info_obj.gif\r
+SHA1-Digest: t9DwZ6l43L5wvgmn+EtISWNfQyo=\r
+\r
+Name: icons/obj16/container_obj.gif\r
+SHA1-Digest: UGIl0tYCtJnXjILBGaqXz9dUlM4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/IHtmlTagConstants.class\r
+SHA1-Digest: 6PeniB+LeMea8+nrFFdBJfquC3Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathBasePage.class\r
+SHA1-Digest: kamDJi1ICi1G0x/wF5PbyBxprtg=\r
+\r
+Name: org/eclipse/cdt/utils/ui/controls/TabFolderLayout.class\r
+SHA1-Digest: Qfyzh65gwo6l3rFSnBQCYW+NrwU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/ExcludeFromBuildHandler$1.cl\r
+ ass\r
+SHA1-Digest: BeGnVLvH4U1TZCTVeD00XGi6LL8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/implementmethod/Paramete\r
+ rNamesInputPage$2$1.class\r
+SHA1-Digest: 5crEaepgdBTpQNO9a+YL5KInKBM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigura\r
+ tionBlock$1.class\r
+SHA1-Digest: R9r8B2CBDGFnO5jn5Z5VWP9cT+A=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBDropTargetListener.\r
+ class\r
+SHA1-Digest: h3/XqexicmLT/743yvM0ThC70fY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerWizard.\r
+ class\r
+SHA1-Digest: ZuVqfpnlGyQ9kiwSVxDhxpI+H7o=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreat\r
+ ionWizardPage$1.class\r
+SHA1-Digest: E1SQ10LnLI5eUZ8z2sJapweJbBk=\r
+\r
+Name: org/eclipse/cdt/ui/text/ITokenStore.class\r
+SHA1-Digest: FwnyVV8jJRKWRo9LhKglez84nH0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSetti\r
+ ngsWizardPage$2.class\r
+SHA1-Digest: IsBwY6y4F0X4hwh0o8VQ6HAivlQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CHeuristicScanner$NonWhitespace\r
+ DefaultPartition.class\r
+SHA1-Digest: r2C20PukzvGqjmkb8iVJkESKsK0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CodeTemplatePreferencePa\r
+ ge.class\r
+SHA1-Digest: kMMU7afH/ejrROJoK69sbtxRbXI=\r
+\r
+Name: icons/wizban/newsrcfldr_wiz.gif\r
+SHA1-Digest: f5cPRLkUAFAKuTZULSyasrnpBs0=\r
+\r
+Name: icons/elcl16/segment_edit.gif\r
+SHA1-Digest: yat2ml9OJ0TqkFQAM+BajLYuTH4=\r
+\r
+Name: icons/elcl16/action-editconfig.gif\r
+SHA1-Digest: kKJLklAxE9IEwAtoTvYuAYzFVto=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ErrorParsTab$3.class\r
+SHA1-Digest: 9ZoNfya6Lc57q/58g+YhPKU04Bw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CPreprocessorScanner.class\r
+SHA1-Digest: 5mN7axM/wGF4KHE78pXBBBpkmTU=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ImportExportWizardButtons.class\r
+SHA1-Digest: xYwsTsxBtloPaig/qTV69SnrwtY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultPhonetic\r
+ DistanceAlgorithm.class\r
+SHA1-Digest: jkSQUEG2sKnxEwtmfhflDunYLus=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposa\r
+ lComputerRegistry.class\r
+SHA1-Digest: z7CSb+WQe807w4G1STxcftEyX/4=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/NewHeaderFileCreationWizard.class\r
+SHA1-Digest: 0EkOCYBynjtR9sTx+H2yB5aCHfU=\r
+\r
+Name: org/eclipse/cdt/ui/newui/StringListModeControl.class\r
+SHA1-Digest: 4ONkySQoD82VsZckzR4TZn2nSXQ=\r
+\r
+Name: icons/elcl16/static_co.gif\r
+SHA1-Digest: J7QetQXCktQAuy0huqvm1nn9/uE=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ManageConfigDialog$4.class\r
+SHA1-Digest: cxneK9edtihcBteaLT7q6yP57pc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$2.class\r
+SHA1-Digest: ouJqjysUvpEcej/4Asc9pNHrJfE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/ToggleLinkingAction.class\r
+SHA1-Digest: sswfNvwy5G1qYqN19BB1FG1odqs=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage$12.class\r
+SHA1-Digest: qh/bbbHnQddEMu11QqPRTss45jU=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/ExclusivePositionUpda\r
+ ter.class\r
+SHA1-Digest: dud4tpU22HEDUydretYb1GsTe3A=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/SpellCheckIterator.cla\r
+ ss\r
+SHA1-Digest: 1YfNShRhf+xg3aDw3ZddV/8suyo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/IStatusLineProposal.\r
+ class\r
+SHA1-Digest: WpIn3m8qNimlhAeC/TgxTTIReu0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CBreakIterator$Run.class\r
+SHA1-Digest: e0CZJyfj/LRSkyf/9tS2AgDm+qY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/CHelpDisplayContext.class\r
+SHA1-Digest: 8kywsYF5VGT2AiTCZK1CaCXid6s=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleRef\r
+ actoringRunner.class\r
+SHA1-Digest: gneT8Nep8ueAqylQLB4mI1O9QlI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/PDOMSearchUnresolvedIncludesQ\r
+ uery.class\r
+SHA1-Digest: GyjpSYJhAtzqqNc1yxMf/Vun8Hc=\r
+\r
+Name: icons/dlcl16/shift_r_edit.gif\r
+SHA1-Digest: Xr1jTQX3qaABFpjlYytDMqo2ovs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/dialogs/ValidatingLabele\r
+ dTextField$1.class\r
+SHA1-Digest: h5/l1M6S1WAFcwggweuixLkgSkA=\r
+\r
+Name: icons/dlcl16/save_console.gif\r
+SHA1-Digest: p68rRGCUbR95QsJGnH+o9orx0aM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/ConstructedCEditorMessages.pr\r
+ operties\r
+SHA1-Digest: tYtCoA2rNpLWGQXcGdMdsq+5mi0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/MethodContext.class\r
+SHA1-Digest: nSwArC5uXYH8cf1oCu9mJnrSZps=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction$Hi\r
+ storyListDialog.class\r
+SHA1-Digest: k7KB73h88vYR6/KKbNdKRvFyAQ0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringUtils\r
+ .class\r
+SHA1-Digest: 3Od+GJC94reb3iZtuOkIN5Ne+gA=\r
+\r
+Name: org/eclipse/cdt/internal/corext/codemanipulation/StubUtility.cla\r
+ ss\r
+SHA1-Digest: A8Qm1Wr3IOVr3UoccKdGtpp0vEs=\r
+\r
+Name: org/eclipse/cdt/ui/newui/EnvDialog.class\r
+SHA1-Digest: 2skSzQ7cyglhI9NIPCf5YqyaJl0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfig\r
+ urationController.class\r
+SHA1-Digest: Vg/yF+JJJ5VyY11or30TiJU6mtw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/PathEntryVariablesGroup$\r
+ 2.class\r
+SHA1-Digest: SewdrCUke1jGjQhgDF47MDutNTU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesListD\r
+ ialogField$1.class\r
+SHA1-Digest: VUtdpwmS3vl8WQg+KLBP9gVZxQ0=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage$ClassNameF\r
+ ieldAdapter.class\r
+SHA1-Digest: hu6MsO19NdTeFMwMY9YoiOVm0YM=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/IndexerBlock.class\r
+SHA1-Digest: 9ATOVUAvyOikyZ22anHXM1cxCdk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/folding/FoldingMessages.propert\r
+ ies\r
+SHA1-Digest: LnMIgOJ/15fKxkhmR1CUnp0Kfv8=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage$2.class\r
+SHA1-Digest: 7lViaVzcl1HpFVZzLwZCiWdkYUA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetUpdate\r
+ r$1.class\r
+SHA1-Digest: rpXgkYOIFUOY/8g4FYFFDIwH30M=\r
+\r
+Name: icons/view16/cbrowsing_pers.gif\r
+SHA1-Digest: 9v6C5axRUAmK75ZzK1pVSatU3GY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/DocumentAdapter.class\r
+SHA1-Digest: FjaLXCGycwZJu43nK8tO9JxB3NU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/AbstractPreferencePage$4\r
+ .class\r
+SHA1-Digest: EUwbhUP5CvLXSphBL2FMpJeSYzk=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ExpLibraryPathTab.class\r
+SHA1-Digest: 1xoMD3U+odeGUFRr6Jlli/0YebA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CodeTemplateSourceViewer\r
+ Configuration.class\r
+SHA1-Digest: IGHcidhAVyeb1ACR/xgIEtd8AbY=\r
+\r
+Name: icons/view16/namespaces.gif\r
+SHA1-Digest: q+L2MBoGXDUzbFHpO2jr8sJW0co=\r
+\r
+Name: icons/obj16/file_change.gif\r
+SHA1-Digest: p7sYcsfD1GrsqMpeU25Y8efx3t4=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractExportTab.class\r
+SHA1-Digest: /Vr48O76feqDyLcP6as30cfauq8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CBreakIterator$Identifier.class\r
+SHA1-Digest: cwH6xCFuSOd/gIckWjuWbgmVEAM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedCorr\r
+ ectionProposal.class\r
+SHA1-Digest: Sun+r1cKOEAX7DB3jcNPmTOOnMU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionGroup\r
+ .class\r
+SHA1-Digest: OqWXcHWououopf2bSdE8TAG5tBI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/dialogs/CreateFileChange\r
+ Preview$CreateFileChangePane.class\r
+SHA1-Digest: iugHmWnD3fG+szJORimMG00HWVE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart$CopyCallHie\r
+ rarchyAction.class\r
+SHA1-Digest: GwyRV+sN4Q2xP/jvj87uDh4+g/M=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBViewPart$1$2.class\r
+SHA1-Digest: 0fyuixG4gMLFZHEC5V+dWn0IPiU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/engine/LocaleSensitive\r
+ SpellDictionary.class\r
+SHA1-Digest: yFVpNSoJu3K7qGNghXytzjX3PGQ=\r
+\r
+Name: icons/ovr16/relatestoMultiple_co.gif\r
+SHA1-Digest: QsGLrQk/4Gu/OnNI5jLpWEkyO4k=\r
+\r
+Name: icons/elcl16/list-movedown.gif\r
+SHA1-Digest: ela6DilX1NyNYhaaMrjQXpoY7A8=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ExpLibraryTab.class\r
+SHA1-Digest: Tx92cLK0Sa9/kNaODKRvN8iGcQ8=\r
+\r
+Name: org/eclipse/cdt/ui/ICHelpBook.class\r
+SHA1-Digest: 5PF8B10BYR+B2n5gR9pUoa0VL4E=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/PDOMSearchElement.class\r
+SHA1-Digest: zA+ut3wy7vK2E2S8NbnlOouMJZI=\r
+\r
+Name: icons/dtool16/opentype.gif\r
+SHA1-Digest: UDrkpMQWpfcfZmF0d+XTq4wkCCw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBloc\r
+ k$2.class\r
+SHA1-Digest: MI9ThvUNperr4aNFiEmrP9ap97Q=\r
+\r
+Name: icons/elcl16/th_horizontal.gif\r
+SHA1-Digest: wpzXlnORNZ+xlgzyQudNiJGgYGs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dnd/FileTransferDropAdapter$1.class\r
+SHA1-Digest: jzMS+AhiwXPyR8lwp7QUR9h3m/U=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/TemplateDrivenWizard$1.class\r
+SHA1-Digest: vnzM0kqwofQpz0jZQDn+Q8Siqsg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/CView$9.class\r
+SHA1-Digest: hPufC46mWa5o4h51cb/JYI8uqzM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedName\r
+ sAssistProposal$DeleteBlockingExitPolicy.class\r
+SHA1-Digest: FcPHu0HCb2daH9u1xMZbmaZniXk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/compare/AbstractMergeViewer.class\r
+SHA1-Digest: oJRYbbuIy8N22rtAhQEQ8DYLH2M=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetPage$1\r
+ .class\r
+SHA1-Digest: XGesc5KPkxZ/RkdW1J1IeIZ2t7c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/implementmethod/Implemen\r
+ tMethodRefactoring.class\r
+SHA1-Digest: yaHwN/nHxtEqMBveachDpd7pHOQ=\r
+\r
+Name: org/eclipse/cdt/utils/ui/controls/FileListControl$SelectPathInpu\r
+ tDialog$2.class\r
+SHA1-Digest: H3KZEx+eO8rYB+hEbBJ1VT4gLpk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/AbstractUpdateIndexAction.cl\r
+ ass\r
+SHA1-Digest: w8nKGMumozI0T25RYiOwa1Y6Nh0=\r
+\r
+Name: icons/elcl16/filterInactive.gif\r
+SHA1-Digest: CfBcseA908OeWWOCnfWkyuAVLQc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/AbstractAnnotationHover\r
+ $HoverControlCreator$1.class\r
+SHA1-Digest: 8J2aQK290HEGgx3jazCLqReCFWI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/LineSearchElement$MatchesComp\r
+ arator.class\r
+SHA1-Digest: lr6rcuHs9g2AHy+TiiN9iS0ulus=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructur\r
+ eProvider$CProjectionAnnotation.class\r
+SHA1-Digest: Owww/JHaFquMXzZmsXCWuRfK76s=\r
+\r
+Name: org/eclipse/cdt/ui/text/TaskTagRule.class\r
+SHA1-Digest: eqanr/euMTGdg46CtP3bHEgm87I=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/CViewRenameAction.class\r
+SHA1-Digest: Ln3GWHoXakY5lEOLQuDDsWU5JMs=\r
+\r
+Name: icons/obj16/exec_obj.gif\r
+SHA1-Digest: gN2+Lr54Q64opFDCdYL/RbO3A3E=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/DefaultBinaryFileEditor.class\r
+SHA1-Digest: 4V/cPlUl13ETHD8fKkaduVkX/Ws=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/ComboDialogFiel\r
+ d$2.class\r
+SHA1-Digest: rOBxM2+9atZEMnwBW+BYyXBi9ng=\r
+\r
+Name: icons/elcl16/list-moveup.gif\r
+SHA1-Digest: BQPOY1vd6SG4L4MyRebhsLPJxqs=\r
+\r
+Name: org/eclipse/cdt/ui/newui/CLocationSourceTab.class\r
+SHA1-Digest: aQrVID/cAht/X5ZNWo9eG0buv6M=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/OverrideIndicatorManager$Over\r
+ rideInfo.class\r
+SHA1-Digest: A9KfNR0JCFrbsiorJmo+Fi8EgUA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/BasicElementLabels.class\r
+SHA1-Digest: OLXmJlA++FHqSlnuPQZcSY1111U=\r
+\r
+Name: icons/dlcl16/clear_co.gif\r
+SHA1-Digest: 0UhusAC9H7/0OtAq93NU4iHpct0=\r
+\r
+Name: org/eclipse/cdt/ui/IFunctionSummary$IFunctionPrototypeSummary.cl\r
+ ass\r
+SHA1-Digest: bU2qcQR4LAT2KROHfx3C0BVTz9A=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/LayoutUtil.clas\r
+ s\r
+SHA1-Digest: b/PoIQkHQ5Rk0S5SwHNI4zxrJeg=\r
+\r
+Name: icons/elcl16/collapseall.gif\r
+SHA1-Digest: X2SYkCGSP2jr+iOlYBLU19jEd4Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CReconciler.class\r
+SHA1-Digest: DAA021MCs6jt62ZEScRzrfP33wg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/SelectionProviderMediato\r
+ r$2.class\r
+SHA1-Digest: 8ety7tslo3JxsWL/S0goKTC05eI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/SpellingPreferenceBlock.\r
+ class\r
+SHA1-Digest: uYCZ8H0p2RIvO+nUibew03Z//fw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/AbstractWorkingSetsContr\r
+ ibution.class\r
+SHA1-Digest: CP5XVc/eakGGHvrW+YYPL9O6/EM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/Mes\r
+ sages.class\r
+SHA1-Digest: IajdnMO8fBb7K5Czru3NulVaXB0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/LineWrappingTa\r
+ bPage$3.class\r
+SHA1-Digest: TbhzJbJJLYmUhN06iz5wMDdFSFg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/CSpellingService$1.cla\r
+ ss\r
+SHA1-Digest: ivknx0XhoDqv/NSjHSYN+wTcK9E=\r
+\r
+Name: org/eclipse/cdt/internal/ui/filters/NamePatternFilter.class\r
+SHA1-Digest: 06ZIqxe8ITzyBWS/zflOM02bv9U=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingWid\r
+ get$2.class\r
+SHA1-Digest: LFW/35IWdN3afaWcvsdqMhbdUhE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/engine/SpellEvent.clas\r
+ s\r
+SHA1-Digest: b5ssi0CQ0n2Jx42YsHdOWfbhFgI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/IndexToASTNameHelper.cla\r
+ ss\r
+SHA1-Digest: aJktQu2Sz3vKcQeEnySXF1U4xEg=\r
+\r
+Name: icons/ovr16/write.gif\r
+SHA1-Digest: rHERpTky3Wk5FPhhFU6OLzstnew=\r
+\r
+Name: icons/wizban/newmngc_app.gif\r
+SHA1-Digest: Pe65ftYD7Vj1pgSr2192Jj1vKeE=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/uitree/UIElementTreeBuilderHel\r
+ per.class\r
+SHA1-Digest: I0ltofvDF9318ikpBHyMsTHg1KM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsInWor\r
+ kingSetAction.class\r
+SHA1-Digest: QHy1R5HRgxMYtc1CXoyuL8UrtBY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CBreakIterator$Other.class\r
+SHA1-Digest: P8GDjHjcNrYj/2WWtl4ic6OI8z4=\r
+\r
+Name: icons/elcl16/view_menu.gif\r
+SHA1-Digest: 6S83KJ2GsQRIP4V5DPnLo7jaXsQ=\r
+\r
+Name: icons/obj16/ch_resource_obj.gif\r
+SHA1-Digest: iku7YQWkrPd3wAfTVlDRrI+UlVM=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractLangsListTab$2.class\r
+SHA1-Digest: E8/H3WAc44diT4LP9x1cQSSofvo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/ASTProvider.class\r
+SHA1-Digest: NZqyo+1/pth/nM9JWrCvZlRU5bM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/IProjectSett\r
+ ingsWizardPageStrategy.class\r
+SHA1-Digest: LCQnOUgoXeIAE93z7PaVg693aTk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner\r
+ $1.class\r
+SHA1-Digest: Tvd8JkClQnD5xCt1Ui0ZIHs52Cs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$23.class\r
+SHA1-Digest: WsP2mdeF4PXvaQdFNZ3qxJShqvw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$BracketInserter.class\r
+SHA1-Digest: P7qCizJBT5d8yVYimFb+1ApXXCM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/ITHModelPresenter.clas\r
+ s\r
+SHA1-Digest: CT2fGmP0PETMTaIZrisuSDPAxPs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/DeleteResConfigsHandler$1.cl\r
+ ass\r
+SHA1-Digest: 4SVf9huUdkoo1hV/OU32cv3CWjo=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/FileTemplateContextTy\r
+ pe$DateVariableResolver.class\r
+SHA1-Digest: +s8Rl/xW1sqwiHo5RPF6UaSvYx0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/SourceFileSelect\r
+ ionDialog.class\r
+SHA1-Digest: ZxVK5s+3XA7X5CgVDEUkLlN9+Qo=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/NewCProjectWizard$1$1$1.class\r
+SHA1-Digest: qhf46TsImQaFY9TxuJnf6ljtuxM=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/CodeTemplateContextTy\r
+ pe$Todo.class\r
+SHA1-Digest: 4cIw5hWZiMj+KzGvI4AceVm2Dhw=\r
+\r
+Name: org/eclipse/cdt/utils/ui/controls/IFileListChangeListener.class\r
+SHA1-Digest: /YgduSBIbG09fLoObNTHcBu9/24=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/MarkerResolutionProp\r
+ osal.class\r
+SHA1-Digest: vg2M+/vot9QXEPCKoeqpfbpdSSA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/template/TemplateEngine$CTempla\r
+ teProposal$1.class\r
+SHA1-Digest: 0jzMNWgXWkuEwSjReourC5Tb3jY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/FoldingActionGroup$1.class\r
+SHA1-Digest: Qtg/PclOqJvbGlOyQhLf63DHMH0=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractSinglePage.class\r
+SHA1-Digest: RUXGHrl281gGVbhzWUN6+JSTA4c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CSourcePreviewerUpdater.\r
+ class\r
+SHA1-Digest: sPy9LHhKvke/y7rhK/yvWx2srQM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/IWorkingSetConfiguration\r
+ Element$ISnapshot.class\r
+SHA1-Digest: QSAvdksyWr9Qxl2gpscmXKnIvsw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEnt\r
+ ryPage$SelectPathInputDialog.class\r
+SHA1-Digest: w+JBJnuJ/4lslxwz/Cwh7nxqvk4=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/CygwinPEBinaryParserPage$6.class\r
+SHA1-Digest: A1bNRCi2Odad+4dVom4jf7zAIJA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$17.class\r
+SHA1-Digest: pTO1hkVsz12R7uZIl5bXZJdo2RA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardPr\r
+ efs.class\r
+SHA1-Digest: zZPvI6aZVdtvF6G3NLJdrYnrTMI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/IDebugLogConstants.class\r
+SHA1-Digest: Ha4JK3V4W0WiD8mrMSTLPvPr1KA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/ICStatusConstants.class\r
+SHA1-Digest: 6EMsOlhNbQ69zZVrWbUevRxKI1U=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/SimpleElementException.class\r
+SHA1-Digest: FS002n9WgNuEOFROMuUlYVXMFPQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/asm/AsmTextEditor$EditorSelec\r
+ tionChangedListener.class\r
+SHA1-Digest: P+6vKMF+oxQpWhmY2lvsBjpML+4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFro\r
+ mInHeaderToImplementationStrategy$1.class\r
+SHA1-Digest: dUudvRYwHgEJe4if2fkmz4/wru8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationB\r
+ lock$1.class\r
+SHA1-Digest: x24GnfnRvqXKfxmOmPTqfkq/pvo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/AbstractInformationControl.clas\r
+ s\r
+SHA1-Digest: QfU9Ih6udwJAxD3uJA2SBy8UgG0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/LinkedNamesFinder.class\r
+SHA1-Digest: R8IDIxQNWWYJc8mWt0dFAcyF6LI=\r
+\r
+Name: icons/ovr16/template_co.gif\r
+SHA1-Digest: OmknKEsw4s/e1RAPpr/uqqUaaQI=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/CProjectWizard.class\r
+SHA1-Digest: 9OHcuS9r1pgrEmuoOPR6AwdFhMs=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/CContextType.class\r
+SHA1-Digest: YqJCkVV0qFtS0vUNHZ6+HwzIA9k=\r
+\r
+Name: icons/obj16/shad_co.gif\r
+SHA1-Digest: amFH4dHeE6QuZCAQoQZKuxVlWAQ=\r
+\r
+Name: org/eclipse/cdt/ui/text/contentassist/ICompletionContributor.cla\r
+ ss\r
+SHA1-Digest: /aG36vuv/IPjU9wp2p4vsDCQn3s=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/Container.class\r
+SHA1-Digest: U+QRxOwTMfbP1x/En5fYi9v4yj8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformation\r
+ Popup$6.class\r
+SHA1-Digest: tgqyc/8IrFbwxkbm36oufkYoAVI=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/IndexerBlock$IndexerConfig.class\r
+SHA1-Digest: KoZMCddspVvbeUY3BLn0S83jmhI=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UISelectWidge\r
+ t.class\r
+SHA1-Digest: X8T+4hWFN9btQgXgZZO1LpMVC18=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractPage$2.class\r
+SHA1-Digest: v+J6zpt+EHPSzFNEAlcjeSL0bWQ=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/CHelpConfigurationPropertyPage$CHelpS\r
+ ettingsDisplay$2.class\r
+SHA1-Digest: EH0d3m9cAu0kSVzL9vmdyC0QVec=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactorin\r
+ g.class\r
+SHA1-Digest: /1nSfxsfqeTJ5hM0/eFKyw1ePu0=\r
+\r
+Name: org/eclipse/cdt/ui/actions/CustomFiltersActionGroup$1.class\r
+SHA1-Digest: jOo9YiX5TgpiruS5H+G7jL/1IL8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/proposals/ASTRewrite\r
+ CorrectionProposal.class\r
+SHA1-Digest: CT7EoYcqs7qrKceeSnPWNdXqhis=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/IInputStatusValidator.class\r
+SHA1-Digest: S3/FNWyUJ/jlYW/GuvlcncNqals=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Getter\r
+ SetterInsertEditProvider.class\r
+SHA1-Digest: l46OBAbOpNG/hv4IzhGQU9so1XI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/MultipleFolderSelecti\r
+ onDialog$4.class\r
+SHA1-Digest: fAyVgue+6DfH28E7qQqAYvBHzAQ=\r
+\r
+Name: org/eclipse/cdt/ui/text/contentassist/ContentAssistInvocationCon\r
+ text.class\r
+SHA1-Digest: 2UBImTjxKTq0JNAVIDvEyXk9p14=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Functi\r
+ onFactory.class\r
+SHA1-Digest: qJNxds9cSL5HuLfif0/jHfubx5w=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkingSetMessages.class\r
+SHA1-Digest: NhwtO+er9CP9FbKB6KFHGt8rcik=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/DocumentMarkerManager.c\r
+ lass\r
+SHA1-Digest: 5fSwdBMXZh7lRu6lQONSXRUlduo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfig\r
+ urationFactory$Registry$Descriptor.class\r
+SHA1-Digest: f+gUa0/mQyYvLSsejTSEM3nq50M=\r
+\r
+Name: org/eclipse/cdt/ui/CElementContentProvider$IRefreshable.class\r
+SHA1-Digest: atKFO52r7KERkBxAaSfgAFMxV14=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/BinaryParserBlock$3.class\r
+SHA1-Digest: sMKJseadbCqfJMQFvVnDp7ZuxhI=\r
+\r
+Name: org/eclipse/cdt/ui/CUIPlugin$2.class\r
+SHA1-Digest: TePlHWZcRRW4BJC1fkLiand+e/I=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedPrefer\r
+ encePage.class\r
+SHA1-Digest: 6gO//klFUhTwoOjJhIddRMtsmKw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightings$Functio\r
+ nHighlighting.class\r
+SHA1-Digest: 9sHfzNnpUr8Yq00I8bnvY4HMrrc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementGroup.class\r
+SHA1-Digest: tN/bQmCFuKnSE7xPyp35GjFbpgI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/Messages.class\r
+SHA1-Digest: Ok/L0G545G9eQ8wikGOnxIa3SBk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightings$Namespa\r
+ ceHighlighting.class\r
+SHA1-Digest: OyL7pc8wSAEoUXLq8IOufrjXNG0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBViewPart$9.class\r
+SHA1-Digest: 8gOiM46CFfJ/GaiPLcBnxuF17eI=\r
+\r
+Name: org/eclipse/cdt/utils/ui/controls/FileListControl$2.class\r
+SHA1-Digest: /SK4GIf+ivp8nptpgwHmBu9PPEo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/ProjectConfigsController\r
+ $ControllerContext.class\r
+SHA1-Digest: kHJfKTMCdFpt8tbcP2TLDLYF5c8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/BuildWorkingSetConfigsCo\r
+ ntribution$BuildConfigAction.class\r
+SHA1-Digest: jDloXOZmjmnaMz1ZLk0AVn1N7KY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/asm/AsmTextTools.class\r
+SHA1-Digest: vSCaSLN1rD4C7EoVlJvn82CX7Tk=\r
+\r
+Name: icons/ovr16/systeminclude_co.gif\r
+SHA1-Digest: PXcF4KodLhbjRa7GwNPFXilAURY=\r
+\r
+Name: icons/obj16/source_attach_attrib.gif\r
+SHA1-Digest: Zdn/8AsfYBAJ/erbEVw3Nr+GW+4=\r
+\r
+Name: icons/obj16/class_obj.gif\r
+SHA1-Digest: 2oZ5N9mMPV7Tm8vKagG2LoxMyFY=\r
+\r
+Name: org/eclipse/cdt/ui/text/ICTokenScanner.class\r
+SHA1-Digest: AjTl5NX39SjPIx/fHdISZ7iVmeU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI$2$1.cl\r
+ ass\r
+SHA1-Digest: 3OmtwwyFjeQ/WzvChGa19zCtWVA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/CView$2.class\r
+SHA1-Digest: OoRPsH33+hciiZjyKZk0d/Oe9Pw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerEntryPa\r
+ ge$ContainersAdapter.class\r
+SHA1-Digest: CnT5OYTOboDrpMlrU5BvZ/ZudKA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBContentProvider.cla\r
+ ss\r
+SHA1-Digest: JFOzpCz56Q/HaMOGF2ULxdilbJY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleRef\r
+ actoringContext.class\r
+SHA1-Digest: 41mhxccBqPAmVh3XmLUZYATPZz8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBViewPart$15.class\r
+SHA1-Digest: 6KvuZBRwi/FGGCDCUto8y9gVtEM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightings$Functio\r
+ nDeclarationHighlighting.class\r
+SHA1-Digest: eXyvLRiR0wutMxT0snU3mzVNPhs=\r
+\r
+Name: org/eclipse/cdt/ui/text/AsmSourceViewerConfiguration.class\r
+SHA1-Digest: 3reTN5Etqfk/tt68uGFy6tPktkc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/PDOMSearchPage$3.class\r
+SHA1-Digest: 778cChXaPDKEblDTvUTJA2PM254=\r
+\r
+Name: icons/obj16/typedef_obj.gif\r
+SHA1-Digest: 9/skt2ElM0BCkHm8kcSnV4wxTHc=\r
+\r
+Name: icons/dlcl16/filterDefines.gif\r
+SHA1-Digest: cgN+SBIdhm2/d7FE2K18j7PpU9g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceOpti\r
+ ons$OptionNode.class\r
+SHA1-Digest: wiGAHvY8ZrrKoFEn6w2c9LXRQzk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/AbstractInformationControl$5.cl\r
+ ass\r
+SHA1-Digest: 8TT1ilrCf/wsawXSMtSccxWWgtw=\r
+\r
+Name: icons/etool16/newclass_wiz.gif\r
+SHA1-Digest: +PhhDpZKIudqyrMESijGbfPx/kU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/togglefunction/Insertion\r
+ PointFinder$1.class\r
+SHA1-Digest: Omxtxr+5f8vfrusx9j50uJQcPno=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/RefactoringExecutionHelp\r
+ er$Operation.class\r
+SHA1-Digest: YGvChnLsulpAWhOb0nzSdJxGBEE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/CElementLabelComposer$Fl\r
+ exibleBuffer.class\r
+SHA1-Digest: QeyK9kn3xHTVKmsr5k794RhxL14=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/implementmethod/Paramete\r
+ rHandler.class\r
+SHA1-Digest: 3j0EFu7D7lXChx3IzQqYZXTEA6Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/Messages.class\r
+SHA1-Digest: oZFa0gvOaorcn79mjKdiPIeBIU4=\r
+\r
+Name: org/eclipse/cdt/ui/newui/CDTUIListComparator.class\r
+SHA1-Digest: nsAISzDJSXe9IEIKH8OwIn9EAtU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingWidge\r
+ t$LanguageTableData.class\r
+SHA1-Digest: f6F/C/3SNSYeb1M/2z81yrV1Trw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/AddBlockCommentAction.class\r
+SHA1-Digest: Pu4sC9eEW/2U4HZm7jHQyafizhs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/StringButtonDia\r
+ logField.class\r
+SHA1-Digest: hTWaspBOcgtpnwOxK2uOkVvG7aE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CInformationProvider.cl\r
+ ass\r
+SHA1-Digest: u7Jbt/Sf9Of5ct6wyKaykQfGvqU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/ProposalFilterPreference\r
+ sUtil$ComboState.class\r
+SHA1-Digest: jyyrEda3KC7NCxEVeT5mcAbXlOE=\r
+\r
+Name: org/eclipse/cdt/ui/NamespacesGrouping.class\r
+SHA1-Digest: nOTaT2uJshjH1ReL8zhIWiFFZ1g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Genera\r
+ teGettersAndSettersInputPage$1.class\r
+SHA1-Digest: 5P3YSM1G5vCkieRAskCHJnc9NLM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/AlreadyExistsD\r
+ ialog.class\r
+SHA1-Digest: t3NV7c7kgNsACGKoZ8oTBawD7E4=\r
+\r
+Name: icons/elcl16/ch_callees.gif\r
+SHA1-Digest: bimTIED/9q4XOIDIZPcR4qufpqc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/AbstractCompareViewerInformatio\r
+ nControl$CompareViewerControl.class\r
+SHA1-Digest: VnAB3ayTRWCOL31jZMKVo8m5wUA=\r
+\r
+Name: icons/obj16/toolbar_pinned.gif\r
+SHA1-Digest: IycEvMkgySuB2wK17MCWcu6Vt88=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ConfigMultiSelectionDialog$1.class\r
+SHA1-Digest: 9P9TgJjpdnZcS6HQAxit4wvXDZA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/NewWizardMessages.class\r
+SHA1-Digest: kuX64oreqPGnKx/Cn33c0/B++ns=\r
+\r
+Name: org/eclipse/cdt/internal/ui/navigator/CNavigatorEditActionGroup.\r
+ class\r
+SHA1-Digest: xt6Tc2Eat95OB3SMTGykjHeFUtc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/AppearancePreferencePage\r
+ .class\r
+SHA1-Digest: HZV2D4JRVw3/CLQ85SZQ1cD7VS8=\r
+\r
+Name: icons/elcl16/ch_callers.gif\r
+SHA1-Digest: 93ZOfGTjFyUYHMVI70lR/U7+pXE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/template/TemplateMessages.prope\r
+ rties\r
+SHA1-Digest: X+YEUIqrbMViXyO+EZuO86b95jA=\r
+\r
+Name: org/eclipse/cdt/ui/refactoring/actions/ToggleFunctionAction.clas\r
+ s\r
+SHA1-Digest: FYla7OdfyPK/oW0q7T0dcxPRctc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactorin\r
+ gPreferences.class\r
+SHA1-Digest: pU26ln8xEMRW/cLJW7kT0pkPnlk=\r
+\r
+Name: icons/etool16/newfile_wiz.gif\r
+SHA1-Digest: QcxM0kkl1Mo/T76FdX6dg4s4tA0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/CRenameClassProce\r
+ ssor.class\r
+SHA1-Digest: 0mm9hwJ9m2HNenbkrI7D3H0jTj0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameLinkedMode$\r
+ 3.class\r
+SHA1-Digest: 6PB2iZk6+mf74Upsb/MTpwKhCVM=\r
+\r
+Name: icons/dtool16/newc_app.gif\r
+SHA1-Digest: Suig672IzG6jSNPFGBZmoGs4D4Q=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/SourceAttachmentBlock\r
+ $2.class\r
+SHA1-Digest: IcLZGMKHVRNxEvGrR3aBzg9CI6g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.class\r
+SHA1-Digest: tRi5a0KGUXfBwyLAdu9bvyNfCtI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/IndexNameToAstNameMatche\r
+ r.class\r
+SHA1-Digest: GmzamPfdm6kRu0L3u+jisgRMBUA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionExplorat\r
+ ionControl$4.class\r
+SHA1-Digest: XNR29uQ1YBLxXJvvRal5z9yWEYk=\r
+\r
+Name: icons/obj16/filesyst.gif\r
+SHA1-Digest: Aauf0IWttKpubN35BhGFmXo2Ekk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/CodeFormatterC\r
+ onfigurationBlock.class\r
+SHA1-Digest: 4B8n+e+xOZ6RevsJ4p+JmUmcZCg=\r
+\r
+Name: org/eclipse/cdt/ui/actions/GenerateActionGroup$1.class\r
+SHA1-Digest: poyflYYR4YUhSq4XZepF7wvP7WM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dnd/DelegatingDropAdapter$6.class\r
+SHA1-Digest: fK2yVNWmQsRIg9/4j+e0hCsb5Jo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/Messages.properties\r
+SHA1-Digest: iJwYjPTy0tPPL/kZ8/wodHY+tNA=\r
+\r
+Name: org/eclipse/cdt/internal/corext/util/CModelUtil.class\r
+SHA1-Digest: XwbhXJVJYc0ZK2CyOFz2ZQ6y2qA=\r
+\r
+Name: org/eclipse/cdt/ui/text/contentassist/ICEditorContentAssistInvoc\r
+ ationContext.class\r
+SHA1-Digest: pE+ll1VYoU98rrkjni+v15OmqoE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/OpenExternalProblemAction.class\r
+SHA1-Digest: H/35CLjwaFMpwIgmPArdDYcsFuQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Getter\r
+ SetterContext$FunctionWrapper.class\r
+SHA1-Digest: mEjRBnIj68EleHCWuGFFjIVj86I=\r
+\r
+Name: icons/dtool16/config-release.gif\r
+SHA1-Digest: e58qnmFQHJpW1CpLMtMaqxVjBpg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CInformationProvider$Ed\r
+ itorWatcher.class\r
+SHA1-Digest: 1rfqZE93fqgFZ77EbuprxKtd0qE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/CRefactoring2.class\r
+SHA1-Digest: mnhdL3uf0MQUXQgAqk5Xaj0nqe8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dnd/TextViewerDragAdapter.class\r
+SHA1-Digest: 1ElFw47DQ6g81zhXjAVBasXKcQI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/indexview/IndexView$IndexContentProv\r
+ ider.class\r
+SHA1-Digest: +5eOWXjHGCbkEzizeDeiP/9oovw=\r
+\r
+Name: org/eclipse/cdt/ui/text/doctools/IDocCommentSimpleDictionary.cla\r
+ ss\r
+SHA1-Digest: ie6CyOGFCTbJ2Q2KG3zy07rdJ/4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/util/CWhitespaceDetector.class\r
+SHA1-Digest: 46obk7qDfYsHWq++ymNM+UiJdy8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/TableLayoutComposite.class\r
+SHA1-Digest: 5iV9TfhOUmAqus2egro95yOrBbU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/utils/DeclarationFinderD\r
+ O.class\r
+SHA1-Digest: sLCUNbhqHgzJfop1gsCBahzUo8s=\r
+\r
+Name: icons/dtool16/newmngc_app.gif\r
+SHA1-Digest: Suig672IzG6jSNPFGBZmoGs4D4Q=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/RemoteTreeViewer$SelectionJob.c\r
+ lass\r
+SHA1-Digest: y15t9amVTqGdWMzDpirSeF7kZnc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$10.class\r
+SHA1-Digest: tYWayCPeSzOw20PtT5qeWx4+Wmc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/engine/IPhoneticDistan\r
+ ceAlgorithm.class\r
+SHA1-Digest: sMxLHVMXAvr8htP72/1lIetuZWg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/NewElementWizard$1.class\r
+SHA1-Digest: OaOv898qm/qy8ok37SX++TzObk8=\r
+\r
+Name: icons/dtool16/config-compiler.gif\r
+SHA1-Digest: Z+y0PixqOxajkiJa2fQZJUilOSU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/LineWrappingTa\r
+ bPage$CategoryListener.class\r
+SHA1-Digest: RM4icFOppCiAB32wrpq6z80mKsQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$4.class\r
+SHA1-Digest: 3wDPAn2mTJeRGgrkJUBHcbqxATs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/ProjectSelectionDialog$1\r
+ .class\r
+SHA1-Digest: yzW8zvhP5AyiaAYvZkvdF+13o2c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/utils/ASTHelper$1.class\r
+SHA1-Digest: CJ3dUbwZoN3fePeduuA19mJ3t9o=\r
+\r
+Name: org/eclipse/cdt/ui/newui/EnvironmentTab$6.class\r
+SHA1-Digest: aIwdMKzD1z+S095di8DVulDqpnw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/ProblemsLabelDecorator$1\r
+ .class\r
+SHA1-Digest: /B8UeXgkz5luGD92borvg6kdMZg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/AbstractSourceViewerInformation\r
+ Control.class\r
+SHA1-Digest: DcCunpc4UOBCE+Tqj8tv0OiNQrA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/ProjectContentTypeMappingDi\r
+ alog$2.class\r
+SHA1-Digest: tTf7Fnvy+I63nqSTKEwVGh1tmNA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformation\r
+ Popup$7$4.class\r
+SHA1-Digest: 1cSuRO/jj+OFU8+bg7jWB7PCj30=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage$3.c\r
+ lass\r
+SHA1-Digest: sPbaSlvOQo02FECCdUrtYNsRmjY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/CSpellingReconcileStra\r
+ tegy.class\r
+SHA1-Digest: O4JC8pQSCKd7IqJ/H8/NAaLK3cY=\r
+\r
+Name: icons/elcl16/clear_co.gif\r
+SHA1-Digest: 0UhusAC9H7/0OtAq93NU4iHpct0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/indexwizards/messages.proper\r
+ ties\r
+SHA1-Digest: UtZ3bk8N5ES2UU2gU1ONHtFdncQ=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/TabFolderOptionBlock$1.class\r
+SHA1-Digest: ejscjxG7AVFOXrvT5D08j5eBjl4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/LineSearchElement$Match.class\r
+SHA1-Digest: Anrvrdy3+BcKlBIEiLyUWL8kf9E=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage$4.clas\r
+ s\r
+SHA1-Digest: 77hng7xeOW7zvVEDBk92WnAzayc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CPresentationReconciler.class\r
+SHA1-Digest: jbPDr6EtAqKxZlFpR0u2Fb2UMyw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CodeFormatterPreferenceP\r
+ age.class\r
+SHA1-Digest: PZ1soL2dX4Y0rFMg+PJLzLtRxDQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/NodeContainer.class\r
+SHA1-Digest: nFzUNU9sIRKId9Q8t47augQP83I=\r
+\r
+Name: org/eclipse/cdt/ui/newui/StructureTreeTab$3.class\r
+SHA1-Digest: VsjwyK0zwvCu7T6+9xFzOpBKzTM=\r
+\r
+Name: icons/dtool16/newfolder_wiz.gif\r
+SHA1-Digest: vk10ORMZj+LVnw8zYq+MthKAL80=\r
+\r
+Name: about.html\r
+SHA1-Digest: smEEY0YLqDk798evb45ZV8N2Nhk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/OverlayPreferenceStore.c\r
+ lass\r
+SHA1-Digest: 4xNsU0be58jDiBwVIygkgKebWiI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/OverlayPreferenceStore$P\r
+ ropertyListener.class\r
+SHA1-Digest: kXnWxSCDVvxAOVS4N5Em8asRqWs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THContentProvider.clas\r
+ s\r
+SHA1-Digest: gIP3WBVaJeNN/GauBugNm2b6Xfg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog$6.cla\r
+ ss\r
+SHA1-Digest: hb336MsbzeibJOUlnSi8jRMpN4M=\r
+\r
+Name: icons/obj16/threads_obj_g.gif\r
+SHA1-Digest: lF5D/L/KKrcf81pXNtxM7o5K/uY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/AbstractAnnotationHover\r
+ $AnnotationInformationControl$1.class\r
+SHA1-Digest: 5rndWy0tg8WlC68rV5iknDicBcg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/CHelpProviderManager.class\r
+SHA1-Digest: yAN3QyFhgaFb1xfwHhy6suTK+Vs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructur\r
+ eProvider$FoldingStructureReconciler.class\r
+SHA1-Digest: NPSZujoYq3n5bzmKy+DCEVgGI3o=\r
+\r
+Name: org/eclipse/cdt/internal/ui/help/CHelpTopic.class\r
+SHA1-Digest: R4KHkXSyPTFJEeQaMHXE341vq9I=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/TemplateClassWizard.class\r
+SHA1-Digest: 0TF5ddABKjppA3JT3i3imGqIXkQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconcile\r
+ r$PositionCollector.class\r
+SHA1-Digest: hzDhVDMxsnK9JLPyamBZMjWXCjo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dnd/CDTViewerDragAdapter.class\r
+SHA1-Digest: LPSuCHO7eEiQAeuVeRyws31Cr0c=\r
+\r
+Name: org/eclipse/cdt/ui/newui/MultiLineTextFieldEditor$4.class\r
+SHA1-Digest: 0w4atTeJHzpW0V4rvvjSIRR03TA=\r
+\r
+Name: icons/obj16/fldr_lib_obj.gif\r
+SHA1-Digest: ujmnUfQd4AV47+f9ZT/wHXETWDE=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/CDTCommonProjectWizard$2.class\r
+SHA1-Digest: 2XfvdK7JefHgZNqC8JuwAwGPA7U=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/SelectionListenerWithAST\r
+ Manager$PartListenerGroup.class\r
+SHA1-Digest: Q4zI251wnqBSIakEYAc1Nea9YoA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/LinkedProposalModelPrese\r
+ nter$LinkedModeExitPolicy.class\r
+SHA1-Digest: kLlYk7oAi5ez1O2YyMj0UnR/IO8=\r
+\r
+Name: org/eclipse/cdt/ui/text/CSourceViewerConfiguration$3.class\r
+SHA1-Digest: yRyMJT8hH2WMIsQPBRWHPWCx8ys=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerSelecti\r
+ onPage$CPathContainerSorter.class\r
+SHA1-Digest: BgRv+0x/ODqAlJ7PUueBFiCvSuM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialogTa\r
+ bPage$PageLayout.class\r
+SHA1-Digest: F5dS4xngDEcsgzC4h68tcMkCmgU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/StandardCElementLabelPro\r
+ vider.class\r
+SHA1-Digest: WLNt/UzoFS17xEj7y5jeFRgYSe4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFro\r
+ mImplementationToHeaderOrClassStrategy.class\r
+SHA1-Digest: ZFxoqK86pje2pcqueu8cSLMOLl4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/SelectionListenerWithAST\r
+ Manager$PartListenerGroup$2.class\r
+SHA1-Digest: l9hYX7gdCDAIk31VCNF+Mrgfm6E=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigura\r
+ tionBlock.class\r
+SHA1-Digest: n/16fzgfHtVr75Dkw3rpBd4iQXg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/util/CColorManager$1.class\r
+SHA1-Digest: pUfc3UJ7qTL980w3cdWD8fCaMaE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathTabBlock.class\r
+SHA1-Digest: KOvGj5StZZ5bSD/UpSD/9/lKvg0=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/CodeTemplateContextTy\r
+ pe$CodeTemplateVariableResolver.class\r
+SHA1-Digest: oGaiJ3Iz1wpxE4cXG28j9g1ceA4=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/CDTCommonProjectWizard$1$1$1.class\r
+SHA1-Digest: EcIH1T5KdowRZCAm9WxmEH3/Vus=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/utils/ExpressionFinder.c\r
+ lass\r
+SHA1-Digest: PNFeQH0Iicj5QxXTPj8k6O0XSpQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatch\r
+ Store.class\r
+SHA1-Digest: peAWOf2/6FUzF0aash3+S/H5G8s=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/TodoTaskPreferencePage.c\r
+ lass\r
+SHA1-Digest: sv0nD3xdvGcAuP356Fc9WSNjN4U=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/IProjectSett\r
+ ingsWizardPageStrategy$MessageType.class\r
+SHA1-Digest: SdZ4sFng7MDSQT4gWeXtISDfq4E=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfig\r
+ urationBlock$1.class\r
+SHA1-Digest: rqsFpEqQ8UHdsC6EoIoW7IfwHGU=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ManageConfigSelector.class\r
+SHA1-Digest: qp9VjSZMDFc0cQWaHmZ2YySjT58=\r
+\r
+Name: icons/dtool16/config-profile.gif\r
+SHA1-Digest: NGq558VCMOLL7EercFXmtJmz49Q=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/CRefactoring2$ProblemFin\r
+ der.class\r
+SHA1-Digest: ZOl+lgJ1XnBwRJ4+7xMIgd+7LtM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBViewPart$2.class\r
+SHA1-Digest: hA4Ti+ZWbXm9foy/ej6/3RSgmCc=\r
+\r
+Name: icons/etool16/action-newconfig.gif\r
+SHA1-Digest: XbJdsIegK7Xom+MaRv/EOTd5DRY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/RemoteTreeContentManager$1.clas\r
+ s\r
+SHA1-Digest: 6jizxk6DdncmBOm6j2HFCvEAuvc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/OverrideIndicatorManager$1Met\r
+ hodDeclarationFinder.class\r
+SHA1-Digest: vOiim210rMbIBgVZW7YTGvTc3AY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction$1\r
+ .class\r
+SHA1-Digest: Ot/k2XfeJWY+UMKUDJUy7PteqMg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructur\r
+ eProvider$CommentPosition.class\r
+SHA1-Digest: ojrT9ayyNZ42eZlPoXpWUGD43x8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/OpenElementInCallHiera\r
+ rchyAction.class\r
+SHA1-Digest: 12Pzo01fzk1Jxk1+deTqEo5KSMg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleViewer.clas\r
+ s\r
+SHA1-Digest: e0Rb/pS2tESHNLV6QzoPpvaXBZw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/IndexUI.class\r
+SHA1-Digest: 0cYDjanaxDnffENE0whITeNqQdw=\r
+\r
+Name: org/eclipse/cdt/ui/newui/BinaryParsTab$3.class\r
+SHA1-Digest: uvt9jY9Cf9C93rGNeu8M2ed38y4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuActi\r
+ on$1.class\r
+SHA1-Digest: zWt/FGu8dbQW/57fJYJ9BppcDhk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/IModifyDialogT\r
+ abPage.class\r
+SHA1-Digest: 8qWJ5w327kKxXmmb4+Cjw6VoMRU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/LanguageVerifier.class\r
+SHA1-Digest: lvM+PpYp6t8FI1iy2FjLER5o75s=\r
+\r
+Name: icons/dtool16/action-deleteconfig.gif\r
+SHA1-Digest: kPiG5krErKLfTUxh/lbVkBt81f0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/ScalabilityPreferencePag\r
+ e$1.class\r
+SHA1-Digest: O0zUzKAzP1y9AujhO/W8cqD7hd0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/IBaseClassInfo.c\r
+ lass\r
+SHA1-Digest: 5M3Fdstz+wulXpcoJkmUx3x6+Xg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/ColoredViewersManager$1.\r
+ class\r
+SHA1-Digest: UM0SD5lrqyoH8nyQPRnWYWjgABA=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/pages/TemplatePreferencePage$1\r
+ .class\r
+SHA1-Digest: wbb+bUzXSIq1tmf8al5FxCG9+ps=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/NewFileDropDownAction.class\r
+SHA1-Digest: EDvpAZyees9IvgNMOInvppd1xGo=\r
+\r
+Name: icons/view16/class_hi.gif\r
+SHA1-Digest: vYgFu3TSq5m9t5d1POqGcLSLpAg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/LanguageMappingLinkListener\r
+ .class\r
+SHA1-Digest: Wwel6XIWieNogRmMtKsnDspv8JM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/WorkingSetFilterUI$1.cla\r
+ ss\r
+SHA1-Digest: xc0MjiqEUHaPax/NufpbY4q2Qfg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRef\r
+ actoringRunner.class\r
+SHA1-Digest: JPy8XdKbhuk/xX3ecuDse//kJrI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightings$Typedef\r
+ Highlighting.class\r
+SHA1-Digest: QjaHqk37SouXPF1d9xNwon8xzCw=\r
+\r
+Name: icons/dtool16/prev_error_nav.gif\r
+SHA1-Digest: 6rwH5piBA2AgCgoZ7ew7Z0474v0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconcile\r
+ r$2.class\r
+SHA1-Digest: I67RZbSW1rNHUMvkQvH45R9yf2M=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuActi\r
+ on$ConfigureTemplatesAction.class\r
+SHA1-Digest: jpqj22eIviLEcvfTmq+YQpCa9VM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CReconciler$ActivationListener.\r
+ class\r
+SHA1-Digest: rHoCawzX6MbJiJEAczciYKVl/SE=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/DocCommentContextType\r
+ .class\r
+SHA1-Digest: M0uHgChg9+zbPSuiKzhrW+f8nL0=\r
+\r
+Name: icons/obj16/hfolder_obj.gif\r
+SHA1-Digest: ookX9kCV50FddwgCRIw5m4w52zA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CReconciler$ElementChangedListe\r
+ ner.class\r
+SHA1-Digest: HKH4Dl/dwUNQVvAgqZfbJPS2T1o=\r
+\r
+Name: icons/obj16/correction_add.gif\r
+SHA1-Digest: 48lJqtGPTLceuO5hgsIb8/qafsw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/ChooserC\r
+ omposite$1.class\r
+SHA1-Digest: 9xl1QekJbB5FNCgZcyRdnmqc9Pg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/SurroundWithActionGroup.clas\r
+ s\r
+SHA1-Digest: 4dZdApcyTsfmQ95fMWBjBm1Zgjw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/CreateParserLogAction$1.clas\r
+ s\r
+SHA1-Digest: fpZ4ZJj1lfUvKp+BiCtqi31QSec=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/proposals/TUCorrecti\r
+ onProposal.class\r
+SHA1-Digest: WwpubGJQzFosf1WQm9KBYAyUjRY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetPageCo\r
+ ntentProvider.class\r
+SHA1-Digest: d5+29CpcftkfR+nG3C9vZWAcJmk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/IDialogFieldLis\r
+ tener.class\r
+SHA1-Digest: U1WrHCjSAk1I65+7OvzXiJRxEMw=\r
+\r
+Name: icons/obj16/correction_change.gif\r
+SHA1-Digest: ZcpDjYDeEJOJmkORmgqZmjSTWlw=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ProjectContentsArea$IErrorMessageReport\r
+ er.class\r
+SHA1-Digest: MIKTA4pEEywC3KgBMtIj9C3ZSJI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionInput$Si\r
+ ngletonRule.class\r
+SHA1-Digest: 31qh4eM3xDASluXqWedqrF01TSc=\r
+\r
+Name: icons/obj16/cdeclaration_obj.gif\r
+SHA1-Digest: VMGXIMF9UzDn+JmC3NBCoDLCQu4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/ProjectConfigurationCont\r
+ roller$ContentProvider.class\r
+SHA1-Digest: a4241HbSp44DvrotJ6J1UnAUyis=\r
+\r
+Name: icons/etool16/config-preprocessor.gif\r
+SHA1-Digest: wSWrpV4I6dFLNxokVl682wbvmGY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigura\r
+ tionBlock$7.class\r
+SHA1-Digest: V5b9gxZznmA89JYUC004cbda16A=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/BusyIndicatorRunnableContext$Bu\r
+ syRunnable$ThreadContext.class\r
+SHA1-Digest: IH5wUQQIdbOoLBzvKH7o5eGVCbs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/CollapseAllAction.class\r
+SHA1-Digest: MsRXDyV9EHpu89LC6Ng6nOP/9AM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/navigator/CNavigatorLinkHelper.class\r
+SHA1-Digest: mvwtMK1Jx1g1HpOnAUx8aePOPt0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/asm/AsmDocumentSetupParticipa\r
+ nt.class\r
+SHA1-Digest: 0o6j9eBvO958fWl2crDMGxT64No=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THGraph.class\r
+SHA1-Digest: QMZOPdRFfwDgVa/1ONWPK5WkCUQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$NextSubWordAction.cla\r
+ ss\r
+SHA1-Digest: Qo6lAo4080FYT6P+Aorl18E7zsk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightingManager.c\r
+ lass\r
+SHA1-Digest: CQ6XiWFZCftBNA3ir/cEFVNxZaQ=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/CCProjectWizard.class\r
+SHA1-Digest: qqeeoGiPX++PWW4cGqEkwW3OnMk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPListImageDescriptor\r
+ .class\r
+SHA1-Digest: BUbS2HNsZPaGl0neofSZBULZb5w=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/conversion/ConvertProjectWizardPage$6\r
+ .class\r
+SHA1-Digest: xhEXhHXASHI3zRcYHWlOx4gF6Ts=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/CRefactoringDescription.\r
+ class\r
+SHA1-Digest: 3J/RKKMfO16U+A0FYnN9BhPDbc8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessor.\r
+ class\r
+SHA1-Digest: LIFe7bnTOoAS/AoItV8WCjRS7/Q=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionHover$1.\r
+ class\r
+SHA1-Digest: qQya85cLlbNh/vwOh6P1y4qeJig=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/ICOptionContainerExtension.class\r
+SHA1-Digest: MexqJPA6Gy3p5h/DnarMG2ZFfcM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSetti\r
+ ngsWizardPage$8.class\r
+SHA1-Digest: lUt1nil2NgKAE6TAxvOF08WYx9o=\r
+\r
+Name: icons/obj16/build_menu.gif\r
+SHA1-Digest: 46OJkH2E2Ild8CNwkgva4PHrbsA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.class\r
+SHA1-Digest: N4+BngUUtP2AM2iUzog3o5Uw/0U=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/SelectionTransferDropAdapter.c\r
+ lass\r
+SHA1-Digest: PEEW/FSI0I8VZ9BPKc9yVYPdTkk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractconstant/InputPag\r
+ e.class\r
+SHA1-Digest: +xuY325pMSCNagyH92YF87VnfFM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/CDTQuickMenuCreator.class\r
+SHA1-Digest: M2mxvjVeiPA837Movt5Ipkdx+Qk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ProfileConfigu\r
+ rationBlock.class\r
+SHA1-Digest: PyWr3ZNDqohDj9ZMWLdoCbYOvC4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/DocumentAdapter$DocumentRepla\r
+ ceCommand.class\r
+SHA1-Digest: rMUUP+c+RWNo89nmWlIze4teFQw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/EditorOpener$1.class\r
+SHA1-Digest: xkl6FlxKEOehx0V28VvjDjCj4oc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialogTa\r
+ bPage$Preference.class\r
+SHA1-Digest: BNz8tTIXieY9WFdJlnxSgOowGJo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/filters/CustomFiltersDialog$2.class\r
+SHA1-Digest: Cx0VlHpggFbgw7t1GwUPOuYo/YM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/EclipsePreferencesAdapter.cla\r
+ ss\r
+SHA1-Digest: g+UHS4zkdtKOdrZWySFIEpItX44=\r
+\r
+Name: org/eclipse/cdt/ui/newui/CLocationTab$LocDialog$1.class\r
+SHA1-Digest: 418JiHRmHmRkMh7UwnkV29AeXJs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleViewer$Inte\r
+ rnalDocumentListener.class\r
+SHA1-Digest: xPJww+H7Gab3j+WH+dQgsKTCCZk=\r
+\r
+Name: icons/dlcl16/refresh_nav.gif\r
+SHA1-Digest: ZfYzwnG+Natkxv00ojcVHDiW3is=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposa\r
+ lComputerRegistry$1.class\r
+SHA1-Digest: 00hcSCd9bvqJZ1X+LAl2zIhXIao=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$8.class\r
+SHA1-Digest: Jcpkiz5idEtQPm4WFIDCUrSQ4sc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/compare/AsmMergeViewer.class\r
+SHA1-Digest: Myky8alP+27GFT2C+MThISJqrt0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CTemplatePreferencePage.\r
+ class\r
+SHA1-Digest: fDptF4dedR90LxuR0Io9uCUMP0Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractF\r
+ unctionComposite$1.class\r
+SHA1-Digest: jOYUiCC0YKxFCAhuFj+eGj3WHWs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/actions/FindUnresolvedInclude\r
+ sProjectAction.class\r
+SHA1-Digest: VXyrpvTlCVhpMSJUkzYlXC70UNw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/ScrollLockAction.class\r
+SHA1-Digest: JoTAArdjoWSH+TtBnxJ2aEMLhqI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog$TextV\r
+ iewerAction.class\r
+SHA1-Digest: 6n0P4FsvVvuNlRqkCxq9W5bAzpI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/utils/SelectionHelper$1.\r
+ class\r
+SHA1-Digest: Gvm7vPV3JX6dLft6edcNVZxZNZQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformation\r
+ Popup$4$1.class\r
+SHA1-Digest: WIIKThEUueJmc4OMIve+pLXukxc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SortLinesAction$SortElement.c\r
+ lass\r
+SHA1-Digest: D8WI8nKDisVOlfMyKPV9ltCBzI8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/LineWrappingTa\r
+ bPage$SelectionState.class\r
+SHA1-Digest: DbQOxxPceiusKYoVmP4Ju/keRNE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dnd/FileTransferDragAdapter$RefreshO\r
+ peration.class\r
+SHA1-Digest: 6bZMcS0cIS5Yg6kXnXgaM/O/F5c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/OpenProjectGroup.class\r
+SHA1-Digest: UaglY90o8c0psdSdzB/NauDHPoA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesCache$4.clas\r
+ s\r
+SHA1-Digest: rgbN7D904oabTlGnrt6eLmE3iO4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/PDOMSearchViewPage$SearchView\r
+ erComparator.class\r
+SHA1-Digest: rl7bGzYQZiBbCfJfCa60r4Dv4Hc=\r
+\r
+Name: org/eclipse/cdt/ui/text/ICPartitions.class\r
+SHA1-Digest: UV+2QM7eyU3/1l6wjnF+xMLeCOM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/CoreSpellingProblem.cl\r
+ ass\r
+SHA1-Digest: 3nCL36EFyqt0U6BX7+YxKMMz/iE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THHistoryDropDownActio\r
+ n.class\r
+SHA1-Digest: KZVuP1uZhGyquauTj20s2B8hgG0=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UIStringListW\r
+ idget$1.class\r
+SHA1-Digest: 8YwBMZJXK0I6Q7Wxz19DOpxcxpE=\r
+\r
+Name: icons/obj16/lib_obj.gif\r
+SHA1-Digest: nkL22+4kbPDTI1ASDZhct7YaLXQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/navigator/CNavigatorRefactorActionGr\r
+ oup.class\r
+SHA1-Digest: jvMmgnmlA3pfBS2XACWKvgnqspI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CMacroCompareViewer.cla\r
+ ss\r
+SHA1-Digest: Uc8VcY2BXbyTBqUbdeAg5XfzTJ8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightings$LocalVa\r
+ riableHighlighting.class\r
+SHA1-Digest: 5AGPw+wYQ0iZBcx+q0r+FH1cKw4=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage$8.class\r
+SHA1-Digest: YCp3wgSra7Y1WZ+MX8dB58xOvnc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsActio\r
+ n.class\r
+SHA1-Digest: +FBLW8u5xUtEVmZ/ypIovz2RVCc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/SpellingConfigurationBlo\r
+ ck$1.class\r
+SHA1-Digest: sLre/wK1EuQNfS1SJEV3alH3MRo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEnt\r
+ ryPerFilePage$SelectPathInputDialog$1.class\r
+SHA1-Digest: /bySnHfTrp+inY15PAuXBBcIakQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CFormattingStrategy.class\r
+SHA1-Digest: P1DXSbrWIU7mMTQa6px3in/GUoo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/FastCPartitionScanner.class\r
+SHA1-Digest: HehxwngTs4DFDdamaK4jTVP2lX8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/filters/NonCElementFilter.class\r
+SHA1-Digest: bpSawk8uEbt5srzDMyt9RME4Bs0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/asm/AsmContentOutlinePage.cla\r
+ ss\r
+SHA1-Digest: Ccravrxmuz8KCDxhmzwRJNwac/Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/DefaultAction.class\r
+SHA1-Digest: g/nqZduI3vR2EjP6MQC22okGvVc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/compare/CStructureCreator.class\r
+SHA1-Digest: /P61DMhrF6udhnA1374Q577dX/M=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/implementmethod/Implemen\r
+ tMethodRefactoring$1.class\r
+SHA1-Digest: T1OFI1goDawrsBzlbY7xBWQ57lQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/BuildLogPreferencePage$3\r
+ .class\r
+SHA1-Digest: tCIMvcsA7KTqecKeLO9ZXanWfZg=\r
+\r
+Name: org/eclipse/cdt/ui/newui/IncludeTab$1.class\r
+SHA1-Digest: YVUAfuUAPo+GqZPw1NTRLKkBBOc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/NewSourceFolderDialog\r
+ $SourceContainerAdapter.class\r
+SHA1-Digest: p+mx6hOR7BabAq959Nkl7sJOZsE=\r
+\r
+Name: plugin.properties\r
+SHA1-Digest: Wc0VZnQAPZoLbGsN7E3f+bJQ8Yo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionInput$1.\r
+ class\r
+SHA1-Digest: QB32zhH+sbWwIJRShstTLKnju3M=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesListD\r
+ ialogField.class\r
+SHA1-Digest: eMn3vkckUwjfPzt6uz4jQj4EC+I=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/FolderSelectionDialog\r
+ $1.class\r
+SHA1-Digest: dLLKxxisLSlnhLHiktLDLak0ZgM=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ExpDialog$2.class\r
+SHA1-Digest: qrYYJk8REbScg2oGzmmHhpGNisU=\r
+\r
+Name: org/eclipse/cdt/ui/text/doctools/IDocCommentDictionary.class\r
+SHA1-Digest: elf8zmJN/3pqp7SqL9oU5WCATac=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactorin\r
+ gWizard.class\r
+SHA1-Digest: AwxAz4ysvaCBqssV8s7gvVERv5M=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/AbstractElementListSelection\r
+ Dialog.class\r
+SHA1-Digest: ZRi7f4dV25jp1V44xkE/cGHR7Ho=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/ExcludedFileDecorator.cl\r
+ ass\r
+SHA1-Digest: kt+GyTANAOjZADbkcQv82GbZgVs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CBreakIterator$LineDelimiter.cl\r
+ ass\r
+SHA1-Digest: Atgw5KRg1FcjCMIz34j7PISMckg=\r
+\r
+Name: icons/obj16/breakpoint_disabled.gif\r
+SHA1-Digest: ObFBejvPzrYIqNWxl04OsQo6GIo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THMemberContentProvide\r
+ r.class\r
+SHA1-Digest: VUcLQRk5azbHUc5hZFklQCly1fo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/CPreview$CSour\r
+ cePreviewerUpdater$1.class\r
+SHA1-Digest: rteE4MhRlVi79O1Yw2SP6bIerh0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/Separator.class\r
+SHA1-Digest: CMdhI1+zG5vkknNWi926A4CC9SU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/ICThemeConstants.class\r
+SHA1-Digest: y4riVTUtAHb3u4hy2Gv/GJ2VgiY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage$1\r
+ .class\r
+SHA1-Digest: xz94lG/mUJoOMHJSi3s78fYY+2I=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/indexwizards/StringVariableS\r
+ electionDialog$1.class\r
+SHA1-Digest: NJyF0lH9vKoiAYLDUq1pibhTVGE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart$15.class\r
+SHA1-Digest: z/8cM2KQnYpMnrB0nJ54+95bOG0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/DefaultBinaryFileEditor$Binar\r
+ yFileEditorInput.class\r
+SHA1-Digest: usM9FyUahgCOsDjtWpAd24NrXRs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/SpellingPreferenceBlock$\r
+ StatusChangeListenerAdapter.class\r
+SHA1-Digest: zK6GyyeBkj2vgY+JxyMauSzyXCc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CReconcilingStrategy.class\r
+SHA1-Digest: 8++Zo0M1Mn7S3IIEjzQnXY8BNO8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElement.class\r
+SHA1-Digest: 5hjJLpH28xZkVSaaKXQAJ3TR7NY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/FormatterTabPa\r
+ ge.class\r
+SHA1-Digest: pfPgh542DplUYX/61yRcP/1fmWE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/doctools/NullDocCommentViewerCo\r
+ nfiguration.class\r
+SHA1-Digest: 7A1w+AI+0DJORS737uDKpskkEhQ=\r
+\r
+Name: org/eclipse/cdt/ui/IBuildConsoleEvent.class\r
+SHA1-Digest: ZpgSwB87JuwH0CuNZqKcDpXkZXU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/Messages.properties\r
+SHA1-Digest: DPTkrNmfNGsbxU4oBIGUx4BpKcg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/IncludesSymbolsProper\r
+ tyPage$2.class\r
+SHA1-Digest: K10mX+MG9NoXN/z5vpYIGTLuc+I=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialogTa\r
+ bPage$DefaultFocusManager.class\r
+SHA1-Digest: FeBVg5s6tNiRPILOqt//pJqNR5A=\r
+\r
+Name: org/eclipse/cdt/ui/actions/BuildConfigAction.class\r
+SHA1-Digest: S6VsIrfTcB8LUO31RlyHvhDxc84=\r
+\r
+Name: icons/elcl16/th_vertical.gif\r
+SHA1-Digest: MySOSIfdRFm3SMXb/YiL2fyqrJA=\r
+\r
+Name: icons/dlcl16/metharg_obj.gif\r
+SHA1-Digest: xPwsUNmOZLXXgUNtQjaSOcESYGI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileWizardMess\r
+ ages.properties\r
+SHA1-Digest: X5tiqhmgRU5nAqtsz2pDZPZJLzM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/GlobalBuildLogPreference\r
+ Page.class\r
+SHA1-Digest: l3G9VUt0s+76np4/sqUjQJqu/jA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.properties\r
+SHA1-Digest: mdnJpeEUCf8rswc8lxuc6xHyAyo=\r
+\r
+Name: org/eclipse/cdt/ui/newui/CDTHelpContextIds.class\r
+SHA1-Digest: W9QRhnZTmJpjQk/+iwG0V9VhoOg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBloc\r
+ k$2.class\r
+SHA1-Digest: A2Uhj6e88Rbs62X69j1gR2sOGRQ=\r
+\r
+Name: icons/obj16/correction_linked_rename.gif\r
+SHA1-Digest: zeaRPYlSGIvaPTZjCREbX2fJzNw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/COperatorRule.class\r
+SHA1-Digest: iT+1YTZsuSdJ6snxbG0az3uqEy4=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/pages/NewProjectCreationPage.c\r
+ lass\r
+SHA1-Digest: 1QwEcVmIDEUaOY7oT6Z4bigL54g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEnt\r
+ ryPage$SelectPathInputDialog$1.class\r
+SHA1-Digest: nt/HcG66B03i9T23axTQsCx4HB4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/DocumentAdapter$2.class\r
+SHA1-Digest: /x3BtoPuN8L+bwQJXteBKgFMwec=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart$3.class\r
+SHA1-Digest: Mr5tTtN4HyaA7WYA4VNTDMXOMnE=\r
+\r
+Name: org/eclipse/cdt/ui/text/CSourceViewerConfiguration.class\r
+SHA1-Digest: 62+N7oenc+NyH0gPvUC4ZiRvZbI=\r
+\r
+Name: icons/obj16/asm_resource_obj.gif\r
+SHA1-Digest: 02pJoWmix9+Qy6+CFQh/hZiOdiQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/InclusionProposal\r
+ Computer$1.class\r
+SHA1-Digest: q8GP7p4c9EMHlIJbNOMK3X5t58c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/WorkspaceContentTypeMapping\r
+ Dialog$1.class\r
+SHA1-Digest: aEFnTo3A4i9zpAdl+fgMXckRhbQ=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/CacheSizeBlock$1.class\r
+SHA1-Digest: iwx2ei55IiCsQfCTHvHMhqyXOso=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THGraphEdge.class\r
+SHA1-Digest: 2H41/qsqMpXThA1D8i+mnAGvbR0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/MultipleFolderSelecti\r
+ onDialog.class\r
+SHA1-Digest: GFPTRMJ9weWYS3ZnVc+FN6Bo8WA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/Messages\r
+ .properties\r
+SHA1-Digest: +nJ3GVUkoQUISwOKaeS8+Py7NP4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/folderwizard/NewFolderWizard\r
+ Messages.class\r
+SHA1-Digest: 4//Ovcp5kCp8hm/UDlRQzlvCSdw=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractLangsListTab$8.class\r
+SHA1-Digest: 2XQXAVP8oh8kmpzpTlhkevtt7RI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/template/TemplateVariableProces\r
+ sor.class\r
+SHA1-Digest: aD0OSNdPmMR1bJFsQr+gwqY+QRk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$29.class\r
+SHA1-Digest: nexw1jFF2vdMSxKrP+6tvyGVEOs=\r
+\r
+Name: org/eclipse/cdt/ui/text/doctools/generic/GenericTagDoubleClickSt\r
+ rategy.class\r
+SHA1-Digest: c+q2ZJB3300/rpiFPY58mk7geq4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/COutlineInformationControl.clas\r
+ s\r
+SHA1-Digest: c+u+bw8YqwrB2GRcvvC8E0FZgw8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/ASTProvider$WAIT_FLAG.class\r
+SHA1-Digest: hEVZ48wkzGUG/OYvz4qX9HwznHk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messag\r
+ es.class\r
+SHA1-Digest: 4zRijHO23gggy5xBOI5zyy4JmZs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedName\r
+ sAssistProposal$2.class\r
+SHA1-Digest: Od+3pAo7lv3vKqTox6hW27HlcYE=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ImportExportWizardButtons$2.class\r
+SHA1-Digest: KQMbMRhn5CSNcMEEq97TZd9woLA=\r
+\r
+Name: dictionaries/en_GB.dictionary\r
+SHA1-Digest: Tp59l1+3Q3g3z+GvhcoUaXMSdm8=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractPropertyDialog.class\r
+SHA1-Digest: S21mJWXhmDfLia15NaSy4Tj6xvk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBloc\r
+ k$ControlData.class\r
+SHA1-Digest: YQ4ze7ExAHocXqOF7IFkkbQHarQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.c\r
+ lass\r
+SHA1-Digest: 0vs/QOwItp0BLupU8/6fDbJ5Z5k=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/indexwizards/StringVariableS\r
+ electionDialog.class\r
+SHA1-Digest: IwZZo1r1fuRJi4KCnq9P+wx8EeE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/LineComparator.class\r
+SHA1-Digest: 7WLJo04Xo4HOIgD8Vpcw0QMaZrE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/ProblemTableViewer.class\r
+SHA1-Digest: YCmWEgrvzx8h/J8hiOdGwhD3sz8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreat\r
+ ionWizardPage$StatusFocusListener.class\r
+SHA1-Digest: /Y4s2z+wBgz0qaibzzX3lz826go=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSetti\r
+ ngsWizardPage$1.class\r
+SHA1-Digest: VtgV3StEHrQQzZ+J7+KDLVvIAUo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/EclipsePreferencesAdapter$Pre\r
+ ferenceChangeListener$1.class\r
+SHA1-Digest: 1FqY+l+RdkPE9RGEVNX97az6P8I=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/SWTUtil.class\r
+SHA1-Digest: LyG8NyORfAsxAnap8hA4O1NgO9Q=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/FolderSelectionDialog\r
+ .class\r
+SHA1-Digest: obj+RDpCoJ+GqhIF7cd2G7sl4Lc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$NavigateNextSubWordAc\r
+ tion.class\r
+SHA1-Digest: EPOW456aq+kkNmQsQkminMJMvaE=\r
+\r
+Name: org/eclipse/cdt/internal/corext/fix/LinkedProposalModel$1.class\r
+SHA1-Digest: JQ4mLP5ibJstYfefVZ0qxzsoFAg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CMacroCompareViewer$Nul\r
+ lTokenComparator.class\r
+SHA1-Digest: sHajHSJsGXjQtIIfIEg/XE5Ey6Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkingSetPropertyTester\r
+ .class\r
+SHA1-Digest: Yx7Olk3hr7uhAWG/9KgR9UKpNZ8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/IncludeReferenceProxy.class\r
+SHA1-Digest: ZbvtoKzSRcKEuaklIPxpGjsoifY=\r
+\r
+Name: org/eclipse/cdt/ui/newui/BinaryParsTab$BinaryParserConfiguration\r
+ .class\r
+SHA1-Digest: kWQCBVKP3UI2xwzzefuQpxrWrWE=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ErrorParsTab$2.class\r
+SHA1-Digest: dj8x7og9cm8TfYpIYdufsoOU1xU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/NameStyleBlock.class\r
+SHA1-Digest: dZE8zKA6wUEmqrwe4/2Gb8DaYN0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/FileLanguageMappingProperty\r
+ Page$LanguageTableData.class\r
+SHA1-Digest: AjFu9stkOiFLB1WTnEEl28CBBXE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfiguratio\r
+ nBlock$CEditorTextHoverDescriptorLabelProvider.class\r
+SHA1-Digest: 6GsDtDtahhcz2Uyyhxq1C2XSkHo=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ManageConfigDialog$3.class\r
+SHA1-Digest: y0h3ooQiz6YXzpNLCqt4ZM5zTjQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$1.class\r
+SHA1-Digest: Fl/Hi3XrUMjFrsUsL5YG83ZWLHQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/TreeListDialogF\r
+ ield.class\r
+SHA1-Digest: GI636hOm5T8cyVBt+tvi0rNELMQ=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage$11.class\r
+SHA1-Digest: kCRopa5BBcVDTCjpAzLRRp/lt8k=\r
+\r
+Name: org/eclipse/cdt/ui/newui/Page_head_general.class\r
+SHA1-Digest: FEJiTfdAjQ71ByCHOgy+8+oM9KY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/ReferenceVisitor.class\r
+SHA1-Digest: INbErSmdemcoy3DigiISHtXUmAM=\r
+\r
+Name: icons/obj16/s_file_obj.gif\r
+SHA1-Digest: 5gGAZIZSu3Lm3HqGAIlgTSKBm2w=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.cl\r
+ ass\r
+SHA1-Digest: eLVAy1E7UiYioClM7Jkt0gk8A64=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/CHelpConfigurationPropertyPage$CHelpB\r
+ ookListLabelProvider.class\r
+SHA1-Digest: FffHTCnaeriSH9HH8JSt4G4VM3w=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/OccurrencesFinder.class\r
+SHA1-Digest: xyHqFGeU21E3uBqSUhaefepZnKs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathEntryMessages.cl\r
+ ass\r
+SHA1-Digest: yCZ31bPSjn0SYCbHj6kXqwtPL6U=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/AbstractBinaryParserPage$BinaryParser\r
+ PageConfiguration.class\r
+SHA1-Digest: JoUNzqH5Nni0Uu/LxERTMTut6QE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/dialogs/LabeledTextField\r
+ .class\r
+SHA1-Digest: I6gw+8ZausQtskngviprYpltmss=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/hidemethod/Messages.prop\r
+ erties\r
+SHA1-Digest: vuHmTwwZ+9VAddvZ33bgSm1ekeo=\r
+\r
+Name: org/eclipse/cdt/ui/PreferenceConstants.class\r
+SHA1-Digest: +TY5PCYUN1rhnDmqIY3Td5oD4eA=\r
+\r
+Name: org/eclipse/cdt/ui/actions/BuildActiveConfigMenuAction.class\r
+SHA1-Digest: PfIs9QEpnRj4nZcJ/UIcE7yiUqM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/PathEntryVariablesGroup$\r
+ 1.class\r
+SHA1-Digest: +SXh68NvXfu7kfY/78rMGB6ockU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkspaceSnapshot.class\r
+SHA1-Digest: fk9ku5P3m/qe81GjSuSbTs8P4sg=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ManageConfigDialog.class\r
+SHA1-Digest: H3+iGjljplvI09KLbYsSr8Tjiig=\r
+\r
+Name: org/eclipse/cdt/ui/newui/EnvironmentTab$MyListSelectionDialog$2.\r
+ class\r
+SHA1-Digest: qxe8qJU6i3qrPpbKCWFpQE1kw44=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/utils/DefinitionFinder.c\r
+ lass\r
+SHA1-Digest: D3AUc38Y97TLo+57a9NWy8Ku+Ls=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/CViewAction.class\r
+SHA1-Digest: Vv2XZtr217jV7Rd14paCwwhUjxc=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage$1.class\r
+SHA1-Digest: CSZ4XqHt/+S5+0v00FXIxWn3m0I=\r
+\r
+Name: icons/obj16/searchm_obj.gif\r
+SHA1-Digest: kCLmGfhNk3E8XFQCF5umAga+HXU=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/GNUSomBinaryParserPage.class\r
+SHA1-Digest: /qwzkU3AMVdwpZUnhH09uAxVxKI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/TranslationUni\r
+ tPreview.class\r
+SHA1-Digest: 5Q50KUS8lMTy+c9TXUy2f7Mf0yo=\r
+\r
+Name: icons/obj16/exec_dbg_obj.gif\r
+SHA1-Digest: TJN8sMb6itXfZ6dLyI4/qjDKZ34=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/AbstractPreferencePage$3\r
+ .class\r
+SHA1-Digest: MOf+B+4njfKnH2jhWzmuHuAEQ48=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSetti\r
+ ngsWizardPage.class\r
+SHA1-Digest: JAOq5AgngPafPToPOq+0mIePgRE=\r
+\r
+Name: icons/obj16/breakpoint_active.gif\r
+SHA1-Digest: qibCnXfO9or0IqDlYTyS+xDSptg=\r
+\r
+Name: icons/obj16/threads_obj_r.gif\r
+SHA1-Digest: vWmlhLgeUs+Sn8zEAROGVoA8XTQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage$F\r
+ ixCFileTypesPreferenceBlock.class\r
+SHA1-Digest: iM4c9C8o/tnoJxajRrIaXZBx6gg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/SourceAttachmentDialo\r
+ g$1.class\r
+SHA1-Digest: BDbjJeMVwNE/3qkCbMjfsoPIsTI=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/uitree/UIAttributes.class\r
+SHA1-Digest: pK93RKPyXuJXletOYVeJ5CwlT0E=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBViewPart$1$1.class\r
+SHA1-Digest: 7reg5H1kg1JfaAS8TRfK2zKqYMQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/ActionUtil.class\r
+SHA1-Digest: Py398swgSK+/s3kZzAwUGhKEeZA=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/messages.properties\r
+SHA1-Digest: J0HqHWGROmYRiLgGbZk45prMaWI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/AddDeclarationNodeToClas\r
+ sChange.class\r
+SHA1-Digest: 1xUCktjWcKgaqj2FuZ3W7INDJtg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBloc\r
+ k$1.class\r
+SHA1-Digest: e4oNLcOV+Y1B/IUr6Bei76E6vPc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/dialogs/Messages.class\r
+SHA1-Digest: ihSsy+eadLX+YbIDzUWKbmRjRJM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/CView$8.class\r
+SHA1-Digest: RfZU1VkMmQJo0rk0KOvFHFUtks0=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/NewCProjectWizardPage.class\r
+SHA1-Digest: AQXZ19k8fyHRXJW3B8rdEI9km9c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfiguratio\r
+ nBlock$4.class\r
+SHA1-Digest: HDNYdYotqNr7ztHvpFjqwXt1qhY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager$2.c\r
+ lass\r
+SHA1-Digest: V5/0/QqqwgTLs6EJSmm4FxQ8K7M=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/TranslationUnitContex\r
+ t.class\r
+SHA1-Digest: +3kNUilF5eSmU+n5Gx/nwFFATzA=\r
+\r
+Name: icons/dlcl16/public_co.gif\r
+SHA1-Digest: 0UjXk/7AurK0Ox+m9qfjDQMhs4Y=\r
+\r
+Name: org/eclipse/cdt/utils/ui/controls/FileListControl$SelectPathInpu\r
+ tDialog$1.class\r
+SHA1-Digest: pf4rxa+7gOGewtYZ974ClOtEjMA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CHeuristicScanner$CharacterMatc\r
+ h.class\r
+SHA1-Digest: AHxtHNTBdTXBIIIKWivdzQGJ+HU=\r
+\r
+Name: org/eclipse/cdt/ui/CDTUIImages.class\r
+SHA1-Digest: OTN6t+Bjtf0/0Us+wkIEJGr+YL4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/DefaultProposalFi\r
+ lter.class\r
+SHA1-Digest: wHHFX1RYjlJPy22/r5Ao/BzPKzo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/implementmethod/Implemen\r
+ tMethodRefactoringRunner.class\r
+SHA1-Digest: YABVLYt4Xb4+SsZA58OsHK5R6kM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/ComboDialogFiel\r
+ d$1.class\r
+SHA1-Digest: 5UZjHEoFmUGLel6KBaDxZqDOadA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/SpellingEngine$SpellEv\r
+ entListener.class\r
+SHA1-Digest: 27r1ylnFjyVGibXgtB4vigRZdYY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/ProblemSearchElement.class\r
+SHA1-Digest: B303uLH9EZ868nq+1rQn+BHXwIs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/GotoNextBookmarkAction$Compa\r
+ reMarker.class\r
+SHA1-Digest: at54dW7so56t3wDS76fDiW/SJ/4=\r
+\r
+Name: icons/etool16/build_configs.gif\r
+SHA1-Digest: FgSfgP7vEGZZ/a2a6BN1roPzq1g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Genera\r
+ teGettersAndSettersInputPage$7.class\r
+SHA1-Digest: Zz9oE7zMSnRwk1jB7cFVTGXOgJM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractF\r
+ unctionInformation.class\r
+SHA1-Digest: Luxko8it8CxOdTKkGHyrVzXWBtQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleDocument.cl\r
+ ass\r
+SHA1-Digest: DSQZwpNgWJBysHg0LGgqylrcHRw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistProc\r
+ essor$3.class\r
+SHA1-Digest: CJLjO13iv+uHq9RKmdly5erMG1M=\r
+\r
+Name: icons/obj16/c_resource_obj.gif\r
+SHA1-Digest: oQg58PMuhGtGKYLtjiUf0lTYLKA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/TaskTagRule$TaskTagMatcher.clas\r
+ s\r
+SHA1-Digest: osFwN/HKOfYnXHys14ZnX2fhnTo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CallsToResult.class\r
+SHA1-Digest: N8Z1RglW4n1u8tirQYucYtd+rLQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceTabP\r
+ age$CElementComponent$1.class\r
+SHA1-Digest: LW52gVkr06hZBuvGkJ4vEG9rDHs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialogTa\r
+ bPage$ComboPreference$1.class\r
+SHA1-Digest: 49RgQPtaEkMJ3Hqcx1PyLLE+SOc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/SelectionProviderMediato\r
+ r$1.class\r
+SHA1-Digest: wh3aQBcEyCCDHc5yDkztQIgajeg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/CSelectAnnotationRul\r
+ erAction.class\r
+SHA1-Digest: q0KeYMBHY4c1zWB9sjd/P4oM3Dg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/AppearancePreferencePage\r
+ $1.class\r
+SHA1-Digest: d3EXZQz0SiyHnQYWKW7qsqDsOXc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightingPresenter\r
+ .class\r
+SHA1-Digest: abZc47NwBNkayqQmhoBsSwtT93Q=\r
+\r
+Name: icons/dtool16/action-editconfig.gif\r
+SHA1-Digest: dj4LtYYqWOTaI+VQES8fHEI6cFI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/LineWrappingTa\r
+ bPage$2.class\r
+SHA1-Digest: Fs1Y42kpCz2o475KCA65G/ZKkvw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingWid\r
+ get$1.class\r
+SHA1-Digest: 3RKhelb6O9jrMGiumQHw7RckFo0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementSorter.class\r
+SHA1-Digest: DNd4ua31usTJVxzi7rTVDGQIT24=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.class\r
+SHA1-Digest: lQLIfWO4ddPGX//cAc1MRJ9y1kQ=\r
+\r
+Name: org/eclipse/cdt/ui/text/doctools/DefaultMultilineCommentAutoEdit\r
+ Strategy$1.class\r
+SHA1-Digest: Lswctlqe+56Ahla2KC0t4tVXdnM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/DeleteFileChange.class\r
+SHA1-Digest: H4jU5Hs6V0MKxP3h0TMYN4BPXD8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathOutputEntryPage.\r
+ class\r
+SHA1-Digest: a6lKqxZgpRz/lQ/73/E/kCoEegc=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/AbstractBinaryParserPage.class\r
+SHA1-Digest: SC/laadLZspShezZBVS+Toinr8k=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CHeuristicScanner$StopCondition\r
+ .class\r
+SHA1-Digest: PgUqloTLSZObeKQ8/d1In6dgCjg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/filters/FilterMessages.properties\r
+SHA1-Digest: MELDUgOttZSOExwftxpEN4YX0Xw=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractLangsListTab$1.class\r
+SHA1-Digest: gwwMEWUG8I3cDUjUNIOBUh2xi1g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditorErrorTickUpdater.class\r
+SHA1-Digest: wX0jtcl97Y+e0TeA4AQn5YiBWOw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Getter\r
+ SetterLabelProvider.class\r
+SHA1-Digest: S2JelYex8+DFBcuIX8gjg00D3UA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$22.class\r
+SHA1-Digest: cIjCsMSyn2eTwRsKeNqrT+xlQZY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/BlockCommentAction.class\r
+SHA1-Digest: M38Q7dowthJpqkAWG4QEyZvGV88=\r
+\r
+Name: org/eclipse/cdt/ui/text/c/hover/ICEditorTextHover.class\r
+SHA1-Digest: OBAJlltT2hKdRIuPVaXPrw5Dwy0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/WordQuickFixProcessor.\r
+ class\r
+SHA1-Digest: Gff3QBDphtKEdnK/+UA8c4zyGJk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRef\r
+ actoring.class\r
+SHA1-Digest: r5h6BoDghGjLqetwPQsg4UiLqhk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ProfileConfigu\r
+ rationBlock$ProfileComboController.class\r
+SHA1-Digest: 57xBIJt8kzICy6qbnf7iiGHa7wo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/indexview/IndexViewSearchQuery.class\r
+SHA1-Digest: hcnTb/h/lXCGY1QEMfhWlGYT2hY=\r
+\r
+Name: org/eclipse/cdt/ui/actions/ShowInCViewAction.class\r
+SHA1-Digest: qTurpN3aYB0groCCLIBIa6mwfcs=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/conversion/ConvertProjectWizardPage.c\r
+ lass\r
+SHA1-Digest: GL1XMkiuoJ7lnO/guyK+gCUatpw=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/CygwinPEBinaryParserPage$5.class\r
+SHA1-Digest: fb6bdYgCLNarOpm7dD2pQV8DxAs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/DialogField$1.c\r
+ lass\r
+SHA1-Digest: WRyy3BhwRREjki2DJDQbJ8HNgSE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$16.class\r
+SHA1-Digest: Ow5RqEYKIo6mNgcMvFkLkE4GMuQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.\r
+ class\r
+SHA1-Digest: m8YohmW9RDlall/4ad7kSLMD0Io=\r
+\r
+Name: org/eclipse/cdt/internal/ui/compare/AbstractMergeViewer$1.class\r
+SHA1-Digest: hQQ/hcAqgou2R05cvtEQJQKCp+g=\r
+\r
+Name: org/eclipse/cdt/ui/text/IHoverHelpInvocationContext.class\r
+SHA1-Digest: rRtfft5X+WiJCg8AYsKwN8qO9Jo=\r
+\r
+Name: icons/etool16/newmngcc_app.gif\r
+SHA1-Digest: 9fMfZW/0oFAkEsLdLitr6hquteI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/ICEditorActionDefinitionIds.c\r
+ lass\r
+SHA1-Digest: rj2sPNcL/heHmkCsB1YjxDlQ87U=\r
+\r
+Name: org/eclipse/cdt/ui/refactoring/actions/CRefactoringActionGroup.c\r
+ lass\r
+SHA1-Digest: 829123ofUmb5cx8vWV1BY5bDFgY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionInput$Ex\r
+ pansionRegionComputer.class\r
+SHA1-Digest: Uc4Gpmv35GHcyfsCfQPLz0UcyZo=\r
+\r
+Name: icons/ovr16/volatile_co.gif\r
+SHA1-Digest: AZHqhVpfH8sRdL4ew4UqLBwkz4I=\r
+\r
+Name: org/eclipse/cdt/ui/actions/ExcludeFromBuildAction$2.class\r
+SHA1-Digest: hhw52wf5LrSY2DaxNjI6VNaLxJM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SortLinesAction.class\r
+SHA1-Digest: 4GCAB4ce/2NkBTp8g4R/1HkQd+M=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/pages/UIPagesProvider.class\r
+SHA1-Digest: Gs1SoooJB21NchMX2HnsWCY47FE=\r
+\r
+Name: icons/elcl16/progress_stop.gif\r
+SHA1-Digest: kqo+0YlPPDIPH/JIX/czNHDae7Q=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/AdaptingSelectionProvide\r
+ r.class\r
+SHA1-Digest: AmXsHfZ+iw3hoW9QCYQQul2WZbY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Genera\r
+ teGettersAndSettersRefactoring.class\r
+SHA1-Digest: SFnZmuyWtueF5k5i+WgkPpn/v0Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerSelecti\r
+ onPage$CPathContainerLabelProvider.class\r
+SHA1-Digest: pTtPH1AbNGujqeAQiuKsh/yWMWo=\r
+\r
+Name: icons/dlcl16/list-moveup.gif\r
+SHA1-Digest: JSqNSncXMbSPnQwUrWcidmAMq2I=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/TaskTagRule.class\r
+SHA1-Digest: /wyXUsvViaQ429ihaHk2th4eHYk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructur\r
+ eProvider$Branch.class\r
+SHA1-Digest: 7tozFDxlG+7efYwr2h5cxETntl8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.cl\r
+ ass\r
+SHA1-Digest: ydzqGQxx2mWx4V2j55KdAN7EXbc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/utils/IdentifierResult.c\r
+ lass\r
+SHA1-Digest: Z3P13ftZq2X5sTRifuSkT0itGTc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage$Out\r
+ lineTreeViewer.class\r
+SHA1-Digest: h/+Wj+QQGpzulET6uDeD5+QpqO8=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/NewFileCreationWizard.class\r
+SHA1-Digest: 94+0CA5oe3cgP/euytpIjGX3GFI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/dialogs/NameAndVisibilit\r
+ yComposite.class\r
+SHA1-Digest: iM/wrtfHR1kz/RNEWaHCpZFhiO8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/utils/SelectionHelper.cl\r
+ ass\r
+SHA1-Digest: ZzpH7UFYkMZ4YwSsFRGK2zsPqBo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/ExclusionPatternEntry\r
+ Dialog$ExclusionPatternAdapter.class\r
+SHA1-Digest: P/tRFbyLVwbyoHs1dPFr2QeBUC0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformation\r
+ Popup$5.class\r
+SHA1-Digest: jq76Dtq/vfq22U5+qiHdf0/G2h8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/CCompletionPropos\r
+ al.class\r
+SHA1-Digest: V08VFwDl6WTLyhyYoFsUb5sirD0=\r
+\r
+Name: icons/dlcl16/collapseall.gif\r
+SHA1-Digest: X2SYkCGSP2jr+iOlYBLU19jEd4Y=\r
+\r
+Name: icons/obj16/search_decl_obj.gif\r
+SHA1-Digest: J2dt4sXGnNXc0kMOrPXUIGEl6V0=\r
+\r
+Name: org/eclipse/cdt/ui/newui/BinaryParsTab$BinaryParserPageConfigura\r
+ tion.class\r
+SHA1-Digest: 3ocx6PILgLQuy1J59rRr8whF9KI=\r
+\r
+Name: org/eclipse/cdt/ui/newui/CDTPropertyManager$DListener.class\r
+SHA1-Digest: B+sv/8VLQftHPR+nvqioyvqjIX4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactorin\r
+ gInputPage$4.class\r
+SHA1-Digest: w8W7+hYX5fubX10ZM0TJnk16w6o=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/FileTemplateContextTy\r
+ pe$CoreVariableResolver.class\r
+SHA1-Digest: S1Vcq7zMwqCfiHWFtXCrprM0PdM=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractPage$1.class\r
+SHA1-Digest: zfCgrhkBufKkC3izWrCxaB5vo3A=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/NullIndexerBlock.class\r
+SHA1-Digest: TAzW83i417IpLDRbgfv1F489gT0=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/CHelpConfigurationPropertyPage$CHelpS\r
+ ettingsDisplay$1.class\r
+SHA1-Digest: QbVP/8z3GasxQE5PiD176RmYLzk=\r
+\r
+Name: org/eclipse/cdt/ui/text/doctools/generic/AbstractGenericTagDocCo\r
+ mmentViewerConfiguration.class\r
+SHA1-Digest: OPDy5gL/Ivav/MIQLzRoE0JUpuU=\r
+\r
+Name: icons/etool16/newcc_app.gif\r
+SHA1-Digest: 9fMfZW/0oFAkEsLdLitr6hquteI=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/Template$1.class\r
+SHA1-Digest: fRFevkTJ4A78S6AIxEvpuJI0NrY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameLinkedMode$\r
+ EditorSynchronizer.class\r
+SHA1-Digest: mbFX1IdQ5QILqrzvqMUQk8mRwiQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/WorkingCopyManager.class\r
+SHA1-Digest: fI6w1hpwhKRi3tgblIbszYnHFVQ=\r
+\r
+Name: icons/obj16/debugts_obj_b.gif\r
+SHA1-Digest: 2i/Qm0bBgjmCaieV8Ua8sJ1jaNk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/CreateParserLogAction$MyVisi\r
+ tor.class\r
+SHA1-Digest: Of6FUlCQNvBuLZnX8rXu0k/HxwA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/dialogs/CreateFileChange\r
+ Preview.class\r
+SHA1-Digest: Tay+KtRjRU2/LOaX26DuNZI6A3w=\r
+\r
+Name: icons/obj16/debugt_obj_g.gif\r
+SHA1-Digest: 5MGVGYr6ljOPX4Py/0yz0GoZeDs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/MultipleFolderSelecti\r
+ onDialog$3.class\r
+SHA1-Digest: K4kPX6CYGiWEzveVpwDaRXKxfUk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/RefactoringSaveHelper$2$\r
+ 1.class\r
+SHA1-Digest: 2DOFuYu+vaJeRLRsXbBM1HyOl50=\r
+\r
+Name: org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog$TypeFilt\r
+ erMatcher.class\r
+SHA1-Digest: em+Ds95XhH6XSKQWU8R1MUsxnqw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CParameterListValidator.class\r
+SHA1-Digest: xResIiR/F4wxnwN05cAtiSIkARA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CDocumentSetupParticipant.cla\r
+ ss\r
+SHA1-Digest: 9QVqhLmadhlSxFDDJGVZWi6mv7w=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/BinaryParserBlock$2.class\r
+SHA1-Digest: +jGiUPw8++4WS3vVA14Z53J7fjg=\r
+\r
+Name: org/eclipse/cdt/ui/CUIPlugin$1.class\r
+SHA1-Digest: JU8q2T8plKGzjUshfa1I23GaLps=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/StringMatcher.class\r
+SHA1-Digest: 7rlRmEjhHKxaTmBNCgT5eUM0Z/c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfig\r
+ urationBlock$7.class\r
+SHA1-Digest: BQYKcZi1kgtS0oQwZE4oe20kNvI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/FoldingMessages.properties\r
+SHA1-Digest: 9W3GqZx7VblDW3oojZc5nEP/GTw=\r
+\r
+Name: icons/dlcl16/filterSystem.gif\r
+SHA1-Digest: 2TeGUmfDK4nHgl0G6N5v7q1gaMw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/FormatterProfi\r
+ leManager.class\r
+SHA1-Digest: 2unHzX9cWrpHcZBFkeIbozizOuM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBViewPart$8.class\r
+SHA1-Digest: /PFPc1x+H34XWdjcppTAJNgn+mA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractC\r
+ onstantRefactoringRunner.class\r
+SHA1-Digest: DrSHUBzu6X7TrW0CkTOKdQni3+U=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/BindingToAstNameMatcher.\r
+ class\r
+SHA1-Digest: rbhEvCROAHrWNxTLV9W5+A0GzfA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CodeTemplateSourceViewer\r
+ Configuration$1.class\r
+SHA1-Digest: kqMtpV03AkyUdM5YJv1F65vc0GQ=\r
+\r
+Name: icons/wizban/newclass_wiz.gif\r
+SHA1-Digest: I9RJuPd8bDGk+IFVLMq6E+B/CFk=\r
+\r
+Name: org/eclipse/cdt/utils/ui/controls/FileListControl$1.class\r
+SHA1-Digest: fUpLTb3yPZCnaMfmE3l7jFuIlRM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/implementmethod/Paramete\r
+ rNamesInputPage.class\r
+SHA1-Digest: z3SKu4LYKZw+AFApiCbDvQtpQhc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/util/CColorManager.class\r
+SHA1-Digest: RxcXoN2wbH2Kqr1smg4xeG/O25Q=\r
+\r
+Name: icons/obj16/binaries_obj.gif\r
+SHA1-Digest: kwwCiKtPIXK/C2aucoe9xo+HKFo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.class\r
+SHA1-Digest: XPjdqYU13ALSjd12aCd+oNnISvc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/LineBackgroundPainter.class\r
+SHA1-Digest: 2ShBAgC/sJPSd2N5AH/Lws8p7Ds=\r
+\r
+Name: icons/ovr16/referencedby_co.gif\r
+SHA1-Digest: H1fnemHSjaWpidP5LwYxgcPbdi4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/CView$1.class\r
+SHA1-Digest: oqNCjcSytnj6sEseF/eQFmuIt8w=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerSelecti\r
+ onPage.class\r
+SHA1-Digest: ZSEfwIceREDbb17MQiV+Gl125KE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSetti\r
+ ngsExportStrategy.class\r
+SHA1-Digest: UfFCA+xsaNXe1BEqWkC26t5m3tQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/RowLayouter.class\r
+SHA1-Digest: eAd3Ih3hy0IeW3sgsDRPDgRuTEA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBViewPart$14.class\r
+SHA1-Digest: 03jUuMGR2QxbDqwabR9Df4cSbmc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/PDOMSearchPage$2.class\r
+SHA1-Digest: EmSiR0kJTf+uHqpUGO+nhN87lTA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dnd/FileTransferDragAdapter.class\r
+SHA1-Digest: 6Tefm0Vdd2qVB9buNduZR5XK7WM=\r
+\r
+Name: icons/ovr16/c_ovr.gif\r
+SHA1-Digest: cwYeMdedOCjvwcn2UJrPFPXmYxo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/navigator/OpenCElementAction.class\r
+SHA1-Digest: gLJb4CQchNrqrZ2ojSFiqsiukkU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/AbstractInformationControl$4.cl\r
+ ass\r
+SHA1-Digest: sh0F921yDC4QaORjcXXCPpwBlAI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightings$Templat\r
+ eParameterHighlighting.class\r
+SHA1-Digest: E2TnqCdFoawuehMHJMO4UCFoEXE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/CopyBuildLogAction.clas\r
+ s\r
+SHA1-Digest: OILlif20fDKloD61wOFFlIacLiE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$IndexerPreferenceList\r
+ ener.class\r
+SHA1-Digest: 2QWTNTUnLncgAFQn4siB37QYA24=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBDragSourceListener.\r
+ class\r
+SHA1-Digest: 6r9NirYSgRNnHILU+TxN8O4vmB4=\r
+\r
+Name: org/eclipse/cdt/ui/resources/RefreshExclusionContributionManager\r
+ .class\r
+SHA1-Digest: 2up5pZIMKWmwgItmzfyG6rk1N8g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CElementHyperlinkDetector$1.c\r
+ lass\r
+SHA1-Digest: yexzKinCI7TOgIlM2pBtbqa733A=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SpecificContentAssistAction.c\r
+ lass\r
+SHA1-Digest: MXhRi/Uqmwb6VcBUzkv3y1yp9gY=\r
+\r
+Name: org/eclipse/cdt/ui/newui/StructureTreeTab$LevelDialog$1.class\r
+SHA1-Digest: wwX0X3Wc8at8+IssN3kW9tonaEM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/Ext\r
+ ractLocalVariableRefactoringDescription.class\r
+SHA1-Digest: Fm1xyFif5DDqmwJMkQ58O6/ExbI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/DeleteIProblemMarkerAction.clas\r
+ s\r
+SHA1-Digest: 374v5blKS5ZI/HiHMIULQuhIaE8=\r
+\r
+Name: icons/dlcl16/segment_edit.gif\r
+SHA1-Digest: yat2ml9OJ0TqkFQAM+BajLYuTH4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/doctools/messages.properties\r
+SHA1-Digest: 8pH4KO/oKnk2qFPy+C0nDhT2fX4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/BracesTabPage.\r
+ class\r
+SHA1-Digest: +LT4H6tJjvzwmh4C0cnjw1mmYQs=\r
+\r
+Name: org/eclipse/cdt/ui/refactoring/actions/Messages.class\r
+SHA1-Digest: jKwoFBULyw5YaMaRW/1HVcUfFPc=\r
+\r
+Name: icons/wizban/c_app_wiz.gif\r
+SHA1-Digest: cvAgQymP6RZBUrImnHl+tMH8Tzk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/TogglePresentationAction.clas\r
+ s\r
+SHA1-Digest: EwIwPkRboG/fFrOR4xq4Zmu3QSQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/ProblemAnnotationIterator.cla\r
+ ss\r
+SHA1-Digest: fFku+JSHZZIGPIZN8JAfW8M08J0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameLinkedMode$\r
+ 2.class\r
+SHA1-Digest: zswYrB7BXNxjwYs8sd/2BO5tPOk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CHeuristicScanner$NonWhitespace\r
+ .class\r
+SHA1-Digest: WS2COGWinEQ4VI6M2e4UgG/o3Yg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/SourceAttachmentBlock\r
+ $1.class\r
+SHA1-Digest: 4gbDglDePBkGJfCwlAWPNXFiUFc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionExplorat\r
+ ionControl$3.class\r
+SHA1-Digest: 9cdchrDcLAAveyySpGZdiz3nOpM=\r
+\r
+Name: org/eclipse/cdt/ui/actions/CustomFiltersActionGroup$ShowFilterDi\r
+ alogAction.class\r
+SHA1-Digest: vVMHfzx1KcpBYtmpZtkcqJRF5dc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dnd/DelegatingDropAdapter$5.class\r
+SHA1-Digest: 1A6B5WK16v4/TN1cCzU9Tg4aRn8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/CCorrectionAssistant\r
+ .class\r
+SHA1-Digest: 8m7/5eI4qBG4MGB/OAvR8PGV6cI=\r
+\r
+Name: org/eclipse/cdt/ui/newui/IncludeDialog.class\r
+SHA1-Digest: LA6RvHfxt9KxmGzfAM+T1pClxzk=\r
+\r
+Name: doxygenTags.csv\r
+SHA1-Digest: xZ93gyuhNPFiTefC7NrfTh75HLE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/ProjectContainerPage$\r
+ 2.class\r
+SHA1-Digest: MY9vufYwoALJ3G3B+Vu3zPaq+c0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractF\r
+ unctionRefactoringWizard.class\r
+SHA1-Digest: jRHOrXHmlUwhuMeoiI2ktVnXBMc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/CViewMoveAction.class\r
+SHA1-Digest: iunL7QWmPi5DWYWk6uewJLFJARs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightings$LocalVa\r
+ riableDeclarationHighlighting.class\r
+SHA1-Digest: Ow0/R21q75EEGlvRaZGB2YlUaKI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/compare/CStructureCreatorVisitor.cla\r
+ ss\r
+SHA1-Digest: LO6WlMhRF/nM4rK4Xi3uzYyC9Sw=\r
+\r
+Name: icons/obj16/variable_local_obj.gif\r
+SHA1-Digest: o65EsJ8m+1pZjUsR7UMxV9VGRU8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/AbstractCompareViewerInformatio\r
+ nControl$1$1.class\r
+SHA1-Digest: zvyQAeg7t6RMlwEOeY+PAzap+6Q=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CodeTemplateBlock.class\r
+SHA1-Digest: cj+zjErYf1wId6ZC5JtXbCMiVmA=\r
+\r
+Name: icons/etool16/newcprj_wiz.gif\r
+SHA1-Digest: zBA8aUd8p64ugjy7PCco3VxHi6Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/TemplateCompletio\r
+ nProposalComputer.class\r
+SHA1-Digest: fdyxhExg34oueDmbPw7/doZ+fAk=\r
+\r
+Name: icons/obj16/export_settings_wiz.gif\r
+SHA1-Digest: dZwkswxs4H2FOfiwtyBISYM0vx8=\r
+\r
+Name: org/eclipse/cdt/ui/actions/DeleteResConfigsAction$2.class\r
+SHA1-Digest: e8ZkzpaojuJXMhz8ybdKk+wXdLY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlighting.class\r
+SHA1-Digest: AMiv1dJx29cFDhz4vplqais4jnU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/implementmethod/Paramete\r
+ rInfo.class\r
+SHA1-Digest: +NCkDYLbXcwdn9sOBadqDimXfkk=\r
+\r
+Name: META-INF/maven/org.eclipse.cdt/org.eclipse.cdt.ui/pom.xml\r
+SHA1-Digest: F7LDWGm9pzjwKVNuvkoWosgvXrM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBloc\r
+ k.class\r
+SHA1-Digest: wErbSJ5ThUuSPsbcAaoDoyNy0O8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/resources/ResourceExclusionContribut\r
+ or$2.class\r
+SHA1-Digest: T4A0sR6q3ZSLJ5GllO5X0blqEmY=\r
+\r
+Name: icons/dtool16/newcc_lib.gif\r
+SHA1-Digest: LALaz7wN6Sx5/dfAVEbm+pfEhwE=\r
+\r
+Name: icons/obj16/person-me.gif\r
+SHA1-Digest: 9lW6O94X0+FVuXaig24Tj28MeFA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$3.class\r
+SHA1-Digest: NnDaU5aVa6RWjkWFOMMc8D++0J8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/TypedViewerFilter.class\r
+SHA1-Digest: uATu8VHyzlRA8RNBYbFVDZF/U/o=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/HTMLAnnotationHover.class\r
+SHA1-Digest: +5mE/xOB9MD1+NRLLypTtV+pikE=\r
+\r
+Name: org/eclipse/cdt/ui/newui/EnvironmentTab$5.class\r
+SHA1-Digest: B8pZ0O646lpwpT0Z7GiHyPJBvnQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionInformat\r
+ ionProvider$1.class\r
+SHA1-Digest: 0RbmhQak3XC8Llzx4h/vkR4VIyE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CDocumentProvider$Translation\r
+ UnitInfo.class\r
+SHA1-Digest: TVleWDNxHYj2p/1SumcSjbysdjo=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/processes/Messages.class\r
+SHA1-Digest: e8ZF4S27CBL4lIcM+RK1j8lFQ4g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/CUIHelp$CUIHelpContextProvider.\r
+ class\r
+SHA1-Digest: PhkdkjlA2X5YbN8NI87aA5TBfIg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/ProjectContentTypeMappingDi\r
+ alog$1.class\r
+SHA1-Digest: p8+uV0tpj5KV/uN/wCvhvFxebgI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformation\r
+ Popup$7$3.class\r
+SHA1-Digest: 9cYtR5qCkF0otOw2GdTkXXR6jAo=\r
+\r
+Name: icons/obj16/import_settings_wiz.gif\r
+SHA1-Digest: Hbio4y0fAyN2KxdgUQ5U157fFZ4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigura\r
+ tionBlock$10.class\r
+SHA1-Digest: W3X5v3uGsXUHZOfys2To5VegBAA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage$2.c\r
+ lass\r
+SHA1-Digest: BSHowgMVZj38QCCwvggSEU7j/wM=\r
+\r
+Name: org/eclipse/cdt/ui/newui/INewCfgDialog.class\r
+SHA1-Digest: 4V3LVkJCC9djada4z5pPH2SGAKk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfig\r
+ urationBlock$DefaultTableLabelProvider.class\r
+SHA1-Digest: KB3Gea+VSn5GmgJTqkIhTk0kgaw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/RefactoringSaveHelper$3.\r
+ class\r
+SHA1-Digest: 8ZHLSjcqS/3qHpWQeGTTuaHbnxo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/navigator/CNavigatorEditActionProvid\r
+ er.class\r
+SHA1-Digest: EwWzlpQ06ZaF3T7tVh1rl5LaGvU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage$3.clas\r
+ s\r
+SHA1-Digest: Np26ZljrIE3KbuWN9dzzSxJKQYg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ProfileConfigu\r
+ rationBlock$1.class\r
+SHA1-Digest: uCzvn2+rL1VRnsb34w8OHj0kYYE=\r
+\r
+Name: org/eclipse/cdt/ui/newui/StructureTreeTab$2.class\r
+SHA1-Digest: KrgHJDQhrmEydfqt2c5n2hFFyRw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/RemoteTreeContentManager$FetchJ\r
+ ob.class\r
+SHA1-Digest: PoF/342q7EbiOz9j7WhUszwfU40=\r
+\r
+Name: org/eclipse/cdt/utils/ui/controls/RadioButtonsArea.class\r
+SHA1-Digest: Qed5blJs+iAuz5aITzDRXHZ90bs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog$5.cla\r
+ ss\r
+SHA1-Digest: UiiCBSCY8zF0pNwldRsWzetc74Q=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/PreferencesAccess$Workin\r
+ gCopyPreferencesAccess.class\r
+SHA1-Digest: 3Nha4z8WZ6ntUuteOx/tGTEmaoE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CStorageDocumentProvider.clas\r
+ s\r
+SHA1-Digest: IbtupZeAnbC7DHIIiln0yu43ifo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialogTa\r
+ bPage$CheckboxPreference.class\r
+SHA1-Digest: oGc2CRZa5/doWYEby8i949bKA6o=\r
+\r
+Name: icons/etool16/config-debug.gif\r
+SHA1-Digest: pVqVoF0l24jlU6aYjnD+CWfLlv8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/dialogs/ValidatingLabele\r
+ dTextField.class\r
+SHA1-Digest: nKC/T7bkoyMVHDt6uXkB4Im2vwM=\r
+\r
+Name: icons/obj16/opentype.gif\r
+SHA1-Digest: O7G7OSILCoRg3tcbiBJVqRVJrrE=\r
+\r
+Name: icons/view16/cprojects.gif\r
+SHA1-Digest: fBE+TI97eQ6EguYYoEaRXCgjCuc=\r
+\r
+Name: icons/wizban/newfile_wiz.gif\r
+SHA1-Digest: Y+EK147QIsFBIC0TWlrh0ci+0q4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/NewBaseClassSele\r
+ ctionDialog$ITypeSelectionListener.class\r
+SHA1-Digest: QgbFpz7SXJuk0PpNBo0p4mJTnTE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandIns\r
+ taller.class\r
+SHA1-Digest: cX3KFWw2Bcx4cPIknH1LBnEmCRs=\r
+\r
+Name: org/eclipse/cdt/ui/newui/MultiLineTextFieldEditor$3.class\r
+SHA1-Digest: JuT9bVvTmRhkLRGLLDwuFsgwN5Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/MemberFilterAction.class\r
+SHA1-Digest: YwgTVD4yGLJHHKYufN9QrOtMz8M=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/CDTCommonProjectWizard$1.class\r
+SHA1-Digest: qdcK9C2T2qTZ0jDWKWFPa+RUCuA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlo\r
+ ck.class\r
+SHA1-Digest: iM4eSfz0Lh9RRK4LB54FsRkDgOM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/SmartTypingConfiguration\r
+ Block.class\r
+SHA1-Digest: Rz4V3OTmoNzwdv788BpJgFSRXQk=\r
+\r
+Name: org/eclipse/cdt/ui/text/CSourceViewerConfiguration$2.class\r
+SHA1-Digest: HOu8Hb8Sr+sni+/pSTi9Q7TnE38=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/uitree/UIElement.class\r
+SHA1-Digest: /T48Gbna2aHFV96n+u2KV6wrmkU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialogTa\r
+ bPage$ComboPreference.class\r
+SHA1-Digest: uFX8n+j2joI0Ydd9J7JVafJ+W3A=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceTabP\r
+ age$CElementComponent.class\r
+SHA1-Digest: zmpLLbxwyfXOCkWWedUwaqKDCjo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightings$LabelHi\r
+ ghlighting.class\r
+SHA1-Digest: I7p+OqwOVTbn93hy+ZND1ADLVic=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/SelectionProviderMediato\r
+ r.class\r
+SHA1-Digest: 13XkOvXoL8EYJHYH7cNzqfifwiE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementAttribute.cl\r
+ ass\r
+SHA1-Digest: sPWKZfPn1O/Tf1u4XCnfHG6bGUM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/SelectionListenerWithAST\r
+ Manager$PartListenerGroup$1.class\r
+SHA1-Digest: gCqy6wBEEANnq45mWm5P5hyUaZU=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractCPropertyTab$4.class\r
+SHA1-Digest: SmPg78YZ627pr0P0FG+ZPiQ3ta0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/OpenIncludeAction$2.class\r
+SHA1-Digest: L6Bsq2svwQms+gvknyIH0HNgGvY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProxy.class\r
+SHA1-Digest: RDPArg3J+9rVr004+gfTVsvRNbw=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/BinaryParserBlock.class\r
+SHA1-Digest: K7HwRgjdkmhDn+SZ3CaoGsk5CXg=\r
+\r
+Name: icons/obj16/template_obj.gif\r
+SHA1-Digest: JVU1OAKYzH1IcISspuuGcMhTPcQ=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/CodeTemplateContextTy\r
+ pe.class\r
+SHA1-Digest: 4rUKUc6zev/AHVMVOgVsQuZf+r8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/ISelectionValidator.class\r
+SHA1-Digest: ICcHnY/R1yBIzmrnhHMLY3pKsTo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBViewPart$1.class\r
+SHA1-Digest: +v21gJi/mqSo6c8RIGDul4KAbCk=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/pages/messages.properties\r
+SHA1-Digest: L5TpNc1qqfPthWDYs4YhWdNA364=\r
+\r
+Name: org/eclipse/cdt/ui/IWorkingCopyManagerExtension.class\r
+SHA1-Digest: c8/Qajn2YML0JAtCxwk6ZW8LAKA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CHeuristicScanner$NonJavaIdenti\r
+ fierPartDefaultPartition.class\r
+SHA1-Digest: anvAFpMcmIYH8R6v7VAAMDTUx+E=\r
+\r
+Name: org/eclipse/cdt/utils/ui/controls/FileListControl$SelectPathInpu\r
+ tDialog$1$1.class\r
+SHA1-Digest: VugXQtT7bRxa4cZuusY1NK7Q5X0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEnt\r
+ ryPage.class\r
+SHA1-Digest: 41mJOnSfMu3bjnMlnFD1aGXVbXE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/PathEntryVariablesGroup.\r
+ class\r
+SHA1-Digest: nPt+OlqGVsOPKHlHFLgdQbPO/z8=\r
+\r
+Name: org/eclipse/cdt/ui/newui/BinaryParsTab$2.class\r
+SHA1-Digest: Q2DD4jthmBG0R5cNNWZeYSi8GzI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/Visibility$4.class\r
+SHA1-Digest: gQb/6k+BSPoWcjXaXaudZhnrD0o=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/ImageImageDescriptor.cla\r
+ ss\r
+SHA1-Digest: DXqnzZ47l9eC/ojqrmK5tEJGjN0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/navigator/CNavigatorDropAdapterAssis\r
+ tant$3.class\r
+SHA1-Digest: iVo3losx0TcsXdsNN/zMst0lSzE=\r
+\r
+Name: org/eclipse/cdt/ui/CodeGeneration.class\r
+SHA1-Digest: E/gbbpLT2mg43kh5wghzwQz00YQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProce\r
+ ssor.class\r
+SHA1-Digest: /l4Z308Yqh41z8MuTOwYttZ2YFY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/CViewActionGroup.class\r
+SHA1-Digest: Hx7Dbgrb3UAgMiswZdA27QRzfqM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialog$2\r
+ .class\r
+SHA1-Digest: pDyRTUG6c/61baXMhVO+4nFLohM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/ReturnSt\r
+ atementFinder.class\r
+SHA1-Digest: kbO1m3187jPmzG66+S9lpd357AU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/FormatterProfi\r
+ leStore.class\r
+SHA1-Digest: v2U+CKj0RlMq2eqoBApCyqKyhNc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconcile\r
+ r$1.class\r
+SHA1-Digest: 28i6FeWqSgToi5AsQv5xoyBjgWk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/asm/AsmPartitionScanner.class\r
+SHA1-Digest: ZQkMXCgHoLbJA7xUkdgPE3tqmE4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/WorkspaceContentTypeMapping\r
+ Dialog.class\r
+SHA1-Digest: nGO3fQ4F6G5NEci47dXLKBBhcmA=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UISpecialList\r
+ Widget.class\r
+SHA1-Digest: qcsMYYIcpAtp761CWZ8Ub/hVu4w=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistHand\r
+ ler.class\r
+SHA1-Digest: JeJHGtH6aJoIB9sHe3ZuB+/5FxY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/CodeFormatterC\r
+ onfigurationBlock$PreviewController.class\r
+SHA1-Digest: 24XPw7NWcvEYFSBsqfeZDSysF/s=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage$Mac\r
+ roGroupingAction.class\r
+SHA1-Digest: xjJJ3p9+MAS3vM2tOQFsIC1wEGs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart$9.class\r
+SHA1-Digest: DCDU0qpSgGNHD3Wz1uevr5j4BKs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/filters/ObjectFilter.class\r
+SHA1-Digest: zmaj+3/Ek+26kl0rM6k1zsHRHzE=\r
+\r
+Name: icons/dlcl16/open_incl.gif\r
+SHA1-Digest: G/EzdXVxHf2ec2uA1BzhYMbbGEo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePagePartici\r
+ pant.class\r
+SHA1-Digest: COt4x9Qh+THHjvWpkMrVJNJxwmA=\r
+\r
+Name: org/eclipse/cdt/internal/corext/codemanipulation/AddIncludesOper\r
+ ation.class\r
+SHA1-Digest: Gp0XdFkR7mOoGYU5Jv1NMYn3IL4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/LineSearchElement.class\r
+SHA1-Digest: 7d42sFlmG8d0tpR6mk3we0WRhO8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/CCorrectionAssistant\r
+ $2.class\r
+SHA1-Digest: mnANu8Jph3RBCv7N4OimI/h79Js=\r
+\r
+Name: icons/elcl16/configure_annotations.gif\r
+SHA1-Digest: jNlhj2RFBlGj5MHqF1f5SOQbx0s=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigura\r
+ tionBlock$HighlightingColorListItem.class\r
+SHA1-Digest: niUZJDRkohyaxWLhsq+2NNuNKRU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/StructureSelectionAction.cla\r
+ ss\r
+SHA1-Digest: KZZBHCFSK/+TIomnyiUb+Ew5bIA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetUpdate\r
+ r.class\r
+SHA1-Digest: os2HlmOHnNzwgRNFdHxI6u5xJBE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage$Inc\r
+ ludeGroupingAction.class\r
+SHA1-Digest: 5JWHaIa3sIZvri6OQ5c4V9mBVHY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/GlobalBuildLogPreference\r
+ Page$FilePathEditor.class\r
+SHA1-Digest: HHMFBhyLvoHnFoO5TwGOnq9D6Uk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/navigator/CNavigatorLabelProvider.cl\r
+ ass\r
+SHA1-Digest: WL/E+k7xuGiZIUIZaD3sUc76KIs=\r
+\r
+Name: org/eclipse/cdt/internal/corext/util/CodeFormatterUtil.class\r
+SHA1-Digest: FPFtWDUKehAPHDI4+JN/PyTwTA4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigura\r
+ tionBlock$6.class\r
+SHA1-Digest: 4tDxmbfy6PCKw07kUpzGgJEPXAg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/filters/SharedFilter.class\r
+SHA1-Digest: nmBF5BE15wOnSCbo74ZsUYcY1yU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/Mes\r
+ sages.properties\r
+SHA1-Digest: UXSjhW+9/4yYLrjGrNmf+Ph9zqA=\r
+\r
+Name: icons/obj16/union_obj.gif\r
+SHA1-Digest: dtg21VYXI+D2xFxgaQcFnT1AjkI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/ViewerPane.class\r
+SHA1-Digest: 6HPbes6ARPLqyUlgohjCqXuLUB0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUt\r
+ il.class\r
+SHA1-Digest: 1EslSyzrDqmjk+cV9/g84ZpEdyI=\r
+\r
+Name: icons/dlcl16/configure_annotations.gif\r
+SHA1-Digest: jB2b2qhh1meTSde1O/MFBzI3E9A=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/conversion/ConvertProjectWizardPage$5\r
+ .class\r
+SHA1-Digest: Qytpjuggt+lH3+2j0azJLqUmcys=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightingPresenter\r
+ $HighlightingPositionUpdater.class\r
+SHA1-Digest: sv5Xh0DbiEiTu6kukeoBBTfNtvY=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/NewCProjectWizard$1.class\r
+SHA1-Digest: 82f6Q3MlGYZfiIQPtxbY3togEJ0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/AbstractMethodSt\r
+ ub.class\r
+SHA1-Digest: 4QoCRyuUDOirZBn0Ntgb6KVpnCU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery$\r
+ 1.class\r
+SHA1-Digest: XadHLfmIWHTfo/XjUCDZO02RTbA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSetti\r
+ ngsWizardPage$7.class\r
+SHA1-Digest: 26M6V0ttQs8eCr8i/7uIFm4AzTY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/TypeHierarchyUI.class\r
+SHA1-Digest: WoWY7k0QGMWXKssDfOo8GKvHZSU=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/TemplateListSelectionPage$2.cl\r
+ ass\r
+SHA1-Digest: pd6Ju9xQrX2GTsPHRyDKpBgN61Y=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ManageConfigRunner$1.class\r
+SHA1-Digest: XOIPRp4FTEfQ44ceMYf1yrhJprw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/filters/CustomFiltersDialog$1.class\r
+SHA1-Digest: fLBdHxiSCNQAkVGtal3gdl3xGpU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/DeferredCWorkbenchAdapter.class\r
+SHA1-Digest: J3L476z7bWRqqZq7V9Y3u90HhXA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsProje\r
+ ctAction.class\r
+SHA1-Digest: joEBFCOU6gFaDgKMch/eSnbzS8s=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/asm/AsmTextTools$1.class\r
+SHA1-Digest: UVdwhT9EfsgB7zTLtx71WoEuL/c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBloc\r
+ k$Key.class\r
+SHA1-Digest: jwo4MRp7KnCkZP6pI3EsomqJTD8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButton\r
+ DialogField.class\r
+SHA1-Digest: fw8P6mSRUgjKDBaXlZEvv3bgGdA=\r
+\r
+Name: icons/obj16/hfolder_prj.gif\r
+SHA1-Digest: QQq1l/dy/nAW0JVMDwEXdnD8xGA=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ExPatternEntryDialog.class\r
+SHA1-Digest: BdqcMdYTzSidVJiEMKF7Rssn95Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/FastCPartitionScanner$RawString\r
+ State.class\r
+SHA1-Digest: 7PQ8tE1f0JdMtmcirsnhBA3tYw0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$7.class\r
+SHA1-Digest: 0HoPUlEIbBC308J9mIEBpexb4RA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/SequenceCharacterIterator.class\r
+SHA1-Digest: gXDjiWzA2CLmV0TEDBy/cW7dIjI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/ICommandAccess.class\r
+SHA1-Digest: D2+A75dJx9wsugAzskCPEqDxpS8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructur\r
+ eProvider$SelectionListener.class\r
+SHA1-Digest: gX4pjb0c5Q1DPf71QY+mPfVAW7U=\r
+\r
+Name: org/eclipse/cdt/ui/newui/BinaryParsTab.class\r
+SHA1-Digest: xYP+3RX/4sxbRU0ybBs/wHOpOVY=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/TranslationUnitContex\r
+ tType$File.class\r
+SHA1-Digest: veb5bYML+BVYU/t52jMRi9N62ro=\r
+\r
+Name: icons/elcl16/sub_co.gif\r
+SHA1-Digest: XdG83SRnG0jRnhxPhj97CRyo2rs=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractExportTab$RichLabelProvider.cla\r
+ ss\r
+SHA1-Digest: FVEa1+LtQkTHtTaamuVT9qHVBTI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.class\r
+SHA1-Digest: a5Ov2KkHzXvam4U4K73n8GQhuZ8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/BuildConsolePreferencePa\r
+ ge.class\r
+SHA1-Digest: uRlIsQmJfVvJlkXpQ7LEIAo2umY=\r
+\r
+Name: org/eclipse/cdt/ui/newui/EnvironmentTab$TabData.class\r
+SHA1-Digest: EFWzYBu9I2dkoX+nCWTWN3uUOYs=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractCPropertyTab.class\r
+SHA1-Digest: bXcB5udQYy5mkS8EsKtwtH+QwSk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/folderwizard/NewFolderWizard\r
+ Messages.properties\r
+SHA1-Digest: oZ5Zzjo+f10w1BqzsaxMn1OXAxQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/RelevanceConstant\r
+ s.class\r
+SHA1-Digest: 8GJYPuEpwoIAQ4EB7EkRMl8WHzY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesCache$3.clas\r
+ s\r
+SHA1-Digest: AKPlFZlhDdb7tV4TUTeB56shSzM=\r
+\r
+Name: icons/dtool16/newsrcfldr_wiz.gif\r
+SHA1-Digest: u4pH7HPN0sSLsFsxn8GGmA9CBbU=\r
+\r
+Name: icons/dlcl16/definingtype_sort_co.gif\r
+SHA1-Digest: F+/JgwRCbeSXYTf82kYYEGQfvRY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/ConsoleEvent.class\r
+SHA1-Digest: GYfCmTikBTxp8bReSbzrPWtCl1w=\r
+\r
+Name: icons/elcl16/templateprop_co.gif\r
+SHA1-Digest: GT44qN4ou5RBseN8n9r9fdc/ucU=\r
+\r
+Name: org/eclipse/cdt/ui/newui/SymbolTab.class\r
+SHA1-Digest: U2LJzfZqGlfXNcG0ZP2/yWvmAPg=\r
+\r
+Name: icons/ovr16/read.gif\r
+SHA1-Digest: mbvd++7VAvYESU2IKFA5OI82iZI=\r
+\r
+Name: icons/obj16/thread_obj_g.gif\r
+SHA1-Digest: K4ETdB48hea9v22klunAf25dRQk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementFilter.class\r
+SHA1-Digest: isOVgKsqpf3vNwd1p6XORX1xzcA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGene\r
+ rator.class\r
+SHA1-Digest: IjudmPKkqGj0DqX9hDGaqOsl/Jg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/SourceFileSelect\r
+ ionDialog$FieldsAdapter.class\r
+SHA1-Digest: 4VqUBL8vAFAMh3LBFKtgZQuw4EE=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage$7.class\r
+SHA1-Digest: 97fc0WGmK5+5j/uFWDnaZdYDdeA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/IndentationTab\r
+ Page.class\r
+SHA1-Digest: yBfEjtxdrnUwTWCW4WpEmRaWfKw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CustomBufferFactory.class\r
+SHA1-Digest: 8lsozaMxSqZg7xXxJAa/GkcThRA=\r
+\r
+Name: icons/etool16/convert-normal.gif\r
+SHA1-Digest: LAtJtd2jEyNgYJDKHZMQOc1s4sE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/BuildGroup.class\r
+SHA1-Digest: mrrGkxTJXaOl6MADxj8JMnbXoDs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Genera\r
+ teGettersAndSettersRefactoringRunner.class\r
+SHA1-Digest: scdXVdkpVrN9xg2hzfzfBLNZNiE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/asm/AsmTextEditor.class\r
+SHA1-Digest: gjxA99bS9e4vJj+mOA0Zfm/zO2I=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ProjectContentsArea.class\r
+SHA1-Digest: 4/+Xsh+8nGz0hpRhD1dP0bEi0Ck=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/BuildLogPreferencePage$2\r
+ .class\r
+SHA1-Digest: UXciCONf/F+Qs2sxjs6p7nyIJhI=\r
+\r
+Name: icons/obj16/var_declaration_obj.gif\r
+SHA1-Digest: DLysfuA0RGRkFunKDlrIdBf6RAU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/ProjectContainerPage.\r
+ class\r
+SHA1-Digest: Bba7PlctZVVfg2lTokznzMXxubg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditorActionContributor.clas\r
+ s\r
+SHA1-Digest: 6bi/TB4iCTdBS4n8+1WjEGpN4Vw=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/IWizardDataPage.class\r
+SHA1-Digest: WyXqVCwfPgkAQ4ry5F98MMoB3nc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/help/CHelpBook$HRDescriptor.class\r
+SHA1-Digest: NmV5oXzcahwyx5RHNHrfR2ILMtE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/LinkedProposalModelPrese\r
+ nter.class\r
+SHA1-Digest: Spb9u/prnggpez1RHpcc6ezEKts=\r
+\r
+Name: org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDia\r
+ log$UpdateElementsJob$1.class\r
+SHA1-Digest: CG/DANbKgKVKRO0ABOh4Bn7QMtM=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ExpDialog$1.class\r
+SHA1-Digest: gehT8kf+uwn3eHnlyxfBjJSI/UY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction$Hi\r
+ storyListDialog$1.class\r
+SHA1-Digest: yn2zuAnEN1e94cbIZKvLl478sAM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/utils/DeclarationFinder.\r
+ class\r
+SHA1-Digest: A55gFpCczjX/NeGCkPA1ZVccfV4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightings$MacroDe\r
+ finitionHighlighting.class\r
+SHA1-Digest: s+Fp8eP3Uma/ab2hnddFZ3K/yEE=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/ReferenceBlock$1.class\r
+SHA1-Digest: cmTzxQjmVy9aOsTMImp/OLIxg5M=\r
+\r
+Name: icons/obj16/debugt_obj_r.gif\r
+SHA1-Digest: j2Up9giq64vm6bFlqnoWpxCdb0Y=\r
+\r
+Name: icons/obj16/using_obj.gif\r
+SHA1-Digest: Hpm9a9839SptnnD22swzIgwecGc=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/NewFolderCreationWizard.class\r
+SHA1-Digest: V3lLzRTbOrd9v9i/YtnsvB2wzxs=\r
+\r
+Name: ChangeLog-browser\r
+SHA1-Digest: lg+m8Dt+/1ENU5ulvS8KR+Czl8E=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/ITemplatesListProvider.class\r
+SHA1-Digest: mPN6bm0PjpHUyaDN0Q5xma5lEPg=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/IndexerOptionPropertyPage.class\r
+SHA1-Digest: MeyK6ZQSqJPyKBDuBYN06cKJGBI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dnd/CDTViewerDropAdapter.class\r
+SHA1-Digest: xdqRq+RHaXTzEpuRkWiWtC9YVQg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistInv\r
+ ocationContext.class\r
+SHA1-Digest: dXntazwhh/qtZ8qFuRVvJED4jUU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/asm/AsmWordDetector.class\r
+SHA1-Digest: qk89Nj0+rs5d0RDUTkuAbleyEgU=\r
+\r
+Name: icons/dtool16/newfile_wiz.gif\r
+SHA1-Digest: 9ixBtnbY13mc3hGreFilf3IvOVw=\r
+\r
+Name: icons/elcl16/helpprop_co.gif\r
+SHA1-Digest: nkL22+4kbPDTI1ASDZhct7YaLXQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkingSetProjectConfigu\r
+ ration.class\r
+SHA1-Digest: 7L70ABPvt6jQl1BrKCEqUbeZzas=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/BuildJob.class\r
+SHA1-Digest: 9XIkM/1HU0Wba/zHhqVsLrl6Ri8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellCheckIter\r
+ ator.class\r
+SHA1-Digest: JJRHe2Gy2qD4dMJMUqKnzKZJ9KA=\r
+\r
+Name: icons/obj16/toolbar_pinned_g.gif\r
+SHA1-Digest: 7+thrjLbiWkwjArhPJ0kvd2CLuA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart$14.class\r
+SHA1-Digest: 7Tx86OCwyen7kpagKyL0bsxjvfI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/DocumentAdapter$Document\r
+ SetCommand.class\r
+SHA1-Digest: mIaYOa8VAz5MOgrbOC0WRUNL8pI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/EditorOpener.class\r
+SHA1-Digest: LgGq5bgGjrpFQxtoayROlHgHIiM=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/TranslationUnitContex\r
+ tType$ReturnType.class\r
+SHA1-Digest: l9tTPIkudv4Ra+QTWi/VHnMH6tg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ProfileManager\r
+ $KeySet.class\r
+SHA1-Digest: AoP853v3lbU3M7YI8fvCz0KpwRc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractF\r
+ unctionRefactoring$3.class\r
+SHA1-Digest: WbMNd7wyhSMZSUalWXOd5NXZZrE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/folding/FoldingMessages.class\r
+SHA1-Digest: InY0RQMB1w5pEcMaLwRz8jgzO/A=\r
+\r
+Name: about_files/ispell-license.txt\r
+SHA1-Digest: /ERZtcjGBTJ3j+68qSBm67kf+80=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/CoreUtility.class\r
+SHA1-Digest: pMj1tZOZ/b21FWjerae+umLPYj4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/IncludesSymbolsProper\r
+ tyPage$1.class\r
+SHA1-Digest: TDJ9XEyk9vmMdWUDhXBL51PaELw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/SimilarF\r
+ inderVisitor.class\r
+SHA1-Digest: 4FYUdaJO6w0fbpN18BRbNWNULLQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/CProposalContextI\r
+ nformation.class\r
+SHA1-Digest: 6VGmNVBCS+kI3YM8aFb9LHvxCSk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CFileTypeDialog$1.class\r
+SHA1-Digest: Chj9H+W8rmfzxP5Pnlxc1kWFZy4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/NameStylePreferencePage.\r
+ class\r
+SHA1-Digest: 7amKEjgg6ji2AbSN7Wx9r+qMnfw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/GotoActionGroup.class\r
+SHA1-Digest: bMVENS8SPNPru/7TJSL17ZWvmhw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/indexview/FindReferencesAction.class\r
+SHA1-Digest: xo8odC68bAOo3SFpMjdku+K/qNU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructur\r
+ eProvider$CElementPosition.class\r
+SHA1-Digest: kpaub5JGMQsiJOdimwvG4u1fWn0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetUpdate\r
+ r$WorkingSetCheck.class\r
+SHA1-Digest: 6WkSOwj+J0o12mahZDYQTNPf5fc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorD\r
+ elegate$1.class\r
+SHA1-Digest: HbGatoHdBPk9O+JpQU8kQTiZ88s=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CInformationProvider$Co\r
+ ntrolCreator.class\r
+SHA1-Digest: 5zg07JPl0O6NbSVIJ5/NYGfCmGI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ProfileManager\r
+ $BuiltInProfile.class\r
+SHA1-Digest: RuMhPxa2c2g/L891EB7FzteunPo=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/NewCProjectWizardOptionPage.class\r
+SHA1-Digest: 2gd29VcCgFRSQJMOTqC3G8AyUwU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBloc\r
+ k$1.class\r
+SHA1-Digest: J38QIhJMZ6Tf3kPBhApADBm0Ei8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CAnnotationIterator.class\r
+SHA1-Digest: XBzd6F9v+jKnKiBkjcQU+us0g5c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/DocumentAdapter$1.class\r
+SHA1-Digest: AK5s9pXQXeEP95UpcwIQPFpNuEM=\r
+\r
+Name: templates/default-filetemplates.xml\r
+SHA1-Digest: vhoA8XmsuIbN1vr4NAgofNm24nc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart$2.class\r
+SHA1-Digest: Z0+Aox88zZvs4PNDlXk2nuRvazE=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/AbstractGNUBinaryParserPage$4.class\r
+SHA1-Digest: llPIAoNzoQRni/xvNA+s3hlHsO0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesLabelProvide\r
+ r.class\r
+SHA1-Digest: UvrxePm6/g+ZtENMUbjYew1SuwE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/HTMLPrinter.class\r
+SHA1-Digest: kIKi7fdq6Vpbh8t6JionJleGONA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CSourceViewer.class\r
+SHA1-Digest: F56a30q9BZFdsfa6RhAPwuQqfxc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/MacroSetting\r
+ sProcessor.class\r
+SHA1-Digest: +iJioFu9m8Pl8fUsDBhQT9fpqdk=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractLangsListTab$7.class\r
+SHA1-Digest: xRGZsM/RCuNJkNx6TEzgcyCAM1I=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/ContributedProcessor\r
+ Descriptor.class\r
+SHA1-Digest: KpUudpL3ZhhVtKje6ovNenPzYhY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfiguratio\r
+ nBlock.class\r
+SHA1-Digest: nJu+6LMMW/Pci2YQMKzjMwn8+jE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$28.class\r
+SHA1-Digest: g78P82BTAmAHxoFIk589l8EAJsQ=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/WizardNode.class\r
+SHA1-Digest: mhOUauftkguGhL4GlQbYhvYU5hQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.class\r
+SHA1-Digest: zOlMwu5Fg3E6jcQghuTNCoT1txQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetPage.c\r
+ lass\r
+SHA1-Digest: xkkfQSzPgFW6cjCWyDRtvX1jqr0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/StringDialogFie\r
+ ld$1.class\r
+SHA1-Digest: 9fFFFEZYlBEPCCzv24/IZ7BdAoY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedName\r
+ sAssistProposal$1.class\r
+SHA1-Digest: jlkWq8fZLaYqZNkDY840aGyVeT0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractC\r
+ onstantInfo.class\r
+SHA1-Digest: XYhilyBtqRavkyHuhZsDl4afNjw=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ImportExportWizardButtons$1.class\r
+SHA1-Digest: cbJDHjFjkhTcJYViQg3IXmk4EII=\r
+\r
+Name: icons/elcl16/alphab_sort_co.gif\r
+SHA1-Digest: 0s8394QVKoPvyWAYcmVLU8X/Jp4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CDocumentProvider$Translation\r
+ UnitAnnotationModel.class\r
+SHA1-Digest: bdi/P4zhqpBZyyb062ccyCUXDNo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorHoverPreferencePa\r
+ ge.class\r
+SHA1-Digest: 7fdWbMVahcXYeT6CCDPrPUFXvI8=\r
+\r
+Name: org/eclipse/cdt/ui/newui/IncludeFileTab$1.class\r
+SHA1-Digest: pnp8EXjxg5XOAMo/RmwcadR2DVE=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UIComposite.c\r
+ lass\r
+SHA1-Digest: mgw3EiUNiTexqLdUopwJ9kI49SE=\r
+\r
+Name: icons/elcl16/search_prev.gif\r
+SHA1-Digest: nUGy85EowQLrI5hDomzojsZItS4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/filters/ClosedProjectFilter.class\r
+SHA1-Digest: TcMc05P27uADRGpe9Juam5KR2mo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/PersistableCElementFactory.class\r
+SHA1-Digest: CoWiq9M9f+Thibwt6zVn5rKjE+o=\r
+\r
+Name: icons/etool16/exportzip_wiz.gif\r
+SHA1-Digest: w+sCb48H2QKu4ptY8NonqdHFieA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/ToggleCommentAction$1.class\r
+SHA1-Digest: ZUO0+RMqDStbqAxUhfp6BIQaBBQ=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ExPatternDialog$ExclusionPatternAdapter\r
+ .class\r
+SHA1-Digest: P2Lc0tnU8wIoLzjk1rgnzr/q0LY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceOpti\r
+ ons.class\r
+SHA1-Digest: 9V8dej88/HbFMjHrOml4SLZZZkk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/ProblemLocation.clas\r
+ s\r
+SHA1-Digest: ZOEJMgPz83COV+BQoAMD9pfmP60=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ErrorParsTab$1.class\r
+SHA1-Digest: L1bfRc2d5UKqVYS3ivnNMX5PTJE=\r
+\r
+Name: icons/obj16/quickfix_warning_obj.gif\r
+SHA1-Digest: Jq0X2P0QjamoRnCdn1fUZmV+VcE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/CRefactoringContribution\r
+ .class\r
+SHA1-Digest: zNgot/+HnJseQDeJ05ItNKajh5g=\r
+\r
+Name: org/eclipse/cdt/ui/resources/messages.properties\r
+SHA1-Digest: 6FchXqTOfMoykO4UF+Y1m8ZWlyA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProc\r
+ essor.class\r
+SHA1-Digest: Y5Q8fN8p6pa3eZKj4wDNAftIs2o=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/BracesTabPage$\r
+ 1.class\r
+SHA1-Digest: A0LpZNfWGLpy/MuwRwvQGs+009E=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/NextErrorAction.class\r
+SHA1-Digest: oeZ0DIvrRN+NFVOGbBUZi294rIs=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ManageConfigDialog$2.class\r
+SHA1-Digest: lUry5rDs5gAGtQpUrYk+FDIAh/I=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathSourceEntryPage$\r
+ SourceContainerAdapter.class\r
+SHA1-Digest: fnI14P2cbr6ImEX5ElV/69hVaq0=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ExpSymbolTab.class\r
+SHA1-Digest: P+DKbVEM3qa6A8EKBjh2l5dR7x0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/NewSourceFolderDialog\r
+ .class\r
+SHA1-Digest: xxcvWC6U4M+XlwiI89gvIt8msow=\r
+\r
+Name: org/eclipse/cdt/ui/newui/EnvironmentTab.class\r
+SHA1-Digest: LE84gaY3fqShzSu5oAi7qwCJosM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfig\r
+ urationFactory$Registry.class\r
+SHA1-Digest: PBqVR8xV1TO7gUAXB8lhNoi6W6w=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/DocumentAdapter.class\r
+SHA1-Digest: 7MHfUq+9W56VtEQuZUmy0pz1ZU8=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage$10.class\r
+SHA1-Digest: sU0EO23nvDr9eIk/OJq3g2/Z450=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractC\r
+ onstantRefactoringDescription.class\r
+SHA1-Digest: hiBx1joSvUKcRt6/6VJ0Vg7z/tU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactorin\r
+ gInputPage.class\r
+SHA1-Digest: q7wv0qc6+mfAC3JW7Iom/FLvKXM=\r
+\r
+Name: org/eclipse/cdt/ui/newui/SymbolDialog$2.class\r
+SHA1-Digest: mr8GupmPKko2Dt4l+7K13Y0eZYo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/IProjectSett\r
+ ingsWizardPage.class\r
+SHA1-Digest: pQPfvjZgSXND/Cf55Ni3ZyppL1Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/CCorrectionProcessor\r
+ .class\r
+SHA1-Digest: 5ukRt2QofA5i+IadP1X6MPN+qvI=\r
+\r
+Name: icons/elcl16/th_single.gif\r
+SHA1-Digest: JSq4wcJO7adGNtk3jFIfEbDJKlo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$DeletePreviousSubWord\r
+ Action.class\r
+SHA1-Digest: a0bzwScjTIPfNhLvjRtuonG5Yhk=\r
+\r
+Name: icons/dlcl16/static_co.gif\r
+SHA1-Digest: J7QetQXCktQAuy0huqvm1nn9/uE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/EditorHighlightingSynchronize\r
+ r.class\r
+SHA1-Digest: OlDMO1L7xLqvuU4nlCL2dadsfGg=\r
+\r
+Name: icons/dlcl16/th_vertical.gif\r
+SHA1-Digest: SrhmwGrMk4nkFRxHCUvRoupSHLU=\r
+\r
+Name: icons/obj16/core_obj.gif\r
+SHA1-Digest: ciRPxEz75GC7jbUByBenviGWWaU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/SpellCheckEngine.class\r
+SHA1-Digest: 6ggaoQHd4w9seXi8aRtQe/2QMxU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationB\r
+ lock.class\r
+SHA1-Digest: ouzNXwnqDS6fTJSz9TrE7YyoL1g=\r
+\r
+Name: icons/obj16/wsp_includefolder.gif\r
+SHA1-Digest: BBMOOqEwJHGac5LSD/4LeWy14mQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/utils/Messages.class\r
+SHA1-Digest: 7DKdevbxDJxTDXCyVfKx4F73R6I=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/DocumentCharacterIterator.class\r
+SHA1-Digest: 913S73fwGJQhsegKnCWOAW4IVmg=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/pages/TemplatePreferencePage.c\r
+ lass\r
+SHA1-Digest: Ahmp6WnqRLHA7PTF5WN71ZnjjsA=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/TemplateEngineUIUtil.class\r
+SHA1-Digest: U/BxQxG1Lk4xs6Z+LnwpwFryt80=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/ProblemTreeViewer.class\r
+SHA1-Digest: 0aFlfPlyuUoJ0FGs3gsXtq8zD+c=\r
+\r
+Name: org/eclipse/cdt/ui/newui/EnvironmentTab$MyListSelectionDialog$1.\r
+ class\r
+SHA1-Digest: KXyfZLIyHG+9GaQYR9gKXgOwtb0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/CDTContextActivator.clas\r
+ s\r
+SHA1-Digest: boksdDscVBLKC19wz52GAWqIZF0=\r
+\r
+Name: org/eclipse/cdt/ui/actions/ChangeBuildConfigContextAction.class\r
+SHA1-Digest: inBvw3Z2My5PmDUH/D6L1Fs8xrs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/AbstractPreferencePage$2\r
+ .class\r
+SHA1-Digest: xKdSrLxDTvr7U5tU2t+XP62Pp8k=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/dialogs/CTextEditChangeP\r
+ reviewViewer$CPPMergeViewer.class\r
+SHA1-Digest: oQVUuezqPUgzQX0IgeNVUc+W6CI=\r
+\r
+Name: icons/obj16/tc_empty.gif\r
+SHA1-Digest: 19DryuARv13s6Ac7tODHNEOpkow=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractPropertyDialog$1.class\r
+SHA1-Digest: WFecrkclJxFCz95hmpZpiWlzOG0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/CustomCodeForm\r
+ atterBlock.class\r
+SHA1-Digest: pQEt76CxDQ1fc4DBTQoj/kUEzrg=\r
+\r
+Name: icons/dtool16/config-linker.gif\r
+SHA1-Digest: ILDkyu8yoqFQidK4QTS4iXBZ2s4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/AbstractMixedPreferenceP\r
+ age$1.class\r
+SHA1-Digest: OQDAkxZK2s5GTp2fzJtVQsLGvyI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/CorrectionMessages.c\r
+ lass\r
+SHA1-Digest: cTEJm384pydQFCsb8+luJBmu0Q8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandHan\r
+ dler$1.class\r
+SHA1-Digest: HJxavFvkbqKwyaq+vaNy6002w5U=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/filewizard/NewHeaderFileCrea\r
+ tionWizardPage.class\r
+SHA1-Digest: LEvGYF9RsbhWy3WtcBUbRjfIem4=\r
+\r
+Name: org/eclipse/cdt/ui/IncludesGrouping.class\r
+SHA1-Digest: q3rlqzJclMkS58m48uDtBHDe3HY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/GlobalBuildConsole.clas\r
+ s\r
+SHA1-Digest: 374+d0CgKYPOVF4DIy7+N3KBYPc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/CView$7.class\r
+SHA1-Digest: MJTfCFSbPiEyTFSU6yUMipzbSpU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightings$EnumHig\r
+ hlighting.class\r
+SHA1-Digest: c/cDbKaEeXiNnltnuCnMclLnCOk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfiguratio\r
+ nBlock$3.class\r
+SHA1-Digest: tgA9YLzfg+LwKvF1rcAyaL+mUOs=\r
+\r
+Name: icons/ovr16/readwrite.gif\r
+SHA1-Digest: i7kaC57O0PCnKISj8L+3nZnjg7Q=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager$1.c\r
+ lass\r
+SHA1-Digest: g0NQoIW6lnyaz6QDxc6jCFCU5eo=\r
+\r
+Name: org/eclipse/cdt/ui/actions/CustomFiltersActionGroup$FilterAction\r
+ MenuContributionItem$1.class\r
+SHA1-Digest: 2irB7hNSmbTORd1rYNavjS/lyTE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/NamespaceSelecti\r
+ onDialog.class\r
+SHA1-Digest: hSW0+sEc7s5uWVpcgegaACU7KeM=\r
+\r
+Name: icons/obj16/cp_order_obj.gif\r
+SHA1-Digest: LsbLDmKD8jNlIPsYQWR82Jn5Y6k=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileWizardMess\r
+ ages.class\r
+SHA1-Digest: +WuMo/pLN9QnhJ2WGALDfAujUew=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ProfileManager\r
+ $CustomProfile.class\r
+SHA1-Digest: TN1nWqU6t/wxLVG50pllKe1jRe4=\r
+\r
+Name: icons/etool16/action-editconfig.gif\r
+SHA1-Digest: kKJLklAxE9IEwAtoTvYuAYzFVto=\r
+\r
+Name: org/eclipse/cdt/ui/newui/IncludeTab.class\r
+SHA1-Digest: CbH+uqOuEABMeO5/9D/iGHzR+zI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/ProjectTemplateStore$1.c\r
+ lass\r
+SHA1-Digest: FMPTRpv2OLNLmsh3+C5ah7kQ9Eg=\r
+\r
+Name: icons/obj16/workspace.gif\r
+SHA1-Digest: 5+Nvc0lUUyntNUxqN2rV9b068VY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/ICReconcilingListener.class\r
+SHA1-Digest: GPg4P2j+MeURffdltw9+yOWpL1s=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/PreviewSourceViewer.clas\r
+ s\r
+SHA1-Digest: SS5ZiTPIWmehrN+hwNy5l76qSgI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Genera\r
+ teGettersAndSettersInputPage$6.class\r
+SHA1-Digest: i8a0cIMsGbIneqMQnhmoxOfBOwE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightingManager$H\r
+ ighlightingStyle.class\r
+SHA1-Digest: R4U+uLWSlsqbg71QP3XaTpNuS/Q=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CWordIterator.class\r
+SHA1-Digest: 0FHRqnrluALbpKoWgXrs+DX3y+0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/utils/CPPASTAllVisitor.c\r
+ lass\r
+SHA1-Digest: 9rzFWUvFgB7axLaeHyOh4SnvTB4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SourceHeaderPartnerFinder$Cou\r
+ nter.class\r
+SHA1-Digest: PbkCOnp9XVkNWayeI4cwQb1PCa8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistProc\r
+ essor$2.class\r
+SHA1-Digest: OchEqOys9hFHtwi8Bw7IVlNdTWw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/PDOMSearchMatch.class\r
+SHA1-Digest: jN1cQiERgfXQI/NOw67L091dIGw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractC\r
+ onstantRefactoringContribution.class\r
+SHA1-Digest: KsRJgX6NgIInJaCIp4wdxJ9Tl6A=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatch\r
+ .class\r
+SHA1-Digest: hGye3yDj3V1GH4sb50hQl7L2hFo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorD\r
+ elegate.class\r
+SHA1-Digest: oSfwwqyF0vji1dLTDKJQ/VWJBAk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialogTa\r
+ bPage$ButtonPreference.class\r
+SHA1-Digest: G7PuHZ5jQDPogTJFk69IKJJyXhs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField\r
+ .class\r
+SHA1-Digest: 8C0ETS30jY3CNSwUy64tzZSAzEA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfig\r
+ urationBlock$PreferenceModel.class\r
+SHA1-Digest: ZLL5puGo5A0VnLxWM8QDiwNe52E=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/IndexerStrategyBlock.cla\r
+ ss\r
+SHA1-Digest: KtX0tczv3wibOj391ActmSI4BWQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/LineWrappingTa\r
+ bPage$1.class\r
+SHA1-Digest: 2nbuBl0fPRuEDq66tjnMHjqEzaA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/doctools/Messages.class\r
+SHA1-Digest: ZgsG+UU38rNz10SfH2j0oezItYg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectInde\r
+ xExportWizardPage$5.class\r
+SHA1-Digest: 1Cz1LR7B/lD6wkU0aG5Nckt1AOo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/navigator/CNavigatorContentProvider$\r
+ 2.class\r
+SHA1-Digest: WOtB0rAyu7exKe9860prPc3fZz0=\r
+\r
+Name: icons/dlcl16/sub_co.gif\r
+SHA1-Digest: 6CIeSYx7nn09iP4bVXAtazgk3g8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/AbstractAnnotationHover\r
+ $AnnotationInfo.class\r
+SHA1-Digest: M73a4kMIq8JVEXcAAN6+CVmlhCI=\r
+\r
+Name: icons/wizban/newmngcc_app.gif\r
+SHA1-Digest: 1o1Y0mE1+RRy+0pxgYhxG06TCuI=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/RegularExpressionStatusDialog$1.class\r
+SHA1-Digest: sp+JW047FPl218JsQUfQgKPuPaM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$21.class\r
+SHA1-Digest: BSqMDoJEFhq+7A/4ISt+TcIuIOQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/IStringButtonAd\r
+ apter.class\r
+SHA1-Digest: clKQ0e8ABRQukI5MqwRMHrV2AQ4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/CViewFrameSource.class\r
+SHA1-Digest: 1Ay1Z3tvYMLBQlESEmNE/Gosubc=\r
+\r
+Name: org/eclipse/cdt/internal/corext/CorextMessages.properties\r
+SHA1-Digest: eUar0rcKx3R0NaBGrziXCB4a+IU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingWidge\r
+ t.class\r
+SHA1-Digest: m9SJ6UZ0GVTsSXfHBHeRdMiBgEE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THHierarchyModel$1.cla\r
+ ss\r
+SHA1-Digest: RxieR8UNgi4JXp+q5T5DkmHOYZw=\r
+\r
+Name: icons/dlcl16/view_menu.gif\r
+SHA1-Digest: 7MKCojVITGtKCbgKzqKqen/nCKk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/LineWrappingTa\r
+ bPage$Category.class\r
+SHA1-Digest: SuKRpf40ty3Nk5P3T30VLI4WfqQ=\r
+\r
+Name: org/eclipse/cdt/ui/actions/DeleteResConfigsAction$ResCfgData.cla\r
+ ss\r
+SHA1-Digest: sDPj4Qp8/KuAkFjKmStEDHgptEw=\r
+\r
+Name: org/eclipse/cdt/ui/actions/FormatAllAction$ObjectDelegate.class\r
+SHA1-Digest: WtqGh3Pnh5XPmmjBbRJmNVb68UA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/IWorkingSetConfiguration\r
+ $ISnapshot.class\r
+SHA1-Digest: X2GKFZou8H0IAt35OdQ2C9Jmtug=\r
+\r
+Name: org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineConfigu\r
+ ration.class\r
+SHA1-Digest: lDBknR0oe/LO83oVq2DtwlcjLbQ=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/CygwinPEBinaryParserPage$4.class\r
+SHA1-Digest: 7JgcRpFny2/3nJyo7ZhoBVCfGrA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/ExclusionPatternEntry\r
+ Dialog.class\r
+SHA1-Digest: 7VoEFyD7AesPU8sGXDmLXmtHYpE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$15.class\r
+SHA1-Digest: aQ/W7Bd8Aci1lAcPUbX0E3i8j2U=\r
+\r
+Name: icons/obj16/enumfo_obj.gif\r
+SHA1-Digest: 5YVQHgWfzkDORB1IRIUSdx0097w=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/utils/VisibilityEnum.cla\r
+ ss\r
+SHA1-Digest: BXFpaYwpqvyRlMHzlaCSPqUn4Bk=\r
+\r
+Name: icons/elcl16/backward_nav.gif\r
+SHA1-Digest: qx89HZcOfCNP8URrsbXsnJSbNro=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$9.class\r
+SHA1-Digest: AG/2Oacaj8ToT/za7Guy749u5jo=\r
+\r
+Name: org/eclipse/cdt/ui/CUIPreferenceInitializer.class\r
+SHA1-Digest: HVSYXwBSDiEAH+BLEPS8u6fsHjM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/indexview/IndexLabelProvider.class\r
+SHA1-Digest: dlDpvPJvuobdu/6ZlkwAuEblAx0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSetti\r
+ ngsImportWizard.class\r
+SHA1-Digest: p6k+OmX64K/KH/2uNaZVrywlWCs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CodeTemplateSourceViewer\r
+ Configuration$TemplateVariableTextHover.class\r
+SHA1-Digest: yN5a02dxNp8L7GP/pkYgzAxYqJ8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THHistoryListAction.cl\r
+ ass\r
+SHA1-Digest: ibsVZixQ8V6RMgl+CBf9dJ+H2Xw=\r
+\r
+Name: org/eclipse/cdt/internal/corext/util/Resources.class\r
+SHA1-Digest: e4zRzQQ3qCIhLliJ/sthQNG6qY0=\r
+\r
+Name: org/eclipse/cdt/ui/actions/ExcludeFromBuildAction$1.class\r
+SHA1-Digest: v/rl0IWjQ84yby7/ZpPLNjaTc4I=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/CUILabelProvider.class\r
+SHA1-Digest: thpPyxmUhStggOxTw18f4rh38z0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/PropertyAndPreferencePag\r
+ e$3.class\r
+SHA1-Digest: NGgF63LM0GEBfVuwweWRkCHPyxU=\r
+\r
+Name: org/eclipse/cdt/ui/newui/EnvironmentTab$MyListSelectionDialog.cl\r
+ ass\r
+SHA1-Digest: hHaGs6ZOEYD8ldBt1Wh0fkUE/rw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/InactiveCodeHighlighting$2.cl\r
+ ass\r
+SHA1-Digest: GoDxJHtcNK7g2pamXg/TmpVkj68=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/implementmethod/InsertLo\r
+ cation.class\r
+SHA1-Digest: BJCFuj+ZbnkY0F/fxpg4OKl4kC8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightings$Enumera\r
+ torHighlighting.class\r
+SHA1-Digest: zq8zQuEsr+nT9Cm4XkComcP1HeE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigsControl\r
+ ler$4.class\r
+SHA1-Digest: dXn4afSifQm9BW+e2g+rWyCYmbw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBViewPart.class\r
+SHA1-Digest: 8qjIffcuTFVixoyn7gE6IOk3Tco=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/CSpellingEngine$Simple\r
+ TokenStore.class\r
+SHA1-Digest: /QCBNTaiLcScJ41n/hMqulBVy0A=\r
+\r
+Name: icons/obj16/quickassist_obj.gif\r
+SHA1-Digest: xBo8UIyfgV44pDR2VsMG5v8tJKM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractF\r
+ unctionRefactoringContribution.class\r
+SHA1-Digest: 4jHfrDDNzefBYhDEUdHpPXwXBKE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/actions/FindRefsProjectAction\r
+ .class\r
+SHA1-Digest: LyK0ScaMKvGujLuSOH/Np4Y+8sA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CBraceRule.class\r
+SHA1-Digest: Q1M4j2CTNA16/0oeEklxJLeM8oI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformation\r
+ Popup$4.class\r
+SHA1-Digest: TpmUSUAviFQwniJ2d+kdFHHi4aY=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/CDTCommonProjectWizard.class\r
+SHA1-Digest: XJN0FZfiH7UuOYNuouz3y/b0O+M=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/IndentationTab\r
+ Page$2.class\r
+SHA1-Digest: eqVjXenuWdJtFzkIndyLwiCi40k=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefChildNode.cl\r
+ ass\r
+SHA1-Digest: mP3dce3fai1gGkl4HCjPu/45G5U=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/CCorrectionProcessor\r
+ $SafeCorrectionProcessorAccess.class\r
+SHA1-Digest: qzoLlCGE08OnPNq/i1wcEBD0jL8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactorin\r
+ gInputPage$3.class\r
+SHA1-Digest: vPUCYXyEXRyS3Ivv77PE5QdvTQI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/doctools/DocCommentOwnerManager\r
+ .class\r
+SHA1-Digest: GozVbD48xblofVac/T+qw6Oea3U=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.pr\r
+ operties\r
+SHA1-Digest: dSQW8jewSZTdCCIIclTEqysw4tI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/RefactoringSaveHelper.cl\r
+ ass\r
+SHA1-Digest: bpNZoyRWs3opWRV+eKHWZq4osQg=\r
+\r
+Name: icons/obj16/c_file_obj.gif\r
+SHA1-Digest: BMizCVKYr3W0xls5HY1LQU2zUps=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IncludeBrowserUI.clas\r
+ s\r
+SHA1-Digest: qiCVA1kRq+i/L6tpE/gLg4oU3mM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/GotoNextBookmarkAction.class\r
+SHA1-Digest: Xh5p80msh7RUMMv1nOlI/J7OZN4=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/Messages.class\r
+SHA1-Digest: W6Jw6ALJrgiGmlYqgGF+37CCy58=\r
+\r
+Name: org/eclipse/cdt/ui/actions/ChangeBuildConfigMenuAction.class\r
+SHA1-Digest: eZrk3Qiz6+D/1LM39/pzBm4kWXg=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/IPathEntryContainerPage.class\r
+SHA1-Digest: Qyr79cjgOt3lKZVFOOZypP4Wwto=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/MultipleFolderSelecti\r
+ onDialog$2.class\r
+SHA1-Digest: OSfF14X00v3ZWcphWSFedmFyLYQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/ProjectConfigurationCont\r
+ roller.class\r
+SHA1-Digest: d0aiuXJD2NwLu477fmWi6RyAros=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProxy$ISnapsh\r
+ ot.class\r
+SHA1-Digest: pD2j10i9FmkTAuWusxTZqb2f068=\r
+\r
+Name: icons/obj16/tc_preferred.gif\r
+SHA1-Digest: Rgn8wwuPrCQE1k9s8ZsM3ZeQ1D0=\r
+\r
+Name: icons/obj16/thread_obj_r.gif\r
+SHA1-Digest: 7eAABXIj0xOfCK8ysSnYPTAZ5AY=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/BinaryParserBlock$1.class\r
+SHA1-Digest: JgwHNd7VOaMmq6po/P4SSGihxP8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfig\r
+ urationBlock$6.class\r
+SHA1-Digest: xNMjOp2mKmF3pMCh2wf70p1OqMY=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/CFormatter.class\r
+SHA1-Digest: y4b3Lnud+8rs95Qc9lvswucoft0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.c\r
+ lass\r
+SHA1-Digest: IOYRDTM6RH1B7ZPahUB1tdpayZ8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/CWorkbenchAdapter.class\r
+SHA1-Digest: 06sbG1T3HBhskG2h+EOwfMC1nqA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBViewPart$7.class\r
+SHA1-Digest: CG+fjoz8gEKQctOCBS9fpOXJxbs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage$5.\r
+ class\r
+SHA1-Digest: hTecxZnzVuvQXn3RjNeYmdRtNU8=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/RegularExpressionStatusDialog.class\r
+SHA1-Digest: EnxA7nPkYiH6c28gihga7+lp9Wk=\r
+\r
+Name: org/eclipse/cdt/ui/CElementContentProvider$RefreshElement.class\r
+SHA1-Digest: frkz+uzaMs5VAvn/LUaRpc/wJ8w=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ExpIncludeTab.class\r
+SHA1-Digest: UakILEnDJy2WKUHjOH+j7iz0njI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/DeleteResConfigsHandler.clas\r
+ s\r
+SHA1-Digest: tPdpN5j4ISb6x+RAdbp2GMWEoRM=\r
+\r
+Name: icons/etool16/action-deleteconfig.gif\r
+SHA1-Digest: LI9q19Mq5Qq71gBuI78IWTS7Cmw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuActi\r
+ on$6.class\r
+SHA1-Digest: oy+lQdXxXAiPdlCEy0wxoom2xnA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlo\r
+ ck.class\r
+SHA1-Digest: ocIFYy1NSoH3rJ9INgB8SFHVD8M=\r
+\r
+Name: icons/dtool16/config-category.gif\r
+SHA1-Digest: taHqzlmPWP6jZtbJZguehWoAE8Y=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/uitree/IPatternMatchingTable.c\r
+ lass\r
+SHA1-Digest: 4oPljQtezIXh80eIRfzt/1RdcrM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/ActivateWorkingSetConfig\r
+ sContribution$ActivateConfigAction.class\r
+SHA1-Digest: /rxWJk/y4mHjnLbPSiJJJvONFW4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/LanguageMappingWidget.class\r
+SHA1-Digest: NxVeNOxj0Z8k0YJPNdkX143AFZ4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBViewPart$13.class\r
+SHA1-Digest: bBc3jHHKYIEMs4HKxKjeIyKzZ6A=\r
+\r
+Name: templates/default-templates.properties\r
+SHA1-Digest: Tq20CSE8IyQY5dpRjhtcWgN6M4k=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/PDOMSearchPatternQuery.class\r
+SHA1-Digest: fbndLVf1HRy44M5ZPMeS84i/QZo=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.class\r
+SHA1-Digest: Z2gO2cQHLY0i7UUQhGZxhwaLhyA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/CRefactoring.class\r
+SHA1-Digest: WKCov24VsusKGplHzlrreyHzzm0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFro\r
+ mInHeaderToClassStrategy.class\r
+SHA1-Digest: siWX1ugNiDblS6U79+S9ZHNHeXI=\r
+\r
+Name: org/eclipse/cdt/ui/CElementImageDescriptor.class\r
+SHA1-Digest: Qgj3MjulLb/3bfpQyYSG9j2PmCk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/PDOMSearchPage$1.class\r
+SHA1-Digest: xizgOhjFPdc0swXixsFYOTRmWcw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/AbstractInformationControl$3.cl\r
+ ass\r
+SHA1-Digest: JtEKa1ewPs7zpJofFIpsItGdxSI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/actions/FindRefsAction.class\r
+SHA1-Digest: hDbcaTfcT9mEHRdQxrvOGZMjrjY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/WordIgnoreProposal.cla\r
+ ss\r
+SHA1-Digest: H+xG9YZeMKgWii9hEUzUoNK/S+Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/ITreeListAdapte\r
+ r.class\r
+SHA1-Digest: tH5kINUdXqB2511fyYpwP8imffc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THHierarchyModel$Backg\r
+ roundJob.class\r
+SHA1-Digest: yaFRyGSu2fBgmSkXYdsoEx0ZL2s=\r
+\r
+Name: org/eclipse/cdt/internal/ui/navigator/AbstractCNavigatorActionGr\r
+ oup.class\r
+SHA1-Digest: p0BgC+A6H7vVb25RmRH6hEKP+vU=\r
+\r
+Name: icons/obj16/toolbar_pinned_r.gif\r
+SHA1-Digest: zbYLt3I3aFR/s6YgFpWVVhV/K0U=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/utils/NamespaceHelper.cl\r
+ ass\r
+SHA1-Digest: 3GvloK3K9uvTFC8xksIAh63p3qY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/implementmethod/Implemen\r
+ tMethodInputPage.class\r
+SHA1-Digest: ddSgWRH7/++9MmP5BZM7l6E4DdQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionExplorat\r
+ ionControl$CDiffNode.class\r
+SHA1-Digest: lBlCaiu5jzsdnpa6Ct1v6YEJ6u0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$ExitPolicy.class\r
+SHA1-Digest: 75YFI0wIoOqOBN7j6p3CqFDBUTA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/CPluginResources.properties\r
+SHA1-Digest: k6qw2PnHTgVEHlkPFOUoMWGzKVs=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/TemplatesChoiceWizard.class\r
+SHA1-Digest: OAzvM8ebaVuYoFW2xEbIkGeDexQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CPairMatcher.class\r
+SHA1-Digest: pILYAShBUK6Rn+alaWMyoz4KFUw=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/NewSourceFolderCreationWizard.class\r
+SHA1-Digest: 5W6HXFaiDZ1+yX7S4+esQcJOGC0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileFromTempla\r
+ teWizard.class\r
+SHA1-Digest: H+IzDPA1/8fuvvZJkfEWYtHyqmA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryDropDownActio\r
+ n.class\r
+SHA1-Digest: UZ16jaKklVUONIiNrrQ/1TCTn1k=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/StatusTool.class\r
+SHA1-Digest: jFYDGDG4tVBRnnv2TIJopKhqne4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/Ext\r
+ ractLocalVariableRefactoring$2.class\r
+SHA1-Digest: ay5XIthlpKb8zak+0YHJCUJf600=\r
+\r
+Name: icons/obj16/variable_obj.gif\r
+SHA1-Digest: pHwUxqItrBHgQIfeCFxrhd57Op8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractF\r
+ unctionComposite.class\r
+SHA1-Digest: c57jSyB06jvxxQOO3yYeLD12PkE=\r
+\r
+Name: org/eclipse/cdt/ui/newui/MultiCfgContributedEnvironment$EnvCmp.c\r
+ lass\r
+SHA1-Digest: eZHeaPH6zIGqbQPbqzRLmpovp3g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THInformationControl.c\r
+ lass\r
+SHA1-Digest: UFUjqlGQCPw98f5SJj3ea/N7FkU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameLinkedMode$\r
+ 1.class\r
+SHA1-Digest: 8ljMksv52WESnG2jtKOHAojMKnc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CBreakIterator.class\r
+SHA1-Digest: 40dJNQrKnubro5WeTcKWummrrg0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionExplorat\r
+ ionControl$2.class\r
+SHA1-Digest: WlY16LIGFfjdF9upmp9OFVMlDVA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SourceHeaderPartnerFinder$Par\r
+ tnerFileComputer.class\r
+SHA1-Digest: bbNl4M9YMH9rBCnkM0u0Rw664sE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CStringAutoIndentStrategy.class\r
+SHA1-Digest: FtPNsLWSycciaWWWEcl5Rb59ZYw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/ExclusionPatternDialo\r
+ g$ExclusionPatternAdapter.class\r
+SHA1-Digest: WV8EDo3yD4bC7/MH1Ayhyme360c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightings$MacroRe\r
+ ferenceHighlighting.class\r
+SHA1-Digest: aOyUZiZztIsVPlNtU4uH2LG3MiE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/ProjectContentTypeMappingDi\r
+ alog.class\r
+SHA1-Digest: EOkXiCa1uv4D0lSNTKMb776E7W8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dnd/DelegatingDropAdapter$4.class\r
+SHA1-Digest: czDwQTRpCJQ4r+UWxGcRlDkNr/g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/TextSearchWrapper\r
+ $2.class\r
+SHA1-Digest: gkR05unbPVF68ZUCRZ3Xlm/cK60=\r
+\r
+Name: org/eclipse/cdt/ui/newui/RenameConfigurationDialog$1.class\r
+SHA1-Digest: E2yKPWvj3t0vgg2gR6k88HfoMGA=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ProjectContentsArea$3.class\r
+SHA1-Digest: IFUgGHQppv1d03/G1N1MCCVdug4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/ProjectContainerPage$\r
+ 1.class\r
+SHA1-Digest: ylchNLKQNnlwvxkmuPj8v5P1ESw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CCommentScanner.class\r
+SHA1-Digest: 56hXukOx/MlNhseNhMic98EsENo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingPreferen\r
+ ceBlock$1.class\r
+SHA1-Digest: J8GOqOjmmO1Adg+tbhnSvs7NY8o=\r
+\r
+Name: org/eclipse/cdt/ui/actions/DeleteResConfigsAction$1.class\r
+SHA1-Digest: Cr1a7MV2JVdBEzLexHkqBA/3e2k=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractExportTab$ExtData.class\r
+SHA1-Digest: E8N/XssoVBngcjxpRkQzegYYmi8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/CElementLabelComposer$Fl\r
+ exibleStringBuffer.class\r
+SHA1-Digest: 4HafzaSFm6n+lIDRGqLfhATMD6U=\r
+\r
+Name: .options\r
+SHA1-Digest: x9I8/LOksaIR8D14T8hBs/B5Tcs=\r
+\r
+Name: org/eclipse/cdt/ui/actions/WorkingSetConfigAction.class\r
+SHA1-Digest: rp4JI32rtVDG4jTTDcHEIEy+2Io=\r
+\r
+Name: org/eclipse/cdt/internal/ui/resources/ResourceExclusionContribut\r
+ or$1.class\r
+SHA1-Digest: JYW6PrPym9UtoZTzYSYejfcBoLg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$PreviousSubWordAction\r
+ .class\r
+SHA1-Digest: is3rxjVSb+3YW3jSZ39UgxVKdWo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/togglefunction/Declarato\r
+ rFinder.class\r
+SHA1-Digest: chR4FkSU3aA3WegWuKBf1UG8xDw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$2.class\r
+SHA1-Digest: tdRgqaKYtiyCv2HsipYkncqfnEg=\r
+\r
+Name: org/eclipse/cdt/ui/newui/EnvironmentTab$4.class\r
+SHA1-Digest: 3bopB4fgx7kbH3KRPjRrzuyCIjM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/TreeNavigator.class\r
+SHA1-Digest: pHIi6Wwh5D0VPhOIL0RSzf7bmJc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/CViewMessages.properties\r
+SHA1-Digest: DCq5G5KI/o3evlQvawwTX68PT30=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialogTa\r
+ bPage$NumberPreference$2.class\r
+SHA1-Digest: nbkxztN3gbVYoUATSwihdHDFd6c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformation\r
+ Popup$7$2.class\r
+SHA1-Digest: 5PAkMPHOFgyE2mzQc63Ma6RyY2c=\r
+\r
+Name: org/eclipse/cdt/ui/newui/StructureTreeTab.class\r
+SHA1-Digest: geWNtsNKuW7ec8VZQNnTc8M3hYA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage$1.c\r
+ lass\r
+SHA1-Digest: 0ms5HsJsg87nwl//dnEgk6os6dw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/RefactoringSaveHelper$2.\r
+ class\r
+SHA1-Digest: Y/VaW2R1ejozx+CoAf3okeOQ4DE=\r
+\r
+Name: plugin.xml\r
+SHA1-Digest: 4/e3oelx5uhtWOXFPYHBT/+qnkE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartition.c\r
+ lass\r
+SHA1-Digest: VWZciHMlrUSrbdJE/c0p8o7SJ08=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage$2.clas\r
+ s\r
+SHA1-Digest: qksS7mFC7nljnswp5YF2Aj2wRtk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/StructureSelectionAction$Exp\r
+ andSelectionJob.class\r
+SHA1-Digest: nDUFucs4fQOs9u1s9gFvK09vIkc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigsControl\r
+ ler.class\r
+SHA1-Digest: b9KoHvFIE8hNDVGtdgHK3vhidA0=\r
+\r
+Name: org/eclipse/cdt/ui/newui/StructureTreeTab$1.class\r
+SHA1-Digest: rloGt5aOwPvTeLEedbaYbWeXZDU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/FileLanguageMappingProperty\r
+ Page$3$1.class\r
+SHA1-Digest: /Ska6MuhR8j6NN5V+6eB/2hlybI=\r
+\r
+Name: icons/obj16/archives_obj.gif\r
+SHA1-Digest: fgO9r91vFshkgQz3HDL+PeUcfog=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/conversion/ConversionWizard.class\r
+SHA1-Digest: pteEW3XlyvkCRumFDXnYyQZfOTc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog$4.cla\r
+ ss\r
+SHA1-Digest: +E6/csiopDm9PspVvDS+FZWpdaY=\r
+\r
+Name: icons/elcl16/group_include.gif\r
+SHA1-Digest: fzP1836Z0sa/slwGPCRZtfLCIy4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/indexview/IndexView$5.class\r
+SHA1-Digest: EvVeRANJbGtfRq0qYh8uEK8Md40=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/folding/CFoldingStructureProvid\r
+ erDescriptor.class\r
+SHA1-Digest: Qu2cIHQdE95zGg7GwOL3yb0GIZE=\r
+\r
+Name: org/eclipse/cdt/ui/newui/MultiLineTextFieldEditor$2.class\r
+SHA1-Digest: ElXE/02WJuJSkJNrmSx0TY635ck=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ConfigMultiSelectionDialog.class\r
+SHA1-Digest: MRI2BzL5C18/z6UlAPaQSbiNsmo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationB\r
+ lock$WSConfigsLabelProvider.class\r
+SHA1-Digest: 2gmBt/MaM3FLPmQUP9hrEVh1R0E=\r
+\r
+Name: org/eclipse/cdt/ui/text/CSourceViewerConfiguration$1.class\r
+SHA1-Digest: ANjLYOmt9yw+RvRhzMUAeednHpI=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/IPagesAfterTemplateSelectionPr\r
+ ovider.class\r
+SHA1-Digest: Sh+2KNVfrexiXb+bpINMQkBzbTg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/AbstractWorkingSetConfig\r
+ sContribution.class\r
+SHA1-Digest: v1NJhxamB0pMPc3QVWHBqyR5f88=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/BuildWorkingSetsContribu\r
+ tion.class\r
+SHA1-Digest: e6S7G9TVNA7SbPyQNs+/ib/csnc=\r
+\r
+Name: org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenSingleConfigurat\r
+ ion.class\r
+SHA1-Digest: pzBVlMnC/4sHZStAdm/WxXtfX8g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSetti\r
+ ngsExportWizard.class\r
+SHA1-Digest: VjcarsQxNg/mxZl9gxm9lx8Xe6I=\r
+\r
+Name: org/eclipse/cdt/ui/text/AbstractCScanner.class\r
+SHA1-Digest: Z3P5SYwcQcZTSEcXy1J9BluDjgY=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractCPropertyTab$3.class\r
+SHA1-Digest: x6I+sRa4MBkAmTaidctTfPIlNrQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/OpenIncludeAction$1.class\r
+SHA1-Digest: FhQ7L/SGU2jI4By3zUvIir1ViRs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructur\r
+ eProvider$ModifiableRegion.class\r
+SHA1-Digest: gnghcoAz9vcAd1b1PxW6wTGvBd0=\r
+\r
+Name: icons/wizban/newcprj_wiz.gif\r
+SHA1-Digest: yRz9VDhg97C/hOhW+g804WooxFM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionHover.cl\r
+ ass\r
+SHA1-Digest: z/7R76Onf5jTsLVEv0oYRzQ4R/M=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionInformat\r
+ ionProvider.class\r
+SHA1-Digest: xrKTA0UElpmD+ugzYUA/bcUlYt4=\r
+\r
+Name: org/eclipse/cdt/ui/text/doctools/generic/GenericTagDoubleClickSt\r
+ rategy$DocumentCharacterIterator.class\r
+SHA1-Digest: aGnMeq8tGRowm8BlVxuCYApuY2c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathLibraryEntryPage\r
+ $LibrariesAdapter.class\r
+SHA1-Digest: V8mijFK8dystrsokBHUXbbr30qw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/CCompletionPropos\r
+ al$ReferenceTracker.class\r
+SHA1-Digest: oMtPsJzUFnrSVSzA25vjbCAY73I=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/SelectionUtil.class\r
+SHA1-Digest: DuXZLzLBPl+/J+94b23jUl5ot8M=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/FileTemplateContextTy\r
+ pe$FileTemplateVariableResolver.class\r
+SHA1-Digest: fGpuBwpYA21ym7qESetY9yDz12A=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/ProblemsLabelDecorator$P\r
+ roblemsLabelChangedEvent.class\r
+SHA1-Digest: WiVG4Q6l4rizd8EH5N10GDU/ZVA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CTemplatePreferencePage$\r
+ 1.class\r
+SHA1-Digest: mZ2j1WCsne4PIYsg2u4CFxML/JQ=\r
+\r
+Name: org/eclipse/cdt/ui/newui/BinaryParsTab$1.class\r
+SHA1-Digest: Rxr53lS6KdKgp6it4QMJOZge4Lg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/Visibility$3.class\r
+SHA1-Digest: +98eesc0xBpf7CZwwUkYKijum5g=\r
+\r
+Name: icons/dlcl16/ch_callees.gif\r
+SHA1-Digest: WgN+PWwBgrOCJDz9SZaZSaTSwmY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationB\r
+ lock$WSConfigsContentProvider.class\r
+SHA1-Digest: ajRbhA/HwoGU5Ev2fg/eR3PI99k=\r
+\r
+Name: org/eclipse/cdt/internal/ui/navigator/CNavigatorDropAdapterAssis\r
+ tant$2.class\r
+SHA1-Digest: 21cVbHAxXRXLt8O6YmwRP3Ocke0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/ColoredViewersManager.cl\r
+ ass\r
+SHA1-Digest: khTEn32GOA4KOfFbtmjgU+Dokgg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/OverrideIndicatorManager.clas\r
+ s\r
+SHA1-Digest: 1Vtxekzxzt/IgPB5/MczaJKfSCU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CTextTools.class\r
+SHA1-Digest: 5W4VbMpmGn/BwlRRWFLJvDWsKP8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/AbstractAnnotationHover\r
+ $PresenterControlCreator.class\r
+SHA1-Digest: sj/BlwWsimvYKhSvDgMmDgc/4NQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/TodoTaskInputDialog.clas\r
+ s\r
+SHA1-Digest: mpKSd9F0DF0uacDzqCgDdbb9RfE=\r
+\r
+Name: org/eclipse/cdt/ui/actions/BuildActiveConfigMenuAction$1.class\r
+SHA1-Digest: jMB1SsF7Ht8hzwFggRPDoU2WJbE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/CSpellingReconcileStra\r
+ tegy$SpellingProblemCollector.class\r
+SHA1-Digest: 4BDuWtfPyB5pOuy/LBr3c2E/uCM=\r
+\r
+Name: icons/dlcl16/ch_callers.gif\r
+SHA1-Digest: bHVi+CclRGNAoT3JD9Y/shMUayo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFil\r
+ eCreator.class\r
+SHA1-Digest: CJ2QnJARX3+85rPNtT8auUNK10s=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialog$1\r
+ .class\r
+SHA1-Digest: SCgh6wPRJBM9bsSloMrD3xTfufY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/FindWordAction.class\r
+SHA1-Digest: 9nL3EQJuIwbyVJ+Vj8ud6U9a+EI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/MembersGrouping.class\r
+SHA1-Digest: dMEq5jRZQ4PsIMOe0a8D8SJ3+G4=\r
+\r
+Name: icons/obj16/unknown_obj.gif\r
+SHA1-Digest: zbjZn/+xpeb0xD+8FfrVyhA3E94=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CTypeHover.class\r
+SHA1-Digest: 8wZOs1M2XViEbw0aJIPliXdZNMI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/NameStyleBlock$NameStyle\r
+ LabelProvider.class\r
+SHA1-Digest: aoF+iJJnh3hlN5oESGQZeHpX5Po=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/TranslationUnitContex\r
+ tType$FileBase.class\r
+SHA1-Digest: Ucgjy9j2mt/uJnBXPxp8RDpTS2U=\r
+\r
+Name: org/eclipse/cdt/internal/corext/CorextMessages.class\r
+SHA1-Digest: AusGIRvfrXxA4BaPqe/KQD45y0o=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesLabel\r
+ Provider.class\r
+SHA1-Digest: AC+a23uYHbJJjd45fnr1hSn6d4g=\r
+\r
+Name: org/eclipse/cdt/ui/actions/SelectionDispatchAction.class\r
+SHA1-Digest: s7vVwgBaTchsAWHQF6t3GiKMJkk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart$8.class\r
+SHA1-Digest: AsCs7Y/pMhhqXbXGmjMvG5oA5dI=\r
+\r
+Name: org/eclipse/cdt/ui/actions/FormatAllAction.class\r
+SHA1-Digest: VJi7q9uOIjsGO+pZVim5tal5ifw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CMarkerAnnotation.class\r
+SHA1-Digest: m83Zi+mjyOLfjy+DV3Dr6uARN1A=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/ProblemHover.class\r
+SHA1-Digest: tiwA6uew8bFdb6msd01Mnmup/vo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/togglefunction/TogglingA\r
+ ctionDelegate.class\r
+SHA1-Digest: 7b6CpWhfyAi6k8VOVPrPFsE07Hc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/WordCompletionProposal\r
+ Computer$1.class\r
+SHA1-Digest: iZT+Wcqa4BztQ1sIHj0hR6nXUek=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSetti\r
+ ngsImportStrategy.class\r
+SHA1-Digest: CbY9yqTWwd/uIAkvagHz1fxKA5c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dnd/FileTransferDropAdapter.class\r
+SHA1-Digest: 0jWZuikVPjh0W8USKlUiOZhhy38=\r
+\r
+Name: org/eclipse/cdt/ui/refactoring/actions/ImplementMethodAction.cla\r
+ ss\r
+SHA1-Digest: aukq5NmCkNQqrK6/lQ+0rlU5EZI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/InactiveCodeHighlighting.clas\r
+ s\r
+SHA1-Digest: glaQ2/LM01lJZeHIIkuCpXPMaQc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/CCorrectionAssistant\r
+ $1.class\r
+SHA1-Digest: l8NSbbNLeFVB9b5N5XDtMOi9LDA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/utils/EclipseObjects.cla\r
+ ss\r
+SHA1-Digest: T9xz76Kz9YDVNwQpPkseUBC49p0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/SpellingPreferences.cl\r
+ ass\r
+SHA1-Digest: 0Dc22KDEFIUld8Ng2I5G2greV58=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBMessages.properties\r
+SHA1-Digest: WH0K09gEe/GTFgxIlY+ilRswBHU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEnt\r
+ ryPerFilePage$IncludeSymbolAdapter.class\r
+SHA1-Digest: Eo8ACjP3e2CVH1YWNoX1E378prA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/TaskTagRule$TaskTagDetector.cla\r
+ ss\r
+SHA1-Digest: XuwMobUH7ewDkfL4iVzYX2bU6uY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigura\r
+ tionBlock$5.class\r
+SHA1-Digest: zSHWP0QLjvA1oe9eAy5tQRaatbM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/Ext\r
+ ractLocalVariableRefactoringRunner.class\r
+SHA1-Digest: kRat3RtHez1bjrx1rHWj/81RYTk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationM\r
+ anager.class\r
+SHA1-Digest: feWOAJ/98dEhnIyxmLtkvQ5bQP8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/utils/ExpressionFinder$1\r
+ .class\r
+SHA1-Digest: 2pP3qUjFV7HJceUXHtpVkdeFO2w=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatch\r
+ Store$1.class\r
+SHA1-Digest: rojIyWTFo9bHJ2ihbod07tn5YaU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/GlobalBuildConsoleManag\r
+ er.class\r
+SHA1-Digest: uqd4tw9GM3Myja1dzD0W5tRNQtI=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/conversion/ConvertProjectWizardPage$4\r
+ .class\r
+SHA1-Digest: A32P1I2PWmAcpGSPa3JXhv6T++s=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSetti\r
+ ngsWizardPage$6.class\r
+SHA1-Digest: qdToBzfzqD4C1WYVlIGFAmMSrfY=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/TemplateListSelectionPage$1.cl\r
+ ass\r
+SHA1-Digest: 4w6rjW5ufVdlZDAdi7j2qJ1/aL8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover$SingletonR\r
+ ule.class\r
+SHA1-Digest: 8JBr+sflWdLHuLH9qnW9X03CM0k=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THHistoryAction.class\r
+SHA1-Digest: UGli6WdnRzcQ2PbkxirKVk6WArc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlo\r
+ ck$SectionManager$1.class\r
+SHA1-Digest: +GVNyU9SRkXFCCD5wbzoX5qw3is=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THDropTargetListener.c\r
+ lass\r
+SHA1-Digest: 8ask052mVxOY9jshLRUGcxgul1A=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ErrorParsTab$7.class\r
+SHA1-Digest: /rJ7WxxvwEQivgoFKsnLkus0tUI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/implementmethod/Implemen\r
+ tMethodData.class\r
+SHA1-Digest: JvELgw/LyXL9lfSp8tI32p7JPlI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ProfileManager\r
+ $Profile.class\r
+SHA1-Digest: gcwy7Hk1KNHrjnoVfbIa/edBhIw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/NewProjectDropDownAction.cla\r
+ ss\r
+SHA1-Digest: Ry8M+P0MirkdJUjerPlSJ5difvs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/ContentTypeMappingDialog.cl\r
+ ass\r
+SHA1-Digest: /lxdgHUYdVJ1HMlLnPf0fWTZcJ4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposa\r
+ lCategory.class\r
+SHA1-Digest: HmCSWX8kZ9YyBDDk/EyCD7DSBeE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathProjectsEntryPag\r
+ e.class\r
+SHA1-Digest: duqgnpLuttlgDzAMCmFHUQRxYVA=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/IWizardWithMemory.class\r
+SHA1-Digest: 21zkoDzNprjfdrXxampLsBEPvfQ=\r
+\r
+Name: icons/obj16/threads_obj_b.gif\r
+SHA1-Digest: IIJ30yUuRGM5iiT/DOrBrHMtwHs=\r
+\r
+Name: icons/obj16/sroot2_obj.gif\r
+SHA1-Digest: sLrTPk+QHg+dWCP/8RYTLZibQMo=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/AbstractIndexerPage$2.class\r
+SHA1-Digest: DerkOlSHSKOKaUxIgTfK8LW7X/M=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$6.class\r
+SHA1-Digest: CR5vujASx5qWHobFI+0X/vw/Yic=\r
+\r
+Name: icons/obj16/enum_obj.gif\r
+SHA1-Digest: zpU9Nb1eBu6tYNaVtetNIu+o7QA=\r
+\r
+Name: org/eclipse/cdt/ui/browser/typeinfo/TypeInfoMessages.properties\r
+SHA1-Digest: gqbyOzjbae4DTsNbX7l47kSAVZs=\r
+\r
+Name: icons/obj16/hfolder_quote_obj.gif\r
+SHA1-Digest: hT4s7EgRmQ8Bhr6fJC2KwR93mJo=\r
+\r
+Name: org/eclipse/cdt/ui/text/doctools/generic/GenericTagCommentScanne\r
+ r.class\r
+SHA1-Digest: p1ZC+NNWl6Rtcq1oZs2cmTHaneI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/RefactoringAvailabilityT\r
+ ester.class\r
+SHA1-Digest: HOsGUUjhQvIr9Ro6pM5B5fl72qU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/OpenCSearchPageAction.class\r
+SHA1-Digest: OC0leveWzM51t0YbV4EVPyHeoUc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDia\r
+ log$UpdateElementsJob.class\r
+SHA1-Digest: 2ayB8+mubEN2UaTn46pismrWO2U=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesCache$2.clas\r
+ s\r
+SHA1-Digest: CQZI3xreGix8IGw/RJf1O/Ce1L4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/AlreadyExistsD\r
+ ialog$3.class\r
+SHA1-Digest: XZxqD8t9HujDePkNrTd5RpZpvas=\r
+\r
+Name: org/eclipse/cdt/ui/newui/TypedCDTViewerFilter.class\r
+SHA1-Digest: 5A5Y+dXBXaaYHTMcUhKj4xg6Sfk=\r
+\r
+Name: org/eclipse/cdt/ui/newui/EnvDialog$4.class\r
+SHA1-Digest: E2w9DC8QeFyoJlBhZ+kem7r0/8E=\r
+\r
+Name: org/eclipse/cdt/ui/Messages.properties\r
+SHA1-Digest: 0aWVvhrU22eICYY/QTkb1xUZDbk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/FoldingActionGroup$Preferenc\r
+ eAction.class\r
+SHA1-Digest: CPerf8v5v3wbjJbZGoSxS69vwR0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ControlStateme\r
+ ntsTabPage$1.class\r
+SHA1-Digest: hhuNr1j1cqIEejZpT1ISlippKLU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/BuildGroup$CDTBuildAction.clas\r
+ s\r
+SHA1-Digest: byI5SinGwHmqHMxUsd6rYpd/lQY=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage$6.class\r
+SHA1-Digest: W8NiRc7GLUDOCyikzuqgIXNGkdE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorColoringPreferenc\r
+ ePage.class\r
+SHA1-Digest: Y3Yk5p4o+yONiXWs2TZBZRsnLsI=\r
+\r
+Name: icons/ovr16/defines_co.gif\r
+SHA1-Digest: BC9bfa39uT2NQqR7XxeV0KNih1o=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractPage.class\r
+SHA1-Digest: u3MiJYIY8IlxmA7hZQ72hOTU8Fs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/BuildLogPreferencePage$1\r
+ .class\r
+SHA1-Digest: q2xH728JF1PHg0BQQ7Idsq5+V2A=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/TextSearchWrapper\r
+ $SearchScope.class\r
+SHA1-Digest: CJZL2e+czUJv2yRjTdHxO5dKvq8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/dialogs/CTextEditChangeP\r
+ reviewViewer$CompareElement.class\r
+SHA1-Digest: 9dmpd3CwP4UIbzBNH0KiRphniCQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CTemplatePreferencePage$\r
+ CEditTemplateDialog.class\r
+SHA1-Digest: At2k9if2tg+Mgm9A2AznWiIOwBc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/CRefactoring$ProblemFind\r
+ er.class\r
+SHA1-Digest: /tQisloMXUZrw6WUTBbM4tAcX28=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/CCorrectionProcessor\r
+ $SafeAssistCollector.class\r
+SHA1-Digest: 1z0Adsg1qwxGzVLrGyYzzo0EVEY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurations\r
+ Page$1.class\r
+SHA1-Digest: YRyQZ3IC9rd5q2kSlWrtwRGTFYo=\r
+\r
+Name: icons/view16/call_hierarchy.gif\r
+SHA1-Digest: bxdYWff3Y+o0pesdQD6Ya8jO9I0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/IViewPartInputProvider.c\r
+ lass\r
+SHA1-Digest: /K184IjzPvKgB4D2wmAFsO9bH+Q=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/RemoteTreeViewer$3.class\r
+SHA1-Digest: lhyWKxh0rgpAyjtiMJ98E0CjPo0=\r
+\r
+Name: icons/obj16/field_private_obj.gif\r
+SHA1-Digest: ELqDzUn+PerzQ9djL8qfVoGtZVA=\r
+\r
+Name: org/eclipse/cdt/ui/actions/OpenViewActionGroup.class\r
+SHA1-Digest: OcEOSFhOKSOvfZRfeD2RvwjEcHY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/ProjectContainerDescr\r
+ iptor.class\r
+SHA1-Digest: j/OYwVEO1DWYChqnrH3fqjx/mKo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/help/CHelpProvider.class\r
+SHA1-Digest: VE7nYw7Mf8inLDpnE6SQDHYaaKo=\r
+\r
+Name: icons/view16/cview.gif\r
+SHA1-Digest: N2qFkomglU3hV1IkxEzX2bm5vss=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dnd/BasicSelectionTransferDragAdapte\r
+ r.class\r
+SHA1-Digest: 93+Vq4jyxInjrxdTxM/TkjrQ1/0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CReconciler$IndexerListener.cla\r
+ ss\r
+SHA1-Digest: NuxJ2nac6aOJWo46rny7VxNQ2uY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dnd/TransferDropTargetListener.class\r
+SHA1-Digest: CJ1o+lVdU02NSwUoLgLE7Pu51CY=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ExPatternDialog$ExPatternLabelProvider.\r
+ class\r
+SHA1-Digest: J/I/cjYF/8OSb5CahL8FZvw6Le0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetPage$5\r
+ .class\r
+SHA1-Digest: LJJWklanDnJsUr69xZhPYSbPsQE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/TokenStore.class\r
+SHA1-Digest: bs1WU9lQAOSYkw0jfUePSOUMXTE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/OpenTypeInHierarchyAct\r
+ ion.class\r
+SHA1-Digest: Jor4mbPiASX+5eaFCH5/afVYngA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightings$MethodD\r
+ eclarationHighlighting.class\r
+SHA1-Digest: GfpYqdesxxMOWNACDNpO2muNB2s=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart$13.class\r
+SHA1-Digest: 7NUSZMZ+J7cWqRa5oFgjG326QDA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$NavigatePreviousSubWo\r
+ rdAction.class\r
+SHA1-Digest: lCs9IPvWGYCQ+ltSAv76MLj8hHY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/messages.properties\r
+SHA1-Digest: i8cgf9WRRzwjJGSxsnzrTCG59l4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructur\r
+ eProvider$FoldingStructureComputationContext.class\r
+SHA1-Digest: 4UcaqtDSbMcLskvAJQFJBi0Dn0E=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/DialogsMessages.class\r
+SHA1-Digest: 6b34iToggO+s/JNrRNY4atlhHpY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractF\r
+ unctionRefactoring$2.class\r
+SHA1-Digest: Vfo0VJDXODeUchC6C3CB59fl0sY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/ProjectConfigsController\r
+ $NullLabelProvider.class\r
+SHA1-Digest: B3T28w4cJ0hCuwXmjPVYigcgZZs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/TextSpellingEngine.cla\r
+ ss\r
+SHA1-Digest: nuIDSDeGTnvZwDs3mziy05m0dRI=\r
+\r
+Name: icons/etool16/newcfile_wiz.gif\r
+SHA1-Digest: 6anJXbM4dG0O3GZ+jY8/nSZUU6Y=\r
+\r
+Name: icons/dtool16/newcprj_wiz.gif\r
+SHA1-Digest: 80TZ5D14gKRX2u7d6AFHkiZETIg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/ActivateWorkingSetConfig\r
+ sContribution.class\r
+SHA1-Digest: i5h2DWXcByfO9CyvdHO9/TPVsVQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/OpenNewWizardAction.class\r
+SHA1-Digest: 5obwmUn4YcihPHIsAfdJDOypS8Y=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/FastIndexerBlock.class\r
+SHA1-Digest: 6DGHyrU1B4U7/gbz706F+w6NZVo=\r
+\r
+Name: icons/dtool16/config-librarian.gif\r
+SHA1-Digest: U0fv7ASQTEZJmmJUweKlM5o8ORw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionControl$\r
+ 1.class\r
+SHA1-Digest: F5UXv27vLYYHsn6vIZeoieMGYAo=\r
+\r
+Name: icons/dlcl16/th_showqualified.gif\r
+SHA1-Digest: Yl7KLteXjnYs0FJRdjuw7+GPvyc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/SourceAttachmentBlock\r
+ .class\r
+SHA1-Digest: lt6/zKHJw+3gpEghPxLVDykefZQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/IndentAction.class\r
+SHA1-Digest: qTJrgUGk77/fWb+wJR6N8t9RD2E=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/hidemethod/Messages.clas\r
+ s\r
+SHA1-Digest: 5Uqsoh4cSm0eB9Au0SWfo8vqoiU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellEvent.cla\r
+ ss\r
+SHA1-Digest: DS6NWRlLdCIB9AuMQS+zM/0ybq4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart$1.class\r
+SHA1-Digest: v/dIPxgcKEZZykuF1ccf+yLzA28=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/AbstractGNUBinaryParserPage$3.class\r
+SHA1-Digest: hnEB5juQ3iqYjrLudXAOpyJx9WA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconcile\r
+ r$2$1.class\r
+SHA1-Digest: o9iP1nfy2S4AoE+58eyHBiPH2yM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/HippieProposalCom\r
+ puter.class\r
+SHA1-Digest: 2vjYp6tYgaG2SsPjaFXqS+T8R9E=\r
+\r
+Name: icons/elcl16/search_sortmatch.gif\r
+SHA1-Digest: FlilAoSuraEP/kEltOv8CRoRnLQ=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/CDTMainWizardPage$3.class\r
+SHA1-Digest: /xUSQX20G2iK1NQCRBXCVc/ZCqs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/CView.class\r
+SHA1-Digest: Do+TfDbvUbqovzKqyTqcM2eLTHE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/utils/TranslationUnitHel\r
+ per$1.class\r
+SHA1-Digest: 44wVmETjEVTaPXOTi267RXKza2U=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UIBrowseWidge\r
+ t.class\r
+SHA1-Digest: ez+cdU9a5pKme107Kk8uxdGaS/0=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractLangsListTab$6.class\r
+SHA1-Digest: Df3UdSVPw+BoQqZG+VeQQYBuh0U=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CDocumentProvider$ProblemMark\r
+ erUpdater.class\r
+SHA1-Digest: Y+ZBGKxveaIOurltlbizBiA9dwA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CContentOutlinerProvider$Elem\r
+ entChangedListener.class\r
+SHA1-Digest: 9iEhR6IvgmaXu2I77bTgz/Y/sq8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/ConstructedCEditorMessages.cl\r
+ ass\r
+SHA1-Digest: iRnANY37lToSH/eElaIbfkg7b1k=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$27.class\r
+SHA1-Digest: oM8c1Q/4MsTLlMhrr5P1/gwe2fA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlo\r
+ ck$4.class\r
+SHA1-Digest: Jx1M5D3f34JmiaX/xlY1CRXwfKo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathEntryMessages.pr\r
+ operties\r
+SHA1-Digest: QCoxvBbzkvToy8xRBHkRBoKkRB4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/ProjectSelectionDialog.c\r
+ lass\r
+SHA1-Digest: xkjsJcFWSGj/25pa0u5mKHOqIeM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/ExternalEditorInputFactory.clas\r
+ s\r
+SHA1-Digest: OrElRv8l9r8OaLN4Ar0GkXSV0BY=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/IndexerBlock$3.class\r
+SHA1-Digest: Fnx0PcQy7vKGjQzBi2JQUZFd9qQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/ProblemHover$ProblemInf\r
+ o.class\r
+SHA1-Digest: XL884X8wmdL05N9ChSwDjXbttyc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectInde\r
+ xExportWizard.class\r
+SHA1-Digest: wJxT51q0tmgi8ehSSEqjsk63ZsM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/CCompletionPropos\r
+ alComparator.class\r
+SHA1-Digest: p+VVeXQHHKu6hIQEPpJrnP2+/xI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/SelectAllAction.class\r
+SHA1-Digest: lBHJxkfMuiQeDjiQ+INGqerMFDc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/CStatusConstants.class\r
+SHA1-Digest: 2PMpNMkzGgo0LHxYPRlNFOI6aVg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dnd/PluginTransferDropAdapter.class\r
+SHA1-Digest: Em6ctblWhJfpGa1b6/U42MYO27E=\r
+\r
+Name: org/eclipse/cdt/internal/ui/indexview/IndexView$Filter.class\r
+SHA1-Digest: 1UwM/BQVu2MAnBoFFEmDjXcObQ4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBloc\r
+ k$3.class\r
+SHA1-Digest: 5sJ9J7QWkRzY6sxuOazeOnXvd58=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlo\r
+ ck$TodoTask.class\r
+SHA1-Digest: U9vln4SkkAIl9/HyU/VhZ8blCJE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob$3\r
+ .class\r
+SHA1-Digest: p2tQEAbXih2lhExU4N7NnIPmLKg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameLinkedMode$\r
+ ExitPolicy.class\r
+SHA1-Digest: nJy0b32xFL6WIsdnQHIYIdjmhZc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/PathEntryVariablesGroup$\r
+ PathEntryVariableElement.class\r
+SHA1-Digest: Bl3F3jM17uIL+X9i2bf7kh5sEn4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/RefactoringExecutionHelp\r
+ er$1.class\r
+SHA1-Digest: XgqQaEvGK5/P4SNjrnVPK5HGRcI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog.class\r
+SHA1-Digest: /ECLiHegSRnfeqRCCBhlJbOp8rk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsListD\r
+ ialogField.class\r
+SHA1-Digest: /X/xL/TegkszPxqkldYSxFMAcI0=\r
+\r
+Name: icons/etool16/newhfile_wiz.gif\r
+SHA1-Digest: pok7PLRjYDZQt88l7EU9ymjBURY=\r
+\r
+Name: icons/obj16/ar_obj.gif\r
+SHA1-Digest: CUR5YMCcRtO48SWVon0qnuxDtXs=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/ICPathContainerPage.class\r
+SHA1-Digest: 8z7ZER+QalS4b+UBVWu4czz9gN4=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ManageConfigDialog$1.class\r
+SHA1-Digest: y8O1s2RL8eX2PPKrHaubbA1e5Gw=\r
+\r
+Name: org/eclipse/cdt/internal/corext/util/Strings.class\r
+SHA1-Digest: IvDz64LQ8DIF32KqdT4VnX3s/Qw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/engine/RankedWordPropo\r
+ sal.class\r
+SHA1-Digest: OMVaULPXijcxpZtDGv8vhUZvTR8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/PreferencesAccess$Workin\r
+ gCopyScopeContext.class\r
+SHA1-Digest: Se395t3CXldnbHHLveCaCMZdlFc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/PathEntryVariableDialog$\r
+ 4.class\r
+SHA1-Digest: 3O/LlcscLPdWHdwBxMonLmf6iKE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/AbstractWizardDropDownAction\r
+ .class\r
+SHA1-Digest: lXHQtnW5pqAMacq19bnaF06JNrE=\r
+\r
+Name: org/eclipse/cdt/ui/newui/SymbolDialog$1.class\r
+SHA1-Digest: YI/EmvxEAvDXPOofobYJ6RBWe0M=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$ExclusivePositionUpda\r
+ ter.class\r
+SHA1-Digest: qeBLP7mDMgUwroL43FCLBFehRhg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/AbstractCompareViewerInformatio\r
+ nControl$1.class\r
+SHA1-Digest: i4PY+vmBwgbww2090CVX2VZmvys=\r
+\r
+Name: icons/obj16/structfo_obj.gif\r
+SHA1-Digest: X6XOj58emtP95g2yUzaDw73OmBg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CCompositeReconcilingStrategy.c\r
+ lass\r
+SHA1-Digest: aRLtD1LqjQ2PaaoqsiHrZsWKNjc=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/ReferenceBlock.class\r
+SHA1-Digest: lX+ardsvrpPxX+3fF2cQmOOVVdc=\r
+\r
+Name: org/eclipse/cdt/ui/text/IQuickFixProcessor.class\r
+SHA1-Digest: T1LXJj0n4bemU04WCHMAM6ihWbk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/PDOMSearchLabelProvider.class\r
+SHA1-Digest: ghr6hEnV7pWcwP7coPkeNwjz3pE=\r
+\r
+Name: org/eclipse/cdt/ui/actions/OpenAction.class\r
+SHA1-Digest: bP4EY47hSYS2NcEpntJTgop6qWs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/PDOMSearchTreeLabelProvider.c\r
+ lass\r
+SHA1-Digest: LkHeEX6zd1mnsDITElexCByS4ew=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileCrea\r
+ tionWizardPage.class\r
+SHA1-Digest: LcNXpTMF1kHTY1Rz9RI7LKC40cU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/AbstractPreferencePage$1\r
+ .class\r
+SHA1-Digest: JhYreQdPgwG4QlLydY1lQzALH88=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/AbstractWizardDataPage.class\r
+SHA1-Digest: SoehUe5RBU69xDTk2uzV5LHQMf0=\r
+\r
+Name: org/eclipse/cdt/internal/corext/fix/LinkedProposalModel.class\r
+SHA1-Digest: jrS4lmVfVTx6YuVOSmAKPPZw5E0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/IndexerStrategyBlock$1.c\r
+ lass\r
+SHA1-Digest: Y1q8T/o/+sj/pFcbaRHatvZxI8k=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/RebuildIndexAction.class\r
+SHA1-Digest: 3LzNfxWO6NW3zWkbrl6vWuGDAqY=\r
+\r
+Name: icons/obj16/namespace_obj.gif\r
+SHA1-Digest: IvT7C1QiXmOZcLVwo5hXRta1oFU=\r
+\r
+Name: org/eclipse/cdt/ui/text/doctools/IDocCommentOwner.class\r
+SHA1-Digest: 5j6cAuxnhCN1949O+oSXG9lhcig=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/utils/TranslationUnitHel\r
+ per.class\r
+SHA1-Digest: AGsxwFd3ye6+hZ3R759QneVjFQ8=\r
+\r
+Name: org/eclipse/cdt/ui/ILanguageUI.class\r
+SHA1-Digest: G0cUxMrgAGc03UtKWOqnq5f5Npg=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/ICOptionPage.class\r
+SHA1-Digest: bqKElY0DlqArsqHIzvR/lxqFPMI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Getter\r
+ SetterInsertEditProvider$AccessorKind.class\r
+SHA1-Digest: F03DtbyuIN2c2F0bKdKCRT1Mx7E=\r
+\r
+Name: icons/dlcl16/search_prev.gif\r
+SHA1-Digest: T3L8e1sNqbDjz7KGvcvnzBCTKaQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/ShowErrorAction.class\r
+SHA1-Digest: qvfTqvk7bX7Y9dMAERCIjre+lVA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dnd/ResourceTransferDragAdapter.clas\r
+ s\r
+SHA1-Digest: CKmHuOObU8xvrRMP9a1aaLQsHrU=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/DocCommentOwnerComposite$1.class\r
+SHA1-Digest: kw8RqPcsed4RbEfD+fW0UuL7QQc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$BracketLevel.class\r
+SHA1-Digest: tA3qy0SyvTsl2iHSfC0CpivFuNA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/implementmethod/MethodDe\r
+ finitionInsertLocationFinder.class\r
+SHA1-Digest: dueqQ7P7W5EertZFlcvcVWIL1dM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/CView$6.class\r
+SHA1-Digest: vgtOYUnhlx6LhZx6zMf6SMVK3As=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfiguratio\r
+ nBlock$2.class\r
+SHA1-Digest: N6zmh4KZyFoV5IrJzixQbC8T0wI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/NewClassCreationWizard.class\r
+SHA1-Digest: /2z6vAk7ulScMKpvhN2e/ZzLNL4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistProc\r
+ essor$3$1.class\r
+SHA1-Digest: BsxmiDXLk2jGyn2eNFCDmP5/P2w=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/PreferenceScopeBlock.class\r
+SHA1-Digest: 7IJ8D0xQABHTkTgX8ML2pC6dvZ4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButton\r
+ DialogFieldGroup$1.class\r
+SHA1-Digest: 3NdijwRwBJk6ul7RMZ9Dcr084o8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructur\r
+ eProvider$2.class\r
+SHA1-Digest: ddRPzX0cg/0u97205VBCvHu1nCc=\r
+\r
+Name: org/eclipse/cdt/ui/CElementSorter.class\r
+SHA1-Digest: 6+EUWdC+wvUd1bOU+vFuxKlF6Rc=\r
+\r
+Name: icons/obj16/enumerator_obj.gif\r
+SHA1-Digest: Hch1uySfv9yBsIx6Dumlh8ypRiU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/RemoveBlockCommentAction.cla\r
+ ss\r
+SHA1-Digest: +2rLkTJxTvAByxP1qE4yRc5Y2YQ=\r
+\r
+Name: icons/etool16/newc_lib.gif\r
+SHA1-Digest: jM+8ll7ZSKgXIc+BR1ktW+KZNjQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CSourceViewerScalableConfigurat\r
+ ion.class\r
+SHA1-Digest: xtZJ33jJkKJYS4fg0ssxlwj5KO8=\r
+\r
+Name: icons/obj16/method_protected_obj.gif\r
+SHA1-Digest: yO3DL7gZmzMzN1lzBmUsP6rR2to=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/CRefactory.class\r
+SHA1-Digest: SLeLZ9c3pocR/QKjWvMXSB3k/eY=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractLangsListTab$RichLabelProvider.\r
+ class\r
+SHA1-Digest: Kl0mUBLJZmpJ+M78KMz+N5FBr8k=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/FileTemplateContextTy\r
+ pe.class\r
+SHA1-Digest: QG6frMPfnn1d5wgW51LBCf1ofxw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathTabBlock$BuildPa\r
+ thAdapter.class\r
+SHA1-Digest: A1pf28xCmYrPwthDwvwMETEzUeM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathProjectsEntryPag\r
+ e$ProjectsListListener.class\r
+SHA1-Digest: 1dCkcQC7KracgPIcVD51tj7ECFI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Genera\r
+ teGettersAndSettersInputPage$5.class\r
+SHA1-Digest: xRP93ZWWrMg2ISKduwTZt3lvmq0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Getter\r
+ SetterNameGenerator.class\r
+SHA1-Digest: BuvJ9e2UfLJR4wpvNY7VeVVbyoE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialogTa\r
+ bPage.class\r
+SHA1-Digest: QyxOEUOTabJi/KzeWUdXlPcICRU=\r
+\r
+Name: icons/etool16/next_error_nav.gif\r
+SHA1-Digest: 8csvjXORPZ5x4hEHEofBCIMHPYM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/IProblemAnnotation.class\r
+SHA1-Digest: xVvohcu8IBdtot5/ty40NHHnb/8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ProfileVersion\r
+ er.class\r
+SHA1-Digest: uMvGtDSvSlAbDZXNmDShy/VluBM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/ExceptionHandler.class\r
+SHA1-Digest: ZgLr7taKFa2/zooc3xeyCaGxpWE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/StringDialogFie\r
+ ld.class\r
+SHA1-Digest: idfpJ8x7YRY4tSxWswpQrcVRToM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistProc\r
+ essor$1.class\r
+SHA1-Digest: rqxmbtF9na9KkDTda3IWcnm/Mw8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/dialogs/VisibilitySelect\r
+ ionPanel.class\r
+SHA1-Digest: v8ixW8YhushTodNNX4xIwCcB40s=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButton\r
+ DialogFieldGroup.class\r
+SHA1-Digest: +t6FutzvdbuC8zGkvLoLHLK9L/g=\r
+\r
+Name: icons/ovr16/path_inherit_co.gif\r
+SHA1-Digest: oTAy6yqLhByfILv+Y2uQh/IE4x0=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ICPropertyProvider.class\r
+SHA1-Digest: mV4bFiKNDACsz47OmyxCItqMcyQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractF\r
+ unctionInputPage$3.class\r
+SHA1-Digest: Lh1e2hap3uU3JJNZx9uETZACIG0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectInde\r
+ xExportWizardPage$4.class\r
+SHA1-Digest: 8Vvlrcbhcj2z8guhKhaaDRk0Jz8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/folderwizard/NewSourceFolder\r
+ WizardPage$RootFieldAdapter.class\r
+SHA1-Digest: Iu1SOnriFA4/WupvbNJi7u2hFvQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/navigator/CNavigatorContentProvider$\r
+ 1.class\r
+SHA1-Digest: 1wIkXaUVJulpXNWZn74DGVV/BYo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/filters/ForwardDeclarationFilter.cla\r
+ ss\r
+SHA1-Digest: q/40hanxyxZOK7mIBEJBe/u6SZM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/CRenameIncludePro\r
+ cessor.class\r
+SHA1-Digest: YZsA6WDVB3pE22LFp5PwE8UTmhY=\r
+\r
+Name: icons/obj16/keyword_obj.gif\r
+SHA1-Digest: svouEFPEv9Y/0QOdjpR4qAleV80=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceTabP\r
+ age$SyntaxComponent.class\r
+SHA1-Digest: qI6QoKFl8+VeR2Y9xndTpSGenKI=\r
+\r
+Name: org/eclipse/cdt/ui/actions/ChangeBuildConfigActionBase.class\r
+SHA1-Digest: 8iiSnYvXDL2/QH06zxgkNYJrO6M=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/EditorUtility.class\r
+SHA1-Digest: /TRt7Lp9O4cPV0IglqLELRWVMVI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$20.class\r
+SHA1-Digest: DQJP2ICTQEPMN80BJqOpsOIjET0=\r
+\r
+Name: org/eclipse/cdt/ui/text/IInvocationContext.class\r
+SHA1-Digest: fLCIfr7kHPG/riKNVfs9qaIbYUI=\r
+\r
+Name: org/eclipse/cdt/ui/CElementContentProvider$1.class\r
+SHA1-Digest: KTxROfA00XJ38x4OZrsPtgA+WdI=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/TranslationUnitContex\r
+ tType$Arguments.class\r
+SHA1-Digest: Y3Gdekt7su45vAYLjn53uwt9Ge0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/NameStyleBlock$NameValid\r
+ ator.class\r
+SHA1-Digest: ec6Y6kTqi+DPLRaQkEWrq7WcfRM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfiguration.\r
+ class\r
+SHA1-Digest: hMmEuTa87e18l58CwW/zQp0bd14=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefNode.class\r
+SHA1-Digest: eMITaPH7L6NP8RLOl86agKAyfOg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CHoverMessages.properti\r
+ es\r
+SHA1-Digest: /oeUi8o4/KELCAXxQrCUBmmbHWQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/dialogs/CTextEditChangeP\r
+ reviewViewer$CTextEditChangePane.class\r
+SHA1-Digest: r7K2b3EbDkrDI/0coDC5elqaaKs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/LibraryRefContainer.class\r
+SHA1-Digest: xadyYhmn2Al2ELB5oRH/AFYW5yU=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/AbstractGNUBinaryParserPage.class\r
+SHA1-Digest: HHp0lFBfgsctVe2c6M/9D5i+HSc=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/CygwinPEBinaryParserPage$3.class\r
+SHA1-Digest: G1nP38jH6j62YLBFFhM+npulsoc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$14.class\r
+SHA1-Digest: 25QSJgCcZSG2fCreSToFGxhr0U4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$8.class\r
+SHA1-Digest: 6otc0Vi55tpuP5hd6OqjsgCP1Bk=\r
+\r
+Name: icons/elcl16/wordassist_co.gif\r
+SHA1-Digest: WpYGr6/zGF8jxD/vmC2nbZjWA6Y=\r
+\r
+Name: org/eclipse/cdt/ui/refactoring/CTextFileChange.class\r
+SHA1-Digest: WVH8RmOZos9ff60ntLqIKaZdZ+Q=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/PendingUpdateAdapter.class\r
+SHA1-Digest: Dz6bTB6xdDF1nzjyuGtlkLMpY50=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/PropertyAndPreferencePag\r
+ e$2.class\r
+SHA1-Digest: cU9KmwGR9L+6+TsTrJpZO9KQHjo=\r
+\r
+Name: org/eclipse/cdt/ui/refactoring/actions/GettersAndSettersAction.c\r
+ lass\r
+SHA1-Digest: isyQ+4mA3XgibzBfmFP56eLfn4I=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/messages.properties\r
+SHA1-Digest: ZTcWOPA2s16PqFvbhXJpna+BX1k=\r
+\r
+Name: org/eclipse/cdt/ui/text/ITokenStoreFactory.class\r
+SHA1-Digest: OjutB+VEb2x8LWAXMcrE72RQ/n4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CTemplatePreferencePage$\r
+ CEditTemplateDialog$1.class\r
+SHA1-Digest: D4BxJGV8aqAddSU1QWAjPIBYg3g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/TabsToSpacesConverter.class\r
+SHA1-Digest: vm7emzCOExEdUTIczP5yPRVkwA0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/doctools/DocCommentMultilinePro\r
+ posalComputer.class\r
+SHA1-Digest: cfE7NzrXvoCi4MNCuevHT/kLqVE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/BuildConsole.class\r
+SHA1-Digest: 4FHLpTmpfogi016l+nRtDwRj8MI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/help/CHelpBook.class\r
+SHA1-Digest: Z4Z8x3NV0BypukKdj2Ko06/CiQw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/BlockCommentAction$Edit$Edit\r
+ Factory.class\r
+SHA1-Digest: FJTpCe/92vCQe+8vyBXQDDZ8rRM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CSourceViewerDecorationSuppor\r
+ t.class\r
+SHA1-Digest: LWr7Jbq9RMW4Npc1DL5hcvtRuxk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/InactiveCodeHighlighting$1.cl\r
+ ass\r
+SHA1-Digest: CwxssUDlakoXFF/S7EkzaU5WOtg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/LinkToFileGroup\r
+ .class\r
+SHA1-Digest: LQiTLwo7KnXlidBgOMiMhnQdIkY=\r
+\r
+Name: icons/etool16/newfolder_wiz.gif\r
+SHA1-Digest: UJ9nAklqg9UDmmodF7ph1bDQRQY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigsControl\r
+ ler$3.class\r
+SHA1-Digest: MZXIIalXfp/8OtWU5WIGbDSHTVY=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UITextWidget.\r
+ class\r
+SHA1-Digest: 35O4O00r50XAHer0mdDxIgNUC4c=\r
+\r
+Name: org/eclipse/cdt/ui/text/AsmSourceViewerConfiguration$1.class\r
+SHA1-Digest: LrxQDLwxYrL1HxujMEd7ec/qZz8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/AbstractAnnotationHover\r
+ $AnnotationInformationControl$5.class\r
+SHA1-Digest: x7SLRnCs5NiCnnJS7tNLxISQ838=\r
+\r
+Name: icons/ovr16/relatesto_co.gif\r
+SHA1-Digest: dNvPhpNxRkL3wnppMGK2EttUJgk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformation\r
+ Popup$3.class\r
+SHA1-Digest: ez+yERJgZf7B6K9uQwiU2mno110=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/IndentationTab\r
+ Page$1.class\r
+SHA1-Digest: unJnaw4eH+kvqY0LFdLkBE3F7CA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactorin\r
+ gInputPage$2.class\r
+SHA1-Digest: 9wxoM2eDOBYpmO4aY69h1Cy/CjA=\r
+\r
+Name: org/eclipse/cdt/ui/CElementLabelProvider.class\r
+SHA1-Digest: 6KcQiQt9EwnTtHjbpYBEZwY6Ba0=\r
+\r
+Name: org/eclipse/cdt/ui/CDTUITools.class\r
+SHA1-Digest: dR33o1+3DHbaT2qy6KIulqpQGyY=\r
+\r
+Name: icons/wizban/typerefact_wiz.gif\r
+SHA1-Digest: 1rAEH72h54lky9C1ahpErR+IpHc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/indexview/IndexNode.class\r
+SHA1-Digest: VK4UmlHr3mMHZ7L9R3gd/nHNyek=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/CHelpConfigurationPropertyPage.class\r
+SHA1-Digest: nnJCmaxKCVESAnAK3UM1HWwuHEM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/togglefunction/Messages.\r
+ class\r
+SHA1-Digest: Xgcy1k+NmxrxNM/ulojYg8YjnP4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/Ext\r
+ ractLocalVariableRefactoringContribution.class\r
+SHA1-Digest: bTk6z4O0uWQr4v3BNayB0bFfNEg=\r
+\r
+Name: org/eclipse/cdt/ui/text/CSourceViewerConfiguration$7.class\r
+SHA1-Digest: 40jOBf7dEioqv2JNO3Lc/77IgeE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$SelectPreviousSubWord\r
+ Action.class\r
+SHA1-Digest: RxetTyf+DLUDiX0PDL+Uz6+qa5s=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryAction.class\r
+SHA1-Digest: NofIfZtA1yW2eEag+Eqfvhwhw00=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/MultipleFolderSelecti\r
+ onDialog$1.class\r
+SHA1-Digest: zh/5X3bQZFYDtbyFOwOlmOM8H/I=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/pages/UIWizardPage.class\r
+SHA1-Digest: ZUzEqFpgMKQ465zUzFM0pRHUCrM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/LexicalSortingAction.class\r
+SHA1-Digest: L9VCnZn+nBE8KahnGFcPoEZimcE=\r
+\r
+Name: icons/obj16/correction_rename.gif\r
+SHA1-Digest: ZcpDjYDeEJOJmkORmgqZmjSTWlw=\r
+\r
+Name: icons/obj16/cfolder_obj.gif\r
+SHA1-Digest: FqxWDk18RgbYI+FKO7aa1lGJlFE=\r
+\r
+Name: org/eclipse/cdt/ui/text/ICHelpInvocationContext.class\r
+SHA1-Digest: 3zwiT0SIH1yD6NxZDkf+r2mRtdE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/DeleteResConfigsHandler$ResC\r
+ fgData.class\r
+SHA1-Digest: o2cLqKti3YK3QECCwHzWiyX2tz8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfig\r
+ urationBlock$5.class\r
+SHA1-Digest: 8PURlRQa8tu0/UvcMjmypHBEyZc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingWidge\r
+ t$3.class\r
+SHA1-Digest: liGWJmfX2Z+LZWR4kWxfUK5sUiI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/AbstractInformationControl$Name\r
+ PatternFilter.class\r
+SHA1-Digest: 3ChYrSHS0QxmPx0GxEEXYcfD7BQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBViewPart$6.class\r
+SHA1-Digest: UUIXByMT3VW1tbZbQMJKdTQh0G4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/engine/AbstractSpellDi\r
+ ctionary.class\r
+SHA1-Digest: MSQxBavg2noDyNwIPwMCDzmiVVY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/BufferedDocumentScanner.class\r
+SHA1-Digest: eG5AcGLKhDxoNF1nzBQTvy2SsxM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage$4.\r
+ class\r
+SHA1-Digest: d8Zx6Hc8DLiJE+vZgyGCVmbZiq4=\r
+\r
+Name: icons/obj16/never_translate.gif\r
+SHA1-Digest: JM7bCdPDq2mNvyXguU9KlfcuMLs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialogTa\r
+ bPage$RadioPreference.class\r
+SHA1-Digest: ma5OMFSrpHFqrtHBovBrEfBuhlo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.prop\r
+ erties\r
+SHA1-Digest: Zy6C/lS8gVas2aWV1TSa4bzVZh4=\r
+\r
+Name: org/eclipse/cdt/ui/CElementContentProvider$RefreshContainer.clas\r
+ s\r
+SHA1-Digest: Wzjg5NkbDaCTbGfMEVv0ayVygRo=\r
+\r
+Name: icons/obj16/field_protected_obj.gif\r
+SHA1-Digest: Hkl/yUZad//SMJG0+sBrouTidKA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/implementmethod/Implemen\r
+ tMethodRefactoringWizard$1.class\r
+SHA1-Digest: EAqQlcdzwZkm1/aSjEr3RPC1k5o=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.class\r
+SHA1-Digest: Oi/uD59JIcvWyJju7fb6CROOgxY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuActi\r
+ on$5.class\r
+SHA1-Digest: jlLGwl+vlqT5/OpOED2C1KZ1lGk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/ICDTCommonProjectWizard.clas\r
+ s\r
+SHA1-Digest: 6rpRHI5GAHnDSLjuwapsUZptfuY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SourceHeaderPartnerFinder$Par\r
+ tnerFileVisitor.class\r
+SHA1-Digest: kGqjaaMFkA7i2iXs9Jbe0vlCXz4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction.cl\r
+ ass\r
+SHA1-Digest: yXmQm/GCW1xtQmxUv+FoNW3gnMw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPref\r
+ erence$1.class\r
+SHA1-Digest: 8Pk35BaieC2yMLhjBVh/6KCtJXM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/EqualityChecker.class\r
+SHA1-Digest: 1L35+RbYQcSU3+vovhdnjtxf/JU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/RefactoringASTCache.clas\r
+ s\r
+SHA1-Digest: X6qei6gktBT1wUSwgTmaOXMgryo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBViewPart$12.class\r
+SHA1-Digest: D7pDAa6G2wtv7Nd7Roj7n1gxsek=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructur\r
+ eProvider.class\r
+SHA1-Digest: 0iOlkIOwpo857ptZiv3Mo6igiU0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultPhonetic\r
+ HashProvider.class\r
+SHA1-Digest: 8CtePzwUudvho5+ii5NOeW15X6w=\r
+\r
+Name: org/eclipse/cdt/internal/ui/build/BuildPreferencePage.class\r
+SHA1-Digest: 5p/zvlpr2109K9BM4/t3DTL1P48=\r
+\r
+Name: icons/elcl16/list-edit.gif\r
+SHA1-Digest: betzFn9bVmegRFFcfhL/82aICRU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/AbstractElementListSelection\r
+ Dialog$2.class\r
+SHA1-Digest: LTLtABz+PYkmELf41qUKJFYcjRw=\r
+\r
+Name: org/eclipse/cdt/ui/browser/typeinfo/TypeInfoMessages.class\r
+SHA1-Digest: u//K4Akw4IN12YLRDrBG8rRAoUQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/AbstractAnnotationHover\r
+ $HoverControlCreator.class\r
+SHA1-Digest: 0La+YaTuIeh0pz3wkNZR7Oqde9Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/AbstractInformationControl$2.cl\r
+ ass\r
+SHA1-Digest: h6RZ55wVl7IfLbdpMUi+IxK+rJA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/StatusLineHandler.class\r
+SHA1-Digest: r56eHyb9M4Hcq48BIgaz1egVmyU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/TableLayoutComposite$1.class\r
+SHA1-Digest: no7irFjEZtbsODnC9baxmAdwMW0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEnt\r
+ ryPage$IncludeSymbolAdapter.class\r
+SHA1-Digest: EkAXJ2RdHUc/cTUw0C67o0vM59g=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/pages/TemplateInputDialog$1.cl\r
+ ass\r
+SHA1-Digest: M7wQeeT4EA3l14nAwks6KfDDdDw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/OverrideIndicatorManager$Over\r
+ rideIndicator.class\r
+SHA1-Digest: vRj6WqOn2SQRblf76qvE8vlByGw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/AbstractMixedPreferenceP\r
+ age.class\r
+SHA1-Digest: BFPA0xVABzJ0sFAIPBMJ9QDLK9Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/SourceAttachmentBlock\r
+ $SourceAttachmentAdapter.class\r
+SHA1-Digest: VPi+3QZwfdEh9c2zT6rt7Kvbv74=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction$R\r
+ equiredInclude.class\r
+SHA1-Digest: gDx1wdToL/3sYeH4Ae08kH/oKPk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/resources/ResourceExclusionContribut\r
+ or$1$1.class\r
+SHA1-Digest: G3mlkN3NAElSykcrbRI6cxh6PxI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBWorkingSetFilter.cl\r
+ ass\r
+SHA1-Digest: 9ufDA/UQ3US7yMjL5nyHwCEHXIU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfig\r
+ urationBlock$ModelElement.class\r
+SHA1-Digest: ji+iQXHg+DEZgvxoTUYO8MhsbAU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/AsyncTreeContentProvider\r
+ $3.class\r
+SHA1-Digest: vMXcFtWJSuTIT7pB+pjisYtGItw=\r
+\r
+Name: org/eclipse/cdt/ui/text/ICCompletionProposal.class\r
+SHA1-Digest: DgkCY5BV/9Z5DkiYW14kUWNaIcQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassInfo.cl\r
+ ass\r
+SHA1-Digest: JX7jiYfNl9RjRwJSfo4npxtxoCA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/IContainerDescriptor.\r
+ class\r
+SHA1-Digest: RUPMbcVEgiPA7HE2lIfHsF3Tn88=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CDocumentProvider$ProblemAnno\r
+ tation.class\r
+SHA1-Digest: /tKYiJ2WhE1NRJpvm7BQScGkqys=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ControlStateme\r
+ ntsTabPage.class\r
+SHA1-Digest: J8mLh2I1I+SBtHUKPgrXH+P8tzw=\r
+\r
+Name: icons/ovr16/inactive_co.gif\r
+SHA1-Digest: tSZMlreTvZp1ITszYJMjcboFbsM=\r
+\r
+Name: org/eclipse/cdt/ui/actions/MemberFilterActionGroup.class\r
+SHA1-Digest: 0fv3TJtLQgM7jpwhO6lpGR92m0g=\r
+\r
+Name: icons/elcl16/history_list.gif\r
+SHA1-Digest: 26C+PIcO7vP3WgzFdcx4Yxb7H3g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/ICHelpContextIds.class\r
+SHA1-Digest: qPOMWxJghymA6hSi+PaKHmUwqVA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/Ext\r
+ ractLocalVariableRefactoring$1.class\r
+SHA1-Digest: KewnF58+F1eixblnGwyDd0XtN98=\r
+\r
+Name: templates/default-codetemplates.xml\r
+SHA1-Digest: Suup2oETp7apM1bgbtwsH5n54lU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultSpellChe\r
+ cker.class\r
+SHA1-Digest: x3sY1zz6nog2pzfcvcTu0IJkCPA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEnt\r
+ ryBasePage.class\r
+SHA1-Digest: ghb56MZ2wlsHq2D1nTxJ8AeOcrY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionExplorat\r
+ ionControl$1.class\r
+SHA1-Digest: +fz9NPAJsoHDrZYItSZppQbHvYo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/AbstractCEditorTextHove\r
+ r$2.class\r
+SHA1-Digest: /49zG27KxiSDUvWRWRvce7qO2c4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/indexview/IndexAction.class\r
+SHA1-Digest: ix8a4BB9mMn0O1NC7lqp8Mzs4DA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/CDTContextActivator$Sele\r
+ ctionListener.class\r
+SHA1-Digest: XKXe9oSlzOz3aSMZr1w0fpO5JXQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialogTa\r
+ bPage$NumberPreference.class\r
+SHA1-Digest: THuHNi3TcFaCoHZ4qkRs87YBXxw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/ChangeExceptionHandler$R\r
+ efactorErrorDialog.class\r
+SHA1-Digest: B2b0tAsuR9IxMpcZpadozqbp6OU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dnd/DelegatingDropAdapter$3.class\r
+SHA1-Digest: /Kz2OT5nIdKfXzldOYy9c4bqjYI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/IncludePaths\r
+ SettingsProcessor.class\r
+SHA1-Digest: KnK7Dy/P6w/ohrvBwrdNrivepjE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/TextSearchWrapper\r
+ $1.class\r
+SHA1-Digest: TbN1OMNj6EOUY7RSfp8RTP5YKrI=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ProjectContentsArea$2.class\r
+SHA1-Digest: u4LCAGPEAnJNopx4HE5gxO4Kg7E=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameSupport.cla\r
+ ss\r
+SHA1-Digest: IHPWHlgFSGpegmCE9ObkSj4ihxY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/navigator/CNavigatorRefactorActionPr\r
+ ovider.class\r
+SHA1-Digest: 2h7TDhzS8bRxNm/RBVHa+6On3m4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CReconciler$PartListener.class\r
+SHA1-Digest: 4IISo/AjUYqdulmffUtLbzZ/UZo=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/conversion/ConvertProjectWizardPage$P\r
+ rojectContentProvider.class\r
+SHA1-Digest: mZsHZAc0WvNTcxCe8ruF6KieEUM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/CSearchMessages.properties\r
+SHA1-Digest: zTF9STy/HtP1HgS34qmU0EhVXAw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/ISettingsPro\r
+ cessor.class\r
+SHA1-Digest: ZbBmC2q2e90q3a9xyTxMtRVXDeE=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/uitree/UIGroupTypeEnum.class\r
+SHA1-Digest: w4JJ+GBZ3KbP7DMcP/GcNFW5Ty0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THSchedulingRule.class\r
+SHA1-Digest: 27jIxRvxGrAsDh7XKsyH8Da8XMU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/RemoteTreeViewer$ExpansionJob.c\r
+ lass\r
+SHA1-Digest: CbFSN/vDB2y8ldi551sq0lUI7Rg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/filters/CustomFiltersDialog$6.class\r
+SHA1-Digest: ebSz2EOAXeE3Ohv1uSKscAcF6SM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/ExtendedTreeViewer.class\r
+SHA1-Digest: ti41xJ3X7n8LjueTUQhOg578HB0=\r
+\r
+Name: org/eclipse/cdt/ui/IBuildConsoleManager.class\r
+SHA1-Digest: YWcvCcW8sKn/O5YAV4S2sujz6Gc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$IndexUpdateRequestorJ\r
+ ob.class\r
+SHA1-Digest: thHyH7BnA9QZjSywvmFVMxkRYHU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/ScrolledPageContent.clas\r
+ s\r
+SHA1-Digest: l8DXGO+nZ4uh9fpyiBX9dcV/R1Q=\r
+\r
+Name: org/eclipse/cdt/internal/ui/CUIStatus.class\r
+SHA1-Digest: m2yZbENVF6s9UZAsIPlU2XeNGaw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction.c\r
+ lass\r
+SHA1-Digest: FiaXAx+/1TmUdM3IY1FXHOVhEnU=\r
+\r
+Name: org/eclipse/cdt/ui/newui/StructureTreeTab$LevelDialog.class\r
+SHA1-Digest: AXohyxK4/tg+0/+Ha0PRn7bUMoE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$1.class\r
+SHA1-Digest: QmcS8V+CNys9lZqX0gf+1acLBo4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CHeuristicScanner$NonJavaIdenti\r
+ fierPart.class\r
+SHA1-Digest: Q4VcnMUSwZsirRj09+YEjl80HOE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$GotoMarkerAdapter.cla\r
+ ss\r
+SHA1-Digest: nLNK34yP8zHpv+VQwpny1hHwMq4=\r
+\r
+Name: icons/view16/members.gif\r
+SHA1-Digest: 5CgQ5Qto1X3RfB9ujXTBxhbgHco=\r
+\r
+Name: org/eclipse/cdt/ui/newui/EnvironmentTab$3.class\r
+SHA1-Digest: tKOHcWRFsBOhLWW5u9z0DbJnukM=\r
+\r
+Name: icons/obj16/macros_file.gif\r
+SHA1-Digest: 0yQgcSyzAdhaWC7z+0N08ntqBqI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileGene\r
+ rator.class\r
+SHA1-Digest: f6DWjDN+7BQ+kg+/sZJv4MUKBPM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialogTa\r
+ bPage$NumberPreference$1.class\r
+SHA1-Digest: 55l4rBCShq7c0RY7jNyTPUMUrnY=\r
+\r
+Name: icons/elcl16/filterDefines.gif\r
+SHA1-Digest: 7B336kTr2z0q0VbQLmY7/FQ91A8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/CSearchMessages.class\r
+SHA1-Digest: z+O7hn08gxR4HQ6MvDk3qSgHMXs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformation\r
+ Popup$7$1.class\r
+SHA1-Digest: 1yZy00B/OAUIU2pV4HzcPCfuHG0=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UISelectWidge\r
+ t$1.class\r
+SHA1-Digest: 8vfjvzlaLO4fQyuWwBsRW3L482s=\r
+\r
+Name: icons/dtool16/newcc_app.gif\r
+SHA1-Digest: /S3AManCmOCLVqzgLpTgo+Hxzzc=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/AbstractErrorParserBlock$FieldListene\r
+ rAdapter.class\r
+SHA1-Digest: 9tTjVFuCP5UedmFbDeDcShRIrqQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/FileLanguageMappingProperty\r
+ Page$3.class\r
+SHA1-Digest: 609ZcCXyy9XjfRAqxL04ZjVCkr4=\r
+\r
+Name: icons/obj16/debugt_obj_b.gif\r
+SHA1-Digest: bHjpFpp4QzNwqs1kcGZwMakN/Kw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/RefactoringSaveHelper$1.\r
+ class\r
+SHA1-Digest: JxhSh+IvHEOQ0LOMDmZ9gPsvH0I=\r
+\r
+Name: icons/elcl16/definingtype_sort_co.gif\r
+SHA1-Digest: iarhJC6sp7CeiC/X5xYbVeB4i3A=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage$1.clas\r
+ s\r
+SHA1-Digest: 1zOjxGLbIRMDuEeTDPAd7I9S+W4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/OverrideIndicatorImageProvide\r
+ r.class\r
+SHA1-Digest: nTNO49htpl6nh5ltQr3pessWvS0=\r
+\r
+Name: icons/dlcl16/impl_co.gif\r
+SHA1-Digest: skFVXZJW65LJ+SXNlEAa+pqt7f0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.cla\r
+ ss\r
+SHA1-Digest: U2e77efe+dcvt91/vziIgzSHg+g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/NewFolderDropDownAction.clas\r
+ s\r
+SHA1-Digest: r2SU7EJHPx0X02nO6Wxj5gtcaWQ=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/event/PatternEventListener.cla\r
+ ss\r
+SHA1-Digest: xF+U9+uXHFPcbFWqt7ZU/BktQH0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Genera\r
+ teGettersAndSettersRefactoring$CompositeTypeSpecFinder.class\r
+SHA1-Digest: DBxsOiAgwIkTKuzq/+BKcDxeiko=\r
+\r
+Name: icons/obj16/method_public_obj.gif\r
+SHA1-Digest: /7Dfxu3TApYuV0jK7Fszug5lQ0I=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/CountLabelProvider.class\r
+SHA1-Digest: SWaPDGH54H8VLe7iacxLcy2nfao=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog$3.cla\r
+ ss\r
+SHA1-Digest: EX/fVdOgiVxQ+RL0N6pmPEC7hkY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/AbstractCEditorTextHove\r
+ r.class\r
+SHA1-Digest: CGZjFaXPyUeKzMCYCm+K4KcU3SI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/togglefunction/EmptyRefa\r
+ ctoringDescription.class\r
+SHA1-Digest: 1uhTg7QoKs+S80l8gu1ZPl0egtc=\r
+\r
+Name: org/eclipse/cdt/ui/actions/GenerateActionGroup.class\r
+SHA1-Digest: uXo2r5dcsDBs+pnrz4xGSo8Izzo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/indexview/IndexView$4.class\r
+SHA1-Digest: wvCn4zIFzhWsonc3aU3tnvjS7E4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/togglefunction/NotSuppor\r
+ tedException.class\r
+SHA1-Digest: zHV4geGZGEJ83KRd2fkXIR2/+Cc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/FastCPartitioner.class\r
+SHA1-Digest: A+ZcEBBHNWg1Bo78ZdmC+HxcbfU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/EnclosingClassSe\r
+ lectionDialog.class\r
+SHA1-Digest: /W908bkNPkg9+r0TJz842H3Mf2g=\r
+\r
+Name: org/eclipse/cdt/ui/newui/MultiLineTextFieldEditor$1.class\r
+SHA1-Digest: 918KtWp31sCewZ1Br4dmecGIPxg=\r
+\r
+Name: icons/obj16/function_obj.gif\r
+SHA1-Digest: iXIpHbrucaILJNSfPBW8P2ihCHM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/CCorrectionProcessor\r
+ $SafeHasAssist.class\r
+SHA1-Digest: 13vVq7qCH3he60arqDk/xX/oLKg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightings$StaticF\r
+ ieldHighlighting.class\r
+SHA1-Digest: 2LmKRMc0GzZwFJmbJLUgjxWQqIo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHReferenceInfo$1.clas\r
+ s\r
+SHA1-Digest: MOzQOZnOM5RNCDXZ2KhDAa3goB4=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractCPropertyTab$2.class\r
+SHA1-Digest: PE53OjgdJ3Y0irALfokJ+E5zxLc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessa\r
+ ges.properties\r
+SHA1-Digest: 56Q+BKIrXpI0l3R6PaCk+r88xDs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/WorkInProgressPreference\r
+ Page.class\r
+SHA1-Digest: L1q9W/hmKQJJC+6bEAAIA55BnM8=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/FormBrowser.class\r
+SHA1-Digest: JlHwEw4jFIWwrZI239G6QnsvliY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreat\r
+ ionWizardPage.class\r
+SHA1-Digest: sVm3DkAPm7nTD4LhGjXd/U1iX5M=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/IWorkingSetConfiguration\r
+ .class\r
+SHA1-Digest: lzau5evA61tg9AJZvCBejlaSMVs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRef\r
+ actoringWizard.class\r
+SHA1-Digest: Wk5GnLJ0lV0y7HPuojeuB8dlwJQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeAction.clas\r
+ s\r
+SHA1-Digest: BdHyE4egS3oGtpayFzIDnGzhxxI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHDropTargetListener.c\r
+ lass\r
+SHA1-Digest: vcxa/vXg1MPVKI5ESIDb8TqMpcg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/LinkToFileGroup\r
+ $3.class\r
+SHA1-Digest: 6qp/Y8H1chuHLDLwIKR8Sp1h26A=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/dialogs/CTextEditChangeP\r
+ reviewViewer$CTextEditChangePreviewViewerContentProvider.class\r
+SHA1-Digest: 77XD6kwOkL/3zYgT7wOEwa2WMyw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/indexwizards/StringVariableL\r
+ abelProvider.class\r
+SHA1-Digest: Nn6r9/RTz2I37WKqByW5ASU/pYY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/NewWizardMessages.properties\r
+SHA1-Digest: XPVNREEVOW5qy34qWR4EVrGWJIs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/Visibility$2.class\r
+SHA1-Digest: uydVyc6yuY3cvqO8vNKbZIFI2To=\r
+\r
+Name: org/eclipse/cdt/utils/ui/controls/FileListControl$ClipboardList.\r
+ class\r
+SHA1-Digest: 1PfRCo/mqM69JrRLgzXQZOlrGIg=\r
+\r
+Name: org/eclipse/cdt/ui/newui/IConfigManager.class\r
+SHA1-Digest: K0G9mG7G/gmvus4Gid2yu4smn50=\r
+\r
+Name: org/eclipse/cdt/internal/ui/navigator/CNavigatorDropAdapterAssis\r
+ tant$1.class\r
+SHA1-Digest: TX8oTaKCWGCWFjWt710CeV3p3Rc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/utils/NamespaceHelper$1.\r
+ class\r
+SHA1-Digest: FDvByaYKJbqEY1i6YvP1t9p9J8c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/AbstractToggleLinkingAction.\r
+ class\r
+SHA1-Digest: FmnYrChvjKW+87O950ILcMPf+LI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/navigator/CNavigatorProblemsLabelDec\r
+ orator.class\r
+SHA1-Digest: Tff5hL8kjEuvkiMIqfnD3Kz/vOc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightingManager$H\r
+ ighlightedRange.class\r
+SHA1-Digest: NFv/tC1PpZXnQzzagE1mCDCgMJ4=\r
+\r
+Name: icons/dtool16/mark_occurrences.gif\r
+SHA1-Digest: PVdECHU79ZkkZORJNQEUiudhJfo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/HelpCompletionPro\r
+ posalComputer.class\r
+SHA1-Digest: XDNGHbU5xNfp6Ex5EewnullRWJg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructur\r
+ eProvider$Tuple.class\r
+SHA1-Digest: p/cJ9p9QHrWMKMMUwZxq0rbmNC4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/WorkbenchRunnableAdapter$1.c\r
+ lass\r
+SHA1-Digest: ycvDIemk03i7FFuZXzz2po9S8TA=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/CDTMainWizardPage.class\r
+SHA1-Digest: nPKbgFitiMc+PkoQvs+ivkf/oeM=\r
+\r
+Name: org/eclipse/cdt/ui/newui/CLocationTab$4.class\r
+SHA1-Digest: UsuXJr2pd/5OmnnBPAfuVkhDojA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/asm/AsmCodeScanner.class\r
+SHA1-Digest: JVgQA0bi33Wy0gEhYJQTqwnRHwY=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/MachOBinaryParserPage.class\r
+SHA1-Digest: c+l3FQMXjhJ9aawfYLQLIfQgRS4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightings$Overloa\r
+ dedOperatorHighlighting.class\r
+SHA1-Digest: CUPjiXqx2BPas06AWQxluWeB1EE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsActio\r
+ n.class\r
+SHA1-Digest: 63C/U0ICLwsGV1Sn/cOF9Tmi26c=\r
+\r
+Name: icons/elcl16/codeassist_co.gif\r
+SHA1-Digest: m4febn8INswNBpeXLdUDaOsy9N8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart$7.class\r
+SHA1-Digest: VSHFtkrASktx7Xay/GdgxyvD6IM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistMess\r
+ ages.properties\r
+SHA1-Digest: C16cIEBIDvyfWWcRQurLZjnvCtM=\r
+\r
+Name: icons/ovr16/rec_relatesto_co.gif\r
+SHA1-Digest: RsH6U/fUZtFGE6wgrVS41hxlN80=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/StorageLabelProvider.cla\r
+ ss\r
+SHA1-Digest: mDLJwfJWZgtwjGXsD9KEiwqfD6g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/BaseCElementContentProvider.class\r
+SHA1-Digest: VB2Ig+AjjwwHus7Ypnbok50NNnI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellCheckEngi\r
+ ne.class\r
+SHA1-Digest: F/jCZA4prY6AQCSnTvh3NwNn7Po=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/CheckedListDial\r
+ ogField$1.class\r
+SHA1-Digest: c4Mior/hRE50OMilfR2bSLLEl48=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/togglefunction/Messages.\r
+ properties\r
+SHA1-Digest: 7Jl/cNfPgxsD1rxTHy4GdOYQL78=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/NewLinesTabPag\r
+ e.class\r
+SHA1-Digest: V7sQ6XC1SwFi+j5DNzLHN17o/80=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/ICAnnotation.class\r
+SHA1-Digest: ibf2rl+eneCTCOLUxf1ZP1zpmTg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/NewElementWizardPage.class\r
+SHA1-Digest: LCnOlNZ4H6e3y/wneHKvIDNek04=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CDocumentProvider$ReverseMap.\r
+ class\r
+SHA1-Digest: DlWYW5kfDLO7w8sndDuLoiFCsCc=\r
+\r
+Name: icons/obj16/extension_obj.gif\r
+SHA1-Digest: Z2OZk1zGHkMoKUiUg4yQs9yLbG0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/StructureSelectEnclosingActi\r
+ on.class\r
+SHA1-Digest: cpPFXS/YBhgbTpGH0eslJg709iU=\r
+\r
+Name: icons/obj16/classfo_obj.gif\r
+SHA1-Digest: LU3Q7rvP+JcSLzq/CrxyPM6BQi8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CDocHover.class\r
+SHA1-Digest: PC7y5k1Jt6xzltNt/VPUT1DQPpg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/PDOMSearchListLabelProvider.c\r
+ lass\r
+SHA1-Digest: W58JsCXUMwT99Bkjng2VYMBvMec=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconcile\r
+ r.class\r
+SHA1-Digest: 00AehEhAC4p3IaUyDEQwhcYrzII=\r
+\r
+Name: icons/elcl16/open_include.gif\r
+SHA1-Digest: 5uorTPM3yjxrRe97ZyoIACFwGG4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/indexwizards/Messages.class\r
+SHA1-Digest: tjplEVBg+kQYDLEYmp7LeS1prWY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigura\r
+ tionBlock$4.class\r
+SHA1-Digest: P9Xu/wogetnkMw2NdH7Dqn8mSLo=\r
+\r
+Name: icons/dlcl16/list-movedown.gif\r
+SHA1-Digest: I21gYQtio2nPwC5fBLTQpGcSJQ0=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/EntryDescriptor.class\r
+SHA1-Digest: YPZOydDJ2PQpAMZY8+K+c/INxMg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CHoverMessages.class\r
+SHA1-Digest: wiiyoMxj3kMQn13GC4eXAQ/Exwk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/filters/ArchiveFilter.class\r
+SHA1-Digest: BjbZN2ombKgY1E7zrrk8Lexd2Js=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/GNUElfBinaryParserPage.class\r
+SHA1-Digest: gKq0S+niZnpS+g3d5c0EAqLefAE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CSourcePreviewerUpdater$\r
+ 3.class\r
+SHA1-Digest: uvm/ZmcfQC0lnD50g7iuDpcK6gI=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/conversion/ConvertProjectWizardPage$3\r
+ .class\r
+SHA1-Digest: 8g/8F2EhVwi+i/5QtK8jaKxDv1U=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/SourceViewerInformation\r
+ Control$2.class\r
+SHA1-Digest: e0Nrv61nlHlju/QjGhR0hIek7R4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/NodeContainer$NameInform\r
+ ation.class\r
+SHA1-Digest: /q9dRXKj9tqQfm57TSR/VYkIEoo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/IScheduledRefactoring.cl\r
+ ass\r
+SHA1-Digest: zQGu35nvei3ZICnru0mTU/5qPdw=\r
+\r
+Name: icons/dlcl16/th_horizontal.gif\r
+SHA1-Digest: 2ltMbiuZdxLTMkdDn8fyKkx1/n4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CElementSet.class\r
+SHA1-Digest: DmEmQvI98oh2wB5Jh370dHU+WTE=\r
+\r
+Name: org/eclipse/cdt/ui/text/doctools/generic/GenericTagCompletionPro\r
+ posalComputer.class\r
+SHA1-Digest: 5mWtvnF5bevl3ZqADy8MD0iJ4fI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Genera\r
+ teGettersAndSettersInputPage.class\r
+SHA1-Digest: gtB/ACmdykRxVvtGOLXBJGh5wJI=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractLangsListTab.class\r
+SHA1-Digest: EiR4qYX6g7wiLYjLvXtm2/jPRLs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSetti\r
+ ngsWizardPage$5.class\r
+SHA1-Digest: ygPrKnQLeic2ox9/z9wbLlOX9w0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CElementHyperlink.class\r
+SHA1-Digest: c6mKAQ2s4FDWi0nqCtULRu/uyGA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathFilterPathPage.c\r
+ lass\r
+SHA1-Digest: 4tchPNYZqubuXCxWaCqabM55jyk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$CopyTypeHie\r
+ rarchyAction.class\r
+SHA1-Digest: LryNMaCN1ba3hxGOZakts+12qPc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/ImageDescriptorRegistry.class\r
+SHA1-Digest: MbMzY8MrM2rmp8CJCbE8G3HCCLU=\r
+\r
+Name: org/eclipse/cdt/ui/newui/ErrorParsTab$6.class\r
+SHA1-Digest: 5xqvjgz1Wj7/Qpxdt339uJUzTzc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/PasteAction$1.class\r
+SHA1-Digest: I0t2fn4LGeKOWvrh1SHYlOT67/Y=\r
+\r
+Name: icons/elcl16/build_exec.png\r
+SHA1-Digest: iLfjYD8BQAO+S5QsJOi3lf3iJW4=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UIBrowseWidge\r
+ t$1.class\r
+SHA1-Digest: CJROvBk9mECuCZg2qxOU3FynSQg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/OpenFileGroup.class\r
+SHA1-Digest: v0ZKqYMs2Xs1dS8tm17BHI/Xjw4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/CCompositeChange.class\r
+SHA1-Digest: 5IoJ9Ji7LD5HIZofmXHDm6pSc4g=\r
+\r
+Name: org/eclipse/cdt/ui/text/folding/ICFoldingStructureProvider.class\r
+SHA1-Digest: hBrPYCvAUTc7c5M5Hjs2pnVgey0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/MacrosGrouping.class\r
+SHA1-Digest: Fj74koRNSaaK7gja9PUubt6U0Ks=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/NewTypeDropDownAction.class\r
+SHA1-Digest: XdOkF+KAhVTpYott6mI9jvZDMuY=\r
+\r
+Name: org/eclipse/cdt/ui/newui/SymbolTab$1.class\r
+SHA1-Digest: Jl+UNbhyfUIb73nGLOmyqR2fbjg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathPropertyPage.cla\r
+ ss\r
+SHA1-Digest: TM1vd2x8k5kt3EHszJDdi5M56O0=\r
+\r
+Name: org/eclipse/cdt/ui/newui/CLocationTab.class\r
+SHA1-Digest: fU/I4CXlV3OevQ362p0D07MWvGQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/Inp\r
+ utPage$1.class\r
+SHA1-Digest: P8Whe0EEzqYOks0UBfKVcPVFkoI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THLabelProvider.class\r
+SHA1-Digest: jjHZYAOQLAOyVMi48Ak8LCbnjUc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/CProjectAdapterFactory.class\r
+SHA1-Digest: Ok5A0rSAWNEtF7s4NSvF9pJ8yXM=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/AbstractIndexerPage$1.class\r
+SHA1-Digest: 89eABEoGf6xQmZVoYmv4IbS4Zks=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$5.class\r
+SHA1-Digest: u//1JyRr0oJ4YUh5b7cmBQ2JIuY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/SourceAttachmentDialo\r
+ g.class\r
+SHA1-Digest: 8/WMIVRXqcvUyyRApscBnsOq+r4=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage$15.class\r
+SHA1-Digest: qC9UE9EoFpsU9UE3rQhktF1Hnyw=\r
+\r
+Name: org/eclipse/cdt/ui/Messages.class\r
+SHA1-Digest: WyiWifk8p/KC4Zv810Eq/qcuP+Q=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$OccurrencesFinderJobC\r
+ anceler.class\r
+SHA1-Digest: Cgc9NB+pcStVfN0pwNNTF+Bjndc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/KeywordCompletion\r
+ ProposalComputer.class\r
+SHA1-Digest: p7M5beyyt1/2F7BClgpG+Cbkwg0=\r
+\r
+Name: org/eclipse/cdt/ui/newui/PageLayout.class\r
+SHA1-Digest: xC6NPaXE1ZqrBdxp7d40S5JMFzw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathLibraryEntryPage\r
+ .class\r
+SHA1-Digest: JaOAvRWzEk3jw7kOAzuV29D/7sE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructur\r
+ eProvider$StatementVisitor.class\r
+SHA1-Digest: GRubNdTUxOJbFTFqmY0CPgZCspU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/QuickAssistLightBulb\r
+ Updater$3.class\r
+SHA1-Digest: jNRrg5TIaVrWumSndv0MGn6v0yo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/SettingsImpo\r
+ rtExportException.class\r
+SHA1-Digest: UoNiUICm2aUAcQQuGSE4ensHIOw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/folding/CFoldingStructureProvid\r
+ erRegistry.class\r
+SHA1-Digest: HdXzJbJ5f1a6PMN5ZbWHUEgINt0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesCache$1.clas\r
+ s\r
+SHA1-Digest: 8238cmCoZBVpDY37PuS9YbRn6Ic=\r
+\r
+Name: org/eclipse/cdt/ui/newui/NewConfigurationDialog$2.class\r
+SHA1-Digest: 8Q5FU4thyhRFhRqvaUR9EwKRNGI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/GotoMatchingBracketAction.cla\r
+ ss\r
+SHA1-Digest: RpVvKZV5Q9iXtJLtIvvsR0Z5/EM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/AlreadyExistsD\r
+ ialog$2.class\r
+SHA1-Digest: mbLC2ECSGUsVJ8N28scFYsOIZ+w=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditorErrorTickUpdater$1.cla\r
+ ss\r
+SHA1-Digest: /e2rHGDJNmc5OTG37TD5dl98zEk=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/AbstractIndexerPage.class\r
+SHA1-Digest: o6DyX3DkJMcDIX57PkOkv8ozvws=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightings$GlobalV\r
+ ariableHighlighting.class\r
+SHA1-Digest: IRZ0zBqIOJMpuBce3qXKWKmZ6Fs=\r
+\r
+Name: org/eclipse/cdt/ui/newui/EnvDialog$3.class\r
+SHA1-Digest: sriYDQJoGXyeuTmgdkYw9wvalKk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/MainActionGroup$1.class\r
+SHA1-Digest: YyDIxPsoDgYY/pFpfSrXLh4q9Js=\r
+\r
+Name: org/eclipse/cdt/internal/ui/CElementPropertySource.class\r
+SHA1-Digest: x33NjF0pBgaW3b9whk+NT2HeKWc=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage$5.class\r
+SHA1-Digest: CErQlGU5pzkNe3bRW7ixGfX/xZI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob$N\r
+ ameKind.class\r
+SHA1-Digest: Am3iu4QjEuyxgVy44zMFj6+vdOk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/ProjectTemplateStore.cla\r
+ ss\r
+SHA1-Digest: 2cQy0hrD43hc7huUSdm0AP044Vk=\r
+\r
+Name: icons/elcl16/search_next.gif\r
+SHA1-Digest: RQXpLCwGwO2SKbD5h5J894Eotis=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/InclusionProposal\r
+ Computer.class\r
+SHA1-Digest: wj1EcOi5fWtFTQq/KrBXgsX6P9o=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceTabP\r
+ age.class\r
+SHA1-Digest: 8zFNynXjBX8Zwf2n0qS1anXtrcM=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/ProjectSelectionPage$2.class\r
+SHA1-Digest: TG7kZCOVV7BwjPRCJIb5CShCm7U=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryDropDownActio\r
+ n$ClearHistoryAction.class\r
+SHA1-Digest: fAVAuRKxiPYUmuusvUqBLBJlpE8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction$H\r
+ istoryListDialog$1.class\r
+SHA1-Digest: CJYmOJAbvajRKtkkiGHUcy6NILQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistPro\r
+ cessor.class\r
+SHA1-Digest: y+4kK3YyuKMmlEYb2giKQq25+No=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/IModifyDialogT\r
+ abPage$IModificationListener.class\r
+SHA1-Digest: /XivYF/j8tDIFUMDR2wT9n9DvN0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistComp\r
+ uterParameter.class\r
+SHA1-Digest: MJ15HeHLi1pRLr3AjPTTeWUi9ck=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEnt\r
+ ryPage$1.class\r
+SHA1-Digest: AmB/URxTV1AUZtbeh0bN/9cj0f8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/LinkedProposalModelPrese\r
+ nter$LinkedPositionProposalImpl.class\r
+SHA1-Digest: xdbXAbFk3z1QsdKjSxQJaCLlSys=\r
+\r
+Name: org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDia\r
+ log$3.class\r
+SHA1-Digest: KkbMt0Pm1xe+4vqIE1W0CFjahr4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/RemoteTreeViewer$2.class\r
+SHA1-Digest: t0hf8JBHfunSx8pIrsC24CK2i6c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/NameComposer.class\r
+SHA1-Digest: 47d0Y5kkTC2jeeWu24owrO+E4VI=\r
+\r
+Name: icons/obj16/breakpoint.gif\r
+SHA1-Digest: fexGh+Ry5n9bujgYiS0ZTvzR0l8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleStr\r
+ ategyFactory.class\r
+SHA1-Digest: w+vWH8gaz5bzDHiYv7QHLO+8V2Q=\r
+\r
+Name: icons/wizban/newcfile_wiz.gif\r
+SHA1-Digest: DRcZN4zcwpfS+pSylhwMgyAqb4E=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetPage$4\r
+ .class\r
+SHA1-Digest: GD9K2qm2I0Gf0ZCqRZGvonglSLA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerDescrip\r
+ tor.class\r
+SHA1-Digest: DeOhE9RHW4QEfUlVzqY8yzat+6Q=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButton\r
+ DialogField$1.class\r
+SHA1-Digest: NP/fvwMFjp+wayzi5mWLIyO2Kwk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField\r
+ $3.class\r
+SHA1-Digest: HcS+tS7js5B4B9qIgxkmdHO291U=\r
+\r
+Name: org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineAutoEdi\r
+ tStrategy.class\r
+SHA1-Digest: DDPb8dRdi0OpCfXv3BhTi1IbEA4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/IListAdapter.cl\r
+ ass\r
+SHA1-Digest: TuKuurJn45IIim4frVAH1yYrzUw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart$12.class\r
+SHA1-Digest: siFpZb7EtqG7oeJiGvxnn9I4wio=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/SpellingPreferenceBlock$\r
+ NullStatusChangeListener.class\r
+SHA1-Digest: 0nPA+aHqCQdHSi8HvPSfJpcURV0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/StatusLineHandler$2.class\r
+SHA1-Digest: xfnVL4K91HhxzVcCh1xp9SHNJPg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CContentOutlinePage$1.class\r
+SHA1-Digest: Vo9mIUIwtglie60jSovAuYOh740=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/CCorrectionProcessor\r
+ $1.class\r
+SHA1-Digest: 9BLGUmuEs6MzrqHFuS9AmA6MJfs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CContentOutlinePage$MemberGro\r
+ upingAction.class\r
+SHA1-Digest: uZjQTzjMR37Jat2F+qUxlnIsMsA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/dialogs/ValidatingLabele\r
+ dTextField$Validator.class\r
+SHA1-Digest: qLUwV7/Y7RNXqwkyuRXZcGInHzI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/template/TemplateEngine.class\r
+SHA1-Digest: LkuWiYk4dgrkQvc5zl3VbVV9C90=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/SurroundWithActionGroup$2.cl\r
+ ass\r
+SHA1-Digest: jiZA77U47DV2Qs6kHYChXDcuNIk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractF\r
+ unctionRefactoring$1.class\r
+SHA1-Digest: GtKwTHzVYFIc9osHD8cuZYnTUCQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/template/TemplateVariablePropos\r
+ al.class\r
+SHA1-Digest: CS8bNo4ZRQmwW6+Il0dHlPHl09I=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/uitree/IUIElementTreeBuilderHe\r
+ lper.class\r
+SHA1-Digest: zpCgp774S5OTQS8ZqsE44oTecTg=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage$FileGroupF\r
+ ieldAdapter.class\r
+SHA1-Digest: n7bNUfLxij+ulu0+WXlf4AUeufE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/AbstractPreferencePage.c\r
+ lass\r
+SHA1-Digest: KcJvOWHsGBfcZWoKM0WP7yI1pRs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/SmartTypingPreferencePag\r
+ e.class\r
+SHA1-Digest: Y6nY1eaUiGH6i2jQvFDIlbn8C8Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/actions/SelectionParseAction.\r
+ class\r
+SHA1-Digest: RnyD4MdrhfwsBy8Egc91iKs4ZpI=\r
+\r
+Name: org/eclipse/cdt/internal/corext/fix/LinkedProposalPositionGroup.\r
+ class\r
+SHA1-Digest: Jkudxzhc7LfSvea6fLGsnofmra4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/NewBaseClassSele\r
+ ctionDialog.class\r
+SHA1-Digest: Q4SMgpT8EAqNu7MYs/qvLSso3XI=\r
+\r
+Name: org/eclipse/cdt/ui/newui/CLocationOutputTab.class\r
+SHA1-Digest: 6MpJHhucz+3vnmSMVpBsVBgWK/s=\r
+\r
+Name: icons/wizban/addpath_wiz.gif\r
+SHA1-Digest: BsklqQ9glR15oukDdaxP+na9hfo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/ChooserC\r
+ omposite.class\r
+SHA1-Digest: lroMxK7QqK51+F9Q2hbdqecfqB8=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UIBooleanWidg\r
+ et.class\r
+SHA1-Digest: 5l2iNLNayj20ju76GUqSrki16KY=\r
+\r
+Name: org/eclipse/cdt/ui/refactoring/actions/ExtractConstantAction.cla\r
+ ss\r
+SHA1-Digest: +kJKCJjOyolEHEpnXxZ4QWI509g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBHistoryDropDownActi\r
+ on$ClearHistoryAction.class\r
+SHA1-Digest: B2Y9M0vDIwXf+W1xu0V6NWFdq88=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/ProjectConfigsController\r
+ $DelegatingLabelProvider.class\r
+SHA1-Digest: K/sIe8Mo8QuBMkZnKV67LcwN8oE=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/AbstractGNUBinaryParserPage$2.class\r
+SHA1-Digest: 3HMQY4Szv2lDQgasygGlVHfIpj8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/CreateProfileD\r
+ ialog.class\r
+SHA1-Digest: KHwCsF4ConHoa0IQlKkfbihn7YI=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/CDTMainWizardPage$2.class\r
+SHA1-Digest: C6RIgDIu3c0S6DYvaATLTxeWZik=\r
+\r
+Name: org/eclipse/cdt/internal/ui/help/CFunctionSummary.class\r
+SHA1-Digest: Thiqa/NccLO0hVwemkx6RwtD0w4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/AnnotationHover.class\r
+SHA1-Digest: HZgTeos5p0czWOB83Y6QPsG3VVQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPref\r
+ erence.class\r
+SHA1-Digest: QuY3AASMlFspQVCf/c6RC8a1fdk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationD\r
+ ialog.class\r
+SHA1-Digest: pK/yQgqRdKYUj1nJxfy5wSRDugs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/CUIMessages.class\r
+SHA1-Digest: YlQKjCoNdFD+rT4EmxlWcJ5LkyM=\r
+\r
+Name: icons/elcl16/shift_l_edit.gif\r
+SHA1-Digest: qE/5fs0zmY1QF4eIoJB4MxgDP4o=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractLangsListTab$5.class\r
+SHA1-Digest: uXtHIZxtOBPHa1OohaqKaRyuZGU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/ToggleMarkOccurrencesAction.c\r
+ lass\r
+SHA1-Digest: ToaTjJGHvf968yTUiG4Wl2ioq0Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$26.class\r
+SHA1-Digest: GxLmYMwpWJ+C2tzUJt3qjZLVsT4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CIndenter.class\r
+SHA1-Digest: U1wbUTmSjDcxrk6w9O20yCWu2v4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI$1$1.cl\r
+ ass\r
+SHA1-Digest: b9ufw6Tqp3HePkUE4HB2yvfLoGo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlo\r
+ ck$3.class\r
+SHA1-Digest: jXjYQVsMoz4uy3KaDxXT6CW4xCE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/SmartTypingConfiguration\r
+ Block$3.class\r
+SHA1-Digest: aJaVDybkvgB/cFrJugHY4xqaYHU=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/TranslationUnitContex\r
+ tType$Project.class\r
+SHA1-Digest: YnNYoUZlYktK8T//7pbq/1VdfC0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenViewActionPr\r
+ ovider.class\r
+SHA1-Digest: VCicm2+M3tviqEp0n9aq2ul3IhE=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/CDTProjectWizard.class\r
+SHA1-Digest: JM0HOAVst1AD2JYAknC0Pt/usTU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/doctools/ProjectMap.class\r
+SHA1-Digest: /yq/XvsUU+43x7Eo0YAJ9XtKEPw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SourceHeaderPartnerFinder$1.c\r
+ lass\r
+SHA1-Digest: gqhsQ5McNOG/czDGEA62uIVDLMc=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/TemplatesChoiceWizard$1.class\r
+SHA1-Digest: 7S5niCUvnGDIjO4rORxrlCboajQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/MessageLine$1.class\r
+SHA1-Digest: 4cWTORy7dqMiB9noqyDujzmR7io=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/IndexerBlock$2.class\r
+SHA1-Digest: vTLpaQmUM7ffWUwCn+N7tlwO5Q8=\r
+\r
+Name: icons/wizban/newhfile_wiz.gif\r
+SHA1-Digest: 52klvVDKkjyjurGrF6KTec7lzJk=\r
+\r
+Name: icons/elcl16/impl_co.gif\r
+SHA1-Digest: upA4o5PE76cEalyYoqjwdraD4Ew=\r
+\r
+Name: org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog$3.class\r
+SHA1-Digest: B5ioe+DbTm+/mQfbVQR1843+PVk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBloc\r
+ k$2.class\r
+SHA1-Digest: hinkWnhpCfC5uRx30xyYgKaRsII=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/ChangeExceptionHandler$N\r
+ otCancelableProgressMonitor.class\r
+SHA1-Digest: 6nm2lr9TMfCtmQD5vQlQUAzwjeI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMe\r
+ ssages.class\r
+SHA1-Digest: eAX2L1d9M6/aErj5GHnV6gbdfq8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/navigator/CNavigatorDropAdapterAssis\r
+ tant.class\r
+SHA1-Digest: iNCVNVIhYz16MOlfiF4e/m0PuRY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/TreeListDialogF\r
+ ield$TreeViewerAdapter.class\r
+SHA1-Digest: bl4BQ06fRSccDOlRBVV4tY3SVv4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/OverrideIndicatorManager$1Com\r
+ positeTypeFinder.class\r
+SHA1-Digest: nZKZCk3Fu3KdXulputf1d2FV8Xc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/SettingsProc\r
+ essor.class\r
+SHA1-Digest: gHBVWj/Qr+BkbkwXjkjZyr9Z6tA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob$2\r
+ .class\r
+SHA1-Digest: +LirMevImfn+HV6fqyvHb3oB7OE=\r
+\r
+Name: icons/dtool16/newclass_wiz.gif\r
+SHA1-Digest: mRtiYYMZuTDIAREl3QE2jSc8GNo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/doctools/DocCommentSinglelinePr\r
+ oposalComputer.class\r
+SHA1-Digest: nHjtyrt0ILFtdrhnqULmnwE6yV0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/implementmethod/Implemen\r
+ tMethodInputPage$3.class\r
+SHA1-Digest: ax2N0RhQJX/z/frKeWVzYp79nz0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellDictionar\r
+ y.class\r
+SHA1-Digest: ujBgGsGd28oMu1nBKQyMTgRKmpY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/newui/Messages.properties\r
+SHA1-Digest: MrxhdRy+aMl0/nDsn6k9m5C837w=\r
+\r
+Name: icons/obj16/thread_obj_b.gif\r
+SHA1-Digest: JxqVVlOJB+axmHjVNW3H1dt2bi4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SourceHeaderPartnerFinder.cla\r
+ ss\r
+SHA1-Digest: WeWW6+7GISt2Xv25fhCDYfH6mTk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/InactiveCodeHighlighting$1$1.\r
+ class\r
+SHA1-Digest: OY/VaHj0Q/oRONeD6IfREn4MZbA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/SingleCharReader.class\r
+SHA1-Digest: X14N7e3b+SxsCQQ5aTTyucjgneU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/PathEntryVariableDialog$\r
+ 3.class\r
+SHA1-Digest: z6tTue5ElH7uys96JZI3XBxoi5o=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/processes/OpenFiles.class\r
+SHA1-Digest: 8+qp0FCiTxv/RaKg8CqoLBluR1E=\r
+\r
+Name: icons/etool16/config-compiler.gif\r
+SHA1-Digest: WtRCkxJjruoZdS8/xinBX9h8LF4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover$3.class\r
+SHA1-Digest: JCJdZzbznbxwCuvHRyv+nVA5nts=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/CViewContentProvider.class\r
+SHA1-Digest: VnG59Pb/SfHVoPkRXUFhcPi32e0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/messages.pro\r
+ perties\r
+SHA1-Digest: CFPd36cTAOjKFLmPNwC/5m9ujGQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/compare/CMergeViewer.class\r
+SHA1-Digest: er8uUlDJx/LNAUWtDee5+uKzdc8=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractPage$5.class\r
+SHA1-Digest: tigSH/NvIp2arQGxREikwQZDLj0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/spelling/SpellingEngineDispatch\r
+ er.class\r
+SHA1-Digest: W5Ssxf1rKQjPtYqjoCqaMyGdwS0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/dialogs/ExtractInputPage\r
+ $2.class\r
+SHA1-Digest: MXh1xgjI+g9pbWeijiVk8Caq3Ig=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage.class\r
+SHA1-Digest: I9EMMV4x/XP1i2aeybtAzgL8hBI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialog.c\r
+ lass\r
+SHA1-Digest: weg5rIiswPp64uZwDgxHXvS0kPQ=\r
+\r
+Name: icons/dlcl16/th_single.gif\r
+SHA1-Digest: GtViAn7MLJZNLBU4dUsK1cNpwO4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructur\r
+ eProvider$StatementRegion.class\r
+SHA1-Digest: NjG7PxeFzNNPsDpLRdddF1VWFvk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/BuildGroup$RebuildAction.class\r
+SHA1-Digest: FyhEdFyJZmNdJG6OzpFMHDCMCfo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/indexview/DiscardExternalDefsAction.\r
+ class\r
+SHA1-Digest: N51Oiox5QSUhhYv4jv7Y6oAMfvQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/RefactoringSavePreferenc\r
+ es.class\r
+SHA1-Digest: 2iBO/ARDkoin8poX60xex8WuMhc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/NodeContainer$1.class\r
+SHA1-Digest: L48SYoOT102hjCAWTs18XYB3DGg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/RefactoringRunner.class\r
+SHA1-Digest: SkB4MreF1s05bT268Ai6YupWR9g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/RemoteTreeContentManager.class\r
+SHA1-Digest: TT+ZUgBJv6777LDilQy3Uymob2U=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/PDOMSearchViewPage$ShowEnclos\r
+ ingDefinitionsAction.class\r
+SHA1-Digest: FYRISWzw6wliidvfia4os6Dx4gk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/NumberRule.class\r
+SHA1-Digest: tz0lUXVbw6dRFqNnOc/o851duS0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/IProfileVersio\r
+ ner.class\r
+SHA1-Digest: u7qk9vSrBOf7GfSpqZC9zW7kgrI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/filters/FilterDescriptor.class\r
+SHA1-Digest: XKYGWRscUV2B+Uw2I+QhJCKbOBg=\r
+\r
+Name: icons/obj16/toolbar_pinned_b.gif\r
+SHA1-Digest: 29RAdiCHCVcL2bw5O4fD5hTPwjQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/CPluginImages.class\r
+SHA1-Digest: l4K0LiMJ7qlTidTPqtuxGV9fdKY=\r
+\r
+Name: org/eclipse/cdt/ui/text/doctools/generic/GenericTagSimpleDiction\r
+ ary.class\r
+SHA1-Digest: 2e02bvwZLduyQ1n7sxeu4zsXhNA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/implementmethod/Implemen\r
+ tMethodRefactoringWizard.class\r
+SHA1-Digest: zeQTMTnx4fxodcgNZmLZfHiXCWk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage$1.\r
+ class\r
+SHA1-Digest: uabaNYCkRnonu2cg0vaEcjlTqlo=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/pages/Messages.class\r
+SHA1-Digest: AiIUa2J50XBNbg4NmruWQVLMlMQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/ProposalFilterPreference\r
+ sUtil.class\r
+SHA1-Digest: 4FytzQ2+av60/9W6wrJOgBqIedo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CContentOutlinePage$Namespace\r
+ GroupingAction.class\r
+SHA1-Digest: 8pm/JQxULL66ohNnQ/ss7bNI/GA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/ChangeTreeSet$ChangePosi\r
+ tionComparator.class\r
+SHA1-Digest: 89fbLDMfIgaYbM+v5ebZ2GYsrGQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/ParsingBasedPropo\r
+ salComputer.class\r
+SHA1-Digest: 8OtUE89DZQhC959pR+8s9Ey/vP4=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UISpecialList\r
+ Widget$1.class\r
+SHA1-Digest: 2kWSwwDfvJaxIxjD0mczG3G6+iQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/ArchiveFileFilter.cla\r
+ ss\r
+SHA1-Digest: ugbi/W4AiELiJCPM7VoxExVDLAo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightings$Externa\r
+ lSDKHighlighting.class\r
+SHA1-Digest: jeewNsiEWxxJifpzVMrNWolWlTg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/SelectionTransferDropAdapter$2\r
+ .class\r
+SHA1-Digest: 0ZNmEEtvSUSuf6P3hbQNecqZYeE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/cview/CView$5.class\r
+SHA1-Digest: 3hRkQRVe5Ts8A21NXGMrxNwiBC4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CodeTemplateBlock$CodeTe\r
+ mplateAdapter.class\r
+SHA1-Digest: 8JCEhv+QBOijaI4I3GeT2jv/wCw=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/DOMSourceIndexerBlock.class\r
+SHA1-Digest: 0rafv6244g3reO3bL0GBGHl6mtA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfiguratio\r
+ nBlock$1.class\r
+SHA1-Digest: yuJYCOM+e6uE/llrbohHTV+WI1o=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/proposals/RenameRefa\r
+ ctoringProposal.class\r
+SHA1-Digest: tjHLwCO4DZO7+rCtkL/pYx4mV0Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/PathEntryVariablePrefere\r
+ ncePage.class\r
+SHA1-Digest: bExG6rEfBFKhC/yd4NTuu/BedbY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ProfileConfigu\r
+ rationBlock$ButtonController.class\r
+SHA1-Digest: OGo0ZwabFxrnuJOV2mP/6RtQ/84=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.class\r
+SHA1-Digest: Jteh43nMDcKa6fXi3wD9/khFcW4=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/FileTemplateContext.c\r
+ lass\r
+SHA1-Digest: m5fcs16AZt/MuTylwPctIaVb79A=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructur\r
+ eProvider$1.class\r
+SHA1-Digest: ma11beSjIbXcmur3m0Lb6963dZg=\r
+\r
+Name: icons/dlcl16/filterInactive.gif\r
+SHA1-Digest: wFxtdSs5cJLisxOYUQ5HeXixKkA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSetti\r
+ ngsWizardPage$12.class\r
+SHA1-Digest: /lbv5F7JduXgkF9TCbj1Avbn6KE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/doctools/NullDocCommentOwner.cl\r
+ ass\r
+SHA1-Digest: /SMcQwvjKT81NGTkfZvZItoP/Y0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$DeleteNextSubWordActi\r
+ on.class\r
+SHA1-Digest: nLyRpq3J8/NqvHdwBhSGp3eahFw=\r
+\r
+Name: org/eclipse/cdt/ui/refactoring/actions/RefactoringAction.class\r
+SHA1-Digest: RHJ9RDxgQozRUfKPDzsfe4T5Etc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Genera\r
+ teGettersAndSettersInputPage$4.class\r
+SHA1-Digest: vZhRUNKyUe7mKI1V07mTtj4iD68=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/folderwizard/NewSourceFolder\r
+ WizardPage.class\r
+SHA1-Digest: CptVsUBJdjBVY3K5U5+5NZ2R2CY=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/uitree/IPageTypeConstants.clas\r
+ s\r
+SHA1-Digest: +2Ert3AVQDBQ+wl5SXiYIQZQs/w=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/uitree/InputUIElement.class\r
+SHA1-Digest: 1yBVYOOT2S89jMzzrYUwCW3ah1I=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedName\r
+ sAssistProposal.class\r
+SHA1-Digest: IE8k8unN9spy6x51MSecBO58RaY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/ElementListSelectionDialog.c\r
+ lass\r
+SHA1-Digest: XjuHWJMSVMczYp0U7jtL20vWwK8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CParserPreferencePage.cl\r
+ ass\r
+SHA1-Digest: LiBqadib1qj83OS8uHBU+Q4GnDg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$BracketInserter$1.cla\r
+ ss\r
+SHA1-Digest: Ifr8uvpxVCHyV/tvgzvIckmnwxM=\r
+\r
+Name: org/eclipse/cdt/utils/ui/controls/FileListControl$SelectPathInpu\r
+ tDialog.class\r
+SHA1-Digest: t9zYoxPGwmDMqKamICRfxFeG/bY=\r
+\r
+Name: icons/dtool16/action-buildconfig.gif\r
+SHA1-Digest: Qujy7yX/h+6V9BGhuVBh4Mzxa2M=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBloc\r
+ k$AssocLabelProvider.class\r
+SHA1-Digest: qhDakzWigKIPbGZcFhHUtY8Y+Ps=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractF\r
+ unctionInputPage$2.class\r
+SHA1-Digest: vNEFZQnCbo1Go8j0bxoAqqXl8Co=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectInde\r
+ xExportWizardPage$3.class\r
+SHA1-Digest: GmQEhE8QIEvTQi10MXQn+FsMe/0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/HelpCompletionPro\r
+ posalComputer$1.class\r
+SHA1-Digest: LCBw6D6wH7MrTL7YFfpnlurLeJM=\r
+\r
+Name: org/eclipse/cdt/ui/text/contentassist/IProposalFilter.class\r
+SHA1-Digest: INsyz4nE7Dce252G3brRDLNVaAI=\r
+\r
+Name: org/eclipse/cdt/ui/actions/ChangeBuildConfigContextAction$1.clas\r
+ s\r
+SHA1-Digest: OUcwZg/XF2URGnmwm/JMJnOskPw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailNod\r
+ eEqualityChecker.class\r
+SHA1-Digest: 8xCBjKBjCwnczVwR/8RRSI8ocXc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.class\r
+SHA1-Digest: PLLvhXWqOBMDf4UZ0Hy/JGZ7UKs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/OptionalMessageDialog.class\r
+SHA1-Digest: JB4ybEwEXJ/H8iDfwXkyOdogKwg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ProfileManager\r
+ .class\r
+SHA1-Digest: /n0/LIIBpaSzryfwV0SrkdlQz5w=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractC\r
+ onstantRefactoring$1.class\r
+SHA1-Digest: fZz4tPTD6x/pJ3wTrm6sVTh5VgM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceOpti\r
+ ons$InnerNode.class\r
+SHA1-Digest: x64irxp4dRzxKT+7nCY9A04L5nQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction$3\r
+ $1.class\r
+SHA1-Digest: Yl/R/fDXBHor4HcMwzZOGeKyu04=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/IOccurrencesFinder.class\r
+SHA1-Digest: d9AQT20mWid4biUxDM1QlIrS4gU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CTemplatesPage.class\r
+SHA1-Digest: SuhFu6vroDwh36odCrokgXTotm4=\r
+\r
+Name: icons/view16/types.gif\r
+SHA1-Digest: TYtoekp1ZfymFENkr+/3EwAu4UA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/ProblemMarkerManager$1.class\r
+SHA1-Digest: jddOVDvAwfFE9Xfr3ZHJiZanl90=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart.class\r
+SHA1-Digest: kW88E28SbLIdLLNCMivQrstvWrU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticHighlightings$FieldHi\r
+ ghlighting.class\r
+SHA1-Digest: qAOpXkH6TAMujcM2XBEHO3AAd+M=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/IOccurrencesFinder$Occurrence\r
+ Location.class\r
+SHA1-Digest: xyZfvNtAotvU+rdtDaT+Us2gOj4=\r
+\r
+Name: org/eclipse/cdt/internal/corext/template/c/TranslationUnitContex\r
+ tType$Method.class\r
+SHA1-Digest: 3pfmuCGTfuQ08hyCDfso14hPf4Y=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/CygwinPEBinaryParserPage$2.class\r
+SHA1-Digest: z5CWLJuVZm10o0RWEx7K88n5W3I=\r
+\r
+Name: org/eclipse/cdt/internal/ui/typehierarchy/THViewPart$13.class\r
+SHA1-Digest: s7n6s6nMDa/Z/mk6iGyfuBCXP50=\r
+\r
+Name: org/eclipse/cdt/ui/text/IContentAssistHelpInvocationContext.clas\r
+ s\r
+SHA1-Digest: h2D14PiloCpQtr/He/i+23wbHoI=\r
+\r
+Name: icons/elcl16/forward_nav.gif\r
+SHA1-Digest: lmLlDPE2WjVohevt+GNU13MFL5w=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/IWizardItemsListListener.class\r
+SHA1-Digest: j3ReQR3zM1swXPv21rH86uB/UC8=\r
+\r
+Name: templates/default-templates.xml\r
+SHA1-Digest: JEmCWU8dL8FNX3nZiFEIh/SiJqw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/OpenIncludeBrowserAct\r
+ ion.class\r
+SHA1-Digest: ucFPt5uVGsijMIIgOEtXBLgDw+Q=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$7.class\r
+SHA1-Digest: tDVC7OyiRiycH29lwAyS47/9g0s=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/contentassist/CCompletionPropos\r
+ al$ExitPolicy.class\r
+SHA1-Digest: inKGduJz/D3U+9N1JcZBb+M0Zvw=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/CacheSizeBlock.class\r
+SHA1-Digest: loL3kWvjxpeV62z4gLZQjAQKx4Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/ProjectSelectionDialog$4\r
+ .class\r
+SHA1-Digest: 96/Mjhx3uQBjAHMEC115ul4GnqM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/indexview/IndexView$Children.class\r
+SHA1-Digest: ET8EPnmHT8Hf+NdSPXaZrQ50Wps=\r
+\r
+Name: org/eclipse/cdt/internal/ui/navigator/CNavigatorContentProvider$\r
+ 2$1.class\r
+SHA1-Digest: zbwLnPjAidliim0z7aI1QQmGaxw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandHan\r
+ dler.class\r
+SHA1-Digest: iIRuj6CAP0ouXkfKRP3BpLSl/5s=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/CWizardRegistry$WizardConfig\r
+ .class\r
+SHA1-Digest: 88RvDMPaIe9NJvmkqRBKtlJoLGU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/help/CFunctionSummary$RequiredInclud\r
+ e.class\r
+SHA1-Digest: /rarNtI1Sj7R4mnkFY9Q59PBge4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/PropertyAndPreferencePag\r
+ e$1.class\r
+SHA1-Digest: RsL8aVnbvMXN56s8lTr5dzTxpZM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerEntryPa\r
+ ge$1.class\r
+SHA1-Digest: FFgLZkp9QVkWD+M32OLwKBlBuMw=\r
+\r
+Name: org/eclipse/cdt/ui/newui/StructureTreeTab$6.class\r
+SHA1-Digest: OMqH4ohAtPeqy4Vrgco1SX99S/Y=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/SelectionConverter.class\r
+SHA1-Digest: MGpLlN4+s8i2IQJkoraOALIHm5E=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/CRenameTypeProces\r
+ sor.class\r
+SHA1-Digest: 2EiwbJNUCl1LUJU5ilwzFCdbNz0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigsControl\r
+ ler$2.class\r
+SHA1-Digest: Q66RLPPwzr6UOFR5UgQ+iVjCCJo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CHelpProviderDescriptor$1.class\r
+SHA1-Digest: Wcbc29Q58Y/Gv6sCl7gzK7TMw08=\r
+\r
+Name: org/eclipse/cdt/internal/ui/buildconsole/MultiBuildConsoleAdapte\r
+ r$BuildOutputStreamAdapter.class\r
+SHA1-Digest: K/17j8GctDFXb5WXkMSabRQVVTQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CReconciler$1.class\r
+SHA1-Digest: ll94wXfgfPSqWDFmwtpn6o7EHQw=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialogTa\r
+ bPage$ButtonPreference$1.class\r
+SHA1-Digest: uRWgzU3iowrheAUuXSPRaerMRmE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/AbstractAnnotationHover\r
+ $AnnotationInformationControl$4.class\r
+SHA1-Digest: uVxBeLU1ykHIuY6CM5dPQsIa9QQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformation\r
+ Popup$2.class\r
+SHA1-Digest: aubdjWiucC6j9d3oOsmEmQEm41Q=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/TreeListDialogF\r
+ ield$3.class\r
+SHA1-Digest: KI03Z+sXG/nWmQshqlmHwrA71fM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/ToggleCommentAction.class\r
+SHA1-Digest: s+odOXCqeqzG65nXTN6HxvWphsI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractC\r
+ onstantRefactoringWizard.class\r
+SHA1-Digest: uoB0c/5e73/f2wHKAGa187Kw1DQ=\r
+\r
+Name: icons/obj16/field_public_obj.gif\r
+SHA1-Digest: 1wf8MtvK4WxuHCTzK5qekG4I8iM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dnd/TransferDragSourceListener.class\r
+SHA1-Digest: eiw3vgjm9v9MkGAoUlZbUn8BY5g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactorin\r
+ gInputPage$1.class\r
+SHA1-Digest: lQSZdVZfWUxSR1rZU8BFc1WjkL0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/AbstractWizardDropDownAction\r
+ $1.class\r
+SHA1-Digest: spM1duGJaMbjpWPLtJIl3F4jHa0=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessa\r
+ ges.class\r
+SHA1-Digest: CNwYnLUhKzzUzcW8IgW9o7+cI+E=\r
+\r
+Name: org/eclipse/cdt/ui/newui/AbstractExportTab$2.class\r
+SHA1-Digest: u6KEkxWn8tJfO2GzefWldZ6+5XI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/CEditor$OccurrencesAnnotation\r
+ UpdaterJob.class\r
+SHA1-Digest: wNI1o/KfAYNzA4Y4Vaxabz1OBfw=\r
+\r
+Name: org/eclipse/cdt/ui/text/CSourceViewerConfiguration$6.class\r
+SHA1-Digest: Fz8NoaBBBucAzJtKeHTmA+EnBm4=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/pages/UIPage.class\r
+SHA1-Digest: aiiF8mSiBb/h0PkG0dnj4m2gOdU=\r
+\r
+Name: org/eclipse/cdt/ui/dialogs/AbstractCOptionPage.class\r
+SHA1-Digest: 6KWYPRPTo1I9nA5pnnw92Opi15A=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFro\r
+ mImplementationToHeaderOrClassStrategy$1.class\r
+SHA1-Digest: 2D8lrD+ChcyJoMA0+FZl7TMNAbI=\r
+\r
+Name: icons/view16/buildconsole.gif\r
+SHA1-Digest: x7szVGWXgX1REWt8I96AFvJblv8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/actions/FindInWorkingSetActio\r
+ n.class\r
+SHA1-Digest: m4AhCpqhZt6X11NYuIUZMjn27qg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/filters/MacroDirectiveFilter.class\r
+SHA1-Digest: ZNxN1li3e2zZsWk7yDfAETKdPbA=\r
+\r
+Name: org/eclipse/cdt/ui/templateengine/FormBrowser$1.class\r
+SHA1-Digest: tUFIvTYTj4KNnrYShZ9OAJZVU3k=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfig\r
+ urationBlock$4.class\r
+SHA1-Digest: pqBpscYlBZuC+6FJCaSksrDSx/8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingWidge\r
+ t$2.class\r
+SHA1-Digest: dak5Bu34HKjZiteig7r6852ReX4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/callhierarchy/CHLabelProvider.class\r
+SHA1-Digest: /Q76QbtTnTNVZJYLVCiaoXzKSyM=\r
+\r
+Name: org/eclipse/cdt/internal/corext/fix/LinkedProposalPositionGroup$\r
+ TrackedNodePosition.class\r
+SHA1-Digest: zwP5pbcU80oxN3ygCXEfpYQNYNE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBViewPart$5.class\r
+SHA1-Digest: qiHLJ8le/w+F56FxZJsxwwBhxhE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage$3.\r
+ class\r
+SHA1-Digest: rZtqhNMEc+GC3Of4DEIpXC8oPFE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/filters/FilterDescriptor$2.class\r
+SHA1-Digest: Ftl8CFAoNuvlmjpWEFJ5Dr0rNRE=\r
+\r
+Name: icons/elcl16/list-delete.gif\r
+SHA1-Digest: 8ds+7GDdJqG/dxqU/DTvX6CeOfI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/c/hover/AbstractAnnotationHover\r
+ .class\r
+SHA1-Digest: vlSq1WghE8otOzCC9wWOhb0EaLs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/asm/AsmTextTools$PreferenceLi\r
+ stener.class\r
+SHA1-Digest: 7PLneBKKFyRMnYzCVY6b+0e5o8A=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/AsyncTreeWorkInProgressN\r
+ ode.class\r
+SHA1-Digest: O4qthO7on7pyiVmAa8l2Y/S9L18=\r
+\r
+Name: icons/etool16/prop_edt.gif\r
+SHA1-Digest: gryexL0eTVIgZ6PAl43cRFfiANI=\r
+\r
+Name: org/eclipse/cdt/ui/FunctionPrototypeSummary.class\r
+SHA1-Digest: 4JLYJ2YDoJr4xtF5BNKdz3+IOlo=\r
+\r
+Name: org/eclipse/cdt/internal/ui/editor/SemanticToken.class\r
+SHA1-Digest: 019+KOCAtzCK5l0/E+kIik65RpI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/ActionMessages.properties\r
+SHA1-Digest: F4J08uQYKez0jKKXSZuoTsXr0Gc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuActi\r
+ on$4.class\r
+SHA1-Digest: zUf2cCbERrCaVMkklN2Iz+o5PQo=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/CDTCommonProjectWizard$1$1.class\r
+SHA1-Digest: SSpx7RqiE97dWM/VYd/WJ4n0jxk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/AbstractWorkingSetConfig\r
+ sContribution$1.class\r
+SHA1-Digest: /U8MzkZq1TINdl8Koxrn0VOXlnM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/Inp\r
+ utPage.class\r
+SHA1-Digest: xP8DZ13zchDcVWW7h1ogaWn/FRQ=\r
+\r
+Name: org/eclipse/cdt/internal/ui/workingsets/WorkingSetProxy.class\r
+SHA1-Digest: rlIz15cAJUgu+OvyHQTjq4KAJoI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/filewizard/WizardNewFileFrom\r
+ TemplateCreationPage.class\r
+SHA1-Digest: 2V5AlDoEtMg5JBI7J95i079htlU=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBViewPart$11.class\r
+SHA1-Digest: IZk0Nr6f3+LA3uFepfEXe3d0VvY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField\r
+ $ColumnsDescription.class\r
+SHA1-Digest: 0z9f5tkqNYcHNhWxIfaczdVK44g=\r
+\r
+Name: org/eclipse/cdt/internal/corext/fix/LinkedProposalPositionGroup$\r
+ PositionInformation.class\r
+SHA1-Digest: 3AwhkLo3YEH8Dj6WZe62zUNTvR4=\r
+\r
+Name: org/eclipse/cdt/ui/refactoring/actions/ExtractFunctionAction.cla\r
+ ss\r
+SHA1-Digest: bLrGzzFnMJcRFTst4TaV2v8cVPI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dialogs/AbstractElementListSelection\r
+ Dialog$1.class\r
+SHA1-Digest: RDn7VcNhYBL6isPxAM3M1g7lCa0=\r
+\r
+Name: org/eclipse/cdt/ui/actions/MemberFilterActionGroup$1.class\r
+SHA1-Digest: aIdVoAhKqub4nImMedGj6mDzB4g=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/utils/DeclarationFinder$\r
+ 1.class\r
+SHA1-Digest: LJTcELBsgsfAwxHIycaQSgKkwZs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/AbstractInformationControl$1.cl\r
+ ass\r
+SHA1-Digest: 1+5xadRXgZpDgf0vuxgMo6x081o=\r
+\r
+Name: org/eclipse/cdt/internal/ui/wizards/classwizard/SourceFileSelect\r
+ ionDialog$Filter.class\r
+SHA1-Digest: VNzYZ9wvVOwEotMZ3dWjmPcJm5s=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/NewCProjectWizard.class\r
+SHA1-Digest: dgIWZgylfqvwAq+Jp89Porzz49w=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/MemberFilter.class\r
+SHA1-Digest: f0XIHeGargbayP9aMj+K0y9dt/U=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleRef\r
+ actoring.class\r
+SHA1-Digest: clUVDHxBMMLIvnc5yf8NkjVWUyY=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.cl\r
+ ass\r
+SHA1-Digest: CF2Ci/XfPWgf+TEbDS9kWrSX3d8=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/ChangeExceptionHandler.c\r
+ lass\r
+SHA1-Digest: a2IVmTktfBojYOQXmD2T3eECoAg=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CFileTypeAssociation.cla\r
+ ss\r
+SHA1-Digest: Yiq7ASatGKArZ8v8wMRLBB/Mgx4=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/ChooserC\r
+ omposite$4.class\r
+SHA1-Digest: 6V6j3UZHJrr0lCoJAR7/IIdW3Jw=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage$StatusFocu\r
+ sListener.class\r
+SHA1-Digest: JqqJMLvolklH8UPoWkDXSu3ji1Q=\r
+\r
+Name: org/eclipse/cdt/internal/ui/dnd/ResourceTransferDropAdapter.clas\r
+ s\r
+SHA1-Digest: eIQbd5mBZU9u5zDd4NUQxRnbUXI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/AsyncTreeContentProvider\r
+ $2.class\r
+SHA1-Digest: BYdYRFJmUVFhat4DpZ57e3LyR8c=\r
+\r
+Name: org/eclipse/cdt/internal/ui/includebrowser/IBMessages.class\r
+SHA1-Digest: w/rskqFVp99oKtaQHhGiGB+LeXw=\r
+\r
+Name: org/eclipse/cdt/ui/newui/RefsTab$3.class\r
+SHA1-Digest: nphEU4sQjQ8Z48wbLpkKJC5WMBM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/text/CBreakIterator$CamelCaseIdentif\r
+ ier.class\r
+SHA1-Digest: pGLiATo27fI6z1sak29djDsHK1Q=\r
+\r
+Name: icons/obj16/fldr_obj.gif\r
+SHA1-Digest: FqxWDk18RgbYI+FKO7aa1lGJlFE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/util/ProblemMarkerManager$ProjectErr\r
+ orVisitor.class\r
+SHA1-Digest: SBrYKNHuEc2Wao6xMFoSgZ02WVs=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/StructureSelectHistoryAction\r
+ .class\r
+SHA1-Digest: ZU2AP6jS1/NoAutDnVna6HGeDJM=\r
+\r
+Name: org/eclipse/cdt/internal/ui/viewsupport/ISelectionListenerWithAS\r
+ T.class\r
+SHA1-Digest: MxGqoxkhGNwVS/bvhOr0ZTIgy3o=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractE\r
+ xpression$1.class\r
+SHA1-Digest: F0GM7+dMG+Ua765v847LGzzv7xc=\r
+\r
+Name: org/eclipse/cdt/ui/wizards/conversion/ConvertProjectWizardPage$P\r
+ rojectLabelProvider.class\r
+SHA1-Digest: oLCjq55bIOLyNUggw1ipb7U7ZJA=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractF\r
+ unctionInputPage.class\r
+SHA1-Digest: 92At4OHOe7Bh9kqbh1S1Q0BISMk=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/SpellingConfigurationBlo\r
+ ck.class\r
+SHA1-Digest: Nw4O5Pap4MekrmVwkvfIv9bGuSc=\r
+\r
+Name: org/eclipse/cdt/internal/ui/search/PDOMSearchTreeContentProvider\r
+ .class\r
+SHA1-Digest: MQaDO3GPJECO+gs5e2LrLqwmi5k=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBloc\r
+ k$AssocSorter.class\r
+SHA1-Digest: kbYNZ85CDBMdgN2Ae6mfBzf4/0o=\r
+\r
+Name: org/eclipse/cdt/internal/ui/indexview/CountNodeAction$2.class\r
+SHA1-Digest: WbNZTW51DzOK3J2GRxKFxXIl6mI=\r
+\r
+Name: org/eclipse/cdt/internal/ui/actions/FoldingActionGroup$FoldingAc\r
+ tion.class\r
+SHA1-Digest: wIawb+0TojOd+Ki6Vv8st8h3/0U=\r
+\r
+Name: org/eclipse/cdt/internal/ui/refactoring/utils/Messages.propertie\r
+ s\r
+SHA1-Digest: LbRxQrBEEX/hNlIgZf3GKKghBWY=\r
+\r
+Name: org/eclipse/cdt/ui/text/doctools/DefaultMultilineCommentAutoEdit\r
+ Strategy.class\r
+SHA1-Digest: JSIyHDF/0DpcmVNInt1MJNix8bE=\r
+\r
+Name: org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesConfigura\r
+ tionBlock$3.class\r
+SHA1-Digest: UyLotFeyK3BKUS1YTt4E+7T2FvI=\r
+\r
diff --git a/org.eclipse.cdt.ui/META-INF/eclipse.inf b/org.eclipse.cdt.ui/META-INF/eclipse.inf
new file mode 100644 (file)
index 0000000..92ffed2
--- /dev/null
@@ -0,0 +1,2 @@
+#Processed using Jarprocessor
+pack200.conditioned = true
diff --git a/org.eclipse.cdt.ui/META-INF/maven/org.eclipse.cdt/org.eclipse.cdt.ui/pom.properties b/org.eclipse.cdt.ui/META-INF/maven/org.eclipse.cdt/org.eclipse.cdt.ui/pom.properties
new file mode 100644 (file)
index 0000000..54025e7
--- /dev/null
@@ -0,0 +1,5 @@
+#Generated by Maven
+#Thu Sep 15 12:22:05 EDT 2011
+version=5.3.1-SNAPSHOT
+groupId=org.eclipse.cdt
+artifactId=org.eclipse.cdt.ui
diff --git a/org.eclipse.cdt.ui/META-INF/maven/org.eclipse.cdt/org.eclipse.cdt.ui/pom.xml b/org.eclipse.cdt.ui/META-INF/maven/org.eclipse.cdt/org.eclipse.cdt.ui/pom.xml
new file mode 100644 (file)
index 0000000..04a7dff
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+       xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+       <modelVersion>4.0.0</modelVersion>
+
+       <parent>
+               <groupId>org.eclipse.cdt</groupId>
+               <artifactId>cdt-parent</artifactId>
+               <version>8.0.0-SNAPSHOT</version>
+               <relativePath>../../pom.xml</relativePath>
+       </parent>
+
+       <version>5.3.1-SNAPSHOT</version>
+       <artifactId>org.eclipse.cdt.ui</artifactId>
+       <packaging>eclipse-plugin</packaging>
+</project>
diff --git a/org.eclipse.cdt.ui/about.html b/org.eclipse.cdt.ui/about.html
new file mode 100644 (file)
index 0000000..d69a125
--- /dev/null
@@ -0,0 +1,70 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>About</title></head>
+
+<body lang="EN-US">
+<h2>About This Content</h2>
+<p>June 09, 2008</p>   
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content").  Unless otherwise 
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL").  A copy of the EPL is available 
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is 
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content.  Check the Redistributor's license that was 
+provided with the Content.  If no such license exists, contact the Redistributor.  Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+<h3>Third Party Content</h3>
+<p>The Content includes items that have been sourced from third parties as set out below. If you   did not receive this Content directly from the Eclipse Foundation, the following is provided   for informational purposes only, and you should look to the Redistributor&rsquo;s license for   terms and conditions of use.</p>
+<h4>Ispell 3.1.20</h4>
+<p>The plug-in is accompanied by software developed by Geoff Kuenning.  The following files:</p>
+<ul>
+  <li>dictionaries/en_US.dictionary</li>
+  <li>dictionaries/en_GB.dictionary</li>
+</ul>
+<p>are based on Ispell 3.1.20.  The home page for Ispell is located at <a href="http://lasr.cs.ucla.edu/geoff/ispell.html" target="_blank">http://lasr.cs.ucla.edu/geoff/ispell.html</a>.</p>
+<p>Your use of Ispell 3.1.20 in the plug-in is subject to the terms and  conditions of the Ispell license. A copy of the Ispell license is  included in <a href="about_files/ispell-license.txt" target="_blank">about_files/ispell-license.txt</a> and is also reproduced below:</p>
+<blockquote> Copyright 1993, Geoff Kuenning, Granada Hills, CA<br />
+  All rights reserved.<br />
+  <br />
+  Redistribution and use in source and binary forms, with or without<br />
+  modification, are permitted provided that the following conditions<br />
+  are met:<br />
+  <br />
+  1. Redistributions of source code must retain the above copyright<br />
+  notice, this list of conditions and the following disclaimer.<br />
+  2. Redistributions in binary form must reproduce the above copyright<br />
+  notice, this list of conditions and the following disclaimer in the<br />
+  documentation and/or other materials provided with the distribution.<br />
+  3. All modifications to the source code must be clearly marked as<br />
+  such.  Binary redistributions based on modified source code<br />
+  must be clearly marked as modified versions in the documentation<br />
+  and/or other materials provided with the distribution.<br />
+  4. All advertising materials mentioning features or use of this software<br />
+  must display the following acknowledgment:<br />
+  This product includes software developed by Geoff Kuenning and<br />
+  other unpaid contributors.<br />
+  5. The name of Geoff Kuenning may not be used to endorse or promote<br />
+  products derived from this software without specific prior<br />
+  written permission.<br />
+  <br />
+  THIS SOFTWARE IS PROVIDED BY GEOFF KUENNING AND CONTRIBUTORS ``AS<br />
+  IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT<br />
+  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS<br />
+  FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL GEOFF<br />
+  KUENNING OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,<br />
+  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,<br />
+  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;<br />
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER<br />
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT<br />
+  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN<br />
+  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE<br />
+  POSSIBILITY OF SUCH DAMAGE</blockquote>
+<p>&nbsp;</p>
+</body></html>
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/about_files/ispell-license.txt b/org.eclipse.cdt.ui/about_files/ispell-license.txt
new file mode 100644 (file)
index 0000000..e9f0601
--- /dev/null
@@ -0,0 +1,36 @@
+  Copyright 1993, Geoff Kuenning, Granada Hills, CA
+  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+
+  1. Redistributions of source code must retain the above copyright
+     notice, this list of conditions and the following disclaimer.
+  2. Redistributions in binary form must reproduce the above copyright
+     notice, this list of conditions and the following disclaimer in the
+     documentation and/or other materials provided with the distribution.
+  3. All modifications to the source code must be clearly marked as
+     such.  Binary redistributions based on modified source code
+     must be clearly marked as modified versions in the documentation
+     and/or other materials provided with the distribution.
+  4. All advertising materials mentioning features or use of this software
+     must display the following acknowledgment:
+     This product includes software developed by Geoff Kuenning and
+     other unpaid contributors.
+  5. The name of Geoff Kuenning may not be used to endorse or promote
+     products derived from this software without specific prior
+     written permission.
+
+  THIS SOFTWARE IS PROVIDED BY GEOFF KUENNING AND CONTRIBUTORS ``AS
+  IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+  FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL GEOFF
+  KUENNING OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+  POSSIBILITY OF SUCH DAMAGE.
diff --git a/org.eclipse.cdt.ui/build.properties b/org.eclipse.cdt.ui/build.properties
new file mode 100644 (file)
index 0000000..3f4284e
--- /dev/null
@@ -0,0 +1,13 @@
+source.. = src/
+bin.includes = META-INF/,\
+               .,\
+               ChangeLog-browser,\
+               about_files/,\
+               icons/,\
+               plugin.properties,\
+               dictionaries/,\
+               about.html,\
+               plugin.xml,\
+               .options,\
+               doxygenTags.csv,\
+               templates/
diff --git a/org.eclipse.cdt.ui/dictionaries/en_GB.dictionary b/org.eclipse.cdt.ui/dictionaries/en_GB.dictionary
new file mode 100644 (file)
index 0000000..a272fb4
--- /dev/null
@@ -0,0 +1,49818 @@
+ACM
+ANSI
+ASAP
+ASCII
+ATM's
+Achilles
+Ada
+Ada's
+Afghanistan
+Afghanistan's
+Africa
+Africa's
+African
+African's
+Africans
+Airedale
+Airedale's
+Alabama
+Alabama's
+Alabamian
+Alabamian's
+Alaska
+Alaska's
+Albania
+Albania's
+Albanian
+Albanian's
+Albanians
+Alcibiades
+Alden
+Alden's
+Algeria
+Algeria's
+Algerian
+Algerian's
+Algol
+Algol's
+Allah
+Allah's
+Alyssa
+Alyssa's
+Amanda
+Amanda's
+Amdahl
+Amdahl's
+Amelia
+Amelia's
+America
+America's
+American
+American's
+Americana
+Americans
+Americas
+Ames
+Amsterdam
+Amsterdam's
+Amtrak
+Amtrak's
+Anabaptist
+Anabaptist's
+Anabaptists
+Andorra
+Andorra's
+Angeleno
+Angeleno's
+Angelenos
+Anglican
+Anglican's
+Anglicanism
+Anglicanism's
+Anglicans
+Anglophilia
+Anglophilia's
+Anglophobia
+Anglophobia's
+Angola
+Angola's
+Antarctica
+Antarctica's
+Aphrodite
+Aphrodite's
+Apollo
+Apollo's
+Apollonian
+Appalachia
+Appalachia's
+Appalachian
+Appalachian's
+Appalachians
+April
+April's
+Aprils
+Aquarius
+Arab
+Arab's
+Arabia
+Arabia's
+Arabian
+Arabian's
+Arabians
+Arabic
+Arabic's
+Arabs
+Archie
+Archie's
+Argentina
+Argentina's
+Argo
+Argo's
+Argos
+Arianism
+Arianism's
+Arianist
+Arianist's
+Arianists
+Aries
+Aristotelian
+Aristotelian's
+Aristotle
+Aristotle's
+Arizona
+Arizona's
+Arkansas
+Arkansas's
+Armageddon
+Armageddon's
+Armenian
+Armenian's
+Armour
+Armour's
+Armstrong
+Armstrong's
+Artemis
+Aryan
+Aryan's
+Aryans
+Asia
+Asia's
+Asian
+Asian's
+Asians
+Asiatic
+Asiatic's
+Asiatics
+Assyrian
+Assyrian's
+Assyriology
+Assyriology's
+Athena
+Athena's
+Athenian
+Athenian's
+Athenians
+Athens
+Atlantic
+Atlantic's
+Auckland
+Auckland's
+Audubon
+Audubon's
+Augusta
+Augusta's
+Augusts
+Austin
+Austin's
+Australia
+Australia's
+Australian
+Australian's
+Australians
+Austria
+Austria's
+Austrian
+Austrian's
+Ave
+BSD
+Babel
+Babel's
+Bach
+Bach's
+Bagrodia
+Bagrodia's
+Bagrodias
+Balkan
+Balkan's
+Balkans
+Baltic
+Baltic's
+Bangladesh
+Bangladesh's
+Bantu
+Bantu's
+Bantus
+Barbados
+Baxter
+Baxter's
+Beethoven
+Beethoven's
+Belgian
+Belgian's
+Belgians
+Belgium
+Belgium's
+Bellovin
+Bellovin's
+Belushi
+Belushi's
+Benedict
+Benedict's
+Benedictine
+Benedictine's
+Bengal
+Bengal's
+Bengali
+Bengali's
+Benzedrine
+Benzedrine's
+Bergsten
+Bergsten's
+Berkeley
+Berkeley's
+Berlin
+Berlin's
+Berliner
+Berliners
+Bermuda
+Bermuda's
+Bessel
+Bessel's
+Beverly
+Beverly's
+Bilbo
+Bilbo's
+Bolivia
+Bolivia's
+Bologna
+Bologna's
+Bolshevik
+Bolshevik's
+Bolsheviks
+Bolshevism
+Bolshevism's
+Borneo
+Borneo's
+Boston
+Boston's
+Bostonian
+Bostonian's
+Bostonians
+Botswana
+Botswana's
+Bourne
+Bourne's
+Brazil
+Brazil's
+Brazilian
+Brazilian's
+Bresenham
+Bresenham's
+Britain
+Britain's
+British
+Britisher
+Britishly
+Briton
+Briton's
+Britons
+Buehring
+Buehring's
+CDC
+CDC's
+CEO
+CMOS
+CPU
+CPU's
+CPUs
+California
+California's
+Californian
+Californian's
+Californians
+Cambridge
+Cambridge's
+Canada
+Canada's
+Carolina
+Carolina's
+Carolinas
+Cartesian
+Chinese
+Chinese's
+Christian
+Christian's
+Christians
+Christiansen
+Christmas
+Cobol
+Cobol's
+Coleman
+Coleman's
+Colorado
+Colorado's
+Comdex
+Comdex's
+Cray
+Cray's
+Crays
+Cupertino
+Cupertino's
+Czechoslovakian
+DARPA
+DARPA's
+DECNET
+DOS
+Dan
+Dan's
+DeMorgan
+DeMorgan's
+Debbie
+Debbie's
+December
+December's
+Decembers
+Delaware
+Delaware's
+Denmark
+Denmark's
+Dijkstra
+Dijkstra's
+Diophantine
+Dylan
+Dylan's
+EDP
+EGA
+EGA's
+Edsger
+Edsger's
+Ellen
+Ellen's
+Elvis
+Elvis's
+English
+English's
+Erlang
+Erlang's
+Ethernet
+Ethernet's
+Ethernets
+Europe
+Europe's
+European
+European's
+Europeans
+FIFO
+Fairbanks
+Februaries
+February
+February's
+Felder
+Florida
+Florida's
+Fortran
+Fortran's
+Fourier
+Fourier's
+France
+France's
+Frances
+French
+French's
+Friday
+Friday's
+Fridays
+GPSS
+Galvin
+Galvin's
+Garfunkel
+Geoff
+Geoff's
+Geoffrey
+Geoffrey's
+German
+German's
+Germans
+Germany
+Germany's
+Gibson
+Gibson's
+Gipsies
+Gipsy
+Gipsy's
+Godzilla
+Godzilla's
+Gothic
+Greek
+Greek's
+Greeks
+Greg
+Greg's
+Heinlein
+Heinlein's
+Hewlett
+Hewlett's
+Holland
+Holland's
+Hollander
+Hollanders
+Hollands
+Honda
+Honda's
+Hz
+I'd
+I'll
+I'm
+I've
+IBM
+IBM's
+IEEE
+ITCorp
+ITCorp's
+ITcorp
+ITcorp's
+Illinois
+Inc
+India
+India's
+Indian
+Indian's
+Indiana
+Indiana's
+Indians
+Intel
+Intel's
+Internet
+Internet's
+Iran
+Iran's
+Ireland
+Ireland's
+Israel
+Israel's
+Israeli
+Israeli's
+Israelis
+Italian
+Italian's
+Italians
+James
+Januaries
+January
+January's
+Japan
+Japan's
+Japanese
+Japanese's
+Jefferson
+Jefferson's
+Jill
+Jill's
+Johnnie
+Johnnie's
+Jr
+Julie
+Julie's
+Julies
+July
+July's
+Julys
+June
+June's
+Junes
+Klein
+Klein's
+Kleinrock
+Kleinrock's
+Kline
+Kline's
+Knuth
+Knuth's
+Kuenning
+Kuenning's
+LED's
+LEDs
+LaTeX
+LaTeX's
+Lagrangian
+Lagrangian's
+Lamport
+Lamport's
+Latin
+Latin's
+Laurie
+Laurie's
+Lenten
+Liz
+Liz's
+Lyle
+Lyle's
+MHz
+MIT
+MIT's
+MacDraw
+MacDraw's
+MacIntosh
+MacIntosh's
+MacPaint
+MacPaint's
+Mafia
+Mafia's
+Malibu
+Malibu's
+Mandelbrot
+Mandelbrot's
+Manhattan
+Manhattan's
+Manila
+Manila's
+Marianne
+Marianne's
+Mary
+Mary's
+Maryland
+Maryland's
+Marylanders
+Massachusetts
+Massey
+Massey's
+Matt
+Matt's
+Maxtor
+Maxtor's
+McElhaney
+McElhaney's
+McKenzie
+McKenzie's
+McMartin
+McMartin's
+Medusa
+Medusa's
+Michigan
+Michigan's
+Microport
+Microport's
+Microsoft
+Microsoft's
+Midwest
+Minnesota
+Minnesota's
+Monday
+Monday's
+Mondays
+Montana
+Montana's
+Montanan
+Montanan's
+Moslem
+Moslem's
+Moslems
+Motorola
+Motorola's
+Mr
+Mrs
+Ms
+Multibus
+Multibus's
+Multics
+Munsey
+Munsey's
+Muslim
+Muslim's
+Muslims
+NFS
+Nazi
+Nazi's
+Nazis
+NeWS
+Nebraska
+Nebraska's
+Nebraskan
+Nebraskan's
+Negro
+Negro's
+Negroes
+Nepal
+Nepal's
+Netherlands
+Newtonian
+November
+November's
+Novembers
+OEM
+OEM's
+OEMS
+OK
+OS
+OS's
+October
+October's
+Octobers
+Oderberg
+Oderberg's
+Oderbergs
+Oedipus
+Ohio
+Ohio's
+Oklahoma
+Oklahoma's
+Oklahoman
+Oklahoman's
+Oliver's
+PC
+PC's
+PCs
+PDP
+Packard
+Packard's
+Packards
+Palestinian
+Pascal
+Pascal's
+Pennsylvania
+Pennsylvania's
+Peter's
+Petkiewicz
+Petkiewicz's
+PhD
+Planck
+Planck's
+Poland
+Poland's
+Popek
+Popek's
+Popeks
+Prime's
+Prokofiev
+Prokofiev's
+QA
+RCS
+ROM
+RSX
+Redford
+Redford's
+Rick
+Rick's
+Ritchie
+Ritchie's
+Robert
+Robert's
+Roberts
+Robinson
+Robinson's
+Roman
+Roman's
+Romans
+Roy
+Roy's
+Rubens
+Russian
+Russian's
+Russians
+SCCS
+SMTP
+Sally's
+Salz
+Salz's
+Sam
+Sam's
+Saturday
+Saturday's
+Saturdays
+Scotland
+Scotland's
+Seagate
+Seagate's
+September
+September's
+Septembers
+Signor
+Sikkim
+Sikkim's
+Sikkimese
+Silverstein
+Silverstein's
+Singapore
+Singapore's
+Spafford
+Spafford's
+Spain
+Spain's
+Spanish
+Spanish's
+Spencer
+Spencer's
+Spuds
+Sr
+Sunday
+Sunday's
+Sundays
+TCP
+TV's
+TeX
+TeX's
+Teflon
+Teflon's
+Tektronix
+Tektronix's
+Tennessee
+Tennessee's
+Texas
+Texas's
+Texases
+Thursday
+Thursday's
+Thursdays
+Tinseltown
+Tinseltown's
+Trudeau
+Trudeau's
+Tuesday
+Tuesday's
+Tuesdays
+Turing
+Turing's
+UART
+UCLA
+UNIX's
+USC
+USC's
+USG
+USG's
+Ultrix
+Ultrix's
+Unix
+Unix's
+Usenet
+Usenet's
+Usenix
+Usenix's
+Utah
+Utah's
+VAR
+VCR
+VMS
+VMS's
+Vanessa
+Vanessa's
+Vax
+Vax's
+Ventura
+Ventura's
+Virginia
+Virginia's
+Warnock
+Warnock's
+Washington
+Washington's
+Wednesday
+Wednesday's
+Wednesdays
+Weibull
+Weibull's
+Wilbur
+Wilbur's
+Willisson
+Willisson's
+Wilson
+Wilson's
+Xenix
+Xenix's
+Xeroxed
+Xeroxes
+Xeroxing
+Yamaha
+Yamaha's
+Yentl
+Yentl's
+York
+York's
+Yorker
+Yorkers
+Yorks
+Zealand
+Zealand's
+Zulu
+Zulu's
+Zulus
+a
+aback
+abaft
+abandon
+abandoned
+abandoner
+abandoning
+abandonment
+abandonments
+abandons
+abase
+abased
+abasement
+abasements
+abaser
+abases
+abash
+abashed
+abashes
+abashing
+abasing
+abate
+abated
+abatement
+abatements
+abater
+abates
+abating
+abbe
+abbey
+abbey's
+abbeys
+abbot
+abbot's
+abbots
+abbreviate
+abbreviated
+abbreviates
+abbreviating
+abbreviation
+abbreviations
+abdomen
+abdomen's
+abdomens
+abdominal
+abdominally
+abduct
+abducted
+abducting
+abduction
+abduction's
+abductions
+abductor
+abductor's
+abductors
+abducts
+abed
+aberrant
+aberrantly
+aberration
+aberrations
+abet
+abets
+abetted
+abetter
+abetting
+abettor
+abeyance
+abhor
+abhorred
+abhorrent
+abhorrently
+abhorrer
+abhorring
+abhors
+abide
+abided
+abider
+abides
+abiding
+abidingly
+abilities
+ability
+ability's
+abject
+abjection
+abjections
+abjectly
+abjectness
+abjure
+abjured
+abjurer
+abjures
+abjuring
+ablate
+ablated
+ablates
+ablating
+ablation
+ablative
+ablatively
+ablaze
+able
+abler
+ablest
+ablution
+ablutions
+ably
+abnormal
+abnormalities
+abnormality
+abnormally
+aboard
+abode
+abode's
+abodes
+abolish
+abolished
+abolisher
+abolishers
+abolishes
+abolishing
+abolishment
+abolishment's
+abolishments
+abolition
+abolitionist
+abolitionists
+abominable
+aboriginal
+aboriginally
+aborigine
+aborigine's
+aborigines
+abort
+aborted
+aborter
+aborting
+abortion
+abortion's
+abortions
+abortive
+abortively
+abortiveness
+aborts
+abound
+abounded
+abounding
+abounds
+about
+above
+aboveground
+abrade
+abraded
+abrader
+abrades
+abrading
+abrasion
+abrasion's
+abrasions
+abreaction
+abreaction's
+abreactions
+abreast
+abridge
+abridged
+abridger
+abridges
+abridging
+abridgment
+abroad
+abrogate
+abrogated
+abrogates
+abrogating
+abrogation
+abrupt
+abruptly
+abruptness
+abscess
+abscessed
+abscesses
+abscissa
+abscissa's
+abscissas
+abscond
+absconded
+absconder
+absconding
+absconds
+absence
+absence's
+absences
+absent
+absented
+absentee
+absentee's
+absenteeism
+absentees
+absentia
+absenting
+absently
+absentminded
+absentmindedly
+absentmindedness
+absents
+absinthe
+absolute
+absolutely
+absoluteness
+absolutes
+absolution
+absolve
+absolved
+absolver
+absolves
+absolving
+absorb
+absorbed
+absorbency
+absorbent
+absorbent's
+absorbents
+absorber
+absorbing
+absorbingly
+absorbs
+absorption
+absorption's
+absorptions
+absorptive
+abstain
+abstained
+abstainer
+abstaining
+abstains
+abstention
+abstentions
+abstinence
+abstract
+abstracted
+abstractedly
+abstractedness
+abstracter
+abstracting
+abstraction
+abstraction's
+abstractionism
+abstractionist
+abstractionists
+abstractions
+abstractive
+abstractly
+abstractness
+abstractor
+abstractor's
+abstractors
+abstracts
+abstruse
+abstrusely
+abstruseness
+abstrusenesses
+absurd
+absurdities
+absurdity
+absurdity's
+absurdly
+absurdness
+abundance
+abundances
+abundant
+abundantly
+abuse
+abused
+abuser
+abusers
+abuses
+abusing
+abusive
+abusively
+abusiveness
+abut
+abutment
+abutments
+abuts
+abutted
+abutter
+abutter's
+abutters
+abutting
+abysmal
+abysmally
+abyss
+abyss's
+abysses
+acacia
+academia
+academic
+academically
+academics
+academies
+academy
+academy's
+accede
+acceded
+accedes
+acceding
+accelerate
+accelerated
+accelerates
+accelerating
+acceleratingly
+acceleration
+accelerations
+accelerative
+accelerator
+accelerators
+accelerometer
+accelerometer's
+accelerometers
+accent
+accented
+accenting
+accents
+accentual
+accentually
+accentuate
+accentuated
+accentuates
+accentuating
+accentuation
+accept
+acceptability
+acceptable
+acceptableness
+acceptably
+acceptance
+acceptance's
+acceptances
+accepted
+acceptedly
+accepter
+accepters
+accepting
+acceptingly
+acceptingness
+acceptive
+acceptor
+acceptor's
+acceptors
+accepts
+access
+accessed
+accesses
+accessibility
+accessible
+accessibly
+accessing
+accession
+accession's
+accessions
+accessories
+accessory
+accessory's
+accident
+accident's
+accidental
+accidentally
+accidentalness
+accidently
+accidents
+acclaim
+acclaimed
+acclaimer
+acclaiming
+acclaims
+acclamation
+acclimate
+acclimated
+acclimates
+acclimating
+acclimation
+accolade
+accolades
+accommodate
+accommodated
+accommodates
+accommodating
+accommodatingly
+accommodation
+accommodations
+accommodative
+accommodativeness
+accompanied
+accompanier
+accompanies
+accompaniment
+accompaniment's
+accompaniments
+accompanist
+accompanist's
+accompanists
+accompany
+accompanying
+accomplice
+accomplices
+accomplish
+accomplished
+accomplisher
+accomplishers
+accomplishes
+accomplishing
+accomplishment
+accomplishment's
+accomplishments
+accord
+accordance
+accordances
+accorded
+accorder
+accorders
+according
+accordingly
+accordion
+accordion's
+accordions
+accords
+accost
+accosted
+accosting
+accosts
+account
+accountabilities
+accountability
+accountable
+accountableness
+accountably
+accountancy
+accountant
+accountant's
+accountants
+accounted
+accounting
+accountings
+accounts
+accredit
+accreditation
+accreditations
+accredited
+accretion
+accretion's
+accretions
+accrue
+accrued
+accrues
+accruing
+acculturate
+acculturated
+acculturates
+acculturating
+acculturation
+acculturative
+accumulate
+accumulated
+accumulates
+accumulating
+accumulation
+accumulations
+accumulative
+accumulatively
+accumulativeness
+accumulator
+accumulator's
+accumulators
+accuracies
+accuracy
+accurate
+accurately
+accurateness
+accursed
+accursedly
+accursedness
+accusal
+accusation
+accusation's
+accusations
+accusative
+accuse
+accused
+accuser
+accusers
+accuses
+accusing
+accusingly
+accustom
+accustomed
+accustomedness
+accustoming
+accustoms
+ace
+ace's
+aced
+acer
+aces
+acetate
+acetone
+acetylene
+ache
+ached
+aches
+achievable
+achieve
+achieved
+achievement
+achievement's
+achievements
+achiever
+achievers
+achieves
+achieving
+aching
+achingly
+acid
+acidic
+acidities
+acidity
+acidly
+acidness
+acids
+acidulous
+acing
+acknowledge
+acknowledged
+acknowledgedly
+acknowledger
+acknowledgers
+acknowledges
+acknowledging
+acme
+acne
+acned
+acolyte
+acolytes
+acorn
+acorn's
+acorns
+acoustic
+acoustical
+acoustically
+acoustician
+acoustics
+acquaint
+acquaintance
+acquaintance's
+acquaintances
+acquainted
+acquainting
+acquaints
+acquiesce
+acquiesced
+acquiescence
+acquiesces
+acquiescing
+acquirable
+acquire
+acquired
+acquires
+acquiring
+acquisition
+acquisition's
+acquisitions
+acquisitiveness
+acquit
+acquits
+acquittal
+acquittals
+acquitted
+acquitter
+acquitting
+acre
+acre's
+acreage
+acres
+acrid
+acridly
+acridness
+acrimonious
+acrimoniously
+acrimony
+acrobat
+acrobat's
+acrobatic
+acrobatics
+acrobats
+acronym
+acronym's
+acronyms
+acropolis
+across
+acrylic
+act
+acted
+acting
+actinium
+actinometer
+actinometer's
+actinometers
+action
+action's
+actions
+activate
+activated
+activates
+activating
+activation
+activations
+activator
+activator's
+activators
+active
+actively
+activeness
+activism
+activist
+activist's
+activists
+activities
+activity
+activity's
+actor
+actor's
+actors
+actress
+actress's
+actresses
+acts
+actual
+actualities
+actuality
+actually
+actuals
+actuarial
+actuarially
+actuate
+actuated
+actuates
+actuating
+actuation
+actuator
+actuator's
+actuators
+acuity
+acumen
+acute
+acutely
+acuteness
+acuter
+acutest
+acyclic
+acyclically
+ad
+adage
+adages
+adagio
+adagios
+adamant
+adamantly
+adapt
+adaptability
+adaptable
+adaptation
+adaptation's
+adaptations
+adapted
+adaptedness
+adapter
+adapters
+adapting
+adaption
+adaptive
+adaptively
+adaptiveness
+adaptor
+adaptors
+adapts
+add
+added
+addenda
+addendum
+adder
+adders
+addict
+addicted
+addicting
+addiction
+addiction's
+addictions
+addictive
+addicts
+adding
+addition
+addition's
+additional
+additionally
+additions
+additive
+additive's
+additively
+additives
+additivity
+address
+addressability
+addressable
+addressed
+addressee
+addressee's
+addressees
+addresser
+addressers
+addresses
+addressing
+adds
+adduce
+adduced
+adducer
+adduces
+adducing
+adduct
+adducted
+adducting
+adduction
+adductive
+adductor
+adducts
+adept
+adeptly
+adeptness
+adepts
+adequacies
+adequacy
+adequate
+adequately
+adequateness
+adhere
+adhered
+adherence
+adherences
+adherent
+adherent's
+adherently
+adherents
+adherer
+adherers
+adheres
+adhering
+adhesion
+adhesions
+adhesive
+adhesive's
+adhesively
+adhesiveness
+adhesives
+adiabatic
+adiabatically
+adieu
+adjacency
+adjacent
+adjacently
+adjective
+adjective's
+adjectively
+adjectives
+adjoin
+adjoined
+adjoining
+adjoins
+adjourn
+adjourned
+adjourning
+adjournment
+adjourns
+adjudge
+adjudged
+adjudges
+adjudging
+adjudicate
+adjudicated
+adjudicates
+adjudicating
+adjudication
+adjudication's
+adjudications
+adjudicative
+adjunct
+adjunct's
+adjunctive
+adjunctly
+adjuncts
+adjure
+adjured
+adjures
+adjuring
+adjust
+adjustable
+adjustably
+adjusted
+adjuster
+adjusters
+adjusting
+adjustive
+adjustment
+adjustment's
+adjustments
+adjustor
+adjustor's
+adjustors
+adjusts
+adjutant
+adjutants
+administer
+administered
+administering
+administerings
+administers
+administration
+administration's
+administrations
+administrative
+administratively
+administrator
+administrator's
+administrators
+admirable
+admirableness
+admirably
+admiral
+admiral's
+admirals
+admiralty
+admiration
+admirations
+admire
+admired
+admirer
+admirers
+admires
+admiring
+admiringly
+admissibility
+admissible
+admission
+admission's
+admissions
+admit
+admits
+admittance
+admitted
+admittedly
+admitting
+admix
+admixed
+admixes
+admixture
+admonish
+admonished
+admonisher
+admonishes
+admonishing
+admonishingly
+admonishment
+admonishment's
+admonishments
+admonition
+admonition's
+admonitions
+ado
+adobe
+adolescence
+adolescent
+adolescent's
+adolescently
+adolescents
+adopt
+adopted
+adopter
+adopters
+adopting
+adoption
+adoption's
+adoptions
+adoptive
+adoptively
+adopts
+adorable
+adorableness
+adoration
+adore
+adored
+adorer
+adores
+adoring
+adorn
+adorned
+adorning
+adornment
+adornment's
+adornments
+adorns
+adrenal
+adrenaline
+adrenally
+adrift
+adroit
+adroitly
+adroitness
+ads
+adsorb
+adsorbed
+adsorbing
+adsorbs
+adsorption
+adulate
+adulating
+adulation
+adulations
+adult
+adult's
+adulterate
+adulterated
+adulterates
+adulterating
+adulteration
+adulterer
+adulterer's
+adulterers
+adulterous
+adulterously
+adultery
+adulthood
+adultly
+adultness
+adults
+adumbrate
+adumbrated
+adumbrates
+adumbrating
+adumbration
+adumbrative
+adumbratively
+advance
+advanced
+advancement
+advancement's
+advancements
+advancer
+advancers
+advances
+advancing
+advantage
+advantaged
+advantageous
+advantageously
+advantageousness
+advantages
+advantaging
+advent
+adventist
+adventists
+adventitious
+adventitiously
+adventitiousness
+adventive
+adventively
+adventure
+adventured
+adventurer
+adventurers
+adventures
+adventuring
+adventurous
+adventurously
+adventurousness
+adverb
+adverb's
+adverbial
+adverbially
+adverbs
+adversaries
+adversary
+adversary's
+adverse
+adversed
+adversely
+adverses
+adversing
+adversities
+adversity
+advertise
+advertised
+advertisement
+advertisement's
+advertisements
+advertiser
+advertisers
+advertises
+advertising
+advice
+advisability
+advisable
+advisableness
+advisably
+advise
+advised
+advisedly
+advisee
+advisee's
+advisees
+advisement
+advisements
+adviser
+adviser's
+advisers
+advises
+advising
+advisor
+advisor's
+advisors
+advisory
+advocacy
+advocate
+advocated
+advocates
+advocating
+advocation
+advocative
+aegis
+aerate
+aerated
+aerates
+aerating
+aeration
+aerator
+aerators
+aerial
+aerial's
+aerially
+aerials
+aeroacoustic
+aerobic
+aerobics
+aerodynamic
+aerodynamics
+aeronautic
+aeronautical
+aeronautically
+aeronautics
+aerosol
+aerosols
+aerospace
+afar
+afars
+affable
+affair
+affair's
+affairs
+affect
+affectation
+affectation's
+affectations
+affected
+affectedly
+affectedness
+affecter
+affecting
+affectingly
+affection
+affection's
+affectionate
+affectionately
+affectioned
+affections
+affective
+affectively
+affects
+afferent
+afferently
+affianced
+affidavit
+affidavit's
+affidavits
+affiliate
+affiliated
+affiliates
+affiliating
+affiliation
+affiliations
+affinities
+affinity
+affinity's
+affirm
+affirmation
+affirmation's
+affirmations
+affirmative
+affirmatively
+affirmed
+affirming
+affirms
+affix
+affixed
+affixes
+affixing
+afflict
+afflicted
+afflicting
+affliction
+affliction's
+afflictions
+afflictive
+afflictively
+afflicts
+affluence
+affluent
+affluently
+afford
+affordable
+afforded
+affording
+affords
+affricate
+affricates
+affrication
+affricative
+affright
+affront
+affronted
+affronting
+affronts
+afghan
+afghans
+aficionado
+aficionados
+afield
+afire
+aflame
+afloat
+afoot
+afore
+aforementioned
+aforesaid
+aforethought
+afoul
+afraid
+afresh
+aft
+after
+aftereffect
+aftereffects
+aftermath
+aftermost
+afternoon
+afternoon's
+afternoons
+afters
+aftershock
+aftershock's
+aftershocks
+afterthought
+afterthoughts
+afterward
+afterwards
+again
+against
+agape
+agar
+agate
+agates
+age
+aged
+agedly
+agedness
+ageless
+agelessly
+agelessness
+agencies
+agency
+agency's
+agenda
+agenda's
+agendas
+agent
+agent's
+agentive
+agents
+ager
+agers
+ages
+agglomerate
+agglomerated
+agglomerates
+agglomeration
+agglomerative
+agglutinate
+agglutinated
+agglutinates
+agglutinating
+agglutination
+agglutinative
+agglutinin
+agglutinins
+aggravate
+aggravated
+aggravates
+aggravating
+aggravation
+aggravations
+aggregate
+aggregated
+aggregately
+aggregateness
+aggregates
+aggregating
+aggregation
+aggregations
+aggregative
+aggregatively
+aggression
+aggression's
+aggressions
+aggressive
+aggressively
+aggressiveness
+aggressor
+aggressors
+aggrieve
+aggrieved
+aggrievedly
+aggrieves
+aggrieving
+aghast
+agile
+agilely
+agility
+aging
+agitate
+agitated
+agitatedly
+agitates
+agitating
+agitation
+agitations
+agitative
+agitator
+agitator's
+agitators
+agleam
+aglow
+agnostic
+agnostic's
+agnostics
+ago
+agog
+agonies
+agony
+agrarian
+agree
+agreeable
+agreeableness
+agreeably
+agreed
+agreeing
+agreement
+agreement's
+agreements
+agreer
+agreers
+agrees
+agricultural
+agriculturally
+agriculture
+ague
+ah
+ahead
+aid
+aide
+aided
+aider
+aides
+aiding
+aids
+ail
+ailed
+aileron
+ailerons
+ailing
+ailment
+ailment's
+ailments
+ails
+aim
+aimed
+aimer
+aimers
+aiming
+aimless
+aimlessly
+aimlessness
+aims
+air
+airbag
+airbag's
+airbags
+airborne
+aircraft
+aircrafts
+airdrop
+airdrops
+aired
+airer
+airers
+airfield
+airfield's
+airfields
+airflow
+airframe
+airframe's
+airframes
+airhead
+airier
+airiest
+airily
+airiness
+airing
+airings
+airless
+airlessness
+airlift
+airlift's
+airlifts
+airline
+airline's
+airliner
+airliner's
+airliners
+airlines
+airlock
+airlock's
+airlocks
+airmail
+airmails
+airman
+airmen
+airport
+airport's
+airports
+airs
+airship
+airship's
+airships
+airspace
+airspeed
+airspeeds
+airstrip
+airstrip's
+airstrips
+airway
+airway's
+airways
+airy
+aisle
+aisles
+ajar
+akimbo
+akin
+alabaster
+alacrity
+alarm
+alarmed
+alarming
+alarmingly
+alarmist
+alarms
+alas
+alba
+albacore
+albeit
+album
+albumen
+albumin
+albums
+alchemy
+alcohol
+alcohol's
+alcoholic
+alcoholic's
+alcoholics
+alcoholism
+alcoholisms
+alcohols
+alcove
+alcove's
+alcoved
+alcoves
+alder
+alderman
+alderman's
+aldermen
+ale
+alee
+alert
+alerted
+alertedly
+alerter
+alerters
+alerting
+alertly
+alertness
+alerts
+alfalfa
+alfresco
+alga
+algae
+algaecide
+algebra
+algebra's
+algebraic
+algebraically
+algebras
+alginate
+alginates
+algorithm
+algorithm's
+algorithmic
+algorithmically
+algorithms
+alias
+aliased
+aliases
+aliasing
+alibi
+alibi's
+alibis
+alien
+alien's
+alienate
+alienated
+alienates
+alienating
+alienation
+aliens
+alight
+alighted
+alighting
+align
+aligned
+aligner
+aligning
+alignment
+alignments
+aligns
+alike
+alikeness
+aliment
+aliments
+alimony
+alive
+aliveness
+alkali
+alkali's
+alkaline
+alkalis
+alkaloid
+alkaloid's
+alkaloids
+alkyl
+all
+allay
+allayed
+allaying
+allays
+allegation
+allegation's
+allegations
+allege
+alleged
+allegedly
+alleges
+allegiance
+allegiance's
+allegiances
+alleging
+allegoric
+allegorical
+allegorically
+allegoricalness
+allegories
+allegory
+allegory's
+allegretto
+allegretto's
+allegrettos
+allegro
+allegro's
+allegros
+allele
+alleles
+allemande
+allergic
+allergies
+allergy
+allergy's
+alleviate
+alleviated
+alleviates
+alleviating
+alleviation
+alleviative
+alleviator
+alleviator's
+alleviators
+alley
+alley's
+alleys
+alleyway
+alleyway's
+alleyways
+alliance
+alliance's
+alliances
+allied
+allier
+allies
+alligator
+alligator's
+alligatored
+alligators
+alliteration
+alliteration's
+alliterations
+alliterative
+alliteratively
+allocate
+allocated
+allocates
+allocating
+allocation
+allocation's
+allocations
+allocative
+allocator
+allocator's
+allocators
+allophone
+allophones
+allophonic
+allot
+alloted
+allotment
+allotment's
+allotments
+allots
+allotted
+allotter
+allotting
+allow
+allowable
+allowableness
+allowably
+allowance
+allowance's
+allowanced
+allowances
+allowancing
+allowed
+allowedly
+allowing
+allows
+alloy
+alloy's
+alloyed
+alloying
+alloys
+allude
+alluded
+alludes
+alluding
+allure
+allured
+allurement
+allures
+alluring
+allusion
+allusion's
+allusions
+allusive
+allusively
+allusiveness
+ally
+allying
+alma
+almanac
+almanac's
+almanacs
+almightiness
+almighty
+almond
+almond's
+almonds
+almoner
+almost
+alms
+almsman
+alnico
+aloe
+aloes
+aloft
+aloha
+alone
+aloneness
+along
+alongside
+aloof
+aloofly
+aloofness
+aloud
+alpha
+alphabet
+alphabet's
+alphabetic
+alphabetical
+alphabetically
+alphabetics
+alphabets
+alphanumeric
+alphanumerics
+alpine
+alps
+already
+also
+altar
+altar's
+altars
+alter
+alterable
+alteration
+alteration's
+alterations
+altercation
+altercation's
+altercations
+altered
+alterer
+alterers
+altering
+alternate
+alternated
+alternately
+alternates
+alternating
+alternation
+alternations
+alternative
+alternatively
+alternativeness
+alternatives
+alternator
+alternator's
+alternators
+alters
+although
+altitude
+altitudes
+alto
+alto's
+altogether
+altos
+altruism
+altruist
+altruistic
+altruistically
+altruists
+alum
+alumna
+alumna's
+alumnae
+alumni
+alumnus
+alundum
+alveolar
+alveolarly
+alveoli
+alveolus
+always
+am
+amain
+amalgam
+amalgam's
+amalgamate
+amalgamated
+amalgamates
+amalgamating
+amalgamation
+amalgamations
+amalgamative
+amalgams
+amanuensis
+amass
+amassed
+amasser
+amasses
+amassing
+amateur
+amateur's
+amateurish
+amateurishly
+amateurishness
+amateurism
+amateurs
+amatory
+amaze
+amazed
+amazedly
+amazement
+amazer
+amazers
+amazes
+amazing
+amazingly
+amazon
+amazon's
+amazons
+ambassador
+ambassador's
+ambassadors
+amber
+ambiance
+ambiances
+ambidextrous
+ambidextrously
+ambient
+ambiguities
+ambiguity
+ambiguity's
+ambiguous
+ambiguously
+ambiguousness
+ambition
+ambition's
+ambitions
+ambitious
+ambitiously
+ambitiousness
+ambivalence
+ambivalent
+ambivalently
+amble
+ambled
+ambler
+ambles
+ambling
+ambrosial
+ambrosially
+ambulance
+ambulance's
+ambulances
+ambulatory
+ambuscade
+ambuscader
+ambush
+ambushed
+ambusher
+ambushes
+ameliorate
+ameliorated
+ameliorating
+amelioration
+ameliorative
+amen
+amenable
+amend
+amended
+amender
+amending
+amendment
+amendment's
+amendments
+amends
+amenities
+amenity
+americium
+amiable
+amiableness
+amiabler
+amiablest
+amicable
+amicableness
+amicably
+amid
+amide
+amidst
+amigo
+amino
+amiss
+amity
+ammo
+ammonia
+ammoniac
+ammonias
+ammonium
+ammunition
+ammunitions
+amnesty
+amoeba
+amoeba's
+amoebas
+amok
+among
+amongst
+amoral
+amorality
+amorally
+amorous
+amorously
+amorousness
+amorphous
+amorphously
+amorphousness
+amount
+amounted
+amounter
+amounters
+amounting
+amounts
+amour
+amour's
+amours
+amp
+ampere
+amperes
+ampersand
+ampersand's
+ampersands
+amphetamine
+amphetamines
+amphibian
+amphibian's
+amphibians
+amphibious
+amphibiously
+amphibiousness
+amphibology
+ample
+ampleness
+ampler
+amplest
+amplification
+amplifications
+amplified
+amplifier
+amplifiers
+amplifies
+amplify
+amplifying
+amplitude
+amplitude's
+amplitudes
+amply
+ampoule
+ampoule's
+ampoules
+amps
+amputate
+amputated
+amputates
+amputating
+amputation
+ams
+amulet
+amulets
+amuse
+amused
+amusedly
+amusement
+amusement's
+amusements
+amuser
+amusers
+amuses
+amusing
+amusingly
+amusingness
+amusive
+amyl
+an
+anachronism
+anachronism's
+anachronisms
+anachronistically
+anaconda
+anacondas
+anaerobic
+anagram
+anagram's
+anagrams
+anal
+analogical
+analogically
+analogies
+analogous
+analogously
+analogousness
+analogy
+analogy's
+analysis
+analyst
+analyst's
+analysts
+analytic
+analytical
+analytically
+analyticities
+analyticity
+analytics
+anaphora
+anaphoric
+anaphorically
+anaplasmosis
+anarchic
+anarchical
+anarchist
+anarchist's
+anarchists
+anarchy
+anastomoses
+anastomosis
+anastomotic
+anathema
+anatomic
+anatomical
+anatomically
+anatomicals
+anatomy
+ancestor
+ancestor's
+ancestors
+ancestral
+ancestrally
+ancestry
+anchor
+anchorage
+anchorage's
+anchorages
+anchored
+anchoring
+anchorite
+anchoritism
+anchors
+anchovies
+anchovy
+ancient
+anciently
+ancientness
+ancients
+ancillaries
+ancillary
+and
+anded
+anders
+anding
+ands
+anecdotal
+anecdotally
+anecdote
+anecdote's
+anecdotes
+anechoic
+anemometer
+anemometer's
+anemometers
+anemometry
+anemone
+anew
+angel
+angel's
+angelic
+angels
+anger
+angered
+angering
+angers
+angiography
+angle
+angled
+angler
+anglers
+angles
+angling
+angrier
+angriest
+angrily
+angriness
+angry
+angst
+angstrom
+angstroms
+anguish
+anguished
+angular
+angularly
+anhydrous
+anhydrously
+aniline
+animal
+animal's
+animally
+animalness
+animals
+animate
+animated
+animatedly
+animately
+animateness
+animates
+animating
+animation
+animations
+animator
+animator's
+animators
+animism
+animosity
+anion
+anion's
+anionic
+anionics
+anions
+anise
+aniseikonic
+anisotropic
+anisotropies
+anisotropy
+anisotropy's
+ankle
+ankle's
+ankles
+annal
+annalen
+annals
+annex
+annexation
+annexations
+annexed
+annexes
+annexing
+annihilate
+annihilated
+annihilates
+annihilating
+annihilation
+annihilative
+anniversaries
+anniversary
+anniversary's
+annotate
+annotated
+annotates
+annotating
+annotation
+annotations
+annotative
+announce
+announced
+announcement
+announcement's
+announcements
+announcer
+announcers
+announces
+announcing
+annoy
+annoyance
+annoyance's
+annoyances
+annoyed
+annoyer
+annoyers
+annoying
+annoyingly
+annoys
+annual
+annually
+annuals
+annul
+annulled
+annulling
+annulment
+annulment's
+annulments
+annuls
+annum
+annunciate
+annunciated
+annunciates
+annunciating
+annunciation
+annunciator
+annunciators
+anode
+anode's
+anodes
+anoint
+anointed
+anointer
+anointing
+anoints
+anomalies
+anomalous
+anomalously
+anomalousness
+anomaly
+anomaly's
+anomic
+anomie
+anon
+anonymity
+anonymous
+anonymously
+anonymousness
+anorexia
+another
+another's
+answer
+answerable
+answered
+answerer
+answerers
+answering
+answers
+ant
+ant's
+antagonism
+antagonisms
+antagonist
+antagonist's
+antagonistic
+antagonistically
+antagonists
+antarctic
+ante
+anteater
+anteater's
+anteaters
+antecedent
+antecedent's
+antecedently
+antecedents
+anted
+antedate
+antedated
+antedates
+antedating
+antelope
+antelope's
+antelopes
+antenna
+antenna's
+antennae
+antennas
+anterior
+anteriorly
+anteriors
+anthem
+anthem's
+anthems
+anther
+anthologies
+anthology
+anthracite
+anthropological
+anthropologically
+anthropologist
+anthropologist's
+anthropologists
+anthropology
+anthropomorphic
+anthropomorphically
+anti
+antibacterial
+antibiotic
+antibiotics
+antibodies
+antibody
+antic
+antic's
+anticipate
+anticipated
+anticipates
+anticipating
+anticipation
+anticipations
+anticipative
+anticipatively
+anticipatory
+anticoagulation
+anticompetitive
+antics
+antidisestablishmentarianism
+antidote
+antidote's
+antidotes
+antiformant
+antifundamentalist
+antigen
+antigen's
+antigens
+antihistorical
+antimicrobial
+antimony
+anting
+antinomian
+antinomy
+antipathy
+antiphonal
+antiphonally
+antipode
+antipode's
+antipodes
+antiquarian
+antiquarian's
+antiquarians
+antiquate
+antiquated
+antiquation
+antique
+antique's
+antiques
+antiquities
+antiquity
+antiredeposition
+antiresonance
+antiresonator
+antiseptic
+antisera
+antiserum
+antislavery
+antisocial
+antisubmarine
+antisymmetric
+antisymmetry
+antithesis
+antithetical
+antithetically
+antithyroid
+antitoxin
+antitoxin's
+antitoxins
+antitrust
+antitruster
+antler
+antlered
+ants
+anus
+anvil
+anvil's
+anvils
+anxieties
+anxiety
+anxious
+anxiously
+anxiousness
+any
+anybodies
+anybody
+anyhow
+anymore
+anyone
+anyone's
+anyones
+anyplace
+anything
+anythings
+anyway
+anyways
+anywhere
+anywheres
+aorta
+apace
+apart
+apartheid
+apartment
+apartment's
+apartments
+apartness
+apathetic
+apathy
+ape
+aped
+aper
+aperiodic
+aperiodicity
+aperture
+apertured
+apes
+apex
+apexes
+aphasia
+aphasic
+aphid
+aphid's
+aphids
+aphonic
+aphorism
+aphorism's
+aphorisms
+apiaries
+apiary
+apical
+apically
+apiece
+aping
+apish
+apishly
+apishness
+aplenty
+aplomb
+apocalypse
+apocalyptic
+apocrypha
+apocryphal
+apocryphally
+apocryphalness
+apogee
+apogees
+apologetic
+apologetically
+apologetics
+apologia
+apologies
+apologist
+apologist's
+apologists
+apology
+apology's
+apostate
+apostates
+apostle
+apostle's
+apostles
+apostolic
+apostrophe
+apostrophes
+apothecary
+apotheoses
+apotheosis
+appalled
+appalling
+appallingly
+appanage
+apparatus
+apparatuses
+apparel
+apparels
+apparent
+apparently
+apparentness
+apparition
+apparition's
+apparitions
+appeal
+appealed
+appealer
+appealers
+appealing
+appealingly
+appeals
+appear
+appearance
+appearances
+appeared
+appearer
+appearers
+appearing
+appears
+appease
+appeased
+appeasement
+appeaser
+appeases
+appeasing
+appellant
+appellant's
+appellants
+appellate
+appellation
+appellative
+appellatively
+append
+appendage
+appendage's
+appendages
+appended
+appender
+appenders
+appendices
+appendicitis
+appending
+appendix
+appendix's
+appendixes
+appends
+appertain
+appertained
+appertaining
+appertains
+appetite
+appetite's
+appetites
+appetitive
+applaud
+applauded
+applauder
+applauding
+applauds
+applause
+apple
+apple's
+applejack
+apples
+appliance
+appliance's
+appliances
+applicability
+applicable
+applicant
+applicant's
+applicants
+application
+application's
+applications
+applicative
+applicatively
+applicator
+applicator's
+applicators
+applied
+applier
+appliers
+applies
+applique
+appliques
+apply
+applying
+appoint
+appointed
+appointee
+appointee's
+appointees
+appointer
+appointers
+appointing
+appointive
+appointment
+appointment's
+appointments
+appoints
+apportion
+apportioned
+apportioning
+apportionment
+apportionments
+apportions
+appraisal
+appraisal's
+appraisals
+appraise
+appraised
+appraiser
+appraisers
+appraises
+appraising
+appraisingly
+appreciable
+appreciably
+appreciate
+appreciated
+appreciates
+appreciating
+appreciation
+appreciations
+appreciative
+appreciatively
+appreciativeness
+apprehend
+apprehended
+apprehender
+apprehending
+apprehends
+apprehensible
+apprehension
+apprehension's
+apprehensions
+apprehensive
+apprehensively
+apprehensiveness
+apprentice
+apprenticed
+apprentices
+apprenticeship
+apprenticeships
+apprise
+apprised
+appriser
+apprisers
+apprises
+apprising
+apprisings
+apprize
+apprized
+apprizer
+apprizers
+apprizes
+apprizing
+apprizingly
+apprizings
+approach
+approachability
+approachable
+approached
+approacher
+approachers
+approaches
+approaching
+approbate
+approbation
+appropriate
+appropriated
+appropriately
+appropriateness
+appropriates
+appropriatest
+appropriating
+appropriation
+appropriations
+appropriative
+appropriator
+appropriator's
+appropriators
+approval
+approval's
+approvals
+approve
+approved
+approver
+approvers
+approves
+approving
+approvingly
+approximate
+approximated
+approximately
+approximates
+approximating
+approximation
+approximations
+approximative
+approximatively
+appurtenance
+appurtenances
+apricot
+apricot's
+apricots
+apron
+apron's
+aprons
+apropos
+apse
+apses
+apsis
+apt
+aptitude
+aptitudes
+aptly
+aptness
+aqua
+aquaria
+aquarium
+aquas
+aquatic
+aquatics
+aqueduct
+aqueduct's
+aqueducts
+aqueous
+aqueously
+aquifer
+aquifers
+arabesque
+arable
+arachnid
+arachnid's
+arachnids
+arbiter
+arbiter's
+arbiters
+arbitrarily
+arbitrariness
+arbitrary
+arbitrate
+arbitrated
+arbitrates
+arbitrating
+arbitration
+arbitrative
+arbitrator
+arbitrator's
+arbitrators
+arboreal
+arboreally
+arc
+arcade
+arcade's
+arcaded
+arcades
+arcading
+arcane
+arced
+arch
+archaeological
+archaeologically
+archaeologist
+archaeologist's
+archaeologists
+archaeology
+archaic
+archaically
+archaicness
+archaism
+archangel
+archangel's
+archangels
+archbishop
+archdiocese
+archdioceses
+arched
+archenemy
+archer
+archers
+archery
+arches
+archetype
+archetypes
+archfool
+arching
+archipelago
+archipelagoes
+architect
+architect's
+architectonic
+architectonics
+architects
+architectural
+architecturally
+architecture
+architecture's
+architectures
+archival
+archive
+archived
+archiver
+archivers
+archives
+archiving
+archivist
+archivists
+archly
+archness
+arcing
+arclike
+arcs
+arctic
+ardent
+ardently
+arduous
+arduously
+arduousness
+are
+area
+area's
+areas
+aren't
+arena
+arena's
+arenas
+ares
+argon
+argonaut
+argonauts
+argot
+arguable
+arguably
+argue
+argued
+arguer
+arguers
+argues
+arguing
+argument
+argument's
+argumentation
+argumentative
+argumentatively
+arguments
+arid
+aridity
+aridness
+aright
+arise
+arisen
+ariser
+arises
+arising
+arisings
+aristocracy
+aristocrat
+aristocrat's
+aristocratic
+aristocratically
+aristocrats
+arithmetic
+arithmetical
+arithmetically
+arithmetics
+ark
+arm
+arm's
+armadillo
+armadillos
+armament
+armament's
+armaments
+armchair
+armchair's
+armchairs
+armed
+armer
+armers
+armful
+armfuls
+armhole
+armies
+arming
+armistice
+armload
+armpit
+armpit's
+armpits
+arms
+army
+army's
+aroma
+aromas
+aromatic
+aromaticness
+arose
+around
+arousal
+arouse
+aroused
+arouses
+arousing
+arpeggio
+arpeggio's
+arpeggios
+arrack
+arraign
+arraigned
+arraigning
+arraignment
+arraignment's
+arraignments
+arraigns
+arrange
+arranged
+arrangement
+arrangement's
+arrangements
+arranger
+arrangers
+arranges
+arranging
+arrant
+arrantly
+array
+arrayed
+arrayer
+arraying
+arrays
+arrears
+arrest
+arrested
+arrester
+arresters
+arresting
+arrestingly
+arrestor
+arrestor's
+arrestors
+arrests
+arrival
+arrival's
+arrivals
+arrive
+arrived
+arriver
+arrives
+arriving
+arrogance
+arrogant
+arrogantly
+arrogate
+arrogated
+arrogates
+arrogating
+arrogation
+arrow
+arrowed
+arrowhead
+arrowhead's
+arrowheads
+arrowing
+arrows
+arroyo
+arroyos
+arsenal
+arsenal's
+arsenals
+arsenic
+arsine
+arsines
+arson
+art
+art's
+arterial
+arterially
+arteries
+arteriolar
+arteriole
+arteriole's
+arterioles
+arteriosclerosis
+artery
+artery's
+artful
+artfully
+artfulness
+arthritis
+arthrogram
+arthrogram's
+arthrograms
+arthropod
+arthropod's
+arthropods
+artichoke
+artichoke's
+artichokes
+article
+article's
+articled
+articles
+articling
+articulate
+articulated
+articulately
+articulateness
+articulates
+articulating
+articulation
+articulations
+articulative
+articulator
+articulators
+articulatory
+artifact
+artifact's
+artifacts
+artifice
+artificer
+artifices
+artificial
+artificialities
+artificiality
+artificially
+artificialness
+artilleries
+artillerist
+artillery
+artisan
+artisan's
+artisans
+artist
+artist's
+artistic
+artistically
+artistry
+artists
+artless
+artlessly
+arts
+artwork
+as
+asbestos
+ascend
+ascendancy
+ascendant
+ascendantly
+ascended
+ascendency
+ascendent
+ascender
+ascenders
+ascending
+ascends
+ascension
+ascensions
+ascent
+ascertain
+ascertainable
+ascertained
+ascertaining
+ascertains
+ascetic
+ascetic's
+asceticism
+ascetics
+ascot
+ascribable
+ascribe
+ascribed
+ascribes
+ascribing
+ascription
+aseptic
+ash
+ashamed
+ashamedly
+ashen
+asher
+ashes
+ashman
+ashore
+ashtray
+ashtray's
+ashtrays
+aside
+asides
+asinine
+asininely
+ask
+askance
+asked
+asker
+askers
+askew
+askewness
+asking
+asks
+asleep
+asocial
+asp
+asparagus
+aspect
+aspect's
+aspects
+aspen
+asper
+aspersion
+aspersion's
+aspersions
+asphalt
+asphalted
+asphyxia
+aspic
+aspirant
+aspirant's
+aspirants
+aspirate
+aspirated
+aspirates
+aspirating
+aspiration
+aspiration's
+aspirations
+aspirator
+aspirators
+aspire
+aspired
+aspirer
+aspires
+aspirin
+aspiring
+aspirins
+ass
+ass's
+assail
+assailant
+assailant's
+assailants
+assailed
+assailing
+assails
+assassin
+assassin's
+assassinate
+assassinated
+assassinates
+assassinating
+assassination
+assassinations
+assassins
+assault
+assaulted
+assaulter
+assaulting
+assaultive
+assaultively
+assaultiveness
+assaults
+assay
+assayed
+assayer
+assayers
+assaying
+assemblage
+assemblage's
+assemblages
+assemble
+assembled
+assembler
+assemblers
+assembles
+assemblies
+assembling
+assembly
+assembly's
+assen
+assent
+assented
+assenter
+assenting
+assents
+assert
+asserted
+asserter
+asserters
+asserting
+assertion
+assertion's
+assertions
+assertive
+assertively
+assertiveness
+asserts
+asses
+assess
+assessed
+assesses
+assessing
+assessment
+assessment's
+assessments
+assessor
+assessor's
+assessors
+asset
+asset's
+assets
+assiduity
+assiduous
+assiduously
+assiduousness
+assign
+assignable
+assigned
+assignee
+assignee's
+assignees
+assigner
+assigners
+assigning
+assignment
+assignment's
+assignments
+assigns
+assimilate
+assimilated
+assimilates
+assimilating
+assimilation
+assimilations
+assimilative
+assist
+assistance
+assistances
+assistant
+assistant's
+assistants
+assistantship
+assistantships
+assisted
+assister
+assisting
+assists
+associate
+associated
+associates
+associating
+association
+association's
+associational
+associations
+associative
+associatively
+associativities
+associativity
+associator
+associator's
+associators
+assonance
+assonant
+assort
+assorted
+assorter
+assorting
+assortment
+assortment's
+assortments
+assorts
+assuage
+assuaged
+assuages
+assuaging
+assume
+assumed
+assumer
+assumes
+assuming
+assumption
+assumption's
+assumptions
+assurance
+assurance's
+assurances
+assure
+assured
+assuredly
+assuredness
+assurer
+assurers
+assures
+assuring
+assuringly
+astatine
+aster
+aster's
+asterisk
+asterisk's
+asterisks
+asteroid
+asteroid's
+asteroidal
+asteroids
+asters
+asthma
+astonish
+astonished
+astonishes
+astonishing
+astonishingly
+astonishment
+astound
+astounded
+astounding
+astoundingly
+astounds
+astral
+astrally
+astray
+astride
+astringency
+astringent
+astringently
+astronaut
+astronaut's
+astronautics
+astronauts
+astronomer
+astronomer's
+astronomers
+astronomical
+astronomically
+astronomy
+astrophysical
+astrophysics
+astute
+astutely
+astuteness
+asunder
+asylum
+asylums
+asymmetric
+asymmetrical
+asymmetrically
+asymmetries
+asymmetry
+asymptomatically
+asymptote
+asymptote's
+asymptotes
+asymptotic
+asymptotically
+asymptoticly
+asynchronism
+asynchronous
+asynchronously
+asynchrony
+at
+atavistic
+ate
+atemporal
+atheism
+atheist
+atheist's
+atheistic
+atheists
+atherosclerosis
+athlete
+athlete's
+athletes
+athletic
+athleticism
+athletics
+atlas
+atmosphere
+atmosphere's
+atmosphered
+atmospheres
+atmospheric
+atmospherics
+atoll
+atoll's
+atolls
+atom
+atom's
+atomic
+atomically
+atomics
+atoms
+atonal
+atonally
+atone
+atoned
+atonement
+atones
+atoning
+atop
+atrocious
+atrociously
+atrociousness
+atrocities
+atrocity
+atrocity's
+atrophic
+atrophied
+atrophies
+atrophy
+atrophying
+attach
+attache
+attached
+attacher
+attachers
+attaches
+attaching
+attachment
+attachment's
+attachments
+attack
+attackable
+attacked
+attacker
+attacker's
+attackers
+attacking
+attacks
+attain
+attainable
+attainableness
+attainably
+attained
+attainer
+attainers
+attaining
+attainment
+attainment's
+attainments
+attains
+attempt
+attempted
+attempter
+attempters
+attempting
+attempts
+attend
+attendance
+attendance's
+attendances
+attendant
+attendant's
+attendants
+attended
+attendee
+attendee's
+attendees
+attender
+attenders
+attending
+attends
+attention
+attention's
+attentional
+attentionality
+attentions
+attentive
+attentively
+attentiveness
+attenuate
+attenuated
+attenuates
+attenuating
+attenuation
+attenuator
+attenuator's
+attenuators
+attest
+attested
+attester
+attesting
+attests
+attic
+attic's
+attics
+attire
+attired
+attires
+attiring
+attitude
+attitude's
+attitudes
+attitudinal
+attitudinally
+attorney
+attorney's
+attorneys
+attract
+attracted
+attracting
+attraction
+attraction's
+attractions
+attractive
+attractively
+attractiveness
+attractor
+attractor's
+attractors
+attracts
+attributable
+attribute
+attributed
+attributer
+attributes
+attributing
+attribution
+attributions
+attributive
+attributively
+attrition
+attune
+attuned
+attunes
+attuning
+atypical
+atypically
+auburn
+auction
+auctioned
+auctioneer
+auctioneer's
+auctioneers
+auctioning
+audacious
+audaciously
+audaciousness
+audacity
+audible
+audibly
+audience
+audience's
+audiences
+audio
+audiogram
+audiogram's
+audiograms
+audiological
+audiologist
+audiologist's
+audiologists
+audiology
+audiometer
+audiometer's
+audiometers
+audiometric
+audiometry
+audit
+audited
+auditing
+audition
+audition's
+auditioned
+auditioning
+auditions
+auditive
+auditor
+auditor's
+auditorium
+auditoriums
+auditors
+auditory
+audits
+auger
+auger's
+augers
+aught
+augment
+augmentation
+augmentations
+augmented
+augmenter
+augmenting
+augments
+augur
+augurs
+august
+augustly
+augustness
+aunt
+aunt's
+auntly
+aunts
+aura
+aura's
+aural
+aurally
+auras
+aureole
+aureomycin
+aurora
+auscultate
+auscultated
+auscultates
+auscultating
+auscultation
+auscultations
+auspice
+auspices
+auspicious
+auspiciously
+auspiciousness
+austere
+austerely
+austereness
+austerity
+authentic
+authentically
+authenticate
+authenticated
+authenticates
+authenticating
+authentication
+authentications
+authenticator
+authenticators
+authenticity
+author
+author's
+authored
+authoring
+authoritarian
+authoritarianism
+authoritative
+authoritatively
+authoritativeness
+authorities
+authority
+authority's
+authors
+authorship
+autism
+autistic
+auto
+auto's
+autobiographic
+autobiographical
+autobiographically
+autobiographies
+autobiography
+autobiography's
+autocollimator
+autocorrelate
+autocorrelated
+autocorrelates
+autocorrelating
+autocorrelation
+autocorrelations
+autocracies
+autocracy
+autocrat
+autocrat's
+autocratic
+autocratically
+autocrats
+autodial
+autofluorescence
+autograph
+autographed
+autographing
+autographs
+automata
+automate
+automated
+automates
+automatic
+automatically
+automatics
+automating
+automation
+automaton
+automatons
+automobile
+automobile's
+automobiles
+automotive
+autonavigator
+autonavigator's
+autonavigators
+autonomic
+autonomous
+autonomously
+autonomy
+autopilot
+autopilot's
+autopilots
+autopsied
+autopsies
+autopsy
+autoregressive
+autorepeat
+autorepeating
+autorepeats
+autos
+autosuggestibility
+autotransformer
+autumn
+autumn's
+autumnal
+autumnally
+autumns
+auxiliaries
+auxiliary
+avail
+availabilities
+availability
+available
+availableness
+availably
+availed
+availer
+availers
+availing
+avails
+avalanche
+avalanched
+avalanches
+avalanching
+avant
+avarice
+avaricious
+avariciously
+avariciousness
+avenge
+avenged
+avenger
+avenges
+avenging
+avenue
+avenue's
+avenues
+aver
+average
+averaged
+averagely
+averageness
+averages
+averaging
+averred
+averrer
+averring
+avers
+averse
+aversely
+averseness
+aversion
+aversion's
+aversions
+aversive
+avert
+averted
+averting
+averts
+avian
+aviaries
+aviary
+aviation
+aviator
+aviator's
+aviators
+avid
+avidity
+avidly
+avidness
+avionic
+avionics
+avocado
+avocados
+avocation
+avocation's
+avocations
+avoid
+avoidable
+avoidably
+avoidance
+avoided
+avoider
+avoiders
+avoiding
+avoids
+avouch
+avow
+avowed
+avowedly
+avower
+avows
+await
+awaited
+awaiting
+awaits
+awake
+awaked
+awaken
+awakened
+awakener
+awakening
+awakens
+awakes
+awaking
+award
+awarded
+awarder
+awarders
+awarding
+awards
+aware
+awareness
+awash
+away
+awayness
+awe
+awed
+awesome
+awesomely
+awesomeness
+awful
+awfully
+awfulness
+awhile
+awhiles
+awing
+awkward
+awkwardly
+awkwardness
+awl
+awl's
+awls
+awning
+awning's
+awninged
+awnings
+awoke
+awry
+ax
+axe
+axed
+axer
+axers
+axes
+axial
+axially
+axing
+axiological
+axiologically
+axiom
+axiom's
+axiomatic
+axiomatically
+axiomatics
+axioms
+axion
+axion's
+axions
+axis
+axle
+axle's
+axles
+axolotl
+axolotl's
+axolotls
+axon
+axon's
+axons
+aye
+ayer
+ayers
+ayes
+azalea
+azalea's
+azaleas
+azimuth
+azimuth's
+azimuths
+azure
+babble
+babbled
+babbler
+babbles
+babbling
+babe
+babe's
+babes
+babied
+babies
+baby
+baby's
+babyhood
+babying
+babyish
+babysit
+babysits
+babysitter
+babysitters
+baccalaureate
+bachelor
+bachelor's
+bachelors
+bacilli
+bacillus
+back
+backache
+backache's
+backaches
+backbone
+backbone's
+backbones
+backdrop
+backdrop's
+backdrops
+backed
+backer
+backers
+background
+background's
+backgrounds
+backing
+backlash
+backlasher
+backlog
+backlog's
+backlogs
+backpack
+backpack's
+backpacker
+backpackers
+backpacks
+backplane
+backplane's
+backplanes
+backs
+backscatter
+backscattered
+backscattering
+backscatters
+backslash
+backslashed
+backslashes
+backslashing
+backspace
+backspaced
+backspaces
+backspacing
+backstabber
+backstabbing
+backstage
+backstairs
+backstitch
+backstitched
+backstitches
+backstitching
+backtrack
+backtracked
+backtracker
+backtrackers
+backtracking
+backtracks
+backup
+backups
+backward
+backwardly
+backwardness
+backwards
+backwater
+backwater's
+backwaters
+backwoods
+backyard
+backyard's
+backyards
+bacon
+baconer
+bacteria
+bacterial
+bacterially
+bacterium
+bad
+bade
+baden
+badge
+badged
+badger
+badger's
+badgered
+badgering
+badgers
+badges
+badging
+badlands
+badly
+badminton
+badness
+bads
+baffle
+baffled
+baffler
+bafflers
+baffles
+baffling
+bafflingly
+bag
+bag's
+bagatelle
+bagatelle's
+bagatelles
+bagel
+bagel's
+bagels
+baggage
+bagged
+bagger
+bagger's
+baggers
+baggier
+baggies
+bagginess
+bagging
+baggy
+bagpipe
+bagpipe's
+bagpiper
+bagpipes
+bags
+bah
+bail
+bailer
+bailiff
+bailiff's
+bailiffs
+bailing
+bailly
+bait
+baited
+baiter
+baiting
+baits
+bake
+baked
+baker
+bakeries
+bakers
+bakery
+bakery's
+bakes
+baking
+bakings
+baklava
+balalaika
+balalaika's
+balalaikas
+balance
+balanced
+balancedness
+balancer
+balancers
+balances
+balancing
+balconied
+balconies
+balcony
+balcony's
+bald
+balder
+balding
+baldly
+baldness
+bale
+baled
+baleful
+balefully
+balefulness
+baler
+balers
+bales
+baling
+balk
+balked
+balker
+balkier
+balkiness
+balking
+balks
+balky
+ball
+ballad
+ballad's
+ballads
+ballast
+ballast's
+ballasts
+balled
+baller
+ballerina
+ballerina's
+ballerinas
+ballers
+ballet
+ballet's
+ballets
+balling
+ballistic
+ballistics
+balloon
+ballooned
+ballooner
+ballooners
+ballooning
+balloons
+ballot
+ballot's
+balloted
+balloter
+balloting
+ballots
+ballplayer
+ballplayer's
+ballplayers
+ballroom
+ballroom's
+ballrooms
+balls
+ballyhoo
+balm
+balm's
+balmier
+balminess
+balms
+balmy
+balsa
+balsam
+balsams
+balustrade
+balustrade's
+balustrades
+bamboo
+bamboos
+ban
+ban's
+banal
+banally
+banana
+banana's
+bananas
+band
+bandage
+bandaged
+bandager
+bandages
+bandaging
+banded
+bander
+bandied
+bandies
+banding
+bandit
+bandit's
+bandits
+bandpass
+bands
+bandstand
+bandstand's
+bandstands
+bandwagon
+bandwagon's
+bandwagons
+bandwidth
+bandwidths
+bandy
+bandying
+bane
+baneful
+banefully
+bang
+banged
+banger
+banging
+bangle
+bangle's
+bangles
+bangs
+baning
+banish
+banished
+banisher
+banishes
+banishing
+banishment
+banister
+banister's
+banisters
+banjo
+banjo's
+banjos
+bank
+banked
+banker
+bankers
+banking
+bankrupt
+bankruptcies
+bankruptcy
+bankruptcy's
+bankrupted
+bankrupting
+bankrupts
+banks
+banned
+banner
+banner's
+banners
+banning
+banquet
+banqueted
+banqueter
+banqueting
+banquetings
+banquets
+bans
+banshee
+banshee's
+banshees
+bantam
+banter
+bantered
+banterer
+bantering
+banteringly
+banters
+baptism
+baptism's
+baptismal
+baptismally
+baptisms
+baptist
+baptist's
+baptistery
+baptistries
+baptistry
+baptistry's
+baptists
+bar
+bar's
+barb
+barbarian
+barbarian's
+barbarians
+barbaric
+barbarities
+barbarity
+barbarous
+barbarously
+barbarousness
+barbecue
+barbecued
+barbecuer
+barbecues
+barbecuing
+barbed
+barbedness
+barbell
+barbell's
+barbells
+barber
+barbered
+barbering
+barbers
+barbital
+barbiturate
+barbiturates
+barbs
+bard
+bard's
+bards
+bare
+bared
+barefoot
+barefooted
+barely
+bareness
+barer
+bares
+barest
+barflies
+barfly
+barfly's
+bargain
+bargained
+bargainer
+bargaining
+bargains
+barge
+barged
+barges
+barging
+baring
+baritone
+baritone's
+baritones
+barium
+bark
+barked
+barker
+barkers
+barking
+barks
+barley
+barn
+barn's
+barns
+barnstorm
+barnstormed
+barnstormer
+barnstorming
+barnstorms
+barnyard
+barnyard's
+barnyards
+barometer
+barometer's
+barometers
+barometric
+baron
+baron's
+baroness
+baronial
+baronies
+barons
+barony
+barony's
+baroque
+baroquely
+baroqueness
+barrack
+barracker
+barracks
+barracuda
+barracuda's
+barracudas
+barrage
+barrage's
+barraged
+barrages
+barraging
+barred
+barrel
+barrel's
+barrels
+barren
+barrenness
+barrens
+barricade
+barricade's
+barricades
+barrier
+barrier's
+barriers
+barring
+barringer
+barrow
+barrows
+bars
+bartender
+bartender's
+bartenders
+barter
+bartered
+barterer
+bartering
+barters
+bas
+basal
+basally
+basalt
+base
+baseball
+baseball's
+baseballs
+baseboard
+baseboard's
+baseboards
+based
+baseless
+baseline
+baseline's
+baselines
+basely
+baseman
+basement
+basement's
+basements
+baseness
+baser
+bases
+basest
+bash
+bashed
+basher
+bashes
+bashful
+bashfully
+bashfulness
+bashing
+basic
+basically
+basics
+basil
+basin
+basin's
+basined
+basing
+basins
+basis
+bask
+basked
+basket
+basket's
+basketball
+basketball's
+basketballs
+baskets
+basking
+bass
+bass's
+basses
+basset
+bassinet
+bassinet's
+bassinets
+basso
+bastard
+bastard's
+bastardly
+bastards
+baste
+basted
+baster
+bastes
+basting
+bastion
+bastion's
+bastioned
+bastions
+bat
+bat's
+batch
+batched
+batcher
+batches
+batching
+bated
+bater
+bath
+bathe
+bathed
+bather
+bathers
+bathes
+bathing
+bathos
+bathrobe
+bathrobe's
+bathrobes
+bathroom
+bathroom's
+bathroomed
+bathrooms
+baths
+bathtub
+bathtub's
+bathtubs
+bating
+baton
+baton's
+batons
+bats
+battalion
+battalion's
+battalions
+batted
+batten
+battened
+battening
+battens
+batter
+battered
+batteries
+battering
+batters
+battery
+battery's
+batting
+battle
+battled
+battlefield
+battlefield's
+battlefields
+battlefront
+battlefront's
+battlefronts
+battleground
+battleground's
+battlegrounds
+battlement
+battlement's
+battlemented
+battlements
+battler
+battlers
+battles
+battleship
+battleship's
+battleships
+battling
+bauble
+bauble's
+baubles
+baud
+bauds
+bauxite
+bawdier
+bawdiness
+bawdy
+bawl
+bawled
+bawler
+bawling
+bawls
+bay
+bayed
+baying
+bayly
+bayonet
+bayonet's
+bayoneted
+bayoneting
+bayonets
+bayou
+bayou's
+bayous
+bays
+bazaar
+bazaar's
+bazaars
+be
+beach
+beached
+beaches
+beachhead
+beachhead's
+beachheads
+beaching
+beacon
+beacon's
+beaconed
+beaconing
+beacons
+bead
+beaded
+beading
+beadle
+beadle's
+beadles
+beads
+beady
+beagle
+beagle's
+beagles
+beak
+beaked
+beaker
+beakers
+beaks
+beam
+beamed
+beamer
+beamers
+beaming
+beams
+bean
+beanbag
+beanbag's
+beanbags
+beaned
+beaner
+beaners
+beaning
+beans
+bear
+bearable
+bearably
+beard
+bearded
+beardedness
+beardless
+beards
+bearer
+bearers
+bearing
+bearings
+bearish
+bearishly
+bearishness
+bears
+beast
+beastings
+beastlier
+beastliness
+beastly
+beasts
+beat
+beatable
+beatably
+beaten
+beater
+beaters
+beatific
+beatification
+beatify
+beating
+beatings
+beatitude
+beatitude's
+beatitudes
+beatnik
+beatnik's
+beatniks
+beats
+beau
+beau's
+beaus
+beauteous
+beauteously
+beauteousness
+beauties
+beautification
+beautifications
+beautified
+beautifier
+beautifiers
+beautifies
+beautiful
+beautifully
+beautifulness
+beautify
+beautifying
+beauty
+beauty's
+beaver
+beaver's
+beavers
+becalm
+becalmed
+becalming
+becalms
+became
+because
+beck
+beckon
+beckoned
+beckoning
+beckons
+become
+becomes
+becoming
+becomingly
+bed
+bed's
+bedazzle
+bedazzled
+bedazzlement
+bedazzles
+bedazzling
+bedbug
+bedbug's
+bedbugs
+bedded
+bedder
+bedder's
+bedders
+bedding
+bedevil
+bedevils
+bedfast
+bedlam
+bedpost
+bedpost's
+bedposts
+bedraggle
+bedraggled
+bedridden
+bedrock
+bedrock's
+bedroom
+bedroom's
+bedroomed
+bedrooms
+beds
+bedside
+bedspread
+bedspread's
+bedspreads
+bedspring
+bedspring's
+bedsprings
+bedstead
+bedstead's
+bedsteads
+bedtime
+bee
+beech
+beechen
+beecher
+beef
+beefed
+beefer
+beefers
+beefier
+beefing
+beefs
+beefsteak
+beefy
+beehive
+beehive's
+beehives
+been
+beens
+beep
+beeped
+beeper
+beeping
+beeps
+beer
+beers
+bees
+beet
+beet's
+beetle
+beetle's
+beetled
+beetles
+beetling
+beets
+befall
+befallen
+befalling
+befalls
+befell
+befit
+befit's
+befits
+befitted
+befitting
+befittingly
+befog
+befogged
+befogging
+befogs
+before
+beforehand
+befoul
+befouled
+befouling
+befouls
+befriend
+befriended
+befriending
+befriends
+befuddle
+befuddled
+befuddles
+befuddling
+beg
+began
+beget
+begets
+begetting
+beggar
+beggared
+beggaring
+beggarliness
+beggarly
+beggars
+beggary
+begged
+begging
+begin
+beginner
+beginner's
+beginners
+beginning
+beginning's
+beginnings
+begins
+begot
+begotten
+begrudge
+begrudged
+begrudger
+begrudges
+begrudging
+begrudgingly
+begs
+beguile
+beguiled
+beguiler
+beguiles
+beguiling
+beguilingly
+begun
+behalf
+behave
+behaved
+behaver
+behaves
+behaving
+behead
+beheading
+beheld
+behest
+behind
+behold
+beholden
+beholder
+beholders
+beholding
+beholds
+beige
+being
+beings
+belated
+belatedly
+belatedness
+belay
+belayed
+belaying
+belays
+belch
+belched
+belches
+belching
+belfries
+belfry
+belfry's
+belie
+belied
+belief
+belief's
+beliefs
+belier
+belies
+believability
+believable
+believably
+believe
+believed
+believer
+believers
+believes
+believing
+belittle
+belittled
+belittler
+belittles
+belittling
+bell
+bell's
+bellboy
+bellboy's
+bellboys
+belle
+belle's
+belles
+bellhop
+bellhop's
+bellhops
+bellicose
+bellicosely
+bellicoseness
+bellicosity
+bellied
+bellies
+belligerence
+belligerent
+belligerent's
+belligerently
+belligerents
+bellman
+bellmen
+bellow
+bellowed
+bellowing
+bellows
+bells
+bellwether
+bellwether's
+bellwethers
+belly
+belly's
+bellyful
+bellying
+belong
+belonged
+belonging
+belongingness
+belongings
+belongs
+beloved
+below
+belt
+belted
+belting
+belts
+bely
+belying
+bemoan
+bemoaned
+bemoaning
+bemoans
+bench
+benched
+bencher
+benches
+benching
+benchmark
+benchmark's
+benchmarking
+benchmarks
+bend
+bendable
+bended
+bender
+benders
+bending
+bends
+beneath
+benediction
+benediction's
+benedictions
+benefactor
+benefactor's
+benefactors
+beneficence
+beneficences
+beneficial
+beneficially
+beneficialness
+beneficiaries
+beneficiary
+benefit
+benefited
+benefiter
+benefiters
+benefiting
+benefits
+benevolence
+benevolent
+benevolently
+benevolentness
+benighted
+benightedly
+benightedness
+benign
+benignly
+bent
+bents
+benzene
+bequeath
+bequeathed
+bequeathes
+bequeathing
+bequest
+bequest's
+bequests
+berate
+berated
+berates
+berating
+bereave
+bereaved
+bereavement
+bereavements
+bereaves
+bereaving
+bereft
+beret
+beret's
+berets
+beribboned
+beriberi
+berkelium
+berried
+berries
+berry
+berry's
+berrying
+berth
+berthed
+berthing
+berthings
+berths
+beryl
+beryllium
+bes
+beseech
+beseeches
+beseeching
+beseechingly
+beset
+besets
+besetting
+beside
+besides
+besiege
+besieged
+besieger
+besiegers
+besieging
+besmirch
+besmirched
+besmirches
+besmirching
+besotted
+besotting
+besought
+bespeak
+bespeaks
+bespectacled
+best
+bested
+bester
+bestial
+bestially
+besting
+bestow
+bestowal
+bestowed
+bests
+bestseller
+bestseller's
+bestsellers
+bestselling
+bet
+bet's
+beta
+betas
+beth
+betide
+betray
+betrayal
+betrayed
+betrayer
+betraying
+betrays
+betroth
+betrothal
+betrothals
+betrothed
+bets
+better
+bettered
+bettering
+betterment
+betterments
+betters
+betting
+between
+betweenness
+betwixt
+bevel
+bevels
+beverage
+beverage's
+beverages
+bevies
+bevy
+bewail
+bewailed
+bewailing
+bewails
+beware
+bewhiskered
+bewilder
+bewildered
+bewilderedly
+bewilderedness
+bewildering
+bewilderingly
+bewilderment
+bewilders
+bewitch
+bewitched
+bewitches
+bewitching
+bewitchingly
+beyond
+biannual
+bias
+biased
+biases
+biasing
+biasness
+bib
+bib's
+bibbed
+bibbing
+bible
+bible's
+bibles
+biblical
+biblically
+bibliographic
+bibliographical
+bibliographically
+bibliographics
+bibliographies
+bibliography
+bibliography's
+bibliophile
+bibliophiles
+bibs
+bicameral
+bicarbonate
+bicentennial
+biceps
+bicker
+bickered
+bickerer
+bickering
+bickers
+biconcave
+biconvex
+bicycle
+bicycled
+bicycler
+bicyclers
+bicycles
+bicycling
+bid
+bid's
+biddable
+bidden
+bidder
+bidder's
+bidders
+biddies
+bidding
+biddy
+bide
+bided
+bider
+bides
+biding
+bidirectional
+bids
+biennial
+biennially
+biennium
+bier
+bifocal
+bifocals
+bifurcate
+bifurcated
+bifurcately
+bifurcates
+bifurcating
+bifurcation
+bifurcations
+big
+bigger
+biggest
+bight
+bight's
+bights
+bigly
+bigness
+bigot
+bigot's
+bigoted
+bigotedly
+bigoting
+bigotry
+bigots
+bijection
+bijection's
+bijections
+bijective
+bijectively
+bike
+bike's
+biked
+biker
+biker's
+bikers
+bikes
+biking
+bikini
+bikini's
+bikinied
+bikinis
+bilabial
+bilateral
+bilaterally
+bilateralness
+bile
+bilge
+bilge's
+bilged
+bilges
+bilging
+bilinear
+bilingual
+bilingually
+bilinguals
+bilk
+bilked
+bilker
+bilking
+bilks
+bill
+billboard
+billboard's
+billboards
+billed
+biller
+billers
+billet
+billeted
+billeting
+billets
+billiard
+billiards
+billing
+billings
+billion
+billions
+billionth
+billow
+billowed
+billowing
+billows
+bills
+bimodal
+bimolecular
+bimolecularly
+bimonthlies
+bimonthly
+bin
+bin's
+binaries
+binary
+binaural
+binaurally
+bind
+binded
+binder
+binders
+binding
+bindingly
+bindingness
+bindings
+binds
+bing
+binge
+bingen
+binges
+bingo
+bingos
+binocular
+binocularly
+binoculars
+binomial
+binomially
+bins
+binuclear
+biochemical
+biochemically
+biochemistry
+biofeedback
+biographer
+biographer's
+biographers
+biographic
+biographical
+biographically
+biographies
+biography
+biography's
+biological
+biologically
+biologicals
+biologist
+biologist's
+biologists
+biology
+biomedical
+biomedicine
+biopsies
+biopsy
+bipartisan
+bipartite
+bipartitely
+bipartition
+biped
+bipeds
+biplane
+biplane's
+biplanes
+bipolar
+biracial
+birch
+birchen
+bircher
+birches
+bird
+bird's
+birdbath
+birdbath's
+birdbaths
+birder
+birdie
+birdied
+birdies
+birdlike
+birds
+birefringence
+birefringent
+birth
+birthday
+birthday's
+birthdays
+birthed
+birthplace
+birthplaces
+birthright
+birthright's
+birthrights
+births
+biscuit
+biscuit's
+biscuits
+bisect
+bisected
+bisecting
+bisection
+bisection's
+bisections
+bisector
+bisector's
+bisectors
+bisects
+bishop
+bishop's
+bishops
+bismuth
+bison
+bison's
+bisons
+bisque
+bisques
+bit
+bit's
+bitblt
+bitblts
+bitch
+bitch's
+bitches
+bite
+biter
+biters
+bites
+biting
+bitingly
+bitmap
+bitmap's
+bitmaps
+bits
+bitser
+bitten
+bitter
+bitterer
+bitterest
+bitterly
+bitterness
+bitters
+bittersweet
+bittersweetly
+bittersweetness
+bituminous
+bitwise
+bivalve
+bivalve's
+bivalved
+bivalves
+bivariate
+bivouac
+bivouacs
+biweekly
+bizarre
+bizarrely
+bizarreness
+blab
+blabbed
+blabbermouth
+blabbermouths
+blabbing
+blabs
+black
+blackberries
+blackberry
+blackberry's
+blackbird
+blackbird's
+blackbirder
+blackbirds
+blackboard
+blackboard's
+blackboards
+blacked
+blacken
+blackened
+blackener
+blackening
+blackens
+blacker
+blackest
+blacking
+blackjack
+blackjack's
+blackjacks
+blacklist
+blacklisted
+blacklister
+blacklisting
+blacklists
+blackly
+blackmail
+blackmailed
+blackmailer
+blackmailers
+blackmailing
+blackmails
+blackness
+blackout
+blackout's
+blackouts
+blacks
+blacksmith
+blacksmith's
+blacksmithing
+blacksmiths
+bladder
+bladder's
+bladders
+blade
+blade's
+bladed
+blades
+blamable
+blame
+blamed
+blameless
+blamelessly
+blamelessness
+blamer
+blamers
+blames
+blaming
+blanch
+blanched
+blancher
+blanches
+blanching
+bland
+blandly
+blandness
+blank
+blanked
+blanker
+blankest
+blanket
+blanketed
+blanketer
+blanketers
+blanketing
+blankets
+blanking
+blankly
+blankness
+blanks
+blare
+blared
+blares
+blaring
+blase
+blaspheme
+blasphemed
+blasphemer
+blasphemes
+blasphemies
+blaspheming
+blasphemous
+blasphemously
+blasphemousness
+blasphemy
+blast
+blasted
+blaster
+blasters
+blasting
+blasts
+blatant
+blatantly
+blatantness
+blaze
+blazed
+blazer
+blazers
+blazes
+blazing
+blazingly
+bleach
+bleached
+bleacher
+bleachers
+bleaches
+bleaching
+bleak
+bleakly
+bleakness
+blear
+bleariness
+bleary
+bleat
+bleater
+bleating
+bleats
+bled
+bleed
+bleeder
+bleeders
+bleeding
+bleedings
+bleeds
+blemish
+blemish's
+blemished
+blemishes
+blemishing
+blend
+blended
+blender
+blenders
+blending
+blends
+bless
+blessed
+blessedly
+blessedness
+blesses
+blessing
+blessings
+blew
+blight
+blighted
+blighter
+blimp
+blimp's
+blimps
+blind
+blinded
+blinder
+blinders
+blindfold
+blindfolded
+blindfolding
+blindfolds
+blinding
+blindingly
+blindly
+blindness
+blinds
+blink
+blinked
+blinker
+blinkered
+blinkering
+blinkers
+blinking
+blinks
+blip
+blip's
+blips
+bliss
+blissful
+blissfully
+blissfulness
+blister
+blistered
+blistering
+blisteringly
+blisters
+blithe
+blithely
+blither
+blithest
+blitz
+blitz's
+blitzes
+blitzkrieg
+blizzard
+blizzard's
+blizzards
+bloat
+bloated
+bloater
+bloaters
+bloating
+bloats
+blob
+blob's
+blobs
+bloc
+bloc's
+block
+block's
+blockade
+blockaded
+blockader
+blockades
+blockading
+blockage
+blockage's
+blockages
+blocked
+blocker
+blockers
+blockhouse
+blockhouses
+blocking
+blocks
+blocs
+bloke
+bloke's
+blokes
+blond
+blond's
+blonde
+blonde's
+blondes
+blonds
+blood
+blooded
+bloodhound
+bloodhound's
+bloodhounds
+bloodied
+bloodiest
+bloodiness
+bloodless
+bloodlessly
+bloodlessness
+bloods
+bloodshed
+bloodshot
+bloodstain
+bloodstain's
+bloodstained
+bloodstains
+bloodstream
+bloody
+bloodying
+bloom
+bloomed
+bloomer
+bloomers
+blooming
+blooms
+blossom
+blossomed
+blossoms
+blot
+blot's
+blots
+blotted
+blotting
+blouse
+blouse's
+blouses
+blousing
+blow
+blowed
+blower
+blowers
+blowfish
+blowing
+blown
+blows
+blowup
+blubber
+blubbered
+blubbering
+bludgeon
+bludgeoned
+bludgeoning
+bludgeons
+blue
+blueberries
+blueberry
+blueberry's
+bluebird
+bluebird's
+bluebirds
+bluebonnet
+bluebonnet's
+bluebonnets
+blued
+bluefish
+bluely
+blueness
+blueprint
+blueprint's
+blueprinted
+blueprinting
+blueprints
+bluer
+blues
+bluest
+bluestocking
+bluff
+bluffed
+bluffer
+bluffing
+bluffly
+bluffness
+bluffs
+bluing
+bluish
+bluishness
+blunder
+blundered
+blunderer
+blundering
+blunderingly
+blunderings
+blunders
+blunt
+blunted
+blunter
+bluntest
+blunting
+bluntly
+bluntness
+blunts
+blur
+blur's
+blurb
+blurred
+blurredly
+blurrier
+blurriness
+blurring
+blurringly
+blurry
+blurs
+blurt
+blurted
+blurter
+blurting
+blurts
+blush
+blushed
+blusher
+blushes
+blushing
+blushingly
+bluster
+blustered
+blusterer
+blustering
+blusteringly
+blusters
+blustery
+boar
+board
+boarded
+boarder
+boarders
+boarding
+boardinghouse
+boardinghouse's
+boardinghouses
+boards
+boast
+boasted
+boaster
+boasters
+boastful
+boastfully
+boastfulness
+boasting
+boastings
+boasts
+boat
+boated
+boater
+boaters
+boathouse
+boathouse's
+boathouses
+boating
+boatload
+boatload's
+boatloads
+boatman
+boatmen
+boats
+boatswain
+boatswain's
+boatswains
+boatyard
+boatyard's
+boatyards
+bob
+bob's
+bobbed
+bobbies
+bobbin
+bobbin's
+bobbing
+bobbins
+bobby
+bobolink
+bobolink's
+bobolinks
+bobs
+bobwhite
+bobwhite's
+bobwhites
+bode
+boded
+bodes
+bodice
+bodied
+bodies
+bodily
+boding
+body
+bodybuilder
+bodybuilder's
+bodybuilders
+bodybuilding
+bodyguard
+bodyguard's
+bodyguards
+bodying
+bog
+bog's
+bogged
+boggle
+boggled
+boggles
+boggling
+bogs
+bogus
+boil
+boiled
+boiler
+boilerplate
+boilers
+boiling
+boils
+boisterous
+boisterously
+boisterousness
+bold
+bolder
+boldest
+boldface
+boldfaced
+boldfaces
+boldfacing
+boldly
+boldness
+boll
+bolster
+bolstered
+bolsterer
+bolstering
+bolsters
+bolt
+bolted
+bolter
+bolting
+bolts
+bomb
+bombard
+bombarded
+bombarding
+bombardment
+bombardments
+bombards
+bombast
+bombaster
+bombastic
+bombed
+bomber
+bombers
+bombing
+bombings
+bombproof
+bombs
+bonanza
+bonanza's
+bonanzas
+bond
+bondage
+bonded
+bonder
+bonders
+bonding
+bonds
+bondsman
+bondsmen
+bone
+boned
+boner
+boners
+bones
+bonfire
+bonfire's
+bonfires
+bong
+bonier
+boning
+bonnet
+bonneted
+bonnets
+bonnier
+bonny
+bonus
+bonus's
+bonuses
+bony
+boo
+boob
+boobies
+booboo
+booby
+book
+bookcase
+bookcase's
+bookcases
+booked
+booker
+bookers
+bookie
+bookie's
+bookies
+booking
+bookings
+bookish
+bookishly
+bookishness
+bookkeeper
+bookkeeper's
+bookkeepers
+bookkeeping
+booklet
+booklet's
+booklets
+books
+bookseller
+bookseller's
+booksellers
+bookshelf
+bookshelf's
+bookshelves
+bookstore
+bookstore's
+bookstores
+boolean
+booleans
+boom
+boomed
+boomer
+boomerang
+boomerang's
+boomerangs
+booming
+booms
+boon
+boor
+boor's
+boorish
+boorishly
+boorishness
+boors
+boos
+boost
+boosted
+booster
+boosting
+boosts
+boot
+booted
+booth
+booths
+booties
+booting
+bootleg
+bootlegged
+bootlegger
+bootlegger's
+bootleggers
+bootlegging
+bootlegs
+boots
+bootstrap
+bootstrap's
+bootstrapped
+bootstrapping
+bootstraps
+booty
+booze
+boozer
+boozing
+borate
+borated
+borates
+borax
+bordello
+bordello's
+bordellos
+border
+bordered
+borderer
+bordering
+borderings
+borderland
+borderland's
+borderlands
+borderline
+borders
+bore
+bored
+boredom
+borer
+borers
+bores
+boric
+boring
+boringly
+boringness
+born
+borne
+boron
+borough
+boroughs
+borrow
+borrowed
+borrower
+borrowers
+borrowing
+borrowings
+borrows
+bosom
+bosom's
+bosoms
+boss
+bossed
+bosses
+bosun
+botanical
+botanically
+botanist
+botanist's
+botanists
+botany
+botch
+botched
+botcher
+botchers
+botches
+botching
+both
+bother
+bothered
+bothering
+bothers
+bothersome
+bottle
+bottled
+bottleneck
+bottleneck's
+bottlenecks
+bottler
+bottlers
+bottles
+bottling
+bottom
+bottomed
+bottomer
+bottoming
+bottomless
+bottomlessly
+bottomlessness
+bottoms
+botulinus
+botulism
+bouffant
+bough
+bough's
+boughed
+boughs
+bought
+boughten
+boulder
+boulder's
+bouldered
+boulders
+boulevard
+boulevard's
+boulevards
+bounce
+bounced
+bouncer
+bouncers
+bounces
+bouncier
+bouncing
+bouncingly
+bouncy
+bound
+boundaries
+boundary
+boundary's
+bounded
+bounden
+bounder
+bounding
+boundless
+boundlessly
+boundlessness
+bounds
+bounteous
+bounteously
+bounteousness
+bountied
+bounties
+bounty
+bounty's
+bouquet
+bouquet's
+bouquets
+bourbon
+bourbons
+bourgeois
+bourgeoisie
+bout
+bout's
+bouts
+bovine
+bovinely
+bovines
+bow
+bowed
+bowel
+bowel's
+bowels
+bowen
+bower
+bowers
+bowing
+bowl
+bowled
+bowler
+bowlers
+bowline
+bowline's
+bowlines
+bowling
+bowls
+bowman
+bows
+bowser
+bowstring
+bowstring's
+bowstrings
+box
+boxcar
+boxcar's
+boxcars
+boxed
+boxer
+boxers
+boxes
+boxing
+boxwood
+boy
+boy's
+boycott
+boycotted
+boycotter
+boycotting
+boycotts
+boyer
+boyfriend
+boyfriend's
+boyfriends
+boyhood
+boyish
+boyishly
+boyishness
+boys
+bra
+bra's
+brace
+braced
+bracelet
+bracelet's
+bracelets
+bracer
+braces
+bracing
+bracket
+bracketed
+bracketing
+brackets
+brackish
+brackishness
+brae
+brae's
+braes
+brag
+bragged
+bragger
+bragging
+brags
+braid
+braided
+braider
+braiding
+braids
+braille
+brain
+brainchild
+brainchild's
+brained
+brainier
+braininess
+braining
+brains
+brainstorm
+brainstorm's
+brainstormer
+brainstorming
+brainstorms
+brainwash
+brainwashed
+brainwasher
+brainwashes
+brainwashing
+brainy
+brake
+braked
+brakes
+braking
+bramble
+bramble's
+brambles
+brambling
+brambly
+bran
+branch
+branched
+branches
+branching
+branchings
+brand
+branded
+brander
+brandied
+brandies
+branding
+brandish
+brandishes
+brandishing
+brands
+brandy
+brandying
+bras
+brash
+brashly
+brashness
+brass
+brassed
+brasses
+brassier
+brassiere
+brassiness
+brassy
+brat
+brat's
+brats
+bravado
+brave
+braved
+bravely
+braveness
+braver
+bravery
+braves
+bravest
+braving
+bravo
+bravoed
+bravoing
+bravos
+bravura
+brawl
+brawled
+brawler
+brawling
+brawls
+brawn
+bray
+brayed
+brayer
+braying
+brays
+braze
+brazed
+brazen
+brazened
+brazening
+brazenly
+brazenness
+brazer
+brazes
+brazier
+brazier's
+braziers
+brazing
+breach
+breached
+breacher
+breachers
+breaches
+breaching
+bread
+breadboard
+breadboard's
+breadboards
+breaded
+breading
+breads
+breadth
+breadwinner
+breadwinner's
+breadwinners
+break
+breakable
+breakables
+breakage
+breakaway
+breakdown
+breakdown's
+breakdowns
+breaker
+breakers
+breakfast
+breakfasted
+breakfaster
+breakfasters
+breakfasting
+breakfasts
+breaking
+breakpoint
+breakpoint's
+breakpointed
+breakpointing
+breakpoints
+breaks
+breakthrough
+breakthrough's
+breakthroughes
+breakthroughs
+breakup
+breakups
+breakwater
+breakwater's
+breakwaters
+breast
+breasted
+breasting
+breasts
+breastwork
+breastwork's
+breastworks
+breath
+breathable
+breathe
+breathed
+breather
+breathers
+breathes
+breathier
+breathing
+breathless
+breathlessly
+breathlessness
+breaths
+breathtaking
+breathtakingly
+breathy
+bred
+breech
+breech's
+breeches
+breeching
+breed
+breeder
+breeding
+breeds
+breeze
+breeze's
+breezed
+breezes
+breezier
+breezily
+breeziness
+breezing
+breezy
+bremsstrahlung
+brethren
+breve
+breves
+brevet
+breveted
+breveting
+brevets
+brevity
+brew
+brewed
+brewer
+breweries
+brewers
+brewery
+brewery's
+brewing
+brews
+briar
+briar's
+briars
+bribe
+bribed
+briber
+bribers
+bribes
+bribing
+brick
+bricked
+bricker
+bricking
+bricklayer
+bricklayer's
+bricklayers
+bricklaying
+bricks
+bridal
+bride
+bride's
+bridegroom
+brides
+bridesmaid
+bridesmaid's
+bridesmaids
+bridge
+bridgeable
+bridged
+bridgehead
+bridgehead's
+bridgeheads
+bridges
+bridgework
+bridgework's
+bridging
+bridle
+bridled
+bridles
+bridling
+brief
+briefcase
+briefcase's
+briefcases
+briefed
+briefer
+briefest
+briefing
+briefing's
+briefings
+briefly
+briefness
+briefs
+brier
+brig
+brig's
+brigade
+brigade's
+brigaded
+brigades
+brigadier
+brigadier's
+brigadiers
+brigading
+brigantine
+bright
+brighten
+brightened
+brightener
+brighteners
+brightening
+brightens
+brighter
+brightest
+brighting
+brightly
+brightness
+brightnesses
+brights
+brigs
+brilliance
+brilliancy
+brilliant
+brilliantly
+brilliantness
+brim
+brimful
+brimmed
+brindle
+brindled
+brine
+briner
+bring
+bringer
+bringers
+bringing
+brings
+brining
+brink
+brinkmanship
+brisk
+brisker
+briskly
+briskness
+bristle
+bristled
+bristles
+bristling
+britches
+brittle
+brittled
+brittlely
+brittleness
+brittler
+brittlest
+brittling
+broach
+broached
+broacher
+broaches
+broaching
+broad
+broadband
+broadcast
+broadcasted
+broadcaster
+broadcasters
+broadcasting
+broadcastings
+broadcasts
+broaden
+broadened
+broadener
+broadeners
+broadening
+broadenings
+broadens
+broader
+broadest
+broadly
+broadness
+broads
+broadside
+brocade
+brocaded
+broccoli
+brochure
+brochure's
+brochures
+broil
+broiled
+broiler
+broilers
+broiling
+broils
+broke
+broken
+brokenly
+brokenness
+broker
+brokerage
+brokers
+bromide
+bromide's
+bromides
+bromine
+bromines
+bronchi
+bronchial
+bronchiole
+bronchiole's
+bronchioles
+bronchitis
+bronchus
+bronze
+bronzed
+bronzer
+bronzes
+bronzing
+brooch
+brooch's
+brooches
+brood
+brooder
+brooding
+broodingly
+broods
+brook
+brooked
+brooks
+broom
+broom's
+broomed
+brooming
+brooms
+broomstick
+broomstick's
+broomsticks
+broth
+brothel
+brothel's
+brothels
+brother
+brother's
+brotherhood
+brotherliness
+brotherly
+brothers
+brought
+brow
+brow's
+browbeat
+browbeaten
+browbeating
+browbeats
+brown
+browned
+browner
+brownest
+brownie
+brownie's
+brownies
+browning
+brownings
+brownish
+brownly
+brownness
+browns
+brows
+browse
+browsed
+browser
+browsers
+browses
+browsing
+bruise
+bruised
+bruiser
+bruisers
+bruises
+bruising
+brunch
+brunches
+brunette
+brunettes
+brunt
+brush
+brushed
+brusher
+brushes
+brushfire
+brushfire's
+brushfires
+brushier
+brushing
+brushlike
+brushy
+brusque
+brusquely
+brusqueness
+brutal
+brutalities
+brutality
+brutally
+brute
+brute's
+brutes
+brutish
+brutishly
+brutishness
+bubble
+bubbled
+bubbler
+bubbles
+bubblier
+bubbling
+bubbly
+buck
+buckboard
+buckboard's
+buckboards
+bucked
+bucker
+bucket
+bucket's
+bucketed
+bucketing
+buckets
+bucking
+buckle
+buckled
+buckler
+buckles
+buckling
+bucks
+buckshot
+buckskin
+buckskins
+buckwheat
+bucolic
+bud
+bud's
+budded
+buddies
+budding
+buddy
+buddy's
+budge
+budged
+budges
+budget
+budgetary
+budgeted
+budgeter
+budgeters
+budgeting
+budgets
+budging
+buds
+buff
+buff's
+buffalo
+buffaloes
+buffer
+buffer's
+buffered
+bufferer
+bufferer's
+bufferers
+buffering
+buffers
+buffet
+buffeted
+buffeting
+buffetings
+buffets
+buffing
+buffoon
+buffoon's
+buffoons
+buffs
+bug
+bug's
+bugged
+bugger
+bugger's
+buggered
+buggering
+buggers
+buggies
+bugging
+buggy
+buggy's
+bugle
+bugled
+bugler
+bugles
+bugling
+bugs
+build
+builded
+builder
+builders
+building
+building's
+buildings
+builds
+buildup
+buildup's
+buildups
+built
+bulb
+bulb's
+bulbed
+bulbs
+bulge
+bulged
+bulges
+bulging
+bulk
+bulked
+bulkhead
+bulkhead's
+bulkheaded
+bulkheads
+bulkier
+bulkiness
+bulks
+bulky
+bull
+bulldog
+bulldog's
+bulldogs
+bulldoze
+bulldozed
+bulldozer
+bulldozers
+bulldozes
+bulldozing
+bulled
+bullet
+bullet's
+bulletin
+bulletin's
+bulletins
+bulletproof
+bulletproofed
+bulletproofing
+bulletproofs
+bullets
+bullied
+bullies
+bulling
+bullion
+bullish
+bullishly
+bullishness
+bulls
+bully
+bullying
+bulwark
+bum
+bum's
+bumble
+bumblebee
+bumblebee's
+bumblebees
+bumbled
+bumbler
+bumblers
+bumbles
+bumbling
+bumblingly
+bummed
+bummer
+bummers
+bumming
+bump
+bumped
+bumper
+bumpers
+bumping
+bumps
+bumptious
+bumptiously
+bumptiousness
+bums
+bun
+bun's
+bunch
+bunched
+bunches
+bunching
+bundle
+bundled
+bundler
+bundles
+bundling
+bungalow
+bungalow's
+bungalows
+bungle
+bungled
+bungler
+bunglers
+bungles
+bungling
+bunglingly
+bunion
+bunion's
+bunions
+bunk
+bunked
+bunker
+bunker's
+bunkered
+bunkering
+bunkers
+bunkhouse
+bunkhouse's
+bunkhouses
+bunking
+bunkmate
+bunkmate's
+bunkmates
+bunks
+bunnies
+bunny
+bunny's
+buns
+bunt
+bunted
+bunter
+bunters
+bunting
+bunts
+buoy
+buoyancy
+buoyant
+buoyantly
+buoyed
+buoying
+buoys
+burden
+burden's
+burdened
+burdening
+burdens
+burdensome
+burdensomely
+burdensomeness
+bureau
+bureau's
+bureaucracies
+bureaucracy
+bureaucracy's
+bureaucrat
+bureaucrat's
+bureaucratic
+bureaucrats
+bureaus
+burgeon
+burgeoned
+burgeoning
+burgeons
+burger
+burgess
+burgess's
+burgesses
+burgher
+burgher's
+burghers
+burglar
+burglar's
+burglaries
+burglarproof
+burglarproofed
+burglarproofing
+burglarproofs
+burglars
+burglary
+burglary's
+burgle
+burgled
+burgles
+burgling
+burial
+buried
+burier
+buries
+burl
+burled
+burler
+burlesque
+burlesqued
+burlesquely
+burlesquer
+burlesques
+burlesquing
+burlier
+burliness
+burly
+burn
+burned
+burner
+burners
+burning
+burningly
+burnings
+burnish
+burnished
+burnisher
+burnishes
+burnishing
+burns
+burnt
+burntly
+burntness
+burp
+burped
+burping
+burps
+burr
+burr's
+burred
+burrer
+burro
+burro's
+burros
+burrow
+burrowed
+burrower
+burrowing
+burrows
+burrs
+bursa
+bursas
+bursitis
+burst
+bursted
+burster
+bursting
+bursts
+bury
+burying
+bus
+busboy
+busboy's
+busboys
+bused
+buses
+bush
+bushed
+bushel
+bushel's
+bushels
+bushes
+bushier
+bushiness
+bushing
+bushings
+bushwhack
+bushwhacked
+bushwhacker
+bushwhacking
+bushwhacks
+bushy
+busied
+busier
+busies
+busiest
+busily
+business
+business's
+businesses
+businesslike
+businessman
+businessmen
+busing
+buss
+bussed
+busses
+bussing
+bust
+bustard
+bustard's
+bustards
+busted
+buster
+busting
+bustle
+bustled
+bustling
+bustlingly
+busts
+busy
+busying
+but
+butane
+butcher
+butcher's
+butchered
+butcherer
+butchering
+butcherly
+butchers
+butchery
+butler
+butler's
+butlers
+butt
+butt's
+butte
+butted
+butter
+buttered
+butterer
+butterers
+butterfat
+butterflies
+butterfly
+butterfly's
+buttering
+butternut
+butters
+buttes
+butting
+buttock
+buttock's
+buttocks
+button
+buttoned
+buttoner
+buttonhole
+buttonhole's
+buttonholer
+buttonholes
+buttoning
+buttons
+buttress
+buttressed
+buttresses
+buttressing
+butts
+butyl
+butyrate
+buxom
+buxomly
+buxomness
+buy
+buyer
+buyer's
+buyers
+buying
+buys
+buzz
+buzzard
+buzzard's
+buzzards
+buzzed
+buzzer
+buzzes
+buzzing
+buzzword
+buzzword's
+buzzwords
+buzzy
+by
+bye
+byers
+byes
+bygone
+bygones
+bylaw
+bylaw's
+bylaws
+byline
+byline's
+byliner
+bylines
+bypass
+bypassed
+bypasses
+bypassing
+byproduct
+byproduct's
+byproducts
+bystander
+bystander's
+bystanders
+byte
+byte's
+bytes
+byway
+byways
+byword
+byword's
+bywords
+cab
+cab's
+cabbage
+cabbage's
+cabbaged
+cabbages
+cabbaging
+caber
+cabin
+cabin's
+cabinet
+cabinet's
+cabinets
+cabins
+cable
+cabled
+cables
+cabling
+cabs
+cache
+cache's
+cached
+cacher
+caches
+caching
+cackle
+cackled
+cackler
+cackles
+cackling
+cacti
+cactus
+cactuses
+cad
+cadence
+cadenced
+cadences
+cadencing
+cafe
+cafe's
+cafes
+cafeteria
+cafeteria's
+cafeterias
+cage
+caged
+cager
+cagers
+cages
+caging
+cajole
+cajoled
+cajoler
+cajoles
+cajoling
+cake
+caked
+cakes
+caking
+calamities
+calamity
+calamity's
+calcium
+calculate
+calculated
+calculatedly
+calculatedness
+calculates
+calculating
+calculation
+calculations
+calculative
+calculator
+calculator's
+calculators
+calculus
+calendar
+calendar's
+calendared
+calendaring
+calendars
+calf
+calfs
+calibrate
+calibrated
+calibrater
+calibrates
+calibrating
+calibration
+calibrations
+calibrator
+calibrators
+calico
+caliph
+caliphs
+call
+called
+caller
+caller's
+callers
+calling
+callous
+calloused
+callously
+callousness
+calls
+calm
+calmed
+calmer
+calmest
+calming
+calmingly
+calmly
+calmness
+calms
+calorie
+calorie's
+calories
+calves
+came
+camel
+camel's
+camels
+camera
+camera's
+cameras
+camion
+camouflage
+camouflaged
+camouflages
+camouflaging
+camp
+campaign
+campaigned
+campaigner
+campaigners
+campaigning
+campaigns
+camped
+camper
+campers
+camping
+camps
+campus
+campus's
+campuses
+can
+can's
+can't
+canal
+canal's
+canals
+canaries
+canary
+canary's
+cancel
+cancellation
+cancellation's
+cancellations
+cancels
+cancer
+cancer's
+cancers
+candid
+candidate
+candidate's
+candidates
+candidly
+candidness
+candied
+candies
+candle
+candled
+candler
+candles
+candlestick
+candlestick's
+candlesticks
+candling
+candy
+candying
+cane
+caned
+caner
+canes
+caning
+canker
+cankered
+cankering
+canned
+canner
+canner's
+canners
+cannibal
+cannibal's
+cannibals
+canning
+cannister
+cannister's
+cannisters
+cannon
+cannon's
+cannoned
+cannoning
+cannons
+cannot
+canoe
+canoe's
+canoed
+canoes
+canon
+canon's
+canonical
+canonically
+canonicals
+canons
+canopy
+cans
+cantankerous
+cantankerously
+cantankerousness
+canto
+canton
+canton's
+cantons
+cantor
+cantor's
+cantors
+cantos
+canvas
+canvas's
+canvaser
+canvases
+canvass
+canvassed
+canvasser
+canvassers
+canvasses
+canvassing
+canyon
+canyon's
+canyons
+cap
+cap's
+capabilities
+capability
+capability's
+capable
+capableness
+capably
+capacious
+capaciously
+capaciousness
+capacitance
+capacitances
+capacities
+capacitive
+capacitively
+capacitor
+capacitor's
+capacitors
+capacity
+cape
+caper
+capered
+capering
+capers
+capes
+capillary
+capita
+capital
+capitalism
+capitalist
+capitalist's
+capitalists
+capitally
+capitals
+capitol
+capitol's
+capitols
+capped
+capping
+capricious
+capriciously
+capriciousness
+caps
+captain
+captained
+captaining
+captains
+caption
+caption's
+captioned
+captioner
+captioning
+captions
+captivate
+captivated
+captivates
+captivating
+captivation
+captive
+captive's
+captives
+captivity
+captor
+captor's
+captors
+capture
+captured
+capturer
+capturers
+captures
+capturing
+car
+car's
+caravan
+caravan's
+caravaner
+caravans
+carbohydrate
+carbohydrate's
+carbohydrates
+carbolic
+carbon
+carbon's
+carbonate
+carbonated
+carbonates
+carbonation
+carbonic
+carbons
+carcass
+carcass's
+carcasses
+card
+card's
+cardboard
+cardboards
+carded
+carder
+cardiac
+cardinal
+cardinalities
+cardinality
+cardinality's
+cardinally
+cardinals
+carding
+cards
+care
+cared
+career
+career's
+careered
+careering
+careers
+carefree
+careful
+carefully
+carefulness
+careless
+carelessly
+carelessness
+carer
+carers
+cares
+caress
+caressed
+caresser
+caresses
+caressing
+caressingly
+caressive
+caressively
+caret
+carets
+cargo
+cargoes
+cargos
+caribou
+caribous
+caring
+carnation
+carnations
+carnival
+carnival's
+carnivals
+carnivorous
+carnivorously
+carnivorousness
+carol
+carol's
+carols
+carpenter
+carpenter's
+carpentered
+carpentering
+carpenters
+carpet
+carpeted
+carpeting
+carpets
+carriage
+carriage's
+carriages
+carried
+carrier
+carriers
+carries
+carrot
+carrot's
+carrots
+carry
+carrying
+carryover
+carryovers
+cars
+cart
+carted
+carter
+carters
+carting
+cartography
+carton
+carton's
+cartons
+cartoon
+cartoon's
+cartoons
+cartridge
+cartridge's
+cartridges
+carts
+carve
+carved
+carver
+carvers
+carves
+carving
+carvings
+cascade
+cascaded
+cascades
+cascading
+case
+cased
+casement
+casement's
+casements
+cases
+cash
+cashed
+casher
+cashers
+cashes
+cashier
+cashier's
+cashiers
+cashing
+casing
+casings
+cask
+cask's
+casket
+casket's
+caskets
+casks
+casserole
+casserole's
+casseroles
+cast
+cast's
+caste
+caste's
+casted
+caster
+casters
+castes
+casteth
+casting
+castings
+castle
+castled
+castles
+castling
+casts
+casual
+casually
+casualness
+casuals
+casualties
+casualty
+casualty's
+cat
+cat's
+catalyst
+catalyst's
+catalysts
+cataract
+cataracts
+catastrophe
+catastrophe's
+catastrophes
+catastrophic
+catch
+catchable
+catcher
+catcher's
+catchers
+catches
+catching
+categorical
+categorically
+categories
+category
+category's
+cater
+catered
+caterer
+catering
+caterpillar
+caterpillar's
+caterpillars
+caters
+cathedral
+cathedral's
+cathedrals
+catheter
+catheters
+cathode
+cathode's
+cathodes
+catholic
+catholic's
+catholics
+cats
+catsup
+cattle
+caught
+causal
+causality
+causally
+causation
+causation's
+causations
+cause
+caused
+causer
+causes
+causeway
+causeway's
+causeways
+causing
+caustic
+causticly
+caustics
+caution
+cautioned
+cautioner
+cautioners
+cautioning
+cautionings
+cautions
+cautious
+cautiously
+cautiousness
+cavalier
+cavalierly
+cavalierness
+cavalry
+cave
+caveat
+caveat's
+caveats
+caved
+caver
+cavern
+cavern's
+caverns
+caves
+caving
+cavities
+cavity
+cavity's
+caw
+cawed
+cawing
+caws
+cease
+ceased
+ceaseless
+ceaselessly
+ceaselessness
+ceases
+ceasing
+cedar
+ceiling
+ceiling's
+ceilinged
+ceilings
+celebrate
+celebrated
+celebratedness
+celebrates
+celebrating
+celebration
+celebrations
+celebratory
+celebrities
+celebrity
+celebrity's
+celery
+celestial
+celestially
+celibate
+celibates
+cell
+cellar
+cellar's
+cellared
+cellarer
+cellaring
+cellars
+celled
+cellist
+cellist's
+cellists
+cells
+cellular
+cellularly
+cement
+cemented
+cementer
+cementing
+cements
+cemeteries
+cemetery
+cemetery's
+censor
+censored
+censoring
+censors
+censorship
+censure
+censured
+censurer
+censures
+censuring
+census
+census's
+censuses
+cent
+centipede
+centipede's
+centipedes
+central
+centrally
+centrals
+centrifuge
+centrifuge's
+centrifuged
+centrifuges
+centrifuging
+centripetal
+centripetally
+cents
+centuries
+century
+century's
+cereal
+cereal's
+cereals
+cerebral
+cerebrally
+ceremonial
+ceremonially
+ceremonialness
+ceremonies
+ceremony
+ceremony's
+certain
+certainly
+certainties
+certainty
+certifiable
+certificate
+certificated
+certificates
+certificating
+certification
+certifications
+certified
+certifier
+certifiers
+certifies
+certify
+certifying
+cessation
+cessation's
+cessations
+chafe
+chafer
+chaff
+chaffer
+chaffered
+chafferer
+chaffering
+chaffing
+chafing
+chagrin
+chagrined
+chagrining
+chagrins
+chain
+chained
+chaining
+chains
+chair
+chaired
+chairing
+chairman
+chairmanship
+chairmanships
+chairmen
+chairperson
+chairperson's
+chairpersons
+chairs
+chalice
+chalice's
+chaliced
+chalices
+chalk
+chalked
+chalking
+chalks
+challenge
+challenged
+challenger
+challengers
+challenges
+challenging
+challengingly
+chamber
+chambered
+chamberer
+chamberers
+chambering
+chamberlain
+chamberlain's
+chamberlains
+chambers
+champagne
+champaign
+champion
+championed
+championing
+champions
+championship
+championship's
+championships
+chance
+chanced
+chancellor
+chancellors
+chances
+chancing
+chandelier
+chandelier's
+chandeliers
+change
+changeability
+changeable
+changeableness
+changeably
+changed
+changeover
+changeover's
+changeovers
+changer
+changers
+changes
+changing
+channel
+channels
+chant
+chanted
+chanter
+chanticleer
+chanticleer's
+chanticleers
+chanting
+chants
+chaos
+chaotic
+chap
+chap's
+chapel
+chapel's
+chapels
+chaperon
+chaperoned
+chaplain
+chaplain's
+chaplains
+chaps
+chapter
+chapter's
+chaptered
+chaptering
+chapters
+char
+character
+character's
+charactered
+charactering
+characteristic
+characteristic's
+characteristically
+characteristics
+characters
+charcoal
+charcoaled
+charcoals
+charge
+chargeable
+chargeableness
+charged
+charger
+chargers
+charges
+charging
+charing
+chariot
+chariot's
+chariots
+charitable
+charitableness
+charities
+charity
+charity's
+charm
+charmed
+charmer
+charmers
+charming
+charmingly
+charms
+chars
+chart
+chartable
+charted
+charter
+chartered
+charterer
+charterers
+chartering
+charters
+charting
+chartings
+charts
+chase
+chased
+chaser
+chasers
+chases
+chasing
+chasm
+chasm's
+chasms
+chaste
+chastely
+chasteness
+chaster
+chastest
+chastise
+chastised
+chastiser
+chastisers
+chastises
+chastising
+chat
+chateau
+chateau's
+chateaus
+chats
+chatter
+chattered
+chatterer
+chatterers
+chattering
+chatterly
+chatters
+chauffeur
+chauffeured
+chauffeuring
+chauffeurs
+chauvinism
+chauvinism's
+chauvinist
+chauvinist's
+chauvinistic
+chauvinists
+cheap
+cheapen
+cheapened
+cheapening
+cheapens
+cheaper
+cheapest
+cheaply
+cheapness
+cheat
+cheated
+cheater
+cheaters
+cheating
+cheats
+check
+checkable
+checked
+checker
+checkered
+checkering
+checkers
+checking
+checkout
+checkouts
+checkpoint
+checkpoint's
+checkpoints
+checks
+checksum
+checksum's
+checksums
+cheek
+cheek's
+cheeks
+cheer
+cheered
+cheerer
+cheerers
+cheerful
+cheerfully
+cheerfulness
+cheerier
+cheerily
+cheeriness
+cheering
+cheerless
+cheerlessly
+cheerlessness
+cheerly
+cheers
+cheery
+cheese
+cheese's
+cheesed
+cheeses
+cheesing
+chef
+chef's
+chefs
+chemical
+chemically
+chemicals
+chemise
+chemises
+chemist
+chemist's
+chemistries
+chemistry
+chemists
+cherish
+cherished
+cherisher
+cherishes
+cherishing
+cherries
+cherry
+cherry's
+cherub
+cherub's
+cherubim
+cherubs
+chess
+chest
+chester
+chestnut
+chestnut's
+chestnuts
+chests
+chew
+chewed
+chewer
+chewers
+chewing
+chews
+chick
+chickadee
+chickadee's
+chickadees
+chicken
+chickened
+chickening
+chickens
+chicks
+chide
+chided
+chides
+chiding
+chief
+chief's
+chiefly
+chiefs
+chieftain
+chieftain's
+chieftains
+chiffon
+child
+child's
+childhood
+childhoods
+childish
+childishly
+childishness
+childly
+children
+children's
+chill
+chilled
+chiller
+chillers
+chillier
+chillies
+chilliness
+chilling
+chillingly
+chillness
+chills
+chilly
+chime
+chime's
+chimed
+chimer
+chimes
+chiming
+chimney
+chimney's
+chimneyed
+chimneys
+chin
+chin's
+chink
+chinked
+chinks
+chinned
+chinner
+chinners
+chinning
+chins
+chintz
+chip
+chip's
+chipmunk
+chipmunk's
+chipmunks
+chips
+chirp
+chirped
+chirping
+chirps
+chisel
+chisels
+chivalrous
+chivalrously
+chivalrousness
+chivalry
+chlorine
+chloroplast
+chloroplast's
+chloroplasts
+chock
+chock's
+chocked
+chocker
+chocking
+chocks
+chocolate
+chocolate's
+chocolates
+choice
+choicely
+choiceness
+choicer
+choices
+choicest
+choir
+choir's
+choirs
+choke
+choked
+choker
+chokers
+chokes
+choking
+chokingly
+cholera
+choose
+chooser
+choosers
+chooses
+choosing
+chop
+chopped
+chopper
+chopper's
+choppers
+chopping
+chops
+choral
+chorally
+chord
+chord's
+chorded
+chording
+chords
+chore
+chores
+choring
+chorion
+chorus
+chorused
+choruses
+chose
+chosen
+christen
+christened
+christening
+christens
+chronic
+chronicle
+chronicled
+chronicler
+chroniclers
+chronicles
+chronological
+chronologically
+chronologies
+chronology
+chronology's
+chubbier
+chubbiest
+chubbiness
+chubby
+chuck
+chuck's
+chucked
+chucking
+chuckle
+chuckled
+chuckles
+chuckling
+chucklingly
+chucks
+chum
+chump
+chump's
+chumping
+chumps
+chums
+chunk
+chunk's
+chunks
+church
+churched
+churches
+churching
+churchliness
+churchly
+churchman
+churchyard
+churchyard's
+churchyards
+churn
+churned
+churner
+churners
+churning
+churns
+chute
+chute's
+chuted
+chutes
+chuting
+cider
+ciders
+cigar
+cigar's
+cigarette
+cigarette's
+cigarettes
+cigars
+cinder
+cinder's
+cinders
+cinnamon
+cipher
+cipher's
+ciphered
+ciphering
+ciphers
+circle
+circled
+circler
+circles
+circling
+circuit
+circuit's
+circuited
+circuiting
+circuitous
+circuitously
+circuitousness
+circuitry
+circuits
+circular
+circular's
+circularities
+circularity
+circularly
+circularness
+circulars
+circulate
+circulated
+circulates
+circulating
+circulation
+circulations
+circulative
+circumference
+circumferences
+circumflex
+circumflexes
+circumlocution
+circumlocution's
+circumlocutions
+circumspect
+circumspectly
+circumstance
+circumstance's
+circumstanced
+circumstances
+circumstancing
+circumstantial
+circumstantially
+circumvent
+circumventable
+circumvented
+circumventing
+circumvents
+circus
+circus's
+circuses
+cistern
+cistern's
+cisterns
+citadel
+citadel's
+citadels
+citation
+citation's
+citations
+cite
+cited
+cites
+citied
+cities
+citing
+citizen
+citizen's
+citizenly
+citizens
+citizenship
+city
+city's
+civic
+civics
+civil
+civilian
+civilian's
+civilians
+civilities
+civility
+civilly
+clad
+clads
+claim
+claimable
+claimant
+claimant's
+claimants
+claimed
+claimer
+claiming
+claims
+clairvoyant
+clairvoyantly
+clairvoyants
+clam
+clam's
+clamber
+clambered
+clamberer
+clambering
+clambers
+clamorous
+clamorously
+clamorousness
+clamp
+clamped
+clamper
+clamping
+clamps
+clams
+clan
+clang
+clanged
+clanger
+clangers
+clanging
+clangs
+clans
+clap
+claps
+clarification
+clarifications
+clarified
+clarifier
+clarifies
+clarify
+clarifying
+clarity
+clash
+clashed
+clasher
+clashes
+clashing
+clasp
+clasped
+clasper
+clasping
+clasps
+class
+classed
+classer
+classes
+classic
+classical
+classically
+classics
+classifiable
+classification
+classifications
+classified
+classifieds
+classifier
+classifiers
+classifies
+classify
+classifying
+classing
+classmate
+classmate's
+classmates
+classroom
+classroom's
+classrooms
+classwork
+clatter
+clattered
+clatterer
+clattering
+clatteringly
+clatters
+clause
+clause's
+clauses
+claw
+clawed
+clawer
+clawing
+claws
+clay
+clay's
+clayed
+claying
+clays
+clean
+cleaned
+cleaner
+cleaner's
+cleaners
+cleanest
+cleaning
+cleanlier
+cleanliness
+cleanly
+cleanness
+cleans
+cleanse
+cleansed
+cleanser
+cleansers
+cleanses
+cleansing
+cleanup
+cleanup's
+cleanups
+clear
+clearance
+clearance's
+clearances
+cleared
+clearer
+clearest
+clearing
+clearing's
+clearings
+clearly
+clearness
+clears
+cleavage
+cleavages
+cleave
+cleaved
+cleaver
+cleavers
+cleaves
+cleaving
+cleft
+cleft's
+clefts
+clench
+clenched
+clenches
+clenching
+clergy
+clergyman
+clerical
+clerically
+clericals
+clerk
+clerk's
+clerked
+clerking
+clerkly
+clerks
+clever
+cleverer
+cleverest
+cleverly
+cleverness
+cliche
+cliche's
+cliches
+click
+clicked
+clicker
+clickers
+clicking
+clicks
+client
+client's
+clients
+cliff
+cliff's
+cliffs
+climate
+climate's
+climates
+climatic
+climatically
+climax
+climaxed
+climaxes
+climaxing
+climb
+climbed
+climber
+climbers
+climbing
+climbs
+clime
+clime's
+climes
+clinch
+clinched
+clincher
+clinches
+clinching
+clinchingly
+cling
+clinging
+clings
+clinic
+clinic's
+clinical
+clinically
+clinics
+clink
+clinked
+clinker
+clinkered
+clinkering
+clinkers
+clip
+clip's
+clipped
+clipper
+clipper's
+clippers
+clipping
+clipping's
+clippings
+clips
+clique
+clique's
+cliques
+cloak
+cloak's
+cloaked
+cloaking
+cloaks
+clobber
+clobbered
+clobbering
+clobbers
+clock
+clocked
+clocker
+clockers
+clocking
+clockings
+clocks
+clockwise
+clockwork
+clod
+clod's
+clods
+clog
+clog's
+clogged
+clogging
+clogs
+cloister
+cloister's
+cloistered
+cloistering
+cloisters
+clone
+cloned
+cloner
+cloners
+clones
+cloning
+close
+closed
+closely
+closeness
+closenesses
+closer
+closers
+closes
+closest
+closet
+closeted
+closets
+closing
+closings
+closure
+closure's
+closured
+closures
+closuring
+cloth
+clothe
+clothed
+clothes
+clothing
+cloud
+clouded
+cloudier
+cloudiest
+cloudiness
+clouding
+cloudless
+cloudlessly
+cloudlessness
+clouds
+cloudy
+clout
+clove
+clover
+cloves
+clown
+clowning
+clowns
+club
+club's
+clubbed
+clubbing
+clubs
+cluck
+clucked
+clucking
+clucks
+clue
+clue's
+clues
+cluing
+clump
+clumped
+clumping
+clumps
+clumsier
+clumsiest
+clumsily
+clumsiness
+clumsy
+clung
+cluster
+clustered
+clustering
+clusterings
+clusters
+clutch
+clutched
+clutches
+clutching
+clutter
+cluttered
+cluttering
+clutters
+coach
+coach's
+coached
+coacher
+coaches
+coaching
+coachman
+coagulate
+coagulated
+coagulates
+coagulating
+coagulation
+coal
+coaled
+coaler
+coalesce
+coalesced
+coalesces
+coalescing
+coaling
+coalition
+coals
+coarse
+coarsely
+coarsen
+coarsened
+coarseness
+coarsening
+coarser
+coarsest
+coast
+coastal
+coasted
+coaster
+coasters
+coasting
+coasts
+coat
+coated
+coater
+coaters
+coating
+coatings
+coats
+coax
+coaxed
+coaxer
+coaxes
+coaxial
+coaxially
+coaxing
+cobbler
+cobbler's
+cobblers
+cobweb
+cobweb's
+cobwebs
+cock
+cocked
+cocker
+cocking
+cockroach
+cockroaches
+cocks
+cocktail
+cocktail's
+cocktails
+cocoa
+coconut
+coconut's
+coconuts
+cocoon
+cocoon's
+cocoons
+cod
+code
+coded
+coder
+coder's
+coders
+codes
+codeword
+codeword's
+codewords
+codification
+codification's
+codifications
+codified
+codifier
+codifier's
+codifiers
+codifies
+codify
+codifying
+coding
+codings
+cods
+coefficient
+coefficient's
+coefficiently
+coefficients
+coerce
+coerced
+coerces
+coercing
+coercion
+coercions
+coercive
+coercively
+coerciveness
+coexist
+coexisted
+coexistence
+coexisting
+coexists
+coffee
+coffee's
+coffees
+coffer
+coffer's
+coffers
+coffin
+coffin's
+coffins
+cogent
+cogently
+cogitate
+cogitated
+cogitates
+cogitating
+cogitation
+cogitative
+cognition
+cognitions
+cognitive
+cognitively
+cognitives
+cohabit
+cohabitation
+cohabitations
+cohabited
+cohabiting
+cohabits
+cohere
+cohered
+coherence
+coherent
+coherently
+coherer
+coheres
+cohering
+cohesion
+cohesive
+cohesively
+cohesiveness
+coil
+coiled
+coiling
+coils
+coin
+coinage
+coincide
+coincided
+coincidence
+coincidence's
+coincidences
+coincidental
+coincidentally
+coincides
+coinciding
+coined
+coiner
+coining
+coins
+coke
+cokes
+coking
+cold
+colder
+coldest
+coldly
+coldness
+colds
+collaborate
+collaborated
+collaborates
+collaborating
+collaboration
+collaborations
+collaborative
+collaboratively
+collaborator
+collaborator's
+collaborators
+collapse
+collapsed
+collapses
+collapsing
+collar
+collared
+collaring
+collars
+collate
+collated
+collateral
+collaterally
+collates
+collating
+collation
+collations
+collative
+collator
+collators
+colleague
+colleague's
+colleagues
+collect
+collected
+collectedly
+collectedness
+collectible
+collecting
+collection
+collection's
+collections
+collective
+collectively
+collectives
+collector
+collector's
+collectors
+collects
+college
+college's
+colleges
+collegiate
+collegiately
+collide
+collided
+collides
+colliding
+collie
+collied
+collier
+collies
+collision
+collision's
+collisions
+cologne
+cologned
+colon
+colon's
+colonel
+colonel's
+colonels
+colonial
+colonially
+colonialness
+colonials
+colonies
+colonist
+colonist's
+colonists
+colons
+colony
+colony's
+colossal
+colossally
+colt
+colt's
+colter
+colts
+column
+column's
+columnar
+columned
+columns
+comb
+combat
+combatant
+combatant's
+combatants
+combated
+combating
+combative
+combatively
+combativeness
+combats
+combed
+comber
+combers
+combination
+combination's
+combinational
+combinations
+combinator
+combinator's
+combinatorial
+combinatorially
+combinatoric
+combinatorics
+combinators
+combine
+combined
+combiner
+combiners
+combines
+combing
+combings
+combining
+combs
+combustion
+combustions
+come
+comedian
+comedian's
+comedians
+comedic
+comedies
+comedy
+comedy's
+comelier
+comeliness
+comely
+comer
+comers
+comes
+comest
+comestible
+comestibles
+comet
+comet's
+cometh
+comets
+comfort
+comfortabilities
+comfortability
+comfortable
+comfortableness
+comfortably
+comforted
+comforter
+comforters
+comforting
+comfortingly
+comforts
+comic
+comic's
+comical
+comically
+comics
+coming
+comings
+comma
+comma's
+command
+command's
+commandant
+commandant's
+commandants
+commanded
+commandeer
+commandeered
+commandeering
+commandeers
+commander
+commanders
+commanding
+commandingly
+commandment
+commandment's
+commandments
+commands
+commas
+commemorate
+commemorated
+commemorates
+commemorating
+commemoration
+commemorations
+commemorative
+commemoratively
+commemoratives
+commence
+commenced
+commencement
+commencement's
+commencements
+commencer
+commences
+commencing
+commend
+commendation
+commendation's
+commendations
+commended
+commender
+commending
+commends
+commensurate
+commensurately
+commensurates
+commensuration
+commensurations
+comment
+comment's
+commentaries
+commentary
+commentary's
+commentator
+commentator's
+commentators
+commented
+commenter
+commenting
+comments
+commerce
+commerced
+commercial
+commercially
+commercialness
+commercials
+commercing
+commission
+commissioned
+commissioner
+commissioners
+commissioning
+commissions
+commit
+commitment
+commitment's
+commitments
+commits
+committed
+committee
+committee's
+committees
+committing
+commodities
+commodity
+commodity's
+commodore
+commodore's
+commodores
+common
+commonalities
+commonality
+commoner
+commoner's
+commoners
+commonest
+commonly
+commonness
+commonplace
+commonplaceness
+commonplaces
+commons
+commonwealth
+commonwealths
+commotion
+commotions
+communal
+communally
+commune
+communed
+communes
+communicant
+communicant's
+communicants
+communicate
+communicated
+communicates
+communicating
+communication
+communications
+communicative
+communicatively
+communicativeness
+communicator
+communicator's
+communicators
+communing
+communion
+communist
+communist's
+communists
+communities
+community
+community's
+commutative
+commutatively
+commutativity
+commute
+commuted
+commuter
+commuters
+commutes
+commuting
+compact
+compacted
+compacter
+compacters
+compactest
+compacting
+compactly
+compactness
+compactor
+compactor's
+compactors
+compacts
+companies
+companion
+companion's
+companionable
+companionableness
+companions
+companionship
+company
+company's
+comparability
+comparable
+comparableness
+comparably
+comparative
+comparatively
+comparativeness
+comparatives
+comparator
+comparator's
+comparators
+compare
+compared
+comparer
+compares
+comparing
+comparison
+comparison's
+comparisons
+compartment
+compartmented
+compartmenting
+compartments
+compass
+compassed
+compasses
+compassing
+compassion
+compassionate
+compassionately
+compassionateness
+compatibilities
+compatibility
+compatibility's
+compatible
+compatibleness
+compatibles
+compatibly
+compel
+compelled
+compelling
+compellingly
+compels
+compendium
+compensate
+compensated
+compensates
+compensating
+compensation
+compensations
+compensative
+compensatory
+compete
+competed
+competence
+competences
+competent
+competently
+competes
+competing
+competition
+competition's
+competitions
+competitive
+competitively
+competitiveness
+competitor
+competitor's
+competitors
+compilable
+compilation
+compilation's
+compilations
+compile
+compiled
+compiler
+compiler's
+compilers
+compiles
+compiling
+complain
+complained
+complainer
+complainers
+complaining
+complainingly
+complains
+complaint
+complaint's
+complaints
+complement
+complementariness
+complementary
+complemented
+complementer
+complementers
+complementing
+complements
+complete
+completed
+completely
+completeness
+completer
+completes
+completing
+completion
+completions
+completive
+complex
+complexes
+complexion
+complexioned
+complexities
+complexity
+complexly
+complexness
+compliance
+compliances
+complicate
+complicated
+complicatedly
+complicatedness
+complicates
+complicating
+complication
+complications
+complicator
+complicator's
+complicators
+complicity
+complied
+complier
+compliers
+complies
+compliment
+complimentary
+complimented
+complimenter
+complimenters
+complimenting
+compliments
+comply
+complying
+component
+component's
+components
+compose
+composed
+composedly
+composedness
+composer
+composer's
+composers
+composes
+composing
+composite
+compositely
+composites
+composition
+compositional
+compositionally
+compositions
+composure
+compound
+compounded
+compounder
+compounding
+compounds
+comprehend
+comprehended
+comprehending
+comprehends
+comprehensibility
+comprehensible
+comprehensibleness
+comprehension
+comprehensive
+comprehensively
+comprehensiveness
+compress
+compressed
+compressedly
+compresses
+compressible
+compressing
+compression
+compressions
+compressive
+compressively
+comprise
+comprised
+comprises
+comprising
+compromise
+compromised
+compromiser
+compromisers
+compromises
+compromising
+compromisingly
+comptroller
+comptroller's
+comptrollers
+compulsion
+compulsion's
+compulsions
+compulsory
+compunction
+compunctions
+computability
+computable
+computation
+computation's
+computational
+computationally
+computations
+compute
+computed
+computer
+computer's
+computerese
+computers
+computes
+computing
+comrade
+comradeliness
+comradely
+comrades
+comradeship
+concatenate
+concatenated
+concatenates
+concatenating
+concatenation
+concatenations
+conceal
+concealed
+concealer
+concealers
+concealing
+concealingly
+concealment
+conceals
+concede
+conceded
+concededly
+conceder
+concedes
+conceding
+conceit
+conceited
+conceitedly
+conceitedness
+conceits
+conceivable
+conceivably
+conceive
+conceived
+conceiver
+conceives
+conceiving
+concentrate
+concentrated
+concentrates
+concentrating
+concentration
+concentrations
+concentrative
+concentrator
+concentrators
+concentric
+concept
+concept's
+conception
+conception's
+conceptions
+conceptive
+concepts
+conceptual
+conceptually
+concern
+concerned
+concernedly
+concerning
+concerns
+concert
+concerted
+concertedly
+concertedness
+concerts
+concession
+concession's
+concessioner
+concessions
+concise
+concisely
+conciseness
+concision
+concisions
+conclude
+concluded
+concluder
+concludes
+concluding
+conclusion
+conclusion's
+conclusions
+conclusive
+conclusively
+conclusiveness
+concomitant
+concomitantly
+concomitants
+concord
+concrete
+concreted
+concretely
+concreteness
+concretes
+concreting
+concretion
+concur
+concurred
+concurrence
+concurrencies
+concurrency
+concurrent
+concurrently
+concurring
+concurs
+condemn
+condemnation
+condemnations
+condemned
+condemner
+condemners
+condemning
+condemns
+condensation
+condense
+condensed
+condenser
+condensers
+condenses
+condensing
+condescend
+condescending
+condescendingly
+condescends
+condition
+conditional
+conditionally
+conditionals
+conditioned
+conditioner
+conditioners
+conditioning
+conditions
+condone
+condoned
+condoner
+condones
+condoning
+conducive
+conduciveness
+conduct
+conducted
+conducting
+conduction
+conductive
+conductively
+conductivities
+conductivity
+conductor
+conductor's
+conductors
+conducts
+conduit
+conduits
+cone
+cone's
+coned
+cones
+confederacy
+confederate
+confederates
+confederation
+confederations
+confederative
+confer
+conference
+conference's
+conferences
+conferencing
+conferred
+conferrer
+conferrer's
+conferrers
+conferring
+confers
+confess
+confessed
+confessedly
+confesses
+confessing
+confession
+confession's
+confessions
+confessor
+confessor's
+confessors
+confidant
+confidant's
+confidants
+confide
+confided
+confidence
+confidences
+confident
+confidential
+confidentiality
+confidentially
+confidentialness
+confidently
+confider
+confides
+confiding
+confidingly
+confidingness
+configurable
+configuration
+configuration's
+configurations
+configure
+configured
+configures
+configuring
+confine
+confined
+confinement
+confinement's
+confinements
+confiner
+confines
+confining
+confirm
+confirmation
+confirmation's
+confirmations
+confirmed
+confirmedly
+confirmedness
+confirming
+confirms
+confiscate
+confiscated
+confiscates
+confiscating
+confiscation
+confiscations
+conflict
+conflicted
+conflicting
+conflictingly
+conflictive
+conflicts
+conform
+conformed
+conformer
+conformers
+conforming
+conformity
+conforms
+confound
+confounded
+confoundedly
+confounder
+confounding
+confounds
+confront
+confrontation
+confrontation's
+confrontations
+confronted
+confronter
+confronters
+confronting
+confronts
+confuse
+confused
+confusedly
+confusedness
+confuser
+confusers
+confuses
+confusing
+confusingly
+confusion
+confusions
+congenial
+congenially
+congested
+congestion
+congratulate
+congratulated
+congratulates
+congratulation
+congratulations
+congregate
+congregated
+congregates
+congregating
+congregation
+congregations
+congress
+congress's
+congressed
+congresses
+congressing
+congressional
+congressionally
+congressman
+congruence
+congruent
+congruently
+coning
+conjecture
+conjectured
+conjecturer
+conjectures
+conjecturing
+conjoined
+conjunct
+conjuncted
+conjunction
+conjunction's
+conjunctions
+conjunctive
+conjunctively
+conjuncts
+conjure
+conjured
+conjurer
+conjurers
+conjures
+conjuring
+connect
+connected
+connectedly
+connectedness
+connecter
+connecters
+connecting
+connection
+connection's
+connections
+connective
+connective's
+connectively
+connectives
+connectivities
+connectivity
+connector
+connector's
+connectors
+connects
+connoisseur
+connoisseur's
+connoisseurs
+connote
+connoted
+connotes
+connoting
+conquer
+conquerable
+conquered
+conquerer
+conquerers
+conquering
+conqueror
+conqueror's
+conquerors
+conquers
+conquest
+conquest's
+conquests
+cons
+conscience
+conscience's
+consciences
+conscientious
+conscientiously
+conscientiousness
+conscious
+consciouses
+consciously
+consciousness
+consecrate
+consecrated
+consecrates
+consecrating
+consecration
+consecrations
+consecrative
+consecutive
+consecutively
+consecutiveness
+consensus
+consent
+consented
+consenter
+consenters
+consenting
+consentingly
+consents
+consequence
+consequence's
+consequences
+consequent
+consequential
+consequentialities
+consequentiality
+consequentially
+consequentialness
+consequently
+consequentness
+consequents
+conservation
+conservation's
+conservationist
+conservationist's
+conservationists
+conservations
+conservatism
+conservative
+conservatively
+conservativeness
+conservatives
+conserve
+conserved
+conserver
+conserves
+conserving
+consider
+considerable
+considerably
+considerate
+considerately
+considerateness
+consideration
+considerations
+considered
+considerer
+considering
+considers
+consign
+consigned
+consigning
+consigns
+consist
+consisted
+consistencies
+consistency
+consistent
+consistently
+consisting
+consists
+consolable
+consolation
+consolation's
+consolations
+console
+consoled
+consoler
+consolers
+consoles
+consolidate
+consolidated
+consolidates
+consolidating
+consolidation
+consolidations
+consoling
+consolingly
+consonant
+consonant's
+consonantly
+consonants
+consort
+consorted
+consorting
+consortium
+consorts
+conspicuous
+conspicuously
+conspicuousness
+conspiracies
+conspiracy
+conspiracy's
+conspirator
+conspirator's
+conspirators
+conspire
+conspired
+conspires
+conspiring
+constable
+constable's
+constables
+constancy
+constant
+constantly
+constants
+constellation
+constellation's
+constellations
+consternation
+constituencies
+constituency
+constituency's
+constituent
+constituent's
+constituently
+constituents
+constitute
+constituted
+constitutes
+constituting
+constitution
+constitutional
+constitutionality
+constitutionally
+constitutions
+constitutive
+constitutively
+constrain
+constrained
+constrainedly
+constraining
+constrains
+constraint
+constraint's
+constraints
+construct
+constructed
+constructibility
+constructible
+constructing
+construction
+construction's
+constructions
+constructive
+constructively
+constructiveness
+constructor
+constructor's
+constructors
+constructs
+construe
+construed
+construes
+construing
+consul
+consul's
+consulate
+consulate's
+consulates
+consuls
+consult
+consultant
+consultant's
+consultants
+consultation
+consultation's
+consultations
+consultative
+consulted
+consulter
+consulting
+consultive
+consults
+consumable
+consumables
+consume
+consumed
+consumedly
+consumer
+consumer's
+consumers
+consumes
+consuming
+consumingly
+consummate
+consummated
+consummately
+consummates
+consummating
+consummation
+consummations
+consummative
+consumption
+consumption's
+consumptions
+consumptive
+consumptively
+contact
+contacted
+contacting
+contacts
+contagion
+contagious
+contagiously
+contagiousness
+contain
+containable
+contained
+container
+containers
+containing
+containment
+containment's
+containments
+contains
+contaminate
+contaminated
+contaminates
+contaminating
+contamination
+contaminations
+contaminative
+contemplate
+contemplated
+contemplates
+contemplating
+contemplation
+contemplations
+contemplative
+contemplatively
+contemplativeness
+contemporaneous
+contemporaneously
+contemporaneousness
+contemporaries
+contemporariness
+contemporary
+contempt
+contemptible
+contemptibleness
+contemptuous
+contemptuously
+contemptuousness
+contend
+contended
+contender
+contenders
+contending
+contends
+content
+contented
+contentedly
+contentedness
+contenting
+contention
+contention's
+contentions
+contently
+contentment
+contents
+contest
+contestable
+contested
+contester
+contesters
+contesting
+contests
+context
+context's
+contexts
+contextual
+contextually
+contiguity
+contiguous
+contiguously
+contiguousness
+continent
+continent's
+continental
+continentally
+continently
+continents
+contingencies
+contingency
+contingency's
+contingent
+contingent's
+contingently
+contingents
+continual
+continually
+continuance
+continuance's
+continuances
+continuation
+continuation's
+continuations
+continue
+continued
+continuer
+continues
+continuing
+continuities
+continuity
+continuous
+continuously
+continuousness
+continuum
+contour
+contour's
+contoured
+contouring
+contours
+contract
+contracted
+contracting
+contraction
+contraction's
+contractions
+contractive
+contractor
+contractor's
+contractors
+contracts
+contractual
+contractually
+contradict
+contradicted
+contradicting
+contradiction
+contradiction's
+contradictions
+contradictoriness
+contradictory
+contradicts
+contradistinction
+contradistinctions
+contrapositive
+contrapositives
+contraption
+contraption's
+contraptions
+contrariness
+contrary
+contrast
+contrasted
+contraster
+contrasters
+contrasting
+contrastingly
+contrastive
+contrastively
+contrasts
+contribute
+contributed
+contributer
+contributers
+contributes
+contributing
+contribution
+contributions
+contributive
+contributively
+contributor
+contributor's
+contributorily
+contributors
+contributory
+contrivance
+contrivance's
+contrivances
+contrive
+contrived
+contriver
+contrives
+contriving
+control
+control's
+controllability
+controllable
+controllably
+controlled
+controller
+controller's
+controllers
+controlling
+controls
+controversial
+controversially
+controversies
+controversy
+controversy's
+conundrum
+conundrum's
+conundrums
+convalescence
+convene
+convened
+convener
+conveners
+convenes
+convenience
+convenience's
+conveniences
+convenient
+conveniently
+convening
+convent
+convent's
+convention
+convention's
+conventional
+conventionally
+conventions
+convents
+converge
+converged
+convergence
+convergences
+convergent
+converges
+converging
+conversant
+conversantly
+conversation
+conversation's
+conversational
+conversationally
+conversations
+converse
+conversed
+conversely
+converses
+conversing
+conversion
+conversioning
+conversions
+convert
+converted
+converter
+converters
+convertibility
+convertible
+convertibleness
+converting
+converts
+convex
+convey
+conveyance
+conveyance's
+conveyanced
+conveyancer
+conveyancers
+conveyances
+conveyancing
+conveyed
+conveyer
+conveyers
+conveying
+conveys
+convict
+convicted
+convicting
+conviction
+conviction's
+convictions
+convictive
+convicts
+convince
+convinced
+convincer
+convincers
+convinces
+convincing
+convincingly
+convincingness
+convoluted
+convoy
+convoyed
+convoying
+convoys
+convulsion
+convulsion's
+convulsions
+coo
+cooing
+cook
+cook's
+cooked
+cooker
+cookers
+cookery
+cookie
+cookie's
+cookies
+cooking
+cooks
+cooky
+cool
+cooled
+cooler
+cooler's
+coolers
+coolest
+coolie
+coolie's
+coolies
+cooling
+coolings
+coolly
+coolness
+coolnesses
+cools
+coon
+coon's
+coons
+coop
+cooped
+cooper
+cooperate
+cooperated
+cooperates
+cooperating
+cooperation
+cooperations
+cooperative
+cooperatively
+cooperativeness
+cooperatives
+cooperator
+cooperator's
+cooperators
+coopered
+coopering
+coopers
+coops
+coordinate
+coordinated
+coordinately
+coordinateness
+coordinates
+coordinating
+coordination
+coordinations
+coordinative
+coordinator
+coordinator's
+coordinators
+cop
+cop's
+cope
+coped
+coper
+copes
+copied
+copier
+copiers
+copies
+coping
+copings
+copious
+copiously
+copiousness
+copper
+copper's
+coppered
+coppering
+coppers
+cops
+copse
+copses
+copy
+copying
+copyright
+copyright's
+copyrighted
+copyrighter
+copyrighters
+copyrighting
+copyrights
+coral
+cord
+corded
+corder
+cordial
+cordially
+cordialness
+cording
+cords
+core
+cored
+corer
+corers
+cores
+coring
+cork
+corked
+corker
+corkers
+corking
+corks
+cormorant
+cormorants
+corn
+corned
+corner
+cornered
+cornering
+corners
+cornerstone
+cornerstone's
+cornerstones
+cornfield
+cornfield's
+cornfields
+corning
+corns
+corollaries
+corollary
+corollary's
+coronaries
+coronary
+coronation
+coronet
+coronet's
+coroneted
+coronets
+coroutine
+coroutine's
+coroutines
+corporal
+corporal's
+corporally
+corporals
+corporate
+corporately
+corporation
+corporation's
+corporations
+corporative
+corps
+corpse
+corpse's
+corpses
+corpus
+correct
+correctable
+corrected
+correcting
+correction
+corrections
+corrective
+correctively
+correctiveness
+correctives
+correctly
+correctness
+corrector
+corrects
+correlate
+correlated
+correlates
+correlating
+correlation
+correlations
+correlative
+correlatively
+correspond
+corresponded
+correspondence
+correspondence's
+correspondences
+correspondent
+correspondent's
+correspondents
+corresponding
+correspondingly
+corresponds
+corridor
+corridor's
+corridors
+corroborate
+corroborated
+corroborates
+corroborating
+corroboration
+corroborations
+corroborative
+corroboratively
+corrosion
+corrosions
+corrupt
+corrupted
+corrupter
+corrupting
+corruption
+corruptive
+corruptively
+corruptly
+corrupts
+corset
+corsets
+cosine
+cosines
+cosmetic
+cosmetics
+cosmology
+cosmopolitan
+cost
+costed
+costing
+costive
+costively
+costiveness
+costlier
+costliness
+costly
+costs
+costume
+costumed
+costumer
+costumers
+costumes
+costuming
+cot
+cot's
+cots
+cottage
+cottager
+cottagers
+cottages
+cotton
+cottoned
+cottoning
+cottons
+cotyledon
+cotyledon's
+cotyledons
+couch
+couched
+couches
+couching
+cough
+coughed
+cougher
+coughing
+coughs
+could
+couldest
+couldn't
+council
+council's
+councillor
+councillor's
+councillors
+councils
+counsel
+counsel's
+counsels
+count
+countable
+countably
+counted
+countenance
+countenancer
+counter
+counteract
+counteracted
+counteracting
+counteractive
+counteracts
+counterclockwise
+countered
+counterexample
+counterexamples
+counterfeit
+counterfeited
+counterfeiter
+counterfeiting
+counterfeits
+countering
+countermeasure
+countermeasure's
+countermeasures
+counterpart
+counterpart's
+counterparts
+counterpoint
+counterpointing
+counterproductive
+counterrevolution
+counters
+countess
+counties
+counting
+countless
+countlessly
+countries
+country
+country's
+countryman
+countryside
+counts
+county
+county's
+couple
+couple's
+coupled
+coupler
+couplers
+couples
+coupling
+couplings
+coupon
+coupon's
+coupons
+courage
+courageous
+courageously
+courageousness
+courier
+courier's
+couriers
+course
+coursed
+courser
+courses
+coursing
+court
+courted
+courteous
+courteously
+courteousness
+courter
+courters
+courtesies
+courtesy
+courtesy's
+courthouse
+courthouse's
+courthouses
+courtier
+courtier's
+courtiers
+courting
+courtliness
+courtly
+courtroom
+courtroom's
+courtrooms
+courts
+courtship
+courtyard
+courtyard's
+courtyards
+cousin
+cousin's
+cousins
+cove
+covenant
+covenant's
+covenanted
+covenanter
+covenanting
+covenants
+cover
+coverable
+coverage
+covered
+coverer
+covering
+coverings
+coverlet
+coverlet's
+coverlets
+covers
+covert
+covertly
+covertness
+coves
+covet
+coveted
+coveter
+coveting
+covetingly
+covetous
+covetously
+covetousness
+covets
+coving
+cow
+coward
+cowardice
+cowardliness
+cowardly
+cowards
+cowboy
+cowboy's
+cowboys
+cowed
+cowedly
+cower
+cowered
+cowerer
+cowerers
+cowering
+coweringly
+cowers
+cowgirl
+cowgirl's
+cowgirls
+cowing
+cowl
+cowled
+cowling
+cowls
+cows
+cowslip
+cowslip's
+cowslips
+coyote
+coyote's
+coyotes
+cozier
+cozies
+coziness
+cozy
+crab
+crab's
+crabs
+crack
+cracked
+cracker
+crackers
+cracking
+crackle
+crackled
+crackles
+crackling
+crackly
+cracks
+cradle
+cradled
+cradler
+cradles
+cradling
+craft
+crafted
+crafter
+craftier
+craftiness
+crafting
+crafts
+craftsman
+crafty
+crag
+crag's
+crags
+cram
+cramp
+cramp's
+cramped
+cramper
+cramps
+crams
+cranberries
+cranberry
+cranberry's
+crane
+crane's
+craned
+cranes
+craning
+crank
+cranked
+crankier
+crankiest
+crankily
+crankiness
+cranking
+cranks
+cranky
+crap
+craping
+craps
+crash
+crashed
+crasher
+crashers
+crashes
+crashing
+crate
+crater
+cratered
+craters
+crates
+crating
+cravat
+cravat's
+cravats
+crave
+craved
+craven
+cravenly
+cravenness
+craver
+craves
+craving
+crawl
+crawled
+crawler
+crawlers
+crawling
+crawls
+craze
+crazed
+crazes
+crazier
+craziest
+crazily
+craziness
+crazing
+crazy
+creak
+creaked
+creaking
+creaks
+cream
+creamed
+creamer
+creamers
+creaminess
+creaming
+creams
+creamy
+crease
+creased
+creaser
+creases
+creasing
+create
+created
+creates
+creating
+creation
+creations
+creative
+creatively
+creativeness
+creativity
+creator
+creator's
+creators
+creature
+creature's
+creatureliness
+creaturely
+creatures
+credence
+credibility
+credible
+credibly
+credit
+creditable
+creditableness
+creditably
+credited
+crediting
+creditor
+creditor's
+creditors
+credits
+credulity
+credulous
+credulously
+credulousness
+creed
+creed's
+creeds
+creek
+creek's
+creeks
+creep
+creeper
+creepers
+creeping
+creeps
+cremate
+cremated
+cremates
+cremating
+cremation
+cremations
+crepe
+crept
+crescent
+crescent's
+crescents
+crest
+crested
+cresting
+crests
+cretin
+cretins
+crevice
+crevice's
+crevices
+crew
+crewed
+crewing
+crews
+crib
+crib's
+cribs
+cricket
+cricket's
+cricketer
+cricketing
+crickets
+cried
+crier
+criers
+cries
+crime
+crime's
+crimes
+criminal
+criminally
+criminals
+crimson
+crimsoning
+cringe
+cringed
+cringer
+cringes
+cringing
+cripple
+crippled
+crippler
+cripples
+crippling
+crises
+crisis
+crisp
+crisper
+crisply
+crispness
+crisps
+criteria
+criterion
+critic
+critic's
+critical
+critically
+criticalness
+criticism
+criticism's
+criticisms
+critics
+critique
+critiqued
+critiques
+critiquing
+critter
+critter's
+critters
+croak
+croaked
+croaker
+croakers
+croaking
+croaks
+crochet
+crocheted
+crocheter
+crocheting
+crochets
+crook
+crooked
+crookedly
+crookedness
+crooks
+crop
+crop's
+cropped
+cropper
+cropper's
+croppers
+cropping
+crops
+cross
+crossable
+crossbar
+crossbar's
+crossbars
+crossed
+crosser
+crossers
+crosses
+crossing
+crossings
+crossly
+crossover
+crossover's
+crossovers
+crossword
+crossword's
+crosswords
+crouch
+crouched
+crouches
+crouching
+crow
+crowd
+crowded
+crowdedness
+crowder
+crowding
+crowds
+crowed
+crowing
+crown
+crowned
+crowner
+crowning
+crowns
+crows
+crucial
+crucially
+crucification
+crucified
+crucifies
+crucify
+crucifying
+crude
+crudely
+crudeness
+cruder
+crudest
+cruel
+crueler
+cruelest
+cruelly
+cruelness
+cruelty
+cruise
+cruised
+cruiser
+cruisers
+cruises
+cruising
+crumb
+crumble
+crumbled
+crumbles
+crumblier
+crumbliness
+crumbling
+crumblings
+crumbly
+crumbs
+crumple
+crumpled
+crumples
+crumpling
+crunch
+crunched
+cruncher
+crunchers
+crunches
+crunchier
+crunchiest
+crunchiness
+crunching
+crunchy
+crusade
+crusaded
+crusader
+crusaders
+crusades
+crusading
+crush
+crushable
+crushed
+crusher
+crushers
+crushes
+crushing
+crushingly
+crust
+crust's
+crustacean
+crustacean's
+crustaceans
+crusted
+crusting
+crusts
+crutch
+crutch's
+crutched
+crutches
+crux
+crux's
+cruxes
+cry
+crying
+cryptanalysis
+cryptic
+cryptographic
+cryptography
+cryptology
+crystal
+crystal's
+crystalline
+crystals
+cub
+cub's
+cube
+cubed
+cuber
+cubes
+cubic
+cubicly
+cubics
+cubing
+cubs
+cuckoo
+cuckoo's
+cuckoos
+cucumber
+cucumber's
+cucumbers
+cuddle
+cuddled
+cuddles
+cuddling
+cudgel
+cudgel's
+cudgels
+cue
+cued
+cues
+cuff
+cuff's
+cuffed
+cuffing
+cuffs
+cuing
+cull
+culled
+culler
+culling
+culls
+culminate
+culminated
+culminates
+culminating
+culmination
+culpability
+culprit
+culprit's
+culprits
+cult
+cult's
+cultivate
+cultivated
+cultivates
+cultivating
+cultivation
+cultivations
+cultivator
+cultivator's
+cultivators
+cults
+cultural
+culturally
+culture
+cultured
+cultures
+culturing
+cumbersome
+cumbersomely
+cumbersomeness
+cumulative
+cumulatively
+cunning
+cunningly
+cunningness
+cup
+cup's
+cupboard
+cupboard's
+cupboards
+cupful
+cupfuls
+cupped
+cupping
+cups
+cur
+curable
+curableness
+curably
+curb
+curbed
+curbing
+curbs
+curds
+cure
+cured
+curer
+cures
+curfew
+curfew's
+curfews
+curing
+curiosities
+curiosity
+curiosity's
+curious
+curiouser
+curiousest
+curiously
+curiousness
+curl
+curled
+curler
+curlers
+curlier
+curliness
+curling
+curls
+curly
+currant
+currant's
+currants
+currencies
+currency
+currency's
+current
+currently
+currentness
+currents
+curricular
+curriculum
+curriculum's
+curriculums
+curried
+currier
+curries
+curry
+currying
+curs
+curse
+cursed
+cursedly
+cursedness
+curses
+cursing
+cursive
+cursively
+cursiveness
+cursor
+cursor's
+cursorily
+cursoriness
+cursors
+cursory
+curt
+curtail
+curtailed
+curtailer
+curtailing
+curtails
+curtain
+curtained
+curtaining
+curtains
+curtly
+curtness
+curtsied
+curtsies
+curtsy
+curtsy's
+curtsying
+curvature
+curvatures
+curve
+curved
+curves
+curving
+cushion
+cushioned
+cushioning
+cushions
+cusp
+cusp's
+cusps
+cuss
+cussed
+cussedly
+cussedness
+cusser
+cusses
+custard
+custodian
+custodian's
+custodians
+custodies
+custody
+custom
+customarily
+customariness
+customary
+customer
+customer's
+customers
+customs
+cut
+cut's
+cute
+cutely
+cuteness
+cuter
+cutes
+cutest
+cutoff
+cutoffs
+cuts
+cutter
+cutter's
+cutters
+cutting
+cuttingly
+cuttings
+cybernetic
+cybernetics
+cycle
+cycled
+cycler
+cycles
+cyclic
+cyclically
+cyclicly
+cycling
+cycloid
+cycloid's
+cycloidal
+cycloids
+cyclone
+cyclone's
+cyclones
+cylinder
+cylinder's
+cylindered
+cylindering
+cylinders
+cylindrical
+cylindrically
+cymbal
+cymbal's
+cymbals
+cynical
+cynically
+cypress
+cyst
+cysts
+cytology
+czar
+dabble
+dabbled
+dabbler
+dabblers
+dabbles
+dabbling
+dad
+dad's
+daddies
+daddy
+dads
+daemon
+daemon's
+daemons
+daffodil
+daffodil's
+daffodils
+dagger
+daggers
+dailies
+daily
+daintier
+dainties
+daintily
+daintiness
+dainty
+dairies
+dairy
+dairying
+daisies
+daisy
+daisy's
+dale
+dale's
+dales
+daleth
+dam
+dam's
+damage
+damaged
+damager
+damagers
+damages
+damaging
+damagingly
+damask
+dame
+damed
+damn
+damnation
+damned
+damneder
+damnedest
+damning
+damningly
+damns
+damp
+damped
+dampen
+dampened
+dampener
+dampening
+dampens
+damper
+dampers
+damping
+damply
+dampness
+damps
+dams
+damsel
+damsel's
+damsels
+dance
+danced
+dancer
+dancers
+dances
+dancing
+dandelion
+dandelion's
+dandelions
+dandier
+dandies
+dandy
+danger
+danger's
+dangerous
+dangerously
+dangerousness
+dangers
+dangle
+dangled
+dangler
+dangler's
+danglers
+dangles
+dangling
+danglingly
+dare
+dared
+darer
+darers
+dares
+daring
+daringly
+daringness
+dark
+darken
+darkened
+darkener
+darkeners
+darkening
+darker
+darkest
+darkly
+darkness
+darks
+darling
+darling's
+darlingly
+darlingness
+darlings
+darn
+darned
+darner
+darning
+darns
+dart
+darted
+darter
+darting
+darts
+dash
+dashed
+dasher
+dashers
+dashes
+dashing
+dashingly
+data
+database
+database's
+databases
+date
+dated
+datedly
+datedness
+dater
+dates
+dating
+dative
+datum
+datums
+daughter
+daughter's
+daughterly
+daughters
+daunt
+daunted
+daunting
+dauntless
+dauntlessly
+dauntlessness
+daunts
+dawn
+dawned
+dawning
+dawns
+day
+day's
+daybreak
+daybreaks
+daydream
+daydreamed
+daydreamer
+daydreamers
+daydreaming
+daydreams
+daylight
+daylight's
+daylights
+days
+daytime
+daytimes
+daze
+dazed
+dazedness
+dazes
+dazing
+dazzle
+dazzled
+dazzler
+dazzlers
+dazzles
+dazzling
+dazzlingly
+deacon
+deacon's
+deacons
+dead
+deaden
+deadened
+deadener
+deadening
+deadeningly
+deadens
+deadlier
+deadliest
+deadline
+deadline's
+deadlines
+deadliness
+deadlock
+deadlocked
+deadlocking
+deadlocks
+deadly
+deadness
+deaf
+deafen
+deafened
+deafening
+deafeningly
+deafens
+deafer
+deafest
+deafly
+deafness
+deal
+dealer
+dealers
+dealing
+dealings
+deallocate
+deallocated
+deallocates
+deallocating
+deallocation
+deallocation's
+deallocations
+deallocator
+deals
+dealt
+dean
+dean's
+deans
+dear
+dearer
+dearest
+dearly
+dearness
+dears
+dearth
+dearths
+death
+deathly
+deaths
+debatable
+debate
+debated
+debater
+debaters
+debates
+debating
+debilitate
+debilitated
+debilitates
+debilitating
+debilitation
+debris
+debt
+debt's
+debtor
+debtors
+debts
+debug
+debugged
+debugger
+debugger's
+debuggers
+debugging
+debugs
+decade
+decade's
+decadence
+decadent
+decadently
+decades
+decay
+decayed
+decayer
+decaying
+decays
+decease
+deceased
+deceases
+deceasing
+deceit
+deceitful
+deceitfully
+deceitfulness
+deceive
+deceived
+deceiver
+deceivers
+deceives
+deceiving
+deceivingly
+decelerate
+decelerated
+decelerates
+decelerating
+deceleration
+decelerations
+decencies
+decency
+decency's
+decent
+decently
+deception
+deception's
+deceptions
+deceptive
+deceptively
+deceptiveness
+decidability
+decidable
+decide
+decided
+decidedly
+decidedness
+decider
+decides
+deciding
+decimal
+decimally
+decimals
+decimate
+decimated
+decimates
+decimating
+decimation
+decipher
+deciphered
+decipherer
+decipherers
+deciphering
+deciphers
+decision
+decision's
+decisions
+decisive
+decisively
+decisiveness
+deck
+decked
+decker
+decking
+deckings
+decks
+declaration
+declaration's
+declarations
+declarative
+declaratively
+declaratives
+declare
+declared
+declarer
+declarers
+declares
+declaring
+declination
+declination's
+declinations
+decline
+declined
+decliner
+decliners
+declines
+declining
+decode
+decoded
+decoder
+decoders
+decodes
+decoding
+decodings
+decompile
+decompiled
+decompiler
+decompilers
+decompiles
+decompiling
+decomposability
+decomposable
+decompose
+decomposed
+decomposer
+decomposes
+decomposing
+decomposition
+decomposition's
+decompositions
+decompression
+decorate
+decorated
+decorates
+decorating
+decoration
+decorations
+decorative
+decoratively
+decorativeness
+decorum
+decorums
+decouple
+decoupled
+decoupler
+decouples
+decoupling
+decoy
+decoy's
+decoys
+decrease
+decreased
+decreases
+decreasing
+decreasingly
+decree
+decreed
+decreeing
+decreer
+decrees
+decrement
+decremented
+decrementing
+decrements
+dedicate
+dedicated
+dedicatedly
+dedicates
+dedicating
+dedication
+dedications
+dedicative
+deduce
+deduced
+deducer
+deduces
+deducible
+deducing
+deduct
+deducted
+deducting
+deduction
+deduction's
+deductions
+deductive
+deductively
+deducts
+deed
+deeded
+deeding
+deeds
+deem
+deemed
+deeming
+deems
+deep
+deepen
+deepened
+deepening
+deepens
+deeper
+deepest
+deeply
+deepness
+deeps
+deer
+deers
+default
+defaulted
+defaulter
+defaulting
+defaults
+defeat
+defeated
+defeating
+defeatism
+defeatist
+defeatists
+defeats
+defect
+defected
+defecting
+defection
+defection's
+defections
+defective
+defectively
+defectiveness
+defectives
+defects
+defend
+defendant
+defendant's
+defendants
+defended
+defender
+defenders
+defending
+defends
+defenestrate
+defenestrated
+defenestrates
+defenestrating
+defenestration
+defenestrations
+defensive
+defensively
+defensiveness
+defer
+deference
+deferment
+deferment's
+deferments
+deferrable
+deferred
+deferrer
+deferrer's
+deferrers
+deferring
+defers
+defiance
+defiances
+defiant
+defiantly
+deficiencies
+deficiency
+deficient
+deficiently
+deficit
+deficit's
+deficits
+defied
+defier
+defies
+defile
+defiled
+defiler
+defiles
+defiling
+definable
+define
+defined
+definer
+definers
+defines
+defining
+definite
+definitely
+definiteness
+definition
+definition's
+definitional
+definitions
+definitive
+definitively
+definitiveness
+deformation
+deformation's
+deformations
+deformed
+deformities
+deformity
+deformity's
+deftly
+defy
+defying
+defyingly
+degenerate
+degenerated
+degenerately
+degenerateness
+degenerates
+degenerating
+degeneration
+degenerative
+degradable
+degradation
+degradation's
+degradations
+degrade
+degraded
+degradedly
+degradedness
+degrader
+degrades
+degrading
+degradingly
+degree
+degree's
+degreed
+degrees
+deign
+deigned
+deigning
+deigns
+deities
+deity
+deity's
+dejected
+dejectedly
+dejectedness
+delay
+delayed
+delayer
+delayers
+delaying
+delays
+delegate
+delegated
+delegates
+delegating
+delegation
+delegations
+delete
+deleted
+deleter
+deletes
+deleting
+deletion
+deletions
+deliberate
+deliberated
+deliberately
+deliberateness
+deliberates
+deliberating
+deliberation
+deliberations
+deliberative
+deliberatively
+deliberativeness
+deliberator
+deliberator's
+deliberators
+delicacies
+delicacy
+delicacy's
+delicate
+delicately
+delicateness
+delicates
+delicious
+deliciouses
+deliciously
+deliciousness
+delight
+delighted
+delightedly
+delightedness
+delighter
+delightful
+delightfully
+delightfulness
+delighting
+delights
+delimit
+delimited
+delimiter
+delimiters
+delimiting
+delimits
+delineate
+delineated
+delineates
+delineating
+delineation
+delineations
+delineative
+delinquency
+delinquent
+delinquent's
+delinquently
+delinquents
+delirious
+deliriously
+deliriousness
+deliver
+deliverable
+deliverables
+deliverance
+delivered
+deliverer
+deliverers
+deliveries
+delivering
+delivers
+delivery
+delivery's
+dell
+dell's
+dells
+delta
+delta's
+deltas
+delude
+deluded
+deluder
+deludes
+deluding
+deludingly
+deluge
+deluged
+deluges
+deluging
+delusion
+delusion's
+delusions
+delve
+delved
+delver
+delves
+delving
+demand
+demanded
+demander
+demanding
+demandingly
+demands
+demise
+demised
+demises
+demising
+demo
+democracies
+democracy
+democracy's
+democrat
+democrat's
+democratic
+democratically
+democrats
+demodulate
+demodulated
+demodulates
+demodulating
+demodulation
+demodulation's
+demodulations
+demodulator
+demodulator's
+demodulators
+demographic
+demographics
+demolish
+demolished
+demolisher
+demolishes
+demolishing
+demolition
+demolitions
+demon
+demon's
+demoness
+demons
+demonstrable
+demonstrableness
+demonstrate
+demonstrated
+demonstrates
+demonstrating
+demonstration
+demonstrations
+demonstrative
+demonstratively
+demonstrativeness
+demonstrator
+demonstrator's
+demonstrators
+demos
+demur
+demurs
+den
+den's
+deniable
+denial
+denial's
+denials
+denied
+denier
+denies
+denigrate
+denigrated
+denigrates
+denigrating
+denigration
+denigrative
+denizen
+denizens
+denomination
+denomination's
+denominations
+denominator
+denominator's
+denominators
+denotable
+denotation
+denotation's
+denotational
+denotationally
+denotations
+denotative
+denote
+denoted
+denotes
+denoting
+denounce
+denounced
+denouncer
+denouncers
+denounces
+denouncing
+dens
+dense
+densely
+denseness
+denser
+densest
+densities
+density
+density's
+dent
+dental
+dentally
+dentals
+dented
+denting
+dentist
+dentist's
+dentists
+dents
+deny
+denying
+denyingly
+depart
+departed
+departing
+department
+department's
+departmental
+departmentally
+departments
+departs
+departure
+departure's
+departures
+depend
+dependability
+dependable
+dependableness
+dependably
+depended
+dependence
+dependences
+dependencies
+dependency
+dependent
+dependently
+dependents
+depending
+depends
+depict
+depicted
+depicter
+depicting
+depicts
+deplete
+depleted
+depletes
+depleting
+depletion
+depletions
+depletive
+deplorable
+deplorableness
+deplore
+deplored
+deplorer
+deplores
+deploring
+deploringly
+deploy
+deployed
+deploying
+deployment
+deployment's
+deployments
+deploys
+deport
+deportation
+deported
+deportee
+deportee's
+deportees
+deporting
+deportment
+deports
+depose
+deposed
+deposes
+deposing
+deposit
+deposited
+depositing
+deposition
+deposition's
+depositions
+depositor
+depositor's
+depositors
+deposits
+depot
+depot's
+depots
+deprave
+depraved
+depravedly
+depravedness
+depraver
+depraves
+depraving
+depreciate
+depreciated
+depreciates
+depreciating
+depreciatingly
+depreciation
+depreciations
+depreciative
+depreciatively
+depress
+depressed
+depresses
+depressing
+depressingly
+depression
+depression's
+depressions
+depressive
+depressively
+deprivation
+deprivation's
+deprivations
+deprive
+deprived
+deprives
+depriving
+depth
+depths
+deputies
+deputy
+deputy's
+dequeue
+dequeued
+dequeues
+dequeuing
+derail
+derailed
+derailing
+derails
+derbies
+derby
+dereference
+dereferenced
+dereferencer
+dereferencers
+dereferences
+dereferencing
+deride
+derided
+derider
+derides
+deriding
+deridingly
+derision
+derivable
+derivation
+derivation's
+derivations
+derivative
+derivative's
+derivatively
+derivativeness
+derivatives
+derive
+derived
+deriver
+derives
+deriving
+descend
+descendant
+descendant's
+descendants
+descended
+descender
+descenders
+descending
+descends
+descent
+descent's
+descents
+describable
+describe
+described
+describer
+describers
+describes
+describing
+descried
+description
+description's
+descriptions
+descriptive
+descriptively
+descriptiveness
+descriptives
+descriptor
+descriptor's
+descriptors
+descry
+descrying
+desert
+deserted
+deserter
+deserters
+deserting
+desertion
+desertions
+deserts
+deserve
+deserved
+deservedly
+deservedness
+deserver
+deserves
+deserving
+deservingly
+deservings
+desiderata
+desideratum
+design
+designate
+designated
+designates
+designating
+designation
+designations
+designative
+designator
+designator's
+designators
+designed
+designedly
+designer
+designer's
+designers
+designing
+designs
+desirability
+desirable
+desirableness
+desirably
+desire
+desired
+desirer
+desires
+desiring
+desirous
+desirously
+desirousness
+desk
+desk's
+desks
+desktop
+desolate
+desolated
+desolately
+desolateness
+desolater
+desolates
+desolating
+desolatingly
+desolation
+desolations
+despair
+despaired
+despairer
+despairing
+despairingly
+despairs
+despatch
+despatched
+desperate
+desperately
+desperateness
+desperation
+despise
+despised
+despiser
+despises
+despising
+despite
+despited
+despot
+despot's
+despotic
+despots
+dessert
+dessert's
+desserts
+destination
+destination's
+destinations
+destine
+destined
+destinies
+destining
+destiny
+destiny's
+destitute
+destituteness
+destitution
+destroy
+destroyed
+destroyer
+destroyer's
+destroyers
+destroying
+destroys
+destruction
+destruction's
+destructions
+destructive
+destructively
+destructiveness
+detach
+detached
+detachedly
+detachedness
+detacher
+detaches
+detaching
+detachment
+detachment's
+detachments
+detail
+detailed
+detailedly
+detailedness
+detailer
+detailing
+details
+detain
+detained
+detainer
+detaining
+detains
+detect
+detectable
+detectably
+detected
+detecting
+detection
+detection's
+detections
+detective
+detectives
+detector
+detector's
+detectors
+detects
+detention
+deteriorate
+deteriorated
+deteriorates
+deteriorating
+deterioration
+deteriorative
+determinable
+determinableness
+determinacy
+determinant
+determinant's
+determinants
+determinate
+determinately
+determinateness
+determination
+determinations
+determinative
+determinatively
+determinativeness
+determine
+determined
+determinedly
+determinedness
+determiner
+determiners
+determines
+determining
+determinism
+deterministic
+deterministically
+detest
+detestable
+detestableness
+detested
+detesting
+detests
+detonate
+detonated
+detonates
+detonating
+detonation
+detonative
+detract
+detracted
+detracting
+detractive
+detractively
+detractor
+detractor's
+detractors
+detracts
+detriment
+detriments
+devastate
+devastated
+devastates
+devastating
+devastatingly
+devastation
+devastations
+devastative
+develop
+developed
+developer
+developer's
+developers
+developing
+development
+development's
+developmental
+developmentally
+developments
+develops
+deviant
+deviant's
+deviantly
+deviants
+deviate
+deviated
+deviates
+deviating
+deviation
+deviations
+device
+device's
+devices
+devil
+devil's
+devilish
+devilishly
+devilishness
+devils
+devise
+devised
+deviser
+devises
+devising
+devisings
+devision
+devisions
+devoid
+devote
+devoted
+devotedly
+devotee
+devotee's
+devotees
+devotes
+devoting
+devotion
+devotions
+devour
+devoured
+devourer
+devouring
+devours
+devout
+devoutly
+devoutness
+dew
+dewdrop
+dewdrop's
+dewdrops
+dewed
+dewier
+dewiness
+dewing
+dews
+dewy
+dexterity
+diabetes
+diadem
+diagnosable
+diagnose
+diagnosed
+diagnoses
+diagnosing
+diagnosis
+diagnostic
+diagnostic's
+diagnostics
+diagonal
+diagonally
+diagonals
+diagram
+diagram's
+diagramed
+diagraming
+diagrammable
+diagrammatic
+diagrammatically
+diagrammed
+diagrammer
+diagrammer's
+diagrammers
+diagramming
+diagrams
+dial
+dial's
+dialect
+dialect's
+dialects
+dialog
+dialog's
+dialogs
+dialogue
+dialogue's
+dialogues
+dials
+diameter
+diameter's
+diameters
+diametrically
+diamond
+diamond's
+diamonds
+diaper
+diaper's
+diapered
+diapering
+diapers
+diaphragm
+diaphragm's
+diaphragms
+diaries
+diary
+diary's
+diatribe
+diatribe's
+diatribes
+dice
+dicer
+dices
+dichotomies
+dichotomy
+dicing
+dickens
+dicky
+dictate
+dictated
+dictates
+dictating
+dictation
+dictations
+dictator
+dictator's
+dictators
+dictatorship
+dictatorships
+diction
+dictionaries
+dictionary
+dictionary's
+dictions
+dictum
+dictum's
+dictums
+did
+didn't
+die
+died
+dielectric
+dielectric's
+dielectrics
+dies
+diet
+dieter
+dieters
+dietitian
+dietitian's
+dietitians
+diets
+differ
+differed
+difference
+difference's
+differenced
+differences
+differencing
+different
+differential
+differential's
+differentially
+differentials
+differentiate
+differentiated
+differentiates
+differentiating
+differentiation
+differentiations
+differentiators
+differently
+differentness
+differer
+differers
+differing
+differs
+difficult
+difficulties
+difficultly
+difficulty
+difficulty's
+diffuse
+diffused
+diffusely
+diffuseness
+diffuser
+diffusers
+diffuses
+diffusing
+diffusion
+diffusions
+diffusive
+diffusively
+diffusiveness
+dig
+digest
+digested
+digester
+digestible
+digesting
+digestion
+digestions
+digestive
+digestively
+digestiveness
+digests
+digger
+digger's
+diggers
+digging
+diggings
+digit
+digit's
+digital
+digitally
+digits
+dignified
+dignify
+dignities
+dignity
+digress
+digressed
+digresses
+digressing
+digression
+digression's
+digressions
+digressive
+digressively
+digressiveness
+digs
+dike
+dike's
+diker
+dikes
+diking
+dilate
+dilated
+dilatedly
+dilatedness
+dilates
+dilating
+dilation
+dilative
+dilemma
+dilemma's
+dilemmas
+diligence
+diligences
+diligent
+diligently
+diligentness
+dilute
+diluted
+dilutely
+diluteness
+diluter
+dilutes
+diluting
+dilution
+dilutions
+dilutive
+dim
+dime
+dime's
+dimension
+dimensional
+dimensionality
+dimensionally
+dimensioned
+dimensioning
+dimensions
+dimer
+dimers
+dimes
+diminish
+diminished
+diminishes
+diminishing
+diminution
+diminutive
+diminutively
+diminutiveness
+dimly
+dimmed
+dimmer
+dimmer's
+dimmers
+dimmest
+dimming
+dimness
+dimple
+dimpled
+dimples
+dimpling
+dims
+din
+dine
+dined
+diner
+diners
+dines
+dingier
+dinginess
+dingy
+dining
+dinner
+dinner's
+dinners
+dint
+diode
+diode's
+diodes
+dioxide
+dioxides
+dip
+diphtheria
+diploma
+diploma's
+diplomacy
+diplomas
+diplomat
+diplomat's
+diplomatic
+diplomatics
+diplomats
+dipped
+dipper
+dipper's
+dippers
+dipping
+dippings
+dips
+dire
+direct
+directed
+directing
+direction
+direction's
+directional
+directionality
+directionally
+directions
+directive
+directive's
+directives
+directly
+directness
+director
+director's
+directories
+directors
+directory
+directory's
+directs
+direly
+direness
+direr
+direst
+dirge
+dirge's
+dirged
+dirges
+dirging
+dirt
+dirt's
+dirtied
+dirtier
+dirties
+dirtiest
+dirtily
+dirtiness
+dirts
+dirty
+dirtying
+disabilities
+disability
+disability's
+disable
+disabled
+disabler
+disablers
+disables
+disabling
+disabuse
+disadvantage
+disadvantage's
+disadvantaged
+disadvantagedness
+disadvantages
+disadvantaging
+disagree
+disagreeable
+disagreeableness
+disagreed
+disagreeing
+disagreement
+disagreement's
+disagreements
+disagrees
+disallow
+disallowed
+disallowing
+disallows
+disambiguate
+disambiguated
+disambiguates
+disambiguating
+disambiguation
+disambiguations
+disappear
+disappearance
+disappearance's
+disappearances
+disappeared
+disappearing
+disappears
+disappoint
+disappointed
+disappointedly
+disappointing
+disappointingly
+disappointment
+disappointment's
+disappointments
+disappoints
+disapproval
+disapprove
+disapproved
+disapprover
+disapproves
+disapproving
+disapprovingly
+disarm
+disarmament
+disarmed
+disarmer
+disarmers
+disarming
+disarmingly
+disarms
+disassemble
+disassembled
+disassembler
+disassembler's
+disassemblers
+disassembles
+disassembling
+disaster
+disaster's
+disasters
+disastrous
+disastrously
+disband
+disbanded
+disbanding
+disbands
+disbelieve
+disbelieved
+disbeliever
+disbelievers
+disbelieves
+disbelieving
+disburse
+disbursed
+disbursement
+disbursement's
+disbursements
+disburser
+disburses
+disbursing
+disc
+disc's
+discard
+discarded
+discarder
+discarding
+discards
+discern
+discerned
+discerner
+discernibility
+discernible
+discernibly
+discerning
+discerningly
+discernment
+discerns
+discharge
+discharged
+discharger
+discharges
+discharging
+disciple
+disciple's
+disciples
+disciplinary
+discipline
+disciplined
+discipliner
+disciplines
+disciplining
+disclaim
+disclaimed
+disclaimer
+disclaimers
+disclaiming
+disclaims
+disclose
+disclosed
+discloser
+discloses
+disclosing
+disclosure
+disclosure's
+disclosures
+discomfort
+discomforting
+discomfortingly
+disconcert
+disconcerted
+disconcerting
+disconcertingly
+disconcerts
+disconnect
+disconnected
+disconnectedly
+disconnectedness
+disconnecter
+disconnecting
+disconnection
+disconnections
+disconnects
+discontent
+discontented
+discontentedly
+discontinuance
+discontinue
+discontinued
+discontinues
+discontinuing
+discontinuities
+discontinuity
+discontinuity's
+discontinuous
+discontinuously
+discord
+discords
+discount
+discounted
+discounter
+discounting
+discounts
+discourage
+discouraged
+discouragement
+discourager
+discourages
+discouraging
+discouragingly
+discourse
+discourse's
+discoursed
+discourser
+discourses
+discoursing
+discover
+discovered
+discoverer
+discoverers
+discoveries
+discovering
+discovers
+discovery
+discovery's
+discredit
+discredited
+discrediting
+discredits
+discreet
+discreetly
+discreetness
+discrepancies
+discrepancy
+discrepancy's
+discrete
+discretely
+discreteness
+discretion
+discretions
+discriminate
+discriminated
+discriminates
+discriminating
+discriminatingly
+discrimination
+discriminations
+discriminative
+discriminatory
+discs
+discuss
+discussed
+discusser
+discusses
+discussing
+discussion
+discussion's
+discussions
+disdain
+disdaining
+disdains
+disease
+diseased
+diseases
+diseasing
+disenfranchise
+disenfranchised
+disenfranchisement
+disenfranchisement's
+disenfranchisements
+disenfranchiser
+disenfranchises
+disenfranchising
+disengage
+disengaged
+disengages
+disengaging
+disentangle
+disentangled
+disentangler
+disentangles
+disentangling
+disfigure
+disfigured
+disfigures
+disfiguring
+disgorge
+disgorger
+disgrace
+disgraced
+disgraceful
+disgracefully
+disgracefulness
+disgracer
+disgraces
+disgracing
+disgruntled
+disguise
+disguised
+disguisedly
+disguiser
+disguises
+disguising
+disgust
+disgusted
+disgustedly
+disgusting
+disgustingly
+disgusts
+dish
+dishearten
+disheartening
+dishearteningly
+dished
+dishes
+dishing
+dishonest
+dishonestly
+dishwasher
+dishwashers
+disillusion
+disillusioned
+disillusioning
+disillusionment
+disillusionment's
+disillusionments
+disinterested
+disinterestedly
+disinterestedness
+disjoint
+disjointed
+disjointedly
+disjointedness
+disjointly
+disjointness
+disjunct
+disjunction
+disjunctions
+disjunctive
+disjunctively
+disjuncts
+disk
+disk's
+disked
+disking
+disks
+dislike
+disliked
+disliker
+dislikes
+disliking
+dislocate
+dislocated
+dislocates
+dislocating
+dislocation
+dislocations
+dislodge
+dislodged
+dislodges
+dislodging
+dismal
+dismally
+dismalness
+dismay
+dismayed
+dismaying
+dismayingly
+dismays
+dismiss
+dismissal
+dismissal's
+dismissals
+dismissed
+dismisser
+dismissers
+dismisses
+dismissing
+dismissive
+dismount
+dismounted
+dismounting
+dismounts
+disobedience
+disobey
+disobeyed
+disobeyer
+disobeying
+disobeys
+disorder
+disordered
+disorderedly
+disorderedness
+disorderliness
+disorderly
+disorders
+disown
+disowned
+disowning
+disowns
+disparate
+disparately
+disparateness
+disparities
+disparity
+disparity's
+dispatch
+dispatched
+dispatcher
+dispatchers
+dispatches
+dispatching
+dispel
+dispelled
+dispelling
+dispels
+dispensation
+dispense
+dispensed
+dispenser
+dispensers
+dispenses
+dispensing
+disperse
+dispersed
+dispersedly
+disperser
+disperses
+dispersing
+dispersion
+dispersions
+dispersive
+dispersively
+dispersiveness
+displace
+displaced
+displacement
+displacement's
+displacements
+displacer
+displaces
+displacing
+display
+displayed
+displayer
+displaying
+displays
+displease
+displeased
+displeasedly
+displeases
+displeasing
+displeasure
+disposable
+disposal
+disposal's
+disposals
+dispose
+disposed
+disposer
+disposes
+disposing
+disposition
+disposition's
+dispositions
+disprove
+disproved
+disproves
+disproving
+dispute
+disputed
+disputer
+disputers
+disputes
+disputing
+disqualification
+disqualified
+disqualifies
+disqualify
+disqualifying
+disquiet
+disquieting
+disquietingly
+disquietly
+disregard
+disregarded
+disregarding
+disregards
+disrupt
+disrupted
+disrupter
+disrupting
+disruption
+disruption's
+disruptions
+disruptive
+disruptively
+disruptiveness
+disrupts
+dissatisfaction
+dissatisfaction's
+dissatisfactions
+dissatisfied
+disseminate
+disseminated
+disseminates
+disseminating
+dissemination
+dissension
+dissension's
+dissensions
+dissent
+dissented
+dissenter
+dissenters
+dissenting
+dissents
+dissertation
+dissertation's
+dissertations
+disservice
+dissident
+dissident's
+dissidents
+dissimilar
+dissimilarities
+dissimilarity
+dissimilarity's
+dissimilarly
+dissipate
+dissipated
+dissipatedly
+dissipatedness
+dissipater
+dissipates
+dissipating
+dissipation
+dissipations
+dissipative
+dissociate
+dissociated
+dissociates
+dissociating
+dissociation
+dissociative
+dissolution
+dissolution's
+dissolutions
+dissolve
+dissolved
+dissolver
+dissolves
+dissolving
+dissonance
+dissonance's
+dissonances
+distal
+distally
+distance
+distanced
+distances
+distancing
+distant
+distantly
+distantness
+distaste
+distasteful
+distastefully
+distastefulness
+distastes
+distemper
+distill
+distillation
+distilled
+distiller
+distillers
+distilling
+distills
+distinct
+distinction
+distinction's
+distinctions
+distinctive
+distinctively
+distinctiveness
+distinctly
+distinctness
+distinguish
+distinguishable
+distinguished
+distinguisher
+distinguishes
+distinguishing
+distort
+distorted
+distorter
+distorting
+distortion
+distortion's
+distortions
+distorts
+distract
+distracted
+distractedly
+distracting
+distractingly
+distraction
+distraction's
+distractions
+distractive
+distracts
+distraught
+distraughtly
+distress
+distressed
+distresses
+distressing
+distressingly
+distribute
+distributed
+distributer
+distributes
+distributing
+distribution
+distribution's
+distributional
+distributions
+distributive
+distributively
+distributiveness
+distributivity
+distributor
+distributor's
+distributors
+district
+district's
+districted
+districting
+districts
+distrust
+distrusted
+distrusts
+disturb
+disturbance
+disturbance's
+disturbances
+disturbed
+disturber
+disturbing
+disturbingly
+disturbs
+ditch
+ditch's
+ditched
+ditcher
+ditches
+ditching
+divan
+divan's
+divans
+dive
+dived
+diver
+diverge
+diverged
+divergence
+divergence's
+divergences
+divergent
+divergently
+diverges
+diverging
+divers
+diverse
+diversely
+diverseness
+diversification
+diversified
+diversifier
+diversifies
+diversify
+diversifying
+diversion
+diversions
+diversities
+diversity
+divert
+diverted
+diverting
+diverts
+dives
+divest
+divested
+divesting
+divests
+divide
+divided
+dividend
+dividend's
+dividends
+divider
+dividers
+divides
+dividing
+divine
+divined
+divinely
+diviner
+divines
+diving
+divining
+divinities
+divinity
+divinity's
+division
+division's
+divisions
+divisor
+divisor's
+divisors
+divorce
+divorced
+divorces
+divorcing
+divulge
+divulged
+divulges
+divulging
+dizzied
+dizzier
+dizziness
+dizzy
+dizzying
+dizzyingly
+do
+dock
+docked
+docker
+docking
+docks
+doctor
+doctor's
+doctoral
+doctorate
+doctorate's
+doctorates
+doctored
+doctoring
+doctors
+doctrine
+doctrine's
+doctrines
+document
+document's
+documentaries
+documentary
+documentary's
+documentation
+documentation's
+documentations
+documented
+documenter
+documenters
+documenting
+documents
+dodge
+dodged
+dodger
+dodgers
+dodges
+dodging
+doer
+doers
+does
+doesn't
+dog
+dog's
+dogged
+doggedly
+doggedness
+dogging
+dogma
+dogma's
+dogmas
+dogmatism
+dogs
+doing
+doings
+dole
+doled
+doleful
+dolefully
+dolefulness
+doles
+doling
+doll
+doll's
+dollar
+dollars
+dollied
+dollies
+dolls
+dolly
+dolly's
+dollying
+dolphin
+dolphin's
+dolphins
+domain
+domain's
+domains
+dome
+domed
+domes
+domestic
+domestically
+domesticate
+domesticated
+domesticates
+domesticating
+domestication
+dominance
+dominant
+dominantly
+dominate
+dominated
+dominates
+dominating
+domination
+dominations
+dominative
+doming
+dominion
+dominions
+don
+don't
+donate
+donated
+donates
+donating
+donation
+donations
+donative
+done
+donkey
+donkey's
+donkeys
+dons
+doom
+doomed
+dooming
+dooms
+door
+door's
+doors
+doorstep
+doorstep's
+doorsteps
+doorway
+doorway's
+doorways
+dope
+doped
+doper
+dopers
+dopes
+doping
+dormant
+dormitories
+dormitory
+dormitory's
+dorsal
+dorsally
+dose
+dosed
+doses
+dosing
+dot
+dot's
+dote
+doted
+doter
+dotes
+doth
+doting
+dotingly
+dots
+dotted
+dotting
+double
+doubled
+doubleness
+doubler
+doublers
+doubles
+doublet
+doublet's
+doublets
+doubling
+doubly
+doubt
+doubtable
+doubted
+doubter
+doubters
+doubtful
+doubtfully
+doubtfulness
+doubting
+doubtingly
+doubtless
+doubtlessly
+doubtlessness
+doubts
+dough
+doughnut
+doughnut's
+doughnuts
+douse
+doused
+douser
+douses
+dousing
+dove
+dover
+doves
+down
+downcast
+downed
+downer
+downers
+downfall
+downfallen
+downier
+downing
+downplay
+downplayed
+downplaying
+downplays
+downright
+downrightly
+downrightness
+downs
+downstairs
+downstream
+downtown
+downtowner
+downtowns
+downward
+downwardly
+downwardness
+downwards
+downy
+doze
+dozed
+dozen
+dozens
+dozenth
+dozer
+dozes
+dozing
+drab
+drably
+drabness
+drabs
+draft
+draft's
+drafted
+drafter
+drafters
+drafting
+drafts
+draftsmen
+drag
+dragged
+dragging
+draggingly
+dragon
+dragon's
+dragons
+dragoon
+dragooned
+dragoons
+drags
+drain
+drainage
+drainages
+drained
+drainer
+drainers
+draining
+drains
+drake
+drama
+drama's
+dramas
+dramatic
+dramatically
+dramatics
+dramatist
+dramatist's
+dramatists
+drank
+drape
+draped
+draper
+draperies
+drapers
+drapery
+drapery's
+drapes
+draping
+drastic
+drastically
+draw
+drawback
+drawback's
+drawbacks
+drawbridge
+drawbridge's
+drawbridges
+drawer
+drawers
+drawing
+drawings
+drawl
+drawled
+drawler
+drawling
+drawlingly
+drawls
+drawly
+drawn
+drawnly
+drawnness
+draws
+dread
+dreaded
+dreadful
+dreadfully
+dreadfulness
+dreading
+dreads
+dream
+dreamed
+dreamer
+dreamers
+dreamier
+dreamily
+dreaminess
+dreaming
+dreamingly
+dreams
+dreamy
+drearier
+dreariness
+dreary
+dredge
+dredge's
+dredged
+dredger
+dredgers
+dredges
+dredging
+dregs
+drench
+drenched
+drencher
+drenches
+drenching
+dress
+dressed
+dresser
+dressers
+dresses
+dressing
+dressings
+dressmaker
+dressmaker's
+dressmakers
+drew
+dried
+drier
+drier's
+driers
+dries
+driest
+drift
+drifted
+drifter
+drifters
+drifting
+driftingly
+drifts
+drill
+drilled
+driller
+drilling
+drills
+drily
+drink
+drinkable
+drinker
+drinkers
+drinking
+drinks
+drip
+drip's
+drips
+drive
+driven
+drivenness
+driver
+driver's
+drivers
+drives
+driveway
+driveway's
+driveways
+driving
+drone
+drone's
+droner
+drones
+droning
+droningly
+drool
+drooled
+drooler
+drooling
+drools
+droop
+drooped
+drooping
+droopingly
+droops
+drop
+drop's
+dropped
+dropper
+dropper's
+droppers
+dropping
+dropping's
+droppings
+drops
+drought
+drought's
+droughts
+drove
+drover
+drovers
+droves
+drown
+drowned
+drowner
+drowning
+drownings
+drowns
+drowsier
+drowsiest
+drowsiness
+drowsy
+drudgery
+drug
+drug's
+druggist
+druggist's
+druggists
+drugs
+drum
+drum's
+drummed
+drummer
+drummer's
+drummers
+drumming
+drums
+drunk
+drunk's
+drunkard
+drunkard's
+drunkards
+drunken
+drunkenly
+drunkenness
+drunker
+drunkly
+drunks
+dry
+drying
+dryly
+dual
+dualities
+duality
+duality's
+dually
+duals
+dub
+dubious
+dubiously
+dubiousness
+dubs
+duchess
+duchess's
+duchesses
+duchies
+duchy
+duck
+ducked
+ducker
+ducking
+ducks
+dude
+due
+duel
+duels
+dueness
+dues
+dug
+duke
+duke's
+dukes
+dull
+dulled
+duller
+dullest
+dulling
+dullness
+dulls
+dully
+duly
+dumb
+dumbbell
+dumbbell's
+dumbbells
+dumber
+dumbest
+dumbly
+dumbness
+dummied
+dummies
+dummy
+dummy's
+dummying
+dump
+dumped
+dumper
+dumpers
+dumping
+dumps
+dunce
+dunce's
+dunces
+dune
+dune's
+dunes
+dungeon
+dungeon's
+dungeons
+duplicate
+duplicated
+duplicates
+duplicating
+duplication
+duplications
+duplicative
+duplicator
+duplicator's
+duplicators
+durabilities
+durability
+durable
+durableness
+durables
+durably
+duration
+duration's
+durations
+during
+dusk
+duskier
+duskiness
+dusky
+dust
+dusted
+duster
+dusters
+dustier
+dustiest
+dustiness
+dusting
+dusts
+dusty
+duties
+dutiful
+dutifully
+dutifulness
+duty
+duty's
+dwarf
+dwarfed
+dwarfness
+dwarfs
+dwell
+dwelled
+dweller
+dwellers
+dwelling
+dwellings
+dwells
+dwindle
+dwindled
+dwindles
+dwindling
+dye
+dyed
+dyeing
+dyer
+dyers
+dyes
+dying
+dynamic
+dynamically
+dynamics
+dynamite
+dynamited
+dynamiter
+dynamites
+dynamiting
+dynasties
+dynasty
+dynasty's
+each
+eager
+eagerly
+eagerness
+eagle
+eagle's
+eagles
+ear
+eared
+earing
+earl
+earl's
+earlier
+earliest
+earliness
+earls
+early
+earmark
+earmarked
+earmarking
+earmarkings
+earmarks
+earn
+earned
+earner
+earner's
+earners
+earnest
+earnestly
+earnestness
+earning
+earnings
+earns
+earring
+earring's
+earrings
+ears
+earshot
+earth
+earth's
+earthed
+earthen
+earthenware
+earthliness
+earthly
+earthquake
+earthquake's
+earthquakes
+earths
+earthworm
+earthworm's
+earthworms
+ease
+eased
+easement
+easement's
+easements
+easer
+eases
+easier
+easiest
+easily
+easiness
+easing
+east
+easter
+easterly
+eastern
+easterner
+easterners
+easting
+easts
+eastward
+eastwards
+easy
+eat
+eaten
+eater
+eaters
+eating
+eatings
+eats
+eaves
+eavesdrop
+eavesdropped
+eavesdropper
+eavesdropper's
+eavesdroppers
+eavesdropping
+eavesdrops
+ebb
+ebbed
+ebbing
+ebbs
+ebony
+eccentric
+eccentric's
+eccentricities
+eccentricity
+eccentrics
+ecclesiastical
+ecclesiastically
+echo
+echoed
+echoes
+echoing
+echos
+eclipse
+eclipsed
+eclipses
+eclipsing
+ecology
+economic
+economical
+economically
+economics
+economies
+economist
+economist's
+economists
+economy
+economy's
+ecstasy
+eddied
+eddies
+eddy
+eddy's
+eddying
+edge
+edged
+edger
+edges
+edging
+edible
+edibleness
+edibles
+edict
+edict's
+edicts
+edifice
+edifice's
+edifices
+edit
+edited
+editing
+edition
+edition's
+editions
+editor
+editor's
+editorial
+editorially
+editorials
+editors
+edits
+educate
+educated
+educatedly
+educatedness
+educates
+educating
+education
+education's
+educational
+educationally
+educations
+educative
+educator
+educator's
+educators
+eel
+eel's
+eels
+eerie
+eerier
+effect
+effected
+effecting
+effective
+effectively
+effectiveness
+effectives
+effector
+effector's
+effectors
+effects
+effectually
+effeminate
+efficacy
+efficiencies
+efficiency
+efficient
+efficiently
+effigy
+effort
+effort's
+effortless
+effortlessly
+effortlessness
+efforts
+egg
+egged
+egger
+egging
+eggs
+ego
+egos
+eigenvalue
+eigenvalue's
+eigenvalues
+eight
+eighteen
+eighteens
+eighteenth
+eighth
+eighth's
+eighthes
+eighties
+eightieth
+eights
+eighty
+either
+ejaculate
+ejaculated
+ejaculates
+ejaculating
+ejaculation
+ejaculations
+eject
+ejected
+ejecting
+ejective
+ejects
+eke
+eked
+ekes
+eking
+el
+elaborate
+elaborated
+elaborately
+elaborateness
+elaborates
+elaborating
+elaboration
+elaborations
+elaborative
+elaborators
+elapse
+elapsed
+elapses
+elapsing
+elastic
+elastically
+elasticities
+elasticity
+elastics
+elate
+elated
+elatedly
+elatedness
+elater
+elates
+elating
+elation
+elbow
+elbowed
+elbowing
+elbows
+elder
+elderliness
+elderly
+elders
+eldest
+elect
+elected
+electing
+election
+election's
+elections
+elective
+electively
+electiveness
+electives
+elector
+elector's
+electoral
+electorally
+electors
+electric
+electrical
+electrically
+electricalness
+electricities
+electricity
+electrics
+electrification
+electrified
+electrify
+electrifying
+electrocute
+electrocuted
+electrocutes
+electrocuting
+electrocution
+electrocutions
+electrode
+electrode's
+electrodes
+electrolyte
+electrolyte's
+electrolytes
+electrolytic
+electron
+electron's
+electronic
+electronically
+electronics
+electrons
+elects
+elegance
+elegances
+elegant
+elegantly
+element
+element's
+elemental
+elementally
+elementals
+elementariness
+elementary
+elements
+elephant
+elephant's
+elephants
+elevate
+elevated
+elevates
+elevating
+elevation
+elevations
+elevator
+elevator's
+elevators
+eleven
+elevens
+elevenses
+eleventh
+elf
+elicit
+elicited
+eliciting
+elicits
+eligibilities
+eligibility
+eligible
+eligibles
+eliminate
+eliminated
+eliminately
+eliminates
+eliminating
+elimination
+eliminations
+eliminative
+eliminator
+eliminators
+elk
+elk's
+elks
+ellipse
+ellipse's
+ellipses
+ellipsis
+ellipsoid
+ellipsoid's
+ellipsoidal
+ellipsoids
+elliptic
+elliptical
+elliptically
+elm
+elmer
+elms
+elongate
+elongated
+elongates
+elongating
+elongation
+eloquence
+eloquent
+eloquently
+els
+else
+else's
+elsewhere
+elucidate
+elucidated
+elucidates
+elucidating
+elucidation
+elucidative
+elude
+eluded
+eludes
+eluding
+elusive
+elusively
+elusiveness
+elves
+emaciated
+emacs
+emacs's
+email
+email's
+emanating
+emancipation
+embark
+embarked
+embarking
+embarks
+embarrass
+embarrassed
+embarrassedly
+embarrasses
+embarrassing
+embarrassingly
+embarrassment
+embassies
+embassy
+embassy's
+embed
+embedded
+embedding
+embeds
+embellish
+embellished
+embellisher
+embellishes
+embellishing
+embellishment
+embellishment's
+embellishments
+ember
+embers
+embezzle
+embezzled
+embezzler
+embezzler's
+embezzlers
+embezzles
+embezzling
+emblem
+emblems
+embodied
+embodier
+embodies
+embodiment
+embodiment's
+embodiments
+embody
+embodying
+embrace
+embraced
+embracer
+embraces
+embracing
+embracingly
+embracive
+embroider
+embroidered
+embroiderer
+embroideries
+embroiders
+embroidery
+embryo
+embryo's
+embryology
+embryos
+emerald
+emerald's
+emeralds
+emerge
+emerged
+emergence
+emergencies
+emergency
+emergency's
+emergent
+emerges
+emerging
+emeries
+emery
+emigrant
+emigrant's
+emigrants
+emigrate
+emigrated
+emigrates
+emigrating
+emigration
+eminence
+eminent
+eminently
+emit
+emits
+emitted
+emotion
+emotion's
+emotional
+emotionally
+emotions
+empathy
+emperor
+emperor's
+emperors
+emphases
+emphasis
+emphatic
+emphatically
+empire
+empire's
+empires
+empirical
+empirically
+empiricist
+empiricist's
+empiricists
+employ
+employable
+employed
+employee
+employee's
+employees
+employer
+employer's
+employers
+employing
+employment
+employment's
+employments
+employs
+empower
+empowered
+empowering
+empowers
+empress
+emptied
+emptier
+empties
+emptiest
+emptily
+emptiness
+empty
+emptying
+emulate
+emulated
+emulates
+emulating
+emulation
+emulations
+emulative
+emulatively
+emulator
+emulator's
+emulators
+enable
+enabled
+enabler
+enablers
+enables
+enabling
+enact
+enacted
+enacting
+enactment
+enactments
+enacts
+enamel
+enamels
+encamp
+encamped
+encamping
+encamps
+encapsulate
+encapsulated
+encapsulates
+encapsulating
+encapsulation
+enchant
+enchanted
+enchanter
+enchanting
+enchantingly
+enchantment
+enchants
+encipher
+enciphered
+encipherer
+enciphering
+enciphers
+encircle
+encircled
+encircles
+encircling
+enclose
+enclosed
+encloses
+enclosing
+enclosure
+enclosure's
+enclosures
+encode
+encoded
+encoder
+encoders
+encodes
+encoding
+encodings
+encompass
+encompassed
+encompasses
+encompassing
+encounter
+encountered
+encountering
+encounters
+encourage
+encouraged
+encouragement
+encouragements
+encourager
+encourages
+encouraging
+encouragingly
+encrypt
+encrypted
+encrypting
+encryption
+encryption's
+encryptions
+encrypts
+encumber
+encumbered
+encumbering
+encumbers
+encyclopedia
+encyclopedia's
+encyclopedias
+encyclopedic
+end
+endanger
+endangered
+endangering
+endangers
+endear
+endeared
+endearing
+endearingly
+endears
+ended
+endemic
+ender
+enders
+ending
+endings
+endive
+endless
+endlessly
+endlessness
+endorse
+endorsed
+endorsement
+endorsement's
+endorsements
+endorser
+endorses
+endorsing
+endow
+endowed
+endowing
+endowment
+endowment's
+endowments
+endows
+ends
+endurable
+endurably
+endurance
+endure
+endured
+endures
+enduring
+enduringly
+enduringness
+enema
+enema's
+enemas
+enemies
+enemy
+enemy's
+energetic
+energetics
+energies
+energy
+enforce
+enforced
+enforcedly
+enforcement
+enforcer
+enforcers
+enforces
+enforcing
+enfranchise
+enfranchised
+enfranchisement
+enfranchiser
+enfranchises
+enfranchising
+engage
+engaged
+engagement
+engagement's
+engagements
+engages
+engaging
+engagingly
+engender
+engendered
+engendering
+engenders
+engine
+engine's
+engined
+engineer
+engineer's
+engineered
+engineering
+engineeringly
+engineerings
+engineers
+engines
+engining
+england
+englander
+englanders
+engrave
+engraved
+engraver
+engravers
+engraves
+engraving
+engravings
+engross
+engrossed
+engrossedly
+engrosser
+engrossing
+engrossingly
+enhance
+enhanced
+enhancement
+enhancement's
+enhancements
+enhances
+enhancing
+enigmatic
+enjoin
+enjoined
+enjoining
+enjoins
+enjoy
+enjoyable
+enjoyableness
+enjoyably
+enjoyed
+enjoying
+enjoyment
+enjoys
+enlarge
+enlarged
+enlargement
+enlargement's
+enlargements
+enlarger
+enlargers
+enlarges
+enlarging
+enlighten
+enlightened
+enlightening
+enlightenment
+enlightens
+enlist
+enlisted
+enlister
+enlisting
+enlistment
+enlistments
+enlists
+enliven
+enlivened
+enlivening
+enlivens
+enmities
+enmity
+ennoble
+ennobled
+ennobler
+ennobles
+ennobling
+ennui
+enormities
+enormity
+enormous
+enormously
+enormousness
+enough
+enqueue
+enqueued
+enqueues
+enquire
+enquired
+enquirer
+enquirers
+enquires
+enquiring
+enrage
+enraged
+enrages
+enraging
+enrich
+enriched
+enricher
+enriches
+enriching
+enrolled
+enrolling
+ensemble
+ensemble's
+ensembles
+ensign
+ensign's
+ensigns
+enslave
+enslaved
+enslaver
+enslavers
+enslaves
+enslaving
+ensnare
+ensnared
+ensnares
+ensnaring
+ensue
+ensued
+ensues
+ensuing
+ensure
+ensured
+ensurer
+ensurers
+ensures
+ensuring
+entail
+entailed
+entailer
+entailing
+entails
+entangle
+entangled
+entangler
+entangles
+entangling
+enter
+entered
+enterer
+entering
+enterprise
+enterpriser
+enterprises
+enterprising
+enterprisingly
+enters
+entertain
+entertained
+entertainer
+entertainers
+entertaining
+entertainingly
+entertainment
+entertainment's
+entertainments
+entertains
+enthusiasm
+enthusiasms
+enthusiast
+enthusiast's
+enthusiastic
+enthusiastically
+enthusiasts
+entice
+enticed
+enticer
+enticers
+entices
+enticing
+entire
+entirely
+entireties
+entirety
+entities
+entitle
+entitled
+entitles
+entitling
+entity
+entity's
+entrance
+entranced
+entrances
+entrancing
+entreat
+entreated
+entreaties
+entreating
+entreatingly
+entreats
+entreaty
+entrench
+entrenched
+entrenches
+entrenching
+entrepreneur
+entrepreneur's
+entrepreneurs
+entries
+entropies
+entropy
+entrust
+entrusted
+entrusting
+entrusts
+entry
+entry's
+enumerable
+enumerate
+enumerated
+enumerates
+enumerating
+enumeration
+enumerations
+enumerative
+enumerator
+enumerator's
+enumerators
+enunciation
+envelop
+envelope
+enveloped
+enveloper
+envelopes
+enveloping
+envelops
+enviably
+envied
+envier
+envies
+envious
+enviously
+enviousness
+environ
+environed
+environing
+environment
+environment's
+environmental
+environmentally
+environments
+environs
+envisage
+envisaged
+envisages
+envisaging
+envision
+envisioned
+envisioning
+envisions
+envoy
+envoy's
+envoys
+envy
+envying
+envyingly
+epaulet
+epaulet's
+epaulets
+ephemeral
+ephemerally
+ephemerals
+epic
+epic's
+epics
+epidemic
+epidemic's
+epidemics
+episcopal
+episcopally
+episode
+episode's
+episodes
+episodic
+epistemological
+epistemologically
+epistemology
+epistle
+epistle's
+epistler
+epistles
+epitaph
+epitaphed
+epitaphing
+epitaphs
+epitaxial
+epitaxially
+epithet
+epithet's
+epithets
+epoch
+epochs
+epsilon
+epsilons
+equal
+equalities
+equality
+equality's
+equally
+equals
+equate
+equated
+equates
+equating
+equation
+equations
+equator
+equator's
+equatorial
+equators
+equilibrium
+equilibriums
+equip
+equipment
+equipments
+equipped
+equipping
+equips
+equitable
+equitableness
+equitably
+equities
+equity
+equivalence
+equivalenced
+equivalences
+equivalencing
+equivalent
+equivalently
+equivalents
+era
+era's
+eradicate
+eradicated
+eradicates
+eradicating
+eradication
+eradicative
+eras
+erasable
+erase
+erased
+eraser
+erasers
+erases
+erasing
+erasion
+erasure
+ere
+erect
+erected
+erecting
+erection
+erection's
+erections
+erectly
+erectness
+erector
+erector's
+erectors
+erects
+ergo
+ermine
+ermine's
+ermined
+ermines
+err
+errand
+errands
+erratic
+erred
+erring
+erringly
+erroneous
+erroneously
+erroneousness
+error
+error's
+errors
+errs
+eruption
+eruptions
+escalate
+escalated
+escalates
+escalating
+escalation
+escapable
+escapade
+escapade's
+escapades
+escape
+escaped
+escapee
+escapee's
+escapees
+escaper
+escapes
+escaping
+eschew
+eschewed
+eschewing
+eschews
+escort
+escorted
+escorting
+escorts
+esoteric
+especial
+especially
+espied
+espies
+espionage
+espouse
+espoused
+espouser
+espouses
+espousing
+esprit
+esprits
+espy
+espying
+esquire
+esquires
+essay
+essayed
+essayer
+essays
+essence
+essence's
+essences
+essential
+essentially
+essentialness
+essentials
+establish
+established
+establisher
+establishes
+establishing
+establishment
+establishment's
+establishments
+estate
+estate's
+estates
+esteem
+esteemed
+esteeming
+esteems
+estimate
+estimated
+estimates
+estimating
+estimation
+estimations
+estimative
+etc
+eternal
+eternally
+eternalness
+eternities
+eternity
+ethereal
+ethereally
+etherealness
+ethic
+ethical
+ethically
+ethicalness
+ethics
+ethnic
+etiquette
+eunuch
+eunuchs
+euphemism
+euphemism's
+euphemisms
+euphoria
+evacuate
+evacuated
+evacuates
+evacuating
+evacuation
+evacuations
+evacuative
+evade
+evaded
+evader
+evades
+evading
+evaluate
+evaluated
+evaluates
+evaluating
+evaluation
+evaluations
+evaluative
+evaluator
+evaluator's
+evaluators
+evaporate
+evaporated
+evaporates
+evaporating
+evaporation
+evaporations
+evaporative
+evaporatively
+eve
+even
+evened
+evener
+evenhanded
+evenhandedly
+evenhandedness
+evening
+evening's
+evenings
+evenly
+evenness
+evens
+event
+event's
+eventful
+eventfully
+eventfulness
+events
+eventual
+eventualities
+eventuality
+eventually
+ever
+everest
+evergreen
+everlasting
+everlastingly
+everlastingness
+evermore
+every
+everybody
+everybody's
+everyday
+everydayness
+everyone
+everyone's
+everyones
+everything
+everywhere
+eves
+evict
+evicted
+evicting
+eviction
+eviction's
+evictions
+evicts
+evidence
+evidenced
+evidences
+evidencing
+evident
+evidently
+evil
+evilly
+evilness
+evils
+evince
+evinced
+evinces
+evincing
+evoke
+evoked
+evokes
+evoking
+evolute
+evolute's
+evolutes
+evolution
+evolution's
+evolutionary
+evolutions
+evolve
+evolved
+evolves
+evolving
+ewe
+ewe's
+ewer
+ewes
+exacerbate
+exacerbated
+exacerbates
+exacerbating
+exacerbation
+exacerbations
+exact
+exacted
+exacter
+exacting
+exactingly
+exactingness
+exaction
+exaction's
+exactions
+exactitude
+exactly
+exactness
+exacts
+exaggerate
+exaggerated
+exaggeratedly
+exaggeratedness
+exaggerates
+exaggerating
+exaggeration
+exaggerations
+exaggerative
+exaggeratively
+exalt
+exalted
+exaltedly
+exalter
+exalters
+exalting
+exalts
+exam
+exam's
+examen
+examination
+examination's
+examinations
+examine
+examined
+examiner
+examiners
+examines
+examining
+example
+example's
+exampled
+examples
+exampling
+exams
+exasperate
+exasperated
+exasperatedly
+exasperates
+exasperating
+exasperatingly
+exasperation
+exasperations
+excavate
+excavated
+excavates
+excavating
+excavation
+excavations
+exceed
+exceeded
+exceeder
+exceeding
+exceedingly
+exceeds
+excel
+excelled
+excellence
+excellences
+excellency
+excellent
+excellently
+excelling
+excels
+except
+excepted
+excepting
+exception
+exception's
+exceptional
+exceptionally
+exceptionalness
+exceptions
+exceptive
+excepts
+excerpt
+excerpted
+excerpter
+excerpts
+excess
+excesses
+excessive
+excessively
+excessiveness
+exchange
+exchangeable
+exchanged
+exchanger
+exchangers
+exchanges
+exchanging
+exchequer
+exchequer's
+exchequers
+excise
+excised
+excises
+excising
+excision
+excisions
+excitable
+excitableness
+excitation
+excitation's
+excitations
+excite
+excited
+excitedly
+excitement
+exciter
+excites
+exciting
+excitingly
+exclaim
+exclaimed
+exclaimer
+exclaimers
+exclaiming
+exclaims
+exclamation
+exclamation's
+exclamations
+exclude
+excluded
+excluder
+excludes
+excluding
+exclusion
+exclusioner
+exclusioners
+exclusions
+exclusive
+exclusively
+exclusiveness
+exclusivity
+excommunicate
+excommunicated
+excommunicates
+excommunicating
+excommunication
+excommunicative
+excrete
+excreted
+excreter
+excretes
+excreting
+excretion
+excretions
+excruciatingly
+excursion
+excursion's
+excursions
+excusable
+excusableness
+excusably
+excuse
+excused
+excuser
+excuses
+excusing
+executable
+executable's
+executables
+execute
+executed
+executer
+executers
+executes
+executing
+execution
+executional
+executioner
+executions
+executive
+executive's
+executives
+executor
+executor's
+executors
+exemplar
+exemplariness
+exemplars
+exemplary
+exemplification
+exemplified
+exemplifier
+exemplifiers
+exemplifies
+exemplify
+exemplifying
+exempt
+exempted
+exempting
+exempts
+exercise
+exercised
+exerciser
+exercisers
+exercises
+exercising
+exert
+exerted
+exerting
+exertion
+exertion's
+exertions
+exerts
+exhale
+exhaled
+exhales
+exhaling
+exhaust
+exhausted
+exhaustedly
+exhauster
+exhaustible
+exhausting
+exhaustingly
+exhaustion
+exhaustive
+exhaustively
+exhaustiveness
+exhausts
+exhibit
+exhibited
+exhibiting
+exhibition
+exhibition's
+exhibitioner
+exhibitions
+exhibitive
+exhibitor
+exhibitor's
+exhibitors
+exhibits
+exhortation
+exhortation's
+exhortations
+exigencies
+exigency
+exile
+exiled
+exiles
+exiling
+exist
+existed
+existence
+existences
+existent
+existential
+existentialism
+existentialist
+existentialist's
+existentialists
+existentially
+existing
+exists
+exit
+exited
+exiting
+exits
+exorbitant
+exorbitantly
+exoskeletons
+exotic
+exoticness
+expand
+expandable
+expanded
+expander
+expander's
+expanders
+expanding
+expands
+expanse
+expansed
+expanses
+expansing
+expansion
+expansionism
+expansions
+expansive
+expansively
+expansiveness
+expect
+expectancies
+expectancy
+expectant
+expectantly
+expectation
+expectation's
+expectations
+expected
+expectedly
+expectedness
+expecting
+expectingly
+expects
+expedient
+expediently
+expedite
+expedited
+expediter
+expedites
+expediting
+expedition
+expedition's
+expeditions
+expeditious
+expeditiously
+expeditiousness
+expel
+expelled
+expelling
+expels
+expend
+expendable
+expended
+expender
+expending
+expenditure
+expenditure's
+expenditures
+expends
+expense
+expensed
+expenses
+expensing
+expensive
+expensively
+expensiveness
+experience
+experienced
+experiences
+experiencing
+experiment
+experimental
+experimentally
+experimentation
+experimentation's
+experimentations
+experimented
+experimenter
+experimenters
+experimenting
+experiments
+expert
+expertise
+expertly
+expertness
+experts
+expiration
+expiration's
+expirations
+expire
+expired
+expires
+expiring
+explain
+explainable
+explained
+explainer
+explainers
+explaining
+explains
+explanation
+explanation's
+explanations
+explanatory
+explicit
+explicitly
+explicitness
+explode
+exploded
+exploder
+explodes
+exploding
+exploit
+exploitable
+exploitation
+exploitation's
+exploitations
+exploited
+exploiter
+exploiters
+exploiting
+exploitive
+exploits
+exploration
+exploration's
+explorations
+exploratory
+explore
+explored
+explorer
+explorers
+explores
+exploring
+explosion
+explosion's
+explosions
+explosive
+explosively
+explosiveness
+explosives
+exponent
+exponent's
+exponential
+exponentially
+exponentials
+exponentiate
+exponentiated
+exponentiates
+exponentiating
+exponentiation
+exponentiation's
+exponentiations
+exponents
+export
+exported
+exporter
+exporters
+exporting
+exports
+expose
+exposed
+exposer
+exposers
+exposes
+exposing
+exposition
+exposition's
+expositions
+expository
+exposure
+exposure's
+exposures
+expound
+expounded
+expounder
+expounding
+expounds
+express
+expressed
+expresser
+expresses
+expressibility
+expressible
+expressibly
+expressing
+expression
+expression's
+expressions
+expressive
+expressively
+expressiveness
+expressly
+expropriate
+expropriated
+expropriates
+expropriating
+expropriation
+expropriations
+expulsion
+expunge
+expunged
+expunger
+expunges
+expunging
+exquisite
+exquisitely
+exquisiteness
+extant
+extend
+extended
+extendedly
+extendedness
+extender
+extendible
+extendibles
+extending
+extends
+extensibility
+extensible
+extension
+extension's
+extensions
+extensive
+extensively
+extensiveness
+extent
+extent's
+extents
+extenuate
+extenuated
+extenuating
+extenuation
+exterior
+exterior's
+exteriorly
+exteriors
+exterminate
+exterminated
+exterminates
+exterminating
+extermination
+exterminations
+external
+externally
+externals
+extinct
+extinction
+extinctive
+extinguish
+extinguished
+extinguisher
+extinguishers
+extinguishes
+extinguishing
+extol
+extols
+extortion
+extortioner
+extortionist
+extortionist's
+extortionists
+extra
+extract
+extracted
+extracting
+extraction
+extraction's
+extractions
+extractive
+extractively
+extractor
+extractor's
+extractors
+extracts
+extracurricular
+extraneous
+extraneously
+extraneousness
+extraordinarily
+extraordinariness
+extraordinary
+extrapolate
+extrapolated
+extrapolates
+extrapolating
+extrapolation
+extrapolations
+extrapolative
+extras
+extravagance
+extravagant
+extravagantly
+extremal
+extreme
+extremed
+extremely
+extremeness
+extremer
+extremes
+extremest
+extremist
+extremist's
+extremists
+extremities
+extremity
+extremity's
+extrinsic
+exuberance
+exult
+exultation
+exulted
+exulting
+exultingly
+exults
+eye
+eyeball
+eyeballs
+eyebrow
+eyebrow's
+eyebrows
+eyed
+eyedness
+eyeglass
+eyeglasses
+eyeing
+eyelid
+eyelid's
+eyelids
+eyepiece
+eyepiece's
+eyepieces
+eyer
+eyers
+eyes
+eyesight
+eyewitness
+eyewitness's
+eyewitnesses
+eying
+fable
+fabled
+fabler
+fables
+fabling
+fabric
+fabric's
+fabricate
+fabricated
+fabricates
+fabricating
+fabrication
+fabrications
+fabrics
+fabulous
+fabulously
+fabulousness
+facade
+facaded
+facades
+facading
+face
+faced
+faceless
+facelessness
+facer
+faces
+facet
+faceted
+faceting
+facets
+facial
+facially
+facile
+facilely
+facileness
+facilitate
+facilitated
+facilitates
+facilitating
+facilitation
+facilitative
+facilities
+facility
+facility's
+facing
+facings
+facsimile
+facsimile's
+facsimiled
+facsimiles
+facsimiling
+fact
+fact's
+faction
+faction's
+factions
+factor
+factored
+factorial
+factories
+factoring
+factorings
+factors
+factory
+factory's
+facts
+factual
+factually
+factualness
+faculties
+faculty
+faculty's
+fade
+faded
+fadedly
+fader
+faders
+fades
+fading
+fag
+fags
+fail
+failed
+failing
+failingly
+failings
+fails
+failure
+failure's
+failures
+fain
+faint
+fainted
+fainter
+faintest
+fainting
+faintly
+faintness
+faints
+fair
+faired
+fairer
+fairest
+fairies
+fairing
+fairly
+fairness
+fairs
+fairy
+fairy's
+fairyland
+faith
+faithful
+faithfully
+faithfulness
+faithfuls
+faithless
+faithlessly
+faithlessness
+faiths
+fake
+faked
+faker
+fakes
+faking
+falcon
+falconer
+falcons
+fall
+fallacies
+fallacious
+fallaciously
+fallaciousness
+fallacy
+fallacy's
+fallen
+faller
+fallibility
+fallible
+falling
+falls
+false
+falsehood
+falsehood's
+falsehoods
+falsely
+falseness
+falser
+falsest
+falsification
+falsified
+falsifier
+falsifies
+falsify
+falsifying
+falsity
+falter
+faltered
+falterer
+faltering
+falteringly
+falters
+fame
+famed
+fames
+familiar
+familiarities
+familiarity
+familiarly
+familiarness
+familiars
+families
+family
+family's
+famine
+famine's
+famines
+faming
+famish
+famished
+famishes
+famishing
+famous
+famously
+famousness
+fan
+fan's
+fanatic
+fanatic's
+fanatically
+fanatics
+fancied
+fancier
+fancier's
+fanciers
+fancies
+fanciest
+fanciful
+fancifully
+fancifulness
+fancily
+fanciness
+fancy
+fancying
+fang
+fang's
+fanged
+fangs
+fanned
+fanning
+fans
+fantasied
+fantasies
+fantastic
+fantasy
+fantasy's
+far
+faraway
+farce
+farce's
+farces
+farcing
+fare
+fared
+farer
+fares
+farewell
+farewells
+faring
+farm
+farmed
+farmer
+farmer's
+farmers
+farmhouse
+farmhouse's
+farmhouses
+farming
+farms
+farmyard
+farmyard's
+farmyards
+farther
+farthest
+farthing
+fascinate
+fascinated
+fascinates
+fascinating
+fascinatingly
+fascination
+fascinations
+fashion
+fashionable
+fashionableness
+fashionably
+fashioned
+fashioner
+fashioners
+fashioning
+fashions
+fast
+fasted
+fasten
+fastened
+fastener
+fasteners
+fastening
+fastenings
+fastens
+faster
+fastest
+fasting
+fastness
+fasts
+fat
+fatal
+fatalities
+fatality
+fatality's
+fatally
+fatals
+fate
+fated
+fates
+father
+father's
+fathered
+fathering
+fatherland
+fatherliness
+fatherly
+fathers
+fathom
+fathomed
+fathoming
+fathoms
+fatigue
+fatigued
+fatigues
+fatiguing
+fatiguingly
+fating
+fatly
+fatness
+fats
+fatten
+fattened
+fattener
+fatteners
+fattening
+fattens
+fatter
+fattest
+fault
+faulted
+faultier
+faultiness
+faulting
+faultless
+faultlessly
+faultlessness
+faults
+faulty
+fawn
+fawned
+fawner
+fawning
+fawningly
+fawns
+fear
+feared
+fearer
+fearful
+fearfully
+fearfulness
+fearing
+fearless
+fearlessly
+fearlessness
+fears
+feasibility
+feasible
+feasibleness
+feast
+feasted
+feaster
+feasting
+feasts
+feat
+feat's
+feather
+feathered
+featherer
+featherers
+feathering
+feathers
+feating
+featly
+feats
+feature
+featured
+featureless
+features
+featuring
+fed
+federal
+federally
+federals
+federation
+feds
+fee
+feeble
+feebleness
+feebler
+feeblest
+feebly
+feed
+feedback
+feedbacks
+feeder
+feeders
+feeding
+feedings
+feeds
+feel
+feeler
+feelers
+feeling
+feelingly
+feelingness
+feelings
+feels
+fees
+feet
+feign
+feigned
+feigner
+feigning
+feigns
+felicities
+felicity
+fell
+felled
+feller
+fellers
+felling
+fellness
+fellow
+fellow's
+fellowly
+fellows
+fellowship
+fellowship's
+fellowships
+fells
+felt
+felted
+felting
+felts
+female
+female's
+femaleness
+females
+feminine
+femininely
+feminineness
+femininity
+feminist
+feminist's
+feminists
+femur
+femur's
+femurs
+fen
+fence
+fenced
+fencer
+fencers
+fences
+fencing
+ferment
+fermentation
+fermentation's
+fermentations
+fermented
+fermenter
+fermenting
+ferments
+fern
+fern's
+ferns
+ferocious
+ferociously
+ferociousness
+ferocity
+ferried
+ferries
+ferrite
+ferry
+ferrying
+fertile
+fertilely
+fertileness
+fertilities
+fertility
+fervent
+fervently
+festival
+festival's
+festivals
+festive
+festively
+festiveness
+festivities
+festivity
+fetch
+fetched
+fetcher
+fetches
+fetching
+fetchingly
+fetter
+fettered
+fettering
+fetters
+feud
+feud's
+feudal
+feudalism
+feudally
+feuds
+fever
+fevered
+fevering
+feverish
+feverishly
+feverishness
+fevers
+few
+fewer
+fewest
+fewness
+fews
+fibrous
+fibrously
+fibrousness
+fickle
+fickleness
+fiction
+fiction's
+fictional
+fictionally
+fictions
+fictitious
+fictitiously
+fictitiousness
+fiddle
+fiddled
+fiddler
+fiddles
+fiddling
+fidelity
+field
+fielded
+fielder
+fielders
+fielding
+fields
+fiend
+fiends
+fierce
+fiercely
+fierceness
+fiercer
+fiercest
+fieriness
+fiery
+fife
+fifteen
+fifteens
+fifteenth
+fifth
+fifthly
+fifties
+fiftieth
+fifty
+fig
+fig's
+fight
+fighter
+fighters
+fighting
+fights
+figs
+figurative
+figuratively
+figurativeness
+figure
+figured
+figurer
+figurers
+figures
+figuring
+figurings
+filament
+filament's
+filaments
+file
+file's
+filed
+filename
+filename's
+filenames
+filer
+filers
+files
+filial
+filially
+filing
+filings
+fill
+fillable
+filled
+filler
+fillers
+filling
+fillings
+fills
+film
+filmed
+filming
+films
+filter
+filter's
+filtered
+filterer
+filtering
+filters
+filth
+filthier
+filthiest
+filthiness
+filthy
+filtration
+filtration's
+fin
+fin's
+final
+finality
+finally
+finals
+finance
+financed
+finances
+financial
+financially
+financier
+financier's
+financiers
+financing
+find
+finder
+finders
+finding
+findings
+finds
+fine
+fined
+finely
+fineness
+finer
+fines
+finest
+finger
+fingered
+fingerer
+fingering
+fingerings
+fingers
+fining
+finish
+finished
+finisher
+finishers
+finishes
+finishing
+finishings
+finite
+finitely
+finiteness
+finites
+fins
+fir
+fire
+firearm
+firearm's
+firearms
+fired
+fireflies
+firefly
+firefly's
+firelight
+firelighting
+fireman
+fireplace
+fireplace's
+fireplaces
+firer
+firers
+fires
+fireside
+firewood
+fireworks
+firing
+firings
+firm
+firm's
+firmament
+firmed
+firmer
+firmest
+firming
+firmly
+firmness
+firms
+firmware
+firmwares
+first
+firsthand
+firstly
+firsts
+firth
+fiscal
+fiscally
+fiscals
+fish
+fished
+fisher
+fisheries
+fisherman
+fisherman's
+fishermen
+fishermen's
+fishers
+fishery
+fishes
+fishing
+fissure
+fissured
+fissures
+fissuring
+fist
+fisted
+fists
+fit
+fitful
+fitfully
+fitfulness
+fitly
+fitness
+fits
+fitted
+fitter
+fitter's
+fitters
+fitting
+fittingly
+fittingness
+fittings
+five
+fiver
+fives
+fix
+fixate
+fixated
+fixates
+fixating
+fixation
+fixations
+fixative
+fixed
+fixedly
+fixedness
+fixer
+fixers
+fixes
+fixing
+fixings
+fixture
+fixture's
+fixtures
+flab
+flabbier
+flabbiness
+flabby
+flag
+flag's
+flagged
+flagging
+flaggingly
+flagrant
+flagrantly
+flags
+flagship
+flagship's
+flagships
+flake
+flaked
+flaker
+flakes
+flaking
+flame
+flamed
+flamer
+flamers
+flames
+flaming
+flamingly
+flammable
+flammables
+flank
+flanked
+flanker
+flankers
+flanking
+flanks
+flannel
+flannel's
+flannels
+flap
+flap's
+flapping
+flaps
+flare
+flared
+flares
+flaring
+flaringly
+flash
+flashed
+flasher
+flashers
+flashes
+flashing
+flashlight
+flashlight's
+flashlights
+flask
+flat
+flatly
+flatness
+flatnesses
+flats
+flatten
+flattened
+flattener
+flattening
+flattens
+flatter
+flattered
+flatterer
+flattering
+flatteringly
+flatters
+flattery
+flattest
+flaunt
+flaunted
+flaunting
+flauntingly
+flaunts
+flaw
+flawed
+flawing
+flawless
+flawlessly
+flawlessness
+flaws
+flax
+flaxen
+flea
+flea's
+fleas
+fled
+fledged
+fledgling
+fledgling's
+fledglings
+flee
+fleece
+fleece's
+fleeced
+fleeces
+fleecier
+fleecy
+fleeing
+fleer
+flees
+fleet
+fleetest
+fleeting
+fleetingly
+fleetingness
+fleetly
+fleetness
+fleets
+flesh
+fleshed
+flesher
+fleshes
+fleshier
+fleshiness
+fleshing
+fleshings
+fleshly
+fleshy
+flew
+flews
+flexibilities
+flexibility
+flexible
+flexibly
+flick
+flicked
+flicker
+flickered
+flickering
+flickeringly
+flicking
+flicks
+flier
+fliers
+flies
+flight
+flight's
+flights
+flinch
+flinched
+flincher
+flinches
+flinching
+fling
+fling's
+flinger
+flinging
+flings
+flint
+flints
+flip
+flips
+flirt
+flirted
+flirter
+flirting
+flirts
+flit
+flits
+float
+floated
+floater
+floaters
+floating
+floats
+flock
+flocked
+flocking
+flocks
+flood
+flooded
+flooder
+flooding
+floods
+floor
+floored
+floorer
+flooring
+floorings
+floors
+flop
+flop's
+floppier
+floppies
+floppily
+floppiness
+floppy
+floppy's
+flops
+flora
+florin
+floss
+flossed
+flosses
+flossing
+flounder
+floundered
+floundering
+flounders
+flour
+floured
+flourish
+flourished
+flourisher
+flourishes
+flourishing
+flourishingly
+flours
+flow
+flowchart
+flowcharting
+flowcharts
+flowed
+flower
+flowered
+flowerer
+floweriness
+flowering
+flowers
+flowery
+flowing
+flowingly
+flown
+flows
+fluctuate
+fluctuated
+fluctuates
+fluctuating
+fluctuation
+fluctuations
+fluent
+fluently
+fluffier
+fluffiest
+fluffiness
+fluffy
+fluid
+fluidity
+fluidly
+fluidness
+fluids
+flung
+flunk
+flunked
+flunker
+flunking
+flunks
+fluorescence
+flurried
+flurries
+flurry
+flurrying
+flush
+flushed
+flushes
+flushing
+flushness
+flute
+flute's
+fluted
+fluter
+flutes
+fluting
+flutter
+fluttered
+flutterer
+fluttering
+flutters
+fly
+flyable
+flyer
+flyer's
+flyers
+flying
+foam
+foamed
+foamer
+foaming
+foams
+focal
+focally
+foci
+focus
+focusable
+focused
+focuser
+focuses
+focusing
+fodder
+foe
+foe's
+foes
+fog
+fog's
+fogged
+foggier
+foggiest
+foggily
+fogginess
+fogging
+foggy
+fogs
+foil
+foiled
+foiling
+foils
+fold
+folded
+folder
+folders
+folding
+foldings
+folds
+foliage
+foliaged
+foliages
+folk
+folk's
+folklore
+folks
+follies
+follow
+followed
+follower
+followers
+following
+followings
+follows
+folly
+fond
+fonder
+fondest
+fondle
+fondled
+fondler
+fondles
+fondling
+fondly
+fondness
+fonds
+font
+font's
+fonts
+food
+food's
+foods
+foodstuff
+foodstuff's
+foodstuffs
+fool
+fooled
+fooling
+foolish
+foolishly
+foolishness
+foolproof
+fools
+foot
+football
+football's
+footballed
+footballer
+footballers
+footballs
+footed
+footer
+footers
+foothold
+footholds
+footing
+footings
+footman
+footnote
+footnote's
+footnotes
+footprint
+footprint's
+footprints
+foots
+footstep
+footsteps
+for
+forage
+foraged
+forager
+forages
+foraging
+foray
+foray's
+forayer
+forays
+forbade
+forbear
+forbear's
+forbearance
+forbearer
+forbearing
+forbears
+forbid
+forbidden
+forbidding
+forbiddingly
+forbiddingness
+forbids
+force
+force's
+forced
+forcedly
+forcefield
+forcefield's
+forcefields
+forceful
+forcefully
+forcefulness
+forcer
+forces
+forcible
+forcibleness
+forcibly
+forcing
+ford
+fords
+fore
+forearm
+forearm's
+forearmed
+forearms
+foreboding
+forebodingly
+forebodingness
+forebodings
+forecast
+forecasted
+forecaster
+forecasters
+forecasting
+forecastle
+forecastles
+forecasts
+forefather
+forefather's
+forefathers
+forefinger
+forefinger's
+forefingers
+forego
+foregoer
+foregoes
+foregoing
+foregone
+foreground
+foregrounds
+forehead
+forehead's
+foreheads
+foreign
+foreigner
+foreigners
+foreignly
+foreignness
+foreigns
+foreman
+foremost
+forenoon
+foresee
+foreseeable
+foreseen
+foreseer
+foresees
+foresight
+foresighted
+foresightedly
+foresightedness
+forest
+forestall
+forestalled
+forestaller
+forestalling
+forestallment
+forestalls
+forested
+forester
+foresters
+forests
+foretell
+foreteller
+foretelling
+foretells
+forethought
+forethought's
+foretold
+forever
+foreverness
+forewarn
+forewarned
+forewarner
+forewarning
+forewarnings
+forewarns
+forfeit
+forfeited
+forfeiter
+forfeiters
+forfeiting
+forfeits
+forgave
+forge
+forged
+forger
+forgeries
+forgers
+forgery
+forgery's
+forges
+forget
+forgetful
+forgetfully
+forgetfulness
+forgetive
+forgets
+forgettable
+forgettably
+forgetting
+forging
+forgivable
+forgivably
+forgive
+forgiven
+forgiveness
+forgiver
+forgives
+forgiving
+forgivingly
+forgivingness
+forgot
+forgotten
+fork
+forked
+forker
+forking
+forks
+forlorn
+forlornly
+forlornness
+form
+formal
+formalism
+formalism's
+formalisms
+formalities
+formality
+formally
+formalness
+formals
+formant
+formants
+format
+formated
+formating
+formation
+formation's
+formations
+formative
+formatively
+formativeness
+formats
+formatted
+formatter
+formatter's
+formatters
+formatting
+formed
+former
+formerly
+formers
+formidable
+formidableness
+forming
+forms
+formula
+formula's
+formulae
+formulas
+formulate
+formulated
+formulates
+formulating
+formulation
+formulations
+formulator
+formulator's
+formulators
+fornication
+forsake
+forsaken
+forsakes
+forsaking
+fort
+fort's
+forte
+fortes
+forth
+forthcoming
+forthwith
+fortier
+forties
+fortieth
+fortification
+fortifications
+fortified
+fortifier
+fortifies
+fortify
+fortifying
+fortitude
+fortnight
+fortnightly
+fortress
+fortress's
+fortresses
+forts
+fortuitous
+fortuitously
+fortuitousness
+fortunate
+fortunately
+fortunateness
+fortunates
+fortune
+fortune's
+fortuned
+fortunes
+fortuning
+forty
+forum
+forum's
+forums
+forward
+forwarded
+forwarder
+forwarders
+forwarding
+forwardly
+forwardness
+forwards
+fossil
+fossils
+foster
+fostered
+fosterer
+fostering
+fosters
+fought
+foul
+fouled
+fouler
+foulest
+fouling
+foully
+foulness
+fouls
+found
+foundation
+foundation's
+foundations
+founded
+founder
+foundered
+foundering
+founders
+founding
+foundries
+foundry
+foundry's
+founds
+fount
+fount's
+fountain
+fountain's
+fountains
+founts
+four
+fours
+fourscore
+fourteen
+fourteener
+fourteens
+fourteenth
+fourth
+fourthly
+fowl
+fowler
+fowling
+fowls
+fox
+fox's
+foxed
+foxes
+foxing
+fractal
+fractal's
+fractals
+fraction
+fraction's
+fractional
+fractionally
+fractioned
+fractioning
+fractions
+fracture
+fractured
+fractures
+fracturing
+fragile
+fragilely
+fragment
+fragmentariness
+fragmentary
+fragmented
+fragmenting
+fragments
+fragrance
+fragrance's
+fragrances
+fragrant
+fragrantly
+frail
+frailer
+frailest
+frailly
+frailness
+frailties
+frailty
+frame
+frame's
+framed
+framer
+framers
+frames
+framework
+framework's
+frameworks
+framing
+framings
+franc
+franchise
+franchise's
+franchised
+franchiser
+franchises
+franchising
+francs
+frank
+franked
+franker
+frankest
+franking
+frankly
+frankness
+franks
+frantic
+frantically
+franticly
+franticness
+fraternal
+fraternally
+fraternities
+fraternity
+fraternity's
+fraud
+fraud's
+frauds
+fraudulently
+fraught
+fraughted
+fraughting
+fraughts
+fray
+frayed
+fraying
+frays
+freak
+freak's
+freaks
+freckle
+freckled
+freckles
+freckling
+free
+freed
+freedom
+freedom's
+freedoms
+freeing
+freeings
+freely
+freeman
+freeness
+freer
+frees
+freest
+freeway
+freeway's
+freeways
+freeze
+freezer
+freezers
+freezes
+freezing
+freight
+freighted
+freighter
+freighters
+freighting
+freights
+frenzied
+frenziedly
+frenzies
+frenzy
+frenzying
+frequencies
+frequency
+frequent
+frequented
+frequenter
+frequenters
+frequenting
+frequently
+frequentness
+frequents
+fresh
+freshen
+freshened
+freshener
+fresheners
+freshening
+freshens
+fresher
+freshers
+freshest
+freshly
+freshman
+freshmen
+freshness
+fret
+fretful
+fretfully
+fretfulness
+frets
+friar
+friar's
+friarly
+friars
+frication
+fricative
+fricatives
+friction
+friction's
+frictionless
+frictionlessly
+frictions
+fried
+friend
+friend's
+friendless
+friendlessness
+friendlier
+friendlies
+friendliest
+friendliness
+friendly
+friends
+friendship
+friendship's
+friendships
+frier
+fries
+frieze
+frieze's
+friezes
+frigate
+frigate's
+frigates
+fright
+frighten
+frightened
+frightening
+frighteningly
+frightens
+frightful
+frightfully
+frightfulness
+frill
+frill's
+frilled
+frills
+fringe
+fringed
+fringes
+fringing
+frisk
+frisked
+frisker
+frisking
+frisks
+frivolous
+frivolously
+frivolousness
+frock
+frock's
+frocked
+frocking
+frocks
+frog
+frog's
+frogs
+frolic
+frolics
+from
+front
+fronted
+frontier
+frontier's
+frontiers
+fronting
+fronts
+frost
+frosted
+frostier
+frostiness
+frosting
+frosts
+frosty
+froth
+frothing
+frown
+frowned
+frowner
+frowning
+frowningly
+frowns
+froze
+frozen
+frozenly
+frozenness
+frugal
+frugally
+fruit
+fruit's
+fruited
+fruiter
+fruiterer
+fruitful
+fruitfully
+fruitfulness
+fruition
+fruitless
+fruitlessly
+fruitlessness
+fruits
+frustrate
+frustrated
+frustrater
+frustrates
+frustrating
+frustratingly
+frustration
+frustrations
+fry
+frying
+fuel
+fuels
+fugitive
+fugitive's
+fugitively
+fugitiveness
+fugitives
+fulfilled
+fulfiller
+fulfilling
+full
+fuller
+fullest
+fullness
+fullword
+fullword's
+fullwords
+fully
+fumble
+fumbled
+fumbler
+fumbles
+fumbling
+fumblingly
+fume
+fumed
+fumes
+fuming
+fun
+function
+function's
+functional
+functionalities
+functionality
+functionally
+functionals
+functioned
+functioning
+functions
+functor
+functor's
+functors
+fund
+fundamental
+fundamentalist
+fundamentalist's
+fundamentalists
+fundamentally
+fundamentals
+funded
+funder
+funders
+funding
+funds
+funeral
+funeral's
+funerals
+fungus
+funguses
+funnel
+funnels
+funnier
+funnies
+funniest
+funnily
+funniness
+funny
+fur
+fur's
+furies
+furious
+furiouser
+furiously
+furiousness
+furnace
+furnace's
+furnaced
+furnaces
+furnacing
+furness
+furnish
+furnished
+furnisher
+furnishers
+furnishes
+furnishing
+furnishings
+furniture
+furrow
+furrowed
+furrowing
+furrows
+furs
+further
+furthered
+furtherer
+furtherest
+furthering
+furthermore
+furthers
+furtive
+furtively
+furtiveness
+fury
+fury's
+fuse
+fused
+fuses
+fusing
+fusion
+fusions
+fuss
+fusser
+fussing
+futile
+futilely
+futileness
+futility
+future
+future's
+futures
+fuzzier
+fuzziest
+fuzziness
+fuzzy
+gabardine
+gabardines
+gable
+gabled
+gabler
+gables
+gad
+gadget
+gadget's
+gadgets
+gag
+gaged
+gager
+gagged
+gagging
+gaging
+gags
+gaieties
+gaiety
+gaily
+gain
+gained
+gainer
+gainers
+gaining
+gainings
+gainly
+gains
+gait
+gaited
+gaiter
+gaiters
+gaits
+galaxies
+galaxy
+galaxy's
+gale
+gales
+gall
+gallant
+gallantly
+gallantry
+gallants
+galled
+galleried
+galleries
+gallery
+galley
+galley's
+galleys
+galling
+gallingly
+gallon
+gallon's
+gallons
+gallop
+galloped
+galloper
+gallopers
+galloping
+gallops
+gallows
+gallowses
+galls
+gamble
+gambled
+gambler
+gamblers
+gambles
+gambling
+game
+gamed
+gamely
+gameness
+games
+gaming
+gamma
+gammas
+gang
+gang's
+ganger
+ganglier
+gangly
+gangrene
+gangrened
+gangrenes
+gangrening
+gangs
+gangster
+gangster's
+gangsters
+gap
+gap's
+gape
+gaped
+gaper
+gapes
+gaping
+gapingly
+gaps
+garage
+garaged
+garages
+garaging
+garb
+garbage
+garbage's
+garbaged
+garbages
+garbaging
+garbed
+garble
+garbled
+garbler
+garbles
+garbling
+garden
+gardened
+gardener
+gardeners
+gardening
+gardens
+gargle
+gargled
+gargles
+gargling
+garland
+garlanded
+garlands
+garlic
+garlics
+garment
+garment's
+garmented
+garmenting
+garments
+garner
+garnered
+garnering
+garners
+garnish
+garnished
+garnishes
+garrison
+garrisoned
+garrisoning
+garrisons
+garter
+garter's
+gartered
+gartering
+garters
+gas
+gas's
+gaseous
+gaseously
+gaseousness
+gases
+gash
+gash's
+gashed
+gashes
+gashing
+gasoline
+gasolines
+gasp
+gasped
+gasper
+gaspers
+gasping
+gaspingly
+gasps
+gassed
+gasser
+gassers
+gassing
+gassings
+gastric
+gastrointestinal
+gate
+gated
+gates
+gateway
+gateway's
+gateways
+gather
+gathered
+gatherer
+gatherers
+gathering
+gatherings
+gathers
+gating
+gaudier
+gaudies
+gaudiness
+gaudy
+gauge
+gauged
+gauger
+gauges
+gauging
+gaunt
+gauntly
+gauntness
+gauze
+gauzed
+gauzes
+gauzing
+gave
+gay
+gayer
+gayest
+gayly
+gayness
+gaze
+gazed
+gazer
+gazers
+gazes
+gazing
+gear
+geared
+gearing
+gears
+geese
+gel
+gel's
+gelatin
+gelled
+gelling
+gels
+gem
+gem's
+gems
+gender
+gender's
+gendered
+gendering
+genders
+gene
+gene's
+general
+general's
+generalist
+generalist's
+generalists
+generalities
+generality
+generally
+generalness
+generals
+generate
+generated
+generates
+generating
+generation
+generations
+generative
+generatively
+generator
+generator's
+generators
+generic
+generically
+genericness
+generosities
+generosity
+generosity's
+generous
+generously
+generousness
+genes
+genetic
+genetically
+genetics
+genial
+genially
+genialness
+genius
+genius's
+geniuses
+genre
+genre's
+genres
+genteel
+genteeler
+genteelest
+genteelly
+genteelness
+gentle
+gentled
+gentleman
+gentlemanliness
+gentlemanly
+gentleness
+gentler
+gentlest
+gentlewoman
+gentling
+gently
+gentries
+gentry
+genuine
+genuinely
+genuineness
+genus
+geographic
+geographical
+geographically
+geographies
+geography
+geological
+geologist
+geologist's
+geologists
+geometric
+geometries
+geometry
+geranium
+germ
+germ's
+germane
+germen
+germinate
+germinated
+germinates
+germinating
+germination
+germinations
+germinative
+germinatively
+germs
+gestalt
+gesture
+gestured
+gestures
+gesturing
+get
+gets
+getter
+getter's
+gettered
+getters
+getting
+ghastlier
+ghastliness
+ghastly
+ghost
+ghosted
+ghosting
+ghostlier
+ghostliness
+ghostlinesses
+ghostly
+ghosts
+giant
+giant's
+giants
+gibberish
+giddied
+giddier
+giddiness
+giddy
+giddying
+gift
+gifted
+giftedly
+giftedness
+gifts
+gig
+gig's
+gigantic
+giganticness
+giggle
+giggled
+giggler
+giggles
+giggling
+gigglingly
+gigs
+gild
+gilded
+gilder
+gilding
+gilds
+gill
+gill's
+gilled
+giller
+gills
+gilt
+gimmick
+gimmick's
+gimmicks
+gin
+gin's
+ginger
+gingerbread
+gingered
+gingering
+gingerliness
+gingerly
+gingham
+ginghams
+gins
+giraffe
+giraffe's
+giraffes
+gird
+girded
+girder
+girder's
+girders
+girding
+girdle
+girdled
+girdler
+girdles
+girdling
+girds
+girl
+girl's
+girlfriend
+girlfriend's
+girlfriends
+girls
+girt
+girth
+give
+given
+givenness
+givens
+giver
+givers
+gives
+giveth
+giving
+givingly
+gizmo
+gizmo's
+gizmos
+glacial
+glacially
+glacier
+glacier's
+glaciers
+glad
+gladder
+gladdest
+glade
+glades
+gladly
+gladness
+glamour
+glamoured
+glamouring
+glamours
+glance
+glanced
+glances
+glancing
+glancingly
+gland
+gland's
+glanders
+glands
+glare
+glared
+glares
+glaring
+glaringly
+glaringness
+glass
+glassed
+glasses
+glassier
+glassies
+glassiness
+glassy
+glaze
+glazed
+glazer
+glazers
+glazes
+glazing
+gleam
+gleamed
+gleaming
+gleams
+glean
+gleaned
+gleaner
+gleaning
+gleanings
+gleans
+glee
+gleed
+gleeful
+gleefully
+gleefulness
+glees
+glen
+glen's
+glens
+glide
+glided
+glider
+gliders
+glides
+gliding
+glimmer
+glimmered
+glimmering
+glimmers
+glimpse
+glimpsed
+glimpser
+glimpsers
+glimpses
+glimpsing
+glint
+glinted
+glinting
+glints
+glisten
+glistened
+glistening
+glistens
+glitch
+glitch's
+glitches
+glitter
+glittered
+glittering
+glitteringly
+glitters
+global
+globally
+globals
+globe
+globe's
+globes
+globing
+globular
+globularity
+globularly
+globularness
+gloom
+gloomier
+gloomily
+gloominess
+glooms
+gloomy
+gloried
+glories
+glorification
+glorifications
+glorified
+glorifier
+glorifiers
+glorifies
+glorify
+glorious
+gloriously
+gloriousness
+glory
+glorying
+gloss
+glossaries
+glossary
+glossary's
+glossed
+glosses
+glossier
+glossies
+glossiness
+glossing
+glossy
+glottal
+glove
+gloved
+glover
+glovers
+gloves
+gloving
+glow
+glowed
+glower
+glowered
+glowering
+glowers
+glowing
+glowingly
+glows
+glucose
+glue
+glued
+gluer
+gluers
+glues
+gluing
+gnat
+gnat's
+gnats
+gnaw
+gnawed
+gnawer
+gnawing
+gnaws
+go
+goad
+goaded
+goading
+goads
+goal
+goal's
+goals
+goat
+goat's
+goatee
+goatee's
+goatees
+goats
+gobble
+gobbled
+gobbler
+gobblers
+gobbles
+gobbling
+goblet
+goblet's
+goblets
+goblin
+goblin's
+goblins
+god
+god's
+goddess
+goddess's
+goddesses
+godlier
+godlike
+godlikeness
+godliness
+godly
+godmother
+godmother's
+godmothers
+gods
+goer
+goering
+goes
+going
+goings
+gold
+golden
+goldenly
+goldenness
+golding
+golds
+goldsmith
+golf
+golfer
+golfers
+golfing
+golfs
+gone
+goner
+gong
+gong's
+gongs
+gonion
+good
+goodbye
+goodbye's
+goodbyes
+goodie
+goodie's
+goodies
+goodly
+goodness
+goods
+goody
+goody's
+goose
+gooses
+goosing
+gore
+gored
+gores
+gorge
+gorgeous
+gorgeously
+gorgeousness
+gorger
+gorges
+gorging
+gorilla
+gorilla's
+gorillas
+goring
+gosh
+gospel
+gospels
+gossip
+gossiper
+gossipers
+gossips
+got
+gotcha
+gotcha's
+gotchas
+goth
+goto
+gotten
+gouge
+gouged
+gouger
+gouges
+gouging
+govern
+governed
+governess
+governesses
+governing
+government
+government's
+governmental
+governmentally
+governments
+governor
+governor's
+governors
+governs
+gown
+gowned
+gowns
+grab
+grabbed
+grabber
+grabber's
+grabbers
+grabbing
+grabbings
+grabs
+grace
+graced
+graceful
+gracefully
+gracefulness
+graces
+gracing
+gracious
+graciously
+graciousness
+gradation
+gradation's
+gradations
+grade
+graded
+gradely
+grader
+graders
+grades
+gradient
+gradient's
+gradients
+grading
+gradings
+gradual
+gradually
+gradualness
+graduate
+graduated
+graduates
+graduating
+graduation
+graduations
+graft
+grafted
+grafter
+grafting
+grafts
+graham
+graham's
+grahams
+grain
+grained
+grainer
+graining
+grains
+grammar
+grammar's
+grammars
+grammatical
+grammatically
+grammaticalness
+granaries
+granary
+granary's
+grand
+grander
+grandest
+grandeur
+grandfather
+grandfather's
+grandfatherly
+grandfathers
+grandiose
+grandiosely
+grandioseness
+grandkid
+grandkid's
+grandkids
+grandly
+grandma
+grandma's
+grandmother
+grandmother's
+grandmotherly
+grandmothers
+grandness
+grandpa
+grandpa's
+grandparent
+grandparents
+grandpas
+grands
+grandson
+grandson's
+grandsons
+grange
+granger
+granges
+granite
+grannies
+granny
+grant
+grant's
+granted
+granter
+granting
+grants
+granularity
+granulate
+granulated
+granulates
+granulating
+granulation
+granulations
+granulative
+grape
+grape's
+grapes
+grapevine
+grapevine's
+grapevines
+graph
+graph's
+graphed
+graphic
+graphical
+graphically
+graphicness
+graphics
+graphing
+graphite
+graphs
+grapple
+grappled
+grappler
+grapples
+grappling
+grasp
+graspable
+grasped
+grasper
+grasping
+graspingly
+graspingness
+grasps
+grass
+grassed
+grassers
+grasses
+grassier
+grassiest
+grassing
+grassy
+grate
+grated
+grateful
+gratefully
+gratefulness
+grater
+grates
+gratification
+gratifications
+gratified
+gratify
+gratifying
+gratifyingly
+grating
+gratingly
+gratings
+gratitude
+gratuities
+gratuitous
+gratuitously
+gratuitousness
+gratuity
+gratuity's
+grave
+gravel
+gravelly
+gravels
+gravely
+graveness
+graver
+gravers
+graves
+gravest
+gravies
+graving
+gravitation
+gravitational
+gravitationally
+gravities
+gravity
+gravy
+gray
+grayed
+grayer
+grayest
+graying
+grayly
+grayness
+grays
+graze
+grazed
+grazer
+grazes
+grazing
+grease
+greased
+greaser
+greasers
+greases
+greasier
+greasiness
+greasing
+greasy
+great
+greaten
+greatened
+greatening
+greater
+greatest
+greatly
+greatness
+greats
+greed
+greedier
+greedily
+greediness
+greedy
+green
+greened
+greener
+greenest
+greenhouse
+greenhouse's
+greenhouses
+greening
+greenish
+greenishness
+greenly
+greenness
+greens
+greet
+greeted
+greeter
+greeting
+greetings
+greets
+grenade
+grenade's
+grenades
+grew
+grey
+greyest
+greying
+grid
+grid's
+grids
+grief
+grief's
+griefs
+grievance
+grievance's
+grievances
+grieve
+grieved
+griever
+grievers
+grieves
+grieving
+grievingly
+grievous
+grievously
+grievousness
+grill
+grilled
+griller
+grilling
+grills
+grim
+grimed
+griming
+grimly
+grimness
+grin
+grind
+grinder
+grinders
+grinding
+grindingly
+grindings
+grinds
+grindstone
+grindstone's
+grindstones
+grins
+grip
+gripe
+griped
+griper
+gripes
+griping
+gripped
+gripper
+gripper's
+grippers
+gripping
+grippingly
+grips
+grit
+grit's
+grits
+grizzlier
+grizzly
+groan
+groaned
+groaner
+groaners
+groaning
+groans
+grocer
+grocer's
+groceries
+grocers
+grocery
+groom
+groom's
+groomed
+groomer
+grooming
+grooms
+groove
+grooved
+groover
+grooves
+grooving
+grope
+groped
+groper
+gropes
+groping
+gross
+grossed
+grosser
+grosses
+grossest
+grossing
+grossly
+grossness
+grotesque
+grotesquely
+grotesqueness
+grotto
+grotto's
+grottos
+ground
+grounded
+grounder
+grounders
+grounding
+grounds
+groundwork
+group
+group's
+grouped
+grouper
+grouping
+groupings
+groups
+grouse
+groused
+grouser
+grouses
+grousing
+grove
+grovel
+grovels
+grover
+grovers
+groves
+grow
+grower
+growers
+growing
+growingly
+growl
+growled
+growler
+growlier
+growliness
+growling
+growlingly
+growls
+growly
+grown
+grownup
+grownup's
+grownups
+grows
+growth
+growths
+grub
+grub's
+grubs
+grudge
+grudge's
+grudged
+grudger
+grudges
+grudging
+grudgingly
+gruesome
+gruesomely
+gruesomeness
+gruff
+gruffly
+gruffness
+grumble
+grumbled
+grumbler
+grumbles
+grumbling
+grumblingly
+grunt
+grunted
+grunter
+grunting
+grunts
+guarantee
+guaranteed
+guaranteeing
+guaranteer
+guaranteers
+guarantees
+guaranty
+guard
+guarded
+guardedly
+guardedness
+guarder
+guardian
+guardian's
+guardians
+guardianship
+guarding
+guards
+guerrilla
+guerrilla's
+guerrillas
+guess
+guessed
+guesser
+guesses
+guessing
+guest
+guest's
+guested
+guesting
+guests
+guidance
+guidances
+guide
+guidebook
+guidebook's
+guidebooks
+guided
+guideline
+guideline's
+guidelines
+guider
+guides
+guiding
+guild
+guilder
+guile
+guilt
+guiltier
+guiltiest
+guiltily
+guiltiness
+guiltless
+guiltlessly
+guiltlessness
+guilts
+guilty
+guinea
+guineas
+guise
+guise's
+guised
+guises
+guising
+guitar
+guitar's
+guitars
+gulch
+gulch's
+gulches
+gulf
+gulf's
+gulfs
+gull
+gulled
+gullibility
+gullied
+gullies
+gulling
+gulls
+gully
+gully's
+gullying
+gulp
+gulped
+gulper
+gulps
+gum
+gum's
+gums
+gun
+gun's
+gunfire
+gunfires
+gunned
+gunner
+gunner's
+gunners
+gunning
+gunpowder
+gunpowders
+guns
+gurgle
+gurgled
+gurgles
+gurgling
+guru
+guru's
+gurus
+gush
+gushed
+gusher
+gushes
+gushing
+gust
+gust's
+gusts
+gut
+guts
+gutser
+gutter
+guttered
+guttering
+gutters
+guy
+guy's
+guyed
+guyer
+guyers
+guying
+guys
+gym
+gymnasium
+gymnasium's
+gymnasiums
+gymnast
+gymnast's
+gymnastic
+gymnastics
+gymnasts
+gyms
+gypsied
+gypsies
+gypsy
+gypsy's
+gypsying
+gyration
+gyrations
+gyroscope
+gyroscope's
+gyroscopes
+ha
+habit
+habit's
+habitable
+habitableness
+habitat
+habitat's
+habitation
+habitation's
+habitations
+habitats
+habits
+habitual
+habitually
+habitualness
+hack
+hacked
+hacker
+hacker's
+hackers
+hacking
+hacks
+had
+hadn't
+hag
+hagen
+haggard
+haggardly
+haggardness
+hail
+hailed
+hailer
+hailing
+hails
+hair
+hair's
+haircut
+haircut's
+haircuts
+hairdresser
+hairdresser's
+hairdressers
+haired
+hairier
+hairiness
+hairless
+hairlessness
+hairs
+hairy
+hale
+haler
+half
+halfness
+halfway
+halfword
+halfword's
+halfwords
+haling
+hall
+hall's
+haller
+hallmark
+hallmark's
+hallmarked
+hallmarking
+hallmarks
+hallow
+hallowed
+hallowing
+hallows
+halls
+hallway
+hallway's
+hallways
+halt
+halted
+halter
+haltered
+haltering
+halters
+halting
+haltingly
+halts
+halve
+halved
+halvers
+halves
+halving
+ham
+ham's
+hamburger
+hamburger's
+hamburgers
+hamlet
+hamlet's
+hamlets
+hammer
+hammered
+hammerer
+hammering
+hammers
+hammock
+hammock's
+hammocks
+hamper
+hampered
+hampering
+hampers
+hams
+hand
+handbag
+handbag's
+handbags
+handbook
+handbook's
+handbooks
+handcuff
+handcuffed
+handcuffing
+handcuffs
+handed
+handedly
+handedness
+hander
+handers
+handful
+handfuls
+handicap
+handicap's
+handicapped
+handicaps
+handier
+handiest
+handily
+handiness
+handing
+handiwork
+handkerchief
+handkerchief's
+handkerchiefs
+handle
+handled
+handler
+handlers
+handles
+handling
+hands
+handshake
+handshake's
+handshaker
+handshakes
+handshaking
+handsome
+handsomely
+handsomeness
+handsomer
+handsomest
+handwriting
+handwritten
+handy
+hang
+hangar
+hangar's
+hangars
+hanged
+hanger
+hangers
+hanging
+hangover
+hangover's
+hangovers
+hangs
+hap
+haphazard
+haphazardly
+haphazardness
+hapless
+haplessly
+haplessness
+haply
+happen
+happened
+happening
+happenings
+happens
+happier
+happiest
+happily
+happiness
+happy
+harass
+harassed
+harasser
+harasses
+harassing
+harassment
+harassments
+hard
+harden
+hardened
+hardener
+hardening
+hardens
+harder
+hardest
+hardier
+hardiness
+harding
+hardings
+hardly
+hardness
+hardnesses
+hards
+hardship
+hardship's
+hardships
+hardware
+hardwares
+hardy
+hare
+hare's
+hares
+hark
+harked
+harken
+harking
+harks
+harlot
+harlot's
+harlots
+harm
+harmed
+harmer
+harmful
+harmfully
+harmfulness
+harming
+harmless
+harmlessly
+harmlessness
+harmonies
+harmonious
+harmoniously
+harmoniousness
+harmony
+harms
+harness
+harnessed
+harnesser
+harnesses
+harnessing
+harp
+harped
+harper
+harpers
+harping
+harpings
+harps
+harried
+harrier
+harrow
+harrowed
+harrower
+harrowing
+harrows
+harry
+harrying
+harsh
+harshen
+harshened
+harshening
+harsher
+harshest
+harshly
+harshness
+hart
+harvest
+harvested
+harvester
+harvesters
+harvesting
+harvests
+has
+hash
+hashed
+hasher
+hashes
+hashing
+hasn't
+hassle
+hassled
+hassler
+hassles
+hassling
+haste
+hasted
+hasten
+hastened
+hastener
+hastening
+hastens
+hastes
+hastier
+hastiest
+hastily
+hastiness
+hasting
+hastings
+hasty
+hat
+hat's
+hatch
+hatched
+hatcher
+hatcheries
+hatchery
+hatchery's
+hatches
+hatchet
+hatchet's
+hatchets
+hatching
+hate
+hated
+hateful
+hatefully
+hatefulness
+hater
+hates
+hath
+hating
+hatred
+hats
+haughtier
+haughtily
+haughtiness
+haughty
+haul
+hauled
+hauler
+haulers
+hauling
+hauls
+haunch
+haunch's
+haunches
+haunt
+haunted
+haunter
+haunting
+hauntingly
+haunts
+have
+haven
+haven's
+haven't
+havens
+haver
+havering
+havers
+haves
+having
+havoc
+havocs
+hawk
+hawked
+hawker
+hawkers
+hawking
+hawks
+hay
+hayer
+haying
+hays
+hazard
+hazard's
+hazarded
+hazarding
+hazardous
+hazardously
+hazardousness
+hazards
+haze
+haze's
+hazed
+hazel
+hazer
+hazes
+hazier
+haziest
+haziness
+hazing
+hazy
+he
+he'd
+he'll
+he's
+head
+head's
+headache
+headache's
+headaches
+headed
+header
+headers
+headgear
+heading
+heading's
+headings
+headland
+headland's
+headlands
+headline
+headlined
+headliner
+headlines
+headlining
+headlong
+headphone
+headphone's
+headphones
+headquarters
+heads
+headway
+heal
+healed
+healer
+healers
+healing
+heals
+health
+healthful
+healthfully
+healthfulness
+healthier
+healthiest
+healthily
+healthiness
+healthy
+heap
+heaped
+heaping
+heaps
+hear
+heard
+hearer
+hearers
+hearest
+hearing
+hearings
+hearken
+hearkened
+hearkening
+hears
+hearsay
+hearses
+hearsing
+heart
+heart's
+heartache
+heartache's
+heartaches
+hearted
+heartedly
+hearten
+heartened
+heartening
+hearteningly
+heartens
+hearth
+heartier
+hearties
+heartiest
+heartily
+heartiness
+heartless
+heartlessly
+heartlessness
+hearts
+hearty
+heat
+heatable
+heated
+heatedly
+heater
+heaters
+heath
+heathen
+heather
+heating
+heats
+heave
+heaved
+heaven
+heaven's
+heavenliness
+heavenly
+heavens
+heaver
+heavers
+heaves
+heavier
+heavies
+heaviest
+heavily
+heaviness
+heaving
+heavy
+hedge
+hedged
+hedgehog
+hedgehog's
+hedgehogs
+hedger
+hedges
+hedging
+hedgingly
+heed
+heeded
+heeding
+heedless
+heedlessly
+heedlessness
+heeds
+heel
+heeled
+heeler
+heelers
+heeling
+heels
+heifer
+height
+heighten
+heightened
+heightening
+heightens
+heights
+heinous
+heinously
+heinousness
+heir
+heir's
+heiress
+heiress's
+heiresses
+heirs
+held
+hell
+hell's
+heller
+hello
+hellos
+hells
+helm
+helmet
+helmet's
+helmeted
+helmets
+help
+helped
+helper
+helpers
+helpful
+helpfully
+helpfulness
+helping
+helpless
+helplessly
+helplessness
+helps
+hem
+hem's
+hemisphere
+hemisphere's
+hemisphered
+hemispheres
+hemlock
+hemlock's
+hemlocks
+hemostat
+hemostats
+hemp
+hempen
+hems
+hen
+hen's
+hence
+henceforth
+henchman
+henchmen
+hens
+her
+herald
+heralded
+heralding
+heralds
+herb
+herb's
+herbivore
+herbivorous
+herbivorously
+herbs
+herd
+herded
+herder
+herding
+herds
+here
+here's
+hereabout
+hereabouts
+hereafter
+hereby
+hereditary
+heredity
+herein
+hereinafter
+heres
+heresy
+heretic
+heretic's
+heretics
+heretofore
+herewith
+heritage
+heritages
+hermit
+hermit's
+hermits
+hero
+hero's
+heroes
+heroic
+heroically
+heroics
+heroin
+heroine
+heroine's
+heroines
+heroism
+heron
+heron's
+herons
+heros
+herring
+herring's
+herrings
+hers
+herself
+hesitant
+hesitantly
+hesitate
+hesitated
+hesitater
+hesitates
+hesitating
+hesitatingly
+hesitation
+hesitations
+heterogeneous
+heterogeneously
+heterogeneousness
+heuristic
+heuristic's
+heuristically
+heuristics
+hew
+hewed
+hewer
+hewing
+hews
+hex
+hexagonal
+hexagonally
+hexer
+hey
+hickories
+hickory
+hid
+hidden
+hide
+hided
+hideous
+hideously
+hideousness
+hideout
+hideout's
+hideouts
+hider
+hides
+hiding
+hierarchical
+hierarchically
+hierarchies
+hierarchy
+hierarchy's
+high
+higher
+highest
+highland
+highlander
+highlands
+highlight
+highlighted
+highlighting
+highlights
+highly
+highness
+highness's
+highnesses
+highway
+highway's
+highways
+hijack
+hijacked
+hijacker
+hijackers
+hijacking
+hijacks
+hike
+hiked
+hiker
+hikers
+hikes
+hiking
+hilarious
+hilariously
+hilariousness
+hill
+hill's
+hilled
+hiller
+hilling
+hillock
+hillocks
+hills
+hillside
+hilltop
+hilltop's
+hilltops
+hilt
+hilt's
+hilts
+him
+hims
+himself
+hind
+hinder
+hindered
+hinderer
+hindering
+hinders
+hindrance
+hindrances
+hinds
+hindsight
+hinge
+hinged
+hinger
+hinges
+hinging
+hint
+hinted
+hinter
+hinting
+hints
+hip
+hip's
+hipness
+hips
+hire
+hired
+hirer
+hirers
+hires
+hiring
+hirings
+his
+hiss
+hissed
+hisser
+hisses
+hissing
+histogram
+histogram's
+histograms
+historian
+historian's
+historians
+historic
+historical
+historically
+historicalness
+histories
+history
+history's
+hit
+hit's
+hitch
+hitched
+hitcher
+hitches
+hitchhike
+hitchhiked
+hitchhiker
+hitchhikers
+hitchhikes
+hitchhiking
+hitching
+hither
+hitherto
+hits
+hitter
+hitter's
+hitters
+hitting
+hive
+hives
+hiving
+hoar
+hoard
+hoarded
+hoarder
+hoarding
+hoards
+hoarier
+hoariness
+hoarse
+hoarsely
+hoarseness
+hoarser
+hoarsest
+hoary
+hoax
+hoax's
+hoaxed
+hoaxer
+hoaxes
+hoaxing
+hobbies
+hobble
+hobbled
+hobbler
+hobbles
+hobbling
+hobby
+hobby's
+hobbyist
+hobbyist's
+hobbyists
+hockey
+hoe
+hoe's
+hoer
+hoes
+hog
+hog's
+hogs
+hoist
+hoisted
+hoister
+hoisting
+hoists
+hold
+holden
+holder
+holders
+holding
+holdings
+holds
+hole
+hole's
+holed
+holes
+holiday
+holiday's
+holidayer
+holidays
+holier
+holies
+holiness
+holing
+holistic
+hollies
+hollow
+hollowed
+hollower
+hollowest
+hollowing
+hollowly
+hollowness
+hollows
+holly
+holocaust
+hologram
+hologram's
+holograms
+holy
+homage
+homaged
+homager
+homages
+homaging
+home
+homebuilt
+homed
+homeless
+homelessness
+homelier
+homeliness
+homely
+homemade
+homemaker
+homemaker's
+homemakers
+homeomorphic
+homeomorphism
+homeomorphism's
+homeomorphisms
+homer
+homers
+homes
+homesick
+homesickness
+homespun
+homestead
+homesteader
+homesteaders
+homesteads
+homeward
+homewards
+homework
+homeworker
+homeworkers
+homing
+homogeneities
+homogeneity
+homogeneity's
+homogeneous
+homogeneously
+homogeneousness
+homomorphic
+homomorphism
+homomorphism's
+homomorphisms
+hone
+honed
+honer
+hones
+honest
+honestly
+honesty
+honey
+honeycomb
+honeycombed
+honeyed
+honeying
+honeymoon
+honeymooned
+honeymooner
+honeymooners
+honeymooning
+honeymoons
+honeys
+honeysuckle
+honing
+honorary
+hood
+hood's
+hooded
+hoodedness
+hooding
+hoods
+hoodwink
+hoodwinked
+hoodwinker
+hoodwinking
+hoodwinks
+hoof
+hoof's
+hoofed
+hoofer
+hoofs
+hook
+hooked
+hookedness
+hooker
+hookers
+hooking
+hooks
+hoop
+hooped
+hooper
+hooping
+hoops
+hooray
+hooray's
+hoorays
+hoot
+hooted
+hooter
+hooters
+hooting
+hoots
+hop
+hope
+hoped
+hopeful
+hopefully
+hopefulness
+hopefuls
+hopeless
+hopelessly
+hopelessness
+hoper
+hopes
+hoping
+hopped
+hopper
+hopper's
+hoppers
+hopping
+hops
+horde
+horde's
+hordes
+horizon
+horizon's
+horizons
+horizontal
+horizontally
+hormone
+hormone's
+hormones
+horn
+horned
+hornedness
+hornet
+hornet's
+hornets
+horns
+horrendous
+horrendously
+horrible
+horribleness
+horribly
+horrid
+horridly
+horridness
+horrified
+horrifies
+horrify
+horrifying
+horrifyingly
+horror
+horror's
+horrors
+horse
+horse's
+horseback
+horsely
+horseman
+horsepower
+horsepowers
+horses
+horseshoe
+horseshoer
+horseshoes
+horsing
+hose
+hose's
+hosed
+hoses
+hosing
+hospitable
+hospitably
+hospital
+hospital's
+hospitality
+hospitals
+host
+host's
+hostage
+hostage's
+hostages
+hosted
+hostess
+hostess's
+hostesses
+hostile
+hostilely
+hostilities
+hostility
+hosting
+hostly
+hosts
+hot
+hotel
+hotel's
+hotels
+hotly
+hotness
+hotter
+hottest
+hound
+hounded
+hounder
+hounding
+hounds
+hour
+hour's
+hourly
+hours
+house
+house's
+housed
+houseflies
+housefly
+housefly's
+household
+household's
+householder
+householders
+households
+housekeeper
+housekeeper's
+housekeepers
+housekeeping
+houser
+houses
+housetop
+housetop's
+housetops
+housewife
+housewife's
+housewifeliness
+housewifely
+housework
+houseworker
+houseworkers
+housing
+housings
+hovel
+hovel's
+hovels
+hover
+hovered
+hoverer
+hovering
+hovers
+how
+how's
+however
+howl
+howled
+howler
+howling
+howls
+hows
+hrs
+hub
+hub's
+hubris
+hubs
+huddle
+huddled
+huddler
+huddles
+huddling
+hue
+hue's
+hued
+hues
+hug
+huge
+hugely
+hugeness
+huger
+hugest
+hugs
+huh
+hull
+hull's
+hulled
+huller
+hulling
+hulls
+hum
+human
+humane
+humanely
+humaneness
+humanities
+humanity
+humanity's
+humanly
+humanness
+humans
+humble
+humbled
+humbleness
+humbler
+humbles
+humblest
+humbling
+humbly
+humid
+humidification
+humidifications
+humidified
+humidifier
+humidifiers
+humidifies
+humidify
+humidifying
+humidities
+humidity
+humidly
+humiliate
+humiliated
+humiliates
+humiliating
+humiliatingly
+humiliation
+humiliations
+humility
+hummed
+humming
+humorous
+humorously
+humorousness
+hump
+humped
+humping
+humps
+hums
+hunch
+hunched
+hunches
+hundred
+hundreds
+hundredth
+hung
+hunger
+hungered
+hungering
+hungers
+hungrier
+hungriest
+hungrily
+hungriness
+hungry
+hunk
+hunk's
+hunker
+hunkered
+hunkering
+hunkers
+hunks
+hunt
+hunted
+hunter
+hunters
+hunting
+hunts
+huntsman
+hurdle
+hurdled
+hurdler
+hurdles
+hurdling
+hurl
+hurled
+hurler
+hurlers
+hurling
+hurrah
+hurricane
+hurricane's
+hurricanes
+hurried
+hurriedly
+hurriedness
+hurrier
+hurries
+hurry
+hurrying
+hurt
+hurter
+hurting
+hurtingly
+hurts
+husband
+husband's
+husbander
+husbandly
+husbandry
+husbands
+hush
+hushed
+hushes
+hushing
+husk
+husked
+husker
+huskier
+huskies
+huskiness
+husking
+husks
+husky
+hustle
+hustled
+hustler
+hustlers
+hustles
+hustling
+hut
+hut's
+huts
+hyacinth
+hybrid
+hybrids
+hydraulic
+hydraulically
+hydraulics
+hydrodynamic
+hydrodynamics
+hydrogen
+hydrogen's
+hydrogens
+hygiene
+hymn
+hymn's
+hymning
+hymns
+hype
+hype's
+hyped
+hyper
+hyperbolic
+hypertext
+hypertext's
+hypes
+hyphen
+hyphen's
+hyphened
+hyphening
+hyphens
+hypocrisies
+hypocrisy
+hypocrite
+hypocrite's
+hypocrites
+hypodermic
+hypodermics
+hypotheses
+hypothesis
+hypothetical
+hypothetically
+hysteresis
+hysterical
+hysterically
+ice
+iceberg
+iceberg's
+icebergs
+iced
+ices
+icier
+iciest
+iciness
+icing
+icings
+icon
+icon's
+icons
+icy
+id
+id's
+idea
+idea's
+ideal
+idealism
+idealistic
+ideally
+ideals
+ideas
+identical
+identically
+identicalness
+identifiable
+identifiably
+identification
+identifications
+identified
+identifier
+identifiers
+identifies
+identify
+identifying
+identities
+identity
+identity's
+ideological
+ideologically
+ideologies
+ideology
+idiocies
+idiocy
+idiosyncrasies
+idiosyncrasy
+idiosyncrasy's
+idiosyncratic
+idiot
+idiot's
+idiotic
+idiots
+idle
+idled
+idleness
+idler
+idlers
+idles
+idlest
+idling
+idly
+idol
+idol's
+idolatry
+idols
+if
+ignition
+ignoble
+ignobleness
+ignorance
+ignorant
+ignorantly
+ignorantness
+ignore
+ignored
+ignorer
+ignores
+ignoring
+ii
+iii
+ill
+illegal
+illegalities
+illegality
+illegally
+illicit
+illicitly
+illiterate
+illiterately
+illiterateness
+illiterates
+illness
+illness's
+illnesses
+illogical
+illogically
+illogicalness
+ills
+illuminate
+illuminated
+illuminates
+illuminating
+illuminatingly
+illumination
+illuminations
+illuminative
+illusion
+illusion's
+illusions
+illusive
+illusively
+illusiveness
+illustrate
+illustrated
+illustrates
+illustrating
+illustration
+illustrations
+illustrative
+illustratively
+illustrator
+illustrator's
+illustrators
+illustrious
+illustriously
+illustriousness
+illy
+image
+imaged
+images
+imaginable
+imaginableness
+imaginably
+imaginariness
+imaginary
+imagination
+imagination's
+imaginations
+imaginative
+imaginatively
+imaginativeness
+imagine
+imagined
+imaginer
+imagines
+imaging
+imagining
+imaginings
+imbalance
+imbalances
+imitate
+imitated
+imitates
+imitating
+imitation
+imitations
+imitative
+imitatively
+imitativeness
+immaculate
+immaculately
+immaculateness
+immaterial
+immaterially
+immaterialness
+immature
+immaturely
+immatureness
+immaturity
+immediacies
+immediacy
+immediate
+immediately
+immediateness
+immemorial
+immemorially
+immense
+immensely
+immenseness
+immerse
+immersed
+immerser
+immerses
+immersing
+immersion
+immersions
+immigrant
+immigrant's
+immigrants
+immigrate
+immigrated
+immigrates
+immigrating
+immigration
+imminent
+imminently
+imminentness
+immoral
+immoralities
+immorality
+immorally
+immortal
+immortality
+immortally
+immortals
+immovability
+immovable
+immovableness
+immovably
+immune
+immunities
+immunity
+immunity's
+immunology
+immutable
+immutableness
+imp
+imp's
+impact
+impacted
+impacter
+impacting
+impaction
+impactions
+impactive
+impactor
+impactor's
+impactors
+impacts
+impair
+impaired
+impairer
+impairing
+impairs
+impart
+imparted
+impartial
+impartially
+imparting
+imparts
+impasse
+impasses
+impassion
+impassioned
+impassioning
+impassions
+impassive
+impassively
+impassiveness
+impatience
+impatient
+impatiently
+impeach
+impeached
+impeaches
+impeaching
+impedance
+impedance's
+impedances
+impede
+impeded
+impeder
+impedes
+impediment
+impediment's
+impediments
+impeding
+impel
+impels
+impending
+impenetrability
+impenetrable
+impenetrableness
+impenetrably
+imperative
+imperatively
+imperativeness
+imperatives
+imperfect
+imperfection
+imperfection's
+imperfections
+imperfective
+imperfectly
+imperfectness
+imperial
+imperialism
+imperialist
+imperialist's
+imperialists
+imperially
+imperil
+imperious
+imperiously
+imperiousness
+impermanence
+impermanent
+impermanently
+impermissible
+impersonal
+impersonally
+impersonate
+impersonated
+impersonates
+impersonating
+impersonation
+impersonations
+impertinent
+impertinently
+imperturbability
+impervious
+imperviously
+imperviousness
+impetuous
+impetuously
+impetuousness
+impetus
+impinge
+impinged
+impinges
+impinging
+impious
+impiously
+implant
+implanted
+implanter
+implanting
+implants
+implausible
+implement
+implementable
+implementation
+implementation's
+implementations
+implemented
+implementer
+implementers
+implementing
+implementor
+implementor's
+implementors
+implements
+implicant
+implicant's
+implicants
+implicate
+implicated
+implicates
+implicating
+implication
+implications
+implicative
+implicatively
+implicativeness
+implicit
+implicitly
+implicitness
+implied
+implies
+implore
+implored
+implores
+imploring
+imply
+implying
+import
+importance
+important
+importantly
+importation
+importations
+imported
+importer
+importers
+importing
+imports
+impose
+imposed
+imposer
+imposes
+imposing
+imposingly
+imposition
+imposition's
+impositions
+impossibilities
+impossibility
+impossible
+impossibleness
+impossibles
+impossibly
+impostor
+impostor's
+impostors
+impotence
+impotent
+impotently
+impoverish
+impoverished
+impoverisher
+impoverishes
+impoverishing
+impoverishment
+impracticable
+impracticableness
+impractical
+impracticality
+impractically
+impracticalness
+imprecise
+imprecisely
+impreciseness
+imprecision
+impregnable
+impregnableness
+impress
+impressed
+impresser
+impresses
+impressing
+impression
+impression's
+impressionable
+impressionableness
+impressionist
+impressionistic
+impressionists
+impressions
+impressive
+impressively
+impressiveness
+impressment
+imprint
+imprinted
+imprinting
+imprints
+imprison
+imprisoned
+imprisoning
+imprisonment
+imprisonment's
+imprisonments
+imprisons
+improbable
+improbableness
+impromptu
+improper
+improperly
+improperness
+improve
+improved
+improvement
+improvements
+improver
+improves
+improving
+improvisation
+improvisation's
+improvisational
+improvisations
+improvise
+improvised
+improviser
+improvisers
+improvises
+improvising
+imps
+impudent
+impudently
+impulse
+impulsed
+impulses
+impulsing
+impulsion
+impulsions
+impulsive
+impulsively
+impulsiveness
+impunity
+impure
+impurely
+impureness
+impurities
+impurity
+impurity's
+impute
+imputed
+imputes
+imputing
+in
+inabilities
+inability
+inaccessibility
+inaccessible
+inaccessibly
+inaccuracies
+inaccuracy
+inaccurate
+inaccurately
+inactions
+inactivation
+inactive
+inactively
+inactivity
+inadequacies
+inadequacy
+inadequate
+inadequately
+inadequateness
+inadmissibility
+inadmissible
+inadvertent
+inadvertently
+inadvisability
+inadvisable
+inalterable
+inalterableness
+inane
+inanely
+inaneness
+inaner
+inanest
+inanimate
+inanimately
+inanimateness
+inapparently
+inapplicability
+inapplicable
+inappreciable
+inappreciably
+inappreciative
+inappreciatively
+inappreciativeness
+inapproachable
+inappropriate
+inappropriately
+inappropriateness
+inapt
+inaptly
+inaptness
+inarguable
+inarguably
+inarticulable
+inartistic
+inartistically
+inasmuch
+inattentive
+inattentively
+inattentiveness
+inaudible
+inaudibly
+inaugural
+inaugurate
+inaugurated
+inaugurating
+inauguration
+inaugurations
+inauspicious
+inauspiciously
+inauspiciousness
+inauthentic
+inauthenticity
+inboards
+inborn
+inbounds
+inbred
+inbuilt
+incantation
+incantations
+incapable
+incapableness
+incapably
+incapacitating
+incarnation
+incarnation's
+incarnations
+incautious
+incautiously
+incautiousness
+incendiaries
+incendiary
+incense
+incensed
+incenses
+incensing
+incentive
+incentive's
+incentively
+incentives
+inception
+inceptions
+incessant
+incessantly
+inch
+inched
+inches
+inching
+incidence
+incidences
+incident
+incident's
+incidental
+incidentally
+incidentals
+incidents
+incipient
+incipiently
+incision
+incision's
+incisions
+incitations
+incite
+incited
+inciter
+incites
+inciting
+incivility
+inclination
+inclination's
+inclinations
+incline
+inclined
+incliner
+inclines
+inclining
+inclose
+inclosed
+incloses
+inclosing
+include
+included
+includes
+including
+inclusion
+inclusion's
+inclusions
+inclusive
+inclusively
+inclusiveness
+incoherence
+incoherences
+incoherent
+incoherently
+income
+incomer
+incomers
+incomes
+incoming
+incommensurate
+incomparability
+incomparable
+incomparably
+incompatibilities
+incompatibility
+incompatibility's
+incompatible
+incompatibly
+incompetence
+incompetent
+incompetent's
+incompetently
+incompetents
+incomplete
+incompletely
+incompleteness
+incompletion
+incomprehensibility
+incomprehensible
+incomprehensibleness
+incomprehensibly
+incomprehension
+incompressible
+incomputable
+inconceivable
+inconceivableness
+inconceivably
+inconclusive
+inconclusively
+inconclusiveness
+inconformity
+incongruence
+incongruent
+incongruently
+inconsequential
+inconsequentially
+inconsequently
+inconsiderable
+inconsiderableness
+inconsiderably
+inconsiderate
+inconsiderately
+inconsiderateness
+inconsideration
+inconsistencies
+inconsistency
+inconsistency's
+inconsistent
+inconsistently
+inconsolable
+inconsolableness
+inconspicuous
+inconspicuously
+inconspicuousness
+inconstancy
+inconstantly
+incontestable
+incontinently
+incontrollable
+inconvenience
+inconvenienced
+inconveniences
+inconveniencing
+inconvenient
+inconveniently
+inconvertibility
+inconvertible
+incorporate
+incorporated
+incorporates
+incorporating
+incorporation
+incorporative
+incorrect
+incorrectly
+incorrectness
+incorruption
+increase
+increased
+increaser
+increases
+increasing
+increasingly
+incredibility
+incredible
+incredibleness
+incredibly
+incredulity
+incredulous
+incredulously
+increment
+incremental
+incrementally
+incremented
+incrementing
+increments
+incubate
+incubated
+incubates
+incubating
+incubation
+incubative
+incubator
+incubator's
+incubators
+incur
+incurable
+incurableness
+incurables
+incurably
+incurred
+incurring
+incurs
+indebted
+indebtedness
+indecent
+indecently
+indecision
+indecisive
+indecisively
+indecisiveness
+indecomposable
+indeed
+indefinable
+indefinableness
+indefinite
+indefinitely
+indefiniteness
+indemnity
+indent
+indentation
+indentation's
+indentations
+indented
+indenter
+indenting
+indents
+independence
+independent
+independently
+independents
+indescribable
+indescribableness
+indeterminable
+indeterminableness
+indeterminacies
+indeterminacy
+indeterminacy's
+indeterminate
+indeterminately
+indeterminateness
+indetermination
+indeterminism
+indeterministic
+index
+indexable
+indexed
+indexer
+indexers
+indexes
+indexing
+indicate
+indicated
+indicates
+indicating
+indication
+indications
+indicative
+indicatively
+indicatives
+indicator
+indicator's
+indicators
+indices
+indictment
+indictment's
+indictments
+indifference
+indifferent
+indifferently
+indigenous
+indigenously
+indigenousness
+indigested
+indigestible
+indigestion
+indignant
+indignantly
+indignation
+indignities
+indignity
+indigo
+indirect
+indirected
+indirecting
+indirection
+indirections
+indirectly
+indirectness
+indirects
+indiscernible
+indiscipline
+indisciplined
+indiscreet
+indiscreetly
+indiscreetness
+indiscriminate
+indiscriminately
+indiscriminateness
+indiscriminating
+indiscriminatingly
+indiscrimination
+indispensability
+indispensable
+indispensableness
+indispensably
+indisposed
+indisposes
+indistinct
+indistinctive
+indistinctly
+indistinctness
+indistinguishable
+indistinguishableness
+individual
+individual's
+individualistic
+individuality
+individually
+individuals
+indivisibility
+indivisible
+indivisibleness
+indoctrinate
+indoctrinated
+indoctrinates
+indoctrinating
+indoctrination
+indolent
+indolently
+indomitable
+indomitableness
+indoor
+indoors
+induce
+induced
+inducement
+inducement's
+inducements
+inducer
+induces
+inducing
+induct
+inductance
+inductances
+inducted
+inducting
+induction
+induction's
+inductions
+inductive
+inductively
+inductiveness
+inductor
+inductor's
+inductors
+inducts
+indulge
+indulged
+indulgence
+indulgence's
+indulgences
+indulger
+indulges
+indulging
+industrial
+industrialist
+industrialist's
+industrialists
+industrially
+industrials
+industries
+industrious
+industriously
+industriousness
+industry
+industry's
+inedited
+ineffective
+ineffectively
+ineffectiveness
+inefficacy
+inefficiencies
+inefficiency
+inefficient
+inefficiently
+inelastically
+inelegant
+inelegantly
+ineloquent
+ineloquently
+inequalities
+inequality
+inequitably
+inequities
+inequity
+inert
+inertia
+inertias
+inertly
+inertness
+inescapable
+inescapably
+inessential
+inestimable
+inevitabilities
+inevitability
+inevitable
+inevitableness
+inevitably
+inexact
+inexactitude
+inexactly
+inexactness
+inexcusable
+inexcusableness
+inexcusably
+inexhaustible
+inexhaustibleness
+inexistent
+inexorable
+inexorableness
+inexorably
+inexpedient
+inexpediently
+inexpensive
+inexpensively
+inexpensiveness
+inexperience
+inexperienced
+inexplainable
+inexplicable
+inexplicableness
+inexplicably
+inexpressibility
+inexpressible
+inexpressibleness
+inexpressibly
+inexpressive
+inexpressively
+inexpressiveness
+inextensible
+infallibility
+infallible
+infallibly
+infamous
+infamously
+infancy
+infant
+infant's
+infantry
+infants
+infeasible
+infect
+infected
+infecting
+infection
+infection's
+infections
+infectious
+infectiously
+infectiousness
+infective
+infects
+infer
+inference
+inference's
+inferencer
+inferences
+inferencing
+inferential
+inferentially
+inferior
+inferior's
+inferiority
+inferiorly
+inferiors
+infernal
+infernally
+inferno
+inferno's
+infernos
+inferred
+inferring
+infers
+infertility
+infest
+infested
+infester
+infesting
+infests
+infidel
+infidel's
+infidelity
+infidels
+infields
+infighter
+infighter's
+infighters
+infighting
+infiltrate
+infiltrated
+infiltrates
+infiltrating
+infiltration
+infiltrative
+infinite
+infinitely
+infiniteness
+infinitesimal
+infinitesimally
+infinities
+infinitive
+infinitive's
+infinitively
+infinitives
+infinitum
+infinity
+infirmity
+infix
+infix's
+infixes
+inflame
+inflamed
+inflamer
+inflaming
+inflammable
+inflammableness
+inflatable
+inflate
+inflated
+inflater
+inflates
+inflating
+inflation
+inflationary
+inflexibility
+inflexible
+inflexibleness
+inflexibly
+inflict
+inflicted
+inflicter
+inflicting
+inflictive
+inflicts
+inflows
+influence
+influenced
+influencer
+influences
+influencing
+influent
+influential
+influentially
+influenza
+inform
+informal
+informality
+informally
+informant
+informant's
+informants
+information
+informational
+informations
+informative
+informatively
+informativeness
+informed
+informer
+informers
+informing
+informs
+infractions
+infrastructure
+infrastructures
+infrequent
+infrequently
+infringe
+infringed
+infringement
+infringement's
+infringements
+infringer
+infringes
+infringing
+infuriate
+infuriated
+infuriately
+infuriates
+infuriating
+infuriatingly
+infuriation
+infuse
+infused
+infuser
+infuses
+infusing
+infusion
+infusions
+ingenious
+ingeniously
+ingeniousness
+ingenuity
+inglorious
+ingloriously
+ingloriousness
+ingot
+ingrained
+ingrainedly
+ingrains
+ingratitude
+ingredient
+ingredient's
+ingredients
+ingrown
+ingrownness
+ingrowth
+ingrowths
+inhabit
+inhabitable
+inhabitance
+inhabitant
+inhabitant's
+inhabitants
+inhabited
+inhabiter
+inhabiting
+inhabits
+inhale
+inhaled
+inhaler
+inhales
+inhaling
+inharmonious
+inharmoniously
+inharmoniousness
+inhere
+inhered
+inherent
+inherently
+inheres
+inhering
+inherit
+inheritable
+inheritableness
+inheritance
+inheritance's
+inheritances
+inherited
+inheriting
+inheritor
+inheritor's
+inheritors
+inheritress
+inheritress's
+inheritresses
+inheritrices
+inheritrix
+inherits
+inhibit
+inhibited
+inhibiter
+inhibiting
+inhibition
+inhibition's
+inhibitions
+inhibitive
+inhibitors
+inhibits
+inholding
+inholdings
+inhomogeneities
+inhomogeneity
+inhospitable
+inhospitableness
+inhospitably
+inhospitality
+inhuman
+inhumane
+inhumanely
+inhumanities
+inhumanly
+inhumanness
+inion
+iniquities
+iniquity
+iniquity's
+initial
+initialness
+initials
+initiate
+initiated
+initiates
+initiating
+initiation
+initiations
+initiative
+initiative's
+initiatives
+initiator
+initiator's
+initiators
+inject
+injected
+injecting
+injection
+injection's
+injections
+injective
+injects
+injudicious
+injudiciously
+injudiciousness
+injunction
+injunction's
+injunctions
+injure
+injured
+injurer
+injures
+injuries
+injuring
+injurious
+injuriously
+injuriousness
+injury
+injury's
+injustice
+injustice's
+injustices
+ink
+inked
+inker
+inkers
+inking
+inkings
+inkling
+inkling's
+inklings
+inks
+inlaid
+inland
+inlander
+inlet
+inlet's
+inlets
+inlier
+inly
+inlying
+inmate
+inmate's
+inmates
+inn
+innards
+innate
+innately
+innateness
+inner
+innerly
+innermost
+inning
+innings
+innocence
+innocent
+innocently
+innocents
+innocuous
+innocuously
+innocuousness
+innovate
+innovated
+innovates
+innovating
+innovation
+innovation's
+innovations
+innovative
+innovativeness
+inns
+innumerability
+innumerable
+innumerableness
+innumerably
+inoperable
+inopportune
+inopportunely
+inopportuneness
+inordinate
+inordinately
+inordinateness
+inorganic
+input
+input's
+inputed
+inputer
+inputing
+inputs
+inputting
+inquietude
+inquire
+inquired
+inquirer
+inquirers
+inquires
+inquiries
+inquiring
+inquiringly
+inquiry
+inquiry's
+inquisition
+inquisition's
+inquisitions
+inquisitive
+inquisitively
+inquisitiveness
+inroad
+inroads
+ins
+insane
+insanely
+insaneness
+insanitary
+insanity
+inscribe
+inscribed
+inscriber
+inscribes
+inscribing
+inscription
+inscription's
+inscriptions
+insect
+insect's
+insects
+insecure
+insecurely
+insecureness
+insecurity
+insensible
+insensibleness
+insensibly
+insensitive
+insensitively
+insensitiveness
+insensitivity
+inseparable
+inseparableness
+insert
+inserted
+inserter
+inserting
+insertion
+insertion's
+insertions
+inserts
+insets
+insetting
+inside
+insider
+insiders
+insides
+insidious
+insidiously
+insidiousness
+insight
+insight's
+insightful
+insightfully
+insights
+insignia
+insignias
+insignificance
+insignificances
+insignificant
+insignificantly
+insincerity
+insinuate
+insinuated
+insinuates
+insinuating
+insinuatingly
+insinuation
+insinuations
+insinuative
+insist
+insisted
+insistence
+insistent
+insistently
+insisting
+insists
+insociability
+insociable
+insociably
+insofar
+insolence
+insolent
+insolently
+insolubility
+insoluble
+insolubleness
+insolvable
+inspect
+inspected
+inspecting
+inspection
+inspection's
+inspections
+inspective
+inspector
+inspector's
+inspectors
+inspects
+inspiration
+inspiration's
+inspirations
+inspire
+inspired
+inspirer
+inspires
+inspiring
+instabilities
+instability
+install
+installation
+installation's
+installations
+installed
+installer
+installers
+installing
+installment
+installment's
+installments
+installs
+instance
+instanced
+instances
+instancing
+instant
+instantaneous
+instantaneously
+instantaneousness
+instanter
+instantiate
+instantiated
+instantiates
+instantiating
+instantiation
+instantiation's
+instantiations
+instantly
+instantness
+instants
+instated
+instates
+instead
+insteps
+instigate
+instigated
+instigates
+instigating
+instigation
+instigative
+instigator
+instigator's
+instigators
+instills
+instinct
+instinct's
+instinctive
+instinctively
+instincts
+institute
+instituted
+instituter
+instituters
+institutes
+instituting
+institution
+institution's
+institutional
+institutionally
+institutions
+institutive
+instruct
+instructed
+instructing
+instruction
+instruction's
+instructional
+instructions
+instructive
+instructively
+instructiveness
+instructor
+instructor's
+instructors
+instructs
+instrument
+instrumental
+instrumentalist
+instrumentalist's
+instrumentalists
+instrumentally
+instrumentals
+instrumentation
+instrumented
+instrumenting
+instruments
+insufficiencies
+insufficiency
+insufficient
+insufficiently
+insulate
+insulated
+insulates
+insulating
+insulation
+insulations
+insulator
+insulator's
+insulators
+insult
+insulted
+insulter
+insulting
+insultingly
+insults
+insuperable
+insupportable
+insupportableness
+insurance
+insurances
+insure
+insured
+insurer
+insurers
+insures
+insurgent
+insurgent's
+insurgents
+insuring
+insurmountable
+insurrection
+insurrection's
+insurrections
+insusceptible
+intact
+intactness
+intakes
+intangible
+intangible's
+intangibleness
+intangibles
+intangibly
+integer
+integer's
+integers
+integral
+integral's
+integrally
+integrals
+integrate
+integrated
+integrates
+integrating
+integration
+integrations
+integrative
+integrity
+intellect
+intellect's
+intellective
+intellectively
+intellects
+intellectual
+intellectually
+intellectualness
+intellectuals
+intelligence
+intelligencer
+intelligences
+intelligent
+intelligently
+intelligibility
+intelligible
+intelligibleness
+intelligibly
+intemperance
+intemperate
+intemperately
+intemperateness
+intend
+intended
+intendedly
+intendedness
+intender
+intending
+intends
+intense
+intensely
+intenseness
+intensification
+intensified
+intensifier
+intensifiers
+intensifies
+intensify
+intensifying
+intension
+intensities
+intensity
+intensive
+intensively
+intensiveness
+intent
+intention
+intentional
+intentionally
+intentioned
+intentions
+intently
+intentness
+intents
+interact
+interacted
+interacting
+interaction
+interaction's
+interactions
+interactive
+interactively
+interactivity
+interacts
+intercept
+intercepted
+intercepter
+intercepting
+intercepts
+interchange
+interchangeability
+interchangeable
+interchangeableness
+interchangeably
+interchanged
+interchanger
+interchanges
+interchanging
+interchangings
+intercity
+intercommunicate
+intercommunicated
+intercommunicates
+intercommunicating
+intercommunication
+interconnect
+interconnected
+interconnectedness
+interconnecting
+interconnection
+interconnection's
+interconnections
+interconnectivity
+interconnects
+intercourse
+interdependence
+interdependencies
+interdependency
+interdependent
+interdependently
+interdisciplinary
+interest
+interested
+interestedly
+interesting
+interestingly
+interestingness
+interests
+interface
+interfaced
+interfacer
+interfaces
+interfacing
+interfere
+interfered
+interference
+interferences
+interferer
+interferes
+interfering
+interferingly
+interim
+interior
+interior's
+interiorly
+interiors
+interlace
+interlaced
+interlaces
+interlacing
+interleave
+interleaved
+interleaves
+interleaving
+interlink
+interlinked
+interlinking
+interlinks
+interlisp
+interlisp's
+intermediaries
+intermediary
+intermediate
+intermediate's
+intermediated
+intermediately
+intermediateness
+intermediates
+intermediating
+intermediation
+interminable
+intermingle
+intermingled
+intermingles
+intermingling
+intermittent
+intermittently
+intermix
+intermixed
+intermixer
+intermixes
+intermixing
+intermodule
+intern
+internal
+internally
+internals
+international
+internationality
+internationally
+internationals
+interned
+interning
+interns
+interpersonal
+interpersonally
+interplay
+interpolate
+interpolated
+interpolates
+interpolating
+interpolation
+interpolations
+interpolative
+interpose
+interposed
+interposer
+interposes
+interposing
+interpret
+interpretable
+interpretation
+interpretation's
+interpretations
+interpreted
+interpreter
+interpreters
+interpreting
+interpretive
+interpretively
+interprets
+interprocess
+interrelate
+interrelated
+interrelatedly
+interrelatedness
+interrelates
+interrelating
+interrelation
+interrelations
+interrelationship
+interrelationship's
+interrelationships
+interrogate
+interrogated
+interrogates
+interrogating
+interrogation
+interrogations
+interrogative
+interrogatively
+interrogatives
+interrupt
+interrupted
+interrupter
+interrupters
+interruptible
+interrupting
+interruption
+interruption's
+interruptions
+interruptive
+interrupts
+intersect
+intersected
+intersecting
+intersection
+intersection's
+intersections
+intersects
+intersperse
+interspersed
+intersperses
+interspersing
+interspersion
+interspersions
+interstage
+interstate
+intertask
+intertwine
+intertwined
+intertwines
+intertwining
+interval
+interval's
+intervals
+intervene
+intervened
+intervener
+intervenes
+intervening
+intervention
+intervention's
+interventions
+interview
+interviewed
+interviewee
+interviewee's
+interviewees
+interviewer
+interviewer's
+interviewers
+interviewing
+interviews
+interwoven
+intestinal
+intestinally
+intestine
+intestine's
+intestines
+intimacy
+intimate
+intimated
+intimately
+intimateness
+intimater
+intimates
+intimating
+intimation
+intimations
+intimidate
+intimidated
+intimidates
+intimidating
+intimidation
+into
+intolerability
+intolerable
+intolerableness
+intolerably
+intolerance
+intolerant
+intolerantly
+intolerantness
+intonation
+intonation's
+intonations
+intoned
+intoner
+intoxicate
+intoxicated
+intoxicatedly
+intoxicating
+intoxication
+intractability
+intractable
+intractableness
+intractably
+intramural
+intramurally
+intransigent
+intransigently
+intransigents
+intransitive
+intransitively
+intransitiveness
+intraprocess
+intricacies
+intricacy
+intricate
+intricately
+intricateness
+intrigue
+intrigued
+intriguer
+intrigues
+intriguing
+intriguingly
+intrinsic
+intrinsically
+intrinsics
+introduce
+introduced
+introducer
+introduces
+introducing
+introduction
+introduction's
+introductions
+introductory
+introspect
+introspection
+introspections
+introspective
+introspectively
+introspectiveness
+introvert
+introverted
+intrude
+intruded
+intruder
+intruder's
+intruders
+intrudes
+intruding
+intrusion
+intrusion's
+intrusions
+intrusive
+intrusively
+intrusiveness
+intrust
+intubate
+intubated
+intubates
+intubating
+intubation
+intuition
+intuition's
+intuitionist
+intuitions
+intuitive
+intuitively
+intuitiveness
+invade
+invaded
+invader
+invaders
+invades
+invading
+invalid
+invalidate
+invalidated
+invalidates
+invalidating
+invalidation
+invalidations
+invalidities
+invalidity
+invalidly
+invalidness
+invalids
+invaluable
+invaluableness
+invaluably
+invariability
+invariable
+invariableness
+invariably
+invariance
+invariant
+invariantly
+invariants
+invasion
+invasion's
+invasions
+invent
+invented
+inventing
+invention
+invention's
+inventions
+inventive
+inventively
+inventiveness
+inventor
+inventor's
+inventories
+inventors
+inventory
+inventory's
+invents
+inveracity
+inverse
+inversely
+inverses
+inversion
+inversions
+inversive
+invert
+invertebrate
+invertebrate's
+invertebrates
+inverted
+inverter
+inverters
+invertible
+inverting
+inverts
+invest
+invested
+investigate
+investigated
+investigates
+investigating
+investigation
+investigations
+investigative
+investigator
+investigator's
+investigators
+investing
+investment
+investment's
+investments
+investor
+investor's
+investors
+invests
+inviability
+inviable
+invincible
+invincibleness
+invisibility
+invisible
+invisibleness
+invisibly
+invitation
+invitation's
+invitations
+invite
+invited
+inviter
+invites
+inviting
+invitingly
+invocation
+invocation's
+invocations
+invoice
+invoiced
+invoices
+invoicing
+invokable
+invoke
+invoked
+invoker
+invokers
+invokes
+invoking
+involuntarily
+involuntariness
+involuntary
+involve
+involved
+involvedly
+involvement
+involvement's
+involvements
+involver
+involves
+involving
+invulnerable
+invulnerableness
+inward
+inwardly
+inwardness
+inwards
+inwrought
+ioctl
+iodine
+ion
+ions
+irate
+irately
+irateness
+ire
+ire's
+ires
+iris
+irises
+irk
+irked
+irking
+irks
+irksome
+irksomely
+irksomeness
+iron
+ironed
+ironer
+ironical
+ironically
+ironicalness
+ironies
+ironing
+ironings
+ironness
+irons
+ironwork
+ironwork's
+ironworker
+ironworks
+irony
+irrational
+irrationality
+irrationally
+irrationalness
+irrationals
+irrecoverable
+irrecoverableness
+irreducible
+irreducibly
+irreflexive
+irrefutable
+irregular
+irregularities
+irregularity
+irregularly
+irregulars
+irrelevance
+irrelevances
+irrelevant
+irrelevantly
+irrepressible
+irresistible
+irresistibleness
+irrespective
+irrespectively
+irresponsible
+irresponsibleness
+irresponsibly
+irreversible
+irrigate
+irrigated
+irrigates
+irrigating
+irrigation
+irrigations
+irritate
+irritated
+irritates
+irritating
+irritatingly
+irritation
+irritations
+irritative
+is
+island
+islander
+islanders
+islands
+isle
+isle's
+isles
+islet
+islet's
+islets
+isling
+isn't
+isolate
+isolated
+isolates
+isolating
+isolation
+isolations
+isometric
+isometrics
+isomorphic
+isomorphically
+isomorphism
+isomorphism's
+isomorphisms
+isotope
+isotope's
+isotopes
+ispell
+ispell's
+issuance
+issue
+issued
+issuer
+issuers
+issues
+issuing
+isthmus
+it
+it'd
+it'll
+it's
+italic
+italics
+itch
+itches
+itching
+item
+item's
+items
+iterate
+iterated
+iterates
+iterating
+iteration
+iterations
+iterative
+iteratively
+iterator
+iterator's
+iterators
+itineraries
+itinerary
+its
+itself
+iv
+ivied
+ivies
+ivories
+ivory
+ivy
+ivy's
+ix
+jab
+jab's
+jabbed
+jabbing
+jabs
+jack
+jacked
+jacker
+jacket
+jacketed
+jackets
+jacking
+jacks
+jade
+jaded
+jadedly
+jadedness
+jades
+jading
+jail
+jailed
+jailer
+jailers
+jailing
+jails
+jam
+jammed
+jamming
+jams
+janitor
+janitor's
+janitors
+jar
+jar's
+jargon
+jarred
+jarring
+jarringly
+jars
+jaunt
+jaunt's
+jaunted
+jauntier
+jauntiness
+jaunting
+jaunts
+jaunty
+javelin
+javelin's
+javelins
+jaw
+jaw's
+jawed
+jaws
+jay
+jazz
+jealous
+jealousies
+jealously
+jealousness
+jealousy
+jean
+jean's
+jeans
+jeep
+jeep's
+jeeped
+jeepers
+jeeping
+jeeps
+jeer
+jeer's
+jeerer
+jeers
+jellied
+jellies
+jelly
+jelly's
+jellyfish
+jellying
+jenny
+jerk
+jerked
+jerker
+jerkier
+jerkiness
+jerking
+jerkings
+jerks
+jerky
+jersey
+jersey's
+jerseys
+jest
+jested
+jester
+jesting
+jests
+jet
+jet's
+jets
+jetted
+jetting
+jewel
+jewelries
+jewelry
+jewels
+jig
+jig's
+jigs
+jingle
+jingled
+jingler
+jingles
+jingling
+job
+job's
+jobs
+jocks
+jocund
+jocundly
+jog
+jogs
+john
+john's
+johns
+join
+joined
+joiner
+joiners
+joining
+joins
+joint
+joint's
+jointed
+jointedly
+jointedness
+jointer
+jointing
+jointly
+jointness
+joints
+joke
+joked
+joker
+jokers
+jokes
+joking
+jokingly
+jollied
+jollier
+jollies
+jolly
+jollying
+jolt
+jolted
+jolter
+jolting
+jolts
+jostle
+jostled
+jostles
+jostling
+jot
+jots
+jotted
+jotting
+journal
+journal's
+journalism
+journalist
+journalist's
+journalistic
+journalists
+journals
+journey
+journeyed
+journeying
+journeyings
+journeys
+joust
+jousted
+jouster
+jousting
+jousts
+joy
+joy's
+joyful
+joyfully
+joyfulness
+joyous
+joyously
+joyousness
+joys
+jubilee
+judge
+judged
+judger
+judges
+judging
+judicable
+judicial
+judicially
+judiciaries
+judiciary
+judicious
+judiciously
+judiciousness
+jug
+jug's
+juggle
+juggled
+juggler
+jugglers
+juggles
+juggling
+jugs
+juice
+juice's
+juiced
+juicer
+juicers
+juices
+juicier
+juiciest
+juiciness
+juicing
+juicy
+jumble
+jumbled
+jumbles
+jumbling
+jump
+jumped
+jumper
+jumpers
+jumpier
+jumpiness
+jumping
+jumps
+jumpy
+junction
+junction's
+junctions
+juncture
+juncture's
+junctures
+jungle
+jungle's
+jungled
+jungles
+junior
+junior's
+juniors
+juniper
+junk
+junker
+junkers
+junkie
+junkies
+junks
+junky
+juries
+jurisdiction
+jurisdiction's
+jurisdictions
+juror
+juror's
+jurors
+jury
+jury's
+just
+juster
+justice
+justice's
+justices
+justifiable
+justifiably
+justification
+justifications
+justified
+justifier
+justifier's
+justifiers
+justifies
+justify
+justifying
+justing
+justly
+justness
+jut
+juvenile
+juvenile's
+juveniles
+juxtapose
+juxtaposed
+juxtaposes
+juxtaposing
+kHz
+keel
+keeled
+keeler
+keeling
+keels
+keen
+keener
+keenest
+keening
+keenly
+keenness
+keep
+keeper
+keepers
+keeping
+keeps
+ken
+kennel
+kennel's
+kennels
+kept
+kerchief
+kerchief's
+kerchiefed
+kerchiefs
+kernel
+kernel's
+kernels
+kerosene
+ketchup
+kettle
+kettle's
+kettles
+key
+keyboard
+keyboard's
+keyboarder
+keyboarding
+keyboards
+keyclick
+keyclick's
+keyclicks
+keyed
+keying
+keypad
+keypad's
+keypads
+keys
+keystroke
+keystroke's
+keystrokes
+keyword
+keyword's
+keywords
+kick
+kicked
+kicker
+kickers
+kicking
+kicks
+kid
+kid's
+kidded
+kidding
+kiddingly
+kidnap
+kidnap's
+kidnaps
+kidney
+kidney's
+kidneys
+kids
+kill
+killed
+killer
+killers
+killing
+killingly
+killings
+kills
+kilobit
+kilobits
+kilobyte
+kilobytes
+kin
+kind
+kinder
+kindergarten
+kindest
+kindhearted
+kindheartedly
+kindheartedness
+kindle
+kindled
+kindler
+kindles
+kindlier
+kindliness
+kindling
+kindly
+kindness
+kindnesses
+kindred
+kinds
+king
+kingdom
+kingdom's
+kingdoms
+kinglier
+kingliness
+kingly
+kings
+kinkier
+kinkiness
+kinky
+kinship
+kinsman
+kiss
+kissed
+kisser
+kissers
+kisses
+kissing
+kissings
+kit
+kit's
+kitchen
+kitchen's
+kitchener
+kitchens
+kite
+kited
+kiter
+kites
+kiting
+kits
+kitsch
+kitten
+kitten's
+kittened
+kittening
+kittens
+kitties
+kitty
+kludge
+kludge's
+kludged
+kludger
+kludger's
+kludgers
+kludges
+kludgey
+kludging
+klutz
+klutz's
+klutzes
+klutziness
+klutzy
+knack
+knacker
+knacks
+knapsack
+knapsack's
+knapsacks
+knave
+knave's
+knaves
+knead
+kneaded
+kneader
+kneading
+kneads
+knee
+kneed
+kneeing
+kneel
+kneeled
+kneeler
+kneeling
+kneels
+knees
+knell
+knell's
+knells
+knelt
+knew
+knife
+knifed
+knifes
+knifing
+knight
+knighted
+knighthood
+knighting
+knightliness
+knightly
+knights
+knit
+knits
+knives
+knob
+knob's
+knobs
+knock
+knocked
+knocker
+knockers
+knocking
+knocks
+knoll
+knoll's
+knolls
+knot
+knot's
+knots
+knotted
+knotting
+know
+knowable
+knower
+knowhow
+knowing
+knowingly
+knowledge
+knowledgeable
+knowledgeableness
+knowledges
+known
+knows
+knuckle
+knuckled
+knuckles
+knuckling
+kudos
+lab
+lab's
+label
+label's
+labels
+laboratories
+laboratory
+laboratory's
+labs
+labyrinth
+labyrinths
+lace
+laced
+lacer
+lacerate
+lacerated
+lacerates
+lacerating
+laceration
+lacerations
+lacerative
+laces
+lacing
+lack
+lackadaisical
+lackadaisically
+lacked
+lacker
+lacking
+lacks
+lacquer
+lacquered
+lacquerer
+lacquerers
+lacquering
+lacquers
+lad
+ladder
+ladders
+laded
+laden
+ladened
+ladening
+ladies
+lading
+lads
+lady
+lady's
+lag
+lager
+lagers
+lagged
+lagoon
+lagoon's
+lagoons
+lags
+laid
+lain
+lair
+lair's
+lairs
+lake
+lake's
+laker
+lakes
+laking
+lamb
+lamb's
+lambda
+lambda's
+lambdas
+lamber
+lambs
+lame
+lamed
+lamely
+lameness
+lament
+lamentable
+lamentableness
+lamentation
+lamentation's
+lamentations
+lamented
+lamenting
+laments
+lamer
+lames
+lamest
+laminar
+laming
+lamp
+lamp's
+lamper
+lamps
+lance
+lanced
+lancer
+lancers
+lances
+lancing
+land
+landed
+lander
+landers
+landing
+landings
+landladies
+landlady
+landlady's
+landlord
+landlord's
+landlords
+landmark
+landmark's
+landmarks
+landowner
+landowner's
+landowners
+lands
+landscape
+landscaped
+landscaper
+landscapes
+landscaping
+lane
+lane's
+lanes
+language
+language's
+languages
+languid
+languidly
+languidness
+languish
+languished
+languisher
+languishes
+languishing
+languishingly
+lantern
+lantern's
+lanterns
+lap
+lap's
+lapel
+lapel's
+lapels
+laps
+lapse
+lapsed
+lapser
+lapses
+lapsing
+lard
+larded
+larder
+larding
+lards
+large
+largely
+largeness
+larger
+largest
+lark
+lark's
+larker
+larks
+larva
+larvae
+larvas
+laser
+laser's
+lasers
+lash
+lashed
+lasher
+lashes
+lashing
+lashings
+lass
+lass's
+lasses
+last
+lasted
+laster
+lasting
+lastingly
+lastingness
+lastly
+lasts
+latch
+latched
+latches
+latching
+late
+lated
+lately
+latencies
+latency
+latency's
+lateness
+latent
+latently
+latents
+later
+lateral
+laterally
+latest
+latex
+latex's
+latexes
+lath
+lather
+lathered
+latherer
+lathering
+lathes
+lathing
+latitude
+latitude's
+latitudes
+latrine
+latrine's
+latrines
+latter
+latter's
+latterly
+lattice
+lattice's
+latticed
+lattices
+latticing
+laugh
+laughable
+laughableness
+laughably
+laughed
+laugher
+laughers
+laughing
+laughingly
+laughs
+laughter
+laughters
+launch
+launched
+launcher
+launchers
+launches
+launching
+launchings
+launder
+laundered
+launderer
+laundering
+launderings
+launders
+laundries
+laundry
+laurel
+laurel's
+laurels
+lava
+lavatories
+lavatory
+lavatory's
+lavender
+lavendered
+lavendering
+lavish
+lavished
+lavishing
+lavishly
+lavishness
+law
+law's
+lawful
+lawfully
+lawfulness
+lawless
+lawlessly
+lawlessness
+lawn
+lawn's
+lawns
+laws
+lawsuit
+lawsuit's
+lawsuits
+lawyer
+lawyer's
+lawyerly
+lawyers
+lay
+layer
+layered
+layering
+layers
+laying
+layman
+laymen
+layoffs
+layout
+layout's
+layouts
+lays
+lazed
+lazied
+lazier
+laziest
+lazily
+laziness
+lazing
+lazy
+lazying
+lead
+leaded
+leaden
+leadenly
+leadenness
+leader
+leader's
+leaders
+leadership
+leadership's
+leaderships
+leading
+leadings
+leads
+leaf
+leafed
+leafier
+leafiest
+leafing
+leafless
+leaflet
+leaflet's
+leaflets
+leafs
+leafy
+league
+leagued
+leaguer
+leaguers
+leagues
+leaguing
+leak
+leakage
+leakage's
+leakages
+leaked
+leaker
+leaking
+leaks
+lean
+leaned
+leaner
+leanest
+leaning
+leanings
+leanly
+leanness
+leans
+leap
+leaped
+leaper
+leaping
+leaps
+leapt
+learn
+learned
+learnedly
+learnedness
+learner
+learners
+learning
+learnings
+learns
+lease
+leased
+leases
+leash
+leash's
+leashes
+leasing
+least
+leather
+leathered
+leathering
+leathern
+leathers
+leave
+leaved
+leaven
+leavened
+leavening
+leaver
+leavers
+leaves
+leaving
+leavings
+lecture
+lectured
+lecturer
+lecturers
+lectures
+lecturing
+led
+ledge
+ledger
+ledgers
+ledges
+lee
+leech
+leech's
+leeches
+leer
+leered
+leering
+leers
+lees
+left
+leftist
+leftist's
+leftists
+leftmost
+leftover
+leftover's
+leftovers
+lefts
+leftward
+leftwards
+leg
+legacies
+legacy
+legacy's
+legal
+legalities
+legality
+legally
+legals
+legend
+legend's
+legendary
+legends
+legged
+leggings
+legibility
+legible
+legibly
+legion
+legion's
+legions
+legislate
+legislated
+legislates
+legislating
+legislation
+legislations
+legislative
+legislatively
+legislator
+legislator's
+legislators
+legislature
+legislature's
+legislatures
+legitimacy
+legitimate
+legitimated
+legitimately
+legitimates
+legitimating
+legitimation
+legs
+leisure
+leisured
+leisureliness
+leisurely
+lemma
+lemma's
+lemmas
+lemon
+lemon's
+lemonade
+lemons
+lend
+lender
+lenders
+lending
+lends
+length
+lengthen
+lengthened
+lengthener
+lengthening
+lengthens
+lengthier
+lengthiness
+lengthly
+lengths
+lengthwise
+lengthy
+leniency
+lenient
+leniently
+lens
+lens's
+lensed
+lenser
+lensers
+lenses
+lensing
+lensings
+lent
+lentil
+lentil's
+lentils
+leopard
+leopard's
+leopards
+leprosy
+less
+lessen
+lessened
+lessening
+lessens
+lesser
+lesses
+lessing
+lesson
+lesson's
+lessoned
+lessoning
+lessons
+lest
+lester
+let
+let's
+lets
+letter
+lettered
+letterer
+lettering
+letters
+letting
+lettuce
+levee
+levee's
+leveed
+levees
+level
+levelly
+levelness
+levels
+lever
+lever's
+leverage
+leveraged
+leverages
+leveraging
+levered
+levering
+levers
+levied
+levier
+levies
+levy
+levying
+lewd
+lewdly
+lewdness
+lexical
+lexically
+lexicographic
+lexicographical
+lexicographically
+lexicon
+lexicon's
+lexicons
+liabilities
+liability
+liability's
+liable
+liableness
+liaison
+liaison's
+liaisons
+liar
+liar's
+liars
+liberal
+liberally
+liberalness
+liberals
+liberate
+liberated
+liberates
+liberating
+liberation
+liberator
+liberator's
+liberators
+liberties
+liberty
+liberty's
+libido
+librarian
+librarian's
+librarians
+libraries
+library
+library's
+libretti
+license
+licensed
+licensee
+licensee's
+licensees
+licenser
+licenses
+licensing
+lichen
+lichen's
+lichened
+lichens
+lick
+licked
+licker
+licking
+licks
+lid
+lid's
+lids
+lie
+lied
+lieder
+liege
+lien
+lien's
+liens
+lier
+lies
+lieu
+lieutenant
+lieutenant's
+lieutenants
+life
+life's
+lifeless
+lifelessly
+lifelessness
+lifelike
+lifelikeness
+lifelong
+lifer
+lifers
+lifestyle
+lifestyles
+lifetime
+lifetime's
+lifetimes
+lift
+lifted
+lifter
+lifters
+lifting
+lifts
+light
+lighted
+lighten
+lightened
+lightener
+lightening
+lightens
+lighter
+lighter's
+lighters
+lightest
+lighthouse
+lighthouse's
+lighthouses
+lighting
+lightly
+lightness
+lightning
+lightning's
+lightninged
+lightnings
+lights
+lightweight
+lightweights
+like
+liked
+likelier
+likeliest
+likelihood
+likelihoods
+likeliness
+likely
+liken
+likened
+likeness
+likeness's
+likenesses
+likening
+likens
+liker
+likes
+likest
+likewise
+liking
+likings
+lilac
+lilac's
+lilacs
+lilied
+lilies
+lily
+lily's
+limb
+limbed
+limber
+limbered
+limbering
+limberly
+limberness
+limbers
+limbs
+lime
+lime's
+limed
+limes
+limestone
+liming
+limit
+limitability
+limitably
+limitation
+limitation's
+limitations
+limited
+limitedly
+limitedness
+limiteds
+limiter
+limiters
+limiting
+limits
+limp
+limped
+limper
+limping
+limply
+limpness
+limps
+linden
+line
+line's
+linear
+linearities
+linearity
+linearly
+lined
+linen
+linen's
+linens
+liner
+liners
+lines
+linger
+lingered
+lingerer
+lingering
+lingeringly
+lingers
+linguist
+linguist's
+linguistic
+linguistically
+linguistics
+linguists
+lining
+linings
+link
+linkage
+linkage's
+linkages
+linked
+linker
+linkers
+linking
+linkings
+links
+linoleum
+linseed
+lint
+linter
+lints
+lion
+lion's
+lioness
+lioness's
+lionesses
+lions
+lip
+lip's
+lips
+lipstick
+liquefied
+liquefier
+liquefiers
+liquefies
+liquefy
+liquefying
+liquid
+liquid's
+liquidation
+liquidation's
+liquidations
+liquidity
+liquidly
+liquidness
+liquids
+liquor
+liquor's
+liquored
+liquoring
+liquors
+lisp
+lisp's
+lisped
+lisper
+lisping
+lisps
+list
+listed
+listen
+listened
+listener
+listeners
+listening
+listens
+lister
+listers
+listing
+listing's
+listings
+lists
+lit
+literacy
+literal
+literally
+literalness
+literals
+literariness
+literary
+literate
+literately
+literateness
+literation
+literature
+literature's
+literatures
+lithe
+lithely
+litheness
+litigate
+litigated
+litigates
+litigating
+litigation
+litigator
+litter
+littered
+litterer
+littering
+litters
+little
+littleness
+littler
+littlest
+livable
+livableness
+livably
+live
+lived
+livelier
+liveliest
+livelihood
+liveliness
+lively
+liven
+livened
+liveness
+livening
+liver
+liveried
+livers
+livery
+lives
+livest
+liveth
+living
+livingly
+livingness
+livings
+lizard
+lizard's
+lizards
+load
+loaded
+loader
+loaders
+loading
+loadings
+loads
+loaf
+loafed
+loafer
+loafers
+loafing
+loafs
+loan
+loaned
+loaner
+loaning
+loans
+loath
+loathe
+loathed
+loather
+loathes
+loathing
+loathly
+loathness
+loathsome
+loathsomely
+loathsomeness
+loaves
+lobbied
+lobbies
+lobby
+lobbying
+lobe
+lobe's
+lobed
+lobes
+lobster
+lobster's
+lobsters
+local
+localities
+locality
+locality's
+locally
+locals
+locate
+located
+locater
+locates
+locating
+location
+locations
+locative
+locatives
+locator
+locator's
+locators
+loci
+lock
+locked
+locker
+lockers
+locking
+lockings
+lockout
+lockout's
+lockouts
+locks
+lockup
+lockup's
+lockups
+locomotion
+locomotive
+locomotive's
+locomotively
+locomotives
+locus
+locus's
+locust
+locust's
+locusts
+lodge
+lodged
+lodger
+lodger's
+lodgers
+lodges
+lodging
+lodgings
+loft
+loft's
+lofter
+loftier
+loftiness
+lofts
+lofty
+log
+log's
+logarithm
+logarithm's
+logarithmically
+logarithms
+logged
+logger
+logger's
+loggers
+logging
+logic
+logic's
+logical
+logically
+logicalness
+logicals
+logician
+logician's
+logicians
+logics
+login
+logins
+logistic
+logistics
+logout
+logs
+loin
+loin's
+loins
+loiter
+loitered
+loiterer
+loitering
+loiters
+lone
+lonelier
+loneliest
+loneliness
+lonely
+loneness
+loner
+loners
+lonesome
+lonesomely
+lonesomeness
+long
+longed
+longer
+longest
+longing
+longingly
+longings
+longitude
+longitude's
+longitudes
+longly
+longness
+longs
+longword
+longword's
+longwords
+look
+lookahead
+looked
+looker
+lookers
+looking
+lookout
+lookouts
+looks
+lookup
+lookup's
+lookups
+loom
+loomed
+looming
+looms
+loon
+loop
+looped
+looper
+loophole
+loophole's
+loopholed
+loopholes
+loopholing
+looping
+loops
+loose
+loosed
+loosely
+loosen
+loosened
+loosener
+looseness
+loosening
+loosens
+looser
+looses
+loosest
+loosing
+loot
+looted
+looter
+looting
+loots
+lord
+lord's
+lording
+lordlier
+lordliness
+lordly
+lords
+lordship
+lore
+lorries
+lorry
+lose
+loser
+losers
+loses
+losing
+losings
+loss
+loss's
+losses
+lossier
+lossiest
+lossy
+lost
+lostness
+lot
+lot's
+lots
+lotteries
+lottery
+lotus
+loud
+louden
+loudened
+loudening
+louder
+loudest
+loudly
+loudness
+loudspeaker
+loudspeaker's
+loudspeakers
+lounge
+lounged
+lounger
+loungers
+lounges
+lounging
+lousier
+lousiness
+lousy
+lovable
+lovableness
+lovably
+love
+love's
+loved
+lovelier
+lovelies
+loveliest
+loveliness
+lovely
+lover
+lover's
+lovering
+loverly
+lovers
+loves
+loving
+lovingly
+lovingness
+low
+lower
+lowered
+lowering
+lowers
+lowest
+lowing
+lowland
+lowlander
+lowlands
+lowlier
+lowliest
+lowliness
+lowly
+lowness
+lows
+loyal
+loyally
+loyalties
+loyalty
+loyalty's
+lubricant
+lubricant's
+lubricants
+lubrication
+luck
+lucked
+luckier
+luckiest
+luckily
+luckiness
+luckless
+lucks
+lucky
+ludicrous
+ludicrously
+ludicrousness
+luggage
+lukewarm
+lukewarmly
+lukewarmness
+lull
+lullaby
+lulled
+lulls
+lumber
+lumbered
+lumberer
+lumbering
+lumbers
+luminous
+luminously
+luminousness
+lump
+lumped
+lumpen
+lumper
+lumping
+lumps
+lunar
+lunatic
+lunatics
+lunch
+lunched
+luncheon
+luncheon's
+luncheons
+luncher
+lunches
+lunching
+lung
+lunged
+lunger
+lunging
+lungs
+lurch
+lurched
+lurcher
+lurches
+lurching
+lure
+lured
+lurer
+lures
+luring
+lurk
+lurked
+lurker
+lurkers
+lurking
+lurks
+luscious
+lusciously
+lusciousness
+lust
+lustier
+lustily
+lustiness
+lusting
+lustrous
+lustrously
+lustrousness
+lusts
+lusty
+lute
+lute's
+luted
+lutes
+luting
+luxuriant
+luxuriantly
+luxuries
+luxurious
+luxuriously
+luxuriousness
+luxury
+luxury's
+lying
+lyingly
+lyings
+lymph
+lynch
+lynched
+lyncher
+lynches
+lynx
+lynx's
+lynxes
+lyre
+lyre's
+lyres
+lyric
+lyrics
+ma'am
+macaroni
+macaroni's
+mace
+maced
+macer
+maces
+machine
+machine's
+machined
+machineries
+machinery
+machines
+machining
+macing
+macro
+macro's
+macroeconomics
+macromolecule
+macromolecule's
+macromolecules
+macros
+macroscopic
+mad
+madam
+madams
+madden
+maddened
+maddening
+maddeningly
+madder
+maddest
+made
+mademoiselle
+mademoiselles
+madly
+madman
+madness
+madras
+magazine
+magazine's
+magazined
+magazines
+magazining
+maggot
+maggot's
+maggots
+magic
+magical
+magically
+magician
+magician's
+magicians
+magistrate
+magistrate's
+magistrates
+magnesium
+magnesiums
+magnet
+magnet's
+magnetic
+magnetically
+magnetics
+magnetism
+magnetism's
+magnetisms
+magnets
+magnification
+magnifications
+magnificence
+magnificent
+magnificently
+magnified
+magnifier
+magnifiers
+magnifies
+magnify
+magnifying
+magnitude
+magnitude's
+magnitudes
+mahogany
+maid
+maid's
+maiden
+maidenliness
+maidenly
+maidens
+maids
+mail
+mailable
+mailbox
+mailbox's
+mailboxes
+mailed
+mailer
+mailer's
+mailers
+mailing
+mailings
+mails
+maim
+maimed
+maimedness
+maimer
+maimers
+maiming
+maims
+main
+mainframe
+mainframe's
+mainframes
+mainland
+mainlander
+mainlanders
+mainly
+mains
+mainstay
+maintain
+maintainability
+maintainable
+maintained
+maintainer
+maintainer's
+maintainers
+maintaining
+maintains
+maintenance
+maintenance's
+maintenances
+majestic
+majesties
+majesty
+majesty's
+major
+majored
+majoring
+majorities
+majority
+majority's
+majors
+makable
+make
+makefile
+makefiles
+maker
+makers
+makes
+makeshift
+makeshifts
+makeup
+makeups
+making
+makings
+maladies
+malady
+malady's
+malaria
+male
+male's
+malefactor
+malefactor's
+malefactors
+maleness
+males
+malfunction
+malfunctioned
+malfunctioning
+malfunctions
+malice
+malicious
+maliciously
+maliciousness
+malignant
+malignantly
+mall
+mall's
+mallet
+mallet's
+mallets
+malls
+malnutrition
+malt
+malted
+malting
+malts
+mama
+mamma
+mamma's
+mammal
+mammal's
+mammals
+mammas
+mammoth
+man
+man's
+manage
+manageable
+manageableness
+managed
+management
+management's
+managements
+manager
+manager's
+managerial
+managerially
+managers
+manages
+managing
+mandate
+mandated
+mandates
+mandating
+mandatories
+mandatory
+mandible
+mandolin
+mandolin's
+mandolins
+mane
+mane's
+maned
+manes
+manger
+manger's
+mangers
+mangle
+mangled
+mangler
+mangles
+mangling
+manhood
+maniac
+maniac's
+maniacs
+manicure
+manicured
+manicures
+manicuring
+manifest
+manifestation
+manifestation's
+manifestations
+manifested
+manifesting
+manifestly
+manifestness
+manifests
+manifold
+manifold's
+manifolder
+manifoldly
+manifoldness
+manifolds
+manipulability
+manipulable
+manipulatable
+manipulate
+manipulated
+manipulates
+manipulating
+manipulation
+manipulations
+manipulative
+manipulativeness
+manipulator
+manipulator's
+manipulators
+manipulatory
+mankind
+manlier
+manliest
+manliness
+manly
+manned
+manner
+mannered
+mannerliness
+mannerly
+manners
+manning
+manometer
+manometer's
+manometers
+manor
+manor's
+manors
+manpower
+mans
+mansion
+mansion's
+mansions
+mantel
+mantel's
+mantels
+mantissa
+mantissa's
+mantissas
+mantle
+mantle's
+mantled
+mantles
+mantling
+manual
+manual's
+manually
+manuals
+manufacture
+manufactured
+manufacturer
+manufacturer's
+manufacturers
+manufactures
+manufacturing
+manure
+manured
+manurer
+manurers
+manures
+manuring
+manuscript
+manuscript's
+manuscripts
+many
+map
+map's
+maple
+maple's
+maples
+mappable
+mapped
+mapping
+mapping's
+mappings
+maps
+mar
+marble
+marbled
+marbler
+marbles
+marbling
+march
+marched
+marcher
+marches
+marching
+mare
+mare's
+mares
+margin
+margin's
+marginal
+marginally
+marginals
+margined
+margining
+margins
+marigold
+marigold's
+marigolds
+marijuana
+marijuana's
+marinate
+marinated
+marinates
+marinating
+marine
+mariner
+marines
+maritime
+maritimer
+mark
+markable
+marked
+markedly
+marker
+markers
+market
+marketability
+marketable
+marketed
+marketer
+marketing
+marketings
+marketplace
+marketplace's
+marketplaces
+markets
+marking
+markings
+marks
+marquis
+marquises
+marriage
+marriage's
+marriages
+married
+marries
+marrow
+marrows
+marry
+marrying
+mars
+marsh
+marsh's
+marshal
+marshaled
+marshaler
+marshalers
+marshaling
+marshals
+marshes
+mart
+marten
+martens
+martial
+martially
+marts
+martyr
+martyr's
+martyrdom
+martyrs
+marvel
+marvels
+masculine
+masculinely
+masculineness
+masculinity
+mash
+mashed
+masher
+mashers
+mashes
+mashing
+mashings
+mask
+masked
+masker
+masking
+maskings
+masks
+masochist
+masochist's
+masochists
+mason
+mason's
+masoned
+masoning
+masonry
+masons
+masquerade
+masquerader
+masquerades
+masquerading
+mass
+massacre
+massacred
+massacrer
+massacres
+massacring
+massage
+massaged
+massager
+massages
+massaging
+massed
+masses
+massing
+massinger
+massive
+massively
+massiveness
+mast
+masted
+master
+master's
+mastered
+masterful
+masterfully
+masterfulness
+mastering
+masterings
+masterliness
+masterly
+masterpiece
+masterpiece's
+masterpieces
+masters
+mastery
+masts
+masturbate
+masturbated
+masturbates
+masturbating
+masturbation
+mat
+mat's
+match
+matchable
+matched
+matcher
+matchers
+matches
+matching
+matchings
+matchless
+matchlessly
+matchmaker
+matchmaker's
+matchmakers
+matchmaking
+matchmaking's
+mate
+mate's
+mated
+mater
+material
+materialism
+materialism's
+materially
+materialness
+materials
+maternal
+maternally
+mates
+math
+mathematical
+mathematically
+mathematician
+mathematician's
+mathematicians
+mathematics
+mating
+matings
+matrices
+matriculation
+matrimony
+matrix
+matrixes
+matron
+matronly
+mats
+matted
+matter
+mattered
+mattering
+matters
+mattress
+mattress's
+mattresses
+maturation
+mature
+matured
+maturely
+matureness
+maturer
+matures
+maturing
+maturities
+maturity
+max
+maxim
+maxim's
+maximal
+maximally
+maxims
+maximum
+maximumly
+maximums
+may
+maybe
+mayer
+mayest
+mayhap
+mayhem
+maying
+mayonnaise
+mayor
+mayor's
+mayoral
+mayors
+mays
+maze
+maze's
+mazed
+mazedly
+mazedness
+mazednesses
+mazer
+mazes
+mazing
+me
+mead
+meadow
+meadow's
+meadows
+meads
+meager
+meagerly
+meagerness
+meal
+meal's
+meals
+mean
+meander
+meandered
+meandering
+meanderings
+meanders
+meaner
+meanest
+meaning
+meaning's
+meaningful
+meaningfully
+meaningfulness
+meaningless
+meaninglessly
+meaninglessness
+meanings
+meanly
+meanness
+means
+meant
+meantime
+meanwhile
+measles
+measurable
+measurably
+measure
+measured
+measuredly
+measurement
+measurement's
+measurements
+measurer
+measures
+measuring
+meat
+meat's
+meats
+mechanic
+mechanic's
+mechanical
+mechanically
+mechanicals
+mechanics
+mechanism
+mechanism's
+mechanisms
+med
+medal
+medal's
+medallion
+medallion's
+medallions
+medals
+meddle
+meddled
+meddler
+meddles
+meddling
+media
+median
+median's
+medianly
+medians
+medias
+mediate
+mediated
+mediately
+mediateness
+mediates
+mediating
+mediation
+mediations
+mediative
+medic
+medic's
+medical
+medically
+medicinal
+medicinally
+medicine
+medicine's
+medicines
+medics
+medieval
+medieval's
+medievally
+medievals
+meditate
+meditated
+meditates
+meditating
+meditation
+meditations
+meditative
+meditatively
+meditativeness
+medium
+medium's
+mediums
+meek
+meeker
+meekest
+meekly
+meekness
+meet
+meeter
+meeting
+meetings
+meetly
+meets
+megabit
+megabits
+megabyte
+megabytes
+megaword
+megawords
+melancholy
+meld
+melding
+melds
+mellow
+mellowed
+mellowing
+mellowly
+mellowness
+mellows
+melodies
+melodious
+melodiously
+melodiousness
+melodrama
+melodrama's
+melodramas
+melody
+melody's
+melon
+melon's
+melons
+melt
+melted
+melter
+melting
+meltingly
+melts
+member
+member's
+membered
+members
+membership
+membership's
+memberships
+membrane
+membrane's
+membraned
+membranes
+memo
+memo's
+memoir
+memoirs
+memorability
+memorable
+memorableness
+memoranda
+memorandum
+memorandums
+memorial
+memorially
+memorials
+memories
+memory
+memory's
+memoryless
+memos
+men
+men's
+menace
+menaced
+menaces
+menacing
+menacingly
+menagerie
+menageries
+mend
+mended
+mender
+mending
+mends
+menial
+menially
+menials
+mens
+mensed
+menses
+mensing
+mental
+mentalities
+mentality
+mentally
+mention
+mentionable
+mentioned
+mentioner
+mentioners
+mentioning
+mentions
+mentor
+mentor's
+mentors
+menu
+menu's
+menus
+mer
+mercenaries
+mercenariness
+mercenary
+mercenary's
+merchandise
+merchandised
+merchandiser
+merchandises
+merchandising
+merchant
+merchant's
+merchants
+mercies
+merciful
+mercifully
+mercifulness
+merciless
+mercilessly
+mercilessness
+mercuries
+mercury
+mercy
+mere
+merely
+merest
+merge
+merged
+merger
+mergers
+merges
+merging
+meridian
+meridians
+merit
+merited
+meriting
+meritorious
+meritoriously
+meritoriousness
+merits
+merrier
+merriest
+merrily
+merriment
+merriments
+merriness
+merry
+mesh
+meshed
+meshes
+meshing
+mess
+message
+message's
+messaged
+messages
+messaging
+messed
+messenger
+messenger's
+messengers
+messes
+messiah
+messiahs
+messier
+messiest
+messieurs
+messily
+messiness
+messing
+messy
+met
+meta
+metacircular
+metacircularity
+metal
+metal's
+metalanguage
+metalanguages
+metallic
+metallurgy
+metals
+metamathematical
+metamorphosis
+metaphor
+metaphor's
+metaphorical
+metaphorically
+metaphors
+metaphysical
+metaphysically
+metaphysics
+metavariable
+mete
+meted
+meteor
+meteor's
+meteoric
+meteorology
+meteors
+meter
+meter's
+metered
+metering
+meters
+metes
+method
+method's
+methodical
+methodically
+methodicalness
+methodist
+methodist's
+methodists
+methodological
+methodologically
+methodologies
+methodologists
+methodology
+methodology's
+methods
+meting
+metric
+metric's
+metrical
+metrically
+metrics
+metropolis
+metropolitan
+mets
+mew
+mewed
+mews
+mica
+mice
+microbicidal
+microbicide
+microcode
+microcoded
+microcodes
+microcoding
+microcomputer
+microcomputer's
+microcomputers
+microeconomics
+microfilm
+microfilm's
+microfilmed
+microfilmer
+microfilms
+microinstruction
+microinstruction's
+microinstructions
+microphone
+microphones
+microphoning
+microprocessing
+microprocessor
+microprocessor's
+microprocessors
+microprogram
+microprogram's
+microprogrammed
+microprogramming
+microprograms
+microscope
+microscope's
+microscopes
+microscopic
+microsecond
+microsecond's
+microseconds
+microstore
+microwave
+microwave's
+microwaves
+microword
+microwords
+mid
+midday
+middle
+middled
+middler
+middles
+middling
+middlingly
+middlings
+midnight
+midnightly
+midnights
+midpoint
+midpoint's
+midpoints
+midst
+midsts
+midsummer
+midway
+midways
+midwinter
+midwinterly
+mien
+miens
+mies
+miff
+miffed
+miffing
+miffs
+might
+mightier
+mightiest
+mightily
+mightiness
+mights
+mighty
+migrate
+migrated
+migrates
+migrating
+migration
+migrations
+migrative
+mild
+milden
+milder
+mildest
+mildew
+mildews
+mildly
+mildness
+mile
+mile's
+mileage
+mileages
+miler
+miles
+milestone
+milestone's
+milestones
+militant
+militantly
+militantness
+militants
+militaries
+militarily
+militarism
+militarisms
+military
+militia
+militias
+milk
+milked
+milker
+milkers
+milkier
+milkiness
+milking
+milkmaid
+milkmaid's
+milkmaids
+milks
+milky
+mill
+milled
+miller
+millers
+millet
+milling
+million
+millionaire
+millionaire's
+millionaires
+millioned
+millions
+millionth
+millipede
+millipede's
+millipedes
+millisecond
+milliseconds
+mills
+millstone
+millstone's
+millstones
+mimic
+mimicked
+mimicking
+mimics
+mince
+minced
+mincer
+mincers
+minces
+mincing
+mincingly
+mind
+minded
+mindedness
+minder
+minders
+mindful
+mindfully
+mindfulness
+minding
+mindless
+mindlessly
+mindlessness
+minds
+mine
+mined
+miner
+mineral
+mineral's
+minerals
+miners
+mines
+ming
+mingle
+mingled
+mingles
+mingling
+miniature
+miniature's
+miniatured
+miniatures
+miniaturing
+minicomputer
+minicomputer's
+minicomputers
+minimal
+minimally
+minimum
+minimums
+mining
+minion
+minions
+minister
+minister's
+ministered
+ministering
+ministers
+ministries
+ministry
+ministry's
+mink
+mink's
+minks
+minnow
+minnow's
+minnows
+minor
+minor's
+minored
+minoring
+minorities
+minority
+minority's
+minors
+minstrel
+minstrel's
+minstrels
+mint
+minted
+minter
+minting
+mints
+minus
+minuses
+minute
+minuted
+minutely
+minuteness
+minuter
+minutes
+minutest
+minuting
+miracle
+miracle's
+miracles
+miraculous
+miraculously
+miraculousness
+mire
+mired
+mires
+miring
+mirror
+mirrored
+mirroring
+mirrors
+mirth
+misapplication
+misapplied
+misapplier
+misapplies
+misapply
+misapplying
+misbehaving
+miscalculation
+miscalculation's
+miscalculations
+miscellaneous
+miscellaneously
+miscellaneousness
+mischief
+mischievous
+mischievously
+mischievousness
+miscommunicate
+miscommunicated
+miscommunicates
+miscommunication
+misconception
+misconception's
+misconceptions
+misconstrue
+misconstrued
+misconstrues
+misconstruing
+misdirect
+misdirected
+misdirection
+misdirects
+miser
+miserable
+miserableness
+miserably
+miseries
+miserliness
+miserly
+misers
+misery
+misery's
+misfeature
+misfit
+misfit's
+misfits
+misfortune
+misfortune's
+misfortunes
+misgiving
+misgivingly
+misgivings
+misguide
+misguided
+misguidedly
+misguidedness
+misguider
+misguides
+misguiding
+mishap
+mishap's
+mishaps
+misinform
+misinformation
+misinformed
+misinforming
+misinforms
+misinterpret
+misinterpreted
+misinterpreter
+misinterpreters
+misinterpreting
+misinterprets
+mislead
+misleader
+misleading
+misleadingly
+misleadings
+misleads
+misled
+mismatch
+mismatched
+mismatches
+mismatching
+misnomer
+misnomered
+misperceive
+misperceived
+misperceives
+misplace
+misplaced
+misplaces
+misplacing
+misread
+misreader
+misreading
+misreads
+misrepresentation
+misrepresentation's
+misrepresentations
+miss
+missed
+misses
+missile
+missile's
+missiles
+missing
+mission
+missionaries
+missionary
+missionary's
+missioned
+missioner
+missioning
+missions
+missive
+missives
+misspell
+misspelled
+misspelling
+misspellings
+misspells
+misstate
+misstated
+misstater
+misstates
+misstating
+mist
+mistakable
+mistake
+mistaken
+mistakenly
+mistaker
+mistakes
+mistaking
+mistakingly
+misted
+mister
+mistered
+mistering
+misters
+mistier
+mistiest
+mistiness
+misting
+mistreat
+mistreated
+mistreating
+mistreats
+mistress
+mistressly
+mistrust
+mistrusted
+mistruster
+mistrusting
+mistrusts
+mists
+misty
+mistype
+mistyped
+mistypes
+mistyping
+misunderstand
+misunderstander
+misunderstanders
+misunderstanding
+misunderstanding's
+misunderstandings
+misunderstands
+misunderstood
+misuse
+misused
+misuser
+misuses
+misusing
+mite
+mites
+mitigate
+mitigated
+mitigates
+mitigating
+mitigation
+mitigations
+mitigative
+mitten
+mitten's
+mittens
+mix
+mixed
+mixer
+mixers
+mixes
+mixing
+mixture
+mixture's
+mixtures
+ml
+mnemonic
+mnemonic's
+mnemonically
+mnemonics
+moan
+moaned
+moaning
+moans
+moat
+moat's
+moats
+mob
+mob's
+mobility
+mobs
+moccasin
+moccasin's
+moccasins
+mock
+mocked
+mocker
+mockers
+mockery
+mocking
+mockingly
+mocks
+modal
+modalities
+modality
+modality's
+modally
+mode
+model
+model's
+models
+modem
+modems
+moderate
+moderated
+moderately
+moderateness
+moderates
+moderating
+moderation
+moderations
+moderator
+moderator's
+moderators
+modern
+modernity
+modernly
+modernness
+moderns
+modes
+modest
+modestly
+modesty
+modifiability
+modifiable
+modifiableness
+modification
+modifications
+modified
+modifier
+modifiers
+modifies
+modify
+modifying
+modular
+modularities
+modularity
+modularly
+modulate
+modulated
+modulates
+modulating
+modulation
+modulations
+modulator
+modulator's
+modulators
+module
+module's
+modules
+modulo
+modulus
+modus
+moist
+moisten
+moistened
+moistener
+moistening
+moistly
+moistness
+moisture
+moistures
+molasses
+mold
+molded
+molder
+moldered
+moldering
+molders
+moldier
+moldiness
+molding
+molds
+moldy
+mole
+molecular
+molecularly
+molecule
+molecule's
+molecules
+moles
+molest
+molested
+molester
+molesters
+molesting
+molests
+molten
+mom
+mom's
+moment
+moment's
+momentarily
+momentariness
+momentary
+momently
+momentous
+momentously
+momentousness
+moments
+momentum
+momentums
+moms
+monarch
+monarchies
+monarchs
+monarchy
+monarchy's
+monasteries
+monastery
+monastery's
+monastic
+monetary
+money
+money's
+moneyed
+moneyer
+moneys
+monitor
+monitored
+monitoring
+monitors
+monk
+monk's
+monkey
+monkeyed
+monkeying
+monkeys
+monks
+mono
+mono's
+monochrome
+monochromes
+monograph
+monograph's
+monographes
+monographs
+monolithic
+monopolies
+monopoly
+monopoly's
+monotheism
+monotone
+monotonic
+monotonically
+monotonicity
+monotonous
+monotonously
+monotonousness
+monotony
+monster
+monster's
+monsters
+monstrous
+monstrously
+monstrousness
+month
+month's
+monthlies
+monthly
+months
+monument
+monument's
+monumental
+monumentally
+monuments
+mood
+mood's
+moodier
+moodiness
+moods
+moody
+moon
+mooned
+mooning
+moonlight
+moonlighted
+moonlighter
+moonlighting
+moonlights
+moonlit
+moons
+moonshine
+moonshiner
+moor
+moor's
+moored
+mooring
+moorings
+moors
+moose
+moot
+mooted
+mop
+moped
+moper
+moping
+mops
+moral
+moral's
+morale
+morales
+moralities
+morality
+morally
+morals
+morass
+morasses
+morbid
+morbidly
+morbidness
+more
+mored
+moreover
+mores
+morion
+morn
+morning
+mornings
+morphological
+morphologically
+morphology
+morrow
+morsel
+morsel's
+morsels
+mortal
+mortality
+mortally
+mortals
+mortar
+mortared
+mortaring
+mortars
+mortgage
+mortgage's
+mortgaged
+mortgager
+mortgages
+mortgaging
+mortification
+mortifications
+mortified
+mortifiedly
+mortifier
+mortifies
+mortify
+mortifying
+mosaic
+mosaic's
+mosaics
+mosquito
+mosquitoes
+mosquitos
+moss
+moss's
+mosses
+mossier
+mossy
+most
+mostly
+motel
+motel's
+motels
+moth
+mother
+mother's
+motherboard
+motherboard's
+motherboards
+mothered
+motherer
+motherers
+mothering
+motherliness
+motherly
+mothers
+motif
+motif's
+motifs
+motion
+motioned
+motioner
+motioning
+motionless
+motionlessly
+motionlessness
+motions
+motivate
+motivated
+motivates
+motivating
+motivation
+motivational
+motivationally
+motivations
+motivative
+motive
+motived
+motives
+motiving
+motley
+motor
+motorcar
+motorcar's
+motorcars
+motorcycle
+motorcycle's
+motorcycles
+motored
+motoring
+motorist
+motorist's
+motorists
+motors
+motto
+mottoes
+mottos
+mould
+moulded
+moulder
+mouldering
+moulding
+moulds
+mound
+mounded
+mounds
+mount
+mountain
+mountain's
+mountaineer
+mountaineering
+mountaineers
+mountainous
+mountainously
+mountainousness
+mountains
+mounted
+mounter
+mounting
+mountings
+mounts
+mourn
+mourned
+mourner
+mourners
+mournful
+mournfully
+mournfulness
+mourning
+mourningly
+mourns
+mouse
+mouser
+mouses
+mousing
+mouth
+mouthed
+mouther
+mouthes
+mouthful
+mouthing
+mouths
+movable
+movableness
+move
+moved
+movement
+movement's
+movements
+mover
+movers
+moves
+movie
+movie's
+movies
+moving
+movingly
+movings
+mow
+mowed
+mower
+mowers
+mowing
+mows
+much
+muchness
+muck
+mucked
+mucker
+mucking
+mucks
+mud
+muddied
+muddier
+muddiness
+muddle
+muddled
+muddler
+muddlers
+muddles
+muddling
+muddy
+muddying
+muds
+muff
+muff's
+muffin
+muffin's
+muffins
+muffle
+muffled
+muffler
+mufflers
+muffles
+muffling
+muffs
+mug
+mug's
+mugs
+mulberries
+mulberry
+mulberry's
+mule
+mule's
+mules
+muling
+multicellular
+multicomponent
+multidimensional
+multilevel
+multinational
+multiple
+multiple's
+multiples
+multiplex
+multiplexed
+multiplexer
+multiplexers
+multiplexes
+multiplexing
+multiplexor
+multiplexor's
+multiplexors
+multiplicand
+multiplicand's
+multiplicands
+multiplication
+multiplications
+multiplicative
+multiplicatively
+multiplicatives
+multiplicity
+multiplied
+multiplier
+multipliers
+multiplies
+multiply
+multiplying
+multiprocess
+multiprocessing
+multiprocessor
+multiprocessor's
+multiprocessors
+multiprogram
+multiprogrammed
+multiprogramming
+multiprogrammings
+multistage
+multitasking
+multitude
+multitude's
+multitudes
+multiuser
+multivariate
+mumble
+mumbled
+mumbler
+mumblers
+mumbles
+mumbling
+mumblings
+mummies
+mummy
+mummy's
+munch
+munched
+muncher
+munches
+munching
+mundane
+mundanely
+mundaneness
+municipal
+municipalities
+municipality
+municipality's
+municipally
+munition
+munitions
+mural
+murals
+murder
+murdered
+murderer
+murderers
+murdering
+murderous
+murderously
+murderousness
+murders
+murkier
+murkiness
+murky
+murmur
+murmured
+murmurer
+murmuring
+murmurs
+muscle
+muscled
+muscles
+muscling
+muscular
+muscularly
+muse
+mused
+muser
+muses
+museum
+museum's
+museums
+mushier
+mushiness
+mushroom
+mushroomed
+mushrooming
+mushrooms
+mushy
+music
+musical
+musically
+musicals
+musician
+musicianly
+musicians
+musics
+musing
+musingly
+musings
+musk
+musket
+musket's
+muskets
+muskrat
+muskrat's
+muskrats
+musks
+muslin
+mussel
+mussel's
+mussels
+must
+mustard
+mustards
+muster
+mustered
+mustering
+musters
+mustier
+mustiness
+musts
+musty
+mutability
+mutable
+mutableness
+mutate
+mutated
+mutates
+mutating
+mutation
+mutations
+mutative
+mutator
+mutators
+mute
+muted
+mutedly
+mutely
+muteness
+muter
+mutes
+mutest
+mutilate
+mutilated
+mutilates
+mutilating
+mutilation
+mutilations
+muting
+mutinies
+mutiny
+mutiny's
+mutter
+muttered
+mutterer
+mutterers
+muttering
+mutters
+mutton
+mutual
+mutually
+muzzle
+muzzle's
+muzzled
+muzzler
+muzzles
+muzzling
+my
+myriad
+myrtle
+myself
+mysteries
+mysterious
+mysteriously
+mysteriousness
+mystery
+mystery's
+mystic
+mystic's
+mystical
+mystically
+mysticism
+mysticisms
+mystics
+myth
+myth's
+mythes
+mythical
+mythically
+mythologies
+mythology
+mythology's
+nag
+nag's
+nags
+nail
+nailed
+nailer
+nailing
+nails
+naive
+naively
+naiveness
+naiver
+naivete
+naked
+nakedly
+nakedness
+name
+name's
+nameable
+named
+nameless
+namelessly
+namelessness
+namely
+namer
+namers
+names
+namesake
+namesake's
+namesakes
+naming
+nanosecond
+nanoseconds
+nap
+nap's
+napkin
+napkin's
+napkins
+naps
+narcissistic
+narcissus
+narcissuses
+narcotic
+narcotics
+narrative
+narrative's
+narratively
+narratives
+narrow
+narrowed
+narrower
+narrowest
+narrowing
+narrowingness
+narrowly
+narrowness
+narrows
+nasal
+nasally
+nastier
+nasties
+nastiest
+nastily
+nastiness
+nasty
+nation
+nation's
+national
+nationalist
+nationalist's
+nationalists
+nationalities
+nationality
+nationality's
+nationally
+nationals
+nations
+nationwide
+native
+natively
+nativeness
+natives
+nativity
+natural
+naturalism
+naturalist
+naturally
+naturalness
+naturals
+nature
+nature's
+natured
+natures
+naught
+naught's
+naughtier
+naughtiness
+naughts
+naughty
+naval
+navally
+navies
+navigable
+navigableness
+navigate
+navigated
+navigates
+navigating
+navigation
+navigations
+navigator
+navigator's
+navigators
+navy
+navy's
+nay
+near
+nearby
+neared
+nearer
+nearest
+nearing
+nearly
+nearness
+nears
+neat
+neaten
+neater
+neatest
+neatly
+neatness
+neats
+nebula
+necessaries
+necessarily
+necessary
+necessitate
+necessitated
+necessitates
+necessitating
+necessitation
+necessitations
+necessities
+necessity
+neck
+necked
+necker
+necking
+necklace
+necklace's
+necklaces
+necks
+necktie
+necktie's
+neckties
+need
+needed
+needer
+needful
+needfully
+needfulness
+needier
+neediness
+needing
+needle
+needled
+needler
+needlers
+needles
+needless
+needlessly
+needlessness
+needlework
+needleworker
+needling
+needly
+needn't
+needs
+needy
+negate
+negated
+negater
+negates
+negating
+negation
+negations
+negative
+negatived
+negatively
+negativeness
+negatives
+negativing
+negator
+negators
+neglect
+neglected
+neglecter
+neglecting
+neglects
+negligence
+negligible
+negotiable
+negotiate
+negotiated
+negotiates
+negotiating
+negotiation
+negotiations
+neigh
+neither
+neophyte
+neophytes
+nephew
+nephew's
+nephews
+nerve
+nerve's
+nerved
+nerves
+nerving
+nervous
+nervously
+nervousness
+nest
+nested
+nester
+nesting
+nestle
+nestled
+nestler
+nestles
+nestling
+nests
+net
+net's
+nether
+nets
+netted
+netting
+nettle
+nettled
+nettles
+nettling
+network
+network's
+networked
+networking
+networks
+neural
+neurally
+neurobiology
+neurobiology's
+neurological
+neurologically
+neurologists
+neuron
+neuron's
+neurons
+neutral
+neutralities
+neutrality
+neutrally
+neutralness
+neutrals
+neutrino
+neutrino's
+neutrinos
+never
+nevertheless
+new
+newborn
+newborns
+newcomer
+newcomer's
+newcomers
+newer
+newest
+newline
+newline's
+newlines
+newly
+newness
+news
+newsgroup
+newsgroup's
+newsgroups
+newsletter
+newsletter's
+newsletters
+newsman
+newsmen
+newspaper
+newspaper's
+newspapers
+newswire
+newt
+newts
+next
+nibble
+nibbled
+nibbler
+nibblers
+nibbles
+nibbling
+nice
+nicely
+niceness
+nicer
+nicest
+niceties
+nicety
+niche
+niches
+niching
+nick
+nicked
+nickel
+nickel's
+nickels
+nicker
+nickered
+nickering
+nicking
+nickname
+nicknamed
+nicknamer
+nicknames
+nicks
+nicotine
+niece
+niece's
+nieces
+niftier
+nifties
+nifty
+nigh
+night
+night's
+nighted
+nighters
+nightfall
+nightgown
+nightingale
+nightingale's
+nightingales
+nightly
+nightmare
+nightmare's
+nightmares
+nights
+nil
+nilly
+nimble
+nimbleness
+nimbler
+nimblest
+nimbly
+nine
+nines
+nineteen
+nineteens
+nineteenth
+nineties
+ninetieth
+ninety
+ninth
+nip
+nips
+nitrogen
+nix
+nixed
+nixer
+nixes
+nixing
+no
+nobilities
+nobility
+noble
+nobleman
+nobleness
+nobler
+nobles
+noblest
+nobly
+nobodies
+nobody
+nobody's
+nocturnal
+nocturnally
+nod
+nod's
+nodded
+nodding
+node
+node's
+nodes
+nods
+noise
+noised
+noiseless
+noiselessly
+noises
+noisier
+noisily
+noisiness
+noising
+noisy
+nomenclature
+nomenclatures
+nominal
+nominally
+nominate
+nominated
+nominates
+nominating
+nomination
+nomination's
+nominations
+nominative
+nominatively
+non
+nonblocking
+nonconservative
+noncyclic
+nondecreasing
+nondescript
+nondescriptly
+nondestructively
+nondeterminacy
+nondeterminate
+nondeterminately
+nondeterminism
+nondeterministic
+nondeterministically
+nondisclosure
+nondisclosures
+none
+nonempty
+nones
+nonetheless
+nonexistence
+nonexistent
+nonextensible
+nonfunctional
+noninteracting
+noninterference
+nonintuitive
+nonlinear
+nonlinearities
+nonlinearity
+nonlinearity's
+nonlinearly
+nonlocal
+nonnegative
+nonorthogonal
+nonorthogonality
+nonperishable
+nonprocedural
+nonprocedurally
+nonprogrammable
+nonprogrammer
+nonsense
+nonsensical
+nonsensically
+nonsensicalness
+nonspecialist
+nonspecialist's
+nonspecialists
+nonstandard
+nontechnical
+nontechnically
+nonterminal
+nonterminal's
+nonterminals
+nonterminating
+nontermination
+nontrivial
+nonuniform
+nonzero
+nook
+nook's
+nooks
+noon
+noonday
+nooning
+noons
+noontide
+nope
+nor
+norm
+norm's
+normal
+normalcy
+normality
+normally
+normals
+normed
+norms
+north
+north's
+northeast
+northeaster
+northeasterly
+northeastern
+norther
+northerly
+northern
+northerner
+northerners
+northernly
+northers
+northing
+northward
+northwards
+northwest
+northwester
+northwesterly
+northwestern
+nose
+nosed
+noses
+nosing
+nostril
+nostril's
+nostrils
+not
+notable
+notableness
+notables
+notably
+notation
+notation's
+notational
+notationally
+notations
+notch
+notched
+notches
+notching
+note
+notebook
+notebook's
+notebooks
+noted
+notedly
+notedness
+noter
+notes
+noteworthiness
+noteworthy
+nothing
+nothingness
+nothings
+notice
+noticeable
+noticeably
+noticed
+notices
+noticing
+notification
+notifications
+notified
+notifier
+notifiers
+notifies
+notify
+notifying
+noting
+notion
+notions
+notorious
+notoriously
+notoriousness
+notwithstanding
+noun
+noun's
+nouns
+nourish
+nourished
+nourisher
+nourishes
+nourishing
+nourishment
+novel
+novel's
+novelist
+novelist's
+novelists
+novels
+novelties
+novelty
+novelty's
+novice
+novice's
+novices
+now
+nowadays
+nowhere
+nowheres
+nows
+nroff
+nroff's
+nuances
+nuclear
+nucleotide
+nucleotide's
+nucleotides
+nucleus
+nucleuses
+nuisance
+nuisance's
+nuisances
+null
+nulled
+nullification
+nullified
+nullifier
+nullifiers
+nullifies
+nullify
+nullifying
+nulls
+numb
+numbed
+number
+numbered
+numberer
+numbering
+numberless
+numbers
+numbing
+numbingly
+numbly
+numbness
+numbs
+numeral
+numeral's
+numerally
+numerals
+numerator
+numerator's
+numerators
+numeric
+numerical
+numerically
+numerics
+numerous
+numerously
+numerousness
+nun
+nun's
+nuns
+nuptial
+nuptials
+nurse
+nurse's
+nursed
+nurser
+nurseries
+nursery
+nursery's
+nurses
+nursing
+nurture
+nurtured
+nurturer
+nurtures
+nurturing
+nut
+nut's
+nutrition
+nutrition's
+nuts
+nymph
+nymphs
+o'clock
+oak
+oaken
+oaks
+oar
+oar's
+oared
+oaring
+oars
+oasis
+oat
+oaten
+oater
+oath
+oaths
+oatmeal
+oats
+obedience
+obediences
+obedient
+obediently
+obey
+obeyed
+obeyer
+obeying
+obeys
+obfuscate
+obfuscated
+obfuscater
+obfuscates
+obfuscating
+obfuscation
+obfuscations
+object
+object's
+objected
+objecting
+objection
+objection's
+objectionable
+objectionableness
+objections
+objective
+objectively
+objectiveness
+objectives
+objector
+objector's
+objectors
+objects
+oblate
+oblately
+oblateness
+oblation
+oblations
+obligate
+obligated
+obligately
+obligates
+obligating
+obligation
+obligation's
+obligations
+obligatory
+oblige
+obliged
+obliger
+obliges
+obliging
+obligingly
+obligingness
+oblique
+obliquely
+obliqueness
+obliterate
+obliterated
+obliterates
+obliterating
+obliteration
+obliterations
+obliterative
+obliteratively
+oblivion
+oblivions
+oblivious
+obliviously
+obliviousness
+oblong
+oblongly
+oblongness
+obscene
+obscenely
+obscure
+obscured
+obscurely
+obscureness
+obscurer
+obscures
+obscuring
+obscurities
+obscurity
+observable
+observance
+observance's
+observances
+observant
+observantly
+observation
+observation's
+observations
+observatories
+observatory
+observe
+observed
+observer
+observers
+observes
+observing
+observingly
+obsession
+obsession's
+obsessions
+obsolescence
+obsolete
+obsoleted
+obsoletely
+obsoleteness
+obsoletes
+obsoleting
+obstacle
+obstacle's
+obstacles
+obstinacy
+obstinate
+obstinately
+obstinateness
+obstruct
+obstructed
+obstructer
+obstructing
+obstruction
+obstruction's
+obstructionist
+obstructions
+obstructive
+obstructively
+obstructiveness
+obstructs
+obtain
+obtainable
+obtainably
+obtained
+obtainer
+obtaining
+obtains
+obviate
+obviated
+obviates
+obviating
+obviation
+obviations
+obvious
+obviously
+obviousness
+occasion
+occasional
+occasionally
+occasioned
+occasioning
+occasionings
+occasions
+occlude
+occluded
+occludes
+occluding
+occlusion
+occlusion's
+occlusions
+occupancies
+occupancy
+occupant
+occupant's
+occupants
+occupation
+occupation's
+occupational
+occupationally
+occupations
+occupied
+occupier
+occupiers
+occupies
+occupy
+occupying
+occur
+occurred
+occurrence
+occurrence's
+occurrences
+occurring
+occurs
+ocean
+ocean's
+oceans
+octal
+octals
+octave
+octaves
+octopus
+odd
+odder
+oddest
+oddities
+oddity
+oddity's
+oddly
+oddness
+odds
+ode
+ode's
+oded
+oder
+odes
+odious
+odiously
+odiousness
+odorous
+odorously
+odorousness
+of
+off
+offend
+offended
+offender
+offenders
+offending
+offends
+offensive
+offensively
+offensiveness
+offensives
+offer
+offered
+offerer
+offerers
+offering
+offerings
+offers
+office
+office's
+officer
+officer's
+officered
+officers
+offices
+official
+official's
+officially
+officials
+officiate
+officiated
+officiates
+officiating
+officiation
+officiations
+officio
+officious
+officiously
+officiousness
+offing
+offs
+offset
+offset's
+offsets
+offspring
+offsprings
+oft
+often
+oftener
+oftentimes
+oh
+oil
+oilcloth
+oiled
+oiler
+oilers
+oilier
+oiliest
+oiliness
+oiling
+oils
+oily
+ointment
+ointments
+okay
+okay's
+okays
+old
+olden
+older
+oldest
+oldness
+olive
+olive's
+oliver
+olives
+omen
+omen's
+omens
+ominous
+ominously
+ominousness
+omission
+omission's
+omissions
+omit
+omits
+omitted
+omitting
+omnipresent
+omnipresently
+omniscient
+omnisciently
+omnivore
+on
+onanism
+once
+oncer
+one
+one's
+oneness
+oner
+onerous
+onerously
+onerousness
+ones
+oneself
+ongoing
+onion
+onions
+online
+onliness
+only
+ons
+onset
+onset's
+onsets
+onto
+onward
+onwards
+oops
+ooze
+oozed
+oozes
+oozing
+opacities
+opacity
+opal
+opal's
+opals
+opaque
+opaquely
+opaqueness
+opcode
+opcode's
+opcodes
+open
+opened
+opener
+openers
+openest
+opening
+opening's
+openings
+openly
+openness
+opens
+opera
+opera's
+operable
+operand
+operand's
+operandi
+operands
+operas
+operate
+operated
+operates
+operating
+operation
+operational
+operationally
+operations
+operative
+operatively
+operativeness
+operatives
+operator
+operator's
+operators
+opiate
+opiates
+opinion
+opinion's
+opinions
+opium
+opponent
+opponent's
+opponents
+opportune
+opportunely
+opportunism
+opportunistic
+opportunistically
+opportunities
+opportunity
+opportunity's
+oppose
+opposed
+opposer
+opposes
+opposing
+opposite
+oppositely
+oppositeness
+opposites
+opposition
+oppositions
+oppress
+oppressed
+oppresses
+oppressing
+oppression
+oppressive
+oppressively
+oppressiveness
+oppressor
+oppressor's
+oppressors
+opt
+opted
+optic
+optical
+optically
+optics
+optimal
+optimality
+optimally
+optimism
+optimistic
+optimistically
+optimum
+opting
+option
+option's
+optional
+optionally
+options
+opts
+or
+or's
+oracle
+oracle's
+oracles
+oral
+orally
+orals
+orange
+orange's
+oranges
+oration
+oration's
+orations
+orator
+orator's
+oratories
+orators
+oratory
+oratory's
+orb
+orbit
+orbital
+orbitally
+orbitals
+orbited
+orbiter
+orbiters
+orbiting
+orbits
+orchard
+orchard's
+orchards
+orchestra
+orchestra's
+orchestras
+orchid
+orchid's
+orchids
+ordain
+ordained
+ordainer
+ordaining
+ordains
+ordeal
+ordeals
+order
+ordered
+orderer
+ordering
+orderings
+orderlies
+orderliness
+orderly
+orders
+ordinal
+ordinance
+ordinance's
+ordinances
+ordinaries
+ordinarily
+ordinariness
+ordinary
+ordinate
+ordinated
+ordinates
+ordinating
+ordination
+ordinations
+ore
+ore's
+ores
+organ
+organ's
+organic
+organics
+organism
+organism's
+organisms
+organist
+organist's
+organists
+organs
+orgies
+orgy
+orgy's
+orient
+orientation
+orientation's
+orientations
+oriented
+orienting
+orients
+orifice
+orifice's
+orifices
+origin
+origin's
+original
+originality
+originally
+originals
+originate
+originated
+originates
+originating
+origination
+originations
+originative
+originatively
+originator
+originator's
+originators
+origins
+orion
+orly
+ornament
+ornamental
+ornamentally
+ornamentation
+ornamentations
+ornamented
+ornamenting
+ornaments
+orphan
+orphaned
+orphaning
+orphans
+orthodox
+orthodoxes
+orthodoxly
+orthogonal
+orthogonality
+orthogonally
+oscillate
+oscillated
+oscillates
+oscillating
+oscillation
+oscillation's
+oscillations
+oscillator
+oscillator's
+oscillators
+oscillatory
+oscilloscope
+oscilloscope's
+oscilloscopes
+ostrich
+ostrich's
+ostriches
+other
+other's
+otherness
+others
+otherwise
+otter
+otter's
+otters
+ought
+oughts
+ounce
+ounces
+our
+ours
+ourself
+ourselves
+out
+outbreak
+outbreak's
+outbreaks
+outburst
+outburst's
+outbursts
+outcast
+outcast's
+outcasts
+outcome
+outcome's
+outcomes
+outcries
+outcry
+outdoor
+outdoors
+outed
+outer
+outermost
+outfit
+outfit's
+outfits
+outgoing
+outgoingness
+outgoings
+outgrew
+outgrow
+outgrowing
+outgrown
+outgrows
+outgrowth
+outing
+outing's
+outings
+outlast
+outlasts
+outlaw
+outlawed
+outlawing
+outlaws
+outlay
+outlay's
+outlays
+outlet
+outlet's
+outlets
+outline
+outlined
+outlines
+outlining
+outlive
+outlived
+outlives
+outliving
+outlook
+outness
+outperform
+outperformed
+outperforming
+outperforms
+outpost
+outpost's
+outposts
+output
+output's
+outputs
+outputting
+outrage
+outraged
+outrageous
+outrageously
+outrageousness
+outrages
+outraging
+outright
+outrightly
+outrun
+outruns
+outs
+outset
+outside
+outsider
+outsider's
+outsiderness
+outsiders
+outskirts
+outstanding
+outstandingly
+outstretched
+outstrip
+outstripped
+outstripping
+outstrips
+outvote
+outvoted
+outvotes
+outvoting
+outward
+outwardly
+outwardness
+outwards
+outweigh
+outweighed
+outweighing
+outweighs
+outwit
+outwits
+outwitted
+outwitting
+oval
+oval's
+ovally
+ovalness
+ovals
+ovaries
+ovary
+ovary's
+oven
+oven's
+ovens
+over
+overall
+overall's
+overalls
+overblown
+overboard
+overcame
+overcast
+overcasting
+overcoat
+overcoat's
+overcoating
+overcoats
+overcome
+overcomer
+overcomes
+overcoming
+overcrowd
+overcrowded
+overcrowding
+overcrowds
+overdone
+overdose
+overdose's
+overdosed
+overdoses
+overdosing
+overdraft
+overdraft's
+overdrafts
+overdraw
+overdrawing
+overdrawn
+overdraws
+overdrew
+overdue
+overemphasis
+overestimate
+overestimated
+overestimates
+overestimating
+overestimation
+overestimations
+overflow
+overflowed
+overflowing
+overflows
+overhang
+overhanging
+overhangs
+overhaul
+overhauled
+overhauler
+overhauling
+overhaulings
+overhauls
+overhead
+overheads
+overhear
+overheard
+overhearer
+overhearing
+overhears
+overing
+overjoy
+overjoyed
+overkill
+overkill's
+overlaid
+overland
+overlap
+overlap's
+overlapped
+overlapping
+overlaps
+overlay
+overlaying
+overlays
+overload
+overloaded
+overloading
+overloads
+overlook
+overlooked
+overlooking
+overlooks
+overly
+overlying
+overnight
+overnighter
+overnighters
+overnights
+overpower
+overpowered
+overpowering
+overpoweringly
+overpowers
+overprint
+overprinted
+overprinting
+overprints
+overproduction
+overridden
+override
+overrider
+overrides
+overriding
+overrode
+overrule
+overruled
+overrules
+overruling
+overrun
+overruns
+overs
+overseas
+oversee
+overseeing
+overseer
+overseers
+oversees
+overshadow
+overshadowed
+overshadowing
+overshadows
+overshoot
+overshooting
+overshoots
+overshot
+oversight
+oversight's
+oversights
+oversimplification
+oversimplifications
+oversimplified
+oversimplifies
+oversimplify
+oversimplifying
+overstate
+overstated
+overstatement
+overstatement's
+overstatements
+overstates
+overstating
+overstocks
+overt
+overtake
+overtaken
+overtaker
+overtakers
+overtakes
+overtaking
+overthrew
+overthrow
+overthrowing
+overthrown
+overthrows
+overtime
+overtly
+overtness
+overtone
+overtone's
+overtones
+overtook
+overture
+overture's
+overtures
+overturn
+overturned
+overturning
+overturns
+overuse
+overview
+overview's
+overviews
+overweight
+overwhelm
+overwhelmed
+overwhelming
+overwhelmingly
+overwhelms
+overwork
+overworked
+overworking
+overworks
+overwrite
+overwrites
+overwriting
+overwritten
+overwrote
+overzealous
+overzealousness
+ovum
+owe
+owed
+owes
+owing
+owl
+owl's
+owler
+owls
+own
+owned
+owner
+owner's
+owners
+ownership
+ownerships
+owning
+owns
+ox
+oxen
+oxidation
+oxide
+oxide's
+oxides
+oxygen
+oxygens
+oyster
+oyster's
+oystering
+oysters
+pa
+pace
+pace's
+paced
+pacer
+pacers
+paces
+pacific
+pacification
+pacifications
+pacified
+pacifier
+pacifies
+pacify
+pacifying
+pacing
+pack
+package
+packaged
+packager
+packagers
+packages
+packaging
+packagings
+packed
+packer
+packers
+packet
+packet's
+packeted
+packeting
+packets
+packing
+packs
+pact
+pact's
+pacts
+pad
+pad's
+padded
+paddies
+padding
+paddings
+paddle
+paddled
+paddler
+paddles
+paddling
+paddy
+pads
+pagan
+pagan's
+pagans
+page
+page's
+pageant
+pageant's
+pageants
+paged
+pager
+pager's
+pagers
+pages
+paginate
+paginated
+paginates
+paginating
+pagination
+paginations
+paging
+paid
+pail
+pail's
+pails
+pain
+pained
+painful
+painfully
+painfulness
+paining
+painless
+painlessly
+painlessness
+pains
+painstaking
+painstakingly
+paint
+painted
+painter
+painterliness
+painterly
+painters
+painting
+paintings
+paints
+pair
+paired
+pairing
+pairings
+pairs
+pairwise
+pal
+pal's
+palace
+palace's
+palaces
+palate
+palate's
+palates
+pale
+paled
+palely
+paleness
+paler
+pales
+palest
+palfrey
+paling
+pall
+palliate
+palliation
+palliative
+palliatively
+palliatives
+pallid
+pallidly
+pallidness
+palling
+pally
+palm
+palmed
+palmer
+palming
+palms
+pals
+pamphlet
+pamphlet's
+pamphlets
+pan
+pan's
+panacea
+panacea's
+panaceas
+pancake
+pancake's
+pancaked
+pancakes
+pancaking
+pancreas
+panda
+panda's
+pandas
+pandemonium
+pander
+pandered
+panderer
+pandering
+panders
+pane
+pane's
+panel
+panelist
+panelist's
+panelists
+panels
+panes
+pang
+pang's
+pangs
+panic
+panic's
+panics
+panned
+panning
+pans
+pansies
+pansy
+pansy's
+pant
+panted
+panther
+panther's
+panthers
+panties
+panting
+pantries
+pantry
+pantry's
+pants
+panty
+papa
+papal
+papally
+paper
+paper's
+paperback
+paperback's
+paperbacks
+papered
+paperer
+paperers
+papering
+paperings
+papers
+paperwork
+paprika
+par
+parachute
+parachute's
+parachuted
+parachuter
+parachutes
+parachuting
+parade
+paraded
+parader
+parades
+paradigm
+paradigm's
+paradigms
+parading
+paradise
+paradox
+paradox's
+paradoxes
+paradoxical
+paradoxically
+paradoxicalness
+paraffin
+paraffins
+paragon
+paragon's
+paragons
+paragraph
+paragraphed
+paragrapher
+paragraphing
+paragraphs
+parallax
+parallax's
+parallel
+parallelism
+parallelogram
+parallelogram's
+parallelograms
+parallels
+paralysis
+parameter
+parameter's
+parameterless
+parameters
+parametric
+paramilitary
+paramount
+paranoia
+paranoid
+parapet
+parapet's
+parapeted
+parapets
+paraphrase
+paraphrased
+paraphraser
+paraphrases
+paraphrasing
+parasite
+parasite's
+parasites
+parasitic
+parasitics
+parcel
+parcels
+parch
+parched
+parchment
+pardon
+pardonable
+pardonableness
+pardonably
+pardoned
+pardoner
+pardoners
+pardoning
+pardons
+pare
+parent
+parent's
+parentage
+parental
+parentally
+parentheses
+parenthesis
+parenthetical
+parenthetically
+parenthood
+parenting
+parents
+parer
+pares
+paring
+parings
+parish
+parish's
+parishes
+parities
+parity
+park
+parked
+parker
+parkers
+parking
+parks
+parliament
+parliament's
+parliamentary
+parliaments
+parole
+paroled
+paroles
+paroling
+parried
+parrot
+parroting
+parrots
+parry
+parrying
+pars
+parse
+parsed
+parser
+parser's
+parsers
+parses
+parsimony
+parsing
+parsings
+parsley
+parson
+parson's
+parsons
+part
+partake
+partaker
+partakes
+partaking
+parted
+parter
+parters
+partial
+partiality
+partially
+partials
+participant
+participant's
+participants
+participate
+participated
+participates
+participating
+participation
+participations
+participative
+participatory
+particle
+particle's
+particles
+particular
+particularly
+particulars
+partied
+parties
+parting
+partings
+partisan
+partisan's
+partisans
+partition
+partitioned
+partitioner
+partitioning
+partitions
+partly
+partner
+partner's
+partnered
+partnering
+partners
+partnership
+partnerships
+partridge
+partridge's
+partridges
+parts
+party
+party's
+partying
+pas
+pass
+passage
+passage's
+passaged
+passages
+passageway
+passaging
+passe
+passed
+passenger
+passenger's
+passengerly
+passengers
+passer
+passers
+passes
+passing
+passion
+passionate
+passionately
+passionateness
+passions
+passive
+passively
+passiveness
+passives
+passivity
+passport
+passport's
+passports
+password
+password's
+passworded
+passwords
+past
+past's
+paste
+pasted
+pastes
+pastime
+pastime's
+pastimes
+pasting
+pastness
+pastor
+pastor's
+pastoral
+pastorally
+pastoralness
+pastors
+pastries
+pastry
+pasts
+pasture
+pasture's
+pastured
+pasturer
+pastures
+pasturing
+pat
+pat's
+patch
+patched
+patcher
+patches
+patching
+patchwork
+patchworker
+patchworkers
+pated
+paten
+patent
+patentable
+patented
+patenter
+patenters
+patenting
+patently
+patents
+pater
+paternal
+paternally
+path
+pathetic
+pathname
+pathname's
+pathnames
+pathological
+pathologically
+pathologies
+pathologist
+pathologist's
+pathologists
+pathology
+pathos
+paths
+pathway
+pathway's
+pathways
+patience
+patient
+patient's
+patiently
+patients
+patriarch
+patriarchs
+patrician
+patrician's
+patricians
+patriot
+patriot's
+patriotic
+patriotism
+patriots
+patrol
+patrol's
+patrols
+patron
+patron's
+patronage
+patronly
+patrons
+pats
+patter
+pattered
+patterer
+pattering
+patterings
+pattern
+patterned
+patterning
+patterns
+patters
+patties
+patty
+patty's
+paucity
+pause
+paused
+pauses
+pausing
+pave
+paved
+pavement
+pavement's
+pavements
+paver
+paves
+pavilion
+pavilion's
+pavilions
+paving
+paw
+pawed
+pawing
+pawn
+pawn's
+pawned
+pawner
+pawning
+pawns
+paws
+pay
+payable
+paycheck
+paycheck's
+paychecks
+payed
+payer
+payer's
+payers
+paying
+payment
+payment's
+payments
+payoff
+payoff's
+payoffs
+payroll
+payrolls
+pays
+pea
+pea's
+peace
+peaceable
+peaceableness
+peaceful
+peacefully
+peacefulness
+peaces
+peach
+peach's
+peaches
+peacock
+peacock's
+peacocks
+peak
+peaked
+peakedness
+peaking
+peaks
+peal
+pealed
+pealing
+peals
+peanut
+peanut's
+peanuts
+pear
+pearl
+pearl's
+pearler
+pearlier
+pearls
+pearly
+pears
+peas
+peasant
+peasant's
+peasantry
+peasants
+peat
+pebble
+pebble's
+pebbled
+pebbles
+pebbling
+peck
+pecked
+pecker
+pecking
+pecks
+peculiar
+peculiarities
+peculiarity
+peculiarity's
+peculiarly
+peculiars
+pedagogic
+pedagogical
+pedagogically
+pedagogics
+pedantic
+peddler
+peddler's
+peddlers
+pedestal
+pedestals
+pedestrian
+pedestrian's
+pedestrians
+pediatric
+pediatrics
+peek
+peeked
+peeking
+peeks
+peel
+peeled
+peeler
+peeler's
+peeling
+peels
+peep
+peeped
+peeper
+peepers
+peeping
+peeps
+peer
+peered
+peering
+peerless
+peerlessly
+peerlessness
+peers
+peeve
+peeve's
+peeved
+peevers
+peeves
+peeving
+peg
+peg's
+pegs
+pellet
+pellet's
+pelleted
+pelleting
+pellets
+pelt
+pelter
+pelting
+pelts
+pen
+penalties
+penalty
+penalty's
+penance
+penanced
+penances
+penancing
+pence
+pencil
+pencils
+pend
+pended
+pending
+pends
+pendulum
+pendulum's
+pendulums
+penetrate
+penetrated
+penetrates
+penetrating
+penetratingly
+penetration
+penetrations
+penetrative
+penetratively
+penetrativeness
+penetrator
+penetrator's
+penetrators
+penguin
+penguin's
+penguins
+peninsula
+peninsula's
+peninsulas
+penitent
+penitentiary
+penitently
+penned
+pennies
+penniless
+penning
+penny
+penny's
+pens
+pension
+pensioned
+pensioner
+pensioners
+pensioning
+pensions
+pensive
+pensively
+pensiveness
+pent
+pentagon
+pentagon's
+pentagons
+penthouse
+penthouse's
+penthouses
+people
+people's
+peopled
+peoples
+peopling
+pep
+pepper
+peppercorn
+peppercorn's
+peppercorns
+peppered
+pepperer
+peppering
+peppers
+per
+perceivable
+perceivably
+perceive
+perceived
+perceiver
+perceivers
+perceives
+perceiving
+percent
+percentage
+percentages
+percentile
+percentiles
+percents
+perceptible
+perceptibly
+perception
+perceptions
+perceptive
+perceptively
+perceptiveness
+perceptual
+perceptually
+perch
+perchance
+perched
+perches
+perching
+percolate
+percolated
+percolates
+percolating
+percolation
+percutaneous
+percutaneously
+peremptoriness
+peremptory
+perennial
+perennially
+perennials
+perfect
+perfected
+perfecter
+perfecting
+perfection
+perfectionist
+perfectionist's
+perfectionists
+perfections
+perfective
+perfectively
+perfectiveness
+perfectly
+perfectness
+perfects
+perforce
+perform
+performance
+performance's
+performances
+performed
+performer
+performers
+performing
+performs
+perfume
+perfumed
+perfumer
+perfumes
+perfuming
+perhaps
+peril
+peril's
+perilous
+perilously
+perilousness
+perils
+period
+period's
+periodic
+periodical
+periodically
+periodicals
+periods
+peripheral
+peripherally
+peripherals
+peripheries
+periphery
+periphery's
+perish
+perishable
+perishable's
+perishables
+perished
+perisher
+perishers
+perishes
+perishing
+perishingly
+permanence
+permanent
+permanently
+permanentness
+permanents
+permeate
+permeated
+permeates
+permeating
+permeation
+permeations
+permeative
+permissibility
+permissible
+permissibleness
+permissibly
+permission
+permissions
+permissive
+permissively
+permissiveness
+permit
+permit's
+permits
+permitted
+permitting
+permutation
+permutation's
+permutations
+permute
+permuted
+permutes
+permuting
+perpendicular
+perpendicularly
+perpendiculars
+perpetrate
+perpetrated
+perpetrates
+perpetrating
+perpetration
+perpetrations
+perpetrator
+perpetrator's
+perpetrators
+perpetual
+perpetually
+perpetuate
+perpetuated
+perpetuates
+perpetuating
+perpetuation
+perplex
+perplexed
+perplexedly
+perplexes
+perplexing
+perplexities
+perplexity
+persecute
+persecuted
+persecutes
+persecuting
+persecution
+persecutive
+persecutor
+persecutor's
+persecutors
+perseverance
+persevere
+persevered
+perseveres
+persevering
+persist
+persisted
+persistence
+persistent
+persistently
+persister
+persisting
+persists
+person
+person's
+personable
+personableness
+personage
+personage's
+personages
+personal
+personalities
+personality
+personality's
+personally
+personals
+personification
+personifications
+personified
+personifier
+personifies
+personify
+personifying
+personnel
+persons
+perspective
+perspective's
+perspectively
+perspectives
+perspicuous
+perspicuously
+perspicuousness
+perspiration
+perspirations
+persuadable
+persuade
+persuaded
+persuader
+persuaders
+persuades
+persuading
+persuasion
+persuasion's
+persuasions
+persuasive
+persuasively
+persuasiveness
+pertain
+pertained
+pertaining
+pertains
+pertinent
+pertinently
+perturb
+perturbation
+perturbation's
+perturbations
+perturbed
+perturbing
+perusal
+peruse
+perused
+peruser
+perusers
+peruses
+perusing
+pervade
+pervaded
+pervades
+pervading
+pervasive
+pervasively
+pervasiveness
+pervert
+perverted
+pervertedly
+pervertedness
+perverter
+perverting
+perverts
+pessimistic
+pest
+pester
+pestered
+pestering
+pesters
+pestilence
+pestilences
+pests
+pet
+petal
+petal's
+petals
+peter
+petered
+peters
+petition
+petitioned
+petitioner
+petitioning
+petitions
+petroleum
+pets
+petted
+petter
+petter's
+petters
+petticoat
+petticoat's
+petticoated
+petticoats
+pettier
+pettiest
+pettiness
+pettinesses
+petting
+petty
+pew
+pew's
+pews
+pewter
+pewterer
+phantom
+phantom's
+phantoms
+phase
+phased
+phaser
+phasers
+phases
+phasing
+pheasant
+pheasant's
+pheasants
+phenomena
+phenomenal
+phenomenally
+phenomenological
+phenomenologically
+phenomenologies
+phenomenology
+phenomenon
+philosopher
+philosopher's
+philosophers
+philosophic
+philosophical
+philosophically
+philosophies
+philosophy
+philosophy's
+phone
+phone's
+phoned
+phoneme
+phoneme's
+phonemes
+phonemic
+phonemics
+phones
+phonetic
+phonetics
+phoning
+phonograph
+phonographer
+phonographs
+phosphate
+phosphate's
+phosphates
+phosphoric
+photo
+photo's
+photocopied
+photocopier
+photocopies
+photocopy
+photocopying
+photograph
+photographed
+photographer
+photographers
+photographic
+photographing
+photographs
+photography
+photos
+phrase
+phrased
+phrases
+phrasing
+phrasings
+phyla
+phylum
+physic
+physical
+physically
+physicalness
+physicals
+physician
+physician's
+physicians
+physicist
+physicist's
+physicists
+physics
+physiological
+physiologically
+physiology
+physique
+physiqued
+pi
+piano
+piano's
+pianos
+piazza
+piazza's
+piazzas
+picayune
+pick
+picked
+picker
+pickering
+pickers
+picket
+picketed
+picketer
+picketers
+picketing
+pickets
+picking
+pickings
+pickle
+pickled
+pickles
+pickling
+picks
+pickup
+pickup's
+pickups
+picnic
+picnic's
+picnics
+pictorial
+pictorially
+pictorialness
+picture
+pictured
+pictures
+picturesque
+picturesquely
+picturesqueness
+picturing
+pie
+piece
+pieced
+piecemeal
+piecer
+pieces
+piecewise
+piecing
+pied
+pier
+pierce
+pierced
+pierces
+piercing
+piercingly
+piers
+pies
+pieties
+piety
+pig
+pig's
+pigeon
+pigeon's
+pigeons
+pigment
+pigmented
+pigments
+pigs
+pike
+pike's
+piked
+piker
+pikes
+piking
+pile
+piled
+pilers
+piles
+pilferage
+pilgrim
+pilgrim's
+pilgrimage
+pilgrimage's
+pilgrimages
+pilgrims
+piling
+pilings
+pill
+pill's
+pillage
+pillaged
+pillager
+pillages
+pillaging
+pillar
+pillared
+pillars
+pillow
+pillow's
+pillows
+pills
+pilot
+pilot's
+piloted
+piloting
+pilots
+pin
+pin's
+pinch
+pinched
+pincher
+pinches
+pinching
+pine
+pineapple
+pineapple's
+pineapples
+pined
+pines
+ping
+pinger
+pinging
+pining
+pinion
+pinioned
+pinions
+pink
+pinked
+pinker
+pinkest
+pinking
+pinkly
+pinkness
+pinks
+pinnacle
+pinnacle's
+pinnacled
+pinnacles
+pinnacling
+pinned
+pinning
+pinnings
+pinpoint
+pinpointed
+pinpointing
+pinpoints
+pins
+pint
+pint's
+pinter
+pints
+pioneer
+pioneered
+pioneering
+pioneers
+pious
+piously
+piousness
+pipe
+piped
+pipeline
+pipelined
+pipelines
+pipelining
+piper
+pipers
+pipes
+piping
+pipingly
+pipings
+pique
+piqued
+piquing
+pirate
+pirate's
+pirated
+pirates
+pirating
+piss
+pissed
+pisser
+pisses
+pissing
+pistil
+pistil's
+pistils
+pistol
+pistol's
+pistols
+piston
+piston's
+pistons
+pit
+pit's
+pitch
+pitched
+pitcher
+pitchers
+pitches
+pitching
+piteous
+piteously
+piteousness
+pitfall
+pitfall's
+pitfalls
+pith
+pithed
+pithes
+pithier
+pithiest
+pithiness
+pithing
+pithy
+pitiable
+pitiableness
+pitied
+pitier
+pitiers
+pities
+pitiful
+pitifully
+pitifulness
+pitiless
+pitilessly
+pitilessness
+pits
+pitted
+pity
+pitying
+pityingly
+pivot
+pivotal
+pivotally
+pivoted
+pivoting
+pivots
+pixel
+pixel's
+pixels
+placard
+placard's
+placards
+place
+placed
+placement
+placement's
+placements
+placer
+places
+placid
+placidly
+placidness
+placing
+plague
+plagued
+plaguer
+plagues
+plaguing
+plaid
+plaid's
+plaided
+plaids
+plain
+plainer
+plainest
+plainly
+plainness
+plains
+plaintiff
+plaintiff's
+plaintiffs
+plaintive
+plaintively
+plaintiveness
+plait
+plait's
+plaiter
+plaiting
+plaits
+plan
+plan's
+planar
+planarity
+plane
+plane's
+planed
+planer
+planers
+planes
+planet
+planet's
+planetary
+planets
+planing
+plank
+planking
+planks
+planned
+planner
+planner's
+planners
+planning
+plans
+plant
+plantation
+plantation's
+plantations
+planted
+planter
+planters
+planting
+plantings
+plants
+plasma
+plaster
+plastered
+plasterer
+plasterers
+plastering
+plasters
+plastic
+plasticity
+plasticly
+plastics
+plate
+plateau
+plateau's
+plateaus
+plated
+platelet
+platelet's
+platelets
+platen
+platen's
+platens
+plater
+platers
+plates
+platform
+platform's
+platforms
+plating
+platings
+platinum
+platter
+platter's
+platters
+plausibility
+plausible
+plausibleness
+play
+playable
+played
+player
+player's
+players
+playful
+playfully
+playfulness
+playground
+playground's
+playgrounds
+playing
+playmate
+playmate's
+playmates
+plays
+plaything
+plaything's
+playthings
+playwright
+playwright's
+playwrights
+plea
+plea's
+plead
+pleaded
+pleader
+pleading
+pleadingly
+pleadings
+pleads
+pleas
+pleasant
+pleasantly
+pleasantness
+please
+pleased
+pleasely
+pleaser
+pleases
+pleasing
+pleasingly
+pleasingness
+pleasurable
+pleasurableness
+pleasure
+pleasured
+pleasures
+pleasuring
+plebeian
+plebeianly
+plebiscite
+plebiscite's
+plebiscites
+pledge
+pledged
+pledger
+pledges
+pledging
+plenary
+plenteous
+plenteously
+plenteousness
+plenties
+plentiful
+plentifully
+plentifulness
+plenty
+pleurisy
+plication
+plied
+plier
+pliers
+plies
+plight
+plighter
+plod
+plods
+plot
+plot's
+plots
+plotted
+plotter
+plotter's
+plotters
+plotting
+ploy
+ploy's
+ploys
+pluck
+plucked
+plucker
+pluckier
+pluckiness
+plucking
+plucky
+plug
+plug's
+plugged
+plugging
+plugs
+plum
+plum's
+plumage
+plumaged
+plumages
+plumb
+plumb's
+plumbed
+plumber
+plumbers
+plumbing
+plumbs
+plume
+plumed
+plumes
+pluming
+plummeting
+plump
+plumped
+plumpen
+plumper
+plumply
+plumpness
+plums
+plunder
+plundered
+plunderer
+plunderers
+plundering
+plunders
+plunge
+plunged
+plunger
+plungers
+plunges
+plunging
+plural
+plurality
+plurally
+plurals
+plus
+pluses
+plush
+plushly
+plushness
+ply
+plying
+pneumonia
+poach
+poached
+poacher
+poachers
+poaches
+poaching
+pocket
+pocketbook
+pocketbook's
+pocketbooks
+pocketed
+pocketing
+pockets
+pod
+pod's
+pods
+poem
+poem's
+poems
+poet
+poet's
+poetic
+poetical
+poetically
+poeticalness
+poetics
+poetries
+poetry
+poetry's
+poets
+point
+pointed
+pointedly
+pointedness
+pointer
+pointers
+pointier
+pointiest
+pointing
+pointless
+pointlessly
+pointlessness
+points
+pointy
+poise
+poised
+poises
+poising
+poison
+poisoned
+poisoner
+poisoning
+poisonous
+poisonously
+poisonousness
+poisons
+poke
+poked
+poker
+pokes
+poking
+polar
+polarities
+polarity
+polarity's
+pole
+poled
+polemic
+polemics
+poler
+poles
+police
+police's
+policed
+policeman
+policeman's
+policemen
+policemen's
+polices
+policies
+policing
+policy
+policy's
+poling
+polish
+polished
+polisher
+polishers
+polishes
+polishing
+polite
+politely
+politeness
+politer
+politest
+politic
+political
+politically
+politician
+politician's
+politicians
+politics
+poll
+polled
+pollen
+poller
+polling
+polls
+pollute
+polluted
+polluter
+pollutes
+polluting
+pollution
+pollutive
+polo
+polygon
+polygon's
+polygons
+polymer
+polymer's
+polymers
+polynomial
+polynomial's
+polynomials
+polyphonic
+pomp
+pompous
+pompously
+pompousness
+pond
+ponder
+pondered
+ponderer
+pondering
+ponderous
+ponderously
+ponderousness
+ponders
+ponds
+ponies
+pony
+pony's
+poof
+pool
+pooled
+pooling
+pools
+poor
+poorer
+poorest
+poorly
+poorness
+pop
+pop's
+pope
+pope's
+popes
+poplar
+popped
+poppied
+poppies
+popping
+poppy
+poppy's
+pops
+populace
+popular
+popularity
+popularly
+populate
+populated
+populates
+populating
+population
+populations
+populous
+populously
+populousness
+porcelain
+porch
+porch's
+porches
+porcupine
+porcupine's
+porcupines
+pore
+pored
+pores
+poring
+pork
+porker
+porn
+pornographic
+porridge
+port
+portability
+portable
+portables
+portably
+portal
+portal's
+portals
+portamento
+portamento's
+ported
+portend
+portended
+portending
+portends
+porter
+portering
+porters
+porting
+portion
+portion's
+portioned
+portioning
+portions
+portlier
+portliness
+portly
+portrait
+portrait's
+portraits
+portray
+portrayed
+portrayer
+portraying
+portrays
+ports
+pose
+posed
+poser
+posers
+poses
+posing
+posit
+posited
+positing
+position
+positional
+positioned
+positioning
+positions
+positive
+positively
+positiveness
+positives
+posits
+possess
+possessed
+possessedly
+possessedness
+possesses
+possessing
+possession
+possession's
+possessional
+possessions
+possessive
+possessive's
+possessively
+possessiveness
+possessives
+possessor
+possessor's
+possessors
+possibilities
+possibility
+possibility's
+possible
+possibles
+possibly
+possum
+possum's
+possums
+post
+postage
+postal
+postcard
+postcard's
+postcards
+postcondition
+postconditions
+posted
+poster
+poster's
+posterior
+posteriorly
+posterity
+posters
+posting
+postings
+postman
+postmaster
+postmaster's
+postmasters
+postpone
+postponed
+postponer
+postpones
+postponing
+posts
+postscript
+postscript's
+postscripts
+postulate
+postulated
+postulates
+postulating
+postulation
+postulations
+posture
+posture's
+postured
+posturer
+postures
+posturing
+pot
+pot's
+potash
+potassium
+potato
+potatoes
+potent
+potentate
+potentate's
+potentates
+potential
+potentialities
+potentiality
+potentially
+potentials
+potentiating
+potentiometer
+potentiometer's
+potentiometers
+potently
+pots
+potted
+potter
+potter's
+potterer
+potteries
+potters
+pottery
+potting
+pouch
+pouch's
+pouched
+pouches
+poultry
+pounce
+pounced
+pounces
+pouncing
+pound
+pounded
+pounder
+pounders
+pounding
+pounds
+pour
+poured
+pourer
+pourers
+pouring
+pouringly
+pours
+pout
+pouted
+pouter
+pouting
+pouts
+poverty
+powder
+powdered
+powderer
+powdering
+powders
+power
+powered
+powerful
+powerfully
+powerfulness
+powering
+powerless
+powerlessly
+powerlessness
+powers
+pox
+poxes
+practicable
+practicableness
+practicably
+practical
+practicalities
+practicality
+practically
+practicalness
+practice
+practice's
+practices
+practitioner
+practitioner's
+practitioners
+pragmatic
+pragmatically
+pragmatics
+prairie
+prairies
+praise
+praised
+praiser
+praisers
+praises
+praising
+praisingly
+prance
+pranced
+prancer
+prances
+prancing
+prancingly
+prank
+prank's
+pranks
+prate
+prated
+prater
+prates
+prating
+pratingly
+pray
+prayed
+prayer
+prayer's
+prayers
+praying
+prays
+preach
+preached
+preacher
+preachers
+preaches
+preaching
+preachingly
+preallocate
+preallocated
+preallocates
+preallocating
+preallocation
+preallocation's
+preallocations
+preallocator
+preallocators
+preassign
+preassigned
+preassigning
+preassigns
+precarious
+precariously
+precariousness
+precaution
+precaution's
+precautioned
+precautioning
+precautions
+precede
+preceded
+precedence
+precedence's
+precedences
+precedent
+precedented
+precedents
+precedes
+preceding
+precept
+precept's
+preceptive
+preceptively
+precepts
+precinct
+precinct's
+precincts
+precious
+preciously
+preciousness
+precipice
+precipitate
+precipitated
+precipitately
+precipitateness
+precipitates
+precipitating
+precipitation
+precipitative
+precipitous
+precipitously
+precipitousness
+precise
+precisely
+preciseness
+precision
+precisions
+preclude
+precluded
+precludes
+precluding
+precocious
+precociously
+precociousness
+preconceive
+preconceived
+preconception
+preconception's
+preconceptions
+precondition
+preconditioned
+preconditions
+precursor
+precursor's
+precursors
+predate
+predated
+predates
+predating
+predation
+predecessor
+predecessor's
+predecessors
+predefine
+predefined
+predefines
+predefining
+predefinition
+predefinition's
+predefinitions
+predetermine
+predetermined
+predeterminer
+predetermines
+predetermining
+predicament
+predicate
+predicated
+predicates
+predicating
+predication
+predications
+predicative
+predict
+predictability
+predictable
+predictably
+predicted
+predicting
+prediction
+prediction's
+predictions
+predictive
+predictively
+predictor
+predictors
+predicts
+predominant
+predominantly
+predominate
+predominated
+predominately
+predominates
+predominating
+predomination
+preempt
+preempted
+preempting
+preemption
+preemptive
+preemptively
+preempts
+preface
+prefaced
+prefacer
+prefaces
+prefacing
+prefer
+preferable
+preferableness
+preferably
+preference
+preference's
+preferences
+preferential
+preferentially
+preferred
+preferring
+prefers
+prefix
+prefixed
+prefixes
+prefixing
+pregnant
+pregnantly
+prehistoric
+prejudge
+prejudged
+prejudger
+prejudice
+prejudiced
+prejudices
+prejudicing
+prelate
+preliminaries
+preliminary
+prelude
+prelude's
+preluded
+preluder
+preludes
+preluding
+premature
+prematurely
+prematureness
+prematurity
+premeditated
+premeditatedly
+premier
+premier's
+premiere
+premiered
+premieres
+premiering
+premiers
+premise
+premise's
+premised
+premises
+premising
+premium
+premium's
+premiums
+preoccupation
+preoccupations
+preoccupied
+preoccupies
+preoccupy
+preparation
+preparation's
+preparations
+preparative
+preparative's
+preparatively
+preparatives
+preparatory
+prepare
+prepared
+preparedly
+preparedness
+preparer
+prepares
+preparing
+prepend
+prepended
+prepender
+prependers
+prepending
+prepends
+preposition
+preposition's
+prepositional
+prepositionally
+prepositions
+preposterous
+preposterously
+preposterousness
+preprint
+preprinted
+preprinting
+preprints
+preprocessor
+preprocessors
+preproduction
+preprogrammed
+prerequisite
+prerequisite's
+prerequisites
+prerogative
+prerogative's
+prerogatived
+prerogatives
+prescribe
+prescribed
+prescriber
+prescribes
+prescribing
+prescription
+prescription's
+prescriptions
+prescriptive
+prescriptively
+preselect
+preselected
+preselecting
+preselects
+presence
+presence's
+presences
+present
+presentation
+presentation's
+presentations
+presented
+presenter
+presenters
+presenting
+presently
+presentness
+presents
+preservation
+preservations
+preservative
+preservative's
+preservatives
+preserve
+preserved
+preserver
+preservers
+preserves
+preserving
+preset
+presets
+preside
+presided
+presidency
+president
+president's
+presidential
+presidentially
+presidents
+presider
+presides
+presiding
+press
+pressed
+presser
+presses
+pressing
+pressingly
+pressings
+pressure
+pressured
+pressures
+pressuring
+prestige
+presumably
+presume
+presumed
+presumer
+presumes
+presuming
+presumingly
+presumption
+presumption's
+presumptions
+presumptuous
+presumptuously
+presumptuousness
+presuppose
+presupposed
+presupposes
+presupposing
+pretend
+pretended
+pretendedly
+pretender
+pretenders
+pretending
+pretends
+pretentious
+pretentiously
+pretentiousness
+pretext
+pretext's
+pretexts
+prettied
+prettier
+pretties
+prettiest
+prettily
+prettiness
+pretty
+prettying
+prevail
+prevailed
+prevailing
+prevailingly
+prevails
+prevalence
+prevalent
+prevalently
+prevent
+preventable
+preventably
+prevented
+preventer
+preventing
+prevention
+preventions
+preventive
+preventively
+preventiveness
+preventives
+prevents
+preview
+previewed
+previewer
+previewers
+previewing
+previews
+previous
+previously
+previousness
+prey
+preyed
+preyer
+preying
+preys
+price
+priced
+priceless
+pricer
+pricers
+prices
+pricing
+prick
+pricked
+pricker
+pricking
+pricklier
+prickliness
+prickly
+pricks
+pride
+prided
+prides
+priding
+pried
+prier
+pries
+priest
+priestliness
+priestly
+priests
+primacy
+primaries
+primarily
+primary
+primary's
+prime
+primed
+primely
+primeness
+primer
+primers
+primes
+primeval
+primevally
+priming
+primitive
+primitively
+primitiveness
+primitives
+primrose
+prince
+princelier
+princeliness
+princely
+princes
+princess
+princess's
+princesses
+principal
+principalities
+principality
+principality's
+principally
+principals
+principle
+principled
+principles
+print
+printable
+printably
+printed
+printer
+printers
+printing
+printout
+printouts
+prints
+prior
+priori
+priorities
+priority
+priority's
+priorly
+priors
+priory
+prism
+prism's
+prisms
+prison
+prisoner
+prisoner's
+prisoners
+prisons
+privacies
+privacy
+private
+privately
+privateness
+privates
+privation
+privations
+privative
+privatively
+privies
+privilege
+privileged
+privileges
+privy
+privy's
+prize
+prized
+prizer
+prizers
+prizes
+prizing
+pro
+pro's
+probabilistic
+probabilistically
+probabilities
+probability
+probable
+probably
+probate
+probated
+probates
+probating
+probation
+probationer
+probationers
+probative
+probe
+probed
+prober
+probes
+probing
+probings
+problem
+problem's
+problematic
+problematical
+problematically
+problems
+procedural
+procedurally
+procedure
+procedure's
+procedures
+proceed
+proceeded
+proceeder
+proceeding
+proceedings
+proceeds
+process
+process's
+processed
+processes
+processing
+procession
+processor
+processor's
+processors
+proclaim
+proclaimed
+proclaimer
+proclaimers
+proclaiming
+proclaims
+proclamation
+proclamation's
+proclamations
+proclivities
+proclivity
+proclivity's
+procrastinate
+procrastinated
+procrastinates
+procrastinating
+procrastination
+procrastinator
+procrastinator's
+procrastinators
+procure
+procured
+procurement
+procurement's
+procurements
+procurer
+procurers
+procures
+procuring
+prodigal
+prodigally
+prodigious
+prodigiously
+prodigiousness
+produce
+produced
+producer
+producers
+produces
+producible
+producing
+product
+product's
+production
+production's
+productions
+productive
+productively
+productiveness
+productivities
+productivity
+products
+profane
+profaned
+profanely
+profaneness
+profaner
+profaning
+profess
+professed
+professedly
+professes
+professing
+profession
+profession's
+professional
+professionalism
+professionalisms
+professionally
+professionals
+professions
+professor
+professor's
+professors
+proffer
+proffered
+proffering
+proffers
+proficiencies
+proficiency
+proficient
+proficiently
+profile
+profiled
+profiler
+profiler's
+profilers
+profiles
+profiling
+profit
+profit's
+profitability
+profitable
+profitableness
+profitably
+profited
+profiteer
+profiteer's
+profiteers
+profiter
+profiters
+profiting
+profits
+profound
+profoundest
+profoundly
+profoundness
+progeny
+program
+program's
+programmability
+programmable
+programmed
+programmer
+programmer's
+programmers
+programming
+programs
+progress
+progressed
+progresses
+progressing
+progression
+progression's
+progressions
+progressive
+progressively
+progressiveness
+prohibit
+prohibited
+prohibiter
+prohibiting
+prohibition
+prohibition's
+prohibitions
+prohibitive
+prohibitively
+prohibitiveness
+prohibits
+project
+project's
+projected
+projecting
+projection
+projection's
+projections
+projective
+projectively
+projector
+projector's
+projectors
+projects
+prolegomena
+proletariat
+proliferate
+proliferated
+proliferates
+proliferating
+proliferation
+proliferative
+prolific
+prolificness
+prolog
+prolog's
+prologs
+prologue
+prologue's
+prologues
+prolong
+prolonged
+prolonger
+prolonging
+prolongs
+promenade
+promenade's
+promenader
+promenades
+promenading
+prominence
+prominent
+prominently
+promiscuity
+promiscuity's
+promiscuous
+promiscuously
+promiscuousness
+promise
+promised
+promiser
+promises
+promising
+promisingly
+promontories
+promontory
+promote
+promoted
+promoter
+promoters
+promotes
+promoting
+promotion
+promotional
+promotions
+promotive
+promotiveness
+prompt
+prompted
+prompter
+prompters
+promptest
+prompting
+promptings
+promptly
+promptness
+prompts
+promulgate
+promulgated
+promulgates
+promulgating
+promulgation
+promulgations
+prone
+pronely
+proneness
+prong
+pronged
+prongs
+pronoun
+pronoun's
+pronounce
+pronounceable
+pronounced
+pronouncedly
+pronouncement
+pronouncement's
+pronouncements
+pronouncer
+pronounces
+pronouncing
+pronouns
+pronunciation
+pronunciation's
+pronunciations
+proof
+proof's
+proofed
+proofer
+proofing
+proofs
+prop
+propaganda
+propagate
+propagated
+propagates
+propagating
+propagation
+propagations
+propagative
+propel
+propelled
+propeller
+propeller's
+propellers
+propels
+propensities
+propensity
+proper
+properly
+properness
+propertied
+properties
+property
+prophecies
+prophecy
+prophecy's
+prophesied
+prophesier
+prophesies
+prophesy
+prophesying
+prophet
+prophet's
+prophetic
+prophets
+propitious
+propitiously
+propitiousness
+proponent
+proponent's
+proponents
+proportion
+proportional
+proportionally
+proportionately
+proportioned
+proportioner
+proportioning
+proportionment
+proportions
+proposal
+proposal's
+proposals
+propose
+proposed
+proposer
+proposers
+proposes
+proposing
+proposition
+propositional
+propositionally
+propositioned
+propositioning
+propositions
+propound
+propounded
+propounder
+propounding
+propounds
+proprietary
+proprietor
+proprietor's
+proprietors
+propriety
+props
+propulsion
+propulsion's
+propulsions
+pros
+prose
+prosecute
+prosecuted
+prosecutes
+prosecuting
+prosecution
+prosecutions
+proser
+prosing
+prosodic
+prosodics
+prospect
+prospected
+prospecting
+prospection
+prospection's
+prospections
+prospective
+prospectively
+prospectiveness
+prospectives
+prospector
+prospector's
+prospectors
+prospects
+prospectus
+prosper
+prospered
+prospering
+prosperity
+prosperous
+prosperously
+prosperousness
+prospers
+prostitution
+prostrate
+prostrated
+prostration
+protect
+protected
+protectedly
+protecting
+protection
+protection's
+protections
+protective
+protectively
+protectiveness
+protector
+protector's
+protectorate
+protectors
+protects
+protege
+protege's
+proteges
+protein
+protein's
+proteins
+protest
+protest's
+protestants
+protestation
+protestations
+protested
+protester
+protester's
+protesters
+protesting
+protestingly
+protests
+protocol
+protocol's
+protocols
+proton
+proton's
+protons
+protoplasm
+prototype
+prototype's
+prototyped
+prototypes
+prototypical
+prototypically
+prototyping
+protrude
+protruded
+protrudes
+protruding
+protrusion
+protrusion's
+protrusions
+proud
+prouder
+proudest
+proudly
+provability
+provable
+provableness
+provably
+prove
+proved
+proven
+provenly
+prover
+proverb
+proverb's
+proverbs
+provers
+proves
+provide
+provided
+providence
+provider
+providers
+provides
+providing
+province
+province's
+provinces
+provincial
+provincially
+proving
+provision
+provisional
+provisionally
+provisioned
+provisioner
+provisioning
+provisions
+provocation
+provoke
+provoked
+provokes
+provoking
+provokingly
+prow
+prow's
+prowess
+prowl
+prowled
+prowler
+prowlers
+prowling
+prowls
+prows
+proximal
+proximally
+proximate
+proximately
+proximateness
+proximity
+prudence
+prudent
+prudently
+prune
+pruned
+pruner
+pruners
+prunes
+pruning
+pry
+prying
+pryingly
+psalm
+psalm's
+psalms
+pseudo
+psyche
+psyche's
+psyches
+psychiatrist
+psychiatrist's
+psychiatrists
+psychiatry
+psychological
+psychologically
+psychologist
+psychologist's
+psychologists
+psychology
+psychosocial
+psychosocially
+pub
+pub's
+public
+publication
+publication's
+publications
+publicity
+publicly
+publicness
+publics
+publish
+published
+publisher
+publishers
+publishes
+publishing
+pubs
+pucker
+puckered
+puckering
+puckers
+pudding
+pudding's
+puddings
+puddle
+puddled
+puddler
+puddles
+puddling
+puff
+puffed
+puffer
+puffers
+puffing
+puffs
+pull
+pulled
+puller
+pulley
+pulley's
+pulleys
+pulling
+pullings
+pulls
+pulp
+pulper
+pulping
+pulpit
+pulpit's
+pulpits
+pulse
+pulsed
+pulser
+pulses
+pulsing
+pump
+pumped
+pumper
+pumping
+pumpkin
+pumpkin's
+pumpkins
+pumps
+pun
+pun's
+punch
+punched
+puncher
+puncher's
+punchers
+punches
+punching
+punchings
+punctual
+punctually
+punctualness
+punctuation
+puncture
+puncture's
+punctured
+punctures
+puncturing
+punier
+puniness
+punish
+punishable
+punished
+punisher
+punishes
+punishing
+punishment
+punishment's
+punishments
+punitive
+punitively
+punitiveness
+puns
+punt
+punted
+punter
+punters
+punting
+punts
+puny
+pup
+pup's
+pupa
+pupas
+pupil
+pupil's
+pupils
+puppet
+puppet's
+puppets
+puppies
+puppy
+puppy's
+pups
+purchasable
+purchase
+purchased
+purchaser
+purchasers
+purchases
+purchasing
+pure
+purely
+pureness
+purer
+purest
+purge
+purged
+purger
+purges
+purging
+purification
+purifications
+purified
+purifier
+purifiers
+purifies
+purify
+purifying
+purity
+purple
+purpled
+purpler
+purples
+purplest
+purpling
+purport
+purported
+purportedly
+purporter
+purporters
+purporting
+purports
+purpose
+purposed
+purposeful
+purposefully
+purposefulness
+purposely
+purposes
+purposing
+purposive
+purposively
+purposiveness
+purr
+purred
+purring
+purringly
+purrs
+purse
+pursed
+purser
+pursers
+purses
+pursing
+pursue
+pursued
+pursuer
+pursuers
+pursues
+pursuing
+pursuit
+pursuit's
+pursuits
+purview
+push
+pushbutton
+pushbuttons
+pushdown
+pushed
+pusher
+pushers
+pushes
+pushing
+puss
+pussier
+pussies
+pussy
+put
+puts
+putter
+putterer
+puttering
+putters
+putting
+puzzle
+puzzled
+puzzlement
+puzzler
+puzzlers
+puzzles
+puzzling
+puzzlings
+pygmies
+pygmy
+pygmy's
+pyramid
+pyramid's
+pyramids
+quack
+quacked
+quacking
+quacks
+quadrant
+quadrant's
+quadrants
+quadratic
+quadratical
+quadratically
+quadratics
+quadrature
+quadrature's
+quadratures
+quadruple
+quadrupled
+quadruples
+quadrupling
+quadword
+quadword's
+quadwords
+quagmire
+quagmire's
+quagmires
+quail
+quail's
+quails
+quaint
+quaintly
+quaintness
+quake
+quaked
+quaker
+quakers
+quakes
+quaking
+qualification
+qualifications
+qualified
+qualifiedly
+qualifier
+qualifiers
+qualifies
+qualify
+qualifying
+qualitative
+qualitatively
+qualities
+quality
+quality's
+qualm
+qualms
+quandaries
+quandary
+quandary's
+quanta
+quantifiable
+quantification
+quantifications
+quantified
+quantifier
+quantifiers
+quantifies
+quantify
+quantifying
+quantitative
+quantitatively
+quantitativeness
+quantities
+quantity
+quantity's
+quantum
+quarantine
+quarantine's
+quarantined
+quarantines
+quarantining
+quarrel
+quarrels
+quarrelsome
+quarrelsomely
+quarrelsomeness
+quarried
+quarrier
+quarries
+quarry
+quarry's
+quarrying
+quart
+quarter
+quartered
+quarterer
+quartering
+quarterlies
+quarterly
+quarters
+quartet
+quartet's
+quartets
+quarts
+quartz
+quash
+quashed
+quashes
+quashing
+quasi
+quaver
+quavered
+quavering
+quaveringly
+quavers
+quay
+quays
+queen
+queen's
+queenly
+queens
+queer
+queerer
+queerest
+queerly
+queerness
+queers
+quell
+quelled
+queller
+quelling
+quells
+quench
+quenched
+quencher
+quenches
+quenching
+queried
+querier
+queries
+query
+querying
+quest
+quested
+quester
+questers
+questing
+question
+questionable
+questionableness
+questionably
+questioned
+questioner
+questioners
+questioning
+questioningly
+questionings
+questionnaire
+questionnaire's
+questionnaires
+questions
+quests
+queue
+queue's
+queued
+queuer
+queuer's
+queuers
+queues
+quick
+quicken
+quickened
+quickener
+quickening
+quickens
+quicker
+quickest
+quickly
+quickness
+quicksilver
+quiet
+quieted
+quieten
+quietened
+quietening
+quietens
+quieter
+quietest
+quieting
+quietly
+quietness
+quiets
+quietude
+quill
+quills
+quilt
+quilted
+quilter
+quilting
+quilts
+quinine
+quit
+quite
+quits
+quitter
+quitter's
+quitters
+quitting
+quiver
+quivered
+quivering
+quivers
+quiz
+quizzed
+quizzes
+quizzing
+quo
+quota
+quota's
+quotas
+quotation
+quotation's
+quotations
+quote
+quoted
+quotes
+quoth
+quotient
+quotients
+quoting
+rabbit
+rabbit's
+rabbited
+rabbiter
+rabbiting
+rabbits
+rabble
+rabbled
+rabbler
+rabbling
+raccoon
+raccoon's
+raccoons
+race
+raced
+racehorse
+racehorse's
+racehorses
+racer
+racers
+races
+racial
+racially
+racing
+rack
+racked
+racker
+racket
+racket's
+racketeer
+racketeering
+racketeers
+rackets
+racking
+racks
+radar
+radar's
+radars
+radial
+radially
+radiance
+radiant
+radiantly
+radiate
+radiated
+radiately
+radiates
+radiating
+radiation
+radiations
+radiative
+radiatively
+radiator
+radiator's
+radiators
+radical
+radically
+radicalness
+radicals
+radio
+radioed
+radioing
+radiology
+radios
+radish
+radish's
+radishes
+radius
+radiuses
+radix
+radixes
+raft
+rafter
+raftered
+rafters
+rafts
+rag
+rag's
+rage
+raged
+rages
+ragged
+raggedly
+raggedness
+raging
+rags
+raid
+raided
+raider
+raiders
+raiding
+raids
+rail
+railed
+railer
+railers
+railing
+railroad
+railroaded
+railroader
+railroaders
+railroading
+railroads
+rails
+railway
+railway's
+railways
+raiment
+rain
+rain's
+rainbow
+rainbows
+raincoat
+raincoat's
+raincoats
+raindrop
+raindrop's
+raindrops
+rained
+rainfall
+rainier
+rainiest
+raining
+rains
+rainy
+raise
+raised
+raiser
+raisers
+raises
+raisin
+raising
+raisins
+rake
+raked
+raker
+rakes
+raking
+rallied
+rallies
+rally
+rallying
+ram
+ram's
+ramble
+rambled
+rambler
+ramblers
+rambles
+rambling
+ramblingly
+ramblings
+ramification
+ramification's
+ramifications
+ramp
+ramp's
+rampart
+ramparts
+ramped
+ramping
+ramps
+rams
+ramses
+ran
+ranch
+ranched
+rancher
+ranchers
+ranches
+ranching
+random
+randomly
+randomness
+rang
+range
+ranged
+ranger
+rangers
+ranges
+ranging
+rank
+ranked
+ranker
+ranker's
+rankers
+rankest
+ranking
+ranking's
+rankings
+rankle
+rankled
+rankles
+rankling
+rankly
+rankness
+ranks
+ransack
+ransacked
+ransacker
+ransacking
+ransacks
+ransom
+ransomer
+ransoming
+ransoms
+rant
+ranted
+ranter
+ranters
+ranting
+rantingly
+rants
+rap
+rap's
+rape
+raped
+raper
+rapes
+rapid
+rapidity
+rapidly
+rapidness
+rapids
+raping
+raps
+rapt
+raptly
+raptness
+rapture
+rapture's
+raptured
+raptures
+rapturing
+rapturous
+rapturously
+rapturousness
+rare
+rarely
+rareness
+rarer
+rarest
+raring
+rarities
+rarity
+rarity's
+rascal
+rascally
+rascals
+rash
+rasher
+rashes
+rashly
+rashness
+rasp
+raspberry
+rasped
+rasper
+rasping
+raspingly
+raspings
+rasps
+raster
+rasters
+rat
+rat's
+rate
+rated
+rater
+raters
+rates
+rather
+ratification
+ratifications
+ratified
+ratifies
+ratify
+ratifying
+rating
+ratings
+ratio
+ratio's
+ration
+rational
+rationale
+rationale's
+rationales
+rationalities
+rationality
+rationally
+rationalness
+rationed
+rationing
+rations
+ratios
+rats
+rattle
+rattled
+rattler
+rattlers
+rattles
+rattlesnake
+rattlesnake's
+rattlesnakes
+rattling
+rattlingly
+ravage
+ravaged
+ravager
+ravagers
+ravages
+ravaging
+rave
+raved
+raven
+ravened
+ravener
+ravening
+ravenous
+ravenously
+ravenousness
+ravens
+raver
+raves
+ravine
+ravine's
+ravined
+ravines
+raving
+ravings
+raw
+rawer
+rawest
+rawly
+rawness
+raws
+ray
+ray's
+rayed
+rays
+razor
+razor's
+razors
+re
+reabbreviate
+reabbreviated
+reabbreviates
+reabbreviating
+reach
+reachable
+reachably
+reached
+reacher
+reaches
+reaching
+reacquainted
+react
+reacted
+reacting
+reaction
+reaction's
+reactionaries
+reactionary
+reactionary's
+reactions
+reactivate
+reactivated
+reactivates
+reactivating
+reactivation
+reactive
+reactively
+reactiveness
+reactivity
+reactor
+reactor's
+reactors
+reacts
+read
+readability
+readable
+readableness
+readapting
+reader
+reader's
+readers
+readied
+readier
+readies
+readiest
+readily
+readiness
+reading
+readings
+readjustable
+readjusted
+readjustments
+readjusts
+readout
+readout's
+readouts
+reads
+ready
+readying
+reaffirm
+reaffirmed
+reaffirming
+reaffirms
+reagents
+real
+realest
+realign
+realigned
+realigning
+realignment
+realignments
+realigns
+realism
+realist
+realist's
+realistic
+realistically
+realists
+realities
+reality
+realizable
+realizable's
+realizableness
+realizables
+realizablies
+realizably
+realization
+realization's
+realizations
+realize
+realized
+realizer
+realizers
+realizes
+realizing
+realizing's
+realizingly
+realizings
+reallocate
+reallocated
+reallocates
+reallocating
+reallocation
+reallocation's
+reallocations
+reallocator
+reallocator's
+reallocators
+reallotments
+reallots
+reallotted
+reallotting
+really
+realm
+realm's
+realms
+realness
+reals
+ream
+ream's
+reamed
+reamer
+reaming
+reams
+reanalysis
+reap
+reaped
+reaper
+reaping
+reappear
+reappeared
+reappearing
+reappears
+reapplying
+reapportioned
+reappraisal
+reappraisals
+reappraised
+reappraises
+reaps
+rear
+reared
+rearer
+rearing
+rearmed
+rearms
+rearrange
+rearrangeable
+rearranged
+rearrangement
+rearrangement's
+rearrangements
+rearranges
+rearranging
+rearrest
+rearrested
+rears
+reason
+reasonable
+reasonableness
+reasonably
+reasoned
+reasoner
+reasoning
+reasonings
+reasons
+reassemble
+reassembled
+reassembler
+reassembles
+reassembling
+reasserts
+reassess
+reassessed
+reassesses
+reassessing
+reassessment
+reassessment's
+reassessments
+reassign
+reassignable
+reassigned
+reassigning
+reassignment
+reassignment's
+reassignments
+reassigns
+reassurances
+reassure
+reassured
+reassures
+reassuring
+reassuringly
+reawaken
+reawakened
+reawakening
+reawakens
+rebate
+rebate's
+rebated
+rebater
+rebates
+rebating
+rebel
+rebel's
+rebelled
+rebelling
+rebellion
+rebellion's
+rebellions
+rebellious
+rebelliously
+rebelliousness
+rebells
+rebels
+rebidding
+rebids
+rebirth
+rebirth's
+rebonds
+reboot
+rebooted
+rebooter
+rebooters
+rebooting
+reboots
+reborn
+rebound
+rebounded
+rebounder
+rebounding
+rebounds
+rebroadcast
+rebroadcasts
+rebuff
+rebuffed
+rebuffing
+rebuffs
+rebuild
+rebuilding
+rebuilds
+rebuilt
+rebuke
+rebuked
+rebuker
+rebukes
+rebuking
+rebut
+rebuttal
+rebuttals
+rebutted
+rebutting
+recalculate
+recalculated
+recalculates
+recalculating
+recalculation
+recalculations
+recall
+recalled
+recaller
+recalling
+recalls
+recapitulate
+recapitulated
+recapitulates
+recapitulating
+recapitulation
+recapped
+recapping
+recapture
+recaptured
+recaptures
+recapturing
+recast
+recasting
+recasts
+recede
+receded
+recedes
+receding
+receipt
+receipt's
+receipted
+receipting
+receipts
+receivable
+receivables
+receive
+received
+receiver
+receiver's
+receivers
+receives
+receiving
+recent
+recently
+recentness
+receptacle
+receptacle's
+receptacles
+reception
+reception's
+receptions
+receptive
+receptively
+receptiveness
+receptivity
+receptor
+receptor's
+receptors
+recess
+recessed
+recesses
+recessing
+recession
+recession's
+recessions
+recessive
+recessively
+recessiveness
+recharged
+recharges
+rechartering
+rechecked
+rechecks
+recipe
+recipe's
+recipes
+recipient
+recipient's
+recipients
+reciprocal
+reciprocally
+reciprocals
+reciprocate
+reciprocated
+reciprocates
+reciprocating
+reciprocation
+reciprocative
+reciprocity
+recirculate
+recirculated
+recirculates
+recirculating
+recirculation
+recital
+recital's
+recitals
+recitation
+recitation's
+recitations
+recite
+recited
+reciter
+recites
+reciting
+reckless
+recklessly
+recklessness
+reckon
+reckoned
+reckoner
+reckoning
+reckonings
+reckons
+reclaim
+reclaimable
+reclaimed
+reclaimer
+reclaimers
+reclaiming
+reclaims
+reclamation
+reclamations
+reclassification
+reclassified
+reclassifies
+reclassify
+reclassifying
+recline
+reclined
+reclines
+reclining
+reclustered
+reclusters
+recode
+recoded
+recodes
+recoding
+recognition
+recognition's
+recognitions
+recoil
+recoiled
+recoiling
+recoils
+recoinage
+recollect
+recollected
+recollecting
+recollection
+recollection's
+recollections
+recollects
+recombination
+recombination's
+recombinational
+recombinations
+recombine
+recombined
+recombines
+recombining
+recommenced
+recommences
+recommend
+recommendation
+recommendation's
+recommendations
+recommended
+recommender
+recommending
+recommends
+recompense
+recompilations
+recompile
+recompiled
+recompiles
+recompiling
+recompute
+recomputed
+recomputes
+recomputing
+reconcile
+reconciled
+reconciler
+reconciles
+reconciliation
+reconciliation's
+reconciliations
+reconciling
+reconditioned
+reconfigurable
+reconfiguration
+reconfiguration's
+reconfigurations
+reconfigure
+reconfigured
+reconfigurer
+reconfigures
+reconfiguring
+reconnect
+reconnected
+reconnecter
+reconnecting
+reconnection
+reconnects
+reconsider
+reconsideration
+reconsidered
+reconsidering
+reconsiders
+reconsolidated
+reconsolidates
+reconstituted
+reconstitutes
+reconstruct
+reconstructed
+reconstructible
+reconstructing
+reconstruction
+reconstructions
+reconstructive
+reconstructs
+recontacted
+reconvened
+reconvenes
+reconverts
+record
+recorded
+recorder
+recorders
+recording
+recordings
+records
+recored
+recount
+recounted
+recounter
+recounting
+recounts
+recourse
+recourses
+recover
+recoverability
+recoverable
+recovered
+recoverer
+recoveries
+recovering
+recovers
+recovery
+recovery's
+recreate
+recreated
+recreates
+recreating
+recreation
+recreational
+recreations
+recreative
+recruit
+recruit's
+recruited
+recruiter
+recruiter's
+recruiters
+recruiting
+recruits
+recta
+rectangle
+rectangle's
+rectangles
+rectangular
+rectangularly
+rector
+rector's
+rectors
+rectum
+rectum's
+rectums
+recur
+recurrence
+recurrence's
+recurrences
+recurrent
+recurrently
+recurring
+recurs
+recurse
+recursed
+recurses
+recursing
+recursion
+recursion's
+recursions
+recursive
+recursively
+recursiveness
+recurved
+recyclable
+recycle
+recycled
+recycles
+recycling
+red
+redbreast
+redden
+reddened
+reddening
+redder
+reddest
+reddish
+reddishness
+redeclare
+redeclared
+redeclares
+redeclaring
+redecorated
+redecorates
+redeem
+redeemed
+redeemer
+redeemers
+redeeming
+redeems
+redefine
+redefined
+redefines
+redefining
+redefinition
+redefinition's
+redefinitions
+redemption
+redemptioner
+redeploys
+redeposit
+redeposit's
+redeposited
+redepositing
+redepositor
+redepositor's
+redepositors
+redeposits
+redesign
+redesigned
+redesigning
+redesigns
+redetermination
+redetermines
+redevelop
+redeveloped
+redeveloper
+redevelopers
+redeveloping
+redevelopment
+redevelops
+redials
+redirect
+redirected
+redirecting
+redirection
+redirections
+redirector
+redirector's
+redirectors
+redirects
+rediscovered
+rediscovers
+redisplay
+redisplayed
+redisplaying
+redisplays
+redistribute
+redistributed
+redistributes
+redistributing
+redistribution
+redistribution's
+redistributions
+redistributive
+redly
+redness
+redoing
+redone
+redouble
+redoubled
+redoubles
+redoubling
+redoubtable
+redraw
+redrawing
+redrawn
+redraws
+redress
+redressed
+redresser
+redresses
+redressing
+reds
+reduce
+reduced
+reducer
+reducers
+reduces
+reducibility
+reducible
+reducibly
+reducing
+reduction
+reduction's
+reductions
+redundancies
+redundancy
+redundant
+redundantly
+reduplicated
+reed
+reed's
+reeder
+reeding
+reeds
+reeducation
+reef
+reefer
+reefing
+reefs
+reel
+reelect
+reelected
+reelecting
+reelects
+reeled
+reeler
+reeling
+reels
+reemerged
+reenactment
+reenforcement
+reenlists
+reenter
+reentered
+reentering
+reenters
+reentrant
+reestablish
+reestablished
+reestablishes
+reestablishing
+reestimating
+reevaluate
+reevaluated
+reevaluates
+reevaluating
+reevaluation
+reeves
+reexamine
+reexamined
+reexamines
+reexamining
+refaced
+refaces
+refelled
+refelling
+refer
+referee
+referee's
+refereed
+refereeing
+referees
+reference
+referenced
+referencer
+references
+referencing
+referendum
+referent
+referent's
+referential
+referentiality
+referentially
+referents
+referral
+referral's
+referrals
+referred
+referrer
+referring
+refers
+refill
+refillable
+refilled
+refilling
+refills
+refine
+refined
+refinement
+refinement's
+refinements
+refiner
+refines
+refining
+refinished
+reflect
+reflected
+reflecting
+reflection
+reflection's
+reflections
+reflective
+reflectively
+reflectiveness
+reflectivity
+reflector
+reflector's
+reflectors
+reflects
+reflex
+reflex's
+reflexed
+reflexes
+reflexive
+reflexively
+reflexiveness
+reflexivity
+reflexly
+refluent
+refocus
+refocused
+refocuses
+refocusing
+refolded
+reform
+reformable
+reformat
+reformation
+reformative
+reformats
+reformatted
+reformatter
+reformatting
+reformed
+reformer
+reformers
+reforming
+reforms
+reformulate
+reformulated
+reformulates
+reformulating
+reformulation
+refractoriness
+refractory
+refrain
+refrained
+refraining
+refrains
+refresh
+refreshed
+refreshen
+refresher
+refreshers
+refreshes
+refreshing
+refreshingly
+refreshment
+refreshment's
+refreshments
+refried
+refries
+refrigerator
+refrigerator's
+refrigerators
+refry
+refrying
+refuel
+refuels
+refuge
+refuged
+refugee
+refugee's
+refugees
+refuges
+refuging
+refund
+refund's
+refunded
+refunder
+refunders
+refunding
+refunds
+refusal
+refusals
+refuse
+refused
+refuser
+refuses
+refusing
+refutable
+refutation
+refute
+refuted
+refuter
+refutes
+refuting
+regain
+regained
+regaining
+regains
+regal
+regaled
+regaling
+regally
+regard
+regarded
+regarding
+regardless
+regardlessly
+regardlessness
+regards
+regenerate
+regenerated
+regenerately
+regenerateness
+regenerates
+regenerating
+regeneration
+regenerative
+regeneratively
+regenerators
+regent
+regent's
+regents
+regime
+regime's
+regimen
+regiment
+regimented
+regiments
+regimes
+region
+region's
+regional
+regionally
+regions
+register
+registered
+registering
+registers
+registration
+registration's
+registrations
+regreets
+regress
+regressed
+regresses
+regressing
+regression
+regression's
+regressions
+regressive
+regressively
+regressiveness
+regret
+regretful
+regretfully
+regretfulness
+regrets
+regrettable
+regrettably
+regretted
+regretting
+regrids
+regroup
+regrouped
+regrouping
+regular
+regularities
+regularity
+regularly
+regulars
+regulate
+regulated
+regulates
+regulating
+regulation
+regulations
+regulative
+regulator
+regulator's
+regulators
+rehash
+rehashed
+rehashes
+rehashing
+rehearsal
+rehearsal's
+rehearsals
+rehearse
+rehearsed
+rehearser
+rehearses
+rehearsing
+rehoused
+rehouses
+reign
+reigned
+reigning
+reigns
+reimbursed
+reimbursement
+reimbursement's
+reimbursements
+rein
+reincarnate
+reincarnated
+reincarnation
+reincorporating
+reincorporation
+reindeer
+reined
+reinforce
+reinforced
+reinforcement
+reinforcement's
+reinforcements
+reinforcer
+reinforces
+reinforcing
+reining
+reins
+reinsert
+reinserted
+reinserting
+reinsertions
+reinserts
+reinstall
+reinstalled
+reinstaller
+reinstalling
+reinstalls
+reinstate
+reinstated
+reinstatement
+reinstates
+reinstating
+reintegrated
+reinterpret
+reinterpretations
+reinterpreted
+reinterpreting
+reinterprets
+reinterviewed
+reintroduce
+reintroduced
+reintroduces
+reintroducing
+reinvent
+reinvented
+reinventing
+reinvention
+reinvents
+reinvested
+reinvoked
+reinvokes
+reissue
+reissued
+reissuer
+reissuer's
+reissuers
+reissues
+reissuing
+reiterate
+reiterated
+reiterates
+reiterating
+reiteration
+reiterations
+reiterative
+reiteratively
+reiterativeness
+reject
+rejected
+rejecter
+rejecting
+rejectingly
+rejection
+rejection's
+rejections
+rejective
+rejector
+rejector's
+rejectors
+rejects
+rejoice
+rejoiced
+rejoicer
+rejoices
+rejoicing
+rejoicingly
+rejoin
+rejoined
+rejoining
+rejoins
+rekindle
+rekindled
+rekindler
+rekindles
+rekindling
+reknit
+relabel
+relabels
+relapse
+relapsed
+relapser
+relapses
+relapsing
+relate
+related
+relatedly
+relatedness
+relater
+relates
+relating
+relation
+relational
+relationally
+relations
+relationship
+relationship's
+relationships
+relative
+relatively
+relativeness
+relatives
+relativism
+relativistic
+relativistically
+relativity
+relativity's
+relax
+relaxation
+relaxation's
+relaxations
+relaxed
+relaxedly
+relaxedness
+relaxer
+relaxes
+relaxing
+relay
+relayed
+relaying
+relays
+relearns
+release
+released
+releaser
+releases
+releasing
+relegate
+relegated
+relegates
+relegating
+relegation
+relent
+relented
+relenting
+relentless
+relentlessly
+relentlessness
+relents
+relevance
+relevances
+relevant
+relevantly
+reliabilities
+reliability
+reliable
+reliableness
+reliably
+reliance
+relic
+relic's
+relicense
+relicensed
+relicenser
+relicenses
+relicensing
+relics
+relied
+relief
+reliefs
+relier
+relies
+relieve
+relieved
+relievedly
+reliever
+relievers
+relieves
+relieving
+religion
+religion's
+religions
+religious
+religiously
+religiousness
+relinking
+relinquish
+relinquished
+relinquishes
+relinquishing
+relish
+relished
+relishes
+relishing
+relive
+relives
+reliving
+reload
+reloaded
+reloader
+reloading
+reloads
+relocate
+relocated
+relocates
+relocating
+relocation
+relocations
+reluctance
+reluctances
+reluctant
+reluctantly
+rely
+relying
+remade
+remain
+remainder
+remainder's
+remaindered
+remaindering
+remainders
+remained
+remaining
+remains
+remark
+remarkable
+remarkableness
+remarkably
+remarked
+remarking
+remarks
+remarriages
+remarried
+remedied
+remedies
+remedy
+remedying
+remember
+remembered
+rememberer
+remembering
+remembers
+remembrance
+remembrance's
+remembrancer
+remembrances
+remind
+reminded
+reminder
+reminders
+reminding
+reminds
+reminiscence
+reminiscence's
+reminiscences
+reminiscent
+reminiscently
+remissions
+remittance
+remittances
+remixed
+remnant
+remnant's
+remnants
+remodel
+remodels
+remodulate
+remodulated
+remodulates
+remodulating
+remodulation
+remodulator
+remodulator's
+remodulators
+remolding
+remonstrate
+remonstrated
+remonstrates
+remonstrating
+remonstration
+remonstrative
+remonstratively
+remorse
+remote
+remotely
+remoteness
+remotest
+remotion
+remoulds
+removable
+removableness
+removal
+removal's
+removals
+remove
+removed
+remover
+removes
+removing
+renaissance
+renal
+rename
+renamed
+renames
+renaming
+renatured
+renatures
+rend
+render
+rendered
+renderer
+rendering
+renderings
+renders
+rendezvous
+rendezvoused
+rendezvouses
+rendezvousing
+rending
+rendition
+rendition's
+renditions
+rends
+renegotiable
+renegotiated
+renegotiates
+renew
+renewal
+renewals
+renewed
+renewer
+renewing
+renews
+reno
+renominated
+renominates
+renounce
+renounced
+renouncer
+renounces
+renouncing
+renown
+renowned
+rent
+rental
+rental's
+rentals
+rented
+renter
+renter's
+renters
+renting
+rents
+renumber
+renumbered
+renumbering
+renumbers
+reopen
+reopened
+reopening
+reopens
+reorder
+reordered
+reordering
+reorders
+reoriented
+repackage
+repackaged
+repackager
+repackages
+repackaging
+repacks
+repaid
+repaint
+repainted
+repainter
+repainters
+repainting
+repaints
+repair
+repaired
+repairer
+repairers
+repairing
+repairman
+repairs
+reparable
+reparation
+reparation's
+reparations
+repartition
+repartitioned
+repartitioner
+repartitioners
+repartitioning
+repartitions
+repast
+repast's
+repasts
+repaving
+repay
+repayable
+repaying
+repayments
+repays
+repeal
+repealed
+repealer
+repealing
+repeals
+repeat
+repeatable
+repeated
+repeatedly
+repeater
+repeaters
+repeating
+repeats
+repel
+repels
+repent
+repentance
+repented
+repenter
+repenting
+repents
+repercussion
+repercussion's
+repercussions
+repertoire
+repetition
+repetition's
+repetitions
+repetitive
+repetitively
+repetitiveness
+rephrase
+rephrased
+rephrases
+rephrasing
+repine
+repined
+repiner
+repining
+replace
+replaceable
+replaced
+replacement
+replacement's
+replacements
+replacer
+replaces
+replacing
+replanted
+replay
+replayed
+replaying
+replays
+repleader
+replenish
+replenished
+replenisher
+replenishes
+replenishing
+replete
+repleteness
+repletion
+replica
+replica's
+replicas
+replicate
+replicated
+replicates
+replicating
+replication
+replications
+replicative
+replied
+replier
+replies
+reply
+replying
+report
+reported
+reportedly
+reporter
+reporters
+reporting
+reports
+repose
+reposed
+reposes
+reposing
+reposition
+repositioned
+repositioning
+repositions
+repositories
+repository
+repository's
+repost
+reposted
+reposter
+reposting
+repostings
+reposts
+represent
+representable
+representably
+representation
+representation's
+representational
+representationally
+representations
+representative
+representatively
+representativeness
+representatives
+represented
+representer
+representing
+represents
+repress
+repressed
+represses
+repressing
+repression
+repression's
+repressions
+repressive
+repressively
+repressiveness
+reprieve
+reprieved
+reprieves
+reprieving
+reprint
+reprinted
+reprinter
+reprinting
+reprints
+reprisal
+reprisal's
+reprisals
+reproach
+reproached
+reproacher
+reproaches
+reproaching
+reproachingly
+reprobates
+reprocessed
+reproduce
+reproduced
+reproducer
+reproducers
+reproduces
+reproducibilities
+reproducibility
+reproducible
+reproducibly
+reproducing
+reproduction
+reproduction's
+reproductions
+reproductive
+reproductively
+reproductivity
+reprogrammed
+reprogrammer
+reprogrammer's
+reprogrammers
+reprogramming
+reproof
+reprove
+reproved
+reprover
+reproving
+reprovingly
+reptile
+reptile's
+reptiles
+republic
+republic's
+republican
+republican's
+republicans
+republication
+republics
+republish
+republished
+republisher
+republisher's
+republishers
+republishes
+republishing
+repudiate
+repudiated
+repudiates
+repudiating
+repudiation
+repudiations
+repulse
+repulsed
+repulses
+repulsing
+repulsion
+repulsions
+repulsive
+repulsively
+repulsiveness
+reputable
+reputably
+reputation
+reputation's
+reputations
+repute
+reputed
+reputedly
+reputes
+reputing
+request
+requested
+requester
+requesters
+requesting
+requestioned
+requests
+requiem
+requiem's
+requiems
+require
+required
+requirement
+requirement's
+requirements
+requirer
+requires
+requiring
+requisite
+requisiteness
+requisites
+requisition
+requisitioned
+requisitioner
+requisitioning
+requisitions
+requite
+requited
+requiter
+requiting
+reran
+reread
+rereading
+rereads
+reroute
+rerouted
+rerouter
+rerouters
+reroutes
+reroutings
+rerun
+rerunning
+reruns
+res
+resalable
+resaturated
+resaturates
+rescaled
+rescan
+rescanned
+rescanning
+rescans
+reschedule
+rescheduled
+rescheduler
+reschedules
+rescheduling
+rescue
+rescued
+rescuer
+rescuers
+rescues
+rescuing
+resealed
+research
+researched
+researcher
+researcher's
+researchers
+researches
+researching
+reselect
+reselected
+reselecting
+reselects
+resell
+reseller
+resellers
+reselling
+resells
+resemblance
+resemblance's
+resemblances
+resemble
+resembled
+resembles
+resembling
+resends
+resent
+resented
+resentful
+resentfully
+resentfulness
+resenting
+resentment
+resents
+resequenced
+reservation
+reservation's
+reservations
+reserve
+reserved
+reservedly
+reservedness
+reserver
+reserves
+reserving
+reservoir
+reservoir's
+reservoirs
+reset
+reseted
+reseter
+reseting
+resets
+resetting
+resettings
+resettled
+resettles
+resettling
+reshape
+reshaped
+reshaper
+reshapes
+reshaping
+reside
+resided
+residence
+residence's
+residences
+resident
+resident's
+residential
+residentially
+residents
+resider
+resides
+residing
+residue
+residue's
+residues
+resifted
+resign
+resignation
+resignation's
+resignations
+resigned
+resignedly
+resignedness
+resigner
+resigning
+resigns
+resin
+resin's
+resined
+resining
+resins
+resist
+resistance
+resistances
+resistant
+resistantly
+resisted
+resister
+resistible
+resistibly
+resisting
+resistive
+resistively
+resistiveness
+resistivity
+resistor
+resistor's
+resistors
+resists
+resize
+resized
+resizes
+resizing
+resold
+resoluble
+resolute
+resolutely
+resoluteness
+resolution
+resolutions
+resolutive
+resolvable
+resolve
+resolved
+resolver
+resolvers
+resolves
+resolving
+resonance
+resonances
+resonant
+resonantly
+resort
+resorted
+resorter
+resorting
+resorts
+resound
+resounding
+resoundingly
+resounds
+resource
+resource's
+resourced
+resourceful
+resourcefully
+resourcefulness
+resources
+resourcing
+respecified
+respect
+respectability
+respectable
+respectableness
+respectably
+respected
+respecter
+respectful
+respectfully
+respectfulness
+respecting
+respective
+respectively
+respectiveness
+respects
+respiration
+respirations
+respired
+respires
+respite
+respited
+respiting
+resplendent
+resplendently
+respond
+responded
+respondent
+respondent's
+respondents
+responder
+responders
+responding
+responds
+response
+responser
+responses
+responsibilities
+responsibility
+responsible
+responsibleness
+responsibly
+responsions
+responsive
+responsively
+responsiveness
+rest
+restart
+restarted
+restarter
+restarting
+restarts
+restate
+restated
+restatement
+restates
+restating
+restaurant
+restaurant's
+restaurants
+rested
+rester
+restful
+restfully
+restfulness
+resting
+restive
+restively
+restiveness
+restless
+restlessly
+restlessness
+restoration
+restoration's
+restorations
+restore
+restored
+restorer
+restorers
+restores
+restoring
+restrain
+restrained
+restrainedly
+restrainer
+restrainers
+restraining
+restrains
+restraint
+restraint's
+restraints
+restrict
+restricted
+restrictedly
+restricting
+restriction
+restriction's
+restrictions
+restrictive
+restrictively
+restrictiveness
+restricts
+restroom
+restroom's
+restrooms
+restructure
+restructured
+restructures
+restructuring
+rests
+resubmit
+resubmits
+resubmitted
+resubmitting
+result
+resultant
+resultantly
+resultants
+resulted
+resulting
+results
+resumable
+resume
+resumed
+resumes
+resuming
+resumption
+resumption's
+resumptions
+resupplier
+resupplier's
+resuppliers
+resurface
+resurfaced
+resurfacer
+resurfacer's
+resurfacers
+resurfaces
+resurfacing
+resurged
+resurges
+resurrect
+resurrected
+resurrecting
+resurrection
+resurrection's
+resurrections
+resurrects
+resuspended
+retail
+retailed
+retailer
+retailers
+retailing
+retails
+retain
+retained
+retainer
+retainers
+retaining
+retainment
+retains
+retaliation
+retard
+retarded
+retarder
+retarding
+retention
+retentions
+retentive
+retentively
+retentiveness
+rethinks
+rethreading
+reticence
+reticent
+reticently
+reticle
+reticle's
+reticles
+reticular
+reticulate
+reticulated
+reticulately
+reticulates
+reticulating
+reticulation
+retied
+retina
+retina's
+retinal
+retinas
+retinue
+retinues
+retire
+retired
+retiredly
+retiredness
+retirement
+retirement's
+retirements
+retires
+retiring
+retiringly
+retiringness
+retitled
+retold
+retort
+retorted
+retorting
+retorts
+retrace
+retraced
+retraces
+retracing
+retract
+retractable
+retracted
+retracting
+retraction
+retractions
+retractor
+retractor's
+retractors
+retracts
+retrain
+retrained
+retraining
+retrains
+retranslated
+retransmission
+retransmission's
+retransmissions
+retransmit
+retransmits
+retransmitted
+retransmitting
+retreat
+retreated
+retreater
+retreating
+retreats
+retried
+retrier
+retriers
+retries
+retrievable
+retrieval
+retrieval's
+retrievals
+retrieve
+retrieved
+retriever
+retrievers
+retrieves
+retrieving
+retroactively
+retrospect
+retrospection
+retrospective
+retrospectively
+retry
+retrying
+return
+returnable
+returned
+returner
+returners
+returning
+returns
+retype
+retyped
+retypes
+retyping
+reunion
+reunion's
+reunions
+reunite
+reunited
+reuniting
+reupholstering
+reusable
+reuse
+reused
+reuses
+reusing
+revalidated
+revalidates
+revalidation
+revalued
+revalues
+revamp
+revamped
+revamping
+revamps
+reveal
+revealed
+revealer
+revealing
+reveals
+revel
+revelation
+revelation's
+revelations
+revelry
+revels
+revenge
+revenge's
+revenged
+revenger
+revenges
+revenging
+revenue
+revenuer
+revenuers
+revenues
+revere
+revered
+reverence
+reverencer
+reverend
+reverend's
+reverends
+reverently
+reveres
+reverified
+reverifies
+reverify
+reverifying
+revering
+reversal
+reversal's
+reversals
+reverse
+reversed
+reversely
+reverser
+reverses
+reversible
+reversing
+reversion
+reversioner
+reversions
+revert
+reverted
+reverter
+reverting
+revertive
+reverts
+revetting
+review
+reviewed
+reviewer
+reviewers
+reviewing
+reviews
+revile
+reviled
+reviler
+reviling
+revise
+revised
+reviser
+revises
+revising
+revision
+revision's
+revisions
+revisit
+revisited
+revisiting
+revisits
+revival
+revival's
+revivals
+revive
+revived
+reviver
+revives
+reviving
+revocation
+revocations
+revoke
+revoked
+revoker
+revokes
+revoking
+revolt
+revolted
+revolter
+revolting
+revoltingly
+revolts
+revolution
+revolution's
+revolutionaries
+revolutionariness
+revolutionary
+revolutionary's
+revolutions
+revolve
+revolved
+revolver
+revolvers
+revolves
+revolving
+reward
+rewarded
+rewarder
+rewarding
+rewardingly
+rewards
+rewind
+rewinded
+rewinder
+rewinding
+rewinds
+rewired
+rewires
+reword
+reworded
+rewording
+rewording's
+rewordings
+rewords
+rework
+reworked
+reworking
+reworks
+rewound
+rewrite
+rewriter
+rewrites
+rewriting
+rewritings
+rewritten
+rewrote
+rhetoric
+rheumatism
+rhinoceros
+rhubarb
+rhyme
+rhymed
+rhymer
+rhymes
+rhyming
+rhythm
+rhythm's
+rhythmic
+rhythmical
+rhythmically
+rhythmics
+rhythms
+rib
+rib's
+ribbed
+ribbing
+ribbon
+ribbon's
+ribbons
+ribs
+rice
+ricer
+rices
+rich
+richen
+richened
+richening
+richer
+riches
+richest
+richly
+richness
+rickshaw
+rickshaw's
+rickshaws
+rid
+ridden
+riddle
+riddled
+riddler
+riddles
+riddling
+ride
+rider
+rider's
+riders
+rides
+ridge
+ridge's
+ridged
+ridges
+ridging
+ridicule
+ridiculed
+ridiculer
+ridicules
+ridiculing
+ridiculous
+ridiculously
+ridiculousness
+riding
+ridings
+rids
+rifle
+rifled
+rifleman
+rifler
+rifles
+rifling
+rift
+rig
+rig's
+rigged
+rigging
+right
+righted
+righten
+righteous
+righteously
+righteousness
+righter
+rightful
+rightfully
+rightfulness
+righting
+rightly
+rightmost
+rightness
+rights
+rightward
+rightwards
+rigid
+rigidities
+rigidity
+rigidly
+rigidness
+rigorous
+rigorously
+rigorousness
+rigs
+rill
+rim
+rim's
+rime
+rimer
+riming
+rims
+rind
+rind's
+rinded
+rinds
+ring
+ringed
+ringer
+ringers
+ringing
+ringingly
+ringings
+rings
+rinse
+rinsed
+rinser
+rinses
+rinsing
+riot
+rioted
+rioter
+rioters
+rioting
+riotous
+riotously
+riotousness
+riots
+rip
+ripe
+ripely
+ripen
+ripened
+ripener
+ripeness
+ripening
+ripens
+riper
+ripest
+ripped
+ripping
+ripple
+rippled
+rippler
+ripples
+rippling
+rips
+rise
+risen
+riser
+risers
+rises
+rising
+risings
+risk
+risked
+risker
+risking
+risks
+rite
+rite's
+rited
+rites
+ritual
+ritually
+rituals
+rival
+rivalries
+rivalry
+rivalry's
+rivals
+rive
+rived
+riven
+river
+river's
+rivers
+riverside
+rivet
+riveted
+riveter
+riveting
+rivets
+riving
+rivulet
+rivulet's
+rivulets
+road
+road's
+roads
+roadside
+roadsides
+roadster
+roadster's
+roadsters
+roadway
+roadway's
+roadways
+roam
+roamed
+roamer
+roaming
+roams
+roar
+roared
+roarer
+roaring
+roaringest
+roars
+roast
+roasted
+roaster
+roasting
+roasts
+rob
+robbed
+robber
+robber's
+robberies
+robbers
+robbery
+robbery's
+robbing
+robe
+robed
+robes
+robin
+robin's
+robing
+robins
+robot
+robot's
+robotic
+robotics
+robots
+robs
+robust
+robustly
+robustness
+rock
+rocked
+rocker
+rockers
+rocket
+rocket's
+rocketed
+rocketing
+rockets
+rockier
+rockies
+rockiness
+rocking
+rocks
+rocky
+rod
+rod's
+rode
+rods
+roe
+roes
+rogue
+rogue's
+rogues
+roguing
+role
+role's
+roles
+roll
+rolled
+roller
+rollers
+rolling
+rolls
+romance
+romanced
+romancer
+romancers
+romances
+romancing
+romantic
+romantic's
+romantically
+romantics
+romp
+romped
+romper
+rompers
+romping
+romps
+roof
+roofed
+roofer
+roofers
+roofing
+roofs
+rook
+rooks
+room
+roomed
+roomer
+roomers
+rooming
+rooms
+roost
+rooster
+roosters
+root
+root's
+rooted
+rootedness
+rooter
+rooting
+roots
+rope
+roped
+roper
+ropers
+ropes
+roping
+rose
+rose's
+rosebud
+rosebud's
+rosebuds
+roses
+rosier
+rosiness
+rosy
+rot
+rotary
+rotate
+rotated
+rotates
+rotating
+rotation
+rotational
+rotationally
+rotations
+rotative
+rotatively
+rotator
+rotator's
+rotators
+rots
+rotten
+rottenly
+rottenness
+rouge
+rough
+roughed
+roughen
+roughened
+roughening
+roughens
+rougher
+roughest
+roughly
+roughness
+rouging
+round
+roundabout
+roundaboutness
+rounded
+roundedness
+rounder
+rounders
+roundest
+rounding
+roundly
+roundness
+roundoff
+rounds
+roundup
+roundup's
+roundups
+rouse
+roused
+rouser
+rouses
+rousing
+rout
+route
+routed
+router
+routers
+routes
+routine
+routinely
+routines
+routing
+routings
+rove
+roved
+rover
+roves
+roving
+row
+rowed
+rowen
+rower
+rowers
+rowing
+rows
+royal
+royalist
+royalist's
+royalists
+royally
+royalties
+royalty
+royalty's
+rub
+rubbed
+rubber
+rubber's
+rubbers
+rubbing
+rubbish
+rubbishes
+rubble
+rubbled
+rubbling
+rubies
+rubout
+rubs
+ruby
+ruby's
+rudder
+rudder's
+rudders
+ruddier
+ruddiness
+ruddy
+rude
+rudely
+rudeness
+ruder
+rudest
+rudiment
+rudiment's
+rudimentariness
+rudimentary
+rudiments
+rue
+ruefully
+rues
+ruffian
+ruffianly
+ruffians
+ruffle
+ruffled
+ruffler
+ruffles
+ruffling
+rug
+rug's
+rugged
+ruggedly
+ruggedness
+rugs
+ruin
+ruination
+ruination's
+ruinations
+ruined
+ruiner
+ruing
+ruining
+ruinous
+ruinously
+ruinousness
+ruins
+rule
+ruled
+ruler
+rulers
+rules
+ruling
+rulings
+rum
+rumble
+rumbled
+rumbler
+rumbles
+rumbling
+rumen
+rumens
+rump
+rumple
+rumpled
+rumples
+rumplier
+rumpling
+rumply
+rumps
+run
+runaway
+runaways
+rung
+rung's
+rungs
+runnable
+runner
+runner's
+runners
+running
+runs
+runtime
+rupture
+ruptured
+ruptures
+rupturing
+rural
+rurally
+rush
+rushed
+rusher
+rushes
+rushing
+russet
+russeted
+russeting
+russets
+rust
+rusted
+rustic
+rusticate
+rusticated
+rusticates
+rusticating
+rustication
+rustier
+rustiness
+rusting
+rustle
+rustled
+rustler
+rustlers
+rustles
+rustling
+rusts
+rusty
+rut
+rut's
+ruthless
+ruthlessly
+ruthlessness
+ruts
+rye
+rye's
+sable
+sable's
+sables
+sabotage
+sabotaged
+sabotages
+sabotaging
+sack
+sacked
+sacker
+sacking
+sacks
+sacred
+sacredly
+sacredness
+sacrifice
+sacrificed
+sacrificer
+sacrificers
+sacrifices
+sacrificial
+sacrificially
+sacrificing
+sad
+sadden
+saddened
+saddening
+saddens
+sadder
+saddest
+saddle
+saddled
+saddler
+saddles
+saddling
+sadism
+sadist
+sadist's
+sadistic
+sadistically
+sadists
+sadly
+sadness
+safe
+safeguard
+safeguarded
+safeguarding
+safeguards
+safely
+safeness
+safer
+safes
+safest
+safetied
+safeties
+safety
+safetying
+sag
+sagacious
+sagaciously
+sagaciousness
+sagacity
+sage
+sagely
+sageness
+sages
+sags
+said
+sail
+sailed
+sailer
+sailing
+sailor
+sailorly
+sailors
+sails
+saint
+sainted
+saintliness
+saintly
+saints
+sake
+saker
+sakes
+salable
+salad
+salad's
+salads
+salaried
+salaries
+salary
+sale
+sale's
+sales
+salesman
+salesmen
+salespeople
+salespeople's
+salesperson
+salesperson's
+salient
+saliently
+saline
+saliva
+sallied
+sallies
+sallow
+sallowness
+sally
+sallying
+salmon
+salmons
+salon
+salon's
+salons
+saloon
+saloon's
+saloons
+salt
+salted
+salter
+salters
+saltier
+saltiest
+saltiness
+salting
+saltness
+salts
+salty
+salutariness
+salutary
+salutation
+salutation's
+salutations
+salute
+saluted
+saluter
+salutes
+saluting
+salvage
+salvaged
+salvager
+salvages
+salvaging
+salvation
+salve
+salver
+salves
+salving
+same
+sameness
+sample
+sample's
+sampled
+sampler
+samplers
+samples
+sampling
+samplings
+sanctification
+sanctified
+sanctifier
+sanctify
+sanction
+sanctioned
+sanctioning
+sanctions
+sanctities
+sanctity
+sanctuaries
+sanctuary
+sanctuary's
+sand
+sandal
+sandal's
+sandals
+sanded
+sander
+sanders
+sandier
+sandiness
+sanding
+sandpaper
+sands
+sandstone
+sandstones
+sandwich
+sandwiched
+sandwiches
+sandwiching
+sandy
+sane
+sanely
+saneness
+saner
+sanest
+sang
+sanguine
+sanguinely
+sanguineness
+sanitarium
+sanitariums
+sanitary
+sanitation
+sanity
+sank
+sap
+sap's
+sapling
+sapling's
+saplings
+sapphire
+saps
+sarcasm
+sarcasm's
+sarcasms
+sarcastic
+sash
+sashed
+sashes
+sat
+satchel
+satchel's
+satchels
+sate
+sated
+satellite
+satellite's
+satellites
+sates
+satin
+sating
+satire
+satire's
+satires
+satirist
+satirist's
+satirists
+satisfaction
+satisfaction's
+satisfactions
+satisfactorily
+satisfactoriness
+satisfactory
+satisfiability
+satisfiable
+satisfied
+satisfier
+satisfiers
+satisfies
+satisfy
+satisfying
+satisfyingly
+saturate
+saturated
+saturater
+saturates
+saturating
+saturation
+saturations
+satyr
+sauce
+saucepan
+saucepan's
+saucepans
+saucer
+saucers
+sauces
+saucier
+sauciness
+saucing
+saucy
+saunter
+sauntered
+saunterer
+sauntering
+saunters
+sausage
+sausage's
+sausages
+savage
+savaged
+savagely
+savageness
+savager
+savagers
+savages
+savaging
+save
+saved
+saver
+savers
+saves
+saving
+savings
+saw
+sawed
+sawer
+sawing
+sawmill
+sawmill's
+sawmills
+saws
+sawtooth
+say
+sayer
+sayers
+saying
+sayings
+says
+scabbard
+scabbard's
+scabbards
+scaffold
+scaffolding
+scaffoldings
+scaffolds
+scalable
+scalar
+scalar's
+scalars
+scald
+scalded
+scalding
+scalds
+scale
+scaled
+scaler
+scalers
+scales
+scalier
+scaliness
+scaling
+scalings
+scallop
+scalloped
+scalloper
+scalloping
+scallops
+scalp
+scalp's
+scalper
+scalping
+scalps
+scaly
+scam
+scam's
+scamper
+scampered
+scampering
+scampers
+scams
+scan
+scandal
+scandal's
+scandalous
+scandalously
+scandalousness
+scandals
+scanned
+scanner
+scanner's
+scanners
+scanning
+scans
+scant
+scantier
+scanties
+scantiest
+scantily
+scantiness
+scantly
+scantness
+scanty
+scar
+scar's
+scarce
+scarcely
+scarceness
+scarcer
+scarcest
+scarcity
+scare
+scared
+scarer
+scares
+scarf
+scarfs
+scarier
+scaring
+scarlet
+scars
+scary
+scatter
+scattered
+scatterer
+scattering
+scatteringly
+scatters
+scavenger
+scavenger's
+scavengers
+scenario
+scenario's
+scenarios
+scene
+scene's
+sceneries
+scenery
+scenes
+scenic
+scenics
+scent
+scented
+scents
+schedule
+schedule's
+scheduled
+scheduler
+scheduler's
+schedulers
+schedules
+scheduling
+schema
+schema's
+schemas
+schemata
+schematic
+schematically
+schematics
+scheme
+scheme's
+schemed
+schemer
+schemers
+schemes
+scheming
+schizophrenia
+scholar
+scholarly
+scholars
+scholarship
+scholarship's
+scholarships
+scholastic
+scholastically
+scholastics
+school
+schoolboy
+schoolboy's
+schoolboys
+schooled
+schooler
+schoolers
+schoolhouse
+schoolhouse's
+schoolhouses
+schooling
+schoolmaster
+schoolmaster's
+schoolmasters
+schoolroom
+schoolroom's
+schoolrooms
+schools
+schoolyard
+schoolyard's
+schoolyards
+schooner
+science
+science's
+sciences
+scientific
+scientifically
+scientist
+scientist's
+scientists
+scissor
+scissored
+scissoring
+scissors
+scoff
+scoffed
+scoffer
+scoffing
+scoffs
+scold
+scolded
+scolder
+scolding
+scolds
+scoop
+scooped
+scooper
+scooping
+scoops
+scope
+scoped
+scopes
+scoping
+scorch
+scorched
+scorcher
+scorches
+scorching
+scorchingly
+score
+score's
+scored
+scorer
+scorers
+scores
+scoring
+scorings
+scorn
+scorned
+scorner
+scornful
+scornfully
+scornfulness
+scorning
+scorns
+scorpion
+scorpion's
+scorpions
+scoundrel
+scoundrel's
+scoundrelly
+scoundrels
+scour
+scoured
+scourer
+scourge
+scourger
+scourging
+scouring
+scourings
+scours
+scout
+scouted
+scouter
+scouting
+scouts
+scow
+scowl
+scowled
+scowler
+scowling
+scowls
+scramble
+scrambled
+scrambler
+scrambles
+scrambling
+scrap
+scrap's
+scrape
+scraped
+scraper
+scrapers
+scrapes
+scraping
+scrapings
+scrapped
+scraps
+scratch
+scratched
+scratcher
+scratchers
+scratches
+scratching
+scrawl
+scrawled
+scrawler
+scrawling
+scrawls
+scream
+screamed
+screamer
+screamers
+screaming
+screamingly
+screams
+screech
+screeched
+screecher
+screeches
+screeching
+screen
+screened
+screener
+screening
+screenings
+screens
+screw
+screwed
+screwer
+screwing
+screws
+scribble
+scribbled
+scribbler
+scribbles
+scribbling
+scribe
+scriber
+scribes
+scribing
+script
+script's
+scripted
+scripting
+scripts
+scripture
+scriptures
+scroll
+scrolled
+scrolling
+scrolls
+scrooge
+scrooge's
+scrooges
+scrub
+scrubs
+scruple
+scrupled
+scruples
+scrupling
+scrupulous
+scrupulously
+scrupulousness
+scrutiny
+scuffle
+scuffled
+scuffles
+scuffling
+sculpt
+sculpted
+sculpting
+sculptor
+sculptor's
+sculptors
+sculpts
+sculpture
+sculptured
+sculptures
+sculpturing
+scum
+scum's
+scums
+scurried
+scurry
+scurrying
+scuttle
+scuttled
+scuttles
+scuttling
+scythe
+scythe's
+scythes
+scything
+sea
+seaboard
+seacoast
+seacoast's
+seacoasts
+seal
+sealed
+sealer
+sealing
+seals
+sealy
+seam
+seaman
+seamanly
+seamed
+seamen
+seamer
+seaming
+seams
+seaport
+seaport's
+seaports
+sear
+search
+searched
+searcher
+searcher's
+searchers
+searches
+searching
+searchingly
+searchings
+seared
+searing
+searingly
+sears
+seas
+seashore
+seashore's
+seashores
+seaside
+season
+season's
+seasonable
+seasonableness
+seasonably
+seasonal
+seasonally
+seasoned
+seasoner
+seasoners
+seasoning
+seasonings
+seasonly
+seasons
+seat
+seated
+seater
+seating
+seats
+seaward
+seawards
+seaweed
+seaweeds
+secede
+seceded
+seceder
+secedes
+seceding
+secluded
+secludedly
+secludedness
+seclusion
+second
+secondaries
+secondarily
+secondariness
+secondary
+seconded
+seconder
+seconders
+secondhand
+seconding
+secondly
+seconds
+secrecy
+secret
+secretarial
+secretaries
+secretary
+secretary's
+secrete
+secreted
+secretes
+secreting
+secretion
+secretions
+secretive
+secretively
+secretiveness
+secretly
+secrets
+sect
+sect's
+section
+sectional
+sectionally
+sectioned
+sectioning
+sections
+sector
+sector's
+sectored
+sectoring
+sectors
+sects
+secular
+secularly
+secure
+secured
+securely
+secureness
+securer
+secures
+securing
+securings
+securities
+security
+sedge
+sediment
+sediment's
+sediments
+seduce
+seduced
+seducer
+seducers
+seduces
+seducing
+seductive
+seductively
+seductiveness
+see
+seed
+seeded
+seeder
+seeders
+seeding
+seedings
+seedling
+seedling's
+seedlings
+seeds
+seeing
+seek
+seeker
+seekers
+seeking
+seekingly
+seeks
+seem
+seemed
+seeming
+seemingly
+seemlier
+seemliness
+seemly
+seems
+seen
+seep
+seeped
+seeping
+seeps
+seer
+seers
+sees
+seethe
+seethed
+seethes
+seething
+segment
+segmentation
+segmentation's
+segmentations
+segmented
+segmenting
+segments
+segregate
+segregated
+segregates
+segregating
+segregation
+segregative
+seismic
+seizable
+seize
+seized
+seizer
+seizers
+seizes
+seizin
+seizing
+seizings
+seizins
+seizor
+seizors
+seizure
+seizure's
+seizures
+seldom
+select
+selected
+selecting
+selection
+selection's
+selections
+selective
+selectively
+selectiveness
+selectivity
+selectness
+selector
+selector's
+selectors
+selects
+self
+selfish
+selfishly
+selfishness
+selfness
+selfsame
+selfsameness
+sell
+seller
+sellers
+selling
+sells
+selves
+semantic
+semantical
+semantically
+semanticist
+semanticist's
+semanticists
+semantics
+semaphore
+semaphore's
+semaphores
+semblance
+semester
+semester's
+semesters
+semiautomated
+semicolon
+semicolon's
+semicolons
+semiconductor
+semiconductor's
+semiconductors
+seminal
+seminally
+seminar
+seminar's
+seminaries
+seminars
+seminary
+seminary's
+semipermanent
+semipermanently
+senate
+senate's
+senates
+senator
+senator's
+senators
+send
+sender
+senders
+sending
+sends
+senior
+senior's
+seniority
+seniors
+sensation
+sensation's
+sensational
+sensationally
+sensations
+sense
+sensed
+senseless
+senselessly
+senselessness
+senses
+sensibilities
+sensibility
+sensible
+sensibleness
+sensibly
+sensing
+sensitive
+sensitively
+sensitiveness
+sensitives
+sensitivities
+sensitivity
+sensor
+sensor's
+sensors
+sensory
+sent
+sentence
+sentenced
+sentences
+sentencing
+sentential
+sententially
+sentiment
+sentiment's
+sentimental
+sentimentally
+sentiments
+sentinel
+sentinel's
+sentinels
+sentries
+sentry
+sentry's
+separable
+separableness
+separate
+separated
+separately
+separateness
+separates
+separating
+separation
+separations
+separative
+separator
+separator's
+separators
+sequel
+sequel's
+sequels
+sequence
+sequenced
+sequencer
+sequencers
+sequences
+sequencing
+sequencings
+sequential
+sequentiality
+sequentially
+sequester
+sequestered
+sequestering
+serendipitous
+serendipitously
+serendipity
+serene
+serenely
+sereneness
+serenity
+serf
+serf's
+serfs
+sergeant
+sergeant's
+sergeants
+serial
+serially
+serials
+series
+serious
+seriously
+seriousness
+sermon
+sermon's
+sermons
+serpent
+serpent's
+serpentine
+serpentinely
+serpents
+serum
+serum's
+serums
+servant
+servant's
+servants
+serve
+served
+server
+server's
+servers
+serves
+service
+serviceable
+serviceableness
+serviced
+servicer
+services
+servicing
+servile
+servilely
+servileness
+serving
+servings
+servitude
+session
+session's
+sessions
+set
+set's
+sets
+setter
+setter's
+setters
+setting
+settings
+settle
+settled
+settlement
+settlement's
+settlements
+settler
+settlers
+settles
+settling
+settlings
+setup
+setups
+seven
+sevens
+seventeen
+seventeens
+seventeenth
+seventh
+seventies
+seventieth
+seventy
+sever
+several
+severally
+severals
+severance
+severe
+severed
+severely
+severeness
+severer
+severest
+severing
+severities
+severity
+severity's
+severs
+sew
+sewed
+sewer
+sewers
+sewing
+sews
+sex
+sexed
+sexes
+sexism
+sexism's
+sexist
+sexist's
+sexists
+sexual
+sexuality
+sexually
+shabbier
+shabbiness
+shabby
+shack
+shacked
+shackle
+shackled
+shackler
+shackles
+shackling
+shacks
+shade
+shaded
+shader
+shades
+shadier
+shadiest
+shadily
+shadiness
+shading
+shadings
+shadow
+shadowed
+shadower
+shadowiness
+shadowing
+shadows
+shadowy
+shady
+shaft
+shaft's
+shafted
+shafting
+shafts
+shaggier
+shagginess
+shaggy
+shakable
+shakably
+shake
+shaken
+shaker
+shakers
+shakes
+shakier
+shakiness
+shaking
+shaky
+shale
+shales
+shall
+shallow
+shallower
+shallowly
+shallowness
+shallows
+sham
+sham's
+shambles
+shame
+shamed
+shameful
+shamefully
+shamefulness
+shameless
+shamelessly
+shamelessness
+shames
+shaming
+shams
+shan't
+shanties
+shanty
+shanty's
+shape
+shaped
+shapeless
+shapelessly
+shapelessness
+shapelier
+shapeliness
+shapely
+shaper
+shapers
+shapes
+shaping
+sharable
+share
+sharecropper
+sharecropper's
+sharecroppers
+shared
+shareholder
+shareholder's
+shareholders
+sharer
+sharers
+shares
+sharing
+shark
+shark's
+sharks
+sharp
+sharped
+sharpen
+sharpened
+sharpener
+sharpening
+sharpens
+sharper
+sharpest
+sharping
+sharply
+sharpness
+sharps
+shatter
+shattered
+shattering
+shatteringly
+shatters
+shave
+shaved
+shaven
+shaver
+shaves
+shaving
+shavings
+shawl
+shawl's
+shawls
+she
+she'd
+she'll
+she's
+sheaf
+shear
+sheared
+shearer
+shearers
+shearing
+shears
+sheath
+sheather
+sheathing
+sheaths
+sheaves
+shed
+sheds
+sheep
+sheer
+sheered
+sheerly
+sheerness
+sheet
+sheeted
+sheeter
+sheeting
+sheets
+shelf
+shelfs
+shell
+shell's
+shelled
+sheller
+shelling
+shells
+shelter
+sheltered
+shelterer
+sheltering
+shelters
+shelve
+shelved
+shelver
+shelves
+shelving
+shepherd
+shepherd's
+shepherded
+shepherding
+shepherds
+sheriff
+sheriff's
+sheriffs
+shied
+shield
+shielded
+shielder
+shielding
+shields
+shier
+shies
+shiest
+shift
+shifted
+shifter
+shifters
+shiftier
+shiftiest
+shiftily
+shiftiness
+shifting
+shifts
+shifty
+shilling
+shillings
+shimmer
+shimmered
+shimmering
+shin
+shine
+shined
+shiner
+shiners
+shines
+shingle
+shingle's
+shingled
+shingler
+shingles
+shingling
+shinier
+shininess
+shining
+shiningly
+shiny
+ship
+ship's
+shipboard
+shipboards
+shipbuilding
+shipment
+shipment's
+shipments
+shippable
+shipped
+shipper
+shipper's
+shippers
+shipping
+ships
+shipwreck
+shipwrecked
+shipwrecks
+shirk
+shirker
+shirking
+shirks
+shirt
+shirting
+shirts
+shit
+shiver
+shivered
+shiverer
+shivering
+shivers
+shoal
+shoal's
+shoals
+shock
+shocked
+shocker
+shockers
+shocking
+shockingly
+shocks
+shod
+shoe
+shoed
+shoeing
+shoemaker
+shoer
+shoes
+shone
+shook
+shoot
+shooter
+shooters
+shooting
+shootings
+shoots
+shop
+shop's
+shopkeeper
+shopkeeper's
+shopkeepers
+shopped
+shopper
+shopper's
+shoppers
+shopping
+shops
+shore
+shore's
+shored
+shores
+shoring
+shorn
+short
+shortage
+shortage's
+shortages
+shortcoming
+shortcoming's
+shortcomings
+shortcut
+shortcut's
+shortcuts
+shorted
+shorten
+shortened
+shortener
+shortening
+shortens
+shorter
+shortest
+shorthand
+shorthanded
+shorthands
+shorting
+shortly
+shortness
+shorts
+shot
+shot's
+shotgun
+shotgun's
+shotguns
+shots
+should
+shoulder
+shouldered
+shouldering
+shoulders
+shouldest
+shouldn't
+shout
+shouted
+shouter
+shouters
+shouting
+shouts
+shove
+shoved
+shovel
+shovels
+shover
+shoves
+shoving
+show
+showed
+shower
+showered
+showering
+showers
+showing
+showings
+shown
+shows
+shrank
+shred
+shred's
+shredder
+shredder's
+shredders
+shreds
+shrew
+shrew's
+shrewd
+shrewdest
+shrewdly
+shrewdness
+shrews
+shriek
+shrieked
+shrieking
+shrieks
+shrill
+shrilled
+shrilling
+shrillness
+shrilly
+shrimp
+shrine
+shrine's
+shrines
+shrink
+shrinkable
+shrinker
+shrinking
+shrinks
+shrivel
+shrivels
+shroud
+shrouded
+shrouding
+shrouds
+shrub
+shrub's
+shrubbery
+shrubs
+shrug
+shrugs
+shrunk
+shrunken
+shudder
+shuddered
+shuddering
+shudders
+shuffle
+shuffled
+shuffler
+shuffles
+shuffling
+shun
+shuns
+shut
+shutdown
+shutdown's
+shutdowns
+shuts
+shutter
+shuttered
+shuttering
+shutters
+shutting
+shuttle
+shuttled
+shuttles
+shuttling
+shy
+shying
+shyly
+shyness
+sibling
+sibling's
+siblings
+sick
+sicken
+sickened
+sickener
+sickening
+sickeningly
+sicker
+sickerly
+sickest
+sicking
+sickle
+sickled
+sicklied
+sickliness
+sickling
+sickly
+sicklying
+sickness
+sickness's
+sicknesses
+sicks
+side
+sideboard
+sideboard's
+sideboards
+sideburns
+sided
+sidedness
+sidelight
+sidelight's
+sidelights
+sides
+sidetrack
+sidetracked
+sidetracking
+sidetracks
+sidewalk
+sidewalk's
+sidewalks
+sideways
+sidewise
+siding
+sidings
+siege
+siege's
+sieges
+sieging
+sierra
+sierras
+sieve
+sieve's
+sievers
+sieves
+sieving
+sift
+sifted
+sifter
+sifting
+siftings
+sifts
+sigh
+sighed
+sigher
+sighing
+sighs
+sight
+sighted
+sighter
+sighting
+sightings
+sightliness
+sightly
+sights
+sign
+signal
+signally
+signals
+signature
+signature's
+signatures
+signed
+signer
+signers
+signet
+significance
+significances
+significant
+significantly
+significants
+signification
+signified
+signifier
+signifies
+signify
+signifying
+signing
+signs
+silence
+silenced
+silencer
+silencers
+silences
+silencing
+silent
+silently
+silentness
+silents
+silhouette
+silhouetted
+silhouettes
+silicon
+silicone
+silicons
+silk
+silken
+silkier
+silkiest
+silkily
+silkiness
+silks
+silky
+sill
+sill's
+sillier
+silliest
+silliness
+sills
+silly
+silt
+silted
+silting
+silts
+silver
+silvered
+silverer
+silveriness
+silvering
+silverly
+silvers
+silvery
+similar
+similarities
+similarity
+similarly
+similitude
+simmer
+simmered
+simmering
+simmers
+simple
+simpleness
+simpler
+simples
+simplest
+simplex
+simplexes
+simplicities
+simplicity
+simplicity's
+simplification
+simplifications
+simplified
+simplifier
+simplifiers
+simplifies
+simplify
+simplifying
+simplistic
+simply
+simulate
+simulated
+simulates
+simulating
+simulation
+simulations
+simulative
+simulator
+simulator's
+simulators
+simultaneity
+simultaneous
+simultaneously
+simultaneousness
+sin
+sin's
+since
+sincere
+sincerely
+sincereness
+sincerest
+sincerity
+sine
+sines
+sinew
+sinew's
+sinews
+sinful
+sinfully
+sinfulness
+sing
+singable
+singed
+singer
+singer's
+singers
+singing
+singingly
+single
+singled
+singleness
+singles
+singleton
+singleton's
+singletons
+singling
+singly
+sings
+singular
+singularities
+singularity
+singularity's
+singularly
+sining
+sinister
+sinisterly
+sinisterness
+sink
+sinked
+sinker
+sinkers
+sinkhole
+sinkholes
+sinking
+sinks
+sinned
+sinner
+sinner's
+sinners
+sinning
+sins
+sinusoidal
+sinusoidally
+sinusoids
+sip
+sips
+sir
+sire
+sired
+siren
+sirens
+sires
+siring
+sirs
+sirup
+sister
+sister's
+sistered
+sistering
+sisterly
+sisters
+sit
+site
+site's
+sited
+sites
+siting
+sits
+sitter
+sitter's
+sitters
+sitting
+sittings
+situate
+situated
+situates
+situating
+situation
+situational
+situationally
+situations
+six
+sixes
+sixpence
+sixpences
+sixteen
+sixteens
+sixteenth
+sixth
+sixthly
+sixties
+sixtieth
+sixty
+sizable
+sizableness
+size
+sized
+sizer
+sizers
+sizes
+sizing
+sizings
+skate
+skated
+skater
+skater's
+skaters
+skates
+skating
+skeletal
+skeletally
+skeleton
+skeleton's
+skeletons
+skeptic
+skeptic's
+skeptical
+skeptically
+skeptics
+sketch
+sketched
+sketcher
+sketches
+sketchier
+sketchily
+sketchiness
+sketching
+sketchy
+skew
+skewed
+skewer
+skewered
+skewering
+skewers
+skewing
+skewness
+skews
+ski
+skied
+skien
+skier
+skies
+skiing
+skill
+skilled
+skillful
+skillfully
+skillfulness
+skilling
+skills
+skim
+skim's
+skimmed
+skimmer
+skimmer's
+skimmers
+skimming
+skimmings
+skimp
+skimped
+skimping
+skimps
+skims
+skin
+skin's
+skinned
+skinner
+skinner's
+skinners
+skinning
+skins
+skip
+skipped
+skipper
+skipper's
+skippered
+skippering
+skippers
+skipping
+skips
+skirmish
+skirmished
+skirmisher
+skirmishers
+skirmishes
+skirmishing
+skirt
+skirted
+skirter
+skirting
+skirts
+skis
+skulk
+skulked
+skulker
+skulking
+skulks
+skull
+skull's
+skulled
+skulls
+skunk
+skunk's
+skunks
+sky
+sky's
+skying
+skylark
+skylarker
+skylarking
+skylarks
+skylight
+skylight's
+skylights
+skyscraper
+skyscraper's
+skyscrapers
+slab
+slabs
+slack
+slacked
+slacken
+slackened
+slackening
+slackens
+slacker
+slackest
+slacking
+slackly
+slackness
+slacks
+slain
+slam
+slammed
+slamming
+slams
+slander
+slandered
+slanderer
+slandering
+slanders
+slang
+slanging
+slant
+slanted
+slanting
+slantingly
+slants
+slap
+slapped
+slapping
+slaps
+slash
+slashed
+slasher
+slashes
+slashing
+slashingly
+slat
+slat's
+slate
+slated
+slater
+slaters
+slates
+slating
+slats
+slaughter
+slaughtered
+slaughterer
+slaughtering
+slaughters
+slave
+slaved
+slaver
+slavered
+slavering
+slavery
+slaves
+slaving
+slay
+slayer
+slayers
+slaying
+slays
+sled
+sled's
+sledge
+sledge's
+sledges
+sledging
+sleds
+sleek
+sleekly
+sleekness
+sleep
+sleeper
+sleepers
+sleepier
+sleepily
+sleepiness
+sleeping
+sleepless
+sleeplessly
+sleeplessness
+sleeps
+sleepy
+sleet
+sleeve
+sleeve's
+sleeved
+sleeves
+sleeving
+sleigh
+sleighs
+sleken
+slekened
+slekening
+slender
+slenderer
+slenderly
+slenderness
+slept
+slew
+slewed
+slewing
+slice
+sliced
+slicer
+slicers
+slices
+slicing
+slick
+slicker
+slickers
+slickly
+slickness
+slicks
+slid
+slide
+slider
+sliders
+slides
+sliding
+slier
+sliest
+slight
+slighted
+slighter
+slightest
+slighting
+slightingly
+slightly
+slightness
+slights
+slim
+slime
+slimed
+slimes
+slimier
+sliminess
+sliming
+slimly
+slimness
+slimy
+sling
+slinger
+slinging
+slings
+slip
+slip's
+slippage
+slipped
+slipper
+slipper's
+slipperier
+slipperiness
+slippers
+slippery
+slipping
+slips
+slit
+slit's
+slits
+slogan
+slogan's
+slogans
+slop
+slope
+sloped
+sloper
+slopers
+slopes
+sloping
+slopped
+sloppier
+sloppiness
+slopping
+sloppy
+slops
+slot
+slot's
+sloth
+sloths
+slots
+slotted
+slouch
+slouched
+sloucher
+slouches
+slouching
+slow
+slowed
+slower
+slowest
+slowing
+slowly
+slowness
+slows
+slug
+sluggish
+sluggishly
+sluggishness
+slugs
+slum
+slum's
+slumber
+slumber's
+slumbered
+slumberer
+slumbering
+slumbers
+slump
+slumped
+slumps
+slums
+slung
+slur
+slur's
+slurs
+sly
+slyly
+smack
+smacked
+smacker
+smacking
+smacks
+small
+smaller
+smallest
+smallness
+smallpox
+smart
+smarted
+smarten
+smartened
+smartening
+smarter
+smartest
+smarting
+smartly
+smartness
+smarts
+smash
+smashed
+smasher
+smashers
+smashes
+smashing
+smashingly
+smear
+smeared
+smearer
+smearing
+smears
+smell
+smelled
+smeller
+smellier
+smelling
+smells
+smelly
+smelt
+smelter
+smelts
+smile
+smiled
+smiler
+smiles
+smiling
+smilingly
+smite
+smiter
+smith
+smith's
+smithies
+smiths
+smithy
+smiting
+smitten
+smock
+smocking
+smocks
+smog
+smokable
+smoke
+smoked
+smoker
+smoker's
+smokers
+smokes
+smokier
+smokies
+smokiness
+smoking
+smoky
+smolder
+smoldered
+smoldering
+smolderingly
+smolders
+smooth
+smoothed
+smoothen
+smoothened
+smoothening
+smoother
+smoothers
+smoothes
+smoothest
+smoothing
+smoothly
+smoothness
+smote
+smother
+smothered
+smothering
+smothers
+smug
+smuggle
+smuggled
+smuggler
+smugglers
+smuggles
+smuggling
+smugly
+smugness
+snail
+snail's
+snails
+snake
+snaked
+snakes
+snaking
+snap
+snapped
+snapper
+snapper's
+snappers
+snappier
+snappiest
+snappily
+snappiness
+snapping
+snappy
+snaps
+snapshot
+snapshot's
+snapshots
+snare
+snared
+snarer
+snares
+snarf
+snarfed
+snarfing
+snarfings
+snarfs
+snaring
+snarl
+snarled
+snarler
+snarling
+snarls
+snatch
+snatched
+snatcher
+snatches
+snatching
+sneak
+sneaked
+sneaker
+sneakered
+sneakers
+sneakier
+sneakiest
+sneakily
+sneakiness
+sneaking
+sneakingly
+sneaks
+sneaky
+sneer
+sneered
+sneerer
+sneering
+sneers
+sneeze
+sneezed
+sneezer
+sneezes
+sneezing
+sniff
+sniffed
+sniffer
+sniffing
+sniffs
+snoop
+snooped
+snooper
+snooping
+snoops
+snore
+snored
+snorer
+snores
+snoring
+snort
+snorted
+snorter
+snorting
+snorts
+snout
+snout's
+snouted
+snouts
+snow
+snowed
+snowier
+snowiest
+snowily
+snowiness
+snowing
+snowman
+snowmen
+snows
+snowshoe
+snowshoe's
+snowshoed
+snowshoer
+snowshoes
+snowy
+snuff
+snuffed
+snuffer
+snuffing
+snuffs
+snug
+snuggle
+snuggled
+snuggles
+snuggling
+snugly
+snugness
+snugs
+so
+soak
+soaked
+soaker
+soaking
+soaks
+soap
+soaped
+soaping
+soaps
+soar
+soared
+soarer
+soaring
+soars
+sob
+sober
+sobered
+soberer
+soberest
+sobering
+soberly
+soberness
+sobers
+sobs
+soccer
+sociability
+sociable
+sociably
+social
+socialism
+socialist
+socialist's
+socialists
+socially
+societal
+societally
+societies
+society
+society's
+sociological
+sociologically
+sociology
+sock
+socked
+socket
+socket's
+sockets
+socking
+socks
+sod
+sod's
+soda
+sodium
+sodomy
+sods
+sofa
+sofa's
+sofas
+soft
+soften
+softened
+softener
+softening
+softens
+softer
+softest
+softly
+softness
+software
+software's
+softwares
+soil
+soiled
+soiling
+soils
+sojourn
+sojourner
+sojourners
+solace
+solaced
+solacer
+solacing
+solar
+sold
+solder
+soldered
+solderer
+soldering
+solders
+soldier
+soldiered
+soldiering
+soldierly
+soldiers
+sole
+soled
+solely
+solemn
+solemnity
+solemnly
+solemnness
+soleness
+soles
+solicit
+solicited
+soliciting
+solicitor
+solicitors
+solicits
+solid
+solidification
+solidified
+solidifies
+solidify
+solidifying
+solidity
+solidly
+solidness
+solids
+soling
+solingen
+solitaire
+solitariness
+solitary
+solitude
+solitude's
+solitudes
+solo
+solo's
+soloed
+soloing
+solos
+solubility
+soluble
+solution
+solution's
+solutions
+solvable
+solve
+solved
+solvent
+solvent's
+solvently
+solvents
+solver
+solvers
+solves
+solving
+somber
+somberly
+somberness
+some
+somebody
+somebody's
+someday
+somehow
+someone
+someone's
+someplace
+someplace's
+somers
+something
+sometime
+sometimes
+somewhat
+somewhere
+somewheres
+son
+son's
+sonar
+sonars
+song
+song's
+songs
+sonly
+sonnet
+sonnet's
+sonnets
+sons
+soon
+sooner
+soonest
+soot
+sooth
+soothe
+soothed
+soother
+soothes
+soothing
+soothingly
+soothingness
+soothly
+sophisticated
+sophisticatedly
+sophistication
+sophomore
+sophomore's
+sophomores
+sorcerer
+sorcerer's
+sorcerers
+sorcery
+sordid
+sordidly
+sordidness
+sore
+sorely
+soreness
+sorer
+sores
+sorest
+sorrier
+sorriest
+sorriness
+sorrow
+sorrow's
+sorrower
+sorrowful
+sorrowfully
+sorrowfulness
+sorrows
+sorry
+sort
+sorted
+sorter
+sorters
+sorting
+sorts
+sos
+sought
+soul
+soul's
+souled
+souls
+sound
+sounded
+sounder
+soundest
+sounding
+sounding's
+soundingly
+soundings
+soundly
+soundness
+sounds
+soup
+soup's
+soups
+sour
+source
+source's
+sources
+soured
+sourer
+sourest
+souring
+sourly
+sourness
+sours
+south
+souther
+southerly
+southern
+southerner
+southerners
+southernly
+southernness
+southing
+sovereign
+sovereign's
+sovereignly
+sovereigns
+soviet
+soviet's
+soviets
+space
+spaced
+spacer
+spacers
+spaces
+spaceship
+spaceship's
+spaceships
+spacing
+spacings
+spade
+spaded
+spader
+spades
+spading
+spaghetti
+span
+span's
+spank
+spanked
+spanker
+spanking
+spanks
+spanned
+spanner
+spanner's
+spanners
+spanning
+spans
+spare
+spared
+sparely
+spareness
+sparer
+spares
+sparest
+sparing
+sparingly
+spark
+sparked
+sparker
+sparking
+sparks
+sparrow
+sparrow's
+sparrows
+sparse
+sparsely
+sparseness
+sparser
+sparsest
+spat
+spate
+spate's
+spates
+spatial
+spatially
+spats
+spatter
+spattered
+spawn
+spawned
+spawner
+spawning
+spawns
+speak
+speakable
+speaker
+speaker's
+speakers
+speaking
+speaks
+spear
+speared
+spearer
+spearing
+spears
+special
+specialist
+specialist's
+specialists
+specially
+specialness
+specials
+species
+specifiable
+specific
+specifically
+specification
+specifications
+specificities
+specificity
+specifics
+specified
+specifier
+specifiers
+specifies
+specify
+specifying
+specimen
+specimen's
+specimens
+speck
+speck's
+speckle
+speckled
+speckles
+speckling
+specks
+spectacle
+spectacled
+spectacles
+spectacular
+spectacularly
+spectator
+spectator's
+spectators
+spectra
+spectrogram
+spectrogram's
+spectrograms
+spectroscopically
+spectrum
+spectrums
+speculate
+speculated
+speculates
+speculating
+speculation
+speculations
+speculative
+speculatively
+speculator
+speculator's
+speculators
+sped
+speech
+speech's
+speeches
+speechless
+speechlessly
+speechlessness
+speed
+speeded
+speeder
+speeders
+speedier
+speedily
+speediness
+speeding
+speeds
+speedup
+speedup's
+speedups
+speedy
+spell
+spelled
+speller
+spellers
+spelling
+spellings
+spells
+spend
+spender
+spenders
+spending
+spends
+spent
+sphere
+sphere's
+spheres
+spherical
+spherically
+sphering
+spice
+spiced
+spices
+spicier
+spiciness
+spicing
+spicy
+spider
+spider's
+spiders
+spied
+spier
+spies
+spike
+spiked
+spiker
+spikes
+spiking
+spill
+spilled
+spiller
+spilling
+spills
+spin
+spinach
+spinal
+spinally
+spindle
+spindled
+spindler
+spindles
+spindling
+spine
+spines
+spinner
+spinner's
+spinners
+spinning
+spins
+spiral
+spirally
+spirals
+spire
+spire's
+spired
+spires
+spiring
+spirit
+spirited
+spiritedly
+spiritedness
+spiriting
+spirits
+spiritual
+spiritually
+spiritualness
+spirituals
+spit
+spite
+spited
+spiteful
+spitefully
+spitefulness
+spites
+spiting
+spits
+spitting
+splash
+splashed
+splasher
+splashers
+splashes
+splashing
+spleen
+splendid
+splendidly
+splendidness
+splice
+spliced
+splicer
+splicers
+splices
+splicing
+splicings
+spline
+spline's
+splined
+splines
+splinter
+splintered
+splintering
+splinters
+split
+split's
+splits
+splitter
+splitter's
+splitters
+splitting
+splittings
+spoil
+spoiled
+spoiler
+spoilers
+spoiling
+spoils
+spoke
+spoked
+spoken
+spokes
+spokesman
+spokesmen
+spoking
+sponge
+sponged
+sponger
+spongers
+sponges
+sponging
+sponsor
+sponsored
+sponsoring
+sponsors
+sponsorship
+spontaneous
+spontaneously
+spontaneousness
+spook
+spookier
+spookiness
+spooky
+spool
+spooled
+spooler
+spoolers
+spooling
+spools
+spoon
+spooned
+spooning
+spoons
+spore
+spore's
+spored
+spores
+sporing
+sport
+sported
+sporting
+sportingly
+sportive
+sportively
+sportiveness
+sports
+sportsman
+sportsmanly
+spot
+spot's
+spotless
+spotlessly
+spotlessness
+spotlight
+spotlight's
+spotlighted
+spotlighting
+spotlights
+spots
+spotted
+spotter
+spotter's
+spotters
+spotting
+spouse
+spouse's
+spouses
+spousing
+spout
+spouted
+spouter
+spouting
+spouts
+sprang
+sprawl
+sprawled
+sprawling
+sprawls
+spray
+sprayed
+sprayer
+spraying
+sprays
+spread
+spreader
+spreaders
+spreading
+spreadings
+spreads
+spreadsheet
+spreadsheets
+spree
+spree's
+sprees
+sprig
+sprightlier
+sprightliness
+sprightly
+spring
+springer
+springers
+springier
+springiest
+springiness
+springing
+springs
+springtime
+springy
+sprinkle
+sprinkled
+sprinkler
+sprinklered
+sprinkles
+sprinkling
+sprint
+sprinted
+sprinter
+sprinters
+sprinting
+sprints
+sprite
+sprout
+sprouted
+sprouting
+sprouts
+spruce
+spruced
+sprucely
+spruceness
+sprucer
+sprucest
+sprucing
+sprung
+spun
+spur
+spur's
+spurious
+spuriously
+spuriousness
+spurn
+spurned
+spurner
+spurning
+spurns
+spurs
+spurt
+spurted
+spurting
+spurts
+sputter
+sputtered
+sputterer
+spy
+spying
+squabble
+squabbled
+squabbler
+squabbles
+squabbling
+squad
+squad's
+squadron
+squadron's
+squadrons
+squads
+squall
+squall's
+squaller
+squalls
+square
+squared
+squarely
+squareness
+squarer
+squares
+squarest
+squaring
+squash
+squashed
+squasher
+squashes
+squashing
+squat
+squatly
+squatness
+squats
+squawk
+squawked
+squawker
+squawking
+squawks
+squeak
+squeaked
+squeaker
+squeaking
+squeaks
+squeal
+squealed
+squealer
+squealing
+squeals
+squeeze
+squeezed
+squeezer
+squeezes
+squeezing
+squid
+squids
+squint
+squinted
+squinter
+squinting
+squintingly
+squints
+squire
+squire's
+squires
+squiring
+squirm
+squirmed
+squirming
+squirms
+squirrel
+squirrelly
+squirrels
+stab
+stabbed
+stabbing
+stabilities
+stability
+stability's
+stable
+stabled
+stableness
+stabler
+stables
+stablest
+stabling
+stably
+stabs
+stack
+stack's
+stacked
+stacker
+stacking
+stacks
+staff
+staff's
+staffed
+staffer
+staffers
+staffing
+staffs
+stag
+stag's
+stage
+stagecoach
+staged
+stager
+stagers
+stages
+stagger
+staggered
+staggerer
+staggering
+staggeringly
+staggers
+staging
+stagnant
+stagnantly
+stags
+staid
+staidly
+staidness
+stain
+stained
+stainer
+staining
+stainless
+stainlessly
+stains
+stair
+stair's
+staircase
+staircase's
+staircases
+stairs
+stairway
+stairway's
+stairways
+stake
+staked
+stakes
+staking
+stale
+staled
+stalely
+staleness
+staler
+stales
+stalest
+staling
+stalk
+stalked
+stalker
+stalking
+stalks
+stall
+stalled
+stalling
+stallings
+stalls
+stalwart
+stalwartly
+stalwartness
+stamen
+stamen's
+stamens
+stamina
+stammer
+stammered
+stammerer
+stammering
+stammers
+stamp
+stamped
+stampede
+stampeded
+stampeder
+stampedes
+stampeding
+stamper
+stampers
+stamping
+stamps
+stance
+stance's
+stances
+stanch
+stancher
+stanchest
+stand
+standard
+standardly
+standards
+standby
+stander
+standing
+standings
+standpoint
+standpoint's
+standpoints
+stands
+standstill
+stanza
+stanza's
+stanzas
+staple
+stapled
+stapler
+staplers
+staples
+stapling
+star
+star's
+starboard
+starboarded
+starboarding
+starboards
+starch
+starched
+starches
+starching
+stare
+stared
+starer
+stares
+starfish
+staring
+stark
+starkest
+starkly
+starkness
+starlet
+starlet's
+starlets
+starlight
+starred
+starrier
+starring
+starry
+stars
+start
+started
+starter
+starters
+starting
+startle
+startled
+startles
+startling
+startlingly
+startlingness
+starts
+startup
+startup's
+startups
+starvation
+starve
+starved
+starver
+starves
+starving
+state
+state's
+stated
+statelier
+stateliness
+stately
+statement
+statement's
+statements
+stater
+states
+statesman
+statesman's
+statesmanly
+static
+statically
+statics
+stating
+station
+stationaries
+stationary
+stationed
+stationer
+stationing
+stations
+statistic
+statistic's
+statistical
+statistically
+statistician
+statistician's
+statisticians
+statistics
+stative
+statue
+statue's
+statued
+statues
+statuesque
+statuesquely
+statuesqueness
+stature
+status
+statuses
+statute
+statute's
+statutes
+statutorily
+statutoriness
+statutory
+staunch
+staunchest
+staunchly
+staunchness
+stave
+staved
+staves
+staving
+stay
+stayed
+stayer
+stayers
+staying
+stays
+stdio
+stead
+steadfast
+steadfastly
+steadfastness
+steadied
+steadier
+steadies
+steadiest
+steadily
+steadiness
+steading
+steady
+steadying
+steak
+steak's
+steaks
+steal
+stealer
+stealing
+steals
+stealth
+stealthier
+stealthily
+stealthiness
+stealthy
+steam
+steamboat
+steamboat's
+steamboats
+steamed
+steamer
+steamers
+steaming
+steams
+steamship
+steamship's
+steamships
+steed
+steeds
+steel
+steeled
+steelers
+steeling
+steels
+steep
+steeped
+steepen
+steepened
+steepening
+steeper
+steepest
+steeping
+steeple
+steeple's
+steeples
+steeply
+steepness
+steeps
+steer
+steered
+steerer
+steering
+steers
+stellar
+stem
+stem's
+stemmed
+stemming
+stems
+stench
+stench's
+stenches
+stencil
+stencil's
+stencils
+stenographer
+stenographer's
+stenographers
+step
+step's
+stepmother
+stepmother's
+stepmothers
+stepped
+stepper
+stepping
+steps
+stepwise
+stereo
+stereo's
+stereos
+stereotype
+stereotyped
+stereotyper
+stereotypers
+stereotypes
+stereotypical
+stereotypically
+stereotyping
+sterile
+sterling
+sterlingly
+sterlingness
+stern
+sternly
+sternness
+sterns
+stew
+steward
+steward's
+stewards
+stewed
+stewing
+stews
+stick
+sticked
+sticker
+stickers
+stickier
+stickiest
+stickily
+stickiness
+sticking
+sticks
+sticky
+stiff
+stiffen
+stiffened
+stiffener
+stiffeners
+stiffening
+stiffens
+stiffer
+stiffest
+stiffly
+stiffness
+stiffnesses
+stiffs
+stifle
+stifled
+stifler
+stifles
+stifling
+stiflingly
+stigma
+stigmas
+stile
+stile's
+stiles
+still
+stilled
+stiller
+stillest
+stilling
+stillness
+stills
+stimulant
+stimulant's
+stimulants
+stimulate
+stimulated
+stimulates
+stimulating
+stimulation
+stimulations
+stimulative
+stimuli
+stimulus
+sting
+stinger
+stinging
+stingingly
+stings
+stink
+stinker
+stinkers
+stinking
+stinkingly
+stinks
+stint
+stint's
+stinted
+stinter
+stinting
+stints
+stipend
+stipend's
+stipends
+stipple
+stippled
+stippler
+stipples
+stippling
+stipulate
+stipulated
+stipulates
+stipulating
+stipulation
+stipulations
+stir
+stirred
+stirrer
+stirrer's
+stirrers
+stirring
+stirringly
+stirrings
+stirrup
+stirrups
+stirs
+stitch
+stitched
+stitcher
+stitches
+stitching
+stochastic
+stochastically
+stock
+stockade
+stockade's
+stockaded
+stockades
+stockading
+stocked
+stocker
+stockers
+stockholder
+stockholder's
+stockholders
+stocking
+stockinged
+stockings
+stocks
+stole
+stole's
+stoled
+stolen
+stoles
+stomach
+stomached
+stomacher
+stomaches
+stomaching
+stone
+stone's
+stoned
+stoner
+stones
+stonier
+stoniness
+stoning
+stony
+stood
+stool
+stools
+stoop
+stooped
+stooping
+stoops
+stop
+stop's
+stopcock
+stopcocks
+stopgap
+stopgap's
+stopgaps
+stoppable
+stoppage
+stoppages
+stopped
+stopper
+stopper's
+stoppered
+stoppering
+stoppers
+stopping
+stops
+storage
+storage's
+storages
+store
+stored
+storehouse
+storehouse's
+storehouses
+stores
+storied
+stories
+storing
+stork
+stork's
+storks
+storm
+stormed
+stormier
+stormiest
+storminess
+storming
+storms
+stormy
+story
+story's
+storying
+stout
+stouten
+stoutened
+stoutening
+stouter
+stoutest
+stoutly
+stoutness
+stove
+stove's
+stover
+stoves
+stow
+stowed
+stowing
+stows
+straggle
+straggled
+straggler
+stragglers
+straggles
+straggling
+straight
+straighten
+straightened
+straightener
+straighteners
+straightening
+straightens
+straighter
+straightest
+straightforward
+straightforwardly
+straightforwardness
+straightforwards
+straightly
+straightness
+straightway
+strain
+strained
+strainer
+strainers
+straining
+strains
+strait
+straiten
+straitened
+straitening
+straitly
+straitness
+straits
+strand
+stranded
+strandedness
+strander
+stranding
+strands
+strange
+strangely
+strangeness
+stranger
+stranger's
+strangers
+strangest
+strangle
+strangled
+strangler
+stranglers
+strangles
+strangling
+stranglings
+strangulation
+strangulation's
+strangulations
+strap
+strap's
+straps
+stratagem
+stratagem's
+stratagems
+strategic
+strategics
+strategies
+strategy
+strategy's
+stratification
+stratifications
+stratified
+stratifies
+stratify
+stratifying
+stratum
+straw
+straw's
+strawberries
+strawberry
+strawberry's
+straws
+stray
+stray's
+strayed
+strayer
+straying
+strays
+streak
+streaked
+streaking
+streaks
+stream
+streamed
+streamer
+streamers
+streaming
+streamline
+streamlined
+streamliner
+streamlines
+streamlining
+streams
+street
+streetcar
+streetcar's
+streetcars
+streeters
+streets
+strength
+strengthen
+strengthened
+strengthener
+strengthening
+strengthens
+strengths
+strenuous
+strenuously
+strenuousness
+stress
+stressed
+stresses
+stressing
+stretch
+stretched
+stretcher
+stretchers
+stretches
+stretching
+strew
+strewing
+strewn
+strews
+strewth
+stricken
+strict
+stricter
+strictest
+strictly
+strictness
+stride
+strider
+strides
+striding
+strife
+strike
+striker
+strikers
+strikes
+striking
+strikingly
+string
+string's
+stringed
+stringent
+stringently
+stringer
+stringers
+stringier
+stringiest
+stringiness
+stringing
+strings
+stringy
+strip
+strip's
+stripe
+striped
+striper
+stripes
+striping
+stripped
+stripper
+stripper's
+strippers
+stripping
+strips
+strive
+striver
+strives
+striving
+strivings
+strobe
+strobe's
+strobed
+strobes
+strobing
+stroboscopic
+strode
+stroke
+stroked
+stroker
+strokers
+strokes
+stroking
+stroll
+strolled
+stroller
+strolling
+strolls
+strong
+stronger
+strongest
+stronghold
+strongly
+strove
+struck
+structural
+structurally
+structure
+structured
+structurer
+structures
+structuring
+struggle
+struggled
+struggler
+struggles
+struggling
+strung
+strut
+struts
+strutted
+strutter
+strutting
+stub
+stub's
+stubbed
+stubbing
+stubble
+stubborn
+stubbornly
+stubbornness
+stubs
+stuck
+stud
+stud's
+student
+student's
+students
+studied
+studiedly
+studiedness
+studier
+studies
+studio
+studio's
+studios
+studious
+studiously
+studiousness
+studs
+study
+studying
+stuff
+stuffed
+stuffer
+stuffier
+stuffiest
+stuffiness
+stuffing
+stuffings
+stuffs
+stuffy
+stumble
+stumbled
+stumbler
+stumbles
+stumbling
+stumblingly
+stump
+stumped
+stumper
+stumping
+stumps
+stun
+stung
+stunning
+stunningly
+stuns
+stunt
+stunt's
+stunted
+stuntedness
+stunting
+stunts
+stupefy
+stupefying
+stupendous
+stupendously
+stupendousness
+stupid
+stupider
+stupidest
+stupidities
+stupidity
+stupidly
+stupidness
+stupor
+sturdier
+sturdiness
+sturdy
+style
+styled
+styler
+stylers
+styles
+styling
+stylish
+stylishly
+stylishness
+stylistic
+stylistically
+stylistics
+sub
+subatomic
+subclass
+subclass's
+subclasses
+subcommittee
+subcommittee's
+subcommittees
+subcomponent
+subcomponent's
+subcomponents
+subcomputation
+subcomputation's
+subcomputations
+subconscious
+subconsciously
+subconsciousness
+subculture
+subculture's
+subcultures
+subdivide
+subdivided
+subdivider
+subdivides
+subdividing
+subdivision
+subdivision's
+subdivisions
+subdue
+subdued
+subduedly
+subduer
+subdues
+subduing
+subexpression
+subexpression's
+subexpressions
+subfield
+subfield's
+subfields
+subfile
+subfile's
+subfiles
+subgoal
+subgoal's
+subgoals
+subgraph
+subgraphs
+subgroup
+subgroup's
+subgrouping
+subgroups
+subinterval
+subinterval's
+subintervals
+subject
+subject's
+subjected
+subjecting
+subjection
+subjective
+subjectively
+subjectiveness
+subjectivity
+subjects
+sublimation
+sublimations
+sublime
+sublimed
+sublimely
+sublimeness
+sublimer
+subliming
+sublist
+sublist's
+sublists
+submarine
+submarined
+submariner
+submariners
+submarines
+submarining
+submerge
+submerged
+submerges
+submerging
+submission
+submission's
+submissions
+submit
+submits
+submitted
+submitting
+submode
+submodes
+submodule
+submodule's
+submodules
+subnetwork
+subnetwork's
+subnetworks
+subordinate
+subordinated
+subordinately
+subordinateness
+subordinates
+subordinating
+subordination
+subordinative
+subproblem
+subproblem's
+subproblems
+subprocess
+subprocess's
+subprocesses
+subprogram
+subprogram's
+subprograms
+subproject
+subproof
+subproof's
+subproofs
+subrange
+subrange's
+subranges
+subroutine
+subroutine's
+subroutines
+subs
+subschema
+subschema's
+subschemas
+subscribe
+subscribed
+subscriber
+subscribers
+subscribes
+subscribing
+subscript
+subscripted
+subscripting
+subscription
+subscription's
+subscriptions
+subscripts
+subsection
+subsection's
+subsections
+subsegment
+subsegment's
+subsegments
+subsequence
+subsequence's
+subsequences
+subsequent
+subsequently
+subsequentness
+subset
+subset's
+subsets
+subside
+subsided
+subsides
+subsidiaries
+subsidiary
+subsidiary's
+subsidies
+subsiding
+subsidy
+subsidy's
+subsist
+subsisted
+subsistence
+subsisting
+subsists
+subspace
+subspace's
+subspaces
+substance
+substance's
+substances
+substantial
+substantially
+substantialness
+substantiate
+substantiated
+substantiates
+substantiating
+substantiation
+substantiations
+substantiative
+substantive
+substantively
+substantiveness
+substantivity
+substitutability
+substitutable
+substitute
+substituted
+substituter
+substitutes
+substituting
+substitution
+substitutions
+substitutive
+substitutively
+substrate
+substrate's
+substrates
+substring
+substrings
+substructure
+substructure's
+substructures
+subsume
+subsumed
+subsumes
+subsuming
+subsystem
+subsystem's
+subsystems
+subtask
+subtask's
+subtasks
+subterranean
+subterraneanly
+subtitle
+subtitle's
+subtitled
+subtitles
+subtitling
+subtle
+subtleness
+subtler
+subtlest
+subtleties
+subtlety
+subtly
+subtopic
+subtopic's
+subtopics
+subtract
+subtracted
+subtracter
+subtracter's
+subtracters
+subtracting
+subtraction
+subtractions
+subtractive
+subtracts
+subtrahend
+subtrahend's
+subtrahends
+subtree
+subtree's
+subtrees
+subunit
+subunit's
+subunits
+suburb
+suburb's
+suburban
+suburbs
+subversion
+subvert
+subverted
+subverter
+subverting
+subverts
+subway
+subway's
+subways
+succeed
+succeeded
+succeeder
+succeeding
+succeeds
+success
+successes
+successful
+successfully
+successfulness
+succession
+succession's
+successions
+successive
+successively
+successiveness
+successor
+successor's
+successors
+succinct
+succinctly
+succinctness
+succumb
+succumbed
+succumbing
+succumbs
+such
+suck
+sucked
+sucker
+suckered
+suckering
+suckers
+sucking
+suckle
+suckled
+suckles
+suckling
+sucks
+suction
+sudden
+suddenly
+suddenness
+suds
+sudser
+sudsing
+sue
+sued
+sueded
+sueding
+suer
+sues
+suffer
+sufferance
+suffered
+sufferer
+sufferers
+suffering
+sufferings
+suffers
+suffice
+sufficed
+sufficer
+suffices
+sufficiency
+sufficient
+sufficiently
+sufficing
+suffix
+suffixed
+suffixer
+suffixes
+suffixing
+suffocate
+suffocated
+suffocates
+suffocating
+suffocatingly
+suffocation
+suffocative
+suffrage
+sugar
+sugared
+sugaring
+sugarings
+sugars
+suggest
+suggested
+suggester
+suggestible
+suggesting
+suggestion
+suggestion's
+suggestions
+suggestive
+suggestively
+suggestiveness
+suggests
+suicidal
+suicidally
+suicide
+suicide's
+suicided
+suicides
+suiciding
+suing
+suit
+suit's
+suitability
+suitable
+suitableness
+suitably
+suitcase
+suitcase's
+suitcases
+suite
+suited
+suiters
+suites
+suiting
+suitor
+suitor's
+suitors
+suits
+sulk
+sulked
+sulkies
+sulkiness
+sulking
+sulks
+sulky
+sullen
+sullenly
+sullenness
+sulphate
+sulphates
+sulphur
+sulphured
+sulphuric
+sultan
+sultan's
+sultans
+sultrier
+sultriness
+sultry
+sum
+sum's
+sumer
+summand
+summand's
+summands
+summaries
+summary
+summary's
+summation
+summation's
+summations
+summed
+summer
+summer's
+summered
+summering
+summers
+summing
+summit
+summon
+summoned
+summoner
+summoners
+summoning
+summons
+summonses
+sumptuous
+sumptuously
+sumptuousness
+sums
+sun
+sun's
+sunbeam
+sunbeam's
+sunbeams
+sunburn
+sundown
+sundowner
+sundowners
+sundries
+sundry
+sung
+sunglass
+sunglasses
+sunk
+sunken
+sunlight
+sunlights
+sunned
+sunnier
+sunniness
+sunning
+sunny
+sunrise
+sunrises
+suns
+sunset
+sunsets
+sunshine
+sunshines
+sup
+super
+superb
+superbly
+superbness
+superclass
+superclass's
+supercomputer
+supercomputer's
+supercomputers
+supered
+superego
+superego's
+superegos
+superficial
+superficially
+superficialness
+superfluities
+superfluity
+superfluity's
+superfluous
+superfluously
+superfluousness
+superhuman
+superhumanly
+superhumanness
+superimpose
+superimposed
+superimposes
+superimposing
+supering
+superintend
+superintendent
+superintendent's
+superintendents
+superior
+superior's
+superiority
+superiorly
+superiors
+superlative
+superlatively
+superlativeness
+superlatives
+supermarket
+supermarket's
+supermarkets
+superpose
+superposed
+superposes
+superposing
+superscript
+superscripted
+superscripting
+superscripts
+supersede
+superseded
+superseder
+supersedes
+superseding
+superset
+superset's
+supersets
+superstition
+superstition's
+superstitions
+superstitious
+superstitiously
+superstitiousness
+supertitle
+supertitle's
+supertitled
+supertitles
+supertitling
+superuser
+superuser's
+superusers
+supervise
+supervised
+supervises
+supervising
+supervision
+supervisions
+supervisor
+supervisor's
+supervisors
+supervisory
+supper
+supper's
+suppers
+supplant
+supplanted
+supplanter
+supplanting
+supplants
+supple
+suppled
+supplely
+supplement
+supplemental
+supplementaries
+supplementary
+supplemented
+supplementer
+supplementing
+supplements
+suppleness
+suppler
+supplication
+supplied
+supplier
+supplier's
+suppliers
+supplies
+suppling
+supply
+supply's
+supplying
+support
+supportable
+supported
+supporter
+supporters
+supporting
+supportingly
+supportive
+supportively
+supports
+suppose
+supposed
+supposedly
+supposer
+supposes
+supposing
+supposition
+supposition's
+suppositions
+suppress
+suppressed
+suppresses
+suppressing
+suppression
+suppressions
+suppressive
+suppressiveness
+supremacy
+supreme
+supremely
+supremeness
+sure
+sured
+surely
+sureness
+surer
+surest
+sureties
+surety
+surf
+surface
+surfaced
+surfaceness
+surfacer
+surfacers
+surfaces
+surfacing
+surfer
+surfer's
+surfers
+surfing
+surge
+surged
+surgely
+surgeon
+surgeon's
+surgeons
+surgeries
+surgery
+surges
+surgical
+surgically
+surging
+surlier
+surliness
+surly
+surmise
+surmised
+surmiser
+surmises
+surmising
+surmount
+surmounted
+surmounting
+surmounts
+surname
+surname's
+surnamed
+surnames
+surpass
+surpassed
+surpasses
+surpassing
+surpassingly
+surplus
+surplus's
+surpluses
+surprise
+surprise's
+surprised
+surpriser
+surprises
+surprising
+surprisingly
+surrender
+surrendered
+surrenderer
+surrendering
+surrenders
+surrogate
+surrogate's
+surrogates
+surrogation
+surround
+surrounded
+surrounding
+surroundings
+surrounds
+survey
+surveyed
+surveying
+surveyor
+surveyor's
+surveyors
+surveys
+survival
+survivals
+survive
+survived
+surviver
+survives
+surviving
+survivor
+survivor's
+survivors
+susceptible
+suspect
+suspected
+suspecter
+suspecting
+suspects
+suspend
+suspended
+suspender
+suspender's
+suspenders
+suspending
+suspends
+suspense
+suspenses
+suspension
+suspensions
+suspensive
+suspensively
+suspicion
+suspicion's
+suspicioned
+suspicioning
+suspicions
+suspicious
+suspiciously
+suspiciousness
+sustain
+sustained
+sustainer
+sustaining
+sustains
+suture
+sutured
+sutures
+suturing
+swagger
+swaggered
+swaggering
+swain
+swain's
+swains
+swallow
+swallowed
+swallower
+swallowing
+swallows
+swam
+swamp
+swamped
+swamper
+swampier
+swampiness
+swamping
+swamps
+swampy
+swan
+swan's
+swans
+swap
+swapped
+swapper
+swapper's
+swappers
+swapping
+swaps
+swarm
+swarmed
+swarmer
+swarming
+swarms
+swarthier
+swarthiness
+swarthy
+swatted
+sway
+swayed
+swayer
+swaying
+sways
+swear
+swearer
+swearing
+swears
+sweat
+sweated
+sweater
+sweaters
+sweating
+sweats
+sweep
+sweeper
+sweepers
+sweeping
+sweepingly
+sweepingness
+sweepings
+sweeps
+sweet
+sweeten
+sweetened
+sweetener
+sweeteners
+sweetening
+sweetenings
+sweetens
+sweeter
+sweetest
+sweetheart
+sweetheart's
+sweethearts
+sweetie
+sweetie's
+sweeties
+sweeting
+sweetly
+sweetness
+sweets
+swell
+swelled
+swelling
+swellings
+swells
+swept
+swerve
+swerved
+swerves
+swerving
+swift
+swifter
+swiftest
+swiftly
+swiftness
+swim
+swimmer
+swimmer's
+swimmers
+swimming
+swimmingly
+swims
+swimsuit
+swimsuit's
+swimsuits
+swine
+swing
+swinger
+swingers
+swinging
+swingingly
+swings
+swipe
+swiped
+swipes
+swiping
+swirl
+swirled
+swirler
+swirling
+swirlingly
+swirls
+swish
+swished
+swisher
+switch
+switch's
+switchboard
+switchboard's
+switchboards
+switched
+switcher
+switchers
+switches
+switching
+switchings
+swollen
+swoon
+swooned
+swooner
+swooning
+swooningly
+swoons
+swoop
+swooped
+swooper
+swooping
+swoops
+sword
+sword's
+swords
+swore
+sworn
+swum
+swung
+sycamore
+syllabi
+syllable
+syllable's
+syllabled
+syllables
+syllabling
+syllabus
+syllogism
+syllogism's
+syllogisms
+symbiosis
+symbiotic
+symbol
+symbol's
+symbolic
+symbolic's
+symbolically
+symbolics
+symbolism
+symbolisms
+symbols
+symmetric
+symmetrical
+symmetrically
+symmetricalness
+symmetries
+symmetry
+symmetry's
+sympathetic
+sympathies
+sympathy
+sympathy's
+symphonies
+symphony
+symphony's
+symposium
+symposiums
+symptom
+symptom's
+symptomatic
+symptoms
+synapse
+synapse's
+synapsed
+synapses
+synapsing
+synchronous
+synchronously
+synchronousness
+synchrony
+syndicate
+syndicated
+syndicates
+syndicating
+syndication
+syndrome
+syndrome's
+syndromes
+synergism
+synergistic
+synonym
+synonym's
+synonymous
+synonymously
+synonyms
+synopses
+synopsis
+syntactic
+syntactical
+syntactically
+syntacticly
+syntactics
+syntax
+syntaxes
+syntheses
+synthesis
+synthetic
+synthetics
+syringe
+syringed
+syringes
+syringing
+syrup
+system
+system's
+systematic
+systematically
+systematicness
+systematics
+systems
+tab
+tabernacle
+tabernacle's
+tabernacled
+tabernacles
+tabernacling
+table
+tableau
+tableau's
+tableaus
+tablecloth
+tablecloths
+tabled
+tables
+tablespoon
+tablespoon's
+tablespoonful
+tablespoonful's
+tablespoonfuls
+tablespoons
+tablet
+tablet's
+tablets
+tabling
+taboo
+taboo's
+taboos
+tabs
+tabular
+tabularly
+tabulate
+tabulated
+tabulates
+tabulating
+tabulation
+tabulations
+tabulator
+tabulator's
+tabulators
+tachometer
+tachometer's
+tachometers
+tachometry
+tacit
+tacitly
+tacitness
+tack
+tacked
+tacker
+tacking
+tackle
+tackle's
+tackled
+tackler
+tackles
+tackling
+tacks
+tact
+tactics
+tactile
+tactilely
+tag
+tag's
+tagged
+tagging
+tags
+tail
+tailed
+tailer
+tailing
+tailings
+tailor
+tailored
+tailoring
+tailors
+tails
+taint
+tainted
+taints
+take
+taken
+taker
+takers
+takes
+taketh
+taking
+takings
+tale
+tale's
+talent
+talented
+talents
+taler
+tales
+talion
+talk
+talkative
+talkatively
+talkativeness
+talked
+talker
+talkers
+talkie
+talking
+talks
+tall
+taller
+tallest
+tallness
+tallow
+tame
+tamed
+tamely
+tameness
+tamer
+tames
+tamest
+taming
+tamper
+tampered
+tamperer
+tampering
+tampers
+tan
+tandem
+tang
+tanged
+tangent
+tangent's
+tangential
+tangentially
+tangents
+tangible
+tangibleness
+tangibly
+tangier
+tangle
+tangled
+tangles
+tangling
+tangly
+tangy
+tank
+tanked
+tanker
+tankers
+tanking
+tanks
+tanner
+tanner's
+tanners
+tans
+tantamount
+tantrum
+tantrum's
+tantrums
+tap
+tap's
+tape
+taped
+taper
+tapered
+taperer
+tapering
+tapers
+tapes
+tapestried
+tapestries
+tapestry
+tapestry's
+taping
+tapings
+tapped
+tapper
+tapper's
+tappers
+tapping
+taproot
+taproot's
+taproots
+taps
+tar
+tardier
+tardies
+tardiness
+tardy
+target
+targeted
+targeting
+targets
+tariff
+tariff's
+tariffs
+taring
+tarried
+tarries
+tarry
+tarrying
+tars
+tart
+tartly
+tartness
+tarts
+task
+tasked
+tasking
+tasks
+taste
+tasted
+tasteful
+tastefully
+tastefulness
+tasteless
+tastelessly
+tastelessness
+taster
+tasters
+tastes
+tasting
+tatter
+tattered
+tattoo
+tattooed
+tattooer
+tattoos
+tau
+taught
+taunt
+taunted
+taunter
+taunting
+tauntingly
+taunts
+taut
+tauten
+tautened
+tautening
+tautly
+tautness
+tautological
+tautologically
+tautologies
+tautology
+tautology's
+tavern
+tavern's
+taverner
+taverns
+tawnier
+tawnies
+tawniness
+tawny
+tax
+taxable
+taxation
+taxed
+taxer
+taxes
+taxi
+taxi's
+taxicab
+taxicab's
+taxicabs
+taxied
+taxiing
+taxing
+taxingly
+taxis
+taxonomic
+taxonomically
+taxonomy
+taxpayer
+taxpayer's
+taxpayers
+tea
+teach
+teachable
+teachableness
+teacher
+teacher's
+teachers
+teaches
+teaching
+teachings
+team
+team's
+teamed
+teaming
+teams
+tear
+tear's
+teared
+tearer
+tearful
+tearfully
+tearfulness
+tearing
+tears
+teas
+tease
+teased
+teaser
+teases
+teasing
+teasingly
+teaspoon
+teaspoon's
+teaspoonful
+teaspoonful's
+teaspoonfuls
+teaspoons
+technical
+technicalities
+technicality
+technicality's
+technically
+technicalness
+technician
+technician's
+technicians
+technique
+technique's
+techniques
+technological
+technologically
+technologies
+technologist
+technologist's
+technologists
+technology
+technology's
+tedious
+tediously
+tediousness
+tedium
+teem
+teemed
+teeming
+teemingly
+teemingness
+teems
+teen
+teenage
+teenaged
+teenager
+teenagers
+teener
+teens
+teeth
+teethe
+teethed
+teether
+teethes
+teething
+telecommunication
+telecommunications
+teleconference
+teleconference's
+teleconferenced
+teleconferences
+teleconferencing
+telegram
+telegram's
+telegrams
+telegraph
+telegraphed
+telegrapher
+telegraphers
+telegraphic
+telegraphing
+telegraphs
+teleological
+teleologically
+teleology
+telephone
+telephoned
+telephoner
+telephoners
+telephones
+telephonic
+telephoning
+telephony
+telescope
+telescoped
+telescopes
+telescoping
+teletype
+teletype's
+teletypes
+televise
+televised
+televises
+televising
+television
+televisions
+televisor
+televisor's
+televisors
+tell
+teller
+tellers
+telling
+tellingly
+tellings
+tells
+temper
+temperament
+temperamental
+temperamentally
+temperaments
+temperance
+temperate
+temperately
+temperateness
+temperature
+temperature's
+temperatures
+tempered
+temperer
+tempering
+tempers
+tempest
+tempests
+tempestuous
+tempestuously
+tempestuousness
+template
+template's
+templates
+temple
+temple's
+templed
+temples
+temporal
+temporally
+temporaries
+temporarily
+temporariness
+temporary
+tempt
+temptation
+temptation's
+temptations
+tempted
+tempter
+tempters
+tempting
+temptingly
+tempts
+ten
+ten's
+tenacious
+tenaciously
+tenaciousness
+tenant
+tenant's
+tenants
+tend
+tended
+tendencies
+tendency
+tender
+tendered
+tendering
+tenderly
+tenderness
+tenders
+tending
+tends
+tenement
+tenement's
+tenements
+tennis
+tenor
+tenor's
+tenors
+tens
+tense
+tensed
+tensely
+tenseness
+tenser
+tenses
+tensest
+tensing
+tension
+tensioned
+tensioner
+tensioning
+tensions
+tensive
+tensor
+tensor's
+tensors
+tent
+tentacle
+tentacled
+tentacles
+tentative
+tentatively
+tentativeness
+tented
+tenter
+tenth
+tenthes
+tenting
+tents
+tenure
+tenured
+tenures
+tequila
+tequila's
+term
+termcap
+termed
+termer
+terminal
+terminal's
+terminally
+terminals
+terminate
+terminated
+terminates
+terminating
+termination
+terminations
+terminative
+terminatively
+terminator
+terminator's
+terminators
+terming
+terminologies
+terminology
+terminus
+termly
+terms
+ternary
+terrace
+terraced
+terraces
+terracing
+terrain
+terrain's
+terrains
+terrestrial
+terrestrial's
+terrestrially
+terrestrials
+terrible
+terribleness
+terribly
+terrier
+terrier's
+terriers
+terrific
+terrificly
+terrified
+terrifies
+terrify
+terrifying
+terrifyingly
+territorial
+territorially
+territories
+territory
+territory's
+terror
+terror's
+terrorism
+terrorist
+terrorist's
+terroristic
+terrorists
+terrors
+tertiaries
+tertiary
+test
+test's
+testability
+testable
+testament
+testament's
+testaments
+tested
+tester
+tester's
+testers
+testicle
+testicle's
+testicles
+testified
+testifier
+testifiers
+testifies
+testify
+testifying
+testimonies
+testimony
+testimony's
+testing
+testings
+tests
+text
+text's
+textbook
+textbook's
+textbooks
+textile
+textile's
+textiles
+texts
+textual
+textually
+texture
+textured
+textures
+texturing
+than
+thank
+thanked
+thanker
+thankful
+thankfully
+thankfulness
+thanking
+thankless
+thanklessly
+thanklessness
+thanks
+thanksgiving
+thanksgiving's
+thanksgivings
+that
+that's
+thatch
+thatched
+thatcher
+thatches
+thatching
+thats
+thaw
+thawed
+thawing
+thaws
+the
+theatrical
+theatrically
+theatricals
+theft
+theft's
+thefts
+their
+their's
+theirs
+them
+thematic
+theme
+theme's
+themes
+themselves
+then
+thence
+thenceforth
+theologian
+theologian's
+theologians
+theological
+theologically
+theologies
+theology
+theorem
+theorem's
+theorems
+theoretic
+theoretical
+theoretically
+theoreticians
+theoretics
+theories
+theorist
+theorist's
+theorists
+theory
+theory's
+therapeutic
+therapeutics
+therapies
+therapist
+therapist's
+therapists
+therapy
+therapy's
+there
+there's
+thereabouts
+thereafter
+thereby
+therefore
+therein
+thereof
+thereon
+thereto
+thereupon
+therewith
+thermodynamic
+thermodynamics
+thermometer
+thermometer's
+thermometers
+thermostat
+thermostat's
+thermostated
+thermostats
+these
+theses
+thesis
+they
+they'd
+they'll
+they're
+they've
+thick
+thicken
+thickened
+thickener
+thickeners
+thickening
+thickens
+thicker
+thickest
+thicket
+thicket's
+thicketed
+thickets
+thickly
+thickness
+thicknesses
+thicks
+thief
+thieve
+thieves
+thieving
+thigh
+thighed
+thighs
+thimble
+thimble's
+thimbles
+thin
+thiner
+thinest
+thing
+thingamajig
+thingamajig's
+thingamajigs
+thingness
+things
+think
+thinkable
+thinkableness
+thinkably
+thinker
+thinkers
+thinking
+thinkingly
+thinkingness
+thinks
+thinly
+thinner
+thinners
+thinness
+thinnest
+thins
+third
+thirdly
+thirds
+thirst
+thirsted
+thirster
+thirstier
+thirstiness
+thirsts
+thirsty
+thirteen
+thirteens
+thirteenth
+thirties
+thirtieth
+thirty
+this
+thistle
+thong
+thonged
+thorn
+thorn's
+thornier
+thorniness
+thorns
+thorny
+thorough
+thoroughfare
+thoroughfare's
+thoroughfares
+thoroughly
+thoroughness
+those
+though
+thought
+thought's
+thoughtful
+thoughtfully
+thoughtfulness
+thoughtless
+thoughtlessly
+thoughtlessness
+thoughts
+thousand
+thousands
+thousandth
+thrash
+thrashed
+thrasher
+thrashes
+thrashing
+thread
+threaded
+threader
+threaders
+threading
+threads
+threat
+threaten
+threatened
+threatener
+threatening
+threateningly
+threatens
+threats
+three
+three's
+threes
+threescore
+threshold
+threshold's
+thresholded
+thresholding
+thresholds
+threw
+thrice
+thrift
+thriftier
+thriftiness
+thrifty
+thrill
+thrilled
+thriller
+thrillers
+thrilling
+thrillingly
+thrills
+thrive
+thrived
+thriver
+thrives
+thriving
+thrivingly
+throat
+throated
+throating
+throats
+throb
+throbbed
+throbbing
+throbs
+throne
+throne's
+thrones
+throng
+throng's
+thronging
+throngs
+throning
+throttle
+throttled
+throttler
+throttles
+throttling
+through
+throughly
+throughout
+throughput
+throw
+thrower
+throwing
+thrown
+throws
+thrush
+thrushes
+thrust
+thruster
+thrusters
+thrusting
+thrusts
+thud
+thuds
+thug
+thug's
+thugs
+thumb
+thumbed
+thumbing
+thumbs
+thump
+thumped
+thumper
+thumping
+thumps
+thunder
+thunderbolt
+thunderbolt's
+thunderbolts
+thundered
+thunderer
+thunderers
+thundering
+thunderingly
+thunders
+thunderstorm
+thunderstorm's
+thunderstorms
+thunderstruck
+thus
+thusly
+thwart
+thwarted
+thwarter
+thwarting
+thwartly
+thwarts
+thyself
+tick
+ticked
+ticker
+tickers
+ticket
+ticket's
+ticketed
+ticketing
+tickets
+ticking
+tickle
+tickled
+tickler
+tickles
+tickling
+ticklish
+ticklishly
+ticklishness
+ticks
+tidal
+tidally
+tide
+tided
+tides
+tidied
+tidier
+tidies
+tidiness
+tiding
+tidings
+tidy
+tidying
+tie
+tied
+tier
+tiered
+tiers
+ties
+tiger
+tiger's
+tigers
+tight
+tighten
+tightened
+tightener
+tighteners
+tightening
+tightenings
+tightens
+tighter
+tightest
+tightly
+tightness
+tights
+tilde
+tildes
+tile
+tiled
+tiler
+tiles
+tiling
+till
+tillable
+tilled
+tiller
+tillered
+tillering
+tillers
+tilling
+tills
+tilt
+tilted
+tilter
+tilters
+tilting
+tilts
+timber
+timbered
+timbering
+timbers
+time
+timed
+timeless
+timelessly
+timelessness
+timelier
+timeliness
+timely
+timeout
+timeouts
+timer
+timers
+times
+timeshare
+timeshared
+timeshares
+timesharing
+timetable
+timetable's
+timetabled
+timetables
+timetabling
+timid
+timidity
+timidly
+timidness
+timing
+timings
+tin
+tin's
+tinge
+tinged
+tinging
+tingle
+tingled
+tingles
+tingling
+tinglingly
+tinier
+tiniest
+tinily
+tininess
+tinker
+tinkered
+tinkerer
+tinkering
+tinkers
+tinkle
+tinkled
+tinkles
+tinkling
+tinned
+tinnier
+tinniest
+tinnily
+tinniness
+tinning
+tinny
+tins
+tint
+tinted
+tinter
+tinting
+tints
+tiny
+tip
+tip's
+tipped
+tipper
+tipper's
+tippers
+tipping
+tips
+tiptoe
+tiptoed
+tire
+tired
+tiredly
+tiredness
+tireless
+tirelessly
+tirelessness
+tires
+tiresome
+tiresomely
+tiresomeness
+tiring
+tissue
+tissue's
+tissued
+tissues
+tissuing
+tit
+tit's
+tithe
+tithe's
+tither
+tithes
+tithing
+title
+titled
+titles
+titling
+tits
+titter
+tittered
+tittering
+titters
+tizzies
+tizzy
+to
+toad
+toad's
+toads
+toast
+toasted
+toaster
+toasters
+toastier
+toasting
+toasts
+toasty
+tobacco
+today
+today's
+todays
+toe
+toe's
+toed
+toes
+together
+togetherness
+toggle
+toggled
+toggles
+toggling
+toil
+toiled
+toiler
+toilet
+toilet's
+toilets
+toiling
+toils
+token
+token's
+tokens
+told
+tolerability
+tolerable
+tolerably
+tolerance
+tolerances
+tolerant
+tolerantly
+tolerate
+tolerated
+tolerates
+tolerating
+toleration
+tolerative
+toll
+tolled
+tolling
+tolls
+tom
+tom's
+tomahawk
+tomahawk's
+tomahawks
+tomato
+tomatoes
+tomb
+tomb's
+tombs
+tomography
+tomorrow
+tomorrow's
+tomorrows
+toms
+ton
+ton's
+tone
+toned
+toner
+tones
+tongs
+tongue
+tongued
+tongues
+tonguing
+tonic
+tonic's
+tonics
+tonight
+toning
+tonnage
+tons
+tonsil
+too
+took
+tool
+tooled
+tooler
+toolers
+tooling
+toolkit
+toolkit's
+toolkits
+tools
+tooth
+toothbrush
+toothbrush's
+toothbrushes
+toothbrushing
+toothed
+toothing
+toothpick
+toothpick's
+toothpicks
+top
+toped
+toper
+topic
+topic's
+topical
+topically
+topics
+toping
+topmost
+topological
+topologically
+topologies
+topology
+topple
+toppled
+topples
+toppling
+tops
+torch
+torch's
+torches
+tore
+torment
+tormented
+tormenter
+tormenters
+tormenting
+torments
+torn
+tornado
+tornadoes
+tornados
+torpedo
+torpedoed
+torpedoes
+torpedoing
+torpedos
+torque
+torquer
+torquers
+torques
+torquing
+torrent
+torrent's
+torrents
+torrid
+torridly
+torridness
+tortoise
+tortoise's
+tortoises
+torture
+tortured
+torturer
+torturers
+tortures
+torturing
+torus
+torus's
+toruses
+toss
+tossed
+tosser
+tosses
+tossing
+total
+total's
+totalities
+totality
+totality's
+totally
+totals
+totter
+tottered
+tottering
+totteringly
+totters
+touch
+touchable
+touched
+toucher
+touches
+touchier
+touchiest
+touchily
+touchiness
+touching
+touchingly
+touchy
+tough
+toughen
+toughened
+toughening
+toughens
+tougher
+toughest
+toughly
+toughness
+tour
+toured
+tourer
+touring
+tourist
+tourist's
+tourists
+tournament
+tournament's
+tournaments
+tours
+tow
+toward
+towardliness
+towardly
+towards
+towed
+towel
+towel's
+towels
+tower
+towered
+towering
+toweringly
+towers
+towing
+town
+town's
+towner
+towns
+township
+township's
+townships
+tows
+toxicity
+toxin
+toxin's
+toxins
+toy
+toyed
+toyer
+toying
+toys
+trace
+traceable
+traceableness
+traced
+traceless
+tracelessly
+tracer
+tracers
+traces
+tracing
+tracings
+track
+tracked
+tracker
+trackers
+tracking
+tracks
+tract
+tract's
+tractability
+tractable
+tractive
+tractor
+tractor's
+tractors
+tracts
+trade
+traded
+trademark
+trademark's
+trademarks
+tradeoff
+tradeoffs
+trader
+traders
+trades
+tradesman
+trading
+tradition
+tradition's
+traditional
+traditionally
+traditions
+traffic
+traffic's
+trafficked
+trafficker
+trafficker's
+traffickers
+trafficking
+traffics
+tragedies
+tragedy
+tragedy's
+tragic
+tragically
+trail
+trailed
+trailer
+trailers
+trailing
+trailings
+trails
+train
+trained
+trainee
+trainee's
+trainees
+trainer
+trainers
+training
+trains
+trait
+trait's
+traitor
+traitor's
+traitors
+traits
+trajectories
+trajectory
+trajectory's
+tramp
+tramped
+tramper
+tramping
+trample
+trampled
+trampler
+tramples
+trampling
+tramps
+trance
+trance's
+trances
+trancing
+tranquil
+tranquility
+tranquillity
+tranquilly
+tranquilness
+transact
+transacted
+transacting
+transaction
+transaction's
+transactions
+transacts
+transceiver
+transceiver's
+transceivers
+transcend
+transcended
+transcendent
+transcendently
+transcending
+transcends
+transcontinental
+transcribe
+transcribed
+transcriber
+transcribers
+transcribes
+transcribing
+transcript
+transcript's
+transcription
+transcription's
+transcriptions
+transcripts
+transfer
+transfer's
+transferability
+transferable
+transferal
+transferal's
+transferals
+transfered
+transference
+transferral
+transferral's
+transferrals
+transferred
+transferrer
+transferrer's
+transferrers
+transferring
+transfers
+transfinite
+transform
+transformable
+transformation
+transformation's
+transformational
+transformations
+transformed
+transformer
+transformers
+transforming
+transforms
+transgress
+transgressed
+transgresses
+transgressing
+transgression
+transgression's
+transgressions
+transgressive
+transience
+transiency
+transient
+transiently
+transients
+transistor
+transistor's
+transistors
+transit
+transition
+transitional
+transitionally
+transitioned
+transitions
+transitive
+transitively
+transitiveness
+transitivity
+transitoriness
+transitory
+translatability
+translatable
+translate
+translated
+translates
+translating
+translation
+translational
+translations
+translative
+translator
+translator's
+translators
+translucent
+translucently
+transmission
+transmission's
+transmissions
+transmit
+transmits
+transmittal
+transmitted
+transmitter
+transmitter's
+transmitters
+transmitting
+transmogrification
+transmogrify
+transparencies
+transparency
+transparency's
+transparent
+transparently
+transparentness
+transpire
+transpired
+transpires
+transpiring
+transplant
+transplanted
+transplanter
+transplanting
+transplants
+transport
+transportability
+transportation
+transportations
+transported
+transporter
+transporters
+transporting
+transports
+transpose
+transposed
+transposes
+transposing
+transposition
+trap
+trap's
+trapezoid
+trapezoid's
+trapezoidal
+trapezoids
+trapped
+trapper
+trapper's
+trappers
+trapping
+trappings
+traps
+trash
+trashed
+trasher
+trashes
+trashing
+traumatic
+travail
+travails
+travel
+travels
+traversal
+traversal's
+traversals
+traverse
+traversed
+traverser
+traverses
+traversing
+travesties
+travesty
+travesty's
+tray
+tray's
+trays
+treacheries
+treacherous
+treacherously
+treacherousness
+treachery
+treachery's
+tread
+treaded
+treader
+treading
+treads
+treason
+treasure
+treasured
+treasurer
+treasures
+treasuries
+treasuring
+treasury
+treasury's
+treat
+treated
+treater
+treaters
+treaties
+treating
+treatise
+treatise's
+treatises
+treatment
+treatment's
+treatments
+treats
+treaty
+treaty's
+treble
+trebled
+trebles
+trebling
+tree
+tree's
+treed
+trees
+treetop
+treetop's
+treetops
+trek
+trek's
+treks
+tremble
+trembled
+trembler
+trembles
+trembling
+tremendous
+tremendously
+tremendousness
+tremor
+tremor's
+tremors
+trench
+trenched
+trencher
+trenchers
+trenches
+trend
+trending
+trends
+trespass
+trespassed
+trespasser
+trespassers
+trespasses
+tress
+tress's
+tressed
+tresses
+trial
+trial's
+trials
+triangle
+triangle's
+triangles
+triangular
+triangularly
+tribal
+tribally
+tribe
+tribe's
+tribes
+tribunal
+tribunal's
+tribunals
+tribune
+tribune's
+tribunes
+tributary
+tribute
+tribute's
+tributes
+tributing
+trichotomy
+trick
+tricked
+tricker
+trickier
+trickiest
+trickiness
+tricking
+trickle
+trickled
+trickles
+trickling
+tricks
+tricky
+tried
+trier
+triers
+tries
+trifle
+trifled
+trifler
+trifles
+trifling
+trigger
+triggered
+triggering
+triggers
+trigonometric
+trigonometry
+trihedral
+trill
+trilled
+triller
+trillion
+trillions
+trillionth
+trim
+trimer
+trimly
+trimmed
+trimmer
+trimmest
+trimming
+trimmings
+trimness
+trims
+trinket
+trinket's
+trinketed
+trinketer
+trinkets
+trip
+trip's
+triple
+tripled
+triples
+triplet
+triplet's
+triplets
+triplication
+tripling
+triply
+trips
+triumph
+triumphal
+triumphantly
+triumphed
+triumphing
+triumphs
+trivia
+trivial
+trivialities
+triviality
+trivially
+trod
+troff
+troff's
+troffer
+troll
+troll's
+trolley
+trolley's
+trolleyed
+trolleys
+trolls
+troop
+trooped
+trooper
+troopers
+trooping
+troops
+trophied
+trophies
+trophy
+trophy's
+trophying
+tropic
+tropic's
+tropical
+tropically
+tropics
+trot
+trots
+trouble
+troubled
+troublemaker
+troublemaker's
+troublemakers
+troubler
+troubles
+troubleshoot
+troubleshooted
+troubleshooter
+troubleshooters
+troubleshooting
+troubleshoots
+troublesome
+troublesomely
+troublesomeness
+troubling
+trough
+trouser
+trousered
+trousers
+trout
+trouts
+trowel
+trowel's
+trowels
+truant
+truant's
+truants
+truce
+trucing
+truck
+trucked
+trucker
+truckers
+trucking
+trucks
+trudge
+trudged
+trudger
+trudges
+trudging
+true
+trued
+trueness
+truer
+trues
+truest
+truing
+truism
+truism's
+truisms
+truly
+trump
+trumped
+trumpet
+trumpeted
+trumpeter
+trumpeting
+trumpets
+trumps
+truncate
+truncated
+truncates
+truncating
+truncation
+truncation's
+truncations
+trunk
+trunk's
+trunked
+trunks
+trust
+trusted
+trustee
+trustee's
+trusteed
+trustees
+truster
+trustful
+trustfully
+trustfulness
+trustier
+trusties
+trustiness
+trusting
+trustingly
+trusts
+trustworthiness
+trustworthy
+trusty
+truth
+truthful
+truthfully
+truthfulness
+truths
+try
+trying
+tryingly
+tty
+tty's
+ttys
+tub
+tub's
+tube
+tubed
+tuber
+tuberculosis
+tubers
+tubes
+tubing
+tubs
+tuck
+tucked
+tucker
+tuckered
+tuckering
+tucking
+tucks
+tuft
+tuft's
+tufted
+tufter
+tufts
+tug
+tugs
+tuition
+tuitions
+tulip
+tulip's
+tulips
+tumble
+tumbled
+tumbler
+tumblers
+tumbles
+tumbling
+tumult
+tumult's
+tumults
+tumultuous
+tumultuously
+tumultuousness
+tunable
+tunableness
+tune
+tuned
+tuner
+tuners
+tunes
+tunic
+tunic's
+tunics
+tuning
+tuning's
+tunings
+tunnel
+tunnels
+tuple
+tuple's
+tuples
+turban
+turban's
+turbaned
+turbans
+turbulence
+turbulence's
+turbulent
+turbulently
+turf
+turkey
+turkey's
+turkeys
+turmoil
+turmoil's
+turmoils
+turn
+turnable
+turned
+turner
+turners
+turning
+turnings
+turnip
+turnip's
+turnips
+turnkey
+turnkeys
+turnover
+turnovers
+turns
+turpentine
+turquoise
+turret
+turret's
+turreted
+turrets
+turtle
+turtle's
+turtles
+turtling
+tutor
+tutored
+tutorial
+tutorial's
+tutorials
+tutoring
+tutors
+twain
+twang
+twanging
+twas
+tweak
+tweaked
+tweaker
+tweaking
+tweaks
+tweed
+tweezer
+tweezers
+twelfth
+twelve
+twelves
+twenties
+twentieth
+twenty
+twice
+twig
+twig's
+twigs
+twilight
+twilight's
+twilights
+twill
+twilled
+twilling
+twin
+twin's
+twine
+twined
+twiner
+twines
+twining
+twinkle
+twinkled
+twinkler
+twinkles
+twinkling
+twins
+twirl
+twirled
+twirler
+twirling
+twirlingly
+twirls
+twist
+twisted
+twister
+twisters
+twisting
+twists
+twitch
+twitched
+twitcher
+twitching
+twitter
+twittered
+twitterer
+twittering
+two
+two's
+twofold
+twos
+tying
+type
+type's
+typed
+typedef
+typedefs
+typer
+types
+typewriter
+typewriter's
+typewriters
+typhoid
+typical
+typically
+typicalness
+typification
+typified
+typifies
+typify
+typifying
+typing
+typist
+typist's
+typists
+typographic
+typographical
+typographically
+typography
+typos
+tyranny
+tyrant
+tyrant's
+tyrants
+ubiquitous
+ubiquitously
+ubiquitousness
+ubiquity
+ugh
+uglier
+ugliest
+ugliness
+ugly
+ulcer
+ulcer's
+ulcered
+ulcering
+ulcers
+ultimate
+ultimately
+ultimateness
+umbrella
+umbrella's
+umbrellas
+umpire
+umpire's
+umpired
+umpires
+umpiring
+unabashed
+unabashedly
+unabated
+unabatedly
+unabbreviated
+unable
+unabridged
+unaccelerated
+unacceptability
+unacceptable
+unacceptably
+unaccessible
+unaccommodated
+unaccompanied
+unaccomplished
+unaccountably
+unaccounted
+unaccustomed
+unaccustomedly
+unachievable
+unachieved
+unacknowledged
+unacquainted
+unadaptable
+unadjustable
+unadjusted
+unadopted
+unadorned
+unadulterated
+unadulteratedly
+unadvised
+unadvisedly
+unaffected
+unaffectedly
+unaffectedness
+unaffectionate
+unaffectionately
+unafraid
+unaggregated
+unaided
+unalienability
+unalienable
+unaligned
+unallocated
+unalloyed
+unalterable
+unalterableness
+unalterably
+unaltered
+unambiguous
+unambiguously
+unambitious
+unanchored
+unanimous
+unanimously
+unannounced
+unanswerable
+unanswered
+unanticipated
+unanticipatedly
+unapologetically
+unappealing
+unappealingly
+unappreciated
+unapproachability
+unapproachable
+unappropriated
+unapt
+unaptly
+unaptness
+unarguable
+unarguably
+unarmed
+unarticulated
+unary
+unashamed
+unashamedly
+unasked
+unassailable
+unassailableness
+unassembled
+unassigned
+unassigns
+unassisted
+unassuming
+unassumingness
+unattached
+unattainability
+unattainable
+unattended
+unattenuated
+unattractive
+unattractively
+unattractiveness
+unattributed
+unauthentic
+unauthenticated
+unavailability
+unavailable
+unavailing
+unavailingly
+unavailingness
+unavoidable
+unavoidably
+unaware
+unawarely
+unawareness
+unawares
+unbacked
+unbalanced
+unbalancedness
+unbanned
+unbanning
+unbans
+unbarbered
+unbarred
+unbated
+unbearable
+unbearably
+unbeatable
+unbeatably
+unbeaten
+unbeautifully
+unbecoming
+unbecomingly
+unbecomingness
+unbelievable
+unbelievably
+unbelieving
+unbelievingly
+unbelted
+unbendable
+unbetrothed
+unbiased
+unbiasedness
+unbidden
+unblemished
+unblinded
+unblinking
+unblinkingly
+unblock
+unblocked
+unblocking
+unblocks
+unblown
+unblushing
+unblushingly
+unbodied
+unbolted
+unboned
+unbonneted
+unborn
+unbound
+unbounded
+unboundedness
+unbowed
+unbranched
+unbreakable
+unbreathable
+unbred
+unbridled
+unbroken
+unbudging
+unbudgingly
+unbuffered
+unbuilt
+unbundled
+unburdened
+unbureaucratic
+unburied
+unburned
+unbuttered
+unbuttoned
+unbuttons
+uncaged
+uncalculating
+uncalled
+uncandidly
+uncanniness
+uncanny
+uncared
+uncaring
+uncatchable
+uncaught
+uncaused
+unceasing
+unceasingly
+uncensored
+uncertain
+uncertainly
+uncertainness
+uncertainties
+uncertainty
+uncertified
+unchallenged
+unchangeability
+unchangeable
+unchangeably
+unchanged
+unchanging
+unchangingly
+unchangingness
+uncharacteristically
+uncharged
+uncharitable
+uncharitableness
+uncharted
+unchartered
+uncheckable
+unchecked
+unchivalrously
+unchosen
+uncivil
+uncivilly
+unclaimed
+unclamorous
+unclamorously
+unclamorousness
+unclarity
+unclassified
+uncle
+uncle's
+unclean
+uncleanliness
+uncleanly
+uncleanness
+unclear
+uncleared
+unclenched
+uncles
+unclipped
+unclosed
+unclothed
+unclouded
+uncloudedly
+unclustered
+uncluttered
+uncoated
+uncoded
+uncoiled
+uncoined
+uncomfortable
+uncomfortably
+uncomforted
+uncommented
+uncommitted
+uncommon
+uncommonly
+uncommonness
+uncomplaining
+uncomplainingly
+uncompleted
+uncomplimentary
+uncomprehending
+uncomprehendingly
+uncompress
+uncompressed
+uncompresses
+uncompressing
+uncompromising
+uncompromisingly
+uncomputable
+unconceivable
+unconcerned
+unconcernedly
+unconcernedness
+unconditional
+unconditionally
+unconditioned
+unconfined
+unconfirmed
+unconformity
+unconnected
+unconquerable
+unconscious
+unconsciously
+unconsciousness
+unconsidered
+unconsolidated
+unconstitutional
+unconstitutionality
+unconstitutionally
+unconstrained
+uncontaminated
+uncontested
+uncontrollability
+uncontrollable
+uncontrollably
+uncontrolled
+unconventional
+unconventionally
+unconvertible
+unconvinced
+unconvincing
+unconvincingly
+unconvincingness
+uncool
+uncooled
+uncooperative
+uncoordinated
+uncorked
+uncorrectable
+uncorrected
+uncorrelated
+uncountable
+uncountably
+uncounted
+uncouth
+uncouthly
+uncouthness
+uncovenanted
+uncover
+uncovered
+uncovering
+uncovers
+uncreated
+uncritically
+uncrowned
+uncrushable
+uncured
+uncurled
+uncynical
+uncynically
+undamaged
+undamped
+undaunted
+undauntedly
+undebatable
+undecidable
+undecided
+undeclared
+undecomposable
+undecorated
+undefended
+undefinability
+undefinable
+undefined
+undefinedness
+undeformed
+undelete
+undeleted
+undemocratic
+undemocratically
+undemonstrative
+undemonstratively
+undemonstrativeness
+undeniable
+undeniableness
+undeniably
+undepicted
+under
+underbrush
+underdone
+underestimate
+underestimated
+underestimates
+underestimating
+underestimation
+underestimations
+underflow
+underflowed
+underflowing
+underflows
+underfoot
+undergo
+undergoes
+undergoing
+undergone
+undergrad
+undergrad's
+undergrads
+undergraduate
+undergraduate's
+undergraduates
+underground
+undergrounder
+underivable
+underived
+underlie
+underlies
+underline
+underlined
+underlines
+underling
+underling's
+underlings
+underlining
+underlinings
+underly
+underlying
+undermine
+undermined
+undermines
+undermining
+underneath
+underpayment
+underpayment's
+underpayments
+underpinning
+underpinnings
+underplay
+underplayed
+underplaying
+underplays
+underscore
+underscored
+underscores
+understand
+understandability
+understandable
+understandably
+understanding
+understandingly
+understandings
+understands
+understated
+understood
+undertake
+undertaken
+undertaker
+undertaker's
+undertakers
+undertakes
+undertaking
+undertakings
+undertook
+underway
+underwear
+underwent
+underworld
+underwrite
+underwriter
+underwriters
+underwrites
+underwriting
+undescended
+undesigned
+undesigning
+undesirability
+undesirable
+undesirableness
+undesirably
+undesired
+undetectable
+undetected
+undetermined
+undeveloped
+undeviated
+undeviating
+undeviatingly
+undid
+undies
+undifferentiated
+undigested
+undignified
+undiluted
+undiminished
+undimmed
+undiplomatic
+undirected
+undisciplined
+undisclosed
+undiscovered
+undiscussed
+undisguised
+undisguisedly
+undismayed
+undisputed
+undisrupted
+undissociated
+undistinguished
+undistorted
+undistributed
+undisturbed
+undivided
+undo
+undocumented
+undoer
+undoes
+undoing
+undoings
+undomesticated
+undone
+undoubled
+undoubted
+undoubtedly
+undrained
+undramatically
+undreamed
+undress
+undressed
+undresses
+undressing
+undried
+undrinkable
+undue
+unduly
+undumper
+undumper's
+undutiful
+undutifully
+undutifulness
+undying
+unearned
+unearthliness
+unearthly
+uneasily
+uneasiness
+uneasy
+uneconomical
+unedited
+unelected
+unembellished
+unemotional
+unemotionally
+unemphatic
+unemphatically
+unemployable
+unemployed
+unemployment
+unencumbered
+unending
+unendingly
+unendurable
+unendurableness
+unendurably
+unenlightening
+unenthusiastic
+unenthusiastically
+unenumerated
+unenvied
+unequal
+unequally
+unequivocal
+unequivocally
+unerring
+unerringly
+unessential
+unethically
+unevaluated
+uneven
+unevenly
+unevenness
+uneventful
+uneventfully
+unexamined
+unexampled
+unexceptionally
+unexcused
+unexpanded
+unexpected
+unexpectedly
+unexpectedness
+unexpended
+unexperienced
+unexplainable
+unexplained
+unexploited
+unexplored
+unexpressed
+unextended
+unfading
+unfadingly
+unfair
+unfairly
+unfairness
+unfaith
+unfaithful
+unfaithfully
+unfaithfulness
+unfaltering
+unfalteringly
+unfamiliar
+unfamiliarity
+unfamiliarly
+unfashionable
+unfashionably
+unfastened
+unfathered
+unfeathered
+unfeigned
+unfeignedly
+unfenced
+unfettered
+unfilial
+unfilially
+unfilled
+unfinished
+unfired
+unfit
+unfitly
+unfitness
+unfitted
+unfixed
+unflagging
+unflaggingly
+unflattering
+unflatteringly
+unfledged
+unflinching
+unflinchingly
+unfocused
+unfold
+unfolded
+unfolding
+unfolds
+unforeseen
+unforgeable
+unforgettable
+unforgettably
+unforgivable
+unforgiving
+unforgivingness
+unformatted
+unformed
+unforthcoming
+unfortunate
+unfortunately
+unfortunates
+unfounded
+unfrequented
+unfriendliness
+unfriendly
+unfrosted
+unfruitful
+unfruitfully
+unfruitfulness
+unfulfilled
+unfunded
+unfunnily
+unfurnished
+ungainliness
+ungainly
+ungallantly
+ungenerously
+ungirt
+unglazed
+unglued
+ungot
+ungotten
+ungoverned
+ungraceful
+ungracefully
+ungracefulness
+ungraciously
+ungraded
+ungrammatical
+ungrateful
+ungratefully
+ungratefulness
+ungratified
+ungrounded
+unguarded
+unguardedly
+unguardedness
+unguessable
+unguessed
+unguided
+unhallow
+unhallowed
+unhampered
+unhandily
+unhandsomely
+unhappier
+unhappiest
+unhappily
+unhappiness
+unhappy
+unharmed
+unhealthily
+unhealthiness
+unhealthy
+unheard
+unheeded
+unheeding
+unhelm
+unhelpfully
+unheralded
+unhesitating
+unhesitatingly
+unhinged
+unhitched
+unhooks
+unhoped
+unhurriedly
+unhysterical
+unhysterically
+unicorn
+unicorn's
+unicorns
+unidentifiable
+unidentified
+unidirectional
+unidirectionality
+unidirectionally
+unification
+unifications
+unified
+unifier
+unifiers
+unifies
+uniform
+uniformed
+uniforming
+uniformities
+uniformity
+uniformly
+uniformness
+uniforms
+unify
+unifying
+unilluminating
+unimaginable
+unimaginably
+unimaginatively
+unimpaired
+unimpassioned
+unimpeded
+unimplemented
+unimportance
+unimportant
+unimpressed
+unimproved
+unincorporated
+unindented
+uninfected
+uninfluenced
+uninformatively
+uninformed
+uninhabited
+uninhibited
+uninhibitedly
+uninhibitedness
+uninitiated
+uninjured
+uninspired
+uninspiring
+uninstantiated
+uninsulated
+unintelligent
+unintelligently
+unintelligibility
+unintelligible
+unintelligibleness
+unintelligibly
+unintended
+unintentional
+unintentionally
+uninteresting
+uninterestingly
+uninterpretable
+uninterpreted
+uninterrupted
+uninterruptedly
+uninterruptedness
+uninterviewed
+uninvited
+union
+union's
+unions
+unique
+uniquely
+uniqueness
+unison
+unit
+unit's
+unite
+united
+unitedly
+uniter
+unites
+unities
+uniting
+unitive
+units
+unity
+unity's
+univalve
+univalve's
+univalves
+universal
+universality
+universally
+universalness
+universals
+universe
+universe's
+universes
+universities
+university
+university's
+unjacketed
+unjam
+unjammed
+unjamming
+unjoined
+unjust
+unjustifiable
+unjustified
+unjustly
+unjustness
+unkind
+unkindliness
+unkindly
+unkindness
+unknit
+unknowable
+unknowing
+unknowingly
+unknown
+unknowns
+unlaced
+unlamented
+unlashed
+unlaundered
+unlawful
+unlawfully
+unlawfulness
+unleaded
+unleash
+unleashed
+unleashes
+unleashing
+unleavened
+unless
+unlettered
+unlicensed
+unlicked
+unlike
+unlikelihood
+unlikelihoods
+unlikeliness
+unlikely
+unlikeness
+unlimbers
+unlimited
+unlimitedly
+unlined
+unlink
+unlinked
+unlinking
+unlinks
+unlisted
+unload
+unloaded
+unloader
+unloaders
+unloading
+unloads
+unlock
+unlocked
+unlocking
+unlocks
+unlogged
+unloved
+unluckily
+unluckiness
+unlucky
+unmade
+unmagnified
+unmaintainable
+unmaintained
+unmaliciously
+unmanageable
+unmanageably
+unmanaged
+unmanned
+unmannered
+unmanneredly
+unmannerliness
+unmannerly
+unmapped
+unmaps
+unmarked
+unmarried
+unmarrieds
+unmasked
+unmatchable
+unmatched
+unmated
+unmates
+unmeant
+unmeasurable
+unmentionable
+unmentionables
+unmentioned
+unmerciful
+unmercifully
+unmeshed
+unmistakable
+unmistakably
+unmitigated
+unmitigatedly
+unmitigatedness
+unmixed
+unmoderated
+unmodifiable
+unmodified
+unmolested
+unmotivated
+unmount
+unmountable
+unmounted
+unmoved
+unmurmuring
+unnameable
+unnamed
+unnatural
+unnaturally
+unnaturalness
+unnecessarily
+unnecessary
+unneeded
+unnegated
+unnerve
+unnerved
+unnerves
+unnerving
+unnervingly
+unnoticed
+unnourished
+unnumbered
+unobservable
+unobservables
+unobserved
+unobtainable
+unoccupied
+unofficial
+unofficially
+unopened
+unordered
+unoriginals
+unorthodoxly
+unpack
+unpackaged
+unpackages
+unpacked
+unpacker
+unpacking
+unpacks
+unpadded
+unpaged
+unpaid
+unpainted
+unpaired
+unparliamentary
+unparsed
+unpartitioned
+unpatriotic
+unpaved
+unperceived
+unperformed
+unperturbed
+unperturbedly
+unplaced
+unplagued
+unplanned
+unpleasant
+unpleasantly
+unpleasantness
+unpleased
+unplowed
+unplugged
+unplugging
+unplugs
+unplumbed
+unpolled
+unpolluted
+unpopular
+unpopularity
+unprecedented
+unprecedentedly
+unpredictability
+unpredictable
+unpredictably
+unpredicted
+unprejudiced
+unprescribed
+unpreserved
+unpretending
+unpretentious
+unpretentiously
+unpretentiousness
+unpriced
+unprimed
+unprincipled
+unprincipledness
+unprintable
+unprinted
+unprivileged
+unproblematic
+unproblematical
+unproblematically
+unprocessed
+unprofitable
+unprofitableness
+unprofitably
+unprojected
+unpromising
+unpromisingly
+unprompted
+unpronounceable
+unpropagated
+unpropertied
+unprotected
+unprotectedly
+unprovability
+unprovable
+unproved
+unproven
+unprovided
+unpublished
+unpunched
+unpunished
+unqualified
+unqualifiedly
+unquantifiable
+unquenched
+unquestionably
+unquestioned
+unquestioningly
+unquoted
+unranked
+unrated
+unravel
+unravels
+unreachable
+unreacted
+unread
+unreadability
+unreadable
+unreal
+unrealism
+unrealistic
+unrealistically
+unrealized
+unrealizes
+unreasonable
+unreasonableness
+unreasonably
+unreassuringly
+unreconstructed
+unrecordable
+unrecorded
+unrecoverable
+unredeemed
+unreferenced
+unrefined
+unreflected
+unregister
+unregistered
+unregistering
+unregisters
+unregulated
+unrehearsed
+unreinforced
+unrelated
+unreleased
+unrelenting
+unrelentingly
+unreliabilities
+unreliability
+unreliable
+unreliably
+unremarked
+unreported
+unrepresentable
+unrepresented
+unrequested
+unrequited
+unreserved
+unreservedly
+unreservedness
+unresisted
+unresisting
+unresolved
+unresponsive
+unresponsively
+unresponsiveness
+unrest
+unrestrained
+unrestrainedly
+unrestrainedness
+unrestricted
+unrestrictedly
+unrestrictive
+unreturned
+unrevealing
+unrifled
+unrighteous
+unrighteously
+unrighteousness
+unroll
+unrolled
+unrolling
+unrolls
+unromantically
+unrotated
+unruffled
+unruled
+unruliness
+unruly
+unsafe
+unsafely
+unsaid
+unsalted
+unsanitary
+unsatisfactorily
+unsatisfactory
+unsatisfiability
+unsatisfiable
+unsatisfied
+unsatisfying
+unsaturated
+unsaved
+unscheduled
+unschooled
+unscientific
+unscientifically
+unscramble
+unscrambled
+unscrambler
+unscrambles
+unscrambling
+unscratched
+unscreened
+unscrews
+unscripted
+unscrupulous
+unscrupulously
+unscrupulousness
+unsealed
+unseals
+unseasonable
+unseasonableness
+unseasonably
+unseasoned
+unsecured
+unseeded
+unseeing
+unseemly
+unseen
+unsegmented
+unsegregated
+unselected
+unselfish
+unselfishly
+unselfishness
+unsent
+unserved
+unserviced
+unsettled
+unsettledness
+unsettling
+unsettlingly
+unshaded
+unshakable
+unshaken
+unshared
+unsharpened
+unshaved
+unshaven
+unsheathing
+unshelled
+unsheltered
+unshielded
+unshod
+unsigned
+unsimplified
+unsized
+unskilled
+unskillful
+unskillfully
+unskillfulness
+unslings
+unsloped
+unslung
+unsmiling
+unsmilingly
+unsnap
+unsnapped
+unsnapping
+unsnaps
+unsociability
+unsociable
+unsociableness
+unsociably
+unsocial
+unsocially
+unsolicited
+unsolvable
+unsolved
+unsophisticated
+unsophistication
+unsorted
+unsought
+unsound
+unsounded
+unsoundly
+unsoundness
+unsparing
+unsparingly
+unspeakable
+unspecified
+unspent
+unspoiled
+unspoken
+unspotted
+unsprayed
+unsprung
+unstable
+unstableness
+unstably
+unstacked
+unstacks
+unstained
+unstapled
+unstaring
+unstated
+unsteadily
+unsteadiness
+unsteady
+unstemmed
+unstinting
+unstintingly
+unstoppable
+unstopped
+unstrained
+unstratified
+unstreamed
+unstressed
+unstriped
+unstructured
+unstrung
+unstuck
+unsubscripted
+unsubstantially
+unsubstantiated
+unsubstituted
+unsuccessful
+unsuccessfully
+unsuffixed
+unsuitability
+unsuitable
+unsuitably
+unsuited
+unsung
+unsupportable
+unsupported
+unsure
+unsurpassed
+unsurprised
+unsurprising
+unsurprisingly
+unsuspected
+unsuspecting
+unsuspended
+unswerving
+unsymmetrically
+unsympathetic
+untamed
+untampered
+untaped
+untapped
+untaught
+untented
+unterminated
+untestable
+untested
+unthematic
+unthinkable
+unthinkably
+unthinkingly
+untidiness
+untidy
+untie
+untied
+unties
+until
+untimeliness
+untimely
+untitled
+unto
+untold
+untouchable
+untouchable's
+untouchables
+untouched
+untoward
+untowardly
+untowardness
+untraceable
+untraced
+untracked
+untrained
+untransformed
+untranslated
+untransposed
+untreated
+untried
+untrod
+untroubled
+untrue
+untruly
+untrusted
+untrustworthiness
+untruth
+untruthful
+untruthfully
+untruthfulness
+untutored
+untwisted
+untying
+untyped
+unusable
+unused
+unusual
+unusually
+unusualness
+unuttered
+unvalued
+unvarnished
+unvarying
+unveil
+unveiled
+unveiling
+unveils
+unventilated
+unverified
+unvisited
+unvoiced
+unwaged
+unwanted
+unwarily
+unwarranted
+unwashed
+unwashedness
+unwatched
+unwavering
+unwaveringly
+unwearied
+unweariedly
+unweighed
+unwelcome
+unwept
+unwholesome
+unwholesomely
+unwieldiness
+unwieldy
+unwilled
+unwilling
+unwillingly
+unwillingness
+unwind
+unwinder
+unwinders
+unwinding
+unwinds
+unwinking
+unwired
+unwise
+unwisely
+unwiser
+unwisest
+unwitnessed
+unwitting
+unwittingly
+unwonted
+unwontedly
+unwontedness
+unworldliness
+unworldly
+unworn
+unworthiness
+unworthy
+unwound
+unwounded
+unwoven
+unwrap
+unwrapped
+unwrapping
+unwraps
+unwrinkled
+unwritable
+unwritten
+unyielded
+unyielding
+unyieldingly
+up
+upbraid
+upbraider
+upbringing
+update
+updated
+updater
+updates
+updating
+upfield
+upgrade
+upgraded
+upgrades
+upgrading
+upheld
+uphill
+uphold
+upholder
+upholders
+upholding
+upholds
+upholster
+upholstered
+upholsterer
+upholsterers
+upholstering
+upholsters
+upkeep
+upland
+uplander
+uplands
+uplift
+uplifted
+uplifter
+uplifting
+uplifts
+upload
+uploaded
+uploading
+uploads
+upon
+upper
+uppermost
+uppers
+upright
+uprightly
+uprightness
+uprising
+uprising's
+uprisings
+uproar
+uproot
+uprooted
+uprooter
+uprooting
+uproots
+ups
+upset
+upsets
+upsetting
+upshot
+upshot's
+upshots
+upside
+upsides
+upstairs
+upstream
+upturn
+upturned
+upturning
+upturns
+upward
+upwardly
+upwardness
+upwards
+urban
+urchin
+urchin's
+urchins
+urge
+urged
+urgent
+urgently
+urger
+urges
+urging
+urgings
+urinate
+urinated
+urinates
+urinating
+urination
+urine
+urn
+urn's
+urning
+urns
+us
+usability
+usable
+usably
+usage
+usages
+use
+used
+useful
+usefully
+usefulness
+useless
+uselessly
+uselessness
+user
+user's
+users
+uses
+usher
+ushered
+ushering
+ushers
+using
+usual
+usually
+usualness
+usurp
+usurped
+usurper
+utensil
+utensil's
+utensils
+utilities
+utility
+utility's
+utmost
+utopian
+utopian's
+utopians
+utter
+utterance
+utterance's
+utterances
+uttered
+utterer
+uttering
+utterly
+uttermost
+utters
+uucp
+uucp's
+vacancies
+vacancy
+vacancy's
+vacant
+vacantly
+vacantness
+vacate
+vacated
+vacates
+vacating
+vacation
+vacationed
+vacationer
+vacationers
+vacationing
+vacations
+vacillate
+vacillated
+vacillates
+vacillating
+vacillatingly
+vacillation
+vacillations
+vacillator
+vacillator's
+vacillators
+vacuo
+vacuous
+vacuously
+vacuousness
+vacuum
+vacuumed
+vacuuming
+vacuums
+vagabond
+vagabond's
+vagabonds
+vagaries
+vagary
+vagary's
+vagina
+vagina's
+vaginas
+vagrant
+vagrantly
+vagrants
+vague
+vaguely
+vagueness
+vaguer
+vaguest
+vainly
+vale
+vale's
+valedictorian
+valedictorian's
+valence
+valence's
+valences
+valentine
+valentine's
+valentines
+vales
+valet
+valet's
+valets
+valiant
+valiantly
+valiantness
+valid
+validate
+validated
+validates
+validating
+validation
+validations
+validity
+validly
+validness
+valley
+valley's
+valleys
+valuable
+valuableness
+valuables
+valuably
+valuation
+valuation's
+valuations
+valuator
+valuators
+value
+valued
+valuer
+valuers
+values
+valuing
+valve
+valve's
+valved
+valves
+valving
+van
+van's
+vane
+vane's
+vaned
+vanes
+vanilla
+vanish
+vanished
+vanisher
+vanishes
+vanishing
+vanishingly
+vanities
+vanity
+vanquish
+vanquished
+vanquisher
+vanquishes
+vanquishing
+vans
+vantage
+vantages
+variability
+variable
+variable's
+variableness
+variables
+variably
+variance
+variance's
+variances
+variant
+variantly
+variants
+variation
+variation's
+variations
+varied
+variedly
+varier
+varies
+varieties
+variety
+variety's
+various
+variously
+variousness
+varnish
+varnish's
+varnished
+varnisher
+varnishers
+varnishes
+varnishing
+vary
+varying
+varyingly
+varyings
+vase
+vase's
+vases
+vassal
+vassals
+vast
+vaster
+vastest
+vastly
+vastness
+vat
+vat's
+vats
+vaudeville
+vault
+vaulted
+vaulter
+vaulting
+vaults
+vaunt
+vaunted
+vaunter
+veal
+vealer
+vealing
+vector
+vector's
+vectored
+vectoring
+vectors
+veer
+veered
+veering
+veeringly
+veers
+vegetable
+vegetable's
+vegetables
+vegetarian
+vegetarian's
+vegetarians
+vegetate
+vegetated
+vegetates
+vegetating
+vegetation
+vegetative
+vegetatively
+vegetativeness
+vehemence
+vehement
+vehemently
+vehicle
+vehicle's
+vehicles
+vehicular
+veil
+veiled
+veiling
+veils
+vein
+veined
+veiner
+veining
+veins
+velocities
+velocity
+velocity's
+velvet
+vend
+vender
+vending
+vendor
+vendor's
+vendors
+venerable
+venerableness
+vengeance
+venison
+venom
+venomous
+venomously
+venomousness
+vent
+vented
+venter
+ventilate
+ventilated
+ventilates
+ventilating
+ventilation
+ventilations
+ventilative
+venting
+ventral
+ventrally
+ventricle
+ventricle's
+ventricles
+vents
+venture
+ventured
+venturer
+venturers
+ventures
+venturing
+venturings
+veracity
+veranda
+veranda's
+verandaed
+verandas
+verb
+verb's
+verbal
+verbally
+verbose
+verbosely
+verboseness
+verbs
+verdict
+verdicts
+verdure
+verdured
+verge
+verger
+verges
+verier
+veriest
+verifiability
+verifiable
+verifiableness
+verification
+verifications
+verified
+verifier
+verifier's
+verifiers
+verifies
+verify
+verifying
+verily
+veritable
+veritableness
+vermin
+versa
+versatile
+versatilely
+versatileness
+versatility
+verse
+versed
+verser
+verses
+versing
+version
+versions
+versus
+vertebrate
+vertebrate's
+vertebrates
+vertebration
+vertex
+vertexes
+vertical
+vertically
+verticalness
+verticals
+vertices
+very
+vessel
+vessel's
+vessels
+vest
+vested
+vestige
+vestige's
+vestiges
+vestigial
+vestigially
+vesting
+vests
+veteran
+veteran's
+veterans
+veterinarian
+veterinarian's
+veterinarians
+veterinary
+veto
+vetoed
+vetoer
+vetoes
+vetoing
+vetting
+vex
+vexation
+vexed
+vexedly
+vexes
+vexing
+vi
+vi's
+via
+viability
+viable
+viably
+vial
+vial's
+vials
+vibrate
+vibrated
+vibrates
+vibrating
+vibration
+vibrations
+vice
+vice's
+viceroy
+vices
+vicing
+vicinities
+vicinity
+vicious
+viciously
+viciousness
+vicissitude
+vicissitude's
+vicissitudes
+victim
+victim's
+victims
+victor
+victor's
+victories
+victorious
+victoriously
+victoriousness
+victors
+victory
+victory's
+victual
+victuals
+video
+videos
+videotape
+videotape's
+videotaped
+videotapes
+videotaping
+vie
+vied
+vier
+vies
+view
+viewable
+viewed
+viewer
+viewers
+viewing
+viewings
+viewpoint
+viewpoint's
+viewpoints
+views
+vigilance
+vigilant
+vigilante
+vigilante's
+vigilantes
+vigilantly
+vignette
+vignette's
+vignetted
+vignetter
+vignettes
+vignetting
+vigorous
+vigorously
+vigorousness
+vii
+viii
+vile
+vilely
+vileness
+viler
+vilest
+vilification
+vilifications
+vilified
+vilifier
+vilifies
+vilify
+vilifying
+villa
+villa's
+village
+village's
+villager
+villagers
+villages
+villain
+villain's
+villainous
+villainously
+villainousness
+villains
+villainy
+villas
+vindictive
+vindictively
+vindictiveness
+vine
+vine's
+vinegar
+vinegars
+vines
+vineyard
+vineyard's
+vineyards
+vining
+vintage
+vintager
+vintages
+violate
+violated
+violates
+violating
+violation
+violations
+violative
+violator
+violator's
+violators
+violence
+violent
+violently
+violet
+violet's
+violets
+violin
+violin's
+violinist
+violinist's
+violinists
+violins
+viper
+viper's
+vipers
+viral
+virally
+virgin
+virgin's
+virginity
+virgins
+virtual
+virtually
+virtue
+virtue's
+virtues
+virtuoso
+virtuoso's
+virtuosos
+virtuous
+virtuously
+virtuousness
+virus
+virus's
+viruses
+vis
+visa
+visaed
+visage
+visaged
+visaing
+visas
+viscosities
+viscosity
+viscount
+viscount's
+viscounts
+viscous
+viscously
+viscousness
+visibilities
+visibility
+visible
+visibleness
+visibly
+vision
+vision's
+visionariness
+visionary
+visioned
+visioning
+visions
+visit
+visitation
+visitation's
+visitations
+visited
+visiting
+visitor
+visitor's
+visitors
+visits
+visor
+visor's
+visored
+visors
+vista
+vista's
+vistaed
+vistas
+visual
+visually
+visuals
+vita
+vitae
+vital
+vitality
+vitally
+vitals
+vitamin
+vitamin's
+vitamins
+vivid
+vividly
+vividness
+vizier
+vocabularies
+vocabulary
+vocal
+vocally
+vocals
+vocation
+vocation's
+vocational
+vocationally
+vocations
+vogue
+voice
+voiced
+voicer
+voicers
+voices
+voicing
+void
+voided
+voider
+voiding
+voidness
+voids
+volatile
+volatileness
+volatiles
+volatilities
+volatility
+volcanic
+volcano
+volcano's
+volcanos
+volley
+volleyball
+volleyball's
+volleyballs
+volleyed
+volleyer
+volleying
+volleys
+volt
+voltage
+voltages
+volts
+volume
+volume's
+volumed
+volumes
+voluming
+voluntarily
+voluntariness
+voluntary
+volunteer
+volunteered
+volunteering
+volunteers
+vomit
+vomited
+vomiter
+vomiting
+vomits
+vortex
+vortexes
+vote
+voted
+voter
+voters
+votes
+voting
+votive
+votively
+votiveness
+vouch
+voucher
+vouchers
+vouches
+vouching
+vow
+vowed
+vowel
+vowel's
+vowels
+vower
+vowing
+vows
+voyage
+voyaged
+voyager
+voyagers
+voyages
+voyaging
+voyagings
+vulgar
+vulgarly
+vulnerabilities
+vulnerability
+vulnerable
+vulnerableness
+vulture
+vulture's
+vultures
+wade
+waded
+wader
+waders
+wades
+wading
+wafer
+wafer's
+wafered
+wafering
+wafers
+waffle
+waffle's
+waffled
+waffles
+waffling
+waft
+wafter
+wag
+wage
+waged
+wager
+wagered
+wagerer
+wagering
+wagers
+wages
+waging
+wagon
+wagon's
+wagons
+wags
+wail
+wailed
+wailer
+wailing
+wails
+waist
+waist's
+waistcoat
+waistcoat's
+waistcoated
+waistcoats
+waisted
+waister
+waists
+wait
+waited
+waiter
+waiter's
+waiters
+waiting
+waitress
+waitress's
+waitresses
+waits
+waive
+waived
+waiver
+waiverable
+waivers
+waives
+waiving
+wake
+waked
+waken
+wakened
+wakener
+wakening
+waker
+wakes
+waking
+walk
+walked
+walker
+walkers
+walking
+walks
+walkway
+walkway's
+walkways
+wall
+wall's
+walled
+waller
+wallet
+wallet's
+wallets
+walling
+wallow
+wallowed
+wallower
+wallowing
+wallows
+walls
+walnut
+walnut's
+walnuts
+walrus
+walrus's
+walruses
+waltz
+waltzed
+waltzer
+waltzes
+waltzing
+wan
+wand
+wander
+wandered
+wanderer
+wanderers
+wandering
+wanderings
+wanders
+wane
+waned
+wanes
+waning
+wanly
+wanness
+want
+wanted
+wanter
+wanting
+wanton
+wantoner
+wantonly
+wantonness
+wants
+war
+war's
+warble
+warbled
+warbler
+warbles
+warbling
+ward
+warded
+warden
+wardens
+warder
+warding
+wardrobe
+wardrobe's
+wardrobes
+wards
+ware
+warehouse
+warehoused
+warehouser
+warehouses
+warehousing
+wares
+warfare
+warier
+wariest
+warily
+wariness
+waring
+warlike
+warm
+warmed
+warmer
+warmers
+warmest
+warming
+warmly
+warmness
+warms
+warmth
+warn
+warned
+warner
+warning
+warningly
+warnings
+warns
+warp
+warp's
+warped
+warper
+warping
+warps
+warrant
+warranted
+warranter
+warranties
+warranting
+warrants
+warranty
+warranty's
+warred
+warring
+warrior
+warrior's
+warriors
+wars
+warship
+warship's
+warships
+wart
+wart's
+warted
+warts
+wary
+was
+wash
+washed
+washer
+washers
+washes
+washing
+washings
+wasn't
+wasp
+wasp's
+wasps
+waste
+wasted
+wasteful
+wastefully
+wastefulness
+waster
+wastes
+wasting
+wastingly
+watch
+watched
+watcher
+watchers
+watches
+watchful
+watchfully
+watchfulness
+watching
+watchings
+watchman
+watchword
+watchword's
+watchwords
+water
+watered
+waterer
+waterfall
+waterfall's
+waterfalls
+wateriness
+watering
+waterings
+waterproof
+waterproofed
+waterproofer
+waterproofing
+waterproofness
+waterproofs
+waters
+waterway
+waterway's
+waterways
+watery
+wave
+waved
+waveform
+waveform's
+waveforms
+wavefront
+wavefront's
+wavefronts
+wavelength
+wavelengths
+waver
+wavered
+waverer
+wavering
+waveringly
+wavers
+waves
+waving
+wax
+waxed
+waxen
+waxer
+waxers
+waxes
+waxier
+waxiness
+waxing
+waxy
+way
+way's
+ways
+wayside
+waysides
+wayward
+waywardly
+waywardness
+we
+we'd
+we'll
+we're
+we've
+weak
+weaken
+weakened
+weakener
+weakening
+weakens
+weaker
+weakest
+weakliness
+weakly
+weakness
+weakness's
+weaknesses
+wealth
+wealthier
+wealthiest
+wealthiness
+wealths
+wealthy
+wean
+weaned
+weaner
+weaning
+weapon
+weapon's
+weaponed
+weapons
+wear
+wearable
+wearer
+wearied
+wearier
+wearies
+weariest
+wearily
+weariness
+wearing
+wearingly
+wearisome
+wearisomely
+wearisomeness
+wears
+weary
+wearying
+weasel
+weasel's
+weasels
+weather
+weathercock
+weathercock's
+weathercocks
+weathered
+weatherer
+weathering
+weatherly
+weathers
+weave
+weaver
+weavers
+weaves
+weaving
+web
+web's
+weber
+webs
+wed
+wedded
+wedding
+wedding's
+weddings
+wedge
+wedged
+wedges
+wedging
+weds
+wee
+weed
+weeded
+weeder
+weeding
+weeds
+week
+week's
+weekday
+weekday's
+weekdays
+weekend
+weekend's
+weekender
+weekends
+weeklies
+weekly
+weeks
+weep
+weeped
+weeper
+weepers
+weeping
+weeps
+weigh
+weighed
+weigher
+weighing
+weighings
+weighs
+weight
+weighted
+weighter
+weighting
+weightings
+weights
+weird
+weirdly
+weirdness
+welcome
+welcomed
+welcomely
+welcomeness
+welcomer
+welcomes
+welcoming
+weld
+welded
+welder
+welders
+welding
+weldings
+welds
+welfare
+well
+welled
+welling
+wellness
+wells
+wench
+wench's
+wencher
+wenches
+went
+wept
+were
+weren't
+west
+wester
+westered
+westering
+westerlies
+westerly
+western
+westerner
+westerners
+westing
+westward
+westwards
+wet
+wetly
+wetness
+wets
+wetted
+wetter
+wettest
+wetting
+whack
+whacked
+whacker
+whacking
+whacks
+whale
+whaler
+whales
+whaling
+whammies
+whammy
+wharf
+wharfs
+wharves
+what
+what's
+whatchamacallit
+whatchamacallit's
+whatchamacallits
+whatever
+whatsoever
+wheat
+wheaten
+wheel
+wheeled
+wheeler
+wheelers
+wheeling
+wheelings
+wheels
+whelp
+when
+whence
+whenever
+whens
+where
+where's
+whereabouts
+whereas
+whereby
+wherein
+whereupon
+wherever
+whether
+whew
+whey
+which
+whichever
+while
+whiled
+whiles
+whiling
+whim
+whim's
+whimper
+whimpered
+whimpering
+whimpers
+whims
+whimsical
+whimsically
+whimsicalness
+whimsied
+whimsies
+whimsy
+whimsy's
+whine
+whined
+whiner
+whines
+whining
+whiningly
+whip
+whip's
+whipped
+whipper
+whipper's
+whippers
+whipping
+whipping's
+whippings
+whips
+whirl
+whirled
+whirler
+whirling
+whirlpool
+whirlpool's
+whirlpools
+whirls
+whirlwind
+whirr
+whirring
+whisk
+whisked
+whisker
+whiskered
+whiskers
+whiskey
+whiskey's
+whiskeys
+whisking
+whisks
+whisper
+whispered
+whisperer
+whispering
+whisperingly
+whisperings
+whispers
+whistle
+whistled
+whistler
+whistlers
+whistles
+whistling
+whit
+white
+whited
+whitely
+whiten
+whitened
+whitener
+whiteners
+whiteness
+whitening
+whitens
+whiter
+whites
+whitespace
+whitest
+whitewash
+whitewashed
+whitewasher
+whitewashing
+whiting
+whittle
+whittled
+whittler
+whittles
+whittling
+whittlings
+whiz
+whizzed
+whizzes
+whizzing
+who
+who's
+whoever
+whole
+wholehearted
+wholeheartedly
+wholeness
+wholes
+wholesale
+wholesaled
+wholesaler
+wholesalers
+wholesales
+wholesaling
+wholesome
+wholesomely
+wholesomeness
+wholly
+whom
+whomever
+whoop
+whooped
+whooper
+whooping
+whoops
+whore
+whore's
+whores
+whoring
+whorl
+whorl's
+whorled
+whorls
+whose
+why
+wick
+wicked
+wickedly
+wickedness
+wicker
+wicking
+wicks
+wide
+widely
+widen
+widened
+widener
+wideness
+widening
+widens
+wider
+widespread
+widest
+widget
+widget's
+widgets
+widow
+widowed
+widower
+widowers
+widows
+width
+widths
+wield
+wielded
+wielder
+wielding
+wields
+wife
+wife's
+wifeliness
+wifely
+wig
+wig's
+wigs
+wigwam
+wild
+wildcat
+wildcat's
+wildcats
+wilder
+wilderness
+wildest
+wilding
+wildly
+wildness
+wile
+wiled
+wiles
+wilier
+wiliness
+wiling
+will
+willed
+willer
+willful
+willfully
+willfulness
+willing
+willingly
+willingness
+willings
+willow
+willow's
+willower
+willows
+wills
+wilt
+wilted
+wilting
+wilts
+wily
+win
+wince
+winced
+winces
+wincing
+wind
+winded
+winder
+winders
+windier
+windiness
+winding
+windmill
+windmill's
+windmilling
+windmills
+window
+window's
+windowed
+windowing
+windows
+winds
+windy
+wine
+wined
+winer
+winers
+wines
+wing
+winged
+winger
+wingers
+winging
+wings
+wining
+wink
+winked
+winker
+winking
+winks
+winner
+winner's
+winners
+winning
+winningly
+winnings
+wins
+winter
+wintered
+winterer
+wintering
+winterly
+winters
+wintrier
+wintriness
+wintry
+wipe
+wiped
+wiper
+wipers
+wipes
+wiping
+wire
+wired
+wireless
+wirer
+wires
+wiretap
+wiretap's
+wiretaps
+wirier
+wiriness
+wiring
+wirings
+wiry
+wisdom
+wisdoms
+wise
+wised
+wisely
+wiseness
+wiser
+wises
+wisest
+wish
+wished
+wisher
+wishers
+wishes
+wishful
+wishfully
+wishfulness
+wishing
+wising
+wisp
+wisp's
+wisps
+wistful
+wistfully
+wistfulness
+wit
+wit's
+witch
+witchcraft
+witches
+witching
+with
+withal
+withdraw
+withdrawal
+withdrawal's
+withdrawals
+withdrawer
+withdrawing
+withdrawn
+withdrawnness
+withdraws
+withdrew
+wither
+withered
+withering
+witheringly
+withers
+withheld
+withhold
+withholder
+withholders
+withholding
+withholdings
+withholds
+within
+without
+withstand
+withstanding
+withstands
+withstood
+witness
+witnessed
+witnesses
+witnessing
+wits
+wittier
+wittiest
+wittiness
+witty
+wives
+wizard
+wizard's
+wizardly
+wizards
+woe
+woeful
+woefully
+woeness
+woke
+wolf
+wolfer
+wolves
+woman
+woman's
+womanhood
+womanliness
+womanly
+womb
+womb's
+wombed
+wombs
+women
+women's
+womens
+won't
+wonder
+wondered
+wonderer
+wonderful
+wonderfully
+wonderfulness
+wondering
+wonderingly
+wonderland
+wonderland's
+wonderment
+wonders
+wondrous
+wondrously
+wondrousness
+wont
+wonted
+wontedly
+wontedness
+wonting
+woo
+wood
+wood's
+woodchuck
+woodchuck's
+woodchucks
+woodcock
+woodcock's
+woodcocks
+wooded
+wooden
+woodenly
+woodenness
+woodier
+woodiness
+wooding
+woodland
+woodlander
+woodman
+woodpecker
+woodpecker's
+woodpeckers
+woods
+woodser
+woodwork
+woodworker
+woodworking
+woody
+wooed
+wooer
+woof
+woofed
+woofer
+woofers
+woofing
+woofs
+wooing
+wool
+wooled
+woolen
+woolens
+woollier
+woollies
+woolliness
+woolly
+wools
+wooly
+woos
+word
+word's
+worded
+wordier
+wordily
+wordiness
+wording
+wordings
+words
+wordy
+wore
+work
+workable
+workableness
+workably
+workaround
+workaround's
+workarounds
+workbench
+workbench's
+workbenches
+workbook
+workbook's
+workbooks
+worked
+worker
+worker's
+workers
+workhorse
+workhorse's
+workhorses
+working
+workingman
+workings
+workload
+workloads
+workman
+workmanly
+workmanship
+workmen
+workmen's
+works
+workshop
+workshop's
+workshops
+workstation
+workstation's
+workstations
+world
+world's
+worlders
+worldliness
+worldly
+worlds
+worldwide
+worm
+wormed
+wormer
+worming
+worms
+worn
+worried
+worriedly
+worrier
+worriers
+worries
+worrisome
+worrisomely
+worrisomeness
+worry
+worrying
+worryingly
+worse
+worser
+worship
+worshipful
+worshipfully
+worshipfulness
+worships
+worst
+worsted
+worth
+worthier
+worthies
+worthiest
+worthiness
+worthing
+worthless
+worthlessly
+worthlessness
+worths
+worthwhile
+worthwhileness
+worthy
+would
+wouldest
+wouldn't
+wound
+wounded
+wounding
+wounds
+wove
+woven
+wrangle
+wrangled
+wrangler
+wranglers
+wrangles
+wrangling
+wrap
+wrap's
+wrapped
+wrapper
+wrapper's
+wrappers
+wrapping
+wrappings
+wraps
+wrath
+wreak
+wreaks
+wreath
+wreathed
+wreathes
+wreathing
+wreck
+wreckage
+wrecked
+wrecker
+wreckers
+wrecking
+wrecks
+wren
+wren's
+wrench
+wrenched
+wrenches
+wrenching
+wrenchingly
+wrens
+wrest
+wrested
+wrester
+wresting
+wrestle
+wrestled
+wrestler
+wrestles
+wrestling
+wrestlings
+wrests
+wretch
+wretched
+wretchedly
+wretchedness
+wretches
+wriggle
+wriggled
+wriggler
+wriggles
+wriggling
+wring
+wringer
+wringing
+wrings
+wrinkle
+wrinkled
+wrinkles
+wrinkling
+wrist
+wrist's
+wrists
+wristwatch
+wristwatch's
+wristwatches
+writ
+writ's
+writable
+write
+writer
+writer's
+writers
+writes
+writhe
+writhed
+writhes
+writhing
+writing
+writings
+writs
+written
+wrong
+wronged
+wronger
+wrongest
+wronging
+wrongly
+wrongness
+wrongs
+wrote
+wrought
+wrung
+xi
+xii
+xiii
+xiv
+xix
+xv
+xvi
+xvii
+xviii
+xx
+yacc
+yacc's
+yank
+yanked
+yanking
+yanks
+yard
+yard's
+yarded
+yarding
+yards
+yardstick
+yardstick's
+yardsticks
+yarn
+yarn's
+yarned
+yarning
+yarns
+yawn
+yawner
+yawning
+yawningly
+yawns
+yea
+yeah
+year
+year's
+yearly
+yearn
+yearned
+yearner
+yearning
+yearningly
+yearnings
+yearns
+years
+yeas
+yeast
+yeast's
+yeasts
+yecch
+yell
+yelled
+yeller
+yelling
+yellow
+yellowed
+yellower
+yellowest
+yellowing
+yellowish
+yellowness
+yellows
+yells
+yelp
+yelped
+yelper
+yelping
+yelps
+yeoman
+yeomanly
+yeomen
+yes
+yeses
+yesterday
+yesterday's
+yesterdays
+yet
+yield
+yielded
+yielder
+yielding
+yields
+yoke
+yoke's
+yokes
+yoking
+yon
+yonder
+you
+you'd
+you'll
+you're
+you've
+young
+younger
+youngest
+youngly
+youngness
+youngster
+youngster's
+youngsters
+your
+your's
+yours
+yourself
+yourselves
+youth
+youth's
+youthes
+youthful
+youthfully
+youthfulness
+yuck
+yummier
+yummy
+yuppie
+yuppie's
+yuppies
+zap
+zapped
+zapping
+zaps
+zeal
+zealous
+zealously
+zealousness
+zebra
+zebra's
+zebras
+zenith
+zero
+zeroed
+zeroes
+zeroing
+zeros
+zeroth
+zest
+zigzag
+zinc
+zinc's
+zodiac
+zodiacs
+zonal
+zonally
+zone
+zoned
+zonely
+zoner
+zones
+zoning
+zoo
+zoo's
+zoological
+zoologically
+zoom
+zoomed
+zooming
+zooms
+zoos
+acclimatisation
+acclimatisations
+acclimatised
+accoutrement
+accoutrement's
+accoutrements
+acknowledgement
+acknowledgement's
+acknowledgements
+actualisation
+actualisation's
+actualisations
+aerofoil
+aerofoils
+aeroplane
+aeroplane's
+aeroplanes
+aerosolise
+aerosolised
+aesthetic
+aesthetic's
+aesthetically
+aesthetics
+agonise
+agonised
+agonisedly
+agoniser
+agonisers
+agonises
+agonising
+agonisinglies
+agonisingly
+alphabetise
+alphabetised
+alphabetiser
+alphabetisers
+alphabetises
+alphabetising
+aluminium
+aluminium's
+aluminiums
+amenorrhoea
+amorist
+amorist's
+amorists
+amortise
+amortised
+amortises
+amortising
+amphitheatre
+amphitheatre's
+amphitheatres
+anaemia
+anaemia's
+anaemias
+anaemic
+anaemics
+anaesthesia
+anaesthesia's
+anaesthesias
+anaesthetic
+anaesthetic's
+anaesthetically
+anaesthetics
+anaesthetise
+anaesthetised
+anaesthetiser
+anaesthetisers
+anaesthetises
+anaesthetising
+analogue
+analogue's
+analogues
+analysable
+analyse
+analysed
+analyser
+analysers
+analyses
+analysing
+anodise
+anodised
+anodises
+anodising
+antagonise
+antagonised
+antagoniser
+antagonisers
+antagonises
+antagonising
+apologise
+apologised
+apologiser
+apologisers
+apologises
+apologising
+appal
+appals
+apparelled
+appetiser
+appetising
+appetisingly
+arbour
+arbour's
+arboured
+arbours
+archaise
+archaised
+archaiser
+archaisers
+archaises
+archaising
+ardour
+ardour's
+ardours
+arithmetise
+arithmetised
+arithmetises
+armour
+armour's
+armoured
+armourer
+armourer's
+armourers
+armouried
+armouries
+armouring
+armours
+armoury
+armoury's
+atomisation
+atomisation's
+atomisations
+atomise
+atomised
+atomiser
+atomisers
+atomises
+atomising
+authorisation
+authorisation's
+authorisations
+authorise
+authorised
+authoriser
+authorisers
+authorises
+authorising
+autodialler
+axiomatisation
+axiomatisation's
+axiomatisations
+axiomatise
+axiomatised
+axiomatises
+axiomatising
+balkanise
+balkanised
+balkanising
+baptise
+baptised
+baptiser
+baptisers
+baptises
+baptising
+barrelled
+barrelling
+bastardise
+bastardised
+bastardises
+bastardising
+bedevilled
+bedevilling
+behaviour
+behaviour's
+behavioural
+behaviourally
+behavioured
+behaviourism
+behaviourism's
+behaviourisms
+behaviouristic
+behaviouristics
+behaviours
+behove
+behoved
+behoves
+behoving
+behoving's
+behovingly
+behovings
+belabour
+belabour's
+belaboured
+belabouring
+belabours
+bevelled
+bevelling
+bevellings
+bowdlerise
+bowdlerised
+bowdleriser
+bowdlerises
+bowdlerising
+brutalise
+brutalised
+brutalises
+brutalising
+bushelled
+bushelling
+bushellings
+calibre
+calibres
+canalled
+canalling
+cancelled
+canceller
+cancelling
+candour
+candour's
+candours
+cannibalise
+cannibalised
+cannibalises
+cannibalising
+canonicalisation
+canonicalise
+canonicalised
+canonicalises
+canonicalising
+capitalisation
+capitalisation's
+capitalisations
+capitalise
+capitalised
+capitaliser
+capitalisers
+capitalises
+capitalising
+carbonisation
+carbonisation's
+carbonisations
+carbonise
+carbonised
+carboniser
+carbonisers
+carbonises
+carbonising
+catalogue
+catalogue's
+catalogued
+cataloguer
+catalogues
+cataloguing
+categorisation
+categorisation's
+categorisations
+categorise
+categorised
+categoriser
+categorisers
+categorises
+categorising
+centimetre
+centimetre's
+centimetres
+centralisation
+centralisation's
+centralisations
+centralise
+centralised
+centraliser
+centralisers
+centralises
+centralising
+centre
+centre's
+centred
+centrepiece
+centrepiece's
+centrepieces
+centres
+centring
+channelled
+channeller
+channeller's
+channellers
+channelling
+characterisable
+characterisables
+characterisation
+characterisation's
+characterisations
+characterise
+characterised
+characteriser
+characterisers
+characterises
+characterising
+cheque
+cheque's
+chequebook
+chequebook's
+chequebooks
+chequer
+chequered
+chequers
+cheques
+chiselled
+chiseller
+chisellers
+civilisation
+civilisation's
+civilisations
+civilise
+civilised
+civilisedness
+civiliser
+civilisers
+civilises
+civilising
+clamour
+clamoured
+clamourer
+clamourer's
+clamourers
+clamouring
+clamours
+cognisance
+cognisant
+colonisation
+colonisation's
+colonisations
+colonise
+colonised
+coloniser
+colonisers
+colonises
+colonising
+colour
+colour's
+coloured
+coloureds
+colourer
+colourer's
+colourers
+colourful
+colourfully
+colourfulness
+colouring
+colourings
+colourless
+colourlessly
+colourlessness
+colours
+columnise
+columnised
+columnises
+columnising
+compartmentalise
+compartmentalised
+compartmentalises
+compartmentalising
+computerise
+computerised
+computerises
+computerising
+conceptualisation
+conceptualisation's
+conceptualisations
+conceptualise
+conceptualised
+conceptualiser
+conceptualises
+conceptualising
+counselled
+counselling
+counsellor
+counsellor's
+counsellors
+criticise
+criticised
+criticiser
+criticisers
+criticises
+criticising
+criticisinglies
+criticisingly
+crystallise
+crystallised
+crystalliser
+crystallisers
+crystallises
+crystallising
+customisable
+customisation
+customisation's
+customisations
+customise
+customised
+customiser
+customisers
+customises
+customising
+decentralisation
+decentralisation's
+decentralisations
+decentralised
+defence
+defence's
+defenced
+defenceless
+defencelessly
+defencelessness
+defences
+defencing
+defencive
+demeanour
+demeanour's
+demeanours
+demoralise
+demoralised
+demoraliser
+demoralisers
+demoralises
+demoralising
+demoralisingly
+dialled
+dialler
+diallers
+dialling
+diallings
+dichotomise
+dichotomised
+dichotomises
+dichotomising
+digitise
+digitised
+digitiser
+digitiser's
+digitisers
+digitises
+digitising
+dishonour
+dishonoured
+dishonourer
+dishonourer's
+dishonourers
+dishonouring
+dishonours
+disorganised
+draught
+draught's
+draughts
+draughtsman
+duelled
+dueller
+duellers
+duelling
+duellings
+economise
+economised
+economiser
+economisers
+economises
+economising
+editorialise
+editorialised
+editorialiser
+editorialises
+editorialising
+enamelled
+enameller
+enamellers
+enamelling
+enamellings
+encyclopaedia
+encyclopaedia's
+encyclopaedias
+endeavour
+endeavoured
+endeavourer
+endeavourer's
+endeavourers
+endeavouring
+endeavours
+enrol
+enrolment
+enrolment's
+enrolments
+enrols
+epitomise
+epitomised
+epitomiser
+epitomisers
+epitomises
+epitomising
+equalisation
+equalisation's
+equalisations
+equalise
+equalised
+equaliser
+equaliser's
+equalisers
+equalises
+equalising
+equalisings
+equalled
+equalling
+eviller
+evillest
+factorisation
+factorisation's
+factorisations
+familiarisation
+familiarisation's
+familiarisations
+familiarise
+familiarised
+familiariser
+familiarisers
+familiarises
+familiarising
+familiarisingly
+fantasise
+fantasised
+fantasiser
+fantasises
+fantasising
+favour
+favourable
+favourableness
+favourables
+favourably
+favoured
+favoured's
+favouredly
+favouredness
+favoureds
+favourer
+favourer's
+favourers
+favouring
+favouring's
+favouringly
+favourings
+favourite
+favourite's
+favourites
+favours
+fertilisation
+fertilisation's
+fertilisations
+fertilise
+fertilised
+fertiliser
+fertilisers
+fertilises
+fertilising
+fervour
+fervour's
+fervours
+fibre
+fibre's
+fibred
+fibreglass
+fibres
+finalisation
+finalisations
+finalise
+finalised
+finalises
+finalising
+flavour
+flavour's
+flavoured
+flavourer
+flavourer's
+flavourers
+flavouring
+flavourings
+flavours
+formalisation
+formalisation's
+formalisations
+formalise
+formalised
+formaliser
+formalisers
+formalises
+formalising
+fuelled
+fueller
+fuellers
+fuelling
+fulfil
+fulfilment
+fulfilment's
+fulfilments
+fulfils
+funnelled
+funnelling
+gaol
+generalisation
+generalisation's
+generalisations
+generalise
+generalised
+generaliser
+generalisers
+generalises
+generalising
+glamorise
+glamorised
+glamoriser
+glamorisers
+glamorises
+glamorising
+gospeller
+gospellers
+gossipped
+gossipping
+gramme
+gramme's
+grammes
+gravelled
+gravelling
+grovelled
+groveller
+grovellers
+grovelling
+grovellingly
+harbour
+harbour's
+harboured
+harbourer
+harbourer's
+harbourers
+harbouring
+harbours
+harmonise
+harmonised
+harmoniser
+harmonisers
+harmonises
+harmonising
+honour
+honourable
+honourableness
+honourables
+honourablies
+honourably
+honoured
+honourer
+honourer's
+honourers
+honouring
+honours
+hospitalise
+hospitalised
+hospitalises
+hospitalising
+humour
+humour's
+humoured
+humourer
+humourers
+humouring
+humours
+hypothesise
+hypothesised
+hypothesiser
+hypothesisers
+hypothesises
+hypothesising
+idealisation
+idealisation's
+idealisations
+idealise
+idealised
+idealiser
+idealisers
+idealises
+idealising
+imperilled
+incognisance
+incognisant
+individualise
+individualised
+individualiser
+individualisers
+individualises
+individualising
+individualisingly
+industrialisation
+industrialisation's
+industrialisations
+informalises
+initialisation
+initialisation's
+initialisations
+initialise
+initialised
+initialiser
+initialisers
+initialises
+initialising
+initialled
+initialler
+initialling
+institutionalise
+institutionalised
+institutionalises
+institutionalising
+internalisation
+internalisation's
+internalisations
+internalise
+internalised
+internalises
+internalising
+italicise
+italicised
+italicises
+italicising
+itemisation
+itemisation's
+itemisations
+itemise
+itemised
+itemiser
+itemisers
+itemises
+itemising
+jeopardise
+jeopardised
+jeopardises
+jeopardising
+jewelled
+jeweller
+jewellers
+jewelling
+journalise
+journalised
+journaliser
+journalisers
+journalises
+journalising
+judgement
+judgement's
+judgements
+kidnapped
+kidnapper
+kidnapper's
+kidnappers
+kidnapping
+kidnapping's
+kidnappings
+kilogramme
+kilogramme's
+kilogrammes
+kilometre
+kilometre's
+kilometres
+labelled
+labeller
+labeller's
+labellers
+labelling
+labour
+laboured
+laboured's
+labouredly
+labouredness
+labourer
+labourer's
+labourers
+labouring
+labouring's
+labouringly
+labourings
+labours
+laurelled
+legalisation
+legalisation's
+legalisations
+legalise
+legalised
+legalises
+legalising
+levelled
+leveller
+levellers
+levellest
+levelling
+liberalise
+liberalised
+liberaliser
+liberalisers
+liberalises
+liberalising
+licence
+licence's
+licences
+linearisable
+linearise
+linearised
+linearises
+linearising
+linearision
+litre
+litres
+localisation
+localisation's
+localisations
+localise
+localised
+localiser
+localisers
+localises
+localising
+lustre
+lustred
+lustres
+lustring
+magnetisation
+magnetisation's
+magnetisations
+manoeuvre
+manoeuvred
+manoeuvrer
+manoeuvres
+manoeuvring
+marvelled
+marvelling
+marvellous
+marvellously
+marvellousness
+materialise
+materialised
+materialiser
+materialisers
+materialises
+materialising
+maximise
+maximised
+maximiser
+maximisers
+maximises
+maximising
+mechanisation
+mechanisation's
+mechanisations
+mechanise
+mechanised
+mechaniser
+mechanisers
+mechanises
+mechanising
+medalled
+medalling
+mediaeval
+mediaeval's
+mediaevally
+mediaevals
+memorisation
+memorisation's
+memorisations
+memorise
+memorised
+memoriser
+memorisers
+memorises
+memorising
+metalled
+metalling
+metallisation
+metallisation's
+metallisations
+metre
+metre's
+metred
+metres
+metring
+millimetre
+millimetre's
+millimetres
+miniaturisation
+miniaturisations
+miniaturise
+miniaturised
+miniaturises
+miniaturising
+minimisation
+minimisation's
+minimisations
+minimise
+minimised
+minimiser
+minimisers
+minimises
+minimising
+misjudgement
+mitre
+mitred
+mitrer
+mitring
+modelled
+modeller
+modellers
+modelling
+modellings
+modernise
+modernised
+moderniser
+modernisers
+modernises
+modernising
+modularisation
+modularise
+modularised
+modularises
+modularising
+motorise
+motorised
+motorises
+motorising
+moustache
+moustached
+moustaches
+multilevelled
+nationalisation
+nationalisation's
+nationalisations
+nationalise
+nationalised
+nationaliser
+nationalisers
+nationalises
+nationalising
+naturalisation
+naturalisation's
+naturalisations
+neighbour
+neighbour's
+neighboured
+neighbourer
+neighbourer's
+neighbourers
+neighbourhood
+neighbourhood's
+neighbourhoods
+neighbouring
+neighbourings
+neighbourliness
+neighbourly
+neighbours
+neutralise
+neutralised
+neutraliser
+neutralisers
+neutralises
+neutralising
+nickelled
+nickelling
+normalisation
+normalisation's
+normalisations
+normalise
+normalised
+normaliser
+normalisers
+normalises
+normalising
+notarise
+notarised
+notarises
+notarising
+nought
+noughts
+odour
+odour's
+odoured
+odours
+offence
+offence's
+offences
+offencive
+optimisation
+optimisation's
+optimisations
+optimise
+optimised
+optimiser
+optimiser's
+optimisers
+optimises
+optimising
+organisable
+organisables
+organisation
+organisation's
+organisational
+organisational's
+organisationally
+organisationals
+organisations
+organise
+organised
+organiser
+organisers
+organises
+organising
+oxidise
+oxidised
+oxidiser
+oxidisers
+oxidises
+oxidising
+oxidisings
+panelled
+panelling
+panellings
+parallelisation
+parallelisation's
+parallelisations
+parallelise
+parallelised
+paralleliser
+parallelisers
+parallelises
+parallelising
+parallelled
+parallelling
+paralyse
+paralysed
+paralysedlies
+paralysedly
+paralyser
+paralyser's
+paralysers
+paralyses
+paralysing
+paralysinglies
+paralysingly
+parameterisable
+parameterisation
+parameterisation's
+parameterisations
+parameterise
+parameterised
+parameterises
+parameterising
+parametrisable
+parametrisation
+parametrisation's
+parametrisations
+parametrise
+parametrised
+parametrises
+parametrising
+parcelled
+parcelling
+parenthesised
+parlour
+parlour's
+parlours
+patronise
+patronised
+patroniser
+patronisers
+patronises
+patronising
+patronising's
+patronisingly
+patronisings
+penalise
+penalised
+penalises
+penalising
+pencilled
+pencilling
+pencillings
+personalisation
+personalisation's
+personalisations
+personalise
+personalised
+personalises
+personalising
+petalled
+philosophise
+philosophised
+philosophiser
+philosophisers
+philosophises
+philosophising
+plough
+ploughed
+plougher
+ploughes
+ploughing
+ploughman
+pluralisation
+pluralisation's
+pluralisations
+pluralise
+pluralised
+pluraliser
+pluralisers
+pluralises
+pluralising
+polarisation
+polarisation's
+polarisations
+popularisation
+popularisation's
+popularisations
+popularise
+popularised
+populariser
+popularisers
+popularises
+popularising
+practician
+practise
+practised
+practiser
+practises
+practising
+preinitialise
+preinitialised
+preinitialises
+preinitialising
+pressurise
+pressurised
+pressuriser
+pressurisers
+pressurises
+pressurising
+pretence
+pretences
+pretencion
+pretencions
+pretencive
+prioritise
+prioritised
+prioritiser
+prioritisers
+prioritises
+prioritising
+prioritisings
+productise
+productised
+productiser
+productisers
+productises
+productising
+programme
+programme's
+programmes
+proselytise
+proselytised
+proselytiser
+proselytisers
+proselytises
+proselytising
+publicise
+publicised
+publicises
+publicising
+pulverise
+pulverised
+pulveriser
+pulverisers
+pulverises
+pulverising
+pyjama
+pyjama's
+pyjamaed
+pyjamas
+quantisation
+quantisation's
+quantisations
+quantise
+quantised
+quantiser
+quantiser's
+quantisers
+quantises
+quantising
+quarrelled
+quarreller
+quarrellers
+quarrelling
+queueing
+randomise
+randomised
+randomiser
+randomises
+randomising
+rationalise
+rationalised
+rationaliser
+rationalisers
+rationalises
+rationalising
+reacclimatisation
+reacclimatisation's
+reacclimatisations
+reacknowledgement
+reacknowledgement's
+reacknowledgements
+reactualisation
+reactualisation's
+reactualisations
+realisable
+realisableness
+realisables
+realisablies
+realisably
+realisation
+realisation's
+realisations
+realise
+realised
+realiser
+realisers
+realises
+realising
+realising's
+realisingly
+realisings
+reanalyse
+reanalysed
+reanalyser
+reanalysers
+reanalyses
+reanalysing
+reapologises
+reauthorisation
+reauthorisation's
+reauthorisations
+reauthorises
+rebrutalises
+recapitalisation
+recapitalisation's
+recapitalisations
+recapitalised
+recapitalises
+recarbonisation
+recarbonisation's
+recarbonisations
+recarboniser
+recarbonisers
+recarbonises
+recategorised
+recentralisation
+recentralisation's
+recentralisations
+recentralises
+recivilisation
+recivilisation's
+recivilisations
+recivilises
+recognisability
+recognisable
+recognisably
+recognisance
+recognise
+recognised
+recognisedlies
+recognisedly
+recogniser
+recognisers
+recognises
+recognising
+recognisinglies
+recognisingly
+recolonisation
+recolonisation's
+recolonisations
+recolonises
+recoloured
+recolours
+reconceptualising
+recriticises
+recrystallised
+recrystallises
+redialled
+refavours
+refertilisation
+refertilisation's
+refertilisations
+refertilises
+refuelled
+refuelling
+reharmonises
+rehonours
+reinitialise
+reinitialised
+reinitialises
+reinitialising
+reitemises
+relabelled
+relabeller
+relabellers
+relabelling
+remagnetisation
+remagnetisation's
+remagnetisations
+rematerialises
+rememorises
+remodelled
+remodelling
+renationalised
+renationalises
+renormalised
+renormalises
+reorganisation
+reorganisation's
+reorganisations
+reorganise
+reorganised
+reorganiser
+reorganisers
+reorganises
+reorganising
+reoxidises
+repatronises
+reprogramme
+reprogrammes
+repulverises
+resepulchres
+restandardisation
+restandardisation's
+restandardisations
+restandardises
+resterilises
+resymbolisation
+resymbolisation's
+resymbolisations
+resymbolises
+resynchronisations
+resynchronised
+resynchronises
+resynthesises
+retranquilises
+reutilisation
+reutilises
+revelled
+reveller
+revellers
+revelling
+revellings
+revisualises
+revolutionise
+revolutionised
+revolutioniser
+revolutionisers
+revolutionises
+revolutionising
+rigour
+rigour's
+rigours
+rivalled
+rivalling
+rouble
+rouble's
+roubles
+routeing
+rumour
+rumour's
+rumoured
+rumourer
+rumourer's
+rumourers
+rumouring
+rumours
+sabre
+sabre's
+sabred
+sabres
+sabring
+sanitise
+sanitised
+sanitiser
+sanitises
+sanitising
+saviour
+saviour's
+saviours
+savour
+savoured
+savourer
+savourer's
+savourers
+savourier
+savouries
+savouriest
+savouriness
+savouring
+savouringlies
+savouringly
+savours
+savoury
+savoury's
+sceptre
+sceptre's
+sceptred
+sceptres
+sceptring
+scrutinise
+scrutinised
+scrutiniser
+scrutinisers
+scrutinises
+scrutinising
+scrutinisinglies
+scrutinisingly
+sepulchre
+sepulchre's
+sepulchred
+sepulchres
+sequentialise
+sequentialised
+sequentialises
+sequentialising
+serialisation
+serialisation's
+serialisations
+serialise
+serialised
+serialises
+serialising
+shovelled
+shoveller
+shovellers
+shovelling
+shrivelled
+shrivelling
+signalled
+signaller
+signallers
+signalling
+socialise
+socialised
+socialiser
+socialises
+socialising
+specialisation
+specialisation's
+specialisations
+specialise
+specialised
+specialiser
+specialisers
+specialises
+specialising
+specialities
+speciality
+speciality's
+spectre
+spectre's
+spectred
+spectres
+spiralled
+spiralling
+splendour
+splendour's
+splendours
+squirrelled
+squirrelling
+stabilise
+stabilised
+stabiliser
+stabilisers
+stabilises
+stabilising
+standardisation
+standardisation's
+standardisations
+standardise
+standardised
+standardiser
+standardisers
+standardises
+standardising
+stencilled
+stenciller
+stencillers
+stencilling
+sterilisation
+sterilisation's
+sterilisations
+sterilise
+sterilised
+steriliser
+sterilisers
+sterilises
+sterilising
+stylised
+subsidise
+subsidised
+subsidiser
+subsidisers
+subsidises
+subsidising
+succour
+succoured
+succourer
+succourer's
+succourers
+succouring
+succours
+summarisation
+summarisation's
+summarisations
+summarise
+summarised
+summariser
+summarisers
+summarises
+summarising
+symbolisation
+symbolisation's
+symbolisations
+symbolise
+symbolised
+symboliser
+symbolisers
+symbolises
+symbolising
+symbolled
+symbolling
+sympathise
+sympathised
+sympathiser
+sympathisers
+sympathises
+sympathising
+sympathising's
+sympathisingly
+sympathisings
+synchronisation
+synchronisation's
+synchronisations
+synchronise
+synchronised
+synchroniser
+synchronisers
+synchronises
+synchronising
+synthesise
+synthesised
+synthesiser
+synthesisers
+synthesises
+synthesising
+syphon
+syphon's
+syphoned
+syphoning
+syphons
+systematise
+systematised
+systematiser
+systematisers
+systematises
+systematising
+tantalise
+tantalised
+tantaliser
+tantalisers
+tantalises
+tantalising
+tantalisinglies
+tantalisingly
+tantalisingness
+tantalisingnesses
+terrorise
+terrorised
+terroriser
+terrorisers
+terrorises
+terrorising
+theatre
+theatre's
+theatres
+theorisation
+theorisation's
+theorisations
+theorise
+theorised
+theoriser
+theorisers
+theorises
+theorising
+titre
+titres
+totalled
+totaller
+totaller's
+totallers
+totalling
+towelled
+towelling
+towellings
+tranquilise
+tranquilised
+tranquiliser
+tranquiliser's
+tranquilisers
+tranquilises
+tranquilising
+tranquilising's
+tranquilisingly
+tranquilisings
+transistorise
+transistorised
+transistorises
+transistorising
+travelled
+traveller
+traveller's
+travellers
+travelling
+travellings
+trivialise
+trivialised
+trivialises
+trivialising
+troweller
+trowellers
+tumour
+tumour's
+tumoured
+tumours
+tunnelled
+tunneller
+tunnellers
+tunnelling
+tunnellings
+tyre
+tyre's
+tyres
+unacclimatised
+unaesthetically
+unamortised
+unanalysable
+unanalysed
+unantagonised
+unantagonising
+unapologising
+unappetising
+unappetisingly
+unarmoured
+unauthorised
+unauthorisedly
+unauthorisedness
+unauthorises
+unbaptised
+unbaptises
+unbastardised
+unbrutalised
+unbrutalises
+uncancelled
+uncapitalised
+uncategorised
+uncharacterised
+uncivilised
+uncivilisedly
+uncivilisedness
+uncivilises
+uncolonised
+uncolonises
+uncoloured
+uncolouredly
+uncolouredness
+uncoloureds
+uncriticised
+uncriticising
+uncriticisingly
+uncrystallised
+undefences
+undishonoured
+undisorganised
+uneconomising
+unendeavoured
+unepitomised
+unequalised
+unequalises
+unequalled
+unfamiliarised
+unfavourable
+unfavourableness
+unfavourables
+unfavourably
+unfavoured
+unfavoured's
+unfavourings
+unfavourite
+unfavourite's
+unfavourites
+unfertilised
+unflavoured
+unformalised
+ungeneralised
+unharmonised
+unharmonises
+unhonourables
+unhonourablies
+unhonourably
+unhonoured
+unhumoured
+unidealised
+unindividualised
+unindividualises
+uninitialised
+unionisation
+unionise
+unionised
+unioniser
+unionisers
+unionises
+unionising
+unitalicised
+unitemised
+unjournalised
+unlabelled
+unlaboured
+unlaboured's
+unlabourings
+unlegalised
+unlevelled
+unlevelling
+unliberalised
+unlocalised
+unlocalises
+unmechanised
+unmechanises
+unmemorised
+unminimised
+unmodernised
+unmodernises
+unmotorised
+unnationalised
+unneighboured
+unneighbourliness
+unneighbourly
+unneutralised
+unnormalised
+unnormalises
+unoptimised
+unoptimises
+unorganisable
+unorganisables
+unorganised
+unoxidised
+unparallelled
+unparameterised
+unparametrised
+unparcelled
+unpatronised
+unpatronising's
+unpenalised
+unphilosophised
+unphilosophises
+unpopularises
+unpractised
+unpulverised
+unpulverises
+unravelled
+unravelling
+unrealisables
+unrealised
+unrealises
+unrecognisable
+unrecognised
+unrecognising
+unrecognisingly
+unreorganised
+unrivalled
+unrumoured
+unsabred
+unsavoured
+unsavouredly
+unsavouredness
+unsceptred
+unsceptres
+unscrutinised
+unscrutinising
+unscrutinisingly
+unsepulchred
+unsepulchres
+unsocialised
+unspecialised
+unspecialising
+unstandardised
+unsterilised
+unsubsidised
+unsuccoured
+unsummarised
+unsymbolised
+unsympathised
+unsympathising
+unsympathising's
+unsympathisingly
+unsympathisings
+unsynchronised
+unsynthesised
+unsyphons
+unsystematised
+unsystematisedly
+unsystematising
+untantalised
+unterrorised
+untranquilised
+unverbalised
+unvictimised
+unvisualised
+unwomanised
+unwomanises
+utilisation
+utilise
+utilised
+utiliser
+utilisers
+utilises
+utilising
+valour
+valour's
+valours
+vandalise
+vandalised
+vandalises
+vandalising
+vapour
+vapour's
+vapoured
+vapourer
+vapourers
+vapouring
+vapouringly
+vapourings
+vapours
+vectorisation
+vectorising
+verbalise
+verbalised
+verbaliser
+verbalisers
+verbalises
+verbalising
+victimise
+victimised
+victimiser
+victimisers
+victimises
+victimising
+victualler
+victuallers
+vigour
+vigour's
+vigours
+visualise
+visualised
+visualiser
+visualisers
+visualises
+visualising
+waggon
+waggon's
+waggoner
+waggoner's
+waggoners
+waggons
+wagonner
+wagonner's
+wagonners
+weaselled
+weaselling
+whisky
+whisky's
+whiskys
+womanise
+womanised
+womaniser
+womanisers
+womanises
+womanising
+woollen
+woollens
+worshipped
+worshipper
+worshipper's
+worshippers
+worshipping
+Christianising
+Europeanisation
+Europeanisation's
+Europeanisations
+Europeanised
+Sanskritise
+acclimatise
+acclimatiser
+acclimatisers
+acclimatises
+acclimatising
+actualise
+actualised
+actualises
+actualising
+aesthete
+aesthetes
+aggrandisement
+aggrandisement's
+aggrandisements
+americanised
+amortisation
+amortisation's
+amortisations
+animised
+annualised
+arsehole
+arsehole's
+arseholes
+balkanisation
+biosynthesised
+bureaucratisation
+bureaucratisation's
+bureaucratisations
+calliper
+callipers
+cancellate
+cancellated
+canonised
+cauterise
+cauterised
+cauterises
+cauterising
+caviller
+cavillers
+centreline
+centrelines
+civilisational
+civilisational's
+civilisationals
+cognisable
+colouration
+colourimeter
+colourimeter's
+colourimeters
+colourimetry
+commercialisation
+commercialisation's
+commercialisations
+communise
+communised
+communises
+communising
+computerisation
+conventionalised
+crystallisation
+crystallisation's
+crystallisations
+decentralising
+deemphasise
+deemphasised
+deemphasiser
+deemphasisers
+deemphasises
+deemphasising
+deglycerolised
+dehumanise
+dehumanised
+dehumanises
+dehumanising
+demineralisation
+demineralisation's
+demineralisations
+democratisation
+democratisation's
+democratisations
+democratise
+democratised
+democratiser
+democratises
+democratising
+demoralisation
+demoralisation's
+demoralisations
+demythologisation
+demythologise
+demythologised
+demythologiser
+demythologises
+demythologising
+depersonalisation
+depersonalisation's
+depersonalisations
+depersonalised
+deputised
+destabilise
+destabilised
+destabilises
+destabilising
+destigmatisation
+desynchronise
+desynchronised
+desynchronises
+desynchronising
+detribalise
+detribalised
+detribalises
+detribalising
+diagonalisable
+dialysed
+diarrhoea
+diarrhoea's
+diarrhoeal
+diarrhoeas
+dichotomisation
+digitalisation
+digitalisation's
+digitalisations
+digitisation
+dioptre
+discoloured
+discoloured's
+discolouredness
+discoloureds
+discolours
+disfavour
+disfavoured
+disfavourer
+disfavourer's
+disfavourers
+disfavouring
+disfavours
+dishevelled
+disorganisation
+disorganisation's
+disorganisations
+dowelling
+downdraught
+dramatisation
+dramatisation's
+dramatisations
+dramatise
+dramatised
+dramatiser
+dramatisers
+dramatises
+dramatising
+draughtier
+draughtiness
+draughtsperson
+draughty
+duellist
+duellists
+dynamised
+emphasise
+emphasised
+emphasiser
+emphasisers
+emphasises
+emphasising
+energised
+energises
+enthral
+enthrals
+epicentre
+epicentre's
+epicentres
+eulogise
+eulogised
+eulogiser
+eulogisers
+eulogises
+eulogising
+exorcise
+exorcised
+exorcises
+exorcising
+extemporise
+extemporised
+extemporiser
+extemporisers
+extemporises
+extemporising
+externalisation
+externalisation's
+externalisations
+favouritism
+favouritism's
+favouritisms
+federalise
+federalised
+federalises
+federalising
+fibreboard
+foetid
+foetidly
+foetidness
+foetus
+foetus's
+foetuses
+fossilised
+fraternise
+fraternised
+fraterniser
+fraternisers
+fraternises
+fraternising
+galvanising
+generalisable
+generalisables
+germanised
+gimballed
+glottalisation
+glycerolised
+gruelling
+gruellingly
+gruellings
+gynaecological
+gynaecological's
+gynaecologicals
+gynaecologist
+gynaecologist's
+gynaecologists
+harmonisation
+harmonisation's
+harmonisations
+homoeomorph
+homoeopath
+homogenisation
+homogenisation's
+homogenisations
+homogenise
+homogenised
+homogeniser
+homogenisers
+homogenises
+homogenising
+honouree
+hospitalisation
+hospitalisation's
+hospitalisations
+humanise
+humanised
+humaniser
+humanisers
+humanises
+humanising
+hydrolysed
+hypnotised
+hypophysectomised
+idolise
+idolised
+idoliser
+idolisers
+idolises
+idolising
+immobilise
+immobilised
+immobiliser
+immobilises
+immobilising
+immortalised
+immunisation
+immunisation's
+immunisations
+impersonalised
+industrialised
+industrialising
+inhumanises
+institutionalisation
+institutionalisation's
+institutionalisations
+internationalisation
+internationalisation's
+internationalisations
+internationalised
+ionise
+ionised
+ioniser
+ionisers
+ionises
+ionising
+ionisings
+ionision
+ionisions
+kinaesthesis
+kinaesthetic
+kinaesthetically
+kinaesthetics
+learnt
+legitimise
+legitimised
+legitimiser
+legitimises
+legitimising
+libeller
+libellers
+libellous
+libellously
+liberalisation
+liberalisation's
+liberalisations
+licenseable
+lionise
+lionised
+lioniser
+lionisers
+lionises
+lionising
+magnetised
+manoeuvrability
+manoeuvrable
+marbleised
+marbleising
+maximisation
+maximisation's
+maximisations
+mediaevalist
+mediaevalist's
+mediaevalists
+memorialised
+mesmerised
+metabolised
+metropolitanisation
+milligramme
+milligramme's
+milligrammes
+millilitre
+millilitre's
+millilitres
+mineralised
+misbehaviour
+misbehaviour's
+misbehaviours
+misdemeanour
+misdemeanour's
+misdemeanours
+mobilisation
+mobilisation's
+mobilisations
+mobilise
+mobilised
+mobiliser
+mobilises
+mobilising
+modernisation
+modernisation's
+modernisations
+monetisation
+monetise
+monetised
+monetises
+monetising
+monopolisation
+monopolisation's
+monopolisations
+monopolise
+monopolised
+monopoliser
+monopolisers
+monopolises
+monopolising
+multicolour
+multicolour's
+multicoloured
+multicolours
+narcotises
+nasalisation
+nasalisation's
+nasalisations
+nasalised
+naturalised
+neutralisation
+neutralisation's
+neutralisations
+nominalised
+novelised
+ochre
+ochre's
+ochres
+oedema
+oedema's
+oedemas
+oedematous
+operationalisation
+operationalisations
+operationalise
+operationalised
+orthogonalisation
+orthogonalised
+orthopaedic
+orthopaedics
+ostracised
+outmanoeuvre
+outmanoeuvred
+outmanoeuvres
+outmanoeuvring
+overemphasise
+overemphasised
+overemphasiser
+overemphasisers
+overemphasises
+overemphasising
+palatalisation
+palatalise
+palatalised
+palatalises
+palatalising
+palletised
+panelisation
+panelised
+parenthesise
+parenthesises
+parenthesising
+pasteurisation
+pasteurisations
+pedalled
+pedalling
+peptising
+platinise
+platinised
+platinises
+platinising
+ploughshare
+ploughshare's
+ploughshares
+polarise
+polarised
+polariser
+polarisers
+polarises
+polarising
+politicised
+polymerisations
+proletarianisation
+proletarianised
+pronominalisation
+pronominalise
+pummelled
+pyorrhoea
+pyorrhoea's
+pyorrhoeas
+pyrolyse
+pyrolyse's
+pyrolyser
+pyrolyses
+radiopasteurisation
+radiosterilisation
+radiosterilised
+rancour
+rancour's
+rancours
+randomisation
+randomisation's
+randomisations
+rationalisation
+rationalisation's
+rationalisations
+reacclimatises
+reactualises
+realisabilities
+realisability
+realisability's
+reconceptualisation
+recrystallisation
+recrystallisation's
+recrystallisations
+recrystallise
+recrystallising
+reemphasise
+reemphasised
+reemphasiser
+reemphasisers
+reemphasises
+reemphasising
+regularising
+reharmonisation
+rehumanises
+remobilisation
+remobilisation's
+remobilisations
+remobilises
+remonetisation
+remonetise
+remonetised
+remonetises
+remonetising
+repopularise
+revaporisation
+revaporisation's
+revaporisations
+revisualisation
+revisualisation's
+revisualisations
+revitalisation
+revitalise
+revitalised
+revitaliser
+revitalisers
+revitalises
+revitalising
+ritualised
+romanticise
+romanticises
+romanticising
+rubberised
+satirises
+scandalised
+scandalising
+sectionalised
+secularisation
+secularisation's
+secularisations
+secularised
+sensitised
+sentimentalise
+sentimentalised
+sentimentaliser
+sentimentalisers
+sentimentalises
+sentimentalising
+sexualised
+signalises
+snivelled
+sniveller
+snivellers
+snivelling
+snivellings
+socialisation
+socialisation's
+socialisations
+stabilisation
+stabilisation's
+stabilisations
+stigmatisation
+stigmatisation's
+stigmatisations
+stigmatised
+stylisation
+stylisation's
+stylisations
+subcategorising
+subsidisation
+subsidisation's
+subsidisations
+substerilisation
+suburbanisation
+suburbanisation's
+suburbanisations
+suburbanised
+suburbanising
+swivelled
+swivelling
+systematisation
+systematisation's
+systematisations
+systemisation
+systemisation's
+systemisations
+teaselled
+teaselling
+teetotaller
+temporise
+temporised
+temporiser
+temporiser's
+temporisers
+temporises
+temporising
+temporising's
+temporisingly
+temporisings
+theatregoer
+theatregoer's
+theatregoers
+theatregoing
+tinselled
+tinselling
+traditionalised
+travelogue
+travelogue's
+travelogues
+trialisation
+triangularisation
+triangularisations
+tricolour
+tricolour's
+tricoloured
+tricolours
+tyne
+tyne's
+tynes
+tyrannise
+tyrannised
+tyranniser
+tyrannisers
+tyrannises
+tyrannising
+tyrannising's
+tyrannisingly
+tyrannisings
+unamortisation
+unamortisation's
+unamortisations
+uncanonised
+uncauterised
+uncauterised's
+uncauteriseds
+undemocratises
+underutilisation
+underutilised
+undialysed
+undialysed's
+undialyseds
+undiscoloureds
+undramatised
+undramatised's
+undramatiseds
+unenergised
+unenergised's
+unenergiseds
+uneulogised
+uneulogised's
+uneulogiseds
+unfossilised
+unfossilised's
+unfossiliseds
+unfraternising
+unfraternising's
+unfraternisings
+unhydrolysed
+unhydrolysed's
+unhydrolyseds
+unidolised
+unidolised's
+unidoliseds
+unimmortalised
+unindustrialised
+unindustrialised's
+unindustrialiseds
+unitised
+universalise
+universalised
+universaliser
+universalisers
+universalises
+universalising
+unlearnt
+unmagnetised
+unmagnetised's
+unmagnetiseds
+unmemorialised
+unmemorialised's
+unmemorialiseds
+unmesmerised
+unmineralised
+unmineralised's
+unmineraliseds
+unmobilised
+unmobilised's
+unmobiliseds
+unmonopolised
+unmonopolises
+unnaturalised
+unpatronising
+unpolarised
+unpolarised's
+unpolariseds
+unsatirises
+unsavouries
+unsavouriness
+unsavoury
+unsavoury's
+unscandalised
+unsecularised
+unsensitised
+unsentimentalises
+unstigmatised
+unstigmatised's
+unstigmatiseds
+untemporisings
+untrammelled
+unvocalised
+unvocalised's
+unvocaliseds
+unvulcanised
+unvulcanised's
+unvulcaniseds
+updraught
+urbanisation
+urbanisation's
+urbanisations
+urbanised
+vacuolisation
+vacuolisation's
+vacuolisations
+vaporisation
+vaporisation's
+vaporisations
+varicoloured
+varicoloured's
+varicoloureds
+velarise
+velarised
+velarises
+velarising
+visualisation
+visualisation's
+visualisations
+vocalisation
+vocalisation's
+vocalisations
+vocalise
+vocalised
+vocaliser
+vocalisers
+vocalises
+vocalising
+volatilisation
+volatilisation's
+volatilisations
+vulcanised
+waggoneer
+watercolour
+watercolour's
+watercoloured
+watercolouring
+watercolourist
+watercolourists
+watercolours
+yodelled
+yodeller
+yodelling
+deprecation
+info
+sync
+synch
+java
+Java
+doc
+Doc
+Mon
+Tue
+Wed
+Thur
+Fri
+Sat
+Sun
+initially
+I
diff --git a/org.eclipse.cdt.ui/dictionaries/en_US.dictionary b/org.eclipse.cdt.ui/dictionaries/en_US.dictionary
new file mode 100644 (file)
index 0000000..b9f7e01
--- /dev/null
@@ -0,0 +1,49752 @@
+ACM
+ANSI
+ASAP
+ASCII
+ATM's
+Achilles
+Ada
+Ada's
+Afghanistan
+Afghanistan's
+Africa
+Africa's
+African
+African's
+Africans
+Airedale
+Airedale's
+Alabama
+Alabama's
+Alabamian
+Alabamian's
+Alaska
+Alaska's
+Albania
+Albania's
+Albanian
+Albanian's
+Albanians
+Alcibiades
+Alden
+Alden's
+Algeria
+Algeria's
+Algerian
+Algerian's
+Algol
+Algol's
+Allah
+Allah's
+Alyssa
+Alyssa's
+Amanda
+Amanda's
+Amdahl
+Amdahl's
+Amelia
+Amelia's
+America
+America's
+American
+American's
+Americana
+Americans
+Americas
+Ames
+Amsterdam
+Amsterdam's
+Amtrak
+Amtrak's
+Anabaptist
+Anabaptist's
+Anabaptists
+Andorra
+Andorra's
+Angeleno
+Angeleno's
+Angelenos
+Anglican
+Anglican's
+Anglicanism
+Anglicanism's
+Anglicans
+Anglophilia
+Anglophilia's
+Anglophobia
+Anglophobia's
+Angola
+Angola's
+Antarctica
+Antarctica's
+Aphrodite
+Aphrodite's
+Apollo
+Apollo's
+Apollonian
+Appalachia
+Appalachia's
+Appalachian
+Appalachian's
+Appalachians
+April
+April's
+Aprils
+Aquarius
+Arab
+Arab's
+Arabia
+Arabia's
+Arabian
+Arabian's
+Arabians
+Arabic
+Arabic's
+Arabs
+Archie
+Archie's
+Argentina
+Argentina's
+Argo
+Argo's
+Argos
+Arianism
+Arianism's
+Arianist
+Arianist's
+Arianists
+Aries
+Aristotelian
+Aristotelian's
+Aristotle
+Aristotle's
+Arizona
+Arizona's
+Arkansas
+Arkansas's
+Armageddon
+Armageddon's
+Armenian
+Armenian's
+Armour
+Armour's
+Armstrong
+Armstrong's
+Artemis
+Aryan
+Aryan's
+Aryans
+Asia
+Asia's
+Asian
+Asian's
+Asians
+Asiatic
+Asiatic's
+Asiatics
+Assyrian
+Assyrian's
+Assyriology
+Assyriology's
+Athena
+Athena's
+Athenian
+Athenian's
+Athenians
+Athens
+Atlantic
+Atlantic's
+Auckland
+Auckland's
+Audubon
+Audubon's
+Augusta
+Augusta's
+Augusts
+Austin
+Austin's
+Australia
+Australia's
+Australian
+Australian's
+Australians
+Austria
+Austria's
+Austrian
+Austrian's
+Ave
+BSD
+Babel
+Babel's
+Bach
+Bach's
+Bagrodia
+Bagrodia's
+Bagrodias
+Balkan
+Balkan's
+Balkans
+Baltic
+Baltic's
+Bangladesh
+Bangladesh's
+Bantu
+Bantu's
+Bantus
+Barbados
+Baxter
+Baxter's
+Beethoven
+Beethoven's
+Belgian
+Belgian's
+Belgians
+Belgium
+Belgium's
+Bellovin
+Bellovin's
+Belushi
+Belushi's
+Benedict
+Benedict's
+Benedictine
+Benedictine's
+Bengal
+Bengal's
+Bengali
+Bengali's
+Benzedrine
+Benzedrine's
+Bergsten
+Bergsten's
+Berkeley
+Berkeley's
+Berlin
+Berlin's
+Berliner
+Berliners
+Bermuda
+Bermuda's
+Bessel
+Bessel's
+Beverly
+Beverly's
+Bilbo
+Bilbo's
+Bolivia
+Bolivia's
+Bologna
+Bologna's
+Bolshevik
+Bolshevik's
+Bolsheviks
+Bolshevism
+Bolshevism's
+Borneo
+Borneo's
+Boston
+Boston's
+Bostonian
+Bostonian's
+Bostonians
+Botswana
+Botswana's
+Bourne
+Bourne's
+Brazil
+Brazil's
+Brazilian
+Brazilian's
+Bresenham
+Bresenham's
+Britain
+Britain's
+British
+Britisher
+Britishly
+Briton
+Briton's
+Britons
+Buehring
+Buehring's
+CDC
+CDC's
+CEO
+CMOS
+CPU
+CPU's
+CPUs
+California
+California's
+Californian
+Californian's
+Californians
+Cambridge
+Cambridge's
+Canada
+Canada's
+Carolina
+Carolina's
+Carolinas
+Cartesian
+Chinese
+Chinese's
+Christian
+Christian's
+Christians
+Christiansen
+Christmas
+Cobol
+Cobol's
+Coleman
+Coleman's
+Colorado
+Colorado's
+Comdex
+Comdex's
+Cray
+Cray's
+Crays
+Cupertino
+Cupertino's
+Czechoslovakian
+DARPA
+DARPA's
+DECNET
+DOS
+Dan
+Dan's
+DeMorgan
+DeMorgan's
+Debbie
+Debbie's
+December
+December's
+Decembers
+Delaware
+Delaware's
+Denmark
+Denmark's
+Dijkstra
+Dijkstra's
+Diophantine
+Dylan
+Dylan's
+EDP
+EGA
+EGA's
+Edsger
+Edsger's
+Ellen
+Ellen's
+Elvis
+Elvis's
+English
+English's
+Erlang
+Erlang's
+Ethernet
+Ethernet's
+Ethernets
+Europe
+Europe's
+European
+European's
+Europeans
+FIFO
+Fairbanks
+Februaries
+February
+February's
+Felder
+Florida
+Florida's
+Fortran
+Fortran's
+Fourier
+Fourier's
+France
+France's
+Frances
+French
+French's
+Friday
+Friday's
+Fridays
+GPSS
+Galvin
+Galvin's
+Garfunkel
+Geoff
+Geoff's
+Geoffrey
+Geoffrey's
+German
+German's
+Germans
+Germany
+Germany's
+Gibson
+Gibson's
+Gipsies
+Gipsy
+Gipsy's
+Godzilla
+Godzilla's
+Gothic
+Greek
+Greek's
+Greeks
+Greg
+Greg's
+Heinlein
+Heinlein's
+Hewlett
+Hewlett's
+Holland
+Holland's
+Hollander
+Hollanders
+Hollands
+Honda
+Honda's
+Hz
+I'd
+I'll
+I'm
+I've
+IBM
+IBM's
+IEEE
+ITCorp
+ITCorp's
+ITcorp
+ITcorp's
+Illinois
+Inc
+India
+India's
+Indian
+Indian's
+Indiana
+Indiana's
+Indians
+Intel
+Intel's
+Internet
+Internet's
+Iran
+Iran's
+Ireland
+Ireland's
+Israel
+Israel's
+Israeli
+Israeli's
+Israelis
+Italian
+Italian's
+Italians
+James
+Januaries
+January
+January's
+Japan
+Japan's
+Japanese
+Japanese's
+Jefferson
+Jefferson's
+Jill
+Jill's
+Johnnie
+Johnnie's
+Jr
+Julie
+Julie's
+Julies
+July
+July's
+Julys
+June
+June's
+Junes
+Klein
+Klein's
+Kleinrock
+Kleinrock's
+Kline
+Kline's
+Knuth
+Knuth's
+Kuenning
+Kuenning's
+LED's
+LEDs
+LaTeX
+LaTeX's
+Lagrangian
+Lagrangian's
+Lamport
+Lamport's
+Latin
+Latin's
+Laurie
+Laurie's
+Lenten
+Liz
+Liz's
+Lyle
+Lyle's
+MHz
+MIT
+MIT's
+MacDraw
+MacDraw's
+MacIntosh
+MacIntosh's
+MacPaint
+MacPaint's
+Mafia
+Mafia's
+Malibu
+Malibu's
+Mandelbrot
+Mandelbrot's
+Manhattan
+Manhattan's
+Manila
+Manila's
+Marianne
+Marianne's
+Mary
+Mary's
+Maryland
+Maryland's
+Marylanders
+Massachusetts
+Massey
+Massey's
+Matt
+Matt's
+Maxtor
+Maxtor's
+McElhaney
+McElhaney's
+McKenzie
+McKenzie's
+McMartin
+McMartin's
+Medusa
+Medusa's
+Michigan
+Michigan's
+Microport
+Microport's
+Microsoft
+Microsoft's
+Midwest
+Minnesota
+Minnesota's
+Monday
+Monday's
+Mondays
+Montana
+Montana's
+Montanan
+Montanan's
+Moslem
+Moslem's
+Moslems
+Motorola
+Motorola's
+Mr
+Mrs
+Ms
+Multibus
+Multibus's
+Multics
+Munsey
+Munsey's
+Muslim
+Muslim's
+Muslims
+NFS
+Nazi
+Nazi's
+Nazis
+NeWS
+Nebraska
+Nebraska's
+Nebraskan
+Nebraskan's
+Negro
+Negro's
+Negroes
+Nepal
+Nepal's
+Netherlands
+Newtonian
+November
+November's
+Novembers
+OEM
+OEM's
+OEMS
+OK
+OS
+OS's
+October
+October's
+Octobers
+Oderberg
+Oderberg's
+Oderbergs
+Oedipus
+Ohio
+Ohio's
+Oklahoma
+Oklahoma's
+Oklahoman
+Oklahoman's
+Oliver's
+PC
+PC's
+PCs
+PDP
+Packard
+Packard's
+Packards
+Palestinian
+Pascal
+Pascal's
+Pennsylvania
+Pennsylvania's
+Peter's
+Petkiewicz
+Petkiewicz's
+PhD
+Planck
+Planck's
+Poland
+Poland's
+Popek
+Popek's
+Popeks
+Prime's
+Prokofiev
+Prokofiev's
+QA
+RCS
+ROM
+RSX
+Redford
+Redford's
+Rick
+Rick's
+Ritchie
+Ritchie's
+Robert
+Robert's
+Roberts
+Robinson
+Robinson's
+Roman
+Roman's
+Romans
+Roy
+Roy's
+Rubens
+Russian
+Russian's
+Russians
+SCCS
+SMTP
+Sally's
+Salz
+Salz's
+Sam
+Sam's
+Saturday
+Saturday's
+Saturdays
+Scotland
+Scotland's
+Seagate
+Seagate's
+September
+September's
+Septembers
+Signor
+Sikkim
+Sikkim's
+Sikkimese
+Silverstein
+Silverstein's
+Singapore
+Singapore's
+Spafford
+Spafford's
+Spain
+Spain's
+Spanish
+Spanish's
+Spencer
+Spencer's
+Spuds
+Sr
+Sunday
+Sunday's
+Sundays
+TCP
+TV's
+TeX
+TeX's
+Teflon
+Teflon's
+Tektronix
+Tektronix's
+Tennessee
+Tennessee's
+Texas
+Texas's
+Texases
+Thursday
+Thursday's
+Thursdays
+Tinseltown
+Tinseltown's
+Trudeau
+Trudeau's
+Tuesday
+Tuesday's
+Tuesdays
+Turing
+Turing's
+UART
+UCLA
+UNIX's
+USC
+USC's
+USG
+USG's
+Ultrix
+Ultrix's
+Unix
+Unix's
+Usenet
+Usenet's
+Usenix
+Usenix's
+Utah
+Utah's
+VAR
+VCR
+VMS
+VMS's
+Vanessa
+Vanessa's
+Vax
+Vax's
+Ventura
+Ventura's
+Virginia
+Virginia's
+Warnock
+Warnock's
+Washington
+Washington's
+Wednesday
+Wednesday's
+Wednesdays
+Weibull
+Weibull's
+Wilbur
+Wilbur's
+Willisson
+Willisson's
+Wilson
+Wilson's
+Xenix
+Xenix's
+Xeroxed
+Xeroxes
+Xeroxing
+Yamaha
+Yamaha's
+Yentl
+Yentl's
+York
+York's
+Yorker
+Yorkers
+Yorks
+Zealand
+Zealand's
+Zulu
+Zulu's
+Zulus
+a
+aback
+abaft
+abandon
+abandoned
+abandoner
+abandoning
+abandonment
+abandonments
+abandons
+abase
+abased
+abasement
+abasements
+abaser
+abases
+abash
+abashed
+abashes
+abashing
+abasing
+abate
+abated
+abatement
+abatements
+abater
+abates
+abating
+abbe
+abbey
+abbey's
+abbeys
+abbot
+abbot's
+abbots
+abbreviate
+abbreviated
+abbreviates
+abbreviating
+abbreviation
+abbreviations
+abdomen
+abdomen's
+abdomens
+abdominal
+abdominally
+abduct
+abducted
+abducting
+abduction
+abduction's
+abductions
+abductor
+abductor's
+abductors
+abducts
+abed
+aberrant
+aberrantly
+aberration
+aberrations
+abet
+abets
+abetted
+abetter
+abetting
+abettor
+abeyance
+abhor
+abhorred
+abhorrent
+abhorrently
+abhorrer
+abhorring
+abhors
+abide
+abided
+abider
+abides
+abiding
+abidingly
+abilities
+ability
+ability's
+abject
+abjection
+abjections
+abjectly
+abjectness
+abjure
+abjured
+abjurer
+abjures
+abjuring
+ablate
+ablated
+ablates
+ablating
+ablation
+ablative
+ablatively
+ablaze
+able
+abler
+ablest
+ablution
+ablutions
+ably
+abnormal
+abnormalities
+abnormality
+abnormally
+aboard
+abode
+abode's
+abodes
+abolish
+abolished
+abolisher
+abolishers
+abolishes
+abolishing
+abolishment
+abolishment's
+abolishments
+abolition
+abolitionist
+abolitionists
+abominable
+aboriginal
+aboriginally
+aborigine
+aborigine's
+aborigines
+abort
+aborted
+aborter
+aborting
+abortion
+abortion's
+abortions
+abortive
+abortively
+abortiveness
+aborts
+abound
+abounded
+abounding
+abounds
+about
+above
+aboveground
+abrade
+abraded
+abrader
+abrades
+abrading
+abrasion
+abrasion's
+abrasions
+abreaction
+abreaction's
+abreactions
+abreast
+abridge
+abridged
+abridger
+abridges
+abridging
+abridgment
+abroad
+abrogate
+abrogated
+abrogates
+abrogating
+abrogation
+abrupt
+abruptly
+abruptness
+abscess
+abscessed
+abscesses
+abscissa
+abscissa's
+abscissas
+abscond
+absconded
+absconder
+absconding
+absconds
+absence
+absence's
+absences
+absent
+absented
+absentee
+absentee's
+absenteeism
+absentees
+absentia
+absenting
+absently
+absentminded
+absentmindedly
+absentmindedness
+absents
+absinthe
+absolute
+absolutely
+absoluteness
+absolutes
+absolution
+absolve
+absolved
+absolver
+absolves
+absolving
+absorb
+absorbed
+absorbency
+absorbent
+absorbent's
+absorbents
+absorber
+absorbing
+absorbingly
+absorbs
+absorption
+absorption's
+absorptions
+absorptive
+abstain
+abstained
+abstainer
+abstaining
+abstains
+abstention
+abstentions
+abstinence
+abstract
+abstracted
+abstractedly
+abstractedness
+abstracter
+abstracting
+abstraction
+abstraction's
+abstractionism
+abstractionist
+abstractionists
+abstractions
+abstractive
+abstractly
+abstractness
+abstractor
+abstractor's
+abstractors
+abstracts
+abstruse
+abstrusely
+abstruseness
+abstrusenesses
+absurd
+absurdities
+absurdity
+absurdity's
+absurdly
+absurdness
+abundance
+abundances
+abundant
+abundantly
+abuse
+abused
+abuser
+abusers
+abuses
+abusing
+abusive
+abusively
+abusiveness
+abut
+abutment
+abutments
+abuts
+abutted
+abutter
+abutter's
+abutters
+abutting
+abysmal
+abysmally
+abyss
+abyss's
+abysses
+acacia
+academia
+academic
+academically
+academics
+academies
+academy
+academy's
+accede
+acceded
+accedes
+acceding
+accelerate
+accelerated
+accelerates
+accelerating
+acceleratingly
+acceleration
+accelerations
+accelerative
+accelerator
+accelerators
+accelerometer
+accelerometer's
+accelerometers
+accent
+accented
+accenting
+accents
+accentual
+accentually
+accentuate
+accentuated
+accentuates
+accentuating
+accentuation
+accept
+acceptability
+acceptable
+acceptableness
+acceptably
+acceptance
+acceptance's
+acceptances
+accepted
+acceptedly
+accepter
+accepters
+accepting
+acceptingly
+acceptingness
+acceptive
+acceptor
+acceptor's
+acceptors
+accepts
+access
+accessed
+accesses
+accessibility
+accessible
+accessibly
+accessing
+accession
+accession's
+accessions
+accessories
+accessory
+accessory's
+accident
+accident's
+accidental
+accidentally
+accidentalness
+accidently
+accidents
+acclaim
+acclaimed
+acclaimer
+acclaiming
+acclaims
+acclamation
+acclimate
+acclimated
+acclimates
+acclimating
+acclimation
+accolade
+accolades
+accommodate
+accommodated
+accommodates
+accommodating
+accommodatingly
+accommodation
+accommodations
+accommodative
+accommodativeness
+accompanied
+accompanier
+accompanies
+accompaniment
+accompaniment's
+accompaniments
+accompanist
+accompanist's
+accompanists
+accompany
+accompanying
+accomplice
+accomplices
+accomplish
+accomplished
+accomplisher
+accomplishers
+accomplishes
+accomplishing
+accomplishment
+accomplishment's
+accomplishments
+accord
+accordance
+accordances
+accorded
+accorder
+accorders
+according
+accordingly
+accordion
+accordion's
+accordions
+accords
+accost
+accosted
+accosting
+accosts
+account
+accountabilities
+accountability
+accountable
+accountableness
+accountably
+accountancy
+accountant
+accountant's
+accountants
+accounted
+accounting
+accountings
+accounts
+accredit
+accreditation
+accreditations
+accredited
+accretion
+accretion's
+accretions
+accrue
+accrued
+accrues
+accruing
+acculturate
+acculturated
+acculturates
+acculturating
+acculturation
+acculturative
+accumulate
+accumulated
+accumulates
+accumulating
+accumulation
+accumulations
+accumulative
+accumulatively
+accumulativeness
+accumulator
+accumulator's
+accumulators
+accuracies
+accuracy
+accurate
+accurately
+accurateness
+accursed
+accursedly
+accursedness
+accusal
+accusation
+accusation's
+accusations
+accusative
+accuse
+accused
+accuser
+accusers
+accuses
+accusing
+accusingly
+accustom
+accustomed
+accustomedness
+accustoming
+accustoms
+ace
+ace's
+aced
+acer
+aces
+acetate
+acetone
+acetylene
+ache
+ached
+aches
+achievable
+achieve
+achieved
+achievement
+achievement's
+achievements
+achiever
+achievers
+achieves
+achieving
+aching
+achingly
+acid
+acidic
+acidities
+acidity
+acidly
+acidness
+acids
+acidulous
+acing
+acknowledge
+acknowledged
+acknowledgedly
+acknowledger
+acknowledgers
+acknowledges
+acknowledging
+acme
+acne
+acned
+acolyte
+acolytes
+acorn
+acorn's
+acorns
+acoustic
+acoustical
+acoustically
+acoustician
+acoustics
+acquaint
+acquaintance
+acquaintance's
+acquaintances
+acquainted
+acquainting
+acquaints
+acquiesce
+acquiesced
+acquiescence
+acquiesces
+acquiescing
+acquirable
+acquire
+acquired
+acquires
+acquiring
+acquisition
+acquisition's
+acquisitions
+acquisitiveness
+acquit
+acquits
+acquittal
+acquittals
+acquitted
+acquitter
+acquitting
+acre
+acre's
+acreage
+acres
+acrid
+acridly
+acridness
+acrimonious
+acrimoniously
+acrimony
+acrobat
+acrobat's
+acrobatic
+acrobatics
+acrobats
+acronym
+acronym's
+acronyms
+acropolis
+across
+acrylic
+act
+acted
+acting
+actinium
+actinometer
+actinometer's
+actinometers
+action
+action's
+actions
+activate
+activated
+activates
+activating
+activation
+activations
+activator
+activator's
+activators
+active
+actively
+activeness
+activism
+activist
+activist's
+activists
+activities
+activity
+activity's
+actor
+actor's
+actors
+actress
+actress's
+actresses
+acts
+actual
+actualities
+actuality
+actually
+actuals
+actuarial
+actuarially
+actuate
+actuated
+actuates
+actuating
+actuation
+actuator
+actuator's
+actuators
+acuity
+acumen
+acute
+acutely
+acuteness
+acuter
+acutest
+acyclic
+acyclically
+ad
+adage
+adages
+adagio
+adagios
+adamant
+adamantly
+adapt
+adaptability
+adaptable
+adaptation
+adaptation's
+adaptations
+adapted
+adaptedness
+adapter
+adapters
+adapting
+adaption
+adaptive
+adaptively
+adaptiveness
+adaptor
+adaptors
+adapts
+add
+added
+addenda
+addendum
+adder
+adders
+addict
+addicted
+addicting
+addiction
+addiction's
+addictions
+addictive
+addicts
+adding
+addition
+addition's
+additional
+additionally
+additions
+additive
+additive's
+additively
+additives
+additivity
+address
+addressability
+addressable
+addressed
+addressee
+addressee's
+addressees
+addresser
+addressers
+addresses
+addressing
+adds
+adduce
+adduced
+adducer
+adduces
+adducing
+adduct
+adducted
+adducting
+adduction
+adductive
+adductor
+adducts
+adept
+adeptly
+adeptness
+adepts
+adequacies
+adequacy
+adequate
+adequately
+adequateness
+adhere
+adhered
+adherence
+adherences
+adherent
+adherent's
+adherently
+adherents
+adherer
+adherers
+adheres
+adhering
+adhesion
+adhesions
+adhesive
+adhesive's
+adhesively
+adhesiveness
+adhesives
+adiabatic
+adiabatically
+adieu
+adjacency
+adjacent
+adjacently
+adjective
+adjective's
+adjectively
+adjectives
+adjoin
+adjoined
+adjoining
+adjoins
+adjourn
+adjourned
+adjourning
+adjournment
+adjourns
+adjudge
+adjudged
+adjudges
+adjudging
+adjudicate
+adjudicated
+adjudicates
+adjudicating
+adjudication
+adjudication's
+adjudications
+adjudicative
+adjunct
+adjunct's
+adjunctive
+adjunctly
+adjuncts
+adjure
+adjured
+adjures
+adjuring
+adjust
+adjustable
+adjustably
+adjusted
+adjuster
+adjusters
+adjusting
+adjustive
+adjustment
+adjustment's
+adjustments
+adjustor
+adjustor's
+adjustors
+adjusts
+adjutant
+adjutants
+administer
+administered
+administering
+administerings
+administers
+administration
+administration's
+administrations
+administrative
+administratively
+administrator
+administrator's
+administrators
+admirable
+admirableness
+admirably
+admiral
+admiral's
+admirals
+admiralty
+admiration
+admirations
+admire
+admired
+admirer
+admirers
+admires
+admiring
+admiringly
+admissibility
+admissible
+admission
+admission's
+admissions
+admit
+admits
+admittance
+admitted
+admittedly
+admitting
+admix
+admixed
+admixes
+admixture
+admonish
+admonished
+admonisher
+admonishes
+admonishing
+admonishingly
+admonishment
+admonishment's
+admonishments
+admonition
+admonition's
+admonitions
+ado
+adobe
+adolescence
+adolescent
+adolescent's
+adolescently
+adolescents
+adopt
+adopted
+adopter
+adopters
+adopting
+adoption
+adoption's
+adoptions
+adoptive
+adoptively
+adopts
+adorable
+adorableness
+adoration
+adore
+adored
+adorer
+adores
+adoring
+adorn
+adorned
+adorning
+adornment
+adornment's
+adornments
+adorns
+adrenal
+adrenaline
+adrenally
+adrift
+adroit
+adroitly
+adroitness
+ads
+adsorb
+adsorbed
+adsorbing
+adsorbs
+adsorption
+adulate
+adulating
+adulation
+adulations
+adult
+adult's
+adulterate
+adulterated
+adulterates
+adulterating
+adulteration
+adulterer
+adulterer's
+adulterers
+adulterous
+adulterously
+adultery
+adulthood
+adultly
+adultness
+adults
+adumbrate
+adumbrated
+adumbrates
+adumbrating
+adumbration
+adumbrative
+adumbratively
+advance
+advanced
+advancement
+advancement's
+advancements
+advancer
+advancers
+advances
+advancing
+advantage
+advantaged
+advantageous
+advantageously
+advantageousness
+advantages
+advantaging
+advent
+adventist
+adventists
+adventitious
+adventitiously
+adventitiousness
+adventive
+adventively
+adventure
+adventured
+adventurer
+adventurers
+adventures
+adventuring
+adventurous
+adventurously
+adventurousness
+adverb
+adverb's
+adverbial
+adverbially
+adverbs
+adversaries
+adversary
+adversary's
+adverse
+adversed
+adversely
+adverses
+adversing
+adversities
+adversity
+advertise
+advertised
+advertisement
+advertisement's
+advertisements
+advertiser
+advertisers
+advertises
+advertising
+advice
+advisability
+advisable
+advisableness
+advisably
+advise
+advised
+advisedly
+advisee
+advisee's
+advisees
+advisement
+advisements
+adviser
+adviser's
+advisers
+advises
+advising
+advisor
+advisor's
+advisors
+advisory
+advocacy
+advocate
+advocated
+advocates
+advocating
+advocation
+advocative
+aegis
+aerate
+aerated
+aerates
+aerating
+aeration
+aerator
+aerators
+aerial
+aerial's
+aerially
+aerials
+aeroacoustic
+aerobic
+aerobics
+aerodynamic
+aerodynamics
+aeronautic
+aeronautical
+aeronautically
+aeronautics
+aerosol
+aerosols
+aerospace
+afar
+afars
+affable
+affair
+affair's
+affairs
+affect
+affectation
+affectation's
+affectations
+affected
+affectedly
+affectedness
+affecter
+affecting
+affectingly
+affection
+affection's
+affectionate
+affectionately
+affectioned
+affections
+affective
+affectively
+affects
+afferent
+afferently
+affianced
+affidavit
+affidavit's
+affidavits
+affiliate
+affiliated
+affiliates
+affiliating
+affiliation
+affiliations
+affinities
+affinity
+affinity's
+affirm
+affirmation
+affirmation's
+affirmations
+affirmative
+affirmatively
+affirmed
+affirming
+affirms
+affix
+affixed
+affixes
+affixing
+afflict
+afflicted
+afflicting
+affliction
+affliction's
+afflictions
+afflictive
+afflictively
+afflicts
+affluence
+affluent
+affluently
+afford
+affordable
+afforded
+affording
+affords
+affricate
+affricates
+affrication
+affricative
+affright
+affront
+affronted
+affronting
+affronts
+afghan
+afghans
+aficionado
+aficionados
+afield
+afire
+aflame
+afloat
+afoot
+afore
+aforementioned
+aforesaid
+aforethought
+afoul
+afraid
+afresh
+aft
+after
+aftereffect
+aftereffects
+aftermath
+aftermost
+afternoon
+afternoon's
+afternoons
+afters
+aftershock
+aftershock's
+aftershocks
+afterthought
+afterthoughts
+afterward
+afterwards
+again
+against
+agape
+agar
+agate
+agates
+age
+aged
+agedly
+agedness
+ageless
+agelessly
+agelessness
+agencies
+agency
+agency's
+agenda
+agenda's
+agendas
+agent
+agent's
+agentive
+agents
+ager
+agers
+ages
+agglomerate
+agglomerated
+agglomerates
+agglomeration
+agglomerative
+agglutinate
+agglutinated
+agglutinates
+agglutinating
+agglutination
+agglutinative
+agglutinin
+agglutinins
+aggravate
+aggravated
+aggravates
+aggravating
+aggravation
+aggravations
+aggregate
+aggregated
+aggregately
+aggregateness
+aggregates
+aggregating
+aggregation
+aggregations
+aggregative
+aggregatively
+aggression
+aggression's
+aggressions
+aggressive
+aggressively
+aggressiveness
+aggressor
+aggressors
+aggrieve
+aggrieved
+aggrievedly
+aggrieves
+aggrieving
+aghast
+agile
+agilely
+agility
+aging
+agitate
+agitated
+agitatedly
+agitates
+agitating
+agitation
+agitations
+agitative
+agitator
+agitator's
+agitators
+agleam
+aglow
+agnostic
+agnostic's
+agnostics
+ago
+agog
+agonies
+agony
+agrarian
+agree
+agreeable
+agreeableness
+agreeably
+agreed
+agreeing
+agreement
+agreement's
+agreements
+agreer
+agreers
+agrees
+agricultural
+agriculturally
+agriculture
+ague
+ah
+ahead
+aid
+aide
+aided
+aider
+aides
+aiding
+aids
+ail
+ailed
+aileron
+ailerons
+ailing
+ailment
+ailment's
+ailments
+ails
+aim
+aimed
+aimer
+aimers
+aiming
+aimless
+aimlessly
+aimlessness
+aims
+air
+airbag
+airbag's
+airbags
+airborne
+aircraft
+aircrafts
+airdrop
+airdrops
+aired
+airer
+airers
+airfield
+airfield's
+airfields
+airflow
+airframe
+airframe's
+airframes
+airhead
+airier
+airiest
+airily
+airiness
+airing
+airings
+airless
+airlessness
+airlift
+airlift's
+airlifts
+airline
+airline's
+airliner
+airliner's
+airliners
+airlines
+airlock
+airlock's
+airlocks
+airmail
+airmails
+airman
+airmen
+airport
+airport's
+airports
+airs
+airship
+airship's
+airships
+airspace
+airspeed
+airspeeds
+airstrip
+airstrip's
+airstrips
+airway
+airway's
+airways
+airy
+aisle
+aisles
+ajar
+akimbo
+akin
+alabaster
+alacrity
+alarm
+alarmed
+alarming
+alarmingly
+alarmist
+alarms
+alas
+alba
+albacore
+albeit
+album
+albumen
+albumin
+albums
+alchemy
+alcohol
+alcohol's
+alcoholic
+alcoholic's
+alcoholics
+alcoholism
+alcoholisms
+alcohols
+alcove
+alcove's
+alcoved
+alcoves
+alder
+alderman
+alderman's
+aldermen
+ale
+alee
+alert
+alerted
+alertedly
+alerter
+alerters
+alerting
+alertly
+alertness
+alerts
+alfalfa
+alfresco
+alga
+algae
+algaecide
+algebra
+algebra's
+algebraic
+algebraically
+algebras
+alginate
+alginates
+algorithm
+algorithm's
+algorithmic
+algorithmically
+algorithms
+alias
+aliased
+aliases
+aliasing
+alibi
+alibi's
+alibis
+alien
+alien's
+alienate
+alienated
+alienates
+alienating
+alienation
+aliens
+alight
+alighted
+alighting
+align
+aligned
+aligner
+aligning
+alignment
+alignments
+aligns
+alike
+alikeness
+aliment
+aliments
+alimony
+alive
+aliveness
+alkali
+alkali's
+alkaline
+alkalis
+alkaloid
+alkaloid's
+alkaloids
+alkyl
+all
+allay
+allayed
+allaying
+allays
+allegation
+allegation's
+allegations
+allege
+alleged
+allegedly
+alleges
+allegiance
+allegiance's
+allegiances
+alleging
+allegoric
+allegorical
+allegorically
+allegoricalness
+allegories
+allegory
+allegory's
+allegretto
+allegretto's
+allegrettos
+allegro
+allegro's
+allegros
+allele
+alleles
+allemande
+allergic
+allergies
+allergy
+allergy's
+alleviate
+alleviated
+alleviates
+alleviating
+alleviation
+alleviative
+alleviator
+alleviator's
+alleviators
+alley
+alley's
+alleys
+alleyway
+alleyway's
+alleyways
+alliance
+alliance's
+alliances
+allied
+allier
+allies
+alligator
+alligator's
+alligatored
+alligators
+alliteration
+alliteration's
+alliterations
+alliterative
+alliteratively
+allocate
+allocated
+allocates
+allocating
+allocation
+allocation's
+allocations
+allocative
+allocator
+allocator's
+allocators
+allophone
+allophones
+allophonic
+allot
+alloted
+allotment
+allotment's
+allotments
+allots
+allotted
+allotter
+allotting
+allow
+allowable
+allowableness
+allowably
+allowance
+allowance's
+allowanced
+allowances
+allowancing
+allowed
+allowedly
+allowing
+allows
+alloy
+alloy's
+alloyed
+alloying
+alloys
+allude
+alluded
+alludes
+alluding
+allure
+allured
+allurement
+allures
+alluring
+allusion
+allusion's
+allusions
+allusive
+allusively
+allusiveness
+ally
+allying
+alma
+almanac
+almanac's
+almanacs
+almightiness
+almighty
+almond
+almond's
+almonds
+almoner
+almost
+alms
+almsman
+alnico
+aloe
+aloes
+aloft
+aloha
+alone
+aloneness
+along
+alongside
+aloof
+aloofly
+aloofness
+aloud
+alpha
+alphabet
+alphabet's
+alphabetic
+alphabetical
+alphabetically
+alphabetics
+alphabets
+alphanumeric
+alphanumerics
+alpine
+alps
+already
+also
+altar
+altar's
+altars
+alter
+alterable
+alteration
+alteration's
+alterations
+altercation
+altercation's
+altercations
+altered
+alterer
+alterers
+altering
+alternate
+alternated
+alternately
+alternates
+alternating
+alternation
+alternations
+alternative
+alternatively
+alternativeness
+alternatives
+alternator
+alternator's
+alternators
+alters
+although
+altitude
+altitudes
+alto
+alto's
+altogether
+altos
+altruism
+altruist
+altruistic
+altruistically
+altruists
+alum
+alumna
+alumna's
+alumnae
+alumni
+alumnus
+alundum
+alveolar
+alveolarly
+alveoli
+alveolus
+always
+am
+amain
+amalgam
+amalgam's
+amalgamate
+amalgamated
+amalgamates
+amalgamating
+amalgamation
+amalgamations
+amalgamative
+amalgams
+amanuensis
+amass
+amassed
+amasser
+amasses
+amassing
+amateur
+amateur's
+amateurish
+amateurishly
+amateurishness
+amateurism
+amateurs
+amatory
+amaze
+amazed
+amazedly
+amazement
+amazer
+amazers
+amazes
+amazing
+amazingly
+amazon
+amazon's
+amazons
+ambassador
+ambassador's
+ambassadors
+amber
+ambiance
+ambiances
+ambidextrous
+ambidextrously
+ambient
+ambiguities
+ambiguity
+ambiguity's
+ambiguous
+ambiguously
+ambiguousness
+ambition
+ambition's
+ambitions
+ambitious
+ambitiously
+ambitiousness
+ambivalence
+ambivalent
+ambivalently
+amble
+ambled
+ambler
+ambles
+ambling
+ambrosial
+ambrosially
+ambulance
+ambulance's
+ambulances
+ambulatory
+ambuscade
+ambuscader
+ambush
+ambushed
+ambusher
+ambushes
+ameliorate
+ameliorated
+ameliorating
+amelioration
+ameliorative
+amen
+amenable
+amend
+amended
+amender
+amending
+amendment
+amendment's
+amendments
+amends
+amenities
+amenity
+americium
+amiable
+amiableness
+amiabler
+amiablest
+amicable
+amicableness
+amicably
+amid
+amide
+amidst
+amigo
+amino
+amiss
+amity
+ammo
+ammonia
+ammoniac
+ammonias
+ammonium
+ammunition
+ammunitions
+amnesty
+amoeba
+amoeba's
+amoebas
+amok
+among
+amongst
+amoral
+amorality
+amorally
+amorous
+amorously
+amorousness
+amorphous
+amorphously
+amorphousness
+amount
+amounted
+amounter
+amounters
+amounting
+amounts
+amour
+amour's
+amours
+amp
+ampere
+amperes
+ampersand
+ampersand's
+ampersands
+amphetamine
+amphetamines
+amphibian
+amphibian's
+amphibians
+amphibious
+amphibiously
+amphibiousness
+amphibology
+ample
+ampleness
+ampler
+amplest
+amplification
+amplifications
+amplified
+amplifier
+amplifiers
+amplifies
+amplify
+amplifying
+amplitude
+amplitude's
+amplitudes
+amply
+ampoule
+ampoule's
+ampoules
+amps
+amputate
+amputated
+amputates
+amputating
+amputation
+ams
+amulet
+amulets
+amuse
+amused
+amusedly
+amusement
+amusement's
+amusements
+amuser
+amusers
+amuses
+amusing
+amusingly
+amusingness
+amusive
+amyl
+an
+anachronism
+anachronism's
+anachronisms
+anachronistically
+anaconda
+anacondas
+anaerobic
+anagram
+anagram's
+anagrams
+anal
+analogical
+analogically
+analogies
+analogous
+analogously
+analogousness
+analogy
+analogy's
+analysis
+analyst
+analyst's
+analysts
+analytic
+analytical
+analytically
+analyticities
+analyticity
+analytics
+anaphora
+anaphoric
+anaphorically
+anaplasmosis
+anarchic
+anarchical
+anarchist
+anarchist's
+anarchists
+anarchy
+anastomoses
+anastomosis
+anastomotic
+anathema
+anatomic
+anatomical
+anatomically
+anatomicals
+anatomy
+ancestor
+ancestor's
+ancestors
+ancestral
+ancestrally
+ancestry
+anchor
+anchorage
+anchorage's
+anchorages
+anchored
+anchoring
+anchorite
+anchoritism
+anchors
+anchovies
+anchovy
+ancient
+anciently
+ancientness
+ancients
+ancillaries
+ancillary
+and
+anded
+anders
+anding
+ands
+anecdotal
+anecdotally
+anecdote
+anecdote's
+anecdotes
+anechoic
+anemometer
+anemometer's
+anemometers
+anemometry
+anemone
+anew
+angel
+angel's
+angelic
+angels
+anger
+angered
+angering
+angers
+angiography
+angle
+angled
+angler
+anglers
+angles
+angling
+angrier
+angriest
+angrily
+angriness
+angry
+angst
+angstrom
+angstroms
+anguish
+anguished
+angular
+angularly
+anhydrous
+anhydrously
+aniline
+animal
+animal's
+animally
+animalness
+animals
+animate
+animated
+animatedly
+animately
+animateness
+animates
+animating
+animation
+animations
+animator
+animator's
+animators
+animism
+animosity
+anion
+anion's
+anionic
+anionics
+anions
+anise
+aniseikonic
+anisotropic
+anisotropies
+anisotropy
+anisotropy's
+ankle
+ankle's
+ankles
+annal
+annalen
+annals
+annex
+annexation
+annexations
+annexed
+annexes
+annexing
+annihilate
+annihilated
+annihilates
+annihilating
+annihilation
+annihilative
+anniversaries
+anniversary
+anniversary's
+annotate
+annotated
+annotates
+annotating
+annotation
+annotations
+annotative
+announce
+announced
+announcement
+announcement's
+announcements
+announcer
+announcers
+announces
+announcing
+annoy
+annoyance
+annoyance's
+annoyances
+annoyed
+annoyer
+annoyers
+annoying
+annoyingly
+annoys
+annual
+annually
+annuals
+annul
+annulled
+annulling
+annulment
+annulment's
+annulments
+annuls
+annum
+annunciate
+annunciated
+annunciates
+annunciating
+annunciation
+annunciator
+annunciators
+anode
+anode's
+anodes
+anoint
+anointed
+anointer
+anointing
+anoints
+anomalies
+anomalous
+anomalously
+anomalousness
+anomaly
+anomaly's
+anomic
+anomie
+anon
+anonymity
+anonymous
+anonymously
+anonymousness
+anorexia
+another
+another's
+answer
+answerable
+answered
+answerer
+answerers
+answering
+answers
+ant
+ant's
+antagonism
+antagonisms
+antagonist
+antagonist's
+antagonistic
+antagonistically
+antagonists
+antarctic
+ante
+anteater
+anteater's
+anteaters
+antecedent
+antecedent's
+antecedently
+antecedents
+anted
+antedate
+antedated
+antedates
+antedating
+antelope
+antelope's
+antelopes
+antenna
+antenna's
+antennae
+antennas
+anterior
+anteriorly
+anteriors
+anthem
+anthem's
+anthems
+anther
+anthologies
+anthology
+anthracite
+anthropological
+anthropologically
+anthropologist
+anthropologist's
+anthropologists
+anthropology
+anthropomorphic
+anthropomorphically
+anti
+antibacterial
+antibiotic
+antibiotics
+antibodies
+antibody
+antic
+antic's
+anticipate
+anticipated
+anticipates
+anticipating
+anticipation
+anticipations
+anticipative
+anticipatively
+anticipatory
+anticoagulation
+anticompetitive
+antics
+antidisestablishmentarianism
+antidote
+antidote's
+antidotes
+antiformant
+antifundamentalist
+antigen
+antigen's
+antigens
+antihistorical
+antimicrobial
+antimony
+anting
+antinomian
+antinomy
+antipathy
+antiphonal
+antiphonally
+antipode
+antipode's
+antipodes
+antiquarian
+antiquarian's
+antiquarians
+antiquate
+antiquated
+antiquation
+antique
+antique's
+antiques
+antiquities
+antiquity
+antiredeposition
+antiresonance
+antiresonator
+antiseptic
+antisera
+antiserum
+antislavery
+antisocial
+antisubmarine
+antisymmetric
+antisymmetry
+antithesis
+antithetical
+antithetically
+antithyroid
+antitoxin
+antitoxin's
+antitoxins
+antitrust
+antitruster
+antler
+antlered
+ants
+anus
+anvil
+anvil's
+anvils
+anxieties
+anxiety
+anxious
+anxiously
+anxiousness
+any
+anybodies
+anybody
+anyhow
+anymore
+anyone
+anyone's
+anyones
+anyplace
+anything
+anythings
+anyway
+anyways
+anywhere
+anywheres
+aorta
+apace
+apart
+apartheid
+apartment
+apartment's
+apartments
+apartness
+apathetic
+apathy
+ape
+aped
+aper
+aperiodic
+aperiodicity
+aperture
+apertured
+apes
+apex
+apexes
+aphasia
+aphasic
+aphid
+aphid's
+aphids
+aphonic
+aphorism
+aphorism's
+aphorisms
+apiaries
+apiary
+apical
+apically
+apiece
+aping
+apish
+apishly
+apishness
+aplenty
+aplomb
+apocalypse
+apocalyptic
+apocrypha
+apocryphal
+apocryphally
+apocryphalness
+apogee
+apogees
+apologetic
+apologetically
+apologetics
+apologia
+apologies
+apologist
+apologist's
+apologists
+apology
+apology's
+apostate
+apostates
+apostle
+apostle's
+apostles
+apostolic
+apostrophe
+apostrophes
+apothecary
+apotheoses
+apotheosis
+appalled
+appalling
+appallingly
+appanage
+apparatus
+apparatuses
+apparel
+apparels
+apparent
+apparently
+apparentness
+apparition
+apparition's
+apparitions
+appeal
+appealed
+appealer
+appealers
+appealing
+appealingly
+appeals
+appear
+appearance
+appearances
+appeared
+appearer
+appearers
+appearing
+appears
+appease
+appeased
+appeasement
+appeaser
+appeases
+appeasing
+appellant
+appellant's
+appellants
+appellate
+appellation
+appellative
+appellatively
+append
+appendage
+appendage's
+appendages
+appended
+appender
+appenders
+appendices
+appendicitis
+appending
+appendix
+appendix's
+appendixes
+appends
+appertain
+appertained
+appertaining
+appertains
+appetite
+appetite's
+appetites
+appetitive
+applaud
+applauded
+applauder
+applauding
+applauds
+applause
+apple
+apple's
+applejack
+apples
+appliance
+appliance's
+appliances
+applicability
+applicable
+applicant
+applicant's
+applicants
+application
+application's
+applications
+applicative
+applicatively
+applicator
+applicator's
+applicators
+applied
+applier
+appliers
+applies
+applique
+appliques
+apply
+applying
+appoint
+appointed
+appointee
+appointee's
+appointees
+appointer
+appointers
+appointing
+appointive
+appointment
+appointment's
+appointments
+appoints
+apportion
+apportioned
+apportioning
+apportionment
+apportionments
+apportions
+appraisal
+appraisal's
+appraisals
+appraise
+appraised
+appraiser
+appraisers
+appraises
+appraising
+appraisingly
+appreciable
+appreciably
+appreciate
+appreciated
+appreciates
+appreciating
+appreciation
+appreciations
+appreciative
+appreciatively
+appreciativeness
+apprehend
+apprehended
+apprehender
+apprehending
+apprehends
+apprehensible
+apprehension
+apprehension's
+apprehensions
+apprehensive
+apprehensively
+apprehensiveness
+apprentice
+apprenticed
+apprentices
+apprenticeship
+apprenticeships
+apprise
+apprised
+appriser
+apprisers
+apprises
+apprising
+apprisings
+apprize
+apprized
+apprizer
+apprizers
+apprizes
+apprizing
+apprizingly
+apprizings
+approach
+approachability
+approachable
+approached
+approacher
+approachers
+approaches
+approaching
+approbate
+approbation
+appropriate
+appropriated
+appropriately
+appropriateness
+appropriates
+appropriatest
+appropriating
+appropriation
+appropriations
+appropriative
+appropriator
+appropriator's
+appropriators
+approval
+approval's
+approvals
+approve
+approved
+approver
+approvers
+approves
+approving
+approvingly
+approximate
+approximated
+approximately
+approximates
+approximating
+approximation
+approximations
+approximative
+approximatively
+appurtenance
+appurtenances
+apricot
+apricot's
+apricots
+apron
+apron's
+aprons
+apropos
+apse
+apses
+apsis
+apt
+aptitude
+aptitudes
+aptly
+aptness
+aqua
+aquaria
+aquarium
+aquas
+aquatic
+aquatics
+aqueduct
+aqueduct's
+aqueducts
+aqueous
+aqueously
+aquifer
+aquifers
+arabesque
+arable
+arachnid
+arachnid's
+arachnids
+arbiter
+arbiter's
+arbiters
+arbitrarily
+arbitrariness
+arbitrary
+arbitrate
+arbitrated
+arbitrates
+arbitrating
+arbitration
+arbitrative
+arbitrator
+arbitrator's
+arbitrators
+arboreal
+arboreally
+arc
+arcade
+arcade's
+arcaded
+arcades
+arcading
+arcane
+arced
+arch
+archaeological
+archaeologically
+archaeologist
+archaeologist's
+archaeologists
+archaeology
+archaic
+archaically
+archaicness
+archaism
+archangel
+archangel's
+archangels
+archbishop
+archdiocese
+archdioceses
+arched
+archenemy
+archer
+archers
+archery
+arches
+archetype
+archetypes
+archfool
+arching
+archipelago
+archipelagoes
+architect
+architect's
+architectonic
+architectonics
+architects
+architectural
+architecturally
+architecture
+architecture's
+architectures
+archival
+archive
+archived
+archiver
+archivers
+archives
+archiving
+archivist
+archivists
+archly
+archness
+arcing
+arclike
+arcs
+arctic
+ardent
+ardently
+arduous
+arduously
+arduousness
+are
+area
+area's
+areas
+aren't
+arena
+arena's
+arenas
+ares
+argon
+argonaut
+argonauts
+argot
+arguable
+arguably
+argue
+argued
+arguer
+arguers
+argues
+arguing
+argument
+argument's
+argumentation
+argumentative
+argumentatively
+arguments
+arid
+aridity
+aridness
+aright
+arise
+arisen
+ariser
+arises
+arising
+arisings
+aristocracy
+aristocrat
+aristocrat's
+aristocratic
+aristocratically
+aristocrats
+arithmetic
+arithmetical
+arithmetically
+arithmetics
+ark
+arm
+arm's
+armadillo
+armadillos
+armament
+armament's
+armaments
+armchair
+armchair's
+armchairs
+armed
+armer
+armers
+armful
+armfuls
+armhole
+armies
+arming
+armistice
+armload
+armpit
+armpit's
+armpits
+arms
+army
+army's
+aroma
+aromas
+aromatic
+aromaticness
+arose
+around
+arousal
+arouse
+aroused
+arouses
+arousing
+arpeggio
+arpeggio's
+arpeggios
+arrack
+arraign
+arraigned
+arraigning
+arraignment
+arraignment's
+arraignments
+arraigns
+arrange
+arranged
+arrangement
+arrangement's
+arrangements
+arranger
+arrangers
+arranges
+arranging
+arrant
+arrantly
+array
+arrayed
+arrayer
+arraying
+arrays
+arrears
+arrest
+arrested
+arrester
+arresters
+arresting
+arrestingly
+arrestor
+arrestor's
+arrestors
+arrests
+arrival
+arrival's
+arrivals
+arrive
+arrived
+arriver
+arrives
+arriving
+arrogance
+arrogant
+arrogantly
+arrogate
+arrogated
+arrogates
+arrogating
+arrogation
+arrow
+arrowed
+arrowhead
+arrowhead's
+arrowheads
+arrowing
+arrows
+arroyo
+arroyos
+arsenal
+arsenal's
+arsenals
+arsenic
+arsine
+arsines
+arson
+art
+art's
+arterial
+arterially
+arteries
+arteriolar
+arteriole
+arteriole's
+arterioles
+arteriosclerosis
+artery
+artery's
+artful
+artfully
+artfulness
+arthritis
+arthrogram
+arthrogram's
+arthrograms
+arthropod
+arthropod's
+arthropods
+artichoke
+artichoke's
+artichokes
+article
+article's
+articled
+articles
+articling
+articulate
+articulated
+articulately
+articulateness
+articulates
+articulating
+articulation
+articulations
+articulative
+articulator
+articulators
+articulatory
+artifact
+artifact's
+artifacts
+artifice
+artificer
+artifices
+artificial
+artificialities
+artificiality
+artificially
+artificialness
+artilleries
+artillerist
+artillery
+artisan
+artisan's
+artisans
+artist
+artist's
+artistic
+artistically
+artistry
+artists
+artless
+artlessly
+arts
+artwork
+as
+asbestos
+ascend
+ascendancy
+ascendant
+ascendantly
+ascended
+ascendency
+ascendent
+ascender
+ascenders
+ascending
+ascends
+ascension
+ascensions
+ascent
+ascertain
+ascertainable
+ascertained
+ascertaining
+ascertains
+ascetic
+ascetic's
+asceticism
+ascetics
+ascot
+ascribable
+ascribe
+ascribed
+ascribes
+ascribing
+ascription
+aseptic
+ash
+ashamed
+ashamedly
+ashen
+asher
+ashes
+ashman
+ashore
+ashtray
+ashtray's
+ashtrays
+aside
+asides
+asinine
+asininely
+ask
+askance
+asked
+asker
+askers
+askew
+askewness
+asking
+asks
+asleep
+asocial
+asp
+asparagus
+aspect
+aspect's
+aspects
+aspen
+asper
+aspersion
+aspersion's
+aspersions
+asphalt
+asphalted
+asphyxia
+aspic
+aspirant
+aspirant's
+aspirants
+aspirate
+aspirated
+aspirates
+aspirating
+aspiration
+aspiration's
+aspirations
+aspirator
+aspirators
+aspire
+aspired
+aspirer
+aspires
+aspirin
+aspiring
+aspirins
+ass
+ass's
+assail
+assailant
+assailant's
+assailants
+assailed
+assailing
+assails
+assassin
+assassin's
+assassinate
+assassinated
+assassinates
+assassinating
+assassination
+assassinations
+assassins
+assault
+assaulted
+assaulter
+assaulting
+assaultive
+assaultively
+assaultiveness
+assaults
+assay
+assayed
+assayer
+assayers
+assaying
+assemblage
+assemblage's
+assemblages
+assemble
+assembled
+assembler
+assemblers
+assembles
+assemblies
+assembling
+assembly
+assembly's
+assen
+assent
+assented
+assenter
+assenting
+assents
+assert
+asserted
+asserter
+asserters
+asserting
+assertion
+assertion's
+assertions
+assertive
+assertively
+assertiveness
+asserts
+asses
+assess
+assessed
+assesses
+assessing
+assessment
+assessment's
+assessments
+assessor
+assessor's
+assessors
+asset
+asset's
+assets
+assiduity
+assiduous
+assiduously
+assiduousness
+assign
+assignable
+assigned
+assignee
+assignee's
+assignees
+assigner
+assigners
+assigning
+assignment
+assignment's
+assignments
+assigns
+assimilate
+assimilated
+assimilates
+assimilating
+assimilation
+assimilations
+assimilative
+assist
+assistance
+assistances
+assistant
+assistant's
+assistants
+assistantship
+assistantships
+assisted
+assister
+assisting
+assists
+associate
+associated
+associates
+associating
+association
+association's
+associational
+associations
+associative
+associatively
+associativities
+associativity
+associator
+associator's
+associators
+assonance
+assonant
+assort
+assorted
+assorter
+assorting
+assortment
+assortment's
+assortments
+assorts
+assuage
+assuaged
+assuages
+assuaging
+assume
+assumed
+assumer
+assumes
+assuming
+assumption
+assumption's
+assumptions
+assurance
+assurance's
+assurances
+assure
+assured
+assuredly
+assuredness
+assurer
+assurers
+assures
+assuring
+assuringly
+astatine
+aster
+aster's
+asterisk
+asterisk's
+asterisks
+asteroid
+asteroid's
+asteroidal
+asteroids
+asters
+asthma
+astonish
+astonished
+astonishes
+astonishing
+astonishingly
+astonishment
+astound
+astounded
+astounding
+astoundingly
+astounds
+astral
+astrally
+astray
+astride
+astringency
+astringent
+astringently
+astronaut
+astronaut's
+astronautics
+astronauts
+astronomer
+astronomer's
+astronomers
+astronomical
+astronomically
+astronomy
+astrophysical
+astrophysics
+astute
+astutely
+astuteness
+asunder
+asylum
+asylums
+asymmetric
+asymmetrical
+asymmetrically
+asymmetries
+asymmetry
+asymptomatically
+asymptote
+asymptote's
+asymptotes
+asymptotic
+asymptotically
+asymptoticly
+asynchronism
+asynchronous
+asynchronously
+asynchrony
+at
+atavistic
+ate
+atemporal
+atheism
+atheist
+atheist's
+atheistic
+atheists
+atherosclerosis
+athlete
+athlete's
+athletes
+athletic
+athleticism
+athletics
+atlas
+atmosphere
+atmosphere's
+atmosphered
+atmospheres
+atmospheric
+atmospherics
+atoll
+atoll's
+atolls
+atom
+atom's
+atomic
+atomically
+atomics
+atoms
+atonal
+atonally
+atone
+atoned
+atonement
+atones
+atoning
+atop
+atrocious
+atrociously
+atrociousness
+atrocities
+atrocity
+atrocity's
+atrophic
+atrophied
+atrophies
+atrophy
+atrophying
+attach
+attache
+attached
+attacher
+attachers
+attaches
+attaching
+attachment
+attachment's
+attachments
+attack
+attackable
+attacked
+attacker
+attacker's
+attackers
+attacking
+attacks
+attain
+attainable
+attainableness
+attainably
+attained
+attainer
+attainers
+attaining
+attainment
+attainment's
+attainments
+attains
+attempt
+attempted
+attempter
+attempters
+attempting
+attempts
+attend
+attendance
+attendance's
+attendances
+attendant
+attendant's
+attendants
+attended
+attendee
+attendee's
+attendees
+attender
+attenders
+attending
+attends
+attention
+attention's
+attentional
+attentionality
+attentions
+attentive
+attentively
+attentiveness
+attenuate
+attenuated
+attenuates
+attenuating
+attenuation
+attenuator
+attenuator's
+attenuators
+attest
+attested
+attester
+attesting
+attests
+attic
+attic's
+attics
+attire
+attired
+attires
+attiring
+attitude
+attitude's
+attitudes
+attitudinal
+attitudinally
+attorney
+attorney's
+attorneys
+attract
+attracted
+attracting
+attraction
+attraction's
+attractions
+attractive
+attractively
+attractiveness
+attractor
+attractor's
+attractors
+attracts
+attributable
+attribute
+attributed
+attributer
+attributes
+attributing
+attribution
+attributions
+attributive
+attributively
+attrition
+attune
+attuned
+attunes
+attuning
+atypical
+atypically
+auburn
+auction
+auctioned
+auctioneer
+auctioneer's
+auctioneers
+auctioning
+audacious
+audaciously
+audaciousness
+audacity
+audible
+audibly
+audience
+audience's
+audiences
+audio
+audiogram
+audiogram's
+audiograms
+audiological
+audiologist
+audiologist's
+audiologists
+audiology
+audiometer
+audiometer's
+audiometers
+audiometric
+audiometry
+audit
+audited
+auditing
+audition
+audition's
+auditioned
+auditioning
+auditions
+auditive
+auditor
+auditor's
+auditorium
+auditoriums
+auditors
+auditory
+audits
+auger
+auger's
+augers
+aught
+augment
+augmentation
+augmentations
+augmented
+augmenter
+augmenting
+augments
+augur
+augurs
+august
+augustly
+augustness
+aunt
+aunt's
+auntly
+aunts
+aura
+aura's
+aural
+aurally
+auras
+aureole
+aureomycin
+aurora
+auscultate
+auscultated
+auscultates
+auscultating
+auscultation
+auscultations
+auspice
+auspices
+auspicious
+auspiciously
+auspiciousness
+austere
+austerely
+austereness
+austerity
+authentic
+authentically
+authenticate
+authenticated
+authenticates
+authenticating
+authentication
+authentications
+authenticator
+authenticators
+authenticity
+author
+author's
+authored
+authoring
+authoritarian
+authoritarianism
+authoritative
+authoritatively
+authoritativeness
+authorities
+authority
+authority's
+authors
+authorship
+autism
+autistic
+auto
+auto's
+autobiographic
+autobiographical
+autobiographically
+autobiographies
+autobiography
+autobiography's
+autocollimator
+autocorrelate
+autocorrelated
+autocorrelates
+autocorrelating
+autocorrelation
+autocorrelations
+autocracies
+autocracy
+autocrat
+autocrat's
+autocratic
+autocratically
+autocrats
+autodial
+autofluorescence
+autograph
+autographed
+autographing
+autographs
+automata
+automate
+automated
+automates
+automatic
+automatically
+automatics
+automating
+automation
+automaton
+automatons
+automobile
+automobile's
+automobiles
+automotive
+autonavigator
+autonavigator's
+autonavigators
+autonomic
+autonomous
+autonomously
+autonomy
+autopilot
+autopilot's
+autopilots
+autopsied
+autopsies
+autopsy
+autoregressive
+autorepeat
+autorepeating
+autorepeats
+autos
+autosuggestibility
+autotransformer
+autumn
+autumn's
+autumnal
+autumnally
+autumns
+auxiliaries
+auxiliary
+avail
+availabilities
+availability
+available
+availableness
+availably
+availed
+availer
+availers
+availing
+avails
+avalanche
+avalanched
+avalanches
+avalanching
+avant
+avarice
+avaricious
+avariciously
+avariciousness
+avenge
+avenged
+avenger
+avenges
+avenging
+avenue
+avenue's
+avenues
+aver
+average
+averaged
+averagely
+averageness
+averages
+averaging
+averred
+averrer
+averring
+avers
+averse
+aversely
+averseness
+aversion
+aversion's
+aversions
+aversive
+avert
+averted
+averting
+averts
+avian
+aviaries
+aviary
+aviation
+aviator
+aviator's
+aviators
+avid
+avidity
+avidly
+avidness
+avionic
+avionics
+avocado
+avocados
+avocation
+avocation's
+avocations
+avoid
+avoidable
+avoidably
+avoidance
+avoided
+avoider
+avoiders
+avoiding
+avoids
+avouch
+avow
+avowed
+avowedly
+avower
+avows
+await
+awaited
+awaiting
+awaits
+awake
+awaked
+awaken
+awakened
+awakener
+awakening
+awakens
+awakes
+awaking
+award
+awarded
+awarder
+awarders
+awarding
+awards
+aware
+awareness
+awash
+away
+awayness
+awe
+awed
+awesome
+awesomely
+awesomeness
+awful
+awfully
+awfulness
+awhile
+awhiles
+awing
+awkward
+awkwardly
+awkwardness
+awl
+awl's
+awls
+awning
+awning's
+awninged
+awnings
+awoke
+awry
+ax
+axe
+axed
+axer
+axers
+axes
+axial
+axially
+axing
+axiological
+axiologically
+axiom
+axiom's
+axiomatic
+axiomatically
+axiomatics
+axioms
+axion
+axion's
+axions
+axis
+axle
+axle's
+axles
+axolotl
+axolotl's
+axolotls
+axon
+axon's
+axons
+aye
+ayer
+ayers
+ayes
+azalea
+azalea's
+azaleas
+azimuth
+azimuth's
+azimuths
+azure
+babble
+babbled
+babbler
+babbles
+babbling
+babe
+babe's
+babes
+babied
+babies
+baby
+baby's
+babyhood
+babying
+babyish
+babysit
+babysits
+babysitter
+babysitters
+baccalaureate
+bachelor
+bachelor's
+bachelors
+bacilli
+bacillus
+back
+backache
+backache's
+backaches
+backbone
+backbone's
+backbones
+backdrop
+backdrop's
+backdrops
+backed
+backer
+backers
+background
+background's
+backgrounds
+backing
+backlash
+backlasher
+backlog
+backlog's
+backlogs
+backpack
+backpack's
+backpacker
+backpackers
+backpacks
+backplane
+backplane's
+backplanes
+backs
+backscatter
+backscattered
+backscattering
+backscatters
+backslash
+backslashed
+backslashes
+backslashing
+backspace
+backspaced
+backspaces
+backspacing
+backstabber
+backstabbing
+backstage
+backstairs
+backstitch
+backstitched
+backstitches
+backstitching
+backtrack
+backtracked
+backtracker
+backtrackers
+backtracking
+backtracks
+backup
+backups
+backward
+backwardly
+backwardness
+backwards
+backwater
+backwater's
+backwaters
+backwoods
+backyard
+backyard's
+backyards
+bacon
+baconer
+bacteria
+bacterial
+bacterially
+bacterium
+bad
+bade
+baden
+badge
+badged
+badger
+badger's
+badgered
+badgering
+badgers
+badges
+badging
+badlands
+badly
+badminton
+badness
+bads
+baffle
+baffled
+baffler
+bafflers
+baffles
+baffling
+bafflingly
+bag
+bag's
+bagatelle
+bagatelle's
+bagatelles
+bagel
+bagel's
+bagels
+baggage
+bagged
+bagger
+bagger's
+baggers
+baggier
+baggies
+bagginess
+bagging
+baggy
+bagpipe
+bagpipe's
+bagpiper
+bagpipes
+bags
+bah
+bail
+bailer
+bailiff
+bailiff's
+bailiffs
+bailing
+bailly
+bait
+baited
+baiter
+baiting
+baits
+bake
+baked
+baker
+bakeries
+bakers
+bakery
+bakery's
+bakes
+baking
+bakings
+baklava
+balalaika
+balalaika's
+balalaikas
+balance
+balanced
+balancedness
+balancer
+balancers
+balances
+balancing
+balconied
+balconies
+balcony
+balcony's
+bald
+balder
+balding
+baldly
+baldness
+bale
+baled
+baleful
+balefully
+balefulness
+baler
+balers
+bales
+baling
+balk
+balked
+balker
+balkier
+balkiness
+balking
+balks
+balky
+ball
+ballad
+ballad's
+ballads
+ballast
+ballast's
+ballasts
+balled
+baller
+ballerina
+ballerina's
+ballerinas
+ballers
+ballet
+ballet's
+ballets
+balling
+ballistic
+ballistics
+balloon
+ballooned
+ballooner
+ballooners
+ballooning
+balloons
+ballot
+ballot's
+balloted
+balloter
+balloting
+ballots
+ballplayer
+ballplayer's
+ballplayers
+ballroom
+ballroom's
+ballrooms
+balls
+ballyhoo
+balm
+balm's
+balmier
+balminess
+balms
+balmy
+balsa
+balsam
+balsams
+balustrade
+balustrade's
+balustrades
+bamboo
+bamboos
+ban
+ban's
+banal
+banally
+banana
+banana's
+bananas
+band
+bandage
+bandaged
+bandager
+bandages
+bandaging
+banded
+bander
+bandied
+bandies
+banding
+bandit
+bandit's
+bandits
+bandpass
+bands
+bandstand
+bandstand's
+bandstands
+bandwagon
+bandwagon's
+bandwagons
+bandwidth
+bandwidths
+bandy
+bandying
+bane
+baneful
+banefully
+bang
+banged
+banger
+banging
+bangle
+bangle's
+bangles
+bangs
+baning
+banish
+banished
+banisher
+banishes
+banishing
+banishment
+banister
+banister's
+banisters
+banjo
+banjo's
+banjos
+bank
+banked
+banker
+bankers
+banking
+bankrupt
+bankruptcies
+bankruptcy
+bankruptcy's
+bankrupted
+bankrupting
+bankrupts
+banks
+banned
+banner
+banner's
+banners
+banning
+banquet
+banqueted
+banqueter
+banqueting
+banquetings
+banquets
+bans
+banshee
+banshee's
+banshees
+bantam
+banter
+bantered
+banterer
+bantering
+banteringly
+banters
+baptism
+baptism's
+baptismal
+baptismally
+baptisms
+baptist
+baptist's
+baptistery
+baptistries
+baptistry
+baptistry's
+baptists
+bar
+bar's
+barb
+barbarian
+barbarian's
+barbarians
+barbaric
+barbarities
+barbarity
+barbarous
+barbarously
+barbarousness
+barbecue
+barbecued
+barbecuer
+barbecues
+barbecuing
+barbed
+barbedness
+barbell
+barbell's
+barbells
+barber
+barbered
+barbering
+barbers
+barbital
+barbiturate
+barbiturates
+barbs
+bard
+bard's
+bards
+bare
+bared
+barefoot
+barefooted
+barely
+bareness
+barer
+bares
+barest
+barflies
+barfly
+barfly's
+bargain
+bargained
+bargainer
+bargaining
+bargains
+barge
+barged
+barges
+barging
+baring
+baritone
+baritone's
+baritones
+barium
+bark
+barked
+barker
+barkers
+barking
+barks
+barley
+barn
+barn's
+barns
+barnstorm
+barnstormed
+barnstormer
+barnstorming
+barnstorms
+barnyard
+barnyard's
+barnyards
+barometer
+barometer's
+barometers
+barometric
+baron
+baron's
+baroness
+baronial
+baronies
+barons
+barony
+barony's
+baroque
+baroquely
+baroqueness
+barrack
+barracker
+barracks
+barracuda
+barracuda's
+barracudas
+barrage
+barrage's
+barraged
+barrages
+barraging
+barred
+barrel
+barrel's
+barrels
+barren
+barrenness
+barrens
+barricade
+barricade's
+barricades
+barrier
+barrier's
+barriers
+barring
+barringer
+barrow
+barrows
+bars
+bartender
+bartender's
+bartenders
+barter
+bartered
+barterer
+bartering
+barters
+bas
+basal
+basally
+basalt
+base
+baseball
+baseball's
+baseballs
+baseboard
+baseboard's
+baseboards
+based
+baseless
+baseline
+baseline's
+baselines
+basely
+baseman
+basement
+basement's
+basements
+baseness
+baser
+bases
+basest
+bash
+bashed
+basher
+bashes
+bashful
+bashfully
+bashfulness
+bashing
+basic
+basically
+basics
+basil
+basin
+basin's
+basined
+basing
+basins
+basis
+bask
+basked
+basket
+basket's
+basketball
+basketball's
+basketballs
+baskets
+basking
+bass
+bass's
+basses
+basset
+bassinet
+bassinet's
+bassinets
+basso
+bastard
+bastard's
+bastardly
+bastards
+baste
+basted
+baster
+bastes
+basting
+bastion
+bastion's
+bastioned
+bastions
+bat
+bat's
+batch
+batched
+batcher
+batches
+batching
+bated
+bater
+bath
+bathe
+bathed
+bather
+bathers
+bathes
+bathing
+bathos
+bathrobe
+bathrobe's
+bathrobes
+bathroom
+bathroom's
+bathroomed
+bathrooms
+baths
+bathtub
+bathtub's
+bathtubs
+bating
+baton
+baton's
+batons
+bats
+battalion
+battalion's
+battalions
+batted
+batten
+battened
+battening
+battens
+batter
+battered
+batteries
+battering
+batters
+battery
+battery's
+batting
+battle
+battled
+battlefield
+battlefield's
+battlefields
+battlefront
+battlefront's
+battlefronts
+battleground
+battleground's
+battlegrounds
+battlement
+battlement's
+battlemented
+battlements
+battler
+battlers
+battles
+battleship
+battleship's
+battleships
+battling
+bauble
+bauble's
+baubles
+baud
+bauds
+bauxite
+bawdier
+bawdiness
+bawdy
+bawl
+bawled
+bawler
+bawling
+bawls
+bay
+bayed
+baying
+bayly
+bayonet
+bayonet's
+bayoneted
+bayoneting
+bayonets
+bayou
+bayou's
+bayous
+bays
+bazaar
+bazaar's
+bazaars
+be
+beach
+beached
+beaches
+beachhead
+beachhead's
+beachheads
+beaching
+beacon
+beacon's
+beaconed
+beaconing
+beacons
+bead
+beaded
+beading
+beadle
+beadle's
+beadles
+beads
+beady
+beagle
+beagle's
+beagles
+beak
+beaked
+beaker
+beakers
+beaks
+beam
+beamed
+beamer
+beamers
+beaming
+beams
+bean
+beanbag
+beanbag's
+beanbags
+beaned
+beaner
+beaners
+beaning
+beans
+bear
+bearable
+bearably
+beard
+bearded
+beardedness
+beardless
+beards
+bearer
+bearers
+bearing
+bearings
+bearish
+bearishly
+bearishness
+bears
+beast
+beastings
+beastlier
+beastliness
+beastly
+beasts
+beat
+beatable
+beatably
+beaten
+beater
+beaters
+beatific
+beatification
+beatify
+beating
+beatings
+beatitude
+beatitude's
+beatitudes
+beatnik
+beatnik's
+beatniks
+beats
+beau
+beau's
+beaus
+beauteous
+beauteously
+beauteousness
+beauties
+beautification
+beautifications
+beautified
+beautifier
+beautifiers
+beautifies
+beautiful
+beautifully
+beautifulness
+beautify
+beautifying
+beauty
+beauty's
+beaver
+beaver's
+beavers
+becalm
+becalmed
+becalming
+becalms
+became
+because
+beck
+beckon
+beckoned
+beckoning
+beckons
+become
+becomes
+becoming
+becomingly
+bed
+bed's
+bedazzle
+bedazzled
+bedazzlement
+bedazzles
+bedazzling
+bedbug
+bedbug's
+bedbugs
+bedded
+bedder
+bedder's
+bedders
+bedding
+bedevil
+bedevils
+bedfast
+bedlam
+bedpost
+bedpost's
+bedposts
+bedraggle
+bedraggled
+bedridden
+bedrock
+bedrock's
+bedroom
+bedroom's
+bedroomed
+bedrooms
+beds
+bedside
+bedspread
+bedspread's
+bedspreads
+bedspring
+bedspring's
+bedsprings
+bedstead
+bedstead's
+bedsteads
+bedtime
+bee
+beech
+beechen
+beecher
+beef
+beefed
+beefer
+beefers
+beefier
+beefing
+beefs
+beefsteak
+beefy
+beehive
+beehive's
+beehives
+been
+beens
+beep
+beeped
+beeper
+beeping
+beeps
+beer
+beers
+bees
+beet
+beet's
+beetle
+beetle's
+beetled
+beetles
+beetling
+beets
+befall
+befallen
+befalling
+befalls
+befell
+befit
+befit's
+befits
+befitted
+befitting
+befittingly
+befog
+befogged
+befogging
+befogs
+before
+beforehand
+befoul
+befouled
+befouling
+befouls
+befriend
+befriended
+befriending
+befriends
+befuddle
+befuddled
+befuddles
+befuddling
+beg
+began
+beget
+begets
+begetting
+beggar
+beggared
+beggaring
+beggarliness
+beggarly
+beggars
+beggary
+begged
+begging
+begin
+beginner
+beginner's
+beginners
+beginning
+beginning's
+beginnings
+begins
+begot
+begotten
+begrudge
+begrudged
+begrudger
+begrudges
+begrudging
+begrudgingly
+begs
+beguile
+beguiled
+beguiler
+beguiles
+beguiling
+beguilingly
+begun
+behalf
+behave
+behaved
+behaver
+behaves
+behaving
+behead
+beheading
+beheld
+behest
+behind
+behold
+beholden
+beholder
+beholders
+beholding
+beholds
+beige
+being
+beings
+belated
+belatedly
+belatedness
+belay
+belayed
+belaying
+belays
+belch
+belched
+belches
+belching
+belfries
+belfry
+belfry's
+belie
+belied
+belief
+belief's
+beliefs
+belier
+belies
+believability
+believable
+believably
+believe
+believed
+believer
+believers
+believes
+believing
+belittle
+belittled
+belittler
+belittles
+belittling
+bell
+bell's
+bellboy
+bellboy's
+bellboys
+belle
+belle's
+belles
+bellhop
+bellhop's
+bellhops
+bellicose
+bellicosely
+bellicoseness
+bellicosity
+bellied
+bellies
+belligerence
+belligerent
+belligerent's
+belligerently
+belligerents
+bellman
+bellmen
+bellow
+bellowed
+bellowing
+bellows
+bells
+bellwether
+bellwether's
+bellwethers
+belly
+belly's
+bellyful
+bellying
+belong
+belonged
+belonging
+belongingness
+belongings
+belongs
+beloved
+below
+belt
+belted
+belting
+belts
+bely
+belying
+bemoan
+bemoaned
+bemoaning
+bemoans
+bench
+benched
+bencher
+benches
+benching
+benchmark
+benchmark's
+benchmarking
+benchmarks
+bend
+bendable
+bended
+bender
+benders
+bending
+bends
+beneath
+benediction
+benediction's
+benedictions
+benefactor
+benefactor's
+benefactors
+beneficence
+beneficences
+beneficial
+beneficially
+beneficialness
+beneficiaries
+beneficiary
+benefit
+benefited
+benefiter
+benefiters
+benefiting
+benefits
+benevolence
+benevolent
+benevolently
+benevolentness
+benighted
+benightedly
+benightedness
+benign
+benignly
+bent
+bents
+benzene
+bequeath
+bequeathed
+bequeathes
+bequeathing
+bequest
+bequest's
+bequests
+berate
+berated
+berates
+berating
+bereave
+bereaved
+bereavement
+bereavements
+bereaves
+bereaving
+bereft
+beret
+beret's
+berets
+beribboned
+beriberi
+berkelium
+berried
+berries
+berry
+berry's
+berrying
+berth
+berthed
+berthing
+berthings
+berths
+beryl
+beryllium
+bes
+beseech
+beseeches
+beseeching
+beseechingly
+beset
+besets
+besetting
+beside
+besides
+besiege
+besieged
+besieger
+besiegers
+besieging
+besmirch
+besmirched
+besmirches
+besmirching
+besotted
+besotting
+besought
+bespeak
+bespeaks
+bespectacled
+best
+bested
+bester
+bestial
+bestially
+besting
+bestow
+bestowal
+bestowed
+bests
+bestseller
+bestseller's
+bestsellers
+bestselling
+bet
+bet's
+beta
+betas
+beth
+betide
+betray
+betrayal
+betrayed
+betrayer
+betraying
+betrays
+betroth
+betrothal
+betrothals
+betrothed
+bets
+better
+bettered
+bettering
+betterment
+betterments
+betters
+betting
+between
+betweenness
+betwixt
+bevel
+bevels
+beverage
+beverage's
+beverages
+bevies
+bevy
+bewail
+bewailed
+bewailing
+bewails
+beware
+bewhiskered
+bewilder
+bewildered
+bewilderedly
+bewilderedness
+bewildering
+bewilderingly
+bewilderment
+bewilders
+bewitch
+bewitched
+bewitches
+bewitching
+bewitchingly
+beyond
+biannual
+bias
+biased
+biases
+biasing
+biasness
+bib
+bib's
+bibbed
+bibbing
+bible
+bible's
+bibles
+biblical
+biblically
+bibliographic
+bibliographical
+bibliographically
+bibliographics
+bibliographies
+bibliography
+bibliography's
+bibliophile
+bibliophiles
+bibs
+bicameral
+bicarbonate
+bicentennial
+biceps
+bicker
+bickered
+bickerer
+bickering
+bickers
+biconcave
+biconvex
+bicycle
+bicycled
+bicycler
+bicyclers
+bicycles
+bicycling
+bid
+bid's
+biddable
+bidden
+bidder
+bidder's
+bidders
+biddies
+bidding
+biddy
+bide
+bided
+bider
+bides
+biding
+bidirectional
+bids
+biennial
+biennially
+biennium
+bier
+bifocal
+bifocals
+bifurcate
+bifurcated
+bifurcately
+bifurcates
+bifurcating
+bifurcation
+bifurcations
+big
+bigger
+biggest
+bight
+bight's
+bights
+bigly
+bigness
+bigot
+bigot's
+bigoted
+bigotedly
+bigoting
+bigotry
+bigots
+bijection
+bijection's
+bijections
+bijective
+bijectively
+bike
+bike's
+biked
+biker
+biker's
+bikers
+bikes
+biking
+bikini
+bikini's
+bikinied
+bikinis
+bilabial
+bilateral
+bilaterally
+bilateralness
+bile
+bilge
+bilge's
+bilged
+bilges
+bilging
+bilinear
+bilingual
+bilingually
+bilinguals
+bilk
+bilked
+bilker
+bilking
+bilks
+bill
+billboard
+billboard's
+billboards
+billed
+biller
+billers
+billet
+billeted
+billeting
+billets
+billiard
+billiards
+billing
+billings
+billion
+billions
+billionth
+billow
+billowed
+billowing
+billows
+bills
+bimodal
+bimolecular
+bimolecularly
+bimonthlies
+bimonthly
+bin
+bin's
+binaries
+binary
+binaural
+binaurally
+bind
+binded
+binder
+binders
+binding
+bindingly
+bindingness
+bindings
+binds
+bing
+binge
+bingen
+binges
+bingo
+bingos
+binocular
+binocularly
+binoculars
+binomial
+binomially
+bins
+binuclear
+biochemical
+biochemically
+biochemistry
+biofeedback
+biographer
+biographer's
+biographers
+biographic
+biographical
+biographically
+biographies
+biography
+biography's
+biological
+biologically
+biologicals
+biologist
+biologist's
+biologists
+biology
+biomedical
+biomedicine
+biopsies
+biopsy
+bipartisan
+bipartite
+bipartitely
+bipartition
+biped
+bipeds
+biplane
+biplane's
+biplanes
+bipolar
+biracial
+birch
+birchen
+bircher
+birches
+bird
+bird's
+birdbath
+birdbath's
+birdbaths
+birder
+birdie
+birdied
+birdies
+birdlike
+birds
+birefringence
+birefringent
+birth
+birthday
+birthday's
+birthdays
+birthed
+birthplace
+birthplaces
+birthright
+birthright's
+birthrights
+births
+biscuit
+biscuit's
+biscuits
+bisect
+bisected
+bisecting
+bisection
+bisection's
+bisections
+bisector
+bisector's
+bisectors
+bisects
+bishop
+bishop's
+bishops
+bismuth
+bison
+bison's
+bisons
+bisque
+bisques
+bit
+bit's
+bitblt
+bitblts
+bitch
+bitch's
+bitches
+bite
+biter
+biters
+bites
+biting
+bitingly
+bitmap
+bitmap's
+bitmaps
+bits
+bitser
+bitten
+bitter
+bitterer
+bitterest
+bitterly
+bitterness
+bitters
+bittersweet
+bittersweetly
+bittersweetness
+bituminous
+bitwise
+bivalve
+bivalve's
+bivalved
+bivalves
+bivariate
+bivouac
+bivouacs
+biweekly
+bizarre
+bizarrely
+bizarreness
+blab
+blabbed
+blabbermouth
+blabbermouths
+blabbing
+blabs
+black
+blackberries
+blackberry
+blackberry's
+blackbird
+blackbird's
+blackbirder
+blackbirds
+blackboard
+blackboard's
+blackboards
+blacked
+blacken
+blackened
+blackener
+blackening
+blackens
+blacker
+blackest
+blacking
+blackjack
+blackjack's
+blackjacks
+blacklist
+blacklisted
+blacklister
+blacklisting
+blacklists
+blackly
+blackmail
+blackmailed
+blackmailer
+blackmailers
+blackmailing
+blackmails
+blackness
+blackout
+blackout's
+blackouts
+blacks
+blacksmith
+blacksmith's
+blacksmithing
+blacksmiths
+bladder
+bladder's
+bladders
+blade
+blade's
+bladed
+blades
+blamable
+blame
+blamed
+blameless
+blamelessly
+blamelessness
+blamer
+blamers
+blames
+blaming
+blanch
+blanched
+blancher
+blanches
+blanching
+bland
+blandly
+blandness
+blank
+blanked
+blanker
+blankest
+blanket
+blanketed
+blanketer
+blanketers
+blanketing
+blankets
+blanking
+blankly
+blankness
+blanks
+blare
+blared
+blares
+blaring
+blase
+blaspheme
+blasphemed
+blasphemer
+blasphemes
+blasphemies
+blaspheming
+blasphemous
+blasphemously
+blasphemousness
+blasphemy
+blast
+blasted
+blaster
+blasters
+blasting
+blasts
+blatant
+blatantly
+blatantness
+blaze
+blazed
+blazer
+blazers
+blazes
+blazing
+blazingly
+bleach
+bleached
+bleacher
+bleachers
+bleaches
+bleaching
+bleak
+bleakly
+bleakness
+blear
+bleariness
+bleary
+bleat
+bleater
+bleating
+bleats
+bled
+bleed
+bleeder
+bleeders
+bleeding
+bleedings
+bleeds
+blemish
+blemish's
+blemished
+blemishes
+blemishing
+blend
+blended
+blender
+blenders
+blending
+blends
+bless
+blessed
+blessedly
+blessedness
+blesses
+blessing
+blessings
+blew
+blight
+blighted
+blighter
+blimp
+blimp's
+blimps
+blind
+blinded
+blinder
+blinders
+blindfold
+blindfolded
+blindfolding
+blindfolds
+blinding
+blindingly
+blindly
+blindness
+blinds
+blink
+blinked
+blinker
+blinkered
+blinkering
+blinkers
+blinking
+blinks
+blip
+blip's
+blips
+bliss
+blissful
+blissfully
+blissfulness
+blister
+blistered
+blistering
+blisteringly
+blisters
+blithe
+blithely
+blither
+blithest
+blitz
+blitz's
+blitzes
+blitzkrieg
+blizzard
+blizzard's
+blizzards
+bloat
+bloated
+bloater
+bloaters
+bloating
+bloats
+blob
+blob's
+blobs
+bloc
+bloc's
+block
+block's
+blockade
+blockaded
+blockader
+blockades
+blockading
+blockage
+blockage's
+blockages
+blocked
+blocker
+blockers
+blockhouse
+blockhouses
+blocking
+blocks
+blocs
+bloke
+bloke's
+blokes
+blond
+blond's
+blonde
+blonde's
+blondes
+blonds
+blood
+blooded
+bloodhound
+bloodhound's
+bloodhounds
+bloodied
+bloodiest
+bloodiness
+bloodless
+bloodlessly
+bloodlessness
+bloods
+bloodshed
+bloodshot
+bloodstain
+bloodstain's
+bloodstained
+bloodstains
+bloodstream
+bloody
+bloodying
+bloom
+bloomed
+bloomer
+bloomers
+blooming
+blooms
+blossom
+blossomed
+blossoms
+blot
+blot's
+blots
+blotted
+blotting
+blouse
+blouse's
+blouses
+blousing
+blow
+blowed
+blower
+blowers
+blowfish
+blowing
+blown
+blows
+blowup
+blubber
+blubbered
+blubbering
+bludgeon
+bludgeoned
+bludgeoning
+bludgeons
+blue
+blueberries
+blueberry
+blueberry's
+bluebird
+bluebird's
+bluebirds
+bluebonnet
+bluebonnet's
+bluebonnets
+blued
+bluefish
+bluely
+blueness
+blueprint
+blueprint's
+blueprinted
+blueprinting
+blueprints
+bluer
+blues
+bluest
+bluestocking
+bluff
+bluffed
+bluffer
+bluffing
+bluffly
+bluffness
+bluffs
+bluing
+bluish
+bluishness
+blunder
+blundered
+blunderer
+blundering
+blunderingly
+blunderings
+blunders
+blunt
+blunted
+blunter
+bluntest
+blunting
+bluntly
+bluntness
+blunts
+blur
+blur's
+blurb
+blurred
+blurredly
+blurrier
+blurriness
+blurring
+blurringly
+blurry
+blurs
+blurt
+blurted
+blurter
+blurting
+blurts
+blush
+blushed
+blusher
+blushes
+blushing
+blushingly
+bluster
+blustered
+blusterer
+blustering
+blusteringly
+blusters
+blustery
+boar
+board
+boarded
+boarder
+boarders
+boarding
+boardinghouse
+boardinghouse's
+boardinghouses
+boards
+boast
+boasted
+boaster
+boasters
+boastful
+boastfully
+boastfulness
+boasting
+boastings
+boasts
+boat
+boated
+boater
+boaters
+boathouse
+boathouse's
+boathouses
+boating
+boatload
+boatload's
+boatloads
+boatman
+boatmen
+boats
+boatswain
+boatswain's
+boatswains
+boatyard
+boatyard's
+boatyards
+bob
+bob's
+bobbed
+bobbies
+bobbin
+bobbin's
+bobbing
+bobbins
+bobby
+bobolink
+bobolink's
+bobolinks
+bobs
+bobwhite
+bobwhite's
+bobwhites
+bode
+boded
+bodes
+bodice
+bodied
+bodies
+bodily
+boding
+body
+bodybuilder
+bodybuilder's
+bodybuilders
+bodybuilding
+bodyguard
+bodyguard's
+bodyguards
+bodying
+bog
+bog's
+bogged
+boggle
+boggled
+boggles
+boggling
+bogs
+bogus
+boil
+boiled
+boiler
+boilerplate
+boilers
+boiling
+boils
+boisterous
+boisterously
+boisterousness
+bold
+bolder
+boldest
+boldface
+boldfaced
+boldfaces
+boldfacing
+boldly
+boldness
+boll
+bolster
+bolstered
+bolsterer
+bolstering
+bolsters
+bolt
+bolted
+bolter
+bolting
+bolts
+bomb
+bombard
+bombarded
+bombarding
+bombardment
+bombardments
+bombards
+bombast
+bombaster
+bombastic
+bombed
+bomber
+bombers
+bombing
+bombings
+bombproof
+bombs
+bonanza
+bonanza's
+bonanzas
+bond
+bondage
+bonded
+bonder
+bonders
+bonding
+bonds
+bondsman
+bondsmen
+bone
+boned
+boner
+boners
+bones
+bonfire
+bonfire's
+bonfires
+bong
+bonier
+boning
+bonnet
+bonneted
+bonnets
+bonnier
+bonny
+bonus
+bonus's
+bonuses
+bony
+boo
+boob
+boobies
+booboo
+booby
+book
+bookcase
+bookcase's
+bookcases
+booked
+booker
+bookers
+bookie
+bookie's
+bookies
+booking
+bookings
+bookish
+bookishly
+bookishness
+bookkeeper
+bookkeeper's
+bookkeepers
+bookkeeping
+booklet
+booklet's
+booklets
+books
+bookseller
+bookseller's
+booksellers
+bookshelf
+bookshelf's
+bookshelves
+bookstore
+bookstore's
+bookstores
+boolean
+booleans
+boom
+boomed
+boomer
+boomerang
+boomerang's
+boomerangs
+booming
+booms
+boon
+boor
+boor's
+boorish
+boorishly
+boorishness
+boors
+boos
+boost
+boosted
+booster
+boosting
+boosts
+boot
+booted
+booth
+booths
+booties
+booting
+bootleg
+bootlegged
+bootlegger
+bootlegger's
+bootleggers
+bootlegging
+bootlegs
+boots
+bootstrap
+bootstrap's
+bootstrapped
+bootstrapping
+bootstraps
+booty
+booze
+boozer
+boozing
+borate
+borated
+borates
+borax
+bordello
+bordello's
+bordellos
+border
+bordered
+borderer
+bordering
+borderings
+borderland
+borderland's
+borderlands
+borderline
+borders
+bore
+bored
+boredom
+borer
+borers
+bores
+boric
+boring
+boringly
+boringness
+born
+borne
+boron
+borough
+boroughs
+borrow
+borrowed
+borrower
+borrowers
+borrowing
+borrowings
+borrows
+bosom
+bosom's
+bosoms
+boss
+bossed
+bosses
+bosun
+botanical
+botanically
+botanist
+botanist's
+botanists
+botany
+botch
+botched
+botcher
+botchers
+botches
+botching
+both
+bother
+bothered
+bothering
+bothers
+bothersome
+bottle
+bottled
+bottleneck
+bottleneck's
+bottlenecks
+bottler
+bottlers
+bottles
+bottling
+bottom
+bottomed
+bottomer
+bottoming
+bottomless
+bottomlessly
+bottomlessness
+bottoms
+botulinus
+botulism
+bouffant
+bough
+bough's
+boughed
+boughs
+bought
+boughten
+boulder
+boulder's
+bouldered
+boulders
+boulevard
+boulevard's
+boulevards
+bounce
+bounced
+bouncer
+bouncers
+bounces
+bouncier
+bouncing
+bouncingly
+bouncy
+bound
+boundaries
+boundary
+boundary's
+bounded
+bounden
+bounder
+bounding
+boundless
+boundlessly
+boundlessness
+bounds
+bounteous
+bounteously
+bounteousness
+bountied
+bounties
+bounty
+bounty's
+bouquet
+bouquet's
+bouquets
+bourbon
+bourbons
+bourgeois
+bourgeoisie
+bout
+bout's
+bouts
+bovine
+bovinely
+bovines
+bow
+bowed
+bowel
+bowel's
+bowels
+bowen
+bower
+bowers
+bowing
+bowl
+bowled
+bowler
+bowlers
+bowline
+bowline's
+bowlines
+bowling
+bowls
+bowman
+bows
+bowser
+bowstring
+bowstring's
+bowstrings
+box
+boxcar
+boxcar's
+boxcars
+boxed
+boxer
+boxers
+boxes
+boxing
+boxwood
+boy
+boy's
+boycott
+boycotted
+boycotter
+boycotting
+boycotts
+boyer
+boyfriend
+boyfriend's
+boyfriends
+boyhood
+boyish
+boyishly
+boyishness
+boys
+bra
+bra's
+brace
+braced
+bracelet
+bracelet's
+bracelets
+bracer
+braces
+bracing
+bracket
+bracketed
+bracketing
+brackets
+brackish
+brackishness
+brae
+brae's
+braes
+brag
+bragged
+bragger
+bragging
+brags
+braid
+braided
+braider
+braiding
+braids
+braille
+brain
+brainchild
+brainchild's
+brained
+brainier
+braininess
+braining
+brains
+brainstorm
+brainstorm's
+brainstormer
+brainstorming
+brainstorms
+brainwash
+brainwashed
+brainwasher
+brainwashes
+brainwashing
+brainy
+brake
+braked
+brakes
+braking
+bramble
+bramble's
+brambles
+brambling
+brambly
+bran
+branch
+branched
+branches
+branching
+branchings
+brand
+branded
+brander
+brandied
+brandies
+branding
+brandish
+brandishes
+brandishing
+brands
+brandy
+brandying
+bras
+brash
+brashly
+brashness
+brass
+brassed
+brasses
+brassier
+brassiere
+brassiness
+brassy
+brat
+brat's
+brats
+bravado
+brave
+braved
+bravely
+braveness
+braver
+bravery
+braves
+bravest
+braving
+bravo
+bravoed
+bravoing
+bravos
+bravura
+brawl
+brawled
+brawler
+brawling
+brawls
+brawn
+bray
+brayed
+brayer
+braying
+brays
+braze
+brazed
+brazen
+brazened
+brazening
+brazenly
+brazenness
+brazer
+brazes
+brazier
+brazier's
+braziers
+brazing
+breach
+breached
+breacher
+breachers
+breaches
+breaching
+bread
+breadboard
+breadboard's
+breadboards
+breaded
+breading
+breads
+breadth
+breadwinner
+breadwinner's
+breadwinners
+break
+breakable
+breakables
+breakage
+breakaway
+breakdown
+breakdown's
+breakdowns
+breaker
+breakers
+breakfast
+breakfasted
+breakfaster
+breakfasters
+breakfasting
+breakfasts
+breaking
+breakpoint
+breakpoint's
+breakpointed
+breakpointing
+breakpoints
+breaks
+breakthrough
+breakthrough's
+breakthroughes
+breakthroughs
+breakup
+breakups
+breakwater
+breakwater's
+breakwaters
+breast
+breasted
+breasting
+breasts
+breastwork
+breastwork's
+breastworks
+breath
+breathable
+breathe
+breathed
+breather
+breathers
+breathes
+breathier
+breathing
+breathless
+breathlessly
+breathlessness
+breaths
+breathtaking
+breathtakingly
+breathy
+bred
+breech
+breech's
+breeches
+breeching
+breed
+breeder
+breeding
+breeds
+breeze
+breeze's
+breezed
+breezes
+breezier
+breezily
+breeziness
+breezing
+breezy
+bremsstrahlung
+brethren
+breve
+breves
+brevet
+breveted
+breveting
+brevets
+brevity
+brew
+brewed
+brewer
+breweries
+brewers
+brewery
+brewery's
+brewing
+brews
+briar
+briar's
+briars
+bribe
+bribed
+briber
+bribers
+bribes
+bribing
+brick
+bricked
+bricker
+bricking
+bricklayer
+bricklayer's
+bricklayers
+bricklaying
+bricks
+bridal
+bride
+bride's
+bridegroom
+brides
+bridesmaid
+bridesmaid's
+bridesmaids
+bridge
+bridgeable
+bridged
+bridgehead
+bridgehead's
+bridgeheads
+bridges
+bridgework
+bridgework's
+bridging
+bridle
+bridled
+bridles
+bridling
+brief
+briefcase
+briefcase's
+briefcases
+briefed
+briefer
+briefest
+briefing
+briefing's
+briefings
+briefly
+briefness
+briefs
+brier
+brig
+brig's
+brigade
+brigade's
+brigaded
+brigades
+brigadier
+brigadier's
+brigadiers
+brigading
+brigantine
+bright
+brighten
+brightened
+brightener
+brighteners
+brightening
+brightens
+brighter
+brightest
+brighting
+brightly
+brightness
+brightnesses
+brights
+brigs
+brilliance
+brilliancy
+brilliant
+brilliantly
+brilliantness
+brim
+brimful
+brimmed
+brindle
+brindled
+brine
+briner
+bring
+bringer
+bringers
+bringing
+brings
+brining
+brink
+brinkmanship
+brisk
+brisker
+briskly
+briskness
+bristle
+bristled
+bristles
+bristling
+britches
+brittle
+brittled
+brittlely
+brittleness
+brittler
+brittlest
+brittling
+broach
+broached
+broacher
+broaches
+broaching
+broad
+broadband
+broadcast
+broadcasted
+broadcaster
+broadcasters
+broadcasting
+broadcastings
+broadcasts
+broaden
+broadened
+broadener
+broadeners
+broadening
+broadenings
+broadens
+broader
+broadest
+broadly
+broadness
+broads
+broadside
+brocade
+brocaded
+broccoli
+brochure
+brochure's
+brochures
+broil
+broiled
+broiler
+broilers
+broiling
+broils
+broke
+broken
+brokenly
+brokenness
+broker
+brokerage
+brokers
+bromide
+bromide's
+bromides
+bromine
+bromines
+bronchi
+bronchial
+bronchiole
+bronchiole's
+bronchioles
+bronchitis
+bronchus
+bronze
+bronzed
+bronzer
+bronzes
+bronzing
+brooch
+brooch's
+brooches
+brood
+brooder
+brooding
+broodingly
+broods
+brook
+brooked
+brooks
+broom
+broom's
+broomed
+brooming
+brooms
+broomstick
+broomstick's
+broomsticks
+broth
+brothel
+brothel's
+brothels
+brother
+brother's
+brotherhood
+brotherliness
+brotherly
+brothers
+brought
+brow
+brow's
+browbeat
+browbeaten
+browbeating
+browbeats
+brown
+browned
+browner
+brownest
+brownie
+brownie's
+brownies
+browning
+brownings
+brownish
+brownly
+brownness
+browns
+brows
+browse
+browsed
+browser
+browsers
+browses
+browsing
+bruise
+bruised
+bruiser
+bruisers
+bruises
+bruising
+brunch
+brunches
+brunette
+brunettes
+brunt
+brush
+brushed
+brusher
+brushes
+brushfire
+brushfire's
+brushfires
+brushier
+brushing
+brushlike
+brushy
+brusque
+brusquely
+brusqueness
+brutal
+brutalities
+brutality
+brutally
+brute
+brute's
+brutes
+brutish
+brutishly
+brutishness
+bubble
+bubbled
+bubbler
+bubbles
+bubblier
+bubbling
+bubbly
+buck
+buckboard
+buckboard's
+buckboards
+bucked
+bucker
+bucket
+bucket's
+bucketed
+bucketing
+buckets
+bucking
+buckle
+buckled
+buckler
+buckles
+buckling
+bucks
+buckshot
+buckskin
+buckskins
+buckwheat
+bucolic
+bud
+bud's
+budded
+buddies
+budding
+buddy
+buddy's
+budge
+budged
+budges
+budget
+budgetary
+budgeted
+budgeter
+budgeters
+budgeting
+budgets
+budging
+buds
+buff
+buff's
+buffalo
+buffaloes
+buffer
+buffer's
+buffered
+bufferer
+bufferer's
+bufferers
+buffering
+buffers
+buffet
+buffeted
+buffeting
+buffetings
+buffets
+buffing
+buffoon
+buffoon's
+buffoons
+buffs
+bug
+bug's
+bugged
+bugger
+bugger's
+buggered
+buggering
+buggers
+buggies
+bugging
+buggy
+buggy's
+bugle
+bugled
+bugler
+bugles
+bugling
+bugs
+build
+builded
+builder
+builders
+building
+building's
+buildings
+builds
+buildup
+buildup's
+buildups
+built
+bulb
+bulb's
+bulbed
+bulbs
+bulge
+bulged
+bulges
+bulging
+bulk
+bulked
+bulkhead
+bulkhead's
+bulkheaded
+bulkheads
+bulkier
+bulkiness
+bulks
+bulky
+bull
+bulldog
+bulldog's
+bulldogs
+bulldoze
+bulldozed
+bulldozer
+bulldozers
+bulldozes
+bulldozing
+bulled
+bullet
+bullet's
+bulletin
+bulletin's
+bulletins
+bulletproof
+bulletproofed
+bulletproofing
+bulletproofs
+bullets
+bullied
+bullies
+bulling
+bullion
+bullish
+bullishly
+bullishness
+bulls
+bully
+bullying
+bulwark
+bum
+bum's
+bumble
+bumblebee
+bumblebee's
+bumblebees
+bumbled
+bumbler
+bumblers
+bumbles
+bumbling
+bumblingly
+bummed
+bummer
+bummers
+bumming
+bump
+bumped
+bumper
+bumpers
+bumping
+bumps
+bumptious
+bumptiously
+bumptiousness
+bums
+bun
+bun's
+bunch
+bunched
+bunches
+bunching
+bundle
+bundled
+bundler
+bundles
+bundling
+bungalow
+bungalow's
+bungalows
+bungle
+bungled
+bungler
+bunglers
+bungles
+bungling
+bunglingly
+bunion
+bunion's
+bunions
+bunk
+bunked
+bunker
+bunker's
+bunkered
+bunkering
+bunkers
+bunkhouse
+bunkhouse's
+bunkhouses
+bunking
+bunkmate
+bunkmate's
+bunkmates
+bunks
+bunnies
+bunny
+bunny's
+buns
+bunt
+bunted
+bunter
+bunters
+bunting
+bunts
+buoy
+buoyancy
+buoyant
+buoyantly
+buoyed
+buoying
+buoys
+burden
+burden's
+burdened
+burdening
+burdens
+burdensome
+burdensomely
+burdensomeness
+bureau
+bureau's
+bureaucracies
+bureaucracy
+bureaucracy's
+bureaucrat
+bureaucrat's
+bureaucratic
+bureaucrats
+bureaus
+burgeon
+burgeoned
+burgeoning
+burgeons
+burger
+burgess
+burgess's
+burgesses
+burgher
+burgher's
+burghers
+burglar
+burglar's
+burglaries
+burglarproof
+burglarproofed
+burglarproofing
+burglarproofs
+burglars
+burglary
+burglary's
+burgle
+burgled
+burgles
+burgling
+burial
+buried
+burier
+buries
+burl
+burled
+burler
+burlesque
+burlesqued
+burlesquely
+burlesquer
+burlesques
+burlesquing
+burlier
+burliness
+burly
+burn
+burned
+burner
+burners
+burning
+burningly
+burnings
+burnish
+burnished
+burnisher
+burnishes
+burnishing
+burns
+burnt
+burntly
+burntness
+burp
+burped
+burping
+burps
+burr
+burr's
+burred
+burrer
+burro
+burro's
+burros
+burrow
+burrowed
+burrower
+burrowing
+burrows
+burrs
+bursa
+bursas
+bursitis
+burst
+bursted
+burster
+bursting
+bursts
+bury
+burying
+bus
+busboy
+busboy's
+busboys
+bused
+buses
+bush
+bushed
+bushel
+bushel's
+bushels
+bushes
+bushier
+bushiness
+bushing
+bushings
+bushwhack
+bushwhacked
+bushwhacker
+bushwhacking
+bushwhacks
+bushy
+busied
+busier
+busies
+busiest
+busily
+business
+business's
+businesses
+businesslike
+businessman
+businessmen
+busing
+buss
+bussed
+busses
+bussing
+bust
+bustard
+bustard's
+bustards
+busted
+buster
+busting
+bustle
+bustled
+bustling
+bustlingly
+busts
+busy
+busying
+but
+butane
+butcher
+butcher's
+butchered
+butcherer
+butchering
+butcherly
+butchers
+butchery
+butler
+butler's
+butlers
+butt
+butt's
+butte
+butted
+butter
+buttered
+butterer
+butterers
+butterfat
+butterflies
+butterfly
+butterfly's
+buttering
+butternut
+butters
+buttes
+butting
+buttock
+buttock's
+buttocks
+button
+buttoned
+buttoner
+buttonhole
+buttonhole's
+buttonholer
+buttonholes
+buttoning
+buttons
+buttress
+buttressed
+buttresses
+buttressing
+butts
+butyl
+butyrate
+buxom
+buxomly
+buxomness
+buy
+buyer
+buyer's
+buyers
+buying
+buys
+buzz
+buzzard
+buzzard's
+buzzards
+buzzed
+buzzer
+buzzes
+buzzing
+buzzword
+buzzword's
+buzzwords
+buzzy
+by
+bye
+byers
+byes
+bygone
+bygones
+bylaw
+bylaw's
+bylaws
+byline
+byline's
+byliner
+bylines
+bypass
+bypassed
+bypasses
+bypassing
+byproduct
+byproduct's
+byproducts
+bystander
+bystander's
+bystanders
+byte
+byte's
+bytes
+byway
+byways
+byword
+byword's
+bywords
+cab
+cab's
+cabbage
+cabbage's
+cabbaged
+cabbages
+cabbaging
+caber
+cabin
+cabin's
+cabinet
+cabinet's
+cabinets
+cabins
+cable
+cabled
+cables
+cabling
+cabs
+cache
+cache's
+cached
+cacher
+caches
+caching
+cackle
+cackled
+cackler
+cackles
+cackling
+cacti
+cactus
+cactuses
+cad
+cadence
+cadenced
+cadences
+cadencing
+cafe
+cafe's
+cafes
+cafeteria
+cafeteria's
+cafeterias
+cage
+caged
+cager
+cagers
+cages
+caging
+cajole
+cajoled
+cajoler
+cajoles
+cajoling
+cake
+caked
+cakes
+caking
+calamities
+calamity
+calamity's
+calcium
+calculate
+calculated
+calculatedly
+calculatedness
+calculates
+calculating
+calculation
+calculations
+calculative
+calculator
+calculator's
+calculators
+calculus
+calendar
+calendar's
+calendared
+calendaring
+calendars
+calf
+calfs
+calibrate
+calibrated
+calibrater
+calibrates
+calibrating
+calibration
+calibrations
+calibrator
+calibrators
+calico
+caliph
+caliphs
+call
+called
+caller
+caller's
+callers
+calling
+callous
+calloused
+callously
+callousness
+calls
+calm
+calmed
+calmer
+calmest
+calming
+calmingly
+calmly
+calmness
+calms
+calorie
+calorie's
+calories
+calves
+came
+camel
+camel's
+camels
+camera
+camera's
+cameras
+camion
+camouflage
+camouflaged
+camouflages
+camouflaging
+camp
+campaign
+campaigned
+campaigner
+campaigners
+campaigning
+campaigns
+camped
+camper
+campers
+camping
+camps
+campus
+campus's
+campuses
+can
+can's
+can't
+canal
+canal's
+canals
+canaries
+canary
+canary's
+cancel
+cancellation
+cancellation's
+cancellations
+cancels
+cancer
+cancer's
+cancers
+candid
+candidate
+candidate's
+candidates
+candidly
+candidness
+candied
+candies
+candle
+candled
+candler
+candles
+candlestick
+candlestick's
+candlesticks
+candling
+candy
+candying
+cane
+caned
+caner
+canes
+caning
+canker
+cankered
+cankering
+canned
+canner
+canner's
+canners
+cannibal
+cannibal's
+cannibals
+canning
+cannister
+cannister's
+cannisters
+cannon
+cannon's
+cannoned
+cannoning
+cannons
+cannot
+canoe
+canoe's
+canoed
+canoes
+canon
+canon's
+canonical
+canonically
+canonicals
+canons
+canopy
+cans
+cantankerous
+cantankerously
+cantankerousness
+canto
+canton
+canton's
+cantons
+cantor
+cantor's
+cantors
+cantos
+canvas
+canvas's
+canvaser
+canvases
+canvass
+canvassed
+canvasser
+canvassers
+canvasses
+canvassing
+canyon
+canyon's
+canyons
+cap
+cap's
+capabilities
+capability
+capability's
+capable
+capableness
+capably
+capacious
+capaciously
+capaciousness
+capacitance
+capacitances
+capacities
+capacitive
+capacitively
+capacitor
+capacitor's
+capacitors
+capacity
+cape
+caper
+capered
+capering
+capers
+capes
+capillary
+capita
+capital
+capitalism
+capitalist
+capitalist's
+capitalists
+capitally
+capitals
+capitol
+capitol's
+capitols
+capped
+capping
+capricious
+capriciously
+capriciousness
+caps
+captain
+captained
+captaining
+captains
+caption
+caption's
+captioned
+captioner
+captioning
+captions
+captivate
+captivated
+captivates
+captivating
+captivation
+captive
+captive's
+captives
+captivity
+captor
+captor's
+captors
+capture
+captured
+capturer
+capturers
+captures
+capturing
+car
+car's
+caravan
+caravan's
+caravaner
+caravans
+carbohydrate
+carbohydrate's
+carbohydrates
+carbolic
+carbon
+carbon's
+carbonate
+carbonated
+carbonates
+carbonation
+carbonic
+carbons
+carcass
+carcass's
+carcasses
+card
+card's
+cardboard
+cardboards
+carded
+carder
+cardiac
+cardinal
+cardinalities
+cardinality
+cardinality's
+cardinally
+cardinals
+carding
+cards
+care
+cared
+career
+career's
+careered
+careering
+careers
+carefree
+careful
+carefully
+carefulness
+careless
+carelessly
+carelessness
+carer
+carers
+cares
+caress
+caressed
+caresser
+caresses
+caressing
+caressingly
+caressive
+caressively
+caret
+carets
+cargo
+cargoes
+cargos
+caribou
+caribous
+caring
+carnation
+carnations
+carnival
+carnival's
+carnivals
+carnivorous
+carnivorously
+carnivorousness
+carol
+carol's
+carols
+carpenter
+carpenter's
+carpentered
+carpentering
+carpenters
+carpet
+carpeted
+carpeting
+carpets
+carriage
+carriage's
+carriages
+carried
+carrier
+carriers
+carries
+carrot
+carrot's
+carrots
+carry
+carrying
+carryover
+carryovers
+cars
+cart
+carted
+carter
+carters
+carting
+cartography
+carton
+carton's
+cartons
+cartoon
+cartoon's
+cartoons
+cartridge
+cartridge's
+cartridges
+carts
+carve
+carved
+carver
+carvers
+carves
+carving
+carvings
+cascade
+cascaded
+cascades
+cascading
+case
+cased
+casement
+casement's
+casements
+cases
+cash
+cashed
+casher
+cashers
+cashes
+cashier
+cashier's
+cashiers
+cashing
+casing
+casings
+cask
+cask's
+casket
+casket's
+caskets
+casks
+casserole
+casserole's
+casseroles
+cast
+cast's
+caste
+caste's
+casted
+caster
+casters
+castes
+casteth
+casting
+castings
+castle
+castled
+castles
+castling
+casts
+casual
+casually
+casualness
+casuals
+casualties
+casualty
+casualty's
+cat
+cat's
+catalyst
+catalyst's
+catalysts
+cataract
+cataracts
+catastrophe
+catastrophe's
+catastrophes
+catastrophic
+catch
+catchable
+catcher
+catcher's
+catchers
+catches
+catching
+categorical
+categorically
+categories
+category
+category's
+cater
+catered
+caterer
+catering
+caterpillar
+caterpillar's
+caterpillars
+caters
+cathedral
+cathedral's
+cathedrals
+catheter
+catheters
+cathode
+cathode's
+cathodes
+catholic
+catholic's
+catholics
+cats
+catsup
+cattle
+caught
+causal
+causality
+causally
+causation
+causation's
+causations
+cause
+caused
+causer
+causes
+causeway
+causeway's
+causeways
+causing
+caustic
+causticly
+caustics
+caution
+cautioned
+cautioner
+cautioners
+cautioning
+cautionings
+cautions
+cautious
+cautiously
+cautiousness
+cavalier
+cavalierly
+cavalierness
+cavalry
+cave
+caveat
+caveat's
+caveats
+caved
+caver
+cavern
+cavern's
+caverns
+caves
+caving
+cavities
+cavity
+cavity's
+caw
+cawed
+cawing
+caws
+cease
+ceased
+ceaseless
+ceaselessly
+ceaselessness
+ceases
+ceasing
+cedar
+ceiling
+ceiling's
+ceilinged
+ceilings
+celebrate
+celebrated
+celebratedness
+celebrates
+celebrating
+celebration
+celebrations
+celebratory
+celebrities
+celebrity
+celebrity's
+celery
+celestial
+celestially
+celibate
+celibates
+cell
+cellar
+cellar's
+cellared
+cellarer
+cellaring
+cellars
+celled
+cellist
+cellist's
+cellists
+cells
+cellular
+cellularly
+cement
+cemented
+cementer
+cementing
+cements
+cemeteries
+cemetery
+cemetery's
+censor
+censored
+censoring
+censors
+censorship
+censure
+censured
+censurer
+censures
+censuring
+census
+census's
+censuses
+cent
+centipede
+centipede's
+centipedes
+central
+centrally
+centrals
+centrifuge
+centrifuge's
+centrifuged
+centrifuges
+centrifuging
+centripetal
+centripetally
+cents
+centuries
+century
+century's
+cereal
+cereal's
+cereals
+cerebral
+cerebrally
+ceremonial
+ceremonially
+ceremonialness
+ceremonies
+ceremony
+ceremony's
+certain
+certainly
+certainties
+certainty
+certifiable
+certificate
+certificated
+certificates
+certificating
+certification
+certifications
+certified
+certifier
+certifiers
+certifies
+certify
+certifying
+cessation
+cessation's
+cessations
+chafe
+chafer
+chaff
+chaffer
+chaffered
+chafferer
+chaffering
+chaffing
+chafing
+chagrin
+chagrined
+chagrining
+chagrins
+chain
+chained
+chaining
+chains
+chair
+chaired
+chairing
+chairman
+chairmanship
+chairmanships
+chairmen
+chairperson
+chairperson's
+chairpersons
+chairs
+chalice
+chalice's
+chaliced
+chalices
+chalk
+chalked
+chalking
+chalks
+challenge
+challenged
+challenger
+challengers
+challenges
+challenging
+challengingly
+chamber
+chambered
+chamberer
+chamberers
+chambering
+chamberlain
+chamberlain's
+chamberlains
+chambers
+champagne
+champaign
+champion
+championed
+championing
+champions
+championship
+championship's
+championships
+chance
+chanced
+chancellor
+chancellors
+chances
+chancing
+chandelier
+chandelier's
+chandeliers
+change
+changeability
+changeable
+changeableness
+changeably
+changed
+changeover
+changeover's
+changeovers
+changer
+changers
+changes
+changing
+channel
+channels
+chant
+chanted
+chanter
+chanticleer
+chanticleer's
+chanticleers
+chanting
+chants
+chaos
+chaotic
+chap
+chap's
+chapel
+chapel's
+chapels
+chaperon
+chaperoned
+chaplain
+chaplain's
+chaplains
+chaps
+chapter
+chapter's
+chaptered
+chaptering
+chapters
+char
+character
+character's
+charactered
+charactering
+characteristic
+characteristic's
+characteristically
+characteristics
+characters
+charcoal
+charcoaled
+charcoals
+charge
+chargeable
+chargeableness
+charged
+charger
+chargers
+charges
+charging
+charing
+chariot
+chariot's
+chariots
+charitable
+charitableness
+charities
+charity
+charity's
+charm
+charmed
+charmer
+charmers
+charming
+charmingly
+charms
+chars
+chart
+chartable
+charted
+charter
+chartered
+charterer
+charterers
+chartering
+charters
+charting
+chartings
+charts
+chase
+chased
+chaser
+chasers
+chases
+chasing
+chasm
+chasm's
+chasms
+chaste
+chastely
+chasteness
+chaster
+chastest
+chastise
+chastised
+chastiser
+chastisers
+chastises
+chastising
+chat
+chateau
+chateau's
+chateaus
+chats
+chatter
+chattered
+chatterer
+chatterers
+chattering
+chatterly
+chatters
+chauffeur
+chauffeured
+chauffeuring
+chauffeurs
+chauvinism
+chauvinism's
+chauvinist
+chauvinist's
+chauvinistic
+chauvinists
+cheap
+cheapen
+cheapened
+cheapening
+cheapens
+cheaper
+cheapest
+cheaply
+cheapness
+cheat
+cheated
+cheater
+cheaters
+cheating
+cheats
+check
+checkable
+checked
+checker
+checkered
+checkering
+checkers
+checking
+checkout
+checkouts
+checkpoint
+checkpoint's
+checkpoints
+checks
+checksum
+checksum's
+checksums
+cheek
+cheek's
+cheeks
+cheer
+cheered
+cheerer
+cheerers
+cheerful
+cheerfully
+cheerfulness
+cheerier
+cheerily
+cheeriness
+cheering
+cheerless
+cheerlessly
+cheerlessness
+cheerly
+cheers
+cheery
+cheese
+cheese's
+cheesed
+cheeses
+cheesing
+chef
+chef's
+chefs
+chemical
+chemically
+chemicals
+chemise
+chemises
+chemist
+chemist's
+chemistries
+chemistry
+chemists
+cherish
+cherished
+cherisher
+cherishes
+cherishing
+cherries
+cherry
+cherry's
+cherub
+cherub's
+cherubim
+cherubs
+chess
+chest
+chester
+chestnut
+chestnut's
+chestnuts
+chests
+chew
+chewed
+chewer
+chewers
+chewing
+chews
+chick
+chickadee
+chickadee's
+chickadees
+chicken
+chickened
+chickening
+chickens
+chicks
+chide
+chided
+chides
+chiding
+chief
+chief's
+chiefly
+chiefs
+chieftain
+chieftain's
+chieftains
+chiffon
+child
+child's
+childhood
+childhoods
+childish
+childishly
+childishness
+childly
+children
+children's
+chill
+chilled
+chiller
+chillers
+chillier
+chillies
+chilliness
+chilling
+chillingly
+chillness
+chills
+chilly
+chime
+chime's
+chimed
+chimer
+chimes
+chiming
+chimney
+chimney's
+chimneyed
+chimneys
+chin
+chin's
+chink
+chinked
+chinks
+chinned
+chinner
+chinners
+chinning
+chins
+chintz
+chip
+chip's
+chipmunk
+chipmunk's
+chipmunks
+chips
+chirp
+chirped
+chirping
+chirps
+chisel
+chisels
+chivalrous
+chivalrously
+chivalrousness
+chivalry
+chlorine
+chloroplast
+chloroplast's
+chloroplasts
+chock
+chock's
+chocked
+chocker
+chocking
+chocks
+chocolate
+chocolate's
+chocolates
+choice
+choicely
+choiceness
+choicer
+choices
+choicest
+choir
+choir's
+choirs
+choke
+choked
+choker
+chokers
+chokes
+choking
+chokingly
+cholera
+choose
+chooser
+choosers
+chooses
+choosing
+chop
+chopped
+chopper
+chopper's
+choppers
+chopping
+chops
+choral
+chorally
+chord
+chord's
+chorded
+chording
+chords
+chore
+chores
+choring
+chorion
+chorus
+chorused
+choruses
+chose
+chosen
+christen
+christened
+christening
+christens
+chronic
+chronicle
+chronicled
+chronicler
+chroniclers
+chronicles
+chronological
+chronologically
+chronologies
+chronology
+chronology's
+chubbier
+chubbiest
+chubbiness
+chubby
+chuck
+chuck's
+chucked
+chucking
+chuckle
+chuckled
+chuckles
+chuckling
+chucklingly
+chucks
+chum
+chump
+chump's
+chumping
+chumps
+chums
+chunk
+chunk's
+chunks
+church
+churched
+churches
+churching
+churchliness
+churchly
+churchman
+churchyard
+churchyard's
+churchyards
+churn
+churned
+churner
+churners
+churning
+churns
+chute
+chute's
+chuted
+chutes
+chuting
+cider
+ciders
+cigar
+cigar's
+cigarette
+cigarette's
+cigarettes
+cigars
+cinder
+cinder's
+cinders
+cinnamon
+cipher
+cipher's
+ciphered
+ciphering
+ciphers
+circle
+circled
+circler
+circles
+circling
+circuit
+circuit's
+circuited
+circuiting
+circuitous
+circuitously
+circuitousness
+circuitry
+circuits
+circular
+circular's
+circularities
+circularity
+circularly
+circularness
+circulars
+circulate
+circulated
+circulates
+circulating
+circulation
+circulations
+circulative
+circumference
+circumferences
+circumflex
+circumflexes
+circumlocution
+circumlocution's
+circumlocutions
+circumspect
+circumspectly
+circumstance
+circumstance's
+circumstanced
+circumstances
+circumstancing
+circumstantial
+circumstantially
+circumvent
+circumventable
+circumvented
+circumventing
+circumvents
+circus
+circus's
+circuses
+cistern
+cistern's
+cisterns
+citadel
+citadel's
+citadels
+citation
+citation's
+citations
+cite
+cited
+cites
+citied
+cities
+citing
+citizen
+citizen's
+citizenly
+citizens
+citizenship
+city
+city's
+civic
+civics
+civil
+civilian
+civilian's
+civilians
+civilities
+civility
+civilly
+clad
+clads
+claim
+claimable
+claimant
+claimant's
+claimants
+claimed
+claimer
+claiming
+claims
+clairvoyant
+clairvoyantly
+clairvoyants
+clam
+clam's
+clamber
+clambered
+clamberer
+clambering
+clambers
+clamorous
+clamorously
+clamorousness
+clamp
+clamped
+clamper
+clamping
+clamps
+clams
+clan
+clang
+clanged
+clanger
+clangers
+clanging
+clangs
+clans
+clap
+claps
+clarification
+clarifications
+clarified
+clarifier
+clarifies
+clarify
+clarifying
+clarity
+clash
+clashed
+clasher
+clashes
+clashing
+clasp
+clasped
+clasper
+clasping
+clasps
+class
+classed
+classer
+classes
+classic
+classical
+classically
+classics
+classifiable
+classification
+classifications
+classified
+classifieds
+classifier
+classifiers
+classifies
+classify
+classifying
+classing
+classmate
+classmate's
+classmates
+classroom
+classroom's
+classrooms
+classwork
+clatter
+clattered
+clatterer
+clattering
+clatteringly
+clatters
+clause
+clause's
+clauses
+claw
+clawed
+clawer
+clawing
+claws
+clay
+clay's
+clayed
+claying
+clays
+clean
+cleaned
+cleaner
+cleaner's
+cleaners
+cleanest
+cleaning
+cleanlier
+cleanliness
+cleanly
+cleanness
+cleans
+cleanse
+cleansed
+cleanser
+cleansers
+cleanses
+cleansing
+cleanup
+cleanup's
+cleanups
+clear
+clearance
+clearance's
+clearances
+cleared
+clearer
+clearest
+clearing
+clearing's
+clearings
+clearly
+clearness
+clears
+cleavage
+cleavages
+cleave
+cleaved
+cleaver
+cleavers
+cleaves
+cleaving
+cleft
+cleft's
+clefts
+clench
+clenched
+clenches
+clenching
+clergy
+clergyman
+clerical
+clerically
+clericals
+clerk
+clerk's
+clerked
+clerking
+clerkly
+clerks
+clever
+cleverer
+cleverest
+cleverly
+cleverness
+cliche
+cliche's
+cliches
+click
+clicked
+clicker
+clickers
+clicking
+clicks
+client
+client's
+clients
+cliff
+cliff's
+cliffs
+climate
+climate's
+climates
+climatic
+climatically
+climax
+climaxed
+climaxes
+climaxing
+climb
+climbed
+climber
+climbers
+climbing
+climbs
+clime
+clime's
+climes
+clinch
+clinched
+clincher
+clinches
+clinching
+clinchingly
+cling
+clinging
+clings
+clinic
+clinic's
+clinical
+clinically
+clinics
+clink
+clinked
+clinker
+clinkered
+clinkering
+clinkers
+clip
+clip's
+clipped
+clipper
+clipper's
+clippers
+clipping
+clipping's
+clippings
+clips
+clique
+clique's
+cliques
+cloak
+cloak's
+cloaked
+cloaking
+cloaks
+clobber
+clobbered
+clobbering
+clobbers
+clock
+clocked
+clocker
+clockers
+clocking
+clockings
+clocks
+clockwise
+clockwork
+clod
+clod's
+clods
+clog
+clog's
+clogged
+clogging
+clogs
+cloister
+cloister's
+cloistered
+cloistering
+cloisters
+clone
+cloned
+cloner
+cloners
+clones
+cloning
+close
+closed
+closely
+closeness
+closenesses
+closer
+closers
+closes
+closest
+closet
+closeted
+closets
+closing
+closings
+closure
+closure's
+closured
+closures
+closuring
+cloth
+clothe
+clothed
+clothes
+clothing
+cloud
+clouded
+cloudier
+cloudiest
+cloudiness
+clouding
+cloudless
+cloudlessly
+cloudlessness
+clouds
+cloudy
+clout
+clove
+clover
+cloves
+clown
+clowning
+clowns
+club
+club's
+clubbed
+clubbing
+clubs
+cluck
+clucked
+clucking
+clucks
+clue
+clue's
+clues
+cluing
+clump
+clumped
+clumping
+clumps
+clumsier
+clumsiest
+clumsily
+clumsiness
+clumsy
+clung
+cluster
+clustered
+clustering
+clusterings
+clusters
+clutch
+clutched
+clutches
+clutching
+clutter
+cluttered
+cluttering
+clutters
+coach
+coach's
+coached
+coacher
+coaches
+coaching
+coachman
+coagulate
+coagulated
+coagulates
+coagulating
+coagulation
+coal
+coaled
+coaler
+coalesce
+coalesced
+coalesces
+coalescing
+coaling
+coalition
+coals
+coarse
+coarsely
+coarsen
+coarsened
+coarseness
+coarsening
+coarser
+coarsest
+coast
+coastal
+coasted
+coaster
+coasters
+coasting
+coasts
+coat
+coated
+coater
+coaters
+coating
+coatings
+coats
+coax
+coaxed
+coaxer
+coaxes
+coaxial
+coaxially
+coaxing
+cobbler
+cobbler's
+cobblers
+cobweb
+cobweb's
+cobwebs
+cock
+cocked
+cocker
+cocking
+cockroach
+cockroaches
+cocks
+cocktail
+cocktail's
+cocktails
+cocoa
+coconut
+coconut's
+coconuts
+cocoon
+cocoon's
+cocoons
+cod
+code
+coded
+coder
+coder's
+coders
+codes
+codeword
+codeword's
+codewords
+codification
+codification's
+codifications
+codified
+codifier
+codifier's
+codifiers
+codifies
+codify
+codifying
+coding
+codings
+cods
+coefficient
+coefficient's
+coefficiently
+coefficients
+coerce
+coerced
+coerces
+coercing
+coercion
+coercions
+coercive
+coercively
+coerciveness
+coexist
+coexisted
+coexistence
+coexisting
+coexists
+coffee
+coffee's
+coffees
+coffer
+coffer's
+coffers
+coffin
+coffin's
+coffins
+cogent
+cogently
+cogitate
+cogitated
+cogitates
+cogitating
+cogitation
+cogitative
+cognition
+cognitions
+cognitive
+cognitively
+cognitives
+cohabit
+cohabitation
+cohabitations
+cohabited
+cohabiting
+cohabits
+cohere
+cohered
+coherence
+coherent
+coherently
+coherer
+coheres
+cohering
+cohesion
+cohesive
+cohesively
+cohesiveness
+coil
+coiled
+coiling
+coils
+coin
+coinage
+coincide
+coincided
+coincidence
+coincidence's
+coincidences
+coincidental
+coincidentally
+coincides
+coinciding
+coined
+coiner
+coining
+coins
+coke
+cokes
+coking
+cold
+colder
+coldest
+coldly
+coldness
+colds
+collaborate
+collaborated
+collaborates
+collaborating
+collaboration
+collaborations
+collaborative
+collaboratively
+collaborator
+collaborator's
+collaborators
+collapse
+collapsed
+collapses
+collapsing
+collar
+collared
+collaring
+collars
+collate
+collated
+collateral
+collaterally
+collates
+collating
+collation
+collations
+collative
+collator
+collators
+colleague
+colleague's
+colleagues
+collect
+collected
+collectedly
+collectedness
+collectible
+collecting
+collection
+collection's
+collections
+collective
+collectively
+collectives
+collector
+collector's
+collectors
+collects
+college
+college's
+colleges
+collegiate
+collegiately
+collide
+collided
+collides
+colliding
+collie
+collied
+collier
+collies
+collision
+collision's
+collisions
+cologne
+cologned
+colon
+colon's
+colonel
+colonel's
+colonels
+colonial
+colonially
+colonialness
+colonials
+colonies
+colonist
+colonist's
+colonists
+colons
+colony
+colony's
+colossal
+colossally
+colt
+colt's
+colter
+colts
+column
+column's
+columnar
+columned
+columns
+comb
+combat
+combatant
+combatant's
+combatants
+combated
+combating
+combative
+combatively
+combativeness
+combats
+combed
+comber
+combers
+combination
+combination's
+combinational
+combinations
+combinator
+combinator's
+combinatorial
+combinatorially
+combinatoric
+combinatorics
+combinators
+combine
+combined
+combiner
+combiners
+combines
+combing
+combings
+combining
+combs
+combustion
+combustions
+come
+comedian
+comedian's
+comedians
+comedic
+comedies
+comedy
+comedy's
+comelier
+comeliness
+comely
+comer
+comers
+comes
+comest
+comestible
+comestibles
+comet
+comet's
+cometh
+comets
+comfort
+comfortabilities
+comfortability
+comfortable
+comfortableness
+comfortably
+comforted
+comforter
+comforters
+comforting
+comfortingly
+comforts
+comic
+comic's
+comical
+comically
+comics
+coming
+comings
+comma
+comma's
+command
+command's
+commandant
+commandant's
+commandants
+commanded
+commandeer
+commandeered
+commandeering
+commandeers
+commander
+commanders
+commanding
+commandingly
+commandment
+commandment's
+commandments
+commands
+commas
+commemorate
+commemorated
+commemorates
+commemorating
+commemoration
+commemorations
+commemorative
+commemoratively
+commemoratives
+commence
+commenced
+commencement
+commencement's
+commencements
+commencer
+commences
+commencing
+commend
+commendation
+commendation's
+commendations
+commended
+commender
+commending
+commends
+commensurate
+commensurately
+commensurates
+commensuration
+commensurations
+comment
+comment's
+commentaries
+commentary
+commentary's
+commentator
+commentator's
+commentators
+commented
+commenter
+commenting
+comments
+commerce
+commerced
+commercial
+commercially
+commercialness
+commercials
+commercing
+commission
+commissioned
+commissioner
+commissioners
+commissioning
+commissions
+commit
+commitment
+commitment's
+commitments
+commits
+committed
+committee
+committee's
+committees
+committing
+commodities
+commodity
+commodity's
+commodore
+commodore's
+commodores
+common
+commonalities
+commonality
+commoner
+commoner's
+commoners
+commonest
+commonly
+commonness
+commonplace
+commonplaceness
+commonplaces
+commons
+commonwealth
+commonwealths
+commotion
+commotions
+communal
+communally
+commune
+communed
+communes
+communicant
+communicant's
+communicants
+communicate
+communicated
+communicates
+communicating
+communication
+communications
+communicative
+communicatively
+communicativeness
+communicator
+communicator's
+communicators
+communing
+communion
+communist
+communist's
+communists
+communities
+community
+community's
+commutative
+commutatively
+commutativity
+commute
+commuted
+commuter
+commuters
+commutes
+commuting
+compact
+compacted
+compacter
+compacters
+compactest
+compacting
+compactly
+compactness
+compactor
+compactor's
+compactors
+compacts
+companies
+companion
+companion's
+companionable
+companionableness
+companions
+companionship
+company
+company's
+comparability
+comparable
+comparableness
+comparably
+comparative
+comparatively
+comparativeness
+comparatives
+comparator
+comparator's
+comparators
+compare
+compared
+comparer
+compares
+comparing
+comparison
+comparison's
+comparisons
+compartment
+compartmented
+compartmenting
+compartments
+compass
+compassed
+compasses
+compassing
+compassion
+compassionate
+compassionately
+compassionateness
+compatibilities
+compatibility
+compatibility's
+compatible
+compatibleness
+compatibles
+compatibly
+compel
+compelled
+compelling
+compellingly
+compels
+compendium
+compensate
+compensated
+compensates
+compensating
+compensation
+compensations
+compensative
+compensatory
+compete
+competed
+competence
+competences
+competent
+competently
+competes
+competing
+competition
+competition's
+competitions
+competitive
+competitively
+competitiveness
+competitor
+competitor's
+competitors
+compilable
+compilation
+compilation's
+compilations
+compile
+compiled
+compiler
+compiler's
+compilers
+compiles
+compiling
+complain
+complained
+complainer
+complainers
+complaining
+complainingly
+complains
+complaint
+complaint's
+complaints
+complement
+complementariness
+complementary
+complemented
+complementer
+complementers
+complementing
+complements
+complete
+completed
+completely
+completeness
+completer
+completes
+completing
+completion
+completions
+completive
+complex
+complexes
+complexion
+complexioned
+complexities
+complexity
+complexly
+complexness
+compliance
+compliances
+complicate
+complicated
+complicatedly
+complicatedness
+complicates
+complicating
+complication
+complications
+complicator
+complicator's
+complicators
+complicity
+complied
+complier
+compliers
+complies
+compliment
+complimentary
+complimented
+complimenter
+complimenters
+complimenting
+compliments
+comply
+complying
+component
+component's
+components
+compose
+composed
+composedly
+composedness
+composer
+composer's
+composers
+composes
+composing
+composite
+compositely
+composites
+composition
+compositional
+compositionally
+compositions
+composure
+compound
+compounded
+compounder
+compounding
+compounds
+comprehend
+comprehended
+comprehending
+comprehends
+comprehensibility
+comprehensible
+comprehensibleness
+comprehension
+comprehensive
+comprehensively
+comprehensiveness
+compress
+compressed
+compressedly
+compresses
+compressible
+compressing
+compression
+compressions
+compressive
+compressively
+comprise
+comprised
+comprises
+comprising
+compromise
+compromised
+compromiser
+compromisers
+compromises
+compromising
+compromisingly
+comptroller
+comptroller's
+comptrollers
+compulsion
+compulsion's
+compulsions
+compulsory
+compunction
+compunctions
+computability
+computable
+computation
+computation's
+computational
+computationally
+computations
+compute
+computed
+computer
+computer's
+computerese
+computers
+computes
+computing
+comrade
+comradeliness
+comradely
+comrades
+comradeship
+concatenate
+concatenated
+concatenates
+concatenating
+concatenation
+concatenations
+conceal
+concealed
+concealer
+concealers
+concealing
+concealingly
+concealment
+conceals
+concede
+conceded
+concededly
+conceder
+concedes
+conceding
+conceit
+conceited
+conceitedly
+conceitedness
+conceits
+conceivable
+conceivably
+conceive
+conceived
+conceiver
+conceives
+conceiving
+concentrate
+concentrated
+concentrates
+concentrating
+concentration
+concentrations
+concentrative
+concentrator
+concentrators
+concentric
+concept
+concept's
+conception
+conception's
+conceptions
+conceptive
+concepts
+conceptual
+conceptually
+concern
+concerned
+concernedly
+concerning
+concerns
+concert
+concerted
+concertedly
+concertedness
+concerts
+concession
+concession's
+concessioner
+concessions
+concise
+concisely
+conciseness
+concision
+concisions
+conclude
+concluded
+concluder
+concludes
+concluding
+conclusion
+conclusion's
+conclusions
+conclusive
+conclusively
+conclusiveness
+concomitant
+concomitantly
+concomitants
+concord
+concrete
+concreted
+concretely
+concreteness
+concretes
+concreting
+concretion
+concur
+concurred
+concurrence
+concurrencies
+concurrency
+concurrent
+concurrently
+concurring
+concurs
+condemn
+condemnation
+condemnations
+condemned
+condemner
+condemners
+condemning
+condemns
+condensation
+condense
+condensed
+condenser
+condensers
+condenses
+condensing
+condescend
+condescending
+condescendingly
+condescends
+condition
+conditional
+conditionally
+conditionals
+conditioned
+conditioner
+conditioners
+conditioning
+conditions
+condone
+condoned
+condoner
+condones
+condoning
+conducive
+conduciveness
+conduct
+conducted
+conducting
+conduction
+conductive
+conductively
+conductivities
+conductivity
+conductor
+conductor's
+conductors
+conducts
+conduit
+conduits
+cone
+cone's
+coned
+cones
+confederacy
+confederate
+confederates
+confederation
+confederations
+confederative
+confer
+conference
+conference's
+conferences
+conferencing
+conferred
+conferrer
+conferrer's
+conferrers
+conferring
+confers
+confess
+confessed
+confessedly
+confesses
+confessing
+confession
+confession's
+confessions
+confessor
+confessor's
+confessors
+confidant
+confidant's
+confidants
+confide
+confided
+confidence
+confidences
+confident
+confidential
+confidentiality
+confidentially
+confidentialness
+confidently
+confider
+confides
+confiding
+confidingly
+confidingness
+configurable
+configuration
+configuration's
+configurations
+configure
+configured
+configures
+configuring
+confine
+confined
+confinement
+confinement's
+confinements
+confiner
+confines
+confining
+confirm
+confirmation
+confirmation's
+confirmations
+confirmed
+confirmedly
+confirmedness
+confirming
+confirms
+confiscate
+confiscated
+confiscates
+confiscating
+confiscation
+confiscations
+conflict
+conflicted
+conflicting
+conflictingly
+conflictive
+conflicts
+conform
+conformed
+conformer
+conformers
+conforming
+conformity
+conforms
+confound
+confounded
+confoundedly
+confounder
+confounding
+confounds
+confront
+confrontation
+confrontation's
+confrontations
+confronted
+confronter
+confronters
+confronting
+confronts
+confuse
+confused
+confusedly
+confusedness
+confuser
+confusers
+confuses
+confusing
+confusingly
+confusion
+confusions
+congenial
+congenially
+congested
+congestion
+congratulate
+congratulated
+congratulates
+congratulation
+congratulations
+congregate
+congregated
+congregates
+congregating
+congregation
+congregations
+congress
+congress's
+congressed
+congresses
+congressing
+congressional
+congressionally
+congressman
+congruence
+congruent
+congruently
+coning
+conjecture
+conjectured
+conjecturer
+conjectures
+conjecturing
+conjoined
+conjunct
+conjuncted
+conjunction
+conjunction's
+conjunctions
+conjunctive
+conjunctively
+conjuncts
+conjure
+conjured
+conjurer
+conjurers
+conjures
+conjuring
+connect
+connected
+connectedly
+connectedness
+connecter
+connecters
+connecting
+connection
+connection's
+connections
+connective
+connective's
+connectively
+connectives
+connectivities
+connectivity
+connector
+connector's
+connectors
+connects
+connoisseur
+connoisseur's
+connoisseurs
+connote
+connoted
+connotes
+connoting
+conquer
+conquerable
+conquered
+conquerer
+conquerers
+conquering
+conqueror
+conqueror's
+conquerors
+conquers
+conquest
+conquest's
+conquests
+cons
+conscience
+conscience's
+consciences
+conscientious
+conscientiously
+conscientiousness
+conscious
+consciouses
+consciously
+consciousness
+consecrate
+consecrated
+consecrates
+consecrating
+consecration
+consecrations
+consecrative
+consecutive
+consecutively
+consecutiveness
+consensus
+consent
+consented
+consenter
+consenters
+consenting
+consentingly
+consents
+consequence
+consequence's
+consequences
+consequent
+consequential
+consequentialities
+consequentiality
+consequentially
+consequentialness
+consequently
+consequentness
+consequents
+conservation
+conservation's
+conservationist
+conservationist's
+conservationists
+conservations
+conservatism
+conservative
+conservatively
+conservativeness
+conservatives
+conserve
+conserved
+conserver
+conserves
+conserving
+consider
+considerable
+considerably
+considerate
+considerately
+considerateness
+consideration
+considerations
+considered
+considerer
+considering
+considers
+consign
+consigned
+consigning
+consigns
+consist
+consisted
+consistencies
+consistency
+consistent
+consistently
+consisting
+consists
+consolable
+consolation
+consolation's
+consolations
+console
+consoled
+consoler
+consolers
+consoles
+consolidate
+consolidated
+consolidates
+consolidating
+consolidation
+consolidations
+consoling
+consolingly
+consonant
+consonant's
+consonantly
+consonants
+consort
+consorted
+consorting
+consortium
+consorts
+conspicuous
+conspicuously
+conspicuousness
+conspiracies
+conspiracy
+conspiracy's
+conspirator
+conspirator's
+conspirators
+conspire
+conspired
+conspires
+conspiring
+constable
+constable's
+constables
+constancy
+constant
+constantly
+constants
+constellation
+constellation's
+constellations
+consternation
+constituencies
+constituency
+constituency's
+constituent
+constituent's
+constituently
+constituents
+constitute
+constituted
+constitutes
+constituting
+constitution
+constitutional
+constitutionality
+constitutionally
+constitutions
+constitutive
+constitutively
+constrain
+constrained
+constrainedly
+constraining
+constrains
+constraint
+constraint's
+constraints
+construct
+constructed
+constructibility
+constructible
+constructing
+construction
+construction's
+constructions
+constructive
+constructively
+constructiveness
+constructor
+constructor's
+constructors
+constructs
+construe
+construed
+construes
+construing
+consul
+consul's
+consulate
+consulate's
+consulates
+consuls
+consult
+consultant
+consultant's
+consultants
+consultation
+consultation's
+consultations
+consultative
+consulted
+consulter
+consulting
+consultive
+consults
+consumable
+consumables
+consume
+consumed
+consumedly
+consumer
+consumer's
+consumers
+consumes
+consuming
+consumingly
+consummate
+consummated
+consummately
+consummates
+consummating
+consummation
+consummations
+consummative
+consumption
+consumption's
+consumptions
+consumptive
+consumptively
+contact
+contacted
+contacting
+contacts
+contagion
+contagious
+contagiously
+contagiousness
+contain
+containable
+contained
+container
+containers
+containing
+containment
+containment's
+containments
+contains
+contaminate
+contaminated
+contaminates
+contaminating
+contamination
+contaminations
+contaminative
+contemplate
+contemplated
+contemplates
+contemplating
+contemplation
+contemplations
+contemplative
+contemplatively
+contemplativeness
+contemporaneous
+contemporaneously
+contemporaneousness
+contemporaries
+contemporariness
+contemporary
+contempt
+contemptible
+contemptibleness
+contemptuous
+contemptuously
+contemptuousness
+contend
+contended
+contender
+contenders
+contending
+contends
+content
+contented
+contentedly
+contentedness
+contenting
+contention
+contention's
+contentions
+contently
+contentment
+contents
+contest
+contestable
+contested
+contester
+contesters
+contesting
+contests
+context
+context's
+contexts
+contextual
+contextually
+contiguity
+contiguous
+contiguously
+contiguousness
+continent
+continent's
+continental
+continentally
+continently
+continents
+contingencies
+contingency
+contingency's
+contingent
+contingent's
+contingently
+contingents
+continual
+continually
+continuance
+continuance's
+continuances
+continuation
+continuation's
+continuations
+continue
+continued
+continuer
+continues
+continuing
+continuities
+continuity
+continuous
+continuously
+continuousness
+continuum
+contour
+contour's
+contoured
+contouring
+contours
+contract
+contracted
+contracting
+contraction
+contraction's
+contractions
+contractive
+contractor
+contractor's
+contractors
+contracts
+contractual
+contractually
+contradict
+contradicted
+contradicting
+contradiction
+contradiction's
+contradictions
+contradictoriness
+contradictory
+contradicts
+contradistinction
+contradistinctions
+contrapositive
+contrapositives
+contraption
+contraption's
+contraptions
+contrariness
+contrary
+contrast
+contrasted
+contraster
+contrasters
+contrasting
+contrastingly
+contrastive
+contrastively
+contrasts
+contribute
+contributed
+contributer
+contributers
+contributes
+contributing
+contribution
+contributions
+contributive
+contributively
+contributor
+contributor's
+contributorily
+contributors
+contributory
+contrivance
+contrivance's
+contrivances
+contrive
+contrived
+contriver
+contrives
+contriving
+control
+control's
+controllability
+controllable
+controllably
+controlled
+controller
+controller's
+controllers
+controlling
+controls
+controversial
+controversially
+controversies
+controversy
+controversy's
+conundrum
+conundrum's
+conundrums
+convalescence
+convene
+convened
+convener
+conveners
+convenes
+convenience
+convenience's
+conveniences
+convenient
+conveniently
+convening
+convent
+convent's
+convention
+convention's
+conventional
+conventionally
+conventions
+convents
+converge
+converged
+convergence
+convergences
+convergent
+converges
+converging
+conversant
+conversantly
+conversation
+conversation's
+conversational
+conversationally
+conversations
+converse
+conversed
+conversely
+converses
+conversing
+conversion
+conversioning
+conversions
+convert
+converted
+converter
+converters
+convertibility
+convertible
+convertibleness
+converting
+converts
+convex
+convey
+conveyance
+conveyance's
+conveyanced
+conveyancer
+conveyancers
+conveyances
+conveyancing
+conveyed
+conveyer
+conveyers
+conveying
+conveys
+convict
+convicted
+convicting
+conviction
+conviction's
+convictions
+convictive
+convicts
+convince
+convinced
+convincer
+convincers
+convinces
+convincing
+convincingly
+convincingness
+convoluted
+convoy
+convoyed
+convoying
+convoys
+convulsion
+convulsion's
+convulsions
+coo
+cooing
+cook
+cook's
+cooked
+cooker
+cookers
+cookery
+cookie
+cookie's
+cookies
+cooking
+cooks
+cooky
+cool
+cooled
+cooler
+cooler's
+coolers
+coolest
+coolie
+coolie's
+coolies
+cooling
+coolings
+coolly
+coolness
+coolnesses
+cools
+coon
+coon's
+coons
+coop
+cooped
+cooper
+cooperate
+cooperated
+cooperates
+cooperating
+cooperation
+cooperations
+cooperative
+cooperatively
+cooperativeness
+cooperatives
+cooperator
+cooperator's
+cooperators
+coopered
+coopering
+coopers
+coops
+coordinate
+coordinated
+coordinately
+coordinateness
+coordinates
+coordinating
+coordination
+coordinations
+coordinative
+coordinator
+coordinator's
+coordinators
+cop
+cop's
+cope
+coped
+coper
+copes
+copied
+copier
+copiers
+copies
+coping
+copings
+copious
+copiously
+copiousness
+copper
+copper's
+coppered
+coppering
+coppers
+cops
+copse
+copses
+copy
+copying
+copyright
+copyright's
+copyrighted
+copyrighter
+copyrighters
+copyrighting
+copyrights
+coral
+cord
+corded
+corder
+cordial
+cordially
+cordialness
+cording
+cords
+core
+cored
+corer
+corers
+cores
+coring
+cork
+corked
+corker
+corkers
+corking
+corks
+cormorant
+cormorants
+corn
+corned
+corner
+cornered
+cornering
+corners
+cornerstone
+cornerstone's
+cornerstones
+cornfield
+cornfield's
+cornfields
+corning
+corns
+corollaries
+corollary
+corollary's
+coronaries
+coronary
+coronation
+coronet
+coronet's
+coroneted
+coronets
+coroutine
+coroutine's
+coroutines
+corporal
+corporal's
+corporally
+corporals
+corporate
+corporately
+corporation
+corporation's
+corporations
+corporative
+corps
+corpse
+corpse's
+corpses
+corpus
+correct
+correctable
+corrected
+correcting
+correction
+corrections
+corrective
+correctively
+correctiveness
+correctives
+correctly
+correctness
+corrector
+corrects
+correlate
+correlated
+correlates
+correlating
+correlation
+correlations
+correlative
+correlatively
+correspond
+corresponded
+correspondence
+correspondence's
+correspondences
+correspondent
+correspondent's
+correspondents
+corresponding
+correspondingly
+corresponds
+corridor
+corridor's
+corridors
+corroborate
+corroborated
+corroborates
+corroborating
+corroboration
+corroborations
+corroborative
+corroboratively
+corrosion
+corrosions
+corrupt
+corrupted
+corrupter
+corrupting
+corruption
+corruptive
+corruptively
+corruptly
+corrupts
+corset
+corsets
+cosine
+cosines
+cosmetic
+cosmetics
+cosmology
+cosmopolitan
+cost
+costed
+costing
+costive
+costively
+costiveness
+costlier
+costliness
+costly
+costs
+costume
+costumed
+costumer
+costumers
+costumes
+costuming
+cot
+cot's
+cots
+cottage
+cottager
+cottagers
+cottages
+cotton
+cottoned
+cottoning
+cottons
+cotyledon
+cotyledon's
+cotyledons
+couch
+couched
+couches
+couching
+cough
+coughed
+cougher
+coughing
+coughs
+could
+couldest
+couldn't
+council
+council's
+councillor
+councillor's
+councillors
+councils
+counsel
+counsel's
+counsels
+count
+countable
+countably
+counted
+countenance
+countenancer
+counter
+counteract
+counteracted
+counteracting
+counteractive
+counteracts
+counterclockwise
+countered
+counterexample
+counterexamples
+counterfeit
+counterfeited
+counterfeiter
+counterfeiting
+counterfeits
+countering
+countermeasure
+countermeasure's
+countermeasures
+counterpart
+counterpart's
+counterparts
+counterpoint
+counterpointing
+counterproductive
+counterrevolution
+counters
+countess
+counties
+counting
+countless
+countlessly
+countries
+country
+country's
+countryman
+countryside
+counts
+county
+county's
+couple
+couple's
+coupled
+coupler
+couplers
+couples
+coupling
+couplings
+coupon
+coupon's
+coupons
+courage
+courageous
+courageously
+courageousness
+courier
+courier's
+couriers
+course
+coursed
+courser
+courses
+coursing
+court
+courted
+courteous
+courteously
+courteousness
+courter
+courters
+courtesies
+courtesy
+courtesy's
+courthouse
+courthouse's
+courthouses
+courtier
+courtier's
+courtiers
+courting
+courtliness
+courtly
+courtroom
+courtroom's
+courtrooms
+courts
+courtship
+courtyard
+courtyard's
+courtyards
+cousin
+cousin's
+cousins
+cove
+covenant
+covenant's
+covenanted
+covenanter
+covenanting
+covenants
+cover
+coverable
+coverage
+covered
+coverer
+covering
+coverings
+coverlet
+coverlet's
+coverlets
+covers
+covert
+covertly
+covertness
+coves
+covet
+coveted
+coveter
+coveting
+covetingly
+covetous
+covetously
+covetousness
+covets
+coving
+cow
+coward
+cowardice
+cowardliness
+cowardly
+cowards
+cowboy
+cowboy's
+cowboys
+cowed
+cowedly
+cower
+cowered
+cowerer
+cowerers
+cowering
+coweringly
+cowers
+cowgirl
+cowgirl's
+cowgirls
+cowing
+cowl
+cowled
+cowling
+cowls
+cows
+cowslip
+cowslip's
+cowslips
+coyote
+coyote's
+coyotes
+cozier
+cozies
+coziness
+cozy
+crab
+crab's
+crabs
+crack
+cracked
+cracker
+crackers
+cracking
+crackle
+crackled
+crackles
+crackling
+crackly
+cracks
+cradle
+cradled
+cradler
+cradles
+cradling
+craft
+crafted
+crafter
+craftier
+craftiness
+crafting
+crafts
+craftsman
+crafty
+crag
+crag's
+crags
+cram
+cramp
+cramp's
+cramped
+cramper
+cramps
+crams
+cranberries
+cranberry
+cranberry's
+crane
+crane's
+craned
+cranes
+craning
+crank
+cranked
+crankier
+crankiest
+crankily
+crankiness
+cranking
+cranks
+cranky
+crap
+craping
+craps
+crash
+crashed
+crasher
+crashers
+crashes
+crashing
+crate
+crater
+cratered
+craters
+crates
+crating
+cravat
+cravat's
+cravats
+crave
+craved
+craven
+cravenly
+cravenness
+craver
+craves
+craving
+crawl
+crawled
+crawler
+crawlers
+crawling
+crawls
+craze
+crazed
+crazes
+crazier
+craziest
+crazily
+craziness
+crazing
+crazy
+creak
+creaked
+creaking
+creaks
+cream
+creamed
+creamer
+creamers
+creaminess
+creaming
+creams
+creamy
+crease
+creased
+creaser
+creases
+creasing
+create
+created
+creates
+creating
+creation
+creations
+creative
+creatively
+creativeness
+creativity
+creator
+creator's
+creators
+creature
+creature's
+creatureliness
+creaturely
+creatures
+credence
+credibility
+credible
+credibly
+credit
+creditable
+creditableness
+creditably
+credited
+crediting
+creditor
+creditor's
+creditors
+credits
+credulity
+credulous
+credulously
+credulousness
+creed
+creed's
+creeds
+creek
+creek's
+creeks
+creep
+creeper
+creepers
+creeping
+creeps
+cremate
+cremated
+cremates
+cremating
+cremation
+cremations
+crepe
+crept
+crescent
+crescent's
+crescents
+crest
+crested
+cresting
+crests
+cretin
+cretins
+crevice
+crevice's
+crevices
+crew
+crewed
+crewing
+crews
+crib
+crib's
+cribs
+cricket
+cricket's
+cricketer
+cricketing
+crickets
+cried
+crier
+criers
+cries
+crime
+crime's
+crimes
+criminal
+criminally
+criminals
+crimson
+crimsoning
+cringe
+cringed
+cringer
+cringes
+cringing
+cripple
+crippled
+crippler
+cripples
+crippling
+crises
+crisis
+crisp
+crisper
+crisply
+crispness
+crisps
+criteria
+criterion
+critic
+critic's
+critical
+critically
+criticalness
+criticism
+criticism's
+criticisms
+critics
+critique
+critiqued
+critiques
+critiquing
+critter
+critter's
+critters
+croak
+croaked
+croaker
+croakers
+croaking
+croaks
+crochet
+crocheted
+crocheter
+crocheting
+crochets
+crook
+crooked
+crookedly
+crookedness
+crooks
+crop
+crop's
+cropped
+cropper
+cropper's
+croppers
+cropping
+crops
+cross
+crossable
+crossbar
+crossbar's
+crossbars
+crossed
+crosser
+crossers
+crosses
+crossing
+crossings
+crossly
+crossover
+crossover's
+crossovers
+crossword
+crossword's
+crosswords
+crouch
+crouched
+crouches
+crouching
+crow
+crowd
+crowded
+crowdedness
+crowder
+crowding
+crowds
+crowed
+crowing
+crown
+crowned
+crowner
+crowning
+crowns
+crows
+crucial
+crucially
+crucification
+crucified
+crucifies
+crucify
+crucifying
+crude
+crudely
+crudeness
+cruder
+crudest
+cruel
+crueler
+cruelest
+cruelly
+cruelness
+cruelty
+cruise
+cruised
+cruiser
+cruisers
+cruises
+cruising
+crumb
+crumble
+crumbled
+crumbles
+crumblier
+crumbliness
+crumbling
+crumblings
+crumbly
+crumbs
+crumple
+crumpled
+crumples
+crumpling
+crunch
+crunched
+cruncher
+crunchers
+crunches
+crunchier
+crunchiest
+crunchiness
+crunching
+crunchy
+crusade
+crusaded
+crusader
+crusaders
+crusades
+crusading
+crush
+crushable
+crushed
+crusher
+crushers
+crushes
+crushing
+crushingly
+crust
+crust's
+crustacean
+crustacean's
+crustaceans
+crusted
+crusting
+crusts
+crutch
+crutch's
+crutched
+crutches
+crux
+crux's
+cruxes
+cry
+crying
+cryptanalysis
+cryptic
+cryptographic
+cryptography
+cryptology
+crystal
+crystal's
+crystalline
+crystals
+cub
+cub's
+cube
+cubed
+cuber
+cubes
+cubic
+cubicly
+cubics
+cubing
+cubs
+cuckoo
+cuckoo's
+cuckoos
+cucumber
+cucumber's
+cucumbers
+cuddle
+cuddled
+cuddles
+cuddling
+cudgel
+cudgel's
+cudgels
+cue
+cued
+cues
+cuff
+cuff's
+cuffed
+cuffing
+cuffs
+cuing
+cull
+culled
+culler
+culling
+culls
+culminate
+culminated
+culminates
+culminating
+culmination
+culpability
+culprit
+culprit's
+culprits
+cult
+cult's
+cultivate
+cultivated
+cultivates
+cultivating
+cultivation
+cultivations
+cultivator
+cultivator's
+cultivators
+cults
+cultural
+culturally
+culture
+cultured
+cultures
+culturing
+cumbersome
+cumbersomely
+cumbersomeness
+cumulative
+cumulatively
+cunning
+cunningly
+cunningness
+cup
+cup's
+cupboard
+cupboard's
+cupboards
+cupful
+cupfuls
+cupped
+cupping
+cups
+cur
+curable
+curableness
+curably
+curb
+curbed
+curbing
+curbs
+curds
+cure
+cured
+curer
+cures
+curfew
+curfew's
+curfews
+curing
+curiosities
+curiosity
+curiosity's
+curious
+curiouser
+curiousest
+curiously
+curiousness
+curl
+curled
+curler
+curlers
+curlier
+curliness
+curling
+curls
+curly
+currant
+currant's
+currants
+currencies
+currency
+currency's
+current
+currently
+currentness
+currents
+curricular
+curriculum
+curriculum's
+curriculums
+curried
+currier
+curries
+curry
+currying
+curs
+curse
+cursed
+cursedly
+cursedness
+curses
+cursing
+cursive
+cursively
+cursiveness
+cursor
+cursor's
+cursorily
+cursoriness
+cursors
+cursory
+curt
+curtail
+curtailed
+curtailer
+curtailing
+curtails
+curtain
+curtained
+curtaining
+curtains
+curtly
+curtness
+curtsied
+curtsies
+curtsy
+curtsy's
+curtsying
+curvature
+curvatures
+curve
+curved
+curves
+curving
+cushion
+cushioned
+cushioning
+cushions
+cusp
+cusp's
+cusps
+cuss
+cussed
+cussedly
+cussedness
+cusser
+cusses
+custard
+custodian
+custodian's
+custodians
+custodies
+custody
+custom
+customarily
+customariness
+customary
+customer
+customer's
+customers
+customs
+cut
+cut's
+cute
+cutely
+cuteness
+cuter
+cutes
+cutest
+cutoff
+cutoffs
+cuts
+cutter
+cutter's
+cutters
+cutting
+cuttingly
+cuttings
+cybernetic
+cybernetics
+cycle
+cycled
+cycler
+cycles
+cyclic
+cyclically
+cyclicly
+cycling
+cycloid
+cycloid's
+cycloidal
+cycloids
+cyclone
+cyclone's
+cyclones
+cylinder
+cylinder's
+cylindered
+cylindering
+cylinders
+cylindrical
+cylindrically
+cymbal
+cymbal's
+cymbals
+cynical
+cynically
+cypress
+cyst
+cysts
+cytology
+czar
+dabble
+dabbled
+dabbler
+dabblers
+dabbles
+dabbling
+dad
+dad's
+daddies
+daddy
+dads
+daemon
+daemon's
+daemons
+daffodil
+daffodil's
+daffodils
+dagger
+daggers
+dailies
+daily
+daintier
+dainties
+daintily
+daintiness
+dainty
+dairies
+dairy
+dairying
+daisies
+daisy
+daisy's
+dale
+dale's
+dales
+daleth
+dam
+dam's
+damage
+damaged
+damager
+damagers
+damages
+damaging
+damagingly
+damask
+dame
+damed
+damn
+damnation
+damned
+damneder
+damnedest
+damning
+damningly
+damns
+damp
+damped
+dampen
+dampened
+dampener
+dampening
+dampens
+damper
+dampers
+damping
+damply
+dampness
+damps
+dams
+damsel
+damsel's
+damsels
+dance
+danced
+dancer
+dancers
+dances
+dancing
+dandelion
+dandelion's
+dandelions
+dandier
+dandies
+dandy
+danger
+danger's
+dangerous
+dangerously
+dangerousness
+dangers
+dangle
+dangled
+dangler
+dangler's
+danglers
+dangles
+dangling
+danglingly
+dare
+dared
+darer
+darers
+dares
+daring
+daringly
+daringness
+dark
+darken
+darkened
+darkener
+darkeners
+darkening
+darker
+darkest
+darkly
+darkness
+darks
+darling
+darling's
+darlingly
+darlingness
+darlings
+darn
+darned
+darner
+darning
+darns
+dart
+darted
+darter
+darting
+darts
+dash
+dashed
+dasher
+dashers
+dashes
+dashing
+dashingly
+data
+database
+database's
+databases
+date
+dated
+datedly
+datedness
+dater
+dates
+dating
+dative
+datum
+datums
+daughter
+daughter's
+daughterly
+daughters
+daunt
+daunted
+daunting
+dauntless
+dauntlessly
+dauntlessness
+daunts
+dawn
+dawned
+dawning
+dawns
+day
+day's
+daybreak
+daybreaks
+daydream
+daydreamed
+daydreamer
+daydreamers
+daydreaming
+daydreams
+daylight
+daylight's
+daylights
+days
+daytime
+daytimes
+daze
+dazed
+dazedness
+dazes
+dazing
+dazzle
+dazzled
+dazzler
+dazzlers
+dazzles
+dazzling
+dazzlingly
+deacon
+deacon's
+deacons
+dead
+deaden
+deadened
+deadener
+deadening
+deadeningly
+deadens
+deadlier
+deadliest
+deadline
+deadline's
+deadlines
+deadliness
+deadlock
+deadlocked
+deadlocking
+deadlocks
+deadly
+deadness
+deaf
+deafen
+deafened
+deafening
+deafeningly
+deafens
+deafer
+deafest
+deafly
+deafness
+deal
+dealer
+dealers
+dealing
+dealings
+deallocate
+deallocated
+deallocates
+deallocating
+deallocation
+deallocation's
+deallocations
+deallocator
+deals
+dealt
+dean
+dean's
+deans
+dear
+dearer
+dearest
+dearly
+dearness
+dears
+dearth
+dearths
+death
+deathly
+deaths
+debatable
+debate
+debated
+debater
+debaters
+debates
+debating
+debilitate
+debilitated
+debilitates
+debilitating
+debilitation
+debris
+debt
+debt's
+debtor
+debtors
+debts
+debug
+debugged
+debugger
+debugger's
+debuggers
+debugging
+debugs
+decade
+decade's
+decadence
+decadent
+decadently
+decades
+decay
+decayed
+decayer
+decaying
+decays
+decease
+deceased
+deceases
+deceasing
+deceit
+deceitful
+deceitfully
+deceitfulness
+deceive
+deceived
+deceiver
+deceivers
+deceives
+deceiving
+deceivingly
+decelerate
+decelerated
+decelerates
+decelerating
+deceleration
+decelerations
+decencies
+decency
+decency's
+decent
+decently
+deception
+deception's
+deceptions
+deceptive
+deceptively
+deceptiveness
+decidability
+decidable
+decide
+decided
+decidedly
+decidedness
+decider
+decides
+deciding
+decimal
+decimally
+decimals
+decimate
+decimated
+decimates
+decimating
+decimation
+decipher
+deciphered
+decipherer
+decipherers
+deciphering
+deciphers
+decision
+decision's
+decisions
+decisive
+decisively
+decisiveness
+deck
+decked
+decker
+decking
+deckings
+decks
+declaration
+declaration's
+declarations
+declarative
+declaratively
+declaratives
+declare
+declared
+declarer
+declarers
+declares
+declaring
+declination
+declination's
+declinations
+decline
+declined
+decliner
+decliners
+declines
+declining
+decode
+decoded
+decoder
+decoders
+decodes
+decoding
+decodings
+decompile
+decompiled
+decompiler
+decompilers
+decompiles
+decompiling
+decomposability
+decomposable
+decompose
+decomposed
+decomposer
+decomposes
+decomposing
+decomposition
+decomposition's
+decompositions
+decompression
+decorate
+decorated
+decorates
+decorating
+decoration
+decorations
+decorative
+decoratively
+decorativeness
+decorum
+decorums
+decouple
+decoupled
+decoupler
+decouples
+decoupling
+decoy
+decoy's
+decoys
+decrease
+decreased
+decreases
+decreasing
+decreasingly
+decree
+decreed
+decreeing
+decreer
+decrees
+decrement
+decremented
+decrementing
+decrements
+dedicate
+dedicated
+dedicatedly
+dedicates
+dedicating
+dedication
+dedications
+dedicative
+deduce
+deduced
+deducer
+deduces
+deducible
+deducing
+deduct
+deducted
+deducting
+deduction
+deduction's
+deductions
+deductive
+deductively
+deducts
+deed
+deeded
+deeding
+deeds
+deem
+deemed
+deeming
+deems
+deep
+deepen
+deepened
+deepening
+deepens
+deeper
+deepest
+deeply
+deepness
+deeps
+deer
+deers
+default
+defaulted
+defaulter
+defaulting
+defaults
+defeat
+defeated
+defeating
+defeatism
+defeatist
+defeatists
+defeats
+defect
+defected
+defecting
+defection
+defection's
+defections
+defective
+defectively
+defectiveness
+defectives
+defects
+defend
+defendant
+defendant's
+defendants
+defended
+defender
+defenders
+defending
+defends
+defenestrate
+defenestrated
+defenestrates
+defenestrating
+defenestration
+defenestrations
+defensive
+defensively
+defensiveness
+defer
+deference
+deferment
+deferment's
+deferments
+deferrable
+deferred
+deferrer
+deferrer's
+deferrers
+deferring
+defers
+defiance
+defiances
+defiant
+defiantly
+deficiencies
+deficiency
+deficient
+deficiently
+deficit
+deficit's
+deficits
+defied
+defier
+defies
+defile
+defiled
+defiler
+defiles
+defiling
+definable
+define
+defined
+definer
+definers
+defines
+defining
+definite
+definitely
+definiteness
+definition
+definition's
+definitional
+definitions
+definitive
+definitively
+definitiveness
+deformation
+deformation's
+deformations
+deformed
+deformities
+deformity
+deformity's
+deftly
+defy
+defying
+defyingly
+degenerate
+degenerated
+degenerately
+degenerateness
+degenerates
+degenerating
+degeneration
+degenerative
+degradable
+degradation
+degradation's
+degradations
+degrade
+degraded
+degradedly
+degradedness
+degrader
+degrades
+degrading
+degradingly
+degree
+degree's
+degreed
+degrees
+deign
+deigned
+deigning
+deigns
+deities
+deity
+deity's
+dejected
+dejectedly
+dejectedness
+delay
+delayed
+delayer
+delayers
+delaying
+delays
+delegate
+delegated
+delegates
+delegating
+delegation
+delegations
+delete
+deleted
+deleter
+deletes
+deleting
+deletion
+deletions
+deliberate
+deliberated
+deliberately
+deliberateness
+deliberates
+deliberating
+deliberation
+deliberations
+deliberative
+deliberatively
+deliberativeness
+deliberator
+deliberator's
+deliberators
+delicacies
+delicacy
+delicacy's
+delicate
+delicately
+delicateness
+delicates
+delicious
+deliciouses
+deliciously
+deliciousness
+delight
+delighted
+delightedly
+delightedness
+delighter
+delightful
+delightfully
+delightfulness
+delighting
+delights
+delimit
+delimited
+delimiter
+delimiters
+delimiting
+delimits
+delineate
+delineated
+delineates
+delineating
+delineation
+delineations
+delineative
+delinquency
+delinquent
+delinquent's
+delinquently
+delinquents
+delirious
+deliriously
+deliriousness
+deliver
+deliverable
+deliverables
+deliverance
+delivered
+deliverer
+deliverers
+deliveries
+delivering
+delivers
+delivery
+delivery's
+dell
+dell's
+dells
+delta
+delta's
+deltas
+delude
+deluded
+deluder
+deludes
+deluding
+deludingly
+deluge
+deluged
+deluges
+deluging
+delusion
+delusion's
+delusions
+delve
+delved
+delver
+delves
+delving
+demand
+demanded
+demander
+demanding
+demandingly
+demands
+demise
+demised
+demises
+demising
+demo
+democracies
+democracy
+democracy's
+democrat
+democrat's
+democratic
+democratically
+democrats
+demodulate
+demodulated
+demodulates
+demodulating
+demodulation
+demodulation's
+demodulations
+demodulator
+demodulator's
+demodulators
+demographic
+demographics
+demolish
+demolished
+demolisher
+demolishes
+demolishing
+demolition
+demolitions
+demon
+demon's
+demoness
+demons
+demonstrable
+demonstrableness
+demonstrate
+demonstrated
+demonstrates
+demonstrating
+demonstration
+demonstrations
+demonstrative
+demonstratively
+demonstrativeness
+demonstrator
+demonstrator's
+demonstrators
+demos
+demur
+demurs
+den
+den's
+deniable
+denial
+denial's
+denials
+denied
+denier
+denies
+denigrate
+denigrated
+denigrates
+denigrating
+denigration
+denigrative
+denizen
+denizens
+denomination
+denomination's
+denominations
+denominator
+denominator's
+denominators
+denotable
+denotation
+denotation's
+denotational
+denotationally
+denotations
+denotative
+denote
+denoted
+denotes
+denoting
+denounce
+denounced
+denouncer
+denouncers
+denounces
+denouncing
+dens
+dense
+densely
+denseness
+denser
+densest
+densities
+density
+density's
+dent
+dental
+dentally
+dentals
+dented
+denting
+dentist
+dentist's
+dentists
+dents
+deny
+denying
+denyingly
+depart
+departed
+departing
+department
+department's
+departmental
+departmentally
+departments
+departs
+departure
+departure's
+departures
+depend
+dependability
+dependable
+dependableness
+dependably
+depended
+dependence
+dependences
+dependencies
+dependency
+dependent
+dependently
+dependents
+depending
+depends
+depict
+depicted
+depicter
+depicting
+depicts
+deplete
+depleted
+depletes
+depleting
+depletion
+depletions
+depletive
+deplorable
+deplorableness
+deplore
+deplored
+deplorer
+deplores
+deploring
+deploringly
+deploy
+deployed
+deploying
+deployment
+deployment's
+deployments
+deploys
+deport
+deportation
+deported
+deportee
+deportee's
+deportees
+deporting
+deportment
+deports
+depose
+deposed
+deposes
+deposing
+deposit
+deposited
+depositing
+deposition
+deposition's
+depositions
+depositor
+depositor's
+depositors
+deposits
+depot
+depot's
+depots
+deprave
+depraved
+depravedly
+depravedness
+depraver
+depraves
+depraving
+depreciate
+depreciated
+depreciates
+depreciating
+depreciatingly
+depreciation
+depreciations
+depreciative
+depreciatively
+depress
+depressed
+depresses
+depressing
+depressingly
+depression
+depression's
+depressions
+depressive
+depressively
+deprivation
+deprivation's
+deprivations
+deprive
+deprived
+deprives
+depriving
+depth
+depths
+deputies
+deputy
+deputy's
+dequeue
+dequeued
+dequeues
+dequeuing
+derail
+derailed
+derailing
+derails
+derbies
+derby
+dereference
+dereferenced
+dereferencer
+dereferencers
+dereferences
+dereferencing
+deride
+derided
+derider
+derides
+deriding
+deridingly
+derision
+derivable
+derivation
+derivation's
+derivations
+derivative
+derivative's
+derivatively
+derivativeness
+derivatives
+derive
+derived
+deriver
+derives
+deriving
+descend
+descendant
+descendant's
+descendants
+descended
+descender
+descenders
+descending
+descends
+descent
+descent's
+descents
+describable
+describe
+described
+describer
+describers
+describes
+describing
+descried
+description
+description's
+descriptions
+descriptive
+descriptively
+descriptiveness
+descriptives
+descriptor
+descriptor's
+descriptors
+descry
+descrying
+desert
+deserted
+deserter
+deserters
+deserting
+desertion
+desertions
+deserts
+deserve
+deserved
+deservedly
+deservedness
+deserver
+deserves
+deserving
+deservingly
+deservings
+desiderata
+desideratum
+design
+designate
+designated
+designates
+designating
+designation
+designations
+designative
+designator
+designator's
+designators
+designed
+designedly
+designer
+designer's
+designers
+designing
+designs
+desirability
+desirable
+desirableness
+desirably
+desire
+desired
+desirer
+desires
+desiring
+desirous
+desirously
+desirousness
+desk
+desk's
+desks
+desktop
+desolate
+desolated
+desolately
+desolateness
+desolater
+desolates
+desolating
+desolatingly
+desolation
+desolations
+despair
+despaired
+despairer
+despairing
+despairingly
+despairs
+despatch
+despatched
+desperate
+desperately
+desperateness
+desperation
+despise
+despised
+despiser
+despises
+despising
+despite
+despited
+despot
+despot's
+despotic
+despots
+dessert
+dessert's
+desserts
+destination
+destination's
+destinations
+destine
+destined
+destinies
+destining
+destiny
+destiny's
+destitute
+destituteness
+destitution
+destroy
+destroyed
+destroyer
+destroyer's
+destroyers
+destroying
+destroys
+destruction
+destruction's
+destructions
+destructive
+destructively
+destructiveness
+detach
+detached
+detachedly
+detachedness
+detacher
+detaches
+detaching
+detachment
+detachment's
+detachments
+detail
+detailed
+detailedly
+detailedness
+detailer
+detailing
+details
+detain
+detained
+detainer
+detaining
+detains
+detect
+detectable
+detectably
+detected
+detecting
+detection
+detection's
+detections
+detective
+detectives
+detector
+detector's
+detectors
+detects
+detention
+deteriorate
+deteriorated
+deteriorates
+deteriorating
+deterioration
+deteriorative
+determinable
+determinableness
+determinacy
+determinant
+determinant's
+determinants
+determinate
+determinately
+determinateness
+determination
+determinations
+determinative
+determinatively
+determinativeness
+determine
+determined
+determinedly
+determinedness
+determiner
+determiners
+determines
+determining
+determinism
+deterministic
+deterministically
+detest
+detestable
+detestableness
+detested
+detesting
+detests
+detonate
+detonated
+detonates
+detonating
+detonation
+detonative
+detract
+detracted
+detracting
+detractive
+detractively
+detractor
+detractor's
+detractors
+detracts
+detriment
+detriments
+devastate
+devastated
+devastates
+devastating
+devastatingly
+devastation
+devastations
+devastative
+develop
+developed
+developer
+developer's
+developers
+developing
+development
+development's
+developmental
+developmentally
+developments
+develops
+deviant
+deviant's
+deviantly
+deviants
+deviate
+deviated
+deviates
+deviating
+deviation
+deviations
+device
+device's
+devices
+devil
+devil's
+devilish
+devilishly
+devilishness
+devils
+devise
+devised
+deviser
+devises
+devising
+devisings
+devision
+devisions
+devoid
+devote
+devoted
+devotedly
+devotee
+devotee's
+devotees
+devotes
+devoting
+devotion
+devotions
+devour
+devoured
+devourer
+devouring
+devours
+devout
+devoutly
+devoutness
+dew
+dewdrop
+dewdrop's
+dewdrops
+dewed
+dewier
+dewiness
+dewing
+dews
+dewy
+dexterity
+diabetes
+diadem
+diagnosable
+diagnose
+diagnosed
+diagnoses
+diagnosing
+diagnosis
+diagnostic
+diagnostic's
+diagnostics
+diagonal
+diagonally
+diagonals
+diagram
+diagram's
+diagramed
+diagraming
+diagrammable
+diagrammatic
+diagrammatically
+diagrammed
+diagrammer
+diagrammer's
+diagrammers
+diagramming
+diagrams
+dial
+dial's
+dialect
+dialect's
+dialects
+dialog
+dialog's
+dialogs
+dialogue
+dialogue's
+dialogues
+dials
+diameter
+diameter's
+diameters
+diametrically
+diamond
+diamond's
+diamonds
+diaper
+diaper's
+diapered
+diapering
+diapers
+diaphragm
+diaphragm's
+diaphragms
+diaries
+diary
+diary's
+diatribe
+diatribe's
+diatribes
+dice
+dicer
+dices
+dichotomies
+dichotomy
+dicing
+dickens
+dicky
+dictate
+dictated
+dictates
+dictating
+dictation
+dictations
+dictator
+dictator's
+dictators
+dictatorship
+dictatorships
+diction
+dictionaries
+dictionary
+dictionary's
+dictions
+dictum
+dictum's
+dictums
+did
+didn't
+die
+died
+dielectric
+dielectric's
+dielectrics
+dies
+diet
+dieter
+dieters
+dietitian
+dietitian's
+dietitians
+diets
+differ
+differed
+difference
+difference's
+differenced
+differences
+differencing
+different
+differential
+differential's
+differentially
+differentials
+differentiate
+differentiated
+differentiates
+differentiating
+differentiation
+differentiations
+differentiators
+differently
+differentness
+differer
+differers
+differing
+differs
+difficult
+difficulties
+difficultly
+difficulty
+difficulty's
+diffuse
+diffused
+diffusely
+diffuseness
+diffuser
+diffusers
+diffuses
+diffusing
+diffusion
+diffusions
+diffusive
+diffusively
+diffusiveness
+dig
+digest
+digested
+digester
+digestible
+digesting
+digestion
+digestions
+digestive
+digestively
+digestiveness
+digests
+digger
+digger's
+diggers
+digging
+diggings
+digit
+digit's
+digital
+digitally
+digits
+dignified
+dignify
+dignities
+dignity
+digress
+digressed
+digresses
+digressing
+digression
+digression's
+digressions
+digressive
+digressively
+digressiveness
+digs
+dike
+dike's
+diker
+dikes
+diking
+dilate
+dilated
+dilatedly
+dilatedness
+dilates
+dilating
+dilation
+dilative
+dilemma
+dilemma's
+dilemmas
+diligence
+diligences
+diligent
+diligently
+diligentness
+dilute
+diluted
+dilutely
+diluteness
+diluter
+dilutes
+diluting
+dilution
+dilutions
+dilutive
+dim
+dime
+dime's
+dimension
+dimensional
+dimensionality
+dimensionally
+dimensioned
+dimensioning
+dimensions
+dimer
+dimers
+dimes
+diminish
+diminished
+diminishes
+diminishing
+diminution
+diminutive
+diminutively
+diminutiveness
+dimly
+dimmed
+dimmer
+dimmer's
+dimmers
+dimmest
+dimming
+dimness
+dimple
+dimpled
+dimples
+dimpling
+dims
+din
+dine
+dined
+diner
+diners
+dines
+dingier
+dinginess
+dingy
+dining
+dinner
+dinner's
+dinners
+dint
+diode
+diode's
+diodes
+dioxide
+dioxides
+dip
+diphtheria
+diploma
+diploma's
+diplomacy
+diplomas
+diplomat
+diplomat's
+diplomatic
+diplomatics
+diplomats
+dipped
+dipper
+dipper's
+dippers
+dipping
+dippings
+dips
+dire
+direct
+directed
+directing
+direction
+direction's
+directional
+directionality
+directionally
+directions
+directive
+directive's
+directives
+directly
+directness
+director
+director's
+directories
+directors
+directory
+directory's
+directs
+direly
+direness
+direr
+direst
+dirge
+dirge's
+dirged
+dirges
+dirging
+dirt
+dirt's
+dirtied
+dirtier
+dirties
+dirtiest
+dirtily
+dirtiness
+dirts
+dirty
+dirtying
+disabilities
+disability
+disability's
+disable
+disabled
+disabler
+disablers
+disables
+disabling
+disabuse
+disadvantage
+disadvantage's
+disadvantaged
+disadvantagedness
+disadvantages
+disadvantaging
+disagree
+disagreeable
+disagreeableness
+disagreed
+disagreeing
+disagreement
+disagreement's
+disagreements
+disagrees
+disallow
+disallowed
+disallowing
+disallows
+disambiguate
+disambiguated
+disambiguates
+disambiguating
+disambiguation
+disambiguations
+disappear
+disappearance
+disappearance's
+disappearances
+disappeared
+disappearing
+disappears
+disappoint
+disappointed
+disappointedly
+disappointing
+disappointingly
+disappointment
+disappointment's
+disappointments
+disappoints
+disapproval
+disapprove
+disapproved
+disapprover
+disapproves
+disapproving
+disapprovingly
+disarm
+disarmament
+disarmed
+disarmer
+disarmers
+disarming
+disarmingly
+disarms
+disassemble
+disassembled
+disassembler
+disassembler's
+disassemblers
+disassembles
+disassembling
+disaster
+disaster's
+disasters
+disastrous
+disastrously
+disband
+disbanded
+disbanding
+disbands
+disbelieve
+disbelieved
+disbeliever
+disbelievers
+disbelieves
+disbelieving
+disburse
+disbursed
+disbursement
+disbursement's
+disbursements
+disburser
+disburses
+disbursing
+disc
+disc's
+discard
+discarded
+discarder
+discarding
+discards
+discern
+discerned
+discerner
+discernibility
+discernible
+discernibly
+discerning
+discerningly
+discernment
+discerns
+discharge
+discharged
+discharger
+discharges
+discharging
+disciple
+disciple's
+disciples
+disciplinary
+discipline
+disciplined
+discipliner
+disciplines
+disciplining
+disclaim
+disclaimed
+disclaimer
+disclaimers
+disclaiming
+disclaims
+disclose
+disclosed
+discloser
+discloses
+disclosing
+disclosure
+disclosure's
+disclosures
+discomfort
+discomforting
+discomfortingly
+disconcert
+disconcerted
+disconcerting
+disconcertingly
+disconcerts
+disconnect
+disconnected
+disconnectedly
+disconnectedness
+disconnecter
+disconnecting
+disconnection
+disconnections
+disconnects
+discontent
+discontented
+discontentedly
+discontinuance
+discontinue
+discontinued
+discontinues
+discontinuing
+discontinuities
+discontinuity
+discontinuity's
+discontinuous
+discontinuously
+discord
+discords
+discount
+discounted
+discounter
+discounting
+discounts
+discourage
+discouraged
+discouragement
+discourager
+discourages
+discouraging
+discouragingly
+discourse
+discourse's
+discoursed
+discourser
+discourses
+discoursing
+discover
+discovered
+discoverer
+discoverers
+discoveries
+discovering
+discovers
+discovery
+discovery's
+discredit
+discredited
+discrediting
+discredits
+discreet
+discreetly
+discreetness
+discrepancies
+discrepancy
+discrepancy's
+discrete
+discretely
+discreteness
+discretion
+discretions
+discriminate
+discriminated
+discriminates
+discriminating
+discriminatingly
+discrimination
+discriminations
+discriminative
+discriminatory
+discs
+discuss
+discussed
+discusser
+discusses
+discussing
+discussion
+discussion's
+discussions
+disdain
+disdaining
+disdains
+disease
+diseased
+diseases
+diseasing
+disenfranchise
+disenfranchised
+disenfranchisement
+disenfranchisement's
+disenfranchisements
+disenfranchiser
+disenfranchises
+disenfranchising
+disengage
+disengaged
+disengages
+disengaging
+disentangle
+disentangled
+disentangler
+disentangles
+disentangling
+disfigure
+disfigured
+disfigures
+disfiguring
+disgorge
+disgorger
+disgrace
+disgraced
+disgraceful
+disgracefully
+disgracefulness
+disgracer
+disgraces
+disgracing
+disgruntled
+disguise
+disguised
+disguisedly
+disguiser
+disguises
+disguising
+disgust
+disgusted
+disgustedly
+disgusting
+disgustingly
+disgusts
+dish
+dishearten
+disheartening
+dishearteningly
+dished
+dishes
+dishing
+dishonest
+dishonestly
+dishwasher
+dishwashers
+disillusion
+disillusioned
+disillusioning
+disillusionment
+disillusionment's
+disillusionments
+disinterested
+disinterestedly
+disinterestedness
+disjoint
+disjointed
+disjointedly
+disjointedness
+disjointly
+disjointness
+disjunct
+disjunction
+disjunctions
+disjunctive
+disjunctively
+disjuncts
+disk
+disk's
+disked
+disking
+disks
+dislike
+disliked
+disliker
+dislikes
+disliking
+dislocate
+dislocated
+dislocates
+dislocating
+dislocation
+dislocations
+dislodge
+dislodged
+dislodges
+dislodging
+dismal
+dismally
+dismalness
+dismay
+dismayed
+dismaying
+dismayingly
+dismays
+dismiss
+dismissal
+dismissal's
+dismissals
+dismissed
+dismisser
+dismissers
+dismisses
+dismissing
+dismissive
+dismount
+dismounted
+dismounting
+dismounts
+disobedience
+disobey
+disobeyed
+disobeyer
+disobeying
+disobeys
+disorder
+disordered
+disorderedly
+disorderedness
+disorderliness
+disorderly
+disorders
+disown
+disowned
+disowning
+disowns
+disparate
+disparately
+disparateness
+disparities
+disparity
+disparity's
+dispatch
+dispatched
+dispatcher
+dispatchers
+dispatches
+dispatching
+dispel
+dispelled
+dispelling
+dispels
+dispensation
+dispense
+dispensed
+dispenser
+dispensers
+dispenses
+dispensing
+disperse
+dispersed
+dispersedly
+disperser
+disperses
+dispersing
+dispersion
+dispersions
+dispersive
+dispersively
+dispersiveness
+displace
+displaced
+displacement
+displacement's
+displacements
+displacer
+displaces
+displacing
+display
+displayed
+displayer
+displaying
+displays
+displease
+displeased
+displeasedly
+displeases
+displeasing
+displeasure
+disposable
+disposal
+disposal's
+disposals
+dispose
+disposed
+disposer
+disposes
+disposing
+disposition
+disposition's
+dispositions
+disprove
+disproved
+disproves
+disproving
+dispute
+disputed
+disputer
+disputers
+disputes
+disputing
+disqualification
+disqualified
+disqualifies
+disqualify
+disqualifying
+disquiet
+disquieting
+disquietingly
+disquietly
+disregard
+disregarded
+disregarding
+disregards
+disrupt
+disrupted
+disrupter
+disrupting
+disruption
+disruption's
+disruptions
+disruptive
+disruptively
+disruptiveness
+disrupts
+dissatisfaction
+dissatisfaction's
+dissatisfactions
+dissatisfied
+disseminate
+disseminated
+disseminates
+disseminating
+dissemination
+dissension
+dissension's
+dissensions
+dissent
+dissented
+dissenter
+dissenters
+dissenting
+dissents
+dissertation
+dissertation's
+dissertations
+disservice
+dissident
+dissident's
+dissidents
+dissimilar
+dissimilarities
+dissimilarity
+dissimilarity's
+dissimilarly
+dissipate
+dissipated
+dissipatedly
+dissipatedness
+dissipater
+dissipates
+dissipating
+dissipation
+dissipations
+dissipative
+dissociate
+dissociated
+dissociates
+dissociating
+dissociation
+dissociative
+dissolution
+dissolution's
+dissolutions
+dissolve
+dissolved
+dissolver
+dissolves
+dissolving
+dissonance
+dissonance's
+dissonances
+distal
+distally
+distance
+distanced
+distances
+distancing
+distant
+distantly
+distantness
+distaste
+distasteful
+distastefully
+distastefulness
+distastes
+distemper
+distill
+distillation
+distilled
+distiller
+distillers
+distilling
+distills
+distinct
+distinction
+distinction's
+distinctions
+distinctive
+distinctively
+distinctiveness
+distinctly
+distinctness
+distinguish
+distinguishable
+distinguished
+distinguisher
+distinguishes
+distinguishing
+distort
+distorted
+distorter
+distorting
+distortion
+distortion's
+distortions
+distorts
+distract
+distracted
+distractedly
+distracting
+distractingly
+distraction
+distraction's
+distractions
+distractive
+distracts
+distraught
+distraughtly
+distress
+distressed
+distresses
+distressing
+distressingly
+distribute
+distributed
+distributer
+distributes
+distributing
+distribution
+distribution's
+distributional
+distributions
+distributive
+distributively
+distributiveness
+distributivity
+distributor
+distributor's
+distributors
+district
+district's
+districted
+districting
+districts
+distrust
+distrusted
+distrusts
+disturb
+disturbance
+disturbance's
+disturbances
+disturbed
+disturber
+disturbing
+disturbingly
+disturbs
+ditch
+ditch's
+ditched
+ditcher
+ditches
+ditching
+divan
+divan's
+divans
+dive
+dived
+diver
+diverge
+diverged
+divergence
+divergence's
+divergences
+divergent
+divergently
+diverges
+diverging
+divers
+diverse
+diversely
+diverseness
+diversification
+diversified
+diversifier
+diversifies
+diversify
+diversifying
+diversion
+diversions
+diversities
+diversity
+divert
+diverted
+diverting
+diverts
+dives
+divest
+divested
+divesting
+divests
+divide
+divided
+dividend
+dividend's
+dividends
+divider
+dividers
+divides
+dividing
+divine
+divined
+divinely
+diviner
+divines
+diving
+divining
+divinities
+divinity
+divinity's
+division
+division's
+divisions
+divisor
+divisor's
+divisors
+divorce
+divorced
+divorces
+divorcing
+divulge
+divulged
+divulges
+divulging
+dizzied
+dizzier
+dizziness
+dizzy
+dizzying
+dizzyingly
+do
+dock
+docked
+docker
+docking
+docks
+doctor
+doctor's
+doctoral
+doctorate
+doctorate's
+doctorates
+doctored
+doctoring
+doctors
+doctrine
+doctrine's
+doctrines
+document
+document's
+documentaries
+documentary
+documentary's
+documentation
+documentation's
+documentations
+documented
+documenter
+documenters
+documenting
+documents
+dodge
+dodged
+dodger
+dodgers
+dodges
+dodging
+doer
+doers
+does
+doesn't
+dog
+dog's
+dogged
+doggedly
+doggedness
+dogging
+dogma
+dogma's
+dogmas
+dogmatism
+dogs
+doing
+doings
+dole
+doled
+doleful
+dolefully
+dolefulness
+doles
+doling
+doll
+doll's
+dollar
+dollars
+dollied
+dollies
+dolls
+dolly
+dolly's
+dollying
+dolphin
+dolphin's
+dolphins
+domain
+domain's
+domains
+dome
+domed
+domes
+domestic
+domestically
+domesticate
+domesticated
+domesticates
+domesticating
+domestication
+dominance
+dominant
+dominantly
+dominate
+dominated
+dominates
+dominating
+domination
+dominations
+dominative
+doming
+dominion
+dominions
+don
+don't
+donate
+donated
+donates
+donating
+donation
+donations
+donative
+done
+donkey
+donkey's
+donkeys
+dons
+doom
+doomed
+dooming
+dooms
+door
+door's
+doors
+doorstep
+doorstep's
+doorsteps
+doorway
+doorway's
+doorways
+dope
+doped
+doper
+dopers
+dopes
+doping
+dormant
+dormitories
+dormitory
+dormitory's
+dorsal
+dorsally
+dose
+dosed
+doses
+dosing
+dot
+dot's
+dote
+doted
+doter
+dotes
+doth
+doting
+dotingly
+dots
+dotted
+dotting
+double
+doubled
+doubleness
+doubler
+doublers
+doubles
+doublet
+doublet's
+doublets
+doubling
+doubly
+doubt
+doubtable
+doubted
+doubter
+doubters
+doubtful
+doubtfully
+doubtfulness
+doubting
+doubtingly
+doubtless
+doubtlessly
+doubtlessness
+doubts
+dough
+doughnut
+doughnut's
+doughnuts
+douse
+doused
+douser
+douses
+dousing
+dove
+dover
+doves
+down
+downcast
+downed
+downer
+downers
+downfall
+downfallen
+downier
+downing
+downplay
+downplayed
+downplaying
+downplays
+downright
+downrightly
+downrightness
+downs
+downstairs
+downstream
+downtown
+downtowner
+downtowns
+downward
+downwardly
+downwardness
+downwards
+downy
+doze
+dozed
+dozen
+dozens
+dozenth
+dozer
+dozes
+dozing
+drab
+drably
+drabness
+drabs
+draft
+draft's
+drafted
+drafter
+drafters
+drafting
+drafts
+draftsmen
+drag
+dragged
+dragging
+draggingly
+dragon
+dragon's
+dragons
+dragoon
+dragooned
+dragoons
+drags
+drain
+drainage
+drainages
+drained
+drainer
+drainers
+draining
+drains
+drake
+drama
+drama's
+dramas
+dramatic
+dramatically
+dramatics
+dramatist
+dramatist's
+dramatists
+drank
+drape
+draped
+draper
+draperies
+drapers
+drapery
+drapery's
+drapes
+draping
+drastic
+drastically
+draw
+drawback
+drawback's
+drawbacks
+drawbridge
+drawbridge's
+drawbridges
+drawer
+drawers
+drawing
+drawings
+drawl
+drawled
+drawler
+drawling
+drawlingly
+drawls
+drawly
+drawn
+drawnly
+drawnness
+draws
+dread
+dreaded
+dreadful
+dreadfully
+dreadfulness
+dreading
+dreads
+dream
+dreamed
+dreamer
+dreamers
+dreamier
+dreamily
+dreaminess
+dreaming
+dreamingly
+dreams
+dreamy
+drearier
+dreariness
+dreary
+dredge
+dredge's
+dredged
+dredger
+dredgers
+dredges
+dredging
+dregs
+drench
+drenched
+drencher
+drenches
+drenching
+dress
+dressed
+dresser
+dressers
+dresses
+dressing
+dressings
+dressmaker
+dressmaker's
+dressmakers
+drew
+dried
+drier
+drier's
+driers
+dries
+driest
+drift
+drifted
+drifter
+drifters
+drifting
+driftingly
+drifts
+drill
+drilled
+driller
+drilling
+drills
+drily
+drink
+drinkable
+drinker
+drinkers
+drinking
+drinks
+drip
+drip's
+drips
+drive
+driven
+drivenness
+driver
+driver's
+drivers
+drives
+driveway
+driveway's
+driveways
+driving
+drone
+drone's
+droner
+drones
+droning
+droningly
+drool
+drooled
+drooler
+drooling
+drools
+droop
+drooped
+drooping
+droopingly
+droops
+drop
+drop's
+dropped
+dropper
+dropper's
+droppers
+dropping
+dropping's
+droppings
+drops
+drought
+drought's
+droughts
+drove
+drover
+drovers
+droves
+drown
+drowned
+drowner
+drowning
+drownings
+drowns
+drowsier
+drowsiest
+drowsiness
+drowsy
+drudgery
+drug
+drug's
+druggist
+druggist's
+druggists
+drugs
+drum
+drum's
+drummed
+drummer
+drummer's
+drummers
+drumming
+drums
+drunk
+drunk's
+drunkard
+drunkard's
+drunkards
+drunken
+drunkenly
+drunkenness
+drunker
+drunkly
+drunks
+dry
+drying
+dryly
+dual
+dualities
+duality
+duality's
+dually
+duals
+dub
+dubious
+dubiously
+dubiousness
+dubs
+duchess
+duchess's
+duchesses
+duchies
+duchy
+duck
+ducked
+ducker
+ducking
+ducks
+dude
+due
+duel
+duels
+dueness
+dues
+dug
+duke
+duke's
+dukes
+dull
+dulled
+duller
+dullest
+dulling
+dullness
+dulls
+dully
+duly
+dumb
+dumbbell
+dumbbell's
+dumbbells
+dumber
+dumbest
+dumbly
+dumbness
+dummied
+dummies
+dummy
+dummy's
+dummying
+dump
+dumped
+dumper
+dumpers
+dumping
+dumps
+dunce
+dunce's
+dunces
+dune
+dune's
+dunes
+dungeon
+dungeon's
+dungeons
+duplicate
+duplicated
+duplicates
+duplicating
+duplication
+duplications
+duplicative
+duplicator
+duplicator's
+duplicators
+durabilities
+durability
+durable
+durableness
+durables
+durably
+duration
+duration's
+durations
+during
+dusk
+duskier
+duskiness
+dusky
+dust
+dusted
+duster
+dusters
+dustier
+dustiest
+dustiness
+dusting
+dusts
+dusty
+duties
+dutiful
+dutifully
+dutifulness
+duty
+duty's
+dwarf
+dwarfed
+dwarfness
+dwarfs
+dwell
+dwelled
+dweller
+dwellers
+dwelling
+dwellings
+dwells
+dwindle
+dwindled
+dwindles
+dwindling
+dye
+dyed
+dyeing
+dyer
+dyers
+dyes
+dying
+dynamic
+dynamically
+dynamics
+dynamite
+dynamited
+dynamiter
+dynamites
+dynamiting
+dynasties
+dynasty
+dynasty's
+each
+eager
+eagerly
+eagerness
+eagle
+eagle's
+eagles
+ear
+eared
+earing
+earl
+earl's
+earlier
+earliest
+earliness
+earls
+early
+earmark
+earmarked
+earmarking
+earmarkings
+earmarks
+earn
+earned
+earner
+earner's
+earners
+earnest
+earnestly
+earnestness
+earning
+earnings
+earns
+earring
+earring's
+earrings
+ears
+earshot
+earth
+earth's
+earthed
+earthen
+earthenware
+earthliness
+earthly
+earthquake
+earthquake's
+earthquakes
+earths
+earthworm
+earthworm's
+earthworms
+ease
+eased
+easement
+easement's
+easements
+easer
+eases
+easier
+easiest
+easily
+easiness
+easing
+east
+easter
+easterly
+eastern
+easterner
+easterners
+easting
+easts
+eastward
+eastwards
+easy
+eat
+eaten
+eater
+eaters
+eating
+eatings
+eats
+eaves
+eavesdrop
+eavesdropped
+eavesdropper
+eavesdropper's
+eavesdroppers
+eavesdropping
+eavesdrops
+ebb
+ebbed
+ebbing
+ebbs
+ebony
+eccentric
+eccentric's
+eccentricities
+eccentricity
+eccentrics
+ecclesiastical
+ecclesiastically
+echo
+echoed
+echoes
+echoing
+echos
+eclipse
+eclipsed
+eclipses
+eclipsing
+ecology
+economic
+economical
+economically
+economics
+economies
+economist
+economist's
+economists
+economy
+economy's
+ecstasy
+eddied
+eddies
+eddy
+eddy's
+eddying
+edge
+edged
+edger
+edges
+edging
+edible
+edibleness
+edibles
+edict
+edict's
+edicts
+edifice
+edifice's
+edifices
+edit
+edited
+editing
+edition
+edition's
+editions
+editor
+editor's
+editorial
+editorially
+editorials
+editors
+edits
+educate
+educated
+educatedly
+educatedness
+educates
+educating
+education
+education's
+educational
+educationally
+educations
+educative
+educator
+educator's
+educators
+eel
+eel's
+eels
+eerie
+eerier
+effect
+effected
+effecting
+effective
+effectively
+effectiveness
+effectives
+effector
+effector's
+effectors
+effects
+effectually
+effeminate
+efficacy
+efficiencies
+efficiency
+efficient
+efficiently
+effigy
+effort
+effort's
+effortless
+effortlessly
+effortlessness
+efforts
+egg
+egged
+egger
+egging
+eggs
+ego
+egos
+eigenvalue
+eigenvalue's
+eigenvalues
+eight
+eighteen
+eighteens
+eighteenth
+eighth
+eighth's
+eighthes
+eighties
+eightieth
+eights
+eighty
+either
+ejaculate
+ejaculated
+ejaculates
+ejaculating
+ejaculation
+ejaculations
+eject
+ejected
+ejecting
+ejective
+ejects
+eke
+eked
+ekes
+eking
+el
+elaborate
+elaborated
+elaborately
+elaborateness
+elaborates
+elaborating
+elaboration
+elaborations
+elaborative
+elaborators
+elapse
+elapsed
+elapses
+elapsing
+elastic
+elastically
+elasticities
+elasticity
+elastics
+elate
+elated
+elatedly
+elatedness
+elater
+elates
+elating
+elation
+elbow
+elbowed
+elbowing
+elbows
+elder
+elderliness
+elderly
+elders
+eldest
+elect
+elected
+electing
+election
+election's
+elections
+elective
+electively
+electiveness
+electives
+elector
+elector's
+electoral
+electorally
+electors
+electric
+electrical
+electrically
+electricalness
+electricities
+electricity
+electrics
+electrification
+electrified
+electrify
+electrifying
+electrocute
+electrocuted
+electrocutes
+electrocuting
+electrocution
+electrocutions
+electrode
+electrode's
+electrodes
+electrolyte
+electrolyte's
+electrolytes
+electrolytic
+electron
+electron's
+electronic
+electronically
+electronics
+electrons
+elects
+elegance
+elegances
+elegant
+elegantly
+element
+element's
+elemental
+elementally
+elementals
+elementariness
+elementary
+elements
+elephant
+elephant's
+elephants
+elevate
+elevated
+elevates
+elevating
+elevation
+elevations
+elevator
+elevator's
+elevators
+eleven
+elevens
+elevenses
+eleventh
+elf
+elicit
+elicited
+eliciting
+elicits
+eligibilities
+eligibility
+eligible
+eligibles
+eliminate
+eliminated
+eliminately
+eliminates
+eliminating
+elimination
+eliminations
+eliminative
+eliminator
+eliminators
+elk
+elk's
+elks
+ellipse
+ellipse's
+ellipses
+ellipsis
+ellipsoid
+ellipsoid's
+ellipsoidal
+ellipsoids
+elliptic
+elliptical
+elliptically
+elm
+elmer
+elms
+elongate
+elongated
+elongates
+elongating
+elongation
+eloquence
+eloquent
+eloquently
+els
+else
+else's
+elsewhere
+elucidate
+elucidated
+elucidates
+elucidating
+elucidation
+elucidative
+elude
+eluded
+eludes
+eluding
+elusive
+elusively
+elusiveness
+elves
+emaciated
+emacs
+emacs's
+email
+email's
+emanating
+emancipation
+embark
+embarked
+embarking
+embarks
+embarrass
+embarrassed
+embarrassedly
+embarrasses
+embarrassing
+embarrassingly
+embarrassment
+embassies
+embassy
+embassy's
+embed
+embedded
+embedding
+embeds
+embellish
+embellished
+embellisher
+embellishes
+embellishing
+embellishment
+embellishment's
+embellishments
+ember
+embers
+embezzle
+embezzled
+embezzler
+embezzler's
+embezzlers
+embezzles
+embezzling
+emblem
+emblems
+embodied
+embodier
+embodies
+embodiment
+embodiment's
+embodiments
+embody
+embodying
+embrace
+embraced
+embracer
+embraces
+embracing
+embracingly
+embracive
+embroider
+embroidered
+embroiderer
+embroideries
+embroiders
+embroidery
+embryo
+embryo's
+embryology
+embryos
+emerald
+emerald's
+emeralds
+emerge
+emerged
+emergence
+emergencies
+emergency
+emergency's
+emergent
+emerges
+emerging
+emeries
+emery
+emigrant
+emigrant's
+emigrants
+emigrate
+emigrated
+emigrates
+emigrating
+emigration
+eminence
+eminent
+eminently
+emit
+emits
+emitted
+emotion
+emotion's
+emotional
+emotionally
+emotions
+empathy
+emperor
+emperor's
+emperors
+emphases
+emphasis
+emphatic
+emphatically
+empire
+empire's
+empires
+empirical
+empirically
+empiricist
+empiricist's
+empiricists
+employ
+employable
+employed
+employee
+employee's
+employees
+employer
+employer's
+employers
+employing
+employment
+employment's
+employments
+employs
+empower
+empowered
+empowering
+empowers
+empress
+emptied
+emptier
+empties
+emptiest
+emptily
+emptiness
+empty
+emptying
+emulate
+emulated
+emulates
+emulating
+emulation
+emulations
+emulative
+emulatively
+emulator
+emulator's
+emulators
+enable
+enabled
+enabler
+enablers
+enables
+enabling
+enact
+enacted
+enacting
+enactment
+enactments
+enacts
+enamel
+enamels
+encamp
+encamped
+encamping
+encamps
+encapsulate
+encapsulated
+encapsulates
+encapsulating
+encapsulation
+enchant
+enchanted
+enchanter
+enchanting
+enchantingly
+enchantment
+enchants
+encipher
+enciphered
+encipherer
+enciphering
+enciphers
+encircle
+encircled
+encircles
+encircling
+enclose
+enclosed
+encloses
+enclosing
+enclosure
+enclosure's
+enclosures
+encode
+encoded
+encoder
+encoders
+encodes
+encoding
+encodings
+encompass
+encompassed
+encompasses
+encompassing
+encounter
+encountered
+encountering
+encounters
+encourage
+encouraged
+encouragement
+encouragements
+encourager
+encourages
+encouraging
+encouragingly
+encrypt
+encrypted
+encrypting
+encryption
+encryption's
+encryptions
+encrypts
+encumber
+encumbered
+encumbering
+encumbers
+encyclopedia
+encyclopedia's
+encyclopedias
+encyclopedic
+end
+endanger
+endangered
+endangering
+endangers
+endear
+endeared
+endearing
+endearingly
+endears
+ended
+endemic
+ender
+enders
+ending
+endings
+endive
+endless
+endlessly
+endlessness
+endorse
+endorsed
+endorsement
+endorsement's
+endorsements
+endorser
+endorses
+endorsing
+endow
+endowed
+endowing
+endowment
+endowment's
+endowments
+endows
+ends
+endurable
+endurably
+endurance
+endure
+endured
+endures
+enduring
+enduringly
+enduringness
+enema
+enema's
+enemas
+enemies
+enemy
+enemy's
+energetic
+energetics
+energies
+energy
+enforce
+enforced
+enforcedly
+enforcement
+enforcer
+enforcers
+enforces
+enforcing
+enfranchise
+enfranchised
+enfranchisement
+enfranchiser
+enfranchises
+enfranchising
+engage
+engaged
+engagement
+engagement's
+engagements
+engages
+engaging
+engagingly
+engender
+engendered
+engendering
+engenders
+engine
+engine's
+engined
+engineer
+engineer's
+engineered
+engineering
+engineeringly
+engineerings
+engineers
+engines
+engining
+england
+englander
+englanders
+engrave
+engraved
+engraver
+engravers
+engraves
+engraving
+engravings
+engross
+engrossed
+engrossedly
+engrosser
+engrossing
+engrossingly
+enhance
+enhanced
+enhancement
+enhancement's
+enhancements
+enhances
+enhancing
+enigmatic
+enjoin
+enjoined
+enjoining
+enjoins
+enjoy
+enjoyable
+enjoyableness
+enjoyably
+enjoyed
+enjoying
+enjoyment
+enjoys
+enlarge
+enlarged
+enlargement
+enlargement's
+enlargements
+enlarger
+enlargers
+enlarges
+enlarging
+enlighten
+enlightened
+enlightening
+enlightenment
+enlightens
+enlist
+enlisted
+enlister
+enlisting
+enlistment
+enlistments
+enlists
+enliven
+enlivened
+enlivening
+enlivens
+enmities
+enmity
+ennoble
+ennobled
+ennobler
+ennobles
+ennobling
+ennui
+enormities
+enormity
+enormous
+enormously
+enormousness
+enough
+enqueue
+enqueued
+enqueues
+enquire
+enquired
+enquirer
+enquirers
+enquires
+enquiring
+enrage
+enraged
+enrages
+enraging
+enrich
+enriched
+enricher
+enriches
+enriching
+enrolled
+enrolling
+ensemble
+ensemble's
+ensembles
+ensign
+ensign's
+ensigns
+enslave
+enslaved
+enslaver
+enslavers
+enslaves
+enslaving
+ensnare
+ensnared
+ensnares
+ensnaring
+ensue
+ensued
+ensues
+ensuing
+ensure
+ensured
+ensurer
+ensurers
+ensures
+ensuring
+entail
+entailed
+entailer
+entailing
+entails
+entangle
+entangled
+entangler
+entangles
+entangling
+enter
+entered
+enterer
+entering
+enterprise
+enterpriser
+enterprises
+enterprising
+enterprisingly
+enters
+entertain
+entertained
+entertainer
+entertainers
+entertaining
+entertainingly
+entertainment
+entertainment's
+entertainments
+entertains
+enthusiasm
+enthusiasms
+enthusiast
+enthusiast's
+enthusiastic
+enthusiastically
+enthusiasts
+entice
+enticed
+enticer
+enticers
+entices
+enticing
+entire
+entirely
+entireties
+entirety
+entities
+entitle
+entitled
+entitles
+entitling
+entity
+entity's
+entrance
+entranced
+entrances
+entrancing
+entreat
+entreated
+entreaties
+entreating
+entreatingly
+entreats
+entreaty
+entrench
+entrenched
+entrenches
+entrenching
+entrepreneur
+entrepreneur's
+entrepreneurs
+entries
+entropies
+entropy
+entrust
+entrusted
+entrusting
+entrusts
+entry
+entry's
+enumerable
+enumerate
+enumerated
+enumerates
+enumerating
+enumeration
+enumerations
+enumerative
+enumerator
+enumerator's
+enumerators
+enunciation
+envelop
+envelope
+enveloped
+enveloper
+envelopes
+enveloping
+envelops
+enviably
+envied
+envier
+envies
+envious
+enviously
+enviousness
+environ
+environed
+environing
+environment
+environment's
+environmental
+environmentally
+environments
+environs
+envisage
+envisaged
+envisages
+envisaging
+envision
+envisioned
+envisioning
+envisions
+envoy
+envoy's
+envoys
+envy
+envying
+envyingly
+epaulet
+epaulet's
+epaulets
+ephemeral
+ephemerally
+ephemerals
+epic
+epic's
+epics
+epidemic
+epidemic's
+epidemics
+episcopal
+episcopally
+episode
+episode's
+episodes
+episodic
+epistemological
+epistemologically
+epistemology
+epistle
+epistle's
+epistler
+epistles
+epitaph
+epitaphed
+epitaphing
+epitaphs
+epitaxial
+epitaxially
+epithet
+epithet's
+epithets
+epoch
+epochs
+epsilon
+epsilons
+equal
+equalities
+equality
+equality's
+equally
+equals
+equate
+equated
+equates
+equating
+equation
+equations
+equator
+equator's
+equatorial
+equators
+equilibrium
+equilibriums
+equip
+equipment
+equipments
+equipped
+equipping
+equips
+equitable
+equitableness
+equitably
+equities
+equity
+equivalence
+equivalenced
+equivalences
+equivalencing
+equivalent
+equivalently
+equivalents
+era
+era's
+eradicate
+eradicated
+eradicates
+eradicating
+eradication
+eradicative
+eras
+erasable
+erase
+erased
+eraser
+erasers
+erases
+erasing
+erasion
+erasure
+ere
+erect
+erected
+erecting
+erection
+erection's
+erections
+erectly
+erectness
+erector
+erector's
+erectors
+erects
+ergo
+ermine
+ermine's
+ermined
+ermines
+err
+errand
+errands
+erratic
+erred
+erring
+erringly
+erroneous
+erroneously
+erroneousness
+error
+error's
+errors
+errs
+eruption
+eruptions
+escalate
+escalated
+escalates
+escalating
+escalation
+escapable
+escapade
+escapade's
+escapades
+escape
+escaped
+escapee
+escapee's
+escapees
+escaper
+escapes
+escaping
+eschew
+eschewed
+eschewing
+eschews
+escort
+escorted
+escorting
+escorts
+esoteric
+especial
+especially
+espied
+espies
+espionage
+espouse
+espoused
+espouser
+espouses
+espousing
+esprit
+esprits
+espy
+espying
+esquire
+esquires
+essay
+essayed
+essayer
+essays
+essence
+essence's
+essences
+essential
+essentially
+essentialness
+essentials
+establish
+established
+establisher
+establishes
+establishing
+establishment
+establishment's
+establishments
+estate
+estate's
+estates
+esteem
+esteemed
+esteeming
+esteems
+estimate
+estimated
+estimates
+estimating
+estimation
+estimations
+estimative
+etc
+eternal
+eternally
+eternalness
+eternities
+eternity
+ethereal
+ethereally
+etherealness
+ethic
+ethical
+ethically
+ethicalness
+ethics
+ethnic
+etiquette
+eunuch
+eunuchs
+euphemism
+euphemism's
+euphemisms
+euphoria
+evacuate
+evacuated
+evacuates
+evacuating
+evacuation
+evacuations
+evacuative
+evade
+evaded
+evader
+evades
+evading
+evaluate
+evaluated
+evaluates
+evaluating
+evaluation
+evaluations
+evaluative
+evaluator
+evaluator's
+evaluators
+evaporate
+evaporated
+evaporates
+evaporating
+evaporation
+evaporations
+evaporative
+evaporatively
+eve
+even
+evened
+evener
+evenhanded
+evenhandedly
+evenhandedness
+evening
+evening's
+evenings
+evenly
+evenness
+evens
+event
+event's
+eventful
+eventfully
+eventfulness
+events
+eventual
+eventualities
+eventuality
+eventually
+ever
+everest
+evergreen
+everlasting
+everlastingly
+everlastingness
+evermore
+every
+everybody
+everybody's
+everyday
+everydayness
+everyone
+everyone's
+everyones
+everything
+everywhere
+eves
+evict
+evicted
+evicting
+eviction
+eviction's
+evictions
+evicts
+evidence
+evidenced
+evidences
+evidencing
+evident
+evidently
+evil
+evilly
+evilness
+evils
+evince
+evinced
+evinces
+evincing
+evoke
+evoked
+evokes
+evoking
+evolute
+evolute's
+evolutes
+evolution
+evolution's
+evolutionary
+evolutions
+evolve
+evolved
+evolves
+evolving
+ewe
+ewe's
+ewer
+ewes
+exacerbate
+exacerbated
+exacerbates
+exacerbating
+exacerbation
+exacerbations
+exact
+exacted
+exacter
+exacting
+exactingly
+exactingness
+exaction
+exaction's
+exactions
+exactitude
+exactly
+exactness
+exacts
+exaggerate
+exaggerated
+exaggeratedly
+exaggeratedness
+exaggerates
+exaggerating
+exaggeration
+exaggerations
+exaggerative
+exaggeratively
+exalt
+exalted
+exaltedly
+exalter
+exalters
+exalting
+exalts
+exam
+exam's
+examen
+examination
+examination's
+examinations
+examine
+examined
+examiner
+examiners
+examines
+examining
+example
+example's
+exampled
+examples
+exampling
+exams
+exasperate
+exasperated
+exasperatedly
+exasperates
+exasperating
+exasperatingly
+exasperation
+exasperations
+excavate
+excavated
+excavates
+excavating
+excavation
+excavations
+exceed
+exceeded
+exceeder
+exceeding
+exceedingly
+exceeds
+excel
+excelled
+excellence
+excellences
+excellency
+excellent
+excellently
+excelling
+excels
+except
+excepted
+excepting
+exception
+exception's
+exceptional
+exceptionally
+exceptionalness
+exceptions
+exceptive
+excepts
+excerpt
+excerpted
+excerpter
+excerpts
+excess
+excesses
+excessive
+excessively
+excessiveness
+exchange
+exchangeable
+exchanged
+exchanger
+exchangers
+exchanges
+exchanging
+exchequer
+exchequer's
+exchequers
+excise
+excised
+excises
+excising
+excision
+excisions
+excitable
+excitableness
+excitation
+excitation's
+excitations
+excite
+excited
+excitedly
+excitement
+exciter
+excites
+exciting
+excitingly
+exclaim
+exclaimed
+exclaimer
+exclaimers
+exclaiming
+exclaims
+exclamation
+exclamation's
+exclamations
+exclude
+excluded
+excluder
+excludes
+excluding
+exclusion
+exclusioner
+exclusioners
+exclusions
+exclusive
+exclusively
+exclusiveness
+exclusivity
+excommunicate
+excommunicated
+excommunicates
+excommunicating
+excommunication
+excommunicative
+excrete
+excreted
+excreter
+excretes
+excreting
+excretion
+excretions
+excruciatingly
+excursion
+excursion's
+excursions
+excusable
+excusableness
+excusably
+excuse
+excused
+excuser
+excuses
+excusing
+executable
+executable's
+executables
+execute
+executed
+executer
+executers
+executes
+executing
+execution
+executional
+executioner
+executions
+executive
+executive's
+executives
+executor
+executor's
+executors
+exemplar
+exemplariness
+exemplars
+exemplary
+exemplification
+exemplified
+exemplifier
+exemplifiers
+exemplifies
+exemplify
+exemplifying
+exempt
+exempted
+exempting
+exempts
+exercise
+exercised
+exerciser
+exercisers
+exercises
+exercising
+exert
+exerted
+exerting
+exertion
+exertion's
+exertions
+exerts
+exhale
+exhaled
+exhales
+exhaling
+exhaust
+exhausted
+exhaustedly
+exhauster
+exhaustible
+exhausting
+exhaustingly
+exhaustion
+exhaustive
+exhaustively
+exhaustiveness
+exhausts
+exhibit
+exhibited
+exhibiting
+exhibition
+exhibition's
+exhibitioner
+exhibitions
+exhibitive
+exhibitor
+exhibitor's
+exhibitors
+exhibits
+exhortation
+exhortation's
+exhortations
+exigencies
+exigency
+exile
+exiled
+exiles
+exiling
+exist
+existed
+existence
+existences
+existent
+existential
+existentialism
+existentialist
+existentialist's
+existentialists
+existentially
+existing
+exists
+exit
+exited
+exiting
+exits
+exorbitant
+exorbitantly
+exoskeletons
+exotic
+exoticness
+expand
+expandable
+expanded
+expander
+expander's
+expanders
+expanding
+expands
+expanse
+expansed
+expanses
+expansing
+expansion
+expansionism
+expansions
+expansive
+expansively
+expansiveness
+expect
+expectancies
+expectancy
+expectant
+expectantly
+expectation
+expectation's
+expectations
+expected
+expectedly
+expectedness
+expecting
+expectingly
+expects
+expedient
+expediently
+expedite
+expedited
+expediter
+expedites
+expediting
+expedition
+expedition's
+expeditions
+expeditious
+expeditiously
+expeditiousness
+expel
+expelled
+expelling
+expels
+expend
+expendable
+expended
+expender
+expending
+expenditure
+expenditure's
+expenditures
+expends
+expense
+expensed
+expenses
+expensing
+expensive
+expensively
+expensiveness
+experience
+experienced
+experiences
+experiencing
+experiment
+experimental
+experimentally
+experimentation
+experimentation's
+experimentations
+experimented
+experimenter
+experimenters
+experimenting
+experiments
+expert
+expertise
+expertly
+expertness
+experts
+expiration
+expiration's
+expirations
+expire
+expired
+expires
+expiring
+explain
+explainable
+explained
+explainer
+explainers
+explaining
+explains
+explanation
+explanation's
+explanations
+explanatory
+explicit
+explicitly
+explicitness
+explode
+exploded
+exploder
+explodes
+exploding
+exploit
+exploitable
+exploitation
+exploitation's
+exploitations
+exploited
+exploiter
+exploiters
+exploiting
+exploitive
+exploits
+exploration
+exploration's
+explorations
+exploratory
+explore
+explored
+explorer
+explorers
+explores
+exploring
+explosion
+explosion's
+explosions
+explosive
+explosively
+explosiveness
+explosives
+exponent
+exponent's
+exponential
+exponentially
+exponentials
+exponentiate
+exponentiated
+exponentiates
+exponentiating
+exponentiation
+exponentiation's
+exponentiations
+exponents
+export
+exported
+exporter
+exporters
+exporting
+exports
+expose
+exposed
+exposer
+exposers
+exposes
+exposing
+exposition
+exposition's
+expositions
+expository
+exposure
+exposure's
+exposures
+expound
+expounded
+expounder
+expounding
+expounds
+express
+expressed
+expresser
+expresses
+expressibility
+expressible
+expressibly
+expressing
+expression
+expression's
+expressions
+expressive
+expressively
+expressiveness
+expressly
+expropriate
+expropriated
+expropriates
+expropriating
+expropriation
+expropriations
+expulsion
+expunge
+expunged
+expunger
+expunges
+expunging
+exquisite
+exquisitely
+exquisiteness
+extant
+extend
+extended
+extendedly
+extendedness
+extender
+extendible
+extendibles
+extending
+extends
+extensibility
+extensible
+extension
+extension's
+extensions
+extensive
+extensively
+extensiveness
+extent
+extent's
+extents
+extenuate
+extenuated
+extenuating
+extenuation
+exterior
+exterior's
+exteriorly
+exteriors
+exterminate
+exterminated
+exterminates
+exterminating
+extermination
+exterminations
+external
+externally
+externals
+extinct
+extinction
+extinctive
+extinguish
+extinguished
+extinguisher
+extinguishers
+extinguishes
+extinguishing
+extol
+extols
+extortion
+extortioner
+extortionist
+extortionist's
+extortionists
+extra
+extract
+extracted
+extracting
+extraction
+extraction's
+extractions
+extractive
+extractively
+extractor
+extractor's
+extractors
+extracts
+extracurricular
+extraneous
+extraneously
+extraneousness
+extraordinarily
+extraordinariness
+extraordinary
+extrapolate
+extrapolated
+extrapolates
+extrapolating
+extrapolation
+extrapolations
+extrapolative
+extras
+extravagance
+extravagant
+extravagantly
+extremal
+extreme
+extremed
+extremely
+extremeness
+extremer
+extremes
+extremest
+extremist
+extremist's
+extremists
+extremities
+extremity
+extremity's
+extrinsic
+exuberance
+exult
+exultation
+exulted
+exulting
+exultingly
+exults
+eye
+eyeball
+eyeballs
+eyebrow
+eyebrow's
+eyebrows
+eyed
+eyedness
+eyeglass
+eyeglasses
+eyeing
+eyelid
+eyelid's
+eyelids
+eyepiece
+eyepiece's
+eyepieces
+eyer
+eyers
+eyes
+eyesight
+eyewitness
+eyewitness's
+eyewitnesses
+eying
+fable
+fabled
+fabler
+fables
+fabling
+fabric
+fabric's
+fabricate
+fabricated
+fabricates
+fabricating
+fabrication
+fabrications
+fabrics
+fabulous
+fabulously
+fabulousness
+facade
+facaded
+facades
+facading
+face
+faced
+faceless
+facelessness
+facer
+faces
+facet
+faceted
+faceting
+facets
+facial
+facially
+facile
+facilely
+facileness
+facilitate
+facilitated
+facilitates
+facilitating
+facilitation
+facilitative
+facilities
+facility
+facility's
+facing
+facings
+facsimile
+facsimile's
+facsimiled
+facsimiles
+facsimiling
+fact
+fact's
+faction
+faction's
+factions
+factor
+factored
+factorial
+factories
+factoring
+factorings
+factors
+factory
+factory's
+facts
+factual
+factually
+factualness
+faculties
+faculty
+faculty's
+fade
+faded
+fadedly
+fader
+faders
+fades
+fading
+fag
+fags
+fail
+failed
+failing
+failingly
+failings
+fails
+failure
+failure's
+failures
+fain
+faint
+fainted
+fainter
+faintest
+fainting
+faintly
+faintness
+faints
+fair
+faired
+fairer
+fairest
+fairies
+fairing
+fairly
+fairness
+fairs
+fairy
+fairy's
+fairyland
+faith
+faithful
+faithfully
+faithfulness
+faithfuls
+faithless
+faithlessly
+faithlessness
+faiths
+fake
+faked
+faker
+fakes
+faking
+falcon
+falconer
+falcons
+fall
+fallacies
+fallacious
+fallaciously
+fallaciousness
+fallacy
+fallacy's
+fallen
+faller
+fallibility
+fallible
+falling
+falls
+false
+falsehood
+falsehood's
+falsehoods
+falsely
+falseness
+falser
+falsest
+falsification
+falsified
+falsifier
+falsifies
+falsify
+falsifying
+falsity
+falter
+faltered
+falterer
+faltering
+falteringly
+falters
+fame
+famed
+fames
+familiar
+familiarities
+familiarity
+familiarly
+familiarness
+familiars
+families
+family
+family's
+famine
+famine's
+famines
+faming
+famish
+famished
+famishes
+famishing
+famous
+famously
+famousness
+fan
+fan's
+fanatic
+fanatic's
+fanatically
+fanatics
+fancied
+fancier
+fancier's
+fanciers
+fancies
+fanciest
+fanciful
+fancifully
+fancifulness
+fancily
+fanciness
+fancy
+fancying
+fang
+fang's
+fanged
+fangs
+fanned
+fanning
+fans
+fantasied
+fantasies
+fantastic
+fantasy
+fantasy's
+far
+faraway
+farce
+farce's
+farces
+farcing
+fare
+fared
+farer
+fares
+farewell
+farewells
+faring
+farm
+farmed
+farmer
+farmer's
+farmers
+farmhouse
+farmhouse's
+farmhouses
+farming
+farms
+farmyard
+farmyard's
+farmyards
+farther
+farthest
+farthing
+fascinate
+fascinated
+fascinates
+fascinating
+fascinatingly
+fascination
+fascinations
+fashion
+fashionable
+fashionableness
+fashionably
+fashioned
+fashioner
+fashioners
+fashioning
+fashions
+fast
+fasted
+fasten
+fastened
+fastener
+fasteners
+fastening
+fastenings
+fastens
+faster
+fastest
+fasting
+fastness
+fasts
+fat
+fatal
+fatalities
+fatality
+fatality's
+fatally
+fatals
+fate
+fated
+fates
+father
+father's
+fathered
+fathering
+fatherland
+fatherliness
+fatherly
+fathers
+fathom
+fathomed
+fathoming
+fathoms
+fatigue
+fatigued
+fatigues
+fatiguing
+fatiguingly
+fating
+fatly
+fatness
+fats
+fatten
+fattened
+fattener
+fatteners
+fattening
+fattens
+fatter
+fattest
+fault
+faulted
+faultier
+faultiness
+faulting
+faultless
+faultlessly
+faultlessness
+faults
+faulty
+fawn
+fawned
+fawner
+fawning
+fawningly
+fawns
+fear
+feared
+fearer
+fearful
+fearfully
+fearfulness
+fearing
+fearless
+fearlessly
+fearlessness
+fears
+feasibility
+feasible
+feasibleness
+feast
+feasted
+feaster
+feasting
+feasts
+feat
+feat's
+feather
+feathered
+featherer
+featherers
+feathering
+feathers
+feating
+featly
+feats
+feature
+featured
+featureless
+features
+featuring
+fed
+federal
+federally
+federals
+federation
+feds
+fee
+feeble
+feebleness
+feebler
+feeblest
+feebly
+feed
+feedback
+feedbacks
+feeder
+feeders
+feeding
+feedings
+feeds
+feel
+feeler
+feelers
+feeling
+feelingly
+feelingness
+feelings
+feels
+fees
+feet
+feign
+feigned
+feigner
+feigning
+feigns
+felicities
+felicity
+fell
+felled
+feller
+fellers
+felling
+fellness
+fellow
+fellow's
+fellowly
+fellows
+fellowship
+fellowship's
+fellowships
+fells
+felt
+felted
+felting
+felts
+female
+female's
+femaleness
+females
+feminine
+femininely
+feminineness
+femininity
+feminist
+feminist's
+feminists
+femur
+femur's
+femurs
+fen
+fence
+fenced
+fencer
+fencers
+fences
+fencing
+ferment
+fermentation
+fermentation's
+fermentations
+fermented
+fermenter
+fermenting
+ferments
+fern
+fern's
+ferns
+ferocious
+ferociously
+ferociousness
+ferocity
+ferried
+ferries
+ferrite
+ferry
+ferrying
+fertile
+fertilely
+fertileness
+fertilities
+fertility
+fervent
+fervently
+festival
+festival's
+festivals
+festive
+festively
+festiveness
+festivities
+festivity
+fetch
+fetched
+fetcher
+fetches
+fetching
+fetchingly
+fetter
+fettered
+fettering
+fetters
+feud
+feud's
+feudal
+feudalism
+feudally
+feuds
+fever
+fevered
+fevering
+feverish
+feverishly
+feverishness
+fevers
+few
+fewer
+fewest
+fewness
+fews
+fibrous
+fibrously
+fibrousness
+fickle
+fickleness
+fiction
+fiction's
+fictional
+fictionally
+fictions
+fictitious
+fictitiously
+fictitiousness
+fiddle
+fiddled
+fiddler
+fiddles
+fiddling
+fidelity
+field
+fielded
+fielder
+fielders
+fielding
+fields
+fiend
+fiends
+fierce
+fiercely
+fierceness
+fiercer
+fiercest
+fieriness
+fiery
+fife
+fifteen
+fifteens
+fifteenth
+fifth
+fifthly
+fifties
+fiftieth
+fifty
+fig
+fig's
+fight
+fighter
+fighters
+fighting
+fights
+figs
+figurative
+figuratively
+figurativeness
+figure
+figured
+figurer
+figurers
+figures
+figuring
+figurings
+filament
+filament's
+filaments
+file
+file's
+filed
+filename
+filename's
+filenames
+filer
+filers
+files
+filial
+filially
+filing
+filings
+fill
+fillable
+filled
+filler
+fillers
+filling
+fillings
+fills
+film
+filmed
+filming
+films
+filter
+filter's
+filtered
+filterer
+filtering
+filters
+filth
+filthier
+filthiest
+filthiness
+filthy
+filtration
+filtration's
+fin
+fin's
+final
+finality
+finally
+finals
+finance
+financed
+finances
+financial
+financially
+financier
+financier's
+financiers
+financing
+find
+finder
+finders
+finding
+findings
+finds
+fine
+fined
+finely
+fineness
+finer
+fines
+finest
+finger
+fingered
+fingerer
+fingering
+fingerings
+fingers
+fining
+finish
+finished
+finisher
+finishers
+finishes
+finishing
+finishings
+finite
+finitely
+finiteness
+finites
+fins
+fir
+fire
+firearm
+firearm's
+firearms
+fired
+fireflies
+firefly
+firefly's
+firelight
+firelighting
+fireman
+fireplace
+fireplace's
+fireplaces
+firer
+firers
+fires
+fireside
+firewood
+fireworks
+firing
+firings
+firm
+firm's
+firmament
+firmed
+firmer
+firmest
+firming
+firmly
+firmness
+firms
+firmware
+firmwares
+first
+firsthand
+firstly
+firsts
+firth
+fiscal
+fiscally
+fiscals
+fish
+fished
+fisher
+fisheries
+fisherman
+fisherman's
+fishermen
+fishermen's
+fishers
+fishery
+fishes
+fishing
+fissure
+fissured
+fissures
+fissuring
+fist
+fisted
+fists
+fit
+fitful
+fitfully
+fitfulness
+fitly
+fitness
+fits
+fitted
+fitter
+fitter's
+fitters
+fitting
+fittingly
+fittingness
+fittings
+five
+fiver
+fives
+fix
+fixate
+fixated
+fixates
+fixating
+fixation
+fixations
+fixative
+fixed
+fixedly
+fixedness
+fixer
+fixers
+fixes
+fixing
+fixings
+fixture
+fixture's
+fixtures
+flab
+flabbier
+flabbiness
+flabby
+flag
+flag's
+flagged
+flagging
+flaggingly
+flagrant
+flagrantly
+flags
+flagship
+flagship's
+flagships
+flake
+flaked
+flaker
+flakes
+flaking
+flame
+flamed
+flamer
+flamers
+flames
+flaming
+flamingly
+flammable
+flammables
+flank
+flanked
+flanker
+flankers
+flanking
+flanks
+flannel
+flannel's
+flannels
+flap
+flap's
+flapping
+flaps
+flare
+flared
+flares
+flaring
+flaringly
+flash
+flashed
+flasher
+flashers
+flashes
+flashing
+flashlight
+flashlight's
+flashlights
+flask
+flat
+flatly
+flatness
+flatnesses
+flats
+flatten
+flattened
+flattener
+flattening
+flattens
+flatter
+flattered
+flatterer
+flattering
+flatteringly
+flatters
+flattery
+flattest
+flaunt
+flaunted
+flaunting
+flauntingly
+flaunts
+flaw
+flawed
+flawing
+flawless
+flawlessly
+flawlessness
+flaws
+flax
+flaxen
+flea
+flea's
+fleas
+fled
+fledged
+fledgling
+fledgling's
+fledglings
+flee
+fleece
+fleece's
+fleeced
+fleeces
+fleecier
+fleecy
+fleeing
+fleer
+flees
+fleet
+fleetest
+fleeting
+fleetingly
+fleetingness
+fleetly
+fleetness
+fleets
+flesh
+fleshed
+flesher
+fleshes
+fleshier
+fleshiness
+fleshing
+fleshings
+fleshly
+fleshy
+flew
+flews
+flexibilities
+flexibility
+flexible
+flexibly
+flick
+flicked
+flicker
+flickered
+flickering
+flickeringly
+flicking
+flicks
+flier
+fliers
+flies
+flight
+flight's
+flights
+flinch
+flinched
+flincher
+flinches
+flinching
+fling
+fling's
+flinger
+flinging
+flings
+flint
+flints
+flip
+flips
+flirt
+flirted
+flirter
+flirting
+flirts
+flit
+flits
+float
+floated
+floater
+floaters
+floating
+floats
+flock
+flocked
+flocking
+flocks
+flood
+flooded
+flooder
+flooding
+floods
+floor
+floored
+floorer
+flooring
+floorings
+floors
+flop
+flop's
+floppier
+floppies
+floppily
+floppiness
+floppy
+floppy's
+flops
+flora
+florin
+floss
+flossed
+flosses
+flossing
+flounder
+floundered
+floundering
+flounders
+flour
+floured
+flourish
+flourished
+flourisher
+flourishes
+flourishing
+flourishingly
+flours
+flow
+flowchart
+flowcharting
+flowcharts
+flowed
+flower
+flowered
+flowerer
+floweriness
+flowering
+flowers
+flowery
+flowing
+flowingly
+flown
+flows
+fluctuate
+fluctuated
+fluctuates
+fluctuating
+fluctuation
+fluctuations
+fluent
+fluently
+fluffier
+fluffiest
+fluffiness
+fluffy
+fluid
+fluidity
+fluidly
+fluidness
+fluids
+flung
+flunk
+flunked
+flunker
+flunking
+flunks
+fluorescence
+flurried
+flurries
+flurry
+flurrying
+flush
+flushed
+flushes
+flushing
+flushness
+flute
+flute's
+fluted
+fluter
+flutes
+fluting
+flutter
+fluttered
+flutterer
+fluttering
+flutters
+fly
+flyable
+flyer
+flyer's
+flyers
+flying
+foam
+foamed
+foamer
+foaming
+foams
+focal
+focally
+foci
+focus
+focusable
+focused
+focuser
+focuses
+focusing
+fodder
+foe
+foe's
+foes
+fog
+fog's
+fogged
+foggier
+foggiest
+foggily
+fogginess
+fogging
+foggy
+fogs
+foil
+foiled
+foiling
+foils
+fold
+folded
+folder
+folders
+folding
+foldings
+folds
+foliage
+foliaged
+foliages
+folk
+folk's
+folklore
+folks
+follies
+follow
+followed
+follower
+followers
+following
+followings
+follows
+folly
+fond
+fonder
+fondest
+fondle
+fondled
+fondler
+fondles
+fondling
+fondly
+fondness
+fonds
+font
+font's
+fonts
+food
+food's
+foods
+foodstuff
+foodstuff's
+foodstuffs
+fool
+fooled
+fooling
+foolish
+foolishly
+foolishness
+foolproof
+fools
+foot
+football
+football's
+footballed
+footballer
+footballers
+footballs
+footed
+footer
+footers
+foothold
+footholds
+footing
+footings
+footman
+footnote
+footnote's
+footnotes
+footprint
+footprint's
+footprints
+foots
+footstep
+footsteps
+for
+forage
+foraged
+forager
+forages
+foraging
+foray
+foray's
+forayer
+forays
+forbade
+forbear
+forbear's
+forbearance
+forbearer
+forbearing
+forbears
+forbid
+forbidden
+forbidding
+forbiddingly
+forbiddingness
+forbids
+force
+force's
+forced
+forcedly
+forcefield
+forcefield's
+forcefields
+forceful
+forcefully
+forcefulness
+forcer
+forces
+forcible
+forcibleness
+forcibly
+forcing
+ford
+fords
+fore
+forearm
+forearm's
+forearmed
+forearms
+foreboding
+forebodingly
+forebodingness
+forebodings
+forecast
+forecasted
+forecaster
+forecasters
+forecasting
+forecastle
+forecastles
+forecasts
+forefather
+forefather's
+forefathers
+forefinger
+forefinger's
+forefingers
+forego
+foregoer
+foregoes
+foregoing
+foregone
+foreground
+foregrounds
+forehead
+forehead's
+foreheads
+foreign
+foreigner
+foreigners
+foreignly
+foreignness
+foreigns
+foreman
+foremost
+forenoon
+foresee
+foreseeable
+foreseen
+foreseer
+foresees
+foresight
+foresighted
+foresightedly
+foresightedness
+forest
+forestall
+forestalled
+forestaller
+forestalling
+forestallment
+forestalls
+forested
+forester
+foresters
+forests
+foretell
+foreteller
+foretelling
+foretells
+forethought
+forethought's
+foretold
+forever
+foreverness
+forewarn
+forewarned
+forewarner
+forewarning
+forewarnings
+forewarns
+forfeit
+forfeited
+forfeiter
+forfeiters
+forfeiting
+forfeits
+forgave
+forge
+forged
+forger
+forgeries
+forgers
+forgery
+forgery's
+forges
+forget
+forgetful
+forgetfully
+forgetfulness
+forgetive
+forgets
+forgettable
+forgettably
+forgetting
+forging
+forgivable
+forgivably
+forgive
+forgiven
+forgiveness
+forgiver
+forgives
+forgiving
+forgivingly
+forgivingness
+forgot
+forgotten
+fork
+forked
+forker
+forking
+forks
+forlorn
+forlornly
+forlornness
+form
+formal
+formalism
+formalism's
+formalisms
+formalities
+formality
+formally
+formalness
+formals
+formant
+formants
+format
+formated
+formating
+formation
+formation's
+formations
+formative
+formatively
+formativeness
+formats
+formatted
+formatter
+formatter's
+formatters
+formatting
+formed
+former
+formerly
+formers
+formidable
+formidableness
+forming
+forms
+formula
+formula's
+formulae
+formulas
+formulate
+formulated
+formulates
+formulating
+formulation
+formulations
+formulator
+formulator's
+formulators
+fornication
+forsake
+forsaken
+forsakes
+forsaking
+fort
+fort's
+forte
+fortes
+forth
+forthcoming
+forthwith
+fortier
+forties
+fortieth
+fortification
+fortifications
+fortified
+fortifier
+fortifies
+fortify
+fortifying
+fortitude
+fortnight
+fortnightly
+fortress
+fortress's
+fortresses
+forts
+fortuitous
+fortuitously
+fortuitousness
+fortunate
+fortunately
+fortunateness
+fortunates
+fortune
+fortune's
+fortuned
+fortunes
+fortuning
+forty
+forum
+forum's
+forums
+forward
+forwarded
+forwarder
+forwarders
+forwarding
+forwardly
+forwardness
+forwards
+fossil
+fossils
+foster
+fostered
+fosterer
+fostering
+fosters
+fought
+foul
+fouled
+fouler
+foulest
+fouling
+foully
+foulness
+fouls
+found
+foundation
+foundation's
+foundations
+founded
+founder
+foundered
+foundering
+founders
+founding
+foundries
+foundry
+foundry's
+founds
+fount
+fount's
+fountain
+fountain's
+fountains
+founts
+four
+fours
+fourscore
+fourteen
+fourteener
+fourteens
+fourteenth
+fourth
+fourthly
+fowl
+fowler
+fowling
+fowls
+fox
+fox's
+foxed
+foxes
+foxing
+fractal
+fractal's
+fractals
+fraction
+fraction's
+fractional
+fractionally
+fractioned
+fractioning
+fractions
+fracture
+fractured
+fractures
+fracturing
+fragile
+fragilely
+fragment
+fragmentariness
+fragmentary
+fragmented
+fragmenting
+fragments
+fragrance
+fragrance's
+fragrances
+fragrant
+fragrantly
+frail
+frailer
+frailest
+frailly
+frailness
+frailties
+frailty
+frame
+frame's
+framed
+framer
+framers
+frames
+framework
+framework's
+frameworks
+framing
+framings
+franc
+franchise
+franchise's
+franchised
+franchiser
+franchises
+franchising
+francs
+frank
+franked
+franker
+frankest
+franking
+frankly
+frankness
+franks
+frantic
+frantically
+franticly
+franticness
+fraternal
+fraternally
+fraternities
+fraternity
+fraternity's
+fraud
+fraud's
+frauds
+fraudulently
+fraught
+fraughted
+fraughting
+fraughts
+fray
+frayed
+fraying
+frays
+freak
+freak's
+freaks
+freckle
+freckled
+freckles
+freckling
+free
+freed
+freedom
+freedom's
+freedoms
+freeing
+freeings
+freely
+freeman
+freeness
+freer
+frees
+freest
+freeway
+freeway's
+freeways
+freeze
+freezer
+freezers
+freezes
+freezing
+freight
+freighted
+freighter
+freighters
+freighting
+freights
+frenzied
+frenziedly
+frenzies
+frenzy
+frenzying
+frequencies
+frequency
+frequent
+frequented
+frequenter
+frequenters
+frequenting
+frequently
+frequentness
+frequents
+fresh
+freshen
+freshened
+freshener
+fresheners
+freshening
+freshens
+fresher
+freshers
+freshest
+freshly
+freshman
+freshmen
+freshness
+fret
+fretful
+fretfully
+fretfulness
+frets
+friar
+friar's
+friarly
+friars
+frication
+fricative
+fricatives
+friction
+friction's
+frictionless
+frictionlessly
+frictions
+fried
+friend
+friend's
+friendless
+friendlessness
+friendlier
+friendlies
+friendliest
+friendliness
+friendly
+friends
+friendship
+friendship's
+friendships
+frier
+fries
+frieze
+frieze's
+friezes
+frigate
+frigate's
+frigates
+fright
+frighten
+frightened
+frightening
+frighteningly
+frightens
+frightful
+frightfully
+frightfulness
+frill
+frill's
+frilled
+frills
+fringe
+fringed
+fringes
+fringing
+frisk
+frisked
+frisker
+frisking
+frisks
+frivolous
+frivolously
+frivolousness
+frock
+frock's
+frocked
+frocking
+frocks
+frog
+frog's
+frogs
+frolic
+frolics
+from
+front
+fronted
+frontier
+frontier's
+frontiers
+fronting
+fronts
+frost
+frosted
+frostier
+frostiness
+frosting
+frosts
+frosty
+froth
+frothing
+frown
+frowned
+frowner
+frowning
+frowningly
+frowns
+froze
+frozen
+frozenly
+frozenness
+frugal
+frugally
+fruit
+fruit's
+fruited
+fruiter
+fruiterer
+fruitful
+fruitfully
+fruitfulness
+fruition
+fruitless
+fruitlessly
+fruitlessness
+fruits
+frustrate
+frustrated
+frustrater
+frustrates
+frustrating
+frustratingly
+frustration
+frustrations
+fry
+frying
+fuel
+fuels
+fugitive
+fugitive's
+fugitively
+fugitiveness
+fugitives
+fulfilled
+fulfiller
+fulfilling
+full
+fuller
+fullest
+fullness
+fullword
+fullword's
+fullwords
+fully
+fumble
+fumbled
+fumbler
+fumbles
+fumbling
+fumblingly
+fume
+fumed
+fumes
+fuming
+fun
+function
+function's
+functional
+functionalities
+functionality
+functionally
+functionals
+functioned
+functioning
+functions
+functor
+functor's
+functors
+fund
+fundamental
+fundamentalist
+fundamentalist's
+fundamentalists
+fundamentally
+fundamentals
+funded
+funder
+funders
+funding
+funds
+funeral
+funeral's
+funerals
+fungus
+funguses
+funnel
+funnels
+funnier
+funnies
+funniest
+funnily
+funniness
+funny
+fur
+fur's
+furies
+furious
+furiouser
+furiously
+furiousness
+furnace
+furnace's
+furnaced
+furnaces
+furnacing
+furness
+furnish
+furnished
+furnisher
+furnishers
+furnishes
+furnishing
+furnishings
+furniture
+furrow
+furrowed
+furrowing
+furrows
+furs
+further
+furthered
+furtherer
+furtherest
+furthering
+furthermore
+furthers
+furtive
+furtively
+furtiveness
+fury
+fury's
+fuse
+fused
+fuses
+fusing
+fusion
+fusions
+fuss
+fusser
+fussing
+futile
+futilely
+futileness
+futility
+future
+future's
+futures
+fuzzier
+fuzziest
+fuzziness
+fuzzy
+gabardine
+gabardines
+gable
+gabled
+gabler
+gables
+gad
+gadget
+gadget's
+gadgets
+gag
+gaged
+gager
+gagged
+gagging
+gaging
+gags
+gaieties
+gaiety
+gaily
+gain
+gained
+gainer
+gainers
+gaining
+gainings
+gainly
+gains
+gait
+gaited
+gaiter
+gaiters
+gaits
+galaxies
+galaxy
+galaxy's
+gale
+gales
+gall
+gallant
+gallantly
+gallantry
+gallants
+galled
+galleried
+galleries
+gallery
+galley
+galley's
+galleys
+galling
+gallingly
+gallon
+gallon's
+gallons
+gallop
+galloped
+galloper
+gallopers
+galloping
+gallops
+gallows
+gallowses
+galls
+gamble
+gambled
+gambler
+gamblers
+gambles
+gambling
+game
+gamed
+gamely
+gameness
+games
+gaming
+gamma
+gammas
+gang
+gang's
+ganger
+ganglier
+gangly
+gangrene
+gangrened
+gangrenes
+gangrening
+gangs
+gangster
+gangster's
+gangsters
+gap
+gap's
+gape
+gaped
+gaper
+gapes
+gaping
+gapingly
+gaps
+garage
+garaged
+garages
+garaging
+garb
+garbage
+garbage's
+garbaged
+garbages
+garbaging
+garbed
+garble
+garbled
+garbler
+garbles
+garbling
+garden
+gardened
+gardener
+gardeners
+gardening
+gardens
+gargle
+gargled
+gargles
+gargling
+garland
+garlanded
+garlands
+garlic
+garlics
+garment
+garment's
+garmented
+garmenting
+garments
+garner
+garnered
+garnering
+garners
+garnish
+garnished
+garnishes
+garrison
+garrisoned
+garrisoning
+garrisons
+garter
+garter's
+gartered
+gartering
+garters
+gas
+gas's
+gaseous
+gaseously
+gaseousness
+gases
+gash
+gash's
+gashed
+gashes
+gashing
+gasoline
+gasolines
+gasp
+gasped
+gasper
+gaspers
+gasping
+gaspingly
+gasps
+gassed
+gasser
+gassers
+gassing
+gassings
+gastric
+gastrointestinal
+gate
+gated
+gates
+gateway
+gateway's
+gateways
+gather
+gathered
+gatherer
+gatherers
+gathering
+gatherings
+gathers
+gating
+gaudier
+gaudies
+gaudiness
+gaudy
+gauge
+gauged
+gauger
+gauges
+gauging
+gaunt
+gauntly
+gauntness
+gauze
+gauzed
+gauzes
+gauzing
+gave
+gay
+gayer
+gayest
+gayly
+gayness
+gaze
+gazed
+gazer
+gazers
+gazes
+gazing
+gear
+geared
+gearing
+gears
+geese
+gel
+gel's
+gelatin
+gelled
+gelling
+gels
+gem
+gem's
+gems
+gender
+gender's
+gendered
+gendering
+genders
+gene
+gene's
+general
+general's
+generalist
+generalist's
+generalists
+generalities
+generality
+generally
+generalness
+generals
+generate
+generated
+generates
+generating
+generation
+generations
+generative
+generatively
+generator
+generator's
+generators
+generic
+generically
+genericness
+generosities
+generosity
+generosity's
+generous
+generously
+generousness
+genes
+genetic
+genetically
+genetics
+genial
+genially
+genialness
+genius
+genius's
+geniuses
+genre
+genre's
+genres
+genteel
+genteeler
+genteelest
+genteelly
+genteelness
+gentle
+gentled
+gentleman
+gentlemanliness
+gentlemanly
+gentleness
+gentler
+gentlest
+gentlewoman
+gentling
+gently
+gentries
+gentry
+genuine
+genuinely
+genuineness
+genus
+geographic
+geographical
+geographically
+geographies
+geography
+geological
+geologist
+geologist's
+geologists
+geometric
+geometries
+geometry
+geranium
+germ
+germ's
+germane
+germen
+germinate
+germinated
+germinates
+germinating
+germination
+germinations
+germinative
+germinatively
+germs
+gestalt
+gesture
+gestured
+gestures
+gesturing
+get
+gets
+getter
+getter's
+gettered
+getters
+getting
+ghastlier
+ghastliness
+ghastly
+ghost
+ghosted
+ghosting
+ghostlier
+ghostliness
+ghostlinesses
+ghostly
+ghosts
+giant
+giant's
+giants
+gibberish
+giddied
+giddier
+giddiness
+giddy
+giddying
+gift
+gifted
+giftedly
+giftedness
+gifts
+gig
+gig's
+gigantic
+giganticness
+giggle
+giggled
+giggler
+giggles
+giggling
+gigglingly
+gigs
+gild
+gilded
+gilder
+gilding
+gilds
+gill
+gill's
+gilled
+giller
+gills
+gilt
+gimmick
+gimmick's
+gimmicks
+gin
+gin's
+ginger
+gingerbread
+gingered
+gingering
+gingerliness
+gingerly
+gingham
+ginghams
+gins
+giraffe
+giraffe's
+giraffes
+gird
+girded
+girder
+girder's
+girders
+girding
+girdle
+girdled
+girdler
+girdles
+girdling
+girds
+girl
+girl's
+girlfriend
+girlfriend's
+girlfriends
+girls
+girt
+girth
+give
+given
+givenness
+givens
+giver
+givers
+gives
+giveth
+giving
+givingly
+gizmo
+gizmo's
+gizmos
+glacial
+glacially
+glacier
+glacier's
+glaciers
+glad
+gladder
+gladdest
+glade
+glades
+gladly
+gladness
+glamour
+glamoured
+glamouring
+glamours
+glance
+glanced
+glances
+glancing
+glancingly
+gland
+gland's
+glanders
+glands
+glare
+glared
+glares
+glaring
+glaringly
+glaringness
+glass
+glassed
+glasses
+glassier
+glassies
+glassiness
+glassy
+glaze
+glazed
+glazer
+glazers
+glazes
+glazing
+gleam
+gleamed
+gleaming
+gleams
+glean
+gleaned
+gleaner
+gleaning
+gleanings
+gleans
+glee
+gleed
+gleeful
+gleefully
+gleefulness
+glees
+glen
+glen's
+glens
+glide
+glided
+glider
+gliders
+glides
+gliding
+glimmer
+glimmered
+glimmering
+glimmers
+glimpse
+glimpsed
+glimpser
+glimpsers
+glimpses
+glimpsing
+glint
+glinted
+glinting
+glints
+glisten
+glistened
+glistening
+glistens
+glitch
+glitch's
+glitches
+glitter
+glittered
+glittering
+glitteringly
+glitters
+global
+globally
+globals
+globe
+globe's
+globes
+globing
+globular
+globularity
+globularly
+globularness
+gloom
+gloomier
+gloomily
+gloominess
+glooms
+gloomy
+gloried
+glories
+glorification
+glorifications
+glorified
+glorifier
+glorifiers
+glorifies
+glorify
+glorious
+gloriously
+gloriousness
+glory
+glorying
+gloss
+glossaries
+glossary
+glossary's
+glossed
+glosses
+glossier
+glossies
+glossiness
+glossing
+glossy
+glottal
+glove
+gloved
+glover
+glovers
+gloves
+gloving
+glow
+glowed
+glower
+glowered
+glowering
+glowers
+glowing
+glowingly
+glows
+glucose
+glue
+glued
+gluer
+gluers
+glues
+gluing
+gnat
+gnat's
+gnats
+gnaw
+gnawed
+gnawer
+gnawing
+gnaws
+go
+goad
+goaded
+goading
+goads
+goal
+goal's
+goals
+goat
+goat's
+goatee
+goatee's
+goatees
+goats
+gobble
+gobbled
+gobbler
+gobblers
+gobbles
+gobbling
+goblet
+goblet's
+goblets
+goblin
+goblin's
+goblins
+god
+god's
+goddess
+goddess's
+goddesses
+godlier
+godlike
+godlikeness
+godliness
+godly
+godmother
+godmother's
+godmothers
+gods
+goer
+goering
+goes
+going
+goings
+gold
+golden
+goldenly
+goldenness
+golding
+golds
+goldsmith
+golf
+golfer
+golfers
+golfing
+golfs
+gone
+goner
+gong
+gong's
+gongs
+gonion
+good
+goodbye
+goodbye's
+goodbyes
+goodie
+goodie's
+goodies
+goodly
+goodness
+goods
+goody
+goody's
+goose
+gooses
+goosing
+gore
+gored
+gores
+gorge
+gorgeous
+gorgeously
+gorgeousness
+gorger
+gorges
+gorging
+gorilla
+gorilla's
+gorillas
+goring
+gosh
+gospel
+gospels
+gossip
+gossiper
+gossipers
+gossips
+got
+gotcha
+gotcha's
+gotchas
+goth
+goto
+gotten
+gouge
+gouged
+gouger
+gouges
+gouging
+govern
+governed
+governess
+governesses
+governing
+government
+government's
+governmental
+governmentally
+governments
+governor
+governor's
+governors
+governs
+gown
+gowned
+gowns
+grab
+grabbed
+grabber
+grabber's
+grabbers
+grabbing
+grabbings
+grabs
+grace
+graced
+graceful
+gracefully
+gracefulness
+graces
+gracing
+gracious
+graciously
+graciousness
+gradation
+gradation's
+gradations
+grade
+graded
+gradely
+grader
+graders
+grades
+gradient
+gradient's
+gradients
+grading
+gradings
+gradual
+gradually
+gradualness
+graduate
+graduated
+graduates
+graduating
+graduation
+graduations
+graft
+grafted
+grafter
+grafting
+grafts
+graham
+graham's
+grahams
+grain
+grained
+grainer
+graining
+grains
+grammar
+grammar's
+grammars
+grammatical
+grammatically
+grammaticalness
+granaries
+granary
+granary's
+grand
+grander
+grandest
+grandeur
+grandfather
+grandfather's
+grandfatherly
+grandfathers
+grandiose
+grandiosely
+grandioseness
+grandkid
+grandkid's
+grandkids
+grandly
+grandma
+grandma's
+grandmother
+grandmother's
+grandmotherly
+grandmothers
+grandness
+grandpa
+grandpa's
+grandparent
+grandparents
+grandpas
+grands
+grandson
+grandson's
+grandsons
+grange
+granger
+granges
+granite
+grannies
+granny
+grant
+grant's
+granted
+granter
+granting
+grants
+granularity
+granulate
+granulated
+granulates
+granulating
+granulation
+granulations
+granulative
+grape
+grape's
+grapes
+grapevine
+grapevine's
+grapevines
+graph
+graph's
+graphed
+graphic
+graphical
+graphically
+graphicness
+graphics
+graphing
+graphite
+graphs
+grapple
+grappled
+grappler
+grapples
+grappling
+grasp
+graspable
+grasped
+grasper
+grasping
+graspingly
+graspingness
+grasps
+grass
+grassed
+grassers
+grasses
+grassier
+grassiest
+grassing
+grassy
+grate
+grated
+grateful
+gratefully
+gratefulness
+grater
+grates
+gratification
+gratifications
+gratified
+gratify
+gratifying
+gratifyingly
+grating
+gratingly
+gratings
+gratitude
+gratuities
+gratuitous
+gratuitously
+gratuitousness
+gratuity
+gratuity's
+grave
+gravel
+gravelly
+gravels
+gravely
+graveness
+graver
+gravers
+graves
+gravest
+gravies
+graving
+gravitation
+gravitational
+gravitationally
+gravities
+gravity
+gravy
+gray
+grayed
+grayer
+grayest
+graying
+grayly
+grayness
+grays
+graze
+grazed
+grazer
+grazes
+grazing
+grease
+greased
+greaser
+greasers
+greases
+greasier
+greasiness
+greasing
+greasy
+great
+greaten
+greatened
+greatening
+greater
+greatest
+greatly
+greatness
+greats
+greed
+greedier
+greedily
+greediness
+greedy
+green
+greened
+greener
+greenest
+greenhouse
+greenhouse's
+greenhouses
+greening
+greenish
+greenishness
+greenly
+greenness
+greens
+greet
+greeted
+greeter
+greeting
+greetings
+greets
+grenade
+grenade's
+grenades
+grew
+grey
+greyest
+greying
+grid
+grid's
+grids
+grief
+grief's
+griefs
+grievance
+grievance's
+grievances
+grieve
+grieved
+griever
+grievers
+grieves
+grieving
+grievingly
+grievous
+grievously
+grievousness
+grill
+grilled
+griller
+grilling
+grills
+grim
+grimed
+griming
+grimly
+grimness
+grin
+grind
+grinder
+grinders
+grinding
+grindingly
+grindings
+grinds
+grindstone
+grindstone's
+grindstones
+grins
+grip
+gripe
+griped
+griper
+gripes
+griping
+gripped
+gripper
+gripper's
+grippers
+gripping
+grippingly
+grips
+grit
+grit's
+grits
+grizzlier
+grizzly
+groan
+groaned
+groaner
+groaners
+groaning
+groans
+grocer
+grocer's
+groceries
+grocers
+grocery
+groom
+groom's
+groomed
+groomer
+grooming
+grooms
+groove
+grooved
+groover
+grooves
+grooving
+grope
+groped
+groper
+gropes
+groping
+gross
+grossed
+grosser
+grosses
+grossest
+grossing
+grossly
+grossness
+grotesque
+grotesquely
+grotesqueness
+grotto
+grotto's
+grottos
+ground
+grounded
+grounder
+grounders
+grounding
+grounds
+groundwork
+group
+group's
+grouped
+grouper
+grouping
+groupings
+groups
+grouse
+groused
+grouser
+grouses
+grousing
+grove
+grovel
+grovels
+grover
+grovers
+groves
+grow
+grower
+growers
+growing
+growingly
+growl
+growled
+growler
+growlier
+growliness
+growling
+growlingly
+growls
+growly
+grown
+grownup
+grownup's
+grownups
+grows
+growth
+growths
+grub
+grub's
+grubs
+grudge
+grudge's
+grudged
+grudger
+grudges
+grudging
+grudgingly
+gruesome
+gruesomely
+gruesomeness
+gruff
+gruffly
+gruffness
+grumble
+grumbled
+grumbler
+grumbles
+grumbling
+grumblingly
+grunt
+grunted
+grunter
+grunting
+grunts
+guarantee
+guaranteed
+guaranteeing
+guaranteer
+guaranteers
+guarantees
+guaranty
+guard
+guarded
+guardedly
+guardedness
+guarder
+guardian
+guardian's
+guardians
+guardianship
+guarding
+guards
+guerrilla
+guerrilla's
+guerrillas
+guess
+guessed
+guesser
+guesses
+guessing
+guest
+guest's
+guested
+guesting
+guests
+guidance
+guidances
+guide
+guidebook
+guidebook's
+guidebooks
+guided
+guideline
+guideline's
+guidelines
+guider
+guides
+guiding
+guild
+guilder
+guile
+guilt
+guiltier
+guiltiest
+guiltily
+guiltiness
+guiltless
+guiltlessly
+guiltlessness
+guilts
+guilty
+guinea
+guineas
+guise
+guise's
+guised
+guises
+guising
+guitar
+guitar's
+guitars
+gulch
+gulch's
+gulches
+gulf
+gulf's
+gulfs
+gull
+gulled
+gullibility
+gullied
+gullies
+gulling
+gulls
+gully
+gully's
+gullying
+gulp
+gulped
+gulper
+gulps
+gum
+gum's
+gums
+gun
+gun's
+gunfire
+gunfires
+gunned
+gunner
+gunner's
+gunners
+gunning
+gunpowder
+gunpowders
+guns
+gurgle
+gurgled
+gurgles
+gurgling
+guru
+guru's
+gurus
+gush
+gushed
+gusher
+gushes
+gushing
+gust
+gust's
+gusts
+gut
+guts
+gutser
+gutter
+guttered
+guttering
+gutters
+guy
+guy's
+guyed
+guyer
+guyers
+guying
+guys
+gym
+gymnasium
+gymnasium's
+gymnasiums
+gymnast
+gymnast's
+gymnastic
+gymnastics
+gymnasts
+gyms
+gypsied
+gypsies
+gypsy
+gypsy's
+gypsying
+gyration
+gyrations
+gyroscope
+gyroscope's
+gyroscopes
+ha
+habit
+habit's
+habitable
+habitableness
+habitat
+habitat's
+habitation
+habitation's
+habitations
+habitats
+habits
+habitual
+habitually
+habitualness
+hack
+hacked
+hacker
+hacker's
+hackers
+hacking
+hacks
+had
+hadn't
+hag
+hagen
+haggard
+haggardly
+haggardness
+hail
+hailed
+hailer
+hailing
+hails
+hair
+hair's
+haircut
+haircut's
+haircuts
+hairdresser
+hairdresser's
+hairdressers
+haired
+hairier
+hairiness
+hairless
+hairlessness
+hairs
+hairy
+hale
+haler
+half
+halfness
+halfway
+halfword
+halfword's
+halfwords
+haling
+hall
+hall's
+haller
+hallmark
+hallmark's
+hallmarked
+hallmarking
+hallmarks
+hallow
+hallowed
+hallowing
+hallows
+halls
+hallway
+hallway's
+hallways
+halt
+halted
+halter
+haltered
+haltering
+halters
+halting
+haltingly
+halts
+halve
+halved
+halvers
+halves
+halving
+ham
+ham's
+hamburger
+hamburger's
+hamburgers
+hamlet
+hamlet's
+hamlets
+hammer
+hammered
+hammerer
+hammering
+hammers
+hammock
+hammock's
+hammocks
+hamper
+hampered
+hampering
+hampers
+hams
+hand
+handbag
+handbag's
+handbags
+handbook
+handbook's
+handbooks
+handcuff
+handcuffed
+handcuffing
+handcuffs
+handed
+handedly
+handedness
+hander
+handers
+handful
+handfuls
+handicap
+handicap's
+handicapped
+handicaps
+handier
+handiest
+handily
+handiness
+handing
+handiwork
+handkerchief
+handkerchief's
+handkerchiefs
+handle
+handled
+handler
+handlers
+handles
+handling
+hands
+handshake
+handshake's
+handshaker
+handshakes
+handshaking
+handsome
+handsomely
+handsomeness
+handsomer
+handsomest
+handwriting
+handwritten
+handy
+hang
+hangar
+hangar's
+hangars
+hanged
+hanger
+hangers
+hanging
+hangover
+hangover's
+hangovers
+hangs
+hap
+haphazard
+haphazardly
+haphazardness
+hapless
+haplessly
+haplessness
+haply
+happen
+happened
+happening
+happenings
+happens
+happier
+happiest
+happily
+happiness
+happy
+harass
+harassed
+harasser
+harasses
+harassing
+harassment
+harassments
+hard
+harden
+hardened
+hardener
+hardening
+hardens
+harder
+hardest
+hardier
+hardiness
+harding
+hardings
+hardly
+hardness
+hardnesses
+hards
+hardship
+hardship's
+hardships
+hardware
+hardwares
+hardy
+hare
+hare's
+hares
+hark
+harked
+harken
+harking
+harks
+harlot
+harlot's
+harlots
+harm
+harmed
+harmer
+harmful
+harmfully
+harmfulness
+harming
+harmless
+harmlessly
+harmlessness
+harmonies
+harmonious
+harmoniously
+harmoniousness
+harmony
+harms
+harness
+harnessed
+harnesser
+harnesses
+harnessing
+harp
+harped
+harper
+harpers
+harping
+harpings
+harps
+harried
+harrier
+harrow
+harrowed
+harrower
+harrowing
+harrows
+harry
+harrying
+harsh
+harshen
+harshened
+harshening
+harsher
+harshest
+harshly
+harshness
+hart
+harvest
+harvested
+harvester
+harvesters
+harvesting
+harvests
+has
+hash
+hashed
+hasher
+hashes
+hashing
+hasn't
+hassle
+hassled
+hassler
+hassles
+hassling
+haste
+hasted
+hasten
+hastened
+hastener
+hastening
+hastens
+hastes
+hastier
+hastiest
+hastily
+hastiness
+hasting
+hastings
+hasty
+hat
+hat's
+hatch
+hatched
+hatcher
+hatcheries
+hatchery
+hatchery's
+hatches
+hatchet
+hatchet's
+hatchets
+hatching
+hate
+hated
+hateful
+hatefully
+hatefulness
+hater
+hates
+hath
+hating
+hatred
+hats
+haughtier
+haughtily
+haughtiness
+haughty
+haul
+hauled
+hauler
+haulers
+hauling
+hauls
+haunch
+haunch's
+haunches
+haunt
+haunted
+haunter
+haunting
+hauntingly
+haunts
+have
+haven
+haven's
+haven't
+havens
+haver
+havering
+havers
+haves
+having
+havoc
+havocs
+hawk
+hawked
+hawker
+hawkers
+hawking
+hawks
+hay
+hayer
+haying
+hays
+hazard
+hazard's
+hazarded
+hazarding
+hazardous
+hazardously
+hazardousness
+hazards
+haze
+haze's
+hazed
+hazel
+hazer
+hazes
+hazier
+haziest
+haziness
+hazing
+hazy
+he
+he'd
+he'll
+he's
+head
+head's
+headache
+headache's
+headaches
+headed
+header
+headers
+headgear
+heading
+heading's
+headings
+headland
+headland's
+headlands
+headline
+headlined
+headliner
+headlines
+headlining
+headlong
+headphone
+headphone's
+headphones
+headquarters
+heads
+headway
+heal
+healed
+healer
+healers
+healing
+heals
+health
+healthful
+healthfully
+healthfulness
+healthier
+healthiest
+healthily
+healthiness
+healthy
+heap
+heaped
+heaping
+heaps
+hear
+heard
+hearer
+hearers
+hearest
+hearing
+hearings
+hearken
+hearkened
+hearkening
+hears
+hearsay
+hearses
+hearsing
+heart
+heart's
+heartache
+heartache's
+heartaches
+hearted
+heartedly
+hearten
+heartened
+heartening
+hearteningly
+heartens
+hearth
+heartier
+hearties
+heartiest
+heartily
+heartiness
+heartless
+heartlessly
+heartlessness
+hearts
+hearty
+heat
+heatable
+heated
+heatedly
+heater
+heaters
+heath
+heathen
+heather
+heating
+heats
+heave
+heaved
+heaven
+heaven's
+heavenliness
+heavenly
+heavens
+heaver
+heavers
+heaves
+heavier
+heavies
+heaviest
+heavily
+heaviness
+heaving
+heavy
+hedge
+hedged
+hedgehog
+hedgehog's
+hedgehogs
+hedger
+hedges
+hedging
+hedgingly
+heed
+heeded
+heeding
+heedless
+heedlessly
+heedlessness
+heeds
+heel
+heeled
+heeler
+heelers
+heeling
+heels
+heifer
+height
+heighten
+heightened
+heightening
+heightens
+heights
+heinous
+heinously
+heinousness
+heir
+heir's
+heiress
+heiress's
+heiresses
+heirs
+held
+hell
+hell's
+heller
+hello
+hellos
+hells
+helm
+helmet
+helmet's
+helmeted
+helmets
+help
+helped
+helper
+helpers
+helpful
+helpfully
+helpfulness
+helping
+helpless
+helplessly
+helplessness
+helps
+hem
+hem's
+hemisphere
+hemisphere's
+hemisphered
+hemispheres
+hemlock
+hemlock's
+hemlocks
+hemostat
+hemostats
+hemp
+hempen
+hems
+hen
+hen's
+hence
+henceforth
+henchman
+henchmen
+hens
+her
+herald
+heralded
+heralding
+heralds
+herb
+herb's
+herbivore
+herbivorous
+herbivorously
+herbs
+herd
+herded
+herder
+herding
+herds
+here
+here's
+hereabout
+hereabouts
+hereafter
+hereby
+hereditary
+heredity
+herein
+hereinafter
+heres
+heresy
+heretic
+heretic's
+heretics
+heretofore
+herewith
+heritage
+heritages
+hermit
+hermit's
+hermits
+hero
+hero's
+heroes
+heroic
+heroically
+heroics
+heroin
+heroine
+heroine's
+heroines
+heroism
+heron
+heron's
+herons
+heros
+herring
+herring's
+herrings
+hers
+herself
+hesitant
+hesitantly
+hesitate
+hesitated
+hesitater
+hesitates
+hesitating
+hesitatingly
+hesitation
+hesitations
+heterogeneous
+heterogeneously
+heterogeneousness
+heuristic
+heuristic's
+heuristically
+heuristics
+hew
+hewed
+hewer
+hewing
+hews
+hex
+hexagonal
+hexagonally
+hexer
+hey
+hickories
+hickory
+hid
+hidden
+hide
+hided
+hideous
+hideously
+hideousness
+hideout
+hideout's
+hideouts
+hider
+hides
+hiding
+hierarchical
+hierarchically
+hierarchies
+hierarchy
+hierarchy's
+high
+higher
+highest
+highland
+highlander
+highlands
+highlight
+highlighted
+highlighting
+highlights
+highly
+highness
+highness's
+highnesses
+highway
+highway's
+highways
+hijack
+hijacked
+hijacker
+hijackers
+hijacking
+hijacks
+hike
+hiked
+hiker
+hikers
+hikes
+hiking
+hilarious
+hilariously
+hilariousness
+hill
+hill's
+hilled
+hiller
+hilling
+hillock
+hillocks
+hills
+hillside
+hilltop
+hilltop's
+hilltops
+hilt
+hilt's
+hilts
+him
+hims
+himself
+hind
+hinder
+hindered
+hinderer
+hindering
+hinders
+hindrance
+hindrances
+hinds
+hindsight
+hinge
+hinged
+hinger
+hinges
+hinging
+hint
+hinted
+hinter
+hinting
+hints
+hip
+hip's
+hipness
+hips
+hire
+hired
+hirer
+hirers
+hires
+hiring
+hirings
+his
+hiss
+hissed
+hisser
+hisses
+hissing
+histogram
+histogram's
+histograms
+historian
+historian's
+historians
+historic
+historical
+historically
+historicalness
+histories
+history
+history's
+hit
+hit's
+hitch
+hitched
+hitcher
+hitches
+hitchhike
+hitchhiked
+hitchhiker
+hitchhikers
+hitchhikes
+hitchhiking
+hitching
+hither
+hitherto
+hits
+hitter
+hitter's
+hitters
+hitting
+hive
+hives
+hiving
+hoar
+hoard
+hoarded
+hoarder
+hoarding
+hoards
+hoarier
+hoariness
+hoarse
+hoarsely
+hoarseness
+hoarser
+hoarsest
+hoary
+hoax
+hoax's
+hoaxed
+hoaxer
+hoaxes
+hoaxing
+hobbies
+hobble
+hobbled
+hobbler
+hobbles
+hobbling
+hobby
+hobby's
+hobbyist
+hobbyist's
+hobbyists
+hockey
+hoe
+hoe's
+hoer
+hoes
+hog
+hog's
+hogs
+hoist
+hoisted
+hoister
+hoisting
+hoists
+hold
+holden
+holder
+holders
+holding
+holdings
+holds
+hole
+hole's
+holed
+holes
+holiday
+holiday's
+holidayer
+holidays
+holier
+holies
+holiness
+holing
+holistic
+hollies
+hollow
+hollowed
+hollower
+hollowest
+hollowing
+hollowly
+hollowness
+hollows
+holly
+holocaust
+hologram
+hologram's
+holograms
+holy
+homage
+homaged
+homager
+homages
+homaging
+home
+homebuilt
+homed
+homeless
+homelessness
+homelier
+homeliness
+homely
+homemade
+homemaker
+homemaker's
+homemakers
+homeomorphic
+homeomorphism
+homeomorphism's
+homeomorphisms
+homer
+homers
+homes
+homesick
+homesickness
+homespun
+homestead
+homesteader
+homesteaders
+homesteads
+homeward
+homewards
+homework
+homeworker
+homeworkers
+homing
+homogeneities
+homogeneity
+homogeneity's
+homogeneous
+homogeneously
+homogeneousness
+homomorphic
+homomorphism
+homomorphism's
+homomorphisms
+hone
+honed
+honer
+hones
+honest
+honestly
+honesty
+honey
+honeycomb
+honeycombed
+honeyed
+honeying
+honeymoon
+honeymooned
+honeymooner
+honeymooners
+honeymooning
+honeymoons
+honeys
+honeysuckle
+honing
+honorary
+hood
+hood's
+hooded
+hoodedness
+hooding
+hoods
+hoodwink
+hoodwinked
+hoodwinker
+hoodwinking
+hoodwinks
+hoof
+hoof's
+hoofed
+hoofer
+hoofs
+hook
+hooked
+hookedness
+hooker
+hookers
+hooking
+hooks
+hoop
+hooped
+hooper
+hooping
+hoops
+hooray
+hooray's
+hoorays
+hoot
+hooted
+hooter
+hooters
+hooting
+hoots
+hop
+hope
+hoped
+hopeful
+hopefully
+hopefulness
+hopefuls
+hopeless
+hopelessly
+hopelessness
+hoper
+hopes
+hoping
+hopped
+hopper
+hopper's
+hoppers
+hopping
+hops
+horde
+horde's
+hordes
+horizon
+horizon's
+horizons
+horizontal
+horizontally
+hormone
+hormone's
+hormones
+horn
+horned
+hornedness
+hornet
+hornet's
+hornets
+horns
+horrendous
+horrendously
+horrible
+horribleness
+horribly
+horrid
+horridly
+horridness
+horrified
+horrifies
+horrify
+horrifying
+horrifyingly
+horror
+horror's
+horrors
+horse
+horse's
+horseback
+horsely
+horseman
+horsepower
+horsepowers
+horses
+horseshoe
+horseshoer
+horseshoes
+horsing
+hose
+hose's
+hosed
+hoses
+hosing
+hospitable
+hospitably
+hospital
+hospital's
+hospitality
+hospitals
+host
+host's
+hostage
+hostage's
+hostages
+hosted
+hostess
+hostess's
+hostesses
+hostile
+hostilely
+hostilities
+hostility
+hosting
+hostly
+hosts
+hot
+hotel
+hotel's
+hotels
+hotly
+hotness
+hotter
+hottest
+hound
+hounded
+hounder
+hounding
+hounds
+hour
+hour's
+hourly
+hours
+house
+house's
+housed
+houseflies
+housefly
+housefly's
+household
+household's
+householder
+householders
+households
+housekeeper
+housekeeper's
+housekeepers
+housekeeping
+houser
+houses
+housetop
+housetop's
+housetops
+housewife
+housewife's
+housewifeliness
+housewifely
+housework
+houseworker
+houseworkers
+housing
+housings
+hovel
+hovel's
+hovels
+hover
+hovered
+hoverer
+hovering
+hovers
+how
+how's
+however
+howl
+howled
+howler
+howling
+howls
+hows
+hrs
+hub
+hub's
+hubris
+hubs
+huddle
+huddled
+huddler
+huddles
+huddling
+hue
+hue's
+hued
+hues
+hug
+huge
+hugely
+hugeness
+huger
+hugest
+hugs
+huh
+hull
+hull's
+hulled
+huller
+hulling
+hulls
+hum
+human
+humane
+humanely
+humaneness
+humanities
+humanity
+humanity's
+humanly
+humanness
+humans
+humble
+humbled
+humbleness
+humbler
+humbles
+humblest
+humbling
+humbly
+humid
+humidification
+humidifications
+humidified
+humidifier
+humidifiers
+humidifies
+humidify
+humidifying
+humidities
+humidity
+humidly
+humiliate
+humiliated
+humiliates
+humiliating
+humiliatingly
+humiliation
+humiliations
+humility
+hummed
+humming
+humorous
+humorously
+humorousness
+hump
+humped
+humping
+humps
+hums
+hunch
+hunched
+hunches
+hundred
+hundreds
+hundredth
+hung
+hunger
+hungered
+hungering
+hungers
+hungrier
+hungriest
+hungrily
+hungriness
+hungry
+hunk
+hunk's
+hunker
+hunkered
+hunkering
+hunkers
+hunks
+hunt
+hunted
+hunter
+hunters
+hunting
+hunts
+huntsman
+hurdle
+hurdled
+hurdler
+hurdles
+hurdling
+hurl
+hurled
+hurler
+hurlers
+hurling
+hurrah
+hurricane
+hurricane's
+hurricanes
+hurried
+hurriedly
+hurriedness
+hurrier
+hurries
+hurry
+hurrying
+hurt
+hurter
+hurting
+hurtingly
+hurts
+husband
+husband's
+husbander
+husbandly
+husbandry
+husbands
+hush
+hushed
+hushes
+hushing
+husk
+husked
+husker
+huskier
+huskies
+huskiness
+husking
+husks
+husky
+hustle
+hustled
+hustler
+hustlers
+hustles
+hustling
+hut
+hut's
+huts
+hyacinth
+hybrid
+hybrids
+hydraulic
+hydraulically
+hydraulics
+hydrodynamic
+hydrodynamics
+hydrogen
+hydrogen's
+hydrogens
+hygiene
+hymn
+hymn's
+hymning
+hymns
+hype
+hype's
+hyped
+hyper
+hyperbolic
+hypertext
+hypertext's
+hypes
+hyphen
+hyphen's
+hyphened
+hyphening
+hyphens
+hypocrisies
+hypocrisy
+hypocrite
+hypocrite's
+hypocrites
+hypodermic
+hypodermics
+hypotheses
+hypothesis
+hypothetical
+hypothetically
+hysteresis
+hysterical
+hysterically
+ice
+iceberg
+iceberg's
+icebergs
+iced
+ices
+icier
+iciest
+iciness
+icing
+icings
+icon
+icon's
+icons
+icy
+id
+id's
+idea
+idea's
+ideal
+idealism
+idealistic
+ideally
+ideals
+ideas
+identical
+identically
+identicalness
+identifiable
+identifiably
+identification
+identifications
+identified
+identifier
+identifiers
+identifies
+identify
+identifying
+identities
+identity
+identity's
+ideological
+ideologically
+ideologies
+ideology
+idiocies
+idiocy
+idiosyncrasies
+idiosyncrasy
+idiosyncrasy's
+idiosyncratic
+idiot
+idiot's
+idiotic
+idiots
+idle
+idled
+idleness
+idler
+idlers
+idles
+idlest
+idling
+idly
+idol
+idol's
+idolatry
+idols
+if
+ignition
+ignoble
+ignobleness
+ignorance
+ignorant
+ignorantly
+ignorantness
+ignore
+ignored
+ignorer
+ignores
+ignoring
+ii
+iii
+ill
+illegal
+illegalities
+illegality
+illegally
+illicit
+illicitly
+illiterate
+illiterately
+illiterateness
+illiterates
+illness
+illness's
+illnesses
+illogical
+illogically
+illogicalness
+ills
+illuminate
+illuminated
+illuminates
+illuminating
+illuminatingly
+illumination
+illuminations
+illuminative
+illusion
+illusion's
+illusions
+illusive
+illusively
+illusiveness
+illustrate
+illustrated
+illustrates
+illustrating
+illustration
+illustrations
+illustrative
+illustratively
+illustrator
+illustrator's
+illustrators
+illustrious
+illustriously
+illustriousness
+illy
+image
+imaged
+images
+imaginable
+imaginableness
+imaginably
+imaginariness
+imaginary
+imagination
+imagination's
+imaginations
+imaginative
+imaginatively
+imaginativeness
+imagine
+imagined
+imaginer
+imagines
+imaging
+imagining
+imaginings
+imbalance
+imbalances
+imitate
+imitated
+imitates
+imitating
+imitation
+imitations
+imitative
+imitatively
+imitativeness
+immaculate
+immaculately
+immaculateness
+immaterial
+immaterially
+immaterialness
+immature
+immaturely
+immatureness
+immaturity
+immediacies
+immediacy
+immediate
+immediately
+immediateness
+immemorial
+immemorially
+immense
+immensely
+immenseness
+immerse
+immersed
+immerser
+immerses
+immersing
+immersion
+immersions
+immigrant
+immigrant's
+immigrants
+immigrate
+immigrated
+immigrates
+immigrating
+immigration
+imminent
+imminently
+imminentness
+immoral
+immoralities
+immorality
+immorally
+immortal
+immortality
+immortally
+immortals
+immovability
+immovable
+immovableness
+immovably
+immune
+immunities
+immunity
+immunity's
+immunology
+immutable
+immutableness
+imp
+imp's
+impact
+impacted
+impacter
+impacting
+impaction
+impactions
+impactive
+impactor
+impactor's
+impactors
+impacts
+impair
+impaired
+impairer
+impairing
+impairs
+impart
+imparted
+impartial
+impartially
+imparting
+imparts
+impasse
+impasses
+impassion
+impassioned
+impassioning
+impassions
+impassive
+impassively
+impassiveness
+impatience
+impatient
+impatiently
+impeach
+impeached
+impeaches
+impeaching
+impedance
+impedance's
+impedances
+impede
+impeded
+impeder
+impedes
+impediment
+impediment's
+impediments
+impeding
+impel
+impels
+impending
+impenetrability
+impenetrable
+impenetrableness
+impenetrably
+imperative
+imperatively
+imperativeness
+imperatives
+imperfect
+imperfection
+imperfection's
+imperfections
+imperfective
+imperfectly
+imperfectness
+imperial
+imperialism
+imperialist
+imperialist's
+imperialists
+imperially
+imperil
+imperious
+imperiously
+imperiousness
+impermanence
+impermanent
+impermanently
+impermissible
+impersonal
+impersonally
+impersonate
+impersonated
+impersonates
+impersonating
+impersonation
+impersonations
+impertinent
+impertinently
+imperturbability
+impervious
+imperviously
+imperviousness
+impetuous
+impetuously
+impetuousness
+impetus
+impinge
+impinged
+impinges
+impinging
+impious
+impiously
+implant
+implanted
+implanter
+implanting
+implants
+implausible
+implement
+implementable
+implementation
+implementation's
+implementations
+implemented
+implementer
+implementers
+implementing
+implementor
+implementor's
+implementors
+implements
+implicant
+implicant's
+implicants
+implicate
+implicated
+implicates
+implicating
+implication
+implications
+implicative
+implicatively
+implicativeness
+implicit
+implicitly
+implicitness
+implied
+implies
+implore
+implored
+implores
+imploring
+imply
+implying
+import
+importance
+important
+importantly
+importation
+importations
+imported
+importer
+importers
+importing
+imports
+impose
+imposed
+imposer
+imposes
+imposing
+imposingly
+imposition
+imposition's
+impositions
+impossibilities
+impossibility
+impossible
+impossibleness
+impossibles
+impossibly
+impostor
+impostor's
+impostors
+impotence
+impotent
+impotently
+impoverish
+impoverished
+impoverisher
+impoverishes
+impoverishing
+impoverishment
+impracticable
+impracticableness
+impractical
+impracticality
+impractically
+impracticalness
+imprecise
+imprecisely
+impreciseness
+imprecision
+impregnable
+impregnableness
+impress
+impressed
+impresser
+impresses
+impressing
+impression
+impression's
+impressionable
+impressionableness
+impressionist
+impressionistic
+impressionists
+impressions
+impressive
+impressively
+impressiveness
+impressment
+imprint
+imprinted
+imprinting
+imprints
+imprison
+imprisoned
+imprisoning
+imprisonment
+imprisonment's
+imprisonments
+imprisons
+improbable
+improbableness
+impromptu
+improper
+improperly
+improperness
+improve
+improved
+improvement
+improvements
+improver
+improves
+improving
+improvisation
+improvisation's
+improvisational
+improvisations
+improvise
+improvised
+improviser
+improvisers
+improvises
+improvising
+imps
+impudent
+impudently
+impulse
+impulsed
+impulses
+impulsing
+impulsion
+impulsions
+impulsive
+impulsively
+impulsiveness
+impunity
+impure
+impurely
+impureness
+impurities
+impurity
+impurity's
+impute
+imputed
+imputes
+imputing
+in
+inabilities
+inability
+inaccessibility
+inaccessible
+inaccessibly
+inaccuracies
+inaccuracy
+inaccurate
+inaccurately
+inactions
+inactivation
+inactive
+inactively
+inactivity
+inadequacies
+inadequacy
+inadequate
+inadequately
+inadequateness
+inadmissibility
+inadmissible
+inadvertent
+inadvertently
+inadvisability
+inadvisable
+inalterable
+inalterableness
+inane
+inanely
+inaneness
+inaner
+inanest
+inanimate
+inanimately
+inanimateness
+inapparently
+inapplicability
+inapplicable
+inappreciable
+inappreciably
+inappreciative
+inappreciatively
+inappreciativeness
+inapproachable
+inappropriate
+inappropriately
+inappropriateness
+inapt
+inaptly
+inaptness
+inarguable
+inarguably
+inarticulable
+inartistic
+inartistically
+inasmuch
+inattentive
+inattentively
+inattentiveness
+inaudible
+inaudibly
+inaugural
+inaugurate
+inaugurated
+inaugurating
+inauguration
+inaugurations
+inauspicious
+inauspiciously
+inauspiciousness
+inauthentic
+inauthenticity
+inboards
+inborn
+inbounds
+inbred
+inbuilt
+incantation
+incantations
+incapable
+incapableness
+incapably
+incapacitating
+incarnation
+incarnation's
+incarnations
+incautious
+incautiously
+incautiousness
+incendiaries
+incendiary
+incense
+incensed
+incenses
+incensing
+incentive
+incentive's
+incentively
+incentives
+inception
+inceptions
+incessant
+incessantly
+inch
+inched
+inches
+inching
+incidence
+incidences
+incident
+incident's
+incidental
+incidentally
+incidentals
+incidents
+incipient
+incipiently
+incision
+incision's
+incisions
+incitations
+incite
+incited
+inciter
+incites
+inciting
+incivility
+inclination
+inclination's
+inclinations
+incline
+inclined
+incliner
+inclines
+inclining
+inclose
+inclosed
+incloses
+inclosing
+include
+included
+includes
+including
+inclusion
+inclusion's
+inclusions
+inclusive
+inclusively
+inclusiveness
+incoherence
+incoherences
+incoherent
+incoherently
+income
+incomer
+incomers
+incomes
+incoming
+incommensurate
+incomparability
+incomparable
+incomparably
+incompatibilities
+incompatibility
+incompatibility's
+incompatible
+incompatibly
+incompetence
+incompetent
+incompetent's
+incompetently
+incompetents
+incomplete
+incompletely
+incompleteness
+incompletion
+incomprehensibility
+incomprehensible
+incomprehensibleness
+incomprehensibly
+incomprehension
+incompressible
+incomputable
+inconceivable
+inconceivableness
+inconceivably
+inconclusive
+inconclusively
+inconclusiveness
+inconformity
+incongruence
+incongruent
+incongruently
+inconsequential
+inconsequentially
+inconsequently
+inconsiderable
+inconsiderableness
+inconsiderably
+inconsiderate
+inconsiderately
+inconsiderateness
+inconsideration
+inconsistencies
+inconsistency
+inconsistency's
+inconsistent
+inconsistently
+inconsolable
+inconsolableness
+inconspicuous
+inconspicuously
+inconspicuousness
+inconstancy
+inconstantly
+incontestable
+incontinently
+incontrollable
+inconvenience
+inconvenienced
+inconveniences
+inconveniencing
+inconvenient
+inconveniently
+inconvertibility
+inconvertible
+incorporate
+incorporated
+incorporates
+incorporating
+incorporation
+incorporative
+incorrect
+incorrectly
+incorrectness
+incorruption
+increase
+increased
+increaser
+increases
+increasing
+increasingly
+incredibility
+incredible
+incredibleness
+incredibly
+incredulity
+incredulous
+incredulously
+increment
+incremental
+incrementally
+incremented
+incrementing
+increments
+incubate
+incubated
+incubates
+incubating
+incubation
+incubative
+incubator
+incubator's
+incubators
+incur
+incurable
+incurableness
+incurables
+incurably
+incurred
+incurring
+incurs
+indebted
+indebtedness
+indecent
+indecently
+indecision
+indecisive
+indecisively
+indecisiveness
+indecomposable
+indeed
+indefinable
+indefinableness
+indefinite
+indefinitely
+indefiniteness
+indemnity
+indent
+indentation
+indentation's
+indentations
+indented
+indenter
+indenting
+indents
+independence
+independent
+independently
+independents
+indescribable
+indescribableness
+indeterminable
+indeterminableness
+indeterminacies
+indeterminacy
+indeterminacy's
+indeterminate
+indeterminately
+indeterminateness
+indetermination
+indeterminism
+indeterministic
+index
+indexable
+indexed
+indexer
+indexers
+indexes
+indexing
+indicate
+indicated
+indicates
+indicating
+indication
+indications
+indicative
+indicatively
+indicatives
+indicator
+indicator's
+indicators
+indices
+indictment
+indictment's
+indictments
+indifference
+indifferent
+indifferently
+indigenous
+indigenously
+indigenousness
+indigested
+indigestible
+indigestion
+indignant
+indignantly
+indignation
+indignities
+indignity
+indigo
+indirect
+indirected
+indirecting
+indirection
+indirections
+indirectly
+indirectness
+indirects
+indiscernible
+indiscipline
+indisciplined
+indiscreet
+indiscreetly
+indiscreetness
+indiscriminate
+indiscriminately
+indiscriminateness
+indiscriminating
+indiscriminatingly
+indiscrimination
+indispensability
+indispensable
+indispensableness
+indispensably
+indisposed
+indisposes
+indistinct
+indistinctive
+indistinctly
+indistinctness
+indistinguishable
+indistinguishableness
+individual
+individual's
+individualistic
+individuality
+individually
+individuals
+indivisibility
+indivisible
+indivisibleness
+indoctrinate
+indoctrinated
+indoctrinates
+indoctrinating
+indoctrination
+indolent
+indolently
+indomitable
+indomitableness
+indoor
+indoors
+induce
+induced
+inducement
+inducement's
+inducements
+inducer
+induces
+inducing
+induct
+inductance
+inductances
+inducted
+inducting
+induction
+induction's
+inductions
+inductive
+inductively
+inductiveness
+inductor
+inductor's
+inductors
+inducts
+indulge
+indulged
+indulgence
+indulgence's
+indulgences
+indulger
+indulges
+indulging
+industrial
+industrialist
+industrialist's
+industrialists
+industrially
+industrials
+industries
+industrious
+industriously
+industriousness
+industry
+industry's
+inedited
+ineffective
+ineffectively
+ineffectiveness
+inefficacy
+inefficiencies
+inefficiency
+inefficient
+inefficiently
+inelastically
+inelegant
+inelegantly
+ineloquent
+ineloquently
+inequalities
+inequality
+inequitably
+inequities
+inequity
+inert
+inertia
+inertias
+inertly
+inertness
+inescapable
+inescapably
+inessential
+inestimable
+inevitabilities
+inevitability
+inevitable
+inevitableness
+inevitably
+inexact
+inexactitude
+inexactly
+inexactness
+inexcusable
+inexcusableness
+inexcusably
+inexhaustible
+inexhaustibleness
+inexistent
+inexorable
+inexorableness
+inexorably
+inexpedient
+inexpediently
+inexpensive
+inexpensively
+inexpensiveness
+inexperience
+inexperienced
+inexplainable
+inexplicable
+inexplicableness
+inexplicably
+inexpressibility
+inexpressible
+inexpressibleness
+inexpressibly
+inexpressive
+inexpressively
+inexpressiveness
+inextensible
+infallibility
+infallible
+infallibly
+infamous
+infamously
+infancy
+infant
+infant's
+infantry
+infants
+infeasible
+infect
+infected
+infecting
+infection
+infection's
+infections
+infectious
+infectiously
+infectiousness
+infective
+infects
+infer
+inference
+inference's
+inferencer
+inferences
+inferencing
+inferential
+inferentially
+inferior
+inferior's
+inferiority
+inferiorly
+inferiors
+infernal
+infernally
+inferno
+inferno's
+infernos
+inferred
+inferring
+infers
+infertility
+infest
+infested
+infester
+infesting
+infests
+infidel
+infidel's
+infidelity
+infidels
+infields
+infighter
+infighter's
+infighters
+infighting
+infiltrate
+infiltrated
+infiltrates
+infiltrating
+infiltration
+infiltrative
+infinite
+infinitely
+infiniteness
+infinitesimal
+infinitesimally
+infinities
+infinitive
+infinitive's
+infinitively
+infinitives
+infinitum
+infinity
+infirmity
+infix
+infix's
+infixes
+inflame
+inflamed
+inflamer
+inflaming
+inflammable
+inflammableness
+inflatable
+inflate
+inflated
+inflater
+inflates
+inflating
+inflation
+inflationary
+inflexibility
+inflexible
+inflexibleness
+inflexibly
+inflict
+inflicted
+inflicter
+inflicting
+inflictive
+inflicts
+inflows
+influence
+influenced
+influencer
+influences
+influencing
+influent
+influential
+influentially
+influenza
+inform
+informal
+informality
+informally
+informant
+informant's
+informants
+information
+informational
+informations
+informative
+informatively
+informativeness
+informed
+informer
+informers
+informing
+informs
+infractions
+infrastructure
+infrastructures
+infrequent
+infrequently
+infringe
+infringed
+infringement
+infringement's
+infringements
+infringer
+infringes
+infringing
+infuriate
+infuriated
+infuriately
+infuriates
+infuriating
+infuriatingly
+infuriation
+infuse
+infused
+infuser
+infuses
+infusing
+infusion
+infusions
+ingenious
+ingeniously
+ingeniousness
+ingenuity
+inglorious
+ingloriously
+ingloriousness
+ingot
+ingrained
+ingrainedly
+ingrains
+ingratitude
+ingredient
+ingredient's
+ingredients
+ingrown
+ingrownness
+ingrowth
+ingrowths
+inhabit
+inhabitable
+inhabitance
+inhabitant
+inhabitant's
+inhabitants
+inhabited
+inhabiter
+inhabiting
+inhabits
+inhale
+inhaled
+inhaler
+inhales
+inhaling
+inharmonious
+inharmoniously
+inharmoniousness
+inhere
+inhered
+inherent
+inherently
+inheres
+inhering
+inherit
+inheritable
+inheritableness
+inheritance
+inheritance's
+inheritances
+inherited
+inheriting
+inheritor
+inheritor's
+inheritors
+inheritress
+inheritress's
+inheritresses
+inheritrices
+inheritrix
+inherits
+inhibit
+inhibited
+inhibiter
+inhibiting
+inhibition
+inhibition's
+inhibitions
+inhibitive
+inhibitors
+inhibits
+inholding
+inholdings
+inhomogeneities
+inhomogeneity
+inhospitable
+inhospitableness
+inhospitably
+inhospitality
+inhuman
+inhumane
+inhumanely
+inhumanities
+inhumanly
+inhumanness
+inion
+iniquities
+iniquity
+iniquity's
+initial
+initialness
+initials
+initiate
+initiated
+initiates
+initiating
+initiation
+initiations
+initiative
+initiative's
+initiatives
+initiator
+initiator's
+initiators
+inject
+injected
+injecting
+injection
+injection's
+injections
+injective
+injects
+injudicious
+injudiciously
+injudiciousness
+injunction
+injunction's
+injunctions
+injure
+injured
+injurer
+injures
+injuries
+injuring
+injurious
+injuriously
+injuriousness
+injury
+injury's
+injustice
+injustice's
+injustices
+ink
+inked
+inker
+inkers
+inking
+inkings
+inkling
+inkling's
+inklings
+inks
+inlaid
+inland
+inlander
+inlet
+inlet's
+inlets
+inlier
+inly
+inlying
+inmate
+inmate's
+inmates
+inn
+innards
+innate
+innately
+innateness
+inner
+innerly
+innermost
+inning
+innings
+innocence
+innocent
+innocently
+innocents
+innocuous
+innocuously
+innocuousness
+innovate
+innovated
+innovates
+innovating
+innovation
+innovation's
+innovations
+innovative
+innovativeness
+inns
+innumerability
+innumerable
+innumerableness
+innumerably
+inoperable
+inopportune
+inopportunely
+inopportuneness
+inordinate
+inordinately
+inordinateness
+inorganic
+input
+input's
+inputed
+inputer
+inputing
+inputs
+inputting
+inquietude
+inquire
+inquired
+inquirer
+inquirers
+inquires
+inquiries
+inquiring
+inquiringly
+inquiry
+inquiry's
+inquisition
+inquisition's
+inquisitions
+inquisitive
+inquisitively
+inquisitiveness
+inroad
+inroads
+ins
+insane
+insanely
+insaneness
+insanitary
+insanity
+inscribe
+inscribed
+inscriber
+inscribes
+inscribing
+inscription
+inscription's
+inscriptions
+insect
+insect's
+insects
+insecure
+insecurely
+insecureness
+insecurity
+insensible
+insensibleness
+insensibly
+insensitive
+insensitively
+insensitiveness
+insensitivity
+inseparable
+inseparableness
+insert
+inserted
+inserter
+inserting
+insertion
+insertion's
+insertions
+inserts
+insets
+insetting
+inside
+insider
+insiders
+insides
+insidious
+insidiously
+insidiousness
+insight
+insight's
+insightful
+insightfully
+insights
+insignia
+insignias
+insignificance
+insignificances
+insignificant
+insignificantly
+insincerity
+insinuate
+insinuated
+insinuates
+insinuating
+insinuatingly
+insinuation
+insinuations
+insinuative
+insist
+insisted
+insistence
+insistent
+insistently
+insisting
+insists
+insociability
+insociable
+insociably
+insofar
+insolence
+insolent
+insolently
+insolubility
+insoluble
+insolubleness
+insolvable
+inspect
+inspected
+inspecting
+inspection
+inspection's
+inspections
+inspective
+inspector
+inspector's
+inspectors
+inspects
+inspiration
+inspiration's
+inspirations
+inspire
+inspired
+inspirer
+inspires
+inspiring
+instabilities
+instability
+install
+installation
+installation's
+installations
+installed
+installer
+installers
+installing
+installment
+installment's
+installments
+installs
+instance
+instanced
+instances
+instancing
+instant
+instantaneous
+instantaneously
+instantaneousness
+instanter
+instantiate
+instantiated
+instantiates
+instantiating
+instantiation
+instantiation's
+instantiations
+instantly
+instantness
+instants
+instated
+instates
+instead
+insteps
+instigate
+instigated
+instigates
+instigating
+instigation
+instigative
+instigator
+instigator's
+instigators
+instills
+instinct
+instinct's
+instinctive
+instinctively
+instincts
+institute
+instituted
+instituter
+instituters
+institutes
+instituting
+institution
+institution's
+institutional
+institutionally
+institutions
+institutive
+instruct
+instructed
+instructing
+instruction
+instruction's
+instructional
+instructions
+instructive
+instructively
+instructiveness
+instructor
+instructor's
+instructors
+instructs
+instrument
+instrumental
+instrumentalist
+instrumentalist's
+instrumentalists
+instrumentally
+instrumentals
+instrumentation
+instrumented
+instrumenting
+instruments
+insufficiencies
+insufficiency
+insufficient
+insufficiently
+insulate
+insulated
+insulates
+insulating
+insulation
+insulations
+insulator
+insulator's
+insulators
+insult
+insulted
+insulter
+insulting
+insultingly
+insults
+insuperable
+insupportable
+insupportableness
+insurance
+insurances
+insure
+insured
+insurer
+insurers
+insures
+insurgent
+insurgent's
+insurgents
+insuring
+insurmountable
+insurrection
+insurrection's
+insurrections
+insusceptible
+intact
+intactness
+intakes
+intangible
+intangible's
+intangibleness
+intangibles
+intangibly
+integer
+integer's
+integers
+integral
+integral's
+integrally
+integrals
+integrate
+integrated
+integrates
+integrating
+integration
+integrations
+integrative
+integrity
+intellect
+intellect's
+intellective
+intellectively
+intellects
+intellectual
+intellectually
+intellectualness
+intellectuals
+intelligence
+intelligencer
+intelligences
+intelligent
+intelligently
+intelligibility
+intelligible
+intelligibleness
+intelligibly
+intemperance
+intemperate
+intemperately
+intemperateness
+intend
+intended
+intendedly
+intendedness
+intender
+intending
+intends
+intense
+intensely
+intenseness
+intensification
+intensified
+intensifier
+intensifiers
+intensifies
+intensify
+intensifying
+intension
+intensities
+intensity
+intensive
+intensively
+intensiveness
+intent
+intention
+intentional
+intentionally
+intentioned
+intentions
+intently
+intentness
+intents
+interact
+interacted
+interacting
+interaction
+interaction's
+interactions
+interactive
+interactively
+interactivity
+interacts
+intercept
+intercepted
+intercepter
+intercepting
+intercepts
+interchange
+interchangeability
+interchangeable
+interchangeableness
+interchangeably
+interchanged
+interchanger
+interchanges
+interchanging
+interchangings
+intercity
+intercommunicate
+intercommunicated
+intercommunicates
+intercommunicating
+intercommunication
+interconnect
+interconnected
+interconnectedness
+interconnecting
+interconnection
+interconnection's
+interconnections
+interconnectivity
+interconnects
+intercourse
+interdependence
+interdependencies
+interdependency
+interdependent
+interdependently
+interdisciplinary
+interest
+interested
+interestedly
+interesting
+interestingly
+interestingness
+interests
+interface
+interfaced
+interfacer
+interfaces
+interfacing
+interfere
+interfered
+interference
+interferences
+interferer
+interferes
+interfering
+interferingly
+interim
+interior
+interior's
+interiorly
+interiors
+interlace
+interlaced
+interlaces
+interlacing
+interleave
+interleaved
+interleaves
+interleaving
+interlink
+interlinked
+interlinking
+interlinks
+interlisp
+interlisp's
+intermediaries
+intermediary
+intermediate
+intermediate's
+intermediated
+intermediately
+intermediateness
+intermediates
+intermediating
+intermediation
+interminable
+intermingle
+intermingled
+intermingles
+intermingling
+intermittent
+intermittently
+intermix
+intermixed
+intermixer
+intermixes
+intermixing
+intermodule
+intern
+internal
+internally
+internals
+international
+internationality
+internationally
+internationals
+interned
+interning
+interns
+interpersonal
+interpersonally
+interplay
+interpolate
+interpolated
+interpolates
+interpolating
+interpolation
+interpolations
+interpolative
+interpose
+interposed
+interposer
+interposes
+interposing
+interpret
+interpretable
+interpretation
+interpretation's
+interpretations
+interpreted
+interpreter
+interpreters
+interpreting
+interpretive
+interpretively
+interprets
+interprocess
+interrelate
+interrelated
+interrelatedly
+interrelatedness
+interrelates
+interrelating
+interrelation
+interrelations
+interrelationship
+interrelationship's
+interrelationships
+interrogate
+interrogated
+interrogates
+interrogating
+interrogation
+interrogations
+interrogative
+interrogatively
+interrogatives
+interrupt
+interrupted
+interrupter
+interrupters
+interruptible
+interrupting
+interruption
+interruption's
+interruptions
+interruptive
+interrupts
+intersect
+intersected
+intersecting
+intersection
+intersection's
+intersections
+intersects
+intersperse
+interspersed
+intersperses
+interspersing
+interspersion
+interspersions
+interstage
+interstate
+intertask
+intertwine
+intertwined
+intertwines
+intertwining
+interval
+interval's
+intervals
+intervene
+intervened
+intervener
+intervenes
+intervening
+intervention
+intervention's
+interventions
+interview
+interviewed
+interviewee
+interviewee's
+interviewees
+interviewer
+interviewer's
+interviewers
+interviewing
+interviews
+interwoven
+intestinal
+intestinally
+intestine
+intestine's
+intestines
+intimacy
+intimate
+intimated
+intimately
+intimateness
+intimater
+intimates
+intimating
+intimation
+intimations
+intimidate
+intimidated
+intimidates
+intimidating
+intimidation
+into
+intolerability
+intolerable
+intolerableness
+intolerably
+intolerance
+intolerant
+intolerantly
+intolerantness
+intonation
+intonation's
+intonations
+intoned
+intoner
+intoxicate
+intoxicated
+intoxicatedly
+intoxicating
+intoxication
+intractability
+intractable
+intractableness
+intractably
+intramural
+intramurally
+intransigent
+intransigently
+intransigents
+intransitive
+intransitively
+intransitiveness
+intraprocess
+intricacies
+intricacy
+intricate
+intricately
+intricateness
+intrigue
+intrigued
+intriguer
+intrigues
+intriguing
+intriguingly
+intrinsic
+intrinsically
+intrinsics
+introduce
+introduced
+introducer
+introduces
+introducing
+introduction
+introduction's
+introductions
+introductory
+introspect
+introspection
+introspections
+introspective
+introspectively
+introspectiveness
+introvert
+introverted
+intrude
+intruded
+intruder
+intruder's
+intruders
+intrudes
+intruding
+intrusion
+intrusion's
+intrusions
+intrusive
+intrusively
+intrusiveness
+intrust
+intubate
+intubated
+intubates
+intubating
+intubation
+intuition
+intuition's
+intuitionist
+intuitions
+intuitive
+intuitively
+intuitiveness
+invade
+invaded
+invader
+invaders
+invades
+invading
+invalid
+invalidate
+invalidated
+invalidates
+invalidating
+invalidation
+invalidations
+invalidities
+invalidity
+invalidly
+invalidness
+invalids
+invaluable
+invaluableness
+invaluably
+invariability
+invariable
+invariableness
+invariably
+invariance
+invariant
+invariantly
+invariants
+invasion
+invasion's
+invasions
+invent
+invented
+inventing
+invention
+invention's
+inventions
+inventive
+inventively
+inventiveness
+inventor
+inventor's
+inventories
+inventors
+inventory
+inventory's
+invents
+inveracity
+inverse
+inversely
+inverses
+inversion
+inversions
+inversive
+invert
+invertebrate
+invertebrate's
+invertebrates
+inverted
+inverter
+inverters
+invertible
+inverting
+inverts
+invest
+invested
+investigate
+investigated
+investigates
+investigating
+investigation
+investigations
+investigative
+investigator
+investigator's
+investigators
+investing
+investment
+investment's
+investments
+investor
+investor's
+investors
+invests
+inviability
+inviable
+invincible
+invincibleness
+invisibility
+invisible
+invisibleness
+invisibly
+invitation
+invitation's
+invitations
+invite
+invited
+inviter
+invites
+inviting
+invitingly
+invocation
+invocation's
+invocations
+invoice
+invoiced
+invoices
+invoicing
+invokable
+invoke
+invoked
+invoker
+invokers
+invokes
+invoking
+involuntarily
+involuntariness
+involuntary
+involve
+involved
+involvedly
+involvement
+involvement's
+involvements
+involver
+involves
+involving
+invulnerable
+invulnerableness
+inward
+inwardly
+inwardness
+inwards
+inwrought
+ioctl
+iodine
+ion
+ions
+irate
+irately
+irateness
+ire
+ire's
+ires
+iris
+irises
+irk
+irked
+irking
+irks
+irksome
+irksomely
+irksomeness
+iron
+ironed
+ironer
+ironical
+ironically
+ironicalness
+ironies
+ironing
+ironings
+ironness
+irons
+ironwork
+ironwork's
+ironworker
+ironworks
+irony
+irrational
+irrationality
+irrationally
+irrationalness
+irrationals
+irrecoverable
+irrecoverableness
+irreducible
+irreducibly
+irreflexive
+irrefutable
+irregular
+irregularities
+irregularity
+irregularly
+irregulars
+irrelevance
+irrelevances
+irrelevant
+irrelevantly
+irrepressible
+irresistible
+irresistibleness
+irrespective
+irrespectively
+irresponsible
+irresponsibleness
+irresponsibly
+irreversible
+irrigate
+irrigated
+irrigates
+irrigating
+irrigation
+irrigations
+irritate
+irritated
+irritates
+irritating
+irritatingly
+irritation
+irritations
+irritative
+is
+island
+islander
+islanders
+islands
+isle
+isle's
+isles
+islet
+islet's
+islets
+isling
+isn't
+isolate
+isolated
+isolates
+isolating
+isolation
+isolations
+isometric
+isometrics
+isomorphic
+isomorphically
+isomorphism
+isomorphism's
+isomorphisms
+isotope
+isotope's
+isotopes
+ispell
+ispell's
+issuance
+issue
+issued
+issuer
+issuers
+issues
+issuing
+isthmus
+it
+it'd
+it'll
+it's
+italic
+italics
+itch
+itches
+itching
+item
+item's
+items
+iterate
+iterated
+iterates
+iterating
+iteration
+iterations
+iterative
+iteratively
+iterator
+iterator's
+iterators
+itineraries
+itinerary
+its
+itself
+iv
+ivied
+ivies
+ivories
+ivory
+ivy
+ivy's
+ix
+jab
+jab's
+jabbed
+jabbing
+jabs
+jack
+jacked
+jacker
+jacket
+jacketed
+jackets
+jacking
+jacks
+jade
+jaded
+jadedly
+jadedness
+jades
+jading
+jail
+jailed
+jailer
+jailers
+jailing
+jails
+jam
+jammed
+jamming
+jams
+janitor
+janitor's
+janitors
+jar
+jar's
+jargon
+jarred
+jarring
+jarringly
+jars
+jaunt
+jaunt's
+jaunted
+jauntier
+jauntiness
+jaunting
+jaunts
+jaunty
+javelin
+javelin's
+javelins
+jaw
+jaw's
+jawed
+jaws
+jay
+jazz
+jealous
+jealousies
+jealously
+jealousness
+jealousy
+jean
+jean's
+jeans
+jeep
+jeep's
+jeeped
+jeepers
+jeeping
+jeeps
+jeer
+jeer's
+jeerer
+jeers
+jellied
+jellies
+jelly
+jelly's
+jellyfish
+jellying
+jenny
+jerk
+jerked
+jerker
+jerkier
+jerkiness
+jerking
+jerkings
+jerks
+jerky
+jersey
+jersey's
+jerseys
+jest
+jested
+jester
+jesting
+jests
+jet
+jet's
+jets
+jetted
+jetting
+jewel
+jewelries
+jewelry
+jewels
+jig
+jig's
+jigs
+jingle
+jingled
+jingler
+jingles
+jingling
+job
+job's
+jobs
+jocks
+jocund
+jocundly
+jog
+jogs
+john
+john's
+johns
+join
+joined
+joiner
+joiners
+joining
+joins
+joint
+joint's
+jointed
+jointedly
+jointedness
+jointer
+jointing
+jointly
+jointness
+joints
+joke
+joked
+joker
+jokers
+jokes
+joking
+jokingly
+jollied
+jollier
+jollies
+jolly
+jollying
+jolt
+jolted
+jolter
+jolting
+jolts
+jostle
+jostled
+jostles
+jostling
+jot
+jots
+jotted
+jotting
+journal
+journal's
+journalism
+journalist
+journalist's
+journalistic
+journalists
+journals
+journey
+journeyed
+journeying
+journeyings
+journeys
+joust
+jousted
+jouster
+jousting
+jousts
+joy
+joy's
+joyful
+joyfully
+joyfulness
+joyous
+joyously
+joyousness
+joys
+jubilee
+judge
+judged
+judger
+judges
+judging
+judicable
+judicial
+judicially
+judiciaries
+judiciary
+judicious
+judiciously
+judiciousness
+jug
+jug's
+juggle
+juggled
+juggler
+jugglers
+juggles
+juggling
+jugs
+juice
+juice's
+juiced
+juicer
+juicers
+juices
+juicier
+juiciest
+juiciness
+juicing
+juicy
+jumble
+jumbled
+jumbles
+jumbling
+jump
+jumped
+jumper
+jumpers
+jumpier
+jumpiness
+jumping
+jumps
+jumpy
+junction
+junction's
+junctions
+juncture
+juncture's
+junctures
+jungle
+jungle's
+jungled
+jungles
+junior
+junior's
+juniors
+juniper
+junk
+junker
+junkers
+junkie
+junkies
+junks
+junky
+juries
+jurisdiction
+jurisdiction's
+jurisdictions
+juror
+juror's
+jurors
+jury
+jury's
+just
+juster
+justice
+justice's
+justices
+justifiable
+justifiably
+justification
+justifications
+justified
+justifier
+justifier's
+justifiers
+justifies
+justify
+justifying
+justing
+justly
+justness
+jut
+juvenile
+juvenile's
+juveniles
+juxtapose
+juxtaposed
+juxtaposes
+juxtaposing
+kHz
+keel
+keeled
+keeler
+keeling
+keels
+keen
+keener
+keenest
+keening
+keenly
+keenness
+keep
+keeper
+keepers
+keeping
+keeps
+ken
+kennel
+kennel's
+kennels
+kept
+kerchief
+kerchief's
+kerchiefed
+kerchiefs
+kernel
+kernel's
+kernels
+kerosene
+ketchup
+kettle
+kettle's
+kettles
+key
+keyboard
+keyboard's
+keyboarder
+keyboarding
+keyboards
+keyclick
+keyclick's
+keyclicks
+keyed
+keying
+keypad
+keypad's
+keypads
+keys
+keystroke
+keystroke's
+keystrokes
+keyword
+keyword's
+keywords
+kick
+kicked
+kicker
+kickers
+kicking
+kicks
+kid
+kid's
+kidded
+kidding
+kiddingly
+kidnap
+kidnap's
+kidnaps
+kidney
+kidney's
+kidneys
+kids
+kill
+killed
+killer
+killers
+killing
+killingly
+killings
+kills
+kilobit
+kilobits
+kilobyte
+kilobytes
+kin
+kind
+kinder
+kindergarten
+kindest
+kindhearted
+kindheartedly
+kindheartedness
+kindle
+kindled
+kindler
+kindles
+kindlier
+kindliness
+kindling
+kindly
+kindness
+kindnesses
+kindred
+kinds
+king
+kingdom
+kingdom's
+kingdoms
+kinglier
+kingliness
+kingly
+kings
+kinkier
+kinkiness
+kinky
+kinship
+kinsman
+kiss
+kissed
+kisser
+kissers
+kisses
+kissing
+kissings
+kit
+kit's
+kitchen
+kitchen's
+kitchener
+kitchens
+kite
+kited
+kiter
+kites
+kiting
+kits
+kitsch
+kitten
+kitten's
+kittened
+kittening
+kittens
+kitties
+kitty
+kludge
+kludge's
+kludged
+kludger
+kludger's
+kludgers
+kludges
+kludgey
+kludging
+klutz
+klutz's
+klutzes
+klutziness
+klutzy
+knack
+knacker
+knacks
+knapsack
+knapsack's
+knapsacks
+knave
+knave's
+knaves
+knead
+kneaded
+kneader
+kneading
+kneads
+knee
+kneed
+kneeing
+kneel
+kneeled
+kneeler
+kneeling
+kneels
+knees
+knell
+knell's
+knells
+knelt
+knew
+knife
+knifed
+knifes
+knifing
+knight
+knighted
+knighthood
+knighting
+knightliness
+knightly
+knights
+knit
+knits
+knives
+knob
+knob's
+knobs
+knock
+knocked
+knocker
+knockers
+knocking
+knocks
+knoll
+knoll's
+knolls
+knot
+knot's
+knots
+knotted
+knotting
+know
+knowable
+knower
+knowhow
+knowing
+knowingly
+knowledge
+knowledgeable
+knowledgeableness
+knowledges
+known
+knows
+knuckle
+knuckled
+knuckles
+knuckling
+kudos
+lab
+lab's
+label
+label's
+labels
+laboratories
+laboratory
+laboratory's
+labs
+labyrinth
+labyrinths
+lace
+laced
+lacer
+lacerate
+lacerated
+lacerates
+lacerating
+laceration
+lacerations
+lacerative
+laces
+lacing
+lack
+lackadaisical
+lackadaisically
+lacked
+lacker
+lacking
+lacks
+lacquer
+lacquered
+lacquerer
+lacquerers
+lacquering
+lacquers
+lad
+ladder
+ladders
+laded
+laden
+ladened
+ladening
+ladies
+lading
+lads
+lady
+lady's
+lag
+lager
+lagers
+lagged
+lagoon
+lagoon's
+lagoons
+lags
+laid
+lain
+lair
+lair's
+lairs
+lake
+lake's
+laker
+lakes
+laking
+lamb
+lamb's
+lambda
+lambda's
+lambdas
+lamber
+lambs
+lame
+lamed
+lamely
+lameness
+lament
+lamentable
+lamentableness
+lamentation
+lamentation's
+lamentations
+lamented
+lamenting
+laments
+lamer
+lames
+lamest
+laminar
+laming
+lamp
+lamp's
+lamper
+lamps
+lance
+lanced
+lancer
+lancers
+lances
+lancing
+land
+landed
+lander
+landers
+landing
+landings
+landladies
+landlady
+landlady's
+landlord
+landlord's
+landlords
+landmark
+landmark's
+landmarks
+landowner
+landowner's
+landowners
+lands
+landscape
+landscaped
+landscaper
+landscapes
+landscaping
+lane
+lane's
+lanes
+language
+language's
+languages
+languid
+languidly
+languidness
+languish
+languished
+languisher
+languishes
+languishing
+languishingly
+lantern
+lantern's
+lanterns
+lap
+lap's
+lapel
+lapel's
+lapels
+laps
+lapse
+lapsed
+lapser
+lapses
+lapsing
+lard
+larded
+larder
+larding
+lards
+large
+largely
+largeness
+larger
+largest
+lark
+lark's
+larker
+larks
+larva
+larvae
+larvas
+laser
+laser's
+lasers
+lash
+lashed
+lasher
+lashes
+lashing
+lashings
+lass
+lass's
+lasses
+last
+lasted
+laster
+lasting
+lastingly
+lastingness
+lastly
+lasts
+latch
+latched
+latches
+latching
+late
+lated
+lately
+latencies
+latency
+latency's
+lateness
+latent
+latently
+latents
+later
+lateral
+laterally
+latest
+latex
+latex's
+latexes
+lath
+lather
+lathered
+latherer
+lathering
+lathes
+lathing
+latitude
+latitude's
+latitudes
+latrine
+latrine's
+latrines
+latter
+latter's
+latterly
+lattice
+lattice's
+latticed
+lattices
+latticing
+laugh
+laughable
+laughableness
+laughably
+laughed
+laugher
+laughers
+laughing
+laughingly
+laughs
+laughter
+laughters
+launch
+launched
+launcher
+launchers
+launches
+launching
+launchings
+launder
+laundered
+launderer
+laundering
+launderings
+launders
+laundries
+laundry
+laurel
+laurel's
+laurels
+lava
+lavatories
+lavatory
+lavatory's
+lavender
+lavendered
+lavendering
+lavish
+lavished
+lavishing
+lavishly
+lavishness
+law
+law's
+lawful
+lawfully
+lawfulness
+lawless
+lawlessly
+lawlessness
+lawn
+lawn's
+lawns
+laws
+lawsuit
+lawsuit's
+lawsuits
+lawyer
+lawyer's
+lawyerly
+lawyers
+lay
+layer
+layered
+layering
+layers
+laying
+layman
+laymen
+layoffs
+layout
+layout's
+layouts
+lays
+lazed
+lazied
+lazier
+laziest
+lazily
+laziness
+lazing
+lazy
+lazying
+lead
+leaded
+leaden
+leadenly
+leadenness
+leader
+leader's
+leaders
+leadership
+leadership's
+leaderships
+leading
+leadings
+leads
+leaf
+leafed
+leafier
+leafiest
+leafing
+leafless
+leaflet
+leaflet's
+leaflets
+leafs
+leafy
+league
+leagued
+leaguer
+leaguers
+leagues
+leaguing
+leak
+leakage
+leakage's
+leakages
+leaked
+leaker
+leaking
+leaks
+lean
+leaned
+leaner
+leanest
+leaning
+leanings
+leanly
+leanness
+leans
+leap
+leaped
+leaper
+leaping
+leaps
+leapt
+learn
+learned
+learnedly
+learnedness
+learner
+learners
+learning
+learnings
+learns
+lease
+leased
+leases
+leash
+leash's
+leashes
+leasing
+least
+leather
+leathered
+leathering
+leathern
+leathers
+leave
+leaved
+leaven
+leavened
+leavening
+leaver
+leavers
+leaves
+leaving
+leavings
+lecture
+lectured
+lecturer
+lecturers
+lectures
+lecturing
+led
+ledge
+ledger
+ledgers
+ledges
+lee
+leech
+leech's
+leeches
+leer
+leered
+leering
+leers
+lees
+left
+leftist
+leftist's
+leftists
+leftmost
+leftover
+leftover's
+leftovers
+lefts
+leftward
+leftwards
+leg
+legacies
+legacy
+legacy's
+legal
+legalities
+legality
+legally
+legals
+legend
+legend's
+legendary
+legends
+legged
+leggings
+legibility
+legible
+legibly
+legion
+legion's
+legions
+legislate
+legislated
+legislates
+legislating
+legislation
+legislations
+legislative
+legislatively
+legislator
+legislator's
+legislators
+legislature
+legislature's
+legislatures
+legitimacy
+legitimate
+legitimated
+legitimately
+legitimates
+legitimating
+legitimation
+legs
+leisure
+leisured
+leisureliness
+leisurely
+lemma
+lemma's
+lemmas
+lemon
+lemon's
+lemonade
+lemons
+lend
+lender
+lenders
+lending
+lends
+length
+lengthen
+lengthened
+lengthener
+lengthening
+lengthens
+lengthier
+lengthiness
+lengthly
+lengths
+lengthwise
+lengthy
+leniency
+lenient
+leniently
+lens
+lens's
+lensed
+lenser
+lensers
+lenses
+lensing
+lensings
+lent
+lentil
+lentil's
+lentils
+leopard
+leopard's
+leopards
+leprosy
+less
+lessen
+lessened
+lessening
+lessens
+lesser
+lesses
+lessing
+lesson
+lesson's
+lessoned
+lessoning
+lessons
+lest
+lester
+let
+let's
+lets
+letter
+lettered
+letterer
+lettering
+letters
+letting
+lettuce
+levee
+levee's
+leveed
+levees
+level
+levelly
+levelness
+levels
+lever
+lever's
+leverage
+leveraged
+leverages
+leveraging
+levered
+levering
+levers
+levied
+levier
+levies
+levy
+levying
+lewd
+lewdly
+lewdness
+lexical
+lexically
+lexicographic
+lexicographical
+lexicographically
+lexicon
+lexicon's
+lexicons
+liabilities
+liability
+liability's
+liable
+liableness
+liaison
+liaison's
+liaisons
+liar
+liar's
+liars
+liberal
+liberally
+liberalness
+liberals
+liberate
+liberated
+liberates
+liberating
+liberation
+liberator
+liberator's
+liberators
+liberties
+liberty
+liberty's
+libido
+librarian
+librarian's
+librarians
+libraries
+library
+library's
+libretti
+license
+licensed
+licensee
+licensee's
+licensees
+licenser
+licenses
+licensing
+lichen
+lichen's
+lichened
+lichens
+lick
+licked
+licker
+licking
+licks
+lid
+lid's
+lids
+lie
+lied
+lieder
+liege
+lien
+lien's
+liens
+lier
+lies
+lieu
+lieutenant
+lieutenant's
+lieutenants
+life
+life's
+lifeless
+lifelessly
+lifelessness
+lifelike
+lifelikeness
+lifelong
+lifer
+lifers
+lifestyle
+lifestyles
+lifetime
+lifetime's
+lifetimes
+lift
+lifted
+lifter
+lifters
+lifting
+lifts
+light
+lighted
+lighten
+lightened
+lightener
+lightening
+lightens
+lighter
+lighter's
+lighters
+lightest
+lighthouse
+lighthouse's
+lighthouses
+lighting
+lightly
+lightness
+lightning
+lightning's
+lightninged
+lightnings
+lights
+lightweight
+lightweights
+like
+liked
+likelier
+likeliest
+likelihood
+likelihoods
+likeliness
+likely
+liken
+likened
+likeness
+likeness's
+likenesses
+likening
+likens
+liker
+likes
+likest
+likewise
+liking
+likings
+lilac
+lilac's
+lilacs
+lilied
+lilies
+lily
+lily's
+limb
+limbed
+limber
+limbered
+limbering
+limberly
+limberness
+limbers
+limbs
+lime
+lime's
+limed
+limes
+limestone
+liming
+limit
+limitability
+limitably
+limitation
+limitation's
+limitations
+limited
+limitedly
+limitedness
+limiteds
+limiter
+limiters
+limiting
+limits
+limp
+limped
+limper
+limping
+limply
+limpness
+limps
+linden
+line
+line's
+linear
+linearities
+linearity
+linearly
+lined
+linen
+linen's
+linens
+liner
+liners
+lines
+linger
+lingered
+lingerer
+lingering
+lingeringly
+lingers
+linguist
+linguist's
+linguistic
+linguistically
+linguistics
+linguists
+lining
+linings
+link
+linkage
+linkage's
+linkages
+linked
+linker
+linkers
+linking
+linkings
+links
+linoleum
+linseed
+lint
+linter
+lints
+lion
+lion's
+lioness
+lioness's
+lionesses
+lions
+lip
+lip's
+lips
+lipstick
+liquefied
+liquefier
+liquefiers
+liquefies
+liquefy
+liquefying
+liquid
+liquid's
+liquidation
+liquidation's
+liquidations
+liquidity
+liquidly
+liquidness
+liquids
+liquor
+liquor's
+liquored
+liquoring
+liquors
+lisp
+lisp's
+lisped
+lisper
+lisping
+lisps
+list
+listed
+listen
+listened
+listener
+listeners
+listening
+listens
+lister
+listers
+listing
+listing's
+listings
+lists
+lit
+literacy
+literal
+literally
+literalness
+literals
+literariness
+literary
+literate
+literately
+literateness
+literation
+literature
+literature's
+literatures
+lithe
+lithely
+litheness
+litigate
+litigated
+litigates
+litigating
+litigation
+litigator
+litter
+littered
+litterer
+littering
+litters
+little
+littleness
+littler
+littlest
+livable
+livableness
+livably
+live
+lived
+livelier
+liveliest
+livelihood
+liveliness
+lively
+liven
+livened
+liveness
+livening
+liver
+liveried
+livers
+livery
+lives
+livest
+liveth
+living
+livingly
+livingness
+livings
+lizard
+lizard's
+lizards
+load
+loaded
+loader
+loaders
+loading
+loadings
+loads
+loaf
+loafed
+loafer
+loafers
+loafing
+loafs
+loan
+loaned
+loaner
+loaning
+loans
+loath
+loathe
+loathed
+loather
+loathes
+loathing
+loathly
+loathness
+loathsome
+loathsomely
+loathsomeness
+loaves
+lobbied
+lobbies
+lobby
+lobbying
+lobe
+lobe's
+lobed
+lobes
+lobster
+lobster's
+lobsters
+local
+localities
+locality
+locality's
+locally
+locals
+locate
+located
+locater
+locates
+locating
+location
+locations
+locative
+locatives
+locator
+locator's
+locators
+loci
+lock
+locked
+locker
+lockers
+locking
+lockings
+lockout
+lockout's
+lockouts
+locks
+lockup
+lockup's
+lockups
+locomotion
+locomotive
+locomotive's
+locomotively
+locomotives
+locus
+locus's
+locust
+locust's
+locusts
+lodge
+lodged
+lodger
+lodger's
+lodgers
+lodges
+lodging
+lodgings
+loft
+loft's
+lofter
+loftier
+loftiness
+lofts
+lofty
+log
+log's
+logarithm
+logarithm's
+logarithmically
+logarithms
+logged
+logger
+logger's
+loggers
+logging
+logic
+logic's
+logical
+logically
+logicalness
+logicals
+logician
+logician's
+logicians
+logics
+login
+logins
+logistic
+logistics
+logout
+logs
+loin
+loin's
+loins
+loiter
+loitered
+loiterer
+loitering
+loiters
+lone
+lonelier
+loneliest
+loneliness
+lonely
+loneness
+loner
+loners
+lonesome
+lonesomely
+lonesomeness
+long
+longed
+longer
+longest
+longing
+longingly
+longings
+longitude
+longitude's
+longitudes
+longly
+longness
+longs
+longword
+longword's
+longwords
+look
+lookahead
+looked
+looker
+lookers
+looking
+lookout
+lookouts
+looks
+lookup
+lookup's
+lookups
+loom
+loomed
+looming
+looms
+loon
+loop
+looped
+looper
+loophole
+loophole's
+loopholed
+loopholes
+loopholing
+looping
+loops
+loose
+loosed
+loosely
+loosen
+loosened
+loosener
+looseness
+loosening
+loosens
+looser
+looses
+loosest
+loosing
+loot
+looted
+looter
+looting
+loots
+lord
+lord's
+lording
+lordlier
+lordliness
+lordly
+lords
+lordship
+lore
+lorries
+lorry
+lose
+loser
+losers
+loses
+losing
+losings
+loss
+loss's
+losses
+lossier
+lossiest
+lossy
+lost
+lostness
+lot
+lot's
+lots
+lotteries
+lottery
+lotus
+loud
+louden
+loudened
+loudening
+louder
+loudest
+loudly
+loudness
+loudspeaker
+loudspeaker's
+loudspeakers
+lounge
+lounged
+lounger
+loungers
+lounges
+lounging
+lousier
+lousiness
+lousy
+lovable
+lovableness
+lovably
+love
+love's
+loved
+lovelier
+lovelies
+loveliest
+loveliness
+lovely
+lover
+lover's
+lovering
+loverly
+lovers
+loves
+loving
+lovingly
+lovingness
+low
+lower
+lowered
+lowering
+lowers
+lowest
+lowing
+lowland
+lowlander
+lowlands
+lowlier
+lowliest
+lowliness
+lowly
+lowness
+lows
+loyal
+loyally
+loyalties
+loyalty
+loyalty's
+lubricant
+lubricant's
+lubricants
+lubrication
+luck
+lucked
+luckier
+luckiest
+luckily
+luckiness
+luckless
+lucks
+lucky
+ludicrous
+ludicrously
+ludicrousness
+luggage
+lukewarm
+lukewarmly
+lukewarmness
+lull
+lullaby
+lulled
+lulls
+lumber
+lumbered
+lumberer
+lumbering
+lumbers
+luminous
+luminously
+luminousness
+lump
+lumped
+lumpen
+lumper
+lumping
+lumps
+lunar
+lunatic
+lunatics
+lunch
+lunched
+luncheon
+luncheon's
+luncheons
+luncher
+lunches
+lunching
+lung
+lunged
+lunger
+lunging
+lungs
+lurch
+lurched
+lurcher
+lurches
+lurching
+lure
+lured
+lurer
+lures
+luring
+lurk
+lurked
+lurker
+lurkers
+lurking
+lurks
+luscious
+lusciously
+lusciousness
+lust
+lustier
+lustily
+lustiness
+lusting
+lustrous
+lustrously
+lustrousness
+lusts
+lusty
+lute
+lute's
+luted
+lutes
+luting
+luxuriant
+luxuriantly
+luxuries
+luxurious
+luxuriously
+luxuriousness
+luxury
+luxury's
+lying
+lyingly
+lyings
+lymph
+lynch
+lynched
+lyncher
+lynches
+lynx
+lynx's
+lynxes
+lyre
+lyre's
+lyres
+lyric
+lyrics
+ma'am
+macaroni
+macaroni's
+mace
+maced
+macer
+maces
+machine
+machine's
+machined
+machineries
+machinery
+machines
+machining
+macing
+macro
+macro's
+macroeconomics
+macromolecule
+macromolecule's
+macromolecules
+macros
+macroscopic
+mad
+madam
+madams
+madden
+maddened
+maddening
+maddeningly
+madder
+maddest
+made
+mademoiselle
+mademoiselles
+madly
+madman
+madness
+madras
+magazine
+magazine's
+magazined
+magazines
+magazining
+maggot
+maggot's
+maggots
+magic
+magical
+magically
+magician
+magician's
+magicians
+magistrate
+magistrate's
+magistrates
+magnesium
+magnesiums
+magnet
+magnet's
+magnetic
+magnetically
+magnetics
+magnetism
+magnetism's
+magnetisms
+magnets
+magnification
+magnifications
+magnificence
+magnificent
+magnificently
+magnified
+magnifier
+magnifiers
+magnifies
+magnify
+magnifying
+magnitude
+magnitude's
+magnitudes
+mahogany
+maid
+maid's
+maiden
+maidenliness
+maidenly
+maidens
+maids
+mail
+mailable
+mailbox
+mailbox's
+mailboxes
+mailed
+mailer
+mailer's
+mailers
+mailing
+mailings
+mails
+maim
+maimed
+maimedness
+maimer
+maimers
+maiming
+maims
+main
+mainframe
+mainframe's
+mainframes
+mainland
+mainlander
+mainlanders
+mainly
+mains
+mainstay
+maintain
+maintainability
+maintainable
+maintained
+maintainer
+maintainer's
+maintainers
+maintaining
+maintains
+maintenance
+maintenance's
+maintenances
+majestic
+majesties
+majesty
+majesty's
+major
+majored
+majoring
+majorities
+majority
+majority's
+majors
+makable
+make
+makefile
+makefiles
+maker
+makers
+makes
+makeshift
+makeshifts
+makeup
+makeups
+making
+makings
+maladies
+malady
+malady's
+malaria
+male
+male's
+malefactor
+malefactor's
+malefactors
+maleness
+males
+malfunction
+malfunctioned
+malfunctioning
+malfunctions
+malice
+malicious
+maliciously
+maliciousness
+malignant
+malignantly
+mall
+mall's
+mallet
+mallet's
+mallets
+malls
+malnutrition
+malt
+malted
+malting
+malts
+mama
+mamma
+mamma's
+mammal
+mammal's
+mammals
+mammas
+mammoth
+man
+man's
+manage
+manageable
+manageableness
+managed
+management
+management's
+managements
+manager
+manager's
+managerial
+managerially
+managers
+manages
+managing
+mandate
+mandated
+mandates
+mandating
+mandatories
+mandatory
+mandible
+mandolin
+mandolin's
+mandolins
+mane
+mane's
+maned
+manes
+manger
+manger's
+mangers
+mangle
+mangled
+mangler
+mangles
+mangling
+manhood
+maniac
+maniac's
+maniacs
+manicure
+manicured
+manicures
+manicuring
+manifest
+manifestation
+manifestation's
+manifestations
+manifested
+manifesting
+manifestly
+manifestness
+manifests
+manifold
+manifold's
+manifolder
+manifoldly
+manifoldness
+manifolds
+manipulability
+manipulable
+manipulatable
+manipulate
+manipulated
+manipulates
+manipulating
+manipulation
+manipulations
+manipulative
+manipulativeness
+manipulator
+manipulator's
+manipulators
+manipulatory
+mankind
+manlier
+manliest
+manliness
+manly
+manned
+manner
+mannered
+mannerliness
+mannerly
+manners
+manning
+manometer
+manometer's
+manometers
+manor
+manor's
+manors
+manpower
+mans
+mansion
+mansion's
+mansions
+mantel
+mantel's
+mantels
+mantissa
+mantissa's
+mantissas
+mantle
+mantle's
+mantled
+mantles
+mantling
+manual
+manual's
+manually
+manuals
+manufacture
+manufactured
+manufacturer
+manufacturer's
+manufacturers
+manufactures
+manufacturing
+manure
+manured
+manurer
+manurers
+manures
+manuring
+manuscript
+manuscript's
+manuscripts
+many
+map
+map's
+maple
+maple's
+maples
+mappable
+mapped
+mapping
+mapping's
+mappings
+maps
+mar
+marble
+marbled
+marbler
+marbles
+marbling
+march
+marched
+marcher
+marches
+marching
+mare
+mare's
+mares
+margin
+margin's
+marginal
+marginally
+marginals
+margined
+margining
+margins
+marigold
+marigold's
+marigolds
+marijuana
+marijuana's
+marinate
+marinated
+marinates
+marinating
+marine
+mariner
+marines
+maritime
+maritimer
+mark
+markable
+marked
+markedly
+marker
+markers
+market
+marketability
+marketable
+marketed
+marketer
+marketing
+marketings
+marketplace
+marketplace's
+marketplaces
+markets
+marking
+markings
+marks
+marquis
+marquises
+marriage
+marriage's
+marriages
+married
+marries
+marrow
+marrows
+marry
+marrying
+mars
+marsh
+marsh's
+marshal
+marshaled
+marshaler
+marshalers
+marshaling
+marshals
+marshes
+mart
+marten
+martens
+martial
+martially
+marts
+martyr
+martyr's
+martyrdom
+martyrs
+marvel
+marvels
+masculine
+masculinely
+masculineness
+masculinity
+mash
+mashed
+masher
+mashers
+mashes
+mashing
+mashings
+mask
+masked
+masker
+masking
+maskings
+masks
+masochist
+masochist's
+masochists
+mason
+mason's
+masoned
+masoning
+masonry
+masons
+masquerade
+masquerader
+masquerades
+masquerading
+mass
+massacre
+massacred
+massacrer
+massacres
+massacring
+massage
+massaged
+massager
+massages
+massaging
+massed
+masses
+massing
+massinger
+massive
+massively
+massiveness
+mast
+masted
+master
+master's
+mastered
+masterful
+masterfully
+masterfulness
+mastering
+masterings
+masterliness
+masterly
+masterpiece
+masterpiece's
+masterpieces
+masters
+mastery
+masts
+masturbate
+masturbated
+masturbates
+masturbating
+masturbation
+mat
+mat's
+match
+matchable
+matched
+matcher
+matchers
+matches
+matching
+matchings
+matchless
+matchlessly
+matchmaker
+matchmaker's
+matchmakers
+matchmaking
+matchmaking's
+mate
+mate's
+mated
+mater
+material
+materialism
+materialism's
+materially
+materialness
+materials
+maternal
+maternally
+mates
+math
+mathematical
+mathematically
+mathematician
+mathematician's
+mathematicians
+mathematics
+mating
+matings
+matrices
+matriculation
+matrimony
+matrix
+matrixes
+matron
+matronly
+mats
+matted
+matter
+mattered
+mattering
+matters
+mattress
+mattress's
+mattresses
+maturation
+mature
+matured
+maturely
+matureness
+maturer
+matures
+maturing
+maturities
+maturity
+max
+maxim
+maxim's
+maximal
+maximally
+maxims
+maximum
+maximumly
+maximums
+may
+maybe
+mayer
+mayest
+mayhap
+mayhem
+maying
+mayonnaise
+mayor
+mayor's
+mayoral
+mayors
+mays
+maze
+maze's
+mazed
+mazedly
+mazedness
+mazednesses
+mazer
+mazes
+mazing
+me
+mead
+meadow
+meadow's
+meadows
+meads
+meager
+meagerly
+meagerness
+meal
+meal's
+meals
+mean
+meander
+meandered
+meandering
+meanderings
+meanders
+meaner
+meanest
+meaning
+meaning's
+meaningful
+meaningfully
+meaningfulness
+meaningless
+meaninglessly
+meaninglessness
+meanings
+meanly
+meanness
+means
+meant
+meantime
+meanwhile
+measles
+measurable
+measurably
+measure
+measured
+measuredly
+measurement
+measurement's
+measurements
+measurer
+measures
+measuring
+meat
+meat's
+meats
+mechanic
+mechanic's
+mechanical
+mechanically
+mechanicals
+mechanics
+mechanism
+mechanism's
+mechanisms
+med
+medal
+medal's
+medallion
+medallion's
+medallions
+medals
+meddle
+meddled
+meddler
+meddles
+meddling
+media
+median
+median's
+medianly
+medians
+medias
+mediate
+mediated
+mediately
+mediateness
+mediates
+mediating
+mediation
+mediations
+mediative
+medic
+medic's
+medical
+medically
+medicinal
+medicinally
+medicine
+medicine's
+medicines
+medics
+medieval
+medieval's
+medievally
+medievals
+meditate
+meditated
+meditates
+meditating
+meditation
+meditations
+meditative
+meditatively
+meditativeness
+medium
+medium's
+mediums
+meek
+meeker
+meekest
+meekly
+meekness
+meet
+meeter
+meeting
+meetings
+meetly
+meets
+megabit
+megabits
+megabyte
+megabytes
+megaword
+megawords
+melancholy
+meld
+melding
+melds
+mellow
+mellowed
+mellowing
+mellowly
+mellowness
+mellows
+melodies
+melodious
+melodiously
+melodiousness
+melodrama
+melodrama's
+melodramas
+melody
+melody's
+melon
+melon's
+melons
+melt
+melted
+melter
+melting
+meltingly
+melts
+member
+member's
+membered
+members
+membership
+membership's
+memberships
+membrane
+membrane's
+membraned
+membranes
+memo
+memo's
+memoir
+memoirs
+memorability
+memorable
+memorableness
+memoranda
+memorandum
+memorandums
+memorial
+memorially
+memorials
+memories
+memory
+memory's
+memoryless
+memos
+men
+men's
+menace
+menaced
+menaces
+menacing
+menacingly
+menagerie
+menageries
+mend
+mended
+mender
+mending
+mends
+menial
+menially
+menials
+mens
+mensed
+menses
+mensing
+mental
+mentalities
+mentality
+mentally
+mention
+mentionable
+mentioned
+mentioner
+mentioners
+mentioning
+mentions
+mentor
+mentor's
+mentors
+menu
+menu's
+menus
+mer
+mercenaries
+mercenariness
+mercenary
+mercenary's
+merchandise
+merchandised
+merchandiser
+merchandises
+merchandising
+merchant
+merchant's
+merchants
+mercies
+merciful
+mercifully
+mercifulness
+merciless
+mercilessly
+mercilessness
+mercuries
+mercury
+mercy
+mere
+merely
+merest
+merge
+merged
+merger
+mergers
+merges
+merging
+meridian
+meridians
+merit
+merited
+meriting
+meritorious
+meritoriously
+meritoriousness
+merits
+merrier
+merriest
+merrily
+merriment
+merriments
+merriness
+merry
+mesh
+meshed
+meshes
+meshing
+mess
+message
+message's
+messaged
+messages
+messaging
+messed
+messenger
+messenger's
+messengers
+messes
+messiah
+messiahs
+messier
+messiest
+messieurs
+messily
+messiness
+messing
+messy
+met
+meta
+metacircular
+metacircularity
+metal
+metal's
+metalanguage
+metalanguages
+metallic
+metallurgy
+metals
+metamathematical
+metamorphosis
+metaphor
+metaphor's
+metaphorical
+metaphorically
+metaphors
+metaphysical
+metaphysically
+metaphysics
+metavariable
+mete
+meted
+meteor
+meteor's
+meteoric
+meteorology
+meteors
+meter
+meter's
+metered
+metering
+meters
+metes
+method
+method's
+methodical
+methodically
+methodicalness
+methodist
+methodist's
+methodists
+methodological
+methodologically
+methodologies
+methodologists
+methodology
+methodology's
+methods
+meting
+metric
+metric's
+metrical
+metrically
+metrics
+metropolis
+metropolitan
+mets
+mew
+mewed
+mews
+mica
+mice
+microbicidal
+microbicide
+microcode
+microcoded
+microcodes
+microcoding
+microcomputer
+microcomputer's
+microcomputers
+microeconomics
+microfilm
+microfilm's
+microfilmed
+microfilmer
+microfilms
+microinstruction
+microinstruction's
+microinstructions
+microphone
+microphones
+microphoning
+microprocessing
+microprocessor
+microprocessor's
+microprocessors
+microprogram
+microprogram's
+microprogrammed
+microprogramming
+microprograms
+microscope
+microscope's
+microscopes
+microscopic
+microsecond
+microsecond's
+microseconds
+microstore
+microwave
+microwave's
+microwaves
+microword
+microwords
+mid
+midday
+middle
+middled
+middler
+middles
+middling
+middlingly
+middlings
+midnight
+midnightly
+midnights
+midpoint
+midpoint's
+midpoints
+midst
+midsts
+midsummer
+midway
+midways
+midwinter
+midwinterly
+mien
+miens
+mies
+miff
+miffed
+miffing
+miffs
+might
+mightier
+mightiest
+mightily
+mightiness
+mights
+mighty
+migrate
+migrated
+migrates
+migrating
+migration
+migrations
+migrative
+mild
+milden
+milder
+mildest
+mildew
+mildews
+mildly
+mildness
+mile
+mile's
+mileage
+mileages
+miler
+miles
+milestone
+milestone's
+milestones
+militant
+militantly
+militantness
+militants
+militaries
+militarily
+militarism
+militarisms
+military
+militia
+militias
+milk
+milked
+milker
+milkers
+milkier
+milkiness
+milking
+milkmaid
+milkmaid's
+milkmaids
+milks
+milky
+mill
+milled
+miller
+millers
+millet
+milling
+million
+millionaire
+millionaire's
+millionaires
+millioned
+millions
+millionth
+millipede
+millipede's
+millipedes
+millisecond
+milliseconds
+mills
+millstone
+millstone's
+millstones
+mimic
+mimicked
+mimicking
+mimics
+mince
+minced
+mincer
+mincers
+minces
+mincing
+mincingly
+mind
+minded
+mindedness
+minder
+minders
+mindful
+mindfully
+mindfulness
+minding
+mindless
+mindlessly
+mindlessness
+minds
+mine
+mined
+miner
+mineral
+mineral's
+minerals
+miners
+mines
+ming
+mingle
+mingled
+mingles
+mingling
+miniature
+miniature's
+miniatured
+miniatures
+miniaturing
+minicomputer
+minicomputer's
+minicomputers
+minimal
+minimally
+minimum
+minimums
+mining
+minion
+minions
+minister
+minister's
+ministered
+ministering
+ministers
+ministries
+ministry
+ministry's
+mink
+mink's
+minks
+minnow
+minnow's
+minnows
+minor
+minor's
+minored
+minoring
+minorities
+minority
+minority's
+minors
+minstrel
+minstrel's
+minstrels
+mint
+minted
+minter
+minting
+mints
+minus
+minuses
+minute
+minuted
+minutely
+minuteness
+minuter
+minutes
+minutest
+minuting
+miracle
+miracle's
+miracles
+miraculous
+miraculously
+miraculousness
+mire
+mired
+mires
+miring
+mirror
+mirrored
+mirroring
+mirrors
+mirth
+misapplication
+misapplied
+misapplier
+misapplies
+misapply
+misapplying
+misbehaving
+miscalculation
+miscalculation's
+miscalculations
+miscellaneous
+miscellaneously
+miscellaneousness
+mischief
+mischievous
+mischievously
+mischievousness
+miscommunicate
+miscommunicated
+miscommunicates
+miscommunication
+misconception
+misconception's
+misconceptions
+misconstrue
+misconstrued
+misconstrues
+misconstruing
+misdirect
+misdirected
+misdirection
+misdirects
+miser
+miserable
+miserableness
+miserably
+miseries
+miserliness
+miserly
+misers
+misery
+misery's
+misfeature
+misfit
+misfit's
+misfits
+misfortune
+misfortune's
+misfortunes
+misgiving
+misgivingly
+misgivings
+misguide
+misguided
+misguidedly
+misguidedness
+misguider
+misguides
+misguiding
+mishap
+mishap's
+mishaps
+misinform
+misinformation
+misinformed
+misinforming
+misinforms
+misinterpret
+misinterpreted
+misinterpreter
+misinterpreters
+misinterpreting
+misinterprets
+mislead
+misleader
+misleading
+misleadingly
+misleadings
+misleads
+misled
+mismatch
+mismatched
+mismatches
+mismatching
+misnomer
+misnomered
+misperceive
+misperceived
+misperceives
+misplace
+misplaced
+misplaces
+misplacing
+misread
+misreader
+misreading
+misreads
+misrepresentation
+misrepresentation's
+misrepresentations
+miss
+missed
+misses
+missile
+missile's
+missiles
+missing
+mission
+missionaries
+missionary
+missionary's
+missioned
+missioner
+missioning
+missions
+missive
+missives
+misspell
+misspelled
+misspelling
+misspellings
+misspells
+misstate
+misstated
+misstater
+misstates
+misstating
+mist
+mistakable
+mistake
+mistaken
+mistakenly
+mistaker
+mistakes
+mistaking
+mistakingly
+misted
+mister
+mistered
+mistering
+misters
+mistier
+mistiest
+mistiness
+misting
+mistreat
+mistreated
+mistreating
+mistreats
+mistress
+mistressly
+mistrust
+mistrusted
+mistruster
+mistrusting
+mistrusts
+mists
+misty
+mistype
+mistyped
+mistypes
+mistyping
+misunderstand
+misunderstander
+misunderstanders
+misunderstanding
+misunderstanding's
+misunderstandings
+misunderstands
+misunderstood
+misuse
+misused
+misuser
+misuses
+misusing
+mite
+mites
+mitigate
+mitigated
+mitigates
+mitigating
+mitigation
+mitigations
+mitigative
+mitten
+mitten's
+mittens
+mix
+mixed
+mixer
+mixers
+mixes
+mixing
+mixture
+mixture's
+mixtures
+ml
+mnemonic
+mnemonic's
+mnemonically
+mnemonics
+moan
+moaned
+moaning
+moans
+moat
+moat's
+moats
+mob
+mob's
+mobility
+mobs
+moccasin
+moccasin's
+moccasins
+mock
+mocked
+mocker
+mockers
+mockery
+mocking
+mockingly
+mocks
+modal
+modalities
+modality
+modality's
+modally
+mode
+model
+model's
+models
+modem
+modems
+moderate
+moderated
+moderately
+moderateness
+moderates
+moderating
+moderation
+moderations
+moderator
+moderator's
+moderators
+modern
+modernity
+modernly
+modernness
+moderns
+modes
+modest
+modestly
+modesty
+modifiability
+modifiable
+modifiableness
+modification
+modifications
+modified
+modifier
+modifiers
+modifies
+modify
+modifying
+modular
+modularities
+modularity
+modularly
+modulate
+modulated
+modulates
+modulating
+modulation
+modulations
+modulator
+modulator's
+modulators
+module
+module's
+modules
+modulo
+modulus
+modus
+moist
+moisten
+moistened
+moistener
+moistening
+moistly
+moistness
+moisture
+moistures
+molasses
+mold
+molded
+molder
+moldered
+moldering
+molders
+moldier
+moldiness
+molding
+molds
+moldy
+mole
+molecular
+molecularly
+molecule
+molecule's
+molecules
+moles
+molest
+molested
+molester
+molesters
+molesting
+molests
+molten
+mom
+mom's
+moment
+moment's
+momentarily
+momentariness
+momentary
+momently
+momentous
+momentously
+momentousness
+moments
+momentum
+momentums
+moms
+monarch
+monarchies
+monarchs
+monarchy
+monarchy's
+monasteries
+monastery
+monastery's
+monastic
+monetary
+money
+money's
+moneyed
+moneyer
+moneys
+monitor
+monitored
+monitoring
+monitors
+monk
+monk's
+monkey
+monkeyed
+monkeying
+monkeys
+monks
+mono
+mono's
+monochrome
+monochromes
+monograph
+monograph's
+monographes
+monographs
+monolithic
+monopolies
+monopoly
+monopoly's
+monotheism
+monotone
+monotonic
+monotonically
+monotonicity
+monotonous
+monotonously
+monotonousness
+monotony
+monster
+monster's
+monsters
+monstrous
+monstrously
+monstrousness
+month
+month's
+monthlies
+monthly
+months
+monument
+monument's
+monumental
+monumentally
+monuments
+mood
+mood's
+moodier
+moodiness
+moods
+moody
+moon
+mooned
+mooning
+moonlight
+moonlighted
+moonlighter
+moonlighting
+moonlights
+moonlit
+moons
+moonshine
+moonshiner
+moor
+moor's
+moored
+mooring
+moorings
+moors
+moose
+moot
+mooted
+mop
+moped
+moper
+moping
+mops
+moral
+moral's
+morale
+morales
+moralities
+morality
+morally
+morals
+morass
+morasses
+morbid
+morbidly
+morbidness
+more
+mored
+moreover
+mores
+morion
+morn
+morning
+mornings
+morphological
+morphologically
+morphology
+morrow
+morsel
+morsel's
+morsels
+mortal
+mortality
+mortally
+mortals
+mortar
+mortared
+mortaring
+mortars
+mortgage
+mortgage's
+mortgaged
+mortgager
+mortgages
+mortgaging
+mortification
+mortifications
+mortified
+mortifiedly
+mortifier
+mortifies
+mortify
+mortifying
+mosaic
+mosaic's
+mosaics
+mosquito
+mosquitoes
+mosquitos
+moss
+moss's
+mosses
+mossier
+mossy
+most
+mostly
+motel
+motel's
+motels
+moth
+mother
+mother's
+motherboard
+motherboard's
+motherboards
+mothered
+motherer
+motherers
+mothering
+motherliness
+motherly
+mothers
+motif
+motif's
+motifs
+motion
+motioned
+motioner
+motioning
+motionless
+motionlessly
+motionlessness
+motions
+motivate
+motivated
+motivates
+motivating
+motivation
+motivational
+motivationally
+motivations
+motivative
+motive
+motived
+motives
+motiving
+motley
+motor
+motorcar
+motorcar's
+motorcars
+motorcycle
+motorcycle's
+motorcycles
+motored
+motoring
+motorist
+motorist's
+motorists
+motors
+motto
+mottoes
+mottos
+mould
+moulded
+moulder
+mouldering
+moulding
+moulds
+mound
+mounded
+mounds
+mount
+mountain
+mountain's
+mountaineer
+mountaineering
+mountaineers
+mountainous
+mountainously
+mountainousness
+mountains
+mounted
+mounter
+mounting
+mountings
+mounts
+mourn
+mourned
+mourner
+mourners
+mournful
+mournfully
+mournfulness
+mourning
+mourningly
+mourns
+mouse
+mouser
+mouses
+mousing
+mouth
+mouthed
+mouther
+mouthes
+mouthful
+mouthing
+mouths
+movable
+movableness
+move
+moved
+movement
+movement's
+movements
+mover
+movers
+moves
+movie
+movie's
+movies
+moving
+movingly
+movings
+mow
+mowed
+mower
+mowers
+mowing
+mows
+much
+muchness
+muck
+mucked
+mucker
+mucking
+mucks
+mud
+muddied
+muddier
+muddiness
+muddle
+muddled
+muddler
+muddlers
+muddles
+muddling
+muddy
+muddying
+muds
+muff
+muff's
+muffin
+muffin's
+muffins
+muffle
+muffled
+muffler
+mufflers
+muffles
+muffling
+muffs
+mug
+mug's
+mugs
+mulberries
+mulberry
+mulberry's
+mule
+mule's
+mules
+muling
+multicellular
+multicomponent
+multidimensional
+multilevel
+multinational
+multiple
+multiple's
+multiples
+multiplex
+multiplexed
+multiplexer
+multiplexers
+multiplexes
+multiplexing
+multiplexor
+multiplexor's
+multiplexors
+multiplicand
+multiplicand's
+multiplicands
+multiplication
+multiplications
+multiplicative
+multiplicatively
+multiplicatives
+multiplicity
+multiplied
+multiplier
+multipliers
+multiplies
+multiply
+multiplying
+multiprocess
+multiprocessing
+multiprocessor
+multiprocessor's
+multiprocessors
+multiprogram
+multiprogrammed
+multiprogramming
+multiprogrammings
+multistage
+multitasking
+multitude
+multitude's
+multitudes
+multiuser
+multivariate
+mumble
+mumbled
+mumbler
+mumblers
+mumbles
+mumbling
+mumblings
+mummies
+mummy
+mummy's
+munch
+munched
+muncher
+munches
+munching
+mundane
+mundanely
+mundaneness
+municipal
+municipalities
+municipality
+municipality's
+municipally
+munition
+munitions
+mural
+murals
+murder
+murdered
+murderer
+murderers
+murdering
+murderous
+murderously
+murderousness
+murders
+murkier
+murkiness
+murky
+murmur
+murmured
+murmurer
+murmuring
+murmurs
+muscle
+muscled
+muscles
+muscling
+muscular
+muscularly
+muse
+mused
+muser
+muses
+museum
+museum's
+museums
+mushier
+mushiness
+mushroom
+mushroomed
+mushrooming
+mushrooms
+mushy
+music
+musical
+musically
+musicals
+musician
+musicianly
+musicians
+musics
+musing
+musingly
+musings
+musk
+musket
+musket's
+muskets
+muskrat
+muskrat's
+muskrats
+musks
+muslin
+mussel
+mussel's
+mussels
+must
+mustard
+mustards
+muster
+mustered
+mustering
+musters
+mustier
+mustiness
+musts
+musty
+mutability
+mutable
+mutableness
+mutate
+mutated
+mutates
+mutating
+mutation
+mutations
+mutative
+mutator
+mutators
+mute
+muted
+mutedly
+mutely
+muteness
+muter
+mutes
+mutest
+mutilate
+mutilated
+mutilates
+mutilating
+mutilation
+mutilations
+muting
+mutinies
+mutiny
+mutiny's
+mutter
+muttered
+mutterer
+mutterers
+muttering
+mutters
+mutton
+mutual
+mutually
+muzzle
+muzzle's
+muzzled
+muzzler
+muzzles
+muzzling
+my
+myriad
+myrtle
+myself
+mysteries
+mysterious
+mysteriously
+mysteriousness
+mystery
+mystery's
+mystic
+mystic's
+mystical
+mystically
+mysticism
+mysticisms
+mystics
+myth
+myth's
+mythes
+mythical
+mythically
+mythologies
+mythology
+mythology's
+nag
+nag's
+nags
+nail
+nailed
+nailer
+nailing
+nails
+naive
+naively
+naiveness
+naiver
+naivete
+naked
+nakedly
+nakedness
+name
+name's
+nameable
+named
+nameless
+namelessly
+namelessness
+namely
+namer
+namers
+names
+namesake
+namesake's
+namesakes
+naming
+nanosecond
+nanoseconds
+nap
+nap's
+napkin
+napkin's
+napkins
+naps
+narcissistic
+narcissus
+narcissuses
+narcotic
+narcotics
+narrative
+narrative's
+narratively
+narratives
+narrow
+narrowed
+narrower
+narrowest
+narrowing
+narrowingness
+narrowly
+narrowness
+narrows
+nasal
+nasally
+nastier
+nasties
+nastiest
+nastily
+nastiness
+nasty
+nation
+nation's
+national
+nationalist
+nationalist's
+nationalists
+nationalities
+nationality
+nationality's
+nationally
+nationals
+nations
+nationwide
+native
+natively
+nativeness
+natives
+nativity
+natural
+naturalism
+naturalist
+naturally
+naturalness
+naturals
+nature
+nature's
+natured
+natures
+naught
+naught's
+naughtier
+naughtiness
+naughts
+naughty
+naval
+navally
+navies
+navigable
+navigableness
+navigate
+navigated
+navigates
+navigating
+navigation
+navigations
+navigator
+navigator's
+navigators
+navy
+navy's
+nay
+near
+nearby
+neared
+nearer
+nearest
+nearing
+nearly
+nearness
+nears
+neat
+neaten
+neater
+neatest
+neatly
+neatness
+neats
+nebula
+necessaries
+necessarily
+necessary
+necessitate
+necessitated
+necessitates
+necessitating
+necessitation
+necessitations
+necessities
+necessity
+neck
+necked
+necker
+necking
+necklace
+necklace's
+necklaces
+necks
+necktie
+necktie's
+neckties
+need
+needed
+needer
+needful
+needfully
+needfulness
+needier
+neediness
+needing
+needle
+needled
+needler
+needlers
+needles
+needless
+needlessly
+needlessness
+needlework
+needleworker
+needling
+needly
+needn't
+needs
+needy
+negate
+negated
+negater
+negates
+negating
+negation
+negations
+negative
+negatived
+negatively
+negativeness
+negatives
+negativing
+negator
+negators
+neglect
+neglected
+neglecter
+neglecting
+neglects
+negligence
+negligible
+negotiable
+negotiate
+negotiated
+negotiates
+negotiating
+negotiation
+negotiations
+neigh
+neither
+neophyte
+neophytes
+nephew
+nephew's
+nephews
+nerve
+nerve's
+nerved
+nerves
+nerving
+nervous
+nervously
+nervousness
+nest
+nested
+nester
+nesting
+nestle
+nestled
+nestler
+nestles
+nestling
+nests
+net
+net's
+nether
+nets
+netted
+netting
+nettle
+nettled
+nettles
+nettling
+network
+network's
+networked
+networking
+networks
+neural
+neurally
+neurobiology
+neurobiology's
+neurological
+neurologically
+neurologists
+neuron
+neuron's
+neurons
+neutral
+neutralities
+neutrality
+neutrally
+neutralness
+neutrals
+neutrino
+neutrino's
+neutrinos
+never
+nevertheless
+new
+newborn
+newborns
+newcomer
+newcomer's
+newcomers
+newer
+newest
+newline
+newline's
+newlines
+newly
+newness
+news
+newsgroup
+newsgroup's
+newsgroups
+newsletter
+newsletter's
+newsletters
+newsman
+newsmen
+newspaper
+newspaper's
+newspapers
+newswire
+newt
+newts
+next
+nibble
+nibbled
+nibbler
+nibblers
+nibbles
+nibbling
+nice
+nicely
+niceness
+nicer
+nicest
+niceties
+nicety
+niche
+niches
+niching
+nick
+nicked
+nickel
+nickel's
+nickels
+nicker
+nickered
+nickering
+nicking
+nickname
+nicknamed
+nicknamer
+nicknames
+nicks
+nicotine
+niece
+niece's
+nieces
+niftier
+nifties
+nifty
+nigh
+night
+night's
+nighted
+nighters
+nightfall
+nightgown
+nightingale
+nightingale's
+nightingales
+nightly
+nightmare
+nightmare's
+nightmares
+nights
+nil
+nilly
+nimble
+nimbleness
+nimbler
+nimblest
+nimbly
+nine
+nines
+nineteen
+nineteens
+nineteenth
+nineties
+ninetieth
+ninety
+ninth
+nip
+nips
+nitrogen
+nix
+nixed
+nixer
+nixes
+nixing
+no
+nobilities
+nobility
+noble
+nobleman
+nobleness
+nobler
+nobles
+noblest
+nobly
+nobodies
+nobody
+nobody's
+nocturnal
+nocturnally
+nod
+nod's
+nodded
+nodding
+node
+node's
+nodes
+nods
+noise
+noised
+noiseless
+noiselessly
+noises
+noisier
+noisily
+noisiness
+noising
+noisy
+nomenclature
+nomenclatures
+nominal
+nominally
+nominate
+nominated
+nominates
+nominating
+nomination
+nomination's
+nominations
+nominative
+nominatively
+non
+nonblocking
+nonconservative
+noncyclic
+nondecreasing
+nondescript
+nondescriptly
+nondestructively
+nondeterminacy
+nondeterminate
+nondeterminately
+nondeterminism
+nondeterministic
+nondeterministically
+nondisclosure
+nondisclosures
+none
+nonempty
+nones
+nonetheless
+nonexistence
+nonexistent
+nonextensible
+nonfunctional
+noninteracting
+noninterference
+nonintuitive
+nonlinear
+nonlinearities
+nonlinearity
+nonlinearity's
+nonlinearly
+nonlocal
+nonnegative
+nonorthogonal
+nonorthogonality
+nonperishable
+nonprocedural
+nonprocedurally
+nonprogrammable
+nonprogrammer
+nonsense
+nonsensical
+nonsensically
+nonsensicalness
+nonspecialist
+nonspecialist's
+nonspecialists
+nonstandard
+nontechnical
+nontechnically
+nonterminal
+nonterminal's
+nonterminals
+nonterminating
+nontermination
+nontrivial
+nonuniform
+nonzero
+nook
+nook's
+nooks
+noon
+noonday
+nooning
+noons
+noontide
+nope
+nor
+norm
+norm's
+normal
+normalcy
+normality
+normally
+normals
+normed
+norms
+north
+north's
+northeast
+northeaster
+northeasterly
+northeastern
+norther
+northerly
+northern
+northerner
+northerners
+northernly
+northers
+northing
+northward
+northwards
+northwest
+northwester
+northwesterly
+northwestern
+nose
+nosed
+noses
+nosing
+nostril
+nostril's
+nostrils
+not
+notable
+notableness
+notables
+notably
+notation
+notation's
+notational
+notationally
+notations
+notch
+notched
+notches
+notching
+note
+notebook
+notebook's
+notebooks
+noted
+notedly
+notedness
+noter
+notes
+noteworthiness
+noteworthy
+nothing
+nothingness
+nothings
+notice
+noticeable
+noticeably
+noticed
+notices
+noticing
+notification
+notifications
+notified
+notifier
+notifiers
+notifies
+notify
+notifying
+noting
+notion
+notions
+notorious
+notoriously
+notoriousness
+notwithstanding
+noun
+noun's
+nouns
+nourish
+nourished
+nourisher
+nourishes
+nourishing
+nourishment
+novel
+novel's
+novelist
+novelist's
+novelists
+novels
+novelties
+novelty
+novelty's
+novice
+novice's
+novices
+now
+nowadays
+nowhere
+nowheres
+nows
+nroff
+nroff's
+nuances
+nuclear
+nucleotide
+nucleotide's
+nucleotides
+nucleus
+nucleuses
+nuisance
+nuisance's
+nuisances
+null
+nulled
+nullification
+nullified
+nullifier
+nullifiers
+nullifies
+nullify
+nullifying
+nulls
+numb
+numbed
+number
+numbered
+numberer
+numbering
+numberless
+numbers
+numbing
+numbingly
+numbly
+numbness
+numbs
+numeral
+numeral's
+numerally
+numerals
+numerator
+numerator's
+numerators
+numeric
+numerical
+numerically
+numerics
+numerous
+numerously
+numerousness
+nun
+nun's
+nuns
+nuptial
+nuptials
+nurse
+nurse's
+nursed
+nurser
+nurseries
+nursery
+nursery's
+nurses
+nursing
+nurture
+nurtured
+nurturer
+nurtures
+nurturing
+nut
+nut's
+nutrition
+nutrition's
+nuts
+nymph
+nymphs
+o'clock
+oak
+oaken
+oaks
+oar
+oar's
+oared
+oaring
+oars
+oasis
+oat
+oaten
+oater
+oath
+oaths
+oatmeal
+oats
+obedience
+obediences
+obedient
+obediently
+obey
+obeyed
+obeyer
+obeying
+obeys
+obfuscate
+obfuscated
+obfuscater
+obfuscates
+obfuscating
+obfuscation
+obfuscations
+object
+object's
+objected
+objecting
+objection
+objection's
+objectionable
+objectionableness
+objections
+objective
+objectively
+objectiveness
+objectives
+objector
+objector's
+objectors
+objects
+oblate
+oblately
+oblateness
+oblation
+oblations
+obligate
+obligated
+obligately
+obligates
+obligating
+obligation
+obligation's
+obligations
+obligatory
+oblige
+obliged
+obliger
+obliges
+obliging
+obligingly
+obligingness
+oblique
+obliquely
+obliqueness
+obliterate
+obliterated
+obliterates
+obliterating
+obliteration
+obliterations
+obliterative
+obliteratively
+oblivion
+oblivions
+oblivious
+obliviously
+obliviousness
+oblong
+oblongly
+oblongness
+obscene
+obscenely
+obscure
+obscured
+obscurely
+obscureness
+obscurer
+obscures
+obscuring
+obscurities
+obscurity
+observable
+observance
+observance's
+observances
+observant
+observantly
+observation
+observation's
+observations
+observatories
+observatory
+observe
+observed
+observer
+observers
+observes
+observing
+observingly
+obsession
+obsession's
+obsessions
+obsolescence
+obsolete
+obsoleted
+obsoletely
+obsoleteness
+obsoletes
+obsoleting
+obstacle
+obstacle's
+obstacles
+obstinacy
+obstinate
+obstinately
+obstinateness
+obstruct
+obstructed
+obstructer
+obstructing
+obstruction
+obstruction's
+obstructionist
+obstructions
+obstructive
+obstructively
+obstructiveness
+obstructs
+obtain
+obtainable
+obtainably
+obtained
+obtainer
+obtaining
+obtains
+obviate
+obviated
+obviates
+obviating
+obviation
+obviations
+obvious
+obviously
+obviousness
+occasion
+occasional
+occasionally
+occasioned
+occasioning
+occasionings
+occasions
+occlude
+occluded
+occludes
+occluding
+occlusion
+occlusion's
+occlusions
+occupancies
+occupancy
+occupant
+occupant's
+occupants
+occupation
+occupation's
+occupational
+occupationally
+occupations
+occupied
+occupier
+occupiers
+occupies
+occupy
+occupying
+occur
+occurred
+occurrence
+occurrence's
+occurrences
+occurring
+occurs
+ocean
+ocean's
+oceans
+octal
+octals
+octave
+octaves
+octopus
+odd
+odder
+oddest
+oddities
+oddity
+oddity's
+oddly
+oddness
+odds
+ode
+ode's
+oded
+oder
+odes
+odious
+odiously
+odiousness
+odorous
+odorously
+odorousness
+of
+off
+offend
+offended
+offender
+offenders
+offending
+offends
+offensive
+offensively
+offensiveness
+offensives
+offer
+offered
+offerer
+offerers
+offering
+offerings
+offers
+office
+office's
+officer
+officer's
+officered
+officers
+offices
+official
+official's
+officially
+officials
+officiate
+officiated
+officiates
+officiating
+officiation
+officiations
+officio
+officious
+officiously
+officiousness
+offing
+offs
+offset
+offset's
+offsets
+offspring
+offsprings
+oft
+often
+oftener
+oftentimes
+oh
+oil
+oilcloth
+oiled
+oiler
+oilers
+oilier
+oiliest
+oiliness
+oiling
+oils
+oily
+ointment
+ointments
+okay
+okay's
+okays
+old
+olden
+older
+oldest
+oldness
+olive
+olive's
+oliver
+olives
+omen
+omen's
+omens
+ominous
+ominously
+ominousness
+omission
+omission's
+omissions
+omit
+omits
+omitted
+omitting
+omnipresent
+omnipresently
+omniscient
+omnisciently
+omnivore
+on
+onanism
+once
+oncer
+one
+one's
+oneness
+oner
+onerous
+onerously
+onerousness
+ones
+oneself
+ongoing
+onion
+onions
+online
+onliness
+only
+ons
+onset
+onset's
+onsets
+onto
+onward
+onwards
+oops
+ooze
+oozed
+oozes
+oozing
+opacities
+opacity
+opal
+opal's
+opals
+opaque
+opaquely
+opaqueness
+opcode
+opcode's
+opcodes
+open
+opened
+opener
+openers
+openest
+opening
+opening's
+openings
+openly
+openness
+opens
+opera
+opera's
+operable
+operand
+operand's
+operandi
+operands
+operas
+operate
+operated
+operates
+operating
+operation
+operational
+operationally
+operations
+operative
+operatively
+operativeness
+operatives
+operator
+operator's
+operators
+opiate
+opiates
+opinion
+opinion's
+opinions
+opium
+opponent
+opponent's
+opponents
+opportune
+opportunely
+opportunism
+opportunistic
+opportunistically
+opportunities
+opportunity
+opportunity's
+oppose
+opposed
+opposer
+opposes
+opposing
+opposite
+oppositely
+oppositeness
+opposites
+opposition
+oppositions
+oppress
+oppressed
+oppresses
+oppressing
+oppression
+oppressive
+oppressively
+oppressiveness
+oppressor
+oppressor's
+oppressors
+opt
+opted
+optic
+optical
+optically
+optics
+optimal
+optimality
+optimally
+optimism
+optimistic
+optimistically
+optimum
+opting
+option
+option's
+optional
+optionally
+options
+opts
+or
+or's
+oracle
+oracle's
+oracles
+oral
+orally
+orals
+orange
+orange's
+oranges
+oration
+oration's
+orations
+orator
+orator's
+oratories
+orators
+oratory
+oratory's
+orb
+orbit
+orbital
+orbitally
+orbitals
+orbited
+orbiter
+orbiters
+orbiting
+orbits
+orchard
+orchard's
+orchards
+orchestra
+orchestra's
+orchestras
+orchid
+orchid's
+orchids
+ordain
+ordained
+ordainer
+ordaining
+ordains
+ordeal
+ordeals
+order
+ordered
+orderer
+ordering
+orderings
+orderlies
+orderliness
+orderly
+orders
+ordinal
+ordinance
+ordinance's
+ordinances
+ordinaries
+ordinarily
+ordinariness
+ordinary
+ordinate
+ordinated
+ordinates
+ordinating
+ordination
+ordinations
+ore
+ore's
+ores
+organ
+organ's
+organic
+organics
+organism
+organism's
+organisms
+organist
+organist's
+organists
+organs
+orgies
+orgy
+orgy's
+orient
+orientation
+orientation's
+orientations
+oriented
+orienting
+orients
+orifice
+orifice's
+orifices
+origin
+origin's
+original
+originality
+originally
+originals
+originate
+originated
+originates
+originating
+origination
+originations
+originative
+originatively
+originator
+originator's
+originators
+origins
+orion
+orly
+ornament
+ornamental
+ornamentally
+ornamentation
+ornamentations
+ornamented
+ornamenting
+ornaments
+orphan
+orphaned
+orphaning
+orphans
+orthodox
+orthodoxes
+orthodoxly
+orthogonal
+orthogonality
+orthogonally
+oscillate
+oscillated
+oscillates
+oscillating
+oscillation
+oscillation's
+oscillations
+oscillator
+oscillator's
+oscillators
+oscillatory
+oscilloscope
+oscilloscope's
+oscilloscopes
+ostrich
+ostrich's
+ostriches
+other
+other's
+otherness
+others
+otherwise
+otter
+otter's
+otters
+ought
+oughts
+ounce
+ounces
+our
+ours
+ourself
+ourselves
+out
+outbreak
+outbreak's
+outbreaks
+outburst
+outburst's
+outbursts
+outcast
+outcast's
+outcasts
+outcome
+outcome's
+outcomes
+outcries
+outcry
+outdoor
+outdoors
+outed
+outer
+outermost
+outfit
+outfit's
+outfits
+outgoing
+outgoingness
+outgoings
+outgrew
+outgrow
+outgrowing
+outgrown
+outgrows
+outgrowth
+outing
+outing's
+outings
+outlast
+outlasts
+outlaw
+outlawed
+outlawing
+outlaws
+outlay
+outlay's
+outlays
+outlet
+outlet's
+outlets
+outline
+outlined
+outlines
+outlining
+outlive
+outlived
+outlives
+outliving
+outlook
+outness
+outperform
+outperformed
+outperforming
+outperforms
+outpost
+outpost's
+outposts
+output
+output's
+outputs
+outputting
+outrage
+outraged
+outrageous
+outrageously
+outrageousness
+outrages
+outraging
+outright
+outrightly
+outrun
+outruns
+outs
+outset
+outside
+outsider
+outsider's
+outsiderness
+outsiders
+outskirts
+outstanding
+outstandingly
+outstretched
+outstrip
+outstripped
+outstripping
+outstrips
+outvote
+outvoted
+outvotes
+outvoting
+outward
+outwardly
+outwardness
+outwards
+outweigh
+outweighed
+outweighing
+outweighs
+outwit
+outwits
+outwitted
+outwitting
+oval
+oval's
+ovally
+ovalness
+ovals
+ovaries
+ovary
+ovary's
+oven
+oven's
+ovens
+over
+overall
+overall's
+overalls
+overblown
+overboard
+overcame
+overcast
+overcasting
+overcoat
+overcoat's
+overcoating
+overcoats
+overcome
+overcomer
+overcomes
+overcoming
+overcrowd
+overcrowded
+overcrowding
+overcrowds
+overdone
+overdose
+overdose's
+overdosed
+overdoses
+overdosing
+overdraft
+overdraft's
+overdrafts
+overdraw
+overdrawing
+overdrawn
+overdraws
+overdrew
+overdue
+overemphasis
+overestimate
+overestimated
+overestimates
+overestimating
+overestimation
+overestimations
+overflow
+overflowed
+overflowing
+overflows
+overhang
+overhanging
+overhangs
+overhaul
+overhauled
+overhauler
+overhauling
+overhaulings
+overhauls
+overhead
+overheads
+overhear
+overheard
+overhearer
+overhearing
+overhears
+overing
+overjoy
+overjoyed
+overkill
+overkill's
+overlaid
+overland
+overlap
+overlap's
+overlapped
+overlapping
+overlaps
+overlay
+overlaying
+overlays
+overload
+overloaded
+overloading
+overloads
+overlook
+overlooked
+overlooking
+overlooks
+overly
+overlying
+overnight
+overnighter
+overnighters
+overnights
+overpower
+overpowered
+overpowering
+overpoweringly
+overpowers
+overprint
+overprinted
+overprinting
+overprints
+overproduction
+overridden
+override
+overrider
+overrides
+overriding
+overrode
+overrule
+overruled
+overrules
+overruling
+overrun
+overruns
+overs
+overseas
+oversee
+overseeing
+overseer
+overseers
+oversees
+overshadow
+overshadowed
+overshadowing
+overshadows
+overshoot
+overshooting
+overshoots
+overshot
+oversight
+oversight's
+oversights
+oversimplification
+oversimplifications
+oversimplified
+oversimplifies
+oversimplify
+oversimplifying
+overstate
+overstated
+overstatement
+overstatement's
+overstatements
+overstates
+overstating
+overstocks
+overt
+overtake
+overtaken
+overtaker
+overtakers
+overtakes
+overtaking
+overthrew
+overthrow
+overthrowing
+overthrown
+overthrows
+overtime
+overtly
+overtness
+overtone
+overtone's
+overtones
+overtook
+overture
+overture's
+overtures
+overturn
+overturned
+overturning
+overturns
+overuse
+overview
+overview's
+overviews
+overweight
+overwhelm
+overwhelmed
+overwhelming
+overwhelmingly
+overwhelms
+overwork
+overworked
+overworking
+overworks
+overwrite
+overwrites
+overwriting
+overwritten
+overwrote
+overzealous
+overzealousness
+ovum
+owe
+owed
+owes
+owing
+owl
+owl's
+owler
+owls
+own
+owned
+owner
+owner's
+owners
+ownership
+ownerships
+owning
+owns
+ox
+oxen
+oxidation
+oxide
+oxide's
+oxides
+oxygen
+oxygens
+oyster
+oyster's
+oystering
+oysters
+pa
+pace
+pace's
+paced
+pacer
+pacers
+paces
+pacific
+pacification
+pacifications
+pacified
+pacifier
+pacifies
+pacify
+pacifying
+pacing
+pack
+package
+packaged
+packager
+packagers
+packages
+packaging
+packagings
+packed
+packer
+packers
+packet
+packet's
+packeted
+packeting
+packets
+packing
+packs
+pact
+pact's
+pacts
+pad
+pad's
+padded
+paddies
+padding
+paddings
+paddle
+paddled
+paddler
+paddles
+paddling
+paddy
+pads
+pagan
+pagan's
+pagans
+page
+page's
+pageant
+pageant's
+pageants
+paged
+pager
+pager's
+pagers
+pages
+paginate
+paginated
+paginates
+paginating
+pagination
+paginations
+paging
+paid
+pail
+pail's
+pails
+pain
+pained
+painful
+painfully
+painfulness
+paining
+painless
+painlessly
+painlessness
+pains
+painstaking
+painstakingly
+paint
+painted
+painter
+painterliness
+painterly
+painters
+painting
+paintings
+paints
+pair
+paired
+pairing
+pairings
+pairs
+pairwise
+pal
+pal's
+palace
+palace's
+palaces
+palate
+palate's
+palates
+pale
+paled
+palely
+paleness
+paler
+pales
+palest
+palfrey
+paling
+pall
+palliate
+palliation
+palliative
+palliatively
+palliatives
+pallid
+pallidly
+pallidness
+palling
+pally
+palm
+palmed
+palmer
+palming
+palms
+pals
+pamphlet
+pamphlet's
+pamphlets
+pan
+pan's
+panacea
+panacea's
+panaceas
+pancake
+pancake's
+pancaked
+pancakes
+pancaking
+pancreas
+panda
+panda's
+pandas
+pandemonium
+pander
+pandered
+panderer
+pandering
+panders
+pane
+pane's
+panel
+panelist
+panelist's
+panelists
+panels
+panes
+pang
+pang's
+pangs
+panic
+panic's
+panics
+panned
+panning
+pans
+pansies
+pansy
+pansy's
+pant
+panted
+panther
+panther's
+panthers
+panties
+panting
+pantries
+pantry
+pantry's
+pants
+panty
+papa
+papal
+papally
+paper
+paper's
+paperback
+paperback's
+paperbacks
+papered
+paperer
+paperers
+papering
+paperings
+papers
+paperwork
+paprika
+par
+parachute
+parachute's
+parachuted
+parachuter
+parachutes
+parachuting
+parade
+paraded
+parader
+parades
+paradigm
+paradigm's
+paradigms
+parading
+paradise
+paradox
+paradox's
+paradoxes
+paradoxical
+paradoxically
+paradoxicalness
+paraffin
+paraffins
+paragon
+paragon's
+paragons
+paragraph
+paragraphed
+paragrapher
+paragraphing
+paragraphs
+parallax
+parallax's
+parallel
+parallelism
+parallelogram
+parallelogram's
+parallelograms
+parallels
+paralysis
+parameter
+parameter's
+parameterless
+parameters
+parametric
+paramilitary
+paramount
+paranoia
+paranoid
+parapet
+parapet's
+parapeted
+parapets
+paraphrase
+paraphrased
+paraphraser
+paraphrases
+paraphrasing
+parasite
+parasite's
+parasites
+parasitic
+parasitics
+parcel
+parcels
+parch
+parched
+parchment
+pardon
+pardonable
+pardonableness
+pardonably
+pardoned
+pardoner
+pardoners
+pardoning
+pardons
+pare
+parent
+parent's
+parentage
+parental
+parentally
+parentheses
+parenthesis
+parenthetical
+parenthetically
+parenthood
+parenting
+parents
+parer
+pares
+paring
+parings
+parish
+parish's
+parishes
+parities
+parity
+park
+parked
+parker
+parkers
+parking
+parks
+parliament
+parliament's
+parliamentary
+parliaments
+parole
+paroled
+paroles
+paroling
+parried
+parrot
+parroting
+parrots
+parry
+parrying
+pars
+parse
+parsed
+parser
+parser's
+parsers
+parses
+parsimony
+parsing
+parsings
+parsley
+parson
+parson's
+parsons
+part
+partake
+partaker
+partakes
+partaking
+parted
+parter
+parters
+partial
+partiality
+partially
+partials
+participant
+participant's
+participants
+participate
+participated
+participates
+participating
+participation
+participations
+participative
+participatory
+particle
+particle's
+particles
+particular
+particularly
+particulars
+partied
+parties
+parting
+partings
+partisan
+partisan's
+partisans
+partition
+partitioned
+partitioner
+partitioning
+partitions
+partly
+partner
+partner's
+partnered
+partnering
+partners
+partnership
+partnerships
+partridge
+partridge's
+partridges
+parts
+party
+party's
+partying
+pas
+pass
+passage
+passage's
+passaged
+passages
+passageway
+passaging
+passe
+passed
+passenger
+passenger's
+passengerly
+passengers
+passer
+passers
+passes
+passing
+passion
+passionate
+passionately
+passionateness
+passions
+passive
+passively
+passiveness
+passives
+passivity
+passport
+passport's
+passports
+password
+password's
+passworded
+passwords
+past
+past's
+paste
+pasted
+pastes
+pastime
+pastime's
+pastimes
+pasting
+pastness
+pastor
+pastor's
+pastoral
+pastorally
+pastoralness
+pastors
+pastries
+pastry
+pasts
+pasture
+pasture's
+pastured
+pasturer
+pastures
+pasturing
+pat
+pat's
+patch
+patched
+patcher
+patches
+patching
+patchwork
+patchworker
+patchworkers
+pated
+paten
+patent
+patentable
+patented
+patenter
+patenters
+patenting
+patently
+patents
+pater
+paternal
+paternally
+path
+pathetic
+pathname
+pathname's
+pathnames
+pathological
+pathologically
+pathologies
+pathologist
+pathologist's
+pathologists
+pathology
+pathos
+paths
+pathway
+pathway's
+pathways
+patience
+patient
+patient's
+patiently
+patients
+patriarch
+patriarchs
+patrician
+patrician's
+patricians
+patriot
+patriot's
+patriotic
+patriotism
+patriots
+patrol
+patrol's
+patrols
+patron
+patron's
+patronage
+patronly
+patrons
+pats
+patter
+pattered
+patterer
+pattering
+patterings
+pattern
+patterned
+patterning
+patterns
+patters
+patties
+patty
+patty's
+paucity
+pause
+paused
+pauses
+pausing
+pave
+paved
+pavement
+pavement's
+pavements
+paver
+paves
+pavilion
+pavilion's
+pavilions
+paving
+paw
+pawed
+pawing
+pawn
+pawn's
+pawned
+pawner
+pawning
+pawns
+paws
+pay
+payable
+paycheck
+paycheck's
+paychecks
+payed
+payer
+payer's
+payers
+paying
+payment
+payment's
+payments
+payoff
+payoff's
+payoffs
+payroll
+payrolls
+pays
+pea
+pea's
+peace
+peaceable
+peaceableness
+peaceful
+peacefully
+peacefulness
+peaces
+peach
+peach's
+peaches
+peacock
+peacock's
+peacocks
+peak
+peaked
+peakedness
+peaking
+peaks
+peal
+pealed
+pealing
+peals
+peanut
+peanut's
+peanuts
+pear
+pearl
+pearl's
+pearler
+pearlier
+pearls
+pearly
+pears
+peas
+peasant
+peasant's
+peasantry
+peasants
+peat
+pebble
+pebble's
+pebbled
+pebbles
+pebbling
+peck
+pecked
+pecker
+pecking
+pecks
+peculiar
+peculiarities
+peculiarity
+peculiarity's
+peculiarly
+peculiars
+pedagogic
+pedagogical
+pedagogically
+pedagogics
+pedantic
+peddler
+peddler's
+peddlers
+pedestal
+pedestals
+pedestrian
+pedestrian's
+pedestrians
+pediatric
+pediatrics
+peek
+peeked
+peeking
+peeks
+peel
+peeled
+peeler
+peeler's
+peeling
+peels
+peep
+peeped
+peeper
+peepers
+peeping
+peeps
+peer
+peered
+peering
+peerless
+peerlessly
+peerlessness
+peers
+peeve
+peeve's
+peeved
+peevers
+peeves
+peeving
+peg
+peg's
+pegs
+pellet
+pellet's
+pelleted
+pelleting
+pellets
+pelt
+pelter
+pelting
+pelts
+pen
+penalties
+penalty
+penalty's
+penance
+penanced
+penances
+penancing
+pence
+pencil
+pencils
+pend
+pended
+pending
+pends
+pendulum
+pendulum's
+pendulums
+penetrate
+penetrated
+penetrates
+penetrating
+penetratingly
+penetration
+penetrations
+penetrative
+penetratively
+penetrativeness
+penetrator
+penetrator's
+penetrators
+penguin
+penguin's
+penguins
+peninsula
+peninsula's
+peninsulas
+penitent
+penitentiary
+penitently
+penned
+pennies
+penniless
+penning
+penny
+penny's
+pens
+pension
+pensioned
+pensioner
+pensioners
+pensioning
+pensions
+pensive
+pensively
+pensiveness
+pent
+pentagon
+pentagon's
+pentagons
+penthouse
+penthouse's
+penthouses
+people
+people's
+peopled
+peoples
+peopling
+pep
+pepper
+peppercorn
+peppercorn's
+peppercorns
+peppered
+pepperer
+peppering
+peppers
+per
+perceivable
+perceivably
+perceive
+perceived
+perceiver
+perceivers
+perceives
+perceiving
+percent
+percentage
+percentages
+percentile
+percentiles
+percents
+perceptible
+perceptibly
+perception
+perceptions
+perceptive
+perceptively
+perceptiveness
+perceptual
+perceptually
+perch
+perchance
+perched
+perches
+perching
+percolate
+percolated
+percolates
+percolating
+percolation
+percutaneous
+percutaneously
+peremptoriness
+peremptory
+perennial
+perennially
+perennials
+perfect
+perfected
+perfecter
+perfecting
+perfection
+perfectionist
+perfectionist's
+perfectionists
+perfections
+perfective
+perfectively
+perfectiveness
+perfectly
+perfectness
+perfects
+perforce
+perform
+performance
+performance's
+performances
+performed
+performer
+performers
+performing
+performs
+perfume
+perfumed
+perfumer
+perfumes
+perfuming
+perhaps
+peril
+peril's
+perilous
+perilously
+perilousness
+perils
+period
+period's
+periodic
+periodical
+periodically
+periodicals
+periods
+peripheral
+peripherally
+peripherals
+peripheries
+periphery
+periphery's
+perish
+perishable
+perishable's
+perishables
+perished
+perisher
+perishers
+perishes
+perishing
+perishingly
+permanence
+permanent
+permanently
+permanentness
+permanents
+permeate
+permeated
+permeates
+permeating
+permeation
+permeations
+permeative
+permissibility
+permissible
+permissibleness
+permissibly
+permission
+permissions
+permissive
+permissively
+permissiveness
+permit
+permit's
+permits
+permitted
+permitting
+permutation
+permutation's
+permutations
+permute
+permuted
+permutes
+permuting
+perpendicular
+perpendicularly
+perpendiculars
+perpetrate
+perpetrated
+perpetrates
+perpetrating
+perpetration
+perpetrations
+perpetrator
+perpetrator's
+perpetrators
+perpetual
+perpetually
+perpetuate
+perpetuated
+perpetuates
+perpetuating
+perpetuation
+perplex
+perplexed
+perplexedly
+perplexes
+perplexing
+perplexities
+perplexity
+persecute
+persecuted
+persecutes
+persecuting
+persecution
+persecutive
+persecutor
+persecutor's
+persecutors
+perseverance
+persevere
+persevered
+perseveres
+persevering
+persist
+persisted
+persistence
+persistent
+persistently
+persister
+persisting
+persists
+person
+person's
+personable
+personableness
+personage
+personage's
+personages
+personal
+personalities
+personality
+personality's
+personally
+personals
+personification
+personifications
+personified
+personifier
+personifies
+personify
+personifying
+personnel
+persons
+perspective
+perspective's
+perspectively
+perspectives
+perspicuous
+perspicuously
+perspicuousness
+perspiration
+perspirations
+persuadable
+persuade
+persuaded
+persuader
+persuaders
+persuades
+persuading
+persuasion
+persuasion's
+persuasions
+persuasive
+persuasively
+persuasiveness
+pertain
+pertained
+pertaining
+pertains
+pertinent
+pertinently
+perturb
+perturbation
+perturbation's
+perturbations
+perturbed
+perturbing
+perusal
+peruse
+perused
+peruser
+perusers
+peruses
+perusing
+pervade
+pervaded
+pervades
+pervading
+pervasive
+pervasively
+pervasiveness
+pervert
+perverted
+pervertedly
+pervertedness
+perverter
+perverting
+perverts
+pessimistic
+pest
+pester
+pestered
+pestering
+pesters
+pestilence
+pestilences
+pests
+pet
+petal
+petal's
+petals
+peter
+petered
+peters
+petition
+petitioned
+petitioner
+petitioning
+petitions
+petroleum
+pets
+petted
+petter
+petter's
+petters
+petticoat
+petticoat's
+petticoated
+petticoats
+pettier
+pettiest
+pettiness
+pettinesses
+petting
+petty
+pew
+pew's
+pews
+pewter
+pewterer
+phantom
+phantom's
+phantoms
+phase
+phased
+phaser
+phasers
+phases
+phasing
+pheasant
+pheasant's
+pheasants
+phenomena
+phenomenal
+phenomenally
+phenomenological
+phenomenologically
+phenomenologies
+phenomenology
+phenomenon
+philosopher
+philosopher's
+philosophers
+philosophic
+philosophical
+philosophically
+philosophies
+philosophy
+philosophy's
+phone
+phone's
+phoned
+phoneme
+phoneme's
+phonemes
+phonemic
+phonemics
+phones
+phonetic
+phonetics
+phoning
+phonograph
+phonographer
+phonographs
+phosphate
+phosphate's
+phosphates
+phosphoric
+photo
+photo's
+photocopied
+photocopier
+photocopies
+photocopy
+photocopying
+photograph
+photographed
+photographer
+photographers
+photographic
+photographing
+photographs
+photography
+photos
+phrase
+phrased
+phrases
+phrasing
+phrasings
+phyla
+phylum
+physic
+physical
+physically
+physicalness
+physicals
+physician
+physician's
+physicians
+physicist
+physicist's
+physicists
+physics
+physiological
+physiologically
+physiology
+physique
+physiqued
+pi
+piano
+piano's
+pianos
+piazza
+piazza's
+piazzas
+picayune
+pick
+picked
+picker
+pickering
+pickers
+picket
+picketed
+picketer
+picketers
+picketing
+pickets
+picking
+pickings
+pickle
+pickled
+pickles
+pickling
+picks
+pickup
+pickup's
+pickups
+picnic
+picnic's
+picnics
+pictorial
+pictorially
+pictorialness
+picture
+pictured
+pictures
+picturesque
+picturesquely
+picturesqueness
+picturing
+pie
+piece
+pieced
+piecemeal
+piecer
+pieces
+piecewise
+piecing
+pied
+pier
+pierce
+pierced
+pierces
+piercing
+piercingly
+piers
+pies
+pieties
+piety
+pig
+pig's
+pigeon
+pigeon's
+pigeons
+pigment
+pigmented
+pigments
+pigs
+pike
+pike's
+piked
+piker
+pikes
+piking
+pile
+piled
+pilers
+piles
+pilferage
+pilgrim
+pilgrim's
+pilgrimage
+pilgrimage's
+pilgrimages
+pilgrims
+piling
+pilings
+pill
+pill's
+pillage
+pillaged
+pillager
+pillages
+pillaging
+pillar
+pillared
+pillars
+pillow
+pillow's
+pillows
+pills
+pilot
+pilot's
+piloted
+piloting
+pilots
+pin
+pin's
+pinch
+pinched
+pincher
+pinches
+pinching
+pine
+pineapple
+pineapple's
+pineapples
+pined
+pines
+ping
+pinger
+pinging
+pining
+pinion
+pinioned
+pinions
+pink
+pinked
+pinker
+pinkest
+pinking
+pinkly
+pinkness
+pinks
+pinnacle
+pinnacle's
+pinnacled
+pinnacles
+pinnacling
+pinned
+pinning
+pinnings
+pinpoint
+pinpointed
+pinpointing
+pinpoints
+pins
+pint
+pint's
+pinter
+pints
+pioneer
+pioneered
+pioneering
+pioneers
+pious
+piously
+piousness
+pipe
+piped
+pipeline
+pipelined
+pipelines
+pipelining
+piper
+pipers
+pipes
+piping
+pipingly
+pipings
+pique
+piqued
+piquing
+pirate
+pirate's
+pirated
+pirates
+pirating
+piss
+pissed
+pisser
+pisses
+pissing
+pistil
+pistil's
+pistils
+pistol
+pistol's
+pistols
+piston
+piston's
+pistons
+pit
+pit's
+pitch
+pitched
+pitcher
+pitchers
+pitches
+pitching
+piteous
+piteously
+piteousness
+pitfall
+pitfall's
+pitfalls
+pith
+pithed
+pithes
+pithier
+pithiest
+pithiness
+pithing
+pithy
+pitiable
+pitiableness
+pitied
+pitier
+pitiers
+pities
+pitiful
+pitifully
+pitifulness
+pitiless
+pitilessly
+pitilessness
+pits
+pitted
+pity
+pitying
+pityingly
+pivot
+pivotal
+pivotally
+pivoted
+pivoting
+pivots
+pixel
+pixel's
+pixels
+placard
+placard's
+placards
+place
+placed
+placement
+placement's
+placements
+placer
+places
+placid
+placidly
+placidness
+placing
+plague
+plagued
+plaguer
+plagues
+plaguing
+plaid
+plaid's
+plaided
+plaids
+plain
+plainer
+plainest
+plainly
+plainness
+plains
+plaintiff
+plaintiff's
+plaintiffs
+plaintive
+plaintively
+plaintiveness
+plait
+plait's
+plaiter
+plaiting
+plaits
+plan
+plan's
+planar
+planarity
+plane
+plane's
+planed
+planer
+planers
+planes
+planet
+planet's
+planetary
+planets
+planing
+plank
+planking
+planks
+planned
+planner
+planner's
+planners
+planning
+plans
+plant
+plantation
+plantation's
+plantations
+planted
+planter
+planters
+planting
+plantings
+plants
+plasma
+plaster
+plastered
+plasterer
+plasterers
+plastering
+plasters
+plastic
+plasticity
+plasticly
+plastics
+plate
+plateau
+plateau's
+plateaus
+plated
+platelet
+platelet's
+platelets
+platen
+platen's
+platens
+plater
+platers
+plates
+platform
+platform's
+platforms
+plating
+platings
+platinum
+platter
+platter's
+platters
+plausibility
+plausible
+plausibleness
+play
+playable
+played
+player
+player's
+players
+playful
+playfully
+playfulness
+playground
+playground's
+playgrounds
+playing
+playmate
+playmate's
+playmates
+plays
+plaything
+plaything's
+playthings
+playwright
+playwright's
+playwrights
+plea
+plea's
+plead
+pleaded
+pleader
+pleading
+pleadingly
+pleadings
+pleads
+pleas
+pleasant
+pleasantly
+pleasantness
+please
+pleased
+pleasely
+pleaser
+pleases
+pleasing
+pleasingly
+pleasingness
+pleasurable
+pleasurableness
+pleasure
+pleasured
+pleasures
+pleasuring
+plebeian
+plebeianly
+plebiscite
+plebiscite's
+plebiscites
+pledge
+pledged
+pledger
+pledges
+pledging
+plenary
+plenteous
+plenteously
+plenteousness
+plenties
+plentiful
+plentifully
+plentifulness
+plenty
+pleurisy
+plication
+plied
+plier
+pliers
+plies
+plight
+plighter
+plod
+plods
+plot
+plot's
+plots
+plotted
+plotter
+plotter's
+plotters
+plotting
+ploy
+ploy's
+ploys
+pluck
+plucked
+plucker
+pluckier
+pluckiness
+plucking
+plucky
+plug
+plug's
+plugged
+plugging
+plugs
+plum
+plum's
+plumage
+plumaged
+plumages
+plumb
+plumb's
+plumbed
+plumber
+plumbers
+plumbing
+plumbs
+plume
+plumed
+plumes
+pluming
+plummeting
+plump
+plumped
+plumpen
+plumper
+plumply
+plumpness
+plums
+plunder
+plundered
+plunderer
+plunderers
+plundering
+plunders
+plunge
+plunged
+plunger
+plungers
+plunges
+plunging
+plural
+plurality
+plurally
+plurals
+plus
+pluses
+plush
+plushly
+plushness
+ply
+plying
+pneumonia
+poach
+poached
+poacher
+poachers
+poaches
+poaching
+pocket
+pocketbook
+pocketbook's
+pocketbooks
+pocketed
+pocketing
+pockets
+pod
+pod's
+pods
+poem
+poem's
+poems
+poet
+poet's
+poetic
+poetical
+poetically
+poeticalness
+poetics
+poetries
+poetry
+poetry's
+poets
+point
+pointed
+pointedly
+pointedness
+pointer
+pointers
+pointier
+pointiest
+pointing
+pointless
+pointlessly
+pointlessness
+points
+pointy
+poise
+poised
+poises
+poising
+poison
+poisoned
+poisoner
+poisoning
+poisonous
+poisonously
+poisonousness
+poisons
+poke
+poked
+poker
+pokes
+poking
+polar
+polarities
+polarity
+polarity's
+pole
+poled
+polemic
+polemics
+poler
+poles
+police
+police's
+policed
+policeman
+policeman's
+policemen
+policemen's
+polices
+policies
+policing
+policy
+policy's
+poling
+polish
+polished
+polisher
+polishers
+polishes
+polishing
+polite
+politely
+politeness
+politer
+politest
+politic
+political
+politically
+politician
+politician's
+politicians
+politics
+poll
+polled
+pollen
+poller
+polling
+polls
+pollute
+polluted
+polluter
+pollutes
+polluting
+pollution
+pollutive
+polo
+polygon
+polygon's
+polygons
+polymer
+polymer's
+polymers
+polynomial
+polynomial's
+polynomials
+polyphonic
+pomp
+pompous
+pompously
+pompousness
+pond
+ponder
+pondered
+ponderer
+pondering
+ponderous
+ponderously
+ponderousness
+ponders
+ponds
+ponies
+pony
+pony's
+poof
+pool
+pooled
+pooling
+pools
+poor
+poorer
+poorest
+poorly
+poorness
+pop
+pop's
+pope
+pope's
+popes
+poplar
+popped
+poppied
+poppies
+popping
+poppy
+poppy's
+pops
+populace
+popular
+popularity
+popularly
+populate
+populated
+populates
+populating
+population
+populations
+populous
+populously
+populousness
+porcelain
+porch
+porch's
+porches
+porcupine
+porcupine's
+porcupines
+pore
+pored
+pores
+poring
+pork
+porker
+porn
+pornographic
+porridge
+port
+portability
+portable
+portables
+portably
+portal
+portal's
+portals
+portamento
+portamento's
+ported
+portend
+portended
+portending
+portends
+porter
+portering
+porters
+porting
+portion
+portion's
+portioned
+portioning
+portions
+portlier
+portliness
+portly
+portrait
+portrait's
+portraits
+portray
+portrayed
+portrayer
+portraying
+portrays
+ports
+pose
+posed
+poser
+posers
+poses
+posing
+posit
+posited
+positing
+position
+positional
+positioned
+positioning
+positions
+positive
+positively
+positiveness
+positives
+posits
+possess
+possessed
+possessedly
+possessedness
+possesses
+possessing
+possession
+possession's
+possessional
+possessions
+possessive
+possessive's
+possessively
+possessiveness
+possessives
+possessor
+possessor's
+possessors
+possibilities
+possibility
+possibility's
+possible
+possibles
+possibly
+possum
+possum's
+possums
+post
+postage
+postal
+postcard
+postcard's
+postcards
+postcondition
+postconditions
+posted
+poster
+poster's
+posterior
+posteriorly
+posterity
+posters
+posting
+postings
+postman
+postmaster
+postmaster's
+postmasters
+postpone
+postponed
+postponer
+postpones
+postponing
+posts
+postscript
+postscript's
+postscripts
+postulate
+postulated
+postulates
+postulating
+postulation
+postulations
+posture
+posture's
+postured
+posturer
+postures
+posturing
+pot
+pot's
+potash
+potassium
+potato
+potatoes
+potent
+potentate
+potentate's
+potentates
+potential
+potentialities
+potentiality
+potentially
+potentials
+potentiating
+potentiometer
+potentiometer's
+potentiometers
+potently
+pots
+potted
+potter
+potter's
+potterer
+potteries
+potters
+pottery
+potting
+pouch
+pouch's
+pouched
+pouches
+poultry
+pounce
+pounced
+pounces
+pouncing
+pound
+pounded
+pounder
+pounders
+pounding
+pounds
+pour
+poured
+pourer
+pourers
+pouring
+pouringly
+pours
+pout
+pouted
+pouter
+pouting
+pouts
+poverty
+powder
+powdered
+powderer
+powdering
+powders
+power
+powered
+powerful
+powerfully
+powerfulness
+powering
+powerless
+powerlessly
+powerlessness
+powers
+pox
+poxes
+practicable
+practicableness
+practicably
+practical
+practicalities
+practicality
+practically
+practicalness
+practice
+practice's
+practices
+practitioner
+practitioner's
+practitioners
+pragmatic
+pragmatically
+pragmatics
+prairie
+prairies
+praise
+praised
+praiser
+praisers
+praises
+praising
+praisingly
+prance
+pranced
+prancer
+prances
+prancing
+prancingly
+prank
+prank's
+pranks
+prate
+prated
+prater
+prates
+prating
+pratingly
+pray
+prayed
+prayer
+prayer's
+prayers
+praying
+prays
+preach
+preached
+preacher
+preachers
+preaches
+preaching
+preachingly
+preallocate
+preallocated
+preallocates
+preallocating
+preallocation
+preallocation's
+preallocations
+preallocator
+preallocators
+preassign
+preassigned
+preassigning
+preassigns
+precarious
+precariously
+precariousness
+precaution
+precaution's
+precautioned
+precautioning
+precautions
+precede
+preceded
+precedence
+precedence's
+precedences
+precedent
+precedented
+precedents
+precedes
+preceding
+precept
+precept's
+preceptive
+preceptively
+precepts
+precinct
+precinct's
+precincts
+precious
+preciously
+preciousness
+precipice
+precipitate
+precipitated
+precipitately
+precipitateness
+precipitates
+precipitating
+precipitation
+precipitative
+precipitous
+precipitously
+precipitousness
+precise
+precisely
+preciseness
+precision
+precisions
+preclude
+precluded
+precludes
+precluding
+precocious
+precociously
+precociousness
+preconceive
+preconceived
+preconception
+preconception's
+preconceptions
+precondition
+preconditioned
+preconditions
+precursor
+precursor's
+precursors
+predate
+predated
+predates
+predating
+predation
+predecessor
+predecessor's
+predecessors
+predefine
+predefined
+predefines
+predefining
+predefinition
+predefinition's
+predefinitions
+predetermine
+predetermined
+predeterminer
+predetermines
+predetermining
+predicament
+predicate
+predicated
+predicates
+predicating
+predication
+predications
+predicative
+predict
+predictability
+predictable
+predictably
+predicted
+predicting
+prediction
+prediction's
+predictions
+predictive
+predictively
+predictor
+predictors
+predicts
+predominant
+predominantly
+predominate
+predominated
+predominately
+predominates
+predominating
+predomination
+preempt
+preempted
+preempting
+preemption
+preemptive
+preemptively
+preempts
+preface
+prefaced
+prefacer
+prefaces
+prefacing
+prefer
+preferable
+preferableness
+preferably
+preference
+preference's
+preferences
+preferential
+preferentially
+preferred
+preferring
+prefers
+prefix
+prefixed
+prefixes
+prefixing
+pregnant
+pregnantly
+prehistoric
+prejudge
+prejudged
+prejudger
+prejudice
+prejudiced
+prejudices
+prejudicing
+prelate
+preliminaries
+preliminary
+prelude
+prelude's
+preluded
+preluder
+preludes
+preluding
+premature
+prematurely
+prematureness
+prematurity
+premeditated
+premeditatedly
+premier
+premier's
+premiere
+premiered
+premieres
+premiering
+premiers
+premise
+premise's
+premised
+premises
+premising
+premium
+premium's
+premiums
+preoccupation
+preoccupations
+preoccupied
+preoccupies
+preoccupy
+preparation
+preparation's
+preparations
+preparative
+preparative's
+preparatively
+preparatives
+preparatory
+prepare
+prepared
+preparedly
+preparedness
+preparer
+prepares
+preparing
+prepend
+prepended
+prepender
+prependers
+prepending
+prepends
+preposition
+preposition's
+prepositional
+prepositionally
+prepositions
+preposterous
+preposterously
+preposterousness
+preprint
+preprinted
+preprinting
+preprints
+preprocessor
+preprocessors
+preproduction
+preprogrammed
+prerequisite
+prerequisite's
+prerequisites
+prerogative
+prerogative's
+prerogatived
+prerogatives
+prescribe
+prescribed
+prescriber
+prescribes
+prescribing
+prescription
+prescription's
+prescriptions
+prescriptive
+prescriptively
+preselect
+preselected
+preselecting
+preselects
+presence
+presence's
+presences
+present
+presentation
+presentation's
+presentations
+presented
+presenter
+presenters
+presenting
+presently
+presentness
+presents
+preservation
+preservations
+preservative
+preservative's
+preservatives
+preserve
+preserved
+preserver
+preservers
+preserves
+preserving
+preset
+presets
+preside
+presided
+presidency
+president
+president's
+presidential
+presidentially
+presidents
+presider
+presides
+presiding
+press
+pressed
+presser
+presses
+pressing
+pressingly
+pressings
+pressure
+pressured
+pressures
+pressuring
+prestige
+presumably
+presume
+presumed
+presumer
+presumes
+presuming
+presumingly
+presumption
+presumption's
+presumptions
+presumptuous
+presumptuously
+presumptuousness
+presuppose
+presupposed
+presupposes
+presupposing
+pretend
+pretended
+pretendedly
+pretender
+pretenders
+pretending
+pretends
+pretentious
+pretentiously
+pretentiousness
+pretext
+pretext's
+pretexts
+prettied
+prettier
+pretties
+prettiest
+prettily
+prettiness
+pretty
+prettying
+prevail
+prevailed
+prevailing
+prevailingly
+prevails
+prevalence
+prevalent
+prevalently
+prevent
+preventable
+preventably
+prevented
+preventer
+preventing
+prevention
+preventions
+preventive
+preventively
+preventiveness
+preventives
+prevents
+preview
+previewed
+previewer
+previewers
+previewing
+previews
+previous
+previously
+previousness
+prey
+preyed
+preyer
+preying
+preys
+price
+priced
+priceless
+pricer
+pricers
+prices
+pricing
+prick
+pricked
+pricker
+pricking
+pricklier
+prickliness
+prickly
+pricks
+pride
+prided
+prides
+priding
+pried
+prier
+pries
+priest
+priestliness
+priestly
+priests
+primacy
+primaries
+primarily
+primary
+primary's
+prime
+primed
+primely
+primeness
+primer
+primers
+primes
+primeval
+primevally
+priming
+primitive
+primitively
+primitiveness
+primitives
+primrose
+prince
+princelier
+princeliness
+princely
+princes
+princess
+princess's
+princesses
+principal
+principalities
+principality
+principality's
+principally
+principals
+principle
+principled
+principles
+print
+printable
+printably
+printed
+printer
+printers
+printing
+printout
+printouts
+prints
+prior
+priori
+priorities
+priority
+priority's
+priorly
+priors
+priory
+prism
+prism's
+prisms
+prison
+prisoner
+prisoner's
+prisoners
+prisons
+privacies
+privacy
+private
+privately
+privateness
+privates
+privation
+privations
+privative
+privatively
+privies
+privilege
+privileged
+privileges
+privy
+privy's
+prize
+prized
+prizer
+prizers
+prizes
+prizing
+pro
+pro's
+probabilistic
+probabilistically
+probabilities
+probability
+probable
+probably
+probate
+probated
+probates
+probating
+probation
+probationer
+probationers
+probative
+probe
+probed
+prober
+probes
+probing
+probings
+problem
+problem's
+problematic
+problematical
+problematically
+problems
+procedural
+procedurally
+procedure
+procedure's
+procedures
+proceed
+proceeded
+proceeder
+proceeding
+proceedings
+proceeds
+process
+process's
+processed
+processes
+processing
+procession
+processor
+processor's
+processors
+proclaim
+proclaimed
+proclaimer
+proclaimers
+proclaiming
+proclaims
+proclamation
+proclamation's
+proclamations
+proclivities
+proclivity
+proclivity's
+procrastinate
+procrastinated
+procrastinates
+procrastinating
+procrastination
+procrastinator
+procrastinator's
+procrastinators
+procure
+procured
+procurement
+procurement's
+procurements
+procurer
+procurers
+procures
+procuring
+prodigal
+prodigally
+prodigious
+prodigiously
+prodigiousness
+produce
+produced
+producer
+producers
+produces
+producible
+producing
+product
+product's
+production
+production's
+productions
+productive
+productively
+productiveness
+productivities
+productivity
+products
+profane
+profaned
+profanely
+profaneness
+profaner
+profaning
+profess
+professed
+professedly
+professes
+professing
+profession
+profession's
+professional
+professionalism
+professionalisms
+professionally
+professionals
+professions
+professor
+professor's
+professors
+proffer
+proffered
+proffering
+proffers
+proficiencies
+proficiency
+proficient
+proficiently
+profile
+profiled
+profiler
+profiler's
+profilers
+profiles
+profiling
+profit
+profit's
+profitability
+profitable
+profitableness
+profitably
+profited
+profiteer
+profiteer's
+profiteers
+profiter
+profiters
+profiting
+profits
+profound
+profoundest
+profoundly
+profoundness
+progeny
+program
+program's
+programmability
+programmable
+programmed
+programmer
+programmer's
+programmers
+programming
+programs
+progress
+progressed
+progresses
+progressing
+progression
+progression's
+progressions
+progressive
+progressively
+progressiveness
+prohibit
+prohibited
+prohibiter
+prohibiting
+prohibition
+prohibition's
+prohibitions
+prohibitive
+prohibitively
+prohibitiveness
+prohibits
+project
+project's
+projected
+projecting
+projection
+projection's
+projections
+projective
+projectively
+projector
+projector's
+projectors
+projects
+prolegomena
+proletariat
+proliferate
+proliferated
+proliferates
+proliferating
+proliferation
+proliferative
+prolific
+prolificness
+prolog
+prolog's
+prologs
+prologue
+prologue's
+prologues
+prolong
+prolonged
+prolonger
+prolonging
+prolongs
+promenade
+promenade's
+promenader
+promenades
+promenading
+prominence
+prominent
+prominently
+promiscuity
+promiscuity's
+promiscuous
+promiscuously
+promiscuousness
+promise
+promised
+promiser
+promises
+promising
+promisingly
+promontories
+promontory
+promote
+promoted
+promoter
+promoters
+promotes
+promoting
+promotion
+promotional
+promotions
+promotive
+promotiveness
+prompt
+prompted
+prompter
+prompters
+promptest
+prompting
+promptings
+promptly
+promptness
+prompts
+promulgate
+promulgated
+promulgates
+promulgating
+promulgation
+promulgations
+prone
+pronely
+proneness
+prong
+pronged
+prongs
+pronoun
+pronoun's
+pronounce
+pronounceable
+pronounced
+pronouncedly
+pronouncement
+pronouncement's
+pronouncements
+pronouncer
+pronounces
+pronouncing
+pronouns
+pronunciation
+pronunciation's
+pronunciations
+proof
+proof's
+proofed
+proofer
+proofing
+proofs
+prop
+propaganda
+propagate
+propagated
+propagates
+propagating
+propagation
+propagations
+propagative
+propel
+propelled
+propeller
+propeller's
+propellers
+propels
+propensities
+propensity
+proper
+properly
+properness
+propertied
+properties
+property
+prophecies
+prophecy
+prophecy's
+prophesied
+prophesier
+prophesies
+prophesy
+prophesying
+prophet
+prophet's
+prophetic
+prophets
+propitious
+propitiously
+propitiousness
+proponent
+proponent's
+proponents
+proportion
+proportional
+proportionally
+proportionately
+proportioned
+proportioner
+proportioning
+proportionment
+proportions
+proposal
+proposal's
+proposals
+propose
+proposed
+proposer
+proposers
+proposes
+proposing
+proposition
+propositional
+propositionally
+propositioned
+propositioning
+propositions
+propound
+propounded
+propounder
+propounding
+propounds
+proprietary
+proprietor
+proprietor's
+proprietors
+propriety
+props
+propulsion
+propulsion's
+propulsions
+pros
+prose
+prosecute
+prosecuted
+prosecutes
+prosecuting
+prosecution
+prosecutions
+proser
+prosing
+prosodic
+prosodics
+prospect
+prospected
+prospecting
+prospection
+prospection's
+prospections
+prospective
+prospectively
+prospectiveness
+prospectives
+prospector
+prospector's
+prospectors
+prospects
+prospectus
+prosper
+prospered
+prospering
+prosperity
+prosperous
+prosperously
+prosperousness
+prospers
+prostitution
+prostrate
+prostrated
+prostration
+protect
+protected
+protectedly
+protecting
+protection
+protection's
+protections
+protective
+protectively
+protectiveness
+protector
+protector's
+protectorate
+protectors
+protects
+protege
+protege's
+proteges
+protein
+protein's
+proteins
+protest
+protest's
+protestants
+protestation
+protestations
+protested
+protester
+protester's
+protesters
+protesting
+protestingly
+protests
+protocol
+protocol's
+protocols
+proton
+proton's
+protons
+protoplasm
+prototype
+prototype's
+prototyped
+prototypes
+prototypical
+prototypically
+prototyping
+protrude
+protruded
+protrudes
+protruding
+protrusion
+protrusion's
+protrusions
+proud
+prouder
+proudest
+proudly
+provability
+provable
+provableness
+provably
+prove
+proved
+proven
+provenly
+prover
+proverb
+proverb's
+proverbs
+provers
+proves
+provide
+provided
+providence
+provider
+providers
+provides
+providing
+province
+province's
+provinces
+provincial
+provincially
+proving
+provision
+provisional
+provisionally
+provisioned
+provisioner
+provisioning
+provisions
+provocation
+provoke
+provoked
+provokes
+provoking
+provokingly
+prow
+prow's
+prowess
+prowl
+prowled
+prowler
+prowlers
+prowling
+prowls
+prows
+proximal
+proximally
+proximate
+proximately
+proximateness
+proximity
+prudence
+prudent
+prudently
+prune
+pruned
+pruner
+pruners
+prunes
+pruning
+pry
+prying
+pryingly
+psalm
+psalm's
+psalms
+pseudo
+psyche
+psyche's
+psyches
+psychiatrist
+psychiatrist's
+psychiatrists
+psychiatry
+psychological
+psychologically
+psychologist
+psychologist's
+psychologists
+psychology
+psychosocial
+psychosocially
+pub
+pub's
+public
+publication
+publication's
+publications
+publicity
+publicly
+publicness
+publics
+publish
+published
+publisher
+publishers
+publishes
+publishing
+pubs
+pucker
+puckered
+puckering
+puckers
+pudding
+pudding's
+puddings
+puddle
+puddled
+puddler
+puddles
+puddling
+puff
+puffed
+puffer
+puffers
+puffing
+puffs
+pull
+pulled
+puller
+pulley
+pulley's
+pulleys
+pulling
+pullings
+pulls
+pulp
+pulper
+pulping
+pulpit
+pulpit's
+pulpits
+pulse
+pulsed
+pulser
+pulses
+pulsing
+pump
+pumped
+pumper
+pumping
+pumpkin
+pumpkin's
+pumpkins
+pumps
+pun
+pun's
+punch
+punched
+puncher
+puncher's
+punchers
+punches
+punching
+punchings
+punctual
+punctually
+punctualness
+punctuation
+puncture
+puncture's
+punctured
+punctures
+puncturing
+punier
+puniness
+punish
+punishable
+punished
+punisher
+punishes
+punishing
+punishment
+punishment's
+punishments
+punitive
+punitively
+punitiveness
+puns
+punt
+punted
+punter
+punters
+punting
+punts
+puny
+pup
+pup's
+pupa
+pupas
+pupil
+pupil's
+pupils
+puppet
+puppet's
+puppets
+puppies
+puppy
+puppy's
+pups
+purchasable
+purchase
+purchased
+purchaser
+purchasers
+purchases
+purchasing
+pure
+purely
+pureness
+purer
+purest
+purge
+purged
+purger
+purges
+purging
+purification
+purifications
+purified
+purifier
+purifiers
+purifies
+purify
+purifying
+purity
+purple
+purpled
+purpler
+purples
+purplest
+purpling
+purport
+purported
+purportedly
+purporter
+purporters
+purporting
+purports
+purpose
+purposed
+purposeful
+purposefully
+purposefulness
+purposely
+purposes
+purposing
+purposive
+purposively
+purposiveness
+purr
+purred
+purring
+purringly
+purrs
+purse
+pursed
+purser
+pursers
+purses
+pursing
+pursue
+pursued
+pursuer
+pursuers
+pursues
+pursuing
+pursuit
+pursuit's
+pursuits
+purview
+push
+pushbutton
+pushbuttons
+pushdown
+pushed
+pusher
+pushers
+pushes
+pushing
+puss
+pussier
+pussies
+pussy
+put
+puts
+putter
+putterer
+puttering
+putters
+putting
+puzzle
+puzzled
+puzzlement
+puzzler
+puzzlers
+puzzles
+puzzling
+puzzlings
+pygmies
+pygmy
+pygmy's
+pyramid
+pyramid's
+pyramids
+quack
+quacked
+quacking
+quacks
+quadrant
+quadrant's
+quadrants
+quadratic
+quadratical
+quadratically
+quadratics
+quadrature
+quadrature's
+quadratures
+quadruple
+quadrupled
+quadruples
+quadrupling
+quadword
+quadword's
+quadwords
+quagmire
+quagmire's
+quagmires
+quail
+quail's
+quails
+quaint
+quaintly
+quaintness
+quake
+quaked
+quaker
+quakers
+quakes
+quaking
+qualification
+qualifications
+qualified
+qualifiedly
+qualifier
+qualifiers
+qualifies
+qualify
+qualifying
+qualitative
+qualitatively
+qualities
+quality
+quality's
+qualm
+qualms
+quandaries
+quandary
+quandary's
+quanta
+quantifiable
+quantification
+quantifications
+quantified
+quantifier
+quantifiers
+quantifies
+quantify
+quantifying
+quantitative
+quantitatively
+quantitativeness
+quantities
+quantity
+quantity's
+quantum
+quarantine
+quarantine's
+quarantined
+quarantines
+quarantining
+quarrel
+quarrels
+quarrelsome
+quarrelsomely
+quarrelsomeness
+quarried
+quarrier
+quarries
+quarry
+quarry's
+quarrying
+quart
+quarter
+quartered
+quarterer
+quartering
+quarterlies
+quarterly
+quarters
+quartet
+quartet's
+quartets
+quarts
+quartz
+quash
+quashed
+quashes
+quashing
+quasi
+quaver
+quavered
+quavering
+quaveringly
+quavers
+quay
+quays
+queen
+queen's
+queenly
+queens
+queer
+queerer
+queerest
+queerly
+queerness
+queers
+quell
+quelled
+queller
+quelling
+quells
+quench
+quenched
+quencher
+quenches
+quenching
+queried
+querier
+queries
+query
+querying
+quest
+quested
+quester
+questers
+questing
+question
+questionable
+questionableness
+questionably
+questioned
+questioner
+questioners
+questioning
+questioningly
+questionings
+questionnaire
+questionnaire's
+questionnaires
+questions
+quests
+queue
+queue's
+queued
+queuer
+queuer's
+queuers
+queues
+quick
+quicken
+quickened
+quickener
+quickening
+quickens
+quicker
+quickest
+quickly
+quickness
+quicksilver
+quiet
+quieted
+quieten
+quietened
+quietening
+quietens
+quieter
+quietest
+quieting
+quietly
+quietness
+quiets
+quietude
+quill
+quills
+quilt
+quilted
+quilter
+quilting
+quilts
+quinine
+quit
+quite
+quits
+quitter
+quitter's
+quitters
+quitting
+quiver
+quivered
+quivering
+quivers
+quiz
+quizzed
+quizzes
+quizzing
+quo
+quota
+quota's
+quotas
+quotation
+quotation's
+quotations
+quote
+quoted
+quotes
+quoth
+quotient
+quotients
+quoting
+rabbit
+rabbit's
+rabbited
+rabbiter
+rabbiting
+rabbits
+rabble
+rabbled
+rabbler
+rabbling
+raccoon
+raccoon's
+raccoons
+race
+raced
+racehorse
+racehorse's
+racehorses
+racer
+racers
+races
+racial
+racially
+racing
+rack
+racked
+racker
+racket
+racket's
+racketeer
+racketeering
+racketeers
+rackets
+racking
+racks
+radar
+radar's
+radars
+radial
+radially
+radiance
+radiant
+radiantly
+radiate
+radiated
+radiately
+radiates
+radiating
+radiation
+radiations
+radiative
+radiatively
+radiator
+radiator's
+radiators
+radical
+radically
+radicalness
+radicals
+radio
+radioed
+radioing
+radiology
+radios
+radish
+radish's
+radishes
+radius
+radiuses
+radix
+radixes
+raft
+rafter
+raftered
+rafters
+rafts
+rag
+rag's
+rage
+raged
+rages
+ragged
+raggedly
+raggedness
+raging
+rags
+raid
+raided
+raider
+raiders
+raiding
+raids
+rail
+railed
+railer
+railers
+railing
+railroad
+railroaded
+railroader
+railroaders
+railroading
+railroads
+rails
+railway
+railway's
+railways
+raiment
+rain
+rain's
+rainbow
+rainbows
+raincoat
+raincoat's
+raincoats
+raindrop
+raindrop's
+raindrops
+rained
+rainfall
+rainier
+rainiest
+raining
+rains
+rainy
+raise
+raised
+raiser
+raisers
+raises
+raisin
+raising
+raisins
+rake
+raked
+raker
+rakes
+raking
+rallied
+rallies
+rally
+rallying
+ram
+ram's
+ramble
+rambled
+rambler
+ramblers
+rambles
+rambling
+ramblingly
+ramblings
+ramification
+ramification's
+ramifications
+ramp
+ramp's
+rampart
+ramparts
+ramped
+ramping
+ramps
+rams
+ramses
+ran
+ranch
+ranched
+rancher
+ranchers
+ranches
+ranching
+random
+randomly
+randomness
+rang
+range
+ranged
+ranger
+rangers
+ranges
+ranging
+rank
+ranked
+ranker
+ranker's
+rankers
+rankest
+ranking
+ranking's
+rankings
+rankle
+rankled
+rankles
+rankling
+rankly
+rankness
+ranks
+ransack
+ransacked
+ransacker
+ransacking
+ransacks
+ransom
+ransomer
+ransoming
+ransoms
+rant
+ranted
+ranter
+ranters
+ranting
+rantingly
+rants
+rap
+rap's
+rape
+raped
+raper
+rapes
+rapid
+rapidity
+rapidly
+rapidness
+rapids
+raping
+raps
+rapt
+raptly
+raptness
+rapture
+rapture's
+raptured
+raptures
+rapturing
+rapturous
+rapturously
+rapturousness
+rare
+rarely
+rareness
+rarer
+rarest
+raring
+rarities
+rarity
+rarity's
+rascal
+rascally
+rascals
+rash
+rasher
+rashes
+rashly
+rashness
+rasp
+raspberry
+rasped
+rasper
+rasping
+raspingly
+raspings
+rasps
+raster
+rasters
+rat
+rat's
+rate
+rated
+rater
+raters
+rates
+rather
+ratification
+ratifications
+ratified
+ratifies
+ratify
+ratifying
+rating
+ratings
+ratio
+ratio's
+ration
+rational
+rationale
+rationale's
+rationales
+rationalities
+rationality
+rationally
+rationalness
+rationed
+rationing
+rations
+ratios
+rats
+rattle
+rattled
+rattler
+rattlers
+rattles
+rattlesnake
+rattlesnake's
+rattlesnakes
+rattling
+rattlingly
+ravage
+ravaged
+ravager
+ravagers
+ravages
+ravaging
+rave
+raved
+raven
+ravened
+ravener
+ravening
+ravenous
+ravenously
+ravenousness
+ravens
+raver
+raves
+ravine
+ravine's
+ravined
+ravines
+raving
+ravings
+raw
+rawer
+rawest
+rawly
+rawness
+raws
+ray
+ray's
+rayed
+rays
+razor
+razor's
+razors
+re
+reabbreviate
+reabbreviated
+reabbreviates
+reabbreviating
+reach
+reachable
+reachably
+reached
+reacher
+reaches
+reaching
+reacquainted
+react
+reacted
+reacting
+reaction
+reaction's
+reactionaries
+reactionary
+reactionary's
+reactions
+reactivate
+reactivated
+reactivates
+reactivating
+reactivation
+reactive
+reactively
+reactiveness
+reactivity
+reactor
+reactor's
+reactors
+reacts
+read
+readability
+readable
+readableness
+readapting
+reader
+reader's
+readers
+readied
+readier
+readies
+readiest
+readily
+readiness
+reading
+readings
+readjustable
+readjusted
+readjustments
+readjusts
+readout
+readout's
+readouts
+reads
+ready
+readying
+reaffirm
+reaffirmed
+reaffirming
+reaffirms
+reagents
+real
+realest
+realign
+realigned
+realigning
+realignment
+realignments
+realigns
+realism
+realist
+realist's
+realistic
+realistically
+realists
+realities
+reality
+realizable
+realizable's
+realizableness
+realizables
+realizablies
+realizably
+realization
+realization's
+realizations
+realize
+realized
+realizer
+realizers
+realizes
+realizing
+realizing's
+realizingly
+realizings
+reallocate
+reallocated
+reallocates
+reallocating
+reallocation
+reallocation's
+reallocations
+reallocator
+reallocator's
+reallocators
+reallotments
+reallots
+reallotted
+reallotting
+really
+realm
+realm's
+realms
+realness
+reals
+ream
+ream's
+reamed
+reamer
+reaming
+reams
+reanalysis
+reap
+reaped
+reaper
+reaping
+reappear
+reappeared
+reappearing
+reappears
+reapplying
+reapportioned
+reappraisal
+reappraisals
+reappraised
+reappraises
+reaps
+rear
+reared
+rearer
+rearing
+rearmed
+rearms
+rearrange
+rearrangeable
+rearranged
+rearrangement
+rearrangement's
+rearrangements
+rearranges
+rearranging
+rearrest
+rearrested
+rears
+reason
+reasonable
+reasonableness
+reasonably
+reasoned
+reasoner
+reasoning
+reasonings
+reasons
+reassemble
+reassembled
+reassembler
+reassembles
+reassembling
+reasserts
+reassess
+reassessed
+reassesses
+reassessing
+reassessment
+reassessment's
+reassessments
+reassign
+reassignable
+reassigned
+reassigning
+reassignment
+reassignment's
+reassignments
+reassigns
+reassurances
+reassure
+reassured
+reassures
+reassuring
+reassuringly
+reawaken
+reawakened
+reawakening
+reawakens
+rebate
+rebate's
+rebated
+rebater
+rebates
+rebating
+rebel
+rebel's
+rebelled
+rebelling
+rebellion
+rebellion's
+rebellions
+rebellious
+rebelliously
+rebelliousness
+rebells
+rebels
+rebidding
+rebids
+rebirth
+rebirth's
+rebonds
+reboot
+rebooted
+rebooter
+rebooters
+rebooting
+reboots
+reborn
+rebound
+rebounded
+rebounder
+rebounding
+rebounds
+rebroadcast
+rebroadcasts
+rebuff
+rebuffed
+rebuffing
+rebuffs
+rebuild
+rebuilding
+rebuilds
+rebuilt
+rebuke
+rebuked
+rebuker
+rebukes
+rebuking
+rebut
+rebuttal
+rebuttals
+rebutted
+rebutting
+recalculate
+recalculated
+recalculates
+recalculating
+recalculation
+recalculations
+recall
+recalled
+recaller
+recalling
+recalls
+recapitulate
+recapitulated
+recapitulates
+recapitulating
+recapitulation
+recapped
+recapping
+recapture
+recaptured
+recaptures
+recapturing
+recast
+recasting
+recasts
+recede
+receded
+recedes
+receding
+receipt
+receipt's
+receipted
+receipting
+receipts
+receivable
+receivables
+receive
+received
+receiver
+receiver's
+receivers
+receives
+receiving
+recent
+recently
+recentness
+receptacle
+receptacle's
+receptacles
+reception
+reception's
+receptions
+receptive
+receptively
+receptiveness
+receptivity
+receptor
+receptor's
+receptors
+recess
+recessed
+recesses
+recessing
+recession
+recession's
+recessions
+recessive
+recessively
+recessiveness
+recharged
+recharges
+rechartering
+rechecked
+rechecks
+recipe
+recipe's
+recipes
+recipient
+recipient's
+recipients
+reciprocal
+reciprocally
+reciprocals
+reciprocate
+reciprocated
+reciprocates
+reciprocating
+reciprocation
+reciprocative
+reciprocity
+recirculate
+recirculated
+recirculates
+recirculating
+recirculation
+recital
+recital's
+recitals
+recitation
+recitation's
+recitations
+recite
+recited
+reciter
+recites
+reciting
+reckless
+recklessly
+recklessness
+reckon
+reckoned
+reckoner
+reckoning
+reckonings
+reckons
+reclaim
+reclaimable
+reclaimed
+reclaimer
+reclaimers
+reclaiming
+reclaims
+reclamation
+reclamations
+reclassification
+reclassified
+reclassifies
+reclassify
+reclassifying
+recline
+reclined
+reclines
+reclining
+reclustered
+reclusters
+recode
+recoded
+recodes
+recoding
+recognition
+recognition's
+recognitions
+recoil
+recoiled
+recoiling
+recoils
+recoinage
+recollect
+recollected
+recollecting
+recollection
+recollection's
+recollections
+recollects
+recombination
+recombination's
+recombinational
+recombinations
+recombine
+recombined
+recombines
+recombining
+recommenced
+recommences
+recommend
+recommendation
+recommendation's
+recommendations
+recommended
+recommender
+recommending
+recommends
+recompense
+recompilations
+recompile
+recompiled
+recompiles
+recompiling
+recompute
+recomputed
+recomputes
+recomputing
+reconcile
+reconciled
+reconciler
+reconciles
+reconciliation
+reconciliation's
+reconciliations
+reconciling
+reconditioned
+reconfigurable
+reconfiguration
+reconfiguration's
+reconfigurations
+reconfigure
+reconfigured
+reconfigurer
+reconfigures
+reconfiguring
+reconnect
+reconnected
+reconnecter
+reconnecting
+reconnection
+reconnects
+reconsider
+reconsideration
+reconsidered
+reconsidering
+reconsiders
+reconsolidated
+reconsolidates
+reconstituted
+reconstitutes
+reconstruct
+reconstructed
+reconstructible
+reconstructing
+reconstruction
+reconstructions
+reconstructive
+reconstructs
+recontacted
+reconvened
+reconvenes
+reconverts
+record
+recorded
+recorder
+recorders
+recording
+recordings
+records
+recored
+recount
+recounted
+recounter
+recounting
+recounts
+recourse
+recourses
+recover
+recoverability
+recoverable
+recovered
+recoverer
+recoveries
+recovering
+recovers
+recovery
+recovery's
+recreate
+recreated
+recreates
+recreating
+recreation
+recreational
+recreations
+recreative
+recruit
+recruit's
+recruited
+recruiter
+recruiter's
+recruiters
+recruiting
+recruits
+recta
+rectangle
+rectangle's
+rectangles
+rectangular
+rectangularly
+rector
+rector's
+rectors
+rectum
+rectum's
+rectums
+recur
+recurrence
+recurrence's
+recurrences
+recurrent
+recurrently
+recurring
+recurs
+recurse
+recursed
+recurses
+recursing
+recursion
+recursion's
+recursions
+recursive
+recursively
+recursiveness
+recurved
+recyclable
+recycle
+recycled
+recycles
+recycling
+red
+redbreast
+redden
+reddened
+reddening
+redder
+reddest
+reddish
+reddishness
+redeclare
+redeclared
+redeclares
+redeclaring
+redecorated
+redecorates
+redeem
+redeemed
+redeemer
+redeemers
+redeeming
+redeems
+redefine
+redefined
+redefines
+redefining
+redefinition
+redefinition's
+redefinitions
+redemption
+redemptioner
+redeploys
+redeposit
+redeposit's
+redeposited
+redepositing
+redepositor
+redepositor's
+redepositors
+redeposits
+redesign
+redesigned
+redesigning
+redesigns
+redetermination
+redetermines
+redevelop
+redeveloped
+redeveloper
+redevelopers
+redeveloping
+redevelopment
+redevelops
+redials
+redirect
+redirected
+redirecting
+redirection
+redirections
+redirector
+redirector's
+redirectors
+redirects
+rediscovered
+rediscovers
+redisplay
+redisplayed
+redisplaying
+redisplays
+redistribute
+redistributed
+redistributes
+redistributing
+redistribution
+redistribution's
+redistributions
+redistributive
+redly
+redness
+redoing
+redone
+redouble
+redoubled
+redoubles
+redoubling
+redoubtable
+redraw
+redrawing
+redrawn
+redraws
+redress
+redressed
+redresser
+redresses
+redressing
+reds
+reduce
+reduced
+reducer
+reducers
+reduces
+reducibility
+reducible
+reducibly
+reducing
+reduction
+reduction's
+reductions
+redundancies
+redundancy
+redundant
+redundantly
+reduplicated
+reed
+reed's
+reeder
+reeding
+reeds
+reeducation
+reef
+reefer
+reefing
+reefs
+reel
+reelect
+reelected
+reelecting
+reelects
+reeled
+reeler
+reeling
+reels
+reemerged
+reenactment
+reenforcement
+reenlists
+reenter
+reentered
+reentering
+reenters
+reentrant
+reestablish
+reestablished
+reestablishes
+reestablishing
+reestimating
+reevaluate
+reevaluated
+reevaluates
+reevaluating
+reevaluation
+reeves
+reexamine
+reexamined
+reexamines
+reexamining
+refaced
+refaces
+refelled
+refelling
+refer
+referee
+referee's
+refereed
+refereeing
+referees
+reference
+referenced
+referencer
+references
+referencing
+referendum
+referent
+referent's
+referential
+referentiality
+referentially
+referents
+referral
+referral's
+referrals
+referred
+referrer
+referring
+refers
+refill
+refillable
+refilled
+refilling
+refills
+refine
+refined
+refinement
+refinement's
+refinements
+refiner
+refines
+refining
+refinished
+reflect
+reflected
+reflecting
+reflection
+reflection's
+reflections
+reflective
+reflectively
+reflectiveness
+reflectivity
+reflector
+reflector's
+reflectors
+reflects
+reflex
+reflex's
+reflexed
+reflexes
+reflexive
+reflexively
+reflexiveness
+reflexivity
+reflexly
+refluent
+refocus
+refocused
+refocuses
+refocusing
+refolded
+reform
+reformable
+reformat
+reformation
+reformative
+reformats
+reformatted
+reformatter
+reformatting
+reformed
+reformer
+reformers
+reforming
+reforms
+reformulate
+reformulated
+reformulates
+reformulating
+reformulation
+refractoriness
+refractory
+refrain
+refrained
+refraining
+refrains
+refresh
+refreshed
+refreshen
+refresher
+refreshers
+refreshes
+refreshing
+refreshingly
+refreshment
+refreshment's
+refreshments
+refried
+refries
+refrigerator
+refrigerator's
+refrigerators
+refry
+refrying
+refuel
+refuels
+refuge
+refuged
+refugee
+refugee's
+refugees
+refuges
+refuging
+refund
+refund's
+refunded
+refunder
+refunders
+refunding
+refunds
+refusal
+refusals
+refuse
+refused
+refuser
+refuses
+refusing
+refutable
+refutation
+refute
+refuted
+refuter
+refutes
+refuting
+regain
+regained
+regaining
+regains
+regal
+regaled
+regaling
+regally
+regard
+regarded
+regarding
+regardless
+regardlessly
+regardlessness
+regards
+regenerate
+regenerated
+regenerately
+regenerateness
+regenerates
+regenerating
+regeneration
+regenerative
+regeneratively
+regenerators
+regent
+regent's
+regents
+regime
+regime's
+regimen
+regiment
+regimented
+regiments
+regimes
+region
+region's
+regional
+regionally
+regions
+register
+registered
+registering
+registers
+registration
+registration's
+registrations
+regreets
+regress
+regressed
+regresses
+regressing
+regression
+regression's
+regressions
+regressive
+regressively
+regressiveness
+regret
+regretful
+regretfully
+regretfulness
+regrets
+regrettable
+regrettably
+regretted
+regretting
+regrids
+regroup
+regrouped
+regrouping
+regular
+regularities
+regularity
+regularly
+regulars
+regulate
+regulated
+regulates
+regulating
+regulation
+regulations
+regulative
+regulator
+regulator's
+regulators
+rehash
+rehashed
+rehashes
+rehashing
+rehearsal
+rehearsal's
+rehearsals
+rehearse
+rehearsed
+rehearser
+rehearses
+rehearsing
+rehoused
+rehouses
+reign
+reigned
+reigning
+reigns
+reimbursed
+reimbursement
+reimbursement's
+reimbursements
+rein
+reincarnate
+reincarnated
+reincarnation
+reincorporating
+reincorporation
+reindeer
+reined
+reinforce
+reinforced
+reinforcement
+reinforcement's
+reinforcements
+reinforcer
+reinforces
+reinforcing
+reining
+reins
+reinsert
+reinserted
+reinserting
+reinsertions
+reinserts
+reinstall
+reinstalled
+reinstaller
+reinstalling
+reinstalls
+reinstate
+reinstated
+reinstatement
+reinstates
+reinstating
+reintegrated
+reinterpret
+reinterpretations
+reinterpreted
+reinterpreting
+reinterprets
+reinterviewed
+reintroduce
+reintroduced
+reintroduces
+reintroducing
+reinvent
+reinvented
+reinventing
+reinvention
+reinvents
+reinvested
+reinvoked
+reinvokes
+reissue
+reissued
+reissuer
+reissuer's
+reissuers
+reissues
+reissuing
+reiterate
+reiterated
+reiterates
+reiterating
+reiteration
+reiterations
+reiterative
+reiteratively
+reiterativeness
+reject
+rejected
+rejecter
+rejecting
+rejectingly
+rejection
+rejection's
+rejections
+rejective
+rejector
+rejector's
+rejectors
+rejects
+rejoice
+rejoiced
+rejoicer
+rejoices
+rejoicing
+rejoicingly
+rejoin
+rejoined
+rejoining
+rejoins
+rekindle
+rekindled
+rekindler
+rekindles
+rekindling
+reknit
+relabel
+relabels
+relapse
+relapsed
+relapser
+relapses
+relapsing
+relate
+related
+relatedly
+relatedness
+relater
+relates
+relating
+relation
+relational
+relationally
+relations
+relationship
+relationship's
+relationships
+relative
+relatively
+relativeness
+relatives
+relativism
+relativistic
+relativistically
+relativity
+relativity's
+relax
+relaxation
+relaxation's
+relaxations
+relaxed
+relaxedly
+relaxedness
+relaxer
+relaxes
+relaxing
+relay
+relayed
+relaying
+relays
+relearns
+release
+released
+releaser
+releases
+releasing
+relegate
+relegated
+relegates
+relegating
+relegation
+relent
+relented
+relenting
+relentless
+relentlessly
+relentlessness
+relents
+relevance
+relevances
+relevant
+relevantly
+reliabilities
+reliability
+reliable
+reliableness
+reliably
+reliance
+relic
+relic's
+relicense
+relicensed
+relicenser
+relicenses
+relicensing
+relics
+relied
+relief
+reliefs
+relier
+relies
+relieve
+relieved
+relievedly
+reliever
+relievers
+relieves
+relieving
+religion
+religion's
+religions
+religious
+religiously
+religiousness
+relinking
+relinquish
+relinquished
+relinquishes
+relinquishing
+relish
+relished
+relishes
+relishing
+relive
+relives
+reliving
+reload
+reloaded
+reloader
+reloading
+reloads
+relocate
+relocated
+relocates
+relocating
+relocation
+relocations
+reluctance
+reluctances
+reluctant
+reluctantly
+rely
+relying
+remade
+remain
+remainder
+remainder's
+remaindered
+remaindering
+remainders
+remained
+remaining
+remains
+remark
+remarkable
+remarkableness
+remarkably
+remarked
+remarking
+remarks
+remarriages
+remarried
+remedied
+remedies
+remedy
+remedying
+remember
+remembered
+rememberer
+remembering
+remembers
+remembrance
+remembrance's
+remembrancer
+remembrances
+remind
+reminded
+reminder
+reminders
+reminding
+reminds
+reminiscence
+reminiscence's
+reminiscences
+reminiscent
+reminiscently
+remissions
+remittance
+remittances
+remixed
+remnant
+remnant's
+remnants
+remodel
+remodels
+remodulate
+remodulated
+remodulates
+remodulating
+remodulation
+remodulator
+remodulator's
+remodulators
+remolding
+remonstrate
+remonstrated
+remonstrates
+remonstrating
+remonstration
+remonstrative
+remonstratively
+remorse
+remote
+remotely
+remoteness
+remotest
+remotion
+remoulds
+removable
+removableness
+removal
+removal's
+removals
+remove
+removed
+remover
+removes
+removing
+renaissance
+renal
+rename
+renamed
+renames
+renaming
+renatured
+renatures
+rend
+render
+rendered
+renderer
+rendering
+renderings
+renders
+rendezvous
+rendezvoused
+rendezvouses
+rendezvousing
+rending
+rendition
+rendition's
+renditions
+rends
+renegotiable
+renegotiated
+renegotiates
+renew
+renewal
+renewals
+renewed
+renewer
+renewing
+renews
+reno
+renominated
+renominates
+renounce
+renounced
+renouncer
+renounces
+renouncing
+renown
+renowned
+rent
+rental
+rental's
+rentals
+rented
+renter
+renter's
+renters
+renting
+rents
+renumber
+renumbered
+renumbering
+renumbers
+reopen
+reopened
+reopening
+reopens
+reorder
+reordered
+reordering
+reorders
+reoriented
+repackage
+repackaged
+repackager
+repackages
+repackaging
+repacks
+repaid
+repaint
+repainted
+repainter
+repainters
+repainting
+repaints
+repair
+repaired
+repairer
+repairers
+repairing
+repairman
+repairs
+reparable
+reparation
+reparation's
+reparations
+repartition
+repartitioned
+repartitioner
+repartitioners
+repartitioning
+repartitions
+repast
+repast's
+repasts
+repaving
+repay
+repayable
+repaying
+repayments
+repays
+repeal
+repealed
+repealer
+repealing
+repeals
+repeat
+repeatable
+repeated
+repeatedly
+repeater
+repeaters
+repeating
+repeats
+repel
+repels
+repent
+repentance
+repented
+repenter
+repenting
+repents
+repercussion
+repercussion's
+repercussions
+repertoire
+repetition
+repetition's
+repetitions
+repetitive
+repetitively
+repetitiveness
+rephrase
+rephrased
+rephrases
+rephrasing
+repine
+repined
+repiner
+repining
+replace
+replaceable
+replaced
+replacement
+replacement's
+replacements
+replacer
+replaces
+replacing
+replanted
+replay
+replayed
+replaying
+replays
+repleader
+replenish
+replenished
+replenisher
+replenishes
+replenishing
+replete
+repleteness
+repletion
+replica
+replica's
+replicas
+replicate
+replicated
+replicates
+replicating
+replication
+replications
+replicative
+replied
+replier
+replies
+reply
+replying
+report
+reported
+reportedly
+reporter
+reporters
+reporting
+reports
+repose
+reposed
+reposes
+reposing
+reposition
+repositioned
+repositioning
+repositions
+repositories
+repository
+repository's
+repost
+reposted
+reposter
+reposting
+repostings
+reposts
+represent
+representable
+representably
+representation
+representation's
+representational
+representationally
+representations
+representative
+representatively
+representativeness
+representatives
+represented
+representer
+representing
+represents
+repress
+repressed
+represses
+repressing
+repression
+repression's
+repressions
+repressive
+repressively
+repressiveness
+reprieve
+reprieved
+reprieves
+reprieving
+reprint
+reprinted
+reprinter
+reprinting
+reprints
+reprisal
+reprisal's
+reprisals
+reproach
+reproached
+reproacher
+reproaches
+reproaching
+reproachingly
+reprobates
+reprocessed
+reproduce
+reproduced
+reproducer
+reproducers
+reproduces
+reproducibilities
+reproducibility
+reproducible
+reproducibly
+reproducing
+reproduction
+reproduction's
+reproductions
+reproductive
+reproductively
+reproductivity
+reprogrammed
+reprogrammer
+reprogrammer's
+reprogrammers
+reprogramming
+reproof
+reprove
+reproved
+reprover
+reproving
+reprovingly
+reptile
+reptile's
+reptiles
+republic
+republic's
+republican
+republican's
+republicans
+republication
+republics
+republish
+republished
+republisher
+republisher's
+republishers
+republishes
+republishing
+repudiate
+repudiated
+repudiates
+repudiating
+repudiation
+repudiations
+repulse
+repulsed
+repulses
+repulsing
+repulsion
+repulsions
+repulsive
+repulsively
+repulsiveness
+reputable
+reputably
+reputation
+reputation's
+reputations
+repute
+reputed
+reputedly
+reputes
+reputing
+request
+requested
+requester
+requesters
+requesting
+requestioned
+requests
+requiem
+requiem's
+requiems
+require
+required
+requirement
+requirement's
+requirements
+requirer
+requires
+requiring
+requisite
+requisiteness
+requisites
+requisition
+requisitioned
+requisitioner
+requisitioning
+requisitions
+requite
+requited
+requiter
+requiting
+reran
+reread
+rereading
+rereads
+reroute
+rerouted
+rerouter
+rerouters
+reroutes
+reroutings
+rerun
+rerunning
+reruns
+res
+resalable
+resaturated
+resaturates
+rescaled
+rescan
+rescanned
+rescanning
+rescans
+reschedule
+rescheduled
+rescheduler
+reschedules
+rescheduling
+rescue
+rescued
+rescuer
+rescuers
+rescues
+rescuing
+resealed
+research
+researched
+researcher
+researcher's
+researchers
+researches
+researching
+reselect
+reselected
+reselecting
+reselects
+resell
+reseller
+resellers
+reselling
+resells
+resemblance
+resemblance's
+resemblances
+resemble
+resembled
+resembles
+resembling
+resends
+resent
+resented
+resentful
+resentfully
+resentfulness
+resenting
+resentment
+resents
+resequenced
+reservation
+reservation's
+reservations
+reserve
+reserved
+reservedly
+reservedness
+reserver
+reserves
+reserving
+reservoir
+reservoir's
+reservoirs
+reset
+reseted
+reseter
+reseting
+resets
+resetting
+resettings
+resettled
+resettles
+resettling
+reshape
+reshaped
+reshaper
+reshapes
+reshaping
+reside
+resided
+residence
+residence's
+residences
+resident
+resident's
+residential
+residentially
+residents
+resider
+resides
+residing
+residue
+residue's
+residues
+resifted
+resign
+resignation
+resignation's
+resignations
+resigned
+resignedly
+resignedness
+resigner
+resigning
+resigns
+resin
+resin's
+resined
+resining
+resins
+resist
+resistance
+resistances
+resistant
+resistantly
+resisted
+resister
+resistible
+resistibly
+resisting
+resistive
+resistively
+resistiveness
+resistivity
+resistor
+resistor's
+resistors
+resists
+resize
+resized
+resizes
+resizing
+resold
+resoluble
+resolute
+resolutely
+resoluteness
+resolution
+resolutions
+resolutive
+resolvable
+resolve
+resolved
+resolver
+resolvers
+resolves
+resolving
+resonance
+resonances
+resonant
+resonantly
+resort
+resorted
+resorter
+resorting
+resorts
+resound
+resounding
+resoundingly
+resounds
+resource
+resource's
+resourced
+resourceful
+resourcefully
+resourcefulness
+resources
+resourcing
+respecified
+respect
+respectability
+respectable
+respectableness
+respectably
+respected
+respecter
+respectful
+respectfully
+respectfulness
+respecting
+respective
+respectively
+respectiveness
+respects
+respiration
+respirations
+respired
+respires
+respite
+respited
+respiting
+resplendent
+resplendently
+respond
+responded
+respondent
+respondent's
+respondents
+responder
+responders
+responding
+responds
+response
+responser
+responses
+responsibilities
+responsibility
+responsible
+responsibleness
+responsibly
+responsions
+responsive
+responsively
+responsiveness
+rest
+restart
+restarted
+restarter
+restarting
+restarts
+restate
+restated
+restatement
+restates
+restating
+restaurant
+restaurant's
+restaurants
+rested
+rester
+restful
+restfully
+restfulness
+resting
+restive
+restively
+restiveness
+restless
+restlessly
+restlessness
+restoration
+restoration's
+restorations
+restore
+restored
+restorer
+restorers
+restores
+restoring
+restrain
+restrained
+restrainedly
+restrainer
+restrainers
+restraining
+restrains
+restraint
+restraint's
+restraints
+restrict
+restricted
+restrictedly
+restricting
+restriction
+restriction's
+restrictions
+restrictive
+restrictively
+restrictiveness
+restricts
+restroom
+restroom's
+restrooms
+restructure
+restructured
+restructures
+restructuring
+rests
+resubmit
+resubmits
+resubmitted
+resubmitting
+result
+resultant
+resultantly
+resultants
+resulted
+resulting
+results
+resumable
+resume
+resumed
+resumes
+resuming
+resumption
+resumption's
+resumptions
+resupplier
+resupplier's
+resuppliers
+resurface
+resurfaced
+resurfacer
+resurfacer's
+resurfacers
+resurfaces
+resurfacing
+resurged
+resurges
+resurrect
+resurrected
+resurrecting
+resurrection
+resurrection's
+resurrections
+resurrects
+resuspended
+retail
+retailed
+retailer
+retailers
+retailing
+retails
+retain
+retained
+retainer
+retainers
+retaining
+retainment
+retains
+retaliation
+retard
+retarded
+retarder
+retarding
+retention
+retentions
+retentive
+retentively
+retentiveness
+rethinks
+rethreading
+reticence
+reticent
+reticently
+reticle
+reticle's
+reticles
+reticular
+reticulate
+reticulated
+reticulately
+reticulates
+reticulating
+reticulation
+retied
+retina
+retina's
+retinal
+retinas
+retinue
+retinues
+retire
+retired
+retiredly
+retiredness
+retirement
+retirement's
+retirements
+retires
+retiring
+retiringly
+retiringness
+retitled
+retold
+retort
+retorted
+retorting
+retorts
+retrace
+retraced
+retraces
+retracing
+retract
+retractable
+retracted
+retracting
+retraction
+retractions
+retractor
+retractor's
+retractors
+retracts
+retrain
+retrained
+retraining
+retrains
+retranslated
+retransmission
+retransmission's
+retransmissions
+retransmit
+retransmits
+retransmitted
+retransmitting
+retreat
+retreated
+retreater
+retreating
+retreats
+retried
+retrier
+retriers
+retries
+retrievable
+retrieval
+retrieval's
+retrievals
+retrieve
+retrieved
+retriever
+retrievers
+retrieves
+retrieving
+retroactively
+retrospect
+retrospection
+retrospective
+retrospectively
+retry
+retrying
+return
+returnable
+returned
+returner
+returners
+returning
+returns
+retype
+retyped
+retypes
+retyping
+reunion
+reunion's
+reunions
+reunite
+reunited
+reuniting
+reupholstering
+reusable
+reuse
+reused
+reuses
+reusing
+revalidated
+revalidates
+revalidation
+revalued
+revalues
+revamp
+revamped
+revamping
+revamps
+reveal
+revealed
+revealer
+revealing
+reveals
+revel
+revelation
+revelation's
+revelations
+revelry
+revels
+revenge
+revenge's
+revenged
+revenger
+revenges
+revenging
+revenue
+revenuer
+revenuers
+revenues
+revere
+revered
+reverence
+reverencer
+reverend
+reverend's
+reverends
+reverently
+reveres
+reverified
+reverifies
+reverify
+reverifying
+revering
+reversal
+reversal's
+reversals
+reverse
+reversed
+reversely
+reverser
+reverses
+reversible
+reversing
+reversion
+reversioner
+reversions
+revert
+reverted
+reverter
+reverting
+revertive
+reverts
+revetting
+review
+reviewed
+reviewer
+reviewers
+reviewing
+reviews
+revile
+reviled
+reviler
+reviling
+revise
+revised
+reviser
+revises
+revising
+revision
+revision's
+revisions
+revisit
+revisited
+revisiting
+revisits
+revival
+revival's
+revivals
+revive
+revived
+reviver
+revives
+reviving
+revocation
+revocations
+revoke
+revoked
+revoker
+revokes
+revoking
+revolt
+revolted
+revolter
+revolting
+revoltingly
+revolts
+revolution
+revolution's
+revolutionaries
+revolutionariness
+revolutionary
+revolutionary's
+revolutions
+revolve
+revolved
+revolver
+revolvers
+revolves
+revolving
+reward
+rewarded
+rewarder
+rewarding
+rewardingly
+rewards
+rewind
+rewinded
+rewinder
+rewinding
+rewinds
+rewired
+rewires
+reword
+reworded
+rewording
+rewording's
+rewordings
+rewords
+rework
+reworked
+reworking
+reworks
+rewound
+rewrite
+rewriter
+rewrites
+rewriting
+rewritings
+rewritten
+rewrote
+rhetoric
+rheumatism
+rhinoceros
+rhubarb
+rhyme
+rhymed
+rhymer
+rhymes
+rhyming
+rhythm
+rhythm's
+rhythmic
+rhythmical
+rhythmically
+rhythmics
+rhythms
+rib
+rib's
+ribbed
+ribbing
+ribbon
+ribbon's
+ribbons
+ribs
+rice
+ricer
+rices
+rich
+richen
+richened
+richening
+richer
+riches
+richest
+richly
+richness
+rickshaw
+rickshaw's
+rickshaws
+rid
+ridden
+riddle
+riddled
+riddler
+riddles
+riddling
+ride
+rider
+rider's
+riders
+rides
+ridge
+ridge's
+ridged
+ridges
+ridging
+ridicule
+ridiculed
+ridiculer
+ridicules
+ridiculing
+ridiculous
+ridiculously
+ridiculousness
+riding
+ridings
+rids
+rifle
+rifled
+rifleman
+rifler
+rifles
+rifling
+rift
+rig
+rig's
+rigged
+rigging
+right
+righted
+righten
+righteous
+righteously
+righteousness
+righter
+rightful
+rightfully
+rightfulness
+righting
+rightly
+rightmost
+rightness
+rights
+rightward
+rightwards
+rigid
+rigidities
+rigidity
+rigidly
+rigidness
+rigorous
+rigorously
+rigorousness
+rigs
+rill
+rim
+rim's
+rime
+rimer
+riming
+rims
+rind
+rind's
+rinded
+rinds
+ring
+ringed
+ringer
+ringers
+ringing
+ringingly
+ringings
+rings
+rinse
+rinsed
+rinser
+rinses
+rinsing
+riot
+rioted
+rioter
+rioters
+rioting
+riotous
+riotously
+riotousness
+riots
+rip
+ripe
+ripely
+ripen
+ripened
+ripener
+ripeness
+ripening
+ripens
+riper
+ripest
+ripped
+ripping
+ripple
+rippled
+rippler
+ripples
+rippling
+rips
+rise
+risen
+riser
+risers
+rises
+rising
+risings
+risk
+risked
+risker
+risking
+risks
+rite
+rite's
+rited
+rites
+ritual
+ritually
+rituals
+rival
+rivalries
+rivalry
+rivalry's
+rivals
+rive
+rived
+riven
+river
+river's
+rivers
+riverside
+rivet
+riveted
+riveter
+riveting
+rivets
+riving
+rivulet
+rivulet's
+rivulets
+road
+road's
+roads
+roadside
+roadsides
+roadster
+roadster's
+roadsters
+roadway
+roadway's
+roadways
+roam
+roamed
+roamer
+roaming
+roams
+roar
+roared
+roarer
+roaring
+roaringest
+roars
+roast
+roasted
+roaster
+roasting
+roasts
+rob
+robbed
+robber
+robber's
+robberies
+robbers
+robbery
+robbery's
+robbing
+robe
+robed
+robes
+robin
+robin's
+robing
+robins
+robot
+robot's
+robotic
+robotics
+robots
+robs
+robust
+robustly
+robustness
+rock
+rocked
+rocker
+rockers
+rocket
+rocket's
+rocketed
+rocketing
+rockets
+rockier
+rockies
+rockiness
+rocking
+rocks
+rocky
+rod
+rod's
+rode
+rods
+roe
+roes
+rogue
+rogue's
+rogues
+roguing
+role
+role's
+roles
+roll
+rolled
+roller
+rollers
+rolling
+rolls
+romance
+romanced
+romancer
+romancers
+romances
+romancing
+romantic
+romantic's
+romantically
+romantics
+romp
+romped
+romper
+rompers
+romping
+romps
+roof
+roofed
+roofer
+roofers
+roofing
+roofs
+rook
+rooks
+room
+roomed
+roomer
+roomers
+rooming
+rooms
+roost
+rooster
+roosters
+root
+root's
+rooted
+rootedness
+rooter
+rooting
+roots
+rope
+roped
+roper
+ropers
+ropes
+roping
+rose
+rose's
+rosebud
+rosebud's
+rosebuds
+roses
+rosier
+rosiness
+rosy
+rot
+rotary
+rotate
+rotated
+rotates
+rotating
+rotation
+rotational
+rotationally
+rotations
+rotative
+rotatively
+rotator
+rotator's
+rotators
+rots
+rotten
+rottenly
+rottenness
+rouge
+rough
+roughed
+roughen
+roughened
+roughening
+roughens
+rougher
+roughest
+roughly
+roughness
+rouging
+round
+roundabout
+roundaboutness
+rounded
+roundedness
+rounder
+rounders
+roundest
+rounding
+roundly
+roundness
+roundoff
+rounds
+roundup
+roundup's
+roundups
+rouse
+roused
+rouser
+rouses
+rousing
+rout
+route
+routed
+router
+routers
+routes
+routine
+routinely
+routines
+routing
+routings
+rove
+roved
+rover
+roves
+roving
+row
+rowed
+rowen
+rower
+rowers
+rowing
+rows
+royal
+royalist
+royalist's
+royalists
+royally
+royalties
+royalty
+royalty's
+rub
+rubbed
+rubber
+rubber's
+rubbers
+rubbing
+rubbish
+rubbishes
+rubble
+rubbled
+rubbling
+rubies
+rubout
+rubs
+ruby
+ruby's
+rudder
+rudder's
+rudders
+ruddier
+ruddiness
+ruddy
+rude
+rudely
+rudeness
+ruder
+rudest
+rudiment
+rudiment's
+rudimentariness
+rudimentary
+rudiments
+rue
+ruefully
+rues
+ruffian
+ruffianly
+ruffians
+ruffle
+ruffled
+ruffler
+ruffles
+ruffling
+rug
+rug's
+rugged
+ruggedly
+ruggedness
+rugs
+ruin
+ruination
+ruination's
+ruinations
+ruined
+ruiner
+ruing
+ruining
+ruinous
+ruinously
+ruinousness
+ruins
+rule
+ruled
+ruler
+rulers
+rules
+ruling
+rulings
+rum
+rumble
+rumbled
+rumbler
+rumbles
+rumbling
+rumen
+rumens
+rump
+rumple
+rumpled
+rumples
+rumplier
+rumpling
+rumply
+rumps
+run
+runaway
+runaways
+rung
+rung's
+rungs
+runnable
+runner
+runner's
+runners
+running
+runs
+runtime
+rupture
+ruptured
+ruptures
+rupturing
+rural
+rurally
+rush
+rushed
+rusher
+rushes
+rushing
+russet
+russeted
+russeting
+russets
+rust
+rusted
+rustic
+rusticate
+rusticated
+rusticates
+rusticating
+rustication
+rustier
+rustiness
+rusting
+rustle
+rustled
+rustler
+rustlers
+rustles
+rustling
+rusts
+rusty
+rut
+rut's
+ruthless
+ruthlessly
+ruthlessness
+ruts
+rye
+rye's
+sable
+sable's
+sables
+sabotage
+sabotaged
+sabotages
+sabotaging
+sack
+sacked
+sacker
+sacking
+sacks
+sacred
+sacredly
+sacredness
+sacrifice
+sacrificed
+sacrificer
+sacrificers
+sacrifices
+sacrificial
+sacrificially
+sacrificing
+sad
+sadden
+saddened
+saddening
+saddens
+sadder
+saddest
+saddle
+saddled
+saddler
+saddles
+saddling
+sadism
+sadist
+sadist's
+sadistic
+sadistically
+sadists
+sadly
+sadness
+safe
+safeguard
+safeguarded
+safeguarding
+safeguards
+safely
+safeness
+safer
+safes
+safest
+safetied
+safeties
+safety
+safetying
+sag
+sagacious
+sagaciously
+sagaciousness
+sagacity
+sage
+sagely
+sageness
+sages
+sags
+said
+sail
+sailed
+sailer
+sailing
+sailor
+sailorly
+sailors
+sails
+saint
+sainted
+saintliness
+saintly
+saints
+sake
+saker
+sakes
+salable
+salad
+salad's
+salads
+salaried
+salaries
+salary
+sale
+sale's
+sales
+salesman
+salesmen
+salespeople
+salespeople's
+salesperson
+salesperson's
+salient
+saliently
+saline
+saliva
+sallied
+sallies
+sallow
+sallowness
+sally
+sallying
+salmon
+salmons
+salon
+salon's
+salons
+saloon
+saloon's
+saloons
+salt
+salted
+salter
+salters
+saltier
+saltiest
+saltiness
+salting
+saltness
+salts
+salty
+salutariness
+salutary
+salutation
+salutation's
+salutations
+salute
+saluted
+saluter
+salutes
+saluting
+salvage
+salvaged
+salvager
+salvages
+salvaging
+salvation
+salve
+salver
+salves
+salving
+same
+sameness
+sample
+sample's
+sampled
+sampler
+samplers
+samples
+sampling
+samplings
+sanctification
+sanctified
+sanctifier
+sanctify
+sanction
+sanctioned
+sanctioning
+sanctions
+sanctities
+sanctity
+sanctuaries
+sanctuary
+sanctuary's
+sand
+sandal
+sandal's
+sandals
+sanded
+sander
+sanders
+sandier
+sandiness
+sanding
+sandpaper
+sands
+sandstone
+sandstones
+sandwich
+sandwiched
+sandwiches
+sandwiching
+sandy
+sane
+sanely
+saneness
+saner
+sanest
+sang
+sanguine
+sanguinely
+sanguineness
+sanitarium
+sanitariums
+sanitary
+sanitation
+sanity
+sank
+sap
+sap's
+sapling
+sapling's
+saplings
+sapphire
+saps
+sarcasm
+sarcasm's
+sarcasms
+sarcastic
+sash
+sashed
+sashes
+sat
+satchel
+satchel's
+satchels
+sate
+sated
+satellite
+satellite's
+satellites
+sates
+satin
+sating
+satire
+satire's
+satires
+satirist
+satirist's
+satirists
+satisfaction
+satisfaction's
+satisfactions
+satisfactorily
+satisfactoriness
+satisfactory
+satisfiability
+satisfiable
+satisfied
+satisfier
+satisfiers
+satisfies
+satisfy
+satisfying
+satisfyingly
+saturate
+saturated
+saturater
+saturates
+saturating
+saturation
+saturations
+satyr
+sauce
+saucepan
+saucepan's
+saucepans
+saucer
+saucers
+sauces
+saucier
+sauciness
+saucing
+saucy
+saunter
+sauntered
+saunterer
+sauntering
+saunters
+sausage
+sausage's
+sausages
+savage
+savaged
+savagely
+savageness
+savager
+savagers
+savages
+savaging
+save
+saved
+saver
+savers
+saves
+saving
+savings
+saw
+sawed
+sawer
+sawing
+sawmill
+sawmill's
+sawmills
+saws
+sawtooth
+say
+sayer
+sayers
+saying
+sayings
+says
+scabbard
+scabbard's
+scabbards
+scaffold
+scaffolding
+scaffoldings
+scaffolds
+scalable
+scalar
+scalar's
+scalars
+scald
+scalded
+scalding
+scalds
+scale
+scaled
+scaler
+scalers
+scales
+scalier
+scaliness
+scaling
+scalings
+scallop
+scalloped
+scalloper
+scalloping
+scallops
+scalp
+scalp's
+scalper
+scalping
+scalps
+scaly
+scam
+scam's
+scamper
+scampered
+scampering
+scampers
+scams
+scan
+scandal
+scandal's
+scandalous
+scandalously
+scandalousness
+scandals
+scanned
+scanner
+scanner's
+scanners
+scanning
+scans
+scant
+scantier
+scanties
+scantiest
+scantily
+scantiness
+scantly
+scantness
+scanty
+scar
+scar's
+scarce
+scarcely
+scarceness
+scarcer
+scarcest
+scarcity
+scare
+scared
+scarer
+scares
+scarf
+scarfs
+scarier
+scaring
+scarlet
+scars
+scary
+scatter
+scattered
+scatterer
+scattering
+scatteringly
+scatters
+scavenger
+scavenger's
+scavengers
+scenario
+scenario's
+scenarios
+scene
+scene's
+sceneries
+scenery
+scenes
+scenic
+scenics
+scent
+scented
+scents
+schedule
+schedule's
+scheduled
+scheduler
+scheduler's
+schedulers
+schedules
+scheduling
+schema
+schema's
+schemas
+schemata
+schematic
+schematically
+schematics
+scheme
+scheme's
+schemed
+schemer
+schemers
+schemes
+scheming
+schizophrenia
+scholar
+scholarly
+scholars
+scholarship
+scholarship's
+scholarships
+scholastic
+scholastically
+scholastics
+school
+schoolboy
+schoolboy's
+schoolboys
+schooled
+schooler
+schoolers
+schoolhouse
+schoolhouse's
+schoolhouses
+schooling
+schoolmaster
+schoolmaster's
+schoolmasters
+schoolroom
+schoolroom's
+schoolrooms
+schools
+schoolyard
+schoolyard's
+schoolyards
+schooner
+science
+science's
+sciences
+scientific
+scientifically
+scientist
+scientist's
+scientists
+scissor
+scissored
+scissoring
+scissors
+scoff
+scoffed
+scoffer
+scoffing
+scoffs
+scold
+scolded
+scolder
+scolding
+scolds
+scoop
+scooped
+scooper
+scooping
+scoops
+scope
+scoped
+scopes
+scoping
+scorch
+scorched
+scorcher
+scorches
+scorching
+scorchingly
+score
+score's
+scored
+scorer
+scorers
+scores
+scoring
+scorings
+scorn
+scorned
+scorner
+scornful
+scornfully
+scornfulness
+scorning
+scorns
+scorpion
+scorpion's
+scorpions
+scoundrel
+scoundrel's
+scoundrelly
+scoundrels
+scour
+scoured
+scourer
+scourge
+scourger
+scourging
+scouring
+scourings
+scours
+scout
+scouted
+scouter
+scouting
+scouts
+scow
+scowl
+scowled
+scowler
+scowling
+scowls
+scramble
+scrambled
+scrambler
+scrambles
+scrambling
+scrap
+scrap's
+scrape
+scraped
+scraper
+scrapers
+scrapes
+scraping
+scrapings
+scrapped
+scraps
+scratch
+scratched
+scratcher
+scratchers
+scratches
+scratching
+scrawl
+scrawled
+scrawler
+scrawling
+scrawls
+scream
+screamed
+screamer
+screamers
+screaming
+screamingly
+screams
+screech
+screeched
+screecher
+screeches
+screeching
+screen
+screened
+screener
+screening
+screenings
+screens
+screw
+screwed
+screwer
+screwing
+screws
+scribble
+scribbled
+scribbler
+scribbles
+scribbling
+scribe
+scriber
+scribes
+scribing
+script
+script's
+scripted
+scripting
+scripts
+scripture
+scriptures
+scroll
+scrolled
+scrolling
+scrolls
+scrooge
+scrooge's
+scrooges
+scrub
+scrubs
+scruple
+scrupled
+scruples
+scrupling
+scrupulous
+scrupulously
+scrupulousness
+scrutiny
+scuffle
+scuffled
+scuffles
+scuffling
+sculpt
+sculpted
+sculpting
+sculptor
+sculptor's
+sculptors
+sculpts
+sculpture
+sculptured
+sculptures
+sculpturing
+scum
+scum's
+scums
+scurried
+scurry
+scurrying
+scuttle
+scuttled
+scuttles
+scuttling
+scythe
+scythe's
+scythes
+scything
+sea
+seaboard
+seacoast
+seacoast's
+seacoasts
+seal
+sealed
+sealer
+sealing
+seals
+sealy
+seam
+seaman
+seamanly
+seamed
+seamen
+seamer
+seaming
+seams
+seaport
+seaport's
+seaports
+sear
+search
+searched
+searcher
+searcher's
+searchers
+searches
+searching
+searchingly
+searchings
+seared
+searing
+searingly
+sears
+seas
+seashore
+seashore's
+seashores
+seaside
+season
+season's
+seasonable
+seasonableness
+seasonably
+seasonal
+seasonally
+seasoned
+seasoner
+seasoners
+seasoning
+seasonings
+seasonly
+seasons
+seat
+seated
+seater
+seating
+seats
+seaward
+seawards
+seaweed
+seaweeds
+secede
+seceded
+seceder
+secedes
+seceding
+secluded
+secludedly
+secludedness
+seclusion
+second
+secondaries
+secondarily
+secondariness
+secondary
+seconded
+seconder
+seconders
+secondhand
+seconding
+secondly
+seconds
+secrecy
+secret
+secretarial
+secretaries
+secretary
+secretary's
+secrete
+secreted
+secretes
+secreting
+secretion
+secretions
+secretive
+secretively
+secretiveness
+secretly
+secrets
+sect
+sect's
+section
+sectional
+sectionally
+sectioned
+sectioning
+sections
+sector
+sector's
+sectored
+sectoring
+sectors
+sects
+secular
+secularly
+secure
+secured
+securely
+secureness
+securer
+secures
+securing
+securings
+securities
+security
+sedge
+sediment
+sediment's
+sediments
+seduce
+seduced
+seducer
+seducers
+seduces
+seducing
+seductive
+seductively
+seductiveness
+see
+seed
+seeded
+seeder
+seeders
+seeding
+seedings
+seedling
+seedling's
+seedlings
+seeds
+seeing
+seek
+seeker
+seekers
+seeking
+seekingly
+seeks
+seem
+seemed
+seeming
+seemingly
+seemlier
+seemliness
+seemly
+seems
+seen
+seep
+seeped
+seeping
+seeps
+seer
+seers
+sees
+seethe
+seethed
+seethes
+seething
+segment
+segmentation
+segmentation's
+segmentations
+segmented
+segmenting
+segments
+segregate
+segregated
+segregates
+segregating
+segregation
+segregative
+seismic
+seizable
+seize
+seized
+seizer
+seizers
+seizes
+seizin
+seizing
+seizings
+seizins
+seizor
+seizors
+seizure
+seizure's
+seizures
+seldom
+select
+selected
+selecting
+selection
+selection's
+selections
+selective
+selectively
+selectiveness
+selectivity
+selectness
+selector
+selector's
+selectors
+selects
+self
+selfish
+selfishly
+selfishness
+selfness
+selfsame
+selfsameness
+sell
+seller
+sellers
+selling
+sells
+selves
+semantic
+semantical
+semantically
+semanticist
+semanticist's
+semanticists
+semantics
+semaphore
+semaphore's
+semaphores
+semblance
+semester
+semester's
+semesters
+semiautomated
+semicolon
+semicolon's
+semicolons
+semiconductor
+semiconductor's
+semiconductors
+seminal
+seminally
+seminar
+seminar's
+seminaries
+seminars
+seminary
+seminary's
+semipermanent
+semipermanently
+senate
+senate's
+senates
+senator
+senator's
+senators
+send
+sender
+senders
+sending
+sends
+senior
+senior's
+seniority
+seniors
+sensation
+sensation's
+sensational
+sensationally
+sensations
+sense
+sensed
+senseless
+senselessly
+senselessness
+senses
+sensibilities
+sensibility
+sensible
+sensibleness
+sensibly
+sensing
+sensitive
+sensitively
+sensitiveness
+sensitives
+sensitivities
+sensitivity
+sensor
+sensor's
+sensors
+sensory
+sent
+sentence
+sentenced
+sentences
+sentencing
+sentential
+sententially
+sentiment
+sentiment's
+sentimental
+sentimentally
+sentiments
+sentinel
+sentinel's
+sentinels
+sentries
+sentry
+sentry's
+separable
+separableness
+separate
+separated
+separately
+separateness
+separates
+separating
+separation
+separations
+separative
+separator
+separator's
+separators
+sequel
+sequel's
+sequels
+sequence
+sequenced
+sequencer
+sequencers
+sequences
+sequencing
+sequencings
+sequential
+sequentiality
+sequentially
+sequester
+sequestered
+sequestering
+serendipitous
+serendipitously
+serendipity
+serene
+serenely
+sereneness
+serenity
+serf
+serf's
+serfs
+sergeant
+sergeant's
+sergeants
+serial
+serially
+serials
+series
+serious
+seriously
+seriousness
+sermon
+sermon's
+sermons
+serpent
+serpent's
+serpentine
+serpentinely
+serpents
+serum
+serum's
+serums
+servant
+servant's
+servants
+serve
+served
+server
+server's
+servers
+serves
+service
+serviceable
+serviceableness
+serviced
+servicer
+services
+servicing
+servile
+servilely
+servileness
+serving
+servings
+servitude
+session
+session's
+sessions
+set
+set's
+sets
+setter
+setter's
+setters
+setting
+settings
+settle
+settled
+settlement
+settlement's
+settlements
+settler
+settlers
+settles
+settling
+settlings
+setup
+setups
+seven
+sevens
+seventeen
+seventeens
+seventeenth
+seventh
+seventies
+seventieth
+seventy
+sever
+several
+severally
+severals
+severance
+severe
+severed
+severely
+severeness
+severer
+severest
+severing
+severities
+severity
+severity's
+severs
+sew
+sewed
+sewer
+sewers
+sewing
+sews
+sex
+sexed
+sexes
+sexism
+sexism's
+sexist
+sexist's
+sexists
+sexual
+sexuality
+sexually
+shabbier
+shabbiness
+shabby
+shack
+shacked
+shackle
+shackled
+shackler
+shackles
+shackling
+shacks
+shade
+shaded
+shader
+shades
+shadier
+shadiest
+shadily
+shadiness
+shading
+shadings
+shadow
+shadowed
+shadower
+shadowiness
+shadowing
+shadows
+shadowy
+shady
+shaft
+shaft's
+shafted
+shafting
+shafts
+shaggier
+shagginess
+shaggy
+shakable
+shakably
+shake
+shaken
+shaker
+shakers
+shakes
+shakier
+shakiness
+shaking
+shaky
+shale
+shales
+shall
+shallow
+shallower
+shallowly
+shallowness
+shallows
+sham
+sham's
+shambles
+shame
+shamed
+shameful
+shamefully
+shamefulness
+shameless
+shamelessly
+shamelessness
+shames
+shaming
+shams
+shan't
+shanties
+shanty
+shanty's
+shape
+shaped
+shapeless
+shapelessly
+shapelessness
+shapelier
+shapeliness
+shapely
+shaper
+shapers
+shapes
+shaping
+sharable
+share
+sharecropper
+sharecropper's
+sharecroppers
+shared
+shareholder
+shareholder's
+shareholders
+sharer
+sharers
+shares
+sharing
+shark
+shark's
+sharks
+sharp
+sharped
+sharpen
+sharpened
+sharpener
+sharpening
+sharpens
+sharper
+sharpest
+sharping
+sharply
+sharpness
+sharps
+shatter
+shattered
+shattering
+shatteringly
+shatters
+shave
+shaved
+shaven
+shaver
+shaves
+shaving
+shavings
+shawl
+shawl's
+shawls
+she
+she'd
+she'll
+she's
+sheaf
+shear
+sheared
+shearer
+shearers
+shearing
+shears
+sheath
+sheather
+sheathing
+sheaths
+sheaves
+shed
+sheds
+sheep
+sheer
+sheered
+sheerly
+sheerness
+sheet
+sheeted
+sheeter
+sheeting
+sheets
+shelf
+shelfs
+shell
+shell's
+shelled
+sheller
+shelling
+shells
+shelter
+sheltered
+shelterer
+sheltering
+shelters
+shelve
+shelved
+shelver
+shelves
+shelving
+shepherd
+shepherd's
+shepherded
+shepherding
+shepherds
+sheriff
+sheriff's
+sheriffs
+shied
+shield
+shielded
+shielder
+shielding
+shields
+shier
+shies
+shiest
+shift
+shifted
+shifter
+shifters
+shiftier
+shiftiest
+shiftily
+shiftiness
+shifting
+shifts
+shifty
+shilling
+shillings
+shimmer
+shimmered
+shimmering
+shin
+shine
+shined
+shiner
+shiners
+shines
+shingle
+shingle's
+shingled
+shingler
+shingles
+shingling
+shinier
+shininess
+shining
+shiningly
+shiny
+ship
+ship's
+shipboard
+shipboards
+shipbuilding
+shipment
+shipment's
+shipments
+shippable
+shipped
+shipper
+shipper's
+shippers
+shipping
+ships
+shipwreck
+shipwrecked
+shipwrecks
+shirk
+shirker
+shirking
+shirks
+shirt
+shirting
+shirts
+shit
+shiver
+shivered
+shiverer
+shivering
+shivers
+shoal
+shoal's
+shoals
+shock
+shocked
+shocker
+shockers
+shocking
+shockingly
+shocks
+shod
+shoe
+shoed
+shoeing
+shoemaker
+shoer
+shoes
+shone
+shook
+shoot
+shooter
+shooters
+shooting
+shootings
+shoots
+shop
+shop's
+shopkeeper
+shopkeeper's
+shopkeepers
+shopped
+shopper
+shopper's
+shoppers
+shopping
+shops
+shore
+shore's
+shored
+shores
+shoring
+shorn
+short
+shortage
+shortage's
+shortages
+shortcoming
+shortcoming's
+shortcomings
+shortcut
+shortcut's
+shortcuts
+shorted
+shorten
+shortened
+shortener
+shortening
+shortens
+shorter
+shortest
+shorthand
+shorthanded
+shorthands
+shorting
+shortly
+shortness
+shorts
+shot
+shot's
+shotgun
+shotgun's
+shotguns
+shots
+should
+shoulder
+shouldered
+shouldering
+shoulders
+shouldest
+shouldn't
+shout
+shouted
+shouter
+shouters
+shouting
+shouts
+shove
+shoved
+shovel
+shovels
+shover
+shoves
+shoving
+show
+showed
+shower
+showered
+showering
+showers
+showing
+showings
+shown
+shows
+shrank
+shred
+shred's
+shredder
+shredder's
+shredders
+shreds
+shrew
+shrew's
+shrewd
+shrewdest
+shrewdly
+shrewdness
+shrews
+shriek
+shrieked
+shrieking
+shrieks
+shrill
+shrilled
+shrilling
+shrillness
+shrilly
+shrimp
+shrine
+shrine's
+shrines
+shrink
+shrinkable
+shrinker
+shrinking
+shrinks
+shrivel
+shrivels
+shroud
+shrouded
+shrouding
+shrouds
+shrub
+shrub's
+shrubbery
+shrubs
+shrug
+shrugs
+shrunk
+shrunken
+shudder
+shuddered
+shuddering
+shudders
+shuffle
+shuffled
+shuffler
+shuffles
+shuffling
+shun
+shuns
+shut
+shutdown
+shutdown's
+shutdowns
+shuts
+shutter
+shuttered
+shuttering
+shutters
+shutting
+shuttle
+shuttled
+shuttles
+shuttling
+shy
+shying
+shyly
+shyness
+sibling
+sibling's
+siblings
+sick
+sicken
+sickened
+sickener
+sickening
+sickeningly
+sicker
+sickerly
+sickest
+sicking
+sickle
+sickled
+sicklied
+sickliness
+sickling
+sickly
+sicklying
+sickness
+sickness's
+sicknesses
+sicks
+side
+sideboard
+sideboard's
+sideboards
+sideburns
+sided
+sidedness
+sidelight
+sidelight's
+sidelights
+sides
+sidetrack
+sidetracked
+sidetracking
+sidetracks
+sidewalk
+sidewalk's
+sidewalks
+sideways
+sidewise
+siding
+sidings
+siege
+siege's
+sieges
+sieging
+sierra
+sierras
+sieve
+sieve's
+sievers
+sieves
+sieving
+sift
+sifted
+sifter
+sifting
+siftings
+sifts
+sigh
+sighed
+sigher
+sighing
+sighs
+sight
+sighted
+sighter
+sighting
+sightings
+sightliness
+sightly
+sights
+sign
+signal
+signally
+signals
+signature
+signature's
+signatures
+signed
+signer
+signers
+signet
+significance
+significances
+significant
+significantly
+significants
+signification
+signified
+signifier
+signifies
+signify
+signifying
+signing
+signs
+silence
+silenced
+silencer
+silencers
+silences
+silencing
+silent
+silently
+silentness
+silents
+silhouette
+silhouetted
+silhouettes
+silicon
+silicone
+silicons
+silk
+silken
+silkier
+silkiest
+silkily
+silkiness
+silks
+silky
+sill
+sill's
+sillier
+silliest
+silliness
+sills
+silly
+silt
+silted
+silting
+silts
+silver
+silvered
+silverer
+silveriness
+silvering
+silverly
+silvers
+silvery
+similar
+similarities
+similarity
+similarly
+similitude
+simmer
+simmered
+simmering
+simmers
+simple
+simpleness
+simpler
+simples
+simplest
+simplex
+simplexes
+simplicities
+simplicity
+simplicity's
+simplification
+simplifications
+simplified
+simplifier
+simplifiers
+simplifies
+simplify
+simplifying
+simplistic
+simply
+simulate
+simulated
+simulates
+simulating
+simulation
+simulations
+simulative
+simulator
+simulator's
+simulators
+simultaneity
+simultaneous
+simultaneously
+simultaneousness
+sin
+sin's
+since
+sincere
+sincerely
+sincereness
+sincerest
+sincerity
+sine
+sines
+sinew
+sinew's
+sinews
+sinful
+sinfully
+sinfulness
+sing
+singable
+singed
+singer
+singer's
+singers
+singing
+singingly
+single
+singled
+singleness
+singles
+singleton
+singleton's
+singletons
+singling
+singly
+sings
+singular
+singularities
+singularity
+singularity's
+singularly
+sining
+sinister
+sinisterly
+sinisterness
+sink
+sinked
+sinker
+sinkers
+sinkhole
+sinkholes
+sinking
+sinks
+sinned
+sinner
+sinner's
+sinners
+sinning
+sins
+sinusoidal
+sinusoidally
+sinusoids
+sip
+sips
+sir
+sire
+sired
+siren
+sirens
+sires
+siring
+sirs
+sirup
+sister
+sister's
+sistered
+sistering
+sisterly
+sisters
+sit
+site
+site's
+sited
+sites
+siting
+sits
+sitter
+sitter's
+sitters
+sitting
+sittings
+situate
+situated
+situates
+situating
+situation
+situational
+situationally
+situations
+six
+sixes
+sixpence
+sixpences
+sixteen
+sixteens
+sixteenth
+sixth
+sixthly
+sixties
+sixtieth
+sixty
+sizable
+sizableness
+size
+sized
+sizer
+sizers
+sizes
+sizing
+sizings
+skate
+skated
+skater
+skater's
+skaters
+skates
+skating
+skeletal
+skeletally
+skeleton
+skeleton's
+skeletons
+skeptic
+skeptic's
+skeptical
+skeptically
+skeptics
+sketch
+sketched
+sketcher
+sketches
+sketchier
+sketchily
+sketchiness
+sketching
+sketchy
+skew
+skewed
+skewer
+skewered
+skewering
+skewers
+skewing
+skewness
+skews
+ski
+skied
+skien
+skier
+skies
+skiing
+skill
+skilled
+skillful
+skillfully
+skillfulness
+skilling
+skills
+skim
+skim's
+skimmed
+skimmer
+skimmer's
+skimmers
+skimming
+skimmings
+skimp
+skimped
+skimping
+skimps
+skims
+skin
+skin's
+skinned
+skinner
+skinner's
+skinners
+skinning
+skins
+skip
+skipped
+skipper
+skipper's
+skippered
+skippering
+skippers
+skipping
+skips
+skirmish
+skirmished
+skirmisher
+skirmishers
+skirmishes
+skirmishing
+skirt
+skirted
+skirter
+skirting
+skirts
+skis
+skulk
+skulked
+skulker
+skulking
+skulks
+skull
+skull's
+skulled
+skulls
+skunk
+skunk's
+skunks
+sky
+sky's
+skying
+skylark
+skylarker
+skylarking
+skylarks
+skylight
+skylight's
+skylights
+skyscraper
+skyscraper's
+skyscrapers
+slab
+slabs
+slack
+slacked
+slacken
+slackened
+slackening
+slackens
+slacker
+slackest
+slacking
+slackly
+slackness
+slacks
+slain
+slam
+slammed
+slamming
+slams
+slander
+slandered
+slanderer
+slandering
+slanders
+slang
+slanging
+slant
+slanted
+slanting
+slantingly
+slants
+slap
+slapped
+slapping
+slaps
+slash
+slashed
+slasher
+slashes
+slashing
+slashingly
+slat
+slat's
+slate
+slated
+slater
+slaters
+slates
+slating
+slats
+slaughter
+slaughtered
+slaughterer
+slaughtering
+slaughters
+slave
+slaved
+slaver
+slavered
+slavering
+slavery
+slaves
+slaving
+slay
+slayer
+slayers
+slaying
+slays
+sled
+sled's
+sledge
+sledge's
+sledges
+sledging
+sleds
+sleek
+sleekly
+sleekness
+sleep
+sleeper
+sleepers
+sleepier
+sleepily
+sleepiness
+sleeping
+sleepless
+sleeplessly
+sleeplessness
+sleeps
+sleepy
+sleet
+sleeve
+sleeve's
+sleeved
+sleeves
+sleeving
+sleigh
+sleighs
+sleken
+slekened
+slekening
+slender
+slenderer
+slenderly
+slenderness
+slept
+slew
+slewed
+slewing
+slice
+sliced
+slicer
+slicers
+slices
+slicing
+slick
+slicker
+slickers
+slickly
+slickness
+slicks
+slid
+slide
+slider
+sliders
+slides
+sliding
+slier
+sliest
+slight
+slighted
+slighter
+slightest
+slighting
+slightingly
+slightly
+slightness
+slights
+slim
+slime
+slimed
+slimes
+slimier
+sliminess
+sliming
+slimly
+slimness
+slimy
+sling
+slinger
+slinging
+slings
+slip
+slip's
+slippage
+slipped
+slipper
+slipper's
+slipperier
+slipperiness
+slippers
+slippery
+slipping
+slips
+slit
+slit's
+slits
+slogan
+slogan's
+slogans
+slop
+slope
+sloped
+sloper
+slopers
+slopes
+sloping
+slopped
+sloppier
+sloppiness
+slopping
+sloppy
+slops
+slot
+slot's
+sloth
+sloths
+slots
+slotted
+slouch
+slouched
+sloucher
+slouches
+slouching
+slow
+slowed
+slower
+slowest
+slowing
+slowly
+slowness
+slows
+slug
+sluggish
+sluggishly
+sluggishness
+slugs
+slum
+slum's
+slumber
+slumber's
+slumbered
+slumberer
+slumbering
+slumbers
+slump
+slumped
+slumps
+slums
+slung
+slur
+slur's
+slurs
+sly
+slyly
+smack
+smacked
+smacker
+smacking
+smacks
+small
+smaller
+smallest
+smallness
+smallpox
+smart
+smarted
+smarten
+smartened
+smartening
+smarter
+smartest
+smarting
+smartly
+smartness
+smarts
+smash
+smashed
+smasher
+smashers
+smashes
+smashing
+smashingly
+smear
+smeared
+smearer
+smearing
+smears
+smell
+smelled
+smeller
+smellier
+smelling
+smells
+smelly
+smelt
+smelter
+smelts
+smile
+smiled
+smiler
+smiles
+smiling
+smilingly
+smite
+smiter
+smith
+smith's
+smithies
+smiths
+smithy
+smiting
+smitten
+smock
+smocking
+smocks
+smog
+smokable
+smoke
+smoked
+smoker
+smoker's
+smokers
+smokes
+smokier
+smokies
+smokiness
+smoking
+smoky
+smolder
+smoldered
+smoldering
+smolderingly
+smolders
+smooth
+smoothed
+smoothen
+smoothened
+smoothening
+smoother
+smoothers
+smoothes
+smoothest
+smoothing
+smoothly
+smoothness
+smote
+smother
+smothered
+smothering
+smothers
+smug
+smuggle
+smuggled
+smuggler
+smugglers
+smuggles
+smuggling
+smugly
+smugness
+snail
+snail's
+snails
+snake
+snaked
+snakes
+snaking
+snap
+snapped
+snapper
+snapper's
+snappers
+snappier
+snappiest
+snappily
+snappiness
+snapping
+snappy
+snaps
+snapshot
+snapshot's
+snapshots
+snare
+snared
+snarer
+snares
+snarf
+snarfed
+snarfing
+snarfings
+snarfs
+snaring
+snarl
+snarled
+snarler
+snarling
+snarls
+snatch
+snatched
+snatcher
+snatches
+snatching
+sneak
+sneaked
+sneaker
+sneakered
+sneakers
+sneakier
+sneakiest
+sneakily
+sneakiness
+sneaking
+sneakingly
+sneaks
+sneaky
+sneer
+sneered
+sneerer
+sneering
+sneers
+sneeze
+sneezed
+sneezer
+sneezes
+sneezing
+sniff
+sniffed
+sniffer
+sniffing
+sniffs
+snoop
+snooped
+snooper
+snooping
+snoops
+snore
+snored
+snorer
+snores
+snoring
+snort
+snorted
+snorter
+snorting
+snorts
+snout
+snout's
+snouted
+snouts
+snow
+snowed
+snowier
+snowiest
+snowily
+snowiness
+snowing
+snowman
+snowmen
+snows
+snowshoe
+snowshoe's
+snowshoed
+snowshoer
+snowshoes
+snowy
+snuff
+snuffed
+snuffer
+snuffing
+snuffs
+snug
+snuggle
+snuggled
+snuggles
+snuggling
+snugly
+snugness
+snugs
+so
+soak
+soaked
+soaker
+soaking
+soaks
+soap
+soaped
+soaping
+soaps
+soar
+soared
+soarer
+soaring
+soars
+sob
+sober
+sobered
+soberer
+soberest
+sobering
+soberly
+soberness
+sobers
+sobs
+soccer
+sociability
+sociable
+sociably
+social
+socialism
+socialist
+socialist's
+socialists
+socially
+societal
+societally
+societies
+society
+society's
+sociological
+sociologically
+sociology
+sock
+socked
+socket
+socket's
+sockets
+socking
+socks
+sod
+sod's
+soda
+sodium
+sodomy
+sods
+sofa
+sofa's
+sofas
+soft
+soften
+softened
+softener
+softening
+softens
+softer
+softest
+softly
+softness
+software
+software's
+softwares
+soil
+soiled
+soiling
+soils
+sojourn
+sojourner
+sojourners
+solace
+solaced
+solacer
+solacing
+solar
+sold
+solder
+soldered
+solderer
+soldering
+solders
+soldier
+soldiered
+soldiering
+soldierly
+soldiers
+sole
+soled
+solely
+solemn
+solemnity
+solemnly
+solemnness
+soleness
+soles
+solicit
+solicited
+soliciting
+solicitor
+solicitors
+solicits
+solid
+solidification
+solidified
+solidifies
+solidify
+solidifying
+solidity
+solidly
+solidness
+solids
+soling
+solingen
+solitaire
+solitariness
+solitary
+solitude
+solitude's
+solitudes
+solo
+solo's
+soloed
+soloing
+solos
+solubility
+soluble
+solution
+solution's
+solutions
+solvable
+solve
+solved
+solvent
+solvent's
+solvently
+solvents
+solver
+solvers
+solves
+solving
+somber
+somberly
+somberness
+some
+somebody
+somebody's
+someday
+somehow
+someone
+someone's
+someplace
+someplace's
+somers
+something
+sometime
+sometimes
+somewhat
+somewhere
+somewheres
+son
+son's
+sonar
+sonars
+song
+song's
+songs
+sonly
+sonnet
+sonnet's
+sonnets
+sons
+soon
+sooner
+soonest
+soot
+sooth
+soothe
+soothed
+soother
+soothes
+soothing
+soothingly
+soothingness
+soothly
+sophisticated
+sophisticatedly
+sophistication
+sophomore
+sophomore's
+sophomores
+sorcerer
+sorcerer's
+sorcerers
+sorcery
+sordid
+sordidly
+sordidness
+sore
+sorely
+soreness
+sorer
+sores
+sorest
+sorrier
+sorriest
+sorriness
+sorrow
+sorrow's
+sorrower
+sorrowful
+sorrowfully
+sorrowfulness
+sorrows
+sorry
+sort
+sorted
+sorter
+sorters
+sorting
+sorts
+sos
+sought
+soul
+soul's
+souled
+souls
+sound
+sounded
+sounder
+soundest
+sounding
+sounding's
+soundingly
+soundings
+soundly
+soundness
+sounds
+soup
+soup's
+soups
+sour
+source
+source's
+sources
+soured
+sourer
+sourest
+souring
+sourly
+sourness
+sours
+south
+souther
+southerly
+southern
+southerner
+southerners
+southernly
+southernness
+southing
+sovereign
+sovereign's
+sovereignly
+sovereigns
+soviet
+soviet's
+soviets
+space
+spaced
+spacer
+spacers
+spaces
+spaceship
+spaceship's
+spaceships
+spacing
+spacings
+spade
+spaded
+spader
+spades
+spading
+spaghetti
+span
+span's
+spank
+spanked
+spanker
+spanking
+spanks
+spanned
+spanner
+spanner's
+spanners
+spanning
+spans
+spare
+spared
+sparely
+spareness
+sparer
+spares
+sparest
+sparing
+sparingly
+spark
+sparked
+sparker
+sparking
+sparks
+sparrow
+sparrow's
+sparrows
+sparse
+sparsely
+sparseness
+sparser
+sparsest
+spat
+spate
+spate's
+spates
+spatial
+spatially
+spats
+spatter
+spattered
+spawn
+spawned
+spawner
+spawning
+spawns
+speak
+speakable
+speaker
+speaker's
+speakers
+speaking
+speaks
+spear
+speared
+spearer
+spearing
+spears
+special
+specialist
+specialist's
+specialists
+specially
+specialness
+specials
+species
+specifiable
+specific
+specifically
+specification
+specifications
+specificities
+specificity
+specifics
+specified
+specifier
+specifiers
+specifies
+specify
+specifying
+specimen
+specimen's
+specimens
+speck
+speck's
+speckle
+speckled
+speckles
+speckling
+specks
+spectacle
+spectacled
+spectacles
+spectacular
+spectacularly
+spectator
+spectator's
+spectators
+spectra
+spectrogram
+spectrogram's
+spectrograms
+spectroscopically
+spectrum
+spectrums
+speculate
+speculated
+speculates
+speculating
+speculation
+speculations
+speculative
+speculatively
+speculator
+speculator's
+speculators
+sped
+speech
+speech's
+speeches
+speechless
+speechlessly
+speechlessness
+speed
+speeded
+speeder
+speeders
+speedier
+speedily
+speediness
+speeding
+speeds
+speedup
+speedup's
+speedups
+speedy
+spell
+spelled
+speller
+spellers
+spelling
+spellings
+spells
+spend
+spender
+spenders
+spending
+spends
+spent
+sphere
+sphere's
+spheres
+spherical
+spherically
+sphering
+spice
+spiced
+spices
+spicier
+spiciness
+spicing
+spicy
+spider
+spider's
+spiders
+spied
+spier
+spies
+spike
+spiked
+spiker
+spikes
+spiking
+spill
+spilled
+spiller
+spilling
+spills
+spin
+spinach
+spinal
+spinally
+spindle
+spindled
+spindler
+spindles
+spindling
+spine
+spines
+spinner
+spinner's
+spinners
+spinning
+spins
+spiral
+spirally
+spirals
+spire
+spire's
+spired
+spires
+spiring
+spirit
+spirited
+spiritedly
+spiritedness
+spiriting
+spirits
+spiritual
+spiritually
+spiritualness
+spirituals
+spit
+spite
+spited
+spiteful
+spitefully
+spitefulness
+spites
+spiting
+spits
+spitting
+splash
+splashed
+splasher
+splashers
+splashes
+splashing
+spleen
+splendid
+splendidly
+splendidness
+splice
+spliced
+splicer
+splicers
+splices
+splicing
+splicings
+spline
+spline's
+splined
+splines
+splinter
+splintered
+splintering
+splinters
+split
+split's
+splits
+splitter
+splitter's
+splitters
+splitting
+splittings
+spoil
+spoiled
+spoiler
+spoilers
+spoiling
+spoils
+spoke
+spoked
+spoken
+spokes
+spokesman
+spokesmen
+spoking
+sponge
+sponged
+sponger
+spongers
+sponges
+sponging
+sponsor
+sponsored
+sponsoring
+sponsors
+sponsorship
+spontaneous
+spontaneously
+spontaneousness
+spook
+spookier
+spookiness
+spooky
+spool
+spooled
+spooler
+spoolers
+spooling
+spools
+spoon
+spooned
+spooning
+spoons
+spore
+spore's
+spored
+spores
+sporing
+sport
+sported
+sporting
+sportingly
+sportive
+sportively
+sportiveness
+sports
+sportsman
+sportsmanly
+spot
+spot's
+spotless
+spotlessly
+spotlessness
+spotlight
+spotlight's
+spotlighted
+spotlighting
+spotlights
+spots
+spotted
+spotter
+spotter's
+spotters
+spotting
+spouse
+spouse's
+spouses
+spousing
+spout
+spouted
+spouter
+spouting
+spouts
+sprang
+sprawl
+sprawled
+sprawling
+sprawls
+spray
+sprayed
+sprayer
+spraying
+sprays
+spread
+spreader
+spreaders
+spreading
+spreadings
+spreads
+spreadsheet
+spreadsheets
+spree
+spree's
+sprees
+sprig
+sprightlier
+sprightliness
+sprightly
+spring
+springer
+springers
+springier
+springiest
+springiness
+springing
+springs
+springtime
+springy
+sprinkle
+sprinkled
+sprinkler
+sprinklered
+sprinkles
+sprinkling
+sprint
+sprinted
+sprinter
+sprinters
+sprinting
+sprints
+sprite
+sprout
+sprouted
+sprouting
+sprouts
+spruce
+spruced
+sprucely
+spruceness
+sprucer
+sprucest
+sprucing
+sprung
+spun
+spur
+spur's
+spurious
+spuriously
+spuriousness
+spurn
+spurned
+spurner
+spurning
+spurns
+spurs
+spurt
+spurted
+spurting
+spurts
+sputter
+sputtered
+sputterer
+spy
+spying
+squabble
+squabbled
+squabbler
+squabbles
+squabbling
+squad
+squad's
+squadron
+squadron's
+squadrons
+squads
+squall
+squall's
+squaller
+squalls
+square
+squared
+squarely
+squareness
+squarer
+squares
+squarest
+squaring
+squash
+squashed
+squasher
+squashes
+squashing
+squat
+squatly
+squatness
+squats
+squawk
+squawked
+squawker
+squawking
+squawks
+squeak
+squeaked
+squeaker
+squeaking
+squeaks
+squeal
+squealed
+squealer
+squealing
+squeals
+squeeze
+squeezed
+squeezer
+squeezes
+squeezing
+squid
+squids
+squint
+squinted
+squinter
+squinting
+squintingly
+squints
+squire
+squire's
+squires
+squiring
+squirm
+squirmed
+squirming
+squirms
+squirrel
+squirrelly
+squirrels
+stab
+stabbed
+stabbing
+stabilities
+stability
+stability's
+stable
+stabled
+stableness
+stabler
+stables
+stablest
+stabling
+stably
+stabs
+stack
+stack's
+stacked
+stacker
+stacking
+stacks
+staff
+staff's
+staffed
+staffer
+staffers
+staffing
+staffs
+stag
+stag's
+stage
+stagecoach
+staged
+stager
+stagers
+stages
+stagger
+staggered
+staggerer
+staggering
+staggeringly
+staggers
+staging
+stagnant
+stagnantly
+stags
+staid
+staidly
+staidness
+stain
+stained
+stainer
+staining
+stainless
+stainlessly
+stains
+stair
+stair's
+staircase
+staircase's
+staircases
+stairs
+stairway
+stairway's
+stairways
+stake
+staked
+stakes
+staking
+stale
+staled
+stalely
+staleness
+staler
+stales
+stalest
+staling
+stalk
+stalked
+stalker
+stalking
+stalks
+stall
+stalled
+stalling
+stallings
+stalls
+stalwart
+stalwartly
+stalwartness
+stamen
+stamen's
+stamens
+stamina
+stammer
+stammered
+stammerer
+stammering
+stammers
+stamp
+stamped
+stampede
+stampeded
+stampeder
+stampedes
+stampeding
+stamper
+stampers
+stamping
+stamps
+stance
+stance's
+stances
+stanch
+stancher
+stanchest
+stand
+standard
+standardly
+standards
+standby
+stander
+standing
+standings
+standpoint
+standpoint's
+standpoints
+stands
+standstill
+stanza
+stanza's
+stanzas
+staple
+stapled
+stapler
+staplers
+staples
+stapling
+star
+star's
+starboard
+starboarded
+starboarding
+starboards
+starch
+starched
+starches
+starching
+stare
+stared
+starer
+stares
+starfish
+staring
+stark
+starkest
+starkly
+starkness
+starlet
+starlet's
+starlets
+starlight
+starred
+starrier
+starring
+starry
+stars
+start
+started
+starter
+starters
+starting
+startle
+startled
+startles
+startling
+startlingly
+startlingness
+starts
+startup
+startup's
+startups
+starvation
+starve
+starved
+starver
+starves
+starving
+state
+state's
+stated
+statelier
+stateliness
+stately
+statement
+statement's
+statements
+stater
+states
+statesman
+statesman's
+statesmanly
+static
+statically
+statics
+stating
+station
+stationaries
+stationary
+stationed
+stationer
+stationing
+stations
+statistic
+statistic's
+statistical
+statistically
+statistician
+statistician's
+statisticians
+statistics
+stative
+statue
+statue's
+statued
+statues
+statuesque
+statuesquely
+statuesqueness
+stature
+status
+statuses
+statute
+statute's
+statutes
+statutorily
+statutoriness
+statutory
+staunch
+staunchest
+staunchly
+staunchness
+stave
+staved
+staves
+staving
+stay
+stayed
+stayer
+stayers
+staying
+stays
+stdio
+stead
+steadfast
+steadfastly
+steadfastness
+steadied
+steadier
+steadies
+steadiest
+steadily
+steadiness
+steading
+steady
+steadying
+steak
+steak's
+steaks
+steal
+stealer
+stealing
+steals
+stealth
+stealthier
+stealthily
+stealthiness
+stealthy
+steam
+steamboat
+steamboat's
+steamboats
+steamed
+steamer
+steamers
+steaming
+steams
+steamship
+steamship's
+steamships
+steed
+steeds
+steel
+steeled
+steelers
+steeling
+steels
+steep
+steeped
+steepen
+steepened
+steepening
+steeper
+steepest
+steeping
+steeple
+steeple's
+steeples
+steeply
+steepness
+steeps
+steer
+steered
+steerer
+steering
+steers
+stellar
+stem
+stem's
+stemmed
+stemming
+stems
+stench
+stench's
+stenches
+stencil
+stencil's
+stencils
+stenographer
+stenographer's
+stenographers
+step
+step's
+stepmother
+stepmother's
+stepmothers
+stepped
+stepper
+stepping
+steps
+stepwise
+stereo
+stereo's
+stereos
+stereotype
+stereotyped
+stereotyper
+stereotypers
+stereotypes
+stereotypical
+stereotypically
+stereotyping
+sterile
+sterling
+sterlingly
+sterlingness
+stern
+sternly
+sternness
+sterns
+stew
+steward
+steward's
+stewards
+stewed
+stewing
+stews
+stick
+sticked
+sticker
+stickers
+stickier
+stickiest
+stickily
+stickiness
+sticking
+sticks
+sticky
+stiff
+stiffen
+stiffened
+stiffener
+stiffeners
+stiffening
+stiffens
+stiffer
+stiffest
+stiffly
+stiffness
+stiffnesses
+stiffs
+stifle
+stifled
+stifler
+stifles
+stifling
+stiflingly
+stigma
+stigmas
+stile
+stile's
+stiles
+still
+stilled
+stiller
+stillest
+stilling
+stillness
+stills
+stimulant
+stimulant's
+stimulants
+stimulate
+stimulated
+stimulates
+stimulating
+stimulation
+stimulations
+stimulative
+stimuli
+stimulus
+sting
+stinger
+stinging
+stingingly
+stings
+stink
+stinker
+stinkers
+stinking
+stinkingly
+stinks
+stint
+stint's
+stinted
+stinter
+stinting
+stints
+stipend
+stipend's
+stipends
+stipple
+stippled
+stippler
+stipples
+stippling
+stipulate
+stipulated
+stipulates
+stipulating
+stipulation
+stipulations
+stir
+stirred
+stirrer
+stirrer's
+stirrers
+stirring
+stirringly
+stirrings
+stirrup
+stirrups
+stirs
+stitch
+stitched
+stitcher
+stitches
+stitching
+stochastic
+stochastically
+stock
+stockade
+stockade's
+stockaded
+stockades
+stockading
+stocked
+stocker
+stockers
+stockholder
+stockholder's
+stockholders
+stocking
+stockinged
+stockings
+stocks
+stole
+stole's
+stoled
+stolen
+stoles
+stomach
+stomached
+stomacher
+stomaches
+stomaching
+stone
+stone's
+stoned
+stoner
+stones
+stonier
+stoniness
+stoning
+stony
+stood
+stool
+stools
+stoop
+stooped
+stooping
+stoops
+stop
+stop's
+stopcock
+stopcocks
+stopgap
+stopgap's
+stopgaps
+stoppable
+stoppage
+stoppages
+stopped
+stopper
+stopper's
+stoppered
+stoppering
+stoppers
+stopping
+stops
+storage
+storage's
+storages
+store
+stored
+storehouse
+storehouse's
+storehouses
+stores
+storied
+stories
+storing
+stork
+stork's
+storks
+storm
+stormed
+stormier
+stormiest
+storminess
+storming
+storms
+stormy
+story
+story's
+storying
+stout
+stouten
+stoutened
+stoutening
+stouter
+stoutest
+stoutly
+stoutness
+stove
+stove's
+stover
+stoves
+stow
+stowed
+stowing
+stows
+straggle
+straggled
+straggler
+stragglers
+straggles
+straggling
+straight
+straighten
+straightened
+straightener
+straighteners
+straightening
+straightens
+straighter
+straightest
+straightforward
+straightforwardly
+straightforwardness
+straightforwards
+straightly
+straightness
+straightway
+strain
+strained
+strainer
+strainers
+straining
+strains
+strait
+straiten
+straitened
+straitening
+straitly
+straitness
+straits
+strand
+stranded
+strandedness
+strander
+stranding
+strands
+strange
+strangely
+strangeness
+stranger
+stranger's
+strangers
+strangest
+strangle
+strangled
+strangler
+stranglers
+strangles
+strangling
+stranglings
+strangulation
+strangulation's
+strangulations
+strap
+strap's
+straps
+stratagem
+stratagem's
+stratagems
+strategic
+strategics
+strategies
+strategy
+strategy's
+stratification
+stratifications
+stratified
+stratifies
+stratify
+stratifying
+stratum
+straw
+straw's
+strawberries
+strawberry
+strawberry's
+straws
+stray
+stray's
+strayed
+strayer
+straying
+strays
+streak
+streaked
+streaking
+streaks
+stream
+streamed
+streamer
+streamers
+streaming
+streamline
+streamlined
+streamliner
+streamlines
+streamlining
+streams
+street
+streetcar
+streetcar's
+streetcars
+streeters
+streets
+strength
+strengthen
+strengthened
+strengthener
+strengthening
+strengthens
+strengths
+strenuous
+strenuously
+strenuousness
+stress
+stressed
+stresses
+stressing
+stretch
+stretched
+stretcher
+stretchers
+stretches
+stretching
+strew
+strewing
+strewn
+strews
+strewth
+stricken
+strict
+stricter
+strictest
+strictly
+strictness
+stride
+strider
+strides
+striding
+strife
+strike
+striker
+strikers
+strikes
+striking
+strikingly
+string
+string's
+stringed
+stringent
+stringently
+stringer
+stringers
+stringier
+stringiest
+stringiness
+stringing
+strings
+stringy
+strip
+strip's
+stripe
+striped
+striper
+stripes
+striping
+stripped
+stripper
+stripper's
+strippers
+stripping
+strips
+strive
+striver
+strives
+striving
+strivings
+strobe
+strobe's
+strobed
+strobes
+strobing
+stroboscopic
+strode
+stroke
+stroked
+stroker
+strokers
+strokes
+stroking
+stroll
+strolled
+stroller
+strolling
+strolls
+strong
+stronger
+strongest
+stronghold
+strongly
+strove
+struck
+structural
+structurally
+structure
+structured
+structurer
+structures
+structuring
+struggle
+struggled
+struggler
+struggles
+struggling
+strung
+strut
+struts
+strutted
+strutter
+strutting
+stub
+stub's
+stubbed
+stubbing
+stubble
+stubborn
+stubbornly
+stubbornness
+stubs
+stuck
+stud
+stud's
+student
+student's
+students
+studied
+studiedly
+studiedness
+studier
+studies
+studio
+studio's
+studios
+studious
+studiously
+studiousness
+studs
+study
+studying
+stuff
+stuffed
+stuffer
+stuffier
+stuffiest
+stuffiness
+stuffing
+stuffings
+stuffs
+stuffy
+stumble
+stumbled
+stumbler
+stumbles
+stumbling
+stumblingly
+stump
+stumped
+stumper
+stumping
+stumps
+stun
+stung
+stunning
+stunningly
+stuns
+stunt
+stunt's
+stunted
+stuntedness
+stunting
+stunts
+stupefy
+stupefying
+stupendous
+stupendously
+stupendousness
+stupid
+stupider
+stupidest
+stupidities
+stupidity
+stupidly
+stupidness
+stupor
+sturdier
+sturdiness
+sturdy
+style
+styled
+styler
+stylers
+styles
+styling
+stylish
+stylishly
+stylishness
+stylistic
+stylistically
+stylistics
+sub
+subatomic
+subclass
+subclass's
+subclasses
+subcommittee
+subcommittee's
+subcommittees
+subcomponent
+subcomponent's
+subcomponents
+subcomputation
+subcomputation's
+subcomputations
+subconscious
+subconsciously
+subconsciousness
+subculture
+subculture's
+subcultures
+subdivide
+subdivided
+subdivider
+subdivides
+subdividing
+subdivision
+subdivision's
+subdivisions
+subdue
+subdued
+subduedly
+subduer
+subdues
+subduing
+subexpression
+subexpression's
+subexpressions
+subfield
+subfield's
+subfields
+subfile
+subfile's
+subfiles
+subgoal
+subgoal's
+subgoals
+subgraph
+subgraphs
+subgroup
+subgroup's
+subgrouping
+subgroups
+subinterval
+subinterval's
+subintervals
+subject
+subject's
+subjected
+subjecting
+subjection
+subjective
+subjectively
+subjectiveness
+subjectivity
+subjects
+sublimation
+sublimations
+sublime
+sublimed
+sublimely
+sublimeness
+sublimer
+subliming
+sublist
+sublist's
+sublists
+submarine
+submarined
+submariner
+submariners
+submarines
+submarining
+submerge
+submerged
+submerges
+submerging
+submission
+submission's
+submissions
+submit
+submits
+submitted
+submitting
+submode
+submodes
+submodule
+submodule's
+submodules
+subnetwork
+subnetwork's
+subnetworks
+subordinate
+subordinated
+subordinately
+subordinateness
+subordinates
+subordinating
+subordination
+subordinative
+subproblem
+subproblem's
+subproblems
+subprocess
+subprocess's
+subprocesses
+subprogram
+subprogram's
+subprograms
+subproject
+subproof
+subproof's
+subproofs
+subrange
+subrange's
+subranges
+subroutine
+subroutine's
+subroutines
+subs
+subschema
+subschema's
+subschemas
+subscribe
+subscribed
+subscriber
+subscribers
+subscribes
+subscribing
+subscript
+subscripted
+subscripting
+subscription
+subscription's
+subscriptions
+subscripts
+subsection
+subsection's
+subsections
+subsegment
+subsegment's
+subsegments
+subsequence
+subsequence's
+subsequences
+subsequent
+subsequently
+subsequentness
+subset
+subset's
+subsets
+subside
+subsided
+subsides
+subsidiaries
+subsidiary
+subsidiary's
+subsidies
+subsiding
+subsidy
+subsidy's
+subsist
+subsisted
+subsistence
+subsisting
+subsists
+subspace
+subspace's
+subspaces
+substance
+substance's
+substances
+substantial
+substantially
+substantialness
+substantiate
+substantiated
+substantiates
+substantiating
+substantiation
+substantiations
+substantiative
+substantive
+substantively
+substantiveness
+substantivity
+substitutability
+substitutable
+substitute
+substituted
+substituter
+substitutes
+substituting
+substitution
+substitutions
+substitutive
+substitutively
+substrate
+substrate's
+substrates
+substring
+substrings
+substructure
+substructure's
+substructures
+subsume
+subsumed
+subsumes
+subsuming
+subsystem
+subsystem's
+subsystems
+subtask
+subtask's
+subtasks
+subterranean
+subterraneanly
+subtitle
+subtitle's
+subtitled
+subtitles
+subtitling
+subtle
+subtleness
+subtler
+subtlest
+subtleties
+subtlety
+subtly
+subtopic
+subtopic's
+subtopics
+subtract
+subtracted
+subtracter
+subtracter's
+subtracters
+subtracting
+subtraction
+subtractions
+subtractive
+subtracts
+subtrahend
+subtrahend's
+subtrahends
+subtree
+subtree's
+subtrees
+subunit
+subunit's
+subunits
+suburb
+suburb's
+suburban
+suburbs
+subversion
+subvert
+subverted
+subverter
+subverting
+subverts
+subway
+subway's
+subways
+succeed
+succeeded
+succeeder
+succeeding
+succeeds
+success
+successes
+successful
+successfully
+successfulness
+succession
+succession's
+successions
+successive
+successively
+successiveness
+successor
+successor's
+successors
+succinct
+succinctly
+succinctness
+succumb
+succumbed
+succumbing
+succumbs
+such
+suck
+sucked
+sucker
+suckered
+suckering
+suckers
+sucking
+suckle
+suckled
+suckles
+suckling
+sucks
+suction
+sudden
+suddenly
+suddenness
+suds
+sudser
+sudsing
+sue
+sued
+sueded
+sueding
+suer
+sues
+suffer
+sufferance
+suffered
+sufferer
+sufferers
+suffering
+sufferings
+suffers
+suffice
+sufficed
+sufficer
+suffices
+sufficiency
+sufficient
+sufficiently
+sufficing
+suffix
+suffixed
+suffixer
+suffixes
+suffixing
+suffocate
+suffocated
+suffocates
+suffocating
+suffocatingly
+suffocation
+suffocative
+suffrage
+sugar
+sugared
+sugaring
+sugarings
+sugars
+suggest
+suggested
+suggester
+suggestible
+suggesting
+suggestion
+suggestion's
+suggestions
+suggestive
+suggestively
+suggestiveness
+suggests
+suicidal
+suicidally
+suicide
+suicide's
+suicided
+suicides
+suiciding
+suing
+suit
+suit's
+suitability
+suitable
+suitableness
+suitably
+suitcase
+suitcase's
+suitcases
+suite
+suited
+suiters
+suites
+suiting
+suitor
+suitor's
+suitors
+suits
+sulk
+sulked
+sulkies
+sulkiness
+sulking
+sulks
+sulky
+sullen
+sullenly
+sullenness
+sulphate
+sulphates
+sulphur
+sulphured
+sulphuric
+sultan
+sultan's
+sultans
+sultrier
+sultriness
+sultry
+sum
+sum's
+sumer
+summand
+summand's
+summands
+summaries
+summary
+summary's
+summation
+summation's
+summations
+summed
+summer
+summer's
+summered
+summering
+summers
+summing
+summit
+summon
+summoned
+summoner
+summoners
+summoning
+summons
+summonses
+sumptuous
+sumptuously
+sumptuousness
+sums
+sun
+sun's
+sunbeam
+sunbeam's
+sunbeams
+sunburn
+sundown
+sundowner
+sundowners
+sundries
+sundry
+sung
+sunglass
+sunglasses
+sunk
+sunken
+sunlight
+sunlights
+sunned
+sunnier
+sunniness
+sunning
+sunny
+sunrise
+sunrises
+suns
+sunset
+sunsets
+sunshine
+sunshines
+sup
+super
+superb
+superbly
+superbness
+superclass
+superclass's
+supercomputer
+supercomputer's
+supercomputers
+supered
+superego
+superego's
+superegos
+superficial
+superficially
+superficialness
+superfluities
+superfluity
+superfluity's
+superfluous
+superfluously
+superfluousness
+superhuman
+superhumanly
+superhumanness
+superimpose
+superimposed
+superimposes
+superimposing
+supering
+superintend
+superintendent
+superintendent's
+superintendents
+superior
+superior's
+superiority
+superiorly
+superiors
+superlative
+superlatively
+superlativeness
+superlatives
+supermarket
+supermarket's
+supermarkets
+superpose
+superposed
+superposes
+superposing
+superscript
+superscripted
+superscripting
+superscripts
+supersede
+superseded
+superseder
+supersedes
+superseding
+superset
+superset's
+supersets
+superstition
+superstition's
+superstitions
+superstitious
+superstitiously
+superstitiousness
+supertitle
+supertitle's
+supertitled
+supertitles
+supertitling
+superuser
+superuser's
+superusers
+supervise
+supervised
+supervises
+supervising
+supervision
+supervisions
+supervisor
+supervisor's
+supervisors
+supervisory
+supper
+supper's
+suppers
+supplant
+supplanted
+supplanter
+supplanting
+supplants
+supple
+suppled
+supplely
+supplement
+supplemental
+supplementaries
+supplementary
+supplemented
+supplementer
+supplementing
+supplements
+suppleness
+suppler
+supplication
+supplied
+supplier
+supplier's
+suppliers
+supplies
+suppling
+supply
+supply's
+supplying
+support
+supportable
+supported
+supporter
+supporters
+supporting
+supportingly
+supportive
+supportively
+supports
+suppose
+supposed
+supposedly
+supposer
+supposes
+supposing
+supposition
+supposition's
+suppositions
+suppress
+suppressed
+suppresses
+suppressing
+suppression
+suppressions
+suppressive
+suppressiveness
+supremacy
+supreme
+supremely
+supremeness
+sure
+sured
+surely
+sureness
+surer
+surest
+sureties
+surety
+surf
+surface
+surfaced
+surfaceness
+surfacer
+surfacers
+surfaces
+surfacing
+surfer
+surfer's
+surfers
+surfing
+surge
+surged
+surgely
+surgeon
+surgeon's
+surgeons
+surgeries
+surgery
+surges
+surgical
+surgically
+surging
+surlier
+surliness
+surly
+surmise
+surmised
+surmiser
+surmises
+surmising
+surmount
+surmounted
+surmounting
+surmounts
+surname
+surname's
+surnamed
+surnames
+surpass
+surpassed
+surpasses
+surpassing
+surpassingly
+surplus
+surplus's
+surpluses
+surprise
+surprise's
+surprised
+surpriser
+surprises
+surprising
+surprisingly
+surrender
+surrendered
+surrenderer
+surrendering
+surrenders
+surrogate
+surrogate's
+surrogates
+surrogation
+surround
+surrounded
+surrounding
+surroundings
+surrounds
+survey
+surveyed
+surveying
+surveyor
+surveyor's
+surveyors
+surveys
+survival
+survivals
+survive
+survived
+surviver
+survives
+surviving
+survivor
+survivor's
+survivors
+susceptible
+suspect
+suspected
+suspecter
+suspecting
+suspects
+suspend
+suspended
+suspender
+suspender's
+suspenders
+suspending
+suspends
+suspense
+suspenses
+suspension
+suspensions
+suspensive
+suspensively
+suspicion
+suspicion's
+suspicioned
+suspicioning
+suspicions
+suspicious
+suspiciously
+suspiciousness
+sustain
+sustained
+sustainer
+sustaining
+sustains
+suture
+sutured
+sutures
+suturing
+swagger
+swaggered
+swaggering
+swain
+swain's
+swains
+swallow
+swallowed
+swallower
+swallowing
+swallows
+swam
+swamp
+swamped
+swamper
+swampier
+swampiness
+swamping
+swamps
+swampy
+swan
+swan's
+swans
+swap
+swapped
+swapper
+swapper's
+swappers
+swapping
+swaps
+swarm
+swarmed
+swarmer
+swarming
+swarms
+swarthier
+swarthiness
+swarthy
+swatted
+sway
+swayed
+swayer
+swaying
+sways
+swear
+swearer
+swearing
+swears
+sweat
+sweated
+sweater
+sweaters
+sweating
+sweats
+sweep
+sweeper
+sweepers
+sweeping
+sweepingly
+sweepingness
+sweepings
+sweeps
+sweet
+sweeten
+sweetened
+sweetener
+sweeteners
+sweetening
+sweetenings
+sweetens
+sweeter
+sweetest
+sweetheart
+sweetheart's
+sweethearts
+sweetie
+sweetie's
+sweeties
+sweeting
+sweetly
+sweetness
+sweets
+swell
+swelled
+swelling
+swellings
+swells
+swept
+swerve
+swerved
+swerves
+swerving
+swift
+swifter
+swiftest
+swiftly
+swiftness
+swim
+swimmer
+swimmer's
+swimmers
+swimming
+swimmingly
+swims
+swimsuit
+swimsuit's
+swimsuits
+swine
+swing
+swinger
+swingers
+swinging
+swingingly
+swings
+swipe
+swiped
+swipes
+swiping
+swirl
+swirled
+swirler
+swirling
+swirlingly
+swirls
+swish
+swished
+swisher
+switch
+switch's
+switchboard
+switchboard's
+switchboards
+switched
+switcher
+switchers
+switches
+switching
+switchings
+swollen
+swoon
+swooned
+swooner
+swooning
+swooningly
+swoons
+swoop
+swooped
+swooper
+swooping
+swoops
+sword
+sword's
+swords
+swore
+sworn
+swum
+swung
+sycamore
+syllabi
+syllable
+syllable's
+syllabled
+syllables
+syllabling
+syllabus
+syllogism
+syllogism's
+syllogisms
+symbiosis
+symbiotic
+symbol
+symbol's
+symbolic
+symbolic's
+symbolically
+symbolics
+symbolism
+symbolisms
+symbols
+symmetric
+symmetrical
+symmetrically
+symmetricalness
+symmetries
+symmetry
+symmetry's
+sympathetic
+sympathies
+sympathy
+sympathy's
+symphonies
+symphony
+symphony's
+symposium
+symposiums
+symptom
+symptom's
+symptomatic
+symptoms
+synapse
+synapse's
+synapsed
+synapses
+synapsing
+synchronous
+synchronously
+synchronousness
+synchrony
+syndicate
+syndicated
+syndicates
+syndicating
+syndication
+syndrome
+syndrome's
+syndromes
+synergism
+synergistic
+synonym
+synonym's
+synonymous
+synonymously
+synonyms
+synopses
+synopsis
+syntactic
+syntactical
+syntactically
+syntacticly
+syntactics
+syntax
+syntaxes
+syntheses
+synthesis
+synthetic
+synthetics
+syringe
+syringed
+syringes
+syringing
+syrup
+system
+system's
+systematic
+systematically
+systematicness
+systematics
+systems
+tab
+tabernacle
+tabernacle's
+tabernacled
+tabernacles
+tabernacling
+table
+tableau
+tableau's
+tableaus
+tablecloth
+tablecloths
+tabled
+tables
+tablespoon
+tablespoon's
+tablespoonful
+tablespoonful's
+tablespoonfuls
+tablespoons
+tablet
+tablet's
+tablets
+tabling
+taboo
+taboo's
+taboos
+tabs
+tabular
+tabularly
+tabulate
+tabulated
+tabulates
+tabulating
+tabulation
+tabulations
+tabulator
+tabulator's
+tabulators
+tachometer
+tachometer's
+tachometers
+tachometry
+tacit
+tacitly
+tacitness
+tack
+tacked
+tacker
+tacking
+tackle
+tackle's
+tackled
+tackler
+tackles
+tackling
+tacks
+tact
+tactics
+tactile
+tactilely
+tag
+tag's
+tagged
+tagging
+tags
+tail
+tailed
+tailer
+tailing
+tailings
+tailor
+tailored
+tailoring
+tailors
+tails
+taint
+tainted
+taints
+take
+taken
+taker
+takers
+takes
+taketh
+taking
+takings
+tale
+tale's
+talent
+talented
+talents
+taler
+tales
+talion
+talk
+talkative
+talkatively
+talkativeness
+talked
+talker
+talkers
+talkie
+talking
+talks
+tall
+taller
+tallest
+tallness
+tallow
+tame
+tamed
+tamely
+tameness
+tamer
+tames
+tamest
+taming
+tamper
+tampered
+tamperer
+tampering
+tampers
+tan
+tandem
+tang
+tanged
+tangent
+tangent's
+tangential
+tangentially
+tangents
+tangible
+tangibleness
+tangibly
+tangier
+tangle
+tangled
+tangles
+tangling
+tangly
+tangy
+tank
+tanked
+tanker
+tankers
+tanking
+tanks
+tanner
+tanner's
+tanners
+tans
+tantamount
+tantrum
+tantrum's
+tantrums
+tap
+tap's
+tape
+taped
+taper
+tapered
+taperer
+tapering
+tapers
+tapes
+tapestried
+tapestries
+tapestry
+tapestry's
+taping
+tapings
+tapped
+tapper
+tapper's
+tappers
+tapping
+taproot
+taproot's
+taproots
+taps
+tar
+tardier
+tardies
+tardiness
+tardy
+target
+targeted
+targeting
+targets
+tariff
+tariff's
+tariffs
+taring
+tarried
+tarries
+tarry
+tarrying
+tars
+tart
+tartly
+tartness
+tarts
+task
+tasked
+tasking
+tasks
+taste
+tasted
+tasteful
+tastefully
+tastefulness
+tasteless
+tastelessly
+tastelessness
+taster
+tasters
+tastes
+tasting
+tatter
+tattered
+tattoo
+tattooed
+tattooer
+tattoos
+tau
+taught
+taunt
+taunted
+taunter
+taunting
+tauntingly
+taunts
+taut
+tauten
+tautened
+tautening
+tautly
+tautness
+tautological
+tautologically
+tautologies
+tautology
+tautology's
+tavern
+tavern's
+taverner
+taverns
+tawnier
+tawnies
+tawniness
+tawny
+tax
+taxable
+taxation
+taxed
+taxer
+taxes
+taxi
+taxi's
+taxicab
+taxicab's
+taxicabs
+taxied
+taxiing
+taxing
+taxingly
+taxis
+taxonomic
+taxonomically
+taxonomy
+taxpayer
+taxpayer's
+taxpayers
+tea
+teach
+teachable
+teachableness
+teacher
+teacher's
+teachers
+teaches
+teaching
+teachings
+team
+team's
+teamed
+teaming
+teams
+tear
+tear's
+teared
+tearer
+tearful
+tearfully
+tearfulness
+tearing
+tears
+teas
+tease
+teased
+teaser
+teases
+teasing
+teasingly
+teaspoon
+teaspoon's
+teaspoonful
+teaspoonful's
+teaspoonfuls
+teaspoons
+technical
+technicalities
+technicality
+technicality's
+technically
+technicalness
+technician
+technician's
+technicians
+technique
+technique's
+techniques
+technological
+technologically
+technologies
+technologist
+technologist's
+technologists
+technology
+technology's
+tedious
+tediously
+tediousness
+tedium
+teem
+teemed
+teeming
+teemingly
+teemingness
+teems
+teen
+teenage
+teenaged
+teenager
+teenagers
+teener
+teens
+teeth
+teethe
+teethed
+teether
+teethes
+teething
+telecommunication
+telecommunications
+teleconference
+teleconference's
+teleconferenced
+teleconferences
+teleconferencing
+telegram
+telegram's
+telegrams
+telegraph
+telegraphed
+telegrapher
+telegraphers
+telegraphic
+telegraphing
+telegraphs
+teleological
+teleologically
+teleology
+telephone
+telephoned
+telephoner
+telephoners
+telephones
+telephonic
+telephoning
+telephony
+telescope
+telescoped
+telescopes
+telescoping
+teletype
+teletype's
+teletypes
+televise
+televised
+televises
+televising
+television
+televisions
+televisor
+televisor's
+televisors
+tell
+teller
+tellers
+telling
+tellingly
+tellings
+tells
+temper
+temperament
+temperamental
+temperamentally
+temperaments
+temperance
+temperate
+temperately
+temperateness
+temperature
+temperature's
+temperatures
+tempered
+temperer
+tempering
+tempers
+tempest
+tempests
+tempestuous
+tempestuously
+tempestuousness
+template
+template's
+templates
+temple
+temple's
+templed
+temples
+temporal
+temporally
+temporaries
+temporarily
+temporariness
+temporary
+tempt
+temptation
+temptation's
+temptations
+tempted
+tempter
+tempters
+tempting
+temptingly
+tempts
+ten
+ten's
+tenacious
+tenaciously
+tenaciousness
+tenant
+tenant's
+tenants
+tend
+tended
+tendencies
+tendency
+tender
+tendered
+tendering
+tenderly
+tenderness
+tenders
+tending
+tends
+tenement
+tenement's
+tenements
+tennis
+tenor
+tenor's
+tenors
+tens
+tense
+tensed
+tensely
+tenseness
+tenser
+tenses
+tensest
+tensing
+tension
+tensioned
+tensioner
+tensioning
+tensions
+tensive
+tensor
+tensor's
+tensors
+tent
+tentacle
+tentacled
+tentacles
+tentative
+tentatively
+tentativeness
+tented
+tenter
+tenth
+tenthes
+tenting
+tents
+tenure
+tenured
+tenures
+tequila
+tequila's
+term
+termcap
+termed
+termer
+terminal
+terminal's
+terminally
+terminals
+terminate
+terminated
+terminates
+terminating
+termination
+terminations
+terminative
+terminatively
+terminator
+terminator's
+terminators
+terming
+terminologies
+terminology
+terminus
+termly
+terms
+ternary
+terrace
+terraced
+terraces
+terracing
+terrain
+terrain's
+terrains
+terrestrial
+terrestrial's
+terrestrially
+terrestrials
+terrible
+terribleness
+terribly
+terrier
+terrier's
+terriers
+terrific
+terrificly
+terrified
+terrifies
+terrify
+terrifying
+terrifyingly
+territorial
+territorially
+territories
+territory
+territory's
+terror
+terror's
+terrorism
+terrorist
+terrorist's
+terroristic
+terrorists
+terrors
+tertiaries
+tertiary
+test
+test's
+testability
+testable
+testament
+testament's
+testaments
+tested
+tester
+tester's
+testers
+testicle
+testicle's
+testicles
+testified
+testifier
+testifiers
+testifies
+testify
+testifying
+testimonies
+testimony
+testimony's
+testing
+testings
+tests
+text
+text's
+textbook
+textbook's
+textbooks
+textile
+textile's
+textiles
+texts
+textual
+textually
+texture
+textured
+textures
+texturing
+than
+thank
+thanked
+thanker
+thankful
+thankfully
+thankfulness
+thanking
+thankless
+thanklessly
+thanklessness
+thanks
+thanksgiving
+thanksgiving's
+thanksgivings
+that
+that's
+thatch
+thatched
+thatcher
+thatches
+thatching
+thats
+thaw
+thawed
+thawing
+thaws
+the
+theatrical
+theatrically
+theatricals
+theft
+theft's
+thefts
+their
+their's
+theirs
+them
+thematic
+theme
+theme's
+themes
+themselves
+then
+thence
+thenceforth
+theologian
+theologian's
+theologians
+theological
+theologically
+theologies
+theology
+theorem
+theorem's
+theorems
+theoretic
+theoretical
+theoretically
+theoreticians
+theoretics
+theories
+theorist
+theorist's
+theorists
+theory
+theory's
+therapeutic
+therapeutics
+therapies
+therapist
+therapist's
+therapists
+therapy
+therapy's
+there
+there's
+thereabouts
+thereafter
+thereby
+therefore
+therein
+thereof
+thereon
+thereto
+thereupon
+therewith
+thermodynamic
+thermodynamics
+thermometer
+thermometer's
+thermometers
+thermostat
+thermostat's
+thermostated
+thermostats
+these
+theses
+thesis
+they
+they'd
+they'll
+they're
+they've
+thick
+thicken
+thickened
+thickener
+thickeners
+thickening
+thickens
+thicker
+thickest
+thicket
+thicket's
+thicketed
+thickets
+thickly
+thickness
+thicknesses
+thicks
+thief
+thieve
+thieves
+thieving
+thigh
+thighed
+thighs
+thimble
+thimble's
+thimbles
+thin
+thiner
+thinest
+thing
+thingamajig
+thingamajig's
+thingamajigs
+thingness
+things
+think
+thinkable
+thinkableness
+thinkably
+thinker
+thinkers
+thinking
+thinkingly
+thinkingness
+thinks
+thinly
+thinner
+thinners
+thinness
+thinnest
+thins
+third
+thirdly
+thirds
+thirst
+thirsted
+thirster
+thirstier
+thirstiness
+thirsts
+thirsty
+thirteen
+thirteens
+thirteenth
+thirties
+thirtieth
+thirty
+this
+thistle
+thong
+thonged
+thorn
+thorn's
+thornier
+thorniness
+thorns
+thorny
+thorough
+thoroughfare
+thoroughfare's
+thoroughfares
+thoroughly
+thoroughness
+those
+though
+thought
+thought's
+thoughtful
+thoughtfully
+thoughtfulness
+thoughtless
+thoughtlessly
+thoughtlessness
+thoughts
+thousand
+thousands
+thousandth
+thrash
+thrashed
+thrasher
+thrashes
+thrashing
+thread
+threaded
+threader
+threaders
+threading
+threads
+threat
+threaten
+threatened
+threatener
+threatening
+threateningly
+threatens
+threats
+three
+three's
+threes
+threescore
+threshold
+threshold's
+thresholded
+thresholding
+thresholds
+threw
+thrice
+thrift
+thriftier
+thriftiness
+thrifty
+thrill
+thrilled
+thriller
+thrillers
+thrilling
+thrillingly
+thrills
+thrive
+thrived
+thriver
+thrives
+thriving
+thrivingly
+throat
+throated
+throating
+throats
+throb
+throbbed
+throbbing
+throbs
+throne
+throne's
+thrones
+throng
+throng's
+thronging
+throngs
+throning
+throttle
+throttled
+throttler
+throttles
+throttling
+through
+throughly
+throughout
+throughput
+throw
+thrower
+throwing
+thrown
+throws
+thrush
+thrushes
+thrust
+thruster
+thrusters
+thrusting
+thrusts
+thud
+thuds
+thug
+thug's
+thugs
+thumb
+thumbed
+thumbing
+thumbs
+thump
+thumped
+thumper
+thumping
+thumps
+thunder
+thunderbolt
+thunderbolt's
+thunderbolts
+thundered
+thunderer
+thunderers
+thundering
+thunderingly
+thunders
+thunderstorm
+thunderstorm's
+thunderstorms
+thunderstruck
+thus
+thusly
+thwart
+thwarted
+thwarter
+thwarting
+thwartly
+thwarts
+thyself
+tick
+ticked
+ticker
+tickers
+ticket
+ticket's
+ticketed
+ticketing
+tickets
+ticking
+tickle
+tickled
+tickler
+tickles
+tickling
+ticklish
+ticklishly
+ticklishness
+ticks
+tidal
+tidally
+tide
+tided
+tides
+tidied
+tidier
+tidies
+tidiness
+tiding
+tidings
+tidy
+tidying
+tie
+tied
+tier
+tiered
+tiers
+ties
+tiger
+tiger's
+tigers
+tight
+tighten
+tightened
+tightener
+tighteners
+tightening
+tightenings
+tightens
+tighter
+tightest
+tightly
+tightness
+tights
+tilde
+tildes
+tile
+tiled
+tiler
+tiles
+tiling
+till
+tillable
+tilled
+tiller
+tillered
+tillering
+tillers
+tilling
+tills
+tilt
+tilted
+tilter
+tilters
+tilting
+tilts
+timber
+timbered
+timbering
+timbers
+time
+timed
+timeless
+timelessly
+timelessness
+timelier
+timeliness
+timely
+timeout
+timeouts
+timer
+timers
+times
+timeshare
+timeshared
+timeshares
+timesharing
+timetable
+timetable's
+timetabled
+timetables
+timetabling
+timid
+timidity
+timidly
+timidness
+timing
+timings
+tin
+tin's
+tinge
+tinged
+tinging
+tingle
+tingled
+tingles
+tingling
+tinglingly
+tinier
+tiniest
+tinily
+tininess
+tinker
+tinkered
+tinkerer
+tinkering
+tinkers
+tinkle
+tinkled
+tinkles
+tinkling
+tinned
+tinnier
+tinniest
+tinnily
+tinniness
+tinning
+tinny
+tins
+tint
+tinted
+tinter
+tinting
+tints
+tiny
+tip
+tip's
+tipped
+tipper
+tipper's
+tippers
+tipping
+tips
+tiptoe
+tiptoed
+tire
+tired
+tiredly
+tiredness
+tireless
+tirelessly
+tirelessness
+tires
+tiresome
+tiresomely
+tiresomeness
+tiring
+tissue
+tissue's
+tissued
+tissues
+tissuing
+tit
+tit's
+tithe
+tithe's
+tither
+tithes
+tithing
+title
+titled
+titles
+titling
+tits
+titter
+tittered
+tittering
+titters
+tizzies
+tizzy
+to
+toad
+toad's
+toads
+toast
+toasted
+toaster
+toasters
+toastier
+toasting
+toasts
+toasty
+tobacco
+today
+today's
+todays
+toe
+toe's
+toed
+toes
+together
+togetherness
+toggle
+toggled
+toggles
+toggling
+toil
+toiled
+toiler
+toilet
+toilet's
+toilets
+toiling
+toils
+token
+token's
+tokens
+told
+tolerability
+tolerable
+tolerably
+tolerance
+tolerances
+tolerant
+tolerantly
+tolerate
+tolerated
+tolerates
+tolerating
+toleration
+tolerative
+toll
+tolled
+tolling
+tolls
+tom
+tom's
+tomahawk
+tomahawk's
+tomahawks
+tomato
+tomatoes
+tomb
+tomb's
+tombs
+tomography
+tomorrow
+tomorrow's
+tomorrows
+toms
+ton
+ton's
+tone
+toned
+toner
+tones
+tongs
+tongue
+tongued
+tongues
+tonguing
+tonic
+tonic's
+tonics
+tonight
+toning
+tonnage
+tons
+tonsil
+too
+took
+tool
+tooled
+tooler
+toolers
+tooling
+toolkit
+toolkit's
+toolkits
+tools
+tooth
+toothbrush
+toothbrush's
+toothbrushes
+toothbrushing
+toothed
+toothing
+toothpick
+toothpick's
+toothpicks
+top
+toped
+toper
+topic
+topic's
+topical
+topically
+topics
+toping
+topmost
+topological
+topologically
+topologies
+topology
+topple
+toppled
+topples
+toppling
+tops
+torch
+torch's
+torches
+tore
+torment
+tormented
+tormenter
+tormenters
+tormenting
+torments
+torn
+tornado
+tornadoes
+tornados
+torpedo
+torpedoed
+torpedoes
+torpedoing
+torpedos
+torque
+torquer
+torquers
+torques
+torquing
+torrent
+torrent's
+torrents
+torrid
+torridly
+torridness
+tortoise
+tortoise's
+tortoises
+torture
+tortured
+torturer
+torturers
+tortures
+torturing
+torus
+torus's
+toruses
+toss
+tossed
+tosser
+tosses
+tossing
+total
+total's
+totalities
+totality
+totality's
+totally
+totals
+totter
+tottered
+tottering
+totteringly
+totters
+touch
+touchable
+touched
+toucher
+touches
+touchier
+touchiest
+touchily
+touchiness
+touching
+touchingly
+touchy
+tough
+toughen
+toughened
+toughening
+toughens
+tougher
+toughest
+toughly
+toughness
+tour
+toured
+tourer
+touring
+tourist
+tourist's
+tourists
+tournament
+tournament's
+tournaments
+tours
+tow
+toward
+towardliness
+towardly
+towards
+towed
+towel
+towel's
+towels
+tower
+towered
+towering
+toweringly
+towers
+towing
+town
+town's
+towner
+towns
+township
+township's
+townships
+tows
+toxicity
+toxin
+toxin's
+toxins
+toy
+toyed
+toyer
+toying
+toys
+trace
+traceable
+traceableness
+traced
+traceless
+tracelessly
+tracer
+tracers
+traces
+tracing
+tracings
+track
+tracked
+tracker
+trackers
+tracking
+tracks
+tract
+tract's
+tractability
+tractable
+tractive
+tractor
+tractor's
+tractors
+tracts
+trade
+traded
+trademark
+trademark's
+trademarks
+tradeoff
+tradeoffs
+trader
+traders
+trades
+tradesman
+trading
+tradition
+tradition's
+traditional
+traditionally
+traditions
+traffic
+traffic's
+trafficked
+trafficker
+trafficker's
+traffickers
+trafficking
+traffics
+tragedies
+tragedy
+tragedy's
+tragic
+tragically
+trail
+trailed
+trailer
+trailers
+trailing
+trailings
+trails
+train
+trained
+trainee
+trainee's
+trainees
+trainer
+trainers
+training
+trains
+trait
+trait's
+traitor
+traitor's
+traitors
+traits
+trajectories
+trajectory
+trajectory's
+tramp
+tramped
+tramper
+tramping
+trample
+trampled
+trampler
+tramples
+trampling
+tramps
+trance
+trance's
+trances
+trancing
+tranquil
+tranquility
+tranquillity
+tranquilly
+tranquilness
+transact
+transacted
+transacting
+transaction
+transaction's
+transactions
+transacts
+transceiver
+transceiver's
+transceivers
+transcend
+transcended
+transcendent
+transcendently
+transcending
+transcends
+transcontinental
+transcribe
+transcribed
+transcriber
+transcribers
+transcribes
+transcribing
+transcript
+transcript's
+transcription
+transcription's
+transcriptions
+transcripts
+transfer
+transfer's
+transferability
+transferable
+transferal
+transferal's
+transferals
+transfered
+transference
+transferral
+transferral's
+transferrals
+transferred
+transferrer
+transferrer's
+transferrers
+transferring
+transfers
+transfinite
+transform
+transformable
+transformation
+transformation's
+transformational
+transformations
+transformed
+transformer
+transformers
+transforming
+transforms
+transgress
+transgressed
+transgresses
+transgressing
+transgression
+transgression's
+transgressions
+transgressive
+transience
+transiency
+transient
+transiently
+transients
+transistor
+transistor's
+transistors
+transit
+transition
+transitional
+transitionally
+transitioned
+transitions
+transitive
+transitively
+transitiveness
+transitivity
+transitoriness
+transitory
+translatability
+translatable
+translate
+translated
+translates
+translating
+translation
+translational
+translations
+translative
+translator
+translator's
+translators
+translucent
+translucently
+transmission
+transmission's
+transmissions
+transmit
+transmits
+transmittal
+transmitted
+transmitter
+transmitter's
+transmitters
+transmitting
+transmogrification
+transmogrify
+transparencies
+transparency
+transparency's
+transparent
+transparently
+transparentness
+transpire
+transpired
+transpires
+transpiring
+transplant
+transplanted
+transplanter
+transplanting
+transplants
+transport
+transportability
+transportation
+transportations
+transported
+transporter
+transporters
+transporting
+transports
+transpose
+transposed
+transposes
+transposing
+transposition
+trap
+trap's
+trapezoid
+trapezoid's
+trapezoidal
+trapezoids
+trapped
+trapper
+trapper's
+trappers
+trapping
+trappings
+traps
+trash
+trashed
+trasher
+trashes
+trashing
+traumatic
+travail
+travails
+travel
+travels
+traversal
+traversal's
+traversals
+traverse
+traversed
+traverser
+traverses
+traversing
+travesties
+travesty
+travesty's
+tray
+tray's
+trays
+treacheries
+treacherous
+treacherously
+treacherousness
+treachery
+treachery's
+tread
+treaded
+treader
+treading
+treads
+treason
+treasure
+treasured
+treasurer
+treasures
+treasuries
+treasuring
+treasury
+treasury's
+treat
+treated
+treater
+treaters
+treaties
+treating
+treatise
+treatise's
+treatises
+treatment
+treatment's
+treatments
+treats
+treaty
+treaty's
+treble
+trebled
+trebles
+trebling
+tree
+tree's
+treed
+trees
+treetop
+treetop's
+treetops
+trek
+trek's
+treks
+tremble
+trembled
+trembler
+trembles
+trembling
+tremendous
+tremendously
+tremendousness
+tremor
+tremor's
+tremors
+trench
+trenched
+trencher
+trenchers
+trenches
+trend
+trending
+trends
+trespass
+trespassed
+trespasser
+trespassers
+trespasses
+tress
+tress's
+tressed
+tresses
+trial
+trial's
+trials
+triangle
+triangle's
+triangles
+triangular
+triangularly
+tribal
+tribally
+tribe
+tribe's
+tribes
+tribunal
+tribunal's
+tribunals
+tribune
+tribune's
+tribunes
+tributary
+tribute
+tribute's
+tributes
+tributing
+trichotomy
+trick
+tricked
+tricker
+trickier
+trickiest
+trickiness
+tricking
+trickle
+trickled
+trickles
+trickling
+tricks
+tricky
+tried
+trier
+triers
+tries
+trifle
+trifled
+trifler
+trifles
+trifling
+trigger
+triggered
+triggering
+triggers
+trigonometric
+trigonometry
+trihedral
+trill
+trilled
+triller
+trillion
+trillions
+trillionth
+trim
+trimer
+trimly
+trimmed
+trimmer
+trimmest
+trimming
+trimmings
+trimness
+trims
+trinket
+trinket's
+trinketed
+trinketer
+trinkets
+trip
+trip's
+triple
+tripled
+triples
+triplet
+triplet's
+triplets
+triplication
+tripling
+triply
+trips
+triumph
+triumphal
+triumphantly
+triumphed
+triumphing
+triumphs
+trivia
+trivial
+trivialities
+triviality
+trivially
+trod
+troff
+troff's
+troffer
+troll
+troll's
+trolley
+trolley's
+trolleyed
+trolleys
+trolls
+troop
+trooped
+trooper
+troopers
+trooping
+troops
+trophied
+trophies
+trophy
+trophy's
+trophying
+tropic
+tropic's
+tropical
+tropically
+tropics
+trot
+trots
+trouble
+troubled
+troublemaker
+troublemaker's
+troublemakers
+troubler
+troubles
+troubleshoot
+troubleshooted
+troubleshooter
+troubleshooters
+troubleshooting
+troubleshoots
+troublesome
+troublesomely
+troublesomeness
+troubling
+trough
+trouser
+trousered
+trousers
+trout
+trouts
+trowel
+trowel's
+trowels
+truant
+truant's
+truants
+truce
+trucing
+truck
+trucked
+trucker
+truckers
+trucking
+trucks
+trudge
+trudged
+trudger
+trudges
+trudging
+true
+trued
+trueness
+truer
+trues
+truest
+truing
+truism
+truism's
+truisms
+truly
+trump
+trumped
+trumpet
+trumpeted
+trumpeter
+trumpeting
+trumpets
+trumps
+truncate
+truncated
+truncates
+truncating
+truncation
+truncation's
+truncations
+trunk
+trunk's
+trunked
+trunks
+trust
+trusted
+trustee
+trustee's
+trusteed
+trustees
+truster
+trustful
+trustfully
+trustfulness
+trustier
+trusties
+trustiness
+trusting
+trustingly
+trusts
+trustworthiness
+trustworthy
+trusty
+truth
+truthful
+truthfully
+truthfulness
+truths
+try
+trying
+tryingly
+tty
+tty's
+ttys
+tub
+tub's
+tube
+tubed
+tuber
+tuberculosis
+tubers
+tubes
+tubing
+tubs
+tuck
+tucked
+tucker
+tuckered
+tuckering
+tucking
+tucks
+tuft
+tuft's
+tufted
+tufter
+tufts
+tug
+tugs
+tuition
+tuitions
+tulip
+tulip's
+tulips
+tumble
+tumbled
+tumbler
+tumblers
+tumbles
+tumbling
+tumult
+tumult's
+tumults
+tumultuous
+tumultuously
+tumultuousness
+tunable
+tunableness
+tune
+tuned
+tuner
+tuners
+tunes
+tunic
+tunic's
+tunics
+tuning
+tuning's
+tunings
+tunnel
+tunnels
+tuple
+tuple's
+tuples
+turban
+turban's
+turbaned
+turbans
+turbulence
+turbulence's
+turbulent
+turbulently
+turf
+turkey
+turkey's
+turkeys
+turmoil
+turmoil's
+turmoils
+turn
+turnable
+turned
+turner
+turners
+turning
+turnings
+turnip
+turnip's
+turnips
+turnkey
+turnkeys
+turnover
+turnovers
+turns
+turpentine
+turquoise
+turret
+turret's
+turreted
+turrets
+turtle
+turtle's
+turtles
+turtling
+tutor
+tutored
+tutorial
+tutorial's
+tutorials
+tutoring
+tutors
+twain
+twang
+twanging
+twas
+tweak
+tweaked
+tweaker
+tweaking
+tweaks
+tweed
+tweezer
+tweezers
+twelfth
+twelve
+twelves
+twenties
+twentieth
+twenty
+twice
+twig
+twig's
+twigs
+twilight
+twilight's
+twilights
+twill
+twilled
+twilling
+twin
+twin's
+twine
+twined
+twiner
+twines
+twining
+twinkle
+twinkled
+twinkler
+twinkles
+twinkling
+twins
+twirl
+twirled
+twirler
+twirling
+twirlingly
+twirls
+twist
+twisted
+twister
+twisters
+twisting
+twists
+twitch
+twitched
+twitcher
+twitching
+twitter
+twittered
+twitterer
+twittering
+two
+two's
+twofold
+twos
+tying
+type
+type's
+typed
+typedef
+typedefs
+typer
+types
+typewriter
+typewriter's
+typewriters
+typhoid
+typical
+typically
+typicalness
+typification
+typified
+typifies
+typify
+typifying
+typing
+typist
+typist's
+typists
+typographic
+typographical
+typographically
+typography
+typos
+tyranny
+tyrant
+tyrant's
+tyrants
+ubiquitous
+ubiquitously
+ubiquitousness
+ubiquity
+ugh
+uglier
+ugliest
+ugliness
+ugly
+ulcer
+ulcer's
+ulcered
+ulcering
+ulcers
+ultimate
+ultimately
+ultimateness
+umbrella
+umbrella's
+umbrellas
+umpire
+umpire's
+umpired
+umpires
+umpiring
+unabashed
+unabashedly
+unabated
+unabatedly
+unabbreviated
+unable
+unabridged
+unaccelerated
+unacceptability
+unacceptable
+unacceptably
+unaccessible
+unaccommodated
+unaccompanied
+unaccomplished
+unaccountably
+unaccounted
+unaccustomed
+unaccustomedly
+unachievable
+unachieved
+unacknowledged
+unacquainted
+unadaptable
+unadjustable
+unadjusted
+unadopted
+unadorned
+unadulterated
+unadulteratedly
+unadvised
+unadvisedly
+unaffected
+unaffectedly
+unaffectedness
+unaffectionate
+unaffectionately
+unafraid
+unaggregated
+unaided
+unalienability
+unalienable
+unaligned
+unallocated
+unalloyed
+unalterable
+unalterableness
+unalterably
+unaltered
+unambiguous
+unambiguously
+unambitious
+unanchored
+unanimous
+unanimously
+unannounced
+unanswerable
+unanswered
+unanticipated
+unanticipatedly
+unapologetically
+unappealing
+unappealingly
+unappreciated
+unapproachability
+unapproachable
+unappropriated
+unapt
+unaptly
+unaptness
+unarguable
+unarguably
+unarmed
+unarticulated
+unary
+unashamed
+unashamedly
+unasked
+unassailable
+unassailableness
+unassembled
+unassigned
+unassigns
+unassisted
+unassuming
+unassumingness
+unattached
+unattainability
+unattainable
+unattended
+unattenuated
+unattractive
+unattractively
+unattractiveness
+unattributed
+unauthentic
+unauthenticated
+unavailability
+unavailable
+unavailing
+unavailingly
+unavailingness
+unavoidable
+unavoidably
+unaware
+unawarely
+unawareness
+unawares
+unbacked
+unbalanced
+unbalancedness
+unbanned
+unbanning
+unbans
+unbarbered
+unbarred
+unbated
+unbearable
+unbearably
+unbeatable
+unbeatably
+unbeaten
+unbeautifully
+unbecoming
+unbecomingly
+unbecomingness
+unbelievable
+unbelievably
+unbelieving
+unbelievingly
+unbelted
+unbendable
+unbetrothed
+unbiased
+unbiasedness
+unbidden
+unblemished
+unblinded
+unblinking
+unblinkingly
+unblock
+unblocked
+unblocking
+unblocks
+unblown
+unblushing
+unblushingly
+unbodied
+unbolted
+unboned
+unbonneted
+unborn
+unbound
+unbounded
+unboundedness
+unbowed
+unbranched
+unbreakable
+unbreathable
+unbred
+unbridled
+unbroken
+unbudging
+unbudgingly
+unbuffered
+unbuilt
+unbundled
+unburdened
+unbureaucratic
+unburied
+unburned
+unbuttered
+unbuttoned
+unbuttons
+uncaged
+uncalculating
+uncalled
+uncandidly
+uncanniness
+uncanny
+uncared
+uncaring
+uncatchable
+uncaught
+uncaused
+unceasing
+unceasingly
+uncensored
+uncertain
+uncertainly
+uncertainness
+uncertainties
+uncertainty
+uncertified
+unchallenged
+unchangeability
+unchangeable
+unchangeably
+unchanged
+unchanging
+unchangingly
+unchangingness
+uncharacteristically
+uncharged
+uncharitable
+uncharitableness
+uncharted
+unchartered
+uncheckable
+unchecked
+unchivalrously
+unchosen
+uncivil
+uncivilly
+unclaimed
+unclamorous
+unclamorously
+unclamorousness
+unclarity
+unclassified
+uncle
+uncle's
+unclean
+uncleanliness
+uncleanly
+uncleanness
+unclear
+uncleared
+unclenched
+uncles
+unclipped
+unclosed
+unclothed
+unclouded
+uncloudedly
+unclustered
+uncluttered
+uncoated
+uncoded
+uncoiled
+uncoined
+uncomfortable
+uncomfortably
+uncomforted
+uncommented
+uncommitted
+uncommon
+uncommonly
+uncommonness
+uncomplaining
+uncomplainingly
+uncompleted
+uncomplimentary
+uncomprehending
+uncomprehendingly
+uncompress
+uncompressed
+uncompresses
+uncompressing
+uncompromising
+uncompromisingly
+uncomputable
+unconceivable
+unconcerned
+unconcernedly
+unconcernedness
+unconditional
+unconditionally
+unconditioned
+unconfined
+unconfirmed
+unconformity
+unconnected
+unconquerable
+unconscious
+unconsciously
+unconsciousness
+unconsidered
+unconsolidated
+unconstitutional
+unconstitutionality
+unconstitutionally
+unconstrained
+uncontaminated
+uncontested
+uncontrollability
+uncontrollable
+uncontrollably
+uncontrolled
+unconventional
+unconventionally
+unconvertible
+unconvinced
+unconvincing
+unconvincingly
+unconvincingness
+uncool
+uncooled
+uncooperative
+uncoordinated
+uncorked
+uncorrectable
+uncorrected
+uncorrelated
+uncountable
+uncountably
+uncounted
+uncouth
+uncouthly
+uncouthness
+uncovenanted
+uncover
+uncovered
+uncovering
+uncovers
+uncreated
+uncritically
+uncrowned
+uncrushable
+uncured
+uncurled
+uncynical
+uncynically
+undamaged
+undamped
+undaunted
+undauntedly
+undebatable
+undecidable
+undecided
+undeclared
+undecomposable
+undecorated
+undefended
+undefinability
+undefinable
+undefined
+undefinedness
+undeformed
+undelete
+undeleted
+undemocratic
+undemocratically
+undemonstrative
+undemonstratively
+undemonstrativeness
+undeniable
+undeniableness
+undeniably
+undepicted
+under
+underbrush
+underdone
+underestimate
+underestimated
+underestimates
+underestimating
+underestimation
+underestimations
+underflow
+underflowed
+underflowing
+underflows
+underfoot
+undergo
+undergoes
+undergoing
+undergone
+undergrad
+undergrad's
+undergrads
+undergraduate
+undergraduate's
+undergraduates
+underground
+undergrounder
+underivable
+underived
+underlie
+underlies
+underline
+underlined
+underlines
+underling
+underling's
+underlings
+underlining
+underlinings
+underly
+underlying
+undermine
+undermined
+undermines
+undermining
+underneath
+underpayment
+underpayment's
+underpayments
+underpinning
+underpinnings
+underplay
+underplayed
+underplaying
+underplays
+underscore
+underscored
+underscores
+understand
+understandability
+understandable
+understandably
+understanding
+understandingly
+understandings
+understands
+understated
+understood
+undertake
+undertaken
+undertaker
+undertaker's
+undertakers
+undertakes
+undertaking
+undertakings
+undertook
+underway
+underwear
+underwent
+underworld
+underwrite
+underwriter
+underwriters
+underwrites
+underwriting
+undescended
+undesigned
+undesigning
+undesirability
+undesirable
+undesirableness
+undesirably
+undesired
+undetectable
+undetected
+undetermined
+undeveloped
+undeviated
+undeviating
+undeviatingly
+undid
+undies
+undifferentiated
+undigested
+undignified
+undiluted
+undiminished
+undimmed
+undiplomatic
+undirected
+undisciplined
+undisclosed
+undiscovered
+undiscussed
+undisguised
+undisguisedly
+undismayed
+undisputed
+undisrupted
+undissociated
+undistinguished
+undistorted
+undistributed
+undisturbed
+undivided
+undo
+undocumented
+undoer
+undoes
+undoing
+undoings
+undomesticated
+undone
+undoubled
+undoubted
+undoubtedly
+undrained
+undramatically
+undreamed
+undress
+undressed
+undresses
+undressing
+undried
+undrinkable
+undue
+unduly
+undumper
+undumper's
+undutiful
+undutifully
+undutifulness
+undying
+unearned
+unearthliness
+unearthly
+uneasily
+uneasiness
+uneasy
+uneconomical
+unedited
+unelected
+unembellished
+unemotional
+unemotionally
+unemphatic
+unemphatically
+unemployable
+unemployed
+unemployment
+unencumbered
+unending
+unendingly
+unendurable
+unendurableness
+unendurably
+unenlightening
+unenthusiastic
+unenthusiastically
+unenumerated
+unenvied
+unequal
+unequally
+unequivocal
+unequivocally
+unerring
+unerringly
+unessential
+unethically
+unevaluated
+uneven
+unevenly
+unevenness
+uneventful
+uneventfully
+unexamined
+unexampled
+unexceptionally
+unexcused
+unexpanded
+unexpected
+unexpectedly
+unexpectedness
+unexpended
+unexperienced
+unexplainable
+unexplained
+unexploited
+unexplored
+unexpressed
+unextended
+unfading
+unfadingly
+unfair
+unfairly
+unfairness
+unfaith
+unfaithful
+unfaithfully
+unfaithfulness
+unfaltering
+unfalteringly
+unfamiliar
+unfamiliarity
+unfamiliarly
+unfashionable
+unfashionably
+unfastened
+unfathered
+unfeathered
+unfeigned
+unfeignedly
+unfenced
+unfettered
+unfilial
+unfilially
+unfilled
+unfinished
+unfired
+unfit
+unfitly
+unfitness
+unfitted
+unfixed
+unflagging
+unflaggingly
+unflattering
+unflatteringly
+unfledged
+unflinching
+unflinchingly
+unfocused
+unfold
+unfolded
+unfolding
+unfolds
+unforeseen
+unforgeable
+unforgettable
+unforgettably
+unforgivable
+unforgiving
+unforgivingness
+unformatted
+unformed
+unforthcoming
+unfortunate
+unfortunately
+unfortunates
+unfounded
+unfrequented
+unfriendliness
+unfriendly
+unfrosted
+unfruitful
+unfruitfully
+unfruitfulness
+unfulfilled
+unfunded
+unfunnily
+unfurnished
+ungainliness
+ungainly
+ungallantly
+ungenerously
+ungirt
+unglazed
+unglued
+ungot
+ungotten
+ungoverned
+ungraceful
+ungracefully
+ungracefulness
+ungraciously
+ungraded
+ungrammatical
+ungrateful
+ungratefully
+ungratefulness
+ungratified
+ungrounded
+unguarded
+unguardedly
+unguardedness
+unguessable
+unguessed
+unguided
+unhallow
+unhallowed
+unhampered
+unhandily
+unhandsomely
+unhappier
+unhappiest
+unhappily
+unhappiness
+unhappy
+unharmed
+unhealthily
+unhealthiness
+unhealthy
+unheard
+unheeded
+unheeding
+unhelm
+unhelpfully
+unheralded
+unhesitating
+unhesitatingly
+unhinged
+unhitched
+unhooks
+unhoped
+unhurriedly
+unhysterical
+unhysterically
+unicorn
+unicorn's
+unicorns
+unidentifiable
+unidentified
+unidirectional
+unidirectionality
+unidirectionally
+unification
+unifications
+unified
+unifier
+unifiers
+unifies
+uniform
+uniformed
+uniforming
+uniformities
+uniformity
+uniformly
+uniformness
+uniforms
+unify
+unifying
+unilluminating
+unimaginable
+unimaginably
+unimaginatively
+unimpaired
+unimpassioned
+unimpeded
+unimplemented
+unimportance
+unimportant
+unimpressed
+unimproved
+unincorporated
+unindented
+uninfected
+uninfluenced
+uninformatively
+uninformed
+uninhabited
+uninhibited
+uninhibitedly
+uninhibitedness
+uninitiated
+uninjured
+uninspired
+uninspiring
+uninstantiated
+uninsulated
+unintelligent
+unintelligently
+unintelligibility
+unintelligible
+unintelligibleness
+unintelligibly
+unintended
+unintentional
+unintentionally
+uninteresting
+uninterestingly
+uninterpretable
+uninterpreted
+uninterrupted
+uninterruptedly
+uninterruptedness
+uninterviewed
+uninvited
+union
+union's
+unions
+unique
+uniquely
+uniqueness
+unison
+unit
+unit's
+unite
+united
+unitedly
+uniter
+unites
+unities
+uniting
+unitive
+units
+unity
+unity's
+univalve
+univalve's
+univalves
+universal
+universality
+universally
+universalness
+universals
+universe
+universe's
+universes
+universities
+university
+university's
+unjacketed
+unjam
+unjammed
+unjamming
+unjoined
+unjust
+unjustifiable
+unjustified
+unjustly
+unjustness
+unkind
+unkindliness
+unkindly
+unkindness
+unknit
+unknowable
+unknowing
+unknowingly
+unknown
+unknowns
+unlaced
+unlamented
+unlashed
+unlaundered
+unlawful
+unlawfully
+unlawfulness
+unleaded
+unleash
+unleashed
+unleashes
+unleashing
+unleavened
+unless
+unlettered
+unlicensed
+unlicked
+unlike
+unlikelihood
+unlikelihoods
+unlikeliness
+unlikely
+unlikeness
+unlimbers
+unlimited
+unlimitedly
+unlined
+unlink
+unlinked
+unlinking
+unlinks
+unlisted
+unload
+unloaded
+unloader
+unloaders
+unloading
+unloads
+unlock
+unlocked
+unlocking
+unlocks
+unlogged
+unloved
+unluckily
+unluckiness
+unlucky
+unmade
+unmagnified
+unmaintainable
+unmaintained
+unmaliciously
+unmanageable
+unmanageably
+unmanaged
+unmanned
+unmannered
+unmanneredly
+unmannerliness
+unmannerly
+unmapped
+unmaps
+unmarked
+unmarried
+unmarrieds
+unmasked
+unmatchable
+unmatched
+unmated
+unmates
+unmeant
+unmeasurable
+unmentionable
+unmentionables
+unmentioned
+unmerciful
+unmercifully
+unmeshed
+unmistakable
+unmistakably
+unmitigated
+unmitigatedly
+unmitigatedness
+unmixed
+unmoderated
+unmodifiable
+unmodified
+unmolested
+unmotivated
+unmount
+unmountable
+unmounted
+unmoved
+unmurmuring
+unnameable
+unnamed
+unnatural
+unnaturally
+unnaturalness
+unnecessarily
+unnecessary
+unneeded
+unnegated
+unnerve
+unnerved
+unnerves
+unnerving
+unnervingly
+unnoticed
+unnourished
+unnumbered
+unobservable
+unobservables
+unobserved
+unobtainable
+unoccupied
+unofficial
+unofficially
+unopened
+unordered
+unoriginals
+unorthodoxly
+unpack
+unpackaged
+unpackages
+unpacked
+unpacker
+unpacking
+unpacks
+unpadded
+unpaged
+unpaid
+unpainted
+unpaired
+unparliamentary
+unparsed
+unpartitioned
+unpatriotic
+unpaved
+unperceived
+unperformed
+unperturbed
+unperturbedly
+unplaced
+unplagued
+unplanned
+unpleasant
+unpleasantly
+unpleasantness
+unpleased
+unplowed
+unplugged
+unplugging
+unplugs
+unplumbed
+unpolled
+unpolluted
+unpopular
+unpopularity
+unprecedented
+unprecedentedly
+unpredictability
+unpredictable
+unpredictably
+unpredicted
+unprejudiced
+unprescribed
+unpreserved
+unpretending
+unpretentious
+unpretentiously
+unpretentiousness
+unpriced
+unprimed
+unprincipled
+unprincipledness
+unprintable
+unprinted
+unprivileged
+unproblematic
+unproblematical
+unproblematically
+unprocessed
+unprofitable
+unprofitableness
+unprofitably
+unprojected
+unpromising
+unpromisingly
+unprompted
+unpronounceable
+unpropagated
+unpropertied
+unprotected
+unprotectedly
+unprovability
+unprovable
+unproved
+unproven
+unprovided
+unpublished
+unpunched
+unpunished
+unqualified
+unqualifiedly
+unquantifiable
+unquenched
+unquestionably
+unquestioned
+unquestioningly
+unquoted
+unranked
+unrated
+unravel
+unravels
+unreachable
+unreacted
+unread
+unreadability
+unreadable
+unreal
+unrealism
+unrealistic
+unrealistically
+unrealized
+unrealizes
+unreasonable
+unreasonableness
+unreasonably
+unreassuringly
+unreconstructed
+unrecordable
+unrecorded
+unrecoverable
+unredeemed
+unreferenced
+unrefined
+unreflected
+unregister
+unregistered
+unregistering
+unregisters
+unregulated
+unrehearsed
+unreinforced
+unrelated
+unreleased
+unrelenting
+unrelentingly
+unreliabilities
+unreliability
+unreliable
+unreliably
+unremarked
+unreported
+unrepresentable
+unrepresented
+unrequested
+unrequited
+unreserved
+unreservedly
+unreservedness
+unresisted
+unresisting
+unresolved
+unresponsive
+unresponsively
+unresponsiveness
+unrest
+unrestrained
+unrestrainedly
+unrestrainedness
+unrestricted
+unrestrictedly
+unrestrictive
+unreturned
+unrevealing
+unrifled
+unrighteous
+unrighteously
+unrighteousness
+unroll
+unrolled
+unrolling
+unrolls
+unromantically
+unrotated
+unruffled
+unruled
+unruliness
+unruly
+unsafe
+unsafely
+unsaid
+unsalted
+unsanitary
+unsatisfactorily
+unsatisfactory
+unsatisfiability
+unsatisfiable
+unsatisfied
+unsatisfying
+unsaturated
+unsaved
+unscheduled
+unschooled
+unscientific
+unscientifically
+unscramble
+unscrambled
+unscrambler
+unscrambles
+unscrambling
+unscratched
+unscreened
+unscrews
+unscripted
+unscrupulous
+unscrupulously
+unscrupulousness
+unsealed
+unseals
+unseasonable
+unseasonableness
+unseasonably
+unseasoned
+unsecured
+unseeded
+unseeing
+unseemly
+unseen
+unsegmented
+unsegregated
+unselected
+unselfish
+unselfishly
+unselfishness
+unsent
+unserved
+unserviced
+unsettled
+unsettledness
+unsettling
+unsettlingly
+unshaded
+unshakable
+unshaken
+unshared
+unsharpened
+unshaved
+unshaven
+unsheathing
+unshelled
+unsheltered
+unshielded
+unshod
+unsigned
+unsimplified
+unsized
+unskilled
+unskillful
+unskillfully
+unskillfulness
+unslings
+unsloped
+unslung
+unsmiling
+unsmilingly
+unsnap
+unsnapped
+unsnapping
+unsnaps
+unsociability
+unsociable
+unsociableness
+unsociably
+unsocial
+unsocially
+unsolicited
+unsolvable
+unsolved
+unsophisticated
+unsophistication
+unsorted
+unsought
+unsound
+unsounded
+unsoundly
+unsoundness
+unsparing
+unsparingly
+unspeakable
+unspecified
+unspent
+unspoiled
+unspoken
+unspotted
+unsprayed
+unsprung
+unstable
+unstableness
+unstably
+unstacked
+unstacks
+unstained
+unstapled
+unstaring
+unstated
+unsteadily
+unsteadiness
+unsteady
+unstemmed
+unstinting
+unstintingly
+unstoppable
+unstopped
+unstrained
+unstratified
+unstreamed
+unstressed
+unstriped
+unstructured
+unstrung
+unstuck
+unsubscripted
+unsubstantially
+unsubstantiated
+unsubstituted
+unsuccessful
+unsuccessfully
+unsuffixed
+unsuitability
+unsuitable
+unsuitably
+unsuited
+unsung
+unsupportable
+unsupported
+unsure
+unsurpassed
+unsurprised
+unsurprising
+unsurprisingly
+unsuspected
+unsuspecting
+unsuspended
+unswerving
+unsymmetrically
+unsympathetic
+untamed
+untampered
+untaped
+untapped
+untaught
+untented
+unterminated
+untestable
+untested
+unthematic
+unthinkable
+unthinkably
+unthinkingly
+untidiness
+untidy
+untie
+untied
+unties
+until
+untimeliness
+untimely
+untitled
+unto
+untold
+untouchable
+untouchable's
+untouchables
+untouched
+untoward
+untowardly
+untowardness
+untraceable
+untraced
+untracked
+untrained
+untransformed
+untranslated
+untransposed
+untreated
+untried
+untrod
+untroubled
+untrue
+untruly
+untrusted
+untrustworthiness
+untruth
+untruthful
+untruthfully
+untruthfulness
+untutored
+untwisted
+untying
+untyped
+unusable
+unused
+unusual
+unusually
+unusualness
+unuttered
+unvalued
+unvarnished
+unvarying
+unveil
+unveiled
+unveiling
+unveils
+unventilated
+unverified
+unvisited
+unvoiced
+unwaged
+unwanted
+unwarily
+unwarranted
+unwashed
+unwashedness
+unwatched
+unwavering
+unwaveringly
+unwearied
+unweariedly
+unweighed
+unwelcome
+unwept
+unwholesome
+unwholesomely
+unwieldiness
+unwieldy
+unwilled
+unwilling
+unwillingly
+unwillingness
+unwind
+unwinder
+unwinders
+unwinding
+unwinds
+unwinking
+unwired
+unwise
+unwisely
+unwiser
+unwisest
+unwitnessed
+unwitting
+unwittingly
+unwonted
+unwontedly
+unwontedness
+unworldliness
+unworldly
+unworn
+unworthiness
+unworthy
+unwound
+unwounded
+unwoven
+unwrap
+unwrapped
+unwrapping
+unwraps
+unwrinkled
+unwritable
+unwritten
+unyielded
+unyielding
+unyieldingly
+up
+upbraid
+upbraider
+upbringing
+update
+updated
+updater
+updates
+updating
+upfield
+upgrade
+upgraded
+upgrades
+upgrading
+upheld
+uphill
+uphold
+upholder
+upholders
+upholding
+upholds
+upholster
+upholstered
+upholsterer
+upholsterers
+upholstering
+upholsters
+upkeep
+upland
+uplander
+uplands
+uplift
+uplifted
+uplifter
+uplifting
+uplifts
+upload
+uploaded
+uploading
+uploads
+upon
+upper
+uppermost
+uppers
+upright
+uprightly
+uprightness
+uprising
+uprising's
+uprisings
+uproar
+uproot
+uprooted
+uprooter
+uprooting
+uproots
+ups
+upset
+upsets
+upsetting
+upshot
+upshot's
+upshots
+upside
+upsides
+upstairs
+upstream
+upturn
+upturned
+upturning
+upturns
+upward
+upwardly
+upwardness
+upwards
+urban
+urchin
+urchin's
+urchins
+urge
+urged
+urgent
+urgently
+urger
+urges
+urging
+urgings
+urinate
+urinated
+urinates
+urinating
+urination
+urine
+urn
+urn's
+urning
+urns
+us
+usability
+usable
+usably
+usage
+usages
+use
+used
+useful
+usefully
+usefulness
+useless
+uselessly
+uselessness
+user
+user's
+users
+uses
+usher
+ushered
+ushering
+ushers
+using
+usual
+usually
+usualness
+usurp
+usurped
+usurper
+utensil
+utensil's
+utensils
+utilities
+utility
+utility's
+utmost
+utopian
+utopian's
+utopians
+utter
+utterance
+utterance's
+utterances
+uttered
+utterer
+uttering
+utterly
+uttermost
+utters
+uucp
+uucp's
+vacancies
+vacancy
+vacancy's
+vacant
+vacantly
+vacantness
+vacate
+vacated
+vacates
+vacating
+vacation
+vacationed
+vacationer
+vacationers
+vacationing
+vacations
+vacillate
+vacillated
+vacillates
+vacillating
+vacillatingly
+vacillation
+vacillations
+vacillator
+vacillator's
+vacillators
+vacuo
+vacuous
+vacuously
+vacuousness
+vacuum
+vacuumed
+vacuuming
+vacuums
+vagabond
+vagabond's
+vagabonds
+vagaries
+vagary
+vagary's
+vagina
+vagina's
+vaginas
+vagrant
+vagrantly
+vagrants
+vague
+vaguely
+vagueness
+vaguer
+vaguest
+vainly
+vale
+vale's
+valedictorian
+valedictorian's
+valence
+valence's
+valences
+valentine
+valentine's
+valentines
+vales
+valet
+valet's
+valets
+valiant
+valiantly
+valiantness
+valid
+validate
+validated
+validates
+validating
+validation
+validations
+validity
+validly
+validness
+valley
+valley's
+valleys
+valuable
+valuableness
+valuables
+valuably
+valuation
+valuation's
+valuations
+valuator
+valuators
+value
+valued
+valuer
+valuers
+values
+valuing
+valve
+valve's
+valved
+valves
+valving
+van
+van's
+vane
+vane's
+vaned
+vanes
+vanilla
+vanish
+vanished
+vanisher
+vanishes
+vanishing
+vanishingly
+vanities
+vanity
+vanquish
+vanquished
+vanquisher
+vanquishes
+vanquishing
+vans
+vantage
+vantages
+variability
+variable
+variable's
+variableness
+variables
+variably
+variance
+variance's
+variances
+variant
+variantly
+variants
+variation
+variation's
+variations
+varied
+variedly
+varier
+varies
+varieties
+variety
+variety's
+various
+variously
+variousness
+varnish
+varnish's
+varnished
+varnisher
+varnishers
+varnishes
+varnishing
+vary
+varying
+varyingly
+varyings
+vase
+vase's
+vases
+vassal
+vassals
+vast
+vaster
+vastest
+vastly
+vastness
+vat
+vat's
+vats
+vaudeville
+vault
+vaulted
+vaulter
+vaulting
+vaults
+vaunt
+vaunted
+vaunter
+veal
+vealer
+vealing
+vector
+vector's
+vectored
+vectoring
+vectors
+veer
+veered
+veering
+veeringly
+veers
+vegetable
+vegetable's
+vegetables
+vegetarian
+vegetarian's
+vegetarians
+vegetate
+vegetated
+vegetates
+vegetating
+vegetation
+vegetative
+vegetatively
+vegetativeness
+vehemence
+vehement
+vehemently
+vehicle
+vehicle's
+vehicles
+vehicular
+veil
+veiled
+veiling
+veils
+vein
+veined
+veiner
+veining
+veins
+velocities
+velocity
+velocity's
+velvet
+vend
+vender
+vending
+vendor
+vendor's
+vendors
+venerable
+venerableness
+vengeance
+venison
+venom
+venomous
+venomously
+venomousness
+vent
+vented
+venter
+ventilate
+ventilated
+ventilates
+ventilating
+ventilation
+ventilations
+ventilative
+venting
+ventral
+ventrally
+ventricle
+ventricle's
+ventricles
+vents
+venture
+ventured
+venturer
+venturers
+ventures
+venturing
+venturings
+veracity
+veranda
+veranda's
+verandaed
+verandas
+verb
+verb's
+verbal
+verbally
+verbose
+verbosely
+verboseness
+verbs
+verdict
+verdicts
+verdure
+verdured
+verge
+verger
+verges
+verier
+veriest
+verifiability
+verifiable
+verifiableness
+verification
+verifications
+verified
+verifier
+verifier's
+verifiers
+verifies
+verify
+verifying
+verily
+veritable
+veritableness
+vermin
+versa
+versatile
+versatilely
+versatileness
+versatility
+verse
+versed
+verser
+verses
+versing
+version
+versions
+versus
+vertebrate
+vertebrate's
+vertebrates
+vertebration
+vertex
+vertexes
+vertical
+vertically
+verticalness
+verticals
+vertices
+very
+vessel
+vessel's
+vessels
+vest
+vested
+vestige
+vestige's
+vestiges
+vestigial
+vestigially
+vesting
+vests
+veteran
+veteran's
+veterans
+veterinarian
+veterinarian's
+veterinarians
+veterinary
+veto
+vetoed
+vetoer
+vetoes
+vetoing
+vetting
+vex
+vexation
+vexed
+vexedly
+vexes
+vexing
+vi
+vi's
+via
+viability
+viable
+viably
+vial
+vial's
+vials
+vibrate
+vibrated
+vibrates
+vibrating
+vibration
+vibrations
+vice
+vice's
+viceroy
+vices
+vicing
+vicinities
+vicinity
+vicious
+viciously
+viciousness
+vicissitude
+vicissitude's
+vicissitudes
+victim
+victim's
+victims
+victor
+victor's
+victories
+victorious
+victoriously
+victoriousness
+victors
+victory
+victory's
+victual
+victuals
+video
+videos
+videotape
+videotape's
+videotaped
+videotapes
+videotaping
+vie
+vied
+vier
+vies
+view
+viewable
+viewed
+viewer
+viewers
+viewing
+viewings
+viewpoint
+viewpoint's
+viewpoints
+views
+vigilance
+vigilant
+vigilante
+vigilante's
+vigilantes
+vigilantly
+vignette
+vignette's
+vignetted
+vignetter
+vignettes
+vignetting
+vigorous
+vigorously
+vigorousness
+vii
+viii
+vile
+vilely
+vileness
+viler
+vilest
+vilification
+vilifications
+vilified
+vilifier
+vilifies
+vilify
+vilifying
+villa
+villa's
+village
+village's
+villager
+villagers
+villages
+villain
+villain's
+villainous
+villainously
+villainousness
+villains
+villainy
+villas
+vindictive
+vindictively
+vindictiveness
+vine
+vine's
+vinegar
+vinegars
+vines
+vineyard
+vineyard's
+vineyards
+vining
+vintage
+vintager
+vintages
+violate
+violated
+violates
+violating
+violation
+violations
+violative
+violator
+violator's
+violators
+violence
+violent
+violently
+violet
+violet's
+violets
+violin
+violin's
+violinist
+violinist's
+violinists
+violins
+viper
+viper's
+vipers
+viral
+virally
+virgin
+virgin's
+virginity
+virgins
+virtual
+virtually
+virtue
+virtue's
+virtues
+virtuoso
+virtuoso's
+virtuosos
+virtuous
+virtuously
+virtuousness
+virus
+virus's
+viruses
+vis
+visa
+visaed
+visage
+visaged
+visaing
+visas
+viscosities
+viscosity
+viscount
+viscount's
+viscounts
+viscous
+viscously
+viscousness
+visibilities
+visibility
+visible
+visibleness
+visibly
+vision
+vision's
+visionariness
+visionary
+visioned
+visioning
+visions
+visit
+visitation
+visitation's
+visitations
+visited
+visiting
+visitor
+visitor's
+visitors
+visits
+visor
+visor's
+visored
+visors
+vista
+vista's
+vistaed
+vistas
+visual
+visually
+visuals
+vita
+vitae
+vital
+vitality
+vitally
+vitals
+vitamin
+vitamin's
+vitamins
+vivid
+vividly
+vividness
+vizier
+vocabularies
+vocabulary
+vocal
+vocally
+vocals
+vocation
+vocation's
+vocational
+vocationally
+vocations
+vogue
+voice
+voiced
+voicer
+voicers
+voices
+voicing
+void
+voided
+voider
+voiding
+voidness
+voids
+volatile
+volatileness
+volatiles
+volatilities
+volatility
+volcanic
+volcano
+volcano's
+volcanos
+volley
+volleyball
+volleyball's
+volleyballs
+volleyed
+volleyer
+volleying
+volleys
+volt
+voltage
+voltages
+volts
+volume
+volume's
+volumed
+volumes
+voluming
+voluntarily
+voluntariness
+voluntary
+volunteer
+volunteered
+volunteering
+volunteers
+vomit
+vomited
+vomiter
+vomiting
+vomits
+vortex
+vortexes
+vote
+voted
+voter
+voters
+votes
+voting
+votive
+votively
+votiveness
+vouch
+voucher
+vouchers
+vouches
+vouching
+vow
+vowed
+vowel
+vowel's
+vowels
+vower
+vowing
+vows
+voyage
+voyaged
+voyager
+voyagers
+voyages
+voyaging
+voyagings
+vulgar
+vulgarly
+vulnerabilities
+vulnerability
+vulnerable
+vulnerableness
+vulture
+vulture's
+vultures
+wade
+waded
+wader
+waders
+wades
+wading
+wafer
+wafer's
+wafered
+wafering
+wafers
+waffle
+waffle's
+waffled
+waffles
+waffling
+waft
+wafter
+wag
+wage
+waged
+wager
+wagered
+wagerer
+wagering
+wagers
+wages
+waging
+wagon
+wagon's
+wagons
+wags
+wail
+wailed
+wailer
+wailing
+wails
+waist
+waist's
+waistcoat
+waistcoat's
+waistcoated
+waistcoats
+waisted
+waister
+waists
+wait
+waited
+waiter
+waiter's
+waiters
+waiting
+waitress
+waitress's
+waitresses
+waits
+waive
+waived
+waiver
+waiverable
+waivers
+waives
+waiving
+wake
+waked
+waken
+wakened
+wakener
+wakening
+waker
+wakes
+waking
+walk
+walked
+walker
+walkers
+walking
+walks
+walkway
+walkway's
+walkways
+wall
+wall's
+walled
+waller
+wallet
+wallet's
+wallets
+walling
+wallow
+wallowed
+wallower
+wallowing
+wallows
+walls
+walnut
+walnut's
+walnuts
+walrus
+walrus's
+walruses
+waltz
+waltzed
+waltzer
+waltzes
+waltzing
+wan
+wand
+wander
+wandered
+wanderer
+wanderers
+wandering
+wanderings
+wanders
+wane
+waned
+wanes
+waning
+wanly
+wanness
+want
+wanted
+wanter
+wanting
+wanton
+wantoner
+wantonly
+wantonness
+wants
+war
+war's
+warble
+warbled
+warbler
+warbles
+warbling
+ward
+warded
+warden
+wardens
+warder
+warding
+wardrobe
+wardrobe's
+wardrobes
+wards
+ware
+warehouse
+warehoused
+warehouser
+warehouses
+warehousing
+wares
+warfare
+warier
+wariest
+warily
+wariness
+waring
+warlike
+warm
+warmed
+warmer
+warmers
+warmest
+warming
+warmly
+warmness
+warms
+warmth
+warn
+warned
+warner
+warning
+warningly
+warnings
+warns
+warp
+warp's
+warped
+warper
+warping
+warps
+warrant
+warranted
+warranter
+warranties
+warranting
+warrants
+warranty
+warranty's
+warred
+warring
+warrior
+warrior's
+warriors
+wars
+warship
+warship's
+warships
+wart
+wart's
+warted
+warts
+wary
+was
+wash
+washed
+washer
+washers
+washes
+washing
+washings
+wasn't
+wasp
+wasp's
+wasps
+waste
+wasted
+wasteful
+wastefully
+wastefulness
+waster
+wastes
+wasting
+wastingly
+watch
+watched
+watcher
+watchers
+watches
+watchful
+watchfully
+watchfulness
+watching
+watchings
+watchman
+watchword
+watchword's
+watchwords
+water
+watered
+waterer
+waterfall
+waterfall's
+waterfalls
+wateriness
+watering
+waterings
+waterproof
+waterproofed
+waterproofer
+waterproofing
+waterproofness
+waterproofs
+waters
+waterway
+waterway's
+waterways
+watery
+wave
+waved
+waveform
+waveform's
+waveforms
+wavefront
+wavefront's
+wavefronts
+wavelength
+wavelengths
+waver
+wavered
+waverer
+wavering
+waveringly
+wavers
+waves
+waving
+wax
+waxed
+waxen
+waxer
+waxers
+waxes
+waxier
+waxiness
+waxing
+waxy
+way
+way's
+ways
+wayside
+waysides
+wayward
+waywardly
+waywardness
+we
+we'd
+we'll
+we're
+we've
+weak
+weaken
+weakened
+weakener
+weakening
+weakens
+weaker
+weakest
+weakliness
+weakly
+weakness
+weakness's
+weaknesses
+wealth
+wealthier
+wealthiest
+wealthiness
+wealths
+wealthy
+wean
+weaned
+weaner
+weaning
+weapon
+weapon's
+weaponed
+weapons
+wear
+wearable
+wearer
+wearied
+wearier
+wearies
+weariest
+wearily
+weariness
+wearing
+wearingly
+wearisome
+wearisomely
+wearisomeness
+wears
+weary
+wearying
+weasel
+weasel's
+weasels
+weather
+weathercock
+weathercock's
+weathercocks
+weathered
+weatherer
+weathering
+weatherly
+weathers
+weave
+weaver
+weavers
+weaves
+weaving
+web
+web's
+weber
+webs
+wed
+wedded
+wedding
+wedding's
+weddings
+wedge
+wedged
+wedges
+wedging
+weds
+wee
+weed
+weeded
+weeder
+weeding
+weeds
+week
+week's
+weekday
+weekday's
+weekdays
+weekend
+weekend's
+weekender
+weekends
+weeklies
+weekly
+weeks
+weep
+weeped
+weeper
+weepers
+weeping
+weeps
+weigh
+weighed
+weigher
+weighing
+weighings
+weighs
+weight
+weighted
+weighter
+weighting
+weightings
+weights
+weird
+weirdly
+weirdness
+welcome
+welcomed
+welcomely
+welcomeness
+welcomer
+welcomes
+welcoming
+weld
+welded
+welder
+welders
+welding
+weldings
+welds
+welfare
+well
+welled
+welling
+wellness
+wells
+wench
+wench's
+wencher
+wenches
+went
+wept
+were
+weren't
+west
+wester
+westered
+westering
+westerlies
+westerly
+western
+westerner
+westerners
+westing
+westward
+westwards
+wet
+wetly
+wetness
+wets
+wetted
+wetter
+wettest
+wetting
+whack
+whacked
+whacker
+whacking
+whacks
+whale
+whaler
+whales
+whaling
+whammies
+whammy
+wharf
+wharfs
+wharves
+what
+what's
+whatchamacallit
+whatchamacallit's
+whatchamacallits
+whatever
+whatsoever
+wheat
+wheaten
+wheel
+wheeled
+wheeler
+wheelers
+wheeling
+wheelings
+wheels
+whelp
+when
+whence
+whenever
+whens
+where
+where's
+whereabouts
+whereas
+whereby
+wherein
+whereupon
+wherever
+whether
+whew
+whey
+which
+whichever
+while
+whiled
+whiles
+whiling
+whim
+whim's
+whimper
+whimpered
+whimpering
+whimpers
+whims
+whimsical
+whimsically
+whimsicalness
+whimsied
+whimsies
+whimsy
+whimsy's
+whine
+whined
+whiner
+whines
+whining
+whiningly
+whip
+whip's
+whipped
+whipper
+whipper's
+whippers
+whipping
+whipping's
+whippings
+whips
+whirl
+whirled
+whirler
+whirling
+whirlpool
+whirlpool's
+whirlpools
+whirls
+whirlwind
+whirr
+whirring
+whisk
+whisked
+whisker
+whiskered
+whiskers
+whiskey
+whiskey's
+whiskeys
+whisking
+whisks
+whisper
+whispered
+whisperer
+whispering
+whisperingly
+whisperings
+whispers
+whistle
+whistled
+whistler
+whistlers
+whistles
+whistling
+whit
+white
+whited
+whitely
+whiten
+whitened
+whitener
+whiteners
+whiteness
+whitening
+whitens
+whiter
+whites
+whitespace
+whitest
+whitewash
+whitewashed
+whitewasher
+whitewashing
+whiting
+whittle
+whittled
+whittler
+whittles
+whittling
+whittlings
+whiz
+whizzed
+whizzes
+whizzing
+who
+who's
+whoever
+whole
+wholehearted
+wholeheartedly
+wholeness
+wholes
+wholesale
+wholesaled
+wholesaler
+wholesalers
+wholesales
+wholesaling
+wholesome
+wholesomely
+wholesomeness
+wholly
+whom
+whomever
+whoop
+whooped
+whooper
+whooping
+whoops
+whore
+whore's
+whores
+whoring
+whorl
+whorl's
+whorled
+whorls
+whose
+why
+wick
+wicked
+wickedly
+wickedness
+wicker
+wicking
+wicks
+wide
+widely
+widen
+widened
+widener
+wideness
+widening
+widens
+wider
+widespread
+widest
+widget
+widget's
+widgets
+widow
+widowed
+widower
+widowers
+widows
+width
+widths
+wield
+wielded
+wielder
+wielding
+wields
+wife
+wife's
+wifeliness
+wifely
+wig
+wig's
+wigs
+wigwam
+wild
+wildcat
+wildcat's
+wildcats
+wilder
+wilderness
+wildest
+wilding
+wildly
+wildness
+wile
+wiled
+wiles
+wilier
+wiliness
+wiling
+will
+willed
+willer
+willful
+willfully
+willfulness
+willing
+willingly
+willingness
+willings
+willow
+willow's
+willower
+willows
+wills
+wilt
+wilted
+wilting
+wilts
+wily
+win
+wince
+winced
+winces
+wincing
+wind
+winded
+winder
+winders
+windier
+windiness
+winding
+windmill
+windmill's
+windmilling
+windmills
+window
+window's
+windowed
+windowing
+windows
+winds
+windy
+wine
+wined
+winer
+winers
+wines
+wing
+winged
+winger
+wingers
+winging
+wings
+wining
+wink
+winked
+winker
+winking
+winks
+winner
+winner's
+winners
+winning
+winningly
+winnings
+wins
+winter
+wintered
+winterer
+wintering
+winterly
+winters
+wintrier
+wintriness
+wintry
+wipe
+wiped
+wiper
+wipers
+wipes
+wiping
+wire
+wired
+wireless
+wirer
+wires
+wiretap
+wiretap's
+wiretaps
+wirier
+wiriness
+wiring
+wirings
+wiry
+wisdom
+wisdoms
+wise
+wised
+wisely
+wiseness
+wiser
+wises
+wisest
+wish
+wished
+wisher
+wishers
+wishes
+wishful
+wishfully
+wishfulness
+wishing
+wising
+wisp
+wisp's
+wisps
+wistful
+wistfully
+wistfulness
+wit
+wit's
+witch
+witchcraft
+witches
+witching
+with
+withal
+withdraw
+withdrawal
+withdrawal's
+withdrawals
+withdrawer
+withdrawing
+withdrawn
+withdrawnness
+withdraws
+withdrew
+wither
+withered
+withering
+witheringly
+withers
+withheld
+withhold
+withholder
+withholders
+withholding
+withholdings
+withholds
+within
+without
+withstand
+withstanding
+withstands
+withstood
+witness
+witnessed
+witnesses
+witnessing
+wits
+wittier
+wittiest
+wittiness
+witty
+wives
+wizard
+wizard's
+wizardly
+wizards
+woe
+woeful
+woefully
+woeness
+woke
+wolf
+wolfer
+wolves
+woman
+woman's
+womanhood
+womanliness
+womanly
+womb
+womb's
+wombed
+wombs
+women
+women's
+womens
+won't
+wonder
+wondered
+wonderer
+wonderful
+wonderfully
+wonderfulness
+wondering
+wonderingly
+wonderland
+wonderland's
+wonderment
+wonders
+wondrous
+wondrously
+wondrousness
+wont
+wonted
+wontedly
+wontedness
+wonting
+woo
+wood
+wood's
+woodchuck
+woodchuck's
+woodchucks
+woodcock
+woodcock's
+woodcocks
+wooded
+wooden
+woodenly
+woodenness
+woodier
+woodiness
+wooding
+woodland
+woodlander
+woodman
+woodpecker
+woodpecker's
+woodpeckers
+woods
+woodser
+woodwork
+woodworker
+woodworking
+woody
+wooed
+wooer
+woof
+woofed
+woofer
+woofers
+woofing
+woofs
+wooing
+wool
+wooled
+woolen
+woolens
+woollier
+woollies
+woolliness
+woolly
+wools
+wooly
+woos
+word
+word's
+worded
+wordier
+wordily
+wordiness
+wording
+wordings
+words
+wordy
+wore
+work
+workable
+workableness
+workably
+workaround
+workaround's
+workarounds
+workbench
+workbench's
+workbenches
+workbook
+workbook's
+workbooks
+worked
+worker
+worker's
+workers
+workhorse
+workhorse's
+workhorses
+working
+workingman
+workings
+workload
+workloads
+workman
+workmanly
+workmanship
+workmen
+workmen's
+works
+workshop
+workshop's
+workshops
+workstation
+workstation's
+workstations
+world
+world's
+worlders
+worldliness
+worldly
+worlds
+worldwide
+worm
+wormed
+wormer
+worming
+worms
+worn
+worried
+worriedly
+worrier
+worriers
+worries
+worrisome
+worrisomely
+worrisomeness
+worry
+worrying
+worryingly
+worse
+worser
+worship
+worshipful
+worshipfully
+worshipfulness
+worships
+worst
+worsted
+worth
+worthier
+worthies
+worthiest
+worthiness
+worthing
+worthless
+worthlessly
+worthlessness
+worths
+worthwhile
+worthwhileness
+worthy
+would
+wouldest
+wouldn't
+wound
+wounded
+wounding
+wounds
+wove
+woven
+wrangle
+wrangled
+wrangler
+wranglers
+wrangles
+wrangling
+wrap
+wrap's
+wrapped
+wrapper
+wrapper's
+wrappers
+wrapping
+wrappings
+wraps
+wrath
+wreak
+wreaks
+wreath
+wreathed
+wreathes
+wreathing
+wreck
+wreckage
+wrecked
+wrecker
+wreckers
+wrecking
+wrecks
+wren
+wren's
+wrench
+wrenched
+wrenches
+wrenching
+wrenchingly
+wrens
+wrest
+wrested
+wrester
+wresting
+wrestle
+wrestled
+wrestler
+wrestles
+wrestling
+wrestlings
+wrests
+wretch
+wretched
+wretchedly
+wretchedness
+wretches
+wriggle
+wriggled
+wriggler
+wriggles
+wriggling
+wring
+wringer
+wringing
+wrings
+wrinkle
+wrinkled
+wrinkles
+wrinkling
+wrist
+wrist's
+wrists
+wristwatch
+wristwatch's
+wristwatches
+writ
+writ's
+writable
+write
+writer
+writer's
+writers
+writes
+writhe
+writhed
+writhes
+writhing
+writing
+writings
+writs
+written
+wrong
+wronged
+wronger
+wrongest
+wronging
+wrongly
+wrongness
+wrongs
+wrote
+wrought
+wrung
+xi
+xii
+xiii
+xiv
+xix
+xv
+xvi
+xvii
+xviii
+xx
+yacc
+yacc's
+yank
+yanked
+yanking
+yanks
+yard
+yard's
+yarded
+yarding
+yards
+yardstick
+yardstick's
+yardsticks
+yarn
+yarn's
+yarned
+yarning
+yarns
+yawn
+yawner
+yawning
+yawningly
+yawns
+yea
+yeah
+year
+year's
+yearly
+yearn
+yearned
+yearner
+yearning
+yearningly
+yearnings
+yearns
+years
+yeas
+yeast
+yeast's
+yeasts
+yecch
+yell
+yelled
+yeller
+yelling
+yellow
+yellowed
+yellower
+yellowest
+yellowing
+yellowish
+yellowness
+yellows
+yells
+yelp
+yelped
+yelper
+yelping
+yelps
+yeoman
+yeomanly
+yeomen
+yes
+yeses
+yesterday
+yesterday's
+yesterdays
+yet
+yield
+yielded
+yielder
+yielding
+yields
+yoke
+yoke's
+yokes
+yoking
+yon
+yonder
+you
+you'd
+you'll
+you're
+you've
+young
+younger
+youngest
+youngly
+youngness
+youngster
+youngster's
+youngsters
+your
+your's
+yours
+yourself
+yourselves
+youth
+youth's
+youthes
+youthful
+youthfully
+youthfulness
+yuck
+yummier
+yummy
+yuppie
+yuppie's
+yuppies
+zap
+zapped
+zapping
+zaps
+zeal
+zealous
+zealously
+zealousness
+zebra
+zebra's
+zebras
+zenith
+zero
+zeroed
+zeroes
+zeroing
+zeros
+zeroth
+zest
+zigzag
+zinc
+zinc's
+zodiac
+zodiacs
+zonal
+zonally
+zone
+zoned
+zonely
+zoner
+zones
+zoning
+zoo
+zoo's
+zoological
+zoologically
+zoom
+zoomed
+zooming
+zooms
+zoos
+acclimatization
+acclimatization's
+acclimatizations
+acclimatized
+accouterment
+accouterment's
+accouterments
+acknowledgment
+acknowledgment's
+acknowledgments
+actualization
+actualization's
+actualizations
+aerosolize
+aerosolized
+agonize
+agonized
+agonizedlies
+agonizedly
+agonizer
+agonizers
+agonizes
+agonizing
+agonizingly
+airfoil
+airfoils
+airplane
+airplane's
+airplanes
+alphabetize
+alphabetized
+alphabetizer
+alphabetizers
+alphabetizes
+alphabetizing
+aluminum
+aluminum's
+aluminums
+amenorrhea
+amortize
+amortized
+amortizes
+amortizing
+amphitheater
+amphitheater's
+amphitheaters
+analog
+analog's
+analogs
+analyzable
+analyze
+analyzed
+analyzer
+analyzers
+analyzes
+analyzing
+anemia
+anemia's
+anemias
+anemic
+anemics
+anesthesia
+anesthesia's
+anesthesias
+anesthetic
+anesthetic's
+anesthetically
+anesthetics
+anesthetize
+anesthetized
+anesthetizer
+anesthetizer's
+anesthetizers
+anesthetizes
+anesthetizing
+anodize
+anodized
+anodizes
+anodizing
+antagonize
+antagonized
+antagonizer
+antagonizers
+antagonizes
+antagonizing
+apologize
+apologized
+apologizer
+apologizers
+apologizes
+apologizing
+appall
+appalls
+appareled
+appetizer
+appetizing
+appetizingly
+arbor
+arbor's
+arbored
+arbors
+archaize
+archaized
+archaizer
+archaizers
+archaizes
+archaizing
+ardor
+ardor's
+ardors
+arithmetize
+arithmetized
+arithmetizes
+armor
+armor's
+armored
+armorer
+armorer's
+armorers
+armoried
+armories
+armoring
+armors
+armory
+armory's
+atomization
+atomization's
+atomizations
+atomize
+atomized
+atomizer
+atomizers
+atomizes
+atomizing
+authorization
+authorization's
+authorizations
+authorize
+authorized
+authorizer
+authorizers
+authorizes
+authorizing
+autodialer
+axiomatization
+axiomatization's
+axiomatizations
+axiomatize
+axiomatized
+axiomatizes
+axiomatizing
+balkanize
+balkanized
+balkanizing
+baptize
+baptized
+baptizer
+baptizers
+baptizes
+baptizing
+barreled
+barreling
+bastardize
+bastardized
+bastardizes
+bastardizing
+bedeviled
+bedeviling
+behavior
+behavior's
+behavioral
+behaviorally
+behaviored
+behaviorism
+behaviorism's
+behaviorisms
+behavioristic
+behavioristics
+behaviors
+behoove
+behoove's
+behooved
+behooves
+behooving
+behooving's
+behoovingly
+behoovings
+belabor
+belabor's
+belabored
+belaboring
+belabors
+beveled
+beveling
+bevelings
+bowdlerize
+bowdlerized
+bowdlerizer
+bowdlerizes
+bowdlerizing
+brutalize
+brutalized
+brutalizes
+brutalizing
+burglarize
+burglarized
+burglarizes
+burglarizing
+busheled
+busheling
+bushelings
+caliber
+calibers
+canaled
+canaling
+canceled
+canceler
+canceling
+candor
+candor's
+candors
+cannibalize
+cannibalized
+cannibalizes
+cannibalizing
+canonicalization
+canonicalize
+canonicalized
+canonicalizes
+canonicalizing
+capitalization
+capitalization's
+capitalizations
+capitalize
+capitalized
+capitalizer
+capitalizers
+capitalizes
+capitalizing
+carbonization
+carbonization's
+carbonizations
+carbonize
+carbonized
+carbonizer
+carbonizers
+carbonizes
+carbonizing
+catalog
+catalog's
+cataloged
+cataloger
+cataloging
+catalogs
+categorization
+categorization's
+categorizations
+categorize
+categorized
+categorizer
+categorizers
+categorizes
+categorizing
+center
+center's
+centered
+centerer
+centerers
+centering
+centerings
+centerpiece
+centerpiece's
+centerpieces
+centers
+centimeter
+centimeter's
+centimeters
+centralization
+centralization's
+centralizations
+centralize
+centralized
+centralizer
+centralizers
+centralizes
+centralizing
+channeled
+channeler
+channeler's
+channelers
+channeling
+characterizable
+characterizable's
+characterizables
+characterization
+characterization's
+characterizations
+characterize
+characterized
+characterizer
+characterizers
+characterizes
+characterizing
+checkbook
+checkbook's
+checkbooks
+chiseled
+chiseler
+chiselers
+civilization
+civilization's
+civilizations
+civilize
+civilized
+civilizedness
+civilizer
+civilizers
+civilizes
+civilizing
+clamor
+clamored
+clamorer
+clamorer's
+clamorers
+clamoring
+clamors
+cognizance
+cognizant
+colonization
+colonization's
+colonizations
+colonize
+colonized
+colonizer
+colonizers
+colonizes
+colonizing
+color
+color's
+colored
+coloreds
+colorer
+colorer's
+colorers
+colorful
+colorfully
+colorfulness
+coloring
+colorings
+colorless
+colorlessly
+colorlessness
+colors
+columnize
+columnized
+columnizes
+columnizing
+compartmentalize
+compartmentalized
+compartmentalizes
+compartmentalizing
+computerize
+computerized
+computerizes
+computerizing
+conceptualization
+conceptualization's
+conceptualizations
+conceptualize
+conceptualized
+conceptualizer
+conceptualizes
+conceptualizing
+counseled
+counseling
+counselor
+counselor's
+counselors
+criticize
+criticized
+criticizer
+criticizers
+criticizes
+criticizing
+criticizinglies
+criticizingly
+crystallize
+crystallized
+crystallizer
+crystallizers
+crystallizes
+crystallizing
+customizable
+customization
+customization's
+customizations
+customize
+customized
+customizer
+customizers
+customizes
+customizing
+decentralization
+decentralization's
+decentralizations
+decentralized
+defense
+defense's
+defensed
+defenseless
+defenselessly
+defenselessness
+defenses
+defensing
+demeanor
+demeanor's
+demeanors
+demoralize
+demoralized
+demoralizer
+demoralizers
+demoralizes
+demoralizing
+demoralizingly
+dialed
+dialer
+dialers
+dialing
+dialings
+dichotomize
+dichotomized
+dichotomizes
+dichotomizing
+digitize
+digitized
+digitizer
+digitizer's
+digitizers
+digitizes
+digitizing
+dishonor
+dishonored
+dishonorer
+dishonorer's
+dishonorers
+dishonoring
+dishonors
+disorganized
+draftsman
+dueled
+dueler
+duelers
+dueling
+duelings
+economize
+economized
+economizer
+economizers
+economizes
+economizing
+editorialize
+editorialized
+editorializer
+editorializes
+editorializing
+enameled
+enameler
+enamelers
+enameling
+enamelings
+endeavor
+endeavor's
+endeavored
+endeavorer
+endeavorer's
+endeavorers
+endeavoring
+endeavors
+enroll
+enrollment
+enrollment's
+enrollments
+enrolls
+epitomize
+epitomized
+epitomizer
+epitomizers
+epitomizes
+epitomizing
+equaled
+equaling
+equalization
+equalization's
+equalizations
+equalize
+equalized
+equalizer
+equalizer's
+equalizers
+equalizes
+equalizing
+equalizings
+esthetic
+esthetic's
+esthetically
+esthetics
+eviler
+evilest
+factorization
+factorization's
+factorizations
+familiarization
+familiarization's
+familiarizations
+familiarize
+familiarized
+familiarizer
+familiarizers
+familiarizes
+familiarizing
+familiarizingly
+fantasize
+fantasized
+fantasizer
+fantasizes
+fantasizing
+favor
+favor's
+favorable
+favorable's
+favorableness
+favorables
+favorably
+favored
+favored's
+favoredly
+favoredness
+favoreds
+favorer
+favorer's
+favorers
+favoring
+favoring's
+favoringly
+favorings
+favorite
+favorite's
+favorites
+favors
+fertilization
+fertilization's
+fertilizations
+fertilize
+fertilized
+fertilizer
+fertilizers
+fertilizes
+fertilizing
+fervor
+fervor's
+fervors
+fiber
+fiber's
+fibered
+fiberglass
+fibers
+finalization
+finalizations
+finalize
+finalized
+finalizes
+finalizing
+flavor
+flavor's
+flavored
+flavorer
+flavorer's
+flavorers
+flavoring
+flavorings
+flavors
+formalization
+formalization's
+formalizations
+formalize
+formalized
+formalizer
+formalizers
+formalizes
+formalizing
+fueled
+fueler
+fuelers
+fueling
+fulfill
+fulfillment
+fulfillment's
+fulfillments
+fulfills
+funneled
+funneling
+generalization
+generalization's
+generalizations
+generalize
+generalized
+generalizer
+generalizers
+generalizes
+generalizing
+glamorize
+glamorized
+glamorizer
+glamorizers
+glamorizes
+glamorizing
+gospeler
+gospelers
+gossiped
+gossiping
+gram
+gram's
+grams
+graveled
+graveling
+groveled
+groveler
+grovelers
+groveling
+grovelingly
+harbor
+harbor's
+harbored
+harborer
+harborer's
+harborers
+harboring
+harbors
+harmonize
+harmonized
+harmonizer
+harmonizers
+harmonizes
+harmonizing
+honor
+honorable
+honorable's
+honorableness
+honorables
+honorablies
+honorably
+honored
+honorer
+honorer's
+honorers
+honoring
+honors
+hospitalize
+hospitalized
+hospitalizes
+hospitalizing
+humor
+humor's
+humored
+humorer
+humorers
+humoring
+humors
+hypothesize
+hypothesized
+hypothesizer
+hypothesizers
+hypothesizes
+hypothesizing
+idealization
+idealization's
+idealizations
+idealize
+idealized
+idealizer
+idealizers
+idealizes
+idealizing
+imperiled
+incognizance
+incognizant
+individualize
+individualized
+individualizer
+individualizers
+individualizes
+individualizing
+individualizingly
+industrialization
+industrialization's
+industrializations
+informalizes
+initialed
+initialer
+initialing
+initialization
+initialization's
+initializations
+initialize
+initialized
+initializer
+initializers
+initializes
+initializing
+institutionalize
+institutionalized
+institutionalizes
+institutionalizing
+internalization
+internalization's
+internalizations
+internalize
+internalized
+internalizes
+internalizing
+italicize
+italicized
+italicizes
+italicizing
+itemization
+itemization's
+itemizations
+itemize
+itemized
+itemizer
+itemizers
+itemizes
+itemizing
+jeopardize
+jeopardized
+jeopardizes
+jeopardizing
+jeweled
+jeweler
+jewelers
+jeweling
+journalize
+journalized
+journalizer
+journalizers
+journalizes
+journalizing
+judgment
+judgment's
+judgments
+kidnaped
+kidnaper
+kidnaper's
+kidnapers
+kidnaping
+kidnaping's
+kidnapings
+kilogram
+kilogram's
+kilograms
+kilometer
+kilometer's
+kilometers
+labeled
+labeler
+labeler's
+labelers
+labeling
+labor
+labored
+labored's
+laboredly
+laboredness
+laborer
+laborer's
+laborers
+laboring
+laboring's
+laboringly
+laborings
+labors
+laureled
+legalization
+legalization's
+legalizations
+legalize
+legalized
+legalizes
+legalizing
+leveled
+leveler
+levelers
+levelest
+leveling
+liberalize
+liberalized
+liberalizer
+liberalizers
+liberalizes
+liberalizing
+license's
+linearizable
+linearize
+linearized
+linearizes
+linearizing
+linearizion
+liter
+liters
+localization
+localization's
+localizations
+localize
+localized
+localizer
+localizers
+localizes
+localizing
+luster
+lustered
+lustering
+lusters
+magnetization
+magnetization's
+magnetizations
+maneuver
+maneuvered
+maneuverer
+maneuvering
+maneuvers
+marveled
+marveling
+marvelous
+marvelously
+marvelousness
+materialize
+materialized
+materializer
+materializers
+materializes
+materializing
+maximize
+maximized
+maximizer
+maximizers
+maximizes
+maximizing
+mechanization
+mechanization's
+mechanizations
+mechanize
+mechanized
+mechanizer
+mechanizers
+mechanizes
+mechanizing
+medaled
+medaling
+memorization
+memorization's
+memorizations
+memorize
+memorized
+memorizer
+memorizers
+memorizes
+memorizing
+metaled
+metaling
+millimeter
+millimeter's
+millimeters
+miniaturization
+miniaturizations
+miniaturize
+miniaturized
+miniaturizes
+miniaturizing
+minimization
+minimization's
+minimizations
+minimize
+minimized
+minimizer
+minimizers
+minimizes
+minimizing
+misjudgment
+misjudgment's
+misjudgments
+miter
+mitered
+miterer
+mitering
+modeled
+modeler
+modelers
+modeling
+modelings
+modernize
+modernized
+modernizer
+modernizers
+modernizes
+modernizing
+modularization
+modularize
+modularized
+modularizes
+modularizing
+motorize
+motorized
+motorizes
+motorizing
+multileveled
+mustache
+mustached
+mustaches
+nationalization
+nationalization's
+nationalizations
+nationalize
+nationalized
+nationalizer
+nationalizers
+nationalizes
+nationalizing
+naturalization
+naturalization's
+naturalizations
+neighbor
+neighbor's
+neighbored
+neighborer
+neighborer's
+neighborers
+neighborhood
+neighborhood's
+neighborhoods
+neighboring
+neighborings
+neighborliness
+neighborly
+neighbors
+neutralize
+neutralized
+neutralizer
+neutralizers
+neutralizes
+neutralizing
+nickeled
+nickeling
+normalization
+normalization's
+normalizations
+normalize
+normalized
+normalizer
+normalizers
+normalizes
+normalizing
+notarize
+notarized
+notarizes
+notarizing
+odor
+odor's
+odored
+odors
+offense
+offense's
+offenses
+optimization
+optimization's
+optimizations
+optimize
+optimized
+optimizer
+optimizer's
+optimizers
+optimizes
+optimizing
+organizable
+organizable's
+organizables
+organization
+organization's
+organizational
+organizational's
+organizationally
+organizationals
+organizations
+organize
+organized
+organizer
+organizers
+organizes
+organizing
+oxidize
+oxidized
+oxidizer
+oxidizers
+oxidizes
+oxidizing
+oxidizings
+pajama
+pajama's
+pajamaed
+pajamas
+paneled
+paneling
+panelings
+paralleled
+paralleling
+parallelization
+parallelization's
+parallelizations
+parallelize
+parallelized
+parallelizer
+parallelizers
+parallelizes
+parallelizing
+paralyze
+paralyzed
+paralyzedlies
+paralyzedly
+paralyzer
+paralyzer's
+paralyzers
+paralyzes
+paralyzing
+paralyzinglies
+paralyzingly
+parameterizable
+parameterization
+parameterization's
+parameterizations
+parameterize
+parameterized
+parameterizes
+parameterizing
+parceled
+parceling
+parenthesized
+parlor
+parlor's
+parlors
+patronize
+patronized
+patronizer
+patronizers
+patronizes
+patronizing
+patronizing's
+patronizingly
+patronizings
+penalize
+penalized
+penalizes
+penalizing
+penciled
+penciling
+pencilings
+personalization
+personalization's
+personalizations
+personalize
+personalized
+personalizes
+personalizing
+petaled
+philosophize
+philosophized
+philosophizer
+philosophizers
+philosophizes
+philosophizing
+plow
+plowed
+plower
+plowing
+plowman
+plows
+pluralization
+pluralization's
+pluralizations
+pluralize
+pluralized
+pluralizer
+pluralizers
+pluralizes
+pluralizing
+polarization
+polarization's
+polarizations
+popularization
+popularization's
+popularizations
+popularize
+popularized
+popularizer
+popularizers
+popularizes
+popularizing
+practiced
+practicer
+practicing
+preinitialize
+preinitialized
+preinitializes
+preinitializing
+pressurize
+pressurized
+pressurizer
+pressurizers
+pressurizes
+pressurizing
+pretense
+pretenses
+pretension
+pretensions
+pretensive
+prioritize
+prioritized
+prioritizer
+prioritizers
+prioritizes
+prioritizing
+prioritizings
+productize
+productized
+productizer
+productizers
+productizes
+productizing
+proselytize
+proselytized
+proselytizer
+proselytizers
+proselytizes
+proselytizing
+publicize
+publicized
+publicizes
+publicizing
+pulverize
+pulverized
+pulverizer
+pulverizers
+pulverizes
+pulverizing
+quantization
+quantization's
+quantizations
+quantize
+quantized
+quantizer
+quantizer's
+quantizers
+quantizes
+quantizing
+quarreled
+quarreler
+quarrelers
+quarreling
+queuing
+randomize
+randomized
+randomizer
+randomizes
+randomizing
+rationalize
+rationalized
+rationalizer
+rationalizers
+rationalizes
+rationalizing
+reacclimatization
+reacclimatization's
+reacclimatizations
+reacknowledgment
+reacknowledgment's
+reacknowledgments
+reactualization
+reactualization's
+reactualizations
+reanalyze
+reanalyzed
+reanalyzer
+reanalyzers
+reanalyzes
+reanalyzing
+reapologizes
+reauthorization
+reauthorization's
+reauthorizations
+reauthorizes
+rebrutalizes
+recapitalization
+recapitalization's
+recapitalizations
+recapitalized
+recapitalizes
+recarbonization
+recarbonization's
+recarbonizations
+recarbonizer
+recarbonizers
+recarbonizes
+recategorized
+recentralization
+recentralization's
+recentralizations
+recentralizes
+recivilization
+recivilization's
+recivilizations
+recivilizes
+recognizability
+recognizable
+recognizably
+recognizance
+recognize
+recognized
+recognizedlies
+recognizedly
+recognizer
+recognizers
+recognizes
+recognizing
+recognizinglies
+recognizingly
+recolonization
+recolonization's
+recolonizations
+recolonizes
+recolored
+recolors
+reconceptualizing
+recriticizes
+recrystallized
+recrystallizes
+redialed
+refavors
+refertilization
+refertilization's
+refertilizations
+refertilizes
+refueled
+refueling
+reharmonizes
+rehonors
+reinitialize
+reinitialized
+reinitializes
+reinitializing
+reitemizes
+relabeled
+relabeler
+relabelers
+relabeling
+remagnetization
+remagnetization's
+remagnetizations
+rematerializes
+rememorizes
+remodeled
+remodeling
+renormalized
+renormalizes
+reorganization
+reorganization's
+reorganizations
+reorganize
+reorganized
+reorganizer
+reorganizers
+reorganizes
+reorganizing
+reoxidizes
+repatronizes
+reprogram
+reprograms
+repulverizes
+resepulchers
+restandardization
+restandardization's
+restandardizations
+restandardizes
+resterilizes
+resymbolization
+resymbolization's
+resymbolizations
+resymbolizes
+resynchronizations
+resynchronized
+resynchronizes
+resynthesizes
+retranquilizes
+reutilization
+reutilizes
+reveled
+reveler
+revelers
+reveling
+revelings
+revisualizes
+revolutionize
+revolutionized
+revolutionizer
+revolutionizers
+revolutionizes
+revolutionizing
+rigor
+rigor's
+rigors
+rivaled
+rivaling
+ruble
+ruble's
+rubles
+rumor
+rumor's
+rumored
+rumorer
+rumorer's
+rumorers
+rumoring
+rumors
+saber
+saber's
+sabered
+sabering
+sabers
+sanitize
+sanitized
+sanitizer
+sanitizes
+sanitizing
+savior
+savior's
+saviors
+savor
+savored
+savorer
+savorer's
+savorers
+savorier
+savories
+savoriest
+savoriness
+savoring
+savoringlies
+savoringly
+savors
+savory
+savory's
+scepter
+scepter's
+sceptered
+sceptering
+scepters
+scrutinize
+scrutinized
+scrutinizer
+scrutinizers
+scrutinizes
+scrutinizing
+scrutinizinglies
+scrutinizingly
+sepulcher
+sepulcher's
+sepulchered
+sepulchers
+sequentialize
+sequentialized
+sequentializes
+sequentializing
+serialization
+serialization's
+serializations
+serialize
+serialized
+serializes
+serializing
+shoveled
+shoveler
+shovelers
+shoveling
+shriveled
+shriveling
+signaled
+signaler
+signalers
+signaling
+siphon
+siphon's
+siphoned
+siphoning
+siphons
+socialize
+socialized
+socializer
+socializes
+socializing
+specialization
+specialization's
+specializations
+specialize
+specialized
+specializer
+specializers
+specializes
+specializing
+specialties
+specialty
+specialty's
+specter
+specter's
+spectered
+specters
+spiraled
+spiraling
+splendor
+splendor's
+splendors
+squirreled
+squirreling
+stabilize
+stabilized
+stabilizer
+stabilizers
+stabilizes
+stabilizing
+standardization
+standardization's
+standardizations
+standardize
+standardized
+standardizer
+standardizers
+standardizes
+standardizing
+stenciled
+stenciler
+stencilers
+stenciling
+sterilization
+sterilization's
+sterilizations
+sterilize
+sterilized
+sterilizer
+sterilizers
+sterilizes
+sterilizing
+stylized
+subsidize
+subsidized
+subsidizer
+subsidizers
+subsidizes
+subsidizing
+succor
+succored
+succorer
+succorer's
+succorers
+succoring
+succors
+summarization
+summarization's
+summarizations
+summarize
+summarized
+summarizer
+summarizers
+summarizes
+summarizing
+symboled
+symboling
+symbolization
+symbolization's
+symbolizations
+symbolize
+symbolized
+symbolizer
+symbolizers
+symbolizes
+symbolizing
+sympathize
+sympathized
+sympathizer
+sympathizers
+sympathizes
+sympathizing
+sympathizing's
+sympathizingly
+sympathizings
+synchronization
+synchronization's
+synchronizations
+synchronize
+synchronized
+synchronizer
+synchronizers
+synchronizes
+synchronizing
+synthesize
+synthesized
+synthesizer
+synthesizers
+synthesizes
+synthesizing
+systematize
+systematized
+systematizer
+systematizers
+systematizes
+systematizing
+tantalize
+tantalized
+tantalizer
+tantalizers
+tantalizes
+tantalizing
+tantalizinglies
+tantalizingly
+tantalizingness
+tantalizingnesses
+terrorize
+terrorized
+terrorizer
+terrorizers
+terrorizes
+terrorizing
+theater
+theater's
+theaters
+theorization
+theorization's
+theorizations
+theorize
+theorized
+theorizer
+theorizers
+theorizes
+theorizing
+tire's
+titer
+titers
+totaled
+totaler
+totaler's
+totalers
+totaling
+toweled
+toweling
+towelings
+tranquilize
+tranquilized
+tranquilizer
+tranquilizer's
+tranquilizers
+tranquilizes
+tranquilizing
+tranquilizing's
+tranquilizingly
+tranquilizings
+transistorize
+transistorized
+transistorizes
+transistorizing
+traveled
+traveler
+traveler's
+travelers
+traveling
+travelings
+trivialize
+trivialized
+trivializes
+trivializing
+troweler
+trowelers
+tumor
+tumor's
+tumored
+tumors
+tunneled
+tunneler
+tunnelers
+tunneling
+tunnelings
+unacclimatized
+unamortized
+unanalyzable
+unanalyzed
+unantagonized
+unantagonizing
+unapologizing
+unappetizing
+unappetizingly
+unarmored
+unauthorized
+unauthorizedly
+unauthorizedness
+unauthorizes
+unbaptized
+unbaptizes
+unbastardized
+unbrutalized
+unbrutalizes
+uncanceled
+uncapitalized
+uncategorized
+uncharacterized
+uncivilized
+uncivilizedly
+uncivilizedness
+uncivilizes
+uncolonized
+uncolonizes
+uncolored
+uncoloredly
+uncoloredness
+uncoloreds
+uncriticized
+uncriticizing
+uncriticizingly
+uncrystallized
+undefenses
+undishonored
+undisorganized
+uneconomizing
+unendeavored
+unepitomized
+unequaled
+unequalized
+unequalizes
+unfamiliarized
+unfavorable
+unfavorable's
+unfavorableness
+unfavorables
+unfavorably
+unfavored
+unfavored's
+unfavorings
+unfavorite
+unfavorite's
+unfavorites
+unfertilized
+unflavored
+unformalized
+ungeneralized
+unharmonized
+unharmonizes
+unhonorables
+unhonorablies
+unhonorably
+unhonored
+unhumored
+unidealized
+unindividualized
+unindividualizes
+uninitialized
+unionization
+unionize
+unionized
+unionizer
+unionizers
+unionizes
+unionizing
+unitalicized
+unitemized
+unjournalized
+unlabeled
+unlabored
+unlabored's
+unlaborings
+unlegalized
+unleveled
+unleveling
+unliberalized
+unlocalized
+unlocalizes
+unmechanized
+unmechanizes
+unmemorized
+unminimized
+unmodernized
+unmodernizes
+unmotorized
+unnationalized
+unneighbored
+unneighborliness
+unneighborly
+unneutralized
+unnormalized
+unnormalizes
+unoptimized
+unoptimizes
+unorganizable
+unorganizable's
+unorganizables
+unorganized
+unorganizedly
+unorganizedness
+unoxidized
+unparalleled
+unparameterized
+unparceled
+unpatronized
+unpatronizing's
+unpenalized
+unphilosophized
+unphilosophizes
+unpopularizes
+unpracticed
+unpulverized
+unpulverizes
+unraveled
+unraveling
+unrecognizable
+unrecognized
+unrecognizing
+unrecognizingly
+unreorganized
+unrivaled
+unrumored
+unsabered
+unsavored
+unsavoredly
+unsavoredness
+unscepters
+unscrutinized
+unscrutinizing
+unscrutinizingly
+unsepulchers
+unsiphons
+unsocialized
+unspecialized
+unspecializing
+unstandardized
+unsterilized
+unsubsidized
+unsuccored
+unsummarized
+unsymbolized
+unsympathized
+unsympathizing
+unsympathizing's
+unsympathizingly
+unsympathizings
+unsynchronized
+unsynthesized
+unsystematized
+unsystematizedly
+unsystematizing
+untantalized
+unterrorized
+untranquilized
+unverbalized
+unvictimized
+unvisualized
+unwomanized
+unwomanizes
+utilization
+utilize
+utilized
+utilizer
+utilizers
+utilizes
+utilizing
+valor
+valor's
+valors
+vandalize
+vandalized
+vandalizes
+vandalizing
+vapor
+vapor's
+vapored
+vaporer
+vaporer's
+vaporers
+vaporing
+vaporing's
+vaporingly
+vaporings
+vapors
+vectorization
+vectorizing
+verbalize
+verbalized
+verbalizer
+verbalizers
+verbalizes
+verbalizing
+victimize
+victimized
+victimizer
+victimizers
+victimizes
+victimizing
+victualer
+victualers
+vigor
+vigor's
+vigors
+visualize
+visualized
+visualizer
+visualizers
+visualizes
+visualizing
+wagoner
+wagoner's
+wagoners
+weaseled
+weaseling
+womanize
+womanized
+womanizer
+womanizers
+womanizes
+womanizing
+worshiped
+worshiper
+worshiper's
+worshipers
+worshiping
+Christianizing
+Europeanization
+Europeanization's
+Europeanizations
+Europeanized
+Sanskritize
+acclimatize
+acclimatizer
+acclimatizers
+acclimatizes
+acclimatizing
+actualize
+actualized
+actualizes
+actualizing
+aggrandizement
+aggrandizement's
+aggrandizements
+americanized
+amortization
+amortization's
+amortizations
+animized
+annualized
+asshole
+asshole's
+assholes
+balkanization
+biosynthesized
+bucketfuls
+bureaucratization
+bureaucratization's
+bureaucratizations
+caliper
+calipers
+cancelate
+cancelated
+canonized
+cauterize
+cauterized
+cauterizes
+cauterizing
+caviler
+cavilers
+centerline
+centerlines
+civilizational
+civilizational's
+civilizationals
+cognizable
+colorimeter
+colorimeter's
+colorimeters
+colorimetry
+commercialization
+commercialization's
+commercializations
+communize
+communized
+communizes
+communizing
+computerization
+conventionalized
+crystallization
+crystallization's
+crystallizations
+decentralizing
+deemphasize
+deemphasized
+deemphasizer
+deemphasizers
+deemphasizes
+deemphasizing
+deglycerolized
+dehumanize
+dehumanized
+dehumanizes
+dehumanizing
+demineralization
+demineralization's
+demineralizations
+democratization
+democratization's
+democratizations
+democratize
+democratized
+democratizer
+democratizes
+democratizing
+demoralization
+demoralization's
+demoralizations
+demythologization
+demythologize
+demythologized
+demythologizer
+demythologizes
+demythologizing
+depersonalization
+depersonalization's
+depersonalizations
+depersonalized
+deputized
+destabilize
+destabilized
+destabilizes
+destabilizing
+destigmatization
+desynchronize
+desynchronized
+desynchronizes
+desynchronizing
+detribalize
+detribalized
+detribalizes
+detribalizing
+diagonalizable
+dialyzed
+diarrhea
+diarrhea's
+diarrheal
+diarrheas
+dichotomization
+digitalization
+digitalization's
+digitalizations
+digitization
+diopter
+discolored
+discolored's
+discoloredness
+discoloreds
+discolors
+disfavor
+disfavored
+disfavorer
+disfavorer's
+disfavorers
+disfavoring
+disfavors
+disheveled
+disorganization
+disorganization's
+disorganizations
+doweling
+downdraft
+draftier
+draftiness
+draftsperson
+drafty
+dramatization
+dramatization's
+dramatizations
+dramatize
+dramatized
+dramatizer
+dramatizers
+dramatizes
+dramatizing
+duelist
+duelists
+dynamized
+edema
+edema's
+edemas
+edematous
+emphasize
+emphasized
+emphasizer
+emphasizers
+emphasizes
+emphasizing
+energized
+energizes
+enthrall
+enthralls
+epicenter
+epicenter's
+epicenters
+esthete
+esthetes
+eulogize
+eulogized
+eulogizer
+eulogizers
+eulogizes
+eulogizing
+exorcize
+exorcized
+exorcizes
+exorcizing
+extemporize
+extemporized
+extemporizer
+extemporizers
+extemporizes
+extemporizing
+externalization
+externalization's
+externalizations
+favoritism
+favoritism's
+favoritisms
+federalize
+federalized
+federalizes
+federalizing
+fetid
+fetidly
+fetidness
+fetus
+fetus's
+fetuses
+fiberboard
+fossilized
+fraternize
+fraternized
+fraternizer
+fraternizers
+fraternizes
+fraternizing
+galvanizing
+generalizable
+generalizable's
+generalizables
+germanized
+gimbaled
+glottalization
+glycerolized
+grueling
+gruelingly
+gynecological
+gynecological's
+gynecologicals
+gynecologist
+gynecologist's
+gynecologists
+harmonization
+harmonization's
+harmonizations
+homeomorph
+homeopath
+homogenization
+homogenization's
+homogenizations
+homogenize
+homogenized
+homogenizer
+homogenizers
+homogenizes
+homogenizing
+honoree
+hospitalization
+hospitalization's
+hospitalizations
+humanize
+humanized
+humanizer
+humanizers
+humanizes
+humanizing
+hydrolyzed
+hypnotized
+hypophysectomized
+idolize
+idolized
+idolizer
+idolizers
+idolizes
+idolizing
+immobilize
+immobilized
+immobilizer
+immobilizes
+immobilizing
+immortalized
+immunization
+immunization's
+immunizations
+impersonalized
+industrialized
+industrializing
+inhumanizes
+institutionalization
+institutionalization's
+institutionalizations
+internationalization
+internationalization's
+internationalizations
+internationalized
+ionize
+ionized
+ionizer
+ionizers
+ionizes
+ionizing
+ionizings
+ionizion
+ionizions
+kinesthesis
+kinesthetic
+kinesthetically
+kinesthetics
+legitimize
+legitimized
+legitimizer
+legitimizes
+legitimizing
+libeler
+libelers
+libelous
+libelously
+liberalization
+liberalization's
+liberalizations
+licensable
+lionize
+lionized
+lionizer
+lionizers
+lionizes
+lionizing
+magnetized
+maneuverability
+maneuverable
+marbleized
+marbleizing
+maximization
+maximization's
+maximizations
+memorialized
+mesmerized
+metabolized
+metalization
+metalization's
+metalizations
+metropolitanization
+milligram
+milligram's
+milligrams
+milliliter
+milliliter's
+milliliters
+mineralized
+misbehavior
+misbehavior's
+misbehaviors
+misdemeanor
+misdemeanor's
+misdemeanors
+mobilization
+mobilization's
+mobilizations
+mobilize
+mobilized
+mobilizer
+mobilizes
+mobilizing
+modernization
+modernization's
+modernizations
+monetization
+monetize
+monetized
+monetizes
+monetizing
+monopolization
+monopolization's
+monopolizations
+monopolize
+monopolized
+monopolizer
+monopolizers
+monopolizes
+monopolizing
+multicolor
+multicolor's
+multicolored
+multicolors
+narcotizes
+nasalization
+nasalization's
+nasalizations
+nasalized
+naturalized
+neutralization
+neutralization's
+neutralizations
+nominalized
+novelized
+ocher
+ocher's
+ochers
+operationalization
+operationalizations
+operationalize
+operationalized
+orthogonalization
+orthogonalized
+orthopedic
+orthopedics
+ostracized
+outmaneuver
+outmaneuvered
+outmaneuvering
+outmaneuvers
+overemphasize
+overemphasized
+overemphasizer
+overemphasizers
+overemphasizes
+overemphasizing
+palatalization
+palatalize
+palatalized
+palatalizes
+palatalizing
+palletized
+panelization
+panelized
+parenthesize
+parenthesizes
+parenthesizing
+pasteurization
+pasteurizations
+pedaled
+pedaling
+peptizing
+platinize
+platinized
+platinizes
+platinizing
+plowshare
+plowshare's
+plowshares
+polarize
+polarized
+polarizer
+polarizers
+polarizes
+polarizing
+politicized
+polymerizations
+proletarianization
+proletarianized
+pronominalization
+pronominalize
+pummeled
+pyorrhea
+pyorrhea's
+pyorrheas
+pyrolyze
+pyrolyze's
+pyrolyzer
+pyrolyzes
+radiopasteurization
+radiosterilization
+radiosterilized
+rancor
+rancor's
+rancors
+randomization
+randomization's
+randomizations
+rationalization
+rationalization's
+rationalizations
+reacclimatizes
+reactualizes
+realizabilities
+realizability
+realizability's
+reconceptualization
+recrystallization
+recrystallization's
+recrystallizations
+recrystallize
+recrystallizing
+reemphasize
+reemphasized
+reemphasizer
+reemphasizers
+reemphasizes
+reemphasizing
+regularizing
+reharmonization
+rehumanizes
+remobilization
+remobilization's
+remobilizations
+remobilizes
+remonetization
+remonetize
+remonetized
+remonetizes
+remonetizing
+repopularize
+revaporization
+revaporization's
+revaporizations
+revisualization
+revisualization's
+revisualizations
+revitalization
+revitalize
+revitalized
+revitalizer
+revitalizers
+revitalizes
+revitalizing
+ritualized
+romanticize
+romanticizes
+romanticizing
+rubberized
+satirizes
+scandalized
+scandalizing
+sectionalized
+secularization
+secularization's
+secularizations
+secularized
+sensitized
+sentimentalize
+sentimentalized
+sentimentalizer
+sentimentalizers
+sentimentalizes
+sentimentalizing
+sexualized
+signalizes
+sniveled
+sniveler
+snivelers
+sniveling
+snivelings
+socialization
+socialization's
+socializations
+stabilization
+stabilization's
+stabilizations
+stigmatization
+stigmatization's
+stigmatizations
+stigmatized
+stylization
+stylization's
+stylizations
+subcategorizing
+subsidization
+subsidization's
+subsidizations
+substerilization
+suburbanization
+suburbanization's
+suburbanizations
+suburbanized
+suburbanizing
+swiveled
+swiveling
+systematization
+systematization's
+systematizations
+systemization
+systemization's
+systemizations
+teaseled
+teaseling
+teetotaler
+temporize
+temporized
+temporizer
+temporizer's
+temporizers
+temporizes
+temporizing
+temporizing's
+temporizingly
+temporizings
+theatergoer
+theatergoer's
+theatergoers
+theatergoing
+theatergoing's
+theatergoings
+thru
+tine's
+tinseled
+tinseling
+traditionalized
+travelog
+travelog's
+travelogs
+trialization
+triangularization
+triangularizations
+tricolor
+tricolor's
+tricolored
+tricolors
+tyrannize
+tyrannized
+tyrannizer
+tyrannizers
+tyrannizes
+tyrannizing
+tyrannizing's
+tyrannizingly
+tyrannizings
+unamortization
+unamortization's
+unamortizations
+uncanonized
+uncauterized
+uncauterized's
+uncauterizeds
+undemocratizes
+underutilization
+underutilized
+undialyzed
+undialyzed's
+undialyzeds
+undiscoloreds
+undramatized
+undramatized's
+undramatizeds
+unenergized
+unenergized's
+unenergizeds
+uneulogized
+uneulogized's
+uneulogizeds
+unfossilized
+unfossilized's
+unfossilizeds
+unfraternizing
+unfraternizing's
+unfraternizings
+unhydrolyzed
+unhydrolyzed's
+unhydrolyzeds
+unidolized
+unidolized's
+unidolizeds
+unimmortalized
+unindustrialized
+unindustrialized's
+unindustrializeds
+unitized
+universalize
+universalized
+universalizer
+universalizers
+universalizes
+universalizing
+unmagnetized
+unmagnetized's
+unmagnetizeds
+unmemorialized
+unmemorialized's
+unmemorializeds
+unmesmerized
+unmineralized
+unmineralized's
+unmineralizeds
+unmobilized
+unmobilized's
+unmobilizeds
+unmonopolized
+unmonopolizes
+unnaturalized
+unpatronizing
+unpolarized
+unpolarized's
+unpolarizeds
+unsatirizes
+unsavories
+unsavoriness
+unsavory
+unsavory's
+unscandalized
+unsecularized
+unsensitized
+unsentimentalizes
+unstigmatized
+unstigmatized's
+unstigmatizeds
+untemporizings
+untrammeled
+unvocalized
+unvocalized's
+unvocalizeds
+unvulcanized
+unvulcanized's
+unvulcanizeds
+updraft
+urbanization
+urbanization's
+urbanizations
+urbanized
+vacuolization
+vacuolization's
+vacuolizations
+vaporization
+vaporization's
+vaporizations
+varicolored
+varicolored's
+varicoloreds
+velarize
+velarized
+velarizes
+velarizing
+visualization
+visualization's
+visualizations
+vocalization
+vocalization's
+vocalizations
+vocalize
+vocalized
+vocalizer
+vocalizers
+vocalizes
+vocalizing
+volatilization
+volatilization's
+volatilizations
+vulcanized
+watercolor
+watercolor's
+watercolored
+watercoloring
+watercolorist
+watercolorists
+watercolors
+yodeled
+yodeler
+yodeling
+deprecation
+info
+sync
+synch
+java
+Java
+doc
+Doc
+Mon
+Tue
+Wed
+Thur
+Fri
+Sat
+Sun
+initially
+I
diff --git a/org.eclipse.cdt.ui/doxygenTags.csv b/org.eclipse.cdt.ui/doxygenTags.csv
new file mode 100644 (file)
index 0000000..65a7071
--- /dev/null
@@ -0,0 +1,138 @@
+a,,
+addindex,,
+addtogroup,,
+anchor,,
+arg,,
+attention,,
+author,,
+b,,
+brief,,
+bug,,
+c,,
+callgraph,,
+callergraph,,
+category,,
+class,,
+code,,
+cond,,
+copybrief,,
+copydetails,,
+copydoc,,
+date,,
+def,,
+defgroup,,
+deprecated,,
+details,,
+dir,,
+dontinclude,,
+dot,,
+dotfile,,
+e,,
+else,,
+elseif,,
+em,,
+endcode,,
+endcond,,
+enddot,,
+endhtmlonly,,
+endif,,
+endlatexonly,,
+endlink,,
+endmanonly,,
+endmsc,,
+endverbatim,,
+endxmlonly,,
+enum,,
+example,,
+exception,,
+f$,,
+f[,,
+f],,
+f{,,
+f},,
+file,,
+fn,,
+headerfile,,
+hideinitializer,,
+htmlinclude,,
+htmlonly,,
+if,,
+ifnot,,
+image,,
+include,,
+includelineno,,
+ingroup,,
+internal,,
+invariant,,
+interface,,
+latexonly,,
+li,,
+line,,
+link,,
+mainpage,,
+manonly,,
+memberof,,
+msc,,
+n,,
+name,,
+namespace,,
+nosubgrouping,,
+note,,
+overload,,
+p,,
+package,,
+page,,
+par,,
+paragraph,,
+param,,
+post,,
+pre,,
+private,,
+privatesection,,
+property,,
+protected,,
+protectedsection,,
+protocol,,
+public,,
+publicsection,,
+ref,,
+relates,,
+relatesalso,,
+remarks,,
+return,,
+retval,,
+sa,,
+section,,
+see,,
+showinitializer,,
+since,,
+skip,,
+skipline,,
+struct,,
+subpage,,
+subsection,,
+subsubsection,,
+test,,
+throw,,
+todo,,
+tparam,,
+typedef,,
+union,,
+until,,
+var,,
+verbatim,,
+verbinclude,,
+version,Starts a paragraph where one or more version strings may be entered.,
+warning,,
+weakgroup,,
+xmlonly,,
+xrefitem,,
+&,,
+@,,
+\,,
+~,,
+<,,
+>,,
+#,,
+%,,
+",,
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/action-editconfig.gif b/org.eclipse.cdt.ui/icons/dlcl16/action-editconfig.gif
new file mode 100644 (file)
index 0000000..179b657
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/action-editconfig.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/alphab_sort_co.gif b/org.eclipse.cdt.ui/icons/dlcl16/alphab_sort_co.gif
new file mode 100644 (file)
index 0000000..7d27529
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/alphab_sort_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/build_exec.png b/org.eclipse.cdt.ui/icons/dlcl16/build_exec.png
new file mode 100644 (file)
index 0000000..b6d8adc
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/build_exec.png differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/ch_callees.gif b/org.eclipse.cdt.ui/icons/dlcl16/ch_callees.gif
new file mode 100644 (file)
index 0000000..4e01f24
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/ch_callees.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/ch_callers.gif b/org.eclipse.cdt.ui/icons/dlcl16/ch_callers.gif
new file mode 100644 (file)
index 0000000..4091cac
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/ch_callers.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/clear_co.gif b/org.eclipse.cdt.ui/icons/dlcl16/clear_co.gif
new file mode 100644 (file)
index 0000000..8f14bd2
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/clear_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/collapseall.gif b/org.eclipse.cdt.ui/icons/dlcl16/collapseall.gif
new file mode 100644 (file)
index 0000000..a2d80a9
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/collapseall.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/config-tool.gif b/org.eclipse.cdt.ui/icons/dlcl16/config-tool.gif
new file mode 100644 (file)
index 0000000..4539ebd
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/config-tool.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/configure_annotations.gif b/org.eclipse.cdt.ui/icons/dlcl16/configure_annotations.gif
new file mode 100644 (file)
index 0000000..a52a650
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/configure_annotations.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/definingtype_sort_co.gif b/org.eclipse.cdt.ui/icons/dlcl16/definingtype_sort_co.gif
new file mode 100644 (file)
index 0000000..ff83256
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/definingtype_sort_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/fields_co.gif b/org.eclipse.cdt.ui/icons/dlcl16/fields_co.gif
new file mode 100644 (file)
index 0000000..50a7033
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/fields_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/filterDefines.gif b/org.eclipse.cdt.ui/icons/dlcl16/filterDefines.gif
new file mode 100644 (file)
index 0000000..75010f5
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/filterDefines.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/filterInactive.gif b/org.eclipse.cdt.ui/icons/dlcl16/filterInactive.gif
new file mode 100644 (file)
index 0000000..d8bda99
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/filterInactive.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/filterSystem.gif b/org.eclipse.cdt.ui/icons/dlcl16/filterSystem.gif
new file mode 100644 (file)
index 0000000..3e1d300
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/filterSystem.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/group_include.gif b/org.eclipse.cdt.ui/icons/dlcl16/group_include.gif
new file mode 100644 (file)
index 0000000..ea94702
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/group_include.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/hierarchy_co.gif b/org.eclipse.cdt.ui/icons/dlcl16/hierarchy_co.gif
new file mode 100644 (file)
index 0000000..23c8d72
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/hierarchy_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/history_list.gif b/org.eclipse.cdt.ui/icons/dlcl16/history_list.gif
new file mode 100644 (file)
index 0000000..131063c
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/history_list.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/impl_co.gif b/org.eclipse.cdt.ui/icons/dlcl16/impl_co.gif
new file mode 100644 (file)
index 0000000..a727403
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/impl_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/inher_co.gif b/org.eclipse.cdt.ui/icons/dlcl16/inher_co.gif
new file mode 100644 (file)
index 0000000..23338d7
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/inher_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/list-add.gif b/org.eclipse.cdt.ui/icons/dlcl16/list-add.gif
new file mode 100644 (file)
index 0000000..5ee82b4
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/list-add.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/list-delete.gif b/org.eclipse.cdt.ui/icons/dlcl16/list-delete.gif
new file mode 100644 (file)
index 0000000..5fd7e2d
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/list-delete.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/list-edit.gif b/org.eclipse.cdt.ui/icons/dlcl16/list-edit.gif
new file mode 100644 (file)
index 0000000..3718972
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/list-edit.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/list-movedown.gif b/org.eclipse.cdt.ui/icons/dlcl16/list-movedown.gif
new file mode 100644 (file)
index 0000000..d286638
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/list-movedown.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/list-moveup.gif b/org.eclipse.cdt.ui/icons/dlcl16/list-moveup.gif
new file mode 100644 (file)
index 0000000..f8440c8
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/list-moveup.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/lock_co.gif b/org.eclipse.cdt.ui/icons/dlcl16/lock_co.gif
new file mode 100644 (file)
index 0000000..b776478
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/lock_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/metharg_obj.gif b/org.eclipse.cdt.ui/icons/dlcl16/metharg_obj.gif
new file mode 100644 (file)
index 0000000..c25ebbd
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/metharg_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/open_incl.gif b/org.eclipse.cdt.ui/icons/dlcl16/open_incl.gif
new file mode 100644 (file)
index 0000000..3503cfe
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/open_incl.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/open_include.gif b/org.eclipse.cdt.ui/icons/dlcl16/open_include.gif
new file mode 100644 (file)
index 0000000..b902fca
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/open_include.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/progress_stop.gif b/org.eclipse.cdt.ui/icons/dlcl16/progress_stop.gif
new file mode 100644 (file)
index 0000000..4f3dcba
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/progress_stop.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/public_co.gif b/org.eclipse.cdt.ui/icons/dlcl16/public_co.gif
new file mode 100644 (file)
index 0000000..93081d6
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/public_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/refresh_nav.gif b/org.eclipse.cdt.ui/icons/dlcl16/refresh_nav.gif
new file mode 100644 (file)
index 0000000..478cff5
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/refresh_nav.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/save_console.gif b/org.eclipse.cdt.ui/icons/dlcl16/save_console.gif
new file mode 100644 (file)
index 0000000..bdae776
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/save_console.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/search_next.gif b/org.eclipse.cdt.ui/icons/dlcl16/search_next.gif
new file mode 100644 (file)
index 0000000..8aacf95
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/search_next.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/search_prev.gif b/org.eclipse.cdt.ui/icons/dlcl16/search_prev.gif
new file mode 100644 (file)
index 0000000..38841ab
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/search_prev.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/search_sortmatch.gif b/org.eclipse.cdt.ui/icons/dlcl16/search_sortmatch.gif
new file mode 100644 (file)
index 0000000..8630705
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/search_sortmatch.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/segment_edit.gif b/org.eclipse.cdt.ui/icons/dlcl16/segment_edit.gif
new file mode 100644 (file)
index 0000000..1b50ff8
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/segment_edit.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/shift_l_edit.gif b/org.eclipse.cdt.ui/icons/dlcl16/shift_l_edit.gif
new file mode 100644 (file)
index 0000000..328e97e
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/shift_l_edit.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/shift_r_edit.gif b/org.eclipse.cdt.ui/icons/dlcl16/shift_r_edit.gif
new file mode 100644 (file)
index 0000000..ec35f69
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/shift_r_edit.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/static_co.gif b/org.eclipse.cdt.ui/icons/dlcl16/static_co.gif
new file mode 100644 (file)
index 0000000..b567be4
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/static_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/sub_co.gif b/org.eclipse.cdt.ui/icons/dlcl16/sub_co.gif
new file mode 100644 (file)
index 0000000..3848a25
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/sub_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/super_co.gif b/org.eclipse.cdt.ui/icons/dlcl16/super_co.gif
new file mode 100644 (file)
index 0000000..45808d1
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/super_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/synced.gif b/org.eclipse.cdt.ui/icons/dlcl16/synced.gif
new file mode 100644 (file)
index 0000000..870934b
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/synced.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/th_automatic.gif b/org.eclipse.cdt.ui/icons/dlcl16/th_automatic.gif
new file mode 100644 (file)
index 0000000..1b93aac
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/th_automatic.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/th_horizontal.gif b/org.eclipse.cdt.ui/icons/dlcl16/th_horizontal.gif
new file mode 100644 (file)
index 0000000..05da624
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/th_horizontal.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/th_showqualified.gif b/org.eclipse.cdt.ui/icons/dlcl16/th_showqualified.gif
new file mode 100644 (file)
index 0000000..f288b59
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/th_showqualified.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/th_single.gif b/org.eclipse.cdt.ui/icons/dlcl16/th_single.gif
new file mode 100644 (file)
index 0000000..530345b
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/th_single.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/th_vertical.gif b/org.eclipse.cdt.ui/icons/dlcl16/th_vertical.gif
new file mode 100644 (file)
index 0000000..0a52f1d
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/th_vertical.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dlcl16/view_menu.gif b/org.eclipse.cdt.ui/icons/dlcl16/view_menu.gif
new file mode 100644 (file)
index 0000000..5d13485
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dlcl16/view_menu.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/action-buildconfig.gif b/org.eclipse.cdt.ui/icons/dtool16/action-buildconfig.gif
new file mode 100644 (file)
index 0000000..f040465
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/action-buildconfig.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/action-deleteconfig.gif b/org.eclipse.cdt.ui/icons/dtool16/action-deleteconfig.gif
new file mode 100644 (file)
index 0000000..0883ade
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/action-deleteconfig.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/action-editconfig.gif b/org.eclipse.cdt.ui/icons/dtool16/action-editconfig.gif
new file mode 100644 (file)
index 0000000..179b657
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/action-editconfig.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/action-newconfig.gif b/org.eclipse.cdt.ui/icons/dtool16/action-newconfig.gif
new file mode 100644 (file)
index 0000000..ea3c137
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/action-newconfig.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/build_configs.gif b/org.eclipse.cdt.ui/icons/dtool16/build_configs.gif
new file mode 100644 (file)
index 0000000..c4c76d0
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/build_configs.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/config-category.gif b/org.eclipse.cdt.ui/icons/dtool16/config-category.gif
new file mode 100644 (file)
index 0000000..cd837b1
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/config-category.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/config-compiler.gif b/org.eclipse.cdt.ui/icons/dtool16/config-compiler.gif
new file mode 100644 (file)
index 0000000..906f442
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/config-compiler.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/config-debug.gif b/org.eclipse.cdt.ui/icons/dtool16/config-debug.gif
new file mode 100644 (file)
index 0000000..7886012
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/config-debug.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/config-librarian.gif b/org.eclipse.cdt.ui/icons/dtool16/config-librarian.gif
new file mode 100644 (file)
index 0000000..dd49d51
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/config-librarian.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/config-linker.gif b/org.eclipse.cdt.ui/icons/dtool16/config-linker.gif
new file mode 100644 (file)
index 0000000..34b228e
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/config-linker.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/config-preprocessor.gif b/org.eclipse.cdt.ui/icons/dtool16/config-preprocessor.gif
new file mode 100644 (file)
index 0000000..5bfadbc
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/config-preprocessor.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/config-profile.gif b/org.eclipse.cdt.ui/icons/dtool16/config-profile.gif
new file mode 100644 (file)
index 0000000..4539ebd
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/config-profile.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/config-release.gif b/org.eclipse.cdt.ui/icons/dtool16/config-release.gif
new file mode 100644 (file)
index 0000000..7d57687
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/config-release.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/config-tool.gif b/org.eclipse.cdt.ui/icons/dtool16/config-tool.gif
new file mode 100644 (file)
index 0000000..4539ebd
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/config-tool.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/convert-normal.gif b/org.eclipse.cdt.ui/icons/dtool16/convert-normal.gif
new file mode 100644 (file)
index 0000000..580eac5
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/convert-normal.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/exportzip_wiz.gif b/org.eclipse.cdt.ui/icons/dtool16/exportzip_wiz.gif
new file mode 100644 (file)
index 0000000..b285d84
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/exportzip_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/mark_occurrences.gif b/org.eclipse.cdt.ui/icons/dtool16/mark_occurrences.gif
new file mode 100644 (file)
index 0000000..1af4d3b
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/mark_occurrences.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/newc_app.gif b/org.eclipse.cdt.ui/icons/dtool16/newc_app.gif
new file mode 100644 (file)
index 0000000..a8353f6
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/newc_app.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/newc_lib.gif b/org.eclipse.cdt.ui/icons/dtool16/newc_lib.gif
new file mode 100644 (file)
index 0000000..3d6b02f
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/newc_lib.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/newcc_app.gif b/org.eclipse.cdt.ui/icons/dtool16/newcc_app.gif
new file mode 100644 (file)
index 0000000..9ed7487
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/newcc_app.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/newcc_lib.gif b/org.eclipse.cdt.ui/icons/dtool16/newcc_lib.gif
new file mode 100644 (file)
index 0000000..fd6e03a
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/newcc_lib.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/newcfile_wiz.gif b/org.eclipse.cdt.ui/icons/dtool16/newcfile_wiz.gif
new file mode 100644 (file)
index 0000000..8928b5a
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/newcfile_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/newclass_wiz.gif b/org.eclipse.cdt.ui/icons/dtool16/newclass_wiz.gif
new file mode 100644 (file)
index 0000000..2d2b249
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/newclass_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/newcprj_wiz.gif b/org.eclipse.cdt.ui/icons/dtool16/newcprj_wiz.gif
new file mode 100644 (file)
index 0000000..f4ebef1
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/newcprj_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/newfile_wiz.gif b/org.eclipse.cdt.ui/icons/dtool16/newfile_wiz.gif
new file mode 100644 (file)
index 0000000..4fd3e41
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/newfile_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/newfolder_wiz.gif b/org.eclipse.cdt.ui/icons/dtool16/newfolder_wiz.gif
new file mode 100644 (file)
index 0000000..86f2c13
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/newfolder_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/newhfile_wiz.gif b/org.eclipse.cdt.ui/icons/dtool16/newhfile_wiz.gif
new file mode 100644 (file)
index 0000000..2f0083b
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/newhfile_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/newmngc_app.gif b/org.eclipse.cdt.ui/icons/dtool16/newmngc_app.gif
new file mode 100644 (file)
index 0000000..a8353f6
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/newmngc_app.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/newmngcc_app.gif b/org.eclipse.cdt.ui/icons/dtool16/newmngcc_app.gif
new file mode 100644 (file)
index 0000000..9ed7487
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/newmngcc_app.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/newsrcfldr_wiz.gif b/org.eclipse.cdt.ui/icons/dtool16/newsrcfldr_wiz.gif
new file mode 100644 (file)
index 0000000..0e30f55
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/newsrcfldr_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/next_error_nav.gif b/org.eclipse.cdt.ui/icons/dtool16/next_error_nav.gif
new file mode 100644 (file)
index 0000000..ec87a59
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/next_error_nav.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/opentype.gif b/org.eclipse.cdt.ui/icons/dtool16/opentype.gif
new file mode 100644 (file)
index 0000000..17eea81
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/opentype.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/prev_error_nav.gif b/org.eclipse.cdt.ui/icons/dtool16/prev_error_nav.gif
new file mode 100644 (file)
index 0000000..e53dcc5
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/prev_error_nav.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/prj_obj.gif b/org.eclipse.cdt.ui/icons/dtool16/prj_obj.gif
new file mode 100644 (file)
index 0000000..9114ee1
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/prj_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/dtool16/prop_edt.gif b/org.eclipse.cdt.ui/icons/dtool16/prop_edt.gif
new file mode 100644 (file)
index 0000000..ce790f5
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/dtool16/prop_edt.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/action-editconfig.gif b/org.eclipse.cdt.ui/icons/elcl16/action-editconfig.gif
new file mode 100644 (file)
index 0000000..cc28a3a
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/action-editconfig.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/alphab_sort_co.gif b/org.eclipse.cdt.ui/icons/elcl16/alphab_sort_co.gif
new file mode 100644 (file)
index 0000000..7d27529
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/alphab_sort_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/backward_nav.gif b/org.eclipse.cdt.ui/icons/elcl16/backward_nav.gif
new file mode 100644 (file)
index 0000000..4fb4150
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/backward_nav.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/build_exec.png b/org.eclipse.cdt.ui/icons/elcl16/build_exec.png
new file mode 100644 (file)
index 0000000..c0272bb
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/build_exec.png differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/ch_callees.gif b/org.eclipse.cdt.ui/icons/elcl16/ch_callees.gif
new file mode 100644 (file)
index 0000000..695e5a5
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/ch_callees.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/ch_callers.gif b/org.eclipse.cdt.ui/icons/elcl16/ch_callers.gif
new file mode 100644 (file)
index 0000000..de0e6f9
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/ch_callers.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/clear_co.gif b/org.eclipse.cdt.ui/icons/elcl16/clear_co.gif
new file mode 100644 (file)
index 0000000..8f14bd2
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/clear_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/codeassist_co.gif b/org.eclipse.cdt.ui/icons/elcl16/codeassist_co.gif
new file mode 100644 (file)
index 0000000..be2962b
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/codeassist_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/collapseall.gif b/org.eclipse.cdt.ui/icons/elcl16/collapseall.gif
new file mode 100644 (file)
index 0000000..a2d80a9
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/collapseall.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/config-tool.gif b/org.eclipse.cdt.ui/icons/elcl16/config-tool.gif
new file mode 100644 (file)
index 0000000..c984fba
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/config-tool.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/configure_annotations.gif b/org.eclipse.cdt.ui/icons/elcl16/configure_annotations.gif
new file mode 100644 (file)
index 0000000..40757a1
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/configure_annotations.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/definingtype_sort_co.gif b/org.eclipse.cdt.ui/icons/elcl16/definingtype_sort_co.gif
new file mode 100644 (file)
index 0000000..166eaba
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/definingtype_sort_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/fields_co.gif b/org.eclipse.cdt.ui/icons/elcl16/fields_co.gif
new file mode 100644 (file)
index 0000000..aa45cf7
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/fields_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/filterDefines.gif b/org.eclipse.cdt.ui/icons/elcl16/filterDefines.gif
new file mode 100644 (file)
index 0000000..612786b
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/filterDefines.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/filterInactive.gif b/org.eclipse.cdt.ui/icons/elcl16/filterInactive.gif
new file mode 100644 (file)
index 0000000..1292803
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/filterInactive.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/filterSystem.gif b/org.eclipse.cdt.ui/icons/elcl16/filterSystem.gif
new file mode 100644 (file)
index 0000000..e4c0868
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/filterSystem.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/forward_nav.gif b/org.eclipse.cdt.ui/icons/elcl16/forward_nav.gif
new file mode 100644 (file)
index 0000000..e2f8c3e
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/forward_nav.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/goto_input.gif b/org.eclipse.cdt.ui/icons/elcl16/goto_input.gif
new file mode 100644 (file)
index 0000000..2a6dea3
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/goto_input.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/group_include.gif b/org.eclipse.cdt.ui/icons/elcl16/group_include.gif
new file mode 100644 (file)
index 0000000..ea94702
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/group_include.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/helpprop_co.gif b/org.eclipse.cdt.ui/icons/elcl16/helpprop_co.gif
new file mode 100644 (file)
index 0000000..cb55e33
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/helpprop_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/hierarchy_co.gif b/org.eclipse.cdt.ui/icons/elcl16/hierarchy_co.gif
new file mode 100644 (file)
index 0000000..45b6b13
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/hierarchy_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/history_list.gif b/org.eclipse.cdt.ui/icons/elcl16/history_list.gif
new file mode 100644 (file)
index 0000000..364c0e7
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/history_list.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/impl_co.gif b/org.eclipse.cdt.ui/icons/elcl16/impl_co.gif
new file mode 100644 (file)
index 0000000..98d914a
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/impl_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/inher_co.gif b/org.eclipse.cdt.ui/icons/elcl16/inher_co.gif
new file mode 100644 (file)
index 0000000..a326000
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/inher_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/list-add.gif b/org.eclipse.cdt.ui/icons/elcl16/list-add.gif
new file mode 100644 (file)
index 0000000..45c0e60
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/list-add.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/list-delete.gif b/org.eclipse.cdt.ui/icons/elcl16/list-delete.gif
new file mode 100644 (file)
index 0000000..af59a0b
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/list-delete.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/list-edit.gif b/org.eclipse.cdt.ui/icons/elcl16/list-edit.gif
new file mode 100644 (file)
index 0000000..d1aa86c
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/list-edit.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/list-movedown.gif b/org.eclipse.cdt.ui/icons/elcl16/list-movedown.gif
new file mode 100644 (file)
index 0000000..572933e
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/list-movedown.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/list-moveup.gif b/org.eclipse.cdt.ui/icons/elcl16/list-moveup.gif
new file mode 100644 (file)
index 0000000..768c5c1
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/list-moveup.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/lock_co.gif b/org.eclipse.cdt.ui/icons/elcl16/lock_co.gif
new file mode 100644 (file)
index 0000000..68fd6cf
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/lock_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/metharg_obj.gif b/org.eclipse.cdt.ui/icons/elcl16/metharg_obj.gif
new file mode 100644 (file)
index 0000000..c25ebbd
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/metharg_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/newmngc_app.gif b/org.eclipse.cdt.ui/icons/elcl16/newmngc_app.gif
new file mode 100644 (file)
index 0000000..23b0284
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/newmngc_app.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/newmngcc_app.gif b/org.eclipse.cdt.ui/icons/elcl16/newmngcc_app.gif
new file mode 100644 (file)
index 0000000..4b39411
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/newmngcc_app.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/open_incl.gif b/org.eclipse.cdt.ui/icons/elcl16/open_incl.gif
new file mode 100644 (file)
index 0000000..3503cfe
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/open_incl.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/open_include.gif b/org.eclipse.cdt.ui/icons/elcl16/open_include.gif
new file mode 100644 (file)
index 0000000..b902fca
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/open_include.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/progress_stop.gif b/org.eclipse.cdt.ui/icons/elcl16/progress_stop.gif
new file mode 100644 (file)
index 0000000..dc47edf
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/progress_stop.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/public_co.gif b/org.eclipse.cdt.ui/icons/elcl16/public_co.gif
new file mode 100644 (file)
index 0000000..93081d6
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/public_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/refresh_nav.gif b/org.eclipse.cdt.ui/icons/elcl16/refresh_nav.gif
new file mode 100644 (file)
index 0000000..3ca04d0
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/refresh_nav.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/save_console.gif b/org.eclipse.cdt.ui/icons/elcl16/save_console.gif
new file mode 100644 (file)
index 0000000..555182c
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/save_console.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/search_next.gif b/org.eclipse.cdt.ui/icons/elcl16/search_next.gif
new file mode 100644 (file)
index 0000000..072b184
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/search_next.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/search_prev.gif b/org.eclipse.cdt.ui/icons/elcl16/search_prev.gif
new file mode 100644 (file)
index 0000000..0716475
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/search_prev.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/search_sortmatch.gif b/org.eclipse.cdt.ui/icons/elcl16/search_sortmatch.gif
new file mode 100644 (file)
index 0000000..8630705
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/search_sortmatch.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/segment_edit.gif b/org.eclipse.cdt.ui/icons/elcl16/segment_edit.gif
new file mode 100644 (file)
index 0000000..1b50ff8
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/segment_edit.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/shift_l_edit.gif b/org.eclipse.cdt.ui/icons/elcl16/shift_l_edit.gif
new file mode 100644 (file)
index 0000000..328e97e
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/shift_l_edit.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/shift_r_edit.gif b/org.eclipse.cdt.ui/icons/elcl16/shift_r_edit.gif
new file mode 100644 (file)
index 0000000..ec35f69
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/shift_r_edit.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/static_co.gif b/org.eclipse.cdt.ui/icons/elcl16/static_co.gif
new file mode 100644 (file)
index 0000000..b567be4
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/static_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/sub_co.gif b/org.eclipse.cdt.ui/icons/elcl16/sub_co.gif
new file mode 100644 (file)
index 0000000..54871df
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/sub_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/super_co.gif b/org.eclipse.cdt.ui/icons/elcl16/super_co.gif
new file mode 100644 (file)
index 0000000..59ac116
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/super_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/synced.gif b/org.eclipse.cdt.ui/icons/elcl16/synced.gif
new file mode 100644 (file)
index 0000000..870934b
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/synced.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/templateprop_co.gif b/org.eclipse.cdt.ui/icons/elcl16/templateprop_co.gif
new file mode 100644 (file)
index 0000000..fdde5fb
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/templateprop_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/th_automatic.gif b/org.eclipse.cdt.ui/icons/elcl16/th_automatic.gif
new file mode 100644 (file)
index 0000000..45469ad
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/th_automatic.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/th_horizontal.gif b/org.eclipse.cdt.ui/icons/elcl16/th_horizontal.gif
new file mode 100644 (file)
index 0000000..d590470
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/th_horizontal.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/th_showqualified.gif b/org.eclipse.cdt.ui/icons/elcl16/th_showqualified.gif
new file mode 100644 (file)
index 0000000..2556b45
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/th_showqualified.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/th_single.gif b/org.eclipse.cdt.ui/icons/elcl16/th_single.gif
new file mode 100644 (file)
index 0000000..42fca3f
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/th_single.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/th_vertical.gif b/org.eclipse.cdt.ui/icons/elcl16/th_vertical.gif
new file mode 100644 (file)
index 0000000..dee0cbc
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/th_vertical.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/view_menu.gif b/org.eclipse.cdt.ui/icons/elcl16/view_menu.gif
new file mode 100644 (file)
index 0000000..a7c4918
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/view_menu.gif differ
diff --git a/org.eclipse.cdt.ui/icons/elcl16/wordassist_co.gif b/org.eclipse.cdt.ui/icons/elcl16/wordassist_co.gif
new file mode 100644 (file)
index 0000000..c9b97fe
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/elcl16/wordassist_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/action-buildconfig.gif b/org.eclipse.cdt.ui/icons/etool16/action-buildconfig.gif
new file mode 100644 (file)
index 0000000..c4c76d0
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/action-buildconfig.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/action-deleteconfig.gif b/org.eclipse.cdt.ui/icons/etool16/action-deleteconfig.gif
new file mode 100644 (file)
index 0000000..3986a4b
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/action-deleteconfig.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/action-editconfig.gif b/org.eclipse.cdt.ui/icons/etool16/action-editconfig.gif
new file mode 100644 (file)
index 0000000..cc28a3a
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/action-editconfig.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/action-newconfig.gif b/org.eclipse.cdt.ui/icons/etool16/action-newconfig.gif
new file mode 100644 (file)
index 0000000..0ebc0df
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/action-newconfig.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/build_configs.gif b/org.eclipse.cdt.ui/icons/etool16/build_configs.gif
new file mode 100644 (file)
index 0000000..c4c76d0
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/build_configs.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/config-category.gif b/org.eclipse.cdt.ui/icons/etool16/config-category.gif
new file mode 100644 (file)
index 0000000..ee7c485
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/config-category.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/config-compiler.gif b/org.eclipse.cdt.ui/icons/etool16/config-compiler.gif
new file mode 100644 (file)
index 0000000..39ee592
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/config-compiler.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/config-debug.gif b/org.eclipse.cdt.ui/icons/etool16/config-debug.gif
new file mode 100644 (file)
index 0000000..aef2061
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/config-debug.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/config-librarian.gif b/org.eclipse.cdt.ui/icons/etool16/config-librarian.gif
new file mode 100644 (file)
index 0000000..1119c67
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/config-librarian.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/config-linker.gif b/org.eclipse.cdt.ui/icons/etool16/config-linker.gif
new file mode 100644 (file)
index 0000000..fe5d559
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/config-linker.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/config-preprocessor.gif b/org.eclipse.cdt.ui/icons/etool16/config-preprocessor.gif
new file mode 100644 (file)
index 0000000..cf62b63
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/config-preprocessor.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/config-profile.gif b/org.eclipse.cdt.ui/icons/etool16/config-profile.gif
new file mode 100644 (file)
index 0000000..c984fba
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/config-profile.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/config-release.gif b/org.eclipse.cdt.ui/icons/etool16/config-release.gif
new file mode 100644 (file)
index 0000000..fa1765e
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/config-release.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/config-tool.gif b/org.eclipse.cdt.ui/icons/etool16/config-tool.gif
new file mode 100644 (file)
index 0000000..c984fba
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/config-tool.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/convert-normal.gif b/org.eclipse.cdt.ui/icons/etool16/convert-normal.gif
new file mode 100644 (file)
index 0000000..0b693cb
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/convert-normal.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/exportzip_wiz.gif b/org.eclipse.cdt.ui/icons/etool16/exportzip_wiz.gif
new file mode 100644 (file)
index 0000000..b7a493c
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/exportzip_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/mark_occurrences.gif b/org.eclipse.cdt.ui/icons/etool16/mark_occurrences.gif
new file mode 100644 (file)
index 0000000..fd7c175
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/mark_occurrences.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/newc_app.gif b/org.eclipse.cdt.ui/icons/etool16/newc_app.gif
new file mode 100644 (file)
index 0000000..23b0284
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/newc_app.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/newc_lib.gif b/org.eclipse.cdt.ui/icons/etool16/newc_lib.gif
new file mode 100644 (file)
index 0000000..5fd6d52
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/newc_lib.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/newcc_app.gif b/org.eclipse.cdt.ui/icons/etool16/newcc_app.gif
new file mode 100644 (file)
index 0000000..4b39411
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/newcc_app.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/newcc_lib.gif b/org.eclipse.cdt.ui/icons/etool16/newcc_lib.gif
new file mode 100644 (file)
index 0000000..9b082f9
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/newcc_lib.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/newcfile_wiz.gif b/org.eclipse.cdt.ui/icons/etool16/newcfile_wiz.gif
new file mode 100644 (file)
index 0000000..138f675
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/newcfile_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/newclass_wiz.gif b/org.eclipse.cdt.ui/icons/etool16/newclass_wiz.gif
new file mode 100644 (file)
index 0000000..eecb86e
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/newclass_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/newcprj_wiz.gif b/org.eclipse.cdt.ui/icons/etool16/newcprj_wiz.gif
new file mode 100644 (file)
index 0000000..3287eda
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/newcprj_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/newfile_wiz.gif b/org.eclipse.cdt.ui/icons/etool16/newfile_wiz.gif
new file mode 100644 (file)
index 0000000..9d05088
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/newfile_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/newfolder_wiz.gif b/org.eclipse.cdt.ui/icons/etool16/newfolder_wiz.gif
new file mode 100644 (file)
index 0000000..310eb18
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/newfolder_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/newhfile_wiz.gif b/org.eclipse.cdt.ui/icons/etool16/newhfile_wiz.gif
new file mode 100644 (file)
index 0000000..9d1fe9f
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/newhfile_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/newmngc_app.gif b/org.eclipse.cdt.ui/icons/etool16/newmngc_app.gif
new file mode 100644 (file)
index 0000000..23b0284
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/newmngc_app.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/newmngcc_app.gif b/org.eclipse.cdt.ui/icons/etool16/newmngcc_app.gif
new file mode 100644 (file)
index 0000000..4b39411
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/newmngcc_app.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/newsrcfldr_wiz.gif b/org.eclipse.cdt.ui/icons/etool16/newsrcfldr_wiz.gif
new file mode 100644 (file)
index 0000000..7caaa0f
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/newsrcfldr_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/next_error_nav.gif b/org.eclipse.cdt.ui/icons/etool16/next_error_nav.gif
new file mode 100644 (file)
index 0000000..1920339
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/next_error_nav.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/opentype.gif b/org.eclipse.cdt.ui/icons/etool16/opentype.gif
new file mode 100644 (file)
index 0000000..e8c4948
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/opentype.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/prev_error_nav.gif b/org.eclipse.cdt.ui/icons/etool16/prev_error_nav.gif
new file mode 100644 (file)
index 0000000..73d1fa1
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/prev_error_nav.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/prj_obj.gif b/org.eclipse.cdt.ui/icons/etool16/prj_obj.gif
new file mode 100644 (file)
index 0000000..0effc17
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/prj_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/etool16/prop_edt.gif b/org.eclipse.cdt.ui/icons/etool16/prop_edt.gif
new file mode 100644 (file)
index 0000000..c4681c6
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/etool16/prop_edt.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/ar_obj.gif b/org.eclipse.cdt.ui/icons/obj16/ar_obj.gif
new file mode 100644 (file)
index 0000000..10d652c
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/ar_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/archives_obj.gif b/org.eclipse.cdt.ui/icons/obj16/archives_obj.gif
new file mode 100644 (file)
index 0000000..c052e66
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/archives_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/asm_resource_obj.gif b/org.eclipse.cdt.ui/icons/obj16/asm_resource_obj.gif
new file mode 100644 (file)
index 0000000..4f1043c
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/asm_resource_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/bin_obj.gif b/org.eclipse.cdt.ui/icons/obj16/bin_obj.gif
new file mode 100644 (file)
index 0000000..66225ec
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/bin_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/binaries_obj.gif b/org.eclipse.cdt.ui/icons/obj16/binaries_obj.gif
new file mode 100644 (file)
index 0000000..5a08512
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/binaries_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/breakpoint.gif b/org.eclipse.cdt.ui/icons/obj16/breakpoint.gif
new file mode 100644 (file)
index 0000000..1eaff5a
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/breakpoint.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/breakpoint_active.gif b/org.eclipse.cdt.ui/icons/obj16/breakpoint_active.gif
new file mode 100644 (file)
index 0000000..11d3d8d
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/breakpoint_active.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/breakpoint_disabled.gif b/org.eclipse.cdt.ui/icons/obj16/breakpoint_disabled.gif
new file mode 100644 (file)
index 0000000..2966a28
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/breakpoint_disabled.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/build_menu.gif b/org.eclipse.cdt.ui/icons/obj16/build_menu.gif
new file mode 100644 (file)
index 0000000..73a2e2a
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/build_menu.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/c_file_obj.gif b/org.eclipse.cdt.ui/icons/obj16/c_file_obj.gif
new file mode 100644 (file)
index 0000000..bd603cf
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/c_file_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/c_resource_obj.gif b/org.eclipse.cdt.ui/icons/obj16/c_resource_obj.gif
new file mode 100644 (file)
index 0000000..cc28a6f
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/c_resource_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/cdeclaration_obj.gif b/org.eclipse.cdt.ui/icons/obj16/cdeclaration_obj.gif
new file mode 100644 (file)
index 0000000..cee1c6c
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/cdeclaration_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/cfolder_obj.gif b/org.eclipse.cdt.ui/icons/obj16/cfolder_obj.gif
new file mode 100644 (file)
index 0000000..03ee1dc
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/cfolder_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/ch_resource_obj.gif b/org.eclipse.cdt.ui/icons/obj16/ch_resource_obj.gif
new file mode 100644 (file)
index 0000000..33161ce
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/ch_resource_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/change.gif b/org.eclipse.cdt.ui/icons/obj16/change.gif
new file mode 100644 (file)
index 0000000..41695a9
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/change.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/class_obj.gif b/org.eclipse.cdt.ui/icons/obj16/class_obj.gif
new file mode 100644 (file)
index 0000000..6279478
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/class_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/classfo_obj.gif b/org.eclipse.cdt.ui/icons/obj16/classfo_obj.gif
new file mode 100644 (file)
index 0000000..f1ee8cf
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/classfo_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/composite_change.gif b/org.eclipse.cdt.ui/icons/obj16/composite_change.gif
new file mode 100644 (file)
index 0000000..71c4196
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/composite_change.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/config.gif b/org.eclipse.cdt.ui/icons/obj16/config.gif
new file mode 100644 (file)
index 0000000..c984fba
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/config.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/container_obj.gif b/org.eclipse.cdt.ui/icons/obj16/container_obj.gif
new file mode 100644 (file)
index 0000000..d90a51c
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/container_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/core_obj.gif b/org.eclipse.cdt.ui/icons/obj16/core_obj.gif
new file mode 100644 (file)
index 0000000..39b5fde
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/core_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/correction_add.gif b/org.eclipse.cdt.ui/icons/obj16/correction_add.gif
new file mode 100644 (file)
index 0000000..416c763
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/correction_add.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/correction_change.gif b/org.eclipse.cdt.ui/icons/obj16/correction_change.gif
new file mode 100644 (file)
index 0000000..068e18d
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/correction_change.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/correction_linked_rename.gif b/org.eclipse.cdt.ui/icons/obj16/correction_linked_rename.gif
new file mode 100644 (file)
index 0000000..d68e54e
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/correction_linked_rename.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/correction_rename.gif b/org.eclipse.cdt.ui/icons/obj16/correction_rename.gif
new file mode 100644 (file)
index 0000000..068e18d
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/correction_rename.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/cp_order_obj.gif b/org.eclipse.cdt.ui/icons/obj16/cp_order_obj.gif
new file mode 100644 (file)
index 0000000..b2fa4ce
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/cp_order_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/cprojects.gif b/org.eclipse.cdt.ui/icons/obj16/cprojects.gif
new file mode 100644 (file)
index 0000000..fcc08ad
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/cprojects.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/csearch_obj.gif b/org.eclipse.cdt.ui/icons/obj16/csearch_obj.gif
new file mode 100644 (file)
index 0000000..d6ad2f5
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/csearch_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/cu_change.gif b/org.eclipse.cdt.ui/icons/obj16/cu_change.gif
new file mode 100644 (file)
index 0000000..bd0e156
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/cu_change.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/debugt_obj_b.gif b/org.eclipse.cdt.ui/icons/obj16/debugt_obj_b.gif
new file mode 100644 (file)
index 0000000..fa6cbff
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/debugt_obj_b.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/debugt_obj_g.gif b/org.eclipse.cdt.ui/icons/obj16/debugt_obj_g.gif
new file mode 100644 (file)
index 0000000..0ac4ae3
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/debugt_obj_g.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/debugt_obj_r.gif b/org.eclipse.cdt.ui/icons/obj16/debugt_obj_r.gif
new file mode 100644 (file)
index 0000000..7e2e45c
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/debugt_obj_r.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/debugts_obj_b.gif b/org.eclipse.cdt.ui/icons/obj16/debugts_obj_b.gif
new file mode 100644 (file)
index 0000000..302b3f6
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/debugts_obj_b.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/debugts_obj_g.gif b/org.eclipse.cdt.ui/icons/obj16/debugts_obj_g.gif
new file mode 100644 (file)
index 0000000..16a7b2c
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/debugts_obj_g.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/debugts_obj_r.gif b/org.eclipse.cdt.ui/icons/obj16/debugts_obj_r.gif
new file mode 100644 (file)
index 0000000..1df7e8c
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/debugts_obj_r.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/define_obj.gif b/org.eclipse.cdt.ui/icons/obj16/define_obj.gif
new file mode 100644 (file)
index 0000000..87d583e
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/define_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/enum_obj.gif b/org.eclipse.cdt.ui/icons/obj16/enum_obj.gif
new file mode 100644 (file)
index 0000000..a441bef
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/enum_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/enumerator_obj.gif b/org.eclipse.cdt.ui/icons/obj16/enumerator_obj.gif
new file mode 100644 (file)
index 0000000..ec91141
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/enumerator_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/enumfo_obj.gif b/org.eclipse.cdt.ui/icons/obj16/enumfo_obj.gif
new file mode 100644 (file)
index 0000000..f470d4c
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/enumfo_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/environment.gif b/org.eclipse.cdt.ui/icons/obj16/environment.gif
new file mode 100644 (file)
index 0000000..716df43
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/environment.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/error_obj.gif b/org.eclipse.cdt.ui/icons/obj16/error_obj.gif
new file mode 100644 (file)
index 0000000..2cd37c2
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/error_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/exclusion_filter_attrib.gif b/org.eclipse.cdt.ui/icons/obj16/exclusion_filter_attrib.gif
new file mode 100644 (file)
index 0000000..5a15a79
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/exclusion_filter_attrib.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/exec_dbg_obj.gif b/org.eclipse.cdt.ui/icons/obj16/exec_dbg_obj.gif
new file mode 100644 (file)
index 0000000..fe21f44
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/exec_dbg_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/exec_obj.gif b/org.eclipse.cdt.ui/icons/obj16/exec_obj.gif
new file mode 100644 (file)
index 0000000..d5f502a
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/exec_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/export_settings_wiz.gif b/org.eclipse.cdt.ui/icons/obj16/export_settings_wiz.gif
new file mode 100644 (file)
index 0000000..b6bc7b2
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/export_settings_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/extension_obj.gif b/org.eclipse.cdt.ui/icons/obj16/extension_obj.gif
new file mode 100644 (file)
index 0000000..7f3f595
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/extension_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/fatalerror_obj.gif b/org.eclipse.cdt.ui/icons/obj16/fatalerror_obj.gif
new file mode 100644 (file)
index 0000000..75a9275
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/fatalerror_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/field_obj.gif b/org.eclipse.cdt.ui/icons/obj16/field_obj.gif
new file mode 100644 (file)
index 0000000..2407494
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/field_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/field_private_obj.gif b/org.eclipse.cdt.ui/icons/obj16/field_private_obj.gif
new file mode 100644 (file)
index 0000000..567c778
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/field_private_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/field_protected_obj.gif b/org.eclipse.cdt.ui/icons/obj16/field_protected_obj.gif
new file mode 100644 (file)
index 0000000..4234e04
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/field_protected_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/field_public_obj.gif b/org.eclipse.cdt.ui/icons/obj16/field_public_obj.gif
new file mode 100644 (file)
index 0000000..63a390c
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/field_public_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/file_change.gif b/org.eclipse.cdt.ui/icons/obj16/file_change.gif
new file mode 100644 (file)
index 0000000..55a7bac
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/file_change.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/filesyst.gif b/org.eclipse.cdt.ui/icons/obj16/filesyst.gif
new file mode 100644 (file)
index 0000000..13ce11b
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/filesyst.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/flask.png b/org.eclipse.cdt.ui/icons/obj16/flask.png
new file mode 100644 (file)
index 0000000..6340e7c
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/flask.png differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/fldr_lib_obj.gif b/org.eclipse.cdt.ui/icons/obj16/fldr_lib_obj.gif
new file mode 100644 (file)
index 0000000..db8e55b
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/fldr_lib_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/fldr_obj.gif b/org.eclipse.cdt.ui/icons/obj16/fldr_obj.gif
new file mode 100644 (file)
index 0000000..03ee1dc
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/fldr_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/fldr_sys_obj.gif b/org.eclipse.cdt.ui/icons/obj16/fldr_sys_obj.gif
new file mode 100644 (file)
index 0000000..07266c0
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/fldr_sys_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/function_obj.gif b/org.eclipse.cdt.ui/icons/obj16/function_obj.gif
new file mode 100644 (file)
index 0000000..92075a8
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/function_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/h_file_obj.gif b/org.eclipse.cdt.ui/icons/obj16/h_file_obj.gif
new file mode 100644 (file)
index 0000000..b902fca
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/h_file_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/hfolder_obj.gif b/org.eclipse.cdt.ui/icons/obj16/hfolder_obj.gif
new file mode 100644 (file)
index 0000000..b98b817
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/hfolder_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/hfolder_prj.gif b/org.eclipse.cdt.ui/icons/obj16/hfolder_prj.gif
new file mode 100644 (file)
index 0000000..3096b1d
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/hfolder_prj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/hfolder_quote_obj.gif b/org.eclipse.cdt.ui/icons/obj16/hfolder_quote_obj.gif
new file mode 100644 (file)
index 0000000..90f9be3
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/hfolder_quote_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/implm_co.gif b/org.eclipse.cdt.ui/icons/obj16/implm_co.gif
new file mode 100644 (file)
index 0000000..b987122
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/implm_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/import_settings_wiz.gif b/org.eclipse.cdt.ui/icons/obj16/import_settings_wiz.gif
new file mode 100644 (file)
index 0000000..8ab627c
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/import_settings_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/incc_obj.gif b/org.eclipse.cdt.ui/icons/obj16/incc_obj.gif
new file mode 100644 (file)
index 0000000..ea94702
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/incc_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/include_obj.gif b/org.eclipse.cdt.ui/icons/obj16/include_obj.gif
new file mode 100644 (file)
index 0000000..1855ca9
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/include_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/includes_container.gif b/org.eclipse.cdt.ui/icons/obj16/includes_container.gif
new file mode 100644 (file)
index 0000000..c8926a2
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/includes_container.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/info_obj.gif b/org.eclipse.cdt.ui/icons/obj16/info_obj.gif
new file mode 100644 (file)
index 0000000..745b884
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/info_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/keyword_obj.gif b/org.eclipse.cdt.ui/icons/obj16/keyword_obj.gif
new file mode 100644 (file)
index 0000000..1be9094
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/keyword_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/label_obj.gif b/org.eclipse.cdt.ui/icons/obj16/label_obj.gif
new file mode 100644 (file)
index 0000000..1d2912b
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/label_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/lib_obj.gif b/org.eclipse.cdt.ui/icons/obj16/lib_obj.gif
new file mode 100644 (file)
index 0000000..cb55e33
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/lib_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/macros_file.gif b/org.eclipse.cdt.ui/icons/obj16/macros_file.gif
new file mode 100644 (file)
index 0000000..1d99459
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/macros_file.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/method_private_obj.gif b/org.eclipse.cdt.ui/icons/obj16/method_private_obj.gif
new file mode 100644 (file)
index 0000000..75bfeb8
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/method_private_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/method_protected_obj.gif b/org.eclipse.cdt.ui/icons/obj16/method_protected_obj.gif
new file mode 100644 (file)
index 0000000..563743d
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/method_protected_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/method_public_obj.gif b/org.eclipse.cdt.ui/icons/obj16/method_public_obj.gif
new file mode 100644 (file)
index 0000000..7d24707
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/method_public_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/namespace_obj.gif b/org.eclipse.cdt.ui/icons/obj16/namespace_obj.gif
new file mode 100644 (file)
index 0000000..c70cce0
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/namespace_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/never_translate.gif b/org.eclipse.cdt.ui/icons/obj16/never_translate.gif
new file mode 100644 (file)
index 0000000..ba42e76
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/never_translate.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/opentype.gif b/org.eclipse.cdt.ui/icons/obj16/opentype.gif
new file mode 100644 (file)
index 0000000..e687f54
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/opentype.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/output_folder_obj.gif b/org.eclipse.cdt.ui/icons/obj16/output_folder_obj.gif
new file mode 100644 (file)
index 0000000..07c4101
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/output_folder_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/output_obj.gif b/org.eclipse.cdt.ui/icons/obj16/output_obj.gif
new file mode 100644 (file)
index 0000000..b6a24b6
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/output_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/over_co.gif b/org.eclipse.cdt.ui/icons/obj16/over_co.gif
new file mode 100644 (file)
index 0000000..938767b
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/over_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/person-me.gif b/org.eclipse.cdt.ui/icons/obj16/person-me.gif
new file mode 100644 (file)
index 0000000..fa074fb
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/person-me.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/quickassist_obj.gif b/org.eclipse.cdt.ui/icons/obj16/quickassist_obj.gif
new file mode 100644 (file)
index 0000000..94ae2a0
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/quickassist_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/quickfix_error_obj.gif b/org.eclipse.cdt.ui/icons/obj16/quickfix_error_obj.gif
new file mode 100644 (file)
index 0000000..07a1054
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/quickfix_error_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/quickfix_warning_obj.gif b/org.eclipse.cdt.ui/icons/obj16/quickfix_warning_obj.gif
new file mode 100644 (file)
index 0000000..3a0827a
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/quickfix_warning_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/s_file_obj.gif b/org.eclipse.cdt.ui/icons/obj16/s_file_obj.gif
new file mode 100644 (file)
index 0000000..c2f79bc
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/s_file_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/search_decl_obj.gif b/org.eclipse.cdt.ui/icons/obj16/search_decl_obj.gif
new file mode 100644 (file)
index 0000000..f31a02a
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/search_decl_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/search_ref_obj.gif b/org.eclipse.cdt.ui/icons/obj16/search_ref_obj.gif
new file mode 100644 (file)
index 0000000..f8f0ce5
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/search_ref_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/search_sortmatch.gif b/org.eclipse.cdt.ui/icons/obj16/search_sortmatch.gif
new file mode 100644 (file)
index 0000000..5952ed9
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/search_sortmatch.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/searchm_obj.gif b/org.eclipse.cdt.ui/icons/obj16/searchm_obj.gif
new file mode 100644 (file)
index 0000000..7b1efa5
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/searchm_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/shad_co.gif b/org.eclipse.cdt.ui/icons/obj16/shad_co.gif
new file mode 100644 (file)
index 0000000..ecf8aa3
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/shad_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/shlib_obj.gif b/org.eclipse.cdt.ui/icons/obj16/shlib_obj.gif
new file mode 100644 (file)
index 0000000..2f063e5
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/shlib_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/source_attach_attrib.gif b/org.eclipse.cdt.ui/icons/obj16/source_attach_attrib.gif
new file mode 100644 (file)
index 0000000..27ee786
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/source_attach_attrib.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/sroot2_obj.gif b/org.eclipse.cdt.ui/icons/obj16/sroot2_obj.gif
new file mode 100644 (file)
index 0000000..b06abca
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/sroot2_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/sroot_obj.gif b/org.eclipse.cdt.ui/icons/obj16/sroot_obj.gif
new file mode 100644 (file)
index 0000000..bacc22a
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/sroot_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/struct_obj.gif b/org.eclipse.cdt.ui/icons/obj16/struct_obj.gif
new file mode 100644 (file)
index 0000000..5db2efa
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/struct_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/structfo_obj.gif b/org.eclipse.cdt.ui/icons/obj16/structfo_obj.gif
new file mode 100644 (file)
index 0000000..bdbc77e
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/structfo_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/tc_empty.gif b/org.eclipse.cdt.ui/icons/obj16/tc_empty.gif
new file mode 100644 (file)
index 0000000..143e14d
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/tc_empty.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/tc_preferred.gif b/org.eclipse.cdt.ui/icons/obj16/tc_preferred.gif
new file mode 100644 (file)
index 0000000..270c645
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/tc_preferred.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/template_obj.gif b/org.eclipse.cdt.ui/icons/obj16/template_obj.gif
new file mode 100644 (file)
index 0000000..c0d9d95
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/template_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/text_edit.gif b/org.eclipse.cdt.ui/icons/obj16/text_edit.gif
new file mode 100644 (file)
index 0000000..9312d7e
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/text_edit.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/thread_obj_b.gif b/org.eclipse.cdt.ui/icons/obj16/thread_obj_b.gif
new file mode 100644 (file)
index 0000000..eb42ff7
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/thread_obj_b.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/thread_obj_g.gif b/org.eclipse.cdt.ui/icons/obj16/thread_obj_g.gif
new file mode 100644 (file)
index 0000000..349337b
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/thread_obj_g.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/thread_obj_r.gif b/org.eclipse.cdt.ui/icons/obj16/thread_obj_r.gif
new file mode 100644 (file)
index 0000000..95983d2
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/thread_obj_r.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/threads_obj_b.gif b/org.eclipse.cdt.ui/icons/obj16/threads_obj_b.gif
new file mode 100644 (file)
index 0000000..588806d
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/threads_obj_b.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/threads_obj_g.gif b/org.eclipse.cdt.ui/icons/obj16/threads_obj_g.gif
new file mode 100644 (file)
index 0000000..e9905e9
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/threads_obj_g.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/threads_obj_r.gif b/org.eclipse.cdt.ui/icons/obj16/threads_obj_r.gif
new file mode 100644 (file)
index 0000000..b02c7ef
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/threads_obj_r.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/toolbar_pinned.gif b/org.eclipse.cdt.ui/icons/obj16/toolbar_pinned.gif
new file mode 100644 (file)
index 0000000..282c727
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/toolbar_pinned.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/toolbar_pinned_b.gif b/org.eclipse.cdt.ui/icons/obj16/toolbar_pinned_b.gif
new file mode 100644 (file)
index 0000000..3e7b64c
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/toolbar_pinned_b.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/toolbar_pinned_g.gif b/org.eclipse.cdt.ui/icons/obj16/toolbar_pinned_g.gif
new file mode 100644 (file)
index 0000000..0f13a0e
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/toolbar_pinned_g.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/toolbar_pinned_multi.gif b/org.eclipse.cdt.ui/icons/obj16/toolbar_pinned_multi.gif
new file mode 100644 (file)
index 0000000..662d829
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/toolbar_pinned_multi.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/toolbar_pinned_r.gif b/org.eclipse.cdt.ui/icons/obj16/toolbar_pinned_r.gif
new file mode 100644 (file)
index 0000000..edcf9dc
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/toolbar_pinned_r.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/typedef_obj.gif b/org.eclipse.cdt.ui/icons/obj16/typedef_obj.gif
new file mode 100644 (file)
index 0000000..9d6df6a
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/typedef_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/typedeffo_obj.gif b/org.eclipse.cdt.ui/icons/obj16/typedeffo_obj.gif
new file mode 100644 (file)
index 0000000..f6b2d56
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/typedeffo_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/union_obj.gif b/org.eclipse.cdt.ui/icons/obj16/union_obj.gif
new file mode 100644 (file)
index 0000000..df0f59f
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/union_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/unionfo_obj.gif b/org.eclipse.cdt.ui/icons/obj16/unionfo_obj.gif
new file mode 100644 (file)
index 0000000..8f3bc26
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/unionfo_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/unknown_obj.gif b/org.eclipse.cdt.ui/icons/obj16/unknown_obj.gif
new file mode 100644 (file)
index 0000000..f34581a
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/unknown_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/unknown_type_obj.gif b/org.eclipse.cdt.ui/icons/obj16/unknown_type_obj.gif
new file mode 100644 (file)
index 0000000..86550fe
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/unknown_type_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/using_obj.gif b/org.eclipse.cdt.ui/icons/obj16/using_obj.gif
new file mode 100644 (file)
index 0000000..561bdf1
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/using_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/var_declaration_obj.gif b/org.eclipse.cdt.ui/icons/obj16/var_declaration_obj.gif
new file mode 100644 (file)
index 0000000..91c4c93
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/var_declaration_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/variable_local_obj.gif b/org.eclipse.cdt.ui/icons/obj16/variable_local_obj.gif
new file mode 100644 (file)
index 0000000..3244b26
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/variable_local_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/variable_obj.gif b/org.eclipse.cdt.ui/icons/obj16/variable_obj.gif
new file mode 100644 (file)
index 0000000..727812d
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/variable_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/warning_obj.gif b/org.eclipse.cdt.ui/icons/obj16/warning_obj.gif
new file mode 100644 (file)
index 0000000..1e5f5eb
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/warning_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/workspace.gif b/org.eclipse.cdt.ui/icons/obj16/workspace.gif
new file mode 100644 (file)
index 0000000..b5a0012
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/workspace.gif differ
diff --git a/org.eclipse.cdt.ui/icons/obj16/wsp_includefolder.gif b/org.eclipse.cdt.ui/icons/obj16/wsp_includefolder.gif
new file mode 100644 (file)
index 0000000..53507f0
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/obj16/wsp_includefolder.gif differ
diff --git a/org.eclipse.cdt.ui/icons/ovr16/c_ovr.gif b/org.eclipse.cdt.ui/icons/ovr16/c_ovr.gif
new file mode 100644 (file)
index 0000000..f449602
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/ovr16/c_ovr.gif differ
diff --git a/org.eclipse.cdt.ui/icons/ovr16/defines_co.gif b/org.eclipse.cdt.ui/icons/ovr16/defines_co.gif
new file mode 100644 (file)
index 0000000..53b995b
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/ovr16/defines_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/ovr16/error_co.gif b/org.eclipse.cdt.ui/icons/ovr16/error_co.gif
new file mode 100644 (file)
index 0000000..119dccc
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/ovr16/error_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/ovr16/external_file.gif b/org.eclipse.cdt.ui/icons/ovr16/external_file.gif
new file mode 100644 (file)
index 0000000..4a637db
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/ovr16/external_file.gif differ
diff --git a/org.eclipse.cdt.ui/icons/ovr16/inactive_co.gif b/org.eclipse.cdt.ui/icons/ovr16/inactive_co.gif
new file mode 100644 (file)
index 0000000..d03b6a9
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/ovr16/inactive_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/ovr16/indexedFile.gif b/org.eclipse.cdt.ui/icons/ovr16/indexedFile.gif
new file mode 100644 (file)
index 0000000..9b4c11c
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/ovr16/indexedFile.gif differ
diff --git a/org.eclipse.cdt.ui/icons/ovr16/path_inherit_co.gif b/org.eclipse.cdt.ui/icons/ovr16/path_inherit_co.gif
new file mode 100644 (file)
index 0000000..85e2189
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/ovr16/path_inherit_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/ovr16/read.gif b/org.eclipse.cdt.ui/icons/ovr16/read.gif
new file mode 100644 (file)
index 0000000..5a4e725
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/ovr16/read.gif differ
diff --git a/org.eclipse.cdt.ui/icons/ovr16/readwrite.gif b/org.eclipse.cdt.ui/icons/ovr16/readwrite.gif
new file mode 100644 (file)
index 0000000..1a563eb
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/ovr16/readwrite.gif differ
diff --git a/org.eclipse.cdt.ui/icons/ovr16/rec_referencedby_co.gif b/org.eclipse.cdt.ui/icons/ovr16/rec_referencedby_co.gif
new file mode 100644 (file)
index 0000000..6c93c32
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/ovr16/rec_referencedby_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/ovr16/rec_relatesto_co.gif b/org.eclipse.cdt.ui/icons/ovr16/rec_relatesto_co.gif
new file mode 100644 (file)
index 0000000..eef6eaa
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/ovr16/rec_relatesto_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/ovr16/referencedby_co.gif b/org.eclipse.cdt.ui/icons/ovr16/referencedby_co.gif
new file mode 100644 (file)
index 0000000..e2456a4
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/ovr16/referencedby_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/ovr16/relatestoMultiple_co.gif b/org.eclipse.cdt.ui/icons/ovr16/relatestoMultiple_co.gif
new file mode 100644 (file)
index 0000000..1b0984a
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/ovr16/relatestoMultiple_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/ovr16/relatesto_co.gif b/org.eclipse.cdt.ui/icons/ovr16/relatesto_co.gif
new file mode 100644 (file)
index 0000000..460f9b4
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/ovr16/relatesto_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/ovr16/setting_nav.gif b/org.eclipse.cdt.ui/icons/ovr16/setting_nav.gif
new file mode 100644 (file)
index 0000000..f25aa53
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/ovr16/setting_nav.gif differ
diff --git a/org.eclipse.cdt.ui/icons/ovr16/static_co.gif b/org.eclipse.cdt.ui/icons/ovr16/static_co.gif
new file mode 100644 (file)
index 0000000..9b2d21f
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/ovr16/static_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/ovr16/systeminclude_co.gif b/org.eclipse.cdt.ui/icons/ovr16/systeminclude_co.gif
new file mode 100644 (file)
index 0000000..5c474e5
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/ovr16/systeminclude_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/ovr16/template_co.gif b/org.eclipse.cdt.ui/icons/ovr16/template_co.gif
new file mode 100644 (file)
index 0000000..8b2e11f
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/ovr16/template_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/ovr16/volatile_co.gif b/org.eclipse.cdt.ui/icons/ovr16/volatile_co.gif
new file mode 100644 (file)
index 0000000..bfc7f9c
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/ovr16/volatile_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/ovr16/warning_co.gif b/org.eclipse.cdt.ui/icons/ovr16/warning_co.gif
new file mode 100644 (file)
index 0000000..ee2dac4
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/ovr16/warning_co.gif differ
diff --git a/org.eclipse.cdt.ui/icons/ovr16/write.gif b/org.eclipse.cdt.ui/icons/ovr16/write.gif
new file mode 100644 (file)
index 0000000..56cfe99
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/ovr16/write.gif differ
diff --git a/org.eclipse.cdt.ui/icons/view16/buildconsole.gif b/org.eclipse.cdt.ui/icons/view16/buildconsole.gif
new file mode 100644 (file)
index 0000000..e1f6e5c
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/view16/buildconsole.gif differ
diff --git a/org.eclipse.cdt.ui/icons/view16/c_pers.gif b/org.eclipse.cdt.ui/icons/view16/c_pers.gif
new file mode 100644 (file)
index 0000000..c2ec7be
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/view16/c_pers.gif differ
diff --git a/org.eclipse.cdt.ui/icons/view16/call_hierarchy.gif b/org.eclipse.cdt.ui/icons/view16/call_hierarchy.gif
new file mode 100644 (file)
index 0000000..7c7dca8
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/view16/call_hierarchy.gif differ
diff --git a/org.eclipse.cdt.ui/icons/view16/cbrowsing_pers.gif b/org.eclipse.cdt.ui/icons/view16/cbrowsing_pers.gif
new file mode 100644 (file)
index 0000000..1a8e5f9
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/view16/cbrowsing_pers.gif differ
diff --git a/org.eclipse.cdt.ui/icons/view16/chierch_pers.gif b/org.eclipse.cdt.ui/icons/view16/chierch_pers.gif
new file mode 100644 (file)
index 0000000..905c338
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/view16/chierch_pers.gif differ
diff --git a/org.eclipse.cdt.ui/icons/view16/class_hi.gif b/org.eclipse.cdt.ui/icons/view16/class_hi.gif
new file mode 100644 (file)
index 0000000..17f927e
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/view16/class_hi.gif differ
diff --git a/org.eclipse.cdt.ui/icons/view16/cprojects.gif b/org.eclipse.cdt.ui/icons/view16/cprojects.gif
new file mode 100644 (file)
index 0000000..be76eef
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/view16/cprojects.gif differ
diff --git a/org.eclipse.cdt.ui/icons/view16/cview.gif b/org.eclipse.cdt.ui/icons/view16/cview.gif
new file mode 100644 (file)
index 0000000..c2ec7be
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/view16/cview.gif differ
diff --git a/org.eclipse.cdt.ui/icons/view16/includeBrowser.gif b/org.eclipse.cdt.ui/icons/view16/includeBrowser.gif
new file mode 100644 (file)
index 0000000..8b784b6
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/view16/includeBrowser.gif differ
diff --git a/org.eclipse.cdt.ui/icons/view16/members.gif b/org.eclipse.cdt.ui/icons/view16/members.gif
new file mode 100644 (file)
index 0000000..e9a6bd9
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/view16/members.gif differ
diff --git a/org.eclipse.cdt.ui/icons/view16/namespaces.gif b/org.eclipse.cdt.ui/icons/view16/namespaces.gif
new file mode 100644 (file)
index 0000000..22f78af
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/view16/namespaces.gif differ
diff --git a/org.eclipse.cdt.ui/icons/view16/templates.gif b/org.eclipse.cdt.ui/icons/view16/templates.gif
new file mode 100644 (file)
index 0000000..a396ac7
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/view16/templates.gif differ
diff --git a/org.eclipse.cdt.ui/icons/view16/types.gif b/org.eclipse.cdt.ui/icons/view16/types.gif
new file mode 100644 (file)
index 0000000..5ba5b91
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/view16/types.gif differ
diff --git a/org.eclipse.cdt.ui/icons/wizban/addpath_wiz.gif b/org.eclipse.cdt.ui/icons/wizban/addpath_wiz.gif
new file mode 100644 (file)
index 0000000..97bddd0
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/wizban/addpath_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/wizban/c_app_wiz.gif b/org.eclipse.cdt.ui/icons/wizban/c_app_wiz.gif
new file mode 100644 (file)
index 0000000..cc58563
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/wizban/c_app_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/wizban/exportzip_wiz.png b/org.eclipse.cdt.ui/icons/wizban/exportzip_wiz.png
new file mode 100644 (file)
index 0000000..4bf65ce
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/wizban/exportzip_wiz.png differ
diff --git a/org.eclipse.cdt.ui/icons/wizban/fieldrefact_wiz.gif b/org.eclipse.cdt.ui/icons/wizban/fieldrefact_wiz.gif
new file mode 100644 (file)
index 0000000..f3e9221
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/wizban/fieldrefact_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/wizban/methrefact_wiz.gif b/org.eclipse.cdt.ui/icons/wizban/methrefact_wiz.gif
new file mode 100644 (file)
index 0000000..ec154e9
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/wizban/methrefact_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/wizban/newcfile_wiz.gif b/org.eclipse.cdt.ui/icons/wizban/newcfile_wiz.gif
new file mode 100644 (file)
index 0000000..1f91a8d
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/wizban/newcfile_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/wizban/newclass_wiz.gif b/org.eclipse.cdt.ui/icons/wizban/newclass_wiz.gif
new file mode 100644 (file)
index 0000000..eb5016a
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/wizban/newclass_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/wizban/newcprj_wiz.gif b/org.eclipse.cdt.ui/icons/wizban/newcprj_wiz.gif
new file mode 100644 (file)
index 0000000..df7c489
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/wizban/newcprj_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/wizban/newfile_wiz.gif b/org.eclipse.cdt.ui/icons/wizban/newfile_wiz.gif
new file mode 100644 (file)
index 0000000..136e94c
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/wizban/newfile_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/wizban/newfolder_wiz.gif b/org.eclipse.cdt.ui/icons/wizban/newfolder_wiz.gif
new file mode 100644 (file)
index 0000000..f988dc6
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/wizban/newfolder_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/wizban/newhfile_wiz.gif b/org.eclipse.cdt.ui/icons/wizban/newhfile_wiz.gif
new file mode 100644 (file)
index 0000000..d610654
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/wizban/newhfile_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/wizban/newmngc_app.gif b/org.eclipse.cdt.ui/icons/wizban/newmngc_app.gif
new file mode 100644 (file)
index 0000000..beefb8e
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/wizban/newmngc_app.gif differ
diff --git a/org.eclipse.cdt.ui/icons/wizban/newmngcc_app.gif b/org.eclipse.cdt.ui/icons/wizban/newmngcc_app.gif
new file mode 100644 (file)
index 0000000..85e3f72
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/wizban/newmngcc_app.gif differ
diff --git a/org.eclipse.cdt.ui/icons/wizban/newsrcfldr_wiz.gif b/org.eclipse.cdt.ui/icons/wizban/newsrcfldr_wiz.gif
new file mode 100644 (file)
index 0000000..d060586
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/wizban/newsrcfldr_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/icons/wizban/prj_obj.gif b/org.eclipse.cdt.ui/icons/wizban/prj_obj.gif
new file mode 100644 (file)
index 0000000..6624c90
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/wizban/prj_obj.gif differ
diff --git a/org.eclipse.cdt.ui/icons/wizban/typerefact_wiz.gif b/org.eclipse.cdt.ui/icons/wizban/typerefact_wiz.gif
new file mode 100644 (file)
index 0000000..ed3b49f
Binary files /dev/null and b/org.eclipse.cdt.ui/icons/wizban/typerefact_wiz.gif differ
diff --git a/org.eclipse.cdt.ui/plugin.properties b/org.eclipse.cdt.ui/plugin.properties
new file mode 100644 (file)
index 0000000..9897cc2
--- /dev/null
@@ -0,0 +1,610 @@
+###############################################################################
+# Copyright (c) 2003, 2011 IBM Corporation, QNX Software Systems, and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+#     Markus Schorn (Wind River Systems)
+#     Anton Leherbauer (Wind River Systems)
+#     Sergey Prigogin (Google)
+#     QNX Software Systems - [272416] Rework the working set configurations
+#     Axel Mueller - [289339] Surround with
+#     Tomasz Wesolowski
+#     James Blackburn (Broadcom Corp.)
+###############################################################################
+pluginName=C/C++ Development Tools UI
+providerName=Eclipse CDT
+
+elementFiltersName=CElement Filters
+binaryParserPage=Binary Parser Page
+pathContainerPage=Path Container Page
+textHoversName=Text Hovers
+cHelpProviderName=C Help Provider
+nature.name=C Nature
+perspective.name=C/C++
+viewsCategory.name=&C/C++
+CView.name=C/C++ Projects
+cPropertyTabName=New CDT Model Property Tab
+
+# The Wizards
+# C/C++
+newCWizardsCategory.name=C/C++
+
+categoryCDT.name=CDT
+
+#Project Conversion
+ConversionWizard.name=Convert a project's nature
+ConversionWizard.description=Convert a project's nature
+
+CElementCreationActionSet.label= C/C++ Element Creation
+CElementCreationActionSet.description= C/C++ Element Creation Action Set
+
+NewProjectDropDownAction.label=&Project...
+NewProjectDropDownAction.tooltip=New C/C++ Project
+
+NewFolderDropDownAction.label=&Source Folder...
+NewFolderDropDownAction.tooltip=New C/C++ Source Folder
+NewWizards.sourceFolder = Source Folder
+NewWizards.sourceFolder.description = Create a new source folder
+NewWizards.folder = Folder
+NewWizards.folder.description = Create a new folder resource
+
+NewFileDropDownAction.label=&Source File...
+NewFileDropDownAction.tooltip=New C/C++ Source File
+
+NewWizards.sourceFile = Source File
+NewWizards.sourceFile.description = Create a new source file
+NewWizards.headerFile = Header File
+NewWizards.headerFile.description = Create a new header file
+NewWizards.file = File from Template
+NewWizards.file.description = Create a new file resource based on a file template
+
+NewTypeDropDownAction.label=&Class...
+NewTypeDropDownAction.tooltip=New C++ Class
+NewWizards.class = Class
+NewWizards.class.description = Create a new C++ class
+
+# Editor 
+
+# Scope and Key Commands 
+scope.cEditor.name=C/C++ Editor
+cEditor.description=Editor for C/C++ Source Files
+
+category.source.name=C/C++ Source
+category.source.description= C/C++ Source Actions
+
+ActionDefinition.sourceQuickMenu.name= Show Source Quick Menu
+ActionDefinition.sourceQuickMenu.description= Shows the source quick menu
+
+ActionDefinition.comment.name= Comment
+ActionDefinition.comment.description= Turn the selected lines into // style comments
+
+ActionDefinition.uncomment.name= Uncomment
+ActionDefinition.uncomment.description= Uncomment the selected // style comment lines
+
+ActionDefinition.toggleComment.name= Comment/Uncomment
+ActionDefinition.toggleComment.description= Comment/Uncomment the selected lines
+
+ActionDefinition.opendecl.name= Open Declaration
+ActionDefinition.opendecl.description= Open an editor on the selected element's declaration(s)
+
+ActionDefinition.opencview.name= Show in C/C++ Project view
+ActionDefinition.opencview.description= Show the selected resource in the C/C++ Project view
+
+ActionDefinition.finddecl.name= Find Declaration
+ActionDefinition.finddecl.description= Find Declaration
+
+ActionDefinition.findrefs.name= Find References
+ActionDefinition.findrefs.description= Find References
+
+ActionDefinition.openCallHierarchy.name= Open Call Hierarchy
+ActionDefinition.openCallHierarchy.description= Open the call hierarchy for the selected element
+
+ActionDefinition.addBlockComment.name= Add Block Comment
+ActionDefinition.addBlockComment.description= Enclose the selection with a block comment
+
+ActionDefinition.removeBlockComment.name= Remove Block Comment
+ActionDefinition.removeBlockComment.description= Remove the block comment enclosing the selection
+
+ActionDefinition.indent.name= Indent Line
+ActionDefinition.indent.description=Indents the current line
+
+ActionDefinition.format.name=Format
+ActionDefinition.format.description=Format Source Code
+
+ActionDefinition.gotoMatchingBracket.name= Go to Matching Bracket
+ActionDefinition.gotoMatchingBracket.description= Moves the cursor to the matching bracket
+
+ActionDefinition.gotoNextBookmark.name= Next Bookmark
+ActionDefinition.gotoNextBookmark.description= Goto next bookmark of the selected file
+
+ActionDefinition.FindWord.name= Find Word
+ActionDefinition.FindWord.description= Select a word and find the next occurrence
+
+ActionDefinition.toggleSourceHeader.name= Toggle Source/Header
+ActionDefinition.toggleSourceHeader.description= Toggles between corresponding source and header files
+
+ActionDefinition.backwardMacroExpansion.name= Back
+ActionDefinition.backwardMacroExpansion.description= Step backward in macro expansions
+ActionDefinition.forwardMacroExpansion.name= Forward
+ActionDefinition.forwardMacroExpansion.description= Step forward in macro expansions
+
+ActionDefinition.showMacroExplorer.name= Explore Macro Expansion
+ActionDefinition.showMacroExplorer.description= Opens a quick view for macro expansion exploration
+
+category.refactoring.description= C/C++ Refactorings
+category.refactoring.name = Refactor - C++
+refactoringExtractConstant.label = Extract Constant...
+refactoringExtractLocalVariable.label = Extract Local Variable...
+refactoringHideMethod.label = Hide Memeber Function...
+
+
+ActionDefinition.renameElement.name= Rename - Refactoring 
+ActionDefinition.renameElement.description= Rename the selected element
+ActionDefinition.extractConstant.name= Extract Constant - Refactoring 
+ActionDefinition.extractConstant.description= Extract a constant for the selected expression
+ActionDefinition.extractLocalVariable.name= Extract Local Variable - Refactoring 
+ActionDefinition.extractLocalVariable.description= Extract a local variable for the selected expression
+ActionDefinition.extractFunction.name= Extract Function - Refactoring 
+ActionDefinition.extractFunction.description= Extract a function for the selected list of expressions or statements
+ActionDefinition.toggleFunction.name= Toggle Function - Refactoring 
+ActionDefinition.toggleFunction.description= Toggles the implementation between header and implementation file
+ActionDefinition.implementMethod.name= Implement Method - Source Generation 
+ActionDefinition.implementMethod.description= Implements a method for a selected method declaration
+ActionDefinition.gettersAndSetters.name = Generate Getters and Setters...
+ActionDefinition.gettersAndSetters.description = Generates getters and setters for a selected field
+
+ActionDefinition.surroundWith.quickMenu.name= Surround With Quick Menu
+ActionDefinition.surroundWith.quickMenu.description= Shows the Surround With quick menu
+
+# Action Set
+CodingActionSet.label= C/C++ Coding
+CodingActionSet.description= Action set containing coding related C/C++ actions
+
+Refactoring.menu.label= Refac&tor
+Refactoring.renameAction.label=Re&name...
+Refactoring.extractConstant.label=Extr&act Constant...
+Refactoring.extractLocalVariable.label=Extract &Local Variable
+Refactoring.extractFunction.label=Extract &Function...
+Refactoring.toggleFunction.label=Toggle Function
+Refactoring.hideMethod.label=Hide Method...
+Refactoring.implementMethod.label=Impl&ement Method...
+Refactoring.gettersAndSetters.label=Gene&rate Getters and Setters...
+
+Source.menu.label = &Source
+
+CEditor.name=C/C++ Editor
+
+CPluginPreferencePage.name=C/C++
+CPluginEditorPreferencePage.name=Editor
+CPluginTemplatePreferencePage.name=Templates
+CPluginBuildPreferencePage.name=Build
+CPluginBuildConsolePreferencePage.name=Console
+CPluginGlobalBuildLogPreferencePage.name=Logging
+CPluginFileTypesPreferencePage.name=File Types
+CodeFormatterPreferencePage.name=Code Style
+codeTemplatePreferencePage.name=Code Templates
+nameStylePreferencePage.name=Name Style
+CodeAssistPreferencePage.name=Content Assist
+CodeAssistAdvancedPreferencePage.name=Advanced
+SmartTypingPreferencePage.name=Typing
+ColoringPreferencePage.name=Syntax Coloring
+FoldingPreferencePage.name=Folding
+HoverPreferencePage.name=Hovers
+markOccurrencesPreferencePage.name=Mark Occurrences
+SaveActionsPreferencePage.name=Save Actions
+ScalabilityPreferencePage.name=Scalability
+
+DefaultBinaryFileEditor.name = Default Binary File Editor
+AsmEditor.name = Assembly Editor
+
+# Task Action
+DeleteTaskAction.label=Delete C/C++ Markers
+DeleteIProblemMarkerAction.label=Delete IProblem Markers
+OpenExternalProblemAction.label=Open external location
+
+# Build configuration actions
+BuildConfigActionSet.label=Build Configuration
+BuildConfigToolbarAction.label=Active Build Configuration
+BuildConfigMenuAction.label=Set Active
+BuildConfigContextAction.label=Set Active
+BuildConfigAction.tooltip=Change active build configuration for project(s)
+BuildConfigAction.tooltip2=Manage configurations for the current project
+BuildActiveConfiguration.label=Build Active Configuration
+BuildActiveConfiguration.tooltip=Build the active configurations of selected projects
+
+ManageConfigAction.label=Manage...
+DeleteRcConfigAction.label=Reset to Default...
+ExcludeAction.label=Exclude from Build...
+BuildConfigurationActionSet.descr=Build active configuration for the current project
+
+BuildLoggingPreferencePage.name=Logging
+
+# Common Editor ruler actions
+AddTask.label=Add &Task...
+AddTask.tooltip=Add Task...
+AddBookmark.label=Add Boo&kmark...
+AddBookmark.tooltip=Add Bookmark...
+QuickFix.label=&Quick Fix
+QuickFix.tooltip=Quick Fix
+
+# C/C++ Search
+CSearchPage.label= C/C++ Search
+openCSearchPageAction.label= &C/C++...
+ElementNameSorter.label= &Name
+ElementNameSorter.tooltip= Sort the view by C Element Name
+ParentNameSorter.label= &Parent Name
+ParentNameSorter.tooltip= Sort the view by C Element Parent Name
+PathNameSorter.label= P&ath
+PathNameSorter.tooltip= Sort the view by Resource Path
+
+# Action sets
+CSearchActionSet.label= C/C++ Search
+CSearchActionSet.description= Action set containing search related C/C++ actions
+CNavigationActionSet.label= C/C++ Navigation
+CNavigationActionSet.description= C/C++ Navigation Action Set
+COpenActionSet.label= C/C++ Open Actions
+COpenActionSet.description= Action set containing open actions for C/C++
+CEditorPresentationActionSet.label=C/C++ Editor Presentation
+CEditorPresentationActionSet.description=Actions to customize the C/C++ editor presentation
+
+# Menus
+searchMenu.label= Se&arch
+
+# Open Element
+OpenTypeAction.label= Open &Element...
+OpenTypeAction.tooltip= Open Element
+ActionDefinition.openType.name= Open Element
+ActionDefinition.openType.description= Open an element in an Editor
+
+#Add Include
+ActionDefinition.addInclude.name= Add Include
+ActionDefinition.addInclude.description= Create include statement on selection
+
+#Sort Lines
+ActionDefinition.sortLines.name= Sort Lines
+ActionDefinition.sortLines.description= Sort selected lines alphabetically
+
+#Show outline dialog
+ActionDefinition.showOutline.name= Show outline
+ActionDefinition.showOutline.description= Shows outline
+
+ActionDefinition.showQuickTypeHierarchy.name= Quick Type Hierarchy
+ActionDefinition.showQuickTypeHierarchy.description= Shows quick type hierarchy
+
+CElementWorkingSetPage.name = C/C++
+
+BuildConsole.name=CDT Build Console
+BuildConsoleFontDefinition.description= The CDT Build Console font is used by the CDT Build Console
+BuildConsoleFontDefinition.label= CDT Build Console Text Font
+
+ActionDefinition.GotoNextMember.name = Go to Next Member
+ActionDefinition.GotoNextMember.description = Move the caret to the next member of the translation unit
+ActionDefinition.GotoPrevMember.name = Go to Previous Member
+ActionDefinition.GotoPrevMember.description = Move the caret to the previous member of the translation unit
+
+##########################################################################
+# Filter Support
+##########################################################################
+
+HideClosedProjects.label= Closed projects
+HideClosedProjects.description= Hides closed projects
+
+HideExecutableFiles.label= Executable files
+HideExecutableFiles.description= Hides executable files
+
+HideSharedFiles.label= Shared object files
+HideSharedFiles.description= Hides shared object files
+
+HideArchiveFiles.label= Archive files
+HideArchiveFiles.description= Hides Archive files
+
+HideObjectFiles.label= Object files
+HideObjectFiles.description= Hides Object files
+
+HideNonCElements.label= Non-C elements
+HideNonCElements.description= Show only C elements
+
+HideNonCProjects.label = Non-C projects
+HideNonCProjects.description= Show only C projects
+
+HideReferencedLibraries.label= Referenced libraries
+HideReferencedLibraries.description= Hides referenced libraries i.e. those not contained inside the project itself
+
+HideCFiles.label= C files
+HideCFiles.description= Hides all C files
+
+HideHeaderFiles.label= Header files
+HideHeaderFiles.description= Hides all Header files
+
+HideUsingDirective.label= Using directive
+HideUsingDirective.description= Hides using directives
+
+HideMacroDirective.label= Macro directive
+HideMacroDirective.description= Hides Macro directives
+
+ForwardDeclarationFilter.label= Forward declaration
+ForwardDeclarationFilter.description= Hides forward declarations, unless found in a header file.
+
+#
+WorkInProgress.name=Work In Progress
+
+CDTSearch.name=Search
+
+CDTIndexerProperty.name=Indexer
+
+CDTHelpProperty.name=Documentation
+
+CDTFileTypesProperty.name=File Types
+
+CDTLanguagesProperty.name=Language Mappings
+
+cDocumentSetupParticipant=C Document Setup Participant
+asmDocumentSetupParticipant=Assembly Document Setup Participant
+
+defaultPathContainerPage=Default Path Container
+
+## CEditor Fonts
+CEditorFontDefiniton.label= C/C++ Editor Text Font
+CEditorFontDefinition.description = The C/C++ editor text font is used by C/C++ editors.
+#--- presentation
+CPresentation.label= C/C++
+CEditorPresentation.label= Editor
+
+CDTIndexerMarker.label= C/C++ Indexer Markers
+
+
+#Type Hierarchy
+CHierarchy.viewCategoryName= C/C++ Type Hierarchy
+CHierarchy.perspective.name=C/C++ Type Hierarchy
+CHierarchy.hierarchyViewName= Hierarchy
+ActionDefinition.open.hierarchy.name= Open Hierarchy
+ActionDefinition.open.hierarchy.description= Open the hierarchy of the selected element
+OpenTypeInHierarchyAction.label=Open Type in Hierarch&y...
+OpenTypeInHierarchyAction.description=Opens a type selected from the all types dialog in a type hierarchy
+OpenTypeInHierarchyAction.tooltip=Opens a Type in a Type Hierarchy
+OpenElementInCallHierarchyAction.label=Open Element in Ca&ll Hierarchy...
+OpenElementInCallHierarchyAction.description=Opens an element selected from a dialog in the call hierarchy
+OpenElementInCallHierarchyAction.tooltip=Opens an Element in the Call Hierarchy
+ActionDefinition.openTypeInHierarchy.name= Open Type in Hierarchy
+ActionDefinition.openTypeInHierarchy.description= Open a type in the type hierarchy view
+ActionDefinition.openTypeHierarchy.name= Open Type Hierarchy
+ActionDefinition.openTypeHierarchy.description= Open a type hierarchy on the selected element
+ActionDefinition.openElementInCallHierarchy.name= Open Element in Call Hierarchy
+ActionDefinition.openElementInCallHierarchy.description= Open an element in the call hierarchy view
+ActionDefinition.openIncludeBrowser.name= Open Include Browser
+ActionDefinition.openIncludeBrowser.description= Open an include browser on the selected element
+OpenTypeHierarchyAction.label=Open Type Hie&rarchy
+OpenTypeHierarchyAction.tooltip=Opens a Type Hierarchy for the Selected Element
+ViewCommand.typeHierarchy.name= C Type Hierarchy
+ViewCommand.typeHierarchy.description= Show the Type Hierarchy view
+OpenDeclarationAction.label=&Open Declaration
+OpenDeclarationAction.tooltip=Open an editor on the selected element's declaration
+
+# hovering contribution
+CEditorTextHoversName=C Editor Text Hovers
+sourceHover= Source
+sourceHoverDescription= Shows the source of the selected element.
+macroExpansionHover= Macro Expansion
+macroExpansionHoverDescription= Shows the expansion of the selected macro.
+cdocHover= Documentation
+cdocHoverDescription= Shows the documentation of the selected element.
+sequentialHover= Combined Hover
+sequentialHoverDescription= Tries the hovers in the sequence listed below and uses the one which fits best for the selected element and the current context.
+annotationHover= Annotation Description
+annotationHoverDescription= Shows the description of the selected annotation.
+problemHover= Problem Description
+problemHoverDescription= Shows the description of the selected problem.
+
+#
+appearancePrefName= Appearance
+
+# PathEntry Variable Preference Name
+pathEntryVariablesPrefName=PathEntry Variables
+
+#--- folding
+foldingStructureProvidersExtensionPoint= Folding Structure Providers
+defaultFoldingStructureProviderName= Default C Folding
+Folding.label= F&olding
+
+# Merge fonts
+cCompareFontDefinition.label= C/C++ compare text font
+cCompareFontDefinition.description= The C/C++ compare text font is used by C/C++ compare/merge tools.
+asmCompareFontDefinition.label= Assembly compare text font
+asmCompareFontDefinition.description= The Assembly compare text font is used by Assembly compare/merge tools.
+
+#--- templates
+c.contextType.name = C/C++
+comment.contextType.name = Comment
+doccomment.contextType.name = Doc Comment
+
+# completion
+completionContributors=Content Assist Completion Contributor
+completionProposalComputer=Completion Proposal Computer
+
+# Quick fix
+quickFixProcessorExtensionPoint=Quick Fix Processor
+quickAssistProcessorExtensionPoint=Quick Assist Processor
+spellingQuickFixProcessor=Spelling Quick Fix Processor
+defaultQuickAssistProcessor=Standard Quick Assist Processor
+
+# Spelling
+cSpellingEngine.label=C/C++ spelling engine
+
+# Indexer Preference Name
+indexerPrefName=Indexer
+
+# indexer names
+CDTIndexer.nullindexer=No Indexer (search based features will not work correctly)
+CDTIndexer.fastindexer=C/C++ Indexer
+
+IndexView.name=C/C++ Index
+RebuildIndex.name=&Rebuild
+SyncIndex.name=&Update with Modified Files
+FreshenIndex.name=&Freshen All Files
+SearchUnresolvedIncludes.name=Search for Unresolved &Includes
+CreateParserLog.name=Create Parser &Log File
+
+indexerPage.name = Indexer Page
+proposalFilter.name = Code Completion Proposal Filter
+includeBrowser.name = Include Browser
+callHierarchy.name = Call Hierarchy
+typeHierarchy.name = Type Hierarchy
+cSearchPage.name = CSearchPage
+
+# Task tags
+todoTaskPrefName = Task Tags
+
+# dummy label (not displayed)
+Dummy.label = dummy
+
+# Common Navigator
+navigatorContent.name = CDT Elements
+
+OpenCallHierarchy.label = Open Call H&ierarchy
+OpenCallHierarchy.tooltip = Open Call Hierarchy
+
+OpenIncludeBrowser.label = Open Inc&lude Browser
+OpenIncludeBrowser.tooltip = Open Include Browser
+
+ParserProposalCategory=Parsing-based Proposals
+DefaultProposalCategory= &Basic Proposals
+TemplateProposalCategory= Te&mplate Proposals
+TextProposalCategory= &Word Proposals
+HelpProposalCategory= Help Proposals
+
+SpecificContentAssist.name= C/C++ Content Assist
+SpecificContentAssist.desc= A parameterizable command that invokes content assist with a single completion proposal category
+SpecificContentAssist.param= type
+
+SurroundWithTemplateAction.label= Surround &With
+
+# CView context
+cViewScope.name = In C/C++ Views
+cViewScope.description = In C/C++ Views
+
+NewCfgDialog.name = newCfgDialog
+teamProjectIndexExportWizard.name = Team Shared Index
+teamProjectIndexExportWizard.description = Exports C/C++ index for use in other workspaces.
+exportWizard.CDTCategory.name = C/C++
+
+projectSettingsIndexExportWizard.name = C/C++ Project Settings
+importWizard.CDTCategory.name = C/C++
+
+page.c.general=C/C++ General
+# menu labels
+Configurations.menu=Build Configurations
+ResourceConfigurations.menu=Resource Configurations
+Index.menu=Index
+CDTWizard=CDT New Project Wizard
+
+CDTproject=CDT Project
+CDTproject.desc=Create a new language-neutral project
+CPPproject=C++ Project
+CPPproject.desc=Create a new C++ project
+Cproject=C Project
+Cproject.desc=Create a new C project
+
+TemplatePreferencePage.name=Template Default Values
+Template.Engine.Wizard=template entries contributor
+ConfigManager=Dialog for Configurations management
+
+HelpInfo=Allows contributing the map files to the map-file-based CDT CHelpProvider.
+
+# Macro Expansion Hover key binding context
+macroExpansionHoverScope.name= In Macro Expansion Hover
+macroExpansionHoverScope.description= In Macro Expansion Hover
+
+# Mark occurrences
+toggleMarkOccurrences.label= Toggle Mark Occurrences
+toggleMarkOccurrences.tooltip= Toggle Mark Occurrences
+toggleMarkOccurrences.description= Toggles mark occurrences in C/C++ editors
+
+OccurrenceAnnotation.label= C/C++ Occurrences
+WriteOccurrenceAnnotation.label= C/C++ Write Occurrences
+
+DocCommentOwner.name = DocCommentOwner
+Doxygen.name = Doxygen
+
+indexedFilesDecorator.label = C/C++ Indexed Files
+
+# Hyperlinking
+cEditorHyperlinkTarget= C/C++ Editor
+cElementHyperlinkDetector= C/C++ Elements
+
+keybinding.MSVS= Microsoft Visual Studio
+wsselection= Manage &Working Sets...
+workingSetConfigsPage=C/C++ Build
+activateWorkingSetConfig.label=Set &Active by Working Set
+activateWorkingSetConfig.context.label=Set &Active
+buildWorkingSetConfig.label=&Build by Working Set
+buildWorkingSetConfig.context.label=&Build
+workingSetConfigs.context.label=&Build Configurations
+workingSetConfigurationsExtensionPoint=Working Set Configurations
+
+# Keywords for Preferences
+preferenceKeywords.common=c cpp cplusplus cdt
+preferenceKeywords.codestyle=profile codestyle project specific comment indentation brace white space blank line new control statement wrapping tab parenthesis bracket
+preferenceKeywords.codetemplates=comment code constructor method file type content
+preferenceKeywords.namestyle=name file getter setter
+preferenceKeywords.todo=case sensitive task tag todo xxx fix fixme project comments
+preferenceKeywords.indexer=index skip references type macro search build configuration cache memory performance
+
+preferenceKeywords.ceditor=editor appearance navigation colors smart caret positioning highlight matching bracket inactive code foreground background save trailing whitespace newline doxygen
+preferenceKeywords.contentassist=editor content code assist complete completion insert overwrite single proposal common prefix automatically auto activation trigger category categories separate specific word hippie template
+preferenceKeywords.saveactions=editor save trailing whitespace white space end file newline 
+preferenceKeywords.scalability=editor mode large file lines disable performance 
+preferenceKeywords.hover=editor hover annotation key modifier combined variable problem string source documentation
+preferenceKeywords.syntaxcoloring=editor colors semantic coloring highlighting multi line single line comment task tag class struct union function method static field constant keywords local variable operators brackets strings type variable inherited method declaration
+preferenceKeywords.templates=editor templates snippet macros
+preferenceKeywords.folding=editor folding section comment header function method statement preprocessor
+preferenceKeywords.markoccurrences=editor occurrence mark highlight
+preferenceKeywords.smarttyping=editor typing type close comment tabs indentation indent imports wrap escape semicolons braces brackets parenthesis parentheses strings literals paste pasting tabulator automatically
+
+
+historyAction.label = History...
+createScriptAction.label = Create Script...
+applyScriptAction.label = Apply Script...
+renameParticipant.name = Source Folder Rename
+
+FormatAction.label= &Format
+IndentAction.label= Correct &Indentation
+AddIncludeAction.label= A&dd Include
+SortLinesAction.label= Sor&t Lines
+CommentAction.label= Co&mment
+UncommentAction.label= &Uncomment
+ToggleCommentAction.label= Togg&le Comment
+AddBlockCommentAction.label= Add &Block Comment
+RemoveBlockCommentAction.label= Remove Bloc&k Comment
+ShiftRightAction.label= &Shift Right
+ShiftLeftAction.label= S&hift Left
+
+# Decorators
+excluded-file.name = C/C++ Files Excluded from Build
+
+templatesViewName= Templates
+
+deleteConfigsCommand.name = Reset to Default
+excludeCommand.name = Exclude from Build
+ActionDefinition.selectEnclosing.description = Expand the selection to enclosing C/C++ element
+ActionDefinition.selectEnclosing.name = Select Enclosing C/C++ Element
+ActionDefinition.selectNext.description = Expand the selection to next C/C++ element
+ActionDefinition.selectNext.name = Select Next C/C++ Element
+ActionDefinition.selectPrevious.description = Expand the selection to enclosing C/C++ element
+ActionDefinition.selectPrevious.name = Select Previous C/C++ Element
+ActionDefinition.selectLast.description = Restore last selection in C/C++ editor
+ActionDefinition.selectLast.name = Restore Last C/C++ Selection
+overrideAnnotation.label = C/C++ Override indicators
+
+transfer.EditorAppearance.name = C/C++ Editor Appearance
+transfer.EditorAppearance.description = Preference related to how the editor presents the edited code to the user (including colors, fonts, hovers, foldings, etc...)
+transfer.EditorBehavior.name = C/C++ Editor Behavior
+transfer.EditorBehavior.description = Preference related to how the editor process the edited code (typing, save action, etc...)
+
+# Refresh Exclusion Contributors
+RefreshExclusionContributor.name = Resources
+
+extension-point.name = Refresh Exclusion Contributor
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/plugin.xml b/org.eclipse.cdt.ui/plugin.xml
new file mode 100644 (file)
index 0000000..047744a
--- /dev/null
@@ -0,0 +1,3977 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+
+   <extension-point id="CHelpProvider" name="%cHelpProviderName" schema="schema/CHelpProvider.exsd"/>
+   <extension-point id="CElementFilters" name="%elementFiltersName"/>
+   <extension-point id="BinaryParserPage" name="%binaryParserPage"/>
+   <extension-point id="PathContainerPage" name="%pathContainerPage" schema="schema/PathContainerPage.exsd"/>
+   <extension-point id="foldingStructureProviders" name="%foldingStructureProvidersExtensionPoint" schema="schema/foldingStructureProviders.exsd"/>
+   <extension-point id="cPropertyTab" name="%cPropertyTabName" schema="schema/cPropertyTab.exsd"/>
+   <extension-point id="CDTWizard" name="%CDTWizard" schema="schema/CDTWizard.exsd"/>
+   
+<!-- =========================================================================== -->
+<!-- Extension point: org.eclipse.cdt.ui.textHovers                        -->
+<!-- Extension Implementation: must implement org.eclipse.jface.text.ITextHover  -->
+<!-- Purpose: Provide a perspective specific text hovering for CEditor files     -->
+<!-- =========================================================================== -->
+   <extension-point id="textHovers" name="%textHoversName" schema="schema/textHovers.exsd"/>
+   <extension-point id="IndexerPage" name="%indexerPage.name" schema="schema/IndexerPage.exsd"/>
+   <extension-point id="ProposalFilter" name="%proposalFilter.name" schema="schema/ProposalFilter.exsd"/>
+   <extension-point id="completionProposalComputer" name="%completionProposalComputer" schema="schema/completionProposalComputer.exsd"/>
+   <extension-point id="newCfgDialog" name="%NewCfgDialog.name" schema="schema/newCfgDialog.exsd"/>
+   <extension-point id="ConfigManager" name="%ConfigManager" schema="schema/ConfigManager.exsd"/>
+   <extension-point id="HelpInfo" name="%HelpInfo" schema="schema/HelpInfo.exsd"/>
+   <extension-point id="quickFixProcessors" name="%quickFixProcessorExtensionPoint" schema="schema/quickFixProcessors.exsd"/>
+   <extension-point id="quickAssistProcessors" name="%quickAssistProcessorExtensionPoint" schema="schema/quickAssistProcessors.exsd"/>
+   <extension-point id="DocCommentOwner" name="%DocCommentOwner.name" schema="schema/DocCommentOwner.exsd"/>
+   <extension-point id="workingSetConfigurations" name="%workingSetConfigurationsExtensionPoint" schema="schema/workingSetConfigurations.exsd"/>
+   <extension-point id="RefreshExclusionContributor" name="%extension-point.name" schema="schema/RefreshExclusionContributor.exsd"/>
+
+   <extension
+         point="org.eclipse.core.runtime.adapters">
+      <factory
+            class="org.eclipse.cdt.internal.ui.CElementAdapterFactory"
+            adaptableType="org.eclipse.cdt.core.model.ICElement">
+         <adapter type="org.eclipse.core.resources.IResource"/>
+         <adapter type="org.eclipse.ui.model.IWorkbenchAdapter"/>
+         <adapter type="org.eclipse.ui.views.properties.IPropertySource"/>
+         <adapter type="org.eclipse.ui.progress.IDeferredWorkbenchAdapter"/>
+         <adapter type="org.eclipse.ui.IActionFilter"/>
+         <adapter type="org.eclipse.ui.IPersistableElement"/>
+      </factory>
+
+     <factory
+            class="org.eclipse.cdt.internal.ui.CElementAdapterFactory"
+            adaptableType="org.eclipse.cdt.core.model.ICContainer">
+         <adapter type="org.eclipse.core.resources.IFolder"/>
+      </factory>
+
+      <factory
+            class="org.eclipse.cdt.internal.ui.CElementAdapterFactory"
+            adaptableType="org.eclipse.cdt.core.model.ITranslationUnit">
+         <adapter type="org.eclipse.core.resources.IFile"/>
+      </factory>
+
+      <factory
+            class="org.eclipse.cdt.internal.ui.CProjectAdapterFactory"
+            adaptableType="org.eclipse.cdt.core.model.ICProject">
+         <adapter type="org.eclipse.core.resources.IProject"/>
+      </factory>
+   </extension>
+
+   <extension
+         point="org.eclipse.ui.elementFactories">
+      <factory
+            class="org.eclipse.cdt.internal.ui.PersistableCElementFactory"
+            id="org.eclipse.cdt.ui.PersistableCElementFactory"/>
+      <factory
+            class="org.eclipse.cdt.internal.ui.util.ExternalEditorInputFactory"
+            id="org.eclipse.cdt.ui.ExternalEditorInputFactory"/>
+   </extension>
+
+<!-- Implement our filters.  -->
+   <extension
+         point="org.eclipse.cdt.ui.CElementFilters">
+<!-- Implement our filters for C-View.  -->
+      <filter
+            targetId="org.eclipse.cdt.ui.CView"
+            selected="true"
+            pattern=".*">
+      </filter>
+      <filter
+            targetId="org.eclipse.cdt.ui.CView"
+            name="%HideExecutableFiles.label"
+            enabled="false"
+            description="%HideExecutableFiles.description"
+            class="org.eclipse.cdt.internal.ui.filters.ExecutableFilter"
+            id="org.eclipse.cdt.internal.ui.CView.ExecutableFilter">
+      </filter>
+      <filter
+            targetId="org.eclipse.cdt.ui.CView"
+            name="%HideSharedFiles.label"
+            enabled="false"
+            description="%HideSharedFiles.description"
+            class="org.eclipse.cdt.internal.ui.filters.SharedFilter"
+            id="org.eclipse.cdt.internal.ui.CView.SharedFilter">
+      </filter>
+      <filter
+            targetId="org.eclipse.cdt.ui.CView"
+            name="%HideObjectFiles.label"
+            enabled="false"
+            description="%HideObjectFiles.description"
+            class="org.eclipse.cdt.internal.ui.filters.ObjectFilter"
+            id="org.eclipse.cdt.internal.ui.CView.ObjectFilter">
+      </filter>
+      <filter
+            targetId="org.eclipse.cdt.ui.CView"
+            name="%HideArchiveFiles.label"
+            enabled="false"
+            description="%HideArchiveFiles.description"
+            class="org.eclipse.cdt.internal.ui.filters.ArchiveFilter"
+            id="org.eclipse.cdt.internal.ui.CView.ArchiveFilter">
+      </filter>
+      <filter
+            targetId="org.eclipse.cdt.ui.CView"
+            name="%HideClosedProjects.label"
+            enabled="false"
+            description="%HideClosedProjects.description"
+            class="org.eclipse.cdt.internal.ui.filters.ClosedProjectFilter"
+            id="org.eclipse.cdt.internal.ui.CView.ClosedProjectFilter">
+      </filter>
+      <filter
+            targetId="org.eclipse.cdt.ui.CView"
+            name="%HideNonCProjects.label"
+            enabled="false"
+            description="%HideNonCProjects.description"
+            class="org.eclipse.cdt.internal.ui.filters.NonCProjectsFilter"
+            id="org.eclipse.cdt.internal.ui.CView.NonCProjectsFilter">
+      </filter>
+      <filter
+            targetId="org.eclipse.cdt.ui.CView"
+            name="%HideNonCElements.label"
+            enabled="false"
+            description="%HideNonCElements.description"
+            class="org.eclipse.cdt.internal.ui.filters.NonCElementFilter"
+            id="org.eclipse.cdt.internal.ui.CView.NonCElementFilter">
+      </filter>
+<!-- C/C++ Outline Page -->
+      <filter
+            targetId="org.eclipse.cdt.ui.COutlinePage"
+            name="%HideUsingDirective.label"
+            enabled="false"
+            description="%HideUsingDirective.description"
+            class="org.eclipse.cdt.internal.ui.filters.UsingDirectiveFilter"
+            id="org.eclipse.cdt.ui.COutlinePage.UsingDeclarationFilter">
+      </filter>
+      <filter
+            targetId="org.eclipse.cdt.ui.COutlinePage"
+            name="%HideMacroDirective.label"
+            enabled="false"
+            description="%HideMacroDirective.description"
+            class="org.eclipse.cdt.internal.ui.filters.MacroDirectiveFilter"
+            id="org.eclipse.cdt.ui.COutlinePage.MacroDirectiveFilter">
+      </filter>
+      <filter
+            targetId="org.eclipse.cdt.ui.COutlinePage"
+            name="%ForwardDeclarationFilter.label"
+            enabled="false"
+            description="%ForwardDeclarationFilter.description" 
+            class="org.eclipse.cdt.internal.ui.filters.ForwardDeclarationFilter"
+            id="org.eclipse.cdt.ui.COutlinePage.ForwardDeclarationFilter">
+      </filter>
+<!-- Asm Outline Page -->
+      <filter
+            targetId="org.eclipse.cdt.ui.AsmOutlinePage"
+            name="%HideMacroDirective.label"
+            enabled="false"
+            description="%HideMacroDirective.description"
+            class="org.eclipse.cdt.internal.ui.filters.MacroDirectiveFilter"
+            id="org.eclipse.cdt.ui.AsmOutlinePage.MacroDirectiveFilter">
+      </filter>
+   </extension>
+      <extension
+         point="org.eclipse.cdt.ui.textHovers">
+      <hover
+            label="%sequentialHover"
+            description="%sequentialHoverDescription"
+            class="org.eclipse.cdt.internal.ui.text.c.hover.BestMatchHover"
+            id="org.eclipse.cdt.ui.BestMatchHover">
+      </hover>
+      <hover
+            label="%problemHover"
+            description="%problemHoverDescription"
+            class="org.eclipse.cdt.internal.ui.text.c.hover.ProblemHover"
+            id="org.eclipse.cdt.ui.ProblemHover">
+      </hover>
+      <hover
+            label="%cdocHover"
+            description="%cdocHoverDescription"
+            class="org.eclipse.cdt.internal.ui.text.c.hover.CDocHover"
+            id="org.eclipse.cdt.ui.CDocHover">
+      </hover>
+      <hover
+            label="%sourceHover"
+            description="%sourceHoverDescription"
+            class="org.eclipse.cdt.internal.ui.text.c.hover.CSourceHover"
+            id="org.eclipse.cdt.ui.CSourceHover">
+      </hover>
+      <hover
+            label="%macroExpansionHover"
+            description="%macroExpansionHoverDescription"
+            class="org.eclipse.cdt.internal.ui.text.c.hover.CMacroExpansionHover"
+            id="org.eclipse.cdt.ui.CMacroExpansionHover">
+      </hover>
+      <hover
+            label="%annotationHover"
+            description="%annotationHoverDescription"
+            class="org.eclipse.cdt.internal.ui.text.c.hover.AnnotationHover"
+            id="org.eclipse.cdt.ui.AnnotationHover">
+      </hover>
+   </extension>
+   
+   <extension
+         point="org.eclipse.ui.perspectives">
+      <perspective
+            name="%perspective.name"
+            icon="icons/view16/c_pers.gif"
+            class="org.eclipse.cdt.internal.ui.CPerspectiveFactory"
+            id="org.eclipse.cdt.ui.CPerspective">
+      </perspective>
+   </extension>
+   <extension
+         point="org.eclipse.ui.perspectiveExtensions">
+      <perspectiveExtension
+            targetID="org.eclipse.ui.resourcePerspective">
+         <perspectiveShortcut
+               id="org.eclipse.cdt.ui.CPerspective">
+         </perspectiveShortcut>
+      </perspectiveExtension>
+      <perspectiveExtension
+            targetID="org.eclipse.debug.ui.DebugPerspective">
+         <perspectiveShortcut
+               id="org.eclipse.cdt.ui.CPerspective">
+         </perspectiveShortcut>
+      </perspectiveExtension>
+      <perspectiveExtension
+            targetID="org.eclipse.cdt.ui.CPerspective">
+         <perspectiveShortcut
+               id="org.eclipse.debug.ui.DebugPerspective">
+         </perspectiveShortcut>
+         <perspectiveShortcut
+               id="org.eclipse.team.ui.TeamSynchronizingPerspective">
+         </perspectiveShortcut>
+         <actionSet id="org.eclipse.debug.ui.launchActionSet"/>
+         <actionSet id="org.eclipse.cdt.ui.buildConfigActionSet"/>
+         <actionSet id="org.eclipse.cdt.ui.NavigationActionSet"/>
+         <actionSet id="org.eclipse.cdt.ui.OpenActionSet"/>
+         <actionSet id="org.eclipse.cdt.ui.CodingActionSet"/>
+         <actionSet id="org.eclipse.ui.edit.text.actionSet.presentation"/>
+
+         <showInPart id="org.eclipse.cdt.ui.includeBrowser"/>
+         <showInPart id="org.eclipse.cdt.ui.CView"/>
+         <showInPart id="org.eclipse.ui.navigator.ProjectExplorer"/>
+         <viewShortcut id="org.eclipse.ui.navigator.ProjectExplorer"/>
+         <viewShortcut id="org.eclipse.cdt.ui.includeBrowser"/>
+      </perspectiveExtension>
+   </extension>
+   <extension
+         point="org.eclipse.ui.views">
+      <category
+            name="%viewsCategory.name"
+            id="org.eclipse.cdt.ui.views">
+      </category>
+      <view
+            name="%CView.name"
+            icon="icons/view16/cview.gif"
+            category="org.eclipse.cdt.ui.views"
+            class="org.eclipse.cdt.internal.ui.cview.CView"
+            id="org.eclipse.cdt.ui.CView">
+      </view>
+      <view
+            category="org.eclipse.cdt.ui.views"
+            class="org.eclipse.cdt.internal.ui.indexview.IndexView"
+            icon="icons/view16/types.gif"
+            id="org.eclipse.cdt.ui.IndexView"
+            name="%IndexView.name"/>
+      <view
+            category="org.eclipse.cdt.ui.views"
+            class="org.eclipse.cdt.internal.ui.includebrowser.IBViewPart"
+            icon="icons/view16/includeBrowser.gif"
+            id="org.eclipse.cdt.ui.includeBrowser"
+            name="%includeBrowser.name"/>
+      <view
+            category="org.eclipse.cdt.ui.views"
+            class="org.eclipse.cdt.internal.ui.callhierarchy.CHViewPart"
+            icon="icons/view16/call_hierarchy.gif"
+            id="org.eclipse.cdt.ui.callHierarchy"
+            name="%callHierarchy.name"/>
+      <view
+            category="org.eclipse.cdt.ui.views"
+            class="org.eclipse.cdt.internal.ui.typehierarchy.THViewPart"
+            icon="icons/view16/class_hi.gif"
+            id="org.eclipse.cdt.ui.typeHierarchy"
+            name="%typeHierarchy.name"/>
+      <view
+            name="%templatesViewName"
+            icon="$nl$/icons/view16/templates.gif"
+            category="org.eclipse.ui"
+            class="org.eclipse.ui.texteditor.templates.TemplatesView"
+            id="org.eclipse.ui.texteditor.TemplatesView" />
+   </extension>
+<!-- The wizards -->
+   <extension
+         point="org.eclipse.ui.newWizards">
+      <category
+            name="%newCWizardsCategory.name"
+            id="org.eclipse.cdt.ui.newCWizards">
+      </category>
+      <wizard
+            name="%NewWizards.sourceFile"
+            icon="icons/etool16/newcfile_wiz.gif"
+            category="org.eclipse.cdt.ui.newCWizards"
+            finalPerspective="org.eclipse.cdt.ui.CPerspective"
+            id="org.eclipse.cdt.ui.wizards.NewSourceFileCreationWizard">
+         <class class="org.eclipse.cdt.ui.wizards.NewSourceFileCreationWizard">
+            <parameter name="cfile" value="true"/>
+         </class>
+         <description>
+            %NewWizards.sourceFile.description
+         </description>
+      </wizard>
+      <wizard
+            name="%NewWizards.headerFile"
+            icon="icons/etool16/newhfile_wiz.gif"
+            category="org.eclipse.cdt.ui.newCWizards"
+            finalPerspective="org.eclipse.cdt.ui.CPerspective"
+            id="org.eclipse.cdt.ui.wizards.NewHeaderFileCreationWizard">
+         <class class="org.eclipse.cdt.ui.wizards.NewHeaderFileCreationWizard">
+            <parameter name="cfile" value="true"/>
+         </class>
+         <description>
+            %NewWizards.headerFile.description
+         </description>
+      </wizard>
+      <wizard
+            name="%NewWizards.file"
+            icon="icons/etool16/newfile_wiz.gif"
+            category="org.eclipse.cdt.ui.newCWizards"
+            finalPerspective="org.eclipse.cdt.ui.CPerspective"
+            id="org.eclipse.cdt.ui.wizards.NewFileCreationWizard">
+         <class class="org.eclipse.cdt.internal.ui.wizards.filewizard.NewFileFromTemplateWizard">
+            <parameter name="cfile" value="true"/>
+         </class>
+         <description>
+            %NewWizards.file.description
+         </description>
+      </wizard>
+      <wizard
+            name="%NewWizards.sourceFolder"
+            icon="icons/etool16/newsrcfldr_wiz.gif"
+            category="org.eclipse.cdt.ui.newCWizards"
+            finalPerspective="org.eclipse.cdt.ui.CPerspective"
+            id="org.eclipse.cdt.ui.wizards.NewSourceFolderCreationWizard">
+         <class class="org.eclipse.cdt.ui.wizards.NewSourceFolderCreationWizard">
+            <parameter name="cfolder" value="true"/>
+         </class>
+         <description>
+            %NewWizards.sourceFolder.description
+         </description>
+      </wizard>
+      <wizard
+            name="%NewWizards.folder"
+            icon="icons/etool16/newfolder_wiz.gif"
+            category="org.eclipse.cdt.ui.newCWizards"
+            finalPerspective="org.eclipse.cdt.ui.CPerspective"
+            id="org.eclipse.cdt.ui.wizards.NewFolderCreationWizard">
+         <class class="org.eclipse.ui.wizards.newresource.BasicNewFolderResourceWizard">
+            <parameter name="cfolder" value="true"/>
+         </class>
+         <description>
+            %NewWizards.folder.description
+         </description>
+      </wizard>
+      <wizard
+            name="%NewWizards.class"
+            icon="icons/etool16/newclass_wiz.gif"
+            category="org.eclipse.cdt.ui.newCWizards"
+            finalPerspective="org.eclipse.cdt.ui.CPerspective"
+            id="org.eclipse.cdt.ui.wizards.NewClassCreationWizard">
+         <class class="org.eclipse.cdt.internal.ui.wizards.NewClassCreationWizard">
+            <parameter name="ctype" value="true"/>
+            <parameter targetId="org.eclipse.cdt.ui.actions.NewTypeDropDown"/>
+         </class>
+         <description>
+            %NewWizards.class.description
+         </description>
+      </wizard>
+      <wizard
+            canFinishEarly="false"
+            category="org.eclipse.cdt.ui.newCWizards"
+            class="org.eclipse.cdt.ui.wizards.CCProjectWizard"
+            finalPerspective="org.eclipse.cdt.ui.CPerspective"
+            hasPages="true"
+            icon="icons/elcl16/newmngcc_app.gif"
+            id="org.eclipse.cdt.ui.wizards.NewCWizard1"
+            name="%CPPproject"
+            project="true">
+          <description>
+             %CPPproject.desc
+          </description>
+       </wizard>
+       <wizard
+             canFinishEarly="false"
+             category="org.eclipse.cdt.ui.newCWizards"
+             class="org.eclipse.cdt.ui.wizards.CProjectWizard"
+             finalPerspective="org.eclipse.cdt.ui.CPerspective"
+             hasPages="true"
+             icon="icons/elcl16/newmngcc_app.gif"
+             id="org.eclipse.cdt.ui.wizards.NewCWizard2"
+             name="%Cproject"
+             project="true">
+         <description>
+             %Cproject.desc
+         </description>
+      </wizard>
+   </extension>
+
+<!-- Define the document setup participant for the C/C++ and Assembly Editors -->
+   <extension
+         id="org.eclipse.cdt.ui.CDocumentSetupParticipant"
+         name="%cDocumentSetupParticipant"
+         point="org.eclipse.core.filebuffers.documentSetup">
+      <participant
+            class="org.eclipse.cdt.internal.ui.editor.CDocumentSetupParticipant"
+            contentTypeId="org.eclipse.cdt.core.cSource">
+      </participant>
+   </extension>
+   <extension
+         id="org.eclipse.cdt.ui.CDocumentSetupParticipant"
+         name="%cDocumentSetupParticipant"
+         point="org.eclipse.core.filebuffers.documentSetup">
+      <participant
+            class="org.eclipse.cdt.internal.ui.editor.CDocumentSetupParticipant"
+            contentTypeId="org.eclipse.cdt.core.cHeader">
+      </participant>
+   </extension>
+   <extension
+         id="org.eclipse.cdt.ui.CDocumentSetupParticipant"
+         name="%cDocumentSetupParticipant"
+         point="org.eclipse.core.filebuffers.documentSetup">
+      <participant
+            class="org.eclipse.cdt.internal.ui.editor.CDocumentSetupParticipant"
+            contentTypeId="org.eclipse.cdt.core.cxxSource">
+      </participant>
+   </extension>
+   <extension
+         id="org.eclipse.cdt.ui.CDocumentSetupParticipant"
+         name="%cDocumentSetupParticipant"
+         point="org.eclipse.core.filebuffers.documentSetup">
+      <participant
+            class="org.eclipse.cdt.internal.ui.editor.CDocumentSetupParticipant"
+            contentTypeId="org.eclipse.cdt.core.cxxHeader">
+      </participant>
+   </extension>
+   <extension
+         id="org.eclipse.cdt.ui.AsmDocumentSetupParticipant"
+         name="%asmDocumentSetupParticipant"
+         point="org.eclipse.core.filebuffers.documentSetup">
+      <participant
+            class="org.eclipse.cdt.internal.ui.editor.asm.AsmDocumentSetupParticipant"
+            contentTypeId="org.eclipse.cdt.core.asmSource">
+      </participant>
+   </extension>
+<!-- Define the C/C++ and Assembly Editors -->
+   <extension
+         id="org.eclipse.cdt.ui.ceditor"
+         point="org.eclipse.ui.editors">
+      <editor
+            default="true"
+            name="%CEditor.name"
+            icon="icons/obj16/c_file_obj.gif"
+            class="org.eclipse.cdt.internal.ui.editor.CEditor"
+            contributorClass="org.eclipse.cdt.internal.ui.editor.CEditorActionContributor"
+            symbolicFontName="org.eclipse.cdt.ui.editors.textfont"
+            id="org.eclipse.cdt.ui.editor.CEditor">
+            <contentTypeBinding contentTypeId="org.eclipse.cdt.core.cSource"/>
+            <contentTypeBinding contentTypeId="org.eclipse.cdt.core.cxxSource"/>
+            <contentTypeBinding contentTypeId="org.eclipse.cdt.core.cxxHeader"/>
+            <contentTypeBinding contentTypeId="org.eclipse.cdt.core.cHeader"/>
+            <contentTypeBinding contentTypeId="org.eclipse.cdt.core.cSource"/>
+      </editor>
+      <editor
+            name="%AsmEditor.name"
+            icon="icons/obj16/s_file_obj.gif"
+            class="org.eclipse.cdt.internal.ui.editor.asm.AsmTextEditor"
+            contributorClass="org.eclipse.cdt.internal.ui.editor.asm.ASMEditorActionContributor"
+            symbolicFontName="org.eclipse.cdt.ui.editors.textfont"
+            id="org.eclipse.cdt.ui.editor.asm.AsmEditor">
+            <contentTypeBinding contentTypeId="org.eclipse.cdt.core.asmSource"/>
+      </editor>
+      <editor
+            class="org.eclipse.cdt.internal.ui.editor.DefaultBinaryFileEditor"
+            default="false"
+            icon="icons/obj16/bin_obj.gif"
+            id="org.eclipse.cdt.ui.binaryEditor"
+            name="%DefaultBinaryFileEditor.name">
+         <contentTypeBinding
+               contentTypeId="org.eclipse.cdt.core.binaryFile">
+         </contentTypeBinding>
+      </editor>
+   </extension>
+
+   <extension
+       point="org.eclipse.ui.themes">
+       <themeElementCategory label="%CPresentation.label" id="org.eclipse.cdt.ui.presentation"/>
+          <themeElementCategory label="%CEditorPresentation.label" id="org.eclipse.cdt.ui.CEditor.presentation" parentId= "org.eclipse.cdt.ui.presentation"/>
+       <fontDefinition
+            label="%CEditorFontDefiniton.label"
+            defaultsTo="org.eclipse.jface.textfont"
+            categoryId="org.eclipse.cdt.ui.CEditor.presentation"
+            id="org.eclipse.cdt.ui.editors.textfont">
+         <description>
+            %CEditorFontDefinition.description
+         </description>
+       </fontDefinition>
+             <fontDefinition
+            label="%BuildConsoleFontDefinition.label"
+            defaultsTo="org.eclipse.jface.textfont"
+            categoryId="org.eclipse.cdt.ui.presentation"
+            id="org.eclipse.cdt.ui.buildconsole.ConsoleFont">
+         <description>
+            %BuildConsoleFontDefinition.description
+         </description>
+      </fontDefinition>
+            <fontDefinition
+            label="%cCompareFontDefinition.label"
+            defaultsTo="org.eclipse.cdt.ui.editors.textfont"
+            categoryId="org.eclipse.compare.contentmergeviewer.TextMergeViewer"
+            id="org.eclipse.cdt.internal.ui.compare.CMergeViewer">
+         <description>
+            %cCompareFontDefinition.description
+         </description>
+      </fontDefinition>
+            <fontDefinition
+            label="%asmCompareFontDefinition.label"
+            defaultsTo="org.eclipse.cdt.ui.editors.textfont"
+            categoryId="org.eclipse.compare.contentmergeviewer.TextMergeViewer"
+            id="org.eclipse.cdt.internal.ui.compare.AsmMergeViewer">
+         <description>
+            %asmCompareFontDefinition.description
+         </description>
+      </fontDefinition>
+      <colorDefinition
+         id="org.eclipse.cdt.ui.content_assist_proposals_background"
+         isEditable="false"
+         label="%Dummy.label"
+         value="255,255,255">
+      </colorDefinition>
+      <colorDefinition
+         id="org.eclipse.cdt.ui.content_assist_proposals_foreground"
+         isEditable="false"
+         label="%Dummy.label"
+         value="0,0,0">
+      </colorDefinition>
+      <colorDefinition
+         id="org.eclipse.cdt.ui.content_assist_parameters_background"
+         isEditable="false"
+         label="%Dummy.label"
+         value="255,255,255">
+      </colorDefinition>
+      <colorDefinition
+         id="org.eclipse.cdt.ui.content_assist_parameters_foreground"
+         isEditable="false"
+         label="%Dummy.label"
+         value="0,0,0">
+      </colorDefinition>
+      <colorDefinition
+            id="org.eclipse.cdt.ui.ColoredLabels.match_highlight"
+            isEditable="false"
+            label="%Dummy.label"
+            value="206, 204, 247">
+      </colorDefinition>
+      <colorDefinition
+            id="org.eclipse.cdt.ui.ColoredLabels.writeaccess_highlight"
+            isEditable="false"
+            label="%Dummy.label"
+            value="240, 216, 168">
+      </colorDefinition>
+      <theme
+         id="org.eclipse.ui.ide.systemDefault">
+         <colorOverride
+            id="org.eclipse.cdt.ui.content_assist_proposals_background"
+            value="COLOR_LIST_BACKGROUND">
+         </colorOverride>
+         <colorOverride
+            id="org.eclipse.cdt.ui.content_assist_proposals_foreground"
+            value="COLOR_LIST_FOREGROUND">
+         </colorOverride>
+         <colorOverride
+            id="org.eclipse.cdt.ui.content_assist_parameters_background"
+            value="COLOR_LIST_BACKGROUND">
+         </colorOverride>
+         <colorOverride
+            id="org.eclipse.cdt.ui.content_assist_parameters_foreground"
+            value="COLOR_LIST_FOREGROUND">
+         </colorOverride>
+      </theme>
+   </extension>
+
+   <extension
+         point="org.eclipse.ui.preferencePages">
+      <page
+            name="%CPluginPreferencePage.name"
+            class="org.eclipse.cdt.internal.ui.preferences.CPluginPreferencePage"
+            id="org.eclipse.cdt.ui.preferences.CPluginPreferencePage">
+          <keywordReference id="org.eclipse.cdt.ui.common"/>
+      </page>
+      <page
+            name="%CPluginEditorPreferencePage.name"
+            category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
+            class="org.eclipse.cdt.internal.ui.preferences.CEditorPreferencePage"
+            id="org.eclipse.cdt.ui.preferences.CEditorPreferencePage">
+          <keywordReference id="org.eclipse.cdt.ui.ceditor"/>
+          <keywordReference id="org.eclipse.cdt.ui.common"/>
+      </page>
+      <page
+            name="%CodeAssistPreferencePage.name"
+            category="org.eclipse.cdt.ui.preferences.CEditorPreferencePage"
+            class="org.eclipse.cdt.internal.ui.preferences.CodeAssistPreferencePage"
+            id="org.eclipse.cdt.ui.preferences.CodeAssistPreferencePage">
+          <keywordReference id="org.eclipse.cdt.ui.contentassist"/>
+          <keywordReference id="org.eclipse.cdt.ui.common"/>
+      </page>
+      <page
+            name="%CodeAssistAdvancedPreferencePage.name"
+            category="org.eclipse.cdt.ui.preferences.CodeAssistPreferencePage"
+            class="org.eclipse.cdt.internal.ui.preferences.CodeAssistAdvancedPreferencePage"
+            id="org.eclipse.cdt.ui.preferences.CodeAssistPreferenceAdvanced">
+          <keywordReference id="org.eclipse.cdt.ui.contentassist"/>
+          <keywordReference id="org.eclipse.cdt.ui.common"/>
+      </page>
+      <page
+            name="%ColoringPreferencePage.name"
+            category="org.eclipse.cdt.ui.preferences.CEditorPreferencePage"
+            class="org.eclipse.cdt.internal.ui.preferences.CEditorColoringPreferencePage"
+            id="org.eclipse.cdt.ui.preferences.CodeColoringPreferencePage">
+          <keywordReference id="org.eclipse.cdt.ui.syntaxcoloring"/>
+          <keywordReference id="org.eclipse.cdt.ui.common"/>
+      </page>
+      <page
+            name="%FoldingPreferencePage.name"
+            category="org.eclipse.cdt.ui.preferences.CEditorPreferencePage"
+            class="org.eclipse.cdt.internal.ui.preferences.FoldingPreferencePage"
+            id="org.eclipse.cdt.ui.preferences.FoldingPreferencePage">
+          <keywordReference id="org.eclipse.cdt.ui.folding"/>
+          <keywordReference id="org.eclipse.cdt.ui.common"/>
+      </page>
+      <page
+            name="%HoverPreferencePage.name"
+            category="org.eclipse.cdt.ui.preferences.CEditorPreferencePage"
+            class="org.eclipse.cdt.internal.ui.preferences.CEditorHoverPreferencePage"
+            id="org.eclipse.cdt.ui.preferences.HoverPreferencePage">
+          <keywordReference id="org.eclipse.cdt.ui.hover"/>
+          <keywordReference id="org.eclipse.cdt.ui.common"/>
+      </page>
+      <page
+            name="%CPluginTemplatePreferencePage.name"
+            category="org.eclipse.cdt.ui.preferences.CEditorPreferencePage"
+            class="org.eclipse.cdt.internal.ui.preferences.CTemplatePreferencePage"
+            id="org.eclipse.cdt.ui.preferences.TemplatePreferencePage">
+          <keywordReference id="org.eclipse.cdt.ui.templates"/>
+          <keywordReference id="org.eclipse.cdt.ui.common"/>
+      </page>
+      <page
+            name="%SmartTypingPreferencePage.name"
+            category="org.eclipse.cdt.ui.preferences.CEditorPreferencePage"
+            class="org.eclipse.cdt.internal.ui.preferences.SmartTypingPreferencePage"
+            id="org.eclipse.cdt.ui.preferences.SmartTypingPreferencePage">
+          <keywordReference id="org.eclipse.cdt.ui.smarttyping"/>
+          <keywordReference id="org.eclipse.cdt.ui.common"/>
+      </page>
+      <page
+            name="%CodeFormatterPreferencePage.name"
+            category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
+            class="org.eclipse.cdt.internal.ui.preferences.CodeFormatterPreferencePage"
+            id="org.eclipse.cdt.ui.preferences.CodeFormatterPreferencePage">
+          <keywordReference id="org.eclipse.cdt.ui.codestyle"/>
+          <keywordReference id="org.eclipse.cdt.ui.common"/>
+      </page>
+      <!-- Build Preference page category provided by CDT UI -->
+      <page
+            name="%CPluginBuildPreferencePage.name"
+            category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
+            class="org.eclipse.cdt.internal.ui.build.BuildPreferencePage"
+            id="org.eclipse.cdt.ui.preferences.BuildSettings">
+          <keywordReference id="org.eclipse.cdt.ui.common"/>
+      </page>
+      <!-- Note that build console should be eventually moved to build plugin -->
+      <page
+            name="%CPluginBuildConsolePreferencePage.name"
+            category="org.eclipse.cdt.ui.preferences.BuildSettings"
+            class="org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage"
+            id="org.eclipse.cdt.ui.preferences.CBuildConsolePreferences">
+          <keywordReference id="org.eclipse.cdt.ui.common"/>
+      </page>
+      <page
+            name="%CPluginGlobalBuildLogPreferencePage.name"
+            category="org.eclipse.cdt.ui.preferences.BuildSettings"
+            class="org.eclipse.cdt.internal.ui.preferences.GlobalBuildLogPreferencePage"
+            id="org.eclipse.cdt.ui.preferences.CGlobalBuildLogPreferences">
+          <keywordReference id="org.eclipse.cdt.ui.common"/>
+      </page>
+      <page
+            name="%CPluginFileTypesPreferencePage.name"
+            category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
+            class="org.eclipse.cdt.internal.ui.preferences.CFileTypesPreferencePage"
+            id="org.eclipse.cdt.ui.preferences.CFileTypesPreferences">
+          <keywordReference id="org.eclipse.cdt.ui.common"/>
+      </page>
+      <page
+            name="%appearancePrefName"
+            category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
+            class="org.eclipse.cdt.internal.ui.preferences.AppearancePreferencePage"
+            id="org.eclipse.cdt.ui.preferences.AppearancePreferencePage">
+          <keywordReference id="org.eclipse.cdt.ui.common"/>
+      </page>
+      <page
+            category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
+            class="org.eclipse.cdt.internal.ui.preferences.IndexerPreferencePage"
+            id="org.eclipse.cdt.ui.preferences.IndexerPreferencePage"
+            name="%indexerPrefName">
+          <keywordReference id="org.eclipse.cdt.ui.indexer"/>
+          <keywordReference id="org.eclipse.cdt.ui.common"/>
+      </page>
+      <page
+            category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
+            class="org.eclipse.cdt.internal.ui.language.WorkspaceLanguageMappingPreferencePage"
+            id="org.eclipse.cdt.ui.preferences.LanguageMappings"
+            name="%CDTLanguagesProperty.name">
+          <keywordReference id="org.eclipse.cdt.ui.common"/>
+      </page>
+      <page
+            category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
+            class="org.eclipse.cdt.internal.ui.preferences.TodoTaskPreferencePage"
+            id="org.eclipse.cdt.ui.preferences.TodoTaskPreferencePage"
+            name="%todoTaskPrefName">
+          <keywordReference id="org.eclipse.cdt.ui.todo"/>
+          <keywordReference id="org.eclipse.cdt.ui.common"/>
+      </page>
+      <page
+            name="%codeTemplatePreferencePage.name"
+            category="org.eclipse.cdt.ui.preferences.CodeFormatterPreferencePage"
+            class="org.eclipse.cdt.internal.ui.preferences.CodeTemplatePreferencePage"
+            id="org.eclipse.cdt.ui.preferences.CodeTemplatePreferencePage">
+          <keywordReference id="org.eclipse.cdt.ui.codetemplates"/>
+          <keywordReference id="org.eclipse.cdt.ui.common"/>
+      </page>
+      <page
+            name="%nameStylePreferencePage.name"
+            category="org.eclipse.cdt.ui.preferences.CodeFormatterPreferencePage"
+            class="org.eclipse.cdt.internal.ui.preferences.NameStylePreferencePage"
+            id="org.eclipse.cdt.ui.preferences.NameStylePreferencePage">
+          <keywordReference id="org.eclipse.cdt.ui.namestyle"/>
+          <keywordReference id="org.eclipse.cdt.ui.common"/>
+      </page>
+      <page
+            name="%markOccurrencesPreferencePage.name"
+            category="org.eclipse.cdt.ui.preferences.CEditorPreferencePage"
+            class="org.eclipse.cdt.internal.ui.preferences.MarkOccurrencesPreferencePage"
+            id="org.eclipse.cdt.ui.preferences.MarkOccurrencesPreferencePage">
+          <keywordReference id="org.eclipse.cdt.ui.markoccurrences"/>
+          <keywordReference id="org.eclipse.cdt.ui.common"/>
+      </page>
+      <page
+            name="%SaveActionsPreferencePage.name"
+            category="org.eclipse.cdt.ui.preferences.CEditorPreferencePage"
+            class="org.eclipse.cdt.internal.ui.preferences.SaveActionsPreferencePage"
+            id="org.eclipse.cdt.ui.preferences.SaveActionsPreferencePage">
+          <keywordReference id="org.eclipse.cdt.ui.saveactions"/>
+          <keywordReference id="org.eclipse.cdt.ui.common"/>
+      </page>
+      <page
+            name="%ScalabilityPreferencePage.name"
+            category="org.eclipse.cdt.ui.preferences.CEditorPreferencePage"
+            class="org.eclipse.cdt.internal.ui.preferences.ScalabilityPreferencePage"
+            id="org.eclipse.cdt.ui.preferences.CScalabilityPreferences">
+          <keywordReference id="org.eclipse.cdt.ui.scalability"/>
+          <keywordReference id="org.eclipse.cdt.ui.common"/>
+      </page>
+      <!--page
+            name="%WorkInProgress.name"
+            category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
+            class="org.eclipse.cdt.internal.ui.preferences.WorkInProgressPreferencePage"
+            id="org.eclipse.cdt.ui.preferneces.WorkInProgressPreferencePage">
+      </page-->
+      <page
+            class="org.eclipse.cdt.ui.templateengine.pages.TemplatePreferencePage"
+            name="%TemplatePreferencePage.name"
+            category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
+            id="org.eclipse.cdt.core.templateengine.shareddefaults">
+          <keywordReference id="org.eclipse.cdt.ui.common"/>
+      </page>
+   </extension>
+
+   <extension
+               point="org.eclipse.ui.keywords">
+      <keyword
+            label="%preferenceKeywords.common"
+            id="org.eclipse.cdt.ui.common"/>
+      <keyword
+            label="%preferenceKeywords.codestyle"
+            id="org.eclipse.cdt.ui.codestyle"/>
+      <keyword
+            label="%preferenceKeywords.codetemplates"
+            id="org.eclipse.cdt.ui.codetemplates"/>
+      <keyword
+            label="%preferenceKeywords.namestyle"
+            id="org.eclipse.cdt.ui.namestyle"/>
+      <keyword
+            label="%preferenceKeywords.todo"
+            id="org.eclipse.cdt.ui.todo"/>            
+      <keyword
+            label="%preferenceKeywords.ceditor"
+            id="org.eclipse.cdt.ui.ceditor"/>      
+      <keyword
+            label="%preferenceKeywords.contentassist"
+            id="org.eclipse.cdt.ui.contentassist"/>   
+      <keyword
+            label="%preferenceKeywords.hover"
+            id="org.eclipse.cdt.ui.hover"/>
+      <keyword
+            label="%preferenceKeywords.saveactions"
+            id="org.eclipse.cdt.ui.saveactions"/>
+      <keyword
+            label="%preferenceKeywords.scalability"
+            id="org.eclipse.cdt.ui.scalability"/>
+      <keyword
+            label="%preferenceKeywords.syntaxcoloring"
+            id="org.eclipse.cdt.ui.syntaxcoloring"/>   
+      <keyword
+            label="%preferenceKeywords.templates"
+            id="org.eclipse.cdt.ui.templates"/>
+      <keyword
+            label="%preferenceKeywords.folding"
+            id="org.eclipse.cdt.ui.folding"/>
+      <keyword
+            label="%preferenceKeywords.markoccurrences"
+            id="org.eclipse.cdt.ui.markoccurrences"/>
+      <keyword
+            label="%preferenceKeywords.smarttyping"
+            id="org.eclipse.cdt.ui.smarttyping"/>
+      <keyword
+            label="%preferenceKeywords.indexer"
+            id="org.eclipse.cdt.ui.indexer"/>
+   </extension>  
+
+   <extension
+         point="org.eclipse.ui.menus">
+      <menuContribution
+            locationURI="popup:org.eclipse.ui.popup.any?before=additions">
+         <separator
+               name="buildGroup"
+               visible="true">
+         </separator>
+      </menuContribution>
+   </extension>
+
+   <extension
+         point="org.eclipse.ui.editorActions">
+      <editorContribution
+            targetID="org.eclipse.cdt.ui.editor.CEditor"
+            id="org.eclipse.ui.texteditor.ruler.actions">
+         <action
+               label="%Dummy.label"
+               helpContextId="org.eclipse.ui.bookmark_action_context"
+               class="org.eclipse.ui.texteditor.BookmarkRulerAction"
+               actionID="RulerDoubleClick"
+               id="org.eclipse.ui.texteditor.BookmarkRulerAction">
+         </action>
+         <action
+               label="%Dummy.label"
+               class="org.eclipse.cdt.internal.ui.text.correction.CSelectRulerAction"
+               actionID="RulerClick"
+               id="org.eclipse.cdt.internal.ui.text.correction.CSelectRulerAction">
+         </action>
+      </editorContribution>
+   </extension>
+   <extension point="org.eclipse.ui.popupMenus">
+      <objectContribution
+            id="org.eclipse.cdt.ui.cresources.contrib"
+            objectClass="org.eclipse.cdt.core.model.ICElement">
+         <visibility>
+            <or>
+               <objectClass name="org.eclipse.cdt.core.model.ITranslationUnit"/>
+               <objectClass name="org.eclipse.cdt.core.model.ICContainer"/>
+               <and>
+                  <objectClass name="org.eclipse.cdt.core.model.ICProject"/>
+                  <objectState name="open" value="true">
+                  </objectState>
+               </and>
+            </or>
+         </visibility>
+         <action
+             class="org.eclipse.cdt.internal.ui.actions.FreshenIndexAction"
+             id="org.eclipse.cdt.ui.updateIndexAction"
+             label="%FreshenIndex.name"
+             menubarPath="org.eclipse.cdt.ui.indexmenu/update"/>
+         <action
+             class="org.eclipse.cdt.internal.ui.actions.UpdateIndexWithModifiedFilesAction"
+             id="org.eclipse.cdt.ui.syncIndexWithDiskAction"
+             label="%SyncIndex.name"
+             menubarPath="org.eclipse.cdt.ui.indexmenu/update"/>
+         <menu
+               id="org.eclipse.cdt.ui.indexmenu"
+               label="%Index.menu"
+               path="buildGroup">
+            <groupMarker name="rebuild"/>
+            <separator name="update"/>
+            <separator name="search"/>
+            <separator name="log"/>
+         </menu>
+      </objectContribution>
+      <objectContribution
+            id="org.eclipse.cdt.ui.ctranslationunit.contrib"
+            objectClass="org.eclipse.cdt.core.model.ICElement">
+         <visibility>
+            <objectClass name="org.eclipse.cdt.core.model.ITranslationUnit"/>
+         </visibility>
+         <action
+             class="org.eclipse.cdt.internal.ui.actions.CreateParserLogAction"
+             id="org.eclipse.cdt.ui.parserLogAction"
+             label="%CreateParserLog.name"
+             menubarPath="org.eclipse.cdt.ui.indexmenu/log"/>
+         <menu
+               id="org.eclipse.cdt.ui.indexmenu"
+               label="%Index.menu"
+               path="buildGroup">
+            <groupMarker name="rebuild"/>
+            <separator name="update"/>
+            <separator name="search"/>
+            <separator name="log"/>
+         </menu>
+      </objectContribution>
+      <objectContribution
+          id="org.eclipse.cdt.ui.cproject.contrib"
+          objectClass="org.eclipse.cdt.core.model.ICProject">
+         <action
+             class="org.eclipse.cdt.internal.ui.actions.RebuildIndexAction"
+             id="org.eclipse.cdt.ui.rebuildIndexAction"
+             label="%RebuildIndex.name"
+             menubarPath="org.eclipse.cdt.ui.indexmenu/rebuild"/>
+         <action
+             class="org.eclipse.cdt.internal.ui.search.actions.FindUnresolvedIncludesProjectAction"
+             id="org.eclipse.cdt.ui.searchUnresolvedIncludes"
+             label="%SearchUnresolvedIncludes.name"
+             menubarPath="org.eclipse.cdt.ui.indexmenu/search"/>
+         <menu
+               id="org.eclipse.cdt.ui.indexmenu"
+               label="%Index.menu"
+               path="buildGroup">
+            <groupMarker name="rebuild"/>
+            <separator name="update"/>
+            <separator name="search"/>
+            <separator name="log"/>
+         </menu>
+      </objectContribution>
+      <!-- project explorer shows IProjects, we need to handle this -->
+      <objectContribution 
+          id="org.eclipse.cdt.ui.cproject.in.explorer.contrib"
+          objectClass="org.eclipse.core.resources.IProject">
+         <visibility>
+              <objectState
+                 name="projectNature"
+                 value="org.eclipse.cdt.core.cnature"/>
+         </visibility>          
+         <action
+             class="org.eclipse.cdt.internal.ui.actions.FreshenIndexAction"
+             id="org.eclipse.cdt.ui.updateIndexAction"
+             label="%FreshenIndex.name"
+             menubarPath="org.eclipse.cdt.ui.indexmenu/update"/>
+         <action
+             class="org.eclipse.cdt.internal.ui.actions.UpdateIndexWithModifiedFilesAction"
+             id="org.eclipse.cdt.ui.syncIndexWithDiskAction"
+             label="%SyncIndex.name"
+             menubarPath="org.eclipse.cdt.ui.indexmenu/update"/>
+         <action
+             class="org.eclipse.cdt.internal.ui.actions.RebuildIndexAction"
+             id="org.eclipse.cdt.ui.rebuildIndexAction"
+             label="%RebuildIndex.name"
+             menubarPath="org.eclipse.cdt.ui.indexmenu/rebuild"/>
+         <action
+             class="org.eclipse.cdt.internal.ui.search.actions.FindUnresolvedIncludesProjectAction"
+             id="org.eclipse.cdt.ui.searchUnresolvedIncludes"
+             label="%SearchUnresolvedIncludes.name"
+             menubarPath="org.eclipse.cdt.ui.indexmenu/search"/>
+         <menu
+               id="org.eclipse.cdt.ui.indexmenu"
+               label="%Index.menu"
+               path="buildGroup">
+            <groupMarker name="rebuild"/>
+            <separator name="update"/>
+            <separator name="search"/>
+            <separator name="log"/>
+         </menu>
+      </objectContribution>
+      <objectContribution
+            objectClass="org.eclipse.core.resources.IMarker"
+            id="org.eclipse.cdt.ui.action.DeleteTaskAction">
+         <filter
+               name="type"
+               value="org.eclipse.cdt.core.problem">
+         </filter>
+         <action
+               label="%DeleteTaskAction.label"
+               icon="icons/ovr16/error_co.gif"
+               class="org.eclipse.cdt.internal.ui.util.DeleteTaskAction"
+               menubarPath="additions"
+               enablesFor="+"
+               id="org.eclipse.cdt.ui.action.DeleteTaskAction">
+         </action>
+      </objectContribution>
+      <viewerContribution
+            targetID="#CEditorRulerContext"
+            id="org.eclipse.cdt.ui.editor.CEditorPopupActions">
+         <action
+               label="%AddTask.label"
+               helpContextId="org.eclipse.ui.AddTask_action_context"
+               class="org.eclipse.ui.texteditor.TaskRulerAction"
+               tooltip="%AddTask.tooltip"
+               menubarPath="add"
+               id="org.eclipse.ui.texteditor.TaskRulerAction">
+         </action>
+         <action
+               label="%AddBookmark.label"
+               helpContextId="org.eclipse.ui.bookmark_action_context"
+               class="org.eclipse.ui.texteditor.BookmarkRulerAction"
+               tooltip="%AddBookmark.tooltip"
+               menubarPath="add"
+               id="org.eclipse.ui.texteditor.BookmarkRulerAction">
+         </action>
+         <action
+               class="org.eclipse.cdt.internal.ui.text.correction.CSelectRulerAction"
+               definitionId="org.eclipse.jdt.ui.edit.text.java.correction.assist.proposals"
+               id="org.eclipse.cdt.internal.ui.text.correction.CSelectRulerAction"
+               label="%QuickFix.label"
+               menubarPath="additions"
+               tooltip="%QuickFix.tooltip">
+         </action>            
+      </viewerContribution>
+      <viewerContribution
+            targetID="#ASMEditorRulerContext"
+            id="org.eclipse.cdt.ui.editor.ASMEditorPopupActions">
+         <action
+               label="%AddTask.label"
+               helpContextId="org.eclipse.ui.AddTask_action_context"
+               class="org.eclipse.ui.texteditor.TaskRulerAction"
+               tooltip="%AddTask.tooltip"
+               menubarPath="add"
+               id="org.eclipse.ui.texteditor.TaskRulerAction">
+         </action>
+         <action
+               label="%AddBookmark.label"
+               helpContextId="org.eclipse.ui.bookmark_action_context"
+               class="org.eclipse.ui.texteditor.BookmarkRulerAction"
+               tooltip="%AddBookmark.tooltip"
+               menubarPath="add"
+               id="org.eclipse.ui.texteditor.BookmarkRulerAction">
+         </action>
+      </viewerContribution>
+      <objectContribution
+            adaptable="true"
+            id="org.eclipse.cdt.ui.action.openExternalProblem"
+            objectClass="org.eclipse.core.resources.IMarker">
+         <action
+               class="org.eclipse.cdt.internal.ui.util.OpenExternalProblemAction"
+               id="org.eclipse.cdt.ui.action.openExternalProblemAction"
+               label="%OpenExternalProblemAction.label"
+               menubarPath="additions"/>
+         <filter
+               name="type"
+               value="org.eclipse.cdt.core.problem"/>
+      </objectContribution>
+      
+     <objectContribution
+           adaptable="true"
+           id="org.eclipse.cdt.ui.buildConfigContribution"
+           objectClass="org.eclipse.core.resources.IResource">
+        <visibility>
+           <and>
+              <objectState
+                 name="projectNature"
+                 value="org.eclipse.cdt.core.cnature"/>
+              <objectClass name="org.eclipse.core.resources.IProject"/>
+           </and>
+        </visibility>
+        <action
+              class="org.eclipse.cdt.ui.actions.ManageConfigsAction"
+              enablesFor="+"
+              id="org.eclipse.cdt.ui.manageConfigsAction0"
+              label="%ManageConfigAction.label"
+              menubarPath="org.eclipse.cdt.ui.cfgmenu/manage"
+              />
+        <action
+              class="org.eclipse.cdt.ui.actions.ChangeBuildConfigContextAction"
+              enablesFor="+"
+              id="org.eclipse.cdt.ui.buildConfigPulldownAction"
+              label="%BuildConfigContextAction.label"
+              menubarPath="org.eclipse.cdt.ui.cfgmenu/manage"
+              style="pulldown"
+              tooltip="%BuildConfigAction.tooltip"/>
+        <menu
+              id="org.eclipse.cdt.ui.cfgmenu"
+              label="%Configurations.menu"
+              path="buildGroup">
+           <groupMarker name="manage"/>
+           <separator name="sep1"/>
+           <groupMarker name="build"/>
+        </menu>
+     </objectContribution>
+   </extension>
+   
+   <extension
+         point="org.eclipse.compare.structureCreators">
+      <structureCreator
+            class="org.eclipse.cdt.internal.ui.compare.CStructureCreator"
+            id="org.eclipse.cdt.ui.compare.CStructureCreator">
+      </structureCreator>
+      <contentTypeBinding
+                       contentTypeId="org.eclipse.cdt.core.cSource"
+            structureCreatorId="org.eclipse.cdt.ui.compare.CStructureCreator">
+         </contentTypeBinding>
+      <contentTypeBinding
+                       contentTypeId="org.eclipse.cdt.core.cHeader"
+            structureCreatorId="org.eclipse.cdt.ui.compare.CStructureCreator">
+         </contentTypeBinding>
+      <contentTypeBinding
+                       contentTypeId="org.eclipse.cdt.core.cxxSource"
+            structureCreatorId="org.eclipse.cdt.ui.compare.CStructureCreator">
+         </contentTypeBinding>
+      <contentTypeBinding
+                       contentTypeId="org.eclipse.cdt.core.cxxHeader"
+            structureCreatorId="org.eclipse.cdt.ui.compare.CStructureCreator">
+         </contentTypeBinding>
+   </extension>
+   <extension
+         point="org.eclipse.compare.contentMergeViewers">
+      <viewer
+            class="org.eclipse.cdt.internal.ui.compare.CContentViewerCreator"
+            extensions="c,cc,cxx,cpp,c++,h,hh,hxx,hpp,c2"
+            id="org.eclipse.cdt.ui.compare.CContentViewerCreator">
+      </viewer>
+      <contentTypeBinding
+                       contentTypeId="org.eclipse.cdt.core.cSource"
+            contentMergeViewerId="org.eclipse.cdt.ui.compare.CContentViewerCreator">
+         </contentTypeBinding>
+      <contentTypeBinding
+                       contentTypeId="org.eclipse.cdt.core.cHeader"
+            contentMergeViewerId="org.eclipse.cdt.ui.compare.CContentViewerCreator">
+         </contentTypeBinding>
+      <contentTypeBinding
+                       contentTypeId="org.eclipse.cdt.core.cxxSource"
+            contentMergeViewerId="org.eclipse.cdt.ui.compare.CContentViewerCreator">
+         </contentTypeBinding>
+      <contentTypeBinding
+                       contentTypeId="org.eclipse.cdt.core.cxxHeader"
+            contentMergeViewerId="org.eclipse.cdt.ui.compare.CContentViewerCreator">
+         </contentTypeBinding>
+      <viewer
+            class="org.eclipse.cdt.internal.ui.compare.AsmContentViewerCreator"
+            extensions="s,asm"
+            id="org.eclipse.cdt.ui.compare.AsmContentViewerCreator"/>
+      <contentTypeBinding
+                       contentTypeId="org.eclipse.cdt.core.asmSource"
+            contentMergeViewerId="org.eclipse.cdt.ui.compare.AsmContentViewerCreator"/>
+   </extension>
+   <extension
+         point="org.eclipse.ui.menus">
+      <menuContribution
+            locationURI="menu:project?after=build">
+         <menu
+               id="org.eclipse.cdt.ui.prjmenu"
+               label="%Configurations.menu">
+            <separator name="manage" visible="false"/>
+            <separator name="sep1" visible="true"/>
+            <separator name="wrksets" visible="false"/>
+         </menu>
+      </menuContribution>
+      <menuContribution
+            locationURI="menu:org.eclipse.cdt.ui.prjmenu?before=wrksets">
+         <menu
+               id="org.eclipse.cdt.ui.workingSets.buildMenu"
+               label="%buildWorkingSetConfig.label">
+            <visibleWhen>
+               <with
+                     variable="activeContexts">
+                  <iterate
+                        ifEmpty="false"
+                        operator="or">
+                     <equals
+                           value="org.eclipse.cdt.ui.buildConfigActionSet">
+                     </equals>
+                  </iterate>
+               </with>
+            </visibleWhen>
+            <dynamic
+                  class="org.eclipse.cdt.internal.ui.workingsets.BuildWorkingSetsContribution"
+                  id="org.eclipse.cdt.ui.buildWorkingSetConfigs">
+            </dynamic>
+         </menu>
+         <menu
+               id="org.eclipse.cdt.ui.workingSets.activateMenu"
+               label="%activateWorkingSetConfig.label">
+            <visibleWhen>
+               <with
+                     variable="activeContexts">
+                  <iterate
+                        ifEmpty="false"
+                        operator="or">
+                     <equals
+                           value="org.eclipse.cdt.ui.buildConfigActionSet">
+                     </equals>
+                  </iterate>
+               </with>
+            </visibleWhen>
+            <dynamic
+                  class="org.eclipse.cdt.internal.ui.workingsets.ActivateWorkingSetsContribution"
+                  id="org.eclipse.cdt.ui.activateWorkingSetConfigs">
+            </dynamic>
+         </menu>
+      </menuContribution>
+   </extension>
+   <extension
+         point="org.eclipse.ui.actionSets">
+      <actionSet
+            label="%CodingActionSet.label"
+            description="%CodingActionSet.description"
+            visible="false"
+            id="org.eclipse.cdt.ui.CodingActionSet">
+         <menu
+               label="%Refactoring.menu.label"
+               path="edit"
+               id="org.eclipse.jdt.ui.refactoring.menu">
+            <separator name="reorgGroup"/>
+            <separator name="codingGroup"/>
+            <separator name="reorgGroup2"/>
+            <separator name="typeGroup"/>
+            <separator name="typeGroup2"/>
+            <separator name="codingGroup2"/>
+            <separator name="typeGroup3"/>
+            <separator
+                  name="historyGroup">
+            </separator>            
+         </menu>
+         <!-- reorg group  -->
+         <action
+               definitionId="org.eclipse.cdt.ui.edit.text.rename.element"
+               label="%Refactoring.renameAction.label"
+               menubarPath="org.eclipse.jdt.ui.refactoring.menu/reorgGroup"
+               id="org.eclipse.cdt.ui.actions.Rename"
+               retarget="true">
+         </action>
+         <action
+               definitionId="org.eclipse.cdt.ui.refactor.hide.method"
+               label="%Refactoring.hideMethod.label"
+               menubarPath="org.eclipse.jdt.ui.refactoring.menu/codingGroup"
+               id="org.eclipse.cdt.ui.actions.HideMethod"
+               retarget="true">
+         </action>
+         <action
+               definitionId="org.eclipse.cdt.ui.refactor.extract.function"
+               label="%Refactoring.extractFunction.label"
+               menubarPath="org.eclipse.jdt.ui.refactoring.menu/codingGroup"
+               id="org.eclipse.cdt.ui.actions.ExtractMethod"
+               retarget="true">
+         </action>
+         <action
+               definitionId="org.eclipse.cdt.ui.refactor.toggle.function"
+               label="%Refactoring.toggleFunction.label"
+               menubarPath="org.eclipse.jdt.ui.refactoring.menu/codingGroup"
+               id="org.eclipse.cdt.ui.actions.ToggleFunction"
+               retarget="true">
+         </action>
+         <action
+               definitionId="org.eclipse.cdt.ui.refactor.extract.constant"
+               label="%Refactoring.extractConstant.label"
+               menubarPath="org.eclipse.jdt.ui.refactoring.menu/codingGroup"
+               id="org.eclipse.cdt.ui.actions.ExtractConstant"
+               retarget="true">
+         </action>
+         <action
+               definitionId="org.eclipse.cdt.ui.refactor.extract.local.variable"
+               label="%Refactoring.extractLocalVariable.label"
+               menubarPath="org.eclipse.jdt.ui.refactoring.menu/codingGroup"
+               id="org.eclipse.cdt.ui.actions.ExtractLocalVariable"
+               retarget="true">
+         </action>
+         <action
+               class="org.eclipse.ltk.ui.refactoring.actions.ShowRefactoringHistoryAction"
+               definitionId="org.eclipse.ltk.ui.refactor.show.refactoring.history"
+               id="org.eclipse.cdt.ui.actions.RefactoringHistory"
+               label="%historyAction.label"
+               menubarPath="org.eclipse.jdt.ui.refactoring.menu/historyGroup"
+               retarget="false">
+         </action>
+         <action
+               class="org.eclipse.ltk.ui.refactoring.actions.CreateRefactoringScriptAction"
+               definitionId="org.eclipse.ltk.ui.refactor.create.refactoring.script"
+               id="org.eclipse.cdt.ui.actions.createRefactoringScript"
+               label="%createScriptAction.label"
+               menubarPath="org.eclipse.jdt.ui.refactoring.menu/historyGroup"
+               retarget="false">
+         </action>
+         <action
+               class="org.eclipse.ltk.ui.refactoring.actions.ApplyRefactoringScriptAction"
+               definitionId="org.eclipse.ltk.ui.refactor.apply.refactoring.script"
+               id="org.eclipse.cdt.ui.actions.applyRefactoringScript"
+               label="%applyScriptAction.label"
+               menubarPath="org.eclipse.jdt.ui.refactoring.menu/historyGroup"
+               retarget="false">
+         </action>
+<!-- =========================================================================== -->
+<!-- Source Menu                                                                 -->
+<!-- =========================================================================== -->
+         <!-- Note: This menu layout must match the definition in org.eclipse.jdt.ui -->
+         <menu
+               id="org.eclipse.jdt.ui.source.menu"
+               label="%Source.menu.label"
+               path="edit">
+                   <separator
+                  name="commentGroup">
+            </separator>
+            <separator
+                  name="editGroup">
+            </separator>
+            <separator
+                  name="importGroup">
+            </separator>
+            <separator
+                  name="generateGroup">
+            </separator>
+            <separator
+                  name="codeGroup">
+            </separator>
+            <separator
+                  name="externalizeGroup">
+            </separator>
+            <separator
+                  name="convertGroup">
+            </separator>
+         </menu>
+<!-- Code Group -->
+         <action
+               class="org.eclipse.cdt.internal.ui.actions.SurroundWithTemplateMenuAction"
+               definitionId="org.eclipse.cdt.ui.edit.text.c.surround.with.quickMenu"
+               label="%SurroundWithTemplateAction.label"
+               menubarPath="org.eclipse.jdt.ui.source.menu/codeGroup"
+               id="org.eclipse.cdt.internal.ui.actions.SurroundWithTemplateMenuAction"
+               style="pulldown">
+         </action>
+<!-- Generate Group -->
+        <action
+               definitionId="org.eclipse.cdt.ui.refactor.getters.and.setters"
+               label="%Refactoring.gettersAndSetters.label"
+               menubarPath="org.eclipse.jdt.ui.source.menu/generateGroup"
+               id="org.eclipse.cdt.ui.actions.GettersAndSetters"
+               retarget="true">
+         </action> 
+         <action
+               definitionId="org.eclipse.cdt.ui.refactor.implement.method"
+               label="%Refactoring.implementMethod.label"
+               menubarPath="org.eclipse.jdt.ui.source.menu/generateGroup"
+               id="org.eclipse.cdt.ui.actions.ImplementMethod"
+               retarget="true">
+         </action>
+<!-- Import Group -->
+         <action
+               definitionId="org.eclipse.cdt.ui.edit.text.c.sort.lines"
+               label="%SortLinesAction.label"
+               retarget="true"
+               menubarPath="org.eclipse.jdt.ui.source.menu/importGroup"
+               id="org.eclipse.cdt.ui.actions.SortLines">
+         </action>
+         <action
+               definitionId="org.eclipse.cdt.ui.edit.text.c.add.include"
+               label="%AddIncludeAction.label"
+               retarget="true"
+               menubarPath="org.eclipse.jdt.ui.source.menu/importGroup"
+               id="org.eclipse.cdt.ui.actions.AddInclude">
+         </action>
+<!-- Edit group -->
+         <action
+               definitionId="org.eclipse.cdt.ui.edit.text.c.format"
+               label="%FormatAction.label"
+               retarget="true"
+               menubarPath="org.eclipse.jdt.ui.source.menu/editGroup"
+               id="org.eclipse.cdt.ui.actions.Format">
+         </action>
+         <action
+               definitionId="org.eclipse.cdt.ui.edit.text.c.indent"
+               label="%IndentAction.label"
+               retarget="true"
+               menubarPath="org.eclipse.jdt.ui.source.menu/editGroup"
+               id="org.eclipse.cdt.ui.actions.Indent">
+         </action>
+         <action
+               definitionId="org.eclipse.ui.edit.text.shiftLeft"
+               disabledIcon="icons/dlcl16/shift_l_edit.gif"
+               icon="icons/elcl16/shift_l_edit.gif"
+               id="org.eclipse.cdt.ui.actions.ShiftLeft"
+               label="%ShiftLeftAction.label"
+               menubarPath="org.eclipse.jdt.ui.source.menu/editGroup"
+               retarget="true">
+         </action>
+         <action
+               definitionId="org.eclipse.ui.edit.text.shiftRight"
+               disabledIcon="icons/dlcl16/shift_r_edit.gif"
+               icon="icons/elcl16/shift_r_edit.gif"
+               id="org.eclipse.cdt.ui.actions.ShiftRight"
+               label="%ShiftRightAction.label"
+               menubarPath="org.eclipse.jdt.ui.source.menu/editGroup"
+               retarget="true">
+         </action>
+<!-- Comment Group -->
+         <action
+               definitionId="org.eclipse.cdt.ui.edit.text.c.uncomment"
+               label="%UncommentAction.label"
+               retarget="true"
+               id="org.eclipse.cdt.ui.actions.Uncomment">
+         </action>
+         <action
+               definitionId="org.eclipse.cdt.ui.edit.text.c.comment"
+               label="%CommentAction.label"
+               retarget="true"
+               id="org.eclipse.cdt.ui.actions.Comment">
+         </action>
+         <action
+               definitionId="org.eclipse.cdt.ui.edit.text.c.remove.block.comment"
+               label="%RemoveBlockCommentAction.label"
+               retarget="true"
+               menubarPath="org.eclipse.jdt.ui.source.menu/commentGroup"
+               id="org.eclipse.cdt.ui.actions.RemoveBlockComment">
+         </action>
+         <action
+               definitionId="org.eclipse.cdt.ui.edit.text.c.add.block.comment"
+               label="%AddBlockCommentAction.label"
+               retarget="true"
+               menubarPath="org.eclipse.jdt.ui.source.menu/commentGroup"
+               id="org.eclipse.cdt.ui.actions.AddBlockComment">
+         </action>
+         <action
+               definitionId="org.eclipse.cdt.ui.edit.text.c.toggle.comment"
+               label="%ToggleCommentAction.label"
+               retarget="true"
+               menubarPath="org.eclipse.jdt.ui.source.menu/commentGroup"
+               id="org.eclipse.cdt.ui.actions.ToggleComment">
+         </action>
+      </actionSet>
+      <actionSet
+            label="%CSearchActionSet.label"
+            description="%CSearchActionSet.description"
+            visible="false"
+            id="org.eclipse.cdt.ui.SearchActionSet">
+         <action
+               label="%openCSearchPageAction.label"
+               icon="icons/obj16/csearch_obj.gif"
+               class="org.eclipse.cdt.internal.ui.search.OpenCSearchPageAction"
+               menubarPath="org.eclipse.search.menu/dialogGroup"
+               id="org.eclipse.cdt.ui.actions.OpenCSearchPage">
+         </action>
+         <menu
+               label="%searchMenu.label"
+               id="org.eclipse.search.menu">
+         </menu>
+      </actionSet>
+      <actionSet
+            label="%CNavigationActionSet.label"
+            description="%CNavigationActionSet.description"
+            visible="false"
+            id="org.eclipse.cdt.ui.NavigationActionSet">
+         <action
+               id="org.eclipse.cdt.ui.actions.openElementInCallHierarchy"
+               class="org.eclipse.cdt.internal.ui.callhierarchy.OpenElementInCallHierarchyAction"
+               definitionId="org.eclipse.cdt.ui.navigate.open.element.in.call.hierarchy"
+               label="%OpenElementInCallHierarchyAction.label"
+               menubarPath="navigate/open.ext2"
+               tooltip="%OpenElementInCallHierarchyAction.tooltip">
+         </action>
+         <action
+               id="org.eclipse.cdt.ui.actions.openTypeInHierarchy"
+               class="org.eclipse.cdt.internal.ui.typehierarchy.OpenTypeInHierarchyAction"
+               definitionId="org.eclipse.cdt.ui.navigate.open.type.in.hierarchy"
+               label="%OpenTypeInHierarchyAction.label"
+               helpContextId="org.eclipse.cdt.ui.open_type_in_hierarchy_action"
+               menubarPath="navigate/open.ext2"
+               tooltip="%OpenTypeInHierarchyAction.tooltip">
+         </action>
+         <action
+               id="org.eclipse.cdt.ui.actions.OpenType"
+               toolbarPath="org.eclipse.search.searchActionSet/Search"
+               class="org.eclipse.cdt.internal.ui.browser.opentype.OpenTypeAction"
+               definitionId="org.eclipse.cdt.ui.navigate.opentype"
+               icon="icons/etool16/opentype.gif"
+               helpContextId="org.eclipse.cdt.ui.open_type_action"
+               label="%OpenTypeAction.label"
+               menubarPath="navigate/open.ext2"
+               tooltip="%OpenTypeAction.tooltip">
+         </action>
+      </actionSet>
+      <actionSet
+            label="%COpenActionSet.label"
+            description="%COpenActionSet.description"
+            visible="false"
+            id="org.eclipse.cdt.ui.OpenActionSet">
+         <action
+               definitionId="org.eclipse.cdt.ui.edit.open.include.browser"
+               id="org.eclipse.cdt.ui.actions.OpenIncludeBrowser"
+               label="%OpenIncludeBrowser.label"
+               menubarPath="navigate/open.ext"
+               retarget="true"
+               tooltip="%OpenIncludeBrowser.tooltip">
+         </action>
+         <action
+               definitionId="org.eclipse.cdt.ui.edit.open.call.hierarchy"
+               id="org.eclipse.cdt.ui.actions.OpenCallHierarchy"
+               label="%OpenCallHierarchy.label"
+               menubarPath="navigate/open.ext"
+               retarget="true"
+               tooltip="%OpenCallHierarchy.tooltip">
+         </action>
+         <action
+               definitionId="org.eclipse.cdt.ui.edit.open.type.hierarchy"
+               label="%OpenTypeHierarchyAction.label"
+               tooltip="%OpenTypeHierarchyAction.tooltip"
+               retarget="true"
+               menubarPath="navigate/open.ext"
+               id="org.eclipse.cdt.ui.actions.OpenTypeHierarchy">
+         </action>
+         <action
+               definitionId="org.eclipse.cdt.ui.edit.opendecl"
+               label="%OpenDeclarationAction.label"
+               tooltip="%OpenDeclarationAction.tooltip"
+               retarget="true"
+               menubarPath="navigate/open.ext"
+               id="org.eclipse.cdt.ui.actions.OpenDeclaration">
+         </action>
+      </actionSet>
+      <actionSet
+           description="%BuildConfigurationActionSet.descr"
+           id="org.eclipse.cdt.ui.buildConfigActionSet"
+           label="%BuildConfigActionSet.label"
+           visible="false">
+        <action
+              class="org.eclipse.cdt.ui.actions.ChangeBuildConfigMenuAction"
+              disabledIcon="icons/dlcl16/config-tool.gif"
+              enablesFor="+"
+              icon="icons/elcl16/config-tool.gif"
+              id="org.eclipse.cdt.ui.buildConfigToolbarAction"
+              label="%BuildConfigToolbarAction.label"
+              style="pulldown"
+              toolbarPath="buildConfig"
+              tooltip="%BuildConfigAction.tooltip2"/>
+        <action
+              class="org.eclipse.cdt.ui.actions.BuildActiveConfigMenuAction"
+              disabledIcon="icons/dlcl16/build_exec.png"
+              enablesFor="+"
+              icon="icons/elcl16/build_exec.png"
+              id="org.eclipse.cdt.ui.buildActiveConfigToolbarAction"
+              label="%BuildActiveConfiguration.label"
+              style="pulldown"
+              toolbarPath="buildConfig"
+              tooltip="%BuildActiveConfiguration.tooltip"/>
+        <action
+              class="org.eclipse.cdt.ui.actions.ManageConfigsAction"
+              enablesFor="+"
+              id="org.eclipse.cdt.ui.manageConfigsAction2"
+              label="%ManageConfigAction.label"
+              menubarPath="project/org.eclipse.cdt.ui.prjmenu/manage"
+              />
+        <action
+              class="org.eclipse.cdt.ui.actions.ChangeBuildConfigMenuAction"
+              enablesFor="+"
+              id="org.eclipse.cdt.ui.buildConfigMenuAction"
+              label="%BuildConfigMenuAction.label"
+              menubarPath="project/org.eclipse.cdt.ui.prjmenu/manage"
+              style="pulldown"
+              tooltip="%BuildConfigAction.tooltip"/>
+        <action
+              class="org.eclipse.cdt.ui.actions.WorkingSetConfigAction"
+              id="org.eclipse.cdt.ui.wsselection"
+              label="%wsselection"
+              menubarPath="project/org.eclipse.cdt.ui.prjmenu/wrksets"
+              style="push"
+              />
+     </actionSet>
+     <actionSet
+            label="%CElementCreationActionSet.label"
+            description="%CElementCreationActionSet.description"
+            visible="false"
+            id="org.eclipse.cdt.ui.CElementCreationActionSet">
+         <action
+               class="org.eclipse.cdt.internal.ui.wizards.NewTypeDropDownAction"
+               disabledIcon="icons/dtool16/newclass_wiz.gif"
+               icon="icons/etool16/newclass_wiz.gif"
+               id="org.eclipse.cdt.ui.actions.NewTypeDropDown"
+               label="%NewTypeDropDownAction.label"
+               style="pulldown"
+               toolbarPath="Normal/CCWizards"
+               tooltip="%NewTypeDropDownAction.tooltip">
+         </action>
+         <action
+               id="org.eclipse.cdt.ui.actions.NewFileDropDown"
+               toolbarPath="Normal/CCWizards"
+               class="org.eclipse.cdt.internal.ui.wizards.NewFileDropDownAction"
+               disabledIcon="icons/dtool16/newcfile_wiz.gif"
+               icon="icons/etool16/newcfile_wiz.gif"
+               label="%NewFileDropDownAction.label"
+               style="pulldown"
+               tooltip="%NewFileDropDownAction.tooltip">
+         </action>
+         <action
+               id="org.eclipse.cdt.ui.actions.NewFolderDropDown"
+               toolbarPath="Normal/CCWizards"
+               class="org.eclipse.cdt.internal.ui.wizards.NewFolderDropDownAction"
+               disabledIcon="icons/dtool16/newsrcfldr_wiz.gif"
+               icon="icons/etool16/newsrcfldr_wiz.gif"
+               label="%NewFolderDropDownAction.label"
+               style="pulldown"
+               tooltip="%NewFolderDropDownAction.tooltip">
+         </action>
+         <action
+               id="org.eclipse.cdt.ui.actions.NewProjectDropDown"
+               toolbarPath="Normal/CCWizards"
+               class="org.eclipse.cdt.internal.ui.wizards.NewProjectDropDownAction"
+               disabledIcon="icons/dtool16/newcprj_wiz.gif"
+               icon="icons/etool16/newcprj_wiz.gif"
+               label="%NewProjectDropDownAction.label"
+               style="pulldown"
+               tooltip="%NewProjectDropDownAction.tooltip">
+         </action>
+      </actionSet>
+      <actionSet
+            label="%CEditorPresentationActionSet.label"
+            visible="false"
+            id="org.eclipse.cdt.ui.text.c.actionSet.presentation">
+         <action
+               allowLabelUpdate="true"
+               style="toggle"
+               toolbarPath="org.eclipse.ui.edit.text.actionSet.presentation/Presentation"
+               id="org.eclipse.cdt.ui.edit.text.c.toggleMarkOccurrences"
+               definitionId="org.eclipse.cdt.ui.edit.text.c.toggleMarkOccurrences"
+               disabledIcon="$nl$/icons/dtool16/mark_occurrences.gif"
+               icon="$nl$/icons/etool16/mark_occurrences.gif"
+               helpContextId="toggle_mark_occurrences_action"
+               label="%toggleMarkOccurrences.label"
+               retarget="true"
+               tooltip="%toggleMarkOccurrences.tooltip">
+         </action>
+      </actionSet>
+   </extension>
+   <extension
+         point="org.eclipse.ui.ide.projectNatureImages">
+      <image
+            icon="icons/ovr16/c_ovr.gif"
+            natureId="org.eclipse.cdt.core.cnature"
+            id="org.eclipse.cdt.ui.cProjectNatureImage">
+      </image>
+   </extension>
+   <extension
+         point="org.eclipse.cdt.core.CBuildConsole">
+      <CBuildConsole
+            class="org.eclipse.cdt.internal.ui.buildconsole.CBuildConsole">
+      </CBuildConsole>
+   </extension>
+   <extension
+         point="org.eclipse.ui.console.consolePageParticipants">
+      <consolePageParticipant
+            class="org.eclipse.cdt.internal.ui.buildconsole.BuildConsolePageParticipant"
+            id="org.eclipse.cdt.internal.ui.buildconsole.BuildConsolePageParticipant">
+         <enablement>
+            <instanceof value="org.eclipse.cdt.internal.ui.buildconsole.BuildConsole"/>
+         </enablement>
+      </consolePageParticipant>
+   </extension>
+   <extension
+                point="org.eclipse.ui.contexts">
+          <context
+            name="%scope.cEditor.name"
+            parentId="org.eclipse.ui.textEditorScope"
+            description="%cEditor.description"
+            id="org.eclipse.cdt.ui.cEditorScope">
+       </context>
+      <context 
+            name="%cViewScope.name" 
+            description="%cViewScope.description" 
+            id="org.eclipse.cdt.ui.cViewScope" 
+            parentId="org.eclipse.ui.contexts.window"
+      />
+      <context
+            name="%macroExpansionHoverScope.name" 
+            description="%macroExpansionHoverScope.description" 
+            id="org.eclipse.cdt.ui.macroExpansionHoverScope" 
+            parentId="org.eclipse.ui.contexts.dialogAndWindow"
+      />
+   </extension>
+
+   <extension point="org.eclipse.ui.bindings">
+      <!--  win32:  M1=CTRL,    M2=SHIFT, M3=ALT, M4=-
+            carbon: M1=COMMAND, M2=SHIFT, M3=ALT, M4=CTRL -->
+            
+<!-- edit -->            
+      <key
+            sequence="M2+M3+ARROW_UP"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.text.c.select.enclosing"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+      <key
+            sequence="M2+M3+ARROW_RIGHT"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.text.c.select.next"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+      <key
+            sequence="M2+M3+ARROW_LEFT"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.text.c.select.previous"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+      <key
+            sequence="M2+M3+ARROW_DOWN"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.text.c.select.last"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+      <key
+            platform="carbon"      
+            sequence="M2+M3+ARROW_UP"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId=""
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+      <key
+            platform="carbon"      
+            sequence="M2+M3+ARROW_RIGHT"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId=""
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+      <key
+            platform="carbon"      
+            sequence="M2+M3+ARROW_LEFT"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId=""
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+      <key
+            platform="carbon"      
+            sequence="M2+M3+ARROW_DOWN"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId=""
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+      <key
+            platform="carbon"      
+            sequence="CTRL+SHIFT+ARROW_UP"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.text.c.select.enclosing"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+      <key
+            platform="carbon"      
+            sequence="CTRL+SHIFT+ARROW_RIGHT"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.text.c.select.next"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+      <key
+            platform="carbon"      
+            sequence="CTRL+SHIFT+ARROW_LEFT"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.text.c.select.previous"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+      <key
+            platform="carbon"      
+            sequence="CTRL+SHIFT+ARROW_DOWN"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.text.c.select.last"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>            
+
+
+            
+      <key
+            sequence="M2+M3+S"
+            commandId="org.eclipse.cdt.ui.edit.text.c.source.quickMenu"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            contextId="org.eclipse.cdt.ui.cEditorScope"/>
+      <key
+            platform="carbon"
+            sequence="M2+M3+S"
+            commandId=""
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            contextId="org.eclipse.cdt.ui.cEditorScope"/>
+      <key
+            platform="carbon"
+            sequence="COMMAND+ALT+S"
+            commandId="org.eclipse.cdt.ui.edit.text.c.source.quickMenu"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            contextId="org.eclipse.cdt.ui.cEditorScope"/>
+        <key
+            sequence="M1+M2+F"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.text.c.format"/>      
+        <key
+            sequence="M2+TAB"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.ui.edit.text.shiftLeft"/>      
+     <key
+            sequence="M1+/"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.text.c.toggle.comment"/>
+     <key
+            sequence="M1+M2+/"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.text.c.add.block.comment"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            sequence="M1+M2+\"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.text.c.remove.block.comment"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>   
+      <key
+            sequence="M1+I"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.text.c.indent"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+       <key
+            sequence="M2+M3+Z"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.text.c.surround.with.quickMenu"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>        
+       <key
+            platform="carbon"
+            sequence="M2+M3+Z"
+            commandId=""
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+       <key
+            platform="carbon"
+            sequence="COMMAND+ALT+Z"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.text.c.surround.with.quickMenu"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>            
+     <key
+            sequence="M1+M3+H"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.open.call.hierarchy"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            platform="carbon"
+            sequence="M1+M3+H"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId=""
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            platform="carbon"
+            sequence="M3+M4+H"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.open.call.hierarchy"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            sequence="M1+M3+H"
+            contextId="org.eclipse.cdt.ui.cViewScope"
+            commandId="org.eclipse.cdt.ui.edit.open.call.hierarchy"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            platform="carbon"
+            sequence="M1+M3+H"
+            contextId="org.eclipse.cdt.ui.cViewScope"
+            commandId=""
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            platform="carbon"
+            sequence="M3+M4+H"
+            contextId="org.eclipse.cdt.ui.cViewScope"
+            commandId="org.eclipse.cdt.ui.edit.open.call.hierarchy"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            sequence="M1+M3+I"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.open.include.browser"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            sequence="M1+M3+I"
+            contextId="org.eclipse.cdt.ui.cViewScope"
+            commandId="org.eclipse.cdt.ui.edit.open.include.browser"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            sequence="F3"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.opendecl"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            sequence="F3"
+            contextId="org.eclipse.cdt.ui.cViewScope"
+            commandId="org.eclipse.cdt.ui.edit.opendecl"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            sequence="M1+M2+T"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.navigate.opentype"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            sequence="M1+M2+T"
+            contextId="org.eclipse.cdt.ui.cViewScope"
+            commandId="org.eclipse.cdt.ui.navigate.opentype"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            commandId="org.eclipse.cdt.ui.search.findrefs"
+            sequence="M1+M2+G"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            commandId="org.eclipse.cdt.ui.search.findrefs"
+            sequence="M1+M2+G"
+            contextId="org.eclipse.cdt.ui.cViewScope"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            commandId="org.eclipse.cdt.ui.search.finddecl"
+            sequence="M1+G"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            commandId="org.eclipse.cdt.ui.search.finddecl"
+            sequence="M1+G"
+            contextId="org.eclipse.cdt.ui.cViewScope"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            sequence="F4"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.open.type.hierarchy"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            sequence="F4"
+            contextId="org.eclipse.cdt.ui.cViewScope"
+            commandId="org.eclipse.cdt.ui.edit.open.type.hierarchy"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            sequence="M1+M2+H"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.navigate.open.type.in.hierarchy"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            sequence="M1+M2+H"
+            contextId="org.eclipse.cdt.ui.cViewScope"
+            commandId="org.eclipse.cdt.ui.navigate.open.type.in.hierarchy"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            sequence="M1+M2+N"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.text.c.add.include"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            sequence="M1+M3+S"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.text.c.sort.lines"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+               platform="carbon"
+            sequence="M1+M3+S"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId=""
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+               platform="carbon"
+            sequence="CTRL+COMMAND+S"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.text.c.sort.lines"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            sequence="M1+O"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.open.outline"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            sequence="M1+T"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.open.quick.type.hierarchy"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            sequence="M1+M2+ARROW_DOWN"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.text.c.goto.next.member"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            sequence="M1+M2+ARROW_UP"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.text.c.goto.prev.member"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            sequence="M1+M2+P"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.text.c.goto.matching.bracket"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            sequence="M1+TAB"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.text.c.toggle.source.header"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            platform="carbon"
+            sequence="M1+TAB"
+            contextId=""
+            commandId=""
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            platform="carbon"
+            sequence="CTRL+TAB"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.text.c.toggle.source.header"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            sequence="M3+ARROW_LEFT"
+            contextId="org.eclipse.cdt.ui.macroExpansionHoverScope"
+            commandId="org.eclipse.cdt.ui.hover.backwardMacroExpansion"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            sequence="M3+ARROW_RIGHT"
+            contextId="org.eclipse.cdt.ui.macroExpansionHoverScope"
+            commandId="org.eclipse.cdt.ui.hover.forwardMacroExpansion"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            sequence="F3"
+            contextId="org.eclipse.cdt.ui.macroExpansionHoverScope"
+            commandId="org.eclipse.cdt.ui.edit.opendecl"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+        <key
+               sequence="M2+M3+O"
+               contextId="org.eclipse.cdt.ui.cEditorScope"
+               commandId="org.eclipse.cdt.ui.edit.text.c.toggleMarkOccurrences"
+               schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+        <key
+               platform="carbon"
+               sequence="M2+M3+O"
+               contextId="org.eclipse.cdt.ui.cEditorScope"
+               commandId=""
+               schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+        <key
+               platform="carbon"
+               sequence="M1+M3+O"
+               contextId="org.eclipse.cdt.ui.cEditorScope"
+               commandId="org.eclipse.cdt.ui.edit.text.c.toggleMarkOccurrences"
+               schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            sequence="M1+="
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.open.quick.macro.explorer"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            sequence="M1+#"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.open.quick.macro.explorer"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+     <key
+            sequence="M2+M3+R"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.text.rename.element"/>
+     <key
+            platform="carbon"
+            sequence="M2+M3+R"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId=""/>
+     <key
+            platform="carbon"
+            sequence="M1+M3+R"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.edit.text.rename.element"/>
+     <key
+            sequence="M2+M3+R"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            contextId="org.eclipse.cdt.ui.cViewScope"
+            commandId="org.eclipse.cdt.ui.edit.text.rename.element"/>
+     <key
+            platform="carbon"
+            sequence="M2+M3+R"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            contextId="org.eclipse.cdt.ui.cViewScope"
+            commandId=""/>
+     <key
+            platform="carbon"
+            sequence="M1+M3+R"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            contextId="org.eclipse.cdt.ui.cViewScope"
+            commandId="org.eclipse.cdt.ui.edit.text.rename.element"/>
+     <key
+            sequence="M2+M3+M"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.refactor.extract.function"/>
+     <key
+            platform="carbon"
+            sequence="M2+M3+M"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId=""/>
+     <key
+            platform="carbon"
+            sequence="M1+M3+M"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.refactor.extract.function"/>
+     <key
+            sequence="M2+M3+T"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.refactor.toggle.function"/>
+     <key
+            platform="carbon"
+            sequence="M2+M3+T"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId=""/>
+     <key
+            platform="carbon"
+            sequence="M1+M3+T"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.refactor.toggle.function"/>
+     <key
+            sequence="M3+C"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.refactor.extract.constant"/>
+     <key
+            sequence="M2+M3+L"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.refactor.extract.local.variable"/>
+     <key
+            platform="carbon"
+            sequence="M2+M3+L"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId=""/>
+     <key
+            platform="carbon"
+            sequence="M1+M3+L"
+            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            commandId="org.eclipse.cdt.ui.refactor.extract.local.variable"/>
+      <scheme
+            id="org.eclipse.cdt.ui.visualstudio"
+                       parentId="org.eclipse.ui.defaultAcceleratorConfiguration"
+            name="%keybinding.MSVS"/>
+
+<!-- =================================================================================== -->
+<!-- MICROSOFT VISUAL STUDIO KEY SHORTCUTS                                               -->
+<!-- =================================================================================== -->
+               <!-- C/C++ Source Keys -->
+          
+           <!-- MSVS Edit.GoToDefinition -->
+               <key
+                       sequence="F12"
+                       commandId="org.eclipse.cdt.ui.edit.opendecl"
+                       contextId="org.eclipse.cdt.ui.cEditorScope"
+                       schemeId="org.eclipse.cdt.ui.visualstudio"/>
+          
+               <!-- Edit Keys -->
+
+               <key
+                       sequence="F3"
+                       commandId="org.eclipse.ui.edit.findNext"
+                       contextId="org.eclipse.ui.textEditorScope"
+                       schemeId="org.eclipse.cdt.ui.visualstudio"/>
+          
+               <key
+                       sequence="M2+F3"
+                       commandId="org.eclipse.ui.edit.findPrevious"
+                       contextId="org.eclipse.ui.textEditorScope"
+                       schemeId="org.eclipse.cdt.ui.visualstudio"/>
+
+               <key
+                       sequence="M1+F3"
+                       commandId="org.eclipse.cdt.ui.edit.text.c.find.word"
+                       contextId="org.eclipse.cdt.ui.cEditorScope"
+                       schemeId="org.eclipse.cdt.ui.visualstudio"/>
+
+               <key
+                       sequence="M1+M2+F"
+                       commandId="org.eclipse.search.ui.openSearchDialog"
+                       schemeId="org.eclipse.cdt.ui.visualstudio"/>
+
+               <!-- File Keys -->         
+               <!-- Help Keys -->
+               <!-- MakeFile Source Keys -->
+          
+               <!-- Navigate Keys -->
+               <key
+            sequence="M1+F2" 
+            commandId="org.eclipse.ui.edit.addBookmark"
+                       schemeId="org.eclipse.cdt.ui.visualstudio"/>
+
+               <key
+            sequence="M2+F2" 
+            commandId="org.eclipse.cdt.ui.edit.text.c.goto.next.bookmark"
+            contextId="org.eclipse.cdt.ui.cEditorScope"
+            schemeId="org.eclipse.cdt.ui.visualstudio"/>
+
+               <key
+            sequence="M1+G" 
+            commandId="org.eclipse.ui.edit.text.goto.line"
+                       schemeId="org.eclipse.cdt.ui.visualstudio"/>
+          
+               <!-- Project Keys -->
+          
+               <!-- MSVS RebuildSolution -->
+<!-- THERE IS CURRENTLY NO REBUILD
+               <key
+                       sequence="M1+M2+B"
+                       commandId="org.eclipse.ui.project.rebuildProject"
+                       schemeId="org.eclipse.cdt.ui.visualstudio"/>
+-->
+               <!-- MSVS NewProject -->   
+               <key
+                       sequence="M1+M2+N"
+                       commandId="org.eclipse.ui.newWizard"
+                       schemeId="org.eclipse.cdt.ui.visualstudio"/>
+          
+               <!-- Run/Debug Keys -->    
+               <!-- MSVS Start -->
+               <key
+                       sequence="M1+F5"
+                       commandId="org.eclipse.debug.ui.commands.RunLast"
+                       schemeId="org.eclipse.cdt.ui.visualstudio"/>
+          
+               <!-- MSVS StartWithoutDebugging -->
+               <key
+                       sequence="F5"
+                       commandId="org.eclipse.debug.ui.commands.DebugLast"
+                       schemeId="org.eclipse.cdt.ui.visualstudio"/>
+          
+               <!-- MSVS StepInto -->
+               <key
+                       sequence="F11"
+                       commandId="org.eclipse.debug.ui.commands.StepInto"
+                       contextId="org.eclipse.debug.ui.debugging"
+                       schemeId="org.eclipse.cdt.ui.visualstudio"/>
+          
+               <!-- MSVS StepOver -->
+               <key
+                       sequence="F10"
+                       commandId="org.eclipse.debug.ui.commands.StepOver"
+                       contextId="org.eclipse.debug.ui.debugging"
+                       schemeId="org.eclipse.cdt.ui.visualstudio"/>
+          
+               <!-- MSVS StepReturn -->
+               <key
+                       sequence="M2+F11"
+                       commandId="org.eclipse.debug.ui.commands.StepReturn"
+                       contextId="org.eclipse.debug.ui.debugging"
+                       schemeId="org.eclipse.cdt.ui.visualstudio"/>
+          
+               <!-- MSVS ToggleBreakpoint -->
+               <key
+                       sequence="F9"
+                       commandId="org.eclipse.debug.ui.commands.ToggleBreakpoint"
+                       schemeId="org.eclipse.cdt.ui.visualstudio"/>
+          
+               <!-- MSVS RunToCursor -->
+               <key
+                       sequence="M1+F10"
+                       commandId="org.eclipse.debug.ui.commands.RunToLine"
+                       schemeId="org.eclipse.cdt.ui.visualstudio"/>
+          
+               <!-- MSVS Breakpoints -->
+               <key
+        commandId="org.eclipse.ui.views.showView"
+        schemeId="org.eclipse.cdt.ui.visualstudio"
+        sequence="M1+M3+B">
+     <parameter
+           id="org.eclipse.ui.views.showView.viewId"
+           value="org.eclipse.debug.ui.BreakpointView">
+     </parameter>
+  </key>
+
+               <!-- Search Keys -->
+               <!-- Text Editing Keys -->
+          
+               <key    
+                       sequence="M1+ARROW_LEFT"
+                       commandId="org.eclipse.ui.edit.text.goto.wordPrevious"
+                       contextId="org.eclipse.ui.textEditorScope"
+                       schemeId="org.eclipse.cdt.ui.visualstudio"/>
+          
+               <key
+                       sequence="M1+ARROW_RIGHT"
+                       commandId="org.eclipse.ui.edit.text.goto.wordNext"
+                       contextId="org.eclipse.ui.textEditorScope"
+                       schemeId="org.eclipse.cdt.ui.visualstudio"/>
+          
+               <!-- View Keys -->
+               <!-- Views Keys -->
+               <!-- Window Keys -->
+                       
+               <!-- MSVC Window NextDocumentWindow --> 
+               <key
+                       sequence="M1+TAB"
+            commandId="org.eclipse.ui.window.nextEditor"
+                       schemeId="org.eclipse.cdt.ui.visualstudio"/>
+
+               <!-- MSVC Window.PreviousDocumentWindow -->
+               <key
+                       sequence="M1+M2+TAB"
+            commandId="org.eclipse.ui.window.previousEditor"
+                       schemeId="org.eclipse.cdt.ui.visualstudio"/>
+            
+   </extension>
+   <extension
+         point="org.eclipse.ui.commands">
+      <category
+            name="%category.source.name"
+            description="%category.source.description"
+            id="org.eclipse.cdt.ui.category.source">
+      </category>
+      <command
+            name="%ActionDefinition.format.name"
+            description="%ActionDefinition.format.description"
+            categoryId="org.eclipse.cdt.ui.category.source"
+            id="org.eclipse.cdt.ui.edit.text.c.format">
+      </command>
+      <command
+            name="%ActionDefinition.sourceQuickMenu.name"
+            description="%ActionDefinition.sourceQuickMenu.description"
+            categoryId="org.eclipse.cdt.ui.category.source"
+            id="org.eclipse.cdt.ui.edit.text.c.source.quickMenu">
+      </command>
+      <command
+            name="%ActionDefinition.comment.name"
+            description="%ActionDefinition.comment.description"
+            categoryId="org.eclipse.cdt.ui.category.source"
+            id="org.eclipse.cdt.ui.edit.text.c.comment">
+      </command>
+      <command
+            name="%ActionDefinition.uncomment.name"
+            description="%ActionDefinition.uncomment.description"
+            categoryId="org.eclipse.cdt.ui.category.source"
+            id="org.eclipse.cdt.ui.edit.text.c.uncomment">
+      </command>
+      <command
+            name="%ActionDefinition.toggleComment.name"
+            description="%ActionDefinition.toggleComment.description"
+            categoryId="org.eclipse.cdt.ui.category.source"
+            id="org.eclipse.cdt.ui.edit.text.c.toggle.comment">
+      </command>
+      <command
+            name="%ActionDefinition.addBlockComment.name"
+            description="%ActionDefinition.addBlockComment.description"
+            categoryId="org.eclipse.cdt.ui.category.source"
+            id="org.eclipse.cdt.ui.edit.text.c.add.block.comment">
+      </command>
+      <command
+            name="%ActionDefinition.removeBlockComment.name"
+            description="%ActionDefinition.removeBlockComment.description"
+            categoryId="org.eclipse.cdt.ui.category.source"
+            id="org.eclipse.cdt.ui.edit.text.c.remove.block.comment">
+      </command>
+      <command
+            name="%ActionDefinition.indent.name"
+            description="%ActionDefinition.indent.description"
+            categoryId="org.eclipse.cdt.ui.category.source"
+            id="org.eclipse.cdt.ui.edit.text.c.indent">
+      </command>
+      <command
+            name="%ActionDefinition.opendecl.name"
+            categoryId="org.eclipse.cdt.ui.category.source"
+            description="%ActionDefinition.opendecl.description"
+            id="org.eclipse.cdt.ui.edit.opendecl">
+      </command>
+      <command
+            name="%ActionDefinition.openType.name"
+            categoryId="org.eclipse.cdt.ui.category.source"
+            description="%ActionDefinition.openType.description"
+            id="org.eclipse.cdt.ui.navigate.opentype">
+      </command>
+      <command
+            name="%ActionDefinition.opencview.name"
+            description="%ActionDefinition.opencview.description"
+            categoryId="org.eclipse.cdt.ui.category.source"
+            id="org.eclipse.cdt.ui.edit.opencview">
+      </command>
+      <command
+            description="%ActionDefinition.finddecl.description"
+            categoryId="org.eclipse.cdt.ui.category.source"
+            name="%ActionDefinition.finddecl.name"
+            id="org.eclipse.cdt.ui.search.finddecl"/>
+      <command
+            categoryId="org.eclipse.cdt.ui.category.source"
+            description="%ActionDefinition.findrefs.description"
+            name="%ActionDefinition.findrefs.name"
+            id="org.eclipse.cdt.ui.search.findrefs"/>
+      <command
+            categoryId="org.eclipse.ui.category.navigate"
+            description="%ActionDefinition.openCallHierarchy.description"
+            name="%ActionDefinition.openCallHierarchy.name"
+            id="org.eclipse.cdt.ui.edit.open.call.hierarchy"/>
+      <command
+            name="%ActionDefinition.openTypeHierarchy.name"
+            description="%ActionDefinition.openTypeHierarchy.description"
+            categoryId="org.eclipse.ui.category.navigate"
+            id="org.eclipse.cdt.ui.edit.open.type.hierarchy">
+      </command>
+      <command
+            categoryId="org.eclipse.ui.category.navigate"
+            description="%ActionDefinition.openIncludeBrowser.description"
+            name="%ActionDefinition.openIncludeBrowser.name"
+            id="org.eclipse.cdt.ui.edit.open.include.browser">
+      </command>
+      <command
+            name="%ActionDefinition.openTypeInHierarchy.name"
+            description="%ActionDefinition.openTypeInHierarchy.description"
+            categoryId="org.eclipse.ui.category.navigate"
+            id="org.eclipse.cdt.ui.navigate.open.type.in.hierarchy">
+      </command>
+      <command
+            name="%ActionDefinition.openElementInCallHierarchy.name"
+            description="%ActionDefinition.openElementInCallHierarchy.description"
+            categoryId="org.eclipse.ui.category.navigate"
+            id="org.eclipse.cdt.ui.navigate.open.element.in.call.hierarchy">
+      </command>
+      <command
+            name="%ActionDefinition.addInclude.name"
+            description="%ActionDefinition.addInclude.description"
+            categoryId="org.eclipse.cdt.ui.category.source"
+            id="org.eclipse.cdt.ui.edit.text.c.add.include">
+      </command>
+      <command
+            name="%ActionDefinition.sortLines.name"
+            description="%ActionDefinition.sortLines.description"
+            categoryId="org.eclipse.cdt.ui.category.source"
+            id="org.eclipse.cdt.ui.edit.text.c.sort.lines">
+      </command>
+      <command
+            name="%ActionDefinition.showOutline.name"
+            description="%ActionDefinition.showOutline.description"
+            categoryId="org.eclipse.cdt.ui.category.source"
+            id="org.eclipse.cdt.ui.edit.open.outline">
+      </command>
+      <command
+            name="%ActionDefinition.showQuickTypeHierarchy.name"
+            description="%ActionDefinition.showQuickTypeHierarchy.description"
+            categoryId="org.eclipse.cdt.ui.category.source"
+            id="org.eclipse.cdt.ui.edit.open.quick.type.hierarchy">
+      </command>
+      <command
+            name="%ActionDefinition.GotoNextMember.name"
+            description="%ActionDefinition.GotoNextMember.description"
+            categoryId="org.eclipse.cdt.ui.category.source"
+            id="org.eclipse.cdt.ui.edit.text.c.goto.next.member">
+      </command>
+      <command
+            name="%ActionDefinition.GotoPrevMember.name"
+            description="%ActionDefinition.GotoPrevMember.description"
+            categoryId="org.eclipse.cdt.ui.category.source"
+            id="org.eclipse.cdt.ui.edit.text.c.goto.prev.member">
+      </command>
+      <command
+            name="%ActionDefinition.gotoMatchingBracket.name"
+            description="%ActionDefinition.gotoMatchingBracket.description"
+            categoryId="org.eclipse.cdt.ui.category.source"
+            id="org.eclipse.cdt.ui.edit.text.c.goto.matching.bracket">
+      </command>
+      <command
+            name="%ActionDefinition.gotoNextBookmark.name"
+            description="%ActionDefinition.gotoNextBookmark.description"
+            categoryId="org.eclipse.cdt.ui.category.source"
+            id="org.eclipse.cdt.ui.edit.text.c.goto.next.bookmark">
+      </command>
+      <command
+            name="%ActionDefinition.FindWord.name"
+            description="%ActionDefinition.FindWord.description"
+            categoryId="org.eclipse.cdt.ui.category.source"
+            id="org.eclipse.cdt.ui.edit.text.c.find.word">
+      </command>
+      <command
+            name="%ActionDefinition.toggleSourceHeader.name"
+            description="%ActionDefinition.toggleSourceHeader.description"
+            categoryId="org.eclipse.cdt.ui.category.source"
+            id="org.eclipse.cdt.ui.edit.text.c.toggle.source.header">
+      </command>
+      <command
+            name="%ActionDefinition.backwardMacroExpansion.name"
+            description="%ActionDefinition.backwardMacroExpansion.description"
+            categoryId="org.eclipse.cdt.ui.category.source"
+            id="org.eclipse.cdt.ui.hover.backwardMacroExpansion"/>
+      <command
+            name="%ActionDefinition.forwardMacroExpansion.name"
+            description="%ActionDefinition.forwardMacroExpansion.description"
+            categoryId="org.eclipse.cdt.ui.category.source"
+            id="org.eclipse.cdt.ui.hover.forwardMacroExpansion"/>
+      <command
+            name="%toggleMarkOccurrences.label"
+            description="%toggleMarkOccurrences.description"
+            categoryId="org.eclipse.cdt.ui.category.source"
+            id="org.eclipse.cdt.ui.edit.text.c.toggleMarkOccurrences"/>
+      <command
+            name="%ActionDefinition.showMacroExplorer.name"
+            description="%ActionDefinition.showMacroExplorer.description"
+            categoryId="org.eclipse.cdt.ui.category.source"
+            id="org.eclipse.cdt.ui.edit.open.quick.macro.explorer"/>
+      <category
+               name="%category.refactoring.name"
+               description="%category.refactoring.description"
+               id="org.eclipse.cdt.ui.category.refactoring"/>
+         <command
+               categoryId="org.eclipse.cdt.ui.category.refactoring"
+               id="org.eclipse.cdt.ui.refactoring.command.ExtractConstant"
+               name="%refactoringExtractConstant.label"/>
+      <command
+            categoryId="org.eclipse.cdt.ui.category.refactoring"
+            id="org.eclipse.cdt.ui.refactoring.command.ExtractLocalVariable"
+            name="%refactoringExtractLocalVariable.label"/>
+         <command
+               categoryId="org.eclipse.cdt.ui.category.refactoring"
+               id="org.eclipse.cdt.ui.refactor.hide.method"   
+               name="%refactoringHideMethod.label"/>
+      <command
+            name="%ActionDefinition.renameElement.name"
+            description="%ActionDefinition.renameElement.description"
+            categoryId="org.eclipse.cdt.ui.category.refactoring"
+            id="org.eclipse.cdt.ui.edit.text.rename.element"/>
+      <command
+            name="%ActionDefinition.extractConstant.name"
+            description="%ActionDefinition.extractConstant.description"
+            categoryId="org.eclipse.cdt.ui.category.refactoring"
+            id="org.eclipse.cdt.ui.refactor.extract.constant"/>
+      <command
+            name="%ActionDefinition.extractLocalVariable.name"
+            description="%ActionDefinition.extractLocalVariable.description"
+            categoryId="org.eclipse.cdt.ui.category.refactoring"
+            id="org.eclipse.cdt.ui.refactor.extract.local.variable"/>
+      <command
+            name="%ActionDefinition.extractFunction.name"
+            description="%ActionDefinition.extractFunction.description"
+            categoryId="org.eclipse.cdt.ui.category.refactoring"
+            id="org.eclipse.cdt.ui.refactor.extract.function"/>
+      <command
+            name="%ActionDefinition.toggleFunction.name"
+            description="%ActionDefinition.toggleFunction.description"
+            categoryId="org.eclipse.cdt.ui.category.refactoring"
+            id="org.eclipse.cdt.ui.refactor.toggle.function"/>
+      <command
+            name="%ActionDefinition.implementMethod.name"
+            description="%ActionDefinition.implementMethod.description"
+            categoryId="org.eclipse.cdt.ui.category.source"
+            id="org.eclipse.cdt.ui.refactor.implement.method"/>
+      <command
+               name="%ActionDefinition.gettersAndSetters.name"
+            description="%ActionDefinition.gettersAndSetters.description"
+               categoryId="org.eclipse.cdt.ui.category.source"
+               id="org.eclipse.cdt.ui.refactor.getters.and.setters"/>
+      <command
+            name="%ActionDefinition.surroundWith.quickMenu.name"
+            description="%ActionDefinition.surroundWith.quickMenu.description"
+            categoryId="org.eclipse.cdt.ui.category.source"
+            id="org.eclipse.cdt.ui.edit.text.c.surround.with.quickMenu">
+      </command>
+      <command
+            name="%ActionDefinition.selectEnclosing.name"
+            description="%ActionDefinition.selectEnclosing.description"
+            categoryId="org.eclipse.ui.category.edit"
+            id="org.eclipse.cdt.ui.edit.text.c.select.enclosing">
+      </command>
+      <command
+            name="%ActionDefinition.selectNext.name"
+            description="%ActionDefinition.selectNext.description"
+            categoryId="org.eclipse.ui.category.edit"
+            id="org.eclipse.cdt.ui.edit.text.c.select.next">
+      </command>
+      <command
+            name="%ActionDefinition.selectPrevious.name"
+            description="%ActionDefinition.selectPrevious.description"
+            categoryId="org.eclipse.ui.category.edit"
+            id="org.eclipse.cdt.ui.edit.text.c.select.previous">
+      </command>
+      <command
+            name="%ActionDefinition.selectLast.name"
+            description="%ActionDefinition.selectLast.description"
+            categoryId="org.eclipse.ui.category.edit"
+            id="org.eclipse.cdt.ui.edit.text.c.select.last">
+      </command>
+   </extension>
+   <extension
+         id="pdomSearchPage"
+         name="%cSearchPage.name"
+         point="org.eclipse.search.searchPages">
+      <page
+            canSearchEnclosingProjects="true"
+            class="org.eclipse.cdt.internal.ui.search.PDOMSearchPage"
+            extensions="c:90,cpp:90, cxx:90, cc:90,C:90, h:90, hh:90, hpp:90, H:90"
+            icon="icons/obj16/csearch_obj.gif"
+            id="org.eclipse.cdt.ui.pdomSearchPage"
+            label="%CSearchPage.label"
+            showScopeSection="true"
+            sizeHint="460, 160"/>
+   </extension>
+
+   <extension
+         point="org.eclipse.ui.actionSetPartAssociations">
+      <actionSetPartAssociation 
+            targetID="org.eclipse.cdt.ui.SearchActionSet">
+         <part id="org.eclipse.cdt.ui.CView"/>
+         <part id="org.eclipse.cdt.ui.editor.CEditor"/>
+         <part id="org.eclipse.search.SearchResultView"/>
+      </actionSetPartAssociation>
+      <actionSetPartAssociation 
+            targetID="org.eclipse.cdt.ui.CodingActionSet">
+         <part id="org.eclipse.cdt.ui.editor.CEditor"/>
+         <part id="org.eclipse.cdt.ui.CView"/>
+      </actionSetPartAssociation>
+      <actionSetPartAssociation 
+               targetID="org.eclipse.cdt.ui.OpenActionSet">
+         <part id="org.eclipse.cdt.ui.editor.CEditor"/>
+      </actionSetPartAssociation>
+      <actionSetPartAssociation 
+            targetID="org.eclipse.cdt.ui.NavigationActionSet">
+         <part id="org.eclipse.cdt.ui.editor.CEditor"/>
+      </actionSetPartAssociation>
+      <actionSetPartAssociation
+            targetID="org.eclipse.ui.edit.text.actionSet.annotationNavigation">
+         <part id="org.eclipse.cdt.ui.editor.CEditor"/>
+      </actionSetPartAssociation>      
+      <actionSetPartAssociation
+            targetID="org.eclipse.cdt.ui.text.c.actionSet.presentation">
+         <part id="org.eclipse.cdt.ui.editor.CEditor"/>
+      </actionSetPartAssociation>               
+   </extension>
+   <extension
+         point="org.eclipse.cdt.ui.BinaryParserPage">
+      <parserPage
+            class="org.eclipse.cdt.ui.dialogs.GNUElfBinaryParserPage"
+            parserID="org.eclipse.cdt.core.GNU_ELF"
+            id="ElfBinaryParserPage">
+      </parserPage>
+      <parserPage
+            class="org.eclipse.cdt.ui.dialogs.CygwinPEBinaryParserPage"
+            parserID="org.eclipse.cdt.core.Cygwin_PE"
+            id="PEBinaryParserPage">
+      </parserPage>
+      <parserPage
+            class="org.eclipse.cdt.ui.dialogs.GNUXCoffBinaryParserPage"
+            parserID="org.eclipse.cdt.core.XCOFF32"
+            id="XcoffBinaryParserPage">
+      </parserPage>
+      <parserPage
+            class="org.eclipse.cdt.ui.dialogs.MachOBinaryParserPage"
+            parserID="org.eclipse.cdt.core.MachO"
+            id="MachOBinaryParserPage">
+      </parserPage>
+      <parserPage
+            class="org.eclipse.cdt.ui.dialogs.MachOBinaryParserPage"
+            parserID="org.eclipse.cdt.core.MachO64"
+            id="MachO64BinaryParserPage">
+      </parserPage>
+      <parserPage
+            class="org.eclipse.cdt.ui.dialogs.GNUSomBinaryParserPage"
+            parserID="org.eclipse.cdt.core.SOM"
+            id="SomBinaryParserPage">
+      </parserPage>
+   </extension>
+   <extension
+         point="org.eclipse.ui.workingSets">
+      <workingSet
+            icon="icons/view16/cview.gif"
+            id="org.eclipse.cdt.ui.CElementWorkingSetPage"
+            name="%CElementWorkingSetPage.name"
+            pageClass="org.eclipse.cdt.internal.ui.workingsets.CElementWorkingSetPage"
+            updaterClass="org.eclipse.cdt.internal.ui.workingsets.CElementWorkingSetUpdater">
+      </workingSet>
+   </extension>
+   <extension
+         id="org.eclipse.cdt.ui.annotations"
+         point="org.eclipse.ui.editors.markerAnnotationSpecification">
+      <specification
+               colorPreferenceValue="254,155,0"
+            annotationType="org.eclipse.cdt.ui.indexmarker"
+            verticalRulerPreferenceValue="true"
+            colorPreferenceKey="indexResultIndicationColor"
+            contributesToHeader="false"
+            overviewRulerPreferenceValue="true"
+            presentationLayer="3"
+            textStylePreferenceValue="NONE"
+            symbolicIcon="warning"
+            icon="icons/obj16/unknown_obj.gif"
+            label="%CDTIndexerMarker.label"
+            textPreferenceValue="true"
+            textPreferenceKey="indexResultIndication"
+            verticalRulerPreferenceKey="indexResultIndicationInVerticalRuler"
+            overviewRulerPreferenceKey="indexResultIndicationInOverviewRuler"
+            showInNextPrevDropdownToolbarActionKey="isIndexResultInNextPrevDropdownToolbarAction"
+            showInNextPrevDropdownToolbarAction="true"
+            isGoToNextNavigationTargetKey="isIndexResultGoToNextNavigationTarget"
+               isGoToNextNavigationTarget="false"
+            isGoToPreviousNavigationTargetKey="isIndexResultGoToPreviousNavigationTarget"
+               isGoToPreviousNavigationTarget="false">
+      </specification>
+         <specification
+            annotationType="org.eclipse.cdt.ui.occurrences"
+            label="%OccurrenceAnnotation.label"
+            icon="$nl$/icons/obj16/searchm_obj.gif"
+            textPreferenceKey="org.eclipse.cdt.ui.occurrenceIndication"
+            textPreferenceValue="false"
+            highlightPreferenceKey="org.eclipse.cdt.ui.occurrenceHighlighting"
+            highlightPreferenceValue="true"
+            contributesToHeader="false"
+            overviewRulerPreferenceKey="org.eclipse.cdt.ui.occurrenceIndicationInOverviewRuler"
+            overviewRulerPreferenceValue="true"
+            verticalRulerPreferenceKey="org.eclipse.cdt.ui.occurrenceIndicationInVerticalRuler"
+            verticalRulerPreferenceValue="false"
+            colorPreferenceKey="org.eclipse.cdt.ui.occurrenceIndicationColor"
+            colorPreferenceValue="212,212,212"
+            presentationLayer="4"
+            showInNextPrevDropdownToolbarActionKey="org.eclipse.cdt.ui.showOccurrenceInNextPrevDropdownToolbarAction"
+            showInNextPrevDropdownToolbarAction="true"
+            isGoToNextNavigationTargetKey="org.eclipse.cdt.ui.isOccurrenceGoToNextNavigationTarget"
+               isGoToNextNavigationTarget="false"
+            isGoToPreviousNavigationTargetKey="org.eclipse.cdt.ui.isOccurrenceGoToPreviousNavigationTarget"
+               isGoToPreviousNavigationTarget="false"
+            textStylePreferenceKey="org.eclipse.cdt.ui.occurrenceTextStyle"
+            textStylePreferenceValue="NONE">
+         </specification>
+         <specification
+            annotationType="org.eclipse.cdt.ui.occurrences.write"
+            label="%WriteOccurrenceAnnotation.label"
+            textPreferenceKey="org.eclipse.cdt.ui.occurrenceIndication"
+            textPreferenceValue="false"
+            highlightPreferenceKey="org.eclipse.cdt.ui.writeOccurrenceHighlighting"
+            highlightPreferenceValue="true"
+            overviewRulerPreferenceKey="org.eclipse.cdt.ui.writeOccurrenceIndicationInOverviewRuler"
+            overviewRulerPreferenceValue="true"
+            verticalRulerPreferenceKey="org.eclipse.cdt.ui.writeOccurrenceIndicationInVerticalRuler"
+            verticalRulerPreferenceValue="false"
+            colorPreferenceKey="org.eclipse.cdt.ui.writeOccurrenceIndicationColor"
+            colorPreferenceValue="240, 216, 168"
+            presentationLayer="4"
+            textStylePreferenceKey="org.eclipse.cdt.ui.writeOccurrenceTextStyle"
+            textStylePreferenceValue="NONE">
+         </specification>
+         <specification
+            annotationType="org.eclipse.cdt.ui.overrideIndicator"
+            label="%overrideAnnotation.label"
+                       annotationImageProvider ="org.eclipse.cdt.internal.ui.editor.OverrideIndicatorImageProvider"
+            textPreferenceKey="org.eclipse.cdt.ui.overrideIndicator"
+            textPreferenceValue="false"
+            highlightPreferenceKey="org.eclipse.cdt.ui.overrideIndicatorHighlighting"
+            highlightPreferenceValue="false"
+            contributesToHeader="false"
+            overviewRulerPreferenceKey="org.eclipse.cdt.ui.overrideIndicatorInOverviewRuler"
+            overviewRulerPreferenceValue="false"
+            verticalRulerPreferenceKey="org.eclipse.cdt.ui.overrideIndicatorInVerticalRuler"
+            verticalRulerPreferenceValue="true"
+            colorPreferenceKey="org.eclipse.cdt.ui.overrideIndicatorColor"
+            colorPreferenceValue="180,207,205"
+            presentationLayer="3"
+            showInNextPrevDropdownToolbarActionKey="org.eclipse.cdt.ui.showoverrideIndicatorInNextPrevDropdownToolbarAction"
+            showInNextPrevDropdownToolbarAction="false"
+            isGoToNextNavigationTargetKey="org.eclipse.cdt.ui.isOverrideIndicatorGoToNextNavigationTarget"
+               isGoToNextNavigationTarget="false"
+            isGoToPreviousNavigationTargetKey="org.eclipse.cdt.ui.isOverrideIndicatorGoToPreviousNavigationTarget"
+               isGoToPreviousNavigationTarget="false"
+            textStylePreferenceKey="org.eclipse.cdt.ui.overrideIndicatorTextStyle"
+            textStylePreferenceValue="SQUIGGLES">
+         </specification>
+   </extension>
+   <extension
+         point="org.eclipse.search.searchResultViewPages">
+      <viewPage
+            class="org.eclipse.cdt.internal.ui.search.PDOMSearchViewPage"
+            id="org.eclipse.cdt.ui.pdomSearchViewPage"
+            searchResultClass="org.eclipse.cdt.internal.ui.search.PDOMSearchResult"/>
+   </extension>
+   
+   <extension
+         point="org.eclipse.ui.propertyPages">
+      <page
+            class="org.eclipse.cdt.ui.newui.Page_head_general"
+            id="org.eclipse.cdt.ui.newui.Page_head_general"
+            name="%page.c.general"
+            >
+         <filter
+               name="projectNature"
+               value="org.eclipse.cdt.core.cnature">
+         </filter>            
+         <enabledWhen>
+            <or>
+                    <adapt type="org.eclipse.core.resources.IProject"/>
+                    
+                    <instanceof value="org.eclipse.core.resources.IFolder"/>
+                    <instanceof value="org.eclipse.cdt.core.model.ICContainer"/>
+
+                <instanceof value="org.eclipse.core.resources.IFile"/>
+                <instanceof value="org.eclipse.cdt.core.model.ITranslationUnit"/>
+                   </or>          
+         </enabledWhen>
+      </page>    
+
+      <page
+            name="%CDTIndexerProperty.name"
+            class="org.eclipse.cdt.ui.dialogs.IndexerOptionPropertyPage"
+            category="org.eclipse.cdt.ui.newui.Page_head_general"
+            id="org.eclipse.cdt.ui.indexer">
+         <enabledWhen>
+                    <adapt type="org.eclipse.core.resources.IProject">
+                         <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
+                    </adapt>         
+         </enabledWhen>
+      </page>
+      <page
+            name="%CDTFileTypesProperty.name"
+            class="org.eclipse.cdt.internal.ui.preferences.CFileTypesPropertyPage"
+            category="org.eclipse.cdt.ui.newui.Page_head_general"
+            id="org.eclipse.cdt.ui.fileTypes">
+         <enabledWhen>
+                    <adapt type="org.eclipse.core.resources.IProject">
+                         <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
+                    </adapt>         
+         </enabledWhen>
+       </page>
+      <page
+            name="%CDTHelpProperty.name"
+            class="org.eclipse.cdt.ui.dialogs.CHelpConfigurationPropertyPage"
+            category="org.eclipse.cdt.ui.newui.Page_head_general"
+            id="org.eclipse.cdt.ui.cHelp">
+         <enabledWhen>
+                    <adapt type="org.eclipse.core.resources.IProject">
+                         <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
+                    </adapt>         
+         </enabledWhen>
+      </page>
+      <page
+            class="org.eclipse.cdt.internal.ui.language.ProjectLanguageMappingPropertyPage"
+            id="org.eclipse.cdt.ui.projectLanguageMappings"
+            category="org.eclipse.cdt.ui.newui.Page_head_general"
+            name="%CDTLanguagesProperty.name">
+         <enabledWhen>
+                    <adapt type="org.eclipse.core.resources.IProject">
+                         <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
+                    </adapt>         
+         </enabledWhen>
+      </page>
+      <page
+            class="org.eclipse.cdt.internal.ui.language.FileLanguageMappingPropertyPage"
+            id="org.eclipse.cdt.ui.fileLanguageMappings"
+            category="org.eclipse.cdt.ui.newui.Page_head_general"
+            name="%CDTLanguagesProperty.name">
+         <enabledWhen>
+            <and>
+               <adapt type="org.eclipse.cdt.core.model.ITranslationUnit"/>
+               <adapt type="org.eclipse.core.resources.IFile"/>
+            </and>
+         </enabledWhen>
+      </page>
+
+      <page
+            name="%CodeFormatterPreferencePage.name"
+            class="org.eclipse.cdt.internal.ui.preferences.CodeFormatterPreferencePage"
+            category="org.eclipse.cdt.ui.newui.Page_head_general"
+            id="org.eclipse.cdt.ui.propertyPages.CodeFormatterPreferencePage">
+         <enabledWhen>
+                    <adapt type="org.eclipse.core.resources.IProject">
+                         <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
+                    </adapt>         
+         </enabledWhen>
+      </page>
+      <page
+            name="%BuildLoggingPreferencePage.name"
+            id="org.eclipse.cdt.managedbuilder.ui.properties.BuildLogPreferencePage"
+            class="org.eclipse.cdt.internal.ui.preferences.BuildLogPreferencePage"
+            category="org.eclipse.cdt.managedbuilder.ui.properties.Page_head_build">
+         <keywordReference id="org.eclipse.cdt.ui.common"/>
+         <enabledWhen>
+             <adapt type="org.eclipse.core.resources.IProject">
+                 <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
+             </adapt>
+         </enabledWhen>
+      </page>
+   </extension>
+
+   <extension
+         point="org.eclipse.cdt.ui.PathContainerPage">
+      <PathContainerPage
+            name="%defaultPathContainerPage"
+            class="org.eclipse.cdt.internal.ui.dialogs.cpaths.CPathContainerDefaultPage"
+            id="*">
+      </PathContainerPage>
+   </extension>
+
+   <extension
+         point="org.eclipse.ui.editors.annotationTypes">
+      <type
+         name="org.eclipse.cdt.ui.error"
+         super="org.eclipse.ui.workbench.texteditor.error"
+         markerType="org.eclipse.cdt.core.problem"
+         markerSeverity="2">
+      </type>
+      <type
+         name="org.eclipse.cdt.ui.warning"
+         super="org.eclipse.ui.workbench.texteditor.warning"
+         markerType="org.eclipse.cdt.core.problem"
+         markerSeverity="1">
+      </type>
+      <type
+         name="org.eclipse.cdt.ui.info"
+         super="org.eclipse.ui.workbench.texteditor.info"
+         markerType="org.eclipse.cdt.core.problem"
+         markerSeverity="0">
+      </type>
+      <type
+         markerType="org.eclipse.cdt.core.indexermarker"
+         name="org.eclipse.cdt.ui.indexmarker">
+      </type>
+      <type
+         name="org.eclipse.cdt.ui.occurrences">
+      </type>
+      <type
+         name="org.eclipse.cdt.ui.occurrences.write"
+         super="org.eclipse.cdt.ui.occurrences">
+      </type>
+      <type name="org.eclipse.cdt.ui.overrideIndicator"/>
+   </extension>
+   <extension point="org.eclipse.ui.workbench.texteditor.spellingEngine">
+      <engine
+            preferencesClass="org.eclipse.cdt.internal.ui.preferences.SpellingPreferenceBlock"
+            label="%cSpellingEngine.label"
+            class="org.eclipse.cdt.internal.ui.text.spelling.SpellingEngineDispatcher"
+            default="false"
+            id="org.eclipse.cdt.internal.ui.text.spelling.CSpellingEngine">
+      </engine>
+   </extension>
+   <extension
+         point="org.eclipse.core.runtime.preferences">
+      <initializer class="org.eclipse.cdt.ui.CUIPreferenceInitializer"/>
+   </extension>
+   <extension
+         point="org.eclipse.core.runtime.preferences">
+      <initializer class="org.eclipse.cdt.ui.text.doctools.doxygen.DoxygenHelper"/>
+   </extension>
+   
+<!-- Default folding -->
+       <extension
+               point= "org.eclipse.cdt.ui.foldingStructureProviders">
+               <provider
+                       id="org.eclipse.cdt.ui.text.defaultFoldingProvider"
+                       name= "%defaultFoldingStructureProviderName"
+                       class="org.eclipse.cdt.internal.ui.text.folding.DefaultCFoldingStructureProvider"
+                       preferencesClass="org.eclipse.cdt.internal.ui.text.folding.DefaultCFoldingPreferenceBlock">
+               </provider>
+       </extension>
+
+<!--- Template extension for the editor -->
+   <extension
+         point="org.eclipse.ui.editors.templates">
+      <contextTypeRegistry id="org.eclipse.cdt.ui.editor.CEditor"/>
+      <contextTypeRegistry id="org.eclipse.cdt.ui.codeTemplates"/>
+      <contextType
+            name="%c.contextType.name"
+            class="org.eclipse.cdt.internal.corext.template.c.CContextType"
+            id="org.eclipse.cdt.ui.text.templates.c"
+            registryId="org.eclipse.cdt.ui.editor.CEditor">
+      </contextType>
+      <contextType
+            class="org.eclipse.cdt.internal.corext.template.c.CommentContextType"
+            id="org.eclipse.cdt.ui.text.templates.comment"
+            name="%comment.contextType.name"
+            registryId="org.eclipse.cdt.ui.editor.CEditor">
+      </contextType>
+      <contextType
+            class="org.eclipse.cdt.internal.corext.template.c.DocCommentContextType"
+            id="org.eclipse.cdt.ui.text.templates.doccomment"
+            name="%doccomment.contextType.name"
+            registryId="org.eclipse.cdt.ui.editor.CEditor">
+      </contextType>
+      <include
+               file="templates/default-templates.xml"
+               translations="$nl$/templates/default-templates.properties">
+      </include>
+      <include
+               file="templates/default-codetemplates.xml"
+               translations="$nl$/templates/default-templates.properties">
+      </include>
+      <include
+               file="templates/default-filetemplates.xml"
+               translations="$nl$/templates/default-templates.properties">
+      </include>
+   </extension>
+   <extension
+         point="org.eclipse.cdt.ui.IndexerPage">
+      <indexerUI
+            class="org.eclipse.cdt.ui.dialogs.NullIndexerBlock"
+            indexerID="org.eclipse.cdt.core.nullindexer"
+            name="%CDTIndexer.nullindexer"
+            id="org.eclipse.cdt.ui.nullindexerUI"/>
+      <indexerUI
+            class="org.eclipse.cdt.ui.dialogs.FastIndexerBlock"
+            id="org.eclipse.cdt.ui.fastIndexer"
+            indexerID="org.eclipse.cdt.core.fastIndexer"
+            name="%CDTIndexer.fastindexer"/>
+   </extension>
+
+    <extension
+        point="org.eclipse.cdt.ui.completionProposalComputer"
+        id="defaultProposalCategory"
+        name="%DefaultProposalCategory">
+        <proposalCategory/>
+    </extension>
+    <extension
+        point="org.eclipse.cdt.ui.completionProposalComputer"
+        id="parserProposalCategory"
+        name="%ParserProposalCategory">
+        <proposalCategory
+            icon="$nl$/icons/elcl16/codeassist_co.gif"/>
+    </extension>
+    <extension
+        point="org.eclipse.cdt.ui.completionProposalComputer"
+        id="templateProposalCategory"
+        name="%TemplateProposalCategory">
+        <proposalCategory
+            icon="$nl$/icons/elcl16/templateprop_co.gif"/>
+    </extension>
+    <extension
+        point="org.eclipse.cdt.ui.completionProposalComputer"
+        id="helpProposalCategory"
+        name="%HelpProposalCategory">
+        <proposalCategory
+            icon="$nl$/icons/elcl16/helpprop_co.gif"/>
+    </extension>
+    <extension
+        point="org.eclipse.cdt.ui.completionProposalComputer"
+        id="textProposalCategory"
+        name="%TextProposalCategory">
+        <proposalCategory
+            icon="$nl$/icons/elcl16/wordassist_co.gif"/>
+    </extension>
+    <extension
+          id="DOMCompletionProposalComputer"
+          point="org.eclipse.cdt.ui.completionProposalComputer">
+       <completionProposalComputer
+             categoryId="org.eclipse.cdt.ui.parserProposalCategory"
+             class="org.eclipse.cdt.internal.ui.text.contentassist.DOMCompletionProposalComputer">
+          <partition type="__dftl_partition_content_type"/>
+          <partition type="__c_preprocessor"/>
+       </completionProposalComputer>
+    </extension>
+    <extension
+          id="InclusionProposalComputer"
+          point="org.eclipse.cdt.ui.completionProposalComputer">
+       <completionProposalComputer
+             categoryId="org.eclipse.cdt.ui.parserProposalCategory"
+             class="org.eclipse.cdt.internal.ui.text.contentassist.InclusionProposalComputer">
+          <partition type="__c_preprocessor"/>
+       </completionProposalComputer>
+    </extension>
+     
+    <extension
+          id="KeywordCompletionProposalComputer"
+          point="org.eclipse.cdt.ui.completionProposalComputer">
+       <completionProposalComputer
+             categoryId="org.eclipse.cdt.ui.parserProposalCategory"
+             class="org.eclipse.cdt.internal.ui.text.contentassist.KeywordCompletionProposalComputer">
+          <partition type="__dftl_partition_content_type"/>
+          <partition type="__c_preprocessor"/>
+       </completionProposalComputer>
+    </extension>
+    <!-- template proposals -->
+    <extension
+        point="org.eclipse.cdt.ui.completionProposalComputer"
+        id="TemplateCompletionProposalComputer">
+        <completionProposalComputer 
+            class="org.eclipse.cdt.internal.ui.text.contentassist.TemplateCompletionProposalComputer"
+            categoryId="org.eclipse.cdt.ui.templateProposalCategory">
+            <partition type="__dftl_partition_content_type"/>
+            <partition type="__c_multiline_comment"/>
+            <partition type="__c_singleline_comment"/>
+            <partition type="__c_multiline_doc_comment"/>
+            <partition type="__c_singleline_doc_comment"/>
+        </completionProposalComputer>
+    </extension>
+    <!-- help provider proposals -->
+    <extension
+        point="org.eclipse.cdt.ui.completionProposalComputer"
+        id="HelpCompletionProposalComputer">
+        <completionProposalComputer
+            class="org.eclipse.cdt.internal.ui.text.contentassist.HelpCompletionProposalComputer"
+            categoryId="org.eclipse.cdt.ui.helpProposalCategory">
+            <partition type="__dftl_partition_content_type"/>
+        </completionProposalComputer>
+    </extension>
+    <!-- hippie word proposals -->
+    <extension
+        point="org.eclipse.cdt.ui.completionProposalComputer"
+        id="HippieCompletionProposalComputer">
+        <completionProposalComputer
+            class="org.eclipse.cdt.internal.ui.text.contentassist.HippieProposalComputer"
+            categoryId="org.eclipse.cdt.ui.textProposalCategory">
+            <partition type="__c_singleline_comment"/>
+            <partition type="__c_multiline_comment"/>
+            <partition type="__c_string"/>
+            <partition type="__c_preprocessor"/>
+        </completionProposalComputer>
+    </extension>
+    
+    <!-- the parameterized content assist action and keybindings for our contributed computers -->
+   <extension
+    point="org.eclipse.ui.commands">
+        <command
+            categoryId="org.eclipse.ui.category.edit"
+            description="%SpecificContentAssist.desc"
+            id="org.eclipse.cdt.ui.specific_content_assist.command"
+            name="%SpecificContentAssist.name"
+            defaultHandler="org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistHandler">
+            <commandParameter
+                id="org.eclipse.cdt.ui.specific_content_assist.category_id"
+                name="%SpecificContentAssist.param"
+                optional="false"
+                values="org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistComputerParameter"/>
+        </command>
+   </extension>
+
+   <extension
+         point="org.eclipse.cdt.ui.quickFixProcessors">
+      <quickFixProcessor
+            name="%spellingQuickFixProcessor"
+            class="org.eclipse.cdt.internal.ui.text.spelling.WordQuickFixProcessor"
+            id="org.eclipse.cdt.ui.text.correction.spelling.QuickFixProcessor">
+            <handledMarkerTypes>
+                <markerType id="org.eclipse.cdt.internal.spelling"/>
+               </handledMarkerTypes>
+      </quickFixProcessor>
+   </extension>
+   <extension
+         point="org.eclipse.cdt.ui.quickAssistProcessors">
+      <quickAssistProcessor
+            name="%defaultQuickAssistProcessor"
+            class="org.eclipse.cdt.internal.ui.text.correction.QuickAssistProcessor"
+            id="org.eclipse.cdt.ui.text.correction.QuickAssistProcessor">
+      </quickAssistProcessor>
+   </extension>
+
+<!--- Common Navigator extensions -->
+  <extension
+       point="org.eclipse.ui.navigator.navigatorContent">
+    <navigatorContent
+          activeByDefault="true"
+          contentProvider="org.eclipse.cdt.internal.ui.navigator.CNavigatorContentProvider"
+          icon="icons/view16/cview.gif"
+          id="org.eclipse.cdt.ui.navigator.content"
+          labelProvider="org.eclipse.cdt.internal.ui.navigator.CNavigatorLabelProvider"
+          name="%navigatorContent.name"
+          priority="normal">
+       <triggerPoints>
+          <or>
+             <instanceof value="org.eclipse.cdt.core.model.ICElement"/>
+             <instanceof value="org.eclipse.cdt.ui.CElementGrouping"/>
+             <and>
+                    <instanceof value="org.eclipse.core.resources.IResource"/>
+                    <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
+             </and>
+             <instanceof value="org.eclipse.core.resources.IWorkspaceRoot"/>
+          </or>
+       </triggerPoints>
+       <possibleChildren>
+          <or>
+             <instanceof value="org.eclipse.core.resources.IResource"/>
+             <instanceof value="org.eclipse.cdt.core.model.ICElement"/>
+             <instanceof value="org.eclipse.cdt.ui.CElementGrouping"/>
+          </or>
+       </possibleChildren>
+       <override
+             policy="InvokeAlwaysRegardlessOfSuppressedExt"
+             suppressedExtensionId="org.eclipse.ui.navigator.resourceContent"/>
+       <commonSorter
+             class="org.eclipse.cdt.ui.CElementSorter"
+             id="org.eclipse.cdt.ui.commonSorter">
+       </commonSorter>
+       <actionProvider
+             class="org.eclipse.cdt.internal.ui.navigator.CNavigatorOpenActionProvider"
+             id="org.eclipse.cdt.ui.navigator.actions.open"
+             overrides="org.eclipse.ui.navigator.resources.OpenActions">
+                <enablement>
+                       <or>
+                               <instanceof value="org.eclipse.cdt.core.model.ICElement" />     
+                       <and>
+                           <instanceof value="org.eclipse.core.resources.IProject"/>
+                           <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
+                       </and>
+                       </or>
+         </enablement>
+       </actionProvider>
+       <actionProvider
+             class="org.eclipse.cdt.internal.ui.navigator.CNavigatorBuildActionProvider"
+             dependsOn="org.eclipse.ui.navigator.resources.ResourceMgmtActions"
+             id="org.eclipse.cdt.ui.navigator.actions.build">
+                <enablement>
+                       <or>
+                               <instanceof value="org.eclipse.cdt.core.model.ICElement" />     
+                       <and>
+                           <instanceof value="org.eclipse.core.resources.IProject"/>
+                           <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
+                       </and>
+                       </or>
+         </enablement>
+       </actionProvider>
+       <actionProvider
+             class="org.eclipse.cdt.internal.ui.navigator.CNavigatorSearchActionProvider"
+             id="org.eclipse.cdt.ui.navigator.actions.search">
+          <enablement>
+             <and>
+                <instanceof value="org.eclipse.cdt.core.model.ISourceReference" />
+                <not>
+                   <instanceof value="org.eclipse.cdt.core.model.ITranslationUnit" />
+                </not>
+             </and>
+          </enablement>
+       </actionProvider>
+       <actionProvider
+             class="org.eclipse.cdt.internal.ui.navigator.CNavigatorOpenViewActionProvider"
+             id="org.eclipse.cdt.ui.navigator.actions.open.view">
+          <enablement>
+             <instanceof value="org.eclipse.cdt.core.model.ICElement"/>
+          </enablement>
+       </actionProvider>
+       <actionProvider
+             class="org.eclipse.cdt.internal.ui.navigator.CNavigatorEditActionProvider"
+             id="org.eclipse.cdt.ui.navigator.actions.edit"
+             overrides="org.eclipse.ui.navigator.resources.actions.EditActions">
+          <enablement>
+                       <or>
+                               <instanceof value="org.eclipse.cdt.core.model.ICElement" />
+                               <and>
+                                  <instanceof value="org.eclipse.core.resources.IResource" />
+                      <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
+                               </and>
+                       </or>
+          </enablement>
+       </actionProvider>
+       <actionProvider
+             class="org.eclipse.cdt.internal.ui.navigator.CNavigatorRefactorActionProvider"
+             id="org.eclipse.cdt.ui.navigator.actions.refactor"
+             overrides="org.eclipse.ui.navigator.resources.actions.RefactorActions">
+          <enablement>
+                       <or>
+                               <instanceof value="org.eclipse.cdt.core.model.ICElement" />     
+                               <and>
+                                  <instanceof value="org.eclipse.core.resources.IResource" />
+                      <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
+                               </and>
+                       </or>
+          </enablement>
+       </actionProvider>
+          <commonWizard
+                associatedExtensionId="org.eclipse.cdt.ui.navigator.content"
+                menuGroupId="org.eclipse.cdt.ui.newProject"
+                type="new"
+                wizardId="org.eclipse.cdt.ui.wizards.NewCWizard1">
+                <enablement/>
+          </commonWizard>
+          <commonWizard
+                associatedExtensionId="org.eclipse.cdt.ui.navigator.content"
+                menuGroupId="org.eclipse.cdt.ui.newProject"
+                type="new"
+                wizardId="org.eclipse.cdt.ui.wizards.NewCWizard2">
+                <enablement/>
+          </commonWizard>
+          <commonWizard
+                associatedExtensionId="org.eclipse.cdt.ui.navigator.content"
+                menuGroupId="org.eclipse.cdt.ui"
+                type="new"
+                wizardId="org.eclipse.cdt.ui.wizards.NewSourceFileCreationWizard">
+                <enablement>
+                       <or>
+                               <instanceof value="org.eclipse.cdt.core.model.ICElement" />     
+                       <and>
+                           <instanceof value="org.eclipse.core.resources.IProject"/>
+                           <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
+                       </and>
+                       </or>
+         </enablement>
+          </commonWizard>
+       <commonWizard
+            associatedExtensionId="org.eclipse.cdt.ui.navigator.content"
+            menuGroupId="org.eclipse.cdt.ui"
+            type="new"
+            wizardId="org.eclipse.cdt.ui.wizards.NewHeaderFileCreationWizard">
+                <enablement>
+                       <or>
+                               <instanceof value="org.eclipse.cdt.core.model.ICElement" />     
+                       <and>
+                           <instanceof value="org.eclipse.core.resources.IProject"/>
+                           <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
+                       </and>
+                       </or>
+         </enablement>
+          </commonWizard>
+       <commonWizard
+            associatedExtensionId="org.eclipse.cdt.ui.navigator.content"
+            menuGroupId="org.eclipse.cdt.ui"
+            type="new"
+            wizardId="org.eclipse.cdt.ui.wizards.NewSourceFolderCreationWizard">
+                <enablement>
+                       <or>
+                               <instanceof value="org.eclipse.cdt.core.model.ICElement" />     
+                       <and>
+                           <instanceof value="org.eclipse.core.resources.IContainer"/>
+                           <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
+                       </and>
+                       </or>
+         </enablement>
+          </commonWizard>
+       <commonWizard
+            associatedExtensionId="org.eclipse.cdt.ui.navigator.content"
+            menuGroupId="org.eclipse.cdt.ui"
+            type="new"
+            wizardId="org.eclipse.cdt.ui.wizards.NewClassCreationWizard">
+                <enablement>
+                       <or>
+                               <instanceof value="org.eclipse.cdt.core.model.ICElement" />     
+                       <and>
+                           <instanceof value="org.eclipse.core.resources.IProject"/>
+                           <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
+                       </and>
+                       </or>
+         </enablement>
+          </commonWizard>
+          <commonWizard
+                associatedExtensionId="org.eclipse.cdt.ui.navigator.content"
+                type="new"
+                wizardId="org.eclipse.cdt.ui.wizards.NewFileCreationWizard">
+                <enablement>
+                       <or>
+                               <instanceof value="org.eclipse.cdt.core.model.ICElement" />     
+                       <and>
+                           <instanceof value="org.eclipse.core.resources.IContainer"/>
+                           <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.cdt.core.cnature"/>
+                       </and>
+                       </or>
+         </enablement>
+          </commonWizard>
+     <dropAssistant
+           class="org.eclipse.cdt.internal.ui.navigator.CNavigatorDropAdapterAssistant"
+           id="org.eclipse.cdt.ui.navigator.dropAssistant">
+        <possibleDropTargets>
+           <or>
+              <instanceof value="org.eclipse.cdt.core.model.ISourceReference"/>
+              <instanceof value="org.eclipse.cdt.core.model.ICContainer"/>
+              <instanceof value="org.eclipse.cdt.core.model.ICProject"/>
+              <instanceof value="org.eclipse.core.resources.IResource"/>
+           </or>
+        </possibleDropTargets>
+     </dropAssistant>
+    </navigatorContent>
+    <commonFilter
+          class="org.eclipse.cdt.internal.ui.filters.ExecutableFilter"
+          description="%HideExecutableFiles.description"
+          id="org.eclipse.cdt.ui.navigator.filters.ExecutableFilter"
+          name="%HideExecutableFiles.label"/>
+    <commonFilter
+          class="org.eclipse.cdt.internal.ui.filters.SharedFilter"
+          description="%HideSharedFiles.description"
+          id="org.eclipse.cdt.ui.navigator.filters.SharedFilter"
+          name="%HideSharedFiles.label"/>
+    <commonFilter
+          class="org.eclipse.cdt.internal.ui.filters.ObjectFilter"
+          description="%HideObjectFiles.description"
+          id="org.eclipse.cdt.ui.navigator.filters.ObjectFilter"
+          name="%HideObjectFiles.label"/>
+    <commonFilter
+          class="org.eclipse.cdt.internal.ui.filters.ArchiveFilter"
+          description="%HideArchiveFiles.description"
+          id="org.eclipse.cdt.ui.navigator.filters.ArchiveFilter"
+          name="%HideArchiveFiles.label"/>
+    <commonFilter
+          class="org.eclipse.cdt.internal.ui.filters.NonCProjectsFilter"
+          description="%HideNonCProjects.description"
+          id="org.eclipse.cdt.ui.navigator.filters.NonCProjectsFilter"
+          name="%HideNonCProjects.label"/>
+    <commonFilter
+          class="org.eclipse.cdt.internal.ui.filters.NonCElementFilter"
+          description="%HideNonCElements.description"
+          id="org.eclipse.cdt.ui.navigator.filters.NonCElementFilter"
+          name="%HideNonCElements.label"/>
+  </extension>
+  <extension
+         point="org.eclipse.ui.navigator.linkHelper">
+      <linkHelper
+            class="org.eclipse.cdt.internal.ui.navigator.CNavigatorLinkHelper"
+            id="org.eclipse.cdt.ui.navigator.linkHelper">
+         <editorInputEnablement>
+            <or>
+               <instanceof value="org.eclipse.ui.IFileEditorInput"/>
+               <instanceof value="org.eclipse.cdt.internal.ui.editor.ITranslationUnitEditorInput"/>
+            </or>
+         </editorInputEnablement>
+         <selectionEnablement>
+            <or>
+               <instanceof value="org.eclipse.core.resources.IResource" />
+               <instanceof value="org.eclipse.cdt.core.model.ICElement"/>
+            </or>
+         </selectionEnablement>
+      </linkHelper>
+  </extension>
+  
+  <extension
+       point="org.eclipse.ui.navigator.viewer">
+    <viewerContentBinding viewerId="org.eclipse.ui.navigator.ProjectExplorer">
+       <includes>
+          <contentExtension pattern="org.eclipse.cdt.ui.navigator.content"/>
+          <contentExtension pattern="org.eclipse.cdt.ui.navigator.filters.*"/>
+          <contentExtension pattern="org.eclipse.cdt.ui.wizards.*"/>
+          <contentExtension pattern="org.eclipse.cdt.ui.navigator.linkHelper"/>
+       </includes>
+    </viewerContentBinding>
+    <dragAssistant
+          class="org.eclipse.cdt.internal.ui.navigator.CNavigatorDragAdapterAssistant"
+          viewerId="org.eclipse.ui.navigator.ProjectExplorer"/>
+  </extension>
+  <extension
+        point="org.eclipse.core.expressions.propertyTesters">
+      <propertyTester
+           id="org.eclipse.cdt.Tester3"
+           class="org.eclipse.cdt.ui.newui.PropertyTester"
+           namespace="org.eclipse.cdt.ui"
+           properties="pageEnabled"
+           type="java.lang.Object"/>
+      <propertyTester
+           id="org.eclipse.cdt.Tester1"
+           class="org.eclipse.cdt.ui.newui.PropertyTester"
+           namespace="org.eclipse.cdt.ui"
+           properties="isSource"
+           type="org.eclipse.cdt.core.model.ITranslationUnit"/>
+      <propertyTester
+           id="org.eclipse.cdt.Tester2"
+           class="org.eclipse.cdt.ui.newui.PropertyTester"
+           namespace="org.eclipse.cdt.ui"
+           properties="isSource"
+           type="org.eclipse.core.resources.IFile"/>
+      <propertyTester
+           id="org.eclipse.cdt.ui.workingSetPropertyTester"
+           class="org.eclipse.cdt.internal.ui.workingsets.WorkingSetPropertyTester"
+           namespace="org.eclipse.cdt.ui"
+           properties="hasCProjects"
+           type="org.eclipse.ui.IWorkingSet"/>
+  </extension>
+  <extension
+        point="org.eclipse.ui.exportWizards">
+     <category
+           id="org.eclipse.cdt.ui.exportWizardCategory"
+           name="%exportWizard.CDTCategory.name">
+     </category>
+     <wizard
+           category="org.eclipse.cdt.ui.exportWizardCategory"
+           class="org.eclipse.cdt.internal.ui.wizards.indexwizards.TeamProjectIndexExportWizard"
+           icon="icons/etool16/exportzip_wiz.gif"
+           id="org.eclipse.cdt.ui.teamSharedIndexWizard"
+           name="%teamProjectIndexExportWizard.name">
+        <selection
+              class="org.eclipse.core.resources.IProject">
+        </selection>
+        <description>
+           %teamProjectIndexExportWizard.description
+        </description>
+     </wizard>
+     <wizard
+           category="org.eclipse.cdt.ui.exportWizardCategory"
+           class="org.eclipse.cdt.internal.ui.wizards.settingswizards.ProjectSettingsExportWizard"
+           icon="icons/obj16/export_settings_wiz.gif"
+           id="org.eclipse.cdt.ui.projectSettingsExportWizard"
+           name="%projectSettingsIndexExportWizard.name">
+        <selection
+              class="org.eclipse.core.resources.IProject">
+        </selection>
+     </wizard>
+  </extension>
+   <extension
+            id="TemplateEngineWizard"
+            name="%Template.Engine.Wizard"
+            point="org.eclipse.cdt.ui.CDTWizard">
+         <wizard
+               class="org.eclipse.cdt.ui.internal.templateengine.wizard.TemplateCNewWizard"
+               name="%Template.Wizard">
+         </wizard>
+   </extension>
+
+   <extension
+         point="org.eclipse.ui.editors.markerUpdaters">
+      <updater
+            class="org.eclipse.cdt.internal.ui.editor.CDocumentProvider$ProblemMarkerUpdater"
+            id="org.eclipse.cdt.ui.problemMarkerUpdater"
+            markerType="org.eclipse.cdt.core.problem">
+      </updater>
+   </extension>
+   <extension
+         id="doccomment.multiline"
+         point="org.eclipse.cdt.ui.completionProposalComputer">
+      <completionProposalComputer
+            activate="true"
+            categoryId="org.eclipse.cdt.ui.parserProposalCategory"
+            class="org.eclipse.cdt.internal.ui.text.doctools.DocCommentMultilineProposalComputer">
+         <partition
+               type="__c_multiline_doc_comment">
+         </partition>
+      </completionProposalComputer>
+   </extension>
+   <extension
+         id="doccomment.singleline"
+         point="org.eclipse.cdt.ui.completionProposalComputer">
+      <completionProposalComputer
+            activate="true"
+            categoryId="org.eclipse.cdt.ui.parserProposalCategory"
+            class="org.eclipse.cdt.internal.ui.text.doctools.DocCommentSinglelineProposalComputer">
+         <partition
+               type="__c_singleline_doc_comment">
+         </partition>
+      </completionProposalComputer>
+   </extension>
+   <extension
+         point="org.eclipse.cdt.ui.CHelpProvider">
+      <provider
+            class="org.eclipse.cdt.internal.ui.help.CHelpProvider"
+            id="org.eclipse.cdt.ui.provider1">
+      </provider>
+   </extension>
+   
+   <extension
+         point="org.eclipse.cdt.ui.DocCommentOwner">
+      <owner
+            id="org.eclipse.cdt.ui.doxygen"
+            name="%Doxygen.name"
+            multiline="org.eclipse.cdt.ui.text.doctools.doxygen.DoxygenMultilineConfiguration"
+            singleline="org.eclipse.cdt.ui.text.doctools.doxygen.DoxygenSingleConfiguration">
+      </owner>
+   </extension>
+   <extension
+         point="org.eclipse.ltk.ui.refactoring.changePreviewViewers">
+         <changePreviewViewer
+            class="org.eclipse.cdt.internal.ui.refactoring.dialogs.CreateFileChangePreview"
+               id="org.eclipse.cdt.internal.ui.refactoring.createFileChangePreviewhangePreview">
+         <enablement>
+            <instanceof value="org.eclipse.cdt.internal.ui.refactoring.CreateFileChange"/>
+         </enablement>
+      </changePreviewViewer>
+         <changePreviewViewer
+            class="org.eclipse.cdt.internal.ui.refactoring.dialogs.CTextEditChangePreviewViewer"
+               id="org.eclipse.cdt.internal.ui.refactoring.CTextChangePreviewhangePreview">
+         <enablement>
+            <instanceof value="org.eclipse.cdt.ui.refactoring.CTextFileChange"/>
+         </enablement>
+      </changePreviewViewer>
+   </extension>
+   <extension
+         point="org.eclipse.ui.decorators">
+      <decorator
+            class="org.eclipse.cdt.internal.ui.viewsupport.IndexedFilesLabelProvider"
+            id="org.eclipse.cdt.ui.indexedFiles"
+            label="%indexedFilesDecorator.label"
+            lightweight="true"
+            state="false">
+         <enablement>
+            <or>
+               <objectClass name="org.eclipse.cdt.core.model.ITranslationUnit"/>
+               <objectClass name="org.eclipse.core.resources.IFile"/>
+            </or>
+         </enablement>
+      </decorator>
+   </extension>
+
+   <!-- Hyperlinking support -->
+   <extension
+         point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectorTargets">
+      <target
+            id="org.eclipse.cdt.ui.cCode"
+            name="%cEditorHyperlinkTarget">
+            <context type="org.eclipse.ui.texteditor.ITextEditor"/>
+      </target>
+   </extension>
+   <extension
+         point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectors">
+       <hyperlinkDetector
+            class="org.eclipse.cdt.internal.ui.editor.CElementHyperlinkDetector"
+            id="org.eclipse.cdt.ui.editor.CElementHyperlinkDetector"
+            name="%cElementHyperlinkDetector"
+            targetId="org.eclipse.cdt.ui.cCode">
+      </hyperlinkDetector>
+   </extension>
+   <extension
+         point="org.eclipse.ui.importWizards">
+      <category
+            id="org.eclipse.cdt.ui.importWizardCategory"
+            name="%importWizard.CDTCategory.name">
+      </category>
+      <wizard
+            category="org.eclipse.cdt.ui.importWizardCategory"
+            class="org.eclipse.cdt.internal.ui.wizards.settingswizards.ProjectSettingsImportWizard"
+            icon="icons/obj16/import_settings_wiz.gif"
+            id="org.eclipse.cdt.ui.projectSettingsImportWizard"
+            name="%projectSettingsIndexExportWizard.name">
+         <selection
+               class="org.eclipse.core.resources.IProject">
+         </selection>
+      </wizard>
+   </extension>
+   <extension
+         point="org.eclipse.cdt.ui.workingSetConfigurations">
+      <projectConfigurationFactory
+            class="org.eclipse.cdt.internal.ui.workingsets.IWorkingSetProjectConfigurationFactory$Registry$Default"
+            id="org.eclipse.cdt.ui.defaultWorkingSetProjectConfigFactory">
+         <projectNature
+               id="org.eclipse.cdt.core.cnature">
+         </projectNature>
+         <projectNature
+               id="org.eclipse.cdt.core.ccnature">
+         </projectNature>
+      </projectConfigurationFactory>
+   </extension>
+   <extension
+         point="org.eclipse.ui.menus">
+      <menuContribution
+            locationURI="popup:org.eclipse.ui.popup.any?after=additions">
+         <menu
+               label="%workingSetConfigs.context.label">
+            <menu
+                  id="org.eclipse.cdt.ui.wsContextMenu.activateMenu"
+                  label="%activateWorkingSetConfig.context.label">
+               <dynamic
+                     class="org.eclipse.cdt.internal.ui.workingsets.ActivateWorkingSetConfigsContribution"
+                     id="org.eclipse.cdt.ui.wsContextMenu.activateContrib">
+               </dynamic>
+            </menu>
+            <menu
+                  id="org.eclipse.cdt.ui.wsContextMenu.buildMenu"
+                  label="%buildWorkingSetConfig.context.label">
+               <dynamic
+                     class="org.eclipse.cdt.internal.ui.workingsets.BuildWorkingSetConfigsContribution"
+                     id="org.eclipse.cdt.ui.wsContextMenu.buildContrib">
+               </dynamic>
+            </menu>
+            <visibleWhen
+                  checkEnabled="false">
+               <with
+                     variable="activeMenuSelection">
+                  <count
+                        value="1">
+                  </count>
+                  <iterate>
+                     <adapt
+                           type="org.eclipse.ui.IWorkingSet">
+                        <test
+                              property="org.eclipse.cdt.ui.hasCProjects">
+                        </test>
+                     </adapt>
+                  </iterate>
+               </with>
+            </visibleWhen>
+         </menu>
+      </menuContribution>
+   </extension>
+   <extension
+         point="org.eclipse.ui.propertyPages">
+      <page
+            class="org.eclipse.cdt.internal.ui.workingsets.WorkingSetConfigurationsPage"
+            id="org.eclipse.ui.cdt.workingSets.configurations"
+            name="%workingSetConfigsPage">
+         <enabledWhen>
+                    <adapt type="org.eclipse.ui.IWorkingSet">
+                         <test property="org.eclipse.cdt.ui.hasCProjects"/>
+                    </adapt>         
+         </enabledWhen>
+      </page>
+   </extension>
+   <extension
+         point="org.eclipse.ltk.core.refactoring.refactoringContributions">
+      <contribution
+            class="org.eclipse.cdt.internal.ui.refactoring.extractconstant.ExtractConstantRefactoringContribution"
+            id="org.eclipse.cdt.ui.refactoring.extractconstant.ExtractConstantRefactoring">
+      </contribution>
+      <contribution
+            class="org.eclipse.cdt.internal.ui.refactoring.extractlocalvariable.ExtractLocalVariableRefactoringContribution"
+            id="org.eclipse.cdt.internal.ui.refactoring.extractlocalvariable.ExtractLocalVariableRefactoring">
+      </contribution>
+      <contribution
+            class="org.eclipse.cdt.internal.ui.refactoring.hidemethod.HideMethodRefactoringContribution"
+            id="org.eclipse.cdt.internal.ui.refactoring.hidemethod.HideMethodRefactoring">
+      </contribution>
+      <contribution
+            class="org.eclipse.cdt.internal.ui.refactoring.extractfunction.ExtractFunctionRefactoringContribution"
+            id="org.eclipse.cdt.internal.ui.refactoring.extractfunction.ExtractFunctionRefactoring">
+      </contribution>
+   </extension>
+       <extension point="org.eclipse.ltk.core.refactoring.renameParticipants">
+               <renameParticipant id="org.eclipse.jdt.junit.renameTypeParticipant"
+                       name="%renameParticipant.name"
+                       class="org.eclipse.cdt.internal.ui.refactoring.rename.RenameSourceFolder">
+                       <enablement>
+                               <or>
+                               <with variable="affectedNatures">
+                                       <iterate operator="or">
+                                               <equals value="org.eclipse.cdt.core.ccnature" />
+                                       </iterate>
+                               </with>
+                               <with variable="affectedNatures">
+                                       <iterate operator="or">
+                                               <equals value="org.eclipse.cdt.core.cnature" />
+                                       </iterate>
+                               </with>
+                               </or>
+                               <with variable="element">
+                                       <instanceof value="org.eclipse.core.resources.IFolder" />
+                               </with>
+                       </enablement>
+               </renameParticipant>
+       </extension>
+   <!-- Add support for undo / redo in the FileListControl -->
+   <extension
+         id="org.eclipse.cdt.ui.FileListControlHandler"
+         point="org.eclipse.ui.handlers">
+      <handler
+            class="org.eclipse.ui.internal.handlers.WidgetMethodHandler:undo"
+            commandId="org.eclipse.ui.edit.undo">
+         <activeWhen>      
+               <with variable="activeFocusControlId">
+                        <equals value="org.eclipse.cdt.ui.FileListControl"/>
+               </with>
+         </activeWhen>
+      </handler>
+      <handler
+            class="org.eclipse.ui.internal.handlers.WidgetMethodHandler:redo"
+            commandId="org.eclipse.ui.edit.redo">
+         <activeWhen>      
+               <with variable="activeFocusControlId">
+                        <equals value="org.eclipse.cdt.ui.FileListControl"/>
+               </with>
+         </activeWhen>
+      </handler>
+      <handler
+            class="org.eclipse.ui.internal.handlers.WidgetMethodHandler:delete"
+            commandId="org.eclipse.ui.edit.delete">
+         <activeWhen>      
+               <with variable="activeFocusControlId">
+                        <equals value="org.eclipse.cdt.ui.FileListControl"/>
+               </with>
+         </activeWhen>
+      </handler>
+   </extension>
+   <extension
+         point="org.eclipse.cdt.core.templateProcessTypes">
+            <processType
+            name="OpenFiles"
+            processRunner="org.eclipse.cdt.ui.templateengine.processes.OpenFiles">
+         <simple
+               name="projectName">
+         </simple>
+         <complexArray
+               name="files">
+            <baseType>
+               <simple
+                     name="target">
+               </simple>
+            </baseType>
+         </complexArray>
+      </processType>
+   </extension>
+       <extension point="org.eclipse.ui.decorators">
+               <decorator adaptable="true"
+                       class="org.eclipse.cdt.internal.ui.viewsupport.ExcludedFileDecorator"
+                       id="org.eclipse.cdt.managedbuilder.ui.excludedFile" label="%excluded-file.name"
+                       lightweight="true" state="true">
+                       <enablement>
+                               <objectClass name="org.eclipse.core.resources.IFile" />
+                       </enablement>
+               </decorator>
+       </extension>
+ <extension
+       point="org.eclipse.ui.commands">
+    <command
+          id="org.eclipse.cdt.ui.deleteConfigsCommand"
+          name="%deleteConfigsCommand.name">
+    </command>
+    <command
+          id="org.eclipse.cdt.ui.excludeCommand"
+          name="%excludeCommand.name">
+    </command>
+ </extension>
+ <extension
+       point="org.eclipse.ui.handlers">
+    <handler
+          class="org.eclipse.cdt.internal.ui.actions.DeleteResConfigsHandler"
+          commandId="org.eclipse.cdt.ui.deleteConfigsCommand">
+    </handler>
+    <handler
+          class="org.eclipse.cdt.internal.ui.actions.ExcludeFromBuildHandler"
+          commandId="org.eclipse.cdt.ui.excludeCommand">
+    </handler>
+ </extension>
+ <extension
+       point="org.eclipse.ui.menus">
+    <menuContribution
+          locationURI="popup:org.eclipse.ui.popup.any?after=buildGroup">
+        <menu
+             id="org.eclipse.cdt.ui.buildConfigContributionM"
+             label="%ResourceConfigurations.menu">
+            <visibleWhen
+                  checkEnabled="false">
+              <with variable="activeMenuSelection">
+                  <iterate operator="and" ifEmpty="false">
+                      <adapt type="org.eclipse.core.resources.IResource">
+                          <test
+                                property="org.eclipse.core.resources.projectNature"
+                                value="org.eclipse.cdt.core.cnature"/>
+                      </adapt>
+                      <or>
+                          <adapt type="org.eclipse.core.resources.IFolder"/>
+                          <adapt type="org.eclipse.core.resources.IFile">
+                              <or>
+                                  <test
+                                        property="org.eclipse.core.resources.contentTypeId"
+                                        value="org.eclipse.cdt.core.cSource"/>
+                                  <test
+                                        property="org.eclipse.core.resources.contentTypeId"
+                                        value="org.eclipse.cdt.core.cxxSource"/>
+                                  <test
+                                        property="org.eclipse.core.resources.contentTypeId"
+                                        value="org.eclipse.cdt.core.asmSource"/>
+                              </or>
+                          </adapt>
+                      </or>
+                  </iterate>
+              </with>
+            </visibleWhen>
+        </menu>
+    </menuContribution>
+    <menuContribution
+          locationURI="popup:org.eclipse.ui.popup.any?after=additions">
+       <menu
+             id="org.eclipse.cdt.ui.buildConfigContributionM"
+             label="%ResourceConfigurations.menu">
+            <visibleWhen
+                  checkEnabled="false">
+                         <with variable="activeMenuEditorInput">
+                               <iterate ifEmpty="false">
+                           <adapt type="org.eclipse.core.resources.IFile">
+                                   <test
+                                         property="org.eclipse.core.resources.projectNature"
+                                         value="org.eclipse.cdt.core.cnature"/>
+                           </adapt>
+                               </iterate>
+                         </with>
+            </visibleWhen>
+       </menu>
+    </menuContribution>
+    <menuContribution
+          locationURI="popup:org.eclipse.cdt.ui.buildConfigContributionM">
+       <command
+             commandId="org.eclipse.cdt.ui.excludeCommand"
+             id="org.eclipse.cdt.ui.excludeCommand.menu"
+             label="%ExcludeAction.label"
+             style="push">
+       </command>
+       <command
+             commandId="org.eclipse.cdt.ui.deleteConfigsCommand"
+             id="org.eclipse.cdt.ui.deleteConfigsCommand.menu"
+             label="%DeleteRcConfigAction.label"
+             style="push">
+       </command>
+    </menuContribution>
+ </extension>
+ <extension
+       point="org.eclipse.ui.console.consoleFactories">
+    <consoleFactory
+          class="org.eclipse.cdt.internal.ui.buildconsole.BuildConsoleFactory"
+          label="%BuildConsole.name">
+    </consoleFactory>
+ </extension>
+ <extension
+       point="org.eclipse.ui.preferenceTransfer">
+    <transfer
+          id="org.eclipse.cdt.ui.transfer.editor.appearance"
+          name="%transfer.EditorAppearance.name">
+       <mapping scope="instance">
+          <entry node="org.eclipse.cdt.ui">
+            <key name="c_multi_line_comment" match="prefix"/>
+            <key name="c_single_line_comment" match="prefix"/>
+            <key name="c_keyword" match="prefix"/>
+            <key name="c_type" match="prefix"/>
+            <key name="c_string" match="prefix"/>
+            <key name="c_operators" match="prefix"/>
+            <key name="c_braces" match="prefix"/>
+            <key name="c_numbers" match="prefix"/>
+            <key name="c_default" match="prefix"/>
+            <key name="pp_directive" match="prefix"/>
+            <key name="pp_default" match="prefix"/>
+            <key name="pp_header" match="prefix"/>
+            <key name="asm_directive" match="prefix"/>
+            <key name="asm_label" match="prefix"/>
+            <key name="c_comment_task_tag" match="prefix"/>
+            <key name="semanticHighlighting." match="prefix"/>
+            <key name="org.eclipse.cdt.internal.ui.text.doctools.doxygen." match="prefix"/>
+            <key name="handleTemporaryProblems"/>
+            <key name="matchingBracketsColor"/>
+            <key name="matchingBrackets"/>
+            <key name="inactiveCodeColor"/>
+            <key name="inactiveCodeEnable"/>
+            <key name="content_assist_proposals_background"/>
+            <key name="content_assist_proposals_foreground"/>
+            <key name="content_assist_parameters_background"/>
+            <key name="content_assist_parameters_foreground"/>
+            <key name="sourceHoverBackgroundColor"/>
+            <key name="sourceHoverBackgroundColor.SystemDefault"/>     
+            <key name="org.eclipse.cdt.ui.editors.textfont"/>
+            <key name="org.eclipse.cdt.ui.editor.showSegments"/>
+            <key name="CEditor.ShowTemporaryProblem"/>
+            <key name="org.eclipse.cdt.ui.outline." match="prefix"/>
+            <key name="editor_folding_" match="prefix"/>
+            <key name="org.eclipse.cdt.quickassist.lightbulb"/>
+          </entry>
+          <entry node="org.eclipse.cdt.core/doctool">
+            <key name="workspace.default"/>
+          </entry>
+          <entry node="org.eclipse.ui.editors">
+            <key name="indexResultIndicationColor"/>
+            <key name="indexResultIndication"/>
+            <key name="indexResultIndicationInVerticalRuler"/>
+            <key name="indexResultIndicationInOverviewRuler"/>
+            <key name="isIndexResultInNextPrevDropdownToolbarAction"/>
+            <key name="isIndexResultGoToNextNavigationTarget"/>
+            <key name="isIndexResultGoToPreviousNavigationTarget"/>
+            <key name="org.eclipse.cdt.ui." match="prefix"/>
+          </entry>
+       </mapping>
+       <description>
+          %transfer.EditorAppearance.description
+       </description>
+    </transfer>
+    <transfer
+          id="org.eclipse.cdt.ui.transfer.editor.behavior"
+          name="%transfer.EditorBehavior.name">
+       <mapping scope="instance">
+          <entry node="org.eclipse.cdt.ui">
+            <key name="org.eclipse.cdt.ui.editor.UseStructuralMode"/>
+            <key name="subWordNavigation"/>
+            <key name="closeStrings"/>
+            <key name="wrapStrings"/>
+            <key name="escapeStrings"/>
+            <key name="closeBrackets"/>
+            <key name="closeAngularBrackets"/>
+            <key name="closeBraces"/>
+            <key name="smartPaste"/>
+            <key name="autoIndent"/>
+            <key name="smart_tab"/>
+            <key name="hoverModifiers"/>
+            <key name="hoverModifierMasks"/>
+            <key name="org.eclipse.cdt.ui.BestMatchHover"/>
+            <key name="org.eclipse.cdt.ui.text.templates.format"/>
+            <key name="content_assist_disabled_computers"/>
+            <key name="content_assist_category_order"/>
+            <key name="ensureNewlineAtEOF"/>
+            <key name="removeTrailingWhitespace"/>
+            <key name="removeTrailingWhitespaceEditedLines"/>
+            <key name="Refactoring.savealleditors"/>
+            <key name="Refactor.lightweight"/>
+            <key name="spelling_" match="prefix"/>
+            <key name="org.eclipse.cdt.ui.add_comments"/>
+            <key name="codetemplates.includeGuardGenerationScheme"/>
+            <key name="markOccurrences"/>
+            <key name="stickyOccurrences"/>
+            <key name="markOverloadedOperatorsOccurrences"/>
+            <key name="scalability." match="prefix"/>
+          </entry>
+       </mapping>
+       <description>
+          %transfer.EditorBehavior.description 
+       </description>
+    </transfer>
+
+ </extension>
+ <extension
+       point="org.eclipse.cdt.ui.RefreshExclusionContributor">
+    <exclusionContributor
+          class="org.eclipse.cdt.internal.ui.resources.ResourceExclusionContributor"
+          id="org.eclipse.cdt.ui.ResourceExclusionContributor"
+          name="%RefreshExclusionContributor.name">
+    </exclusionContributor>
+ </extension>
+
+</plugin>
diff --git a/org.eclipse.cdt.ui/schema/CDTWizard.exsd b/org.eclipse.cdt.ui/schema/CDTWizard.exsd
new file mode 100644 (file)
index 0000000..3445900
--- /dev/null
@@ -0,0 +1,122 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.ui">
+<annotation>
+      <appInfo>
+         <meta.schema plugin="org.eclipse.cdt.ui" id="CDTWizard" name="CDTWizard"/>
+      </appInfo>
+      <documentation>
+         [Enter description of this extension point.]
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <complexType>
+         <sequence>
+            <element ref="wizard" minOccurs="1" maxOccurs="unbounded"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="wizard">
+      <complexType>
+         <attribute name="class" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="java" basedOn="org.eclipse.cdt.ui.wizards.CNewWizard"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+         <attribute name="parent" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="java"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="since"/>
+      </appInfo>
+      <documentation>
+         [Enter the first release in which this extension point appears.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="examples"/>
+      </appInfo>
+      <documentation>
+         [Enter extension point usage example here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="apiInfo"/>
+      </appInfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="implementation"/>
+      </appInfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="copyright"/>
+      </appInfo>
+      <documentation>
+         
+      </documentation>
+   </annotation>
+
+</schema>
diff --git a/org.eclipse.cdt.ui/schema/CHelpProvider.exsd b/org.eclipse.cdt.ui/schema/CHelpProvider.exsd
new file mode 100644 (file)
index 0000000..af30542
--- /dev/null
@@ -0,0 +1,109 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.ui">
+<annotation>
+      <appInfo>
+         <meta.schema plugin="org.eclipse.cdt.ui" id="CHelpProvider" name="C Help Provider"/>
+      </appInfo>
+      <documentation>
+         [Enter description of this extension point.]
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <complexType>
+         <sequence minOccurs="1" maxOccurs="unbounded">
+            <element ref="provider"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="provider">
+      <complexType>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="java"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="since"/>
+      </appInfo>
+      <documentation>
+         [Enter the first release in which this extension point appears.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="examples"/>
+      </appInfo>
+      <documentation>
+         [Enter extension point usage example here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="apiInfo"/>
+      </appInfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="implementation"/>
+      </appInfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="copyright"/>
+      </appInfo>
+      <documentation>
+         
+      </documentation>
+   </annotation>
+
+</schema>
diff --git a/org.eclipse.cdt.ui/schema/ConfigManager.exsd b/org.eclipse.cdt.ui/schema/ConfigManager.exsd
new file mode 100644 (file)
index 0000000..228a588
--- /dev/null
@@ -0,0 +1,119 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.ui">
+<annotation>
+      <appInfo>
+         <meta.schema plugin="org.eclipse.cdt.ui" id="ConfigManager" name="ConfigManager"/>
+      </appInfo>
+      <documentation>
+         In the new CDT 4.0 project model, you should be able to override the dialog
+that gets displayed when clicking the manage button on any of the C/C++
+project property pages,
+
+
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <complexType>
+         <sequence>
+            <element ref="manager" minOccurs="1" maxOccurs="unbounded"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="manager">
+      <complexType>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  Class which implements IConfigManager interface
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="java" basedOn="org.eclipse.cdt.ui.newui.IConfigManager"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="since"/>
+      </appInfo>
+      <documentation>
+         CDT 4.0
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="examples"/>
+      </appInfo>
+      <documentation>
+         [Enter extension point usage example here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="apiInfo"/>
+      </appInfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="implementation"/>
+      </appInfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="copyright"/>
+      </appInfo>
+      <documentation>
+         /**********************************************************************
+ * Copyright (c) 2007 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ **********************************************************************/
+      </documentation>
+   </annotation>
+
+</schema>
diff --git a/org.eclipse.cdt.ui/schema/DocCommentOwner.exsd b/org.eclipse.cdt.ui/schema/DocCommentOwner.exsd
new file mode 100644 (file)
index 0000000..65ccf71
--- /dev/null
@@ -0,0 +1,166 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.ui">
+<annotation>
+      <appInfo>
+         <meta.schema plugin="org.eclipse.cdt.ui" id="DocCommentOwner" name="DocCommentOwner"/>
+      </appInfo>
+      <documentation>
+         This extension point allows contribution of document comment detection, presentation and editing behaviours to the CDT editor.&lt;p&gt;
+
+Where C and C++ define single and multiline comments, there is no corresponding language level definition of distinguished comments recognized by documentation tools. A list of these is available here: &lt;a href=&quot;http://en.wikipedia.org/wiki/Comparison_of_documentation_generators&quot;&gt;Wikipedia Comparison of Documentation Generators&lt;/a&gt;&lt;p&gt;
+
+The customization for single and multi-line comments is handled by two contributed implementations of the same interface &lt;ul&gt;&lt;li&gt;&lt;code&gt;org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration&lt;/code&gt;&lt;/ul&gt;
+The javadoc for this interface describes the individual editor features that can be contributed.&lt;p&gt;
+
+A level of understanding of the eclipse and CDT editor infrastructure is needed in order to contribute to this extension point. A good starting point is to look at the GenericDocTag classes in the package - see the API Information section below.
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <complexType>
+         <choice>
+            <element ref="owner"/>
+         </choice>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="owner">
+      <complexType>
+         <attribute name="id" type="string" use="required">
+            <annotation>
+               <documentation>
+                  a globally unique ID representing this owner.
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string" use="required">
+            <annotation>
+               <documentation>
+                  a human readable name for the CDT UI
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+         <attribute name="multiline" type="string" use="required">
+            <annotation>
+               <documentation>
+                  The comment viewer configuration that should be used for detection, presentation and editing of C/C++ multiline comments
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="java" basedOn=":org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+         <attribute name="singleline" type="string" use="required">
+            <annotation>
+               <documentation>
+                  The comment viewer configuration that should be used for detection, presentation and editing of C/C++ singleline comments
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="java" basedOn=":org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="since"/>
+      </appInfo>
+      <documentation>
+         5.0
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="examples"/>
+      </appInfo>
+      <documentation>
+         &lt;pre&gt;
+&lt;extension
+    point=&quot;org.eclipse.cdt.ui.DocCommentOwner&quot;&gt;
+    &lt;owner
+        id=&quot;org.eclipse.cdt.ui.doxygen&quot;
+        name=&quot;Doxygen&quot;
+        multiline=&quot;org.eclipse.cdt.ui.text.doctools.doxygen.DoxygenMultilineConfiguration&quot;
+        singleline=&quot;org.eclipse.cdt.ui.text.doctools.doxygen.DoxygenSingleConfiguration&quot;&gt;
+    &lt;/owner&gt;
+&lt;/extension&gt;
+&lt;/pre&gt;
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="apiInfo"/>
+      </appInfo>
+      <documentation>
+         &lt;br&gt;
+The javadoc is considered the primary source of information for plug-in implementors. Only a light outline is given here&lt;p&gt;
+Key interfaces are:
+&lt;ul&gt;
+&lt;li&gt;org.eclipse.cdt.ui.text.doctools.IDocCommentOwner
+&lt;li&gt;org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration
+&lt;li&gt;org.eclipse.cdt.ui.text.doctools.IDocCommentOwnershipListener
+&lt;/ul&gt;
+
+Key implementations are:
+&lt;ul&gt;
+&lt;li&gt;the implementations in package org.eclipse.cdt.ui.text.doctools.generic
+&lt;/ul&gt;
+
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="implementation"/>
+      </appInfo>
+      <documentation>
+         An abstract implementation of some key interfaces is given in the package &lt;code&gt;org.eclipse.cdt.ui.text.doctools.generic&lt;/code&gt;
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="copyright"/>
+      </appInfo>
+      <documentation>
+         Copyright (c) 2008 Symbian Software Systems and others.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Eclipse Public License v1.0
+which accompanies this distribution, and is available at
+&lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
+      </documentation>
+   </annotation>
+
+</schema>
diff --git a/org.eclipse.cdt.ui/schema/HelpInfo.exsd b/org.eclipse.cdt.ui/schema/HelpInfo.exsd
new file mode 100644 (file)
index 0000000..65d08b3
--- /dev/null
@@ -0,0 +1,127 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.ui">
+<annotation>
+      <appInfo>
+         <meta.schema plugin="org.eclipse.cdt.ui" id="HelpInfo" name="Allows contributing the map files to the map-file-based CDT CHelpProvider."/>
+      </appInfo>
+      <documentation>
+         Allows contributing the map files to 
+the map-file-based CDT CHelpProvider.
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <complexType>
+         <sequence>
+            <element ref="helpInfo" minOccurs="1" maxOccurs="unbounded"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="helpInfo">
+      <annotation>
+         <documentation>
+            Allows defining map-file path relative to the plugin directory.
+         </documentation>
+      </annotation>
+      <complexType>
+         <attribute name="file" type="string" use="required">
+            <annotation>
+               <documentation>
+                  Contains map-file path relative to the plugin directory.
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="resource"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+         <attribute name="format" type="string">
+            <annotation>
+               <documentation>
+                  May contain ID of map file format.
+For now, there&apos;s only one (default) help map format.
+
+               </documentation>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="since"/>
+      </appInfo>
+      <documentation>
+         CDT 4.0.2
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="examples"/>
+      </appInfo>
+      <documentation>
+         &lt;extension
+  point=&quot;org.eclipse.cdt.ui.HelpInfo&quot;
+  id=&quot;org.eclipse.cdt.ui.help.cpp&quot;
+  name=&quot;C++ Help&quot;&gt;
+  &lt;helpInfo file=&quot;data1.xml&quot;/&gt;
+  &lt;helpInfo file=&quot;data2.xml&quot;/&gt;
+  &lt;helpInfo file=&quot;data3.xml&quot;/&gt;
+&lt;/extension&gt;
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="apiInfo"/>
+      </appInfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="implementation"/>
+      </appInfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="copyright"/>
+      </appInfo>
+      <documentation>
+         
+      </documentation>
+   </annotation>
+
+</schema>
diff --git a/org.eclipse.cdt.ui/schema/IndexerPage.exsd b/org.eclipse.cdt.ui/schema/IndexerPage.exsd
new file mode 100644 (file)
index 0000000..376bc4e
--- /dev/null
@@ -0,0 +1,123 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.ui">
+<annotation>
+      <appInfo>
+         <meta.schema plugin="org.eclipse.cdt.ui" id="IndexerPage" name="Indexer Page"/>
+      </appInfo>
+      <documentation>
+         [Enter description of this extension point.]
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <complexType>
+         <sequence>
+            <element ref="indexerUI" minOccurs="1" maxOccurs="unbounded"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="indexerUI">
+      <complexType>
+         <attribute name="id" type="string" use="required">
+            <annotation>
+               <documentation>
+                  a unique id for this indexer page
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string" use="required">
+            <annotation>
+               <documentation>
+                  a UI name for this page to be used in the UI
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="indexerID" type="string" use="required">
+            <annotation>
+               <documentation>
+                  the unique id of the indexer that this UI is associated with
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  the class that implements &lt;code&gt;org.eclipse.cdt.ui.index2.AbstractIndexerPage&lt;/code&gt;
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="java" basedOn="org.eclipse.cdt.ui.dialogs.AbstractIndexerPage"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="since"/>
+      </appInfo>
+      <documentation>
+         [Enter the first release in which this extension point appears.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="examples"/>
+      </appInfo>
+      <documentation>
+         [Enter extension point usage example here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="apiInfo"/>
+      </appInfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="implementation"/>
+      </appInfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="copyright"/>
+      </appInfo>
+      <documentation>
+         
+      </documentation>
+   </annotation>
+
+</schema>
diff --git a/org.eclipse.cdt.ui/schema/PathContainerPage.exsd b/org.eclipse.cdt.ui/schema/PathContainerPage.exsd
new file mode 100644 (file)
index 0000000..21980f4
--- /dev/null
@@ -0,0 +1,123 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.ui" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appInfo>
+         <meta.schema plugin="org.eclipse.cdt.ui" id="PathContainerPage" name="Path Container Page"/>
+      </appInfo>
+      <documentation>
+         [Enter description of this extension point.]
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appInfo>
+            <meta.element deprecated="true" />
+         </appInfo>
+      </annotation>
+      <complexType>
+         <sequence>
+            <element ref="PathContainerPage"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="PathContainerPage">
+      <complexType>
+         <attribute name="id" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="java"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="icon" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="resource"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="since"/>
+      </appInfo>
+      <documentation>
+         [Enter the first release in which this extension point appears.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="examples"/>
+      </appInfo>
+      <documentation>
+         [Enter extension point usage example here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="apiInfo"/>
+      </appInfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="implementation"/>
+      </appInfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+
+</schema>
diff --git a/org.eclipse.cdt.ui/schema/ProposalFilter.exsd b/org.eclipse.cdt.ui/schema/ProposalFilter.exsd
new file mode 100644 (file)
index 0000000..9b650aa
--- /dev/null
@@ -0,0 +1,135 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.ui" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appinfo>
+         <meta.schema plugin="org.eclipse.cdt.ui" id="ProposalFilter" name="Completion Proposal Filter"/>
+      </appinfo>
+      <documentation>
+         When the user requests code completion for an identifier prefix then proposals are gathered from a variety of sources. It is quite common that several proposals for the same completion are gathered. After gathering it is therefore necessary to filter proposals and present them in an optimal ordering to the user.
+
+The notion of what is &quot;optimal&quot; may vary from one application to another. This extension point allows the contribution of completion filters which best suit the needs of the user in any given situation. 
+
+The decision about which filter will actually be used remains with the user who can select his preference from a list of all contributed filters (menu Window - Preferences - C/C++ - Editor - Content Assist).
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <complexType>
+         <sequence>
+            <element ref="ProposalFilter"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute translatable="true"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="ProposalFilter">
+      <complexType>
+         <attribute name="id" type="string" use="required">
+            <annotation>
+               <documentation>
+                  The required unique id of the ProposalFilter
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string" use="required">
+            <annotation>
+               <documentation>
+                  The required name of the ProposalFilter. This name will appear in the preferences combo and should therefore be informative for the user.
+               </documentation>
+               <appinfo>
+                  <meta.attribute translatable="true"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  The required fully qualified name of the implementing class which must implement org.eclipse.cdt.ui.text.contentassist.IProposalFilter
+               </documentation>
+               <appinfo>
+                  <meta.attribute kind="java" basedOn="org.eclipse.cdt.ui.text.contentassist.IProposalFilter"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="since"/>
+      </appinfo>
+      <documentation>
+         CDT 3.1
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="examples"/>
+      </appinfo>
+      <documentation>
+         See the default implementation in org.eclipse.cdt.internal.ui.text.contentassist.DefaultProposalFilter as an example.
+      </documentation>
+   </annotation>
+
+
+   <annotation>
+      <appinfo>
+         <meta.section type="apiinfo"/>
+      </appinfo>
+      <documentation>
+         ProposalFilters must implement interface &lt;code&gt;org.eclipse.cdt.ui.text.contentassist.IProposalFilter&lt;code&gt;.
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="implementation"/>
+      </appinfo>
+      <documentation>
+         The default implementation in org.eclipse.cdt.internal.ui.text.contentassist.DefaultProposalFilter is the default filtering method which is used as long as the user preference is not changed.
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="copyright"/>
+      </appinfo>
+      <documentation>
+         Copyright (c) 2006 Norbert Ploett and others.
+
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Eclipse Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/epl-v10.html
+
+Contributors:
+Norbert Ploett (Siemens) - Initial Contribution
+      </documentation>
+   </annotation>
+
+</schema>
diff --git a/org.eclipse.cdt.ui/schema/RefreshExclusionContributor.exsd b/org.eclipse.cdt.ui/schema/RefreshExclusionContributor.exsd
new file mode 100644 (file)
index 0000000..77d5fb2
--- /dev/null
@@ -0,0 +1,140 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.ui" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appInfo>
+         <meta.schema plugin="org.eclipse.cdt.ui" id="RefreshExclusionContributor" name="Refresh Exclusion Contributor"/>
+      </appInfo>
+      <documentation>
+         This extension point allows for contribution of new types of refresh exclusions to CDT&apos;s refresh exclusion system.  A refresh exclusion is essentially some arbitrary rule that can be tested against a given resource and evaluates to true or false.  The exclusion returns true if it should be applied (i.e. the tested resource should be excluded).  Rules can be nested, so it is possible to have exclusions to exclusions.
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appInfo>
+            <meta.element />
+         </appInfo>
+      </annotation>
+      <complexType>
+         <sequence minOccurs="1" maxOccurs="unbounded">
+            <element ref="exclusionContributor"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="exclusionContributor">
+      <annotation>
+         <documentation>
+            A contribution of a new type of refresh exclusion.
+         </documentation>
+      </annotation>
+      <complexType>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  Java class corresponding to the contribution, responsible both for acting as a factory that creates concrete instances of the exclusion, as well as providing a UI for modifying properties specific to the exclusion.
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="java" basedOn="org.eclipse.cdt.ui.resources.RefreshExclusionContribution:"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string" use="required">
+            <annotation>
+               <documentation>
+                  A unique string that identifies this contribution.
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string" use="required">
+            <annotation>
+               <documentation>
+                  The human readable name used to refer to this exclusion type in the UI.
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="isTest" type="boolean">
+            <annotation>
+               <documentation>
+                  Attribute indicating this contribution is for testing purposes and hence the given contributor should not be considered for contributions to the UI.
+               </documentation>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="since"/>
+      </appInfo>
+      <documentation>
+         5.3
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="examples"/>
+      </appInfo>
+      <documentation>
+         [Enter extension point usage example here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="apiinfo"/>
+      </appInfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="implementation"/>
+      </appInfo>
+      <documentation>
+         There is a supplied implementation for Resource Exclusions.
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="copyright"/>
+      </appInfo>
+      <documentation>
+         Copyright (c) 2011 IBM Corporation and others.&lt;br&gt;
+All rights reserved. This program and the accompanying materials are made
+available under the terms of the Eclipse Public License v1.0 which accompanies
+this distribution, and is available at &lt;a 
+href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
+      </documentation>
+   </annotation>
+
+</schema>
diff --git a/org.eclipse.cdt.ui/schema/cPropertyTab.exsd b/org.eclipse.cdt.ui/schema/cPropertyTab.exsd
new file mode 100644 (file)
index 0000000..5dcd20a
--- /dev/null
@@ -0,0 +1,224 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.ui" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appInfo>
+         <meta.schema plugin="org.eclipse.cdt.ui" id="cPropertyTab" name="cPropertyTab"/>
+      </appInfo>
+      <documentation>
+         Implementation of property/preference UI element.
+
+There&apos;re 2 ways to display property/preference data:
+either on pages with tabs, or on simple pages.
+
+In first case, each cPropertyTab extending class
+represents single tab in tabfolder. 
+In second case, cPropertyTab extending class 
+represents whole page contents (except header
+elements which are common for all pages).
+
+Note that cPropertyTab extending class (&quot;tabs&quot; below) do not
+distinguish these 2 cases, moreover, they may be shown both 
+in multi-tab and single-tab mode. It&apos;s up to page to select 
+displaying mode.
+
+In multi-tab page, tabs are displayed in order defined by 
+their weights.
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appInfo>
+            <meta.element />
+         </appInfo>
+      </annotation>
+      <complexType>
+         <sequence>
+            <element ref="tab" minOccurs="1" maxOccurs="unbounded"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="tab">
+      <complexType>
+         <attribute name="icon" type="string">
+            <annotation>
+               <documentation>
+                  Icon to be displayed for corresponding tab in tabfolder.
+Ignored for single-tab pages
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="resource"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  Class implementing org.eclipse.cdt.ui.newui.ICPropertyTab
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="java" basedOn=":org.eclipse.cdt.ui.newui.ICPropertyTab"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string" use="required">
+            <annotation>
+               <documentation>
+                  Name of tab in tabfolder. 
+Ignored for single-tab pages.
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="parent" type="string" use="required">
+            <annotation>
+               <documentation>
+                  Class name for container page.
+Usually pages are to be derived from 
+org.eclipse.cdt.ui.newui.AbstractPage,
+but it is not obligatory.
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="tooltip" type="string">
+            <annotation>
+               <documentation>
+                  Text of tooltip shown over the tab.
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="weight" type="string">
+            <annotation>
+               <documentation>
+                  Abstract value to be used for sorting tabs inside of tab folder.
+Ignored for single-tab page.
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="helpId" type="string">
+            <annotation>
+               <documentation>
+                  Help context Id for given tab.
+               </documentation>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="since"/>
+      </appInfo>
+      <documentation>
+         4.0
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="examples"/>
+      </appInfo>
+      <documentation>
+         &lt;extension
+           point=&quot;org.eclipse.cdt.ui.cPropertyTab&quot;&gt;
+     &lt;tab
+           class=&quot;org.eclipse.cdt.managedbuilder.ui.newui.DiscoveryTab&quot;
+           icon=&quot;icons/elcl16/discovery.gif&quot;
+           name=&quot;Discovery options&quot;
+           weight=&quot;100&quot; 
+           parent=&quot;org.eclipse.cdt.ui.newui.Page_PathAndSymb&quot;/&gt;
+  &lt;/extension&gt;
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="apiInfo"/>
+      </appInfo>
+      <documentation>
+         Tabs must implement interface:
+org.eclipse.cdt.managedbuilder.ui.newproperties.ICPropertyTab
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="implementation"/>
+      </appInfo>
+      <documentation>
+         Implementors in org.eclipse.cdt.ui.newui:
+BinaryParsTab      
+CLocationOutputTab 
+CLocationSourceTab 
+CLocationTab       
+EnvironmentTab     
+ErrorParsTab       
+ExpIncludeTab      
+ExpLibraryPathTab  
+ExpLibraryTab      
+ExpSymbolTab       
+ICPropertyTab      
+IncludeTab         
+LanguagesTab       
+LibraryPathTab     
+LibraryTab         
+RefsTab            
+SDKsTab            
+SymbolTab          
+
+Implementors in org.eclipse.cdt.managedbuilder.ui.newui:
+ArtifactTab            
+BuilderSettingsTab     
+BuildStepsTab          
+CBuildLocationOutputTab
+CPropertyVarsTab       
+DiscoveryTab           
+ToolChainEditTab       
+ToolSettingsTab
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="copyright"/>
+      </appInfo>
+      <documentation>
+         /*******************************************************************************
+ * Copyright (c) 2007 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+      </documentation>
+   </annotation>
+
+</schema>
diff --git a/org.eclipse.cdt.ui/schema/completionProposalComputer.exsd b/org.eclipse.cdt.ui/schema/completionProposalComputer.exsd
new file mode 100644 (file)
index 0000000..22fd335
--- /dev/null
@@ -0,0 +1,213 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.ui">
+<annotation>
+      <appInfo>
+         <meta.schema plugin="org.eclipse.cdt.ui" id="completionProposalComputer" name="Completion Proposal Computer"/>
+      </appInfo>
+      <documentation>
+         This extension point allows to contribute completion proposal computers to participate in the content assist process of the C/C++ editor.
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appInfo>
+            <meta.element labelAttribute="name"/>
+         </appInfo>
+      </annotation>
+      <complexType>
+         <choice>
+            <element ref="completionProposalComputer"/>
+            <element ref="proposalCategory"/>
+         </choice>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  The fully qualified identifier of the target extension point
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string" use="required">
+            <annotation>
+               <documentation>
+                  The identifier of the extension instance, unique within the declaring plug-in (the plug-in&apos;s identifier will be prepended to form a platform-wide unique id)
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  The optional name of the extension instance
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="completionProposalComputer">
+      <annotation>
+         <documentation>
+            A proposal computer contribution. If no partition types are specified, the computer is added to all partition types.
+         </documentation>
+      </annotation>
+      <complexType>
+         <sequence minOccurs="0" maxOccurs="6">
+            <element ref="partition"/>
+         </sequence>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  The name of the class that implements the contributed computer. The
+class must be public and implement
+&lt;samp&gt;org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer&lt;/samp&gt;
+and must have a public 0-argument constructor.
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="java"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+         <attribute name="activate" type="boolean" use="default" value="false">
+            <annotation>
+               <documentation>
+                  If the attribute is set to &quot;true&quot; it will force this plug-in to be loaded on content assist invocation.
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="categoryId" type="string" use="default" value="org.eclipse.cdt.ui.defaultProposalCategory">
+            <annotation>
+               <documentation>
+                  The id of a &lt;tt&gt;proposalCategory&lt;/tt&gt;
+               </documentation>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="partition">
+      <annotation>
+         <appInfo>
+            <meta.element labelAttribute="type"/>
+         </appInfo>
+      </annotation>
+      <complexType>
+         <attribute name="type" use="required">
+            <annotation>
+               <documentation>
+                  A C/C++ partition type for which the specified computer can provide completion proposals. See &lt;code&gt;IDocument.DEFAULT_CONTENT_TYPE&lt;/code&gt; and &lt;code&gt;ICPartitions&lt;/code&gt; for valid values.
+               </documentation>
+            </annotation>
+            <simpleType>
+               <restriction base="string">
+                  <enumeration value="__dftl_partition_content_type">
+                  </enumeration>
+                  <enumeration value="__c_multiline_comment">
+                  </enumeration>
+                  <enumeration value="__c_singleline_comment">
+                  </enumeration>
+                  <enumeration value="__c_string">
+                  </enumeration>
+                  <enumeration value="__c_character">
+                  </enumeration>
+                  <enumeration value="__c_preprocessor">
+                  </enumeration>
+                  <enumeration value="__c_multiline_doc_comment">
+                  </enumeration>
+                  <enumeration value="__c_singleline_doc_comment">
+                  </enumeration>
+               </restriction>
+            </simpleType>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="proposalCategory">
+      <annotation>
+         <documentation>
+            A proposal category contribution defines categories of proposals used to group them in the UI.
+         </documentation>
+      </annotation>
+      <complexType>
+         <attribute name="icon" type="string">
+            <annotation>
+               <documentation>
+                  The optional icon of the category, which can be displayed in the user preferences.
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="resource"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="since"/>
+      </appInfo>
+      <documentation>
+         4.0
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="examples"/>
+      </appInfo>
+      <documentation>
+         The following is an example of a completion proposal computer contribution:
+
+&lt;p&gt;
+&lt;pre&gt;
+ &lt;extension point=&quot;org.eclipse.cdt.ui.completionProposalComputer&quot;
+   id=&quot;textual_proposals&quot;
+   name=&quot;Text Proposals&quot;&gt;
+   &lt;proposalCategory icon=&quot;icons/wordcompletions.png&quot;/&gt;
+ &lt;/extension&gt;
+ &lt;extension point=&quot;org.eclipse.cdt.ui.completionProposalComputer&quot;
+   id=&quot;WordCompletionProposalComputer&quot;
+   name=&quot;Word Completion Proposal Computer&quot;&gt;
+   &lt;completionProposalComputer
+      class=&quot;org.eclipse.cdt.internal.ui.text.contentassist.HippieProposalComputer&quot;
+      categoryId=&quot;org.eclipse.ui.texteditor.textual_proposals&quot;&gt;
+      &lt;partition type=&quot;__c_multiline_comment&quot;/&gt;
+   &lt;/completionProposalComputer&gt;
+ &lt;/extension&gt;
+&lt;/pre&gt;
+&lt;/p&gt;
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="apiInfo"/>
+      </appInfo>
+      <documentation>
+         The contributed class must extend &lt;code&gt;org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer&lt;/code&gt;
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="implementation"/>
+      </appInfo>
+      <documentation>
+         see &lt;code&gt;org.eclipse.cdt.internal.ui.text.contentassist.HippieProposalComputer&lt;/code&gt; for an example.
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="copyright"/>
+      </appInfo>
+      <documentation>
+         Copyright (c) 2006, 2007 IBM Corporation and others.&lt;br&gt;
+All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
+      </documentation>
+   </annotation>
+
+</schema>
diff --git a/org.eclipse.cdt.ui/schema/foldingStructureProviders.exsd b/org.eclipse.cdt.ui/schema/foldingStructureProviders.exsd
new file mode 100644 (file)
index 0000000..32675c7
--- /dev/null
@@ -0,0 +1,142 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.ui">
+<annotation>
+      <appInfo>
+         <meta.schema plugin="org.eclipse.cdt.ui" id="foldingStructureProviders" name="C/C++ Folding Structure Provider"/>
+      </appInfo>
+      <documentation>
+         Contributions to this extension point define folding structures for the C/C++ editor. That is, they define the regions of a C/C++ source file that can be folded away. See &lt;code&gt;org.eclipse.jface.text.source.ProjectionViewer&lt;/code&gt; for reference.
+&lt;p&gt;
+Extensions may optionally contribute a preference block which will appear on the C/C++ editor preference page.
+&lt;/p&gt;
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <complexType>
+         <sequence>
+            <element ref="provider"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="provider">
+      <annotation>
+         <appInfo>
+            <meta.element labelAttribute="name"/>
+         </appInfo>
+      </annotation>
+      <complexType>
+         <attribute name="id" type="string" use="required">
+            <annotation>
+               <documentation>
+                  The unique identifier of this provider.
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  The name of this provider. If none is given, the id is used instead.
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  An implementation of org.eclipse.cdt.ui.text.folding.ICFoldingStructureProvider
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="java" basedOn="org.eclipse.cdt.ui.text.folding.ICFoldingStructureProvider"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+         <attribute name="preferencesClass" type="string">
+            <annotation>
+               <documentation>
+                  An implementation of org.eclipse.cdt.ui.text.folding.ICFoldingPreferenceBlock
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="java" basedOn="org.eclipse.cdt.ui.text.folding.ICFoldingPreferenceBlock"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="since"/>
+      </appInfo>
+      <documentation>
+         3.0
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="examples"/>
+      </appInfo>
+      <documentation>
+         See &lt;code&gt;org.eclipse.cdt.ui.text.folding.DefaultCFoldingStructureProvider&lt;/code&gt; for an example.
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="apiInfo"/>
+      </appInfo>
+      <documentation>
+         
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="implementation"/>
+      </appInfo>
+      <documentation>
+         &lt;code&gt;org.eclipse.cdt.ui.text.folding.DefaultCFoldingStructureProvider&lt;/code&gt; provides the default folding structure for the C/C++ editor.
+         &lt;code&gt;org.eclipse.cdt.internal.ui.text.folding.DefaultCFoldingPreferenceBlock&lt;/code&gt; provides the preference block for the default structure provider.
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="copyright"/>
+      </appInfo>
+      <documentation>
+         Copyright (c) 2001, 2006 IBM Corporation and others.&lt;br&gt;
+All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
+      </documentation>
+   </annotation>
+
+</schema>
diff --git a/org.eclipse.cdt.ui/schema/newCfgDialog.exsd b/org.eclipse.cdt.ui/schema/newCfgDialog.exsd
new file mode 100644 (file)
index 0000000..da63547
--- /dev/null
@@ -0,0 +1,143 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.ui">
+<annotation>
+      <appInfo>
+         <meta.schema plugin="org.eclipse.cdt.ui" id="newCfgDialog" name="newCfgDialog"/>
+      </appInfo>
+      <documentation>
+         Contributions to this extension point define specific dialog for new configuration creation. This dialog will be called from &quot;Manage configurations&quot; screen instead of standard (independent of managed build system) dialog. &lt;br&gt;
+Contributed extension is usually provided with whole managed build system (MBS), so new dialog may be able to handle some MBS-specific features.&lt;br&gt;
+To disinguish numerous dialogs for separate MBSs, mbs_id element should be the same as corresponding MBS Id.
+
+
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <complexType>
+         <sequence>
+            <element ref="dialog" minOccurs="1" maxOccurs="unbounded"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="dialog">
+      <complexType>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  class -  New configuration dialog class.&lt;br&gt; 
+Should implement org.eclipse.cdt.ui.newui.INewCfgDialog interface
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="java" basedOn="org.eclipse.cdt.ui.newui.INewCfgDialog"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+         <attribute name="title" type="string" use="required">
+            <annotation>
+               <documentation>
+                  title - initial title of New configuration dialog.
+
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="mbs_id" type="string" use="required">
+            <annotation>
+               <documentation>
+                  This element should contain ID of corresponding managed buld system (MBS).&lt;br&gt;
+Dialog will be displayed only if MBS Id for current project equals to mbs_id.
+               </documentation>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="since"/>
+      </appInfo>
+      <documentation>
+         4.0
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="examples"/>
+      </appInfo>
+      <documentation>
+           &lt;extension
+        point=&quot;org.eclipse.cdt.ui.newCfgDialog&quot;&gt;
+        &lt;dialog
+            class=&quot;org.eclipse.cdt.managedbuilder.ui.newui.NewCfgDialog&quot;
+            mbs_id=&quot;org.eclipse.cdt.managedbuilder.core.configurationDataProvider&quot;
+            title=&quot;MBS: create configuration&quot;/&gt;
+  &lt;/extension&gt;
+
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="apiInfo"/>
+      </appInfo>
+      <documentation>
+         &quot;class&quot; element should implement org.eclipse.cdt.ui.newui.INewCfgDialog interface
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="implementation"/>
+      </appInfo>
+      <documentation>
+         org.eclipse.cdt.managedbuilder.ui.newui.NewCfgDialog
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="copyright"/>
+      </appInfo>
+      <documentation>
+         /*******************************************************************************
+ * Copyright (c) 2007 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+      </documentation>
+   </annotation>
+
+</schema>
diff --git a/org.eclipse.cdt.ui/schema/quickAssistProcessors.exsd b/org.eclipse.cdt.ui/schema/quickAssistProcessors.exsd
new file mode 100644 (file)
index 0000000..d524350
--- /dev/null
@@ -0,0 +1,164 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.ui">
+<annotation>
+      <appInfo>
+         <meta.schema plugin="org.eclipse.cdt.ui" id="quickAssistProcessors" name="Quick Assist Processor"/>
+      </appInfo>
+      <documentation>
+         This extension point allows to add a Quick Assist processor to offer new Quick Assists in the C/C++ editor.
+This extension point supports the &lt;code&gt;enablement&lt;/code&gt; tag. Properties to test on are:
+&lt;dl&gt;
+&lt;li&gt;translationUnit: type ITranslationUnit; the translation unit the quick assist is applied on&lt;/li&gt;
+
+&lt;li&gt;projectNatures: type Collection; all project natures of the current project&lt;/li&gt;
+&lt;/dl&gt;
+      </documentation>
+   </annotation>
+
+   <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
+
+   <element name="extension">
+      <complexType>
+         <sequence>
+            <element ref="quickAssistProcessor" minOccurs="1" maxOccurs="unbounded"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  a fully qualified identifier of the target extension point
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  an optional identifier of the extension instance
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  an optional name of the extension instance
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="quickAssistProcessor">
+      <complexType>
+         <sequence>
+            <element ref="enablement" minOccurs="0" maxOccurs="1"/>
+         </sequence>
+         <attribute name="id" type="string" use="required">
+            <annotation>
+               <documentation>
+                  a unique identifier for the Quick Assist processor
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  a localized name of the Quick Assist processor
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+         <attribute name="class" type="string">
+            <annotation>
+               <documentation>
+                  the name of the class that implements this Quick Assist processor. The
+class must be public and implement
+&lt;samp&gt;org.eclipse.cdt.ui.text.IQuickAssistProcessor&lt;/samp&gt;
+with a public 0-argument constructor.
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="java" basedOn="org.eclipse.cdt.ui.text.IQuickAssistProcessor"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+         <attribute name="requiredSourceLevel" type="string">
+            <annotation>
+               <documentation>
+                  an optional attribute to specify the minimal source compliance this processor requires
+               </documentation>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="examples"/>
+      </appInfo>
+      <documentation>
+         The following is an example of a Quick Assist processor contribution:
+
+&lt;p&gt;
+&lt;pre&gt;
+ &lt;extension point=&quot;org.eclipse.cdt.ui.quickAssistProcessors&quot;&gt;
+  &lt;quickAssistProcessor
+   id=&quot;AdvancedQuickAssistProcessor&quot;
+   name=&quot;Advanced Quick Assist Processor&quot;
+   class=&quot;com.example.AdvancedQuickAssistProcessor&quot;&gt;
+  &lt;/quickAssistProcessor&gt;
+   &lt;enablement&gt;
+      &lt;with variable=&quot;projectNatures&quot;&gt;
+         &lt;iterate operator=&quot;or&quot;&gt;
+            &lt;equals value=&quot;org.eclipse.cdt.core.cnature&quot;/&gt;
+            &lt;equals value=&quot;org.eclipse.cdt.core.ccnature&quot;/&gt;
+         &lt;/iterate&gt;
+      &lt;/with&gt;
+   &lt;/enablement&gt;
+ &lt;/extension&gt;
+&lt;/pre&gt;
+&lt;/p&gt;
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="since"/>
+      </appInfo>
+      <documentation>
+         5.1
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="apiInfo"/>
+      </appInfo>
+      <documentation>
+         The contributed class must implement &lt;code&gt;org.eclipse.cdt.ui.text.IQuickAssistProcessor&lt;/code&gt;
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="implementation"/>
+      </appInfo>
+      <documentation>
+         
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="copyright"/>
+      </appInfo>
+      <documentation>
+         Copyright (c) 2001, 2008 IBM Corporation and others.&lt;br&gt;
+All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
+      </documentation>
+   </annotation>
+
+</schema>
diff --git a/org.eclipse.cdt.ui/schema/quickFixProcessors.exsd b/org.eclipse.cdt.ui/schema/quickFixProcessors.exsd
new file mode 100644 (file)
index 0000000..211b556
--- /dev/null
@@ -0,0 +1,182 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.ui">
+<annotation>
+      <appInfo>
+         <meta.schema plugin="org.eclipse.cdt.ui" id="quickFixProcessors" name="Quick Fix Processor"/>
+      </appInfo>
+      <documentation>
+         This extension point allows to add a Quick Fix processor to offer new Quick Fixes on C/C++ problems.
+&lt;p&gt;
+Extension can specify which problem marker types it can handle. It will only get problems of these types to process.
+&lt;/p&gt;
+&lt;p&gt;
+This extension point supports the &lt;code&gt;enablement&lt;/code&gt; tag. Properties to test on are:
+&lt;dl&gt;
+&lt;li&gt;translationUnit: type ITranslationUnit; the translation unit the quick assist is applied on&lt;/li&gt;
+
+&lt;li&gt;projectNatures: type Collection; all project natures of the current project&lt;/li&gt;
+&lt;/dl&gt;
+&lt;/p&gt;
+      </documentation>
+   </annotation>
+
+   <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
+
+   <element name="extension">
+      <complexType>
+         <sequence>
+            <element ref="quickFixProcessor" minOccurs="1" maxOccurs="unbounded"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  a fully qualified identifier of the target extension point
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  an optional identifier of the extension instance
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  an optional name of the extension instance
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="quickFixProcessor">
+      <complexType>
+         <sequence>
+            <element ref="enablement" minOccurs="0" maxOccurs="1"/>
+            <element ref="handledMarkerTypes" minOccurs="0" maxOccurs="unbounded"/>
+         </sequence>
+         <attribute name="id" type="string" use="required">
+            <annotation>
+               <documentation>
+                  a unique identifier for the Quick Fix processor
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  a localized name of the Quick Fix processor
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  the name of the class that implements this Quick Fix processor. The
+class must be public and implement
+&lt;samp&gt;org.eclipse.cdt.ui.text.IQuickFixProcessor&lt;/samp&gt;
+with a public 0-argument constructor.
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="java" basedOn="org.eclipse.cdt.ui.text.IQuickFixProcessor"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="handledMarkerTypes">
+      <annotation>
+         <documentation>
+            Specifies the marker types of the problems this quick fix processor can handle.
+If no handled marker type are specified, the processor will get problems of types org.eclipse.cdt.core.problem, org.eclipse.cdt.core.buildpath_problem and org.eclipse.cdt.core.task.
+         </documentation>
+      </annotation>
+      <complexType>
+         <sequence>
+            <element ref="markerType" minOccurs="1" maxOccurs="unbounded"/>
+         </sequence>
+      </complexType>
+   </element>
+
+   <element name="markerType">
+      <complexType>
+         <attribute name="id" type="string" use="required">
+            <annotation>
+               <documentation>
+                  the marker type id of the marker that can be handled by this processor
+               </documentation>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="since"/>
+      </appInfo>
+      <documentation>
+         4.1
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="examples"/>
+      </appInfo>
+      <documentation>
+         The following is an example of a Quick Fix processor contribution:
+
+&lt;p&gt;
+&lt;pre&gt;
+ &lt;extension point=&quot;org.eclipse.cdt.ui.quickFixProcessors&quot;&gt;
+  &lt;quickFixProcessor
+   id=&quot;AdvancedQuickFixProcessor&quot;
+   name=&quot;Advanced Quick Fix Processor&quot;
+   class=&quot;com.example.AdvancedQuickFixProcessor&quot;&gt;
+   &lt;handledMarkerTypes&gt;
+      &lt;markerType id=&quot;org.eclipse.myplugin.audits&quot;/&gt;
+   &lt;/handledMarkerTypes&gt;
+   &lt;enablement&gt;
+      &lt;with variable=&quot;projectNatures&quot;&gt;
+         &lt;iterate operator=&quot;or&quot;&gt;
+            &lt;equals value=&quot;org.eclipse.cdt.core.cnature&quot;/&gt;
+         &lt;/iterate&gt;
+      &lt;/with&gt;
+   &lt;/enablement&gt;
+  &lt;/quickFixProcessor&gt;
+ &lt;/extension&gt;
+&lt;/pre&gt;
+&lt;/p&gt;
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="apiInfo"/>
+      </appInfo>
+      <documentation>
+         The contributed class must implement &lt;code&gt;org.eclipse.cdt.ui.text.IQuickFixProcessor&lt;/code&gt;
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="copyright"/>
+      </appInfo>
+      <documentation>
+         Copyright (c) 2001, 2007 IBM Corporation and others.&lt;br&gt;
+All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
+      </documentation>
+   </annotation>
+
+</schema>
diff --git a/org.eclipse.cdt.ui/schema/textHovers.exsd b/org.eclipse.cdt.ui/schema/textHovers.exsd
new file mode 100644 (file)
index 0000000..2111801
--- /dev/null
@@ -0,0 +1,144 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.ui">
+<annotation>
+      <appInfo>
+         <meta.schema plugin="org.eclipse.cdt.ui" id="textHovers" name="C/C++ Editor Text Hovers"/>
+      </appInfo>
+      <documentation>
+         This extension point is used to plug-in text hovers in a C/C++ editor.
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <complexType>
+         <sequence>
+            <element ref="hover" minOccurs="0" maxOccurs="unbounded"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  a fully qualified identifier of the target extension point
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  an optional identifier of the extension instance
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  an optional name of the extension instance
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="hover">
+      <complexType>
+         <attribute name="id" type="string" use="required">
+            <annotation>
+               <documentation>
+                  the id, typically the same as the fully qualified class name.
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  the fully qualified class name implementing the interface &lt;code&gt;org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover&lt;/code&gt;.
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="java" basedOn="org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+         <attribute name="label" type="string">
+            <annotation>
+               <documentation>
+                  the translatable label for this hover.
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+         <attribute name="description" type="string">
+            <annotation>
+               <documentation>
+                  the translatable description for this hover.
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+         <attribute name="activate" type="boolean" use="default" value="false">
+            <annotation>
+               <documentation>
+                  if the attribute is set to &quot;true&quot; it will force this plug-in to be loaded on hover activation.
+               </documentation>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="examples"/>
+      </appInfo>
+      <documentation>
+         The following is an example of a hover definition:
+
+&lt;p&gt;
+&lt;pre&gt;
+ &lt;extension point=&quot;org.eclipse.cdt.ui.textHovers&quot;&gt;
+  &lt;hover
+    label=&quot;Debug Text Hover&quot;
+    perspective=&quot;org.eclipse.debug.ui.DebugPerspective&quot;
+    class=&quot;org.eclipse.cdt.debug.internal.ui.editors.DebugTextHover&quot;
+    id=&quot;org.eclipse.cdt.debug.internal.ui.editors.DebugTextHover&quot;&gt;
+  &lt;/hover&gt;
+ &lt;/extension&gt;
+&lt;/pre&gt;
+&lt;/p&gt;
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="apiInfo"/>
+      </appInfo>
+      <documentation>
+         
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="implementation"/>
+      </appInfo>
+      <documentation>
+         
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="copyright"/>
+      </appInfo>
+      <documentation>
+         Copyright (c) 2001, 2006 IBM Corporation and others.&lt;br&gt;
+All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
+      </documentation>
+   </annotation>
+
+</schema>
diff --git a/org.eclipse.cdt.ui/schema/workingSetConfigurations.exsd b/org.eclipse.cdt.ui/schema/workingSetConfigurations.exsd
new file mode 100644 (file)
index 0000000..a1d6645
--- /dev/null
@@ -0,0 +1,149 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.ui" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appInfo>
+         <meta.schema plugin="org.eclipse.cdt.ui" id="workingSetConfigurations" name="Working Set Configurations"/>
+      </appInfo>
+      <documentation>
+         &lt;p&gt;
+&lt;b&gt;This extension point is internal to the CDT plug-in family.&lt;/b&gt;
+&lt;/p&gt;&lt;p&gt;
+Extension point for registration of project configuration factories for handling extended configuration options for custom project natures, in working set configurations.  These factories are responsible for creating the project configuration elements and the UI controllers for the Manage Working Set Configurations dialog.
+&lt;/p&gt;
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appInfo>
+            <meta.element />
+         </appInfo>
+      </annotation>
+      <complexType>
+         <sequence minOccurs="1" maxOccurs="unbounded">
+            <element ref="projectConfigurationFactory"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="projectConfigurationFactory">
+      <annotation>
+         <documentation>
+            Registration of a factory for project configuration elements in working set configurations.  Factories are registered against project natures via nested &lt;tt&gt;&amp;lt;nature&amp;gt;&lt;/tt&gt; elements.
+         </documentation>
+      </annotation>
+      <complexType>
+         <sequence minOccurs="1" maxOccurs="unbounded">
+            <element ref="projectNature"/>
+         </sequence>
+         <attribute name="id" type="string" use="required">
+            <annotation>
+               <documentation>
+                  A unique identifier for the project configuration factory.
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  Fully qualified name of the factory class.  It must implement the &lt;tt&gt;IWorkingSetProjectConfigurationFactory&lt;/tt&gt; interface.
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="java" basedOn=":org.eclipse.cdt.internal.ui.workingsets.IWorkingSetProjectConfigurationFactory"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="projectNature">
+      <annotation>
+         <documentation>
+            A reference to a project nature.
+         </documentation>
+      </annotation>
+      <complexType>
+         <attribute name="id" type="string" use="required">
+            <annotation>
+               <documentation>
+                  The referenced project nature ID.
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="identifier" basedOn="org.eclipse.core.resources.natures/@id"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="since"/>
+      </appInfo>
+      <documentation>
+         6.0
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="examples"/>
+      </appInfo>
+      <documentation>
+         &lt;pre&gt;
+&lt;extension point=&quot;org.eclipse.cdt.ui.workingSetConfigurations&quot;&gt;
+  &lt;projectConfigurationFactory
+        id=&quot;org.example.myProject&quot;
+        class=&quot;org.example.MyProjectConfigurationFactory&quot;&gt;
+    &lt;nature id=&quot;org.example.myProjectNature&quot;/&gt;
+  &lt;/projectConfigurationFactory&gt;
+&lt;/extension&gt;
+&lt;/pre&gt;
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="apiinfo"/>
+      </appInfo>
+      <documentation>
+         Registered project configuration factories are required to implement the &lt;tt&gt;org.eclipse.cdt.internal.ui.workingsets.IWorkingSetProjectConfigurationFactory&lt;/tt&gt; interface.
+      </documentation>
+   </annotation>
+
+
+   <annotation>
+      <appInfo>
+         <meta.section type="copyright"/>
+      </appInfo>
+      <documentation>
+         Copyright (c) 2009 QNX Software Systems and others.  All rights reserved.
+      </documentation>
+   </annotation>
+
+</schema>
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/CorextMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/CorextMessages.java
new file mode 100644 (file)
index 0000000..04425a7
--- /dev/null
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ *  Copyright (c) 2004, 2008 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *  IBM Rational Software - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.corext;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class CorextMessages extends NLS {
+
+       private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.corext.CorextMessages";//$NON-NLS-1$
+
+       private CorextMessages() {
+               // Do not instantiate
+       }
+
+       public static String Resources_outOfSyncResources;
+       public static String Resources_outOfSync;
+       public static String Resources_modifiedResources;
+       public static String Resources_fileModified;
+
+       static {
+               NLS.initializeMessages(BUNDLE_NAME, CorextMessages.class);
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/CorextMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/CorextMessages.properties
new file mode 100644 (file)
index 0000000..2a976f1
--- /dev/null
@@ -0,0 +1,16 @@
+###############################################################################
+# Copyright (c) 2000, 2008 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+#     Anton Leherbauer (Wind River Systems)
+###############################################################################
+
+Resources_outOfSyncResources= Some resources are out of sync
+Resources_outOfSync= Resource ''{0}'' is out of sync with file system.
+Resources_modifiedResources= There are modified resources
+Resources_fileModified= File ''{0}'' has been modified since the beginning of the operation
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/AddIncludesOperation.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/AddIncludesOperation.java
new file mode 100644 (file)
index 0000000..3b1f8b2
--- /dev/null
@@ -0,0 +1,276 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2010 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software Systems
+ *     Sergey Prigogin (Google)
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.corext.codemanipulation;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.text.edits.InsertEdit;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.IBuffer;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IMacro;
+import org.eclipse.cdt.core.model.ISourceRange;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.IRequiredInclude;
+
+import org.eclipse.cdt.internal.ui.editor.CEditorMessages;
+
+/**
+ * Adds includes and 'using' declarations to a translation unit.
+ * If the translation unit is open in an editor, be sure to pass over its working copy.
+ */
+public class AddIncludesOperation implements IWorkspaceRunnable {
+       private final ITranslationUnit fTranslationUnit;
+       private final int fBeforeOffset;
+       private final IRequiredInclude[] fIncludes;
+       private final String[] fUsings;
+       private String fNewLine;
+       private IBuffer fBuffer;
+       private List<ICElement> fExistingIncludes;
+       private List<ICElement> fExistingUsings;
+       private InsertEdit fIncludesInsert;
+       private InsertEdit fUsingsInsert;
+       private int fIncludesPos= -1;
+
+       /**
+        * @param tu a translation unit.
+        * @param beforeOffset includes and 'using' declarations have to be inserted before this offset.
+        * @param includes '#include' statements to insert.
+        * @param usings 'using' statements to insert.
+        */
+       public AddIncludesOperation(ITranslationUnit tu, int beforeOffset, IRequiredInclude[] includes,
+                       String[] usings) {
+               fTranslationUnit = tu;
+               fBeforeOffset = beforeOffset;
+               fIncludes= includes;
+               fUsings = usings;
+       }
+
+       /**
+        * @return Returns the scheduling rule for this operation
+        */
+       public ISchedulingRule getSchedulingRule() {
+               return ResourcesPlugin.getWorkspace().getRoot();
+       }
+
+       public void run(IProgressMonitor monitor) throws CoreException {
+               if (monitor == null) {
+                       monitor= new NullProgressMonitor();
+               }
+               try {
+                       monitor.beginTask(CEditorMessages.AddIncludesOperation_description, 3);
+
+                       fBuffer = fTranslationUnit.getBuffer();
+                       fNewLine= getLineSeparator();
+                       fExistingIncludes = fTranslationUnit.getChildrenOfType(ICElement.C_INCLUDE);
+                       fIncludesInsert = getIncludesInsert();
+                       monitor.worked(1);
+                       if (fUsings != null && fUsings.length > 0) {
+                               fExistingUsings = fTranslationUnit.getChildrenOfType(ICElement.C_USING);
+                       }
+                       fUsingsInsert = getUsingsInsert();
+                       monitor.worked(1);
+
+                       if (fIncludesInsert != null) {
+                               fBuffer.replace(fIncludesInsert.getOffset(), 0, fIncludesInsert.getText());
+                       }
+                       if (fUsingsInsert != null) {
+                               int offset = fUsingsInsert.getOffset();
+                               if (fIncludesInsert != null && offset >= fIncludesInsert.getOffset()) {
+                                       offset += fIncludesInsert.getText().length();
+                               }
+                               fBuffer.replace(offset, 0, fUsingsInsert.getText());
+                       }
+                       monitor.worked(1);
+               } finally {
+                       monitor.done();
+               }
+       }
+
+       private InsertEdit getIncludesInsert() throws CoreException {
+               if (fIncludes == null || fIncludes.length == 0) {
+                       return null;
+               }
+
+               ArrayList<IRequiredInclude> toAdd = new ArrayList<IRequiredInclude>();
+               for (IRequiredInclude include : fIncludes) {
+                       String name = include.getIncludeName();
+                       boolean found = false;
+                       for (ICElement element : fExistingIncludes) {
+                               ISourceRange range = ((ISourceReference) element).getSourceRange();
+                               if (range.getStartPos() + range.getLength() > fBeforeOffset) {
+                                       break;
+                               }
+                               if (name.equals(element.getElementName())) {
+                                       found = true;
+                                       break;
+                               }
+                       }
+                       if (!found) {
+                               toAdd.add(include);
+                       }
+               }
+               if (toAdd.isEmpty()) {
+                       return null;
+               }
+
+               // So we have our list. Now insert.
+               StringBuilder buf = new StringBuilder();
+               for (IRequiredInclude include : toAdd) {
+                       if (include.isStandard()) {
+                               buf.append("#include <" + include.getIncludeName() + ">").append(fNewLine); //$NON-NLS-1$ //$NON-NLS-2$
+                       } else {
+                               buf.append("#include \"" + include.getIncludeName() + "\"").append(fNewLine); //$NON-NLS-1$ //$NON-NLS-2$
+                       }
+               }
+
+               int pos= getIncludeInsertionPosition();
+               return new InsertEdit(pos, buf.toString()); 
+       }
+
+       private int getIncludeInsertionPosition() throws CModelException {
+               if (fIncludesPos < 0) {
+                       if (fExistingIncludes.isEmpty()) {
+                               fIncludesPos= getOffsetAfterLeadingMacroDefinitions();
+                       } else { 
+                               fIncludesPos = getOffsetAfterLast(fExistingIncludes);
+                       }
+               }
+               return fIncludesPos;
+       }
+
+       private InsertEdit getUsingsInsert() throws CoreException {
+               if (fUsings == null || fUsings.length == 0) {
+                       return null;
+               }
+
+               ArrayList<String> toAdd = new ArrayList<String>(fUsings.length);
+               for (String name : fUsings) {
+                       boolean found = false;
+                       for (ICElement element : fExistingUsings) {
+                               ISourceRange range = ((ISourceReference) element).getSourceRange();
+                               if (range.getStartPos() + range.getLength() > fBeforeOffset) {
+                                       break;
+                               }
+                               if (name.equals(element.getElementName())) {
+                                       found = true;
+                                       break;
+                               }
+                       }
+                       if (!found) {
+                               toAdd.add(name);
+                       }
+               }
+               if (toAdd.isEmpty()) {
+                       return null;
+               }
+
+               // So we have our list. Now insert.
+               StringBuilder buf = new StringBuilder();
+               for (String using : toAdd) {
+                       buf.append("using ").append(using).append(';').append(fNewLine); //$NON-NLS-1$
+               }
+
+               int pos = getOffsetAfterLast(fExistingUsings);
+               int pos2 = getIncludeInsertionPosition();
+               if (pos <= pos2) {
+                       pos = pos2;
+                       buf.insert(0, fNewLine); // Add a blank line between #include and using statements.
+               }
+
+               return new InsertEdit(pos, buf.toString());
+       }
+
+       /**
+        * Find the last of elements located before fBeforeOffset and returns offset of the following line.
+        * @param elements source elements to consider.
+        * @return offset of the line after the last of elements located before fBeforeOffset, or
+        * zero, if there is no such element.
+        * @throws CModelException
+        */
+       private int getOffsetAfterLast(List<ICElement> elements) throws CModelException {
+               for (int i = elements.size(); --i >= 0;) {
+                       ISourceRange range = ((ISourceReference) elements.get(i)).getSourceRange();
+                       int end = range.getStartPos() + range.getLength(); 
+                       if (end <= fBeforeOffset) {
+                               return findNewLine(range.getStartPos() + range.getLength());
+                       }
+               }
+               return 0;
+       }
+
+       /**
+        * Find the last leading macro definition before <code>fBeforeOffset</code>.
+        * And returns the offset of the line after.
+        */
+       private int getOffsetAfterLeadingMacroDefinitions() throws CModelException {
+               ISourceRange found= null;
+               for (ICElement child: fTranslationUnit.getChildren()) {
+                       if (!(child instanceof IMacro) || !(child instanceof ISourceReference))
+                               break;
+                       
+                       final ISourceReference sourceRef = (ISourceReference) child;
+                       if (!sourceRef.isActive())
+                               break;
+                       
+                       ISourceRange range= sourceRef.getSourceRange();
+                       if (range.getStartPos() + range.getLength() > fBeforeOffset)
+                               break;
+                       
+                       found= range;
+               }
+               if (found != null) {
+                       return findNewLine(found.getStartPos() + found.getLength());
+               }
+               return 0;
+       }
+
+       private int findNewLine(int pos) {
+               while (fBuffer.getChar(pos) != '\n') {
+                       pos++;
+               }
+               if (fBuffer.getChar(pos) == '\r') {
+                       pos++;
+               }
+               return pos + 1;
+       }
+
+       private String getLineSeparator() {
+               try {
+                       if (fBuffer instanceof IAdaptable) {
+                               IDocument doc= (IDocument) ((IAdaptable) fBuffer).getAdapter(IDocument.class);
+                               if (doc != null) {
+                                       String delim= doc.getLineDelimiter(0);
+                                       if (delim != null) {
+                                               return delim;
+                                       }
+                               }
+                       }
+               } catch (BadLocationException e) {
+               }
+               return System.getProperty("line.separator", "\n");  //$NON-NLS-1$//$NON-NLS-2$
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/StubUtility.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/codemanipulation/StubUtility.java
new file mode 100644 (file)
index 0000000..e11f01f
--- /dev/null
@@ -0,0 +1,750 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Rational Software - initial implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Jens Elmenthaler (Verigy) - http://bugs.eclipse.org/235586
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.corext.codemanipulation;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.UUID;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.templates.Template;
+import org.eclipse.jface.text.templates.TemplateBuffer;
+import org.eclipse.jface.text.templates.TemplateContext;
+import org.eclipse.jface.text.templates.TemplateException;
+import org.eclipse.jface.text.templates.TemplateVariable;
+import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData;
+import org.eclipse.swt.SWT;
+import org.eclipse.text.edits.DeleteEdit;
+import org.eclipse.text.edits.InsertEdit;
+import org.eclipse.text.edits.MalformedTreeException;
+import org.eclipse.text.edits.MultiTextEdit;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.CCorePreferenceConstants;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.IBuffer;
+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.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.utils.PathUtil;
+
+import org.eclipse.cdt.internal.corext.template.c.CodeTemplateContext;
+import org.eclipse.cdt.internal.corext.template.c.CodeTemplateContextType;
+import org.eclipse.cdt.internal.corext.template.c.FileTemplateContext;
+import org.eclipse.cdt.internal.corext.template.c.FileTemplateContextType;
+import org.eclipse.cdt.internal.corext.util.Strings;
+
+import org.eclipse.cdt.internal.ui.viewsupport.ProjectTemplateStore;
+
+public class StubUtility {
+       private static final String[] EMPTY= {};
+       
+       private StubUtility() {
+       }
+
+       /*
+        * Don't use this method directly, use CodeGeneration.
+        * @see org.eclipse.cdt.ui.CodeGeneration#getHeaderFileContent(ITranslationUnit, String, String, String)
+        */     
+       public static String getHeaderFileContent(ITranslationUnit tu, String declarations,
+                       String fileComment, String includes, String namespaceBegin,     String namespaceEnd,
+                       String namespaceName, String typeComment, String typeName,
+                       String lineDelimiter) throws CoreException {
+               return getHeaderFileContent(getDefaultFileTemplate(tu), tu, declarations, fileComment,
+                               includes, namespaceBegin, namespaceEnd, namespaceName, typeComment, typeName,
+                               lineDelimiter);
+       }
+
+       /*
+        * Don't use this method directly, use CodeGeneration.
+        * @see org.eclipse.cdt.ui.CodeGeneration#getHeaderFileContent(Template, ITranslationUnit, String, String, String)
+        */     
+       public static String getHeaderFileContent(Template template, ITranslationUnit tu,
+                       String declarations, String fileComment, String includes, String namespaceBegin,
+                       String namespaceEnd, String namespaceName, String typeComment, String typeName,
+                       String lineDelimiter) throws CoreException {
+               if (template == null) {
+                       return null;
+               }
+               ICProject project= tu.getCProject();
+               CodeTemplateContext context= new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
+               context.setTranslationUnitVariables(tu);
+               String includeGuardSymbol= generateIncludeGuardSymbol(tu.getResource(), project);
+               context.setVariable(CodeTemplateContextType.DECLARATIONS, declarations != null ? declarations : ""); //$NON-NLS-1$
+               context.setVariable(CodeTemplateContextType.FILE_COMMENT, fileComment != null ? fileComment : ""); //$NON-NLS-1$
+               context.setVariable(CodeTemplateContextType.INCLUDE_GUARD_SYMBOL, includeGuardSymbol != null ? includeGuardSymbol : ""); //$NON-NLS-1$
+               context.setVariable(CodeTemplateContextType.INCLUDES, includes != null ? includes : ""); //$NON-NLS-1$
+               context.setVariable(CodeTemplateContextType.NAMESPACE_BEGIN, namespaceBegin != null ? namespaceBegin : ""); //$NON-NLS-1$
+               context.setVariable(CodeTemplateContextType.NAMESPACE_END, namespaceEnd != null ? namespaceEnd : ""); //$NON-NLS-1$
+               context.setVariable(CodeTemplateContextType.NAMESPACE_NAME, namespaceName != null ? namespaceName : ""); //$NON-NLS-1$
+               context.setVariable(CodeTemplateContextType.TYPE_COMMENT, typeComment != null ? typeComment : ""); //$NON-NLS-1$
+               context.setVariable(CodeTemplateContextType.TYPENAME, typeName != null ? typeName : ""); //$NON-NLS-1$
+               String[] fullLine= {
+                               CodeTemplateContextType.DECLARATIONS, CodeTemplateContextType.FILE_COMMENT,
+                               CodeTemplateContextType.INCLUDES,
+                               CodeTemplateContextType.NAMESPACE_BEGIN, CodeTemplateContextType.NAMESPACE_END,
+                               CodeTemplateContextType.TYPE_COMMENT
+                       };
+
+               String text = evaluateTemplate(context, template, fullLine);
+               if (text != null && !text.endsWith(lineDelimiter))
+                       text += lineDelimiter;
+               return text;
+       }
+
+       /*
+        * Don't use this method directly, use CodeGeneration.
+        * @see org.eclipse.cdt.ui.CodeGeneration#getBodyFileContent(ITranslationUnit, String, String, String, String, String, String, String, String, String)
+        */     
+       public static String getBodyFileContent(ITranslationUnit tu,
+                       String declarations, String fileComment, String includes, String namespaceBegin,
+                       String namespaceEnd, String namespaceName, String typeComment, String typeName,
+                       String lineDelimiter) throws CoreException {
+               return getBodyFileContent(getDefaultFileTemplate(tu), tu, declarations, fileComment,
+                               includes, namespaceBegin, namespaceEnd, namespaceName, typeComment, typeName,
+                               lineDelimiter);
+       }
+
+       /*
+        * Don't use this method directly, use CodeGeneration.
+        * @see org.eclipse.cdt.ui.CodeGeneration#getBodyFileContent(Template, ITranslationUnit, String, String, String, String, String, String, String, String, String)
+        */     
+       public static String getBodyFileContent(Template template, ITranslationUnit tu,
+                       String declarations, String fileComment, String includes, String namespaceBegin,
+                       String namespaceEnd, String namespaceName, String typeComment, String typeName,
+                       String lineDelimiter) throws CoreException {
+               if (template == null) {
+                       return null;
+               }
+               ICProject project= tu.getCProject();
+               CodeTemplateContext context= new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
+               context.setTranslationUnitVariables(tu);
+               context.setVariable(CodeTemplateContextType.DECLARATIONS, declarations != null ? declarations : ""); //$NON-NLS-1$
+               context.setVariable(CodeTemplateContextType.FILE_COMMENT, fileComment != null ? fileComment : ""); //$NON-NLS-1$
+               context.setVariable(CodeTemplateContextType.INCLUDES, includes != null ? includes : ""); //$NON-NLS-1$
+               context.setVariable(CodeTemplateContextType.NAMESPACE_BEGIN, namespaceBegin != null ? namespaceBegin : ""); //$NON-NLS-1$
+               context.setVariable(CodeTemplateContextType.NAMESPACE_END, namespaceEnd != null ? namespaceEnd : ""); //$NON-NLS-1$
+               context.setVariable(CodeTemplateContextType.NAMESPACE_NAME, namespaceName != null ? namespaceName : ""); //$NON-NLS-1$
+               context.setVariable(CodeTemplateContextType.TYPE_COMMENT, typeComment != null ? typeComment : ""); //$NON-NLS-1$
+               context.setVariable(CodeTemplateContextType.TYPENAME, typeName != null ? typeName : ""); //$NON-NLS-1$
+               String[] fullLine= {
+                               CodeTemplateContextType.DECLARATIONS, CodeTemplateContextType.FILE_COMMENT,
+                               CodeTemplateContextType.INCLUDES,
+                               CodeTemplateContextType.NAMESPACE_BEGIN, CodeTemplateContextType.NAMESPACE_END,
+                               CodeTemplateContextType.TYPE_COMMENT
+                       };
+               String text = evaluateTemplate(context, template, fullLine);
+               if (text != null && !text.endsWith(lineDelimiter))
+                       text += lineDelimiter;
+               return text;
+       }
+
+       /*
+        * Don't use this method directly, use CodeGeneration.
+        * @see org.eclipse.cdt.ui.CodeGeneration#getTestFileContent(ITranslationUnit, String, String, String)
+        */     
+       public static String getTestFileContent(ITranslationUnit tu, String declarations,
+                       String fileComment, String includes, String namespaceBegin, String namespaceEnd,
+                       String namespaceName, String typeName, String lineDelimiter)
+                                       throws CoreException {
+               return getBodyFileContent(getTestFileTemplate(tu), tu, declarations, fileComment,
+                               includes, namespaceBegin, namespaceEnd, namespaceName, null, typeName,
+                               lineDelimiter);
+       }
+
+       public static String getFileContent(Template template, IFile file, String lineDelimiter) throws CoreException {
+               ICProject cproject = null;
+               final IProject project = file.getProject();
+               if (CoreModel.hasCNature(project)) {
+                       cproject = CoreModel.getDefault().create(project);
+               }
+               FileTemplateContext context;
+               if (cproject != null) {
+                       context= new CodeTemplateContext(template.getContextTypeId(), cproject, lineDelimiter);
+               } else {
+                       context= new FileTemplateContext(template.getContextTypeId(), lineDelimiter);
+               }
+               String fileComment= getFileComment(file, lineDelimiter);
+               context.setVariable(CodeTemplateContextType.FILE_COMMENT, fileComment != null ? fileComment : ""); //$NON-NLS-1$
+               String includeGuardSymbol= generateIncludeGuardSymbol(file, cproject);
+               context.setVariable(CodeTemplateContextType.INCLUDE_GUARD_SYMBOL, includeGuardSymbol != null ? includeGuardSymbol : ""); //$NON-NLS-1$
+               context.setResourceVariables(file);
+               String[] fullLine= { CodeTemplateContextType.FILE_COMMENT };
+               
+               String text = evaluateTemplate(context, template, fullLine);
+               if (!text.endsWith(lineDelimiter))
+                       text += lineDelimiter;
+               return text;
+       }
+
+       /*
+        * Don't use this method directly, use CodeGeneration.
+        */
+       public static String getClassBodyContent(ICProject project, String className,
+                       String classMemberDeclarations, String lineDelimiter) throws CoreException {
+               Template template= getCodeTemplate(CodeTemplateContextType.CLASS_BODY_ID, project);
+               if (template == null) {
+                       return classMemberDeclarations;
+               }
+               CodeTemplateContext context= new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
+               context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, className);
+               context.setVariable(CodeTemplateContextType.DECLARATIONS, classMemberDeclarations != null ? classMemberDeclarations : ""); //$NON-NLS-1$
+               String str= evaluateTemplate(context, template,
+                               new String[] { CodeTemplateContextType.DECLARATIONS });
+               if (str == null && classMemberDeclarations != null && !Strings.containsOnlyWhitespaces(classMemberDeclarations)) {
+                       return classMemberDeclarations;
+               }
+               return str;
+       }
+
+       /*
+        * Don't use this method directly, use CodeGeneration.
+        */
+       public static String getMethodBodyContent(ICProject project, String typeName, String methodName, String bodyStatement, String lineDelimiter) throws CoreException {
+               String templateId= CodeTemplateContextType.METHODSTUB_ID;
+               return getMethodBodyContent(templateId, project, typeName, methodName, bodyStatement, lineDelimiter);
+       }
+
+       /*
+        * Don't use this method directly, use CodeGeneration.
+        */
+       public static String getMethodBodyContent(String templateId, ICProject project, String typeName,
+                       String methodName, String bodyStatement, String lineDelimiter) throws CoreException {
+               Template template= getCodeTemplate(templateId, project);
+               if (template == null) {
+                       return bodyStatement;
+               }
+               CodeTemplateContext context= new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
+               context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD, methodName);
+               context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, typeName);
+               context.setVariable(CodeTemplateContextType.BODY_STATEMENT, bodyStatement != null ? bodyStatement : ""); //$NON-NLS-1$
+               String str= evaluateTemplate(context, template, new String[] { CodeTemplateContextType.BODY_STATEMENT });
+               if (str == null && bodyStatement != null && !Strings.containsOnlyWhitespaces(bodyStatement)) {
+                       return bodyStatement;
+               }
+               return str;
+       }
+
+       /*
+        * Don't use this method directly, use CodeGeneration.
+        */
+       public static String getConstructorBodyContent(ICProject project, String typeName, String bodyStatement, String lineDelimiter) throws CoreException {
+               String templateId= CodeTemplateContextType.CONSTRUCTORSTUB_ID;
+               return getMethodBodyContent(templateId, project, typeName, typeName, bodyStatement, lineDelimiter);
+       }
+
+       /*
+        * Don't use this method directly, use CodeGeneration.
+        */
+       public static String getDestructorBodyContent(ICProject project, String typeName, String bodyStatement, String lineDelimiter) throws CoreException {
+               String templateId= CodeTemplateContextType.DESTRUCTORSTUB_ID;
+               return getMethodBodyContent(templateId, project, typeName, "~"+typeName, bodyStatement, lineDelimiter); //$NON-NLS-1$
+       }
+
+       /*
+        * Don't use this method directly, use CodeGeneration.
+        */
+       public static String getNamespaceBeginContent(ICProject project, String namespaceName,
+                       String lineDelimiter) throws CoreException {
+               Template template= getCodeTemplate(CodeTemplateContextType.NAMESPACE_BEGIN_ID, project);
+               if (template == null) {
+                       return null;
+               }
+               CodeTemplateContext context= new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
+               context.setVariable(CodeTemplateContextType.NAMESPACE_NAME, namespaceName);
+               return evaluateTemplate(context, template, EMPTY);
+       }
+
+       /*
+        * Don't use this method directly, use CodeGeneration.
+        */
+       public static String getNamespaceEndContent(ICProject project, String namespaceName,
+                       String lineDelimiter) throws CoreException {
+               Template template= getCodeTemplate(CodeTemplateContextType.NAMESPACE_END_ID, project);
+               if (template == null) {
+                       return null;
+               }
+               CodeTemplateContext context= new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
+               context.setVariable(CodeTemplateContextType.NAMESPACE_NAME, namespaceName);
+               return evaluateTemplate(context, template, EMPTY);
+       }
+
+       /*
+        * Don't use this method directly, use CodeGeneration.
+        * @see org.eclipse.cdt.ui.CodeGeneration#getFileComment(ITranslationUnit, String)
+        */     
+       public static String getFileComment(ITranslationUnit tu, String lineDelimiter) throws CoreException {
+               Template template= getCodeTemplate(CodeTemplateContextType.FILECOMMENT_ID, tu.getCProject());
+               if (template == null) {
+                       return null;
+               }
+               
+               ICProject project= tu.getCProject();
+               CodeTemplateContext context= new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
+               context.setTranslationUnitVariables(tu);
+               return evaluateTemplate(context, template);
+       }       
+
+       private static String getFileComment(IFile file, String lineDelimiter) throws CoreException {
+               Template template= getCodeTemplate(CodeTemplateContextType.FILECOMMENT_ID, file.getProject());
+               if (template == null) {
+                       return null;
+               }
+               
+               FileTemplateContext context= new FileTemplateContext(template.getContextTypeId(), lineDelimiter);
+               context.setResourceVariables(file);
+               return evaluateTemplate(context, template);
+       }       
+
+       /*
+        * Don't use this method directly, use CodeGeneration.
+        * @see org.eclipse.cdt.ui.CodeGeneration#getClassComment(ITranslationUnit, String, String)
+        */     
+       public static String getClassComment(ITranslationUnit tu, String typeQualifiedName, String lineDelimiter) throws CoreException {
+               Template template= getCodeTemplate(CodeTemplateContextType.TYPECOMMENT_ID, tu.getCProject());
+               if (template == null) {
+                       return null;
+               }
+               
+               ICProject project= tu.getCProject();
+               CodeTemplateContext context= new CodeTemplateContext(template.getContextTypeId(), project, lineDelimiter);
+               context.setTranslationUnitVariables(tu);
+               context.setVariable(CodeTemplateContextType.TYPENAME, typeQualifiedName);
+               return evaluateTemplate(context, template);
+       }
+
+       /*
+        * Don't use this method directly, use CodeGeneration.
+        * @see org.eclipse.cdt.ui.CodeGeneration#getMethodComment(ITranslationUnit, String, String, String[], String[], String, String)
+        */
+       public static String getMethodComment(ITranslationUnit tu, String typeName, String methodName, String[] paramNames, String[] excTypeSig, String retTypeSig, String lineDelimiter) throws CoreException {
+               String templateId= CodeTemplateContextType.METHODCOMMENT_ID;
+               return getMethodComment(templateId, tu, typeName, methodName, paramNames, excTypeSig, retTypeSig, lineDelimiter);
+       }
+       
+       /*
+        * Don't use this method directly, use CodeGeneration.
+        * @see org.eclipse.cdt.ui.CodeGeneration#getConstructorComment(ITranslationUnit, String, String[], String[], String)
+        */
+       public static String getConstructorComment(ITranslationUnit tu, String typeName, String[] paramNames, String[] excTypeSig, String lineDelimiter) throws CoreException {
+               String templateId= CodeTemplateContextType.CONSTRUCTORCOMMENT_ID;
+               return getMethodComment(templateId, tu, typeName, typeName, paramNames, excTypeSig, null, lineDelimiter);
+       }
+       
+       /*
+        * Don't use this method directly, use CodeGeneration.
+        * @see org.eclipse.cdt.ui.CodeGeneration#getDestructorComment(ITranslationUnit, String, String[], String)
+        */
+       public static String getDestructorComment(ITranslationUnit tu, String typeName, String[] excTypeSig, String lineDelimiter) throws CoreException {
+               String templateId= CodeTemplateContextType.DESTRUCTORCOMMENT_ID;
+               return getMethodComment(templateId, tu, typeName, "~" + typeName, EMPTY, excTypeSig, null, lineDelimiter); //$NON-NLS-1$
+       }
+
+       /*
+        * Don't use this method directly, use CodeGeneration.
+        * @see org.eclipse.cdt.ui.CodeGeneration#getMethodComment(ITranslationUnit, String, String, String[], String[], String, String)
+        */
+       public static String getMethodComment(String templateId, ITranslationUnit tu, String typeName, String methodName, String[] paramNames, String[] excTypeSig, String retTypeSig, String lineDelimiter) throws CoreException {
+               Template template= getCodeTemplate(templateId, tu.getCProject());
+               if (template == null) {
+                       return null;
+               }
+               CodeTemplateContext context= new CodeTemplateContext(template.getContextTypeId(), tu.getCProject(), lineDelimiter);
+               context.setTranslationUnitVariables(tu);
+               context.setVariable(CodeTemplateContextType.ENCLOSING_TYPE, typeName);
+               context.setVariable(CodeTemplateContextType.ENCLOSING_METHOD, methodName);
+               
+               if (retTypeSig != null) {
+                       context.setVariable(CodeTemplateContextType.RETURN_TYPE, retTypeSig);
+               }
+               context.setTranslationUnitVariables(tu);
+               TemplateBuffer buffer;
+               try {
+                       buffer= context.evaluate(template);
+               } catch (BadLocationException e) {
+                       throw new CoreException(Status.CANCEL_STATUS);
+               } catch (TemplateException e) {
+                       throw new CoreException(Status.CANCEL_STATUS);
+               }
+               if (buffer == null) {
+                       return null;
+               }
+               
+               // TODO doc comment tags
+               
+               String str= buffer.getString();
+               if (Strings.containsOnlyWhitespaces(str)) {
+                       return null;
+               }
+
+               return str;
+       }
+       
+       // remove lines for empty variables, prefix multi-line variables
+       private static String fixFullLineVariables(TemplateBuffer buffer, String[] variables) throws MalformedTreeException, BadLocationException {
+               IDocument doc= new Document(buffer.getString());
+               int nLines= doc.getNumberOfLines();
+               MultiTextEdit edit= new MultiTextEdit();
+               HashSet<Integer> removedLines= new HashSet<Integer>();
+               for (int i= 0; i < variables.length; i++) {
+                       TemplateVariable position= findVariable(buffer, variables[i]);
+                       if (position == null) {
+                               continue;
+                       }
+                       if (position.getLength() > 0) {
+                               int[] offsets= position.getOffsets();
+                               for (int j= 0; j < offsets.length; j++) {
+                                       final int offset = offsets[j];
+                                       try {
+                                               int startLine= doc.getLineOfOffset(offset);
+                                               int startOffset= doc.getLineOffset(startLine);
+                                               int endLine= doc.getLineOfOffset(offset + position.getLength());
+                                               String prefix= doc.get(startOffset, offset - startOffset);
+                                               if (prefix.length() > 0 && startLine < endLine) {
+                                                       for (int line= startLine + 1; line <= endLine; ++line) {
+                                                               int lineOffset= doc.getLineOffset(line);
+                                                               edit.addChild(new InsertEdit(lineOffset, prefix));
+                                                       }
+                                               }
+                                       } catch (BadLocationException e) {
+                                               break;
+                                       }
+                               }
+                       } else {
+                               int[] offsets= position.getOffsets();
+                               for (int k= 0; k < offsets.length; k++) {
+                                       int line= doc.getLineOfOffset(offsets[k]);
+                                       IRegion lineInfo= doc.getLineInformation(line);
+                                       int offset= lineInfo.getOffset();
+                                       String str= doc.get(offset, lineInfo.getLength());
+                                       if (Strings.containsOnlyWhitespaces(str) && nLines > line + 1 && removedLines.add(new Integer(line))) {
+                                               int nextStart= doc.getLineOffset(line + 1);
+                                               int length= nextStart - offset;
+                                               edit.addChild(new DeleteEdit(offset, length));
+                                       }
+                               }
+                       }
+               }
+               edit.apply(doc, 0);
+               return doc.get();
+       }
+
+       private static TemplateVariable findVariable(TemplateBuffer buffer, String variable) {
+               TemplateVariable[] positions= buffer.getVariables();
+               for (int i= 0; i < positions.length; i++) {
+                       TemplateVariable curr= positions[i];
+                       if (variable.equals(curr.getType())) {
+                               return curr;
+                       }
+               }
+               return null;
+       }
+       
+       private static String evaluateTemplate(TemplateContext context, Template template) throws CoreException {
+               TemplateBuffer buffer;
+               try {
+                       buffer= context.evaluate(template);
+               } catch (BadLocationException e) {
+                       throw new CoreException(Status.CANCEL_STATUS);
+               } catch (TemplateException e) {
+                       throw new CoreException(Status.CANCEL_STATUS);
+               }
+               if (buffer == null)
+                       return null;
+               String str= buffer.getString();
+               if (Strings.containsOnlyWhitespaces(str)) {
+                       return null;
+               }
+               return str;
+       }
+       
+       private static String evaluateTemplate(TemplateContext context, Template template, String[] fullLineVariables) throws CoreException {
+               TemplateBuffer buffer;
+               try {
+                       buffer= context.evaluate(template);
+                       if (buffer == null)
+                               return null;
+                       String str= fixFullLineVariables(buffer, fullLineVariables);
+                       if (Strings.containsOnlyWhitespaces(str)) {
+                               return null;
+                       }
+                       return str;
+               } catch (BadLocationException e) {
+                       throw new CoreException(Status.CANCEL_STATUS);
+               } catch (TemplateException e) {
+                       throw new CoreException(Status.CANCEL_STATUS);
+               }
+       }
+
+       /**
+        * Returns the line delimiter which is used in the specified project.
+        * 
+        * @param project the C project, or <code>null</code>
+        * @return the used line delimiter
+        */
+       public static String getLineDelimiterUsed(ICProject project) {
+               return getProjectLineDelimiter(project);
+       }
+
+       private static String getProjectLineDelimiter(ICProject cProject) {
+               IProject project= null;
+               if (cProject != null)
+                       project= cProject.getProject();
+               
+               String lineDelimiter= getLineDelimiterPreference(project);
+               if (lineDelimiter != null)
+                       return lineDelimiter;
+               
+               return System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+       }
+       
+       public static String getLineDelimiterPreference(IProject project) {
+               IScopeContext[] scopeContext;
+               if (project != null) {
+                       // project preference
+                       scopeContext= new IScopeContext[] { new ProjectScope(project) };
+                       String lineDelimiter= Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, scopeContext);
+                       if (lineDelimiter != null)
+                               return lineDelimiter;
+               }
+               // workspace preference
+               scopeContext= new IScopeContext[] { InstanceScope.INSTANCE };
+               String platformDefault= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+               return Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, platformDefault, scopeContext);
+       }
+       
+       /**
+        * Examines a string and returns the first line delimiter found.
+        */
+       public static String getLineDelimiterUsed(ICElement elem) throws CModelException {
+        if (elem == null) return ""; //$NON-NLS-1$
+        
+               ITranslationUnit cu= (ITranslationUnit) elem.getAncestor(ICElement.C_UNIT);
+               if (cu != null && cu.exists()) {
+                       IBuffer buf= cu.getBuffer();
+                       int length= buf.getLength();
+                       for (int i= 0; i < length; i++) {
+                               char ch= buf.getChar(i);
+                               if (ch == SWT.CR) {
+                                       if (i + 1 < length) {
+                                               if (buf.getChar(i + 1) == SWT.LF) {
+                                                       return "\r\n"; //$NON-NLS-1$
+                                               }
+                                       }
+                                       return "\r"; //$NON-NLS-1$
+                               } else if (ch == SWT.LF) {
+                                       return "\n"; //$NON-NLS-1$
+                               }
+                       }
+               }
+               return getProjectLineDelimiter(elem.getCProject());
+       }
+
+       /**
+        * Get the default task tag for the given project.
+        * 
+        * @param project
+        * @return the default task tag
+        */
+       public static String getTodoTaskTag(ICProject project) {
+               String markers= null;
+               if (project == null) {
+                       markers= CCorePlugin.getOption(CCorePreferenceConstants.TODO_TASK_TAGS);
+               } else {
+                       markers= project.getOption(CCorePreferenceConstants.TODO_TASK_TAGS, true);
+               }
+               
+               if (markers != null && markers.length() > 0) {
+                       int idx= markers.indexOf(',');
+                       if (idx == -1) {
+                               return markers;
+                       }
+                       return markers.substring(0, idx);
+               }
+               return CCorePreferenceConstants.DEFAULT_TASK_TAG;
+       }
+       
+       public static boolean doAddComments(ICProject project) {
+               return PreferenceConstants.getPreference(PreferenceConstants.CODEGEN_ADD_COMMENTS, project, false); 
+       }
+       
+       private static Template getDefaultFileTemplate(ITranslationUnit tu) {
+               String templateId= null;
+               if (tu.isASMLanguage()) {
+                       templateId= CodeTemplateContextType.ASM_SOURCEFILE_ID;
+               } else if (tu.isCXXLanguage()) {
+                       if (tu.isHeaderUnit()) {
+                               templateId= CodeTemplateContextType.CPP_HEADERFILE_ID;
+                       } else {
+                               templateId= CodeTemplateContextType.CPP_SOURCEFILE_ID;
+                       }
+               } else if (tu.isCLanguage()) {
+                       if (tu.isHeaderUnit()) {
+                               templateId= CodeTemplateContextType.C_HEADERFILE_ID;
+                       } else {
+                               templateId= CodeTemplateContextType.C_SOURCEFILE_ID;
+                       }
+               }
+               return getCodeTemplate(templateId, tu.getCProject());
+       }
+
+       private static Template getTestFileTemplate(ITranslationUnit tu) {
+               String templateId= null;
+               if (tu.isCXXLanguage() && !tu.isHeaderUnit()) {
+                       templateId= CodeTemplateContextType.CPP_TESTFILE_ID;
+               }
+               return getCodeTemplate(templateId, tu.getCProject());
+       }
+
+       private static Template getCodeTemplate(String id, ICProject cProject) {
+               return getCodeTemplate(id, cProject != null ? cProject.getProject() : null);
+       }
+
+       private static Template getCodeTemplate(String id, IProject project) {
+               if (project == null)
+                       return CUIPlugin.getDefault().getCodeTemplateStore().findTemplateById(id);
+               ProjectTemplateStore projectStore= new ProjectTemplateStore(project);
+               try {
+                       projectStore.load();
+               } catch (IOException e) {
+                       CUIPlugin.log(e);
+               }
+               return projectStore.findTemplateById(id);
+       }
+
+       private static String generateIncludeGuardSymbol(IResource file, ICProject cproject) {
+               int scheme = PreferenceConstants.getPreference(
+                               PreferenceConstants.CODE_TEMPLATES_INCLUDE_GUARD_SCHEME, cproject,
+                               PreferenceConstants.CODE_TEMPLATES_INCLUDE_GUARD_SCHEME_FILE_NAME);
+               
+               switch (scheme) {
+               case PreferenceConstants.CODE_TEMPLATES_INCLUDE_GUARD_SCHEME_FILE_PATH:
+                       if (file == null)
+                               return null;
+                       IPath path = file.getFullPath();
+                       ISourceRoot root = cproject.findSourceRoot(file);
+                       if (root != null) {
+                               path = PathUtil.makeRelativePath(path, root.getPath());
+                       }
+                       return generateIncludeGuardSymbolFromFilePath(path.toString());
+                       
+               default:
+                       CUIPlugin.log("Unknown preference value " + scheme + " for include guard scheme.", null); //$NON-NLS-1$ //$NON-NLS-2$
+                       //$FALL-THROUGH$
+               case PreferenceConstants.CODE_TEMPLATES_INCLUDE_GUARD_SCHEME_FILE_NAME:
+                       if (file == null)
+                               return null;
+                       return generateIncludeGuardSymbolFromFilePath(file.getName());
+
+               case PreferenceConstants.CODE_TEMPLATES_INCLUDE_GUARD_SCHEME_UUID:
+               return generateIncludeGuardSymbolFromUUID();
+               }
+    }
+
+       private static String generateIncludeGuardSymbolFromFilePath(String filename) {
+               // Convert to upper case and replace invalid characters with underscores,
+               // e.g. convert some/directory/foo-bar.h to SOME_DIRECTORY_FOO_BAR_H_
+               StringBuilder buf = new StringBuilder(filename.length() + 1);
+               for (int i = 0; i < filename.length(); ++i) {
+                       char ch = filename.charAt(i);
+                       if (Character.isLetterOrDigit(ch)) {
+                               buf.append(Character.toUpperCase(ch));
+                       } else if (buf.length() > 0){
+                               buf.append('_');
+                       }
+               }
+               buf.append('_');
+               return buf.toString();
+       }
+
+       private static String generateIncludeGuardSymbolFromUUID() {
+               String uuid = UUID.randomUUID().toString();
+               
+               // 1) Make sure the guard always starts with a letter.
+               // 2) Convert to upper case and remove invalid characters
+               // 
+               // e.g. convert
+               //         067e6162-3b6f-4ae2-a171-2470b63dff00 to
+               //        H067E6162-3b6F-4AE2-A171-2470B63DFF00
+               StringBuilder buf = new StringBuilder();
+               
+               buf.append('H');
+               
+               for (int i = 0; i < uuid.length(); ++i) {
+                       char ch = uuid.charAt(i);
+                       if (Character.isLetterOrDigit(ch)) {
+                               buf.append(Character.toUpperCase(ch));
+                       } else {
+                               buf.append('_');
+                       }
+               }
+
+               return buf.toString();
+       }
+
+       /**
+        * Get a set of file templates for the given content types.
+        * 
+        * @param contentTypes  the list of content types
+        * @param project  the project or <code>null</code>
+        * @return an array of templates
+        */
+       public static Template[] getFileTemplatesForContentTypes(String[] contentTypes, IProject project) {
+               if (contentTypes == null || contentTypes.length == 0) {
+                       return new Template[0];
+               }
+               TemplatePersistenceData[] templateDatas;
+               if (project == null) {
+                       templateDatas= CUIPlugin.getDefault().getCodeTemplateStore().getTemplateData(true);
+               } else {
+                       ProjectTemplateStore projectStore= new ProjectTemplateStore(project.getProject());
+                       try {
+                               projectStore.load();
+                       } catch (IOException e) {
+                               CUIPlugin.log(e);
+                       }
+                       templateDatas= projectStore.getTemplateData();
+               }
+               List<Template> result= new ArrayList<Template>();
+               for (int j = 0; j < contentTypes.length; j++) {
+                       for (int i = 0; i < templateDatas.length; i++) {
+                               Template template = templateDatas[i].getTemplate();
+                               final String contextTypeId = template.getContextTypeId();
+                               if (FileTemplateContextType.isContextTypeForContentType(contextTypeId, contentTypes[j])) {
+                                       result.add(template);
+                               }
+                       }
+               }
+               return result.toArray(new Template[result.size()]);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/fix/LinkedProposalModel.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/fix/LinkedProposalModel.java
new file mode 100644 (file)
index 0000000..e888f1d
--- /dev/null
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.corext.fix;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.cdt.core.dom.rewrite.ITrackedNodePosition;
+
+import org.eclipse.cdt.internal.corext.fix.LinkedProposalPositionGroup.PositionInformation;
+
+public class LinkedProposalModel {
+       private Map<String, LinkedProposalPositionGroup> fPositionGroups;
+       private LinkedProposalPositionGroup.PositionInformation fEndPosition;
+       
+       public void addPositionGroup(LinkedProposalPositionGroup positionGroup) {
+               if (positionGroup == null) {
+                       throw new IllegalArgumentException("positionGroup must not be null"); //$NON-NLS-1$
+               }
+               
+               if (fPositionGroups == null) {
+                       fPositionGroups= new HashMap<String, LinkedProposalPositionGroup>();
+               }
+               fPositionGroups.put(positionGroup.getGroupId(), positionGroup);
+       }
+       
+       public LinkedProposalPositionGroup getPositionGroup(String groupId, boolean createIfNotExisting) {
+               LinkedProposalPositionGroup group= fPositionGroups != null ? (LinkedProposalPositionGroup) fPositionGroups.get(groupId) : null;
+               if (createIfNotExisting && group == null) {
+                       group= new LinkedProposalPositionGroup(groupId);
+                       addPositionGroup(group);
+               }
+               return group;
+       }
+       
+       public Iterator<LinkedProposalPositionGroup> getPositionGroupIterator() {
+               if (fPositionGroups == null) {
+                       return new Iterator<LinkedProposalPositionGroup>() {
+                               public boolean hasNext() {return false;}
+                               public LinkedProposalPositionGroup next() {return null;}
+                               public void remove() {}
+                       };
+               }
+               return fPositionGroups.values().iterator();
+       }
+       
+       /**
+        * Sets the end position of the linked mode to the end of the passed range.
+        * @param position The position that describes the end position of the linked mode.
+        */
+       public void setEndPosition(PositionInformation position) {
+               fEndPosition= position;
+       }
+       
+       public void setEndPosition(ITrackedNodePosition position) {
+               setEndPosition(LinkedProposalPositionGroup.createPositionInformation(position, false));
+       }
+       
+       public PositionInformation getEndPosition() {
+               return fEndPosition;
+       }
+
+       public boolean hasLinkedPositions() {
+               return fPositionGroups != null && !fPositionGroups.isEmpty();
+       }
+
+       public void clear() {
+               fPositionGroups= null;
+               fEndPosition= null;     
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/fix/LinkedProposalPositionGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/fix/LinkedProposalPositionGroup.java
new file mode 100644 (file)
index 0000000..04987b1
--- /dev/null
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.corext.fix;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.link.LinkedModeModel;
+import org.eclipse.jface.text.link.LinkedPosition;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.text.edits.ReplaceEdit;
+import org.eclipse.text.edits.TextEdit;
+
+import org.eclipse.cdt.core.dom.rewrite.ITrackedNodePosition;
+
+
+public class LinkedProposalPositionGroup {
+       /**
+        * {@link LinkedProposalPositionGroup.PositionInformation} describes a position
+        * inside a position group. The information provided must be accurate
+        * after the document change to the proposal has been performed, but doesn't
+        * need to reflect the changed done by the linking mode.
+        */
+       public static abstract class PositionInformation {
+               public abstract int getOffset();
+               public abstract int getLength();
+               public abstract int getSequenceRank();
+       }
+       
+       public static class Proposal {
+               
+               private String fDisplayString;
+               private Image fImage;
+               private int fRelevance;
+
+               public Proposal(String displayString, Image image, int relevance) {
+                       fDisplayString= displayString;
+                       fImage= image;
+                       fRelevance= relevance;
+               }
+               
+               public String getDisplayString() {
+                       return fDisplayString;
+               }
+               
+               public Image getImage() {
+                       return fImage;
+               }
+               
+               public int getRelevance() {
+                       return fRelevance;
+               }
+                               
+               public void setImage(Image image) {
+                       fImage= image;
+               }
+               
+               public String getAdditionalProposalInfo() {
+                       return null;
+               }
+                               
+               public TextEdit computeEdits(int offset, LinkedPosition position, char trigger, int stateMask, LinkedModeModel model) throws CoreException {
+                       return new ReplaceEdit(position.getOffset(), position.getLength(), fDisplayString);
+               }
+       }       
+       
+       public static PositionInformation createPositionInformation(ITrackedNodePosition pos, boolean isFirst) {
+               return new TrackedNodePosition(pos, isFirst);
+       }
+       
+       private static class TrackedNodePosition extends PositionInformation {
+               private final ITrackedNodePosition fPos;
+               private final boolean fIsFirst;
+               
+               public TrackedNodePosition(ITrackedNodePosition pos, boolean isFirst) {
+                       fPos= pos;
+                       fIsFirst= isFirst;
+               }
+
+               @Override
+               public int getOffset() {
+                       return fPos.getStartPosition();
+               }
+               
+               @Override
+               public int getLength() {
+                       return fPos.getLength();
+               }
+               
+               @Override
+               public int getSequenceRank() {
+                       return fIsFirst ? 0 : 1;
+               }
+       }
+       
+       private final String fGroupId;
+       private final List<PositionInformation> fPositions;
+       private final List<Proposal> fProposals;
+       
+
+       public LinkedProposalPositionGroup(String groupID) {
+               fGroupId= groupID;
+               fPositions= new ArrayList<PositionInformation>();
+               fProposals= new ArrayList<Proposal>();
+       }
+       
+       public void addPosition(PositionInformation position) {
+               fPositions.add(position);
+       }
+       
+       public void addProposal(Proposal proposal) {
+               fProposals.add(proposal);
+       }
+       
+       public void addPosition(ITrackedNodePosition position, boolean isFirst) {
+               addPosition(createPositionInformation(position, isFirst));
+       }
+       
+       public void addProposal(String displayString, Image image, int relevance) {
+               addProposal(new Proposal(displayString, image, relevance));
+       }
+
+       public String getGroupId() {
+               return fGroupId;
+       }
+
+       public PositionInformation[] getPositions() {
+               return fPositions.toArray(new PositionInformation[fPositions.size()]);
+       }
+
+       public Proposal[] getProposals() {
+               return fProposals.toArray(new Proposal[fProposals.size()]);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CContext.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CContext.java
new file mode 100644 (file)
index 0000000..d33107d
--- /dev/null
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QnX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.corext.template.c;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.text.templates.Template;
+import org.eclipse.jface.text.templates.TemplateBuffer;
+import org.eclipse.jface.text.templates.TemplateContextType;
+import org.eclipse.jface.text.templates.TemplateException;
+import org.eclipse.jface.text.templates.TemplateTranslator;
+
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+
+/**
+ * A context for C/C++.
+ */
+public class CContext extends TranslationUnitContext { 
+
+       /**
+        * Creates a C/C++ code template context.
+        * 
+        * @param type the context type
+        * @param document the document
+        * @param completionOffset the completion position within the document
+        * @param completionLength the length of the context
+        * @param translationUnit the translation unit represented by the document
+        */
+       public CContext(TemplateContextType type, IDocument document, int completionOffset, int completionLength,
+               ITranslationUnit translationUnit) {
+               super(type, document, completionOffset, completionLength, translationUnit);
+       }
+
+       /**
+        * Creates a C/C++ code template context.
+        * 
+        * @param type the context type.
+        * @param document the document.
+        * @param completionPosition the completion position within the document
+        * @param translationUnit the translation unit (may be <code>null</code>).
+        */
+       public CContext(TemplateContextType type, IDocument document,
+                       Position completionPosition, ITranslationUnit translationUnit) {
+               super(type, document, completionPosition, translationUnit);
+       }
+
+       /*
+        * @see DocumentTemplateContext#getStart()
+        */ 
+       @Override
+       public int getStart() {
+               if (fIsManaged && getCompletionLength() > 0)
+                       return super.getStart();
+               
+               try {
+                       IDocument document= getDocument();
+
+                       int start= getCompletionOffset();
+                       int end= getCompletionOffset() + getCompletionLength();
+                       
+                       while (start != 0 && Character.isUnicodeIdentifierPart(document.getChar(start - 1)))
+                               start--;
+                       
+                       while (start != end && Character.isWhitespace(document.getChar(start)))
+                               start++;
+                       
+                       if (start == end)
+                               start= getCompletionOffset();   
+                       
+                               return start;   
+
+               } catch (BadLocationException e) {
+                       return super.getStart();        
+               }
+       }
+
+       @Override
+       public int getEnd() {
+               if (fIsManaged || getCompletionLength() == 0)
+                       return super.getEnd();
+
+               try {
+                       IDocument document= getDocument();
+
+                       int start= getCompletionOffset();
+                       int end= getCompletionOffset() + getCompletionLength();
+                       
+                       while (start != end && Character.isWhitespace(document.getChar(end - 1)))
+                               end--;
+                       
+                       return end;     
+
+               } catch (BadLocationException e) {
+                       return super.getEnd();
+               }               
+       }
+       
+       /*
+        * @see TemplateContext#evaluate(Template)
+        */
+       @Override
+       public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException {
+               if (!canEvaluate(template))
+                       return null;
+                       
+               TemplateTranslator translator= new TemplateTranslator();
+               TemplateBuffer buffer= translator.translate(template.getPattern());
+
+               getContextType().resolve(buffer, this);
+
+               IPreferenceStore prefs= CUIPlugin.getDefault().getPreferenceStore();
+               boolean useCodeFormatter= prefs.getBoolean(PreferenceConstants.TEMPLATES_USE_CODEFORMATTER);                    
+
+               ICProject project= getCProject();
+               int indentationLevel = isReadOnly() ? 0 : getIndentationLevel();
+               CFormatter formatter= new CFormatter(TextUtilities.getDefaultLineDelimiter(getDocument()), indentationLevel, useCodeFormatter, project);
+               formatter.format(buffer, this);
+               
+               return buffer;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CContextType.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CContextType.java
new file mode 100644 (file)
index 0000000..dd1e243
--- /dev/null
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.corext.template.c;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Position;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+/**
+ * A context type for C/C++ code.
+ */
+public class CContextType extends TranslationUnitContextType {
+
+       public final static String ID = "org.eclipse.cdt.ui.text.templates.c"; //$NON-NLS-1$
+
+       public CContextType() {
+               super();
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.corext.template.c.TranslationUnitContextType#createContext(org.eclipse.jface.text.IDocument, int, int, org.eclipse.cdt.core.model.ITranslationUnit)
+        */
+       @Override
+       public TranslationUnitContext createContext(IDocument document, int offset,
+                       int length, ITranslationUnit translationUnit) {
+               return new CContext(this, document, offset, length, translationUnit);
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.corext.template.c.TranslationUnitContextType#createContext(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.Position, org.eclipse.cdt.core.model.ITranslationUnit)
+        */
+       @Override
+       public TranslationUnitContext createContext(IDocument document,
+                       Position position, ITranslationUnit translationUnit) {
+               return new CContext(this, document, position, translationUnit);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CFormatter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CFormatter.java
new file mode 100644 (file)
index 0000000..6b36e1c
--- /dev/null
@@ -0,0 +1,442 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Qnx Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *     Sergey Prigogin, Google
+ *******************************************************************************/
+package org.eclipse.cdt.internal.corext.template.c;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.BadPositionCategoryException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.TypedPosition;
+import org.eclipse.jface.text.rules.FastPartitioner;
+import org.eclipse.jface.text.templates.DocumentTemplateContext;
+import org.eclipse.jface.text.templates.GlobalTemplateVariables;
+import org.eclipse.jface.text.templates.TemplateBuffer;
+import org.eclipse.jface.text.templates.TemplateContext;
+import org.eclipse.jface.text.templates.TemplateVariable;
+import org.eclipse.text.edits.MalformedTreeException;
+import org.eclipse.text.edits.MultiTextEdit;
+import org.eclipse.text.edits.RangeMarker;
+import org.eclipse.text.edits.ReplaceEdit;
+import org.eclipse.text.edits.TextEdit;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.formatter.CodeFormatter;
+import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
+
+import org.eclipse.cdt.internal.ui.editor.IndentUtil;
+import org.eclipse.cdt.internal.ui.text.FastCPartitionScanner;
+
+
+/**
+ * A template editor using the C/C++ formatter to format a template buffer.
+ */
+public class CFormatter {
+
+       private static final String COMMENT_START= "/*-"; //$NON-NLS-1$
+       private static final String COMMENT_END= "*/"; //$NON-NLS-1$
+
+       /** The line delimiter to use if code formatter is not used. */
+       private final String fLineDelimiter;
+       /** The initial indent level */
+       private final int fInitialIndentLevel;
+       
+       /** Flag indicating whether to use the code formatter or not. */
+       private boolean fUseCodeFormatter;
+       private final ICProject fProject;
+
+       /**
+        * Creates a CFormatter with the target line delimiter.
+        * 
+        * @param lineDelimiter the line delimiter to use
+        * @param initialIndentLevel the initial indentation level
+        * @param useCodeFormatter <code>true</code> if the core code formatter should be used
+        * @param project the C/C++ project from which to get the preferences, or <code>null</code> for workbench settings
+        */
+       public CFormatter(String lineDelimiter, int initialIndentLevel, boolean useCodeFormatter, ICProject project) {
+               fLineDelimiter= lineDelimiter;
+               fUseCodeFormatter= useCodeFormatter;
+               fInitialIndentLevel= initialIndentLevel;
+               fProject= project;
+       }
+
+       /**
+        * Formats the template buffer.
+        * @param buffer
+        * @param context
+        * @throws BadLocationException
+        */
+       public void format(TemplateBuffer buffer, TemplateContext context) throws BadLocationException {
+               try {
+                       VariableTracker tracker= new VariableTracker(buffer);
+                       IDocument document= tracker.getDocument();
+                       
+                       internalFormat(document, context, buffer);
+                       convertLineDelimiters(document);
+                       if (isReplacedAreaEmpty(context))
+                               trimStart(document);
+                       
+                       tracker.updateBuffer();
+               } catch (MalformedTreeException e) {
+                       throw new BadLocationException();
+               }
+       }
+
+       /**
+        * @param document
+        * @param context
+        * @param buffer 
+        * @throws BadLocationException
+        */
+       private void internalFormat(IDocument document, TemplateContext context, TemplateBuffer buffer) throws BadLocationException {
+               if (fUseCodeFormatter) {
+                       // try to format and fall back to indenting
+                       try {
+                               format(document);
+                               return;
+                       } catch (BadLocationException e) {
+                       } catch (MalformedTreeException e) {
+                       }
+               }
+               // fallback: indent
+               indent(document, buffer);
+       }
+
+       private void convertLineDelimiters(IDocument document) throws BadLocationException {
+               int lines= document.getNumberOfLines();
+               for (int line= 0; line < lines; line++) {
+                       IRegion region= document.getLineInformation(line);
+                       String lineDelimiter= document.getLineDelimiter(line);
+                       if (lineDelimiter != null)
+                               document.replace(region.getOffset() + region.getLength(), lineDelimiter.length(), fLineDelimiter);
+               }
+       }
+
+       private void trimStart(IDocument document) throws BadLocationException {
+               trimAtOffset(0, document);
+       }
+
+       private String trimAtOffset(int offset, IDocument document) throws BadLocationException {
+               int i= offset;
+               while ((i < document.getLength()) && Character.isWhitespace(document.getChar(i)))
+                       i++;
+               
+               String trim= document.get(offset, i - offset);
+               document.replace(offset, i - offset, ""); //$NON-NLS-1$
+               return trim;
+       }
+
+       private boolean isReplacedAreaEmpty(TemplateContext context) {
+               if (context instanceof DocumentTemplateContext) {
+                       DocumentTemplateContext dtc= (DocumentTemplateContext) context;
+                       if (dtc.getCompletionLength() == 0) {
+                               return true;
+                       }
+                       try {
+                               if (dtc.getDocument().get(dtc.getStart(), dtc.getEnd() - dtc.getStart()).trim().length() == 0)
+                                       return true;
+                       } catch (BadLocationException x) {
+                               // ignore - this may happen when the document was modified after the initial invocation, and the
+                               // context does not track the changes properly - don't trim in that case
+                               return false;
+                       }
+               }
+               return false;
+       }
+
+       private void format(IDocument doc) throws BadLocationException {
+               Map<String, String> options;
+               if (fProject != null)
+                       options= fProject.getOptions(true); 
+               else
+                       options= CCorePlugin.getOptions();
+               
+               TextEdit edit= CodeFormatterUtil.format(CodeFormatter.K_UNKNOWN, doc.get(), fInitialIndentLevel, fLineDelimiter, options);
+               if (edit == null)
+                       throw new BadLocationException(); // fall back to indenting
+               
+               edit.apply(doc, TextEdit.UPDATE_REGIONS);
+       }
+
+       private void indent(IDocument document, TemplateBuffer buffer) throws BadLocationException, MalformedTreeException {
+               prefixSelectionLines(document, buffer);
+               adjustIndentation(document);
+       }
+
+       /**
+        * Convert leading tabs to correct indentation and add initial indentation level.
+        * 
+        * @param document
+        * @throws BadLocationException 
+        */
+       private void adjustIndentation(IDocument document) throws BadLocationException {
+               int lines= document.getNumberOfLines();
+               if (lines == 0)
+                       return;
+
+               String option;
+               if (fProject == null)
+                       option= CCorePlugin.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
+               else
+                       option= fProject.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, true);
+
+               boolean useSpaces= CCorePlugin.SPACE.equals(option);
+               int indentWidth= CodeFormatterUtil.getIndentWidth(fProject);
+               int tabWidth= CodeFormatterUtil.getTabWidth(fProject);
+               
+               for (int line= 0; line < lines; ++line) {
+                       IRegion lineRegion= document.getLineInformation(line);
+                       String indent= IndentUtil.getCurrentIndent(document, line, false);
+                       int tabs= 0;
+                       for (int i = 0; i < indent.length(); i++) {
+                               if (indent.charAt(i) == '\t') {
+                                       tabs++;
+                               } else {
+                                       break;
+                               }
+                       }
+                       int totalIndentWidth= (fInitialIndentLevel + tabs) * indentWidth + IndentUtil.computeVisualLength(indent.substring(tabs), tabWidth);
+                       String newIndent= IndentUtil.changePrefix("", totalIndentWidth, tabWidth, useSpaces); //$NON-NLS-1$
+                       document.replace(lineRegion.getOffset(), indent.length(), newIndent);
+               }
+       }
+
+       /**
+        * Prefix each line of <code>line_selection</code> substitutions with
+        * the prefix of the first line.
+        * 
+        * @param document
+        * @param buffer
+        */
+       private void prefixSelectionLines(IDocument document, TemplateBuffer buffer) {
+               TemplateVariable[] variables= buffer.getVariables();
+               for (int i = 0; i < variables.length; i++) {
+                       if (variables[i].getName().equals(GlobalTemplateVariables.LineSelection.NAME)) {
+                               if (variables[i].getLength() > 0) {
+                                       final int tabWidth= CodeFormatterUtil.getTabWidth(fProject);
+                                       int delta= 0;
+                                       int[] offsets= variables[i].getOffsets();
+                                       for (int j= 0; j < offsets.length; j++) {
+                                               final int offset = offsets[j] + delta;
+                                               try {
+                                                       int startLine= document.getLineOfOffset(offset);
+                                                       int startOffset= document.getLineOffset(startLine);
+                                                       int endLine= document.getLineOfOffset(offset+variables[i].getLength() - 1);
+                                                       String prefix= document.get(startOffset, offset - startOffset);
+                                                       String shift= trimAtOffset(offset, document);
+                                                       delta -= shift.length();
+                                                       if (startLine < endLine) {
+                                                               int shiftWidth= IndentUtil.computeVisualLength(shift, tabWidth);
+                                                               for (int line= startLine + 1; line <= endLine; ++line) {
+                                                                       String currentIndent= IndentUtil.getCurrentIndent(document, line, false);
+                                                                       int indentWidth= IndentUtil.computeVisualLength(currentIndent, tabWidth);
+                                                                       int newIndentWidth= Math.max(0, indentWidth - shiftWidth);
+                                                                       // replace current indent with prefix + spaces
+                                                                       String newIndent= IndentUtil.changePrefix(prefix, prefix.length() + newIndentWidth, 1, true);
+                                                                       int lineOffset= document.getLineOffset(line);
+                                                                       document.replace(lineOffset, currentIndent.length(), newIndent);
+                                                                       delta -= currentIndent.length();
+                                                                       delta += newIndent.length();
+                                                               }
+                                                       }
+                                               } catch (BadLocationException exc) {
+                                                       break;
+                                               }
+                                       }
+                               }
+                               break;
+                       }
+               }
+       }
+
+       /**
+        * Wraps a {@link TemplateBuffer} and tracks the variable offsets while changes to the buffer
+        * occur. Whitespace variables are also tracked.
+        */
+       private static final class VariableTracker {
+               private static final String CATEGORY= "__template_variables"; //$NON-NLS-1$
+               private Document fDocument;
+               private final TemplateBuffer fBuffer;
+               private List<TypedPosition> fPositions;
+               
+               /**
+                * Creates a new tracker.
+                * 
+                * @param buffer the buffer to track
+                * @throws MalformedTreeException
+                * @throws BadLocationException
+                */
+               public VariableTracker(TemplateBuffer buffer) throws MalformedTreeException, BadLocationException {
+                       Assert.isLegal(buffer != null);
+                       fBuffer= buffer;
+                       fDocument= new Document(fBuffer.getString());
+                       installCStuff(fDocument);
+                       fDocument.addPositionCategory(CATEGORY);
+                       fDocument.addPositionUpdater(new ExclusivePositionUpdater(CATEGORY));
+                       fPositions= createRangeMarkers(fBuffer.getVariables(), fDocument);
+               }
+               
+               /**
+                * Installs a C partitioner with <code>document</code>.
+                *
+                * @param document the document
+                */
+               private static void installCStuff(Document document) {
+                       String[] types= new String[] {
+                                       ICPartitions.C_MULTI_LINE_COMMENT,
+                                       ICPartitions.C_SINGLE_LINE_COMMENT,
+                                       ICPartitions.C_STRING,
+                                       ICPartitions.C_CHARACTER,
+                                       ICPartitions.C_PREPROCESSOR,
+                                       IDocument.DEFAULT_CONTENT_TYPE
+                       };
+                       FastPartitioner partitioner= new FastPartitioner(new FastCPartitionScanner(), types);
+                       partitioner.connect(document);
+                       document.setDocumentPartitioner(ICPartitions.C_PARTITIONING, partitioner);
+               }
+               
+               /**
+                * Returns the document with the buffer contents. Whitespace variables are decorated with
+                * comments.
+                * 
+                * @return the buffer document
+                */
+               public IDocument getDocument() {
+                       checkState();
+                       return fDocument;
+               }
+               
+               private void checkState() {
+                       if (fDocument == null)
+                               throw new IllegalStateException();
+               }
+
+               /**
+                * Restores any decorated regions and updates the buffer's variable offsets.
+                * 
+                * @return the buffer.
+                * @throws MalformedTreeException
+                * @throws BadLocationException
+                */
+               public TemplateBuffer updateBuffer() throws MalformedTreeException, BadLocationException {
+                       checkState();
+                       TemplateVariable[] variables= fBuffer.getVariables();
+                       try {
+                               removeRangeMarkers(fPositions, fDocument, variables);
+                       } catch (BadPositionCategoryException x) {
+                               Assert.isTrue(false);
+                       }
+                       fBuffer.setContent(fDocument.get(), variables);
+                       fDocument= null;
+                       
+                       return fBuffer;
+               }
+               
+               private List<TypedPosition> createRangeMarkers(TemplateVariable[] variables, IDocument document) throws MalformedTreeException, BadLocationException {
+                       Map<ReplaceEdit, String> markerToOriginal= new HashMap<ReplaceEdit, String>();
+                       
+                       MultiTextEdit root= new MultiTextEdit(0, document.getLength());
+                       List<TextEdit> edits= new ArrayList<TextEdit>();
+                       boolean hasModifications= false;
+                       for (int i= 0; i != variables.length; i++) {
+                               final TemplateVariable variable= variables[i];
+                               int[] offsets= variable.getOffsets();
+                               
+                               String value= variable.getDefaultValue();
+                               if (isWhitespaceVariable(value)) {
+                                       // replace whitespace positions with unformattable comments
+                                       String placeholder= COMMENT_START + value + COMMENT_END;
+                                       for (int j= 0; j != offsets.length; j++) {
+                                               ReplaceEdit replace= new ReplaceEdit(offsets[j], value.length(), placeholder);
+                                               root.addChild(replace);
+                                               hasModifications= true;
+                                               markerToOriginal.put(replace, value);
+                                               edits.add(replace);
+                                       }
+                               } else {
+                                       for (int j= 0; j != offsets.length; j++) {
+                                               RangeMarker marker= new RangeMarker(offsets[j], value.length());
+                                               root.addChild(marker);
+                                               edits.add(marker);
+                                       }
+                               }
+                       }
+                       
+                       if (hasModifications) {
+                               // update the document and convert the replaces to markers
+                               root.apply(document, TextEdit.UPDATE_REGIONS);
+                       }
+                       
+                       List<TypedPosition> positions= new ArrayList<TypedPosition>();
+                       for (Iterator<TextEdit> it= edits.iterator(); it.hasNext();) {
+                               TextEdit edit= it.next();
+                               try {
+                                       // abuse TypedPosition to piggy back the original contents of the position
+                                       final TypedPosition pos= new TypedPosition(edit.getOffset(), edit.getLength(), markerToOriginal.get(edit));
+                                       document.addPosition(CATEGORY, pos);
+                                       positions.add(pos);
+                               } catch (BadPositionCategoryException x) {
+                                       Assert.isTrue(false);
+                               }
+                       }
+                       
+                       return positions;
+               }
+               
+               private boolean isWhitespaceVariable(String value) {
+                       int length= value.length();
+                       return length == 0 || value.trim().length() == 0;
+               }
+               
+               private void removeRangeMarkers(List<TypedPosition> positions, IDocument document, TemplateVariable[] variables) throws MalformedTreeException, BadLocationException, BadPositionCategoryException {
+                       
+                       // revert previous changes
+                       for (Iterator<TypedPosition> it= positions.iterator(); it.hasNext();) {
+                               TypedPosition position= it.next();
+                               // remove and re-add in order to not confuse ExclusivePositionUpdater
+                               document.removePosition(CATEGORY, position);
+                               final String original= position.getType();
+                               if (original != null) {
+                                       document.replace(position.getOffset(), position.getLength(), original);
+                                       position.setLength(original.length());
+                               }
+                               document.addPosition(position);
+                       }
+                       
+                       Iterator<TypedPosition> it= positions.iterator();
+                       for (int i= 0; i != variables.length; i++) {
+                               TemplateVariable variable= variables[i];
+
+                               int[] offsets= new int[variable.getOffsets().length];
+                               for (int j= 0; j != offsets.length; j++)
+                                       offsets[j]= it.next().getOffset();
+
+                               variable.setOffsets(offsets);   
+                       }
+
+               }
+       }
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CodeTemplateContext.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CodeTemplateContext.java
new file mode 100644 (file)
index 0000000..9d7dcd5
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.corext.template.c;
+
+import org.eclipse.core.resources.IFile;
+
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+/**
+ * A template context for C/C++ code and comment.
+ *
+ * @since 5.0
+ */
+public class CodeTemplateContext extends FileTemplateContext {
+       private ICProject fProject;
+
+       public CodeTemplateContext(String contextTypeId, ICProject project, String lineDelimiter) {
+               super(contextTypeId, lineDelimiter);
+               fProject= project;
+       }
+
+       public ICProject getCProject() {
+               return fProject;
+       }
+
+       public void setTranslationUnitVariables(ITranslationUnit tu) {
+               IFile file= (IFile) tu.getResource();
+               if (file != null) {
+                       super.setResourceVariables(file);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CodeTemplateContextType.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CodeTemplateContextType.java
new file mode 100644 (file)
index 0000000..2d1270c
--- /dev/null
@@ -0,0 +1,275 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.corext.template.c;
+
+import org.eclipse.jface.text.templates.ContextTypeRegistry;
+import org.eclipse.jface.text.templates.TemplateContext;
+import org.eclipse.jface.text.templates.TemplateException;
+import org.eclipse.jface.text.templates.TemplateVariableResolver;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.ICProject;
+
+import org.eclipse.cdt.internal.corext.codemanipulation.StubUtility;
+
+public class CodeTemplateContextType extends FileTemplateContextType {
+       /* Context types */
+       private static final String CONTEXTTYPE_PREFIX= "org.eclipse.cdt.ui.text.codetemplates."; //$NON-NLS-1$
+
+       public static final String CPPSOURCEFILE_CONTEXTTYPE= CCorePlugin.CONTENT_TYPE_CXXSOURCE + FileTemplateContextType.CONTEXTTYPE_SUFFIX;
+       public static final String CPPHEADERFILE_CONTEXTTYPE= CCorePlugin.CONTENT_TYPE_CXXHEADER + FileTemplateContextType.CONTEXTTYPE_SUFFIX;
+       public static final String CSOURCEFILE_CONTEXTTYPE= CCorePlugin.CONTENT_TYPE_CSOURCE + FileTemplateContextType.CONTEXTTYPE_SUFFIX;
+       public static final String CHEADERFILE_CONTEXTTYPE= CCorePlugin.CONTENT_TYPE_CHEADER + FileTemplateContextType.CONTEXTTYPE_SUFFIX;
+       public static final String ASMSOURCEFILE_CONTEXTTYPE= CCorePlugin.CONTENT_TYPE_ASMSOURCE + FileTemplateContextType.CONTEXTTYPE_SUFFIX;
+
+       public static final String NAMESPACE_CONTEXTTYPE= CONTEXTTYPE_PREFIX + "namespace_context"; //$NON-NLS-1$
+       public static final String CLASS_BODY_CONTEXTTYPE= CONTEXTTYPE_PREFIX + "class_context"; //$NON-NLS-1$
+       public static final String CONSTRUCTORBODY_CONTEXTTYPE= CONTEXTTYPE_PREFIX + "constructorbody_context"; //$NON-NLS-1$
+       public static final String DESTRUCTORBODY_CONTEXTTYPE= CONTEXTTYPE_PREFIX + "destructorbody_context"; //$NON-NLS-1$
+       public static final String METHODBODY_CONTEXTTYPE= CONTEXTTYPE_PREFIX + "methodbody_context"; //$NON-NLS-1$
+       public static final String FILECOMMENT_CONTEXTTYPE= CONTEXTTYPE_PREFIX + "filecomment_context"; //$NON-NLS-1$
+       public static final String TYPECOMMENT_CONTEXTTYPE= CONTEXTTYPE_PREFIX + "typecomment_context"; //$NON-NLS-1$
+       public static final String FIELDCOMMENT_CONTEXTTYPE= CONTEXTTYPE_PREFIX + "fieldcomment_context"; //$NON-NLS-1$
+       public static final String METHODCOMMENT_CONTEXTTYPE= CONTEXTTYPE_PREFIX + "methodcomment_context"; //$NON-NLS-1$
+       public static final String CONSTRUCTORCOMMENT_CONTEXTTYPE= CONTEXTTYPE_PREFIX + "constructorcomment_context"; //$NON-NLS-1$
+       public static final String DESTRUCTORCOMMENT_CONTEXTTYPE= CONTEXTTYPE_PREFIX + "destructorcomment_context"; //$NON-NLS-1$
+
+       /* Templates */
+       private static final String CODETEMPLATES_PREFIX= "org.eclipse.cdt.ui.text.codetemplates."; //$NON-NLS-1$
+       public static final String COMMENT_SUFFIX= "comment"; //$NON-NLS-1$
+       
+       public static final String ASM_SOURCEFILE_ID= CODETEMPLATES_PREFIX + "asmsourcefile"; //$NON-NLS-1$     
+       public static final String CPP_SOURCEFILE_ID= CODETEMPLATES_PREFIX + "cppsourcefile"; //$NON-NLS-1$     
+       public static final String CPP_HEADERFILE_ID= CODETEMPLATES_PREFIX + "cppheaderfile"; //$NON-NLS-1$     
+       public static final String CPP_TESTFILE_ID= CODETEMPLATES_PREFIX + "cpptestfile"; //$NON-NLS-1$ 
+       public static final String C_SOURCEFILE_ID= CODETEMPLATES_PREFIX + "csourcefile"; //$NON-NLS-1$ 
+       public static final String C_HEADERFILE_ID= CODETEMPLATES_PREFIX + "cheaderfile"; //$NON-NLS-1$ 
+       public static final String NAMESPACE_BEGIN_ID= CODETEMPLATES_PREFIX + "namespace_begin"; //$NON-NLS-1$  
+       public static final String NAMESPACE_END_ID= CODETEMPLATES_PREFIX + "namespace_end"; //$NON-NLS-1$      
+       public static final String CLASS_BODY_ID= CODETEMPLATES_PREFIX + "class_body"; //$NON-NLS-1$    
+       public static final String METHODSTUB_ID= CODETEMPLATES_PREFIX + "methodbody"; //$NON-NLS-1$    
+       public static final String CONSTRUCTORSTUB_ID= CODETEMPLATES_PREFIX + "constructorbody"; //$NON-NLS-1$
+       public static final String DESTRUCTORSTUB_ID= CODETEMPLATES_PREFIX + "destructorbody"; //$NON-NLS-1$
+       public static final String FILECOMMENT_ID= CODETEMPLATES_PREFIX + "file" + COMMENT_SUFFIX; //$NON-NLS-1$
+       public static final String TYPECOMMENT_ID= CODETEMPLATES_PREFIX + "type" + COMMENT_SUFFIX; //$NON-NLS-1$
+       public static final String FIELDCOMMENT_ID= CODETEMPLATES_PREFIX + "field" + COMMENT_SUFFIX; //$NON-NLS-1$
+       public static final String METHODCOMMENT_ID= CODETEMPLATES_PREFIX + "method" + COMMENT_SUFFIX; //$NON-NLS-1$
+       public static final String CONSTRUCTORCOMMENT_ID= CODETEMPLATES_PREFIX + "constructor" + COMMENT_SUFFIX; //$NON-NLS-1$
+       public static final String DESTRUCTORCOMMENT_ID= CODETEMPLATES_PREFIX + "destructor" + COMMENT_SUFFIX; //$NON-NLS-1$
+
+       /* Resolver types */
+       public static final String ENCLOSING_METHOD= "enclosing_method"; //$NON-NLS-1$
+       public static final String ENCLOSING_TYPE= "enclosing_type"; //$NON-NLS-1$
+       public static final String BODY_STATEMENT= "body_statement"; //$NON-NLS-1$
+       public static final String FIELD= "field"; //$NON-NLS-1$
+       public static final String FIELD_TYPE= "field_type"; //$NON-NLS-1$
+
+       public static final String RETURN_TYPE= "return_type"; //$NON-NLS-1$
+
+       public static final String TYPENAME= "type_name"; //$NON-NLS-1$
+       public static final String NAMESPACE_NAME= "namespace_name"; //$NON-NLS-1$
+       public static final String BASE_CLASSES= "base_classes"; //$NON-NLS-1$
+       public static final String INCLUDE_GUARD_SYMBOL= "include_guard_symbol"; //$NON-NLS-1$
+
+       public static final String DECLARATIONS= "declarations"; //$NON-NLS-1$
+       public static final String TYPE_COMMENT= "typecomment"; //$NON-NLS-1$
+       public static final String FILE_COMMENT= "filecomment"; //$NON-NLS-1$
+       public static final String INCLUDES= "includes"; //$NON-NLS-1$
+       public static final String NAMESPACE_BEGIN= "namespace_begin"; //$NON-NLS-1$
+       public static final String NAMESPACE_END= "namespace_end"; //$NON-NLS-1$
+
+       /**
+        * Resolver that resolves to the variable defined in the context.
+        */
+       public static class CodeTemplateVariableResolver extends FileTemplateVariableResolver {
+               public CodeTemplateVariableResolver(String type, String description) {
+                       super(type, description);
+               }
+       }
+
+       /**
+        * Resolver for task tags.
+        */
+       protected static class Todo extends TemplateVariableResolver {
+               public Todo() {
+                       super("todo", TemplateMessages.CodeTemplateContextType_variable_description_todo);  //$NON-NLS-1$
+               }
+
+               @Override
+               protected String resolve(TemplateContext context) {
+                       ICProject cProject = null;
+                       if (context instanceof CodeTemplateContext) {
+                               cProject = ((CodeTemplateContext) context).getCProject();
+                       }
+                       String todoTaskTag= StubUtility.getTodoTaskTag(cProject);
+                       if (todoTaskTag == null)
+                               return "XXX"; //$NON-NLS-1$
+
+                       return todoTaskTag;
+               }
+       }
+
+       private boolean fIsComment;
+
+       public CodeTemplateContextType(String contextTypeId) {
+               this(contextTypeId, contextTypeId);
+       }
+
+       public CodeTemplateContextType(String contextTypeId, String contextName) {
+               super(contextTypeId, contextName);
+
+               fIsComment= false;
+
+               // global
+               addResolver(new Todo());
+
+               if (CPPSOURCEFILE_CONTEXTTYPE.equals(contextTypeId)) {
+                       addResolver(new CodeTemplateVariableResolver(DECLARATIONS, TemplateMessages.CodeTemplateContextType_variable_description_typedeclaration)); 
+                       addResolver(new CodeTemplateVariableResolver(FILE_COMMENT, TemplateMessages.CodeTemplateContextType_variable_description_filecomment)); 
+                       addResolver(new CodeTemplateVariableResolver(INCLUDES, TemplateMessages.CodeTemplateContextType_variable_description_includes)); 
+                       addResolver(new CodeTemplateVariableResolver(NAMESPACE_BEGIN, TemplateMessages.CodeTemplateContextType_variable_description_namespace_begin)); 
+                       addResolver(new CodeTemplateVariableResolver(NAMESPACE_END, TemplateMessages.CodeTemplateContextType_variable_description_namespace_end)); 
+                       addResolver(new CodeTemplateVariableResolver(NAMESPACE_NAME, TemplateMessages.CodeTemplateContextType_variable_description_namespace_name)); 
+                       addResolver(new CodeTemplateVariableResolver(TYPE_COMMENT, TemplateMessages.CodeTemplateContextType_variable_description_typecomment)); 
+                       addResolver(new CodeTemplateVariableResolver(TYPENAME, TemplateMessages.CodeTemplateContextType_variable_description_class_name));
+                       addTranslationUnitVariables();
+               } else if (CPPHEADERFILE_CONTEXTTYPE.equals(contextTypeId)) {
+                       addResolver(new CodeTemplateVariableResolver(DECLARATIONS, TemplateMessages.CodeTemplateContextType_variable_description_typedeclaration)); 
+                       addResolver(new CodeTemplateVariableResolver(FILE_COMMENT, TemplateMessages.CodeTemplateContextType_variable_description_filecomment)); 
+                       addResolver(new CodeTemplateVariableResolver(INCLUDE_GUARD_SYMBOL, TemplateMessages.CodeTemplateContextType_variable_description_include_guard_symbol)); 
+                       addResolver(new CodeTemplateVariableResolver(INCLUDES, TemplateMessages.CodeTemplateContextType_variable_description_includes)); 
+                       addResolver(new CodeTemplateVariableResolver(NAMESPACE_BEGIN, TemplateMessages.CodeTemplateContextType_variable_description_namespace_begin)); 
+                       addResolver(new CodeTemplateVariableResolver(NAMESPACE_END, TemplateMessages.CodeTemplateContextType_variable_description_namespace_end)); 
+                       addResolver(new CodeTemplateVariableResolver(NAMESPACE_NAME, TemplateMessages.CodeTemplateContextType_variable_description_namespace_name)); 
+                       addResolver(new CodeTemplateVariableResolver(TYPE_COMMENT, TemplateMessages.CodeTemplateContextType_variable_description_typecomment)); 
+                       addResolver(new CodeTemplateVariableResolver(TYPENAME, TemplateMessages.CodeTemplateContextType_variable_description_class_name));
+                       addTranslationUnitVariables();
+               } else if (CSOURCEFILE_CONTEXTTYPE.equals(contextTypeId)) {
+                       addResolver(new CodeTemplateVariableResolver(DECLARATIONS, TemplateMessages.CodeTemplateContextType_variable_description_typedeclaration)); 
+                       addResolver(new CodeTemplateVariableResolver(FILE_COMMENT, TemplateMessages.CodeTemplateContextType_variable_description_filecomment)); 
+                       addResolver(new CodeTemplateVariableResolver(INCLUDES, TemplateMessages.CodeTemplateContextType_variable_description_includes)); 
+                       addTranslationUnitVariables();
+               } else if (CHEADERFILE_CONTEXTTYPE.equals(contextTypeId)) {
+                       addResolver(new CodeTemplateVariableResolver(DECLARATIONS, TemplateMessages.CodeTemplateContextType_variable_description_typedeclaration)); 
+                       addResolver(new CodeTemplateVariableResolver(FILE_COMMENT, TemplateMessages.CodeTemplateContextType_variable_description_filecomment)); 
+                       addResolver(new CodeTemplateVariableResolver(INCLUDE_GUARD_SYMBOL, TemplateMessages.CodeTemplateContextType_variable_description_include_guard_symbol)); 
+                       addResolver(new CodeTemplateVariableResolver(INCLUDES, TemplateMessages.CodeTemplateContextType_variable_description_includes)); 
+                       addTranslationUnitVariables();
+               } else if (METHODBODY_CONTEXTTYPE.equals(contextTypeId)) {
+                       addResolver(new CodeTemplateVariableResolver(BODY_STATEMENT, TemplateMessages.CodeTemplateContextType_variable_description_bodystatement)); 
+                       addResolver(new CodeTemplateVariableResolver(ENCLOSING_METHOD, TemplateMessages.CodeTemplateContextType_variable_description_enclosingmethod)); 
+                       addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE, TemplateMessages.CodeTemplateContextType_variable_description_enclosingtype)); 
+               } else if (CONSTRUCTORBODY_CONTEXTTYPE.equals(contextTypeId)) {
+                       addResolver(new CodeTemplateVariableResolver(BODY_STATEMENT, TemplateMessages.CodeTemplateContextType_variable_description_bodystatement)); 
+                       addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE, TemplateMessages.CodeTemplateContextType_variable_description_enclosingtype)); 
+               } else if (DESTRUCTORBODY_CONTEXTTYPE.equals(contextTypeId)) {
+                       addResolver(new CodeTemplateVariableResolver(BODY_STATEMENT, TemplateMessages.CodeTemplateContextType_variable_description_bodystatement)); 
+                       addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE, TemplateMessages.CodeTemplateContextType_variable_description_enclosingtype)); 
+               } else if (CLASS_BODY_CONTEXTTYPE.equals(contextTypeId)) {
+                       addResolver(new CodeTemplateVariableResolver(DECLARATIONS, TemplateMessages.CodeTemplateContextType_variable_description_class_members)); 
+                       addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE, TemplateMessages.CodeTemplateContextType_variable_description_class_name)); 
+               } else if (NAMESPACE_CONTEXTTYPE.equals(contextTypeId)) {
+                       addResolver(new CodeTemplateVariableResolver(NAMESPACE_BEGIN, TemplateMessages.CodeTemplateContextType_variable_description_namespace_begin)); 
+                       addResolver(new CodeTemplateVariableResolver(NAMESPACE_END, TemplateMessages.CodeTemplateContextType_variable_description_namespace_end)); 
+                       addResolver(new CodeTemplateVariableResolver(NAMESPACE_NAME, TemplateMessages.CodeTemplateContextType_variable_description_namespace_name)); 
+               } else if (TYPECOMMENT_CONTEXTTYPE.equals(contextTypeId)) {
+                       addResolver(new CodeTemplateVariableResolver(TYPENAME, TemplateMessages.CodeTemplateContextType_variable_description_typename)); 
+                       addTranslationUnitVariables();
+                       fIsComment= true;
+               } else if (FILECOMMENT_CONTEXTTYPE.equals(contextTypeId)) {
+                       addTranslationUnitVariables();
+                       fIsComment= true;
+               } else if (FIELDCOMMENT_CONTEXTTYPE.equals(contextTypeId)) {
+                       addResolver(new CodeTemplateVariableResolver(FIELD, TemplateMessages.CodeTemplateContextType_variable_description_fieldname)); 
+                       addResolver(new CodeTemplateVariableResolver(FIELD_TYPE, TemplateMessages.CodeTemplateContextType_variable_description_fieldtype)); 
+                       addTranslationUnitVariables();
+                       fIsComment= true;
+               } else if (METHODCOMMENT_CONTEXTTYPE.equals(contextTypeId)) {
+                       addResolver(new CodeTemplateVariableResolver(ENCLOSING_METHOD, TemplateMessages.CodeTemplateContextType_variable_description_enclosingmethod)); 
+                       addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE, TemplateMessages.CodeTemplateContextType_variable_description_enclosingtype)); 
+                       addResolver(new CodeTemplateVariableResolver(RETURN_TYPE, TemplateMessages.CodeTemplateContextType_variable_description_returntype)); 
+                       addTranslationUnitVariables();
+                       fIsComment= true;
+               } else if (CONSTRUCTORCOMMENT_CONTEXTTYPE.equals(contextTypeId)) {
+                       addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE, TemplateMessages.CodeTemplateContextType_variable_description_enclosingtype)); 
+                       addTranslationUnitVariables();
+                       fIsComment= true;
+               } else if (DESTRUCTORCOMMENT_CONTEXTTYPE.equals(contextTypeId)) {
+                       addResolver(new CodeTemplateVariableResolver(ENCLOSING_TYPE, TemplateMessages.CodeTemplateContextType_variable_description_enclosingtype)); 
+                       addTranslationUnitVariables();
+                       fIsComment= true;
+               } else {
+                       addTranslationUnitVariables();
+               }
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.corext.template.c.FileTemplateContextType#addResourceVariables()
+        */
+       @Override
+       protected void addResourceVariables() {
+               // don't add resource variables by default
+       }
+
+       private void addTranslationUnitVariables() {
+               super.addResourceVariables();
+       }
+
+       public static void registerContextTypes(ContextTypeRegistry registry) {
+               registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CPPSOURCEFILE_CONTEXTTYPE, TemplateMessages.CodeTemplateContextType_cppsource_name));
+               registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CPPHEADERFILE_CONTEXTTYPE, TemplateMessages.CodeTemplateContextType_cppheader_name));
+               registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CSOURCEFILE_CONTEXTTYPE, TemplateMessages.CodeTemplateContextType_csource_name));
+               registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CHEADERFILE_CONTEXTTYPE, TemplateMessages.CodeTemplateContextType_cheader_name));
+               FileTemplateContextType asmContextType= new FileTemplateContextType(CodeTemplateContextType.ASMSOURCEFILE_CONTEXTTYPE, TemplateMessages.CodeTemplateContextType_asmsource_name);
+               asmContextType.addResolver(new CodeTemplateVariableResolver(FILE_COMMENT, TemplateMessages.CodeTemplateContextType_variable_description_filecomment));
+               registry.addContextType(asmContextType);
+
+               registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.NAMESPACE_CONTEXTTYPE));
+               registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CLASS_BODY_CONTEXTTYPE));
+               registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CONSTRUCTORBODY_CONTEXTTYPE));
+               registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.DESTRUCTORBODY_CONTEXTTYPE));
+               registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.METHODBODY_CONTEXTTYPE));
+
+               registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.FILECOMMENT_CONTEXTTYPE));
+               registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.TYPECOMMENT_CONTEXTTYPE));
+               registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.FIELDCOMMENT_CONTEXTTYPE));
+               registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.METHODCOMMENT_CONTEXTTYPE));
+               registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CONSTRUCTORCOMMENT_CONTEXTTYPE));
+               registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.DESTRUCTORCOMMENT_CONTEXTTYPE));
+       }
+
+       @Override
+       public void validate(String pattern) throws TemplateException {
+               super.validate(pattern);
+               if (fIsComment) {
+                       if (!isValidComment(pattern)) {
+                               throw new TemplateException(TemplateMessages.CodeTemplateContextType_validate_invalidcomment); 
+                       }
+               }
+       }
+
+       private boolean isValidComment(String template) {
+//             IScanner scanner= ToolFactory.createScanner(true, false, false, false);
+//             scanner.setSource(template.toCharArray());
+//             try {
+//                     int next= scanner.getNextToken();
+//                     while (TokenScanner.isComment(next)) {
+//                             next= scanner.getNextToken();
+//                     }
+//                     return next == ITerminalSymbols.TokenNameEOF;
+//             } catch (InvalidInputException e) {
+//             }
+//             return false;
+               return true;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CommentContext.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CommentContext.java
new file mode 100644 (file)
index 0000000..dd75f07
--- /dev/null
@@ -0,0 +1,149 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.corext.template.c;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.text.templates.Template;
+import org.eclipse.jface.text.templates.TemplateBuffer;
+import org.eclipse.jface.text.templates.TemplateContextType;
+import org.eclipse.jface.text.templates.TemplateException;
+import org.eclipse.jface.text.templates.TemplateTranslator;
+
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+/**
+ * A context for (block) comments.
+ *
+ * @since 4.0
+ */
+public class CommentContext extends TranslationUnitContext {
+
+       /**
+        * Creates a comment template context.
+        * 
+        * @param type the context type.
+        * @param document the document.
+        * @param completionOffset the completion offset within the document.
+        * @param completionLength the completion length within the document.
+        * @param translationUnit the translation unit (may be <code>null</code>).
+        */
+       public CommentContext(TemplateContextType type, IDocument document,
+                       int completionOffset, int completionLength, ITranslationUnit translationUnit) {
+               super(type, document, completionOffset, completionLength, translationUnit);
+       }
+
+       /**
+        * Creates a comment template context.
+        * 
+        * @param type the context type.
+        * @param document the document.
+        * @param completionPosition the completion position within the document
+        * @param translationUnit the translation unit (may be <code>null</code>).
+        */
+       public CommentContext(TemplateContextType type, IDocument document,
+                       Position completionPosition, ITranslationUnit translationUnit) {
+               super(type, document, completionPosition, translationUnit);
+       }
+
+       /*
+        * @see DocumentTemplateContext#getStart()
+        */ 
+       @Override
+       public int getStart() {
+               if (fIsManaged && getCompletionLength() > 0)
+                       return super.getStart();
+               
+               try {
+                       IDocument document= getDocument();
+
+                       if (getCompletionLength() == 0) {
+                               int start= getCompletionOffset();
+               
+                               while ((start != 0) && !Character.isWhitespace(document.getChar(start - 1)))
+                                       start--;
+                               
+                               if ((start != 0) && !Character.isWhitespace(document.getChar(start - 1)))
+                                       start--;
+               
+                               return start;
+                               
+                       } 
+
+                       int start= getCompletionOffset();
+                       int end= getCompletionOffset() + getCompletionLength();
+                       
+                       while (start != 0 && !Character.isWhitespace(document.getChar(start - 1)))
+                               start--;
+                       
+                       while (start != end && Character.isWhitespace(document.getChar(start)))
+                               start++;
+                       
+                       if (start == end)
+                               start= getCompletionOffset();   
+                       
+                       return start;                                   
+                       
+
+               } catch (BadLocationException e) {
+                       return getCompletionOffset();   
+               }
+       }
+
+       /*
+        * @see org.eclipse.jdt.internal.corext.template.DocumentTemplateContext#getEnd()
+        */
+       @Override
+       public int getEnd() {
+               if (fIsManaged || getCompletionLength() == 0)           
+                       return super.getEnd();
+
+               try {                   
+                       IDocument document= getDocument();
+
+                       int start= getCompletionOffset();
+                       int end= getCompletionOffset() + getCompletionLength();
+                       
+                       while (start != end && Character.isWhitespace(document.getChar(end - 1)))
+                               end--;
+                       
+                       return end;     
+
+               } catch (BadLocationException e) {
+                       return super.getEnd();
+               }               
+       }
+
+       /*
+        * @see TemplateContext#evaluate(Template)
+        */
+       @Override
+       public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException {
+               TemplateTranslator translator= new TemplateTranslator();
+               TemplateBuffer buffer= translator.translate(template);
+
+               getContextType().resolve(buffer, this);
+               
+               // don't use code formatter for comment templates
+               boolean useCodeFormatter= false;
+
+               ICProject project= getCProject();
+               CFormatter formatter= new CFormatter(TextUtilities.getDefaultLineDelimiter(getDocument()), getIndentationLevel(), useCodeFormatter, project);
+               formatter.format(buffer, this);
+                       
+               return buffer;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CommentContextType.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/CommentContextType.java
new file mode 100644 (file)
index 0000000..f7c83f5
--- /dev/null
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.corext.template.c;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Position;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+/**
+ * A context type for comments.
+ *
+ * @since 4.0
+ */
+public class CommentContextType extends TranslationUnitContextType {
+
+       public static final String ID= "org.eclipse.cdt.ui.text.templates.comment"; //$NON-NLS-1$
+
+       /**
+        * Creates a comment context type.
+        */
+       public CommentContextType() {
+               super();
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.corext.template.c.TranslationUnitContextType#createContext(org.eclipse.jface.text.IDocument, int, int, org.eclipse.cdt.core.model.ITranslationUnit)
+        */
+       @Override
+       public TranslationUnitContext createContext(IDocument document, int offset,
+                       int length, ITranslationUnit translationUnit) {
+               return new CommentContext(this, document, offset, length, translationUnit);
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.corext.template.c.TranslationUnitContextType#createContext(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.Position, org.eclipse.cdt.core.model.ITranslationUnit)
+        */
+       @Override
+       public TranslationUnitContext createContext(IDocument document,
+                       Position position, ITranslationUnit translationUnit) {
+               return new CommentContext(this, document, position, translationUnit);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/DocCommentContextType.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/DocCommentContextType.java
new file mode 100644 (file)
index 0000000..e164bff
--- /dev/null
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.corext.template.c;
+
+/**
+ * A context type for documentation comments.
+ *
+ * @since 5.1
+ */
+public class DocCommentContextType extends CommentContextType {
+
+       @SuppressWarnings("hiding")
+       public static final String ID= "org.eclipse.cdt.ui.text.templates.doccomment"; //$NON-NLS-1$
+
+       public DocCommentContextType() {
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/ExclusivePositionUpdater.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/ExclusivePositionUpdater.java
new file mode 100644 (file)
index 0000000..758f6eb
--- /dev/null
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin, Google
+ *******************************************************************************/
+package org.eclipse.cdt.internal.corext.template.c;
+
+import org.eclipse.jface.text.BadPositionCategoryException;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IPositionUpdater;
+import org.eclipse.jface.text.Position;
+
+/**
+ * Position updater that takes any changes at the borders of a position to not belong to the position.
+ */
+final class ExclusivePositionUpdater implements IPositionUpdater {
+
+       /** The position category. */
+       private final String fCategory;
+
+       /**
+        * Creates a new updater for the given <code>category</code>.
+        *
+        * @param category the new category.
+        */
+       public ExclusivePositionUpdater(String category) {
+               fCategory= category;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.IPositionUpdater#update(org.eclipse.jface.text.DocumentEvent)
+        */
+       public void update(DocumentEvent event) {
+
+               int eventOffset= event.getOffset();
+               int eventOldLength= event.getLength();
+               int eventNewLength= event.getText() == null ? 0 : event.getText().length();
+               int deltaLength= eventNewLength - eventOldLength;
+
+               try {
+                       Position[] positions= event.getDocument().getPositions(fCategory);
+
+                       for (int i= 0; i != positions.length; i++) {
+
+                               Position position= positions[i];
+
+                               if (position.isDeleted())
+                                       continue;
+
+                               int offset= position.getOffset();
+                               int length= position.getLength();
+                               int end= offset + length;
+
+                               if (offset >= eventOffset + eventOldLength)
+                                       // position comes
+                                       // after change - shift
+                                       position.setOffset(offset + deltaLength);
+                               else if (end <= eventOffset) {
+                                       // position comes way before change -
+                                       // leave alone
+                               } else if (offset <= eventOffset && end >= eventOffset + eventOldLength) {
+                                       // event completely internal to the position - adjust length
+                                       position.setLength(length + deltaLength);
+                               } else if (offset < eventOffset) {
+                                       // event extends over end of position - adjust length
+                                       int newEnd= eventOffset;
+                                       position.setLength(newEnd - offset);
+                               } else if (end > eventOffset + eventOldLength) {
+                                       // event extends from before position into it - adjust offset
+                                       // and length
+                                       // offset becomes end of event, length adjusted accordingly
+                                       int newOffset= eventOffset + eventNewLength;
+                                       position.setOffset(newOffset);
+                                       position.setLength(end - newOffset + deltaLength);
+                               } else {
+                                       // event consumes the position - delete it
+                                       position.delete();
+                               }
+                       }
+               } catch (BadPositionCategoryException e) {
+                       // ignore and return
+               }
+       }
+
+       /**
+        * Returns the position category.
+        *
+        * @return the position category
+        */
+       public String getCategory() {
+               return fCategory;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/FileTemplateContext.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/FileTemplateContext.java
new file mode 100644 (file)
index 0000000..fca3a09
--- /dev/null
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.corext.template.c;
+
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DefaultLineTracker;
+import org.eclipse.jface.text.ILineTracker;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.templates.Template;
+import org.eclipse.jface.text.templates.TemplateBuffer;
+import org.eclipse.jface.text.templates.TemplateContext;
+import org.eclipse.jface.text.templates.TemplateException;
+import org.eclipse.jface.text.templates.TemplateTranslator;
+import org.eclipse.jface.text.templates.TemplateVariableResolver;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * A template context for plain file resources.
+ *
+ * @since 5.0
+ */
+public class FileTemplateContext extends TemplateContext {
+
+       private String fLineDelimiter;
+
+       public FileTemplateContext(String contextTypeId, String lineDelimiter) {
+               super(CUIPlugin.getDefault().getCodeTemplateContextRegistry().getContextType(contextTypeId));
+               fLineDelimiter= lineDelimiter;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.templates.TemplateContext#evaluate(org.eclipse.jface.text.templates.Template)
+        */
+       @Override
+       public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException {
+               // test that all variables are defined
+               Iterator<?> iterator= getContextType().resolvers();
+               while (iterator.hasNext()) {
+                       TemplateVariableResolver var= (TemplateVariableResolver) iterator.next();
+                       if (var.getClass() == FileTemplateContextType.FileTemplateVariableResolver.class) {
+                               Assert.isNotNull(getVariable(var.getType()), "Variable " + var.getType() + " not defined"); //$NON-NLS-1$ //$NON-NLS-2$
+                       }
+               }
+
+               if (!canEvaluate(template))
+                       return null;
+                       
+               String pattern= changeLineDelimiter(template.getPattern(), fLineDelimiter);
+               
+               TemplateTranslator translator= new TemplateTranslator();
+               TemplateBuffer buffer= translator.translate(pattern);
+               getContextType().resolve(buffer, this);
+               return buffer;
+       }
+       
+       private static String changeLineDelimiter(String code, String lineDelim) {
+               try {
+                       ILineTracker tracker= new DefaultLineTracker();
+                       tracker.set(code);
+                       int nLines= tracker.getNumberOfLines();
+                       if (nLines == 1) {
+                               return code;
+                       }
+                       
+                       StringBuffer buf= new StringBuffer();
+                       for (int i= 0; i < nLines; i++) {
+                               if (i != 0) {
+                                       buf.append(lineDelim);
+                               }
+                               IRegion region = tracker.getLineInformation(i);
+                               String line= code.substring(region.getOffset(), region.getOffset() + region.getLength());
+                               buf.append(line);
+                       }
+                       return buf.toString();
+               } catch (BadLocationException e) {
+                       // can not happen
+                       return code;
+               }
+       }               
+
+       /*
+        * @see org.eclipse.jface.text.templates.TemplateContext#canEvaluate(org.eclipse.jface.text.templates.Template)
+        */
+       @Override
+       public boolean canEvaluate(Template template) {
+               return true;
+       }
+       
+       public void setResourceVariables(IFile file) {
+               setVariable(FileTemplateContextType.FILENAME, file.getName());
+               setVariable(FileTemplateContextType.FILEBASE, new Path(file.getName()).removeFileExtension().lastSegment());
+               IPath location= file.getLocation();
+               setVariable(FileTemplateContextType.FILELOCATION, location != null ? location.toOSString() : ""); //$NON-NLS-1$
+               setVariable(FileTemplateContextType.FILEPATH, file.getFullPath().toString());
+               setVariable(FileTemplateContextType.PROJECTNAME, file.getProject().getName());
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/FileTemplateContextType.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/FileTemplateContextType.java
new file mode 100644 (file)
index 0000000..bba0e7f
--- /dev/null
@@ -0,0 +1,262 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.corext.template.c;
+
+import com.ibm.icu.text.DateFormat;
+import com.ibm.icu.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.core.runtime.content.IContentTypeManager;
+import org.eclipse.core.variables.IStringVariableManager;
+import org.eclipse.core.variables.VariablesPlugin;
+import org.eclipse.jface.text.templates.ContextTypeRegistry;
+import org.eclipse.jface.text.templates.GlobalTemplateVariables;
+import org.eclipse.jface.text.templates.SimpleTemplateVariableResolver;
+import org.eclipse.jface.text.templates.TemplateContext;
+import org.eclipse.jface.text.templates.TemplateContextType;
+import org.eclipse.jface.text.templates.TemplateException;
+import org.eclipse.jface.text.templates.TemplateVariable;
+import org.eclipse.jface.text.templates.TemplateVariableResolver;
+import org.eclipse.jface.text.templates.TemplateVariableType;
+
+import org.eclipse.cdt.internal.corext.util.Messages;
+
+/**
+ * A generic template context type for file resources based on content-type.
+ *
+ * @since 5.0
+ */
+public class FileTemplateContextType extends TemplateContextType {
+       public static final String CONTEXTTYPE_SUFFIX= ".contenttype_context"; //$NON-NLS-1$
+
+       public static final String CONTENTTYPE_TEXT= "org.eclipse.core.runtime.text"; //$NON-NLS-1$
+       public static final String TEXTFILE_CONTEXTTYPE= CONTENTTYPE_TEXT + CONTEXTTYPE_SUFFIX;
+
+       /* resolver types */
+       public static final String FILENAME= "file_name"; //$NON-NLS-1$
+       public static final String FILEBASE= "file_base"; //$NON-NLS-1$
+       public static final String FILELOCATION= "file_loc"; //$NON-NLS-1$
+       public static final String FILEPATH= "file_path"; //$NON-NLS-1$
+       public static final String PROJECTNAME= "project_name"; //$NON-NLS-1$
+
+       /**
+        * Resolver that resolves to the variable defined in the context.
+        */
+       static class FileTemplateVariableResolver extends SimpleTemplateVariableResolver {
+               public FileTemplateVariableResolver(String type, String description) {
+                       super(type, description);
+               }
+               
+               @Override
+               protected String resolve(TemplateContext context) {
+                       String value= context.getVariable(getType());
+                       return value != null ? value : ""; //$NON-NLS-1$
+               }
+       }
+
+       /**
+        * This date variable evaluates to the current date in a specific format.
+        */
+       static class DateVariableResolver extends SimpleTemplateVariableResolver {
+               private String fFormat;
+
+               public DateVariableResolver() {
+                       super("date", TemplateMessages.FileTemplateContextType_variable_description_date); //$NON-NLS-1$
+               }
+               
+               /*
+                * @see org.eclipse.jface.text.templates.TemplateVariableResolver#resolve(org.eclipse.jface.text.templates.TemplateVariable, org.eclipse.jface.text.templates.TemplateContext)
+                */
+               @Override
+               public void resolve(TemplateVariable variable, TemplateContext context) {
+                       fFormat= null;
+                       TemplateVariableType type= variable.getVariableType();
+                       List<?> params= type.getParams();
+                       if (params.size() == 1) {
+                               fFormat= params.get(0).toString();
+                       }
+                       super.resolve(variable, context);
+               }
+               
+               /*
+                * @see org.eclipse.jface.text.templates.SimpleTemplateVariableResolver#resolve(org.eclipse.jface.text.templates.TemplateContext)
+                */
+               @Override
+               protected String resolve(TemplateContext context) {
+                       DateFormat f;
+                       if (fFormat == null) {
+                               f= DateFormat.getDateInstance();
+                       } else {
+                               f= new SimpleDateFormat(fFormat);
+                       }
+                       return f.format(new java.util.Date());
+               }
+       }
+
+       /**
+        * Resolver that resolves to the value of a core variable.
+        */
+       static class CoreVariableResolver extends SimpleTemplateVariableResolver {
+               private String fVariableName;
+               private String[] fArguments;
+
+               public CoreVariableResolver(String type) {
+                       super(type, TemplateMessages.FileTemplateContextType__variable_description_eclipse);
+               }
+
+               /*
+                * @see org.eclipse.jface.text.templates.TemplateVariableResolver#resolve(org.eclipse.jface.text.templates.TemplateVariable, org.eclipse.jface.text.templates.TemplateContext)
+                */
+               @Override
+               public void resolve(TemplateVariable variable, TemplateContext context) {
+                       fVariableName= variable.getName();
+                       TemplateVariableType type= variable.getVariableType();
+                       List<?> params= type.getParams();
+                       fArguments= params.toArray(new String[params.size()]);
+                       super.resolve(variable, context);
+               }
+               
+               /*
+                * @see org.eclipse.jface.text.templates.SimpleTemplateVariableResolver#resolve(org.eclipse.jface.text.templates.TemplateContext)
+                */
+               @Override
+               protected String resolve(TemplateContext context) {
+                       StringBuffer expr= new StringBuffer("${"); //$NON-NLS-1$
+                       expr.append(fVariableName);
+                       for (int i = 0; i < fArguments.length; i++) {
+                               expr.append(':').append(fArguments[i]);
+                       }
+                       expr.append('}');
+                       IStringVariableManager mgr= VariablesPlugin.getDefault().getStringVariableManager();
+                       try {
+                               return mgr.performStringSubstitution(expr.toString(), false);
+                       } catch (CoreException exc) {
+                               return expr.toString();
+                       }
+               }
+       }
+
+       public FileTemplateContextType(String contextTypeId) {
+               this(contextTypeId, contextTypeId);
+       }
+
+       public FileTemplateContextType(String contextTypeId, String contextName) {
+               super(contextTypeId, contextName);
+
+               // global
+               addResolver(new GlobalTemplateVariables.Dollar());
+               addResolver(new DateVariableResolver());
+               addResolver(new GlobalTemplateVariables.Year());
+               addResolver(new GlobalTemplateVariables.Time());
+               addResolver(new GlobalTemplateVariables.User());
+
+//             addResolver(new CoreVariableResolver("eclipse")); //$NON-NLS-1$
+               
+               addResourceVariables();
+       }
+       
+       protected void addResourceVariables() {
+               addResolver(new FileTemplateVariableResolver(FILENAME, TemplateMessages.FileTemplateContextType_variable_description_filename));
+               addResolver(new FileTemplateVariableResolver(FILEBASE, TemplateMessages.FileTemplateContextType_variable_description_filebase));
+               addResolver(new FileTemplateVariableResolver(FILELOCATION, TemplateMessages.FileTemplateContextType_variable_description_fileloc));
+               addResolver(new FileTemplateVariableResolver(FILEPATH, TemplateMessages.FileTemplateContextType_variable_description_filepath));
+               addResolver(new FileTemplateVariableResolver(PROJECTNAME, TemplateMessages.FileTemplateContextType_variable_description_projectname));
+       }
+
+       @Override
+       protected TemplateVariableResolver getResolver(String type) {
+               // compatibility with editor template variables
+               if ("file".equals(type)) { //$NON-NLS-1$
+                       type= FILENAME;
+               } else if ("project".equals(type) || "enclosing_project".equals(type)) { //$NON-NLS-1$ //$NON-NLS-2$
+                       type= PROJECTNAME;
+               }
+               return super.getResolver(type);
+       }
+
+       @Override
+       protected void validateVariables(TemplateVariable[] variables) throws TemplateException {
+               ArrayList<String> required=  new ArrayList<String>(5);
+               for (int i= 0; i < variables.length; i++) {
+                       String type= variables[i].getType();
+                       if (getResolver(type) == null) {
+                               throw new TemplateException(Messages.format(TemplateMessages.FileTemplateContextType_validate_unknownvariable, type));
+                       }
+                       required.remove(type);
+               }
+               if (!required.isEmpty()) {
+                       String missing= required.get(0);
+                       throw new TemplateException(Messages.format(TemplateMessages.FileTemplateContextType_validate_missingvariable, missing));
+               }
+               super.validateVariables(variables);
+       }
+
+       /*
+        * @see org.eclipse.jface.text.templates.TemplateContextType#resolve(org.eclipse.jface.text.templates.TemplateVariable, org.eclipse.jface.text.templates.TemplateContext)
+        */
+       @Override
+       public void resolve(TemplateVariable variable, TemplateContext context) {
+               String type= variable.getType();
+               TemplateVariableResolver resolver= getResolver(type);
+               if (resolver == null) {
+                       resolver= new FileTemplateVariableResolver(type, ""); //$NON-NLS-1$
+               }
+               resolver.resolve(variable, context);
+       }
+
+       public static void registerContextTypes(ContextTypeRegistry registry) {
+               IContentTypeManager contentTypeMgr= Platform.getContentTypeManager();
+               IContentType[] contentTypes= contentTypeMgr.getAllContentTypes();
+               for (int i = 0; i < contentTypes.length; i++) {
+                       IContentType contentType = contentTypes[i];
+                       if (isTextContentType(contentType) && contentType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC).length > 0) {
+                               final String contextTypeId= contextTypeIdForContentType(contentType);
+                               if (registry.getContextType(contextTypeId) == null) {
+                                       registry.addContextType(new FileTemplateContextType(contextTypeId, contentType.getName()));
+                               }
+                       }
+               }
+       }
+
+       public static String contextTypeIdForContentType(IContentType contentType) {
+               return contentType.getId() + CONTEXTTYPE_SUFFIX;
+       }
+
+       public static boolean isFileTemplateContextType(String contextTypeId) {
+               return contextTypeId.endsWith(CONTEXTTYPE_SUFFIX);
+       }
+
+       public static boolean isContextTypeForContentType(String contextTypeId, String contentTypeId) {
+               return contextTypeId.endsWith(CONTEXTTYPE_SUFFIX) && contextTypeId.startsWith(contentTypeId);
+       }
+
+       public static String contentTypeIdForContextType(String contextTypeId) {
+               return contextTypeId.substring(0, contextTypeId.length() - CONTEXTTYPE_SUFFIX.length());
+       }
+
+       private static boolean isTextContentType(IContentType contentType) {
+               if (contentType == null) {
+                       return false;
+               }
+               String id= contentType.getId();
+               if (id.equals(CONTENTTYPE_TEXT)) {
+                       return true;
+               }
+               if (id.indexOf(".pde.") != -1 || id.indexOf(".jdt.") != -1) { //$NON-NLS-1$ //$NON-NLS-2$
+                       return false;
+               }
+               return isTextContentType(contentType.getBaseType());
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TemplateMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TemplateMessages.java
new file mode 100644 (file)
index 0000000..5e15918
--- /dev/null
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QnX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.corext.template.c;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class TemplateMessages extends NLS {
+       public static String CContextType_variable_description_file;
+       public static String CContextType_variable_description_file_base;
+       public static String CContextType_variable_description_enclosing_method;
+       public static String CContextType_variable_description_enclosing_project;
+       public static String CContextType_variable_description_enclosing_method_arguments;
+       public static String CContextType_variable_description_return_type;
+       public static String CContextType_variable_description_todo;
+       
+       public static String CodeTemplateContextType_variable_description_todo;
+       public static String CodeTemplateContextType_variable_description_typedeclaration;
+       public static String CodeTemplateContextType_variable_description_class_members;
+       public static String CodeTemplateContextType_variable_description_fieldname;
+       public static String CodeTemplateContextType_variable_description_fieldtype;
+       public static String CodeTemplateContextType_variable_description_typecomment;
+       public static String CodeTemplateContextType_variable_description_enclosingtype;
+       public static String CodeTemplateContextType_variable_description_includes;
+       public static String CodeTemplateContextType_variable_description_namespace_begin;
+       public static String CodeTemplateContextType_variable_description_namespace_end;
+       public static String CodeTemplateContextType_variable_description_namespace_name;
+       public static String CodeTemplateContextType_variable_description_typename;
+       public static String CodeTemplateContextType_variable_description_class_name;
+       public static String CodeTemplateContextType_variable_description_base_classes;
+       public static String CodeTemplateContextType_variable_description_include_guard_symbol;
+       public static String CodeTemplateContextType_variable_description_enclosingmethod;
+       public static String CodeTemplateContextType_variable_description_bodystatement;
+       public static String CodeTemplateContextType_variable_description_returntype;
+       public static String CodeTemplateContextType_variable_description_filecomment;
+       public static String CodeTemplateContextType_validate_invalidcomment;
+       public static String CodeTemplateContextType_csource_name;
+       public static String CodeTemplateContextType_cheader_name;
+       public static String CodeTemplateContextType_cppsource_name;
+       public static String CodeTemplateContextType_cppheader_name;
+       public static String CodeTemplateContextType_asmsource_name;
+       
+       public static String FileTemplateContextType__variable_description_eclipse;
+       public static String FileTemplateContextType_validate_unknownvariable;
+       public static String FileTemplateContextType_validate_missingvariable;
+       public static String FileTemplateContextType_variable_description_date;
+       public static String FileTemplateContextType_variable_description_filename;
+       public static String FileTemplateContextType_variable_description_filebase;
+       public static String FileTemplateContextType_variable_description_fileloc;
+       public static String FileTemplateContextType_variable_description_filepath;
+       public static String FileTemplateContextType_variable_description_projectname;
+
+       static {
+               NLS.initializeMessages(TemplateMessages.class.getName(), TemplateMessages.class);
+       }
+
+       // Do not instantiate.
+       private TemplateMessages() {
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TemplateMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TemplateMessages.properties
new file mode 100644 (file)
index 0000000..95a3b7d
--- /dev/null
@@ -0,0 +1,59 @@
+#########################################
+# Copyright (c) 2005, 2011 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+#        QnX Software System
+#     Anton Leherbauer (Wind River Systems)
+#     Sergey Prigogin (Google)
+#########################################
+
+CContextType_variable_description_file=Name of source file
+CContextType_variable_description_file_base=Name of source file without extension
+CContextType_variable_description_enclosing_method=Enclosing method name
+CContextType_variable_description_enclosing_project=Enclosing project name
+CContextType_variable_description_enclosing_method_arguments=Argument names of enclosing method
+CContextType_variable_description_return_type=Enclosing method return type
+CContextType_variable_description_todo=Todo task tag
+
+CodeTemplateContextType_variable_description_todo=Todo task tag
+CodeTemplateContextType_variable_description_typedeclaration=Generated type declaration
+CodeTemplateContextType_variable_description_class_members=Generated declarations of class members
+CodeTemplateContextType_variable_description_fieldname=The name of field
+CodeTemplateContextType_variable_description_fieldtype=The type of the field
+CodeTemplateContextType_variable_description_typecomment=Content of code template 'Comments > Types'
+CodeTemplateContextType_variable_description_enclosingtype=The enclosing type
+CodeTemplateContextType_variable_description_includes=Generated include statements
+CodeTemplateContextType_variable_description_namespace_begin=Beginning of namespace declaration
+CodeTemplateContextType_variable_description_namespace_end=End of namespace declaration
+CodeTemplateContextType_variable_description_namespace_name=Name of the current namespace
+CodeTemplateContextType_variable_description_class_name=Name of the current class
+CodeTemplateContextType_variable_description_typename=Name of the current type
+CodeTemplateContextType_variable_description_base_classes=Base clauses
+CodeTemplateContextType_variable_description_include_guard_symbol=Include guard symbol
+CodeTemplateContextType_variable_description_enclosingmethod=The enclosing method
+CodeTemplateContextType_variable_description_bodystatement=Return statement or super call
+CodeTemplateContextType_variable_description_returntype=Return type of the enclosing method
+CodeTemplateContextType_variable_description_filecomment=Content of code template 'Comments > Files'
+
+CodeTemplateContextType_validate_invalidcomment=Pattern is not a valid C/C++ comment.
+
+CodeTemplateContextType_csource_name=C Source File
+CodeTemplateContextType_cheader_name=C Header File
+CodeTemplateContextType_cppsource_name=C++ Source File
+CodeTemplateContextType_cppheader_name=C++ Header File
+CodeTemplateContextType_asmsource_name=Assembly Source File
+
+FileTemplateContextType__variable_description_eclipse=Resolve Eclipse core variables
+FileTemplateContextType_validate_unknownvariable=Variable ''{0}'' is unknown.
+FileTemplateContextType_validate_missingvariable=Variable ''{0}'' is required.
+FileTemplateContextType_variable_description_date= Current date
+FileTemplateContextType_variable_description_filename=Name of the file
+FileTemplateContextType_variable_description_filebase=Name of the file without extension
+FileTemplateContextType_variable_description_fileloc=File system location of the file
+FileTemplateContextType_variable_description_filepath=Workspace path of the file
+FileTemplateContextType_variable_description_projectname=Name of the enclosing project
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TranslationUnitContext.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TranslationUnitContext.java
new file mode 100644 (file)
index 0000000..709af63
--- /dev/null
@@ -0,0 +1,177 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.corext.template.c;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.templates.DocumentTemplateContext;
+import org.eclipse.jface.text.templates.Template;
+import org.eclipse.jface.text.templates.TemplateContextType;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
+import org.eclipse.cdt.internal.corext.util.Strings;
+
+/**
+ * A translation unit context.
+ */
+public abstract class TranslationUnitContext extends DocumentTemplateContext {
+
+       /** The translation unit, may be <code>null</code>. */
+       private final ITranslationUnit fTranslationUnit;
+       /** A flag to force evaluation in head-less mode. */
+       protected boolean fForceEvaluation;
+       /** <code>true</code> if the context has a managed (i.e. added to the document) position, <code>false</code> otherwise. */
+       protected final boolean fIsManaged;
+
+       /**
+        * Creates a translation unit context.
+        * 
+        * @param type the context type
+        * @param document the document
+        * @param completionOffset the completion position within the document
+        * @param completionLength the length of the context
+        * @param translationUnit the translation unit represented by the document
+        */
+       protected TranslationUnitContext(TemplateContextType type, IDocument document, int completionOffset,
+                       int completionLength, ITranslationUnit translationUnit) {
+               super(type, document, completionOffset, completionLength);
+               fTranslationUnit= translationUnit;
+               fIsManaged= false;
+       }
+       
+       /**
+        * Creates a translation unit context.
+        * 
+        * @param type the context type
+        * @param document the document
+        * @param completionPosition the completion position within the document
+        * @param translationUnit the translation unit represented by the document
+        */
+       protected TranslationUnitContext(TemplateContextType type, IDocument document, 
+                       Position completionPosition, ITranslationUnit translationUnit) {
+               super(type, document, completionPosition);
+               fTranslationUnit= translationUnit;
+               fIsManaged= true;
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.templates.DocumentTemplateContext#canEvaluate(org.eclipse.jface.text.templates.Template)
+        */
+       @Override
+       public boolean canEvaluate(Template template) {
+               if (fForceEvaluation)
+                       return true;
+               
+               String key= getKey();
+               return template.matches(key, getContextType().getId())
+                       && key.length() != 0 && template.getName().startsWith(key);
+       }
+
+
+
+       /*
+        * @see org.eclipse.cdt.internal.corext.template.DocumentTemplateContext#getKey()
+        */
+       @Override
+       public String getKey() {
+               if (getCompletionLength() == 0)         
+                       return super.getKey();
+
+               try {
+                       IDocument document= getDocument();
+
+                       int start= getStart();
+                       int end= getCompletionOffset();
+                       return start <= end
+                       ? document.get(start, end - start)
+                                       : ""; //$NON-NLS-1$
+
+               } catch (BadLocationException e) {
+                       return super.getKey();                  
+               }
+       }
+       
+       /**
+        * Returns the translation unit if one is associated with this context, <code>null</code> otherwise.
+        */
+       public final ITranslationUnit getTranslationUnit() {
+               return fTranslationUnit;
+       }
+
+       /**
+        * Returns the enclosing element of a particular element type, <code>null</code>
+        * if no enclosing element of that type exists.
+        */
+       public ICElement findEnclosingElement(int elementType) {
+               if (fTranslationUnit == null)
+                       return null;
+
+               try {
+                       ICElement element= fTranslationUnit.getElementAtOffset(getStart());
+                       while (element != null && element.getElementType() != elementType)
+                               element= element.getParent();
+                       
+                       return element;
+
+               } catch (CModelException e) {
+                       return null;
+               }
+       }
+
+       /**
+        * Sets whether evaluation is forced or not.
+        * 
+        * @param evaluate <code>true</code> in order to force evaluation,
+        *            <code>false</code> otherwise
+        */
+       public void setForceEvaluation(boolean evaluate) {
+               fForceEvaluation= evaluate;     
+       }
+       
+       /**
+        * Get the associated <code>ICProject</code>.
+        * @return the associated <code>ICProject</code> or <code>null</code>
+        */
+       protected ICProject getCProject() {
+               ITranslationUnit translationUnit= getTranslationUnit();
+               ICProject project= translationUnit == null ? null : translationUnit.getCProject();
+               return project;
+       }       
+
+       /**
+        * Get the indentation level at the position of code completion.
+        * @return the indentation level at the position of code completion
+        */
+       protected int getIndentationLevel() {
+               int start= getStart();
+               IDocument document= getDocument();
+               try {
+                       IRegion region= document.getLineInformationOfOffset(start);
+                       String lineContent= document.get(region.getOffset(), region.getLength());
+                       ICProject project= getCProject();
+                       return Strings.computeIndentUnits(lineContent, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project));
+               } catch (BadLocationException e) {
+                       return 0;
+               }
+       }       
+}
+
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TranslationUnitContextType.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/TranslationUnitContextType.java
new file mode 100644 (file)
index 0000000..bde96e4
--- /dev/null
@@ -0,0 +1,210 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.corext.template.c;
+
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.templates.GlobalTemplateVariables;
+import org.eclipse.jface.text.templates.TemplateContext;
+import org.eclipse.jface.text.templates.TemplateContextType;
+import org.eclipse.jface.text.templates.TemplateVariableResolver;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IFunctionDeclaration;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+import org.eclipse.cdt.internal.corext.codemanipulation.StubUtility;
+
+
+/**
+ * A context type for translation units.
+ */
+public abstract class TranslationUnitContextType extends TemplateContextType {
+
+       protected static class ReturnType extends TemplateVariableResolver {
+               public ReturnType() {
+                       super("return_type", TemplateMessages.CContextType_variable_description_return_type);  //$NON-NLS-1$
+               }
+               @Override
+               public String resolve(TemplateContext context) {
+                       ICElement element= ((TranslationUnitContext) context).findEnclosingElement(ICElement.C_METHOD);
+                       if (element == null) {
+                               element= ((TranslationUnitContext) context).findEnclosingElement(ICElement.C_FUNCTION);
+                       }
+                       if (element == null) {
+                               return null;
+                       }
+
+                       if (element instanceof IFunctionDeclaration) {
+                               return ((IFunctionDeclaration) element).getReturnType();
+                       }
+                       return null;
+               }
+       }
+
+       protected static class File extends TemplateVariableResolver {
+               public File() {
+                       super("file", TemplateMessages.CContextType_variable_description_file);  //$NON-NLS-1$
+               }
+               @Override
+               public String resolve(TemplateContext context) {
+                       ITranslationUnit unit= ((TranslationUnitContext) context).getTranslationUnit();
+                       return (unit == null) ? null : unit.getElementName();
+               }
+       }
+
+       protected static class FileBase extends TemplateVariableResolver {
+               public FileBase() {
+                       super("file_base", TemplateMessages.CContextType_variable_description_file_base);  //$NON-NLS-1$
+               }
+               @Override
+               public String resolve(TemplateContext context) {
+                       ITranslationUnit unit= ((TranslationUnitContext) context).getTranslationUnit();
+                       return (unit == null) ? null : new Path(unit.getElementName()).removeFileExtension().lastSegment();
+               }
+       }
+
+       protected static class EnclosingCElement extends TemplateVariableResolver {
+               protected final int fElementType;
+               
+               public EnclosingCElement(String name, String description, int elementType) {
+                       super(name, description);
+                       fElementType= elementType;
+               }
+               @Override
+               public String resolve(TemplateContext context) {
+                       ICElement element= ((TranslationUnitContext) context).findEnclosingElement(fElementType);
+                       return (element == null) ? null : element.getElementName();
+               }
+       }
+       
+       protected static class Method extends TemplateVariableResolver {
+               public Method() {
+                       super("enclosing_method", TemplateMessages.CContextType_variable_description_enclosing_method);  //$NON-NLS-1$
+               }
+               @Override
+               public String resolve(TemplateContext context) {
+                       ICElement element= ((TranslationUnitContext) context).findEnclosingElement(ICElement.C_FUNCTION);
+                       if (element == null) {
+                               element= ((TranslationUnitContext) context).findEnclosingElement(ICElement.C_FUNCTION_DECLARATION);
+                               if (element == null) {
+                                       element= ((TranslationUnitContext) context).findEnclosingElement(ICElement.C_METHOD);
+                                       if (element == null) {
+                                               element= ((TranslationUnitContext) context).findEnclosingElement(ICElement.C_METHOD_DECLARATION);
+                                       }
+                               }
+                       }
+
+                       if (element instanceof IFunctionDeclaration) {
+                               return element.getElementName();
+                       }
+                       return null;
+               }
+       }
+
+       protected static class Project extends TemplateVariableResolver {
+               public Project() {
+                       super("enclosing_project", TemplateMessages.CContextType_variable_description_enclosing_project);  //$NON-NLS-1$
+               }
+               @Override
+               public String resolve(TemplateContext context) {
+                       ITranslationUnit unit= ((TranslationUnitContext) context).getTranslationUnit();
+                       return (unit == null) ? null : unit.getCProject().getElementName();
+               }
+       }       
+
+       protected static class Arguments extends TemplateVariableResolver {
+               public Arguments() {
+                       super("enclosing_method_arguments", TemplateMessages.CContextType_variable_description_enclosing_method_arguments);  //$NON-NLS-1$
+               }
+               @Override
+               public String resolve(TemplateContext context) {
+                       ICElement element= ((TranslationUnitContext) context).findEnclosingElement(ICElement.C_FUNCTION);
+                       if (element == null) {
+                               element= ((TranslationUnitContext) context).findEnclosingElement(ICElement.C_FUNCTION_DECLARATION);
+                               if (element == null) {
+                                       element= ((TranslationUnitContext) context).findEnclosingElement(ICElement.C_METHOD);
+                                       if (element == null) {
+                                               element= ((TranslationUnitContext) context).findEnclosingElement(ICElement.C_METHOD_DECLARATION);
+                                       }
+                               }
+                       }
+
+                       if (element instanceof IFunctionDeclaration) {
+                               String[] arguments= ((IFunctionDeclaration)element).getParameterTypes();
+                               StringBuffer buffer= new StringBuffer();
+                               
+                               for (int i= 0; i < arguments.length; i++) {
+                                       if (i > 0)
+                                               buffer.append(", "); //$NON-NLS-1$
+                                       buffer.append(arguments[i]);                            
+                               }
+                               
+                               return buffer.toString();
+                       }
+                       return null;
+               }
+       }
+
+       protected static class Todo extends TemplateVariableResolver {
+
+               public Todo() {
+                       super("todo", TemplateMessages.CContextType_variable_description_todo);  //$NON-NLS-1$
+               }
+               @Override
+               protected String resolve(TemplateContext context) {
+                       TranslationUnitContext cContext= (TranslationUnitContext) context;
+                       ITranslationUnit tUnit= cContext.getTranslationUnit();
+                       if (tUnit == null)
+                               return "XXX"; //$NON-NLS-1$
+                       
+                       ICProject cProject= tUnit.getCProject();
+                       String todoTaskTag= StubUtility.getTodoTaskTag(cProject);
+                       if (todoTaskTag == null)
+                               return "XXX"; //$NON-NLS-1$
+
+                       return todoTaskTag;
+               }
+       }       
+
+       /*
+        * @see TemplateContextType#TemplateContextType()
+        */
+       public TranslationUnitContextType() {
+               super();        
+               // global
+               addResolver(new GlobalTemplateVariables.Cursor());
+               addResolver(new GlobalTemplateVariables.WordSelection());
+               addResolver(new GlobalTemplateVariables.LineSelection());
+               addResolver(new GlobalTemplateVariables.Dollar());
+               addResolver(new GlobalTemplateVariables.Date());
+               addResolver(new GlobalTemplateVariables.Year());
+               addResolver(new GlobalTemplateVariables.Time());
+               addResolver(new GlobalTemplateVariables.User());
+               
+               // translation unit
+               addResolver(new File());
+               addResolver(new FileBase());
+               addResolver(new ReturnType());
+               addResolver(new Method());
+               addResolver(new Project());
+               addResolver(new Arguments());
+               addResolver(new Todo());
+       }
+
+       public abstract TranslationUnitContext createContext(IDocument document, int offset, int length, ITranslationUnit translationUnit);
+       public abstract TranslationUnitContext createContext(IDocument document, Position position, ITranslationUnit translationUnit);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CModelUtil.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CModelUtil.java
new file mode 100644 (file)
index 0000000..cf72713
--- /dev/null
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Rational Software - Initial API and implementation
+ *    Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.corext.util;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICContainer;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICModelStatus;
+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.core.model.IWorkingCopy;
+
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+
+public class CModelUtil {
+       /**
+        * Returns the working copy TU of the given TU. If the TU is already a
+        * working copy or the TU has no working copy the input TU is returned.
+        */
+       public static ITranslationUnit toWorkingCopy(ITranslationUnit unit) {
+               if (!unit.isWorkingCopy()) {
+                       ITranslationUnit workingCopy= EditorUtility.getWorkingCopy(unit);
+                       if (workingCopy != null) {
+                               return workingCopy;
+                       }
+               }
+               return unit;
+       }
+       
+       public static ITranslationUnit toOriginal(ITranslationUnit unit) {
+               if (unit.isWorkingCopy()) {
+                       return (((IWorkingCopy) unit).getOriginalElement());
+               }
+               return unit;
+       }
+
+       /**
+        * Returns the source root of <code>ICElement</code>. If the given
+        * element is already a source root, the element itself is returned.
+        */
+       public static ISourceRoot getSourceRoot(ICElement element) {
+               ICElement root = element;
+               while (root != null) {
+                       if (root instanceof ISourceRoot)
+                               return (ISourceRoot)root;
+                       ICElement parent = root.getAncestor(ICElement.C_CCONTAINER);
+                       if (parent == root)
+                               return null;
+                       root = parent;
+               }
+               return null;
+       }
+
+       /**
+        * Returns the source folder of <code>ICElement</code>. If the given
+        * element is already a source folder, the element itself is returned.
+        */
+       public static ICContainer getSourceFolder(ICElement element) {
+               ICContainer folder = null;
+           if (element != null) {
+                       boolean foundSourceRoot = false;
+                       ICElement curr = element;
+                       while (curr != null && !foundSourceRoot) {
+                               if (curr instanceof ICContainer && folder == null) {
+                                   folder = (ICContainer)curr;
+                               }
+                               foundSourceRoot = (curr instanceof ISourceRoot);
+                               curr = curr.getParent();
+                       }
+                       if (folder == null) {
+                           ICProject cproject = element.getCProject();
+                               folder = cproject.findSourceRoot(cproject.getProject());
+                       }
+           }
+               return folder;
+       }
+       
+       /**
+        * Returns <code>true</code> if the given source root is
+        * referenced. This means it is own by a different project but is referenced
+        * by the root's parent. Returns <code>false</code> if the given root
+        * doesn't have an underlying resource.
+        */
+       public static boolean isReferenced(ISourceRoot root) {
+               IResource resource= root.getResource();
+               if (resource != null) {
+                       IProject project= resource.getProject();
+                       IProject container= root.getCProject().getProject();
+                       return !container.equals(project);
+               }
+               return false;
+       }
+       
+       /**
+        * Returns the translation unit the element belongs to or <code>null</code> if it does not.
+        */
+       public static ITranslationUnit getTranslationUnit(ICElement elem) {
+               while (elem != null) {
+                       if (elem instanceof ITranslationUnit) {
+                               return (ITranslationUnit) elem;
+                       }
+                       elem= elem.getParent();
+               }
+               return null;
+       }
+       
+       /*
+     * Don't log not-exists exceptions
+        */
+       public static boolean isExceptionToBeLogged(CoreException exception) {
+               if (!(exception instanceof CModelException))
+                       return true;
+               CModelException ce= (CModelException)exception;
+               ICModelStatus status = ce.getCModelStatus();
+               if (status == null || !status.doesNotExist())
+                       return true;
+               return false;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CodeFormatterUtil.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/CodeFormatterUtil.java
new file mode 100644 (file)
index 0000000..9e2065e
--- /dev/null
@@ -0,0 +1,170 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.corext.util;
+
+import java.util.Map;
+
+import org.eclipse.text.edits.TextEdit;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.ToolFactory;
+import org.eclipse.cdt.core.formatter.CodeFormatter;
+import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
+import org.eclipse.cdt.core.model.ICProject;
+
+public class CodeFormatterUtil {
+       /**
+        * Creates a string that represents the given number of indentation units.
+        * The returned string can contain tabs and/or spaces depending on the core
+        * formatter preferences.
+        * 
+        * @param indentationUnits the number of indentation units to generate
+        * @param project the project from which to get the formatter settings,
+        *        <code>null</code> if the workspace default should be used
+        * @return the indent string
+        */
+       public static String createIndentString(int indentationUnits, ICProject project) {
+               Map<String, String> options= project != null ? project.getOptions(true) : CCorePlugin.getOptions();             
+               return ToolFactory.createDefaultCodeFormatter(options).createIndentationString(indentationUnits);
+       } 
+               
+       /**
+        * Gets the current tab width.
+        * 
+        * @param project The project where the source is used, used for project
+        *        specific options or <code>null</code> if the project is unknown
+        *        and the workspace default should be used
+        * @return The tab width
+        */
+       public static int getTabWidth(ICProject project) {
+               /*
+                * If the tab-char is SPACE, FORMATTER_INDENTATION_SIZE is not used
+                * by the core formatter.
+                * We piggy back the visual tab length setting in that preference in
+                * that case.
+                */
+               String key;
+               if (CCorePlugin.SPACE.equals(getCoreOption(project, DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR)))
+                       key= DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE;
+               else
+                       key= DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE;
+               
+               return getCoreOption(project, key, 4);
+       }
+
+       /**
+        * Returns the current indent width.
+        * 
+        * @param project the project where the source is used or <code>null</code>
+        *        if the project is unknown and the workspace default should be used
+        * @return the indent width
+        */
+       public static int getIndentWidth(ICProject project) {
+               String key;
+               if (DefaultCodeFormatterConstants.MIXED.equals(getCoreOption(project, DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR)))
+                       key= DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE;
+               else
+                       key= DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE;
+               
+               return getCoreOption(project, key, 4);
+       }
+
+       /**
+        * Returns the possibly <code>project</code>-specific core preference
+        * defined under <code>key</code>.
+        * 
+        * @param project the project to get the preference from, or
+        *        <code>null</code> to get the global preference
+        * @param key the key of the preference
+        * @return the value of the preference
+        */
+       private static String getCoreOption(ICProject project, String key) {
+               if (project == null)
+                       return CCorePlugin.getOption(key);
+               return project.getOption(key, true);
+       }
+
+       /**
+        * Returns the possibly <code>project</code>-specific core preference
+        * defined under <code>key</code>, or <code>def</code> if the value is
+        * not a integer.
+        * 
+        * @param project the project to get the preference from, or
+        *        <code>null</code> to get the global preference
+        * @param key the key of the preference
+        * @param def the default value
+        * @return the value of the preference
+        */
+       private static int getCoreOption(ICProject project, String key, int def) {
+               try {
+                       return Integer.parseInt(getCoreOption(project, key));
+               } catch (NumberFormatException e) {
+                       return def;
+               }
+       }
+
+       /**
+        * Creates edits that describe how to format the given string. Returns <code>null</code>
+        * if the code could not be formatted for the given kind.
+        * 
+        * @throws IllegalArgumentException If the offset and length are not inside the string, a
+        *  IllegalArgumentException is thrown.
+        */
+       public static TextEdit format(int kind, String source, int offset, int length,
+                       int indentationLevel, String lineSeparator, Map<String, ?> options) {
+               if (offset < 0 || length < 0 || offset + length > source.length()) {
+                       throw new IllegalArgumentException("offset or length outside of string. offset: " + //$NON-NLS-1$
+                                       offset + ", length: " + length + ", string size: " + source.length());   //$NON-NLS-1$//$NON-NLS-2$
+               }
+               CodeFormatter formatter = ToolFactory.createCodeFormatter(options);
+               if (formatter != null) {
+                       return formatter.format(kind, source, offset, length, indentationLevel, lineSeparator);
+               }
+               return null;
+       }
+       
+       public static TextEdit format(int kind, String source, int indentationLevel,
+                       String lineSeparator, Map<String, ?> options) {
+               String prefix= ""; //$NON-NLS-1$
+               String suffix= ""; //$NON-NLS-1$
+               switch (kind) {
+               case CodeFormatter.K_EXPRESSION:
+                       prefix= "int __dummy__="; //$NON-NLS-1$
+                       suffix= ";"; //$NON-NLS-1$
+                       break;
+               case CodeFormatter.K_STATEMENTS:
+                       prefix= "void __dummy__() {"; //$NON-NLS-1$
+                       suffix= "}"; //$NON-NLS-1$
+                       --indentationLevel;
+                       break;
+               }
+               String tuSource= prefix + source + suffix;
+               return format(tuSource, prefix.length(), source.length(), indentationLevel, lineSeparator,
+                               options);
+       }
+
+       private static TextEdit format(String source, int offset, int length, int indentationLevel,
+                       String lineSeparator, Map<String, ?> options) {
+               TextEdit edit= format(CodeFormatter.K_TRANSLATION_UNIT, source, offset, length,
+                               indentationLevel, lineSeparator, options);
+               if (edit != null && offset > 0) {
+                       edit.moveTree(-offset);
+               }
+               return edit;
+       }
+       
+       /**
+        * @return The formatter tab width on workspace level.
+        */
+       public static int getTabWidth() {
+               return getTabWidth(null);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/Messages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/Messages.java
new file mode 100644 (file)
index 0000000..204420e
--- /dev/null
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.corext.util;
+
+import com.ibm.icu.text.MessageFormat;
+
+/**
+ * Helper class to format message strings.
+ * 
+ * @since 3.1
+ */
+public class Messages {
+
+       public static String format(String message, Object object) {
+               return MessageFormat.format(message, new Object[] { object });
+       }
+
+       public static String format(String message, Object[] objects) {
+               return MessageFormat.format(message, objects);
+       }
+
+       private Messages() {
+               // Not for instantiation
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/Resources.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/Resources.java
new file mode 100644 (file)
index 0000000..9d50e36
--- /dev/null
@@ -0,0 +1,193 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.corext.util;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.internal.corext.CorextMessages;
+import org.eclipse.cdt.internal.ui.CUIStatus;
+import org.eclipse.cdt.internal.ui.ICStatusConstants;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceStatus;
+import org.eclipse.core.resources.ResourceAttributes;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.osgi.util.NLS;
+
+public class Resources {
+
+       private Resources() {
+       }
+
+       /**
+        * Checks if the given resource is in sync with the underlying file system.
+        * 
+        * @param resource the resource to be checked
+        * @return IStatus status describing the check's result. If <code>status.
+        * isOK()</code> returns <code>true</code> then the resource is in sync
+        */
+       public static IStatus checkInSync(IResource resource) {
+               return checkInSync(new IResource[] {resource});
+       }
+       
+       /**
+        * Checks if the given resources are in sync with the underlying file
+        * system.
+        * 
+        * @param resources the resources to be checked
+        * @return IStatus status describing the check's result. If <code>status.
+        *  isOK() </code> returns <code>true</code> then the resources are in sync
+        */
+       public static IStatus checkInSync(IResource[] resources) {
+               IStatus result= null;
+               for (int i= 0; i < resources.length; i++) {
+                       IResource resource= resources[i];
+                       if (!resource.isSynchronized(IResource.DEPTH_INFINITE)) {
+                               result= addOutOfSync(result, resource);
+                       }                       
+               }
+               if (result != null)
+                       return result;
+               return new Status(IStatus.OK, CUIPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$             
+       }
+
+       /**
+        * Makes the given resource committable. Committable means that it is
+        * writeable and that its content hasn't changed by calling
+        * <code>validateEdit</code> for the given resource on <tt>IWorkspace</tt>.
+        * 
+        * @param resource the resource to be checked
+        * @param context the context passed to <code>validateEdit</code> 
+        * @return status describing the method's result. If <code>status.isOK()</code> returns <code>true</code> then the resources are committable.
+        * 
+        * @see org.eclipse.core.resources.IWorkspace#validateEdit(org.eclipse.core.resources.IFile[], java.lang.Object)
+        */
+       public static IStatus makeCommittable(IResource resource, Object context) {
+               return makeCommittable(new IResource[] { resource }, context);
+       }
+       
+       /**
+        * Makes the given resources committable. Committable means that all
+        * resources are writeable and that the content of the resources hasn't
+        * changed by calling <code>validateEdit</code> for a given file on
+        * <tt>IWorkspace</tt>.
+        * 
+        * @param resources the resources to be checked
+        * @param context the context passed to <code>validateEdit</code> 
+        * @return IStatus status describing the method's result. If <code>status.
+        * isOK()</code> returns <code>true</code> then the add resources are
+        * committable
+        * 
+        * @see org.eclipse.core.resources.IWorkspace#validateEdit(org.eclipse.core.resources.IFile[], java.lang.Object)
+        */
+       public static IStatus makeCommittable(IResource[] resources, Object context) {
+               List<IResource> readOnlyFiles= new ArrayList<IResource>();
+               for (int i= 0; i < resources.length; i++) {
+                       IResource resource= resources[i];
+                       if (resource.getType() == IResource.FILE) {
+                               ResourceAttributes attributes = resource.getResourceAttributes();
+                               if (attributes != null && attributes.isReadOnly()) {    
+                                       readOnlyFiles.add(resource);
+                               }
+                       }
+               }
+               if (readOnlyFiles.size() == 0)
+                       return new Status(IStatus.OK, CUIPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
+                       
+               Map<IFile, Long> oldTimeStamps= createModificationStampMap(readOnlyFiles);
+               IStatus status= ResourcesPlugin.getWorkspace().validateEdit(
+                       readOnlyFiles.toArray(new IFile[readOnlyFiles.size()]), context);
+               if (!status.isOK())
+                       return status;
+                       
+               IStatus modified= null;
+               Map<IFile, Long> newTimeStamps= createModificationStampMap(readOnlyFiles);
+               for (Iterator<IFile> iter= oldTimeStamps.keySet().iterator(); iter.hasNext();) {
+                       IFile file= iter.next();
+                       if (!oldTimeStamps.get(file).equals(newTimeStamps.get(file)))
+                               modified= addModified(modified, file);
+               }
+               if (modified != null)   
+                       return modified;
+               return new Status(IStatus.OK, CUIPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
+       }
+
+       private static Map<IFile, Long> createModificationStampMap(List<IResource> files){
+               Map<IFile, Long> map= new HashMap<IFile, Long>();
+               for (Iterator<IResource> iter= files.iterator(); iter.hasNext(); ) {
+                       IFile file= (IFile)iter.next();
+                       map.put(file, new Long(file.getModificationStamp()));
+               }
+               return map;
+       }
+       
+       private static IStatus addModified(IStatus status, IFile file) {
+               IStatus entry= CUIStatus.createError(
+                       ICStatusConstants.VALIDATE_EDIT_CHANGED_CONTENT, 
+                       NLS.bind(CorextMessages.Resources_fileModified, file.getFullPath().toString()),
+                       null);
+               if (status == null) {
+                       return entry;
+               } else if (status.isMultiStatus()) {
+                       ((MultiStatus)status).add(entry);
+                       return status;
+               } else {
+                       MultiStatus result= new MultiStatus(CUIPlugin.getPluginId(),
+                               ICStatusConstants.VALIDATE_EDIT_CHANGED_CONTENT,
+                               CorextMessages.Resources_modifiedResources, null);
+                       result.add(status);
+                       result.add(entry);
+                       return result;
+               }
+       }       
+
+       private static IStatus addOutOfSync(IStatus status, IResource resource) {
+               IStatus entry= new Status(
+                       IStatus.ERROR,
+                       ResourcesPlugin.getPlugin().getBundle().getSymbolicName(),
+                       IResourceStatus.OUT_OF_SYNC_LOCAL,
+                       NLS.bind(CorextMessages.Resources_outOfSync, resource.getFullPath().toString()),
+                       null);
+               if (status == null) {
+                       return entry;
+               } else if (status.isMultiStatus()) {
+                       ((MultiStatus)status).add(entry);
+                       return status;
+               } else {
+                       MultiStatus result= new MultiStatus(
+                               ResourcesPlugin.getPlugin().getBundle().getSymbolicName(),
+                               IResourceStatus.OUT_OF_SYNC_LOCAL,
+                               CorextMessages.Resources_outOfSyncResources, null);
+                       result.add(status);
+                       result.add(entry);
+                       return result;
+               }
+       }
+
+       public static String[] getLocationOSStrings(IResource[] resources) {
+               List<String> result= new ArrayList<String>(resources.length);
+               for (int i= 0; i < resources.length; i++) {
+                       IPath location= resources[i].getLocation();
+                       if (location != null)
+                               result.add(location.toOSString());
+               }
+               return result.toArray(new String[result.size()]);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/SimplePositionTracker.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/SimplePositionTracker.java
new file mode 100644 (file)
index 0000000..d3f75f5
--- /dev/null
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.corext.util;
+
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IPositionUpdater;
+
+import org.eclipse.cdt.internal.core.PositionTracker;
+
+/**
+ * A simple general purpose position tracker.
+ *
+ * @since 4.0
+ */
+public class SimplePositionTracker extends PositionTracker implements
+               IPositionUpdater {
+
+       private IDocument fDocument;
+
+       /*
+        * @see org.eclipse.jface.text.IPositionUpdater#update(org.eclipse.jface.text.DocumentEvent)
+        */
+       public void update(DocumentEvent event) {
+        String text = event.getText();
+        int insertLen = text != null ? text.length() : 0;
+        update(event.getOffset(), event.getLength(), insertLen);
+    }
+
+    private void update(int offset, int deleteLen, int insertLen) {
+        if (insertLen > deleteLen) {
+            insert(offset + deleteLen, insertLen - deleteLen);
+        } else if (insertLen < deleteLen) {
+            delete(offset+insertLen, deleteLen - insertLen);
+        }
+    }
+
+    /**
+     * Start tracking on the given document.
+     * 
+     * @param doc
+     */
+    public synchronized void startTracking(IDocument doc) {
+        stopTracking();
+        fDocument= doc;
+        if (fDocument != null) {
+               fDocument.addPositionUpdater(this);
+        }
+    }
+
+    /**
+     * Stop tracking.
+     */
+    public synchronized void stopTracking() {
+        if (fDocument != null) {
+            fDocument.removePositionUpdater(this);
+            fDocument= null;
+        }
+    }
+    
+    /**
+     * Destroy the tracker.
+     */
+    public void dispose() {
+        stopTracking();
+    }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/Strings.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/util/Strings.java
new file mode 100644 (file)
index 0000000..8242e9c
--- /dev/null
@@ -0,0 +1,610 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.corext.util;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.action.LegacyActionTools;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DefaultLineTracker;
+import org.eclipse.jface.text.ILineTracker;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.osgi.util.TextProcessor;
+
+import org.eclipse.cdt.core.formatter.IndentManipulation;
+import org.eclipse.cdt.core.model.ICProject;
+
+/**
+ * Helper class to provide String manipulation functions not available in standard JDK.
+ */
+public class Strings {
+
+       private Strings() {}
+       
+       /**
+        * Tells whether we have to use the {@link TextProcessor}
+        * <p>
+        * This is used for performance optimization.
+        * </p>
+        */
+       public static final boolean USE_TEXT_PROCESSOR;
+       static {
+               String testString= "args : String[]"; //$NON-NLS-1$
+               USE_TEXT_PROCESSOR= testString != TextProcessor.process(testString);
+       }
+
+       private static final String C_ELEMENT_DELIMITERS= TextProcessor.getDefaultDelimiters() + "<>(),?{} "; //$NON-NLS-1$
+
+       public static boolean startsWithIgnoreCase(CharSequence text, CharSequence prefix) {
+               int textLength= text.length();
+               int prefixLength= prefix.length();
+               if (textLength < prefixLength)
+                       return false;
+               for (int i= prefixLength - 1; i >= 0; i--) {
+                       if (Character.toLowerCase(prefix.charAt(i)) != Character.toLowerCase(text.charAt(i)))
+                               return false;
+               }
+               return true;
+       }
+
+       public static boolean endsWith(CharSequence containing, CharSequence contained) {
+               int start = containing.length() - contained.length();
+               if (start < 0)
+                       return false;
+               for (int i = start, j = 0; i < containing.length(); i++, j++) {
+                       if (containing.charAt(i) != contained.charAt(j))
+                               return false;
+               }
+               return true;
+       }
+
+       public static String removeNewLine(String message) {
+               StringBuffer result= new StringBuffer();
+               int current= 0;
+               int index= message.indexOf('\n', 0);
+               while (index != -1) {
+                       result.append(message.substring(current, index));
+                       if (current < index && index != 0)
+                               result.append(' ');
+                       current= index + 1;
+                       index= message.indexOf('\n', current);
+               }
+               result.append(message.substring(current));
+               return result.toString();
+       }
+
+       /**
+        * Converts the given string into an array of lines. The lines 
+        * don't contain any line delimiter characters.
+        *
+        * @return the string converted into an array of strings. Returns <code>
+        *      null</code> if the input string can't be converted in an array of lines.
+        */
+       public static String[] convertIntoLines(String input) {
+               try {
+                       ILineTracker tracker= new DefaultLineTracker();
+                       tracker.set(input);
+                       int size= tracker.getNumberOfLines();
+                       String result[]= new String[size];
+                       for (int i= 0; i < size; i++) {
+                               IRegion region= tracker.getLineInformation(i);
+                               int offset= region.getOffset();
+                               result[i]= input.substring(offset, offset + region.getLength());
+                       }
+                       return result;
+               } catch (BadLocationException e) {
+                       return null;
+               }
+       }
+
+       /**
+        * Returns <code>true</code> if the given string only consists of
+        * white spaces according to C. If the string is empty, <code>true
+        * </code> is returned.
+        * 
+        * @return <code>true</code> if the string only consists of white
+        *      spaces; otherwise <code>false</code> is returned
+        * 
+        * @see java.lang.Character#isWhitespace(char)
+        */
+       public static boolean containsOnlyWhitespaces(String s) {
+               int size= s.length();
+               for (int i= 0; i < size; i++) {
+                       if (!Character.isWhitespace(s.charAt(i)))
+                               return false;
+               }
+               return true;
+       }
+       
+       /**
+        * Removes leading tabs and spaces from the given string. If the string
+        * doesn't contain any leading tabs or spaces then the string itself is 
+        * returned.
+        */
+       public static String trimLeadingTabsAndSpaces(String line) {
+               int size= line.length();
+               int start= size;
+               for (int i= 0; i < size; i++) {
+                       char c= line.charAt(i);
+                       if (!IndentManipulation.isIndentChar(c)) {
+                               start= i;
+                               break;
+                       }
+               }
+               if (start == 0)
+                       return line;
+               else if (start == size)
+                       return ""; //$NON-NLS-1$
+               else
+                       return line.substring(start);
+       }
+       
+       public static String trimTrailingTabsAndSpaces(String line) {
+               int size= line.length();
+               int end= size;
+               for (int i= size - 1; i >= 0; i--) {
+                       char c= line.charAt(i);
+                       if (IndentManipulation.isIndentChar(c)) {
+                               end= i;
+                       } else {
+                               break;
+                       }
+               }
+               if (end == size)
+                       return line;
+               else if (end == 0)
+                       return ""; //$NON-NLS-1$
+               else
+                       return line.substring(0, end);
+       }
+               
+       /**
+        * Returns the indent of the given string in indentation units. Odd spaces
+        * are not counted.
+        * 
+        * @param line the text line
+        * @param project the project from which to get the formatter
+        *        preferences, or <code>null</code> for global preferences
+        * @since 5.0
+        */
+       public static int computeIndentUnits(String line, ICProject project) {
+               return IndentManipulation.measureIndentUnits(line, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project));
+       }
+       
+       /**
+        * Returns the indent of the given string in indentation units. Odd spaces
+        * are not counted.
+        * 
+        * @param line the text line
+        * @param tabWidth the width of the '\t' character in space equivalents
+        * @param indentWidth the width of one indentation unit in space equivalents
+        * @since 5.0
+        */
+       public static int computeIndentUnits(String line, int tabWidth, int indentWidth) {
+               return IndentManipulation.measureIndentUnits(line, tabWidth, indentWidth);
+       }
+       
+       /**
+        * Computes the visual length of the indentation of a
+        * <code>CharSequence</code>, counting a tab character as the size until
+        * the next tab stop and every other whitespace character as one.
+        * 
+        * @param line the string to measure the indent of
+        * @param tabSize the visual size of a tab in space equivalents
+        * @return the visual length of the indentation of <code>line</code>
+        * @since 5.0
+        */
+       public static int measureIndentLength(CharSequence line, int tabSize) {
+               return IndentManipulation.measureIndentInSpaces(line, tabSize);
+       }
+
+       /**
+        * Removes the given number of indents from the line. Asserts that the given line 
+        * has the requested number of indents. If <code>indentsToRemove <= 0</code>
+        * the line is returned.
+        * 
+        * @param project the project from which to get the formatter
+        *        preferences, or <code>null</code> for global preferences
+        * @since 5.0
+        */
+       public static String trimIndent(String line, int indentsToRemove, ICProject project) {
+               return IndentManipulation.trimIndent(line, indentsToRemove, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project));
+       }
+       
+       /**
+        * Removes the given number of indents from the line. Asserts that the given line 
+        * has the requested number of indents. If <code>indentsToRemove <= 0</code>
+        * the line is returned.
+        * 
+        * @since 5.0
+        */
+       public static String trimIndent(String line, int indentsToRemove, int tabWidth, int indentWidth) {
+               return IndentManipulation.trimIndent(line, indentsToRemove, tabWidth, indentWidth);
+       }
+       
+       /**
+        * Removes the common number of indents from all lines. If a line
+        * only consists out of white space it is ignored.
+
+        * @param project the project from which to get the formatter
+        *        preferences, or <code>null</code> for global preferences
+        * @since 5.0
+        */
+       public static void trimIndentation(String[] lines, ICProject project) {
+               trimIndentation(lines, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project), true);
+       }
+       /**
+        * Removes the common number of indents from all lines. If a line
+        * only consists out of white space it is ignored.
+        * 
+        * @since 5.0
+        */
+       public static void trimIndentation(String[] lines, int tabWidth, int indentWidth) {
+               trimIndentation(lines, tabWidth, indentWidth, true);
+       }
+       
+       /**
+        * Removes the common number of indents from all lines. If a line
+        * only consists out of white space it is ignored. If <code>
+        * considerFirstLine</code> is false the first line will be ignored.
+        * 
+        * @param project the project from which to get the formatter
+        *        preferences, or <code>null</code> for global preferences
+        * @since 5.0
+        */
+       public static void trimIndentation(String[] lines, ICProject project, boolean considerFirstLine) {
+               trimIndentation(lines, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project), considerFirstLine);
+       }
+       
+       /**
+        * Removes the common number of indents from all lines. If a line
+        * only consists out of white space it is ignored. If <code>
+        * considerFirstLine</code> is false the first line will be ignored.
+        * @since 5.0
+        */
+       public static void trimIndentation(String[] lines, int tabWidth, int indentWidth, boolean considerFirstLine) {
+               String[] toDo= new String[lines.length];
+               // find indentation common to all lines
+               int minIndent= Integer.MAX_VALUE; // very large
+               for (int i= considerFirstLine ? 0 : 1; i < lines.length; i++) {
+                       String line= lines[i];
+                       if (containsOnlyWhitespaces(line))
+                               continue;
+                       toDo[i]= line;
+                       int indent= computeIndentUnits(line, tabWidth, indentWidth);
+                       if (indent < minIndent) {
+                               minIndent= indent;
+                       }
+               }
+               
+               if (minIndent > 0) {
+                       // remove this indent from all lines
+                       for (int i= considerFirstLine ? 0 : 1; i < toDo.length; i++) {
+                               String s= toDo[i];
+                               if (s != null)
+                                       lines[i]= trimIndent(s, minIndent, tabWidth, indentWidth);
+                               else {
+                                       String line= lines[i];
+                                       int indent= computeIndentUnits(line, tabWidth, indentWidth);
+                                       if (indent > minIndent)
+                                               lines[i]= trimIndent(line, minIndent, tabWidth, indentWidth);
+                                       else
+                                               lines[i]= trimLeadingTabsAndSpaces(line);
+                               }
+                       }
+               }
+       }
+               
+       /**
+        * Returns that part of the indentation of <code>line</code> that makes up
+        * a multiple of indentation units.
+        * 
+        * @param line the line to scan
+        * @param project the project from which to get the formatter
+        *        preferences, or <code>null</code> for global preferences
+        * @return the indent part of <code>line</code>, but no odd spaces
+        * @since 5.0
+        */
+       public static String getIndentString(String line, ICProject project) {
+               return IndentManipulation.extractIndentString(line, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project));
+       }
+       
+       /**
+        * Returns that part of the indentation of <code>line</code> that makes up
+        * a multiple of indentation units.
+        * 
+        * @param line the line to scan
+        * @param tabWidth the size of one tab in space equivalents
+        * @param indentWidth the size of the indent in space equivalents
+        * @return the indent part of <code>line</code>, but no odd spaces
+        * @since 5.0
+        */
+       public static String getIndentString(String line, int tabWidth, int indentWidth) {
+               return IndentManipulation.extractIndentString(line, tabWidth, indentWidth);
+       }
+               
+       public static String[] removeTrailingEmptyLines(String[] sourceLines) {
+               int lastNonEmpty= findLastNonEmptyLineIndex(sourceLines);
+               String[] result= new String[lastNonEmpty + 1];
+               for (int i= 0; i < result.length; i++) {
+                       result[i]= sourceLines[i];
+               }
+               return result;
+       }
+
+       private static int findLastNonEmptyLineIndex(String[] sourceLines) {
+               for (int i= sourceLines.length - 1; i >= 0; i--) {
+                       if (! sourceLines[i].trim().equals(""))//$NON-NLS-1$
+                               return i;
+               }
+               return -1;
+       }
+       
+       /**
+        * Change the indent of, possible muti-line, code range. The current indent is removed, a new indent added.
+        * The first line of the code will not be changed. (It is considered to have no indent as it might start in
+        * the middle of a line)
+        * 
+        * @param project the project from which to get the formatter
+        *        preferences, or <code>null</code> for global preferences
+        * @since 5.0
+        */
+       public static String changeIndent(String code, int codeIndentLevel, ICProject project, String newIndent, String lineDelim) {
+               return IndentManipulation.changeIndent(code, codeIndentLevel, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project), newIndent, lineDelim);
+       }
+       
+       /**
+        * Change the indent of, possible muti-line, code range. The current indent is removed, a new indent added.
+        * The first line of the code will not be changed. (It is considered to have no indent as it might start in
+        * the middle of a line)
+        * @since 5.0
+        */
+       public static String changeIndent(String code, int codeIndentLevel, int tabWidth, int indentWidth, String newIndent, String lineDelim) {
+               return IndentManipulation.changeIndent(code, codeIndentLevel, tabWidth, indentWidth, newIndent, lineDelim);
+       }
+       
+       public static String trimIndentation(String source, ICProject project, boolean considerFirstLine) {
+               return trimIndentation(source, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project), considerFirstLine);
+       }
+       
+       public static String trimIndentation(String source, int tabWidth, int indentWidth, boolean considerFirstLine) {
+               try {
+                       ILineTracker tracker= new DefaultLineTracker();
+                       tracker.set(source);
+                       int size= tracker.getNumberOfLines();
+                       if (size == 1)
+                               return source;
+                       String lines[]= new String[size];
+                       for (int i= 0; i < size; i++) {
+                               IRegion region= tracker.getLineInformation(i);
+                               int offset= region.getOffset();
+                               lines[i]= source.substring(offset, offset + region.getLength());
+                       }
+                       Strings.trimIndentation(lines, tabWidth, indentWidth, considerFirstLine);
+                       StringBuffer result= new StringBuffer();
+                       int last= size - 1;
+                       for (int i= 0; i < size; i++) {
+                               result.append(lines[i]);
+                               if (i < last)
+                                       result.append(tracker.getLineDelimiter(i));
+                       }
+                       return result.toString();
+               } catch (BadLocationException e) {
+                       Assert.isTrue(false,"Can not happend"); //$NON-NLS-1$
+                       return null;
+               }
+       }
+               
+       /**
+        * Concatenate the given strings into one strings using the passed line delimiter as a
+        * delimiter. No delimiter is added to the last line.
+        */
+       public static String concatenate(String[] lines, String delimiter) {
+               StringBuffer buffer= new StringBuffer();
+               for (int i= 0; i < lines.length; i++) {
+                       if (i > 0)
+                               buffer.append(delimiter);
+                       buffer.append(lines[i]);
+               }
+               return buffer.toString();
+       }
+       
+       public static boolean equals(String s, char[] c) {
+               if (s.length() != c.length)
+                       return false;
+
+               for (int i = c.length; --i >= 0;) {
+                       if (s.charAt(i) != c[i])
+                               return false;
+               }
+               return true;
+       }
+               
+       public static String removeTrailingCharacters(String text, char toRemove) {
+               int size= text.length();
+               int end= size;
+               for (int i= size - 1; i >= 0; i--) {
+                       char c= text.charAt(i);
+                       if (c == toRemove) {
+                               end= i;
+                       } else {
+                               break;
+                       }
+               }
+               if (end == size)
+                       return text;
+               else if (end == 0)
+                       return ""; //$NON-NLS-1$
+               else
+                       return text.substring(0, end);
+       }
+
+       /**
+        * Converts tabs to spaces in a line of text.
+        * @param line The line of text.
+        * @param tabWidth Tabulation size.
+        * @return The line with tab characters replaced by spaces.
+        */
+       public static String convertTabsToSpaces(String line, int tabWidth) {
+               StringBuilder buf = null;
+               for (int i = 0; i < line.length(); i++) {
+                       char c = line.charAt(i);
+                       if (c == '\t') {
+                               if (buf == null) {
+                                       buf = new StringBuilder(line.length() * tabWidth);
+                                       buf.append(line.subSequence(0, i));
+                               }
+                               for (int k = tabWidth - i % tabWidth; --k >= 0;) {
+                                       buf.append(' ');
+                               }
+                       } else if (buf != null) {
+                               buf.append(c);
+                       }
+               }
+               return buf != null ? buf.toString() : line;
+       }
+
+       public static String removeMnemonicIndicator(String string) {
+               return LegacyActionTools.removeMnemonics(string);
+       }
+
+       
+       /**
+        * Adds special marks so that that the given styled string is readable in a BiDi environment.
+        * 
+        * @param styledString the styled string
+        * @return the processed styled string
+        */
+       public static StyledString markLTR(StyledString styledString) {
+               
+               /*
+                * NOTE: For performance reasons we do not call  markLTR(styledString, null)
+                */
+               
+               if (!USE_TEXT_PROCESSOR)
+                       return styledString;
+
+               String inputString= styledString.getString();
+               String string= TextProcessor.process(inputString);
+               if (string != inputString)
+                       insertMarks(styledString, inputString, string);
+               return styledString;
+       }
+
+       /**
+        * Adds special marks so that that the given styled string is readable in a BiDi environment.
+        * 
+        * @param styledString the styled string
+        * @param delimiters the additional delimiters
+        * @return the processed styled string
+        */
+       public static StyledString markLTR(StyledString styledString, String delimiters) {
+               if (!USE_TEXT_PROCESSOR)
+                       return styledString;
+
+               String inputString= styledString.getString();
+               String string= TextProcessor.process(inputString, delimiters);
+               if (string != inputString)
+                       insertMarks(styledString, inputString, string);
+               return styledString;
+       }
+
+       /**
+        * Adds special marks so that that the given string is readable in a BiDi environment.
+        * 
+        * @param string the string
+        * @return the processed styled string
+        * @since 5.3
+        */
+       public static String markLTR(String string) {
+               if (!USE_TEXT_PROCESSOR)
+                       return string;
+
+               return TextProcessor.process(string);
+       }
+
+       /**
+        * Adds special marks so that that the given string is readable in a BiDi environment.
+        * 
+        * @param string the string
+        * @param delimiters the delimiters
+        * @return the processed styled string
+        * @since 5.3
+        */
+       public static String markLTR(String string, String delimiters) {
+               if (!USE_TEXT_PROCESSOR)
+                       return string;
+
+               return TextProcessor.process(string, delimiters);
+       }
+
+       /**
+        * Adds special marks so that that the given C element label is readable in a BiDi
+        * environment.
+        * 
+        * @param string the string
+        * @return the processed styled string
+        * @since 5.3
+        */
+       public static String markCElementLabelLTR(String string) {
+               if (!USE_TEXT_PROCESSOR)
+                       return string;
+
+               return TextProcessor.process(string, C_ELEMENT_DELIMITERS);
+       }
+
+       /**
+        * Adds special marks so that that the given styled C element label is readable in a BiDi
+        * environment.
+        * 
+        * @param styledString the styled string
+        * @return the processed styled string
+        * @since 5.3
+        */
+       public static StyledString markCElementLabelLTR(StyledString styledString) {
+               if (!USE_TEXT_PROCESSOR)
+                       return styledString;
+
+               String inputString= styledString.getString();
+               String string= TextProcessor.process(inputString, C_ELEMENT_DELIMITERS);
+               if (string != inputString)
+                       insertMarks(styledString, inputString, string);
+               return styledString;
+       }
+
+       /**
+        * Inserts the marks into the given styled string.
+        * 
+        * @param styledString the styled string
+        * @param originalString the original string
+        * @param processedString the processed string
+        * @since 5.3
+        */
+       private static void insertMarks(StyledString styledString, String originalString, String processedString) {
+               int originalLength= originalString.length();
+               int processedStringLength= processedString.length();
+               char orig= originalLength > 0 ? originalString.charAt(0) : '\0';
+               for (int o= 0, p= 0; p < processedStringLength; p++) {
+                       char processed= processedString.charAt(p);
+                       if (o < originalLength) {
+                               if (orig == processed) {
+                                       o++;
+                                       if (o < originalLength)
+                                               orig= originalString.charAt(o);
+                                       continue;
+                               }
+                       }
+                       styledString.insert(processed, p);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java
new file mode 100644 (file)
index 0000000..990089e
--- /dev/null
@@ -0,0 +1,781 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.IArchive;
+import org.eclipse.cdt.core.model.IArchiveContainer;
+import org.eclipse.cdt.core.model.IBinary;
+import org.eclipse.cdt.core.model.IBinaryContainer;
+import org.eclipse.cdt.core.model.IBinaryModule;
+import org.eclipse.cdt.core.model.ICContainer;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IInclude;
+import org.eclipse.cdt.core.model.IMacro;
+import org.eclipse.cdt.core.model.IMember;
+import org.eclipse.cdt.core.model.INamespace;
+import org.eclipse.cdt.core.model.IParent;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.core.model.ISourceRoot;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.CDTUITools;
+import org.eclipse.cdt.ui.CElementGrouping;
+import org.eclipse.cdt.ui.IncludesGrouping;
+import org.eclipse.cdt.ui.NamespacesGrouping;
+/**
+ * A base content provider for C elements. It provides access to the
+ * C element hierarchy without listening to changes in the C model.
+ * Use this class when you want to present the C elements
+ * in a modal dialog or wizard.
+ * <p>
+ * The following C element hierarchy is surfaced by this content provider:
+ * <p>
+ * <pre>
+C model (<code>ICModel</code>)<br>
+   C project (<code>ICProject</code>)<br>
+      Source root (<code>ISourceRoot</code>)<br>
+      C Container(folders) (<code>ICContainer</code>)<br>
+      Translation unit (<code>ITranslationUnit</code>)<br>
+      Binary file (<code>IBinary</code>)<br>
+      Archive file (<code>IArchive</code>)<br>
+      Non C Resource file (<code>Object</code>)<br>
+
+ * </pre>
+ */
+public class BaseCElementContentProvider implements ITreeContentProvider {
+
+       protected static final Object[] NO_CHILDREN= new Object[0];
+
+       protected boolean fProvideMembers= false;
+       protected boolean fProvideWorkingCopy= false;
+       protected boolean fIncludesGrouping= false;
+       protected boolean fNamespacesGrouping= false;
+       protected boolean fMemberGrouping= false;
+       protected boolean fMacroGrouping= false;
+       
+       public BaseCElementContentProvider() {
+               this(false, false);
+       }
+       
+       public BaseCElementContentProvider(boolean provideMembers, boolean provideWorkingCopy) {
+           fProvideMembers= provideMembers;
+               fProvideWorkingCopy= provideWorkingCopy;
+       }
+
+       /**
+        * Returns whether the members are provided when asking
+        * for a TU's children.
+        */
+       public boolean getProvideMembers() {
+               return fProvideMembers;
+       }
+
+       /**
+        * Returns whether the members are provided when asking
+        * for a TU's children.
+        */
+       public void setProvideMembers(boolean b) {
+               fProvideMembers= b;
+       }
+
+       /**
+        * Sets whether the members are provided from
+        * a working copy of a compilation unit
+        */
+       public void setProvideWorkingCopy(boolean b) {
+               fProvideWorkingCopy= b;
+       }
+
+       /**
+        * Returns whether the members are provided
+        * from a working copy a compilation unit.
+        */
+       public boolean getProvideWorkingCopy() {
+               return fProvideWorkingCopy;
+       }
+
+       /**
+        * Can elements be group.
+        */
+       public boolean areIncludesGroup() {
+           return fIncludesGrouping;
+       }
+
+       /**
+        * Allow Elements to be group.
+        * @param b
+        */
+       public void setIncludesGrouping(boolean b) {
+           fIncludesGrouping = b;
+       }
+
+       /**
+        * Can elements be group.
+        */
+       public boolean areNamespacesGroup() {
+           return fNamespacesGrouping;
+       }
+
+       /**
+        * Allow Elements to be group.
+        * @param b
+        */
+       public void setNamespacesGrouping(boolean b) {
+           fNamespacesGrouping = b;
+       }
+
+       /**
+        * @return whether grouping of members is enabled
+        */
+       public boolean isMemberGroupingEnabled() {
+               return fMemberGrouping;
+       }
+       
+       /**
+        * Enable/disable member grouping by common namespace.
+        * @param enable
+        */
+       public void setMemberGrouping(boolean enable) {
+               fMemberGrouping = enable;
+       }
+       
+       /**
+        * @return whether grouping of macros is enabled
+        */
+       public boolean isMacroGroupingEnabled() {
+               return fMacroGrouping;
+       }
+       
+       /**
+        * Enable/disable marco grouping
+        * @param enable
+        */
+       public void setMacroGrouping(boolean enable) {
+               fMacroGrouping = enable;
+       }
+
+       /* (non-Cdoc)
+        * Method declared on IContentProvider.
+        */
+       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+       }
+
+       /* (non-Cdoc)
+        * Method declared on IContentProvider.
+        */
+       public void dispose() {
+       }
+
+       /* (non-Cdoc)
+        * Method declared on IStructuredContentProvider.
+        */
+       public Object[] getElements(Object parent) {
+               return getChildren(parent);
+       }
+       
+       /* (non-Cdoc)
+        * Method declared on ITreeContentProvider.
+        */
+       public Object[] getChildren(Object element) {
+               if (!exists(element))
+                       return NO_CHILDREN;
+
+               try {
+                       if (element instanceof ICModel) {
+                               return  getCProjects((ICModel)element);
+                       } else if  (element instanceof ICProject ) {
+                               return getSourceRoots((ICProject)element);
+                       } else if (element instanceof ICContainer) {
+                               return getCResources((ICContainer)element);
+                       } else if (element instanceof ITranslationUnit) {
+                               // if we want to get the children of a translation unit
+                               if (fProvideMembers) {
+                                       // if we want to use the working copy of it
+                                       ITranslationUnit tu = (ITranslationUnit)element;
+                                       if (fProvideWorkingCopy){
+                                               // if it is not already a working copy
+                                               if (!(element instanceof IWorkingCopy)){
+                                                       // if it has a valid working copy
+                                                       IWorkingCopy copy = CDTUITools.getWorkingCopyManager().findSharedWorkingCopy(tu);
+                                                       if (copy != null) {
+                                                               tu = copy;
+                                                       }
+                                               }
+                                       }
+                                       return getTranslationUnitChildren(tu);
+                               }
+                       } else if (element instanceof IBinary) {
+                               return ((IBinary)element).getChildren();
+                       } else if (element instanceof IArchive) {
+                               return ((IArchive)element).getChildren();
+                       } else if (element instanceof IBinaryModule) {
+                               return ((IBinaryModule)element).getChildren();
+                       } else if (element instanceof INamespace) {
+                               return getNamespaceChildren((INamespace) element);
+                       } else if (element instanceof ISourceReference  && element instanceof IParent) {
+                               return ((IParent)element).getChildren();
+                       } else if (element instanceof IProject) {
+                               return getResources((IProject)element);
+                       } else if (element instanceof IFolder) {
+                               return getResources((IFolder)element);
+                       } else if (element instanceof CElementGrouping) {
+                               return ((CElementGrouping)element).getChildren(element);
+                       }
+               } catch (CModelException e) {
+                       //CUIPlugin.log(e);
+                       return NO_CHILDREN;
+               }
+               return NO_CHILDREN;
+       }
+
+       /* (non-Cdoc)
+        *
+        * @see ITreeContentProvider
+        */
+       public boolean hasChildren(Object element) {
+               if (fProvideMembers) {
+                       // assume TUs and binary files are never empty
+                       if (element instanceof IBinary || element instanceof ITranslationUnit || element instanceof IArchive) {
+                               return true;
+                       }
+               } else {
+                       // don't allow to drill down into a compilation unit or class file
+                       if (element instanceof ITranslationUnit || element instanceof IBinary || element instanceof IArchive
+                                       || element instanceof IFile) {
+                               return false;
+                       }
+               }
+
+               if (element instanceof ICProject) {
+                       ICProject cp= (ICProject)element;
+                       if (!cp.getProject().isOpen()) {
+                               return false;
+                       }
+                       return true;
+               }
+
+               if (element instanceof ICContainer) {
+                       ICContainer container= (ICContainer)element;
+                       IResource resource= container.getResource();
+                       if (resource instanceof IContainer) {
+                               try {
+                                       return ((IContainer)resource).members().length > 0;
+                               } catch (CoreException exc) {
+                                       return false;
+                               }
+                       }
+               }
+
+               if (element instanceof IParent) {
+                       // when we have C children return true, else we fetch all the children
+                       if (((IParent)element).hasChildren()) {
+                               return true;
+                       }
+               }
+               
+               if (element instanceof CElementGrouping) {
+                       return true;
+               }
+
+               Object[] children= getChildren(element);
+               return (children != null) && children.length > 0;
+       }
+        
+       /* (non-Cdoc)
+        * Method declared on ITreeContentProvider.
+        */
+       public Object getParent(Object element) {
+               if (!exists(element)) {
+                       return null;
+               }
+               return internalGetParent(element);
+       }
+
+       public Object internalGetParent(Object element) {
+               if (element instanceof IResource) {
+                       IResource parent= ((IResource)element).getParent();
+                       if (parent != null && parent.isAccessible()) {
+                               ICElement cParent= CoreModel.getDefault().create(parent);
+                               if (cParent != null && cParent.exists()) {
+                                       return cParent;
+                               }
+                       }
+                       return parent;
+               }
+               Object parent = null;
+               if (element instanceof ICElement) {
+                       if (element instanceof ICContainer && !CCorePlugin.showSourceRootsAtTopOfProject()) {
+                               parent = ((ICContainer) element).getResource().getParent();
+                       }
+                       else
+                       parent = ((ICElement)element).getParent();
+                       // translate working copy parent to original TU,
+                       // because working copies are never returned by getChildren
+                       // this is necessary for proper show-in-target support
+                       if (parent instanceof IWorkingCopy) {
+                               parent= ((IWorkingCopy)parent).getOriginalElement();
+                       }
+               } else if (element instanceof IWorkbenchAdapter) {
+                       parent = ((IWorkbenchAdapter)element).getParent(element);
+               }
+
+               // if the parent is the default ISourceRoot == ICProject  return the project
+               if (parent instanceof ISourceRoot) {
+                       if (isProjectSourceRoot((ISourceRoot)parent)) {
+                               parent = ((ISourceRoot)parent).getCProject();
+                       }
+               } else if (parent instanceof IBinaryContainer || parent instanceof IArchiveContainer) {
+                       // If the virtual container is the parent we must find the legitimate parent.
+                       if (element instanceof ICElement) {
+                               IResource res = ((ICElement)element).getResource();
+                               if (res != null) {
+                                       parent = internalGetParent(res);
+                               }
+                       }
+               }
+               if (parent instanceof INamespace && fNamespacesGrouping) {
+                       final INamespace namespace = (INamespace)parent;
+                       final NamespacesGrouping grouping = new NamespacesGrouping(namespace.getTranslationUnit(), namespace, fMemberGrouping);
+                       if (grouping.getNamespaces().length > 2) {
+                               parent = grouping;
+                       }
+               }
+               if (parent instanceof IMember && fMemberGrouping) {
+                       final IMember member = (IMember)parent;
+                       final String ns = getElementNamespace(member);
+                       if (ns != null) {
+                               Object parentParent = member.getParent();
+                               if (parentParent instanceof INamespace && fNamespacesGrouping) {
+                                       final INamespace namespace = (INamespace)parent;
+                                       final NamespacesGrouping grouping = new NamespacesGrouping(namespace.getTranslationUnit(), namespace);
+                                       if (grouping.getNamespaces().length > 2) {
+                                               parentParent = grouping;
+                                       }
+                               }
+                               return new MembersGrouping(parentParent, ns);
+                       }
+               }
+               // if we are doing grouping for the includes return the grouping container.
+               if (element instanceof IInclude && fIncludesGrouping) {
+                       parent = new IncludesGrouping(((IInclude)element).getTranslationUnit());
+               }
+               if (element instanceof IMacro && fMacroGrouping) {
+                       parent = new MacrosGrouping(((IMacro)element).getTranslationUnit());
+               }
+               return parent;
+       }
+       
+       protected Object[] getCProjects(ICModel cModel) throws CModelException {
+               Object[] objects = cModel.getCProjects();
+               try {
+                       Object[] nonC = cModel.getNonCResources();
+                       if (nonC.length > 0) {
+                               objects = concatenate(objects, nonC);
+                       }
+               } catch (CModelException e) {
+                       //
+               }
+               return objects;
+       }
+
+       protected Object[] getSourceRoots(ICProject cproject) throws CModelException {
+               if (!cproject.getProject().isOpen())
+                       return NO_CHILDREN;
+                       
+               List<ICElement> list= new ArrayList<ICElement>();
+               ICElement[] children = cproject.getChildren();
+               for (ICElement child : children) {
+                       if (child instanceof ISourceRoot && child.getResource().getType() == IResource.PROJECT) {
+                               // Was a source root at the project, get the children of this element
+                               ICElement[] c2 = ((ISourceRoot)child).getChildren();
+                               for (int k = 0; k < c2.length; ++k)
+                                       list.add(c2[k]);
+                       } else if (CCorePlugin.showSourceRootsAtTopOfProject()) {
+                               list.add(child);
+                       } else if (child instanceof ISourceRoot && 
+                                               child.getResource().getParent().equals(cproject.getProject())) {        
+                               list.add(child);
+               }
+               }
+
+               Object[] objects = list.toArray();
+               Object[] nonC = cproject.getNonCResources();
+               if (nonC != null && nonC.length > 0) {
+                       nonC = filterNonCResources(nonC, cproject);
+                       objects = concatenate(objects, nonC);
+               }
+
+               return objects;
+       }
+
+       protected Object[] getTranslationUnitChildren(ITranslationUnit unit) throws CModelException {
+               Object[] children = unit.getChildren();
+               if (fIncludesGrouping) {
+                       boolean hasInclude = false;
+                       ArrayList<Object> list = new ArrayList<Object>(children.length);
+                       for (int i = 0; i < children.length; i++) {
+                               if (!(children[i] instanceof IInclude)) {
+                                       list.add(children[i]);
+                               } else {
+                                       hasInclude = true;
+                               }
+                       }
+                       if (hasInclude) {
+                               list.add (0, new IncludesGrouping(unit));
+                       }
+                       children = list.toArray();
+               }
+               Map<String, NamespacesGrouping> nsmap = new HashMap<String, NamespacesGrouping>();
+               if (fNamespacesGrouping) {
+                       // check if there is another namespace with the same name for the same parent
+                       List<Object> list = new ArrayList<Object>(children.length);
+                       for (int i = 0; i < children.length; ++i) {
+                               if (children[i] instanceof INamespace) {
+                                       INamespace n1 = (INamespace)children[i];
+                                       NamespacesGrouping namespacesGrouping = nsmap.get(n1.getElementName());
+                                       if (namespacesGrouping == null) {
+                                               namespacesGrouping = new NamespacesGrouping(unit, n1, fMemberGrouping);
+                                               if (namespacesGrouping.getNamespaces().length > 1) {
+                                                       nsmap.put(n1.getElementName(), namespacesGrouping);
+                                                       list.add(namespacesGrouping);
+                                               } else {
+                                                       list.add(children[i]);
+                                               }
+                                       }
+                               } else {
+                                       list.add(children[i]);
+                               }
+                       }
+                       children = list.toArray();
+               }
+               if (fMemberGrouping) {
+                       // check if there is another member with the same namespace for the same parent
+                       List<Object> list = new ArrayList<Object>(children.length);
+                       Map<String, MembersGrouping> map = new HashMap<String, MembersGrouping>();
+                       for (int i = 0; i < children.length; ++i) {
+                               if (children[i] instanceof IMember) {
+                                       final ICElement member = (ICElement)children[i];
+                                       String namespace = getElementNamespace(member);
+                                       MembersGrouping memberGrouping = map.get(namespace);
+                                       if (memberGrouping == null) {
+                                               memberGrouping = new MembersGrouping(unit, namespace);
+                                               map.put(namespace, memberGrouping);
+                                               list.add(memberGrouping);
+                                       }
+                               } else if (fNamespacesGrouping && children[i] instanceof INamespace) {
+                                       if (!nsmap.containsKey(((INamespace) children[i]).getElementName())) {
+                                               list.add(children[i]);
+                                       }
+                               } else {
+                                       list.add(children[i]);
+                               }
+                       }
+                       children = list.toArray();
+               }
+               if (fMacroGrouping) {
+                       ArrayList<Object> list = new ArrayList<Object>(children.length);
+                       boolean hasMacros = false;
+                       for (int i = 0; i < children.length; i++) {
+                               if (!(children[i] instanceof IMacro))
+                                       list.add(children[i]);
+                               else
+                                       hasMacros = true;
+                       }
+                       if (hasMacros) {
+                               //Check if include gouping is there. If so, put macros after
+                               if(!list.isEmpty()){
+                                       if(list.get(0) instanceof IncludesGrouping)
+                                               list.add (1, new MacrosGrouping(unit));
+                                       else
+                                               list.add (0, new MacrosGrouping(unit));
+                               }
+                               else
+                                       list.add (0, new MacrosGrouping(unit));
+                       }
+                       children = list.toArray();
+               }
+               return children;
+       }
+
+       protected Object[] getNamespaceChildren(IParent element) throws CModelException {
+               Object[] children = element.getChildren();
+               if (fMemberGrouping) {
+                       // check if there is another member with the same namespace for the same parent
+                       List<Object> list = new ArrayList<Object>(children.length);
+                       Map<String, MembersGrouping> map = new HashMap<String, MembersGrouping>();
+                       for (int i = 0; i < children.length; ++i) {
+                               if (children[i] instanceof IMember) {
+                                       final ICElement member = (ICElement)children[i];
+                                       String namespace = getElementNamespace(member);
+                                       MembersGrouping memberGrouping = map.get(namespace);
+                                       if (memberGrouping == null) {
+                                               memberGrouping = new MembersGrouping(element, namespace);
+                                               map.put(namespace, memberGrouping);
+                                               list.add(memberGrouping);
+                                       }
+                               } else {
+                                       list.add(children[i]);
+                               }
+                       }
+                       children = list.toArray();
+               }
+               return children;
+       }
+
+       private static String getElementNamespace(ICElement member) {
+               String name = member.getElementName();
+               int idx = name.lastIndexOf("::"); //$NON-NLS-1$
+               if (idx < 0) {
+                       return null;
+               }
+               return name.substring(0, idx);
+       }
+
+       protected Object[] getCResources(ICContainer container) throws CModelException {
+               Object[] objects = null;
+               ICElement[] children = container.getChildren();
+               List<ICElement> missingElements = Collections.emptyList();
+               if (!CCorePlugin.showSourceRootsAtTopOfProject()) {
+                       missingElements = getMissingElements(container, children);
+               }
+               try {
+                       objects = container.getNonCResources();
+                       if (objects.length > 0) {
+                               objects = filterNonCResources(objects, container.getCProject());
+                       }
+               } catch (CModelException e) {
+               }
+               
+               Object[] result = children;
+               if (missingElements.size() > 0) {
+            result = concatenate(result, missingElements.toArray());
+               }
+
+               if (objects != null && objects.length > 0) {
+                       result = concatenate(result, objects);
+               }
+
+               return result;
+       }
+
+       private List<ICElement> getMissingElements(ICContainer container, ICElement[] elements) {
+               // nested source roots may be filtered out below the project root, 
+               // we need to find them to add them back in
+               List<ICElement> missingElements = new ArrayList<ICElement>();
+               try {
+                       List<IResource> missingContainers = new ArrayList<IResource>();
+                       IResource[] allChildren = ((IContainer) container.getResource()).members();
+                       for (IResource child : allChildren) {
+                               if (!(child instanceof IContainer))
+                                       continue;
+                               boolean found = false;
+                               for (ICElement element : elements) {
+                                       if (element.getResource().equals(child)) {
+                                               found = true;
+                                               break;
+                                       }
+                               }
+                               if (!found)
+                                       missingContainers.add(child);
+                       }
+                       for (IResource resource : missingContainers) {
+                               ICElement element = container.getCProject().findElement(resource.getFullPath());
+                               if (element != null)
+                                       missingElements.add(element);
+                       }
+               } catch (CoreException e1) {
+               }
+               return missingElements;
+       }
+
+       protected Object[] getResources(IProject project) {
+               try {
+                       return project.members();
+               } catch (CoreException e) {
+               }
+               return NO_CHILDREN;
+       }
+
+       protected Object[] getResources(IFolder folder) throws CModelException {
+               ICProject cproject = CoreModel.getDefault().create(folder.getProject());
+               Object[] members = null;
+               try {
+                       members = folder.members();
+               } catch (CoreException e) {
+                       //
+               }
+               if (members == null || members.length == 0) {
+                       return NO_CHILDREN;
+               }
+               return filterNonCResources(members, cproject);
+       }
+       
+       private Object[] filterNonCResources(Object[] objects, ICProject cproject) throws CModelException {
+               ICElement[] binaries = null;
+               ICElement[] archives = null;
+               try {
+                       binaries = getBinaries(cproject);
+                       archives = getArchives(cproject);
+               } catch (CModelException e) {
+                       archives = binaries = new ICElement[0];
+               }
+               ISourceRoot[] roots = null;
+               try {
+                       roots = cproject.getSourceRoots();
+               } catch (CModelException e) {
+                       roots = new ISourceRoot[0];
+               }
+               List<Object> nonCResources = new ArrayList<Object>(objects.length);
+               for (Object object : objects) {
+                       Object o= object;
+                       // A folder can also be a source root in the following case
+                       // Project
+                       //  + src <- source folder
+                       //    + excluded <- excluded from class path
+                       //      + included  <- a new source folder.
+                       // Included is a member of excluded, but since it is rendered as a source
+                       // folder we have to exclude it as a normal child.
+                       if (o instanceof IFolder) {
+                               IFolder folder = (IFolder)o;
+                               ISourceRoot root = null;
+                               for (int j = 0; j < roots.length; j++) {
+                                       if (roots[j].getPath().equals(folder.getFullPath())) {
+                                               root = roots[j];
+                                               break;
+                                       }
+                               }
+                               // it is a sourceRoot skip it.
+                               if (root != null) {
+                                       if (CCorePlugin.showSourceRootsAtTopOfProject())
+                                       continue;
+                                       else
+                                               o = root;
+                               }
+                       } else if (o instanceof IFile){
+                               boolean found = false;
+                               for (ICElement binarie : binaries) {
+                                       IResource res = binarie.getResource();
+                                       if (o.equals(res)) {
+                                               o = binarie;
+                                               found = true;
+                                               break;
+                                       }
+                               }
+                               if (!found) {
+                                       for (ICElement archive : archives) {
+                                               IResource res = archive.getResource();
+                                               if (o.equals(res)) {
+                                                       o = archive;
+                                                       break;
+                                               }
+                                       }
+                               }
+                       }
+                       nonCResources.add(o);
+               }
+               return nonCResources.toArray();
+       }
+
+       /**
+        * Note: This method is for internal use only. Clients should not call this method.
+        */
+       protected boolean isProjectSourceRoot(ISourceRoot root) {
+               IResource resource= root.getResource();
+               return (resource instanceof IProject);
+       }
+
+       protected boolean exists(Object element) {
+               if (element == null) {
+                       return false;
+               }
+               if (element instanceof IResource) {
+                       return ((IResource)element).exists();
+               }
+               if (element instanceof ICElement) {
+                       return ((ICElement)element).exists();
+               }
+               return true;
+       }
+
+       protected IBinary[] getBinaries(ICProject cproject) throws CModelException {
+               IBinaryContainer container = cproject.getBinaryContainer();
+               return getBinaries(container);
+       }
+
+       protected IBinary[] getBinaries(IBinaryContainer container) throws CModelException {
+               ICElement[] celements = container.getChildren();
+               ArrayList<IBinary> list = new ArrayList<IBinary>(celements.length);
+               for (ICElement celement : celements) {
+                       if (celement instanceof IBinary) {
+                               IBinary bin = (IBinary)celement;
+                               list.add(bin);
+                       }
+               }
+               IBinary[] bins = new IBinary[list.size()];
+               list.toArray(bins);
+               return bins;
+       }
+
+       protected IArchive[] getArchives(ICProject cproject) throws CModelException {
+               IArchiveContainer container = cproject.getArchiveContainer();
+               return getArchives(container);
+       }
+
+       protected IArchive[] getArchives(IArchiveContainer container) throws CModelException {
+               ICElement[] celements = container.getChildren();
+               ArrayList<IArchive> list = new ArrayList<IArchive>(celements.length);
+               for (ICElement celement : celements) {
+                       if (celement instanceof IArchive) {
+                               IArchive ar = (IArchive)celement;
+                               list.add(ar);
+                       }
+               }
+               IArchive[] ars = new IArchive[list.size()];
+               list.toArray(ars);
+               return ars;
+       }
+
+       /**
+        * Note: This method is for internal use only. Clients should not call this method.
+        */
+       protected static Object[] concatenate(Object[] a1, Object[] a2) {
+               int a1Len = a1.length;
+               int a2Len = a2.length;
+               Object[] res = new Object[a1Len + a2Len];
+               System.arraycopy(a1, 0, res, 0, a1Len);
+               System.arraycopy(a2, 0, res, a1Len, a2Len);
+               return res;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BinaryPropertySource.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BinaryPropertySource.java
new file mode 100644 (file)
index 0000000..24b90d5
--- /dev/null
@@ -0,0 +1,209 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.viewers.IBasicPropertyConstants;
+import org.eclipse.ui.views.properties.FilePropertySource;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.PropertyDescriptor;
+
+import org.eclipse.cdt.core.model.IBinary;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+public class BinaryPropertySource extends FilePropertySource {
+       
+       private final static String ELF_CPU= "CElementProperties.elf_cpu"; //$NON-NLS-1$
+       private final static String ELF_TEXT= "CElementProperties.elf_text"; //$NON-NLS-1$
+       private final static String ELF_DATA= "CElementProperties.elf_data"; //$NON-NLS-1$
+       private final static String ELF_BSS= "CElementProperties.elf_bss"; //$NON-NLS-1$
+       private final static String ELF_TYPE= "CElementProperties.elf_type"; //$NON-NLS-1$
+       private final static String ELF_HAS_DEBUG= "CElementProperties.elf_has_debug"; //$NON-NLS-1$
+       private final static String ELF_SONAME= "CElementProperties.elf_soname"; //$NON-NLS-1$
+       private final static String ELF_NEEDED= "CElementProperties.elf_needed"; //$NON-NLS-1$
+       
+       private IBinary binary;
+       
+       // Property Descriptors
+       static private IPropertyDescriptor[] fgPropertyDescriptors;
+       
+       /**
+        * Get a PropertyDescriptor that defines the binary properties of an Elf
+        * @return the PropertyDescriptor
+        */
+       private static IPropertyDescriptor[] getInitialPropertyDescriptor() {
+               // cpu name
+               String cpuName= CUIPlugin.getResourceString(ELF_CPU);
+               PropertyDescriptor cpuDescriptor= new PropertyDescriptor(ICElementPropertyConstants.P_ELF_CPU, cpuName);
+               cpuDescriptor.setAlwaysIncompatible(true);
+               cpuDescriptor.setCategory(ICElementPropertyConstants.P_BINARY_FILE_CATEGORY);
+
+               // elf text
+               String textName = CUIPlugin.getResourceString(ELF_TEXT);
+               PropertyDescriptor textDescriptor= new PropertyDescriptor(ICElementPropertyConstants.P_ELF_TEXT, textName);
+               textDescriptor.setAlwaysIncompatible(true);
+               textDescriptor.setCategory(ICElementPropertyConstants.P_BINARY_FILE_CATEGORY);
+               
+               // elf data
+               String dataName = CUIPlugin.getResourceString(ELF_DATA);
+               PropertyDescriptor dataDescriptor= new PropertyDescriptor(ICElementPropertyConstants.P_ELF_DATA, dataName);
+               dataDescriptor.setAlwaysIncompatible(true);
+               dataDescriptor.setCategory(ICElementPropertyConstants.P_BINARY_FILE_CATEGORY);
+               
+               // elf bss
+               String bssName = CUIPlugin.getResourceString(ELF_BSS);
+               PropertyDescriptor bssDescriptor= new PropertyDescriptor(ICElementPropertyConstants.P_ELF_BSS, bssName);
+               bssDescriptor.setAlwaysIncompatible(true);
+               bssDescriptor.setCategory(ICElementPropertyConstants.P_BINARY_FILE_CATEGORY);
+               
+               // elf type
+               String typeName = CUIPlugin.getResourceString(ELF_TYPE);
+               PropertyDescriptor typeDescriptor= new PropertyDescriptor(ICElementPropertyConstants.P_ELF_TYPE, typeName);
+               typeDescriptor.setAlwaysIncompatible(true);
+               typeDescriptor.setCategory(ICElementPropertyConstants.P_BINARY_FILE_CATEGORY);
+               
+               // elf needed
+               String neededName = CUIPlugin.getResourceString(ELF_NEEDED);
+               PropertyDescriptor neededDescriptor= new PropertyDescriptor(ICElementPropertyConstants.P_ELF_NEEDED, neededName);
+               neededDescriptor.setAlwaysIncompatible(true);
+               neededDescriptor.setCategory(ICElementPropertyConstants.P_BINARY_FILE_CATEGORY);
+               
+               // elf soname
+               String sonameName = CUIPlugin.getResourceString(ELF_SONAME);
+               PropertyDescriptor sonameDescriptor= new PropertyDescriptor(ICElementPropertyConstants.P_ELF_SONAME, sonameName);
+               sonameDescriptor.setAlwaysIncompatible(true);
+               sonameDescriptor.setCategory(ICElementPropertyConstants.P_BINARY_FILE_CATEGORY);
+               
+               // elf debug
+               String debugName = CUIPlugin.getResourceString(ELF_HAS_DEBUG);
+               PropertyDescriptor debugDescriptor= new PropertyDescriptor(ICElementPropertyConstants.P_ELF_HAS_DEBUG, debugName);
+               debugDescriptor.setAlwaysIncompatible(true);
+               debugDescriptor.setCategory(ICElementPropertyConstants.P_BINARY_FILE_CATEGORY);
+               
+               return new IPropertyDescriptor[] { cpuDescriptor, textDescriptor, dataDescriptor,
+                       bssDescriptor, typeDescriptor, sonameDescriptor, debugDescriptor, neededDescriptor };
+       }
+       
+       public BinaryPropertySource(IBinary bin) {
+               super((IFile)bin.getResource());
+               binary= bin;
+       }
+
+       /**
+        * @see IPropertySource#getPropertyDescriptors
+        */
+       @Override
+       public IPropertyDescriptor[] getPropertyDescriptors() {
+               if (fgPropertyDescriptors == null) {
+                       initializeBinaryDescriptors();
+               }
+               return fgPropertyDescriptors;
+       }
+
+       /**
+        * @see IPropertySource#getPropertyValue
+        */     
+       @Override
+       public Object getPropertyValue(Object name) {
+               if (element != null) {
+                       Object returnValue = super.getPropertyValue(name);
+                       if(returnValue != null) {
+                               return returnValue;
+                       }
+               }
+               if (name.equals(IBasicPropertyConstants.P_TEXT)) {
+                       return binary.getElementName();
+               } else if (name.equals(ICElementPropertyConstants.P_ELF_CPU)) {
+                       return binary.getCPU();
+               } else if (name.equals(ICElementPropertyConstants.P_ELF_TEXT)) {
+                       return Long.toString(binary.getText());
+               } else if (name.equals(ICElementPropertyConstants.P_ELF_DATA)) {
+                       return Long.toString(binary.getData());
+               } else if (name.equals(ICElementPropertyConstants.P_ELF_BSS)) {
+                       return Long.toString(binary.getBSS());
+               } else if (name.equals(ICElementPropertyConstants.P_ELF_SONAME)) {
+                       return binary.getSoname();
+               } else if (name.equals(ICElementPropertyConstants.P_ELF_HAS_DEBUG)) {
+                        if (binary.hasDebug()) {
+                               return "true";//$NON-NLS-1$
+                       }
+                       return "false";//$NON-NLS-1$
+               } else if (name.equals(ICElementPropertyConstants.P_ELF_NEEDED)) {
+                       String[] needed = binary.getNeededSharedLibs();
+                       String need = ""; //$NON-NLS-1$
+                       for (int i = 0; i < needed.length; i++) {
+                               need += " " + needed[i]; //$NON-NLS-1$
+                       }
+                       return need.trim();
+               } else if (name.equals(ICElementPropertyConstants.P_ELF_TYPE)) {
+                       if (binary.isObject()) {
+                               return "object"; //$NON-NLS-1$
+                       } else if (binary.isExecutable()) {
+                               return "executable"; //$NON-NLS-1$
+                       } else if (binary.isSharedLib()) {
+                               return "shared library"; //$NON-NLS-1$
+                       } else if (binary.isCore()) {
+                               return "core file"; //$NON-NLS-1$
+                       }
+               }
+               return null;
+       }
+
+       /**
+        * Return the Property Descriptors for the file type.
+        */
+       private void initializeBinaryDescriptors() {
+               if (element != null) {
+                       IPropertyDescriptor[] superDescriptors = super.getPropertyDescriptors();
+                       int superLength = superDescriptors.length;
+                       IPropertyDescriptor[] binDescriptors = getInitialPropertyDescriptor();
+                       int binLength = binDescriptors.length;
+                       fgPropertyDescriptors = new IPropertyDescriptor[superLength + binLength];
+                       System.arraycopy(superDescriptors, 0, fgPropertyDescriptors, 0, superLength);
+                       System.arraycopy(binDescriptors, 0, fgPropertyDescriptors, superLength, binLength);
+               } else {
+                       fgPropertyDescriptors = getInitialPropertyDescriptor();
+               }
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
+        */
+       @Override
+       public Object getEditableValue() {
+               return this;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
+        */
+       @Override
+       public boolean isPropertySet(Object id) {
+               return false;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
+        */
+       @Override
+       public void resetPropertyValue(Object id) {
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
+        */
+       @Override
+       public void setPropertyValue(Object id, Object value) {
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CActionFilter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CActionFilter.java
new file mode 100644 (file)
index 0000000..8912250
--- /dev/null
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.ui.IActionFilter;
+
+import org.eclipse.cdt.core.model.ICElement;
+
+/**
+ * An implementation of the IWorkbenchAdapter for CElements.
+ */
+public class CActionFilter implements IActionFilter {
+
+       public CActionFilter() {
+       }
+
+       public boolean testAttribute(Object target, String name, String value) {
+               ICElement element = (ICElement) target;
+               IResource resource = element.getResource();
+               if (resource != null) {
+                       IActionFilter filter = (IActionFilter) resource.getAdapter(IActionFilter.class);
+                       if (filter != null) {
+                               return filter.testAttribute(resource, name, value);
+                       }
+               }
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java
new file mode 100644 (file)
index 0000000..f3c1983
--- /dev/null
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.ui.IActionFilter;
+import org.eclipse.ui.IPersistableElement;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.eclipse.ui.progress.IDeferredWorkbenchAdapter;
+import org.eclipse.ui.views.properties.FilePropertySource;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.ResourcePropertySource;
+
+import org.eclipse.cdt.core.model.IBinary;
+import org.eclipse.cdt.core.model.ICElement;
+
+/**
+ * Implements basic UI support for C elements.
+ */
+public class CElementAdapterFactory implements IAdapterFactory {
+       
+       private static Class<?>[] PROPERTIES= new Class[] {
+               IPropertySource.class,
+               IResource.class,
+               IWorkbenchAdapter.class,
+               IPersistableElement.class,
+               IDeferredWorkbenchAdapter.class,
+               IActionFilter.class 
+       };
+       
+       private static CWorkbenchAdapter fgCWorkbenchAdapter;
+       private static CActionFilter fgCActionFilter;
+       
+       /**
+        * @see CElementAdapterFactory#getAdapterList
+        */
+       public Class<?>[] getAdapterList() {
+               return PROPERTIES;
+       }
+
+       /**
+        * @see CElementAdapterFactory#getAdapter
+        */     
+       @SuppressWarnings({ "unchecked", "rawtypes" })
+       public Object getAdapter(Object element, Class key) {
+               ICElement celem = (ICElement) element;
+               
+               if (IPropertySource.class.equals(key)) {
+                       return getPropertySource(celem);
+               } else if (IResource.class.isAssignableFrom(key)) {
+                       IResource resource= getResource(celem);
+                       if (resource != null && key.isAssignableFrom(resource.getClass())) {
+                               return resource;
+                       }
+               } else if (IPersistableElement.class.equals(key)) {
+                       return new PersistableCElementFactory(celem);
+               } else if (IDeferredWorkbenchAdapter.class.equals(key)) {
+                       return getDeferredWorkbenchAdapter(celem);
+               } else if (IWorkbenchAdapter.class.equals(key)) {
+                       return getWorkbenchAdapter(celem);
+               } else if (IActionFilter.class.equals(key)) {
+                       return getActionFilter(celem);
+               }
+               return null; 
+       }
+
+       private IPropertySource getPropertySource(ICElement celement) {
+               if (celement instanceof IBinary) {
+                       return new BinaryPropertySource((IBinary)celement);                             
+               }
+               IResource res = celement.getResource();
+               if (res != null) {
+                       if (res instanceof IFile) {
+                               return new FilePropertySource((IFile)res);
+                       }
+                       return new ResourcePropertySource(res);
+               }
+               return new CElementPropertySource(celement);            
+       }
+
+       private IResource getResource(ICElement celement) {
+               return celement.getResource();
+       }
+
+       private IDeferredWorkbenchAdapter getDeferredWorkbenchAdapter(ICElement celement) {
+               return new DeferredCWorkbenchAdapter(celement);
+       }
+
+       private IWorkbenchAdapter getWorkbenchAdapter(ICElement celement) {
+               if (fgCWorkbenchAdapter == null) {
+                       fgCWorkbenchAdapter = new CWorkbenchAdapter();
+               }
+               return fgCWorkbenchAdapter;
+       }
+       
+       private IActionFilter getActionFilter(ICElement celement) {
+               if (fgCActionFilter == null) {
+                       fgCActionFilter = new CActionFilter();
+               }
+               return fgCActionFilter;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementPropertySource.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementPropertySource.java
new file mode 100644 (file)
index 0000000..e69c13d
--- /dev/null
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.jface.viewers.IBasicPropertyConstants;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.PropertyDescriptor;
+
+public class CElementPropertySource implements IPropertySource {
+       
+       private final static String LABEL= "CElementProperties.name"; //$NON-NLS-1$
+       
+       private ICElement fCElement;
+       
+       // Property Descriptors
+       static private IPropertyDescriptor[] fgPropertyDescriptors;
+       
+       static {
+               // resource name
+               String displayName= CUIPlugin.getResourceString(LABEL);
+               PropertyDescriptor descriptor= new PropertyDescriptor(IBasicPropertyConstants.P_TEXT, displayName);
+               descriptor.setAlwaysIncompatible(true);
+               
+               fgPropertyDescriptors= new IPropertyDescriptor[] { descriptor };
+       }
+       
+       public CElementPropertySource(ICElement elem) {
+               fCElement= elem;
+       }
+
+       /**
+        * @see IPropertySource#getPropertyDescriptors
+        */
+       public IPropertyDescriptor[] getPropertyDescriptors() {
+               return fgPropertyDescriptors;
+       }
+
+       /**
+        * @see IPropertySource#getPropertyValue
+        */     
+       public Object getPropertyValue(Object name) {
+               if (name.equals(IBasicPropertyConstants.P_TEXT)) {
+                       return fCElement.getElementName();
+               }
+               return null;
+       }
+
+       /**
+        * @see IPropertySource#setPropertyValue
+        */     
+       public void setPropertyValue(Object name, Object value) {
+       }
+
+       /**
+        * @see IPropertySource#getEditableValue
+        */     
+       public Object getEditableValue() {
+               return null;
+       }
+
+       /**
+        * @see IPropertySource#isPropertySet
+        */     
+       public boolean isPropertySet(Object property) {
+               return false;
+       }
+
+       /**
+        * @see IPropertySource#resetPropertyValue
+        */     
+       public void resetPropertyValue(Object property) {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CHelpProviderManager.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CHelpProviderManager.java
new file mode 100644 (file)
index 0000000..f8096cd
--- /dev/null
@@ -0,0 +1,229 @@
+/**********************************************************************
+ * Copyright (c) 2004, 2006 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *     Intel Corporation - Initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ **********************************************************************/
+package org.eclipse.cdt.internal.ui;
+
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.internal.ui.text.CHelpBookDescriptor;
+import org.eclipse.cdt.internal.ui.text.CHelpSettings;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.ICHelpResourceDescriptor;
+import org.eclipse.cdt.ui.IFunctionSummary;
+import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
+import org.eclipse.core.resources.IProject;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * This class is used to manage external plugins that contribute 
+ * C/C++ help information through the CHelpProvider extension point
+ */
+
+public class CHelpProviderManager {
+       final private static String C_HELP_SETTINGS_FILE_NAME = "cHelpSettings.xml"; //$NON-NLS-1$
+       final private static String ELEMENT_ROOT = "cHelpSettings"; //$NON-NLS-1$
+
+       //private static Map fProjectHelpSettings = null;
+       private static CHelpSettings fDefaultHelpSettings = null;
+       
+       private static File fSettingsFile = null;
+       static private CHelpProviderManager fInstance = null;
+
+       private static IProject fCurrentProject = null;
+       private static CHelpSettings fCurrentSettings = null;
+
+       private CHelpProviderManager() {
+       }
+       
+       private static File getSettingsFile(){
+               if(fSettingsFile == null){
+                       fSettingsFile = CUIPlugin.getDefault().getStateLocation().append(C_HELP_SETTINGS_FILE_NAME).toFile();
+               }
+               return fSettingsFile;
+       }
+       
+//     private static Map getSettingsMap(){
+//             if(fProjectHelpSettings == null)
+//                     fProjectHelpSettings = new HashMap();
+//             return fProjectHelpSettings;
+//     }
+       
+       private static CHelpSettings getDefaultHelpSettings(){
+               if(fDefaultHelpSettings == null){
+                       fDefaultHelpSettings = new CHelpSettings(null);
+               }
+               return fDefaultHelpSettings;
+       }
+
+       private static CHelpSettings getPersistedHelpSettings(IProject project){
+/* uncomment to use Map
+               Map settingsMap = getSettingsMap();
+               CHelpSettings settings = (CHelpSettings)settingsMap.get(project.getName());
+               if(settings == null){
+                       settings = createHelpSettings(project);
+                       settingsMap.put(project.getName(),settings);
+               }
+               return settings;
+*/
+               return createHelpSettings(project);
+       }
+       
+       private static CHelpSettings createHelpSettings(IProject project){
+//             String projectName = project.getName();
+               File file = getSettingsFile();
+               CHelpSettings settings = null;
+               Element rootElement = null;
+
+               if(file.isFile()){
+                       try{
+                               DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+                               Document doc = builder.parse(file);
+                               NodeList nodes = doc.getElementsByTagName(ELEMENT_ROOT);
+                               
+                               if (nodes.getLength() > 0)
+                                       rootElement = (Element)nodes.item(0);
+                               
+                       }catch(ParserConfigurationException e){
+                       }catch(SAXException e){
+                       }catch(IOException e){
+                       }
+               }
+
+               settings = new CHelpSettings(project,rootElement);
+               return settings;
+       }
+       
+       private static CHelpSettings getHelpSettings(IProject project){
+               if(project == null)
+                       return getDefaultHelpSettings();
+
+               CHelpSettings settings = null;
+               if(fCurrentProject != null && fCurrentSettings != null && project == fCurrentProject)
+                       settings = fCurrentSettings;
+               else{
+                       fCurrentProject = project;
+                       fCurrentSettings = getPersistedHelpSettings(project);
+                       settings = fCurrentSettings;
+               }
+               return settings;
+       }
+       
+       private static CHelpSettings getHelpSettings(ICHelpInvocationContext context){
+               IProject project = getProjectFromContext(context);
+               
+               return getHelpSettings(project);
+       }
+       
+       private static IProject getProjectFromContext(ICHelpInvocationContext context){
+               IProject project = context.getProject();
+               if(project == null){
+                       ITranslationUnit unit = context.getTranslationUnit();
+                       if(unit != null)
+                               project = unit.getCProject().getProject();
+               }
+               return project;
+       }
+
+       public static CHelpProviderManager getDefault() {
+               if (fInstance == null) {
+                       fInstance = new CHelpProviderManager();
+               }
+               return fInstance;
+       }
+
+       public IFunctionSummary getFunctionInfo(ICHelpInvocationContext context, String name) {
+               CHelpSettings settings = getHelpSettings(context);
+       
+               return settings.getFunctionInfo(context,name);
+       }
+
+       public IFunctionSummary[] getMatchingFunctions(ICHelpInvocationContext context, String frag) {
+               CHelpSettings settings = getHelpSettings(context);
+               
+               return settings.getMatchingFunctions(context,frag);
+       }
+
+       public ICHelpResourceDescriptor[] getHelpResources(ICHelpInvocationContext context, String name){
+               CHelpSettings settings = getHelpSettings(context);
+               
+               return settings.getHelpResources(context,name);
+       }
+       
+       public CHelpBookDescriptor[] getCHelpBookDescriptors(ICHelpInvocationContext context){
+               return getHelpSettings(context).getCHelpBookDescriptors();
+       }
+       
+       public void serialize(ICHelpInvocationContext context){
+               CHelpSettings settings = getHelpSettings(context);
+
+               File file = getSettingsFile();
+
+               try{
+                       DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+                       Document doc;
+                       Element rootElement = null;
+
+                       if(file.exists()){
+                               doc = builder.parse(file);
+                               NodeList nodes = doc.getElementsByTagName(ELEMENT_ROOT);
+                               
+                               if (nodes.getLength() > 0)
+                                       rootElement = (Element)nodes.item(0);
+                       }
+                       else{
+                               doc = builder.newDocument();
+                       }
+
+                       if(rootElement == null){
+                               rootElement = doc.createElement(ELEMENT_ROOT);
+                               doc.appendChild(rootElement);
+                       }
+
+                       settings.serialize(doc,rootElement);
+
+                       FileWriter writer = new FileWriter(file);
+
+                       Transformer transformer=TransformerFactory.newInstance().newTransformer();
+                       transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
+                       transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
+                       transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
+                       DOMSource source = new DOMSource(doc);
+                       StreamResult result = new StreamResult(writer);
+
+                       transformer.transform(source, result);
+
+                       writer.close();
+               }catch(ParserConfigurationException e){
+               }catch(SAXException e){
+               }catch(TransformerConfigurationException e){
+               }catch(TransformerException e){
+               }catch(IOException e){
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPerspectiveFactory.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPerspectiveFactory.java
new file mode 100644 (file)
index 0000000..192f565
--- /dev/null
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui;
+
+import org.eclipse.cdt.internal.ui.wizards.CWizardRegistry;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.search.ui.NewSearchUI;
+import org.eclipse.ui.IFolderLayout;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+import org.eclipse.ui.console.IConsoleConstants;
+import org.eclipse.ui.navigator.resources.ProjectExplorer;
+
+public class CPerspectiveFactory implements IPerspectiveFactory {
+               
+       /**
+        * Constructs a new Default layout engine.
+        */
+       public CPerspectiveFactory() {
+               super();
+       }
+
+       /**
+        * @see IPerspectiveFactory#createInitialLayout
+        */
+       public void createInitialLayout(IPageLayout layout) {
+               String editorArea = layout.getEditorArea();
+               
+               IFolderLayout folder1= layout.createFolder("topLeft", IPageLayout.LEFT, (float)0.25, editorArea); //$NON-NLS-1$
+               folder1.addView(ProjectExplorer.VIEW_ID);
+               folder1.addPlaceholder(CUIPlugin.CVIEW_ID);
+               folder1.addPlaceholder(IPageLayout.ID_RES_NAV);
+               folder1.addPlaceholder(IPageLayout.ID_BOOKMARKS);
+               
+               IFolderLayout folder2= layout.createFolder("bottom", IPageLayout.BOTTOM, (float)0.75, editorArea); //$NON-NLS-1$
+               folder2.addView(IPageLayout.ID_PROBLEM_VIEW);
+               folder2.addView(IPageLayout.ID_TASK_LIST);
+               folder2.addView(IConsoleConstants.ID_CONSOLE_VIEW);
+               folder2.addView(IPageLayout.ID_PROP_SHEET);
+               
+               IFolderLayout folder3= layout.createFolder("topRight", IPageLayout.RIGHT,(float)0.75, editorArea); //$NON-NLS-1$
+               folder3.addView(IPageLayout.ID_OUTLINE);
+
+               layout.addActionSet(CUIPlugin.SEARCH_ACTION_SET_ID);
+               layout.addActionSet(CUIPlugin.ID_CELEMENT_CREATION_ACTION_SET);
+               layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET);
+               
+               // views - build console
+               layout.addShowViewShortcut(IConsoleConstants.ID_CONSOLE_VIEW);
+               
+               // views - searching
+               layout.addShowViewShortcut(NewSearchUI.SEARCH_VIEW_ID);
+               
+               // views - standard workbench
+               layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
+               layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW);
+               layout.addShowViewShortcut(CUIPlugin.CVIEW_ID);
+               layout.addShowViewShortcut(IPageLayout.ID_RES_NAV);
+               layout.addShowViewShortcut(IPageLayout.ID_PROP_SHEET);
+               layout.addShowViewShortcut(IPageLayout.ID_TASK_LIST);
+
+               addCWizardShortcuts(layout);
+       }
+       
+       private void addCWizardShortcuts(IPageLayout layout) {
+               // new actions - C project creation wizard
+               String[] wizIDs = CWizardRegistry.getProjectWizardIDs();
+               for (int i = 0; i < wizIDs.length; ++i) {
+                       layout.addNewWizardShortcut(wizIDs[i]);
+               }
+               // new actions - C folder creation wizard
+               wizIDs = CWizardRegistry.getFolderWizardIDs();
+               for (int i = 0; i < wizIDs.length; ++i) {
+                       layout.addNewWizardShortcut(wizIDs[i]);
+               }
+               // new actions - C file creation wizard
+               wizIDs = CWizardRegistry.getFileWizardIDs();
+               for (int i = 0; i < wizIDs.length; ++i) {
+                       layout.addNewWizardShortcut(wizIDs[i]);
+               }
+               // new actions - C type creation wizard
+               wizIDs = CWizardRegistry.getTypeWizardIDs();
+               for (int i = 0; i < wizIDs.length; ++i) {
+                       layout.addNewWizardShortcut(wizIDs[i]);
+               }
+               
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java
new file mode 100644 (file)
index 0000000..c600ac5
--- /dev/null
@@ -0,0 +1,597 @@
+/*******************************************************************************
+ *  Copyright (c) 2005, 2010 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Markus Schorn (Wind River Systems)
+ *     Anton Leherbauer (Wind River Systems)
+ *     Sergey Prigogin (Google) 
+ *     Dmitry Kozlov (CodeSourcery)
+ *     Tomasz Wesolowski
+ *     Andrew Gvozdev (Quoin Inc.) - moved usage involving registry to CDTSharedImages
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui;
+
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.graphics.Image;
+import org.osgi.framework.Bundle;
+
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * This is internal class with some helper methods for handling images.
+ * The use of this class for images managed by registry is deprecated,
+ * use public API class {@link CDTSharedImages} for that.
+ */
+public class CPluginImages {
+       public static final IPath ICONS_PATH= new Path("$nl$/icons"); //$NON-NLS-1$
+
+       /** Converter from CPluginImages key to CDTSharedImages key */
+       private static Map<String, String> fPathMap = new HashMap<String, String>();
+
+       private static final String NAME_PREFIX= CUIPlugin.PLUGIN_ID + '.';
+       private static final int NAME_PREFIX_LENGTH= NAME_PREFIX.length();
+
+       private static final String ICONS= "icons/"; //$NON-NLS-1$
+       public static final String T_OBJ= "obj16/"; //$NON-NLS-1$
+       public static final String T_WIZBAN= "wizban/"; //$NON-NLS-1$
+       public static final String T_LCL=  "lcl16/"; //$NON-NLS-1$
+       public static final String T_DLCL=  "dlcl16/"; //$NON-NLS-1$
+       public static final String T_ELCL=  "elcl16/"; //$NON-NLS-1$
+       public static final String T_TOOL= "tool16/"; //$NON-NLS-1$
+       public static final String T_VIEW= "view16/"; //$NON-NLS-1$
+       public static final String T_OVR= "ovr16/"; //$NON-NLS-1$
+
+       public static final String IMG_OBJS_TEMPLATE= NAME_PREFIX + "template_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_VARIABLE= NAME_PREFIX + "variable_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_LOCAL_VARIABLE= NAME_PREFIX + "variable_local_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_CLASS= NAME_PREFIX + "class_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_CLASS_ALT= NAME_PREFIX + "classfo_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_NAMESPACE= NAME_PREFIX + "namespace_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_USING= NAME_PREFIX + "using_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_STRUCT= NAME_PREFIX + "struct_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_STRUCT_ALT= NAME_PREFIX + "structfo_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_UNION= NAME_PREFIX + "union_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_UNION_ALT= NAME_PREFIX + "unionfo_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_TYPEDEF= NAME_PREFIX + "typedef_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_TYPEDEF_ALT= NAME_PREFIX + "typedeffo_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_ENUMERATION= NAME_PREFIX + "enum_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_ENUMERATION_ALT= NAME_PREFIX + "enumfo_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_UNKNOWN_TYPE= NAME_PREFIX + "unknown_type_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_ENUMERATOR= NAME_PREFIX + "enumerator_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_FUNCTION= NAME_PREFIX + "function_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_PUBLIC_METHOD= NAME_PREFIX + "method_public_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_PROTECTED_METHOD= NAME_PREFIX + "method_protected_obj.gif"; //$NON-NLS-1$
+
+       public static final String IMG_OBJS_PRIVATE_METHOD= NAME_PREFIX + "method_private_obj.gif";      //$NON-NLS-1$
+       public static final String IMG_OBJS_PUBLIC_FIELD= NAME_PREFIX + "field_public_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_PROTECTED_FIELD= NAME_PREFIX + "field_protected_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_PRIVATE_FIELD= NAME_PREFIX + "field_private_obj.gif";        //$NON-NLS-1$
+       public static final String IMG_OBJS_KEYWORD= NAME_PREFIX + "keyword_obj.gif";    //$NON-NLS-1$
+       
+       public static final String IMG_OBJS_DECLARATION= NAME_PREFIX + "cdeclaration_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_VAR_DECLARATION= NAME_PREFIX + "var_declaration_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_INCLUDE= NAME_PREFIX + "include_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_MACRO= NAME_PREFIX + "define_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_LABEL= NAME_PREFIX + "label_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_TUNIT= NAME_PREFIX + "c_file_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_TUNIT_HEADER= NAME_PREFIX + "h_file_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_TUNIT_ASM= NAME_PREFIX + "s_file_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_TUNIT_RESOURCE= NAME_PREFIX + "c_resource_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_TUNIT_RESOURCE_H= NAME_PREFIX + "ch_resource_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_TUNIT_RESOURCE_A= NAME_PREFIX + "asm_resource_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_SOURCE_ROOT=  NAME_PREFIX + "sroot_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_SOURCE2_ROOT=  NAME_PREFIX + "sroot2_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_FOLDER=  NAME_PREFIX + "fldr_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_CFOLDER=  NAME_PREFIX + "cfolder_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_CONFIG =  NAME_PREFIX + "config.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_ARCHIVE= NAME_PREFIX + "ar_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_BINARY= NAME_PREFIX + "bin_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_SHLIB= NAME_PREFIX + "shlib_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_CEXEC= NAME_PREFIX + "exec_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_CEXEC_DEBUG= NAME_PREFIX + "exec_dbg_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_CORE= NAME_PREFIX + "core_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_CONTAINER= NAME_PREFIX + "container_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_ARCHIVES_CONTAINER= NAME_PREFIX + "archives_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_BINARIES_CONTAINER= NAME_PREFIX + "binaries_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_OUTPUT_FOLDER= NAME_PREFIX + "output_folder_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_LIBRARY= NAME_PREFIX + "lib_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_INCLUDES_CONTAINER = NAME_PREFIX + "includes_container.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_INCLUDES_FOLDER = NAME_PREFIX + "hfolder_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_QUOTE_INCLUDES_FOLDER = NAME_PREFIX + "hfolder_quote_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_INCLUDES_FOLDER_SYSTEM = NAME_PREFIX + "fldr_sys_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_INCLUDES_FOLDER_WORKSPACE = NAME_PREFIX + "wsp_includefolder.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_ORDER= NAME_PREFIX + "cp_order_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_EXCLUDSION_FILTER_ATTRIB= NAME_PREFIX + "exclusion_filter_attrib.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_SOURCE_ATTACH_ATTRIB = NAME_PREFIX + "source_attach_attrib.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_ARCHIVE_WSRC= NAME_PREFIX + "ar_src_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_IMPORT_SETTINGS = NAME_PREFIX + "import_settings_wiz.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_EXPORT_SETTINGS = NAME_PREFIX + "export_settings_wiz.gif"; //$NON-NLS-1$
+
+       public static final String IMG_OBJS_PROJECT=NAME_PREFIX + "prj_obj.gif"; //$NON-NLS-1$
+
+       public static final String IMG_OBJS_INCCONT= NAME_PREFIX + "incc_obj.gif";                      //$NON-NLS-1$
+
+       // Breakpoint images
+       public static final String IMG_OBJS_BREAKPOINT = NAME_PREFIX + "breakpoint.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_BREAKPOINT_DISABLED = NAME_PREFIX + "breakpoint_disabled.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_BREAKPOINT_ACTIVE = NAME_PREFIX + "breakpoint_active.gif"; //$NON-NLS-1$
+
+       public static final String IMG_OBJS_FIXABLE_PROBLEM= NAME_PREFIX + "quickfix_warning_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_FIXABLE_ERROR= NAME_PREFIX + "quickfix_error_obj.gif"; //$NON-NLS-1$
+
+       // build console
+       public static final String IMG_VIEW_BUILD = NAME_PREFIX + "buildconsole.gif"; //$NON-NLS-1$
+       public static final String IMG_SAVE_CONSOLE = NAME_PREFIX + "save_console.gif";   //$NON-NLS-1$
+
+       // unknown type
+       public static final String IMG_OBJS_UNKNOWN = NAME_PREFIX + "unknown_obj.gif"; //$NON-NLS-1$
+       
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_BUILD_CONSOLE = createManaged(T_VIEW, IMG_VIEW_BUILD);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_VARIABLE= createManaged(T_OBJ, IMG_OBJS_VARIABLE);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_LOCAL_VARIABLE= createManaged(T_OBJ, IMG_OBJS_LOCAL_VARIABLE);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_CLASS= createManaged(T_OBJ, IMG_OBJS_CLASS);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_NAMESPACE= createManaged(T_OBJ, IMG_OBJS_NAMESPACE);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_USING = createManaged(T_OBJ, IMG_OBJS_USING);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_STRUCT= createManaged(T_OBJ, IMG_OBJS_STRUCT);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_UNION= createManaged(T_OBJ, IMG_OBJS_UNION);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_TYPEDEF= createManaged(T_OBJ, IMG_OBJS_TYPEDEF);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_ENUMERATION= createManaged(T_OBJ, IMG_OBJS_ENUMERATION);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_UNKNOWN_TYPE= createManaged(T_OBJ, IMG_OBJS_UNKNOWN_TYPE);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_ENUMERATOR= createManaged(T_OBJ, IMG_OBJS_ENUMERATOR);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_FUNCTION= createManaged(T_OBJ, IMG_OBJS_FUNCTION);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_PUBLIC_METHOD= createManaged(T_OBJ, IMG_OBJS_PUBLIC_METHOD);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_PROTECTED_METHOD= createManaged(T_OBJ, IMG_OBJS_PROTECTED_METHOD);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_PRIVATE_METHOD= createManaged(T_OBJ, IMG_OBJS_PRIVATE_METHOD);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_PUBLIC_FIELD= createManaged(T_OBJ, IMG_OBJS_PUBLIC_FIELD);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_PROTECTED_FIELD= createManaged(T_OBJ, IMG_OBJS_PROTECTED_FIELD);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_PRIVATE_FIELD= createManaged(T_OBJ, IMG_OBJS_PRIVATE_FIELD);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_KEYWORD= createManaged(T_OBJ, IMG_OBJS_KEYWORD);                      
+
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_CLASS_ALT= createManaged(T_OBJ, IMG_OBJS_CLASS_ALT);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_STRUCT_ALT= createManaged(T_OBJ, IMG_OBJS_STRUCT_ALT);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_UNION_ALT= createManaged(T_OBJ, IMG_OBJS_UNION_ALT);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_TYPEDEF_ALT= createManaged(T_OBJ, IMG_OBJS_TYPEDEF_ALT);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_ENUMERATION_ALT= createManaged(T_OBJ, IMG_OBJS_ENUMERATION_ALT);
+
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_DECLARARION= createManaged(T_OBJ, IMG_OBJS_DECLARATION);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_VAR_DECLARARION= createManaged(T_OBJ, IMG_OBJS_VAR_DECLARATION);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_INCLUDE= createManaged(T_OBJ, IMG_OBJS_INCLUDE);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_MACRO= createManaged(T_OBJ, IMG_OBJS_MACRO);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_LABEL= createManaged(T_OBJ, IMG_OBJS_LABEL);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_TUNIT= createManaged(T_OBJ, IMG_OBJS_TUNIT);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_TUNIT_HEADER= createManaged(T_OBJ, IMG_OBJS_TUNIT_HEADER);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_TUNIT_ASM= createManaged(T_OBJ, IMG_OBJS_TUNIT_ASM);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_TUNIT_RESOURCE= createManaged(T_OBJ, IMG_OBJS_TUNIT_RESOURCE);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_TUNIT_RESOURCE_H= createManaged(T_OBJ, IMG_OBJS_TUNIT_RESOURCE_H);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_TUNIT_RESOURCE_A= createManaged(T_OBJ, IMG_OBJS_TUNIT_RESOURCE_A);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_SOURCE_ROOT= createManaged(T_OBJ, IMG_OBJS_SOURCE_ROOT);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_SOURCE2_ROOT= createManaged(T_OBJ, IMG_OBJS_SOURCE2_ROOT);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_FOLDER= createManaged(T_OBJ, IMG_OBJS_FOLDER);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_CFOLDER= createManaged(T_OBJ, IMG_OBJS_CFOLDER);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_CONFIG = createManaged(T_OBJ, IMG_OBJS_CONFIG);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_ARCHIVE= createManaged(T_OBJ, IMG_OBJS_ARCHIVE);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_ARCHIVE_WSRC= createManaged(T_OBJ, IMG_OBJS_ARCHIVE);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_BINARY= createManaged(T_OBJ, IMG_OBJS_BINARY);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_SHLIB= createManaged(T_OBJ, IMG_OBJS_SHLIB);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_CEXEC= createManaged(T_OBJ, IMG_OBJS_CEXEC);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_CEXEC_DEBUG= createManaged(T_OBJ, IMG_OBJS_CEXEC_DEBUG);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_CORE= createManaged(T_OBJ, IMG_OBJS_CORE);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_CONTAINER= createManaged(T_OBJ, IMG_OBJS_CONTAINER);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_ARCHIVES_CONTAINER= createManaged(T_OBJ, IMG_OBJS_ARCHIVES_CONTAINER);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_BINARIES_CONTAINER= createManaged(T_OBJ, IMG_OBJS_BINARIES_CONTAINER);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_OUTPUT_FOLDER= createManaged(T_OBJ, IMG_OBJS_OUTPUT_FOLDER);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_LIBRARY= createManaged(T_OBJ, IMG_OBJS_LIBRARY);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_INCLUDES_CONTAINER= createManaged(T_OBJ, IMG_OBJS_INCLUDES_CONTAINER);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_INCLUDES_FOLDER= createManaged(T_OBJ, IMG_OBJS_INCLUDES_FOLDER);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_QUOTE_INCLUDES_FOLDER= createManaged(T_OBJ, IMG_OBJS_QUOTE_INCLUDES_FOLDER);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_INCLUDES_FOLDER_SYSTEM  = createManaged(T_OBJ, IMG_OBJS_INCLUDES_FOLDER_SYSTEM);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_INCLUDES_FOLDER_WORKSPACE= createManaged(T_OBJ, IMG_OBJS_INCLUDES_FOLDER_WORKSPACE);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_ORDER= createManaged(T_OBJ, IMG_OBJS_ORDER);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_EXCLUSION_FILTER_ATTRIB = createManaged(T_OBJ, IMG_OBJS_EXCLUDSION_FILTER_ATTRIB);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_SOURCE_ATTACH_ATTRIB= createManaged(T_OBJ, IMG_OBJS_SOURCE_ATTACH_ATTRIB);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_IMPORT_SETTINGS = createManaged(T_OBJ, IMG_OBJS_IMPORT_SETTINGS);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_EXPORT_SETTINGS = createManaged(T_OBJ, IMG_OBJS_EXPORT_SETTINGS);
+
+       public static final ImageDescriptor DESC_OVR_PATH_INHERIT = createUnManaged(T_OVR, "path_inherit_co.gif"); //$NON-NLS-1$
+       public static final ImageDescriptor DESC_OBJS_OVERRIDES = createUnManaged(T_OBJ, "over_co.gif"); //$NON-NLS-1$
+       public static final ImageDescriptor DESC_OBJS_IMPLEMENTS = createUnManaged(T_OBJ, "implm_co.gif"); //$NON-NLS-1$
+       public static final ImageDescriptor DESC_OBJS_SHADOWS = createUnManaged(T_OBJ, "shad_co.gif"); //$NON-NLS-1$
+
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_FIXABLE_PROBLEM= createManaged(T_OBJ, IMG_OBJS_FIXABLE_PROBLEM);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_FIXABLE_ERROR= createManaged(T_OBJ, IMG_OBJS_FIXABLE_ERROR);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_INCCONT= createManaged(T_OBJ, IMG_OBJS_INCCONT);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_UNKNOWN = createManaged(T_OBJ, IMG_OBJS_UNKNOWN);
+       // Breakpoint image descriptors
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_BREAKPOINT = createManaged( T_OBJ, IMG_OBJS_BREAKPOINT );
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_BREAKPOINT_DISABLED = createManaged( T_OBJ, IMG_OBJS_BREAKPOINT_DISABLED );
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_BREAKPOINT_ACTIVE = createManaged( T_OBJ, IMG_OBJS_BREAKPOINT_ACTIVE );
+
+       public static final String IMG_MENU_SHIFT_RIGHT= NAME_PREFIX + "shift_r_edit.gif"; //$NON-NLS-1$
+       public static final String IMG_MENU_SHIFT_LEFT= NAME_PREFIX + "shift_l_edit.gif"; //$NON-NLS-1$
+       public static final String IMG_MENU_OPEN_INCLUDE= NAME_PREFIX + "open_include.gif"; //$NON-NLS-1$
+       public static final String IMG_MENU_GROUP_INCLUDE= NAME_PREFIX + "group_include.gif"; //$NON-NLS-1$
+       public static final String IMG_MENU_SEGMENT_EDIT= NAME_PREFIX + "segment_edit.gif"; //$NON-NLS-1$
+       public static final String IMG_MENU_CODE_ASSIST= NAME_PREFIX + "metharg_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_MENU_COLLAPSE_ALL= NAME_PREFIX + "collapseall.gif"; //$NON-NLS-1$
+       public static final String IMG_CLEAR_CONSOLE= NAME_PREFIX + "clear_co.gif"; //$NON-NLS-1$
+       public static final String IMG_SCROLL_LOCK= NAME_PREFIX + "lock_co.gif"; //$NON-NLS-1$
+       public static final String IMG_ALPHA_SORTING= NAME_PREFIX + "alphab_sort_co.gif"; //$NON-NLS-1$
+       public static final String IMG_TOOL_GOTO_PREV_ERROR= NAME_PREFIX + "prev_error_nav.gif"; //$NON-NLS-1$
+       public static final String IMG_TOOL_GOTO_NEXT_ERROR= NAME_PREFIX + "next_error_nav.gif"; //$NON-NLS-1$
+       public static final String IMG_EDIT_PROPERTIES= NAME_PREFIX + "prop_edt.gif";    //$NON-NLS-1$
+    
+       public static final String IMG_ACTION_HIDE_FIELDS= NAME_PREFIX + "fields_co.gif"; //$NON-NLS-1$
+       public static final String IMG_ACTION_SHOW_PUBLIC= NAME_PREFIX + "public_co.gif"; //$NON-NLS-1$
+       public static final String IMG_ACTION_HIDE_STATIC= NAME_PREFIX + "static_co.gif"; //$NON-NLS-1$
+
+    public static final String IMG_ACTION_SHOW_REF_BY = NAME_PREFIX + "ch_callers.gif"; //$NON-NLS-1$
+    public static final String IMG_ACTION_SHOW_RELATES_TO = NAME_PREFIX + "ch_callees.gif"; //$NON-NLS-1$
+    public static final String IMG_ACTION_HIDE_INACTIVE = NAME_PREFIX + "filterInactive.gif"; //$NON-NLS-1$
+    public static final String IMG_ACTION_HIDE_SYSTEM = NAME_PREFIX + "filterSystem.gif"; //$NON-NLS-1$
+    public static final String IMG_ACTION_HIDE_MACROS = NAME_PREFIX + "filterDefines.gif"; //$NON-NLS-1$
+    public static final String IMG_SHOW_NEXT= NAME_PREFIX + "search_next.gif"; //$NON-NLS-1$
+    public static final String IMG_SHOW_PREV= NAME_PREFIX + "search_prev.gif"; //$NON-NLS-1$
+
+    public static final String IMG_REFRESH= NAME_PREFIX + "refresh_nav.gif"; //$NON-NLS-1$
+    public static final String IMG_LCL_CANCEL= NAME_PREFIX + "progress_stop.gif"; //$NON-NLS-1$
+
+    // view orientation
+       public static final String IMG_LCL_HORIZONTAL_ORIENTATION= NAME_PREFIX + "th_horizontal.gif"; //$NON-NLS-1$
+       public static final String IMG_LCL_VERTICAL_ORIENTATION= NAME_PREFIX + "th_vertical.gif"; //$NON-NLS-1$
+       public static final String IMG_LCL_AUTOMATIC_ORIENTATION= NAME_PREFIX + "th_automatic.gif"; //$NON-NLS-1$
+       public static final String IMG_LCL_SINGLE_ORIENTATION= NAME_PREFIX + "th_single.gif"; //$NON-NLS-1$
+
+    // hierarchy kind
+       public static final String IMG_LCL_TYPE_HIERARCHY= NAME_PREFIX + "hierarchy_co.gif"; //$NON-NLS-1$
+       public static final String IMG_LCL_SUB_TYPE_HIERARCHY= NAME_PREFIX + "sub_co.gif"; //$NON-NLS-1$
+       public static final String IMG_LCL_SUPER_TYPE_HIERARCHY= NAME_PREFIX + "super_co.gif"; //$NON-NLS-1$
+       public static final String IMG_LCL_SHOW_INHERITED_MEMBERS= NAME_PREFIX + "inher_co.gif"; //$NON-NLS-1$
+       
+       public static final String IMG_FILESYSTEM= NAME_PREFIX + "filesyst.gif"; //$NON-NLS-1$
+       public static final String IMG_WORKSPACE = NAME_PREFIX + "workspace.gif"; //$NON-NLS-1$
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_FILESYSTEM = createManaged(T_OBJ, IMG_FILESYSTEM);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_WORKSPACE  = createManaged(T_OBJ, IMG_WORKSPACE);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_TEMPLATE= createManaged(T_OBJ, IMG_OBJS_TEMPLATE);
+       
+       public static final ImageDescriptor DESC_OVR_STATIC= createUnManaged(T_OVR, "static_co.gif"); //$NON-NLS-1$
+       public static final ImageDescriptor DESC_OVR_CONSTANT= createUnManaged(T_OVR, "c_ovr.gif"); //$NON-NLS-1$
+       public static final ImageDescriptor DESC_OVR_VOLATILE= createUnManaged(T_OVR, "volatile_co.gif"); //$NON-NLS-1$
+       public static final ImageDescriptor DESC_OVR_TEMPLATE= createUnManaged(T_OVR, "template_co.gif"); //$NON-NLS-1$
+    public static final ImageDescriptor DESC_OVR_RELATESTO= createUnManaged(T_OVR, "relatesto_co.gif"); //$NON-NLS-1$
+    public static final ImageDescriptor DESC_OVR_RELATESTOMULTIPLE= createUnManaged(T_OVR, "relatestoMultiple_co.gif"); //$NON-NLS-1$
+    public static final ImageDescriptor DESC_OVR_REFERENCEDBY= createUnManaged(T_OVR, "referencedby_co.gif"); //$NON-NLS-1$
+    public static final ImageDescriptor DESC_OVR_REC_RELATESTO= createUnManaged(T_OVR, "rec_relatesto_co.gif"); //$NON-NLS-1$
+    public static final ImageDescriptor DESC_OVR_REC_REFERENCEDBY= createUnManaged(T_OVR, "rec_referencedby_co.gif"); //$NON-NLS-1$
+    public static final ImageDescriptor DESC_OVR_SYSTEM_INCLUDE= createUnManaged(T_OVR, "systeminclude_co.gif"); //$NON-NLS-1$
+    public static final ImageDescriptor DESC_OVR_DEFINES= createUnManaged(T_OVR, "defines_co.gif"); //$NON-NLS-1$
+    public static final ImageDescriptor DESC_OVR_INACTIVE= createUnManaged(T_OVR, "inactive_co.gif"); //$NON-NLS-1$
+    public static final ImageDescriptor DESC_OVR_READ_ACCESS= createUnManaged(T_OVR, "read.gif"); //$NON-NLS-1$
+    public static final ImageDescriptor DESC_OVR_READ_WRITE_ACCESS= createUnManaged(T_OVR, "readwrite.gif"); //$NON-NLS-1$
+    public static final ImageDescriptor DESC_OVR_WRITE_ACCESS= createUnManaged(T_OVR, "write.gif"); //$NON-NLS-1$
+       public static final ImageDescriptor DESC_OVR_EXTERNAL_FILE= createUnManaged(T_OVR, "external_file.gif"); //$NON-NLS-1$
+       public static final ImageDescriptor DESC_OVR_SETTING= createUnManaged(T_OVR, "setting_nav.gif"); //$NON-NLS-1$
+
+       public static final ImageDescriptor DESC_OVR_WARNING= createUnManaged(T_OVR, "warning_co.gif"); //$NON-NLS-1$
+       public static final ImageDescriptor DESC_OVR_ERROR= createUnManaged(T_OVR, "error_co.gif"); //$NON-NLS-1$
+
+
+       public static final ImageDescriptor DESC_WIZABAN_NEW_PROJ= createUnManaged(T_WIZBAN, "newcprj_wiz.gif"); //$NON-NLS-1$
+       public static final ImageDescriptor DESC_WIZBAN_NEWCLASS= createUnManaged(T_WIZBAN, "newclass_wiz.gif");         //$NON-NLS-1$
+       public static final ImageDescriptor DESC_WIZABAN_C_APP= createUnManaged(T_WIZBAN, "c_app_wiz.gif"); //$NON-NLS-1$
+       public static final ImageDescriptor DESC_WIZBAN_NEW_FILE= createUnManaged(T_WIZBAN, "newfile_wiz.gif"); //$NON-NLS-1$
+       public static final ImageDescriptor DESC_WIZBAN_NEW_HEADERFILE= createUnManaged(T_WIZBAN, "newhfile_wiz.gif"); //$NON-NLS-1$
+       public static final ImageDescriptor DESC_WIZBAN_NEW_SOURCEFILE= createUnManaged(T_WIZBAN, "newcfile_wiz.gif"); //$NON-NLS-1$
+       public static final ImageDescriptor DESC_WIZBAN_NEWSRCFOLDR= createUnManaged(T_WIZBAN, "newsrcfldr_wiz.gif"); //$NON-NLS-1$
+       public static final ImageDescriptor DESC_WIZBAN_EXPORTINDEX= createUnManaged(T_WIZBAN, "exportzip_wiz.png"); //$NON-NLS-1$
+
+       public static final ImageDescriptor DESC_WIZBAN_ADD_LIBRARY = createUnManaged(T_WIZBAN, "addpath_wiz.gif"); //$NON-NLS-1$
+       // For the build image
+       public static final String IMG_OBJS_BUILD= NAME_PREFIX + "build_menu.gif"; //$NON-NLS-1$
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_BUILD_MENU = createManaged(T_OBJ, IMG_OBJS_BUILD);
+
+       //for search
+       public static final String IMG_OBJS_SEARCH_REF  = NAME_PREFIX + "search_ref_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_SEARCH_DECL = NAME_PREFIX + "search_decl_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_SEARCH_LINE = NAME_PREFIX + "searchm_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_CSEARCH     = NAME_PREFIX + "csearch_obj.gif"; //$NON-NLS-1$
+       
+       public static final String IMG_OBJS_SEARCHFOLDER = NAME_PREFIX + "fldr_obj.gif";  //$NON-NLS-1$
+       public static final String IMG_OBJS_SEARCHPROJECT = NAME_PREFIX + "cprojects.gif";  //$NON-NLS-1$
+       
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_SEARCH_DECL = createManaged(T_OBJ, IMG_OBJS_SEARCH_DECL);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_SEARCH_REF  = createManaged(T_OBJ, IMG_OBJS_SEARCH_REF);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_SEARCH_LINE = createManaged(T_OBJ, IMG_OBJS_SEARCH_LINE);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_CSEARCH     = createManaged(T_OBJ, IMG_OBJS_CSEARCH);
+       
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_SEARCHHIERPROJECT = createManaged(T_OBJ,IMG_OBJS_SEARCHPROJECT);
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_SEARCHHIERFODLER = createManaged(T_OBJ,IMG_OBJS_SEARCHFOLDER);
+       
+       // refactoring
+       public static final String IMG_OBJS_REFACTORING_FATAL= NAME_PREFIX + "fatalerror_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_REFACTORING_ERROR= NAME_PREFIX + "error_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_REFACTORING_WARNING= NAME_PREFIX + "warning_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_REFACTORING_INFO= NAME_PREFIX + "info_obj.gif";     //$NON-NLS-1$
+
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_REFACTORING_FATAL= createManaged( T_OBJ, IMG_OBJS_REFACTORING_FATAL); 
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_REFACTORING_ERROR= createManaged( T_OBJ, IMG_OBJS_REFACTORING_ERROR); 
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_REFACTORING_WARNING= createManaged( T_OBJ, IMG_OBJS_REFACTORING_WARNING); 
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_REFACTORING_INFO= createManaged ( T_OBJ, IMG_OBJS_REFACTORING_INFO);       
+               
+       public static final ImageDescriptor DESC_WIZBAN_REFACTOR_FIELD= createUnManaged(T_WIZBAN, "fieldrefact_wiz.gif");       //$NON-NLS-1$
+       public static final ImageDescriptor DESC_WIZBAN_REFACTOR_METHOD= createUnManaged(T_WIZBAN, "methrefact_wiz.gif");       //$NON-NLS-1$
+       public static final ImageDescriptor DESC_WIZBAN_REFACTOR_TYPE= createUnManaged(T_WIZBAN, "typerefact_wiz.gif");         //$NON-NLS-1$
+
+       public static final ImageDescriptor DESC_OBJS_DEFAULT_CHANGE= createUnManaged(T_OBJ, "change.gif"); //$NON-NLS-1$
+       public static final ImageDescriptor DESC_OBJS_COMPOSITE_CHANGE= createUnManaged(T_OBJ, "composite_change.gif"); //$NON-NLS-1$
+       public static final ImageDescriptor DESC_OBJS_CU_CHANGE= createUnManaged(T_OBJ, "cu_change.gif"); //$NON-NLS-1$
+       public static final ImageDescriptor DESC_OBJS_FILE_CHANGE= createUnManaged(T_OBJ, "file_change.gif"); //$NON-NLS-1$
+       public static final ImageDescriptor DESC_OBJS_TEXT_EDIT= createUnManaged(T_OBJ, "text_edit.gif"); //$NON-NLS-1$
+
+       public static final String IMG_PREFERRED = NAME_PREFIX + "tc_preferred.gif"; //$NON-NLS-1$
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_PREFERRED = createManaged(T_OBJ, IMG_PREFERRED);
+       public static final String IMG_EMPTY = NAME_PREFIX + "tc_empty.gif"; //$NON-NLS-1$
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_EMPTY = createManaged(T_OBJ, IMG_EMPTY);
+
+       public static final ImageDescriptor DESC_DLCL_CONFIGURE_ANNOTATIONS= createUnManaged(T_DLCL, "configure_annotations.gif"); //$NON-NLS-1$
+       public static final ImageDescriptor DESC_ELCL_CONFIGURE_ANNOTATIONS= createUnManaged(T_ELCL, "configure_annotations.gif"); //$NON-NLS-1$
+       public static final ImageDescriptor DESC_DLCL_VIEW_MENU= createUnManaged(T_DLCL, "view_menu.gif"); //$NON-NLS-1$
+       public static final ImageDescriptor DESC_ELCL_VIEW_MENU= createUnManaged(T_ELCL, "view_menu.gif"); //$NON-NLS-1$
+       
+       public static final String IMG_OBJS_QUICK_ASSIST= NAME_PREFIX + "quickassist_obj.gif"; //$NON-NLS-1$
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_QUICK_ASSIST = createManaged(T_OBJ, IMG_OBJS_QUICK_ASSIST);
+       public static final String IMG_CORRECTION_ADD= NAME_PREFIX + "correction_add.gif"; //$NON-NLS-1$
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_CORRECTION_ADD = createManaged(T_OBJ, IMG_CORRECTION_ADD);
+       public static final String IMG_CORRECTION_CHANGE= NAME_PREFIX + "correction_change.gif"; //$NON-NLS-1$
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_CORRECTION_CHANGE = createManaged(T_OBJ, IMG_CORRECTION_CHANGE);
+       public static final String IMG_CORRECTION_RENAME= NAME_PREFIX + "correction_rename.gif"; //$NON-NLS-1$
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_CORRECTION_RENAME = createManaged(T_OBJ, IMG_CORRECTION_RENAME);
+       public static final String IMG_CORRECTION_LINKED_RENAME= NAME_PREFIX + "correction_linked_rename.gif"; //$NON-NLS-1$
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_CORRECTION_LINKED_RENAME = createManaged(T_OBJ, IMG_CORRECTION_LINKED_RENAME);
+
+       public static final String IMG_OBJS_NLS_NEVER_TRANSLATE= NAME_PREFIX + "never_translate.gif"; //$NON-NLS-1$
+       /** @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImageDescriptor(String)}. */
+       @Deprecated public static final ImageDescriptor DESC_OBJS_NLS_NEVER_TRANSLATE = createManaged(T_OBJ, IMG_OBJS_NLS_NEVER_TRANSLATE);
+
+       public static final ImageDescriptor DESC_ELCL_NAVIGATE_BACKWARD = createUnManaged(T_ELCL, "backward_nav.gif"); //$NON-NLS-1$
+       public static final ImageDescriptor DESC_ELCL_NAVIGATE_FORWARD = createUnManaged(T_ELCL, "forward_nav.gif"); //$NON-NLS-1$
+       public static final ImageDescriptor DESC_ELCL_OPEN_DECLARATION = createUnManaged(T_ELCL, "goto_input.gif"); //$NON-NLS-1$
+
+       // incorrectly defined descriptors
+       /** @deprecated as of CDT 8.0. */
+       @Deprecated public static final ImageDescriptor IMG_SAVE_CONSOLE_DESC = null;
+       /** @deprecated as of CDT 8.0. */
+       @Deprecated public static final ImageDescriptor DESC_OVR_FOCUS = null;
+       /** @deprecated as of CDT 8.0. */
+       @Deprecated public static final ImageDescriptor DESC_TOOL_NEWCLASS = null;
+
+       
+       /**
+        * Creates an image descriptor which is managed by internal registry in CDTSharedImages.
+        * {@code name} is assumed to start with "org.eclipse.cdt.ui."
+        * 
+        * @deprecated as of CDT 8.0 with deprecation of {@link #get(String)}.
+        */
+       @Deprecated
+       private static ImageDescriptor createManaged(String prefix, String name) {
+               try {
+                       String convertedKey = ICONS + prefix + name.substring(NAME_PREFIX_LENGTH);
+                       fPathMap.put(name, convertedKey);
+                       return CDTSharedImages.getImageDescriptor(convertedKey);
+               } catch (Throwable e) {
+                       CUIPlugin.log(e);
+               }
+               return ImageDescriptor.getMissingImageDescriptor();
+       }
+       
+       /**
+        * Get an image from internal image registry. The image is managed by the registry and
+        * must not be disposed by the caller.
+        * 
+        * @param key - one of {@code CPluginImages.IMG_} constants.
+        * @return the image corresponding the given key.
+        * 
+        * @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImage(String)}.
+        */
+       @Deprecated
+       public static Image get(String key) {
+               String pathKey = fPathMap.get(key);
+               return CDTSharedImages.getImage(pathKey);
+       }
+       
+       /**
+        * Creates an image descriptor for the given prefix and name in the JDT UI bundle. The path can
+        * contain variables like $NL$.
+        * If no image could be found, <code>useMissingImageDescriptor</code> decides if either
+        * the 'missing image descriptor' is returned or <code>null</code>.
+        * or <code>null</code>.
+        */
+       private static ImageDescriptor create(String prefix, String name, boolean useMissingImageDescriptor) {
+               IPath path= ICONS_PATH.append(prefix).append(name);
+               return createImageDescriptor(CUIPlugin.getDefault().getBundle(), path, useMissingImageDescriptor);
+       }
+       
+       /**
+        * Creates an image descriptor for the given prefix and name in the JDT UI bundle. The path can
+        * contain variables like $NL$.
+        * If no image could be found, the 'missing image descriptor' is returned.
+        */
+       private static ImageDescriptor createUnManaged(String prefix, String name) {
+               try {
+                       return create(prefix, name, true);
+               } catch (Throwable e) {
+                       CUIPlugin.log(e.getMessage(), e);
+               }
+               return ImageDescriptor.getMissingImageDescriptor();
+       }
+       
+       /**
+        * Creates an image descriptor for the given path in a bundle. The path can contain variables
+        * like $NL$.
+        * If no image could be found, <code>useMissingImageDescriptor</code> decides if either
+        * the 'missing image descriptor' is returned or <code>null</code>.
+        * Added for 3.1.1.
+        */
+       public static ImageDescriptor createImageDescriptor(Bundle bundle, IPath path, boolean useMissingImageDescriptor) {
+               URL url= FileLocator.find(bundle, path, null);
+               if (url != null) {
+                       return ImageDescriptor.createFromURL(url);
+               }
+               
+               Exception e = new Exception(NLS.bind(CUIMessages.CPluginImages_MissingImage, path, bundle.getSymbolicName()));
+               CUIPlugin.log(e.getMessage(), e);
+
+               if (useMissingImageDescriptor) {
+                       return ImageDescriptor.getMissingImageDescriptor();
+               }
+               return null;
+       }
+
+       /**
+        * Sets the three image descriptors for enabled, disabled, and hovered to an action. The actions
+        * are retrieved from the *tool16 folders.
+        * 
+        * @param action        the action
+        * @param iconName      the icon name
+        */
+       public static void setToolImageDescriptors(IAction action, String iconName) {
+               setImageDescriptors(action, T_TOOL, iconName);
+       }
+       
+       /**
+        * Sets the three image descriptors for enabled, disabled, and hovered to an action. The actions
+        * are retrieved from the *lcl16 folders.
+        * 
+        * @param action        the action
+        * @param iconName      the icon name
+        */
+       public static void setLocalImageDescriptors(IAction action, String iconName) {
+               setImageDescriptors(action, T_LCL, iconName);
+       }
+
+       /**
+        * Sets all available image descriptors for the given action.
+        */     
+       public static void setImageDescriptors(IAction action, String type, String relPath) {
+           if (relPath.startsWith(NAME_PREFIX))
+               relPath= relPath.substring(NAME_PREFIX_LENGTH);
+               action.setDisabledImageDescriptor(createUnManaged(("d" + type), relPath)); //$NON-NLS-1$
+//             action.setHoverImageDescriptor(create("c" + type, relPath)); //$NON-NLS-1$
+               action.setImageDescriptor(createUnManaged(("e" + type), relPath)); //$NON-NLS-1$
+
+               // We are still not sure about this, let see TF results first.
+               //              Use the managed version so that we ensure that there is no resource handle leaks
+               //              Let the widget itself manage the disabled/hover attribution.  This was a huge leak
+               //ImageDescriptor desc = getImageRegistry().getDescriptor(relPath);
+               //if(desc == null) {
+               //      desc = createManaged(T + "c" + type, relPath);
+               //}     
+               //action.setImageDescriptor(desc);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties
new file mode 100644 (file)
index 0000000..8e36699
--- /dev/null
@@ -0,0 +1,232 @@
+###############################################################################
+# Copyright (c) 2005, 2010 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+#     QNX Software System
+#     Markus Schorn (Wind River Systems)
+#     Anton Leherbauer (Wind River Systems)
+###############################################################################
+
+# ------- CView -----------------
+CView.make_edit_action =Project properties
+
+# ------- Preference Page ------- 
+ConsolePreferencePage.clearConsole.label=Always clear console before building
+ConsolePreferencePage.autoOpenConsole.label=Open console when building
+ConsolePreferencePage.consoleOnTop.label=Bring console to top when building (if present)
+ConsolePreferencePage.consoleLines.label=Limit console output (number of lines):
+ConsolePreferencePage.consoleLines.errorMessage=Value must be an integer between 10 and 2147483647
+ConsolePreferencePage.tabWidth.label=Display tab width:
+ConsolePreferencePage.tabWidth.errorMessage=Value must be an integer between 1 and 100
+ConsolePreferencePage.colorSettings.label=Console text color settings
+ConsolePreferencePage.outputColor.label=Output text color
+ConsolePreferencePage.infoColor.label=Information message text color
+ConsolePreferencePage.errorColor.label=Error message text color
+ConsolePreferencePage.backgroundColor.label=Background color
+ConsolePreferencePage.problemBackgroundColor.label=Background color for build errors
+ConsolePreferencePage.problemWarningBackgroundColor.label=Background color for build warnings
+ConsolePreferencePage.problemInfoBackgroundColor.label=Background color for build informational messages
+ConsolePreferencePage.problemHighlightedColor.label=Highlighting color for build problems
+
+# ------- Project/Prefernces/Wizards COnfiguration blocks -------
+
+ErrorParserBlock.label=Error Parsers
+ErrorParserBlock.desc=Set the error parsers for this project
+
+BinaryParserBlock.label=Binary Parser
+BinaryParserBlock.desc=Set required binary parser for this project
+
+BaseIndexerBlock.label=C/C++ Indexer
+BaseIndexerBlock.desc=C/C++ Indexer setting for this project.
+BaseIndexerBlock.comboLabel=Indexer Options
+
+ReferenceBlock.label= Projects
+ReferenceBlock.desc= Referenced C/C++ Projects
+
+# ------- ProjectConfigurationBlock------- 
+
+ProjectConfigurationBlock.buildCmdText.label=The build command is an executable program which will be used by the builder to build your C project. If the build command is not on the current system environment path, you have to enter an absolute path name. If the build command is make then it will use the makefile which is located in the project folder
+ProjectConfigurationBlock.buildArgsText.label=Build can be either incremental or full. You can specify different build arguments\nfor the two kinds.
+ProjectConfigurationBlock.buildArgText.label=Additional build arguments
+
+ProjectConfigurationBlock.buildLocation.label=Build command:
+ProjectConfigurationBlock.buildLocation.button=Browse...
+ProjectConfigurationBlock.fullBuildArguments.label=Full Build Arguments:
+ProjectConfigurationBlock.incrBuildArguments.label=Incremental Build Arguments:
+ProjectConfigurationBlock.error.InvalidBuildCommand=Invalid build command
+# --- The new wizards ----
+# FIXME: Remove the properties above when satisfy with wizards.
+
+SettingsBlock.label=Build Settings
+SettingsBlock.keepOnGoing=Keep Going On Error
+SettingsBlock.stopOnError=Stop On Error
+SettingsBlock.makeOption.label=Build Command
+SettingsBlock.makeOption.use_default=Use Default
+SettingsBlock.makeOption.build_cmd=Build Command:
+
+#Strings for the platform selection tab
+PlatformBlock.label.platform=Platform:
+PlatformBlock.tip.platform=Select the platform you wish to deploy on
+PlatformBlock.label.configs=Configurations:
+
+# String constants for the build configuration tab
+ConfigurationBlock.label=Build Information
+ConfigurationBlock.type=Project Type
+ConfigurationBlock.type.app=Application
+ConfigurationBlock.type.shared=Shared Library/DLL
+ConfigurationBlock.type.static=Static Library
+ConfigurationBlock.build.label=Build Settings
+ConfigurationBlock.build.continue=Continue On Error
+ConfigurationBlock.build.stop=Stop On Error
+
+# String constants for the build include path and preprocessor symbols
+BuildPathInfoBlock.label=Paths and Symbols
+BuildPathInfoBlock.paths=Include paths:
+BuildPathInfoBlock.symbols=Defined symbols:
+BuildPathInfoBlock.browse.path=New Include Path
+BuildPathInfoBlock.browse.path.label=Path:
+BuildPathInfoBlock.browse.symbol=New Defined Symbol
+BuildPathInfoBlock.browse.symbol.label=Symbol:
+
+StdMakeProjectWizard.op_error=Standard Make Error
+StdMakeProjectWizard.title=Standard Make Project
+StdMakeProjectWizard.description=Create a new Standard Make project.
+StdMakeProjectWizardSettings.title=Standard Make Settings
+StdMakeProjectWizardSettings.description=Define the Standard Make build settings.
+
+StdCWizard.title=Standard Make C Project
+StdCWizard.description=Create a new Standard Make C project.
+StdCWizardSettings.title=Standard Make C Settings
+StdCWizardSettings.description=Define the Standard Make C build settings.
+
+StdCCWizard.title=Standard Make C++ Project
+StdCCWizard.description=Create a new Standard Make C++ Project.
+StdCCWizardSettings.title=Standard Make C++ Settings
+StdCCWizardSettings.description=Define the Standard Make C++ build settings.
+
+MngMakeProjectWizard.op_error=Managed Make Error
+MngMakeProjectWizard.title=Managed Make Project
+MngMakeProjectWizard.description=Create a new Managed Make project.
+MngMakeProjectWizardSettings.title=Managed Make Settings
+MngMakeProjectWizardSettings.description=Define the Managed Make build settings.
+
+MngCWizard.title=Managed Make C Project
+MngCWizard.description=Create a new Managed Make C project.
+MngCWizardSettings.title=Managed Make C Settings
+MngCWizardSettings.description=Define the Managed Make C build settings.
+
+MngCCWizard.title=Managed Make C++ Project
+MngCCWizard.description=Create a new Managed Make C++ Project.
+MngCCWizardSettings.title=Managed Make C++ Settings
+MngCCWizardSettings.description=Define the Managed Make C++ build settings.
+
+CProjectWizard.op_error.title=Error Creating Project
+CProjectWizard.op_error.message=Project cannot be created
+CProjectWizard.op_description=C Project Wizard
+CProjectWizard.windowTitle=New Project
+CProjectWizard.description=C Project Wizard
+CProjectWizard.title=C Project Wizard
+CProjectWizardPage=C Wizard Page
+
+# Defaults from ConvertProjectWizardPage
+ConversionWizard.windowTitle=Convert to a C/C++ Project
+ConversionWizard.description=Select project(s) for conversion
+ConversionWizard.title=Add a C++ Nature to project(s)
+ConversionWizard.projectlist=Candidates for conversion:
+
+# Convert to C/C++
+StdMakeConversionWizard.windowTitle=Convert Projects to C or C++
+StdMakeConversionWizard.description=Select project(s) for conversion
+StdMakeConversionWizard.title=Add a C or C++ Nature to selected project(s)
+
+TabFolderPage=Tab Folder Page
+TabFolderPage.title=Project
+TabFolderPage.desc=Project Settings
+
+# ------- CProjectPropertyPage------- 
+
+CProjectPropertyPage.nocproject=Not a C builder
+CProjectPropertyPage.closedproject=C information is not available for a closed project
+
+# ------- Building ------- 
+
+BuildConsole.name=CDT Build Console
+CBuilder.build_error=Could not execute builder "{0}" configured in the project property page.
+
+# ------- Properties-------
+
+CElementProperties.name=name
+CElementProperties.elf_cpu=cpu
+CElementProperties.elf_text=text
+CElementProperties.elf_data=data
+CElementProperties.elf_bss=bss
+CElementProperties.elf_type=type
+CElementProperties.elf_soname=soname
+CElementProperties.elf_has_debug=debug
+CElementProperties.elf_needed=needed
+
+# ------- Compare -------
+
+CMergeViewer.title=C Compare Viewer
+CStructureCreator.name=C Compare
+AsmMergeViewer.title=Assembly Compare Viewer
+
+# ------- OpenIncludeDeclarationAction------------
+
+OpenIncludeAction.label=&Open
+OpenIncludeAction.tooltip=Open the Selected Include in the Editor
+OpenIncludeAction.description=Open the selected include in the editor
+OpenIncludeAction.dialog.title=Open Include
+OpenIncludeAction.dialog.message=Select the file to open
+OpenIncludeAction.error = No Includes Found
+OpenIncludeAction.error.description = No include files were found that matched that name.
+
+
+# ------- SearchDialogAction ---------------
+SearchDialogAction.label=C/C++ Search...
+SearchDialogAction.tooltip=Opens C/C++ Search Dialog
+SearchDialogAction.description=Opens C/C++ Search Dialog
+
+
+# ------- LexicalSortingAction------------
+
+LexicalSortingAction.label=Sort
+LexicalSortingAction.description=Sorts the elements in the outliner
+LexicalSortingAction.tooltip=Sort
+LexicalSortingAction.tooltip.on=Do Not Sort
+LexicalSortingAction.tooltip.off=Sort
+
+# ------- ClearOutputAction------------
+ClearOutputAction.label=Clea&r Console
+ClearOutputAction.tooltip=Clear Console 
+
+# ------- New menu items to overwrite superclass ----------
+CreateFileAction.text = &File
+CreateFolderAction.text = F&older
+
+# ------- Drag and Drop Message Text -----------
+CViewDragNDrop.txt = already exists. Would you like to overwrite it?
+
+# ------- EditorUtility Open Closed Project Text -----------
+EditorUtility.closedproject = Project is closed
+Editorutility.closedproject.description = The project {0} containing that declaration is closed.
+
+# ------- Index View Text -----------
+IndexerBlock.enable=Enable indexer
+IndexView.rebuildIndex.name = Rebuild Index
+IndexView.openDefinition.name = Open Definition
+IndexView.findReferences.name = Find References
+IndexView.findDeclarations.name = Find Declarations
+IndexView.ToggleExternals.name = Toggle Show Externals
+IndexView.ToggleExternals.tooltip = Show Externaly Defined Symbols
+IndexView.setFastIndexer.name = Use Fast Indexer
+IndexView.CountSymbols.name = Count Symbols
+IndexView.CountSymbols.title = Symbol Count
+IndexView.CountSymbols.message = The selected PDOMs contain {0} files, {1} macros; {2} symbols\r\n{3} references, {4} declarations, {5} definitions.
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CProjectAdapterFactory.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CProjectAdapterFactory.java
new file mode 100644 (file)
index 0000000..c9c3f24
--- /dev/null
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IAdapterFactory;
+
+import org.eclipse.cdt.core.model.ICProject;
+
+/**
+ * Adapter factory to adapt <code>ICProject</code> to <code>IProject</code>.
+ *
+ * @since 4.0
+ */
+public class CProjectAdapterFactory implements IAdapterFactory {
+
+       private static final Class<?>[] ADAPTERS = { IProject.class };
+
+       /*
+        * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
+        */
+       @SuppressWarnings("rawtypes")
+       public Object getAdapter(Object adaptableObject, Class adapterType) {
+               if (IProject.class.equals(adapterType)) {
+                       return ((ICProject)adaptableObject).getProject();
+               }
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
+        */
+       public Class<?>[] getAdapterList() {
+               return ADAPTERS;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CStatusConstants.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CStatusConstants.java
new file mode 100644 (file)
index 0000000..efda5df
--- /dev/null
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui;
+
+/**
+ * Defines status codes relevant to the C UI plug-in. When a 
+ * Core exception is thrown, it contain a status object describing
+ * the cause of the exception. The status objects originating from the
+ * C UI plug-in use the codes defined in this interface.
+ */
+public class CStatusConstants {
+       
+       // Prevent instantiation
+       private CStatusConstants() {
+       }
+
+       /** Status code describing an internal error */
+       public static final int INTERNAL_ERROR= 1;
+       
+       /**
+        * Status constant indicating that an exception occured on
+        * storing or loading templates.
+        */
+       public static final int TEMPLATE_IO_EXCEPTION = 2;
+       
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIException.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIException.java
new file mode 100644 (file)
index 0000000..f89e329
--- /dev/null
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+
+/**
+ * An exception to wrap a status. This is necessary to use the core's IRunnableWithProgress
+ * support
+ */
+
+public class CUIException extends CoreException {
+       
+       /**
+        * Comment for <code>serialVersionUID</code>
+        */
+       private static final long serialVersionUID = 1L;
+
+       public CUIException(IStatus status) {
+               super(status);
+       }       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.java
new file mode 100644 (file)
index 0000000..c6a0008
--- /dev/null
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Rational Software - initial implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class CUIMessages extends NLS {
+
+       private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.CUIMessages";//$NON-NLS-1$
+
+       private CUIMessages() {
+               // Do not instantiate
+       }
+
+       public static String Drag_move_problem_title;
+       public static String Drag_move_problem_message;
+       public static String ExceptionDialog_seeErrorLogMessage;
+       public static String CAnnotationHover_multipleMarkers;
+       public static String TabFolderOptionBlock_error;
+       public static String TabFolderOptionBlock_error_settingOptions;
+       public static String TabFolderOptionBlock_error_message;
+       public static String BinaryParserBlock_binaryParser;
+       public static String BinaryParserBlock_button_up;
+       public static String BinaryParserBlock_button_down;
+       public static String BinaryParserBlock_binaryParserOptions;
+       public static String BinaryParserBlock_settingBinaryParser;
+       public static String ReferenceBlock_task_ReferenceProjects;
+       public static String BinaryParserPage_task_savingAttributes;
+       public static String BinaryParserPage_label_addr2lineCommand;
+       public static String BinaryParserPage_label_browse;
+       public static String BinaryParserPage_label_browse1;
+       public static String BinaryParserPage_label_browse2;
+       public static String BinaryParserPage_label_cppfiltCommand;
+       public static String BinaryParserPage_label_cygpathCommand;
+       public static String BinaryParserPage_label_nmCommand;
+       public static String AbstractErrorParserBlock_task_setErrorParser;
+       public static String ConvertProjectWizardPage_convertTo;
+       public static String ConvertProjectWizardPage_SelectAll;
+       public static String ConvertProjectWizardPage_CProject;
+       public static String ConvertProjectWizardPage_CppProject;
+       public static String ConvertProjectWizardPage_DeselectAll;
+       public static String AbstractErrorParserBlock_label_up;
+       public static String AbstractErrorParserBlock_label_down;
+       public static String AbstractErrorParserBlock_label_selectAll;
+       public static String AbstractErrorParserBlock_label_unselectAll;
+       public static String AbstractErrorParserBlock_label_errorParsers;
+       public static String ICElementPropertyConstants_catagory;
+       public static String StatusBarUpdater_num_elements_selected;
+       public static String CHelpConfigurationPropertyPage_buttonLabels_CheckAll;
+       public static String CHelpConfigurationPropertyPage_buttonLabels_UncheckAll;
+       public static String CHelpConfigurationPropertyPage_HelpBooks;
+       public static String CPluginImages_MissingImage;
+       public static String AsyncTreeContentProvider_JobName;
+       public static String AsyncTreeContentProvider_TaskName;
+       public static String TextEditorDropAdapter_error_title;
+       public static String TextEditorDropAdapter_error_message;
+       public static String TextEditorDropAdapter_unreadableFile;
+       public static String TextEditorDropAdapter_noFile;
+       public static String OptionalMessageDialog_dontShowAgain;
+       public static String OptionalMessageDialog_rememberDecision;
+       public static String CStructureCreatorVisitor_translationUnitName;
+       public static String FileTransferDragAdapter_refreshing;
+       public static String FileTransferDragAdapter_problem;
+       public static String FileTransferDragAdapter_problemTitle;
+
+       static {
+               NLS.initializeMessages(BUNDLE_NAME, CUIMessages.class);
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.properties
new file mode 100644 (file)
index 0000000..581ad5e
--- /dev/null
@@ -0,0 +1,75 @@
+###############################################################################
+# Copyright (c) 2002, 2009 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     Rational Software - Initial API and implementation
+#     Markus Schorn (Wind River Systems)
+#     Anton Leherbauer (Wind River Systems)
+###############################################################################
+
+Drag_move_problem_title=Drag and Drop Problem
+Drag_move_problem_message={0} is read only. Do you still wish to delete it?
+ExceptionDialog_seeErrorLogMessage=See error log for more details.
+
+CAnnotationHover_multipleMarkers=Multiple markers at this line
+
+TabFolderOptionBlock_error=Error
+TabFolderOptionBlock_error_settingOptions=Error setting options
+TabFolderOptionBlock_error_message=Error in {0} tab
+
+BinaryParserBlock_binaryParser=Binary Parser:
+BinaryParserBlock_button_up=Up
+BinaryParserBlock_button_down=Down
+BinaryParserBlock_binaryParserOptions=Binary Parser Options
+BinaryParserBlock_settingBinaryParser=Setting Binary Parser...
+
+ReferenceBlock_task_ReferenceProjects=Reference Projects
+
+BinaryParserPage_task_savingAttributes=Saving Attributes
+BinaryParserPage_label_addr2lineCommand=addr2line Command:
+BinaryParserPage_label_browse=&Browse...
+BinaryParserPage_label_browse1=B&rowse...
+BinaryParserPage_label_browse2=Br&owse...
+BinaryParserPage_label_cppfiltCommand=c++filt Command:
+BinaryParserPage_label_cygpathCommand=cygpath Command:
+BinaryParserPage_label_nmCommand=nm Command:
+
+AbstractErrorParserBlock_task_setErrorParser=Setting Error Parsers...
+ConvertProjectWizardPage_convertTo=Convert to C or C++
+ConvertProjectWizardPage_SelectAll=Select All
+ConvertProjectWizardPage_CProject=C Project
+ConvertProjectWizardPage_CppProject=C++ Project
+ConvertProjectWizardPage_DeselectAll=Deselect All
+AbstractErrorParserBlock_label_up=Up
+AbstractErrorParserBlock_label_down=Down
+AbstractErrorParserBlock_label_selectAll=Select All
+AbstractErrorParserBlock_label_unselectAll=Unselect All
+AbstractErrorParserBlock_label_errorParsers=Error Parsers
+
+ICElementPropertyConstants_catagory=Binary Info
+
+StatusBarUpdater_num_elements_selected={0} items selected
+
+CHelpConfigurationPropertyPage_buttonLabels_CheckAll=Check All
+CHelpConfigurationPropertyPage_buttonLabels_UncheckAll=Uncheck All
+CHelpConfigurationPropertyPage_HelpBooks=Help books
+CPluginImages_MissingImage=Image {0} is missing in bundle {1}
+AsyncTreeContentProvider_JobName=Child Node Computation
+AsyncTreeContentProvider_TaskName=Compute child nodes
+
+TextEditorDropAdapter_error_title=Drag and Drop
+TextEditorDropAdapter_error_message=A problem occurred during drag and drop.
+TextEditorDropAdapter_unreadableFile=Unreadable file: ''{0}''
+TextEditorDropAdapter_noFile=Not a file: ''{0}''
+
+OptionalMessageDialog_dontShowAgain= Do not show this &message again
+OptionalMessageDialog_rememberDecision=Re&member my decision
+CStructureCreatorVisitor_translationUnitName=Translation Unit
+
+FileTransferDragAdapter_refreshing=Refreshing...
+FileTransferDragAdapter_problem=Problem while moving or copying files.
+FileTransferDragAdapter_problemTitle=Drag & Drop
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIStatus.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIStatus.java
new file mode 100644 (file)
index 0000000..ca914a4
--- /dev/null
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+/**
+ * Convenience class for error exceptions thrown inside JavaUI plugin.
+ */
+public class CUIStatus extends Status {
+
+       public CUIStatus(int code, String message, Throwable throwable) {
+               super(IStatus.ERROR, CUIPlugin.getPluginId(), code, message, throwable);
+       }
+       
+       private CUIStatus(int severity, int code, String message, Throwable throwable) {
+               super(severity, CUIPlugin.getPluginId(), code, message, throwable);
+       }
+       
+       public static IStatus createError(int code, Throwable throwable) {
+               String message= throwable.getMessage();
+               if (message == null) {
+                       message= throwable.getClass().getName();
+               }
+               return new CUIStatus(IStatus.ERROR, code, message, throwable);
+       }
+
+       public static IStatus createError(int code, String message, Throwable throwable) {
+               return new CUIStatus(IStatus.ERROR, code, message, throwable);
+       }
+       
+       public static IStatus createWarning(int code, String message, Throwable throwable) {
+               return new CUIStatus(IStatus.WARNING, code, message, throwable);
+       }
+
+       public static IStatus createInfo(int code, String message, Throwable throwable) {
+               return new CUIStatus(IStatus.INFO, code, message, throwable);
+       }
+       
+}
+
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java
new file mode 100644 (file)
index 0000000..12e2cab
--- /dev/null
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IParent;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
+import org.eclipse.cdt.ui.CElementLabelProvider;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+
+/**
+ * An implementation of the IWorkbenchAdapter for CElements.
+ */
+public class CWorkbenchAdapter implements IWorkbenchAdapter {
+
+       private static final Object[] fgEmptyArray = new Object[0];
+       private CElementImageProvider fImageProvider;
+       private CElementLabelProvider fLabelProvider;
+
+       public CWorkbenchAdapter() {
+               fImageProvider = new CElementImageProvider();
+               fLabelProvider = new CElementLabelProvider();
+       }
+
+       /**
+        * @see IWorkbenchAdapter#getChildren
+        */
+       public Object[] getChildren(Object o) {
+               if (o instanceof IParent) {
+                       try {
+                               Object[] members = ((IParent) o).getChildren();
+                               if (members != null) {
+                                       return members;
+                               }
+                       } catch (CModelException e) {
+                               CUIPlugin.log(e);
+                       }
+               }
+               return fgEmptyArray;
+       }
+
+       /**
+        * @see IWorkbenchAdapter#getImageDescriptor
+        */
+       public ImageDescriptor getImageDescriptor(Object element) {
+               if (element instanceof ICElement) {
+                       return fImageProvider.getCImageDescriptor(
+                               (ICElement) element,
+                               CElementImageProvider.OVERLAY_ICONS | CElementImageProvider.SMALL_ICONS);
+               }
+               return null;
+       }
+
+       /**
+        * @see IWorkbenchAdapter#getLabel
+        */
+       public String getLabel(Object o) {
+               if (o instanceof ICElement) {
+                       return fLabelProvider.getText(o);
+               }
+               return null;
+       }
+
+       /**
+        * @see IWorkbenchAdapter#getParent
+        */
+       public Object getParent(Object o) {
+               if (o instanceof ICElement) {
+                       return ((ICElement) o).getParent();
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DeferredCWorkbenchAdapter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DeferredCWorkbenchAdapter.java
new file mode 100644 (file)
index 0000000..141534c
--- /dev/null
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IParent;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.ui.progress.IDeferredWorkbenchAdapter;
+import org.eclipse.ui.progress.IElementCollector;
+
+public class DeferredCWorkbenchAdapter extends CWorkbenchAdapter implements IDeferredWorkbenchAdapter {
+
+       private ICElement fCElement;
+
+       public DeferredCWorkbenchAdapter(ICElement element) {
+               super();
+               fCElement = element;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ui.progress.IDeferredWorkbenchAdapter#fetchDeferredChildren(java.lang.Object,
+        *           org.eclipse.jface.progress.IElementCollector,
+        *           org.eclipse.core.runtime.IProgressMonitor)
+        */
+       public void fetchDeferredChildren(Object object, IElementCollector collector, IProgressMonitor monitor) {
+               Object[] children = getChildren(object);
+               if (monitor.isCanceled()) {
+                       return;
+               }
+               collector.add(children, monitor);
+           collector.done();
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ui.progress.IDeferredWorkbenchAdapter#isContainer()
+        */
+       public boolean isContainer() {
+               return fCElement instanceof IParent;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ui.progress.IDeferredWorkbenchAdapter#getRule(java.lang.Object)
+        */
+       public ISchedulingRule getRule(final Object object) {
+       return fCElement.getResource();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DocumentInputStream.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DocumentInputStream.java
new file mode 100644 (file)
index 0000000..e9affa9
--- /dev/null
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+/**
+ * Input stream which reads from a document
+ */
+public class DocumentInputStream extends InputStream {
+       
+       private IDocument fDocument;
+       private int fCurrPos;
+       
+       public DocumentInputStream(IDocument document) {
+               fDocument= document;
+               fCurrPos= 0;
+       }
+       
+       public IDocument getDocument() {
+               return fDocument;
+       }
+               
+       /**
+        * {@inheritDoc}
+        */
+        @Override
+       public int read() throws IOException {
+               try {
+                       if (fCurrPos < fDocument.getLength()) {
+                               return fDocument.getChar(fCurrPos++);
+                       }
+               } catch (BadLocationException e) {
+               }
+               return -1;
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICElementPropertyConstants.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICElementPropertyConstants.java
new file mode 100644 (file)
index 0000000..17fa4c7
--- /dev/null
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui;
+
+/**
+ * This interface documents the property constants used by the ICElement
+ * property source.
+ */
+
+public interface ICElementPropertyConstants {
+       /** 
+        * The <code>ICElement</code> property key for elf cpu.
+        */
+       public static final String      P_ELF_CPU = "elf_cpu"; //$NON-NLS-1$
+
+       /** 
+        * The <code>ICElement</code> property key for elf text.
+        */
+       public static final String      P_ELF_TEXT = "text"; //$NON-NLS-1$
+
+       /** 
+        * The <code>ICElement</code> property key for elf data.
+        */
+       public static final String  P_ELF_DATA = "data"; //$NON-NLS-1$
+
+       /** 
+        * The <code>ICElement</code> property key for elf bss.
+        */
+       public static final String      P_ELF_BSS = "bss"; //$NON-NLS-1$
+
+       /** 
+        * The <code>ICElement</code> property key for elf bss.
+        */
+       public static final String      P_ELF_HAS_DEBUG = "debug"; //$NON-NLS-1$
+
+       /** 
+        * The <code>ICElement</code> property key for elf soname.
+        */
+       public static final String  P_ELF_SONAME = "soname"; //$NON-NLS-1$
+
+       /** 
+        * The <code>ICElement</code> property key for elf type.
+        */
+       public static final String  P_ELF_TYPE = "type"; //$NON-NLS-1$
+
+       /** 
+        * The <code>ICElement</code> property key for elf type.
+        */
+       public static final String  P_ELF_NEEDED = "needed"; //$NON-NLS-1$
+
+       public static final String P_BINARY_FILE_CATEGORY = CUIMessages.ICElementPropertyConstants_catagory; 
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java
new file mode 100644 (file)
index 0000000..a639db0
--- /dev/null
@@ -0,0 +1,170 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * Help context ids for the c ui.
+ * <p>
+ * This interface contains constants only; it is not intended to be implemented or extended.
+ * </p>
+ *  
+ */
+public interface ICHelpContextIds {
+       public static final String PREFIX = CUIPlugin.PLUGIN_ID + "."; //$NON-NLS-1$
+
+       // Wizard pages
+       public static final String NEW_CPROJECT_WIZARD_PAGE = PREFIX + "new_cproject_wizard_page_context"; //$NON-NLS-1$
+       public static final String NEW_LAUNCH_WIZARD_PAGE = PREFIX + "new_launch_wizard_page_context"; //$NON-NLS-1$
+       public static final String NEW_CLASS_WIZARD_PAGE = PREFIX + "new_class_wizard_page_context"; //$NON-NLS-1$
+       public static final String NEW_SRCFLDER_WIZARD_PAGE = PREFIX + "new_srcfldr_wizard_page_context"; //$NON-NLS-1$
+       public static final String OPEN_CLASS_WIZARD_ACTION = PREFIX + "open_class_wizard_action"; //$NON-NLS-1$
+       public static final String OPEN_PROJECT_WIZARD_ACTION = PREFIX + "open_project_wizard_action"; //$NON-NLS-1$
+       public static final String CONVERT_TO_CCPP_WIZARD_PAGE = PREFIX + "cdt_t_conv_proj_context"; //$NON-NLS-1$
+       public static final String NEW_C_FILE_WIZARD_PAGE = PREFIX + "cdt_creating_cpp_file_context"; //$NON-NLS-1$
+       // Actions
+
+       public static final String ADD_INCLUDE_ON_SELECTION_ACTION = PREFIX + "add_includes_on_selection_action_context"; //$NON-NLS-1$;
+       public static final String FILTER_PUBLIC_ACTION= PREFIX + "filter_public_action"; //$NON-NLS-1$
+       public static final String FILTER_FIELDS_ACTION= PREFIX + "filter_fields_action"; //$NON-NLS-1$
+       public static final String FILTER_STATIC_ACTION= PREFIX + "filter_static_action"; //$NON-NLS-1$
+       public static final String FILTER_LOCALTYPES_ACTION= PREFIX + "filter_localtypes_action"; //$NON-NLS-1$
+
+       public static final String GOTO_NEXT_ERROR_ACTION= PREFIX + "goto_next_error_action";    //$NON-NLS-1$  
+       public static final String GOTO_PREVIOUS_ERROR_ACTION=  PREFIX + "goto_previous_error_action";   //$NON-NLS-1$  
+       public static final String TOGGLE_MARK_OCCURRENCES_ACTION= PREFIX + "toggle_mark_occurrences_action_context"; //$NON-NLS-1$
+       public static final String FORMAT_ALL= PREFIX + "format_all_action";     //$NON-NLS-1$
+       public static final String GOTO_MATCHING_BRACKET_ACTION= PREFIX + "goto_matching_bracket_action";        //$NON-NLS-1$
+
+       // Preference/property pages
+       public static final String C_PREF_PAGE = PREFIX + "c_pref"; //$NON-NLS-1$
+       public static final String C_EDITOR_PREF_PAGE = PREFIX + "c_editor_gen"; //$NON-NLS-1$
+       public static final String C_EDITOR_COLORS_PREF_PAGE = PREFIX + "c_editor_color"; //$NON-NLS-1$
+       public static final String C_EDITOR_CONTENT_ASSIST_PREF_PAGE = PREFIX + "c_editor_con_assist"; //$NON-NLS-1$
+       public static final String C_EDITOR_HOVERS_PAGE = PREFIX + "c_editor_hov"; //$NON-NLS-1$
+       public static final String C_EDITOR_TYPING_PAGE = PREFIX + "c_editor_typing"; //$NON-NLS-1$;
+       public static final String C_EDITOR_FOLDING_PAGE = PREFIX + "c_editor_folding"; //$NON-NLS-1$;
+       public static final String FILE_TYPES_STD_PAGE = PREFIX + "std_prop_file_types"; //$NON-NLS-1$
+       public static final String FILE_TYPES_MAN_PAGE = PREFIX + "std_prop_file_types"; //$NON-NLS-1$
+       public static final String FILE_TYPES_PREF_PAGE = PREFIX + "c_file_types"; //$NON-NLS-1$
+       public static final String TEMPLATE_PREFERENCE_PAGE = PREFIX + "code_temp"; //$NON-NLS-1$
+       public static final String LAUNCH_PROPERTY_PAGE = PREFIX + "new_launch_property_page_context"; //$NON-NLS-1$
+       public static final String PROJECT_PROPERTY_PAGE = PREFIX + "new_project_property_page_context"; //$NON-NLS-1$
+       public static final String CODEFORMATTER_PREFERENCE_PAGE = PREFIX + "codeformatter_preference_page_context"; //$NON-NLS-1$
+       public static final String INDEXER_PREFERENCE_PAGE = PREFIX + "indexer_preference_page"; //$NON-NLS-1$
+       public static final String LANGUAGE_MAPPING_PREFERENCE_PAGE = PREFIX + "language_mapping_preference_page"; //$NON-NLS-1$
+       public static final String BUILD_CONSOLE_PREFERENCE_PAGE = PREFIX + "build_console_preference_page"; //$NON-NLS-1$
+
+       public static final String PROJ_CONF_BLOCK = PREFIX + "new_proj_conf_block_context"; //$NON-NLS-1$
+
+       public static final String TODO_TASK_INPUT_DIALOG = PREFIX + "todo_task_input_dialog_context"; //$NON-NLS-1$
+
+       public static final String TODO_TASK_PROPERTY_PAGE = PREFIX + "tasktags_property_page_context"; //$NON-NLS-1$
+       public static final String TODO_TASK_PREFERENCE_PAGE = PREFIX + "tasktags_preference_page_context"; //$NON-NLS-1$
+
+       public static final String BINARY_PARSER_PAGE = PREFIX + "newproj_parser_binary"; //$NON-NLS-1$
+       public static final String ERROR_PARSERS_PAGE = PREFIX + "newproj_parser_error"; //$NON-NLS-1$
+       public static final String PROJECT_PATHS_SOURCE = PREFIX + "std_prop_source"; //$NON-NLS-1$
+       public static final String PROJECT_PATHS_OUTPUT = PREFIX + "std_prop_output"; //$NON-NLS-1$
+       public static final String PROJECT_PATHS_PROJECTS = PREFIX + "std_prop_projects"; //$NON-NLS-1$
+       public static final String PROJECT_PATHS_LIBRARIES = PREFIX + "std_prop_libraries"; //$NON-NLS-1$
+       public static final String PROJECT_PATHS_CONTAINERS      = PREFIX + "std_prop_containers"; //$NON-NLS-1$
+       public static final String PROJECT_REFERENCES = PREFIX + "std_prop_references";  //$NON-NLS-1$
+       public static final String PROJECT_INCLUDE_PATHS_SYMBOLS = PREFIX + "std_prop_include";  //$NON-NLS-1$
+
+       public static final String APPEARANCE_PREFERENCE_PAGE = PREFIX + "appearance_preference_page_context"; //$NON-NLS-1$
+       public static final String SPELLING_CONFIGURATION_BLOCK= PREFIX + "spelling_configuration_block_context"; //$NON-NLS-1$
+       public static final String CODE_TEMPLATES_PREFERENCE_PAGE = PREFIX + "code_templates_preference_context"; //$NON-NLS-1$
+       public static final String NAME_STYLE_PREFERENCE_PAGE = PREFIX + "name_style_preference_context"; //$NON-NLS-1$
+
+       // Console view
+       public static final String CLEAR_CONSOLE_ACTION = PREFIX + "clear_console_action_context"; //$NON-NLS-1$
+       public static final String CLEAR_CONSOLE_VIEW = PREFIX + "clear_console_view_context"; //$NON-NLS-1$
+
+       public static final String TOGGLE_PRESENTATION_ACTION = PREFIX + "toggle_presentation_action_context"; //$NON-NLS-1$
+       public static final String TOGGLE_TEXTHOVER_ACTION = PREFIX + "toggle_texthover_action_context"; //$NON-NLS-1$
+
+       public static final String COLLAPSE_ALL_ACTION = PREFIX + "collapse_all_action"; //$NON-NLS-1$
+
+       public static final String C_SEARCH_PAGE = PREFIX + "cdt_u_search"; //$NON-NLS-1$
+
+       public static final String COPY_ACTION = PREFIX + "copy_action_context"; //$NON-NLS-1$
+
+       // Custom Filters
+       public static final String CUSTOM_FILTERS_DIALOG= PREFIX + "open_custom_filters_dialog_context"; //$NON-NLS-1$
+
+
+       public static final String PASTE_ACTION = PREFIX + "paste_action_context"; //$NON_NLS-1$ //$NON-NLS-1$
+
+       public static final String MOVE_ACTION = PREFIX + "move_action_context"; //$NON-NLS-1$
+       public static final String RENAME_ACTION = PREFIX + "rename_action_context"; //$NON-NLS-1$
+
+       
+       public static final String REFACTORING_PREFERENCE_PAGE= PREFIX + "refactoring_preference_page_context"; //$NON-NLS-1$
+       public static final String REFACTORING_ERROR_WIZARD_PAGE=       PREFIX + "refactoring_error_wizard_page_context";  //$NON-NLS-1$
+       public static final String REFACTORING_PREVIEW_WIZARD_PAGE= PREFIX + "refactoring_preview_wizard_page_context"; //$NON-NLS-1$   
+       public static final String RENAME_PARAMS_WIZARD_PAGE=   PREFIX + "rename_params_wizard_page"; //$NON-NLS-1$
+       public static final String RENAME_METHOD_WIZARD_PAGE=   PREFIX + "rename_method_wizard_page_context"; //$NON-NLS-1$
+       public static final String RENAME_TYPE_WIZARD_PAGE=     PREFIX + "rename_type_wizard_page_context"; //$NON-NLS-1$
+       public static final String RENAME_FIELD_WIZARD_PAGE=    PREFIX + "rename_field_wizard_page_context"; //$NON-NLS-1$
+       public static final String RENAME_RESOURCE_WIZARD_PAGE= PREFIX + "rename_resource_wizard_page_context"; //$NON-NLS-1$
+
+       // Dialogs
+       public static final String EDIT_TEMPLATE_DIALOG = PREFIX + "edit_template_dialog_context"; //$NON-NLS-1$
+       public static final String OPEN_ELEMENT_DIALOG = PREFIX + "open_element_dialog_context"; //$NON-NLS-1$
+
+       // view parts
+       public static final String TYPE_HIERARCHY_VIEW= PREFIX + "type_hierarchy_view_context"; //$NON-NLS-1$
+       public static final String CALL_HIERARCHY_VIEW= PREFIX + "call_hierarchy_view_context"; //$NON-NLS-1$
+       public static final String INCLUDE_BROWSER_VIEW= PREFIX + "include_browser_view_context"; //$NON-NLS-1$
+
+       public static final String OPEN_ACTION = PREFIX + "open_action"; //$NON-NLS-1$
+       public static final String OPEN_PROJECT_ACTION = PREFIX + "open_project_action"; //$NON-NLS-1$
+
+       public static final String OPEN_TYPE_ACTION = PREFIX + "open_type_action"; //$NON-NLS-1$
+       public static final String OPEN_TYPE_IN_HIERARCHY_ACTION = PREFIX + "open_type_in_hierarchy_action"; //$NON-NLS-1$
+       public static final String OPEN_TYPE_HIERARCHY_ACTION = PREFIX + "open_type_hierarchy_action"; //$NON-NLS-1$    
+       public static final String SELECT_ALL_ACTION = PREFIX + "select_all_action"; //$NON-NLS-1$
+       public static final String LINK_EDITOR_ACTION = PREFIX + "link_editor_action"; //$NON-NLS-1$
+       public static final String TYPEHIERARCHY_HISTORY_ACTION = PREFIX + "typehierarchy_history_action"; //$NON-NLS-1$
+       public static final String HISTORY_ACTION = PREFIX + "history_action"; //$NON-NLS-1$
+       public static final String HISTORY_LIST_ACTION = PREFIX + "history_list_action"; //$NON-NLS-1$
+       public static final String TOGGLE_ORIENTATION_ACTION = PREFIX + "toggle_orientations_action"; //$NON-NLS-1$             
+       public static final String FOCUS_ON_TYPE_ACTION = PREFIX + "focus_on_type_action"; //$NON-NLS-1$
+       public static final String FOCUS_ON_SELECTION_ACTION = PREFIX + "focus_on_selection_action"; //$NON-NLS-1$
+
+       public static final String HISTORY_LIST_DIALOG = PREFIX + "history_list_dialog_context"; //$NON-NLS-1$  
+
+       public static final String SHOW_INHERITED_ACTION = PREFIX + "show_inherited_action"; //$NON-NLS-1$
+       public static final String SHOW_SUPERTYPES = PREFIX + "show_supertypes_action"; //$NON-NLS-1$
+       public static final String SHOW_SUBTYPES = PREFIX + "show_subtypes_action"; //$NON-NLS-1$
+       public static final String SHOW_HIERARCHY = PREFIX + "show_hierarchy_action"; //$NON-NLS-1$
+
+       public static final String SORT_BY_DEFINING_TYPE_ACTION = PREFIX + "sort_by_defining_type_action"; //$NON-NLS-1$        
+       public static final String SHOW_QUALIFIED_NAMES_ACTION = PREFIX + "show_qualified_names_action"; //$NON-NLS-1$  
+       public static final String ENABLE_METHODFILTER_ACTION = PREFIX + "enable_methodfilter_action"; //$NON-NLS-1$
+       
+       public static final String LEXICAL_SORTING_BROWSING_ACTION = PREFIX + "lexical_sorting_browsing_action"; //$NON-NLS-1$
+       
+       public static final String PROJECT_INDEXER_PROPERTIES = PREFIX +  "std_prop_indexer"; //$NON-NLS-1$
+       public static final String CEDITOR_VIEW = PREFIX + "editor_view"; //$NON-NLS-1$
+       public static final String COUTLINE_VIEW = PREFIX + "outline_view"; //$NON-NLS-1$
+       public static final String CPROJECT_VIEW = PREFIX + "projects_view"; //$NON-NLS-1$
+       public static final String C_SEARCH_VIEW = PREFIX + "search_view"; //$NON-NLS-1$
+
+       public static final String PATHENTRY_VARIABLES_PREFERENCE_PAGE= PREFIX + "pathentry_variables_preference_page_context"; //$NON-NLS-1$
+
+       public static final String SAVE_ACTIONS_PREFERENCE_PAGE = PREFIX + "save_actions_preference_page_context"; //$NON-NLS-1$
+       public static final String SCALABILITY_PREFERENCE_PAGE = PREFIX + "scalability_preference_page_context"; //$NON-NLS-1$
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICStatusConstants.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICStatusConstants.java
new file mode 100644 (file)
index 0000000..d95c40b
--- /dev/null
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ *  Copyright (c) 2004, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *  IBM Rational Software - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui;
+
+/**
+ * Defines status codes relevant to the CDT UI plug-in. When a 
+ * Core exception is thrown, it contain a status object describing
+ * the cause of the exception. The status objects originating from the
+ * CDT UI plug-in use the codes defined in this interface.
+  */
+public interface ICStatusConstants {
+
+       // C UI status constants start at 10000 to make sure that we don't
+       // collide with resource and c model constants.
+       
+       public static final int INTERNAL_ERROR= 10001;
+       
+       /**
+        * Status constant indicating that an exception occurred on
+        * storing or loading templates.
+        */
+       public static final int TEMPLATE_IO_EXCEPTION = 10002;
+
+       /**
+        * Status constant indicating that an validateEdit call has changed the
+        * content of a file on disk.
+        */
+       public static final int VALIDATE_EDIT_CHANGED_CONTENT= 10003;
+       
+       /**
+        * Status constant indicating that a <tt>ChangeAbortException</tt> has been
+        * caught.
+        */
+       public static final int CHANGE_ABORTED= 10004;
+
+       /**
+        * Status constant indicating that an exception occurred while
+        * parsing template file.
+        */
+       public static final int TEMPLATE_PARSE_EXCEPTION = 10005;
+
+       /**
+        * Status constant indication that a problem occurred while calculating
+        * the changed region during a save.
+        * 
+        * @since 5.1
+        */
+       public static final int EDITOR_CHANGED_REGION_CALCULATION= 10006;
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICThemeConstants.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICThemeConstants.java
new file mode 100644 (file)
index 0000000..fe764f8
--- /dev/null
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+/**
+ * Defines the constants used in the <code>org.eclipse.ui.themes</code>
+ * extension contributed by this plug-in.
+ */
+public interface ICThemeConstants {
+       String ID_PREFIX= CUIPlugin.PLUGIN_ID + "."; //$NON-NLS-1$
+
+       /**
+        * A theme constant that holds the background color used in the code assist selection dialog.
+        */
+       public final String CODEASSIST_PROPOSALS_BACKGROUND= ID_PREFIX + PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND;
+
+       /**
+        * A theme constant that holds the foreground color used in the code assist selection dialog.
+        */
+       public final String CODEASSIST_PROPOSALS_FOREGROUND= ID_PREFIX + PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND;
+
+       /**
+        * A theme constant that holds the background color used for parameter hints.
+        */
+       public final String CODEASSIST_PARAMETERS_BACKGROUND= ID_PREFIX + PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND;
+
+       /**
+        * A theme constant that holds the foreground color used for parameter hints.
+        */
+       public final String CODEASSIST_PARAMETERS_FOREGROUND= ID_PREFIX + PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND;
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/IContextMenuConstants.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/IContextMenuConstants.java
new file mode 100644 (file)
index 0000000..2c5e9df
--- /dev/null
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui;
+
+import org.eclipse.ui.navigator.ICommonMenuConstants;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * Constants for menu groups used in context menus for C views and editors.
+ * <p>
+ * This interface declares constants only; it is not intended to be implemented.
+ * </p>
+ */
+public interface IContextMenuConstants {
+
+       /**
+        * Type hierarchy view part: pop-up menu target ID for supertype hierarchy viewer
+        * (value <code>"org.eclipse.cdt.ui.TypeHierarchy.supertypes"</code>).
+        * 
+        * @since 2.0
+        */
+       public static final String TARGET_ID_SUPERTYPES_VIEW= CUIPlugin.ID_TYPE_HIERARCHY + ".supertypes"; //$NON-NLS-1$        
+
+       /**
+        * Type hierarchy view part: Pop-up menu target ID for the subtype hierarchy viewer
+        * (value <code>"org.eclipse.cdt.ui.TypeHierarchy.subtypes"</code>).
+        * 
+        * @since 2.0
+        */
+       public static final String TARGET_ID_SUBTYPES_VIEW= CUIPlugin.ID_TYPE_HIERARCHY + ".subtypes"; //$NON-NLS-1$    
+
+       /**
+        * Type hierarchy view part: pop-up menu target ID for the member viewer
+        * (value <code>"org.eclipse.cdt.ui.TypeHierarchy.members"</code>).
+        * 
+        * @since 2.0
+        */
+       public static final String TARGET_ID_MEMBERS_VIEW= CUIPlugin.ID_TYPE_HIERARCHY + ".members"; //$NON-NLS-1$      
+
+       /**
+        * Pop-up menu: name of group for goto actions (value <code>"group.goto"</code>).
+        * <p>
+        * Examples for open actions are:
+        * <ul>
+        *  <li>Go Into</li>
+        *  <li>Go To</li>
+        * </ul>
+        * </p>
+        */
+       public static final String GROUP_GOTO=          ICommonMenuConstants.GROUP_GOTO;
+       /**
+        * Pop-up menu: name of group for open actions (value <code>"group.open"</code>).
+        * <p>
+        * Examples for open actions are:
+        * <ul>
+        *  <li>Open To</li>
+        *  <li>Open With</li>
+        * </ul>
+        * </p>
+        */
+       public static final String GROUP_OPEN=          ICommonMenuConstants.GROUP_OPEN;
+       
+       /**
+        * Pop-up menu: name of group for show actions (value <code>"group.show"</code>).
+        * <p>
+        * Examples for show actions are:
+        * <ul>
+        *  <li>Show in Navigator</li>
+        *  <li>Show in Type Hierarchy</li>
+        * </ul>
+        * </p>
+        */
+       public static final String GROUP_SHOW=          ICommonMenuConstants.GROUP_SHOW;
+       
+       /**
+        * Pop-up menu: name of group for new actions (value <code>"group.new"</code>).
+        * <p>
+        * Examples for new actions are:
+        * <ul>
+        *  <li>Create new class</li>
+        *  <li>Create new interface</li>
+        * </ul>
+        * </p>
+        */
+       public static final String GROUP_NEW=           ICommonMenuConstants.GROUP_NEW;
+
+       /**
+        * Pop-up menu: name of group for build actions (value <code>"group.build"</code>).
+        */
+       public static final String GROUP_BUILD=         ICommonMenuConstants.GROUP_BUILD;
+       
+       /**
+        * Pop-up menu: name of group for reorganize actions (value <code>"group.reorganize"</code>).
+        */     
+       public static final String GROUP_REORGANIZE=    ICommonMenuConstants.GROUP_REORGANIZE;  
+       
+       /**
+        * Pop-up menu: name of group for code generation or refactoring actions (
+        * value <code>"group.generate"</code>).
+        */     
+       public static final String GROUP_GENERATE=      ICommonMenuConstants.GROUP_GENERATE;
+
+       /**
+        * Pop-up menu: name of group for search actions (value <code>"group.search"</code>).
+        */     
+       public static final String GROUP_SEARCH=        ICommonMenuConstants.GROUP_SEARCH;
+       
+       /**
+        * Pop-up menu: name of group for additional actions (value <code>"group.additions"</code>).
+        */     
+       public static final String GROUP_ADDITIONS=     ICommonMenuConstants.GROUP_ADDITIONS;
+
+       /**
+        * Pop-up menu: name of group for viewer setup actions (value <code>"group.viewerSetup"</code>).
+        */     
+       public static final String GROUP_VIEWER_SETUP=  ICommonMenuConstants.GROUP_VIEWER_SETUP;
+
+       /**
+        * Pop-up menu: name of group for properties actions (value <code>"group.properties"</code>).
+        */     
+       public static final String GROUP_PROPERTIES=    ICommonMenuConstants.GROUP_PROPERTIES;
+
+       /**
+        * Pop-up menu: name of group for debug actions (value <code>"group.debug"</code>).
+        */     
+       public static final String GROUP_DEBUG= "group.debug"; //$NON-NLS-1$
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/LineBackgroundPainter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/LineBackgroundPainter.java
new file mode 100644 (file)
index 0000000..ea5364b
--- /dev/null
@@ -0,0 +1,553 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IPaintPositionManager;
+import org.eclipse.jface.text.IPainter;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.ITextViewerExtension5;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.TypedPosition;
+import org.eclipse.swt.custom.LineBackgroundEvent;
+import org.eclipse.swt.custom.LineBackgroundListener;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+
+/**
+ * A painter for configurable background painting a range of text lines.
+ * Replicates also the functionality of the 
+ * {@link org.eclipse.jface.text.CursorLinePainter}
+ * because only one {@link LineBackgroundListener} is allowed
+ * per {@link StyledText} widget.
+ * 
+ * @author anton.leherbauer@windriver.com
+ * 
+ * @since 4.0
+ */
+public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
+
+       /** The default position type for untyped positions */
+       private static final String DEFAULT_TYPE= "__default__"; //$NON-NLS-1$
+       /** The position type for the cursor line position */
+       private static final String CURSOR_LINE_TYPE= "__cursor_line__"; //$NON-NLS-1$
+
+       /** Manager for position changes */
+       private IPaintPositionManager fPositionManager;
+       /** Indicates whether this painter is active */
+       private boolean fIsActive= false;
+       /** The text viewer this painter is associated with */
+       private ITextViewer fTextViewer;
+       /** The viewer's widget */
+       private StyledText fTextWidget;
+       /** Text positions (cursor line position is always at index 0 */
+       private List<Position> fPositions= new ArrayList<Position>();
+       /** Cached text positions */
+       private List<Position> fLastPositions= new ArrayList<Position>();
+       /** Temporary changed positions */
+       private List<Position> fChangedPositions= new ArrayList<Position>();
+       /** Cursor line position */
+       private Position fCursorLine= new TypedPosition(0, 0, CURSOR_LINE_TYPE);
+       /** Saved cursor line position */
+       private Position fLastCursorLine= new Position(0, 0);
+       /** Enablement of the cursor line highlighting */
+       private boolean fCursorLineEnabled;
+       /** Whether cursor line highlighting is active */
+       private boolean fCursorLineActive;
+       /** Map of position type to color */
+       private Map<String, Color> fColorMap= new HashMap<String, Color>();
+
+       /**
+        * Creates a new painter for the given text viewer.
+        * @param textViewer
+        */
+       public LineBackgroundPainter(ITextViewer textViewer) {
+               super();
+               fTextViewer= textViewer;
+               fTextWidget= textViewer.getTextWidget();
+               fPositions.add(fCursorLine);
+               fLastPositions.add(fLastCursorLine);
+       }
+
+       /**
+        * Sets the color in which to draw the background of the given position type.
+        * 
+        * @param positionType  the position type for which to specify the background color
+        * @param color  the color in which to draw the background of the given position type
+        */
+       public void setBackgroundColor(String positionType, Color color) {
+               fColorMap.put(positionType, color);
+       }
+
+       /**
+        * Sets the color in which to draw the background of the cursor line.
+        * 
+        * @param cursorLineColor the color in which to draw the background of the cursor line
+        */
+       public void setCursorLineColor(Color cursorLineColor) {
+               fColorMap.put(CURSOR_LINE_TYPE, cursorLineColor);
+       }
+
+       /**
+        * Sets the color in which to draw the background of untyped positions.
+        * 
+        * @param color  the color in which to draw the background of untyped positions
+        */
+       public void setDefaultColor(Color color) {
+               fColorMap.put(DEFAULT_TYPE, color);
+       }
+
+       /**
+        * Enable/disable cursor line highlighting.
+        * 
+        * @param enable
+        */
+       public void enableCursorLine(boolean enable) {
+               fCursorLineEnabled= enable;
+               fCursorLineActive= enable;
+               if (fCursorLineActive) {
+                       updateCursorLine();
+               }
+       }
+
+       /**
+        * Set highlight positions. It is assumed that all positions
+        * are up-to-date with respect to the text viewer document.
+        * 
+        * @param positions a list of <code>Position</code>s
+        */
+       public void setHighlightPositions(List<Position> positions) {
+               boolean isActive= fIsActive;
+               deactivate(isActive);
+               fPositions.clear();
+               fPositions.add(fCursorLine);
+               fPositions.addAll(positions);
+               if (isActive) {
+                       activate(true);
+               }
+       }
+
+       /**
+        * Add highlight positions. It is assumed that all positions
+        * are up-to-date with respect to the text viewer document.
+        * 
+        * @param positions a list of <code>Position</code>s
+        */
+       public void addHighlightPositions(List<Position> positions) {
+               boolean isActive= fIsActive;
+               deactivate(isActive);
+               fPositions.addAll(positions);
+               if (isActive) {
+                       activate(true);
+               }
+       }
+
+       /**
+        * Remove highlight positions by identity.
+        * 
+        * @param positions a list of <code>Position</code>s
+        */
+       public void removeHighlightPositions(List<Position> positions) {
+               boolean isActive= fIsActive;
+               deactivate(isActive);
+               fPositions.removeAll(positions);
+               if (isActive) {
+                       activate(true);
+               }
+       }
+
+       /**
+        * Replace given highlight positions in one step.
+        * 
+        * @param removePositions a list of <code>Position</code>s to remove
+        * @param addPositions a list of <code>Position</code>s to add
+        */
+       public void replaceHighlightPositions(List<Position> removePositions, List<Position> addPositions) {
+               boolean isActive= fIsActive;
+               deactivate(isActive);
+               fPositions.removeAll(removePositions);
+               fPositions.addAll(addPositions);
+               if (isActive) {
+                       activate(true);
+               }
+       }
+
+       /**
+        * Trigger redraw of managed positions.
+        */
+       public void redraw() {
+               if(fIsActive) {
+                       fTextWidget.redraw();
+               }
+       }
+
+       /**
+        * Manage all positions.
+        * @param positions
+        */
+       private void managePositions(List<Position> positions) {
+               if (fPositionManager == null) {
+                       return;
+               }
+               int sz= fPositions.size();
+               for (int i= 0; i < sz; ++i) {
+                       Position position= positions.get(i);
+                       fPositionManager.managePosition(position);
+               }
+       }
+
+       /**
+        * Unmanage all positions.
+        * @param positions
+        */
+       private void unmanagePositions(List<Position> positions) {
+               if (fPositionManager == null) {
+                       return;
+               }
+               int sz= fPositions.size();
+               for (int i= 0; i < sz; ++i) {
+                       Position position= positions.get(i);
+                       fPositionManager.unmanagePosition(position);
+               }
+       }
+
+       /*
+        * @see org.eclipse.jface.text.IPainter#dispose()
+        */
+       public void dispose() {
+               // no deactivate!
+               fIsActive= false;
+               fTextViewer= null;
+               fTextWidget= null;
+               fCursorLine= null;
+               fLastCursorLine= null;
+               fPositions= null;
+               fLastPositions= null;
+               fChangedPositions= null;
+               fColorMap= null;
+       }
+
+       /**
+        * Query whether this painter is already disposed.
+        * @return <code>true</code> if the painter is disposed
+        */
+       public boolean isDisposed() {
+               return fTextViewer == null;
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.IPainter#paint(int)
+        */
+       public void paint(int reason) {
+               IDocument document= fTextViewer.getDocument();
+               if (document == null) {
+                       deactivate(false);
+                       return;
+               }
+               activate(false);
+
+               if (fCursorLineEnabled) {
+                       // check selection
+                       StyledText textWidget= fTextViewer.getTextWidget();
+                       Point selection= textWidget.getSelection();
+                       int startLine= textWidget.getLineAtOffset(selection.x);
+                       int endLine= textWidget.getLineAtOffset(selection.y);
+                       if (startLine != endLine) {
+                               redrawPositions(Collections.singletonList(fLastCursorLine));
+                               fCursorLineActive= false;
+                       } else {
+                               fCursorLineActive= true;
+                       }
+                       if (fCursorLineActive) {
+                               // redraw in case of text changes prior to update of current cursor line
+                               if (!fLastCursorLine.equals(fCursorLine)) {
+                                       redrawPositions(Collections.singletonList(fLastCursorLine));
+                                       fLastCursorLine.offset= fCursorLine.offset;
+                                       fLastCursorLine.length= fCursorLine.length;
+                               }
+                               updateCursorLine();
+                       }
+               }
+               List<Position> changedPositions= getChangedPositions();
+               if (changedPositions != null) {
+                       redrawPositions(changedPositions);
+                       updatePositions();
+                       redrawPositions(changedPositions);
+               }
+       }
+
+       /**
+        * Activate the painter.
+        * @param redraw
+        */
+       private void activate(boolean redraw) {
+               if (!fIsActive) {
+                       fIsActive= true;
+                       fTextWidget.addLineBackgroundListener(this);
+                       if (redraw) {
+                               if (fCursorLineActive) {
+                                       updateCursorLine();
+                               }
+                               updatePositions();
+                               redrawPositions(fPositions);
+                       }
+                       managePositions(fPositions);
+               }
+       }
+
+       /**
+        * Copy positions from the current position list to the last position list.
+        */
+       private void updatePositions() {
+               int sz= fPositions.size();
+               for (int i= 0; i < sz; ++i) {
+                       Position position= fPositions.get(i);
+                       Position copy;
+                       if (i == fLastPositions.size()) {
+                               copy= new Position(position.offset, position.length);
+                               copy.isDeleted= position.isDeleted;
+                               fLastPositions.add(copy);
+                       } else {
+                               copy= fLastPositions.get(i);
+                               copy.offset= position.offset;
+                               copy.length= position.length;
+                               copy.isDeleted= position.isDeleted;
+                       }
+                       position.isDeleted= false;
+               }
+               int diff= fLastPositions.size() - sz;
+               while (diff > 0) {
+                       --diff;
+                       fLastPositions.remove(sz + diff);
+               }
+       }
+
+       /**
+        * Check which positions have changed since last redraw.
+        * @return a list of changed positions or <code>null</code> if none changed.
+        */
+       private List<Position> getChangedPositions() {
+               if (fLastPositions.size() != fPositions.size()) {
+                       return fLastPositions;
+               }
+               List<Position> changedPositions= null;
+               for (int i= 0, sz= fPositions.size(); i < sz; ++i) {
+                       Position previous= fLastPositions.get(i);
+                       Position current= fPositions.get(i);
+                       if (!previous.equals(current)) {
+                               if (changedPositions == null) {
+                                       changedPositions= fChangedPositions;
+                                       changedPositions.clear();
+                               }
+                               changedPositions.add(previous);
+                       }
+               }
+               return changedPositions;
+       }
+
+       /**
+        * Trigger redraw of given text positions.
+        * 
+        * @param positions
+        */
+       private void redrawPositions(List<Position> positions) {
+               // TextViewer.getTopIndexStartOffset is buggy
+               // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=174419
+//             final int minOffset= fTextViewer.getTopIndexStartOffset();
+               final int minOffset= getTopIndexStartOffset();
+               final int maxOffset= fTextViewer.getBottomIndexEndOffset()+3;
+               Rectangle clientArea= fTextWidget.getClientArea();
+               int width= clientArea.width + fTextWidget.getHorizontalPixel();
+               int lineHeight= fTextWidget.getLineHeight();
+               for (int i= 0, sz= positions.size(); i < sz; ++i) {
+                       Position position= positions.get(i);
+                       // if the position that is about to be drawn was deleted then we can't
+                       if (position.isDeleted()) {
+                               continue;
+                       }
+                       // check if position overlaps with visible area
+                       if (!position.overlapsWith(minOffset, maxOffset - minOffset + 1)) {
+                               continue;
+                       }
+                       int widgetOffset= getWidgetOffset(position.offset);
+                       if (widgetOffset < 0 || widgetOffset > fTextWidget.getCharCount()) {
+                               continue;
+                       }
+                       // TLETODO [performance] SyledText.getLocationAtOffset() is very expensive
+                       Point upperLeft= fTextWidget.getLocationAtOffset(widgetOffset);
+                       int upperY= Math.max(Math.min(upperLeft.y, clientArea.height), 0);
+                       int height;
+                       if (position.length == 0) {
+                               height= lineHeight;
+                       } else {
+                               int widgetEndOffset= Math.min(widgetOffset + position.length, fTextWidget.getCharCount());
+                               Point lowerRight= fTextWidget.getLocationAtOffset(widgetEndOffset);
+                               int lowerY= Math.min(lowerRight.y + lineHeight, clientArea.height);
+                               height= lowerY - upperY;
+                       }
+                       if (height > 0) {
+                               fTextWidget.redraw(0, upperY, width, height, false);
+                       }
+               }
+       }
+
+       /**
+        * Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=174419
+        * @return the offset of the topmost visible line
+        * @see ITextViewer#getTopIndexStartOffset()
+        */
+       private int getTopIndexStartOffset() {
+               if (fTextWidget != null) {
+                       int top= fTextWidget.getTopIndex();
+                       // https://bugs.eclipse.org/bugs/show_bug.cgi?id=183653
+                       top= fTextWidget.getOffsetAtLine(Math.min(fTextWidget.getLineCount() - 1, top));
+                       if (top >= 0) {
+                               return getDocumentOffset(top);
+                       }
+               }
+               return -1;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.IPainter#deactivate(boolean)
+        */
+       public void deactivate(boolean redraw) {
+               if (fIsActive) {
+                       fIsActive= false;
+                       fTextWidget.removeLineBackgroundListener(this);
+                       if (redraw) {
+                               redrawPositions(fLastPositions);
+                       }
+                       unmanagePositions(fPositions);
+               }
+       }
+
+       /*
+        * @see org.eclipse.jface.text.IPainter#setPositionManager(org.eclipse.jface.text.IPaintPositionManager)
+        */
+       public void setPositionManager(IPaintPositionManager manager) {
+               fPositionManager= manager;
+       }
+
+       /**
+        * Convert a document offset to the corresponding widget offset.
+        * @param documentOffset
+        * @return widget offset
+        */
+       private int getWidgetOffset(int documentOffset) {
+               if (fTextViewer instanceof ITextViewerExtension5) {
+                       ITextViewerExtension5 extension= (ITextViewerExtension5)fTextViewer;
+                       return extension.modelOffset2WidgetOffset(documentOffset);
+               }
+               IRegion visible= fTextViewer.getVisibleRegion();
+               int widgetOffset= documentOffset - visible.getOffset();
+               if (widgetOffset > visible.getLength()) {
+                       return -1;
+               }
+               return widgetOffset;
+       }
+
+       /**
+        * Convert a widget offset to the corresponding document offset.
+        * @param widgetOffset
+        * @return document offset
+        */
+       private int getDocumentOffset(int widgetOffset) {
+               if (fTextViewer instanceof ITextViewerExtension5) {
+                       ITextViewerExtension5 extension= (ITextViewerExtension5)fTextViewer;
+                       return extension.widgetOffset2ModelOffset(widgetOffset);
+               }
+               IRegion visible= fTextViewer.getVisibleRegion();
+               if (widgetOffset > visible.getLength()) {
+                       return -1;
+               }
+               return widgetOffset + visible.getOffset();
+       }
+
+       /*
+        * @see org.eclipse.swt.custom.LineBackgroundListener#lineGetBackground(org.eclipse.swt.custom.LineBackgroundEvent)
+        */
+       public void lineGetBackground(LineBackgroundEvent event) {
+               if (fTextWidget != null) {
+                       Position match= findIncludingPosition(getDocumentOffset(event.lineOffset));
+                       if (match != null) {
+                               Color color= getColorForPosition(match);
+                               if (color != null) {
+                                       event.lineBackground= color;
+                               }
+                       }
+               }
+       }
+
+       /**
+        * Get the color associated with given position.
+        * @param position
+        * @return the color associated with the position type
+        */
+       private Color getColorForPosition(Position position) {
+               if (position == fCursorLine) {
+                       if (fCursorLine.length == 0) {
+                               return fColorMap.get(CURSOR_LINE_TYPE);
+                       }
+               } else {
+                       if (position instanceof TypedPosition) {
+                               String type= ((TypedPosition)position).getType();
+                               return fColorMap.get(type);
+                       }
+                       return fColorMap.get(DEFAULT_TYPE);
+               }
+               return null;
+       }
+
+       /**
+        * Find position which includes the (document-)offset.
+        * @param offset
+        * @return the first position including the offset or <code>null</code>.
+        */
+       private Position findIncludingPosition(int offset) {
+               // TLETODO [performance] Use binary search?
+               for (int i= fCursorLineActive ? 0 : 1, sz= fPositions.size(); i < sz; ++i) {
+                       Position position= fPositions.get(i);
+                       if (position.offset == offset || position.includes(offset)) {
+                               return position;
+                       }
+               }
+               return null;
+       }
+
+       /**
+        * Updates the position of the cursor line.
+        */
+       private void updateCursorLine() {
+               try {
+                       IDocument document= fTextViewer.getDocument();
+                       if (document != null) {
+                               int lineNumber= document.getLineOfOffset(getDocumentOffset(fTextWidget.getCaretOffset()));
+       
+                               fCursorLine.isDeleted= false;
+                               fCursorLine.offset= document.getLineOffset(lineNumber);
+                               fCursorLine.length= 0;
+                       }
+               } catch (BadLocationException e) {
+                       // gracefully ignored
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/MacrosGrouping.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/MacrosGrouping.java
new file mode 100644 (file)
index 0000000..4d2952d
--- /dev/null
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Marc-Andre Laperle - Bug 233390 (adapted from IncludesGrouping)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CElementGrouping;
+
+/**
+ * Grouping for macro definitions.
+ * 
+ * @since 5.2
+ */
+public class MacrosGrouping extends CElementGrouping {
+       ITranslationUnit tu;
+
+       public MacrosGrouping(ITranslationUnit unit) {
+               super(CElementGrouping.MACROS_GROUPING);
+               tu = unit;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
+        */
+       @Override
+       public Object[] getChildren(Object object) {
+               try {
+                       return tu.getChildrenOfType(ICElement.C_MACRO).toArray();
+               } catch (CModelException e) {
+               }
+               return super.getChildren(object);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
+        */
+       @Override
+       public Object getParent(Object object) {
+               return tu;
+       }
+
+       /* (non-Javadoc)
+        * @see java.lang.Object#equals(java.lang.Object)
+        */
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj) {
+                       return true;
+               }
+               if (obj instanceof MacrosGrouping) {
+                       return tu.equals(((MacrosGrouping)obj).tu) ;
+               }
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/MembersGrouping.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/MembersGrouping.java
new file mode 100644 (file)
index 0000000..96f89d9
--- /dev/null
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IMember;
+import org.eclipse.cdt.core.model.INamespace;
+import org.eclipse.cdt.core.model.IParent;
+import org.eclipse.cdt.ui.CElementGrouping;
+import org.eclipse.cdt.ui.NamespacesGrouping;
+
+/**
+ * Grouping for members in the same namespace.
+ */
+public class MembersGrouping extends CElementGrouping {
+
+       private final Object fParent;
+       private final String fNamespace;
+
+       public MembersGrouping(Object parent, String namespace) {
+               super(CElementGrouping.CLASS_GROUPING);
+               assert parent instanceof ICElement || parent instanceof NamespacesGrouping;
+               fParent= parent;
+               fNamespace= namespace;
+       }
+
+       @Override
+       public String getLabel(Object object) {
+               return fNamespace;
+       }
+
+       @Override
+       public Object[] getChildren(Object object) {
+               List<ICElement> nsMembers = new ArrayList<ICElement>();
+               if (fParent instanceof IParent) {
+                       try {
+                               nsMembers.addAll(getNamespaceChildren(((IParent)fParent).getChildren()));
+                       } catch (CModelException exc) {
+                       }
+               } else if (fParent instanceof NamespacesGrouping) {
+                       NamespacesGrouping nsGrouping = (NamespacesGrouping) fParent;
+                       INamespace[] namespaces = nsGrouping.getNamespaces();
+                       for (INamespace iNamespace : namespaces) {
+                               try {
+                                       nsMembers.addAll(getNamespaceChildren(iNamespace.getChildren()));
+                               } catch (CModelException exc) {
+                               }
+                       }
+               }
+               return nsMembers.toArray();
+       }
+
+       /**
+        * @param iNamespace
+        * @return
+        */
+       private Collection<? extends ICElement> getNamespaceChildren(ICElement[] icElements) {
+               List<ICElement> members = new ArrayList<ICElement>(icElements.length);
+               for (ICElement icElement : icElements) {
+                       if (icElement instanceof IMember) {
+                               String name = icElement.getElementName();
+                               int idx = name.lastIndexOf("::"); //$NON-NLS-1$
+                               if (idx < 0) {
+                                       continue;
+                               }
+                               String namespace = name.substring(0, idx);
+                               if (fNamespace.equals(namespace)) {
+                                       members.add(icElement);
+                               }
+                       }
+               }
+               return members;
+       }
+
+       @Override
+       public Object getParent(Object object) {
+               return fParent;
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj) {
+                       return true;
+               }
+               if (obj instanceof MembersGrouping) {
+                       final MembersGrouping other= (MembersGrouping)obj;
+                       return fParent.equals(other.fParent) && fNamespace.equals(other.fNamespace);
+               }
+               return false;
+       }
+
+       @Override
+       public int hashCode() {
+               return fParent.hashCode() * 17 + fNamespace.hashCode();
+       }
+       
+       @Override
+       public String toString() {
+               return fNamespace;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/PersistableCElementFactory.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/PersistableCElementFactory.java
new file mode 100644 (file)
index 0000000..547ce71
--- /dev/null
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui;
+
+import java.io.File;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.ui.IElementFactory;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IPersistableElement;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+
+/** 
+ * The PersistableCElementFactory is used to save and recreate an ICElement object.
+ * As such, it implements the IPersistableElement interface for storage
+ * and the IElementFactory interface for recreation.
+ *
+ * @see IMemento
+ * @see IPersistableElement
+ * @see IElementFactory
+ */
+public class PersistableCElementFactory implements IElementFactory, IPersistableElement {
+
+    // These persistence constants are stored in XML.  Do not
+    // change them.
+    private static final String TAG_PATH = "path";//$NON-NLS-1$
+    private static final String TAG_TYPE = "type";//$NON-NLS-1$
+
+    private static final String FACTORY_ID = "org.eclipse.cdt.ui.PersistableCElementFactory";//$NON-NLS-1$
+
+    // IPersistable data.
+    private ICElement fCElement;
+
+    /**
+     * Create a PersistableCElementFactory.  This constructor is typically used
+     * for our IElementFactory side.
+     */
+    public PersistableCElementFactory() {
+    }
+
+    /**
+     * Create a PersistableCElementFactory.  This constructor is typically used
+     * for our IPersistableElement side.
+     */
+    public PersistableCElementFactory(ICElement input) {
+        fCElement = input;
+    }
+
+    /**
+     * @see IElementFactory
+     */
+    public IAdaptable createElement(IMemento memento) {
+        // Get the file name.
+        String fileName = memento.getString(TAG_PATH);
+        if (fileName == null) {
+                       return null;
+               }
+
+        IPath elementPath= new Path(fileName);
+        fCElement = CoreModel.getDefault().create(elementPath);
+        if (fCElement != null && fCElement.getResource() != null) {
+               IResource resource= fCElement.getResource();
+               if (!resource.isAccessible()) {
+                       return resource;
+               }
+        }
+        if (fCElement != null) {
+               return fCElement;
+        }
+        
+        final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+        Integer elementType= memento.getInteger(TAG_TYPE);
+               if (elementType == null) {
+                       if (elementPath.segmentCount() == 1) {
+                               return root.getProject(fileName);
+                       }
+               IFolder folder= root.getFolder(elementPath);
+               File osFile= folder.getLocation().toFile();
+               if (osFile.isDirectory()) {
+                       return folder;
+               }
+               return root.getFile(elementPath);
+        }
+               switch (elementType.intValue()) {
+               case IResource.ROOT:
+                       return root;
+               case IResource.PROJECT:
+                       return root.getProject(fileName);
+               case IResource.FOLDER:
+                       return root.getFolder(elementPath);
+               case IResource.FILE:
+                       return root.getFile(elementPath);
+               }
+        return null;
+    }
+
+    /**
+     * @see IPersistableElement
+     */
+    public String getFactoryId() {
+        return FACTORY_ID;
+    }
+
+    /**
+     * @see IPersistableElement
+     */
+    public void saveState(IMemento memento) {
+       if (fCElement.getResource() != null) {
+               memento.putString(TAG_PATH, fCElement.getResource().getFullPath().toString());
+               memento.putInteger(TAG_TYPE, fCElement.getResource().getType());
+       }
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ResourceAdapterFactory.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ResourceAdapterFactory.java
new file mode 100644 (file)
index 0000000..3904942
--- /dev/null
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.runtime.IAdapterFactory;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+
+public class ResourceAdapterFactory implements IAdapterFactory {
+
+       private static Class<?>[] PROPERTIES= new Class[] {
+               ICElement.class
+       };
+       
+       //private static CElementFactory celementFactory= new CElementFactory();
+       private static CoreModel celementFactory= CoreModel.getDefault();
+
+       /**
+        * @see IAdapterFactory#getAdapterList
+        */     
+       public Class<?>[] getAdapterList() {
+               return PROPERTIES;
+       }
+       
+       /**
+        * @see IAdapterFactory#getAdapter
+        */
+       @SuppressWarnings("rawtypes")
+       public Object getAdapter(Object element, Class key) {
+               if (ICElement.class.equals(key)) {
+                       //try {
+                               if (element instanceof IFile) {
+                                       return celementFactory.create((IFile)element);
+                               } else if (element instanceof IFolder) {
+                                       return celementFactory.create((IFolder)element);
+                               } else if (element instanceof IProject) {
+                                       return celementFactory.create((IProject)element);
+                               } else if (element instanceof IWorkspaceRoot) {
+                                       return CoreModel.create((IWorkspaceRoot)element);
+                               } else if (element instanceof IResource) {
+                                       return celementFactory.create((IResource)element);
+                               }
+                       //} catch (CoreException e) {
+                       //      CUIPlugin.getDefault().getLog().log(e.getStatus());
+                       //}
+               }
+               return null;
+       }       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractToggleLinkingAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractToggleLinkingAction.java
new file mode 100644 (file)
index 0000000..901dd83
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.actions;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.jface.action.Action;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * This is an action template for actions that toggle whether
+ * it links its selection to the active editor.
+ * 
+ * @since 3.0
+ */
+public abstract class AbstractToggleLinkingAction extends Action {
+       
+       /**
+        * Constructs a new action.
+        */
+       public AbstractToggleLinkingAction() {
+               super(ActionMessages.ToggleLinkingAction_label);
+               setDescription(ActionMessages.ToggleLinkingAction_description);
+               setToolTipText(ActionMessages.ToggleLinkingAction_tooltip);
+               CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "synced.gif"); //$NON-NLS-1$               
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.LINK_EDITOR_ACTION);
+       }
+
+       /**
+        * Runs the action.
+        */
+       @Override
+       public abstract void run();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractUpdateIndexAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractUpdateIndexAction.java
new file mode 100644 (file)
index 0000000..bf4d34d
--- /dev/null
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *    Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.actions;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.index.IIndexManager;
+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.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+public abstract class AbstractUpdateIndexAction implements IObjectActionDelegate {
+
+       private ISelection fSelection;
+       
+       public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+       }
+
+       public void run(IAction action) {
+               if (!(fSelection instanceof IStructuredSelection))
+                       return;
+               
+               IStructuredSelection cElements= SelectionConverter.convertSelectionToCElements(fSelection);
+               Iterator<?> i= cElements.iterator();
+               ArrayList<ICElement> tuSelection= new ArrayList<ICElement>();
+               while (i.hasNext()) {
+                       Object o= i.next();
+                       if (o instanceof ICProject || o instanceof ICContainer || o instanceof ITranslationUnit) {
+                               tuSelection.add((ICElement) o);
+                       }
+               }
+               ICElement[] tuArray= tuSelection.toArray(new ICElement[tuSelection.size()]);
+               
+               try {
+                       CCorePlugin.getIndexManager().update(tuArray, getUpdateOptions());
+               }
+               catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }
+       }
+
+       /**
+        * Return the options to update the translation.
+        * @see IIndexManager#update(ICElement[], int)
+        * @since 4.0
+        */
+       abstract protected int getUpdateOptions();
+
+       /**
+        * @see IActionDelegate#selectionChanged(IAction, ISelection)
+        */
+       public void selectionChanged(IAction action, ISelection selection) {
+               fSelection = selection;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java
new file mode 100644 (file)
index 0000000..bb59cbe
--- /dev/null
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ *  Copyright (c) 2001, 2010 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     Rational Software - initial implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.actions;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Class that gives access to the action messages resource bundle.
+ */
+public class ActionMessages extends NLS {
+       public static String SourceMenu_label;
+       public static String SelectionConverter_codeResolve_failed;
+       public static String OpenAction_label;
+       public static String OpenAction_tooltip;
+       public static String OpenAction_description;
+       public static String OpenAction_declaration_label;
+       public static String OpenAction_select_element;
+       public static String OpenAction_error_title;
+       public static String OpenAction_error_message;
+       public static String OpenAction_error_messageArgs;
+       public static String OpenAction_error_messageProblems;
+       public static String OpenAction_error_messageBadSelection;
+       public static String MemberFilterActionGroup_hide_fields_label;
+       public static String MemberFilterActionGroup_hide_fields_tooltip;
+       public static String MemberFilterActionGroup_hide_fields_description;
+       public static String MemberFilterActionGroup_hide_static_label;
+       public static String MemberFilterActionGroup_hide_static_tooltip;
+       public static String MemberFilterActionGroup_hide_static_description;
+       public static String MemberFilterActionGroup_hide_nonpublic_label;
+       public static String MemberFilterActionGroup_hide_nonpublic_tooltip;
+       public static String MemberFilterActionGroup_hide_nonpublic_description;
+       public static String MemberFilterActionGroup_hide_inactive_label;
+       public static String MemberFilterActionGroup_hide_inactive_tooltip;
+       public static String MemberFilterActionGroup_hide_inactive_description;
+       public static String ActionUtil_notOnBuildPath_title;
+       public static String ActionUtil_notOnBuildPath_message;
+       public static String ActionUtil_warning_derived_dontShowAgain;
+       public static String ActionUtil_warning_derived_message;
+       public static String ActionUtil_warning_derived_title;
+       public static String SelectAllAction_label;
+       public static String SelectAllAction_tooltip;
+       public static String ToggleLinkingAction_label;
+       public static String ToggleLinkingAction_tooltip;
+       public static String ToggleLinkingAction_description;
+       public static String IncludesGroupingAction_label;
+       public static String IncludesGroupingAction_tooltip;
+       public static String IncludesGroupingAction_description;
+       public static String NamespacesGroupingAction_label;
+       public static String NamespacesGroupingAction_tooltip;
+       public static String NamespacesGroupingAction_description;
+       public static String MemberGroupingAction_label;
+       public static String MemberGroupingAction_tooltip;
+       public static String MemberGroupingAction_description;
+       public static String MacroGroupingAction_label;
+       public static String MacroGroupingAction_tooltip;
+       public static String MacroGroupingAction_description;
+       public static String COutlineInformationControl_viewMenu_sort_label;
+       public static String ChangeBuildConfigMenuAction_title;
+       public static String ChangeBuildConfigMenuAction_text;
+       public static String CreateParserLogAction_existingFile;
+       public static String CreateParserLogAction_readOnlyFile;
+       public static String DeleteResConfigsAction_0;
+       public static String DeleteResConfigsAction_1;
+       public static String ExcludeFromBuildAction_0;
+       public static String ExcludeFromBuildAction_1;
+       public static String BuildActiveConfigMenuAction_defaultTooltip;
+       public static String BuildActiveConfigMenuAction_buildConfigTooltip;
+       public static String SurroundWithTemplateMenuAction_SubMenuName;
+       public static String SurroundWithTemplateMenuAction_ConfigureTemplatesActionName;
+       public static String SurroundWithTemplateMenuAction_NoneApplicable;
+       public static String CopyTreeAction_problem;
+       public static String CopyTreeAction_clipboard_busy;
+       public static String FormatAllAction_label;
+       public static String FormatAllAction_tooltip;
+       public static String FormatAllAction_description;
+       public static String FormatAllAction_status_description;
+       public static String FormatAllAction_multi_status_title;
+       public static String FormatAllAction_error_title;
+       public static String FormatAllAction_error_message;
+       public static String FormatAllAction_operation_description;
+       public static String FormatAllAction_failedvalidateedit_title;
+       public static String FormatAllAction_failedvalidateedit_message;
+       public static String FormatAllAction_noundo_title;
+       public static String FormatAllAction_noundo_message;
+
+       static {
+               // Initialize resource bundle.
+               NLS.initializeMessages(ActionMessages.class.getName(), ActionMessages.class);
+       }
+
+       private ActionMessages() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties
new file mode 100644 (file)
index 0000000..c27f42b
--- /dev/null
@@ -0,0 +1,111 @@
+###############################################################################
+# Copyright (c) 2000, 2010 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+#     Anton Leherbauer (Wind River Systems)
+#     Axel Mueller - [289339] Surround with
+#     Sergey Prigogin (Google)
+###############################################################################
+
+SourceMenu_label=Source
+
+SelectionConverter_codeResolve_failed=Couldn't convert text selection into a C element
+
+OpenAction_label=&Open
+OpenAction_tooltip=Open an editor on the selected element
+OpenAction_description=Open an editor on the selected element
+OpenAction_declaration_label=&Open Declaration
+OpenAction_select_element=&Select or enter the element to open:
+
+OpenAction_error_title=Open
+OpenAction_error_message=Cannot open default editor.
+OpenAction_error_messageArgs=Cannot open default editor on {0}. {1}
+OpenAction_error_messageProblems=Problems Opening Editor
+OpenAction_error_messageBadSelection=Current text selection doesn't resolve to a C element
+
+MemberFilterActionGroup_hide_fields_label=Hide Fiel&ds
+MemberFilterActionGroup_hide_fields_tooltip=Hide Fields
+MemberFilterActionGroup_hide_fields_description=Toggles the visibility of fields
+
+MemberFilterActionGroup_hide_static_label=Hide &Static Members
+MemberFilterActionGroup_hide_static_tooltip=Hide Static Members
+MemberFilterActionGroup_hide_static_description=Toggles the visibility of static members
+
+MemberFilterActionGroup_hide_nonpublic_label=Hide Non-&Public Members
+MemberFilterActionGroup_hide_nonpublic_tooltip=Hide Non-Public Members
+MemberFilterActionGroup_hide_nonpublic_description=Toggles the visibility of non-public members
+
+MemberFilterActionGroup_hide_inactive_label=Hide &Inactive Elements
+MemberFilterActionGroup_hide_inactive_tooltip=Hide Inactive Elements
+MemberFilterActionGroup_hide_inactive_description=Toggles the visibility of inactive elements
+
+ActionUtil_notOnBuildPath_title=Operation Cannot be Performed
+ActionUtil_notOnBuildPath_message=The resource is not on the build path of a Java project.
+ActionUtil_warning_derived_title=Derived File Encountered
+ActionUtil_warning_derived_message=The file ''{0}'' is derived. Do you really want to edit it?
+ActionUtil_warning_derived_dontShowAgain=In the future, never warn if editing a derived file.
+
+SelectAllAction_label= Select A&ll
+SelectAllAction_tooltip= Select All
+
+ToggleLinkingAction_label=Lin&k With Editor
+ToggleLinkingAction_tooltip=Link with Editor
+ToggleLinkingAction_description=Link with active editor
+
+IncludesGroupingAction_label=Group Includes
+IncludesGroupingAction_tooltip=Group includes statements
+IncludesGroupingAction_description=Group includes statements
+
+NamespacesGroupingAction_label=Group Namespaces
+NamespacesGroupingAction_tooltip=Group namespaces
+NamespacesGroupingAction_description=Group namespaces
+
+MemberGroupingAction_label=Group Methods
+MemberGroupingAction_tooltip=Group method definitions
+MemberGroupingAction_description=Group method definitions
+
+MacroGroupingAction_label= Group Macros
+MacroGroupingAction_tooltip= Group macro definitions
+MacroGroupingAction_description= Group macro definitions
+
+COutlineInformationControl_viewMenu_sort_label=Sort
+
+ChangeBuildConfigMenuAction_title=Sorry
+ChangeBuildConfigMenuAction_text=No way to manage configurations for selected objects.
+CreateParserLogAction_existingFile=''{0}'' already exists.\nDo you want to replace it?
+CreateParserLogAction_readOnlyFile=''{0}'' cannot be modified\!
+
+DeleteResConfigsAction_0=Select resource configurations to restore default settings
+DeleteResConfigsAction_1=Reset Resource Configurations
+
+ExcludeFromBuildAction_0=Exclude object(s) from build in the following configurations
+ExcludeFromBuildAction_1=Exclude from build
+
+BuildActiveConfigMenuAction_defaultTooltip=Build the active configurations of selected projects
+BuildActiveConfigMenuAction_buildConfigTooltip=Build ''{0}'' for project ''{1}''
+
+SurroundWithTemplateMenuAction_SubMenuName=Surround &With
+SurroundWithTemplateMenuAction_ConfigureTemplatesActionName=&Configure Templates...
+SurroundWithTemplateMenuAction_NoneApplicable=(no template applicable)
+
+CopyTreeAction_problem=Problem Copying to Clipboard
+CopyTreeAction_clipboard_busy=There was a problem when accessing the system clipboard. Retry?
+
+FormatAllAction_label=&Format
+FormatAllAction_tooltip=Format all selected C/C++ files
+FormatAllAction_description=Format all selected C/C++ files
+FormatAllAction_status_description=Problems while formatting some files. See 'Details' for more information.
+FormatAllAction_multi_status_title=Format
+FormatAllAction_error_title=Format
+FormatAllAction_error_message=Unexpected error while formatting. See log for details.
+
+FormatAllAction_operation_description=Formatting...
+FormatAllAction_failedvalidateedit_title=Format
+FormatAllAction_failedvalidateedit_message=Problems while accessing selected files.
+FormatAllAction_noundo_title=Format
+FormatAllAction_noundo_message='Undo' is not supported by this operation. Do you want to continue?
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionUtil.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionUtil.java
new file mode 100644 (file)
index 0000000..258e18b
--- /dev/null
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.actions;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.MessageDialogWithToggle;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
+
+import org.eclipse.cdt.core.model.ICElement;
+
+import org.eclipse.cdt.internal.corext.util.Messages;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.viewsupport.BasicElementLabels;
+
+/*
+ * http://dev.eclipse.org/bugs/show_bug.cgi?id=19104
+ */
+public class ActionUtil {
+       
+       private ActionUtil(){
+       }
+
+       //bug 31998     we will have to disable renaming of linked packages (and cus)
+       public static boolean mustDisableCModelAction(Shell shell, Object element) {
+           return false;
+//             if (!(element instanceof IPackageFragment) && !(element instanceof IPackageFragmentRoot))
+//                     return false;
+//             
+//             IResource resource= ResourceUtil.getResource(element);
+//             if ((resource == null) || (! (resource instanceof IFolder)) || (! resource.isLinked()))
+//                     return false;
+//                     
+//             MessageDialog.openInformation(shell, ActionMessages.ActionUtil.not_possible"), ActionMessages.ActionUtil.no_linked")); //$NON-NLS-1$ //$NON-NLS-2$
+//             return true;
+       }
+       
+       public static boolean isProcessable(CEditor editor) {
+               if (editor == null)
+                       return true;
+               Shell shell = editor.getSite().getShell();
+               ICElement input= SelectionConverter.getInput(editor);
+               // if a C/C++ editor doesn't have an input of type C element
+               // then it is for sure not on the build path
+               if (input == null) {
+                       MessageDialog.openInformation(shell, 
+                                       ActionMessages.ActionUtil_notOnBuildPath_title,
+                                       ActionMessages.ActionUtil_notOnBuildPath_message);
+                       return false;
+               }
+               return isProcessable(shell, input);
+       }
+       
+       public static boolean isProcessable(Shell shell, Object element) {
+               if (!(element instanceof ICElement))
+                       return true;
+                       
+               if (isOnBuildPath((ICElement) element))
+                       return true;
+               MessageDialog.openInformation(shell, 
+                               ActionMessages.ActionUtil_notOnBuildPath_title,
+                               ActionMessages.ActionUtil_notOnBuildPath_message);
+               return false;
+       }
+
+       public static boolean isOnBuildPath(ICElement element) {        
+        //fix for bug http://dev.eclipse.org/bugs/show_bug.cgi?id=20051
+        if (element.getElementType() == ICElement.C_PROJECT)
+            return true;
+//             ICProject project= element.getCProject();
+//             if (!project.isOnSourceRoot(element.getResource()))
+//                     return false;
+               return true;
+       }
+
+       /**
+        * Check whether <code>editor</code> and <code>element</code> are
+        * processable and editable. If the editor edits the element, the validation
+        * is only performed once. If necessary, ask the user whether the file(s)
+        * should be edited.
+        *
+        * @param editor an editor, or <code>null</code> iff the action was not
+        *        executed from an editor
+        * @param shell a shell to serve as parent for a dialog
+        * @param element the element to check, cannot be <code>null</code>
+        * @return <code>true</code> if the element can be edited,
+        *         <code>false</code> otherwise
+        */
+       public static boolean isEditable(CEditor editor, Shell shell, ICElement element) {
+               if (editor != null) {
+                       ICElement input= SelectionConverter.getInput(editor);
+                       if (input != null && input.equals(element.getAncestor(ICElement.C_UNIT)))
+                               return isEditable(editor);
+                       else
+                               return isEditable(editor) && isEditable(shell, element);
+               }
+               return isEditable(shell, element);
+       }
+
+       public static boolean isEditable(CEditor editor) {
+               if (!isProcessable(editor))
+                       return false;
+
+               return editor.validateEditorInputState();
+       }
+       
+       public static boolean isEditable(Shell shell, ICElement element) {
+               if (!isProcessable(shell, element))
+                       return false;
+
+               ICElement cu= element.getAncestor(ICElement.C_UNIT);
+               if (cu != null) {
+                       IResource resource= cu.getResource();
+                       if (resource != null && resource.isDerived()) {
+                               // see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#validateEditorInputState()
+                               final String warnKey= AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WARN_IF_INPUT_DERIVED;
+                               IPreferenceStore store= EditorsUI.getPreferenceStore();
+                               if (!store.getBoolean(warnKey))
+                                       return true;
+
+                               MessageDialogWithToggle toggleDialog= MessageDialogWithToggle.openYesNoQuestion(
+                                               shell,
+                                               ActionMessages.ActionUtil_warning_derived_title,
+                                               Messages.format(ActionMessages.ActionUtil_warning_derived_message, BasicElementLabels.getPathLabel(resource.getFullPath(), false)),
+                                               ActionMessages.ActionUtil_warning_derived_dontShowAgain,
+                                               false,
+                                               null,
+                                               null);
+
+                               EditorsUI.getPreferenceStore().setValue(warnKey, !toggleDialog.getToggleState());
+                               return toggleDialog.getReturnCode() == IDialogConstants.YES_ID;
+                       }
+               }
+               return true;
+       }
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AddBlockCommentAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AddBlockCommentAction.java
new file mode 100644 (file)
index 0000000..6b0046a
--- /dev/null
@@ -0,0 +1,200 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Andrew Gvozdev - http://bugs.eclipse.org/236160
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.actions;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ResourceBundle;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.BadPartitioningException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentExtension3;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+/**
+ * Action that encloses the editor's current selection with C block comment terminators
+ * (<code>&#47;&#42;</code> and <code>&#42;&#47;</code>).
+ * 
+ * @since 3.0
+ */
+public class AddBlockCommentAction extends BlockCommentAction {
+       /**
+        * Creates a new instance.
+        * 
+        * @param bundle the resource bundle
+        * @param prefix a prefix to be prepended to the various resource keys
+        *   (described in <code>ResourceAction</code> constructor), or 
+        *   <code>null</code> if none
+        * @param editor the text editor
+        */
+       public AddBlockCommentAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
+               super(bundle, prefix, editor);
+       }
+       
+       @Override
+       protected void runInternal(ITextSelection selection,
+                       IDocumentExtension3 docExtension, Edit.EditFactory factory)
+                       throws BadLocationException, BadPartitioningException {
+               
+               if ( !(docExtension instanceof IDocument) ) return;
+               
+               List<Edit> edits= new LinkedList<Edit>();
+
+               ITypedRegion firstPartition = docExtension.getPartition(ICPartitions.C_PARTITIONING,
+                               selection.getOffset(), false);
+               ITypedRegion lastPartition = docExtension.getPartition(ICPartitions.C_PARTITIONING,
+                               selection.getOffset() + selection.getLength() - 1, false);
+               
+               int commentAreaStart = selection.getOffset();
+               int commentAreaEnd = selection.getOffset()+selection.getLength();
+               // Include special partitions fully in the comment area
+               if (isSpecialPartition(firstPartition.getType())) {
+                       commentAreaStart = firstPartition.getOffset();
+               }
+               if (isSpecialPartition(lastPartition.getType())) {
+                       commentAreaEnd = lastPartition.getOffset() + lastPartition.getLength();
+               }
+               Region estimatedCommentArea = new Region(commentAreaStart,commentAreaEnd-commentAreaStart);
+
+               
+               Region commentArea = handleEnclosingPartitions(estimatedCommentArea, lastPartition,
+                               (IDocument)docExtension, factory, edits);
+
+               handleInteriorPartition(commentArea, firstPartition, docExtension, factory, edits);
+               
+               executeEdits(edits);
+       }
+
+       /**
+        * Add enclosing comment tags for the whole area to be commented
+        * 
+        * @param commentArea initial comment area which can be adjusted
+        * @param lastPartition last partition
+        * @param doc document
+        * @param factory Edit factory
+        * @param edits List of edits to update the document
+        * @return new possibly adjusted comment area
+        * @throws BadLocationException
+        */
+       private Region handleEnclosingPartitions(Region commentArea,
+                       ITypedRegion lastPartition, IDocument doc, Edit.EditFactory factory,
+                       List<Edit> edits) throws BadLocationException {
+               
+               int commentAreaStart = commentArea.getOffset();
+               int commentAreaEnd = commentArea.getOffset() + commentArea.getLength();
+               
+               String commentStartTag = getCommentStart(); // "/*"
+               String commentEndTag   = getCommentEnd();   // "*/"
+               
+               String startLineEOL = doc.getLineDelimiter(doc.getLineOfOffset(commentAreaStart));
+               if (startLineEOL==null) startLineEOL=""; //$NON-NLS-1$
+               String endLineEOL = doc.getLineDelimiter(doc.getLineOfOffset(commentAreaEnd-1));
+               if (endLineEOL==null) endLineEOL=""; //$NON-NLS-1$
+               
+               boolean isLeftEol = commentAreaStart<startLineEOL.length()
+                       || doc.get(commentAreaStart-startLineEOL.length(),startLineEOL.length()).equals(startLineEOL);
+               boolean isRightEol = doc.get(commentAreaEnd-endLineEOL.length(),endLineEOL.length()).equals(endLineEOL);
+               
+               if (isLeftEol && isRightEol) {
+                       // Block of full lines found
+                       int areaStartLine = doc.getLineOfOffset(commentAreaStart+startLineEOL.length());
+                       int areaEndLine = doc.getLineOfOffset(commentAreaEnd-endLineEOL.length());
+                       if (areaStartLine!=areaEndLine) {
+                               // If multiple full lines arrange inserting comment tags on their own lines
+                               commentStartTag = getCommentStart()+startLineEOL;
+                               commentEndTag   = getCommentEnd()+endLineEOL;
+                       } else {
+                               // If one full line insert end comment tag on the same line (before the EOL)
+                               commentAreaEnd = commentAreaEnd-endLineEOL.length();
+                       }
+               } else {
+                       if (lastPartition.getType() == ICPartitions.C_SINGLE_LINE_COMMENT
+                                       || lastPartition.getType() == ICPartitions.C_SINGLE_LINE_DOC_COMMENT) {
+                               // C++ comments "//" partition ends with EOL, insert end comment tag before it
+                               // on the same line, so we get something like /*// text*/
+                               commentAreaEnd = commentAreaEnd-endLineEOL.length();
+                       }
+               }
+               
+               edits.add(factory.createEdit(commentAreaStart, 0, commentStartTag));
+               edits.add(factory.createEdit(commentAreaEnd, 0, commentEndTag));
+               
+               return new Region(commentAreaStart,commentAreaEnd-commentAreaStart);
+       }
+
+       /**
+        * Make all inside partitions join in one comment, in particular remove
+        * all enclosing comment tokens of the inside partitions.
+        * 
+        * @param commentArea comment area region
+        * @param partition first partition
+        * @param docExtension document
+        * @param factory EditFactory
+        * @param List of edits to update the document
+        * @throws BadLocationException
+        * @throws BadPartitioningException
+        */
+       private void handleInteriorPartition(IRegion commentArea,
+                       ITypedRegion partition, IDocumentExtension3 docExtension,
+                       Edit.EditFactory factory, List<Edit> edits)
+                       throws BadLocationException, BadPartitioningException {
+               
+               int commentAreaEnd = commentArea.getOffset() + commentArea.getLength();
+               int prevPartitionEnd = -1;
+               int partitionEnd = partition.getOffset()+partition.getLength();
+               
+               final int startCommentTokenLength = getCommentStart().length();
+               final int endCommentTokenLength = getCommentEnd().length();
+               
+               while (partitionEnd<=commentAreaEnd) {
+                       if (partition.getType() == ICPartitions.C_MULTI_LINE_COMMENT
+                                       || partition.getType() == ICPartitions.C_MULTI_LINE_DOC_COMMENT) {      
+                               // already in a comment - remove start/end tokens
+                               edits.add(factory.createEdit(partition.getOffset(), startCommentTokenLength, "")); //$NON-NLS-1$
+                               edits.add(factory.createEdit(partitionEnd - endCommentTokenLength, endCommentTokenLength, "")); //$NON-NLS-1$   
+                       }
+                       // advance to next partition
+                       prevPartitionEnd = partitionEnd;
+                       partition= docExtension.getPartition(ICPartitions.C_PARTITIONING, partitionEnd, false);
+                       partitionEnd = partition.getOffset() + partition.getLength();
+                       
+                       // break the loop if we get stuck and no advance was made
+                       if (partitionEnd<=prevPartitionEnd) break;
+               }
+       }
+
+       /**
+        * Returns whether <code>partType</code> is special, i.e. a <code>String</code>,
+        * <code>Character</code>, or <code>Comment</code> partition.
+        * 
+        * @param partType the partition type to check
+        * @return <code>true</code> if <code>partType</code> is special, <code>false</code> otherwise
+        */
+       private boolean isSpecialPartition(String partType) {
+               return partType != IDocument.DEFAULT_CONTENT_TYPE;
+       }
+
+       @Override
+       protected boolean isValidSelection(ITextSelection selection) {
+               return selection != null && !selection.isEmpty() && selection.getLength() > 0;
+       }
+
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/BlockCommentAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/BlockCommentAction.java
new file mode 100644 (file)
index 0000000..726b84d
--- /dev/null
@@ -0,0 +1,330 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.actions;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.ResourceBundle;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.BadPartitioningException;
+import org.eclipse.jface.text.BadPositionCategoryException;
+import org.eclipse.jface.text.DefaultPositionUpdater;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentExtension3;
+import org.eclipse.jface.text.IPositionUpdater;
+import org.eclipse.jface.text.IRewriteTarget;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.ITextEditorExtension2;
+import org.eclipse.ui.texteditor.TextEditorAction;
+
+/**
+ * Common block comment code.
+ * 
+ * @since 3.0
+ */
+public abstract class BlockCommentAction extends TextEditorAction {
+       /**
+        * Creates a new instance.
+        * @param bundle
+        * @param prefix
+        * @param editor
+        */
+       public BlockCommentAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
+               super(bundle, prefix, editor);
+       }
+
+       /**
+        * An edit is a kind of <code>DocumentEvent</code>, in this case an edit instruction, that is 
+        * affiliated with a <code>Position</code> on a document. The offset of the document event is 
+        * not stored statically, but taken from the affiliated <code>Position</code>, which gets 
+        * updated when other edits occur.
+        */
+       static class Edit extends DocumentEvent {
+               
+               /**
+                * Factory for edits which manages the creation, installation and destruction of 
+                * position categories, position updaters etc. on a certain document. Once a factory has
+                * been obtained, <code>Edit</code> objects can be obtained from it which will be linked to
+                * the document by positions of one position category.
+                * <p>Clients are required to call <code>release</code> once the <code>Edit</code>s are not
+                * used any more, so the positions can be discarded.</p>
+                */
+               public static class EditFactory {
+       
+                       /** The position category basename for this edits. */
+                       private static final String CATEGORY= "__positionalEditPositionCategory"; //$NON-NLS-1$
+                       
+                       /** The count of factories. */
+                       private static int fgCount= 0;
+               
+                       /** This factory's category. */
+                       private final String fCategory;
+                       private IDocument fDocument;
+                       private IPositionUpdater fUpdater;
+                       
+                       /**
+                        * Creates a new <code>EditFactory</code> with an unambiguous position category name.
+                        * @param document the document that is being edited.
+                        */
+                       public EditFactory(IDocument document) {
+                               fCategory= CATEGORY + fgCount++;
+                               fDocument= document;
+                       }
+                       
+                       /**
+                        * Creates a new edition on the document of this factory.
+                        * 
+                        * @param offset the offset of the edition at the point when is created.
+                        * @param length the length of the edition (not updated via the position update mechanism)
+                        * @param text the text to be replaced on the document
+                        * @return an <code>Edit</code> reflecting the edition on the document
+                        */
+                       public Edit createEdit(int offset, int length, String text) throws BadLocationException {
+                               
+                               if (!fDocument.containsPositionCategory(fCategory)) {
+                                       fDocument.addPositionCategory(fCategory);
+                                       fUpdater= new DefaultPositionUpdater(fCategory);
+                                       fDocument.addPositionUpdater(fUpdater);
+                               }
+                               
+                               Position position= new Position(offset);
+                               try {
+                                       fDocument.addPosition(fCategory, position);
+                               } catch (BadPositionCategoryException e) {
+                                       Assert.isTrue(false);
+                               }
+                               return new Edit(fDocument, length, text, position);
+                       }
+                       
+                       /**
+                        * Releases the position category on the document and uninstalls the position updater. 
+                        * <code>Edit</code>s managed by this factory are not updated after this call.
+                        */
+                       public void release() {
+                               if (fDocument != null && fDocument.containsPositionCategory(fCategory)) {
+                                       fDocument.removePositionUpdater(fUpdater);
+                                       try {
+                                               fDocument.removePositionCategory(fCategory);
+                                       } catch (BadPositionCategoryException e) {
+                                               Assert.isTrue(false);
+                                       }
+                                       fDocument= null;
+                                       fUpdater= null;
+                               }
+                       }
+               }
+               
+               /** The position in the document where this edit be executed. */
+               private Position fPosition;
+               
+               /**
+                * Creates a new edition on <code>document</code>, taking its offset from <code>position</code>.
+                * 
+                * @param document the document being edited
+                * @param length the length of the edition
+                * @param text the replacement text of the edition
+                * @param position the position keeping the edition's offset
+                */
+               protected Edit(IDocument document, int length, String text, Position position) {
+                       super(document, 0, length, text);
+                       fPosition= position;
+               }
+               
+               /*
+                * @see org.eclipse.jface.text.DocumentEvent#getOffset()
+                */
+               @Override
+               public int getOffset() {
+                       return fPosition.getOffset();
+               }
+               
+               /**
+                * Executes the edition on document. The offset is taken from the position.
+                * 
+                * @throws BadLocationException if the execution of the document fails.
+                */
+               public void perform() throws BadLocationException {
+                       getDocument().replace(getOffset(), getLength(), getText());
+               }
+               
+       }
+
+       @Override
+       public void run() {
+               if (!isEnabled())
+                       return;
+                       
+               ITextEditor editor= getTextEditor();
+               if (editor == null || !ensureEditable(editor))
+                       return;
+                       
+               ITextSelection selection= getCurrentSelection();
+               if (!isValidSelection(selection))
+                       return;
+               
+               if (!validateEditorInputState())
+                       return;
+               
+               IDocumentProvider docProvider= editor.getDocumentProvider();
+               IEditorInput input= editor.getEditorInput();
+               if (docProvider == null || input == null)
+                       return;
+                       
+               IDocument document= docProvider.getDocument(input);
+               if (document == null)
+                       return;
+                       
+               IDocumentExtension3 docExtension;
+               if (document instanceof IDocumentExtension3)
+                       docExtension= (IDocumentExtension3) document;
+               else
+                       return;
+               
+               IRewriteTarget target= (IRewriteTarget)editor.getAdapter(IRewriteTarget.class);
+               if (target != null) {
+                       target.beginCompoundChange();
+               }
+               
+               Edit.EditFactory factory= new Edit.EditFactory(document);
+               
+               try {
+                       runInternal(selection, docExtension, factory);
+       
+               } catch (BadLocationException e) {
+                       // can happen on concurrent modification, deletion etc. of the document 
+                       // -> don't complain, just bail out
+               } catch (BadPartitioningException e) {
+                       // should not happen
+                       Assert.isTrue(false, "bad partitioning");  //$NON-NLS-1$
+               } finally {
+                       factory.release();
+                       
+                       if (target != null) {
+                               target.endCompoundChange();
+                       }
+               }
+       }
+
+       /**
+        * Calls <code>perform</code> on all <code>Edit</code>s in <code>edits</code>.
+        * 
+        * @param edits a list of <code>Edit</code>s
+        * @throws BadLocationException if an <code>Edit</code> threw such an exception.
+        */
+       protected void executeEdits(List<Edit> edits) throws BadLocationException {
+               for (Iterator<Edit> it= edits.iterator(); it.hasNext();) {
+                       Edit edit= it.next();
+                       edit.perform();
+               }
+       }
+
+       /**
+        * Ensures that the editor is modifyable. If the editor is an instance of
+        * <code>ITextEditorExtension2</code>, its <code>validateEditorInputState</code> method 
+        * is called, otherwise, the result of <code>isEditable</code> is returned.
+        * 
+        * @param editor the editor to be checked
+        * @return <code>true</code> if the editor is editable, <code>false</code> otherwise
+        */
+       protected boolean ensureEditable(ITextEditor editor) {
+               Assert.isNotNull(editor);
+       
+               if (editor instanceof ITextEditorExtension2) {
+                       ITextEditorExtension2 ext= (ITextEditorExtension2) editor;
+                       return ext.validateEditorInputState();
+               }
+               
+               return editor.isEditable();
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.IUpdate#update()
+        */
+       @Override
+       public void update() {
+               super.update();
+               
+               if (isEnabled()) {
+                       if (!canModifyEditor() || !isValidSelection(getCurrentSelection()))
+                               setEnabled(false);
+               }
+       }
+
+       /**
+        * Returns the editor's selection, or <code>null</code> if no selection can be obtained or the 
+        * editor is <code>null</code>.
+        * 
+        * @return the selection of the action's editor, or <code>null</code>
+        */
+       protected ITextSelection getCurrentSelection() {
+               ITextEditor editor= getTextEditor();
+               if (editor != null) {
+                       ISelectionProvider provider= editor.getSelectionProvider();
+                       if (provider != null) {
+                               ISelection selection= provider.getSelection();
+                               if (selection instanceof ITextSelection) 
+                                       return (ITextSelection) selection;
+                       }
+               }
+               return null;
+       }
+
+       /**
+        * Runs the real command once all the editor, document, and selection checks have succeeded.
+        * 
+        * @param selection the current selection we are being called for
+        * @param docExtension the document extension where we get the partitioning from
+        * @param factory the edit factory we can use to create <code>Edit</code>s 
+        * @throws BadLocationException if an edition fails
+        * @throws BadPartitioningException if a partitioning call fails
+        */
+       protected abstract void runInternal(ITextSelection selection, IDocumentExtension3 docExtension, Edit.EditFactory factory) throws BadLocationException, BadPartitioningException;
+
+       /**
+        * Checks whether <code>selection</code> is valid.
+        * 
+        * @param selection the selection to check
+        * @return <code>true</code> if the selection is valid, <code>false</code> otherwise
+        */
+       protected abstract boolean isValidSelection(ITextSelection selection);
+
+       /**
+        * Returns the text to be inserted at the selection start.
+        * 
+        * @return the text to be inserted at the selection start
+        */
+       protected String getCommentStart() {
+               // for now: no space story
+               return "/*"; //$NON-NLS-1$
+       }
+
+       /**
+        * Returns the text to be inserted at the selection end.
+        * 
+        * @return the text to be inserted at the selection end
+        */
+       protected String getCommentEnd() {
+               // for now: no space story
+               return "*/"; //$NON-NLS-1$
+       }
+
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CDTQuickMenuCreator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CDTQuickMenuCreator.java
new file mode 100644 (file)
index 0000000..1b33aa4
--- /dev/null
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems) - Ported to CDT
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.actions;
+
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.graphics.Point;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.ITextViewerExtension5;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.source.ISourceViewer;
+
+import org.eclipse.ui.actions.QuickMenuCreator;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.text.CWordFinder;
+
+/**
+ * C/C++ editor aware quick menu creator. In the given editor, the menu will be aligned with the word
+ * at the current offset.
+ * 
+ * @since 5.2
+ */
+public abstract class CDTQuickMenuCreator extends QuickMenuCreator {
+
+       private final CEditor fEditor;
+
+       /**
+        * Create a CDT quick menu creator
+        * @param editor a Java editor, or <code>null</code> if none
+        */
+       public CDTQuickMenuCreator(CEditor editor) {
+               fEditor= editor;
+       }
+
+       @Override
+       protected Point computeMenuLocation(StyledText text) {
+               if (fEditor == null || text != fEditor.getViewer().getTextWidget())
+                       return super.computeMenuLocation(text);
+               return computeWordStart();
+       }
+
+       private Point computeWordStart() {
+               ITextSelection selection= (ITextSelection)fEditor.getSelectionProvider().getSelection();
+               IRegion textRegion= CWordFinder.findWord(fEditor.getViewer().getDocument(), selection.getOffset());
+               if (textRegion == null)
+                       return null;
+
+               IRegion widgetRegion= modelRange2WidgetRange(textRegion);
+               if (widgetRegion == null)
+                       return null;
+
+               int start= widgetRegion.getOffset();
+
+               StyledText styledText= fEditor.getViewer().getTextWidget();
+               Point result= styledText.getLocationAtOffset(start);
+               result.y+= styledText.getLineHeight(start);
+
+               if (!styledText.getClientArea().contains(result))
+                       return null;
+               return result;
+       }
+
+       private IRegion modelRange2WidgetRange(IRegion region) {
+               ISourceViewer viewer= fEditor.getViewer();
+               if (viewer instanceof ITextViewerExtension5) {
+                       ITextViewerExtension5 extension= (ITextViewerExtension5)viewer;
+                       return extension.modelRange2WidgetRange(region);
+               }
+
+               IRegion visibleRegion= viewer.getVisibleRegion();
+               int start= region.getOffset() - visibleRegion.getOffset();
+               int end= start + region.getLength();
+               if (end > visibleRegion.getLength())
+                       end= visibleRegion.getLength();
+
+               return new Region(start, end - start);
+       }
+
+       /**
+        * Returns a handler that can create and open the quick menu.
+        * 
+        * @return a handler that can create and open the quick menu
+        */
+       public IHandler createHandler() {
+               return new AbstractHandler() {
+                       public Object execute(ExecutionEvent event) throws ExecutionException {
+                               createMenu();
+                               return null;
+                       }
+               };
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CompositeActionGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CompositeActionGroup.java
new file mode 100644 (file)
index 0000000..916a0b9
--- /dev/null
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.actions;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.core.runtime.Assert;
+
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.actions.ActionGroup;
+
+public class CompositeActionGroup extends ActionGroup {
+
+       private ActionGroup[] fGroups;
+       
+       public CompositeActionGroup() {
+       }
+       
+       public CompositeActionGroup(ActionGroup[] groups) {
+               setGroups(groups);
+       }
+
+       protected void setGroups(ActionGroup[] groups) {
+               Assert.isTrue(fGroups == null);
+               Assert.isNotNull(groups);
+               fGroups= groups;                
+       }
+               
+       public ActionGroup get(int index) {
+               if (fGroups == null)
+                       return null;
+               return fGroups[index];
+       }
+       
+       public void addGroup(ActionGroup group) {
+               if (fGroups == null) {
+                       fGroups= new ActionGroup[] { group };
+               } else {
+                       ActionGroup[] newGroups= new ActionGroup[fGroups.length + 1];
+                       System.arraycopy(fGroups, 0, newGroups, 0, fGroups.length);
+                       newGroups[fGroups.length]= group;
+                       fGroups= newGroups;
+               }
+       }
+       
+       @Override
+       public void dispose() {
+               super.dispose();
+               if (fGroups == null)
+                       return;
+               for (int i= 0; i < fGroups.length; i++) {
+                       fGroups[i].dispose();
+               }
+       }
+
+       @Override
+       public void fillActionBars(IActionBars actionBars) {
+               super.fillActionBars(actionBars);
+               if (fGroups == null)
+                       return;
+               for (int i= 0; i < fGroups.length; i++) {
+                       fGroups[i].fillActionBars(actionBars);
+               }
+       }
+
+       @Override
+       public void fillContextMenu(IMenuManager menu) {
+               super.fillContextMenu(menu);
+               if (fGroups == null)
+                       return;
+               for (int i= 0; i < fGroups.length; i++) {
+                       fGroups[i].fillContextMenu(menu);
+               }
+       }
+
+       @Override
+       public void setContext(ActionContext context) {
+               super.setContext(context);
+               if (fGroups == null)
+                       return;
+               for (int i= 0; i < fGroups.length; i++) {
+                       fGroups[i].setContext(context);
+               }
+       }
+
+       @Override
+       public void updateActionBars() {
+               super.updateActionBars();
+               if (fGroups == null)
+                       return;
+               for (int i= 0; i < fGroups.length; i++) {
+                       fGroups[i].updateActionBars();
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CopyTreeAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CopyTreeAction.java
new file mode 100644 (file)
index 0000000..6410045
--- /dev/null
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
+ *   Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.actions;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.osgi.util.TextProcessor;
+import org.eclipse.swt.SWTError;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.part.ViewPart;
+
+import org.eclipse.cdt.internal.ui.util.SelectionUtil;
+
+/**
+ * Copies contents of a TreeViewer to the clipboard.
+ */
+public class CopyTreeAction extends Action {
+       private static final char INDENTATION= '\t';
+
+       private ViewPart fView;
+       private TreeViewer fViewer;
+
+       public CopyTreeAction(String label, ViewPart view, TreeViewer viewer) {
+               super(label);
+               fView= view;
+               fViewer= viewer;
+       }
+
+       public boolean canActionBeAdded() {
+               Object element= SelectionUtil.getSingleElement(getSelection());
+               return element != null;
+       }
+
+       private ISelection getSelection() {
+               ISelectionProvider provider= fView.getSite().getSelectionProvider();
+
+               if (provider != null) {
+                       return provider.getSelection();
+               }
+
+               return null;
+       }
+
+       /*
+        * @see IAction#run()
+        */
+       @Override
+       public void run() {
+               StringBuilder buf= new StringBuilder();
+               addChildren(fViewer.getTree().getSelection()[0], 0, buf);
+
+               TextTransfer plainTextTransfer= TextTransfer.getInstance();
+               Clipboard clipboard= new Clipboard(fView.getSite().getShell().getDisplay());
+               try {
+                       clipboard.setContents(
+                                       new String[] { convertLineTerminators(buf.toString()) },
+                                       new Transfer[] { plainTextTransfer });
+               } catch (SWTError e) {
+                       if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD)
+                               throw e;
+                       if (MessageDialog.openQuestion(fView.getViewSite().getShell(),
+                                       ActionMessages.CopyTreeAction_problem, ActionMessages.CopyTreeAction_clipboard_busy)) {
+                               run();
+                       }
+               } finally {
+                       clipboard.dispose();
+               }
+       }
+
+       /**
+        * Adds the specified {@link TreeItem}'s text to the StringBuilder.
+        * 
+        * @param item the tree item
+        * @param indent the indent size
+        * @param buf the string buffer
+        */
+       private void addChildren(TreeItem item, int indent, StringBuilder buf) {
+               for (int i= 0; i < indent; i++) {
+                       buf.append(INDENTATION);
+               }
+
+               buf.append(TextProcessor.deprocess(item.getText()));
+               buf.append('\n');
+
+               if (item.getExpanded()) {
+                       TreeItem[] items= item.getItems();
+                       for (TreeItem item2 : items) {
+                               addChildren(item2, indent + 1, buf);
+                       }
+               }
+       }
+
+       static String convertLineTerminators(String in) {
+               StringWriter stringWriter= new StringWriter();
+               PrintWriter printWriter= new PrintWriter(stringWriter);
+               StringReader stringReader= new StringReader(in);
+               BufferedReader bufferedReader= new BufferedReader(stringReader);
+               try {
+                       String line= bufferedReader.readLine();
+                       while (line != null) {
+                               printWriter.print(line);
+                               line= bufferedReader.readLine();
+                               if (line != null && line.length() != 0)
+                                       printWriter.println();
+
+                       }
+               } catch (IOException e) {
+                       return in; // return the call hierarchy unfiltered
+               }
+               return stringWriter.toString();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java
new file mode 100644 (file)
index 0000000..bd047e2
--- /dev/null
@@ -0,0 +1,383 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.actions;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.SortedMap;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+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.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartSite;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTProblem;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IProblemBinding;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexFile;
+import org.eclipse.cdt.core.index.IIndexFileLocation;
+import org.eclipse.cdt.core.index.IIndexInclude;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.parser.ExtendedScannerInfo;
+import org.eclipse.cdt.core.parser.IScannerInfoProvider;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.model.ASTCache;
+import org.eclipse.cdt.internal.core.model.TranslationUnit;
+import org.eclipse.cdt.internal.core.pdom.ASTFilePathResolver;
+import org.eclipse.cdt.internal.core.pdom.PDOM;
+import org.eclipse.cdt.internal.core.pdom.indexer.ProjectIndexerInputAdapter;
+
+import org.eclipse.cdt.internal.ui.editor.ASTProvider;
+
+@SuppressWarnings("nls")
+public class CreateParserLogAction implements IObjectActionDelegate {
+
+       private static final class MyVisitor extends ASTVisitor {
+               List<IASTProblem> fProblems= new ArrayList<IASTProblem>();
+               List<IProblemBinding> fProblemBindings= new ArrayList<IProblemBinding>();
+               List<Exception> fExceptions= new ArrayList<Exception>();
+
+               MyVisitor() {
+                       shouldVisitProblems= true;
+                       shouldVisitNames= true;
+               }
+
+               @Override
+               public int visit(IASTProblem problem) {
+                       fProblems.add(problem);
+                       return PROCESS_SKIP;
+               }
+               
+               @Override
+               public int visit(IASTName name) {
+                       if (name instanceof ICPPASTQualifiedName) {
+                               return PROCESS_CONTINUE;
+                       }
+                       try {
+                               IBinding binding= name.resolveBinding();
+                               if (binding instanceof IProblemBinding) {
+                                       fProblemBindings.add((IProblemBinding) binding);
+                               }
+                       } catch (RuntimeException e) {
+                               fExceptions.add(e);
+                       }
+                       return PROCESS_CONTINUE;
+               }
+       }
+
+       private static final Comparator<String> COMP_INSENSITIVE= new Comparator<String> () {
+               public int compare(String o1, String o2) {
+                       return o1.toUpperCase().compareTo(o2.toUpperCase());
+               }
+       };
+
+       private ISelection fSelection;
+       private IWorkbenchPartSite fSite;
+       
+       public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+               fSite= targetPart.getSite();
+       }
+
+       public void selectionChanged(IAction action, ISelection selection) {
+               fSelection = selection;
+       }
+
+       public void run(IAction action) {
+               if (!(fSelection instanceof IStructuredSelection))
+                       return;
+               
+               final String title= action.getText().replace("&", "");  
+               IStructuredSelection cElements= SelectionConverter.convertSelectionToCElements(fSelection);
+               Iterator<?> i= cElements.iterator();
+               ArrayList<ITranslationUnit> tuSelection= new ArrayList<ITranslationUnit>();
+               while (i.hasNext()) {
+                       Object o= i.next();
+                       if (o instanceof ITranslationUnit) {
+                               tuSelection.add((ITranslationUnit) o);
+                       }
+               }
+               ITranslationUnit[] tuArray= tuSelection.toArray(new ITranslationUnit[tuSelection.size()]);
+               if (tuArray.length == 0) {
+                       return;
+               }
+               FileDialog dlg= new FileDialog(fSite.getShell(), SWT.SAVE);
+               dlg.setText(title);
+               dlg.setFilterExtensions(new String[]{"*.log"});  
+               String path= null;
+               while(path == null) {
+                       path= dlg.open();
+                       if (path == null)
+                               return;
+
+                       File file= new File(path);              
+                       if (file.exists()) {
+                               if (!file.canWrite()) {
+                                       final String msg= NLS.bind(ActionMessages.CreateParserLogAction_readOnlyFile, path); 
+                                       MessageDialog.openError(fSite.getShell(), title, msg);
+                                       path= null;
+                               }
+                               else {
+                                       final String msg = NLS.bind(ActionMessages.CreateParserLogAction_existingFile, path); 
+                                       if (!MessageDialog.openQuestion(fSite.getShell(), title, msg)) {
+                                               path= null;
+                                       }
+                               }
+                       }
+               }
+               
+               try {
+                       PrintStream out= new PrintStream(path);
+                       try {
+                               boolean needsep= false;
+                               for (ITranslationUnit tu : tuArray) {
+                                       if (needsep) {
+                                               out.println(); out.println(); 
+                                       }
+                                       createLog(out, tu, new NullProgressMonitor());
+                                       needsep= true;
+                               }
+                       }
+                       finally {
+                               out.close();
+                       }
+               } catch (IOException e) {
+                       MessageDialog.openError(fSite.getShell(), action.getText(), e.getMessage());
+               }
+       }
+
+       private void createLog(final PrintStream out, final ITranslationUnit tu, IProgressMonitor pm) {
+               try {
+                       tu.open(pm);
+               } catch (CModelException e) {
+                       CUIPlugin.log(e);
+               }
+               ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_IF_OPEN, pm, new ASTCache.ASTRunnable() {
+                       public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
+                               if (ast != null)
+                                       return createLog(out, tu, lang, ast);
+                               return Status.CANCEL_STATUS;
+                       }
+               });
+       }
+
+       protected IStatus createLog(PrintStream out, ITranslationUnit tu, ILanguage lang, IASTTranslationUnit ast) {
+               IStatus status = Status.OK_STATUS;
+               final ICProject cproject = tu.getCProject();
+               final String projectName= cproject == null ? null : cproject.getElementName();
+               String scannerInfoProvider= "null";
+               if (cproject != null) {
+                       IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(cproject.getProject());
+                       if (provider != null) {
+                               scannerInfoProvider= provider.getClass().getName();
+                       }
+               }       
+               
+               ITranslationUnit ctx= tu;
+               if (tu instanceof TranslationUnit) {
+                       TranslationUnit itu= (TranslationUnit) tu;
+                       ctx= itu.getSourceContextTU(ast.getIndex(), ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT);
+               }
+               final ExtendedScannerInfo scfg= new ExtendedScannerInfo(ctx.getScannerInfo(true));
+               final String indent= "   "; 
+               final MyVisitor visitor= new MyVisitor();
+               ast.accept(visitor);
+               
+               out.println("Project:               " + projectName); 
+               out.println("Index Version:         " + PDOM.versionString(PDOM.getDefaultVersion())); 
+               out.println("Scanner Info Provider: " + scannerInfoProvider);
+               out.println("Build Configuration:   " + getBuildConfig(cproject));
+               out.println("File:      " + tu.getLocationURI()); 
+               out.println("Context:   " + ctx.getLocationURI()); 
+               out.println("Language:  " + lang.getName()); 
+               out.println();
+               out.println("Include Search Path (option -I):");  
+               output(out, indent, scfg.getIncludePaths());
+               out.println();
+               out.println("Local Include Search Path (option -iquote):"); 
+               output(out, indent, scfg.getLocalIncludePath());
+               out.println();
+               out.println("Preincluded files (option -include):"); 
+               output(out, indent, scfg.getIncludeFiles());
+               out.println();
+               out.println("Preincluded macro files (option -imacros):"); 
+               output(out, indent, scfg.getMacroFiles());
+               out.println();
+               out.println("Macro definitions (option -D):"); 
+               HashSet<String> reported= new HashSet<String>();
+               output(out, indent, scfg.getDefinedSymbols(), reported);
+               out.println();
+               out.println("Macro definitions (from configuration + headers in index):"); 
+               output(out, indent, ast.getBuiltinMacroDefinitions(), reported);
+               out.println();
+               out.println("Macro definitions (from files actually parsed):"); 
+               output(out, indent, ast.getMacroDefinitions(), reported);
+
+               out.println();
+               out.println("Unresolved includes (from headers in index):"); 
+               try {
+                       outputUnresolvedIncludes(cproject, ast.getIndex(), out, indent, ast.getIncludeDirectives(), ast.getLinkage().getLinkageID());
+               } catch (CoreException e) {
+                       status= e.getStatus();
+               }
+               
+               out.println();
+               out.println("Scanner problems:"); 
+               output(out, indent, ast.getPreprocessorProblems());
+
+               out.println();
+               out.println("Parser problems:"); 
+               output(out, indent, visitor.fProblems.toArray(new IASTProblem[visitor.fProblems.size()]));
+               
+               out.println();
+               out.println("Unresolved names:"); 
+               output(out, indent, visitor.fProblemBindings);
+
+               out.println();
+               out.println("Exceptions in name resolution:"); 
+               output(out, visitor.fExceptions);
+
+               return status;
+       }
+
+       private String getBuildConfig(ICProject cproject) {
+       ICProjectDescriptionManager prjDescMgr= CCorePlugin.getDefault().getProjectDescriptionManager();
+       ICProjectDescription prefs= prjDescMgr.getProjectDescription(cproject.getProject(), false);
+       if (prefs != null) {
+               ICConfigurationDescription cfg= prefs.getDefaultSettingConfiguration();
+               if (cfg != null) 
+                       return cfg.getName();
+       }
+       return "unknown";
+       }
+
+       private void outputUnresolvedIncludes(ICProject prj, IIndex index, PrintStream out, String indent, 
+                       IASTPreprocessorIncludeStatement[] includeDirectives, int linkageID) throws CoreException {
+               ASTFilePathResolver resolver= new ProjectIndexerInputAdapter(prj);
+               HashSet<IIndexFileLocation> handled= new HashSet<IIndexFileLocation>();
+               for (IASTPreprocessorIncludeStatement include : includeDirectives) {
+                       if (include.isActive() && include.isResolved()) {
+                               outputUnresolvedIncludes(index, out, indent, resolver.resolveASTPath(include.getPath()), linkageID, handled);
+                       }
+               }
+       }
+
+       private void outputUnresolvedIncludes(IIndex index, PrintStream out, String indent, 
+                       IIndexFileLocation ifl, int linkageID, HashSet<IIndexFileLocation> handled) throws CoreException {
+               if (!handled.add(ifl)) {
+                       return;
+               }
+               IIndexFile ifile= index.getFile(linkageID, ifl);
+               if (ifile == null) {
+                       out.println(indent + ifl.getURI() + " is not indexed"); 
+               }
+               else {
+                       IIndexInclude[] includes = ifile.getIncludes();
+                       for (IIndexInclude inc : includes) {
+                               if (inc.isActive()) {
+                                       if (inc.isResolved()) {
+                                               outputUnresolvedIncludes(index, out, indent, inc.getIncludesLocation(), linkageID, handled);
+                                       }
+                                       else {
+                                               out.println(indent + "Unresolved inclusion: " + inc.getFullName() + " in file " +  
+                                                               inc.getIncludedByLocation().getURI());
+                                       }
+                               }
+                       }
+               }
+       }
+
+       private void output(PrintStream out, String indent, String[] list) {
+               for (String line : list) {
+                       out.println(indent + line);
+               }
+       }
+
+       private void output(PrintStream out, String indent, Map<String, String> definedSymbols, HashSet<String> reported) {
+               SortedMap<String, String> sorted= new TreeMap<String, String>(COMP_INSENSITIVE);
+               sorted.putAll(definedSymbols);
+               for (Entry<String, String> entry : sorted.entrySet()) {
+                       final String macro = entry.getKey() + '=' + entry.getValue();
+                       if (reported.add(macro)) {
+                               out.println(indent + macro);
+                       }
+               }
+       }
+       
+       private void output(PrintStream out, String indent,     IASTPreprocessorMacroDefinition[] defs, HashSet<String> reported) {
+               SortedSet<String> macros= new TreeSet<String>(COMP_INSENSITIVE);
+               for (IASTPreprocessorMacroDefinition def : defs) {
+                       macros.add(def.toString());
+               }
+               
+               for (String macro : macros) {
+                       if (reported.add(macro)) {
+                               out.println(indent + macro);
+                       }
+               }
+       }
+       
+       private void output(PrintStream out, String indent,     IASTProblem[] preprocessorProblems) {
+               for (IASTProblem problem : preprocessorProblems) {
+                       out.println(indent + problem.getMessageWithLocation());
+               }
+       }
+       
+       private void output(PrintStream out, String indent, List<IProblemBinding> list) {
+               for (IProblemBinding problem : list) {
+               String file= problem.getFileName();
+               int line = problem.getLineNumber();
+                       out.println(indent + problem.getMessage() + " in file " + file + ':' + line); 
+               }
+       }
+
+       private void output(PrintStream out, List<Exception> list) {
+               for (Exception problem : list) {
+                       problem.printStackTrace(out);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/DeleteResConfigsHandler.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/DeleteResConfigsHandler.java
new file mode 100644 (file)
index 0000000..0f3322c
--- /dev/null
@@ -0,0 +1,235 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *     Nokia - converted from action to handler
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.actions;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.ISources;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ListSelectionDialog;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+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.ITranslationUnit;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.newui.AbstractPage;
+
+
+
+/**
+ * Handler for command that deletes resource description. (If resource description is missing
+ * one from parent is normally used)
+ */
+public class DeleteResConfigsHandler extends AbstractHandler {
+
+       protected ArrayList<IResource> objects;
+       private   ArrayList<ResCfgData> outData;                
+
+       @Override
+       public void setEnabled(Object context) {
+               ISelection selection = getSelection(context);
+               setEnabledFromSelection(selection);
+       }
+       
+       protected ISelection getSelection(Object context) {
+               Object s = HandlerUtil.getVariable(context, ISources.ACTIVE_MENU_SELECTION_NAME);
+        if (s instanceof ISelection) {
+               return (ISelection) s;
+        }
+           return null;
+       }
+
+       public void setEnabledFromSelection(ISelection selection) {
+               objects = null;
+               
+               if ((selection != null) && !selection.isEmpty()) {
+                       // case for context menu
+                       Object[] obs = null;
+                       if (selection instanceof IStructuredSelection) {
+                               obs = ((IStructuredSelection)selection).toArray();
+                       }
+                       else if (selection instanceof ITextSelection) {
+                               IFile file = getFileFromActiveEditor();
+                               if (file != null)
+                                       obs = Collections.singletonList(file).toArray();
+                       }
+                       if (obs != null && obs.length > 0) {
+                               for (int i=0; i<obs.length; i++) {
+                                       IResource res = null;
+                                       // only folders and files may be affected by this action
+                                       if (obs[i] instanceof ICContainer || obs[i] instanceof ITranslationUnit)
+                                               res = ((ICElement)obs[i]).getResource();
+                                       // project's configuration cannot be deleted
+                                       else if (obs[i] instanceof IResource && !(obs[i] instanceof IProject))
+                                               res = (IResource)obs[i];
+                                       if (res != null) {
+                                               IProject p = res.getProject();
+                                               if (!p.isOpen()) continue;
+                                               
+                                               if (!CoreModel.getDefault().isNewStyleProject(p))
+                                                       continue;
+       
+                                               IPath path = res.getProjectRelativePath();
+                                               // getting description in read-only mode
+                                               ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false);
+                                               if (prjd == null) continue;
+                                               ICConfigurationDescription[] cfgds = prjd.getConfigurations();
+                                               if (cfgds == null || cfgds.length == 0) continue;
+                                               for (ICConfigurationDescription cfgd : cfgds) {
+                                                       ICResourceDescription rd = cfgd.getResourceDescription(path, true);
+                                                       if (rd != null) {
+                                                               if (objects == null) objects = new ArrayList<IResource>();
+                                                               objects.add(res);
+                                                               break; // stop configurations scanning
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               } 
+               setBaseEnabled(objects != null);
+       }
+
+       private IFile getFileFromActiveEditor() {
+               IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+               if (window != null) {
+                       IWorkbenchPage page = window.getActivePage();
+                       if (page != null) {
+                               IEditorPart editor = page.getActiveEditor();
+                               if (editor != null) {
+                                       IEditorInput input = editor.getEditorInput();
+                                       if (input != null)
+                                               return (IFile) input.getAdapter(IFile.class);
+                               }
+                       }
+               }
+               return null;
+       }
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               openDialog();
+               return null;
+       }
+
+       private void openDialog() {
+               if (objects == null || objects.size() == 0) return; 
+               // create list of configurations to delete
+               
+               ListSelectionDialog dialog = new ListSelectionDialog(
+                               CUIPlugin.getActiveWorkbenchShell(), 
+                               objects, 
+                               createSelectionDialogContentProvider(), 
+                               new LabelProvider() {}, ActionMessages.DeleteResConfigsAction_0);
+               dialog.setTitle(ActionMessages.DeleteResConfigsAction_1);
+               if (dialog.open() == Window.OK) {
+                       Object[] selected = dialog.getResult();
+                       if (selected != null && selected.length > 0) {
+                               for (Object element : selected) {
+                                       ((ResCfgData)element).delete();
+                                       AbstractPage.updateViews(((ResCfgData)element).res);
+                               }
+                       }
+               }
+       }
+
+       // Stores data for resource description with its "parents".
+       class ResCfgData {
+               IResource res;
+               ICProjectDescription prjd;
+               ICConfigurationDescription cfgd;
+               ICResourceDescription rdesc;
+               
+               public ResCfgData(IResource res2, ICProjectDescription prjd2,
+                               ICConfigurationDescription cfgd2, ICResourceDescription rdesc2) {
+                       res = res2; prjd = prjd2; cfgd = cfgd2; rdesc = rdesc2;
+               }
+               
+               // performs deletion
+               public void delete() {
+                       try {
+                               cfgd.removeResourceDescription(rdesc);
+                               CoreModel.getDefault().setProjectDescription(res.getProject(), prjd);
+                       } catch (CoreException e) {}
+               }
+               @Override
+               public String toString() {
+                       return "[" + cfgd.getName() + "] for " + res.getName();   //$NON-NLS-1$ //$NON-NLS-2$
+               }
+       }
+       
+       
+       private IStructuredContentProvider createSelectionDialogContentProvider() {
+               outData = null;
+               
+               return new IStructuredContentProvider() {
+
+                       public Object[] getElements(Object inputElement) {
+                               if (outData != null) return outData.toArray();
+                               
+                               outData = new ArrayList<ResCfgData>();
+                               List<?> ls = (List<?>)inputElement;
+                               Iterator<?> it = ls.iterator();
+                               IProject proj = null;
+                               ICProjectDescription prjd = null;
+                               ICConfigurationDescription[] cfgds = null;
+
+                               // creating list of all res descs for all objects
+                               while (it.hasNext()) {
+                                       IResource res = (IResource)it.next();
+                                       IPath path = res.getProjectRelativePath();
+                                       if (res.getProject() != proj) {
+                                               proj = res.getProject();
+                                               prjd = CoreModel.getDefault().getProjectDescription(proj);
+                                               cfgds = prjd.getConfigurations();
+                                       }
+                                       if (cfgds != null) {
+                                               for (ICConfigurationDescription cfgd : cfgds) {
+                                                       ICResourceDescription rd = cfgd.getResourceDescription(path, true);
+                                                       if (rd != null) 
+                                                               outData.add(new ResCfgData(res, prjd, cfgd, rd));
+                                               }
+                                       }
+                               }
+                               return outData.toArray();
+                       }
+                       public void dispose() {}
+                       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+               };
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ExcludeFromBuildHandler.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ExcludeFromBuildHandler.java
new file mode 100644 (file)
index 0000000..fe53bae
--- /dev/null
@@ -0,0 +1,261 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *     Nokia - converted from action to handler
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.actions;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.ISources;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ListSelectionDialog;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+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.ITranslationUnit;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICSourceEntry;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.newui.AbstractPage;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+
+/**
+ * Handler for command that excludes resources from build.
+ */
+public class ExcludeFromBuildHandler extends AbstractHandler {
+
+       protected ArrayList<IResource> objects;
+       protected ArrayList<String> cfgNames;
+
+       @Override
+       public void setEnabled(Object context) {
+               ISelection selection = getSelection(context);
+               setEnabledFromSelection(selection);
+       }
+       
+       protected ISelection getSelection(Object context) {
+               Object s = HandlerUtil.getVariable(context, ISources.ACTIVE_MENU_SELECTION_NAME);
+        if (s instanceof ISelection) {
+               return (ISelection) s;
+        }
+           return null;
+       }
+
+       public void setEnabledFromSelection(ISelection selection) {
+               objects = null;
+               cfgNames = null;
+               boolean cfgsOK = true;
+               
+               if ((selection != null) && !selection.isEmpty()) {
+                       // case for context menu
+                       Object[] obs = null;
+                       if (selection instanceof IStructuredSelection) {
+                               obs = ((IStructuredSelection)selection).toArray();
+                       }
+                       else if (selection instanceof ITextSelection) {
+                               IFile file = getFileFromActiveEditor();
+                               if (file != null)
+                                       obs = Collections.singletonList(file).toArray();
+                       }
+                       if (obs != null && obs.length > 0) {
+                               for (int i=0; i<obs.length && cfgsOK; i++) {
+                                       // if project selected, don't do anything
+                                       if ((obs[i] instanceof IProject) || (obs[i] instanceof ICProject)) {
+                                               cfgsOK=false; 
+                                               break;
+                                       }
+                                       IResource res = null;
+                                       // only folders and files may be affected by this action
+                                       if (obs[i] instanceof ICContainer || obs[i] instanceof ITranslationUnit) {
+                                               res = ((ICElement) obs[i]).getResource();
+                                       } else if (obs[i] instanceof IResource) {
+                                               // project's configuration cannot be deleted
+                                               res = (IResource) obs[i];
+                                       }
+                                       if (res != null) {
+                                               ICConfigurationDescription[] cfgds = getCfgsRead(res);
+                                               if (cfgds == null || cfgds.length == 0) continue;
+                                               
+                                               if (objects == null) objects = new ArrayList<IResource>();
+                                               objects.add(res);
+                                               if (cfgNames == null) {
+                                                       cfgNames = new ArrayList<String>(cfgds.length);
+                                                       for (int j=0; j<cfgds.length; j++) { 
+                                                               if (!canExclude(res, cfgds[j])) {
+                                                                       cfgNames = null;
+                                                                       cfgsOK = false;
+                                                                       break;
+                                                               }
+                                                               cfgNames.add(cfgds[j].getName());
+                                                       }
+                                               } else {
+                                                       if (cfgNames.size() != cfgds.length) {
+                                                               cfgsOK = false;
+                                                       } else {
+                                                               for (int j=0; j<cfgds.length; j++) {
+                                                                       if (! canExclude(res, cfgds[j]) ||
+                                                                               ! cfgNames.contains(cfgds[j].getName())) {
+                                                                               cfgsOK = false;
+                                                                               break;
+                                                                       }
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               } 
+               setBaseEnabled(cfgsOK && (objects != null));
+       }
+
+       private IFile getFileFromActiveEditor() {
+               IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+               if (window != null) {
+                       IWorkbenchPage page = window.getActivePage();
+                       if (page != null) {
+                               IEditorPart editor = page.getActiveEditor();
+                               if (editor != null) {
+                                       IEditorInput input = editor.getEditorInput();
+                                       if (input != null)
+                                               return (IFile) input.getAdapter(IFile.class);
+                               }
+                       }
+               }
+               return null;
+       }
+
+       private boolean canExclude(IResource res, ICConfigurationDescription cfg) {
+               IPath p = res.getFullPath();
+               ICSourceEntry[] ent = cfg.getSourceEntries();
+               boolean state = CDataUtil.isExcluded(p, ent);
+               return CDataUtil.canExclude(p, (res instanceof IFolder), !state, ent);
+       }
+
+       private void setExclude(IResource res, ICConfigurationDescription cfg, boolean exclude) {
+               try {
+                       ICSourceEntry[] newEntries = CDataUtil.setExcluded(res.getFullPath(), (res instanceof IFolder), exclude, cfg.getSourceEntries());
+                       cfg.setSourceEntries(newEntries);
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }                                       
+       }
+       
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               openDialog();
+               return null;
+       }
+       
+       private ICConfigurationDescription[] getCfgsRead(IResource res) {
+               IProject p = res.getProject();
+               if (!p.isOpen()) return null;
+               if (!CoreModel.getDefault().isNewStyleProject(p)) return null;
+               ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false);
+               if (prjd == null) return null;
+               return prjd.getConfigurations();
+       }
+       
+       private void openDialog() {
+               if (objects == null || objects.size() == 0) return; 
+               // create list of configurations to delete
+               
+               ListSelectionDialog dialog = new ListSelectionDialog(
+                               CUIPlugin.getActiveWorkbenchShell(), 
+                               cfgNames, 
+                               createSelectionDialogContentProvider(), 
+                               new LabelProvider() {}, 
+                               ActionMessages.ExcludeFromBuildAction_0);
+               dialog.setTitle(ActionMessages.ExcludeFromBuildAction_1);
+               
+               boolean[] status = new boolean[cfgNames.size()];
+               Iterator<IResource> it = objects.iterator();
+               while (it.hasNext()) {
+                       IResource res = it.next();
+                       ICConfigurationDescription[] cfgds = getCfgsRead(res);
+                       IPath p = res.getFullPath();
+                       for (int i=0; i<cfgds.length; i++) {
+                               boolean b = CDataUtil.isExcluded(p, cfgds[i].getSourceEntries());
+                               if (b) status[i] = true;
+                       }
+               }
+               ArrayList<String> lst = new ArrayList<String>();
+               for (int i=0; i<status.length; i++) 
+                       if (status[i]) lst.add(cfgNames.get(i));
+               if (lst.size() > 0)
+                       dialog.setInitialElementSelections(lst);
+               
+               if (dialog.open() == Window.OK) {
+                       Object[] selected = dialog.getResult(); // may be empty
+                       Iterator<IResource> it2 = objects.iterator();
+                       while (it2.hasNext()) {
+                               IResource res = it2.next();
+                               IProject p = res.getProject();
+                               if (!p.isOpen()) continue;
+                               // get writable description
+                               ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, true);
+                               if (prjd == null) continue;
+                               ICConfigurationDescription[] cfgds = prjd.getConfigurations();
+                               for (int i=0; i<cfgds.length; i++) {
+                                       boolean exclude = false;
+                                       for (int j=0; j<selected.length; j++) {
+                                               if (cfgds[i].getName().equals(selected[j])) {
+                                                       exclude = true;
+                                                       break;
+                                               }
+                                       }
+                                       setExclude(res, cfgds[i], exclude);
+                               }
+                               try {
+                                       CoreModel.getDefault().setProjectDescription(p, prjd);
+                               } catch (CoreException e) {
+                                       CUIPlugin.logError(Messages.AbstractPage_11 + e.getLocalizedMessage()); 
+                               }
+                               AbstractPage.updateViews(res);
+                       }
+               }
+       }
+
+       private IStructuredContentProvider createSelectionDialogContentProvider() {
+               return new IStructuredContentProvider() {
+                       public Object[] getElements(Object inputElement) { return cfgNames.toArray(); }
+                       public void dispose() {}
+                       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+               };
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FindWordAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FindWordAction.java
new file mode 100644 (file)
index 0000000..437aabe
--- /dev/null
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Nokia - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.actions;
+
+import java.util.ResourceBundle;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.texteditor.FindNextAction;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.TextEditorAction;
+
+import org.eclipse.cdt.internal.ui.text.CWordFinder;
+
+/**
+ * Select the word at current cursor location and find the next occurrence.
+ */
+public class FindWordAction extends TextEditorAction {
+
+    public static final String FIND_WORD = "FindWord"; //$NON-NLS-1$
+
+    private ITextViewer fViewer;
+    private FindNextAction fFindNext;
+
+       /**
+        * Creates new action.
+        */
+    public FindWordAction(ResourceBundle bundle, String prefix, ITextEditor editor, ITextViewer viewer) {
+               super(bundle, prefix, editor);
+               fViewer = viewer;
+               fFindNext = new FindNextAction(bundle, prefix, editor, true);
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.jface.action.Action#run()
+        */
+       @Override
+       public void run() {
+               ITextEditor editor = getTextEditor();
+               if (editor == null )
+                       return;
+
+               ISelectionProvider selectionProvider = editor.getSelectionProvider();
+               if (selectionProvider == null)
+                       return;
+
+               ITextSelection selection = (ITextSelection) selectionProvider.getSelection();
+               if (selection == null || selection.isEmpty())
+                       return;
+
+               IDocumentProvider docProvider = editor.getDocumentProvider();
+               IEditorInput input = editor.getEditorInput();
+               if (docProvider == null || input == null)
+                       return;
+
+               IDocument document = docProvider.getDocument(input);
+               if (document == null)
+                       return;
+                       
+               IResource resource = (IResource)(input).getAdapter(IResource.class);
+               if (resource == null || !(resource instanceof IFile))
+                       return;
+
+               // find the word at current cursor location
+               int offset = selection.getOffset();
+               IRegion region = CWordFinder.findWord(document, offset);
+               if (region == null || region.getLength() == 0)
+                       return;
+
+               // select the word and find next occurrence
+               fViewer.setSelectedRange(region.getOffset(), region.getLength());
+               fFindNext.run();
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingActionGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingActionGroup.java
new file mode 100644 (file)
index 0000000..87ec40c
--- /dev/null
@@ -0,0 +1,200 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.actions;
+
+import java.util.ResourceBundle;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.source.projection.IProjectionListener;
+import org.eclipse.jface.text.source.projection.ProjectionViewer;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.editors.text.IFoldingCommandIds;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.IUpdate;
+import org.eclipse.ui.texteditor.ResourceAction;
+import org.eclipse.ui.texteditor.TextOperationAction;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+
+
+/**
+ * Groups the CDT folding actions.
+ *  
+ * @since 3.0
+ */
+public class FoldingActionGroup extends ActionGroup {
+
+       private static abstract class PreferenceAction extends ResourceAction implements IUpdate {
+               PreferenceAction(ResourceBundle bundle, String prefix, int style) {
+                       super(bundle, prefix, style);
+                       update();
+               }
+       }
+       
+       private class FoldingAction extends PreferenceAction {
+
+               FoldingAction(ResourceBundle bundle, String prefix) {
+                       super(bundle, prefix, IAction.AS_PUSH_BUTTON);
+               }
+
+               public void update() {
+                       setEnabled(FoldingActionGroup.this.isEnabled() && fViewer.isProjectionMode());
+               }
+               
+       }
+       
+       private ProjectionViewer fViewer;
+       private IProjectionListener fProjectionListener;
+       
+       private TextOperationAction fToggle;
+       private TextOperationAction fExpand;
+       private TextOperationAction fCollapse;
+       private TextOperationAction fExpandAll;
+       
+       // since 4.0
+       private TextOperationAction fCollapseAll;
+       private PreferenceAction fRestoreDefaults;
+
+
+       
+       /**
+        * Creates a new projection action group for <code>editor</code>. If the
+        * supplied viewer is not an instance of <code>ProjectionViewer</code>, the
+        * action group is disabled.
+        * 
+        * @param editor the text editor to operate on
+        * @param viewer the viewer of the editor
+        */
+       public FoldingActionGroup(final ITextEditor editor, ITextViewer viewer) {
+               if (!(viewer instanceof ProjectionViewer)) {
+                       fToggle= null;
+                       fExpand= null;
+                       fCollapse= null;
+                       fExpandAll= null;
+                       fCollapseAll= null;
+                       fRestoreDefaults= null;
+                       fProjectionListener= null;
+                       return;
+               }
+               
+               fViewer= (ProjectionViewer) viewer;
+               
+               fProjectionListener= new IProjectionListener() {
+                       public void projectionEnabled() {
+                               update();
+                       }
+                       public void projectionDisabled() {
+                               update();
+                       }
+               };
+               
+               fViewer.addProjectionListener(fProjectionListener);
+               
+               fToggle= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.Toggle.", editor, ProjectionViewer.TOGGLE, true); //$NON-NLS-1$
+               fToggle.setActionDefinitionId(IFoldingCommandIds.FOLDING_TOGGLE);
+               editor.setAction("FoldingToggle", fToggle); //$NON-NLS-1$
+               
+               fExpandAll= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.ExpandAll.", editor, ProjectionViewer.EXPAND_ALL, true); //$NON-NLS-1$
+               fExpandAll.setActionDefinitionId(IFoldingCommandIds.FOLDING_EXPAND_ALL);
+               editor.setAction("FoldingExpandAll", fExpandAll); //$NON-NLS-1$
+               
+               fCollapseAll= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.CollapseAll.", editor, ProjectionViewer.COLLAPSE_ALL, true); //$NON-NLS-1$
+               fCollapseAll.setActionDefinitionId(IFoldingCommandIds.FOLDING_COLLAPSE_ALL);
+               editor.setAction("FoldingCollapseAll", fCollapseAll); //$NON-NLS-1$
+
+               fExpand= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.Expand.", editor, ProjectionViewer.EXPAND, true); //$NON-NLS-1$
+               fExpand.setActionDefinitionId(IFoldingCommandIds.FOLDING_EXPAND);
+               editor.setAction("FoldingExpand", fExpand); //$NON-NLS-1$
+               
+               fCollapse= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.Collapse.", editor, ProjectionViewer.COLLAPSE, true); //$NON-NLS-1$
+               fCollapse.setActionDefinitionId(IFoldingCommandIds.FOLDING_COLLAPSE);
+               editor.setAction("FoldingCollapse", fCollapse); //$NON-NLS-1$
+
+               fRestoreDefaults= new FoldingAction(FoldingMessages.getResourceBundle(), "Projection.Restore.") { //$NON-NLS-1$
+                       @Override
+                       public void run() {
+                               if (editor instanceof CEditor) {
+                                       CEditor cEditor= (CEditor) editor;
+                                       cEditor.resetProjection();
+                               }
+                       }
+               };
+               fRestoreDefaults.setActionDefinitionId(IFoldingCommandIds.FOLDING_RESTORE);
+               editor.setAction("FoldingRestore", fRestoreDefaults); //$NON-NLS-1$
+       }
+       
+       /**
+        * Returns <code>true</code> if the group is enabled. 
+        * <pre>
+        * Invariant: isEnabled() <=> fViewer and all actions are != null.
+        * </pre>
+        * 
+        * @return <code>true</code> if the group is enabled
+        */
+       protected boolean isEnabled() {
+               return fViewer != null;
+       }
+       
+       /*
+        * @see org.eclipse.ui.actions.ActionGroup#dispose()
+        */
+       @Override
+       public void dispose() {
+               if (isEnabled()) {
+                       fViewer.removeProjectionListener(fProjectionListener);
+                       fViewer= null;
+               }
+               super.dispose();
+       }
+       
+       /**
+        * Updates the actions.
+        */
+       protected void update() {
+               if (isEnabled()) {
+                       fToggle.update();
+                       fToggle.setChecked(fViewer.isProjectionMode());
+                       fExpand.update();
+                       fExpandAll.update();
+                       fCollapse.update();
+                       fCollapseAll.update();
+                       fRestoreDefaults.update();
+               }
+       }
+       
+       /**
+        * Fills the menu with all folding actions.
+        * 
+        * @param manager the menu manager for the folding submenu
+        */
+       public void fillMenu(IMenuManager manager) {
+               if (isEnabled()) {
+                       update();
+                       manager.add(fToggle);
+                       manager.add(fExpandAll);
+                       manager.add(fExpand);
+                       manager.add(fCollapse);
+                       manager.add(fCollapseAll);
+                       manager.add(fRestoreDefaults);
+               }
+       }
+       
+       /*
+        * @see org.eclipse.ui.actions.ActionGroup#updateActionBars()
+        */
+       @Override
+       public void updateActionBars() {
+               update();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingMessages.java
new file mode 100644 (file)
index 0000000..d42be4d
--- /dev/null
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.actions;
+
+import com.ibm.icu.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * Class that gives access to the folding messages resource bundle.
+ */
+public class FoldingMessages {
+
+       private static final String BUNDLE_NAME= "org.eclipse.cdt.internal.ui.actions.FoldingMessages"; //$NON-NLS-1$
+
+       private static final ResourceBundle RESOURCE_BUNDLE= ResourceBundle.getBundle(BUNDLE_NAME);
+
+       private FoldingMessages() {
+               // no instance
+       }
+
+       /**
+        * Returns the resource string associated with the given key in the resource bundle. If there isn't 
+        * any value under the given key, the key is returned.
+        *
+        * @param key the resource key
+        * @return the string
+        */     
+       public static String getString(String key) {
+               try {
+                       return RESOURCE_BUNDLE.getString(key);
+               } catch (MissingResourceException e) {
+                       return '!' + key + '!';
+               }
+       }
+       
+       /**
+        * Returns the resource bundle managed by the receiver.
+        * 
+        * @return the resource bundle
+        * @since 3.0
+        */
+       public static ResourceBundle getResourceBundle() {
+               return RESOURCE_BUNDLE;
+       }
+       
+       /**
+        * Returns the formatted resource string associated with the given key in the resource bundle. 
+        * <code>MessageFormat</code> is used to format the message. If there isn't  any value 
+        * under the given key, the key is returned.
+        *
+        * @param key the resource key
+        * @param arg the message argument
+        * @return the string
+        */     
+       public static String getFormattedString(String key, Object arg) {
+               return getFormattedString(key, new Object[] { arg });
+       }
+       
+       /**
+        * Returns the formatted resource string associated with the given key in the resource bundle. 
+        * <code>MessageFormat</code> is used to format the message. If there isn't  any value 
+        * under the given key, the key is returned.
+        *
+        * @param key the resource key
+        * @param args the message arguments
+        * @return the string
+        */     
+       public static String getFormattedString(String key, Object[] args) {
+               return MessageFormat.format(getString(key), args);      
+       }       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingMessages.properties
new file mode 100644 (file)
index 0000000..7f9a9c8
--- /dev/null
@@ -0,0 +1,39 @@
+###############################################################################
+# Copyright (c) 2005, 2006 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+###############################################################################
+Projection.Toggle.label= &Enable Folding
+Projection.Toggle.tooltip= Toggles Folding
+Projection.Toggle.description= Toggles folding for the current editor
+Projection.Toggle.image=
+
+Projection.ExpandAll.label= Expand &All
+Projection.ExpandAll.tooltip= Expands All Collapsed Regions
+Projection.ExpandAll.description= Expands any collapsed regions in the current editor
+Projection.ExpandAll.image=
+
+Projection.Expand.label= E&xpand
+Projection.Expand.tooltip= Expands the Current Collapsed Region
+Projection.Expand.description= Expands the collapsed region at the current selection
+Projection.Expand.image=
+
+Projection.CollapseAll.label= Collapse A&ll
+Projection.CollapseAll.tooltip= Collapses All Expanded Regions
+Projection.CollapseAll.description= Collapse any expanded regions in the current editor
+Projection.CollapseAll.image=
+
+Projection.Collapse.label= Colla&pse
+Projection.Collapse.tooltip= Collapses the Current Region
+Projection.Collapse.description= Collapses the Current Region
+Projection.Collapse.image=
+
+Projection.Restore.label= &Reset Structure
+Projection.Restore.tooltip= Restore the Original Folding Structure
+Projection.Restore.description= Restores the original folding structure
+Projection.Restore.image=
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FreshenIndexAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FreshenIndexAction.java
new file mode 100644 (file)
index 0000000..ffed3d4
--- /dev/null
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.actions;
+
+import org.eclipse.cdt.core.index.IIndexManager;
+
+public class FreshenIndexAction extends AbstractUpdateIndexAction {
+
+       @Override
+       protected int getUpdateOptions() {
+               return IIndexManager.UPDATE_ALL | IIndexManager.UPDATE_EXTERNAL_FILES_FOR_PROJECT;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GoToNextPreviousMemberAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GoToNextPreviousMemberAction.java
new file mode 100644 (file)
index 0000000..e854a07
--- /dev/null
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     P.Tomaszewski
+ *  Anton Leherbauer (Wind River Systems)
+ *  Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.actions;
+
+import java.util.ResourceBundle;
+
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.TextEditorAction;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IParent;
+import org.eclipse.cdt.core.model.ISourceRange;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+
+/**
+ * Gives possibility to move fast between member elements of the c/c++ source.
+ *
+ * @author P.Tomaszewski
+ */
+public class GoToNextPreviousMemberAction extends TextEditorAction {
+
+    public static final String NEXT_MEMBER = "GotoNextMember"; //$NON-NLS-1$
+       public static final String PREVIOUS_MEMBER = "GotoPrevMember"; //$NON-NLS-1$
+       
+       /** Determines should action take user to the next member or to the previous one. */
+    private boolean fGotoNext;
+    
+    /**
+     * Creates new action.
+     * @param bundle Resource bundle.
+     * @param prefix Prefix.
+     * @param editor Editor.
+     * @param gotoNext Is it go to next or previous action.
+     */
+    public GoToNextPreviousMemberAction(ResourceBundle bundle, String prefix, ITextEditor editor, boolean gotoNext) {
+        super(bundle, prefix, editor);
+
+        fGotoNext = gotoNext;
+    }
+
+    /**
+     * Creates new action.
+     * @param bundle Resource bundle.
+     * @param prefix Prefix.
+     * @param editor Editor.
+     * @param style UI style.
+     * @param gotoNext Is it go to next or previous action.
+     */
+    public GoToNextPreviousMemberAction(ResourceBundle bundle, String prefix, ITextEditor editor, int style, boolean gotoNext) {
+        super(bundle, prefix, editor, style);
+
+        fGotoNext = gotoNext;
+    }
+
+    /*
+        * @see org.eclipse.ui.texteditor.TextEditorAction#update()
+        */
+       @Override
+       public void update() {
+        final ITextEditor editor = getTextEditor();
+               setEnabled(editor instanceof CEditor && ((CEditor)editor).getInputCElement() != null);
+       }
+
+       /**
+     * @see org.eclipse.jface.action.Action#run()
+     */
+    @Override
+       public void run() {
+        final CEditor editor = (CEditor) getTextEditor();
+        final ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
+        final IEditorInput editorInput = editor.getEditorInput();
+        final IWorkingCopy workingCopy =  CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput);
+        if (workingCopy == null) {
+               return;
+        }
+        try {
+            ISourceReference next= fGotoNext ? 
+                       getNextElement(workingCopy, selection.getOffset()) :
+                       getPrevElement(workingCopy, selection.getOffset());
+            if (next != null) {
+                editor.selectAndReveal(next.getSourceRange().getIdStartPos(), 0);
+            } 
+        } catch (CModelException e) {
+               CUIPlugin.log(e);
+        }
+    }
+
+       private ISourceReference getNextElement(IParent parent, int offset) throws CModelException {
+               ICElement[] children= parent.getChildren();
+               for (int i = 0; i < children.length; i++) {
+                       ICElement element = children[i];
+                       if (element instanceof ISourceReference) {
+                               final ISourceReference candidate1= (ISourceReference) element;
+                               final ISourceRange range= candidate1.getSourceRange();
+                               final int idpos1= range.getIdStartPos();
+                               if (element instanceof IParent && range.getStartPos() + range.getLength() > offset) {
+                                       ISourceReference candidate2= getNextElement((IParent) element, offset);
+                                       if (candidate2 != null) {
+                                               final int idpos2= candidate2.getSourceRange().getIdStartPos();
+                                               if (idpos1 <= offset || idpos1 > idpos2) {
+                                                       return candidate2;
+                                               }
+                                       }
+                               }
+                               if (idpos1 > offset) {
+                                       return candidate1;
+                               }
+                       }
+               }
+               return null;
+       }
+
+       private ISourceReference getPrevElement(IParent parent, int offset) throws CModelException {
+               ICElement[] children= parent.getChildren();
+               for (int i= children.length-1; i >= 0; i--) {
+                       ICElement element = children[i];
+                       if (element instanceof ISourceReference) {
+                               final ISourceReference candidate1= (ISourceReference) element;
+                               final ISourceRange range= candidate1.getSourceRange();
+                               final int idpos1= range.getIdStartPos();
+                               if (element instanceof IParent && range.getStartPos() < offset) {
+                                       ISourceReference candidate2= getPrevElement((IParent) element, offset);
+                                       if (candidate2 != null) {
+                                               final int idpos2= candidate2.getSourceRange().getIdStartPos();
+                                               if (idpos1 >= offset || idpos1 < idpos2) {
+                                                       return candidate2;
+                                               }
+                                       }
+                               }
+                               if (idpos1 < offset) {
+                                       return candidate1;
+                               }
+                       }
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GotoNextBookmarkAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GotoNextBookmarkAction.java
new file mode 100644 (file)
index 0000000..a041904
--- /dev/null
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Nokia - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.actions;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.ResourceBundle;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.util.OpenStrategy;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.MarkerUtilities;
+import org.eclipse.ui.texteditor.TextEditorAction;
+
+/**
+ * Find and goto the next bookmark in the currently selected file.
+ */
+public class GotoNextBookmarkAction extends TextEditorAction {
+
+    public static final String NEXT_BOOKMARK = "GotoNextBookmark"; //$NON-NLS-1$
+
+    /**
+        * Private class to handle comparison of markers using their line numbers.
+        */
+       private class CompareMarker implements Comparator<IMarker> {
+               public int compare(IMarker m1, IMarker m2) {
+                       int l1 = MarkerUtilities.getLineNumber(m1);
+                       int l2 = MarkerUtilities.getLineNumber(m2);
+                       if (l1 > l2) return 1;
+                       if (l1 < l2) return -1;
+                       return 0;
+               }
+       }
+
+       /**
+        * Creates new action.
+        */
+       public GotoNextBookmarkAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
+               super(bundle, prefix, editor);
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.jface.action.Action#run()
+        */
+       @Override
+       public void run() {
+               ITextEditor editor = getTextEditor();
+               if (editor == null )
+                       return;
+
+               ISelectionProvider provider = editor.getSelectionProvider();
+               if (provider == null)
+                       return;
+
+               ITextSelection selection = (ITextSelection) provider.getSelection();
+               if (selection == null || selection.isEmpty())
+                       return;
+
+               IEditorInput input= editor.getEditorInput();
+               if (input == null)
+                       return;
+
+               IResource resource = (IResource)(input).getAdapter(IResource.class);
+               if (resource == null || !(resource instanceof IFile))
+                       return;
+
+               try {
+                       IMarker[] bookmarks = resource.findMarkers(IMarker.BOOKMARK, true, IResource.DEPTH_ONE);
+                       if (bookmarks.length == 0)
+                               return;
+
+                       // sort bookmarks by line number
+                       CompareMarker comparator = new CompareMarker();
+                       Arrays.sort(bookmarks, comparator);
+
+                       // marker line numbers are 1-based
+                       int line = selection.getStartLine() + 1;
+                       IMarker lastBookmark = bookmarks[bookmarks.length - 1];
+
+                       // start from the beginning of file if reached or went beyond last bookmark
+                       if (line >= MarkerUtilities.getLineNumber(lastBookmark)) {
+                               line = 1;
+                       }
+
+                       // find the next bookmark and goto it
+                       for (int i = 0; i < bookmarks.length; i++) {
+                               IMarker bookmark = bookmarks[i];
+                               if (MarkerUtilities.getLineNumber(bookmark) > line) {
+                                       IDE.openEditor(getTextEditor().getSite().getPage(), bookmark, OpenStrategy.activateOnOpen());
+                                       break;
+                               }
+                       }
+               }
+               catch (CoreException e) {
+                       e.printStackTrace();
+               }
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/IndentAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/IndentAction.java
new file mode 100644 (file)
index 0000000..df58e6d
--- /dev/null
@@ -0,0 +1,572 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin, Google
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.actions;
+
+import java.util.ResourceBundle;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.IRewriteTarget;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.TextSelection;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.ITextEditorExtension3;
+import org.eclipse.ui.texteditor.TextEditorAction;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.editor.IndentUtil;
+import org.eclipse.cdt.internal.ui.text.CHeuristicScanner;
+import org.eclipse.cdt.internal.ui.text.CIndenter;
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+
+
+/**
+ * Indents a line or range of lines in a C document to its correct position. No complete
+ * AST must be present, the indentation is computed using heuristics. The algorithm used is fast for
+ * single lines, but does not store any information and therefore not so efficient for large line
+ * ranges.
+ * 
+ * @see org.eclipse.cdt.internal.ui.text.CHeuristicScanner
+ * @see org.eclipse.cdt.internal.ui.text.CIndenter
+ */
+public class IndentAction extends TextEditorAction {
+       
+       /** The caret offset after an indent operation. */
+       private int fCaretOffset;
+       
+       /**
+        * Whether this is the action invoked by TAB. When <code>true</code>, indentation behaves
+        * differently to accommodate normal TAB operation.
+        */
+       private final boolean fIsTabAction;
+       
+       /**
+        * Creates a new instance.
+        * 
+        * @param bundle the resource bundle
+        * @param prefix the prefix to use for keys in <code>bundle</code>
+        * @param editor the text editor
+        * @param isTabAction whether the action should insert tabs if over the indentation
+        */
+       public IndentAction(ResourceBundle bundle, String prefix, ITextEditor editor, boolean isTabAction) {
+               super(bundle, prefix, editor);
+               fIsTabAction= isTabAction;
+       }
+       
+       /*
+        * @see org.eclipse.jface.action.Action#run()
+        */
+       @Override
+       public void run() {
+               // update has been called by the framework
+               if (!isEnabled() || !validateEditorInputState())
+                       return;
+               
+               ITextSelection selection= getSelection();
+               final IDocument document= getDocument();
+               
+               if (document != null) {
+                       final int offset= selection.getOffset();
+                       final int length= selection.getLength();
+                       final Position end= new Position(offset + length);
+                       final int firstLine, nLines;
+                       fCaretOffset= -1;
+                       
+                       try {
+                               firstLine= document.getLineOfOffset(offset);
+                               // check for marginal (zero-length) lines
+                               int minusOne= length == 0 ? 0 : 1;
+                               nLines= document.getLineOfOffset(offset + length - minusOne) - firstLine + 1;
+                               document.addPosition(end);
+                       } catch (BadLocationException e) {
+                               // will only happen on concurrent modification
+                               CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK, "", e)); //$NON-NLS-1$
+                               return;
+                       }
+                       
+                       Runnable runnable= new Runnable() {
+                               public void run() {
+                                       IRewriteTarget target= (IRewriteTarget)getTextEditor().getAdapter(IRewriteTarget.class);
+                                       if (target != null)
+                                               target.beginCompoundChange();
+                                       
+                                       try {
+                                               CHeuristicScanner scanner= new CHeuristicScanner(document);
+                                               CIndenter indenter= new CIndenter(document, scanner, getCProject());
+                                               final boolean multiLine= nLines > 1;
+                                               boolean hasChanged= false;
+                                               for (int i= 0; i < nLines; i++) {
+                                                       hasChanged |= indentLine(document, firstLine + i, offset, indenter, scanner, multiLine);
+                                               }
+                                               
+                                               // update caret position: move to new position when indenting just one line
+                                               // keep selection when indenting multiple
+                                               int newOffset, newLength;
+                                               if (!fIsTabAction && multiLine) {
+                                                       newOffset= offset;
+                                                       newLength= end.getOffset() - offset;
+                                               } else {
+                                                       newOffset= fCaretOffset;
+                                                       newLength= 0;
+                                               }
+                                               
+                                               // always reset the selection if anything was replaced
+                                               // but not when we had a single line non-tab invocation
+                                               if (newOffset != -1 && (hasChanged || newOffset != offset || newLength != length))
+                                                       selectAndReveal(newOffset, newLength);
+                                               
+                                       } catch (BadLocationException e) {
+                                               // will only happen on concurrent modification
+                                               CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK, "ConcurrentModification in IndentAction", e)); //$NON-NLS-1$
+                                       } finally {
+                                               document.removePosition(end);
+                                               if (target != null)
+                                                       target.endCompoundChange();
+                                       }
+                               }
+                       };
+                       
+                       if (nLines > 50) {
+                               Display display= getTextEditor().getEditorSite().getWorkbenchWindow().getShell().getDisplay();
+                               BusyIndicator.showWhile(display, runnable);
+                       } else {
+                               runnable.run();
+                       }
+               }
+       }
+       
+       /**
+        * Selects the given range on the editor.
+        * 
+        * @param newOffset the selection offset
+        * @param newLength the selection range
+        */
+       private void selectAndReveal(int newOffset, int newLength) {
+               Assert.isTrue(newOffset >= 0);
+               Assert.isTrue(newLength >= 0);
+               ITextEditor editor= getTextEditor();
+               if (editor instanceof CEditor) {
+                       ISourceViewer viewer= ((CEditor)editor).getViewer();
+                       if (viewer != null)
+                               viewer.setSelectedRange(newOffset, newLength);
+               } else {
+                       // this is too intrusive, but will never get called anyway
+                       getTextEditor().selectAndReveal(newOffset, newLength);
+               }
+       }
+
+       /**
+        * Indents a single line using the heuristic scanner. Multiline comments are
+        * indented as specified by the <code>CCommentAutoIndentStrategy</code>.
+        * 
+        * @param document the document
+        * @param line the line to be indented
+        * @param caret the caret position
+        * @param indenter the indenter
+        * @param scanner the heuristic scanner
+        * @param multiLine <code>true</code> if more than one line is being indented
+        * @return <code>true</code> if <code>document</code> was modified, <code>false</code> otherwise
+        * @throws BadLocationException if the document got changed concurrently
+        */
+       private boolean indentLine(IDocument document, int line, int caret, CIndenter indenter, CHeuristicScanner scanner, boolean multiLine) throws BadLocationException {
+               IRegion currentLine= document.getLineInformation(line);
+               int offset= currentLine.getOffset();
+               int wsStart= offset; // where we start searching for non-WS; after the "//" in single line comments
+               
+               String indent= null;
+               if (offset < document.getLength()) {
+                       ITypedRegion partition= TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, true);
+                       ITypedRegion startingPartition= TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, false);
+                       String type= partition.getType();
+                       if (type.equals(ICPartitions.C_MULTI_LINE_COMMENT) || type.equals(ICPartitions.C_MULTI_LINE_DOC_COMMENT)) {
+                               indent= computeCommentIndent(document, line, scanner, startingPartition);
+                       } else if (startingPartition.getType().equals(ICPartitions.C_PREPROCESSOR)) {
+                               indent= computePreprocessorIndent(document, line, startingPartition);
+                       } else if (startingPartition.getType().equals(ICPartitions.C_STRING) && offset > startingPartition.getOffset()) {
+                               // don't indent inside (raw-)string
+                               return false;
+                       } else if (!fIsTabAction && startingPartition.getOffset() == offset && startingPartition.getType().equals(ICPartitions.C_SINGLE_LINE_COMMENT)) {
+                               // line comment starting at position 0 -> indent inside
+                               if (indentInsideLineComments()) {
+                                       int max= document.getLength() - offset;
+                                       int slashes= 2;
+                                       while (slashes < max - 1 && document.get(offset + slashes, 2).equals("//")) //$NON-NLS-1$
+                                               slashes+= 2;
+                                       
+                                       wsStart= offset + slashes;
+                                       
+                                       StringBuilder computed= indenter.computeIndentation(offset);
+                                       if (computed == null)
+                                               computed= new StringBuilder(0);
+                                       int tabSize= getTabSize();
+                                       while (slashes > 0 && computed.length() > 0) {
+                                               char c= computed.charAt(0);
+                                               if (c == '\t') {
+                                                       if (slashes > tabSize)
+                                                               slashes-= tabSize;
+                                                       else
+                                                               break;
+                                               } else if (c == ' ') {
+                                                       slashes--;
+                                               } else {
+                                                       break;
+                                               }
+                                               
+                                               computed.deleteCharAt(0);
+                                       }
+                                       
+                                       indent= document.get(offset, wsStart - offset) + computed;
+                               }
+                       }
+               }
+               
+               // standard C code indentation
+               if (indent == null) {
+                       StringBuilder computed= indenter.computeIndentation(offset);
+                       if (computed != null)
+                               indent= computed.toString();
+                       else
+                               indent= ""; //$NON-NLS-1$
+               }
+               
+               // change document:
+               // get current white space
+               int lineLength= currentLine.getLength();
+               int end= scanner.findNonWhitespaceForwardInAnyPartition(wsStart, offset + lineLength);
+               if (end == CHeuristicScanner.NOT_FOUND) {
+                       // an empty line
+                       end= offset + lineLength;
+                       if (multiLine && !indentEmptyLines())
+                               indent= ""; //$NON-NLS-1$
+               }
+               int length= end - offset;
+               String currentIndent= document.get(offset, length);
+               
+               // if we are right before the text start / line end, and already after the insertion point
+               // then just shift to the right
+               if (fIsTabAction && caret == end && whiteSpaceLength(currentIndent) >= whiteSpaceLength(indent)) {
+                       int indentWidth= whiteSpaceLength(currentIndent) + getIndentSize();
+                       if (useTabsAndSpaces()) {
+                               currentIndent = trimSpacesRight(currentIndent);
+                       }
+                       String replacement= IndentUtil.changePrefix(currentIndent, indentWidth, getTabSize(), useSpaces());
+                       document.replace(offset, length, replacement);
+                       fCaretOffset= offset + replacement.length();
+                       return true;
+               }
+               
+               // set the caret offset so it can be used when setting the selection
+               if (caret >= offset && caret <= end)
+                       fCaretOffset= offset + indent.length();
+               else
+                       fCaretOffset= -1;
+               
+               // only change the document if it is a real change
+               if (!indent.equals(currentIndent)) {
+                       document.replace(offset, length, indent);
+                       return true;
+               }
+               return false;
+       }
+
+       /**
+        * Strip trailing space characters.
+        * 
+        * @param indent
+        * @return string with trailing spaces removed
+        */
+       private String trimSpacesRight(String indent) {
+               int i = indent.length() - 1;
+               while (i >= 0 && indent.charAt(i) == ' ') {
+                       --i;
+               }
+               return indent.substring(0, i+1);
+       }
+
+       /**
+        * Computes and returns the indentation for a block comment line.
+        * 
+        * @param document the document
+        * @param line the line in document
+        * @param scanner the scanner
+        * @param partition the comment partition
+        * @return the indent, or <code>null</code> if not computable
+        * @throws BadLocationException
+        */
+       private String computeCommentIndent(IDocument document, int line, CHeuristicScanner scanner, ITypedRegion partition) throws BadLocationException {
+               return IndentUtil.computeCommentIndent(document, line, scanner, partition);
+       }
+       
+       /**
+        * Computes and returns the indentation for a preprocessor line.
+        * 
+        * @param document the document
+        * @param line the line in document
+        * @param partition the comment partition
+        * @return the indent, or <code>null</code> if not computable
+        * @throws BadLocationException
+        */
+       private String computePreprocessorIndent(IDocument document, int line, ITypedRegion partition) throws BadLocationException {
+               return IndentUtil.computePreprocessorIndent(document, line, partition);
+       }
+       
+       /**
+        * Returns the size in characters of a string. All characters count one, tabs count the editor's
+        * preference for the tab display
+        * 
+        * @param indent the string to be measured.
+        * @return the size in characters of a string
+        */
+       private int whiteSpaceLength(String indent) {
+               if (indent == null)
+                       return 0;
+               return IndentUtil.computeVisualLength(indent, getTabSize());
+       }
+
+       /**
+        * Returns whether spaces should be used exclusively for indentation, depending on the editor and
+        * formatter preferences.
+        * 
+        * @return <code>true</code> if only spaces should be used
+        */
+       private boolean useSpaces() {
+               return CCorePlugin.SPACE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR));
+       }
+       
+       /**
+        * Returns whether mixed tabs/spaces should be used for indentation, depending on the editor and
+        * formatter preferences.
+        * 
+        * @return <code>true</code> if tabs and spaces should be used
+        */
+       private boolean useTabsAndSpaces() {
+               return DefaultCodeFormatterConstants.MIXED.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR));
+       }
+       
+       /**
+        * Returns the tab size used by the editor, which is deduced from the
+        * formatter preferences.
+        * 
+        * @return the tab size as defined in the current formatter preferences
+        */
+       private int getTabSize() {
+               return getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, 4);
+       }
+
+       /**
+        * Returns the indent size used by the editor, which is deduced from the
+        * formatter preferences.
+        * 
+        * @return the indent size as defined in the current formatter preferences
+        */
+       private int getIndentSize() {
+               return CodeFormatterUtil.getIndentWidth(getCProject());
+       }
+
+       /**
+        * Returns <code>true</code> if empty lines should be indented, <code>false</code> otherwise.
+        * 
+        * @return <code>true</code> if empty lines should be indented, <code>false</code> otherwise
+        */
+       private boolean indentEmptyLines() {
+               return DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES));
+       }
+       
+       /**
+        * Returns <code>true</code> if line comments at column 0 should be indented inside, <code>false</code> otherwise.
+        * 
+        * @return <code>true</code> if line comments at column 0 should be indented inside, <code>false</code> otherwise.
+        */
+       private boolean indentInsideLineComments() {
+               return DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_INSIDE_LINE_COMMENTS));
+       }
+       
+       /**
+        * Returns the possibly project-specific core preference defined under <code>key</code>.
+        * 
+        * @param key the key of the preference
+        * @return the value of the preference
+        */
+       private String getCoreFormatterOption(String key) {
+               ICProject project= getCProject();
+               if (project == null)
+                       return CCorePlugin.getOption(key);
+               return project.getOption(key, true);
+       }
+
+       /**
+        * Returns the possibly project-specific core preference defined under <code>key</code>, or
+        * <code>def</code> if the value is not a integer.
+        * 
+        * @param key the key of the preference
+        * @param def the default value
+        * @return the value of the preference
+        */
+       private int getCoreFormatterOption(String key, int def) {
+               try {
+                       return Integer.parseInt(getCoreFormatterOption(key));
+               } catch (NumberFormatException e) {
+                       return def;
+               }
+       }
+
+       /**
+        * Returns the <code>ICProject</code> of the current editor input, or
+        * <code>null</code> if it cannot be found.
+        * 
+        * @return the <code>ICProject</code> of the current editor input, or
+        *         <code>null</code> if it cannot be found
+        */
+       private ICProject getCProject() {
+               ITextEditor editor= getTextEditor();
+               if (editor == null)
+                       return null;
+               
+               return EditorUtility.getCProject(editor.getEditorInput());
+       }
+
+       /**
+        * Returns the editor's selection provider.
+        * 
+        * @return the editor's selection provider or <code>null</code>
+        */
+       private ISelectionProvider getSelectionProvider() {
+               ITextEditor editor= getTextEditor();
+               if (editor != null) {
+                       return editor.getSelectionProvider();
+               }
+               return null;
+       }
+       
+       /*
+        * @see org.eclipse.ui.texteditor.IUpdate#update()
+        */
+       @Override
+       public void update() {
+               super.update();
+               
+               if (isEnabled()) {
+                       if (fIsTabAction)
+                               setEnabled(canModifyEditor() && isSmartMode() && isValidSelection());
+                       else
+                               setEnabled(canModifyEditor() && !getSelection().isEmpty());
+               }
+       }
+       
+       /**
+        * Returns if the current selection is valid, i.e. whether it is empty and the caret in the
+        * whitespace at the start of a line, or covers multiple lines.
+        * 
+        * @return <code>true</code> if the selection is valid for an indent operation
+        */
+       private boolean isValidSelection() {
+               ITextSelection selection= getSelection();
+               if (selection.isEmpty())
+                       return false;
+               
+               int offset= selection.getOffset();
+               int length= selection.getLength();
+               
+               IDocument document= getDocument();
+               if (document == null)
+                       return false;
+               
+               try {
+                       IRegion firstLine= document.getLineInformationOfOffset(offset);
+                       int lineOffset= firstLine.getOffset();
+                       
+                       // either the selection has to be empty and the caret in the WS at the line start
+                       // or the selection has to extend over multiple lines
+                       if (length == 0) {
+                               return document.get(lineOffset, offset - lineOffset).trim().length() == 0;
+                       }
+//                     return lineOffset + firstLine.getLength() < offset + length;
+                       return false; // only enable for empty selections for now
+               } catch (BadLocationException e) {
+               }
+               
+               return false;
+       }
+       
+       /**
+        * Returns the smart preference state.
+        * 
+        * @return <code>true</code> if smart mode is on, <code>false</code> otherwise
+        */
+       private boolean isSmartMode() {
+               ITextEditor editor= getTextEditor();
+               
+               if (editor instanceof ITextEditorExtension3)
+                       return ((ITextEditorExtension3) editor).getInsertMode() == ITextEditorExtension3.SMART_INSERT;
+               
+               return false;
+       }
+       
+       /**
+        * Returns the document currently displayed in the editor, or <code>null</code> if none can be
+        * obtained.
+        * 
+        * @return the current document or <code>null</code>
+        */
+       private IDocument getDocument() {
+               ITextEditor editor= getTextEditor();
+               if (editor != null) {
+                       IDocumentProvider provider= editor.getDocumentProvider();
+                       IEditorInput input= editor.getEditorInput();
+                       if (provider != null && input != null)
+                               return provider.getDocument(input);
+                       
+               }
+               return null;
+       }
+       
+       /**
+        * Returns the selection on the editor or an invalid selection if none can be obtained. Returns
+        * never <code>null</code>.
+        * 
+        * @return the current selection, never <code>null</code>
+        */
+       private ITextSelection getSelection() {
+               ISelectionProvider provider= getSelectionProvider();
+               if (provider != null) {
+                       ISelection selection= provider.getSelection();
+                       if (selection instanceof ITextSelection)
+                               return (ITextSelection) selection;
+               }
+               
+               // null object
+               return TextSelection.emptySelection();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/OpenActionUtil.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/OpenActionUtil.java
new file mode 100644 (file)
index 0000000..cf271af
--- /dev/null
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.actions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.ui.CElementLabelProvider;
+
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
+import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider;
+
+public class OpenActionUtil {
+       
+       private OpenActionUtil() {
+               // no instance.
+       }
+               
+       /**
+        * Opens the editor on the given element and subsequently selects it.
+        */
+       public static void open(Object element) throws CModelException, PartInitException {
+               open(element, true);
+       }
+       
+       /**
+        * Opens the editor on the given element and subsequently selects it.
+        */
+       public static void open(Object element, boolean activate) throws CModelException, PartInitException {
+               IEditorPart part= EditorUtility.openInEditor(element, activate);
+               if (element instanceof ICElement)
+                       EditorUtility.revealInEditor(part, (ICElement)element);
+       }
+       
+       /**
+        * Filters out source references from the given code resolve results.
+        * A utility method that can be called by subclassers. 
+        */
+       public static List<ISourceReference> filterResolveResults(ICElement[] codeResolveResults) {
+               int nResults= codeResolveResults.length;
+               List<ISourceReference> refs= new ArrayList<ISourceReference>(nResults);
+               for (int i= 0; i < nResults; i++) {
+                       if (codeResolveResults[i] instanceof ISourceReference)
+                               refs.add((ISourceReference) codeResolveResults[i]);
+               }
+               return refs;
+       }
+                                               
+       /**
+        * Shows a dialog for resolving an ambiguous C element.
+        * Utility method that can be called by subclasses.
+        */
+       public static ICElement selectCElement(ICElement[] elements, Shell shell, String title, String message) {
+               return selectCElement(elements, shell, title, message, 0, 0);
+       }
+
+       /**
+        * Shows a dialog for resolving an ambiguous C element.
+        * @see CElementLabels
+        * @param elements an array of ambiguous elements.
+        * @param shell parent shell for showing the dialog
+        * @param title title of the dialog
+        * @param message message to be shown in the dialog
+        * @param textFlags text flags to change the label provider 
+        * @param imageFlags image flags to change the label provider 
+        * @return the selected element or <code>null</code>
+        * @since 4.0
+        */
+       public static ICElement selectCElement(ICElement[] elements, Shell shell, String title, String message, long textFlags, int imageFlags) {
+               int nResults= elements.length;
+               
+               if (nResults == 0)
+                       return null;
+               
+               if (nResults == 1)
+                       return elements[0];
+               
+               ILabelProvider labelProvider;
+               if (textFlags == 0 && imageFlags == 0) {
+                       labelProvider= new CElementLabelProvider(CElementLabelProvider.SHOW_DEFAULT | CElementLabelProvider.SHOW_QUALIFIED);
+               }
+               else {
+                       labelProvider= new CUILabelProvider(textFlags, imageFlags);
+               }
+                                               
+               ElementListSelectionDialog dialog= new ElementListSelectionDialog(shell, labelProvider);
+               dialog.setTitle(title);
+               dialog.setMessage(message);
+               dialog.setElements(elements);
+               
+               if (dialog.open() == Window.OK) {
+                       Object[] selection= dialog.getResult();
+                       if (selection != null && selection.length > 0) {
+                               nResults= selection.length;
+                               for (int i= 0; i < nResults; i++) {
+                                       Object current= selection[i];
+                                       if (current instanceof ICElement)
+                                               return (ICElement) current;
+                               }
+                       }
+               }               
+               return null;
+       }       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RebuildIndexAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RebuildIndexAction.java
new file mode 100644 (file)
index 0000000..a9300c6
--- /dev/null
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.actions;
+
+import java.util.Iterator;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.ICProject;
+
+public class RebuildIndexAction implements IObjectActionDelegate {
+
+       private ISelection fSelection;
+
+       public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+       }
+       
+       public void run(IAction action) {
+               IStructuredSelection cElements= SelectionConverter.convertSelectionToCElements(fSelection);
+               for (Iterator<?> i = cElements.iterator(); i.hasNext();) {
+                       Object elem = i.next();
+                       if (elem instanceof ICProject) {
+                               CCorePlugin.getIndexManager().reindex((ICProject) elem);
+                       }
+               }
+       }
+       
+       /**
+        * @see IActionDelegate#selectionChanged(IAction, ISelection)
+        */
+       public void selectionChanged(IAction action, ISelection selection) {
+               fSelection= selection;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RemoveBlockCommentAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RemoveBlockCommentAction.java
new file mode 100644 (file)
index 0000000..399c9a8
--- /dev/null
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Andrew Gvozdev - http://bugs.eclipse.org/236160
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.actions;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ResourceBundle;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.BadPartitioningException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentExtension3;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+/**
+ * Action that removes the enclosing comment marks from a C block comment.
+ * 
+ * @since 3.0
+ */
+public class RemoveBlockCommentAction extends BlockCommentAction {
+
+       /**
+        * Creates a new instance.
+        * 
+        * @param bundle the resource bundle
+        * @param prefix a prefix to be prepended to the various resource keys
+        *   (described in <code>ResourceAction</code> constructor), or 
+        *   <code>null</code> if none
+        * @param editor the text editor
+        */
+       public RemoveBlockCommentAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
+               super(bundle, prefix, editor);
+       }
+       
+       @Override
+       protected void runInternal(ITextSelection selection, IDocumentExtension3 docExtension, Edit.EditFactory factory) throws BadPartitioningException, BadLocationException {
+               if ( !(docExtension instanceof IDocument) ) return;
+
+               List<Edit> edits= new LinkedList<Edit>();
+               
+               int partitionStart = -1;
+               int partitionEnd   = selection.getOffset();
+
+               do {
+                       ITypedRegion partition = docExtension.getPartition(ICPartitions.C_PARTITIONING, partitionEnd, false);
+                       if (partition.getOffset() <= partitionStart) {
+                               // If we did not advance break the loop
+                               break;
+                       }
+                       partitionStart = partition.getOffset();
+                       partitionEnd   = partitionStart + partition.getLength();
+                       if (partition.getType() == ICPartitions.C_MULTI_LINE_COMMENT
+                                       || partition.getType() == ICPartitions.C_MULTI_LINE_DOC_COMMENT) {
+                               uncommentPartition((IDocument)docExtension, factory, edits, partitionStart, partitionEnd);
+                       }
+               } while (partitionEnd < selection.getOffset()+selection.getLength());
+
+               executeEdits(edits);
+       }
+
+       private void uncommentPartition(IDocument doc, Edit.EditFactory factory,
+                       List<Edit> edits, int partitionStart, int partitionEnd)
+                       throws BadLocationException {
+               
+               int startCommentTokenLength = getCommentStart().length();
+               int endCommentTokenLength = getCommentEnd().length();
+
+               // Remove whole line (with EOL) if it contains start or end comment tag
+               // and nothing else
+               if (partitionStart >= 0) {
+                       IRegion lineRegion = doc.getLineInformationOfOffset(partitionStart);
+                       String lineContent = doc.get(lineRegion.getOffset(), lineRegion.getLength());
+                       // start comment tag '/*'
+                       if (lineContent.equals(getCommentStart())) {
+                               String eol = doc.getLineDelimiter(doc.getLineOfOffset(partitionStart));
+                               if (eol!=null) {
+                                       startCommentTokenLength = startCommentTokenLength+eol.length();
+                               }
+                       }
+               }
+
+               int commentContentEnd = partitionEnd - endCommentTokenLength;
+               if (partitionEnd < doc.getLength()) {
+                       IRegion lineRegion = doc.getLineInformationOfOffset(partitionEnd);
+                       String lineContent = doc.get(lineRegion.getOffset(), lineRegion.getLength());
+                       // end comment tag '*/'
+                       if (lineContent.equals(getCommentEnd())) {
+                               String eol = doc.getLineDelimiter(doc.getLineOfOffset(partitionEnd));
+                               if (eol!=null) {
+                                       endCommentTokenLength = endCommentTokenLength + eol.length();
+                               }
+                       }
+               }
+
+               edits.add(factory.createEdit(partitionStart, startCommentTokenLength, "")); //$NON-NLS-1$
+               edits.add(factory.createEdit(commentContentEnd, endCommentTokenLength, "")); //$NON-NLS-1$
+       }
+
+       @Override
+       protected boolean isValidSelection(ITextSelection selection) {
+               return selection != null && !selection.isEmpty() && selection.getLength() > 0;
+       }
+
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SelectAllAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SelectAllAction.java
new file mode 100644 (file)
index 0000000..3e3652c
--- /dev/null
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.actions;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.actions.ActionMessages;
+import org.eclipse.jface.action.Action;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.viewers.TableViewer;
+
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * This action selects all entries currently showing in view.
+ */
+public class SelectAllAction extends Action {
+
+       private TableViewer fViewer;
+
+       /**
+        * Creates the action.
+        */
+       public SelectAllAction(TableViewer viewer) {
+               super("selectAll"); //$NON-NLS-1$
+               setText(ActionMessages.SelectAllAction_label);
+               setToolTipText(ActionMessages.SelectAllAction_tooltip);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.SELECT_ALL_ACTION);
+               Assert.isNotNull(viewer);
+               fViewer= viewer;
+       }
+
+       /**
+        * Selects all resources in the view.
+        */
+       @Override
+       public void run() {
+               fViewer.getTable().selectAll();
+               // force viewer selection change
+               fViewer.setSelection(fViewer.getSelection());
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SelectionConverter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SelectionConverter.java
new file mode 100644 (file)
index 0000000..2e1d899
--- /dev/null
@@ -0,0 +1,335 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.actions;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+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.viewers.StructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ISourceRange;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.IWorkingCopyManager;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
+
+public class SelectionConverter {
+
+       protected static final ICElement[] EMPTY_RESULT= new ICElement[0];
+       /**
+        * Converts the selection provided by the given part into a structured selection.
+        * The following conversion rules are used:
+        * <ul>
+        *      <li><code>part instanceof CEditor</code>: returns a structured selection
+        *      using code resolve to convert the editor's text selection.</li>
+        * <li><code>part instanceof IWorkbenchPart</code>: returns the part's selection
+        *      if it is a structured selection.</li>
+        * <li><code>default</code>: returns an empty structured selection.</li>
+        * </ul>
+        */
+       public static IStructuredSelection getStructuredSelection(IWorkbenchPart part) throws CModelException {
+               if (part instanceof CEditor)
+                       return new StructuredSelection(codeResolve((CEditor)part));
+               ISelectionProvider provider= part.getSite().getSelectionProvider();
+               if (provider != null) {
+                       ISelection selection= provider.getSelection();
+                       if (selection instanceof IStructuredSelection)
+                               return (IStructuredSelection)selection;
+               }
+               return StructuredSelection.EMPTY;
+       }
+
+       /**
+        * Converts objects of a structured selection to c elements if possible.
+        * This is a convenience method, fully equivalent to 
+        * <code>convertSelectionToCElements(s, false)</code>.
+        * @param s The structured selection
+        * @return The converted selection
+        */
+               public static IStructuredSelection convertSelectionToCElements(ISelection s) {
+               return convertSelectionToCElements(s, false);
+       }
+
+       /**
+        * Converts objects of a structured selection to c elements if possible.
+        * @param s The structured selection
+        * @param keepNonCElements Whether to keep objects in selection if they cannot be converted
+        * @return The converted selection
+        */
+       public static IStructuredSelection convertSelectionToCElements(ISelection s,
+                       boolean keepNonCElements) {
+               List<Object> converted = new ArrayList<Object>();
+               if (s instanceof IStructuredSelection) {
+                       Object[] elements = ((IStructuredSelection) s).toArray();
+                       for (int i = 0; i < elements.length; i++) {
+                               Object e = elements[i];
+                               if (e instanceof ICElement) {
+                                       converted.add(e);
+                               } else if (e instanceof IAdaptable) {
+                                       ICElement c = (ICElement) ((IAdaptable) e).getAdapter(ICElement.class);
+                                       if (c != null) {
+                                               converted.add(c);
+                                       } else if (keepNonCElements)
+                                               converted.add(e);
+                               } else if (keepNonCElements)
+                                       converted.add(e);
+                       }
+               }
+               return new StructuredSelection(converted.toArray());
+       }
+
+       public static IStructuredSelection convertSelectionToResources(ISelection s) {
+               List<Object> converted = new ArrayList<Object>();
+               if (s instanceof StructuredSelection) {
+                       Object[] elements = ((StructuredSelection) s).toArray();
+                       for (int i = 0; i < elements.length; i++) {
+                               Object e = elements[i];
+                               if (e instanceof IResource) {
+                                       converted.add(e);
+                               } else if (e instanceof IAdaptable) {
+                                       IResource r = (IResource) ((IAdaptable) e).getAdapter(IResource.class);
+                                       if (r != null) {
+                                               converted.add(r);
+                                       }
+                               }
+                       }
+               }
+               return new StructuredSelection(converted.toArray());
+       }
+
+       public static boolean allResourcesAreOfType(IStructuredSelection selection, int resourceMask) {
+               Iterator<?> resources = selection.iterator();
+               while (resources.hasNext()) {
+                       Object next = resources.next();
+                       if (next instanceof IAdaptable) {
+                               IAdaptable element = (IAdaptable) next;
+                               IResource resource = (IResource) element.getAdapter(IResource.class);
+
+                               if (resource == null) {
+                                       return false;
+                               }
+                               if (!resourceIsType(resource, resourceMask)) {
+                                       return false;
+                               }
+                       }
+               }
+               return true;
+       }
+
+       /**
+        * Returns the selection adapted to IResource. Returns null if any of the
+        * entries are not adaptable.
+        * 
+        * @param selection
+        *            the selection
+        * @param resourceMask
+        *            resource mask formed by bitwise OR of resource type constants
+        *            (defined on <code>IResource</code>)
+        * @return IStructuredSelection or null if any of the entries are not
+        *         adaptable.
+        * @see IResource#getType()
+        */
+       public static IStructuredSelection allResources(IStructuredSelection selection, int resourceMask) {
+               Iterator<?> adaptables = selection.iterator();
+               List<IResource> result = new ArrayList<IResource>();
+               while (adaptables.hasNext()) {
+                       Object next = adaptables.next();
+                       if (next instanceof IAdaptable) {
+                               IResource resource = (IResource) ((IAdaptable) next).getAdapter(IResource.class);
+                               if (resource == null) {
+                                       return null;
+                               } else if (resourceIsType(resource, resourceMask)) {
+                                       result.add(resource);
+                               }
+                       } else {
+                               return null;
+                       }
+               }
+               return new StructuredSelection(result);
+
+       }
+
+       public static ICElement getElementAtOffset(ITextEditor editor) throws CModelException {
+               return getElementAtOffset(getInput(editor), (ITextSelection) editor.getSelectionProvider().getSelection());
+       }
+
+       public static ICElement[] getElementsAtOffset(ITextEditor editor) throws CModelException {
+               return getElementsAtOffset(getInput(editor), (ITextSelection) editor.getSelectionProvider().getSelection());
+       }
+
+       public static ICElement getElementAtOffset(ICElement input, ITextSelection selection) throws CModelException {
+               if (input instanceof ITranslationUnit) {
+                       ITranslationUnit tunit = (ITranslationUnit) input;
+                       if (tunit.isWorkingCopy() && tunit.isOpen()) {
+                               synchronized (tunit) {
+                                       if (tunit instanceof IWorkingCopy) {
+                                               ((IWorkingCopy) tunit).reconcile();
+                                       }
+                               }
+                       }
+                       ICElement ref = tunit.getElementAtOffset(selection.getOffset());
+                       if (ref == null)
+                               return input;
+                       return ref;
+               }
+               return null;
+       }
+
+       public static ICElement[] getElementsAtOffset(ICElement input, ITextSelection selection) throws CModelException {
+               if (input instanceof ITranslationUnit) {
+                       ITranslationUnit tunit = (ITranslationUnit) input;
+                       if (tunit.isWorkingCopy() && tunit.isOpen()) {
+                               synchronized (tunit) {
+                                       if (tunit instanceof IWorkingCopy) {
+                                               ((IWorkingCopy) tunit).reconcile();
+                                       }
+                               }
+                       }
+                       ICElement[] refs = tunit.getElementsAtOffset(selection.getOffset());
+                       if (refs == null)
+                               return new ICElement[] { input };
+                       return refs;
+               }
+               return null;
+       }
+
+       public static ICElement getInput(ITextEditor editor) {
+               if (editor == null) return null;
+               IEditorInput input = editor.getEditorInput();
+               IWorkingCopyManager manager = CUIPlugin.getDefault().getWorkingCopyManager();
+               return manager.getWorkingCopy(input);
+       }
+
+       /**
+        * Returns whether the type of the given resource is among the specified
+        * resource types.
+        * 
+        * @param resource
+        *            the resource
+        * @param resourceMask
+        *            resource mask formed by bitwise OR of resource type constants
+        *            (defined on <code>IResource</code>)
+        * @return <code>true</code> if the resources has a matching type, and
+        *         <code>false</code> otherwise
+        * @see IResource#getType()
+        */
+       public static boolean resourceIsType(IResource resource, int resourceMask) {
+               return (resource.getType() & resourceMask) != 0;
+       }
+
+       public static ICElement[] codeResolve(CEditor editor) throws CModelException {
+               return codeResolve(getInput(editor), (ITextSelection)editor.getSelectionProvider().getSelection());
+       }
+
+       public static ICElement[] codeResolve(ICElement input, ITextSelection selection) throws CModelException {
+               if (input instanceof ITranslationUnit) {
+                       ITranslationUnit tunit = (ITranslationUnit) input;
+                       if (tunit.isWorkingCopy() && tunit.isOpen()) {
+                               synchronized (tunit) {
+                                       if (tunit instanceof IWorkingCopy) {
+                                               ((IWorkingCopy) tunit).reconcile();
+                                       }
+                               }
+                       }
+               ICElement[] elems = tunit.getElementsAtOffset(selection.getOffset());
+               if (elems != null) {
+                   for (int i = 0; i < elems.length; ++i) {
+                       ICElement elem = elems[i];
+                       if (elem instanceof ISourceReference) {
+                           String text = selection.getText();
+                           if (text.equals(elem.getElementName())) {
+                               return new ICElement[] { elem };
+                           }
+                       }
+                   }
+                   for (int i = 0; i < elems.length; ++i) {
+                       ICElement elem = elems[i];
+                       if (elem instanceof ISourceReference) {
+                           ISourceRange range = ((ISourceReference)elem).getSourceRange();
+                           if (range.getStartPos() == selection.getOffset()) {
+                               return new ICElement[] { elem };
+                           }
+                       }
+                   }
+               }
+           }
+               return EMPTY_RESULT;
+       }
+       
+       /**
+        * Converts the text selection provided by the given editor a Java element by
+        * asking the user if code reolve returned more than one result. If the selection 
+        * doesn't cover a Java element <code>null</code> is returned.
+        */
+       public static ICElement codeResolve(CEditor editor, Shell shell, String title, String message) throws CModelException {
+           ICElement[] elements= codeResolve(editor);
+               if (elements == null || elements.length == 0)
+                       return null;
+               ICElement candidate= elements[0];
+               if (elements.length > 1) {
+                       candidate= OpenActionUtil.selectCElement(elements, shell, title, message);
+               }
+               return candidate;
+       }
+       
+
+       /**
+        * Converts the text selection provided by the given editor into an array of
+        * C elements. If the selection doesn't cover a C element and the selection's
+        * length is greater than 0 the method returns the editor's input element.
+        */
+       public static ICElement[] codeResolveOrInput(CEditor editor) throws CModelException {
+           ICElement input= getInput(editor);
+               ITextSelection selection= (ITextSelection)editor.getSelectionProvider().getSelection();
+               ICElement[] result= codeResolve(input, selection);
+               if (result.length == 0) {
+                       result= new ICElement[] {input};
+               }
+               return result;
+       }
+
+       public static ICElement[] codeResolveOrInputHandled(CEditor editor, Shell shell, String title) {
+               try {
+                       return codeResolveOrInput(editor);
+               } catch(CModelException e) {
+                       ExceptionHandler.handle(e, shell, title, ActionMessages.SelectionConverter_codeResolve_failed);
+               }
+               return null;
+       }
+       
+       public static boolean canOperateOn(CEditor editor) {
+               if (editor == null)
+                       return false;
+               return getInput(editor) != null;
+               
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectEnclosingAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectEnclosingAction.java
new file mode 100644 (file)
index 0000000..a9628e4
--- /dev/null
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Tomasz Wesolowski and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Tomasz Wesolowski - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.actions;
+
+import java.util.ResourceBundle;
+
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTNodeSelector;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.model.ISourceRange;
+
+import org.eclipse.cdt.internal.core.model.ext.SourceRange;
+
+import org.eclipse.cdt.internal.ui.editor.SelectionHistory;
+
+public class StructureSelectEnclosingAction extends StructureSelectionAction {
+
+       public static final String PREFIX = "StructureSelectEnclosing."; //$NON-NLS-1$
+
+       public StructureSelectEnclosingAction(ResourceBundle bundle, ITextEditor editor, SelectionHistory history) {
+               super(bundle, PREFIX, editor, history);
+       }
+
+       @Override
+       public ISourceRange doExpand(IASTTranslationUnit ast, SourceRange current) {
+
+               ISourceRange newSourceRange = expandToEnclosing(ast, current);
+               if (newSourceRange != null) {
+                       history.remember(current);
+               }
+               return newSourceRange;
+       }
+       
+       /**
+        * Made public to serve as fallback for other expansions
+        */
+       public static ISourceRange expandToEnclosing(IASTTranslationUnit ast, SourceRange current) {
+               final IASTNodeSelector nodeSelector = ast.getNodeSelector(null);
+               IASTNode node = nodeSelector.findStrictlyEnclosingNode(current.getStartPos(), current.getLength());
+               if (node == null)
+                       return null;
+               
+               final IASTFileLocation fileLocation = node.getFileLocation();
+               return new SourceRange(fileLocation.getNodeOffset(), fileLocation.getNodeLength());
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectHistoryAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectHistoryAction.java
new file mode 100644 (file)
index 0000000..8cc07e9
--- /dev/null
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Tomasz Wesolowski - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.actions;
+
+import java.util.ResourceBundle;
+
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.model.ISourceRange;
+
+import org.eclipse.cdt.internal.core.model.ext.SourceRange;
+
+import org.eclipse.cdt.internal.ui.editor.SelectionHistory;
+
+public class StructureSelectHistoryAction extends StructureSelectionAction {
+
+       public static final String PREFIX = "StructureSelectHistory."; //$NON-NLS-1$
+
+       public StructureSelectHistoryAction(ResourceBundle bundle, ITextEditor editor,
+                       SelectionHistory history) {
+               super(bundle, PREFIX, editor, history);
+       }
+
+       @Override
+       protected ISourceRange doExpand(IASTTranslationUnit ast, SourceRange currentSourceRange) {
+               if (!history.isEmpty()) {
+                       return history.getLast();
+               }
+               return null;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectNextAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectNextAction.java
new file mode 100644 (file)
index 0000000..6c97641
--- /dev/null
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Tomasz Wesolowski and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Tomasz Wesolowski - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.actions;
+
+import java.util.ResourceBundle;
+
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.model.ISourceRange;
+
+import org.eclipse.cdt.internal.core.model.ext.SourceRange;
+
+import org.eclipse.cdt.internal.ui.editor.SelectionHistory;
+
+public class StructureSelectNextAction extends StructureSelectionAction {
+
+       public static final String PREFIX = "StructureSelectNext."; //$NON-NLS-1$
+
+       public StructureSelectNextAction(ResourceBundle bundle, ITextEditor editor,
+                       SelectionHistory history) {
+               super(bundle, PREFIX, editor, history);
+       }
+
+       @Override
+       public ISourceRange doExpand(IASTTranslationUnit ast, SourceRange current) {
+               
+               ISourceRange newSourceRange = expandToNext(ast, current);
+               if (newSourceRange == null) {
+                       newSourceRange = StructureSelectEnclosingAction.expandToEnclosing(ast, current); 
+               }
+               if (newSourceRange != null) {
+                       history.remember(current);
+               }                       
+               return newSourceRange;
+       }
+
+       private ISourceRange expandToNext(IASTTranslationUnit ast, SourceRange current) {
+               
+               IASTNode enclosingNode = ast.getNodeSelector(null).findEnclosingNode(current.getStartPos(),
+                               current.getLength());
+               if (samePosition(enclosingNode, current)) {
+                       enclosingNode = enclosingNode.getParent();
+               }
+               if (enclosingNode == null) {
+                       return null;
+               }
+               
+               // find the last child of enclosingNode containing selection end
+               
+               int selectionEnd = current.getStartPos()+current.getLength();
+               
+               int lastSelectedChildIndex = -1;
+               IASTNode[] children = enclosingNode.getChildren();
+               for (int i = 0; i < children.length; i++) {
+                       IASTNode node = children[i];
+                       if (nodeContains(node, selectionEnd)) {
+                               lastSelectedChildIndex = i;
+                               break;
+                       }
+               }
+               
+               if (lastSelectedChildIndex != -1 && lastSelectedChildIndex+1 < children.length) {
+                       IASTNode nextNode = children[lastSelectedChildIndex+1];
+                       int endingOffset = nextNode.getFileLocation().getNodeOffset()+nextNode.getFileLocation().getNodeLength();
+                       return new SourceRange(current.getStartPos(),endingOffset-current.getStartPos());
+               }
+               return null;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectPreviousAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectPreviousAction.java
new file mode 100644 (file)
index 0000000..ecf7eac
--- /dev/null
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Tomasz Wesolowski and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Tomasz Wesolowski - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.actions;
+
+import java.util.ResourceBundle;
+
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.model.ISourceRange;
+
+import org.eclipse.cdt.internal.core.model.ext.SourceRange;
+
+import org.eclipse.cdt.internal.ui.editor.SelectionHistory;
+
+public class StructureSelectPreviousAction extends StructureSelectionAction {
+
+       public static final String PREFIX = "StructureSelectPrevious."; //$NON-NLS-1$
+
+       public StructureSelectPreviousAction(ResourceBundle bundle, ITextEditor editor,
+                       SelectionHistory history) {
+               super(bundle, PREFIX, editor, history);
+       }
+       
+       @Override
+       public ISourceRange doExpand(IASTTranslationUnit ast, SourceRange current) {
+               
+               ISourceRange newSourceRange = expandToPrevious(ast, current);
+               if (newSourceRange == null) {
+                       newSourceRange = StructureSelectEnclosingAction.expandToEnclosing(ast, current); 
+               }
+               if (newSourceRange != null) {
+                       history.remember(current);
+               }                       
+               return newSourceRange;
+       }
+
+       private ISourceRange expandToPrevious(IASTTranslationUnit ast, SourceRange current) {
+               
+               IASTNode enclosingNode = ast.getNodeSelector(null).findEnclosingNode(current.getStartPos(),
+                               current.getLength());
+               if (samePosition(enclosingNode, current)) {
+                       enclosingNode = enclosingNode.getParent();
+               }
+               if (enclosingNode == null) {
+                       return null;
+               }
+               
+               // find the first child of enclosingNode containing selection end
+               
+               int selectionStart = current.getStartPos();
+               
+               int firstSelectedChildIndex = -1;
+               IASTNode[] children = enclosingNode.getChildren();
+               for (int i = 0; i < children.length; i++) {
+                       IASTNode node = children[i];
+                       if (nodeContains(node, selectionStart)) {
+                               firstSelectedChildIndex = i;
+                               break;
+                       }
+               }
+               
+               if (firstSelectedChildIndex != -1 && firstSelectedChildIndex-1 >= 0) {
+                       IASTNode prevNode = children[firstSelectedChildIndex-1];
+                       int endingOffset = current.getStartPos() + current.getLength();
+                       return new SourceRange(prevNode.getFileLocation().getNodeOffset(), endingOffset - prevNode.getFileLocation().getNodeOffset());
+               }
+               return null;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectionAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectionAction.java
new file mode 100644 (file)
index 0000000..13f1aca
--- /dev/null
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Tomasz Wesolowski and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Tomasz Wesolowski - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.actions;
+
+import java.util.ResourceBundle;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.TextEditorAction;
+
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.ISourceRange;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CDTUITools;
+import org.eclipse.cdt.ui.text.SharedASTJob;
+
+import org.eclipse.cdt.internal.core.model.ext.SourceRange;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.editor.SelectionHistory;
+
+public abstract class StructureSelectionAction extends TextEditorAction {
+
+       protected final SelectionHistory history;
+
+       protected StructureSelectionAction(ResourceBundle bundle, String prefix, ITextEditor editor, SelectionHistory history) {
+               super(bundle, prefix, editor);
+               this.history = history;
+       }
+
+       private final class ExpandSelectionJob extends SharedASTJob {
+               public ISourceRange newSourceRange;
+               private SourceRange currentSourceRange;
+
+               private ExpandSelectionJob(String name, ITranslationUnit tUnit, CEditor cEditor, SourceRange range) {
+                       super(name, tUnit);
+                       currentSourceRange = range;
+                       newSourceRange = null;
+               }
+
+               @Override
+               public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
+                       newSourceRange = doExpand(ast,currentSourceRange);
+                       return Status.OK_STATUS;
+               }
+       }
+
+       public static final String ENCLOSING = "StructureSelectEnclosing"; //$NON-NLS-1$
+       public static final String NEXT = "StructureSelectNext"; //$NON-NLS-1$
+       public static final String PREVIOUS = "StructureSelectPrevious"; //$NON-NLS-1$
+       public static final String HISTORY = "StructureSelectHistory"; //$NON-NLS-1$
+       
+       @Override
+       public void run() {
+               IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+               if (!(editorPart instanceof CEditor)) {
+                       return;
+               }
+               final CEditor cEditor = (CEditor) editorPart;
+
+               ITranslationUnit tu = (ITranslationUnit) CDTUITools.getEditorInputCElement(cEditor.getEditorInput());
+               
+               ITextSelection selection;
+               try {
+                       selection = (ITextSelection) cEditor.getSelectionProvider().getSelection();
+               } catch (ClassCastException e) {
+                       return;
+               }
+               
+               final int offset = selection.getOffset();
+               final int length = selection.getLength();
+               
+               ExpandSelectionJob expandSelectionJob = new ExpandSelectionJob("expand selection", tu, cEditor, new SourceRange(offset, length)); //$NON-NLS-1$
+               
+               expandSelectionJob.schedule();
+               try {
+                       expandSelectionJob.join();
+               } catch (InterruptedException e) {
+                       return;
+               }
+               
+               if (expandSelectionJob.newSourceRange != null) {
+                       history.ignoreSelectionChanges();
+                       cEditor.setSelection(expandSelectionJob.newSourceRange, true);
+                       history.listenToSelectionChanges();
+               }
+       }
+
+       protected abstract ISourceRange doExpand(IASTTranslationUnit ast, SourceRange currentSourceRange);
+
+       protected boolean nodeContains(IASTNode node, int position) {
+               IASTFileLocation fl = node.getFileLocation();
+               return position >= fl.getNodeOffset() && position <= fl.getNodeOffset() + fl.getNodeLength();
+       }
+
+       protected boolean samePosition(IASTNode node, SourceRange current) {
+               IASTFileLocation fl = node.getFileLocation();
+               return fl.getNodeOffset() == current.getStartPos() && fl.getNodeLength() == current.getLength();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithActionGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithActionGroup.java
new file mode 100644 (file)
index 0000000..087b44e
--- /dev/null
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Axel Mueller - [289339] ported from JDT to CDT
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+
+public class SurroundWithActionGroup extends ActionGroup {
+
+       private CEditor fEditor;
+       private final String fGroup;
+
+       public SurroundWithActionGroup(CEditor editor, String group) {
+               fEditor= editor;
+               fGroup= group;
+       }
+
+       /**
+        * The Menu to show when right click on the editor
+        * {@inheritDoc}
+        */
+       @Override
+       public void fillContextMenu(IMenuManager menu) {
+               ISelectionProvider selectionProvider= fEditor.getSelectionProvider();
+               if (selectionProvider == null)
+                       return;
+
+               ISelection selection= selectionProvider.getSelection();
+               if (!(selection instanceof ITextSelection))
+                       return;
+
+               ITextSelection textSelection= (ITextSelection)selection;
+               if (textSelection.getLength() == 0)
+                       return;
+
+               String menuText= ActionMessages.SurroundWithTemplateMenuAction_SubMenuName;
+
+               MenuManager subMenu = new MenuManager(menuText, SurroundWithTemplateMenuAction.SURROUND_WITH_QUICK_MENU_ACTION_ID);
+               subMenu.setActionDefinitionId(SurroundWithTemplateMenuAction.SURROUND_WITH_QUICK_MENU_ACTION_ID);
+               menu.appendToGroup(fGroup, subMenu);
+               subMenu.add(new Action() {});
+               subMenu.addMenuListener(new IMenuListener() {
+                       public void menuAboutToShow(IMenuManager manager) {
+                               manager.removeAll();
+                               SurroundWithTemplateMenuAction.fillMenu(manager, fEditor);
+                       }
+               });
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuAction.java
new file mode 100644 (file)
index 0000000..470af5a
--- /dev/null
@@ -0,0 +1,387 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Axel Mueller - [289339] ported from JDT to CDT
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.actions;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.swt.events.MenuAdapter;
+import org.eclipse.swt.events.MenuEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.core.runtime.Assert;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IEditingSupport;
+import org.eclipse.jface.text.IEditingSupportRegistry;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.IRewriteTarget;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.ITextViewerExtension;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2;
+
+import org.eclipse.ui.IPartListener;
+import org.eclipse.ui.IPartService;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
+import org.eclipse.ui.actions.QuickMenuCreator;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.text.contentassist.CContentAssistInvocationContext;
+import org.eclipse.cdt.internal.ui.text.contentassist.TemplateCompletionProposalComputer;
+
+public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownDelegate2 {
+
+       public static final String SURROUND_WITH_QUICK_MENU_ACTION_ID= "org.eclipse.cdt.ui.edit.text.c.surround.with.quickMenu";  //$NON-NLS-1$
+
+       private static final String C_TEMPLATE_PREFERENCE_PAGE_ID= "org.eclipse.cdt.ui.preferences.TemplatePreferencePage"; //$NON-NLS-1$
+
+       private static final String TEMPLATE_GROUP= "templateGroup"; //$NON-NLS-1$
+
+       private static final String CONFIG_GROUP= "configGroup"; //$NON-NLS-1$
+       
+       private static class ConfigureTemplatesAction extends Action {
+
+               public ConfigureTemplatesAction() {
+                       super(ActionMessages.SurroundWithTemplateMenuAction_ConfigureTemplatesActionName);
+               }
+
+               /**
+                * {@inheritDoc}
+                */
+               @Override
+               public void run() {
+                       PreferencesUtil.createPreferenceDialogOn(getShell(), C_TEMPLATE_PREFERENCE_PAGE_ID, new String[] {C_TEMPLATE_PREFERENCE_PAGE_ID}, null).open();
+               }
+
+               private Shell getShell() {
+                       return CUIPlugin.getActiveWorkbenchShell();
+               }
+       }
+
+       private static Action NONE_APPLICABLE_ACTION= new Action(ActionMessages.SurroundWithTemplateMenuAction_NoneApplicable) {
+               @Override
+               public void run() {
+                       //Do nothing
+               }
+               @Override
+               public boolean isEnabled() {
+                       return false;
+               }
+       };
+
+       private Menu fMenu;
+       private IPartService fPartService;
+       private IPartListener fPartListener= new IPartListener() {
+
+               public void partActivated(IWorkbenchPart part) {
+               }
+
+               public void partBroughtToTop(IWorkbenchPart part) {
+               }
+
+               public void partClosed(IWorkbenchPart part) {
+               }
+
+               public void partDeactivated(IWorkbenchPart part) {
+                       disposeMenuItems();
+               }
+
+               public void partOpened(IWorkbenchPart part) {
+               }
+       };
+
+       protected void disposeMenuItems() {
+               if (fMenu == null || fMenu.isDisposed()) {
+                       return;
+               }
+               MenuItem[] items = fMenu.getItems();
+               for (int i= 0; i < items.length; i++) {
+                       MenuItem menuItem= items[i];
+                       if (!menuItem.isDisposed()) {
+                               menuItem.dispose();
+                       }
+               }
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public Menu getMenu(Menu parent) {
+               setMenu(new Menu(parent));
+               fillMenu(fMenu);
+               initMenu();
+               return fMenu;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public Menu getMenu(Control parent) {
+               setMenu(new Menu(parent));
+               fillMenu(fMenu);
+               initMenu();
+               return fMenu;
+       }
+
+       public static void fillMenu(IMenuManager menu, CEditor editor) {
+               IAction[] actions= getTemplateActions(editor);
+               if (actions == null || actions.length == 0) {
+                       menu.add(NONE_APPLICABLE_ACTION);
+               } else {
+                       menu.add(new Separator(TEMPLATE_GROUP));
+                       for (int i= 0; i < actions.length; i++)
+                               menu.add(actions[i]);
+               }
+
+               menu.add(new Separator(CONFIG_GROUP));
+               menu.add(new ConfigureTemplatesAction());
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void dispose() {
+               if (fPartService != null) {
+                       fPartService.removePartListener(fPartListener);
+                       fPartService= null;
+               }
+               setMenu(null);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void init(IWorkbenchWindow window) {
+               if (fPartService != null) {
+                       fPartService.removePartListener(fPartListener);
+                       fPartService= null;
+               }
+
+               if (window != null) {
+                       IPartService partService= window.getPartService();
+                       if (partService != null) {
+                               fPartService= partService;
+                               partService.addPartListener(fPartListener);
+                       }
+               }
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void run(IAction action) {
+               IWorkbenchPart activePart= CUIPlugin.getActivePage().getActivePart();
+               if (!(activePart instanceof CEditor))
+                       return;
+
+               final CEditor editor= (CEditor) activePart;
+
+               new QuickMenuCreator() {
+                       @Override
+                       protected void fillMenu(IMenuManager menu) {
+                               SurroundWithTemplateMenuAction.fillMenu(menu, editor);
+                       }
+               }.createMenu();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void selectionChanged(IAction action, ISelection selection) {
+               // Default do nothing
+       }
+
+       /**
+        * The menu to show in the workbench menu
+        * @param menu the menu to fill entries into it
+        */
+       protected void fillMenu(Menu menu) {
+
+               IWorkbenchPart activePart= CUIPlugin.getActivePage().getActivePart();
+               if (!(activePart instanceof CEditor)) {
+                       ActionContributionItem item= new ActionContributionItem(NONE_APPLICABLE_ACTION);
+                       item.fill(menu, -1);
+                       return;
+               }
+
+               CEditor editor= (CEditor)activePart;
+               IAction[] actions= getTemplateActions(editor);
+
+               if ( actions == null || actions.length <= 0) {
+                       ActionContributionItem item= new ActionContributionItem(NONE_APPLICABLE_ACTION);
+                       item.fill(menu, -1);
+               } else {
+                       for (int i= 0; i < actions.length; i++) {
+                               ActionContributionItem item= new ActionContributionItem(actions[i]);
+                               item.fill(menu, -1);
+                       }
+               }
+
+               Separator configGroup= new Separator(CONFIG_GROUP);
+               configGroup.fill(menu, -1);
+
+               ActionContributionItem configAction= new ActionContributionItem(new ConfigureTemplatesAction());
+               configAction.fill(menu, -1);
+
+       }
+
+       protected void initMenu() {
+               fMenu.addMenuListener(new MenuAdapter() {
+                       @Override
+                       public void menuShown(MenuEvent e) {
+                               Menu m = (Menu)e.widget;
+                               MenuItem[] items = m.getItems();
+                               for (int i=0; i < items.length; i++) {
+                                       items[i].dispose();
+                               }
+                               fillMenu(m);
+                       }
+               });
+       }
+
+       private void setMenu(Menu menu) {
+               if (fMenu != null) {
+                       fMenu.dispose();
+               }
+               fMenu = menu;
+       }
+
+       private static IAction[] getTemplateActions(CEditor editor) {
+               ITextSelection textSelection= getTextSelection(editor);
+               if (textSelection == null || textSelection.getLength() == 0)
+                       return null;
+                       
+               ITranslationUnit tu= CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
+               if (tu == null)
+                       return null;
+
+               TemplateCompletionProposalComputer templateComputer = new TemplateCompletionProposalComputer();
+               CContentAssistInvocationContext context = new CContentAssistInvocationContext( editor.getViewer(), textSelection.getOffset(), editor, true, false );
+       
+               List<ICompletionProposal> proposals= templateComputer.computeCompletionProposals(context, null);
+               if (proposals == null || proposals.isEmpty())
+                       return null;
+               
+               return getActionsFromProposals(proposals, context.getInvocationOffset(), editor.getViewer());
+       }
+
+       private static ITextSelection getTextSelection(CEditor editor) {
+               ISelectionProvider selectionProvider= editor.getSelectionProvider();
+               if (selectionProvider == null)
+                       return null;
+
+               ISelection selection= selectionProvider.getSelection();
+               if (!(selection instanceof ITextSelection))
+                       return null;
+
+               return (ITextSelection)selection;
+       }
+
+       private static IAction[] getActionsFromProposals(List<ICompletionProposal> proposals, final int offset, final ITextViewer viewer) {
+               List<Action> result= new ArrayList<Action>();
+               int j = 1;
+               for (Iterator<ICompletionProposal> it= proposals.iterator(); it.hasNext();) {
+                       final ICompletionProposal proposal= it.next();
+
+                       StringBuffer actionName= new StringBuffer();
+                       if (j < 10) {
+                               actionName.append('&').append(j).append(' ');
+                       }
+                       actionName.append(proposal.getDisplayString());
+                       Action action= new Action(actionName.toString()) {
+                               /**
+                                * {@inheritDoc}
+                                */
+                               @Override
+                               public void run() {
+                                       applyProposal(proposal, viewer, (char)0, 0, offset);
+                               }
+                       };
+
+                       result.add(action);
+                       j++;
+               }
+               if (result.size() == 0)
+                       return null;
+
+               return result.toArray(new IAction[result.size()]);
+       }
+
+       private static void applyProposal(ICompletionProposal proposal, ITextViewer viewer, char trigger, int stateMask, final int offset) {
+               Assert.isTrue(proposal instanceof ICompletionProposalExtension2);
+
+               IRewriteTarget target= null;
+               IEditingSupportRegistry registry= null;
+               IEditingSupport helper= new IEditingSupport() {
+
+                       public boolean isOriginator(DocumentEvent event, IRegion focus) {
+                               return focus.getOffset() <= offset && focus.getOffset() + focus.getLength() >= offset;
+                       }
+
+                       public boolean ownsFocusShell() {
+                               return false;
+                       }
+               };
+
+               try {
+                       IDocument document= viewer.getDocument();
+
+                       if (viewer instanceof ITextViewerExtension) {
+                               ITextViewerExtension extension= (ITextViewerExtension) viewer;
+                               target= extension.getRewriteTarget();
+                       }
+
+                       if (target != null)
+                               target.beginCompoundChange();
+
+                       if (viewer instanceof IEditingSupportRegistry) {
+                               registry= (IEditingSupportRegistry) viewer;
+                               registry.register(helper);
+                       }
+
+                       ((ICompletionProposalExtension2)proposal).apply(viewer, trigger, stateMask, offset);
+
+                       Point selection= proposal.getSelection(document);
+                       if (selection != null) {
+                               viewer.setSelectedRange(selection.x, selection.y);
+                               viewer.revealRange(selection.x, selection.y);
+                       }
+               } finally {
+                       if (target != null)
+                               target.endCompoundChange();
+
+                       if (registry != null)
+                               registry.unregister(helper);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/UpdateIndexWithModifiedFilesAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/UpdateIndexWithModifiedFilesAction.java
new file mode 100644 (file)
index 0000000..d8fbca4
--- /dev/null
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.actions;
+
+import org.eclipse.cdt.core.index.IIndexManager;
+
+public class UpdateIndexWithModifiedFilesAction extends AbstractUpdateIndexAction {
+
+       @Override
+       protected int getUpdateOptions() {
+               return IIndexManager.UPDATE_CHECK_TIMESTAMPS | IIndexManager.UPDATE_CHECK_CONFIGURATION |
+               IIndexManager.UPDATE_EXTERNAL_FILES_FOR_PROJECT | IIndexManager.UPDATE_CHECK_CONTENTS_HASH;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/WorkbenchRunnableAdapter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/WorkbenchRunnableAdapter.java
new file mode 100644 (file)
index 0000000..c7ac589
--- /dev/null
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.actions;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.internal.ui.CUIStatus;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.Job;
+
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.operation.IThreadListener;
+
+/**
+ * An <code>IRunnableWithProgress</code> that adapts and  <code>IWorkspaceRunnable</code>
+ * so that is can be executed inside <code>IRunnableContext</code>. <code>OperationCanceledException</code> 
+ * thrown by the adapted runnable are caught and re-thrown as a <code>InterruptedException</code>.
+ */
+public class WorkbenchRunnableAdapter implements IRunnableWithProgress, IThreadListener {
+       private IWorkspaceRunnable fWorkspaceRunnable;
+       private ISchedulingRule fRule;
+       private boolean fTransfer;
+       
+       /**
+        * Runs a workspace runnable with the workspace lock.
+        */
+       public WorkbenchRunnableAdapter(IWorkspaceRunnable runnable) {
+               this(runnable, ResourcesPlugin.getWorkspace().getRoot());
+       }
+       
+       /**
+        * Runs a workspace runnable with the given lock or <code>null</code> to run with no lock at all.
+        */
+       public WorkbenchRunnableAdapter(IWorkspaceRunnable runnable, ISchedulingRule rule) {
+               fWorkspaceRunnable= runnable;
+               fRule= rule;
+       }
+       
+       /**
+        * Runs a workspace runnable with the given lock or <code>null</code> to run with no lock at
+        * all.
+        * 
+        * @param runnable the runnable
+        * @param rule the scheduling rule, or <code>null</code>
+        * @param transfer <code>true</code> iff the rule is to be transfered to the modal context
+        *            thread
+        */
+       public WorkbenchRunnableAdapter(IWorkspaceRunnable runnable, ISchedulingRule rule, boolean transfer) {
+               fWorkspaceRunnable= runnable;
+               fRule= rule;
+               fTransfer= transfer;
+       }
+
+       public ISchedulingRule getSchedulingRule() {
+               return fRule;
+       }
+
+       public void threadChange(Thread thread) {
+               if (fTransfer)
+                       Job.getJobManager().transferRule(fRule, thread);
+       }
+
+       /*
+        * @see IRunnableWithProgress#run(IProgressMonitor)
+        */
+       public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+               try {
+                       CoreModel.run(fWorkspaceRunnable, fRule, monitor);
+               } catch (OperationCanceledException e) {
+                       throw new InterruptedException(e.getMessage());
+               } catch (CoreException e) {
+                       throw new InvocationTargetException(e);
+               }
+       }
+       
+       public void runAsUserJob(String name, final Object jobFamiliy) {
+               Job buildJob = new Job(name){ 
+                       /* (non-Javadoc)
+                        * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
+                        */
+                       @Override
+                       protected IStatus run(IProgressMonitor monitor) {
+                               try {
+                                       WorkbenchRunnableAdapter.this.run(monitor);
+                               } catch (InvocationTargetException e) {
+                                       Throwable cause= e.getCause();
+                                       if (cause instanceof CoreException) {
+                                               return ((CoreException) cause).getStatus();
+                                       }
+                                       return CUIStatus.createError(IStatus.ERROR, cause);
+                               } catch (InterruptedException e) {
+                                       return Status.CANCEL_STATUS;
+                               } finally {
+                                       monitor.done();
+                               }
+                               return Status.OK_STATUS;
+                       }
+                       @Override
+                       public boolean belongsTo(Object family) {
+                               return jobFamiliy == family;
+                       }
+               };
+               buildJob.setRule(fRule);
+               buildJob.setUser(true); 
+               buildJob.schedule();
+               
+               // TODO: should block until user pressed 'to background'
+       }
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java
new file mode 100644 (file)
index 0000000..6f1a856
--- /dev/null
@@ -0,0 +1,404 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.browser.opentype;
+
+import java.util.Arrays;
+import java.util.HashSet;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.jface.wizard.ProgressMonitorPart;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.browser.ITypeInfo;
+import org.eclipse.cdt.core.browser.IndexTypeInfo;
+import org.eclipse.cdt.core.browser.QualifiedTypeName;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexBinding;
+import org.eclipse.cdt.core.index.IIndexMacro;
+import org.eclipse.cdt.core.index.IndexFilter;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog;
+
+import org.eclipse.cdt.internal.core.browser.IndexModelUtil;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+
+/**
+ * A dialog to select an element from a filterable list of elements.
+ *
+ * @since 4.0
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class ElementSelectionDialog extends TypeSelectionDialog {
+       /**
+        * Job to update the element list in the background.
+        */
+       private class UpdateElementsJob extends Job {
+               /**
+                * The last used prefix to query the index. <code>null</code> means
+                * the query result should be empty.
+                */
+               private volatile char[] fCurrentPrefix = null;
+
+               public UpdateElementsJob(String name) {
+                       super(name);
+                       setSystem(true);
+                       setUser(false);
+                       setPriority(Job.LONG);
+               }
+
+               public char[] getCurrentPrefix() {
+                       return fCurrentPrefix;
+               }
+               public void scheduleQuery(char[] prefix) {
+                       fCurrentPrefix= prefix;
+                       int delay = fCurrentPrefix == null ? 0 : (fCurrentPrefix.length < 5 ? 400 : 200);
+                       schedule(delay);
+               }
+
+               @Override
+               public IStatus run(final IProgressMonitor monitor) {
+                       monitor.beginTask(OpenTypeMessages.ElementSelectionDialog_UpdateElementsJob_inProgress, IProgressMonitor.UNKNOWN);
+                       final ITypeInfo[] elements= getElementsByPrefix(fCurrentPrefix, monitor);
+                       if (elements != null && !monitor.isCanceled()) {
+                               final Shell shell= getShell();
+                               if (shell != null && !shell.isDisposed()) {
+                                       Runnable update= new Runnable() {
+                                               public void run() {
+                                                       if (!shell.isDisposed() && !monitor.isCanceled()) {
+                                                               setListElements(elements);
+                                                               updateOkState();
+                                                       }
+                                               }};
+                                       shell.getDisplay().asyncExec(update);
+                                       monitor.done();
+                                       return Status.OK_STATUS;
+                               }
+                       }
+                       return Status.CANCEL_STATUS;
+               }
+       }
+
+       /**
+        * A job listener for simple job status reporting.
+        */
+       private final class UpdateJobListener extends JobChangeAdapter {
+               boolean fDone;
+               private IProgressMonitor fMonitor;
+
+               private UpdateJobListener(IProgressMonitor monitor) {
+                       fMonitor= monitor;
+               }
+
+               @Override
+               public void done(IJobChangeEvent event) {
+                       fDone= true;
+                       final Shell shell= getShell();
+                       if (shell != null && !shell.isDisposed()) {
+                               Runnable update= new Runnable() {
+                                       public void run() {
+                                               if (!shell.isDisposed() && fDone) {
+                                                       fMonitor.done();
+                                               }
+                                       }};
+                               shell.getDisplay().asyncExec(update);
+                       }
+               }
+
+               @Override
+               public void running(final IJobChangeEvent event) {
+                       fDone= false;
+                       final Shell shell= getShell();
+                       if (shell != null && !shell.isDisposed()) {
+                               Runnable update= new Runnable() {
+                                       public void run() {
+                                               if (!shell.isDisposed() && !fDone) {
+                                                       fMonitor.beginTask(OpenTypeMessages.ElementSelectionDialog_UpdateElementsJob_inProgress, IProgressMonitor.UNKNOWN);
+                                               }
+                                       }};
+                               shell.getDisplay().asyncExec(update);
+                       }
+               }
+       }
+
+       private static final ISchedulingRule SINGLE_INSTANCE_RULE = new ISchedulingRule() {
+               public boolean contains(ISchedulingRule rule) {
+                       return rule == this;
+               }
+               public boolean isConflicting(ISchedulingRule rule) {
+                       return rule == this;
+               }};
+
+       private UpdateElementsJob fUpdateJob;
+       private boolean fAllowEmptyPrefix= true;
+       private boolean fAllowEmptyString= true;
+       private ProgressMonitorPart fProgressMonitorPart;
+
+       private String fHelpContextId;
+
+       /**
+        * Constructs an instance of <code>OpenTypeDialog</code>.
+        * @param parent  the parent shell.
+        */
+       public ElementSelectionDialog(Shell parent) {
+               super(parent);
+               setHelpContextId(ICHelpContextIds.OPEN_ELEMENT_DIALOG);
+               setMatchEmptyString(false);
+               fUpdateJob= new UpdateElementsJob(OpenTypeMessages.ElementSelectionDialog_UpdateElementsJob_name);
+               fUpdateJob.setRule(SINGLE_INSTANCE_RULE);
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog#create()
+        */
+       @Override
+       public void create() {
+               super.create();
+               // trigger initial query
+               scheduleUpdate(getFilter());
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog#close()
+        */
+       @Override
+       public boolean close() {
+               fUpdateJob.cancel();
+               return super.close();
+       }
+
+       /**
+        * Configure the help context id for this dialog.
+        * 
+        * @param helpContextId
+        */
+       public void setHelpContextId(String helpContextId) {
+               fHelpContextId= helpContextId;
+               setHelpAvailable(fHelpContextId != null);
+       }
+
+       /*
+        * @see org.eclipse.ui.dialogs.AbstractElementListSelectionDialog#setMatchEmptyString(boolean)
+        */
+       @Override
+       public void setMatchEmptyString(boolean matchEmptyString) {
+               super.setMatchEmptyString(matchEmptyString);
+               fAllowEmptyString= matchEmptyString;
+               if (matchEmptyString) {
+                       setAllowEmptyPrefix(true);
+               }
+       }
+
+       /**
+        * Set whether an empty prefix should be allowed for queries.
+        * 
+        * @param allowEmptyPrefix
+        */
+       public void setAllowEmptyPrefix(boolean allowEmptyPrefix) {
+               fAllowEmptyPrefix = allowEmptyPrefix;
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog#showLowLevelFilter()
+        */
+       @Override
+       protected boolean showLowLevelFilter() {
+               // the low-level filter is useless for us
+               return false;
+       }
+
+       /*
+        * @see org.eclipse.ui.dialogs.TwoPaneElementSelector#createDialogArea(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       public Control createDialogArea(Composite parent) {
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, fHelpContextId);
+               return super.createDialogArea(parent);
+       }
+
+       /*
+        * @see org.eclipse.ui.dialogs.TwoPaneElementSelector#createLowerList(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected Table createLowerList(Composite parent) {
+               Table table= super.createLowerList(parent);
+               createProgressMonitorPart(parent);
+               return table;
+       }
+
+       /**
+        * Create the control for progress reporting.
+        * @param parent
+        */
+       private void createProgressMonitorPart(Composite parent) {
+               fProgressMonitorPart= new ProgressMonitorPart(parent, new GridLayout(2, false));
+               GridData gridData= new GridData(GridData.FILL_HORIZONTAL);
+               gridData.horizontalIndent= 0;
+        gridData.verticalAlignment= GridData.BEGINNING;
+        fProgressMonitorPart.setLayoutData(gridData);
+        
+               Label separator= new Label(parent.getParent(), SWT.SEPARATOR | SWT.HORIZONTAL);
+               separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+        fUpdateJob.addJobChangeListener(new UpdateJobListener(fProgressMonitorPart));
+       }
+
+       /**
+        * Query the elements for the given prefix.
+        * 
+        * @param prefix
+        * @param monitor
+        */
+       protected ITypeInfo[] getElementsByPrefix(char[] prefix, IProgressMonitor monitor) {
+               if (monitor.isCanceled()) {
+                       return null;
+               }
+               HashSet<IndexTypeInfo> types = new HashSet<IndexTypeInfo>();
+               if (prefix != null) {
+                       final IndexFilter filter= new IndexFilter() {
+                               @Override
+                               public boolean acceptBinding(IBinding binding) throws CoreException {
+                                       if (isVisibleType(IndexModelUtil.getElementType(binding))) {
+                                               return IndexFilter.ALL_DECLARED.acceptBinding(binding);
+                                       }
+                                       return false;
+                               }
+                       };
+                       try {
+                               IIndex index = CCorePlugin.getIndexManager().getIndex(CoreModel.getDefault().getCModel().getCProjects());
+                               index.acquireReadLock();
+                               try {
+                                       IIndexBinding[] bindings= index.findBindingsForPrefix(prefix, false, filter, monitor);
+                                       for (int i= 0; i < bindings.length; i++) {
+                                               if (i % 0x1000 == 0 && monitor.isCanceled()) {
+                                                       return null;
+                                               }
+                                               final IndexTypeInfo typeinfo = IndexTypeInfo.create(index, bindings[i]);
+                                               types.add(typeinfo);
+                                       }
+                                       
+                                       if (isVisibleType(ICElement.C_MACRO)) {
+                                               IIndexMacro[] macros= index.findMacrosForPrefix(prefix, IndexFilter.ALL_DECLARED, monitor);
+                                               for (int i= 0; i < macros.length; i++) {
+                                                       if (i % 0x1000 == 0 && monitor.isCanceled()) {
+                                                               return null;
+                                                       }
+                                                       final IndexTypeInfo typeinfo = IndexTypeInfo.create(index, macros[i]);
+                                                       types.add(typeinfo);
+                                               }
+                                       }
+                               } finally {
+                                       index.releaseReadLock();
+                               }
+                       } catch (CoreException e) {
+                               CUIPlugin.log(e);
+                       } catch (InterruptedException e) {
+                               CUIPlugin.log(e);
+                       }
+               }
+               return types.toArray(new ITypeInfo[types.size()]);
+       }
+
+       @Override
+       protected final void setListElements(Object[] elements) {
+               super.setListElements(elements);
+       }
+
+       /**
+        * @deprecated Unsupported
+        */
+       @Deprecated
+       @Override
+       public void setElements(Object[] elements) {
+               throw new UnsupportedOperationException();
+       }
+
+       @Override
+       protected void handleEmptyList() {
+               updateOkState();
+       }
+
+       @Override
+       protected Text createFilterText(Composite parent) {
+               final Text result = super.createFilterText(parent);
+               Listener listener = new Listener() {
+            public void handleEvent(Event e) {
+                scheduleUpdate(result.getText());
+            }
+        };
+        result.addListener(SWT.Modify, listener);
+        return result;
+       }
+
+       protected void scheduleUpdate(String filterText) {
+               char[] newPrefix= toPrefix(filterText);
+               final char[] currentPrefix= fUpdateJob.getCurrentPrefix();
+               final boolean equivalentPrefix= isEquivalentPrefix(currentPrefix, newPrefix);
+               boolean emptyQuery= newPrefix.length == 0 && !fAllowEmptyPrefix || filterText.length() == 0 && !fAllowEmptyString;
+               final int jobState = fUpdateJob.getState();
+               boolean needQuery= !equivalentPrefix || (currentPrefix.length < newPrefix.length && currentPrefix.length < 5 && jobState == Job.RUNNING);
+               if (emptyQuery) {
+                       newPrefix= null;
+                       needQuery= needQuery || currentPrefix != null;
+               }
+               if (needQuery || jobState == Job.WAITING || jobState == Job.SLEEPING) {
+                       fUpdateJob.cancel();
+                       fUpdateJob.scheduleQuery(newPrefix);
+               }
+       }
+
+       private char[] toPrefix(String userFilter) {
+               QualifiedTypeName qualifiedName= new QualifiedTypeName(userFilter);
+               if (qualifiedName.segmentCount() > 1) {
+                       userFilter= qualifiedName.lastSegment();
+               }
+               if (userFilter.endsWith("<")) { //$NON-NLS-1$
+                       userFilter= userFilter.substring(0, userFilter.length() - 1);
+               }
+               int asterisk= userFilter.indexOf("*"); //$NON-NLS-1$
+               int questionMark= userFilter.indexOf("?"); //$NON-NLS-1$
+               int prefixEnd = asterisk < 0 ? questionMark :
+                               questionMark < 0 ? asterisk : Math.min(asterisk, questionMark);
+               return (prefixEnd == -1 ? userFilter : userFilter.substring(0, prefixEnd)).toCharArray();               
+       }
+
+       private boolean isEquivalentPrefix(char[] currentPrefix, char[] newPrefix) {
+               if (currentPrefix == null || currentPrefix.length > newPrefix.length) {
+                       return false;
+               } else if (newPrefix.length == currentPrefix.length) {
+                       return Arrays.equals(currentPrefix, newPrefix);
+               }
+               return new String(currentPrefix).equals(new String(newPrefix, 0, currentPrefix.length));
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeAction.java
new file mode 100644 (file)
index 0000000..806aee2
--- /dev/null
@@ -0,0 +1,188 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Andrew Ferguson (Symbian)
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.browser.opentype;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.browser.ITypeInfo;
+import org.eclipse.cdt.core.browser.ITypeReference;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class OpenTypeAction implements IWorkbenchWindowActionDelegate {
+
+       private IWorkbenchWindow fWorkbenchWindow;
+
+       public OpenTypeAction() {
+               super();
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+        */
+       public void run(IAction action) {
+               ElementSelectionDialog dialog = new ElementSelectionDialog(getShell());
+               configureDialog(dialog);
+               int result = dialog.open();
+               if (result != IDialogConstants.OK_ID)
+                       return;
+               
+               ITypeInfo info = (ITypeInfo) dialog.getFirstResult();
+               if (info == null)
+                       return;
+               
+               ITypeReference location = info.getResolvedReference();
+               if (location == null) {
+                       // could not resolve location
+                       String title = OpenTypeMessages.OpenTypeAction_errorTitle; 
+                       String message = NLS.bind(OpenTypeMessages.OpenTypeAction_errorTypeNotFound, info.getQualifiedTypeName().toString()); 
+                       MessageDialog.openError(getShell(), title, message);
+               } else if (!openTypeInEditor(location)) {
+                       // error opening editor
+                       String title = OpenTypeMessages.OpenTypeAction_errorTitle; 
+                       String message = NLS.bind(OpenTypeMessages.OpenTypeAction_errorOpenEditor, location.getPath().toString()); 
+                       MessageDialog.openError(getShell(), title, message);
+               }
+       }
+       
+       private void configureDialog(ElementSelectionDialog dialog) {
+               dialog.setTitle(OpenTypeMessages.OpenTypeDialog_title); 
+               dialog.setMessage(OpenTypeMessages.OpenTypeDialog_message); 
+               dialog.setDialogSettings(getClass().getName());
+               if (fWorkbenchWindow != null) {
+                       IWorkbenchPage page= fWorkbenchWindow.getActivePage();
+                       if (page != null) {
+                               IWorkbenchPart part= page.getActivePart();
+                               if (part instanceof ITextEditor) {
+                                       ISelection sel= ((ITextEditor) part).getSelectionProvider().getSelection();
+                                       if (sel instanceof ITextSelection) {
+                                               String txt= ((ITextSelection) sel).getText();
+                                               if (txt.length() > 0 && txt.length() < 80) {
+                                                       dialog.setFilter(txt, true);
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+
+       protected Shell getShell() {
+               return fWorkbenchWindow.getShell();
+       }
+       
+       /**
+        * Opens an editor and displays the selected type.
+        * 
+        * @param info Type to display.
+        * @return true if succesfully displayed.
+        */
+       private boolean openTypeInEditor(ITypeReference location) {
+               ICElement[] cElements= location.getCElements();
+               try {
+                       if (cElements != null && cElements.length > 0) {
+                               IEditorPart editor= EditorUtility.openInEditor(cElements[0]);
+                               EditorUtility.revealInEditor(editor, cElements[0]);
+                               return true;
+                       }
+                       ITranslationUnit unit = location.getTranslationUnit();
+                       IEditorPart editorPart = null;
+               
+                       if (unit != null)
+                               editorPart = EditorUtility.openInEditor(unit);
+                       if (editorPart == null) {
+                               // open as external file
+                               editorPart = EditorUtility.openInEditor(location.getLocation(), null);
+                       }
+
+                       // highlight the type in the editor
+                       if (editorPart != null && editorPart instanceof ITextEditor) {
+                               ITextEditor editor = (ITextEditor) editorPart;
+                if( location.isLineNumber() )
+                {
+                    IDocument document= editor.getDocumentProvider().getDocument(editor.getEditorInput());
+                    try
+                    {
+                        int startOffset = document.getLineOffset(location.getOffset()-1);
+                        int length=document.getLineLength(location.getOffset()-1);
+                        editor.selectAndReveal(startOffset, length);
+                        return true;
+                    }
+                    catch( BadLocationException ble )
+                    {
+                        return false;
+                    }
+                }
+                editor.selectAndReveal(location.getOffset(), location.getLength());
+                               return true;
+                       }
+               } catch (CModelException ex) {
+                       ex.printStackTrace();
+                       return false;
+               } catch (PartInitException ex) {
+                       ex.printStackTrace();
+                       return false;
+               }
+               
+               return false;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
+        */
+       public void dispose() {
+               fWorkbenchWindow= null;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
+        */
+       public void init(IWorkbenchWindow window) {
+               fWorkbenchWindow= window;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
+        *      org.eclipse.jface.viewers.ISelection)
+        */
+       public void selectionChanged(IAction action, ISelection selection) {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeDialog.java
new file mode 100644 (file)
index 0000000..63cb95a
--- /dev/null
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software Systems - adapted for use in CDT
+ *     Andrew Ferguson (Symbian)
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.browser.opentype;
+
+import org.eclipse.swt.widgets.Shell;
+
+
+/**
+ * A dialog to select a type from a list of types.
+ * 
+ * @deprecated Use {@link ElementSelectionDialog} instead.
+ * @noextend This class is not intended to be subclassed by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ */
+@Deprecated
+public class OpenTypeDialog extends ElementSelectionDialog {
+
+       /**
+        * Constructs an instance of <code>OpenTypeDialog</code>.
+        * @param parent  the parent shell.
+        */
+       public OpenTypeDialog(Shell parent) {
+               super(parent);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeMessages.java
new file mode 100644 (file)
index 0000000..5241f2a
--- /dev/null
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.browser.opentype;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ */
+public final class OpenTypeMessages extends NLS {
+
+       private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.browser.opentype.OpenTypeMessages";//$NON-NLS-1$
+
+       private OpenTypeMessages() {
+               // Do not instantiate
+       }
+
+       public static String OpenTypeAction_errorTitle;
+       public static String OpenTypeAction_errorOpenEditor;
+       public static String OpenTypeAction_errorTypeNotFound;
+       public static String OpenTypeDialog_title;
+       public static String OpenTypeDialog_message;
+       public static String ElementSelectionDialog_UpdateElementsJob_name;
+       public static String ElementSelectionDialog_UpdateElementsJob_inProgress;
+
+       static {
+               NLS.initializeMessages(BUNDLE_NAME, OpenTypeMessages.class);
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeMessages.properties
new file mode 100644 (file)
index 0000000..06a7ff1
--- /dev/null
@@ -0,0 +1,21 @@
+###############################################################################
+# Copyright (c) 2000, 2008 QNX Software Systems and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     QNX Software Systems - Initial API and implementation
+#     Anton Leherbauer (Wind River Systems)
+###############################################################################
+
+OpenTypeAction_errorTitle=Open Element
+OpenTypeAction_errorOpenEditor=Error opening editor for file \"{0}\"
+OpenTypeAction_errorTypeNotFound=Could not locate definition of element \"{0}\"
+
+OpenTypeDialog_title=Open Element
+OpenTypeDialog_message=&Choose an element (? = any character, * = any string):
+
+ElementSelectionDialog_UpdateElementsJob_name=Updating element list
+ElementSelectionDialog_UpdateElementsJob_inProgress=Updating element list...
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/BuildPreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/BuildPreferencePage.java
new file mode 100644 (file)
index 0000000..5c1f898
--- /dev/null
@@ -0,0 +1,174 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *     James Blackburn (Broadcom Corp.)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.build;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.core.resources.ACBuilder;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.preferences.PreferencesMessages;
+
+/**
+ * The page for top-level build preferences
+ */
+public class BuildPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+       private static final int GROUP_VINDENT = 5;
+       private static final int GROUP_HINDENT = 20;
+       private Button buildActive, buildAll, buildOnlyOnRefChange;
+
+       public BuildPreferencePage() {
+               super();
+               setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
+               setDescription(PreferencesMessages.CBuildPreferencePage_description);
+       }
+
+       @Override
+       public void createControl(Composite parent) {
+               super.createControl(parent);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.C_PREF_PAGE);
+       }
+
+       @Override
+       protected Control createContents(Composite parent) {
+               initializeDialogUnits(parent);
+
+               Composite container= new Composite(parent, SWT.NONE);
+               GridLayout layout= new GridLayout();
+               layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+               layout.marginWidth= 0;
+               layout.verticalSpacing= convertVerticalDLUsToPixels(10);
+               layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+               container.setLayout(layout);
+
+               // Build either default configuration or all.
+               Group gr = addGroup(container, PreferencesMessages.CPluginPreferencePage_build_scope);
+               Label l1 = new Label(gr, SWT.NONE);
+               l1.setText(PreferencesMessages.CPluginPreferencePage_1);
+               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.verticalIndent = GROUP_VINDENT;
+               l1.setLayoutData(gd);
+
+               boolean needAllConfigBuild = ACBuilder.needAllConfigBuild();
+
+               buildActive = new Button(gr, SWT.RADIO);
+               buildActive.setText(PreferencesMessages.CPluginPreferencePage_2);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.verticalIndent = GROUP_VINDENT;
+               gd.horizontalIndent = GROUP_HINDENT;
+               buildActive.setLayoutData(gd);
+               buildActive.setSelection(!needAllConfigBuild);
+
+               buildAll = new Button(gr, SWT.RADIO);
+               buildAll.setText(PreferencesMessages.CPluginPreferencePage_3);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalIndent = GROUP_HINDENT;
+               buildAll.setLayoutData(gd);
+               buildAll.setSelection(needAllConfigBuild);
+
+               addNote(gr, PreferencesMessages.CPluginPreferencePage_4);
+
+               // Building project dependencies.
+               Group gr2 = addGroup(container, PreferencesMessages.CPluginPreferencePage_building_configurations);
+               buildOnlyOnRefChange = new Button(gr2, SWT.CHECK);
+               buildOnlyOnRefChange.setText(PreferencesMessages.CPluginPreferencePage_7);
+               GridData gd2 = new GridData(GridData.FILL_HORIZONTAL);
+               gd2.verticalIndent = GROUP_VINDENT;
+               buildOnlyOnRefChange.setLayoutData(gd2);
+               buildOnlyOnRefChange.setSelection(ACBuilder.buildConfigResourceChanges());
+
+               Dialog.applyDialogFont(container);
+               return container;
+       }
+
+       private void addNote(Group parent, String noteMessage) {
+               Composite noteControl= createNoteComposite(JFaceResources.getDialogFont(), parent,
+                               PreferencesMessages.CPluginPreferencePage_note, noteMessage);
+               GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               gd.verticalIndent = GROUP_VINDENT;
+               noteControl.setLayoutData(gd);
+       }
+
+       @Override
+       protected Composite createNoteComposite(Font font, Composite composite, String title, String message) {
+               Composite messageComposite = super.createNoteComposite(font, composite, title, message);
+               Control[] children = messageComposite.getChildren();
+               if (children.length == 2 && (children[1] instanceof Label)) {
+                       // this is temporary fix for problem that 3 line note does not displayed properly within the group
+                       Label messageLabel = (Label) children[1];
+                       GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+                       gd.widthHint=500;
+                       messageLabel.setLayoutData(gd);
+               }
+               return messageComposite;
+       }
+
+       private Group addGroup(Composite parent, String label) {
+               return addGroup(parent, label, 1);
+       }
+
+       private Group addGroup(Composite parent, String label, int numColumns) {
+               Group group = new Group(parent, SWT.NONE);
+               group.setText(label);
+               group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               group.setLayout(new GridLayout(numColumns, false));
+               return group;
+       }
+
+       /**
+        * @see IWorkbenchPreferencePage#init
+        */
+       public void init(IWorkbench workbench) {
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.preference.IPreferencePage#performOk()
+        */
+       @Override
+       public boolean performOk() {
+               if (!super.performOk())
+                       return false;
+               // tell the Core Plugin about this preference
+               ACBuilder.setAllConfigBuild(buildAll.getSelection());
+               ACBuilder.setBuildConfigResourceChanges(buildOnlyOnRefChange.getSelection());
+               return true;
+       }
+
+    @Override
+       protected void performDefaults() {
+               ACBuilder.setAllConfigBuild(false);
+               ACBuilder.setBuildConfigResourceChanges(false);
+               buildActive.setSelection(true);
+               buildAll.setSelection(false);
+               buildOnlyOnRefChange.setSelection(false);
+       super.performDefaults();
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsole.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsole.java
new file mode 100644 (file)
index 0000000..025f2dc
--- /dev/null
@@ -0,0 +1,136 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ * Red Hat Inc. - Multiple build console support
+ * Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation
+ * Alex Collins (Broadcom Corp.) - Global build console
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.buildconsole;
+
+import java.net.URL;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.ui.console.AbstractConsole;
+import org.eclipse.ui.console.IConsoleConstants;
+import org.eclipse.ui.console.IConsoleView;
+import org.eclipse.ui.part.IPageBookViewPage;
+
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.IBuildConsoleManager;
+
+/**
+ * CDT Build console.
+ *
+ */
+public class BuildConsole extends AbstractConsole {
+
+       /**
+        * Menu group identifier for the console view context menu and toolbar, for actions pertaining to
+        * error navigation (value <code>"errorGroup"</code>).
+        */
+       public static final String ERROR_GROUP = "errorGroup"; //$NON-NLS-1$
+               
+       /**
+        * Property constant indicating the color of a stream has changed. 
+        */
+       public static final String P_STREAM_COLOR = CUIPlugin.PLUGIN_ID  + ".CONSOLE_P_STREAM_COLOR";    //$NON-NLS-1$
+
+       /** The page containing this build console */
+       private BuildConsolePage fBuildConsolePage;
+       /** The page for the console currently being displayed by the UI */
+       private static BuildConsolePage fCurrentBuildConsolePage;
+
+       private IBuildConsoleManager fConsoleManager;
+       private String fConsoleName;
+       private String fConsoleId;
+       private Color fBackground;
+
+       /**
+        * Constructor.
+        * 
+        * @param manager - build console manager.
+        * @param name - name of console to appear in the list of consoles in context menu
+        *    in the Console view.
+        * @param contextId - context menu id in the Console view.
+        */
+       public BuildConsole(IBuildConsoleManager manager, String name, String contextId) {
+               this(manager, name, contextId, null);
+       }
+
+       /**
+        * Constructor.
+        * 
+        * @param manager - build console manager.
+        * @param name - name of console to appear in the list of consoles in context menu
+        *    in the Console view.
+        * @param contextId - context menu id in the Console view.
+        * @param iconUrl - a {@link URL} of the icon for the context menu of the Console
+        *    view. The url is expected to point to an image in eclipse OSGi bundle.
+        *    {@code iconUrl} can be <b>null</b>, in that case the default image is used.
+        */
+       public BuildConsole(IBuildConsoleManager manager, String name, String contextId, URL iconUrl) {
+               super(name, CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_VIEW_BUILD_CONSOLE));
+               if (iconUrl!=null) {
+                       CDTSharedImages.register(iconUrl);
+                       this.setImageDescriptor(CDTSharedImages.getImageDescriptor(iconUrl.toString()));
+               }
+               fConsoleManager = manager;
+               fConsoleName = name;
+               fConsoleId = contextId;
+       }
+
+       public IPageBookViewPage createPage(IConsoleView view) {
+               fBuildConsolePage = new BuildConsolePage(view, this, fConsoleId); 
+               fCurrentBuildConsolePage = fBuildConsolePage;
+               return fBuildConsolePage;
+       }
+       
+       BuildConsolePage getPage() {
+               return fBuildConsolePage;
+       }
+
+       static BuildConsolePage getCurrentPage() {
+               return fCurrentBuildConsolePage;
+       }
+
+       static void setCurrentPage(BuildConsolePage page) {
+               fCurrentBuildConsolePage = page;
+       }
+
+       public void setTitle(IProject project) {
+               String title = fConsoleName;
+               if (project != null) {
+                       title += " [" + project.getName() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
+               }
+               setName(title);
+       }
+
+       public IBuildConsoleManager getConsoleManager() {
+               return fConsoleManager;
+       }
+
+       public void setBackground(Color background) {
+               if (fBackground == null) {
+                       if (background == null) {
+                               return;
+                       }
+               } else if (fBackground.equals(background)){
+                       return;
+               }
+               Color old = fBackground;
+               fBackground = background;
+               firePropertyChange(this, IConsoleConstants.P_BACKGROUND_COLOR, old, fBackground);
+       }
+
+       public Color getBackground() {
+               return fBackground;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleDocument.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleDocument.java
new file mode 100644 (file)
index 0000000..4563065
--- /dev/null
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2006 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.buildconsole;
+
+import org.eclipse.jface.text.DefaultLineTracker;
+import org.eclipse.jface.text.Document;
+
+public class BuildConsoleDocument extends Document {
+
+       public BuildConsoleDocument() {
+               setTextStore(new ConsoleOutputTextStore(2500)); 
+               setLineTracker(new DefaultLineTracker());
+               completeInitialization();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleFactory.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleFactory.java
new file mode 100644 (file)
index 0000000..440a175
--- /dev/null
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Ericsson and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Ericsson - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.buildconsole;
+
+import org.eclipse.ui.console.IConsoleFactory;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.IBuildConsoleManager;
+
+/**
+ * A console factory to allow the user to open the build console
+ * before actually doing a build.
+ */
+public class BuildConsoleFactory implements IConsoleFactory {
+       public void openConsole() {
+               IBuildConsoleManager manager = CUIPlugin.getDefault().getConsoleManager();
+               if (manager instanceof BuildConsoleManager) {
+                       ((BuildConsoleManager)manager).showConsole();
+               }
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java
new file mode 100644 (file)
index 0000000..8d24a8c
--- /dev/null
@@ -0,0 +1,516 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2011 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Red Hat Inc. - multiple build console support
+ *     Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation
+ *     Alex Collins (Broadcom Corp.) - Global build console
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.buildconsole;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.filesystem.URIUtil;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.console.ConsolePlugin;
+import org.eclipse.ui.console.IConsoleConstants;
+import org.eclipse.ui.console.IConsoleView;
+import org.osgi.service.prefs.Preferences;
+
+import org.eclipse.cdt.core.resources.IConsole;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.IBuildConsoleEvent;
+import org.eclipse.cdt.ui.IBuildConsoleListener;
+import org.eclipse.cdt.ui.IBuildConsoleManager;
+
+import org.eclipse.cdt.internal.core.LocalProjectScope;
+
+import org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage;
+
+public class BuildConsoleManager implements IBuildConsoleManager, IResourceChangeListener, IPropertyChangeListener {
+       /*package*/ static final String PREF_QUALIFIER = CUIPlugin.PLUGIN_ID;
+       public static final String KEY_KEEP_LOG = "keepLog"; //$NON-NLS-1$
+       public static final String KEY_LOG_LOCATION = "logLocation"; //$NON-NLS-1$
+       public static final boolean CONSOLE_KEEP_LOG_DEFAULT = true;
+
+       private static final String BUILD_CONSOLE_NODE = "buildConsole"; //$NON-NLS-1$
+       private static final String PROJECT_LOG_EXT = ".build.log"; //$NON-NLS-1$
+
+       private ListenerList listeners = new ListenerList();
+       /** UI console object in which per-project consoles are shown */
+       private BuildConsole fConsole;
+       private Map<IProject, BuildConsolePartitioner> fConsoleMap = new HashMap<IProject, BuildConsolePartitioner>();
+       private Color infoColor;
+       private Color outputColor;
+       private Color errorColor;
+       private Color backgroundColor;
+       private Color problemHighlightedColor;
+       private Color problemErrorBackgroundColor;
+       private Color problemInfoBackgroundColor;
+       private Color problemWarningBackgroundColor;
+
+       public Color getProblemHighlightedColor() {
+               return problemHighlightedColor;
+       }
+
+       /**
+        * This function returns background color for errors only now
+        */
+       public Color getProblemBackgroundColor() {
+               return problemErrorBackgroundColor;
+       }
+
+       public Color getWarningBackgroundColor() {
+               return problemWarningBackgroundColor;
+       }
+       
+       public Color getInfoBackgroundColor() {
+               return problemInfoBackgroundColor;
+       }
+       
+       private BuildConsoleStreamDecorator infoStream;
+       private BuildConsoleStreamDecorator outputStream;
+       private BuildConsoleStreamDecorator errorStream;
+       
+       private String fName;
+       private String fContextMenuId;
+
+       static public final int BUILD_STREAM_TYPE_INFO = 0;
+       static public final int BUILD_STREAM_TYPE_OUTPUT = 1;
+       static public final int BUILD_STREAM_TYPE_ERROR = 2;
+       
+       static public final String DEFAULT_CONTEXT_MENU_ID = CUIPlugin.PLUGIN_ID + ".CDTBuildConsole"; //$NON-NLS-1$
+
+       private IProject fLastProject;
+
+       /**
+        * Default constructor.
+        */
+       public BuildConsoleManager() {
+       }
+
+       /**
+        * Notifies the console manager that console activity has started on the
+        * project The manager will open the console if the preference is set to
+        * show the console, and notify listeners
+        */
+       protected void startConsoleActivity(IProject project) {
+               Object[] list = listeners.getListeners();
+               if (list.length > 0) {
+                       for (Object element : list) {
+                               IBuildConsoleListener listener = (IBuildConsoleListener)element;
+                               ConsoleEvent event = new ConsoleEvent(BuildConsoleManager.this, project, IBuildConsoleEvent.CONSOLE_START);
+                               listener.consoleChange(event);
+                       }
+               }
+               showConsole();
+       }
+
+       /**
+        * Opens the console view. If the view is already open, it is brought to the
+        * front. The console that is shown is the console that was last on top.
+        */
+       protected void showConsole() {
+               IWorkbenchWindow window = CUIPlugin.getActiveWorkbenchWindow();
+               if (window != null) {
+                       IWorkbenchPage page = window.getActivePage();
+                       if (page != null) {
+                               IViewPart consoleView = page.findView(IConsoleConstants.ID_CONSOLE_VIEW);
+                               if (consoleView == null && BuildConsolePreferencePage.isAutoOpenConsole()) {
+                                       IWorkbenchPart activePart = page.getActivePart();
+                                       try {
+                                               consoleView = page.showView(IConsoleConstants.ID_CONSOLE_VIEW);
+                                       } catch (PartInitException pie) {
+                                               CUIPlugin.log(pie);
+                                       }
+                                       //restore focus stolen by the creation of the
+                                       // console
+                                       page.activate(activePart);
+                               } else {
+                                       boolean bringToTop = shouldBringToTop(consoleView);
+                                       if (bringToTop) {
+                                               page.bringToTop(consoleView);
+                                       }
+                               }
+                               if (consoleView instanceof IConsoleView) {
+                                       if (BuildConsole.getCurrentPage() == null)
+                                               ((IConsoleView)consoleView).display(fConsole);
+                                       else
+                                               ((IConsoleView)consoleView).display(BuildConsole.getCurrentPage().getConsole());
+                               }
+                       }
+               }
+       }
+
+       boolean shouldBringToTop(IViewPart consoleView) {
+               boolean bringToTop = false;
+               if (consoleView instanceof IConsoleView) {
+                       IConsoleView cView = (IConsoleView)consoleView;
+                       return !cView.isPinned() && BuildConsolePreferencePage.isConsoleOnTop();
+               }
+               return bringToTop;
+       }
+
+       /**
+        * Traverses the delta looking for added/removed/changed launch
+        * configuration files.
+        * 
+        * @see IResourceChangeListener#resourceChanged(IResourceChangeEvent)
+        */
+       public void resourceChanged(IResourceChangeEvent event) {
+               IResource resource = event.getResource();
+               if (resource != null && resource.getType() == IResource.PROJECT) {
+                       if (event.getType() == IResourceChangeEvent.PRE_DELETE || event.getType() == IResourceChangeEvent.PRE_CLOSE) {
+                               IDocumentPartitioner partioner = fConsoleMap.remove(resource);
+                               if (partioner != null) {
+                                       partioner.disconnect();
+                                       Object[] list = listeners.getListeners();
+                                       if (list.length > 0) {
+                                               for (Object element : list) {
+                                                       IBuildConsoleListener listener = (IBuildConsoleListener)element;
+                                                       ConsoleEvent consoleEvent = new ConsoleEvent(this, (IProject)resource, IBuildConsoleEvent.CONSOLE_CLOSE);
+                                                       listener.consoleChange(consoleEvent);
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+
+       /**
+        * Release resources allocated on {@link #startup(String, String, URL)}.
+        */
+       public void shutdown() {
+               if (infoColor != null) {
+                       infoColor.dispose();
+                       outputColor.dispose();
+                       errorColor.dispose();
+                       backgroundColor.dispose();
+                       problemErrorBackgroundColor.dispose();
+                       problemWarningBackgroundColor.dispose();
+                       problemInfoBackgroundColor.dispose();
+                       problemHighlightedColor.dispose();
+               }
+               ConsolePlugin.getDefault().getConsoleManager().removeConsoles(new org.eclipse.ui.console.IConsole[]{fConsole});
+               CUIPlugin.getWorkspace().removeResourceChangeListener(this);
+               CUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
+       }
+
+       private void runUI(Runnable run) {
+               Display display;
+               display = Display.getCurrent();
+               if (display == null) {
+                       display = Display.getDefault();
+                       display.asyncExec(run);
+               } else {
+                       run.run();
+               }
+       }
+
+       /**
+        * Create new build console. Subclasses may override to create a specialized
+        * console.
+        * 
+        * @param name - name of console to appear in the list of consoles in context menu
+        *    in the Console view.
+        * @param contextId - context menu id in the Console view.
+        * @param iconUrl - a {@link URL} of the icon for the context menu of the Console
+        *    view. The url is expected to point to an image in eclipse OSGi bundle.
+        *    {@code iconUrl} can be <b>null</b>, in that case the default image is used.
+        * @return newly created build console.
+        */
+       protected BuildConsole createBuildConsole(String name, String contextId, final URL iconUrl) {
+               return new BuildConsole(this, name, contextId, iconUrl);
+       }
+       
+       /**
+        * Start console activities. This will create a new console in the Console view,
+        * create streams, color resources, register listeners etc.
+        * Most work is done in UI thread.
+        * 
+        * Use {@link #shutdown()} after the console activity ends.
+        * 
+        * @param name - name of the console to appear in the Console view.
+        * @param contextId - context menu id in the Console view.
+        * @param iconUrl - icon to show in the context menu.
+        */
+       public void startup(String name, String contextId, final URL iconUrl) {
+               // Ensure global console is initialized before any other build console
+               if (!(this instanceof GlobalBuildConsoleManager))
+                       GlobalBuildConsoleManager.startup();
+
+               infoStream = new BuildConsoleStreamDecorator();
+               outputStream = new BuildConsoleStreamDecorator();
+               errorStream = new BuildConsoleStreamDecorator();
+               fName = name;
+               fContextMenuId = contextId;
+
+               runUI(new Runnable() {
+
+                       /*
+                        * (non-Javadoc)
+                        * 
+                        * @see java.lang.Runnable#run()
+                        */
+                       public void run() {
+                               // add console to the Console view
+                               fConsole = createBuildConsole(fName, fContextMenuId, iconUrl);
+                               ConsolePlugin.getDefault().getConsoleManager().addConsoles(new org.eclipse.ui.console.IConsole[]{fConsole});
+
+                               infoStream.setConsole(fConsole);
+                               infoColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_INFO_COLOR);
+                               infoStream.setColor(infoColor);
+                               outputStream.setConsole(fConsole);
+                               outputColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_OUTPUT_COLOR);
+                               outputStream.setColor(outputColor);
+                               errorStream.setConsole(fConsole);
+                               errorColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_ERROR_COLOR);
+                               errorStream.setColor(errorColor);
+                               backgroundColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_BACKGROUND_COLOR);
+                               fConsole.setBackground(backgroundColor);
+                               problemHighlightedColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_HIGHLIGHTED_COLOR);
+                               problemErrorBackgroundColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR);
+                               problemWarningBackgroundColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR);
+                               problemInfoBackgroundColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR);
+                       }
+               });
+               CUIPlugin.getWorkspace().addResourceChangeListener(this);
+               CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+        */
+       public void propertyChange(PropertyChangeEvent event) {
+               String property = event.getProperty();
+               // colors
+               if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_INFO_COLOR)) {
+                       Color newColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_INFO_COLOR);
+                       infoStream.setColor(newColor);
+                       infoColor.dispose();
+                       infoColor = newColor;
+               } else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_OUTPUT_COLOR)) {
+                       Color newColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_OUTPUT_COLOR);
+                       outputStream.setColor(newColor);
+                       outputColor.dispose();
+                       outputColor = newColor;
+               } else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_ERROR_COLOR)) {
+                       Color newColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_ERROR_COLOR);
+                       errorStream.setColor(newColor);
+                       errorColor.dispose();
+                       errorColor = newColor;
+               } else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_BACKGROUND_COLOR)) {
+                       Color newColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_BACKGROUND_COLOR);
+                       fConsole.setBackground(newColor);
+                       backgroundColor.dispose();
+                       backgroundColor = newColor;
+               } else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_HIGHLIGHTED_COLOR)) {
+                       Color newColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_HIGHLIGHTED_COLOR);
+                       problemHighlightedColor.dispose();
+                       problemHighlightedColor = newColor;
+                       redrawTextViewer();
+               } else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR)) {
+                       Color newColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR);
+                       problemErrorBackgroundColor.dispose();
+                       problemErrorBackgroundColor = newColor;
+                       redrawTextViewer();
+               } else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR)) {
+                       Color newColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR);
+                       problemWarningBackgroundColor.dispose();
+                       problemWarningBackgroundColor = newColor;
+                       redrawTextViewer();
+               } else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR)) {
+                       Color newColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR);
+                       problemInfoBackgroundColor.dispose();
+                       problemInfoBackgroundColor = newColor;
+                       redrawTextViewer();
+               }
+       }
+
+       private void redrawTextViewer() {
+               final BuildConsolePage p = BuildConsole.getCurrentPage();
+               if ( p == null ) return;
+               final BuildConsoleViewer v = p.getViewer();
+               if ( v  == null ) return;               
+               Display display = Display.getDefault();
+               display.asyncExec(new Runnable() {
+                       public void run() {
+                               v.getTextWidget().redraw();
+                       }
+               });
+       }
+
+       public BuildConsoleStreamDecorator getStreamDecorator(int type) throws CoreException {
+               switch (type) {
+                       case BUILD_STREAM_TYPE_ERROR :
+                               return errorStream;
+                       case BUILD_STREAM_TYPE_INFO :
+                               return infoStream;
+                       case BUILD_STREAM_TYPE_OUTPUT :
+                               return outputStream;
+               }
+               throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, -1, "No Such Console", null)); //$NON-NLS-1$
+       }
+
+       /**
+        * Returns a color instance based on data from a preference field.
+        */
+       private Color createColor(Display display, String preference) {
+               RGB rgb = PreferenceConverter.getColor(CUIPlugin.getDefault().getPreferenceStore(), preference);
+               return new Color(display, rgb);
+       }
+
+       /**
+        * Returns a background color instance based on data from a preference field.
+        * This is a workaround for black console bug 320723. 
+        */
+       private Color createBackgroundColor(Display display, String preference) {
+               IPreferenceStore preferenceStore = CUIPlugin.getDefault().getPreferenceStore();
+               RGB rgb;
+               if (preferenceStore.contains(preference)) {
+                       rgb = PreferenceConverter.getColor(preferenceStore, preference);
+               } else {
+                       rgb = new RGB(200, 200, 200); // gray background
+               }
+               return new Color(display, rgb);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public IConsole getConsole(IProject project) {
+               return new MultiBuildConsoleAdapter(getProjectConsole(project), GlobalBuildConsoleManager.getGlobalConsole());
+       }
+
+       /**
+        * {@inheritDoc}
+        * 
+        * @return the console for the specified project. Returns {@code null}
+        *   if project is {@code null} or not accessible.
+        */
+       public IConsole getProjectConsole(IProject project) {
+               if (project==null || !project.isAccessible())
+                       return null;
+
+               fLastProject = project;
+               return getProjectConsolePartioner(project).getConsole();
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.cdt.ui.IBuildConsoleManager#getLastBuiltProject()
+        */
+       public IProject getLastBuiltProject() {
+               return fLastProject;
+       }
+
+       /**
+        * @return the partitioner for the specified projects build console
+        */
+       private BuildConsolePartitioner getProjectConsolePartioner(IProject project) {
+               BuildConsolePartitioner partitioner = fConsoleMap.get(project);
+               if (partitioner == null) {
+                       partitioner = new BuildConsolePartitioner(project, this);
+                       fConsoleMap.put(project, partitioner);
+               }
+               return partitioner;
+       }
+
+       /**
+        * @return the document backing the build console for the specified project
+        */
+       public IDocument getConsoleDocument(IProject project) {
+               Assert.isNotNull(project);
+               return getProjectConsolePartioner(project).getDocument();
+       }
+
+       public void addConsoleListener(IBuildConsoleListener listener) {
+               listeners.add(listener);
+       }
+
+       public void removeConsoleListener(IBuildConsoleListener listener) {
+               listeners.remove(listener);
+       }
+
+       /**
+        * @return logging preferences for a given project.
+        * @param project to get logging preferences for, can't be {@code null}.
+        */
+       public Preferences getBuildLogPreferences(IProject project) {
+               return new LocalProjectScope(project).getNode(PREF_QUALIFIER).node(BUILD_CONSOLE_NODE);
+       }
+
+       /**
+        * @return default location of logs for a project.
+        * @param project to get default log location for, can't be {@code null}.
+        */
+       public String getDefaultConsoleLogLocation(IProject project) {
+               IPath defaultLogLocation = CUIPlugin.getDefault().getStateLocation().append(project.getName() + PROJECT_LOG_EXT);
+               return defaultLogLocation.toOSString();
+       }
+
+       /**
+        * Where the log for per-project console is kept.
+        * 
+        * @param project - the project. Cannot be {@code null}.
+        * @return {@link URI} of build log or {@code null} if not available.
+        */
+       public URI getLogURI(IProject project) {
+               Assert.isNotNull(project);
+
+               if (fContextMenuId!=DEFAULT_CONTEXT_MENU_ID)
+                       return null;
+
+               URI logURI = null;
+
+               Preferences prefs = getBuildLogPreferences(project);
+               boolean keepLog = prefs.getBoolean(KEY_KEEP_LOG, CONSOLE_KEEP_LOG_DEFAULT);
+               if (keepLog) {
+                       String strLocation;
+                       strLocation = prefs.get(KEY_LOG_LOCATION, getDefaultConsoleLogLocation(project));
+                       if (strLocation.trim().length()>0) {
+                               logURI = URIUtil.toURI(strLocation);
+                       }
+                       if (logURI==null) {
+                               IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID,"Can't determine URI for location=["+strLocation+"]");  //$NON-NLS-1$ //$NON-NLS-2$
+                               CUIPlugin.log(status);
+                       }
+               }
+               return logURI;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.java
new file mode 100644 (file)
index 0000000..b45a085
--- /dev/null
@@ -0,0 +1,645 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2011 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Red Hat Inc. - multiple build console support
+ *     Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation
+ *                                    Save build output
+ *     Alex Collins (Broadcom Corp.) - Global build console
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.buildconsole;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.ResourceBundle;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IFindReplaceTarget;
+import org.eclipse.jface.text.ITextListener;
+import org.eclipse.jface.text.ITextOperationTarget;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.TextEvent;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.OpenStrategy;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Widget;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.console.IConsoleConstants;
+import org.eclipse.ui.console.IConsoleView;
+import org.eclipse.ui.console.actions.ClearOutputAction;
+import org.eclipse.ui.console.actions.TextViewerAction;
+import org.eclipse.ui.console.actions.TextViewerGotoLineAction;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.ide.ResourceUtil;
+import org.eclipse.ui.part.IPageSite;
+import org.eclipse.ui.part.Page;
+import org.eclipse.ui.texteditor.FindReplaceAction;
+import org.eclipse.ui.texteditor.ITextEditorActionConstants;
+import org.eclipse.ui.texteditor.IUpdate;
+
+import org.eclipse.cdt.core.ProblemMarkerInfo;
+import org.eclipse.cdt.core.model.ICModelMarker;
+import org.eclipse.cdt.core.resources.IConsole;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.IBuildConsoleEvent;
+import org.eclipse.cdt.ui.IBuildConsoleListener;
+import org.eclipse.cdt.ui.IBuildConsoleManager;
+
+import org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage;
+
+public class BuildConsolePage extends Page
+               implements
+                       ISelectionListener,
+                       IPropertyChangeListener,
+                       IBuildConsoleListener,
+                       ITextListener,
+                       IAdaptable {
+
+       static final int POSITION_NEXT = -1;
+       static final int POSITION_PREV = -2;
+       static final int POSITION_FIST = -3;
+
+       private BuildConsole fConsole;
+       private IConsoleView fConsoleView;
+       private String fContextMenuId;
+       private BuildConsoleViewer fViewer;
+       private IProject fProject;
+
+       // text selection listener
+       private ISelectionChangedListener fTextListener = new ISelectionChangedListener() {
+
+               public void selectionChanged(SelectionChangedEvent event) {
+                       updateSelectionDependentActions();
+               }
+       };
+
+       // actions
+       private ClearOutputAction fClearOutputAction;
+       private Map<String, IAction> fGlobalActions = new HashMap<String, IAction>(10);
+       private List<String> fSelectionActions = new ArrayList<String>(3);
+       private CopyBuildLogAction fSaveLogAction;
+
+       // menus
+       private Menu fMenu;
+       private ScrollLockAction fScrollLockAction;
+       private boolean fIsLocked;
+       private NextErrorAction fNextErrorAction;
+       private PreviousErrorAction fPreviousErrorAction;
+       private ShowErrorAction fShowErrorAction;
+
+       /**
+        * @param view
+        * @param console
+        * @param contextId
+        */
+       public BuildConsolePage(IConsoleView view, BuildConsole console,
+                       String contextId) {
+               fConsole = console;
+               fConsoleView = view;
+               fContextMenuId = contextId;
+       }
+
+       protected void setProject(IProject project) {
+               if (fProject != project && project.isAccessible()) {
+                       fProject = project;
+               }
+       }
+
+       protected IProject getProject() {
+               return fProject;
+       }
+
+       protected BuildConsole getConsole() {
+               return fConsole;
+       }
+
+       protected IDocument setDocument() {
+               IProject project = getProject();
+               if (project != null) {
+                       IBuildConsoleManager consoleManager = getConsole().getConsoleManager();
+                       IDocument document = consoleManager.getConsoleDocument(project);
+                       IConsole console = consoleManager.getProjectConsole(project);
+                       getViewer().setDocument(document);
+                       if (console instanceof BuildConsolePartitioner) {
+                               BuildConsolePartitioner par = (BuildConsolePartitioner)console;
+                               // Show the error, but don't show it in the editor if we are viewing the global console.
+                               // Prevents showing errors in the editor for projects other than the current project.
+                               showError(par, fShowErrorAction.isChecked() && !(getConsole() instanceof GlobalBuildConsole));
+                       }
+               }
+               return null;
+       }
+
+       public void consoleChange(final IBuildConsoleEvent event) {
+               if (event.getType() == IBuildConsoleEvent.CONSOLE_START || event.getType() == IBuildConsoleEvent.CONSOLE_CLOSE) {
+                       Control control = getControl();
+                       if (control != null && !control.isDisposed()) {
+                               Display display = control.getDisplay();
+                               display.asyncExec(new Runnable() {
+
+                                       /*
+                                        * (non-Javadoc)
+                                        *
+                                        * @see java.lang.Runnable#run()
+                                        */
+                                       public void run() {
+                                               if (isAvailable()) {
+                                                       if (event.getType() == IBuildConsoleEvent.CONSOLE_CLOSE && getProject() != event.getProject()) {
+                                                               return;
+                                                       }
+                                                       setProject(event.getProject());
+                                                       if (isAvailable()) {
+                                                               setDocument();
+                                                               getConsole().setTitle(getProject());
+                                                       }
+                                               }
+                                       }
+                               });
+                       }
+               }
+       }
+
+       boolean isAvailable() {
+               return getControl() != null;
+       }
+
+       /*
+        * (non-Javadoc)
+        *
+        * @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       public void createControl(Composite parent) {
+               fViewer = new BuildConsoleViewer(parent);
+
+               MenuManager manager = new MenuManager("#MessageConsole", "#MessageConsole"); //$NON-NLS-1$ //$NON-NLS-2$
+               manager.setRemoveAllWhenShown(true);
+               manager.addMenuListener(new IMenuListener() {
+
+                       public void menuAboutToShow(IMenuManager m) {
+                               contextMenuAboutToShow(m);
+                       }
+               });
+               fMenu = manager.createContextMenu(getControl());
+               getControl().setMenu(fMenu);
+               IPageSite site = getSite();
+               site.registerContextMenu(fContextMenuId, manager, getViewer());
+               site.setSelectionProvider(getViewer());
+               createActions();
+               configureToolBar(site.getActionBars().getToolBarManager());
+               fViewer.getSelectionProvider().addSelectionChangedListener(fTextListener);
+
+               JFaceResources.getFontRegistry().addListener(this);
+               setFont(JFaceResources.getFont(BuildConsolePreferencePage.PREF_BUILDCONSOLE_FONT));
+               setTabs(CUIPlugin.getDefault().getPreferenceStore().getInt(BuildConsolePreferencePage.PREF_BUILDCONSOLE_TAB_WIDTH));
+
+               getConsole().addPropertyChangeListener(this);
+               CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
+
+               fViewer.addTextListener(this);
+               fViewer.getTextWidget().setBackground(getConsole().getBackground());
+
+               setInitialSelection();
+       }
+
+       /**
+        * Fill the context menu
+        *
+        * @param menu
+        *            menu
+        */
+       protected void contextMenuAboutToShow(IMenuManager menu) {
+               menu.add(fGlobalActions.get(ActionFactory.COPY.getId()));
+               menu.add(fGlobalActions.get(ActionFactory.SELECT_ALL.getId()));
+               menu.add(new Separator("FIND")); //$NON-NLS-1$
+               menu.add(fGlobalActions.get(ActionFactory.FIND.getId()));
+               menu.add(fGlobalActions.get(ITextEditorActionConstants.GOTO_LINE));
+               menu.add(fClearOutputAction);
+               menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+       }
+
+       /*
+        * (non-Javadoc)
+        *
+        * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+        */
+       public void propertyChange(PropertyChangeEvent event) {
+               final Object source = event.getSource();
+               final String property = event.getProperty();
+
+               if (BuildConsole.P_STREAM_COLOR.equals(property) && source instanceof BuildConsoleStreamDecorator) {
+                       BuildConsoleStreamDecorator stream = (BuildConsoleStreamDecorator)source;
+                       if (stream.getConsole().equals(getConsole()) && getControl() != null) {
+                               Display display = getControl().getDisplay();
+                               display.asyncExec(new Runnable() {
+
+                                       public void run() {
+                                               getViewer().getTextWidget().redraw();
+                                       }
+                               });
+                       }
+               } else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_FONT)) {
+                       setFont(JFaceResources.getFont(BuildConsolePreferencePage.PREF_BUILDCONSOLE_FONT));
+               } else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_TAB_WIDTH)) {
+                       setTabs(CUIPlugin.getDefault().getPreferenceStore().getInt(BuildConsolePreferencePage.PREF_BUILDCONSOLE_TAB_WIDTH));
+               } else if (IConsoleConstants.P_BACKGROUND_COLOR.equals(property)) {
+                       fViewer.getTextWidget().setBackground(fConsole.getBackground());
+               }
+       }
+
+       protected void createActions() {
+               fClearOutputAction = new ClearOutputAction(getViewer());
+               fScrollLockAction = new ScrollLockAction(getViewer());
+               fScrollLockAction.setChecked(fIsLocked);
+               fNextErrorAction = new NextErrorAction(this);
+               fPreviousErrorAction = new PreviousErrorAction(this);
+               fShowErrorAction = new ShowErrorAction(this);
+               fSaveLogAction = new CopyBuildLogAction(this);
+
+               getViewer().setAutoScroll(!fIsLocked);
+               // In order for the clipboard actions to accessible via their shortcuts
+               // (e.g., Ctrl-C, Ctrl-V), we *must* set a global action handler for
+               // each action
+               IActionBars actionBars = getSite().getActionBars();
+               TextViewerAction action = new TextViewerAction(getViewer(), ITextOperationTarget.COPY);
+               action.configureAction(ConsoleMessages.BuildConsolePage__Copy_Ctrl_C_6,
+                               ConsoleMessages.BuildConsolePage_Copy_7, ConsoleMessages.BuildConsolePage_Copy_7);
+               action.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
+               action.setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(
+                               ISharedImages.IMG_TOOL_COPY_DISABLED));
+               action.setHoverImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
+               setGlobalAction(actionBars, ActionFactory.COPY.getId(), action);
+               action = new TextViewerAction(getViewer(), ITextOperationTarget.SELECT_ALL);
+               action.configureAction(ConsoleMessages.BuildConsolePage_Select__All_Ctrl_A_12,
+                               ConsoleMessages.BuildConsolePage_Select_All,
+                               ConsoleMessages.BuildConsolePage_Select_All);
+               setGlobalAction(actionBars, ActionFactory.SELECT_ALL.getId(), action);
+               //XXX Still using "old" resource access
+               ResourceBundle bundle = ResourceBundle.getBundle(ConsoleMessages.BUNDLE_NAME);
+               setGlobalAction(actionBars, ActionFactory.FIND.getId(), new FindReplaceAction(bundle, "find_replace_action_", //$NON-NLS-1$
+                               getConsoleView()));
+               action = new TextViewerGotoLineAction(getViewer());
+               setGlobalAction(actionBars, ITextEditorActionConstants.GOTO_LINE, action);
+               actionBars.updateActionBars();
+               fSelectionActions.add(ActionFactory.COPY.getId());
+               fSelectionActions.add(ActionFactory.FIND.getId());
+       }
+
+       protected void updateSelectionDependentActions() {
+               Iterator<String> iterator = fSelectionActions.iterator();
+               while (iterator.hasNext()) {
+                       updateAction(iterator.next());
+               }
+       }
+
+       protected void updateAction(String actionId) {
+               IAction action = fGlobalActions.get(actionId);
+               if (action instanceof IUpdate) {
+                       ((IUpdate)action).update();
+               }
+       }
+
+       protected void setGlobalAction(IActionBars actionBars, String actionID, IAction action) {
+               fGlobalActions.put(actionID, action);
+               actionBars.setGlobalActionHandler(actionID, action);
+       }
+
+       protected void configureToolBar(IToolBarManager mgr) {
+               mgr.insertBefore(IConsoleConstants.OUTPUT_GROUP, new GroupMarker(BuildConsole.ERROR_GROUP));
+               mgr.appendToGroup(BuildConsole.ERROR_GROUP, fNextErrorAction);
+               mgr.appendToGroup(BuildConsole.ERROR_GROUP, fPreviousErrorAction);
+               mgr.appendToGroup(BuildConsole.ERROR_GROUP, fShowErrorAction);
+               mgr.appendToGroup(IConsoleConstants.OUTPUT_GROUP, fSaveLogAction);
+               mgr.appendToGroup(IConsoleConstants.OUTPUT_GROUP, fScrollLockAction);
+               mgr.appendToGroup(IConsoleConstants.OUTPUT_GROUP, fClearOutputAction);
+       }
+
+       protected BuildConsoleViewer getViewer() {
+               return fViewer;
+       }
+
+       /**
+        * Returns the view this page is contained in
+        *
+        * @return the view this page is contained in
+        */
+       protected IConsoleView getConsoleView() {
+               return fConsoleView;
+       }
+
+       /*
+        * (non-Javadoc)
+        *
+        * @see org.eclipse.ui.part.IPage#dispose()
+        */
+       @Override
+       public void dispose() {
+               getSite().getPage().removeSelectionListener(this);
+               getConsole().getConsoleManager().removeConsoleListener(this);
+               fViewer.removeTextListener(this);
+               super.dispose();
+       }
+
+       @Override
+       public void init(IPageSite pageSite) {
+               super.init(pageSite);
+               getSite().getPage().addSelectionListener(this);
+               getConsole().getConsoleManager().addConsoleListener(this);
+       }
+
+       protected void setInitialSelection() {
+               // Use the selection, if any
+               IWorkbenchPage page= getSite().getPage();
+               ISelection selection= null;
+               if (page != null)
+                       selection= page.getSelection();
+
+               if (convertSelectionToProject(selection) == null) {
+                       if (selection instanceof ITextSelection) {
+                               Object part= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
+                               if (part instanceof IEditorPart) {
+                                       if (setSelectionFromEditor((IEditorPart)part) == true)
+                                               return;
+                               }
+                       }
+                       IProject project = getConsole().getConsoleManager().getLastBuiltProject();
+                       if (project != null)
+                               selection = new StructuredSelection(project);
+               }
+               selectionChanged(null, selection);
+       }
+
+       boolean setSelectionFromEditor(IEditorPart part) {
+               if (part == null)
+                       return false;
+               IWorkbenchPartSite site= part.getSite();
+               if (site == null)
+                       return false;
+               ISelectionProvider provider= site.getSelectionProvider();
+               if (provider != null ) {
+                       IEditorInput ei= part.getEditorInput();
+                       if (ei instanceof IFileEditorInput) {
+                               IFile file= ((IFileEditorInput)ei).getFile();
+                               selectionChanged(part, new StructuredSelection(file));
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+       public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+               IProject newProject = convertSelectionToProject(selection);
+               IProject oldProject = getProject();
+               if (oldProject == null || (newProject != null && !newProject.equals(oldProject))) {
+                       setProject(newProject);
+                       setDocument();
+                       getConsole().setTitle(getProject());
+               }
+       }
+
+       IProject convertSelectionToProject(ISelection selection) {
+               IProject project = null;
+               if (selection == null || ! (selection instanceof IStructuredSelection)) {
+                       return project;
+               }
+               IStructuredSelection ssel = (IStructuredSelection)selection;
+               Object element = ssel.getFirstElement();
+               if (element instanceof IAdaptable) {
+                       IAdaptable input = (IAdaptable)element;
+                       IResource resource = null;
+                       if (input instanceof IResource) {
+                               resource = (IResource)input;
+                       } else {
+                               resource = (IResource)input.getAdapter(IResource.class);
+                       }
+                       if (resource != null) {
+                               project = resource.getProject();
+                       }
+               }
+               return project;
+       }
+
+       /*
+        * (non-Javadoc)
+        *
+        * @see org.eclipse.ui.part.IPage#getControl()
+        */
+       @Override
+       public Control getControl() {
+               if (fViewer != null) {
+                       return fViewer.getControl();
+               }
+               return null;
+       }
+
+       /*
+        * (non-Javadoc)
+        *
+        * @see org.eclipse.ui.part.IPage#setFocus()
+        */
+       @Override
+       public void setFocus() {
+               Control control = getControl();
+               if (control != null) {
+                       control.setFocus();
+               }
+               updateSelectionDependentActions();
+       }
+
+       /**
+        * Sets the font for this page.
+        *
+        * @param font
+        *            font
+        */
+       protected void setFont(Font font) {
+               getViewer().getTextWidget().setFont(font);
+       }
+
+       /**
+        * Sets the tab width for this page.
+        *
+        * @param tabs
+        *            tab width
+        */
+       protected void setTabs(int tabs) {
+               getViewer().getTextWidget().setTabs(tabs);
+       }
+
+       /**
+        * Refreshes this page
+        */
+       protected void refresh() {
+               getViewer().refresh();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+        */
+       @SuppressWarnings("rawtypes")
+       public Object getAdapter(Class required) {
+               if (IFindReplaceTarget.class.equals(required)) {
+                       return getViewer().getFindReplaceTarget();
+               }
+               if (Widget.class.equals(required)) {
+                       return getViewer().getTextWidget();
+               }
+//             if (IShowInSource.class.equals(required)) {
+//                     return this;
+//             }
+//             if (IShowInTargetList.class.equals(required)) {
+//                     return this;
+//             }
+               return null;
+       }
+
+       /*
+        * (non-Javadoc)
+        *
+        * @see org.eclipse.jface.text.ITextListener#textChanged(org.eclipse.jface.text.TextEvent)
+        */
+       public void textChanged(TextEvent event) {
+               //               update the find replace action if the document length is > 0
+               IUpdate findReplace = (IUpdate)fGlobalActions.get(ActionFactory.FIND.getId());
+               if (findReplace != null) {
+                       findReplace.update();
+               }
+       }
+
+       /**
+        * Get the current CDT IConsole being displayed on the page
+        */
+       private IConsole getCurrentConsole() {
+               IBuildConsoleManager consoleManager = fConsole.getConsoleManager();
+               return consoleManager.getProjectConsole(getProject());
+       }
+
+       /**
+        * Highlight next/previous error or error by console offset
+        * @param position POSITION_NEXT (-1), POSITION_PREV (-2), or offset
+        */
+       void moveToError(int position) {
+               IConsole console = getCurrentConsole();
+               if (console == null) return;
+               if (console instanceof BuildConsolePartitioner) {
+                       BuildConsolePartitioner par = (BuildConsolePartitioner)console;
+                       // Move to specified line in the model (BuildConsolePartitioner)
+                       if ( position == POSITION_NEXT ) {
+                               par.fDocumentMarkerManager.moveToNextError();
+                       } else if ( position == POSITION_PREV ) {
+                               par.fDocumentMarkerManager.moveToPreviousError();
+                       } else if ( position == POSITION_FIST ) {
+                               par.fDocumentMarkerManager.moveToFirstError();
+                       } else if ( position >= 0 ) {
+                               if ( ! par.fDocumentMarkerManager.moveToErrorByOffset(position) ) {
+                                       // we haven't moved, because offset points to non-error partition
+                                       return;
+                               }
+                       }
+                       showError(par, position > 0 || fShowErrorAction.isChecked() );
+               }
+       }
+
+       /**
+        * Highlight current error and show it in editor
+        */
+       public void showError(BuildConsolePartitioner par, boolean openInEditor) {
+               // Highlight current error
+               BuildConsolePartition p = par.fDocumentMarkerManager.getCurrentPartition();
+               if ( p == null ) return;
+               getViewer().selectPartition(par, p);
+               // Show error in editor if necessary
+               // (always show when absolute positioning, otherwise depends
+               // on fShowErrorAction state)
+               if ( openInEditor ) {
+                       openErrorInEditor(par.fDocumentMarkerManager.getCurrentErrorMarker());
+               }
+       }
+
+       /**
+        * Open error specified by marker in editor
+        */
+       public static void openErrorInEditor(ProblemMarkerInfo marker) {
+               IWorkbenchWindow window = CUIPlugin.getActiveWorkbenchWindow();
+
+               if ( marker == null || marker.file == null || window == null )  return;
+
+               IWorkbenchPage page = window.getActivePage();
+               if (page == null) return;
+
+               IEditorPart editor = page.getActiveEditor();
+               if (editor != null) {
+                       IEditorInput input = editor.getEditorInput();
+                       IFile file = ResourceUtil.getFile(input);
+                       if (file != null && file.equals(marker.file) && OpenStrategy.activateOnOpen()) {
+                               page.activate(editor);
+                       }
+               }
+
+               if ( marker.file instanceof IFile ) {
+                       try {
+                               // Find IMarker corresponding to ProblemMarkerInfo
+                               IMarker mrkrs[] = marker.file.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_ONE);
+                               for (IMarker m: mrkrs) {
+                                       if ( marker.lineNumber == ((Integer)m.getAttribute(IMarker.LINE_NUMBER)).intValue() &&
+                                                               marker.description.equals(m.getAttribute(IMarker.MESSAGE)) &&
+                                                               marker.severity == ((Integer)m.getAttribute(IMarker.SEVERITY)).intValue() ) {
+                                               IDE.openEditor(page, m, OpenStrategy.activateOnOpen());
+                                               return;
+                                       }
+                               }
+                       } catch (PartInitException e) {
+                               CUIPlugin.log(e);
+                       } catch (CoreException e) {
+                               CUIPlugin.log(e);
+                       }
+               }
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePageParticipant.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePageParticipant.java
new file mode 100644 (file)
index 0000000..774f6e8
--- /dev/null
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Broadcom Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alex Collins (Broadcom Corp.) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.buildconsole;
+
+import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.IConsolePageParticipant;
+import org.eclipse.ui.part.IPageBookViewPage;
+
+/**
+ * Attached to extension point org.eclipse.ui.console.consolePageParticipants to notify
+ * BuildConsole that a new page has become visible.
+ */
+public class BuildConsolePageParticipant implements IConsolePageParticipant {
+       private BuildConsole console;
+
+       public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+               return null;
+       }
+
+       public void init(IPageBookViewPage page, IConsole console) {
+               this.console = (BuildConsole)console;
+       }
+
+       public void dispose() {
+       }
+
+       public void activated() {
+               BuildConsole.setCurrentPage(console.getPage());
+       }
+
+       public void deactivated() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartition.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartition.java
new file mode 100644 (file)
index 0000000..8910664
--- /dev/null
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ * Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.buildconsole;
+
+import org.eclipse.cdt.core.ProblemMarkerInfo;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.jface.text.TypedRegion;
+
+public class BuildConsolePartition extends TypedRegion {
+
+       /** Associated stream */
+       private BuildConsoleStreamDecorator fStream;
+       
+       /** Marker associated with this partition if any */
+       private ProblemMarkerInfo fMarker; 
+
+       /** Partition type */
+       public static final String CONSOLE_PARTITION_TYPE = CUIPlugin.getPluginId() + ".CONSOLE_PARTITION_TYPE"; //$NON-NLS-1$  
+       
+       /** Partition types to report build problems in the console */
+       public static final String ERROR_PARTITION_TYPE = CUIPlugin.getPluginId() + ".ERROR_PARTITION_TYPE"; //$NON-NLS-1$  
+       public static final String INFO_PARTITION_TYPE = CUIPlugin.getPluginId() + ".INFO_PARTITION_TYPE"; //$NON-NLS-1$  
+       public static final String WARNING_PARTITION_TYPE = CUIPlugin.getPluginId() + ".WARNING_PARTITION_TYPE"; //$NON-NLS-1$  
+       
+       public BuildConsolePartition(BuildConsoleStreamDecorator stream, int offset, int length, String type) {
+               super(offset, length, type);
+               fStream = stream;
+       }
+
+       public BuildConsolePartition(BuildConsoleStreamDecorator stream, int offset, int length, String type, ProblemMarkerInfo marker) {
+               super(offset, length, type);
+               fStream = stream;
+               fMarker = marker;
+       }
+
+       /**
+        * @see java.lang.Object#equals(java.lang.Object)
+        */
+       @Override
+       public boolean equals(Object partition) {
+               if (super.equals(partition)) {
+                       return fStream.equals(((BuildConsolePartition) partition).getStream());
+               }
+               return false;
+       }
+
+       /**
+        * @see java.lang.Object#hashCode()
+        */
+       @Override
+       public int hashCode() {
+               return super.hashCode() + fStream.hashCode();
+       }
+
+       /**
+        * Returns this partition's stream
+        * 
+        * @return this partition's stream
+        */
+       public BuildConsoleStreamDecorator getStream() {
+               return fStream;
+       }
+
+       /**
+        * Returns whether this partition is allowed to be combined with the given
+        * partition.
+        * 
+        * @param partition
+        * @return boolean
+        */
+       public boolean canBeCombinedWith(BuildConsolePartition partition) {
+               // Error partitions never can be combined together
+               String type = getType();
+               if (isProblemPartitionType(type)) {
+                       return false; 
+               }
+
+               int start = getOffset();
+               int end = start + getLength();
+               int otherStart = partition.getOffset();
+               int otherEnd = otherStart + partition.getLength();
+               boolean overlap = (otherStart >= start && otherStart <= end) || (start >= otherStart && start <= otherEnd);
+               return getStream() != null && overlap && type.equals(partition.getType()) && getStream().equals(partition.getStream());
+       }
+
+       /**
+        * Returns a new partition representing this and the given parition
+        * combined.
+        * 
+        * @param partition
+        * @return partition
+        */
+       public BuildConsolePartition combineWith(BuildConsolePartition partition) {
+               int start = getOffset();
+               int end = start + getLength();
+               int otherStart = partition.getOffset();
+               int otherEnd = otherStart + partition.getLength();
+               int theStart = Math.min(start, otherStart);
+               int theEnd = Math.max(end, otherEnd);
+               return createNewPartition(theStart, theEnd - theStart, CONSOLE_PARTITION_TYPE);
+       }
+
+       /**
+        * Creates a new partition of this type with the given offset, and length.
+        * @param offset
+        * @param length
+        * @return a new partition with the given range
+        */
+       public BuildConsolePartition createNewPartition(int offset, int length, String type) {
+               return new BuildConsolePartition(getStream(), offset, length, type, getMarker());
+       }
+
+       public ProblemMarkerInfo getMarker() {
+               return fMarker;
+       }
+
+       public static boolean isProblemPartitionType(String type) {
+               return type==BuildConsolePartition.ERROR_PARTITION_TYPE
+                       || type==BuildConsolePartition.WARNING_PARTITION_TYPE
+                       || type==BuildConsolePartition.INFO_PARTITION_TYPE;
+       }
+       
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java
new file mode 100644 (file)
index 0000000..648bed3
--- /dev/null
@@ -0,0 +1,636 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation
+ *     Andrew Gvozdev (Quoin Inc.)  - Copy build log (bug 306222)
+ *     Alex Collins (Broadcom Corp.) - Global console
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.buildconsole;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.jface.text.IDocumentPartitionerExtension;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.console.ConsolePlugin;
+
+import org.eclipse.cdt.core.ConsoleOutputStream;
+import org.eclipse.cdt.core.ProblemMarkerInfo;
+import org.eclipse.cdt.core.resources.IConsole;
+import org.eclipse.cdt.core.resources.ResourcesUtil;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage;
+
+public class BuildConsolePartitioner
+               implements
+                       IDocumentPartitioner,
+                       IDocumentPartitionerExtension,
+                       IConsole,
+                       IPropertyChangeListener {
+
+       private IProject fProject;
+
+       /**
+        * List of partitions
+        */
+       List<ITypedRegion> fPartitions = new ArrayList<ITypedRegion>(5);
+
+       private int fMaxLines;
+
+       /**
+        * The stream that was last appended to
+        */
+       BuildConsoleStreamDecorator fLastStream = null;
+
+       BuildConsoleDocument fDocument;
+       DocumentMarkerManager fDocumentMarkerManager;
+       boolean killed;
+       BuildConsoleManager fManager;
+
+       /**
+        * A queue of stream entries written to standard out and standard err.
+        * Entries appended to the end of the queue and removed from the front.
+        * Intentionally a vector to obtain synchronization as entries are added and
+        * removed.
+        */
+       Vector<StreamEntry> fQueue = new Vector<StreamEntry>(5);
+
+       private URI fLogURI;
+       private OutputStream fLogStream;
+
+       private class StreamEntry {
+               static public final int EVENT_APPEND = 0;
+               static public final int EVENT_OPEN_LOG = 1;
+               static public final int EVENT_CLOSE_LOG = 2;
+               static public final int EVENT_OPEN_APPEND_LOG = 3;
+
+               /** Identifier of the stream written to. */
+               private BuildConsoleStreamDecorator fStream;
+               /** The text written */
+               private StringBuffer fText = null;
+               /** Problem marker corresponding to the line of text */
+               private ProblemMarkerInfo fMarker;
+               /** Type of event **/
+               private int eventType;
+
+               public StreamEntry(String text, BuildConsoleStreamDecorator stream, ProblemMarkerInfo marker) {
+                       fText = new StringBuffer(text);
+                       fStream = stream;
+                       fMarker = marker;
+                       eventType = EVENT_APPEND;
+               }
+
+               /**
+                * This constructor is used for special events such as clear console or close log.
+                *
+                * @param event - kind of event.
+                */
+               public StreamEntry(int event) {
+                       fText = null;
+                       fStream = null;
+                       fMarker = null;
+                       eventType = event;
+               }
+
+               /**
+                * Returns the stream identifier
+                */
+               public BuildConsoleStreamDecorator getStream() {
+                       return fStream;
+               }
+
+               public void appendText(String text) {
+                       fText.append(text);
+               }
+
+               public int size() {
+                       return fText.length();
+               }
+
+               /**
+                * Returns the text written
+                */
+               public String getText() {
+                       return fText.toString();
+               }
+
+               /**
+                * Returns error marker
+                */
+               public ProblemMarkerInfo getMarker() {
+                       return fMarker;
+               }
+
+               /**
+                * Returns type of event
+                */
+               public int getEventType() {
+                       return eventType;
+               }
+
+       }
+
+       /**
+        * Construct a partitioner that is not associated with a specific project
+        */
+       public BuildConsolePartitioner(BuildConsoleManager manager) {
+               this(null, manager);
+       }
+
+       public BuildConsolePartitioner(IProject project, BuildConsoleManager manager) {
+               fProject = project;
+               fManager = manager;
+               fMaxLines = BuildConsolePreferencePage.buildConsoleLines();
+               fDocument = new BuildConsoleDocument();
+               fDocument.setDocumentPartitioner(this);
+               fDocumentMarkerManager = new DocumentMarkerManager(fDocument, this);
+               connect(fDocument);
+
+               fLogURI = null;
+               fLogStream = null;
+       }
+
+       /**
+        * Sets the indicator that stream was opened so logging can be started. Should be called
+        * when opening the output stream.
+        */
+       public void setStreamOpened() {
+               fQueue.add(new StreamEntry(StreamEntry.EVENT_OPEN_LOG));
+               asyncProcessQueue();
+       }
+
+       /**
+        * Open the stream for appending. Must be called after a call to setStreamOpened().
+        * Can be used to reopen a stream for writing after it has been closed, without
+        * emptying the log file.
+        */
+       public void setStreamAppend() {
+               fQueue.add(new StreamEntry(StreamEntry.EVENT_OPEN_APPEND_LOG));
+               asyncProcessQueue();
+       }
+
+       /**
+        * Sets the indicator that stream was closed so logging should be stopped. Should be called when
+        * build process has finished. Note that there could still be unprocessed console
+        * stream entries in the queue being worked on in the background.
+        */
+       public void setStreamClosed() {
+               fQueue.add(new StreamEntry(StreamEntry.EVENT_CLOSE_LOG));
+               asyncProcessQueue();
+       }
+
+       /**
+        * Adds the new text to the document.
+        *
+        * @param text - the text to append.
+        * @param stream - the stream to append to.
+        */
+       public void appendToDocument(String text, BuildConsoleStreamDecorator stream, ProblemMarkerInfo marker) {
+               boolean addToQueue = true;
+               synchronized (fQueue) {
+                       int i = fQueue.size();
+                       if (i > 0) {
+                               StreamEntry entry = fQueue.get(i - 1);
+                               // if last stream is the same and we have not exceeded our
+                               // display write limit, append.
+                               if (entry.getStream()==stream && entry.getEventType()==StreamEntry.EVENT_APPEND && entry.getMarker()==marker && entry.size()<10000) {
+                                       entry.appendText(text);
+                                       addToQueue = false;
+                               }
+                       }
+                       if (addToQueue) {
+                               fQueue.add(new StreamEntry(text, stream, marker));
+                       }
+               }
+               if (addToQueue) {
+                       asyncProcessQueue();
+               }
+       }
+
+       /**
+        * Asynchronous processing of stream entries to append to console.
+        * Note that all these are processed by the same thread - the user-interface thread
+        * as of {@link Display#asyncExec(Runnable)}.
+        */
+       private void asyncProcessQueue() {
+               Runnable r = new Runnable() {
+                       public void run() {
+                               StreamEntry entry;
+                               try {
+                                       entry = fQueue.remove(0);
+                               } catch (ArrayIndexOutOfBoundsException e) {
+                                       return;
+                               }
+                               switch (entry.getEventType()) {
+                               case StreamEntry.EVENT_OPEN_LOG:
+                               case StreamEntry.EVENT_OPEN_APPEND_LOG:
+                                       logOpen(entry.getEventType() == StreamEntry.EVENT_OPEN_APPEND_LOG);
+                                       break;
+                               case StreamEntry.EVENT_APPEND:
+                                       fLastStream = entry.getStream();
+                                       try {
+                                               warnOfContentChange(fLastStream);
+
+                                               if (fLastStream == null) {
+                                                       // special case to empty document
+                                                       fPartitions.clear();
+                                                       fDocumentMarkerManager.clear();
+                                                       fDocument.set(""); //$NON-NLS-1$
+                                               }
+                                               String text = entry.getText();
+                                               if (text.length()>0) {
+                                                       addStreamEntryToDocument(entry);
+                                                       log(text);
+                                                       checkOverflow();
+                                               }
+                                       } catch (BadLocationException e) {
+                                       }
+                                       break;
+                               case StreamEntry.EVENT_CLOSE_LOG:
+                                       logClose();
+                                       break;
+                               }
+                       }
+
+                       /**
+                        * Open the log
+                        * @param append Set to true if the log should be opened for appending, false for overwriting.
+                        */
+                       private void logOpen(boolean append) {
+                               fLogURI = fManager.getLogURI(fProject);
+                               if (fLogURI!=null) {
+                                       try {
+                                               IFileStore logStore = EFS.getStore(fLogURI);
+                                               // Ensure the directory exists before opening the file
+                                               IFileStore dir = logStore.getParent();
+                                               if (dir != null)
+                                                       dir.mkdir(EFS.NONE, null);
+                                               int opts = append ? EFS.APPEND : EFS.NONE;
+                                               fLogStream = logStore.openOutputStream(opts, null);
+                                       } catch (CoreException e) {
+                                               CUIPlugin.log(e);
+                                       } finally {
+                                               ResourcesUtil.refreshWorkspaceFiles(fLogURI);
+                                       }
+                               }
+                       }
+
+                       private void log(String text) {
+                               if (fLogStream!=null) {
+                                       try {
+                                               fLogStream.write(text.getBytes());
+                                               if (fQueue.isEmpty()) {
+                                                       fLogStream.flush();
+                                               }
+                                       } catch (IOException e) {
+                                               CUIPlugin.log(e);
+                                       } finally {
+                                               ResourcesUtil.refreshWorkspaceFiles(fLogURI);
+                                       }
+                               }
+                       }
+
+                       private void logClose() {
+                               if (fLogStream!=null) {
+                                       try {
+                                               fLogStream.close();
+                                       } catch (IOException e) {
+                                               CUIPlugin.log(e);
+                                       } finally {
+                                               ResourcesUtil.refreshWorkspaceFiles(fLogURI);
+                                       }
+                                       fLogStream = null;
+                               }
+                       }
+
+               };
+               Display display = CUIPlugin.getStandardDisplay();
+               if (display != null) {
+                       display.asyncExec(r);
+               }
+       }
+
+       private void addStreamEntryToDocument(StreamEntry entry) throws BadLocationException {
+               ProblemMarkerInfo marker = entry.getMarker();
+               if (marker==null) {
+                       // It is plain unmarkered console output
+                       addPartition(new BuildConsolePartition(fLastStream,
+                                       fDocument.getLength(),
+                                       entry.getText().length(),
+                                       BuildConsolePartition.CONSOLE_PARTITION_TYPE));
+               } else {
+                       // this text line in entry is markered with ProblemMarkerInfo,
+                       // create special partition for it.
+                       String errorPartitionType;
+                       if (marker.severity==IMarker.SEVERITY_INFO) {
+                               errorPartitionType = BuildConsolePartition.INFO_PARTITION_TYPE;
+                       } else if (marker.severity==IMarker.SEVERITY_WARNING) {
+                               errorPartitionType = BuildConsolePartition.WARNING_PARTITION_TYPE;
+                       } else {
+                               errorPartitionType = BuildConsolePartition.ERROR_PARTITION_TYPE;
+                       }
+                       addPartition(new BuildConsolePartition(fLastStream,
+                                       fDocument.getLength(),
+                                       entry.getText().length(),
+                                       errorPartitionType, marker));
+               }
+               fDocument.replace(fDocument.getLength(), 0, entry.getText());
+       }
+
+       void warnOfContentChange(BuildConsoleStreamDecorator stream) {
+               if (stream != null) {
+                       ConsolePlugin.getDefault().getConsoleManager().warnOfContentChange(stream.getConsole());
+               }
+               fManager.showConsole();
+       }
+
+       public IDocument getDocument() {
+               return fDocument;
+       }
+
+       public void setDocumentSize(int nLines) {
+               fMaxLines = nLines;
+               nLines = fDocument.getNumberOfLines();
+               checkOverflow();
+       }
+
+       public void connect(IDocument document) {
+               CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
+       }
+
+       public void disconnect() {
+               fDocument.setDocumentPartitioner(null);
+               CUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
+               killed = true;
+       }
+
+       public void documentAboutToBeChanged(DocumentEvent event) {
+       }
+
+       public boolean documentChanged(DocumentEvent event) {
+               return documentChanged2(event) != null;
+       }
+
+       /**
+        * @see org.eclipse.jface.text.IDocumentPartitioner#getLegalContentTypes()
+        */
+       public String[] getLegalContentTypes() {
+               return new String[]{BuildConsolePartition.CONSOLE_PARTITION_TYPE};
+       }
+
+       /**
+        * @see org.eclipse.jface.text.IDocumentPartitioner#getContentType(int)
+        */
+       public String getContentType(int offset) {
+               ITypedRegion partition = getPartition(offset);
+               if (partition != null) {
+                       return partition.getType();
+               }
+               return null;
+       }
+
+       /**
+        * @see org.eclipse.jface.text.IDocumentPartitioner#computePartitioning(int,
+        *      int)
+        */
+       public ITypedRegion[] computePartitioning(int offset, int length) {
+               if (offset == 0 && length == fDocument.getLength()) {
+                       return fPartitions.toArray(new ITypedRegion[fPartitions.size()]);
+               }
+               int end = offset + length;
+               List<ITypedRegion> list = new ArrayList<ITypedRegion>();
+               for (int i = 0; i < fPartitions.size(); i++) {
+                       ITypedRegion partition = fPartitions.get(i);
+                       int partitionStart = partition.getOffset();
+                       int partitionEnd = partitionStart + partition.getLength();
+                       if ( (offset >= partitionStart && offset <= partitionEnd) ||
+                                       (offset < partitionStart && end >= partitionStart)) {
+                               list.add(partition);
+                       }
+               }
+               return list.toArray(new ITypedRegion[list.size()]);
+       }
+
+       /**
+        * @see org.eclipse.jface.text.IDocumentPartitioner#getPartition(int)
+        */
+       public ITypedRegion getPartition(int offset) {
+               for (int i = 0; i < fPartitions.size(); i++) {
+                       ITypedRegion partition = fPartitions.get(i);
+                       int start = partition.getOffset();
+                       int end = start + partition.getLength();
+                       if (offset >= start && offset < end) {
+                               return partition;
+                       }
+               }
+               return null;
+       }
+
+       public IRegion documentChanged2(DocumentEvent event) {
+               String text = event.getText();
+               if (getDocument().getLength() == 0) {
+                       // cleared
+                       fPartitions.clear();
+                       return new Region(0, 0);
+               }
+               ITypedRegion[] affectedRegions = computePartitioning(event.getOffset(), text.length());
+               if (affectedRegions.length == 0) {
+                       return null;
+               }
+               if (affectedRegions.length == 1) {
+                       return affectedRegions[0];
+               }
+               int affectedLength = affectedRegions[0].getLength();
+               for (int i = 1; i < affectedRegions.length; i++) {
+                       ITypedRegion region = affectedRegions[i];
+                       affectedLength += region.getLength();
+               }
+
+               return new Region(affectedRegions[0].getOffset(), affectedLength);
+       }
+
+       /**
+        * Checks to see if the console buffer has overflowed, and empties the
+        * overflow if needed, updating partitions and hyperlink positions.
+        */
+       protected void checkOverflow() {
+               if (fMaxLines >= 0) {
+                       int nLines = fDocument.getNumberOfLines();
+                       if (nLines > fMaxLines + 1) {
+                               int overflow = 0;
+                               try {
+                                       overflow = fDocument.getLineOffset(nLines - fMaxLines);
+                               } catch (BadLocationException e1) {
+                               }
+                               // update partitions
+                               List<ITypedRegion> newParitions = new ArrayList<ITypedRegion>(fPartitions.size());
+                               Iterator<ITypedRegion> partitions = fPartitions.iterator();
+                               while (partitions.hasNext()) {
+                                       ITypedRegion region = partitions.next();
+                                       if (region instanceof BuildConsolePartition) {
+                                               BuildConsolePartition messageConsolePartition = (BuildConsolePartition)region;
+
+                                               ITypedRegion newPartition = null;
+                                               int offset = region.getOffset();
+                                               String type = messageConsolePartition.getType();
+                                               if (offset < overflow) {
+                                                       int endOffset = offset + region.getLength();
+                                                       if (endOffset < overflow || BuildConsolePartition.isProblemPartitionType(type)) {
+                                                               // remove partition,
+                                                               // partitions with problem markers can't be split - remove them too
+                                                       } else {
+                                                               // split partition
+                                                               int length = endOffset - overflow;
+                                                               newPartition = messageConsolePartition.createNewPartition(0, length, type);
+                                                       }
+                                               } else {
+                                                       // modify partition offset
+                                                       offset = messageConsolePartition.getOffset() - overflow;
+                                                       newPartition = messageConsolePartition.createNewPartition(offset, messageConsolePartition.getLength(), type);
+                                               }
+                                               if (newPartition != null) {
+                                                       newParitions.add(newPartition);
+                                               }
+                                       }
+                               }
+                               fPartitions = newParitions;
+                               fDocumentMarkerManager.moveToFirstError();
+
+                               try {
+                                       fDocument.replace(0, overflow, ""); //$NON-NLS-1$
+                               } catch (BadLocationException e) {
+                               }
+                       }
+               }
+       }
+
+       /**
+        * Adds a new partition, combining with the previous partition if possible.
+        */
+       private BuildConsolePartition addPartition(BuildConsolePartition partition) {
+               if (fPartitions.isEmpty()) {
+                       fPartitions.add(partition);
+               } else {
+                       int index = fPartitions.size() - 1;
+                       BuildConsolePartition last = (BuildConsolePartition)fPartitions.get(index);
+                       if (last.canBeCombinedWith(partition)) {
+                               // replace with a single partition
+                               partition = last.combineWith(partition);
+                               fPartitions.set(index, partition);
+                       } else {
+                               // different kinds - add a new parition
+                               fPartitions.add(partition);
+                       }
+               }
+               return partition;
+       }
+
+       public IConsole getConsole() {
+               return this;
+       }
+
+       public void propertyChange(PropertyChangeEvent event) {
+               if (event.getProperty() == BuildConsolePreferencePage.PREF_BUILDCONSOLE_LINES) {
+                       setDocumentSize(BuildConsolePreferencePage.buildConsoleLines());
+               }
+       }
+
+       public void start(final IProject project) {
+               Display display = CUIPlugin.getStandardDisplay();
+               if (display != null) {
+                       display.asyncExec(new Runnable() {
+                               public void run() {
+                                       fLogStream = null;
+                                       fLogURI = null;
+                                       fManager.startConsoleActivity(project);
+                               }
+                       });
+               }
+
+
+               if (BuildConsolePreferencePage.isClearBuildConsole()) {
+                       appendToDocument("", null, null); //$NON-NLS-1$
+               }
+       }
+
+       public ConsoleOutputStream getOutputStream() throws CoreException {
+               return new BuildOutputStream(this, fManager.getStreamDecorator(BuildConsoleManager.BUILD_STREAM_TYPE_OUTPUT));
+       }
+
+       public ConsoleOutputStream getInfoStream() throws CoreException {
+               return new BuildOutputStream(this, fManager.getStreamDecorator(BuildConsoleManager.BUILD_STREAM_TYPE_INFO));
+       }
+
+       public ConsoleOutputStream getErrorStream() throws CoreException {
+               return new BuildOutputStream(this, fManager.getStreamDecorator(BuildConsoleManager.BUILD_STREAM_TYPE_ERROR));
+       }
+
+       /** This method is useful for future debugging and bug-fixing */
+       @SuppressWarnings({ "unused", "nls" })
+       private void printDocumentPartitioning() {
+               System.out.println("Document partitioning: ");
+               for (ITypedRegion tr : fPartitions) {
+                       BuildConsolePartition p = (BuildConsolePartition) tr;
+                       int start = p.getOffset();
+                       int end = p.getOffset() + p.getLength();
+                       String text;
+                       String isError = "U";
+                       String type = p.getType();
+                       if (type == BuildConsolePartition.ERROR_PARTITION_TYPE) {
+                               isError = "E";
+                       } else if (type == BuildConsolePartition.WARNING_PARTITION_TYPE) {
+                               isError = "W";
+                       } else if (type == BuildConsolePartition.INFO_PARTITION_TYPE) {
+                               isError = "I";
+                       } else if (type == BuildConsolePartition.CONSOLE_PARTITION_TYPE) {
+                               isError = "C";
+                       }
+                       try {
+                               text = fDocument.get(p.getOffset(), p.getLength());
+                       } catch (BadLocationException e) {
+                               text = "N/A";
+                       }
+                       if (text.endsWith("\n")) {
+                               text = text.substring(0, text.length() - 1);
+                       }
+                       System.out.println("    " + isError + " " + start + "-" + end + ":[" + text + "]");
+               }
+       }
+
+       /**
+        * @return {@link URI} location of log file.
+        */
+       public URI getLogURI() {
+               return fLogURI;
+       }
+
+       IProject getProject() {
+               return fProject;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleStreamDecorator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleStreamDecorator.java
new file mode 100644 (file)
index 0000000..363d1d0
--- /dev/null
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ * Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.buildconsole;
+
+import org.eclipse.swt.graphics.Color;
+
+
+public class BuildConsoleStreamDecorator {
+       private BuildConsole fConsole = null;
+       
+       private Color fColor = null;
+       
+       /**
+        * Constructs a new stream connected to the given console.
+        * 
+        */
+       public BuildConsoleStreamDecorator() {
+       }
+
+       public void setConsole(BuildConsole console) {
+               fConsole = console;
+       }
+
+       /**
+        * Sets the color of this message stream
+        * 
+        * @param color color of this message stream, possibly <code>null</code>
+        */
+       public void setColor(Color color) {
+               Color old = fColor;
+               fColor = color;
+               if (fConsole != null) {
+                       fConsole.firePropertyChange(this, BuildConsole.P_STREAM_COLOR, old, color);
+               }
+       }
+       
+       /**
+        * Returns the color of this message stream, or <code>null</code>
+        * if default.
+        * 
+        * @return the color of this message stream, or <code>null</code>
+        */
+       public Color getColor() {
+               return fColor;
+       }
+       
+       /**
+        * Returns the console this stream is connected to.
+        * 
+        * @return the console this stream is connected to
+        */
+       public BuildConsole getConsole() {
+               return fConsole;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleViewer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleViewer.java
new file mode 100644 (file)
index 0000000..7b309e6
--- /dev/null
@@ -0,0 +1,273 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ * Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.buildconsole;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentListener;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.TextViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.LineBackgroundEvent;
+import org.eclipse.swt.custom.LineBackgroundListener;
+import org.eclipse.swt.custom.LineStyleEvent;
+import org.eclipse.swt.custom.LineStyleListener;
+import org.eclipse.swt.custom.StyleRange;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.MouseTrackListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+public class BuildConsoleViewer extends TextViewer
+       implements  LineStyleListener,
+                               LineBackgroundListener,
+                               MouseTrackListener,
+                               MouseListener {
+
+       protected InternalDocumentListener fInternalDocumentListener = new InternalDocumentListener();
+       /**
+        * Whether the console scrolls as output is appended.
+        */
+       private boolean fAutoScroll = true;
+       /**
+        * Internal document listener.
+        */
+       class InternalDocumentListener implements IDocumentListener {
+
+               /*
+                * (non-Javadoc)
+                *
+                * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
+                */
+               public void documentAboutToBeChanged(DocumentEvent e) {
+               }
+
+               /*
+                * (non-Javadoc)
+                *
+                * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent)
+                */
+               public void documentChanged(DocumentEvent e) {
+                       revealEndOfDocument();
+               }
+       }
+
+       /**
+        * Sets whether this viewer should auto-scroll as output is appended to the
+        * document.
+        *
+        * @param scroll
+        */
+       public void setAutoScroll(boolean scroll) {
+               fAutoScroll = scroll;
+       }
+
+       /**
+        * Returns whether this viewer should auto-scroll as output is appended to
+        * the document.
+        */
+       public boolean isAutoScroll() {
+               return fAutoScroll;
+       }
+
+       /**
+        * Creates a new console viewer and adds verification checking to only
+        * allow text modification if the text is being modified in the editable
+        * portion of the underlying document.
+        *
+        * @see org.eclipse.swt.events.VerifyListener
+        */
+       public BuildConsoleViewer(Composite parent) {
+               super(parent, getSWTStyles());
+               StyledText styledText = getTextWidget();
+               styledText.addLineStyleListener(this);
+               styledText.addLineBackgroundListener(this);
+               styledText.addMouseTrackListener(this);
+               styledText.setFont(parent.getFont());
+               styledText.setDoubleClickEnabled(true);
+               styledText.setEditable(false);
+               styledText.setWordWrap(true);
+       }
+
+       /**
+        * Returns the SWT style flags used when instantiating this viewer
+        */
+       private static int getSWTStyles() {
+               int styles = SWT.H_SCROLL | SWT.V_SCROLL;
+               return styles;
+       }
+
+       /**
+        * Reveals (makes visible) the end of the current document
+        */
+       protected void revealEndOfDocument() {
+               if (isAutoScroll()) {
+                       IDocument doc = getDocument();
+                       int lines = doc.getNumberOfLines();
+                       try {
+                               // lines are 0-based
+                               int lineStartOffset = doc.getLineOffset(lines - 1);
+                               StyledText widget = getTextWidget();
+                               if (lineStartOffset > 0) {
+                                       widget.setCaretOffset(lineStartOffset);
+                                       widget.showSelection();
+                               }
+                               int lineEndOffset = lineStartOffset + doc.getLineLength(lines - 1);
+                               if (lineEndOffset > 0) {
+                                       widget.setCaretOffset(lineEndOffset);
+                               }
+                       } catch (BadLocationException e) {
+                       }
+               }
+       }
+
+       /*
+        * (non-Javadoc)
+        *
+        * @see org.eclipse.jface.text.ITextViewer#setDocument(org.eclipse.jface.text.IDocument)
+        */
+       @Override
+       public void setDocument(IDocument doc) {
+               IDocument oldDoc = getDocument();
+               IDocument document = doc;
+               if (oldDoc == null && document == null) {
+                       return;
+               }
+               if (oldDoc != null) {
+                       oldDoc.removeDocumentListener(fInternalDocumentListener);
+                       if (oldDoc.equals(document)) {
+                               document.addDocumentListener(fInternalDocumentListener);
+                               return;
+                       }
+               }
+
+               super.setDocument(document);
+               if (document != null) {
+                       revealEndOfDocument();
+                       document.addDocumentListener(fInternalDocumentListener);
+               }
+       }
+
+       /*
+        * (non-Javadoc)
+        *
+        * @see org.eclipse.swt.custom.LineStyleListener#lineGetStyle(org.eclipse.swt.custom.LineStyleEvent)
+        */
+       public void lineGetStyle(LineStyleEvent event) {
+               IDocument document = getDocument();
+               if (document == null) return;
+               BuildConsolePartitioner partitioner = (BuildConsolePartitioner) document.getDocumentPartitioner();
+               if (partitioner == null) return;
+
+               BuildConsolePartition p = partitioner.fDocumentMarkerManager.getCurrentPartition();
+               Color problemHighlightedColor =  partitioner.fManager.getProblemHighlightedColor();
+
+               // Note, computePartitioning actually doesn't change anything in partitioning,
+               // but only computes number of affected regions.
+               ITypedRegion[] regions = partitioner.computePartitioning(event.lineOffset, event.lineText.length());
+               StyleRange[] styles = new StyleRange[regions.length];
+               for (int i = 0; i < regions.length; i++) {
+                       BuildConsolePartition partition = (BuildConsolePartition) regions[i];
+                       if (partition.getStream()== null) return;
+
+                       Color colorFG = partition.getStream().getColor();
+                       Color colorBG = null;
+
+                       // Highlight current partition
+                       if ( partition == p ) {
+                               colorFG = problemHighlightedColor;
+                       }
+                       StyleRange styleRange = new StyleRange(partition.getOffset(), partition.getLength(), colorFG, colorBG);
+                       styles[i] = styleRange;
+               }
+               event.styles = styles;
+       }
+
+       public void selectPartition(BuildConsolePartitioner partitioner, BuildConsolePartition p) {
+               try {
+                       int start = partitioner.getDocument().getLineOfOffset(p.getOffset());
+                       int end = partitioner.getDocument().getLineOfOffset(p.getOffset()+p.getLength()-1);
+
+                       if ( fAutoScroll ) {
+                               // Check if area around this line is visible, scroll if needed
+                               int top = getTopIndex();
+                               int bottom = getBottomIndex();
+                               if ( start < top + 1 ) {
+                                       setTopIndex(start - 1 > 0 ? start - 1 : 0);
+                               } else if ( end > bottom -1 ) {
+                                       setTopIndex(top + start - bottom + 1);
+                               }
+                       }
+
+                       // Select line
+                       StyledText st = getTextWidget();
+                       st.redrawRange(0, partitioner.getDocument().getLength(), true);
+
+               } catch (BadLocationException e) {
+                       CUIPlugin.log(e);
+               }
+       }
+
+       public void mouseEnter(MouseEvent e) {
+               getTextWidget().addMouseListener(this);
+       }
+
+       public void mouseExit(MouseEvent e) {
+               getTextWidget().removeMouseListener(this);
+       }
+
+       public void mouseHover(MouseEvent e) {
+       }
+
+       public void mouseDoubleClick(MouseEvent e) {
+               int offset = -1;
+               try {
+                       Point p = new Point(e.x, e.y);
+                       offset = getTextWidget().getOffsetAtLocation(p);
+                       BuildConsole.getCurrentPage().moveToError(offset);
+               } catch (IllegalArgumentException ex) {
+               }
+       }
+
+       public void mouseDown(MouseEvent e) {
+       }
+
+       public void mouseUp(MouseEvent e) {
+       }
+
+       public void lineGetBackground(LineBackgroundEvent event) {
+               IDocument document = getDocument();
+               if (document == null) return;
+               BuildConsolePartitioner partitioner = (BuildConsolePartitioner) document.getDocumentPartitioner();
+               if (partitioner == null) return;
+
+               BuildConsolePartition partition = (BuildConsolePartition) partitioner.getPartition(event.lineOffset);
+               // Set background for error partitions
+               if (partition!=null) {
+                       String type = partition.getType();
+                       if (type==BuildConsolePartition.ERROR_PARTITION_TYPE) {
+                               event.lineBackground = partitioner.fManager.getProblemBackgroundColor();
+                       } else if (type==BuildConsolePartition.WARNING_PARTITION_TYPE) {
+                               event.lineBackground = partitioner.fManager.getWarningBackgroundColor();
+                       } else if (type==BuildConsolePartition.INFO_PARTITION_TYPE) {
+                               event.lineBackground = partitioner.fManager.getInfoBackgroundColor();
+                       }
+               }
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildOutputStream.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildOutputStream.java
new file mode 100644 (file)
index 0000000..a5ce089
--- /dev/null
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation
+ *     Alex Collins (Broadcom Corp.) - Global build console
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.buildconsole;
+
+import java.io.IOException;
+
+import org.eclipse.cdt.core.ConsoleOutputStream;
+import org.eclipse.cdt.core.ProblemMarkerInfo;
+
+import org.eclipse.cdt.internal.core.IErrorMarkeredOutputStream;
+
+/**
+ * Output stream which put all output to BuildConsolePartitioner 
+ * and informs it when stream is closed
+ */
+public class BuildOutputStream extends ConsoleOutputStream implements IErrorMarkeredOutputStream {
+
+       final BuildConsoleStreamDecorator fStream;
+       private BuildConsolePartitioner fPartitioner;
+
+       public BuildOutputStream(BuildConsolePartitioner partitioner, 
+                       BuildConsoleStreamDecorator stream) {
+               fPartitioner = partitioner;
+               if (fPartitioner.getProject() == null)
+                       // Note: The global console log stream should have been
+                       // opened by BuildConsoleManager.startGlobalConsole()
+                       fPartitioner.setStreamAppend();
+               else
+                       fPartitioner.setStreamOpened();
+               fStream = stream;
+       }
+
+       @Override
+       public void flush() throws IOException {
+       }
+
+       @Override
+       public void close() throws IOException {
+               flush();
+               fPartitioner.setStreamClosed();
+       }
+
+       @Override
+       public void write(byte[] b, int off, int len) throws IOException {
+               fPartitioner.appendToDocument(new String(b, off, len), fStream, null);
+       }
+
+       public void write(String s, ProblemMarkerInfo marker) throws IOException {
+               fPartitioner.appendToDocument(s, fStream, marker);
+               
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CBuildConsole.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CBuildConsole.java
new file mode 100644 (file)
index 0000000..fb49394
--- /dev/null
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2006 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.buildconsole;
+
+import java.net.URL;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.cdt.core.ConsoleOutputStream;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.IBuildConsoleManager;
+
+import org.eclipse.cdt.internal.core.ICConsole;
+
+/**
+ * CDT console adaptor providing output streams. The adaptor provides means of
+ * access to UI plugin console.
+ */
+public class CBuildConsole implements ICConsole {
+       IProject project;
+       IBuildConsoleManager fConsoleManager;
+       
+       /**
+        * Constructor for BuildConsole.
+        */
+       public CBuildConsole() {
+       }
+
+       public void init(String contextId, String name, URL iconUrl) {
+               if (contextId==null)
+                       fConsoleManager = CUIPlugin.getDefault().getConsoleManager();
+               else
+                       fConsoleManager = CUIPlugin.getDefault().getConsoleManager(name, contextId, iconUrl); // careful with order of arguments
+       }
+
+       /**
+        * Start the console for a given project.
+        * 
+        * @param project - the project to start the console.
+        */
+       public void start(IProject project) {
+               this.project = project;
+               fConsoleManager.getConsole(project).start(project);
+       }
+       
+       /**
+        * @throws CoreException
+        * @see org.eclipse.cdt.core.resources.IConsole#getOutputStream()
+        */
+       public ConsoleOutputStream getOutputStream() throws CoreException {
+               Assert.isNotNull(project, ConsoleMessages.CBuildConsole_Console_Must_Be_Started_First);
+               return fConsoleManager.getConsole(project).getOutputStream();
+       }
+
+       public ConsoleOutputStream getInfoStream() throws CoreException {
+               Assert.isNotNull(project, ConsoleMessages.CBuildConsole_Console_Must_Be_Started_First);
+               return fConsoleManager.getConsole(project).getInfoStream();
+       }
+
+       public ConsoleOutputStream getErrorStream() throws CoreException {
+               Assert.isNotNull(project, ConsoleMessages.CBuildConsole_Console_Must_Be_Started_First);
+               return fConsoleManager.getConsole(project).getErrorStream();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleEvent.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleEvent.java
new file mode 100644 (file)
index 0000000..fd84976
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2006 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.buildconsole;
+
+import java.util.EventObject;
+
+import org.eclipse.cdt.ui.IBuildConsoleEvent;
+import org.eclipse.core.resources.IProject;
+
+public class ConsoleEvent extends EventObject implements IBuildConsoleEvent {
+
+       /**
+        * Comment for <code>serialVersionUID</code>
+        */
+       private static final long serialVersionUID = 1L;
+
+       private IProject fProject;
+       private int fType;
+
+       public ConsoleEvent(Object source, IProject project, int type) {
+               super(source);
+               fProject = project;
+               fType = type;
+       }
+
+       public IProject getProject() {
+               return fProject;
+       }
+
+       public int getType() {
+               return fType;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleMessages.java
new file mode 100644 (file)
index 0000000..a30e5a5
--- /dev/null
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ * Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation
+ *                                Save build output
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.buildconsole;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class ConsoleMessages extends NLS {
+
+       static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.buildconsole.ConsoleMessages";//$NON-NLS-1$
+
+       private ConsoleMessages() {
+               // Do not instantiate
+       }
+
+       public static String BuildConsole_GlobalConsole;
+       public static String find_replace_action_label;
+       public static String find_replace_action_tooltip;
+       public static String find_replace_action_image;
+       public static String find_replace_action_description;
+       public static String BuildConsolePage__Copy_Ctrl_C_6;
+       public static String BuildConsolePage_Copy_7;
+       public static String BuildConsolePage_Select__All_Ctrl_A_12;
+       public static String BuildConsolePage_Select_All;
+       public static String ScrollLockAction_Scroll_Lock_1;
+       public static String PreviousErrorAction_Tooltip;
+       public static String NextErrorAction_Tooltip;
+       public static String ShowErrorAction_Tooltip;
+       public static String CBuildConsole_Console_Must_Be_Started_First;
+       public static String CopyLog_ActionTooltip;
+       public static String CopyLog_BuildNotLogged;
+       public static String CopyLog_ChooseDestination;
+       public static String CopyLog_ErrorCopyingFile;
+       public static String CopyLog_ErrorWhileCopyingLog;
+       public static String CopyLog_InvalidDestination;
+       public static String CopyLog_LogFileIsNotAvailable;
+       public static String CopyLog_UnableToAccess;
+       public static String CopyLog_UnavailableLog;
+
+       static {
+               NLS.initializeMessages(BUNDLE_NAME, ConsoleMessages.class);
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleMessages.properties
new file mode 100644 (file)
index 0000000..cc5b532
--- /dev/null
@@ -0,0 +1,40 @@
+###############################################################################
+# Copyright (c) 2003, 2010 QNX Software Systems and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# QNX Software Systems - Initial API and implementation
+# IBM Corporation
+###############################################################################
+
+BuildConsole_GlobalConsole=CDT Global Build Console
+
+find_replace_action_label=&Find/Replace...@Ctrl+F
+find_replace_action_tooltip=Find/Replace
+find_replace_action_image=
+find_replace_action_description=Find/Replace
+
+BuildConsolePage__Copy_Ctrl_C_6=&Copy@Ctrl+C
+BuildConsolePage_Copy_7=Copy
+BuildConsolePage_Select__All_Ctrl_A_12=Select &All@Ctrl+A
+BuildConsolePage_Select_All=Select All
+
+CBuildConsole_Console_Must_Be_Started_First=Build Console must be started with a specific project before being used.
+CopyLog_ActionTooltip=Copy Build Log
+CopyLog_BuildNotLogged=No build was logged. Build the project or/and check the Logging page in project properties.
+CopyLog_ChooseDestination=Choose Log File Destination
+CopyLog_ErrorCopyingFile=Error Copying a File
+CopyLog_ErrorWhileCopyingLog=Error while copying working log file: 
+CopyLog_InvalidDestination=Destination is not valid: 
+CopyLog_LogFileIsNotAvailable=Working log file is not available.
+CopyLog_UnableToAccess=Unable to access build log at 
+CopyLog_UnavailableLog=Unavailable Log
+
+ScrollLockAction_Scroll_Lock_1=Scroll Lock
+
+NextErrorAction_Tooltip=Next Error
+PreviousErrorAction_Tooltip=Previous Error 
+ShowErrorAction_Tooltip=Show Error In Editor
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleOutputTextStore.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleOutputTextStore.java
new file mode 100644 (file)
index 0000000..a1798f6
--- /dev/null
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2006 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.buildconsole;
+
+import org.eclipse.jface.text.ITextStore;
+
+public class ConsoleOutputTextStore implements ITextStore {
+
+       private StringBuffer fBuffer;
+
+       public ConsoleOutputTextStore(int bufferSize) {
+               fBuffer = new StringBuffer(bufferSize);
+       }
+
+       /**
+        * @see ITextStore#get(int)
+        */
+       public char get(int pos) {
+               return fBuffer.charAt(pos);
+       }
+
+       /**
+        * @see ITextStore#get(int, int)
+        */
+       public String get(int pos, int length) {
+               return fBuffer.substring(pos, pos + length);
+       }
+
+       /**
+        * @see ITextStore#getLength()
+        */
+       public int getLength() {
+               return fBuffer.length();
+       }
+
+       /**
+        * @see ITextStore#replace(int, int, String)
+        */
+       public void replace(int pos, int length, String text) {
+               if (text == null) {
+                       text = ""; //$NON-NLS-1$
+               }
+               fBuffer.replace(pos, pos + length, text);
+       }
+
+       /**
+        * @see ITextStore#set(String)
+        */
+       public void set(String text) {
+               fBuffer = new StringBuffer(text);
+       }
+
+       /**
+        * @see StringBuffer#ensureCapacity(int)
+        */
+       public void setMinimalBufferSize(int bufferSize) {
+               fBuffer.ensureCapacity(bufferSize);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CopyBuildLogAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CopyBuildLogAction.java
new file mode 100644 (file)
index 0000000..31bc00b
--- /dev/null
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Andrew Gvozdev and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Andrew Gvozdev (Quoin Inc.) - Initial API and implementation
+ *     Alex Collins (Broadcom Corp.) - Global console
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.buildconsole;
+
+import java.net.URI;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.filesystem.URIUtil;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.cdt.core.resources.IConsole;
+import org.eclipse.cdt.core.resources.ResourcesUtil;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.IBuildConsoleManager;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+
+/**
+ * Action to copy build log from working file to a user selected file.
+ */
+public class CopyBuildLogAction extends Action {
+       private BuildConsolePage fConsolePage;
+
+       public CopyBuildLogAction(BuildConsolePage page) {
+               super();
+               setToolTipText(ConsoleMessages.CopyLog_ActionTooltip);
+               CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_SAVE_CONSOLE);
+               fConsolePage = page;
+       }
+
+       @Override
+       public void run() {
+               IBuildConsoleManager consoleManager = fConsolePage.getConsole().getConsoleManager();
+               IProject project = fConsolePage.getProject();
+               IConsole console = consoleManager.getProjectConsole(project);
+
+               Shell shell = Display.getCurrent().getActiveShell();
+
+               if (console instanceof BuildConsolePartitioner) {
+                       URI srcURI = ((BuildConsolePartitioner)console).getLogURI();
+                       if (srcURI==null) {
+                               MessageDialog.openWarning(shell, ConsoleMessages.CopyLog_UnavailableLog,
+                                               ConsoleMessages.CopyLog_BuildNotLogged);
+                               return;
+                       }
+
+                       IFileStore srcStore = null;
+                       try {
+                               srcStore = EFS.getStore(srcURI);
+                       } catch (CoreException e) {
+                               CUIPlugin.log(e);
+                               MessageDialog.openError(shell, ConsoleMessages.CopyLog_UnavailableLog,
+                                               ConsoleMessages.CopyLog_UnableToAccess+srcURI);
+                               return;
+                       }
+
+                       if (!srcStore.fetchInfo().exists()) {
+                               MessageDialog.openError(shell, ConsoleMessages.CopyLog_UnavailableLog,
+                                               ConsoleMessages.CopyLog_LogFileIsNotAvailable);
+                                       return;
+                       }
+
+                       // open file dialog
+                       FileDialog dialog = new FileDialog(shell, SWT.NONE);
+                       dialog.setText(ConsoleMessages.CopyLog_ChooseDestination);
+
+                       String destLocation = dialog.open();
+                       if (destLocation!=null) {
+                               URI destURI = URIUtil.toURI(destLocation);
+                               if (destURI==null) {
+                                       MessageDialog.openError(shell, ConsoleMessages.CopyLog_UnavailableLog,
+                                                       ConsoleMessages.CopyLog_InvalidDestination+destLocation);
+                                       return;
+                               }
+                               try {
+                                       IFileStore destStore = EFS.getStore(destURI);
+                                       srcStore.copy(destStore, EFS.OVERWRITE, null);
+                               } catch (CoreException e) {
+                                       CUIPlugin.log(e);
+                                       MessageDialog.openError(shell, ConsoleMessages.CopyLog_ErrorCopyingFile,
+                                                       ConsoleMessages.CopyLog_ErrorWhileCopyingLog+e.getLocalizedMessage());
+                               } finally {
+                                       ResourcesUtil.refreshWorkspaceFiles(destURI);
+                               }
+                       }
+               } else {
+                       MessageDialog.openWarning(shell, ConsoleMessages.CopyLog_UnavailableLog,
+                                       ConsoleMessages.CopyLog_BuildNotLogged);
+               }
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/DocumentMarkerManager.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/DocumentMarkerManager.java
new file mode 100644 (file)
index 0000000..5819976
--- /dev/null
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2010 CodeSourcery and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Kozlov (CodeSourcery) - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.buildconsole;
+
+import org.eclipse.jface.text.ITypedRegion;
+
+import org.eclipse.cdt.core.ProblemMarkerInfo;
+
+/**
+ * Manages current position of highlighted error in BuildConsole 
+ */
+class DocumentMarkerManager {
+       
+       BuildConsoleDocument fDocument; 
+       BuildConsolePartitioner fPartitioner;
+       
+       int highlightedPartitionIndex = -1;
+       
+       DocumentMarkerManager(BuildConsoleDocument document, BuildConsolePartitioner partitioner) {
+               fDocument = document;
+               fPartitioner = partitioner;
+       }
+
+       /** Increment index */
+       void moveToNextError() {                                
+               if ( fPartitioner.fPartitions.size() == 0 ) return;
+               if ( highlightedPartitionIndex == -1 ) { 
+                       moveToFirstError();
+                       return;
+               }
+               int i = highlightedPartitionIndex + 1; 
+               do {
+                       if ( i == fPartitioner.fPartitions.size() ) {
+                               i = 0;
+                       }
+                       String type = fPartitioner.fPartitions.get(i).getType();
+                       if (BuildConsolePartition.isProblemPartitionType(type)) {
+                               highlightedPartitionIndex = i;
+                               return;
+                       } else {
+                               i++;
+                       }
+               } while ( highlightedPartitionIndex != i);
+       }
+       
+       /** Decrement index */
+       void moveToPreviousError() {    
+               if ( fPartitioner.fPartitions.size() == 0 ) return;
+               if ( highlightedPartitionIndex == -1 ) { 
+                       moveToFirstError();
+                       return;
+               }
+               
+               int i = highlightedPartitionIndex - 1; 
+               do {
+                       if ( i == -1 ) {
+                               i = fPartitioner.fPartitions.size() - 1;
+                       }
+                       String type = fPartitioner.fPartitions.get(i).getType();
+                       if (BuildConsolePartition.isProblemPartitionType(type)) {
+                               highlightedPartitionIndex = i;
+                               return;
+                       } else {
+                               i--;
+                       }
+               } while ( highlightedPartitionIndex != i);
+       }
+       
+       void moveToFirstError() {
+               for (int i=0; i<fPartitioner.fPartitions.size(); i++) {
+                       String type = fPartitioner.fPartitions.get(i).getType();
+                       if (BuildConsolePartition.isProblemPartitionType(type)) {
+                               highlightedPartitionIndex = i;
+                               return;                 
+                       }
+               }
+               highlightedPartitionIndex = -1;
+       }
+
+       /** Returns true if offset points to error partition and false otherwise */
+       boolean moveToErrorByOffset(int offset) {
+               ITypedRegion p = fPartitioner.getPartition(offset);
+               String type = p.getType();
+               if (BuildConsolePartition.isProblemPartitionType(type)) {
+                       highlightedPartitionIndex = fPartitioner.fPartitions.indexOf(p);
+                       return true;
+               }
+               return false;
+       }
+
+       /** Get marker for current error */
+       ProblemMarkerInfo getCurrentErrorMarker() {
+               BuildConsolePartition p = getCurrentPartition();
+               if ( p != null ) { 
+                       return p.getMarker();
+               } else {
+                       return null;
+               }
+       }
+
+       /** Get partition for current error */
+       BuildConsolePartition getCurrentPartition() {
+               if ( 0 <= highlightedPartitionIndex &&  
+                               highlightedPartitionIndex < fPartitioner.fPartitions.size() ) {
+                       BuildConsolePartition p = (BuildConsolePartition)fPartitioner.fPartitions.get(highlightedPartitionIndex);
+                       return p;
+               }
+               return null;
+       }       
+       
+       void clear() {
+               highlightedPartitionIndex = -1;         
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/GlobalBuildConsole.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/GlobalBuildConsole.java
new file mode 100644 (file)
index 0000000..5e9f393
--- /dev/null
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Broadcom Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alex Collins (Broadcom Corp.)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.buildconsole;
+
+import java.net.URL;
+
+import org.eclipse.cdt.ui.IBuildConsoleManager;
+import org.eclipse.core.resources.IProject;
+
+/**
+ * Customized BuildConsole for the global console that displays its title differently
+ */
+public class GlobalBuildConsole extends BuildConsole {
+       public GlobalBuildConsole(IBuildConsoleManager manager, String name, String contextId, URL iconUrl) {
+               super(manager, name, contextId, iconUrl);
+       }
+
+       @Override
+       public void setTitle(IProject project) {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/GlobalBuildConsoleManager.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/GlobalBuildConsoleManager.java
new file mode 100644 (file)
index 0000000..d841cef
--- /dev/null
@@ -0,0 +1,191 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Jeff Johnston (Red Hat Inc.) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Jeff Johnston (Red Hat Inc.), Andrew Gvozdev - initial implementation 
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.buildconsole;
+
+import java.net.URI;
+import java.net.URL;
+
+import org.eclipse.core.filesystem.URIUtil;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
+import org.osgi.service.prefs.Preferences;
+
+import org.eclipse.cdt.core.resources.IConsole;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage;
+
+/**
+ * Build console manager managing the global CDT build console.
+ * Singleton.
+ *
+ */
+public class GlobalBuildConsoleManager extends BuildConsoleManager {
+       private static final String GLOBAL_BUILD_CONSOLE_NODE = "globalBuildConsole"; //$NON-NLS-1$
+       private static final String GLOBAL_LOG_FILE = "global-build.log"; //$NON-NLS-1$
+
+       private static final String GLOBAL_CONTEXT_MENU_ID = CUIPlugin.PLUGIN_ID + ".CDTGlobalBuildConsole"; //$NON-NLS-1$
+
+       /** Singleton instance */
+       private static GlobalBuildConsoleManager INSTANCE = null;
+       private static BuildConsolePartitioner fGlobalConsolePartitioner = null;
+       
+       /**
+        * Default constructor is private. The only instance will be created on
+        * access of static methods and assigned to {@link #INSTANCE}.
+        */
+       private GlobalBuildConsoleManager() {
+               // startup is in the constructor to ensure starting only once
+               startup(ConsoleMessages.BuildConsole_GlobalConsole, GLOBAL_CONTEXT_MENU_ID, null);
+       }
+
+       /**
+        * @return get instance creating one if necessary.
+        */
+       private static GlobalBuildConsoleManager getInstance() {
+               if (INSTANCE==null)
+                       INSTANCE = new GlobalBuildConsoleManager();
+               return INSTANCE;
+       }
+       
+       /**
+        * @return get global console partitioner creating one if necessary.
+        */
+       private static BuildConsolePartitioner getConsolePartitioner() {
+               if (fGlobalConsolePartitioner==null) {
+                       fGlobalConsolePartitioner = new BuildConsolePartitioner(getInstance());
+               }
+               return fGlobalConsolePartitioner;
+       }
+       
+       
+       /**
+        * Start the console. This will call {@link #startup(String, String, URL)}
+        * to add the global console to the Console view.
+        */
+       public static void startup() {
+               // instantiate the INSTANCE
+               getInstance();
+       }
+       
+       /**
+        * Stop the console and deallocate resources allocated during {@link #startup()}
+        */
+       public static void stop() {
+               // avoid initializing INSTANCE needlessly during shutdown
+               if (INSTANCE!=null)
+                       INSTANCE.shutdown();
+       }
+       
+       @Override
+       protected BuildConsole createBuildConsole(String name, String contextId, final URL iconUrl) {
+               return new GlobalBuildConsole(this, name, contextId, iconUrl);
+       }
+
+       /**
+        * @return the global build console.
+        */
+       public static IConsole getGlobalConsole() {
+               return getConsolePartitioner().getConsole();
+       }
+
+       /**
+        * Start the global console; called at the start of the build.
+        * Clears the contents of the console and sets up the log output stream.
+        */
+       public static void startGlobalConsole() {
+               if (BuildConsolePreferencePage.isClearBuildConsole())
+                       getConsolePartitioner().appendToDocument("", null, null); //$NON-NLS-1$
+               getConsolePartitioner().setStreamOpened();
+       }
+
+       /**
+        * Intended to handle event after console output for the whole build including
+        * referenced projects finished. Currently this event is not triggered and
+        * the function does nothing.
+        */
+       public static void stopGlobalConsole() {
+               // Doesn't do anything currently. This would be a cleaner place to close the global console
+               // log, but there is nowhere in CDT that can invoke it at the end of the entire build.
+               // Instead, the log is repeatedly closed and opened for append by each project build.
+       }
+
+       /**
+        * @return logging preference store for the workspace.
+        */
+       public static IPreferenceStore getBuildLogPreferenceStore() {
+               return new ScopedPreferenceStore(InstanceScope.INSTANCE, PREF_QUALIFIER + "/" + GLOBAL_BUILD_CONSOLE_NODE); //$NON-NLS-1$
+       }
+
+       /**
+        * @return logging preferences for the workspace.
+        */
+       public static Preferences getBuildLogPreferences() {
+               return InstanceScope.INSTANCE.getNode(PREF_QUALIFIER).node(GLOBAL_BUILD_CONSOLE_NODE);
+       }
+
+       /**
+        * @return default location of logs for the workspace.
+        */
+       public static String getDefaultConsoleLogLocation() {
+               IPath defaultLogLocation = CUIPlugin.getDefault().getStateLocation().append(GLOBAL_LOG_FILE);
+               return defaultLogLocation.toOSString();
+       }
+
+       @Override
+       public IConsole getConsole(IProject project) {
+               return getGlobalConsole();
+       }
+
+       @Override
+       public IConsole getProjectConsole(IProject project) {
+               return getGlobalConsole();
+       }
+
+       @Override
+       public IDocument getConsoleDocument(IProject project) {
+               return getConsolePartitioner().getDocument();
+       }
+
+       @Override
+       public IProject getLastBuiltProject() {
+               return null;
+       }
+
+       /**
+        * @return {@link URI} of the global build log or {@code null} if not available.
+        */
+       @Override
+       public URI getLogURI(IProject project) {
+               URI logURI = null;
+
+               Preferences prefs = getBuildLogPreferences();
+               boolean keepLog = prefs.getBoolean(KEY_KEEP_LOG, CONSOLE_KEEP_LOG_DEFAULT);
+               if (keepLog) {
+                       String strLocation = prefs.get(KEY_LOG_LOCATION, getDefaultConsoleLogLocation());
+                       if (strLocation.trim().length()>0) {
+                               logURI = URIUtil.toURI(strLocation);
+                       }
+                       if (logURI==null) {
+                               IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID,"Can't determine URI for location=["+strLocation+"]");  //$NON-NLS-1$ //$NON-NLS-2$
+                               CUIPlugin.log(status);
+                       }
+               }
+               return logURI;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/MultiBuildConsoleAdapter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/MultiBuildConsoleAdapter.java
new file mode 100644 (file)
index 0000000..86769c0
--- /dev/null
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Broadcom Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alex Collins (Broadcom Corp.)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.buildconsole;
+
+import java.io.IOException;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.cdt.core.ConsoleOutputStream;
+import org.eclipse.cdt.core.ProblemMarkerInfo;
+import org.eclipse.cdt.core.resources.IConsole;
+
+import org.eclipse.cdt.internal.core.IErrorMarkeredOutputStream;
+
+/**
+ * Adapter that wraps a project console and the global console to allow builders
+ * to send their build output to a single IConsole object
+ */
+class MultiBuildConsoleAdapter implements IConsole {
+
+       private final IConsole fProjectConsole;
+       private final IConsole fGlobalConsole;
+
+       private static class BuildOutputStreamAdapter extends ConsoleOutputStream implements IErrorMarkeredOutputStream {
+               private final BuildOutputStream one;
+               private final BuildOutputStream two;
+
+               public BuildOutputStreamAdapter(BuildOutputStream one, BuildOutputStream two) {
+                       this.one = one;
+                       this.two = two;
+               }
+
+               @Override
+               public synchronized String readBuffer() {
+                       return one.readBuffer();
+               }
+
+               @Override
+               public synchronized void write(int c) throws IOException {
+                       one.write(c);
+                       two.write(c);
+               }
+
+           @Override
+               public synchronized void write(byte[] b, int off, int len) throws IOException {
+                       one.write(b, off, len);
+                       two.write(b, off, len);
+           }
+
+               public void write(String s, ProblemMarkerInfo marker) throws IOException {
+                       one.write(s, marker);
+                       two.write(s, marker);
+               }
+
+               @Override
+               public void close() throws IOException {
+                       one.flush();
+                       two.flush();
+                       one.close();
+                       two.close();
+               }
+
+       }
+
+       public MultiBuildConsoleAdapter(IConsole projectConsole, IConsole globalConsole) {
+               fProjectConsole = projectConsole;
+               fGlobalConsole = globalConsole;
+       }
+
+       public void start(IProject project) {
+               fProjectConsole.start(project);
+       }
+
+       public ConsoleOutputStream getOutputStream() throws CoreException {
+               return new BuildOutputStreamAdapter((BuildOutputStream)fProjectConsole.getOutputStream(), (BuildOutputStream)fGlobalConsole.getOutputStream());
+       }
+
+       public ConsoleOutputStream getInfoStream() throws CoreException {
+               return new BuildOutputStreamAdapter((BuildOutputStream)fProjectConsole.getInfoStream(), (BuildOutputStream)fGlobalConsole.getInfoStream());
+       }
+
+       public ConsoleOutputStream getErrorStream() throws CoreException {
+               return new BuildOutputStreamAdapter((BuildOutputStream)fProjectConsole.getErrorStream(), (BuildOutputStream)fGlobalConsole.getErrorStream());
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/NextErrorAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/NextErrorAction.java
new file mode 100644 (file)
index 0000000..1fb0c0b
--- /dev/null
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2010 CodeSourcery and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Kozlov (CodeSourcery) - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.buildconsole;
+
+import org.eclipse.jface.action.Action;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+
+/**
+ * Advance console document to the next error reported by compiler
+ */
+public class NextErrorAction extends Action {
+
+       private BuildConsolePage fConsolePage;
+
+       public NextErrorAction(BuildConsolePage page) {
+               super(ConsoleMessages.NextErrorAction_Tooltip); 
+               fConsolePage = page;
+               setEnabled(true);
+               setToolTipText(ConsoleMessages.NextErrorAction_Tooltip); 
+               CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_SHOW_NEXT);
+       }
+
+       /**
+        * @see org.eclipse.jface.action.IAction#run()
+        */
+       @Override
+       public void run() {
+               fConsolePage.moveToError(BuildConsolePage.POSITION_NEXT);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/PreviousErrorAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/PreviousErrorAction.java
new file mode 100644 (file)
index 0000000..1c42bfa
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2010 CodeSourcery and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Kozlov (CodeSourcery) - Initial API and implementation
+ * IBM Corporation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.buildconsole;
+
+import org.eclipse.jface.action.Action;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+
+/**
+ * Retard console document to the previous error reported by compiler
+ */
+public class PreviousErrorAction extends Action {
+
+       private BuildConsolePage fConsolePage;
+
+       public PreviousErrorAction(BuildConsolePage page) {
+               super(ConsoleMessages.PreviousErrorAction_Tooltip); 
+               fConsolePage = page;
+               setEnabled(true);
+               setToolTipText(ConsoleMessages.PreviousErrorAction_Tooltip); 
+               CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_SHOW_PREV);
+       }
+
+       /**
+        * @see org.eclipse.jface.action.IAction#run()
+        */
+       @Override
+       public void run() {
+               fConsolePage.moveToError(BuildConsolePage.POSITION_PREV);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ScrollLockAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ScrollLockAction.java
new file mode 100644 (file)
index 0000000..b0a821e
--- /dev/null
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.buildconsole;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.jface.action.Action;
+
+/**
+ * Toggles console auto-scroll
+ */
+
+public class ScrollLockAction extends Action {
+
+       private BuildConsoleViewer fConsoleViewer;
+
+       public ScrollLockAction(BuildConsoleViewer viewer) {
+               super(ConsoleMessages.ScrollLockAction_Scroll_Lock_1); 
+               fConsoleViewer = viewer;
+               setToolTipText(ConsoleMessages.ScrollLockAction_Scroll_Lock_1); 
+               CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_SCROLL_LOCK);
+               setChecked(false);
+       }
+
+       /**
+        * @see org.eclipse.jface.action.IAction#run()
+        */
+       @Override
+       public void run() {
+               fConsoleViewer.setAutoScroll(!isChecked());
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ShowErrorAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ShowErrorAction.java
new file mode 100644 (file)
index 0000000..7fbd327
--- /dev/null
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2010 CodeSourcery and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Dmitry Kozlov (CodeSourcery) - Initial API and implementation
+ * Alex Collins (Broadcom Corp.)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.buildconsole;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.action.Action;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.core.resources.IConsole;
+import org.eclipse.cdt.ui.IBuildConsoleManager;
+
+/**
+ * Set whether to show error in editor when moving to next/prev error in Build Console
+ */
+public class ShowErrorAction extends Action {
+
+       private BuildConsolePage fConsolePage;
+       
+       public ShowErrorAction(BuildConsolePage page) {
+               super(ConsoleMessages.ShowErrorAction_Tooltip); 
+               fConsolePage = page;
+               setChecked(true);
+               setToolTipText(ConsoleMessages.ShowErrorAction_Tooltip); 
+               ISharedImages images = PlatformUI.getWorkbench().getSharedImages();             
+               setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_ELCL_SYNCED));
+               setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_ELCL_SYNCED_DISABLED));
+       }
+
+       /**
+        * @see org.eclipse.jface.action.IAction#run()
+        */
+       @Override
+       public void run() {
+               super.run();
+               if (isChecked()) {
+                       IBuildConsoleManager consoleManager = fConsolePage.getConsole().getConsoleManager();
+                       IProject project = fConsolePage.getProject();
+                       IConsole console = consoleManager.getProjectConsole(project);
+                       if (console instanceof BuildConsolePartitioner) {
+                               BuildConsolePartitioner par = (BuildConsolePartitioner)console;
+                               fConsolePage.showError(par, true);
+                       }
+               }
+       }       
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CElementSet.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CElementSet.java
new file mode 100644 (file)
index 0000000..d058116
--- /dev/null
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.callhierarchy;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import org.eclipse.cdt.core.model.ICElement;
+
+import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
+
+public class CElementSet {
+       private Set<ICElement> fSet= new LinkedHashSet<ICElement>();
+       private int fHashCode;
+       
+       CElementSet( ICElement[] elements) {
+               fSet.addAll(Arrays.asList(elements));
+               fHashCode= 0;
+        for (int i = 0; i < elements.length; i++) {
+               fHashCode = 31*fHashCode + elements[i].hashCode();
+        }
+       }
+
+       @Override
+       public int hashCode() {
+               return fHashCode;
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj) {
+                       return true;
+               }
+               if (obj == null) {
+                       return false;
+               }
+               if (getClass() != obj.getClass()) {
+                       return false;
+               }
+               final CElementSet other = (CElementSet) obj;
+               if (fHashCode != other.fHashCode) {
+                       return false;
+               }
+               if (fSet == null) {
+                       if (other.fSet != null) {
+                               return false;
+                       }
+               } 
+               else {
+                       if (fSet.size() != other.fSet.size()) {
+                               return false;
+                       }
+                       for (Iterator<ICElement> iter = fSet.iterator(); iter.hasNext(); ) {
+                               if (!other.fSet.contains(iter.next())) { 
+                                       return false;
+                               }
+                       }
+               }
+               return true;
+       }
+
+       public boolean isEmpty() {
+               return fSet.isEmpty();
+       }
+
+       public ICElement[] getElements(WorkingSetFilterUI filter) {
+               ArrayList<ICElement> result= new ArrayList<ICElement>(fSet.size());
+               for (Iterator<ICElement> iter = fSet.iterator(); iter.hasNext(); ) {
+                       ICElement element = iter.next();
+                       if (filter == null || filter.isPartOfWorkingSet(element)) {
+                               result.add(element);
+                       }
+               }
+               return result.toArray(new ICElement[result.size()]);
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java
new file mode 100644 (file)
index 0000000..ddbc224
--- /dev/null
@@ -0,0 +1,271 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.callhierarchy;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IEnumerator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexFile;
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IMethod;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IVariable;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.corext.util.CModelUtil;
+
+import org.eclipse.cdt.internal.ui.viewsupport.AsyncTreeContentProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
+import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
+
+/** 
+ * This is the content provider for the call hierarchy.
+ */
+public class CHContentProvider extends AsyncTreeContentProvider {
+
+       private static final IProgressMonitor NPM = new NullProgressMonitor();
+       private boolean fComputeReferencedBy = true;
+       private WorkingSetFilterUI fFilter;
+       private CHViewPart fView;
+
+       /**
+        * Constructs the content provider.
+        */
+       public CHContentProvider(CHViewPart view, Display disp) {
+               super(disp);
+               fView= view;
+       }
+
+       @Override
+       public Object getParent(Object element) {
+               if (element instanceof CHNode) {
+                       CHNode node = (CHNode) element;
+                       return node.getParent();
+               }
+               return super.getParent(element);
+       }
+
+       @Override
+       protected Object[] syncronouslyComputeChildren(Object parentElement) {
+               if (parentElement instanceof CHMultiDefNode) {
+                       return ((CHMultiDefNode) parentElement).getChildNodes();
+               }
+               if (parentElement instanceof CHNode) {
+                       CHNode node = (CHNode) parentElement;
+                       if (node.isRecursive() || node.getRepresentedDeclaration() == null) {
+                               return NO_CHILDREN;
+                       }
+                       if (fComputeReferencedBy) {
+                               if (node.isInitializer()) {
+                                       return NO_CHILDREN;
+                               }
+                       }
+                       else if (node.isVariableOrEnumerator() || node.isMacro()) { 
+                               return NO_CHILDREN;
+                       }
+                       
+               }
+               // allow for async computation
+               return null;
+       }
+
+       @Override
+       protected Object[] asyncronouslyComputeChildren(Object parentElement, IProgressMonitor monitor) {
+               try {
+                       if (parentElement instanceof ICElement) {
+                               return asyncComputeRoot((ICElement) parentElement);
+                       }
+
+                       if (parentElement instanceof CHNode) {
+                               CHNode node = (CHNode) parentElement;
+                               if (fComputeReferencedBy) {
+                                       return asyncronouslyComputeReferencedBy(node);
+                               }
+                               return asyncronouslyComputeRefersTo(node);
+                       }
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               } catch (InterruptedException e) {
+                       Thread.currentThread().interrupt();
+               }
+               return NO_CHILDREN;
+       }
+       
+       private Object[] asyncComputeRoot(final ICElement input) throws CoreException, InterruptedException {
+               IIndex index= CCorePlugin.getIndexManager().getIndex(input.getCProject());
+               index.acquireReadLock();
+               try {
+                       ICElement element= input;
+                       if (!IndexUI.isIndexed(index, input)) {
+                               getDisplay().asyncExec(new Runnable() {
+                                       public void run() {
+                                               fView.reportNotIndexed(input);
+                                       }
+                               });
+                       } 
+                       else {
+                               element= IndexUI.attemptConvertionToHandle(index, input);
+                               final ICElement finalElement= element;
+                               getDisplay().asyncExec(new Runnable() {
+                                       public void run() {
+                                               fView.reportInputReplacement(input, finalElement);
+                                       }
+                               });
+                       }
+                       ITranslationUnit tu= CModelUtil.getTranslationUnit(element);
+                       if (!fComputeReferencedBy && element instanceof IMethod) {
+                               IIndexName methodName= IndexUI.elementToName(index, element);
+                               if (methodName != null) {
+                                       IBinding methodBinding= index.findBinding(methodName);
+                                       if (methodBinding instanceof ICPPMethod) {
+                                               ICElement[] defs= CHQueries.findOverriders(index, (ICPPMethod) methodBinding);
+                                               if (defs != null && defs.length > 0) {
+                                                       return new Object[] { new CHMultiDefNode(null, tu, 0, defs, methodBinding.getLinkage().getLinkageID()) };
+                                               }
+                                       }
+                               }
+                       }
+                       return new Object[] { new CHNode(null, tu, 0, element, -1) };
+               }
+               finally {
+                       index.releaseReadLock();
+               }
+       }
+
+       private Object[] asyncronouslyComputeReferencedBy(CHNode parent) throws CoreException, InterruptedException {
+               ICProject[] scope= CoreModel.getDefault().getCModel().getCProjects();
+               IIndex index= CCorePlugin.getIndexManager().getIndex(scope);
+               index.acquireReadLock();
+               try {
+                       return CHQueries.findCalledBy(this, parent, index, NPM);
+               }
+               finally {
+                       index.releaseReadLock();
+               }
+       }
+
+       private Object[] asyncronouslyComputeRefersTo(CHNode parent) throws CoreException, InterruptedException {
+               ICProject[] scope= CoreModel.getDefault().getCModel().getCProjects();
+               IIndex index= CCorePlugin.getIndexManager().getIndex(scope);
+               index.acquireReadLock();
+               try {
+                       return CHQueries.findCalls(this, parent, index, NPM);
+               }
+               finally {
+                       index.releaseReadLock();
+               }
+       }
+
+       public void setComputeReferencedBy(boolean value) {
+               fComputeReferencedBy = value;
+       }
+
+       public boolean getComputeReferencedBy() {
+               return fComputeReferencedBy;
+       }
+
+       public void setWorkingSetFilter(WorkingSetFilterUI filterUI) {
+               fFilter= filterUI;
+               recompute();
+       }
+
+       CHNode[] createNodes(CHNode node, CalledByResult result) throws CoreException {
+               ArrayList<CHNode> nodes= new ArrayList<CHNode>();
+               ICElement[] elements= result.getElements();
+               for (ICElement element : elements) {
+                       if (element != null) {
+                               if (fFilter == null || fFilter.isPartOfWorkingSet(element)) {
+                                       IIndexName[] refs= result.getReferences(element);
+                                       if (refs != null && refs.length > 0) {
+                                               CHNode newNode = createRefbyNode(node, element, refs);
+                                               nodes.add(newNode);
+                                       }
+                               }
+                       }
+               }
+               return nodes.toArray(new CHNode[nodes.size()]);
+       }
+       
+       private CHNode createRefbyNode(CHNode parent, ICElement element, IIndexName[] refs) throws CoreException {
+               ITranslationUnit tu= CModelUtil.getTranslationUnit(element);
+               final IIndexFile file = refs[0].getFile();
+               CHNode node= new CHNode(parent, tu, file.getTimestamp(), element, file.getLinkageID());
+               if (element instanceof IVariable || element instanceof IEnumerator) {
+                       node.setInitializer(true);
+               }
+               boolean readAccess= false;
+               boolean writeAccess= false;
+               for (IIndexName reference : refs) {
+                       node.addReference(new CHReferenceInfo(reference.getNodeOffset(), reference.getNodeLength()));
+                       readAccess= (readAccess || reference.isReadAccess());
+                       writeAccess= (writeAccess || reference.isWriteAccess());
+               }
+               node.setRWAccess(readAccess, writeAccess);
+               node.sortReferencesByOffset();
+               return node;
+       }
+
+       CHNode[] createNodes(CHNode node, CallsToResult callsTo) throws CoreException {
+               ITranslationUnit tu= CModelUtil.getTranslationUnit(node.getRepresentedDeclaration());
+               ArrayList<CHNode> result= new ArrayList<CHNode>();
+               CElementSet[] elementSets= callsTo.getElementSets();
+               for (CElementSet elementSet : elementSets) {
+                       CElementSet set = elementSet;
+                       if (!set.isEmpty()) {
+                               IIndexName[] refs= callsTo.getReferences(set);
+                               ICElement[] elements= set.getElements(fFilter);
+                               if (elements.length > 0) {
+                                       CHNode childNode = createReftoNode(node, tu, elements, refs);
+                                       result.add(childNode);
+                               }
+                       }
+               }
+               return result.toArray(new CHNode[result.size()]);
+       }
+
+       private CHNode createReftoNode(CHNode parent, ITranslationUnit tu, ICElement[] elements, IIndexName[] references) throws CoreException {
+               assert elements.length > 0;
+
+               final IIndexFile file = references[0].getFile();
+               final long timestamp= file.getTimestamp();
+               final int linkageID= file.getLinkageID();
+               
+               CHNode node;
+               if (elements.length == 1) {
+                       node= new CHNode(parent, tu, timestamp, elements[0], linkageID);
+               } else {
+                       node= new CHMultiDefNode(parent, tu, timestamp, elements, linkageID);
+               }
+               
+               boolean readAccess= false;
+               boolean writeAccess= false;
+               for (IIndexName reference : references) {
+                       node.addReference(new CHReferenceInfo(reference.getNodeOffset(), reference.getNodeLength()));
+                       readAccess= (readAccess || reference.isReadAccess());
+                       writeAccess= (writeAccess || reference.isWriteAccess());
+               }
+               node.sortReferencesByOffset();
+               node.setRWAccess(readAccess, writeAccess);
+               return node;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHDropTargetListener.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHDropTargetListener.java
new file mode 100644 (file)
index 0000000..7e5eab7
--- /dev/null
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.callhierarchy;
+
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.DropTargetListener;
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.cdt.core.model.ICElement;
+
+
+public class CHDropTargetListener implements DropTargetListener {
+    
+    private CHViewPart fCallHierarchy;
+       private ICElement fInput;
+       private boolean fEnabled= true;
+
+    public CHDropTargetListener(CHViewPart view) {
+        fCallHierarchy= view;
+    }
+    
+    public void setEnabled(boolean val) {
+       fEnabled= val;
+    }
+    
+    public void dragEnter(DropTargetEvent event) {
+       fInput= null;
+        checkOperation(event);
+        if (event.detail != DND.DROP_NONE) {
+                       if (LocalSelectionTransfer.getTransfer().isSupportedType(event.currentDataType)) {
+                               fInput= checkLocalSelection();
+                               if (!CallHierarchyUI.isRelevantForCallHierarchy(fInput)) {
+                                       event.detail= DND.DROP_NONE;
+                                       fInput= null;
+                               }
+               }
+        }
+    }
+
+       private ICElement checkLocalSelection() {
+               ISelection sel= LocalSelectionTransfer.getTransfer().getSelection();
+               if (sel instanceof IStructuredSelection) {
+                       for (Iterator<?> iter = ((IStructuredSelection)sel).iterator(); iter.hasNext();) {
+                               Object element = iter.next();
+                               if (element instanceof ICElement) {
+                                       return (ICElement) element;
+                               }
+                               if (element instanceof IAdaptable) {
+                                       ICElement adapter= (ICElement) ((IAdaptable) element).getAdapter(ICElement.class);
+                                       if (adapter != null) {
+                                               return adapter;
+                                       }
+                               }
+                       }
+               }
+               return null;
+       }
+
+    public void dragLeave(DropTargetEvent event) {
+    }
+
+    public void dragOperationChanged(DropTargetEvent event) {
+        checkOperation(event);
+    }
+
+    public void dragOver(DropTargetEvent event) {
+    }
+
+    public void drop(DropTargetEvent event) {
+       if (fInput == null) {
+            Display.getCurrent().beep();
+        }
+        else {
+            fCallHierarchy.setInput(fInput);
+        }
+    }
+
+    public void dropAccept(DropTargetEvent event) {
+    }
+    
+    private void checkOperation(DropTargetEvent event) {
+        if (fEnabled && (event.operations & DND.DROP_COPY) != 0) {
+            event.detail= DND.DROP_COPY;
+        }
+        else {
+            event.detail= DND.DROP_NONE;
+        }
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryAction.java
new file mode 100644 (file)
index 0000000..1d6c952
--- /dev/null
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.callhierarchy;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+import org.eclipse.cdt.core.model.ICElement;
+
+import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
+
+
+/**
+ * Action used for the include browser forward / backward buttons
+ */
+public class CHHistoryAction extends Action {
+       final static long LABEL_OPTIONS= 
+               CElementLabels.M_PARAMETER_TYPES | 
+               CElementLabels.ALL_FULLY_QUALIFIED |
+               CElementLabels.TEMPLATE_ARGUMENTS |
+               CElementLabels.MF_POST_FILE_QUALIFIED;
+       
+       private CHViewPart fViewPart;
+       private ICElement fElement;
+       
+       public CHHistoryAction(CHViewPart viewPart, ICElement element) {
+        super("", AS_RADIO_BUTTON); //$NON-NLS-1$
+               fViewPart= viewPart;
+               fElement= element;              
+       
+               String elementName= CElementLabels.getElementLabel(element, LABEL_OPTIONS);
+               setText(elementName);
+               setImageDescriptor(getImageDescriptor(element));
+       }
+       
+       private ImageDescriptor getImageDescriptor(ICElement elem) {
+               CElementImageProvider imageProvider= new CElementImageProvider();
+               ImageDescriptor desc= imageProvider.getBaseImageDescriptor(elem, 0);
+               imageProvider.dispose();
+               return desc;
+       }
+       
+       /*
+        * @see Action#run()
+        */
+       @Override
+       public void run() {
+               fViewPart.setInput(fElement);
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryDropDownAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryDropDownAction.java
new file mode 100644 (file)
index 0000000..c732d41
--- /dev/null
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.callhierarchy;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IMenuCreator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+
+import org.eclipse.cdt.core.model.ICElement;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+
+public class CHHistoryDropDownAction extends Action implements IMenuCreator {
+       
+       public static class ClearHistoryAction extends Action {
+
+               private CHViewPart fView;
+               
+               public ClearHistoryAction(CHViewPart view) {
+                       super(CHMessages.CHHistoryDropDownAction_ClearHistory_label);
+                       fView= view;
+               }
+                       
+               @Override
+               public void run() {
+                       fView.setHistoryEntries(new ICElement[0]);
+                       fView.setInput(null);
+               }
+       }
+
+       public static final int RESULTS_IN_DROP_DOWN= 10;
+
+       private CHViewPart fHierarchyView;
+       private Menu fMenu;
+       
+       public CHHistoryDropDownAction(CHViewPart view) {
+               fHierarchyView= view;
+               fMenu= null;
+               setToolTipText(CHMessages.CHHistoryDropDownAction_ShowHistoryList_tooltip); 
+               CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "history_list.gif"); //$NON-NLS-1$
+               setMenuCreator(this);
+       }
+
+       public void dispose() {
+               // action is reused, can be called several times.
+               if (fMenu != null) {
+                       fMenu.dispose();
+                       fMenu= null;
+               }
+       }
+
+       public Menu getMenu(Menu parent) {
+               return null;
+       }
+
+       public Menu getMenu(Control parent) {
+               if (fMenu != null) {
+                       fMenu.dispose();
+               }
+               fMenu= new Menu(parent);
+               ICElement[] elements= fHierarchyView.getHistoryEntries();
+               addEntries(fMenu, elements);
+               new MenuItem(fMenu, SWT.SEPARATOR);
+               addActionToMenu(fMenu, new CHHistoryListAction(fHierarchyView));
+               addActionToMenu(fMenu, new ClearHistoryAction(fHierarchyView));
+               return fMenu;
+       }
+       
+       private boolean addEntries(Menu menu, ICElement[] elements) {
+               boolean checked= false;
+               
+               int min= Math.min(elements.length, RESULTS_IN_DROP_DOWN);
+               for (int i= 0; i < min; i++) {
+                       CHHistoryAction action= new CHHistoryAction(fHierarchyView, elements[i]);
+                       action.setChecked(elements[i].equals(fHierarchyView.getInput()));
+                       checked= checked || action.isChecked();
+                       addActionToMenu(menu, action);
+               }
+               
+               
+               return checked;
+       }
+       
+
+       protected void addActionToMenu(Menu parent, Action action) {
+               ActionContributionItem item= new ActionContributionItem(action);
+               item.fill(parent, -1);
+       }
+
+       @Override
+       public void run() {
+               (new CHHistoryListAction(fHierarchyView)).run();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction.java
new file mode 100644 (file)
index 0000000..ba2d6a8
--- /dev/null
@@ -0,0 +1,182 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.callhierarchy;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.StatusDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.cdt.core.model.ICElement;
+
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
+
+public class CHHistoryListAction extends Action {
+       
+       private class HistoryListDialog extends StatusDialog {
+               private ListDialogField<ICElement> fHistoryList;
+               private IStatus fHistoryStatus;
+               private ICElement fResult;
+               
+               private HistoryListDialog(Shell shell, ICElement[] historyEntries) {
+                       super(shell);
+                       setHelpAvailable(false);                        
+                       setTitle(CHMessages.CHHistoryListAction_HistoryDialog_title); 
+                       String[] buttonLabels= new String[] { 
+                               CHMessages.CHHistoryListAction_Remove_label, 
+                       };
+                                       
+                       IListAdapter<ICElement> adapter= new IListAdapter<ICElement>() {
+                               public void customButtonPressed(ListDialogField<ICElement> field, int index) {
+                                       doCustomButtonPressed();
+                               }
+                               public void selectionChanged(ListDialogField<ICElement> field) {
+                                       doSelectionChanged();
+                               }
+                               
+                               public void doubleClicked(ListDialogField<ICElement> field) {
+                                       doDoubleClicked();
+                               }                               
+                       };
+               
+                       ILabelProvider labelProvider= new CUILabelProvider(CHHistoryAction.LABEL_OPTIONS, CElementImageProvider.OVERLAY_ICONS);
+                       
+                       fHistoryList= new ListDialogField<ICElement>(adapter, buttonLabels, labelProvider);
+                       fHistoryList.setLabelText(CHMessages.CHHistoryListAction_HistoryList_label); 
+                       fHistoryList.setElements(Arrays.asList(historyEntries));
+                       
+                       ISelection sel;
+                       if (historyEntries.length > 0) {
+                               sel= new StructuredSelection(historyEntries[0]);
+                       } else {
+                               sel= new StructuredSelection();
+                       }
+                       
+                       fHistoryList.selectElements(sel);
+               }
+                       
+               /*
+                * @see Dialog#createDialogArea(Composite)
+                */
+               @Override
+               protected Control createDialogArea(Composite parent) {
+                       initializeDialogUnits(parent);
+                       
+                       Composite composite= (Composite) super.createDialogArea(parent);
+                       
+                       Composite inner= new Composite(composite, SWT.NONE);
+                       inner.setFont(parent.getFont());
+                       
+                       inner.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+                       LayoutUtil.doDefaultLayout(inner, new DialogField[] { fHistoryList }, true, 0, 0);
+                       LayoutUtil.setHeightHint(fHistoryList.getListControl(null), convertHeightInCharsToPixels(12));
+                       LayoutUtil.setHorizontalGrabbing(fHistoryList.getListControl(null), true);
+
+                       applyDialogFont(composite);             
+                       return composite;
+               }
+
+               /**
+                * Method doCustomButtonPressed.
+                */
+               private void doCustomButtonPressed() {
+                       fHistoryList.removeElements(fHistoryList.getSelectedElements());
+               }
+               
+               private void doDoubleClicked() {
+                       if (fHistoryStatus.isOK()) {
+                               okPressed();
+                       }
+               }
+
+               private void doSelectionChanged() {
+                       StatusInfo status= new StatusInfo();
+                       List<ICElement> selected= fHistoryList.getSelectedElements();
+                       if (selected.size() != 1) {
+                               status.setError(""); //$NON-NLS-1$
+                               fResult= null;
+                       } else {
+                               fResult= selected.get(0);
+                       }
+                       fHistoryList.enableButton(0, fHistoryList.getSize() > selected.size() && selected.size() != 0);                 
+                       fHistoryStatus= status;
+                       updateStatus(status);   
+               }
+                               
+               public ICElement getResult() {
+                       return fResult;
+               }
+               
+               public ICElement[] getRemaining() {
+                       List<ICElement> elems= fHistoryList.getElements();
+                       return elems.toArray(new ICElement[elems.size()]);
+               }       
+               
+               /*
+                * @see org.eclipse.jface.window.Window#configureShell(Shell)
+                */
+               @Override
+               protected void configureShell(Shell newShell) {
+                       super.configureShell(newShell);
+//                     PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, ...);
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.window.Window#create()
+                */
+               @Override
+               public void create() {
+                       setShellStyle(getShellStyle() | SWT.RESIZE);
+                       super.create();
+               }
+
+       }
+       
+       private CHViewPart fView;
+       
+       public CHHistoryListAction(CHViewPart view) {
+               fView= view;
+               setText(CHMessages.CHHistoryListAction_OpenHistory_label); 
+       }
+               
+       /*
+        * @see IAction#run()
+        */
+       @Override
+       public void run() {
+               ICElement[] historyEntries= fView.getHistoryEntries();
+               HistoryListDialog dialog= new HistoryListDialog(fView.getSite().getShell(), historyEntries);
+               if (dialog.open() == Window.OK) {
+                       fView.setHistoryEntries(dialog.getRemaining());
+                       fView.setInput(dialog.getResult());
+               }
+       }
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHLabelProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHLabelProvider.java
new file mode 100644 (file)
index 0000000..663231f
--- /dev/null
@@ -0,0 +1,235 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *    Patrick Hofer  [bug 325799]
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.callhierarchy;
+
+import java.util.HashMap;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.StyledCellLabelProvider;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
+import org.eclipse.cdt.ui.CElementImageDescriptor;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.ImageImageDescriptor;
+
+public class CHLabelProvider extends AppearanceAwareLabelProvider {
+       private final static long LABEL_OPTIONS_SIMPLE = CElementLabels.ALL_FULLY_QUALIFIED
+                       | CElementLabels.M_PARAMETER_TYPES | CElementLabels.M_APP_RETURNTYPE | CElementLabels.F_APP_TYPE_SIGNATURE | CElementLabels.TEMPLATE_ARGUMENTS;
+       private final static long LABEL_OPTIONS_SHOW_FILES= LABEL_OPTIONS_SIMPLE | CElementLabels.MF_POST_FILE_QUALIFIED;
+       
+    private CUILabelProvider fCLabelProvider= new CUILabelProvider(LABEL_OPTIONS_SIMPLE, CElementImageProvider.OVERLAY_ICONS);
+    private CHContentProvider fContentProvider;
+    private HashMap<String, Image> fCachedImages= new HashMap<String, Image>();
+       private Color fColorInactive;
+    
+    public CHLabelProvider(Display display, CHContentProvider cp) {
+        fColorInactive= display.getSystemColor(SWT.COLOR_DARK_GRAY);
+        fContentProvider= cp;
+    }
+    
+    @Override
+       public Image getImage(Object element) {
+        if (element instanceof CHNode) {
+            CHNode node= (CHNode) element;
+            Image image= null;
+            if (node.isInitializer()) {
+                       ImageDescriptor desc= CElementImageProvider.getFunctionImageDescriptor();
+                       image= CUIPlugin.getImageDescriptorRegistry().get(desc);
+            }
+            else {
+               ICElement decl= node.getOneRepresentedDeclaration();
+               if (decl != null) {
+                       image= fCLabelProvider.getImage(decl);
+               }
+            }
+            if (image != null) {
+               return decorateImage(image, node);
+            }
+        }
+        return super.getImage(element);
+    }
+
+    @Override
+       public String getText(Object element) {
+        if (element instanceof CHNode) {
+            CHNode node= (CHNode) element;
+            ICElement decl= node.getOneRepresentedDeclaration();
+            if (decl != null) {
+               String label;
+               if (node.isMultiDef()) {
+                       long options= fCLabelProvider.getTextFlags();
+                       fCLabelProvider.setTextFlags(LABEL_OPTIONS_SIMPLE);
+                       label= fCLabelProvider.getText(decl);
+                       fCLabelProvider.setTextFlags(options);
+               }
+               else {
+                       label= fCLabelProvider.getText(decl);
+                       if (node.isInitializer()) {
+                               label= addInitializerDecoration(label);
+                       }
+               }
+               int refCount= node.getReferenceCount();
+               if (refCount > 1) {
+                       label += NLS.bind(" ({0} {1})", new Integer(refCount), CHMessages.CHLabelProvider_matches);  //$NON-NLS-1$
+               }
+               return decorateText(label, element);
+            }
+        }
+        return super.getText(element);
+    }
+    
+    @Override
+       public StyledString getStyledText(Object element) {
+       if (element instanceof CHNode) {
+            CHNode node= (CHNode) element;
+            ICElement decl= node.getOneRepresentedDeclaration();
+            if (decl != null) {
+               StyledString label;
+               if (node.isMultiDef()) {
+                       long options= fCLabelProvider.getTextFlags();
+                       fCLabelProvider.setTextFlags(LABEL_OPTIONS_SIMPLE);
+                       label= fCLabelProvider.getStyledText(decl);
+                       fCLabelProvider.setTextFlags(options);
+               }
+               else {
+                       label= fCLabelProvider.getStyledText(decl);
+                       if (node.isInitializer()) {
+                               label= addInitializerDecoration(label);
+                       }
+               }
+               int refCount= node.getReferenceCount();
+               if (refCount > 1) {
+                       final int offset= label.length();
+                       label.append(NLS.bind(" ({0} {1})", new Integer(refCount), CHMessages.CHLabelProvider_matches));  //$NON-NLS-1$
+                       label.setStyle(offset, label.length() - offset, StyledString.COUNTER_STYLER);
+                               
+               }
+               //return label;
+               String decorated= decorateText(label.getString(), element);
+                       if (decorated != null) {
+                               return StyledCellLabelProvider.styleDecoratedString(decorated, StyledString.DECORATIONS_STYLER, label);
+                       }
+                       return label;
+               }
+        }
+        return fCLabelProvider.getStyledText(element);
+       }
+    
+    private String addInitializerDecoration(String label) {
+       int i= 0;
+       char[] content= label.toCharArray();
+       for (i = 0; i < content.length; i++) {
+                       char c = content[i];
+                       if (c == '-' || Character.isWhitespace(c)) {
+                               break;
+                       }
+               }
+       StringBuffer buf= new StringBuffer(label.length() + 10);
+       buf.append("{init "); //$NON-NLS-1$
+       buf.append(content, 0, i);
+       buf.append("}()"); //$NON-NLS-1$
+       buf.append(content, i, content.length-i);
+
+       return buf.toString();
+       }
+
+    private StyledString addInitializerDecoration(StyledString label) {
+       int i= 0;
+       char[] content= label.toString().toCharArray();
+       for (i = 0; i < content.length; i++) {
+                       char c = content[i];
+                       if (c == '-' || Character.isWhitespace(c)) {
+                               break;
+                       }
+               }
+       StyledString label2= new StyledString();
+       label2.append("{init "); //$NON-NLS-1$
+       i += label2.length();
+       label2.append(label);
+       label2.insert('}', i++);
+       label2.insert('(', i++);
+       label2.insert(')', i++);
+       label2.setStyle(0, i, null);
+       return label2;
+       }
+    
+
+       @Override
+       public void dispose() {
+        fCLabelProvider.dispose();
+        for (Image image : fCachedImages.values()) {
+            image.dispose();
+        }
+        fCachedImages.clear();
+        super.dispose();
+    }
+
+    private Image decorateImage(Image image, CHNode node) {
+        int flags= 0;        
+        if (node.isRecursive()) {
+            flags |= CElementImageDescriptor.RECURSIVE_RELATION;
+        }
+        else if (fContentProvider.hasChildren(node)) {
+            if (fContentProvider.getComputeReferencedBy()) {
+                flags |= CElementImageDescriptor.REFERENCED_BY;
+            }
+            else {
+               if (node.isMultiDef()) {
+                       flags |= CElementImageDescriptor.RELATES_TO_MULTIPLE;
+               }
+               else {
+                       flags |= CElementImageDescriptor.RELATES_TO;
+               }
+            }
+        }
+        if (node.isReadAccess()) {
+               flags |= CElementImageDescriptor.READ_ACCESS;
+        }
+        if (node.isWriteAccess()) {
+               flags |= CElementImageDescriptor.WRITE_ACCESS;
+        }
+
+        String key= image.toString()+String.valueOf(flags);
+        Image result= fCachedImages.get(key);
+        if (result == null) {
+            ImageDescriptor desc= new CElementImageDescriptor(
+                    new ImageImageDescriptor(image), flags, new Point(20,16));
+            result= desc.createImage();
+            fCachedImages.put(key, result);
+        }
+        return result;
+    }
+
+    @Override
+       public Color getForeground(Object element) {
+       if (element instanceof CHMultiDefNode) {
+               return fColorInactive;
+       }
+       return null;
+    }
+
+    public void setShowFiles(boolean show) {
+               fCLabelProvider.setTextFlags(show ? LABEL_OPTIONS_SHOW_FILES : LABEL_OPTIONS_SIMPLE);
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.java
new file mode 100644 (file)
index 0000000..127fcd4
--- /dev/null
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *    Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.callhierarchy;
+
+import org.eclipse.osgi.util.NLS;
+
+public class CHMessages extends NLS {
+       public static String CallHierarchyUI_label;
+       public static String CallHierarchyUI_openFailureMessage;
+       public static String CallHierarchyUI_selectMessage;
+       public static String CHHistoryListAction_HistoryDialog_title;
+       public static String CHHistoryListAction_HistoryList_label;
+       public static String CHHistoryListAction_OpenHistory_label;
+       public static String CHHistoryListAction_Remove_label;
+       public static String CHLabelProvider_matches;
+       public static String CHViewPart_emptyPageMessage;
+       public static String CHViewPart_FilterVariables_label;
+       public static String CHViewPart_FilterVariables_tooltip;
+       public static String CHViewPart_FocusOn_label;
+       public static String CHViewPart_NextReference_label;
+       public static String CHViewPart_NextReference_tooltip;
+       public static String CHViewPart_Open_label;
+       public static String CHViewPart_Open_tooltip;
+       public static String CHViewPart_PreviousReference_label;
+       public static String CHViewPart_PreviousReference_tooltip;
+       public static String CHViewPart_Refresh_label;
+       public static String CHViewPart_Refresh_tooltip;
+       public static String CHViewPart_CopyCallHierarchy_label;
+       public static String CHViewPart_ShowCallees_label;
+       public static String CHViewPart_ShowCallees_tooltip;
+       public static String CHViewPart_ShowCallers_label;
+       public static String CHViewPart_ShowCallers_tooltip;
+       public static String CHViewPart_ShowFiles_label;
+       public static String CHViewPart_ShowFiles_tooltip;
+       public static String CHViewPart_ShowReference_label;
+       public static String CHViewPart_ShowReference_tooltip;
+       public static String CHViewPart_Title_callees;
+       public static String CHViewPart_Title_callers;
+       public static String CHViewPart_WorkspaceScope;
+       public static String CHHistoryDropDownAction_ClearHistory_label;
+       public static String CHHistoryDropDownAction_ShowHistoryList_tooltip;
+       public static String OpenCallHierarchyAction_label;
+       public static String OpenCallHierarchyAction_tooltip;
+       public static String OpenElementInCallHierarchyAction_errorDlgTitle;
+       public static String OpenElementInCallHierarchyAction_errorNoDefinition;
+       public static String OpenElementInCallHierarchyAction_message;
+       public static String OpenElementInCallHierarchyAction_title;
+       public static String OpenElementInCallHierarchyAction_upperListLabel;
+
+       static {
+               // initialize resource bundle
+               NLS.initializeMessages(CHMessages.class.getName(), CHMessages.class);
+       }
+
+       private CHMessages() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.properties
new file mode 100644 (file)
index 0000000..2e8321e
--- /dev/null
@@ -0,0 +1,52 @@
+###############################################################################
+# Copyright (c) 2006, 2010 Wind River Systems, Inc. and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     Markus Schorn (Wind River Systems)
+#     Sergey Prigogin (Google)
+###############################################################################
+CHViewPart_emptyPageMessage=To display the call hierarchy, select a function or method and select the 'Open Call Hierarchy' menu option.
+CHViewPart_ShowCallers_label=Show Callers
+CHViewPart_ShowCallers_tooltip=Show Callers
+CHViewPart_ShowCallees_label=Show Callees
+CHViewPart_ShowCallees_tooltip=Show Callees
+CHViewPart_ShowReference_label=Show Reference
+CHViewPart_ShowReference_tooltip=Show Reference
+CHViewPart_FilterVariables_label=Filter Variables
+CHViewPart_FilterVariables_tooltip=Hide Variables, Constants and Enumerators
+CHViewPart_ShowFiles_label=Show File Names
+CHViewPart_ShowFiles_tooltip=Show File Names
+CHViewPart_NextReference_label=Next Reference
+CHViewPart_NextReference_tooltip=Show Next Reference
+CHHistoryListAction_Remove_label=Remove
+CHViewPart_PreviousReference_label=Previous Reference
+CHViewPart_PreviousReference_tooltip=Show Previous Reference
+CHViewPart_Refresh_label=Refresh
+CHViewPart_Refresh_tooltip=Refresh View Content
+CHViewPart_WorkspaceScope=workspace
+CHViewPart_Title_callers=Callers of {0} - in {1}
+CHViewPart_Title_callees=Calls from {0} - in {1}
+CHViewPart_FocusOn_label=Focus On ''{0}''
+CHViewPart_Open_label=Open
+CHViewPart_Open_tooltip=Open
+CHViewPart_CopyCallHierarchy_label=Copy E&xpanded Hierarchy
+CHLabelProvider_matches=matches
+CHHistoryDropDownAction_ClearHistory_label=Clear History
+CHHistoryListAction_HistoryDialog_title=Call Hierarchy History
+CHHistoryListAction_HistoryList_label=Select the input for the Call Hierarchy:
+CHHistoryListAction_OpenHistory_label=Open History...
+CHHistoryDropDownAction_ShowHistoryList_tooltip=Show History List
+OpenCallHierarchyAction_label=Open Call H&ierarchy
+OpenCallHierarchyAction_tooltip=Open Call Hierarchy
+CallHierarchyUI_label=Open Call Hierarchy
+CallHierarchyUI_selectMessage=Select one element from the list
+CallHierarchyUI_openFailureMessage=Cannot resolve selected text to a defined function or member
+OpenElementInCallHierarchyAction_errorDlgTitle=Open Element in Call Hierarchy
+OpenElementInCallHierarchyAction_title=Open Element in Call Hierarchy
+OpenElementInCallHierarchyAction_upperListLabel=&Matching Elements:
+OpenElementInCallHierarchyAction_message=&Choose an element (? = any character, * = any string):
+OpenElementInCallHierarchyAction_errorNoDefinition=Could not locate definition of element ''{0}''
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefChildNode.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefChildNode.java
new file mode 100644 (file)
index 0000000..1df96be
--- /dev/null
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.callhierarchy;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+/**
+ * Represents a child of a node with multiple definitions.
+ */
+public class CHMultiDefChildNode extends CHNode {
+
+    public CHMultiDefChildNode(CHMultiDefNode parent, ITranslationUnit fileOfReferences, long timestamp, ICElement decl, int linkageID) {
+       super(parent, fileOfReferences, timestamp, decl, linkageID);
+    }
+    
+       @Override
+       public int getReferenceCount() {
+               return getParent().getReferenceCount();
+       }
+       
+       @Override
+       public CHReferenceInfo getReference(int idx) {
+               return getParent().getReference(idx);
+       }
+       
+       @Override
+       public int getFirstReferenceOffset() {
+               return getParent().getFirstReferenceOffset();
+       }
+       
+       @Override
+       public void addReference(CHReferenceInfo info) {
+               assert false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefNode.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefNode.java
new file mode 100644 (file)
index 0000000..868e5a8
--- /dev/null
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.callhierarchy;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+import org.eclipse.cdt.internal.ui.util.CoreUtility;
+
+public class CHMultiDefNode extends CHNode {
+
+       private CHNode[] fChildren;
+
+       public CHMultiDefNode(CHNode parent, ITranslationUnit tu, long timestamp, ICElement[] elements, int linkageID) {
+               super(parent, tu, timestamp, null, linkageID);
+               if (elements.length == 0) {
+                       throw new IllegalArgumentException();
+               }
+               fHashCode+= elements[0].hashCode();
+               fChildren= new CHNode[elements.length];
+               for (int i = 0; i < elements.length; i++) {
+                       ICElement element = elements[i];
+                       fChildren[i]= new CHMultiDefChildNode(this, tu, timestamp, element, linkageID);
+               }
+       }
+       
+       public CHNode[] getChildNodes() {
+               return fChildren;
+       }
+
+       @Override
+       public boolean isMacro() {
+               return fChildren[0].isMacro();
+       }
+
+       @Override
+       public boolean isVariableOrEnumerator() {
+               return fChildren[0].isVariableOrEnumerator();
+       }
+
+       
+       @Override
+       public ICElement getOneRepresentedDeclaration() {
+               return fChildren[0].getRepresentedDeclaration();
+       }
+
+       @Override
+       public boolean isMultiDef() {
+               return true;
+       }
+    
+    @Override
+       public boolean equals(Object o) {
+       if (!super.equals(o) || !(o instanceof CHMultiDefNode)) 
+               return false;
+
+       final CHMultiDefNode rhs = (CHMultiDefNode) o;
+               return CoreUtility.safeEquals(getOneRepresentedDeclaration(), rhs.getOneRepresentedDeclaration());
+    }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHNode.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHNode.java
new file mode 100644 (file)
index 0000000..8976e9c
--- /dev/null
@@ -0,0 +1,200 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.callhierarchy;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IEnumerator;
+import org.eclipse.cdt.core.model.IMacro;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IVariableDeclaration;
+
+import org.eclipse.cdt.internal.ui.util.CoreUtility;
+
+/**
+ * Represents a node in the include browser
+ */
+public class CHNode implements IAdaptable {    
+       private CHNode fParent;
+       private ICElement fRepresentedDecl;
+       private ITranslationUnit fFileOfReferences;
+    private List<CHReferenceInfo> fReferences;
+    
+    protected int fHashCode;
+    private long fTimestamp;
+    private boolean fIsRecursive;
+       private boolean fIsInitializer;
+       private boolean fIsReadAccess;
+       private boolean fIsWriteAccess;
+       private final int fLinkageID;
+
+    /**
+     * Creates a new node for the include browser
+     */
+    public CHNode(CHNode parent, ITranslationUnit fileOfReferences, long timestamp, ICElement decl, int linkageID) {
+        fParent= parent;
+        fFileOfReferences= fileOfReferences;
+        fReferences= Collections.emptyList();
+        fRepresentedDecl= decl;
+        fIsRecursive= computeIsRecursive(fParent, decl);
+        fHashCode= computeHashCode();
+        fTimestamp= timestamp;
+        fLinkageID= linkageID;
+    }
+    
+       private int computeHashCode() {
+        int hashCode= 1;
+        if (fParent != null) {
+            hashCode= fParent.hashCode() * 31;
+        }
+        if (fRepresentedDecl != null) {
+               hashCode+= fRepresentedDecl.hashCode();
+        }
+        return hashCode;
+    }   
+
+    @Override
+       public int hashCode() {
+        return fHashCode;
+    }
+    
+    @Override
+       public boolean equals(Object o) {
+               if (!(o instanceof CHNode)) {
+                       return false;
+               }
+
+               CHNode rhs = (CHNode) o;
+               if (fHashCode != rhs.fHashCode) {
+                       return false;
+               }
+
+               return CoreUtility.safeEquals(fRepresentedDecl, rhs.fRepresentedDecl);
+    }
+    
+    private boolean computeIsRecursive(CHNode parent, ICElement decl) {
+        if (parent == null || decl == null) {
+            return false;
+        }
+        if (decl.equals(parent.fRepresentedDecl)) {
+            return true;
+        }
+        return computeIsRecursive(parent.fParent, decl);
+    }
+
+       /**
+     * Returns the parent node or <code>null</code> for the root node.
+     */
+    public CHNode getParent() {
+        return fParent;
+    }
+
+    public int getLinkageID() {
+       return fLinkageID;
+    }
+
+       public boolean isRecursive() {
+        return fIsRecursive;
+    }
+
+       public int getReferenceCount() {
+               return fReferences.size();
+       }
+       
+       public CHReferenceInfo getReference(int idx) {
+               return fReferences.get(idx);
+       }
+       
+       public ICElement getRepresentedDeclaration() {
+               return fRepresentedDecl;
+       }
+
+       public long getTimestamp() {
+               return fTimestamp;
+       }
+
+       public boolean isMacro() {
+               return fRepresentedDecl instanceof IMacro;
+       }
+
+       public boolean isVariableOrEnumerator() {
+               return fRepresentedDecl instanceof IVariableDeclaration ||
+                       fRepresentedDecl instanceof IEnumerator;
+       }
+       
+       public int getFirstReferenceOffset() {
+               return fReferences.isEmpty() ? -1 : getReference(0).getOffset();
+       }
+       
+       public void addReference(CHReferenceInfo info) {
+               switch (fReferences.size()) {
+               case 0:
+                       fReferences= Collections.singletonList(info);
+                       return;
+               case 1:
+                       fReferences= new ArrayList<CHReferenceInfo>(fReferences);
+                       break;
+               }
+               fReferences.add(info);
+       }
+
+       public ITranslationUnit getFileOfReferences() {
+               return fFileOfReferences;
+       }
+
+       @SuppressWarnings({ "unchecked", "rawtypes" })
+       public Object getAdapter(Class adapter) {
+               if (adapter.isAssignableFrom(ICElement.class)) {
+                       return getRepresentedDeclaration();
+               }
+               return null;
+       }
+       
+       public boolean isMultiDef() {
+               return false;
+       }
+
+       public ICElement getOneRepresentedDeclaration() {
+               return getRepresentedDeclaration();
+       }
+
+       public boolean isInitializer() {
+               return fIsInitializer;
+       }
+
+       public void setInitializer(boolean isInitializer) {
+               fIsInitializer = isInitializer;
+       }
+
+       public void sortReferencesByOffset() {
+               if (fReferences.size() > 1) {
+                       Collections.sort(fReferences, CHReferenceInfo.COMPARE_OFFSET);
+               }
+       }
+
+       public void setRWAccess(boolean readAccess, boolean writeAccess) {
+               fIsReadAccess= readAccess;
+               fIsWriteAccess= writeAccess;
+       }
+
+       public boolean isReadAccess() {
+               return fIsReadAccess;
+       }
+
+       public boolean isWriteAccess() {
+               return fIsWriteAccess;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java
new file mode 100644 (file)
index 0000000..d456591
--- /dev/null
@@ -0,0 +1,171 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.callhierarchy;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.ILinkage;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexBinding;
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
+import org.eclipse.cdt.internal.core.model.ext.ICElementHandle;
+
+import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
+
+
+/**
+ * Access to high level queries in the index.
+ * @since 4.0
+ */
+public class CHQueries {
+       private static final CHNode[] EMPTY_NODES= new CHNode[0];
+       
+    private CHQueries() {}
+    
+       /**
+        * Searches for functions and methods that call a given element.
+        */
+       public static CHNode[] findCalledBy(CHContentProvider cp, CHNode node, IIndex index, IProgressMonitor pm) 
+                       throws CoreException {
+               CalledByResult result= new CalledByResult();
+               ICElement callee= node.getRepresentedDeclaration();
+               if (!(callee instanceof ISourceReference)) {
+                       return EMPTY_NODES;
+               }
+               boolean done= false;
+               int linkageID= node.getLinkageID();
+               if (linkageID == -1) {
+                       final ITranslationUnit tu = ((ISourceReference) callee).getTranslationUnit();
+                       if (tu == null)
+                               return EMPTY_NODES;
+                       
+                       final String ct = tu.getContentTypeId();
+                       if (ct.equals(CCorePlugin.CONTENT_TYPE_CXXHEADER)) {
+                               // bug 260262: in a header file we need to consider c and c++
+                               findCalledBy(callee, ILinkage.C_LINKAGE_ID, index, result);
+                               findCalledBy(callee, ILinkage.CPP_LINKAGE_ID, index, result);
+                               done= true;
+                       }
+               }
+               if (!done) {
+                       findCalledBy(callee, linkageID, index, result);
+               }
+               return cp.createNodes(node, result);
+       }
+
+       private static void findCalledBy(ICElement callee, int linkageID, IIndex index, CalledByResult result) 
+                       throws CoreException {
+               final ICProject project = callee.getCProject();
+               IIndexBinding calleeBinding= IndexUI.elementToBinding(index, callee, linkageID);
+               if (calleeBinding != null) {
+                       findCalledBy1(index, calleeBinding, true, project, result);
+                       if (calleeBinding instanceof ICPPMethod) {
+                               IBinding[] overriddenBindings= ClassTypeHelper.findOverridden((ICPPMethod) calleeBinding);
+                               for (IBinding overriddenBinding : overriddenBindings) {
+                                       findCalledBy1(index, overriddenBinding, false, project, result);
+                               }
+                       }
+               }
+       }
+
+       private static void findCalledBy1(IIndex index, IBinding callee, boolean includeOrdinaryCalls,
+                       ICProject project, CalledByResult result) throws CoreException {
+               findCalledBy2(index, callee, includeOrdinaryCalls, project, result);
+               List<? extends IBinding> specializations = IndexUI.findSpecializations(callee);
+               for (IBinding spec : specializations) {
+                       findCalledBy2(index, spec, includeOrdinaryCalls, project, result);
+               }
+       }
+
+
+       private static void findCalledBy2(IIndex index, IBinding callee, boolean includeOrdinaryCalls, ICProject project, CalledByResult result) 
+                       throws CoreException {
+               IIndexName[] names= index.findNames(callee, IIndex.FIND_REFERENCES | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
+               for (IIndexName rname : names) {
+                       if (includeOrdinaryCalls || rname.couldBePolymorphicMethodCall()) {
+                               IIndexName caller= rname.getEnclosingDefinition();
+                               if (caller != null) {
+                                       ICElement elem= IndexUI.getCElementForName(project, index, caller);
+                                       if (elem != null) {
+                                               result.add(elem, rname);
+                                       } 
+                               }
+                       }
+               }
+       }
+
+       /**
+        * Searches for all calls that are made within a given range.
+        */
+       public static CHNode[] findCalls(CHContentProvider cp, CHNode node, IIndex index, IProgressMonitor pm) 
+                       throws CoreException {
+               ICElement caller= node.getRepresentedDeclaration();
+               CallsToResult result= new CallsToResult();
+               IIndexName callerName= IndexUI.elementToName(index, caller);
+               if (callerName != null) {
+                       IIndexName[] refs= callerName.getEnclosedNames();
+                       for (IIndexName name : refs) {
+                               IBinding binding= index.findBinding(name);
+                               if (CallHierarchyUI.isRelevantForCallHierarchy(binding)) {
+                                       for(;;) {
+                                               ICElement[] defs= null;
+                                               if (binding instanceof ICPPMethod) {
+                                                       defs = findOverriders(index, (ICPPMethod) binding);
+                                               }
+                                               if (defs == null) {
+                                                       defs= IndexUI.findRepresentative(index, binding);
+                                               }
+                                               if (defs != null && defs.length > 0) {
+                                                       result.add(defs, name);
+                                               } else if (binding instanceof ICPPSpecialization) {
+                                                       binding= ((ICPPSpecialization) binding).getSpecializedBinding();
+                                                       if (binding != null)
+                                                               continue;
+                                               }
+                                               break;
+                                       }
+                               }
+                       }
+               }
+               return cp.createNodes(node, result);
+       }
+
+       /**
+        * Searches for overriders of method and converts them to ICElement, returns null, if there are none.
+        */
+       static ICElement[] findOverriders(IIndex index, ICPPMethod binding)     throws CoreException {
+               IBinding[] virtualOverriders= ClassTypeHelper.findOverriders(index, binding);
+               if (virtualOverriders.length > 0) {
+                       ArrayList<ICElementHandle> list= new ArrayList<ICElementHandle>();
+                       list.addAll(Arrays.asList(IndexUI.findRepresentative(index, binding)));
+                       for (IBinding overrider : virtualOverriders) {
+                               list.addAll(Arrays.asList(IndexUI.findRepresentative(index, overrider)));
+                       }
+                       return list.toArray(new ICElement[list.size()]);
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHReferenceInfo.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHReferenceInfo.java
new file mode 100644 (file)
index 0000000..bd8af5e
--- /dev/null
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.callhierarchy;
+
+import java.util.Comparator;
+
+public class CHReferenceInfo {
+       public static final Comparator<CHReferenceInfo> COMPARE_OFFSET = new Comparator<CHReferenceInfo>() {
+               public int compare(CHReferenceInfo r1, CHReferenceInfo r2) {
+                       return r1.fOffset - r2.fOffset;
+               }
+       };
+       private int fOffset;
+       private int fLength;
+
+       public CHReferenceInfo(int offset, int length) {
+               fOffset= offset;
+               fLength= length;
+       }
+       
+       public int getOffset() {
+               return fOffset;
+       }
+
+       public int getLength() {
+               return fLength;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java
new file mode 100644 (file)
index 0000000..dc1a089
--- /dev/null
@@ -0,0 +1,812 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2011 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *    Sergey Prigogin (Google)
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.callhierarchy;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.IOpenListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.OpenEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DropTarget;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.contexts.IContextActivation;
+import org.eclipse.ui.contexts.IContextService;
+import org.eclipse.ui.navigator.ICommonMenuConstants;
+import org.eclipse.ui.part.PageBook;
+import org.eclipse.ui.part.ViewPart;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IFunction;
+import org.eclipse.cdt.core.model.IMethod;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.actions.CdtActionConstants;
+import org.eclipse.cdt.ui.actions.OpenViewActionGroup;
+import org.eclipse.cdt.ui.refactoring.actions.CRefactoringActionGroup;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.IContextMenuConstants;
+import org.eclipse.cdt.internal.ui.actions.CopyTreeAction;
+import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
+import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
+import org.eclipse.cdt.internal.ui.util.CoreUtility;
+import org.eclipse.cdt.internal.ui.util.Messages;
+import org.eclipse.cdt.internal.ui.viewsupport.AdaptingSelectionProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
+import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCLabelProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.EditorOpener;
+import org.eclipse.cdt.internal.ui.viewsupport.ExtendedTreeViewer;
+import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
+import org.eclipse.cdt.internal.ui.viewsupport.TreeNavigator;
+import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
+
+/**
+ * The view part for the include browser.
+ */
+public class CHViewPart extends ViewPart {
+       private static final int MAX_HISTORY_SIZE = 10;
+    private static final String TRUE = String.valueOf(true);
+    private static final String KEY_WORKING_SET_FILTER = "workingSetFilter"; //$NON-NLS-1$
+    private static final String KEY_FILTER_VARIABLES = "variableFilter"; //$NON-NLS-1$
+    private static final String KEY_SHOW_FILES= "showFilesInLabels"; //$NON-NLS-1$
+    
+    private IMemento fMemento;
+    private boolean fShowsMessage;
+    private CHNode fNavigationNode;
+    private int fNavigationDetail;
+    
+       private ArrayList<ICElement> fHistoryEntries= new ArrayList<ICElement>(MAX_HISTORY_SIZE);
+
+    // widgets
+    private PageBook fPagebook;
+    private Composite fViewerPage;
+    private Label fInfoText;
+
+    // treeviewer
+    private CHContentProvider fContentProvider;
+    private CHLabelProvider fLabelProvider;
+    private ExtendedTreeViewer fTreeViewer;
+
+    // filters, sorter
+    private ViewerFilter fVariableFilter;
+    private ViewerComparator fSorterAlphaNumeric;
+    private ViewerComparator fSorterReferencePosition;
+       private WorkingSetFilterUI fWorkingSetFilterUI;
+
+    // actions
+    private Action fReferencedByAction;
+    private Action fMakesReferenceToAction;
+    private Action fFilterVariablesAction;
+    private Action fShowFilesInLabelsAction;
+    private Action fNextAction;
+    private Action fPreviousAction;
+    private Action fRefreshAction;
+       private Action fHistoryAction;
+       private Action fShowReference;
+       private Action fOpenElement;
+       private CopyTreeAction fCopyAction;
+       
+       // action groups
+       private OpenViewActionGroup fOpenViewActionGroup;
+       private SelectionSearchGroup fSelectionSearchGroup;
+       private CRefactoringActionGroup fRefactoringActionGroup;
+       private IContextActivation fContextActivation;
+    
+    @Override
+       public void setFocus() {
+        fPagebook.setFocus();
+    }
+
+    public void setMessage(String msg) {
+        fInfoText.setText(msg);
+        fPagebook.showPage(fInfoText);
+        fShowsMessage= true;
+        updateDescription();
+        updateActionEnablement();
+    }
+    
+    public void setInput(ICElement input) {
+       if (input == null) {
+            setMessage(CHMessages.CHViewPart_emptyPageMessage);
+            fTreeViewer.setInput(null);
+            return;
+       }
+        fShowsMessage= false;
+        boolean allowsRefTo= allowsRefTo(input);
+        fTreeViewer.setInput(null);
+        if (!allowsRefTo && !fContentProvider.getComputeReferencedBy()) {
+               fContentProvider.setComputeReferencedBy(true);
+               fReferencedByAction.setChecked(true);
+               fMakesReferenceToAction.setChecked(false);
+               updateSorter();
+        }
+       fMakesReferenceToAction.setEnabled(allowsRefTo);
+        fTreeViewer.setInput(input);
+        fPagebook.showPage(fViewerPage);
+        updateDescription();
+       updateHistory(input);
+       updateActionEnablement();
+    }
+
+       public void reportNotIndexed(ICElement input) {
+               if (input != null && getInput() == input) {
+                       setMessage(IndexUI.getFileNotIndexedMessage(input));
+               }
+       }
+
+       public void reportInputReplacement(ICElement input, ICElement inputHandle) {
+               if (input == getInput()) {
+                       fTreeViewer.setInput(inputHandle);
+                       fTreeViewer.setExpandedState(inputHandle, true);
+               }
+       }
+
+       private boolean allowsRefTo(ICElement element) {
+               if (element instanceof IFunction || element instanceof IMethod) {
+                       return true;
+               }
+               
+               return false;
+       }
+
+       @Override
+       public void createPartControl(Composite parent) {
+        fPagebook = new PageBook(parent, SWT.NULL);
+        createInfoPage();
+        createViewerPage();
+                
+        getSite().setSelectionProvider(new AdaptingSelectionProvider(ICElement.class, fTreeViewer));
+
+        initDragAndDrop();
+        createActions();
+        createContextMenu();
+
+        setMessage(CHMessages.CHViewPart_emptyPageMessage);
+        
+        initializeActionStates();
+        
+       IContextService ctxService = (IContextService) getSite().getService(IContextService.class);
+       if (ctxService != null) {
+               fContextActivation= ctxService.activateContext(CUIPlugin.CVIEWS_SCOPE);
+       }
+
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(fPagebook, ICHelpContextIds.CALL_HIERARCHY_VIEW);
+       }
+       
+       @Override
+       public void dispose() {
+               if (fContextActivation != null) {
+                       IContextService ctxService = (IContextService)getSite().getService(IContextService.class);
+               if (ctxService != null) {
+                       ctxService.deactivateContext(fContextActivation);
+               }
+               }
+
+               if (fOpenViewActionGroup != null) {
+                       fOpenViewActionGroup.dispose();
+                       fOpenViewActionGroup= null;
+               }
+               if (fSelectionSearchGroup != null) {
+                       fSelectionSearchGroup.dispose();
+                       fSelectionSearchGroup= null;
+               }
+               if (fRefactoringActionGroup != null) {
+                       fRefactoringActionGroup.dispose();
+                       fRefactoringActionGroup= null;
+               }
+               if (fWorkingSetFilterUI != null) {
+                       fWorkingSetFilterUI.dispose();
+                       fWorkingSetFilterUI= null;
+               }
+               super.dispose();
+       }
+       
+    private void initializeActionStates() {
+        boolean referencedBy= true;
+        boolean filterVariables= false;
+        boolean showFiles= false;
+        
+        if (fMemento != null) {
+            filterVariables= TRUE.equals(fMemento.getString(KEY_FILTER_VARIABLES));
+            showFiles= TRUE.equals(fMemento.getString(KEY_SHOW_FILES));
+        }
+        
+        fLabelProvider.setShowFiles(showFiles);
+        fShowFilesInLabelsAction.setChecked(showFiles);
+        
+        fReferencedByAction.setChecked(referencedBy);
+        fMakesReferenceToAction.setChecked(!referencedBy);
+        fContentProvider.setComputeReferencedBy(referencedBy);
+        
+        fFilterVariablesAction.setChecked(filterVariables);
+        fFilterVariablesAction.run();
+        updateSorter();
+    }
+
+    @Override
+       public void init(IViewSite site, IMemento memento) throws PartInitException {
+        fMemento= memento;
+        super.init(site, memento);
+    }
+
+
+    @Override
+       public void saveState(IMemento memento) {
+        if (fWorkingSetFilterUI != null) {
+               fWorkingSetFilterUI.saveState(memento, KEY_WORKING_SET_FILTER);
+        }
+        memento.putString(KEY_FILTER_VARIABLES, String.valueOf(fFilterVariablesAction.isChecked()));
+        memento.putString(KEY_SHOW_FILES, String.valueOf(fShowFilesInLabelsAction.isChecked()));
+        super.saveState(memento);
+    }
+
+    private void createContextMenu() {
+        MenuManager manager = new MenuManager();
+        manager.setRemoveAllWhenShown(true);
+        manager.addMenuListener(new IMenuListener() {
+            public void menuAboutToShow(IMenuManager m) {
+                onContextMenuAboutToShow(m);
+            }
+        });
+        Menu menu = manager.createContextMenu(fTreeViewer.getControl());
+        fTreeViewer.getControl().setMenu(menu);
+        IWorkbenchPartSite site = getSite();
+        site.registerContextMenu(CUIPlugin.ID_CALL_HIERARCHY, manager, fTreeViewer);
+    }
+
+    private void createViewerPage() {
+        Display display= getSite().getShell().getDisplay();
+        fViewerPage = new Composite(fPagebook, SWT.NULL);
+        fViewerPage.setLayoutData(new GridData(GridData.FILL_BOTH));
+        fViewerPage.setSize(100, 100);
+        fViewerPage.setLayout(new FillLayout());
+
+        fContentProvider= new CHContentProvider(this, display); 
+        fLabelProvider= new CHLabelProvider(display, fContentProvider);
+        fTreeViewer= new ExtendedTreeViewer(fViewerPage);
+        fTreeViewer.setContentProvider(fContentProvider);
+        fTreeViewer.setLabelProvider(new DecoratingCLabelProvider(fLabelProvider));
+        fTreeViewer.setAutoExpandLevel(2);     
+        fTreeViewer.addOpenListener(new IOpenListener() {
+                       public void open(OpenEvent event) {
+               onShowSelectedReference(event.getSelection());
+            }
+        });
+    }
+    
+    private void createInfoPage() {
+       fInfoText = new Label(fPagebook, SWT.TOP | SWT.LEFT | SWT.WRAP);
+    }
+
+    private void initDragAndDrop() {
+        CHDropTargetListener dropListener= new CHDropTargetListener(this);
+        Transfer[] localSelectionTransfer= new Transfer[] {
+                       LocalSelectionTransfer.getTransfer()
+        };
+        DropTarget dropTarget = new DropTarget(fPagebook, DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT);
+        dropTarget.setTransfer(localSelectionTransfer);
+        dropTarget.addDropListener(dropListener);
+    }
+
+    private void createActions() {
+       // action groups
+       fOpenViewActionGroup= new OpenViewActionGroup(this);
+       fOpenViewActionGroup.setSuppressCallHierarchy(true);
+       fOpenViewActionGroup.setSuppressProperties(true);
+       fOpenViewActionGroup.setEnableIncludeBrowser(true);
+       fSelectionSearchGroup= new SelectionSearchGroup(getSite());
+       fRefactoringActionGroup= new CRefactoringActionGroup(this);
+       
+       fWorkingSetFilterUI= new WorkingSetFilterUI(this, fMemento, KEY_WORKING_SET_FILTER) {
+            @Override
+                       protected void onWorkingSetChange() {
+                updateWorkingSetFilter(this);
+            }
+            @Override
+                       protected void onWorkingSetNameChange() {
+                updateDescription();
+            }
+        };
+
+        fReferencedByAction= 
+            new Action(CHMessages.CHViewPart_ShowCallers_label, IAction.AS_RADIO_BUTTON) { 
+                @Override
+                               public void run() {
+                    if (isChecked()) {
+                        onSetShowReferencedBy(true);
+                    }
+                }
+        };
+        fReferencedByAction.setToolTipText(CHMessages.CHViewPart_ShowCallers_tooltip);
+        CPluginImages.setImageDescriptors(fReferencedByAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_REF_BY);       
+
+        fMakesReferenceToAction= 
+            new Action(CHMessages.CHViewPart_ShowCallees_label, IAction.AS_RADIO_BUTTON) { 
+                @Override
+                               public void run() {
+                    if (isChecked()) {
+                        onSetShowReferencedBy(false);
+                    }
+                }
+        };
+        fMakesReferenceToAction.setToolTipText(CHMessages.CHViewPart_ShowCallees_tooltip);
+        CPluginImages.setImageDescriptors(fMakesReferenceToAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_RELATES_TO);       
+
+        fVariableFilter= new ViewerFilter() {
+            @Override
+                       public boolean select(Viewer viewer, Object parentElement, Object element) {
+                if (element instanceof CHNode) {
+                       CHNode node= (CHNode) element;
+                    return !node.isVariableOrEnumerator();
+                }
+                return true;
+            }
+        };
+        fFilterVariablesAction= new Action(CHMessages.CHViewPart_FilterVariables_label, IAction.AS_CHECK_BOX) {
+            @Override
+                       public void run() {
+                if (isChecked()) {
+                    fTreeViewer.addFilter(fVariableFilter);
+                }
+                else {
+                    fTreeViewer.removeFilter(fVariableFilter);
+                }
+            }
+        };
+        fFilterVariablesAction.setToolTipText(CHMessages.CHViewPart_FilterVariables_tooltip);
+        CPluginImages.setImageDescriptors(fFilterVariablesAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_FIELDS);       
+        
+        fSorterAlphaNumeric= new ViewerComparator();
+        fSorterReferencePosition= new ViewerComparator() {
+            @Override
+                       public int category(Object element) {
+                if (element instanceof CHNode) {
+                    return 0;
+                }
+                return 1;
+            }
+            @Override
+                       public int compare(Viewer viewer, Object e1, Object e2) {
+                if (!(e1 instanceof CHNode)) {
+                    if (!(e2 instanceof CHNode)) {
+                        return 0;
+                    }
+                    return -1;
+                }
+                if (!(e2 instanceof CHNode)) {
+                    return 1;
+                }
+                CHNode n1= (CHNode) e1;
+                CHNode n2= (CHNode) e2;
+                int offset1= n1.getFirstReferenceOffset();
+                int offset2= n2.getFirstReferenceOffset();
+                return CoreUtility.compare(offset1, offset2);
+            }
+        };
+        
+        fShowReference= new Action(CHMessages.CHViewPart_ShowReference_label) {
+               @Override
+                       public void run() {
+                       onShowSelectedReference(fTreeViewer.getSelection());
+               }
+        };
+        fShowReference.setToolTipText(CHMessages.CHViewPart_ShowReference_tooltip);    
+        fOpenElement= new Action(CHMessages.CHViewPart_Open_label) {
+               @Override
+                       public void run() {
+                       onOpenElement(fTreeViewer.getSelection());
+               }
+        };
+        fOpenElement.setToolTipText(CHMessages.CHViewPart_Open_tooltip);
+        fOpenElement.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_DECL);
+
+        fShowFilesInLabelsAction= new Action(CHMessages.CHViewPart_ShowFiles_label, IAction.AS_CHECK_BOX) {
+            @Override
+                       public void run() {
+                onShowFilesInLabels(isChecked());
+            }
+        };
+        fShowFilesInLabelsAction.setToolTipText(CHMessages.CHViewPart_ShowFiles_tooltip);
+        fNextAction = new Action(CHMessages.CHViewPart_NextReference_label) {
+            @Override
+                       public void run() {
+                onNextOrPrevious(true);
+            }
+        };
+        fNextAction.setToolTipText(CHMessages.CHViewPart_NextReference_tooltip); 
+        CPluginImages.setImageDescriptors(fNextAction, CPluginImages.T_LCL, CPluginImages.IMG_SHOW_NEXT);       
+
+        fPreviousAction = new Action(CHMessages.CHViewPart_PreviousReference_label) {
+            @Override
+                       public void run() {
+                onNextOrPrevious(false);
+            }
+        };
+        fPreviousAction.setToolTipText(CHMessages.CHViewPart_PreviousReference_tooltip); 
+        CPluginImages.setImageDescriptors(fPreviousAction, CPluginImages.T_LCL, CPluginImages.IMG_SHOW_PREV);       
+
+        fRefreshAction = new Action(CHMessages.CHViewPart_Refresh_label) {
+            @Override
+                       public void run() {
+                onRefresh();
+            }
+        };
+        fRefreshAction.setToolTipText(CHMessages.CHViewPart_Refresh_tooltip); 
+        CPluginImages.setImageDescriptors(fRefreshAction, CPluginImages.T_LCL, CPluginImages.IMG_REFRESH);       
+
+        fHistoryAction = new CHHistoryDropDownAction(this);
+
+        fCopyAction= new CopyCallHierarchyAction(this, fTreeViewer);
+
+        // setup action bar
+        // global action hooks
+        IActionBars actionBars = getViewSite().getActionBars();
+        fRefactoringActionGroup.fillActionBars(actionBars);
+        fOpenViewActionGroup.fillActionBars(actionBars);
+        fSelectionSearchGroup.fillActionBars(actionBars);
+        
+        actionBars.setGlobalActionHandler(CdtActionConstants.OPEN_DECLARATION, fOpenElement);
+        actionBars.setGlobalActionHandler(ActionFactory.NEXT.getId(), fNextAction);
+        actionBars.setGlobalActionHandler(ActionFactory.PREVIOUS.getId(), fPreviousAction);
+        actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), fRefreshAction);
+        actionBars.updateActionBars();
+        
+        // local toolbar
+        IToolBarManager tm = actionBars.getToolBarManager();
+        tm.add(fNextAction);
+        tm.add(fPreviousAction);
+        tm.add(new Separator());
+        tm.add(fFilterVariablesAction);
+        tm.add(new Separator());
+        tm.add(fReferencedByAction);
+        tm.add(fMakesReferenceToAction);
+               tm.add(fHistoryAction);
+        tm.add(fRefreshAction);
+
+        // local menu
+        IMenuManager mm = actionBars.getMenuManager();
+
+        fWorkingSetFilterUI.fillActionBars(actionBars);
+        mm.add(fReferencedByAction);
+        mm.add(fMakesReferenceToAction);
+        mm.add(new Separator());
+        mm.add(fShowFilesInLabelsAction);
+        mm.add(new Separator());
+        mm.add(fFilterVariablesAction);
+    }
+    
+    private void setNextNode(boolean forward) {
+       TreeNavigator navigator= new TreeNavigator(fTreeViewer.getTree(), CHNode.class);
+       TreeItem selectedItem= navigator.getSelectedItemOrFirstOnLevel(1, forward);
+       if (selectedItem == null) {
+               fNavigationNode= null;
+               return;
+       }
+       
+       
+        if (selectedItem.getData().equals(fNavigationNode)) {
+               if (forward && fNavigationDetail < getReferenceCount(fNavigationNode)-1) {
+                       fNavigationDetail++;
+               }
+               else if (!forward && fNavigationDetail > 0) {
+                       fNavigationDetail--;
+               }
+               else {
+                       selectedItem= navigator.getNextSibbling(selectedItem, forward);
+                fNavigationNode= selectedItem == null ? null : (CHNode) selectedItem.getData();
+               initNavigationDetail(forward);
+               }
+        }
+        else {
+               fNavigationNode= (CHNode) selectedItem.getData();
+               initNavigationDetail(forward);
+        }
+    }
+
+       private void initNavigationDetail(boolean forward) {
+               if (!forward && fNavigationNode != null) {
+                       fNavigationDetail= Math.max(0, getReferenceCount(fNavigationNode) -1);
+               }
+               else {
+                       fNavigationDetail= 0;
+               }
+       }
+        
+       protected void onShowSelectedReference(ISelection selection) {
+               CHNode node= selectionToNode(selection);
+               if (node != null && node == fNavigationNode && node.getReferenceCount() > 0) {
+                       fNavigationDetail= (fNavigationDetail + 1) % node.getReferenceCount();
+               }
+               else {
+                       fNavigationDetail= 0;
+               }
+       fNavigationNode= node; 
+        showReference();
+       }
+
+       protected void onOpenElement(ISelection selection) {
+       CHNode node= selectionToNode(selection);
+       openElement(node);
+       }
+
+       private void openElement(CHNode node) {
+               if (node != null && !node.isMultiDef()) {
+               ICElement elem= node.getRepresentedDeclaration();
+               if (elem != null) {
+                       IWorkbenchPage page= getSite().getPage();
+                       try {
+                                       EditorOpener.open(page, elem);
+                               } catch (CModelException e) {
+                                       CUIPlugin.log(e);
+                               }
+               }
+       }
+       }
+
+    protected void onNextOrPrevious(boolean forward) {
+       setNextNode(forward);
+        if (fNavigationNode != null) {
+            StructuredSelection sel= new StructuredSelection(fNavigationNode);
+            fTreeViewer.setSelection(sel);
+            showReference();
+        }
+    }
+
+    protected void onRefresh() {
+        fContentProvider.recompute();
+    }
+    
+    protected void onShowFilesInLabels(boolean show) {
+        fLabelProvider.setShowFiles(show);
+        fTreeViewer.refresh();
+    }
+
+    private void updateHistory(ICElement input) {
+       if (input != null) {
+               fHistoryEntries.remove(input);
+               fHistoryEntries.add(0, input);
+               if (fHistoryEntries.size() > MAX_HISTORY_SIZE) {
+                       fHistoryEntries.remove(MAX_HISTORY_SIZE-1);
+               }
+       }
+       }
+
+    private void updateSorter() {
+        if (fReferencedByAction.isChecked()) {
+            fTreeViewer.setComparator(fSorterAlphaNumeric);
+        }
+        else {
+            fTreeViewer.setComparator(fSorterReferencePosition);
+        }
+    }
+    
+    private void updateDescription() {
+        String message= ""; //$NON-NLS-1$
+        if (!fShowsMessage) {
+               ICElement elem= getInput();
+            if (elem != null) {
+                String format, scope, label;
+               
+                // label
+                label= CElementLabels.getElementLabel(elem, CHHistoryAction.LABEL_OPTIONS);
+               
+                // scope
+                IWorkingSet workingSet= fWorkingSetFilterUI.getWorkingSet();
+               if (workingSet == null) {       
+                       scope= CHMessages.CHViewPart_WorkspaceScope;
+               }
+               else {
+                       scope= workingSet.getLabel();
+               }
+                
+               // format
+               if (fReferencedByAction.isChecked()) {
+                       format= CHMessages.CHViewPart_Title_callers;
+               }
+               else {
+                       format= CHMessages.CHViewPart_Title_callees;
+               }
+               
+               // message
+               message= Messages.format(format, label, scope);
+            }
+        }
+        setContentDescription(message);
+    }
+    
+       private void updateActionEnablement() {
+               fHistoryAction.setEnabled(!fHistoryEntries.isEmpty());
+               fNextAction.setEnabled(!fShowsMessage);
+               fPreviousAction.setEnabled(!fShowsMessage);
+               fRefreshAction.setEnabled(!fShowsMessage);
+       }
+
+    private void updateWorkingSetFilter(WorkingSetFilterUI filterUI) {
+       fContentProvider.setWorkingSetFilter(filterUI);
+    }
+    
+    public void onSetShowReferencedBy(boolean showReferencedBy) {
+        if (showReferencedBy != fContentProvider.getComputeReferencedBy()) {
+            Object input= fTreeViewer.getInput();
+            fTreeViewer.setInput(null);
+            fContentProvider.setComputeReferencedBy(showReferencedBy);
+            updateSorter();
+            fTreeViewer.setInput(input);
+            updateDescription();
+        }
+    }
+
+    protected void onContextMenuAboutToShow(IMenuManager menu) {
+               CUIPlugin.createStandardGroups(menu);
+               
+               CHNode node= selectionToNode(fTreeViewer.getSelection());
+               if (node != null) {
+                       if (getReferenceCount(node) > 0) {
+                               menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, fShowReference);
+                       }
+                       if (!node.isMultiDef()) {
+                               menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, fOpenElement);
+                       }
+                       if (node.getParent() != null) {
+                               final ICElement element= node.getRepresentedDeclaration();
+                               if (element != null) {
+                                       String label= Messages.format(CHMessages.CHViewPart_FocusOn_label, 
+                                                       CElementLabels.getTextLabel(element, CElementLabels.ALL_FULLY_QUALIFIED | CElementLabels.M_PARAMETER_TYPES));
+                                       menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, new Action(label) {
+                                               @Override
+                                               public void run() {
+                                                       setInput(element);
+                                               }
+                                       });
+                               }
+                       }
+               }
+               
+               // action groups
+               ISelection selection = getSite().getSelectionProvider().getSelection();
+               if (OpenViewActionGroup.canActionBeAdded(selection)){
+                       fOpenViewActionGroup.fillContextMenu(menu);
+               }
+
+               if (fCopyAction.canActionBeAdded()) {
+               menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, fCopyAction);
+               }
+
+               if (SelectionSearchGroup.canActionBeAdded(selection)){
+                       fSelectionSearchGroup.fillContextMenu(menu);
+               }
+               fRefactoringActionGroup.fillContextMenu(menu);
+    }
+           
+    private void showReference() {
+        if (fNavigationNode != null) {
+               ITranslationUnit file= fNavigationNode.getFileOfReferences();
+               if (file != null) {
+                       IWorkbenchPage page= getSite().getPage();
+                       if (fNavigationNode.getReferenceCount() > 0) {
+                               long timestamp= fNavigationNode.getTimestamp();
+                               if (fNavigationDetail < 0) {
+                                       fNavigationDetail= 0;
+                               }
+                               else if (fNavigationDetail >= fNavigationNode.getReferenceCount()-1) {
+                                       fNavigationDetail= fNavigationNode.getReferenceCount()-1;
+                               }
+
+                               CHReferenceInfo ref= fNavigationNode.getReference(fNavigationDetail);
+                               Region region= new Region(ref.getOffset(), ref.getLength());
+                               EditorOpener.open(page, file, region, timestamp);
+                       }
+                       else {
+                               try {
+                                       EditorOpener.open(page, fNavigationNode.getRepresentedDeclaration());
+                               } catch (CModelException e) {
+                                       CUIPlugin.log(e);
+                               }
+                       }
+               }
+        }
+    }
+    
+       private int getReferenceCount(CHNode node) {
+               if (node != null) {
+                       CHNode parent = node.getParent();
+                       if (parent instanceof CHMultiDefNode) {
+                               return parent.getReferenceCount();
+                       }
+                       return node.getReferenceCount();
+       }
+               return 0;
+       }
+               
+
+       private CHNode selectionToNode(ISelection selection) {
+               if (selection instanceof IStructuredSelection) {
+                       IStructuredSelection ss= (IStructuredSelection) selection;
+                       for (Iterator<?> iter = ss.iterator(); iter.hasNext(); ) {
+                               Object cand= iter.next();
+                               if (cand instanceof CHNode) {
+                                       return (CHNode) cand;
+                               }
+                       }
+               }
+               return null;
+       }
+
+       public Control getPageBook() {
+               return fPagebook;
+       }
+
+       public ICElement[] getHistoryEntries() {
+               return fHistoryEntries.toArray(new ICElement[fHistoryEntries.size()]);
+       }
+
+       public void setHistoryEntries(ICElement[] remaining) {
+               fHistoryEntries.clear();
+               fHistoryEntries.addAll(Arrays.asList(remaining));
+       }
+
+       public ICElement getInput() {
+        Object input= fTreeViewer.getInput();
+        if (input instanceof ICElement) {
+               return (ICElement) input;
+        }
+        return null;
+       }
+
+       public TreeViewer getTreeViewer() {
+               return fTreeViewer;
+       }
+
+       private static class CopyCallHierarchyAction extends CopyTreeAction {
+               public CopyCallHierarchyAction(ViewPart view, TreeViewer viewer) {
+                       super(CHMessages.CHViewPart_CopyCallHierarchy_label, view, viewer);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java
new file mode 100644 (file)
index 0000000..59e228e
--- /dev/null
@@ -0,0 +1,305 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.callhierarchy;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IEnumerator;
+import org.eclipse.cdt.core.dom.ast.IFunction;
+import org.eclipse.cdt.core.dom.ast.IVariable;
+import org.eclipse.cdt.core.dom.ast.c.ICExternalBinding;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexManager;
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.model.ext.ICElementHandle;
+import org.eclipse.cdt.internal.corext.util.CModelUtil;
+
+import org.eclipse.cdt.internal.ui.actions.OpenActionUtil;
+import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
+import org.eclipse.cdt.internal.ui.util.StatusLineHandler;
+import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
+
+public class CallHierarchyUI {
+       private static final ICElement[] NO_ELEMENTS = {};
+       private static boolean sIsJUnitTest= false;
+
+       public static void setIsJUnitTest(boolean val) {
+               sIsJUnitTest= val;
+       }
+       
+       public static void open(final IWorkbenchWindow window, final ICElement input) {
+        if (input != null) {
+               final Display display= Display.getCurrent();
+
+               Job job= new Job(CHMessages.CallHierarchyUI_label) {
+                       @Override
+                               protected IStatus run(IProgressMonitor monitor) {
+                               final ICElement[] elems= findDefinitions(input);
+                                       if (elems != null && elems.length > 0) {
+                                               display.asyncExec(new Runnable() {
+                                                       public void run() {
+                                                               internalOpen(window, elems);
+                                                       }});
+                                       } 
+                                       return Status.OK_STATUS;
+                       }
+               };
+               job.setUser(true);
+               job.schedule();
+        }
+    }
+
+    private static CHViewPart internalOpen(IWorkbenchWindow window, ICElement input) {
+        IWorkbenchPage page= window.getActivePage();
+        try {
+            CHViewPart result= (CHViewPart)page.showView(CUIPlugin.ID_CALL_HIERARCHY);
+            result.setInput(input);
+            return result;
+        } catch (CoreException e) {
+            ExceptionHandler.handle(e, window.getShell(), CHMessages.OpenCallHierarchyAction_label, null); 
+        }
+        return null;        
+    }
+
+    private static CHViewPart internalOpen(IWorkbenchWindow window, ICElement[] input) {
+               ICElement elem = null;
+               switch (input.length) {
+               case 0:
+                       break;
+               case 1:
+                       elem = input[0];
+                       break;
+               default:
+                       if (sIsJUnitTest) {
+                               throw new RuntimeException("ambiguous input"); //$NON-NLS-1$
+                       }
+                       elem = OpenActionUtil.selectCElement(input, window.getShell(),
+                                       CHMessages.CallHierarchyUI_label, CHMessages.CallHierarchyUI_selectMessage,
+                                       CElementLabels.ALL_DEFAULT | CElementLabels.MF_POST_FILE_QUALIFIED, 0);
+                       break;
+               }
+               if (elem != null) {
+                       return internalOpen(window, elem);
+               } 
+               return null;
+       }
+
+    public static void open(final ITextEditor editor, final ITextSelection sel) {
+               if (editor != null) {
+                       ICElement inputCElement = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
+                       if (inputCElement != null) {
+                               final ICProject project= inputCElement.getCProject();
+                               final IEditorInput editorInput = editor.getEditorInput();
+                               final Display display= Display.getCurrent();
+
+                               Job job= new Job(CHMessages.CallHierarchyUI_label) {
+                                       @Override
+                                       protected IStatus run(IProgressMonitor monitor) {
+                                               try {
+                                                       StatusLineHandler.clearStatusLine(editor.getSite());
+                                                       final ICElement[] elems= findDefinitions(project, editorInput, sel);
+                                                       if (elems.length > 0) {
+                                                               display.asyncExec(new Runnable() {
+                                                                       public void run() {
+                                                                               internalOpen(editor.getSite().getWorkbenchWindow(), elems);
+                                                                       }});
+                                                       } else {
+                                                               StatusLineHandler.showStatusLineMessage(editor.getSite(), 
+                                                                               CHMessages.CallHierarchyUI_openFailureMessage);
+                                                       }
+                                                       return Status.OK_STATUS;
+                                               } 
+                                               catch (CoreException e) {
+                                                       return e.getStatus();
+                                               }
+                                       }
+                               };
+                               job.setUser(true);
+                               job.schedule();
+                       }
+               }
+    }
+    
+       private static ICElement[] findDefinitions(ICProject project, IEditorInput editorInput, ITextSelection sel) 
+                       throws CoreException {
+               try {
+                       IIndex index= CCorePlugin.getIndexManager().getIndex(project, IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT);
+
+                       index.acquireReadLock();
+                       try {
+                               IASTName name= IndexUI.getSelectedName(editorInput, sel);
+                               if (name != null) {
+                                       IBinding binding= name.resolveBinding();
+                                       if (CallHierarchyUI.isRelevantForCallHierarchy(binding)) {
+                                               if (name.isDefinition()) {
+                                                       ICElement elem= IndexUI.getCElementForName(project, index, name);
+                                                       if (elem != null) {
+                                                               return new ICElement[]{elem};
+                                                       }
+                                                       return NO_ELEMENTS;
+                                               } 
+                                               
+                                               ICElement[] elems= IndexUI.findAllDefinitions(index, binding);
+                                               if (elems.length != 0) 
+                                                       return elems;
+                                                       
+                                               if (name.isDeclaration()) {
+                                                       ICElementHandle elem= IndexUI.getCElementForName(project, index, name);
+                                                       if (elem != null) {
+                                                               return new ICElement[] {elem};
+                                                       }
+                                                       return NO_ELEMENTS;
+                                               }
+
+                                               ICElementHandle elem= IndexUI.findAnyDeclaration(index, project, binding);
+                                               if (elem != null) {
+                                                       return new ICElement[]{elem};
+                                               }
+                                               
+                                               if (binding instanceof ICPPSpecialization) {
+                                                       return findSpecializationDeclaration(binding, project, index);
+                                               }
+                                               return NO_ELEMENTS;
+                                       }
+                               }
+                       }
+                       finally {
+                               index.releaseReadLock();
+                       }
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               } catch (InterruptedException e) {
+                       Thread.currentThread().interrupt();
+               }
+               return NO_ELEMENTS;
+       }
+
+       private static ICElement[] findSpecializationDeclaration(IBinding binding, ICProject project,
+                       IIndex index) throws CoreException {
+               while (binding instanceof ICPPSpecialization) {
+                       IBinding original= ((ICPPSpecialization) binding).getSpecializedBinding();
+                       ICElementHandle[] elems= IndexUI.findAllDefinitions(index, original);
+                       if (elems.length == 0) {
+                               ICElementHandle elem= IndexUI.findAnyDeclaration(index, project, original);
+                               if (elem != null) {
+                                       elems= new ICElementHandle[]{elem};
+                               }
+                       }
+                       if (elems.length > 0) {
+                               return elems;
+                       }
+                       binding= original;
+               }
+               return NO_ELEMENTS;
+       }
+
+       public static ICElement[] findDefinitions(ICElement input) {
+               try {
+                       final ITranslationUnit tu= CModelUtil.getTranslationUnit(input);
+                       if (tu != null) {
+                               final ICProject project= tu.getCProject();
+                               final IIndex index= CCorePlugin.getIndexManager().getIndex(project, IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT);
+
+                               index.acquireReadLock();
+                               try {
+                                       if (needToFindDefinition(input)) {
+                                               IBinding binding= IndexUI.elementToBinding(index, input);
+                                               if (binding != null) {
+                                                       ICElement[] result= IndexUI.findAllDefinitions(index, binding);
+                                                       if (result.length > 0) {
+                                                               return result;
+                                                       }
+                                               }
+                                       }
+                                       IIndexName name= IndexUI.elementToName(index, input);
+                                       if (name != null) {
+                                               ICElementHandle handle= IndexUI.getCElementForName(tu, index, name);
+                                               return new ICElement[] {handle};
+                                       }
+                               }
+                               finally {
+                                       index.releaseReadLock();
+                               }
+                       }
+               }
+               catch (CoreException e) {
+                       CUIPlugin.log(e);
+               } 
+               catch (InterruptedException e) {
+                       Thread.currentThread().interrupt();
+               }
+               return new ICElement[] {input};
+       }
+
+       private static boolean needToFindDefinition(ICElement elem) {
+               switch (elem.getElementType()) {
+               case ICElement.C_FUNCTION_DECLARATION:
+               case ICElement.C_METHOD_DECLARATION:
+               case ICElement.C_TEMPLATE_FUNCTION_DECLARATION:
+               case ICElement.C_TEMPLATE_METHOD_DECLARATION:
+                       return true;
+               }
+               return false;
+       }
+
+       public static boolean isRelevantForCallHierarchy(IBinding binding) {
+               if (binding instanceof ICExternalBinding ||
+                               binding instanceof IEnumerator ||
+                               binding instanceof IFunction ||
+                               binding instanceof IVariable) {
+                       return true;
+               }
+               return false;
+       }
+
+       public static boolean isRelevantForCallHierarchy(ICElement elem) {
+               if (elem == null) {
+                       return false;
+               }
+               switch (elem.getElementType()) {
+               case ICElement.C_ENUMERATOR:
+               case ICElement.C_FIELD:
+               case ICElement.C_FUNCTION:
+               case ICElement.C_FUNCTION_DECLARATION:
+               case ICElement.C_METHOD:
+               case ICElement.C_METHOD_DECLARATION:
+               case ICElement.C_TEMPLATE_FUNCTION:
+               case ICElement.C_TEMPLATE_FUNCTION_DECLARATION:
+               case ICElement.C_TEMPLATE_METHOD:
+               case ICElement.C_TEMPLATE_METHOD_DECLARATION:
+               case ICElement.C_TEMPLATE_VARIABLE:
+               case ICElement.C_VARIABLE:
+               case ICElement.C_VARIABLE_DECLARATION:
+                       return true;
+               }
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CalledByResult.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CalledByResult.java
new file mode 100644 (file)
index 0000000..d649f34
--- /dev/null
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.callhierarchy;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.core.model.ICElement;
+
+public class CalledByResult {
+       private Map<ICElement, List<IIndexName>> fElementToReferences= new HashMap<ICElement, List<IIndexName>>();
+
+       public ICElement[] getElements() {
+               Set<ICElement> elements = fElementToReferences.keySet();
+               return elements.toArray(new ICElement[elements.size()]);
+       }
+       
+       public IIndexName[] getReferences(ICElement calledElement) {
+               List<IIndexName> references= fElementToReferences.get(calledElement);
+               return references.toArray(new IIndexName[references.size()]);
+       }
+
+       public void add(ICElement elem, IIndexName ref) {
+               List<IIndexName> list= fElementToReferences.get(elem);
+               if (list == null) {
+                       list= new ArrayList<IIndexName>();
+                       fElementToReferences.put(elem, list);
+               }
+               list.add(ref);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallsToResult.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallsToResult.java
new file mode 100644 (file)
index 0000000..c61ee02
--- /dev/null
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.callhierarchy;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.core.model.ICElement;
+
+public class CallsToResult {
+       private Map<CElementSet, List<IIndexName>> fElementSetsToReferences= new HashMap<CElementSet, List<IIndexName>>();
+
+       public CElementSet[] getElementSets() {
+               Set<CElementSet> elementSets = fElementSetsToReferences.keySet();
+               return elementSets.toArray(new CElementSet[elementSets.size()]);
+       }
+       
+       public IIndexName[] getReferences(CElementSet elementSet) {
+               List<IIndexName> references= fElementSetsToReferences.get(elementSet);
+               return references.toArray(new IIndexName[references.size()]);
+       }
+
+       public void add(ICElement[] elems, IIndexName ref) {
+               CElementSet key= new CElementSet(elems);
+               List<IIndexName> list= fElementSetsToReferences.get(key);
+               if (list == null) {
+                       list= new ArrayList<IIndexName>();
+                       fElementSetsToReferences.put(key, list);
+               }
+               list.add(ref);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/OpenCallHierarchyAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/OpenCallHierarchyAction.java
new file mode 100644 (file)
index 0000000..b6f5bec
--- /dev/null
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.callhierarchy;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IEnumeration;
+import org.eclipse.cdt.core.model.IEnumerator;
+import org.eclipse.cdt.core.model.IFunctionDeclaration;
+import org.eclipse.cdt.core.model.IVariableDeclaration;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.actions.SelectionDispatchAction;
+
+
+public class OpenCallHierarchyAction extends SelectionDispatchAction {
+
+       private ITextEditor fEditor;
+
+       public OpenCallHierarchyAction(IWorkbenchSite site) {
+               super(site);
+               setText(CHMessages.OpenCallHierarchyAction_label);
+               setToolTipText(CHMessages.OpenCallHierarchyAction_tooltip);
+       }
+       
+       public OpenCallHierarchyAction(ITextEditor editor) {
+               this(editor.getSite());
+               fEditor= editor;
+               setEnabled(fEditor != null && CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput()) != null);
+       }
+
+       @Override
+       public void run(ITextSelection sel) {
+               CallHierarchyUI.open(fEditor, sel);
+       }
+       
+       @Override
+       public void run(IStructuredSelection selection) {
+               if (!selection.isEmpty()) {
+                       Object selectedObject= selection.getFirstElement();
+                       ICElement elem= (ICElement) getAdapter(selectedObject, ICElement.class);
+                       if (elem != null) {
+                               CallHierarchyUI.open(getSite().getWorkbenchWindow(), elem);
+                       }
+               }
+       }
+
+       @Override
+       public void selectionChanged(ITextSelection sel) {
+       }
+                       
+       @Override
+       public void selectionChanged(IStructuredSelection selection) {
+               if (selection.isEmpty()) {
+                       setEnabled(false);
+                       return;
+               }
+               
+               Object selectedObject= selection.getFirstElement();
+               ICElement elem= (ICElement) getAdapter(selectedObject, ICElement.class);
+               if (elem != null) {
+                       setEnabled(isValidElement(elem));
+               }
+               else {
+                       setEnabled(false);
+               }
+       }
+
+       private boolean isValidElement(ICElement elem) {
+               if (elem instanceof IFunctionDeclaration) {
+                       return true;
+               }
+               if (elem instanceof IVariableDeclaration) {
+                       return !(elem instanceof IEnumeration);
+               }
+               if (elem instanceof IEnumerator) {
+                       return true;
+               }
+               return false;
+       }
+
+       @SuppressWarnings("rawtypes")
+       private Object getAdapter(Object object, Class desiredClass) {
+               if (desiredClass.isInstance(object)) {
+                       return object;
+               }
+               if (object instanceof IAdaptable) {
+                       IAdaptable adaptable= (IAdaptable) object;
+                       return adaptable.getAdapter(desiredClass);
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/OpenElementInCallHierarchyAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/OpenElementInCallHierarchyAction.java
new file mode 100644 (file)
index 0000000..5fa962e
--- /dev/null
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.callhierarchy;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.browser.ITypeInfo;
+import org.eclipse.cdt.core.browser.ITypeReference;
+import org.eclipse.cdt.core.model.ICElement;
+
+import org.eclipse.cdt.internal.ui.browser.opentype.ElementSelectionDialog;
+
+public class OpenElementInCallHierarchyAction implements IWorkbenchWindowActionDelegate {
+
+       private static final int[] VISIBLE_TYPES = { 
+               ICElement.C_FUNCTION, ICElement.C_METHOD, ICElement.C_VARIABLE, ICElement.C_ENUMERATOR,
+               ICElement.C_FUNCTION_DECLARATION, ICElement.C_METHOD_DECLARATION, ICElement.C_VARIABLE_DECLARATION };
+       
+       private IWorkbenchWindow fWorkbenchWindow;
+
+       public OpenElementInCallHierarchyAction() {
+       }
+
+       public void run(IAction action) {
+               ElementSelectionDialog dialog = new ElementSelectionDialog(getShell());
+               configureDialog(dialog);
+               int result = dialog.open();
+               if (result != IDialogConstants.OK_ID)
+                       return;
+               
+               ITypeInfo info = (ITypeInfo) dialog.getFirstResult();
+               if (info == null)
+                       return;
+               
+               ICElement[] elements= null;
+               ITypeReference location = info.getResolvedReference();
+               if (location != null) {
+                       elements= location.getCElements();
+               }
+               if (elements == null || elements.length == 0) {
+                       String title = CHMessages.OpenElementInCallHierarchyAction_errorDlgTitle;
+                       String message = NLS.bind(CHMessages.OpenElementInCallHierarchyAction_errorNoDefinition, info.getQualifiedTypeName().toString());
+                       MessageDialog.openError(getShell(), title, message);
+               } 
+               else {
+                       CallHierarchyUI.open(fWorkbenchWindow, elements[0]);
+               }
+       }
+       
+       private void configureDialog(ElementSelectionDialog dialog) {
+               dialog.setDialogSettings(getClass().getName());
+               dialog.setVisibleTypes(VISIBLE_TYPES);
+               dialog.setTitle(CHMessages.OpenElementInCallHierarchyAction_title);
+               dialog.setUpperListLabel(CHMessages.OpenElementInCallHierarchyAction_upperListLabel);
+               dialog.setMessage(CHMessages.OpenElementInCallHierarchyAction_message);
+
+               if (fWorkbenchWindow != null) {
+                       IWorkbenchPage page= fWorkbenchWindow.getActivePage();
+                       if (page != null) {
+                               IWorkbenchPart part= page.getActivePart();
+                               if (part instanceof ITextEditor) {
+                                       ISelection sel= ((ITextEditor) part).getSelectionProvider().getSelection();
+                                       if (sel instanceof ITextSelection) {
+                                               String txt= ((ITextSelection) sel).getText();
+                                               if (txt.length() > 0 && txt.length() < 80) {
+                                                       dialog.setFilter(txt, true);
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+
+       private Shell getShell() {
+               return fWorkbenchWindow.getShell();
+       }
+
+       public void dispose() {
+               fWorkbenchWindow= null;
+       }
+       
+       public void init(IWorkbenchWindow window) {
+               fWorkbenchWindow= window;
+       }
+       
+       public void selectionChanged(IAction action, ISelection selection) {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/ReferenceVisitor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/ReferenceVisitor.java
new file mode 100644 (file)
index 0000000..3b1dcc3
--- /dev/null
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.callhierarchy;
+
+import java.util.ArrayList;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+
+/**
+ * Visitor to find references in a given range of the source code.
+ * @since 4.0
+ */
+class ReferenceVisitor extends ASTVisitor {
+       private ArrayList<IASTName> fReferences= new ArrayList<IASTName>();
+       private int fOffset;
+       private int fEndOffset;
+       private String fFileName;
+       
+       ReferenceVisitor(String fileName, int offset, int length) {
+               shouldVisitNames= true;
+               shouldVisitDeclarations= true;
+               
+               fFileName= fileName;
+               fOffset= offset;
+               fEndOffset= offset+length;
+       }
+       
+       public IASTName[] getReferences() {
+               return fReferences.toArray(new IASTName[fReferences.size()]);
+       }
+
+       @Override
+       public int visit(IASTName name) {
+               if (name.isReference()) {
+                       IASTFileLocation loc= name.getFileLocation();
+                       if (!loc.getFileName().equals(fFileName)) {
+                               return PROCESS_SKIP;
+                       }
+                       int offset= loc.getNodeOffset();
+                       if (fOffset <= offset && offset+loc.getNodeLength() <= fEndOffset) {
+                               fReferences.add(name);
+                       }
+               }
+               return super.visit(name);
+       }
+
+       @Override
+       public int visit(IASTDeclaration declaration) {
+               IASTFileLocation loc= declaration.getFileLocation();
+               if (loc != null) {
+                       if (!loc.getFileName().equals(fFileName)) {
+                               return PROCESS_SKIP;
+                       }
+                       int offset= loc.getNodeOffset();
+                       if (offset + loc.getNodeLength() <= fOffset || fEndOffset <= offset) {
+                               return PROCESS_SKIP;
+                       }
+               }
+               return PROCESS_CONTINUE;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AbstractMergeViewer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AbstractMergeViewer.java
new file mode 100644 (file)
index 0000000..fbcfeb3
--- /dev/null
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *     Andrew Ferguson (Symbian)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.compare;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.contentmergeviewer.TextMergeViewer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.text.TextViewer;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.texteditor.AbstractTextEditor;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.ICColorConstants;
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+
+/**
+ * Abstract implementation of a merge viewer.
+ */
+abstract class AbstractMergeViewer extends TextMergeViewer {
+
+       private IPropertyChangeListener fPreferenceChangeListener;
+       private IPreferenceStore fPreferenceStore;
+
+       protected boolean fUseSystemColors;
+
+       /**
+        * Creates a color from the information stored in the given preference store.
+        * Returns <code>null</code> if there is no such information available.
+        */
+       protected static RGB createColor(IPreferenceStore store, String key) {
+               if (!store.contains(key))
+                       return null;
+               if (store.isDefault(key))
+                       return PreferenceConverter.getDefaultColor(store, key);
+               return PreferenceConverter.getColor(store, key);
+       }
+
+       /**
+        * Create a new merge viewer.
+        * 
+        * @param parent
+        * @param style
+        * @param configuration
+        */
+       public AbstractMergeViewer(Composite parent, int style, CompareConfiguration configuration) {
+               super(parent, style | SWT.LEFT_TO_RIGHT, configuration);
+
+               IPreferenceStore store = getPreferenceStore();
+
+               fUseSystemColors= store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT);
+               if (! fUseSystemColors) {
+                       RGB bg= createColor(store, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
+                       setBackgroundColor(bg);
+                       RGB fg= createColor(store, ICColorConstants.C_DEFAULT);
+                       setForegroundColor(fg);
+               }
+
+       }
+
+       protected IPreferenceStore getPreferenceStore() {
+               if (fPreferenceStore == null) {
+                       fPreferenceStore= CUIPlugin.getDefault().getCombinedPreferenceStore();
+                       fPreferenceChangeListener= new IPropertyChangeListener() {
+                               public void propertyChange(PropertyChangeEvent event) {
+                                       handlePropertyChange(event);
+                               }
+                       };
+                       fPreferenceStore.addPropertyChangeListener(fPreferenceChangeListener);
+               }
+               return fPreferenceStore;
+       }
+
+       @Override
+       protected void handleDispose(DisposeEvent event) {
+               if (fPreferenceChangeListener != null) {
+                       fPreferenceStore.removePropertyChangeListener(fPreferenceChangeListener);
+                       fPreferenceChangeListener= null;
+               }
+               super.handleDispose(event);
+       }
+
+       protected void handlePropertyChange(PropertyChangeEvent event) {
+               
+               String key= event.getProperty();
+               
+               if (key.equals(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND)) {
+       
+                       if (!fUseSystemColors) {
+                               RGB bg= createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
+                               setBackgroundColor(bg);
+                       }
+                                               
+               } else if (key.equals(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)) {
+       
+                       fUseSystemColors= fPreferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT);
+                       if (fUseSystemColors) {
+                               setBackgroundColor(null);
+                               setForegroundColor(null);
+                       } else {
+                               RGB bg= createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
+                               setBackgroundColor(bg);
+                               RGB fg= createColor(fPreferenceStore, ICColorConstants.C_DEFAULT);
+                               setForegroundColor(fg);
+                       }
+               } else if (key.equals(ICColorConstants.C_DEFAULT)) {
+       
+                       if (!fUseSystemColors) {
+                               RGB fg= createColor(fPreferenceStore, ICColorConstants.C_DEFAULT);
+                               setForegroundColor(fg);
+                       }
+               }
+       }
+
+       @Override
+       protected String getDocumentPartitioning() {
+               return ICPartitions.C_PARTITIONING;
+       }
+
+       @Override
+       protected void configureTextViewer(TextViewer textViewer) {
+               if (textViewer instanceof SourceViewer) {
+                       ((SourceViewer)textViewer).configure(getSourceViewerConfiguration());
+               }
+       }
+
+       /*
+        * @see org.eclipse.compare.contentmergeviewer.ContentMergeViewer#getTitle()
+        */
+       @Override
+       public abstract String getTitle();
+
+       /**
+        * @return a source configuration for the viewer
+        */
+       protected abstract SourceViewerConfiguration getSourceViewerConfiguration();
+
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AsmContentViewerCreator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AsmContentViewerCreator.java
new file mode 100644 (file)
index 0000000..243627e
--- /dev/null
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.compare;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.IViewerCreator;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Creates a merge viewer for assembly code.
+ */
+public class AsmContentViewerCreator  implements IViewerCreator {
+
+       /*
+        * @see org.eclipse.compare.IViewerCreator#createViewer(org.eclipse.swt.widgets.Composite, org.eclipse.compare.CompareConfiguration)
+        */
+       public Viewer createViewer(Composite parent, CompareConfiguration config) {
+               return new AsmMergeViewer(parent, SWT.NULL, config);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AsmMergeViewer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AsmMergeViewer.java
new file mode 100644 (file)
index 0000000..9321468
--- /dev/null
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.compare;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.widgets.Composite;
+
+import org.eclipse.cdt.ui.CDTUITools;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.AsmSourceViewerConfiguration;
+import org.eclipse.cdt.ui.text.ICPartitions;
+import org.eclipse.cdt.ui.text.IColorManager;
+
+/**
+ * A merge viewer for assembly code.
+ */
+public class AsmMergeViewer extends AbstractMergeViewer {
+
+       private static final String TITLE= "AsmMergeViewer.title"; //$NON-NLS-1$
+
+       AsmSourceViewerConfiguration fSourceViewerConfiguration;
+
+       /**
+        * Create a new assembly merge viewer.
+        * 
+        * @param parent
+        * @param style
+        * @param configuration
+        */
+       public AsmMergeViewer(Composite parent, int style, CompareConfiguration configuration) {
+               super(parent, style, configuration);
+       }
+
+       @Override
+       protected SourceViewerConfiguration getSourceViewerConfiguration() {
+               if (fSourceViewerConfiguration == null) {
+                       IPreferenceStore store= getPreferenceStore();
+                       final IColorManager colorManager = CDTUITools.getColorManager();
+                       fSourceViewerConfiguration= new AsmSourceViewerConfiguration(colorManager, store, null, ICPartitions.C_PARTITIONING);
+               }
+               return fSourceViewerConfiguration;
+       }
+
+       @Override
+       public String getTitle() {
+               return CUIPlugin.getResourceString(TITLE);
+       }
+
+       @Override
+       protected IDocumentPartitioner getDocumentPartitioner() {
+               return CDTUITools.createAsmDocumentPartitioner();
+       }
+
+       @Override
+       protected void handlePropertyChange(PropertyChangeEvent event) {
+               super.handlePropertyChange(event);
+
+               if (fSourceViewerConfiguration != null && fSourceViewerConfiguration.affectsTextPresentation(event)) {
+                       fSourceViewerConfiguration.handlePropertyChangeEvent(event);
+                       invalidateTextPresentation();
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CContentViewerCreator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CContentViewerCreator.java
new file mode 100644 (file)
index 0000000..9e24f2f
--- /dev/null
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.compare;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.IViewerCreator;
+
+
+import org.eclipse.jface.viewers.Viewer;
+
+
+/**
+ * Required when creating a CMergeViewer from the plugin.xml file.
+ */
+public class CContentViewerCreator implements IViewerCreator {
+       
+       public Viewer createViewer(Composite parent, CompareConfiguration mp) {
+               return new CMergeViewer(parent, SWT.NULL, mp);
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CMergeViewer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CMergeViewer.java
new file mode 100644 (file)
index 0000000..0068174
--- /dev/null
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ *  Copyright (c) 2005, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.compare;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.widgets.Composite;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.CSourceViewerConfiguration;
+import org.eclipse.cdt.ui.text.ICPartitions;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
+
+import org.eclipse.cdt.internal.ui.text.CTextTools;
+import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
+
+/**
+ * A merge viewer for C/C++ code.
+ */
+public class CMergeViewer extends AbstractMergeViewer {
+       
+       private static final String TITLE= "CMergeViewer.title"; //$NON-NLS-1$
+
+       CSourceViewerConfiguration fSourceViewerConfiguration;
+               
+       public CMergeViewer(Composite parent, int styles, CompareConfiguration mp) {
+               super(parent, styles, mp);
+       }
+
+       @Override
+       protected SourceViewerConfiguration getSourceViewerConfiguration() {
+               if (fSourceViewerConfiguration == null) {
+                       CTextTools tools= CUIPlugin.getDefault().getTextTools();
+                       IPreferenceStore store = getPreferenceStore();
+                       fSourceViewerConfiguration = new CSourceViewerConfiguration(tools.getColorManager(), store, null, ICPartitions.C_PARTITIONING);
+               }
+               return fSourceViewerConfiguration;
+       }
+
+       @Override
+       protected IDocumentPartitioner getDocumentPartitioner() {
+               // use workspace default for highlighting doc comments in compare viewer
+               IDocCommentOwner owner= DocCommentOwnerManager.getInstance().getWorkspaceCommentOwner();
+               return CUIPlugin.getDefault().getTextTools().createDocumentPartitioner(owner);
+       }
+
+       @Override
+       public String getTitle() {
+               return CUIPlugin.getResourceString(TITLE);
+       }
+
+       @Override
+       protected void handlePropertyChange(PropertyChangeEvent event) {
+               super.handlePropertyChange(event);
+
+               if (fSourceViewerConfiguration != null && fSourceViewerConfiguration.affectsTextPresentation(event)) {
+                       fSourceViewerConfiguration.handlePropertyChangeEvent(event);
+                       invalidateTextPresentation();
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CNode.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CNode.java
new file mode 100644 (file)
index 0000000..434cff3
--- /dev/null
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.compare;
+
+import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.compare.structuremergeviewer.DocumentRangeNode;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * 
+ */
+class CNode extends DocumentRangeNode implements ITypedElement {
+
+       public CNode(DocumentRangeNode parent, int type, String id, IDocument doc, int start, int length) {
+               super(parent, type, id, doc, start, length);
+               if (parent != null) {
+                       parent.addChild(this);
+               }
+       }
+
+       public CNode(DocumentRangeNode parent, int type, String id, int start, int length) {
+               this(parent, type, id, parent.getDocument(), start, length);
+       }
+
+       public String getName() {
+               return getId();
+       }
+
+       public String getType() {
+               return "c2"; //$NON-NLS-1$
+       }
+
+       public Image getImage() {
+               ImageDescriptor descriptor = CElementImageProvider.getImageDescriptor(getTypeCode());
+               return CUIPlugin.getImageDescriptorRegistry().get(descriptor);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreator.java
new file mode 100644 (file)
index 0000000..8ae775f
--- /dev/null
@@ -0,0 +1,212 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *     Andrew Ferguson (Symbian)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.compare;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import org.eclipse.compare.IEncodedStreamContentAccessor;
+import org.eclipse.compare.ISharedDocumentAdapter;
+import org.eclipse.compare.IStreamContentAccessor;
+import org.eclipse.compare.ResourceNode;
+import org.eclipse.compare.contentmergeviewer.IDocumentRange;
+import org.eclipse.compare.structuremergeviewer.DocumentRangeNode;
+import org.eclipse.compare.structuremergeviewer.IStructureComparator;
+import org.eclipse.compare.structuremergeviewer.StructureCreator;
+import org.eclipse.compare.structuremergeviewer.StructureRootNode;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.jface.text.Position;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.parser.FileContent;
+import org.eclipse.cdt.core.parser.IScannerInfo;
+import org.eclipse.cdt.core.parser.IncludeFileContentProvider;
+import org.eclipse.cdt.core.parser.ParserUtil;
+import org.eclipse.cdt.core.parser.ScannerInfo;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.ICPartitions;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
+
+import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
+
+/**
+ * A structure creator for C/C++ translation units.
+ */
+public class CStructureCreator extends StructureCreator {
+
+       private static final String NAME = "CStructureCreator.name"; //$NON-NLS-1$
+
+       public CStructureCreator() {
+       }
+
+       public String getName() {
+               return CUIPlugin.getResourceString(NAME);
+       }
+
+       /*
+        * @see IStructureCreator#getContents
+        */
+       public String getContents(Object node, boolean ignoreWhitespace) {
+               if (node instanceof IDocumentRange) {
+                       IDocumentRange documentRange= (IDocumentRange)node;
+                       final Position range = documentRange.getRange();
+                       try {
+                               return documentRange.getDocument().get(range.getOffset(), range.getLength());
+                       } catch (BadLocationException exc) {
+                       }
+               }
+               if (node instanceof IStreamContentAccessor) {
+                       IStreamContentAccessor sca = (IStreamContentAccessor) node;
+                       try {
+                               return readString(sca);
+                       } catch (CoreException ex) {
+                       }
+               }
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.compare.structuremergeviewer.StructureCreator#createStructureComparator(java.lang.Object, org.eclipse.jface.text.IDocument, org.eclipse.compare.ISharedDocumentAdapter, org.eclipse.core.runtime.IProgressMonitor)
+        */
+       @Override
+       protected IStructureComparator createStructureComparator(Object element,
+                       IDocument document, ISharedDocumentAdapter sharedDocumentAdapter,
+                       IProgressMonitor monitor) throws CoreException {
+
+               DocumentRangeNode root= new StructureRootNode(document, element, this, sharedDocumentAdapter);
+
+               // don't follow inclusions
+               IncludeFileContentProvider contentProvider = IncludeFileContentProvider.getEmptyFilesProvider();
+               
+               // empty scanner info
+               IScannerInfo scanInfo= new ScannerInfo();
+               
+               FileContent content = FileContent.create("<text>", document.get().toCharArray()); //$NON-NLS-1$
+               
+               // determine the language
+               boolean isSource[]= {false};
+               ILanguage language= determineLanguage(element, isSource);
+               
+               try {
+                       IASTTranslationUnit ast;
+                       int options= isSource[0] ? ILanguage.OPTION_IS_SOURCE_UNIT : 0;
+                       ast= language.getASTTranslationUnit(content, scanInfo, contentProvider, null, options, ParserUtil.getParserLogService());
+                       CStructureCreatorVisitor structureCreator= new CStructureCreatorVisitor(root);
+                       // build structure
+                       ast.accept(structureCreator);
+               } catch (CoreException exc) {
+                       CUIPlugin.log(exc);
+               }
+
+               return root;
+       }
+
+       /**
+        * Try to determine the <code>ILanguage</code> for the given input element.
+        * 
+        * @param element
+        * @return a language instance
+        */
+       private ILanguage determineLanguage(Object element, boolean[] isSource) {
+               ILanguage language= null;
+               if (element instanceof ResourceNode) {
+                       IResource resource= ((ResourceNode)element).getResource();
+                       if (resource.getType() == IResource.FILE) {
+                               ITranslationUnit tUnit= (ITranslationUnit)CoreModel.getDefault().create(resource);
+                               if (tUnit != null) {
+                                       try {
+                                               language= tUnit.getLanguage();
+                                               isSource[0]= tUnit.isSourceUnit();
+                                       } catch (CoreException exc) {
+                                               // silently ignored
+                                       }
+                               }
+                       }
+               }
+               if (language == null) {
+                       language= GPPLanguage.getDefault();
+               }
+               return language;
+       }
+
+       @Override
+       protected String getDocumentPartitioning() {
+               return ICPartitions.C_PARTITIONING;
+       }
+       
+       @Override
+       protected IDocumentPartitioner getDocumentPartitioner() {
+               // use workspace default for highlighting doc comments in compare viewer
+               IDocCommentOwner owner= DocCommentOwnerManager.getInstance().getWorkspaceCommentOwner();
+               return CUIPlugin.getDefault().getTextTools().createDocumentPartitioner(owner);
+       }
+       
+       private static String readString(IStreamContentAccessor sa) throws CoreException {
+               InputStream is= sa.getContents();
+               if (is != null) {
+                       String encoding= null;
+                       if (sa instanceof IEncodedStreamContentAccessor) {
+                               try {
+                                       encoding= ((IEncodedStreamContentAccessor) sa).getCharset();
+                               } catch (Exception e) {
+                               }
+                       }
+                       if (encoding == null)
+                               encoding= ResourcesPlugin.getEncoding();
+                       return readString(is, encoding);
+               }
+               return null;
+       }
+
+       private static String readString(InputStream is, String encoding) {
+               if (is == null)
+                       return null;
+               BufferedReader reader= null;
+               try {
+                       StringBuffer buffer= new StringBuffer();
+                       char[] part= new char[2048];
+                       int read= 0;
+                       reader= new BufferedReader(new InputStreamReader(is, encoding));
+
+                       while ((read= reader.read(part)) != -1)
+                               buffer.append(part, 0, read);
+                       
+                       return buffer.toString();
+                       
+               } catch (IOException ex) {
+                       // NeedWork
+               } finally {
+                       if (reader != null) {
+                               try {
+                                       reader.close();
+                               } catch (IOException ex) {
+                                       // silently ignored
+                               }
+                       }
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreatorVisitor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreatorVisitor.java
new file mode 100644 (file)
index 0000000..a12e512
--- /dev/null
@@ -0,0 +1,534 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.compare;
+
+import java.util.Stack;
+
+import org.eclipse.compare.structuremergeviewer.DocumentRangeNode;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Position;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceAlias;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateSpecialization;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
+import org.eclipse.cdt.core.model.ICElement;
+
+import org.eclipse.cdt.internal.core.model.ASTStringUtil;
+import org.eclipse.cdt.internal.core.model.CoreModelMessages;
+
+import org.eclipse.cdt.internal.ui.CUIMessages;
+
+/**
+ * AST visitor to create compare structure.
+ *
+ * @since 5.0
+ */
+class CStructureCreatorVisitor extends ASTVisitor {
+
+       private static final String TRANSLATION_UNIT_NAME = CUIMessages.CStructureCreatorVisitor_translationUnitName; 
+       private static final String ANONYMOUS_NAME= CoreModelMessages.getString("CElementLabels.anonymous"); //$NON-NLS-1$
+       
+       private Stack<DocumentRangeNode> fStack = new Stack<DocumentRangeNode>();
+       private IDocument fDocument;
+       private String fTranslationUnitFileName;
+
+       /**
+        * Create visitor adding nodes to given root.
+        * 
+        * @param root
+        */
+       public CStructureCreatorVisitor(DocumentRangeNode root) {
+               fDocument = root.getDocument();
+               fStack.clear();
+               fStack.push(root);
+               // visitor options
+               shouldVisitTranslationUnit= true;
+               shouldVisitDeclarations= true;
+               shouldVisitEnumerators=true;
+               shouldVisitNamespaces=true;
+       }
+
+       /*
+        * @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTTranslationUnit)
+        */
+       @Override
+       public int visit(IASTTranslationUnit tu) {
+               fTranslationUnitFileName= tu.getFilePath();
+
+               push(ICElement.C_UNIT, TRANSLATION_UNIT_NAME, 0);
+
+               // TODO fix ordering of includes and macros 
+               // includes
+               final IASTPreprocessorIncludeStatement[] includeDirectives= tu.getIncludeDirectives();
+               for (int i= 0; i < includeDirectives.length; i++) {
+                       IASTPreprocessorIncludeStatement includeDirective= includeDirectives[i];
+                       if (isLocalToFile(includeDirective)) {
+                               push(ICElement.C_INCLUDE, new String(includeDirective.getName().toCharArray()), getStartOffset(includeDirective));
+                               pop(getEndOffset(includeDirective));
+                       }
+               }
+               // macros
+               final IASTPreprocessorMacroDefinition[] macroDefinitions= tu.getMacroDefinitions();
+               for (int i= 0; i < macroDefinitions.length; i++) {
+                       IASTPreprocessorMacroDefinition macroDefinition= macroDefinitions[i];
+                       if (isLocalToFile(macroDefinition)) {
+                               push(ICElement.C_MACRO, new String(macroDefinition.getName().toCharArray()), getStartOffset(macroDefinition));
+                               pop(getEndOffset(macroDefinition));
+                       }
+               }
+               
+               return super.visit(tu);
+       }
+
+       /**
+        * Test whether given AST node is local to the source file 
+        * and not part of an inclusion.
+        * 
+        * @param node
+        * @return <code>true</code> if the node is part of the source file.
+        */
+       private boolean isLocalToFile(IASTNode node) {
+               return fTranslationUnitFileName.equals(node.getContainingFilename());
+       }
+
+       /**
+        * Compute the start offset of given AST node.
+        * 
+        * @param node
+        * @return
+        */
+       private int getStartOffset(IASTNode node) {
+               IASTFileLocation fileLocation= getMinFileLocation(node.getNodeLocations());
+               if (fileLocation != null) {
+                       return fileLocation.getNodeOffset();
+               }
+               DocumentRangeNode container= getCurrentContainer();
+               Object[] children= container.getChildren();
+               if (children != null && children.length > 0) {
+                       Position prevRange= ((DocumentRangeNode)children[children.length - 1]).getRange();
+                       return prevRange.getOffset() + prevRange.getLength();
+               }
+               // fallback: use container range start
+               Position containerRange= container.getRange();
+               return containerRange.getOffset();
+       }
+
+       /**
+        * Compute the end offset of give AST node.
+        * 
+        * @param node
+        * @return
+        */
+       private int getEndOffset(IASTNode node) {
+               IASTFileLocation fileLocation= getMaxFileLocation(node.getNodeLocations());
+               if (fileLocation != null) {
+                       return fileLocation.getNodeOffset() + fileLocation.getNodeLength();
+               }
+               // fallback: use container range end
+               DocumentRangeNode container= getCurrentContainer();
+               Position containerRange= container.getRange();
+               return containerRange.getOffset() + containerRange.getLength();
+       }
+
+/*
+        * @see org.eclipse.cdt.core.dom.ast.ASTVisitor#leave(org.eclipse.cdt.core.dom.ast.IASTTranslationUnit)
+        */
+       @Override
+       public int leave(IASTTranslationUnit tu) {
+               super.leave(tu);
+               assert getCurrentContainer().getTypeCode() == ICElement.C_UNIT;
+               pop(fDocument.getLength());
+               return PROCESS_SKIP;
+       }
+       
+       /*
+        * @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTDeclaration)
+        */
+       @Override
+       public int visit(IASTDeclaration node) {
+               boolean isTemplateDecl= isTemplateDecl(node);
+               final int startOffset= isTemplateDecl ? getStartOffset(node.getParent()) : getStartOffset(node);
+               final int endOffset= getEndOffset(node);
+               if (node instanceof IASTFunctionDefinition) {
+                       IASTFunctionDefinition functionDef= (IASTFunctionDefinition)node;
+                       final int nodeType;
+                       if (inClassBody()) {
+                               nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_METHOD : ICElement.C_METHOD;
+                       } else {
+                               nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_FUNCTION : ICElement.C_FUNCTION;
+                       }
+                       push(nodeType, getDeclaratorName(functionDef.getDeclarator()), startOffset);
+                       pop(endOffset);
+                       return PROCESS_SKIP;
+               } else if (node instanceof IASTSimpleDeclaration) {
+                       IASTSimpleDeclaration simpleDecl= (IASTSimpleDeclaration)node;
+                       IASTDeclSpecifier declSpec= simpleDecl.getDeclSpecifier();
+                       if (declSpec instanceof ICPPASTCompositeTypeSpecifier) {
+                               ICPPASTCompositeTypeSpecifier compositeTypeSpec= (ICPPASTCompositeTypeSpecifier)declSpec;
+                               final String nodeName= getTypeName(compositeTypeSpec);
+                               final int nodeType;
+                               switch (compositeTypeSpec.getKey()) {
+                               case IASTCompositeTypeSpecifier.k_struct:
+                                       nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_STRUCT : ICElement.C_STRUCT;
+                                       break;
+                               case IASTCompositeTypeSpecifier.k_union:
+                                       nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_UNION : ICElement.C_UNION;
+                                       break;
+                               case ICPPASTCompositeTypeSpecifier.k_class:
+                                       nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_CLASS : ICElement.C_CLASS;
+                                       break;
+                               default:
+                                       assert false : "Unexpected composite type specifier"; //$NON-NLS-1$
+                                       return PROCESS_CONTINUE;
+                               }
+                               push(nodeType, nodeName, startOffset);
+                       } else if (declSpec instanceof IASTEnumerationSpecifier) {
+                               IASTEnumerationSpecifier enumSpecifier= (IASTEnumerationSpecifier)declSpec;
+                               push(ICElement.C_ENUMERATION, getEnumerationName(enumSpecifier), startOffset);
+                       } else {
+                               IASTDeclarator[] declarators= simpleDecl.getDeclarators();
+                               for (int i = 0; i < declarators.length; i++) {
+                                       IASTDeclarator declarator= declarators[i];
+                                       int declStartOffset= declarators.length == 1 ? startOffset : getStartOffset(declarator);
+                                       int declEndOffset= declarators.length == 1 ? endOffset : getEndOffset(declarator);
+                                       final String nodeName = getDeclaratorName(declarator);
+                                       if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_typedef) {
+                                               push(ICElement.C_TYPEDEF, nodeName, declStartOffset);
+                                               pop(declEndOffset);
+                                       } else if (declarator instanceof IASTFunctionDeclarator && !hasNestedPointerOperators(declarator)) {
+                                               final int nodeType;
+                                               if (inClassBody()) {
+                                                       nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_METHOD_DECLARATION : ICElement.C_METHOD_DECLARATION;
+                                               } else {
+                                                       nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_FUNCTION_DECLARATION : ICElement.C_FUNCTION_DECLARATION;
+                                               }
+                                               push(nodeType, nodeName, declStartOffset);
+                                               pop(declEndOffset);
+                                       } else if (declarator != null) {
+                                               final int nodeType;
+                                               if (inClassBody()) {
+                                                       nodeType= ICElement.C_FIELD;
+                                               } else {
+                                                       if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_extern) {
+                                                               nodeType= ICElement.C_VARIABLE_DECLARATION;
+                                                       } else {
+                                                               nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_VARIABLE : ICElement.C_VARIABLE;
+                                                       }
+                                               }
+                                               push(nodeType, nodeName, declStartOffset);
+                                               pop(declEndOffset);
+                                       }
+                               }
+                       }
+               } else if (node instanceof IASTASMDeclaration) {
+                       // ignored
+               } else if (node instanceof ICPPASTVisibilityLabel) {
+                       // ignored
+               } else if (node instanceof ICPPASTNamespaceDefinition) {
+                       // handled below
+               } else if (node instanceof ICPPASTNamespaceAlias) {
+                       // ignored
+               } else if (node instanceof ICPPASTUsingDeclaration) {
+                       ICPPASTUsingDeclaration usingDecl= (ICPPASTUsingDeclaration)node;
+                       push(ICElement.C_USING, ASTStringUtil.getQualifiedName(usingDecl.getName()), startOffset);
+                       pop(endOffset);
+               } else if (node instanceof ICPPASTUsingDirective) {
+                       ICPPASTUsingDirective usingDirective= (ICPPASTUsingDirective)node;
+                       push(ICElement.C_USING, ASTStringUtil.getQualifiedName(usingDirective.getQualifiedName()), startOffset);
+                       pop(endOffset);
+               } else if (node instanceof ICPPASTLinkageSpecification) {
+                       // declarations get flattened
+               } else if (node instanceof ICPPASTTemplateDeclaration) {
+                       // handled at child declaration level
+               } else if (node instanceof ICPPASTTemplateSpecialization) {
+                       // ignored
+               } else if (node instanceof ICPPASTExplicitTemplateInstantiation) {
+                       // ignored
+               } else if (node instanceof IASTProblemDeclaration) {
+                       // ignored
+               }
+               return super.visit(node);
+       }
+
+       /*
+        * @see org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor#visit(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition)
+        */
+       @Override
+       public int visit(ICPPASTNamespaceDefinition namespace) {
+               push(ICElement.C_NAMESPACE, ASTStringUtil.getQualifiedName(namespace.getName()), getStartOffset(namespace));
+               return super.visit(namespace);
+       }
+
+       /*
+        * @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator)
+        */
+       @Override
+       public int visit(IASTEnumerator enumerator) {
+               push(ICElement.C_ENUMERATOR, ASTStringUtil.getQualifiedName(enumerator.getName()), getStartOffset(enumerator));
+               pop(getEndOffset(enumerator));
+               return super.visit(enumerator);
+       }
+       
+       /*
+        * @see org.eclipse.cdt.core.dom.ast.ASTVisitor#leave(org.eclipse.cdt.core.dom.ast.IASTDeclaration)
+        */
+       @Override
+       public int leave(IASTDeclaration node) {
+               super.leave(node);
+               boolean isTemplateDecl= isTemplateDecl(node);
+               final int endOffset= isTemplateDecl ? getEndOffset(node.getParent()) : getEndOffset(node);
+               if (node instanceof IASTFunctionDefinition) {
+                       final int nodeType;
+                       if (inClassBody()) {
+                               nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_METHOD : ICElement.C_METHOD;
+                       } else {
+                               nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_FUNCTION : ICElement.C_FUNCTION;
+                       }
+                       assert getCurrentContainer().getTypeCode() == nodeType;
+                       pop(endOffset);
+               } else if (node instanceof IASTSimpleDeclaration) {
+                       IASTSimpleDeclaration simpleDecl= (IASTSimpleDeclaration)node;
+                       IASTDeclSpecifier declSpec= simpleDecl.getDeclSpecifier();
+                       boolean isCompositeType= false;
+                       if (declSpec instanceof ICPPASTCompositeTypeSpecifier) {
+                               isCompositeType= true;
+                               ICPPASTCompositeTypeSpecifier compositeTypeSpec= (ICPPASTCompositeTypeSpecifier)declSpec;
+                               final int nodeType;
+                               switch (compositeTypeSpec.getKey()) {
+                               case IASTCompositeTypeSpecifier.k_struct:
+                                       nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_STRUCT : ICElement.C_STRUCT;
+                                       break;
+                               case IASTCompositeTypeSpecifier.k_union:
+                                       nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_UNION : ICElement.C_UNION;
+                                       break;
+                               case ICPPASTCompositeTypeSpecifier.k_class:
+                                       nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_CLASS : ICElement.C_CLASS;
+                                       break;
+                               default:
+                                       assert false : "Unexpected composite type specifier"; //$NON-NLS-1$
+                                       return PROCESS_CONTINUE;
+                               }
+                               assert getCurrentContainer().getTypeCode() == nodeType;
+                               pop(isTemplateDecl ? endOffset : getEndOffset(declSpec));
+                       } else if (declSpec instanceof IASTEnumerationSpecifier) {
+                               isCompositeType= true;
+                               assert getCurrentContainer().getTypeCode() == ICElement.C_ENUMERATION;
+                               pop(getEndOffset(declSpec));
+                       }
+                       if (isCompositeType) {
+                               IASTDeclarator[] declarators= simpleDecl.getDeclarators();
+                               for (int i= 0; i < declarators.length; i++) {
+                                       IASTDeclarator declarator= declarators[i];
+                                       final String nodeName= getDeclaratorName(declarator);
+                                       final int declStartOffset= getStartOffset(declarator);
+                                       final int declEndOffset= getEndOffset(declarator);
+                                       if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_typedef) {
+                                               push(ICElement.C_TYPEDEF, nodeName, declStartOffset);
+                                               pop(declEndOffset);
+                                       } else if (declarator instanceof IASTFunctionDeclarator && !hasNestedPointerOperators(declarator)) {
+                                               final int nodeType;
+                                               if (inClassBody()) {
+                                                       nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_METHOD_DECLARATION : ICElement.C_METHOD_DECLARATION;
+                                               } else {
+                                                       nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_FUNCTION_DECLARATION : ICElement.C_FUNCTION_DECLARATION;
+                                               }
+                                               push(nodeType, nodeName, declStartOffset);
+                                               pop(declEndOffset);
+                                       } else if (declarator != null) {
+                                               final int nodeType;
+                                               if (inClassBody()) {
+                                                       nodeType= ICElement.C_FIELD;
+                                               } else {
+                                                       if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_extern) {
+                                                               nodeType= ICElement.C_VARIABLE_DECLARATION;
+                                                       } else {
+                                                               nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_VARIABLE : ICElement.C_VARIABLE;
+                                                       }
+                                               }
+                                               push(nodeType, nodeName, declStartOffset);
+                                               pop(declEndOffset);
+                                       }
+                               }
+                       }
+               } else if (node instanceof IASTASMDeclaration) {
+                       // ignored
+               } else if (node instanceof ICPPASTVisibilityLabel) {
+                       // ignored
+               } else if (node instanceof ICPPASTNamespaceDefinition) {
+                       // handled below
+               } else if (node instanceof ICPPASTNamespaceAlias) {
+                       // ignored
+               } else if (node instanceof ICPPASTUsingDeclaration) {
+                       // handled in visit
+               } else if (node instanceof ICPPASTUsingDirective) {
+                       // handled in visit
+               } else if (node instanceof ICPPASTLinkageSpecification) {
+                       // declarations get flattened
+               } else if (node instanceof ICPPASTTemplateDeclaration) {
+                       // handled at child declaration level
+               } else if (node instanceof ICPPASTTemplateSpecialization) {
+                       // ignored
+               } else if (node instanceof ICPPASTExplicitTemplateInstantiation) {
+                       // ignored
+               } else if (node instanceof IASTProblemDeclaration) {
+                       // ignored
+               }
+               return PROCESS_CONTINUE;
+       }
+       
+       /*
+        * @see org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor#leave(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition)
+        */
+       @Override
+       public int leave(ICPPASTNamespaceDefinition namespace) {
+               assert getCurrentContainer().getTypeCode() == ICElement.C_NAMESPACE;
+               pop(getEndOffset(namespace));
+               return super.leave(namespace);
+       }
+
+       private DocumentRangeNode getCurrentContainer() {
+               return fStack.peek();
+       }
+
+       /**
+        * Adds a new node with the given type and name to the current container.
+        */
+       private void push(int type, String name, int declarationStart) {
+               if (name.length() == 0) {
+                       name= ANONYMOUS_NAME;
+               }
+               fStack.push(new CNode(getCurrentContainer(), type, name, declarationStart, 0));
+       }
+
+       /**
+        * Closes the current node by setting its end position
+        * and pops it off the stack.
+        */
+       private void pop(int declarationEnd) {
+               DocumentRangeNode current= getCurrentContainer();
+               current.setAppendPosition(declarationEnd);
+               current.setLength(declarationEnd - current.getRange().getOffset());
+               fStack.pop();
+       }
+
+       
+       /**
+        * @return <code>true</code> if the current container is class-like.
+        */
+       private boolean inClassBody() {
+               int typeCode= getCurrentContainer().getTypeCode();
+               return typeCode == ICElement.C_CLASS
+                               || typeCode == ICElement.C_TEMPLATE_CLASS
+                               || typeCode == ICElement.C_STRUCT
+                               || typeCode == ICElement.C_TEMPLATE_STRUCT
+                               || typeCode == ICElement.C_UNION
+                               || typeCode == ICElement.C_TEMPLATE_UNION;
+       }
+
+       /**
+        * Test whether the given declaration is a templated declaration.
+        * 
+        * @param node 
+        * @return <code>true</code> if the declaration is templated.
+        */
+       private boolean isTemplateDecl(IASTDeclaration node) {
+               return node.getParent() instanceof ICPPASTTemplateDeclaration;
+       }
+
+       private boolean hasNestedPointerOperators(IASTDeclarator declarator) {
+               declarator= declarator.getNestedDeclarator();
+               while (declarator != null) {
+                       if (declarator.getPointerOperators().length > 0) {
+                               return true;
+                       }
+                       declarator= declarator.getNestedDeclarator();
+               }
+               return false;
+       }
+
+       private String getEnumerationName(IASTEnumerationSpecifier enumSpecifier) {
+               String nodeName= ASTStringUtil.getQualifiedName(enumSpecifier.getName());
+               if (nodeName.length() == 0) {
+                       nodeName= ANONYMOUS_NAME;
+               }
+               return nodeName;
+       }
+
+       private String getTypeName(IASTCompositeTypeSpecifier compositeTypeSpec) {
+               String nodeName= ASTStringUtil.getQualifiedName(compositeTypeSpec.getName());
+               if (nodeName.length() == 0) {
+                       nodeName= ANONYMOUS_NAME;
+               }
+               return nodeName;
+       }
+
+       private String getDeclaratorName(IASTDeclarator node) {
+               node= getInnermostDeclarator(node);
+               IASTName name= node.getName();
+               String nodeName= ASTStringUtil.getQualifiedName(name);
+               if (nodeName.length() == 0) {
+                       nodeName= ANONYMOUS_NAME;
+               }
+               return nodeName;
+       }
+
+       private IASTDeclarator getInnermostDeclarator(IASTDeclarator node) {
+               IASTDeclarator nested= node.getNestedDeclarator();
+               while (nested != null) {
+                       node= nested;
+                       nested= node.getNestedDeclarator();
+               }
+               return node;
+       }
+
+       private static IASTFileLocation getMaxFileLocation(IASTNodeLocation[] locations) {
+               if (locations == null || locations.length == 0) {
+                       return null;
+               }
+               final IASTNodeLocation nodeLocation= locations[locations.length-1];
+               return nodeLocation.asFileLocation();
+       }
+
+       private static IASTFileLocation getMinFileLocation(IASTNodeLocation[] locations) {
+               if (locations == null || locations.length == 0) {
+                       return null;
+               }
+               final IASTNodeLocation nodeLocation= locations[0];
+               return nodeLocation.asFileLocation();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/BuildGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/BuildGroup.java
new file mode 100644 (file)
index 0000000..1567d45
--- /dev/null
@@ -0,0 +1,261 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Alex Collins (Broadcom Corp.)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.cview;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.BuildAction;
+import org.eclipse.ui.ide.IDEActionFactory;
+import org.eclipse.ui.ide.ResourceUtil;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * This is the action group for workspace actions such as Build
+ */
+public class BuildGroup extends CViewActionGroup {
+
+       /**
+        * An internal class which overrides the 'shouldPerformResourcePruning'
+        * method so that referenced projects aren't build twice . (The CDT
+        * managedbuild builds CDT reference project configuration as part of
+        * building the top-level project).
+        *
+        * Also ensure that files in referenced projects are saved automatically
+        * before build.
+        */
+       public static class CDTBuildAction extends BuildAction {
+           public CDTBuildAction(IShellProvider shell, int kind) {
+               super(shell, kind);
+           }
+           @Override
+           @SuppressWarnings("unchecked")
+           public void run() {
+               // Ensure we correctly save files in all referenced projects before build
+               Set<IProject> prjs = new HashSet<IProject>();
+               for (IResource resource : (List<IResource>)getSelectedResources()) {
+                       IProject project = resource.getProject();
+                       if (project != null) {
+                               prjs.add(project);
+                               try {
+                                       prjs.addAll(Arrays.asList(project.getReferencedProjects()));
+                               } catch (CoreException e) {
+                                       // Project not accessible or not open
+                               }
+                       }
+               }
+               saveEditors(prjs);
+
+                       // Clear the build console, and open a stream
+                       CUIPlugin.getDefault().startGlobalConsole();
+
+               // Now delegate to the parent
+               super.run();
+           }
+
+           /**
+            * Taken from inaccessible o.e.ui.ide.BuildUtilities.java
+            *
+            * Causes all editors to save any modified resources in the provided collection
+            * of projects depending on the user's preference.
+            * @param projects The projects in which to save editors, or <code>null</code>
+            * to save editors in all projects.
+            */
+           private static void saveEditors(Collection<IProject> projects) {
+               if (!BuildAction.isSaveAllSet()) {
+                       return;
+               }
+               IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
+               for (IWorkbenchWindow window : windows) {
+                       IWorkbenchPage[] pages = window.getPages();
+                       for (IWorkbenchPage page : pages) {
+                               if (projects == null) {
+                                       page.saveAllEditors(false);
+                               } else {
+                                       IEditorPart[] editors = page.getDirtyEditors();
+                                       for (IEditorPart editor : editors) {
+                                               IFile inputFile = ResourceUtil.getFile(editor.getEditorInput());
+                                               if (inputFile != null) {
+                                                       if (projects.contains(inputFile.getProject())) {
+                                                               page.saveEditor(editor, false);
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+           }
+       }
+
+       private static class RebuildAction extends CDTBuildAction {
+           public RebuildAction(IShellProvider shell) {
+               super(shell, IncrementalProjectBuilder.FULL_BUILD);
+           }
+           @Override
+               protected void invokeOperation(IResource resource, IProgressMonitor monitor)
+                   throws CoreException {
+               // these are both async.  NOT what I want.
+               ((IProject) resource).build(IncrementalProjectBuilder.CLEAN_BUILD, monitor);
+               ((IProject) resource).build(IncrementalProjectBuilder.FULL_BUILD, monitor);
+
+           }
+       }
+
+       private BuildAction buildAction;
+       private BuildAction rebuildAction;
+       private BuildAction cleanAction;
+
+       // Menu tags for the build
+       final String BUILD_GROUP_MARKER = "buildGroup"; //$NON-NLS-1$
+       final String BUILD_GROUP_MARKER_END = "end-buildGroup"; //$NON-NLS-1$
+
+       public BuildGroup(CView cview) {
+               super(cview);
+       }
+
+       @Override
+       public void fillActionBars(IActionBars actionBars) {
+               actionBars.setGlobalActionHandler(IDEActionFactory.BUILD_PROJECT.getId(), buildAction);
+       }
+
+       /**
+        * Adds the build actions to the context menu.
+        * <p>
+        * The following conditions apply: build-only projects selected, auto build
+        * disabled, at least one * builder present
+        * </p>
+        * <p>
+        * No disabled action should be on the context menu.
+        * </p>
+        * 
+        * @param menu
+        *            context menu to add actions to
+        */
+       @Override
+       public void fillContextMenu(IMenuManager menu) {
+               IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
+               boolean isProjectSelection = true;
+               boolean hasOpenProjects = false;
+               boolean hasClosedProjects = false;
+               boolean hasBuilder = true; // false if any project is closed or does
+               // not have builder
+
+               menu.add(new GroupMarker(BUILD_GROUP_MARKER));
+
+               Iterator<?> resources = selection.iterator();
+               while (resources.hasNext() && (!hasOpenProjects || !hasClosedProjects || hasBuilder || isProjectSelection)) {
+                       Object next = resources.next();
+                       IProject project = null;
+
+                       if (next instanceof IProject) {
+                               project = (IProject) next;
+                       } else if (next instanceof IAdaptable) {
+                               IResource res = (IResource)((IAdaptable)next).getAdapter(IResource.class);
+                               if (res instanceof IProject) {
+                                       project = (IProject) res;
+                               }
+                       }
+
+                       if (project == null) {
+                               isProjectSelection = false;
+                               continue;
+                       }
+                       if (project.isOpen()) {
+                               hasOpenProjects = true;
+                               if (hasBuilder && !hasBuilder(project)) {
+                                       hasBuilder = false;
+                               }
+                       } else {
+                               hasClosedProjects = true;
+                               hasBuilder = false;
+                       }
+               }
+
+               if (!selection.isEmpty() && isProjectSelection && hasBuilder) {
+                       buildAction.selectionChanged(selection);
+                       menu.add(buildAction);
+//                     rebuildAction.selectionChanged(selection);
+//                     menu.add(rebuildAction);
+                       cleanAction.selectionChanged(selection);
+                       menu.add(cleanAction);
+               }
+               menu.add(new GroupMarker(BUILD_GROUP_MARKER_END));
+       }
+
+       /**
+        * Handles a key pressed event by invoking the appropriate action.
+        */
+       @Override
+       public void handleKeyPressed(KeyEvent event) {
+       }
+
+       /**
+        * Returns whether there are builders configured on the given project.
+        * 
+        * @return <code>true</code> if it has builders, <code>false</code> if
+        *         not, or if this could not be determined
+        */
+       boolean hasBuilder(IProject project) {
+               try {
+                       ICommand[] commands = project.getDescription().getBuildSpec();
+                       if (commands.length > 0) return true;
+               } catch (CoreException e) {
+                       // Cannot determine if project has builders. Project is closed
+                       // or does not exist. Fall through to return false.
+               }
+               return false;
+       }
+
+       @Override
+       protected void makeActions() {
+               final IWorkbenchPartSite site = getCView().getSite();
+
+               buildAction = new CDTBuildAction(site, IncrementalProjectBuilder.INCREMENTAL_BUILD);
+               buildAction.setText(CViewMessages.BuildAction_label); 
+
+               cleanAction = new CDTBuildAction(site, IncrementalProjectBuilder.CLEAN_BUILD);
+               cleanAction.setText(CViewMessages.CleanAction_label); 
+               
+               rebuildAction = new RebuildAction(site);
+               rebuildAction.setText(CViewMessages.RebuildAction_label); 
+       }
+
+       @Override
+       public void updateActionBars() {
+               IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
+               buildAction.selectionChanged(selection);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java
new file mode 100644 (file)
index 0000000..099f7ba
--- /dev/null
@@ -0,0 +1,1103 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *     Anton Leherbauer (Wind River Systems) - Fix bug 150045
+ *     Ken Ryall (Nokia) - Fix bug 175144
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.cview;
+
+
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.AbstractTreeViewer;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.IOpenListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.OpenEvent;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.FileTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.ScrollBar;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPartListener;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetManager;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.ResourceWorkingSetFilter;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.contexts.IContextActivation;
+import org.eclipse.ui.contexts.IContextService;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.eclipse.ui.part.ISetSelectionTarget;
+import org.eclipse.ui.part.IShowInSource;
+import org.eclipse.ui.part.IShowInTarget;
+import org.eclipse.ui.part.IShowInTargetList;
+import org.eclipse.ui.part.PluginTransfer;
+import org.eclipse.ui.part.ResourceTransfer;
+import org.eclipse.ui.part.ShowInContext;
+import org.eclipse.ui.part.ViewPart;
+import org.eclipse.ui.views.framelist.FrameList;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.IArchive;
+import org.eclipse.cdt.core.model.IArchiveContainer;
+import org.eclipse.cdt.core.model.IBinary;
+import org.eclipse.cdt.core.model.IBinaryContainer;
+import org.eclipse.cdt.core.model.IBinaryModule;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IParent;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CElementContentProvider;
+import org.eclipse.cdt.ui.CElementSorter;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
+import org.eclipse.cdt.internal.ui.dnd.CDTViewerDragAdapter;
+import org.eclipse.cdt.internal.ui.dnd.DelegatingDropAdapter;
+import org.eclipse.cdt.internal.ui.dnd.FileTransferDragAdapter;
+import org.eclipse.cdt.internal.ui.dnd.FileTransferDropAdapter;
+import org.eclipse.cdt.internal.ui.dnd.PluginTransferDropAdapter;
+import org.eclipse.cdt.internal.ui.dnd.ResourceTransferDragAdapter;
+import org.eclipse.cdt.internal.ui.dnd.ResourceTransferDropAdapter;
+import org.eclipse.cdt.internal.ui.dnd.TransferDragSourceListener;
+import org.eclipse.cdt.internal.ui.dnd.TransferDropTargetListener;
+import org.eclipse.cdt.internal.ui.editor.ITranslationUnitEditorInput;
+import org.eclipse.cdt.internal.ui.preferences.CPluginPreferencePage;
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
+import org.eclipse.cdt.internal.ui.util.RemoteTreeViewer;
+import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCLabelProvider;
+
+/**
+ * 
+ * CView
+ * 
+ */
+public class CView extends ViewPart implements ISetSelectionTarget, IPropertyChangeListener, IShowInTarget, IShowInTargetList {
+
+       ProblemTreeViewer viewer;
+       IMemento memento;
+
+       CViewActionGroup actionGroup;
+
+       FrameList frameList;
+       CViewFrameSource frameSource;
+
+       ResourceWorkingSetFilter workingSetFilter = new ResourceWorkingSetFilter();
+
+       protected boolean dragDetected;
+       private Listener dragDetectListener;
+
+       // Persistance tags.
+       static final String TAG_SELECTION = "selection"; //$NON-NLS-1$
+       static final String TAG_EXPANDED = "expanded"; //$NON-NLS-1$
+       static final String TAG_ELEMENT = "element"; //$NON-NLS-1$
+       static final String TAG_PATH = "path"; //$NON-NLS-1$
+       static final String TAG_VERTICAL_POSITION = "verticalPosition"; //$NON-NLS-1$
+       static final String TAG_HORIZONTAL_POSITION = "horizontalPosition"; //$NON-NLS-1$
+       static final String TAG_WORKINGSET = "workingSet"; //$NON-NLS-1$
+
+       //Menu tags
+       final String WORKING_GROUP_MARKER = "workingSetGroup"; //$NON-NLS-1$
+       final String WORKING_GROUP_MARKER_END = "end-workingSetGroup"; //$NON-NLS-1$
+
+       private IPartListener partListener = new IPartListener() {
+
+               public void partActivated(IWorkbenchPart part) {
+                       if (part instanceof IEditorPart) {
+                               editorActivated((IEditorPart) part);
+                       }
+               }
+
+               public void partBroughtToTop(IWorkbenchPart part) {
+               }
+
+               public void partClosed(IWorkbenchPart part) {
+               }
+
+               public void partDeactivated(IWorkbenchPart part) {
+               }
+
+               public void partOpened(IWorkbenchPart part) {
+               }
+       };
+
+       private IPropertyChangeListener workingSetListener = new IPropertyChangeListener() {
+
+               public void propertyChange(PropertyChangeEvent ev) {
+                       String property = ev.getProperty();
+                       Object newValue = ev.getNewValue();
+                       Object oldValue = ev.getOldValue();
+                       IWorkingSet filterWorkingSet = workingSetFilter.getWorkingSet();
+
+                       if (property == null) {
+                               return;
+                       }
+                       if (IWorkingSetManager.CHANGE_WORKING_SET_REMOVE.equals(property) && oldValue == filterWorkingSet) {
+                               setWorkingSet(null);
+                       } else if (IWorkingSetManager.CHANGE_WORKING_SET_NAME_CHANGE.equals(property) && newValue == filterWorkingSet) {
+                               updateTitle();
+                       } else if (IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE.equals(property) && newValue == filterWorkingSet) {
+                               getViewer().refresh();
+                       }
+               }
+       };
+
+       public CView() {
+               super();
+       }
+
+       /**
+        * @see IWorkbenchPart#setFocus()
+        */
+       @Override
+       public void setFocus() {
+               viewer.getTree().setFocus();
+               //composite.setFocus ();
+       }
+
+       /**
+        * Reveal and select the passed element selection in self's visual
+        * component
+        * 
+        * @see ISetSelectionTarget#selectReveal(ISelection)
+        */
+       public void selectReveal(ISelection selection) {
+               IStructuredSelection ssel = SelectionConverter.convertSelectionToCElements(selection, true);
+               if (!ssel.isEmpty()) {
+                       getViewer().setSelection(ssel, true);
+               }
+       }
+
+       private IContextActivation fContextActivation;
+
+       /**
+        * Handles an open event from the viewer.
+        * Opens an editor on the selected file.
+        *
+        * @param event the open event
+        */
+       protected void handleOpen(OpenEvent event) {
+               IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+               getActionGroup().runDefaultAction(selection);
+       }
+
+       /**
+        * Handles double clicks in viewer. Opens editor if file double-clicked.
+        */
+       protected void handleDoubleClick(DoubleClickEvent event) {
+               IStructuredSelection s = (IStructuredSelection) event.getSelection();
+               Object o = s.getFirstElement();
+               if (viewer.isExpandable(o)) {
+                       // Do not drill in to translation units of binaries.
+                       if (o instanceof ITranslationUnit || o instanceof IBinary || o instanceof IArchive) {
+                               return;
+                       }
+                       viewer.setExpandedState(o, !viewer.getExpandedState(o));
+               }
+       }
+
+       /**
+        * Handles key events in viewer.
+        */
+       void handleKeyPressed(KeyEvent event) {
+               if (getActionGroup() != null) {
+                       getActionGroup().handleKeyPressed(event);
+               }
+       }
+
+       /**
+        * Handles a key release in the viewer. Does nothing by default.
+        * 
+        */
+       protected void handleKeyReleased(KeyEvent event) {
+               if (getActionGroup() != null) {
+                       getActionGroup().handleKeyReleased(event);
+               }
+       }
+
+       /**
+        * Handles selection changed in viewer. Updates global actions. Links to
+        * editor (if option enabled)
+        */
+       void handleSelectionChanged(SelectionChangedEvent event) {
+               final IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+               updateStatusLine(selection);
+               updateActionBars(selection);
+               dragDetected = false;
+               if (isLinkingEnabled()) {
+                       getSite().getShell().getDisplay().asyncExec(new Runnable() {
+
+                               public void run() {
+                                       if (dragDetected == false) {
+                                               // only synchronize with editor when the selection is
+                                               // not the result
+                                               // of a drag. Fixes bug 22274.
+                                               linkToEditor(selection);
+                                       }
+                               }
+                       });
+               }
+       }
+
+       /**
+        * Returns the action group.
+        * 
+        * @return the action group
+        */
+       protected CViewActionGroup getActionGroup() {
+               return actionGroup;
+       }
+
+       /**
+        * Sets the action group.
+        * 
+        * @param actionGroup
+        *            the action group
+        */
+       protected void setActionGroup(CViewActionGroup actionGroup) {
+               this.actionGroup = actionGroup;
+       }
+
+       /**
+        * Answer the property defined by key.
+        */
+       @SuppressWarnings("rawtypes")
+       @Override
+       public Object getAdapter(Class key) {
+               if (key.equals(ISelectionProvider.class)) {
+                       return viewer;
+               } else if (key == IShowInSource.class) {
+                       return getShowInSource();
+               } else if (key == IShowInTarget.class) {
+                       return this;
+               }
+               return super.getAdapter(key);
+       }
+
+       /*
+        * (non-Javadoc) Method declared on IViewPart.
+        */
+       @Override
+       public void init(IViewSite site, IMemento memento) throws PartInitException {
+               super.init(site, memento);
+               this.memento = memento;
+       }
+
+       /**
+        * init the frame source and the framelist.
+        */
+       void initFrameList() {
+               frameSource = new CViewFrameSource(this);
+               frameList = new FrameList(frameSource);
+               frameSource.connectTo(frameList);
+       }
+
+       /**
+        * Initializes the sorter.
+        */
+       void initCElementSorter() {
+               viewer.setSorter(new CElementSorter());
+       }
+
+       /**
+        * Adds the filters to the viewer.
+        * 
+        * @param viewer
+        *            the viewer
+        */
+       void initFilters(TreeViewer viewer) {
+               viewer.addFilter(workingSetFilter);
+       }
+
+       /**
+        * Adds drag and drop support to the navigator.
+        */
+       void initDragAndDrop() {
+               initDrag();
+               initDrop();
+
+               dragDetectListener = new Listener() {
+
+                       public void handleEvent(Event event) {
+                               dragDetected = true;
+                       }
+               };
+               viewer.getControl().addListener(SWT.DragDetect, dragDetectListener);
+
+       }
+
+       private void initDrag() {
+               int ops= DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
+               Transfer[] transfers= new Transfer[] {
+                               LocalSelectionTransfer.getTransfer(),
+                               ResourceTransfer.getInstance(),
+                               FileTransfer.getInstance(),
+               };
+               TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] {
+                               new SelectionTransferDragAdapter(viewer),
+                               new ResourceTransferDragAdapter(viewer),
+                               new FileTransferDragAdapter(viewer)
+               };
+               viewer.addDragSupport(ops, transfers, new CDTViewerDragAdapter(viewer, dragListeners));
+       }
+
+       private void initDrop() {
+               int ops= DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK | DND.DROP_DEFAULT;
+               Transfer[] transfers= new Transfer[] {
+                       LocalSelectionTransfer.getTransfer(),
+                       ResourceTransfer.getInstance(),
+                       FileTransfer.getInstance(),
+                       PluginTransfer.getInstance()
+               };
+               TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] {
+                       new SelectionTransferDropAdapter(viewer),
+                       new ResourceTransferDropAdapter(viewer),
+                       new FileTransferDropAdapter(viewer),                    
+                       new PluginTransferDropAdapter(viewer),
+               };
+               viewer.addDropSupport(ops, transfers, new DelegatingDropAdapter(dropListeners));
+       }
+
+       /**
+        * Initializes the default preferences
+        */
+       public static void initDefaults(IPreferenceStore store) {
+       }
+
+       /**
+        * get the default preferences.
+        */
+       void initFilterFromPreferences() {
+       }
+
+       /**
+        * Sets the content provider for the viewer.
+        */
+       void initContentProvider(TreeViewer viewer) {
+               IContentProvider provider = createContentProvider();
+               viewer.setContentProvider(provider);
+       }
+
+       /**
+        * Sets the label provider for the viewer.
+        */
+       void initLabelProvider(TreeViewer viewer) {
+               CUILabelProvider cProvider = createLabelProvider();
+               viewer.setLabelProvider(new DecoratingCLabelProvider(cProvider, true));
+       }
+
+       /**
+        * Initializes and registers the context menu.
+        */
+       protected void initContextMenu() {
+               MenuManager menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
+               menuMgr.setRemoveAllWhenShown(true);
+               menuMgr.addMenuListener(new IMenuListener() {
+
+                       public void menuAboutToShow(IMenuManager manager) {
+                               CView.this.fillContextMenu(manager);
+                       }
+               });
+               TreeViewer viewer = getViewer();
+               Menu menu = menuMgr.createContextMenu(viewer.getTree());
+               viewer.getTree().setMenu(menu);
+               getSite().registerContextMenu(menuMgr, viewer);
+       }
+
+       /**
+        * Restores the working set filter from the persistence store.
+        */
+       void initWorkingSetFilter() {
+               // FIXME: the memento does not work if we close the view
+               // and reopen we should save this somewhere else.
+               // but it goes to pretty much all the settings 8-(
+               if (memento == null) {
+                       return;
+               }
+               String wsname = memento.getString(TAG_WORKINGSET);
+
+               if (wsname != null && wsname.equals("") == false) { //$NON-NLS-1$
+                       IWorkingSetManager wsmanager = getViewSite().getWorkbenchWindow().getWorkbench().getWorkingSetManager();
+                       IWorkingSet workingSet = wsmanager.getWorkingSet(wsname);
+                       if (workingSet != null) {
+                               // Only initialize filter. Don't set working set into viewer.
+                               // Working set is set via WorkingSetFilterActionGroup
+                               // during action creation.
+                               workingSetFilter.setWorkingSet(workingSet);
+                       }
+               }
+       }
+
+       /**
+        * Add listeners to the viewer.
+        */
+       protected void initListeners(TreeViewer viewer) {
+               viewer.addDoubleClickListener(new IDoubleClickListener() {
+
+                       public void doubleClick(DoubleClickEvent event) {
+                               handleDoubleClick(event);
+                       }
+               });
+
+               viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+                       public void selectionChanged(SelectionChangedEvent event) {
+                               handleSelectionChanged(event);
+                       }
+               });
+
+               viewer.addOpenListener(new IOpenListener() {
+                       public void open(OpenEvent event) {
+                               handleOpen(event);
+                       }
+               });
+
+               viewer.getControl().addKeyListener(new KeyAdapter() {
+
+                       @Override
+                       public void keyPressed(KeyEvent e) {
+                               handleKeyPressed(e);
+                       }
+
+                       @Override
+                       public void keyReleased(KeyEvent e) {
+                               handleKeyReleased(e);
+                       }
+               });
+       }
+
+       @Override
+       public void createPartControl(Composite parent) {
+
+               viewer = createViewer(parent);
+               viewer.setUseHashlookup(true);
+               viewer.setComparer(new CViewElementComparer());
+               initContentProvider(viewer);
+               initLabelProvider(viewer);
+               CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
+
+               initFilters(viewer);
+               initWorkingSetFilter();
+               initListeners(viewer);
+               initCElementSorter();
+               initFrameList();
+               initDragAndDrop();
+               updateTitle();
+
+               viewer.setInput(CoreModel.getDefault().getCModel());
+
+               initContextMenu();
+
+               //Add the property changes after all of the UI work has been done.
+               IWorkingSetManager wsmanager = getViewSite().getWorkbenchWindow().getWorkbench().getWorkingSetManager();
+               wsmanager.addPropertyChangeListener(workingSetListener);
+
+               // Needs to be done before the actions
+               getSite().setSelectionProvider(viewer);
+               getSite().getPage().addPartListener(partListener);
+
+               // Make the Actions for the Context Menu
+               makeActions();
+               getActionGroup().fillActionBars(getViewSite().getActionBars());
+               updateActionBars((IStructuredSelection) viewer.getSelection());
+
+               if (memento != null) {
+                       getActionGroup().restoreFilterAndSorterState(memento);
+               } else {
+                       initFilterFromPreferences();
+               }
+
+
+               if (memento != null) {
+                       restoreState(memento);
+               }
+               memento = null;
+
+       IContextService ctxService = (IContextService) getSite().getService(IContextService.class);
+       if (ctxService != null) {
+               fContextActivation= ctxService.activateContext(CUIPlugin.CVIEWS_SCOPE);
+       }
+    }
+       
+       protected ProblemTreeViewer createViewer(Composite parent) {
+               return new RemoteTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+       }
+
+       protected IContentProvider createContentProvider() {
+               boolean showCUChildren = PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.PREF_SHOW_CU_CHILDREN);
+               boolean groupIncludes = PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.CVIEW_GROUP_INCLUDES);
+               boolean groupMacros = PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.CVIEW_GROUP_MACROS);
+               CViewContentProvider provider = new CViewContentProvider(viewer, getSite(), showCUChildren, true);
+               provider.setIncludesGrouping(groupIncludes);
+               provider.setMacroGrouping(groupMacros);
+               return provider;
+       }
+
+       protected CUILabelProvider createLabelProvider() {
+               return new CViewLabelProvider(AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS, AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS | CElementImageProvider.SMALL_ICONS);
+       }
+
+       /*
+        * (non-Javadoc) Method declared on IWorkbenchPart.
+        */
+       @Override
+       public void dispose() {
+               if (fContextActivation != null) {
+                       IContextService ctxService = (IContextService)getSite().getService(IContextService.class);
+               if (ctxService != null) {
+                       ctxService.deactivateContext(fContextActivation);
+               }
+               }
+
+               getSite().getPage().removePartListener(partListener);
+               CUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
+               if (getActionGroup() != null) {
+                       getActionGroup().dispose();
+               }
+               IWorkingSetManager wsmanager = getViewSite().getWorkbenchWindow().getWorkbench().getWorkingSetManager();
+               wsmanager.removePropertyChangeListener(workingSetListener);
+
+               Control control = viewer.getControl();
+               if (dragDetectListener != null && control != null && control.isDisposed() == false) {
+                       control.removeListener(SWT.DragDetect, dragDetectListener);
+               }
+
+               super.dispose();
+       }
+
+       /**
+        * An editor has been activated. Set the selection in this navigator to be
+        * the editor's input, if linking is enabled.
+        */
+       void editorActivated(IEditorPart editor) {
+               if (!CPluginPreferencePage.isLinkToEditor()) {
+                       return;
+               }
+
+               IEditorInput input = editor.getEditorInput();
+               Object linkElement = null;
+               if (input instanceof IFileEditorInput) {
+                       CoreModel factory = CoreModel.getDefault();
+                       IFileEditorInput fileInput = (IFileEditorInput) input;
+                       IFile file = fileInput.getFile();
+                       ICElement celement = factory.create(file);
+                       if (celement != null) {
+                               linkElement = celement;
+                       } else {
+                               linkElement = file;
+                       }
+               } else if (input instanceof ITranslationUnitEditorInput) {
+                       ITranslationUnitEditorInput tuInput = (ITranslationUnitEditorInput) input;
+                       linkElement = tuInput.getTranslationUnit();
+               }
+               if (linkElement != null) {
+                       ISelection newSelection = new StructuredSelection(linkElement);
+                       if (!viewer.getSelection().equals(newSelection)) {
+                               viewer.setSelection(newSelection);
+                       }
+               }
+       }
+
+       /**
+        * Returns the working set filter for this view.
+        * 
+        * @return the working set
+        */
+       public IWorkingSet getWorkingSet() {
+               return workingSetFilter.getWorkingSet();
+       }
+
+       /**
+        * Returns the sorter.
+        */
+       public CElementSorter getSorter() {
+               return (CElementSorter) getViewer().getSorter();
+       }
+
+       /**
+        * Returns the tree viewer which shows the resource hierarchy.
+        */
+       public TreeViewer getViewer() {
+               return viewer;
+       }
+
+       /*
+        */
+       public FrameList getFrameList() {
+               return frameList;
+       }
+
+       /**
+        * Create self's action objects
+        */
+       void makeActions() {
+               setActionGroup(new MainActionGroup(this));
+       }
+
+       /**
+        * Called when the context menu is about to open. Delegates to the action
+        * group using the viewer's selection as the action context.
+        * 
+        * @since 2.0
+        */
+       protected void fillContextMenu(IMenuManager menu) {
+               IStructuredSelection selection = (IStructuredSelection) getViewer().getSelection();
+               CViewActionGroup actionGroup = getActionGroup();
+               if (actionGroup != null) {
+                       actionGroup.setContext(new ActionContext(selection));
+                       actionGroup.fillContextMenu(menu);
+                       actionGroup.setContext(null);
+               }
+       }
+
+       /**
+        * Returns the tool tip text for the given element.
+        */
+       String getToolTipText(Object element) {
+               if (element instanceof IResource) {
+                       IPath path = ((IResource) element).getFullPath();
+                       if (path.isRoot()) {
+                               return "CVIEW"; //$NON-NLS-1$
+                       }
+                       return path.makeRelative().toString();
+               }
+               return ((ILabelProvider) viewer.getLabelProvider()).getText(element);
+       }
+
+       /**
+        * Returns the message to show in the status line.
+        * 
+        * @param selection
+        *            the current selection
+        * @return the status line message
+        */
+       String getStatusLineMessage(IStructuredSelection selection) {
+               if (selection.size() == 1) {
+                       Object o = selection.getFirstElement();
+                       if (o instanceof IResource) {
+                               return ((IResource) o).getFullPath().makeRelative().toString();
+                       } else if (o instanceof ICElement) {
+                               ICElement celement = (ICElement) o;
+                               IResource res = (IResource) celement.getAdapter(IResource.class);
+                               if (res != null) {
+                                       return res.getFullPath().toString();
+                               } else if (celement.getElementType() == ICElement.C_VCONTAINER) {
+                                       if (celement instanceof IBinaryContainer) {
+                                               ICProject cproj = celement.getCProject();
+                                               if (cproj != null) {
+                                                       return cproj.getPath() + CViewMessages.CView_binaries; 
+                                               }
+                                       } else if (celement instanceof IArchiveContainer) {
+                                               ICProject cproj = celement.getCProject();
+                                               if (cproj != null) {
+                                                       return cproj.getPath() + CViewMessages.CView_archives; 
+                                               }
+                                       } else if (celement instanceof IBinaryModule) {
+                                               IBinary bin = ((IBinaryModule) celement).getBinary();
+                                               return bin.getPath() + ":" + celement.getElementName(); //$NON-NLS-1$
+                                       }
+                               } else if (celement.getElementType() > ICElement.C_UNIT) {
+                                       return celement.getPath().toString() + " - [" + celement.getElementName() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
+                               }
+                               return celement.getElementName();
+                       } else if (o instanceof IWorkbenchAdapter) {
+                               IWorkbenchAdapter wAdapter = (IWorkbenchAdapter)o;
+                               return wAdapter.getLabel(o);
+                       } else {
+                               return "ItemSelected"; //$NON-NLS-1$
+                       }
+               }
+               if (selection.size() > 1) {
+                       return NLS.bind(CViewMessages.CView_statusLine, 
+                                       new String[] { Integer.toString(selection.size())});
+               }
+               return "";//$NON-NLS-1$
+       }
+
+       /**
+        * Updates the action bar actions.
+        * 
+        * @param selection
+        *            the current selection
+        */
+       protected void updateActionBars(IStructuredSelection selection) {
+               CViewActionGroup group = getActionGroup();
+               if (group != null) {
+                       group.setContext(new ActionContext(selection));
+                       group.updateActionBars();
+               }
+       }
+
+       void updateTitle() {
+               Object input = getViewer().getInput();
+               String viewName = getConfigurationElement().getAttribute("name"); //$NON-NLS-1$
+               if (input == null || (input instanceof ICModel)) {
+                       setPartName(viewName);
+                       setTitleToolTip(""); //$NON-NLS-1$
+               } else {
+                       ILabelProvider labelProvider = (ILabelProvider) getViewer().getLabelProvider();
+                       String inputText = labelProvider.getText(input);
+                       setPartName(inputText);
+                       setTitleToolTip(getToolTipText(input));
+               }
+       }
+
+       /**
+        * Updates the message shown in the status line.
+        * 
+        * @param selection
+        *            the current selection
+        */
+       void updateStatusLine(IStructuredSelection selection) {
+               String msg = getStatusLineMessage(selection);
+               getViewSite().getActionBars().getStatusLineManager().setMessage(msg);
+       }
+
+       /*
+        */
+       public void setWorkingSet(IWorkingSet workingSet) {
+               TreeViewer treeViewer = getViewer();
+               Object[] expanded = treeViewer.getExpandedElements();
+               ISelection selection = treeViewer.getSelection();
+
+               workingSetFilter.setWorkingSet(workingSet);
+               /*
+                * if (workingSet != null) { settings.put(STORE_WORKING_SET,
+                * workingSet.getName()); } else { settings.put(STORE_WORKING_SET, "");
+                * //$NON-NLS-1$ }
+                */
+               updateTitle();
+               treeViewer.refresh();
+               treeViewer.setExpandedElements(expanded);
+               if (selection.isEmpty() == false && selection instanceof IStructuredSelection) {
+                       IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+                       treeViewer.reveal(structuredSelection.getFirstElement());
+               }
+       }
+
+       public void propertyChange(PropertyChangeEvent event) {
+               if (viewer == null) return;
+
+               boolean refreshViewer = false;
+               String property = event.getProperty();
+
+               if (property.equals(PreferenceConstants.PREF_SHOW_CU_CHILDREN)) {
+                       boolean showCUChildren = PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.PREF_SHOW_CU_CHILDREN);
+                       IContentProvider provider = viewer.getContentProvider();
+                       if (provider instanceof CElementContentProvider) {
+                               ((CElementContentProvider) provider).setProvideMembers(showCUChildren);
+                       }
+                       refreshViewer = true;
+               } else if (property.equals(PreferenceConstants.PREF_LINK_TO_EDITOR)) {
+                       CViewActionGroup group = getActionGroup();
+                       if (group instanceof MainActionGroup) {
+                               boolean enable = isLinkingEnabled();
+                               ((MainActionGroup)group).toggleLinkingAction.setChecked(enable);
+                       }
+               } else if (property.equals(PreferenceConstants.CVIEW_GROUP_INCLUDES)) {
+                       boolean groupIncludes = PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.CVIEW_GROUP_INCLUDES);
+                       IContentProvider provider = viewer.getContentProvider();
+                       if (provider instanceof CElementContentProvider) {
+                               ((CElementContentProvider) provider).setIncludesGrouping(groupIncludes);
+                       }
+                       refreshViewer = true;
+               } else if (property.equals(PreferenceConstants.CVIEW_GROUP_MACROS)) {
+                       boolean groupMacros = PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.CVIEW_GROUP_MACROS);
+                       IContentProvider provider = viewer.getContentProvider();
+                       if (provider instanceof CElementContentProvider) {
+                               ((CElementContentProvider) provider).setMacroGrouping(groupMacros);
+                       }
+                       refreshViewer = true;
+               }
+
+               if (refreshViewer) {
+                       viewer.refresh();
+               }
+       }
+
+       /**
+        * Returns whether the navigator selection automatically tracks the active
+        * editor.
+        * 
+        * @return <code>true</code> if linking is enabled, <code>false</code>
+        *         if not
+        */
+       public boolean isLinkingEnabled() {
+               return CPluginPreferencePage.isLinkToEditor();
+       }
+
+       public void setLinkingEnabled(boolean enable) {
+               CPluginPreferencePage.setLinkingEnabled(enable);
+               if (enable) {
+                       IEditorPart editor = this.getSite().getPage().getActiveEditor();
+                       if (editor != null) {
+                               editorActivated(editor);
+                       }
+               }
+       }
+
+       /**
+        * Links to editor (if option enabled)
+        */
+       void linkToEditor(IStructuredSelection selection) {
+               // ignore selection changes if the package explorer is not the active
+               // part.
+               // In this case the selection change isn't triggered by a user.
+               if (!isActivePart()) {
+                       return;
+               }
+               if (selection.size() == 1) {
+                       Object obj = selection.getFirstElement();
+                       IEditorPart part = EditorUtility.isOpenInEditor(obj);
+                       if (part != null) {
+                               IWorkbenchPage page = getSite().getPage();
+                               page.bringToTop(part);
+                               if (obj instanceof ISourceReference) {
+                                       if (obj instanceof ICElement && !(obj instanceof ITranslationUnit)) {
+                                               EditorUtility.revealInEditor(part, (ICElement) obj);
+                                       }
+                               }
+                       }
+               }
+       }
+
+       private boolean isActivePart() {
+               return this == getSite().getPage().getActivePart();
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see IViewPartInputProvider#getViewPartInput()
+        */
+       public Object getViewPartInput() {
+               if (viewer != null) {
+                       return viewer.getInput();
+               }
+               return null;
+       }
+
+       public void collapseAll() {
+               viewer.getControl().setRedraw(false);
+               viewer.collapseToLevel(getViewPartInput(), AbstractTreeViewer.ALL_LEVELS);
+               viewer.getControl().setRedraw(true);
+       }
+
+       void restoreState(IMemento memento) {
+               
+               CoreModel factory = CoreModel.getDefault();
+               
+               getActionGroup().restoreFilterAndSorterState(memento);
+
+               IMemento childMem = memento.getChild(TAG_EXPANDED);
+               if (childMem != null) {
+                       ArrayList<ICElement> elements = new ArrayList<ICElement>();
+                       IMemento[] elementMem = childMem.getChildren(TAG_ELEMENT);
+                       for (IMemento element2 : elementMem) {
+                               String p = element2.getString(TAG_PATH);
+                               if (p != null) {
+                                       IPath path = new Path(p);
+                                       ICElement element = factory.create(path);
+                                       if (element != null) {
+                                               elements.add(element);
+                                       }
+                               }
+                       }
+                       viewer.setExpandedElements(elements.toArray());
+               }
+               childMem = memento.getChild(TAG_SELECTION);
+               if (childMem != null) {
+                       ArrayList<ICElement> list = new ArrayList<ICElement>();
+                       IMemento[] elementMem = childMem.getChildren(TAG_ELEMENT);
+                       for (IMemento element2 : elementMem) {
+                               String p = element2.getString(TAG_PATH);
+                               if (p != null) {
+                                       IPath path = new Path(p);
+                                       ICElement element = factory.create(path);
+                                       if (element != null) {
+                                               list.add(element);
+                                       }
+                               }
+                       }
+                       viewer.setSelection(new StructuredSelection(list));
+               }
+
+               Tree tree = viewer.getTree();
+               //save vertical position
+               ScrollBar bar = tree.getVerticalBar();
+               if (bar != null) {
+                       try {
+                               String posStr = memento.getString(TAG_VERTICAL_POSITION);
+                               int position;
+                               position = new Integer(posStr).intValue();
+                               bar.setSelection(position);
+                               position = new Integer(posStr).intValue();
+                               bar.setSelection(position);
+                       } catch (NumberFormatException e) {
+                       }
+               }
+               bar = tree.getHorizontalBar();
+               if (bar != null) {
+                       try {
+                               String posStr = memento.getString(TAG_HORIZONTAL_POSITION);
+                               int position;
+                               position = new Integer(posStr).intValue();
+                               bar.setSelection(position);
+                       } catch (NumberFormatException e) {
+                       }
+               }
+       }
+
+       @Override
+       public void saveState(IMemento memento) {
+               if (viewer == null) {
+                       if (this.memento != null) { //Keep the old state;
+                               memento.putMemento(this.memento);
+                       }
+                       return;
+               }
+
+               //save expanded elements
+               Tree tree = viewer.getTree();
+               Object expandedElements[] = viewer.getExpandedElements();
+               if (expandedElements.length > 0) {
+                       IMemento expandedMem = memento.createChild(TAG_EXPANDED);
+                       for (Object expandedElement : expandedElements) {
+                               Object o = expandedElement;
+                               // Do not save expanded binary files are libraries.
+                               if (o instanceof IParent
+                                               && !(o instanceof IArchiveContainer || o instanceof IBinaryContainer || o instanceof IBinary || o instanceof IArchive)) {
+                                       IMemento elementMem = expandedMem.createChild(TAG_ELEMENT);
+                                       ICElement e = (ICElement) o;
+                                       IResource res = e.getResource();
+                                       if (res != null && res.getLocation() != null) {
+                                               elementMem.putString(TAG_PATH, res.getLocation().toOSString());
+                                       }
+                               }
+                       }
+               }
+
+               //save selection
+               Object elements[] = ((IStructuredSelection) viewer.getSelection()).toArray();
+               if (elements.length > 0) {
+                       IMemento selectionMem = memento.createChild(TAG_SELECTION);
+                       for (Object element : elements) {
+                               if (element instanceof ICElement) {
+                                       ICElement e = (ICElement) element;
+                                       IResource r = e.getResource();
+                                       if (r != null && r.getLocation() != null) {
+                                               IMemento elementMem = selectionMem.createChild(TAG_ELEMENT);
+                                               elementMem.putString(TAG_PATH, r.getLocation().toString());
+                                       }
+                               }
+                       }
+               }
+
+               //save vertical position
+               ScrollBar bar = tree.getVerticalBar();
+               int position = bar != null ? bar.getSelection() : 0;
+               memento.putString(TAG_VERTICAL_POSITION, String.valueOf(position));
+               //save horizontal position
+               bar = tree.getHorizontalBar();
+               position = bar != null ? bar.getSelection() : 0;
+               memento.putString(TAG_HORIZONTAL_POSITION, String.valueOf(position));
+
+               getActionGroup().saveFilterAndSorterState(memento);
+               //Save the working set away
+               if (workingSetFilter.getWorkingSet() != null) {
+                       String wsname = workingSetFilter.getWorkingSet().getName();
+                       if (wsname != null) {
+                               memento.putString(TAG_WORKINGSET, wsname);
+                       }
+               }
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ui.part.IShowInTarget#show(org.eclipse.ui.part.ShowInContext)
+        */
+       public boolean show(ShowInContext context) {
+               ISelection selection= context.getSelection();
+               if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
+                       selectReveal(selection);
+                       return true;
+               }
+               IEditorInput input = (IEditorInput) context.getInput();
+               if (input != null) {
+                       IResource res = (IResource) input.getAdapter(IResource.class);
+                       if (res != null) {
+                               selectReveal(new StructuredSelection(res));
+                               return true;
+                       }
+               }
+               return false;
+       }
+       /**
+        * Returns the <code>IShowInSource</code> for this view.
+        */
+       protected IShowInSource getShowInSource() {
+               return new IShowInSource() {
+                       public ShowInContext getShowInContext() {
+                               return new ShowInContext(getViewer().getInput(), getViewer().getSelection());
+                       }
+               };
+       }
+
+    public String[] getShowInTargetIds() {
+        return new String[]{IPageLayout.ID_RES_NAV};
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewAction.java
new file mode 100644 (file)
index 0000000..849811d
--- /dev/null
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.cview;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.actions.SelectionProviderAction;
+
+/**
+ * Superclass of all actions provided by the cview.
+ */
+public abstract class CViewAction extends SelectionProviderAction {
+       
+       private CView cview;
+
+       /**
+        * Creates a new instance of the class.
+        */
+       public CViewAction(CView cview, String label) {
+               super(cview.getViewer(), label);
+               this.cview = cview;
+       }
+
+       /**
+        * Returns the cview for which this action was created.
+        */
+       public CView getCView() {
+               return cview;
+       }
+
+       /**
+        * Returns the viewer
+        */
+       protected Viewer getViewer() {
+               return getCView().getViewer();
+       }
+
+       /**
+        * Returns the shell to use within actions.
+        */
+       protected Shell getShell() {
+               return getCView().getSite().getShell();
+       }
+
+       /**
+        * Returns the workbench.
+        */
+       protected IWorkbench getWorkbench() {
+               return CUIPlugin.getDefault().getWorkbench();
+       }
+
+       /**
+        * Returns the workbench window.
+        */
+       protected IWorkbenchWindow getWorkbenchWindow() {
+               return getCView().getSite().getWorkbenchWindow();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewActionGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewActionGroup.java
new file mode 100644 (file)
index 0000000..36b3d02
--- /dev/null
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.cview;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.views.navigator.SortAndFilterActionGroup;
+import org.eclipse.ui.views.navigator.WorkspaceActionGroup;
+
+/**
+ * This is the action group for all the view actions.
+ * It delegates to several subgroups for most of the actions.
+ * 
+ * @see GotoActionGroup
+ * @see OpenFileGroup
+ * @see RefactorActionGroup
+ * @see SortAndFilterActionGroup
+ * @see WorkspaceActionGroup
+ * 
+ */
+public abstract class CViewActionGroup extends ActionGroup {
+
+       /**
+        * The resource navigator.
+        */
+       protected CView cview;
+       
+       /**
+        * Constructs a new navigator action group and creates its actions.
+        * 
+        * @param cview the CView
+        */
+       public CViewActionGroup(CView cview) {
+               this.cview = cview;
+               makeActions();
+       }
+       
+       /**
+        * Returns the image descriptor with the given relative path.
+        */
+       protected ImageDescriptor getImageDescriptor(String relativePath) {
+               String iconPath = "icons/"; //$NON-NLS-1$
+               try {
+                       URL installURL = CUIPlugin.getDefault().getBundle().getEntry("/"); //$NON-NLS-1$
+                       URL url = new URL(installURL, iconPath + relativePath);
+                       return ImageDescriptor.createFromURL(url);
+               } catch (MalformedURLException e) {
+                       // should not happen
+                       return ImageDescriptor.getMissingImageDescriptor();
+               }
+       }       
+
+       /**
+        * Returns the resource navigator.
+        */
+       public CView getCView() {
+               return cview;
+       }
+       
+       /**
+        * Handles a key pressed event by invoking the appropriate action.
+        * Does nothing by default.
+        */
+       public void handleKeyPressed(KeyEvent event) {
+       }
+
+       /**
+        * Handles a key released event by invoking the appropriate action.
+        * Does nothing by default.
+        */
+       public void handleKeyReleased(KeyEvent event) {
+       }
+
+       /**
+        * Makes the actions contained in this action group.
+        */
+       protected abstract void makeActions();
+       
+       /**
+        * Called when the context menu is about to open.
+        * Override to add your own context dependent menu contributions.
+        */
+       @Override
+       public abstract void fillContextMenu(IMenuManager menu);
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars)
+        */
+       @Override
+       public abstract void fillActionBars(IActionBars actionBars);
+
+       @Override
+       public abstract void updateActionBars();
+
+       /**
+        * Runs the default action in the group.
+        * Does nothing by default.
+        * 
+        * @param selection the current selection
+        */
+       public void runDefaultAction(IStructuredSelection selection) {
+       }
+
+       public void restoreFilterAndSorterState(IMemento memento) {
+       }
+       
+       public void saveFilterAndSorterState(IMemento memento) {
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewContentProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewContentProvider.java
new file mode 100644 (file)
index 0000000..f8ba3ad
--- /dev/null
@@ -0,0 +1,270 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.cview;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.ui.IWorkbenchPartSite;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.IArchive;
+import org.eclipse.cdt.core.model.IArchiveContainer;
+import org.eclipse.cdt.core.model.IBinary;
+import org.eclipse.cdt.core.model.IBinaryContainer;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IIncludeReference;
+import org.eclipse.cdt.core.model.ILibraryReference;
+import org.eclipse.cdt.ui.CElementContentProvider;
+
+import org.eclipse.cdt.internal.ui.util.RemoteTreeContentManager;
+import org.eclipse.cdt.internal.ui.util.RemoteTreeViewer;
+
+/**
+ * CViewContentProvider
+ */
+public class CViewContentProvider extends CElementContentProvider {
+       private RemoteTreeContentManager fManager;
+
+       public CViewContentProvider() {
+               super();
+       }
+
+       /**
+        * 
+        */
+       public CViewContentProvider(TreeViewer viewer, IWorkbenchPartSite site) {
+               super();
+               fManager = createContentManager(viewer, site);
+       }
+
+       /**
+        * @param provideMembers
+        * @param provideWorkingCopy
+        */
+       public CViewContentProvider(TreeViewer viewer, IWorkbenchPartSite site, boolean provideMembers, boolean provideWorkingCopy) {
+               super(provideMembers, provideWorkingCopy);
+               fManager = createContentManager(viewer, site);
+       }
+
+       protected RemoteTreeContentManager createContentManager(TreeViewer viewer, IWorkbenchPartSite site) {
+               if (site == null) {
+                       return new RemoteTreeContentManager(this, (RemoteTreeViewer)viewer, null);
+               }
+               return new RemoteTreeContentManager(this, (RemoteTreeViewer)viewer, site);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
+        */
+       @Override
+       public Object[] getChildren(Object element) {
+               Object[] objs = null;
+
+               if (fManager != null) {
+                       // use the the deferred manager for some cases
+                       if (element instanceof IBinary) {
+                               // It takes sometimes to parse binaries deferred it
+                               objs = fManager.getChildren(element);
+                       } else if (element instanceof IArchive) {
+                               // It takes sometimes to parse archives deferred it
+                               objs = fManager.getChildren(element);
+                       }
+               }
+               
+               if (objs == null) {
+                       objs = super.getChildren(element);
+               }
+               Object[] extras = null;
+               try {
+                       if (element instanceof ICProject) {
+                               extras = getProjectChildren((ICProject)element);
+                       } else if (element instanceof IBinaryContainer) {
+                               extras = getExecutables((IBinaryContainer)element);
+                       } else if (element instanceof IArchiveContainer) {
+                               extras = getArchives((IArchiveContainer)element);
+                       } else if (element instanceof IIncludeReference) {
+                               extras = getIncludeReferenceChildren((IIncludeReference)element);
+                       }
+                       /*
+                        * Do not to this for now, since ILibraryReference is an Archive.
+                        else if (element instanceof ILibraryReference) {
+                               extras =  ((ILibraryReference)element).getChildren();
+                       }*/
+               } catch (CModelException e) {
+               }
+               if (extras != null && extras.length > 0) {
+                       objs = concatenate(objs, extras);
+               }
+               return objs;
+       }
+
+       public Object[] getIncludeReferenceChildren(IIncludeReference ref) throws CModelException {
+               // We do not want to show children for Include paths that are inside the workspace.
+               // no need to that since they can access elsewhere and that simplifies the
+               // CView code.
+               IPath location = ref.getPath();
+               IContainer[] containers = ref.getCModel().getWorkspace().getRoot().findContainersForLocation(location);
+               for (int i = 0; i < containers.length; ++i) {
+                       if (containers[i].isAccessible()) {
+                               return NO_CHILDREN;
+                       }
+               }
+               return ref.getChildren();
+       }
+       
+       private Object[] getProjectChildren(ICProject cproject) throws CModelException {
+               Object[] extras = null;
+               IArchiveContainer archive = cproject.getArchiveContainer(); 
+               if (getArchives(archive).length > 0) {
+                       extras = new Object[] {archive};
+               }
+               IBinaryContainer bin = cproject.getBinaryContainer(); 
+               if (getExecutables(bin).length > 0) {
+                       Object[] o = new Object[] {bin};
+                       if (extras != null && extras.length > 0) {
+                               extras = concatenate(extras, o);
+                       } else {
+                               extras = o;
+                       }
+               }
+               LibraryRefContainer libRefCont = new LibraryRefContainer(cproject);
+               Object[] libRefs = libRefCont.getChildren(cproject);
+               if (libRefs != null && libRefs.length > 0) {
+                       Object[] o = new Object[] {libRefCont};
+                       if (extras != null && extras.length > 0) {
+                               extras = concatenate(extras, o);
+                       } else {
+                               extras = o;
+                       }
+               }
+               
+               IncludeRefContainer incRefCont = new IncludeRefContainer(cproject);
+               Object[] incRefs = incRefCont.getChildren(cproject);
+               if (incRefs != null && incRefs.length > 0) {
+                       Object[]  o = new Object[] {incRefCont};
+                       if (extras != null && extras.length > 0) {
+                               extras = concatenate(extras, o);
+                       } else {
+                               extras = o;
+                       }
+               }
+               return extras;
+       }
+
+       protected IBinary[] getExecutables(IBinaryContainer container) throws CModelException {
+               ICElement[] celements = container.getChildren();
+               ArrayList<IBinary> list = new ArrayList<IBinary>(celements.length);
+               for (int i = 0; i < celements.length; i++) {
+                       if (celements[i] instanceof IBinary) {
+                               IBinary bin = (IBinary)celements[i];
+                               if (bin.showInBinaryContainer()) {
+                                       list.add(bin);
+                               }
+                       }
+               }
+               IBinary[] bins = new IBinary[list.size()];
+               list.toArray(bins);
+               return bins;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.BaseCElementContentProvider#internalGetParent(java.lang.Object)
+        */
+       @Override
+       public Object internalGetParent(Object element) {
+               // since we insert logical containers we have to fix
+               // up the parent for {IInclude,ILibrary}Reference so that they refer
+               // to the container and containers refere to the project
+               Object parent = super.internalGetParent(element);
+               if (element instanceof IncludeReferenceProxy) {
+                       parent = ((IncludeReferenceProxy)element).getIncludeRefContainer();
+               } else if (element instanceof IncludeRefContainer) {
+                       parent = ((IncludeRefContainer)element).getCProject();
+               } else if (element instanceof ILibraryReference) {
+                       if (parent instanceof ICProject) {
+                               parent = new LibraryRefContainer((ICProject)parent);
+                       }
+               } else if (element instanceof LibraryRefContainer) {
+                       parent = ((LibraryRefContainer)element).getCProject();
+               }
+               return parent;
+       }
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
+        */
+       @Override
+       public boolean hasChildren(Object element) {
+               if (fManager != null) {
+                       if (element instanceof IBinary) {
+                               return fManager.mayHaveChildren(element);
+                       } else if (element instanceof IArchive) {
+                               return fManager.mayHaveChildren(element);
+                       }
+               }
+               if (element instanceof IBinaryContainer) {
+                       try {
+                               IBinaryContainer cont = (IBinaryContainer)element;
+                               IBinary[] bins = getBinaries(cont);
+                               return (bins != null) && bins.length > 0;
+                       } catch (CModelException e) {
+                               return false;
+                       }
+               } else if (element instanceof IArchiveContainer) {
+                       try {
+                               IArchiveContainer cont = (IArchiveContainer)element;
+                               IArchive[] ars = getArchives(cont);
+                               return (ars != null) && ars.length > 0;
+                       } catch (CModelException e) {
+                               return false;
+                       }                       
+               } else if (element instanceof IncludeReferenceProxy) {
+                       IIncludeReference ref = ((IncludeReferenceProxy)element).getReference();
+                       IPath location = ref.getPath();
+                       IContainer[] containers = ref.getCModel().getWorkspace().getRoot().findContainersForLocation(location);
+                       for (int i = 0; i < containers.length; ++i) {
+                               if (containers[i].isAccessible()) {
+                                       return false;
+                               }
+                       }
+
+               }
+               return super.hasChildren(element);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+        */
+       @Override
+       public void dispose() {
+               if (fManager != null) {
+                       fManager.cancel();
+               }
+               super.dispose();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+        */
+       @Override
+       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+               if (fManager != null) {
+                       fManager.cancel();
+               }
+               super.inputChanged(viewer, oldInput, newInput);
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewElementComparer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewElementComparer.java
new file mode 100644 (file)
index 0000000..05bfd4d
--- /dev/null
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2008 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.cview;
+
+import org.eclipse.jface.viewers.IElementComparer;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+
+public class CViewElementComparer implements IElementComparer {
+
+       public boolean equals(Object o1, Object o2) {
+               if (o1 == o2)   // this handles also the case that both are null
+                       return true;
+               if (o1 == null)  
+                       return false; // o2 != null if we reach this point 
+               if (o1.equals(o2))
+                       return true;
+
+               // Assume they are CElements
+               ICElement c1= (o1 instanceof ICElement) ? (ICElement)o1 : null;
+               ICElement c2= (o2 instanceof ICElement) ? (ICElement)o2 : null;
+               if (c1 == null || c2 == null)
+                       return false;
+
+               if (c1.getElementType() != c2.getElementType())
+                       return false;
+
+               // Below is for children of TranslationUnits but we have to make sure
+               // we handle the case that the child comes from the a workingCopy in that
+               // case it should be equal as the original element.
+               ITranslationUnit u1 = (ITranslationUnit)c1.getAncestor(ICElement.C_UNIT);
+               ITranslationUnit u2 = (ITranslationUnit)c2.getAncestor(ICElement.C_UNIT);
+               if (u1 == null || u2 == null) {
+                       return false;
+               }
+               
+               if (u1.isWorkingCopy() && u2.isWorkingCopy() || !u1.isWorkingCopy() && !u2.isWorkingCopy()) {
+                       return false;
+               }
+               // From here on either c1 or c2 is a working copy.
+               if (u1.isWorkingCopy()) {
+                       c1= ((IWorkingCopy)u1).getOriginal(c1);
+               } else if (u2.isWorkingCopy()) {
+                       c2= ((IWorkingCopy)u2).getOriginal(c2); 
+               }
+               if (c1 == null || c2 == null)
+                       return false;
+               return c1.equals(c2);
+       }
+
+       public int hashCode(Object o1) {
+               return o1.hashCode();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewFrameSource.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewFrameSource.java
new file mode 100644 (file)
index 0000000..0d77616
--- /dev/null
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.cview;
+
+import org.eclipse.ui.views.framelist.TreeFrame;
+import org.eclipse.ui.views.framelist.TreeViewerFrameSource;
+
+public class CViewFrameSource extends TreeViewerFrameSource {
+        private CView cview;
+
+        @Override
+               protected TreeFrame createFrame(Object input) {
+                TreeFrame frame = super.createFrame(input);
+                frame.setToolTipText(cview.getToolTipText(input));
+                return frame;
+        }
+        /**
+         * Also updates the title of the packages explorer
+         */
+        @Override
+               protected void frameChanged(TreeFrame frame) {
+                super.frameChanged(frame);
+                cview.updateTitle();
+        }
+        public CViewFrameSource(CView cview) {
+                super(cview.getViewer());
+                this.cview = cview;
+        }
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java
new file mode 100644 (file)
index 0000000..4d326cd
--- /dev/null
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ * Anton Leherbauer (Wind River Systems)
+ * Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.cview;
+
+import org.eclipse.core.filesystem.URIUtil;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.swt.graphics.Image;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IIncludeReference;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CElementImageDescriptor;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.corext.util.Strings;
+
+import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
+
+/*
+ * CViewLabelProvider 
+ */
+public class CViewLabelProvider extends AppearanceAwareLabelProvider {
+       
+       public CViewLabelProvider(long textFlags, int imageFlags) {
+               super(textFlags, imageFlags);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
+        */
+       @Override
+       public String getText(Object element) {
+               if (element instanceof IncludeReferenceProxy) {
+                       final IIncludeReference ref = ((IncludeReferenceProxy)element).getReference();
+                       final IPath uriPathLocation = ref.getPath().makeAbsolute();
+                       final IContainer[] containers= ResourcesPlugin.getWorkspace().getRoot().findContainersForLocationURI(URIUtil.toURI(uriPathLocation));
+                       if (containers.length > 0) {
+                               // bug 192707, prefer the project the reference belongs to.
+                               final ICProject prj= ref.getCProject();
+                               if (prj != null) {
+                                       for (int i = 0; i < containers.length; i++) {
+                                               final IContainer container = containers[i];
+                                               final IProject project = container.getProject();
+                                               // in case the path is empty, the container is the workspace root and project is null.
+                                               if (project != null && project.equals(prj.getProject())) {
+                                                       return container.getFullPath().makeRelative().toString();
+                                               }
+                                       }
+                               }
+                               IPath p = containers[0].getFullPath();
+                               p = (p.isRoot()) ? uriPathLocation : p.makeRelative();
+                               return decorateText(p.toString(), element);
+                       }
+               } else if (element instanceof IIncludeReference) {
+                       IIncludeReference ref = (IIncludeReference)element;
+                       Object parent = ref.getParent();
+                       if (parent instanceof IIncludeReference) {
+                               IPath p = ref.getPath();
+                               IPath parentLocation = ((IIncludeReference)parent).getPath();
+                               if (parentLocation.isPrefixOf(p)) {
+                                       p = p.setDevice(null);
+                                       p = p.removeFirstSegments(parentLocation.segmentCount());
+                               }
+                               return decorateText(p.toString(), element);
+                       }
+               } else if (element instanceof ITranslationUnit) {
+                       ITranslationUnit unit = (ITranslationUnit)element;
+                       Object parent = unit.getParent();
+                       if (parent instanceof IIncludeReference) {
+                               IPath p = unit.getPath();
+                               IPath parentLocation = ((IIncludeReference)parent).getPath();
+                               if (parentLocation.isPrefixOf(p)) {
+                                       p = p.setDevice(null);
+                                       p = p.removeFirstSegments(parentLocation.segmentCount());
+                               }
+                               return decorateText(p.toString(), element);
+                       }                       
+               }
+               return super.getText(element);
+       }
+       
+       @Override
+       public StyledString getStyledText(Object element) {
+               return Strings.markLTR(new StyledString(getText(element)));                                                             
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
+        */
+       @Override
+       public Image getImage(Object element) {
+               if (element instanceof IncludeReferenceProxy) {
+                       IIncludeReference reference = ((IncludeReferenceProxy)element).getReference();
+                       IPath path = reference.getPath();
+                       IContainer container = reference.getCModel().getWorkspace().getRoot().getContainerForLocation(path);
+                       if (container != null && container.isAccessible()) {
+                               ImageDescriptor desc = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER_WORKSPACE);
+                               desc = new CElementImageDescriptor(desc, 0, CElementImageProvider.SMALL_SIZE);
+                               return CUIPlugin.getImageDescriptorRegistry().get(desc);
+                       }
+               } else if (element instanceof IIncludeReference) {
+                       ImageDescriptor desc = CElementImageProvider.getImageDescriptor(ICElement.C_CCONTAINER);
+                       desc = new CElementImageDescriptor(desc, 0, CElementImageProvider.SMALL_SIZE);
+                       return CUIPlugin.getImageDescriptorRegistry().get(desc);
+               }
+               return super.getImage(element);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.java
new file mode 100644 (file)
index 0000000..e646d87
--- /dev/null
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.cview;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class CViewMessages extends NLS {
+
+       private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.cview.CViewMessages";//$NON-NLS-1$
+
+       private CViewMessages() {
+               // Do not instantiate
+       }
+
+       public static String OpenWithMenu_label;
+       public static String BuildAction_label;
+       public static String RebuildAction_label;
+       public static String CleanAction_label;
+       public static String CollapseAllAction_label;
+       public static String CollapseAllAction_tooltip;
+       public static String CollapseAllAction_description;
+       public static String CopyAction_title;
+       public static String CopyAction_toolTip;
+       public static String PasteAction_title;
+       public static String PasteAction_toolTip;
+       public static String NewWizardsActionGroup_new;
+       public static String DefaultAction_WIP;
+       public static String DefaultAction_workInProgress;
+       public static String CView_binaries;
+       public static String CView_archives;
+       public static String LibraryRefContainer_Libraries;
+       public static String IncludeRefContainer_Includes;
+       public static String CView_statusLine;
+       public static String CopyToClipboardProblemDialog_title;
+       public static String CopyToClipboardProblemDialog_message;
+       public static String SelectionTransferDropAdapter_error_title;
+       public static String SelectionTransferDropAdapter_error_message;
+       public static String SelectionTransferDropAdapter_error_exception;
+
+       static {
+               NLS.initializeMessages(BUNDLE_NAME, CViewMessages.class);
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.properties
new file mode 100644 (file)
index 0000000..56993fc
--- /dev/null
@@ -0,0 +1,47 @@
+###############################################################################
+# Copyright (c) 2000, 2009 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+#     Anton Leherbauer (Wind River Systems) - Fixed bug 141484
+###############################################################################
+
+
+OpenWithMenu_label=Open Wit&h
+
+BuildAction_label=&Build Project
+RebuildAction_label=Rebuild Pro&ject
+CleanAction_label=Clean Project
+
+CollapseAllAction_label=Collapse All
+CollapseAllAction_tooltip=Collapse All
+CollapseAllAction_description=Collapse All
+
+CopyAction_title = &Copy
+CopyAction_toolTip = Copy
+
+PasteAction_title=&Paste
+PasteAction_toolTip = Paste
+
+NewWizardsActionGroup_new=Ne&w
+
+DefaultAction_WIP=WIP
+DefaultAction_workInProgress=Work In Progress
+CView_binaries=\ - binaries
+CView_archives=\ - archives
+LibraryRefContainer_Libraries=Libraries
+# START NON-TRANSLATABLE
+IncludeRefContainer_Includes=Includes
+# END NON-TRANSLATABLE
+CView_statusLine = {0} items selected
+
+CopyToClipboardProblemDialog_title=Problem Copying to Clipboard
+CopyToClipboardProblemDialog_message=There was a problem when accessing the system clipboard. Retry?
+
+SelectionTransferDropAdapter_error_title=Drag and Drop Problem
+SelectionTransferDropAdapter_error_message=A problem occurred during Drag and Drop.
+SelectionTransferDropAdapter_error_exception=An unexpected exception occurred during Drag and Drop.
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMoveAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMoveAction.java
new file mode 100644 (file)
index 0000000..295f6db
--- /dev/null
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.cview;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.MoveProjectAction;
+import org.eclipse.ui.actions.MoveResourceAction;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+
+/**
+ * The ResourceNavigatorMoveAction is a resource move that aso updates the navigator
+ * to show the result of the move.
+ * It also delegates to MoveProjectAction as needed.
+ * 
+ * @since 2.0
+ */
+public class CViewMoveAction extends MoveResourceAction {
+       private StructuredViewer viewer;
+       private MoveProjectAction moveProjectAction;
+       
+/**
+ * Create a ResourceNavigatorMoveAction and use the supplied viewer to update the UI.
+ * @param shellProvider provider for the shell
+ * @param structureViewer StructuredViewer
+ */
+public CViewMoveAction(IShellProvider shellProvider, StructuredViewer structureViewer) {
+       super(shellProvider);
+       PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.MOVE_ACTION);
+       this.viewer = structureViewer;
+       this.moveProjectAction = new MoveProjectAction(shellProvider);
+}
+/* (non-Javadoc)
+ * Method declared on IAction.
+ */
+@Override
+public void run() {
+       if (moveProjectAction.isEnabled()) {
+               moveProjectAction.run();
+               return;
+       }
+       
+       super.run();
+       List<?> destinations = getDestinations();
+       if (destinations != null && destinations.isEmpty() == false) {
+               IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+               List<IResource> resources = new ArrayList<IResource>();
+               Iterator<?> iterator = destinations.iterator();
+       
+               while (iterator.hasNext()) {
+                       IResource newResource = root.findMember((IPath) iterator.next());
+                       if (newResource != null)
+                               resources.add(newResource);
+               }
+       
+               this.viewer.setSelection(new StructuredSelection(resources), true);
+       }
+
+}
+
+@Override
+protected boolean updateSelection(IStructuredSelection selection) {
+       moveProjectAction.selectionChanged(selection);
+       return super.updateSelection(selection) || moveProjectAction.isEnabled();
+}
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewRenameAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewRenameAction.java
new file mode 100644 (file)
index 0000000..844890e
--- /dev/null
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.cview;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.RenameResourceAction;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+
+
+/**
+ * The ResourceNavigatorRenameAction is the rename action used by the
+ * ResourceNavigator that also allows updating after rename.
+ * @since 2.0
+ */
+public class CViewRenameAction extends RenameResourceAction {
+       private TreeViewer viewer;
+       /**
+        * Create a ResourceNavigatorRenameAction and use the tree of the supplied viewer
+        * for editing.
+        * @param shell Shell
+        * @param treeViewer TreeViewer
+        * @deprecated
+        */
+       @Deprecated
+       public CViewRenameAction(Shell shell, TreeViewer treeViewer) {
+               super(shell, treeViewer.getTree());
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(
+                       this,
+                       ICHelpContextIds.RENAME_ACTION);
+               this.viewer = treeViewer;
+       }
+       /**
+        * Create a ResourceNavigatorRenameAction and use the tree of the supplied viewer
+        * for editing.
+        * @param shellProvider a provider for a shell
+        * @param treeViewer TreeViewer
+        */
+       public CViewRenameAction(IShellProvider shellProvider, TreeViewer treeViewer) {
+               super(shellProvider, treeViewer.getTree());
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(
+                       this,
+                       ICHelpContextIds.RENAME_ACTION);
+               this.viewer = treeViewer;
+       }
+
+       /* (non-Javadoc)
+        * Run the action to completion using the supplied path.
+        */
+       @Override
+       protected void runWithNewPath(IPath path, IResource resource) {
+               IWorkspaceRoot root = resource.getProject().getWorkspace().getRoot();
+               super.runWithNewPath(path, resource);
+               if (this.viewer != null) {
+                       IResource newResource = root.findMember(path);
+                       if (newResource != null)
+                               this.viewer.setSelection(new StructuredSelection(newResource), true);
+               }
+       }
+       /**
+       * Handle the key release
+       */
+       public void handleKeyReleased(KeyEvent event) {
+               if (event.keyCode == SWT.F2 && event.stateMask == 0 && isEnabled()) {
+                       run();
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CollapseAllAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CollapseAllAction.java
new file mode 100644 (file)
index 0000000..8f06d23
--- /dev/null
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.cview;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.jface.action.Action;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Collapse all nodes.
+ */
+class CollapseAllAction extends Action {
+       
+       private CView cview;
+       
+       CollapseAllAction(CView part) {
+               super(CViewMessages.CollapseAllAction_label); 
+               setDescription(CViewMessages.CollapseAllAction_description); 
+               setToolTipText(CViewMessages.CollapseAllAction_tooltip); 
+               CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_COLLAPSE_ALL);
+               cview = part;
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.COLLAPSE_ALL_ACTION);
+       }
+       @Override
+       public void run() { 
+               cview.collapseAll();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CopyAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CopyAction.java
new file mode 100644 (file)
index 0000000..33f0839
--- /dev/null
@@ -0,0 +1,204 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.cview;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWTError;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.FileTransfer;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.SelectionListenerAction;
+import org.eclipse.ui.part.ResourceTransfer;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+
+/**
+ * Standard action for copying the currently selected resources to the clipboard.
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ * 
+ * @since 2.0
+ */
+public class CopyAction extends SelectionListenerAction {
+
+       /**
+        * The id of this action.
+        */
+       public static final String ID = PlatformUI.PLUGIN_ID + ".CopyAction"; //$NON-NLS-1$
+
+       /**
+        * The shell in which to show any dialogs.
+        */
+       private Shell shell;
+
+       /**
+        * System clipboard
+        */
+       private Clipboard clipboard;
+
+       /**
+        * Associated paste action. May be <code>null</code>
+        */
+       private PasteAction pasteAction;
+
+       /**
+        * Creates a new action.
+        *
+        * @param shell the shell for any dialogs
+        * @param clipboard a platform clipboard
+        */
+       public CopyAction(Shell shell, Clipboard clipboard) {
+               super(CViewMessages.CopyAction_title); 
+               Assert.isNotNull(shell);
+               Assert.isNotNull(clipboard);
+               this.shell = shell;
+               this.clipboard = clipboard;
+               setToolTipText(CViewMessages.CopyAction_toolTip); 
+               setId(CopyAction.ID);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.COPY_ACTION);
+
+       }
+       /**
+        * Creates a new action.
+        *
+        * @param shell the shell for any dialogs
+        * @param clipboard a platform clipboard
+        * @param pasteAction a paste action
+        * 
+        * @since 2.0
+        */
+       public CopyAction(Shell shell, Clipboard clipboard, PasteAction pasteAction) {
+               this(shell, clipboard);
+               this.pasteAction = pasteAction;
+       }
+       /**
+        * The <code>CopyAction</code> implementation of this method defined 
+        * on <code>IAction</code> copies the selected resources to the 
+        * clipboard.
+        */
+       @Override
+       public void run() {
+               List<?> selectedResources = getSelectedResources();
+               IResource[] resources = selectedResources.toArray(new IResource[selectedResources.size()]);
+
+               // Get the file names and a string representation
+               final int length = resources.length;
+               int actualLength = 0;
+               String[] fileNames = new String[length];
+               StringBuffer buf = new StringBuffer();
+               for (int i = 0; i < length; i++) {
+                       IPath location = resources[i].getLocation();
+                       // location may be null. See bug 29491.
+                       if (location != null)
+                               fileNames[actualLength++] = location.toOSString();
+                       if (i > 0)
+                               buf.append("\n"); //$NON-NLS-1$
+                       buf.append(resources[i].getName());
+               }
+               // was one or more of the locations null?
+               if (actualLength < length) {
+                       String[] tempFileNames = fileNames;
+                       fileNames = new String[actualLength];
+                       for (int i = 0; i < actualLength; i++)
+                               fileNames[i] = tempFileNames[i];
+               }
+               setClipboard(resources, fileNames, buf.toString());
+
+               // update the enablement of the paste action
+               // workaround since the clipboard does not suppot callbacks
+               if (pasteAction != null && pasteAction.getStructuredSelection() != null)
+                       pasteAction.selectionChanged(pasteAction.getStructuredSelection());
+       }
+       /**
+        * Set the clipboard contents. Prompt to retry if clipboard is busy.
+        * 
+        * @param resources the resources to copy to the clipboard
+        * @param fileNames file names of the resources to copy to the clipboard
+        * @param names string representation of all names
+        */
+       private void setClipboard(IResource[] resources, String[] fileNames, String names) {
+               try {
+                       // set the clipboard contents
+                       if (fileNames.length > 0) {
+                               clipboard.setContents(
+                                       new Object[] { resources, fileNames, names },
+                                       new Transfer[] { ResourceTransfer.getInstance(), FileTransfer.getInstance(), TextTransfer.getInstance()});
+                       } else {
+                               clipboard.setContents(
+                                       new Object[] { resources, names },
+                                       new Transfer[] { ResourceTransfer.getInstance(), TextTransfer.getInstance()});
+                       }
+               } catch (SWTError e) {
+                       if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD)
+                               throw e;
+                       if (MessageDialog.openQuestion(shell, CViewMessages.CopyToClipboardProblemDialog_title, CViewMessages.CopyToClipboardProblemDialog_message)) 
+                               setClipboard(resources, fileNames, names);
+               }
+       }
+       /**
+        * The <code>CopyAction</code> implementation of this
+        * <code>SelectionListenerAction</code> method enables this action if 
+        * one or more resources of compatible types are selected.
+        */
+       @Override
+       protected boolean updateSelection(IStructuredSelection selection) {
+               if (!super.updateSelection(selection))
+                       return false;
+
+               if (getSelectedNonResources().size() > 0)
+                       return false;
+
+               List<?> selectedResources = getSelectedResources();
+               if (selectedResources.size() == 0)
+                       return false;
+
+               boolean projSelected = selectionIsOfType(IResource.PROJECT);
+               boolean fileFoldersSelected = selectionIsOfType(IResource.FILE | IResource.FOLDER);
+               if (!projSelected && !fileFoldersSelected)
+                       return false;
+
+               // selection must be homogeneous
+               if (projSelected && fileFoldersSelected)
+                       return false;
+
+               // must have a common parent    
+               IContainer firstParent = ((IResource) selectedResources.get(0)).getParent();
+               if (firstParent == null)
+                       return false;
+
+               Iterator<?> resourcesEnum = selectedResources.iterator();
+               while (resourcesEnum.hasNext()) {
+                       IResource currentResource = (IResource) resourcesEnum.next();
+                       if (!currentResource.getParent().equals(firstParent))
+                               return false;
+                       // resource location must exist
+                       if (currentResource.getLocationURI() == null)
+                               return false;
+               }
+
+               return true;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/DefaultAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/DefaultAction.java
new file mode 100644 (file)
index 0000000..4c90350
--- /dev/null
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.cview;
+
+
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.jface.action.Action;
+import org.eclipse.swt.SWT;
+
+public class DefaultAction extends Action {
+
+       Shell shell;
+
+       DefaultAction (Shell shell, String s) {
+               super (s);
+               this.shell = shell;
+       }
+
+       @Override
+       public void run() {
+               MessageBox errorMsg = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
+               errorMsg.setText(CViewMessages.DefaultAction_WIP); 
+               errorMsg.setMessage (CViewMessages.DefaultAction_workInProgress); 
+               errorMsg.open();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/GotoActionGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/GotoActionGroup.java
new file mode 100644 (file)
index 0000000..74803f4
--- /dev/null
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.cview;
+
+import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.views.framelist.BackAction;
+import org.eclipse.ui.views.framelist.ForwardAction;
+import org.eclipse.ui.views.framelist.FrameList;
+import org.eclipse.ui.views.framelist.GoIntoAction;
+import org.eclipse.ui.views.framelist.UpAction;
+
+/**
+ * This is the action group for the goto actions.
+ */
+public class GotoActionGroup extends CViewActionGroup {
+
+       private BackAction backAction;
+       private ForwardAction forwardAction;
+       private GoIntoAction goIntoAction;
+       private UpAction upAction;
+
+       public GotoActionGroup(CView cview) {
+               super(cview);
+       }
+
+       @Override
+       public void fillContextMenu(IMenuManager menu) {
+                IStructuredSelection celements = (IStructuredSelection) getContext().getSelection();
+               IStructuredSelection selection = SelectionConverter.convertSelectionToResources(celements);
+               if (selection.size() == 1) {
+                       if (SelectionConverter.allResourcesAreOfType(selection, IResource.FOLDER)) {
+                               menu.add(goIntoAction);
+                       } else {
+                               IStructuredSelection resourceSelection = SelectionConverter.allResources(selection, IResource.PROJECT);
+                               if (resourceSelection != null && !resourceSelection.isEmpty()) {
+                                       IProject project = (IProject) resourceSelection.getFirstElement();
+                                       if (project.isOpen()) {
+                                               menu.add(goIntoAction);
+                                       }
+                               }
+                       }
+               }
+       }
+
+       @Override
+       public void fillActionBars(IActionBars actionBars) {
+               actionBars.setGlobalActionHandler(IWorkbenchActionConstants.GO_INTO, goIntoAction);
+               actionBars.setGlobalActionHandler(ActionFactory.BACK.getId(), backAction);
+               actionBars.setGlobalActionHandler(ActionFactory.FORWARD.getId(), forwardAction);
+               actionBars.setGlobalActionHandler(IWorkbenchActionConstants.UP, upAction);
+
+               IToolBarManager toolBar = actionBars.getToolBarManager();
+               toolBar.add(backAction);
+               toolBar.add(forwardAction);
+               toolBar.add(upAction);
+       }
+
+       @Override
+       protected void makeActions() {
+               FrameList frameList = getCView().getFrameList();
+               goIntoAction = new GoIntoAction(frameList);
+               backAction = new BackAction(frameList);
+               forwardAction = new ForwardAction(frameList);
+               upAction = new UpAction(frameList);
+       }
+
+       /* (non-Javadoc)
+        */
+       @Override
+       public void updateActionBars() {
+               ActionContext context = getContext();
+               boolean enable = false;
+
+               // Fix for bug 26126. Resource change listener could call
+               // updateActionBars without a context being set.
+               // This should never happen because resource navigator sets
+               // context immediately after this group is created.
+               if (context != null) {
+                       IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
+                       if (selection.size() == 1) {
+                               Object object = selection.getFirstElement();
+                               if (object instanceof IAdaptable) {
+                                       IResource resource = (IResource)((IAdaptable)object).getAdapter(IResource.class);
+                                       if (resource instanceof IProject) {
+                                               enable = ((IProject) resource).isOpen();
+                                       } else if (resource instanceof IFolder) {
+                                               enable = true;
+                                       }
+                               }
+                       }
+               }
+               goIntoAction.setEnabled(enable);
+               // the rest of the actions update by listening to frame list changes
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/IncludeRefContainer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/IncludeRefContainer.java
new file mode 100644 (file)
index 0000000..6b7aee0
--- /dev/null
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.cview;
+
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IIncludeReference;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CElementGrouping;
+
+/**
+ * IncludeRefContainer
+ */
+public class IncludeRefContainer extends CElementGrouping {
+
+       ICProject fCProject;
+
+       /**
+        * 
+        */
+       public IncludeRefContainer(ICProject cproject) {
+               super(INCLUDE_REF_CONTAINER);
+               fCProject = cproject;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+        */
+       @SuppressWarnings("rawtypes")
+       @Override
+       public Object getAdapter(Class adapter) {
+               if (adapter == IWorkbenchAdapter.class) {
+                       return this;
+               }
+               if (adapter == ICProject.class) {
+                       return fCProject;
+               }
+               return null;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
+        */
+       @Override
+       public Object[] getChildren(Object o) {
+               try {
+                       IIncludeReference[] references = fCProject.getIncludeReferences();
+                       IncludeReferenceProxy[] proxies = new IncludeReferenceProxy[references.length];
+                       for (int i = 0; i < proxies.length; ++i) {
+                               proxies[i] = new IncludeReferenceProxy(this, references[i]);
+                       }
+                       return proxies;
+               } catch (CModelException e) {
+               }
+               return NO_CHILDREN;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
+        */
+       @Override
+       public ImageDescriptor getImageDescriptor(Object object) {
+               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_INCLUDES_CONTAINER);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
+        */
+       @Override
+       public String getLabel(Object o) {
+               return CViewMessages.IncludeRefContainer_Includes;  
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
+        */
+       @Override
+       public Object getParent(Object o) {
+               return getCProject();
+       }
+
+       public ICProject getCProject() {
+               return fCProject;
+       }
+
+       /* (non-Javadoc)
+        * @see java.lang.Object#equals(java.lang.Object)
+        */
+       @Override
+       public boolean equals(Object obj) {
+               if (obj instanceof IncludeRefContainer) {
+                       IncludeRefContainer other = (IncludeRefContainer)obj;
+                       return fCProject.equals(other.getCProject());
+               }
+               return super.equals(obj);
+       }
+
+       /* (non-Javadoc)
+        * @see java.lang.Object#hashCode()
+        */
+       @Override
+       public int hashCode() {
+               if (fCProject != null) {
+                       return fCProject.hashCode();
+               }
+               return super.hashCode();
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/IncludeReferenceProxy.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/IncludeReferenceProxy.java
new file mode 100644 (file)
index 0000000..80855bb
--- /dev/null
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.cview;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.IIncludeReference;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CElementGrouping;
+
+/**
+ * @author User
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class IncludeReferenceProxy extends CElementGrouping {
+
+       IncludeRefContainer includeRefContainer;
+       IIncludeReference reference;
+       
+       public IncludeReferenceProxy(IncludeRefContainer parent, IIncludeReference reference) {
+               super(0);
+               this.reference = reference;
+               this.includeRefContainer = parent;
+       }
+
+       public IIncludeReference getReference() {
+               return reference;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
+        */
+       @Override
+       public Object[] getChildren(Object object) {
+               try {
+                       return reference.getChildren();
+               } catch (CModelException e) {
+                       // We should log the error.
+               }
+               return NO_CHILDREN;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
+        */
+       @Override
+       public ImageDescriptor getImageDescriptor(Object object) {
+               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
+        */
+       @Override
+       public Object getParent(Object object) {
+               return getIncludeRefContainer();
+       }
+
+       public IncludeRefContainer getIncludeRefContainer() {
+               return includeRefContainer;
+       }
+
+       /* (non-Javadoc)
+        * @see java.lang.Object#equals(java.lang.Object)
+        */
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj) {
+                       return true;
+               }
+               if (!(obj instanceof IncludeReferenceProxy)) {
+                       return false;
+               }
+               IncludeReferenceProxy other = (IncludeReferenceProxy) obj;
+               return reference.equals(other.reference);
+       }
+
+       /*
+        * @see java.lang.Object#hashCode()
+        */
+       @Override
+       public int hashCode() {
+               return reference.hashCode();
+       }
+       
+       /* (non-Javadoc)
+        * @see java.lang.Object#toString()
+        */
+       @Override
+       public String toString() {
+               return reference.toString();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/LibraryRefContainer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/LibraryRefContainer.java
new file mode 100644 (file)
index 0000000..1abcb89
--- /dev/null
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.cview;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ILibraryReference;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CElementGrouping;
+
+/**
+ * VirtualGrouping
+ */
+public class LibraryRefContainer extends CElementGrouping {
+
+       private Object[] EMPTY = new Object[0];
+       private ICProject fCProject;
+
+       /**
+        * 
+        */
+       public LibraryRefContainer(ICProject cproject) {
+               super(LIBRARY_REF_CONTAINER);
+               fCProject = cproject;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+        */
+       @SuppressWarnings("rawtypes")
+       @Override
+       public Object getAdapter(Class adapter) {
+               if (adapter == IWorkbenchAdapter.class) {
+                       return this;
+               }
+               if (adapter == ICProject.class) {
+                       return fCProject;
+               }
+               return null;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
+        */
+       @Override
+       public Object[] getChildren(Object o) {
+               try {
+                       ILibraryReference[] references = fCProject.getLibraryReferences();
+                       ArrayList<ILibraryReference> list = new ArrayList<ILibraryReference>(references.length);
+                       for (ILibraryReference reference : references) {
+                               IPath path = reference.getPath();
+                               IFile file = reference.getCModel().getWorkspace().getRoot().getFileForLocation(path);
+                               if (file == null || !file.isAccessible()) {
+                                       list.add(reference);
+                               }
+                       }
+                       return list.toArray();
+               } catch (CModelException e) {
+               }
+               return EMPTY;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
+        */
+       @Override
+       public ImageDescriptor getImageDescriptor(Object object) {
+               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_LIBRARY);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
+        */
+       @Override
+       public String getLabel(Object o) {
+               return CViewMessages.LibraryRefContainer_Libraries; 
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
+        */
+       @Override
+       public Object getParent(Object o) {
+               return getCProject();
+       }
+
+       public ICProject getCProject() {
+               return fCProject;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/MainActionGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/MainActionGroup.java
new file mode 100644 (file)
index 0000000..fbc2489
--- /dev/null
@@ -0,0 +1,381 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.cview;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.actions.AddBookmarkAction;
+import org.eclipse.ui.actions.AddTaskAction;
+import org.eclipse.ui.actions.ExportResourcesAction;
+import org.eclipse.ui.actions.ImportResourcesAction;
+import org.eclipse.ui.actions.NewWizardMenu;
+import org.eclipse.ui.actions.WorkingSetFilterActionGroup;
+import org.eclipse.ui.ide.IDEActionFactory;
+
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.actions.CustomFiltersActionGroup;
+import org.eclipse.cdt.ui.actions.OpenViewActionGroup;
+import org.eclipse.cdt.ui.refactoring.actions.CRefactoringActionGroup;
+
+import org.eclipse.cdt.internal.ui.IContextMenuConstants;
+import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
+import org.eclipse.cdt.internal.ui.editor.OpenIncludeAction;
+import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
+
+/**
+ * The main action group for the cview. This contains a few actions and several
+ * subgroups.
+ */
+public class MainActionGroup extends CViewActionGroup {
+
+       // Actions for Menu context.
+       AddBookmarkAction addBookmarkAction;
+       AddTaskAction addTaskAction;
+
+       ImportResourcesAction importAction;
+       ExportResourcesAction exportAction;
+
+       // CElement action
+       OpenIncludeAction openIncludeAction;
+
+       // Collapsing
+       CollapseAllAction collapseAllAction;
+       ToggleLinkingAction toggleLinkingAction;
+
+
+       BuildGroup buildGroup;
+       OpenFileGroup openFileGroup;
+       GotoActionGroup gotoGroup;
+       RefactorActionGroup refactorGroup;
+       OpenProjectGroup openProjectGroup;
+       WorkingSetFilterActionGroup workingSetGroup;
+       CustomFiltersActionGroup fCustomFiltersActionGroup;     
+
+       SelectionSearchGroup selectionSearchGroup;
+
+       OpenViewActionGroup openViewActionGroup;        
+       CRefactoringActionGroup crefactoringActionGroup;
+       
+    private NewWizardMenu newWizardMenu;
+
+       public MainActionGroup(CView cview) {
+               super(cview);
+       }
+
+       /**
+        * Handles key events in viewer.
+        */
+       @Override
+       public void handleKeyPressed(KeyEvent event) {
+               refactorGroup.handleKeyPressed(event);
+               openFileGroup.handleKeyPressed(event);
+               openProjectGroup.handleKeyPressed(event);
+               gotoGroup.handleKeyPressed(event);
+               buildGroup.handleKeyPressed(event);
+       }
+
+       /**
+        * Handles key events in viewer.
+        */
+       @Override
+       public void handleKeyReleased(KeyEvent event) {
+               refactorGroup.handleKeyReleased(event);
+               openFileGroup.handleKeyReleased(event);
+               openProjectGroup.handleKeyReleased(event);
+               gotoGroup.handleKeyReleased(event);
+               buildGroup.handleKeyReleased(event);
+       }
+
+       @Override
+       protected void makeActions() {
+               final Viewer viewer = getCView().getViewer();
+               IShellProvider shellProvider = getCView().getViewSite();
+               Shell shell = shellProvider.getShell();
+
+               openFileGroup = new OpenFileGroup(getCView());
+               openProjectGroup = new OpenProjectGroup(getCView());
+               gotoGroup = new GotoActionGroup(getCView());
+               buildGroup = new BuildGroup(getCView());
+               refactorGroup = new RefactorActionGroup(getCView());
+
+        newWizardMenu = new NewWizardMenu(getCView().getSite().getWorkbenchWindow());
+
+               openIncludeAction = new OpenIncludeAction(viewer);
+
+               //sortByNameAction = new SortViewAction(this, false);
+               //sortByTypeAction = new SortViewAction(this, true);
+
+               IPropertyChangeListener workingSetUpdater = new IPropertyChangeListener() {
+                       public void propertyChange(PropertyChangeEvent event) {
+                               String property = event.getProperty();
+                                 
+                               if (WorkingSetFilterActionGroup.CHANGE_WORKING_SET.equals(property)) {
+                                       Object newValue = event.getNewValue();
+                                         
+                                       if (newValue instanceof IWorkingSet) {
+                                               getCView().setWorkingSet((IWorkingSet) newValue);
+                                       } else if (newValue == null) {
+                                               getCView().setWorkingSet(null);
+                                       }
+                               }
+                       }
+               };
+               workingSetGroup = new WorkingSetFilterActionGroup(shell, workingSetUpdater);
+               workingSetGroup.setWorkingSet(getCView().getWorkingSet());
+               fCustomFiltersActionGroup= new CustomFiltersActionGroup(getCView(), getCView().getViewer());
+
+               addBookmarkAction = new AddBookmarkAction(shellProvider, true);
+               addTaskAction = new AddTaskAction(shellProvider);
+
+               // Importing/exporting.
+               importAction = new ImportResourcesAction(getCView().getSite().getWorkbenchWindow());
+               exportAction = new ExportResourcesAction(getCView().getSite().getWorkbenchWindow());
+
+               collapseAllAction = new CollapseAllAction(getCView());
+
+               toggleLinkingAction = new ToggleLinkingAction(getCView()); 
+               toggleLinkingAction.setImageDescriptor(getImageDescriptor("elcl16/synced.gif"));//$NON-NLS-1$
+//             toggleLinkingAction.setHoverImageDescriptor(getImageDescriptor("clcl16/synced.gif"));//$NON-NLS-1$
+
+               selectionSearchGroup = new SelectionSearchGroup(getCView().getSite());
+               openViewActionGroup= new OpenViewActionGroup(getCView());
+               crefactoringActionGroup= new CRefactoringActionGroup(getCView());
+       }
+
+       /**
+        * Called when the context menu is about to open. Override to add your own
+        * context dependent menu contributions.
+        */
+       @Override
+       public void fillContextMenu(IMenuManager menu) {
+               IStructuredSelection celements = (IStructuredSelection) getCView().getViewer().getSelection();
+               IStructuredSelection resources = SelectionConverter.convertSelectionToResources(celements);
+
+               addNewMenu(menu, resources);
+
+               if (resources.isEmpty()) {
+                       menu.add(new Separator(IContextMenuConstants.GROUP_GOTO));
+                       menu.add(new Separator(IContextMenuConstants.GROUP_OPEN));
+                       menu.add(new Separator(IContextMenuConstants.GROUP_BUILD));
+                       menu.add(new Separator(IContextMenuConstants.GROUP_REORGANIZE));
+                       menu.add(new Separator("group.private1")); //$NON-NLS-1$
+                       importAction.selectionChanged(resources);
+                       menu.add(importAction);
+                       exportAction.selectionChanged(resources);
+                       menu.add(exportAction);
+                       menu.add(new Separator("group.private2")); //$NON-NLS-1$
+                       //Can be added once support for manually adding external files to index is established
+                       /*menu.add(new Separator());
+                       menu.add(addToIndexAction);*/
+                       menu.add(new Separator(IContextMenuConstants.GROUP_SEARCH));
+                       addSearchMenu(menu, celements);
+                       menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
+                       menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS + "-end")); //$NON-NLS-1$
+                       menu.add(new Separator(IContextMenuConstants.GROUP_PROPERTIES));
+
+                       openViewActionGroup.fillContextMenu(menu);
+                       crefactoringActionGroup.fillContextMenu(menu);
+
+                       if (OpenIncludeAction.canActionBeAdded(celements)) {
+                               menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, openIncludeAction);
+                       }
+
+                       return;
+               }
+
+               menu.add(new Separator(IContextMenuConstants.GROUP_GOTO));
+               gotoGroup.fillContextMenu(menu);
+               menu.add(new Separator(IContextMenuConstants.GROUP_OPEN));
+               openFileGroup.fillContextMenu(menu);
+               menu.add(new Separator(IContextMenuConstants.GROUP_BUILD));
+               buildGroup.fillContextMenu(menu);
+               menu.add(new Separator(IContextMenuConstants.GROUP_REORGANIZE));
+               refactorGroup.fillContextMenu(menu);
+               menu.add(new Separator("group.private1")); //$NON-NLS-1$
+               importAction.selectionChanged(resources);
+               menu.add(importAction);
+               exportAction.selectionChanged(resources);
+               menu.add(exportAction);
+               menu.add(new Separator("group.private2")); //$NON-NLS-1$
+               openProjectGroup.fillContextMenu(menu);
+               addBookMarkMenu(menu, resources);
+               menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
+               menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS + "-end")); //$NON-NLS-1$
+               menu.add(new Separator(IContextMenuConstants.GROUP_PROPERTIES));
+               
+               openViewActionGroup.fillContextMenu(menu);
+               crefactoringActionGroup.fillContextMenu(menu);
+       }
+       /**
+        * Extends the superclass implementation to set the context in the
+        * subgroups.
+        */
+       @Override
+       public void setContext(ActionContext context) {
+               super.setContext(context);
+               gotoGroup.setContext(context);
+               openFileGroup.setContext(context);
+               openProjectGroup.setContext(context);
+               refactorGroup.setContext(context);
+               buildGroup.setContext(context);
+               openViewActionGroup.setContext(context);
+               crefactoringActionGroup.setContext(context);
+               //sortAndFilterGroup.setContext(context);
+               //workspaceGroup.setContext(context);
+       }
+
+       void addNewMenu(IMenuManager menu, IStructuredSelection selection) {
+               MenuManager newMenu = new MenuManager(CViewMessages.NewWizardsActionGroup_new); 
+        menu.add(newMenu);
+        newMenu.add(newWizardMenu);
+       }
+
+       void addBookMarkMenu(IMenuManager menu, IStructuredSelection selection) {
+               Object obj = selection.getFirstElement();
+               if (obj instanceof IAdaptable) {
+                       IAdaptable element = (IAdaptable) obj;
+                       IResource resource = (IResource) element.getAdapter(IResource.class);
+                       if (resource instanceof IFile) {
+                               addBookmarkAction.selectionChanged(selection);
+                               menu.add(addBookmarkAction);
+                       }
+               }
+       }
+
+       void addSearchMenu(IMenuManager menu, IStructuredSelection selection) {
+               IAdaptable element = (IAdaptable) selection.getFirstElement();
+
+               if (element instanceof ITranslationUnit || element instanceof ICProject) {
+                       return;
+               }
+
+               if (SelectionSearchGroup.canActionBeAdded(selection)){
+                       selectionSearchGroup.fillContextMenu(menu);
+               }
+       }
+       
+       @Override
+       public void runDefaultAction(IStructuredSelection selection) {
+               openFileGroup.runDefaultAction(selection);
+               openProjectGroup.runDefaultAction(selection);
+               gotoGroup.runDefaultAction(selection);
+               buildGroup.runDefaultAction(selection);
+               refactorGroup.runDefaultAction(selection);
+               //workingSetGroup.runDefaultAction(selection);
+       }
+
+       /**
+        * Updates all actions with the given selection. Necessary when popping up
+        * a menu, because some of the enablement criteria may have changed, even
+        * if the selection in the viewer hasn't. E.g. A project was opened or
+        * closed.
+        */
+       @Override
+       public void updateActionBars() {
+               IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
+
+               //sortByTypeAction.selectionChanged(selection);
+               //sortByNameAction.selectionChanged(selection);
+               addBookmarkAction.selectionChanged(selection);
+               addTaskAction.selectionChanged(selection);
+
+               openFileGroup.updateActionBars();
+               openProjectGroup.updateActionBars();
+               gotoGroup.updateActionBars();
+               buildGroup.updateActionBars();
+               refactorGroup.updateActionBars();
+               workingSetGroup.updateActionBars();
+               fCustomFiltersActionGroup.updateActionBars();
+
+               openViewActionGroup.updateActionBars();
+               crefactoringActionGroup.updateActionBars();
+       }
+
+       @Override
+       public void fillActionBars(IActionBars actionBars) {
+               actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), addBookmarkAction);
+               actionBars.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), addTaskAction);
+
+               workingSetGroup.fillActionBars(actionBars);
+               fCustomFiltersActionGroup.fillActionBars(actionBars);
+               gotoGroup.fillActionBars(actionBars);
+               refactorGroup.fillActionBars(actionBars);
+               openFileGroup.fillActionBars(actionBars);
+               openProjectGroup.fillActionBars(actionBars);
+               buildGroup.fillActionBars(actionBars);
+
+               openViewActionGroup.fillActionBars(actionBars);
+               crefactoringActionGroup.fillActionBars(actionBars);
+               
+               IToolBarManager toolBar = actionBars.getToolBarManager();
+               toolBar.add(new Separator());
+               toolBar.add(collapseAllAction);
+               toolBar.add(toggleLinkingAction);
+
+               IMenuManager menu = actionBars.getMenuManager();
+               //menu.add (clibFilterAction);
+               //menu.add(fCustomFiltersActionGroup);
+               menu.add(toggleLinkingAction);
+       }
+
+       //---- Persistent state -----------------------------------------------------------------------
+
+       @Override
+       public void restoreFilterAndSorterState(IMemento memento) {
+               //fWorkingSetFilterActionGroup.restoreState(memento);
+               fCustomFiltersActionGroup.restoreState(memento);
+       }
+       
+       @Override
+       public void saveFilterAndSorterState(IMemento memento) {
+               //fWorkingSetFilterActionGroup.saveState(memento);
+               fCustomFiltersActionGroup.saveState(memento);
+       }
+
+       public CustomFiltersActionGroup getCustomFilterActionGroup() {
+           return fCustomFiltersActionGroup;
+       }
+
+       @Override
+       public void dispose() {
+               importAction.dispose();
+               exportAction.dispose();
+               refactorGroup.dispose();
+               openFileGroup.dispose();
+               openProjectGroup.dispose();
+               gotoGroup.dispose();
+               buildGroup.dispose();
+               newWizardMenu.dispose();
+               openViewActionGroup.dispose();
+               crefactoringActionGroup.dispose();
+               super.dispose();
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/OpenFileGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/OpenFileGroup.java
new file mode 100644 (file)
index 0000000..2f81a17
--- /dev/null
@@ -0,0 +1,170 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.cview;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.actions.OpenFileAction;
+import org.eclipse.ui.actions.OpenInNewWindowAction;
+import org.eclipse.ui.actions.OpenWithMenu;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+
+/**
+ * This is the action group for the open actions.
+ */
+public class OpenFileGroup extends CViewActionGroup {
+
+       private OpenFileAction openFileAction;
+
+       public OpenFileGroup(CView cview) {
+               super(cview);
+       }
+
+       @Override
+       protected void makeActions() {
+               openFileAction = new OpenFileAction(getCView().getSite().getPage());
+       }
+
+       @Override
+       public void fillContextMenu(IMenuManager menu) {
+                IStructuredSelection celements = (IStructuredSelection) getContext().getSelection();
+               IStructuredSelection selection = SelectionConverter.convertSelectionToResources(celements);
+               boolean anyResourceSelected = !selection.isEmpty()
+                               && SelectionConverter.allResourcesAreOfType(selection, IResource.PROJECT | IResource.FOLDER | IResource.FILE);
+               boolean onlyFilesSelected = !selection.isEmpty() && SelectionConverter.allResourcesAreOfType(selection, IResource.FILE);
+
+               if (onlyFilesSelected) {
+                       openFileAction.selectionChanged(selection);
+                       menu.add(openFileAction);
+                       fillOpenWithMenu(menu, selection);
+               }
+
+               if (anyResourceSelected) {
+                       addNewWindowAction(menu, selection);
+               }
+       }
+
+       /**
+        * Adds the OpenWith submenu to the context menu.
+        * 
+        * @param menu
+        *            the context menu
+        * @param selection
+        *            the current selection
+        */
+       private void fillOpenWithMenu(IMenuManager menu, IStructuredSelection selection) {
+               // Only supported if exactly one file is selected.
+               if (selection.size() != 1) {
+                       return;
+               }
+               Object element = selection.getFirstElement();
+               if (!(element instanceof IFile)) {
+                       return;
+               }
+
+               MenuManager submenu = new MenuManager(CViewMessages.OpenWithMenu_label); 
+               submenu.add(new OpenWithMenu(getCView().getSite().getPage(), (IFile) element));
+               menu.add(submenu);
+       }
+
+       /**
+        * Adds the Open in New Window action to the context menu.
+        * 
+        * @param menu
+        *            the context menu
+        * @param selection
+        *            the current selection
+        */
+       private void addNewWindowAction(IMenuManager menu, IStructuredSelection selection) {
+
+               // Only supported if exactly one container (i.e open project or folder) is selected.
+               if (selection.size() != 1) {
+                       return;
+               }
+               Object element = selection.getFirstElement();
+               if (!(element instanceof IContainer)) {
+                       return;
+               }
+               if (element instanceof IProject && !(((IProject) element).isOpen())) {
+                       return;
+               }
+
+               menu.add(new OpenInNewWindowAction(getCView().getSite().getWorkbenchWindow(), (IContainer) element));
+       }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars)
+     */
+    @Override
+       public void fillActionBars(IActionBars actionBars) {
+    }
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.actions.ActionGroup#updateActionBars()
+     */
+    @Override
+       public void updateActionBars() {
+    }
+
+       /**
+        * Runs the default action (open file).
+        */
+       @Override
+       public void runDefaultAction(IStructuredSelection selection) {
+               Object obj = selection.getFirstElement();
+               if (obj instanceof ICElement) {
+                       ICElement celement = (ICElement) obj;
+                       //System.out.println ("Double click on " + element);
+                       try {
+                               IEditorPart part = EditorUtility.openInEditor(celement);
+                               if (part != null) {
+                                       IWorkbenchPage page = getCView().getSite().getPage();
+                                       page.bringToTop(part);
+                                       if (celement instanceof ISourceReference && !(celement instanceof ITranslationUnit)) {
+                                               EditorUtility.revealInEditor(part, celement);
+                                       }
+                               }
+                       } catch (Exception e) {
+                       }
+               } else if (obj instanceof IAdaptable) {
+                       IResource element = (IResource)((IAdaptable)obj).getAdapter(IResource.class);
+                       if (element instanceof IFile) {
+                               openFileAction.selectionChanged(selection);
+                               openFileAction.run();
+                       }
+                       else if(element instanceof IProject){
+                               try {
+                                       ((IProject)element).open(null);
+                               } catch (CoreException e) {
+                                       CUIPlugin.log(e);
+                               }
+                       }
+               }
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/OpenProjectGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/OpenProjectGroup.java
new file mode 100644 (file)
index 0000000..2fee3f2
--- /dev/null
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.cview;
+
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.CloseResourceAction;
+import org.eclipse.ui.actions.OpenResourceAction;
+import org.eclipse.ui.actions.RefreshAction;
+import org.eclipse.ui.ide.IDEActionFactory;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * This is the action group for actions such as Refresh Local, and Open/Close
+ * Project.
+ */
+public class OpenProjectGroup extends CViewActionGroup {
+
+       private OpenResourceAction openProjectAction;
+       private CloseResourceAction closeProjectAction;
+       private RefreshAction refreshAction;
+
+       public OpenProjectGroup(CView cview) {
+               super(cview);
+       }
+
+       @Override
+       public void fillActionBars(IActionBars actionBars) {
+               actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), refreshAction);
+               actionBars.setGlobalActionHandler(IDEActionFactory.OPEN_PROJECT.getId(), openProjectAction);
+               actionBars.setGlobalActionHandler(IDEActionFactory.CLOSE_PROJECT.getId(), closeProjectAction);
+       }
+
+       /**
+        * Adds the open project, close project and refresh resource actions to the
+        * context menu.
+        * <p>
+        * refresh-no closed project selected
+        * </p>
+        * <p>
+        * Both the open project and close project action may be on the menu at the
+        * same time.
+        * </p>
+        * <p>
+        * No disabled action should be on the context menu.
+        * </p>
+        * 
+        * @param menu
+        *            context menu to add actions to
+        */
+       @Override
+       public void fillContextMenu(IMenuManager menu) {
+               IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
+               boolean isProjectSelection = true;
+               boolean hasOpenProjects = false;
+               boolean hasClosedProjects = false;
+               Iterator<?> resources = selection.iterator();
+
+               while (resources.hasNext() && (!hasOpenProjects || !hasClosedProjects || isProjectSelection)) {
+                       Object next = resources.next();
+                       IProject project = null;
+
+                       if (next instanceof IProject) {
+                               project = (IProject) next;
+                       } else if (next instanceof IAdaptable) {
+                               IResource res = (IResource) ((IAdaptable) next).getAdapter(IResource.class);
+                               if (res instanceof IProject) {
+                                       project = (IProject)res;
+                               }
+                       }
+
+                       if (project == null) {
+                               isProjectSelection = false;
+                               continue;
+                       }
+                       if (project.isOpen()) {
+                               hasOpenProjects = true;
+                       } else {
+                               hasClosedProjects = true;
+                       }
+               }
+               if (!hasClosedProjects) {
+                       refreshAction.selectionChanged(selection);
+                       menu.add(refreshAction);
+               }
+               if (isProjectSelection) {
+                       if (hasClosedProjects) {
+                               openProjectAction.selectionChanged(selection);
+                               menu.add(openProjectAction);
+                       }
+                       if (hasOpenProjects) {
+                               closeProjectAction.selectionChanged(selection);
+                               menu.add(closeProjectAction);
+                       }
+               }
+       }
+
+       /**
+        * Handles a key pressed event by invoking the appropriate action.
+        */
+       @Override
+       public void handleKeyPressed(KeyEvent event) {
+               if (event.keyCode == SWT.F5 && event.stateMask == 0) {
+                       if (refreshAction.isEnabled()) {
+                               refreshAction.refreshAll();
+                       }
+                       // Swallow the event
+                       event.doit = false;
+               }
+       }
+
+       @Override
+       protected void makeActions() {
+               final IWorkbenchPartSite site= getCView().getSite();
+               IWorkspace workspace = CUIPlugin.getWorkspace();
+
+               openProjectAction = new OpenResourceAction(site);
+               workspace.addResourceChangeListener(openProjectAction, IResourceChangeEvent.POST_CHANGE);
+               closeProjectAction = new CloseResourceAction(site);
+               workspace.addResourceChangeListener(closeProjectAction, IResourceChangeEvent.POST_CHANGE);
+               refreshAction = new RefreshAction(site);
+               refreshAction.setDisabledImageDescriptor(getImageDescriptor("dlcl16/refresh_nav.gif"));//$NON-NLS-1$
+               refreshAction.setImageDescriptor(getImageDescriptor("elcl16/refresh_nav.gif"));//$NON-NLS-1$
+//             refreshAction.setHoverImageDescriptor(getImageDescriptor("clcl16/refresh_nav.gif"));//$NON-NLS-1$               
+       }
+
+       @Override
+       public void updateActionBars() {
+               IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
+               refreshAction.selectionChanged(selection);
+               openProjectAction.selectionChanged(selection);
+               closeProjectAction.selectionChanged(selection);
+       }
+
+       @Override
+       public void dispose() {
+               IWorkspace workspace = CUIPlugin.getWorkspace();
+               workspace.removeResourceChangeListener(closeProjectAction);
+               workspace.removeResourceChangeListener(openProjectAction);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/PasteAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/PasteAction.java
new file mode 100644 (file)
index 0000000..90b2dbf
--- /dev/null
@@ -0,0 +1,237 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.cview;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.FileTransfer;
+import org.eclipse.swt.dnd.TransferData;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.CopyFilesAndFoldersOperation;
+import org.eclipse.ui.actions.CopyProjectOperation;
+import org.eclipse.ui.actions.SelectionListenerAction;
+import org.eclipse.ui.part.ResourceTransfer;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+
+/**
+ * Standard action for pasting resources on the clipboard to the selected resource's location.
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ * 
+ * @since 2.0
+ */
+/*package*/
+public class PasteAction extends SelectionListenerAction {
+
+       /**
+        * The id of this action.
+        */
+       public static final String ID = PlatformUI.PLUGIN_ID + ".PasteAction"; //$NON-NLS-1$
+
+       /**
+        * The shell in which to show any dialogs.
+        */
+       private Shell shell;
+
+       /**
+        * System clipboard
+        */
+       Clipboard clipboard;
+
+       /**
+        * Creates a new action.
+        *
+        * @param shell the shell for any dialogs
+        */
+       public PasteAction(Shell shell, Clipboard clipboard) {
+               super(CViewMessages.PasteAction_title); 
+               Assert.isNotNull(shell);
+               Assert.isNotNull(clipboard);
+               this.shell = shell;
+               this.clipboard = clipboard;
+               setToolTipText(CViewMessages.PasteAction_toolTip); 
+               setId(PasteAction.ID);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.PASTE_ACTION);
+       }
+       /**
+        * Returns the actual target of the paste action. Returns null
+        * if no valid target is selected.
+        * 
+        * @return the actual target of the paste action
+        */
+       private IResource getTarget() {
+               List<?> selectedResources = getSelectedResources();
+
+               for (int i = 0; i < selectedResources.size(); i++) {
+                       IResource resource = (IResource) selectedResources.get(i);
+
+                       if (resource instanceof IProject && !((IProject) resource).isOpen())
+                               return null;
+                       if (resource.getType() == IResource.FILE)
+                               resource = resource.getParent();
+                       if (resource != null)
+                               return resource;
+               }
+               return null;
+       }
+       /**
+        * Returns whether any of the given resources are linked resources.
+        * 
+        * @param resources resource to check for linked type. may be null
+        * @return true=one or more resources are linked. false=none of the 
+        *      resources are linked
+        */
+       private boolean isLinked(IResource[] resources) {
+               if (resources != null) {
+                       for (int i = 0; i < resources.length; i++) {
+                               if (resources[i].isLinked()) {
+                                       return true;
+                               }
+                       }
+               }
+               return false;
+       }
+       /**
+        * Implementation of method defined on <code>IAction</code>.
+        */
+       @Override
+       public void run() {
+               // try a resource transfer
+               ResourceTransfer resTransfer = ResourceTransfer.getInstance();
+               IResource[] resourceData = (IResource[]) clipboard.getContents(resTransfer);
+
+               if (resourceData != null && resourceData.length > 0) {
+                       if (resourceData[0].getType() == IResource.PROJECT) {
+                               // enablement checks for all projects
+                               for (int i = 0; i < resourceData.length; i++) {
+                                       CopyProjectOperation operation = new CopyProjectOperation(this.shell);
+                                       operation.copyProject((IProject) resourceData[i]);
+                               }
+                       } else {
+                               // enablement should ensure that we always have access to a container
+                               IContainer container = getContainer();
+
+                               CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(this.shell);
+                               operation.copyResources(resourceData, container);
+                       }
+                       return;
+               }
+
+               // try a file transfer
+               FileTransfer fileTransfer = FileTransfer.getInstance();
+               String[] fileData = (String[]) clipboard.getContents(fileTransfer);
+
+               if (fileData != null) {
+                       // enablement should ensure that we always have access to a container
+                       IContainer container = getContainer();
+
+                       CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(this.shell);
+                       operation.copyFiles(fileData, container);
+               }
+       }
+       /**
+        * Returns the container to hold the pasted resources.
+        */
+       private IContainer getContainer() {
+               List<?> selection = getSelectedResources();
+               if (selection.get(0) instanceof IFile)
+                       return ((IFile) selection.get(0)).getParent();
+               return (IContainer) selection.get(0);
+       }
+       /**
+        * The <code>PasteAction</code> implementation of this
+        * <code>SelectionListenerAction</code> method enables this action if 
+        * a resource compatible with what is on the clipboard is selected.
+        */
+       @Override
+       protected boolean updateSelection(IStructuredSelection selection) {
+               if (!super.updateSelection(selection))
+                       return false;
+
+               final IResource[][] clipboardData = new IResource[1][];
+               shell.getDisplay().syncExec(new Runnable() {
+                       public void run() {
+                               // clipboard must have resources or files
+                               ResourceTransfer resTransfer = ResourceTransfer.getInstance();
+                               clipboardData[0] = (IResource[])clipboard.getContents(resTransfer);
+                       }
+               });
+               IResource[] resourceData = clipboardData[0];
+               if (resourceData != null && resourceData.length > 0     && resourceData[0].getType() == IResource.PROJECT) {
+                       for (int i = 0; i < resourceData.length; i++) {
+                               // make sure all resource data are open projects
+                               // can paste open projects regardless of selection
+                               if (resourceData[i].getType() != IResource.PROJECT || ((IProject) resourceData[i]).isOpen() == false)
+                                       return false;
+                       }
+                       return true;
+               }
+
+               // can paste files and folders to a single selection (project must be open)
+               // or multiple file selection with the same parent
+               if (getSelectedNonResources().size() > 0)
+                       return false;
+
+               // targetResource is null if no valid target is selected or 
+               // selection is empty   
+               IResource targetResource = getTarget();
+               if (targetResource == null)
+                       return false;
+
+               // can paste files and folders to a single selection (file, folder,
+               // open project) or multiple file selection with the same parent
+               List<?> selectedResources = getSelectedResources();
+               if (selectedResources.size() > 1) {
+                       // if more than one resource is selected the selection has 
+                       // to be all files with the same parent
+                       for (int i = 0; i < selectedResources.size(); i++) {
+                               IResource resource = (IResource) selectedResources.get(i);
+                               if (resource.getType() != IResource.FILE)
+                                       return false;
+                               if (!targetResource.equals(resource.getParent()))
+                                       return false;
+                       }
+               }
+
+               if (resourceData != null) {
+                       // linked resources can only be pasted into projects
+                       if (isLinked(resourceData) && targetResource.getType() != IResource.PROJECT)
+                               return false;
+
+                       if (targetResource.getType() == IResource.FOLDER) {
+                               // don't try to copy folder to self
+                               for (int i = 0; i < resourceData.length; i++) {
+                                       if (targetResource.equals(resourceData[i]))
+                                               return false;
+                               }
+                       }
+                       return true;
+               }
+
+               TransferData[] transfers = clipboard.getAvailableTypes();
+               FileTransfer fileTransfer = FileTransfer.getInstance();
+               for (int i = 0; i < transfers.length; i++) {
+                       if (fileTransfer.isSupportedType(transfers[i]))
+                               return true;
+               }
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/RefactorActionGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/RefactorActionGroup.java
new file mode 100644 (file)
index 0000000..b035163
--- /dev/null
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.cview;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.DeleteResourceAction;
+import org.eclipse.ui.actions.TextActionHandler;
+
+import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
+
+/**
+ * This is the action group for refactor actions,
+ * including global action handlers for copy, paste and delete.
+ * 
+ */
+public class RefactorActionGroup extends CViewActionGroup {
+
+       private Clipboard clipboard;
+
+       private CopyAction copyAction;
+       private DeleteResourceAction deleteAction;
+       private PasteAction pasteAction;
+       private CViewRenameAction renameAction;
+       private CViewMoveAction moveAction;
+       private TextActionHandler textActionHandler;
+       
+       public RefactorActionGroup(CView cview) {
+               super(cview);
+       }
+
+       @Override
+       public void dispose() {
+               if (clipboard != null) {
+                       clipboard.dispose();
+                       clipboard = null;
+               }
+               super.dispose();
+       }
+
+       @Override
+       public void fillContextMenu(IMenuManager menu) {
+               IStructuredSelection celements = (IStructuredSelection) getContext().getSelection();
+               IStructuredSelection selection = SelectionConverter.convertSelectionToResources(celements);
+
+               boolean anyResourceSelected = !selection.isEmpty()
+                               && SelectionConverter.allResourcesAreOfType(selection, IResource.PROJECT | IResource.FOLDER | IResource.FILE);
+
+               copyAction.selectionChanged(selection);
+               menu.add(copyAction);
+               pasteAction.selectionChanged(selection);
+               menu.add(pasteAction);
+
+               if (anyResourceSelected) {
+                       deleteAction.selectionChanged(selection);
+                       menu.add(deleteAction);
+                       moveAction.selectionChanged(selection);
+                       menu.add(moveAction);
+                       renameAction.selectionChanged(selection);
+                       menu.add(renameAction);
+               }
+       }
+
+       @Override
+       public void fillActionBars(IActionBars actionBars) {
+               textActionHandler = new TextActionHandler(actionBars); // hooks handlers
+               textActionHandler.setCopyAction(copyAction);
+               textActionHandler.setPasteAction(pasteAction);
+               textActionHandler.setDeleteAction(deleteAction);
+               renameAction.setTextActionHandler(textActionHandler);
+               
+               actionBars.setGlobalActionHandler(ActionFactory.MOVE.getId(), moveAction);
+               actionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(), renameAction);
+       }
+
+       /**
+        * Handles a key pressed event by invoking the appropriate action.
+        */
+       @Override
+       public void handleKeyPressed(KeyEvent event) {
+               if (event.character == SWT.DEL && event.stateMask == 0) {
+                       if (deleteAction.isEnabled()) {
+                               deleteAction.run();
+                       }
+                       // Swallow the event.
+                       event.doit = false;
+               } else if (event.keyCode == SWT.F2 && event.stateMask == 0) {
+                       if (renameAction.isEnabled()) {
+                               renameAction.run();
+                       }
+                       // Swallow the event.
+                       event.doit = false;                     
+               }
+       }
+
+       @Override
+       protected void makeActions() {
+               TreeViewer treeViewer = getCView().getViewer();
+               final IWorkbenchPartSite site = getCView().getSite();
+               Shell shell = site.getShell();
+               clipboard = new Clipboard(shell.getDisplay());
+               
+               pasteAction = new PasteAction(shell, clipboard);
+               ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
+               pasteAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED));
+               pasteAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
+               pasteAction.setHoverImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
+
+               copyAction = new CopyAction(shell, clipboard, pasteAction);
+               copyAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED));
+               copyAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
+               copyAction.setHoverImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
+               
+               moveAction = new CViewMoveAction(site, treeViewer);
+               renameAction = new CViewRenameAction(site, treeViewer);
+               
+               deleteAction = new DeleteResourceAction(site);
+               deleteAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
+               deleteAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));              
+               deleteAction.setHoverImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
+       }
+
+       @Override
+       public void updateActionBars() {
+               IStructuredSelection celements = (IStructuredSelection) getContext().getSelection();
+               IStructuredSelection selection = SelectionConverter.convertSelectionToResources(celements);
+
+               copyAction.selectionChanged(selection);
+               pasteAction.selectionChanged(selection);
+               deleteAction.selectionChanged(selection);
+               moveAction.selectionChanged(selection);
+               renameAction.selectionChanged(selection);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/SelectionTransferDragAdapter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/SelectionTransferDragAdapter.java
new file mode 100644 (file)
index 0000000..d2f9976
--- /dev/null
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.cview;
+
+import java.util.Iterator;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ISourceReference;
+
+import org.eclipse.cdt.internal.ui.dnd.BasicSelectionTransferDragAdapter;
+
+public class SelectionTransferDragAdapter extends BasicSelectionTransferDragAdapter {
+       
+       public SelectionTransferDragAdapter(ISelectionProvider provider) {
+               super(provider);
+       }
+       
+       @Override
+       protected boolean isDragable(ISelection selection) {
+               if (selection instanceof IStructuredSelection) {
+                       for (Iterator<?> iter= ((IStructuredSelection)selection).iterator(); iter.hasNext();) {
+                               Object element= iter.next();
+                               if (element instanceof ICElement) {
+                                       if (!(element instanceof ISourceReference)) {
+                                               return  false;
+                                       }
+                               }
+                       }
+                       return true;
+               }
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/SelectionTransferDropAdapter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/SelectionTransferDropAdapter.java
new file mode 100644 (file)
index 0000000..d40789b
--- /dev/null
@@ -0,0 +1,342 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ * Anton Leherbauer (Wind River Systems) - Fixed bug 141484
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.cview;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+import org.eclipse.cdt.internal.ui.dnd.CDTViewerDropAdapter;
+import org.eclipse.cdt.internal.ui.dnd.TransferDropTargetListener;
+import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
+
+public class SelectionTransferDropAdapter extends CDTViewerDropAdapter implements TransferDropTargetListener {
+
+       private List<?> fElements;
+       private ICElement[] fMoveData;
+       private ICElement[] fCopyData;
+
+       private static final long DROP_TIME_DIFF_TRESHOLD= 150;
+
+       public SelectionTransferDropAdapter(StructuredViewer viewer) {
+               super(viewer, DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND);
+       }
+
+       //---- TransferDropTargetListener interface ---------------------------------------
+       
+       public Transfer getTransfer() {
+               return LocalSelectionTransfer.getTransfer();
+       }
+       
+       public boolean isEnabled(DropTargetEvent event) {
+               Object target= event.item != null ? event.item.getData() : null;
+               if (target == null) {
+                       return false;
+               }
+               return target instanceof ISourceReference;
+       }
+
+       //---- Actual DND -----------------------------------------------------------------
+       
+       @Override
+       public void dragEnter(DropTargetEvent event) {
+               clear();
+               super.dragEnter(event);
+       }
+       
+       @Override
+       public void dragLeave(DropTargetEvent event) {
+               clear();
+               super.dragLeave(event);
+       }
+       
+       private void clear() {
+               fElements = null;
+               fMoveData = null;
+               fCopyData = null;
+       }
+       
+       @Override
+       public void validateDrop(Object target, DropTargetEvent event, int operation) {
+               event.detail= DND.DROP_NONE;
+               
+               if (tooFast(event)) { 
+                       return;
+               }
+               
+               initializeSelection();
+                               
+               try {
+                       switch(operation) {
+                               case DND.DROP_DEFAULT:
+                                       event.detail= handleValidateDefault(target, event); 
+                                       break;
+                               case DND.DROP_COPY:
+                                       event.detail= handleValidateCopy(target, event);
+                                       break;
+                               case DND.DROP_MOVE:
+                                       event.detail= handleValidateMove(target, event);
+                                       break;
+                               case DND.DROP_LINK:
+                                       event.detail= handleValidateLink(target, event);
+                                       break;
+                       }
+               } catch (CModelException e){
+                       ExceptionHandler.handle(e, CViewMessages.SelectionTransferDropAdapter_error_title, CViewMessages.SelectionTransferDropAdapter_error_message); 
+                       event.detail= DND.DROP_NONE;
+               }       
+       }
+
+       protected void initializeSelection(){
+               if (fElements != null) {
+                       return;
+               }
+               ISelection s= LocalSelectionTransfer.getTransfer().getSelection();
+               if (!(s instanceof IStructuredSelection)) {
+                       return;
+               }
+               fElements = ((IStructuredSelection)s).toList();
+       }
+       
+       private boolean tooFast(DropTargetEvent event) {
+               return Math.abs(LocalSelectionTransfer.getTransfer().getSelectionSetTime() - (event.time & 0xFFFFFFFFL)) < DROP_TIME_DIFF_TRESHOLD;
+       }       
+
+       @Override
+       public void drop(Object target, DropTargetEvent event) {
+               try {
+                       switch(event.detail) {
+                               case DND.DROP_MOVE:
+                                       handleDropMove(target, event);
+                                       break;
+                               case DND.DROP_COPY:
+                                       handleDropCopy(target, event);
+                                       break;
+                               case DND.DROP_LINK:
+                                       handleDropLink(target, event);
+                                       break;
+                       }
+               } catch (CModelException e){
+                       ExceptionHandler.handle(e, CViewMessages.SelectionTransferDropAdapter_error_title, CViewMessages.SelectionTransferDropAdapter_error_message); 
+               } catch(InvocationTargetException e) {
+                       ExceptionHandler.handle(e, CViewMessages.SelectionTransferDropAdapter_error_title, CViewMessages.SelectionTransferDropAdapter_error_exception); 
+               } catch (InterruptedException e) {
+                       //ok
+               } finally {
+                       // The drag source listener must not perform any operation
+                       // since this drop adapter did the remove of the source even
+                       // if we moved something.
+                       event.detail= DND.DROP_NONE;
+               }
+       }
+       
+       private int handleValidateDefault(Object target, DropTargetEvent event) throws CModelException {
+               if (target == null) {
+                       return DND.DROP_NONE;
+               }       
+               return handleValidateMove(target, event);       
+       }
+       
+       private int handleValidateMove(Object target, DropTargetEvent event) throws CModelException {
+               if (target == null || fElements.contains(target)) {
+                       return DND.DROP_NONE;
+               }
+               if (fMoveData == null) {
+                       ICElement[] cElements= getCElements(fElements);
+                       if (cElements != null && cElements.length > 0) {
+                               fMoveData = cElements;
+                       }
+               }
+               
+               if (!canMoveElements()) {
+                       return DND.DROP_NONE;
+               }
+
+               if (target instanceof ISourceReference) {
+                       return DND.DROP_MOVE;
+               }
+               return DND.DROP_NONE;
+       }
+       
+       private boolean canMoveElements() {
+               if (fMoveData != null) {
+                       return hasCommonParent(fMoveData);
+               }
+               return false;
+       }
+
+       private boolean hasCommonParent(ICElement[] elements) {
+               if (elements.length > 1) {
+                       ICElement parent = elements[0];
+                       for (int i = 0; i < elements.length; ++i) {
+                               ICElement p = elements[i].getParent();
+                               if (parent == null) {
+                                       if (p != null) {
+                                               return false;
+                                       }
+                               } else if (!parent.equals(p)){
+                                       return false;
+                               }
+                       }
+               }
+               return true;
+       }
+
+       private void handleDropLink(Object target, DropTargetEvent event) {
+       }
+
+       private int handleValidateLink(Object target, DropTargetEvent event) {
+               return DND.DROP_NONE;
+       }
+       
+       private void handleDropMove(final Object target, DropTargetEvent event) throws CModelException, InvocationTargetException, InterruptedException{
+               final ICElement[] cElements= getCElements(fElements);
+               
+               if (target instanceof ICElement) {
+                       ICElement cTarget = (ICElement)target;
+                       ICElement parent = cTarget;
+                       boolean isTargetTranslationUnit = cTarget instanceof ITranslationUnit;
+                       if (!isTargetTranslationUnit) {
+                               parent = cTarget.getParent();
+                       }
+                       final ICElement[] containers = new ICElement[cElements.length];
+                       for (int i = 0; i < containers.length; ++i) {
+                               containers[i] = parent;
+                       }
+                       ICElement[] neighbours = null;
+                       if (!isTargetTranslationUnit) {
+                               neighbours = new ICElement[cElements.length];
+                               for (int i = 0; i < neighbours.length; ++i) {
+                                       neighbours[i] = cTarget;
+                               }
+                       }
+                       final ICElement[] siblings = neighbours;
+                       IRunnableWithProgress runnable = new IRunnableWithProgress() {
+                               public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+                                       try {
+                                               CoreModel.getDefault().getCModel().move(cElements, containers, siblings, null, false, monitor);
+                                       } catch (CModelException e) {
+                                               throw new InvocationTargetException(e);
+                                       }
+                               }
+                       };
+                       run(runnable);
+               }
+       }
+
+       private int handleValidateCopy(Object target, DropTargetEvent event) throws CModelException{
+               if (target == null) {
+                       return DND.DROP_NONE;
+               }
+
+               if (fCopyData == null) {
+                       ICElement[] cElements= getCElements(fElements);
+                       if (cElements != null && cElements.length > 0) {
+                               fCopyData= cElements;
+                       }
+               }
+               
+               if (!canCopyElements())
+                       return DND.DROP_NONE;   
+
+               if (target instanceof ISourceReference) {
+                       return DND.DROP_COPY;
+               }
+               return DND.DROP_NONE;                                   
+       }
+                       
+       private boolean canCopyElements() {
+               if (fCopyData != null) {
+                       return hasCommonParent(fCopyData);
+               }
+               return false;
+       }               
+       
+       private void handleDropCopy(final Object target, DropTargetEvent event) throws CModelException, InvocationTargetException, InterruptedException{
+               final ICElement[] cElements= getCElements(fElements);
+
+               if (target instanceof ICElement) {
+                       ICElement cTarget = (ICElement)target;
+                       ICElement parent = cTarget;
+                       boolean isTargetTranslationUnit = cTarget instanceof ITranslationUnit;
+                       if (!isTargetTranslationUnit) {
+                               parent = cTarget.getParent();
+                       }
+                       final ICElement[] containers = new ICElement[cElements.length];
+                       for (int i = 0; i < containers.length; ++i) {
+                               containers[i] = parent;
+                       }
+                       ICElement[] neighbours = null;
+                       if (!isTargetTranslationUnit) {
+                               neighbours = new ICElement[cElements.length];
+                               for (int i = 0; i < neighbours.length; ++i) {
+                                       neighbours[i] = cTarget;
+                               }
+                       }
+                       final ICElement[] siblings = neighbours;
+                       IRunnableWithProgress runnable = new IRunnableWithProgress() {
+                               public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+                                       try {
+                                               CoreModel.getDefault().getCModel().copy(cElements, containers, siblings, null, false, monitor);
+                                       } catch (CModelException e) {
+                                               throw new InvocationTargetException(e);
+                                       }
+                               }
+                       };
+                       run(runnable);
+               }
+       }
+
+       private Shell getShell() {
+               return getViewer().getControl().getShell();
+       }
+
+       public void run(IRunnableWithProgress runnable) throws InterruptedException, InvocationTargetException {
+               IRunnableContext context= new ProgressMonitorDialog(getShell());
+               context.run(true, true, runnable);
+       }
+
+       public static ICElement[] getCElements(List<?> elements) {
+               List<ICElement> resources= new ArrayList<ICElement>(elements.size());
+               for (Iterator<?> iter= elements.iterator(); iter.hasNext();) {
+                       Object element= iter.next();
+                       if (element instanceof ITranslationUnit) {
+                               continue;
+                       }
+                       if (element instanceof ICElement)
+                               resources.add((ICElement) element);
+               }
+               return resources.toArray(new ICElement[resources.size()]);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/ToggleLinkingAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/ToggleLinkingAction.java
new file mode 100644 (file)
index 0000000..ab292b6
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.cview;
+
+import org.eclipse.cdt.internal.ui.actions.AbstractToggleLinkingAction;
+
+/**
+ * This action toggles whether this navigator links its selection to the active
+ * editor.
+ * 
+ * @since 2.0
+ */
+public class ToggleLinkingAction extends AbstractToggleLinkingAction {
+       
+    CView fCView;
+    
+       /**
+        * Constructs a new action.
+        */
+       public ToggleLinkingAction(CView cView) {
+               fCView = cView;
+               setChecked(cView.isLinkingEnabled());
+       }
+
+       /**
+        * Runs the action.
+        */
+       @Override
+       public void run() {
+           fCView.setLinkingEnabled(isChecked());
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/AbstractElementListSelectionDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/AbstractElementListSelectionDialog.java
new file mode 100644 (file)
index 0000000..2ad44ec
--- /dev/null
@@ -0,0 +1,287 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * A class to select one or more elements out of an indexed property
+ */
+public abstract class AbstractElementListSelectionDialog extends SelectionStatusDialog {
+       
+       private ILabelProvider fRenderer;
+       private boolean fIgnoreCase;
+       private boolean fIsMultipleSelection;
+       
+       private SelectionList fSelectionList;
+       private Label fMessage;
+       private ISelectionValidator fValidator; 
+       
+       private String fMessageText;
+       private String fEmptyListMessage;
+       private String fNothingSelectedMessage;
+       
+       private StatusInfo fCurrStatus;
+       
+       /*
+        * @private
+        */
+       protected void access$superOpen() {
+               super.open();
+       }
+       /*
+        * @private
+        * @see Dialog#cancelPressed
+        */
+       @Override
+       protected void cancelPressed() {
+               setResult(null);
+               super.cancelPressed();
+       }
+       protected Point computeInitialSize() {
+               return new Point(convertWidthInCharsToPixels(60), convertHeightInCharsToPixels(18));
+       }
+       /*
+        * @private
+        * @see Window#createDialogArea(Composite)
+        */
+       @Override
+       protected Control createDialogArea(Composite parent) {
+               Composite contents= (Composite)super.createDialogArea(parent);
+               
+               fMessage= createMessage(contents);
+               
+               int flags= fIsMultipleSelection ? SWT.MULTI : SWT.SINGLE;                       
+               fSelectionList= new SelectionList(contents, flags | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL,
+                       fRenderer, fIgnoreCase);
+               
+               fSelectionList.addSelectionListener(new SelectionListener() {
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               handleDoubleClick();
+                       }
+                       public void widgetSelected(SelectionEvent e) {
+                               verifyCurrentSelection();
+                       }
+               });
+
+               GridData spec= new GridData();
+               Point initialSize= computeInitialSize();
+               spec.widthHint= initialSize.x;
+               spec.heightHint= initialSize.y;
+               spec.grabExcessVerticalSpace= true;
+               spec.grabExcessHorizontalSpace= true;
+               spec.horizontalAlignment= GridData.FILL;
+               spec.verticalAlignment= GridData.FILL;
+               fSelectionList.setLayoutData(spec);
+                               
+               return contents;
+       }
+       /**
+        * Creates the message text widget and sets layout data.
+        */
+       protected Label createMessage(Composite parent) {
+               Label text= new Label(parent, SWT.NULL);
+               text.setText(fMessageText);
+               GridData spec= new GridData();
+               spec.grabExcessVerticalSpace= false;
+               spec.grabExcessHorizontalSpace= true;
+               spec.horizontalAlignment= GridData.FILL;
+               spec.verticalAlignment= GridData.BEGINNING;
+               text.setLayoutData(spec);
+               return text;
+       }
+       /*
+        * @private
+        * @see Window#create(Shell)
+        */
+       @Override
+       public void create() {
+               super.create();
+               if (isEmptyList()) {
+                       fMessage.setEnabled(false);
+                       fSelectionList.setEnabled(false);
+               } else {
+                       verifyCurrentSelection();               
+                       fSelectionList.selectFilterText();
+                       fSelectionList.setFocus();
+               }       
+       }
+       /**
+        * Returns the currently used filter text.
+        */
+       protected String getFilter() {
+               return fSelectionList.getFilter();
+       }
+       /**
+        * Returns the selection indices.
+        */
+       protected int[] getSelectionIndices() {
+               return fSelectionList.getSelectionIndices();
+       }
+       /**
+        * Returns the widget selection. Returns empty list when the widget is not
+        * usable.
+        */
+       protected List<?> getWidgetSelection() {
+               if (fSelectionList == null || fSelectionList.isDisposed())
+                       return Collections.emptyList();
+               return fSelectionList.getSelection();   
+       }
+       /**
+        * An element as been selected in the list by double clicking on it.
+        * Emulate a OK button pressed to close the dialog.
+        */     
+       protected abstract void handleDoubleClick();
+       /**
+        * Checks whether the list of elements is empty or not.
+        */
+       protected boolean isEmptyList() {
+               if (fSelectionList == null)
+                       return true;
+               return fSelectionList.isEmptyList();
+       }
+       /**
+        * Constructs a list selection dialog.
+        * @param renderer The label renderer used
+        * @param ignoreCase Decides if the match string ignores lower/upppr case
+        * @param multipleSelection Allow multiple selection     
+        */
+       protected AbstractElementListSelectionDialog(Shell parent, String title, Image image, ILabelProvider renderer, boolean ignoreCase, boolean multipleSelection) {
+               super(parent);
+               setTitle(title);
+               setImage(image);
+               fRenderer= renderer;
+               fIgnoreCase= ignoreCase;
+               fIsMultipleSelection= multipleSelection;
+               
+               fMessageText= ""; //$NON-NLS-1$
+               
+               fCurrStatus= new StatusInfo();
+               
+               fValidator= null;
+               fEmptyListMessage= ""; //$NON-NLS-1$
+               fNothingSelectedMessage= ""; //$NON-NLS-1$
+       }
+       /**
+        * Constructs a list selection dialog.
+        * @param renderer The label renderer used
+        * @param ignoreCase Decides if the match string ignores lower/upppr case
+        * @param multipleSelection Allow multiple selection     
+        */
+       protected AbstractElementListSelectionDialog(Shell parent, ILabelProvider renderer, boolean ignoreCase, boolean multipleSelection) {
+               this(parent, "", null, renderer, ignoreCase, multipleSelection); //$NON-NLS-1$
+       }
+       /*
+        * @private
+        */
+       @Override
+       public int open() {
+               BusyIndicator.showWhile(null, new Runnable() {
+                       public void run() {
+                               access$superOpen();
+                       }
+               });
+               return getReturnCode() ;
+       }
+       /**
+        * Refilters the current list according to the filter entered into the
+        * text edit field.
+        */
+       protected void refilter() {
+               fSelectionList.filter(true);
+       }
+       /**
+        * If a empty-list message is set, a error message is shown
+        * Must be set before widget creation
+        */
+       public void setEmptyListMessage(String message) {
+               fEmptyListMessage= message;
+       }
+       /**
+        * Sets the filter text to the given value.
+        */
+       protected void setFilter(String text, boolean refilter) {
+               fSelectionList.setFilter(text, refilter);
+       }
+       /**
+        * Sets the message to be shown above the match text field.
+        * Must be set before widget creation
+        */
+       @Override
+       public void setMessage(String message) {
+               fMessageText= message;
+       }
+       /**
+        * If the selection is empty, this message is shown
+        */
+       public void setNothingSelectedMessage(String message) {
+               fNothingSelectedMessage= message;
+       }
+       /**
+        * Selects the elements in the list determined by the given
+        * selection indices.
+        */
+       protected void setSelection(int[] selection) {
+               fSelectionList.setSelection(selection);
+       }
+       /**
+        * Initializes the selection list widget with the given list of
+        * elements.
+        */
+       protected void setSelectionListElements(List<?> elements, boolean refilter) {
+               fSelectionList.setElements(elements, refilter);
+       }
+       /**
+        * A validator can be set to check if the current selection
+        * is valid
+        */
+       public void setValidator(ISelectionValidator validator) {
+               fValidator= validator;
+       }
+       /**
+        * Verifies the current selection and updates the status line
+        * accordingly.
+        */
+       protected boolean verifyCurrentSelection() {
+               List<?> sel= getWidgetSelection();
+               int length= sel.size();
+               if (length > 0) {
+                       if (fValidator != null) {
+                               fValidator.isValid(sel.toArray(), fCurrStatus);
+                       } else {
+                               fCurrStatus.setOK();
+                       }
+               } else {
+                       if (isEmptyList()) {
+                               fCurrStatus.setError(fEmptyListMessage);
+                       } else {
+                               fCurrStatus.setError(fNothingSelectedMessage);
+                       }
+               }
+               updateStatus(fCurrStatus);
+               return fCurrStatus.isOK();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ElementListSelectionDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ElementListSelectionDialog.java
new file mode 100644 (file)
index 0000000..2471501
--- /dev/null
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * A class to select one or more elements out of an indexed property
+ */
+public class ElementListSelectionDialog extends AbstractElementListSelectionDialog {
+       
+       private List<?> fElements;
+       
+       /*
+        * @private
+        */
+       @Override
+       protected void computeResult() {
+               setResult(getWidgetSelection());
+       }
+       /*
+        * @private
+        */     
+       @Override
+       protected Control createDialogArea(Composite parent) {
+               Control result= super.createDialogArea(parent);
+               
+               setSelectionListElements(fElements, false);
+               //a little trick to make the window come up faster
+               String initialFilter= null;
+               if (getPrimaryInitialSelection() instanceof String)
+                       initialFilter= (String)getPrimaryInitialSelection();
+               if (initialFilter != null)
+                       setFilter(initialFilter, true);
+               else
+                       refilter();
+                                       
+               return result;
+       }
+       public Object getSelectedElement() {
+               return getPrimaryResult();
+       }
+       public Object[] getSelectedElements() {
+               return getResult();
+       }
+       /*
+        * @private
+        */     
+       @Override
+       protected void handleDoubleClick() {
+               if (verifyCurrentSelection()) {
+                       buttonPressed(IDialogConstants.OK_ID);
+               }
+       }
+       /**
+        * Constructs a list selection dialog.
+        * @param renderer The label renderer used
+        * @param ignoreCase Decides if the match string ignores lower/upper case
+        * @param multipleSelection Allow multiple selection     
+        */
+       public ElementListSelectionDialog(Shell parent, String title, Image image, ILabelProvider renderer, boolean ignoreCase, boolean multipleSelection) {
+               super (parent, title, image, renderer, ignoreCase, multipleSelection);
+       }
+       /**
+        * Constructs a list selection dialog.
+        * @param renderer The label renderer used
+        * @param ignoreCase Decides if the match string ignores lower/upppr case
+        * @param multipleSelection Allow multiple selection     
+        */
+       public ElementListSelectionDialog(Shell parent, ILabelProvider renderer, boolean ignoreCase, boolean multipleSelection) {
+               this(parent, "", null, renderer, ignoreCase, multipleSelection); //$NON-NLS-1$
+       }
+       public int open(Object[] elements) {
+               return open(Arrays.asList(elements));
+       }
+       public int open(Object[] elements, String initialSelection) {
+               return open(Arrays.asList(elements), initialSelection);
+       }
+       /**
+        * Open the dialog.
+        * @param elements The elements to show in the list
+        * @return Returns OK or CANCEL
+        */     
+       public int open(List<?> elements) {
+               setElements(elements);
+               return open();
+       }
+       /**
+        * Open the dialog.
+        * @param elements The elements to show in the list
+        * @param initialSelection The initial content of the match text box.
+        * @return Returns OK or CANCEL
+        */
+       public int open(List<?> elements, String initialSelection) {
+               setElements(elements);
+               setInitialSelection(initialSelection);
+               return open();
+       }
+       /**
+        * Sets the elements presented by this dialog.
+        */
+       public void setElements(List<?> elements) {
+               fElements= elements;    
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ISelectionValidator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ISelectionValidator.java
new file mode 100644 (file)
index 0000000..de9ff24
--- /dev/null
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs;
+
+public interface ISelectionValidator {
+       void isValid(Object[] selection, StatusInfo res);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/IStatusChangeListener.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/IStatusChangeListener.java
new file mode 100644 (file)
index 0000000..9b88bd1
--- /dev/null
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs;
+
+import org.eclipse.core.runtime.IStatus;
+
+public interface IStatusChangeListener {
+       
+       /**
+        * Called to announce that the given status has changed.
+        */
+       void statusChanged(IStatus status);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/MessageLine.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/MessageLine.java
new file mode 100644 (file)
index 0000000..9b51869
--- /dev/null
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * A message line. It distinguishes between "normal" messages and errors. 
+ * Setting an error message hides a currently displayed message until 
+ * <code>clearErrorMessage</code> is called.
+ */
+public class MessageLine extends CLabel {
+       private String fMessageText;
+       private String fErrorText;
+
+       private Color fDefaultColor;
+       private RGB fErrorRGB;
+       protected Color fErrorColor;
+
+       private static RGB fgErrorRGB= new RGB(200, 0, 0);
+
+       /**
+        * Clears the currently displayed error message and redisplays
+        * the message which was active before the error message was set.
+        */
+       public void clearErrorMessage() {
+               setErrorMessage(null);
+       }
+       /**
+        * Clears the currently displayed message.
+        */
+       public void clearMessage() {
+               setMessage(null);
+       }
+       /**
+        * Get the currently displayed error text.
+        * @return The error message. If no error message is displayed <code>null</code> is returned.
+        */
+       public String getErrorMessage() {
+               return fErrorText;
+       }
+       /**
+        * Get the currently displayed message.
+        * @return The message. If no message is displayed <code>null<code> is returned.
+        */
+       public String getMessage() {
+               return fMessageText;
+       }
+       /**
+        * Creates a new message line as a child of the parent and with the given SWT style bits.
+        * Error message will be shown with in the given RGB color.
+        */
+       public MessageLine(Composite parent, int style, RGB errorRGB) {
+               super(parent, style);
+               fDefaultColor= getForeground();
+               fErrorRGB= errorRGB;
+       }
+       /**
+        * Creates a new message line as a child of the parent and with the given SWT style bits.
+        * Error message will be shown with in the RGB color 200,0,0.
+        */
+       public MessageLine(Composite parent, int style) {
+               super(parent, style);
+               fDefaultColor= getForeground();
+               fErrorRGB= fgErrorRGB;
+       }
+       /**
+        * Creates a new message line as a child of the given parent.
+        * Error message will be shown with in the RGB color 200,0,0.
+        */
+       public MessageLine(Composite parent) {
+               this(parent, SWT.LEFT);
+       }
+       /**
+        * Sets the default error color used by all message lines.
+        * Note: a call to this method only affects newly created MessageLines not existing ones. 
+        */
+       public static void setErrorColor(RGB color) {
+               fgErrorRGB= color;
+       }
+       /**
+            * Display the given error message. A currently displayed message
+            * is saved and will be redisplayed when the error message is cleared.
+            */
+       public void setErrorMessage(String message) {
+               fErrorText= message;
+
+               if (message == null) {
+                       setMessage(fMessageText);
+               } else {
+                       if (fErrorColor == null) {
+                               fErrorColor= new Color(getDisplay(), fErrorRGB);
+                               addDisposeListener(new DisposeListener() {
+                                       public void widgetDisposed(DisposeEvent e) {
+                                               fErrorColor.dispose();
+                                       }
+                               });
+                       }
+                       setForeground(fErrorColor);
+                       setText(message);
+               }
+       }
+       /**
+            * Set the message text. If the message line currently displays an error,
+            * the message is stored and will be shown after a call to clearErrorMessage
+            */
+       public void setMessage(String message) {
+               fMessageText= message;
+               if (message == null)
+                       message= ""; //$NON-NLS-1$
+               if (fErrorText == null) {
+                       setForeground(fDefaultColor);
+                       setText(message);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/OptionalMessageDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/OptionalMessageDialog.java
new file mode 100644 (file)
index 0000000..2c6fe84
--- /dev/null
@@ -0,0 +1,153 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.CUIMessages;
+
+/**
+ * This is a <code>MessageDialog</code> which allows the user
+ * to choose that the dialog isn't shown again the next time.
+ */ 
+public class OptionalMessageDialog extends MessageDialog {
+       // Dialog store id constants
+       private static final String STORE_ID= "OptionalMessageDialog.hide."; //$NON-NLS-1$
+       private static final String KEY_DETAIL = ".detail"; //$NON-NLS-1$
+
+       public static final int NOT_SHOWN= IDialogConstants.CLIENT_ID + 1;
+       public static final int NO_DETAIL= -1;
+       
+       private Button fHideDialogCheckBox;
+       private String fId;
+       private String fHideMessage;
+
+       /**
+        * Opens the dialog but only if the user hasn't chosen to hide it.
+        * Returns <code>NOT_SHOWN</code> if the dialog was not shown.
+        */
+       public static int open(String id, Shell parent, String title, Image titleImage, String message, int dialogType, String[] buttonLabels, int defaultButtonIndex) {
+               if (!isDialogEnabled(id))
+                       return OptionalMessageDialog.NOT_SHOWN;
+               
+               MessageDialog dialog= new OptionalMessageDialog(id, parent, title, titleImage, message, dialogType, buttonLabels, defaultButtonIndex);
+               return dialog.open();
+       }
+
+       protected OptionalMessageDialog(String id, Shell parent, String title, Image titleImage, String message, int dialogType, String[] buttonLabels, int defaultButtonIndex) {
+               super(parent, title, titleImage, message, dialogType, buttonLabels, defaultButtonIndex);
+               fId= id;
+               switch(dialogType) {
+               case QUESTION:
+        case QUESTION_WITH_CANCEL:
+               fHideMessage= CUIMessages.OptionalMessageDialog_rememberDecision;
+               break;
+        default:
+               fHideMessage= CUIMessages.OptionalMessageDialog_dontShowAgain;
+               }
+       }
+
+       @Override
+       protected Control createCustomArea(Composite parent) {
+               Composite composite= new Composite(parent, SWT.NONE);
+               GridLayout layout= new GridLayout();
+               layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+               layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+               layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+               composite.setLayout(layout);
+               composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+               
+               fHideDialogCheckBox= new Button(composite, SWT.CHECK | SWT.LEFT);
+               fHideDialogCheckBox.setText(fHideMessage);
+               fHideDialogCheckBox.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               setDialogEnabled(fId, !((Button)e.widget).getSelection());
+                       }
+               });
+               applyDialogFont(fHideDialogCheckBox);
+               return fHideDialogCheckBox;
+       }
+       
+       //--------------- Configuration handling --------------
+       
+       /**
+        * Returns this dialog
+        * 
+        * @return the settings to be used
+        */
+       private static IDialogSettings getDialogSettings() {
+               IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings();
+               settings= settings.getSection(STORE_ID);
+               if (settings == null)
+                       settings= CUIPlugin.getDefault().getDialogSettings().addNewSection(STORE_ID);
+               return settings;
+       }
+               
+       /**
+        * Answers whether the optional dialog is enabled and should be shown.
+        */
+       public static boolean isDialogEnabled(String key) {
+               IDialogSettings settings= getDialogSettings();
+               return !settings.getBoolean(key);
+       }
+       
+       /**
+        * Sets a detail for the dialog.
+        */
+       public static void setDialogDetail(String key, int detail) {
+               IDialogSettings settings= getDialogSettings();
+               settings.put(key+KEY_DETAIL, detail);
+       }
+
+       /**
+        * Returns the detail for this dialog, or NO_DETAIL, if none.
+        */
+       public static int getDialogDetail(String key) {
+               IDialogSettings settings= getDialogSettings();
+               try {
+                       return settings.getInt(key+KEY_DETAIL);
+               } catch (NumberFormatException e) {
+                       return NO_DETAIL;
+               }
+       }
+       
+       /**
+        * Sets whether the optional dialog is enabled and should be shown.
+        */
+       public static void setDialogEnabled(String key, boolean isEnabled) {
+               IDialogSettings settings= getDialogSettings();
+               settings.put(key, !isEnabled);
+       }
+
+       /**
+        * Clears all remembered information about hidden dialogs
+        */
+       public static void clearAllRememberedStates() {
+               IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings();
+               settings.addNewSection(STORE_ID);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionList.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionList.java
new file mode 100644 (file)
index 0000000..f2cbe9e
--- /dev/null
@@ -0,0 +1,259 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.internal.ui.util.StringMatcher;
+import org.eclipse.cdt.internal.ui.util.TwoArrayQuickSort;
+
+/**
+ * A selection widget that consists of a list and a text entry field. The list
+ * of elements presented are limited to the pattern entered into the text entry
+ * field.
+ */
+public class SelectionList extends Composite {
+
+       // State
+       private Object[] fElements;
+       protected ILabelProvider fRenderer;
+       private boolean fIgnoreCase;
+       
+       // Implementation details
+       private String[] fRenderedStrings;
+       private int[] fFilteredElements;        
+       private String fRememberedMatchText;
+
+       // SWT widgets
+       private Table fList;
+       private Text fText;
+       
+       /**
+        * Adds a selection change listener to this widget.
+        */
+       public void addSelectionListener(SelectionListener listener) {
+               fList.addSelectionListener(listener);
+       }
+       private void createList(int style) {
+               fList= new Table(this, style);
+               fList.setLayoutData(new GridData(GridData.FILL_BOTH));
+               fList.addDisposeListener(new DisposeListener() {
+                       public void widgetDisposed(DisposeEvent e) {
+                               fRenderer.dispose();
+                       }
+               });
+       }
+       private void createText() {
+               fText= new Text(this, SWT.BORDER);
+               GridData spec= new GridData();
+               spec.grabExcessVerticalSpace= false;
+               spec.grabExcessHorizontalSpace= true;
+               spec.horizontalAlignment= GridData.FILL;
+               spec.verticalAlignment= GridData.BEGINNING;
+               fText.setLayoutData(spec);
+               Listener l= new Listener() {
+                       public void handleEvent(Event evt) {
+                               filter(false);
+                       }
+               };
+               fText.addListener(SWT.Modify, l);
+       }
+       /**
+        * Filters the list of elements according to the pattern entered
+        * into the text entry field.
+        */
+       public void filter(boolean forceUpdate) {
+               int k= 0;
+               String text= fText.getText();
+               if (!forceUpdate && text.equals(fRememberedMatchText))
+                       return;
+               fRememberedMatchText= text;
+               StringMatcher matcher= new StringMatcher(text+"*", fIgnoreCase, false); //$NON-NLS-1$
+               for (int i= 0; i < fElements.length; i++) {
+                       if (matcher.match(fRenderedStrings[i])) {
+                               fFilteredElements[k]= i;
+                               k++;
+                       }
+               }
+               fFilteredElements[k]= -1;
+               updateListWidget(fFilteredElements, k);
+       }
+       /**
+        * Returns the currently used filter text.
+        */
+       public String getFilter() {
+               return fText.getText();
+       }
+       /**
+        * Returns the selection indices.
+        */
+       public int[] getSelectionIndices() {
+               return fList.getSelectionIndices();
+       }
+       /**
+        * Returns a list of selected elements. Note that the type of the elements
+        * returned in the list are the same as the ones passed to the selection list
+        * via <code>setElements</code>. The list doesn't contain the rendered strings.
+        */
+       public List<?> getSelection() {
+               if (fList == null || fList.isDisposed() || fList.getSelectionCount() == 0)
+                       return Collections.emptyList();
+               int[] listSelection= fList.getSelectionIndices();
+               List<Object> selected= new ArrayList<Object>(listSelection.length);
+               for (int i= 0; i < listSelection.length; i++) {
+                       selected.add(fElements[fFilteredElements[listSelection[i]]]);
+               }
+               return selected;
+       }
+       /**
+        * Returns <code>true</code> when the list of elements is empty.
+        */
+       public boolean isEmptyList() {
+               return fElements == null || fElements.length == 0;
+       }
+       /**
+        * Creates new instance of the widget.
+        */
+       public SelectionList(Composite parent, int style, ILabelProvider renderer, boolean ignoreCase) {
+               super(parent, SWT.NONE);
+               fRenderer= renderer;
+               fIgnoreCase= ignoreCase;
+               GridLayout layout= new GridLayout();
+               layout.marginHeight= 0; layout.marginWidth= 0;
+               //XXX: 1G9V58A: ITPUI:WIN2000 - Dialog.convert* methods should be static
+               setLayout(layout);
+               createText();
+               createList(style);
+       }
+       /**
+        * Removes a selection change listener to this widget.
+        */
+       public void removeSelectionListener(SelectionListener listener) {
+               fList.removeSelectionListener(listener);
+       }
+       private String[] renderStrings() {
+               String[] strings= new String[fElements.length];
+               for (int i= 0; i < strings.length; i++) {
+                       strings[i]= fRenderer.getText(fElements[i]);
+               }
+               TwoArrayQuickSort.sort(strings, fElements, fIgnoreCase);
+               return strings;
+       }
+       /**
+        * Select the pattern text.
+        */
+       public void selectFilterText() {
+               fText.selectAll();
+       }
+       /**
+        * Sets the list of elements presented in the widget.
+        */
+       public void setElements(List<?> elements, boolean refilter) {
+               // We copy the list since we sort it.
+               if (elements == null)
+                       fElements= new Object[0];
+               else 
+                       fElements= elements.toArray();
+               fFilteredElements= new int[fElements.length+1];
+               fRenderedStrings= renderStrings();
+               if (refilter)
+                       filter(true);           
+       }
+       /* 
+        * Non Java-doc
+        */
+       @Override
+       public void setEnabled(boolean enable) {
+               super.setEnabled(enable);
+               fText.setEnabled(enable);
+               fList.setEnabled(enable);
+       }
+       /**
+        * Sets the filter pattern. Current only prefix filter pattern are supported.
+        */
+       public void setFilter(String pattern, boolean refilter) {
+               fText.setText(pattern);
+               if (refilter)
+                       filter(true);
+       }
+       /*
+        * Non Java-doc
+        */
+       @Override
+       public boolean setFocus() {
+               return fText.setFocus();
+       }
+       /*
+        * Non Java-doc
+        */
+       @Override
+       public void setFont(Font font) {
+               super.setFont(font);
+               fText.setFont(font);
+               fList.setFont(font);
+       }
+       /**
+        * Selects the elements in the list determined by the given
+        * selection indices.
+        */
+       protected void setSelection(int[] selection) {
+               fList.setSelection(selection);
+       }
+       private void updateListWidget(int[] indices, int size) {
+               if (fList == null || fList.isDisposed())
+                       return;
+               fList.setRedraw(false);
+               int itemCount= fList.getItemCount();
+               if (size < itemCount) {
+                       fList.remove(0, itemCount-size-1);
+               }
+
+               TableItem[] items= fList.getItems();
+               for (int i= 0; i < size; i++) {
+                       TableItem ti= null;
+                       if (i < itemCount) {
+                               ti= items[i];
+                       } else {
+                               ti= new TableItem(fList, i);
+                       }
+                       ti.setText(fRenderedStrings[indices[i]]);
+                       Image img= fRenderer.getImage(fElements[indices[i]]);
+                       if (img != null)
+                               ti.setImage(img);
+               }
+               if (fList.getItemCount() > 0) {
+                       fList.setSelection(0);
+               }
+                                       
+               fList.setRedraw(true);
+               Event event= new Event();
+               fList.notifyListeners(SWT.Selection, event);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionStatusDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionStatusDialog.java
new file mode 100644 (file)
index 0000000..4683df3
--- /dev/null
@@ -0,0 +1,197 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.SelectionDialog;
+
+/**
+ * An abstract base class for dialogs with a status bar and ok/cancel buttons.
+ * The status message must be passed over as StatusInfo object and can be
+ * an error, warning or ok. The OK button is enabled / disabled depending
+ * on the status.
+ */ 
+public abstract class SelectionStatusDialog extends SelectionDialog {
+       
+       private MessageLine fStatusLine;
+       private IStatus fLastStatus;
+       private Image fImage;
+       private boolean fInitialSelectionSet;
+       private boolean fStatusLineAboveButtons= false;
+       
+       
+       /**
+        * Compute the result and return it.
+        */
+       protected abstract void computeResult();
+       /* (non-Javadoc)
+        * Method declared in Window.
+        */
+       @Override
+       protected void configureShell(Shell shell) {
+               super.configureShell(shell);
+               if (fImage != null)
+                       shell.setImage(fImage);
+       }
+       /* (non-Javadoc)
+        * Method declared in Dialog.
+        */
+       @Override
+       protected Control createButtonBar(Composite parent) {
+               Composite composite= new Composite(parent, SWT.NULL);
+               GridLayout layout= new GridLayout();
+               if (fStatusLineAboveButtons) {
+                       layout.verticalSpacing= 0;
+               } else {
+                       layout.numColumns= 2;
+               }
+               layout.marginHeight= 0; layout.marginWidth= 0;
+               composite.setLayout(layout);
+               composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               
+               fStatusLine= new MessageLine(composite);
+               fStatusLine.setAlignment(SWT.LEFT);
+               fStatusLine.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               fStatusLine.setMessage(""); //$NON-NLS-1$
+
+               super.createButtonBar(composite);
+               return composite;
+       }
+       /* (non-Javadoc)
+        * Method declared in Dialog.
+        */
+       @Override
+       public void create() {
+               super.create();
+               if (fLastStatus != null) {
+                       updateStatus(fLastStatus);
+               }
+       }
+       /**
+        * Returns the first element of the initial selection or <code>null<code>
+        * if there isn't any initial selection.
+        * @return the first element of the initial selection.
+        */
+       protected Object getPrimaryInitialSelection() {
+               List<?> result= getInitialElementSelections();
+               if (result == null || result.size() == 0)
+                       return null;
+               return result.get(0);   
+       }
+       /**
+        * Returns the first element from the list of results. Returns <code>null</code>
+        * if no element has been selected.
+        *
+        * @return the first result element if one exists. Otherwise <code>null</code> is
+        *  returned.
+        */
+       public Object getPrimaryResult() {
+               Object[] result= getResult();
+               if (result == null || result.length == 0)
+                       return null;
+               return result[0];       
+       }
+       public SelectionStatusDialog(Shell parent) {
+               super(parent);
+               fInitialSelectionSet= false;
+       }
+       /* (non-Javadoc)
+        * Method declared in Dialog.
+        */
+       @Override
+       protected void okPressed() {
+               computeResult();
+               super.okPressed();
+       }
+       /**
+        * Sets the image for this dialog.
+        *
+        * @param image the dialog's image
+        */
+       public void setImage(Image image) {
+               fImage= image;
+       }
+       protected void setInitialSelection(int position, Object element) {
+               @SuppressWarnings("unchecked")
+               List<Object> l= getInitialElementSelections();
+               l.set(position, element);
+               fInitialSelectionSet= true;
+       }
+       /**
+        * Sets the initial selection to the given element.
+        */
+       public void setInitialSelection(Object element) {
+               // Allow clients to use set their own initial selection(s)
+               if (fInitialSelectionSet && element != null && element.equals("A")) //$NON-NLS-1$
+                       return;
+
+               if (element != null) {
+                       setInitialSelections(new Object[] { element });
+               } else {
+                       setInitialSelections(new Object[0]);
+               }
+       }
+       @Override
+       public void setInitialSelections(Object[] selectedElements) {
+               super.setInitialSelections(selectedElements);
+               fInitialSelectionSet= true;
+       }
+       /**
+        * Sets a result element at the given position.
+        */
+       protected void setResult(int position, Object element) {
+               Object[] result= getResult();
+               result[position]= element;
+               setResult(Arrays.asList(result));
+       }
+       /**
+        * Controls whether status line appears to the left of the buttons (default)
+        * or above them.
+        *
+        * @param aboveButtons if <code>true</code> status line is placed above buttons; if
+        *      <code>false</code> to the right
+        */
+       public void setStatusLineAboveButtons(boolean aboveButtons) {
+               fStatusLineAboveButtons= aboveButtons;
+       }
+       /**
+        * Update the status of the ok button to reflect the given status. Subclasses
+        * may override this method to update additional buttons.
+        */
+       protected void updateButtonsEnableState(IStatus status) {
+               Button okButton= getOkButton();
+               if (okButton != null && !okButton.isDisposed())
+                       okButton.setEnabled(!status.matches(IStatus.ERROR));
+       }
+       /**
+        * Update the dialog's status line to reflect the given status. It is safe to call
+        * this method before the dialog has been opened.
+        */
+       protected void updateStatus(IStatus status) {
+               fLastStatus= status;
+               if (fStatusLine != null && !fStatusLine.isDisposed()) {
+                   updateButtonsEnableState(status);
+                   StatusTool.applyToStatusLine(fStatusLine, status);                  
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusDialog.java
new file mode 100644 (file)
index 0000000..1f42b00
--- /dev/null
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs;
+
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * @deprecated. This class is deprecated since CDT 6.1. Use {@link org.eclipse.jface.dialogs.StatusDialog} instead.
+ * 
+ * An abstract base class for dialogs with a status bar and ok/cancel buttons.
+ * The status message must be passed over as StatusInfo object and can be
+ * an error, warning or ok. The OK button is enabled or disabled depending
+ * on the status.
+ */
+@Deprecated
+public abstract class StatusDialog extends org.eclipse.jface.dialogs.StatusDialog {
+       public StatusDialog(Shell parent) {
+               super(parent);
+               setHelpAvailable(false);
+       }
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusInfo.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusInfo.java
new file mode 100644 (file)
index 0000000..9a92cbd
--- /dev/null
@@ -0,0 +1,149 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs;
+
+import org.eclipse.core.runtime.IStatus;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * A settable IStatus
+ * Can be an error, warning, info or ok. For error, info and warning states,
+ * a message describes the problem
+ */
+public class StatusInfo implements IStatus {
+       
+       public static final IStatus OK_STATUS= new StatusInfo();
+
+       private String fStatusMessage;
+       private int fSeverity;
+
+       /**
+        * Creates a status set to OK (no message)
+        */
+       public StatusInfo() {
+               this(OK, null);
+       }
+
+       /**
+        * Creates a status.
+        * @param severity The status severity: ERROR, WARNING, INFO and OK.
+        * @param message The message of the status. Applies only for ERROR,
+        * WARNING and INFO.
+        */     
+       public StatusInfo(int severity, String message) {
+               fStatusMessage= message;
+               fSeverity= severity;
+       }               
+
+       /**
+        * @see IStatus#getChildren()
+        */
+       public IStatus[] getChildren() {
+               return new IStatus[0];
+       }
+       /**
+        * @see IStatus#getCode()
+        */
+       public int getCode() {
+               return fSeverity;
+       }
+       /**
+        * @see IStatus#getException()
+        */
+       public Throwable getException() {
+               return null;
+       }
+       /**
+        * @see IStatus#getMessage
+        */
+       public String getMessage() {
+               return fStatusMessage;
+       }
+       /**
+        * @see IStatus#getPlugin()
+        */
+       public String getPlugin() {
+               return CUIPlugin.PLUGIN_ID;
+       }
+       /**
+        * @see IStatus#getSeverity()
+        */
+       public int getSeverity() {
+               return fSeverity;
+       }
+       public boolean isError() {
+               return fSeverity == IStatus.ERROR;
+       }
+       public boolean isInfo() {
+               return fSeverity == IStatus.INFO;
+       }
+       /**
+        * @see IStatus#isMultiStatus()
+        */
+       public boolean isMultiStatus() {
+               return false;
+       }
+       public boolean isOK() {
+               return fSeverity == IStatus.OK;
+       }
+       public boolean isWarning() {
+               return fSeverity == IStatus.WARNING;
+       }
+       /**
+        * @see IStatus#matches(int)
+        */
+       public boolean matches(int severityMask) {
+               return (fSeverity & severityMask) != 0;
+       }
+       public void setError(String errorMessage) {
+               fStatusMessage= errorMessage;
+               fSeverity= IStatus.ERROR;
+       }
+       public void setInfo(String infoMessage) {
+               fStatusMessage= infoMessage;
+               fSeverity= IStatus.INFO;
+       }
+       public void setOK() {
+               fStatusMessage= null;
+               fSeverity= IStatus.OK;
+       }
+       public void setWarning(String warningMessage) {
+               fStatusMessage= warningMessage;
+               fSeverity= IStatus.WARNING;
+       }
+
+       /**
+        * Returns a string representation of the status, suitable 
+        * for debugging purposes only.
+        */
+       @Override
+       public String toString() {
+               StringBuffer buf = new StringBuffer();
+               buf.append("StatusInfo "); //$NON-NLS-1$
+               if (fSeverity == OK) {
+                       buf.append("OK"); //$NON-NLS-1$
+               } else if (fSeverity == ERROR) {
+                       buf.append("ERROR"); //$NON-NLS-1$
+               } else if (fSeverity == WARNING) {
+                       buf.append("WARNING"); //$NON-NLS-1$
+               } else if (fSeverity == INFO) {
+                       buf.append("INFO"); //$NON-NLS-1$
+               } else {
+                       buf.append("severity="); //$NON-NLS-1$
+                       buf.append(fSeverity);
+               }
+               buf.append(": "); //$NON-NLS-1$
+               buf.append(fStatusMessage);
+               return buf.toString();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusTool.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusTool.java
new file mode 100644 (file)
index 0000000..32e9036
--- /dev/null
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs;
+
+import org.eclipse.core.runtime.IStatus;
+
+import org.eclipse.jface.dialogs.DialogPage;
+
+public class StatusTool {
+       /**
+        * Applies the status to the status line of a dialog page
+        */
+       public static void applyToStatusLine(MessageLine messageLine, IStatus status) {
+               String[] messages= getErrorMessages(status);
+               messageLine.setErrorMessage(messages[0]);
+               messageLine.setMessage(messages[1]);
+       }
+
+       /**
+        * Applies the status to the status line of a dialog page
+        */
+       public static void applyToStatusLine(DialogPage page, IStatus status) {
+               String[] messages= getErrorMessages(status);
+               page.setErrorMessage(messages[0]);
+               page.setMessage(messages[1]);
+       }
+
+       /**
+        * Returns error-message / warning-message for a status
+        */
+       public static String[] getErrorMessages(IStatus status) {
+               String message= status.getMessage();
+               if (status.matches(IStatus.ERROR) && !"".equals(message)) { //$NON-NLS-1$
+                       return new String[] { message, null };
+               } else if (status.matches(IStatus.WARNING | IStatus.INFO)) {
+                       return new String[] { null, message };
+               } else {
+                       return new String[] { null, null };
+               }
+       }
+
+       /**
+        * Compare two IStatus. The more severe is returned:
+        * An error is more severe than a warning, and a warning is more severe
+        * than ok.
+        */
+       public static IStatus getMoreSevere(IStatus s1, IStatus s2) {
+               if (s1.getSeverity() > s2.getSeverity()) {
+                       return s1;
+               }
+               return s2;
+       }
+
+       /**
+        * Finds the most severe status from a array of status
+        * An error is more severe than a warning, and a warning is more severe
+        * than ok.
+        */
+       public static IStatus getMostSevere(IStatus[] status) {
+               IStatus max= null;
+               for (int i= 0; i < status.length; i++) {
+                       IStatus curr= status[i];
+                       if (curr.matches(IStatus.ERROR)) {
+                               return curr;
+                       }
+                       if (max == null || curr.getSeverity() > max.getSeverity()) {
+                               max= curr;
+                       }
+               }
+               return max;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusUtil.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusUtil.java
new file mode 100644 (file)
index 0000000..4b5e291
--- /dev/null
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs;
+
+import org.eclipse.core.runtime.IStatus;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.dialogs.IMessageProvider;
+
+/**
+ * A utility class to work with IStatus.
+ */
+public class StatusUtil {
+       /**
+        * Compares two instances of <code>IStatus</code>. The more severe is returned:
+        * An error is more severe than a warning, and a warning is more severe
+        * than ok. If the two statuses have the same severity, the second is returned.
+        */
+       public static IStatus getMoreSevere(IStatus s1, IStatus s2) {
+               if (s1.getSeverity() > s2.getSeverity()) {
+                       return s1;
+               }
+               return s2;
+       }
+
+       /**
+        * Finds the most severe status from a array of statuses.
+        * An error is more severe than a warning, and a warning is more severe
+        * than ok.
+        */
+       public static IStatus getMostSevere(IStatus[] status) {
+               IStatus max= null;
+               for (int i= 0; i < status.length; i++) {
+                       IStatus curr= status[i];
+                       if (curr.matches(IStatus.ERROR)) {
+                               return curr;
+                       }
+                       if (max == null || curr.getSeverity() > max.getSeverity()) {
+                               max= curr;
+                       }
+               }
+               return max;
+       }
+               
+       /**
+        * Applies the status to the status line of a dialog page.
+        */
+       public static void applyToStatusLine(DialogPage page, IStatus status) {
+               String message= status.getMessage();
+               switch (status.getSeverity()) {
+               case IStatus.OK:
+                       page.setMessage(message, IMessageProvider.NONE);
+                       page.setErrorMessage(null);
+                       break;
+               case IStatus.WARNING:
+                       page.setMessage(message, IMessageProvider.WARNING);
+                       page.setErrorMessage(null);
+                       break;                          
+               case IStatus.INFO:
+                       page.setMessage(message, IMessageProvider.INFORMATION);
+                       page.setErrorMessage(null);
+                       break;                  
+               default:
+                       if (message.length() == 0) {
+                               message= null;
+                       }
+                       page.setMessage(null);
+                       page.setErrorMessage(message);
+                       break;          
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TypedElementSelectionValidator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TypedElementSelectionValidator.java
new file mode 100644 (file)
index 0000000..fdb6e2c
--- /dev/null
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs;
+
+import java.util.Collection;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+
+
+/**
+ * Implementation of a <code>ISelectionValidator</code> to validate the
+ * type of an element.
+ * Empty selections are not accepted.
+ */
+public class TypedElementSelectionValidator implements ISelectionStatusValidator {
+
+       private IStatus fgErrorStatus= new StatusInfo(IStatus.ERROR, ""); //$NON-NLS-1$
+       private IStatus fgOKStatus= new StatusInfo();
+
+       private Class<?>[] fAcceptedTypes;
+       private boolean fAllowMultipleSelection;
+       private Collection<?> fRejectedElements;
+       
+       /**
+        * @param acceptedTypes The types accepted by the validator
+        * @param allowMultipleSelection If set to <code>true</code>, the validator
+        * allows multiple selection.
+        */
+       public TypedElementSelectionValidator(Class<?>[] acceptedTypes, boolean allowMultipleSelection) {
+               this(acceptedTypes, allowMultipleSelection, null);
+       }
+       
+       /**
+        * @param acceptedTypes The types accepted by the validator
+        * @param allowMultipleSelection If set to <code>true</code>, the validator
+        * allows multiple selection.
+        * @param rejectedElements A list of elements that are not accepted
+        */
+       public TypedElementSelectionValidator(Class<?>[] acceptedTypes, boolean allowMultipleSelection, Collection<Object> rejectedElements) {
+               Assert.isNotNull(acceptedTypes);
+               fAcceptedTypes= acceptedTypes;
+               fAllowMultipleSelection= allowMultipleSelection;
+               fRejectedElements= rejectedElements;
+       }       
+       
+       /*
+        * @see org.eclipse.ui.dialogs.ISelectionValidator#isValid(java.lang.Object)
+        */
+       public IStatus validate(Object[] elements) {
+               if (isValid(elements)) {
+                       return fgOKStatus;
+               }
+               return fgErrorStatus;
+       }       
+
+       private boolean isOfAcceptedType(Object o) {
+               for (int i= 0; i < fAcceptedTypes.length; i++) {
+                       if (fAcceptedTypes[i].isInstance(o)) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+       
+       private boolean isRejectedElement(Object elem) {
+               return (fRejectedElements != null) && fRejectedElements.contains(elem);
+       }
+       
+       private boolean isValid(Object[] selection) {
+               if (selection.length == 0) {
+                       return false;
+               }
+               
+               if (!fAllowMultipleSelection && selection.length != 1) {
+                       return false;
+               }
+               
+               for (int i= 0; i < selection.length; i++) {
+                       Object o= selection[i]; 
+                       if (!isOfAcceptedType(o) || isRejectedElement(o)) {
+                               return false;
+                       }
+               }
+               return true;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TypedViewerFilter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TypedViewerFilter.java
new file mode 100644 (file)
index 0000000..4c2e850
--- /dev/null
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+/**
+ * Viewer filter used in selection dialogs.
+ */
+public class TypedViewerFilter extends ViewerFilter {
+
+       private Class<?>[] fAcceptedTypes;
+       private Object[] fRejectedElements;
+
+       /**
+        * Creates a filter that only allows elements of gives types.
+        * @param acceptedTypes The types of accepted elements
+        */
+       public TypedViewerFilter(Class<?>[] acceptedTypes) {
+               this(acceptedTypes, null);
+       }
+
+       /**
+        * Creates a filter that only allows elements of gives types, but not from a
+        * list of rejected elements.
+        * @param acceptedTypes Accepted elements must be of this types
+        * @param rejectedElements Element equals to the rejected elements are
+        * filtered out
+        */     
+       public TypedViewerFilter(Class<?>[] acceptedTypes, Object[] rejectedElements) {
+               Assert.isNotNull(acceptedTypes);
+               fAcceptedTypes= acceptedTypes;
+               fRejectedElements= rejectedElements;
+       }       
+
+       /**
+        * @see ViewerFilter#select
+        */
+       @Override
+       public boolean select(Viewer viewer, Object parentElement, Object element) {
+               if (fRejectedElements != null) {
+                       for (int i= 0; i < fRejectedElements.length; i++) {
+                               if (element.equals(fRejectedElements[i])) {
+                                       return false;
+                               }
+                       }
+               }
+               for (int i= 0; i < fAcceptedTypes.length; i++) {
+                       if (fAcceptedTypes[i].isInstance(element)) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/AbstractPathOptionBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/AbstractPathOptionBlock.java
new file mode 100644 (file)
index 0000000..35ffc65
--- /dev/null
@@ -0,0 +1,361 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.core.runtime.SubProgressMonitor;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICModelStatus;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
+import org.eclipse.cdt.ui.dialogs.ICOptionPage;
+import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
+
+import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
+import org.eclipse.cdt.internal.ui.util.CoreUtility;
+
+/**
+ * Abstract block for C/C++ Project Paths page for 3.X projects.
+ * 
+ * @deprecated as of CDT 4.0. This option block was used to set preferences/properties
+ * for 3.X style projects.
+ */
+@Deprecated
+abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock implements ICOptionContainer {
+
+       private StatusInfo fCPathStatus;
+       private StatusInfo fBuildPathStatus;
+
+       private ICElement fCurrCElement;
+       
+       private String fUserSettingsTimeStamp;
+       private long fFileTimeStamp;
+
+       private int fPageIndex, fPageCount;
+       private CPathBasePage fCurrPage;
+
+       private IStatusChangeListener fContext;
+
+       public AbstractPathOptionBlock(IStatusChangeListener context, int pageToShow) {
+               super(false);
+
+               fContext = context;
+               fPageIndex = pageToShow;
+
+               fCPathStatus = new StatusInfo();
+               fBuildPathStatus = new StatusInfo();
+
+               setOptionContainer(this);
+       }
+
+       // -------- public api --------
+
+       /**
+        * @return Returns the current class path (raw). Note that the entries
+        *         returned must not be valid.
+        */
+       public IPathEntry[] getRawCPath() throws CModelException{
+               List<CPElement> elements = getCPaths();
+
+               IPathEntry[] entries = getCProject().getRawPathEntries();
+               List<IPathEntry> cpath = new ArrayList<IPathEntry>(elements.size() + entries.length);
+
+               int[] applyTypes = getAppliedFilteredTypes(); 
+               // create and set the paths
+               for (int i = 0; i < elements.size(); i++) {
+                       CPElement entry = (elements.get(i));                    
+                       for (int applyType : applyTypes) {
+                               if (entry.getEntryKind() == applyType) {
+                                       cpath.add(entry.getPathEntry());
+                                       break;
+                               }
+                       }
+               }
+
+               // add entries which do not match type being applyed by the ui block
+               for (IPathEntry entrie : entries) {
+                       int pathType = entrie.getEntryKind();
+                       boolean found = false;
+                       for (int applyType : applyTypes) {
+                               if (pathType == applyType) {
+                                       found = true;
+                                       break;
+                               }
+                       }
+                       if (!found) {
+                               cpath.add(entrie);
+                       }
+               }
+               
+               return cpath.toArray(new IPathEntry[cpath.size()]);
+       }
+
+       /**
+        * Initializes the paths for the given project. Multiple calls to init are
+        * allowed, but all existing settings will be cleared and replace by the
+        * given or default paths.
+        * 
+        * @param element
+        *        The C/C++ project to configure. Does not have to exist.
+        * @param cpathEntries
+        *        The path entries to be set in the page. If <code>null</code> is
+        *        passed, jdt default settings are used, or - if the project is an
+        *        existing Java project - the path entries of the existing project
+        */
+       public void init(ICElement element, IPathEntry[] cpathEntries) {
+               setCElement(element);
+               List<CPElement> newCPath = null;
+
+               if (cpathEntries == null) {
+                       try {
+                               cpathEntries = getCProject().getRawPathEntries();
+                       } catch (CModelException e) {
+                       }
+                       
+               }
+               if (cpathEntries != null) {
+                       newCPath = getFilteredElements(cpathEntries, getFilteredTypes());
+               } else {
+                       newCPath = new ArrayList<CPElement>();
+               }
+               initialize(element, newCPath);
+       }
+
+       abstract protected int[] getFilteredTypes(); // path type which block would like access to
+       abstract protected int[] getAppliedFilteredTypes(); // path type which block modifies 
+
+       abstract protected void initialize(ICElement element, List<CPElement> cPaths);
+
+       protected ArrayList<CPElement> getFilteredElements(IPathEntry[] cPathEntries, int[] types) {
+               ArrayList<CPElement> newCPath = new ArrayList<CPElement>();
+               for (IPathEntry curr : cPathEntries) {
+                       if (contains(types, curr.getEntryKind())) {
+                               newCPath.add(CPElement.createFromExisting(curr, getCElement()));
+                       }
+               }
+               return newCPath;
+       }
+
+       // returns true if set contains elem
+       private boolean contains(int[] set, int elem) {
+               if (set == null)
+                       return false;
+               for (int i = 0; i < set.length; ++i) {
+                       if (set[i] == elem)
+                               return true;
+               }
+               return false;
+       }
+
+       abstract protected List<CPElement> getCPaths();
+
+       private String getEncodedSettings() {
+               StringBuffer buf = new StringBuffer();
+               
+               List<CPElement> elements = getCPaths();
+               int nElements = elements.size();
+               buf.append('[').append(nElements).append(']');
+               for (int i = 0; i < nElements; i++) {
+                       CPElement elem = elements.get(i);
+                       elem.appendEncodedSettings(buf);
+               }
+               return buf.toString();
+       }
+
+       public boolean hasChangesInDialog() {
+               String currSettings = getEncodedSettings();
+               return !currSettings.equals(fUserSettingsTimeStamp);
+       }
+
+       public boolean hasChangesInCPathFile() {
+               IFile file = getProject().getFile(".cdtproject"); //$NON-NLS-1$
+               return fFileTimeStamp != file.getModificationStamp();
+       }
+
+       public void initializeTimeStamps() {
+               IFile file = getProject().getFile(".cdtproject"); //$NON-NLS-1$
+               fFileTimeStamp = file.getModificationStamp();
+               fUserSettingsTimeStamp = getEncodedSettings();
+       }
+
+       @Override
+       abstract protected void addTabs();
+
+       protected void setCElement(ICElement element) {
+               fCurrCElement = element;
+       }
+
+       protected ICElement getCElement() {
+               return fCurrCElement;
+       }
+
+       protected ICProject getCProject() {
+               return fCurrCElement.getCProject();
+       }
+
+       public IProject getProject() {
+               return getCProject().getProject();
+       }
+
+       protected void doStatusLineUpdate() {
+               IStatus res = findMostSevereStatus();
+               fContext.statusChanged(res);
+       }
+
+       private IStatus findMostSevereStatus() {
+               return StatusUtil.getMostSevere(new IStatus[] { fCPathStatus, fBuildPathStatus});
+       }
+
+       protected StatusInfo getPathStatus() {
+               return fCPathStatus;
+       }
+
+       // -------- tab switching ----------
+
+       @Override
+       public void setCurrentPage(ICOptionPage page) {
+               super.setCurrentPage(page);
+               CPathBasePage newPage = (CPathBasePage) page;
+               if (fCurrPage != null) {
+                       List<?> selection = fCurrPage.getSelection();
+                       if (!selection.isEmpty()) {
+                               newPage.setSelection(selection);
+                       }
+               }
+               fCurrPage = (CPathBasePage) page;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.cdt.ui.dialogs.ICOptionContainer#updateContainer()
+        */
+       public void updateContainer() {
+               update();
+       }
+
+       protected void updateBuildPathStatus() {
+               List<CPElement> elements = getCPaths();
+               IPathEntry[] entries = new IPathEntry[elements.size()];
+
+               for (int i = elements.size() - 1; i >= 0; i--) {
+                       CPElement currElement = elements.get(i);
+                       entries[i] = currElement.getPathEntry();
+               }
+
+               ICModelStatus status = CoreModel.validatePathEntries(getCProject(), entries);
+               if (!status.isOK()) {
+                       fBuildPathStatus.setError(status.getMessage());
+                       return;
+               }
+               fBuildPathStatus.setOK();
+       }
+
+       public Preferences getPreferences() {
+               return null;
+       }
+
+       protected void addPage(CPathBasePage page) {
+               addTab(page);
+               if (fPageIndex == fPageCount) {
+                       fCurrPage = page;
+               }
+               fPageCount++;
+       }
+
+       @Override
+       protected ICOptionPage getStartPage() {
+               if (fCurrPage == null) {
+                       return super.getStartPage();
+               }
+               return fCurrPage;
+       }
+
+       protected void internalConfigureCProject(List<CPElement> cPathEntries, IProgressMonitor monitor) throws CoreException,
+                       InterruptedException {
+               // 10 monitor steps to go
+
+               monitor.worked(2);
+               
+               IPathEntry[] entries = getCProject().getRawPathEntries();
+               
+               List<IPathEntry> cpath = new ArrayList<IPathEntry>(cPathEntries.size() + entries.length);
+
+               int[] applyTypes = getAppliedFilteredTypes(); 
+               // create and set the paths
+               for (int i = 0; i < cPathEntries.size(); i++) {
+                       CPElement entry = (cPathEntries.get(i));                        
+                       for (int applyType : applyTypes) {
+                               if (entry.getEntryKind() == applyType) {
+                                       IResource res = entry.getResource();
+                                       if ((res instanceof IFolder) && !res.exists()) {
+                                               CoreUtility.createFolder((IFolder) res, true, true, null);
+                                       }
+                                       cpath.add(entry.getPathEntry());
+                                       break;
+                               }
+                       }
+               }
+
+               // add entries which do not match type being applyed by the ui block
+               for (IPathEntry entrie : entries) {
+                       int pathType = entrie.getEntryKind();
+                       boolean found = false;
+                       for (int applyType : applyTypes) {
+                               if (pathType == applyType) {
+                                       found = true;
+                                       break;
+                               }
+                       }
+                       if (!found) {
+                               cpath.add(entrie);
+                       }
+               }
+               monitor.worked(1);
+
+               getCProject().setRawPathEntries(cpath.toArray(new IPathEntry[cpath.size()]),
+                               new SubProgressMonitor(monitor, 7));
+       }
+
+       // -------- creation -------------------------------
+
+       public void configureCProject(IProgressMonitor monitor) throws CoreException, InterruptedException {
+               if (monitor == null) {
+                       monitor = new NullProgressMonitor();
+               }
+               monitor.setTaskName(CPathEntryMessages.CPathsBlock_operationdesc_c); 
+               monitor.beginTask("", 10); //$NON-NLS-1$
+
+               try {
+                       internalConfigureCProject(getCPaths(), monitor);
+                       initializeTimeStamps();
+               } finally {
+                       monitor.done();
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ArchiveFileFilter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ArchiveFileFilter.java
new file mode 100644 (file)
index 0000000..f324ce7
--- /dev/null
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+/**
+ * Viewer filter for archive selection dialogs.
+ * Archives are files with file extension "a",  "dll", "so.
+ * The filter is not case sensitive.
+ * 
+ * @deprecated as of CDT 4.0. This class was used for property pages
+ * for 3.X style projects.
+ */
+@Deprecated
+public class ArchiveFileFilter extends ViewerFilter {
+
+       private static final String[] fgArchiveExtensions= { "a", "so", "dll" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+       private List<IFile> fExcludes;
+       private boolean fRecursive;
+       
+       /**
+        * @param excludedFiles Excluded files will not pass the filter.
+        * <code>null</code> is allowed if no files should be excluded. 
+        * @param recusive Folders are only shown if, searched recursivly, contain
+        * an archive
+        */
+       public ArchiveFileFilter(IFile[] excludedFiles, boolean recusive) {
+               if (excludedFiles != null) {
+                       fExcludes= Arrays.asList(excludedFiles);
+               } else {
+                       fExcludes= null;
+               }
+               fRecursive= recusive;
+       }
+       
+       /*
+        * @see ViewerFilter#select
+        */
+       @Override
+       public boolean select(Viewer viewer, Object parent, Object element) {
+               if (element instanceof IFile) {
+                       if (fExcludes != null && fExcludes.contains(element)) {
+                               return false;
+                       }
+                       return isArchivePath(((IFile)element).getFullPath());
+               } else if (element instanceof IContainer) { // IProject, IFolder
+                       if (!fRecursive) {
+                               return true;
+                       }
+                       try {
+                               IResource[] resources= ((IContainer)element).members();
+                               for (int i= 0; i < resources.length; i++) {
+                                       // recursive! Only show containers that contain an archive
+                                       if (select(viewer, parent, resources[i])) {
+                                               return true;
+                                       }
+                               }
+                       } catch (CoreException e) {
+                               CUIPlugin.log(e.getStatus());
+                       }                               
+               }
+               return false;
+       }
+       
+       public static boolean isArchivePath(IPath path) {
+               String ext= path.getFileExtension();
+               if (ext != null && ext.length() != 0) {
+                       return isArchiveFileExtension(ext);
+               }
+               return false;
+       }
+       
+       public static boolean isArchiveFileExtension(String ext) {
+               for (int i= 0; i < fgArchiveExtensions.length; i++) {
+                       if (ext.equalsIgnoreCase(fgArchiveExtensions[i])) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+                       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElement.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElement.java
new file mode 100644 (file)
index 0000000..0f8157a
--- /dev/null
@@ -0,0 +1,794 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IIncludeEntry;
+import org.eclipse.cdt.core.model.IIncludeFileEntry;
+import org.eclipse.cdt.core.model.ILibraryEntry;
+import org.eclipse.cdt.core.model.IMacroEntry;
+import org.eclipse.cdt.core.model.IMacroFileEntry;
+import org.eclipse.cdt.core.model.IOutputEntry;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.core.model.IPathEntryContainer;
+import org.eclipse.cdt.core.model.IPathEntryContainerExtension;
+import org.eclipse.cdt.core.model.ISourceEntry;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * @deprecated as of CDT 4.0. This class was used for property pages
+ * for 3.X style projects.
+ */
+@Deprecated
+public class CPElement {
+       public static final String SOURCEATTACHMENT = "sourcepath"; //$NON-NLS-1$
+       public static final String SOURCEATTACHMENTROOT = "rootpath"; //$NON-NLS-1$
+       public static final String EXCLUSION = "exclusion"; //$NON-NLS-1$
+       public static final String INCLUDE = "includepath"; //$NON-NLS-1$
+       public static final String LIBRARY = "librarypath"; //$NON-NLS-1$
+       public static final String SYSTEM_INCLUDE = "systeminclude"; //$NON-NLS-1$
+       public static final String MACRO_NAME = "macroname"; //$NON-NLS-1$
+       public static final String MACRO_VALUE = "macrovalue"; //$NON-NLS-1$
+       public static final String BASE_REF = "base-ref"; //$NON-NLS-1$
+       public static final String BASE = "base-path"; //$NON-NLS-1$
+       public static final String PARENT = "parent"; //$NON-NLS-1$
+       public static final String PARENT_CONTAINER = "parent-container"; //$NON-NLS-1$
+    public static final String INCLUDE_FILE = "includefile"; //$NON-NLS-1$
+    public static final String MACROS_FILE = "macrosfile"; //$NON-NLS-1$
+
+       private final int fEntryKind;
+       private final IPath fPath;
+       private final ICProject fCProject;
+       private final IResource fResource;
+       private final ArrayList<Object> fChildren = new ArrayList<Object>(1);
+
+       private boolean fIsExported;
+
+       private IPathEntry fCachedEntry;
+       private CPElement Inherited; // used when the path is duplicated on a child
+                                                                // resource but is inherited from a parent
+                                                                // resource these are not real path entries
+
+       private IStatus fStatus;
+       
+       // create a inherited element and apply to path/resource
+       public CPElement(CPElement element, IPath path, IResource res) {
+               this(element.getCProject(), element.getEntryKind(), path, res);
+               setExported(element.isExported());
+               fChildren.clear();
+               for(int i = 0; i < element.fChildren.size(); i++) {
+                       CPElementAttribute attrib = (CPElementAttribute)element.fChildren.get(i);
+                       fChildren.add(new CPElementAttribute(this, attrib.getKey(), attrib.getValue()));
+               }
+               Inherited = element;
+       }
+
+       public CPElement(ICProject project, int entryKind, IPath path, IResource res) {
+               fCProject = project;
+               fEntryKind = entryKind;
+               fPath = path;
+               fResource = res;
+
+               fIsExported = false;
+               fCachedEntry = null;
+
+               switch (entryKind) {
+                       case IPathEntry.CDT_OUTPUT:
+                               createAttributeElement(EXCLUSION, new Path[0]);
+                               break;
+                       case IPathEntry.CDT_SOURCE:
+                               createAttributeElement(EXCLUSION, new Path[0]);
+                               break;
+                       case IPathEntry.CDT_LIBRARY:
+                               createAttributeElement(LIBRARY, new Path("")); //$NON-NLS-1$
+                               createAttributeElement(SOURCEATTACHMENT, null);
+                               createAttributeElement(BASE_REF, new Path("")); //$NON-NLS-1$
+                               createAttributeElement(BASE, new Path("")); //$NON-NLS-1$
+                               break;
+                       case IPathEntry.CDT_INCLUDE:
+                               createAttributeElement(INCLUDE, new Path("")); //$NON-NLS-1$
+                               createAttributeElement(EXCLUSION, new Path[0]);
+                               createAttributeElement(SYSTEM_INCLUDE, Boolean.valueOf(true));
+                               createAttributeElement(BASE_REF, new Path("")); //$NON-NLS-1$
+                               createAttributeElement(BASE, new Path("")); //$NON-NLS-1$
+                               break;
+            case IPathEntry.CDT_INCLUDE_FILE:
+                createAttributeElement(INCLUDE_FILE, new Path("")); //$NON-NLS-1$
+                createAttributeElement(EXCLUSION, new Path[0]);
+                createAttributeElement(BASE_REF, new Path("")); //$NON-NLS-1$
+                createAttributeElement(BASE, new Path("")); //$NON-NLS-1$
+                break;
+                       case IPathEntry.CDT_MACRO:
+                               createAttributeElement(MACRO_NAME, ""); //$NON-NLS-1$
+                               createAttributeElement(MACRO_VALUE, ""); //$NON-NLS-1$
+                               createAttributeElement(EXCLUSION, new Path[0]);
+                               createAttributeElement(BASE_REF, new Path("")); //$NON-NLS-1$
+                               createAttributeElement(BASE, new Path("")); //$NON-NLS-1$
+                               break;
+            case IPathEntry.CDT_MACRO_FILE:
+                createAttributeElement(MACROS_FILE, new Path("")); //$NON-NLS-1$
+                createAttributeElement(EXCLUSION, new Path[0]);
+                createAttributeElement(BASE_REF, new Path("")); //$NON-NLS-1$
+                createAttributeElement(BASE, new Path("")); //$NON-NLS-1$
+                break;
+                       case IPathEntry.CDT_CONTAINER:
+                               try {
+                                       IPathEntryContainer container = CoreModel.getPathEntryContainer(fPath, fCProject);
+                                       if (container != null) {
+                        IPathEntry[] entries = null;
+                        if (container instanceof IPathEntryContainerExtension &&
+                                res instanceof IFile) {
+                            IPathEntryContainerExtension extContainer = (IPathEntryContainerExtension) container;
+                            entries = extContainer.getPathEntries(res.getFullPath(),
+                                    IPathEntry.CDT_INCLUDE | IPathEntry.CDT_MACRO |
+                                    IPathEntry.CDT_INCLUDE_FILE | IPathEntry.CDT_MACRO_FILE);
+                        } else {
+                            entries = container.getPathEntries();
+                        }
+                                               for (IPathEntry entrie : entries) {
+                                                       CPElement curr = createFromExisting(entrie, fCProject);
+                                                       curr.createAttributeElement(PARENT_CONTAINER, this);
+                                                       CPElementGroup group = new CPElementGroup(this, curr.getEntryKind());
+                                                       int indx = fChildren.indexOf(group);
+                                                       if (indx == -1) {
+                                                               fChildren.add(group);
+                                                       } else {
+                                                               group = (CPElementGroup)fChildren.get(indx);
+                                                       }
+                                                       group.addChild(curr);
+                                               }
+                                       }
+                               } catch (CModelException e) {
+                               }
+                               break;
+                       default:
+                               break;
+               }
+       }
+
+       public IPathEntry getPathEntry() {
+               if (Inherited != null) {
+                       return null;
+               }
+               if (fCachedEntry == null) {
+                       fCachedEntry = newPathEntry();
+               }
+               return fCachedEntry;
+       }
+
+       private IPathEntry newPathEntry() {
+               IPath[] exclusionPattern = (IPath[])getAttribute(EXCLUSION);
+               IPath base = (IPath)getAttribute(BASE);
+               IPath baseRef = (IPath)getAttribute(BASE_REF);
+               switch (fEntryKind) {
+                       case IPathEntry.CDT_OUTPUT:
+                               return CoreModel.newOutputEntry(fPath, exclusionPattern);
+                       case IPathEntry.CDT_SOURCE:
+                               return CoreModel.newSourceEntry(fPath, exclusionPattern);
+                       case IPathEntry.CDT_LIBRARY:
+                               IPath libraryPath = (IPath)getAttribute(LIBRARY);
+                               IPath attach = (IPath)getAttribute(SOURCEATTACHMENT);
+                               if (!baseRef.isEmpty()) {
+                                       return CoreModel.newLibraryRefEntry(fPath, baseRef, libraryPath);
+                               }
+                               return CoreModel.newLibraryEntry(fPath, base, libraryPath, attach, null, null, isExported());
+                       case IPathEntry.CDT_PROJECT:
+                               return CoreModel.newProjectEntry(fPath, isExported());
+                       case IPathEntry.CDT_CONTAINER:
+                               return CoreModel.newContainerEntry(fPath, isExported());
+                       case IPathEntry.CDT_INCLUDE:
+                               IPath include = (IPath)getAttribute(INCLUDE);
+                               if (!baseRef.isEmpty()) {
+                                       return CoreModel.newIncludeRefEntry(fPath, baseRef, include);
+                               }
+                               return CoreModel.newIncludeEntry(fPath, base, include, ((Boolean)getAttribute(SYSTEM_INCLUDE)).booleanValue(),
+                                               exclusionPattern, isExported());
+            case IPathEntry.CDT_INCLUDE_FILE:
+                IPath includeFile = (IPath)getAttribute(INCLUDE_FILE);
+                return CoreModel.newIncludeFileEntry(fPath, baseRef, base, includeFile,
+                        exclusionPattern, isExported());
+                       case IPathEntry.CDT_MACRO:
+                               String macroName = (String)getAttribute(MACRO_NAME);
+                               String macroValue = (String)getAttribute(MACRO_VALUE);
+                               if (!baseRef.isEmpty()) {
+                                       return CoreModel.newMacroRefEntry(fPath, baseRef, macroName);
+                               }
+                               return CoreModel.newMacroEntry(fPath, macroName, macroValue, exclusionPattern, isExported());
+            case IPathEntry.CDT_MACRO_FILE:
+                IPath macrosFile = (IPath)getAttribute(MACROS_FILE);
+                return CoreModel.newMacroFileEntry(fPath, baseRef, base, macrosFile,
+                        exclusionPattern, isExported());
+                       default:
+                               return null;
+               }
+       }
+
+       public static StringBuffer appendEncodePath(IPath path, StringBuffer buf) {
+               if (path != null) {
+                       String str = path.toString();
+                       buf.append('[').append(str.length()).append(']').append(str);
+               } else {
+                       buf.append('[').append(']');
+               }
+               return buf.append(';');
+       }
+
+       public StringBuffer appendEncodedSettings(StringBuffer buf) {
+               buf.append(fEntryKind).append(';');
+               appendEncodePath(fPath, buf).append(';');
+               buf.append(Boolean.valueOf(fIsExported)).append(';');
+               switch (fEntryKind) {
+                       case IPathEntry.CDT_OUTPUT:
+                       case IPathEntry.CDT_SOURCE:
+                       case IPathEntry.CDT_INCLUDE:
+            case IPathEntry.CDT_INCLUDE_FILE:
+                       case IPathEntry.CDT_MACRO:
+            case IPathEntry.CDT_MACRO_FILE:
+                               IPath[] exclusion = (IPath[])getAttribute(EXCLUSION);
+                               buf.append('[').append(exclusion.length).append(']');
+                               for (IPath element : exclusion) {
+                                       appendEncodePath(element, buf);
+                               }
+                               switch (fEntryKind) {
+                                       case IPathEntry.CDT_INCLUDE:
+                                               IPath baseRef = (IPath)getAttribute(BASE_REF);
+                                               appendEncodePath(baseRef, buf);
+                                               IPath base = (IPath)getAttribute(BASE);
+                                               appendEncodePath(base, buf);
+                                               IPath include = (IPath)getAttribute(INCLUDE);
+                                               appendEncodePath(include, buf);
+                                               break;
+                    case IPathEntry.CDT_INCLUDE_FILE:
+                        baseRef = (IPath)getAttribute(BASE_REF);
+                        appendEncodePath(baseRef, buf);
+                        base = (IPath)getAttribute(BASE);
+                        appendEncodePath(base, buf);
+                        IPath includeFile = (IPath)getAttribute(INCLUDE_FILE);
+                        appendEncodePath(includeFile, buf);
+                        break;
+                                       case IPathEntry.CDT_MACRO:
+                                               baseRef = (IPath)getAttribute(BASE_REF);
+                                               appendEncodePath(baseRef, buf);
+                                               base = (IPath)getAttribute(BASE);
+                                               appendEncodePath(base, buf);
+                                               String symbol = (String)getAttribute(MACRO_NAME);
+                                               buf.append(symbol).append(';');
+                                               break;
+                    case IPathEntry.CDT_MACRO_FILE:
+                        baseRef = (IPath)getAttribute(BASE_REF);
+                        appendEncodePath(baseRef, buf);
+                        base = (IPath)getAttribute(BASE);
+                        appendEncodePath(base, buf);
+                        IPath macrosFile = (IPath)getAttribute(MACROS_FILE);
+                        appendEncodePath(macrosFile, buf);
+                        break;
+                                       default:
+                                               break;
+                               }
+                               break;
+                       case IPathEntry.CDT_LIBRARY:
+                               IPath baseRef = (IPath)getAttribute(BASE_REF);
+                               appendEncodePath(baseRef, buf);
+                               IPath base = (IPath)getAttribute(BASE);
+                               appendEncodePath(base, buf);
+                               IPath sourceAttach = (IPath)getAttribute(SOURCEATTACHMENT);
+                               appendEncodePath(sourceAttach, buf);
+                               IPath library = (IPath)getAttribute(LIBRARY);
+                               appendEncodePath(library, buf);
+                               break;
+                       default:
+                               break;
+               }
+               buf.setLength(buf.length() - 1);
+               return buf;
+       }
+
+       /**
+        * Gets the path entry path.
+        * 
+        * @see IPathEntry#getPath()
+        */
+       public IPath getPath() {
+               return fPath;
+       }
+
+       /**
+        * Gets the classpath entry kind.
+        * 
+        * @see IPathEntry#getEntryKind()
+        */
+       public int getEntryKind() {
+               return fEntryKind;
+       }
+
+       /**
+        * Entries without resource are either non existing or a variable entry
+        * External jars do not have a resource
+        */
+       public IResource getResource() {
+               return fResource;
+       }
+
+       public CPElement getParentContainer() {
+               CPElementAttribute attribute = findAttributeElement(PARENT_CONTAINER);
+               if (attribute != null) {
+                       return (CPElement)attribute.getValue();
+               }
+               return null;
+       }
+
+       public void setParent(CPElementGroup group) {
+               CPElementAttribute attribute = findAttributeElement(PARENT);
+               if (attribute == null) {
+                       if (group != null) {
+                               createAttributeElement(PARENT, group);
+                       }
+               } else {
+                       attribute.setValue(group);
+               }
+       }
+
+       public CPElementGroup getParent() {
+               CPElementAttribute attribute = findAttributeElement(PARENT);
+               if (attribute != null) {
+                       return (CPElementGroup)attribute.getValue();
+               }
+               return null;
+       }
+
+       public CPElementAttribute setAttribute(String key, Object value) {
+               CPElementAttribute attribute = findAttributeElement(key);
+               if (attribute == null) {
+                       return null;
+               }
+               attribute.setValue(value);
+               attributeChanged(key);
+               return attribute;
+       }
+
+       private CPElementAttribute findAttributeElement(String key) {
+               for (int i = 0; i < fChildren.size(); i++) {
+                       Object curr = fChildren.get(i);
+                       if (curr instanceof CPElementAttribute) {
+                               CPElementAttribute elem = (CPElementAttribute)curr;
+                               if (key.equals(elem.getKey())) {
+                                       return elem;
+                               }
+                       }
+               }
+               return null;
+       }
+
+       public Object getAttribute(String key) {
+               CPElementAttribute attrib = findAttributeElement(key);
+               if (attrib != null) {
+                       return attrib.getValue();
+               }
+               return null;
+       }
+
+       private void createAttributeElement(String key, Object value) {
+               fChildren.add(new CPElementAttribute(this, key, value));
+       }
+
+       public Object[] getChildren() {
+               switch (fEntryKind) {
+                       case IPathEntry.CDT_OUTPUT:
+                       case IPathEntry.CDT_SOURCE:
+                       case IPathEntry.CDT_INCLUDE:
+            case IPathEntry.CDT_INCLUDE_FILE:
+                       case IPathEntry.CDT_MACRO:
+            case IPathEntry.CDT_MACRO_FILE:
+                               if (getInherited() == null && getParentContainer() == null) {
+                                       return new Object[]{findAttributeElement(EXCLUSION)};
+                               }
+                               break;
+                       //                      case IPathEntry.CDT_LIBRARY:
+                       //                              return new Object[] { findAttributeElement(SOURCEATTACHMENT) };
+
+                       case IPathEntry.CDT_CONTAINER: {
+                               List<Object> list = new ArrayList<Object>();
+                               for (int i = 0; i < fChildren.size(); i++) {
+                                       Object curr = fChildren.get(i);
+                                       if (curr instanceof CPElementGroup) {
+                                               list.add(curr);
+                                       }
+                               }
+                               return list.toArray();
+                       }
+               }
+               return new Object[0];
+       }
+       
+       private void attributeChanged(String key) {
+               fCachedEntry = null;
+               fStatus = null;
+       }
+
+       /*
+        * @see Object#equals(java.lang.Object)
+        */
+       @Override
+       public boolean equals(Object other) {
+               if (other != null && other.getClass().equals(getClass())) {
+                       CPElement elem = (CPElement)other;
+                       if (elem.fEntryKind != fEntryKind || !elem.fPath.equals(fPath)) {
+                               return false;
+                       }
+                       switch (fEntryKind) {
+                               case IPathEntry.CDT_LIBRARY:
+                                       return (getAttribute(LIBRARY).equals(elem.getAttribute(LIBRARY))
+                                                       && getAttribute(BASE).equals(elem.getAttribute(BASE)) && getAttribute(BASE_REF).equals(
+                                                       elem.getAttribute(BASE_REF)));
+                               case IPathEntry.CDT_INCLUDE:
+                                       return (getAttribute(INCLUDE).equals(elem.getAttribute(INCLUDE))
+                                                       && getAttribute(BASE_REF).equals(elem.getAttribute(BASE_REF)) && getAttribute(BASE).equals(
+                                                       elem.getAttribute(BASE)));
+                case IPathEntry.CDT_INCLUDE_FILE:
+                    return (getAttribute(INCLUDE_FILE).equals(elem.getAttribute(INCLUDE_FILE))
+                            && getAttribute(BASE_REF).equals(elem.getAttribute(BASE_REF)) && getAttribute(BASE).equals(
+                            elem.getAttribute(BASE)));
+                               case IPathEntry.CDT_MACRO:
+                                       return (getAttribute(MACRO_NAME).equals(elem.getAttribute(MACRO_NAME))
+                                                       && getAttribute(BASE_REF).equals(elem.getAttribute(BASE_REF)) && getAttribute(BASE).equals(
+                                                       elem.getAttribute(BASE)));
+                case IPathEntry.CDT_MACRO_FILE:
+                    return (getAttribute(MACROS_FILE).equals(elem.getAttribute(MACROS_FILE))
+                            && getAttribute(BASE_REF).equals(elem.getAttribute(BASE_REF)) && getAttribute(BASE).equals(
+                            elem.getAttribute(BASE)));
+                       }
+                       return true;
+               }
+               return false;
+       }
+
+       /*
+        * @see Object#hashCode()
+        */
+       @Override
+       public int hashCode() {
+               final int HASH_FACTOR = 89;
+               int hashCode = fPath.hashCode() + fEntryKind;
+               switch (fEntryKind) {
+                       case IPathEntry.CDT_LIBRARY:
+                               hashCode = hashCode * HASH_FACTOR + getAttribute(LIBRARY).hashCode();
+                               hashCode = hashCode * HASH_FACTOR + getAttribute(BASE).hashCode();
+                               hashCode = hashCode * HASH_FACTOR + getAttribute(BASE_REF).hashCode();
+                               break;
+                       case IPathEntry.CDT_INCLUDE:
+                               hashCode = hashCode * HASH_FACTOR + getAttribute(INCLUDE).hashCode();
+                               hashCode = hashCode * HASH_FACTOR + getAttribute(BASE_REF).hashCode();
+                               hashCode = hashCode * HASH_FACTOR + getAttribute(BASE).hashCode();
+                               break;
+            case IPathEntry.CDT_INCLUDE_FILE:
+                hashCode = hashCode * HASH_FACTOR + getAttribute(INCLUDE_FILE).hashCode();
+                hashCode = hashCode * HASH_FACTOR + getAttribute(BASE_REF).hashCode();
+                hashCode = hashCode * HASH_FACTOR + getAttribute(BASE).hashCode();
+                break;
+                       case IPathEntry.CDT_MACRO:
+                               hashCode = hashCode * HASH_FACTOR + getAttribute(MACRO_NAME).hashCode();
+                               hashCode = hashCode * HASH_FACTOR + getAttribute(BASE_REF).hashCode();
+                               hashCode = hashCode * HASH_FACTOR + getAttribute(BASE).hashCode();
+                               break;
+            case IPathEntry.CDT_MACRO_FILE:
+                hashCode = hashCode * HASH_FACTOR + getAttribute(MACROS_FILE).hashCode();
+                hashCode = hashCode * HASH_FACTOR + getAttribute(BASE_REF).hashCode();
+                hashCode = hashCode * HASH_FACTOR + getAttribute(BASE).hashCode();
+                break;
+               }
+               return hashCode;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see java.lang.Object#toString()
+        */
+       @Override
+       public String toString() {
+               return getPathEntry().toString();
+       }
+
+       /**
+        * Returns if a entry is missing.
+        * 
+        * @return Returns a boolean
+        */
+       public IStatus getStatus() {
+               if (Inherited != null) {
+                       return Inherited.getStatus();
+               }
+               if (fStatus == null) {
+                       fStatus = Status.OK_STATUS;
+                       IResource res = null;
+                       IPath path;
+                       IWorkspaceRoot root = CUIPlugin.getWorkspace().getRoot();
+                       IPathEntry entry = getPathEntry();
+                       switch (getEntryKind()) {
+                               case IPathEntry.CDT_CONTAINER:
+                                       try {
+                                               if ((CoreModel.getPathEntryContainer(fPath, fCProject) == null)) {
+                                                       fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1,
+                                                                       CPathEntryMessages.CPElement_status_pathContainerMissing, null); 
+                                               }
+                                       } catch (CModelException e) {
+                                       }
+                                       break;
+                               case IPathEntry.CDT_LIBRARY:
+                                       if (!((ILibraryEntry)entry).getFullLibraryPath().toFile().exists()) {
+                                               fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_libraryPathNotFound, null); 
+                                       }
+                                       break;
+                               case IPathEntry.CDT_SOURCE:
+                                       path = fPath.removeTrailingSeparator();
+                                       res = root.findMember(path);
+                                       if (res == null) {
+                                               if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
+                                                       res = root.getFolder(path);
+                                               }
+                                               fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_sourcePathMissing, null); 
+                                       }
+                                       break;
+                               case IPathEntry.CDT_OUTPUT:
+                                       path = fPath.removeTrailingSeparator();
+                                       res = root.findMember(path);
+                                       if (res == null) {
+                                               if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
+                                                       res = root.getFolder(path);
+                                               }
+                                               fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_outputPathMissing, null); 
+                                       }
+                                       break;
+                               case IPathEntry.CDT_INCLUDE:
+                                       path = fPath.removeTrailingSeparator();
+                                       res = root.findMember(path);
+                                       if (res == null) {
+                                               if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
+                                                       res = root.getFolder(path);
+                                               }
+                                       }
+                                       if (res != null && res.getType() != IResource.ROOT && res.getType() != IResource.PROJECT && fCProject != null) {
+                                               if (!fCProject.isOnSourceRoot(res)) {
+                                                       fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_notOnSourcePath, null); 
+                                               }
+                                       }
+                                       if (!((IIncludeEntry) entry).getFullIncludePath().toFile().exists()) {
+                                               fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_includePathNotFound, null); 
+                                       }
+                                       break;
+                case IPathEntry.CDT_INCLUDE_FILE:
+                    path = fPath.removeTrailingSeparator();
+                    res = root.findMember(path);
+                    if (res == null) {
+                        if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
+                            res = root.getFolder(path);
+                        }
+                    }
+                    if (res != null && res.getType() != IResource.ROOT && res.getType() != IResource.PROJECT && fCProject != null) {
+                        if (!fCProject.isOnSourceRoot(res)) {
+                            fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_notOnSourcePath, null); 
+                        }
+                    }
+                    if (!((IIncludeFileEntry)entry).getFullIncludeFilePath().toFile().exists()) {
+                        fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_includeFilePathNotFound, null); 
+                    }
+                    break;
+                               case IPathEntry.CDT_MACRO:
+                                       path = fPath.removeTrailingSeparator();
+                                       res = root.findMember(path);
+                                       if (res == null) {
+                                               if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
+                                                       res = root.getFolder(path);
+                                               }
+                                       }
+                                       if (res != null && res.getType() != IResource.ROOT && res.getType() != IResource.PROJECT && fCProject != null) {
+                                               if (!fCProject.isOnSourceRoot(res)) {
+                                                       fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_notOnSourcePath, null); 
+                                               }
+                                       }
+                                       break;
+                case IPathEntry.CDT_MACRO_FILE:
+                    path = fPath.removeTrailingSeparator();
+                    res = root.findMember(path);
+                    if (res == null) {
+                        if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
+                            res = root.getFolder(path);
+                        }
+                    }
+                    if (res != null && res.getType() != IResource.ROOT && res.getType() != IResource.PROJECT && fCProject != null) {
+                        if (!fCProject.isOnSourceRoot(res)) {
+                            fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_notOnSourcePath, null); 
+                        }
+                    }
+                    if (!((IMacroFileEntry)entry).getFullMacroFilePath().toFile().exists()) {
+                        fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_macrosFilePathNotFound, null); 
+                    }
+                    break;
+                               case IPathEntry.CDT_PROJECT:
+                                       res = root.findMember(fPath);
+                                       if (res == null) {
+                                               fStatus = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_missingProjectPath, null); 
+                                       }
+                                       break;
+                       }
+               }
+               return fStatus;
+       }
+
+       /**
+        * Returns if a entry is exported (only applies to libraries)
+        * 
+        * @return Returns a boolean
+        */
+       public boolean isExported() {
+               return fIsExported;
+       }
+
+       /**
+        * Sets the export state of the entry.
+        */
+       public void setExported(boolean isExported) {
+               if (isExported != fIsExported) {
+                       fIsExported = isExported;
+
+                       attributeChanged(null);
+               }
+       }
+
+       public CPElement getInherited() {
+               return Inherited;
+       }
+
+       /**
+        * Gets the project.
+        * 
+        * @return Returns a ICProject
+        */
+       public ICProject getCProject() {
+               return fCProject;
+       }
+
+       public static CPElement createFromExisting(IPathEntry curr, ICElement element) {
+               IPath path = curr.getPath();
+               IWorkspaceRoot root = CUIPlugin.getWorkspace().getRoot();
+               IPath sourceAttachment = null;
+               IPath[] exclusion = null;
+               IPath include = null;
+        IPath includeFile = null;
+               IPath library = null;
+               String macroName = null;
+               String macroValue = null;
+        IPath macrosFile = null;
+               boolean sysInclude = false;
+               IPath baseRef = null;
+               IPath base = null;
+
+               // get the resource
+               IResource res = null;
+
+               switch (curr.getEntryKind()) {
+                       case IPathEntry.CDT_CONTAINER:
+                               res = (element instanceof ICProject) ? null : element.getResource();
+                               break;
+                       case IPathEntry.CDT_LIBRARY:
+                               library = ((ILibraryEntry)curr).getLibraryPath();
+                               sourceAttachment = ((ILibraryEntry)curr).getSourceAttachmentPath();
+                               base = ((ILibraryEntry)curr).getBasePath();
+                               baseRef = ((ILibraryEntry)curr).getBaseReference();
+                               break;
+                       case IPathEntry.CDT_SOURCE:
+                               path = path.removeTrailingSeparator();
+                               res = root.findMember(path);
+                               if (res == null) {
+                                       if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
+                                               res = root.getFolder(path);
+                                       }
+                               }
+                               exclusion = ((ISourceEntry)curr).getExclusionPatterns();
+                               break;
+                       case IPathEntry.CDT_OUTPUT:
+                               path = path.removeTrailingSeparator();
+                               res = root.findMember(path);
+                               if (res == null) {
+                                       if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
+                                               res = root.getFolder(path);
+                                       }
+                               }
+                               exclusion = ((IOutputEntry)curr).getExclusionPatterns();
+                               break;
+                       case IPathEntry.CDT_INCLUDE:
+                               path = path.removeTrailingSeparator();
+                               res = root.findMember(path);
+                               if (res == null) {
+                                       if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
+                                               res = root.getFolder(path);
+                                       }
+                               }
+                               exclusion = ((IIncludeEntry)curr).getExclusionPatterns();
+                               sysInclude = ((IIncludeEntry)curr).isSystemInclude();
+                               baseRef = ((IIncludeEntry)curr).getBaseReference();
+                               base = ((IIncludeEntry)curr).getBasePath();
+                               include = ((IIncludeEntry)curr).getIncludePath();
+                               break;
+            case IPathEntry.CDT_INCLUDE_FILE:
+                path = path.removeTrailingSeparator();
+                res = root.findMember(path);
+                if (res == null) {
+                    if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
+                        res = root.getFolder(path);
+                    }
+                }
+                exclusion = ((IIncludeFileEntry)curr).getExclusionPatterns();
+                includeFile = ((IIncludeFileEntry)curr).getIncludeFilePath();
+                baseRef = ((IIncludeFileEntry)curr).getBaseReference();
+                base = ((IIncludeFileEntry)curr).getBasePath();
+                break;
+                       case IPathEntry.CDT_MACRO:
+                               path = path.removeTrailingSeparator();
+                               res = root.findMember(path);
+                               if (res == null) {
+                                       if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
+                                               res = root.getFolder(path);
+                                       }
+                               }
+                               exclusion = ((IMacroEntry)curr).getExclusionPatterns();
+                               macroName = ((IMacroEntry)curr).getMacroName();
+                               macroValue = ((IMacroEntry)curr).getMacroValue();
+                               baseRef = ((IMacroEntry)curr).getBaseReference();
+                               base = ((IMacroEntry)curr).getBasePath();
+                               break;
+            case IPathEntry.CDT_MACRO_FILE:
+                path = path.removeTrailingSeparator();
+                res = root.findMember(path);
+                if (res == null) {
+                    if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
+                        res = root.getFolder(path);
+                    }
+                }
+                exclusion = ((IMacroFileEntry)curr).getExclusionPatterns();
+                macrosFile = ((IMacroFileEntry)curr).getMacroFilePath();
+                baseRef = ((IMacroFileEntry)curr).getBaseReference();
+                base = ((IMacroFileEntry)curr).getBasePath();
+                break;
+                       case IPathEntry.CDT_PROJECT:
+                               res = root.findMember(path);
+                               break;
+               }
+               CPElement elem = new CPElement((element == null) ? null : element.getCProject(), curr.getEntryKind(), path, res);
+               elem.setAttribute(SOURCEATTACHMENT, sourceAttachment);
+               elem.setAttribute(EXCLUSION, exclusion);
+               elem.setAttribute(INCLUDE, include);
+        elem.setAttribute(INCLUDE_FILE, includeFile);
+               elem.setAttribute(LIBRARY, library);
+               elem.setAttribute(MACRO_NAME, macroName);
+               elem.setAttribute(MACRO_VALUE, macroValue);
+        elem.setAttribute(MACROS_FILE, macrosFile);
+               elem.setAttribute(SYSTEM_INCLUDE, Boolean.valueOf(sysInclude));
+               elem.setAttribute(BASE_REF, baseRef);
+               elem.setAttribute(BASE, base);
+               elem.setExported(curr.isExported());
+               return elem;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementAttribute.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementAttribute.java
new file mode 100644 (file)
index 0000000..6236ff5
--- /dev/null
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+/**
+ * @deprecated as of CDT 4.0. This class was used for property pages
+ * for 3.X style projects.
+ */
+@Deprecated
+public class CPElementAttribute {
+
+       private CPElement fParent;
+       private String fKey;
+       private Object fValue;
+
+       public CPElementAttribute(CPElement parent, String key, Object value) {
+               fKey = key;
+               fValue = value;
+               fParent = parent;
+       }
+
+       public CPElement getParent() {
+               return fParent;
+       }
+
+       /**
+        * Returns the key.
+        * 
+        * @return String
+        */
+       public String getKey() {
+               return fKey;
+       }
+
+       /**
+        * Returns the value.
+        * 
+        * @return Object
+        */
+       public Object getValue() {
+               return fValue;
+       }
+
+       /**
+        * Returns the value.
+        */
+       public void setValue(Object value) {
+               fValue = value;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementFilter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementFilter.java
new file mode 100644 (file)
index 0000000..ff680a8
--- /dev/null
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+/**
+ * Viewer filter for archive selection dialogs. Archives are files with file extension '.so', '.dll' and '.a'. The filter is not
+ * case sensitive.
+ * 
+ * @deprecated as of CDT 4.0. This class was used for property pages
+ * for 3.X style projects.
+ */
+@Deprecated
+public class CPElementFilter extends ViewerFilter {
+
+       protected List<Object> fExcludes;
+       protected int[] fKind;
+       protected boolean fExportedOnly;
+       protected boolean fShowInherited;
+
+       /**
+        * @param excludedElements
+        *            Excluded paths will not pass the filter. <code>null</code> is allowed if no files should be excluded.
+        */
+       public CPElementFilter(Object[] excludedElements, int[] kind, boolean exportedOnly, boolean showInherited) {
+               if (excludedElements != null) {
+                       fExcludes = Arrays.asList(excludedElements);
+               }
+               fKind = kind;
+               fExportedOnly = exportedOnly;
+               fShowInherited = showInherited;
+       }
+
+       public CPElementFilter(int[] kind, boolean exportedOnly, boolean showInherited) {
+               this(null, kind, exportedOnly, showInherited);
+       }
+
+       /*
+        * @see ViewerFilter#select
+        */
+       @Override
+       public boolean select(Viewer viewer, Object parent, Object element) {
+               if (element instanceof CPElement) {
+                       for (int i = 0; i < fKind.length; i++) {
+                               if ( ((CPElement)element).getEntryKind() == fKind[i]) {
+                                       if (fExcludes == null || !fExcludes.contains(element)) {
+                                               if (fExportedOnly == true) {
+                                                       if ( !fShowInherited ) {
+                                                               return ((CPElement)element).getInherited() == null && ((CPElement)element).isExported();
+                                                       }
+                                                       return ((CPElement)element).isExported();
+                                               }
+                                               if ( !fShowInherited ) {
+                                                       return ((CPElement)element).getInherited() == null;
+                                               }
+                                               return true;
+                                       }
+                               }
+                       }
+               } else if (element instanceof IPathEntry) {
+                       for (int i = 0; i < fKind.length; i++) {
+                               if ( ((IPathEntry)element).getEntryKind() == fKind[i]) {
+                                       if (fExcludes == null || !fExcludes.contains(element)) {
+                                               if (fExportedOnly == true) {
+                                                       return ((IPathEntry)element).isExported();
+                                               }
+                                               return true;
+                                       }
+                               }
+                       }
+               } else if (element instanceof CPElementGroup) {
+                       for (int i = 0; i < fKind.length; i++) {
+                               if ( ((CPElementGroup)element).getEntryKind() == fKind[i]) {
+                                       return true;
+                               }
+                       }
+               } else {
+                       return true;
+               }
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementGroup.java
new file mode 100644 (file)
index 0000000..d95475d
--- /dev/null
@@ -0,0 +1,205 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * @deprecated as of CDT 4.0. This class was used for property pages
+ * for 3.X style projects.
+ */
+@Deprecated
+public class CPElementGroup {
+
+       private CPElement parent;
+       private final int kind;
+       private IResource resource;
+       private Map<Integer, List<CPElement>> childrenListMap;
+       private List<CPElement> childrenList;
+
+       public CPElementGroup(IResource resource) {
+               this.kind = -1;
+               this.resource = resource;
+               this.childrenListMap = new LinkedHashMap<Integer, List<CPElement>>(2);
+       }
+
+       public CPElementGroup(CPElement parent, int kind) {
+               this.parent = parent;
+               this.kind = kind;
+               this.childrenList = new ArrayList<CPElement>();
+       }
+
+       public IResource getResource() {
+               return resource;
+       }
+
+       public IPath getPath() {
+               return resource != null ? resource.getFullPath() : parent.getPath();
+       }
+
+       public CPElement getParent() {
+               return parent;
+       }
+
+       public int getEntryKind() {
+               return kind;
+       }
+
+       @Override
+       public boolean equals(Object arg0) {
+               if (arg0 == this) {
+                       return true;
+               }
+               if (arg0 instanceof CPElementGroup) {
+                       CPElementGroup other = (CPElementGroup)arg0;
+                       return (kind == other.kind && ( (parent == null && other.parent == null) || parent.equals(other.parent)) && ( (resource == null && other.resource == null) || resource.equals(other.resource)));
+               }
+               return false;
+       }
+
+       @Override
+       public int hashCode() {
+               int hashCode = parent != null ? parent.hashCode() : 0;
+               hashCode += resource != null ? resource.hashCode() : 0;
+               return hashCode + kind;
+       }
+
+       public int indexof(CPElement element) {
+               List<CPElement> children = getChildrenList(element.getEntryKind(), false);
+               return children != null ? children.indexOf(element) : -1;
+       }
+       
+       public void addChild(CPElement element, int insertIndex) {
+               List<CPElement> children = getChildrenList(element.getEntryKind(), true);
+               children.add(insertIndex, element);
+               element.setParent(this);
+       }
+       
+       public void addChild(CPElement element) {
+               List<CPElement> children = getChildrenList(element.getEntryKind(), true);
+               int indx = children.indexOf(element);
+               if (indx == -1) {
+                       indx = children.size();
+                       if (element.getInherited() == null) {
+                               for (int i = 0; i < children.size(); i++) {
+                                       CPElement next = children.get(i);
+                                       if (next.getInherited() != null) {
+                                               indx = i;
+                                               break;
+                                       }
+                               }
+                       }
+                       children.add(indx, element);
+                       element.setParent(this);
+               } else { // add element with closes matching resource path.
+                       CPElement other = children.get(indx);
+                       if (other.getInherited() != null && element.getInherited() != null) {
+                               IPath otherPath = other.getInherited().getPath();
+                               IPath elemPath = element.getInherited().getPath();
+                               if (!otherPath.equals(elemPath) && otherPath.isPrefixOf(elemPath)) {
+                                       children.remove(indx);
+                                       other.setParent(null);
+                                       children.add(element);
+                                       element.setParent(this);
+                               }
+                       }
+               }
+       }
+
+       public void setChildren(CPElement[] elements) {
+               if (elements.length > 0) {
+                       if (childrenListMap != null) {
+                               childrenListMap.put(new Integer(elements[0].getEntryKind()), new ArrayList<CPElement>(Arrays.asList(elements)));
+                       } else {
+                               childrenList = new ArrayList<CPElement>(Arrays.asList(elements));
+                       }
+               }
+       }
+
+       public void addChildren(CPElement[] elements) {
+               for (CPElement element : elements) {
+                       addChild(element);
+               }
+       }
+
+       public boolean removeChild(CPElement element) {
+               List<CPElement> children = getChildrenList(element.getEntryKind(), false);
+               if (children == null) {
+                       return false;
+               }
+               boolean removed = children.remove(element);
+               if (removed) {
+                       element.setParent(null);
+               }
+               return removed;
+       }
+
+       public CPElement[] getChildren(int kind) {
+               List<CPElement> children = getChildrenList(kind, true);
+               return children.toArray(new CPElement[children.size()]);
+       }
+
+       public CPElement[] getChildren() {
+               if (childrenList != null) {
+                       return childrenList.toArray(new CPElement[childrenList.size()]);
+               }
+               Collection<List<CPElement>> lists = childrenListMap.values();
+               Iterator<List<CPElement>> iter = lists.iterator();
+               List<CPElement> children = new ArrayList<CPElement>();
+               while (iter.hasNext()) {
+                       children.addAll(iter.next());
+               }
+               return children.toArray(new CPElement[children.size()]);
+       }
+
+       public boolean contains(CPElement element) {
+               List<CPElement> children = getChildrenList(element.getEntryKind(), false);
+               if (children == null) {
+                       return false;
+               }
+               return children.contains(element);
+       }
+
+       public void replaceChild(CPElement element, CPElement replaceWith) {
+               List<CPElement> children = getChildrenList(element.getEntryKind(), false);
+               if (children == null) {
+                       return;
+               }
+               int idx = children.indexOf(element);
+               if (idx != -1) {
+                       children.remove(idx);
+                       children.add(idx, replaceWith);
+               }
+       }
+
+       private List<CPElement> getChildrenList(int kind, boolean create) {
+               List<CPElement> children = null;
+               if (childrenList != null) {
+                       children = childrenList;
+               } else {
+                       children = childrenListMap.get(new Integer(kind));
+                       if (children == null && create) {
+                               children = new ArrayList<CPElement>();
+                               childrenListMap.put(new Integer(kind), children);
+                       }
+               }
+               return children;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementLabelProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementLabelProvider.java
new file mode 100644 (file)
index 0000000..3649aac
--- /dev/null
@@ -0,0 +1,443 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IColorProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.core.model.IPathEntryContainer;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;
+
+/**
+ * @deprecated as of CDT 4.0. This class was used for property pages
+ * for 3.X style projects.
+ */
+@Deprecated
+class CPElementLabelProvider extends LabelProvider implements IColorProvider {
+
+       private Color inDirect = new Color(Display.getDefault(), new RGB(170, 170, 170));
+
+       private String fNewLabel, fCreateLabel;
+       private ImageDescriptor fIncludeIcon, fMacroIcon, fLibWSrcIcon, fLibIcon;
+    private ImageDescriptor fQuoteIncludeIcon, fIncludeFileIcon, fMacrosFileIcon;
+       private ImageDescriptor fFolderImage, fOutputImage, fProjectImage, fContainerImage;
+       private boolean bShowExported;
+       private boolean bShowParentInfo;
+       private ImageDescriptorRegistry fRegistry;
+
+       public CPElementLabelProvider() {
+               this(true, false);
+       }
+
+       public CPElementLabelProvider(boolean showExported, boolean showParentInfo) {
+               fNewLabel = CPathEntryMessages.CPElementLabelProvider_new; 
+               fCreateLabel = CPathEntryMessages.CPElementLabelProvider_willbecreated; 
+               fRegistry = CUIPlugin.getImageDescriptorRegistry();
+
+               fLibIcon = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ARCHIVE);
+               fLibWSrcIcon = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ARCHIVE);
+               fIncludeIcon = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER);
+        fQuoteIncludeIcon = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_QUOTE_INCLUDES_FOLDER);
+        fIncludeFileIcon = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT_HEADER);
+               fMacroIcon = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_MACRO);
+        fMacrosFileIcon = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT_HEADER);
+               fFolderImage = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_SOURCE_ROOT);
+               fOutputImage = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CONTAINER);
+               fContainerImage = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_LIBRARY);
+
+               IWorkbench workbench = CUIPlugin.getDefault().getWorkbench();
+
+               fProjectImage = workbench.getSharedImages().getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT);
+               bShowExported = showExported;
+               bShowParentInfo = showParentInfo;
+       }
+
+       /*
+        * @see org.eclipse.jface.viewers.BaseLabelProvider#dispose()
+        */
+       @Override
+       public void dispose() {
+               inDirect.dispose();
+               inDirect= null;
+               super.dispose();
+       }
+       
+       @Override
+       public String getText(Object element) {
+               if (element instanceof CPElement) {
+                       return getCPElementText((CPElement)element);
+               } else if (element instanceof CPElementAttribute) {
+                       return getCPElementAttributeText((CPElementAttribute)element);
+               } else if (element instanceof IPathEntry) {
+                       return getCPElementText(CPElement.createFromExisting((IPathEntry)element, null));
+               } else if (element instanceof CPElementGroup) {
+                       return (getCPContainerGroupText((CPElementGroup)element));
+               }
+               return super.getText(element);
+       }
+
+       private String getCPContainerGroupText(CPElementGroup group) {
+               switch (group.getEntryKind()) {
+                       case IPathEntry.CDT_INCLUDE :
+                               return CPathEntryMessages.CPElementLabelProvider_Includes; 
+            case IPathEntry.CDT_INCLUDE_FILE :
+                return CPathEntryMessages.CPElementLabelProvider_IncludeFiles; 
+                       case IPathEntry.CDT_MACRO :
+                               return CPathEntryMessages.CPElementLabelProvider_PreprocessorSymbols; 
+            case IPathEntry.CDT_MACRO_FILE :
+                return CPathEntryMessages.CPElementLabelProvider_MacrosFiles; 
+                       case IPathEntry.CDT_LIBRARY :
+                               return CPathEntryMessages.CPElementLabelProvider_Libraries; 
+                       case -1 :
+                               if (group.getResource().getType() == IResource.PROJECT) {
+                                       return group.getResource().getName();
+                               }
+                               StringBuffer label = new StringBuffer(group.getResource().getProjectRelativePath().toString());
+                               if (!group.getResource().exists()) {
+                                       label.append(fCreateLabel);
+                               }
+                               return label.toString();
+               }
+               return ""; //$NON-NLS-1$
+       }
+
+       public String getCPElementAttributeText(CPElementAttribute attrib) {
+               String notAvailable = CPathEntryMessages.CPElementLabelProvider_none; 
+               StringBuffer buf = new StringBuffer();
+               String key = attrib.getKey();
+               if (key.equals(CPElement.SOURCEATTACHMENT)) {
+                       buf.append(CPathEntryMessages.CPElementLabelProvider_source_attachment_label); 
+                       IPath path = (IPath)attrib.getValue();
+                       if (path != null && !path.isEmpty()) {
+                               buf.append(getPathString(path, path.getDevice() != null));
+                       } else {
+                               buf.append(notAvailable);
+                       }
+               } else if (key.equals(CPElement.SOURCEATTACHMENTROOT)) {
+                       buf.append(CPathEntryMessages.CPElementLabelProvider_source_attachment_root_label); 
+                       IPath path = (IPath)attrib.getValue();
+                       if (path != null && !path.isEmpty()) {
+                               buf.append(path.toString());
+                       } else {
+                               buf.append(notAvailable);
+                       }
+               }
+               if (key.equals(CPElement.EXCLUSION)) {
+                       buf.append(CPathEntryMessages.CPElementLabelProvider_exclusion_filter_label); 
+                       IPath[] patterns = (IPath[])attrib.getValue();
+                       if (patterns != null && patterns.length > 0) {
+                               for (int i = 0; i < patterns.length; i++) {
+                                       if (i > 0) {
+                                               buf.append(CPathEntryMessages.CPElementLabelProvider_exclusion_filter_separator); 
+                                       }
+                                       buf.append(patterns[i].toString());
+                               }
+                       } else {
+                               buf.append(notAvailable);
+                       }
+               }
+               return buf.toString();
+       }
+
+       public String getCPElementText(CPElement cpentry) {
+               IPath path = cpentry.getPath();
+               switch (cpentry.getEntryKind()) {
+                       case IPathEntry.CDT_LIBRARY : {
+                               IPath libPath = (IPath)cpentry.getAttribute(CPElement.LIBRARY);
+                               StringBuffer str = new StringBuffer();
+                               addBaseString(libPath, cpentry, str);
+                               addExport(cpentry, str);
+                               addParentInfo(cpentry, str);
+                               return str.toString();
+                       }
+                       case IPathEntry.CDT_PROJECT :
+                               return path.lastSegment();
+                       case IPathEntry.CDT_INCLUDE : {
+                               IPath incPath = ((IPath)cpentry.getAttribute(CPElement.INCLUDE));
+                               StringBuffer str = new StringBuffer();
+                               addBaseString(incPath, cpentry, str);
+                               addExport(cpentry, str);
+                               addParentInfo(cpentry, str);
+                               return str.toString();
+                       }
+            case IPathEntry.CDT_INCLUDE_FILE : {
+                IPath incFilePath = ((IPath)cpentry.getAttribute(CPElement.INCLUDE_FILE));
+                StringBuffer str = new StringBuffer();
+                addBaseString(incFilePath, cpentry, str);
+                addExport(cpentry, str);
+                addParentInfo(cpentry, str);
+                return str.toString();
+            }
+                       case IPathEntry.CDT_MACRO : {
+                               StringBuffer str = new StringBuffer((String)cpentry.getAttribute(CPElement.MACRO_NAME) + "=" //$NON-NLS-1$
+                                               + (String)cpentry.getAttribute(CPElement.MACRO_VALUE));
+                               addBaseString(null, cpentry, str);
+                               addExport(cpentry, str);
+                               addParentInfo(cpentry, str);
+                               return str.toString();
+                       }
+            case IPathEntry.CDT_MACRO_FILE : {
+                IPath macroFilePath = ((IPath)cpentry.getAttribute(CPElement.MACROS_FILE));
+                StringBuffer str = new StringBuffer();
+                addBaseString(macroFilePath, cpentry, str);
+                addExport(cpentry, str);
+                addParentInfo(cpentry, str);
+                return str.toString();
+            }
+                       case IPathEntry.CDT_CONTAINER : {
+                               StringBuffer str = new StringBuffer(path.toString());
+                               try {
+                                       IPathEntryContainer container = CoreModel.getPathEntryContainer(cpentry.getPath(), cpentry.getCProject());
+                                       if (container != null) {
+                                               str.setLength(0);
+                                               str.append(container.getDescription());
+                                       }
+                               } catch (CModelException e) {
+                               }
+                               addExport(cpentry, str);
+                               return str.toString();
+                       }
+                       case IPathEntry.CDT_SOURCE :
+                       case IPathEntry.CDT_OUTPUT : {
+                               StringBuffer buf = new StringBuffer(path.makeRelative().toString());
+                               IResource resource = cpentry.getResource();
+                               if (resource != null && !resource.exists()) {
+                                       buf.append(' ');
+                                       if (cpentry.getStatus().getSeverity() != IStatus.OK) { // only valid error for src/output would missing path...
+                                               buf.append(fCreateLabel);
+                                       } else {
+                                               buf.append(fNewLabel);
+                                       }
+                               }
+                               return buf.toString();
+                       }
+                       default :
+               // pass
+               }
+               return CPathEntryMessages.CPElementLabelProvider_unknown_element_label; 
+       }
+       /**
+        * @param cpentry
+        * @param str
+        */
+       private void addParentInfo(CPElement cpentry, StringBuffer str) {
+               if (bShowParentInfo) {
+                       CPElement parent = cpentry.getParentContainer();
+                       if (parent != null) {
+                               str.append(" ["); //$NON-NLS-1$
+                               try {
+                                       IPathEntryContainer container = CoreModel.getPathEntryContainer(cpentry.getPath(), cpentry.getCProject());
+                                       if (container != null) {
+                                               str.append(container.getDescription());
+                                       }
+                               } catch (CModelException e) {
+                                       str.append(parent.getPath());
+                               }
+                               str.append(']');
+                       }
+               }
+       }
+
+       private void addExport(CPElement cpentry, StringBuffer str) {
+               if (bShowExported && cpentry.isExported()) {
+                       str.append(' ');
+                       str.append(CPathEntryMessages.CPElementLabelProvider_export_label); 
+               }
+       }
+
+       private void addBaseString(IPath endPath, CPElement cpentry, StringBuffer str) {
+               IPath baseRef = (IPath)cpentry.getAttribute(CPElement.BASE_REF);
+               if (!baseRef.isEmpty()) {
+                       if (baseRef.isAbsolute()) {
+                               //                              str.append("From project ");
+                               IPath path = baseRef;
+                               if (endPath != null) {
+                                       path = path.append(endPath);
+                               }
+                               str.append(path.makeRelative().toOSString());
+                       } else {
+                               //                              str.append("From contribution ");
+                               IPathEntryContainer container;
+                               if (endPath != null) {
+                                       str.append(endPath.toOSString());
+                               }
+                               str.append(" - ("); //$NON-NLS-1$
+                               try {
+                                       container = CoreModel.getPathEntryContainer(baseRef, cpentry.getCProject());
+                                       if (container != null) {
+                                               str.append(container.getDescription());
+                                       }
+                               } catch (CModelException e1) {
+                               }
+                               str.append(')');
+                       }
+               } else {
+                       IPath path = (IPath)cpentry.getAttribute(CPElement.BASE);
+                       if (!path.isEmpty()) {
+                               if (endPath != null) {
+                                       path = path.append(endPath);
+                               }
+                               str.insert(0, path.toOSString());
+                       } else if (endPath != null) {
+                               str.insert(0, endPath.toOSString());
+                       }
+               }
+
+       }
+
+       private String getPathString(IPath path, boolean isExternal) {
+               //              if (ArchiveFileFilter.isArchivePath(path)) {
+               //                      IPath appendedPath = path.removeLastSegments(1);
+               //                      String appended = isExternal ? appendedPath.toOSString() :
+               // appendedPath.makeRelative().toString();
+               //                      return
+               // CPathEntryMessages.getFormattedString("CPListLabelProvider.twopart",
+               // //$NON-NLS-1$
+               //                                      new String[] { path.lastSegment(), appended});
+               //              } else {
+               return isExternal ? path.toOSString() : path.makeRelative().toString();
+               //              }
+       }
+
+       private ImageDescriptor getCPElementBaseImage(CPElement cpentry) {
+               switch (cpentry.getEntryKind()) {
+                       case IPathEntry.CDT_OUTPUT :
+                               if (cpentry.getPath().segmentCount() == 1) {
+                                       return fProjectImage;
+                               }
+                               return fOutputImage;
+                       case IPathEntry.CDT_SOURCE :
+                               if (cpentry.getPath().segmentCount() == 1) {
+                                       return fProjectImage;
+                               }
+                               return fFolderImage;
+                       case IPathEntry.CDT_LIBRARY :
+                               IPath path = (IPath)cpentry.getAttribute(CPElement.SOURCEATTACHMENT);
+                               if (path == null || path.isEmpty()) {
+                                       return fLibIcon;
+                               }
+                               return fLibWSrcIcon;
+                       case IPathEntry.CDT_PROJECT :
+                               return fProjectImage;
+                       case IPathEntry.CDT_CONTAINER :
+                               return fContainerImage;
+                       case IPathEntry.CDT_INCLUDE :
+                if (((Boolean)cpentry.getAttribute(CPElement.SYSTEM_INCLUDE)).booleanValue())
+                                   return fIncludeIcon;
+                return fQuoteIncludeIcon;
+            case IPathEntry.CDT_INCLUDE_FILE :
+                return fIncludeFileIcon;
+                       case IPathEntry.CDT_MACRO :
+                               return fMacroIcon;
+            case IPathEntry.CDT_MACRO_FILE :
+                return fMacrosFileIcon;
+                       default :
+                               return null;
+               }
+       }
+
+       private static final Point SMALL_SIZE = new Point(16, 16);
+
+       @Override
+       public Image getImage(Object element) {
+               if (element instanceof CPElement) {
+                       CPElement cpentry = (CPElement)element;
+                       ImageDescriptor imageDescriptor = getCPElementBaseImage(cpentry);
+                       if (imageDescriptor != null) {
+                               switch (cpentry.getStatus().getSeverity()) {
+                                       case IStatus.WARNING :
+                                               imageDescriptor = new CPListImageDescriptor(imageDescriptor, CPListImageDescriptor.WARNING, SMALL_SIZE);
+                                               break;
+                                       case IStatus.ERROR :
+                                               imageDescriptor = new CPListImageDescriptor(imageDescriptor, CPListImageDescriptor.ERROR, SMALL_SIZE);
+                                               break;
+                               }
+                               if (cpentry.getInherited() != null) {
+                                       imageDescriptor = new CPListImageDescriptor(imageDescriptor, CPListImageDescriptor.PATH_INHERIT, SMALL_SIZE);
+                               }
+                               return fRegistry.get(imageDescriptor);
+                       }
+               } else if (element instanceof CPElementAttribute) {
+                       String key = ((CPElementAttribute)element).getKey();
+                       if (key.equals(CPElement.SOURCEATTACHMENT)) {
+                               return fRegistry.get(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_SOURCE_ATTACH_ATTRIB));
+                       } else if (key.equals(CPElement.EXCLUSION)) {
+                               return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_EXCLUSION_FILTER_ATTRIB);
+                       }
+               } else if (element instanceof IPathEntry) {
+                       return getImage(CPElement.createFromExisting((IPathEntry)element, null));
+               } else if (element instanceof CPElementGroup) {
+                       switch ( ((CPElementGroup)element).getEntryKind()) {
+                               case IPathEntry.CDT_INCLUDE :
+                                       return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_CONTAINER);
+                               case IPathEntry.CDT_MACRO :
+                                       return fRegistry.get(fMacroIcon);
+                case IPathEntry.CDT_INCLUDE_FILE :
+                case IPathEntry.CDT_MACRO_FILE :
+                    return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDE);
+                               case IPathEntry.CDT_LIBRARY :
+                                       return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_LIBRARY);
+                               case -1 :
+                                       IResource res = ((CPElementGroup)element).getResource();
+                                       IWorkbenchAdapter adapter = (IWorkbenchAdapter)res.getAdapter(IWorkbenchAdapter.class);
+                                       ImageDescriptor imageDescriptor = adapter.getImageDescriptor(res);
+                                       if (!res.exists()) {
+                                               imageDescriptor = new CPListImageDescriptor(imageDescriptor, CPListImageDescriptor.WARNING, SMALL_SIZE);
+                                       }
+                                       return fRegistry.get(imageDescriptor);
+                       }
+               }
+               return null;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
+        */
+       public Color getForeground(Object element) {
+               if (element instanceof CPElement) {
+                       if ( ((CPElement)element).getInherited() != null) {
+                               return inDirect;
+                       }
+               }
+               return null;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
+        */
+       public Color getBackground(Object element) {
+               // TODO Auto-generated method stub
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementSorter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementSorter.java
new file mode 100644 (file)
index 0000000..c717442
--- /dev/null
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+
+import org.eclipse.cdt.core.model.IPathEntry;
+
+/**
+ * @deprecated as of CDT 4.0. This class was used for property pages
+ * for 3.X style projects.
+ */
+@Deprecated
+public class CPElementSorter extends ViewerSorter {
+
+       private static final int SOURCE = 0;
+       private static final int PROJECT = 1;
+       private static final int LIBRARY = 2;
+       private static final int CONTAINER = 3;
+       private static final int OTHER = 5;
+
+       /*
+        * @see ViewerSorter#category(Object)
+        */
+       @Override
+       public int category(Object obj) {
+               if (obj instanceof CPElement) {
+                       switch ( ((CPElement)obj).getEntryKind()) {
+                               case IPathEntry.CDT_LIBRARY :
+                                       return LIBRARY;
+                               case IPathEntry.CDT_PROJECT :
+                                       return PROJECT;
+                               case IPathEntry.CDT_SOURCE :
+                                       return SOURCE;
+                               case IPathEntry.CDT_CONTAINER :
+                                       return CONTAINER;
+                       }
+               } else if (obj instanceof CPElementGroup) {
+                       switch ( ((CPElementGroup)obj).getEntryKind()) {
+                               case IPathEntry.CDT_LIBRARY :
+                                       return LIBRARY;
+                               case IPathEntry.CDT_PROJECT :
+                                       return PROJECT;
+                               case IPathEntry.CDT_SOURCE :
+                                       return SOURCE;
+                               case IPathEntry.CDT_CONTAINER :
+                                       return CONTAINER;
+                               case -1 :
+                                       if ( ((CPElementGroup)obj).getResource() instanceof IProject) {
+                                               return PROJECT;
+                                       }
+                       }
+               }
+               return OTHER;
+       }
+
+       @Override
+       public void sort(Viewer viewer, Object[] elements) {
+               // include paths and symbol definitions must not be sorted
+               List<Object> sort = new ArrayList<Object>(elements.length);
+               List<CPElement> includes = new ArrayList<CPElement>(elements.length);
+               List<CPElement> syms = new ArrayList<CPElement>(elements.length);
+               for (Object element : elements) {
+                       if (element instanceof CPElement) {
+                               CPElement cpelement = (CPElement)element;
+                               if (cpelement.getEntryKind() == IPathEntry.CDT_INCLUDE) {
+                                       includes.add(cpelement);
+                               } else if (cpelement.getEntryKind() == IPathEntry.CDT_MACRO) {
+                                       syms.add(cpelement);
+                               } else {
+                                       sort.add(cpelement);
+                               }
+                       } else {
+                               sort.add(element);
+                       }
+               }
+               System.arraycopy(sort.toArray(), 0, elements, 0, sort.size());
+               super.sort(viewer, elements);
+               System.arraycopy(includes.toArray(), 0, elements, sort.size(), includes.size());
+               System.arraycopy(syms.toArray(), 0, elements, sort.size() + includes.size(), syms.size());
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPListImageDescriptor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPListImageDescriptor.java
new file mode 100644 (file)
index 0000000..8f20e10
--- /dev/null
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.jface.resource.CompositeImageDescriptor;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.Point;
+
+/**
+ * @deprecated as of CDT 4.0. This class was used for property pages
+ * for 3.X style projects.
+ */
+@Deprecated
+public class CPListImageDescriptor extends CompositeImageDescriptor {
+
+       /** Flag to render the waring adornment */
+       public final static int WARNING=                        0x1;
+
+       /** Flag to render the inherited adornment */
+       public final static int ERROR=                          0x2;
+
+       /** Flag to render the inherited adornment */
+       public final static int PATH_INHERIT=           0x4;
+
+       private ImageDescriptor fBaseImage;
+       private int flags;
+       private Point fSize;
+
+       public CPListImageDescriptor(ImageDescriptor baseImage, int flags, Point size) {
+               fBaseImage = baseImage;
+               this.flags = flags;
+               fSize = size;
+       }
+
+       /**
+        * @see CompositeImageDescriptor#getSize()
+        */
+       @Override
+       protected Point getSize() {
+               if (fSize == null) {
+                       ImageData data = fBaseImage.getImageData();
+                       setSize(new Point(data.width, data.height));
+               }
+               return fSize;
+       }
+
+       /**
+        * @see Object#equals(java.lang.Object)
+        */
+       @Override
+       public boolean equals(Object object) {
+               if (!(object instanceof CPListImageDescriptor)) {
+                       return false;
+               }
+
+               CPListImageDescriptor other = (CPListImageDescriptor) object;
+               return fBaseImage.equals(other.fBaseImage) && flags == other.flags && fSize.equals(other.fSize);
+       }
+
+       /**
+        * @see Object#hashCode()
+        */
+       @Override
+       public int hashCode() {
+               return fBaseImage.hashCode() & flags | fSize.hashCode();
+       }
+
+       /**
+        * @see CompositeImageDescriptor#drawCompositeImage(int, int)
+        */
+       @Override
+       protected void drawCompositeImage(int width, int height) {
+               ImageData bg = fBaseImage.getImageData();
+               if (bg == null) {
+                       bg = DEFAULT_IMAGE_DATA;
+               }
+               drawImage(bg, 0, 0);
+               drawOverlays();
+       }
+
+       /**
+        * Add any overlays to the image as specified in the flags.
+        */
+       protected void drawOverlays() {
+               Point size= getSize();
+               ImageData data = null;
+               int x= getSize().x;
+               if ((flags & PATH_INHERIT) == PATH_INHERIT) {
+                       data = CPluginImages.DESC_OVR_PATH_INHERIT.getImageData();
+                       drawImage(data, x, 0);
+               }
+               x= 0;
+               if ((flags & ERROR) != 0) {
+                       data= CPluginImages.DESC_OVR_ERROR.getImageData();
+                       drawImage(data, x, size.y - data.height);
+                       x+= data.width;
+               }
+               if ((flags & WARNING) != 0) {
+                       data= CPluginImages.DESC_OVR_WARNING.getImageData();
+                       drawImage(data, x, size.y - data.height);
+                       x+= data.width;
+               }
+       }
+
+       protected void setSize(Point size) {
+               fSize = size;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathBasePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathBasePage.java
new file mode 100644 (file)
index 0000000..66396b6
--- /dev/null
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+import org.eclipse.cdt.core.model.CoreModelUtil;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
+
+/**
+ * Abstract Option Page for C/C++ Project Paths page for 3.X projects.
+ * 
+ * @deprecated as of CDT 4.0. This page was used to set preferences/properties
+ * for 3.X style projects.
+ */
+@Deprecated
+public abstract class CPathBasePage extends AbstractCOptionPage {
+
+       public CPathBasePage(String title) {
+               super(title);
+       }
+
+       public CPathBasePage(String title, ImageDescriptor image) {
+               super(title, image);
+       }
+
+       protected void fixNestingConflicts(List<CPElement> newEntries, List<CPElement> existingList, Set<CPElement> modifiedSourceEntries) {
+               ArrayList<CPElement> existing = new ArrayList<CPElement>(existingList);
+               for (int i = 0; i < newEntries.size(); i++) {
+                       CPElement curr = newEntries.get(i);
+                       addExclusionPatterns(curr, existing, modifiedSourceEntries);
+                       // add the entry to the existing list so it can be analyse also.
+                       existing.add(curr);
+               }
+       }
+
+       private void addExclusionPatterns(CPElement newEntry, List<CPElement> existing, Set<CPElement> modifiedEntries) {
+               IPath entryPath = newEntry.getPath();
+               for (int i = 0; i < existing.size(); i++) {
+                       CPElement curr = existing.get(i);
+                       if (curr.getEntryKind() == IPathEntry.CDT_SOURCE) {
+                               IPath currPath = curr.getPath();
+                               if (currPath.isPrefixOf(entryPath) && !currPath.equals(entryPath)) {
+                                       IPath[] exclusionFilters = (IPath[]) curr.getAttribute(CPElement.EXCLUSION);
+                                       if (!CoreModelUtil.isExcludedPath(entryPath.removeFirstSegments(1), exclusionFilters)) {
+                                               IPath pathToExclude = entryPath.removeFirstSegments(currPath.segmentCount()).addTrailingSeparator();
+                                               IPath[] newExclusionFilters = new IPath[exclusionFilters.length + 1];
+                                               System.arraycopy(exclusionFilters, 0, newExclusionFilters, 0, exclusionFilters.length);
+                                               newExclusionFilters[exclusionFilters.length] = pathToExclude;
+                                               curr.setAttribute(CPElement.EXCLUSION, newExclusionFilters);
+                                               modifiedEntries.add(curr);
+                                       }
+                               }
+                       }
+               }
+       }
+
+       public abstract List<?> getSelection();
+
+       public abstract void setSelection(List<?> selection);
+
+       public abstract boolean isEntryKind(int kind);
+
+       protected List<CPElement> filterList(List<CPElement> cpelements) {
+               ArrayList<CPElement> filtered = new ArrayList<CPElement>();
+
+               for (int i = 0; i < cpelements.size(); i++) {
+                       CPElement cpe = cpelements.get(i);
+                       if (isEntryKind(cpe.getEntryKind())) {
+                               filtered.add(cpe);
+                       }
+               }
+               return filtered;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerDefaultPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerDefaultPage.java
new file mode 100644 (file)
index 0000000..6b106db
--- /dev/null
@@ -0,0 +1,138 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.util.ArrayList;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IContainerEntry;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.wizards.NewElementWizardPage;
+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.cdt.ui.wizards.IPathEntryContainerPage;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @deprecated as of CDT 4.0. This class was used for property pages/wizards
+ * for 3.X style projects.
+ */
+@Deprecated
+public class CPathContainerDefaultPage extends NewElementWizardPage implements IPathEntryContainerPage {
+       private StringDialogField fEntryField;
+       private ArrayList<IPath> fUsedPaths;
+
+       /**
+        * Constructor for ClasspathContainerDefaultPage.
+        */
+       public CPathContainerDefaultPage() {
+               super("CPathContainerDefaultPage"); //$NON-NLS-1$
+               setTitle(CPathEntryMessages.CPathContainerDefaultPage_title); 
+               setDescription(CPathEntryMessages.CPathContainerDefaultPage_description); 
+               setImageDescriptor(CPluginImages.DESC_WIZBAN_ADD_LIBRARY);
+               
+               fUsedPaths= new ArrayList<IPath>();
+               
+               fEntryField= new StringDialogField();
+               fEntryField.setLabelText(CPathEntryMessages.CPathContainerDefaultPage_path_label); 
+               fEntryField.setDialogFieldListener(new IDialogFieldListener() {
+                       public void dialogFieldChanged(DialogField field) {
+                               validatePath();
+                       }
+               });
+               validatePath();
+       }
+
+       protected void validatePath() {
+               StatusInfo status= new StatusInfo();
+               String str= fEntryField.getText();
+               if (str.length() == 0) {
+                       status.setError(CPathEntryMessages.CPathContainerDefaultPage_path_error_enterpath); 
+               } else if (!Path.ROOT.isValidPath(str)) {
+                       status.setError(CPathEntryMessages.CPathContainerDefaultPage_path_error_invalidpath); 
+               } else {
+                       IPath path= new Path(str);
+                       if (path.segmentCount() == 0) {
+                               status.setError(CPathEntryMessages.CPathContainerDefaultPage_path_error_needssegment); 
+                       } else if (fUsedPaths.contains(path)) {
+                               status.setError(CPathEntryMessages.CPathContainerDefaultPage_path_error_alreadyexists); 
+                       }
+               }
+               updateStatus(status);
+       }
+
+       /* (non-Javadoc)
+        * @see IDialogPage#createControl(Composite)
+        */
+       public void createControl(Composite parent) {
+               Composite composite= new Composite(parent, SWT.NONE);
+               GridLayout layout= new GridLayout();
+               layout.numColumns= 1;
+               composite.setLayout(layout);
+               
+               fEntryField.doFillIntoGrid(composite, 2);
+               LayoutUtil.setHorizontalGrabbing(fEntryField.getTextControl(null), true);
+               
+               fEntryField.setFocus();
+               
+               setControl(composite);
+               Dialog.applyDialogFont(composite);
+//             WorkbenchHelp.setHelp(composite, IJavaHelpContextIds.CLASSPATH_CONTAINER_DEFAULT_PAGE);
+       }
+
+       /* (non-Javadoc)
+        * @see IClasspathContainerPage#finish()
+        */
+       public boolean finish() {
+               return true;
+       }
+       
+       /* (non-Javadoc)
+        * @see IClasspathContainerPage#getSelection()
+        */
+       public IContainerEntry[] getNewContainers() {
+               return new IContainerEntry[] {CoreModel.newContainerEntry(new Path(fEntryField.getText()))};
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jdt.ui.wizards.IClasspathContainerPageExtension#initialize(org.eclipse.jdt.core.IJavaProject, org.eclipse.jdt.core.IClasspathEntry)
+        */
+       public void initialize(ICProject project, IPathEntry[] currentEntries) {
+               for (int i= 0; i < currentEntries.length; i++) {
+                       IPathEntry curr= currentEntries[i];
+                       if (curr.getEntryKind() == IPathEntry.CDT_CONTAINER) {
+                               fUsedPaths.add(curr.getPath());
+                       }
+               }
+       }               
+
+       /* (non-Javadoc)
+        * @see IClasspathContainerPage#setSelection(IClasspathEntry)
+        */
+       public void setSelection(IContainerEntry containerEntry) {
+               if (containerEntry != null) {
+                       fUsedPaths.remove(containerEntry.getPath());
+                       fEntryField.setText(containerEntry.getPath().toString());
+               } else {
+                       fEntryField.setText(""); //$NON-NLS-1$
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerDescriptor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerDescriptor.java
new file mode 100644 (file)
index 0000000..4b8e20a
--- /dev/null
@@ -0,0 +1,369 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.swt.SWTException;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.osgi.framework.Bundle;
+
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IContainerEntry;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.wizards.IPathEntryContainerPage;
+
+import org.eclipse.cdt.internal.ui.util.CoreUtility;
+
+/**
+ * @deprecated as of CDT 4.0. This wizard was used in property pages/wizards
+ * for 3.X style projects.
+ */
+@Deprecated
+public class CPathContainerDescriptor implements IContainerDescriptor {
+
+
+       /**
+        * Adapter class to adapter deprecated ICPathContainerPage to new IPathEntryContainerPage
+        * @author Dave
+        * @deprecated
+        */
+       @Deprecated
+       public static class PathEntryContainerPageAdapter implements IPathEntryContainerPage {
+               public static IPathEntryContainerPage createAdapter(Object elem) {
+                       if (elem instanceof org.eclipse.cdt.ui.wizards.ICPathContainerPage) {
+                               return new PathEntryContainerPageAdapter((org.eclipse.cdt.ui.wizards.ICPathContainerPage) elem);
+                       }
+                       return null;
+               }
+
+
+               private final org.eclipse.cdt.ui.wizards.ICPathContainerPage fPage;
+               protected PathEntryContainerPageAdapter(org.eclipse.cdt.ui.wizards.ICPathContainerPage page) {
+                       fPage = page;
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.cdt.ui.wizards.IPathEntryContainerPage#initialize(org.eclipse.cdt.core.model.ICProject, org.eclipse.cdt.core.model.IPathEntry[])
+                */
+               public void initialize(ICProject project, IPathEntry[] currentEntries) {
+                       fPage.initialize(project, currentEntries);
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.cdt.ui.wizards.IPathEntryContainerPage#finish()
+                */
+               public boolean finish() {
+                       return fPage.finish();
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.cdt.ui.wizards.IPathEntryContainerPage#getNewContainers()
+                */
+               public IContainerEntry[] getNewContainers() {
+                       IPathEntry[] entries = fPage.getContainerEntries();
+                       IContainerEntry[] containers = new IContainerEntry[entries.length];
+                       System.arraycopy(entries, 0, containers, 0, entries.length);
+                       return containers;
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.cdt.ui.wizards.IPathEntryContainerPage#setSelection(org.eclipse.cdt.core.model.IContainerEntry)
+                */
+               public void setSelection(IContainerEntry containerEntry) {
+                       fPage.setSelection(containerEntry);
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+                */
+               public void createControl(Composite parent) {
+                       fPage.createControl(parent);
+
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.wizard.IWizardPage#canFlipToNextPage()
+                */
+               public boolean canFlipToNextPage() {
+                       return fPage.canFlipToNextPage();
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.wizard.IWizardPage#getName()
+                */
+               public String getName() {
+                       return fPage.getName();
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.wizard.IWizardPage#getNextPage()
+                */
+               public IWizardPage getNextPage() {
+                       return fPage.getNextPage();
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.wizard.IWizardPage#getPreviousPage()
+                */
+               public IWizardPage getPreviousPage() {
+                       return fPage.getPreviousPage();
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.wizard.IWizardPage#getWizard()
+                */
+               public IWizard getWizard() {
+                       return fPage.getWizard();
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.wizard.IWizardPage#isPageComplete()
+                */
+               public boolean isPageComplete() {
+                       return fPage.isPageComplete();
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.wizard.IWizardPage#setPreviousPage(org.eclipse.jface.wizard.IWizardPage)
+                */
+               public void setPreviousPage(IWizardPage page) {
+                       fPage.setPreviousPage(page);
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.wizard.IWizardPage#setWizard(org.eclipse.jface.wizard.IWizard)
+                */
+               public void setWizard(IWizard newWizard) {
+                       fPage.setWizard(newWizard);
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.dialogs.IDialogPage#dispose()
+                */
+               public void dispose() {
+                       fPage.dispose();
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.dialogs.IDialogPage#getControl()
+                */
+               public Control getControl() {
+                       return fPage.getControl();
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.dialogs.IDialogPage#getDescription()
+                */
+               public String getDescription() {
+                       return fPage.getDescription();
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.dialogs.IDialogPage#getErrorMessage()
+                */
+               public String getErrorMessage() {
+                       return fPage.getErrorMessage();
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.dialogs.IDialogPage#getImage()
+                */
+               public Image getImage() {
+                       return fPage.getImage();
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.dialogs.IDialogPage#getMessage()
+                */
+               public String getMessage() {
+                       return fPage.getMessage();
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.dialogs.IDialogPage#getTitle()
+                */
+               public String getTitle() {
+                       return fPage.getTitle();
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.dialogs.IDialogPage#performHelp()
+                */
+               public void performHelp() {
+                       fPage.performHelp();
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.dialogs.IDialogPage#setDescription(java.lang.String)
+                */
+               public void setDescription(String description) {
+                       fPage.setDescription(description);
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.dialogs.IDialogPage#setImageDescriptor(org.eclipse.jface.resource.ImageDescriptor)
+                */
+               public void setImageDescriptor(ImageDescriptor image) {
+                       fPage.setImageDescriptor(image);
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.dialogs.IDialogPage#setTitle(java.lang.String)
+                */
+               public void setTitle(String title) {
+                       fPage.setTitle(title);
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
+                */
+               public void setVisible(boolean visible) {
+                       fPage.setVisible(visible);
+               }
+
+       }
+       private IConfigurationElement fConfigElement;
+
+       private static final String ATT_EXTENSION = "PathContainerPage"; //$NON-NLS-1$
+
+       private static final String ATT_ID = "id"; //$NON-NLS-1$
+       private static final String ATT_NAME = "name"; //$NON-NLS-1$
+       private static final String ATT_ICON = "icon"; //$NON-NLS-1$
+       private static final String ATT_PAGE_CLASS = "class"; //$NON-NLS-1$     
+
+       private Image pageImage;
+
+       public CPathContainerDescriptor(IConfigurationElement configElement) throws CoreException {
+               super();
+               fConfigElement = configElement;
+
+               String id = fConfigElement.getAttribute(ATT_ID);
+               String name = configElement.getAttribute(ATT_NAME);
+               String pageClassName = configElement.getAttribute(ATT_PAGE_CLASS);
+
+               if (name == null) {
+                       throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, "Invalid extension (missing name): " + id, //$NON-NLS-1$
+                                       null));
+               }
+               if (pageClassName == null) {
+                       throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0,
+                                       "Invalid extension (missing page class name): " + id, null)); //$NON-NLS-1$
+               }
+       }
+
+       public IPathEntryContainerPage createPage() throws CoreException {
+               Object elem = CoreUtility.createExtension(fConfigElement, ATT_PAGE_CLASS);
+               if (elem instanceof IPathEntryContainerPage) {
+                       return (IPathEntryContainerPage) elem;
+               } 
+               IPathEntryContainerPage result= PathEntryContainerPageAdapter.createAdapter(elem);
+               if (result != null) {
+                       return result;
+               }
+               String id = fConfigElement.getAttribute(ATT_ID);
+               throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0,
+                               "Invalid extension (page not of type IClasspathContainerPage): " + id, null)); //$NON-NLS-1$
+       }
+
+       public String getName() {
+               return fConfigElement.getAttribute(ATT_NAME);
+       }
+
+       public Image getImage() {
+               if (pageImage == null) {
+                       String imageName = fConfigElement.getAttribute(ATT_ICON);
+                       if (imageName != null) {
+                               IExtension extension = fConfigElement.getDeclaringExtension();
+                               String plugin = extension.getContributor().getName();
+                               Image image = getImageFromPlugin(plugin, imageName);
+                               pageImage = image;
+                       }
+               }
+               return pageImage;
+       }
+
+       public Image getImageFromPlugin(String plugin, String subdirectoryAndFilename) {
+               Bundle bundle = Platform.getBundle(plugin);
+               URL iconURL = bundle.getEntry("/"); //$NON-NLS-1$
+               return getImageFromURL(iconURL, subdirectoryAndFilename);
+       }
+
+       public Image getImageFromURL(URL installURL, String subdirectoryAndFilename) {
+               Image image = null;
+               try {
+                       URL newURL = new URL(installURL, subdirectoryAndFilename);
+                       ImageDescriptor desc = ImageDescriptor.createFromURL(newURL);
+                       image = desc.createImage();
+               } catch (MalformedURLException e) {
+               } catch (SWTException e) {
+               }
+               return image;
+       }
+
+       public String getPageClass() {
+               return fConfigElement.getAttribute(ATT_PAGE_CLASS);
+       }
+
+       public boolean canEdit(IPathEntry entry) {
+               String id = fConfigElement.getAttribute(ATT_ID);
+               if (entry.getEntryKind() == IPathEntry.CDT_CONTAINER) {
+                       String type = entry.getPath().segment(0);
+                       return id.equals(type);
+               }
+               return false;
+       }
+
+       public static IContainerDescriptor[] getDescriptors() {
+               ArrayList<IContainerDescriptor> containers = new ArrayList<IContainerDescriptor>();
+
+               IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID, ATT_EXTENSION);
+               if (extensionPoint != null) {
+                       IContainerDescriptor defaultPage = null;
+                       String defaultPageName = CPathContainerDefaultPage.class.getName();
+
+                       IConfigurationElement[] elements = extensionPoint.getConfigurationElements();
+                       for (IConfigurationElement element : elements) {
+                               try {
+                                       CPathContainerDescriptor curr = new CPathContainerDescriptor(element);
+                                       if (defaultPageName.equals(curr.getPageClass())) {
+                                               defaultPage = curr;
+                                       } else {
+                                               containers.add(curr);
+                                       }
+                               } catch (CoreException e) {
+                                       CUIPlugin.log(e);
+                               }
+                       }
+                       if (defaultPageName != null && containers.isEmpty()) {
+                               // default page only added if no other extensions found
+                               containers.add(defaultPage);
+                       }
+               }
+               return containers.toArray(new CPathContainerDescriptor[containers.size()]);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerEntryPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerEntryPage.java
new file mode 100644 (file)
index 0000000..2687d72
--- /dev/null
@@ -0,0 +1,479 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.widgets.Composite;
+
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IContainerEntry;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+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.ITreeListAdapter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
+
+/**
+ * Path Containers tab for C/C++ Project Paths page for 3.X projects.
+ * 
+ * @deprecated as of CDT 4.0. This tab was used to set preferences/properties
+ * for 3.X style projects.
+ */
+@Deprecated
+public class CPathContainerEntryPage extends CPathBasePage {
+       private ListDialogField<CPElement> fCPathList;
+       private ICProject fCurrCProject;
+
+       private TreeListDialogField<CPElement> fContainersList;
+
+       private final int IDX_ADD = 0;
+
+       private final int IDX_EDIT = 2;
+       private final int IDX_REMOVE = 3;
+       private final int IDX_EXPORT = 5;
+
+       public CPathContainerEntryPage(ListDialogField<CPElement> cPathList) {
+               super(CPathEntryMessages.ContainerEntryPage_title); 
+               fCPathList = cPathList;
+
+               String[] buttonLabels = new String[]{
+               CPathEntryMessages.ContainerEntryPage_add_button, 
+                               /* */null,
+                               CPathEntryMessages.ContainerEntryPage_edit_button, 
+                               CPathEntryMessages.ContainerEntryPage_remove_button, 
+                               null,
+                               CPathEntryMessages.ContainerEntryPage_export_button
+               };
+
+               ContainersAdapter adapter = new ContainersAdapter();
+
+               fContainersList = new TreeListDialogField<CPElement>(adapter, buttonLabels, new CPElementLabelProvider());
+               fContainersList.setDialogFieldListener(adapter);
+               fContainersList.setLabelText(CPathEntryMessages.ContainerEntryPage_libraries_label); 
+
+               fContainersList.enableButton(IDX_REMOVE, false);
+               fContainersList.enableButton(IDX_EDIT, false);
+               fContainersList.enableButton(IDX_EXPORT, false);
+               fContainersList.setTreeExpansionLevel(2);
+
+               fContainersList.setViewerComparator(new CPElementSorter());
+
+       }
+
+       public void init(ICProject jproject) {
+               fCurrCProject = jproject;
+               updateLibrariesList();
+       }
+
+       private void updateLibrariesList() {
+               List<CPElement> cpelements = fCPathList.getElements();
+               List<CPElement> libelements = new ArrayList<CPElement>(cpelements.size());
+
+               int nElements = cpelements.size();
+               for (int i = 0; i < nElements; i++) {
+                       CPElement cpe = cpelements.get(i);
+                       if (isEntryKind(cpe.getEntryKind())) {
+                               libelements.add(cpe);
+                       }
+               }
+               fContainersList.setElements(libelements);
+       }
+
+       // -------- ui creation
+
+       @Override
+       public void createControl(Composite parent) {
+               PixelConverter converter = new PixelConverter(parent);
+
+               Composite composite = new Composite(parent, SWT.NONE);
+
+               LayoutUtil.doDefaultLayout(composite, new DialogField[]{fContainersList}, true);
+               LayoutUtil.setHorizontalGrabbing(fContainersList.getTreeControl(null), true);
+
+               int buttonBarWidth = converter.convertWidthInCharsToPixels(24);
+               fContainersList.setButtonsMinWidth(buttonBarWidth);
+
+               fContainersList.getTreeViewer().addFilter(new ViewerFilter() {
+
+                       @Override
+                       public boolean select(Viewer viewer, Object parentElement, Object element) {
+                               if (element instanceof CPElementGroup) {
+                                       return ((CPElementGroup)element).getChildren().length != 0;
+                               }
+                               return true;
+                       }
+               });
+
+               setControl(composite);
+               
+               CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.PROJECT_PATHS_CONTAINERS);
+       }
+
+       private class ContainersAdapter implements IDialogFieldListener, ITreeListAdapter<CPElement> {
+
+               private final Object[] EMPTY_ARR = new Object[0];
+
+               // -------- IListAdapter --------
+               public void customButtonPressed(TreeListDialogField<CPElement> field, int index) {
+                       containerPageCustomButtonPressed(field, index);
+               }
+
+               public void selectionChanged(TreeListDialogField<CPElement> field) {
+                       containerPageSelectionChanged(field);
+               }
+
+               public void doubleClicked(TreeListDialogField<CPElement> field) {
+                       containerPageDoubleClicked(field);
+               }
+
+               public void keyPressed(TreeListDialogField<CPElement> field, KeyEvent event) {
+                       containerPageKeyPressed(field, event);
+               }
+
+               public Object[] getChildren(TreeListDialogField<CPElement> field, Object element) {
+                       if (element instanceof CPElement) {
+                               return ((CPElement)element).getChildren();
+                       } else if (element instanceof CPElementGroup) {
+                               return ((CPElementGroup)element).getChildren();
+                       }
+                       return EMPTY_ARR;
+               }
+
+               public Object getParent(TreeListDialogField<CPElement> field, Object element) {
+                       if (element instanceof CPElementAttribute) {
+                               return ((CPElementAttribute)element).getParent();
+                       } else if (element instanceof CPElementGroup) {
+                               return ((CPElementGroup)element).getParent();
+                       }
+                       return null;
+               }
+
+               public boolean hasChildren(TreeListDialogField<CPElement> field, Object element) {
+                       if (element instanceof CPElementGroup) {
+                               return true;
+                       } else if (element instanceof CPElement) {
+                               return ((CPElement)element).getChildren().length != 0;
+                       }
+                       return false;
+
+               }
+
+               // ---------- IDialogFieldListener --------
+
+               public void dialogFieldChanged(DialogField field) {
+                       containerPageDialogFieldChanged(field);
+               }
+       }
+
+       void containerPageCustomButtonPressed(DialogField field, int index) {
+               CPElement[] containers = null;
+               switch (index) {
+                       case IDX_ADD :
+                               /* add container */
+                               containers = openContainerSelectionDialog(null);
+                               break;
+                       case IDX_EDIT :
+                               /* edit */
+                               editEntry();
+                               return;
+                       case IDX_REMOVE :
+                               /* remove */
+                               removeEntry();
+                               return;
+                       case IDX_EXPORT :
+                               /* export */
+                               exportEntry();
+                               return;
+               }
+               if (containers != null) {
+                       int nElementsChosen = containers.length;
+                       // remove duplicates
+                       List<CPElement> cplist = fContainersList.getElements();
+                       List<CPElement> elementsToAdd = new ArrayList<CPElement>(nElementsChosen);
+
+                       for (int i = 0; i < nElementsChosen; i++) {
+                               CPElement curr = containers[i];
+                               if (!cplist.contains(curr) && !elementsToAdd.contains(curr)) {
+                                       elementsToAdd.add(curr);
+                                       //                                      curr.setAttribute(CPElement.SOURCEATTACHMENT, BuildPathSupport.guessSourceAttachment(curr));
+                               }
+                       }
+
+                       fContainersList.addElements(elementsToAdd);
+                       if (index == IDX_ADD) {
+                               fContainersList.refresh();
+                       }
+                       fContainersList.postSetSelection(new StructuredSelection(containers));
+               }
+       }
+
+       protected void containerPageDoubleClicked(TreeListDialogField<?> field) {
+               List<?> selection = fContainersList.getSelectedElements();
+               if (canEdit(selection)) {
+                       editEntry();
+               }
+       }
+
+       protected void containerPageKeyPressed(TreeListDialogField<?> field, KeyEvent event) {
+               if (field == fContainersList) {
+                       if (event.character == SWT.DEL && event.stateMask == 0) {
+                               List<?> selection = field.getSelectedElements();
+                               if (canRemove(selection)) {
+                                       removeEntry();
+                               }
+                       }
+               }
+       }
+
+       private boolean canRemove(List<?> selElements) {
+               if (selElements.size() == 0) {
+                       return false;
+               }
+               for (int i = 0; i < selElements.size(); i++) {
+                       Object elem = selElements.get(i);
+                       if (elem instanceof CPElement) {
+                               CPElement curr = (CPElement)elem;
+                               if (curr.getParentContainer() != null) {
+                                       return false;
+                               }
+                       } else {
+                               return false;
+                       }
+               }
+               return true;
+       }
+
+       private void removeEntry() {
+               List<?> selElements = fContainersList.getSelectedElements();
+               fContainersList.removeElements(selElements);
+       }
+
+       private boolean canExport(List<?> selElements) {
+               if (selElements.size() == 0) {
+                       return false;
+               }
+               for (int i = 0; i < selElements.size(); i++) {
+                       Object elem = selElements.get(i);
+                       if (elem instanceof CPElement) {
+                               CPElement curr = (CPElement)elem;
+                               if (curr.getParentContainer() != null) {
+                                       return false;
+                               }
+                       } else {
+                               return false;
+                       }
+               }
+               return true;
+       }
+
+       private void exportEntry() {
+               List<?> selElements = fContainersList.getSelectedElements();
+               if (selElements.size() == 0) {
+                       return;
+               }
+               for (int i = 0; i < selElements.size(); i++) {
+                       Object elem = selElements.get(i);
+                       if (elem instanceof CPElement) {
+                               ((CPElement)elem).setExported(! ((CPElement)elem).isExported()); // toggle export
+                       }
+               }
+               fContainersList.refresh();
+       }
+
+       /**
+        * Method editEntry.
+        */
+       private void editEntry() {
+               List<?> selElements = fContainersList.getSelectedElements();
+               if (selElements.size() != 1) {
+                       return;
+               }
+               Object elem = selElements.get(0);
+               if (fContainersList.getIndexOfElement(elem) != -1) {
+                       editElementEntry((CPElement)elem);
+               } else if (elem instanceof CPElementAttribute) {
+                       editAttributeEntry((CPElementAttribute)elem);
+               }
+       }
+
+       private void editAttributeEntry(CPElementAttribute elem) {
+//             String key = elem.getKey();
+//             if (key.equals(CPElement.SOURCEATTACHMENT)) {
+//                     CPElement selElement = elem.getParent();
+//
+//                     IPath containerPath = null;
+//                     boolean applyChanges = false;
+//                     Object parentContainer = selElement.getParentContainer();
+//                     if (parentContainer instanceof CPElement) {
+//                             containerPath = ((CPElement)parentContainer).getPath();
+//                             applyChanges = true;
+//                     }
+//                     SourceAttachmentDialog dialog = new SourceAttachmentDialog(getShell(), (ILibraryEntry)selElement.getPathEntry(), containerPath,
+//                                     fCurrCProject, applyChanges);
+//                     if (dialog.open() == Window.OK) {
+//                             selElement.setAttribute(CPElement.SOURCEATTACHMENT, dialog.getSourceAttachmentPath());
+//                             fContainersList.refresh();
+//                             fCPathList.refresh(); // images
+//                     }
+//             }
+       }
+
+       private void editElementEntry(CPElement elem) {
+               CPElement[] res = null;
+
+               res = openContainerSelectionDialog(elem);
+               if (res != null && res.length > 0) {
+                       CPElement curr = res[0];
+                       curr.setExported(elem.isExported());
+                       fContainersList.replaceElement(elem, curr);
+               }
+
+       }
+
+       void containerPageSelectionChanged(DialogField field) {
+               List<?> selElements = fContainersList.getSelectedElements();
+               fContainersList.enableButton(IDX_EDIT, canEdit(selElements));
+               fContainersList.enableButton(IDX_REMOVE, canRemove(selElements));
+               fContainersList.enableButton(IDX_EXPORT, canExport(selElements));
+       }
+
+       private boolean canEdit(List<?> selElements) {
+               if (selElements.size() != 1) {
+                       return false;
+               }
+               Object elem = selElements.get(0);
+               if (elem instanceof CPElement) {
+                       CPElement curr = (CPElement)elem;
+                       return ! (curr.getResource() instanceof IFolder) && curr.getParentContainer() == null;
+               }
+               if (elem instanceof CPElementAttribute) {
+                       return true;
+               }
+               return false;
+       }
+
+       void containerPageDialogFieldChanged(DialogField field) {
+               if (fCurrCProject != null) {
+                       // already initialized
+                       updateCPathList();
+               }
+       }
+
+       private void updateCPathList() {
+               List<CPElement> projelements = fContainersList.getElements();
+
+               List<CPElement> cpelements = fCPathList.getElements();
+               int nEntries = cpelements.size();
+               // backwards, as entries will be deleted
+               int lastRemovePos = nEntries;
+               for (int i = nEntries - 1; i >= 0; i--) {
+                       CPElement cpe = cpelements.get(i);
+                       int kind = cpe.getEntryKind();
+                       if (isEntryKind(kind)) {
+                               if (!projelements.remove(cpe)) {
+                                       cpelements.remove(i);
+                                       lastRemovePos = i;
+                               }
+                       }
+               }
+
+               cpelements.addAll(lastRemovePos, projelements);
+
+               if (lastRemovePos != nEntries || !projelements.isEmpty()) {
+                       fCPathList.setElements(cpelements);
+               }
+       }
+
+       private CPElement[] openContainerSelectionDialog(CPElement existing) {
+               IContainerEntry elem = null;
+               String title;
+               if (existing == null) {
+                       title = CPathEntryMessages.ContainerEntryPage_ContainerDialog_new_title; 
+               } else {
+                       title = CPathEntryMessages.ContainerEntryPage_ContainerDialog_edit_title; 
+                       elem = (IContainerEntry)existing.getPathEntry();
+               }
+               CPathContainerWizard wizard = new CPathContainerWizard(elem, fCurrCProject, getRawClasspath());
+               wizard.setWindowTitle(title);
+               if (CPathContainerWizard.openWizard(getShell(), wizard) == Window.OK) {
+                       IPathEntry[] created = wizard.getContainers();
+                       if (created != null) {
+                               CPElement[] res = new CPElement[created.length];
+                               for (int i = 0; i < res.length; i++) {
+                                       res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_CONTAINER, created[i].getPath(), null);
+                               }
+                               return res;
+                       }
+               }
+               return null;
+       }
+
+       private IPathEntry[] getRawClasspath() {
+               IPathEntry[] currEntries = new IPathEntry[fCPathList.getSize()];
+               for (int i = 0; i < currEntries.length; i++) {
+                       CPElement curr = fCPathList.getElement(i);
+                       currEntries[i] = curr.getPathEntry();
+               }
+               return currEntries;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathBasePage#isEntryKind(int)
+        */
+       @Override
+       public boolean isEntryKind(int kind) {
+               return kind == IPathEntry.CDT_CONTAINER;
+       }
+
+       /*
+        * @see BuildPathBasePage#getSelection
+        */
+       @Override
+       public List<?> getSelection() {
+               return fContainersList.getSelectedElements();
+       }
+
+       /*
+        * @see BuildPathBasePage#setSelection
+        */
+       @Override
+       public void setSelection(List<?> selElements) {
+               fContainersList.selectElements(new StructuredSelection(selElements));
+       }
+
+       @Override
+       public void performApply(IProgressMonitor monitor) throws CoreException {
+       }
+
+       @Override
+       public void performDefaults() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerSelectionPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerSelectionPage.java
new file mode 100644 (file)
index 0000000..e8447b2
--- /dev/null
@@ -0,0 +1,170 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.util.Arrays;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.viewsupport.ListContentProvider;
+
+/**
+ * @deprecated as of CDT 4.0. This page was used for CPathContainerWizard
+ * for 3.X style projects.
+  */
+@Deprecated
+public class CPathContainerSelectionPage extends WizardPage {
+
+       private static final String DIALOGSTORE_SECTION= "CPathContainerSelectionPage"; //$NON-NLS-1$
+       private static final String DIALOGSTORE_CONTAINER_IDX= "index"; //$NON-NLS-1$
+
+
+       private static class CPathContainerLabelProvider extends LabelProvider {
+               @Override
+               public String getText(Object element) {
+                       return ((IContainerDescriptor) element).getName();
+               }
+               
+               @Override
+               public Image getImage(Object element) {
+                       return ((IContainerDescriptor) element).getImage();
+               }
+       }
+
+       private static class CPathContainerSorter extends ViewerSorter {
+               
+               @Override
+               public int category(Object element) {
+                       if ( element instanceof ProjectContainerDescriptor) {
+                               return 0;
+                       }
+                       return 1;
+               }
+       }
+
+       private TableViewer fListViewer;
+       private IContainerDescriptor[] fContainers;
+       private IDialogSettings fDialogSettings;
+
+       /**
+        * Constructor for ClasspathContainerWizardPage.
+        * @param containerPages
+        */
+       protected CPathContainerSelectionPage(IContainerDescriptor[] containerPages) {
+               super("CPathContainerWizardPage"); //$NON-NLS-1$
+               setTitle(CPathEntryMessages.CPathContainerSelectionPage_title); 
+               setDescription(CPathEntryMessages.CPathContainerSelectionPage_description); 
+               setImageDescriptor(CPluginImages.DESC_WIZBAN_ADD_LIBRARY);
+
+               fContainers= containerPages;
+
+               IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings();
+               fDialogSettings= settings.getSection(DIALOGSTORE_SECTION);
+               if (fDialogSettings == null) {
+                       fDialogSettings= settings.addNewSection(DIALOGSTORE_SECTION);
+                       fDialogSettings.put(DIALOGSTORE_CONTAINER_IDX, 0);
+               }
+               validatePage();
+       }
+
+       /* (non-Javadoc)
+        * @see IDialogPage#createControl(Composite)
+        */
+       public void createControl(Composite parent) {
+               fListViewer= new TableViewer(parent, SWT.SINGLE | SWT.BORDER);
+               fListViewer.setLabelProvider(new CPathContainerLabelProvider());
+               fListViewer.setContentProvider(new ListContentProvider());
+               fListViewer.setSorter(new CPathContainerSorter());
+               fListViewer.setInput(Arrays.asList(fContainers));
+               fListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+                       public void selectionChanged(SelectionChangedEvent event) {
+                               validatePage();
+                       }
+               });
+               fListViewer.addDoubleClickListener(new IDoubleClickListener() {
+                       public void doubleClick(DoubleClickEvent event) {
+                               doDoubleClick();
+                       }
+               });             
+               
+               int selectionIndex= fDialogSettings.getInt(DIALOGSTORE_CONTAINER_IDX);
+               if (selectionIndex >= fContainers.length) {
+                       selectionIndex= 0;
+               }
+               fListViewer.getTable().select(selectionIndex);
+               validatePage();
+               setControl(fListViewer.getTable());
+               Dialog.applyDialogFont(fListViewer.getTable());
+       }
+
+       /**
+        * Method validatePage.
+        */
+       void validatePage() {
+               setPageComplete(getSelected() != null);
+       }
+
+
+       public IContainerDescriptor getSelected() {
+               if (fListViewer != null) {
+                       ISelection selection= fListViewer.getSelection();
+                       if (selection instanceof IStructuredSelection) {
+                               IStructuredSelection ss = (IStructuredSelection) selection;
+                               if (ss.size() == 1) 
+                                       return (IContainerDescriptor) ss.getFirstElement();
+                       }
+               }
+               return null;
+       }
+       
+       protected void doDoubleClick() {
+               if (canFlipToNextPage()) {
+                       getContainer().showPage(getNextPage());
+               }
+       }       
+
+       /* (non-Javadoc)
+        * @see IWizardPage#canFlipToNextPage()
+        */
+       @Override
+       public boolean canFlipToNextPage() {
+               return isPageComplete(); // avoid the getNextPage call to prevent potential plugin load
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
+        */
+       @Override
+       public void setVisible(boolean visible) {
+               if (!visible && fListViewer != null) {
+                       fDialogSettings.put(DIALOGSTORE_CONTAINER_IDX, fListViewer.getTable().getSelectionIndex());
+               }
+               super.setVisible(visible);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerWizard.java
new file mode 100644 (file)
index 0000000..3282c7d
--- /dev/null
@@ -0,0 +1,247 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IContainerEntry;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.core.model.IProjectEntry;
+import org.eclipse.cdt.ui.wizards.IPathEntryContainerPage;
+
+import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
+
+/**
+ * @deprecated as of CDT 4.0. This wizard was used in property pages
+ * for 3.X style projects.
+ */
+@Deprecated
+public class CPathContainerWizard extends Wizard {
+
+       private IContainerDescriptor fPageDesc;
+       private IContainerEntry fEntryToEdit;
+
+       private IPathEntry[] fNewEntries;
+       private IContainerEntry[] fContainerEntries;
+       private IProjectEntry fProjectEntry;
+
+       private IPathEntryContainerPage fContainerPage;
+       private ICElement fCurrElement;
+       private IPathEntry[] fCurrCPath;
+       private CPathFilterPage fFilterPage;
+
+       private CPathContainerSelectionPage fSelectionWizardPage;
+       private int[] fFilterType;
+
+       /**
+        * Constructor for ClasspathContainerWizard.
+        */
+       public CPathContainerWizard(IContainerEntry entryToEdit, ICElement currElement, IPathEntry[] currEntries) {
+               this(entryToEdit, null, currElement, currEntries, null);
+       }
+
+       /**
+        * Constructor for ClasspathContainerWizard.
+        */
+       public CPathContainerWizard(IContainerDescriptor pageDesc, ICElement currElement, IPathEntry[] currEntries) {
+               this(null, pageDesc, currElement, currEntries, null);
+       }
+
+       public CPathContainerWizard(IContainerEntry entryToEdit, IContainerDescriptor pageDesc, ICElement currElement,
+                       IPathEntry[] currEntries, int[] filterType) {
+               fEntryToEdit = entryToEdit;
+               fPageDesc = pageDesc;
+               fNewEntries = null;
+
+               fFilterType = filterType;
+               fCurrElement = currElement;
+               fCurrCPath = currEntries;
+       }
+
+       public IPathEntry getEntriesParent() {
+               if (fProjectEntry != null) {
+                       return fProjectEntry;
+               }
+               return fContainerEntries[0];
+       }
+
+       public IPathEntry[] getEntries() {
+               return fNewEntries;
+       }
+
+       public IContainerEntry[] getContainers() {
+               return fContainerEntries;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see IWizard#performFinish()
+        */
+       @Override
+       public boolean performFinish() {
+               if (fContainerPage != null) {
+                       if (fContainerPage.finish()) {
+                               if (fContainerPage instanceof ProjectContainerPage) {
+                                       fProjectEntry = ((ProjectContainerPage)fContainerPage).getProjectEntry();
+                               } else {
+                                       fContainerEntries = fContainerPage.getNewContainers();
+                               }
+                               if (fFilterPage != null && fFilterPage.isPageComplete()) {
+                                       fNewEntries = fFilterPage.getSelectedEntries();
+                               }
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see IWizard#addPages()
+        */
+       @Override
+       public void addPages() {
+               if (fPageDesc != null) {
+                       fContainerPage = getContainerPage(fPageDesc);
+                       addPage(fContainerPage);
+               } else if (fEntryToEdit == null) { // new entry: show selection page as
+                       // first page
+                       IContainerDescriptor[] containers = CPathContainerDescriptor.getDescriptors();
+                       List<IContainerDescriptor> allContainers = new ArrayList<IContainerDescriptor>(Arrays.asList(containers));
+                       if (fFilterType != null) {
+                               allContainers.add(0, new ProjectContainerDescriptor(fFilterType));
+                       }
+                       fSelectionWizardPage = new CPathContainerSelectionPage(
+                                       allContainers.toArray(new IContainerDescriptor[0]));
+                       addPage(fSelectionWizardPage);
+
+                       // add as dummy, will not be shown
+                       fContainerPage = new CPathContainerDefaultPage();
+                       addPage(fContainerPage);
+                       if (fFilterType != null) {
+                               fFilterPage = new CPathFilterPage(fCurrElement, fFilterType);
+                               addPage(fFilterPage);
+                       }
+               } else { // fPageDesc == null && fEntryToEdit != null
+                       IContainerDescriptor[] containers = CPathContainerDescriptor.getDescriptors();
+                       IContainerDescriptor descriptor = findDescriptorPage(containers, fEntryToEdit);
+                       fContainerPage = getContainerPage(descriptor);
+                       addPage(fContainerPage);
+               }
+               super.addPages();
+       }
+
+       private IPathEntryContainerPage getContainerPage(IContainerDescriptor pageDesc) {
+               IPathEntryContainerPage containerPage = null;
+               if (pageDesc != null) {
+                       try {
+                               containerPage = pageDesc.createPage();
+                       } catch (CoreException e) {
+                               handlePageCreationFailed(e);
+                       }
+               }
+               if (containerPage == null) {
+                       containerPage = new CPathContainerDefaultPage();
+               }
+               containerPage.initialize(fCurrElement.getCProject(), fCurrCPath);
+               if (!(containerPage instanceof ProjectContainerPage)) {
+                       containerPage.setSelection(fEntryToEdit);
+               }
+               containerPage.setWizard(this);
+               return containerPage;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see IWizard#getNextPage(IWizardPage)
+        */
+       @Override
+       public IWizardPage getNextPage(IWizardPage page) {
+               if (page == fSelectionWizardPage) {
+
+                       IContainerDescriptor selected = fSelectionWizardPage.getSelected();
+                       fContainerPage = getContainerPage(selected);
+                       return fContainerPage;
+               } else if (page == fContainerPage && fFilterPage != null) {
+                       if (fContainerPage.finish() && fContainerPage.getNewContainers().length > 0
+                                       && fContainerPage.getNewContainers()[0] != null) {
+                               IPathEntry entry;
+                               if (fContainerPage instanceof ProjectContainerPage) {
+                                       entry = ((ProjectContainerPage)fContainerPage).getProjectEntry();
+                               } else {
+                                       entry = fContainerPage.getNewContainers()[0];
+                               }
+                               fFilterPage.setParentEntry(entry);
+                       }
+                       return fFilterPage;
+               }
+               return super.getNextPage(page);
+       }
+
+       private void handlePageCreationFailed(CoreException e) {
+               String title = CPathEntryMessages.CPathContainerWizard_pagecreationerror_title; 
+               String message = CPathEntryMessages.CPathContainerWizard_pagecreationerror_message; 
+               ExceptionHandler.handle(e, getShell(), title, message);
+       }
+
+       private IContainerDescriptor findDescriptorPage(IContainerDescriptor[] containers, IPathEntry entry) {
+               for (IContainerDescriptor container2 : containers) {
+                       if (container2.canEdit(entry)) {
+                               return container2;
+                       }
+               }
+               return null;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see IWizard#canFinish()
+        */
+       @Override
+       public boolean canFinish() {
+               if (fSelectionWizardPage != null) {
+                       if (!fContainerPage.isPageComplete()) {
+                               return false;
+                       }
+               }
+               boolean canFinish = false;
+               if (fContainerPage != null) {
+                       canFinish = fContainerPage.isPageComplete();
+               }
+               if (canFinish == true && fFilterPage != null) {
+                       canFinish = fFilterPage.isPageComplete();
+               }
+               return canFinish;
+       }
+
+       public static int openWizard(Shell shell, CPathContainerWizard wizard) {
+               WizardDialog dialog = new WizardDialog(shell, wizard);
+               PixelConverter converter = new PixelConverter(shell);
+               dialog.setMinimumPageSize(converter.convertWidthInCharsToPixels(70), converter.convertHeightInCharsToPixels(20));
+               dialog.create();
+               return dialog.open();
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathEntryMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathEntryMessages.java
new file mode 100644 (file)
index 0000000..77bf3e9
--- /dev/null
@@ -0,0 +1,212 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class CPathEntryMessages extends NLS {
+
+       private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.dialogs.cpaths.CPathEntryMessages";//$NON-NLS-1$
+
+       private CPathEntryMessages() {
+               // Do not instantiate
+       }
+
+       public static String CPathsPropertyPage_no_C_project_message;
+       public static String CPathsPropertyPage_closed_project_message;
+       public static String CPathsPropertyPage_error_title;
+       public static String CPathsPropertyPage_error_message;
+       public static String CPathsPropertyPage_unsavedchanges_title;
+       public static String CPathsPropertyPage_unsavedchanges_message;
+       public static String CPathsPropertyPage_unsavedchanges_button_save;
+       public static String CPathsPropertyPage_unsavedchanges_button_discard;
+       public static String CPathFilterPage_title;
+       public static String CPathFilterPage_description;
+       public static String CPathFilterPage_label;
+       public static String CPathContainerSelectionPage_title;
+       public static String CPathContainerSelectionPage_description;
+       public static String CPathContainerWizard_pagecreationerror_title;
+       public static String CPathContainerWizard_pagecreationerror_message;
+       public static String CPathContainerDefaultPage_title;
+       public static String CPathContainerDefaultPage_description;
+       public static String CPathContainerDefaultPage_path_label;
+       public static String CPathContainerDefaultPage_path_error_enterpath;
+       public static String CPathContainerDefaultPage_path_error_invalidpath;
+       public static String CPathContainerDefaultPage_path_error_needssegment;
+       public static String CPathContainerDefaultPage_path_error_alreadyexists;
+       public static String ProjectContainer_label;
+       public static String ProjectContainerPage_title;
+       public static String ProjectContainerPage_description;
+       public static String ProjectContainerPage_label;
+       public static String IncludeSymbolEntryPage_title;
+       public static String IncludeSymbolEntryPage_label;
+       public static String IncludeSymbolEntryPage_addFolderFile;
+       public static String IncludeSymbolEntryPage_addUserSymbol;
+       public static String IncludeSymbolEntryPage_addExternalInclude;
+       public static String IncludeSymbolEntryPage_addFromWorkspace;
+       public static String IncludeSymbolEntryPage_addContributed;
+       public static String IncludeSymbolEntryPage_edit;
+       public static String IncludeSymbolEntryPage_remove;
+       public static String IncludeSymbolEntryPage_export;
+       public static String IncludeSymbolEntryPage_up;
+       public static String IncludeSymbolEntryPage_down;
+       public static String IncludeSymbolsEntryPage_show_inherited_check;
+       public static String IncludeSymbolEntryPage_addSymbol_title;
+       public static String IncludeSymbolEntryPage_addSymbol_message;
+       public static String IncludeSymbolEntryPage_editSymbol_title;
+       public static String IncludeSymbolEntryPage_editSymbol_message;
+       public static String IncludeSymbolEntryPage_addExternal_button_browse;
+       public static String IncludeSymbolEntryPage_addExternal_title;
+       public static String IncludeSymbolEntryPage_addExternal_message;
+       public static String IncludeSymbolEntryPage_editExternal_title;
+       public static String IncludeSymbolEntryPage_editExternal_message;
+       public static String IncludeSymbolEntryPage_ContainerDialog_new_title;
+       public static String IncludeSymbolEntryPage_ContainerDialog_edit_title;
+       public static String IncludeSymbolEntryPage_fromWorkspaceDialog_new_title;
+       public static String IncludeSymbolEntryPage_fromWorkspaceDialog_new_description;
+       public static String IncludeSymbolEntryPage_fromWorkspaceDialog_edit_title;
+       public static String IncludeSymbolEntryPage_fromWorkspaceDialog_edit_description;
+       public static String IncludeSymbolEntryPage_newResource_title;
+       public static String IncludeSymbolEntryPage_newResource_description;
+       public static String IncludeSymbolEntryPage_browseForFolder;
+       public static String ContainerEntryPage_title;
+       public static String ContainerEntryPage_add_button;
+       public static String ContainerEntryPage_edit_button;
+       public static String ContainerEntryPage_remove_button;
+       public static String ContainerEntryPage_export_button;
+       public static String ContainerEntryPage_libraries_label;
+       public static String ContainerEntryPage_ContainerDialog_new_title;
+       public static String ContainerEntryPage_ContainerDialog_edit_title;
+       public static String CPathsBlock_path_up_button;
+       public static String CPathsBlock_path_down_button;
+       public static String CPathsBlock_path_checkall_button;
+       public static String CPathsBlock_path_uncheckall_button;
+       public static String CPathsBlock_operationdesc_c;
+       public static String CPElement_status_multiplePathErrors;
+       public static String CPElement_status_pathContainerMissing;
+       public static String CPElement_status_libraryPathNotFound;
+       public static String CPElement_status_sourcePathMissing;
+       public static String CPElement_status_outputPathMissing;
+       public static String CPElement_status_notOnSourcePath;
+       public static String CPElement_status_includePathNotFound;
+       public static String CPElement_status_includeFilePathNotFound;
+       public static String CPElement_status_macrosFilePathNotFound;
+       public static String CPElement_status_missingProjectPath;
+       public static String SourcePathEntryPage_title;
+       public static String SourcePathEntryPage_description;
+       public static String SourcePathEntryPage_folders_label;
+       public static String SourcePathEntryPage_folders_remove_button;
+       public static String SourcePathEntryPage_folders_add_button;
+       public static String SourcePathEntryPath_folders_edit_button;
+       public static String SourcePathEntryPage_ExistingSourceFolderDialog_new_title;
+       public static String SourcePathEntryPage_ExistingSourceFolderDialog_new_description;
+       public static String SourcePathEntryPage_ExistingSourceFolderDialog_edit_title;
+       public static String SourcePathEntryPage_ExistingSourceFolderDialog_edit_description;
+       public static String SourcePathEntryPage_NewSourceFolderDialog_new_title;
+       public static String SourcePathEntryPage_NewSourceFolderDialog_edit_title;
+       public static String SourcePathEntryPage_NewSourceFolderDialog_description;
+       public static String SourcePathEntryPage_exclusion_added_title;
+       public static String SourcePathEntryPage_exclusion_added_message;
+       public static String OutputPathEntryPage_title;
+       public static String OutputPathEntryPage_description;
+       public static String OutputPathEntryPage_folders_label;
+       public static String OutputPathEntryPage_folders_remove_button;
+       public static String OutputPathEntryPage_folders_add_button;
+       public static String OutputPathEntryPage_folders_edit_button;
+       public static String OutputPathEntryPage_ExistingOutputFolderDialog_new_title;
+       public static String OutputPathEntryPage_ExistingOutputFolderDialog_new_description;
+       public static String OutputPathEntryPage_ExistingOutputFolderDialog_edit_title;
+       public static String OutputPathEntryPage_ExistingOutputFolderDialog_edit_description;
+       public static String OutputPathEntryPage_exclusion_added_title;
+       public static String OutputPathEntryPage_exclusion_added_message;
+       public static String ProjectsEntryPage_title;
+       public static String ProjectsEntryPage_description;
+       public static String ProjectsEntryPage_projects_label;
+       public static String ProjectsEntryPage_projects_checkall_button;
+       public static String ProjectsEntryWorkbookPage_projects_uncheckall_button;
+       public static String LibrariesEntryPage_title;
+       public static String LibrariesEntryPage_description;
+       public static String LibrariesEntryPage_libraries_label;
+       public static String LibrariesEntryPage_libraries_remove_button;
+       public static String LibrariesEntryPage_libraries_addextlib_button;
+       public static String LibrariesEntryPage_libraries_addcontriblib_button;
+       public static String LibrariesEntryPage_libraries_addworkspacelib_button;
+       public static String LibrariesEntryPage_libraries_edit_button;
+       public static String LibrariesEntryPage_libraries_export_button;
+       public static String LibrariesEntryPage_ContainerDialog_new_title;
+       public static String LibrariesEntryPage_ContainerDialog_edit_title;
+       public static String LibrariesEntryPage_ExtLibDialog_new_title;
+       public static String LibrariesEntryPage_ExtLibDialog_new_description;
+       public static String LibrariesEntryPage_ExtLibDialog_edit_title;
+       public static String LibrariesEntryPage_ExtLibDialog_edit_description;
+       public static String OrderExportsPage_title;
+       public static String OrderExportsPage_description;
+       public static String ExclusionPatternDialog_title;
+       public static String ExclusionPatternDialog_pattern_label;
+       public static String ExclusionPatternDialog_pattern_add;
+       public static String ExclusionPatternDialog_pattern_add_multiple;
+       public static String ExclusionPatternDialog_pattern_remove;
+       public static String ExclusionPatternDialog_pattern_edit;
+       public static String ExclusionPatternDialog_ChooseExclusionPattern_title;
+       public static String ExclusionPatternDialog_ChooseExclusionPattern_description;
+       public static String ExclusionPatternEntryDialog_add_title;
+       public static String ExclusionPatternEntryDialog_edit_title;
+       public static String ExclusionPatternEntryDialog_description;
+       public static String ExclusionPatternEntryDialog_pattern_label;
+       public static String ExclusionPatternEntryDialog_pattern_button;
+       public static String ExclusionPatternEntryDialog_error_empty;
+       public static String ExclusionPatternEntryDialog_error_notrelative;
+       public static String ExclusionPatternEntryDialog_error_exists;
+       public static String ExclusionPatternEntryDialog_ChooseExclusionPattern_title;
+       public static String ExclusionPatternEntryDialog_ChooseExclusionPattern_description;
+       public static String CPElementLabelProvider_new;
+       public static String CPElementLabelProvider_willbecreated;
+       public static String CPElementLabelProvider_none;
+       public static String CPElementLabelProvider_source_attachment_label;
+       public static String CPElementLabelProvider_source_attachment_root_label;
+       public static String CPElementLabelProvider_exclusion_filter_label;
+       public static String CPElementLabelProvider_exclusion_filter_separator;
+       public static String CPElementLabelProvider_unknown_element_label;
+       public static String CPElementLabelProvider_Includes;
+       public static String CPElementLabelProvider_IncludeFiles;
+       public static String CPElementLabelProvider_PreprocessorSymbols;
+       public static String CPElementLabelProvider_MacrosFiles;
+       public static String CPElementLabelProvider_Libraries;
+       public static String CPElementLabelProvider_export_label;
+       public static String NewSourceFolderDialog_useproject_button;
+       public static String NewSourceFolderDialog_usefolder_button;
+       public static String NewSourceFolderDialog_sourcefolder_label;
+       public static String NewSourceFolderDialog_error_invalidpath;
+       public static String NewSourceFolderDialog_error_enterpath;
+       public static String NewSourceFolderDialog_error_pathexists;
+       public static String FolderSelectionDialog_button;
+       public static String MultipleFolderSelectionDialog_button;
+       public static String SourceAttachmentBlock_message;
+       public static String SourceAttachmentBlock_filename_label;
+       public static String SourceAttachmentBlock_filename_externalfile_button;
+       public static String SourceAttachmentBlock_filename_externalfolder_button;
+       public static String SourceAttachmentBlock_filename_internal_button;
+       public static String SourceAttachmentBlock_filename_error_notvalid;
+       public static String SourceAttachmentBlock_filename_error_filenotexists;
+       public static String SourceAttachmentBlock_intjardialog_title;
+       public static String SourceAttachmentBlock_intjardialog_message;
+       public static String SourceAttachmentBlock_extjardialog_text;
+       public static String SourceAttachmentBlock_extfolderdialog_text;
+       public static String SourceAttachmentBlock_putoncpdialog_title;
+       public static String SourceAttachmentBlock_putoncpdialog_message;
+       public static String SourceAttachmentDialog_title;
+       public static String SourceAttachmentDialog_error_title;
+       public static String SourceAttachmentDialog_error_message;
+
+       static {
+               NLS.initializeMessages(BUNDLE_NAME, CPathEntryMessages.class);
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathEntryMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathEntryMessages.properties
new file mode 100644 (file)
index 0000000..8f7aa3e
--- /dev/null
@@ -0,0 +1,258 @@
+###############################################################################
+# Copyright (c) 2004, 2008 QNX Software Systems and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     QNX Software Systems - initial API and implementation
+#     Anton Leherbauer (Wind River Systems)
+###############################################################################
+
+CPathsPropertyPage_no_C_project_message=Not a C/C++ project.
+CPathsPropertyPage_closed_project_message=Path information is not available for a closed project.
+CPathsPropertyPage_error_title=Error Setting Project Paths
+CPathsPropertyPage_error_message=An error occurred while setting the project path
+CPathsPropertyPage_unsavedchanges_title=Setting C/C++ Project Path
+CPathsPropertyPage_unsavedchanges_message=The C/C++ Project path property page contains unsaved modifications. Do you want to save changes so that other path related property pages can be updated?
+CPathsPropertyPage_unsavedchanges_button_save=Apply
+CPathsPropertyPage_unsavedchanges_button_discard=Discard
+
+# ------- CPathFilterPage-------
+
+CPathFilterPage_title=Container Paths
+CPathFilterPage_description=Select path which are to be contributed to the project.
+CPathFilterPage_label=C/C++ Container path:
+
+# ------- CPathContainerSelectionPage-------
+
+CPathContainerSelectionPage_title=Add Contributed
+CPathContainerSelectionPage_description=Select the library type to add.
+
+# ------- CPathContainerWizard-------
+
+CPathContainerWizard_pagecreationerror_title= Library Wizard
+CPathContainerWizard_pagecreationerror_message=Wizard page creation failed. Check log for details.
+
+# ------- CPathContainerDefaultPage-------
+
+CPathContainerDefaultPage_title=C/C++ Path Container
+CPathContainerDefaultPage_description=Edit the C/C++ container path. First segment is the container type.
+CPathContainerDefaultPage_path_label=&C/C++ path container path:
+CPathContainerDefaultPage_path_error_enterpath=Enter path.
+CPathContainerDefaultPage_path_error_invalidpath=Invalid path.
+CPathContainerDefaultPage_path_error_needssegment=Path needs at least one segment.
+CPathContainerDefaultPage_path_error_alreadyexists=Entry already exists.
+
+# -------- ProjectContainerPage ---------
+ProjectContainer_label=C/C++ Project Path Entries
+ProjectContainerPage_title=C/C++ Project Path Entries
+ProjectContainerPage_description=Select the C/C++ Project which contains path entries to be contributed to this project.
+ProjectContainerPage_label=C/C++ Projects:
+
+# -------- CPathIncludeSymbolEntryPage --------
+IncludeSymbolEntryPage_title=Include/Symbols
+IncludeSymbolEntryPage_label=Include Paths and Preprocessor Symbols:
+IncludeSymbolEntryPage_addFolderFile=Add Folder/File...
+IncludeSymbolEntryPage_addUserSymbol=Add Preprocessor Symbol...
+IncludeSymbolEntryPage_addExternalInclude=Add External Include Path...
+IncludeSymbolEntryPage_addFromWorkspace=Add Include Path from Workspace...
+IncludeSymbolEntryPage_addContributed=Add Contributed...
+IncludeSymbolEntryPage_edit=Edit...
+IncludeSymbolEntryPage_remove=Remove
+IncludeSymbolEntryPage_export=Export
+IncludeSymbolEntryPage_up=Up
+IncludeSymbolEntryPage_down=Down
+IncludeSymbolsEntryPage_show_inherited_check=Show Inherited Paths
+IncludeSymbolEntryPage_addSymbol_title=Add Preprocessor Symbol
+IncludeSymbolEntryPage_addSymbol_message=Symbol definition:
+IncludeSymbolEntryPage_editSymbol_title=Edit Preprocessor Symbol
+IncludeSymbolEntryPage_editSymbol_message=Symbol definition:
+IncludeSymbolEntryPage_addExternal_button_browse=Browse...
+IncludeSymbolEntryPage_addExternal_title=Add External Include Path
+IncludeSymbolEntryPage_addExternal_message=Include path:
+IncludeSymbolEntryPage_editExternal_title=Edit External Include Path
+IncludeSymbolEntryPage_editExternal_message=Include path:
+IncludeSymbolEntryPage_ContainerDialog_new_title=Contributed Include Path Selection
+IncludeSymbolEntryPage_ContainerDialog_edit_title=Contributed Include Path Selection
+IncludeSymbolEntryPage_fromWorkspaceDialog_new_title=New Include Path from Workspace
+IncludeSymbolEntryPage_fromWorkspaceDialog_new_description=Select a folder as a include path from the workspace.
+IncludeSymbolEntryPage_fromWorkspaceDialog_edit_title=Edit Include Path from Workspace
+IncludeSymbolEntryPage_fromWorkspaceDialog_edit_description=Select a folder as a include path from the workspace.
+IncludeSymbolEntryPage_newResource_title=Add File/Folder
+IncludeSymbolEntryPage_newResource_description=Select a file or folder to add to the include/symbol list to add/remove paths or symbols on.
+IncludeSymbolEntryPage_browseForFolder=Browse For Folder
+
+# ------- CPathContainerEntryPage ------
+ContainerEntryPage_title=Path Containers
+ContainerEntryPage_add_button=Add...
+ContainerEntryPage_edit_button=Edit...
+ContainerEntryPage_remove_button=Remove
+ContainerEntryPage_export_button=Export
+ContainerEntryPage_libraries_label=Containers:
+ContainerEntryPage_ContainerDialog_new_title=Add New C/C++ Path Container
+ContainerEntryPage_ContainerDialog_edit_title=Edit C/C++ Path Container
+
+# ------- BuildPathsBlock -------
+CPathsBlock_path_up_button=&Up
+CPathsBlock_path_down_button=&Down
+CPathsBlock_path_checkall_button=Select &All
+CPathsBlock_path_uncheckall_button=D&eselect All
+CPathsBlock_operationdesc_c=Setting project paths...
+
+CPElement_status_multiplePathErrors={0} project path entries have errors.
+CPElement_status_pathContainerMissing=Missing project path container.
+CPElement_status_libraryPathNotFound=Library not found.
+CPElement_status_sourcePathMissing=Source path does not exist.
+CPElement_status_outputPathMissing=Output path does not exist.
+CPElement_status_notOnSourcePath=Project path must exist on source path.
+CPElement_status_includePathNotFound=Include path not found.
+CPElement_status_includeFilePathNotFound=Include file path not found.
+CPElement_status_macrosFilePathNotFound=Macros file path not found.
+CPElement_status_missingProjectPath=Missing project path.
+
+# ------- SourcePathEntryPage-------
+SourcePathEntryPage_title=&Source
+SourcePathEntryPage_description=Source Path for project
+SourcePathEntryPage_folders_label=Source folders on build pat&h:
+SourcePathEntryPage_folders_remove_button=&Remove
+SourcePathEntryPage_folders_add_button=&Add Folder...
+SourcePathEntryPath_folders_edit_button=&Edit...
+
+SourcePathEntryPage_ExistingSourceFolderDialog_new_title=Source Folder Selection
+SourcePathEntryPage_ExistingSourceFolderDialog_new_description=&Choose source folders to be added to the build path:
+
+SourcePathEntryPage_ExistingSourceFolderDialog_edit_title=Source Folder Selection
+SourcePathEntryPage_ExistingSourceFolderDialog_edit_description=&Select the source folder:
+
+SourcePathEntryPage_NewSourceFolderDialog_new_title=New Source Folder
+SourcePathEntryPage_NewSourceFolderDialog_edit_title=Edit Source Folder
+
+SourcePathEntryPage_NewSourceFolderDialog_description=&Enter a path relative to ''{0}'':
+
+SourcePathEntryPage_exclusion_added_title=Source Folder Added
+SourcePathEntryPage_exclusion_added_message=Exclusion filters have been added to nesting folders.
+
+# ------- OutputPathEntryPage-------
+OutputPathEntryPage_title=&Output
+OutputPathEntryPage_description=Build Output locations
+OutputPathEntryPage_folders_label=Output folders on build pat&h:
+OutputPathEntryPage_folders_remove_button=&Remove
+OutputPathEntryPage_folders_add_button=&Add Folder...
+OutputPathEntryPage_folders_edit_button=&Edit...
+
+OutputPathEntryPage_ExistingOutputFolderDialog_new_title=Output Folder Selection
+OutputPathEntryPage_ExistingOutputFolderDialog_new_description=&Choose Output folders to be added to the build path:
+
+OutputPathEntryPage_ExistingOutputFolderDialog_edit_title=Output Folder Selection
+OutputPathEntryPage_ExistingOutputFolderDialog_edit_description=&Select the Output folder:
+
+OutputPathEntryPage_exclusion_added_title=Output Folder Added
+OutputPathEntryPage_exclusion_added_message=Exclusion filters have been added to nesting folders.
+
+# ------- ProjectsWorkbookPage-------
+ProjectsEntryPage_title=&Projects
+ProjectsEntryPage_description=
+ProjectsEntryPage_projects_label=&Required projects on the build path:
+ProjectsEntryPage_projects_checkall_button=Select &All
+ProjectsEntryWorkbookPage_projects_uncheckall_button=&Deselect All
+
+# ------- LibrariesWorkbookPage-------
+LibrariesEntryPage_title=&Libraries
+LibrariesEntryPage_description=
+LibrariesEntryPage_libraries_label=Libraries on the build path:
+LibrariesEntryPage_libraries_remove_button=&Remove
+
+LibrariesEntryPage_libraries_addextlib_button=Add E&xternal Library...
+LibrariesEntryPage_libraries_addcontriblib_button=Add &Contributed...
+LibrariesEntryPage_libraries_addworkspacelib_button=Add from Workspace...
+LibrariesEntryPage_libraries_edit_button=&Edit...
+LibrariesEntryPage_libraries_export_button=Export
+
+LibrariesEntryPage_ContainerDialog_new_title=Contributed Library Path Selection
+LibrariesEntryPage_ContainerDialog_edit_title=Contributed Library Path Selection
+
+LibrariesEntryPage_ExtLibDialog_new_title=Library Selection
+LibrariesEntryPage_ExtLibDialog_new_description=&Choose Library to be added to the project paths:
+
+LibrariesEntryPage_ExtLibDialog_edit_title=Edit Library
+LibrariesEntryPage_ExtLibDialog_edit_description=&Select the library:
+
+# -------- OrderExportPage ---------
+OrderExportsPage_title=&Order and Export
+OrderExportsPage_description=
+
+# ------- ExclusionPatternDialog -------
+ExclusionPatternDialog_title=Source Folder Exclusion Patterns
+ExclusionPatternDialog_pattern_label=E&xclusion patterns for ''{0}'':
+ExclusionPatternDialog_pattern_add=A&dd...
+ExclusionPatternDialog_pattern_add_multiple=Add &Multiple...
+ExclusionPatternDialog_pattern_remove=&Remove
+ExclusionPatternDialog_pattern_edit=&Edit...
+ExclusionPatternDialog_ChooseExclusionPattern_title=Exclusion Pattern Selection
+ExclusionPatternDialog_ChooseExclusionPattern_description=&Choose folders or files to exclude:
+
+# ------- ExclusionPatternEntryDialog -------
+ExclusionPatternEntryDialog_add_title=Add Exclusion Pattern
+ExclusionPatternEntryDialog_edit_title=Edit Exclusion Pattern
+ExclusionPatternEntryDialog_description=Enter a pattern for excluding files from the source folder. Allowed wildcards are '*', '?' and '**'. Examples: 'util/A*.c', 'lib/util/', '**/Test*'.
+ExclusionPatternEntryDialog_pattern_label=E&xclusion pattern (Path relative to ''{0}''):
+ExclusionPatternEntryDialog_pattern_button=Bro&wse...
+ExclusionPatternEntryDialog_error_empty=Enter a pattern.
+ExclusionPatternEntryDialog_error_notrelative=Pattern must be a relative path.
+ExclusionPatternEntryDialog_error_exists=Pattern already exists.
+ExclusionPatternEntryDialog_ChooseExclusionPattern_title=Exclusion Pattern Selection
+ExclusionPatternEntryDialog_ChooseExclusionPattern_description=&Choose a folder or file to exclude:
+
+# ------- CPListLabelProvider -------
+CPElementLabelProvider_new=(new)
+CPElementLabelProvider_willbecreated=(will be created)
+CPElementLabelProvider_none=(None)
+CPElementLabelProvider_source_attachment_label=Source attachment:
+CPElementLabelProvider_source_attachment_root_label=Source attachment root:
+CPElementLabelProvider_exclusion_filter_label=Exclusion filter:
+CPElementLabelProvider_exclusion_filter_separator=;
+CPElementLabelProvider_unknown_element_label=unknown element
+CPElementLabelProvider_Includes=Include Paths
+CPElementLabelProvider_IncludeFiles=Include Files
+CPElementLabelProvider_PreprocessorSymbols=Preprocessor Symbols
+CPElementLabelProvider_MacrosFiles=Symbol Definitions Files
+CPElementLabelProvider_Libraries=Libraries
+CPElementLabelProvider_export_label= (Exported)
+
+# ------- NewSourceFolderDialog-------
+NewSourceFolderDialog_useproject_button=&Project as source folder
+NewSourceFolderDialog_usefolder_button=&Folder as source folder
+NewSourceFolderDialog_sourcefolder_label=&Source folder name:
+NewSourceFolderDialog_error_invalidpath=Invalid folder path: ''{0}''
+NewSourceFolderDialog_error_enterpath=Folder name must be entered.
+NewSourceFolderDialog_error_pathexists=The folder is already in the list.
+
+FolderSelectionDialog_button=Create &New Folder...
+MultipleFolderSelectionDialog_button=Create &New Folder...
+
+# ------- SourceAttachmentBlock-------
+
+SourceAttachmentBlock_message=Select the location (folder, JAR or zip) containing the source for ''{0}'':
+
+SourceAttachmentBlock_filename_label=Lo&cation path:
+SourceAttachmentBlock_filename_externalfile_button=External &File...
+SourceAttachmentBlock_filename_externalfolder_button=External F&older...
+SourceAttachmentBlock_filename_internal_button=&Workspace...
+
+SourceAttachmentBlock_filename_error_notvalid= The archive path is not a valid path.
+SourceAttachmentBlock_filename_error_filenotexists= The path ''{0}'' does not exist.
+
+SourceAttachmentBlock_intjardialog_title=Source Location Selection
+SourceAttachmentBlock_intjardialog_message=&Select folder or JAR/zip archive containing the source:
+
+SourceAttachmentBlock_extjardialog_text=JAR/ZIP File Selection
+SourceAttachmentBlock_extfolderdialog_text=Folder Selection
+
+SourceAttachmentBlock_putoncpdialog_title=Setting Source Attachment
+SourceAttachmentBlock_putoncpdialog_message=Source can only be attached to libraries on the build path.\nDo you want to add the library to the build path?
+
+SourceAttachmentDialog_title=Source Attachment Configuration
+SourceAttachmentDialog_error_title=Error Attaching Source
+SourceAttachmentDialog_error_message=An error occurred while associating the source.
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathFilterPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathFilterPage.java
new file mode 100644 (file)
index 0000000..32230a3
--- /dev/null
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.core.model.IPathEntryContainer;
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.viewsupport.ListContentProvider;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+/**
+ * @deprecated as of CDT 4.0. This page was used in Path Container Wizard
+ * for 3.X style projects.
+ */
+@Deprecated
+public class CPathFilterPage extends WizardPage {
+
+       private final int[] fFilterType;
+
+       private CheckboxTableViewer viewer;
+       private IPathEntry fParentEntry;
+       private List<IPathEntry> fPaths;
+       private List<?> fExclusions;
+       private ViewerFilter filter;
+       
+       protected ICElement fCElement;
+
+       protected CPathFilterPage(ICElement cElement, int[] filterType) {
+               super("CPathFilterPage"); //$NON-NLS-1$
+               setTitle(CPathEntryMessages.CPathFilterPage_title); 
+               setDescription(CPathEntryMessages.CPathFilterPage_description); 
+               setImageDescriptor(CPluginImages.DESC_WIZBAN_ADD_LIBRARY);
+               fFilterType = filterType;
+               fCElement = cElement;
+               validatePage();
+       }
+
+       public void createControl(Composite parent) {
+               Composite container = new Composite(parent, SWT.NULL);
+               GridLayout layout = new GridLayout();
+               layout.numColumns = 2;
+               container.setLayout(layout);
+               Label label = new Label(container, SWT.NULL);
+               label.setText(CPathEntryMessages.CPathFilterPage_label); 
+               GridData gd = new GridData();
+               gd.horizontalSpan = 2;
+               label.setLayoutData(gd);
+               viewer = CheckboxTableViewer.newCheckList(container, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+               viewer.setContentProvider(new ListContentProvider());
+               viewer.setLabelProvider(new CPElementLabelProvider(false, false));
+               viewer.addCheckStateListener(new ICheckStateListener() {
+
+                       public void checkStateChanged(CheckStateChangedEvent event) {
+                               validatePage();
+                       }
+               });
+               gd = new GridData(GridData.FILL_BOTH);
+               gd.widthHint = 400;
+               gd.heightHint = 300;
+               viewer.getTable().setLayoutData(gd);
+               setControl(container);
+               Dialog.applyDialogFont(container);
+       }
+
+       @Override
+       public void setVisible(boolean visible) {
+               if (fPaths != null) {
+                       viewer.setInput(fPaths);
+               }
+               super.setVisible(visible);
+       }
+
+       public void setParentEntry(IPathEntry entry) {
+               fParentEntry = entry;
+               if (fParentEntry.getEntryKind() == IPathEntry.CDT_PROJECT) {
+                       IProject project = CUIPlugin.getWorkspace().getRoot().getProject(fParentEntry.getPath().segment(0));
+                       if (project.isAccessible()) {
+                               ICProject cProject = CoreModel.getDefault().create(project);
+                               try {
+                                       fPaths = Arrays.asList(cProject.getRawPathEntries());
+                               } catch (CModelException e) {
+                               }
+                       }
+               } else if (fParentEntry.getEntryKind() == IPathEntry.CDT_CONTAINER) {
+                       try {
+                               IPathEntryContainer container = CoreModel.getPathEntryContainer(fParentEntry.getPath(), fCElement.getCProject());
+                               if (container != null) {
+                                       fPaths = Arrays.asList(container.getPathEntries());
+                               }
+                       } catch (CModelException e) {
+                       }
+               }
+               createExlusions(fParentEntry.getEntryKind() == IPathEntry.CDT_PROJECT);
+       }
+
+       
+       private void createExlusions(boolean showExported) {
+               fExclusions = new ArrayList<Object>();
+               if (filter != null) {
+                       viewer.removeFilter(filter);
+               }
+               filter = new CPElementFilter(fExclusions.toArray(), fFilterType, showExported, false);
+               viewer.addFilter(filter);
+       }
+
+       /**
+        * Method validatePage.
+        */
+       void validatePage() {
+               setPageComplete(getSelectedEntries().length > 0);
+       }
+
+       public IPathEntry[] getSelectedEntries() {
+               if (viewer != null) {
+                       Object[] paths = viewer.getCheckedElements();
+                       IPathEntry[] entries = new IPathEntry[paths.length];
+                       System.arraycopy(paths, 0, entries, 0, entries.length);
+                       return entries;
+               }
+               return new IPathEntry[0];
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathFilterPathPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathFilterPathPage.java
new file mode 100644 (file)
index 0000000..7824868
--- /dev/null
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import org.eclipse.jface.wizard.Wizard;
+
+
+/**
+ * @deprecated as of CDT 4.0. This class does not seem to be used,
+ * probably remnant of 3.X style projects or earlier.
+ */
+@Deprecated
+public class CPathFilterPathPage extends Wizard {
+
+       @Override
+       public boolean performFinish() {
+               return true;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryBasePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryBasePage.java
new file mode 100644 (file)
index 0000000..add6956
--- /dev/null
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.util.List;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+
+import org.eclipse.cdt.core.model.ICElement;
+
+/**
+ * Abstract DialogPage for C/C++ Project Paths page for 3.X projects.
+ * 
+ * @deprecated as of CDT 4.0. This page was used to set preferences/properties
+ * for 3.X style projects.
+ */
+@Deprecated
+public abstract class CPathIncludeSymbolEntryBasePage extends CPathBasePage {
+
+    public CPathIncludeSymbolEntryBasePage(String title) {
+        super(title);
+    }
+
+    public CPathIncludeSymbolEntryBasePage(String title, ImageDescriptor image) {
+        super(title, image);
+    }
+
+    public abstract void init(ICElement cElement, List<CPElement> cPaths);
+    public abstract List<CPElement> getCPaths();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryPage.java
new file mode 100644 (file)
index 0000000..8ec639e
--- /dev/null
@@ -0,0 +1,1130 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+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.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.CoreModelUtil;
+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.IContainerEntry;
+import org.eclipse.cdt.core.model.IIncludeEntry;
+import org.eclipse.cdt.core.model.IMacroEntry;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CElementContentProvider;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
+import org.eclipse.cdt.internal.ui.dialogs.TypedElementSelectionValidator;
+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.ITreeListAdapter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
+
+/**
+ * DialogPage for C/C++ Project Paths page for 3.X projects.
+ * 
+ * @deprecated as of CDT 4.0. This page was used for property pages
+ * for 3.X style projects.
+ */
+@Deprecated
+public class CPathIncludeSymbolEntryPage extends CPathIncludeSymbolEntryBasePage {
+       private TreeListDialogField<CPElementGroup> fIncludeSymPathsList;
+       private SelectionButtonDialogField fShowInheritedPaths;
+       private ICProject fCurrCProject;
+       private CPElementFilter fFilter;
+       private IStatusChangeListener fContext;
+
+       private final int IDX_ADD_FOLDER_FILE = 0;
+       private final int IDX_ADD_SYMBOL = 2;
+       private final int IDX_ADD_EXT_INCLUDE = 4;
+       private final int IDX_ADD_WS_INCLUDE = 5;
+       private final int IDX_ADD_CONTRIBUTED = 7;
+       private final int IDX_EDIT = 9;
+       private final int IDX_REMOVE = 10;
+       private final int IDX_EXPORT = 12;
+       private final int IDX_UP = 14;
+       private final int IDX_DOWN = 15;
+
+       private static final String[] buttonLabel = new String[]{
+
+       CPathEntryMessages.IncludeSymbolEntryPage_addFolderFile, 
+                       null,
+                       CPathEntryMessages.IncludeSymbolEntryPage_addUserSymbol, 
+                       null,
+                       CPathEntryMessages.IncludeSymbolEntryPage_addExternalInclude, 
+                       CPathEntryMessages.IncludeSymbolEntryPage_addFromWorkspace, 
+                       null,
+                       CPathEntryMessages.IncludeSymbolEntryPage_addContributed, 
+                       null,
+                       CPathEntryMessages.IncludeSymbolEntryPage_edit, 
+                       CPathEntryMessages.IncludeSymbolEntryPage_remove, 
+                       null,
+                       CPathEntryMessages.IncludeSymbolEntryPage_export, 
+                       null,
+                       CPathEntryMessages.IncludeSymbolEntryPage_up, 
+                       CPathEntryMessages.IncludeSymbolEntryPage_down}; 
+       private CPElementGroup fTopGroup;
+
+       private class IncludeSymbolAdapter implements IDialogFieldListener, ITreeListAdapter<CPElementGroup> {
+               private final Object[] EMPTY_ARR = new Object[0];
+
+               // -------- IListAdapter --------
+               public void customButtonPressed(TreeListDialogField<CPElementGroup> field, int index) {
+                       ListCustomButtonPressed(field, index);
+               }
+
+               public void selectionChanged(TreeListDialogField<CPElementGroup> field) {
+                       listPageSelectionChanged(field);
+               }
+
+               public void doubleClicked(TreeListDialogField<CPElementGroup> field) {
+                       ListPageDoubleClicked(field);
+               }
+
+               public void keyPressed(TreeListDialogField<CPElementGroup> field, KeyEvent event) {
+                       ListPageKeyPressed(field, event);
+               }
+
+               public Object[] getChildren(TreeListDialogField<CPElementGroup> field, Object element) {
+                       if (element instanceof CPElement) {
+                               return ((CPElement)element).getChildren();
+                       } else if (element instanceof CPElementGroup) {
+                               return ((CPElementGroup)element).getChildren();
+                       }
+                       return EMPTY_ARR;
+               }
+
+               public Object getParent(TreeListDialogField<CPElementGroup> field, Object element) {
+                       if (element instanceof CPElementGroup) {
+                               return ((CPElementGroup)element).getParent();
+                       } else if (element instanceof CPElement) {
+                               return ((CPElement)element).getParent();
+                       }
+                       return null;
+               }
+
+               public boolean hasChildren(TreeListDialogField<CPElementGroup> field, Object element) {
+                       if (element instanceof CPElementGroup) {
+                               return true;
+                       }
+                       if (element instanceof CPElement) {
+                               return ((CPElement)element).getChildren().length > 0;
+                       }
+                       return false;
+               }
+
+               // ---------- IDialogFieldListener --------
+
+               public void dialogFieldChanged(DialogField field) {
+                       listPageDialogFieldChanged(field);
+               }
+
+       }
+
+       public CPathIncludeSymbolEntryPage(IStatusChangeListener context) {
+               super(CPathEntryMessages.IncludeSymbolEntryPage_title); 
+               fContext = context;
+               IncludeSymbolAdapter adapter = new IncludeSymbolAdapter();
+               fIncludeSymPathsList = new TreeListDialogField<CPElementGroup>(adapter, buttonLabel, new CPElementLabelProvider(true, false)) {
+
+                       @Override
+                       protected int getTreeStyle() {
+                               return super.getTreeStyle() & ~SWT.MULTI;
+                       }
+               };
+               fIncludeSymPathsList.setLabelText(CPathEntryMessages.IncludeSymbolEntryPage_label); 
+               fIncludeSymPathsList.enableButton(IDX_REMOVE, false);
+               fIncludeSymPathsList.enableButton(IDX_EDIT, false);
+               fIncludeSymPathsList.enableButton(IDX_ADD_CONTRIBUTED, true);
+               fIncludeSymPathsList.enableButton(IDX_ADD_EXT_INCLUDE, true);
+               fIncludeSymPathsList.enableButton(IDX_ADD_WS_INCLUDE, true);
+               fIncludeSymPathsList.enableButton(IDX_ADD_SYMBOL, true);
+               fIncludeSymPathsList.enableButton(IDX_EXPORT, false);
+               fIncludeSymPathsList.enableButton(IDX_UP, false);
+               fIncludeSymPathsList.enableButton(IDX_DOWN, false);
+               fIncludeSymPathsList.setTreeExpansionLevel(2);
+               fShowInheritedPaths = new SelectionButtonDialogField(SWT.CHECK);
+               fShowInheritedPaths.setSelection(true);
+               fShowInheritedPaths.setLabelText(CPathEntryMessages.IncludeSymbolsEntryPage_show_inherited_check); 
+               fShowInheritedPaths.setDialogFieldListener(adapter);
+
+               fFilter = new CPElementFilter(new int[]{-1, IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO, IPathEntry.CDT_CONTAINER}, false,
+                               true);
+       }
+
+       @Override
+       public void createControl(Composite parent) {
+               PixelConverter converter = new PixelConverter(parent);
+
+               Composite composite = new Composite(parent, SWT.NONE);
+               composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+               LayoutUtil.doDefaultLayout(composite, new DialogField[]{fIncludeSymPathsList, fShowInheritedPaths}, true);
+               LayoutUtil.setHorizontalGrabbing(fIncludeSymPathsList.getTreeControl(null), true);
+
+               int buttonBarWidth = converter.convertWidthInCharsToPixels(24);
+               fIncludeSymPathsList.setButtonsMinWidth(buttonBarWidth);
+               setControl(composite);
+               fIncludeSymPathsList.getTreeViewer().addFilter(fFilter);
+               CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.PROJECT_INCLUDE_PATHS_SYMBOLS);
+       }
+
+       @Override
+       public Image getImage() {
+               return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_CONTAINER);
+       }
+
+       @Override
+       public void init(ICElement cElement, List<CPElement> cPaths) {
+               fCurrCProject = cElement.getCProject();
+               List<CPElementGroup> elements = createGroups(cElement, cPaths);
+               fIncludeSymPathsList.setElements(elements);
+               updateStatus();
+       }
+
+       private void updateStatus() {
+               CPElement entryError = null;
+               int nErrorEntries = 0;
+               IStatus status = Status.OK_STATUS;
+               List<CPElement> elements = getCPaths();
+               for (int i = elements.size() - 1; i >= 0; i--) {
+                       CPElement currElement = elements.get(i);
+                       if (currElement.getStatus().getSeverity() != IStatus.OK) {
+                               nErrorEntries++;
+                               if (entryError == null) {
+                                       entryError = currElement;
+                               }
+                       }
+               }
+
+               if (nErrorEntries > 0) {
+                       if (nErrorEntries == 1 && entryError != null) {
+                               status = entryError.getStatus();
+                       } else {
+                               status = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, NLS.bind(
+                                               CPathEntryMessages.CPElement_status_multiplePathErrors,
+                                               String.valueOf(nErrorEntries)), null);
+                       }
+               }
+               fContext.statusChanged(status);
+       }
+
+       private void updateStatus(List<?> selected) {
+               if (selected.size() != 1) {
+                       updateStatus();
+                       return;
+               }
+               CPElement element = null;
+               if (selected.get(0) instanceof CPElement) {
+                       element = (CPElement)selected.get(0);
+               } else if (selected.get(0) instanceof CPElementAttribute) {
+                       element = ((CPElementAttribute)selected.get(0)).getParent();
+               }
+               if (element != null && element.getStatus().getSeverity() != IStatus.OK) {
+                       fContext.statusChanged(element.getStatus());
+               } else {
+                       updateStatus();
+                       return;
+               }
+       }
+       
+       private List<CPElementGroup> createGroups(ICElement element, List<?> cPaths) {
+               // create resource groups
+               List<CPElementGroup> resourceGroups = new ArrayList<CPElementGroup>(5);
+               fTopGroup = new CPElementGroup(element.getResource());
+               resourceGroups.add(fTopGroup);
+                // add containers first so that they appear at top of list
+               for (int i = 0; i < cPaths.size(); i++) {
+                       CPElement cpelement = (CPElement)cPaths.get(i);
+                       switch (cpelement.getEntryKind()) {
+                               case IPathEntry.CDT_CONTAINER :
+                                       fTopGroup.addChild(cpelement);
+                                       break;
+                       }
+               }
+               for (int i = 0; i < cPaths.size(); i++) {
+                       CPElement cpelement = (CPElement)cPaths.get(i);
+                       switch (cpelement.getEntryKind()) {
+                               case IPathEntry.CDT_INCLUDE :
+                               case IPathEntry.CDT_MACRO :
+                                       CPElementGroup resGroup = new CPElementGroup(cpelement.getResource());
+                                       int ndx = resourceGroups.indexOf(resGroup);
+                                       if (ndx == -1) {
+                                               resourceGroups.add(resGroup);
+                                       } else {
+                                               resGroup = resourceGroups.get(ndx);
+                                       }
+                                       resGroup.addChild(cpelement);
+                       }
+               }
+
+               // place each path in its appropriate inherited group (or not if
+               // excluded)
+               for (int i = 0; i < cPaths.size(); i++) {
+                       CPElement cpelement = (CPElement)cPaths.get(i);
+                       switch (cpelement.getEntryKind()) {
+                               case IPathEntry.CDT_INCLUDE :
+                               case IPathEntry.CDT_MACRO :
+                                       addPathToResourceGroups(cpelement, null, resourceGroups);
+                       }
+               }
+               return resourceGroups;
+       }
+
+       private void addPathToResourceGroup(CPElement element, CPElementGroup parent, CPElementGroup group) {
+               IPath resPath = element.getPath();
+               IPath[] exclusions = (IPath[])element.getAttribute(CPElement.EXCLUSION);
+               if ((group != parent || !group.getResource().equals(element.getResource()))
+                               && resPath.isPrefixOf(group.getPath())
+                               && (resPath.equals(group.getPath()) || !CoreModelUtil.isExcludedPath(
+                                               group.getResource().getFullPath().removeFirstSegments(resPath.segmentCount()), exclusions))) {
+                       if (parent != null) { // try to insert at proper place in group...
+                               int insertHere = -1;
+                               int ndx = parent.indexof(element);
+                               if (ndx != -1) {
+                                       CPElement[] children = parent.getChildren(element.getEntryKind());
+                                       for (int i = ndx; i < children.length; i++) {
+                                               insertHere = group.indexof(new CPElement(children[i], group.getPath(), group.getResource()));
+                                               if (insertHere != -1) {
+                                                       group.addChild(new CPElement(element, group.getPath(), group.getResource()), insertHere);
+                                                       break;
+                                               }
+                                       }
+                               }
+                               if (insertHere == -1) {
+                                       group.addChild(new CPElement(element, group.getPath(), group.getResource()));
+                               }
+                       } else {
+                               group.addChild(new CPElement(element, group.getPath(), group.getResource()));
+                       }
+               }
+       }
+
+       private void addPathToResourceGroups(CPElement element, CPElementGroup parent, List<CPElementGroup> groups) {
+               if (parent != null) {
+                       parent.addChild(element);
+               }
+               for (int i = 0; i < groups.size(); i++) {
+                       CPElementGroup group = groups.get(i);
+                       addPathToResourceGroup(element, parent, group);
+               }
+       }
+
+       private void updatePathOnResourceGroups(CPElement element, List<CPElementGroup> groups) {
+               CPElementGroup parent = element.getParent();
+               IPath resPath = element.getPath();
+               IPath[] exclusions = (IPath[])element.getAttribute(CPElement.EXCLUSION);
+               for (int i = 0; i < groups.size(); i++) {
+                       CPElementGroup group = groups.get(i);
+                       if (group != parent) {
+                               boolean found = false;
+                               CPElement[] elements = group.getChildren(element.getEntryKind());
+                               for (CPElement element2 : elements) {
+                                       if (element2.getInherited() == element) {
+                                               found = true;
+                                               if (!CoreModelUtil.isExcludedPath(group.getResource().getFullPath().removeFirstSegments(
+                                                               resPath.segmentCount()), exclusions)) {
+                                                       group.replaceChild(element2, new CPElement(element, group.getPath(), group.getResource()));
+                                               } else {
+                                                       group.removeChild(element2);
+                                               }
+                                               break;
+                                       }
+                               }
+                               if (!found) {
+                                       addPathToResourceGroup(element, parent, group);
+                               }
+                       }
+               }
+       }
+
+       private CPElement removePathFromResourceGroups(CPElement element, List<CPElementGroup> groups) {
+               CPElement Inherited = element.getInherited();
+               CPElementGroup resGroup = element.getParent();
+               resGroup.removeChild(element);
+               if (Inherited != null) { // applied exclusion to orig.
+                       IPath exclude = element.getPath().removeFirstSegments(Inherited.getPath().segmentCount());
+                       IPath[] exclusions = (IPath[])Inherited.getAttribute(CPElement.EXCLUSION);
+                       IPath[] newExlusions = new IPath[exclusions.length + 1];
+                       System.arraycopy(exclusions, 0, newExlusions, 0, exclusions.length);
+                       newExlusions[exclusions.length] = exclude;
+                       Inherited.setAttribute(CPElement.EXCLUSION, newExlusions);
+                       return null;
+               }
+               // remove all inherited
+               for (int i = 0; i < groups.size(); i++) {
+                       CPElementGroup group = groups.get(i);
+                       CPElement elements[] = group.getChildren(element.getEntryKind());
+                       for (CPElement element2 : elements) {
+                               if (element2.getInherited() == element) {
+                                       group.removeChild(element2);
+                                       break;
+                               }
+                       }
+               }
+               return element;
+       }
+
+       private boolean canAddPath(List<?> selected) {
+               CPElementGroup group = getSelectedGroup();
+               if (group != null) {
+                       return group.getEntryKind() == -1; // resource group
+               }
+               return false;
+       }
+
+       private boolean canRemove(List<?> selected) {
+               if (selected.size() != 1) {
+                       return false;
+               }
+               Object elem = selected.get(0);
+               if (elem instanceof CPElement) {
+                       CPElement element = (CPElement)elem;
+                       if (element.getParentContainer() == null) {
+                               return element.getEntryKind() == IPathEntry.CDT_INCLUDE || element.getEntryKind() == IPathEntry.CDT_MACRO;
+                       }
+               } else if (elem instanceof CPElementAttribute) {
+                       CPElementAttribute attrib = (CPElementAttribute)elem;
+                       if (attrib.getKey().equals(CPElement.EXCLUSION)) {
+                               if (((IPath[])attrib.getValue()).length > 0) {
+                                       return true;
+                               }
+                       }
+               }
+               return false;
+       }
+
+       private void removeEntry() {
+               List<?> selected = getSelection();
+               Object elem = selected.get(0);
+               if (elem instanceof CPElement) {
+                       CPElement element = (CPElement)elem;
+                       CPElementGroup parent = element.getParent();
+                       if (removePathFromResourceGroups(element, fIncludeSymPathsList.getElements()) == null) {
+                               updatePathOnResourceGroups(element.getInherited(), fIncludeSymPathsList.getElements());
+                       }
+                       fIncludeSymPathsList.refresh();
+                       fIncludeSymPathsList.selectElements(new StructuredSelection(parent));
+               } else if (elem instanceof CPElementAttribute) {
+                       CPElementAttribute attrib = (CPElementAttribute)elem;
+                       String key = attrib.getKey();
+                       Object value = key.equals(CPElement.EXCLUSION) ? new Path[0] : null;
+                       attrib.getParent().setAttribute(key, value);
+                       updatePathOnResourceGroups(attrib.getParent(), fIncludeSymPathsList.getElements());
+                       fIncludeSymPathsList.refresh();
+               }
+               updateStatus();
+       }
+
+       private boolean canEdit(List<?> selected) {
+               if (selected.size() != 1) {
+                       return false;
+               }
+               Object elem = selected.get(0);
+               if (elem instanceof CPElement) {
+                       CPElement element = (CPElement)selected.get(0);
+                       if (element.getParentContainer() == null && element.getInherited() == null) {
+                               IPath path = (IPath)element.getAttribute(CPElement.BASE_REF);
+                               if (path != null && !path.equals(Path.EMPTY)) {
+                                       return false;
+                               }
+                               return element.getEntryKind() == IPathEntry.CDT_INCLUDE || element.getEntryKind() == IPathEntry.CDT_MACRO
+                                               || element.getEntryKind() == IPathEntry.CDT_CONTAINER;
+                       }
+               }
+               if (elem instanceof CPElementAttribute) {
+                       return true;
+               }
+               return false;
+       }
+
+       private void editEntry() {
+               List<?> selElements = fIncludeSymPathsList.getSelectedElements();
+               if (selElements.size() != 1) {
+                       return;
+               }
+               Object element = selElements.get(0);
+
+               if (element instanceof CPElement) {
+                       editElementEntry((CPElement)element);
+               } else if (element instanceof CPElementAttribute) {
+                       editAttributeEntry((CPElementAttribute)element);
+               }
+       }
+
+       private void editElementEntry(CPElement element) {
+               IPath path = (IPath)element.getAttribute(CPElement.BASE_REF);
+               if (path != null && !path.equals(Path.EMPTY)) {
+                       return;
+               } else if (element.getEntryKind() == IPathEntry.CDT_MACRO) {
+                       addSymbol(element);
+               } else if (element.getEntryKind() == IPathEntry.CDT_INCLUDE) {
+                       path = (IPath)element.getAttribute(CPElement.BASE);
+                       if (path != null && !path.equals(Path.EMPTY)) {
+                               CPElement[] includes = openWorkspacePathEntryDialog(null);
+                               if (includes != null && includes.length > 0) {
+                                       includes[0].setExported(element.isExported());
+
+                               }
+                       } else {
+                               addInclude(element);
+                       }
+               } else if (element.getEntryKind() == IPathEntry.CDT_CONTAINER) {
+                       CPElement[] res = null;
+
+                       res = openContainerSelectionDialog(element);
+                       if (res != null && res.length > 0) {
+                               CPElement curr = res[0];
+                               curr.setExported(element.isExported());
+                               fTopGroup.replaceChild(element, curr);
+                               fIncludeSymPathsList.refresh();
+                       }
+               }
+       }
+
+       private void editAttributeEntry(CPElementAttribute elem) {
+               String key = elem.getKey();
+               if (key.equals(CPElement.EXCLUSION)) {
+                       CPElement selElement = elem.getParent();
+                       ExclusionPatternDialog dialog = new ExclusionPatternDialog(getShell(), selElement);
+                       if (dialog.open() == Window.OK) {
+                               selElement.setAttribute(CPElement.EXCLUSION, dialog.getExclusionPattern());
+                               updatePathOnResourceGroups(selElement, fIncludeSymPathsList.getElements());
+                               fIncludeSymPathsList.refresh();
+                               updateStatus();
+                       }
+               }
+       }
+
+       private void exportEntry() {
+               CPElement element = (CPElement)getSelection().get(0);
+               element.setExported(!element.isExported()); // toggle
+               fIncludeSymPathsList.refresh(element);
+       }
+
+       private boolean canExport(List<?> selected) {
+               if (selected.size() != 1) {
+                       return false;
+               }
+               Object elem = selected.get(0);
+               if (elem instanceof CPElement) {
+                       CPElement element = (CPElement)selected.get(0);
+                       if (element.getParentContainer() == null && element.getInherited() == null) {
+                               IPath base_ref = (IPath)element.getAttribute(CPElement.BASE_REF);
+                               if (base_ref != null && !base_ref.equals(Path.EMPTY))
+                                       return false;
+                               return element.getEntryKind() == IPathEntry.CDT_INCLUDE || element.getEntryKind() == IPathEntry.CDT_MACRO;
+                       }
+               }
+               return false;
+       }
+
+       private boolean canMove(List<?> selected) {
+               if (selected.size() == 0) {
+                       return false;
+               }
+               for (int i = 0; i < selected.size(); i++) {
+                       Object element = selected.get(i);
+                       if (! (element instanceof CPElement))
+                               return false;
+                       CPElement elem = (CPElement)element;
+                       if (elem.getEntryKind() != IPathEntry.CDT_INCLUDE && elem.getEntryKind() != IPathEntry.CDT_MACRO) {
+                               return false;
+                       }
+                       if (elem.getParentContainer() != null || elem.getInherited() != null) {
+                               return false;
+                       }
+               }
+               return true;
+       }
+
+       private boolean canMoveUp(List<?> selected) {
+               if (!canMove(selected)) {
+                       return false;
+               }
+               CPElement first = (CPElement)selected.get(0);
+               CPElementGroup parent = first.getParent();
+               CPElement children[] = parent.getChildren(first.getEntryKind());
+               int indx = Arrays.asList(children).indexOf(first);
+               if (indx <= 0) {
+                       return false;
+               }
+               return true;
+       }
+
+       private boolean canMoveDown(List<?> selected) {
+               if (!canMove(selected)) {
+                       return false;
+               }
+               CPElement last = (CPElement)selected.get(selected.size() - 1);
+               CPElementGroup parent = last.getParent();
+               CPElement children[] = parent.getChildren(last.getEntryKind());
+               int indx = Arrays.asList(children).indexOf(last);
+               if (indx >= children.length - 1 || children[indx + 1].getInherited() != null) {
+                       return false;
+               }
+               return true;
+       }
+
+       private boolean moveUp(CPElement element) {
+               boolean rc = false;
+               int kind = element.getEntryKind();
+               for (CPElementGroup group : fIncludeSymPathsList.getElements()) {
+                       CPElement[] children = group.getChildren(kind);
+                       for (int k = 0; k < children.length; ++k) {
+                               CPElement child = children[k];
+                               if (element.equals(child) || (child.getInherited() != null && child.getInherited().equals(element))) {
+                                       if (child.getInherited() != null && k > 0 && children[k - 1].getInherited() == null) {
+                                               break;
+                                       }
+                                       int prevIndex = k - 1;
+                                       if (prevIndex >= 0) {
+                                               // swap the two
+                                               children[k] = children[prevIndex];
+                                               children[prevIndex] = child;
+                                               rc = true;
+                                               break;
+                                       }
+                               }
+                       }
+                       group.setChildren(children);
+               }
+               fIncludeSymPathsList.refresh();
+               fIncludeSymPathsList.selectElements(new StructuredSelection(element));
+               fIncludeSymPathsList.setFocus();
+               return rc;
+       }
+
+       /**
+        *  
+        */
+       private boolean moveDown(CPElement element) {
+               boolean rc = false;
+               int kind = element.getEntryKind();
+               for (CPElementGroup group : fIncludeSymPathsList.getElements()) {
+                       CPElement[] children = group.getChildren(kind);
+                       for (int k = children.length - 1; k >= 0; --k) {
+                               CPElement child = children[k];
+                               if (element.equals(child) || (child.getInherited() != null && child.getInherited().equals(element))) {
+                                       int prevIndex = k + 1;
+                                       if (prevIndex < children.length) {
+                                               // swap the two
+                                               children[k] = children[prevIndex];
+                                               children[prevIndex] = child;
+                                               rc = true;
+                                               break;
+                                       }
+                               }
+                       }
+                       group.setChildren(children);
+               }
+               fIncludeSymPathsList.refresh();
+               fIncludeSymPathsList.selectElements(new StructuredSelection(element));
+               fIncludeSymPathsList.setFocus();
+               return rc;
+       }
+
+       private CPElementGroup getSelectedGroup() {
+               List<?> selected = fIncludeSymPathsList.getSelectedElements();
+               if (!selected.isEmpty()) {
+                       Object item = selected.get(0);
+                       if (item instanceof CPElement) {
+                               item = ((CPElement)item).getParent();
+                       }
+                       if (item instanceof CPElementGroup) {
+                               return (CPElementGroup)item;
+                       }
+               }
+               return fTopGroup;
+       }
+
+       protected void listPageDialogFieldChanged(DialogField field) {
+               if (field == fShowInheritedPaths) {
+                       boolean showInherited = fShowInheritedPaths.isSelected();
+                       if (fFilter != null) {
+                               fIncludeSymPathsList.getTreeViewer().removeFilter(fFilter);
+                       }
+                       fFilter = new CPElementFilter(new int[]{-1, IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO, IPathEntry.CDT_CONTAINER},
+                                       false, showInherited);
+                       fIncludeSymPathsList.getTreeViewer().addFilter(fFilter);
+                       fIncludeSymPathsList.refresh();
+               }
+               updateStatus();
+       }
+
+       protected void listPageSelectionChanged(TreeListDialogField<?> field) {
+               List<?> selected = field.getSelectedElements();
+               field.enableButton(IDX_REMOVE, canRemove(selected));
+               field.enableButton(IDX_EDIT, canEdit(selected));
+               field.enableButton(IDX_ADD_CONTRIBUTED, canAddPath(selected));
+               field.enableButton(IDX_ADD_EXT_INCLUDE, canAddPath(selected));
+               field.enableButton(IDX_ADD_WS_INCLUDE, canAddPath(selected));
+               field.enableButton(IDX_ADD_SYMBOL, canAddPath(selected));
+               field.enableButton(IDX_EXPORT, canExport(selected));
+               field.enableButton(IDX_DOWN, canMoveDown(selected));
+               field.enableButton(IDX_UP, canMoveUp(selected));
+               updateStatus(selected);
+       }
+
+       protected void ListCustomButtonPressed(TreeListDialogField<?> field, int index) {
+               switch (index) {
+                       case IDX_ADD_FOLDER_FILE :
+                               addNewPathResource();
+                               break;
+                       case IDX_ADD_SYMBOL :
+                               addSymbol(null);
+                               break;
+                       case IDX_ADD_EXT_INCLUDE :
+                               addInclude(null);
+                               break;
+                       case IDX_ADD_WS_INCLUDE :
+                               addFromWorkspace();
+                               break;
+                       case IDX_ADD_CONTRIBUTED :
+                               addContributed();
+                               break;
+                       case IDX_EDIT :
+                               if (canEdit(field.getSelectedElements())) {
+                                       editEntry();
+                               }
+                               break;
+                       case IDX_REMOVE :
+                               if (canRemove(field.getSelectedElements())) {
+                                       removeEntry();
+                               }
+                               break;
+                       case IDX_DOWN :
+                               if (canMoveDown(field.getSelectedElements())) {
+                                       moveDown((CPElement)field.getSelectedElements().get(0));
+                               }
+                               break;
+                       case IDX_UP :
+                               if (canMoveUp(field.getSelectedElements())) {
+                                       moveUp((CPElement)field.getSelectedElements().get(0));
+                               }
+                               break;
+                       case IDX_EXPORT :
+                               if (canExport(field.getSelectedElements())) {
+                                       exportEntry();
+                               }
+
+               }
+       }
+
+       protected void ListPageDoubleClicked(TreeListDialogField<?> field) {
+               if (canEdit(fIncludeSymPathsList.getSelectedElements())) {
+                       editEntry();
+               }
+       }
+
+       protected void ListPageKeyPressed(TreeListDialogField<?> field, KeyEvent event) {
+               if (field == fIncludeSymPathsList) {
+                       if (event.character == SWT.DEL && event.stateMask == 0) {
+                               List<?> selection = field.getSelectedElements();
+                               if (canEdit(selection)) {
+                                       removeEntry();
+                               }
+                       }
+               }
+       }
+
+       protected IPathEntry[] getRawPathEntries() {
+               List<CPElement> paths = getCPaths();
+               IPathEntry[] currEntries = new IPathEntry[paths.size()];
+               for (int i = 0; i < currEntries.length; i++) {
+                       CPElement curr = paths.get(i);
+                       currEntries[i] = curr.getPathEntry();
+               }
+               return currEntries;
+       }
+
+       protected void addNewPathResource() {
+               Class<?>[] acceptedClasses = new Class[]{ICProject.class, ICContainer.class, ITranslationUnit.class};
+               TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses, false);
+               ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
+
+               String title = CPathEntryMessages.IncludeSymbolEntryPage_newResource_title; 
+               String message = CPathEntryMessages.IncludeSymbolEntryPage_newResource_description; 
+
+               ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(),
+                               new CElementContentProvider());
+               dialog.setValidator(validator);
+               dialog.setTitle(title);
+               dialog.setMessage(message);
+               dialog.addFilter(filter);
+               dialog.setInput(fCurrCProject);
+               dialog.setInitialSelection(fCurrCProject);
+
+               if (dialog.open() == Window.OK) {
+                       Object[] elements = dialog.getResult();
+                       IResource resource;
+                       if (elements[0] instanceof IResource) {
+                               resource = (IResource)elements[0];
+                       } else {
+                               resource = ((ICElement)elements[0]).getResource();
+                       }
+                       CPElementGroup newGroup = new CPElementGroup(resource);
+                       if (!fIncludeSymPathsList.getElements().contains(newGroup)) {
+                               List<CPElementGroup> groups = fIncludeSymPathsList.getElements();
+                               for (int i = 0; i < groups.size(); i++) {
+                                       CPElementGroup group = groups.get(i);
+                                       if (group.getPath().isPrefixOf(newGroup.getPath())) {
+                                               CPElement[] cpelements = group.getChildren();
+                                               for (CPElement cpelement : cpelements) {
+                                                       if (cpelement.getInherited() == null) {
+                                                               switch (cpelement.getEntryKind()) {
+                                                                       case IPathEntry.CDT_INCLUDE :
+                                                                       case IPathEntry.CDT_MACRO :
+                                                                               addPathToResourceGroup(cpelement, null, newGroup);
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                               fIncludeSymPathsList.addElement(newGroup);
+                       }
+                       fIncludeSymPathsList.selectElements(new StructuredSelection(newGroup));
+                       fIncludeSymPathsList.expandElement(newGroup, 1);
+               }
+       }
+
+       protected void addSymbol(CPElement existing) {
+               // Popup an entry dialog
+               InputDialog dialog;
+               if (existing == null) {
+                       dialog = new InputDialog(getShell(), CPathEntryMessages.IncludeSymbolEntryPage_addSymbol_title, 
+                                       CPathEntryMessages.IncludeSymbolEntryPage_addSymbol_message, "",  //$NON-NLS-1$
+                                       null);
+               } else {
+                       StringBuffer initialValue = new StringBuffer();
+                       initialValue.append((String)existing.getAttribute(CPElement.MACRO_NAME));
+                       initialValue.append('=');
+                       initialValue.append((String)existing.getAttribute(CPElement.MACRO_VALUE));
+                       dialog = new InputDialog(getShell(), CPathEntryMessages.IncludeSymbolEntryPage_editSymbol_title, 
+                                       CPathEntryMessages.IncludeSymbolEntryPage_editSymbol_message, initialValue.toString(), 
+                                       null);
+               }
+
+               String symbol = null;
+               if (dialog.open() == Window.OK) {
+                       symbol = dialog.getValue();
+                       if (symbol != null && symbol.length() > 0) {
+                               CPElementGroup group = getSelectedGroup();
+                               CPElement newPath = new CPElement(fCurrCProject, IPathEntry.CDT_MACRO, group.getResource().getFullPath(),
+                                               group.getResource());
+                               String name, value = ""; //$NON-NLS-1$
+                               int index = symbol.indexOf("="); //$NON-NLS-1$
+                               if (index != -1) {
+                                       name = symbol.substring(0, index).trim();
+                                       value = symbol.substring(index + 1).trim();
+                               } else {
+                                       name = symbol.trim();
+                               }
+                               if (existing != null) {
+                                       existing.setAttribute(CPElement.MACRO_NAME, name);
+                                       existing.setAttribute(CPElement.MACRO_VALUE, value);
+                                       updatePathOnResourceGroups(existing, fIncludeSymPathsList.getElements());
+                                       fIncludeSymPathsList.refresh();
+                               } else {
+                                       newPath.setAttribute(CPElement.MACRO_NAME, name);
+                                       newPath.setAttribute(CPElement.MACRO_VALUE, value);
+                                       if (!group.contains(newPath)) {
+                                               addPathToResourceGroups(newPath, group, fIncludeSymPathsList.getElements());
+                                               fIncludeSymPathsList.refresh();
+                                               fIncludeSymPathsList.selectElements(new StructuredSelection(newPath));
+                                       }
+                                       updateStatus();
+                               }
+                       }
+               }
+       }
+
+       protected void addInclude(CPElement existing) {
+               InputDialog dialog;
+               if (existing == null) {
+                       dialog = new SelectPathInputDialog(getShell(),
+                                       CPathEntryMessages.IncludeSymbolEntryPage_addExternal_title, 
+                                       CPathEntryMessages.IncludeSymbolEntryPage_addExternal_message, null, null); 
+               } else {
+                       dialog = new SelectPathInputDialog(
+                                       getShell(),
+                                       CPathEntryMessages.IncludeSymbolEntryPage_editExternal_title, 
+                                       CPathEntryMessages.IncludeSymbolEntryPage_editExternal_message, ((IPath)existing.getAttribute(CPElement.INCLUDE)).toOSString(), null); 
+               }
+               String newItem = null;
+               if (dialog.open() == Window.OK) {
+                       newItem = dialog.getValue();
+                       if (newItem != null && !newItem.equals("")) { //$NON-NLS-1$
+                               if (existing == null) {
+                                       CPElementGroup group = getSelectedGroup();
+                                       CPElement newPath = new CPElement(fCurrCProject, IPathEntry.CDT_INCLUDE, group.getResource().getFullPath(),
+                                                       group.getResource());
+                                       newPath.setAttribute(CPElement.INCLUDE, new Path(newItem));
+                                       if (!group.contains(newPath)) {
+                                               addPathToResourceGroups(newPath, group, fIncludeSymPathsList.getElements());
+                                               fIncludeSymPathsList.refresh();
+                                               fIncludeSymPathsList.selectElements(new StructuredSelection(newPath));
+                                       }
+                               } else {
+                                       existing.setAttribute(CPElement.INCLUDE, new Path(newItem));
+                                       updatePathOnResourceGroups(existing, fIncludeSymPathsList.getElements());
+                                       fIncludeSymPathsList.refresh();
+                               }
+                               updateStatus();
+                       }
+               }
+       }
+
+       protected void addFromWorkspace() {
+               CPElement[] includes = openWorkspacePathEntryDialog(null);
+               if (includes != null && includes.length > 0) {
+                       int nElementsChosen = includes.length;
+                       CPElementGroup group = getSelectedGroup();
+                       for (int i = 0; i < nElementsChosen; i++) {
+                               CPElement curr = includes[i];
+                               if (!group.contains(curr)) {
+                                       addPathToResourceGroups(curr, group, fIncludeSymPathsList.getElements());
+                                       fIncludeSymPathsList.refresh();
+                                       fIncludeSymPathsList.selectElements(new StructuredSelection(curr));
+                                       updateStatus();
+                               }
+                       }
+               }
+
+       }
+
+       protected void addContributed() {
+               CPElement[] includes = openContainerSelectionDialog(null);
+               if (includes != null && includes.length > 0) {
+                       int nElementsChosen = includes.length;
+                       // remove duplicates
+                       CPElementGroup group = getSelectedGroup();
+                       for (int i = 0; i < nElementsChosen; i++) {
+                               CPElement curr = includes[i];
+                               if (!group.contains(curr)) {
+                                       addPathToResourceGroups(curr, getSelectedGroup(), fIncludeSymPathsList.getElements());
+                                       fIncludeSymPathsList.refresh();
+                                       fIncludeSymPathsList.selectElements(new StructuredSelection(curr));
+                                       updateStatus();
+                               }
+                       }
+               }
+       }
+
+       protected CPElement[] openWorkspacePathEntryDialog(CPElement existing) {
+               Class<?>[] acceptedClasses = new Class[]{ICProject.class, IProject.class, IContainer.class, ICContainer.class};
+               TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses, existing == null);
+               ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
+
+               String title = (existing == null) ? CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_new_title
+                               : CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_edit_title; 
+               String message = (existing == null)
+                               ? CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_new_description
+                               : CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_edit_description; 
+
+               ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(),
+                               new CElementContentProvider());
+               dialog.setValidator(validator);
+               dialog.setTitle(title);
+               dialog.setMessage(message);
+               dialog.addFilter(filter);
+               dialog.setInput(CoreModel.getDefault().getCModel());
+               if (existing == null) {
+                       dialog.setInitialSelection(fCurrCProject);
+               } else {
+                       dialog.setInitialSelection(existing.getCProject());
+               }
+
+               if (dialog.open() == Window.OK) {
+                       Object[] elements = dialog.getResult();
+                       CPElement[] res = new CPElement[elements.length];
+                       for (int i = 0; i < res.length; i++) {
+                               IProject project;
+                               IPath includePath;
+                               if (elements[i] instanceof IResource) {
+                                       project = ((IResource)elements[i]).getProject();
+                                       includePath = ((IResource)elements[i]).getProjectRelativePath();
+                               } else {
+                                       project = ((ICElement)elements[i]).getCProject().getProject();
+                                       includePath = ((ICElement)elements[i]).getResource().getProjectRelativePath();
+                               }
+                               CPElementGroup group = getSelectedGroup();
+                               res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_INCLUDE, group.getResource().getFullPath(),
+                                               group.getResource());
+                               res[i].setAttribute(CPElement.BASE, project.getFullPath().makeRelative());
+                               res[i].setAttribute(CPElement.INCLUDE, includePath);
+                       }
+                       return res;
+               }
+               return null;
+       }
+
+       protected CPElement[] openContainerSelectionDialog(CPElement existing) {
+               IContainerEntry elem = null;
+               String title;
+               if (existing == null) {
+                       title = CPathEntryMessages.IncludeSymbolEntryPage_ContainerDialog_new_title; 
+               } else {
+                       title = CPathEntryMessages.IncludeSymbolEntryPage_ContainerDialog_edit_title; 
+                       elem = (IContainerEntry)existing.getPathEntry();
+               }
+               CPathContainerWizard wizard = new CPathContainerWizard(elem, null, fCurrCProject, getRawPathEntries(), new int[]{
+                               IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO});
+               wizard.setWindowTitle(title);
+               if (CPathContainerWizard.openWizard(getShell(), wizard) == Window.OK) {
+                       IPathEntry parent = wizard.getEntriesParent();
+                       IPathEntry[] elements = wizard.getEntries();
+
+                       if (elements != null) {
+                               CPElement[] res = new CPElement[elements.length];
+                               CPElementGroup group = getSelectedGroup();
+                               for (int i = 0; i < res.length; i++) {
+                                       if (elements[i].getEntryKind() == IPathEntry.CDT_INCLUDE) {
+                                               res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_INCLUDE, group.getResource().getFullPath(),
+                                                               group.getResource());
+                                               res[i].setAttribute(CPElement.INCLUDE, ((IIncludeEntry)elements[i]).getIncludePath());
+                                               res[i].setAttribute(CPElement.BASE_REF, parent.getPath());
+                                       } else if (elements[i].getEntryKind() == IPathEntry.CDT_MACRO) {
+                                               res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_MACRO, group.getResource().getFullPath(),
+                                                               group.getResource());
+                                               res[i].setAttribute(CPElement.MACRO_NAME, ((IMacroEntry)elements[i]).getMacroName());
+                                               res[i].setAttribute(CPElement.BASE_REF, parent.getPath());
+                                       }
+                               }
+                               return res;
+                       }
+                       return new CPElement[]{CPElement.createFromExisting(parent, fCurrCProject)};
+               }
+               return null;
+       }
+
+       private class SelectPathInputDialog extends InputDialog {
+
+               public SelectPathInputDialog(Shell parentShell, String dialogTitle, String dialogMessage, String initialValue,
+                               IInputValidator validator) {
+                       super(parentShell, dialogTitle, dialogMessage, initialValue, validator);
+               }
+
+               @Override
+               protected void createButtonsForButtonBar(Composite parent) {
+                       super.createButtonsForButtonBar(parent);
+                       Button browse = createButton(parent, 3,
+                                       CPathEntryMessages.IncludeSymbolEntryPage_addExternal_button_browse, 
+                                       false);
+                       browse.addSelectionListener(new SelectionAdapter() {
+
+                               @Override
+                               public void widgetSelected(SelectionEvent ev) {
+                                       DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.OPEN);
+                                       dialog.setText(CPathEntryMessages.IncludeSymbolEntryPage_browseForFolder); 
+                                       String currentName = getText().getText();
+                                       if (currentName != null && currentName.trim().length() != 0) {
+                                               dialog.setFilterPath(currentName);
+                                       }
+                                       String dirname = dialog.open();
+                                       if (dirname != null) {
+                                               getText().setText(dirname);
+                                       }
+                               }
+                       });
+               }
+
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.cdt.internal.ui.dialogs.cpaths.CPathBasePage#getSelection()
+        */
+       @Override
+       public List<?> getSelection() {
+               return fIncludeSymPathsList.getSelectedElements();
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.cdt.internal.ui.dialogs.cpaths.CPathBasePage#setSelection(java.util.List)
+        */
+       @Override
+       public void setSelection(List<?> selElements) {
+               fIncludeSymPathsList.selectElements(new StructuredSelection(selElements));
+       }
+
+       @Override
+       public boolean isEntryKind(int kind) {
+               return kind == IPathEntry.CDT_INCLUDE || kind == IPathEntry.CDT_MACRO;
+       }
+
+       @Override
+       public void performApply(IProgressMonitor monitor) throws CoreException {
+       }
+
+       @Override
+       public void performDefaults() {
+       }
+
+       @Override
+       public List<CPElement> getCPaths() {
+               List<CPElement> cPaths = new ArrayList<CPElement>();
+               List<CPElementGroup> groups = fIncludeSymPathsList.getElements();
+               for (int i = 0; i < groups.size(); i++) {
+                       CPElementGroup group = groups.get(i);
+                       CPElement[] elements = group.getChildren();
+                       for (CPElement element : elements) {
+                               if (element.getInherited() == null) {
+                                       cPaths.add(element);
+                               }
+                       }
+               }
+               return cPaths;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryPerFilePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeSymbolEntryPerFilePage.java
new file mode 100644 (file)
index 0000000..6a441c6
--- /dev/null
@@ -0,0 +1,1189 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+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.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.CoreModelUtil;
+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.IContainerEntry;
+import org.eclipse.cdt.core.model.IIncludeEntry;
+import org.eclipse.cdt.core.model.IMacroEntry;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CElementContentProvider;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
+import org.eclipse.cdt.internal.ui.dialogs.TypedElementSelectionValidator;
+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.ITreeListAdapter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
+
+/**
+ * DialogPage for C/C++ Project Paths page for 3.X projects.
+ * 
+ * @deprecated as of CDT 4.0. This page was used for property pages
+ * for 3.X style projects.
+ */
+@Deprecated
+public class CPathIncludeSymbolEntryPerFilePage extends CPathIncludeSymbolEntryBasePage {
+
+    private TreeListDialogField<CPElementGroup> fIncludeSymPathsList;
+    private SelectionButtonDialogField fShowInheritedPaths;
+    private ICElement fCurrCElement;
+    private ICProject fCurrCProject;
+    private CPElementFilter fFilter;
+    private IStatusChangeListener fContext;
+    private int fTreeExpansionLevel = 2;
+
+    private final int IDX_ADD_FOLDER_FILE = 0;
+    private final int IDX_ADD_SYMBOL = 2;
+    private final int IDX_ADD_EXT_INCLUDE = 4;
+    private final int IDX_ADD_WS_INCLUDE = 5;
+    private final int IDX_ADD_CONTRIBUTED = 7;
+    private final int IDX_EDIT = 9;
+    private final int IDX_REMOVE = 10;
+    private final int IDX_EXPORT = 12;
+    private final int IDX_UP = 14;
+    private final int IDX_DOWN = 15;
+
+    private static final String[] buttonLabel = new String[]{
+
+               CPathEntryMessages.IncludeSymbolEntryPage_addFolderFile, 
+            null,
+            CPathEntryMessages.IncludeSymbolEntryPage_addUserSymbol, 
+            null,
+            CPathEntryMessages.IncludeSymbolEntryPage_addExternalInclude, 
+            CPathEntryMessages.IncludeSymbolEntryPage_addFromWorkspace, 
+            null,
+            CPathEntryMessages.IncludeSymbolEntryPage_addContributed, 
+            null,
+            CPathEntryMessages.IncludeSymbolEntryPage_edit, 
+            CPathEntryMessages.IncludeSymbolEntryPage_remove, 
+            null,
+            CPathEntryMessages.IncludeSymbolEntryPage_export, 
+            null,
+            CPathEntryMessages.IncludeSymbolEntryPage_up, 
+            CPathEntryMessages.IncludeSymbolEntryPage_down}; 
+    private CPElementGroup fTopGroup;
+
+    /**
+     * Per file specific CPElementFilter
+     * 
+     * @author vhirsl
+     */
+    private class CPElementPerFileFilter extends CPElementFilter {
+
+        public CPElementPerFileFilter(int[] kind, boolean exportedOnly, boolean showInherited) {
+            super(kind, exportedOnly, showInherited);
+        }
+
+        /* (non-Javadoc)
+         * @see org.eclipse.cdt.internal.ui.dialogs.cpaths.CPElementFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+         */
+        @Override
+               public boolean select(Viewer viewer, Object parent, Object element) {
+            IResource res = null;
+            if (element instanceof CPElement) {
+                CPElement cpElem = (CPElement) element;
+                res = cpElem.getResource();
+            } else if (element instanceof CPElementGroup) {
+                CPElementGroup cpElemGroup = (CPElementGroup) element;
+                res = cpElemGroup.getResource();
+            }
+            if (res != null && !res.equals(fCurrCElement.getResource())) {
+                IPath currResPath = fCurrCElement.getResource().getFullPath();
+                IPath resPath = res.getFullPath();
+                boolean found = false;
+                for (int i = currResPath.segmentCount() - 1; i >= 0; --i) {
+                    if (resPath.equals(currResPath.uptoSegment(i))) {
+                        found = true;
+                        break;
+                    }
+                }
+                if (found == false) 
+                    return false;
+            }
+            return super.select(viewer, parent, element);
+        }
+
+    }
+
+    private class IncludeSymbolAdapter implements IDialogFieldListener, ITreeListAdapter<CPElementGroup> {
+
+        private final Object[] EMPTY_ARR = new Object[0];
+
+        // -------- IListAdapter --------
+        public void customButtonPressed(TreeListDialogField<CPElementGroup> field, int index) {
+            listCustomButtonPressed(field, index);
+        }
+
+        public void selectionChanged(TreeListDialogField<CPElementGroup> field) {
+            listPageSelectionChanged(field);
+        }
+
+        public void doubleClicked(TreeListDialogField<CPElementGroup> field) {
+            listPageDoubleClicked(field);
+        }
+
+        public void keyPressed(TreeListDialogField<CPElementGroup> field, KeyEvent event) {
+            listPageKeyPressed(field, event);
+        }
+
+        public Object[] getChildren(TreeListDialogField<CPElementGroup> field, Object element) {
+            if (element instanceof CPElement) {
+                return ((CPElement)element).getChildren();
+            } else if (element instanceof CPElementGroup) {
+                return ((CPElementGroup)element).getChildren();
+            }
+            return EMPTY_ARR;
+        }
+
+        public Object getParent(TreeListDialogField<CPElementGroup> field, Object element) {
+            if (element instanceof CPElementGroup) {
+                return ((CPElementGroup)element).getParent();
+            } else if (element instanceof CPElement) {
+                return ((CPElement)element).getParent();
+            }
+            return null;
+        }
+
+        public boolean hasChildren(TreeListDialogField<CPElementGroup> field, Object element) {
+            if (element instanceof CPElementGroup) {
+                return true;
+            }
+            if (element instanceof CPElement) {
+                return ((CPElement)element).getChildren().length > 0;
+            }
+            return false;
+        }
+
+        // ---------- IDialogFieldListener --------
+
+        public void dialogFieldChanged(DialogField field) {
+            listPageDialogFieldChanged(field);
+        }
+
+    }
+
+    public CPathIncludeSymbolEntryPerFilePage(IStatusChangeListener context) {
+        super(CPathEntryMessages.IncludeSymbolEntryPage_title); 
+        fContext = context;
+        IncludeSymbolAdapter adapter = new IncludeSymbolAdapter();
+        fIncludeSymPathsList = new TreeListDialogField<CPElementGroup>(adapter, buttonLabel, new CPElementLabelProvider(true, false)) {
+
+            @Override
+                       protected int getTreeStyle() {
+                return super.getTreeStyle() & ~SWT.MULTI;
+            }
+        };
+        fIncludeSymPathsList.setLabelText(CPathEntryMessages.IncludeSymbolEntryPage_label); 
+        fIncludeSymPathsList.enableButton(IDX_ADD_FOLDER_FILE, false);
+        fIncludeSymPathsList.enableButton(IDX_REMOVE, false);
+        fIncludeSymPathsList.enableButton(IDX_EDIT, false);
+        fIncludeSymPathsList.enableButton(IDX_ADD_CONTRIBUTED, true);
+        fIncludeSymPathsList.enableButton(IDX_ADD_EXT_INCLUDE, true);
+        fIncludeSymPathsList.enableButton(IDX_ADD_WS_INCLUDE, true);
+        fIncludeSymPathsList.enableButton(IDX_ADD_SYMBOL, true);
+        fIncludeSymPathsList.enableButton(IDX_EXPORT, false);
+        fIncludeSymPathsList.enableButton(IDX_UP, false);
+        fIncludeSymPathsList.enableButton(IDX_DOWN, false);
+        fIncludeSymPathsList.setTreeExpansionLevel(fTreeExpansionLevel);
+        fShowInheritedPaths = new SelectionButtonDialogField(SWT.CHECK);
+        fShowInheritedPaths.setSelection(true);
+        fShowInheritedPaths.setLabelText(CPathEntryMessages.IncludeSymbolsEntryPage_show_inherited_check); 
+        fShowInheritedPaths.setDialogFieldListener(adapter);
+
+        fFilter = new CPElementPerFileFilter(new int[]{-1, IPathEntry.CDT_INCLUDE, IPathEntry.CDT_INCLUDE_FILE, 
+                    IPathEntry.CDT_MACRO, IPathEntry.CDT_MACRO_FILE, IPathEntry.CDT_CONTAINER},
+                false, true);
+    }
+
+    @Override
+       public void createControl(Composite parent) {
+        PixelConverter converter = new PixelConverter(parent);
+
+        Composite composite = new Composite(parent, SWT.NONE);
+        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+        LayoutUtil.doDefaultLayout(composite, new DialogField[]{fIncludeSymPathsList, fShowInheritedPaths}, true);
+        LayoutUtil.setHorizontalGrabbing(fIncludeSymPathsList.getTreeControl(null), true);
+
+        int buttonBarWidth = converter.convertWidthInCharsToPixels(24);
+        fIncludeSymPathsList.setButtonsMinWidth(buttonBarWidth);
+        setControl(composite);
+        fIncludeSymPathsList.getTreeViewer().addFilter(fFilter);
+        CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.PROJECT_INCLUDE_PATHS_SYMBOLS);
+    }
+
+    @Override
+       public Image getImage() {
+        return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_CONTAINER);
+    }
+
+    @Override
+       public void init(ICElement cElement, List<CPElement> cPaths) {
+        fCurrCElement = cElement;
+        fCurrCProject = cElement.getCProject();
+        List<CPElementGroup> elements = createGroups(cElement, cPaths);
+        fIncludeSymPathsList.setElements(elements);
+        updateStatus();
+    }
+
+    private void updateStatus() {
+        CPElement entryError = null;
+        int nErrorEntries = 0;
+        IStatus status = Status.OK_STATUS;
+        List<CPElement> elements = getCPaths();
+        for (int i = elements.size() - 1; i >= 0; i--) {
+            CPElement currElement = elements.get(i);
+            if (currElement.getStatus().getSeverity() != IStatus.OK) {
+                nErrorEntries++;
+                if (entryError == null) {
+                    entryError = currElement;
+                }
+            }
+        }
+
+        if (nErrorEntries > 0) {
+            if (nErrorEntries == 1 && entryError != null) {
+                status = entryError.getStatus();
+            } else {
+                status = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, NLS.bind(
+                        CPathEntryMessages.CPElement_status_multiplePathErrors,
+                        String.valueOf(nErrorEntries)), null);
+            }
+        }
+        fContext.statusChanged(status);
+    }
+
+    private void updateStatus(List<?> selected) {
+        if (selected.size() != 1) {
+            updateStatus();
+            return;
+        }
+        CPElement element = null;
+        if (selected.get(0) instanceof CPElement) {
+            element = (CPElement)selected.get(0);
+        } else if (selected.get(0) instanceof CPElementAttribute) {
+            element = ((CPElementAttribute)selected.get(0)).getParent();
+        }
+        if (element != null && element.getStatus().getSeverity() != IStatus.OK) {
+            fContext.statusChanged(element.getStatus());
+        } else {
+            updateStatus();
+            return;
+        }
+    }
+    
+    private List<CPElementGroup> createGroups(ICElement element, List<CPElement> cPaths) {
+        // create resource groups
+        List<CPElementGroup> resourceGroups = new ArrayList<CPElementGroup>(5);
+        fTopGroup = new CPElementGroup(element.getResource());
+        resourceGroups.add(fTopGroup);
+         // add containers first so that they appear at top of list
+        for (int i = 0; i < cPaths.size(); i++) {
+            CPElement cpelement = cPaths.get(i);
+            switch (cpelement.getEntryKind()) {
+                case IPathEntry.CDT_CONTAINER :
+                    fTopGroup.addChild(cpelement);
+                    break;
+            }
+        }
+        for (int i = 0; i < cPaths.size(); i++) {
+            CPElement cpelement = cPaths.get(i);
+            switch (cpelement.getEntryKind()) {
+                case IPathEntry.CDT_INCLUDE :
+                case IPathEntry.CDT_INCLUDE_FILE :
+                case IPathEntry.CDT_MACRO :
+                case IPathEntry.CDT_MACRO_FILE :
+                    CPElementGroup resGroup = new CPElementGroup(cpelement.getResource());
+                    int ndx = resourceGroups.indexOf(resGroup);
+                    if (ndx == -1) {
+                        resourceGroups.add(resGroup);
+                    } else {
+                        resGroup = resourceGroups.get(ndx);
+                    }
+                    resGroup.addChild(cpelement);
+            }
+        }
+
+        // place each path in its appropriate inherited group (or not if
+        // excluded)
+        for (int i = 0; i < cPaths.size(); i++) {
+            CPElement cpelement = cPaths.get(i);
+            switch (cpelement.getEntryKind()) {
+                case IPathEntry.CDT_INCLUDE :
+                case IPathEntry.CDT_INCLUDE_FILE :
+                case IPathEntry.CDT_MACRO :
+                case IPathEntry.CDT_MACRO_FILE :
+                    addPathToResourceGroups(cpelement, null, resourceGroups);
+            }
+        }
+        return resourceGroups;
+    }
+
+    private void addPathToResourceGroup(CPElement element, CPElementGroup parent, CPElementGroup group) {
+        IPath resPath = element.getPath();
+        IPath[] exclusions = (IPath[])element.getAttribute(CPElement.EXCLUSION);
+        if ( (group != parent || !group.getResource().equals(element.getResource()))
+                && resPath.isPrefixOf(group.getPath())
+                && (resPath.equals(group.getPath()) || !CoreModelUtil.isExcludedPath(
+                        group.getResource().getFullPath().removeFirstSegments(resPath.segmentCount()), exclusions))) {
+            if (parent != null) { // try to insert at proper place in group...
+                int insertHere = -1;
+                int ndx = parent.indexof(element);
+                if (ndx != -1) {
+                    CPElement[] children = parent.getChildren(element.getEntryKind());
+                    for (int i = ndx; i < children.length; i++) {
+                        insertHere = group.indexof(new CPElement(children[i], group.getPath(), group.getResource()));
+                        if (insertHere != -1) {
+                            group.addChild(new CPElement(element, group.getPath(), group.getResource()), insertHere);
+                            break;
+                        }
+                    }
+                }
+                if (insertHere == -1) {
+                    group.addChild(new CPElement(element, group.getPath(), group.getResource()));
+                }
+            } else {
+                group.addChild(new CPElement(element, group.getPath(), group.getResource()));
+            }
+        }
+    }
+
+    private void addPathToResourceGroups(CPElement element, CPElementGroup parent, List<CPElementGroup> groups) {
+        if (parent != null) {
+            parent.addChild(element);
+        }
+        for (int i = 0; i < groups.size(); i++) {
+            CPElementGroup group = groups.get(i);
+            addPathToResourceGroup(element, parent, group);
+        }
+    }
+
+    private void updatePathOnResourceGroups(CPElement element, List<CPElementGroup> groups) {
+        CPElementGroup parent = element.getParent();
+        IPath resPath = element.getPath();
+        IPath[] exclusions = (IPath[])element.getAttribute(CPElement.EXCLUSION);
+        for (int i = 0; i < groups.size(); i++) {
+            CPElementGroup group = groups.get(i);
+            if (group != parent) {
+                boolean found = false;
+                CPElement[] elements = group.getChildren(element.getEntryKind());
+                for (CPElement element2 : elements) {
+                    if (element2.getInherited() == element) {
+                        found = true;
+                        if (!CoreModelUtil.isExcludedPath(group.getResource().getFullPath().removeFirstSegments(
+                                resPath.segmentCount()), exclusions)) {
+                            group.replaceChild(element2, new CPElement(element, group.getPath(), group.getResource()));
+                        } else {
+                            group.removeChild(element2);
+                        }
+                        break;
+                    }
+                }
+                if (!found) {
+                    addPathToResourceGroup(element, parent, group);
+                }
+            }
+        }
+    }
+
+    private CPElement removePathFromResourceGroups(CPElement element, List<CPElementGroup> groups) {
+        CPElement Inherited = element.getInherited();
+        CPElementGroup resGroup = element.getParent();
+        resGroup.removeChild(element);
+        if (Inherited != null) { // applied exclusion to orig.
+            IPath exclude = element.getPath().removeFirstSegments(Inherited.getPath().segmentCount());
+            IPath[] exclusions = (IPath[])Inherited.getAttribute(CPElement.EXCLUSION);
+            IPath[] newExlusions = new IPath[exclusions.length + 1];
+            System.arraycopy(exclusions, 0, newExlusions, 0, exclusions.length);
+            newExlusions[exclusions.length] = exclude;
+            Inherited.setAttribute(CPElement.EXCLUSION, newExlusions);
+            return null;
+        }
+        // remove all inherited
+        for (int i = 0; i < groups.size(); i++) {
+            CPElementGroup group = groups.get(i);
+            CPElement elements[] = group.getChildren(element.getEntryKind());
+            for (CPElement element2 : elements) {
+                if (element2.getInherited() == element) {
+                    group.removeChild(element2);
+                    break;
+                }
+            }
+        }
+        return element;
+    }
+
+    private boolean canAddPath(List<?> selected) {
+        CPElementGroup group = getSelectedGroup();
+        if (group != null) {
+            return group.getEntryKind() == -1; // resource group
+        }
+        return false;
+    }
+
+    private boolean canRemove(List<?> selected) {
+        if (selected.size() != 1) {
+            return false;
+        }
+        Object elem = selected.get(0);
+        if (elem instanceof CPElement) {
+            CPElement element = (CPElement)elem;
+            if (element.getParentContainer() == null) {
+                return element.getEntryKind() == IPathEntry.CDT_INCLUDE || element.getEntryKind() == IPathEntry.CDT_MACRO;
+            }
+        } else if (elem instanceof CPElementAttribute) {
+            CPElementAttribute attrib = (CPElementAttribute)elem;
+            if (attrib.getKey().equals(CPElement.EXCLUSION)) {
+                if ( ((IPath[])attrib.getValue()).length > 0) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    private void removeEntry() {
+        List<?> selected = getSelection();
+        Object elem = selected.get(0);
+        if (elem instanceof CPElement) {
+            CPElement element = (CPElement)elem;
+            CPElementGroup parent = element.getParent();
+            if (removePathFromResourceGroups(element, fIncludeSymPathsList.getElements()) == null) {
+                updatePathOnResourceGroups( element.getInherited(), fIncludeSymPathsList.getElements());
+            }
+            fIncludeSymPathsList.refresh();
+            fIncludeSymPathsList.selectElements(new StructuredSelection(parent));
+        } else if (elem instanceof CPElementAttribute) {
+            CPElementAttribute attrib = (CPElementAttribute)elem;
+            String key = attrib.getKey();
+            Object value = key.equals(CPElement.EXCLUSION) ? new Path[0] : null;
+            attrib.getParent().setAttribute(key, value);
+            updatePathOnResourceGroups(attrib.getParent(), fIncludeSymPathsList.getElements());
+            fIncludeSymPathsList.refresh();
+        }
+        updateStatus();
+    }
+
+    private boolean canEdit(List<?> selected) {
+        if (selected.size() != 1) {
+            return false;
+        }
+        Object elem = selected.get(0);
+        if (elem instanceof CPElement) {
+            CPElement element = (CPElement)selected.get(0);
+            if (element.getParentContainer() == null && element.getInherited() == null) {
+                IPath path = (IPath)element.getAttribute(CPElement.BASE_REF);
+                if (path != null && !path.equals(Path.EMPTY)) {
+                    return false;
+                }
+                return element.getEntryKind() == IPathEntry.CDT_INCLUDE || element.getEntryKind() == IPathEntry.CDT_MACRO
+                        || element.getEntryKind() == IPathEntry.CDT_CONTAINER;
+            }
+        }
+        if (elem instanceof CPElementAttribute) {
+            return true;
+        }
+        return false;
+    }
+
+    private void editEntry() {
+        List<?> selElements = fIncludeSymPathsList.getSelectedElements();
+        if (selElements.size() != 1) {
+            return;
+        }
+        Object element = selElements.get(0);
+
+        if (element instanceof CPElement) {
+            editElementEntry((CPElement)element);
+        } else if (element instanceof CPElementAttribute) {
+            editAttributeEntry((CPElementAttribute)element);
+        }
+    }
+
+    private void editElementEntry(CPElement element) {
+        IPath path = (IPath)element.getAttribute(CPElement.BASE_REF);
+        if (path != null && !path.equals(Path.EMPTY)) {
+            return;
+        } else if (element.getEntryKind() == IPathEntry.CDT_MACRO) {
+            addSymbol(element);
+        } else if (element.getEntryKind() == IPathEntry.CDT_INCLUDE) {
+            path = (IPath)element.getAttribute(CPElement.BASE);
+            if (path != null && !path.equals(Path.EMPTY)) {
+                CPElement[] includes = openWorkspacePathEntryDialog(null);
+                if (includes != null && includes.length > 0) {
+                    includes[0].setExported(element.isExported());
+
+                }
+            } else {
+                addInclude(element);
+            }
+        } else if (element.getEntryKind() == IPathEntry.CDT_CONTAINER) {
+            CPElement[] res = null;
+
+            res = openContainerSelectionDialog(element);
+            if (res != null && res.length > 0) {
+                CPElement curr = res[0];
+                curr.setExported(element.isExported());
+                fTopGroup.replaceChild(element, curr);
+                fIncludeSymPathsList.refresh();
+            }
+        }
+    }
+
+    private void editAttributeEntry(CPElementAttribute elem) {
+        String key = elem.getKey();
+        if (key.equals(CPElement.EXCLUSION)) {
+            CPElement selElement = elem.getParent();
+            ExclusionPatternDialog dialog = new ExclusionPatternDialog(getShell(), selElement);
+            if (dialog.open() == Window.OK) {
+                selElement.setAttribute(CPElement.EXCLUSION, dialog.getExclusionPattern());
+                updatePathOnResourceGroups(selElement, fIncludeSymPathsList.getElements());
+                fIncludeSymPathsList.refresh();
+                updateStatus();
+            }
+        }
+    }
+
+    private void exportEntry() {
+        CPElement element = (CPElement)getSelection().get(0);
+        element.setExported(!element.isExported()); // toggle
+        fIncludeSymPathsList.refresh(element);
+    }
+
+    private boolean canExport(List<?> selected) {
+        if (selected.size() != 1) {
+            return false;
+        }
+        Object elem = selected.get(0);
+        if (elem instanceof CPElement) {
+            CPElement element = (CPElement)selected.get(0);
+            if (element.getParentContainer() == null && element.getInherited() == null) {
+                IPath base_ref = (IPath)element.getAttribute(CPElement.BASE_REF);
+                if (base_ref != null && !base_ref.equals(Path.EMPTY))
+                    return false;
+                return element.getEntryKind() == IPathEntry.CDT_INCLUDE || element.getEntryKind() == IPathEntry.CDT_MACRO;
+            }
+        }
+        return false;
+    }
+
+    private boolean canMove(List<?> selected) {
+        if (selected.size() == 0) {
+            return false;
+        }
+        for (int i = 0; i < selected.size(); i++) {
+            Object element = selected.get(i);
+            if (! (element instanceof CPElement))
+                return false;
+            CPElement elem = (CPElement)element;
+            if (elem.getEntryKind() != IPathEntry.CDT_INCLUDE && elem.getEntryKind() != IPathEntry.CDT_MACRO) {
+                return false;
+            }
+            if (elem.getParentContainer() != null || elem.getInherited() != null) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    private boolean canMoveUp(List<?> selected) {
+        if (!canMove(selected)) {
+            return false;
+        }
+        CPElement first = (CPElement)selected.get(0);
+        CPElementGroup parent = first.getParent();
+        CPElement children[] = parent.getChildren(first.getEntryKind());
+        int indx = Arrays.asList(children).indexOf(first);
+        if (indx <= 0) {
+            return false;
+        }
+        return true;
+    }
+
+    private boolean canMoveDown(List<?> selected) {
+        if (!canMove(selected)) {
+            return false;
+        }
+        CPElement last = (CPElement)selected.get(selected.size() - 1);
+        CPElementGroup parent = last.getParent();
+        CPElement children[] = parent.getChildren(last.getEntryKind());
+        int indx = Arrays.asList(children).indexOf(last);
+        if (indx >= children.length - 1 || children[indx + 1].getInherited() != null) {
+            return false;
+        }
+        return true;
+    }
+
+    private boolean moveUp(CPElement element) {
+        boolean rc = false;
+        int kind = element.getEntryKind();
+        for (CPElementGroup group : fIncludeSymPathsList.getElements()) {
+            CPElement[] children = group.getChildren(kind);
+            for (int k = 0; k < children.length; ++k) {
+                CPElement child = children[k];
+                if (element.equals(child) || (child.getInherited() != null && child.getInherited().equals(element))) {
+                    if (child.getInherited() != null && k > 0 && children[k - 1].getInherited() == null) {
+                        break;
+                    }
+                    int prevIndex = k - 1;
+                    if (prevIndex >= 0) {
+                        // swap the two
+                        children[k] = children[prevIndex];
+                        children[prevIndex] = child;
+                        rc = true;
+                        break;
+                    }
+                }
+            }
+            group.setChildren(children);
+        }
+        fIncludeSymPathsList.refresh();
+        fIncludeSymPathsList.selectElements(new StructuredSelection(element));
+        fIncludeSymPathsList.setFocus();
+        return rc;
+    }
+
+    /**
+     *  
+     */
+    private boolean moveDown(CPElement element) {
+        boolean rc = false;
+        int kind = element.getEntryKind();
+        for (CPElementGroup group : fIncludeSymPathsList.getElements()) {
+            CPElement[] children = group.getChildren(kind);
+            for (int k = children.length - 1; k >= 0; --k) {
+                CPElement child = children[k];
+                if (element.equals(child) || (child.getInherited() != null && child.getInherited().equals(element))) {
+                    int prevIndex = k + 1;
+                    if (prevIndex < children.length) {
+                        // swap the two
+                        children[k] = children[prevIndex];
+                        children[prevIndex] = child;
+                        rc = true;
+                        break;
+                    }
+                }
+            }
+            group.setChildren(children);
+        }
+        fIncludeSymPathsList.refresh();
+        fIncludeSymPathsList.selectElements(new StructuredSelection(element));
+        fIncludeSymPathsList.setFocus();
+        return rc;
+    }
+
+    private CPElementGroup getSelectedGroup() {
+        List<?> selected = fIncludeSymPathsList.getSelectedElements();
+        if (!selected.isEmpty()) {
+            Object item = selected.get(0);
+            if (item instanceof CPElement) {
+                item = ((CPElement)item).getParent();
+            }
+            if (item instanceof CPElementGroup) {
+                return (CPElementGroup)item;
+            }
+        }
+        return fTopGroup;
+    }
+
+    protected void listPageDialogFieldChanged(DialogField field) {
+        boolean showInherited = fShowInheritedPaths.isSelected();
+        if (field == fShowInheritedPaths) {
+            if (fFilter != null) {
+                fIncludeSymPathsList.getTreeViewer().removeFilter(fFilter);
+            }
+            fFilter = new CPElementPerFileFilter(new int[]{-1, IPathEntry.CDT_INCLUDE, IPathEntry.CDT_INCLUDE_FILE,
+                        IPathEntry.CDT_MACRO, IPathEntry.CDT_MACRO_FILE, IPathEntry.CDT_CONTAINER},
+                    false, showInherited); 
+            fIncludeSymPathsList.getTreeViewer().addFilter(fFilter);
+            fIncludeSymPathsList.setTreeExpansionLevel(fTreeExpansionLevel);
+            fIncludeSymPathsList.refresh();
+        }
+        updateStatus();
+    }
+
+    protected void listPageSelectionChanged(TreeListDialogField<CPElementGroup> field) {
+        List<?> selected = field.getSelectedElements();
+        field.enableButton(IDX_REMOVE, canRemove(selected));
+        field.enableButton(IDX_EDIT, canEdit(selected));
+        field.enableButton(IDX_ADD_CONTRIBUTED, canAddPath(selected));
+        field.enableButton(IDX_ADD_EXT_INCLUDE, canAddPath(selected));
+        field.enableButton(IDX_ADD_WS_INCLUDE, canAddPath(selected));
+        field.enableButton(IDX_ADD_SYMBOL, canAddPath(selected));
+        field.enableButton(IDX_EXPORT, canExport(selected));
+        field.enableButton(IDX_DOWN, canMoveDown(selected));
+        field.enableButton(IDX_UP, canMoveUp(selected));
+        updateStatus(selected);
+    }
+
+    protected void listCustomButtonPressed(TreeListDialogField<CPElementGroup> field, int index) {
+        switch (index) {
+            case IDX_ADD_FOLDER_FILE :
+                addNewPathResource();
+                break;
+            case IDX_ADD_SYMBOL :
+                addSymbol(null);
+                break;
+            case IDX_ADD_EXT_INCLUDE :
+                addInclude(null);
+                break;
+            case IDX_ADD_WS_INCLUDE :
+                addFromWorkspace();
+                break;
+            case IDX_ADD_CONTRIBUTED :
+                addContributed();
+                break;
+            case IDX_EDIT :
+                if (canEdit(field.getSelectedElements())) {
+                    editEntry();
+                }
+                break;
+            case IDX_REMOVE :
+                if (canRemove(field.getSelectedElements())) {
+                    removeEntry();
+                }
+                break;
+            case IDX_DOWN :
+                if (canMoveDown(field.getSelectedElements())) {
+                    moveDown((CPElement)field.getSelectedElements().get(0));
+                }
+                break;
+            case IDX_UP :
+                if (canMoveUp(field.getSelectedElements())) {
+                    moveUp((CPElement)field.getSelectedElements().get(0));
+                }
+                break;
+            case IDX_EXPORT :
+                if (canExport(field.getSelectedElements())) {
+                    exportEntry();
+                }
+
+        }
+    }
+
+    protected void listPageDoubleClicked(TreeListDialogField<CPElementGroup> field) {
+        if (canEdit(fIncludeSymPathsList.getSelectedElements())) {
+            editEntry();
+        }
+    }
+
+    protected void listPageKeyPressed(TreeListDialogField<CPElementGroup> field, KeyEvent event) {
+        if (field == fIncludeSymPathsList) {
+            if (event.character == SWT.DEL && event.stateMask == 0) {
+                List<?> selection = field.getSelectedElements();
+                if (canEdit(selection)) {
+                    removeEntry();
+                }
+            }
+        }
+    }
+
+    protected IPathEntry[] getRawPathEntries() {
+        List<CPElement> paths = getCPaths();
+        IPathEntry[] currEntries = new IPathEntry[paths.size()];
+        for (int i = 0; i < currEntries.length; i++) {
+            CPElement curr = paths.get(i);
+            currEntries[i] = curr.getPathEntry();
+        }
+        return currEntries;
+    }
+
+    protected void addNewPathResource() {
+        Class<?>[] acceptedClasses = new Class[]{ICProject.class, ICContainer.class, ITranslationUnit.class};
+        TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses, false);
+        ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
+
+        String title = CPathEntryMessages.IncludeSymbolEntryPage_newResource_title; 
+        String message = CPathEntryMessages.IncludeSymbolEntryPage_newResource_description; 
+
+        ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(),
+                new CElementContentProvider());
+        dialog.setValidator(validator);
+        dialog.setTitle(title);
+        dialog.setMessage(message);
+        dialog.addFilter(filter);
+        dialog.setInput(fCurrCProject);
+        dialog.setInitialSelection(fCurrCProject);
+
+        if (dialog.open() == Window.OK) {
+            Object[] elements = dialog.getResult();
+            IResource resource;
+            if (elements[0] instanceof IResource) {
+                resource = (IResource)elements[0];
+            } else {
+                resource = ((ICElement)elements[0]).getResource();
+            }
+            CPElementGroup newGroup = new CPElementGroup(resource);
+            if (!fIncludeSymPathsList.getElements().contains(newGroup)) {
+                List<CPElementGroup> groups = fIncludeSymPathsList.getElements();
+                for (int i = 0; i < groups.size(); i++) {
+                    CPElementGroup group = groups.get(i);
+                    if (group.getPath().isPrefixOf(newGroup.getPath())) {
+                        CPElement[] cpelements = group.getChildren();
+                        for (CPElement cpelement : cpelements) {
+                            if (cpelement.getInherited() == null) {
+                                switch (cpelement.getEntryKind()) {
+                                    case IPathEntry.CDT_INCLUDE :
+                                    case IPathEntry.CDT_INCLUDE_FILE :
+                                    case IPathEntry.CDT_MACRO :
+                                    case IPathEntry.CDT_MACRO_FILE :
+                                        addPathToResourceGroup(cpelement, null, newGroup);
+                                }
+                            }
+                        }
+                    }
+                }
+                fIncludeSymPathsList.addElement(newGroup);
+            }
+            fIncludeSymPathsList.selectElements(new StructuredSelection(newGroup));
+            fIncludeSymPathsList.expandElement(newGroup, 1);
+        }
+    }
+
+    protected void addSymbol(CPElement existing) {
+        // Popup an entry dialog
+        InputDialog dialog;
+        if (existing == null) {
+            dialog = new InputDialog(getShell(), CPathEntryMessages.IncludeSymbolEntryPage_addSymbol_title, 
+                    CPathEntryMessages.IncludeSymbolEntryPage_addSymbol_message, "",  //$NON-NLS-1$
+                    null);
+        } else {
+            StringBuffer initialValue = new StringBuffer();
+            initialValue.append((String)existing.getAttribute(CPElement.MACRO_NAME));
+            initialValue.append('=');
+            initialValue.append((String)existing.getAttribute(CPElement.MACRO_VALUE));
+            dialog = new InputDialog(getShell(), CPathEntryMessages.IncludeSymbolEntryPage_editSymbol_title, 
+                    CPathEntryMessages.IncludeSymbolEntryPage_editSymbol_message, initialValue.toString(), 
+                    null);
+        }
+
+        String symbol = null;
+        if (dialog.open() == Window.OK) {
+            symbol = dialog.getValue();
+            if (symbol != null && symbol.length() > 0) {
+                CPElementGroup group = getSelectedGroup();
+                CPElement newPath = new CPElement(fCurrCProject, IPathEntry.CDT_MACRO, group.getResource().getFullPath(),
+                        group.getResource());
+                String name, value = ""; //$NON-NLS-1$
+                int index = symbol.indexOf("="); //$NON-NLS-1$
+                if (index != -1) {
+                    name = symbol.substring(0, index).trim();
+                    value = symbol.substring(index + 1).trim();
+                } else {
+                    name = symbol.trim();
+                }
+                if (existing != null) {
+                    existing.setAttribute(CPElement.MACRO_NAME, name);
+                    existing.setAttribute(CPElement.MACRO_VALUE, value);
+                    updatePathOnResourceGroups(existing, fIncludeSymPathsList.getElements());
+                    fIncludeSymPathsList.refresh();
+                } else {
+                    newPath.setAttribute(CPElement.MACRO_NAME, name);
+                    newPath.setAttribute(CPElement.MACRO_VALUE, value);
+                    if (!group.contains(newPath)) {
+                        addPathToResourceGroups(newPath, group, fIncludeSymPathsList.getElements());
+                        fIncludeSymPathsList.refresh();
+                        fIncludeSymPathsList.selectElements(new StructuredSelection(newPath));
+                    }
+                    updateStatus();
+                }
+            }
+        }
+    }
+
+    protected void addInclude(CPElement existing) {
+        InputDialog dialog;
+        if (existing == null) {
+            dialog = new SelectPathInputDialog(getShell(),
+                    CPathEntryMessages.IncludeSymbolEntryPage_addExternal_title, 
+                    CPathEntryMessages.IncludeSymbolEntryPage_addExternal_message, null, null); 
+        } else {
+            dialog = new SelectPathInputDialog(
+                    getShell(),
+                    CPathEntryMessages.IncludeSymbolEntryPage_editExternal_title, 
+                    CPathEntryMessages.IncludeSymbolEntryPage_editExternal_message, ((IPath)existing.getAttribute(CPElement.INCLUDE)).toOSString(), null); 
+        }
+        String newItem = null;
+        if (dialog.open() == Window.OK) {
+            newItem = dialog.getValue();
+            if (newItem != null && !newItem.equals("")) { //$NON-NLS-1$
+                if (existing == null) {
+                    CPElementGroup group = getSelectedGroup();
+                    CPElement newPath = new CPElement(fCurrCProject, IPathEntry.CDT_INCLUDE, group.getResource().getFullPath(),
+                            group.getResource());
+                    newPath.setAttribute(CPElement.INCLUDE, new Path(newItem));
+                    if (!group.contains(newPath)) {
+                        addPathToResourceGroups(newPath, group, fIncludeSymPathsList.getElements());
+                        fIncludeSymPathsList.refresh();
+                        fIncludeSymPathsList.selectElements(new StructuredSelection(newPath));
+                    }
+                } else {
+                    existing.setAttribute(CPElement.INCLUDE, new Path(newItem));
+                    updatePathOnResourceGroups(existing, fIncludeSymPathsList.getElements());
+                    fIncludeSymPathsList.refresh();
+                }
+                updateStatus();
+            }
+        }
+    }
+
+    protected void addFromWorkspace() {
+        CPElement[] includes = openWorkspacePathEntryDialog(null);
+        if (includes != null && includes.length > 0) {
+            int nElementsChosen = includes.length;
+            CPElementGroup group = getSelectedGroup();
+            for (int i = 0; i < nElementsChosen; i++) {
+                CPElement curr = includes[i];
+                if (!group.contains(curr)) {
+                    addPathToResourceGroups(curr, group, fIncludeSymPathsList.getElements());
+                    fIncludeSymPathsList.refresh();
+                    fIncludeSymPathsList.selectElements(new StructuredSelection(curr));
+                    updateStatus();
+                }
+            }
+        }
+
+    }
+
+    protected void addContributed() {
+        CPElement[] includes = openContainerSelectionDialog(null);
+        if (includes != null && includes.length > 0) {
+            int nElementsChosen = includes.length;
+            // remove duplicates
+            CPElementGroup group = getSelectedGroup();
+            for (int i = 0; i < nElementsChosen; i++) {
+                CPElement curr = includes[i];
+                if (!group.contains(curr)) {
+                    addPathToResourceGroups(curr, getSelectedGroup(), fIncludeSymPathsList.getElements());
+                    fIncludeSymPathsList.refresh();
+                    fIncludeSymPathsList.selectElements(new StructuredSelection(curr));
+                    updateStatus();
+                }
+            }
+        }
+    }
+
+    protected CPElement[] openWorkspacePathEntryDialog(CPElement existing) {
+        Class<?>[] acceptedClasses = new Class[]{ICProject.class, IProject.class, IContainer.class, ICContainer.class};
+        TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses, existing == null);
+        ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
+
+        String title = (existing == null) ? CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_new_title
+                : CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_edit_title; 
+        String message = (existing == null)
+                ? CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_new_description
+                : CPathEntryMessages.IncludeSymbolEntryPage_fromWorkspaceDialog_edit_description; 
+
+        ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(),
+                new CElementContentProvider());
+        dialog.setValidator(validator);
+        dialog.setTitle(title);
+        dialog.setMessage(message);
+        dialog.addFilter(filter);
+        dialog.setInput(CoreModel.getDefault().getCModel());
+        if (existing == null) {
+            dialog.setInitialSelection(fCurrCProject);
+        } else {
+            dialog.setInitialSelection(existing.getCProject());
+        }
+
+        if (dialog.open() == Window.OK) {
+            Object[] elements = dialog.getResult();
+            CPElement[] res = new CPElement[elements.length];
+            for (int i = 0; i < res.length; i++) {
+                IProject project;
+                IPath includePath;
+                if (elements[i] instanceof IResource) {
+                    project = ((IResource)elements[i]).getProject();
+                    includePath = ((IResource)elements[i]).getProjectRelativePath();
+                } else {
+                    project = ((ICElement)elements[i]).getCProject().getProject();
+                    includePath = ((ICElement)elements[i]).getResource().getProjectRelativePath();
+                }
+                CPElementGroup group = getSelectedGroup();
+                res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_INCLUDE, group.getResource().getFullPath(),
+                        group.getResource());
+                res[i].setAttribute(CPElement.BASE, project.getFullPath().makeRelative());
+                res[i].setAttribute(CPElement.INCLUDE, includePath);
+            }
+            return res;
+        }
+        return null;
+    }
+
+    protected CPElement[] openContainerSelectionDialog(CPElement existing) {
+        IContainerEntry elem = null;
+        String title;
+        if (existing == null) {
+            title = CPathEntryMessages.IncludeSymbolEntryPage_ContainerDialog_new_title; 
+        } else {
+            title = CPathEntryMessages.IncludeSymbolEntryPage_ContainerDialog_edit_title; 
+            elem = (IContainerEntry)existing.getPathEntry();
+        }
+        CPathContainerWizard wizard = new CPathContainerWizard(elem, null, fCurrCProject, getRawPathEntries(), new int[]{
+                IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO});
+        wizard.setWindowTitle(title);
+        if (CPathContainerWizard.openWizard(getShell(), wizard) == Window.OK) {
+            IPathEntry parent = wizard.getEntriesParent();
+            IPathEntry[] elements = wizard.getEntries();
+
+            if (elements != null) {
+                CPElement[] res = new CPElement[elements.length];
+                CPElementGroup group = getSelectedGroup();
+                for (int i = 0; i < res.length; i++) {
+                    if (elements[i].getEntryKind() == IPathEntry.CDT_INCLUDE) {
+                        res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_INCLUDE, group.getResource().getFullPath(),
+                                group.getResource());
+                        res[i].setAttribute(CPElement.INCLUDE, ((IIncludeEntry)elements[i]).getIncludePath());
+                        res[i].setAttribute(CPElement.BASE_REF, parent.getPath());
+                    } else if (elements[i].getEntryKind() == IPathEntry.CDT_MACRO) {
+                        res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_MACRO, group.getResource().getFullPath(),
+                                group.getResource());
+                        res[i].setAttribute(CPElement.MACRO_NAME, ((IMacroEntry)elements[i]).getMacroName());
+                        res[i].setAttribute(CPElement.BASE_REF, parent.getPath());
+                    }
+                }
+                return res;
+            }
+            return new CPElement[]{CPElement.createFromExisting(parent, fCurrCProject)};
+        }
+        return null;
+    }
+
+    private class SelectPathInputDialog extends InputDialog {
+
+        public SelectPathInputDialog(Shell parentShell, String dialogTitle, String dialogMessage, String initialValue,
+                IInputValidator validator) {
+            super(parentShell, dialogTitle, dialogMessage, initialValue, validator);
+        }
+
+        @Override
+               protected void createButtonsForButtonBar(Composite parent) {
+            super.createButtonsForButtonBar(parent);
+            Button browse = createButton(parent, 3,
+                    CPathEntryMessages.IncludeSymbolEntryPage_addExternal_button_browse, 
+                    false);
+            browse.addSelectionListener(new SelectionAdapter() {
+
+                @Override
+                               public void widgetSelected(SelectionEvent ev) {
+                    DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.OPEN);
+                    dialog.setText(CPathEntryMessages.IncludeSymbolEntryPage_browseForFolder); 
+                    String currentName = getText().getText();
+                    if (currentName != null && currentName.trim().length() != 0) {
+                        dialog.setFilterPath(currentName);
+                    }
+                    String dirname = dialog.open();
+                    if (dirname != null) {
+                        getText().setText(dirname);
+                    }
+                }
+            });
+        }
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.cdt.internal.ui.dialogs.cpaths.CPathBasePage#getSelection()
+     */
+    @Override
+       public List<?> getSelection() {
+        return fIncludeSymPathsList.getSelectedElements();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.cdt.internal.ui.dialogs.cpaths.CPathBasePage#setSelection(java.util.List)
+     */
+    @Override
+       public void setSelection(List<?> selElements) {
+        fIncludeSymPathsList.selectElements(new StructuredSelection(selElements));
+    }
+
+    @Override
+       public boolean isEntryKind(int kind) {
+        return kind == IPathEntry.CDT_INCLUDE || kind == IPathEntry.CDT_MACRO;
+    }
+
+    @Override
+       public void performApply(IProgressMonitor monitor) throws CoreException {
+    }
+
+    @Override
+       public void performDefaults() {
+    }
+
+    @Override
+       public List<CPElement> getCPaths() {
+        List<CPElement> cPaths = new ArrayList<CPElement>();
+        List<CPElementGroup> groups = fIncludeSymPathsList.getElements();
+        for (int i = 0; i < groups.size(); i++) {
+            CPElementGroup group = groups.get(i);
+            CPElement[] elements = group.getChildren();
+            for (CPElement element : elements) {
+                if (element.getInherited() == null) {
+                    cPaths.add(element);
+                }
+            }
+        }
+        return cPaths;
+    }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathLibraryEntryPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathLibraryEntryPage.java
new file mode 100644 (file)
index 0000000..3ce9f80
--- /dev/null
@@ -0,0 +1,560 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ * Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.eclipse.ui.views.navigator.ResourceComparator;
+
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IContainerEntry;
+import org.eclipse.cdt.core.model.ILibraryEntry;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.dialogs.TypedElementSelectionValidator;
+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.ITreeListAdapter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
+
+/**
+ * Libraries tab for C/C++ Project Paths page for 3.X projects.
+ * 
+ * @deprecated as of CDT 4.0. This tab was used to set preferences/properties
+ * for 3.X style projects.
+ */
+@Deprecated
+public class CPathLibraryEntryPage extends CPathBasePage {
+       private ListDialogField<CPElement> fCPathList;
+       private ICProject fCurrCProject;
+       private IPath fProjPath;
+       private TreeListDialogField<CPElement> fLibrariesList;
+
+       private IWorkspaceRoot fWorkspaceRoot;
+
+       private final int IDX_ADD_LIBEXT = 0;
+       private final int IDX_ADD_LIB = 1;
+       private final int IDX_ADD_CONTRIBUTED = 2;
+       private final int IDX_EDIT = 4;
+       private final int IDX_REMOVE = 5;
+       private final int IDX_EXPORT = 7;
+
+       public CPathLibraryEntryPage(ListDialogField<CPElement> cPathList) {
+               super(CPathEntryMessages.LibrariesEntryPage_title); 
+               setDescription(CPathEntryMessages.LibrariesEntryPage_description); 
+
+               fWorkspaceRoot = CUIPlugin.getWorkspace().getRoot();
+               fCPathList = cPathList;
+
+               LibrariesAdapter adapter = new LibrariesAdapter();
+
+               String[] buttonLabels= new String[] { 
+                       CPathEntryMessages.LibrariesEntryPage_libraries_addextlib_button, 
+                       CPathEntryMessages.LibrariesEntryPage_libraries_addworkspacelib_button, 
+                       CPathEntryMessages.LibrariesEntryPage_libraries_addcontriblib_button, 
+                       /* */ null,  
+                       CPathEntryMessages.LibrariesEntryPage_libraries_edit_button, 
+                       CPathEntryMessages.LibrariesEntryPage_libraries_remove_button, 
+                       null,
+                       CPathEntryMessages.LibrariesEntryPage_libraries_export_button
+               };              
+
+               fLibrariesList = new TreeListDialogField<CPElement>(adapter, buttonLabels, new CPElementLabelProvider());
+               fLibrariesList.setDialogFieldListener(adapter);
+               fLibrariesList.setLabelText(CPathEntryMessages.LibrariesEntryPage_libraries_label); 
+
+               fLibrariesList.setViewerComparator(new CPElementSorter());
+               fLibrariesList.enableButton(IDX_EDIT, false);
+               fLibrariesList.enableButton(IDX_REMOVE, false);
+               fLibrariesList.enableButton(IDX_EXPORT, false);
+               fLibrariesList.setTreeExpansionLevel(2);
+       }
+
+       @Override
+       public Image getImage() {
+               return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_ARCHIVE);
+       }
+
+       public void init(ICProject cproject) {
+               fCurrCProject = cproject;
+               fProjPath = fCurrCProject.getProject().getFullPath();
+               updateLibrariesList();
+       }
+
+       private void updateLibrariesList() {
+               List<CPElement> cpelements = filterList(fCPathList.getElements());
+               fLibrariesList.setElements(cpelements);
+       }               
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.dialogs.cpaths.CPathBasePage#getSelection()
+        */
+       @Override
+       public List<?> getSelection() {
+               return fLibrariesList.getSelectedElements();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.dialogs.cpaths.CPathBasePage#setSelection(java.util.List)
+        */
+       @Override
+       public void setSelection(List<?> selElements) {
+               fLibrariesList.selectElements(new StructuredSelection(selElements));
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.dialogs.cpaths.CPathBasePage#isEntryKind(int)
+        */
+       @Override
+       public boolean isEntryKind(int kind) {
+               return kind == IPathEntry.CDT_LIBRARY;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
+        */
+       @Override
+       public void performApply(IProgressMonitor monitor) throws CoreException {
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
+        */
+       @Override
+       public void performDefaults() {
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       public void createControl(Composite parent) {
+               PixelConverter converter = new PixelConverter(parent);
+               Composite composite = new Composite(parent, SWT.NONE);
+
+               LayoutUtil.doDefaultLayout(composite, new DialogField[] {fLibrariesList}, true);
+               LayoutUtil.setHorizontalGrabbing(fLibrariesList.getTreeControl(null), true);
+
+               int buttonBarWidth = converter.convertWidthInCharsToPixels(24);
+               fLibrariesList.setButtonsMinWidth(buttonBarWidth);
+
+               fLibrariesList.getTreeViewer().setSorter(new CPElementSorter());
+
+               setControl(composite);
+               
+               CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.PROJECT_PATHS_LIBRARIES);
+       }
+
+       private class LibrariesAdapter implements IDialogFieldListener, ITreeListAdapter<CPElement> {
+               private final Object[] EMPTY_ARR= new Object[0];
+               
+               // -------- IListAdapter --------
+               public void customButtonPressed(TreeListDialogField<CPElement> field, int index) {
+                       libraryPageCustomButtonPressed(field, index);
+               }
+               
+               public void selectionChanged(TreeListDialogField<CPElement> field) {
+                       libraryPageSelectionChanged(field);
+               }
+               
+               public void doubleClicked(TreeListDialogField<CPElement> field) {
+                       libraryPageDoubleClicked(field);
+               }
+               
+               public void keyPressed(TreeListDialogField<CPElement> field, KeyEvent event) {
+                       libraryPageKeyPressed(field, event);
+               }
+
+               public Object[] getChildren(TreeListDialogField<CPElement> field, Object element) {
+                       if (element instanceof CPElement) {
+                               return ((CPElement) element).getChildren();
+                       }
+                       return EMPTY_ARR;
+               }
+
+               public Object getParent(TreeListDialogField<CPElement> field, Object element) {
+                       if (element instanceof CPElementAttribute) {
+                               return ((CPElementAttribute) element).getParent();
+                       }
+                       return null;
+               }
+
+               public boolean hasChildren(TreeListDialogField<CPElement> field, Object element) {
+//                     return (element instanceof CPElement);
+                       return false;
+               }               
+                       
+               // ---------- IDialogFieldListener --------
+       
+               public void dialogFieldChanged(DialogField field) {
+               }
+       }
+
+       protected void libraryPageCustomButtonPressed(DialogField field, int index) {
+               CPElement[] libentries= null;
+               switch (index) {
+               case IDX_ADD_LIB: /* add jar */
+                       libentries= openLibFileDialog(null);
+                       break;
+               case IDX_ADD_LIBEXT: /* add external jar */
+                       libentries= openExtLibFileDialog(null);
+                       break;
+               case IDX_ADD_CONTRIBUTED: /* add variable */
+                       libentries= openContainerSelectionDialog(null);
+                       break;
+               case IDX_EDIT: /* edit */
+                       editEntry();
+                       return;
+               case IDX_REMOVE: /* remove */
+                       removeEntry();
+                       return;
+               case IDX_EXPORT :
+                       /* export */
+                       exportEntry();
+                       return;         
+               }
+               
+               if (libentries != null) {
+                       int nElementsChosen= libentries.length;                                 
+                       // remove duplicates
+                       List<CPElement> cplist= fLibrariesList.getElements();
+                       List<CPElement> elementsToAdd= new ArrayList<CPElement>(nElementsChosen);
+                       
+                       for (int i= 0; i < nElementsChosen; i++) {
+                               CPElement curr= libentries[i];
+                               if (!cplist.contains(curr) && !elementsToAdd.contains(curr)) {
+                                       elementsToAdd.add(curr);
+                                       //curr.setAttribute(CPElement.SOURCEATTACHMENT, BuildPathSupport.guessSourceAttachment(curr));
+                               }
+                       }
+                       fLibrariesList.addElements(elementsToAdd);
+                       fCPathList.addElements(elementsToAdd);
+                       if (index == IDX_ADD_LIB) {
+                               fLibrariesList.refresh();
+                       }
+                       fLibrariesList.postSetSelection(new StructuredSelection(libentries));
+               }
+       }
+
+       private boolean canExport(List<?> selElements) {
+               if (selElements.size() == 0) {
+                       return false;
+               }
+               for (int i = 0; i < selElements.size(); i++) {
+                       Object elem = selElements.get(i);
+                       if (elem instanceof CPElement) {
+                               CPElement curr = (CPElement)elem;
+                               if (curr.getParentContainer() != null) {
+                                       return false;
+                               }
+                               IPath base_ref = (IPath)curr.getAttribute(CPElement.BASE_REF);
+                               if (base_ref != null && !base_ref.equals(Path.EMPTY))
+                                       return false;
+
+                       }
+               }
+               return true;
+       }
+
+       private void exportEntry() {
+               List<?> selElements = fLibrariesList.getSelectedElements();
+               if (selElements.size() != 1) {
+                       return;
+               }
+               Object elem = selElements.get(0);
+               if (fLibrariesList.getIndexOfElement(elem) != -1) {
+                       ((CPElement)elem).setExported(!((CPElement)elem).isExported()); // toggle export
+                       fLibrariesList.refresh(elem);
+               }
+       }
+       
+       protected void libraryPageDoubleClicked(TreeListDialogField<CPElement> field) {
+               List<?> selection= fLibrariesList.getSelectedElements();
+               if (canEdit(selection)) {
+                       editEntry();
+               }
+       }
+
+       protected void libraryPageKeyPressed(TreeListDialogField<CPElement> field, KeyEvent event) {
+               if (field == fLibrariesList) {
+                       if (event.character == SWT.DEL && event.stateMask == 0) {
+                               List<?> selection= field.getSelectedElements();
+                               if (canRemove(selection)) {
+                                       removeEntry();
+                               }
+                       }
+               }       
+       }       
+
+       private void removeEntry() {
+               List<?> selElements= fLibrariesList.getSelectedElements();
+               for (int i= selElements.size() - 1; i >= 0 ; i--) {
+                       Object elem= selElements.get(i);
+                       if (elem instanceof CPElementAttribute) {
+                               CPElementAttribute attrib= (CPElementAttribute) elem;
+                               attrib.getParent().setAttribute(attrib.getKey(), null);
+                               selElements.remove(i);                          
+                       }
+               }
+               if (selElements.isEmpty()) {
+                       fLibrariesList.refresh();
+                       fCPathList.dialogFieldChanged(); // validate
+               } else {
+                       fCPathList.removeElements(selElements);
+                       fLibrariesList.removeElements(selElements);
+               }
+       }
+
+       private boolean canRemove(List<?> selElements) {
+               if (selElements.size() == 0) {
+                       return false;
+               }
+               for (int i= 0; i < selElements.size(); i++) {
+                       Object elem= selElements.get(i);
+                       if (elem instanceof CPElementAttribute) {
+                               if (((CPElementAttribute)elem).getValue() == null) {
+                                       return false;
+                               }
+                       } else if (elem instanceof CPElement) {
+                               CPElement curr= (CPElement) elem;
+                               if (curr.getParentContainer() != null) {
+                                       return false;
+                               }
+                       }
+               }
+               return true;
+       }       
+
+       /**
+        * Method editEntry.
+        */
+       private void editEntry() {
+               List<?> selElements= fLibrariesList.getSelectedElements();
+               if (selElements.size() != 1) {
+                       return;
+               }
+               Object elem= selElements.get(0);
+               if (fLibrariesList.getIndexOfElement(elem) != -1) {
+                       editElementEntry((CPElement) elem);
+               } else if (elem instanceof CPElementAttribute) {
+                       editAttributeEntry((CPElementAttribute) elem);
+               }
+       }
+       
+       private void editAttributeEntry(CPElementAttribute elem) {
+               String key= elem.getKey();
+               if (key.equals(CPElement.SOURCEATTACHMENT)) {
+                       CPElement selElement= elem.getParent();
+                       ILibraryEntry libEntry = (ILibraryEntry)selElement.getPathEntry();
+                       SourceAttachmentDialog dialog= new SourceAttachmentDialog(getShell(), libEntry, fCurrCProject, true);
+                       if (dialog.open() == Window.OK) {
+                               selElement.setAttribute(CPElement.SOURCEATTACHMENT, dialog.getSourceAttachmentPath());
+                               fLibrariesList.refresh();
+                               fCPathList.refresh(); // images
+                       }
+               }
+       }
+
+       private void editElementEntry(CPElement elem) {
+               CPElement[] res= null;
+               switch (elem.getEntryKind()) {
+                       case IPathEntry.CDT_LIBRARY:
+                               IPath p = (IPath)elem.getAttribute(CPElement.LIBRARY);
+                               if (p.isAbsolute()) {
+                                       res= openExtLibFileDialog(elem);
+                               } else {
+                                       res= openLibFileDialog(elem);                   
+                               }
+                       break;
+               }
+               if (res != null && res.length > 0) {
+                       CPElement curr= res[0];
+                       curr.setExported(elem.isExported());
+                       fLibrariesList.replaceElement(elem, curr);
+               }                                       
+       }
+
+       protected void libraryPageSelectionChanged(DialogField field) {
+               List<?> selElements= fLibrariesList.getSelectedElements();
+               fLibrariesList.enableButton(IDX_EDIT, canEdit(selElements));
+               fLibrariesList.enableButton(IDX_REMOVE, canRemove(selElements));
+               fLibrariesList.enableButton(IDX_EXPORT, canExport(selElements));
+       }
+
+       private IFile[] getUsedLibFiles(CPElement existing) {
+               List<IResource> res= new ArrayList<IResource>();
+               List<CPElement> cplist= fLibrariesList.getElements();
+               for (int i= 0; i < cplist.size(); i++) {
+                       CPElement elem= cplist.get(i);
+                       if (elem.getEntryKind() == IPathEntry.CDT_LIBRARY && (elem != existing)) {
+                               IResource resource= elem.getResource();
+                               if (resource instanceof IFile) {
+                                       res.add(resource);
+                               }
+                       }
+               }
+               return res.toArray(new IFile[res.size()]);
+       }
+
+       private CPElement newCPLibraryElement(IPath libraryPath) {
+               CPElement element = new CPElement(fCurrCProject, IPathEntry.CDT_LIBRARY, fProjPath, null);
+               element.setAttribute(CPElement.LIBRARY, libraryPath);
+               return element;
+       }
+
+       private CPElement[] openExtLibFileDialog(CPElement existing) {
+               String title= CPathEntryMessages.LibrariesEntryPage_ExtLibDialog_new_title; 
+               
+               FileDialog dialog= new FileDialog(getShell(), existing == null ? SWT.MULTI : SWT.SINGLE);
+               dialog.setText(title);
+               dialog.setFilterExtensions(new String[] {"*.a;*.so;*.dll;*.lib"}); //$NON-NLS-1$
+               //dialog.setFilterPath(lastUsedPath);
+               if (existing != null) {
+                       dialog.setFileName(existing.getPath().lastSegment());
+               }
+               
+               String res= dialog.open();
+               if (res == null) {
+                       return null;
+               }
+               String[] fileNames= dialog.getFileNames();
+               int nChosen= fileNames.length;
+                       
+               IPath filterPath= new Path(dialog.getFilterPath());
+               CPElement[] elems= new CPElement[nChosen];
+               for (int i= 0; i < nChosen; i++) {
+                       IPath path= filterPath.append(fileNames[i]).makeAbsolute();     
+                       elems[i]= newCPLibraryElement(path);
+               }
+               //fDialogSettings.put(IUIConstants.DIALOGSTORE_LASTEXTJAR, filterPath.toOSString());
+               
+               return elems;   
+       }
+
+       private CPElement[] openLibFileDialog(CPElement existing) {
+               Class<?>[] acceptedClasses= new Class[] { IFile.class };
+               TypedElementSelectionValidator validator= new TypedElementSelectionValidator(acceptedClasses, existing == null);
+               ViewerFilter filter= new ArchiveFileFilter(getUsedLibFiles(existing), true);
+               
+               ILabelProvider lp= new WorkbenchLabelProvider();
+               ITreeContentProvider cp= new WorkbenchContentProvider();
+               
+               String title= (existing == null) ? CPathEntryMessages.LibrariesEntryPage_ExtLibDialog_new_title : CPathEntryMessages.LibrariesEntryPage_ExtLibDialog_edit_title; 
+               String message= (existing == null) ? CPathEntryMessages.LibrariesEntryPage_ExtLibDialog_new_description : CPathEntryMessages.LibrariesEntryPage_ExtLibDialog_edit_description; 
+               
+               ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), lp, cp);
+               dialog.setValidator(validator);
+               dialog.setTitle(title);
+               dialog.setMessage(message);
+               dialog.addFilter(filter);
+               dialog.setInput(fWorkspaceRoot);
+               dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
+               if (existing == null) {
+                       dialog.setInitialSelection(fCurrCProject.getProject());         
+               } else {
+                       dialog.setInitialSelection(existing.getResource());
+               }
+               
+               if (dialog.open() == Window.OK) {
+                       Object[] elements= dialog.getResult();
+                       CPElement[] res= new CPElement[elements.length];
+                       for (int i= 0; i < res.length; i++) {
+                               IPath path= ((IResource)elements[i]).getLocation();
+                               res[i]= newCPLibraryElement(path);
+                       }
+                       return res;
+               }
+               return null;
+       }
+
+       protected IPathEntry[] getRawPathEntries() {
+               IPathEntry[] currEntries = new IPathEntry[fCPathList.getSize()];
+               for (int i = 0; i < currEntries.length; i++) {
+                       CPElement curr = fCPathList.getElement(i);
+                       currEntries[i] = curr.getPathEntry();
+               }
+               return currEntries;
+       }
+
+       protected CPElement[] openContainerSelectionDialog(CPElement existing) {
+               IContainerEntry elem = null;
+               String title;
+               if (existing == null) {
+                       title = CPathEntryMessages.LibrariesEntryPage_ContainerDialog_new_title; 
+               } else {
+                       title = CPathEntryMessages.LibrariesEntryPage_ContainerDialog_edit_title; 
+                       elem = (IContainerEntry)existing.getPathEntry();
+               }
+               CPathContainerWizard wizard = new CPathContainerWizard(elem, null, fCurrCProject, getRawPathEntries(),
+                               new int[] {IPathEntry.CDT_LIBRARY});
+               wizard.setWindowTitle(title);
+               if (CPathContainerWizard.openWizard(getShell(), wizard) == Window.OK) {
+                       IPathEntry parent = wizard.getEntriesParent();
+                       IPathEntry[] elements = wizard.getEntries();
+
+                       if (elements != null) {
+                               CPElement[] res = new CPElement[elements.length];
+                               for (int i = 0; i < res.length; i++) {
+                                       res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_LIBRARY, fProjPath, null);
+                                       res[i].setAttribute(CPElement.LIBRARY, ((ILibraryEntry)elements[i]).getLibraryPath());
+                                       res[i].setAttribute(CPElement.BASE_REF, parent.getPath());
+                               }
+                               return res;
+                       }
+               }
+               return null;
+       }
+
+       private boolean canEdit(List<?> selElements) {
+               if (selElements.size() != 1) {
+                       return false;
+               }
+               Object elem= selElements.get(0);
+               if (elem instanceof CPElement) {
+                       CPElement curr= (CPElement) elem;
+                       return !(curr.getResource() instanceof IFolder) && curr.getParentContainer() == null;
+               }
+               if (elem instanceof CPElementAttribute) {
+                       return true;
+               }
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathOrderExportPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathOrderExportPage.java
new file mode 100644 (file)
index 0000000..39ea8d4
--- /dev/null
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+
+import org.eclipse.cdt.ui.CDTSharedImages;
+
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
+
+/**
+ * Export tab for C/C++ Project Paths page for 3.X projects.
+ * 
+ * @deprecated as of CDT 4.0. This tab was used to set preferences/properties
+ * for 3.X style projects.
+ */
+@Deprecated
+public class CPathOrderExportPage extends CPathBasePage {
+
+       private ListDialogField<?> fCPathList;
+       
+       public CPathOrderExportPage(ListDialogField<?> cPathList) {
+               super(CPathEntryMessages.OrderExportsPage_title); 
+               setDescription(CPathEntryMessages.OrderExportsPage_description); 
+               fCPathList = cPathList;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.cdt.ui.dialogs.AbstractCOptionPage#createControl(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       public void createControl(Composite parent) {
+               PixelConverter converter = new PixelConverter(parent);
+
+               Composite composite = new Composite(parent, SWT.NONE);
+               setControl(composite);
+
+               LayoutUtil.doDefaultLayout(composite, new DialogField[]{fCPathList}, true);
+               LayoutUtil.setHorizontalGrabbing(fCPathList.getListControl(null), true);
+
+               int buttonBarWidth = converter.convertWidthInCharsToPixels(24);
+               fCPathList.setButtonsMinWidth(buttonBarWidth);
+       }
+
+       @Override
+       public Image getImage() {
+               return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_ORDER);
+       }
+       /*
+        * @see BuildPathBasePage#getSelection
+        */
+       @Override
+       public List<?> getSelection() {
+               return fCPathList.getSelectedElements();
+       }
+
+       /*
+        * @see BuildPathBasePage#setSelection
+        */
+       @Override
+       public void setSelection(List<?> selElements) {
+               fCPathList.selectElements(new StructuredSelection(selElements));
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathBasePage#isEntryKind(int)
+        */
+       @Override
+       public boolean isEntryKind(int kind) {
+               return true;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.cdt.ui.dialogs.AbstractCOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
+        */
+       @Override
+       public void performApply(IProgressMonitor monitor) throws CoreException {
+
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.cdt.ui.dialogs.AbstractCOptionPage#performDefaults()
+        */
+       @Override
+       public void performDefaults() {
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathOutputEntryPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathOutputEntryPage.java
new file mode 100644 (file)
index 0000000..8ec565c
--- /dev/null
@@ -0,0 +1,574 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.dialogs.NewFolderDialog;
+import org.eclipse.ui.model.BaseWorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+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.ITreeListAdapter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
+
+/**
+ * Output tab for C/C++ Project Paths page for 3.X projects.
+ * 
+ * @deprecated as of CDT 4.0. This tab was used to set preferences/properties
+ * for 3.X style projects.
+ */
+@Deprecated
+public class CPathOutputEntryPage extends CPathBasePage {
+
+       private ListDialogField<CPElement> fCPathList;
+       private ICProject fCurrCProject;
+       private IPath fProjPath;
+
+       private IWorkspaceRoot fWorkspaceRoot;
+
+       private TreeListDialogField<CPElement> fOutputList;
+
+       private final int IDX_ADD = 0;
+       private final int IDX_EDIT = 2;
+       private final int IDX_REMOVE = 3;
+
+       public CPathOutputEntryPage(ListDialogField<CPElement> cPathList) {
+               super(CPathEntryMessages.OutputPathEntryPage_title); 
+               setDescription(CPathEntryMessages.OutputPathEntryPage_description); 
+
+               fWorkspaceRoot = CUIPlugin.getWorkspace().getRoot();
+               fCPathList = cPathList;
+
+               OutputContainerAdapter adapter = new OutputContainerAdapter();
+
+               String[] buttonLabels;
+
+               buttonLabels = new String[]{
+               CPathEntryMessages.OutputPathEntryPage_folders_add_button, 
+                               /* 1 */null, CPathEntryMessages.OutputPathEntryPage_folders_edit_button, 
+                               CPathEntryMessages.OutputPathEntryPage_folders_remove_button
+               };
+
+               fOutputList = new TreeListDialogField<CPElement>(adapter, buttonLabels, new CPElementLabelProvider());
+               fOutputList.setDialogFieldListener(adapter);
+               fOutputList.setLabelText(CPathEntryMessages.OutputPathEntryPage_folders_label); 
+
+               fOutputList.setViewerComparator(new CPElementSorter());
+               fOutputList.enableButton(IDX_EDIT, false);
+               fOutputList.enableButton(IDX_REMOVE, false);
+               fOutputList.setTreeExpansionLevel(2);
+       }
+
+       @Override
+       public Image getImage() {
+               return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_CONTAINER);
+       }
+
+       public void init(ICProject cproject) {
+               fCurrCProject = cproject;
+               fProjPath = fCurrCProject.getProject().getFullPath();
+               updateFoldersList();
+       }
+
+       private void updateFoldersList() {
+
+               List<CPElement> folders = filterList(fCPathList.getElements());
+               fOutputList.setElements(folders);
+
+               for (int i = 0; i < folders.size(); i++) {
+                       CPElement cpe = folders.get(i);
+                       IPath[] patterns = (IPath[])cpe.getAttribute(CPElement.EXCLUSION);
+                       if (patterns.length > 0) {
+                               fOutputList.expandElement(cpe, 3);
+                       }
+               }
+       }
+
+       @Override
+       public void createControl(Composite parent) {
+               PixelConverter converter = new PixelConverter(parent);
+               Composite composite = new Composite(parent, SWT.NONE);
+
+               LayoutUtil.doDefaultLayout(composite, new DialogField[]{fOutputList}, true);
+               LayoutUtil.setHorizontalGrabbing(fOutputList.getTreeControl(null), true);
+
+               int buttonBarWidth = converter.convertWidthInCharsToPixels(24);
+               fOutputList.setButtonsMinWidth(buttonBarWidth);
+
+               // expand
+               List<CPElement> elements = fOutputList.getElements();
+               for (int i = 0; i < elements.size(); i++) {
+                       CPElement elem = elements.get(i);
+                       IPath[] patterns = (IPath[])elem.getAttribute(CPElement.EXCLUSION);
+                       if (patterns.length > 0) {
+                               fOutputList.expandElement(elem, 3);
+                       }
+               }
+               setControl(composite);
+               
+               CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.PROJECT_PATHS_OUTPUT);
+       }
+
+       private class OutputContainerAdapter implements ITreeListAdapter<CPElement>, IDialogFieldListener {
+
+               private final Object[] EMPTY_ARR = new Object[0];
+
+               // -------- IListAdapter --------
+               public void customButtonPressed(TreeListDialogField<CPElement> field, int index) {
+                       outputPageCustomButtonPressed(field, index);
+               }
+
+               public void selectionChanged(TreeListDialogField<CPElement> field) {
+                       outputPageSelectionChanged(field);
+               }
+
+               public void doubleClicked(TreeListDialogField<CPElement> field) {
+                       outputPageDoubleClicked(field);
+               }
+
+               public void keyPressed(TreeListDialogField<CPElement> field, KeyEvent event) {
+                       outputPageKeyPressed(field, event);
+               }
+
+               public Object[] getChildren(TreeListDialogField<CPElement> field, Object element) {
+                       if (element instanceof CPElement) {
+                               return ((CPElement)element).getChildren();
+                       }
+                       return EMPTY_ARR;
+               }
+
+               public Object getParent(TreeListDialogField<CPElement> field, Object element) {
+                       if (element instanceof CPElementAttribute) {
+                               return ((CPElementAttribute)element).getParent();
+                       }
+                       return null;
+               }
+
+               public boolean hasChildren(TreeListDialogField<CPElement> field, Object element) {
+                       return (element instanceof CPElement);
+               }
+
+               // ---------- IDialogFieldListener --------
+               public void dialogFieldChanged(DialogField field) {
+                       outputPageDialogFieldChanged(field);
+               }
+
+       }
+
+       protected void outputPageKeyPressed(TreeListDialogField<CPElement> field, KeyEvent event) {
+               if (field == fOutputList) {
+                       if (event.character == SWT.DEL && event.stateMask == 0) {
+                               List<?> selection = field.getSelectedElements();
+                               if (canRemove(selection)) {
+                                       removeEntry();
+                               }
+                       }
+               }
+       }
+
+       protected void outputPageDoubleClicked(TreeListDialogField<CPElement> field) {
+               if (field == fOutputList) {
+                       List<?> selection = field.getSelectedElements();
+                       if (canEdit(selection)) {
+                               editEntry();
+                       }
+               }
+       }
+
+       private boolean hasFolders(IContainer container) {
+               try {
+                       IResource[] members = container.members();
+                       for (IResource member : members) {
+                               if (member instanceof IContainer) {
+                                       return true;
+                               }
+                       }
+               } catch (CoreException e) {
+                       // ignore
+               }
+               return false;
+       }
+
+       protected void outputPageCustomButtonPressed(DialogField field, int index) {
+               if (field == fOutputList) {
+                       if (index == IDX_ADD) {
+                               List<CPElement> elementsToAdd = new ArrayList<CPElement>(10);
+                               IProject project = fCurrCProject.getProject();
+                               if (project.exists()) {
+                                       if (hasFolders(project)) {
+                                               CPElement[] srcentries = openOutputContainerDialog(null);
+                                               if (srcentries != null) {
+                                                       for (CPElement srcentrie : srcentries) {
+                                                               elementsToAdd.add(srcentrie);
+                                                       }
+                                               }
+                                       } else {
+                                               CPElement entry = openNewOutputContainerDialog(null, true);
+                                               if (entry != null) {
+                                                       elementsToAdd.add(entry);
+                                               }
+                                       }
+                               } else {
+                                       CPElement entry = openNewOutputContainerDialog(null, false);
+                                       if (entry != null) {
+                                               elementsToAdd.add(entry);
+                                       }
+                               }
+                               if (!elementsToAdd.isEmpty()) {
+                                       HashSet<CPElement> modifiedElements = new HashSet<CPElement>();
+                                       askForAddingExclusionPatternsDialog(elementsToAdd, modifiedElements);
+
+                                       fOutputList.addElements(elementsToAdd);
+                                       fOutputList.postSetSelection(new StructuredSelection(elementsToAdd));
+
+                                       if (!modifiedElements.isEmpty()) {
+                                               for (Iterator<CPElement> iter = modifiedElements.iterator(); iter.hasNext();) {
+                                                       Object elem = iter.next();
+                                                       fOutputList.refresh(elem);
+                                                       fOutputList.expandElement(elem, 3);
+                                               }
+                                       }
+
+                               }
+                       } else if (index == IDX_EDIT) {
+                               editEntry();
+                       } else if (index == IDX_REMOVE) {
+                               removeEntry();
+                       }
+               }
+       }
+
+       private void editEntry() {
+               List<?> selElements = fOutputList.getSelectedElements();
+               if (selElements.size() != 1) {
+                       return;
+               }
+               Object elem = selElements.get(0);
+               if (fOutputList.getIndexOfElement(elem) != -1) {
+                       editElementEntry((CPElement)elem);
+               } else if (elem instanceof CPElementAttribute) {
+                       editAttributeEntry((CPElementAttribute)elem);
+               }
+       }
+
+       private void editElementEntry(CPElement elem) {
+               CPElement res = null;
+
+               res = openNewOutputContainerDialog(elem, true);
+
+               if (res != null) {
+                       fOutputList.replaceElement(elem, res);
+               }
+       }
+
+       private void editAttributeEntry(CPElementAttribute elem) {
+               String key = elem.getKey();
+               if (key.equals(CPElement.EXCLUSION)) {
+                       CPElement selElement = elem.getParent();
+                       ExclusionPatternDialog dialog = new ExclusionPatternDialog(getShell(), selElement);
+                       if (dialog.open() == Window.OK) {
+                               selElement.setAttribute(CPElement.EXCLUSION, dialog.getExclusionPattern());
+                               fOutputList.refresh();
+                               fCPathList.dialogFieldChanged(); // validate
+                       }
+               }
+       }
+
+       protected void outputPageSelectionChanged(DialogField field) {
+               List<?> selected = fOutputList.getSelectedElements();
+               fOutputList.enableButton(IDX_EDIT, canEdit(selected));
+               fOutputList.enableButton(IDX_REMOVE, canRemove(selected));
+       }
+
+       private void removeEntry() {
+               List<Object> selElements = fOutputList.getSelectedElements();
+               for (int i = selElements.size() - 1; i >= 0; i--) {
+                       Object elem = selElements.get(i);
+                       if (elem instanceof CPElementAttribute) {
+                               CPElementAttribute attrib = (CPElementAttribute)elem;
+                               String key = attrib.getKey();
+                               Object value = key.equals(CPElement.EXCLUSION) ? new Path[0] : null;
+                               attrib.getParent().setAttribute(key, value);
+                               selElements.remove(i);
+                       }
+               }
+               if (selElements.isEmpty()) {
+                       fOutputList.refresh();
+                       fCPathList.dialogFieldChanged(); // validate
+               } else {
+                       fOutputList.removeElements(selElements);
+               }
+       }
+
+       private boolean canRemove(List<?> selElements) {
+               if (selElements.size() == 0) {
+                       return false;
+               }
+               for (int i = 0; i < selElements.size(); i++) {
+                       Object elem = selElements.get(i);
+                       if (elem instanceof CPElementAttribute) {
+                               CPElementAttribute attrib = (CPElementAttribute)elem;
+                               if (attrib.getKey().equals(CPElement.EXCLUSION)) {
+                                       if ( ((IPath[])attrib.getValue()).length == 0) {
+                                               return false;
+                                       }
+                               } else if (attrib.getValue() == null) {
+                                       return false;
+                               }
+                       } else if (elem instanceof CPElement) {
+                               CPElement curr = (CPElement)elem;
+                               if (curr.getParentContainer() != null) {
+                                       return false;
+                               }
+                       }
+               }
+               return true;
+       }
+
+       private boolean canEdit(List<?> selElements) {
+               if (selElements.size() != 1) {
+                       return false;
+               }
+               Object elem = selElements.get(0);
+               if (elem instanceof CPElement) {
+                       return false;
+               }
+               if (elem instanceof CPElementAttribute) {
+                       return true;
+               }
+               return false;
+       }
+
+       protected void outputPageDialogFieldChanged(DialogField field) {
+               if (fCurrCProject == null) {
+                       // not initialized
+                       return;
+               }
+
+               if (field == fOutputList) {
+                       updateCPathList();
+               }
+       }
+
+       private void updateCPathList() {
+               List<CPElement> srcelements = fOutputList.getElements();
+
+               List<CPElement> cpelements = fCPathList.getElements();
+               int nEntries = cpelements.size();
+               // backwards, as entries will be deleted
+               int lastRemovePos = nEntries;
+               int afterLastSourcePos = 0;
+               for (int i = nEntries - 1; i >= 0; i--) {
+                       CPElement cpe = cpelements.get(i);
+                       int kind = cpe.getEntryKind();
+                       if (isEntryKind(kind)) {
+                               if (!srcelements.remove(cpe)) {
+                                       cpelements.remove(i);
+                                       lastRemovePos = i;
+                               } else if (lastRemovePos == nEntries) {
+                                       afterLastSourcePos = i + 1;
+                               }
+                       }
+               }
+
+               if (!srcelements.isEmpty()) {
+                       int insertPos = Math.min(afterLastSourcePos, lastRemovePos);
+                       cpelements.addAll(insertPos, srcelements);
+               }
+
+               if (lastRemovePos != nEntries || !srcelements.isEmpty()) {
+                       fCPathList.setElements(cpelements);
+               }
+       }
+
+       private CPElement openNewOutputContainerDialog(CPElement existing, boolean includeLinked) {
+               if (includeLinked) {
+                       NewFolderDialog dialog = new NewFolderDialog(getShell(), fCurrCProject.getProject());
+                       if (dialog.open() == Window.OK) {
+                               IResource createdFolder = (IResource)dialog.getResult()[0];
+                               return newCPOutputElement(createdFolder);
+                       }
+                       return null;
+               }
+               String title = (existing == null) ? CPathEntryMessages.SourcePathEntryPage_NewSourceFolderDialog_new_title
+                               : CPathEntryMessages.SourcePathEntryPage_NewSourceFolderDialog_edit_title; 
+               IProject proj = fCurrCProject.getProject();
+               NewSourceFolderDialog dialog = new NewSourceFolderDialog(getShell(), title, proj, getExistingContainers(existing), existing);
+               dialog.setMessage(NLS.bind(CPathEntryMessages.SourcePathEntryPage_NewSourceFolderDialog_description, 
+                               fProjPath.toString()));
+               if (dialog.open() == Window.OK) {
+                       IResource folder = dialog.getSourceFolder();
+                       return newCPOutputElement(folder);
+               }
+               return null;
+       }
+
+       private void askForAddingExclusionPatternsDialog(List<CPElement> newEntries, Set<CPElement> modifiedEntries) {
+               fixNestingConflicts(newEntries, fOutputList.getElements(), modifiedEntries);
+               if (!modifiedEntries.isEmpty()) {
+                       String title = CPathEntryMessages.OutputPathEntryPage_exclusion_added_title; 
+                       String message = CPathEntryMessages.OutputPathEntryPage_exclusion_added_message; 
+                       MessageDialog.openInformation(getShell(), title, message);
+               }
+       }
+
+       private CPElement[] openOutputContainerDialog(CPElement existing) {
+
+               Class<?>[] acceptedClasses = new Class[]{IProject.class, IFolder.class};
+               List<IContainer> existingContainers = getExistingContainers(null);
+
+               IProject[] allProjects = fWorkspaceRoot.getProjects();
+               ArrayList<IProject> rejectedElements = new ArrayList<IProject>(allProjects.length);
+               IProject currProject = fCurrCProject.getProject();
+               for (int i = 0; i < allProjects.length; i++) {
+                       if (!allProjects[i].equals(currProject)) {
+                               rejectedElements.add(allProjects[i]);
+                       }
+               }
+
+               ViewerFilter filter = new TypedViewerFilter(acceptedClasses, rejectedElements.toArray());
+
+               ILabelProvider lp = new WorkbenchLabelProvider();
+               ITreeContentProvider cp = new BaseWorkbenchContentProvider();
+
+               String title = (existing == null)
+                               ? CPathEntryMessages.OutputPathEntryPage_ExistingOutputFolderDialog_new_title
+                               : CPathEntryMessages.OutputPathEntryPage_ExistingOutputFolderDialog_edit_title; 
+               String message = (existing == null)
+                               ? CPathEntryMessages.OutputPathEntryPage_ExistingOutputFolderDialog_new_description
+                               : CPathEntryMessages.OutputPathEntryPage_ExistingOutputFolderDialog_edit_description; 
+
+               MultipleFolderSelectionDialog dialog = new MultipleFolderSelectionDialog(getShell(), lp, cp);
+               dialog.setExisting(existingContainers.toArray());
+               dialog.setTitle(title);
+               dialog.setMessage(message);
+               dialog.addFilter(filter);
+               dialog.setInput(fCurrCProject.getProject().getParent());
+               if (existing == null) {
+                       dialog.setInitialFocus(fCurrCProject.getProject());
+               } else {
+                       dialog.setInitialFocus(existing.getResource());
+               }
+               if (dialog.open() == Window.OK) {
+                       Object[] elements = dialog.getResult();
+                       CPElement[] res = new CPElement[elements.length];
+                       for (int i = 0; i < res.length; i++) {
+                               IResource elem = (IResource)elements[i];
+                               res[i] = newCPOutputElement(elem);
+                       }
+                       return res;
+               }
+               return null;
+       }
+
+       private List<IContainer> getExistingContainers(CPElement existing) {
+               List<IContainer> res = new ArrayList<IContainer>();
+               List<CPElement> cplist = fOutputList.getElements();
+               for (int i = 0; i < cplist.size(); i++) {
+                       CPElement elem = cplist.get(i);
+                       if (elem != existing) {
+                               IResource resource = elem.getResource();
+                               if (resource instanceof IContainer) { // defensive code
+                                       res.add((IContainer) resource);
+                               }
+                       }
+               }
+               return res;
+       }
+
+       private CPElement newCPOutputElement(IResource res) {
+               Assert.isNotNull(res);
+               return new CPElement(fCurrCProject, IPathEntry.CDT_OUTPUT, res.getFullPath(), res);
+       }
+
+       /*
+        * @see BuildPathBasePage#getSelection
+        */
+       @Override
+       public List<Object> getSelection() {
+               return fOutputList.getSelectedElements();
+       }
+
+       /*
+        * @see BuildPathBasePage#setSelection
+        */
+       @Override
+       public void setSelection(List<?> selElements) {
+               fOutputList.selectElements(new StructuredSelection(selElements));
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathBasePage#isEntryKind(int)
+        */
+       @Override
+       public boolean isEntryKind(int kind) {
+               return kind == IPathEntry.CDT_OUTPUT;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
+        */
+       @Override
+       public void performApply(IProgressMonitor monitor) throws CoreException {
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
+        */
+       @Override
+       public void performDefaults() {
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathProjectsEntryPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathProjectsEntryPage.java
new file mode 100644 (file)
index 0000000..f6ea7aa
--- /dev/null
@@ -0,0 +1,218 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.CheckedListDialogField;
+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.ListDialogField;
+
+/**
+ * Projects tab for C/C++ Project Paths page for 3.X projects.
+ * 
+ * @deprecated as of CDT 4.0. This tab was used for property pages
+ * for 3.X style projects.
+ */
+@Deprecated
+public class CPathProjectsEntryPage extends CPathBasePage {
+
+       private CheckedListDialogField<CPElement> fProjectsList;
+       ICProject fCurrCProject;
+       private ListDialogField<CPElement> fCPathList;
+
+       public CPathProjectsEntryPage(ListDialogField<CPElement> cPathList) {
+               super(CPathEntryMessages.ProjectsEntryPage_title); 
+               setDescription(CPathEntryMessages.ProjectsEntryPage_description); 
+               ProjectsListListener listener = new ProjectsListListener();
+
+               String[] buttonLabels = new String[] { CPathEntryMessages.ProjectsEntryPage_projects_checkall_button, 
+               CPathEntryMessages.ProjectsEntryWorkbookPage_projects_uncheckall_button}; 
+
+               fProjectsList = new CheckedListDialogField<CPElement>(null, buttonLabels, new CPElementLabelProvider());
+               fProjectsList.setDialogFieldListener(listener);
+               fProjectsList.setLabelText(CPathEntryMessages.ProjectsEntryPage_projects_label); 
+               fProjectsList.setCheckAllButtonIndex(0);
+               fProjectsList.setUncheckAllButtonIndex(1);
+
+               fProjectsList.setViewerComparator(new CPElementSorter());
+               fCPathList = cPathList;
+       }
+
+       @Override
+       public Image getImage() {
+               return PlatformUI.getWorkbench().getSharedImages().getImage(IDE.SharedImages.IMG_OBJ_PROJECT);
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
+        */
+       @Override
+       public void performApply(IProgressMonitor monitor) throws CoreException {
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
+        */
+       @Override
+       public void performDefaults() {
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       public void createControl(Composite parent) {
+               PixelConverter converter = new PixelConverter(parent);
+
+               Composite composite = new Composite(parent, SWT.NONE);
+
+               setControl(composite);
+
+               LayoutUtil.doDefaultLayout(composite, new DialogField[] { fProjectsList}, true);
+               LayoutUtil.setHorizontalGrabbing(fProjectsList.getListControl(null), true);
+
+               int buttonBarWidth = converter.convertWidthInCharsToPixels(24);
+               fProjectsList.setButtonsMinWidth(buttonBarWidth);
+               
+               CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.PROJECT_PATHS_PROJECTS);
+       }
+
+       private class ProjectsListListener implements IDialogFieldListener {
+
+               // ---------- IDialogFieldListener --------
+
+               public void dialogFieldChanged(DialogField field) {
+                       if (fCurrCProject != null) {
+                               // already initialized
+                               updateCPathList();
+                       }
+               }
+       }
+
+       public void init(ICProject cproject) {
+               updateProjectsList(cproject);
+       }
+
+       void updateProjectsList(ICProject currCProject) {
+               ICModel cmodel = currCProject.getCModel();
+
+               List<CPElement> projects = new ArrayList<CPElement>();
+               final List<CPElement> checkedProjects = new ArrayList<CPElement>();
+               try {
+                       ICProject[] cprojects = cmodel.getCProjects();
+                       
+                       // a vector remembering all projects that dont have to be added anymore
+                       List<IResource> existingProjects = new ArrayList<IResource>(cprojects.length);
+                       existingProjects.add(currCProject.getProject());
+                       
+                       // add the projects-cpentries that are already on the C Path
+                       List<CPElement> cpelements = fCPathList.getElements();
+                       for (int i = cpelements.size() - 1; i >= 0; i--) {
+                               CPElement cpelem = cpelements.get(i);
+                               if (isEntryKind(cpelem.getEntryKind())) {
+                                       existingProjects.add(cpelem.getResource());
+                                       projects.add(cpelem);
+                                       checkedProjects.add(cpelem);
+                               }
+                       }
+                       
+                       for (ICProject cproject : cprojects) {
+                               IProject proj = cproject.getProject();
+                               if (!existingProjects.contains(proj)) {
+                                       projects.add(new CPElement(fCurrCProject, IPathEntry.CDT_PROJECT, proj.getFullPath(), proj));
+                               }
+                       }
+               } catch (CModelException e) {
+                       CUIPlugin.log(e);
+               }
+               fProjectsList.setElements(projects);
+               fProjectsList.setCheckedElements(checkedProjects);
+               fCurrCProject = currCProject;
+       }
+
+       void updateCPathList() {
+               List<CPElement> projelements = fProjectsList.getCheckedElements();
+
+               boolean remove = false;
+               List<CPElement> pelements = fCPathList.getElements();
+               // backwards, as entries will be deleted
+               for (int i = pelements.size() - 1; i >= 0; i--) {
+                       CPElement pe = pelements.get(i);
+                       if (isEntryKind(pe.getEntryKind())) {
+                               if (!projelements.remove(pe)) {
+                                       pelements.remove(i);
+                                       remove = true;
+                               }
+                       }
+               }
+               for (int i = 0; i < projelements.size(); i++) {
+                       pelements.add(projelements.get(i));
+               }
+               if (remove || (projelements.size() > 0)) {
+                       fCPathList.setElements(pelements);
+               }
+       }
+
+       /*
+        * @see BuildPathBasePage#getSelection
+        */
+       @Override
+       public List<CPElement> getSelection() {
+               return fProjectsList.getSelectedElements();
+       }
+
+       /*
+        * @see BuildPathBasePage#setSelection
+        */
+       @Override
+       public void setSelection(List<?> selElements) {
+               fProjectsList.selectElements(new StructuredSelection(selElements));
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathBasePage#isEntryKind(int)
+        */
+       @Override
+       public boolean isEntryKind(int kind) {
+               return kind == IPathEntry.CDT_PROJECT;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathPropertyPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathPropertyPage.java
new file mode 100644 (file)
index 0000000..f04683a
--- /dev/null
@@ -0,0 +1,226 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.cdt.core.CProjectNature;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.resources.IPathEntryStore;
+import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
+import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
+import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+/**
+ * C/C++ Project Paths page for 3.X projects.
+ * 
+ * @deprecated as of CDT 4.0. This property page was used to set properties
+ * "C/C++ Make Project" for 3.X style projects.
+ * This page lives dormant as of writing (CDT 7.0) but may get activated for
+ * {@code org.eclipse.cdt.make.core.makeNature} project (3.X style).
+ */
+@Deprecated
+public class CPathPropertyPage extends PropertyPage implements IStatusChangeListener{
+
+       private static final String PAGE_SETTINGS = "CPathsPropertyPage"; //$NON-NLS-1$
+       private static final String INDEX = "pageIndex"; //$NON-NLS-1$
+
+       CPathTabBlock fCPathsBlock;
+       IPathEntryStore fStore;
+
+       @Override
+       protected Control createContents(Composite parent) {
+               IProject project = getProject();
+               Control result;
+
+               // ensure the page has no special buttons
+               noDefaultAndApplyButton();
+               if (project == null || !isCProject(project)) {
+                       result = createWithoutCProject(parent);
+               } else if (!project.isOpen()) {
+                       result = createForClosedProject(parent);
+               } else {
+                       result = createWithCProject(parent, project);
+               }
+               Dialog.applyDialogFont(result);
+               return result;
+       }
+
+       private IDialogSettings getSettings() {
+               IDialogSettings cSettings = CUIPlugin.getDefault().getDialogSettings();
+               IDialogSettings pageSettings = cSettings.getSection(PAGE_SETTINGS);
+               if (pageSettings == null) {
+                       pageSettings = cSettings.addNewSection(PAGE_SETTINGS);
+                       pageSettings.put(INDEX, 3);
+               }
+               return pageSettings;
+       }
+
+       /*
+        * Content for valid projects.
+        */
+       private Control createWithCProject(Composite parent, IProject project) {
+               fCPathsBlock = new CPathTabBlock(this, getSettings().getInt(INDEX));
+               fCPathsBlock.init(CoreModel.getDefault().create(project), null);
+               return fCPathsBlock.createContents(parent);
+       }
+
+       /*
+        * Content for non-C projects.
+        */
+       private Control createWithoutCProject(Composite parent) {
+               Label label = new Label(parent, SWT.LEFT);
+               label.setText(CPathEntryMessages.CPathsPropertyPage_no_C_project_message); 
+
+               fCPathsBlock = null;
+               setValid(true);
+               return label;
+       }
+
+       /*
+        * Content for closed projects.
+        */
+       private Control createForClosedProject(Composite parent) {
+               Label label = new Label(parent, SWT.LEFT);
+               label.setText(CPathEntryMessages.CPathsPropertyPage_closed_project_message); 
+
+               fCPathsBlock = null;
+               setValid(true);
+               return label;
+       }
+
+       @Override
+       public void setVisible(boolean visible) {
+               if (fCPathsBlock != null) {
+                       if (!visible) {
+                               if (fCPathsBlock.hasChangesInDialog()) {
+                                       String title = CPathEntryMessages.CPathsPropertyPage_unsavedchanges_title; 
+                                       String message = CPathEntryMessages.CPathsPropertyPage_unsavedchanges_message; 
+                                       String[] buttonLabels = new String[]{
+                                                       CPathEntryMessages.CPathsPropertyPage_unsavedchanges_button_save, 
+                                                       CPathEntryMessages.CPathsPropertyPage_unsavedchanges_button_discard, 
+                                       };
+                                       MessageDialog dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION,
+                                                       buttonLabels, 0);
+                                       int res = dialog.open();
+                                       if (res == 0) {
+                                               performOk();
+                                       } else if (res == 1) {
+                                               fCPathsBlock.init(CoreModel.getDefault().create(getProject()), null);
+                                       }
+                               }
+                       } else {
+                               if (!fCPathsBlock.hasChangesInDialog() && fCPathsBlock.hasChangesInCPathFile()) {
+                                       fCPathsBlock.init(CoreModel.getDefault().create(getProject()), null);
+                               }
+                       }
+               }
+               super.setVisible(visible);
+       }
+
+       private IProject getProject() {
+               IAdaptable adaptable = getElement();
+               if (adaptable != null) {
+                       ICElement elem = (ICElement)adaptable.getAdapter(ICElement.class);
+                       if (elem instanceof ICProject) {
+                               return ((ICProject)elem).getProject();
+                       }
+               }
+               return null;
+       }
+
+       private boolean isCProject(IProject proj) {
+               try {
+                       return proj.hasNature(CProjectNature.C_NATURE_ID);
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }
+               return false;
+       }
+
+       /*
+        * @see IPreferencePage#performOk
+        */
+       @Override
+       public boolean performOk() {
+               if (fCPathsBlock != null) {
+                       getSettings().put(INDEX, fCPathsBlock.getPageIndex());
+
+                       Shell shell = getControl().getShell();
+                       IRunnableWithProgress runnable = new IRunnableWithProgress() {
+
+                               public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+                                       try {
+                                               fCPathsBlock.configureCProject(monitor);
+                                       } catch (CoreException e) {
+                                               throw new InvocationTargetException(e);
+                                       }
+                               }
+                       };
+                       IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable);
+                       try {
+                               new ProgressMonitorDialog(shell).run(true, true, op);
+                       } catch (InvocationTargetException e) {
+                               String title = CPathEntryMessages.CPathsPropertyPage_error_title; 
+                               String message = CPathEntryMessages.CPathsPropertyPage_error_message; 
+                               ExceptionHandler.handle(e, shell, title, message);
+                               return false;
+                       } catch (InterruptedException e) {
+                               // cancelled
+                               return false;
+                       }
+               }
+               return true;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see IStatusChangeListener#statusChanged
+        */
+       public void statusChanged(IStatus status) {
+               setValid(!status.matches(IStatus.ERROR));
+               StatusUtil.applyToStatusLine(this, status);
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.preference.IPreferencePage#performCancel()
+        */
+       @Override
+       public boolean performCancel() {
+               if (fCPathsBlock != null) {
+                       getSettings().put(INDEX, fCPathsBlock.getPageIndex());
+               }
+               return super.performCancel();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathSourceEntryPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathSourceEntryPage.java
new file mode 100644 (file)
index 0000000..393d225
--- /dev/null
@@ -0,0 +1,550 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.dialogs.NewFolderDialog;
+import org.eclipse.ui.model.BaseWorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+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.ITreeListAdapter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
+
+/**
+ * Source tab for C/C++ Project Paths page for 3.X projects.
+ * 
+ * @deprecated as of CDT 4.0. This tab was used for property pages
+ * for 3.X style projects.
+ */
+@Deprecated
+public class CPathSourceEntryPage extends CPathBasePage {
+
+       private ListDialogField<CPElement> fCPathList;
+       private ICProject fCurrCProject;
+       private IPath fProjPath;
+
+       private IWorkspaceRoot fWorkspaceRoot;
+
+       private TreeListDialogField<CPElement> fFoldersList;
+
+       private final int IDX_ADD = 0;
+       private final int IDX_EDIT = 2;
+       private final int IDX_REMOVE = 3;
+
+       public CPathSourceEntryPage(ListDialogField<CPElement> classPathList) {
+               super(CPathEntryMessages.SourcePathEntryPage_title); 
+               setDescription(CPathEntryMessages.SourcePathEntryPage_description); 
+
+               fWorkspaceRoot = CUIPlugin.getWorkspace().getRoot();
+               fCPathList = classPathList;
+
+               SourceContainerAdapter adapter = new SourceContainerAdapter();
+
+               String[] buttonLabels;
+
+               buttonLabels = new String[]{
+               CPathEntryMessages.SourcePathEntryPage_folders_add_button, 
+                               /* 1 */null, CPathEntryMessages.SourcePathEntryPath_folders_edit_button, 
+                               CPathEntryMessages.SourcePathEntryPage_folders_remove_button
+               };
+
+               fFoldersList = new TreeListDialogField<CPElement>(adapter, buttonLabels, new CPElementLabelProvider());
+               fFoldersList.setDialogFieldListener(adapter);
+               fFoldersList.setLabelText(CPathEntryMessages.SourcePathEntryPage_folders_label); 
+
+               fFoldersList.setViewerComparator(new CPElementSorter());
+               fFoldersList.enableButton(IDX_EDIT, false);
+               fFoldersList.enableButton(IDX_REMOVE, false);
+               fFoldersList.setTreeExpansionLevel(2);
+       }
+
+       @Override
+       public Image getImage() {
+               return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_SOURCE_ROOT);
+       }
+
+       public void init(ICProject cproject) {
+               fCurrCProject = cproject;
+               fProjPath = fCurrCProject.getProject().getFullPath();
+               updateFoldersList();
+       }
+
+       private void updateFoldersList() {
+               List<CPElement> folders = filterList(fCPathList.getElements());
+               fFoldersList.setElements(folders);
+
+               for (int i = 0; i < folders.size(); i++) {
+                       CPElement cpe = folders.get(i);
+                       IPath[] patterns = (IPath[])cpe.getAttribute(CPElement.EXCLUSION);
+                       if (patterns.length > 0) {
+                               fFoldersList.expandElement(cpe, 3);
+                       }
+               }
+       }
+
+       @Override
+       public void createControl(Composite parent) {
+               PixelConverter converter = new PixelConverter(parent);
+               Composite composite = new Composite(parent, SWT.NONE);
+
+               LayoutUtil.doDefaultLayout(composite, new DialogField[]{fFoldersList}, true);
+               LayoutUtil.setHorizontalGrabbing(fFoldersList.getTreeControl(null), true);
+
+               int buttonBarWidth = converter.convertWidthInCharsToPixels(24);
+               fFoldersList.setButtonsMinWidth(buttonBarWidth);
+
+               // expand
+               List<CPElement> elements = fFoldersList.getElements();
+               for (int i = 0; i < elements.size(); i++) {
+                       CPElement elem = elements.get(i);
+                       IPath[] patterns = (IPath[])elem.getAttribute(CPElement.EXCLUSION);
+                       if (patterns.length > 0) {
+                               fFoldersList.expandElement(elem, 3);
+                       }
+               }
+               setControl(composite);
+               
+               CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.PROJECT_PATHS_SOURCE);        
+       }
+
+       private class SourceContainerAdapter implements ITreeListAdapter<CPElement>, IDialogFieldListener {
+
+               private final Object[] EMPTY_ARR = new Object[0];
+
+               // -------- IListAdapter --------
+               public void customButtonPressed(TreeListDialogField<CPElement> field, int index) {
+                       sourcePageCustomButtonPressed(field, index);
+               }
+
+               public void selectionChanged(TreeListDialogField<CPElement> field) {
+                       sourcePageSelectionChanged(field);
+               }
+
+               public void doubleClicked(TreeListDialogField<CPElement> field) {
+                       sourcePageDoubleClicked(field);
+               }
+
+               public void keyPressed(TreeListDialogField<CPElement> field, KeyEvent event) {
+                       sourcePageKeyPressed(field, event);
+               }
+
+               public Object[] getChildren(TreeListDialogField<CPElement> field, Object element) {
+                       if (element instanceof CPElement) {
+                               return ((CPElement)element).getChildren();
+                       }
+                       return EMPTY_ARR;
+               }
+
+               public Object getParent(TreeListDialogField<CPElement> field, Object element) {
+                       if (element instanceof CPElementAttribute) {
+                               return ((CPElementAttribute)element).getParent();
+                       }
+                       return null;
+               }
+
+               public boolean hasChildren(TreeListDialogField<CPElement> field, Object element) {
+                       return (element instanceof CPElement);
+               }
+
+               // ---------- IDialogFieldListener --------
+               public void dialogFieldChanged(DialogField field) {
+                       sourcePageDialogFieldChanged(field);
+               }
+
+       }
+
+       protected void sourcePageKeyPressed(TreeListDialogField<CPElement> field, KeyEvent event) {
+               if (field == fFoldersList) {
+                       if (event.character == SWT.DEL && event.stateMask == 0) {
+                               List<Object> selection = field.getSelectedElements();
+                               if (canRemove(selection)) {
+                                       removeEntry();
+                               }
+                       }
+               }
+       }
+
+       protected void sourcePageDoubleClicked(TreeListDialogField<CPElement> field) {
+               if (field == fFoldersList) {
+                       List<Object> selection = field.getSelectedElements();
+                       if (canEdit(selection)) {
+                               editEntry();
+                       }
+               }
+       }
+
+       protected void sourcePageCustomButtonPressed(DialogField field, int index) {
+               if (field == fFoldersList) {
+                       if (index == IDX_ADD) {
+                               List<CPElement> elementsToAdd = new ArrayList<CPElement>(10);
+                               IProject project = fCurrCProject.getProject();
+                               if (project.exists()) {
+                                       CPElement[] srcentries = openSourceContainerDialog(null);
+                                       if (srcentries != null) {
+                                               for (CPElement srcentrie : srcentries) {
+                                                       elementsToAdd.add(srcentrie);
+                                               }
+                                       }
+                               } else {
+                                       CPElement entry = openNewSourceContainerDialog(null, false);
+                                       if (entry != null) {
+                                               elementsToAdd.add(entry);
+                                       }
+                               }
+                               if (!elementsToAdd.isEmpty()) {
+                                       HashSet<CPElement> modifiedElements = new HashSet<CPElement>();
+                                       askForAddingExclusionPatternsDialog(elementsToAdd, modifiedElements);
+
+                                       fFoldersList.addElements(elementsToAdd);
+                                       fFoldersList.postSetSelection(new StructuredSelection(elementsToAdd));
+
+                                       if (!modifiedElements.isEmpty()) {
+                                               for (Object elem : modifiedElements) {
+                                                       fFoldersList.refresh(elem);
+                                                       fFoldersList.expandElement(elem, 3);
+                                               }
+                                       }
+
+                               }
+                       } else if (index == IDX_EDIT) {
+                               editEntry();
+                       } else if (index == IDX_REMOVE) {
+                               removeEntry();
+                       }
+               }
+       }
+
+       private void editEntry() {
+               List<Object> selElements = fFoldersList.getSelectedElements();
+               if (selElements.size() != 1) {
+                       return;
+               }
+               Object elem = selElements.get(0);
+               if (fFoldersList.getIndexOfElement(elem) != -1) {
+                       editElementEntry((CPElement)elem);
+               } else if (elem instanceof CPElementAttribute) {
+                       editAttributeEntry((CPElementAttribute)elem);
+               }
+       }
+
+       private void editElementEntry(CPElement elem) {
+               CPElement res = null;
+
+               res = openNewSourceContainerDialog(elem, true);
+
+               if (res != null) {
+                       fFoldersList.replaceElement(elem, res);
+               }
+       }
+
+       private void editAttributeEntry(CPElementAttribute elem) {
+               String key = elem.getKey();
+               if (key.equals(CPElement.EXCLUSION)) {
+                       CPElement selElement = elem.getParent();
+                       ExclusionPatternDialog dialog = new ExclusionPatternDialog(getShell(), selElement);
+                       if (dialog.open() == Window.OK) {
+                               selElement.setAttribute(CPElement.EXCLUSION, dialog.getExclusionPattern());
+                               fFoldersList.refresh();
+                               fCPathList.dialogFieldChanged(); // validate
+                       }
+               }
+       }
+
+       protected void sourcePageSelectionChanged(DialogField field) {
+               List<Object> selected = fFoldersList.getSelectedElements();
+               fFoldersList.enableButton(IDX_EDIT, canEdit(selected));
+               fFoldersList.enableButton(IDX_REMOVE, canRemove(selected));
+       }
+
+       private void removeEntry() {
+               List<Object> selElements = fFoldersList.getSelectedElements();
+               for (int i = selElements.size() - 1; i >= 0; i--) {
+                       Object elem = selElements.get(i);
+                       if (elem instanceof CPElementAttribute) {
+                               CPElementAttribute attrib = (CPElementAttribute)elem;
+                               String key = attrib.getKey();
+                               Object value = key.equals(CPElement.EXCLUSION) ? new Path[0] : null;
+                               attrib.getParent().setAttribute(key, value);
+                               selElements.remove(i);
+                       }
+               }
+               if (selElements.isEmpty()) {
+                       fFoldersList.refresh();
+                       fCPathList.dialogFieldChanged(); // validate
+               } else {
+                       fFoldersList.removeElements(selElements);
+               }
+       }
+
+       private boolean canRemove(List<?> selElements) {
+               if (selElements.size() == 0) {
+                       return false;
+               }
+               for (int i = 0; i < selElements.size(); i++) {
+                       Object elem = selElements.get(i);
+                       if (elem instanceof CPElementAttribute) {
+                               CPElementAttribute attrib = (CPElementAttribute)elem;
+                               if (attrib.getKey().equals(CPElement.EXCLUSION)) {
+                                       if ( ((IPath[])attrib.getValue()).length == 0) {
+                                               return false;
+                                       }
+                               } else if (attrib.getValue() == null) {
+                                       return false;
+                               }
+                       } else if (elem instanceof CPElement) {
+                               CPElement curr = (CPElement)elem;
+                               if (curr.getParentContainer() != null) {
+                                       return false;
+                               }
+                       }
+               }
+               return true;
+       }
+
+       private boolean canEdit(List<?> selElements) {
+               if (selElements.size() != 1) {
+                       return false;
+               }
+               Object elem = selElements.get(0);
+               if (elem instanceof CPElement) {
+                       return false;
+               }
+               if (elem instanceof CPElementAttribute) {
+                       return true;
+               }
+               return false;
+       }
+
+       void sourcePageDialogFieldChanged(DialogField field) {
+               if (fCurrCProject == null) {
+                       // not initialized
+                       return;
+               }
+
+               if (field == fFoldersList) {
+                       updateClasspathList();
+               }
+       }
+
+       private void updateClasspathList() {
+               List<CPElement> srcelements = fFoldersList.getElements();
+
+               List<CPElement> cpelements = fCPathList.getElements();
+               int nEntries = cpelements.size();
+               // backwards, as entries will be deleted
+               int lastRemovePos = nEntries;
+               int afterLastSourcePos = 0;
+               for (int i = nEntries - 1; i >= 0; i--) {
+                       CPElement cpe = cpelements.get(i);
+                       int kind = cpe.getEntryKind();
+                       if (isEntryKind(kind)) {
+                               if (!srcelements.remove(cpe)) {
+                                       cpelements.remove(i);
+                                       lastRemovePos = i;
+                               } else if (lastRemovePos == nEntries) {
+                                       afterLastSourcePos = i + 1;
+                               }
+                       }
+               }
+
+               if (!srcelements.isEmpty()) {
+                       int insertPos = Math.min(afterLastSourcePos, lastRemovePos);
+                       cpelements.addAll(insertPos, srcelements);
+               }
+
+               if (lastRemovePos != nEntries || !srcelements.isEmpty()) {
+                       fCPathList.setElements(cpelements);
+               }
+       }
+
+       private CPElement openNewSourceContainerDialog(CPElement existing, boolean includeLinked) {
+               if (includeLinked) {
+                       NewFolderDialog dialog = new NewFolderDialog(getShell(), fCurrCProject.getProject());
+                       if (dialog.open() == Window.OK) {
+                               IResource createdFolder = (IResource)dialog.getResult()[0];
+                               return newCPSourceElement(createdFolder);
+                       }
+                       return null;
+               }
+               String title = (existing == null) ? CPathEntryMessages.SourcePathEntryPage_NewSourceFolderDialog_new_title
+                               : CPathEntryMessages.SourcePathEntryPage_NewSourceFolderDialog_edit_title; 
+
+               IProject proj = fCurrCProject.getProject();
+               NewSourceFolderDialog dialog = new NewSourceFolderDialog(getShell(), title, proj, getExistingContainers(existing), existing);
+               dialog.setMessage(NLS.bind(CPathEntryMessages.SourcePathEntryPage_NewSourceFolderDialog_description, 
+                               fProjPath.toString()));
+               if (dialog.open() == Window.OK) {
+                       IResource folder = dialog.getSourceFolder();
+                       return newCPSourceElement(folder);
+               }
+               return null;
+       }
+
+       private void askForAddingExclusionPatternsDialog(List<CPElement> newEntries, Set<CPElement> modifiedEntries) {
+               fixNestingConflicts(newEntries, fFoldersList.getElements(), modifiedEntries);
+               if (!modifiedEntries.isEmpty()) {
+                       String title = CPathEntryMessages.SourcePathEntryPage_exclusion_added_title; 
+                       String message = CPathEntryMessages.SourcePathEntryPage_exclusion_added_message; 
+                       MessageDialog.openInformation(getShell(), title, message);
+               }
+       }
+
+       private CPElement[] openSourceContainerDialog(CPElement existing) {
+
+               Class<?>[] acceptedClasses = new Class[]{IProject.class, IFolder.class};
+               List<IContainer> existingContainers = getExistingContainers(null);
+
+               IProject[] allProjects = fWorkspaceRoot.getProjects();
+               ArrayList<IProject> rejectedElements = new ArrayList<IProject>(allProjects.length);
+               IProject currProject = fCurrCProject.getProject();
+               for (int i = 0; i < allProjects.length; i++) {
+                       if (!allProjects[i].equals(currProject)) {
+                               rejectedElements.add(allProjects[i]);
+                       }
+               }
+
+               ViewerFilter filter = new TypedViewerFilter(acceptedClasses, rejectedElements.toArray());
+
+               ILabelProvider lp = new WorkbenchLabelProvider();
+               ITreeContentProvider cp = new BaseWorkbenchContentProvider();
+
+               String title = (existing == null)
+                               ? CPathEntryMessages.SourcePathEntryPage_ExistingSourceFolderDialog_new_title
+                               : CPathEntryMessages.SourcePathEntryPage_ExistingSourceFolderDialog_edit_title; 
+               String message = (existing == null)
+                               ? CPathEntryMessages.SourcePathEntryPage_ExistingSourceFolderDialog_new_description
+                               : CPathEntryMessages.SourcePathEntryPage_ExistingSourceFolderDialog_edit_description; 
+
+               MultipleFolderSelectionDialog dialog = new MultipleFolderSelectionDialog(getShell(), lp, cp);
+               dialog.setExisting(existingContainers.toArray());
+               dialog.setTitle(title);
+               dialog.setMessage(message);
+               dialog.addFilter(filter);
+               dialog.setInput(fCurrCProject.getProject().getParent());
+               if (existing == null) {
+                       dialog.setInitialFocus(fCurrCProject.getProject());
+               } else {
+                       dialog.setInitialFocus(existing.getResource());
+               }
+               if (dialog.open() == Window.OK) {
+                       Object[] elements = dialog.getResult();
+                       CPElement[] res = new CPElement[elements.length];
+                       for (int i = 0; i < res.length; i++) {
+                               IResource elem = (IResource)elements[i];
+                               res[i] = newCPSourceElement(elem);
+                       }
+                       return res;
+               }
+               return null;
+       }
+
+       private List<IContainer> getExistingContainers(CPElement existing) {
+               List<IContainer> res = new ArrayList<IContainer>();
+               List<CPElement> cplist = fFoldersList.getElements();
+               for (int i = 0; i < cplist.size(); i++) {
+                       CPElement elem = cplist.get(i);
+                       if (elem != existing) {
+                               IResource resource = elem.getResource();
+                               if (resource instanceof IContainer) { // defensive code
+                                       res.add((IContainer) resource);
+                               }
+                       }
+               }
+               return res;
+       }
+
+       private CPElement newCPSourceElement(IResource res) {
+               Assert.isNotNull(res);
+               return new CPElement(fCurrCProject, IPathEntry.CDT_SOURCE, res.getFullPath(), res);
+       }
+
+       /*
+        * @see BuildPathBasePage#getSelection
+        */
+       @Override
+       public List<Object> getSelection() {
+               return fFoldersList.getSelectedElements();
+       }
+
+       /*
+        * @see BuildPathBasePage#setSelection
+        */
+       @Override
+       public void setSelection(List<?> selElements) {
+               fFoldersList.selectElements(new StructuredSelection(selElements));
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jdt.internal.ui.wizards.buildpaths.BuildPathBasePage#isEntryKind(int)
+        */
+       @Override
+       public boolean isEntryKind(int kind) {
+               return kind == IPathEntry.CDT_SOURCE;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.cdt.ui.dialogs.AbstractCOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
+        */
+       @Override
+       public void performApply(IProgressMonitor monitor) throws CoreException {
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.cdt.ui.dialogs.AbstractCOptionPage#performDefaults()
+        */
+       @Override
+       public void performDefaults() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathTabBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathTabBlock.java
new file mode 100644 (file)
index 0000000..6ae5b7f
--- /dev/null
@@ -0,0 +1,182 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IPathEntry;
+
+import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
+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.ListDialogField;
+
+/**
+ * Block for C/C++ Project Paths page for 3.X projects.
+ * 
+ * @deprecated as of CDT 4.0. This option block was for property pages
+ * for 3.X style projects.
+ */
+@Deprecated
+public class CPathTabBlock extends AbstractPathOptionBlock {
+       
+       private final int[] pathTypes = {IPathEntry.CDT_SOURCE, IPathEntry.CDT_PROJECT, IPathEntry.CDT_OUTPUT, IPathEntry.CDT_LIBRARY,IPathEntry.CDT_CONTAINER};
+
+       private ListDialogField<CPElement> fCPathList;
+
+       private CPathSourceEntryPage fSourcePage;
+       private CPathProjectsEntryPage fProjectsPage;
+       private CPathOutputEntryPage fOutputPage;
+       private CPathContainerEntryPage fContainerPage;
+       private CPathLibraryEntryPage fLibrariesPage;
+
+       private class BuildPathAdapter implements IDialogFieldListener {
+
+               // ---------- IDialogFieldListener --------
+               public void dialogFieldChanged(DialogField field) {
+                       buildPathDialogFieldChanged(field);
+               }
+       }
+
+       void buildPathDialogFieldChanged(DialogField field) {
+               if (field == fCPathList) {
+                       updateCPathStatus();
+               }
+               doStatusLineUpdate();
+       }
+
+       public CPathTabBlock(IStatusChangeListener context, int pageToShow) {
+               super(context, pageToShow);
+
+               String[] buttonLabels = new String[]{ CPathEntryMessages.CPathsBlock_path_up_button, 
+                               CPathEntryMessages.CPathsBlock_path_down_button, 
+                               /* 2 */null, CPathEntryMessages.CPathsBlock_path_checkall_button, 
+                               CPathEntryMessages.CPathsBlock_path_uncheckall_button
+
+               };
+               BuildPathAdapter adapter = new BuildPathAdapter();
+
+               fCPathList = new ListDialogField<CPElement>(null, buttonLabels, null);
+               fCPathList.setDialogFieldListener(adapter);
+       }
+
+       @Override
+       protected List<CPElement> getCPaths() {
+               return fCPathList.getElements();
+       }
+
+       @Override
+       protected void addTabs() {
+               fSourcePage = new CPathSourceEntryPage(fCPathList);
+               addPage(fSourcePage);
+               fOutputPage = new CPathOutputEntryPage(fCPathList);
+               addPage(fOutputPage);
+               fProjectsPage = new CPathProjectsEntryPage(fCPathList);
+               addPage(fProjectsPage);
+               fLibrariesPage = new CPathLibraryEntryPage(fCPathList);
+               addPage(fLibrariesPage);
+               fContainerPage = new CPathContainerEntryPage(fCPathList);
+               addPage(fContainerPage);
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock#createContents(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       public Control createContents(Composite parent) {
+               Control control = super.createContents(parent);
+               if (getCProject() != null) {
+                       fSourcePage.init(getCProject());
+                       fOutputPage.init(getCProject());
+                       fProjectsPage.init(getCProject());
+                       fContainerPage.init(getCProject());
+                       fLibrariesPage.init(getCProject());
+               }
+               Dialog.applyDialogFont(control);
+               return control;
+       }
+
+       @Override
+       protected void initialize(ICElement element, List<CPElement> cPaths) {
+
+               fCPathList.setElements(cPaths);
+
+               if (fProjectsPage != null) {
+                       fSourcePage.init(getCProject());
+                       fOutputPage.init(getCProject());
+                       fProjectsPage.init(getCProject());
+                       fContainerPage.init(getCProject());
+                       fLibrariesPage.init(getCProject());
+               }
+
+               doStatusLineUpdate();
+               initializeTimeStamps();
+       }
+
+       @Override
+       protected int[] getFilteredTypes() {
+               return pathTypes;
+       }
+
+       @Override
+       protected int[] getAppliedFilteredTypes() {
+               return pathTypes;
+       }
+       /**
+        * Validates the build path.
+        */
+       public void updateCPathStatus() {
+               getPathStatus().setOK();
+
+               List<CPElement> elements = fCPathList.getElements();
+
+               CPElement entryError = null;
+               int nErrorEntries = 0;
+               IPathEntry[] entries = new IPathEntry[elements.size()];
+
+               for (int i = elements.size() - 1; i >= 0; i--) {
+                       CPElement currElement = elements.get(i);
+
+                       entries[i] = currElement.getPathEntry();
+                       if (currElement.getStatus().getSeverity() != IStatus.OK) {
+                               nErrorEntries++;
+                               if (entryError == null) {
+                                       entryError = currElement;
+                               }
+                       }
+               }
+
+               if (nErrorEntries > 0) {
+                       if (nErrorEntries == 1 && entryError != null) {
+                               getPathStatus().setWarning(entryError.getStatus().getMessage());
+                       } else {
+                               getPathStatus().setWarning(NLS.bind(CPathEntryMessages.CPElement_status_multiplePathErrors, 
+                                               String.valueOf(nErrorEntries)));
+                       }
+               }
+
+               /*
+                * if (fCurrJProject.hasClasspathCycle(entries)) {
+                * fClassPathStatus.setWarning(NewWizardMessages.getString("BuildPathsBlock.warning.CycleInClassPath"));
+                * //$NON-NLS-1$ }
+                */
+               updateBuildPathStatus();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ExclusionPatternDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ExclusionPatternDialog.java
new file mode 100644 (file)
index 0000000..1016c62
--- /dev/null
@@ -0,0 +1,282 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.StatusDialog;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.eclipse.ui.views.navigator.ResourceComparator;
+
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.dialogs.TypedElementSelectionValidator;
+import org.eclipse.cdt.internal.ui.dialogs.TypedViewerFilter;
+import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;
+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.IListAdapter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
+
+/**
+ * @deprecated as of CDT 4.0. This dialog was used for property pages
+ * for 3.X style projects.
+ *
+ */
+@Deprecated
+public class ExclusionPatternDialog extends StatusDialog {
+       
+       private static class ExclusionPatternLabelProvider extends LabelProvider {
+                               
+               @Override
+               public Image getImage(Object element) {
+                       ImageDescriptorRegistry registry= CUIPlugin.getImageDescriptorRegistry();
+                       return registry.get(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_EXCLUSION_FILTER_ATTRIB));
+               }
+
+               @Override
+               public String getText(Object element) {
+                       return (String) element;
+               }
+
+       }
+       
+       
+       private ListDialogField<String> fExclusionPatternList;
+       private CPElement fCurrElement;
+       private IProject fCurrProject;
+       
+       private IContainer fCurrSourceFolder;
+       
+       private static final int IDX_ADD= 0;
+       private static final int IDX_ADD_MULTIPLE= 1;
+       private static final int IDX_EDIT= 2;
+       private static final int IDX_REMOVE= 4;
+       
+               
+       public ExclusionPatternDialog(Shell parent, CPElement entryToEdit) {
+               super(parent);
+               fCurrElement= entryToEdit;
+               setTitle(CPathEntryMessages.ExclusionPatternDialog_title); 
+
+               String label= NLS.bind(CPathEntryMessages.ExclusionPatternDialog_pattern_label, entryToEdit.getPath().makeRelative().toString()); 
+               
+               String[] buttonLabels= new String[] {
+                       CPathEntryMessages.ExclusionPatternDialog_pattern_add, 
+                       CPathEntryMessages.ExclusionPatternDialog_pattern_add_multiple, 
+                       CPathEntryMessages.ExclusionPatternDialog_pattern_edit, 
+                       null,
+                       CPathEntryMessages.ExclusionPatternDialog_pattern_remove
+               };
+
+               ExclusionPatternAdapter adapter= new ExclusionPatternAdapter();
+
+               fExclusionPatternList= new ListDialogField<String>(adapter, buttonLabels, new ExclusionPatternLabelProvider());
+               fExclusionPatternList.setDialogFieldListener(adapter);
+               fExclusionPatternList.setLabelText(label);
+               fExclusionPatternList.setRemoveButtonIndex(IDX_REMOVE);
+               fExclusionPatternList.enableButton(IDX_EDIT, false);
+       
+               fCurrProject= entryToEdit.getCProject().getProject();
+               IWorkspaceRoot root= fCurrProject.getWorkspace().getRoot();
+               IResource res= root.findMember(entryToEdit.getPath());
+               if (res instanceof IContainer) {
+                       fCurrSourceFolder= (IContainer) res;
+               }                               
+               
+               IPath[] pattern= (IPath[]) entryToEdit.getAttribute(CPElement.EXCLUSION);
+               
+               ArrayList<String> elements= new ArrayList<String>(pattern.length);
+               for (IPath element : pattern) {
+                       elements.add(element.toString());
+               }
+               fExclusionPatternList.setElements(elements);
+               fExclusionPatternList.selectFirstElement();
+               fExclusionPatternList.enableButton(IDX_ADD_MULTIPLE, fCurrSourceFolder != null);
+
+               setHelpAvailable(false);
+       }
+       
+       
+       @Override
+       protected Control createDialogArea(Composite parent) {
+               Composite composite= (Composite)super.createDialogArea(parent);
+
+               Composite inner= new Composite(composite, SWT.NONE);
+               GridLayout layout= new GridLayout();
+               layout.marginHeight= 0;
+               layout.marginWidth= 0;
+               layout.numColumns= 2;
+               inner.setLayout(layout);
+               
+               fExclusionPatternList.doFillIntoGrid(inner, 3);
+               LayoutUtil.setHorizontalSpan(fExclusionPatternList.getLabelControl(null), 2);
+               
+               applyDialogFont(composite);             
+               return composite;
+       }
+       
+       protected void doCustomButtonPressed(ListDialogField<String> field, int index) {
+               if (index == IDX_ADD) {
+                       addEntry();
+               } else if (index == IDX_EDIT) {
+                       editEntry();
+               } else if (index == IDX_ADD_MULTIPLE) {
+                       addMultipleEntries();
+               }
+       }
+       
+       protected void doDoubleClicked(ListDialogField<String> field) {
+               editEntry();
+       }
+       
+       protected void doSelectionChanged(ListDialogField<String> field) {
+               List<String> selected= field.getSelectedElements();
+               fExclusionPatternList.enableButton(IDX_EDIT, canEdit(selected));
+       }
+       
+       private boolean canEdit(List<String> selected) {
+               return selected.size() == 1;
+       }
+       
+       private void editEntry() {
+               
+               List<String> selElements= fExclusionPatternList.getSelectedElements();
+               if (selElements.size() != 1) {
+                       return;
+               }
+               List<String> existing= fExclusionPatternList.getElements();
+               String entry= selElements.get(0);
+               ExclusionPatternEntryDialog dialog= new ExclusionPatternEntryDialog(getShell(), entry, existing, fCurrElement);
+               if (dialog.open() == Window.OK) {
+                       fExclusionPatternList.replaceElement(entry, dialog.getExclusionPattern());
+               }
+       }
+       
+       private void addEntry() {
+               List<String> existing= fExclusionPatternList.getElements();
+               ExclusionPatternEntryDialog dialog= new ExclusionPatternEntryDialog(getShell(), null, existing, fCurrElement);
+               if (dialog.open() == Window.OK) {
+                       fExclusionPatternList.addElement(dialog.getExclusionPattern());
+               }
+       }       
+       
+       
+               
+       // -------- ExclusionPatternAdapter --------
+
+       private class ExclusionPatternAdapter implements IListAdapter<String>, IDialogFieldListener {
+               public void customButtonPressed(ListDialogField<String> field, int index) {
+                       doCustomButtonPressed(field, index);
+               }
+
+               public void selectionChanged(ListDialogField<String> field) {
+                       doSelectionChanged(field);
+               }
+
+               public void doubleClicked(ListDialogField<String> field) {
+                       doDoubleClicked(field);
+               }
+
+               public void dialogFieldChanged(DialogField field) {
+               }
+               
+       }
+       
+       protected void doStatusLineUpdate() {
+       }               
+       
+       protected void checkIfPatternValid() {
+       }
+       
+               
+       public IPath[] getExclusionPattern() {
+               IPath[] res= new IPath[fExclusionPatternList.getSize()];
+               for (int i= 0; i < res.length; i++) {
+                       String entry= fExclusionPatternList.getElement(i);
+                       res[i]= new Path(entry);
+               }
+               return res;
+       }
+               
+       /*
+        * @see org.eclipse.jface.window.Window#configureShell(Shell)
+        */
+       @Override
+       protected void configureShell(Shell newShell) {
+               super.configureShell(newShell);
+//             WorkbenchHelp.setHelp(newShell, ICHelpContextIds.EXCLUSION_PATTERN_DIALOG);
+       }
+       
+       private void addMultipleEntries() {
+               Class<?>[] acceptedClasses= new Class<?>[] { IFolder.class, IFile.class };
+               ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, true);
+               ViewerFilter filter= new TypedViewerFilter(acceptedClasses);
+
+               ILabelProvider lp= new WorkbenchLabelProvider();
+               ITreeContentProvider cp= new WorkbenchContentProvider();
+               
+               IResource initialElement= null; 
+
+               ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), lp, cp);
+               dialog.setTitle(CPathEntryMessages.ExclusionPatternDialog_ChooseExclusionPattern_title); 
+               dialog.setValidator(validator);
+               dialog.setMessage(CPathEntryMessages.ExclusionPatternDialog_ChooseExclusionPattern_description); 
+               dialog.addFilter(filter);
+               dialog.setInput(fCurrSourceFolder);
+               dialog.setInitialSelection(initialElement);
+               dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
+
+               if (dialog.open() == Window.OK) {
+                       Object[] objects= dialog.getResult();
+                       int existingSegments= fCurrSourceFolder.getFullPath().segmentCount();
+                       
+                       for (Object object : objects) {
+                               IResource curr= (IResource) object;
+                               IPath path= curr.getFullPath().removeFirstSegments(existingSegments).makeRelative();
+                               String res;
+                               if (curr instanceof IContainer) {
+                                       res= path.addTrailingSeparator().toString();
+                               } else {
+                                       res= path.toString();
+                               }
+                               fExclusionPatternList.addElement(res);
+                       }
+               }
+       }       
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ExclusionPatternEntryDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ExclusionPatternEntryDialog.java
new file mode 100644 (file)
index 0000000..e480033
--- /dev/null
@@ -0,0 +1,241 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.StatusDialog;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.eclipse.ui.views.navigator.ResourceComparator;
+
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.dialogs.TypedElementSelectionValidator;
+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.IStringButtonAdapter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
+
+/**
+ * @deprecated as of CDT 4.0. This class was used for property pages
+ * for 3.X style projects.
+ */
+@Deprecated
+public class ExclusionPatternEntryDialog extends StatusDialog {
+
+       private StringButtonDialogField fExclusionPatternDialog;
+       private StatusInfo fExclusionPatternStatus;
+
+       private IContainer fCurrSourceFolder;
+       private String fExclusionPattern;
+       private List<String> fExistingPatterns;
+
+       public ExclusionPatternEntryDialog(Shell parent, String patternToEdit, List<String> existingPatterns, CPElement entryToEdit) {
+               super(parent);
+               fExistingPatterns = existingPatterns;
+               if (patternToEdit == null) {
+                       setTitle(CPathEntryMessages.ExclusionPatternEntryDialog_add_title); 
+               } else {
+                       setTitle(CPathEntryMessages.ExclusionPatternEntryDialog_edit_title); 
+                       fExistingPatterns.remove(patternToEdit);
+               }
+
+               IWorkspaceRoot root = entryToEdit.getCProject().getProject().getWorkspace().getRoot();
+               IResource res = root.findMember(entryToEdit.getPath());
+               if (res instanceof IContainer) {
+                       fCurrSourceFolder = (IContainer) res;
+               }
+
+               fExclusionPatternStatus = new StatusInfo();
+
+               String label = NLS.bind(CPathEntryMessages.ExclusionPatternEntryDialog_pattern_label, 
+                               entryToEdit.getPath().makeRelative().toString());
+
+               ExclusionPatternAdapter adapter = new ExclusionPatternAdapter();
+               fExclusionPatternDialog = new StringButtonDialogField(adapter);
+               fExclusionPatternDialog.setLabelText(label);
+               fExclusionPatternDialog.setButtonLabel(CPathEntryMessages.ExclusionPatternEntryDialog_pattern_button); 
+               fExclusionPatternDialog.setDialogFieldListener(adapter);
+               fExclusionPatternDialog.enableButton(fCurrSourceFolder != null);
+
+               if (patternToEdit == null) {
+                       fExclusionPatternDialog.setText(""); //$NON-NLS-1$
+               } else {
+                       fExclusionPatternDialog.setText(patternToEdit.toString());
+               }
+
+               setHelpAvailable(false);
+       }
+
+       @Override
+       protected Control createDialogArea(Composite parent) {
+               Composite composite = (Composite) super.createDialogArea(parent);
+
+               int widthHint = convertWidthInCharsToPixels(60);
+
+               Composite inner = new Composite(composite, SWT.NONE);
+               GridLayout layout = new GridLayout();
+               layout.marginHeight = 0;
+               layout.marginWidth = 0;
+               layout.numColumns = 2;
+               inner.setLayout(layout);
+
+               Label description = new Label(inner, SWT.WRAP);
+               description.setText(CPathEntryMessages.ExclusionPatternEntryDialog_description); 
+               GridData gd = new GridData();
+               gd.horizontalSpan = 2;
+               gd.widthHint = convertWidthInCharsToPixels(80);
+               description.setLayoutData(gd);
+
+               fExclusionPatternDialog.doFillIntoGrid(inner, 3);
+
+               LayoutUtil.setWidthHint(fExclusionPatternDialog.getLabelControl(null), widthHint);
+               LayoutUtil.setHorizontalSpan(fExclusionPatternDialog.getLabelControl(null), 2);
+
+               LayoutUtil.setWidthHint(fExclusionPatternDialog.getTextControl(null), widthHint);
+               LayoutUtil.setHorizontalGrabbing(fExclusionPatternDialog.getTextControl(null), true);
+
+               fExclusionPatternDialog.postSetFocusOnDialogField(parent.getDisplay());
+               applyDialogFont(composite);
+               return composite;
+       }
+
+       // -------- ExclusionPatternAdapter --------
+
+       private class ExclusionPatternAdapter implements IDialogFieldListener, IStringButtonAdapter {
+
+               // -------- IDialogFieldListener
+
+               public void dialogFieldChanged(DialogField field) {
+                       doStatusLineUpdate();
+               }
+
+               public void changeControlPressed(DialogField field) {
+                       doChangeControlPressed();
+               }
+       }
+
+       protected void doChangeControlPressed() {
+               IPath pattern = chooseExclusionPattern();
+               if (pattern != null) {
+                       fExclusionPatternDialog.setText(pattern.toString());
+               }
+       }
+
+       protected void doStatusLineUpdate() {
+               checkIfPatternValid();
+               updateStatus(fExclusionPatternStatus);
+       }
+
+       protected void checkIfPatternValid() {
+               String pattern = fExclusionPatternDialog.getText().trim();
+               if (pattern.length() == 0) {
+                       fExclusionPatternStatus.setError(CPathEntryMessages.ExclusionPatternEntryDialog_error_empty); 
+                       return;
+               }
+               IPath path = new Path(pattern);
+               if (path.isAbsolute() || path.getDevice() != null) {
+                       fExclusionPatternStatus.setError(CPathEntryMessages.ExclusionPatternEntryDialog_error_notrelative); 
+                       return;
+               }
+               if (fExistingPatterns.contains(pattern)) {
+                       fExclusionPatternStatus.setError(CPathEntryMessages.ExclusionPatternEntryDialog_error_exists); 
+                       return;
+               }
+
+               fExclusionPattern = pattern;
+               fExclusionPatternStatus.setOK();
+       }
+
+       public String getExclusionPattern() {
+               return fExclusionPattern;
+       }
+
+       /*
+        * @see org.eclipse.jface.window.Window#configureShell(Shell)
+        */
+       @Override
+       protected void configureShell(Shell newShell) {
+               super.configureShell(newShell);
+               //              WorkbenchHelp.setHelp(newShell,
+               // ICHelpContextIds.EXCLUSION_PATTERN_DIALOG);
+       }
+
+       // ---------- util method ------------
+
+       private IPath chooseExclusionPattern() {
+               Class<?>[] acceptedClasses = new Class<?>[] { IFolder.class, IFile.class};
+               ISelectionStatusValidator validator = new TypedElementSelectionValidator(acceptedClasses, false);
+               ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
+
+               ILabelProvider lp = new WorkbenchLabelProvider();
+               ITreeContentProvider cp = new WorkbenchContentProvider();
+
+               IPath initialPath = new Path(fExclusionPatternDialog.getText());
+               IResource initialElement = null;
+               IContainer curr = fCurrSourceFolder;
+               int nSegments = initialPath.segmentCount();
+               for (int i = 0; i < nSegments; i++) {
+                       IResource elem = curr.findMember(initialPath.segment(i));
+                       if (elem != null) {
+                               initialElement = elem;
+                       }
+                       if (elem instanceof IContainer) {
+                               curr = (IContainer) elem;
+                       } else {
+                               break;
+                       }
+               }
+
+               ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), lp, cp);
+               dialog.setTitle(CPathEntryMessages.ExclusionPatternEntryDialog_ChooseExclusionPattern_title); 
+               dialog.setValidator(validator);
+               dialog.setMessage(CPathEntryMessages.ExclusionPatternEntryDialog_ChooseExclusionPattern_description); 
+               dialog.addFilter(filter);
+               dialog.setInput(fCurrSourceFolder);
+               dialog.setInitialSelection(initialElement);
+               dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
+
+               if (dialog.open() == Window.OK) {
+                       IResource res = (IResource) dialog.getFirstResult();
+                       IPath path = res.getFullPath().removeFirstSegments(fCurrSourceFolder.getFullPath().segmentCount()).makeRelative();
+                       if (res instanceof IContainer) {
+                               return path.addTrailingSeparator();
+                       }
+                       return path;
+               }
+               return null;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/FolderSelectionDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/FolderSelectionDialog.java
new file mode 100644 (file)
index 0000000..e7c4a33
--- /dev/null
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.NewFolderDialog;
+import org.eclipse.ui.views.navigator.ResourceComparator;
+
+import org.eclipse.cdt.internal.ui.util.SWTUtil;
+
+
+/**
+ * @deprecated as of CDT 4.0. This class was used for property pages
+ * for 3.X style projects.
+ */
+@Deprecated
+public class FolderSelectionDialog extends ElementTreeSelectionDialog implements ISelectionChangedListener {
+
+       private Button fNewFolderButton;
+       private IContainer fSelectedContainer;
+
+       public FolderSelectionDialog(Shell parent, ILabelProvider labelProvider, ITreeContentProvider contentProvider) {
+               super(parent, labelProvider, contentProvider);
+               setComparator(new ResourceComparator(ResourceComparator.NAME));
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected Control createDialogArea(Composite parent) {
+               Composite result= (Composite)super.createDialogArea(parent);
+               
+               getTreeViewer().addSelectionChangedListener(this);
+               
+               Button button = new Button(result, SWT.PUSH);
+               button.setText(CPathEntryMessages.FolderSelectionDialog_button); 
+               button.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent event) {
+                               newFolderButtonPressed();
+                       }
+               });
+               button.setFont(parent.getFont());
+               button.setLayoutData(new GridData());
+               SWTUtil.setButtonDimensionHint(button);
+               fNewFolderButton= button;
+               
+               applyDialogFont(result);                
+               return result;
+       }
+
+       private void updateNewFolderButtonState() {
+               IStructuredSelection selection= (IStructuredSelection) getTreeViewer().getSelection();
+               fSelectedContainer= null;
+               if (selection.size() == 1) {
+                       Object first= selection.getFirstElement();
+                       if (first instanceof IContainer) {
+                               fSelectedContainer= (IContainer) first;
+                       }
+               }
+               fNewFolderButton.setEnabled(fSelectedContainer != null);
+       }       
+       
+       protected void newFolderButtonPressed() {
+               NewFolderDialog dialog= new NewFolderDialog(getShell(), fSelectedContainer);
+               if (dialog.open() == Window.OK) {
+                       TreeViewer treeViewer= getTreeViewer();
+                       treeViewer.refresh(fSelectedContainer);
+                       Object createdFolder= dialog.getResult()[0];
+                       treeViewer.reveal(createdFolder);
+                       treeViewer.setSelection(new StructuredSelection(createdFolder));
+               }
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+        */
+       public void selectionChanged(SelectionChangedEvent event) {
+               updateNewFolderButtonState();
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/IContainerDescriptor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/IContainerDescriptor.java
new file mode 100644 (file)
index 0000000..cd3dcb2
--- /dev/null
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.ui.wizards.IPathEntryContainerPage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @deprecated as of CDT 4.0. This class was used for property pages
+ * for 3.X style projects.
+ */
+@Deprecated
+public interface IContainerDescriptor {
+
+       public IPathEntryContainerPage createPage() throws CoreException;
+       public String getName();
+       public Image getImage();
+       public boolean canEdit(IPathEntry entry);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/IncludesSymbolsPropertyPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/IncludesSymbolsPropertyPage.java
new file mode 100644 (file)
index 0000000..2cfe842
--- /dev/null
@@ -0,0 +1,279 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.cdt.core.CProjectNature;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.resources.IPathEntryStore;
+import org.eclipse.cdt.core.resources.IPathEntryStoreListener;
+import org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent;
+import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
+import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
+import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+/**
+ * C/C++ Include Paths and Symbols page for 3.X projects.
+ * 
+ * This page lives dormant as of writing (CDT 7.0) but may get activated for
+ * {@code org.eclipse.cdt.make.core.makeNature} project (3.X style).
+ * 
+ * @deprecated as of CDT 4.0.
+ */
+@Deprecated
+public class IncludesSymbolsPropertyPage extends PropertyPage implements IStatusChangeListener, IPathEntryStoreListener {
+
+       private static final String PAGE_SETTINGS = "IncludeSysmbolsPropertyPage"; //$NON-NLS-1$
+       private static final String INDEX = "pageIndex"; //$NON-NLS-1$
+
+       NewIncludesSymbolsTabBlock fIncludesSymbolsBlock;
+       IPathEntryStore fStore;
+
+       @Override
+       protected Control createContents(Composite parent) {
+               IProject project = getProject();
+               Control result;
+               if (project == null || !isCProject(project)) {
+                       result = createWithoutCProject(parent);
+               } else if (!project.isOpen()) {
+                       result = createForClosedProject(parent);
+               } else {
+                       try {
+                               fStore = CoreModel.getPathEntryStore(getProject());
+                               fStore.addPathEntryStoreListener(this);
+                       } catch (CoreException e) {
+                       }
+                       result = createWithCProject(parent, project);
+               }
+               Dialog.applyDialogFont(result);
+               noDefaultAndApplyButton();
+               return result;
+       }
+
+       private IDialogSettings getSettings() {
+               IDialogSettings cSettings = CUIPlugin.getDefault().getDialogSettings();
+               IDialogSettings pageSettings = cSettings.getSection(PAGE_SETTINGS);
+               if (pageSettings == null) {
+                       pageSettings = cSettings.addNewSection(PAGE_SETTINGS);
+                       pageSettings.put(INDEX, 3);
+               }
+               return pageSettings;
+       }
+
+       /*
+        * Content for valid projects.
+        */
+       private Control createWithCProject(Composite parent, IProject project) {
+               fIncludesSymbolsBlock = new NewIncludesSymbolsTabBlock(this, getSettings().getInt(INDEX));
+               fIncludesSymbolsBlock.init(getCElement(), null);
+               return fIncludesSymbolsBlock.createContents(parent);
+       }
+
+       /*
+        * Content for non-C projects.
+        */
+       private Control createWithoutCProject(Composite parent) {
+               Label label = new Label(parent, SWT.LEFT);
+               label.setText(CPathEntryMessages.CPathsPropertyPage_no_C_project_message); 
+
+               fIncludesSymbolsBlock = null;
+               setValid(true);
+               return label;
+       }
+
+       /*
+        * Content for closed projects.
+        */
+       private Control createForClosedProject(Composite parent) {
+               Label label = new Label(parent, SWT.LEFT);
+               label.setText(CPathEntryMessages.CPathsPropertyPage_closed_project_message); 
+
+               fIncludesSymbolsBlock = null;
+               setValid(true);
+               return label;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.dialogs.IDialogPage#dispose()
+        */
+       @Override
+       public void dispose() {
+               if (fStore != null) {
+                       fStore.removePathEntryStoreListener(this);
+               }
+       }
+       
+       @Override
+       public void setVisible(boolean visible) {
+               if (fIncludesSymbolsBlock != null) {
+                       if (!visible) {
+                               if (fIncludesSymbolsBlock.hasChangesInDialog()) {
+                                       String title = CPathEntryMessages.CPathsPropertyPage_unsavedchanges_title; 
+                                       String message = CPathEntryMessages.CPathsPropertyPage_unsavedchanges_message; 
+                                       String[] buttonLabels = new String[]{
+                                                       CPathEntryMessages.CPathsPropertyPage_unsavedchanges_button_save, 
+                                                       CPathEntryMessages.CPathsPropertyPage_unsavedchanges_button_discard, 
+                                       };
+                                       MessageDialog dialog = new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION,
+                                                       buttonLabels, 0);
+                                       int res = dialog.open();
+                                       if (res == 0) {
+                                               performOk();
+                                       } else if (res == 1) {
+                                               fIncludesSymbolsBlock.init(getCElement(), null);
+                                       }
+                               }
+                       } else {
+                               if (!fIncludesSymbolsBlock.hasChangesInDialog() && fIncludesSymbolsBlock.hasChangesInCPathFile()) {
+                                       fIncludesSymbolsBlock.init(getCElement(), null);
+                               }
+                       }
+               }
+               super.setVisible(visible);
+       }
+
+       private IProject getProject() {
+               IAdaptable adaptable = getElement();
+               if (adaptable != null) {
+                       IResource resource = (IResource)adaptable.getAdapter(IResource.class);
+                       return resource.getProject();
+               }
+               return null;
+       }
+
+       protected ICElement getCElement() {
+               IAdaptable adaptable = getElement();
+               if (adaptable != null) {
+                       ICElement elem = (ICElement)adaptable.getAdapter(ICElement.class);
+                       return elem;
+               }
+               return null;
+       }
+
+       private boolean isCProject(IProject proj) {
+               try {
+                       return proj.hasNature(CProjectNature.C_NATURE_ID);
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }
+               return false;
+       }
+
+       /*
+        * @see IPreferencePage#performOk
+        */
+       @Override
+       public boolean performOk() {
+               if (fIncludesSymbolsBlock != null) {
+                       getSettings().put(INDEX, fIncludesSymbolsBlock.getPageIndex());
+
+                       Shell shell = getControl().getShell();
+                       IRunnableWithProgress runnable = new IRunnableWithProgress() {
+
+                               public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+                                       try {
+                                               fIncludesSymbolsBlock.configureCProject(monitor);
+                                       } catch (CoreException e) {
+                                               throw new InvocationTargetException(e);
+                                       }
+                               }
+                       };
+                       IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable);
+                       try {
+                               new ProgressMonitorDialog(shell).run(true, true, op);
+                       } catch (InvocationTargetException e) {
+                               String title = CPathEntryMessages.CPathsPropertyPage_error_title; 
+                               String message = CPathEntryMessages.CPathsPropertyPage_error_message; 
+                               ExceptionHandler.handle(e, shell, title, message);
+                               return false;
+                       } catch (InterruptedException e) {
+                               // cancelled
+                               return false;
+                       }
+               }
+               return true;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see IStatusChangeListener#statusChanged
+        */
+       public void statusChanged(IStatus status) {
+               setValid(!status.matches(IStatus.ERROR));
+               StatusUtil.applyToStatusLine(this, status);
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.preference.IPreferencePage#performCancel()
+        */
+       @Override
+       public boolean performCancel() {
+               if (fIncludesSymbolsBlock != null) {
+                       getSettings().put(INDEX, fIncludesSymbolsBlock.getPageIndex());
+               }
+               return super.performCancel();
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.cdt.core.resources.IPathEntryStoreListener#pathEntryStoreChanged(org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent)
+        */
+       public void pathEntryStoreChanged(PathEntryStoreChangedEvent event) {
+               if (event.hasContentChanged()) {
+                       Control control = getControl();
+                       if (control != null && !control.isDisposed()) {
+                               control.getDisplay().asyncExec(new Runnable() {
+
+                                       public void run() {
+                                               Control control = getControl();
+                                               if (control != null && !control.isDisposed()) {
+                                                       try {
+                                                               fIncludesSymbolsBlock.init(getCElement(), fIncludesSymbolsBlock.getRawCPath());
+                                                       } catch (CModelException e) {
+                                                               CUIPlugin.log(e);
+                                                       }
+                                               }
+                                       }
+                               });
+                       }
+               }
+
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/MultipleFolderSelectionDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/MultipleFolderSelectionDialog.java
new file mode 100644 (file)
index 0000000..62c7ffe
--- /dev/null
@@ -0,0 +1,323 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.dialogs.NewFolderDialog;
+import org.eclipse.ui.dialogs.SelectionStatusDialog;
+import org.eclipse.ui.views.navigator.ResourceComparator;
+
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.util.SWTUtil;
+
+/**
+ * @deprecated as of CDT 4.0. This class was used for property pages
+ * for 3.X style projects.
+ */
+@Deprecated
+public class MultipleFolderSelectionDialog extends SelectionStatusDialog implements ISelectionChangedListener {
+
+       CheckboxTreeViewer fViewer;
+
+       private ILabelProvider fLabelProvider;
+       private ITreeContentProvider fContentProvider;
+       private List<ViewerFilter> fFilters;
+
+       private Object fInput;
+       private Button fNewFolderButton;
+       private IContainer fSelectedContainer;
+       Set<Object> fExisting;
+       private Object fFocusElement;
+
+       public MultipleFolderSelectionDialog(Shell parent, ILabelProvider labelProvider, ITreeContentProvider contentProvider) {
+               super(parent);
+               fLabelProvider = labelProvider;
+               fContentProvider = contentProvider;
+
+               setSelectionResult(null);
+               setStatusLineAboveButtons(true);
+
+               int shellStyle = getShellStyle();
+               setShellStyle(shellStyle | SWT.MAX | SWT.RESIZE);
+
+               fExisting = null;
+               fFocusElement = null;
+               fFilters = null;
+       }
+
+       public void setExisting(Object[] existing) {
+               fExisting = new HashSet<Object>();
+               for (int i = 0; i < existing.length; i++) {
+                       fExisting.add(existing[i]);
+               }
+       }
+
+       /**
+        * Sets the tree input.
+        * 
+        * @param input
+        *        the tree input.
+        */
+       public void setInput(Object input) {
+               fInput = input;
+       }
+
+       /**
+        * Adds a filter to the tree viewer.
+        * 
+        * @param filter
+        *        a filter.
+        */
+       public void addFilter(ViewerFilter filter) {
+               if (fFilters == null)
+                       fFilters = new ArrayList<ViewerFilter>(4);
+
+               fFilters.add(filter);
+       }
+
+       /**
+        * Handles cancel button pressed event.
+        */
+       @Override
+       protected void cancelPressed() {
+               setSelectionResult(null);
+               super.cancelPressed();
+       }
+
+       /*
+        * @see SelectionStatusDialog#computeResult()
+        */
+       @Override
+       protected void computeResult() {
+               Object[] checked = fViewer.getCheckedElements();
+               if (fExisting == null) {
+                       if (checked.length == 0) {
+                               checked = null;
+                       }
+               } else {
+                       ArrayList<Object> res = new ArrayList<Object>();
+                       for (int i = 0; i < checked.length; i++) {
+                               Object elem = checked[i];
+                               if (!fExisting.contains(elem)) {
+                                       res.add(elem);
+                               }
+                       }
+                       if (!res.isEmpty()) {
+                               checked = res.toArray();
+                       } else {
+                               checked = null;
+                       }
+               }
+               setSelectionResult(checked);
+       }
+
+       void access$superCreate() {
+               super.create();
+       }
+
+       /*
+        * @see Window#create()
+        */
+       @Override
+       public void create() {
+
+               BusyIndicator.showWhile(null, new Runnable() {
+
+                       public void run() {
+                               access$superCreate();
+
+                               fViewer.setCheckedElements(getInitialElementSelections().toArray());
+
+                               fViewer.expandToLevel(2);
+                               if (fExisting != null) {
+                                       for (Iterator<Object> iter = fExisting.iterator(); iter.hasNext();) {
+                                               fViewer.reveal(iter.next());
+                                       }
+                               }
+
+                               updateOKStatus();
+                       }
+               });
+
+       }
+
+       /**
+        * Creates the tree viewer.
+        * 
+        * @param parent
+        *        the parent composite
+        * @return the tree viewer
+        */
+       protected CheckboxTreeViewer createTreeViewer(Composite parent) {
+               fViewer = new CheckboxTreeViewer(parent, SWT.BORDER);
+
+               fViewer.setContentProvider(fContentProvider);
+               fViewer.setLabelProvider(fLabelProvider);
+               fViewer.addCheckStateListener(new ICheckStateListener() {
+
+                       public void checkStateChanged(CheckStateChangedEvent event) {
+                               updateOKStatus();
+                       }
+               });
+
+               fViewer.setComparator(new ResourceComparator(ResourceComparator.NAME));
+               if (fFilters != null) {
+                       for (int i = 0; i != fFilters.size(); i++)
+                               fViewer.addFilter(fFilters.get(i));
+               }
+
+               fViewer.setInput(fInput);
+
+               return fViewer;
+       }
+
+       /**
+        *  
+        */
+       protected void updateOKStatus() {
+               computeResult();
+               if (getResult() != null) {
+                       updateStatus(new StatusInfo());
+               } else {
+                       updateStatus(new StatusInfo(IStatus.ERROR, "")); //$NON-NLS-1$
+               }
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected Control createDialogArea(Composite parent) {
+               Composite composite = (Composite) super.createDialogArea(parent);
+
+               createMessageArea(composite);
+               CheckboxTreeViewer treeViewer = createTreeViewer(composite);
+
+               GridData data = new GridData(GridData.FILL_BOTH);
+               data.widthHint = convertWidthInCharsToPixels(60);
+               data.heightHint = convertHeightInCharsToPixels(18);
+
+               Tree treeWidget = treeViewer.getTree();
+               treeWidget.setLayoutData(data);
+               treeWidget.setFont(composite.getFont());
+
+               Button button = new Button(composite, SWT.PUSH);
+               button.setText(CPathEntryMessages.MultipleFolderSelectionDialog_button); 
+               button.addSelectionListener(new SelectionAdapter() {
+
+                       @Override
+                       public void widgetSelected(SelectionEvent event) {
+                               newFolderButtonPressed();
+                       }
+               });
+               button.setFont(composite.getFont());
+               button.setLayoutData(new GridData());
+               SWTUtil.setButtonDimensionHint(button);
+               fNewFolderButton = button;
+
+               treeViewer.addSelectionChangedListener(this);
+               if (fExisting != null) {
+                       Object[] existing = fExisting.toArray();
+                       treeViewer.setGrayedElements(existing);
+                       setInitialSelections(existing);
+               }
+               if (fFocusElement != null) {
+                       treeViewer.setSelection(new StructuredSelection(fFocusElement), true);
+               }
+               treeViewer.addCheckStateListener(new ICheckStateListener() {
+
+                       public void checkStateChanged(CheckStateChangedEvent event) {
+                               forceExistingChecked(event);
+                       }
+               });
+
+               applyDialogFont(composite);
+               return composite;
+       }
+
+       protected void forceExistingChecked(CheckStateChangedEvent event) {
+               if (fExisting != null) {
+                       Object elem = event.getElement();
+                       if (fExisting.contains(elem)) {
+                               fViewer.setChecked(elem, true);
+                       }
+               }
+       }
+
+       private void updateNewFolderButtonState() {
+               IStructuredSelection selection = (IStructuredSelection) fViewer.getSelection();
+               fSelectedContainer = null;
+               if (selection.size() == 1) {
+                       Object first = selection.getFirstElement();
+                       if (first instanceof IContainer) {
+                               fSelectedContainer = (IContainer) first;
+                       }
+               }
+               fNewFolderButton.setEnabled(fSelectedContainer != null);
+       }
+
+       protected void newFolderButtonPressed() {
+               NewFolderDialog dialog = new NewFolderDialog(getShell(), fSelectedContainer);
+               if (dialog.open() == Window.OK) {
+                       CheckboxTreeViewer treeViewer = fViewer;
+                       treeViewer.refresh(fSelectedContainer);
+                       Object createdFolder = dialog.getResult()[0];
+                       treeViewer.reveal(createdFolder);
+                       treeViewer.setChecked(createdFolder, true);
+                       treeViewer.setSelection(new StructuredSelection(createdFolder));
+                       updateOKStatus();
+               }
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+        */
+       public void selectionChanged(SelectionChangedEvent event) {
+               updateNewFolderButtonState();
+       }
+
+       public void setInitialFocus(Object focusElement) {
+               fFocusElement = focusElement;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/NewIncludesSymbolsTabBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/NewIncludesSymbolsTabBlock.java
new file mode 100644 (file)
index 0000000..916241c
--- /dev/null
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.ui.dialogs.ICOptionPage;
+
+import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
+
+/**
+ * Block for C/C++ Include Paths and Symbols page for 3.X projects.
+ * 
+ * @deprecated as of CDT 4.0.
+ */
+@Deprecated
+public class NewIncludesSymbolsTabBlock extends AbstractPathOptionBlock implements IStatusChangeListener {
+
+       private CPathIncludeSymbolEntryBasePage fIncludeSymbols;
+
+       private List<CPElement> fCPaths;
+
+       private Composite fComposite;
+
+       public NewIncludesSymbolsTabBlock(IStatusChangeListener context, int pageToShow) {
+               super(context, pageToShow);
+       }
+
+       @Override
+       protected void addTab(ICOptionPage tab) {
+               tab.setContainer(this);
+               tab.createControl(fComposite);
+               addOptionPage(tab);
+       }
+
+       @Override
+       protected void addTabs() {
+       }
+
+       @Override
+       public Control createContents(Composite parent) {
+               fComposite = new Composite(parent, SWT.NONE);
+               fComposite.setLayout(new GridLayout(1, false));
+
+               addPage(fIncludeSymbols);
+               setCurrentPage(fIncludeSymbols);
+               initializingTabs = false;
+
+               if (getCProject() != null) {
+                       fIncludeSymbols.init(getCElement(), fCPaths);
+               }
+               Dialog.applyDialogFont(fComposite);
+               return fComposite;
+       }
+
+       @Override
+       protected List<CPElement> getCPaths() {
+               if (fIncludeSymbols != null) {
+                       return fIncludeSymbols.getCPaths();
+               } 
+               return fCPaths;
+       }
+
+       @Override
+       protected int[] getFilteredTypes() {
+               return new int[] {IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO, IPathEntry.CDT_CONTAINER};
+       }
+
+       @Override
+       protected int[] getAppliedFilteredTypes() {
+               return new int[] {IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO};
+       }
+       
+       @Override
+       protected void initialize(ICElement element, List<CPElement> cPaths) {
+               fCPaths = cPaths;
+
+               if (element instanceof ICProject) {
+            fIncludeSymbols = new CPathIncludeSymbolEntryPage(this);
+        }
+        else {
+            fIncludeSymbols = new CPathIncludeSymbolEntryPerFilePage(this);
+        }
+        if (fIncludeSymbols != null) {
+                       fIncludeSymbols.init(element, cPaths);
+               }
+               doStatusLineUpdate();
+               initializeTimeStamps();
+       }
+       
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus)
+        */
+       public void statusChanged(IStatus status) {
+               switch (status.getSeverity()) {
+                       case IStatus.ERROR :
+                               getPathStatus().setError(status.getMessage());
+                               break;
+                       case IStatus.INFO :
+                               getPathStatus().setInfo(status.getMessage());
+                               break;
+                       case IStatus.WARNING :
+                               getPathStatus().setWarning(status.getMessage());
+                               break;
+                       default:
+                               getPathStatus().setOK();
+               }
+               updateBuildPathStatus();
+               doStatusLineUpdate();
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/NewSourceFolderDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/NewSourceFolderDialog.java
new file mode 100644 (file)
index 0000000..ecb208e
--- /dev/null
@@ -0,0 +1,195 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.StatusDialog;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+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.SelectionButtonDialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringDialogField;
+
+/**
+ * @deprecated as of CDT 4.0. This class was used for property pages
+ * for 3.X style projects.
+ */
+@Deprecated
+public class NewSourceFolderDialog extends StatusDialog {
+
+       private SelectionButtonDialogField fUseProjectButton;
+       private SelectionButtonDialogField fUseFolderButton;
+
+       private StringDialogField fContainerDialogField;
+       private StatusInfo fContainerFieldStatus;
+
+       private IContainer fFolder;
+       private List<IContainer> fExistingFolders;
+       private IProject fCurrProject;
+
+       public NewSourceFolderDialog(Shell parent, String title, IProject project, List<IContainer> existingFolders, CPElement entryToEdit) {
+               super(parent);
+               setTitle(title);
+
+               fContainerFieldStatus = new StatusInfo();
+
+               SourceContainerAdapter adapter = new SourceContainerAdapter();
+
+               fUseProjectButton = new SelectionButtonDialogField(SWT.RADIO);
+               fUseProjectButton.setLabelText(CPathEntryMessages.NewSourceFolderDialog_useproject_button); 
+               fUseProjectButton.setDialogFieldListener(adapter);
+
+               fUseFolderButton = new SelectionButtonDialogField(SWT.RADIO);
+               fUseFolderButton.setLabelText(CPathEntryMessages.NewSourceFolderDialog_usefolder_button); 
+               fUseFolderButton.setDialogFieldListener(adapter);
+
+               fContainerDialogField = new StringDialogField();
+               fContainerDialogField.setDialogFieldListener(adapter);
+               fContainerDialogField.setLabelText(CPathEntryMessages.NewSourceFolderDialog_sourcefolder_label); 
+
+               fUseFolderButton.attachDialogField(fContainerDialogField);
+
+               fFolder = null;
+               fExistingFolders = existingFolders;
+               fCurrProject = project;
+
+               boolean useFolders = true;
+               if (entryToEdit == null) {
+                       fContainerDialogField.setText(""); //$NON-NLS-1$
+               } else {
+                       IPath editPath = entryToEdit.getPath().removeFirstSegments(1);
+                       fContainerDialogField.setText(editPath.toString());
+                       useFolders = !editPath.isEmpty();
+               }
+               fUseFolderButton.setSelection(useFolders);
+               fUseProjectButton.setSelection(!useFolders);
+
+               setHelpAvailable(false);
+       }
+
+       public void setMessage(String message) {
+               fContainerDialogField.setLabelText(message);
+       }
+
+       @Override
+       protected Control createDialogArea(Composite parent) {
+               Composite composite = (Composite) super.createDialogArea(parent);
+
+               Composite inner = new Composite(composite, SWT.NONE);
+               GridLayout layout = new GridLayout();
+               layout.marginHeight = 0;
+               layout.marginWidth = 0;
+               layout.numColumns = 1;
+               inner.setLayout(layout);
+
+               int widthHint = convertWidthInCharsToPixels(50);
+
+               GridData data = new GridData(GridData.FILL_HORIZONTAL);
+               data.widthHint = widthHint;
+
+               if (fExistingFolders.contains(fCurrProject)) {
+                       fContainerDialogField.doFillIntoGrid(inner, 2);
+               } else {
+                       fUseProjectButton.doFillIntoGrid(inner, 1);
+                       fUseFolderButton.doFillIntoGrid(inner, 1);
+                       fContainerDialogField.getTextControl(inner);
+
+                       int horizontalIndent = convertWidthInCharsToPixels(3);
+                       data.horizontalIndent = horizontalIndent;
+               }
+               Control control = fContainerDialogField.getTextControl(null);
+               control.setLayoutData(data);
+
+               fContainerDialogField.postSetFocusOnDialogField(parent.getDisplay());
+               applyDialogFont(composite);
+               return composite;
+       }
+
+       // -------- SourceContainerAdapter --------
+
+       private class SourceContainerAdapter implements IDialogFieldListener {
+
+               // -------- IDialogFieldListener
+
+               public void dialogFieldChanged(DialogField field) {
+                       doStatusLineUpdate();
+               }
+       }
+
+       protected void doStatusLineUpdate() {
+               checkIfPathValid();
+               updateStatus(fContainerFieldStatus);
+       }
+
+       protected void checkIfPathValid() {
+               fFolder = null;
+               IContainer folder = null;
+               if (fUseFolderButton.isSelected()) {
+                       String pathStr = fContainerDialogField.getText();
+                       if (pathStr.length() == 0) {
+                               fContainerFieldStatus.setError(CPathEntryMessages.NewSourceFolderDialog_error_enterpath); 
+                               return;
+                       }
+                       IPath path = fCurrProject.getFullPath().append(pathStr);
+                       IWorkspace workspace = fCurrProject.getWorkspace();
+
+                       IStatus pathValidation = workspace.validatePath(path.toString(), IResource.FOLDER);
+                       if (!pathValidation.isOK()) {
+                               fContainerFieldStatus.setError(NLS.bind(CPathEntryMessages.NewSourceFolderDialog_error_invalidpath, 
+                                               pathValidation.getMessage()));
+                               return;
+                       }
+                       folder = fCurrProject.getFolder(pathStr);
+               } else {
+                       folder = fCurrProject;
+               }
+               if (isExisting(folder)) {
+                       fContainerFieldStatus.setError(CPathEntryMessages.NewSourceFolderDialog_error_pathexists); 
+                       return;
+               }
+               fContainerFieldStatus.setOK();
+               fFolder = folder;
+       }
+
+       private boolean isExisting(IContainer folder) {
+               return fExistingFolders.contains(folder);
+       }
+
+       public IContainer getSourceFolder() {
+               return fFolder;
+       }
+
+       /*
+        * @see org.eclipse.jface.window.Window#configureShell(Shell)
+        */
+       @Override
+       protected void configureShell(Shell newShell) {
+               super.configureShell(newShell);
+               //              WorkbenchHelp.setHelp(newShell,
+               // ICHelpContextIds.NEW_CONTAINER_DIALOG);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ProjectContainerDescriptor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ProjectContainerDescriptor.java
new file mode 100644 (file)
index 0000000..e15bb7e
--- /dev/null
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.wizards.IPathEntryContainerPage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ide.IDE;
+
+/**
+ * @deprecated as of CDT 4.0. This class was used for Path Container Wizard
+ * for 3.X style projects.
+ */
+@Deprecated
+public class ProjectContainerDescriptor implements IContainerDescriptor {
+       private int[] fFilterType;
+       
+       public ProjectContainerDescriptor(int[] filterType) {
+               fFilterType = filterType;
+       }
+
+       public IPathEntryContainerPage createPage() throws CoreException {
+               return new ProjectContainerPage(fFilterType);
+       }
+
+       public String getName() {
+               return CPathEntryMessages.ProjectContainer_label; 
+       }
+       
+       public Image getImage() {
+               return CUIPlugin.getDefault().getWorkbench().getSharedImages().getImage(IDE.SharedImages.IMG_OBJ_PROJECT);
+
+       }
+
+       public boolean canEdit(IPathEntry entry) {
+               return false;
+       }
+
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ProjectContainerPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ProjectContainerPage.java
new file mode 100644 (file)
index 0000000..f8e4a65
--- /dev/null
@@ -0,0 +1,175 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IContainerEntry;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.core.model.IProjectEntry;
+import org.eclipse.cdt.ui.wizards.IPathEntryContainerPage;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.viewsupport.ListContentProvider;
+
+/**
+ * @deprecated as of CDT 4.0. This class was used for Path Container Wizard
+ * for 3.X style projects.
+ */
+@Deprecated
+public class ProjectContainerPage extends WizardPage implements IPathEntryContainerPage {
+
+       private int[] fFilterType;
+       private TableViewer viewer;
+       ICProject fCProject;
+
+       protected ProjectContainerPage(int[] filterType) {
+               super("projectContainerPage"); //$NON-NLS-1$
+               setTitle(CPathEntryMessages.ProjectContainerPage_title); 
+               setDescription(CPathEntryMessages.ProjectContainerPage_description); 
+               setImageDescriptor(CPluginImages.DESC_WIZBAN_ADD_LIBRARY);
+               fFilterType = filterType;
+               validatePage();
+       }
+
+       public void initialize(ICProject project, IPathEntry[] currentEntries) {
+               fCProject = project;
+       }
+
+       public boolean finish() {
+               return true;
+       }
+
+       public IContainerEntry[] getNewContainers() {
+               return new IContainerEntry[0];
+       }
+       
+       IProjectEntry getProjectEntry() {
+               if (viewer != null) {
+                       ISelection selection = viewer.getSelection();
+                       if (selection instanceof IStructuredSelection) {
+                               IStructuredSelection ss = (IStructuredSelection) selection;
+                               if (ss.size() == 1) {
+                                       ICProject project = (ICProject) ss.getFirstElement();
+                                       return CoreModel.newProjectEntry(project.getPath());
+                               }
+                       }
+               }
+               return null;
+       }
+       
+       void setProjectEntry(IProjectEntry entry) {
+               if (entry != null) {
+                       viewer.setSelection(new StructuredSelection(entry));
+               }
+       }
+       
+       public void setSelection(IContainerEntry containerEntry) {
+       }
+
+       public void createControl(Composite parent) {
+               // create a composite with standard margins and spacing
+               Composite container = new Composite(parent, SWT.NONE);
+               GridLayout layout = new GridLayout();
+               layout.numColumns = 2;
+               container.setLayout(layout);
+               Label label = new Label(container, SWT.NULL);
+               label.setText(CPathEntryMessages.ProjectContainerPage_label); 
+               GridData gd = new GridData();
+               gd.horizontalSpan = 2;
+               label.setLayoutData(gd);
+               viewer = new TableViewer(container, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+
+               viewer.setContentProvider(new ListContentProvider());
+               viewer.setLabelProvider(new WorkbenchLabelProvider());
+               viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+                       public void selectionChanged(SelectionChangedEvent event) {
+                               validatePage();
+                       }
+               });
+               gd = new GridData(GridData.FILL_BOTH);
+               gd.widthHint = 400;
+               gd.heightHint = 300;
+               viewer.getTable().setLayoutData(gd);
+               viewer.addFilter(new ViewerFilter() {
+
+                       @Override
+                       public boolean select(Viewer viewer, Object parentElement, Object element) {
+                               return !element.equals(fCProject);
+                       }
+               });
+               setControl(container);
+               initializeView();
+               validatePage();
+       }
+
+       private void initializeView() {
+               List<ICProject> list = new ArrayList<ICProject>();
+               List<IPathEntry> current;
+               try {
+                       current = Arrays.asList(fCProject.getRawPathEntries());
+                       ICProject[] cProjects = CoreModel.getDefault().getCModel().getCProjects();
+                       for (int i = 0; i < cProjects.length; i++) {
+                               boolean added = false;
+                               if (!cProjects[i].equals(fCProject) && !current.contains(CoreModel.newProjectEntry(cProjects[i].getPath()))) {
+                                       IPathEntry[] projEntries = cProjects[i].getRawPathEntries();
+                                       for (IPathEntry projEntrie : projEntries) {
+                                               for (int element : fFilterType) {
+                                                       if (projEntrie.getEntryKind() == element && projEntrie.isExported()) {
+                                                               list.add(cProjects[i]);
+                                                               added = true;
+                                                               break;
+                                                       }
+                                               }
+                                               if (added) {
+                                                       break;
+                                               }
+                                       }
+                               }
+                       }
+               } catch (CModelException e) {
+               }
+               viewer.setInput(list);
+       }
+
+       /**
+        * Method validatePage.
+        */
+       protected void validatePage() {
+               setPageComplete(getSelected() != null);
+       }
+
+       private IPathEntry getSelected() {
+               return getProjectEntry();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/SourceAttachmentBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/SourceAttachmentBlock.java
new file mode 100644 (file)
index 0000000..3c6ffd7
--- /dev/null
@@ -0,0 +1,483 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
+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.Path;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ILibraryEntry;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
+import org.eclipse.cdt.internal.ui.dialogs.TypedElementSelectionValidator;
+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.SelectionButtonDialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
+
+/**
+ * UI to set the source attachment archive and root. Same implementation for both setting attachments for libraries from variable
+ * entries and for normal (internal or external) jar.
+ * 
+ * @deprecated as of CDT 4.0. This class was used for property pages
+ * for 3.X style projects.
+ */
+@Deprecated
+public class SourceAttachmentBlock {
+       private IStatusChangeListener fContext;
+
+       private StringButtonDialogField fFileNameField;
+       private SelectionButtonDialogField fWorkspaceButton;
+       private SelectionButtonDialogField fExternalFolderButton;
+
+       private IStatus fNameStatus;
+
+       private IWorkspaceRoot fWorkspaceRoot;
+
+       private Control fSWTWidget;
+       private CLabel fFullPathResolvedLabel;
+
+       private ICProject fProject;
+       private ILibraryEntry fEntry;
+
+       /**
+        * @deprecated
+        */
+       @Deprecated
+       public SourceAttachmentBlock(IWorkspaceRoot root, IStatusChangeListener context, ILibraryEntry oldEntry) {
+               this(context, oldEntry, null);
+       }
+
+       /**
+        * @param context
+        *            listeners for status updates
+        * @param entry
+        *            The entry to edit
+        * @param project
+        *            Project to which the entry belongs. Can be <code>null</code> if <code>getRunnable</code> is not run and the
+        *            entry does not belong to a container.
+        *  
+        */
+       public SourceAttachmentBlock(IStatusChangeListener context, ILibraryEntry entry, ICProject project) {
+               Assert.isNotNull(entry);
+
+               fContext = context;
+               fEntry = entry;
+               fProject = project;
+
+               fWorkspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+
+               fNameStatus = new StatusInfo();
+
+               SourceAttachmentAdapter adapter = new SourceAttachmentAdapter();
+
+               fFileNameField = new StringButtonDialogField(adapter);
+               fFileNameField.setDialogFieldListener(adapter);
+               fFileNameField.setLabelText(CPathEntryMessages.SourceAttachmentBlock_filename_label); 
+               fFileNameField.setButtonLabel(CPathEntryMessages.SourceAttachmentBlock_filename_externalfile_button); 
+
+               fWorkspaceButton = new SelectionButtonDialogField(SWT.PUSH);
+               fWorkspaceButton.setDialogFieldListener(adapter);
+               fWorkspaceButton.setLabelText(CPathEntryMessages.SourceAttachmentBlock_filename_internal_button); 
+
+               fExternalFolderButton = new SelectionButtonDialogField(SWT.PUSH);
+               fExternalFolderButton.setDialogFieldListener(adapter);
+               fExternalFolderButton.setLabelText(CPathEntryMessages.SourceAttachmentBlock_filename_externalfolder_button); 
+
+               // set the old settings
+               setDefaults();
+       }
+
+       public void setDefaults() {
+               if (fEntry.getSourceAttachmentPath() != null) {
+                       fFileNameField.setText(fEntry.getSourceAttachmentPath().toString());
+               } else {
+                       fFileNameField.setText(""); //$NON-NLS-1$
+               }
+       }
+
+       /**
+        * Gets the source attachment path chosen by the user
+        */
+       public IPath getSourceAttachmentPath() {
+               if (fFileNameField.getText().length() == 0) {
+                       return null;
+               }
+               return new Path(fFileNameField.getText());
+       }
+
+       /**
+        * Gets the source attachment root chosen by the user Returns null to let JCore automatically detect the root.
+        */
+       public IPath getSourceAttachmentRootPath() {
+               return null;
+       }
+
+       /**
+        * Null for now
+        */
+       public IPath getSourceAttachmentPrefixMapping() {
+               return null;
+       }
+
+       /**
+        * Creates the control
+        */
+       public Control createControl(Composite parent) {
+               PixelConverter converter = new PixelConverter(parent);
+
+               fSWTWidget = parent;
+
+               Composite composite = new Composite(parent, SWT.NONE);
+
+               GridLayout layout = new GridLayout();
+               layout.marginHeight = 0;
+               layout.marginWidth = 0;
+               layout.numColumns = 4;
+               composite.setLayout(layout);
+
+               int widthHint = converter.convertWidthInCharsToPixels(60);
+
+               GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               gd.horizontalSpan = 3;
+
+               Label message = new Label(composite, SWT.LEFT);
+               message.setLayoutData(gd);
+               message.setText(NLS.bind(
+                               CPathEntryMessages.SourceAttachmentBlock_message, fEntry.getLibraryPath().lastSegment()));
+
+               fWorkspaceButton.doFillIntoGrid(composite, 1);
+
+               // archive name field
+               fFileNameField.doFillIntoGrid(composite, 4);
+               LayoutUtil.setWidthHint(fFileNameField.getTextControl(null), widthHint);
+               LayoutUtil.setHorizontalGrabbing(fFileNameField.getTextControl(null), true);
+
+               // aditional 'browse workspace' button for normal jars
+               DialogField.createEmptySpace(composite, 3);
+
+               fExternalFolderButton.doFillIntoGrid(composite, 1);
+
+               fFileNameField.postSetFocusOnDialogField(parent.getDisplay());
+
+               Dialog.applyDialogFont(composite);
+
+               //WorkbenchHelp.setHelp(composite, IJavaHelpContextIds.SOURCE_ATTACHMENT_BLOCK);
+               return composite;
+       }
+
+       private class SourceAttachmentAdapter implements IStringButtonAdapter, IDialogFieldListener {
+               // -------- IStringButtonAdapter --------
+               public void changeControlPressed(DialogField field) {
+                       attachmentChangeControlPressed(field);
+               }
+
+               // ---------- IDialogFieldListener --------
+               public void dialogFieldChanged(DialogField field) {
+                       attachmentDialogFieldChanged(field);
+               }
+       }
+
+       void attachmentChangeControlPressed(DialogField field) {
+               if (field == fFileNameField) {
+                       IPath jarFilePath = chooseExtJarFile();
+                       if (jarFilePath != null) {
+                               fFileNameField.setText(jarFilePath.toString());
+                       }
+               }
+       }
+
+       // ---------- IDialogFieldListener --------
+
+       void attachmentDialogFieldChanged(DialogField field) {
+               if (field == fFileNameField) {
+                       fNameStatus = updateFileNameStatus();
+               } else if (field == fWorkspaceButton) {
+                       IPath jarFilePath = chooseInternalJarFile();
+                       if (jarFilePath != null) {
+                               fFileNameField.setText(jarFilePath.toString());
+                       }
+                       return;
+               } else if (field == fExternalFolderButton) {
+                       IPath folderPath = chooseExtFolder();
+                       if (folderPath != null) {
+                               fFileNameField.setText(folderPath.toString());
+                       }
+                       return;
+               }
+               doStatusLineUpdate();
+       }
+
+       private void doStatusLineUpdate() {
+               fFileNameField.enableButton(canBrowseFileName());
+
+               // set the resolved path for variable jars
+               if (fFullPathResolvedLabel != null) {
+                       fFullPathResolvedLabel.setText(getResolvedLabelString(fFileNameField.getText(), true));
+               }
+
+               IStatus status = StatusUtil.getMostSevere(new IStatus[]{fNameStatus});
+               fContext.statusChanged(status);
+       }
+
+       private boolean canBrowseFileName() {
+               return true;
+       }
+
+       private String getResolvedLabelString(String path, boolean osPath) {
+               IPath resolvedPath = getResolvedPath(new Path(path));
+               if (resolvedPath != null) {
+                       if (osPath) {
+                               return resolvedPath.toOSString();
+                       }
+                       return resolvedPath.toString();
+               }
+               return ""; //$NON-NLS-1$
+       }
+
+       /*
+        * Do substitution here
+        */
+       private IPath getResolvedPath(IPath path) {
+               return path;
+       }
+
+       private IStatus updateFileNameStatus() {
+               StatusInfo status = new StatusInfo();
+
+               String fileName = fFileNameField.getText();
+               if (fileName.length() == 0) {
+                       // no source attachment
+                       return status;
+               }
+               if (!Path.EMPTY.isValidPath(fileName)) {
+                       status.setError(CPathEntryMessages.SourceAttachmentBlock_filename_error_notvalid); 
+                       return status;
+               }
+               IPath filePath = new Path(fileName);
+               File file = filePath.toFile();
+               IResource res = fWorkspaceRoot.findMember(filePath);
+               if (res != null && res.getLocation() != null) {
+                       file = res.getLocation().toFile();
+               }
+               if (!file.exists()) {
+                       String message = NLS.bind(
+                                       CPathEntryMessages.SourceAttachmentBlock_filename_error_filenotexists, filePath.toString());
+                       status.setError(message);
+                       return status;
+               }
+               return status;
+       }
+
+       /*
+        * Opens a dialog to choose a jar from the file system.
+        */
+       private IPath chooseExtJarFile() {
+               IPath currPath = new Path(fFileNameField.getText());
+               if (currPath.isEmpty()) {
+                       currPath = fEntry.getPath();
+               }
+
+               if (ArchiveFileFilter.isArchivePath(currPath)) {
+                       currPath = currPath.removeLastSegments(1);
+               }
+
+               FileDialog dialog = new FileDialog(getShell());
+               dialog.setText(CPathEntryMessages.SourceAttachmentBlock_extjardialog_text); 
+               dialog.setFilterExtensions(new String[]{"*.jar;*.zip"}); //$NON-NLS-1$
+               dialog.setFilterPath(currPath.toOSString());
+               String res = dialog.open();
+               if (res != null) {
+                       return new Path(res).makeAbsolute();
+               }
+               return null;
+       }
+
+       private IPath chooseExtFolder() {
+               IPath currPath = new Path(fFileNameField.getText());
+               if (currPath.isEmpty()) {
+                       currPath = fEntry.getPath();
+               }
+               if (ArchiveFileFilter.isArchivePath(currPath)) {
+                       currPath = currPath.removeLastSegments(1);
+               }
+
+               DirectoryDialog dialog = new DirectoryDialog(getShell());
+               dialog.setText(CPathEntryMessages.SourceAttachmentBlock_extfolderdialog_text); 
+               dialog.setFilterPath(currPath.toOSString());
+               String res = dialog.open();
+               if (res != null) {
+                       return new Path(res).makeAbsolute();
+               }
+               return null;
+       }
+
+       /*
+        * Opens a dialog to choose an internal jar.
+        */
+       private IPath chooseInternalJarFile() {
+               String initSelection = fFileNameField.getText();
+
+               Class<?>[] acceptedClasses = new Class<?>[]{IFolder.class, IFile.class};
+               TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses, false);
+
+               ViewerFilter filter = new ArchiveFileFilter(null, false);
+
+               ILabelProvider lp = new WorkbenchLabelProvider();
+               ITreeContentProvider cp = new WorkbenchContentProvider();
+
+               IResource initSel = null;
+               if (initSelection.length() > 0) {
+                       initSel = fWorkspaceRoot.findMember(new Path(initSelection));
+               }
+               if (initSel == null) {
+                       initSel = fWorkspaceRoot.findMember(fEntry.getPath());
+               }
+
+               FolderSelectionDialog dialog = new FolderSelectionDialog(getShell(), lp, cp);
+               dialog.setAllowMultiple(false);
+               dialog.setValidator(validator);
+               dialog.addFilter(filter);
+               dialog.setTitle(CPathEntryMessages.SourceAttachmentBlock_intjardialog_title); 
+               dialog.setMessage(CPathEntryMessages.SourceAttachmentBlock_intjardialog_message); 
+               dialog.setInput(fWorkspaceRoot);
+               dialog.setInitialSelection(initSel);
+               if (dialog.open() == Window.OK) {
+                       IResource res = (IResource)dialog.getFirstResult();
+                       return res.getFullPath();
+               }
+               return null;
+       }
+
+       private Shell getShell() {
+               if (fSWTWidget != null) {
+                       return fSWTWidget.getShell();
+               }
+               return CUIPlugin.getActiveWorkbenchShell();
+       }
+
+       /**
+        * Creates a runnable that sets the source attachment by modifying the project's classpath.
+        */
+       public IRunnableWithProgress getRunnable(final ICProject jproject, final Shell shell) {
+               fProject = jproject;
+               return getRunnable(shell);
+       }
+
+       /**
+        * Creates a runnable that sets the source attachment by modifying the project's classpath or updating a container.
+        */
+       public IRunnableWithProgress getRunnable(final Shell shell) {
+               return new IRunnableWithProgress() {
+
+                       public void run(IProgressMonitor monitor) throws InvocationTargetException {
+                               try {
+                                       attachSource(shell, monitor);
+                               } catch (CoreException e) {
+                                       throw new InvocationTargetException(e);
+                               }
+                       }
+               };
+       }
+
+       protected void attachSource(final Shell shell, IProgressMonitor monitor) throws CoreException {
+               boolean isExported = fEntry.isExported();
+               ILibraryEntry newEntry;
+               newEntry = CoreModel.newLibraryEntry(fEntry.getPath(), fEntry.getBasePath(), fEntry.getLibraryPath(),
+                               getSourceAttachmentPath(), getSourceAttachmentRootPath(), getSourceAttachmentPrefixMapping(), isExported);
+               updateProjectPathEntry(shell, fProject, newEntry, monitor);
+       }
+
+       private void updateProjectPathEntry(Shell shell, ICProject cproject, ILibraryEntry newEntry, IProgressMonitor monitor)
+                       throws CModelException {
+               IPathEntry[] oldClasspath = cproject.getRawPathEntries();
+               int nEntries = oldClasspath.length;
+               ArrayList<IPathEntry> newEntries = new ArrayList<IPathEntry>(nEntries + 1);
+               int entryKind = newEntry.getEntryKind();
+               IPath jarPath = newEntry.getPath();
+               boolean found = false;
+               for (int i = 0; i < nEntries; i++) {
+                       IPathEntry curr = oldClasspath[i];
+                       if (curr.getEntryKind() == entryKind && curr.getPath().equals(jarPath)) {
+                               // add modified entry
+                               newEntries.add(newEntry);
+                               found = true;
+                       } else {
+                               newEntries.add(curr);
+                       }
+               }
+               if (!found) {
+                       if (newEntry.getSourceAttachmentPath() == null || !putJarOnClasspathDialog(shell)) {
+                               return;
+                       }
+                       // add new
+                       newEntries.add(newEntry);
+               }
+               IPathEntry[] newPathEntries = newEntries.toArray(new IPathEntry[newEntries.size()]);
+               cproject.setRawPathEntries(newPathEntries, monitor);
+       }
+
+       private boolean putJarOnClasspathDialog(Shell shell) {
+               final boolean[] result = new boolean[1];
+               shell.getDisplay().syncExec(new Runnable() {
+
+                       public void run() {
+                               String title = CPathEntryMessages.SourceAttachmentBlock_putoncpdialog_title; 
+                               String message = CPathEntryMessages.SourceAttachmentBlock_putoncpdialog_message; 
+                               result[0] = MessageDialog.openQuestion(CUIPlugin.getActiveWorkbenchShell(), title, message);
+                       }
+               });
+               return result[0];
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/SourceAttachmentDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/SourceAttachmentDialog.java
new file mode 100644 (file)
index 0000000..b604576
--- /dev/null
@@ -0,0 +1,181 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.dialogs.cpaths;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.dialogs.StatusDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ILibraryEntry;
+import org.eclipse.cdt.core.model.IPathEntry;
+
+import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
+import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
+
+/**
+ * A dialog to configure the source attachment of a library (library and zip archive).
+ *
+ * @deprecated as of CDT 4.0. This class was used for property pages
+ * for 3.X style projects.
+ */
+@Deprecated
+public class SourceAttachmentDialog extends StatusDialog {
+       
+       private SourceAttachmentBlock fSourceAttachmentBlock;
+       private boolean fApplyChanges;
+
+       /**
+        * Creates an instance of the SourceAttachmentDialog. After
+        * <code>open</code>, the edited paths can be access with
+        * <code>getSourceAttachmentPath</code> and
+        * <code>getSourceAttachmentRootPath</code>. 
+        * @param parent Parent shell for the dialog
+        * @param entry The entry to edit
+        * @param project Project to which the entry belongs. Can be
+        * <code>null</code> if <code>applyChanges</code> is false and the entry
+        * does not belong to a container.
+        * @param applyChanges If set to <code>true</code>, changes are applied on
+        * OK. If set to false, no changes are commited. When changes are applied,
+        * classpath entries which are not found on the classpath will be added as
+        * new libraries.
+        */
+       public SourceAttachmentDialog(Shell parent, ILibraryEntry entry, ICProject project, boolean applyChanges) {
+               super(parent);
+               fApplyChanges= applyChanges;
+
+               IStatusChangeListener listener= new IStatusChangeListener() {
+                       public void statusChanged(IStatus status) {
+                               updateStatus(status);
+                       }
+               };              
+               fSourceAttachmentBlock= new SourceAttachmentBlock(listener, entry, project);                    
+       
+               setTitle(CPathEntryMessages.SourceAttachmentDialog_title); 
+               setHelpAvailable(false);
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+        */
+       @Override
+       protected void configureShell(Shell newShell) {
+               super.configureShell(newShell);
+               //WorkbenchHelp.setHelp(newShell, IJavaHelpContextIds.SOURCE_ATTACHMENT_DIALOG);
+       }               
+                       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected Control createDialogArea(Composite parent) {
+               Composite composite= (Composite) super.createDialogArea(parent);
+                       
+               Control inner= createSourceAttachmentControls(composite);
+               inner.setLayoutData(new GridData(GridData.FILL_BOTH));                  
+               applyDialogFont(composite);             
+               return composite;
+       }
+
+       /**
+        * Creates the controls for the source attachment configuration.
+        */     
+       protected Control createSourceAttachmentControls(Composite composite) {
+               return fSourceAttachmentBlock.createControl(composite);
+       }
+       
+       
+       /**
+        * Returns the configured source attachment path.
+        */
+       public IPath getSourceAttachmentPath() {
+               return fSourceAttachmentBlock.getSourceAttachmentPath();
+       }
+
+       /**
+        * Returns the configured source attachment path root. Sonce 2.1 source
+        * attachment roots are autodetected. The value returned is therefore always
+        * null.
+        */     
+       public IPath getSourceAttachmentRootPath() {
+               return fSourceAttachmentBlock.getSourceAttachmentRootPath();
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+        */
+       @Override
+       protected void okPressed() {
+               super.okPressed();
+               if (fApplyChanges) {
+                       try {
+                               IRunnableWithProgress runnable= getRunnable();
+                               new ProgressMonitorDialog(getShell()).run(true, true, runnable);                                                
+       
+                       } catch (InvocationTargetException e) {
+                               String title= CPathEntryMessages.SourceAttachmentDialog_error_title; 
+                               String message= CPathEntryMessages.SourceAttachmentDialog_error_message; 
+                               ExceptionHandler.handle(e, getShell(), title, message);
+       
+                       } catch (InterruptedException e) {
+                               // cancelled
+                       }
+               }
+       }
+       
+       /**
+        * Creates the runnable that configures the project with the new source
+        * attachements.
+     */
+       protected IRunnableWithProgress getRunnable() {
+               return fSourceAttachmentBlock.getRunnable(getShell());
+       }
+
+       /**
+        * Helper method that tests if an classpath entry can be found in a
+        * container. <code>null</code> is returned if the entry can not be found
+        * or if the container does not allows the configuration of source
+        * attachments
+        * @param jproject The container's parent project
+        * @param containerPath The path of the container
+        * @param libPath The path of the bibrary to be found
+        * @return IClasspathEntry A classpath entry from the container of
+        * <code>null</code> if the container can not be modified.
+     */
+       public static IPathEntry getPathEntryToEdit(ICProject jproject, IPath containerPath, IPath libPath) throws CModelException {
+               //IPathEntryContainer container= CoreModel.getPathEntryContainer(containerPath, jproject);
+               //PathEntryContainerInitializer initializer= CoreModel.getPathEntryContainerInitializer(containerPath.segment(0));
+               //if (container != null && initializer != null && initializer.canUpdateClasspathContainer(containerPath, jproject)) {
+               //      IPathEntry[] entries= container.getPathEntries();
+               //      for (int i= 0; i < entries.length; i++) {
+               //              IPathEntry curr= entries[i];
+               //              IPathEntry resolved= CoreModel.getResolvedPathEntry(curr);
+               //              if (resolved != null && libPath.equals(resolved.getPath())) {
+               //                      return curr; // return the real entry
+               //              }
+               //      }
+               //}
+               return null; // attachment not possible
+       }       
+       
+       
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/BasicSelectionTransferDragAdapter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/BasicSelectionTransferDragAdapter.java
new file mode 100644 (file)
index 0000000..15841b1
--- /dev/null
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    QNX Software Systems - Initial API and implementation
+ *    Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.dnd;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DragSourceAdapter;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.dnd.Transfer;
+
+public class BasicSelectionTransferDragAdapter extends DragSourceAdapter implements TransferDragSourceListener {
+       
+       private ISelectionProvider fProvider;
+       
+       public BasicSelectionTransferDragAdapter(ISelectionProvider provider) {
+               Assert.isNotNull(provider);
+               fProvider= provider;
+       }
+
+       /**
+        * @see TransferDragSourceListener#getTransfer
+        */
+       public Transfer getTransfer() {
+               return LocalSelectionTransfer.getTransfer();
+       }
+       
+       /* non Java-doc
+        * @see org.eclipse.swt.dnd.DragSourceListener#dragStart
+        */
+       @Override
+       public void dragStart(DragSourceEvent event) {
+               ISelection selection= fProvider.getSelection();
+               LocalSelectionTransfer.getTransfer().setSelection(selection);
+               LocalSelectionTransfer.getTransfer().setSelectionSetTime(event.time & 0xFFFFFFFFL);
+               event.doit= isDragable(selection);
+       }
+       
+       /**
+        * Checks if the elements contained in the given selection can
+        * be dragged.
+        * <p>
+        * Subclasses may override.
+        * 
+        * @param selection containing the elements to be dragged
+        */
+       protected boolean isDragable(ISelection selection) {
+               return true;
+       }
+
+
+       /* non Java-doc
+        * @see org.eclipse.swt.dnd.DragSourceListener#dragSetData
+        */             
+       @Override
+       public void dragSetData(DragSourceEvent event) {
+               // For consistency set the data to the selection even though
+               // the selection is provided by the LocalSelectionTransfer
+               // to the drop target adapter.
+               event.data= LocalSelectionTransfer.getTransfer().getSelection();
+       }
+
+
+       /* non Java-doc
+        * @see org.eclipse.swt.dnd.DragSourceListener#dragFinished
+        */     
+       @Override
+       public void dragFinished(DragSourceEvent event) {
+               // Make sure we don't have to do any remaining work
+               Assert.isTrue(event.detail != DND.DROP_MOVE);
+               LocalSelectionTransfer.getTransfer().setSelection(null);
+               LocalSelectionTransfer.getTransfer().setSelectionSetTime(0);
+       }       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/CDTViewerDragAdapter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/CDTViewerDragAdapter.java
new file mode 100644 (file)
index 0000000..7fd2acb
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.dnd;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.swt.dnd.DragSourceEvent;
+
+/**
+ * CDTViewerDragAdapter
+ */
+public class CDTViewerDragAdapter extends DelegatingDragAdapter {
+
+       private StructuredViewer fViewer;
+
+       public CDTViewerDragAdapter(StructuredViewer viewer, TransferDragSourceListener[] listeners) {
+               super(listeners);
+               Assert.isNotNull(viewer);
+               fViewer= viewer;
+       }
+       
+       @Override
+       public void dragStart(DragSourceEvent event) {
+               IStructuredSelection selection= (IStructuredSelection)fViewer.getSelection();
+               if (selection.isEmpty()) {
+                       event.doit= false;
+                       return; 
+               }
+               super.dragStart(event);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/CDTViewerDropAdapter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/CDTViewerDropAdapter.java
new file mode 100644 (file)
index 0000000..858e1c6
--- /dev/null
@@ -0,0 +1,268 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2006 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.dnd;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.DropTargetListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Item;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.TreeItem;
+
+/**
+ * A drag and drop adapter to be used together with structured viewers.
+ * The adapater delegates the <code>dragEnter</code>, <code>dragOperationChanged
+ * </code>, <code>dragOver</code> and <code>dropAccept</code> method to the
+ * <code>validateDrop</code> method. Furthermore it adds location feedback.
+ */
+public class CDTViewerDropAdapter implements DropTargetListener {
+
+       /**
+        * Constant describing the position of the mouse cursor relative 
+        * to the target object.  This means the mouse is not positioned
+        * over or near any valid target.
+        */
+       public static final int LOCATION_NONE= DND.FEEDBACK_NONE;
+       
+       /**
+        * Constant describing the position of the mouse cursor relative 
+        * to the target object.  This means the mouse is positioned
+        * directly on the target.
+        */
+       public static final int LOCATION_ON= DND.FEEDBACK_SELECT;
+       
+       /**
+        * Constant describing the position of the mouse cursor relative 
+        * to the target object.  This means the mouse is positioned
+        * slightly before the target.
+        */
+       public static final int LOCATION_BEFORE= DND.FEEDBACK_INSERT_BEFORE;
+       
+       /**
+        * Constant describing the position of the mouse cursor relative 
+        * to the target object.  This means the mouse is positioned
+        * slightly after the target.
+        */
+       public static final int LOCATION_AFTER= DND.FEEDBACK_INSERT_AFTER;
+       
+       /**
+        * The threshold used to determine if the mouse is before or after
+        * an item.
+        */
+       private static final int LOCATION_EPSILON= 5; 
+       
+       /**
+        * Style to enable location feedback.
+        */
+       public static final int INSERTION_FEEDBACK= 1 << 1; 
+
+       private StructuredViewer fViewer;
+       private int fFeedback;
+       private boolean fShowInsertionFeedback;
+       private int fRequestedOperation;
+       private int fLastOperation;
+       protected int fLocation;
+       protected Object fTarget;
+
+       public CDTViewerDropAdapter(StructuredViewer viewer, int feedback) {
+               Assert.isNotNull(viewer);
+               fViewer= viewer;
+               fFeedback= feedback;
+               fLastOperation= -1;
+       }
+
+       /**
+        * Controls whether the drop adapter shows insertion feedback or not.
+        * 
+        * @param showInsertionFeedback <code>true</code> if the drop adapter is supposed
+        *      to show insertion feedback. Otherwise <code>false</code>
+        */
+       public void showInsertionFeedback(boolean showInsertionFeedback) {
+               fShowInsertionFeedback= showInsertionFeedback;
+       }
+       
+       /**
+        * Returns the viewer this adapter is working on.
+        */
+       protected StructuredViewer getViewer() {
+               return fViewer;
+       } 
+       
+       //---- Hooks to override -----------------------------------------------------
+       
+       /**
+        * The actual drop has occurred. Calls <code>drop(Object target, DropTargetEvent event)
+        * </code>.
+        * @see DropTargetListener#drop(org.eclipse.swt.dnd.DropTargetEvent)
+        */      
+       public void drop(DropTargetEvent event) {
+               drop(fTarget, event);
+       }
+       
+       /**
+        * The actual drop has occurred.
+        * @param target the drop target in form of a domain element.
+        * @param event the drop traget event
+        */      
+       public void drop(Object target, DropTargetEvent event) {
+       }
+       
+       /**
+        * Checks if the drop is valid. The method calls <code>validateDrop
+        * (Object target, DropTargetEvent event). Implementors can alter the 
+        * <code>currentDataType</code> field and the <code>detail</code> field 
+        * to give feedback about drop acceptence.
+        */
+       public void validateDrop(DropTargetEvent event) {
+               validateDrop(fTarget, event, fRequestedOperation);
+       }
+       
+       /**
+        * Checks if the drop on the current target is valid. The method
+        * can alter the <code>currentDataType</code> field and the <code>
+        * detail</code> field to give feedback about drop acceptence.
+        * @param target the drop target in form of a domain element.
+        * @param event the drop traget event
+        * @param operation the operation requested by the user.
+        */
+       public void validateDrop(Object target, DropTargetEvent event, int operation) {
+       }
+       
+       public void dragEnter(DropTargetEvent event) {
+               dragOperationChanged(event);
+       }
+       
+       public void dragLeave(DropTargetEvent event) {
+               fTarget= null;
+               fLocation= LOCATION_NONE;
+       }
+       
+       public void dragOperationChanged(DropTargetEvent event) {
+               fRequestedOperation= event.detail;
+               fTarget= computeTarget(event);
+               fLocation= computeLocation(event);
+               validateDrop(event);
+               fLastOperation= event.detail;
+               computeFeedback(event);
+       }
+       
+       public void dragOver(DropTargetEvent event) {
+               Object oldTarget= fTarget;
+               fTarget= computeTarget(event);
+               
+               //set the location feedback
+               int oldLocation= fLocation;
+               fLocation= computeLocation(event);
+               if (oldLocation != fLocation || oldTarget != fTarget || fLastOperation != event.detail) {
+                       validateDrop(event);
+                       fLastOperation= event.detail;
+               } else {
+                       event.detail= fLastOperation;
+               }
+               computeFeedback(event);
+       }
+       
+       public void dropAccept(DropTargetEvent event) {
+               fTarget= computeTarget(event);
+               validateDrop(event);
+               fLastOperation= event.detail;
+       }
+       
+       /**
+        * Returns the data held by <code>event.item</code>. Inside a viewer
+        * this corresponds to the items data model element.
+        */
+       protected Object computeTarget(DropTargetEvent event) {
+               return event.item == null ? null : event.item.getData();
+       }
+       
+       /**
+        * Returns the position of the given coordinates relative to the given target.
+        * The position is determined to be before, after, or on the item, based on 
+        * some threshold value. The return value is one of the LOCATION_* constants 
+        * defined in this class.
+        */
+       final protected int computeLocation(DropTargetEvent event) {
+               if (!(event.item instanceof Item))
+                       return LOCATION_NONE;
+               
+               Item item= (Item) event.item;
+               Point coordinates= fViewer.getControl().toControl(new Point(event.x, event.y));
+               Rectangle bounds= getBounds(item);
+               if (bounds == null) {
+                       return LOCATION_NONE;
+               }
+               if ((coordinates.y - bounds.y) < LOCATION_EPSILON) {
+                       return LOCATION_BEFORE;
+               }
+               if ((bounds.y + bounds.height - coordinates.y) < LOCATION_EPSILON) {
+                       return LOCATION_AFTER;
+               }
+               return LOCATION_ON;
+       }
+
+       /**
+        * Returns the bounds of the given item, or <code>null</code> if it is not a 
+        * valid type of item.
+        */
+       private Rectangle getBounds(Item item) {
+               if (item instanceof TreeItem)
+                       return ((TreeItem) item).getBounds();
+                       
+               if (item instanceof TableItem)
+                       return ((TableItem) item).getBounds(0);
+                       
+               return null;
+       }
+
+       /**
+        * Sets the drag under feedback corresponding to the value of <code>fLocation</code>
+        * and the <code>INSERTION_FEEDBACK</code> style bit.
+        */
+       protected void computeFeedback(DropTargetEvent event) {
+               if (!fShowInsertionFeedback && fLocation != LOCATION_NONE) {
+                       event.feedback= DND.FEEDBACK_SELECT;
+               } else {
+                       event.feedback= fLocation;
+               }
+               event.feedback|= fFeedback;
+       }
+       
+       /**
+        * Sets the drop operation to </code>DROP_NODE<code>.
+        */
+       protected void clearDropOperation(DropTargetEvent event) {
+               event.detail= DND.DROP_NONE;
+       }
+       
+       /**
+        * Returns the requested drop operation.
+        */
+       protected int getRequestedOperation() {
+               return fRequestedOperation;
+       } 
+       
+       protected void setDefaultFeedback(int feedback) {
+               fFeedback= feedback;
+       }
+       
+       //---- helper methods to test DnD 
+       
+       public void internalTestSetLocation(int location) {
+               fLocation= location;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/DelegatingDragAdapter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/DelegatingDragAdapter.java
new file mode 100644 (file)
index 0000000..1adb529
--- /dev/null
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dnd;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.dnd.DragSource;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.dnd.DragSourceListener;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.dnd.TransferData;
+
+/**
+ * A delegating drag adapter negotiates between a set of <code>TransferDragSourceListener</code>s
+ * On <code>dragStart</code> the adapter determines the listener to be used for any further
+ * <code>drag*</code> callbacks.
+ */
+public class DelegatingDragAdapter implements DragSourceListener {
+       private TransferDragSourceListener[] fPossibleListeners;
+       private List<TransferDragSourceListener> fActiveListeners;
+       private TransferDragSourceListener fFinishListener;
+       
+       public DelegatingDragAdapter(TransferDragSourceListener[] listeners) {
+               setPossibleListeners(listeners);
+       }
+       
+       protected void setPossibleListeners(TransferDragSourceListener[] listeners) {
+               Assert.isNotNull(listeners);
+               Assert.isTrue(fActiveListeners == null, "Can only set possible listeners before drag operation has started"); //$NON-NLS-1$
+               fPossibleListeners= listeners;
+       }
+       
+       /* non Java-doc
+        * @see DragSourceListener
+        */
+       public void dragStart(DragSourceEvent event) {
+               fFinishListener= null;
+               boolean saveDoit= event.doit;
+               Object saveData= event.data;
+               boolean doIt= false;
+               List<Transfer> transfers= new ArrayList<Transfer>(fPossibleListeners.length);
+               fActiveListeners= new ArrayList<TransferDragSourceListener>(fPossibleListeners.length);
+               
+               for (TransferDragSourceListener listener : fPossibleListeners) {
+                       event.doit= saveDoit;
+                       listener.dragStart(event);
+                       if (event.doit) {
+                               transfers.add(listener.getTransfer());
+                               fActiveListeners.add(listener);
+                       }
+                       doIt= doIt || event.doit;
+               }
+               if (doIt) {
+                       ((DragSource)event.widget).setTransfer(transfers.toArray(new Transfer[transfers.size()]));
+               }
+               event.data= saveData;
+               event.doit= doIt;
+       }
+
+       /* non Java-doc
+        * @see DragSourceListener
+        */
+       public void dragSetData(DragSourceEvent event) {
+               fFinishListener= getListener(event.dataType);
+               if (fFinishListener != null) {
+                       fFinishListener.dragSetData(event);
+               }
+       }
+       
+       /* non Java-doc
+        * @see DragSourceListener
+        */
+       public void dragFinished(DragSourceEvent event) {
+               try{
+                       if (fFinishListener != null) {
+                               fFinishListener.dragFinished(event);
+                       } else {
+                               // If the user presses Escape then we get a dragFinished without
+                               // getting a dragSetData before.
+                               fFinishListener= getListener(event.dataType);
+                               if (fFinishListener != null) {
+                                       fFinishListener.dragFinished(event);
+                               }
+                       }
+               } finally{
+                       fFinishListener= null;
+                       fActiveListeners= null;
+               }       
+       }
+       
+       private TransferDragSourceListener getListener(TransferData type) {
+               if (type == null)
+                       return null;
+                       
+               for (TransferDragSourceListener listener : fActiveListeners) {
+                       if (listener.getTransfer().isSupportedType(type))
+                               return listener;
+               }
+               return null;
+       }       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/DelegatingDropAdapter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/DelegatingDropAdapter.java
new file mode 100644 (file)
index 0000000..c2134bf
--- /dev/null
@@ -0,0 +1,264 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2006 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.dnd;
+
+import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.util.SafeRunnable;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.DropTargetListener;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.dnd.TransferData;
+
+/**
+ * DelegatingDropAdapter
+ */
+public class DelegatingDropAdapter implements DropTargetListener {
+       private TransferDropTargetListener[] fListeners;
+       TransferDropTargetListener fCurrentListener;
+       private int fOriginalDropType;
+
+       /**
+        * Creates a new delegating drop adapter.
+        * 
+        * @param listeners an array of potential listeners
+        */
+       public DelegatingDropAdapter(TransferDropTargetListener[] listeners) {
+               Assert.isNotNull(listeners);
+               fListeners= listeners;
+       }
+
+       /**
+        * The cursor has entered the drop target boundaries. The current listener
+        * is updated, and <code>#dragEnter()</code> is forwarded to the current
+        * listener.
+        * 
+        * @param event the drop target event
+        * @see DropTargetListener#dragEnter(DropTargetEvent)
+        */
+       public void dragEnter(DropTargetEvent event) {
+               fOriginalDropType= event.detail;
+               updateCurrentListener(event);
+       }
+
+       /**
+        * The cursor has left the drop target boundaries. The event is forwarded to
+        * the current listener.
+        * 
+        * @param event the drop target event
+        * @see DropTargetListener#dragLeave(DropTargetEvent)
+        */
+       public void dragLeave(final DropTargetEvent event) {
+               setCurrentListener(null, event);
+       }
+
+       /**
+        * The operation being performed has changed (usually due to the user
+        * changing a drag modifier key while dragging). Updates the current
+        * listener and forwards this event to that listener.
+        * 
+        * @param event the drop target event
+        * @see DropTargetListener#dragOperationChanged(DropTargetEvent)
+        */
+       public void dragOperationChanged(final DropTargetEvent event) {
+               fOriginalDropType= event.detail;
+               TransferDropTargetListener oldListener= getCurrentListener();
+               updateCurrentListener(event);
+               final TransferDropTargetListener newListener= getCurrentListener();
+               // only notify the current listener if it hasn't changed based on the
+               // operation change. otherwise the new listener would get a dragEnter
+               // followed by a dragOperationChanged with the exact same event.
+               if (newListener != null && newListener == oldListener) {
+                       SafeRunner.run(new SafeRunnable() {
+                               public void run() throws Exception {
+                                       newListener.dragOperationChanged(event);
+                               }
+                       });
+               }
+       }
+
+       /**
+        * The cursor is moving over the drop target. Updates the current listener
+        * and forwards this event to that listener. If no listener can handle the
+        * drag operation the <code>event.detail</code> field is set to
+        * <code>DND.DROP_NONE</code> to indicate an invalid drop.
+        * 
+        * @param event the drop target event
+        * @see DropTargetListener#dragOver(DropTargetEvent)
+        */
+       public void dragOver(final DropTargetEvent event) {
+               TransferDropTargetListener oldListener= getCurrentListener();
+               updateCurrentListener(event);
+               final TransferDropTargetListener newListener= getCurrentListener();
+
+               // only notify the current listener if it hasn't changed based on the
+               // drag over. otherwise the new listener would get a dragEnter
+               // followed by a dragOver with the exact same event.
+               if (newListener != null && newListener == oldListener) {
+                       SafeRunner.run(new SafeRunnable() {
+                               public void run() throws Exception {
+                                       newListener.dragOver(event);
+                               }
+                       });
+               }
+       }
+
+       /**
+        * Forwards this event to the current listener, if there is one. Sets the
+        * current listener to <code>null</code> afterwards.
+        * 
+        * @param event the drop target event
+        * @see DropTargetListener#drop(DropTargetEvent)
+        */
+       public void drop(final DropTargetEvent event) {
+               updateCurrentListener(event);
+               if (getCurrentListener() != null) {
+                       SafeRunner.run(new SafeRunnable() {
+                               public void run() throws Exception {
+                                       getCurrentListener().drop(event);
+                               }
+                       });
+               }
+               setCurrentListener(null, event);
+       }
+
+       /**
+        * Forwards this event to the current listener if there is one.
+        * 
+        * @param event the drop target event
+        * @see DropTargetListener#dropAccept(DropTargetEvent)
+        */
+       public void dropAccept(final DropTargetEvent event) {
+               if (getCurrentListener() != null) {
+                       SafeRunner.run(new SafeRunnable() {
+                               public void run() throws Exception {
+                                       getCurrentListener().dropAccept(event);
+                               }
+                       });
+               }
+       }
+
+       /**
+        * Returns the listener which currently handles drop events.
+        * 
+        * @return the <code>TransferDropTargetListener</code> which currently
+        *         handles drop events.
+        */
+       TransferDropTargetListener getCurrentListener() {
+               return fCurrentListener;
+       }
+
+       /**
+        * Returns the transfer data type supported by the given listener. Returns
+        * <code>null</code> if the listener does not support any of the specified
+        * data types.
+        * 
+        * @param dataTypes available data types
+        * @param listener <code>TransferDropTargetListener</code> to use for
+        *        testing supported data types.
+        * @return the transfer data type supported by the given listener or
+        *         <code>null</code>.
+        */
+       private TransferData getSupportedTransferType(TransferData[] dataTypes, TransferDropTargetListener listener) {
+               for (int i= 0; i < dataTypes.length; i++) {
+                       if (listener.getTransfer().isSupportedType(dataTypes[i])) {
+                               return dataTypes[i];
+                       }
+               }
+               return null;
+       }
+
+       /**
+        * Returns the combined set of <code>Transfer</code> types of all
+        * <code>TransferDropTargetListeners</code>.
+        * 
+        * @return the combined set of <code>Transfer</code> types
+        */
+       public Transfer[] getTransfers() {
+               Transfer[] types= new Transfer[fListeners.length];
+               for (int i= 0; i < fListeners.length; i++) {
+                       types[i]= fListeners[i].getTransfer();
+               }
+               return types;
+       }
+
+       /**
+        * Sets the current listener to <code>listener</code>. Sends the given
+        * <code>DropTargetEvent</code> if the current listener changes.
+        * 
+        * @return <code>true</code> if the new listener is different than the
+        *         previous <code>false</code> otherwise
+        */
+       private boolean setCurrentListener(TransferDropTargetListener listener, final DropTargetEvent event) {
+               if (fCurrentListener == listener)
+                       return false;
+               if (fCurrentListener != null) {
+                       SafeRunner.run(new SafeRunnable() {
+                               public void run() throws Exception {
+                                       fCurrentListener.dragLeave(event);
+                               }
+                       });
+               }
+               fCurrentListener= listener;
+               if (fCurrentListener != null) {
+                       SafeRunner.run(new SafeRunnable() {
+                               public void run() throws Exception {
+                                       fCurrentListener.dragEnter(event);
+                               }
+                       });
+               }
+               return true;
+       }
+
+       /**
+        * Updates the current listener to one that can handle the drop. There can
+        * be many listeners and each listener may be able to handle many
+        * <code>TransferData</code> types. The first listener found that can
+        * handle a drop of one of the given <code>TransferData</code> types will
+        * be selected. If no listener can handle the drag operation the
+        * <code>event.detail</code> field is set to <code>DND.DROP_NONE</code>
+        * to indicate an invalid drop.
+        * 
+        * @param event the drop target event
+        */
+       private void updateCurrentListener(DropTargetEvent event) {
+               int originalDetail= event.detail;
+               // Revert the detail to the "original" drop type that the User
+               // indicated. This is necessary because the previous listener 
+               // may have changed the detail to something other than what the 
+               // user indicated.
+               event.detail= fOriginalDropType;
+
+               for (int i= 0; i < fListeners.length; i++) {
+                       TransferDropTargetListener listener= fListeners[i];
+                       TransferData dataType= getSupportedTransferType(event.dataTypes, listener);
+                       if (dataType != null) {
+                               TransferData originalDataType= event.currentDataType;
+                               // set the data type supported by the drop listener
+                               event.currentDataType= dataType;
+                               if (listener.isEnabled(event)) {
+                                       // if the listener stays the same, set its previously
+                                       // determined
+                                       // event detail
+                                       if (!setCurrentListener(listener, event))
+                                               event.detail= originalDetail;
+                                       return;
+                               }
+                               event.currentDataType= originalDataType;
+                       }
+               }
+               setCurrentListener(null, event);
+               event.detail= DND.DROP_NONE;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/FileTransferDragAdapter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/FileTransferDragAdapter.java
new file mode 100644 (file)
index 0000000..74bd99c
--- /dev/null
@@ -0,0 +1,187 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dnd;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Assert;
+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.MultiStatus;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.dnd.FileTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.CUIMessages;
+import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
+
+public class FileTransferDragAdapter implements TransferDragSourceListener {
+       private final ISelectionProvider provider;
+
+       public FileTransferDragAdapter(ISelectionProvider provider) {
+               super();
+               this.provider = provider;
+               Assert.isNotNull(provider);
+       }
+
+       public Transfer getTransfer() {
+               return FileTransfer.getInstance();
+       }
+
+       public void dragStart(DragSourceEvent event) {
+               event.doit = !getResources().isEmpty();
+       }
+
+       public void dragSetData(DragSourceEvent event) {
+               event.data = getResourceLocations(getResources());
+       }
+
+       public void dragFinished(DragSourceEvent event) {
+               if (event.doit) {
+                       if (event.detail == DND.DROP_MOVE) {
+                               // Never delete resources when dragging outside Eclipse.                                
+                               // See: http://bugs.eclipse.org/bugs/show_bug.cgi?id=30543
+                       } else if (event.detail == DND.DROP_NONE || event.detail == DND.DROP_TARGET_MOVE) {
+                               runOperation(new RefreshOperation(getResources()), true, false);
+                       }
+               }
+       }
+
+       private static class RefreshOperation extends WorkspaceModifyOperation {
+               private final Set<IResource> roots;
+
+               public RefreshOperation(List<IResource> resources) {
+                       super();
+
+                       roots = new HashSet<IResource>(resources.size());
+
+                       for (IResource resource : resources) {
+                               IResource parent = resource.getParent();
+                               roots.add(parent != null ? parent : resource);
+                       }
+               }
+
+               @Override
+               public void execute(IProgressMonitor monitor) throws CoreException {
+                       try {
+                               monitor.beginTask(CUIMessages.FileTransferDragAdapter_refreshing, roots.size()); 
+                               MultiStatus status = new MultiStatus(CUIPlugin.getPluginId(), IStatus.OK, CUIMessages.FileTransferDragAdapter_problem, null); 
+
+                               for (IResource resource : roots) {
+                                       try {
+                                               resource.refreshLocal(
+                                                       IResource.DEPTH_ONE,
+                                                       new SubProgressMonitor(monitor, 1));
+                                       } catch (CoreException e) {
+                                               status.add(e.getStatus());
+                                       }
+                               }
+
+                               if (!status.isOK())
+                                       throw new CoreException(status);
+                       } finally {
+                               monitor.done();
+                       }
+               }
+       }
+
+       private List<IResource> getResources() {
+               List<IResource> result = Collections.emptyList();
+               ISelection selection = provider.getSelection();
+
+               if (selection instanceof IStructuredSelection) {
+                       IStructuredSelection structured = (IStructuredSelection) selection;
+
+                       result = new ArrayList<IResource>(structured.size());
+
+                       for (Iterator<?> iterator = structured.iterator(); iterator.hasNext();) {
+                               Object object = iterator.next();
+                               IResource resource = null;
+
+                               if (object instanceof IResource) {
+                                       resource = (IResource) object;
+                               } else if (object instanceof IAdaptable) {
+                                       resource = (IResource) ((IAdaptable) object).getAdapter(IResource.class);
+                               }
+
+                               if (resource != null)
+                                       result.add(resource);
+                       }
+               }
+
+               return result;
+       }
+
+       private static String[] getResourceLocations(List<IResource> resources) {
+               if (!resources.isEmpty()) {
+                       int count = resources.size();
+                       List<String> locations = new ArrayList<String>(count);
+                       
+                       for (IResource resource : resources) {
+                               IPath location = resource.getLocation();
+                               
+                               if (location != null) {
+                                       locations.add(location.toOSString());
+                               }
+                       }
+                       
+                       String[] result = new String[locations.size()];
+                       
+                       locations.toArray(result);
+                       
+                       return result;
+               }
+               return null;
+       }
+
+       private static void runOperation(
+               IRunnableWithProgress operation,
+               boolean fork,
+               boolean cancelable) {
+               try {
+                       IWorkbench workbench = CUIPlugin.getDefault().getWorkbench();
+                       IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
+                       Shell parent = window.getShell();
+
+                       new ProgressMonitorDialog(parent).run(fork, cancelable, operation);
+               } catch (InterruptedException e) {
+                       // Do nothing. Operation has been canceled by user.
+               } catch (InvocationTargetException e) {
+                       String message = CUIMessages.FileTransferDragAdapter_problem; 
+                       String title = CUIMessages.FileTransferDragAdapter_problemTitle; 
+
+                       ExceptionHandler.handle(e, title, message);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/FileTransferDropAdapter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/FileTransferDropAdapter.java
new file mode 100644 (file)
index 0000000..c897b2f
--- /dev/null
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.dnd;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourceAttributes;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.AbstractTreeViewer;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.FileTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.actions.CopyFilesAndFoldersOperation;
+
+/**
+ * FileTransferDropAdapter
+ */
+public class FileTransferDropAdapter extends CDTViewerDropAdapter implements TransferDropTargetListener {
+
+       public FileTransferDropAdapter(AbstractTreeViewer viewer) {
+               super(viewer, DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND);
+       }
+
+       //---- TransferDropTargetListener interface ---------------------------------------
+       
+       public Transfer getTransfer() {
+               return FileTransfer.getInstance();
+       }
+       
+       public boolean isEnabled(DropTargetEvent event) {
+               Object target= event.item != null ? event.item.getData() : null;
+               if (target == null) {
+                       return false;
+               }
+               return target instanceof ICElement || target instanceof IResource;
+       }
+
+       //---- Actual DND -----------------------------------------------------------------
+       
+       @Override
+       public void validateDrop(Object target, DropTargetEvent event, int operation) {
+               event.detail= DND.DROP_NONE;
+               boolean isContainer = false;
+               if (target instanceof IContainer) {
+                       isContainer = true;
+               } else if (target instanceof IAdaptable) {
+                       target = ((IAdaptable)target).getAdapter(IResource.class);
+                       isContainer = target instanceof IContainer;
+               }
+               if (isContainer) {
+                       IContainer container= (IContainer)target;
+                       if (container.isAccessible()) {
+                               ResourceAttributes attributes = container.getResourceAttributes();
+                               if (attributes != null && !attributes.isReadOnly()) {
+                                       event.detail= DND.DROP_COPY;
+                               }
+                       }
+               }
+       }
+
+       @Override
+       public void drop(Object dropTarget, final DropTargetEvent event) {
+               int operation= event.detail;
+               
+               event.detail= DND.DROP_NONE;
+               final Object data= event.data;
+               if (data == null || !(data instanceof String[]) || operation != DND.DROP_COPY)
+                       return;
+               
+               final IContainer target= getActualTarget(dropTarget);
+               if (target == null)
+                       return;
+               
+               // Run the import operation asynchronously. 
+               // Otherwise the drag source (e.g., Windows Explorer) will be blocked 
+               // while the operation executes. Fixes bug 35796.
+               Display.getCurrent().asyncExec(new Runnable() {
+                       public void run() {
+                               getShell().forceActive();
+                               new CopyFilesAndFoldersOperation(getShell()).copyFiles((String[]) data, target);
+                               // Import always performs a copy.
+                               event.detail= DND.DROP_COPY;
+                       }
+               });
+       }
+       
+       private IContainer getActualTarget(Object dropTarget) {
+               if (dropTarget instanceof IContainer) {
+                       return (IContainer)dropTarget;
+               } else if (dropTarget instanceof ICElement) {
+                       return getActualTarget(((ICElement)dropTarget).getResource());
+               }
+               return null;
+       }
+       
+       Shell getShell() {
+               return getViewer().getControl().getShell();
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/PluginTransferDropAdapter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/PluginTransferDropAdapter.java
new file mode 100644 (file)
index 0000000..dd607c8
--- /dev/null
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.dnd;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.ui.part.PluginDropAdapter;
+import org.eclipse.ui.part.PluginTransfer;
+
+import org.eclipse.cdt.core.model.ICElement;
+
+/**
+ * PluginTransferDropAdapter
+ * Enable DND to support PluginTransfer type.
+ * The actual DND operation is a call back to the 
+ * org.eclipse.ui.dropActions delegate.
+ *
+ */
+
+public class PluginTransferDropAdapter extends PluginDropAdapter implements
+               TransferDropTargetListener {
+
+       public PluginTransferDropAdapter (StructuredViewer viewer) {
+               super(viewer);
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.dnd.TransferDropTargetListener#getTransfer()
+        */
+       public Transfer getTransfer() {
+               return PluginTransfer.getInstance();
+       }
+
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.dnd.TransferDropTargetListener#isEnabled(org.eclipse.swt.dnd.DropTargetEvent)
+        */
+       public boolean isEnabled(DropTargetEvent event) {
+               Object target= event.item != null ? event.item.getData() : null;
+               if (target == null) {
+                       return false;
+               }
+               return target instanceof ICElement || target instanceof IResource;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDragAdapter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDragAdapter.java
new file mode 100644 (file)
index 0000000..8ff933a
--- /dev/null
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dnd;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DragSource;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.actions.ReadOnlyStateChecker;
+import org.eclipse.ui.part.ResourceTransfer;
+
+import org.eclipse.cdt.internal.ui.CUIMessages;
+
+/**
+ * A drag adapter that transfers the current selection as </code>
+ * IResource</code>. Only those elements in the selection are part 
+ * of the transfer which can be converted into an <code>IResource
+ * </code>.
+ */
+public class ResourceTransferDragAdapter implements TransferDragSourceListener {
+       private final ISelectionProvider provider;
+
+       /**
+        * Creates a new ResourceTransferDragAdapter for the given selection provider.
+        *
+        * @param provider the selection provider to access the viewer's selection
+        */
+       public ResourceTransferDragAdapter(ISelectionProvider provider) {
+               super();
+               this.provider = provider;
+               Assert.isNotNull(provider);
+       }
+
+       public Transfer getTransfer() {
+               return ResourceTransfer.getInstance();
+       }
+
+       public void dragStart(DragSourceEvent event) {
+               IResource[] resources = getSelectedResources();
+               event.doit = resources.length > 0;
+       }
+
+       public void dragSetData(DragSourceEvent event) {
+               event.data = getSelectedResources();
+       }
+
+       public void dragFinished(DragSourceEvent event) {
+               if (event.doit && event.detail == DND.DROP_MOVE) {
+                       IResource[] resources = getSelectedResources();
+
+                       if (resources.length == 0)
+                               return;
+
+                       DragSource dragSource = (DragSource) event.widget;
+                       Control control = dragSource.getControl();
+                       Shell shell = control.getShell();
+                       String title = CUIMessages.Drag_move_problem_title; 
+                       String message = CUIMessages.Drag_move_problem_message; 
+
+                       ReadOnlyStateChecker checker = new ReadOnlyStateChecker(shell, title, message);
+
+                       resources = checker.checkReadOnlyResources(resources);
+
+                       // delete the old elements
+                       for (int i = 0; i < resources.length; ++i) {
+                               try {
+                                       resources[i].delete(IResource.KEEP_HISTORY | IResource.FORCE, null);
+                               } catch (CoreException e) {
+                                       e.printStackTrace();
+                               }
+                       }
+               }
+       }
+
+       private IResource[] getSelectedResources() {
+               List<IResource> resources = Collections.emptyList();
+               ISelection selection = provider.getSelection();
+
+               if (selection instanceof IStructuredSelection) {
+                       IStructuredSelection structured = (IStructuredSelection) selection;
+
+                       resources = new ArrayList<IResource>(structured.size());
+
+                       for (Iterator<?> iterator = structured.iterator(); iterator.hasNext();) {
+                               Object element = iterator.next();
+                               IResource resource = null;
+                               if (element instanceof IResource) {
+                                       resource = (IResource)element;
+                               } else if (element instanceof IAdaptable) {
+                                       IAdaptable adaptable = (IAdaptable) element;
+                                       resource = (IResource) adaptable.getAdapter(IResource.class);
+                               }
+                               if (resource != null) {
+                                       resources.add(resource);
+                               }
+                       }
+               }
+
+               IResource[] result = new IResource[resources.size()];
+               resources.toArray(result);
+
+               return result;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDropAdapter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDropAdapter.java
new file mode 100644 (file)
index 0000000..0ffa8ae
--- /dev/null
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems) - 151571 DND move on GTK
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.dnd;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.actions.CopyFilesAndFoldersOperation;
+import org.eclipse.ui.actions.MoveFilesAndFoldersOperation;
+import org.eclipse.ui.actions.ReadOnlyStateChecker;
+import org.eclipse.ui.part.ResourceTransfer;
+
+import org.eclipse.cdt.core.model.ICElement;
+
+/**
+ * ResourceTransferDropAdapter
+ */
+public class ResourceTransferDropAdapter extends CDTViewerDropAdapter implements TransferDropTargetListener {
+
+       /**
+        * @param viewer
+        */
+       public ResourceTransferDropAdapter(StructuredViewer viewer) {
+               super(viewer, DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.drag.TransferDropTargetListener#getTransfer()
+        */
+       public Transfer getTransfer() {
+               return ResourceTransfer.getInstance();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.drag.TransferDropTargetListener#isEnabled(org.eclipse.swt.dnd.DropTargetEvent)
+        */
+       public boolean isEnabled(DropTargetEvent event) {
+               Object target= event.item != null ? event.item.getData() : null;
+               if (target == null) {
+                       return false;
+               }
+               return target instanceof ICElement || target instanceof IResource;
+       }
+
+       @Override
+       public void validateDrop(Object target, DropTargetEvent event, int op) {
+               IContainer destination = getDestination(target);
+               if (destination == null) {
+                       event.detail = DND.DROP_NONE;
+               } else {
+                       IResource[] selectedResources = getSelectedResources();
+                       if (selectedResources.length == 0) {
+                               event.detail = DND.DROP_NONE;
+                       } else {
+                               if (op == DND.DROP_COPY) {
+                                       CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(getShell());
+                                       if (operation.validateDestination(destination, selectedResources) == null) {
+                                               event.detail = op;
+                                       }
+                               } else {
+                                       MoveFilesAndFoldersOperation operation = new MoveFilesAndFoldersOperation(getShell());
+                                       if (operation.validateDestination(destination, selectedResources) == null) {
+                                               event.detail = DND.DROP_MOVE;
+                                       }
+                               }
+                       }
+               }
+       }
+
+       @Override
+       public void drop(Object dropTarget, final DropTargetEvent event) {
+               int op= event.detail;
+               
+               event.detail= DND.DROP_NONE;
+               final Object data= event.data;
+               if (data == null || !(data instanceof IResource[]))
+                       return;
+               
+               final IContainer target= getDestination(dropTarget);
+               if (target == null) {
+                       return;
+               }
+               IResource[] sources = (IResource[])data;
+               if (op == DND.DROP_COPY) {
+                       CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(getShell());
+                       operation.copyResources(sources, target);
+               } else  {
+                       ReadOnlyStateChecker checker = new ReadOnlyStateChecker(
+                               getShell(), 
+                               "Move Resource Action", //$NON-NLS-1$
+                               "Move Resource Action");//$NON-NLS-1$   
+                       sources = checker.checkReadOnlyResources(sources);
+                       MoveFilesAndFoldersOperation operation = new MoveFilesAndFoldersOperation(getShell());
+                       operation.copyResources(sources, target);
+               }
+       }
+
+       private IContainer getDestination(Object dropTarget) {
+               if (dropTarget instanceof IContainer) {
+                       return (IContainer)dropTarget;
+               } else if (dropTarget instanceof ICElement) {
+                       return getDestination(((ICElement)dropTarget).getResource());
+               }
+               return null;
+       }
+
+       /**
+        * Returns the resource selection from the LocalSelectionTransfer.
+        * 
+        * @return the resource selection from the LocalSelectionTransfer
+        */
+       private IResource[] getSelectedResources() {
+               ArrayList<IResource> selectedResources = new ArrayList<IResource>();
+               
+               ISelection selection = LocalSelectionTransfer.getTransfer()
+               .getSelection();
+               if (selection instanceof IStructuredSelection) {
+                       IStructuredSelection ssel = (IStructuredSelection) selection;
+                       for (Iterator<?> i = ssel.iterator(); i.hasNext();) {
+                               Object o = i.next();
+                               if (o instanceof IResource) {
+                                       selectedResources.add((IResource) o);
+                               }
+                               else if (o instanceof IAdaptable) {
+                                       IAdaptable a = (IAdaptable) o;
+                                       IResource r = (IResource) a.getAdapter(IResource.class);
+                                       if (r != null) {
+                                               selectedResources.add(r);
+                                       }
+                               }
+                       }
+               }
+               return selectedResources.toArray(new IResource[selectedResources.size()]);
+       }
+
+       /**
+        * Returns the shell
+        */
+       protected Shell getShell() {
+               return getViewer().getControl().getShell();
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/TextViewerDragAdapter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/TextViewerDragAdapter.java
new file mode 100644 (file)
index 0000000..e8a39d0
--- /dev/null
@@ -0,0 +1,228 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dnd;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.BadPositionCategoryException;
+import org.eclipse.jface.text.DefaultPositionUpdater;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IPositionUpdater;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.ITextViewerExtension;
+import org.eclipse.jface.text.ITextViewerExtension5;
+import org.eclipse.jface.text.Position;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.custom.StyledTextContent;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DragSourceAdapter;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.ui.texteditor.ITextEditorExtension;
+
+/**
+ * Drag source adapter for text selections in ITextViewers.
+ * 
+ * @since 4.0
+ */
+public class TextViewerDragAdapter extends DragSourceAdapter {
+
+       /** The position category to be used to indicate a drag source selection */
+       public final static String DRAG_SELECTION_CATEGORY= "dragSelectionCategory"; //$NON-NLS-1$
+       /** The position updater for the drag selection position */
+       private IPositionUpdater fPositionUpdater;
+       /** The drag selection position */
+       private Position fSelectionPosition;
+       /** The text viewer allowing drag */
+       private ITextViewer fViewer;
+       /** The editor of the viewer (may be null) */
+       private ITextEditorExtension fEditor;
+       /** Flag whether this drag source listener allows to drag */
+       private boolean fIsEnabled= true;
+
+       /**
+        * Create a new TextViewerDragAdapter.
+        * @param viewer the text viewer
+        */
+       public TextViewerDragAdapter(ITextViewer viewer) {
+               this(viewer, null);
+       }
+
+       /**
+        * Create a new TextViewerDragAdapter.
+        * @param viewer the text viewer
+        */
+       public TextViewerDragAdapter(ITextViewer viewer, ITextEditorExtension editor) {
+               fViewer= viewer;
+               fEditor= editor;
+       }
+
+       /*
+        * @see org.eclipse.swt.dnd.DragSourceListener#dragFinished(org.eclipse.swt.dnd.DragSourceEvent)
+        */
+       @Override
+       public void dragFinished(DragSourceEvent event) {
+               IDocument doc= fViewer.getDocument();
+               try {
+                       doc.removePositionCategory(DRAG_SELECTION_CATEGORY);
+                       doc.removePositionUpdater(fPositionUpdater);
+               } catch (BadPositionCategoryException e1) {
+                       // cannot happen
+               }
+               if (event.doit && event.detail == DND.DROP_MOVE && isDocumentEditable()) {
+                       try {
+                               doc.replace(fSelectionPosition.offset, fSelectionPosition.length, null);
+                       } catch (BadLocationException e) {
+                               // ignore
+                       }
+               }
+               if (fViewer instanceof ITextViewerExtension) {
+                       ((ITextViewerExtension)fViewer).getRewriteTarget().endCompoundChange();
+               }
+       }
+
+       /*
+        * @see org.eclipse.swt.dnd.DragSourceListener#dragSetData(org.eclipse.swt.dnd.DragSourceEvent)
+        */
+       @Override
+       public void dragSetData(DragSourceEvent event) {
+               IDocument doc= fViewer.getDocument();
+               try {
+                       event.data= doc.get(fSelectionPosition.offset, fSelectionPosition.length);
+               } catch (BadLocationException e) {
+                       event.detail= DND.DROP_NONE;
+                       event.doit= false;
+               }
+       }
+
+       /*
+        * @see org.eclipse.swt.dnd.DragSourceListener#dragStart(org.eclipse.swt.dnd.DragSourceEvent)
+        */
+       @Override
+       public void dragStart(DragSourceEvent event) {
+               if (!fIsEnabled) {
+                       event.doit= false;
+                       return;
+               }
+               // convert screen coordinates to widget offest
+               int offset= getOffsetAtLocation(event.x, event.y, false);
+               // convert further to a document offset
+               offset= getDocumentOffset(offset);
+               Point selection= fViewer.getSelectedRange();
+               if (selection != null && offset >= selection.x && offset < selection.x+selection.y) {
+                       fSelectionPosition= new Position(selection.x, selection.y);
+                       if (fViewer instanceof ITextViewerExtension) {
+                               ((ITextViewerExtension)fViewer).getRewriteTarget().beginCompoundChange();
+                       }
+                       IDocument doc= fViewer.getDocument();
+                       try {
+                               // add the drag selection position
+                               // the position is used to delete the selection on a DROP_MOVE
+                               // and it can be used by the drop target to determine if it should
+                               // allow the drop (e.g. if drop location overlaps selection)
+                               doc.addPositionCategory(DRAG_SELECTION_CATEGORY);
+                               fPositionUpdater= new DefaultPositionUpdater(DRAG_SELECTION_CATEGORY);
+                               doc.addPositionUpdater(fPositionUpdater);
+                               doc.addPosition(DRAG_SELECTION_CATEGORY, fSelectionPosition);
+                       } catch (BadLocationException e) {
+                               // should not happen
+                       } catch (BadPositionCategoryException e) {
+                               // cannot happen
+                       }
+                       event.doit= true;
+                       // this has no effect?
+                       event.detail = DND.DROP_COPY;
+                       if (isDocumentEditable()) {
+                               event.detail |= DND.DROP_MOVE;
+                       }
+               } else {
+                       event.doit= false;
+                       event.detail = DND.DROP_NONE;
+               }
+       }
+
+       /**
+        * Convert mouse screen coordinates to a <code>StyledText</code> offset.
+        * 
+        * @param x
+        *            screen X-coordinate
+        * @param y
+        *            screen Y-coordinate
+        * @param absolute
+        *            if <code>true</code>, coordinates are expected to be
+        *            absolute screen coordinates
+        * @return text offset
+        * 
+        * @see StyledText#getOffsetAtLocation()
+        */
+       private int getOffsetAtLocation(int x, int y, boolean absolute) {
+               StyledText textWidget= fViewer.getTextWidget();
+               StyledTextContent content= textWidget.getContent();
+               Point location;
+               if (absolute) {
+                       location= textWidget.toControl(x, y);
+               } else {
+                       location= new Point(x ,y);
+               }
+               int line= (textWidget.getTopPixel() + location.y) / textWidget.getLineHeight();
+               if (line >= content.getLineCount()) {
+                       return content.getCharCount();
+               }
+               int lineOffset= content.getOffsetAtLine(line);
+               String lineText= content.getLine(line);
+               Point endOfLine= textWidget.getLocationAtOffset(lineOffset + lineText.length());
+               if (location.x >= endOfLine.x) {
+                       return lineOffset + lineText.length();
+               }
+               try {
+                       return textWidget.getOffsetAtLocation(location);
+               } catch (IllegalArgumentException iae) {
+                       // we are expecting this
+                       return -1;
+               }
+       }
+
+       /**
+        * Convert a widget offset to the corresponding document offset.
+        * @param widgetOffset
+        * @return document offset
+        */
+       private int getDocumentOffset(int widgetOffset) {
+               if (fViewer instanceof ITextViewerExtension5) {
+                       ITextViewerExtension5 extension= (ITextViewerExtension5)fViewer;
+                       return extension.widgetOffset2ModelOffset(widgetOffset);
+               }
+               IRegion visible= fViewer.getVisibleRegion();
+               if (widgetOffset > visible.getLength()) {
+                       return -1;
+               }
+               return widgetOffset + visible.getOffset();
+       }
+
+       /**
+        * @return true if the document may be changed by the drag.
+        */
+       private boolean isDocumentEditable() {
+               if (fEditor != null) {
+                       return !fEditor.isEditorInputReadOnly();
+               }
+               return fViewer.isEditable();
+       }
+
+       /**
+        * Enable or disable this drag listener.
+        * @param enabled
+        */
+       public void setEnabled(boolean enabled) {
+               fIsEnabled= enabled;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/TransferDragSourceListener.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/TransferDragSourceListener.java
new file mode 100644 (file)
index 0000000..36a9308
--- /dev/null
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.dnd;
+
+import org.eclipse.swt.dnd.DragSourceListener;
+import org.eclipse.swt.dnd.Transfer;
+
+/**
+ * A special drag source listener which is typed with a <code>TransferData</code>.
+ */
+public interface TransferDragSourceListener extends DragSourceListener {
+       /**
+        * Returns the transfer used by this drag source.
+        */
+       public Transfer getTransfer();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/TransferDropTargetListener.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/TransferDropTargetListener.java
new file mode 100644 (file)
index 0000000..c82682b
--- /dev/null
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2005 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.dnd;
+
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.DropTargetListener;
+import org.eclipse.swt.dnd.Transfer;
+
+/**
+ * TransferDropTargetListener
+ */
+public interface TransferDropTargetListener extends DropTargetListener {
+
+       /**
+        * Returns the transfer used by this drop target.
+        */
+       public Transfer getTransfer();
+       
+       /**
+        * Returns whether the listener is able to handle the given
+        * drop traget event.
+        * 
+        * @param event the drop target event
+        * 
+        * @return <code>true</code> if the listener can handle the event;
+        *  otherwise <code>false</code>
+        */
+       public boolean isEnabled(DropTargetEvent event);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ASTProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ASTProvider.java
new file mode 100644 (file)
index 0000000..a55f05a
--- /dev/null
@@ -0,0 +1,408 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems) - Adapted for CDT
+ *     Markus Schorn (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentExtension4;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPartListener2;
+import org.eclipse.ui.IWindowListener;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartReference;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.model.ASTCache;
+import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
+
+/**
+ * Provides a shared AST for clients. The shared AST is
+ * the AST of the active CEditor's input element.
+ * 
+ * @since 4.0
+ */
+public final class ASTProvider {
+       /**
+        * Wait flag.
+        */
+       public static final class WAIT_FLAG {
+               String fName;
+
+               private WAIT_FLAG(String name) {
+                       fName= name;
+               }
+
+               /*
+                * @see java.lang.Object#toString()
+                */
+               @Override
+               public String toString() {
+                       return fName;
+               }
+       }
+
+       /**
+        * Wait flag indicating that a client requesting an AST
+        * wants to wait until an AST is ready. If the translation unit is not open no AST will
+        * be provided.
+        * <p>
+        * If not yet cached and if the translation unit is open, an AST will be created by 
+        * this AST provider.
+        * </p>
+        */
+       public static final WAIT_FLAG WAIT_IF_OPEN= new WAIT_FLAG("wait if open"); //$NON-NLS-1$
+
+       /**
+        * Wait flag indicating that a client requesting an AST
+        * only wants to wait for the shared AST of the active editor. 
+        * If the translation unit is not open no AST will be provided.
+        * <p>
+        * No AST will be created by the AST provider.
+        * </p>
+        */
+       public static final WAIT_FLAG WAIT_ACTIVE_ONLY= new WAIT_FLAG("wait active only"); //$NON-NLS-1$
+
+       /**
+        * Wait flag indicating that a client requesting an AST
+        * only wants the already available shared AST.
+        * <p>
+        * No AST will be created by the AST provider.
+        * </p>
+        */
+       public static final WAIT_FLAG WAIT_NO= new WAIT_FLAG("don't wait"); //$NON-NLS-1$
+
+       /** Full parse mode (no PDOM) */
+       public static int PARSE_MODE_FULL= 0;
+       /** Fast parse mode (use PDOM) */
+       public static int PARSE_MODE_FAST= ITranslationUnit.AST_SKIP_INDEXED_HEADERS;
+
+       /**
+        * Internal activation listener.
+        */
+       private class ActivationListener implements IPartListener2, IWindowListener {
+
+               /*
+                * @see org.eclipse.ui.IPartListener2#partActivated(org.eclipse.ui.IWorkbenchPartReference)
+                */
+               public void partActivated(IWorkbenchPartReference ref) {
+                       if (isCEditor(ref) && !isActiveEditor(ref))
+                               activeEditorChanged(ref.getPart(true));
+               }
+
+               /*
+                * @see org.eclipse.ui.IPartListener2#partBroughtToTop(org.eclipse.ui.IWorkbenchPartReference)
+                */
+               public void partBroughtToTop(IWorkbenchPartReference ref) {
+                       if (isCEditor(ref) && !isActiveEditor(ref))
+                               activeEditorChanged(ref.getPart(true));
+               }
+
+               /*
+                * @see org.eclipse.ui.IPartListener2#partClosed(org.eclipse.ui.IWorkbenchPartReference)
+                */
+               public void partClosed(IWorkbenchPartReference ref) {
+                       if (isActiveEditor(ref)) {
+                               activeEditorChanged(null);
+                       }
+               }
+
+               /*
+                * @see org.eclipse.ui.IPartListener2#partDeactivated(org.eclipse.ui.IWorkbenchPartReference)
+                */
+               public void partDeactivated(IWorkbenchPartReference ref) {
+               }
+
+               /*
+                * @see org.eclipse.ui.IPartListener2#partOpened(org.eclipse.ui.IWorkbenchPartReference)
+                */
+               public void partOpened(IWorkbenchPartReference ref) {
+                       if (isCEditor(ref) && !isActiveEditor(ref))
+                               activeEditorChanged(ref.getPart(true));
+               }
+
+               /*
+                * @see org.eclipse.ui.IPartListener2#partHidden(org.eclipse.ui.IWorkbenchPartReference)
+                */
+               public void partHidden(IWorkbenchPartReference ref) {
+               }
+
+               /*
+                * @see org.eclipse.ui.IPartListener2#partVisible(org.eclipse.ui.IWorkbenchPartReference)
+                */
+               public void partVisible(IWorkbenchPartReference ref) {
+                       if (isCEditor(ref) && !isActiveEditor(ref))
+                               activeEditorChanged(ref.getPart(true));
+               }
+
+               /*
+                * @see org.eclipse.ui.IPartListener2#partInputChanged(org.eclipse.ui.IWorkbenchPartReference)
+                */
+               public void partInputChanged(IWorkbenchPartReference ref) {
+                       if (isCEditor(ref) && isActiveEditor(ref))
+                               activeEditorChanged(ref.getPart(true));
+               }
+
+               /*
+                * @see org.eclipse.ui.IWindowListener#windowActivated(org.eclipse.ui.IWorkbenchWindow)
+                */
+               public void windowActivated(IWorkbenchWindow window) {
+                       IWorkbenchPartReference ref= window.getPartService().getActivePartReference();
+                       if (isCEditor(ref) && !isActiveEditor(ref))
+                               activeEditorChanged(ref.getPart(true));
+               }
+
+               /*
+                * @see org.eclipse.ui.IWindowListener#windowDeactivated(org.eclipse.ui.IWorkbenchWindow)
+                */
+               public void windowDeactivated(IWorkbenchWindow window) {
+               }
+
+               /*
+                * @see org.eclipse.ui.IWindowListener#windowClosed(org.eclipse.ui.IWorkbenchWindow)
+                */
+               public void windowClosed(IWorkbenchWindow window) {
+                       if (fActiveEditor != null && fActiveEditor.getSite() != null && window == fActiveEditor.getSite().getWorkbenchWindow()) {
+                               activeEditorChanged(null);
+                       }
+                       window.getPartService().removePartListener(this);
+               }
+
+               /*
+                * @see org.eclipse.ui.IWindowListener#windowOpened(org.eclipse.ui.IWorkbenchWindow)
+                */
+               public void windowOpened(IWorkbenchWindow window) {
+                       window.getPartService().addPartListener(this);
+               }
+
+               private boolean isActiveEditor(IWorkbenchPartReference ref) {
+                       return ref != null && isActiveEditor(ref.getPart(false));
+               }
+
+               private boolean isActiveEditor(IWorkbenchPart part) {
+                       return part != null && part == fActiveEditor;
+               }
+
+               private boolean isCEditor(IWorkbenchPartReference ref) {
+                       if (ref == null)
+                               return false;
+
+                       String id= ref.getId();
+                       return CUIPlugin.EDITOR_ID.equals(id) || ref.getPart(false) instanceof CEditor;
+               }
+       }
+
+       private ASTCache fCache= new ASTCache();
+       private ActivationListener fActivationListener;
+       private IWorkbenchPart fActiveEditor;
+       private long fTimeStamp;
+
+       /**
+        * Returns the C plug-in's AST provider.
+        * 
+        * @return the AST provider
+        */
+       public static ASTProvider getASTProvider() {
+               return CUIPlugin.getDefault().getASTProvider();
+       }
+
+       /**
+        * Creates a new AST provider.
+        */
+       public ASTProvider() {
+               install();
+       }
+
+       /**
+        * Installs this AST provider.
+        */
+       void install() {
+               if (PlatformUI.isWorkbenchRunning()) {
+                       // Create and register activation listener
+                       fActivationListener= new ActivationListener();
+                       PlatformUI.getWorkbench().addWindowListener(fActivationListener);
+
+                       // Ensure existing windows get connected
+                       IWorkbenchWindow[] windows= PlatformUI.getWorkbench().getWorkbenchWindows();
+                       for (int i= 0, length= windows.length; i < length; i++)
+                               windows[i].getPartService().addPartListener(fActivationListener);
+               }
+       }
+
+       private void activeEditorChanged(IWorkbenchPart editor) {
+               ICElement cElement= null;
+               if (editor instanceof CEditor) {
+                       cElement= ((CEditor) editor).getInputCElement();
+               }
+               synchronized (this) {
+                       fActiveEditor= editor;
+                       fTimeStamp= IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP;
+                       fCache.setActiveElement((ITranslationUnit) cElement);
+               }
+       }
+
+       /**
+        * Informs that reconciling for the given element is about to be started.
+        *
+        * @param cElement the C element
+        * @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#aboutToBeReconciled()
+        */
+       void aboutToBeReconciled(ICElement cElement) {
+               if (cElement == null)
+                       return;
+               Assert.isTrue(cElement instanceof ITranslationUnit);
+               fCache.aboutToBeReconciled((ITranslationUnit) cElement);
+               updateModificationStamp();
+       }
+
+       private boolean updateModificationStamp() {
+               long timeStamp= IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP;
+               ITextEditor textEditor= null;
+               synchronized (this) {
+                       if (fActiveEditor instanceof ITextEditor) {
+                               textEditor= (ITextEditor) fActiveEditor;
+                               timeStamp= fTimeStamp;
+                       }
+               }
+               if (textEditor != null) {
+                       IEditorInput editorInput= textEditor.getEditorInput();
+                       IDocument document= textEditor.getDocumentProvider().getDocument(editorInput);
+                       if (document instanceof IDocumentExtension4) {
+                               IDocumentExtension4 docExt= (IDocumentExtension4) document;
+                               long newTimeStamp= docExt.getModificationStamp();
+                               if (newTimeStamp != timeStamp) {
+                                       synchronized (this) {
+                                               if (fActiveEditor == textEditor && fTimeStamp == timeStamp) {
+                                                       fTimeStamp= newTimeStamp;
+                                                       return true;
+                                               }
+                                       }
+                               }
+                       }
+               }
+               return false;
+       }
+
+       /**
+        * Disposes this AST provider.
+        */
+       public void dispose() {
+               if (fActivationListener != null) {
+                       // Dispose activation listener
+                       PlatformUI.getWorkbench().removeWindowListener(fActivationListener);
+                       fActivationListener= null;
+               }
+               fCache.setActiveElement(null);
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#reconciled()
+        */
+       void reconciled(IASTTranslationUnit ast, ICElement cElement, IProgressMonitor progressMonitor) {
+               if (cElement == null)
+                       return;
+               Assert.isTrue(cElement instanceof ITranslationUnit);
+               fCache.reconciled(ast, (ITranslationUnit) cElement);
+       }
+
+       /**
+        * Executes {@link ASTRunnable#runOnAST(ILanguage, IASTTranslationUnit)}
+        * with the shared AST for the given translation unit. Handles acquiring
+        * and releasing the index read-lock for the client.
+        * 
+        * @param cElement     the translation unit
+        * @param waitFlag     condition for waiting for the AST to be built.
+        * @param monitor      a progress monitor, may be <code>null</code>
+        * @param astRunnable  the runnable taking the AST
+        * @return the status  returned by the ASTRunnable
+        */
+       public IStatus runOnAST(ICElement cElement, WAIT_FLAG waitFlag, IProgressMonitor monitor,
+                       ASTCache.ASTRunnable astRunnable) {
+               Assert.isTrue(cElement instanceof ITranslationUnit);
+               final ITranslationUnit tu = (ITranslationUnit) cElement;
+               if (!prepareForUsingCache(tu, waitFlag))
+                       return Status.CANCEL_STATUS;
+               return fCache.runOnAST(tu, waitFlag != WAIT_NO, monitor, astRunnable);
+       }
+
+       /**
+        * Returns a shared AST and locks it for exclusive access. An AST obtained from this
+        * method has to be released by calling {@link #releaseSharedAST(IASTTranslationUnit)}.
+        * Subsequent call to this method will block until the AST is released.
+        * <p>
+        * The AST can be released by a thread other than the one that acquired it.
+        * <p>
+        * An index lock must be held by the caller when calling this method. The index lock may
+        * not be released until the AST is released.
+        * 
+        * @param tu The translation unit to get the AST for.
+        * @param index index with read lock held.
+        * @param waitFlag condition for waiting for the AST to be built.
+        * @param monitor a progress monitor, may be <code>null</code>.
+        * @return the shared AST, or <code>null</code> if the shared AST is not available.
+        */
+       public final IASTTranslationUnit acquireSharedAST(ITranslationUnit tu, IIndex index,
+                       WAIT_FLAG waitFlag, IProgressMonitor monitor) {
+               if (!prepareForUsingCache(tu, waitFlag))
+                       return null;
+               return fCache.acquireSharedAST(tu, index, waitFlag != WAIT_NO, monitor);
+       }
+
+       /**
+        * Releases a shared AST previously acquired by calling
+        * {@link #acquireSharedAST(ITranslationUnit, IIndex, WAIT_FLAG, IProgressMonitor)}.
+        * <p>
+        * Can be called by a thread other than the one that acquired the AST.
+       *
+        * @param ast the AST to release.
+        */
+       public final void releaseSharedAST(IASTTranslationUnit ast) {
+               fCache.releaseSharedAST(ast);
+       }
+
+       /**
+        * Prepares the AST cache to be used for the given translation unit.
+        * 
+        * @param tu the translation unit.
+        * @param waitFlag condition for waiting for the AST to be built.
+        * @return <code>true</code> if the AST cache can be used for the given translation unit,
+        *              <code>false</code> otherwise.
+        */
+       private boolean prepareForUsingCache(ITranslationUnit tu, WAIT_FLAG waitFlag) {
+               if (!tu.isOpen())
+                       return false;
+
+               // http://bugs.eclipse.org/bugs/show_bug.cgi?id=342506 explains
+               // benign nature of the race conditions in the code below. 
+               final boolean isActive= fCache.isActiveElement(tu);
+               if (waitFlag == WAIT_ACTIVE_ONLY && !isActive) {
+                       return false;
+               }
+               if (isActive && updateModificationStamp()) {
+                       fCache.disposeAST();
+               }
+               return true;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage.java
new file mode 100644 (file)
index 0000000..dfa1e64
--- /dev/null
@@ -0,0 +1,763 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Markus Schorn (Wind River Systems)
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Item;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Widget;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.navigator.resources.ProjectExplorer;
+import org.eclipse.ui.part.IPageSite;
+import org.eclipse.ui.part.IShowInSource;
+import org.eclipse.ui.part.IShowInTarget;
+import org.eclipse.ui.part.IShowInTargetList;
+import org.eclipse.ui.part.Page;
+import org.eclipse.ui.part.ShowInContext;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.IncludesGrouping;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.actions.OpenViewActionGroup;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.IContextMenuConstants;
+import org.eclipse.cdt.internal.ui.actions.AbstractToggleLinkingAction;
+import org.eclipse.cdt.internal.ui.actions.ActionMessages;
+import org.eclipse.cdt.internal.ui.cview.SelectionTransferDragAdapter;
+import org.eclipse.cdt.internal.ui.cview.SelectionTransferDropAdapter;
+import org.eclipse.cdt.internal.ui.dnd.CDTViewerDragAdapter;
+import org.eclipse.cdt.internal.ui.dnd.DelegatingDropAdapter;
+import org.eclipse.cdt.internal.ui.dnd.TransferDragSourceListener;
+import org.eclipse.cdt.internal.ui.dnd.TransferDropTargetListener;
+import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
+import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
+import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
+import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCLabelProvider;
+
+/**
+ * Abstract outline page based on CModel.
+ *
+ * @since 5.0
+ */
+public abstract class AbstractCModelOutlinePage extends Page implements IContentOutlinePage, ISelectionChangedListener, IAdaptable {
+
+       /**
+        * The default label provider for the outline.
+        */
+       public static class COutlineLabelProvider extends AppearanceAwareLabelProvider {
+
+               /**
+                * Flag whether to show member definitions with qualified or simple names.
+                */
+               private boolean fSimpleName;
+
+               public COutlineLabelProvider(long textFlags, int imageFlags) {
+                       super(textFlags, imageFlags);
+                       PreferenceConstants.getPreferenceStore().addPropertyChangeListener(this);
+                       fSimpleName= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.OUTLINE_GROUP_MEMBERS);
+               }
+
+               @Override
+               public void dispose() {
+                       PreferenceConstants.getPreferenceStore().removePropertyChangeListener(this);
+                       super.dispose();
+               }
+               
+               @Override
+               protected long evaluateTextFlags(Object element) {
+                       if (fSimpleName) {
+                               return super.evaluateTextFlags(element) | CElementLabels.M_SIMPLE_NAME | CElementLabels.F_SIMPLE_NAME;
+                       }
+                       return super.evaluateTextFlags(element);
+               }
+               
+               @Override
+               public void propertyChange(PropertyChangeEvent event) {
+                       if (PreferenceConstants.OUTLINE_GROUP_MEMBERS.equals(event.getProperty())) {
+                               final Object newValue = event.getNewValue();
+                               if (newValue instanceof Boolean) {
+                                       fSimpleName= ((Boolean) newValue).booleanValue();
+                               } else {
+                                       fSimpleName= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.OUTLINE_GROUP_MEMBERS);
+                               }
+                       }
+               }
+       }
+
+       /**
+        * A specialized tree viewer for outline content.
+        *
+        * @since 5.0
+        */
+       private static class OutlineTreeViewer extends ProblemTreeViewer {
+
+               public OutlineTreeViewer(Composite parent, int flags) {
+                       super(parent, flags);
+               }
+               /*
+                * @see TreeViewer#internalExpandToLevel
+                */
+               @Override
+               protected void internalExpandToLevel(Widget node, int level) {
+                       if (node instanceof Item) {
+                               Item i= (Item) node;
+                               final Object data = i.getData();
+                               // don't expand include grouping by default
+                               if (data instanceof IncludesGrouping) {
+                                       return;
+                               } else if (data instanceof ICElement) {
+                                       if (!shouldExpandElement((ICElement)data)) {
+                                               return;
+                                       }
+                               }
+                       }
+                       super.internalExpandToLevel(node, level);
+               }
+               
+               private boolean shouldExpandElement(ICElement cElement) {
+                       final ICElement parent= cElement.getParent();
+                       if (parent == null) {
+                               return false;
+                       }
+                       // expand classes and namespaces
+                       final int elementType= cElement.getElementType();
+                       final int parentType= parent.getElementType();
+                       switch (elementType) {
+                       case ICElement.C_CLASS:
+                       case ICElement.C_TEMPLATE_CLASS:
+                               return parentType == ICElement.C_UNIT || parentType == ICElement.C_NAMESPACE;
+                       case ICElement.C_NAMESPACE:
+                               return parentType == ICElement.C_UNIT;
+                       default:
+                               return false;
+                       }
+               }
+       }
+
+       protected static class IncludeGroupingAction extends Action {
+               AbstractCModelOutlinePage fOutLinePage;
+
+               public IncludeGroupingAction(AbstractCModelOutlinePage outlinePage) {
+                       super(ActionMessages.IncludesGroupingAction_label);
+                       setDescription(ActionMessages.IncludesGroupingAction_description);
+                       setToolTipText(ActionMessages.IncludesGroupingAction_tooltip);
+                       CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_GROUP_INCLUDE);
+
+                       boolean enabled= isIncludesGroupingEnabled();
+                       setChecked(enabled);
+                       fOutLinePage = outlinePage;
+               }
+
+               /**
+                * Runs the action.
+                */
+               @Override
+               public void run() {
+                       PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.OUTLINE_GROUP_INCLUDES, isChecked());
+               }
+
+               public boolean isIncludesGroupingEnabled () {
+                       return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.OUTLINE_GROUP_INCLUDES);
+               }
+
+       }
+
+       /**
+        * This action toggles macro grouping
+        * 
+        * @since 5.2
+        */
+       protected static class MacroGroupingAction extends Action {
+
+               public MacroGroupingAction(AbstractCModelOutlinePage outlinePage) {
+                       super(ActionMessages.MacroGroupingAction_label);
+                       setDescription(ActionMessages.MacroGroupingAction_description);
+                       setToolTipText(ActionMessages.MacroGroupingAction_tooltip);
+                       CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_MACROS);
+                       this.setImageDescriptor(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_MACRO));
+                       this.setDisabledImageDescriptor(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_MACRO));
+                       
+
+                       boolean enabled= isMacroGroupingEnabled();
+                       setChecked(enabled);
+               }
+
+               /**
+                * Runs the action.
+                */
+               @Override
+               public void run() {
+                       PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.OUTLINE_GROUP_MACROS, isChecked());
+               }
+
+               public boolean isMacroGroupingEnabled () {
+                       return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.OUTLINE_GROUP_MACROS);
+               }
+
+       }
+       
+       /**
+        * This action toggles whether this C Outline page links
+        * its selection to the active editor.
+        * 
+        * @since 3.0
+        */
+       public class ToggleLinkingAction extends AbstractToggleLinkingAction {
+       
+               /**
+                * Constructs a new action.
+                */
+               public ToggleLinkingAction() {
+                       setChecked(isLinkingEnabled());
+               }
+
+               /**
+                * Runs the action.
+                */
+               @Override
+               public void run() {
+                       boolean checked = isChecked();
+                       PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.OUTLINE_LINK_TO_EDITOR, checked);
+                       if (checked && fEditor != null)
+                               synchronizeSelectionWithEditor();
+               }
+       }
+       
+       private static final long TEXT_FLAGS = AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | CElementLabels.F_APP_TYPE_SIGNATURE | CElementLabels.M_APP_RETURNTYPE;
+       private static final int IMAGE_FLAGS = AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS;
+       protected ITextEditor fEditor;
+       protected ITranslationUnit fInput;
+       private ProblemTreeViewer fTreeViewer;
+       private ListenerList fSelectionChangedListeners = new ListenerList(ListenerList.IDENTITY);
+       protected TogglePresentationAction fTogglePresentation;
+       protected String fContextMenuId;
+       private Menu fMenu;
+       protected OpenIncludeAction fOpenIncludeAction;
+       private ToggleLinkingAction fToggleLinkingAction;
+       private ActionGroup fMemberFilterActionGroup;
+       private ActionGroup fSelectionSearchGroup;
+       private ActionGroup fRefactoringActionGroup;
+       private ActionGroup fSourceActionGroup;
+       private ActionGroup fOpenViewActionGroup;
+       /**
+        * Custom filter action group.
+        * @since 3.0
+        */
+       private ActionGroup fCustomFiltersActionGroup;
+
+       /**
+        * Create a new outline page for the given editor.
+        * @param contextMenuId  The id of this page's context menu
+        * @param editor  the editor associated with this outline page
+        */
+       public AbstractCModelOutlinePage(String contextMenuId, ITextEditor editor) {
+               super();
+               fEditor= editor;
+               fInput= null;
+               fContextMenuId= contextMenuId;
+
+               fTogglePresentation= new TogglePresentationAction();
+               fTogglePresentation.setEditor(editor);
+               
+               fOpenIncludeAction= new OpenIncludeAction(this);
+       }
+
+       /*
+        * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+        */
+       @SuppressWarnings("rawtypes")
+       public Object getAdapter(Class key) {
+               if (key == IShowInSource.class) {
+                       return getShowInSource();
+               }
+               if (key == IShowInTargetList.class) {
+                       return new IShowInTargetList() {
+                               public String[] getShowInTargetIds() {
+                                       return new String[] { ProjectExplorer.VIEW_ID };
+                               }
+                       };
+               }
+               if (key == IShowInTarget.class) {
+                       return getShowInTarget();
+               }
+               return null;
+       }
+
+       /**
+        * Returns the <code>IShowInSource</code> for this view.
+        *
+        * @return the {@link IShowInSource}
+        */
+       protected IShowInSource getShowInSource() {
+               return new IShowInSource() {
+                       public ShowInContext getShowInContext() {
+                               return new ShowInContext(
+                                       null,
+                                       getSite().getSelectionProvider().getSelection());
+                       }
+               };
+       }
+
+       /**
+        * Returns the <code>IShowInTarget</code> for this view.
+        *
+        * @return the {@link IShowInTarget}
+        */
+       protected IShowInTarget getShowInTarget() {
+               return new IShowInTarget() {
+                       public boolean show(ShowInContext context) {
+                               ISelection sel= context.getSelection();
+                               if (sel instanceof ITextSelection) {
+                                       ITextSelection tsel= (ITextSelection) sel;
+                                       int offset= tsel.getOffset();
+                                       ICElement element= null;
+                                       if (fEditor instanceof CEditor) {
+                                               element= ((CEditor)fEditor).getElementAt(offset, false);
+                                       } else if (fInput != null) {
+                                               try {
+                                                       element= fInput.getElementAtOffset(offset);
+                                               } catch (CModelException exc) {
+                                                       CUIPlugin.log(exc);
+                                               }
+                                       }
+                                       if (element != null) {
+                                               setSelection(new StructuredSelection(element));
+                                               return true;
+                                       }
+                               } else if (sel instanceof IStructuredSelection) {
+                                       setSelection(sel);
+                                       return true;
+                               }
+                               return false;
+                       }
+               };
+       }
+
+       public boolean isLinkingEnabled() {
+               return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.OUTLINE_LINK_TO_EDITOR);
+       }
+
+       public ICElement getRoot() {
+               return fInput;
+       }
+
+       /**
+        * Sets the selected element to the one at the current cursor position in the editor.
+        */
+       public void synchronizeSelectionWithEditor() {
+               if(fInput == null || fEditor == null || fTreeViewer == null)
+                       return;
+       
+               ITextSelection editorSelection = (ITextSelection) fEditor.getSelectionProvider().getSelection();
+               if(editorSelection == null)
+                       return;
+               
+               int offset = editorSelection.getOffset();
+               
+               ICElement editorElement= null;
+               try {
+                        if (fInput.isStructureKnown() && fInput.isConsistent()) {
+                                editorElement = fInput.getElementAtOffset(offset);
+                        }
+               } catch (CModelException e) {
+                       return;
+               }
+       
+               if (editorElement != null) {
+                       IStructuredSelection selection = new StructuredSelection(editorElement);
+                       fTreeViewer.setSelection(selection, true);
+               }
+       }
+
+       /**
+        * called to create the context menu of the outline
+        */
+       protected void contextMenuAboutToShow(IMenuManager menu) {
+               CUIPlugin.createStandardGroups(menu);
+               
+               ISelection selection= getSelection();
+               if (fOpenViewActionGroup != null && OpenViewActionGroup.canActionBeAdded(selection)){
+                       fOpenViewActionGroup.fillContextMenu(menu);
+               }
+       
+               if (OpenIncludeAction.canActionBeAdded(selection)) {
+                       menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, fOpenIncludeAction);
+               }
+       
+               if (fSelectionSearchGroup != null && SelectionSearchGroup.canActionBeAdded(selection)){
+                       fSelectionSearchGroup.fillContextMenu(menu);
+                       menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+               }
+               
+               if (fSourceActionGroup != null) {
+                       fSourceActionGroup.fillContextMenu(menu);
+               }
+       
+               if (fRefactoringActionGroup != null) {
+                       fRefactoringActionGroup.fillContextMenu(menu);
+               }
+       }
+
+       protected CContentOutlinerProvider createContentProvider(TreeViewer viewer) {
+               IWorkbenchPart part= getSite().getPage().getActivePart();
+               if (part == null) {
+                       return new CContentOutlinerProvider(viewer);
+               }
+               return new CContentOutlinerProvider(viewer, part.getSite());
+       }
+
+       protected ProblemTreeViewer createTreeViewer(Composite parent) {
+               fTreeViewer = new OutlineTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+               fTreeViewer.setContentProvider(createContentProvider(fTreeViewer));
+               fTreeViewer.setLabelProvider(new DecoratingCLabelProvider(createLabelProvider(), true));
+               fTreeViewer.setAutoExpandLevel(3);
+               fTreeViewer.setUseHashlookup(true);
+               fTreeViewer.addSelectionChangedListener(this);
+               return fTreeViewer;
+       }
+
+       private CUILabelProvider createLabelProvider() {
+               return new COutlineLabelProvider(TEXT_FLAGS, IMAGE_FLAGS);
+       }
+       
+       @Override
+       public void createControl(Composite parent) {
+               fTreeViewer = createTreeViewer(parent);
+               initDragAndDrop();
+       
+               MenuManager manager= new MenuManager(fContextMenuId);
+               manager.setRemoveAllWhenShown(true);
+               manager.addMenuListener(new IMenuListener() {
+                       public void menuAboutToShow(IMenuManager manager) {
+                               contextMenuAboutToShow(manager);
+                       }
+               });
+               Control control= fTreeViewer.getControl();
+               fMenu= manager.createContextMenu(control);
+               control.setMenu(fMenu);
+       
+               fTreeViewer.addDoubleClickListener(new IDoubleClickListener() {
+                       public void doubleClick(DoubleClickEvent event) {
+                               if (fOpenIncludeAction != null) {
+                                       fOpenIncludeAction.run();
+                               }
+                       }
+               });
+               // register global actions
+               IPageSite site= getSite();
+               site.registerContextMenu(fContextMenuId, manager, fTreeViewer);
+               site.setSelectionProvider(fTreeViewer);
+               
+               IActionBars bars= site.getActionBars();         
+               bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY, fTogglePresentation);
+       
+               fSelectionSearchGroup = createSearchActionGroup();
+               fOpenViewActionGroup = createOpenViewActionGroup();
+               fSourceActionGroup = createSourceActionGroup();
+               fRefactoringActionGroup= createRefactoringActionGroup();
+               // Custom filter group
+               fCustomFiltersActionGroup= createCustomFiltersActionGroup();
+       
+               // Do this before setting input but after the initializations of the fields filtering
+               registerActionBars(bars);
+       
+               fTreeViewer.setInput(fInput);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(control, ICHelpContextIds.COUTLINE_VIEW);
+       }
+
+       @Override
+       public void dispose() {
+               if (fTreeViewer != null) {
+                       fTreeViewer.removeSelectionChangedListener(this);
+                       fTreeViewer= null;
+               }
+               
+               if (fTogglePresentation != null) {
+                       fTogglePresentation.setEditor(null);
+                       fTogglePresentation= null;
+               }
+               
+               if (fMemberFilterActionGroup != null) {
+                       fMemberFilterActionGroup.dispose();
+                       fMemberFilterActionGroup= null;
+               }
+               
+               if (fOpenViewActionGroup != null) {
+                   fOpenViewActionGroup.dispose();
+                   fOpenViewActionGroup= null;
+               }
+       
+               if (fRefactoringActionGroup != null) {
+                       fRefactoringActionGroup.dispose();
+                       fRefactoringActionGroup= null;
+               }
+       
+               if (fSelectionSearchGroup != null) {
+                       fSelectionSearchGroup.dispose();
+                       fSelectionSearchGroup= null;
+               }
+       
+               if (fCustomFiltersActionGroup != null) {
+                       fCustomFiltersActionGroup.dispose();
+                       fCustomFiltersActionGroup= null;
+               }
+       
+               if (fSelectionChangedListeners != null) {
+                       fSelectionChangedListeners.clear();
+                       // don't set the listeners to null, the outline page may be reused.
+               }
+       
+               if (fMenu != null && !fMenu.isDisposed()) {
+                       fMenu.dispose();
+                       fMenu= null;
+               }
+       
+               fInput= null;
+               
+               super.dispose();
+       }
+
+       /**
+        * Register actions to the action bars.
+        * 
+        * @param actionBars
+        */
+       protected void registerActionBars(IActionBars actionBars) {
+               IToolBarManager toolBarManager= actionBars.getToolBarManager();
+               
+               LexicalSortingAction action= new LexicalSortingAction(getTreeViewer());
+               toolBarManager.add(action);
+       
+               fMemberFilterActionGroup= createMemberFilterActionGroup();
+               if (fMemberFilterActionGroup != null) {
+                       fMemberFilterActionGroup.fillActionBars(actionBars);
+               }
+               if (fCustomFiltersActionGroup != null) {
+                       fCustomFiltersActionGroup.fillActionBars(actionBars);
+               }
+               if (fOpenViewActionGroup != null) {
+                       fOpenViewActionGroup.fillActionBars(actionBars);
+               }
+               if (fRefactoringActionGroup != null) {
+                       fRefactoringActionGroup.fillActionBars(actionBars);
+               }
+       
+               IMenuManager menu= actionBars.getMenuManager();
+               menu.add(new Separator("EndFilterGroup")); //$NON-NLS-1$
+               
+               fToggleLinkingAction= new ToggleLinkingAction();
+               menu.add(fToggleLinkingAction);
+               
+               menu.add(new Separator("group.layout")); //$NON-NLS-1$
+               menu.add(new IncludeGroupingAction(this));
+               menu.add(new MacroGroupingAction(this));
+       }
+
+       /**
+        * return an ActionGroup contributing search actions or
+        *         <code>null</code> if search is not supported
+        */
+       protected ActionGroup createSearchActionGroup() {
+               // default: no search action group
+               return null;
+       }
+
+       /**
+        * @return an OpenViewActionGroup contributing open view actions or
+        *         <code>null</code> if open view actions are not wanted
+        */
+       protected ActionGroup createOpenViewActionGroup() {
+               // default: no open view action group
+               return null;
+       }
+
+       /**
+        * @return an ActionGroup contributing refactoring actions or
+        *         <code>null</code> if refactoring is not supported
+        */
+       protected ActionGroup createRefactoringActionGroup() {
+               // default: no refactoring actions
+               return null;
+       }
+       
+       /**
+        * @return an ActionGroup contributing source actions or
+        *         <code>null</code> if source actions are not supported
+        */
+       protected ActionGroup createSourceActionGroup() {
+               // default: no source actions
+               return null;
+       }
+
+       /**
+        * @return an ActionGroup instance to provide custom filters or
+        *         <code>null</code> if this action group is not wanted
+        */
+       protected ActionGroup createCustomFiltersActionGroup() {
+               // default: no custom filters
+               return null;
+       }
+
+       /**
+        * @return an ActionGroup contributing member filters or <code>null</code>
+        *         if member filters are not wanted
+        */
+       protected ActionGroup createMemberFilterActionGroup() {
+               // default: no member filters
+               return null;
+       }
+
+       public void addSelectionChangedListener(ISelectionChangedListener listener) {
+               fSelectionChangedListeners.add(listener);
+       }
+
+       /**
+        * Fires a selection changed event.
+        *
+        * @param selection the new selection
+        */
+       protected void fireSelectionChanged(ISelection selection) {
+               // create an event
+               SelectionChangedEvent event = new SelectionChangedEvent(this, selection);
+       
+               // fire the event
+               Object[] listeners = fSelectionChangedListeners.getListeners();
+               for (int i = 0; i < listeners.length; ++i) {
+                       ((ISelectionChangedListener) listeners[i]).selectionChanged(event);
+               }
+               if (fRefactoringActionGroup != null) {
+                       fRefactoringActionGroup.setContext(new ActionContext(selection));
+                       fRefactoringActionGroup.updateActionBars();
+               }
+               
+               if (fSourceActionGroup != null) {
+                       fSourceActionGroup.setContext(new ActionContext(selection));
+                       fSourceActionGroup.updateActionBars();
+               }
+       }
+
+       @Override
+       public Control getControl() {
+               if (fTreeViewer == null)
+                       return null;
+               return fTreeViewer.getControl();
+       }
+
+       public ISelection getSelection() {
+               if (fTreeViewer == null)
+                       return StructuredSelection.EMPTY;
+               return fTreeViewer.getSelection();
+       }
+
+       /**
+        * Returns this page's tree viewer.
+        *
+        * @return this page's tree viewer, or <code>null</code> if 
+        *   <code>createControl</code> has not been called yet
+        */
+       protected TreeViewer getTreeViewer() {
+               return fTreeViewer;
+       }
+
+       public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+               fSelectionChangedListeners.remove(listener);
+       }
+
+       public void selectionChanged(SelectionChangedEvent event) {
+               fireSelectionChanged(event.getSelection());
+       }
+
+       /**
+        * Sets focus to a part in the page.
+        */
+       @Override
+       public void setFocus() {
+               fTreeViewer.getControl().setFocus();
+       }
+
+       public void setSelection(ISelection selection) {
+               if (fTreeViewer != null) 
+                       fTreeViewer.setSelection(selection);
+       }
+
+       /**
+        * Set the current input to the content provider.  
+        * @param unit
+        */
+       public void setInput(ITranslationUnit unit) {
+               fInput = unit;
+               if (fTreeViewer != null) {
+                       fTreeViewer.setInput (fInput);
+               }
+       }
+
+       private void initDragAndDrop() {
+               int ops= DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
+               Transfer[] transfers= new Transfer[] {
+                       LocalSelectionTransfer.getTransfer()
+               };
+               
+               // Drop Adapter
+               TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] {
+                       new SelectionTransferDropAdapter(fTreeViewer)
+               };
+               fTreeViewer.addDropSupport(ops | DND.DROP_DEFAULT, transfers, new DelegatingDropAdapter(dropListeners));
+               
+               // Drag Adapter
+               TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] {
+                       new SelectionTransferDragAdapter(fTreeViewer)
+               };
+               fTreeViewer.addDragSupport(ops, transfers, new CDTViewerDragAdapter(fTreeViewer, dragListeners));
+       }
+
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AddIncludeOnSelectionAction.java
new file mode 100644 (file)
index 0000000..4c77039
--- /dev/null
@@ -0,0 +1,724 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software Systems
+ *     Markus Schorn (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+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.core.runtime.Status;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.TextEditorAction;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNodeSelector;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.ICompositeType;
+import org.eclipse.cdt.core.dom.ast.IEnumeration;
+import org.eclipse.cdt.core.dom.ast.IEnumerator;
+import org.eclipse.cdt.core.dom.ast.IFunction;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.ITypedef;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexBinding;
+import org.eclipse.cdt.core.index.IIndexFile;
+import org.eclipse.cdt.core.index.IIndexInclude;
+import org.eclipse.cdt.core.index.IIndexMacro;
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.core.index.IndexFilter;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.parser.IScannerInfo;
+import org.eclipse.cdt.core.parser.IScannerInfoProvider;
+import org.eclipse.cdt.core.parser.Keywords;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.IFunctionSummary;
+import org.eclipse.cdt.ui.IRequiredInclude;
+import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
+import org.eclipse.cdt.ui.text.SharedASTJob;
+import org.eclipse.cdt.utils.PathUtil;
+
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
+import org.eclipse.cdt.internal.core.resources.ResourceLookup;
+import org.eclipse.cdt.internal.corext.codemanipulation.AddIncludesOperation;
+
+import org.eclipse.cdt.internal.ui.CHelpProviderManager;
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.actions.WorkbenchRunnableAdapter;
+import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
+
+/**
+ * Adds an include statement and, optionally, a 'using' declaration for the currently
+ * selected name.
+ */
+public class AddIncludeOnSelectionAction extends TextEditorAction {
+       public static boolean sIsJUnitTest = false;
+
+       private ITranslationUnit fTu;
+       private IProject fProject;
+       private String[] fIncludePath;
+       private IRequiredInclude[] fRequiredIncludes;
+       private String[] fUsingDeclarations;
+
+       public AddIncludeOnSelectionAction(ITextEditor editor) {
+               super(CEditorMessages.getBundleForConstructedKeys(), "AddIncludeOnSelection.", editor); //$NON-NLS-1$
+
+               CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(this,
+                               ICHelpContextIds.ADD_INCLUDE_ON_SELECTION_ACTION);
+       }
+
+       private void insertInclude(IRequiredInclude[] includes, String[] usings, int beforeOffset) {
+               AddIncludesOperation op= new AddIncludesOperation(fTu, beforeOffset, includes, usings);
+               try {
+                       PlatformUI.getWorkbench().getProgressService().runInUI(
+                                       PlatformUI.getWorkbench().getProgressService(),
+                                       new WorkbenchRunnableAdapter(op), op.getSchedulingRule());
+               } catch (InvocationTargetException e) {
+                       ExceptionHandler.handle(e, getShell(), CEditorMessages.AddIncludeOnSelection_error_title,
+                                       CEditorMessages.AddIncludeOnSelection_insertion_failed); 
+               } catch (InterruptedException e) {
+                       // Do nothing. Operation has been canceled.
+               }
+       }
+
+       private static ITranslationUnit getTranslationUnit(ITextEditor editor) {
+               if (editor == null) {
+                       return null;
+               }
+               return CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
+       }
+
+       private Shell getShell() {
+               return getTextEditor().getSite().getShell();
+       }
+
+       @Override
+       public void run() {
+               fTu = getTranslationUnit(getTextEditor());
+               if (fTu == null) {
+                       return;
+               }
+               fProject = fTu.getCProject().getProject();
+        IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(fProject);
+        fIncludePath = null;
+        if (provider != null) {
+            IScannerInfo info = provider.getScannerInformation(fTu.getResource());
+            if (info != null) {
+                fIncludePath = info.getIncludePaths();
+            }
+        }
+        if (fIncludePath == null) {
+               fIncludePath = new String[0];
+        }
+
+               try {
+                       final ISelection selection= getTextEditor().getSelectionProvider().getSelection();
+                       if (selection.isEmpty() || !(selection instanceof ITextSelection)) {
+                               return;
+                       }
+                       if (!validateEditorInputState()) {
+                               return;
+                       }
+
+                       final String[] lookupName = new String[1];
+
+                       SharedASTJob job = new SharedASTJob(CEditorMessages.AddIncludeOnSelection_label, fTu) {
+                               @Override
+                               public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
+                                       deduceInclude((ITextSelection) selection, ast, lookupName);
+                                       return Status.OK_STATUS;
+                               }
+                       };
+                       job.schedule();
+                       job.join();
+
+                       if (fRequiredIncludes == null || fRequiredIncludes.length == 0 && lookupName[0].length() > 0) {
+                               // Try contribution from plugins.
+                               IFunctionSummary fs = findContribution(lookupName[0]);
+                               if (fs != null) {
+                                       fRequiredIncludes = fs.getIncludes();
+                                       String ns = fs.getNamespace();
+                                       if (ns != null && ns.length() > 0) {
+                                               fUsingDeclarations = new String[] { fs.getNamespace() };
+                                       }
+                               }
+
+                       }
+                       if (fRequiredIncludes != null && fRequiredIncludes.length >= 0) {
+                               insertInclude(fRequiredIncludes, fUsingDeclarations, ((ITextSelection) selection).getOffset());
+                       }
+               } catch (InterruptedException e) {
+                       Thread.currentThread().interrupt();
+               }
+       }
+
+       /**
+        * Extracts the includes for the given selection.  This can be both used to perform
+        * the work as well as being invoked when there is a change.
+        * @param selection a text selection.
+        * @param ast an AST.
+        * @param lookupName a one-element array used to return the selected name.
+        */
+       private void deduceInclude(ITextSelection selection, IASTTranslationUnit ast, String[] lookupName)
+                       throws CoreException {
+               IASTNodeSelector selector = ast.getNodeSelector(fTu.getLocation().toOSString());
+               IASTName name = selector.findEnclosingName(selection.getOffset(), selection.getLength());
+               if (name == null) {
+                       return;
+               }
+               char[] nameChars = name.toCharArray();
+               lookupName[0] = new String(nameChars);
+               IBinding binding = name.resolveBinding();
+               if (binding instanceof ICPPVariable) {
+                       IType type = ((ICPPVariable) binding).getType();
+                       type = SemanticUtil.getNestedType(type,
+                                       SemanticUtil.ALLCVQ | SemanticUtil.PTR | SemanticUtil.ARRAY | SemanticUtil.REF);
+                       if (type instanceof IBinding) {
+                               binding = (IBinding) type;
+                               nameChars = binding.getNameCharArray();
+                       }
+               }
+               if (nameChars.length == 0) {
+                       return;
+               }
+
+               final Map<String, IncludeCandidate> candidatesMap= new HashMap<String, IncludeCandidate>();
+               final IIndex index = ast.getIndex();
+               final IndexFilter filter = IndexFilter.getDeclaredBindingFilter(ast.getLinkage().getLinkageID(), false);
+               
+               List<IIndexBinding> bindings = new ArrayList<IIndexBinding>();
+               IIndexBinding adaptedBinding= index.adaptBinding(binding);
+               if (adaptedBinding == null) {
+                       bindings.addAll(Arrays.asList(index.findBindings(nameChars, false, filter, new NullProgressMonitor())));
+               } else {
+                       bindings.add(adaptedBinding);
+                       while (adaptedBinding instanceof ICPPSpecialization) {
+                               adaptedBinding= index.adaptBinding(((ICPPSpecialization) adaptedBinding).getSpecializedBinding());
+                               if (adaptedBinding != null) {
+                                       bindings.add(adaptedBinding);
+                               }
+                       }
+               }
+
+               for (IIndexBinding indexBinding : bindings) {
+                       // Replace ctor with the class itself.
+                       if (indexBinding instanceof ICPPConstructor) {
+                               indexBinding = indexBinding.getOwner();
+                       }
+                       IIndexName[] definitions= null;
+                       // class, struct, union, enum-type, enum-item
+                       if (indexBinding instanceof ICompositeType || indexBinding instanceof IEnumeration || indexBinding instanceof IEnumerator) {
+                               definitions= index.findDefinitions(indexBinding);
+                       } else if (indexBinding instanceof ITypedef || (indexBinding instanceof IFunction)) {
+                               definitions = index.findDeclarations(indexBinding);
+                       }
+                       if (definitions != null) {
+                               for (IIndexName definition : definitions) {
+                                       considerForInclusion(definition, indexBinding, index, candidatesMap);
+                               }
+                               if (definitions.length > 0 && adaptedBinding != null) 
+                                       break;
+                       }
+               }
+               IIndexMacro[] macros = index.findMacros(nameChars, filter, new NullProgressMonitor());
+               for (IIndexMacro macro : macros) {
+                       IIndexName definition = macro.getDefinition();
+                       considerForInclusion(definition, macro, index, candidatesMap);
+               }
+
+               final ArrayList<IncludeCandidate> candidates = new ArrayList<IncludeCandidate>(candidatesMap.values());
+               if (candidates.size() > 1) {
+                       if (sIsJUnitTest) {
+                               throw new RuntimeException("ambiguous input"); //$NON-NLS-1$
+                       }
+                       runInUIThread(new Runnable() {
+                               public void run() {
+                                       ElementListSelectionDialog dialog=
+                                               new ElementListSelectionDialog(getShell(), new LabelProvider());
+                                       dialog.setElements(candidates.toArray());
+                                       dialog.setTitle(CEditorMessages.AddIncludeOnSelection_label); 
+                                       dialog.setMessage(CEditorMessages.AddIncludeOnSelection_description); 
+                                       if (dialog.open() == Window.OK) {
+                                               candidates.clear();
+                                               candidates.add((IncludeCandidate) dialog.getFirstResult());
+                                       }
+                               }
+                       });
+               }
+
+               fRequiredIncludes = null;
+               fUsingDeclarations = null;
+               if (candidates.size() == 1) {
+                       IncludeCandidate candidate = candidates.get(0);
+                       fRequiredIncludes = new IRequiredInclude[] { candidate.getInclude() };
+                       IIndexBinding indexBinding = candidate.getBinding();
+
+                       if (indexBinding instanceof ICPPBinding && !(indexBinding instanceof IIndexMacro)) {
+                               // Decide what 'using' declaration, if any, should be added along with the include.
+                               String usingDeclaration = deduceUsingDeclaration(binding, indexBinding, ast);
+                               if (usingDeclaration != null)
+                                       fUsingDeclarations = new String[] { usingDeclaration };
+                       }
+               }
+       }
+
+       /**
+        * Adds an include candidate to the <code>candidates</code> map if the file containing
+        * the definition is suitable for inclusion.
+        */
+       private void considerForInclusion(IIndexName definition, IIndexBinding binding,
+                       IIndex index, Map<String, IncludeCandidate> candidates) throws CoreException {
+               if (definition == null) {
+                       return;
+               }
+               IIndexFile file = definition.getFile();
+               // Consider the file for inclusion only if it is not a source file,
+               // or a source file that was already included by some other file. 
+               if (!isSource(getPath(file)) || index.findIncludedBy(file, 0).length > 0) {
+                       IIndexFile representativeFile = getRepresentativeFile(file, index);
+                       IRequiredInclude include = getRequiredInclude(representativeFile, index);
+                       if (include != null) {
+                               IncludeCandidate candidate = new IncludeCandidate(binding, include);
+                               if (!candidates.containsKey(candidate.toString())) {
+                                       candidates.put(candidate.toString(), candidate);
+                               }
+                       }
+               }
+       }
+
+       private String deduceUsingDeclaration(IBinding source, IBinding target, IASTTranslationUnit ast) {
+               if (source.equals(target)) {
+                       return null;  // No using declaration is needed.
+               }
+               ArrayList<String> targetChain = getUsingChain(target);
+               if (targetChain.size() <= 1) {
+                       return null;  // Target is not in a namespace
+               }
+
+               // Check if any of the existing using declarations and directives matches
+               // the target.
+               final IASTDeclaration[] declarations= ast.getDeclarations(false);
+               for (IASTDeclaration declaration : declarations) {
+                       if (declaration.isPartOfTranslationUnitFile()) {
+                               IASTName name = null;
+                               if (declaration instanceof ICPPASTUsingDeclaration) {
+                                       name = ((ICPPASTUsingDeclaration) declaration).getName();
+                                       if (match(name, targetChain, false)) {
+                                               return null;
+                                       }
+                               } else if (declaration instanceof ICPPASTUsingDirective) {
+                                       name = ((ICPPASTUsingDirective) declaration).getQualifiedName();
+                                       if (match(name, targetChain, true)) {
+                                               return null;
+                                       }
+                               }
+                       }
+               }
+
+               ArrayList<String> sourceChain = getUsingChain(source);
+               if (sourceChain.size() >= targetChain.size()) {
+                       int j = targetChain.size();
+                       for (int i = sourceChain.size(); --j >= 1 && --i >= 1;) {
+                               if (!sourceChain.get(i).equals(targetChain.get(j))) {
+                                       break;
+                               }
+                       }
+                       if (j <= 0) {
+                               return null;  // Source is in the target's namespace
+                       }
+               }
+               StringBuilder buf = new StringBuilder();
+               for (int i = targetChain.size(); --i >= 0;) {
+                       if (buf.length() > 0) {
+                               buf.append("::"); //$NON-NLS-1$
+                       }
+                       buf.append(targetChain.get(i));
+               }
+               return buf.toString();
+       }
+
+       private boolean match(IASTName name, ArrayList<String> usingChain, boolean excludeLast) {
+               IASTName[] names;
+               if (name instanceof ICPPASTQualifiedName) {
+                       names = ((ICPPASTQualifiedName) name).getNames();
+               } else {
+                       names = new IASTName[] { name };
+               }
+               if (names.length != usingChain.size() - (excludeLast ? 1 : 0)) {
+                       return false;
+               }
+               for (int i = 0; i < names.length; i++) {
+                       if (!names[i].toString().equals(usingChain.get(usingChain.size() - 1 - i))) {
+                               return false;
+                       }
+               }
+               return true;
+       }
+
+       /**
+        * Returns components of the qualified name in reverse order.
+        * For ns1::ns2::Name, e.g., it returns [Name, ns2, ns1].
+        */
+       private ArrayList<String> getUsingChain(IBinding binding) {
+               ArrayList<String> chain = new ArrayList<String>(4);
+               for (; binding != null; binding = binding.getOwner()) {
+                       String name = binding.getName();
+                       if (binding instanceof ICPPNamespace) {
+                               if (name.length() == 0) {
+                                       continue;
+                               }
+                       } else {
+                               chain.clear();
+                       }
+                       chain.add(name);
+               }
+               return chain;
+       }
+
+       /**
+        * Given a header file, decides if this header file should be included directly or
+        * through another header file. For example, <code>bits/stl_map.h</code> is not supposed
+        * to be included directly, but should be represented by <code>map</code>.
+        * @return the header file to include.
+        */
+       private IIndexFile getRepresentativeFile(IIndexFile headerFile, IIndex index) {
+               try {
+                       if (isWorkspaceFile(headerFile.getLocation().getURI())) {
+                               return headerFile;
+                       }
+                       // TODO(sprigogin): Change to ArrayDeque when Java 5 support is no longer needed.
+                       LinkedList<IIndexFile> front = new LinkedList<IIndexFile>();
+                       front.add(headerFile);
+                       HashSet<IIndexFile> processed = new HashSet<IIndexFile>();
+                       processed.add(headerFile);
+                       while (!front.isEmpty()) {
+                               IIndexFile file = front.remove();
+                               // A header without an extension is a good candidate for inclusion into a C++ source file.
+                               if (fTu.isCXXLanguage() && !hasExtension(getPath(file))) {
+                                       return file;
+                               }
+                               IIndexInclude[] includes = index.findIncludedBy(file, 0);
+                               for (IIndexInclude include : includes) {
+                                       IIndexFile includer = include.getIncludedBy();
+                                       if (!processed.contains(includer)) {
+                                               URI uri = includer.getLocation().getURI();
+                                               if (isSource(uri.getPath()) || isWorkspaceFile(uri)) {
+                                                       return file;
+                                               }
+                                               front.add(includer);
+                                               processed.add(includer);
+                                       }
+                               }
+                       }
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }
+               return headerFile;
+       }
+
+       private boolean isWorkspaceFile(URI uri) {
+               for (IFile file : ResourceLookup.findFilesForLocationURI(uri)) {
+                       if (file.exists()) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+       private boolean hasExtension(String path) {
+               return path.indexOf('.', path.lastIndexOf('/') + 1) >= 0;
+       }
+
+       private IFunctionSummary findContribution(final String name) {
+               final IFunctionSummary[] fs = new IFunctionSummary[1];
+               IRunnableWithProgress op = new IRunnableWithProgress() {
+                       public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+                               ICHelpInvocationContext context = new ICHelpInvocationContext() {
+                                       public IProject getProject() {
+                                               return fProject;
+                                       }
+
+                                       public ITranslationUnit getTranslationUnit() {
+                                               return fTu;
+                                       }
+                               };
+
+                               fs[0] = CHelpProviderManager.getDefault().getFunctionInfo(context, name);
+                       }
+               };
+               try {
+                       PlatformUI.getWorkbench().getProgressService().busyCursorWhile(op);
+               } catch (InvocationTargetException e) {
+                       ExceptionHandler.handle(e, getShell(), CEditorMessages.AddIncludeOnSelection_error_title,
+                                       CEditorMessages.AddIncludeOnSelection_help_provider_error); 
+               } catch (InterruptedException e) {
+                       // Do nothing. Operation has been canceled.
+               }
+               return fs[0];
+       }
+
+       private void runInUIThread(Runnable runnable) {
+               if (Display.getCurrent() != null) {
+                       runnable.run();
+               } else {
+                       Display.getDefault().syncExec(runnable);
+               }
+       }
+
+       @Override
+       public void update() {
+               ITextEditor editor = getTextEditor();
+               setEnabled(editor != null && getTranslationUnit(editor) != null);
+       }
+
+       /**
+        * Checks if a file is a source file (.c, .cpp, .cc, etc). Header files are not considered source files.
+        * @return Returns <code>true</code> if the the file is a source file.
+        */
+       private boolean isSource(String filename) {
+               IContentType ct= CCorePlugin.getContentType(fProject, filename);
+               if (ct != null) {
+                       String id = ct.getId();
+                       if (CCorePlugin.CONTENT_TYPE_CSOURCE.equals(id) || CCorePlugin.CONTENT_TYPE_CXXSOURCE.equals(id)) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+       private static String getPath(IIndexFile file) throws CoreException {
+               return file.getLocation().getURI().getPath();
+       }
+
+       /**
+        * Returns the RequiredInclude object to be added to the include list
+        * @param path - the full path of the file to include
+        * @return the required include
+        * @throws CoreException 
+        */
+       private IRequiredInclude getRequiredInclude(IIndexFile file, IIndex index) throws CoreException {
+               IIndexInclude[] includes;
+               includes = index.findIncludedBy(file);
+               if (includes.length > 0) {
+                       // Let the existing includes vote. To be eligible to vote, an include
+                       // has to be resolvable in the context of the current translation unit.
+                       int systemIncludeVotes = 0;
+                       String[] ballotBox = new String[includes.length];
+                       int k = 0;
+                       for (IIndexInclude include : includes) {
+                               if (isResolvable(include)) {
+                                       ballotBox[k++] = include.getFullName();
+                                       if (include.isSystemInclude()) {
+                                               systemIncludeVotes++;
+                                       }
+                               }
+                       }
+                       if (k != 0) {
+                               Arrays.sort(ballotBox, 0, k);
+                               String contender = ballotBox[0];
+                               int votes = 1;
+                               String winner = contender;
+                               int winnerVotes = votes;
+                               for (int i = 1; i < k; i++) {
+                                       if (!ballotBox[i].equals(contender)) {
+                                               contender = ballotBox[i]; 
+                                               votes = 1;
+                                       }
+                                       votes++;
+                                       if (votes > winnerVotes) {
+                                               winner = contender;
+                                               winnerVotes = votes;
+                                       }
+                               }
+                               return new RequiredInclude(winner, systemIncludeVotes * 2 >= k);
+                       }
+               }
+
+               // The file has never been included before.
+               URI targetUri = file.getLocation().getURI();
+        IPath targetLocation = PathUtil.getCanonicalPath(new Path(targetUri.getPath()));
+       IPath sourceLocation = PathUtil.getCanonicalPath(fTu.getResource().getLocation());
+        boolean isSystemIncludePath = false;
+
+        IPath path = PathUtil.makeRelativePathToIncludes(targetLocation, fIncludePath);
+        if (path != null && ResourceLookup.findFilesForLocationURI(targetUri).length == 0) {
+               // A header file in the include path but outside the workspace is included with angle brackets.
+            isSystemIncludePath = true;
+        }
+        if (path == null) {
+               IPath sourceDirectory = sourceLocation.removeLastSegments(1);
+               if (PathUtil.isPrefix(sourceDirectory, targetLocation)) {
+                       path = targetLocation.removeFirstSegments(sourceDirectory.segmentCount());
+               } else {
+                       path = targetLocation;
+               }
+               if (targetLocation.getDevice() != null &&
+                               targetLocation.getDevice().equalsIgnoreCase(sourceDirectory.getDevice())) {
+                       path = path.setDevice(null);
+               }
+               if (path.isAbsolute() && path.getDevice() == null &&
+                               ResourceLookup.findFilesForLocationURI(targetUri).length != 0) {
+                       // The file is inside workspace. Include with a relative path.
+                       path = PathUtil.makeRelativePath(path, sourceDirectory);
+               }
+        }
+       return new RequiredInclude(path.toString(), isSystemIncludePath);
+    }
+
+       /**
+        * Returns <code>true</code> if the given include can be resolved in the context of
+        * the current translation unit.
+        */
+       private boolean isResolvable(IIndexInclude include) {
+               try {
+                       File target = new File(include.getIncludesLocation().getURI().getPath());
+                       String includeName = include.getFullName();
+                       for (String dir : fIncludePath) {
+                               if (target.equals(new File(dir, includeName))) {
+                                       return true;
+                               }
+                       }
+                       if (include.isSystemInclude()) {
+                               return false;
+                       }
+                       String directory = new File(fTu.getLocationURI().getPath()).getParent();
+                       return target.equals(new File(directory, includeName).getCanonicalFile());
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+                       return false;
+               } catch (IOException e) {
+                       CUIPlugin.log(e);
+                       return false;
+               }
+       }
+
+       /**
+        * Returns the fully qualified name for a given index binding.
+        * @param binding
+        * @return binding's fully qualified name
+        * @throws CoreException
+        */
+       private static String getBindingQualifiedName(IIndexBinding binding) throws CoreException {
+               String[] qname= CPPVisitor.getQualifiedName(binding);
+               StringBuilder result = new StringBuilder();
+               boolean needSep= false;
+               for (String element : qname) {
+                       if (needSep)
+                               result.append(Keywords.cpCOLONCOLON);
+                       result.append(element);  
+                       needSep= true;
+               }
+               return result.toString();
+       }
+
+       /**
+        * To be used by ElementListSelectionDialog for user to choose which declarations/
+        * definitions for "add include" when there are more than one to choose from.  
+        */
+       private static class IncludeCandidate {
+               private final IIndexBinding binding;
+               private final IRequiredInclude include;
+               private final String label;
+
+               public IncludeCandidate(IIndexBinding binding, IRequiredInclude include) throws CoreException {
+                       this.binding = binding;
+                       this.include = include;
+                       this.label = getBindingQualifiedName(binding) + " - " + include.toString(); //$NON-NLS-1$
+               }
+
+               public IIndexBinding getBinding() {
+                       return binding;
+               }
+
+               public IRequiredInclude getInclude() {
+                       return include;
+               }
+
+               @Override
+               public String toString() {
+                       return label;
+               }
+       }
+
+       private static class RequiredInclude implements IRequiredInclude {
+               final String includeName;
+               final boolean isSystem;
+
+               RequiredInclude(String includeName, boolean isSystem) {
+                       this.includeName = includeName;
+                       this.isSystem = isSystem;
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.cdt.ui.IRequiredInclude#getIncludeName()
+                */
+               public String getIncludeName() {
+                       return includeName;
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.cdt.ui.IRequiredInclude#isStandard()
+                */
+               public boolean isStandard() {
+                       return isSystem;
+               }
+
+               @Override
+               public String toString() {
+                       StringBuilder buf = new StringBuilder(includeName.length() + 2);
+                       buf.append(isSystem ? '<' : '"');
+                       buf.append(includeName);
+                       buf.append(isSystem ? '>' : '"');
+                       return buf.toString();
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CAnnotationIterator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CAnnotationIterator.java
new file mode 100644 (file)
index 0000000..c69ed6e
--- /dev/null
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.ui.texteditor.MarkerAnnotation;
+
+/**
+ * Filters problems based on their types.
+ */
+public class CAnnotationIterator implements Iterator<Annotation> {
+       private Iterator<Annotation> fIterator;
+       private Annotation fNext;
+       private boolean fReturnAllAnnotations;
+       
+       /**
+        * Returns a new CAnnotationIterator.
+        * @param parent the parent iterator to iterate over annotations
+        * @param returnAllAnnotations whether to return all annotations or just problem annotations
+        */
+       public CAnnotationIterator(Iterator<Annotation> parent, boolean returnAllAnnotations) {
+               fReturnAllAnnotations= returnAllAnnotations;
+               fIterator= parent;
+               skip();
+       }
+
+       private void skip() {
+               while (fIterator.hasNext()) {
+                       Annotation next= fIterator.next();
+                       
+                       if (next.isMarkedDeleted())
+                               continue;
+
+                       if (fReturnAllAnnotations || next instanceof ICAnnotation || isProblemMarkerAnnotation(next)) {
+                               fNext= next;
+                               return;
+                       }
+               }
+               fNext= null;
+       }
+
+       private static boolean isProblemMarkerAnnotation(Annotation annotation) {
+               if (!(annotation instanceof MarkerAnnotation))
+                       return false;
+               try {
+                       return(((MarkerAnnotation)annotation).getMarker().isSubtypeOf(IMarker.PROBLEM));
+               } catch (CoreException e) {
+                       return false;
+               }
+       }
+
+       /*
+        * @see Iterator#hasNext()
+        */
+       public boolean hasNext() {
+               return fNext != null;
+       }
+
+       /*
+        * @see Iterator#next()
+        */
+       public Annotation next() {
+               try {
+                       return fNext;
+               } finally {
+                       skip();
+               }
+       }
+
+       /*
+        * @see Iterator#remove()
+        */
+       public void remove() {
+               throw new UnsupportedOperationException();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinePage.java
new file mode 100644 (file)
index 0000000..a24f54f
--- /dev/null
@@ -0,0 +1,236 @@
+/*******************************************************************************
+ *  Copyright (c) 2005, 2010 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Markus Schorn (Wind River Systems)
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StackLayout;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.actions.CustomFiltersActionGroup;
+import org.eclipse.cdt.ui.actions.GenerateActionGroup;
+import org.eclipse.cdt.ui.actions.MemberFilterActionGroup;
+import org.eclipse.cdt.ui.actions.OpenViewActionGroup;
+import org.eclipse.cdt.ui.refactoring.actions.CRefactoringActionGroup;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.actions.ActionMessages;
+import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
+
+
+/**
+ * Outline page for C/C++ translation units.
+ */
+public class CContentOutlinePage extends AbstractCModelOutlinePage {
+       
+       private Composite fParent;
+       private StackLayout fStackLayout;
+       private Composite fOutlinePage;
+       private Control fStatusPage;
+       private boolean fScalabilityMode;
+
+       public CContentOutlinePage(CEditor editor) {
+               super("#TranslationUnitOutlinerContext", editor); //$NON-NLS-1$
+       }
+
+       /**
+        * Provides access to the CEditor corresponding to this CContentOutlinePage.
+        * @returns the CEditor corresponding to this CContentOutlinePage.
+        */
+       public CEditor getEditor() {
+               return (CEditor)fEditor;
+       }
+
+       @Override
+       public void createControl(Composite parent) {
+               fParent = new Composite(parent, SWT.NONE);
+               fStackLayout = new StackLayout();
+               fParent.setLayout(fStackLayout);
+               fOutlinePage = new Composite(fParent, SWT.NONE);
+               fOutlinePage.setLayout(new FillLayout());
+               super.createControl(fOutlinePage);
+               fStatusPage = createStatusPage(fParent);
+               updateVisiblePage();
+       }
+
+       @Override
+       public Control getControl() {
+               return fParent;
+       }
+
+       private Control createStatusPage(Composite parent) {
+               final Link link= new Link(parent, SWT.NONE);
+               link.setText(CEditorMessages.Scalability_outlineDisabled);
+               link.setToolTipText(CEditorMessages.Scalability_linkToolTip);
+               link.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               PreferencesUtil.createPreferenceDialogOn(link.getShell(), "org.eclipse.cdt.ui.preferences.CScalabilityPreferences", null, null).open(); //$NON-NLS-1$
+                       }
+               });
+               return link;
+       }
+
+       @Override
+       public void setInput(ITranslationUnit unit) {
+               final CEditor editor= getEditor();
+               if (editor.isEnableScalablilityMode() 
+                               && PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.SCALABILITY_RECONCILER)) {
+                       fScalabilityMode = true;
+                       super.setInput(null);
+               } else {
+                       fScalabilityMode = false;
+                       super.setInput(unit);
+               }
+               updateVisiblePage();
+       }
+
+       private void updateVisiblePage() {
+               if (fStackLayout == null) {
+                       return;
+               }
+               if (fScalabilityMode) {
+                       if (fStackLayout.topControl != fStatusPage) {
+                               fStackLayout.topControl = fStatusPage;
+                               fParent.layout();
+                       }
+               } else {
+                       if (fStackLayout.topControl != fOutlinePage) {
+                               fStackLayout.topControl = fOutlinePage;
+                               fParent.layout();
+                       }
+               }
+       }
+
+       @Override
+       protected ActionGroup createSearchActionGroup() {
+               return new SelectionSearchGroup(this);
+       }
+
+       @Override
+       protected ActionGroup createOpenViewActionGroup() {
+               OpenViewActionGroup ovag= new OpenViewActionGroup(this, getEditor());
+               ovag.setEnableIncludeBrowser(true);
+               return ovag;
+       }
+
+       @Override
+       protected ActionGroup createRefactoringActionGroup() {
+               return new CRefactoringActionGroup(this);
+       }
+       
+
+       @Override
+       protected ActionGroup createSourceActionGroup() {
+               return new GenerateActionGroup(this);
+       }
+
+       @Override
+       protected ActionGroup createCustomFiltersActionGroup() {
+               return new CustomFiltersActionGroup("org.eclipse.cdt.ui.COutlinePage", getTreeViewer()); //$NON-NLS-1$
+       }
+
+       @Override
+       protected ActionGroup createMemberFilterActionGroup() {
+               return new MemberFilterActionGroup(getTreeViewer(), "COutlineViewer"); //$NON-NLS-1$
+       }
+       
+       /**
+        * This action toggles namespace grouping
+        * 
+        * @since 5.2
+        */
+       protected static class NamespaceGroupingAction extends Action {
+
+               public NamespaceGroupingAction(AbstractCModelOutlinePage outlinePage) {
+                       super(ActionMessages.NamespacesGroupingAction_label);
+                       setDescription(ActionMessages.NamespacesGroupingAction_description);
+                       setToolTipText(ActionMessages.NamespacesGroupingAction_tooltip);
+                       this.setImageDescriptor(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_NAMESPACE));
+                       this.setDisabledImageDescriptor(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_NAMESPACE));
+
+                       boolean enabled= isNamspacesGroupingEnabled();
+                       setChecked(enabled);
+               }
+
+               /**
+                * Runs the action.
+                */
+               @Override
+               public void run() {
+                       PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.OUTLINE_GROUP_NAMESPACES, isChecked());
+               }
+
+               public boolean isNamspacesGroupingEnabled () {
+                       return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.OUTLINE_GROUP_NAMESPACES);
+               }
+       }
+       
+       /**
+        * This action toggles member definition grouping
+        * 
+        * @since 5.2
+        */
+       protected static class MemberGroupingAction extends Action {
+
+               public MemberGroupingAction(AbstractCModelOutlinePage outlinePage) {
+                       super(ActionMessages.MemberGroupingAction_label);
+                       setDescription(ActionMessages.MemberGroupingAction_description);
+                       setToolTipText(ActionMessages.MemberGroupingAction_tooltip);
+                       CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_PUBLIC);
+
+                       boolean enabled= isMemberGroupingEnabled();
+                       setChecked(enabled);
+               }
+
+               /**
+                * Runs the action.
+                */
+               @Override
+               public void run() {
+                       PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.OUTLINE_GROUP_MEMBERS, isChecked());
+               }
+
+               public boolean isMemberGroupingEnabled () {
+                       return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.OUTLINE_GROUP_MEMBERS);
+               }
+       }
+       
+       @Override
+       protected void registerActionBars(IActionBars actionBars) {
+               super.registerActionBars(actionBars);
+               IMenuManager menu= actionBars.getMenuManager();
+
+               // appendToGroup does not work reliably (bug 326748)
+//             menu.appendToGroup("group.layout", new MemberGroupingAction(this)); //$NON-NLS-1$
+//             menu.appendToGroup("group.layout", new NamespaceGroupingAction(this)); //$NON-NLS-1$
+
+               // add actions directly instead
+               menu.add(new MemberGroupingAction(this));
+               menu.add(new NamespaceGroupingAction(this));
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinerProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CContentOutlinerProvider.java
new file mode 100644 (file)
index 0000000..0d2bf36
--- /dev/null
@@ -0,0 +1,381 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.progress.PendingUpdateAdapter;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ElementChangedEvent;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICElementDelta;
+import org.eclipse.cdt.core.model.IElementChangedListener;
+import org.eclipse.cdt.core.model.ISourceRange;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+import org.eclipse.cdt.internal.core.model.CShiftData;
+import org.eclipse.cdt.internal.core.model.SourceManipulation;
+
+import org.eclipse.cdt.internal.ui.BaseCElementContentProvider;
+
+/**
+ * Manages contents of the outliner.
+ */
+public class CContentOutlinerProvider extends BaseCElementContentProvider {
+
+       /** Tree viewer which handles this content provider. */
+       TreeViewer treeViewer;
+
+       /** Translation unit's root. */
+       ITranslationUnit root;
+
+       /** Something changed listener. */
+       private ElementChangedListener fListener;
+
+       /** Property change listener. */
+       private IPropertyChangeListener fPropertyListener;
+
+       /** Flag indicating that we are waiting for a delta to populate the view. */
+       private boolean fInitialDeltaPending;
+
+       public CContentOutlinerProvider(TreeViewer viewer) {
+               this(viewer, null);
+       }
+
+       /**
+        * Creates new content provider for dialog.
+        * 
+        * @param viewer
+        *            Tree viewer.
+        */
+       public CContentOutlinerProvider(TreeViewer viewer, IWorkbenchPartSite site) {
+               super(true, true);
+               treeViewer = viewer;
+               final IPreferenceStore store = PreferenceConstants.getPreferenceStore();
+               setIncludesGrouping(store.getBoolean(PreferenceConstants.OUTLINE_GROUP_INCLUDES));
+               setNamespacesGrouping(store.getBoolean(PreferenceConstants.OUTLINE_GROUP_NAMESPACES));
+               setMemberGrouping(store.getBoolean(PreferenceConstants.OUTLINE_GROUP_MEMBERS));
+               setMacroGrouping(store.getBoolean(PreferenceConstants.OUTLINE_GROUP_MACROS));
+       }
+
+       /**
+        * Called by the editor to signal that the content has updated.
+        */
+       public void contentUpdated() {
+               if (treeViewer != null && !treeViewer.getControl().isDisposed()) {
+                       treeViewer.getControl().getDisplay().asyncExec(new Runnable() {
+                               public void run() {
+                                       if (!treeViewer.getControl().isDisposed()) {
+                                               if (fInitialDeltaPending) {
+                                                       fInitialDeltaPending= false;
+                                                       treeViewer.setInput(root);
+                                               } else {
+                                                       // setting the selection here causes a secondary editor to scroll
+                                                       // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=191358
+       //                                              final ISelection sel = treeViewer.getSelection();
+       //                                              treeViewer.setSelection(updateSelection(sel));
+                                                       treeViewer.refresh();
+                                               }
+                                       }
+                               }
+                       });
+               }
+       }
+
+       /**
+        * Called after CEditor contents is changed.
+        * Existing elements can change their offset and length.
+        * 
+        * @param sdata  delta information
+        */
+       public void contentShift(CShiftData sdata) {
+               try {
+                       ICElement[] el = root.getChildren();
+                       for (int i=0; i< el.length; i++) {
+                               if (!(el[i] instanceof SourceManipulation)) continue;
+
+                               SourceManipulation sm = (SourceManipulation) el[i];
+                               ISourceRange src = sm.getSourceRange();
+                               int endOffset = src.getStartPos() + src.getLength();
+                               
+                               // code BELOW this element changed - do nothing !
+                               if (sdata.getOffset() > endOffset) { continue;  }
+                               
+                               if (sdata.getOffset() < src.getStartPos()) {
+                                       // code ABOVE this element changed - modify offset
+                                       sm.setIdPos(src.getIdStartPos() + sdata.getSize(), src.getIdLength());
+                                       sm.setPos(src.getStartPos() + sdata.getSize(), src.getLength());
+                                       sm.setLines(src.getStartLine() + sdata.getLines(), src.getEndLine() + sdata.getLines());
+                               } else {
+                                       // code INSIDE of this element changed - modify length
+                                       sm.setPos(src.getStartPos(), src.getLength() + sdata.getSize());
+                                       sm.setLines(src.getStartLine(), src.getEndLine() + sdata.getLines());
+                               }
+                       }
+               } catch (CModelException e) {}
+       }
+       
+       /**
+        * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+        */
+       @Override
+       public void dispose() {
+               super.dispose();
+               if (fListener != null) {
+                       CoreModel.getDefault().removeElementChangedListener(fListener);
+                       fListener = null;
+               }
+               if (fPropertyListener != null) {
+                       PreferenceConstants.getPreferenceStore().removePropertyChangeListener(fPropertyListener);
+                       fPropertyListener = null;
+               }
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.BaseCElementContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+        */
+       @Override
+       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+               boolean isTU = newInput instanceof ITranslationUnit;
+
+               if (isTU) {
+                       root = (ITranslationUnit) newInput;
+                       if (fListener == null) {
+                               fListener= new ElementChangedListener();
+                               CoreModel.getDefault().addElementChangedListener(fListener);
+                               fPropertyListener= new PropertyListener();
+                               PreferenceConstants.getPreferenceStore().addPropertyChangeListener(fPropertyListener);
+                       }
+               } else {
+                       if (fListener != null) {
+                               CoreModel.getDefault().removeElementChangedListener(fListener);
+                               PreferenceConstants.getPreferenceStore().removePropertyChangeListener(fPropertyListener);
+                               fListener= null;
+                               fPropertyListener= null;
+                       }
+                       root= null;
+               }
+       }
+
+       /**
+        * @see org.eclipse.cdt.internal.ui.BaseCElementContentProvider#getChildren(java.lang.Object)
+        */
+       @Override
+       public Object[] getChildren(Object element) {
+               Object[] children = null;
+               // Use the deferred manager for the first time (when parsing)
+               if (element instanceof ITranslationUnit) {
+                       ITranslationUnit unit= (ITranslationUnit)element;
+                       if (!unit.isOpen()) {
+                               fInitialDeltaPending= true;
+                               children= new Object[] { new PendingUpdateAdapter() };
+                       }
+               }
+               if (children == null) {
+                       children = super.getChildren(element);
+               }
+               return children;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
+        */
+       @Override
+       public boolean hasChildren(Object element) {
+               return super.hasChildren(element);
+       }
+
+       /**
+        * Updates current selection.
+        * 
+        * @param sel
+        *            Selection to update.
+        * @return Updated selection.
+        */
+       protected ISelection updateSelection(ISelection sel) {
+               final ArrayList<ICElement> newSelection = new ArrayList<ICElement>();
+               if (sel instanceof IStructuredSelection) {
+                       final Iterator<?> iter = ((IStructuredSelection) sel).iterator();
+                       while (iter.hasNext()) {
+                               final Object o = iter.next();
+                               if (o instanceof ICElement) {
+                                       newSelection.add((ICElement)o);
+                               }
+                       }
+               }
+               return new StructuredSelection(newSelection);
+       }
+
+       /**
+        * The element change listener of the C outline viewer.
+        * 
+        * @see IElementChangedListener
+        */
+       class ElementChangedListener implements IElementChangedListener {
+
+               /**
+                * Default constructor.
+                */
+               public ElementChangedListener() {
+                       // nothing to initialize.
+               }
+
+               /**
+                * @see org.eclipse.cdt.core.model.IElementChangedListener#elementChanged(org.eclipse.cdt.core.model.ElementChangedEvent)
+                */
+               public void elementChanged(final ElementChangedEvent e) {
+                       if (e.getType() == ElementChangedEvent.POST_SHIFT && e.getDelta() instanceof CShiftData) {
+                               contentShift((CShiftData)(e.getDelta()));
+                               return;
+                       }
+                       
+                       final ICElementDelta delta = findElement(root, e.getDelta());
+                       if (delta != null) {
+                               contentUpdated();
+                       }
+               }
+
+               /**
+                * Determines is structural change.
+                * 
+                * @param cuDelta
+                *            Delta to check.
+                * @return <b>true</b> if structural change.
+                */
+               private boolean isPossibleStructuralChange(ICElementDelta cuDelta) {
+                       boolean ret;
+                       if (cuDelta.getKind() != ICElementDelta.CHANGED) {
+                               ret = true; // add or remove
+                       } else {
+                               final int flags = cuDelta.getFlags();
+                               if ((flags & ICElementDelta.F_CHILDREN) != 0) {
+                                       ret = true;
+                               } else {
+                                       ret = (flags & (ICElementDelta.F_CONTENT | ICElementDelta.F_FINE_GRAINED)) == ICElementDelta.F_CONTENT;
+                               }
+                       }
+                       return ret;
+               }
+
+               /**
+                * Searches for element.
+                * 
+                * @param unit
+                *            Unit to search in.
+                * @param delta
+                *            Delta.
+                * @return Found element.
+                */
+               protected ICElementDelta findElement(ICElement unit,
+                               ICElementDelta delta) {
+                       if (delta == null || unit == null) {
+                               return null;
+                       }
+
+                       final ICElement element = delta.getElement();
+
+                       if (unit.equals(element)) {
+                               if (isPossibleStructuralChange(delta)) {
+                                       return delta;
+                               }
+                               return null;
+                       }
+
+                       if (element.getElementType() > ICElement.C_UNIT) {
+                               return null;
+                       }
+
+                       final ICElementDelta[] children = delta.getAffectedChildren();
+                       if (children == null || children.length == 0) {
+                               return null;
+                       }
+
+                       for (ICElementDelta element2 : children) {
+                               final ICElementDelta d = findElement(unit, element2);
+                               if (d != null) {
+                                       return d;
+                               }
+                       }
+
+                       return null;
+               }
+       }
+
+       /**
+        * 
+        * Property change listener.
+        * 
+        * @author P.Tomaszewski
+        */
+       class PropertyListener implements IPropertyChangeListener {
+
+               /**
+                * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+                */
+               public void propertyChange(PropertyChangeEvent event) {
+                       String prop = event.getProperty();
+                       if (prop.equals(PreferenceConstants.OUTLINE_GROUP_INCLUDES)) {
+                               Object newValue = event.getNewValue();
+                               if (newValue instanceof Boolean) {
+                                       boolean value = ((Boolean) newValue).booleanValue();
+                                       if (areIncludesGroup() != value) {
+                                               setIncludesGrouping(value);
+                                               contentUpdated();
+                                       }
+                               }
+                       } else if (prop.equals(PreferenceConstants.OUTLINE_GROUP_NAMESPACES)) {
+                               Object newValue = event.getNewValue();
+                               if (newValue instanceof Boolean) {
+                                       boolean value = ((Boolean) newValue).booleanValue();
+                                       if (areNamespacesGroup() != value) {
+                                               setNamespacesGrouping(value);
+                                               contentUpdated();
+                                       }
+                               }
+                       } else if (prop.equals(PreferenceConstants.OUTLINE_GROUP_MEMBERS)) {
+                               Object newValue = event.getNewValue();
+                               if (newValue instanceof Boolean) {
+                                       boolean value = ((Boolean) newValue).booleanValue();
+                                       if (isMemberGroupingEnabled() != value) {
+                                               setMemberGrouping(value);
+                                               contentUpdated();
+                                       }
+                               }
+                       }else if (prop.equals(PreferenceConstants.OUTLINE_GROUP_MACROS)) {
+                               Object newValue = event.getNewValue();
+                               if (newValue instanceof Boolean) {
+                                       boolean value = ((Boolean) newValue).booleanValue();
+                                       if (isMacroGroupingEnabled() != value) {
+                                               setMacroGrouping(value);
+                                               contentUpdated();
+                                       }
+                               }
+                       }
+                       
+               }
+
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java
new file mode 100644 (file)
index 0000000..ecb595c
--- /dev/null
@@ -0,0 +1,1209 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.filebuffers.ITextFileBuffer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+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.ListenerList;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DefaultLineTracker;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentExtension3;
+import org.eclipse.jface.text.ILineTracker;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.AnnotationModel;
+import org.eclipse.jface.text.source.AnnotationModelEvent;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.text.source.IAnnotationModelListener;
+import org.eclipse.jface.text.source.IAnnotationModelListenerExtension;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.text.edits.DeleteEdit;
+import org.eclipse.text.edits.InsertEdit;
+import org.eclipse.text.edits.MalformedTreeException;
+import org.eclipse.text.edits.MultiTextEdit;
+import org.eclipse.text.edits.TextEdit;
+import org.eclipse.text.undo.DocumentUndoManagerRegistry;
+import org.eclipse.text.undo.IDocumentUndoManager;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.editors.text.ForwardingDocumentProvider;
+import org.eclipse.ui.editors.text.ILocationProvider;
+import org.eclipse.ui.editors.text.ILocationProviderExtension;
+import org.eclipse.ui.editors.text.TextFileDocumentProvider;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.IMarkerUpdater;
+import org.eclipse.ui.texteditor.MarkerAnnotation;
+import org.eclipse.ui.texteditor.MarkerUtilities;
+import org.eclipse.ui.texteditor.ResourceMarkerAnnotationModel;
+import org.eclipse.ui.texteditor.spelling.SpellingAnnotation;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICModelMarker;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IProblemRequestor;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.core.parser.IPersistableProblem;
+import org.eclipse.cdt.core.parser.IProblem;
+import org.eclipse.cdt.ui.CDTUITools;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+import org.eclipse.cdt.internal.core.model.TranslationUnit;
+
+import org.eclipse.cdt.internal.ui.text.IProblemRequestorExtension;
+import org.eclipse.cdt.internal.ui.text.spelling.CoreSpellingProblem;
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+
+/**
+ * A document provider for C/C++ content.
+ */
+public class CDocumentProvider extends TextFileDocumentProvider {
+       /**
+        * Bundle of all required informations to allow working copy management.
+        */
+       static protected class TranslationUnitInfo extends FileInfo {
+               public IWorkingCopy fCopy;
+       }
+
+       /**
+        * Annotation representing an <code>IProblem</code>.
+        */
+       static protected class ProblemAnnotation extends Annotation implements ICAnnotation {
+               private static final String INDEXER_ANNOTATION_TYPE= "org.eclipse.cdt.ui.indexmarker"; //$NON-NLS-1$
+               
+               private final ITranslationUnit fTranslationUnit;
+               private final int fId;
+               private final boolean fIsProblem;
+               private final String[] fArguments;
+               private final String fMarkerType;
+               private List<ICAnnotation> fOverlaids;
+
+               public ProblemAnnotation(IProblem problem, ITranslationUnit tu) {
+                       fTranslationUnit= tu;
+                       setText(problem.getMessage());
+                       fId= problem.getID();
+                       fIsProblem= problem.isError() || problem.isWarning();
+                       fArguments= isProblem() ? problem.getArguments() : null;
+            setType(problem instanceof CoreSpellingProblem ?
+                       SpellingAnnotation.TYPE : INDEXER_ANNOTATION_TYPE);
+                       if (problem instanceof IPersistableProblem)
+                               fMarkerType= ((IPersistableProblem) problem).getMarkerType();
+                       else
+                               fMarkerType= null;
+               }
+               
+               /*
+                * @see ICAnnotation#getArguments()
+                */
+               public String[] getArguments() {
+                       return fArguments;
+               }
+       
+               /*
+                * @see ICAnnotation#getId()
+                */
+               public int getId() {
+                       return fId;
+               }
+       
+               /*
+                * @see ICAnnotation#isProblem()
+                */
+               public boolean isProblem() {
+                       return fIsProblem;
+               }
+               
+               /*
+                * @see ICAnnotation#hasOverlay()
+                */
+               public boolean hasOverlay() {
+                       return false;
+               }
+               
+               /*
+                * @see ICAnnotation#getOverlay()
+                */
+               public ICAnnotation getOverlay() {
+                       return null;
+               }
+               
+               /*
+                * @see ICAnnotation#addOverlaid(ICAnnotation)
+                */
+               public void addOverlaid(ICAnnotation annotation) {
+                       if (fOverlaids == null)
+                               fOverlaids= new ArrayList<ICAnnotation>(1);
+                       fOverlaids.add(annotation);
+               }
+       
+               /*
+                * @see ICAnnotation#removeOverlaid(ICAnnotation)
+                */
+               public void removeOverlaid(ICAnnotation annotation) {
+                       if (fOverlaids != null) {
+                               fOverlaids.remove(annotation);
+                               if (fOverlaids.size() == 0)
+                                       fOverlaids= null;
+                       }
+               }
+               
+               /*
+                * @see ICAnnotation#getOverlaidIterator()
+                */
+               public Iterator<ICAnnotation> getOverlaidIterator() {
+                       if (fOverlaids != null)
+                               return fOverlaids.iterator();
+                       return null;
+               }
+                               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.ICAnnotation#getTranslationUnit()
+                */
+               public ITranslationUnit getTranslationUnit() {
+                       return fTranslationUnit;
+               }
+
+               /*
+                * @see org.eclipsecjdt.internal.ui.editor.ICAnnotation#getMarkerType()
+                */
+               public String getMarkerType() {
+                       return fMarkerType;
+               }
+       }
+               
+       /**
+        * Internal structure for mapping positions to some value.
+        * The reason for this specific structure is that positions can
+        * change over time. Thus a lookup is based on value and not
+        * on hash value.
+        */
+       protected static class ReverseMap {
+               
+               static class Entry {
+                       Position fPosition;
+                       Object fValue;
+               }
+               
+               private List<Entry> fList= new ArrayList<Entry>(2);
+               private int fAnchor= 0;
+               
+               public ReverseMap() {
+               }
+               
+               public Object get(Position position) {
+                       
+                       Entry entry;
+                       
+                       // behind anchor
+                       int length= fList.size();
+                       for (int i= fAnchor; i < length; i++) {
+                               entry= fList.get(i);
+                               if (entry.fPosition.equals(position)) {
+                                       fAnchor= i;
+                                       return entry.fValue;
+                               }
+                       }
+                       
+                       // before anchor
+                       for (int i= 0; i < fAnchor; i++) {
+                               entry= fList.get(i);
+                               if (entry.fPosition.equals(position)) {
+                                       fAnchor= i;
+                                       return entry.fValue;
+                               }
+                       }
+                       
+                       return null;
+               }
+               
+               private int getIndex(Position position) {
+                       Entry entry;
+                       int length= fList.size();
+                       for (int i= 0; i < length; i++) {
+                               entry= fList.get(i);
+                               if (entry.fPosition.equals(position))
+                                       return i;
+                       }
+                       return -1;
+               }
+               
+               public void put(Position position,  Object value) {
+                       int index= getIndex(position);
+                       if (index == -1) {
+                               Entry entry= new Entry();
+                               entry.fPosition= position;
+                               entry.fValue= value;
+                               fList.add(entry);
+                       } else {
+                               Entry entry= fList.get(index);
+                               entry.fValue= value;
+                       }
+               }
+               
+               public void remove(Position position) {
+                       int index= getIndex(position);
+                       if (index > -1)
+                               fList.remove(index);
+               }
+               
+               public void clear() {
+                       fList.clear();
+                       fAnchor= 0;
+               }
+       }
+
+       /**
+        * A marker updater which removes problems markers with length 0.
+        */
+       public static class ProblemMarkerUpdater implements IMarkerUpdater {
+
+               /**
+                * Default constructor (executable extension).
+                */
+               public ProblemMarkerUpdater() {
+               }
+
+               /*
+                * @see org.eclipse.ui.texteditor.IMarkerUpdater#getAttribute()
+                */
+               public String[] getAttribute() {
+                       return null;
+               }
+
+               /*
+                * @see org.eclipse.ui.texteditor.IMarkerUpdater#getMarkerType()
+                */
+               public String getMarkerType() {
+                       return ICModelMarker.C_MODEL_PROBLEM_MARKER;
+               }
+
+               /*
+                * @see org.eclipse.ui.texteditor.IMarkerUpdater#updateMarker(org.eclipse.core.resources.IMarker, org.eclipse.jface.text.IDocument, org.eclipse.jface.text.Position)
+                */
+               public boolean updateMarker(IMarker marker, IDocument document, Position position) {
+                       if (position == null) {
+                               return true;
+                       }
+                       if (position.isDeleted() || position.getLength() == 0) {
+                               return false;
+                       }
+                       return true;
+               }
+       }
+
+       /**
+        * Annotation model dealing with c marker annotations and temporary problems.
+        * Also acts as a problem requestor for its translation unit. Initially inactive. Must be explicitly
+        * activated.
+        */
+       protected static class TranslationUnitAnnotationModel extends ResourceMarkerAnnotationModel implements IProblemRequestor, IProblemRequestorExtension {
+               
+               private static class ProblemRequestorState {
+                       boolean fInsideReportingSequence= false;
+                       List<IProblem> fReportedProblems;
+               }
+               
+               private ThreadLocal<ProblemRequestorState> fProblemRequestorState= new ThreadLocal<ProblemRequestorState>();
+               private int fStateCount= 0;
+               
+               private ITranslationUnit fTranslationUnit;
+               private List<ProblemAnnotation> fGeneratedAnnotations;
+               private IProgressMonitor fProgressMonitor;
+               private boolean fIsActive= false;
+               
+               private ReverseMap fReverseMap= new ReverseMap();
+               private List<CMarkerAnnotation> fPreviouslyOverlaid= null;
+               private List<CMarkerAnnotation> fCurrentlyOverlaid= new ArrayList<CMarkerAnnotation>();
+               
+               
+               public TranslationUnitAnnotationModel(IResource resource) {
+                       super(resource);
+               }
+               
+               public void setTranslationUnit(ITranslationUnit unit)  {
+                       fTranslationUnit= unit;
+               }
+               
+               @Override
+               protected MarkerAnnotation createMarkerAnnotation(IMarker marker) {
+                       String markerType= MarkerUtilities.getMarkerType(marker);
+                       if (markerType != null && markerType.startsWith(CMarkerAnnotation.C_MARKER_TYPE_PREFIX)) {
+                               return new CMarkerAnnotation(marker);
+                       }
+                       return super.createMarkerAnnotation(marker);
+               }
+               
+               
+               /* (non-Javadoc)
+                * @see org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel#createPositionFromMarker(org.eclipse.core.resources.IMarker)
+                */
+               @Override
+               protected Position createPositionFromMarker(IMarker marker) {
+                       int start= MarkerUtilities.getCharStart(marker);
+                       int end= MarkerUtilities.getCharEnd(marker);
+                       
+                       if (start > end) {
+                               end= start + end;
+                               start= end - start;
+                               end= end - start;
+                       }
+                       
+                       if (start == -1 && end == -1) {
+                               // marker line number is 1-based
+                               int line= MarkerUtilities.getLineNumber(marker);
+                               if (line > 0 && fDocument != null) {
+                                       try {
+                                               IRegion lineRegion= fDocument.getLineInformation(line - 1);
+                                               start= lineRegion.getOffset();
+                                               end= start + lineRegion.getLength();
+                                               if (marker.isSubtypeOf(ICModelMarker.C_MODEL_PROBLEM_MARKER)) {
+                                                       // strip leading whitespace
+                                                       while (start < end && Character.isWhitespace(fDocument.getChar(start))) {
+                                                               ++start;
+                                                       }
+                                               }
+                                       } catch (BadLocationException x) {
+                                       } catch (CoreException exc) {
+                                       }
+                               }
+                       }
+                       
+                       if (start > -1 && end > -1)
+                               return new Position(start, end - start);
+                       
+                       return null;
+               }
+               /*
+                * @see org.eclipse.jface.text.source.AnnotationModel#createAnnotationModelEvent()
+                */
+               @Override
+               protected AnnotationModelEvent createAnnotationModelEvent() {
+                       return new TranslationUnitAnnotationModelEvent(this, getResource());
+               }
+               
+               protected Position createPositionFromProblem(IProblem problem) {
+                       int start= problem.getSourceStart();
+                       if (start < 0)
+                               return null;
+                       
+                       int length= problem.getSourceEnd() - problem.getSourceStart() + 1;
+                       if (length < 0)
+                               return null;
+                       return new Position(start, length);
+               }
+               
+               /*
+                * @see IProblemRequestor#beginReporting()
+                */
+               public void beginReporting() {
+                       ProblemRequestorState state= fProblemRequestorState.get();
+                       if (state == null)
+                               internalBeginReporting(false);
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.text.java.IProblemRequestorExtension#beginReportingSequence()
+                */
+               public void beginReportingSequence() {
+                       ProblemRequestorState state= fProblemRequestorState.get();
+                       if (state == null)
+                               internalBeginReporting(true);
+               }
+               
+               /**
+                * Sets up the infrastructure necessary for problem reporting.
+                * 
+                * @param insideReportingSequence <code>true</code> if this method
+                *            call is issued from inside a reporting sequence
+                */
+               private void internalBeginReporting(boolean insideReportingSequence) {
+                       if (fTranslationUnit != null) {
+                               ProblemRequestorState state= new ProblemRequestorState();
+                               state.fInsideReportingSequence= insideReportingSequence;
+                               state.fReportedProblems= new ArrayList<IProblem>();
+                               synchronized (getLockObject()) {
+                                       fProblemRequestorState.set(state);
+                                       ++fStateCount;
+                               }
+                       }
+               }
+               
+               /*
+                * @see IProblemRequestor#acceptProblem(IProblem)
+                */
+               public void acceptProblem(IProblem problem) {
+                       if (isActive()) {
+                               ProblemRequestorState state= fProblemRequestorState.get();
+                               if (state != null)
+                                       state.fReportedProblems.add(problem);
+                       }
+               }
+               
+               /*
+                * @see IProblemRequestor#endReporting()
+                */
+               public void endReporting() {
+                       ProblemRequestorState state= fProblemRequestorState.get();
+                       if (state != null && !state.fInsideReportingSequence)
+                               internalEndReporting(state);
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.text.java.IProblemRequestorExtension#endReportingSequence()
+                */
+               public void endReportingSequence() {
+                       ProblemRequestorState state= fProblemRequestorState.get();
+                       if (state != null && state.fInsideReportingSequence)
+                               internalEndReporting(state);
+               }
+               
+               private void internalEndReporting(ProblemRequestorState state) {
+                       int stateCount= 0;
+                       synchronized(getLockObject()) {
+                               -- fStateCount;
+                               stateCount= fStateCount;
+                               fProblemRequestorState.set(null);
+                       }
+                       
+                       if (stateCount == 0 && isActive())
+                               reportProblems(state.fReportedProblems);
+               }
+               
+               /**
+                * Signals the end of problem reporting.
+                */
+               private void reportProblems(List<IProblem> reportedProblems) {
+                       if (fProgressMonitor != null && fProgressMonitor.isCanceled())
+                               return;
+                       
+                       boolean temporaryProblemsChanged= false;
+                       
+                       synchronized (getLockObject()) {
+                               boolean isCanceled= false;
+                               
+                               fPreviouslyOverlaid= fCurrentlyOverlaid;
+                               fCurrentlyOverlaid= new ArrayList<CMarkerAnnotation>();
+                               
+                               if (fGeneratedAnnotations.size() > 0) {
+                                       temporaryProblemsChanged= true;
+                                       removeAnnotations(fGeneratedAnnotations, false, true);
+                                       fGeneratedAnnotations.clear();
+                               }
+                               
+                               if (reportedProblems != null && reportedProblems.size() > 0) {
+                                       Iterator<IProblem> e= reportedProblems.iterator();
+                                       while (e.hasNext()) {
+                                               
+                                               if (fProgressMonitor != null && fProgressMonitor.isCanceled()) {
+                                                       isCanceled= true;
+                                                       break;
+                                               }
+                                               
+                                               IProblem problem= e.next();
+                                               Position position= createPositionFromProblem(problem);
+                                               if (position != null) {
+                                                       
+                                                       try {
+                                                               ProblemAnnotation annotation= new ProblemAnnotation(problem, fTranslationUnit);
+                                                               overlayMarkers(position, annotation);
+                                                               addAnnotation(annotation, position, false);
+                                                               fGeneratedAnnotations.add(annotation);
+                                                               
+                                                               temporaryProblemsChanged= true;
+                                                       } catch (BadLocationException x) {
+                                                               // ignore invalid position
+                                                       }
+                                               }
+                                       }
+                               }
+                               
+                               removeMarkerOverlays(isCanceled);
+                               fPreviouslyOverlaid= null;
+                       }
+                       
+                       if (temporaryProblemsChanged)
+                               fireModelChanged();
+               }
+               
+               private void removeMarkerOverlays(boolean isCanceled) {
+                       if (isCanceled) {
+                               fCurrentlyOverlaid.addAll(fPreviouslyOverlaid);
+                       } else if (fPreviouslyOverlaid != null) {
+                               Iterator<CMarkerAnnotation> e= fPreviouslyOverlaid.iterator();
+                               while (e.hasNext()) {
+                                       CMarkerAnnotation annotation= e.next();
+                                       annotation.setOverlay(null);
+                               }
+                       }
+               }
+               
+               /**
+                * Overlays value with problem annotation.
+                * @param problemAnnotation
+                */
+               private void setOverlay(Object value, ProblemAnnotation problemAnnotation) {
+                       if (value instanceof CMarkerAnnotation) {
+                               CMarkerAnnotation annotation= (CMarkerAnnotation) value;
+                               if (annotation.isProblem()) {
+                                       annotation.setOverlay(problemAnnotation);
+                                       fPreviouslyOverlaid.remove(annotation);
+                                       fCurrentlyOverlaid.add(annotation);
+                               }
+                       } else {
+                       }
+               }
+               
+               private void overlayMarkers(Position position, ProblemAnnotation problemAnnotation) {
+                       Object value= getAnnotations(position);
+                       if (value instanceof List<?>) {
+                               List<?> list= (List<?>) value;
+                               for (Object element : list)
+                                       setOverlay(element, problemAnnotation);
+                       } else {
+                               setOverlay(value, problemAnnotation);
+                       }
+               }
+               
+               /**
+                * Tells this annotation model to collect temporary problems from now on.
+                */
+               private void startCollectingProblems() {
+                       fGeneratedAnnotations= new ArrayList<ProblemAnnotation>();
+               }
+               
+               /**
+                * Tells this annotation model to no longer collect temporary problems.
+                */
+               private void stopCollectingProblems() {
+                       if (fGeneratedAnnotations != null)
+                               removeAnnotations(fGeneratedAnnotations, true, true);
+                       fGeneratedAnnotations= null;
+               }
+               
+               /*
+                * @see IProblemRequestor#isActive()
+                */
+               public boolean isActive() {
+                       return fIsActive;
+               }
+               
+               /*
+                * @see IProblemRequestorExtension#setProgressMonitor(IProgressMonitor)
+                */
+               public void setProgressMonitor(IProgressMonitor monitor) {
+                       fProgressMonitor= monitor;
+               }
+               
+               /*
+                * @see IProblemRequestorExtension#setIsActive(boolean)
+                */
+               public void setIsActive(boolean isActive) {
+                       if (fIsActive != isActive) {
+                               fIsActive= isActive;
+                               if (fIsActive)
+                                       startCollectingProblems();
+                               else
+                                       stopCollectingProblems();
+                       }
+               }
+               
+               private Object getAnnotations(Position position) {
+                       synchronized (getLockObject()) {
+                               return fReverseMap.get(position);
+                       }
+               }
+               
+               /*
+                * @see AnnotationModel#addAnnotation(Annotation, Position, boolean)
+                */
+               @Override
+               @SuppressWarnings({ "unchecked" })
+               protected void addAnnotation(Annotation annotation, Position position, boolean fireModelChanged) throws BadLocationException {
+                       super.addAnnotation(annotation, position, fireModelChanged);
+                       
+                       synchronized (getLockObject()) {
+                               Object cached= fReverseMap.get(position);
+                               if (cached == null) {
+                                       fReverseMap.put(position, annotation);
+                               } else if (cached instanceof List) {
+                                       List<Annotation> list= (List<Annotation>) cached;
+                                       list.add(annotation);
+                               } else if (cached instanceof Annotation) {
+                                       List<Object> list= new ArrayList<Object>(2);
+                                       list.add(cached);
+                                       list.add(annotation);
+                                       fReverseMap.put(position, list);
+                               }
+                       }
+               }
+               
+               /*
+                * @see AnnotationModel#removeAllAnnotations(boolean)
+                */
+               @Override
+               protected void removeAllAnnotations(boolean fireModelChanged) {
+                       super.removeAllAnnotations(fireModelChanged);
+                       synchronized (getLockObject()) {
+                               fReverseMap.clear();
+                       }
+               }
+               
+               /*
+                * @see AnnotationModel#removeAnnotation(Annotation, boolean)
+                */
+               @Override
+               protected void removeAnnotation(Annotation annotation, boolean fireModelChanged) {
+                       Position position= getPosition(annotation);
+                       synchronized (getLockObject()) {
+                               Object cached= fReverseMap.get(position);
+                               if (cached instanceof List<?>) {
+                                       List<?> list= (List<?>) cached;
+                                       list.remove(annotation);
+                                       if (list.size() == 1) {
+                                               fReverseMap.put(position, list.get(0));
+                                               list.clear();
+                                       }
+                               } else if (cached instanceof Annotation) {
+                                       fReverseMap.remove(position);
+                               }
+                       }
+                       super.removeAnnotation(annotation, fireModelChanged);
+               }
+       }
+
+       protected static class GlobalAnnotationModelListener implements IAnnotationModelListener, IAnnotationModelListenerExtension {
+               
+               private ListenerList fListenerList;
+               
+               public GlobalAnnotationModelListener() {
+                       fListenerList= new ListenerList(ListenerList.IDENTITY);
+               }
+               
+               /**
+                * @see IAnnotationModelListener#modelChanged(IAnnotationModel)
+                */
+               public void modelChanged(IAnnotationModel model) {
+                       Object[] listeners= fListenerList.getListeners();
+                       for (Object listener : listeners) {
+                               ((IAnnotationModelListener) listener).modelChanged(model);
+                       }
+               }
+
+               /**
+                * @see IAnnotationModelListenerExtension#modelChanged(AnnotationModelEvent)
+                */
+               public void modelChanged(AnnotationModelEvent event) {
+                       Object[] listeners= fListenerList.getListeners();
+                       for (Object curr : listeners) {
+                               if (curr instanceof IAnnotationModelListenerExtension) {
+                                       ((IAnnotationModelListenerExtension) curr).modelChanged(event);
+                               }
+                       }
+               }
+               
+               public void addListener(IAnnotationModelListener listener) {
+                       fListenerList.add(listener);
+               }
+               
+               public void removeListener(IAnnotationModelListener listener) {
+                       fListenerList.remove(listener);
+               }
+       }
+       
+       /** Preference key for temporary problems */
+       private final static String HANDLE_TEMPORARY_PROBLEMS= PreferenceConstants.EDITOR_EVALUATE_TEMPORARY_PROBLEMS;
+
+       /** Internal property changed listener */
+       private IPropertyChangeListener fPropertyListener;
+       /** Annotation model listener added to all created CU annotation models */
+       private GlobalAnnotationModelListener fGlobalAnnotationModelListener;
+
+       /**
+        * 
+        */
+       public CDocumentProvider() {
+               super();
+               IDocumentProvider parentProvider= new ExternalSearchDocumentProvider();
+               parentProvider= new ForwardingDocumentProvider(ICPartitions.C_PARTITIONING, new CDocumentSetupParticipant(), parentProvider);
+               setParentDocumentProvider(parentProvider);
+               fGlobalAnnotationModelListener= new GlobalAnnotationModelListener();
+               fPropertyListener= new IPropertyChangeListener() {
+                       public void propertyChange(PropertyChangeEvent event) {
+                               if (HANDLE_TEMPORARY_PROBLEMS.equals(event.getProperty()))
+                                       enableHandlingTemporaryProblems();
+                       }
+               };
+               CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPropertyListener);
+       }
+
+       /*
+        * @see org.eclipse.ui.editors.text.TextFileDocumentProvider#connect(java.lang.Object)
+        */
+       @Override
+       public void connect(Object element) throws CoreException {
+               super.connect(element);
+               IDocument document= getDocument(element);
+               if (document instanceof IDocumentExtension3) {
+                       IDocumentExtension3 extension= (IDocumentExtension3) document;
+                       if (extension.getDocumentPartitioner(ICPartitions.C_PARTITIONING) == null)
+                               new CDocumentSetupParticipant().setup(document);
+               }
+       }
+
+       /**
+        * Creates a translation unit from the given file.
+        * 
+        * @param file
+        *            the file from which to create the translation unit
+        */
+       protected ITranslationUnit createTranslationUnit(IFile file) {
+               Object element = CoreModel.getDefault().create(file);
+               if (element instanceof ITranslationUnit) {
+                       return (ITranslationUnit) element;
+               }
+               if (element == null) {
+                       // not in a source folder?
+                       ICProject cproject= CoreModel.getDefault().create(file.getProject());
+                       if (cproject != null) {
+                               String contentTypeId= CoreModel.getRegistedContentTypeId(file.getProject(), file.getName());
+                               if (contentTypeId != null) {
+                                       return new TranslationUnit(cproject, file, contentTypeId);
+                               }
+                       }
+               }
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.ui.editors.text.TextFileDocumentProvider#createEmptyFileInfo()
+        */
+       @Override
+       protected FileInfo createEmptyFileInfo() {
+               return new TranslationUnitInfo();
+       }
+
+       /*
+        * @see org.eclipse.ui.editors.text.TextFileDocumentProvider#createAnnotationModel(org.eclipse.core.resources.IFile)
+        */
+       @Override
+       protected IAnnotationModel createAnnotationModel(IFile file) {
+               return new TranslationUnitAnnotationModel(file);
+       }
+
+       /*
+        * @see org.eclipse.ui.editors.text.TextFileDocumentProvider#createFileInfo(java.lang.Object)
+        */
+       @Override
+       protected FileInfo createFileInfo(Object element) throws CoreException {
+               ITranslationUnit original = null;
+               if (element instanceof IFileEditorInput) {
+                       IFileEditorInput input = (IFileEditorInput)element;
+                       original = createTranslationUnit(input.getFile());
+               } else if (element instanceof ITranslationUnitEditorInput) {
+                       ITranslationUnitEditorInput input = (ITranslationUnitEditorInput)element;
+                       original = input.getTranslationUnit();
+               } else if (element instanceof IAdaptable) {
+                       IAdaptable adaptable= (IAdaptable)element;
+                       ILocationProvider locationProvider= (ILocationProvider)adaptable.getAdapter(ILocationProvider.class);
+                       if (locationProvider instanceof ILocationProviderExtension) {
+                               URI uri= ((ILocationProviderExtension)locationProvider).getURI(element);
+                               original= createTranslationUnit(uri);
+                       }
+                       if (original == null && locationProvider != null) {
+                               IPath location= locationProvider.getPath(element);
+                               original= createTranslationUnit(location);
+                       }
+               }
+
+               if (original == null) {
+                       return null;
+               }
+               
+               FileInfo info = super.createFileInfo(element);
+               if (!(info instanceof TranslationUnitInfo))
+                       return null;
+               TranslationUnitInfo tuInfo = (TranslationUnitInfo) info;
+               setUpSynchronization(tuInfo);
+
+               IProblemRequestor requestor= tuInfo.fModel instanceof IProblemRequestor ? (IProblemRequestor) tuInfo.fModel : null;
+               tuInfo.fCopy = CDTUITools.getWorkingCopyManager().getSharedWorkingCopy(original, requestor, getProgressMonitor());
+
+               if (tuInfo.fModel == null) {
+                       IPath location = original.getLocation();
+                       if (location != null) {
+                               IResource markerResource= original.getCProject().getProject();
+                               tuInfo.fModel= new ExternalSearchAnnotationModel(markerResource, location);
+                               IAnnotationModel fileBufferAnnotationModel= tuInfo.fTextFileBuffer.getAnnotationModel();
+                               if (fileBufferAnnotationModel != null) {
+                                       ((AnnotationModel)tuInfo.fModel).addAnnotationModel("fileBufferModel", fileBufferAnnotationModel); //$NON-NLS-1$
+                               }
+                               tuInfo.fCachedReadOnlyState= true;
+                       }
+               }
+               if (tuInfo.fModel instanceof TranslationUnitAnnotationModel) {
+                       TranslationUnitAnnotationModel model= (TranslationUnitAnnotationModel) tuInfo.fModel;
+                       model.setTranslationUnit(tuInfo.fCopy);
+               }
+               if (tuInfo.fModel != null)
+                       tuInfo.fModel.addAnnotationModelListener(fGlobalAnnotationModelListener);
+               if (requestor instanceof IProblemRequestorExtension) {
+                       IProblemRequestorExtension extension= (IProblemRequestorExtension)requestor;
+                       extension.setIsActive(isHandlingTemporaryProblems());
+               }
+               return tuInfo;
+       }
+
+       /**
+        * Try to synthesize an ITranslationUnit out of thin air.
+        * @param location  the file system location of the file in question
+        * @return a translation unit or <code>null</code>
+        */
+       private ITranslationUnit createTranslationUnit(IPath location) {
+               if (location == null) {
+                       return null;
+               }
+               IEditorInput input= EditorUtility.getEditorInputForLocation(location, null);
+               if (input instanceof ITranslationUnitEditorInput) {
+                       return ((ITranslationUnitEditorInput)input).getTranslationUnit();
+               }
+               return null;
+       }
+
+       /**
+        * Try to synthesize an ITranslationUnit out of thin air.
+        * @param uri  the URU of the file in question
+        * @return a translation unit or <code>null</code>
+        */
+       private ITranslationUnit createTranslationUnit(URI uri) {
+               if (uri == null) {
+                       return null;
+               }
+               IEditorInput input= EditorUtility.getEditorInputForLocation(uri, null);
+               if (input instanceof ITranslationUnitEditorInput) {
+                       return ((ITranslationUnitEditorInput)input).getTranslationUnit();
+               }
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.ui.editors.text.TextFileDocumentProvider#disposeFileInfo(java.lang.Object,
+        *      org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo)
+        */
+       @Override
+       protected void disposeFileInfo(Object element, FileInfo info) {
+               if (info instanceof TranslationUnitInfo) {
+                       TranslationUnitInfo tuInfo = (TranslationUnitInfo) info;
+                       tuInfo.fCopy.destroy();
+                       if (tuInfo.fModel != null)
+                               tuInfo.fModel.removeAnnotationModelListener(fGlobalAnnotationModelListener);
+               }
+               super.disposeFileInfo(element, info);
+       }
+
+       /**
+        * Creates and returns a new sub-progress monitor for the
+        * given parent monitor.
+        *
+        * @param monitor the parent progress monitor
+        * @param ticks the number of work ticks allocated from the parent monitor
+        * @return the new sub-progress monitor
+        */
+       private IProgressMonitor getSubProgressMonitor(IProgressMonitor monitor, int ticks) {
+               if (monitor != null)
+                       return new SubProgressMonitor(monitor, ticks, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
+
+               return new NullProgressMonitor();
+       }
+
+       protected void commitWorkingCopy(IProgressMonitor monitor, Object element, TranslationUnitInfo info,
+                       boolean overwrite) throws CoreException {
+               if (monitor == null)
+                       monitor= new NullProgressMonitor();
+
+               monitor.beginTask("", 100); //$NON-NLS-1$
+
+               try {
+                       IDocument document= info.fTextFileBuffer.getDocument();
+                       IResource resource= info.fCopy.getResource();
+
+                       if (resource instanceof IFile && !resource.exists()) {
+                               // The underlying resource has been deleted, just recreate the file, ignore the rest
+                               createFileFromDocument(monitor, (IFile) resource, document);
+                               return;
+                       }
+
+                       try {
+                               CoreException saveActionException= null;
+                               try {
+                                       performSaveActions(info.fTextFileBuffer, getSubProgressMonitor(monitor, 20));
+                               } catch (CoreException e) {
+                                       saveActionException = e;
+                               }
+
+                               commitFileBuffer(monitor, info, overwrite);
+
+                               if (saveActionException != null) {
+                                       throw saveActionException;
+                               }
+                       } catch (CoreException x) {
+                               // Inform about the failure
+                               fireElementStateChangeFailed(element);
+                               throw x;
+                       } catch (RuntimeException x) {
+                               // Inform about the failure
+                               fireElementStateChangeFailed(element);
+                               throw x;
+                       }
+               } finally {
+                       monitor.done();
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.editors.text.TextFileDocumentProvider#createSaveOperation(java.lang.Object, org.eclipse.jface.text.IDocument, boolean)
+        */
+       @Override
+       protected DocumentProviderOperation createSaveOperation(final Object element, final IDocument document,
+                       final boolean overwrite) throws CoreException {
+               final FileInfo info= getFileInfo(element);
+               if (info instanceof TranslationUnitInfo) {
+                       return new DocumentProviderOperation() {
+                               /*
+                                * @see org.eclipse.ui.editors.text.TextFileDocumentProvider.DocumentProviderOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
+                                */
+                               @Override
+                               protected void execute(IProgressMonitor monitor) throws CoreException {
+                                       commitWorkingCopy(monitor, element, (TranslationUnitInfo) info, overwrite);
+                               }
+                               /*
+                                * @see org.eclipse.ui.editors.text.TextFileDocumentProvider.DocumentProviderOperation#getSchedulingRule()
+                                */
+                               @Override
+                               public ISchedulingRule getSchedulingRule() {
+                                       if (info.fElement instanceof IFileEditorInput) {
+                                               IFile file= ((IFileEditorInput) info.fElement).getFile();
+                                               return computeSchedulingRule(file);
+                                       }
+                                       return null;
+                               }
+                       };
+               }
+               return null;
+       }
+
+       /**
+        * Removes trailing whitespaces from changed lines and adds newline at the end of the file,
+        * if the last line of the file was changed.
+        * @throws BadLocationException 
+        */
+       private void performSaveActions(ITextFileBuffer buffer, IProgressMonitor monitor) throws CoreException {
+               if (shouldRemoveTrailingWhitespace() || shouldAddNewlineAtEof()) {
+                       IRegion[] changedRegions= needsChangedRegions() ?
+                                       EditorUtility.calculateChangedLineRegions(buffer, getSubProgressMonitor(monitor, 20)) :
+                                   null;
+                       IDocument document = buffer.getDocument();
+                       TextEdit edit = createSaveActionEdit(document, changedRegions);
+                       if (edit != null) {
+                               try {
+                                       IDocumentUndoManager manager= DocumentUndoManagerRegistry.getDocumentUndoManager(document);
+                                       manager.beginCompoundChange();
+                                       edit.apply(document);
+                                       manager.endCompoundChange();
+                               } catch (MalformedTreeException e) {
+                                       String message= e.getMessage();
+                                       if (message == null)
+                                               message= "MalformedTreeException"; //$NON-NLS-1$
+                                       throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, message, e));
+                               } catch (BadLocationException e) {
+                                       String message= e.getMessage();
+                                       if (message == null)
+                                               message= "BadLocationException"; //$NON-NLS-1$
+                                       throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, message, e));
+                               }
+                       }
+               }
+       }
+
+       private static boolean shouldAddNewlineAtEof() {
+               return PreferenceConstants.getPreferenceStore().getBoolean(
+                               PreferenceConstants.ENSURE_NEWLINE_AT_EOF);
+       }
+
+       private static boolean shouldRemoveTrailingWhitespace() {
+               return PreferenceConstants.getPreferenceStore().getBoolean(
+                               PreferenceConstants.REMOVE_TRAILING_WHITESPACE);
+       }
+
+       private static boolean isLimitedRemoveTrailingWhitespace() {
+               return PreferenceConstants.getPreferenceStore().getBoolean(
+                               PreferenceConstants.REMOVE_TRAILING_WHITESPACE_LIMIT_TO_EDITED_LINES);
+       }
+       
+       private static boolean needsChangedRegions() {
+               return shouldRemoveTrailingWhitespace() && isLimitedRemoveTrailingWhitespace();
+       }
+
+       /**
+        * Creates a text edit for the save actions.
+        * @return a text edit, or <code>null</code> if the save actions leave the file intact.
+        */
+       private TextEdit createSaveActionEdit(IDocument document, IRegion[] changedRegions) {
+               TextEdit rootEdit = null;
+               TextEdit lastWhitespaceEdit = null;
+               try {
+                       if (shouldRemoveTrailingWhitespace()) {
+                               if (!isLimitedRemoveTrailingWhitespace()) {
+                                       // Pretend that the whole document changed.
+                                       changedRegions = new IRegion[] { new Region(0, document.getLength()) };
+                               }
+                               // Remove trailing whitespace from changed lines.
+                               for (IRegion region : changedRegions) {
+                                       int firstLine = document.getLineOfOffset(region.getOffset());
+                                       int lastLine = document.getLineOfOffset(region.getOffset() + region.getLength());
+                                       for (int line = firstLine; line <= lastLine; line++) {
+                                               IRegion lineRegion = document.getLineInformation(line);
+                                               if (lineRegion.getLength() == 0) {
+                                                       continue;
+                                               }
+                                               int lineStart = lineRegion.getOffset();
+                                               int lineEnd = lineStart + lineRegion.getLength();
+
+                                               // Find the rightmost none-whitespace character
+                                               int charPos = lineEnd - 1;
+                                               while (charPos >= lineStart && Character.isWhitespace(document.getChar(charPos)))
+                                                       charPos--;
+
+                                               charPos++;
+                                               if (charPos < lineEnd) {
+                                                       // check partition - don't remove whitespace inside strings
+                                                       ITypedRegion partition = TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, charPos, false);
+                                                       if (!ICPartitions.C_STRING.equals(partition.getType())) {
+                                                               lastWhitespaceEdit= new DeleteEdit(charPos, lineEnd - charPos);
+                                                               if (rootEdit == null) {
+                                                                       rootEdit = new MultiTextEdit();
+                                                               }
+                                                               rootEdit.addChild(lastWhitespaceEdit);
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+                       if (shouldAddNewlineAtEof()) {
+                               // Add newline at the end of the file.
+                               int endOffset = document.getLength();
+                               IRegion lastLineRegion = document.getLineInformationOfOffset(endOffset);
+                               // Insert newline at the end of the document if the last line is not empty and
+                               // will not become empty after removal of trailing whitespace.
+                               if (lastLineRegion.getLength() != 0 &&
+                                               (lastWhitespaceEdit == null ||
+                                               lastWhitespaceEdit.getOffset() != lastLineRegion.getOffset() ||
+                                               lastWhitespaceEdit.getLength() != lastLineRegion.getLength())) {
+                                       TextEdit edit = new InsertEdit(endOffset, TextUtilities.getDefaultLineDelimiter(document));
+                                       if (rootEdit == null) {
+                                               rootEdit = edit;
+                                       } else {
+                                               rootEdit.addChild(edit);
+                                       }
+                               }
+                       }
+               } catch (BadLocationException e) {
+                       CUIPlugin.log(e);
+               }
+               return rootEdit;
+       }
+
+//     private static boolean isWhitespaceRegion(IDocument document, IRegion region) throws BadLocationException {
+//             int end = region.getOffset() + region.getLength();
+//             for (int i = region.getOffset(); i < end; i++) {
+//                     if (!Character.isWhitespace(document.getChar(i))) {
+//                             return false;
+//                     }
+//             }
+//             return true;
+//     }
+       
+       /**
+        * Returns the preference whether handling temporary problems is enabled.
+        */
+       protected boolean isHandlingTemporaryProblems() {
+               IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+               return store.getBoolean(HANDLE_TEMPORARY_PROBLEMS);
+       }
+       
+       /**
+        * Switches the state of problem acceptance according to the value in the preference store.
+        */
+       protected void enableHandlingTemporaryProblems() {
+               boolean enable= isHandlingTemporaryProblems();
+               for (Iterator<?> iter= getFileInfosIterator(); iter.hasNext();) {
+                       FileInfo info= (FileInfo) iter.next();
+                       if (info.fModel instanceof IProblemRequestorExtension) {
+                               IProblemRequestorExtension  extension= (IProblemRequestorExtension) info.fModel;
+                               extension.setIsActive(enable);
+                       }
+               }
+       }
+
+       public void addGlobalAnnotationModelListener(IAnnotationModelListener listener) {
+               fGlobalAnnotationModelListener.addListener(listener);
+       }
+
+       public void removeGlobalAnnotationModelListener(IAnnotationModelListener listener) {
+               fGlobalAnnotationModelListener.removeListener(listener);
+       }
+
+       public IWorkingCopy getWorkingCopy(Object element) {
+               FileInfo fileInfo = getFileInfo(element);
+               if (fileInfo instanceof TranslationUnitInfo) {
+                       TranslationUnitInfo info = (TranslationUnitInfo) fileInfo;
+                       return info.fCopy;
+               }
+               return null;
+       }
+
+       public void shutdown() {
+//             CUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyListener);
+               Iterator<?> e = getConnectedElementsIterator();
+               while (e.hasNext())
+                       disconnect(e.next());
+       }
+
+       public ILineTracker createLineTracker(Object element) {
+               return new DefaultLineTracker();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentSetupParticipant.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentSetupParticipant.java
new file mode 100644 (file)
index 0000000..82fcef9
--- /dev/null
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *      QNX Software Systems - Initial API and implementation
+ *      Andrew Ferguson (Symbian)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.editor;
+
+import org.eclipse.core.filebuffers.IDocumentSetupParticipant;
+import org.eclipse.core.filebuffers.IDocumentSetupParticipantExtension;
+import org.eclipse.core.filebuffers.LocationKind;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.text.IDocument;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.text.CTextTools;
+
+
+/**
+ * CDocumentSetupParticipant
+ */
+public class CDocumentSetupParticipant implements IDocumentSetupParticipant, IDocumentSetupParticipantExtension {
+       /**
+        * 
+        */
+       public CDocumentSetupParticipant() {
+       }
+       
+       /*
+        * @see org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup(org.eclipse.jface.text.IDocument)
+        */
+       public void setup(IDocument document) {
+               setup(document, null, null);
+       }
+       
+       /*
+        * @see org.eclipse.core.filebuffers.IDocumentSetupParticipantExtension#setup(org.eclipse.jface.text.IDocument, org.eclipse.core.runtime.IPath, org.eclipse.core.filebuffers.LocationKind)
+        */
+       public void setup(IDocument document, IPath location, LocationKind locationKind) {
+               CTextTools tools= CUIPlugin.getDefault().getTextTools();
+               tools.setupCDocument(document, location, locationKind);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java
new file mode 100644 (file)
index 0000000..ac350b3
--- /dev/null
@@ -0,0 +1,3745 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *     Markus Schorn (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *     Axel Mueller - [289339] Surround with
+ *     Tomasz Wesolowski - [320561] Override indicators
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import java.text.CharacterIterator;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.ResourceBundle;
+import java.util.Set;
+import java.util.Stack;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.help.IContext;
+import org.eclipse.help.IContextProvider;
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IStatusLineManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.MessageDialogWithToggle;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.BadPositionCategoryException;
+import org.eclipse.jface.text.DefaultLineTracker;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentExtension;
+import org.eclipse.jface.text.IDocumentExtension4;
+import org.eclipse.jface.text.IDocumentListener;
+import org.eclipse.jface.text.IInformationControl;
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.IPositionUpdater;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ISelectionValidator;
+import org.eclipse.jface.text.ISynchronizable;
+import org.eclipse.jface.text.ITextHover;
+import org.eclipse.jface.text.ITextInputListener;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.ITextViewerExtension;
+import org.eclipse.jface.text.ITextViewerExtension2;
+import org.eclipse.jface.text.ITextViewerExtension5;
+import org.eclipse.jface.text.ITextViewerExtension7;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.IWidgetTokenKeeper;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.text.contentassist.ContentAssistant;
+import org.eclipse.jface.text.contentassist.IContentAssistant;
+import org.eclipse.jface.text.formatter.FormattingContext;
+import org.eclipse.jface.text.formatter.FormattingContextProperties;
+import org.eclipse.jface.text.formatter.IFormattingContext;
+import org.eclipse.jface.text.link.ILinkedModeListener;
+import org.eclipse.jface.text.link.LinkedModeModel;
+import org.eclipse.jface.text.link.LinkedModeUI;
+import org.eclipse.jface.text.link.LinkedModeUI.ExitFlags;
+import org.eclipse.jface.text.link.LinkedModeUI.IExitPolicy;
+import org.eclipse.jface.text.link.LinkedPosition;
+import org.eclipse.jface.text.link.LinkedPositionGroup;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.text.source.IAnnotationModelExtension;
+import org.eclipse.jface.text.source.IAnnotationModelExtension2;
+import org.eclipse.jface.text.source.ICharacterPairMatcher;
+import org.eclipse.jface.text.source.IOverviewRuler;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.ISourceViewerExtension2;
+import org.eclipse.jface.text.source.IVerticalRuler;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
+import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel;
+import org.eclipse.jface.text.source.projection.ProjectionSupport;
+import org.eclipse.jface.text.source.projection.ProjectionViewer;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.search.ui.actions.TextSearchGroup;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.custom.ST;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.custom.VerifyKeyListener;
+import org.eclipse.swt.events.HelpEvent;
+import org.eclipse.swt.events.HelpListener;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorActionBarContributor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPartService;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.editors.text.TextEditor;
+import org.eclipse.ui.help.IWorkbenchHelpSystem;
+import org.eclipse.ui.ide.IGotoMarker;
+import org.eclipse.ui.navigator.ICommonMenuConstants;
+import org.eclipse.ui.part.EditorActionBarContributor;
+import org.eclipse.ui.part.IShowInSource;
+import org.eclipse.ui.part.IShowInTargetList;
+import org.eclipse.ui.part.ShowInContext;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
+import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
+import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
+import org.eclipse.ui.texteditor.AnnotationPreference;
+import org.eclipse.ui.texteditor.ChainedPreferenceStore;
+import org.eclipse.ui.texteditor.ContentAssistAction;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditorActionConstants;
+import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
+import org.eclipse.ui.texteditor.IUpdate;
+import org.eclipse.ui.texteditor.MarkerAnnotation;
+import org.eclipse.ui.texteditor.MarkerUtilities;
+import org.eclipse.ui.texteditor.SourceViewerDecorationSupport;
+import org.eclipse.ui.texteditor.TextNavigationAction;
+import org.eclipse.ui.texteditor.TextOperationAction;
+import org.eclipse.ui.texteditor.link.EditorLinkedModeUI;
+import org.eclipse.ui.texteditor.templates.ITemplatesPage;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+
+import com.ibm.icu.text.BreakIterator;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.CCorePreferenceConstants;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNodeSelector;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
+import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
+import org.eclipse.cdt.core.index.IIndexManager;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.ISourceRange;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.IWorkingCopyManager;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.actions.GenerateActionGroup;
+import org.eclipse.cdt.ui.actions.OpenViewActionGroup;
+import org.eclipse.cdt.ui.refactoring.actions.CRefactoringActionGroup;
+import org.eclipse.cdt.ui.text.CSourceViewerConfiguration;
+import org.eclipse.cdt.ui.text.ICPartitions;
+import org.eclipse.cdt.ui.text.folding.ICFoldingStructureProvider;
+
+import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
+import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
+import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.IContextMenuConstants;
+import org.eclipse.cdt.internal.ui.actions.AddBlockCommentAction;
+import org.eclipse.cdt.internal.ui.actions.FindWordAction;
+import org.eclipse.cdt.internal.ui.actions.FoldingActionGroup;
+import org.eclipse.cdt.internal.ui.actions.GoToNextPreviousMemberAction;
+import org.eclipse.cdt.internal.ui.actions.GotoNextBookmarkAction;
+import org.eclipse.cdt.internal.ui.actions.IndentAction;
+import org.eclipse.cdt.internal.ui.actions.RemoveBlockCommentAction;
+import org.eclipse.cdt.internal.ui.actions.StructureSelectEnclosingAction;
+import org.eclipse.cdt.internal.ui.actions.StructureSelectHistoryAction;
+import org.eclipse.cdt.internal.ui.actions.StructureSelectNextAction;
+import org.eclipse.cdt.internal.ui.actions.StructureSelectPreviousAction;
+import org.eclipse.cdt.internal.ui.actions.StructureSelectionAction;
+import org.eclipse.cdt.internal.ui.actions.SurroundWithActionGroup;
+import org.eclipse.cdt.internal.ui.search.IOccurrencesFinder;
+import org.eclipse.cdt.internal.ui.search.IOccurrencesFinder.OccurrenceLocation;
+import org.eclipse.cdt.internal.ui.search.OccurrencesFinder;
+import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
+import org.eclipse.cdt.internal.ui.text.CHeuristicScanner;
+import org.eclipse.cdt.internal.ui.text.CPairMatcher;
+import org.eclipse.cdt.internal.ui.text.CSourceViewerScalableConfiguration;
+import org.eclipse.cdt.internal.ui.text.CTextTools;
+import org.eclipse.cdt.internal.ui.text.CWordFinder;
+import org.eclipse.cdt.internal.ui.text.CWordIterator;
+import org.eclipse.cdt.internal.ui.text.DocumentCharacterIterator;
+import org.eclipse.cdt.internal.ui.text.ICReconcilingListener;
+import org.eclipse.cdt.internal.ui.text.Symbols;
+import org.eclipse.cdt.internal.ui.text.TabsToSpacesConverter;
+import org.eclipse.cdt.internal.ui.text.c.hover.SourceViewerInformationControl;
+import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
+import org.eclipse.cdt.internal.ui.util.CUIHelp;
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+import org.eclipse.cdt.internal.ui.viewsupport.ISelectionListenerWithAST;
+import org.eclipse.cdt.internal.ui.viewsupport.SelectionListenerWithASTManager;
+
+/**
+ * C/C++ source editor.
+ */
+public class CEditor extends TextEditor implements ISelectionChangedListener, ICReconcilingListener {
+       /** Marker used for synchronization from Problems View to the editor on double-click. */
+       private IMarker fSyncProblemsViewMarker = null;
+
+       /**
+        * A slightly modified implementation of IGotomarker compared to AbstractDecoratedTextEditor.
+        * 
+        * @since 5.0
+        */
+       private final class GotoMarkerAdapter implements IGotoMarker {
+               /*
+                * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#gotoMarker(org.eclipse.core.resources.IMarker)
+                */
+               public void gotoMarker(IMarker marker) {
+                       if (fIsUpdatingMarkerViews)
+                               return;
+
+                       if (getSourceViewer() == null)
+                               return;
+
+                       int start= MarkerUtilities.getCharStart(marker);
+                       int end= MarkerUtilities.getCharEnd(marker);
+                       
+                       boolean selectLine= start < 0 || end < 0;
+
+                       // look up the current range of the marker when the document has been edited
+                       IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput());
+                       if (model instanceof AbstractMarkerAnnotationModel) {
+                               AbstractMarkerAnnotationModel markerModel= (AbstractMarkerAnnotationModel) model;
+                               Position pos= markerModel.getMarkerPosition(marker);
+                               if (pos != null && !pos.isDeleted()) {
+                                       // use position instead of marker values
+                                       start= pos.getOffset();
+                                       end= pos.getOffset() + pos.getLength();
+                                       // use position as is
+                                       selectLine= false;
+                               }
+
+                               if (pos != null && pos.isDeleted()) {
+                                       // do nothing if position has been deleted
+                                       return;
+                               }
+                       }
+
+                       IDocument document= getDocumentProvider().getDocument(getEditorInput());
+
+                       if (selectLine) {
+                               int line;
+                               try {
+                                       if (start >= 0) {
+                                               IRegion lineInfo= document.getLineInformationOfOffset(start);
+                                               start= lineInfo.getOffset();
+                                               end= start + lineInfo.getLength();
+                                       } else {
+                                               line= MarkerUtilities.getLineNumber(marker);
+                                               // Marker line numbers are 1-based
+                                               -- line;
+                                               IRegion lineInfo= document.getLineInformation(line);
+                                               start= lineInfo.getOffset();
+                                               end= start + lineInfo.getLength();
+                                       }
+                               } catch (BadLocationException e) {
+                                       return;
+                               }
+                       }
+
+                       int length= document.getLength();
+                       if (end - 1 < length && start < length) {
+                               fSyncProblemsViewMarker = marker;
+                               selectAndReveal(start, end - start);
+                       }
+               }
+       }
+
+       class AdaptedSourceViewer extends CSourceViewer  {
+
+               public AdaptedSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
+                                                  boolean showAnnotationsOverview, int styles, IPreferenceStore store) {
+                       super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles, store);
+               }
+
+               @Override
+               public IContentAssistant getContentAssistant() {
+                       return fContentAssistant;
+               }
+
+               /*
+                * @see ITextOperationTarget#doOperation(int)
+                */
+               @Override
+               public void doOperation(int operation) {
+                       if (getTextWidget() == null)
+                               return;
+
+                       switch (operation) {
+                               case CONTENTASSIST_PROPOSALS:
+                                       String msg= fContentAssistant.showPossibleCompletions();
+                                       setStatusLineErrorMessage(msg);
+                                       return;
+                               case QUICK_ASSIST:
+                                       /*
+                                        * XXX: We can get rid of this once the SourceViewer has a way to update the status line
+                                        * https://bugs.eclipse.org/bugs/show_bug.cgi?id=133787
+                                        */
+                                       msg= fQuickAssistAssistant.showPossibleQuickAssists();
+                                       setStatusLineErrorMessage(msg);
+                                       return;
+                       }
+
+                       super.doOperation(operation);
+               }
+
+               /*
+                * @see IWidgetTokenOwner#requestWidgetToken(IWidgetTokenKeeper)
+                */
+               @Override
+               public boolean requestWidgetToken(IWidgetTokenKeeper requester) {
+                       if (PlatformUI.getWorkbench().getHelpSystem().isContextHelpDisplayed())
+                               return false;
+                       return super.requestWidgetToken(requester);
+               }
+
+               /*
+                * @see IWidgetTokenOwnerExtension#requestWidgetToken(IWidgetTokenKeeper, int)
+                * @since 3.0
+                */
+               @Override
+               public boolean requestWidgetToken(IWidgetTokenKeeper requester, int priority) {
+                       if (PlatformUI.getWorkbench().getHelpSystem().isContextHelpDisplayed())
+                               return false;
+                       return super.requestWidgetToken(requester, priority);
+               }
+
+               /*
+                * @see org.eclipse.jface.text.source.SourceViewer#createFormattingContext()
+                * @since 3.0
+                */
+               @Override
+               public IFormattingContext createFormattingContext() {
+                       IFormattingContext context= new FormattingContext();
+
+                       Map<String, Object> preferences;
+                       ICElement inputCElement= getInputCElement();
+                       ICProject cProject= inputCElement != null ? inputCElement.getCProject() : null;
+                       if (cProject == null)
+                               preferences= new HashMap<String, Object>(CCorePlugin.getOptions());
+                       else
+                               preferences= new HashMap<String, Object>(cProject.getOptions(true));
+
+                       if (inputCElement instanceof ITranslationUnit) {
+                               ITranslationUnit tu= (ITranslationUnit) inputCElement;
+                               ILanguage language= null;
+                               try {
+                                       language= tu.getLanguage();
+                               } catch (CoreException exc) {
+                                       // use fallback CPP
+                                       language= GPPLanguage.getDefault();
+                               }
+                               preferences.put(DefaultCodeFormatterConstants.FORMATTER_TRANSLATION_UNIT, tu);
+                       preferences.put(DefaultCodeFormatterConstants.FORMATTER_LANGUAGE, language);
+                               preferences.put(DefaultCodeFormatterConstants.FORMATTER_CURRENT_FILE, tu.getResource());
+                       }
+
+                       if (cProject == null) {
+                               // custom formatter specified?
+                               String customFormatterId= getPreferenceStore().getString(CCorePreferenceConstants.CODE_FORMATTER);
+                               if (customFormatterId != null) {
+                                       preferences.put(CCorePreferenceConstants.CODE_FORMATTER, customFormatterId);
+                               }
+                       }
+                       context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, preferences);
+
+                       return context;
+               }
+       }
+
+       private class ExitPolicy implements IExitPolicy {
+               final char fExitCharacter;
+               final char fEscapeCharacter;
+               final Stack<BracketLevel> fStack;
+               final int fSize;
+
+               public ExitPolicy(char exitCharacter, char escapeCharacter, Stack<BracketLevel> stack) {
+                       fExitCharacter = exitCharacter;
+                       fEscapeCharacter = escapeCharacter;
+                       fStack = stack;
+                       fSize = fStack.size();
+               }
+
+               /*
+                * @see org.eclipse.jface.text.link.LinkedModeUI$IExitPolicy#doExit(org.eclipse.jface.text.link.LinkedModeModel, org.eclipse.swt.events.VerifyEvent, int, int)
+                */
+               public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) {
+                       if (fSize == fStack.size() && !isMasked(offset)) {
+                               if (event.character == fExitCharacter) {
+                                       BracketLevel level = fStack.peek();
+                                       if (level.fFirstPosition.offset > offset || level.fSecondPosition.offset < offset)
+                                               return null;
+                                       if (level.fSecondPosition.offset == offset && length == 0)
+                                               // don't enter the character if if its the closing peer
+                                               return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
+                               }
+                               // when entering an anonymous class between the parenthesis', we don't want
+                               // to jump after the closing parenthesis when return is pressed
+                               if (event.character == SWT.CR && offset > 0) {
+                                       IDocument document = getSourceViewer().getDocument();
+                                       try {
+                                               if (document.getChar(offset - 1) == '{')
+                                                       return new ExitFlags(ILinkedModeListener.EXIT_ALL, true);
+                                       } catch (BadLocationException e) {
+                                       }
+                               }
+                       }
+                       return null;
+               }
+
+               private boolean isMasked(int offset) {
+                       IDocument document = getSourceViewer().getDocument();
+                       try {
+                               return fEscapeCharacter == document.getChar(offset - 1);
+                       } catch (BadLocationException e) {
+                       }
+                       return false;
+               }
+       }
+
+       private static class BracketLevel {
+//             int fOffset;
+//             int fLength;
+               LinkedModeUI fUI;
+               Position fFirstPosition;
+               Position fSecondPosition;
+       }
+
+       /**
+        * Position updater that takes any changes at the borders of a position to not belong to the position.
+        *
+        * @since 4.0
+        */
+       private static class ExclusivePositionUpdater implements IPositionUpdater {
+
+               /** The position category. */
+               private final String fCategory;
+
+               /**
+                * Creates a new updater for the given <code>category</code>.
+                *
+                * @param category the new category.
+                */
+               public ExclusivePositionUpdater(String category) {
+                       fCategory = category;
+               }
+
+               /*
+                * @see org.eclipse.jface.text.IPositionUpdater#update(org.eclipse.jface.text.DocumentEvent)
+                */
+               public void update(DocumentEvent event) {
+                       int eventOffset = event.getOffset();
+                       int eventOldLength = event.getLength();
+                       int eventNewLength = event.getText() == null ? 0 : event.getText().length();
+                       int deltaLength = eventNewLength - eventOldLength;
+
+                       try {
+                               Position[] positions = event.getDocument().getPositions(fCategory);
+
+                               for (int i = 0; i != positions.length; i++) {
+
+                                       Position position = positions[i];
+
+                                       if (position.isDeleted())
+                                               continue;
+
+                                       int offset = position.getOffset();
+                                       int length = position.getLength();
+                                       int end = offset + length;
+
+                                       if (offset >= eventOffset + eventOldLength) {
+                                               // position comes
+                                               // after change - shift
+                                               position.setOffset(offset + deltaLength);
+                                   } else if (end <= eventOffset) {
+                                               // position comes way before change -
+                                               // leave alone
+                                       } else if (offset <= eventOffset && end >= eventOffset + eventOldLength) {
+                                               // event completely internal to the position - adjust length
+                                               position.setLength(length + deltaLength);
+                                       } else if (offset < eventOffset) {
+                                               // event extends over end of position - adjust length
+                                               int newEnd = eventOffset;
+                                               position.setLength(newEnd - offset);
+                                       } else if (end > eventOffset + eventOldLength) {
+                                               // event extends from before position into it - adjust offset
+                                               // and length
+                                               // offset becomes end of event, length adjusted accordingly
+                                               int newOffset = eventOffset + eventNewLength;
+                                               position.setOffset(newOffset);
+                                               position.setLength(end - newOffset);
+                                       } else {
+                                               // event consumes the position - delete it
+                                               position.delete();
+                                       }
+                               }
+                       } catch (BadPositionCategoryException e) {
+                               // ignore and return
+                       }
+               }
+
+//             /**
+//              * Returns the position category.
+//              *
+//              * @return the position category
+//              */
+//             public String getCategory() {
+//                     return fCategory;
+//             }
+       }
+
+       private class BracketInserter implements VerifyKeyListener, ILinkedModeListener {
+
+               private boolean fCloseBrackets = true;
+               private boolean fCloseStrings = true;
+               private boolean fCloseAngularBrackets = true;
+               private final String CATEGORY = toString();
+               private IPositionUpdater fUpdater = new ExclusivePositionUpdater(CATEGORY);
+               private Stack<BracketLevel> fBracketLevelStack = new Stack<BracketLevel>();
+
+               public void setCloseBracketsEnabled(boolean enabled) {
+                       fCloseBrackets = enabled;
+               }
+
+               public void setCloseStringsEnabled(boolean enabled) {
+                       fCloseStrings = enabled;
+               }
+
+               public void setCloseAngularBracketsEnabled(boolean enabled) {
+                       fCloseAngularBrackets = enabled;
+               }
+
+               private boolean isAngularIntroducer(String identifier) {
+                       return identifier.length() > 0 && (Character.isUpperCase(identifier.charAt(0))
+                                       || angularIntroducers.contains(identifier)
+                                       || identifier.endsWith("_ptr") //$NON-NLS-1$
+                                       || identifier.endsWith("_cast")); //$NON-NLS-1$
+               }
+
+               /*
+                * @see org.eclipse.swt.custom.VerifyKeyListener#verifyKey(org.eclipse.swt.events.VerifyEvent)
+                */
+               public void verifyKey(VerifyEvent event) {
+
+                       // early pruning to slow down normal typing as little as possible
+                       if (!event.doit || getInsertMode() != SMART_INSERT)
+                               return;
+                       switch (event.character) {
+                               case '(':
+                               case '<':
+                               case '[':
+                               case '\'':
+                               case '\"':
+                                       break;
+                               default:
+                                       return;
+                       }
+
+                       final ISourceViewer sourceViewer = getSourceViewer();
+                       IDocument document = sourceViewer.getDocument();
+
+                       final Point selection = sourceViewer.getSelectedRange();
+                       final int offset = selection.x;
+                       final int length = selection.y;
+                       try {
+                               IRegion startLine = document.getLineInformationOfOffset(offset);
+                               IRegion endLine = document.getLineInformationOfOffset(offset + length);
+                               if (startLine != endLine && isBlockSelectionModeEnabled()) {
+                                       return;
+                               }
+
+                               ITypedRegion partition = TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, true);
+                               if (!IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType())
+                                               && !ICPartitions.C_PREPROCESSOR.equals(partition.getType())) {
+                                       return;
+                               }
+
+                               CHeuristicScanner scanner = new CHeuristicScanner(document, ICPartitions.C_PARTITIONING, partition.getType());
+                               int nextToken = scanner.nextToken(offset + length, endLine.getOffset() + endLine.getLength());
+                               String next = nextToken == Symbols.TokenEOF ? null : document.get(offset, scanner.getPosition() - offset).trim();
+                               int prevToken = scanner.previousToken(offset - 1, startLine.getOffset());
+                               int prevTokenOffset = scanner.getPosition() + 1;
+                               String previous = prevToken == Symbols.TokenEOF ? null : document.get(prevTokenOffset, offset - prevTokenOffset).trim();
+
+                               switch (event.character) {
+                                       case '(':
+                                               if (!fCloseBrackets
+                                                               || nextToken == Symbols.TokenLPAREN
+                                                               || nextToken == Symbols.TokenIDENT
+                                                               || next != null && next.length() > 1)
+                                                       return;
+                                               break;
+
+                                       case '<':
+                                               if (!(fCloseAngularBrackets && fCloseBrackets)
+                                                               || nextToken == Symbols.TokenLESSTHAN
+                                                               || prevToken != Symbols.TokenIDENT
+                                                               || !isAngularIntroducer(previous))
+                                                       return;
+                                               break;
+
+                                       case '[':
+                                               if (!fCloseBrackets
+                                                               || nextToken == Symbols.TokenIDENT
+                                                               || next != null && next.length() > 1)
+                                                       return;
+                                               break;
+
+                                       case '\'':
+                                       case '"':
+                                               if (!fCloseStrings
+                                                               || nextToken == Symbols.TokenIDENT
+                                                               || next != null && (next.length() > 1 || next.charAt(0) == event.character)
+                                                               || isInsideStringInPreprocessorDirective(partition, document, offset))
+                                                       return;
+                                               break;
+
+                                       default:
+                                               return;
+                               }
+
+                               if (!validateEditorInputState())
+                                       return;
+
+                               final char character = event.character;
+                               final char closingCharacter = getPeerCharacter(character);
+                               final StringBuilder buffer = new StringBuilder(3);
+                               buffer.append(character);
+                               buffer.append(closingCharacter);
+                               if (closingCharacter == '>' && nextToken != Symbols.TokenEOF
+                                               && document.getChar(offset + length) == '>') {
+                                       // Insert a space to avoid two consecutive closing angular brackets.
+                                       buffer.append(' ');
+                               }
+
+                               document.replace(offset, length, buffer.toString());
+
+                               BracketLevel level = new BracketLevel();
+                               fBracketLevelStack.push(level);
+
+                               LinkedPositionGroup group = new LinkedPositionGroup();
+                               group.addPosition(new LinkedPosition(document, offset + 1, 0, LinkedPositionGroup.NO_STOP));
+
+                               LinkedModeModel model = new LinkedModeModel();
+                               model.addLinkingListener(this);
+                               model.addGroup(group);
+                               model.forceInstall();
+
+//                             level.fOffset = offset;
+//                             level.fLength = 2;
+
+                               // set up position tracking for our magic peers
+                               if (fBracketLevelStack.size() == 1) {
+                                       document.addPositionCategory(CATEGORY);
+                                       document.addPositionUpdater(fUpdater);
+                               }
+                               level.fFirstPosition = new Position(offset, 1);
+                               level.fSecondPosition = new Position(offset + 1, 1);
+                               document.addPosition(CATEGORY, level.fFirstPosition);
+                               document.addPosition(CATEGORY, level.fSecondPosition);
+
+                               level.fUI = new EditorLinkedModeUI(model, sourceViewer);
+                               level.fUI.setSimpleMode(true);
+                               level.fUI.setExitPolicy(new ExitPolicy(closingCharacter, getEscapeCharacter(closingCharacter), fBracketLevelStack));
+                               level.fUI.setExitPosition(sourceViewer, offset + 2, 0, Integer.MAX_VALUE);
+                               level.fUI.setCyclingMode(LinkedModeUI.CYCLE_NEVER);
+                               level.fUI.enter();
+
+                               IRegion newSelection = level.fUI.getSelectedRegion();
+                               sourceViewer.setSelectedRange(newSelection.getOffset(), newSelection.getLength());
+
+                               event.doit = false;
+                       } catch (BadLocationException e) {
+                               CUIPlugin.log(e);
+                       } catch (BadPositionCategoryException e) {
+                               CUIPlugin.log(e);
+                       }
+               }
+
+               private boolean isInsideStringInPreprocessorDirective(ITypedRegion partition, IDocument document, int offset) throws BadLocationException {
+                       if (ICPartitions.C_PREPROCESSOR.equals(partition.getType()) && offset < document.getLength()) {
+                               // use temporary document to test whether offset is inside non-default partition
+                               String directive = document.get(partition.getOffset(), offset - partition.getOffset() + 1);
+                               int hashIdx = directive.indexOf('#');
+                               if (hashIdx >= 0) {
+                                       IDocument tmp = new Document(directive.substring(hashIdx + 1));
+                                       new CDocumentSetupParticipant().setup(tmp);
+                                       String type = TextUtilities.getContentType(tmp, ICPartitions.C_PARTITIONING, offset - (partition.getOffset() + hashIdx + 1), true);
+                                       if (!type.equals(IDocument.DEFAULT_CONTENT_TYPE)) {
+                                               return true;
+                                       }
+                               }
+                       }
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.jface.text.link.ILinkedModeListener#left(org.eclipse.jface.text.link.LinkedModeModel, int)
+                */
+               public void left(LinkedModeModel environment, int flags) {
+
+                       final BracketLevel level = fBracketLevelStack.pop();
+
+                       if (flags != ILinkedModeListener.EXTERNAL_MODIFICATION)
+                               return;
+
+                       // remove brackets
+                       final ISourceViewer sourceViewer = getSourceViewer();
+                       final IDocument document = sourceViewer.getDocument();
+                       if (document instanceof IDocumentExtension) {
+                               IDocumentExtension extension = (IDocumentExtension) document;
+                               extension.registerPostNotificationReplace(null, new IDocumentExtension.IReplace() {
+
+                                       public void perform(IDocument d, IDocumentListener owner) {
+                                               if ((level.fFirstPosition.isDeleted || level.fFirstPosition.length == 0)
+                                                               && !level.fSecondPosition.isDeleted
+                                                               && level.fSecondPosition.offset == level.fFirstPosition.offset) {
+                                                       try {
+                                                               document.replace(level.fSecondPosition.offset,
+                                                                                                level.fSecondPosition.length,
+                                                                                                null);
+                                                       } catch (BadLocationException e) {
+                                                               CUIPlugin.log(e);
+                                                       }
+                                               }
+
+                                               if (fBracketLevelStack.size() == 0) {
+                                                       document.removePositionUpdater(fUpdater);
+                                                       try {
+                                                               document.removePositionCategory(CATEGORY);
+                                                       } catch (BadPositionCategoryException e) {
+                                                               CUIPlugin.log(e);
+                                                       }
+                                               }
+                                       }
+                               });
+                       }
+               }
+
+               /*
+                * @see org.eclipse.jface.text.link.ILinkedModeListener#suspend(org.eclipse.jface.text.link.LinkedModeModel)
+                */
+               public void suspend(LinkedModeModel environment) {
+               }
+
+               /*
+                * @see org.eclipse.jface.text.link.ILinkedModeListener#resume(org.eclipse.jface.text.link.LinkedModeModel, int)
+                */
+               public void resume(LinkedModeModel environment, int flags) {
+               }
+       }
+
+       /**
+        * Updates the C outline page selection and this editor's range indicator.
+        *
+        * @since 3.0
+        */
+       private class EditorSelectionChangedListener extends AbstractSelectionChangedListener {
+
+               /**
+                * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+                */
+               public void selectionChanged(SelectionChangedEvent event) {
+                       // XXX: see https://bugs.eclipse.org/bugs/show_bug.cgi?id=56161
+                       CEditor.this.selectionChanged();
+               }
+       }
+
+       /**
+        * Text navigation action to navigate to the next sub-word.
+        *
+        * @since 4.0
+        */
+       protected abstract class NextSubWordAction extends TextNavigationAction {
+
+               protected CWordIterator fIterator = new CWordIterator();
+
+               /**
+                * Creates a new next sub-word action.
+                *
+                * @param code Action code for the default operation. Must be an action code from @see org.eclipse.swt.custom.ST.
+                */
+               protected NextSubWordAction(int code) {
+                       super(getSourceViewer().getTextWidget(), code);
+               }
+
+               /*
+                * @see org.eclipse.jface.action.IAction#run()
+                */
+               @Override
+               public void run() {
+                       // Check whether sub word navigation is enabled.
+                       final IPreferenceStore store = getPreferenceStore();
+                       if (!store.getBoolean(SUB_WORD_NAVIGATION)) {
+                               super.run();
+                               return;
+                       }
+
+                       final ISourceViewer viewer = getSourceViewer();
+                       final IDocument document = viewer.getDocument();
+                       fIterator.setText((CharacterIterator) new DocumentCharacterIterator(document));
+                       int position = widgetOffset2ModelOffset(viewer, viewer.getTextWidget().getCaretOffset());
+                       if (position == -1)
+                               return;
+
+                       int next = findNextPosition(position);
+                       try {
+                               if (isBlockSelectionModeEnabled() && document.getLineOfOffset(next) != document.getLineOfOffset(position)) {
+                                       super.run(); // may navigate into virtual white space
+                               } else if (next != BreakIterator.DONE) {
+                                       setCaretPosition(next);
+                                       getTextWidget().showSelection();
+                                       fireSelectionChanged();
+                               }
+                       } catch (BadLocationException x) {
+                               // ignore
+                       }
+               }
+
+               /**
+                * Finds the next position after the given position.
+                *
+                * @param position the current position
+                * @return the next position
+                */
+               protected int findNextPosition(int position) {
+                       ISourceViewer viewer = getSourceViewer();
+                       int widget = -1;
+                       while (position != BreakIterator.DONE && widget == -1) { // TODO: optimize
+                               position = fIterator.following(position);
+                               if (position != BreakIterator.DONE)
+                                       widget = modelOffset2WidgetOffset(viewer, position);
+                       }
+                       return position;
+               }
+
+               /**
+                * Sets the caret position to the sub-word boundary given with <code>position</code>.
+                *
+                * @param position Position where the action should move the caret
+                */
+               protected abstract void setCaretPosition(int position);
+       }
+
+       /**
+        * Text navigation action to navigate to the next sub-word.
+        *
+        * @since 4.0
+        */
+       protected class NavigateNextSubWordAction extends NextSubWordAction {
+
+               /**
+                * Creates a new navigate next sub-word action.
+                */
+               public NavigateNextSubWordAction() {
+                       super(ST.WORD_NEXT);
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.CEditor.NextSubWordAction#setCaretPosition(int)
+                */
+               @Override
+               protected void setCaretPosition(final int position) {
+                       getTextWidget().setCaretOffset(modelOffset2WidgetOffset(getSourceViewer(), position));
+               }
+       }
+
+       /**
+        * Text operation action to delete the next sub-word.
+        *
+        * @since 4.0
+        */
+       protected class DeleteNextSubWordAction extends NextSubWordAction implements IUpdate {
+
+               /**
+                * Creates a new delete next sub-word action.
+                */
+               public DeleteNextSubWordAction() {
+                       super(ST.DELETE_WORD_NEXT);
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.CEditor.NextSubWordAction#setCaretPosition(int)
+                */
+               @Override
+               protected void setCaretPosition(final int position) {
+                       if (!validateEditorInputState())
+                               return;
+
+                       final ISourceViewer viewer = getSourceViewer();
+                       StyledText text= viewer.getTextWidget();
+                       Point widgetSelection= text.getSelection();
+                       if (isBlockSelectionModeEnabled() && widgetSelection.y != widgetSelection.x) {
+                               final int caret= text.getCaretOffset();
+                               final int offset= modelOffset2WidgetOffset(viewer, position);
+
+                               if (caret == widgetSelection.x)
+                                       text.setSelectionRange(widgetSelection.y, offset - widgetSelection.y);
+                               else
+                                       text.setSelectionRange(widgetSelection.x, offset - widgetSelection.x);
+                               text.invokeAction(ST.DELETE_NEXT);
+                       } else {
+                               Point selection= viewer.getSelectedRange();
+                               final int caret, length;
+                               if (selection.y != 0) {
+                                       caret= selection.x;
+                                       length= selection.y;
+                               } else {
+                                       caret= widgetOffset2ModelOffset(viewer, text.getCaretOffset());
+                                       length= position - caret;
+                               }
+
+                               try {
+                                       viewer.getDocument().replace(caret, length, ""); //$NON-NLS-1$
+                               } catch (BadLocationException exception) {
+                                       // Should not happen
+                               }
+                       }
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.CEditor.NextSubWordAction#findNextPosition(int)
+                */
+               @Override
+               protected int findNextPosition(int position) {
+                       return fIterator.following(position);
+               }
+
+               /*
+                * @see org.eclipse.ui.texteditor.IUpdate#update()
+                */
+               public void update() {
+                       setEnabled(isEditorInputModifiable());
+               }
+       }
+
+       /**
+        * Text operation action to select the next sub-word.
+        *
+        * @since 4.0
+        */
+       protected class SelectNextSubWordAction extends NextSubWordAction {
+
+               /**
+                * Creates a new select next sub-word action.
+                */
+               public SelectNextSubWordAction() {
+                       super(ST.SELECT_WORD_NEXT);
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.CEditor.NextSubWordAction#setCaretPosition(int)
+                */
+               @Override
+               protected void setCaretPosition(final int position) {
+                       final ISourceViewer viewer = getSourceViewer();
+
+                       final StyledText text = viewer.getTextWidget();
+                       if (text != null && !text.isDisposed()) {
+
+                               final Point selection = text.getSelection();
+                               final int caret = text.getCaretOffset();
+                               final int offset = modelOffset2WidgetOffset(viewer, position);
+
+                               if (caret == selection.x)
+                                       text.setSelectionRange(selection.y, offset - selection.y);
+                               else
+                                       text.setSelectionRange(selection.x, offset - selection.x);
+                       }
+               }
+       }
+
+       /**
+        * Text navigation action to navigate to the previous sub-word.
+        *
+        * @since 4.0
+        */
+       protected abstract class PreviousSubWordAction extends TextNavigationAction {
+
+               protected CWordIterator fIterator = new CWordIterator();
+
+               /**
+                * Creates a new previous sub-word action.
+                *
+                * @param code Action code for the default operation. Must be an action code from @see org.eclipse.swt.custom.ST.
+                */
+               protected PreviousSubWordAction(final int code) {
+                       super(getSourceViewer().getTextWidget(), code);
+               }
+
+               /*
+                * @see org.eclipse.jface.action.IAction#run()
+                */
+               @Override
+               public void run() {
+                       // Check whether sub word navigation is enabled.
+                       final IPreferenceStore store = getPreferenceStore();
+                       if (!store.getBoolean(SUB_WORD_NAVIGATION)) {
+                               super.run();
+                               return;
+                       }
+
+                       final ISourceViewer viewer = getSourceViewer();
+                       final IDocument document = viewer.getDocument();
+                       fIterator.setText((CharacterIterator) new DocumentCharacterIterator(document));
+                       int position = widgetOffset2ModelOffset(viewer, viewer.getTextWidget().getCaretOffset());
+                       if (position == -1)
+                               return;
+
+                       int previous = findPreviousPosition(position);
+                       try {
+                               if (isBlockSelectionModeEnabled() && document.getLineOfOffset(previous) != document.getLineOfOffset(position)) {
+                                       super.run(); // may navigate into virtual white space
+                               } else if (previous != BreakIterator.DONE) {
+                                       setCaretPosition(previous);
+                                       getTextWidget().showSelection();
+                                       fireSelectionChanged();
+                               }
+                       } catch (BadLocationException x) {
+                               // ignore - getLineOfOffset failed
+                       }
+               }
+
+               /**
+                * Finds the previous position before the given position.
+                *
+                * @param position the current position
+                * @return the previous position
+                */
+               protected int findPreviousPosition(int position) {
+                       ISourceViewer viewer = getSourceViewer();
+                       int widget = -1;
+                       while (position != BreakIterator.DONE && widget == -1) { // TODO: optimize
+                               position = fIterator.preceding(position);
+                               if (position != BreakIterator.DONE)
+                                       widget = modelOffset2WidgetOffset(viewer, position);
+                       }
+                       return position;
+               }
+
+               /**
+                * Sets the caret position to the sub-word boundary given with <code>position</code>.
+                *
+                * @param position Position where the action should move the caret
+                */
+               protected abstract void setCaretPosition(int position);
+       }
+
+       /**
+        * Text navigation action to navigate to the previous sub-word.
+        *
+        * @since 4.0
+        */
+       protected class NavigatePreviousSubWordAction extends PreviousSubWordAction {
+
+               /**
+                * Creates a new navigate previous sub-word action.
+                */
+               public NavigatePreviousSubWordAction() {
+                       super(ST.WORD_PREVIOUS);
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.CEditor.PreviousSubWordAction#setCaretPosition(int)
+                */
+               @Override
+               protected void setCaretPosition(final int position) {
+                       getTextWidget().setCaretOffset(modelOffset2WidgetOffset(getSourceViewer(), position));
+               }
+       }
+
+       /**
+        * Text operation action to delete the previous sub-word.
+        *
+        * @since 4.0
+        */
+       protected class DeletePreviousSubWordAction extends PreviousSubWordAction implements IUpdate {
+
+               /**
+                * Creates a new delete previous sub-word action.
+                */
+               public DeletePreviousSubWordAction() {
+                       super(ST.DELETE_WORD_PREVIOUS);
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.CEditor.PreviousSubWordAction#setCaretPosition(int)
+                */
+               @Override
+               protected void setCaretPosition(int position) {
+                       if (!validateEditorInputState())
+                               return;
+
+                       final int length;
+                       final ISourceViewer viewer = getSourceViewer();
+                       StyledText text= viewer.getTextWidget();
+                       Point widgetSelection= text.getSelection();
+                       if (isBlockSelectionModeEnabled() && widgetSelection.y != widgetSelection.x) {
+                               final int caret= text.getCaretOffset();
+                               final int offset= modelOffset2WidgetOffset(viewer, position);
+
+                               if (caret == widgetSelection.x)
+                                       text.setSelectionRange(widgetSelection.y, offset - widgetSelection.y);
+                               else
+                                       text.setSelectionRange(widgetSelection.x, offset - widgetSelection.x);
+                               text.invokeAction(ST.DELETE_PREVIOUS);
+                       } else {
+                               Point selection= viewer.getSelectedRange();
+                               if (selection.y != 0) {
+                                       position= selection.x;
+                                       length= selection.y;
+                               } else {
+                                       length= widgetOffset2ModelOffset(viewer, text.getCaretOffset()) - position;
+                               }
+
+                               try {
+                                       viewer.getDocument().replace(position, length, ""); //$NON-NLS-1$
+                               } catch (BadLocationException exception) {
+                                       // Should not happen
+                               }
+                       }
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.CEditor.PreviousSubWordAction#findPreviousPosition(int)
+                */
+               @Override
+               protected int findPreviousPosition(int position) {
+                       return fIterator.preceding(position);
+               }
+
+               /*
+                * @see org.eclipse.ui.texteditor.IUpdate#update()
+                */
+               public void update() {
+                       setEnabled(isEditorInputModifiable());
+               }
+       }
+
+       /**
+        * Text operation action to select the previous sub-word.
+        *
+        * @since 4.0
+        */
+       protected class SelectPreviousSubWordAction extends PreviousSubWordAction {
+
+               /**
+                * Creates a new select previous sub-word action.
+                */
+               public SelectPreviousSubWordAction() {
+                       super(ST.SELECT_WORD_PREVIOUS);
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.CEditor.PreviousSubWordAction#setCaretPosition(int)
+                */
+               @Override
+               protected void setCaretPosition(final int position) {
+                       final ISourceViewer viewer = getSourceViewer();
+
+                       final StyledText text = viewer.getTextWidget();
+                       if (text != null && !text.isDisposed()) {
+
+                               final Point selection = text.getSelection();
+                               final int caret = text.getCaretOffset();
+                               final int offset = modelOffset2WidgetOffset(viewer, position);
+
+                               if (caret == selection.x)
+                                       text.setSelectionRange(selection.y, offset - selection.y);
+                               else
+                                       text.setSelectionRange(selection.x, offset - selection.x);
+                       }
+               }
+       }
+
+       private class IndexerPreferenceListener implements IPreferenceChangeListener {
+               private IProject fProject;
+
+               public void preferenceChange(PreferenceChangeEvent event) {
+                       if (IndexerPreferences.KEY_INDEX_ON_OPEN.equals(event.getKey())) {
+                               ICElement element= getInputCElement();
+                               ITranslationUnit tu = element != null ? (ITranslationUnit) element : null;
+                               updateIndexInclusion(tu, false);
+                       }
+               }
+
+               void registerFor(IProject project) {
+                       if (fProject == project || fProject != null && fProject.equals(project)) {
+                               return;
+                       }
+                       unregister();
+                       fProject = project;
+                       if (fProject != null) {
+                               IndexerPreferences.addChangeListener(fProject, this);
+                       }
+               }
+
+               void unregister() {
+                       if (fProject != null) {
+                               IndexerPreferences.removeChangeListener(fProject, this);
+                               fProject = null;
+                       }
+               }
+       }
+
+       private static class IndexUpdateRequestorJob extends Job {
+               // Temporary hack to avoid API changes.
+               private static final int RESET_INDEX_INCLUSION = IIndexManager.FORCE_INDEX_INCLUSION << 1;
+               private final ITranslationUnit tuToAdd;
+               private final ITranslationUnit tuToReset;
+
+               /**
+                * @param tu The translation unit to add or to remove from the index.
+                * @param add {@code true} to add, {@code false} to reset index inclusion.
+                */
+               IndexUpdateRequestorJob(ITranslationUnit tuToAdd, ITranslationUnit tuToReset) {
+                       super(CEditorMessages.CEditor_index_expander_job_name);
+                       this.tuToAdd = tuToAdd;
+                       this.tuToReset = tuToReset;
+                       setSystem(true);
+                       setPriority(Job.DECORATE);
+               }
+
+               @Override
+               protected IStatus run(IProgressMonitor monitor) {
+                       try {
+                               IIndexManager indexManager = CCorePlugin.getIndexManager();
+                               if (tuToReset != null) {
+                                       indexManager.update(new ICElement[] { tuToReset },
+                                                       RESET_INDEX_INCLUSION | IIndexManager.UPDATE_CHECK_TIMESTAMPS);
+                               }
+                               if (tuToAdd != null) {
+                                       indexManager.update(new ICElement[] { tuToAdd },
+                                                       IIndexManager.FORCE_INDEX_INCLUSION | IIndexManager.UPDATE_CHECK_TIMESTAMPS);
+                               }
+                       } catch (CoreException e) {
+                       }
+                       return Status.OK_STATUS;
+               }
+       }
+
+       /**
+        * The editor selection changed listener.
+        *
+        * @since 3.0
+        */
+       private EditorSelectionChangedListener fEditorSelectionChangedListener;
+
+       /**
+        * Time when last error message got set.
+        * 
+        * @since 5.3
+        */
+       private long fErrorMessageTime;
+
+       /**
+        * Timeout for the error message.
+        * 
+        * @since 5.3
+        */
+       private static final long ERROR_MESSAGE_TIMEOUT= 1000;
+
+       /** The outline page */
+       protected CContentOutlinePage fOutlinePage;
+
+       /** Search actions **/
+       private ActionGroup fSelectionSearchGroup;
+       private ActionGroup fTextSearchGroup;
+       private CRefactoringActionGroup fRefactoringActionGroup;
+       private ActionGroup fOpenInViewGroup;
+
+       /** Generate action group filling the "Source" submenu */
+       private GenerateActionGroup fGenerateActionGroup;
+       
+       /** Generate action group filling the "Surround with" submenu */
+       private SurroundWithActionGroup fSurroundWithActionGroup;
+
+       /** Pairs of brackets, used to match. */
+    protected final static char[] BRACKETS = { '{', '}', '(', ')', '[', ']', '<', '>' };
+
+       /** Matches the brackets. */
+    protected CPairMatcher fBracketMatcher = new CPairMatcher(BRACKETS);
+
+       /** The bracket inserter. */
+       private BracketInserter fBracketInserter = new BracketInserter();
+
+       /** Listener to annotation model changes that updates the error tick in the tab image */
+       private CEditorErrorTickUpdater fCEditorErrorTickUpdater;
+
+       /** Preference key for sub-word navigation, aka smart caret positioning */
+       public final static String SUB_WORD_NAVIGATION = "subWordNavigation"; //$NON-NLS-1$
+       /** Preference key for matching brackets */
+       public final static String MATCHING_BRACKETS = "matchingBrackets"; //$NON-NLS-1$
+       /** Preference key for matching brackets color */
+       public final static String MATCHING_BRACKETS_COLOR = "matchingBracketsColor"; //$NON-NLS-1$
+       /** Preference key for inactive code painter enablement */
+       public static final String INACTIVE_CODE_ENABLE = "inactiveCodeEnable"; //$NON-NLS-1$
+       /** Preference key for inactive code painter color */
+       public static final String INACTIVE_CODE_COLOR = "inactiveCodeColor"; //$NON-NLS-1$
+       /** Preference key for automatically closing strings */
+       private final static String CLOSE_STRINGS = PreferenceConstants.EDITOR_CLOSE_STRINGS;
+       /** Preference key for automatically closing brackets and parenthesis */
+       private final static String CLOSE_BRACKETS = PreferenceConstants.EDITOR_CLOSE_BRACKETS;
+       /** Preference key for automatically closing angular brackets */
+       private final static String CLOSE_ANGULAR_BRACKETS = PreferenceConstants.EDITOR_CLOSE_ANGULAR_BRACKETS;
+
+    /** Preference key for compiler task tags */
+    private final static String TODO_TASK_TAGS = CCorePreferenceConstants.TODO_TASK_TAGS;
+
+       /**
+        * This editor's projection support
+        */
+       protected ProjectionSupport fProjectionSupport;
+       /**
+        * This editor's projection model updater
+        */
+       private ICFoldingStructureProvider fProjectionModelUpdater;
+
+       /**
+        * The action group for folding.
+        */
+       private FoldingActionGroup fFoldingGroup;
+
+       /**
+        * AST reconciling listeners.
+        * @since 4.0
+        */
+       private ListenerList fReconcilingListeners= new ListenerList(ListenerList.IDENTITY);
+
+       /**
+        * Semantic highlighting manager
+        * @since 4.0
+        */
+       private SemanticHighlightingManager fSemanticManager;
+
+       /**
+        * True if editor is opening a large file.
+        * @since 5.0
+        */
+       private boolean fEnableScalablilityMode = false;
+
+       /**
+        * Flag indicating whether the reconciler is currently running.
+        */
+       private volatile boolean fIsReconciling;
+
+       private CTemplatesPage fTemplatesPage;
+
+       private SelectionHistory fSelectionHistory;
+
+       /** The translation unit that was added by the editor to index, or <code>null</code>. */
+       private ITranslationUnit fTuAddedToIndex;
+
+       private IndexerPreferenceListener fIndexerPreferenceListener;
+
+       private static final Set<String> angularIntroducers = new HashSet<String>();
+       static {
+               angularIntroducers.add("template"); //$NON-NLS-1$
+               angularIntroducers.add("vector"); //$NON-NLS-1$
+               angularIntroducers.add("deque"); //$NON-NLS-1$
+               angularIntroducers.add("list"); //$NON-NLS-1$
+               angularIntroducers.add("slist"); //$NON-NLS-1$
+               angularIntroducers.add("map"); //$NON-NLS-1$
+               angularIntroducers.add("set"); //$NON-NLS-1$
+               angularIntroducers.add("multimap"); //$NON-NLS-1$
+               angularIntroducers.add("multiset"); //$NON-NLS-1$
+               angularIntroducers.add("hash_map"); //$NON-NLS-1$
+               angularIntroducers.add("hash_set"); //$NON-NLS-1$
+               angularIntroducers.add("hash_multimap"); //$NON-NLS-1$
+               angularIntroducers.add("hash_multiset"); //$NON-NLS-1$
+               angularIntroducers.add("unordered_map"); //$NON-NLS-1$
+               angularIntroducers.add("unordered_set"); //$NON-NLS-1$
+               angularIntroducers.add("unordered_multimap"); //$NON-NLS-1$
+               angularIntroducers.add("unordered_multiset"); //$NON-NLS-1$
+               angularIntroducers.add("pair"); //$NON-NLS-1$
+               angularIntroducers.add("tuple"); //$NON-NLS-1$
+               angularIntroducers.add("include"); //$NON-NLS-1$
+       }
+
+       /**
+        * Default constructor.
+        */
+       public CEditor() {
+               setDocumentProvider(CUIPlugin.getDefault().getDocumentProvider());
+
+               setEditorContextMenuId("#CEditorContext"); //$NON-NLS-1$
+               setRulerContextMenuId("#CEditorRulerContext"); //$NON-NLS-1$
+               setOutlinerContextMenuId("#CEditorOutlinerContext"); //$NON-NLS-1$
+
+               fCEditorErrorTickUpdater = new CEditorErrorTickUpdater(this);
+               fIndexerPreferenceListener = new IndexerPreferenceListener();
+       }
+
+       /**
+        * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#initializeEditor()
+        */
+       @Override
+       protected void initializeEditor() {
+       }
+
+       /**
+        * @see org.eclipse.ui.texteditor.AbstractTextEditor#doSetInput(org.eclipse.ui.IEditorInput)
+        */
+       @Override
+       protected void doSetInput(IEditorInput input) throws CoreException {
+               ISourceViewer sourceViewer= getSourceViewer();
+               if (!(sourceViewer instanceof ISourceViewerExtension2)) {
+                       setPreferenceStore(createCombinedPreferenceStore(input));
+                       internalDoSetInput(input);
+                       updateScalabilityMode(input);
+                       return;
+               }
+
+               getDocumentProvider().connect(input);
+               try {
+                       // Uninstall & unregister preference store listener
+                       getSourceViewerDecorationSupport(sourceViewer).uninstall();
+                       ((ISourceViewerExtension2) sourceViewer).unconfigure();
+
+                       setPreferenceStore(createCombinedPreferenceStore(input));
+                       updateScalabilityMode(input);
+
+                       // Install & register preference store listener
+                       sourceViewer.configure(getSourceViewerConfiguration());
+                       getSourceViewerDecorationSupport(sourceViewer).install(getPreferenceStore());
+
+                       internalDoSetInput(input);
+               } finally {
+                       getDocumentProvider().disconnect(input);
+               }
+       }
+
+       private void internalDoSetInput(IEditorInput input) throws CoreException {
+               ISourceViewer sourceViewer= getSourceViewer();
+               CSourceViewer cSourceViewer= null;
+               if (sourceViewer instanceof CSourceViewer) {
+                       cSourceViewer= (CSourceViewer) sourceViewer;
+               }
+
+               IPreferenceStore store= getPreferenceStore();
+               if (cSourceViewer != null && isFoldingEnabled() && (store == null || !store.getBoolean(PreferenceConstants.EDITOR_SHOW_SEGMENTS)))
+                       cSourceViewer.prepareDelayedProjection();
+
+               fIndexerPreferenceListener.unregister();
+
+               super.doSetInput(input);
+
+               setOutlinePageInput(fOutlinePage, input);
+
+               if (fProjectionModelUpdater != null) {
+                       fProjectionModelUpdater.initialize();
+               }
+               if (fCEditorErrorTickUpdater != null) {
+                       fCEditorErrorTickUpdater.updateEditorImage(getInputCElement());
+               }
+               ICElement element= getInputCElement();
+               if (element != null) {
+                       IProject project = element.getCProject().getProject();
+                       fIndexerPreferenceListener.registerFor(project);
+               }
+
+               if (element instanceof ITranslationUnit) {
+                       ITranslationUnit tu = (ITranslationUnit) element;
+                       updateIndexInclusion(tu, false);
+                       fBracketMatcher.configure(tu.getLanguage());
+               } else {
+                       updateIndexInclusion(null, false);
+                       fBracketMatcher.configure(null);
+               }
+       }
+
+       private void updateIndexInclusion(ITranslationUnit tu, boolean synchronous) {
+               if (tu!= null) {
+                       IProject project = tu.getCProject().getProject();
+                       if (!String.valueOf(true).equals(IndexerPreferences.get(project, IndexerPreferences.KEY_INDEX_ON_OPEN, null))) {
+                               tu = null;
+                       }
+               }
+               if (tu != null || fTuAddedToIndex != null) {
+                       IndexUpdateRequestorJob job = new IndexUpdateRequestorJob(tu, fTuAddedToIndex);
+                       fTuAddedToIndex = tu;
+                       job.schedule();
+                       if (synchronous) {
+                               try {
+                                       job.join();
+                               } catch (InterruptedException e) {
+                                       // Ignore.
+                               }
+                       }
+               }
+       }
+
+       private void updateScalabilityMode(IEditorInput input) {
+               int lines = getDocumentProvider().getDocument(input).getNumberOfLines();
+               boolean wasEnabled = fEnableScalablilityMode;
+               fEnableScalablilityMode = lines > getPreferenceStore().getInt(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES);
+               if (fEnableScalablilityMode && !wasEnabled) {
+                       // Alert users that scalability mode should be turned on
+                       if (getPreferenceStore().getBoolean(PreferenceConstants.SCALABILITY_ALERT)) {
+                               MessageDialogWithToggle dialog = new MessageDialogWithToggle(
+                                               Display.getCurrent().getActiveShell(),
+                                               CEditorMessages.Scalability_info,  
+                                               null,
+                                               CEditorMessages.Scalability_message,  
+                                               MessageDialog.INFORMATION,
+                                               new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL}, 0,
+                                               CEditorMessages.Scalability_reappear,  
+                                               false) {
+                                       {
+                                               setShellStyle(SWT.DIALOG_TRIM | SWT.MODELESS | SWT.ON_TOP | getDefaultOrientation());
+                                       }
+                                       @Override
+                                       protected void buttonPressed(int buttonId) {
+                                               PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.SCALABILITY_ALERT, !getToggleState());
+                                               super.buttonPressed(buttonId);
+                                               if (buttonId == IDialogConstants.YES_ID) {
+                                                       PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(Display.getCurrent().getActiveShell(),
+                                                                       "org.eclipse.cdt.ui.preferences.CScalabilityPreferences", null, null); //$NON-NLS-1$
+                                                       dialog.open();
+                                               }
+                                       }
+                               };
+                               dialog.setBlockOnOpen(false);
+                               dialog.open();
+                       }
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.AbstractTextEditor#setPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)
+        * @since 5.0
+        */
+       @Override
+       protected void setPreferenceStore(IPreferenceStore store) {
+               super.setPreferenceStore(store);
+               SourceViewerConfiguration sourceViewerConfiguration= getSourceViewerConfiguration();
+               if (!(sourceViewerConfiguration instanceof CSourceViewerConfiguration)) {
+                       CTextTools textTools= CUIPlugin.getDefault().getTextTools();
+                       setSourceViewerConfiguration(new CSourceViewerScalableConfiguration(textTools.getColorManager(), store, this, ICPartitions.C_PARTITIONING));
+               }
+
+               if (getSourceViewer() instanceof CSourceViewer)
+                       ((CSourceViewer) getSourceViewer()).setPreferenceStore(store);
+
+               fMarkOccurrenceAnnotations= store.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
+               fMarkOverloadedOperatorOccurrences= store.getBoolean(PreferenceConstants.EDITOR_MARK_OVERLOADED_OPERATOR_OCCURRENCES);
+               fStickyOccurrenceAnnotations= store.getBoolean(PreferenceConstants.EDITOR_STICKY_OCCURRENCES);
+       }
+
+       /**
+        * Update the title image.
+     * @param image Title image.
+        */
+       public void updatedTitleImage(Image image) {
+               setTitleImage(image);
+       }
+
+       /**
+        * Returns the C element wrapped by this editors input.
+        *
+        * @return the C element wrapped by this editors input.
+        * @since 3.0
+        */
+       public ICElement getInputCElement () {
+               return CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(getEditorInput());
+       }
+
+       /**
+     * @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed()
+        */
+    @Override
+       public boolean isSaveAsAllowed() {
+               return true;
+       }
+
+       /**
+        * Gets the outline page of the c-editor.
+     * @return Outline page.
+        */
+       public CContentOutlinePage getOutlinePage() {
+               if (fOutlinePage == null) {
+                       fOutlinePage = new CContentOutlinePage(this);
+                       fOutlinePage.addSelectionChangedListener(this);
+               }
+               setOutlinePageInput(fOutlinePage, getEditorInput());
+               return fOutlinePage;
+       }
+
+       /**
+        * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+        */
+       @SuppressWarnings("rawtypes")
+       @Override
+       public Object getAdapter(Class required) {
+               if (IContentOutlinePage.class.equals(required)) {
+                       return getOutlinePage();
+               } else if (required == IShowInTargetList.class) {
+                       return new IShowInTargetList() {
+                               @SuppressWarnings("deprecation")
+                               public String[] getShowInTargetIds() {
+                                       return new String[] { IPageLayout.ID_PROJECT_EXPLORER, IPageLayout.ID_OUTLINE, IPageLayout.ID_RES_NAV };
+                               }
+                       };
+               } else if (required == IShowInSource.class) {
+                       ICElement ce= null;
+                       ce= getElementAt(getSourceViewer().getSelectedRange().x, false);
+                       if (ce instanceof ITranslationUnit) {
+                               ce = null;
+                       }
+                       final ISelection selection= ce != null ? new StructuredSelection(ce) : null;
+                       return new IShowInSource() {
+                               public ShowInContext getShowInContext() {
+                                       return new ShowInContext(getEditorInput(), selection);
+                               }
+                       };
+               } else if (ProjectionAnnotationModel.class.equals(required)) {
+                       if (fProjectionSupport != null) {
+                               Object adapter = fProjectionSupport.getAdapter(getSourceViewer(), required);
+                               if (adapter != null)
+                                       return adapter;
+                       }
+               } else if (IContextProvider.class.equals(required)) {
+                       return new CUIHelp.CUIHelpContextProvider(this);
+               } else if (IGotoMarker.class.equals(required)) {
+                       IGotoMarker gotoMarker= new GotoMarkerAdapter();
+                       return gotoMarker;
+               } else if (ITemplatesPage.class.equals(required)) {
+                       if (fTemplatesPage == null) {
+                               fTemplatesPage = new CTemplatesPage(this);
+                       }
+                       return fTemplatesPage;
+               }
+               return super.getAdapter(required);
+       }
+       
+       /**
+        * Handles a property change event describing a change
+        * of the editor's preference store and updates the preference
+        * related editor properties.
+        *
+        * @param event the property change event
+        */
+       @Override
+       protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
+               String property = event.getProperty();
+
+               if (AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH.equals(property)) {
+                       /*
+                        * Ignore tab setting since we rely on the formatter preferences.
+                        * We do this outside the try-finally block to avoid that EDITOR_TAB_WIDTH
+                        * is handled by the base-class (AbstractDecoratedTextEditor).
+                        */
+                       return;
+               }
+               if (AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS.equals(property)) {
+                       // Ignore spaces-for-tab setting since we rely on the formatter preferences.
+                       return;
+               }
+
+               try {
+                       final AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
+
+                       if (asv != null) {
+
+                               boolean newBooleanValue= false;
+                               Object newValue= event.getNewValue();
+                               if (newValue != null)
+                                       newBooleanValue= Boolean.valueOf(newValue.toString()).booleanValue();
+
+                               if (CLOSE_BRACKETS.equals(property)) {
+                                       fBracketInserter.setCloseBracketsEnabled(newBooleanValue);
+                                       return;
+                               }
+
+                               if (CLOSE_ANGULAR_BRACKETS.equals(property)) {
+                                       fBracketInserter.setCloseAngularBracketsEnabled(newBooleanValue);
+                                       return;
+                               }
+
+                               if (CLOSE_STRINGS.equals(property)) {
+                                       fBracketInserter.setCloseStringsEnabled(newBooleanValue);
+                                       return;
+                               }
+
+                               if (PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS.equals(property))
+                                       updateHoverBehavior();
+
+                               ((CSourceViewerConfiguration) getSourceViewerConfiguration()).handlePropertyChangeEvent(event);
+
+                               if (PreferenceConstants.EDITOR_SMART_TAB.equals(property)) {
+                                       if (newBooleanValue) {
+                                               setActionActivationCode("IndentOnTab", '\t', -1, SWT.NONE); //$NON-NLS-1$
+                                       } else {
+                                               removeActionActivationCode("IndentOnTab"); //$NON-NLS-1$
+                                       }
+                                       return;
+                               }
+
+                               if (TODO_TASK_TAGS.equals(event.getProperty())) {
+                                       ISourceViewer sourceViewer = getSourceViewer();
+                                       if (sourceViewer != null && affectsTextPresentation(event))
+                                               sourceViewer.invalidateTextPresentation();
+                                       return;
+                               }
+                               
+                               if (affectsOverrideIndicatorAnnotations(event)) {
+                                       if (isShowingOverrideIndicators()) {
+                                               if (fOverrideIndicatorManager == null)
+                                                       installOverrideIndicator(true);
+                                       } else {
+                                               if (fOverrideIndicatorManager != null)
+                                                       uninstallOverrideIndicator();
+                                       }
+                                       return;
+                               }
+
+                               if (PreferenceConstants.EDITOR_FOLDING_PROVIDER.equals(property)) {
+                                       if (fProjectionModelUpdater != null) {
+                                               fProjectionModelUpdater.uninstall();
+                                       }
+                                       // either freshly enabled or provider changed
+                                       fProjectionModelUpdater = CUIPlugin.getDefault().getFoldingStructureProviderRegistry().getCurrentFoldingProvider();
+                                       if (fProjectionModelUpdater != null) {
+                                               fProjectionModelUpdater.install(this, asv);
+                                       }
+                                       return;
+                               }
+
+                               if (DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE.equals(property)
+                                               || DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE.equals(property)
+                                               || DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR.equals(property)) {
+                                       StyledText textWidget= asv.getTextWidget();
+                                       int tabWidth= getSourceViewerConfiguration().getTabWidth(asv);
+                                       if (textWidget.getTabs() != tabWidth)
+                                               textWidget.setTabs(tabWidth);
+                                       uninstallTabsToSpacesConverter();
+                                       if (isTabsToSpacesConversionEnabled()) {
+                                               installTabsToSpacesConverter();
+                                       } else {
+                                               updateIndentationMode();
+                                       }
+                                       return;
+                               }
+
+                               if (PreferenceConstants.EDITOR_MARK_OCCURRENCES.equals(property)) {
+                                       if (newBooleanValue != fMarkOccurrenceAnnotations) {
+                                               fMarkOccurrenceAnnotations= newBooleanValue;
+                                               if (!fMarkOccurrenceAnnotations)
+                                                       uninstallOccurrencesFinder();
+                                               else
+                                                       installOccurrencesFinder(true);
+                                       }
+                                       return;
+                               }
+                               if (PreferenceConstants.EDITOR_STICKY_OCCURRENCES.equals(property)) {
+                                       fStickyOccurrenceAnnotations= newBooleanValue;
+                                       return;
+                               }
+                               if (PreferenceConstants.EDITOR_MARK_OVERLOADED_OPERATOR_OCCURRENCES.equals(property)) {
+                                       fMarkOverloadedOperatorOccurrences= newBooleanValue;
+                                       return;
+                               }
+
+                               if (SemanticHighlightings.affectsEnablement(getPreferenceStore(), event)
+                                               || (isEnableScalablilityMode() && PreferenceConstants.SCALABILITY_SEMANTIC_HIGHLIGHT.equals(property))) {
+                                       if (isSemanticHighlightingEnabled()) {
+                                               installSemanticHighlighting();
+                                               fSemanticManager.refresh();
+                                       } else {
+                                               uninstallSemanticHighlighting();
+                                       }
+                                       return;
+                               }
+                               
+                               // For Scalability
+                               if (isEnableScalablilityMode()) {
+                                       if (PreferenceConstants.SCALABILITY_RECONCILER.equals(property) ||
+                                                       PreferenceConstants.SCALABILITY_SYNTAX_COLOR.equals(property)) {
+                                               BusyIndicator.showWhile(getSite().getShell().getDisplay(), new Runnable() {
+                                                       public void run() {
+                                                               setOutlinePageInput(fOutlinePage, getEditorInput());
+                                                               asv.unconfigure();
+                                                               asv.configure(getSourceViewerConfiguration());
+                                                       }});
+                                               return;
+                                       }
+                               }
+                               
+                               IContentAssistant c = asv.getContentAssistant();
+                               if (c instanceof ContentAssistant) {
+                                       ContentAssistPreference.changeConfiguration((ContentAssistant) c, getPreferenceStore(), event);
+                               }
+                       }
+               } finally {
+                       super.handlePreferenceStoreChanged(event);
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.AbstractTextEditor#initializeViewerColors(org.eclipse.jface.text.source.ISourceViewer)
+        */
+       @Override
+       protected void initializeViewerColors(ISourceViewer viewer) {
+               // is handled by CSourceViewer
+       }
+
+       /*
+        * Update the hovering behavior depending on the preferences.
+        */
+       private void updateHoverBehavior() {
+               SourceViewerConfiguration configuration= getSourceViewerConfiguration();
+               String[] types= configuration.getConfiguredContentTypes(getSourceViewer());
+
+               for (String t : types) {
+
+                       ISourceViewer sourceViewer= getSourceViewer();
+                       if (sourceViewer instanceof ITextViewerExtension2) {
+                               // Remove existing hovers
+                               ((ITextViewerExtension2) sourceViewer).removeTextHovers(t);
+
+                               int[] stateMasks= configuration.getConfiguredTextHoverStateMasks(getSourceViewer(), t);
+
+                               if (stateMasks != null) {
+                                       for (int stateMask : stateMasks) {
+                                               ITextHover textHover= configuration.getTextHover(sourceViewer, t, stateMask);
+                                               ((ITextViewerExtension2) sourceViewer).setTextHover(textHover, t, stateMask);
+                                       }
+                               } else {
+                                       ITextHover textHover= configuration.getTextHover(sourceViewer, t);
+                                       ((ITextViewerExtension2) sourceViewer).setTextHover(textHover, t, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
+                               }
+                       } else {
+                               sourceViewer.setTextHover(configuration.getTextHover(sourceViewer, t), t);
+                       }
+               }
+       }
+
+       /**
+        * React to changed selection in the editor.
+        *
+        * @since 3.0
+        */
+       protected void selectionChanged() {
+               if (getSelectionProvider() == null)
+                       return;
+               ISourceReference element= computeHighlightRangeSourceReference();
+               updateStatusLine();
+               synchronizeOutlinePage();
+               setSelection(element, false);
+       }
+
+       /**
+        * Computes and returns the source reference that includes the caret and
+        * serves as provider for the outline page selection and the editor range
+        * indication.
+        *
+        * @return the computed source reference
+        * @since 4.0
+        */
+       protected ISourceReference computeHighlightRangeSourceReference() {
+               ISourceViewer sourceViewer= getSourceViewer();
+               if (sourceViewer == null)
+                       return null;
+
+               StyledText styledText= sourceViewer.getTextWidget();
+               if (styledText == null)
+                       return null;
+
+               int caret= 0;
+               if (sourceViewer instanceof ITextViewerExtension5) {
+                       ITextViewerExtension5 extension= (ITextViewerExtension5) sourceViewer;
+                       caret= extension.widgetOffset2ModelOffset(styledText.getSelection().x);
+               } else {
+                       int offset= sourceViewer.getVisibleRegion().getOffset();
+                       caret= offset + styledText.getSelection().x;
+               }
+
+               ICElement element= getElementAt(caret, false);
+
+               if (!(element instanceof ISourceReference))
+                       return null;
+
+               return (ISourceReference) element;
+       }
+
+       /**
+        * Returns the most narrow element including the given offset.  If <code>reconcile</code>
+        * is <code>true</code> the editor's input element is reconciled in advance. If it is
+        * <code>false</code> this method only returns a result if the editor's input element
+        * does not need to be reconciled.
+        *
+        * @param offset the offset included by the retrieved element
+        * @param reconcile <code>true</code> if working copy should be reconciled
+        * @return the most narrow element which includes the given offset
+        */
+       protected ICElement getElementAt(int offset, boolean reconcile) {
+               ITranslationUnit unit= (ITranslationUnit) getInputCElement();
+
+               if (unit != null) {
+                       try {
+                               if (reconcile && unit instanceof IWorkingCopy) {
+                                       synchronized (unit) {
+                                               ((IWorkingCopy) unit).reconcile();
+                                       }
+                                       return unit.getElementAtOffset(offset);
+                               } else if (unit.isStructureKnown() && unit.isConsistent() && !fIsReconciling) {
+                                       return unit.getElementAtOffset(offset);
+                               }
+                       } catch (CModelException x) {
+                               CUIPlugin.log(x.getStatus());
+                               // nothing found, be tolerant and go on
+                       }
+               }
+
+               return null;
+       }
+
+       /**
+        * Synchronizes the outline view selection with the given element
+        * position in the editor.
+        *
+        * @since 4.0
+        */
+       protected void synchronizeOutlinePage() {
+               if (fOutlinePage != null && fOutlinePage.isLinkingEnabled()) {
+                       fOutlinePage.removeSelectionChangedListener(this);
+                       fOutlinePage.synchronizeSelectionWithEditor();
+                       fOutlinePage.addSelectionChangedListener(this);
+               }
+       }
+
+       /**
+        * React to changed selection in the outline view.
+        * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+        */
+       public void selectionChanged(SelectionChangedEvent event) {
+               ISelection sel = event.getSelection();
+               if (sel instanceof IStructuredSelection) {
+                       IStructuredSelection selection = (IStructuredSelection) sel;
+                       Object obj = selection.getFirstElement();
+                       if (obj instanceof ISourceReference) {
+                               try {
+                                       ISourceRange range = ((ISourceReference) obj).getSourceRange();
+                                       if (range != null) {
+                                               setSelection(range, !isActivePart());
+                                       }
+                               } catch (CModelException e) {
+                    // Selection change not applied.
+                               }
+                       }
+               }
+       }
+
+       /**
+     * Sets selection for C element.
+     * @param element Element to select.
+        */
+    public void setSelection(ICElement element) {
+               if (element instanceof ISourceReference && !(element instanceof ITranslationUnit)) {
+                       ISourceReference reference = (ISourceReference) element;
+                       // set hightlight range
+                       setSelection(reference, true);
+               }
+       }
+
+    /**
+     * Sets selection for source reference.
+     * @param element Source reference to set.
+     * @param moveCursor Should cursor be moved.
+     */
+    public void setSelection(ISourceReference element, boolean moveCursor) {
+               if (element != null) {
+                       StyledText  textWidget = null;
+
+                       ISourceViewer sourceViewer = getSourceViewer();
+                       if (sourceViewer != null)
+                               textWidget = sourceViewer.getTextWidget();
+
+                       if (textWidget == null)
+                               return;
+
+                       try {
+                               setSelection(element.getSourceRange(), moveCursor);
+                       } catch (CModelException e) {
+                // Selection not applied.
+                       }
+               }
+       }
+
+       /**
+        * Sets the current editor selection to the source range. Optionally
+        * sets the current editor position.
+        *
+        * @param element the source range to be shown in the editor, can be null.
+        * @param moveCursor if true the editor is scrolled to show the range.
+        */
+       public void setSelection(ISourceRange element, boolean moveCursor) {
+               if (getSelectionProvider() == null)
+                       return;
+
+               ISelection selection= getSelectionProvider().getSelection();
+               if (selection instanceof ITextSelection) {
+                       ITextSelection textSelection= (ITextSelection) selection;
+                       // PR 39995: [navigation] Forward history cleared after going back in navigation history:
+                       // mark only in navigation history if the cursor is being moved (which it isn't if
+                       // this is called from a PostSelectionEvent that should only update the magnet)
+                       if (moveCursor && (textSelection.getOffset() != 0 || textSelection.getLength() != 0))
+                               markInNavigationHistory();
+               }
+
+               if (element != null) {
+                       
+                       StyledText textWidget= null;
+                       
+                       ISourceViewer sourceViewer= getSourceViewer();
+                       if (sourceViewer == null)
+                               return;
+                       
+                       textWidget= sourceViewer.getTextWidget();
+                       if (textWidget == null)
+                               return;
+
+                       try {
+                               IRegion alternateRegion = null;
+                               int start = element.getStartPos();
+                               int length = element.getLength();
+       
+                               // Sanity check sometimes the parser may throw wrong numbers.
+                               if (start < 0 || length < 0) {
+                                       start = 0;
+                                       length = 0;
+                               }
+       
+                               // 0 length and start and non-zero start line says we know
+                               // the line for some reason, but not the offset.
+                               if (length == 0 && start == 0 && element.getStartLine() > 0) {
+                                       // We have the information in term of lines, we can work it out.
+                                       // Binary elements return the first executable statement so we have to subtract -1
+                                       start = getDocumentProvider().getDocument(getEditorInput()).getLineOffset(element.getStartLine() - 1);
+                                       if (element.getEndLine() > 0) {
+                                               length = getDocumentProvider().getDocument(getEditorInput()).getLineOffset(element.getEndLine()) - start;
+                                       } else {
+                                               length = start;
+                                       }
+                                       // create an alternate region for the keyword highlight.
+                                       alternateRegion = getDocumentProvider().getDocument(getEditorInput()).getLineInformation(element.getStartLine() - 1);
+                                       if (start == length || length < 0) {
+                                               if (alternateRegion != null) {
+                                                       start = alternateRegion.getOffset();
+                                                       length = alternateRegion.getLength();
+                                               }
+                                       }
+                               }
+                               setHighlightRange(start, length, moveCursor);
+       
+                               if (moveCursor) {
+                                       start = element.getIdStartPos();
+                                       length = element.getIdLength();
+                                       if (start == 0 && length == 0 && alternateRegion != null) {
+                                               start = alternateRegion.getOffset();
+                                               length = alternateRegion.getLength();
+                                       }
+                                       if (start > -1 && length > 0) {
+                                               try  {
+                                                       textWidget.setRedraw(false);
+                                                       sourceViewer.revealRange(start, length);
+                                                       sourceViewer.setSelectedRange(start, length);
+                                               } finally {
+                                                       textWidget.setRedraw(true);
+                                               }
+                                               markInNavigationHistory();
+                                       }
+                                       updateStatusField(ITextEditorActionConstants.STATUS_CATEGORY_INPUT_POSITION);
+                               }
+                       } catch (IllegalArgumentException x) {
+                   // No information to the user
+                       } catch (BadLocationException e) {
+                   // No information to the user
+                       }
+               } else if (moveCursor) {
+                       resetHighlightRange();
+                       markInNavigationHistory();
+               }
+       }
+
+       /**
+     * Checks is the editor active part.
+     * @return <code>true</code> if editor is the active part of the workbench.
+        */
+    private boolean isActivePart() {
+               IWorkbenchWindow window = getSite().getWorkbenchWindow();
+               IPartService service = window.getPartService();
+               return (this == service.getActivePart());
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.AbstractTextEditor#installTabsToSpacesConverter()
+        * @since 4.0
+        */
+       @Override
+       protected void installTabsToSpacesConverter() {
+               ISourceViewer sourceViewer= getSourceViewer();
+               SourceViewerConfiguration config= getSourceViewerConfiguration();
+               if (config != null && sourceViewer instanceof ITextViewerExtension7) {
+                       int tabWidth= config.getTabWidth(sourceViewer);
+                       TabsToSpacesConverter tabToSpacesConverter= new TabsToSpacesConverter();
+                       tabToSpacesConverter.setNumberOfSpacesPerTab(tabWidth);
+                       IDocumentProvider provider= getDocumentProvider();
+                       if (provider instanceof CDocumentProvider) {
+                               CDocumentProvider cProvider= (CDocumentProvider) provider;
+                               tabToSpacesConverter.setLineTracker(cProvider.createLineTracker(getEditorInput()));
+                       } else {
+                               tabToSpacesConverter.setLineTracker(new DefaultLineTracker());
+                       }
+                       ((ITextViewerExtension7) sourceViewer).setTabsToSpacesConverter(tabToSpacesConverter);
+                       updateIndentationMode();
+               }
+       }
+
+       private void updateIndentationMode() {
+               ISourceViewer sourceViewer= getSourceViewer();
+               if (sourceViewer instanceof CSourceViewer) {
+                       CSourceViewer cSourceVieer= (CSourceViewer) sourceViewer;
+                       ICElement element= getInputCElement();
+                       ICProject project= element == null ? null : element.getCProject();
+                       final int indentWidth= CodeFormatterUtil.getIndentWidth(project);
+                       final boolean useSpaces= isTabsToSpacesConversionEnabled();
+                       cSourceVieer.configureIndentation(indentWidth, useSpaces);
+               }
+               super.updateIndentPrefixes();
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#isTabsToSpacesConversionEnabled()
+        * @since 4.0
+        */
+       @Override
+       protected boolean isTabsToSpacesConversionEnabled() {
+               ICElement element= getInputCElement();
+               ICProject project= element == null ? null : element.getCProject();
+               String option;
+               if (project == null)
+                       option= CCorePlugin.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
+               else
+                       option= project.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, true);
+               return CCorePlugin.SPACE.equals(option);
+       }
+
+    /**
+     * @see org.eclipse.ui.IWorkbenchPart#dispose()
+     */
+    @Override
+       public void dispose() {
+       updateIndexInclusion(null, true);
+
+               ISourceViewer sourceViewer = getSourceViewer();
+               if (sourceViewer instanceof ITextViewerExtension)
+                       ((ITextViewerExtension) sourceViewer).removeVerifyKeyListener(fBracketInserter);
+
+               if (fProjectionModelUpdater != null) {
+                       fProjectionModelUpdater.uninstall();
+                       fProjectionModelUpdater = null;
+               }
+
+               if (fProjectionSupport != null) {
+                       fProjectionSupport.dispose();
+                       fProjectionSupport = null;
+               }
+
+               // cancel possible running computation
+               fMarkOccurrenceAnnotations= false;
+               uninstallOccurrencesFinder();
+               uninstallOverrideIndicator();
+
+       uninstallSemanticHighlighting();
+
+               if (fCEditorErrorTickUpdater != null) {
+                       fCEditorErrorTickUpdater.dispose();
+                       fCEditorErrorTickUpdater = null;
+               }
+
+        if (fBracketMatcher != null) {
+                       fBracketMatcher.dispose();
+                       fBracketMatcher = null;
+               }
+
+               if (fOutlinePage != null) {
+                       fOutlinePage.dispose();
+                       fOutlinePage = null;
+               }
+
+               if (fSelectionSearchGroup != null) {
+                       fSelectionSearchGroup.dispose();
+                       fSelectionSearchGroup = null;
+               }
+
+               if (fTextSearchGroup != null) {
+                       fTextSearchGroup.dispose();
+                       fTextSearchGroup = null;
+               }
+
+               if (fRefactoringActionGroup != null) {
+                       fRefactoringActionGroup.dispose();
+                       fRefactoringActionGroup = null;
+               }
+
+               if (fOpenInViewGroup != null) {
+                       fOpenInViewGroup.dispose();
+                       fOpenInViewGroup = null;
+               }
+
+               if (fGenerateActionGroup != null) {
+                       fGenerateActionGroup.dispose();
+                       fGenerateActionGroup= null;
+               }
+               
+               if (fSurroundWithActionGroup != null) {
+                       fSurroundWithActionGroup.dispose();
+                       fSurroundWithActionGroup= null;
+               }
+               
+               if (fEditorSelectionChangedListener != null)  {
+                       fEditorSelectionChangedListener.uninstall(getSelectionProvider());
+                       fEditorSelectionChangedListener = null;
+               }
+               
+               if (fSelectionHistory != null) {
+                       fSelectionHistory.dispose();
+                       fSelectionHistory = null;
+               }
+
+               super.dispose();
+       }
+
+       /**
+        * @see org.eclipse.ui.texteditor.AbstractTextEditor#canHandleMove(org.eclipse.ui.IEditorInput, org.eclipse.ui.IEditorInput)
+        */
+       @Override
+       protected boolean canHandleMove(IEditorInput originalElement, IEditorInput movedElement) {
+               String oldLanguage = ""; //$NON-NLS-1$
+               if (originalElement instanceof IFileEditorInput) {
+                       IFile file = ((IFileEditorInput) originalElement).getFile();
+                       if (file != null) {
+                               IContentType type = CCorePlugin.getContentType(file.getProject(), file.getName());
+                               if (type != null) {
+                                       oldLanguage = type.getId();
+                               }
+                               if (oldLanguage == null) {
+                                       return false;
+                               }
+                       }
+               }
+
+               String newLanguage = ""; //$NON-NLS-1$
+               if (movedElement instanceof IFileEditorInput) {
+                       IFile file = ((IFileEditorInput) movedElement).getFile();
+                       if (file != null) {
+                               IContentType type = CCorePlugin.getContentType(file.getProject(), file.getName());
+                               if (type != null) {
+                                       newLanguage = type.getId();
+                               }
+                               if (newLanguage == null) {
+                                       return false;
+                               }
+                       }
+               }
+               return oldLanguage.equals(newLanguage);
+       }
+
+       /**
+        * @see org.eclipse.ui.texteditor.AbstractTextEditor#createActions()
+        */
+       @Override
+       protected void createActions() {
+               super.createActions();
+
+               fFoldingGroup = new FoldingActionGroup(this, getSourceViewer());
+
+               // Default text editing menu items
+               IAction action= new GotoMatchingBracketAction(this);
+               action.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_MATCHING_BRACKET);
+               setAction(GotoMatchingBracketAction.GOTO_MATCHING_BRACKET, action);
+               
+               final ResourceBundle bundle = ConstructedCEditorMessages.getResourceBundle();
+               action = new GotoNextBookmarkAction(bundle, "GotoNextBookmark.", this); //$NON-NLS-1$
+               action.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_NEXT_BOOKMARK);
+               setAction(GotoNextBookmarkAction.NEXT_BOOKMARK, action);
+
+               action = new FindWordAction(bundle, "FindWord.", this, getSourceViewer()); //$NON-NLS-1$
+               action.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_WORD);
+               setAction(FindWordAction.FIND_WORD, action);
+               markAsStateDependentAction(FindWordAction.FIND_WORD, true);
+               markAsSelectionDependentAction(FindWordAction.FIND_WORD, true);
+
+               action = new ToggleCommentAction(bundle, "ToggleComment.", this); //$NON-NLS-1$
+               action.setActionDefinitionId(ICEditorActionDefinitionIds.TOGGLE_COMMENT);
+               setAction("ToggleComment", action); //$NON-NLS-1$
+               markAsStateDependentAction("ToggleComment", true); //$NON-NLS-1$
+               configureToggleCommentAction();
+
+               action = new AddBlockCommentAction(bundle, "AddBlockComment.", this);  //$NON-NLS-1$
+               action.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_BLOCK_COMMENT);
+               setAction("AddBlockComment", action); //$NON-NLS-1$
+               markAsStateDependentAction("AddBlockComment", true); //$NON-NLS-1$
+               markAsSelectionDependentAction("AddBlockComment", true); //$NON-NLS-1$
+               //WorkbenchHelp.setHelp(action, ICHelpContextIds.ADD_BLOCK_COMMENT_ACTION);
+
+               action = new RemoveBlockCommentAction(bundle, "RemoveBlockComment.", this);  //$NON-NLS-1$
+               action.setActionDefinitionId(ICEditorActionDefinitionIds.REMOVE_BLOCK_COMMENT);
+               setAction("RemoveBlockComment", action); //$NON-NLS-1$
+               markAsStateDependentAction("RemoveBlockComment", true); //$NON-NLS-1$
+               markAsSelectionDependentAction("RemoveBlockComment", true); //$NON-NLS-1$
+               //WorkbenchHelp.setHelp(action, ICHelpContextIds.REMOVE_BLOCK_COMMENT_ACTION);
+
+               action = new IndentAction(bundle, "Indent.", this, false); //$NON-NLS-1$
+               action.setActionDefinitionId(ICEditorActionDefinitionIds.INDENT);
+               setAction("Indent", action); //$NON-NLS-1$
+               markAsStateDependentAction("Indent", true); //$NON-NLS-1$
+               markAsSelectionDependentAction("Indent", true); //$NON-NLS-1$
+//             PlatformUI.getWorkbench().getHelpSystem().setHelp(action, ICHelpContextIds.INDENT_ACTION);
+
+               action = new IndentAction(bundle, "Indent.", this, true); //$NON-NLS-1$
+               setAction("IndentOnTab", action); //$NON-NLS-1$
+               markAsStateDependentAction("IndentOnTab", true); //$NON-NLS-1$
+               markAsSelectionDependentAction("IndentOnTab", true); //$NON-NLS-1$
+
+               if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SMART_TAB)) {
+                       setActionActivationCode("IndentOnTab", '\t', -1, SWT.NONE); //$NON-NLS-1$
+               }
+
+               action = new TextOperationAction(bundle, "Format.", this, ISourceViewer.FORMAT); //$NON-NLS-1$
+               action.setActionDefinitionId(ICEditorActionDefinitionIds.FORMAT);
+               setAction("Format", action); //$NON-NLS-1$
+               markAsStateDependentAction("Format", true); //$NON-NLS-1$
+
+               action = new SortLinesAction(this);
+               action.setActionDefinitionId(ICEditorActionDefinitionIds.SORT_LINES);
+               setAction("SortLines", action); //$NON-NLS-1$
+               markAsStateDependentAction("SortLines", true); //$NON-NLS-1$
+               markAsSelectionDependentAction("SortLines", true); //$NON-NLS-1$
+
+               action = new ContentAssistAction(bundle, "ContentAssistProposal.", this); //$NON-NLS-1$
+               action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
+               setAction("ContentAssistProposal", action); //$NON-NLS-1$
+               markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$
+
+               action= new TextOperationAction(bundle, "ContentAssistContextInformation.", this, ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION); //$NON-NLS-1$
+               action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
+               setAction("ContentAssistContextInformation", action); //$NON-NLS-1$
+               markAsStateDependentAction("ContentAssistContextInformation", true); //$NON-NLS-1$
+
+        action = new TextOperationAction(bundle, "OpenOutline.", this, CSourceViewer.SHOW_OUTLINE, true); //$NON-NLS-1$
+        action.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_OUTLINE);
+        setAction("OpenOutline", action); //$NON-NLS-1$*/
+
+        action = new TextOperationAction(bundle, "OpenHierarchy.", this, CSourceViewer.SHOW_HIERARCHY, true); //$NON-NLS-1$
+        action.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_QUICK_TYPE_HIERARCHY);
+        setAction("OpenHierarchy", action); //$NON-NLS-1$*/
+
+        action = new GoToNextPreviousMemberAction(bundle, "GotoNextMember.", this, true); //$NON-NLS-1$
+        action.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_NEXT_MEMBER);
+        setAction(GoToNextPreviousMemberAction.PREVIOUS_MEMBER, action);
+
+        action = new GoToNextPreviousMemberAction(bundle, "GotoPreviousMember.", this, false); //$NON-NLS-1$
+        action.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_PREVIOUS_MEMBER);
+        setAction(GoToNextPreviousMemberAction.NEXT_MEMBER, action);
+
+        action= new ToggleSourceAndHeaderAction(bundle, "ToggleSourceHeader.", this); //$NON-NLS-1$
+        action.setActionDefinitionId(ICEditorActionDefinitionIds.TOGGLE_SOURCE_HEADER);
+        setAction("ToggleSourceHeader", action); //$NON-NLS-1$
+
+        action = new TextOperationAction(bundle, "OpenMacroExplorer.", this, CSourceViewer.SHOW_MACRO_EXPLORER, true); //$NON-NLS-1$
+        action.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_QUICK_MACRO_EXPLORER);
+        setAction("OpenMacroExplorer", action); //$NON-NLS-1$*/
+        
+        fSelectionHistory = new SelectionHistory(this);
+        
+        action = new StructureSelectEnclosingAction(bundle, this, fSelectionHistory);
+        action.setActionDefinitionId(ICEditorActionDefinitionIds.SELECT_ENCLOSING);
+        setAction(StructureSelectionAction.ENCLOSING, action);
+        
+        action = new StructureSelectNextAction(bundle, this, fSelectionHistory);
+        action.setActionDefinitionId(ICEditorActionDefinitionIds.SELECT_NEXT);
+        setAction(StructureSelectionAction.NEXT, action);
+        
+        action = new StructureSelectPreviousAction(bundle, this, fSelectionHistory);
+        action.setActionDefinitionId(ICEditorActionDefinitionIds.SELECT_PREVIOUS);
+        setAction(StructureSelectionAction.PREVIOUS, action);
+        
+        action = new StructureSelectHistoryAction(bundle, this, fSelectionHistory);
+        action.setActionDefinitionId(ICEditorActionDefinitionIds.SELECT_LAST);
+        setAction(StructureSelectionAction.HISTORY, action);
+        
+        
+        // Assorted action groupings
+               fSelectionSearchGroup = createSelectionSearchGroup();
+               fTextSearchGroup= new TextSearchGroup(this);
+               fRefactoringActionGroup= new CRefactoringActionGroup(this, ITextEditorActionConstants.GROUP_EDIT);
+               fOpenInViewGroup= createOpenViewActionGroup();
+               fGenerateActionGroup= new GenerateActionGroup(this, ITextEditorActionConstants.GROUP_EDIT);
+               fSurroundWithActionGroup = new SurroundWithActionGroup(this, ITextEditorActionConstants.GROUP_EDIT);
+               
+               action = getAction(ITextEditorActionConstants.SHIFT_RIGHT);
+               if (action != null) {
+                       action.setId(ITextEditorActionConstants.SHIFT_RIGHT);
+                       CPluginImages.setImageDescriptors(action, CPluginImages.T_LCL, CPluginImages.IMG_MENU_SHIFT_RIGHT);
+               }
+               action = getAction(ITextEditorActionConstants.SHIFT_LEFT);
+               if (action != null) {
+                       action.setId(ITextEditorActionConstants.SHIFT_LEFT);
+                       CPluginImages.setImageDescriptors(action, CPluginImages.T_LCL, CPluginImages.IMG_MENU_SHIFT_LEFT);
+               }
+       }
+
+       protected ActionGroup createSelectionSearchGroup() {
+               return new SelectionSearchGroup(this);
+       }
+       
+       protected ActionGroup createOpenViewActionGroup() {
+               return new OpenViewActionGroup(this);
+       }
+
+       /**
+        * @see org.eclipse.ui.texteditor.AbstractTextEditor#editorContextMenuAboutToShow(org.eclipse.jface.action.IMenuManager)
+        */
+       @Override
+       public void editorContextMenuAboutToShow(IMenuManager menu) {
+               // marker for contributions to the top
+               menu.add(new GroupMarker(ICommonMenuConstants.GROUP_TOP));
+               // separator for debug related actions (similar to ruler context menu)
+               menu.add(new Separator(IContextMenuConstants.GROUP_DEBUG));
+               menu.add(new GroupMarker(IContextMenuConstants.GROUP_DEBUG+".end")); //$NON-NLS-1$
+
+               super.editorContextMenuAboutToShow(menu);
+
+               // remove shift actions added by base class
+               menu.remove(ITextEditorActionConstants.SHIFT_LEFT);
+               menu.remove(ITextEditorActionConstants.SHIFT_RIGHT);
+
+               menu.insertAfter(IContextMenuConstants.GROUP_OPEN, new GroupMarker(IContextMenuConstants.GROUP_SHOW));
+
+               final boolean hasCElement= getInputCElement() != null;
+               if (hasCElement) {
+                       addAction(menu, IContextMenuConstants.GROUP_OPEN, "OpenDeclarations"); //$NON-NLS-1$
+               addAction(menu, IContextMenuConstants.GROUP_OPEN, "OpenDefinition"); //$NON-NLS-1$
+                       addAction(menu, IContextMenuConstants.GROUP_OPEN, "OpenTypeHierarchy"); //$NON-NLS-1$
+                       addAction(menu, IContextMenuConstants.GROUP_OPEN, "OpenCallHierarchy"); //$NON-NLS-1$
+
+                       addAction(menu, IContextMenuConstants.GROUP_OPEN, "OpenOutline"); //$NON-NLS-1$
+                       addAction(menu, IContextMenuConstants.GROUP_OPEN, "OpenHierarchy"); //$NON-NLS-1$
+                       addAction(menu, IContextMenuConstants.GROUP_OPEN, "OpenMacroExplorer"); //$NON-NLS-1$
+                       addAction(menu, IContextMenuConstants.GROUP_OPEN, "ToggleSourceHeader"); //$NON-NLS-1$
+               }
+
+               ActionContext context= new ActionContext(getSelectionProvider().getSelection());
+               fGenerateActionGroup.setContext(context);
+               fGenerateActionGroup.fillContextMenu(menu);
+               fGenerateActionGroup.setContext(null);
+
+               fSurroundWithActionGroup.setContext(context);
+               fSurroundWithActionGroup.fillContextMenu(menu);
+               fSurroundWithActionGroup.setContext(null);
+               
+               if (hasCElement) {
+                       fSelectionSearchGroup.fillContextMenu(menu);
+               }
+               fTextSearchGroup.fillContextMenu(menu);
+
+               if (hasCElement) {
+                       fRefactoringActionGroup.fillContextMenu(menu);
+                       fOpenInViewGroup.fillContextMenu(menu);
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.AbstractTextEditor#rulerContextMenuAboutToShow(org.eclipse.jface.action.IMenuManager)
+        */
+       @Override
+       protected void rulerContextMenuAboutToShow(IMenuManager menu) {
+               super.rulerContextMenuAboutToShow(menu);
+               IMenuManager foldingMenu= new MenuManager(CEditorMessages.CEditor_menu_folding, "projection");  //$NON-NLS-1$
+               menu.appendToGroup(ITextEditorActionConstants.GROUP_RULERS, foldingMenu);
+
+               IAction action= getAction("FoldingToggle"); //$NON-NLS-1$
+               foldingMenu.add(action);
+               action= getAction("FoldingExpandAll"); //$NON-NLS-1$
+               foldingMenu.add(action);
+               action= getAction("FoldingCollapseAll"); //$NON-NLS-1$
+               foldingMenu.add(action);
+               action= getAction("FoldingRestore"); //$NON-NLS-1$
+               foldingMenu.add(action);
+       }
+
+       /**
+     * Sets an input for the outline page.
+        * @param page Page to set the input.
+        * @param input Input to set.
+        */
+       public static void setOutlinePageInput(CContentOutlinePage page, IEditorInput input) {
+               if (page != null) {
+                       IWorkingCopyManager manager = CUIPlugin.getDefault().getWorkingCopyManager();
+                       page.setInput(manager.getWorkingCopy(input));
+               }
+       }
+
+       /**
+     * Determines if folding is enabled.
+        * @return <code>true</code> if folding is enabled, <code>false</code> otherwise.
+        */
+       boolean isFoldingEnabled() {
+               return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED);
+       }
+
+       /*
+        * @see org.eclipse.ui.part.WorkbenchPart#getOrientation()
+        * @since 4.0
+        */
+       @Override
+       public int getOrientation() {
+               // C/C++ editors are always left to right by default
+               return SWT.LEFT_TO_RIGHT;
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#createPartControl(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       public void createPartControl(Composite parent) {
+               super.createPartControl(parent);
+
+               // bug 291008 - register custom help listener
+               final IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
+               parent.addHelpListener(new HelpListener() {
+                       public void helpRequested(HelpEvent e) {
+                               IContextProvider provider = (IContextProvider) CEditor.this.getAdapter(IContextProvider.class);
+                               if (provider != null) {
+                                       IContext context = provider.getContext(CEditor.this);
+                                       if (context != null) {
+                                               helpSystem.displayHelp(context);
+                                               return;
+                                       }
+                               }
+                               helpSystem.displayHelp(ICHelpContextIds.CEDITOR_VIEW);
+                       }});
+               
+               fEditorSelectionChangedListener = new EditorSelectionChangedListener();
+               fEditorSelectionChangedListener.install(getSelectionProvider());
+
+               if (isSemanticHighlightingEnabled())
+                       installSemanticHighlighting();
+
+               IPreferenceStore preferenceStore = getPreferenceStore();
+               boolean closeBrackets = preferenceStore.getBoolean(CLOSE_BRACKETS);
+               boolean closeAngularBrackets = preferenceStore.getBoolean(CLOSE_ANGULAR_BRACKETS);
+               boolean closeStrings = preferenceStore.getBoolean(CLOSE_STRINGS);
+
+               fBracketInserter.setCloseBracketsEnabled(closeBrackets);
+               fBracketInserter.setCloseStringsEnabled(closeStrings);
+               fBracketInserter.setCloseAngularBracketsEnabled(closeAngularBrackets);
+
+               ISourceViewer sourceViewer = getSourceViewer();
+               if (sourceViewer instanceof ITextViewerExtension)
+                       ((ITextViewerExtension) sourceViewer).prependVerifyKeyListener(fBracketInserter);
+
+               if (isMarkingOccurrences())
+                       installOccurrencesFinder(false);
+               
+               if(isShowingOverrideIndicators())
+                       installOverrideIndicator(false);
+               
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#getSourceViewerDecorationSupport(org.eclipse.jface.text.source.ISourceViewer)
+        */
+       @Override
+       protected SourceViewerDecorationSupport getSourceViewerDecorationSupport(ISourceViewer viewer) {
+               if (fSourceViewerDecorationSupport == null) {
+                       fSourceViewerDecorationSupport= new CSourceViewerDecorationSupport(this, viewer, getOverviewRuler(), getAnnotationAccess(), getSharedColors());
+                       configureSourceViewerDecorationSupport(fSourceViewerDecorationSupport);
+               }
+               return fSourceViewerDecorationSupport;
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#configureSourceViewerDecorationSupport(org.eclipse.ui.texteditor.SourceViewerDecorationSupport)
+        */
+       @Override
+       protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) {
+               super.configureSourceViewerDecorationSupport(support);
+               //Enhance the stock source viewer decorator with a bracket matcher
+               support.setCharacterPairMatcher(fBracketMatcher);
+               support.setMatchingCharacterPainterPreferenceKeys(MATCHING_BRACKETS, MATCHING_BRACKETS_COLOR);
+               ((CSourceViewerDecorationSupport) support).setInactiveCodePainterPreferenceKeys(INACTIVE_CODE_ENABLE, INACTIVE_CODE_COLOR);
+       }
+
+       /**
+        * Returns the lock object for the given annotation model.
+        *
+        * @param annotationModel the annotation model
+        * @return the annotation model's lock object
+        * @since 5.0
+        */
+       private Object getLockObject(IAnnotationModel annotationModel) {
+               if (annotationModel instanceof ISynchronizable) {
+                       Object lock= ((ISynchronizable) annotationModel).getLockObject();
+                       if (lock != null)
+                               return lock;
+               }
+               return annotationModel;
+       }
+
+       /**
+        * Jumps to the matching bracket.
+        */
+       public void gotoMatchingBracket() {
+
+               ISourceViewer sourceViewer = getSourceViewer();
+               IDocument document = sourceViewer.getDocument();
+               if (document == null)
+                       return;
+
+               IRegion selection = getSignedSelection(sourceViewer);
+
+               int selectionLength = Math.abs(selection.getLength());
+               if (selectionLength > 1) {
+                       setStatusLineErrorMessage(CEditorMessages.GotoMatchingBracket_error_invalidSelection);  
+                       sourceViewer.getTextWidget().getDisplay().beep();
+                       return;
+               }
+
+               // #26314
+               int sourceCaretOffset = selection.getOffset() + selection.getLength();
+               if (isSurroundedByBrackets(document, sourceCaretOffset))
+                       sourceCaretOffset -= selection.getLength();
+
+               IRegion region = fBracketMatcher.match(document, sourceCaretOffset);
+               if (region == null) {
+                       setStatusLineErrorMessage(CEditorMessages.GotoMatchingBracket_error_noMatchingBracket); 
+                       sourceViewer.getTextWidget().getDisplay().beep();
+                       return;
+               }
+
+               int offset = region.getOffset();
+               int length = region.getLength();
+
+               if (length < 1)
+                       return;
+
+               int anchor = fBracketMatcher.getAnchor();
+               // http://dev.eclipse.org/bugs/show_bug.cgi?id=34195
+               int targetOffset = (ICharacterPairMatcher.RIGHT == anchor) ? offset + 1: offset + length;
+
+               boolean visible = false;
+               if (sourceViewer instanceof ITextViewerExtension5) {
+                       ITextViewerExtension5 extension = (ITextViewerExtension5) sourceViewer;
+                       visible = (extension.modelOffset2WidgetOffset(targetOffset) > -1);
+               } else {
+                       IRegion visibleRegion = sourceViewer.getVisibleRegion();
+                       // http://dev.eclipse.org/bugs/show_bug.cgi?id=34195
+                       visible = (targetOffset >= visibleRegion.getOffset() && targetOffset <= visibleRegion.getOffset() + visibleRegion.getLength());
+               }
+
+               if (!visible) {
+                       setStatusLineErrorMessage(CEditorMessages.GotoMatchingBracket_error_bracketOutsideSelectedElement);     
+                       sourceViewer.getTextWidget().getDisplay().beep();
+                       return;
+               }
+
+               if (selection.getLength() > 0)
+                       targetOffset -= selection.getLength();
+
+               sourceViewer.setSelectedRange(targetOffset, selection.getLength());
+               sourceViewer.revealRange(targetOffset, selection.getLength());
+       }
+
+       protected void updateStatusLine() {
+               ITextSelection selection = (ITextSelection) getSelectionProvider().getSelection();
+               Annotation annotation = getAnnotation(selection.getOffset(), selection.getLength(), fSyncProblemsViewMarker);
+               setStatusLineErrorMessage(null);
+               setStatusLineMessage(null);
+               if (annotation != null) {
+                       if (fSyncProblemsViewMarker == null) {
+                               updateMarkerViews(annotation);
+                       }
+                       if (annotation instanceof ICAnnotation && ((ICAnnotation) annotation).isProblem())
+                               setStatusLineMessage(annotation.getText());
+               }
+               fSyncProblemsViewMarker = null;
+       }
+
+       /**
+        * Returns the annotation overlapping with the given range or <code>null</code>.
+        *
+        * @param offset the region offset
+        * @param length the region length
+        * @param marker associated marker or <code>null</code> of not available
+        * @return the found annotation or <code>null</code>
+        */
+       private Annotation getAnnotation(int offset, int length, IMarker marker) {
+               IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput());
+               if (model == null)
+                       return null;
+               
+               @SuppressWarnings("rawtypes")
+               Iterator parent;
+               if (model instanceof IAnnotationModelExtension2) {
+                       parent= ((IAnnotationModelExtension2) model).getAnnotationIterator(offset, length, true, true);
+               } else {
+                       parent= model.getAnnotationIterator();
+               }
+
+               @SuppressWarnings("unchecked")
+               Iterator<Annotation> e= new CAnnotationIterator(parent, false);
+               Annotation annotation = null;
+               while (e.hasNext()) {
+                       Annotation a = e.next();
+                       if (!isNavigationTarget(a))
+                               continue;
+                       
+                       Position p = model.getPosition(a);
+                       if (p != null && p.overlapsWith(offset, length)) {
+                               if (annotation == null) {
+                                       annotation = a;
+                                       if (marker == null)
+                                               break;
+                               }
+                               if (a instanceof MarkerAnnotation) {
+                                       if (((MarkerAnnotation) a).getMarker().equals(marker)) {
+                                               annotation = a;
+                                               break;
+                                       }
+                               }
+                       }
+               }
+               
+               return annotation;
+       }
+
+       /*
+        * Get the dektop's StatusLineManager
+        */
+       @Override
+       protected IStatusLineManager getStatusLineManager() {
+               IEditorActionBarContributor contributor = getEditorSite().getActionBarContributor();
+               if (contributor instanceof EditorActionBarContributor) {
+                       return ((EditorActionBarContributor) contributor).getActionBars().getStatusLineManager();
+               }
+               return null;
+       }
+
+       /**
+        * Configures the toggle comment action
+        *
+        * @since 4.0.0
+        */
+       private void configureToggleCommentAction() {
+               IAction action = getAction("ToggleComment"); //$NON-NLS-1$
+               if (action instanceof ToggleCommentAction) {
+                       ISourceViewer sourceViewer = getSourceViewer();
+                       SourceViewerConfiguration configuration = getSourceViewerConfiguration();
+                       ((ToggleCommentAction) action).configure(sourceViewer, configuration);
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.AbstractTextEditor#createNavigationActions()
+        */
+       @Override
+       protected void createNavigationActions() {
+               super.createNavigationActions();
+
+               final StyledText textWidget = getSourceViewer().getTextWidget();
+
+               IAction action = new NavigatePreviousSubWordAction();
+               action.setActionDefinitionId(ITextEditorActionDefinitionIds.WORD_PREVIOUS);
+               setAction(ITextEditorActionDefinitionIds.WORD_PREVIOUS, action);
+               textWidget.setKeyBinding(SWT.CTRL | SWT.ARROW_LEFT, SWT.NULL);
+
+               action = new NavigateNextSubWordAction();
+               action.setActionDefinitionId(ITextEditorActionDefinitionIds.WORD_NEXT);
+               setAction(ITextEditorActionDefinitionIds.WORD_NEXT, action);
+               textWidget.setKeyBinding(SWT.CTRL | SWT.ARROW_RIGHT, SWT.NULL);
+
+               action = new SelectPreviousSubWordAction();
+               action.setActionDefinitionId(ITextEditorActionDefinitionIds.SELECT_WORD_PREVIOUS);
+               setAction(ITextEditorActionDefinitionIds.SELECT_WORD_PREVIOUS, action);
+               textWidget.setKeyBinding(SWT.CTRL | SWT.SHIFT | SWT.ARROW_LEFT, SWT.NULL);
+
+               action = new SelectNextSubWordAction();
+               action.setActionDefinitionId(ITextEditorActionDefinitionIds.SELECT_WORD_NEXT);
+               setAction(ITextEditorActionDefinitionIds.SELECT_WORD_NEXT, action);
+               textWidget.setKeyBinding(SWT.CTRL | SWT.SHIFT | SWT.ARROW_RIGHT, SWT.NULL);
+
+               action = new DeletePreviousSubWordAction();
+               action.setActionDefinitionId(ITextEditorActionDefinitionIds.DELETE_PREVIOUS_WORD);
+               setAction(ITextEditorActionDefinitionIds.DELETE_PREVIOUS_WORD, action);
+               textWidget.setKeyBinding(SWT.CTRL | SWT.BS, SWT.NULL);
+               markAsStateDependentAction(ITextEditorActionDefinitionIds.DELETE_PREVIOUS_WORD, true);
+
+               action = new DeleteNextSubWordAction();
+               action.setActionDefinitionId(ITextEditorActionDefinitionIds.DELETE_NEXT_WORD);
+               setAction(ITextEditorActionDefinitionIds.DELETE_NEXT_WORD, action);
+               textWidget.setKeyBinding(SWT.CTRL | SWT.DEL, SWT.NULL);
+               markAsStateDependentAction(ITextEditorActionDefinitionIds.DELETE_NEXT_WORD, true);
+       }
+
+       public final ISourceViewer getViewer() {
+               return getSourceViewer();
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#createSourceViewer(org.eclipse.swt.widgets.Composite, org.eclipse.jface.text.source.IVerticalRuler, int)
+        */
+       @Override
+       protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
+               IPreferenceStore store= getPreferenceStore();
+               ISourceViewer sourceViewer =
+                               new AdaptedSourceViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(), styles, store);
+
+               CSourceViewer cSourceViewer= null;
+               if (sourceViewer instanceof CSourceViewer) {
+                       cSourceViewer= (CSourceViewer) sourceViewer;
+               }
+
+               /*
+                * This is a performance optimization to reduce the computation of
+                * the text presentation triggered by {@link #setVisibleDocument(IDocument)}
+                */
+               if (cSourceViewer != null && isFoldingEnabled() && (store == null || !store.getBoolean(PreferenceConstants.EDITOR_SHOW_SEGMENTS)))
+                       cSourceViewer.prepareDelayedProjection();
+
+               ProjectionViewer projectionViewer = (ProjectionViewer) sourceViewer;
+
+               fProjectionSupport = new ProjectionSupport(projectionViewer, getAnnotationAccess(), getSharedColors());
+               fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.error"); //$NON-NLS-1$
+               fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.warning"); //$NON-NLS-1$
+               fProjectionSupport.addSummarizableAnnotationType("org.eclipse.search.results"); //$NON-NLS-1$
+               fProjectionSupport.setHoverControlCreator(new IInformationControlCreator() {
+                       public IInformationControl createInformationControl(Shell shell) {
+                               return new SourceViewerInformationControl(shell, false, getOrientation(), null);
+                       }
+               });
+               fProjectionSupport.install();
+
+               fProjectionModelUpdater = CUIPlugin.getDefault().getFoldingStructureProviderRegistry().getCurrentFoldingProvider();
+               if (fProjectionModelUpdater != null)
+                       fProjectionModelUpdater.install(this, projectionViewer);
+
+               if (isFoldingEnabled())
+                       projectionViewer.doOperation(ProjectionViewer.TOGGLE);
+
+               getSourceViewerDecorationSupport(sourceViewer);
+
+               return sourceViewer;
+       }
+
+       /** Outliner context menu Id */
+       protected String fOutlinerContextMenuId;
+
+       /**
+        * Holds the current occurrence annotations.
+        * @since 5.0
+        */
+       private Annotation[] fOccurrenceAnnotations= null;
+       /**
+        * Tells whether all occurrences of the element at the
+        * current caret location are automatically marked in
+        * this editor.
+        * @since 5.0
+        */
+       private boolean fMarkOccurrenceAnnotations;
+       /**
+        * Tells whether the occurrence annotations are sticky
+        * i.e. whether they stay even if there's no valid Java
+        * element at the current caret position.
+        * Only valid if {@link #fMarkOccurrenceAnnotations} is <code>true</code>.
+        * @since 5.0
+        */
+       private boolean fStickyOccurrenceAnnotations;
+       /**
+        * Tells whether to mark overloaded operator occurrences in this editor.
+        * Only valid if {@link #fMarkOccurrenceAnnotations} is <code>true</code>.
+        * @since 5.3
+        */
+       private boolean fMarkOverloadedOperatorOccurrences;
+       /**
+        * The selection used when forcing occurrence marking
+        * through code.
+        * @since 5.0
+        */
+       private ISelection fForcedMarkOccurrencesSelection;
+       /**
+        * The document modification stamp at the time when the last
+        * occurrence marking took place.
+        * @since 5.0
+        */
+       private long fMarkOccurrenceModificationStamp= IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP;
+       /**
+        * The region of the word under the caret used to when
+        * computing the current occurrence markings.
+        * @since 5.0
+        */
+       private IRegion fMarkOccurrenceTargetRegion;
+
+       private OccurrencesAnnotationUpdaterJob fOccurrencesAnnotationUpdaterJob;
+       private OccurrencesFinderJobCanceler fOccurrencesFinderJobCanceler;
+       private ISelectionListenerWithAST fPostSelectionListenerWithAST;
+
+       private OverrideIndicatorManager fOverrideIndicatorManager;
+
+       /**
+        * Sets the outliner's context menu ID.
+        */
+       protected void setOutlinerContextMenuId(String menuId) {
+               fOutlinerContextMenuId = menuId;
+       }
+
+       /*
+        * @see org.eclipse.ui.editors.text.TextEditor#initializeKeyBindingScopes()
+        */
+       @Override
+       protected void initializeKeyBindingScopes() {
+               setKeyBindingScopes(new String [] { "org.eclipse.cdt.ui.cEditorScope" }); //$NON-NLS-1$
+       }
+
+       /*
+        * @see AbstractTextEditor#affectsTextPresentation(PropertyChangeEvent)
+        */
+       @Override
+       protected boolean affectsTextPresentation(PropertyChangeEvent event) {
+               SourceViewerConfiguration configuration = getSourceViewerConfiguration();
+               if (configuration instanceof CSourceViewerConfiguration) {
+                       return ((CSourceViewerConfiguration) configuration).affectsTextPresentation(event);
+               }
+               return false;
+       }
+
+       /**
+        * Returns the folding action group, or <code>null</code> if there is none.
+        *
+        * @return the folding action group, or <code>null</code> if there is none
+        */
+       protected FoldingActionGroup getFoldingActionGroup() {
+               return fFoldingGroup;
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.AbstractTextEditor#performRevert()
+        */
+       @Override
+       protected void performRevert() {
+               ProjectionViewer projectionViewer = (ProjectionViewer) getSourceViewer();
+               projectionViewer.setRedraw(false);
+               try {
+
+                       boolean projectionMode = projectionViewer.isProjectionMode();
+                       if (projectionMode) {
+                               projectionViewer.disableProjection();
+                               if (fProjectionModelUpdater != null)
+                                       fProjectionModelUpdater.uninstall();
+                       }
+
+                       super.performRevert();
+
+                       if (projectionMode) {
+                               if (fProjectionModelUpdater != null)
+                                       fProjectionModelUpdater.install(this, projectionViewer);
+                               projectionViewer.enableProjection();
+                       }
+
+               } finally {
+                       projectionViewer.setRedraw(true);
+               }
+       }
+
+    /**
+     * Sets the given message as error message to this editor's status line.
+     *
+     * @param message message to be set
+     */
+    @Override
+       public void setStatusLineErrorMessage(String message) {
+               long now= System.currentTimeMillis();
+               if (message != null || now - fErrorMessageTime > ERROR_MESSAGE_TIMEOUT) {
+                       super.setStatusLineErrorMessage(message);
+                       fErrorMessageTime= message != null ? now : 0;
+               }
+    }
+
+       /**
+        * Sets the given message as message to this editor's status line.
+        *
+        * @param message message to be set
+        * @since 3.0
+        */
+       @Override
+       protected void setStatusLineMessage(String message) {
+               if (System.currentTimeMillis() - fErrorMessageTime > ERROR_MESSAGE_TIMEOUT)
+                       super.setStatusLineMessage(message);
+       }
+
+       /**
+        * Returns the signed current selection.
+        * The length will be negative if the resulting selection
+        * is right-to-left (RtoL).
+        * <p>
+        * The selection offset is model based.
+        * </p>
+        *
+        * @param sourceViewer the source viewer
+        * @return a region denoting the current signed selection, for a resulting RtoL selections length is < 0
+        */
+       protected IRegion getSignedSelection(ISourceViewer sourceViewer) {
+               StyledText text = sourceViewer.getTextWidget();
+               Point selection = text.getSelectionRange();
+
+               if (text.getCaretOffset() == selection.x) {
+                       selection.x = selection.x + selection.y;
+                       selection.y = -selection.y;
+               }
+
+               selection.x = widgetOffset2ModelOffset(sourceViewer, selection.x);
+
+               return new Region(selection.x, selection.y);
+       }
+
+       private static boolean isBracket(char character) {
+               for (int i = 0; i != BRACKETS.length; ++i) {
+                       if (character == BRACKETS[i])
+                               return true;
+               }
+               return false;
+       }
+
+       private static boolean isSurroundedByBrackets(IDocument document, int offset) {
+               if (offset == 0 || offset == document.getLength())
+                       return false;
+
+               try {
+                       return isBracket(document.getChar(offset - 1)) &&
+                                       isBracket(document.getChar(offset));
+               } catch (BadLocationException e) {
+                       return false;
+               }
+       }
+
+       private static char getEscapeCharacter(char character) {
+               switch (character) {
+                       case '"':
+                       case '\'':
+                               return '\\';
+                       default:
+                               return 0;
+               }
+       }
+
+       private static char getPeerCharacter(char character) {
+               switch (character) {
+                       case '(':
+                               return ')';
+
+                       case ')':
+                               return '(';
+
+                       case '<':
+                               return '>';
+
+                       case '>':
+                               return '<';
+
+                       case '[':
+                               return ']';
+
+                       case ']':
+                               return '[';
+
+                       case '"':
+                               return character;
+
+                       case '\'':
+                               return character;
+
+                       default:
+                               throw new IllegalArgumentException();
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#collectContextMenuPreferencePages()
+        */
+       @Override
+       protected String[] collectContextMenuPreferencePages() {
+               // Add C/C++ Editor relevant pages
+               String[] parentPrefPageIds = super.collectContextMenuPreferencePages();
+               String[] prefPageIds = new String[parentPrefPageIds.length + 13];
+               int nIds = 0;
+               prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.CEditorPreferencePage"; //$NON-NLS-1$
+               prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.CodeAssistPreferencePage"; //$NON-NLS-1$
+               prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.CodeAssistPreferenceAdvanced"; //$NON-NLS-1$
+               prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.HoverPreferencePage"; //$NON-NLS-1$
+               prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.FoldingPreferencePage"; //$NON-NLS-1$
+               prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.MarkOccurrencesPreferencePage"; //$NON-NLS-1$
+               prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.CodeColoringPreferencePage"; //$NON-NLS-1$
+               prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.TemplatePreferencePage"; //$NON-NLS-1$
+               prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.SmartTypingPreferencePage"; //$NON-NLS-1$
+               prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.CodeFormatterPreferencePage"; //$NON-NLS-1$
+               prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.CScalabilityPreferences"; //$NON-NLS-1$
+               prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.SaveActionsPreferencePage"; //$NON-NLS-1$
+               prefPageIds[nIds++] = "org.eclipse.cdt.codan.ui.preferences.CodanPreferencePage"; //$NON-NLS-1$
+               System.arraycopy(parentPrefPageIds, 0, prefPageIds, nIds, parentPrefPageIds.length);
+               return prefPageIds;
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#aboutToBeReconciled()
+        * @since 4.0
+        */
+       public void aboutToBeReconciled() {
+               fIsReconciling= true;
+
+               // Notify AST provider
+               CUIPlugin.getDefault().getASTProvider().aboutToBeReconciled(getInputCElement());
+
+               // Notify listeners
+               Object[] listeners = fReconcilingListeners.getListeners();
+               for (int i = 0, length= listeners.length; i < length; ++i) {
+                       ((ICReconcilingListener) listeners[i]).aboutToBeReconciled();
+               }
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#reconciled(IASTTranslationUnit, boolean, IProgressMonitor)
+        * @since 4.0
+        */
+       public void reconciled(IASTTranslationUnit ast, boolean force, IProgressMonitor progressMonitor) {
+               fIsReconciling= false;
+
+               CUIPlugin cuiPlugin= CUIPlugin.getDefault();
+               if (cuiPlugin == null)
+                       return;
+
+               // Always notify AST provider
+               cuiPlugin.getASTProvider().reconciled(ast, getInputCElement(), progressMonitor);
+
+               // Notify listeners
+               Object[] listeners = fReconcilingListeners.getListeners();
+               for (int i = 0, length= listeners.length; i < length; ++i) {
+                       ((ICReconcilingListener) listeners[i]).reconciled(ast, force, progressMonitor);
+               }
+       }
+
+       /**
+        * Adds the given listener.
+        * Has no effect if an identical listener was not already registered.
+        *
+        * @param listener      The reconcile listener to be added
+        * @since 4.0
+        */
+       final public void addReconcileListener(ICReconcilingListener listener) {
+               fReconcilingListeners.add(listener);
+       }
+
+       /**
+        * Removes the given listener.
+        * Has no effect if an identical listener was not already registered.
+        *
+        * @param listener      the reconcile listener to be removed
+        * @since 4.0
+        */
+       final public void removeReconcileListener(ICReconcilingListener listener) {
+               fReconcilingListeners.remove(listener);
+       }
+
+       /**
+        * @return <code>true</code> if Semantic Highlighting is enabled.
+        *
+        * @since 4.0
+        */
+       protected boolean isSemanticHighlightingEnabled() {
+               return SemanticHighlightings.isEnabled(getPreferenceStore()) && !(isEnableScalablilityMode() && getPreferenceStore().getBoolean(PreferenceConstants.SCALABILITY_SEMANTIC_HIGHLIGHT));
+       }
+
+       /**
+        * Install Semantic Highlighting.
+        *
+        * @since 4.0
+        */
+       private void installSemanticHighlighting() {
+               if (fSemanticManager == null) {
+                       fSemanticManager= new SemanticHighlightingManager();
+                       fSemanticManager.install(this, (CSourceViewer) getSourceViewer(), CUIPlugin.getDefault().getTextTools().getColorManager(), getPreferenceStore());
+               }
+       }
+
+       /**
+        * Uninstall Semantic Highlighting.
+        *
+        * @since 4.0
+        */
+       private void uninstallSemanticHighlighting() {
+               if (fSemanticManager != null) {
+                       fSemanticManager.uninstall();
+                       fSemanticManager= null;
+               }
+       }
+
+       /**
+        * Called whenever the editor is activated and allows for registering
+        * action handlers.
+        */
+       public void fillActionBars(IActionBars actionBars) {
+               fOpenInViewGroup.fillActionBars(actionBars);
+               fRefactoringActionGroup.fillActionBars(actionBars);
+               fGenerateActionGroup.fillActionBars(actionBars);
+               fFoldingGroup.updateActionBars();
+               fSurroundWithActionGroup.fillActionBars(actionBars);
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.AbstractTextEditor#updateStateDependentActions()
+        */
+       @Override
+       protected void updateStateDependentActions() {
+               super.updateStateDependentActions();
+               fGenerateActionGroup.editorStateChanged();
+       }
+
+       /**
+        * Resets the foldings structure according to the folding
+        * preferences.
+        *
+        * @since 4.0
+        */
+       public void resetProjection() {
+               if (fProjectionModelUpdater != null) {
+                       fProjectionModelUpdater.initialize();
+               }
+       }
+
+       /**
+        * Updates occurrence annotations.
+        *
+        * @since 5.0
+        */
+       class OccurrencesAnnotationUpdaterJob extends Job {
+               private final IDocument fDocument;
+               private final ISelection fSelection;
+               private final ISelectionValidator fPostSelectionValidator;
+               private boolean fCanceled;
+               private final OccurrenceLocation[] fLocations;
+
+               public OccurrencesAnnotationUpdaterJob(IDocument document, OccurrenceLocation[] locations, ISelection selection, ISelectionValidator validator) {
+                       super(CEditorMessages.CEditor_markOccurrences_job_name); 
+                       fDocument= document;
+                       fSelection= selection;
+                       fLocations= locations;
+                       fPostSelectionValidator= validator;
+               }
+
+               // cannot use cancel() because it is declared final
+               void doCancel() {
+                       fCanceled= true;
+                       cancel();
+               }
+
+               private boolean isCanceled(IProgressMonitor progressMonitor) {
+                       return fCanceled || progressMonitor.isCanceled()
+                               ||  fPostSelectionValidator != null && !(fPostSelectionValidator.isValid(fSelection) || fForcedMarkOccurrencesSelection == fSelection)
+                               || LinkedModeModel.hasInstalledModel(fDocument);
+               }
+
+               /*
+                * @see Job#run(org.eclipse.core.runtime.IProgressMonitor)
+                */
+               @Override
+               public IStatus run(IProgressMonitor progressMonitor) {
+                       if (isCanceled(progressMonitor))
+                               return Status.CANCEL_STATUS;
+
+                       ITextViewer textViewer= getViewer();
+                       if (textViewer == null)
+                               return Status.CANCEL_STATUS;
+
+                       IDocument document= textViewer.getDocument();
+                       if (document == null)
+                               return Status.CANCEL_STATUS;
+
+                       IDocumentProvider documentProvider= getDocumentProvider();
+                       if (documentProvider == null)
+                               return Status.CANCEL_STATUS;
+
+                       IAnnotationModel annotationModel= documentProvider.getAnnotationModel(getEditorInput());
+                       if (annotationModel == null)
+                               return Status.CANCEL_STATUS;
+
+                       // Add occurrence annotations
+                       int length= fLocations.length;
+                       Map<Annotation, Position> annotationMap= new HashMap<Annotation, Position>(length);
+                       for (int i= 0; i < length; i++) {
+                               if (isCanceled(progressMonitor))
+                                       return Status.CANCEL_STATUS;
+
+                               OccurrenceLocation location= fLocations[i];
+                               Position position= new Position(location.getOffset(), location.getLength());
+
+                               String description= location.getDescription();
+                               String annotationType= (location.getFlags() == IOccurrencesFinder.F_WRITE_OCCURRENCE) ? "org.eclipse.cdt.ui.occurrences.write" : "org.eclipse.cdt.ui.occurrences"; //$NON-NLS-1$ //$NON-NLS-2$
+
+                               annotationMap.put(new Annotation(annotationType, false, description), position);
+                       }
+
+                       if (isCanceled(progressMonitor))
+                               return Status.CANCEL_STATUS;
+
+                       synchronized (getLockObject(annotationModel)) {
+                               if (annotationModel instanceof IAnnotationModelExtension) {
+                                       ((IAnnotationModelExtension) annotationModel).replaceAnnotations(fOccurrenceAnnotations, annotationMap);
+                               } else {
+                                       removeOccurrenceAnnotations();
+                                       Iterator<Map.Entry<Annotation, Position>> iter= annotationMap.entrySet().iterator();
+                                       while (iter.hasNext()) {
+                                               Map.Entry<Annotation, Position> mapEntry= iter.next();
+                                               annotationModel.addAnnotation(mapEntry.getKey(), mapEntry.getValue());
+                                       }
+                               }
+                               fOccurrenceAnnotations= annotationMap.keySet().toArray(new Annotation[annotationMap.keySet().size()]);
+                       }
+
+                       return Status.OK_STATUS;
+               }
+       }
+
+       /**
+        * Cancels the occurrences finder job upon document changes.
+        *
+        * @since 5.0
+        */
+       class OccurrencesFinderJobCanceler implements IDocumentListener, ITextInputListener {
+
+               public void install() {
+                       ISourceViewer sourceViewer= getSourceViewer();
+                       if (sourceViewer == null)
+                               return;
+
+                       StyledText text= sourceViewer.getTextWidget();
+                       if (text == null || text.isDisposed())
+                               return;
+
+                       sourceViewer.addTextInputListener(this);
+
+                       IDocument document= sourceViewer.getDocument();
+                       if (document != null)
+                               document.addDocumentListener(this);
+               }
+
+               public void uninstall() {
+                       ISourceViewer sourceViewer= getSourceViewer();
+                       if (sourceViewer != null)
+                               sourceViewer.removeTextInputListener(this);
+
+                       IDocumentProvider documentProvider= getDocumentProvider();
+                       if (documentProvider != null) {
+                               IDocument document= documentProvider.getDocument(getEditorInput());
+                               if (document != null)
+                                       document.removeDocumentListener(this);
+                       }
+               }
+
+               /*
+                * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
+                */
+               public void documentAboutToBeChanged(DocumentEvent event) {
+                       if (fOccurrencesAnnotationUpdaterJob != null)
+                               fOccurrencesAnnotationUpdaterJob.doCancel();
+               }
+
+               /*
+                * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent)
+                */
+               public void documentChanged(DocumentEvent event) {
+               }
+
+               /*
+                * @see org.eclipse.jface.text.ITextInputListener#inputDocumentAboutToBeChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument)
+                */
+               public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
+                       if (oldInput == null)
+                               return;
+
+                       oldInput.removeDocumentListener(this);
+               }
+
+               /*
+                * @see org.eclipse.jface.text.ITextInputListener#inputDocumentChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument)
+                */
+               public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
+                       if (newInput == null)
+                               return;
+                       newInput.addDocumentListener(this);
+               }
+       }
+
+       /**
+        * Updates the occurrences annotations based
+        * on the current selection.
+        *
+        * @param selection the text selection
+        * @param astRoot the compilation unit AST
+        * @since 5.0
+        */
+       protected void updateOccurrenceAnnotations(ITextSelection selection, IASTTranslationUnit astRoot) {
+               if (fOccurrencesAnnotationUpdaterJob != null)
+                       fOccurrencesAnnotationUpdaterJob.cancel();
+
+               if (!fMarkOccurrenceAnnotations)
+                       return;
+
+               if (astRoot == null || selection == null)
+                       return;
+
+               IDocument document= getSourceViewer().getDocument();
+               if (document == null)
+                       return;
+
+               ISelectionValidator validator= null;
+               if (fForcedMarkOccurrencesSelection != selection && getSelectionProvider() instanceof ISelectionValidator) {
+                       validator= (ISelectionValidator) getSelectionProvider();
+                       if (!validator.isValid(selection)) {
+                               return;
+                       }
+               }
+
+               boolean hasChanged= false;
+               if (document instanceof IDocumentExtension4) {
+                       int offset= selection.getOffset();
+                       long currentModificationStamp= ((IDocumentExtension4) document).getModificationStamp();
+                       IRegion markOccurrenceTargetRegion= fMarkOccurrenceTargetRegion;
+                       hasChanged= currentModificationStamp != fMarkOccurrenceModificationStamp;
+                       if (markOccurrenceTargetRegion != null && !hasChanged) {
+                               if (markOccurrenceTargetRegion.getOffset() <= offset && offset <= markOccurrenceTargetRegion.getOffset() + markOccurrenceTargetRegion.getLength())
+                                       return;
+                       }
+                       fMarkOccurrenceTargetRegion= CWordFinder.findWord(document, offset);
+                       fMarkOccurrenceModificationStamp= currentModificationStamp;
+               }
+
+               OccurrenceLocation[] locations= null;
+
+               IASTNodeSelector selector= astRoot.getNodeSelector(null);
+               IASTName name= selector.findEnclosingName(selection.getOffset(), selection.getLength());
+               if (name == null)
+                       name = selector.findEnclosingImplicitName(selection.getOffset(), selection.getLength());
+
+               if (validator != null && !validator.isValid(selection)) {
+                       return;
+               }
+
+               if (name != null) {
+                       IBinding binding= name.resolveBinding();
+                       if (binding != null) {
+                               OccurrencesFinder occurrencesFinder= new OccurrencesFinder();
+                               if (occurrencesFinder.initialize(astRoot, name) == null) {
+                                   if (!fMarkOverloadedOperatorOccurrences) {
+                                       occurrencesFinder.setOptions(OccurrencesFinder.OPTION_EXCLUDE_IMPLICIT_REFERENCES);
+                                   }
+                                       locations= occurrencesFinder.getOccurrences();
+                               }
+                       }
+               }
+
+               if (locations == null || locations.length == 0) {
+                       if (!fStickyOccurrenceAnnotations)
+                               removeOccurrenceAnnotations();
+                       else if (hasChanged) // check consistency of current annotations
+                               removeOccurrenceAnnotations();
+                       return;
+               }
+
+               fOccurrencesAnnotationUpdaterJob= new OccurrencesAnnotationUpdaterJob(document, locations, selection, validator);
+               // we are already in a background job
+               //fOccurrencesFinderJob.setPriority(Job.DECORATE);
+               //fOccurrencesFinderJob.setSystem(true);
+               //fOccurrencesFinderJob.schedule();
+               fOccurrencesAnnotationUpdaterJob.run(new NullProgressMonitor());
+       }
+
+       protected void installOccurrencesFinder(boolean forceUpdate) {
+               fMarkOccurrenceAnnotations= true;
+
+               fPostSelectionListenerWithAST= new ISelectionListenerWithAST() {
+                       public void selectionChanged(IEditorPart part, ITextSelection selection, IASTTranslationUnit astRoot) {
+                               updateOccurrenceAnnotations(selection, astRoot);
+                       }
+               };
+               SelectionListenerWithASTManager.getDefault().addListener(this, fPostSelectionListenerWithAST);
+               if (forceUpdate && getSelectionProvider() != null) {
+                       fForcedMarkOccurrencesSelection= getSelectionProvider().getSelection();
+                       ASTProvider.getASTProvider().runOnAST(getInputCElement(), ASTProvider.WAIT_NO, getProgressMonitor(), new ASTRunnable() {
+                               public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
+                                       updateOccurrenceAnnotations((ITextSelection) fForcedMarkOccurrencesSelection, ast);
+                                       return Status.OK_STATUS;
+                               }});
+               }
+
+               if (fOccurrencesFinderJobCanceler == null) {
+                       fOccurrencesFinderJobCanceler= new OccurrencesFinderJobCanceler();
+                       fOccurrencesFinderJobCanceler.install();
+               }
+       }
+
+       protected void uninstallOccurrencesFinder() {
+               fMarkOccurrenceAnnotations= false;
+
+               if (fOccurrencesAnnotationUpdaterJob != null) {
+                       fOccurrencesAnnotationUpdaterJob.cancel();
+                       fOccurrencesAnnotationUpdaterJob= null;
+               }
+
+               if (fOccurrencesFinderJobCanceler != null) {
+                       fOccurrencesFinderJobCanceler.uninstall();
+                       fOccurrencesFinderJobCanceler= null;
+               }
+
+               if (fPostSelectionListenerWithAST != null) {
+                       SelectionListenerWithASTManager.getDefault().removeListener(this, fPostSelectionListenerWithAST);
+                       fPostSelectionListenerWithAST= null;
+               }
+
+               removeOccurrenceAnnotations();
+       }
+
+       protected boolean isMarkingOccurrences() {
+               IPreferenceStore store= getPreferenceStore();
+               return store != null && store.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
+       }
+
+       void removeOccurrenceAnnotations() {
+               fMarkOccurrenceModificationStamp= IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP;
+               fMarkOccurrenceTargetRegion= null;
+
+               IDocumentProvider documentProvider= getDocumentProvider();
+               if (documentProvider == null)
+                       return;
+
+               IAnnotationModel annotationModel= documentProvider.getAnnotationModel(getEditorInput());
+               if (annotationModel == null || fOccurrenceAnnotations == null)
+                       return;
+
+               synchronized (getLockObject(annotationModel)) {
+                       if (annotationModel instanceof IAnnotationModelExtension) {
+                               ((IAnnotationModelExtension) annotationModel).replaceAnnotations(fOccurrenceAnnotations, null);
+                       } else {
+                               for (Annotation occurrenceAnnotation : fOccurrenceAnnotations)
+                                       annotationModel.removeAnnotation(occurrenceAnnotation);
+                       }
+                       fOccurrenceAnnotations= null;
+               }
+       }
+
+       /**
+        * Creates and returns the preference store for this editor with the given input.
+        *
+        * @param input The editor input for which to create the preference store
+        * @return the preference store for this editor
+        */
+       private IPreferenceStore createCombinedPreferenceStore(IEditorInput input) {
+               List<IPreferenceStore> stores= new ArrayList<IPreferenceStore>(3);
+
+               ICProject project= EditorUtility.getCProject(input);
+               if (project != null) {
+                       stores.add(new EclipsePreferencesAdapter(new ProjectScope(project.getProject()), CCorePlugin.PLUGIN_ID));
+               }
+
+               stores.add(CUIPlugin.getDefault().getPreferenceStore());
+               stores.add(new ScopedPreferenceStore(InstanceScope.INSTANCE, CCorePlugin.PLUGIN_ID));
+               stores.add(EditorsUI.getPreferenceStore());
+
+               return new ChainedPreferenceStore(stores.toArray(new IPreferenceStore[stores.size()]));
+       }
+
+       /**
+        * @return <code>true</code> if parser based Content Assist proposals are disabled.
+        *
+        * @since 5.0
+        */
+       public boolean isParserBasedContentAssistDisabled() {
+               return getPreferenceStore().getBoolean(PreferenceConstants.SCALABILITY_PARSER_BASED_CONTENT_ASSIST);
+       }
+       
+       /**
+        * @return <code>true</code> if Content Assist auto activation is disabled.
+        *
+        * @since 5.0
+        */
+       public boolean isContentAssistAutoActivartionDisabled() {
+               return getPreferenceStore().getBoolean(PreferenceConstants.SCALABILITY_CONTENT_ASSIST_AUTO_ACTIVATION);
+       }
+       
+       /**
+        * @return <code>true</code> if the number of lines in the file exceed
+        * the line number for scalability mode in the preference.
+        *
+        * @since 5.0
+        */
+       public boolean isEnableScalablilityMode() {
+               return fEnableScalablilityMode;
+       }
+
+       @Override
+       protected boolean isPrefQuickDiffAlwaysOn() {
+               // enable only if not in scalability mode
+               // workaround for http://bugs.eclipse.org/75555
+               return super.isPrefQuickDiffAlwaysOn() && !isEnableScalablilityMode();
+       }
+       public boolean shouldProcessLocalParsingCompletions() {
+               return true;
+       }
+       
+       protected void uninstallOverrideIndicator() {
+               if (fOverrideIndicatorManager != null) {
+                       fOverrideIndicatorManager.removeAnnotations();
+                       removeReconcileListener(fOverrideIndicatorManager);
+                       fOverrideIndicatorManager= null;
+               }
+       }
+       
+       /**
+        * Determines whether the preference change encoded by the given event
+        * changes the override indication.
+        *
+        * @param event the event to be investigated
+        * @return <code>true</code> if event causes a change
+        * @since 5.3
+        */
+       protected boolean affectsOverrideIndicatorAnnotations(PropertyChangeEvent event) {
+               String key= event.getProperty();
+               AnnotationPreference preference= getAnnotationPreferenceLookup().getAnnotationPreference(OverrideIndicatorManager.ANNOTATION_TYPE);
+               if (key == null || preference == null)
+                       return false;
+
+               return key.equals(preference.getHighlightPreferenceKey())
+                       || key.equals(preference.getVerticalRulerPreferenceKey())
+                       || key.equals(preference.getOverviewRulerPreferenceKey())
+                       || key.equals(preference.getTextPreferenceKey());
+       }
+       
+       /**
+        * Returns the boolean preference for the given key.
+        *
+        * @param store the preference store
+        * @param key the preference key
+        * @return <code>true</code> if the key exists in the store and its value is <code>true</code>
+        * @since 5.3
+        */
+       private boolean getBoolean(IPreferenceStore store, String key) {
+               return key != null && store.getBoolean(key);
+       }
+       
+       /**
+        * Tells whether override indicators are shown.
+        *
+        * @return <code>true</code> if the override indicators are shown
+        * @since 5.3
+        */
+       protected boolean isShowingOverrideIndicators() {
+               AnnotationPreference preference= getAnnotationPreferenceLookup().getAnnotationPreference(OverrideIndicatorManager.ANNOTATION_TYPE);
+               IPreferenceStore store= getPreferenceStore();
+               return getBoolean(store, preference.getHighlightPreferenceKey())
+                       || getBoolean(store, preference.getVerticalRulerPreferenceKey())
+                       || getBoolean(store, preference.getOverviewRulerPreferenceKey())
+                       || getBoolean(store, preference.getTextPreferenceKey());
+       }
+       
+       protected void installOverrideIndicator(boolean provideAST) {
+               uninstallOverrideIndicator();
+               IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput());
+
+               if (model == null)
+                       return;
+
+               fOverrideIndicatorManager= new OverrideIndicatorManager(model);
+               
+               addReconcileListener(fOverrideIndicatorManager);
+
+               ICElement inputCElement = getInputCElement();
+               if (provideAST && inputCElement instanceof ITranslationUnit) {
+                       ASTProvider.getASTProvider().runOnAST(inputCElement, ASTProvider.WAIT_ACTIVE_ONLY, getProgressMonitor(), new ASTRunnable() {
+                               public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
+                                       if (ast != null)
+                                               fOverrideIndicatorManager.reconciled(ast, true, getProgressMonitor());
+                                       return Status.OK_STATUS;
+                               }});
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorActionContributor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorActionContributor.java
new file mode 100644 (file)
index 0000000..1338d9d
--- /dev/null
@@ -0,0 +1,259 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Markus Schorn (Wind River Systems)
+ *     Anton Leherbauer (Wind River Systems)
+ *     Tomasz Wesolowski
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import java.util.ResourceBundle;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.editors.text.TextEditorActionContributor;
+import org.eclipse.ui.ide.IDEActionFactory;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.ITextEditorActionConstants;
+import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
+import org.eclipse.ui.texteditor.RetargetTextEditorAction;
+
+import org.eclipse.cdt.ui.actions.CdtActionConstants;
+
+import org.eclipse.cdt.internal.ui.IContextMenuConstants;
+import org.eclipse.cdt.internal.ui.actions.StructureSelectHistoryAction;
+import org.eclipse.cdt.internal.ui.actions.StructureSelectNextAction;
+import org.eclipse.cdt.internal.ui.actions.StructureSelectPreviousAction;
+import org.eclipse.cdt.internal.ui.actions.StructureSelectionAction;
+import org.eclipse.cdt.internal.ui.actions.StructureSelectEnclosingAction;
+import org.eclipse.cdt.internal.ui.actions.FindWordAction;
+import org.eclipse.cdt.internal.ui.actions.GoToNextPreviousMemberAction;
+import org.eclipse.cdt.internal.ui.actions.GotoNextBookmarkAction;
+
+public class CEditorActionContributor extends TextEditorActionContributor {
+       
+       private RetargetTextEditorAction fContentAssist;
+       private RetargetTextEditorAction fContextInformation;
+       private TogglePresentationAction fTogglePresentation;
+       private GotoAnnotationAction fPreviousAnnotation;
+       private GotoAnnotationAction fNextAnnotation;
+       private RetargetTextEditorAction fGotoMatchingBracket;
+       private RetargetTextEditorAction fGotoNextBookmark;
+       private RetargetTextEditorAction fGotoNextMemberAction;
+       private RetargetTextEditorAction fGotoPreviousMemberAction;
+       private RetargetTextEditorAction fToggleInsertModeAction;
+       private RetargetTextEditorAction fShowOutline;
+       private RetargetTextEditorAction fToggleSourceHeader;
+       private ToggleMarkOccurrencesAction fToggleMarkOccurrencesAction;
+       private RetargetTextEditorAction fFindWord;
+       private RetargetTextEditorAction fExpandSelectionToEnclosing;
+       private RetargetTextEditorAction fExpandSelectionToNext;
+       private RetargetTextEditorAction fExpandSelectionToPrevious;
+       private RetargetTextEditorAction fExpandSelectionToHistory;
+       
+       public CEditorActionContributor() {
+               super();
+               
+               ResourceBundle bundle = ConstructedCEditorMessages.getResourceBundle();
+       
+               fContentAssist = new RetargetTextEditorAction(bundle, "ContentAssistProposal."); //$NON-NLS-1$
+               fContentAssist.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
+
+               fContextInformation = new RetargetTextEditorAction(bundle, "ContentAssistContextInformation."); //$NON-NLS-1$
+               fContextInformation.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
+
+               // actions that are "contributed" to editors, they are considered belonging to the active editor
+               fTogglePresentation= new TogglePresentationAction();
+
+               fToggleMarkOccurrencesAction= new ToggleMarkOccurrencesAction();
+
+               fPreviousAnnotation= new GotoAnnotationAction("PreviousAnnotation.", false); //$NON-NLS-1$
+               fNextAnnotation= new GotoAnnotationAction("NextAnnotation.", true); //$NON-NLS-1$
+
+               fGotoMatchingBracket= new RetargetTextEditorAction(bundle, "GotoMatchingBracket."); //$NON-NLS-1$
+               fGotoMatchingBracket.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_MATCHING_BRACKET);
+
+               fGotoNextBookmark = new RetargetTextEditorAction(bundle, "GotoNextBookmark."); //$NON-NLS-1$
+               fGotoNextBookmark.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_NEXT_BOOKMARK);
+
+               fGotoNextMemberAction= new RetargetTextEditorAction(bundle, "GotoNextMember."); //$NON-NLS-1$
+               fGotoNextMemberAction.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_NEXT_MEMBER);
+               fGotoPreviousMemberAction= new RetargetTextEditorAction(bundle, "GotoPreviousMember."); //$NON-NLS-1$
+               fGotoPreviousMemberAction.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_PREVIOUS_MEMBER);
+
+               fToggleInsertModeAction= new RetargetTextEditorAction(bundle, "ToggleInsertMode.", IAction.AS_CHECK_BOX); //$NON-NLS-1$
+               fToggleInsertModeAction.setActionDefinitionId(ITextEditorActionDefinitionIds.TOGGLE_INSERT_MODE);
+
+               fShowOutline= new RetargetTextEditorAction(bundle, "OpenOutline."); //$NON-NLS-1$
+               fShowOutline.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_OUTLINE);
+
+               fToggleSourceHeader= new RetargetTextEditorAction(bundle, "ToggleSourceHeader."); //$NON-NLS-1$
+               fToggleSourceHeader.setActionDefinitionId(ICEditorActionDefinitionIds.TOGGLE_SOURCE_HEADER);
+
+               fFindWord = new RetargetTextEditorAction(bundle, "FindWord."); //$NON-NLS-1$
+               fFindWord.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_WORD);
+               
+               fExpandSelectionToEnclosing = new RetargetTextEditorAction(bundle, StructureSelectEnclosingAction.PREFIX);
+               fExpandSelectionToEnclosing.setActionDefinitionId(ICEditorActionDefinitionIds.SELECT_ENCLOSING);
+               fExpandSelectionToNext= new RetargetTextEditorAction(bundle, StructureSelectNextAction.PREFIX);
+               fExpandSelectionToNext.setActionDefinitionId(ICEditorActionDefinitionIds.SELECT_NEXT);
+               fExpandSelectionToPrevious= new RetargetTextEditorAction(bundle, StructureSelectPreviousAction.PREFIX);
+               fExpandSelectionToPrevious.setActionDefinitionId(ICEditorActionDefinitionIds.SELECT_PREVIOUS);
+               fExpandSelectionToHistory= new RetargetTextEditorAction(bundle, StructureSelectHistoryAction.PREFIX);
+               fExpandSelectionToHistory.setActionDefinitionId(ICEditorActionDefinitionIds.SELECT_LAST);
+       }       
+
+       /*
+        * @see org.eclipse.ui.texteditor.BasicTextEditorActionContributor#contributeToMenu(org.eclipse.jface.action.IMenuManager)
+        */
+       @Override
+       public void contributeToMenu(IMenuManager menu) {
+               
+               super.contributeToMenu(menu);
+               
+               IMenuManager editMenu= menu.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
+               if (editMenu != null) { 
+                       editMenu.appendToGroup(ITextEditorActionConstants.GROUP_ASSIST, fContentAssist);
+                       editMenu.appendToGroup(ITextEditorActionConstants.GROUP_ASSIST, fContextInformation);
+
+                       editMenu.prependToGroup(IWorkbenchActionConstants.FIND_EXT, fFindWord);
+
+//                     editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, fShiftRight);
+//                     editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, fShiftLeft);
+//                     editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, fFormatter);
+//                     editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, new Separator());
+//                     editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, fAddInclude);
+//                     editMenu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, new Separator());
+
+                       editMenu.appendToGroup(IContextMenuConstants.GROUP_ADDITIONS, fToggleInsertModeAction);
+                       
+                       {
+                               MenuManager structureSelection = new MenuManager(CEditorMessages.CEditorActionContributor_ExpandSelectionMenu_label,"expandSelection"); //$NON-NLS-1$
+                               editMenu.insertAfter(ITextEditorActionConstants.SELECT_ALL, structureSelection);
+                               structureSelection.add(fExpandSelectionToEnclosing);
+                               structureSelection.add(fExpandSelectionToNext);
+                               structureSelection.add(fExpandSelectionToPrevious);
+                               structureSelection.add(fExpandSelectionToHistory);
+                       }
+               }
+               
+               IMenuManager navigateMenu= menu.findMenuUsingPath(IWorkbenchActionConstants.M_NAVIGATE);
+               if (navigateMenu != null) {
+                       navigateMenu.appendToGroup(IWorkbenchActionConstants.OPEN_EXT, fToggleSourceHeader);
+
+                       navigateMenu.appendToGroup(IWorkbenchActionConstants.SHOW_EXT, fShowOutline);
+
+                       IMenuManager gotoMenu= navigateMenu.findMenuUsingPath(IWorkbenchActionConstants.GO_TO);
+                       if (gotoMenu != null) {
+                               gotoMenu.add(new Separator("additions2"));  //$NON-NLS-1$
+                               gotoMenu.appendToGroup("additions2", fGotoPreviousMemberAction); //$NON-NLS-1$
+                               gotoMenu.appendToGroup("additions2", fGotoNextMemberAction); //$NON-NLS-1$
+                               gotoMenu.appendToGroup("additions2", fGotoMatchingBracket); //$NON-NLS-1$
+                               gotoMenu.appendToGroup("additions2", fGotoNextBookmark); //$NON-NLS-1$
+                       }
+               }
+       }
+       
+       /**
+        * @see org.eclipse.ui.part.EditorActionBarContributor#init(IActionBars)
+        */
+       @Override
+       public void init(IActionBars bars) {
+               super.init(bars);
+
+               // register actions that have a dynamic editor. 
+               bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_NEXT_ANNOTATION, fNextAnnotation);
+               bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_PREVIOUS_ANNOTATION, fPreviousAnnotation);
+               bars.setGlobalActionHandler(ITextEditorActionConstants.NEXT, fNextAnnotation);
+               bars.setGlobalActionHandler(ITextEditorActionConstants.PREVIOUS, fPreviousAnnotation);
+               bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY, fTogglePresentation);
+               bars.setGlobalActionHandler(ICEditorActionDefinitionIds.TOGGLE_MARK_OCCURRENCES, fToggleMarkOccurrencesAction);
+       }
+
+       /*
+        * @see org.eclipse.ui.editors.text.TextEditorActionContributor#setActiveEditor(org.eclipse.ui.IEditorPart)
+        */
+       @Override
+       public void setActiveEditor(IEditorPart part) {
+               
+               super.setActiveEditor(part);
+               
+               ITextEditor textEditor= null;
+               if (part instanceof ITextEditor)
+                       textEditor= (ITextEditor) part;
+               
+               fTogglePresentation.setEditor(textEditor);
+               fToggleMarkOccurrencesAction.setEditor(textEditor);
+               fPreviousAnnotation.setEditor(textEditor);
+               fNextAnnotation.setEditor(textEditor);
+
+               fContentAssist.setAction(getAction(textEditor, "ContentAssistProposal")); //$NON-NLS-1$
+               fContextInformation.setAction(getAction(textEditor, "ContentAssistContextInformation")); //$NON-NLS-1$
+
+               fGotoMatchingBracket.setAction(getAction(textEditor, GotoMatchingBracketAction.GOTO_MATCHING_BRACKET));
+               fGotoNextBookmark.setAction(getAction(textEditor, GotoNextBookmarkAction.NEXT_BOOKMARK));
+               fGotoNextMemberAction.setAction(getAction(textEditor, GoToNextPreviousMemberAction.NEXT_MEMBER));
+               fGotoPreviousMemberAction.setAction(getAction(textEditor, GoToNextPreviousMemberAction.PREVIOUS_MEMBER));
+
+               fShowOutline.setAction(getAction(textEditor, "OpenOutline")); //$NON-NLS-1$
+               fToggleSourceHeader.setAction(getAction(textEditor, "ToggleSourceHeader")); //$NON-NLS-1$
+               fToggleInsertModeAction.setAction(getAction(textEditor, ITextEditorActionConstants.TOGGLE_INSERT_MODE));
+               fFindWord.setAction(getAction(textEditor, FindWordAction.FIND_WORD));
+               
+               fExpandSelectionToEnclosing.setAction(getAction(textEditor, StructureSelectionAction.ENCLOSING));
+               fExpandSelectionToNext.setAction(getAction(textEditor, StructureSelectionAction.NEXT));
+               fExpandSelectionToPrevious.setAction(getAction(textEditor, StructureSelectionAction.PREVIOUS));
+               fExpandSelectionToHistory.setAction(getAction(textEditor, StructureSelectionAction.HISTORY));
+
+               // Source menu.
+               IActionBars bars= getActionBars();
+               bars.setGlobalActionHandler(CdtActionConstants.SHIFT_RIGHT, getAction(textEditor, "ShiftRight")); //$NON-NLS-1$
+               bars.setGlobalActionHandler(CdtActionConstants.SHIFT_LEFT, getAction(textEditor, "ShiftLeft")); //$NON-NLS-1$
+               bars.setGlobalActionHandler(CdtActionConstants.COMMENT, getAction(textEditor, "Comment")); //$NON-NLS-1$
+               bars.setGlobalActionHandler(CdtActionConstants.UNCOMMENT, getAction(textEditor, "Uncomment")); //$NON-NLS-1$
+               bars.setGlobalActionHandler(CdtActionConstants.TOGGLE_COMMENT, getAction(textEditor, "ToggleComment")); //$NON-NLS-1$
+               bars.setGlobalActionHandler(CdtActionConstants.FORMAT, getAction(textEditor, "Format")); //$NON-NLS-1$
+               bars.setGlobalActionHandler(CdtActionConstants.ADD_BLOCK_COMMENT, getAction(textEditor, "AddBlockComment")); //$NON-NLS-1$
+               bars.setGlobalActionHandler(CdtActionConstants.REMOVE_BLOCK_COMMENT, getAction(textEditor, "RemoveBlockComment")); //$NON-NLS-1$
+               bars.setGlobalActionHandler(CdtActionConstants.INDENT, getAction(textEditor, "Indent")); //$NON-NLS-1$
+               bars.setGlobalActionHandler(CdtActionConstants.ADD_INCLUDE, getAction(textEditor, "AddIncludeOnSelection")); //$NON-NLS-1$
+               bars.setGlobalActionHandler(CdtActionConstants.SORT_LINES, getAction(textEditor, "SortLines")); //$NON-NLS-1$
+
+               IAction action= getAction(textEditor, ITextEditorActionConstants.REFRESH);
+               bars.setGlobalActionHandler(ITextEditorActionConstants.REFRESH, action);
+
+               bars.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), getAction(textEditor, IDEActionFactory.ADD_TASK.getId()));
+               bars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), getAction(textEditor, IDEActionFactory.BOOKMARK.getId()));
+
+               bars.setGlobalActionHandler(IDEActionFactory.OPEN_PROJECT.getId(), getAction(textEditor, IDEActionFactory.OPEN_PROJECT.getId()));
+               bars.setGlobalActionHandler(IDEActionFactory.CLOSE_PROJECT.getId(), getAction(textEditor, IDEActionFactory.CLOSE_PROJECT.getId()));
+               bars.setGlobalActionHandler(IDEActionFactory.CLOSE_UNRELATED_PROJECTS.getId(), getAction(textEditor, IDEActionFactory.CLOSE_UNRELATED_PROJECTS.getId()));
+
+               if (part instanceof CEditor) {
+                       CEditor cEditor= (CEditor) part;
+                       cEditor.fillActionBars(bars);
+               }
+
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IEditorActionBarContributor#dispose()
+        */
+       @Override
+       public void dispose() {
+               setActiveEditor(null);
+               super.dispose();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorErrorTickUpdater.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorErrorTickUpdater.java
new file mode 100644 (file)
index 0000000..7c8e6dd
--- /dev/null
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorInput;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.util.IProblemChangedListener;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.ProblemsLabelDecorator;
+
+/**
+ * The <code>JavaEditorErrorTickUpdater</code> will register as a AnnotationModelListener
+ * on the annotation model of a Java Editor and update the title images when the annotation
+ * model changed.
+ */
+public class CEditorErrorTickUpdater implements IProblemChangedListener {
+
+       /**
+        * Provider for the editor title image. Marks external files with a folder overlay.
+        *
+        * @since 5.0
+        */
+       private static class CEditorImageProvider extends CUILabelProvider {
+               CEditorImageProvider() {
+                       super(0, CElementImageProvider.SMALL_ICONS);
+               }
+               @Override
+               protected int evaluateImageFlags(Object element) {
+                       int flags= getImageFlags();
+                       if (element instanceof ITranslationUnit) {
+                               ITranslationUnit tUnit= (ITranslationUnit) element;
+                               if (tUnit.getResource() == null) {
+                                       flags |= CElementImageProvider.OVERLAY_EXTERNAL;
+                               }
+                       }
+                       return flags;
+               }
+       }
+
+       protected CEditor fCEditor;
+       private CUILabelProvider fLabelProvider;
+
+       public CEditorErrorTickUpdater(CEditor editor) {
+               Assert.isNotNull(editor);
+               fCEditor= editor;
+               fLabelProvider=  new CEditorImageProvider();
+               fLabelProvider.addLabelDecorator(new ProblemsLabelDecorator(null));
+               CUIPlugin.getDefault().getProblemMarkerManager().addListener(this);
+       }
+
+       
+       /* (non-Javadoc)
+        * @see IProblemChangedListener#problemsChanged(IResource[], boolean)
+        */
+       public void problemsChanged(IResource[] resourcesChanged, boolean isMarkerChange) {
+               if (!isMarkerChange) {
+                       return;
+               }
+               IEditorInput input= fCEditor.getEditorInput();
+               if (input != null) { // might run async, tests needed
+                       ICElement celement= fCEditor.getInputCElement();
+                       if (celement != null) {
+                               IResource resource= celement.getResource();
+                               if (resource == null) {
+                                       return;
+                               }
+                               for (int i = 0; i < resourcesChanged.length; i++){
+                                       if (resource.equals(resourcesChanged[i])) {
+                                               updateEditorImage(celement);
+                                               return;
+                                       }
+                               }
+                       }
+               }
+       }
+                       
+       public void updateEditorImage(ICElement celement) {
+               Image titleImage= fCEditor.getTitleImage();
+               if (titleImage == null) {
+                       return;
+               }
+               Image newImage= fLabelProvider.getImage(celement);
+               if (titleImage != newImage) {
+                       postImageChange(newImage);
+               }
+       }
+       
+       private void postImageChange(final Image newImage) {
+               Shell shell= fCEditor.getEditorSite().getShell();
+               if (shell != null && !shell.isDisposed()) {
+                       shell.getDisplay().syncExec(new Runnable() {
+                               public void run() {
+                                       fCEditor.updatedTitleImage(newImage);
+                               }
+                       });
+               }
+       }
+               
+       public void dispose() {
+               fLabelProvider.dispose();
+               CUIPlugin.getDefault().getProblemMarkerManager().removeListener(this);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.java
new file mode 100644 (file)
index 0000000..9c27d36
--- /dev/null
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Tomasz Wesolowski
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import java.util.ResourceBundle;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class CEditorMessages extends NLS {
+       private static final String BUNDLE_FOR_CONSTRUCTED_KEYS=
+                       "org.eclipse.cdt.internal.ui.editor.ConstructedCEditorMessages"; //$NON-NLS-1$
+       private static ResourceBundle fgBundleForConstructedKeys= ResourceBundle.getBundle(BUNDLE_FOR_CONSTRUCTED_KEYS);
+
+       /**
+        * Returns the message bundle which contains constructed keys.
+        *
+        * @return the message bundle
+        * @since 5.1
+        */
+       public static ResourceBundle getBundleForConstructedKeys() {
+               return fgBundleForConstructedKeys;
+       }
+
+       public static String AddIncludeOnSelection_label;
+       public static String AddIncludeOnSelection_description;
+       public static String AddIncludeOnSelection_error_title;
+       public static String AddIncludeOnSelection_insertion_failed;
+       public static String AddIncludeOnSelection_help_provider_error;
+       public static String AddIncludesOperation_description;
+       public static String ShowInCView_description;
+       public static String ShowInCView_label;
+       public static String ShowInCView_tooltip;
+       public static String OpenDeclarations_description;
+       public static String OpenDeclarationsAction_dialog_title;
+       public static String OpenDeclarationsAction_selectMessage;
+       public static String OpenDeclarations_dialog_title;
+       public static String OpenDeclarations_label;
+       public static String OpenDeclarations_tooltip;
+       public static String OverrideIndicatorManager_implements;
+       public static String OverrideIndicatorManager_overrides;
+       public static String OverrideIndicatorManager_shadows;
+       public static String OverrideIndicatorManager_via;
+       public static String DefaultCEditorTextHover_html_name;
+       public static String DefaultCEditorTextHover_html_prototype;
+       public static String DefaultCEditorTextHover_html_description;
+       public static String DefaultCEditorTextHover_html_includes;
+       public static String CEditor_menu_folding;
+       public static String EditorUtility_concatModifierStrings;
+       public static String GotoMatchingBracket_label;
+       public static String GotoMatchingBracket_error_invalidSelection;
+       public static String GotoMatchingBracket_error_noMatchingBracket;
+       public static String GotoMatchingBracket_error_bracketOutsideSelectedElement;
+       public static String Scalability_message;
+       public static String Scalability_info;
+       public static String Scalability_linkToolTip;
+       public static String Scalability_reappear;
+       public static String Scalability_outlineDisabled;
+       public static String ToggleComment_error_title;
+       public static String ToggleComment_error_message;
+       public static String InactiveCodeHighlighting_job;
+       public static String Reconciling_job;
+       public static String SemanticHighlighting_job;
+       public static String SemanticHighlighting_field;
+       public static String SemanticHighlighting_staticField;
+       public static String SemanticHighlighting_staticConstField;
+       public static String SemanticHighlighting_methodDeclaration;
+       public static String SemanticHighlighting_staticMethodInvocation;
+       public static String SemanticHighlighting_localVariableDeclaration;
+       public static String SemanticHighlighting_localVariable;
+       public static String SemanticHighlighting_globalVariable;
+       public static String SemanticHighlighting_parameterVariable;
+       public static String SemanticHighlighting_method;
+       public static String SemanticHighlighting_classes;
+       public static String SemanticHighlighting_enums;
+       public static String SemanticHighlighting_enumerator;
+       public static String SemanticHighlighting_templateArguments;
+       public static String SemanticHighlighting_templateParameter;
+       public static String SemanticHighlighting_functionDeclaration;
+       public static String SemanticHighlighting_function;
+       public static String SemanticHighlighting_overloadedOperators;
+       public static String SemanticHighlighting_macroSubstitution;
+       public static String SemanticHighlighting_macroDefintion;
+       public static String SemanticHighlighting_typeDef;
+       public static String SemanticHighlighting_namespace;
+       public static String SemanticHighlighting_label;
+       public static String SemanticHighlighting_problem;
+       public static String SemanticHighlighting_externalSDK;
+       public static String CEditor_markOccurrences_job_name;
+       public static String CEditor_index_expander_job_name;
+       public static String CEditorActionContributor_ExpandSelectionMenu_label;
+
+       static {
+               NLS.initializeMessages(CEditorMessages.class.getName(), CEditorMessages.class);
+       }
+
+       // Do not instantiate
+       private CEditorMessages() {
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditorMessages.properties
new file mode 100644 (file)
index 0000000..c189c20
--- /dev/null
@@ -0,0 +1,96 @@
+#########################################
+# Copyright (c) 2005, 2011 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+#     QNX Software System
+#     Anton Leherbauer (Wind River Systems)
+#     Markus Schorn (Wind River Systems)
+#     Sergey Prigogin (Google)
+#     Tomasz Wesolowski
+#########################################
+
+AddIncludeOnSelection_label=Add Include
+AddIncludeOnSelection_description=Add include statement for selected name
+AddIncludeOnSelection_error_title=Error Adding Include
+AddIncludeOnSelection_insertion_failed=Adding include statements failed
+AddIncludeOnSelection_help_provider_error=Help provider error
+AddIncludesOperation_description=Adding include statement
+
+ShowInCView_description=Show the current resource in the C/C++ Projects view
+ShowInCView_label=Show in C/C++ Projects
+ShowInCView_tooltip=Show current resource in C/C++ Projects view
+
+OpenDeclarations_description=Open an editor on the selected element's declaration
+OpenDeclarationsAction_dialog_title=Open Declaration
+OpenDeclarationsAction_selectMessage=Select one element from the list
+OpenDeclarations_dialog_title=Open Declaration
+OpenDeclarations_label=&Open Declaration
+OpenDeclarations_tooltip=Open an editor on the selected element's declaration
+OverrideIndicatorManager_implements=Implements
+OverrideIndicatorManager_overrides=Overrides
+OverrideIndicatorManager_shadows=Shadows
+OverrideIndicatorManager_via=via
+
+DefaultCEditorTextHover_html_name=<b>Name:</b> 
+DefaultCEditorTextHover_html_prototype=<br><b>Prototype:</b> 
+DefaultCEditorTextHover_html_description=<br><b>Description:</b><br>
+DefaultCEditorTextHover_html_includes=<br><b>Header files:</b><br>
+
+CEditor_menu_folding=F&olding
+
+EditorUtility_concatModifierStrings= {0} + {1}
+
+GotoMatchingBracket_label=Go to Matching Bracket
+GotoMatchingBracket_error_invalidSelection=No bracket selected
+GotoMatchingBracket_error_noMatchingBracket=No matching bracket found
+GotoMatchingBracket_error_bracketOutsideSelectedElement=Bracket is outside selected element
+
+Scalability_message=You are opening a large file. Scalability mode has been turned on for this editor to help improve performance.\n\nDo you want to change scalability settings now?
+Scalability_info=Editor Scalability
+Scalability_linkToolTip=Open the Scalability preference page
+Scalability_reappear=Do not show this message again.
+# do not translate the href argument (org.eclipse.cdt.ui.preferences.CScalabilityPreferences)
+Scalability_outlineDisabled=Outline is disabled due to scalability mode (<a href="org.eclipse.cdt.ui.preferences.CScalabilityPreferences">options</a>).
+
+ToggleComment_error_title=Comment/Uncomment
+ToggleComment_error_message=An error occurred while commenting/uncommenting.
+
+InactiveCodeHighlighting_job= Inactive Code Highlighting
+
+Reconciling_job= Reconciling
+
+SemanticHighlighting_job= Semantic Highlighting
+SemanticHighlighting_field= Fields
+SemanticHighlighting_staticField= Static fields
+SemanticHighlighting_staticConstField= Constants
+SemanticHighlighting_methodDeclaration= Method declarations
+SemanticHighlighting_staticMethodInvocation= Static method invocations
+SemanticHighlighting_localVariableDeclaration= Local variable declarations
+SemanticHighlighting_localVariable= Local variable references
+SemanticHighlighting_globalVariable= Global variables
+SemanticHighlighting_parameterVariable= Parameter variables
+SemanticHighlighting_method= Methods
+SemanticHighlighting_classes= Classes, Structs, Unions
+SemanticHighlighting_enums= Enums
+SemanticHighlighting_enumerator= Enumerators
+SemanticHighlighting_templateArguments= Template arguments
+SemanticHighlighting_templateParameter= Template parameters
+SemanticHighlighting_functionDeclaration= Function declarations
+SemanticHighlighting_function= Functions
+SemanticHighlighting_overloadedOperators= Overloaded Operators
+SemanticHighlighting_macroSubstitution= Macro references
+SemanticHighlighting_macroDefintion= Macro definitions
+SemanticHighlighting_typeDef= Typedefs
+SemanticHighlighting_namespace= Namespaces
+SemanticHighlighting_label= Labels
+SemanticHighlighting_problem= Problems
+SemanticHighlighting_externalSDK= External SDK calls
+
+CEditor_markOccurrences_job_name= Occurrences Marker
+CEditor_index_expander_job_name= Index Expander
+CEditorActionContributor_ExpandSelectionMenu_label=E&xpand Selection To
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementHyperlink.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementHyperlink.java
new file mode 100644 (file)
index 0000000..99f1715
--- /dev/null
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+
+
+/**
+ * C element hyperlink.
+ * 
+ * @since 3.0
+ */
+public class CElementHyperlink implements IHyperlink {
+
+       private final IRegion fRegion;
+       private final IAction fOpenAction;
+
+       
+       /**
+        * Creates a new C element hyperlink.
+        */
+       public CElementHyperlink(IRegion region, IAction openAction) {
+               Assert.isNotNull(openAction);
+               Assert.isNotNull(region);
+               
+               fRegion= region;
+               fOpenAction= openAction;
+       }
+       
+       public IRegion getHyperlinkRegion() {
+               return fRegion;
+       }
+
+       public void open() {
+               fOpenAction.run();
+       }
+
+       public String getTypeLabel() {
+               return null;
+       }
+
+       public String getHyperlinkText() {
+               return Action.removeMnemonics(fOpenAction.getText());
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementHyperlinkDetector.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CElementHyperlinkDetector.java
new file mode 100644 (file)
index 0000000..fe35342
--- /dev/null
@@ -0,0 +1,222 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     IBM Corporation
+ *     Markus Schorn (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.dom.ast.IASTImageLocation;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
+import org.eclipse.cdt.core.dom.ast.IASTNodeSelector;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.model.ICLanguageKeywords;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
+import org.eclipse.cdt.internal.formatter.scanner.Scanner;
+import org.eclipse.cdt.internal.formatter.scanner.Token;
+
+import org.eclipse.cdt.internal.ui.text.CWordFinder;
+
+public class CElementHyperlinkDetector extends AbstractHyperlinkDetector {
+
+       public CElementHyperlinkDetector() {
+       }
+
+       public IHyperlink[] detectHyperlinks(final ITextViewer textViewer, final IRegion region, boolean canShowMultipleHyperlinks) {
+               ITextEditor textEditor= (ITextEditor) getAdapter(ITextEditor.class);
+               if (region == null || !(textEditor instanceof CEditor))
+                       return null;
+
+               final IAction openAction= textEditor.getAction("OpenDeclarations"); //$NON-NLS-1$
+               if (openAction == null)
+                       return null;
+
+               IDocument document = textViewer.getDocument();
+               final IWorkingCopy workingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(textEditor.getEditorInput());
+               if (workingCopy == null) {
+                       return null;
+               }
+
+               final IRegion[] hyperlinkRegion = { null };
+               // Do not wait for AST if it's not available yet. Waiting for AST would block the UI thread
+               // for the duration of the parsing.
+               IStatus status= ASTProvider.getASTProvider().runOnAST(workingCopy, ASTProvider.WAIT_NO, null, new ASTRunnable() {
+                       public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
+                               if (ast == null)
+                                       return Status.CANCEL_STATUS;
+                               final int offset= region.getOffset();
+                               final int length= Math.max(1, region.getLength());
+                               final IASTNodeSelector nodeSelector= ast.getNodeSelector(null);
+                               IASTNode linkASTNode = null;
+                               IASTNodeLocation linkLocation = null;
+                               
+                               IASTName selectedName= nodeSelector.findEnclosingName(offset, length);
+                               if (selectedName != null) { // found a name
+                                       // Prefer include statement over the include name
+                                       if (selectedName.getParent() instanceof IASTPreprocessorIncludeStatement) {
+                                               linkASTNode = selectedName.getParent();
+                                       } else {
+                                               linkASTNode = selectedName;
+                                       }
+                               } else { 
+                                       final IASTNode implicit = nodeSelector.findEnclosingImplicitName(offset, length);
+                                       if (implicit != null) {
+                                               linkASTNode = implicit;
+                                       } else {
+                                               // Search for include statement
+                                               final IASTNode cand= nodeSelector.findEnclosingNode(offset, length);
+                                               if (cand instanceof IASTPreprocessorIncludeStatement) {
+                                                       linkASTNode = cand;
+                                               }
+                                       }
+                               }
+                               
+                               if (linkASTNode != null) {
+                                       if (linkASTNode instanceof IASTName) {
+                                               IASTName astName = (IASTName) linkASTNode;
+                                               IASTImageLocation imageLocation = astName.getImageLocation();
+                                               if (imageLocation != null) {
+                                                       linkLocation = imageLocation;
+                                               }
+                                       }
+                                       if (linkLocation == null) {
+                                               linkLocation = linkASTNode.getFileLocation();
+                                       }
+                               }
+                               
+                               if (linkLocation == null) {
+                                       // Consider a fallback way of finding the hyperlink
+                                       // (see http://bugs.eclipse.org/bugs/show_bug.cgi?id=333050).
+                                       return Status.CANCEL_STATUS;
+                               }
+
+                               hyperlinkRegion[0] = new Region(linkLocation.getNodeOffset(), linkLocation.getNodeLength());
+                               return Status.OK_STATUS;
+                       }
+               });
+
+               if (status == Status.CANCEL_STATUS) {
+                       // AST was not available yet or didn't help us to find the hyperlink, try to compute
+                       // the hyperlink without it.  
+                       try {
+                               // Check partition type.
+                               String partitionType= TextUtilities.getContentType(document, ICPartitions.C_PARTITIONING, region.getOffset(), false);
+                               if (IDocument.DEFAULT_CONTENT_TYPE.equals(partitionType)) {
+                                       // Regular code.
+                                       hyperlinkRegion[0] = getIdentifier(document, region.getOffset(), workingCopy.getLanguage());
+                               } else if (ICPartitions.C_PREPROCESSOR.equals(partitionType)) {
+                                       // Preprocessor directive.
+                                       Scanner scanner= new Scanner();
+                                       scanner.setSplitPreprocessor(true);
+                           scanner.setSource(document.get().toCharArray());
+                           scanner.setCurrentPosition(findPreprocessorDirectiveStart(document, region.getOffset()));
+                           Token token = scanner.nextToken();
+                           if (token.getType() == Token.tPREPROCESSOR_INCLUDE) {
+                               int endPos = token.getOffset() + token.getLength();
+                               // Trim trailing whitespace.
+                               while (Character.isWhitespace(document.getChar(--endPos))) {
+                               }
+                               endPos++;
+                                   if (region.getOffset() <= endPos) {
+                                       hyperlinkRegion[0] = new Region(token.getOffset(), endPos - token.getOffset());
+                                   }
+                           } else {
+                                               hyperlinkRegion[0] = getIdentifier(document, region.getOffset(), workingCopy.getLanguage());
+                           }
+                               }
+                       } catch (BadLocationException e) {
+                               // Ignore to return null.
+                       } catch (CoreException e) {
+                               // Ignore to return null.
+                       }
+               }
+               if (hyperlinkRegion[0] == null)
+                       return null;
+               return new IHyperlink[] { new CElementHyperlink(hyperlinkRegion[0], openAction) };
+       }
+
+       /**
+        * Returns the identifier at the given offset, or {@code null} if the there is no identifier
+        * at the offset.
+        */
+       private static IRegion getIdentifier(IDocument document, int offset, ILanguage language) throws BadLocationException {
+               IRegion wordRegion= CWordFinder.findWord(document, offset);
+               if (wordRegion != null && wordRegion.getLength() > 0) {
+                       String word = document.get(wordRegion.getOffset(), wordRegion.getLength());
+                       if (!Character.isDigit(word.charAt(0)) && !isLanguageKeyword(language, word)) {
+                               return wordRegion;
+                       }
+               }
+               return null;
+       }
+
+       private static boolean isLanguageKeyword(ILanguage lang, String word) {
+               ICLanguageKeywords keywords= (ICLanguageKeywords) lang.getAdapter(ICLanguageKeywords.class);
+               if (keywords != null) {
+                       for (String keyword : keywords.getKeywords()) {
+                               if (keyword.equals(word))
+                                       return true;
+                       }
+                       for (String type : keywords.getBuiltinTypes()) {
+                               if (type.equals(word))
+                                       return true;
+                       }
+                       for (String keyword : keywords.getPreprocessorKeywords()) {
+                               if (keyword.charAt(0) == '#' && keyword.length() == word.length() + 1 &&
+                                               keyword.regionMatches(1, word, 0, word.length())) {
+                                       return true;
+                               }
+                       }
+               }
+               return false;
+       }
+
+       /**
+        * Finds beginning of a preprocessor directive.
+        */
+       private static int findPreprocessorDirectiveStart(IDocument document, int offset) throws BadLocationException {
+               while (true) {
+                       IRegion lineRegion = document.getLineInformationOfOffset(offset);
+                       int lineOffset = lineRegion.getOffset();
+                       if (lineOffset == 0)
+                               return lineOffset;
+                       int lineEnd = lineOffset + lineRegion.getLength();
+                       for (offset = lineOffset; offset < lineEnd && Character.isWhitespace(document.getChar(offset)); offset++) {
+                       }
+                       if (offset < document.getLength() && document.getChar(offset) == '#') {
+                               return lineOffset;
+                       }
+                       // The line doesn't start with #, try previous line.
+                       offset = lineOffset - 1;
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CMarkerAnnotation.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CMarkerAnnotation.java
new file mode 100644 (file)
index 0000000..76b4262
--- /dev/null
@@ -0,0 +1,180 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.ui.texteditor.MarkerAnnotation;
+import org.eclipse.ui.texteditor.MarkerUtilities;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICModelMarker;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+
+public class CMarkerAnnotation extends MarkerAnnotation implements IProblemAnnotation, ICAnnotation {          
+
+       public static final String C_MARKER_TYPE_PREFIX= "org.eclipse.cdt"; //$NON-NLS-1$
+       public static final String ERROR_ANNOTATION_TYPE= "org.eclipse.cdt.ui.error"; //$NON-NLS-1$
+       public static final String WARNING_ANNOTATION_TYPE= "org.eclipse.cdt.ui.warning"; //$NON-NLS-1$
+       public static final String INFO_ANNOTATION_TYPE= "org.eclipse.cdt.ui.info"; //$NON-NLS-1$
+       public static final String TASK_ANNOTATION_TYPE= "org.eclipse.ui.workbench.texteditor.task"; //$NON-NLS-1$
+
+       private boolean fIsProblemMarker;
+
+       private ICAnnotation fOverlay;
+
+       public CMarkerAnnotation(IMarker marker) {
+               super(marker);
+               fIsProblemMarker = MarkerUtilities.isMarkerType(getMarker(), IMarker.PROBLEM); 
+       }
+
+       /**
+        * @see IProblemAnnotation#getMessage()
+        */
+       public String getMessage() {
+               if (fIsProblemMarker)
+                       return getMarker().getAttribute(IMarker.MESSAGE, ""); //$NON-NLS-1$
+               return ""; //$NON-NLS-1$
+       }
+
+       /**
+        * @see IProblemAnnotation#isError()
+        */
+       public boolean isError() {
+               if (fIsProblemMarker) {
+                       int markerSeverity= getMarker().getAttribute(IMarker.SEVERITY, -1);
+                       return (markerSeverity == IMarker.SEVERITY_ERROR);
+               }
+               return false;
+       }
+
+       /**
+        * @see IProblemAnnotation#isWarning()
+        */
+       public boolean isWarning() {
+               if (fIsProblemMarker) {
+                       int markerSeverity= getMarker().getAttribute(IMarker.SEVERITY, -1);
+                       return (markerSeverity == IMarker.SEVERITY_WARNING);
+               }
+               return false;
+       }
+       
+       /**
+        * @see IProblemAnnotation#isTemporaryProblem()
+        */
+       public boolean isTemporaryProblem() {
+               return false;
+       }
+       
+       /**
+        * @see IProblemAnnotation#getArguments()
+        */
+       public String[] getArguments() {
+               String [] s = {"problem", "here"}; //$NON-NLS-1$ //$NON-NLS-2$
+               //if (fIsProblemMarker)
+               //      return Util.getProblemArgumentsFromMarker(getMarker().getAttribute(CCorePlugin.C_PROBLEMMARKER));
+               return s;
+               //returnm null;
+       }
+
+       /**
+        * @see IProblemAnnotation#getId()
+        */
+       public int getId() {
+               if (fIsProblemMarker)
+                       return getMarker().getAttribute(ICModelMarker.C_MODEL_PROBLEM_MARKER, -1);
+               return 0;
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.editor.IProblemAnnotation#isProblem()
+        */
+       public boolean isProblem() {
+               return fIsProblemMarker;
+       }
+       
+       /**
+        * Overlays this annotation with the given cAnnotation.
+        * 
+        * @param cAnnotation annotation that is overlaid by this annotation
+        */
+       public void setOverlay(ICAnnotation cAnnotation) {
+               if (fOverlay != null)
+                       fOverlay.removeOverlaid(this);
+                       
+               fOverlay= cAnnotation;
+               if (!isMarkedDeleted())
+                       markDeleted(fOverlay != null);
+               
+               if (fOverlay != null)
+                       fOverlay.addOverlaid(this);
+       }
+
+       /*
+        * @see ICAnnotation#hasOverlay()
+        */
+       public boolean hasOverlay() {
+               return fOverlay != null;
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.editor.ICAnnotation#getOverlay()
+        */
+       public ICAnnotation getOverlay() {
+               return fOverlay;
+       }
+       
+       /*
+        * @see ICAnnotation#addOverlaid(ICAnnotation)
+        */
+       public void addOverlaid(ICAnnotation annotation) {
+               // not supported
+       }
+
+       /*
+        * @see ICAnnotation#removeOverlaid(ICAnnotation)
+        */
+       public void removeOverlaid(ICAnnotation annotation) {
+               // not supported
+       }
+       
+       /*
+        * @see ICAnnotation#getOverlaidIterator()
+        */
+       public Iterator<ICAnnotation> getOverlaidIterator() {
+               // not supported
+               return null;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jdt.internal.ui.javaeditor.IJavaAnnotation#getCompilationUnit()
+        */
+       public ITranslationUnit getTranslationUnit() {
+               ICElement element= CoreModel.getDefault().create(getMarker().getResource());
+               if (element instanceof ITranslationUnit) {
+                       return (ITranslationUnit)element;
+               }
+               return null;
+       }
+
+       public String getMarkerType() {
+               IMarker marker= getMarker();
+               if (marker == null || !marker.exists())
+                       return null;
+               
+               return MarkerUtilities.getMarkerType(getMarker());
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSourceViewer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSourceViewer.java
new file mode 100644 (file)
index 0000000..4997c8d
--- /dev/null
@@ -0,0 +1,622 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Sergey Prigogin, Google
+ *     Anton Leherbauer (Wind River Systems)
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DocumentRewriteSession;
+import org.eclipse.jface.text.DocumentRewriteSessionType;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentExtension4;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextPresentationListener;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TextViewer;
+import org.eclipse.jface.text.contentassist.IContentAssistant;
+import org.eclipse.jface.text.information.IInformationPresenter;
+import org.eclipse.jface.text.source.IOverviewRuler;
+import org.eclipse.jface.text.source.IVerticalRuler;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
+import org.eclipse.jface.text.source.projection.ProjectionViewer;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyleRange;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
+import org.eclipse.ui.texteditor.AbstractTextEditor;
+
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.CSourceViewerConfiguration;
+
+
+/**
+ * Source viewer for C/C++ et al.
+ */
+public class CSourceViewer extends ProjectionViewer implements IPropertyChangeListener {
+
+    /** Show outline operation id. */
+    public static final int SHOW_OUTLINE= 101;
+    /** Show type hierarchy operation id. */
+    public static final int SHOW_HIERARCHY= 102;
+    /** Show macro explorer operation id. */
+    public static final int SHOW_MACRO_EXPLORER= 103;
+    
+    /** Presents outline. */
+    private IInformationPresenter fOutlinePresenter;
+    /** Presents type hierarchy. */
+    private IInformationPresenter fHierarchyPresenter;
+    /** Presents macro explorer. */
+    private IInformationPresenter fMacroExplorationPresenter;
+
+       /**
+        * This viewer's foreground color.
+        * @since 4.0
+        */
+       private Color fForegroundColor;
+       /**
+        * The viewer's background color.
+        * @since 4.0
+        */
+       private Color fBackgroundColor;
+       /**
+        * This viewer's selection foreground color.
+        * @since 4.0
+        */
+       private Color fSelectionForegroundColor;
+       /**
+        * The viewer's selection background color.
+        * @since 4.0
+        */
+       private Color fSelectionBackgroundColor;
+       /**
+        * The preference store.
+        *
+        * @since 4.0
+        */
+       private IPreferenceStore fPreferenceStore;
+       /**
+        * Is this source viewer configured?
+        *
+        * @since 4.0
+        */
+       private boolean fIsConfigured;
+
+       /**
+        * Whether to delay setting the visual document until the projection has been computed.
+        * <p>
+        * Added for performance optimization.
+        * </p>
+        * @see #prepareDelayedProjection()
+        * @since 4.0
+        */
+       private boolean fIsSetVisibleDocumentDelayed;
+       /**
+        * Whether projection mode was enabled when switching to segmented mode.
+        * Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=195808
+        */
+       private boolean fWasProjectionMode;
+       
+       /**
+        * The configured indent width.
+        */
+       private int fIndentWidth= 4;
+       /**
+        * Flag indicating whether to use spaces exclusively for indentation.
+        */
+       private boolean fUseSpaces;
+
+       /**
+     * Creates new source viewer. 
+     * @param parent
+        * @param ruler
+        * @param overviewRuler
+        * @param isOverviewRulerShowing
+        * @param styles
+        * @param store
+        */
+    public CSourceViewer(
+               Composite parent,
+               IVerticalRuler ruler,
+               IOverviewRuler overviewRuler,
+               boolean isOverviewRulerShowing,
+               int styles,
+               IPreferenceStore store) {
+               super(parent, ruler, overviewRuler, isOverviewRulerShowing, styles);
+        setPreferenceStore(store);
+       }
+    
+       public IContentAssistant getContentAssistant() {
+               return fContentAssistant;
+       }
+       
+       /*
+        * @see ISourceViewer#configure(SourceViewerConfiguration)
+        */
+       @Override
+       public void configure(SourceViewerConfiguration configuration) {
+               // Prevent access to colors disposed in unconfigure().
+               StyledText textWidget= getTextWidget();
+               if (textWidget != null && !textWidget.isDisposed()) {
+                       Color foregroundColor= textWidget.getForeground();
+                       if (foregroundColor != null && foregroundColor.isDisposed())
+                               textWidget.setForeground(null);
+                       Color backgroundColor= textWidget.getBackground();
+                       if (backgroundColor != null && backgroundColor.isDisposed())
+                               textWidget.setBackground(null);
+               }
+
+               if (configuration instanceof CSourceViewerConfiguration) {
+                       CSourceViewerConfiguration cConfiguration= (CSourceViewerConfiguration)configuration;
+                       cConfiguration.resetScanners();
+               }
+               
+               super.configure(configuration);
+
+               if (configuration instanceof CSourceViewerConfiguration) {
+                       CSourceViewerConfiguration cConfiguration= (CSourceViewerConfiguration)configuration;
+                       fOutlinePresenter= cConfiguration.getOutlinePresenter(this);
+                       if (fOutlinePresenter != null)
+                               fOutlinePresenter.install(this);
+                       fHierarchyPresenter= cConfiguration.getHierarchyPresenter(this);
+                       if (fHierarchyPresenter != null) 
+                               fHierarchyPresenter.install(this);
+                       fMacroExplorationPresenter= cConfiguration.getMacroExplorationPresenter(this);
+                       if (fMacroExplorationPresenter != null) {
+                               fMacroExplorationPresenter.install(this);
+                       }
+                       String[] defaultIndentPrefixes= (String[])fIndentChars.get(IDocument.DEFAULT_CONTENT_TYPE);
+                       if (defaultIndentPrefixes != null && defaultIndentPrefixes.length > 0) {
+                               final int indentWidth= cConfiguration.getIndentWidth(this);
+                               final boolean useSpaces= cConfiguration.useSpacesOnly(this);
+                               configureIndentation(indentWidth, useSpaces);
+                       }
+               }
+               if (fPreferenceStore != null) {
+                       fPreferenceStore.addPropertyChangeListener(this);
+                       initializeViewerColors();
+                       // init flag here in case we start in segmented mode
+                       fWasProjectionMode= fPreferenceStore.getBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED);
+               }
+
+               fIsConfigured= true;
+       }
+
+       protected void initializeViewerColors() {
+               if (fPreferenceStore != null) {
+
+                       StyledText styledText= getTextWidget();
+
+                       // ----------- foreground color --------------------
+                       Color color= fPreferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT)
+                               ? null
+                               : createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, styledText.getDisplay());
+                       styledText.setForeground(color);
+
+                       if (fForegroundColor != null)
+                               fForegroundColor.dispose();
+
+                       fForegroundColor= color;
+
+                       // ---------- background color ----------------------
+                       color= fPreferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)
+                               ? null
+                               : createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, styledText.getDisplay());
+                       styledText.setBackground(color);
+
+                       if (fBackgroundColor != null)
+                               fBackgroundColor.dispose();
+
+                       fBackgroundColor= color;
+
+                       // ----------- selection foreground color --------------------
+                       color= fPreferenceStore.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR)
+                               ? null
+                               : createColor(fPreferenceStore, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR, styledText.getDisplay());
+                       styledText.setSelectionForeground(color);
+
+                       if (fSelectionForegroundColor != null)
+                               fSelectionForegroundColor.dispose();
+
+                       fSelectionForegroundColor= color;
+
+                       // ---------- selection background color ----------------------
+                       color= fPreferenceStore.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR)
+                               ? null
+                               : createColor(fPreferenceStore, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR, styledText.getDisplay());
+                       styledText.setSelectionBackground(color);
+
+                       if (fSelectionBackgroundColor != null)
+                               fSelectionBackgroundColor.dispose();
+
+                       fSelectionBackgroundColor= color;
+               }
+    }
+
+    /**
+     * Creates a color from the information stored in the given preference store.
+     * Returns <code>null</code> if there is no such information available.
+     *
+     * @param store the store to read from
+     * @param key the key used for the lookup in the preference store
+     * @param display the display used create the color
+     * @return the created color according to the specification in the preference store
+     */
+    private Color createColor(IPreferenceStore store, String key, Display display) {
+
+        RGB rgb= null;
+
+        if (store.contains(key)) {
+
+            if (store.isDefault(key))
+                rgb= PreferenceConverter.getDefaultColor(store, key);
+            else
+                rgb= PreferenceConverter.getColor(store, key);
+
+            if (rgb != null)
+                return new Color(display, rgb);
+        }
+
+        return null;
+    }
+
+    /*
+     * @see org.eclipse.jface.text.source.SourceViewer#unconfigure()
+     */
+    @Override
+       public void unconfigure() {
+        if (fOutlinePresenter != null) {
+            fOutlinePresenter.uninstall();  
+            fOutlinePresenter= null;
+        }
+        if (fHierarchyPresenter != null) {
+               fHierarchyPresenter.uninstall();  
+               fHierarchyPresenter= null;
+        }
+        if (fMacroExplorationPresenter != null) {
+               fMacroExplorationPresenter.uninstall();  
+               fMacroExplorationPresenter= null;
+        }
+               if (fForegroundColor != null) {
+                       fForegroundColor.dispose();
+                       fForegroundColor= null;
+               }
+               if (fBackgroundColor != null) {
+                       fBackgroundColor.dispose();
+                       fBackgroundColor= null;
+               }
+
+               if (fPreferenceStore != null)
+                       fPreferenceStore.removePropertyChangeListener(this);
+
+       super.unconfigure();
+
+               fIsConfigured= false;
+    }
+
+       /*
+        * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+        */
+       public void propertyChange(PropertyChangeEvent event) {
+               String property= event.getProperty();
+               if (AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND.equals(property)
+                               || AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT.equals(property)
+                               || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND.equals(property)
+                               || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property)
+                               || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR.equals(property)
+                               || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR.equals(property)
+                               || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR.equals(property)
+                               || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR.equals(property))
+               {
+                       initializeViewerColors();
+               }
+       }
+
+       /**
+        * Sets the preference store on this viewer.
+        *
+        * @param store the preference store
+        *
+        * @since 4.0
+        */
+       public void setPreferenceStore(IPreferenceStore store) {
+               if (fIsConfigured && fPreferenceStore != null)
+                       fPreferenceStore.removePropertyChangeListener(this);
+
+               fPreferenceStore= store;
+
+               if (fIsConfigured && fPreferenceStore != null) {
+                       fPreferenceStore.addPropertyChangeListener(this);
+                       initializeViewerColors();
+               }
+       }
+
+       /*
+        * @see org.eclipse.jface.text.source.SourceViewer#createControl(org.eclipse.swt.widgets.Composite, int)
+        */
+       @Override
+       protected void createControl(Composite parent, int styles) {
+
+               // Use LEFT_TO_RIGHT unless otherwise specified.
+               if ((styles & SWT.RIGHT_TO_LEFT) == 0 && (styles & SWT.LEFT_TO_RIGHT) == 0)
+                       styles |= SWT.LEFT_TO_RIGHT;
+                       
+               super.createControl(parent, styles);
+       }
+
+       /*
+     * @see org.eclipse.jface.text.ITextOperationTarget#doOperation(int)
+        */
+    @Override
+       public void doOperation(int operation) {
+
+               if (getTextWidget() == null) {
+                       return;
+               }
+               switch (operation) {
+            case SHOW_OUTLINE:
+                fOutlinePresenter.showInformation();
+                return;
+            case SHOW_HIERARCHY:
+               fHierarchyPresenter.showInformation();
+               return;
+            case SHOW_MACRO_EXPLORER:
+               fMacroExplorationPresenter.showInformation();
+               }
+               super.doOperation(operation);
+       }
+
+    /*
+     * @see org.eclipse.jface.text.source.projection.ProjectionViewer#canDoOperation(int)
+     */
+    @Override
+       public boolean canDoOperation(int operation) {
+               switch (operation) {
+        case SHOW_OUTLINE:
+            return fOutlinePresenter != null;
+        case SHOW_HIERARCHY:
+               return fHierarchyPresenter != null;
+        case SHOW_MACRO_EXPLORER:
+               return fMacroExplorationPresenter != null;
+               }
+        return super.canDoOperation(operation);
+    }
+
+       /**
+        * Prepend given listener to the list of presentation listeners
+        * 
+        * @param listener  The listener to be added.
+        * 
+        * @see TextViewer#addTextPresentationListener(ITextPresentationListener)
+        * @since 4.0
+        */
+       public void prependTextPresentationListener(ITextPresentationListener listener) {
+               Assert.isNotNull(listener);
+
+               @SuppressWarnings("unchecked") // using list from base class
+               List<ITextPresentationListener> textPresentationListeners= fTextPresentationListeners;
+               
+               if (textPresentationListeners == null) 
+                       fTextPresentationListeners= textPresentationListeners= new ArrayList<ITextPresentationListener>();
+
+               textPresentationListeners.remove(listener);
+               textPresentationListeners.add(0, listener);
+       }
+
+       /**
+        * Delays setting the visual document until after the projection has been computed.
+        * This method must only be called before the document is set on the viewer.
+        * <p>
+        * This is a performance optimization to reduce the computation of
+        * the text presentation triggered by <code>setVisibleDocument(IDocument)</code>.
+        * </p>
+        * 
+        * @see #setVisibleDocument(IDocument)
+        * @since 4.0
+        */
+       void prepareDelayedProjection() {
+               Assert.isTrue(!fIsSetVisibleDocumentDelayed);
+               fIsSetVisibleDocumentDelayed= true;
+       }
+       
+       /**
+        * {@inheritDoc}
+        * <p>
+        * This is a performance optimization to reduce the computation of
+        * the text presentation triggered by {@link #setVisibleDocument(IDocument)}
+        * </p>
+        * @since 4.0
+        */
+       @Override
+       protected void setVisibleDocument(IDocument document) {
+               if (fIsSetVisibleDocumentDelayed) {
+                       fIsSetVisibleDocumentDelayed= false;
+                       IDocument previous= getVisibleDocument();
+                       enableProjection(); // will set the visible document if anything is folded
+                       IDocument current= getVisibleDocument();
+                       // if the visible document was not replaced, continue as usual
+                       if (current != null && current != previous)
+                               return;
+               }
+               
+               super.setVisibleDocument(document);
+       }
+
+       /**
+        * {@inheritDoc}
+        * <p>
+        * Performance optimization: since we know at this place
+        * that none of the clients expects the given range to be
+        * untouched we reuse the given range as return value.
+        * </p>
+        */
+       @Override
+       protected StyleRange modelStyleRange2WidgetStyleRange(StyleRange range) {
+               IRegion region= modelRange2WidgetRange(new Region(range.start, range.length));
+               if (region != null) {
+                       // don't clone the style range, but simply reuse it.
+                       range.start= region.getOffset();
+                       range.length= region.getLength();
+                       return range;
+               }
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.source.projection.ProjectionViewer#setVisibleRegion(int, int)
+        */
+       @Override
+       public void setVisibleRegion(int start, int length) {
+               // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=195808
+               if (!fWasProjectionMode && isProjectionMode()) {
+                       fWasProjectionMode= true;
+               }
+               super.setVisibleRegion(start, length);
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.source.projection.ProjectionViewer#resetVisibleRegion()
+        */
+       @Override
+       public void resetVisibleRegion() {
+               super.resetVisibleRegion();
+               // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=195808
+               if (fWasProjectionMode) {
+                       fWasProjectionMode= false;
+                       enableProjection();
+               }
+       }
+
+
+       /**
+        * Configure the indentation mode for this viewer.
+        * 
+        * @param indentWidth  the indentation width
+        * @param useSpaces  if <code>true</code>, only spaces are used for indentation
+        */
+       public void configureIndentation(int indentWidth, boolean useSpaces) {
+               fIndentWidth= indentWidth;
+               fUseSpaces= useSpaces;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.TextViewer#shift(boolean, boolean, boolean)
+        */
+       @Override
+       protected void shift(boolean useDefaultPrefixes, boolean right, boolean ignoreWhitespace) {
+               if (!useDefaultPrefixes) {
+                       // simple shift case
+                       adjustIndent(right, fIndentWidth, fUseSpaces);
+                       return;
+               }
+               super.shift(useDefaultPrefixes, right, ignoreWhitespace);
+       }
+
+       /**
+        * Increase/decrease indentation of current selection.
+        * 
+        * @param increase  if <code>true</code>, indent is increased by one unit
+        * @param shiftWidth  width in spaces of one indent unit
+        * @param useSpaces  if <code>true</code>, only spaces are used for indentation
+        */
+       protected void adjustIndent(boolean increase, int shiftWidth, boolean useSpaces) {
+               if (fUndoManager != null) {
+                       fUndoManager.beginCompoundChange();
+               }
+               IDocument d= getDocument();
+               DocumentRewriteSession rewriteSession= null;
+               try {
+                       if (d instanceof IDocumentExtension4) {
+                               IDocumentExtension4 extension= (IDocumentExtension4) d;
+                               rewriteSession= extension.startRewriteSession(DocumentRewriteSessionType.SEQUENTIAL);
+                       }
+
+                       Point selection= getSelectedRange();
+
+                       // perform the adjustment
+                       int tabWidth= getTextWidget().getTabs();
+                       int startLine= d.getLineOfOffset(selection.x);
+                       int endLine= selection.y == 0 ? startLine : d.getLineOfOffset(selection.x + selection.y - 1);
+                       for (int line= startLine; line <= endLine; ++line) {
+                               IRegion lineRegion= d.getLineInformation(line);
+                               String indent= IndentUtil.getCurrentIndent(d, line, false);
+                               int indentWidth= IndentUtil.computeVisualLength(indent, tabWidth);
+                               int newIndentWidth= Math.max(0, indentWidth + (increase ? shiftWidth : -shiftWidth));
+                               String newIndent= IndentUtil.changePrefix(indent.trim(), newIndentWidth, tabWidth, useSpaces);
+                               int commonLen= getCommonPrefixLength(indent, newIndent);
+                               if (commonLen < Math.max(indent.length(), newIndent.length())) {
+                                       if (commonLen > 0) {
+                                               indent= indent.substring(commonLen);
+                                               newIndent= newIndent.substring(commonLen);
+                                       }
+                                       final int offset= lineRegion.getOffset() + commonLen;
+                                       if (!increase && newIndent.length() > indent.length() && indent.length() > 0) {
+                                               d.replace(offset, indent.length(), ""); //$NON-NLS-1$
+                                               d.replace(offset, 0, newIndent);
+                                       } else {
+                                               d.replace(offset, indent.length(), newIndent);
+                                       }
+                               }
+                       }
+                       
+               } catch (BadLocationException x) {
+                       // ignored
+               } finally {
+                       if (rewriteSession != null) {
+                               ((IDocumentExtension4)d).stopRewriteSession(rewriteSession);
+                       }
+                       if (fUndoManager != null) {
+                               fUndoManager.endCompoundChange();
+                       }
+               }
+       }
+
+    /**
+     * Compute the length of the common prefix of two strings.
+     * 
+        * @param s1
+        * @param s2
+        * @return the length of the common prefix
+        */
+       private static int getCommonPrefixLength(String s1, String s2) {
+               final int l1= s1.length();
+               final int l2= s2.length();
+               int i= 0;
+               while (i < l1 && i < l2 && s1.charAt(i) == s2.charAt(i)) {
+                       ++i;
+               }
+               return i;
+       }
+
+       /*
+     * work around for memory leak in TextViewer$WidgetCommand
+     */
+    @Override
+       protected void updateTextListeners(WidgetCommand cmd) {
+        super.updateTextListeners(cmd);
+        cmd.preservedText= null;
+        cmd.event= null;
+        cmd.text= null;
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSourceViewerDecorationSupport.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CSourceViewerDecorationSupport.java
new file mode 100644 (file)
index 0000000..c07bc8a
--- /dev/null
@@ -0,0 +1,321 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.text.ITextViewerExtension2;
+import org.eclipse.jface.text.source.IAnnotationAccess;
+import org.eclipse.jface.text.source.IOverviewRuler;
+import org.eclipse.jface.text.source.ISharedTextColors;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.ui.texteditor.SourceViewerDecorationSupport;
+
+import org.eclipse.cdt.internal.ui.LineBackgroundPainter;
+
+/**
+ * <code>SourceViewerDecorationSupport</code> with extension(s):
+ * <ul>
+ *   <li>inactive code painter</li>
+ * </ul>
+ * 
+ * @author anton.leherbauer@windriver.com
+ * 
+ * @since 4.0
+ */
+public class CSourceViewerDecorationSupport extends SourceViewerDecorationSupport {
+
+       /** The key to use for the {@link LineBackgroundPainter} */
+       private static final String INACTIVE_CODE_KEY = "inactiveCode"; //$NON-NLS-1$
+
+       /** The preference key for the inactive code highlight color */
+       private String fInactiveCodeColorKey;
+       /** The preference key for the inactive code highlight enablement */
+       private String fInactiveCodeEnableKey;
+       /** The generic line background painter instance. */
+       private LineBackgroundPainter fLineBackgroundPainter;
+       /** The shared colors instance (duplicate of private base class member) */
+       private ISharedTextColors fSharedColors;
+       /** The preference store (duplicate of private base class member) */
+       private IPreferenceStore fPrefStore;
+       /** The preference key for the cursor line highlight color (duplicate of private base class member) */
+       private String fCLPColorKey;
+       /** The preference key for the cursor line highlight enablement (duplicate of private base class member) */
+       private String fCLPEnableKey;
+       /** The source viewer (duplicate of private base class member) */
+       protected ISourceViewer fViewer;
+       /** The editor we are associated with */
+       private CEditor fEditor;
+       /** The inactive code highlighting */
+       private InactiveCodeHighlighting fInactiveCodeHighlighting;
+
+       /**
+        * Inherited constructor.
+        * 
+        * @param sourceViewer
+        * @param overviewRuler
+        * @param annotationAccess
+        * @param sharedTextColors
+        */
+       CSourceViewerDecorationSupport(
+               CEditor editor,
+               ISourceViewer sourceViewer,
+               IOverviewRuler overviewRuler,
+               IAnnotationAccess annotationAccess,
+               ISharedTextColors sharedTextColors) {
+               super(sourceViewer, overviewRuler, annotationAccess, sharedTextColors);
+               fEditor = editor;
+               // we have to save our own references, because super class members are all private
+               fViewer = sourceViewer;
+               fSharedColors = sharedTextColors;
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.SourceViewerDecorationSupport#dispose()
+        */
+       @Override
+       public void dispose() {
+               super.dispose();
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.SourceViewerDecorationSupport#handlePreferenceStoreChanged(org.eclipse.jface.util.PropertyChangeEvent)
+        */
+       @Override
+       protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
+               String p = event.getProperty();
+               if (p.equals(fCLPEnableKey)) {
+                       if (isCLPActive()) {
+                               showCLP();
+                       } else {
+                               hideCLP();
+                       }
+               } else if (p.equals(fCLPColorKey)) {
+                       updateCLPColor();
+               } else if (p.equals(fInactiveCodeEnableKey)) {
+                       if (isInactiveCodePositionsActive()) {
+                               showInactiveCodePositions(true);
+                       } else {
+                               hideInactiveCodePositions();
+                       }
+               } else if (p.equals(fInactiveCodeColorKey)) {
+                       updateInactiveCodeColor();
+               }
+               super.handlePreferenceStoreChanged(event);
+       }
+
+       /**
+        * Update the color for inactive code positions.
+        */
+       private void updateInactiveCodeColor() {
+               if (fLineBackgroundPainter != null) {
+                       fLineBackgroundPainter.setBackgroundColor(INACTIVE_CODE_KEY, getColor(fInactiveCodeColorKey));
+                       if (isInactiveCodePositionsActive()) {
+                               fLineBackgroundPainter.redraw();
+                       }
+               }
+       }
+
+       /**
+        * Update the color for the cursor line highlighting.
+        */
+       private void updateCLPColor() {
+               if (fLineBackgroundPainter != null) {
+                       fLineBackgroundPainter.setCursorLineColor(getColor(fCLPColorKey));
+                       if (isCLPActive()) {
+                               fLineBackgroundPainter.redraw();
+                       }
+               }
+       }
+
+       /**
+        * Hide cursor line highlighting.
+        */
+       private void hideCLP() {
+               if (fLineBackgroundPainter != null) {
+                       if (!isInactiveCodePositionsActive()) {
+                               uninstallLineBackgroundPainter();
+                       } else {
+                               fLineBackgroundPainter.enableCursorLine(false);
+                               fLineBackgroundPainter.redraw();
+                       }
+               }
+       }
+
+       /**
+        * Show cursor line highlighting.
+        */
+       private void showCLP() {
+               installLineBackgroundPainter();
+               if (fLineBackgroundPainter != null) {
+                       fLineBackgroundPainter.enableCursorLine(true);
+                       fLineBackgroundPainter.redraw();
+               }
+       }
+
+       /**
+        * @return true if cursor line highlighting is active.
+        */
+       private boolean isCLPActive() {
+               if (fPrefStore != null) {
+                       return fPrefStore.getBoolean(fCLPEnableKey);
+               }
+               return false;
+       }
+
+       /**
+        * @return true if inactive code highlighting is active.
+        */
+       private boolean isInactiveCodePositionsActive() {
+               if (fPrefStore != null) {
+                       return fPrefStore.getBoolean(fInactiveCodeEnableKey);
+               }
+               return false;
+       }
+
+       /**
+        * Returns the shared color for the given key.
+        * 
+        * @param key the color key string
+        * @return the shared color for the given key
+        */
+       private Color getColor(String key) {
+               if (fPrefStore != null) {
+                       RGB rgb = PreferenceConverter.getColor(fPrefStore, key);
+                       return getColor(rgb);
+               }
+               return null;
+       }
+
+       /**
+        * Returns the shared color for the given RGB.
+        * 
+        * @param rgb the rgb
+        * @return the shared color for the given rgb
+        */
+       private Color getColor(RGB rgb) {
+               return fSharedColors.getColor(rgb);
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.SourceViewerDecorationSupport#install(org.eclipse.jface.preference.IPreferenceStore)
+        */
+       @Override
+       public void install(IPreferenceStore store) {
+               super.install(store);
+               fPrefStore = store;
+               if (isCLPActive()) {
+                       showCLP();
+               }
+               if (isInactiveCodePositionsActive()) {
+                       showInactiveCodePositions(false);
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.SourceViewerDecorationSupport#uninstall()
+        */
+       @Override
+       public void uninstall() {
+               uninstallLineBackgroundPainter();
+               super.uninstall();
+       }
+
+       /**
+        * Install line background painter (inactive code/cursor line).
+        */
+       private void installLineBackgroundPainter() {
+               if (fLineBackgroundPainter == null) {
+                       if (fViewer instanceof ITextViewerExtension2) {
+                               fLineBackgroundPainter = new LineBackgroundPainter(fViewer);
+                               fLineBackgroundPainter.setBackgroundColor(INACTIVE_CODE_KEY, getColor(fInactiveCodeColorKey));
+                               fLineBackgroundPainter.setCursorLineColor(getColor(fCLPColorKey));
+                               fLineBackgroundPainter.enableCursorLine(isCLPActive());
+                               ((ITextViewerExtension2)fViewer).addPainter(fLineBackgroundPainter);
+                       }
+               }
+       }
+
+       /**
+        * Uninstall line background painter (inactive code/cursor line).
+        */
+       private void uninstallLineBackgroundPainter() {
+               if (fLineBackgroundPainter != null) {
+                       if (fInactiveCodeHighlighting != null) {
+                               fInactiveCodeHighlighting.uninstall();
+                               fInactiveCodeHighlighting= null;
+                       }
+                       if (fViewer instanceof ITextViewerExtension2) {
+                               ((ITextViewerExtension2)fViewer).removePainter(fLineBackgroundPainter);
+                       }
+                       fLineBackgroundPainter.deactivate(true);
+                       fLineBackgroundPainter.dispose();
+                       fLineBackgroundPainter = null;
+               }
+       }
+
+       /**
+        * Show inactive code positions.
+        * 
+        * @param refresh trigger a refresh of the positions
+        */
+       private void showInactiveCodePositions(boolean refresh) {
+               installLineBackgroundPainter();
+               if (fLineBackgroundPainter != null) {
+                       fInactiveCodeHighlighting= new InactiveCodeHighlighting(INACTIVE_CODE_KEY);
+                       fInactiveCodeHighlighting.install(fEditor, fLineBackgroundPainter);
+                       if (refresh) {
+                               fInactiveCodeHighlighting.refresh();
+                       }
+               }
+       }
+
+       /**
+        * Hide inactive code positions.
+        */
+       private void hideInactiveCodePositions() {
+               if (fLineBackgroundPainter != null) {
+                       if (fInactiveCodeHighlighting != null) {
+                               fInactiveCodeHighlighting.uninstall();
+                               fInactiveCodeHighlighting= null;
+                       }
+                       if (!isCLPActive()) {
+                               uninstallLineBackgroundPainter();
+                       }
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.SourceViewerDecorationSupport#setCursorLinePainterPreferenceKeys(java.lang.String, java.lang.String)
+        */
+       @Override
+       public void setCursorLinePainterPreferenceKeys(String enableKey, String colorKey) {
+               // this is a dirty hack to override the original cursor line painter
+               // and replace it with the generic BackgroundLinePainter
+               fCLPEnableKey = enableKey;
+               fCLPColorKey = colorKey;
+               super.setCursorLinePainterPreferenceKeys(enableKey + "-overridden", colorKey); //$NON-NLS-1$
+       }
+
+       /**
+        * Set the preference keys for the inactive code painter.
+        * @param enableKey
+        * @param colorKey
+        */
+       public void setInactiveCodePainterPreferenceKeys(String enableKey, String colorKey) {
+               fInactiveCodeEnableKey = enableKey;
+               fInactiveCodeColorKey = colorKey;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CStorageDocumentProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CStorageDocumentProvider.java
new file mode 100644 (file)
index 0000000..35bf81e
--- /dev/null
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.text.CTextTools;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.source.AnnotationModel;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.ui.editors.text.StorageDocumentProvider;
+
+/**
+ * CStorageDocumentProvider
+ */
+public class CStorageDocumentProvider extends StorageDocumentProvider {
+       
+       /**
+        * 
+        */
+       public CStorageDocumentProvider() {
+               super();
+       }
+
+       @Override
+       protected IAnnotationModel createAnnotationModel(Object element) throws CoreException {
+               IAnnotationModel m = super.createAnnotationModel(element);
+               if (m == null)
+                       m = new AnnotationModel();
+               return m;
+       }
+
+       /*
+        * @see org.eclipse.ui.editors.text.StorageDocumentProvider#setupDocument(java.lang.Object, org.eclipse.jface.text.IDocument)
+        */
+       @Override
+       protected void setupDocument(Object element, IDocument document) {
+               if (document != null) {
+                       CTextTools tools= CUIPlugin.getDefault().getTextTools();
+                       tools.setupCDocument(document);
+               }
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CTemplatesPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CTemplatesPage.java
new file mode 100644 (file)
index 0000000..d2f8c53
--- /dev/null
@@ -0,0 +1,346 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Dakshinamurthy Karra, IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Dakshinamurthy Karra (Jalian Systems) - Templates View - https://bugs.eclipse.org/bugs/show_bug.cgi?id=69581
+ *     Marc-Andre Laperle - CDT version
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.ITextViewerExtension;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TextSelection;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.text.templates.ContextTypeRegistry;
+import org.eclipse.jface.text.templates.DocumentTemplateContext;
+import org.eclipse.jface.text.templates.Template;
+import org.eclipse.jface.text.templates.TemplateContextType;
+import org.eclipse.jface.text.templates.TemplateProposal;
+import org.eclipse.jface.text.templates.persistence.TemplateStore;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.texteditor.templates.AbstractTemplatesPage;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+import org.eclipse.cdt.internal.corext.template.c.CContext;
+import org.eclipse.cdt.internal.corext.template.c.CContextType;
+
+import org.eclipse.cdt.internal.ui.preferences.CSourcePreviewerUpdater;
+import org.eclipse.cdt.internal.ui.preferences.EditTemplateDialog;
+import org.eclipse.cdt.internal.ui.text.CTextTools;
+import org.eclipse.cdt.internal.ui.text.SimpleCSourceViewerConfiguration;
+import org.eclipse.cdt.internal.ui.text.template.TemplateVariableProcessor;
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+
+/**
+ * The templates page for the C editor.
+ *
+ * @since 5.2
+ */
+public class CTemplatesPage extends AbstractTemplatesPage {
+
+       private static final String PREFERENCE_PAGE_ID= "org.eclipse.cdt.ui.preferences.TemplatePreferencePage"; //$NON-NLS-1$
+       private static final TemplateStore TEMPLATE_STORE= CUIPlugin.getDefault().getTemplateStore();
+       private static final IPreferenceStore PREFERENCE_STORE= CUIPlugin.getDefault().getPreferenceStore();
+       private static final ContextTypeRegistry TEMPLATE_CONTEXT_REGISTRY= CUIPlugin.getDefault().getTemplateContextRegistry();
+
+       private TemplateVariableProcessor fTemplateProcessor;
+       private CEditor fCEditor;
+
+       /**
+        * Create a new AbstractTemplatesPage for the CEditor
+        * 
+        * @param cEditor the C editor
+        */
+       public CTemplatesPage(CEditor cEditor) {
+               super(cEditor, cEditor.getViewer());
+               fCEditor= cEditor;
+               fTemplateProcessor= new TemplateVariableProcessor();
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.templates.AbstractTemplatesPage#insertTemplate(org.eclipse.jface.text.templates.Template, org.eclipse.jface.text.IDocument)
+        */
+       @Override
+       protected void insertTemplate(Template template, IDocument document) {
+               if (!fCEditor.validateEditorInputState())
+                       return;
+
+               ISourceViewer contextViewer= fCEditor.getViewer();
+               ITextSelection textSelection= (ITextSelection) contextViewer.getSelectionProvider().getSelection();
+               if (!isValidTemplate(document, template, textSelection.getOffset(), textSelection.getLength()))
+                       return;
+               beginCompoundChange(contextViewer);
+               /*
+                * The Editor checks whether a completion for a word exists before it allows for the template to be
+                * applied. We pickup the current text at the selection position and replace it with the first char
+                * of the template name for this to succeed.
+                * Another advantage by this method is that the template replaces the selected text provided the
+                * selection by itself is not used in the template pattern.
+                */
+               String savedText;
+               try {
+                       savedText= document.get(textSelection.getOffset(), textSelection.getLength());
+                       if (savedText.length() == 0) {
+                               String prefix= getIdentifierPart(document, template, textSelection.getOffset(), textSelection.getLength());
+                               if (prefix.length() > 0 && !template.getName().startsWith(prefix.toString())) {
+                                       return;
+                               }
+                               if (prefix.length() > 0) {
+                                       contextViewer.setSelectedRange(textSelection.getOffset() - prefix.length(), prefix.length());
+                                       textSelection= (ITextSelection) contextViewer.getSelectionProvider().getSelection();
+                               }
+                       }
+                       document.replace(textSelection.getOffset(), textSelection.getLength(), template.getName().substring(0, 1));
+               } catch (BadLocationException e) {
+                       endCompoundChange(contextViewer);
+                       return;
+               }
+               Position position= new Position(textSelection.getOffset() + 1, 0);
+               Region region= new Region(textSelection.getOffset() + 1, 0);
+               contextViewer.getSelectionProvider().setSelection(new TextSelection(textSelection.getOffset(), 1));
+               ITranslationUnit compilationUnit= (ITranslationUnit) EditorUtility.getEditorInputCElement(fCEditor);
+
+               TemplateContextType type= getContextTypeRegistry().getContextType(template.getContextTypeId());
+               DocumentTemplateContext context= ((CContextType) type).createContext(document, position, compilationUnit);
+               context.setVariable("selection", savedText); //$NON-NLS-1$
+               if (context.getKey().length() == 0) {
+                       try {
+                               document.replace(textSelection.getOffset(), 1, savedText);
+                       } catch (BadLocationException e) {
+                               endCompoundChange(contextViewer);
+                               return;
+                       }
+               }
+               TemplateProposal proposal= new TemplateProposal(template, context, region, null);
+               fCEditor.getSite().getPage().activate(fCEditor);
+               proposal.apply(fCEditor.getViewer(), ' ', 0, region.getOffset());
+               endCompoundChange(contextViewer);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.texteditor.templates.AbstractTemplatesPage#getContextTypeRegistry()
+        */
+       @Override
+       protected ContextTypeRegistry getContextTypeRegistry() {
+               return TEMPLATE_CONTEXT_REGISTRY;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.texteditor.templates.AbstractTemplatesPage#getTemplatePreferenceStore()
+        */
+       @Override
+       protected IPreferenceStore getTemplatePreferenceStore() {
+               return PREFERENCE_STORE;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.texteditor.templates.AbstractTemplatesPage#getTemplateStore()
+        */
+       @Override
+       public TemplateStore getTemplateStore() {
+               return TEMPLATE_STORE;
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.templates.TextEditorTemplatesPage#isValidTemplate(org.eclipse.jface.text.templates.Template, int, int)
+        */
+       @Override
+       protected boolean isValidTemplate(IDocument document, Template template, int offset, int length) {
+               String[] contextIds= getContextTypeIds(document, offset);
+               for (int i= 0; i < contextIds.length; i++) {
+                       if (contextIds[i].equals(template.getContextTypeId())) {
+                               DocumentTemplateContext context= getContext(document, template, offset, length);
+                               return context.canEvaluate(template) || isTemplateAllowed(context, template);
+                       }
+               }
+               return false;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.texteditor.templates.TextEditorTemplatesPage#createPatternViewer(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected SourceViewer createPatternViewer(Composite parent) {
+               IDocument document= new Document();
+               CTextTools tools= CUIPlugin.getDefault().getTextTools();
+               tools.setupCDocumentPartitioner(document, ICPartitions.C_PARTITIONING, null);
+               IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
+               CSourceViewer viewer= new CSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL, store);
+               SimpleCSourceViewerConfiguration configuration= new SimpleCSourceViewerConfiguration(tools.getColorManager(), store, null, ICPartitions.C_PARTITIONING, false);
+               viewer.configure(configuration);
+               viewer.setEditable(false);
+               viewer.setDocument(document);
+
+               Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
+               viewer.getTextWidget().setFont(font);
+               new CSourcePreviewerUpdater(viewer, configuration, store);
+
+               Control control= viewer.getControl();
+               GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
+               control.setLayoutData(data);
+
+               viewer.setEditable(false);
+               return viewer;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.texteditor.templates.AbstractTemplatesPage#getImageForTemplate(org.eclipse.jface.text.templates.Template)
+        */
+       @Override
+       protected Image getImage(Template template) {
+               return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_TEMPLATE);
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.templates.TextEditorTemplatesPage#editTemplate(org.eclipse.jface.text.templates.Template, boolean, boolean)
+        */
+       @Override
+       protected Template editTemplate(Template template, boolean edit, boolean isNameModifiable) {
+               EditTemplateDialog dialog= new EditTemplateDialog(getSite().getShell(), template, edit, isNameModifiable, false, getContextTypeRegistry());
+               if (dialog.open() == Window.OK)
+                       return dialog.getTemplate();
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.templates.TextEditorTemplatesPage#updatePatternViewer(org.eclipse.jface.text.templates.Template)
+        */
+       @Override
+       protected void updatePatternViewer(Template template) {
+               if (template == null) {
+                       getPatternViewer().getDocument().set(""); //$NON-NLS-1$
+                       return ;
+               }
+               String contextId= template.getContextTypeId();
+               TemplateContextType type= getContextTypeRegistry().getContextType(contextId);
+               fTemplateProcessor.setContextType(type);
+
+               IDocument doc= getPatternViewer().getDocument();
+
+               String start= ""; //$NON-NLS-1$
+               doc.set(start + template.getPattern());
+               int startLen= start.length();
+               getPatternViewer().setDocument(doc, startLen, doc.getLength() - startLen);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.texteditor.templates.AbstractTemplatesPage#getPreferencePageId()
+        */
+       @Override
+       protected String getPreferencePageId() {
+               return PREFERENCE_PAGE_ID;
+       }
+
+       /**
+        * Undomanager - end compound change
+        * 
+        * @param viewer the viewer
+        */
+       private void endCompoundChange(ISourceViewer viewer) {
+               if (viewer instanceof ITextViewerExtension)
+                       ((ITextViewerExtension) viewer).getRewriteTarget().endCompoundChange();
+       }
+
+       /**
+        * Undomanager - begin a compound change
+        * 
+        * @param viewer the viewer
+        */
+       private void beginCompoundChange(ISourceViewer viewer) {
+               if (viewer instanceof ITextViewerExtension)
+                       ((ITextViewerExtension) viewer).getRewriteTarget().beginCompoundChange();
+       }
+
+       /**
+        * Check whether the template is allowed even though the context can't evaluate it. This is
+        * needed because the Dropping of a template is more lenient than ctl-space invoked code assist.
+        * 
+        * @param context the template context
+        * @param template the template
+        * @return true if the template is allowed
+        */
+       private boolean isTemplateAllowed(DocumentTemplateContext context, Template template) {
+               int offset;
+               try {
+                       return ((offset= context.getCompletionOffset()) > 0 && !isTemplateNamePart(context.getDocument().getChar(offset - 1)));
+               } catch (BadLocationException e) {
+               }
+               return false;
+       }
+
+       /**
+        * Checks whether the character is a valid character in C template names
+        * 
+        * @param ch the character
+        * @return <code>true</code> if the character is part of a template name
+        */
+       private boolean isTemplateNamePart(char ch) {
+               return !Character.isWhitespace(ch) && ch != '(' && ch != ')' && ch != '{' && ch != '}' && ch != ';';
+       }
+
+       /**
+        * Get context
+        * 
+        * @param document the document
+        * @param template the template
+        * @param offset the offset
+        * @param length the length
+        * @return the context
+        */
+       private DocumentTemplateContext getContext(IDocument document, Template template, final int offset, int length) {
+               DocumentTemplateContext context= new CContext(getContextTypeRegistry().getContextType(template.getContextTypeId()), document, new Position(offset, length), (ITranslationUnit) EditorUtility.getEditorInputCElement(
+                                       fCEditor));
+               return context;
+       }
+
+       /**
+        * Get the active contexts for the given position in the document.
+        * <p>
+        * FIXME: should trigger code assist to get the context.
+        * </p>
+        * 
+        * @param document the document
+        * @param offset the offset
+        * @return an array of valid context id
+        */
+       @Override
+       protected String[] getContextTypeIds(IDocument document, int offset) {
+               return new String[] { CContextType.ID };
+       }
+
+       /**
+        * Get the C identifier terminated at the given offset
+        * 
+        * @param document the document
+        * @param template the template
+        * @param offset the offset
+        * @param length the length
+        * @return the identifier part the C identifier
+        */
+       private String getIdentifierPart(IDocument document, Template template, int offset, int length) {
+               return getContext(document, template, offset, length).getKey();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ConstructedCEditorMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ConstructedCEditorMessages.java
new file mode 100644 (file)
index 0000000..a7403a2
--- /dev/null
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+
+import com.ibm.icu.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+
+public class ConstructedCEditorMessages  {
+       private static final String RESOURCE_BUNDLE = "org.eclipse.cdt.internal.ui.editor.ConstructedCEditorMessages"; //$NON-NLS-1$
+
+
+       private static ResourceBundle fgResourceBundle;
+       static {
+               try {
+                       fgResourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE);
+               } catch (MissingResourceException x) {
+                       fgResourceBundle = null;
+               }
+       }
+
+
+       private ConstructedCEditorMessages() {
+       }
+
+
+       public static ResourceBundle getResourceBundle() {
+               return fgResourceBundle;
+       }
+       
+       public static String getString( String key ) {
+               try {
+                       return fgResourceBundle.getString( key );
+               } catch(MissingResourceException e) {
+                       return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$
+               } catch (NullPointerException e) {
+                       return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$
+               }
+       }
+
+       /**
+        * 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);
+       }
+       
+       /**
+        * Gets a string from the resource bundle and formats it with arguments
+        */     
+       public static String getFormattedString(String key, Object arg) {
+               return MessageFormat.format(getString(key), new Object[] { arg } );
+       }       
+
+}
+
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ConstructedCEditorMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ConstructedCEditorMessages.properties
new file mode 100644 (file)
index 0000000..5a0345c
--- /dev/null
@@ -0,0 +1,155 @@
+###############################################################################
+#  Copyright (c) 2005, 2010 IBM Corporation and others.
+#  All rights reserved. This program and the accompanying materials
+#  are made available under the terms of the Eclipse Public License v1.0
+#  which accompanies this distribution, and is available at
+#  http://www.eclipse.org/legal/epl-v10.html
+# 
+#  Contributors:
+#     IBM Corporation - initial API and implementation
+#     QNX Software System
+#     Anton Leherbauer (Wind River Systems)
+#     Markus Schorn (Wind River Systems)
+#     Sergey Prigogin (Google)
+#     Tomasz Wesolowski
+###############################################################################
+
+AddIncludeOnSelection.description=Add include statement for selected name
+AddIncludeOnSelection.label=Add Include
+AddIncludeOnSelection.tooltip=Add Include Statement for Selected Name
+
+SortLines.description=Sort selected lines alphabetically
+SortLines.label=Sort Lines
+SortLines.tooltip=Sort Selected Lines Alphabetically
+
+OpenOutline.label= Quick Out&line
+OpenOutline.tooltip= Shows the Quick Outline of Editor Input
+OpenOutline.description= Shows the quick outline for the editor input
+
+OpenHierarchy.label= Quick Type Hierarchy
+OpenHierarchy.tooltip= Shows the Quick Type Hierarchy of Editor Input
+OpenHierarchy.description= Shows the quick type hierarchy for the editor input
+
+TogglePresentation.label=Show Source of Selected Element Only
+TogglePresentation.tooltip=Show Source of Selected Element Only
+
+#NextError.label=Ne&xt Problem
+#NextError.tooltip=Go to Next Problem
+#NextError.description=Go to next problem
+#
+#PreviousError.label=Previo&us Problem
+#PreviousError.tooltip=Go to Previous Problem
+#PreviousError.description=Go to previous problem
+
+ContentAssistProposal.label=Co&ntent Assist
+ContentAssistProposal.tooltip=Content Assist
+ContentAssistProposal.description=Content Assist
+
+ContentAssistContextInformation.label=Parameter &Hints
+ContentAssistContextInformation.tooltip=Show Parameter Hints
+ContentAssistContextInformation.description=Show Method Parameter Hints
+
+ToggleComment.label=Togg&le Comment
+ToggleComment.tooltip=Toggle Comment For the Selected Lines
+ToggleComment.description=Toggle Comment for the selected lines
+
+AddBlockComment.label=Add &Block Comment
+AddBlockComment.tooltip=Enclose the Selection in a Block Comment
+AddBlockComment.description=Encloses the selection with block comment markers
+
+RemoveBlockComment.label=Remove Bloc&k Comment
+RemoveBlockComment.tooltip=Remove Block Comment Markers Enclosing the Caret
+RemoveBlockComment.description=Removes any block comment markers enclosing the caret
+
+Format.label=F&ormat
+Format.tooltip=Format the Selected Text
+Format.description=Format the selected text
+
+ShiftRight.label=Sh&ift Right
+ShiftRight.tooltip=Shift Right
+ShiftRight.description=Shift the selected text to the right
+
+ShiftLeft.label=S&hift Left
+ShiftLeft.tooltip=Shift Left
+ShiftLeft.description=Shift the selected text to the left
+
+NextAnnotation.label= Ne&xt Annotation
+NextAnnotation.tooltip= Next Annotation
+NextAnnotation.description= Next Annotation
+
+PreviousAnnotation.label= Pre&vious Annotation
+PreviousAnnotation.tooltip= Previous Annotation
+PreviousAnnotation.description= Previous Annotation
+
+Indent.label=Correct &Indentation
+Indent.tooltip=&Indent Current Line to Correct Indentation
+Indent.description=&Indents the current line or selection depending on surrounding source code
+
+GotoNextMember.label= N&ext Member
+GotoNextMember.tooltip=Move the Caret to the Next Member of the Translation Unit
+GotoNextMember.description=Move the caret to the next member of the translation unit
+
+GotoPreviousMember.label= Previ&ous Member
+GotoPreviousMember.tooltip=Move the Caret to the Previous Member of the Translation Unit
+GotoPreviousMember.description=Move the caret to the previous member of the translation unit
+
+GotoMatchingBracket.label= Matching &Bracket
+GotoMatchingBracket.tooltip=Go to Matching Bracket
+GotoMatchingBracket.description=Go to Matching Bracket
+
+GotoNextBookmark.description=Goto next bookmark of the selected file
+GotoNextBookmark.label=Next Bookmark
+GotoNextBookmark.tooltip=Goto Next Bookmark of the Selected File
+
+FindWord.description=Select a word and find the next occurrence
+FindWord.label=Find Word
+FindWord.tooltip=Select a Word and Find the Next Occurrence
+
+ToggleInsertMode.label=Sma&rt Insert Mode
+ToggleInsertMode.tooltip=Toggle Smart Insert Mode
+ToggleInsertMode.image=
+ToggleInsertMode.description= Toggles smart insert mode
+
+ToggleSourceHeader.label= To&ggle Source/Header
+ToggleSourceHeader.tooltip= Toggle Source and Header File
+ToggleSourceHeader.image=
+ToggleSourceHeader.description= Toggles between corresponding source and header file
+
+ToggleMarkOccurrencesAction.label= Toggle Mark Occurrences
+ToggleMarkOccurrencesAction.tooltip= Toggle Mark Occurrences
+
+OpenMacroExplorer.label= Explore &Macro Expansion
+OpenMacroExplorer.tooltip= Open a quick view for macro expansion exploration
+OpenMacroExplorer.image=
+OpenMacroExplorer.description= Opens a quick view for macro expansion exploration
+
+CSelectAnnotationRulerAction.QuickFix.label= &Quick Fix
+CSelectAnnotationRulerAction.QuickFix.tooltip= Quick Fix
+CSelectAnnotationRulerAction.QuickFix.description= Runs Quick Fix on the annotation's line
+CSelectAnnotationRulerAction.QuickFix.image=
+
+CSelectAnnotationRulerAction.GotoAnnotation.label= &Go to Annotation
+CSelectAnnotationRulerAction.GotoAnnotation.tooltip= Go to Annotation
+CSelectAnnotationRulerAction.GotoAnnotation.description= Selects the annotation in the editor
+CSelectAnnotationRulerAction.GotoAnnotation.image=
+
+StructureSelectNext.label=&Next Element
+StructureSelectNext.tooltip=Expand Selection to Include Next Sibling
+StructureSelectNext.description=Expand selection to include next sibling
+
+StructureSelectPrevious.label=&Previous Element
+StructureSelectPrevious.tooltip=Expand Selection to Include Previous Sibling
+StructureSelectPrevious.description=Expand selection to include previous sibling
+
+StructureSelectEnclosing.label=&Enclosing Element
+StructureSelectEnclosing.tooltip=Expand Selection to Include Enclosing Element
+StructureSelectEnclosing.description=Expand selection to include enclosing element
+
+StructureSelectHistory.label=&Restore Last Selection
+StructureSelectHistory.tooltip=Restore Last Selection
+StructureSelectHistory.description=Restore last selection
+
+CSelectAnnotationRulerAction.OpenSuperImplementation.label= &Open Super Implementation
+CSelectAnnotationRulerAction.OpenSuperImplementation.tooltip= Open Super Implementation
+CSelectAnnotationRulerAction.OpenSuperImplementation.description= Opens the super implementation
+CSelectAnnotationRulerAction.OpenSuperImplementation.image=
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CustomBufferFactory.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CustomBufferFactory.java
new file mode 100644 (file)
index 0000000..c59d283
--- /dev/null
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ * Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.editor;
+
+import java.net.URI;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.cdt.core.model.IBuffer;
+import org.eclipse.cdt.core.model.IOpenable;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.model.IBufferFactory;
+
+/**
+ * CustomBufferFactory
+ */
+public class CustomBufferFactory implements IBufferFactory {
+       /**
+        * 
+        */
+       public CustomBufferFactory() {
+               super();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.core.model.IBufferFactory#createBuffer(org.eclipse.cdt.core.model.IOpenable)
+        */
+       public IBuffer createBuffer(IOpenable owner) {
+               if (owner instanceof IWorkingCopy) {
+
+                       IWorkingCopy unit= (IWorkingCopy) owner;
+                       ITranslationUnit original= unit.getOriginalElement();
+                       IResource resource= original.getResource();
+                       if (resource instanceof IFile) {
+                               IFile fFile = (IFile)resource;
+                               DocumentAdapter adapter= new DocumentAdapter(owner, fFile);
+                               return adapter;
+                       }
+
+                       // URI
+                       URI locationUri= original.getLocationURI();
+                       if (locationUri != null) {
+                               try {
+                                       return new DocumentAdapter(owner, locationUri);
+                               } catch (CoreException exc) {
+                                       CUIPlugin.log(exc);
+                               }
+                       }
+
+               }
+               return DocumentAdapter.NULL;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/DefaultBinaryFileEditor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/DefaultBinaryFileEditor.java
new file mode 100644 (file)
index 0000000..f5f95a9
--- /dev/null
@@ -0,0 +1,191 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.editor;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.IVerticalRuler;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IPersistableElement;
+import org.eclipse.ui.IStorageEditorInput;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.editors.text.StorageDocumentProvider;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.ide.ResourceUtil;
+import org.eclipse.ui.texteditor.AbstractTextEditor;
+
+import org.eclipse.cdt.core.IBinaryParser;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.IBinary;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.resources.FileStorage;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.utils.IGnuToolFactory;
+import org.eclipse.cdt.utils.Objdump;
+
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+
+/**
+ * A readonly editor to view binary files. This default implementation displays
+ * the GNU objdump output of the binary as plain text. If no objdump output can be
+ * obtained, the binary content is displayed.
+ */
+public class DefaultBinaryFileEditor extends AbstractTextEditor {
+
+       /**
+        * A storage editor input for binary files.
+        */
+       public static class BinaryFileEditorInput extends PlatformObject implements IStorageEditorInput {
+
+               private final IBinary fBinary;
+               private IStorage fStorage;
+
+               /**
+                * Create an editor input from the given binary.
+                * @param binary
+                */
+               public BinaryFileEditorInput(IBinary binary) {
+                       fBinary= binary;
+               }
+
+               /*
+                * @see org.eclipse.ui.IEditorInput#exists()
+                */
+               public boolean exists() {
+                       return fBinary.exists();
+               }
+
+               /*
+                * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
+                */
+               public ImageDescriptor getImageDescriptor() {
+                       IFile file= (IFile)fBinary.getResource();
+                       IContentType contentType= IDE.getContentType(file);
+                       return PlatformUI.getWorkbench().getEditorRegistry()
+                                       .getImageDescriptor(file.getName(), contentType);
+               }
+
+               /*
+                * @see org.eclipse.ui.IEditorInput#getName()
+                */
+               public String getName() {
+                       return fBinary.getElementName();
+               }
+
+               /*
+                * @see org.eclipse.ui.IEditorInput#getPersistable()
+                */
+               public IPersistableElement getPersistable() {
+                       return null;
+               }
+
+               /*
+                * @see org.eclipse.ui.IEditorInput#getToolTipText()
+                */
+               public String getToolTipText() {
+                       return fBinary.getResource().getFullPath().toString();
+               }
+
+               /*
+                * @see org.eclipse.ui.IStorageEditorInput#getStorage()
+                */
+               public IStorage getStorage() throws CoreException {
+                       if (fStorage == null) {
+                               IBinaryParser.IBinaryObject object= (IBinaryParser.IBinaryObject)fBinary.getAdapter(IBinaryParser.IBinaryObject.class);
+                               if (object != null) {
+                                       IGnuToolFactory factory= (IGnuToolFactory) object.getBinaryParser().getAdapter(IGnuToolFactory.class);
+                                       if (factory != null) {
+                                               Objdump objdump= factory.getObjdump(object.getPath());
+                                               if (objdump != null) {
+                                                       try {
+                                                               fStorage= new FileStorage(new ByteArrayInputStream(objdump.getOutput()), object.getPath());
+                                                       } catch (IOException exc) {
+                                                               CUIPlugin.log(exc);
+                                                       }
+                                               }
+                                       }
+                               }
+                               if (fStorage == null) {
+                                       // backwards compatibility
+                                       fStorage= EditorUtility.getStorage(fBinary);
+                                       if (fStorage == null) {
+                                               // fall back to binary content
+                                               fStorage= (IFile)fBinary.getResource();
+                                       }
+                               }
+                       }
+                       return fStorage;
+               }
+
+       }
+
+       /**
+        * A storage document provider for binary files.
+        */
+       public static class BinaryFileDocumentProvider extends StorageDocumentProvider {
+               
+               /*
+                * @see org.eclipse.ui.editors.text.StorageDocumentProvider#createDocument(java.lang.Object)
+                */
+               @Override
+               protected IDocument createDocument(Object element) throws CoreException {
+                       IFile file= ResourceUtil.getFile(element);
+                       if (file != null) {
+                               ICElement cElement= CoreModel.getDefault().create(file);
+                               if (cElement instanceof IBinary) {
+                                       element= new BinaryFileEditorInput((IBinary)cElement);
+                               }
+                       }
+                       return super.createDocument(element);
+               }
+               /*
+                * @see org.eclipse.ui.editors.text.StorageDocumentProvider#isModifiable(java.lang.Object)
+                */
+               @Override
+               public boolean isModifiable(Object element) {
+                       return false;
+               }
+               /*
+                * @see org.eclipse.ui.editors.text.StorageDocumentProvider#isReadOnly(java.lang.Object)
+                */
+               @Override
+               public boolean isReadOnly(Object element) {
+                       return true;
+               }
+               
+       }
+
+       public DefaultBinaryFileEditor() {
+               super();
+               setDocumentProvider(new BinaryFileDocumentProvider());
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#createSourceViewer(org.eclipse.swt.widgets.Composite, org.eclipse.jface.text.source.IVerticalRuler, int)
+        */
+       @Override
+       protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
+               ISourceViewer sourceViewer= super.createSourceViewer(parent, ruler, styles);
+               sourceViewer.setEditable(false);
+               return sourceViewer;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/DocumentAdapter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/DocumentAdapter.java
new file mode 100644 (file)
index 0000000..b1adf31
--- /dev/null
@@ -0,0 +1,556 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Rational Software - Initial API and implementation
+ * Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.core.filebuffers.ITextFileBuffer;
+import org.eclipse.core.filebuffers.ITextFileBufferManager;
+import org.eclipse.core.filebuffers.LocationKind;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourceAttributes;
+import org.eclipse.core.runtime.Assert;
+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.NullProgressMonitor;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DefaultLineTracker;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentListener;
+import org.eclipse.jface.text.ISynchronizable;
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.cdt.core.model.BufferChangedEvent;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.IBuffer;
+import org.eclipse.cdt.core.model.IBufferChangedListener;
+import org.eclipse.cdt.core.model.IOpenable;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+
+/**
+ * Adapts <code>IDocument</code> to <code>IBuffer</code>. Uses the
+ * same algorithm as the text widget to determine the buffer's line delimiter.
+ * All text inserted into the buffer is converted to this line delimiter.
+ * This class is <code>public</code> for test purposes only.
+ * 
+ * This class is similar to the JDT DocumentAdapter class.
+ */
+public class DocumentAdapter implements IBuffer, IDocumentListener, IAdaptable {
+
+       /**
+        * Internal implementation of a NULL instanceof IBuffer.
+        */
+       static private class NullBuffer implements IBuffer {
+                       
+               public void addBufferChangedListener(IBufferChangedListener listener) {}
+               
+               public void append(char[] text) {}
+               
+               public void append(String text) {}
+               
+               public void close() {}
+               
+               public char getChar(int position) {
+                       return 0;
+               }
+               
+               public char[] getCharacters() {
+                       return null;
+               }
+               
+               public String getContents() {
+                       return null;
+               }
+               
+               public int getLength() {
+                       return 0;
+               }
+               
+               public IOpenable getOwner() {
+                       return null;
+               }
+               
+               public String getText(int offset, int length) {
+                       return null;
+               }
+               
+               public IResource getUnderlyingResource() {
+                       return null;
+               }
+               
+               public boolean hasUnsavedChanges() {
+                       return false;
+               }
+               
+               public boolean isClosed() {
+                       return false;
+               }
+               
+               public boolean isReadOnly() {
+                       return true;
+               }
+               
+               public void removeBufferChangedListener(IBufferChangedListener listener) {}
+               
+               public void replace(int position, int length, char[] text) {}
+               
+               public void replace(int position, int length, String text) {}
+               
+               public void save(IProgressMonitor progress, boolean force) throws CModelException {}
+               
+               public void setContents(char[] contents) {}
+               
+               public void setContents(String contents) {}
+       }
+               
+       
+       /** NULL implementing <code>IBuffer</code> */
+       public final static IBuffer NULL= new NullBuffer();
+
+       /**
+        *  Executes a document set content call in the ui thread.
+        */
+       protected class DocumentSetCommand implements Runnable {
+               
+               private String fContents;
+               
+               public void run() {
+                       fDocument.set(fContents);
+               }
+       
+               public void set(String contents) {
+                       fContents= contents;
+                       Display.getDefault().syncExec(this);
+               }
+       }
+
+       /**
+        * Executes a document replace call in the ui thread.
+        */
+       protected class DocumentReplaceCommand implements Runnable {
+               
+               private int fOffset;
+               private int fLength;
+               private String fText;
+               
+               public void run() {
+                       try {
+                               fDocument.replace(fOffset, fLength, fText);
+                       } catch (BadLocationException x) {
+                               // ignore
+                       }
+               }
+               
+               public void replace(int offset, int length, String text) {
+                       fOffset= offset;
+                       fLength= length;
+                       fText= text;
+                       Display.getDefault().syncExec(this);
+               }
+       }
+
+       private static final boolean DEBUG_LINE_DELIMITERS= true;
+
+       private IOpenable fOwner;
+       private IFile fFile;
+       private ITextFileBuffer fTextFileBuffer;
+       IDocument fDocument;
+
+       private DocumentSetCommand fSetCmd= new DocumentSetCommand();
+       private DocumentReplaceCommand fReplaceCmd= new DocumentReplaceCommand();
+
+       private Set<String> fLegalLineDelimiters;
+
+       private List<IBufferChangedListener> fBufferListeners= new ArrayList<IBufferChangedListener>(3);
+       private IStatus fStatus;
+
+       final private IPath fLocation;
+       final private LocationKind fLocationKind;
+
+       private IFileStore fFileStore;
+
+       
+       public DocumentAdapter(IOpenable owner, IFile file) {
+               fOwner= owner;
+               fFile= file;
+               fLocation= file.getFullPath();
+               fLocationKind= LocationKind.IFILE;
+
+               initialize();
+       }
+
+       public DocumentAdapter(IOpenable owner, IPath location) {
+               fOwner= owner;
+               fLocation= location;
+               fLocationKind= LocationKind.NORMALIZE;
+               
+               initialize();
+       }
+
+       public DocumentAdapter(IOpenable owner, URI locationUri) throws CoreException {
+               fOwner= owner;
+               fFileStore= EFS.getStore(locationUri);
+
+               fLocation= null;
+               fLocationKind= null;
+
+               initialize();
+       }
+
+       private void initialize() {
+               ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
+               try {
+                       if (fLocation != null) {
+                               manager.connect(fLocation, fLocationKind, new NullProgressMonitor());
+                               fTextFileBuffer= manager.getTextFileBuffer(fLocation, fLocationKind);
+                       } else {
+                               manager.connectFileStore(fFileStore, new NullProgressMonitor());
+                               fTextFileBuffer= manager.getFileStoreTextFileBuffer(fFileStore);
+                       }
+                       fDocument= fTextFileBuffer.getDocument();
+               } catch (CoreException x) {
+                       fStatus= x.getStatus();
+                       if (fLocation != null) {
+                               fDocument= manager.createEmptyDocument(fLocation, fLocationKind);
+                       }
+                       if (fDocument instanceof ISynchronizable) {
+                               ((ISynchronizable)fDocument).setLockObject(new Object());
+                       }
+               }
+               fDocument.addPrenotifiedDocumentListener(this);
+       }
+
+       /**
+        * Returns the status of this document adapter.
+        */
+       public IStatus getStatus() {
+               if (fStatus != null)
+                       return fStatus;
+               if (fTextFileBuffer != null)
+                       return fTextFileBuffer.getStatus();
+               return null;
+       }
+       
+       /**
+        * Returns the adapted document.
+        * 
+        * @return the adapted document
+        */
+       public IDocument getDocument() {
+               return fDocument;
+       }
+
+       /*
+        * @see IBuffer#addBufferChangedListener(IBufferChangedListener)
+        */
+       public void addBufferChangedListener(IBufferChangedListener listener) {
+               Assert.isNotNull(listener);
+               if (!fBufferListeners.contains(listener))
+                       fBufferListeners.add(listener);
+       }
+       
+       /*
+        * @see IBuffer#removeBufferChangedListener(IBufferChangedListener)
+        */
+       public void removeBufferChangedListener(IBufferChangedListener listener) {
+               Assert.isNotNull(listener);
+               fBufferListeners.remove(listener);
+       }
+       
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#append(char[])
+        */
+       public void append(char[] text) {
+               append(new String(text));
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#append(java.lang.String)
+        */
+       public void append(String text) {
+               if (DEBUG_LINE_DELIMITERS) {
+                       validateLineDelimiters(text);
+               }
+               fReplaceCmd.replace(fDocument.getLength(), 0, text);
+       }
+
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#close()
+        */
+       public void close() {
+               
+               if (isClosed())
+                       return;
+                       
+               IDocument d= fDocument;
+               fDocument= null;
+               d.removePrenotifiedDocumentListener(this);
+               
+               if (fTextFileBuffer != null) {
+                       ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
+                       try {
+                               if (fLocation != null) {
+                                       manager.disconnect(fLocation, fLocationKind, new NullProgressMonitor());
+                               } else {
+                                       manager.disconnectFileStore(fFileStore, new NullProgressMonitor());
+                               }
+                       } catch (CoreException x) {
+                               // ignore
+                       }
+                       fTextFileBuffer= null;
+               }
+               
+               fireBufferChanged(new BufferChangedEvent(this, 0, 0, null));
+               fBufferListeners.clear();
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#getChar(int)
+        */
+       public char getChar(int position) {
+               try {
+                       return fDocument.getChar(position);
+               } catch (BadLocationException x) {
+                       throw new ArrayIndexOutOfBoundsException();
+               }
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#getCharacters()
+        */
+       public char[] getCharacters() {
+               String content= getContents();
+               return content == null ? null : content.toCharArray();
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#getContents()
+        */
+       public String getContents() {
+               return fDocument.get();
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#getLength()
+        */
+       public int getLength() {
+               return fDocument.getLength();
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#getOwner()
+        */
+       public IOpenable getOwner() {
+               return fOwner;
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#getText(int, int)
+        */
+       public String getText(int offset, int length) {
+               try {
+                       return fDocument.get(offset, length);
+               } catch (BadLocationException x) {
+                       throw new ArrayIndexOutOfBoundsException();
+               }
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#getUnderlyingResource()
+        */
+       public IResource getUnderlyingResource() {
+               return fFile;
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#hasUnsavedChanges()
+        */
+       public boolean hasUnsavedChanges() {
+               return fTextFileBuffer != null ? fTextFileBuffer.isDirty() : false;
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#isClosed()
+        */
+       public boolean isClosed() {
+               return fDocument == null;
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#isReadOnly()
+        */
+       public boolean isReadOnly() {
+               IResource resource= getUnderlyingResource();
+               if (resource != null) {
+                       ResourceAttributes attributes = resource.getResourceAttributes();
+                       if (attributes != null) {
+                               return attributes.isReadOnly();
+                       }
+               }
+               return false;
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#replace(int, int, char[])
+        */
+       public void replace(int position, int length, char[] text) {
+               replace(position, length, new String(text));
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#replace(int, int, java.lang.String)
+        */
+       public void replace(int position, int length, String text) {
+               if (DEBUG_LINE_DELIMITERS) {
+                       validateLineDelimiters(text);
+               }
+               fReplaceCmd.replace(position, length, text);
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#save(org.eclipse.core.runtime.IProgressMonitor, boolean)
+        */
+       public void save(IProgressMonitor progress, boolean force) throws CModelException {
+               try {
+                       if (fTextFileBuffer != null)
+                               fTextFileBuffer.commit(progress, force);
+               } catch (CoreException e) {
+                       throw new CModelException(e);
+               }
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#setContents(char[])
+        */
+       public void setContents(char[] contents) {
+               setContents(new String(contents));
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#setContents(java.lang.String)
+        */
+       public void setContents(String contents) {
+               int oldLength= fDocument.getLength();
+               
+               if (contents == null) {
+                       
+                       if (oldLength != 0)
+                               fSetCmd.set(""); //$NON-NLS-1$
+               
+               } else {
+                       // set only if different
+                       if (DEBUG_LINE_DELIMITERS) {
+                               validateLineDelimiters(contents);
+                       }
+                       
+                       int newLength= contents.length();
+                       if (oldLength != newLength || !contents.equals(fDocument.get()))
+                               fSetCmd.set(contents);
+                       
+               }
+       }
+
+       private void validateLineDelimiters(String contents) {
+
+               if (fLegalLineDelimiters == null) {
+                       // collect all line delimiters in the document
+                       HashSet<String> existingDelimiters= new HashSet<String>();
+
+                       for (int i= fDocument.getNumberOfLines() - 1; i >= 0; i-- ) {
+                               try {
+                                       String curr= fDocument.getLineDelimiter(i);
+                                       if (curr != null) {
+                                               existingDelimiters.add(curr);
+                                       }
+                               } catch (BadLocationException e) {
+                                       CUIPlugin.log(e);
+                               }
+                       }
+                       if (existingDelimiters.isEmpty()) {
+                               return; // first insertion of a line delimiter: no test
+                       }
+                       fLegalLineDelimiters= existingDelimiters;
+                       
+               }
+               
+               DefaultLineTracker tracker= new DefaultLineTracker();
+               tracker.set(contents);
+               
+               int lines= tracker.getNumberOfLines();
+               if (lines <= 1)
+                       return;
+               
+               for (int i= 0; i < lines; i++) {
+                       try {
+                               String curr= tracker.getLineDelimiter(i);
+                               if (curr != null && !fLegalLineDelimiters.contains(curr)) {
+                                       StringBuffer buf= new StringBuffer("New line delimiter added to new code: "); //$NON-NLS-1$
+                                       for (int k= 0; k < curr.length(); k++) {
+                                               buf.append(String.valueOf((int) curr.charAt(k)));
+                                       }
+                                       CUIPlugin.log(new Exception(buf.toString()));
+                               }
+                       } catch (BadLocationException e) {
+                               CUIPlugin.log(e);
+                       }
+               }
+       }
+
+       /*
+        * @see IDocumentListener#documentAboutToBeChanged(DocumentEvent)
+        */
+       public void documentAboutToBeChanged(DocumentEvent event) {
+               // there is nothing to do here
+       }
+
+       /*
+        * @see IDocumentListener#documentChanged(DocumentEvent)
+        */
+       public void documentChanged(DocumentEvent event) {
+               fireBufferChanged(new BufferChangedEvent(this, event.getOffset(), event.getLength(), event.getText()));
+       }
+       
+       private void fireBufferChanged(BufferChangedEvent event) {
+               if (fBufferListeners != null && fBufferListeners.size() > 0) {
+                       Iterator<IBufferChangedListener> e= new ArrayList<IBufferChangedListener>(fBufferListeners).iterator();
+                       while (e.hasNext())
+                               e.next().bufferChanged(event);
+               }
+       }
+
+       @SuppressWarnings({ "unchecked", "rawtypes" })
+       public Object getAdapter(Class adapter) {
+               if (adapter.isAssignableFrom(ITextFileBuffer.class)) {
+                       return fTextFileBuffer;
+               } else if (adapter.isAssignableFrom(IDocument.class)) {
+                       return fDocument;
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/EclipsePreferencesAdapter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/EclipsePreferencesAdapter.java
new file mode 100644 (file)
index 0000000..3527c58
--- /dev/null
@@ -0,0 +1,316 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.widgets.Display;
+import org.osgi.service.prefs.BackingStoreException;
+
+/**
+ * Adapts an options {@link IEclipsePreferences} to {@link org.eclipse.jface.preference.IPreferenceStore}.
+ * <p>
+ * This preference store is read-only i.e. write access
+ * throws an {@link java.lang.UnsupportedOperationException}.
+ * </p>
+ */
+class EclipsePreferencesAdapter implements IPreferenceStore {
+
+       /**
+        * Preference change listener. Listens for events preferences
+        * fires a {@link org.eclipse.jface.util.PropertyChangeEvent}
+        * on this adapter with arguments from the received event.
+        */
+       private class PreferenceChangeListener implements IEclipsePreferences.IPreferenceChangeListener {
+
+               /**
+                * {@inheritDoc}
+                */
+               public void preferenceChange(final IEclipsePreferences.PreferenceChangeEvent event) {
+                       if (Display.getCurrent() == null) {
+                               Display.getDefault().asyncExec(new Runnable() {
+                                       public void run() {
+                                               firePropertyChangeEvent(event.getKey(), event.getOldValue(), event.getNewValue());
+                                       }
+                               });
+                       } else {
+                               firePropertyChangeEvent(event.getKey(), event.getOldValue(), event.getNewValue());
+                       }
+               }
+       }
+
+       /** Listeners on on this adapter */
+       private ListenerList fListeners= new ListenerList(ListenerList.IDENTITY);
+
+       /** Listener on the node */
+       private IEclipsePreferences.IPreferenceChangeListener fListener= new PreferenceChangeListener();
+
+       /** wrapped node */
+       private final IScopeContext fContext;
+       private final String fQualifier;
+
+       /**
+        * Initialize with the node to wrap
+        *
+        * @param context the context to access
+        * @param qualifier the qualifier
+        */
+       public EclipsePreferencesAdapter(IScopeContext context, String qualifier) {
+               fContext= context;
+               fQualifier= qualifier;
+       }
+
+       private IEclipsePreferences getNode() {
+               return fContext.getNode(fQualifier);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void addPropertyChangeListener(IPropertyChangeListener listener) {
+               if (fListeners.size() == 0)
+                       getNode().addPreferenceChangeListener(fListener);
+               fListeners.add(listener);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void removePropertyChangeListener(IPropertyChangeListener listener) {
+               fListeners.remove(listener);
+               if (fListeners.size() == 0) {
+                       getNode().removePreferenceChangeListener(fListener);
+               }
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public boolean contains(String name) {
+               return getNode().get(name, null) != null;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {
+               PropertyChangeEvent event= new PropertyChangeEvent(this, name, oldValue, newValue);
+               Object[] listeners= fListeners.getListeners();
+               for (int i= 0; i < listeners.length; i++)
+                       ((IPropertyChangeListener) listeners[i]).propertyChange(event);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public boolean getBoolean(String name) {
+               return getNode().getBoolean(name, BOOLEAN_DEFAULT_DEFAULT);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public boolean getDefaultBoolean(String name) {
+               return BOOLEAN_DEFAULT_DEFAULT;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public double getDefaultDouble(String name) {
+               return DOUBLE_DEFAULT_DEFAULT;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public float getDefaultFloat(String name) {
+               return FLOAT_DEFAULT_DEFAULT;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public int getDefaultInt(String name) {
+               return INT_DEFAULT_DEFAULT;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public long getDefaultLong(String name) {
+               return LONG_DEFAULT_DEFAULT;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public String getDefaultString(String name) {
+               return STRING_DEFAULT_DEFAULT;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public double getDouble(String name) {
+               return getNode().getDouble(name, DOUBLE_DEFAULT_DEFAULT);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public float getFloat(String name) {
+               return getNode().getFloat(name, FLOAT_DEFAULT_DEFAULT);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public int getInt(String name) {
+               return getNode().getInt(name, INT_DEFAULT_DEFAULT);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public long getLong(String name) {
+               return getNode().getLong(name, LONG_DEFAULT_DEFAULT);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public String getString(String name) {
+               return getNode().get(name, STRING_DEFAULT_DEFAULT);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public boolean isDefault(String name) {
+               return false;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public boolean needsSaving() {
+               try {
+                       return getNode().keys().length > 0;
+               } catch (BackingStoreException e) {
+                       // ignore
+               }
+               return true;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void putValue(String name, String value) {
+               throw new UnsupportedOperationException();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void setDefault(String name, double value) {
+               throw new UnsupportedOperationException();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void setDefault(String name, float value) {
+               throw new UnsupportedOperationException();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void setDefault(String name, int value) {
+               throw new UnsupportedOperationException();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void setDefault(String name, long value) {
+               throw new UnsupportedOperationException();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void setDefault(String name, String defaultObject) {
+               throw new UnsupportedOperationException();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void setDefault(String name, boolean value) {
+               throw new UnsupportedOperationException();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void setToDefault(String name) {
+               throw new UnsupportedOperationException();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void setValue(String name, double value) {
+               throw new UnsupportedOperationException();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void setValue(String name, float value) {
+               throw new UnsupportedOperationException();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void setValue(String name, int value) {
+               throw new UnsupportedOperationException();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void setValue(String name, long value) {
+               throw new UnsupportedOperationException();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void setValue(String name, String value) {
+               throw new UnsupportedOperationException();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void setValue(String name, boolean value) {
+               throw new UnsupportedOperationException();
+       }
+
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/EditorHighlightingSynchronizer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/EditorHighlightingSynchronizer.java
new file mode 100644 (file)
index 0000000..b4906f4
--- /dev/null
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import org.eclipse.core.runtime.Assert;
+
+import org.eclipse.jface.text.link.ILinkedModeListener;
+import org.eclipse.jface.text.link.LinkedModeModel;
+
+
+/**
+ * Turns off occurrences highlighting on a C editor until linked mode is
+ * left.
+ *
+ * @since 5.0
+ */
+public class EditorHighlightingSynchronizer implements ILinkedModeListener {
+
+       private final CEditor fEditor;
+       private final boolean fWasOccurrencesOn;
+
+       /**
+        * Creates a new synchronizer.
+        *
+        * @param editor the editor the occurrences markers of which will be
+        *        synchronized with the linked mode
+        */
+       public EditorHighlightingSynchronizer(CEditor editor) {
+               Assert.isLegal(editor != null);
+               fEditor= editor;
+               fWasOccurrencesOn= fEditor.isMarkingOccurrences();
+
+               if (fWasOccurrencesOn && !isEditorDisposed())
+                       fEditor.uninstallOccurrencesFinder();
+       }
+
+       /*
+        * @see org.eclipse.jface.text.link.ILinkedModeListener#left(org.eclipse.jface.text.link.LinkedModeModel, int)
+        */
+       public void left(LinkedModeModel environment, int flags) {
+               if (fWasOccurrencesOn && !isEditorDisposed())
+                       fEditor.installOccurrencesFinder(true);
+       }
+
+       private boolean isEditorDisposed() {
+               return fEditor == null || fEditor.getSelectionProvider() == null;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.link.ILinkedModeListener#suspend(org.eclipse.jface.text.link.LinkedModeModel)
+        */
+       public void suspend(LinkedModeModel environment) {
+       }
+
+       /*
+        * @see org.eclipse.jface.text.link.ILinkedModeListener#resume(org.eclipse.jface.text.link.LinkedModeModel, int)
+        */
+       public void resume(LinkedModeModel environment, int flags) {
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ExternalSearchAnnotationModel.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ExternalSearchAnnotationModel.java
new file mode 100644 (file)
index 0000000..1a4b3ea
--- /dev/null
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Rational Software - Initial Contribution
+ *     Norbert Ploett (Siemens AG)
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.ui.texteditor.ResourceMarkerAnnotationModel;
+
+import org.eclipse.cdt.core.model.ICModelMarker;
+
+public class ExternalSearchAnnotationModel extends ResourceMarkerAnnotationModel {
+
+       private final IPath fLocation;
+       private final int fDepth;
+       private final String fLocationAttribute;
+       
+       /**
+        * @param markerResource
+        * @param location
+        */
+       public ExternalSearchAnnotationModel(IResource markerResource, IPath location) {
+               this(markerResource, location, IResource.DEPTH_ZERO, ICModelMarker.C_MODEL_MARKER_EXTERNAL_LOCATION);
+       }
+
+       /**
+        * @param markerResource
+        * @param location
+        * @param depth
+        */
+       ExternalSearchAnnotationModel(IResource markerResource, IPath location, int depth) {
+               this(markerResource, location, depth, ICModelMarker.C_MODEL_MARKER_EXTERNAL_LOCATION);
+       }
+
+       /**
+        * @param markerResource
+        * @param location
+        * @param depth
+        * @param locationAttribute
+        */
+       ExternalSearchAnnotationModel(IResource markerResource,
+                       IPath location, int depth, String locationAttribute) {
+               super(markerResource);
+               fLocation= location;
+               fDepth= depth;
+               fLocationAttribute= locationAttribute;
+       }
+
+       @Override
+       protected IMarker[] retrieveMarkers() throws CoreException {
+               IMarker[] markers = null;
+               if (getResource() != null) {
+                       markers = getResource().findMarkers(IMarker.MARKER, true, fDepth);
+               }
+               return markers;
+       }
+
+       @Override
+       protected boolean isAcceptable(IMarker marker) {
+               boolean acceptable = false;
+               String externalFileName = marker.getAttribute(fLocationAttribute, null);
+               if (externalFileName != null) { // Only accept markers with external
+                                                                               // paths set
+                       IPath externalPath = new Path(externalFileName);
+                       acceptable = externalPath.equals(fLocation); // Only accept
+                                                                                                                       // markers for this
+                                                                                                                       // annotation
+                                                                                                                       // model's external
+                                                                                                                       // editor
+               }
+               return acceptable;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ExternalSearchDocumentProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ExternalSearchDocumentProvider.java
new file mode 100644 (file)
index 0000000..17dab01
--- /dev/null
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Norbert Ploett (Siemens AG)
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import java.net.URI;
+
+import org.eclipse.core.filesystem.URIUtil;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.text.source.AnnotationModel;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.ui.IPathEditorInput;
+import org.eclipse.ui.IStorageEditorInput;
+import org.eclipse.ui.editors.text.ILocationProvider;
+import org.eclipse.ui.editors.text.ILocationProviderExtension;
+import org.eclipse.ui.editors.text.TextFileDocumentProvider;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
+
+public class ExternalSearchDocumentProvider extends TextFileDocumentProvider {
+       
+       public ExternalSearchDocumentProvider() {
+               super(new CStorageDocumentProvider());
+       }
+
+       /*
+        * @see org.eclipse.ui.editors.text.TextFileDocumentProvider#createFileInfo(java.lang.Object)
+        */
+       @Override
+       protected FileInfo createFileInfo(Object element) throws CoreException {
+               final FileInfo info= super.createFileInfo(element);
+               if (info != null && info.fModel == null) {
+                       info.fModel= createAnnotationModel(element);
+                       if (info.fModel != null) {
+                               IAnnotationModel fileBufferAnnotationModel= info.fTextFileBuffer.getAnnotationModel();
+                               if (fileBufferAnnotationModel != null) {
+                                       ((AnnotationModel)info.fModel).addAnnotationModel("fileBufferModel", fileBufferAnnotationModel); //$NON-NLS-1$
+                               }
+                               setUpSynchronization(info);
+                       }
+               }
+               return info;
+       }
+
+
+       protected IAnnotationModel createAnnotationModel(Object element) throws CoreException {
+               if (element instanceof ExternalEditorInput) {
+                       return createExternalSearchAnnotationModel((ExternalEditorInput)element);
+               }
+               if (element instanceof IStorageEditorInput) {
+                       IStorage storage= ((IStorageEditorInput)element).getStorage();
+                       if (storage.getFullPath() != null) {
+                               return createExternalSearchAnnotationModel(storage.getFullPath(), null);
+                       }
+               }
+               if (element instanceof IPathEditorInput) {
+                       IPath location = ((IPathEditorInput) element).getPath();
+                       if (location != null) {
+                               return createExternalSearchAnnotationModel(location, null);
+                       }
+               }
+               if (element instanceof IAdaptable) {
+                       IAdaptable adaptable= (IAdaptable) element;
+                       ILocationProvider provider = (ILocationProvider) adaptable.getAdapter(ILocationProvider.class);
+                       if (provider != null) {
+                               IPath location = provider.getPath(element);
+                               if (location != null) {
+                                       return createExternalSearchAnnotationModel(location, null);
+                               }
+                               if (provider instanceof ILocationProviderExtension) {
+                                       ILocationProviderExtension extendedProvider = (ILocationProviderExtension) provider;
+                                       URI uri = extendedProvider.getURI(element);
+                                       location = URIUtil.toPath(uri);
+                                       if (location != null) {
+                                               return createExternalSearchAnnotationModel(location, null);
+                                       }
+                               }
+                       }
+               }
+               return null;
+       }
+
+       /**
+        * Create an annotation model for the given {@link ExternalEditorInput}.
+        * 
+        * @param externalInput
+        * @return  a new annotation model for the external editor input
+        */
+       private IAnnotationModel createExternalSearchAnnotationModel(ExternalEditorInput externalInput) {
+               IPath location = externalInput.getPath();
+               if (location != null) {
+                       IResource markerResource = externalInput.getMarkerResource();
+                       return createExternalSearchAnnotationModel(location, markerResource);
+               }
+               return null;
+       }
+       
+       /**
+        * Create an annotation model for the given file and associated resource marker.
+        * 
+        * @param location  the local file system location
+        * @param markerResource  the resource to retrieve markers from, may be <code>null</code>
+        * @return  a new annotation model for the file
+        */
+       private IAnnotationModel createExternalSearchAnnotationModel(IPath location, IResource markerResource) {
+               AnnotationModel model= null;
+               if (markerResource != null){
+                       model = new ExternalSearchAnnotationModel(markerResource, location);
+               } else {
+                       // no marker resource available - search workspace root and all project resources (depth one)
+                       markerResource= CUIPlugin.getWorkspace().getRoot();
+                       model = new ExternalSearchAnnotationModel(markerResource, location, IResource.DEPTH_ONE);
+               }
+               return model;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/GotoAnnotationAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/GotoAnnotationAction.java
new file mode 100644 (file)
index 0000000..36342ca
--- /dev/null
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.editor;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.TextEditorAction;
+
+
+
+public class GotoAnnotationAction extends TextEditorAction {
+               
+       private boolean fForward;
+       
+       public GotoAnnotationAction(String prefix, boolean forward) {
+               super(ConstructedCEditorMessages.getResourceBundle(), prefix, null);
+               fForward= forward;
+               if (forward)
+                       PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.GOTO_NEXT_ERROR_ACTION);
+               else
+                       PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.GOTO_PREVIOUS_ERROR_ACTION);
+       }
+       
+       @Override
+       public void run() {
+               CEditor e= (CEditor) getTextEditor();
+               e.gotoAnnotation(fForward);
+       }
+       
+       @Override
+       public void setEditor(ITextEditor editor) {
+               if (editor instanceof CEditor) 
+                       super.setEditor(editor);
+               update();
+       }
+       
+       @Override
+       public void update() {
+               setEnabled(getTextEditor() instanceof CEditor);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/GotoMatchingBracketAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/GotoMatchingBracketAction.java
new file mode 100644 (file)
index 0000000..3b56ae3
--- /dev/null
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.editor;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.core.runtime.Assert;
+
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+
+
+public class GotoMatchingBracketAction extends Action {
+
+       public final static String GOTO_MATCHING_BRACKET= "GotoMatchingBracket"; //$NON-NLS-1$
+       
+       private final CEditor fEditor;
+       
+       public GotoMatchingBracketAction(CEditor editor) {
+               super(CEditorMessages.GotoMatchingBracket_label); 
+               Assert.isNotNull(editor);
+               fEditor= editor;
+               setEnabled(true);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.GOTO_MATCHING_BRACKET_ACTION);
+       }
+       
+       @Override
+       public void run() {
+               fEditor.gotoMatchingBracket();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICAnnotation.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICAnnotation.java
new file mode 100644 (file)
index 0000000..e48dc19
--- /dev/null
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.editor;
+
+import java.util.Iterator;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+/**
+ * ICAnnotation
+ *
+ * Interface of annotations representing markers
+ * and problems.
+ * 
+ * @see org.eclipse.core.resources.IMarker
+ * @see org.eclipse.cdt.core.parser.IProblem
+ */
+public interface ICAnnotation {
+       
+       /**
+        * @see org.eclipse.jface.text.source.Annotation#getType()
+        */
+       String getType();
+       
+       /**
+        * @see org.eclipse.jface.text.source.Annotation#isPersistent()
+        */
+       boolean isPersistent();
+       
+       /**
+        * @see org.eclipse.jface.text.source.Annotation#isMarkedDeleted()
+        */
+       boolean isMarkedDeleted();
+       
+       /**
+        * @see org.eclipse.jface.text.source.Annotation#getText() 
+        */
+       String getText();
+       
+       /**
+        * Returns whether this annotation is overlaid.
+        * 
+        * @return <code>true</code> if overlaid
+        */
+       boolean hasOverlay();
+       
+       /**
+        * Returns the overlay of this annotation.
+        * 
+        * @return the annotation's overlay
+        */
+       ICAnnotation getOverlay();
+       
+       /**
+        * Returns an iterator for iterating over the
+        * annotation which are overlaid by this annotation.
+        * 
+        * @return an iterator over the overlaid annotations
+        */
+       Iterator<ICAnnotation> getOverlaidIterator();
+       
+       /**
+        * Adds the given annotation to the list of
+        * annotations which are overlaid by this annotations.
+        *  
+        * @param annotation    the problem annotation
+        */
+       void addOverlaid(ICAnnotation annotation);
+       
+       /**
+        * Removes the given annotation from the list of
+        * annotations which are overlaid by this annotation.
+        *  
+        * @param annotation    the problem annotation
+        */
+       void removeOverlaid(ICAnnotation annotation);
+       
+       /**
+        * Tells whether this annotation is a problem
+        * annotation.
+        * 
+        * @return <code>true</code> if it is a problem annotation
+        */
+       boolean isProblem();
+       
+       /**
+        * Returns the compilation unit corresponding to the document on which the annotation is set
+        * or <code>null</code> if no corresponding co0mpilationunit exists.
+        */
+       ITranslationUnit getTranslationUnit();
+       
+       String[] getArguments();
+       
+       int getId();
+
+       /**
+        * Returns the marker type associated to this problem or <code>null<code> if no marker type
+        * can be evaluated. See also {@link org.eclipse.cdt.ui.text.IProblemLocation#getMarkerType()}.
+        * 
+        * @return the type of the marker which would be associated to the problem or
+        * <code>null<code> if no marker type can be evaluated. 
+        */
+       String getMarkerType();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICEditorActionDefinitionIds.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ICEditorActionDefinitionIds.java
new file mode 100644 (file)
index 0000000..80025ab
--- /dev/null
@@ -0,0 +1,281 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     IBM Corporation
+ *     Markus Schorn (Wind River Systems)
+ *     Anton Leherbauer (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *     Tomasz Wesolowski
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.editor;
+
+import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
+
+/**
+ * Defines the definition IDs for the C editor actions.
+ *
+ * @since 2.1
+ *
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
+*/
+public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinitionIds {
+
+       /**
+        * Action definition ID of the source -> toggle comment action
+        * (value <code>"org.eclipse.cdt.ui.edit.text.c.toggle.comment"</code>).
+        * @since 4.0.0
+        */
+       public static final String TOGGLE_COMMENT= "org.eclipse.cdt.ui.edit.text.c.toggle.comment"; //$NON-NLS-1$
+       
+       /**
+        * Action definition ID of the source -> add block comment action
+        * (value <code>"org.eclipse.cdt.ui.edit.text.c.add.block.comment"</code>).
+        * @since 3.0
+        */
+       public static final String ADD_BLOCK_COMMENT= "org.eclipse.cdt.ui.edit.text.c.add.block.comment"; //$NON-NLS-1$
+
+       /**
+        * Action definition ID of the source -> remove block comment action
+        * (value <code>"org.eclipse.cdt.ui.edit.text.c.remove.block.comment"</code>).
+        * @since 3.0
+        */
+       public static final String REMOVE_BLOCK_COMMENT= "org.eclipse.cdt.ui.edit.text.c.remove.block.comment"; //$NON-NLS-1$
+       
+       /**
+        * Action definition ID of the source -> join lines action
+        * (value <code>"org.eclipse.cdt.ui.edit.text.c.join.lines"</code>).
+        * @since 3.0.2
+        */
+       public static final String JOIN_LINES= "org.eclipse.cdt.ui.edit.text.c.join.lines"; //$NON-NLS-1$
+       
+       /**
+        * Action definition ID of the source -> indent action
+        * (value <code>"org.eclipse.cdt.ui.edit.text.c.indent"</code>).
+        */
+       public static final String INDENT = "org.eclipse.cdt.ui.edit.text.c.indent"; //$NON-NLS-1$
+       
+       /**
+        * Action definition ID of the source -> format action
+        * (value <code>"org.eclipse.cdt.ui.edit.text.c.format"</code>).
+        */
+       public static final String FORMAT = "org.eclipse.cdt.ui.edit.text.c.format"; //$NON-NLS-1$
+
+       /**
+        * Action definition ID of the source -> add include action
+        * (value <code>"org.eclipse.cdt.ui.edit.text.c.add.include"</code>).
+        */
+       public static final String ADD_INCLUDE= "org.eclipse.cdt.ui.edit.text.c.add.include"; //$NON-NLS-1$     
+
+       /**
+        * Action definition ID of the open declaration action
+        * (value <code>"org.eclipse.cdt.ui.edit.opendecl"</code>).
+        */
+       public static final String OPEN_DECL= "org.eclipse.cdt.ui.edit.opendecl"; //$NON-NLS-1$
+    
+       /**
+        * Action definition ID of the show in C/C++ Projects View action
+        * (value <code>"org.eclipse.cdt.ui.edit.opencview"</code>).
+        */
+       public static final String OPEN_CVIEW= "org.eclipse.cdt.ui.edit.opencview"; //$NON-NLS-1$
+       
+       /**
+        * Action definition ID of the refactor -> rename element action
+        * (value <code>"org.eclipse.cdt.ui.edit.text.rename.element"</code>).
+        */
+       public static final String RENAME_ELEMENT= "org.eclipse.cdt.ui.edit.text.rename.element"; //$NON-NLS-1$
+
+       /**
+        * Action definition ID of the refactor -> extract constant action
+        * (value <code>"org.eclipse.cdt.ui.refactor.extract.constant"</code>).
+        */
+       public static final String EXTRACT_CONSTANT= "org.eclipse.cdt.ui.refactor.extract.constant"; //$NON-NLS-1$
+
+       /**
+        * Action definition ID of the refactor -> extract local variable action
+        * (value <code>"org.eclipse.cdt.ui.refactor.extract.local.variable"</code>).
+        */
+       public static final String EXTRACT_LOCAL_VARIABLE= "org.eclipse.cdt.ui.refactor.extract.local.variable"; //$NON-NLS-1$
+       
+       /**
+        * Action definition ID of the refactor -> extract function action (value
+        * <code>"org.eclipse.cdt.ui.refactor.extract.function"</code>).
+        */
+       public static final String EXTRACT_FUNCTION = "org.eclipse.cdt.ui.refactor.extract.function"; //$NON-NLS-1$
+
+       /**
+        * Action definition ID of the refactor -> toggle function action (value
+        * <code>"org.eclipse.cdt.ui.refactor.toggle.function"</code>).
+        */
+       public static final String TOGGLE_FUNCTION = "org.eclipse.cdt.ui.refactor.toggle.function"; //$NON-NLS-1$
+
+       /**
+        * Action definition ID of the refactor -> hide method action
+        * (value <code>"org.eclipse.cdt.ui.refactor.hide.method"</code>).
+        */
+       public static final String HIDE_METHOD= "org.eclipse.cdt.ui.refactor.hide.method"; //$NON-NLS-1$
+       
+       /**
+        * Action definition ID of the refactor -> implement method action
+        * (value <code>"org.eclipse.cdt.ui.refactor.implement.method"</code>).
+        */
+       public static final String IMPLEMENT_METHOD= "org.eclipse.cdt.ui.refactor.implement.method"; //$NON-NLS-1$
+
+       /**
+        * Action definition ID of the refactor -> generate getters and setters
+        * (value <code>"org.eclipse.cdt.ui.refactor.getters.and.setters"</code>).
+        */
+       public static final String GETTERS_AND_SETTERS= "org.eclipse.cdt.ui.refactor.getters.and.setters"; //$NON-NLS-1$
+
+       /**
+        * Action definition ID of the refactor -> undo action
+        * (value <code>"org.eclipse.cdt.ui.edit.text.undo.action"</code>).
+        */
+       public static final String UNDO_ACTION= "org.eclipse.cdt.ui.edit.text.undo.action"; //$NON-NLS-1$
+       
+       /**
+        * Action definition ID of the refactor -> redo action
+        * (value <code>"org.eclipse.cdt.ui.edit.text.redo.action"</code>).
+        */
+       public static final String REDO_ACTION= "org.eclipse.cdt.ui.edit.text.redo.action"; //$NON-NLS-1$       
+
+       /**
+        * Action definition ID of the find references in workspace action
+        * (value <code>"org.eclipse.cdt.ui.search.findrefs"</code>).
+        */
+       public static final String FIND_REFS= "org.eclipse.cdt.ui.search.findrefs"; //$NON-NLS-1$       
+       
+       /**
+        * Action definition ID of the find declarations in workspace action
+        * (value <code>"org.eclipse.cdt.ui.search.finddecl"</code>).
+        */
+       public static final String FIND_DECL= "org.eclipse.cdt.ui.search.finddecl"; //$NON-NLS-1$       
+
+       /**
+        * Action definition ID of the navigate -> open type hierarchy action
+        * (value <code>"org.eclipse.cdt.ui.edit.text.c.open.type.hierarchy"</code>).
+        */
+       public static final String OPEN_TYPE_HIERARCHY= "org.eclipse.cdt.ui.edit.open.type.hierarchy"; //$NON-NLS-1$
+
+       /**
+        * Action definition ID of the navigate -> open type hierarchy action
+        * (value <code>"org.eclipse.cdt.ui.edit.text.c.open.quick.type.hierarchy"</code>).
+        */
+       public static final String OPEN_QUICK_TYPE_HIERARCHY= "org.eclipse.cdt.ui.edit.open.quick.type.hierarchy"; //$NON-NLS-1$
+
+       /**
+        * Action definition ID of the navigate -> open action
+        * (value <code>"org.eclipse.cdt.ui.edit.text.c.open.editor"</code>).
+        */
+       public static final String OPEN_EDITOR= "org.eclipse.cdt.ui.edit.text.c.open.editor"; //$NON-NLS-1$
+
+       /**
+        * Action definition ID of the open quick outline.
+        * (value <code>"org.eclipse.cdt.ui.edit.open.outline"</code>).
+        */
+       public static final String OPEN_OUTLINE= "org.eclipse.cdt.ui.edit.open.outline"; //$NON-NLS-1$
+
+       /**
+        * Action definition ID for opening the call hierarchy.
+        * (value <code>"org.eclipse.cdt.ui.edit.open.call.hierarchy"</code>).
+        */
+       public static final String OPEN_CALL_HIERARCHY= "org.eclipse.cdt.ui.edit.open.call.hierarchy"; //$NON-NLS-1$
+
+       /**
+        * Action definition ID for opening the include browser.
+        * (value <code>"org.eclipse.cdt.ui.edit.open.include.browser"</code>).
+        */
+       public static final String OPEN_INCLUDE_BROWSER= "org.eclipse.cdt.ui.edit.open.include.browser"; //$NON-NLS-1$
+
+       /**
+        * Action definition ID for go to next c member.
+        * (value <code>"org.eclipse.cdt.ui.edit.text.c.goto.next.memeber"</code>)
+        */
+       public static final String GOTO_NEXT_MEMBER = "org.eclipse.cdt.ui.edit.text.c.goto.next.member"; //$NON-NLS-1$
+
+       /**
+        * Action definition ID for go to previous c member.
+        * (value <code>"org.eclipse.cdt.ui.edit.text.c.goto.prev.memeber"</code>)
+        */
+       public static final String GOTO_PREVIOUS_MEMBER = "org.eclipse.cdt.ui.edit.text.c.goto.prev.member"; //$NON-NLS-1$
+
+       /**
+        * Action definition ID of the edit -> go to matching bracket action
+        * (value <code>"org.eclipse.cdt.ui.edit.text.c.goto.matching.bracket"</code>).
+        *
+        * @since 3.0
+        */
+       public static final String GOTO_MATCHING_BRACKET= "org.eclipse.cdt.ui.edit.text.c.goto.matching.bracket"; //$NON-NLS-1$
+
+       /**
+        * Action definition ID for goto next bookmark action
+        * (value <code>"org.eclipse.cdt.ui.edit.text.c.goto.next.bookmark"</code>).
+        */
+       public static final String GOTO_NEXT_BOOKMARK = "org.eclipse.cdt.ui.edit.text.c.goto.next.bookmark"; //$NON-NLS-1$      
+
+       /**
+        * Action definition ID for find word action
+        * (value <code>"org.eclipse.cdt.ui.edit.text.c.find.word"</code>).
+        */
+       public static final String FIND_WORD = "org.eclipse.cdt.ui.edit.text.c.find.word"; //$NON-NLS-1$        
+
+       /**
+        * Action definition ID for toggle source/header action.
+        * (value <code>"org.eclipse.cdt.ui.edit.text.c.toggle.source.header"</code>)
+        * 
+        * @since 4.0
+        */
+       public static final String TOGGLE_SOURCE_HEADER = "org.eclipse.cdt.ui.edit.text.c.toggle.source.header"; //$NON-NLS-1$
+
+       /**
+        * Action definition id of toggle mark occurrences action
+        * (value: <code>"org.eclipse.cdt.ui.edit.text.c.toggleMarkOccurrences"</code>).
+        * @since 5.0
+        */
+       public static final String TOGGLE_MARK_OCCURRENCES= "org.eclipse.cdt.ui.edit.text.c.toggleMarkOccurrences"; //$NON-NLS-1$
+
+       /**
+        * Action definition ID of the open macro explorer quick view action
+        * (value <code>"org.eclipse.cdt.ui.edit.open.quick.macro.explorer"</code>).
+        * @since 5.0
+        */
+       public static final String OPEN_QUICK_MACRO_EXPLORER = "org.eclipse.cdt.ui.edit.open.quick.macro.explorer"; //$NON-NLS-1$
+
+       /**
+        * Action definition id of sort lines action.
+        * (value: <code>"org.eclipse.cdt.ui.edit.text.c.sort.lines"</code>).
+        * @since 5.2
+        */
+       public static final String SORT_LINES = "org.eclipse.cdt.ui.edit.text.c.sort.lines"; //$NON-NLS-1$
+
+       /**
+        * Action definition ID of the edit -> select enclosing action
+        * (value <code>"org.eclipse.cdt.ui.edit.text.c.select.enclosing"</code>).
+        */
+       public static final String SELECT_ENCLOSING = "org.eclipse.cdt.ui.edit.text.c.select.enclosing"; //$NON-NLS-1$
+       
+       /**
+        * Action definition ID of the edit -> select next action
+        * (value <code>"org.eclipse.cdt.ui.edit.text.c.select.next"</code>).
+        */
+       public static final String SELECT_NEXT = "org.eclipse.cdt.ui.edit.text.c.select.next"; //$NON-NLS-1$
+       
+       /**
+        * Action definition ID of the edit -> select previous action
+        * (value <code>"org.eclipse.cdt.ui.edit.text.c.select.previous"</code>).
+        */
+       public static final String SELECT_PREVIOUS = "org.eclipse.cdt.ui.edit.text.c.select.previous"; //$NON-NLS-1$
+       
+       /**
+        * Action definition ID of the edit -> select restore last action
+        * (value <code>"org.eclipse.cdt.ui.edit.text.c.select.last"</code>).
+        */
+       public static final String SELECT_LAST = "org.eclipse.cdt.ui.edit.text.c.select.last"; //$NON-NLS-1$
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IProblemAnnotation.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IProblemAnnotation.java
new file mode 100644 (file)
index 0000000..9eafd57
--- /dev/null
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+/**
+ * Interface of annotations representing problems.
+ */
+public interface IProblemAnnotation {
+       
+       String getMessage();
+       
+       int getId();
+       
+       String[] getArguments();
+       
+       boolean isTemporaryProblem();
+       
+       boolean isWarning();
+       
+       boolean isError();
+       
+       boolean isProblem();
+}
+
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ITranslationUnitEditorInput.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ITranslationUnitEditorInput.java
new file mode 100644 (file)
index 0000000..cb56529
--- /dev/null
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+/**
+ * ITranslationUnitEditorInput
+ */
+public interface ITranslationUnitEditorInput {
+
+       ITranslationUnit getTranslationUnit();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/InactiveCodeHighlighting.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/InactiveCodeHighlighting.java
new file mode 100644 (file)
index 0000000..861aa0a
--- /dev/null
@@ -0,0 +1,352 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.EmptyStackException;
+import java.util.List;
+import java.util.Stack;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextInputListener;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.TypedPosition;
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorElifStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorElseStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorEndifStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIfStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIfdefStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIfndefStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.model.ASTCache;
+
+import org.eclipse.cdt.internal.ui.LineBackgroundPainter;
+import org.eclipse.cdt.internal.ui.text.ICReconcilingListener;
+
+/**
+ * Paints code lines disabled by preprocessor directives (#ifdef etc.)
+ * with a configurable background color (default light gray).
+ * 
+ * @see LineBackgroundPainter
+ * @since 4.0
+ */
+public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInputListener {
+
+       /**
+        * Implementation of <code>IRegion</code> that can be reused
+        * by setting the offset and the length.
+        */
+       private static class HighlightPosition extends TypedPosition implements IRegion {
+               public HighlightPosition(int offset, int length, String type) {
+                       super(offset, length, type);
+               }
+               public HighlightPosition(IRegion region, String type) {
+                       super(region.getOffset(), region.getLength(), type);
+               }
+       }
+
+
+       /** The line background painter */
+       private LineBackgroundPainter fLineBackgroundPainter;
+       /** The key for inactive code positions in the background painter */
+       private String fHighlightKey;
+       /** The current translation unit */
+       private ITranslationUnit fTranslationUnit;
+       /** The background job doing the AST parsing */
+       private Job fUpdateJob;
+       /** The lock for job manipulation */
+       private Object fJobLock = new Object();
+       /** The editor this is installed on */
+       private CEditor fEditor;
+       /** The list of currently highlighted positions */
+       private List<Position> fInactiveCodePositions= Collections.emptyList();
+       private IDocument fDocument;
+
+       /**
+        * Create a highlighter for the given key.
+        * @param highlightKey
+        */
+       public InactiveCodeHighlighting(String highlightKey) {
+               fHighlightKey= highlightKey;
+       }
+
+       /**
+        * Schedule update of the inactive code positions in the background.
+        */
+       private void scheduleJob() {
+               synchronized (fJobLock) {
+                       if (fUpdateJob == null) {
+                               fUpdateJob = new Job(CEditorMessages.InactiveCodeHighlighting_job) { 
+                                       @Override
+                                       protected IStatus run(final IProgressMonitor monitor) {
+                                               IStatus result = Status.OK_STATUS;
+                                               if (fTranslationUnit != null) {
+                                                       final ASTProvider astProvider= CUIPlugin.getDefault().getASTProvider();
+                                                       result= astProvider.runOnAST(fTranslationUnit, ASTProvider.WAIT_IF_OPEN, monitor, new ASTCache.ASTRunnable() {
+                                                               public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
+                                                                       reconciled(ast, true, monitor);
+                                                                       return Status.OK_STATUS;
+                                                               }
+                                                       });
+                                               }
+                                               if (monitor.isCanceled()) {
+                                                       result = Status.CANCEL_STATUS;
+                                               }
+                                               return result;
+                                       }
+                               };
+                               fUpdateJob.setPriority(Job.DECORATE);
+                       }
+                       if (fUpdateJob.getState() == Job.NONE) {
+                               fUpdateJob.schedule();
+                       }
+               }
+       }
+
+       /**
+        * Install this highlighting on the given editor and line background painter.
+        * 
+        * @param editor
+        * @param lineBackgroundPainter
+        */
+       public void install(CEditor editor, LineBackgroundPainter lineBackgroundPainter) {
+               assert fEditor == null;
+               assert editor != null && lineBackgroundPainter != null;
+               fEditor= editor;
+               fLineBackgroundPainter= lineBackgroundPainter;
+               ICElement cElement= fEditor.getInputCElement();
+               if (cElement instanceof ITranslationUnit) {
+                       fTranslationUnit = (ITranslationUnit)cElement;
+               } else {
+                       fTranslationUnit = null;
+               }
+               fDocument= fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
+               fEditor.getViewer().addTextInputListener(this);
+               fEditor.addReconcileListener(this);
+       }
+
+       /**
+        * Uninstall this highlighting from the editor. Does nothing if already uninstalled.
+        */
+       public void uninstall() {
+               synchronized (fJobLock) {
+                       if (fUpdateJob != null && fUpdateJob.getState() == Job.RUNNING) {
+                               fUpdateJob.cancel();
+                       }
+               }
+               if (fLineBackgroundPainter != null && !fLineBackgroundPainter.isDisposed()) {
+                       fLineBackgroundPainter.removeHighlightPositions(fInactiveCodePositions);
+                       fInactiveCodePositions= Collections.emptyList();
+                       fLineBackgroundPainter= null;
+               }
+               if (fEditor != null) {
+                       fEditor.removeReconcileListener(this);
+                       if (fEditor.getViewer() != null) {
+                               fEditor.getViewer().removeTextInputListener(this);
+                       }
+                       fEditor= null;
+                       fTranslationUnit= null;
+                       fDocument= null;
+               }
+       }
+
+       /**
+        * Force refresh.
+        */
+       public void refresh() {
+               scheduleJob();
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#aboutToBeReconciled()
+        */
+       public void aboutToBeReconciled() {
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#reconciled(IASTTranslationUnit, boolean, IProgressMonitor)
+        */
+       public void reconciled(IASTTranslationUnit ast, final boolean force, IProgressMonitor progressMonitor) {
+               if (progressMonitor != null && progressMonitor.isCanceled()) {
+                       return;
+               }
+               final List<Position> newInactiveCodePositions= collectInactiveCodePositions(ast);
+               Runnable updater = new Runnable() {
+                       public void run() {
+                               if (fEditor != null && fLineBackgroundPainter != null && !fLineBackgroundPainter.isDisposed()) {
+                                       fLineBackgroundPainter.replaceHighlightPositions(fInactiveCodePositions, newInactiveCodePositions);
+                                       fInactiveCodePositions= newInactiveCodePositions;
+                               }
+                       }
+               };
+               if (fEditor != null) {
+                       Display.getDefault().asyncExec(updater);
+               }
+       }
+
+       /**
+        * Collect source positions of preprocessor-hidden branches 
+        * in the given translation unit.
+        * 
+        * @param translationUnit  the {@link IASTTranslationUnit}, may be <code>null</code>
+        * @return a {@link List} of {@link IRegion}s
+        */
+       private List<Position> collectInactiveCodePositions(IASTTranslationUnit translationUnit) {
+               if (translationUnit == null) {
+                       return Collections.emptyList();
+               }
+               String fileName = translationUnit.getFilePath();
+               if (fileName == null) {
+                       return Collections.emptyList();
+               }
+               List<Position> positions = new ArrayList<Position>();
+               int inactiveCodeStart = -1;
+               boolean inInactiveCode = false;
+               Stack<Boolean> inactiveCodeStack = new Stack<Boolean>();
+
+               IASTPreprocessorStatement[] preprocStmts = translationUnit.getAllPreprocessorStatements();
+
+               for (IASTPreprocessorStatement statement : preprocStmts) {
+                       IASTFileLocation floc= statement.getFileLocation();
+                       if (floc == null || !fileName.equals(floc.getFileName())) {
+                               // preprocessor directive is from a different file
+                               continue;
+                       }
+                       if (statement instanceof IASTPreprocessorIfStatement) {
+                               IASTPreprocessorIfStatement ifStmt = (IASTPreprocessorIfStatement)statement;
+                               inactiveCodeStack.push(Boolean.valueOf(inInactiveCode));
+                               if (!ifStmt.taken()) {
+                                       if (!inInactiveCode) {
+                                               inactiveCodeStart = floc.getNodeOffset();
+                                               inInactiveCode = true;
+                                       }
+                               }
+                       } else if (statement instanceof IASTPreprocessorIfdefStatement) {
+                               IASTPreprocessorIfdefStatement ifdefStmt = (IASTPreprocessorIfdefStatement)statement;
+                               inactiveCodeStack.push(Boolean.valueOf(inInactiveCode));
+                               if (!ifdefStmt.taken()) {
+                                       if (!inInactiveCode) {
+                                               inactiveCodeStart = floc.getNodeOffset();
+                                               inInactiveCode = true;
+                                       }
+                               }
+                       } else if (statement instanceof IASTPreprocessorIfndefStatement) {
+                               IASTPreprocessorIfndefStatement ifndefStmt = (IASTPreprocessorIfndefStatement)statement;
+                               inactiveCodeStack.push(Boolean.valueOf(inInactiveCode));
+                               if (!ifndefStmt.taken()) {
+                                       if (!inInactiveCode) {
+                                               inactiveCodeStart = floc.getNodeOffset();
+                                               inInactiveCode = true;
+                                       }
+                               }
+                       } else if (statement instanceof IASTPreprocessorElseStatement) {
+                               IASTPreprocessorElseStatement elseStmt = (IASTPreprocessorElseStatement)statement;
+                               if (!elseStmt.taken() && !inInactiveCode) {
+                                       inactiveCodeStart = floc.getNodeOffset();
+                                       inInactiveCode = true;
+                               } else if (elseStmt.taken() && inInactiveCode) {
+                                       int inactiveCodeEnd = floc.getNodeOffset();
+                                       positions.add(createHighlightPosition(inactiveCodeStart, inactiveCodeEnd, false, fHighlightKey));
+                                       inInactiveCode = false;
+                               }
+                       } else if (statement instanceof IASTPreprocessorElifStatement) {
+                               IASTPreprocessorElifStatement elifStmt = (IASTPreprocessorElifStatement)statement;
+                               if (!elifStmt.taken() && !inInactiveCode) {
+                                       inactiveCodeStart = floc.getNodeOffset();
+                                       inInactiveCode = true;
+                               } else if (elifStmt.taken() && inInactiveCode) {
+                                       int inactiveCodeEnd = floc.getNodeOffset();
+                                       positions.add(createHighlightPosition(inactiveCodeStart, inactiveCodeEnd, false, fHighlightKey));
+                                       inInactiveCode = false;
+                               }
+                       } else if (statement instanceof IASTPreprocessorEndifStatement) {
+                               try {
+                                       boolean wasInInactiveCode = inactiveCodeStack.pop().booleanValue();
+                                       if (inInactiveCode && !wasInInactiveCode) {
+                                               int inactiveCodeEnd = floc.getNodeOffset() + floc.getNodeLength();
+                                               positions.add(createHighlightPosition(inactiveCodeStart, inactiveCodeEnd, true, fHighlightKey));
+                                       }
+                                       inInactiveCode = wasInInactiveCode;
+                               }
+                               catch( EmptyStackException e) {}
+                       }
+               }
+               if (inInactiveCode) {
+                       // handle unterminated #if - http://bugs.eclipse.org/255018
+                       int inactiveCodeEnd = fDocument.getLength();
+                       positions.add(createHighlightPosition(inactiveCodeStart, inactiveCodeEnd, true, fHighlightKey));
+               }
+               return positions;
+       }
+
+       /**
+        * Create a highlight position aligned to start at a line offset. The region's start is
+        * decreased to the line offset, and the end offset decreased to the line start if
+        * <code>inclusive</code> is <code>false</code>. 
+        * 
+        * @param startOffset  the start offset of the region to align
+        * @param endOffset  the (exclusive) end offset of the region to align
+        * @param inclusive whether  the last line should be included or not
+        * @param key  the highlight key
+        * @return a position aligned for background highlighting
+        */
+       private HighlightPosition createHighlightPosition(int startOffset, int endOffset, boolean inclusive, String key) {
+               final IDocument document= fDocument;
+               try {
+                       if (document != null) {
+                               int start= document.getLineOfOffset(startOffset);
+                               int end= document.getLineOfOffset(endOffset);
+                               startOffset= document.getLineOffset(start);
+                               if (!inclusive) {
+                                       endOffset= document.getLineOffset(end);
+                               }
+                       }
+               } catch (BadLocationException x) {
+                       // concurrent modification?
+               }
+               return new HighlightPosition(startOffset, endOffset - startOffset, key);
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.ITextInputListener#inputDocumentAboutToBeChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument)
+        */
+       public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
+               if (fEditor != null && fLineBackgroundPainter != null && !fLineBackgroundPainter.isDisposed()) {
+                       fLineBackgroundPainter.removeHighlightPositions(fInactiveCodePositions);
+                       fInactiveCodePositions= Collections.emptyList();
+               }
+       }
+
+       /*
+        * @see org.eclipse.jface.text.ITextInputListener#inputDocumentChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument)
+        */
+       public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
+               fDocument= newInput;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IndentUtil.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/IndentUtil.java
new file mode 100644 (file)
index 0000000..7718d02
--- /dev/null
@@ -0,0 +1,664 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin, Google
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.text.source.ILineRange;
+import org.eclipse.jface.text.source.LineRange;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
+
+import org.eclipse.cdt.internal.ui.text.CHeuristicScanner;
+import org.eclipse.cdt.internal.ui.text.CIndenter;
+
+
+/**
+ * Utility that indents a number of lines in a document.
+ */
+public final class IndentUtil {
+       
+       private static final String SLASHES= "//"; //$NON-NLS-1$
+
+       /**
+        * The result of an indentation operation. The result may be passed to
+        * subsequent calls to
+        * {@link IndentUtil#indentLines(IDocument, ILineRange, ICProject, IndentUtil.IndentResult) indentLines}
+        * to obtain consistent results with respect to the indentation of
+        * line-comments.
+        */
+       public static final class IndentResult {
+               private IndentResult(boolean[] commentLines) {
+                       commentLinesAtColumnZero= commentLines;
+               }
+               private boolean[] commentLinesAtColumnZero;
+               private boolean hasChanged;
+               private int leftmostLine= -1;
+               /**
+                * Returns <code>true</code> if the indentation operation changed the
+                * document, <code>false</code> if not.
+                * @return <code>true</code> if the document was changed
+                */
+               public boolean hasChanged() {
+                       return hasChanged;
+               }
+       }
+       
+       private IndentUtil() {
+               // do not instantiate
+       }
+
+       /**
+        * Indents the line range specified by <code>lines</code> in
+        * <code>document</code>. The passed C project may be
+        * <code>null</code>, it is used solely to obtain formatter preferences.
+        * 
+        * @param document the document to be changed
+        * @param lines the line range to be indented
+        * @param project the C project to get the formatter preferences from, or
+        *        <code>null</code> if global preferences should be used
+        * @param result the result from a previous call to <code>indentLines</code>,
+        *        in order to maintain comment line properties, or <code>null</code>.
+        *        Note that the passed result may be changed by the call.
+        * @return an indent result that may be queried for changes and can be
+        *         reused in subsequent indentation operations
+        * @throws BadLocationException if <code>lines</code> is not a valid line
+        *         range on <code>document</code>
+        */
+       public static IndentResult indentLines(IDocument document, ILineRange lines, ICProject project, IndentResult result) throws BadLocationException {
+               int numberOfLines= lines.getNumberOfLines();
+               
+               if (numberOfLines < 1)
+                       return new IndentResult(null);
+               
+               result= reuseOrCreateToken(result, numberOfLines);
+               
+               CHeuristicScanner scanner= new CHeuristicScanner(document);
+               CIndenter indenter= new CIndenter(document, scanner, project);
+               boolean changed= false;
+               int tabSize= CodeFormatterUtil.getTabWidth(project);
+               boolean indentInsideLineComments= indentInsideLineComments(project);
+               for (int line= lines.getStartLine(), last= line + numberOfLines, i= 0; line < last; line++) {
+                       changed |= indentLine(document, line, indenter, scanner, result.commentLinesAtColumnZero, i++, tabSize, indentInsideLineComments);
+               }
+               result.hasChanged= changed;
+               
+               return result;
+       }
+
+       /**
+        * Inserts <code>indent</code> string at the beginning of each line in <code>lines</code>.
+        * @param document the document to be changed.
+        * @param lines the line range to be indented.
+        * @param indent the indent string to be inserted.
+        * @throws BadLocationException if <code>lines</code> is not a valid line
+        *         range on <code>document</code>
+        */
+       public static void indentLines(IDocument document, LineRange lines, String indent) throws BadLocationException {
+               int numberOfLines= lines.getNumberOfLines();
+               for (int line= lines.getStartLine(), last= line + numberOfLines; line < last; line++) {
+                       int offset= document.getLineOffset(line);
+                       document.replace(offset, 0, indent);
+               }
+       }
+       
+       /**
+        * Returns <code>true</code> if line comments at column 0 should be indented inside, <code>false</code> otherwise.
+        * 
+        * @param project  the project to get project specific options from
+        * @return <code>true</code> if line comments at column 0 should be indented inside, <code>false</code> otherwise.
+        */
+       public static boolean indentInsideLineComments(ICProject project) {
+               return DefaultCodeFormatterConstants.TRUE.equals(getCoreOption(project, DefaultCodeFormatterConstants.FORMATTER_INDENT_INSIDE_LINE_COMMENTS));
+       }
+
+       /**
+        * Returns the possibly <code>project</code>-specific core preference
+        * defined under <code>key</code>.
+        * 
+        * @param project the project to get the preference from, or
+        *        <code>null</code> to get the global preference
+        * @param key the key of the preference
+        * @return the value of the preference
+        */
+       private static String getCoreOption(ICProject project, String key) {
+               if (project == null)
+                       return CCorePlugin.getOption(key);
+               return project.getOption(key, true);
+       }
+
+       /**
+        * Shifts the line range specified by <code>lines</code> in
+        * <code>document</code>. The amount that the lines get shifted
+        * are determined by the first line in the range, all subsequent
+        * lines are adjusted accordingly. The passed C project may be
+        * <code>null</code>, it is used solely to obtain formatter
+        * preferences.
+        * 
+        * @param document the document to be changed
+        * @param lines the line range to be shifted
+        * @param project the C project to get the formatter preferences
+        *        from, or <code>null</code> if global preferences should
+        *        be used
+        * @param result the result from a previous call to
+        *        <code>shiftLines</code>, in order to maintain comment
+        *        line properties, or <code>null</code>. Note that the
+        *        passed result may be changed by the call.
+        * @return an indent result that may be queried for changes and can
+        *         be reused in subsequent indentation operations
+        * @throws BadLocationException if <code>lines</code> is not a
+        *         valid line range on <code>document</code>
+        */
+       public static IndentResult shiftLines(IDocument document, ILineRange lines, ICProject project, IndentResult result) throws BadLocationException {
+               int numberOfLines= lines.getNumberOfLines();
+               
+               if (numberOfLines < 1)
+                       return new IndentResult(null);
+               
+               result= reuseOrCreateToken(result, numberOfLines);
+               result.hasChanged= false;
+               
+               CHeuristicScanner scanner= new CHeuristicScanner(document);
+               CIndenter indenter= new CIndenter(document, scanner, project);
+               
+               boolean indentInsideLineComments= indentInsideLineComments(project);
+               String current= getCurrentIndent(document, lines.getStartLine(), indentInsideLineComments);
+               StringBuilder correct= new StringBuilder(computeIndent(document, lines.getStartLine(), indenter, scanner));
+               
+               int tabSize= CodeFormatterUtil.getTabWidth(project);
+               StringBuilder addition= new StringBuilder();
+               int difference= subtractIndent(correct, current, addition, tabSize);
+               
+               if (difference == 0)
+                       return result;
+                       
+               if (result.leftmostLine == -1)
+                       result.leftmostLine= getLeftMostLine(document, lines, tabSize, indentInsideLineComments);
+               
+               int maxReduction= computeVisualLength(getCurrentIndent(document, result.leftmostLine + lines.getStartLine(), indentInsideLineComments), tabSize);
+               
+               if (difference > 0) {
+                       for (int line= lines.getStartLine(), last= line + numberOfLines, i= 0; line < last; line++)
+                               addIndent(document, line, addition, result.commentLinesAtColumnZero, i++, indentInsideLineComments);
+               } else {
+                       int reduction= Math.min(-difference, maxReduction);
+                       for (int line= lines.getStartLine(), last= line + numberOfLines, i= 0; line < last; line++)
+                               cutIndent(document, line, reduction, tabSize, result.commentLinesAtColumnZero, i++, indentInsideLineComments);
+               }
+                               
+               result.hasChanged= true;
+               
+               return result;
+               
+       }
+
+       /**
+        * Indents line <code>line</code> in <code>document</code> with <code>indent</code>.
+        * Leaves leading comment signs alone.
+        *
+        * @param document the document
+        * @param line the line
+        * @param indent the indentation to insert
+        * @param commentlines
+        * @param relative
+        * @param indentInsideLineComments option whether to indent inside line comments starting at column 0
+        * @throws BadLocationException on concurrent document modification
+        */
+       private static void addIndent(IDocument document, int line, CharSequence indent, boolean[] commentlines, int relative, boolean indentInsideLineComments) throws BadLocationException {
+               IRegion region= document.getLineInformation(line);
+               int insert= region.getOffset();
+               int endOffset= region.getOffset() + region.getLength();
+
+               if (indentInsideLineComments) {
+                       // go behind line comments
+                       if (!commentlines[relative]) {
+                               while (insert < endOffset - 2 && document.get(insert, 2).equals(SLASHES))
+                                       insert += 2;
+                       }
+               }
+
+               // insert indent
+               document.replace(insert, 0, indent.toString());
+       }
+
+       /**
+        * Cuts the visual equivalent of <code>toDelete</code> characters out of the
+        * indentation of line <code>line</code> in <code>document</code>.
+        *
+        * @param document
+        * @param line
+        * @param shiftWidth
+        * @param tabWidth
+        * @return number of characters deleted
+        * @throws BadLocationException
+        */
+       public static int cutIndent(IDocument document, int line, int shiftWidth, int tabWidth) throws BadLocationException {
+               return cutIndent(document, line, shiftWidth, tabWidth, new boolean[1], 0, false);
+       }
+
+       /**
+        * Cuts the visual equivalent of <code>toDelete</code> characters out of the
+        * indentation of line <code>line</code> in <code>document</code>. Leaves
+        * leading comment signs alone if desired.
+        *
+        * @param document the document
+        * @param line the line
+        * @param toDelete the number of space equivalents to delete.
+        * @param commentLines
+        * @param relative
+        * @param indentInsideLineComments option whether to indent inside line comments starting at column 0
+        * @return number of characters deleted
+        * @throws BadLocationException on concurrent document modification
+        */
+       private static int cutIndent(IDocument document, int line, int toDelete, int tabSize, boolean[] commentLines, int relative, boolean indentInsideLineComments) throws BadLocationException {
+               IRegion region= document.getLineInformation(line);
+               int from= region.getOffset();
+               int endOffset= region.getOffset() + region.getLength();
+
+               if (indentInsideLineComments) {
+                       // go behind line comments
+                       while (from < endOffset - 2 && document.get(from, 2).equals(SLASHES))
+                               from += 2;
+               }
+       
+               int to= from;
+               while (toDelete > 0 && to < endOffset) {
+                       char ch= document.getChar(to);
+                       if (!Character.isWhitespace(ch))
+                               break;
+                       toDelete -= computeVisualLength(ch, tabSize);
+                       if (toDelete >= 0)
+                               to++;
+                       else
+                               break;
+               }
+               
+               if (endOffset > to + 1 && document.get(to, 2).equals(SLASHES))
+                       commentLines[relative]= true;
+
+               document.replace(from, to - from, ""); //$NON-NLS-1$
+               return to - from;
+       }
+
+       /**
+        * Computes the difference of two indentations and returns the difference in
+        * length of current and correct. If the return value is positive, <code>addition</code>
+        * is initialized with a substring of that length of <code>correct</code>.
+        *
+        * @param correct the correct indentation
+        * @param current the current indentation (migth contain non-whitespace)
+        * @param difference a string buffer - if the return value is positive, it will be cleared and set to the substring of <code>current</code> of that length
+        * @return the difference in lenght of <code>correct</code> and <code>current</code>
+        */
+       private static int subtractIndent(CharSequence correct, CharSequence current, StringBuilder difference, int tabSize) {
+               int c1= computeVisualLength(correct, tabSize);
+               int c2= computeVisualLength(current, tabSize);
+               int diff= c1 - c2;
+               if (diff <= 0)
+                       return diff;
+
+               difference.setLength(0);
+               int len= 0, i= 0;
+               while (len < diff) {
+                       char c= correct.charAt(i++);
+                       difference.append(c);
+                       len += computeVisualLength(c, tabSize);
+               }
+
+
+               return diff;
+       }
+
+       private static int computeVisualLength(char ch, int tabSize) {
+               if (ch == '\t')
+                       return tabSize;
+               return 1;
+       }
+
+       /**
+        * Returns the visual length of a given <code>CharSequence</code> taking into
+        * account the visual tabulator length.
+        *
+        * @param seq the string to measure
+        * @return the visual length of <code>seq</code>
+        */
+       public static int computeVisualLength(CharSequence seq, int tablen) {
+               int size= 0;
+
+               for (int i= 0; i < seq.length(); i++) {
+                       char ch= seq.charAt(i);
+                       if (ch == '\t') {
+                               if (tablen != 0)
+                                       size += tablen - size % tablen;
+                               // else: size stays the same
+                       } else {
+                               size++;
+                       }
+               }
+               return size;
+       }
+
+       /**
+        * Returns the indentation of the line <code>line</code> in <code>document</code>.
+        * The returned string may contain pairs of leading slashes that are considered
+        * part of the indentation.
+        *
+        * @param document the document
+        * @param line the line
+        * @param indentInsideLineComments  option whether to indent inside line comments starting at column 0
+        * @return the indentation of <code>line</code> in <code>document</code>
+        * @throws BadLocationException if the document is changed concurrently
+        */
+       public static String getCurrentIndent(IDocument document, int line, boolean indentInsideLineComments) throws BadLocationException {
+               IRegion region= document.getLineInformation(line);
+               int from= region.getOffset();
+               int endOffset= region.getOffset() + region.getLength();
+
+               int to= from;
+               if (indentInsideLineComments) {
+                       // go behind line comments
+                       while (to < endOffset - 2 && document.get(to, 2).equals(SLASHES))
+                               to += 2;
+               }
+               
+               while (to < endOffset) {
+                       char ch= document.getChar(to);
+                       if (!Character.isWhitespace(ch))
+                               break;
+                       to++;
+               }
+
+               return document.get(from, to - from);
+       }
+       
+       private static int getLeftMostLine(IDocument document, ILineRange lines, int tabSize, boolean indentInsideLineComments) throws BadLocationException {
+               int numberOfLines= lines.getNumberOfLines();
+               int first= lines.getStartLine();
+               int minLine= -1;
+               int minIndent= Integer.MAX_VALUE;
+               for (int line= 0; line < numberOfLines; line++) {
+                       int length= computeVisualLength(getCurrentIndent(document, line + first, indentInsideLineComments), tabSize);
+                       if (length < minIndent && document.getLineLength(line + first) > 0) {
+                               minIndent= length;
+                               minLine= line;
+                       }
+               }
+               return minLine;
+       }
+
+       private static IndentResult reuseOrCreateToken(IndentResult token, int numberOfLines) {
+               if (token == null)
+                       token= new IndentResult(new boolean[numberOfLines]);
+               else if (token.commentLinesAtColumnZero == null)
+                       token.commentLinesAtColumnZero= new boolean[numberOfLines];
+               else if (token.commentLinesAtColumnZero.length != numberOfLines) {
+                       boolean[] commentBooleans= new boolean[numberOfLines];
+                       System.arraycopy(token.commentLinesAtColumnZero, 0, commentBooleans, 0, Math.min(numberOfLines, token.commentLinesAtColumnZero.length));
+                       token.commentLinesAtColumnZero= commentBooleans;
+               }
+               return token;
+       }
+       
+       /**
+        * Indents a single line using the heuristic scanner. Multiline comments are
+        * indented as specified by the <code>CCommentAutoIndentStrategy</code>.
+        * 
+        * @param document the document
+        * @param line the line to be indented
+        * @param indenter the C indenter
+        * @param scanner the heuristic scanner
+        * @param commentLines the indent token comment booleans
+        * @param lineIndex the zero-based line index
+        * @param indentInsideLineComments option whether to indent inside line comments
+        *             starting at column 0
+        * @return <code>true</code> if the document was modified,
+        *         <code>false</code> if not
+        * @throws BadLocationException if the document got changed concurrently
+        */
+       private static boolean indentLine(IDocument document, int line, CIndenter indenter,
+                       CHeuristicScanner scanner, boolean[] commentLines, int lineIndex, int tabSize,
+                       boolean indentInsideLineComments) throws BadLocationException {
+               IRegion currentLine= document.getLineInformation(line);
+               final int offset= currentLine.getOffset();
+               int wsStart= offset; // where we start searching for non-WS; after the "//" in single line comments
+               
+               String indent= null;
+               if (offset < document.getLength()) {
+                       ITypedRegion partition= TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, true);
+                       ITypedRegion startingPartition= TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, false);
+                       String type= partition.getType();
+                       if (type.equals(ICPartitions.C_MULTI_LINE_COMMENT) || type.equals(ICPartitions.C_MULTI_LINE_DOC_COMMENT)) {
+                               indent= computeCommentIndent(document, line, scanner, startingPartition);
+                       } else if (startingPartition.getType().equals(ICPartitions.C_PREPROCESSOR)) {
+                               indent= computePreprocessorIndent(document, line, startingPartition);
+                       } else if (!commentLines[lineIndex] && startingPartition.getOffset() == offset && startingPartition.getType().equals(ICPartitions.C_SINGLE_LINE_COMMENT)) {
+                               return false;
+                       }
+               }
+               
+               // standard C code indentation
+               if (indent == null) {
+                       StringBuilder computed= indenter.computeIndentation(offset);
+                       if (computed != null)
+                               indent= computed.toString();
+                       else
+                               indent= ""; //$NON-NLS-1$
+               }
+               
+               // change document:
+               // get current white space
+               int lineLength= currentLine.getLength();
+               int end= scanner.findNonWhitespaceForwardInAnyPartition(wsStart, offset + lineLength);
+               if (end == CHeuristicScanner.NOT_FOUND)
+                       end= offset + lineLength;
+               int length= end - offset;
+               String currentIndent= document.get(offset, length);
+               
+               // memorize the fact that a line is a single line comment (but not at column 0) and should be treated like code
+               // as opposed to commented out code, which should keep its slashes at column 0
+               // if 'indentInsideLineComments' is false, all comment lines are indented with the code
+               if (length > 0 || !indentInsideLineComments) {
+                       ITypedRegion partition= TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, end, false);
+                       if (partition.getOffset() == end && ICPartitions.C_SINGLE_LINE_COMMENT.equals(partition.getType())) {
+                               commentLines[lineIndex]= true;
+                       }
+               }
+               
+               // only change the document if it is a real change
+               if (!indent.equals(currentIndent)) {
+                       document.replace(offset, length, indent);
+                       return true;
+               }
+               
+               return false;
+       }
+
+       /**
+        * Computes and returns the indentation for a source line.
+        * 
+        * @param document the document
+        * @param line the line in document
+        * @param indenter the C indenter
+        * @param scanner the scanner
+        * @return the indent, never <code>null</code>
+        * @throws BadLocationException
+        */
+       public static String computeIndent(IDocument document, int line, CIndenter indenter, CHeuristicScanner scanner) throws BadLocationException {
+               IRegion currentLine= document.getLineInformation(line);
+               final int offset= currentLine.getOffset();
+               
+               String indent= null;
+               if (offset < document.getLength()) {
+                       ITypedRegion partition= TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, true);
+                       ITypedRegion startingPartition= TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, false);
+                       String type= partition.getType();
+                       if (type.equals(ICPartitions.C_MULTI_LINE_COMMENT) || type.equals(ICPartitions.C_MULTI_LINE_DOC_COMMENT)) {
+                               indent= computeCommentIndent(document, line, scanner, startingPartition);
+                       } else if (startingPartition.getType().equals(ICPartitions.C_PREPROCESSOR)) {
+                               indent= computePreprocessorIndent(document, line, startingPartition);
+                       }
+               }
+               
+               // standard C code indentation
+               if (indent == null) {
+                       StringBuilder computed= indenter.computeIndentation(offset);
+                       if (computed != null)
+                               indent= computed.toString();
+                       else
+                               indent= new String();
+               }
+               return indent;
+       }
+       
+       /**
+        * Computes and returns the indentation for a block comment line.
+        * 
+        * @param document the document
+        * @param line the line in document
+        * @param scanner the scanner
+        * @param partition the comment partition
+        * @return the indent, or <code>null</code> if not computable
+        * @throws BadLocationException
+        */
+       public static String computeCommentIndent(IDocument document, int line, CHeuristicScanner scanner, ITypedRegion partition) throws BadLocationException {
+               if (line == 0) // impossible - the first line is never inside a comment
+                       return null;
+               
+               // don't make any assumptions if the line does not start with \s*\* - it might be
+               // commented out code, for which we don't want to change the indent
+               final IRegion lineInfo= document.getLineInformation(line);
+               final int lineStart= lineInfo.getOffset();
+               final int lineLength= lineInfo.getLength();
+               final int lineEnd= lineStart + lineLength;
+               int nonWS= scanner.findNonWhitespaceForwardInAnyPartition(lineStart, lineEnd);
+               if (nonWS == CHeuristicScanner.NOT_FOUND || document.getChar(nonWS) != '*') {
+                       if (nonWS == CHeuristicScanner.NOT_FOUND)
+                               return document.get(lineStart, lineLength);
+                       return document.get(lineStart, nonWS - lineStart);
+               }
+               
+               // take the indent from the previous line and reuse
+               IRegion previousLine= document.getLineInformation(line - 1);
+               int previousLineStart= previousLine.getOffset();
+               int previousLineLength= previousLine.getLength();
+               int previousLineEnd= previousLineStart + previousLineLength;
+               
+               StringBuilder buf= new StringBuilder();
+               int previousLineNonWS= scanner.findNonWhitespaceForwardInAnyPartition(previousLineStart, previousLineEnd);
+               if (previousLineNonWS == CHeuristicScanner.NOT_FOUND || document.getChar(previousLineNonWS) != '*') {
+                       // align with the comment start if the previous line is not an asterix line
+                       previousLine= document.getLineInformationOfOffset(partition.getOffset());
+                       previousLineStart= previousLine.getOffset();
+                       previousLineLength= previousLine.getLength();
+                       previousLineEnd= previousLineStart + previousLineLength;
+                       previousLineNonWS= scanner.findNonWhitespaceForwardInAnyPartition(previousLineStart, previousLineEnd);
+                       if (previousLineNonWS == CHeuristicScanner.NOT_FOUND)
+                               previousLineNonWS= previousLineEnd;
+                       
+                       // add the initial space
+                       // TODO this may be controlled by a formatter preference in the future
+                       buf.append(' ');
+               }
+               
+               String indentation= document.get(previousLineStart, previousLineNonWS - previousLineStart);
+               buf.insert(0, indentation);
+               return buf.toString();
+       }
+
+       /**
+        * Computes and returns the indentation for a preprocessor line.
+        * 
+        * @param document the document
+        * @param line the line in document
+        * @param partition the comment partition
+        * @return the indent, or <code>null</code> if not computable
+        * @throws BadLocationException
+        */
+       public static String computePreprocessorIndent(IDocument document, int line, ITypedRegion partition)
+                       throws BadLocationException {
+               int ppFirstLine= document.getLineOfOffset(partition.getOffset());
+               if (line == ppFirstLine) {
+                       return ""; //$NON-NLS-1$
+               }
+               CHeuristicScanner ppScanner= new CHeuristicScanner(document, ICPartitions.C_PARTITIONING, partition.getType());
+               CIndenter ppIndenter= new CIndenter(document, ppScanner);
+               if (line == ppFirstLine + 1) {
+                       return ppIndenter.createReusingIndent(new StringBuilder(), ppIndenter.getContinuationLineIndent(), 0).toString();
+               }
+               StringBuilder computed= ppIndenter.computeIndentation(document.getLineOffset(line), false);
+               if (computed != null) {
+                       return computed.toString();
+               }
+               // take the indent from the previous line and reuse
+               IRegion previousLine= document.getLineInformation(line - 1);
+               int previousLineStart= previousLine.getOffset();
+               int previousLineLength= previousLine.getLength();
+               int previousLineEnd= previousLineStart + previousLineLength;
+               
+               int previousLineNonWS= ppScanner.findNonWhitespaceForwardInAnyPartition(previousLineStart, previousLineEnd);
+               String previousIndent= document.get(previousLineStart, previousLineNonWS - previousLineStart);
+               computed= new StringBuilder(previousIndent);
+               return computed.toString();
+       }
+
+       /**
+        * Extends the string with whitespace to match displayed width.
+        * @param prefix  add to this string
+        * @param displayedWidth  the desired display width
+        * @param tabWidth  the configured tab width
+        * @param useSpaces  whether to use spaces only
+        */
+       public static String changePrefix(String prefix, int displayedWidth, int tabWidth, boolean useSpaces) {
+               int column = computeVisualLength(prefix, tabWidth);
+               if (column > displayedWidth) {
+                       return prefix;
+               }
+               final StringBuilder buffer = new StringBuilder(prefix);
+               appendIndent(buffer, displayedWidth, tabWidth, useSpaces, column);
+               return buffer.toString();
+       }
+
+       /**
+        * Appends whitespace to given buffer such that its visual length equals the given width.
+        * @param buffer  the buffer to add whitespace to
+        * @param width  the desired visual indent width
+        * @param tabWidth  the configured tab width
+        * @param useSpaces  whether tabs should be substituted by spaces
+        * @param startColumn  the column where to start measurement
+        * @return StringBuilder
+        */
+       private static StringBuilder appendIndent(StringBuilder buffer, int width, int tabWidth, boolean useSpaces, int startColumn) {
+               assert tabWidth > 0;
+               int tabStop = startColumn - startColumn % tabWidth;
+               int tabs = useSpaces ? 0 : (width-tabStop) / tabWidth;
+               for (int i = 0; i < tabs; ++i) {
+                       buffer.append('\t');
+                       tabStop += tabWidth;
+                       startColumn = tabStop;
+               }
+               int spaces = width - startColumn;
+               for (int i = 0; i < spaces; ++i) {
+                       buffer.append(' ');
+               }
+               return buffer;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/LexicalSortingAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/LexicalSortingAction.java
new file mode 100644 (file)
index 0000000..168f473
--- /dev/null
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+
+import org.eclipse.cdt.ui.CElementSorter;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+
+
+public class LexicalSortingAction extends Action {
+       
+       private static final String ACTION_NAME= "LexicalSortingAction"; //$NON-NLS-1$
+       
+       private final ViewerComparator fSorter;
+       private final TreeViewer fTreeViewer;
+       private final String fStoreKey;
+
+       public LexicalSortingAction(TreeViewer treeViewer) {
+               this(treeViewer, ".sort"); //$NON-NLS-1$
+       }
+
+       public LexicalSortingAction(TreeViewer treeViewer, String storeKeySuffix) {
+               super(CUIPlugin.getResourceString(ACTION_NAME + ".label")); //$NON-NLS-1$
+               
+               setDescription(CUIPlugin.getResourceString(ACTION_NAME + ".description")); //$NON-NLS-1$
+               setToolTipText(CUIPlugin.getResourceString(ACTION_NAME + ".tooltip")); //$NON-NLS-1$
+       
+               CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_ALPHA_SORTING);
+       
+               fTreeViewer= treeViewer;
+               fSorter= new CElementSorter();
+               fStoreKey= ACTION_NAME + storeKeySuffix;
+
+               boolean checked= CUIPlugin.getDefault().getDialogSettings().getBoolean(fStoreKey);
+               valueChanged(checked, false);
+       }
+       
+       @Override
+       public void run() {
+               valueChanged(isChecked(), true);
+       }
+       
+       private void valueChanged(boolean on, boolean store) {
+               setChecked(on);
+               fTreeViewer.setComparator(on ? fSorter : null);
+               
+               String key= ACTION_NAME + ".tooltip" + (on ? ".on" : ".off"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+               setToolTipText(CUIPlugin.getResourceString(key));
+               
+               if (store) {
+                       CUIPlugin.getDefault().getDialogSettings().put(fStoreKey, on);
+               }
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java
new file mode 100644 (file)
index 0000000..19ac337
--- /dev/null
@@ -0,0 +1,309 @@
+/*******************************************************************************
+ *  Copyright (c) 2005, 2011 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Sergey Prigogin (Google) - https://bugs.eclipse.org/bugs/show_bug.cgi?id=13221
+ *     Ed Swartz (Nokia)
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceProxy;
+import org.eclipse.core.resources.IResourceProxyVisitor;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.MessageBox;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IInclude;
+import org.eclipse.cdt.core.parser.ExtendedScannerInfo;
+import org.eclipse.cdt.core.parser.IExtendedScannerInfo;
+import org.eclipse.cdt.core.parser.IScannerInfo;
+import org.eclipse.cdt.core.parser.IScannerInfoProvider;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.utils.PathUtil;
+import org.eclipse.cdt.utils.UNCPathConverter;
+
+import org.eclipse.cdt.internal.core.resources.ResourceLookup;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.dialogs.ElementListSelectionDialog;
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+
+
+public class OpenIncludeAction extends Action {
+
+       private static final String PREFIX= "OpenIncludeAction."; //$NON-NLS-1$
+       
+       private static final String DIALOG_TITLE= PREFIX + "dialog.title"; //$NON-NLS-1$
+       private static final String DIALOG_MESSAGE= PREFIX + "dialog.message"; //$NON-NLS-1$
+       
+       private ISelectionProvider fSelectionProvider;
+
+
+       public OpenIncludeAction(ISelectionProvider provider) {
+               super(CUIPlugin.getResourceString(PREFIX + "label")); //$NON-NLS-1$
+               setDescription(CUIPlugin.getResourceString(PREFIX + "description")); //$NON-NLS-1$
+               setToolTipText(CUIPlugin.getResourceString(PREFIX + "tooltip")); //$NON-NLS-1$
+               
+               CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_OPEN_INCLUDE);
+               
+               fSelectionProvider= provider;
+       }
+                       
+       @Override
+       public void run() {
+               IInclude include= getIncludeStatement(fSelectionProvider.getSelection());
+               if (include == null) {
+                       return;
+               }
+               
+               try {
+                       IResource res = include.getUnderlyingResource();
+                       ArrayList<IPath> filesFound = new ArrayList<IPath>(4);
+                       String fullFileName= include.getFullFileName();
+                       if (fullFileName != null) {
+                               IPath fullPath = new Path(fullFileName);
+                               if (fullPath.isAbsolute() && fullPath.toFile().exists()) {
+                                       filesFound.add(fullPath);
+                               } else if (fullPath.isUNC()) {
+                                       IFileStore store = EFS.getStore(UNCPathConverter.getInstance().toURI(fullPath));
+                                       if (store.fetchInfo().exists()) {
+                                               filesFound.add(fullPath);
+                                       }
+                               }
+                       }
+                       if (filesFound.isEmpty() && res != null) {
+                               IProject proj = res.getProject();
+                               String includeName = include.getElementName();
+                               // Search in the scannerInfo information
+                               IScannerInfoProvider provider =  CCorePlugin.getDefault().getScannerInfoProvider(proj);
+                               if (provider != null) {
+                                       IScannerInfo info = provider.getScannerInformation(res);
+                                       // XXXX this should fall back to project by itself
+                                       if (info == null) {
+                                               info = provider.getScannerInformation(proj);
+                                       }
+                                       if (info != null) {
+                                               IExtendedScannerInfo scanInfo = new ExtendedScannerInfo(info);
+                                               
+                                               boolean isSystemInclude = include.isStandard();
+                                               
+                                               if (!isSystemInclude) {
+                                                       // search in current directory
+                                                       IPath location= include.getTranslationUnit().getLocation();
+                                                       if (location != null) {
+                                                               String currentDir= location.removeLastSegments(1).toOSString();
+                                                               findFile(new String[] { currentDir }, includeName, filesFound);
+                                                       }
+                                                       if (filesFound.isEmpty()) {
+                                                               // search in "..." include directories
+                                                               String[] localIncludePaths = scanInfo.getLocalIncludePath();
+                                                               findFile(localIncludePaths, includeName, filesFound);
+                                                       }
+                                               }
+       
+                                               if (filesFound.isEmpty()) {
+                                                       // search in <...> include directories
+                                                       String[] includePaths = scanInfo.getIncludePaths();
+                                                       findFile(includePaths, includeName, filesFound);
+                                               }
+                                       }
+                                       
+                                       if (filesFound.isEmpty()) {
+                                               // Fall back and search the project
+                                               findFile(proj, new Path(includeName), filesFound);
+                                       }
+                               }
+                       }
+                       IPath fileToOpen;
+                       int nElementsFound= filesFound.size();
+                       if (nElementsFound == 0) {
+                               noElementsFound();
+                               fileToOpen= null;
+                       } else if (nElementsFound == 1) {
+                               fileToOpen= filesFound.get(0);
+                       } else {
+                               fileToOpen= chooseFile(filesFound);
+                       }
+                       
+                       if (fileToOpen != null) {
+                               EditorUtility.openInEditor(fileToOpen, include);
+                       } 
+               } catch (CModelException e) {
+                       CUIPlugin.log(e.getStatus());
+               } catch (CoreException e) {
+                       CUIPlugin.log(e.getStatus());
+               }
+       }
+
+       private void noElementsFound() {
+               MessageBox errorMsg = new MessageBox(CUIPlugin.getActiveWorkbenchShell(), SWT.ICON_ERROR | SWT.OK);
+               errorMsg.setText(CUIPlugin.getResourceString("OpenIncludeAction.error")); //$NON-NLS-1$
+               errorMsg.setMessage (CUIPlugin.getResourceString("OpenIncludeAction.error.description")); //$NON-NLS-1$
+               errorMsg.open();
+       }
+       
+       private boolean isInProject(IPath path) {
+               return getWorkspaceRoot().getFileForLocation(path) != null;             
+       }
+       
+       /**
+        * Returns the path as is, if it points to a workspace resource. If the path
+        * does not point to a workspace resource, but there are linked workspace
+        * resources pointing to it, returns the paths of these resources.
+        * Otherwise, returns the path as is. 
+        */
+       private IPath[] resolveIncludeLink(IPath path) {
+               if (!isInProject(path)) {
+                       IFile[] files = ResourceLookup.findFilesForLocation(path);
+                       if (files.length > 0) {
+                               IPath[] paths = new IPath[files.length];
+                               for (int i = 0; i < files.length; i++) {
+                                       paths[i] = files[i].getFullPath(); 
+                               }
+                               return paths;
+                       }
+               }
+               
+               return new IPath[] { path };
+       }
+
+       private IWorkspaceRoot getWorkspaceRoot() {
+               return ResourcesPlugin.getWorkspace().getRoot();
+       }
+       
+       private void findFile(String[] includePaths, String name, ArrayList<IPath> list)
+                       throws CoreException {
+               // in case it is an absolute path
+               IPath includeFile= new Path(name);              
+               if (includeFile.isAbsolute()) {
+                       includeFile = PathUtil.getCanonicalPathWindows(includeFile);
+                       if (includeFile.toFile().exists()) {
+                               list.add(includeFile);
+                               return;
+                       }
+               }
+               HashSet<IPath> foundSet = new HashSet<IPath>();
+               for (String includePath : includePaths) {
+                       IPath path = PathUtil.getCanonicalPathWindows(new Path(includePath).append(includeFile));
+                       File file = path.toFile();
+                       if (file.exists()) {
+                               IPath[] paths = resolveIncludeLink(path);
+                               for (IPath p : paths) {
+                                       if (foundSet.add(p)) {
+                                               list.add(p);
+                                       }
+                               }
+                       } 
+               }
+       }
+
+       /**
+        * Recurse in the project.
+        * @param parent
+        * @param name
+        * @param list
+        * @throws CoreException
+        */
+       private void findFile(IContainer parent, final IPath name, final ArrayList<IPath> list) throws CoreException {
+               parent.accept(new IResourceProxyVisitor() {
+
+                       public boolean visit(IResourceProxy proxy) throws CoreException {
+                               if (proxy.getType() == IResource.FILE && proxy.getName().equalsIgnoreCase(name.lastSegment())) {
+                                       IPath rPath = proxy.requestResource().getLocation();
+                                       if (rPath != null) {
+                                               int numSegToRemove = rPath.segmentCount() - name.segmentCount();
+                                               IPath sPath = rPath.removeFirstSegments(numSegToRemove);
+                                               sPath = sPath.setDevice(name.getDevice());
+                                               if (Platform.getOS().equals(Platform.OS_WIN32) ?
+                                                               sPath.toOSString().equalsIgnoreCase(name.toOSString()) :
+                                                               sPath.equals(name)) {
+                                                       list.add(rPath);
+                                               }
+                                               return false;
+                                       }
+                               }
+                               return true;
+                       }
+               }, 0);
+       }
+
+       private IPath chooseFile(ArrayList<IPath> filesFound) {
+               ILabelProvider renderer= new LabelProvider() {
+                       @Override
+                       public String getText(Object element) {
+                               if (element instanceof IPath) {
+                                       IPath file= (IPath)element;
+                                       return file.lastSegment() + " - "  + file.toString(); //$NON-NLS-1$
+                               }
+                               return super.getText(element);
+                       }
+               };
+               
+               ElementListSelectionDialog dialog= new ElementListSelectionDialog(CUIPlugin.getActiveWorkbenchShell(), renderer, false, false);
+               dialog.setTitle(CUIPlugin.getResourceString(DIALOG_TITLE));
+               dialog.setMessage(CUIPlugin.getResourceString(DIALOG_MESSAGE));
+               dialog.setElements(filesFound);
+               
+               if (dialog.open() == Window.OK) {
+                       return (IPath) dialog.getSelectedElement();
+               }
+               return null;
+       }
+
+       private static IInclude getIncludeStatement(ISelection sel) {
+               if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
+                       List<?> list= ((IStructuredSelection)sel).toList();
+                       if (list.size() == 1) {
+                               Object element= list.get(0);
+                               if (element instanceof IInclude) {
+                                       return (IInclude)element;
+                               }
+                       }
+               }
+               return null;
+       }
+       
+       public static boolean canActionBeAdded(ISelection selection) {
+               ICElement include = getIncludeStatement(selection);
+               if (include != null) {
+                       IResource res = include.getUnderlyingResource();
+                       if (res != null) {
+                               return true; 
+                       }
+               }
+               return false;
+       }       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OverrideIndicatorImageProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OverrideIndicatorImageProvider.java
new file mode 100644 (file)
index 0000000..fd3e434
--- /dev/null
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Tomasz Wesolowski and others
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Tomasz Wesolowski - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.texteditor.IAnnotationImageProvider;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+
+/**
+ * @author Tomasz Wesolowski
+ *
+ */
+public class OverrideIndicatorImageProvider implements
+               IAnnotationImageProvider {
+
+       private static final String OVERRIDE_IMG_DESC_ID = "CPluginImages.DESC_OBJS_OVERRIDES"; //$NON-NLS-1$
+       private static final String IMPLEMENT_IMG_DESC_ID = "CPluginImages.DESC_OBJS_IMPLEMENTS"; //$NON-NLS-1$
+       private static final String SHADOW_IMG_DESC_ID = "CPluginImages.DESC_OBJS_SHADOWS"; //$NON-NLS-1$
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.texteditor.IAnnotationImageProvider#getManagedImage(org.eclipse.jface.text.source.Annotation)
+        */
+       public Image getManagedImage(Annotation annotation) {
+               return null;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.texteditor.IAnnotationImageProvider#getImageDescriptorId(org.eclipse.jface.text.source.Annotation)
+        */
+       public String getImageDescriptorId(Annotation annotation) {
+               if (!isImageProviderFor(annotation)) {
+                       return null;
+               }
+               switch (getAnnotationType(annotation)) {
+               case OverrideIndicatorManager.RESULT_OVERRIDES:
+                       return OVERRIDE_IMG_DESC_ID;
+               case OverrideIndicatorManager.RESULT_IMPLEMENTS:
+                       return IMPLEMENT_IMG_DESC_ID;
+               case OverrideIndicatorManager.RESULT_SHADOWS:
+                       return SHADOW_IMG_DESC_ID;
+               }
+               assert false;
+               return null;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.texteditor.IAnnotationImageProvider#getImageDescriptor(java.lang.String)
+        */
+       public ImageDescriptor getImageDescriptor(String imageDescritporId) {
+               if (imageDescritporId.equals(OVERRIDE_IMG_DESC_ID)) {
+                       return CPluginImages.DESC_OBJS_OVERRIDES;
+               } else if (imageDescritporId.equals(IMPLEMENT_IMG_DESC_ID)) {
+                       return CPluginImages.DESC_OBJS_IMPLEMENTS;
+               } else if (imageDescritporId.equals(SHADOW_IMG_DESC_ID)) {
+                       return CPluginImages.DESC_OBJS_SHADOWS;
+               }
+               assert false;
+               return null;
+       }
+       
+       private boolean isImageProviderFor(Annotation annotation) {
+               return annotation != null && OverrideIndicatorManager.OverrideIndicator.ANNOTATION_TYPE_ID.equals(annotation.getType());
+       }
+       
+       private int getAnnotationType(Annotation annotation) {
+               return ((OverrideIndicatorManager.OverrideIndicator)annotation).getIndicationType();
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OverrideIndicatorManager.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OverrideIndicatorManager.java
new file mode 100644 (file)
index 0000000..e4a39ea
--- /dev/null
@@ -0,0 +1,429 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Tomasz Wesolowski and others
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Tomasz Wesolowski - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.Vector;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.text.ISynchronizable;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationModel;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.ui.CDTUITools;
+
+import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
+import org.eclipse.cdt.internal.core.model.ASTStringUtil;
+import org.eclipse.cdt.internal.core.model.ext.ICElementHandle;
+
+import org.eclipse.cdt.internal.ui.text.ICReconcilingListener;
+import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
+
+public class OverrideIndicatorManager implements ICReconcilingListener {
+
+       static final String ANNOTATION_TYPE = "org.eclipse.cdt.ui.overrideIndicator"; //$NON-NLS-1$
+       
+       private static final String MESSAGE_SEPARATOR = ";\n"; //$NON-NLS-1$
+
+       public static class OverrideInfo {
+
+               public int nodeOffset;
+               public int resultType;
+               public String message;
+               public int nodeLength;
+               
+               public IBinding binding;
+
+               public OverrideInfo(int nodeOffset, int nodeLength, int markerType, String message, IBinding binding) {
+                       this.nodeOffset = nodeOffset;
+                       this.resultType = markerType;
+                       this.message = message;
+                       this.binding = binding;
+               }
+       }
+
+       public static final int RESULT_OVERRIDES = 0;
+       public static final int RESULT_IMPLEMENTS = 1;
+       public static final int RESULT_SHADOWS = 2;
+
+       public class OverrideIndicator extends Annotation {
+
+               public static final String ANNOTATION_TYPE_ID = "org.eclipse.cdt.ui.overrideIndicator"; //$NON-NLS-1$
+               private int type;
+               private ICElementHandle declaration;
+
+               public OverrideIndicator(int resultType, String message, IBinding binding, IIndex index) {
+                       super(ANNOTATION_TYPE_ID, false, message);
+                       this.type = resultType;
+                       try {
+                               declaration = IndexUI.findAnyDeclaration(index, null, binding);
+                               if (declaration == null) {
+                                       ICElementHandle[] allDefinitions = IndexUI.findAllDefinitions(index, binding);
+                                       if (allDefinitions.length > 0) {
+                                               declaration = allDefinitions[0];
+                                       }
+                               }
+                       } catch (CoreException e) {
+                       }
+               }
+
+               public int getIndicationType() {
+                       return type;
+               }
+
+               public void open() {
+                       try {
+                               CDTUITools.openInEditor(declaration, true, true);
+                       } catch (CoreException e) {
+                       }
+
+               }
+
+       }
+
+       private IAnnotationModel fAnnotationModel;
+       private Vector<OverrideIndicator> fOverrideAnnotations = new Vector<OverrideIndicator>();
+       private Object fAnnotationModelLockObject;
+
+       public OverrideIndicatorManager(IAnnotationModel annotationModel) {
+               fAnnotationModel = annotationModel;
+               fAnnotationModelLockObject = getLockObject(fAnnotationModel);
+       }
+
+       private void handleResult(OverrideInfo info, IIndex index) {
+
+               Position position = new Position(info.nodeOffset, info.nodeLength);
+
+               OverrideIndicator indicator = new OverrideIndicator(info.resultType, info.message, info.binding, index);
+               synchronized (fAnnotationModelLockObject) {
+                       fAnnotationModel.addAnnotation(indicator, position);
+               }
+               fOverrideAnnotations.add(indicator);
+       }
+
+       /**
+        * Removes all override indicators from this manager's annotation model.
+        */
+       public void removeAnnotations() {
+               if (fOverrideAnnotations == null)
+                       return;
+
+               synchronized (fAnnotationModelLockObject) {
+                       for (Annotation i : fOverrideAnnotations)
+                               fAnnotationModel.removeAnnotation(i);
+                       fOverrideAnnotations.clear();
+               }
+       }
+
+       public void generateAnnotations(IASTTranslationUnit ast, final IIndex index) {
+
+               class MethodDeclarationFinder extends ASTVisitor {
+                       {
+                               shouldVisitDeclarations = true;
+                       }
+
+                       @Override
+                       public int visit(IASTDeclaration declaration) {
+                               try {
+                                       IBinding binding = null;
+                                       ICPPMethod method = null;
+                                       if (isFunctionDeclaration(declaration)) {
+                                               binding = getDeclarationBinding(declaration);
+                                       } else if (declaration instanceof IASTFunctionDefinition) {
+                                               binding = getDefinitionBinding((IASTFunctionDefinition) declaration);
+                                       }
+                                       if (binding instanceof ICPPMethod) {
+                                               method = (ICPPMethod) binding;
+                                               OverrideInfo overrideInfo = testForOverride(method, declaration.getFileLocation());
+                                               if (overrideInfo != null) {
+                                                       handleResult(overrideInfo, index);
+                                               }
+                                       } 
+                               } catch (DOMException e) {
+                               }
+                               // go to next declaration
+                               return PROCESS_SKIP;
+                       }
+               }
+
+               class CompositeTypeFinder extends ASTVisitor {
+                       {
+                               shouldVisitDeclSpecifiers = true;
+                       }
+
+                       @Override
+                       public int visit(IASTDeclSpecifier declSpec) {
+                               if (declSpec instanceof ICPPASTCompositeTypeSpecifier) {
+                                       declSpec.accept(new MethodDeclarationFinder());
+                               }
+                               return PROCESS_CONTINUE;
+                       }
+               }
+
+               class MethodDefinitionFinder extends ASTVisitor {
+                       {
+                               shouldVisitDeclarations = true;
+                       }
+
+                       @Override
+                       public int visit(IASTDeclaration declaration) {
+                               try {
+                                       if (!(declaration instanceof IASTFunctionDefinition)) {
+                                               return PROCESS_SKIP;
+                                       }
+                                       IASTFunctionDefinition definition = (IASTFunctionDefinition) declaration;
+                                       IBinding definitionBinding = getDefinitionBinding(definition);
+                                       if (!(definitionBinding instanceof ICPPMethod)) {
+                                               return PROCESS_SKIP;
+                                       }
+                                       ICPPMethod method = (ICPPMethod) definitionBinding;
+                                       OverrideInfo overrideInfo = testForOverride(method, definition.getFileLocation());
+                                       if (overrideInfo != null) {
+                                               handleResult(overrideInfo, index);
+                                       }
+                               } catch (DOMException e) {
+                               }
+                               return PROCESS_SKIP;
+                       }
+               }
+
+               ast.accept(new CompositeTypeFinder());
+               ast.accept(new MethodDefinitionFinder());
+       }
+       
+       public static OverrideInfo testForOverride(ICPPMethod testedOverride, IASTFileLocation location) throws DOMException {
+
+               testedOverride.getClassOwner().getBases();
+
+               boolean onlyPureVirtual = true;
+               StringBuilder sb = new StringBuilder();
+               Set<ICPPMethod> overridenMethods = new HashSet<ICPPMethod>();
+               Set<ICPPMethod> shadowedMethods = new HashSet<ICPPMethod>();
+               
+               Set<ICPPClassType> alreadyTestedBases = new HashSet<ICPPClassType>();
+
+               ICPPBase[] bases = testedOverride.getClassOwner().getBases();
+               
+               // Don't override 'self' in cyclic inheritance
+               alreadyTestedBases.add(testedOverride.getClassOwner());
+
+               for (ICPPBase base : bases) {
+                       ICPPClassType testedClass;
+                       if (!(base.getBaseClass() instanceof ICPPClassType)) {
+                               continue;
+                       }
+                       testedClass = (ICPPClassType) base.getBaseClass();
+
+                       overridenMethods.clear();
+                       shadowedMethods.clear();
+                       handleBaseClass(testedClass, testedOverride, overridenMethods, shadowedMethods, alreadyTestedBases);
+
+                       for (ICPPMethod overriddenMethod : overridenMethods) {
+
+                               if (sb.length() > 0) {
+                                       sb.append(MESSAGE_SEPARATOR);
+                               }
+                               if (overriddenMethod.isPureVirtual()) {
+                                       sb.append(CEditorMessages.OverrideIndicatorManager_implements);
+                               } else {
+                                       sb.append(CEditorMessages.OverrideIndicatorManager_overrides);
+                                       onlyPureVirtual = false;
+                               }
+                               sb.append(' ');
+                               sb.append(getQualifiedNameString(overriddenMethod));
+
+                               if (bases.length > 1 && overriddenMethod.getClassOwner() != testedClass) {
+                                       sb.append(' ');
+                                       sb.append(CEditorMessages.OverrideIndicatorManager_via);
+                                       sb.append(' ');
+                                       sb.append(getQualifiedNameString(testedClass));
+                               }
+                       }
+                       for (ICPPMethod shadowedMethod : shadowedMethods) {
+                               if (sb.length() > 0) {
+                                       sb.append(MESSAGE_SEPARATOR);
+                               }
+                               sb.append(CEditorMessages.OverrideIndicatorManager_shadows);
+                               sb.append(' ');
+                               sb.append(getQualifiedNameString(shadowedMethod));
+                       }
+               }
+               
+               int markerType;
+               if (overridenMethods.size() > 0) {
+                       markerType = onlyPureVirtual ? RESULT_IMPLEMENTS : RESULT_OVERRIDES;
+               } else {
+                       markerType = RESULT_SHADOWS;
+               }
+               
+               IBinding bindingToOpen = null;
+               if (overridenMethods.size() > 0) {
+                       bindingToOpen = overridenMethods.iterator().next();
+               } else if (shadowedMethods.size() > 0) {
+                       bindingToOpen = shadowedMethods.iterator().next();
+               }
+               
+               if (sb.length() > 0) {
+                       OverrideInfo info = new OverrideInfo(location.getNodeOffset(), location.getNodeLength(), markerType,
+                                       sb.toString(), bindingToOpen);
+                       return info;
+               }
+               return null;
+
+       }
+
+       /**
+        * If the class directly has a valid override for testedOverride, it is added to foundBindings. Otherwise
+        * each base class is added to handleBaseClass.
+        * 
+        * @param shadowedMethods
+        * @param alreadyTestedBases 
+        * 
+        * @throws DOMException
+        */
+       private static void handleBaseClass(ICPPClassType aClass, ICPPMethod testedOverride,
+                       Set<ICPPMethod> foundMethods, Set<ICPPMethod> shadowedMethods, Set<ICPPClassType> alreadyTestedBases) throws DOMException {
+               
+               if (alreadyTestedBases.contains(aClass)) {
+                       return;
+               } else {
+                       alreadyTestedBases.add(aClass);
+               }
+
+               Vector<ICPPMethod> validOverrides = new Vector<ICPPMethod>();
+               for (ICPPMethod method : aClass.getDeclaredMethods()) {
+                       if (testedOverride.getName().equals(method.getName())) {
+                               if (ClassTypeHelper.isOverrider(testedOverride, method)) {
+                                       validOverrides.add(method);
+                               } else if (sameParameters(testedOverride, method)) {
+                                       shadowedMethods.add(method);
+                               }
+                       }
+               }
+               if (validOverrides.size() > 1) {
+                       /* System.err.println("Found many valid overrides"); */
+               }
+               if (validOverrides.size() >= 1) {
+                       foundMethods.addAll(validOverrides);
+                       return;
+               }
+
+               for (ICPPBase b : aClass.getBases()) {
+                       if (!(b.getBaseClass() instanceof ICPPClassType)) {
+                               continue;
+                       }
+                       ICPPClassType baseClass = (ICPPClassType) b.getBaseClass();
+                       handleBaseClass(baseClass, testedOverride, foundMethods, shadowedMethods, alreadyTestedBases);
+               }
+       }
+
+       private static boolean sameParameters(ICPPMethod a, ICPPMethod b) throws DOMException {
+               ICPPFunctionType aType = a.getType();
+               ICPPFunctionType bType = b.getType();
+               if (aType.getParameterTypes().length != bType.getParameterTypes().length) {
+                       return false;
+               }
+               for (int i = 0; i < aType.getParameterTypes().length; ++i) {
+                       IType overrideParamType = aType.getParameterTypes()[i];
+                       IType methodParamType = bType.getParameterTypes()[i];
+                       if (!overrideParamType.isSameType(methodParamType)) {
+                               return false;
+                       }
+               }
+               return true;
+       }
+
+       private static String getQualifiedNameString(ICPPBinding binding) throws DOMException {
+               String methodQualifiedName = ASTStringUtil.join(binding.getQualifiedName(), "::"); //$NON-NLS-1$
+               return methodQualifiedName;
+       }
+
+       private static boolean isFunctionDeclaration(IASTDeclaration declaration) {
+               if (!(declaration instanceof IASTSimpleDeclaration)) {
+                       return false;
+               }
+               IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration) declaration;
+               IASTDeclarator[] declarators = simpleDecl.getDeclarators();
+               if (declarators.length < 1) {
+                       return false;
+               }
+               IASTDeclarator declarator = ASTQueries.findInnermostDeclarator(declarators[0]);
+               return (declarator instanceof IASTFunctionDeclarator);
+       }
+
+       private static IBinding getDefinitionBinding(IASTFunctionDefinition definition) {
+               IASTDeclarator declarator = ASTQueries.findInnermostDeclarator(definition.getDeclarator());
+               return declarator.getName().resolveBinding();
+       }
+
+       private static IBinding getDeclarationBinding(IASTDeclaration declaration) {
+               for (IASTNode node : declaration.getChildren()) {
+                       if (node instanceof IASTDeclarator) {
+                               IASTDeclarator decl = ASTQueries.findInnermostDeclarator((IASTDeclarator) node);
+                               return decl.getName().resolveBinding();
+                       }
+               }
+               return null;
+       }
+
+       public void aboutToBeReconciled() {
+       }
+
+       public void reconciled(IASTTranslationUnit ast, boolean force, IProgressMonitor progressMonitor) {
+               if (ast == null) {
+                       return;
+               }
+               IIndex index = ast.getIndex();
+               removeAnnotations();
+               generateAnnotations(ast, index);
+       }
+
+       /**
+        * Returns the lock object for the given annotation model.
+        * 
+        * @param annotationModel
+        *            the annotation model
+        * @return the annotation model's lock object
+        */
+       private Object getLockObject(IAnnotationModel annotationModel) {
+               if (annotationModel instanceof ISynchronizable) {
+                       Object lock = ((ISynchronizable) annotationModel).getLockObject();
+                       if (lock != null)
+                               return lock;
+               }
+               return annotationModel;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ProblemAnnotationIterator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ProblemAnnotationIterator.java
new file mode 100644 (file)
index 0000000..181c418
--- /dev/null
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import java.util.Iterator;
+
+import org.eclipse.jface.text.source.IAnnotationModel;
+
+
+/**
+ * Filters problems based on their types.
+ */
+public class ProblemAnnotationIterator implements Iterator<IProblemAnnotation> {
+                       
+       private Iterator<?> fIterator;
+       private IProblemAnnotation fNext;
+       
+       public ProblemAnnotationIterator(IAnnotationModel model) {
+               fIterator= model.getAnnotationIterator();
+               skip();
+       }
+       
+       private void skip() {
+               while (fIterator.hasNext()) {
+                       Object next= fIterator.next();
+                       if (next instanceof IProblemAnnotation) {
+                               fNext= (IProblemAnnotation) next;
+                               return;
+                       }
+               }
+               fNext= null;
+       }
+       
+       /*
+        * @see Iterator#hasNext()
+        */
+       public boolean hasNext() {
+               return fNext != null;
+       }
+
+       /*
+        * @see Iterator#next()
+        */
+       public IProblemAnnotation next() {
+               try {
+                       return fNext;
+               } finally {
+                       skip();
+               }
+       }
+
+       /*
+        * @see Iterator#remove()
+        */
+       public void remove() {
+               throw new UnsupportedOperationException();
+       }
+}
+
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SelectionHistory.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SelectionHistory.java
new file mode 100644 (file)
index 0000000..8f19683
--- /dev/null
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation (JDT)
+ *     Tomasz Wesolowski - port from JDT
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import java.util.Stack;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+
+import org.eclipse.cdt.core.model.ISourceRange;
+
+public class SelectionHistory {
+
+       private Stack<ISourceRange> fHistory;
+       private CEditor fEditor;
+       private ISelectionChangedListener fSelectionListener;
+       private int fSelectionChangeListenerCounter;
+
+       public SelectionHistory(CEditor editor) {
+               Assert.isNotNull(editor);
+               fEditor= editor;
+               fHistory= new Stack<ISourceRange>();
+               fSelectionListener= new ISelectionChangedListener() {
+                       public void selectionChanged(SelectionChangedEvent event) {
+                               if (fSelectionChangeListenerCounter == 0)
+                                       flush();
+                       }
+               };
+               fEditor.getSelectionProvider().addSelectionChangedListener(fSelectionListener);
+       }
+
+       public boolean isEmpty() {
+               return fHistory.isEmpty();
+       }
+
+       public void remember(ISourceRange range) {
+               fHistory.push(range);
+       }
+
+       public ISourceRange getLast() {
+               if (isEmpty())
+                       return null;
+               ISourceRange result= fHistory.pop();
+               return result;
+       }
+
+       public void flush() {
+               if (fHistory.isEmpty())
+                       return;
+               fHistory.clear();
+       }
+
+       public void ignoreSelectionChanges() {
+               fSelectionChangeListenerCounter++;
+       }
+
+       public void listenToSelectionChanges() {
+               fSelectionChangeListenerCounter--;
+       }
+
+       public void dispose() {
+               fEditor.getSelectionProvider().removeSelectionChangedListener(fSelectionListener);
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlighting.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlighting.java
new file mode 100644 (file)
index 0000000..0fb2e16
--- /dev/null
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems) - Adapted for CDT
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.editor;
+
+import org.eclipse.swt.graphics.RGB;
+
+/**
+ * Semantic highlighting.
+ * Cloned from JDT.
+ * 
+ * @since 4.0
+ */
+public abstract class SemanticHighlighting {
+
+       /**
+        * @return the preference key, will be augmented by a prefix and a suffix for each preference
+        */
+       public abstract String getPreferenceKey();
+
+       /**
+        * @return the default text color
+        */
+       public RGB getDefaultTextColor() {
+               return new RGB(0, 0, 0);
+       }
+
+       /**
+        * @return <code>true</code> if the text attribute bold is set by default
+        */
+       public boolean isBoldByDefault() {
+               return false;
+       }
+
+       /**
+        * @return <code>true</code> if the text attribute italic is set by default
+        */
+       public boolean isItalicByDefault() {
+               return false;
+       }
+
+       /**
+        * @return <code>true</code> if the text attribute strikethrough is set by default
+        */
+       public boolean isStrikethroughByDefault() {
+               return false;
+       }
+
+       /**
+        * @return <code>true</code> if the text attribute underline is set by default
+        * @since 3.1
+        */
+       public boolean isUnderlineByDefault() {
+               return false;
+       }
+
+       /**
+        * @return <code>true</code> if the text attribute italic is enabled by default
+        */
+       public abstract boolean isEnabledByDefault();
+
+       /**
+        * @return the display name
+        */
+       public abstract String getDisplayName();
+       
+       /**
+        * Indicates that the highlighting needs to visit implicit names 
+        * (e.g. overloaded operators)
+        */
+       public boolean requiresImplicitNames() {
+               return false;
+       }
+
+       /**
+        * Returns <code>true</code> iff the semantic highlighting consumes the semantic token.
+        * <p>
+        * NOTE: Implementors are not allowed to keep a reference on the token or on any object
+        * retrieved from the token.
+        * </p>
+        *
+        * @param token the semantic token for a {@link org.eclipse.cdt.core.dom.ast.IASTName}
+        * @return <code>true</code> iff the semantic highlighting consumes the semantic token
+        */
+       public abstract boolean consumes(SemanticToken token);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingManager.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingManager.java
new file mode 100644 (file)
index 0000000..6f4a8b5
--- /dev/null
@@ -0,0 +1,631 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems) - Adapted for CDT
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.editor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.resource.StringConverter;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyleRange;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+
+import org.eclipse.cdt.ui.text.CSourceViewerConfiguration;
+import org.eclipse.cdt.ui.text.ICPartitions;
+import org.eclipse.cdt.ui.text.IColorManager;
+import org.eclipse.cdt.internal.ui.text.CPresentationReconciler;
+import org.eclipse.cdt.internal.ui.text.CSourceViewerScalableConfiguration;
+
+/**
+ * Semantic highlighting manager.
+ * Cloned from JDT.
+ * 
+ * @since 4.0
+ */
+public class SemanticHighlightingManager implements IPropertyChangeListener {
+
+       /**
+        * Highlighting style.
+        */
+       static class HighlightingStyle {
+
+               /** Text attribute */
+               private TextAttribute fTextAttribute;
+               /** Enabled state */
+               private boolean fIsEnabled;
+
+               /**
+                * Initialize with the given text attribute.
+                * @param textAttribute The text attribute
+                * @param isEnabled the enabled state
+                */
+               public HighlightingStyle(TextAttribute textAttribute, boolean isEnabled) {
+                       setTextAttribute(textAttribute);
+                       setEnabled(isEnabled);
+               }
+
+               /**
+                * @return Returns the text attribute.
+                */
+               public TextAttribute getTextAttribute() {
+                       return fTextAttribute;
+               }
+
+               /**
+                * @param textAttribute The background to set.
+                */
+               public void setTextAttribute(TextAttribute textAttribute) {
+                       fTextAttribute= textAttribute;
+               }
+
+               /**
+                * @return the enabled state
+                */
+               public boolean isEnabled() {
+                       return fIsEnabled;
+               }
+
+               /**
+                * @param isEnabled the new enabled state
+                */
+               public void setEnabled(boolean isEnabled) {
+                       fIsEnabled= isEnabled;
+               }
+       }
+
+       /**
+        * Highlighted Positions.
+        */
+       static class HighlightedPosition extends Position {
+
+               /** Highlighting of the position */
+               private HighlightingStyle fStyle;
+
+               /** Lock object */
+               private Object fLock;
+
+               /**
+                * Initialize the styled positions with the given offset, length and foreground color.
+                *
+                * @param offset The position offset
+                * @param length The position length
+                * @param highlighting The position's highlighting
+                * @param lock The lock object
+                */
+               public HighlightedPosition(int offset, int length, HighlightingStyle highlighting, Object lock) {
+                       super(offset, length);
+                       fStyle= highlighting;
+                       fLock= lock;
+               }
+
+               /**
+                * @return Returns a corresponding style range.
+                */
+               public StyleRange createStyleRange() {
+                       int len= 0;
+                       if (fStyle.isEnabled())
+                               len= getLength();
+
+                       TextAttribute textAttribute= fStyle.getTextAttribute();
+                       int style= textAttribute.getStyle();
+                       int fontStyle= style & (SWT.ITALIC | SWT.BOLD | SWT.NORMAL);
+                       StyleRange styleRange= new StyleRange(getOffset(), len, textAttribute.getForeground(), textAttribute.getBackground(), fontStyle);
+                       styleRange.strikeout= (style & TextAttribute.STRIKETHROUGH) != 0;
+                       styleRange.underline= (style & TextAttribute.UNDERLINE) != 0;
+
+                       return styleRange;
+               }
+
+               /**
+                * Uses reference equality for the highlighting.
+                *
+                * @param off The offset
+                * @param len The length
+                * @param highlighting The highlighting
+                * @return <code>true</code> iff the given offset, length and highlighting are equal to the internal ones.
+                */
+               public boolean isEqual(int off, int len, HighlightingStyle highlighting) {
+                       synchronized (fLock) {
+                               return !isDeleted() && getOffset() == off && getLength() == len && fStyle == highlighting;
+                       }
+               }
+
+               /**
+                * Is this position contained in the given range (inclusive)? Synchronizes on position updater.
+                *
+                * @param off The range offset
+                * @param len The range length
+                * @return <code>true</code> iff this position is not delete and contained in the given range.
+                */
+               public boolean isContained(int off, int len) {
+                       synchronized (fLock) {
+                               return !isDeleted() && off <= getOffset() && off + len >= getOffset() + getLength();
+                       }
+               }
+
+               public void update(int off, int len) {
+                       synchronized (fLock) {
+                               super.setOffset(off);
+                               super.setLength(len);
+                       }
+               }
+
+               /*
+                * @see org.eclipse.jface.text.Position#setLength(int)
+                */
+               @Override
+               public void setLength(int length) {
+                       synchronized (fLock) {
+                               super.setLength(length);
+                       }
+               }
+
+               /*
+                * @see org.eclipse.jface.text.Position#setOffset(int)
+                */
+               @Override
+               public void setOffset(int offset) {
+                       synchronized (fLock) {
+                               super.setOffset(offset);
+                       }
+               }
+
+               /*
+                * @see org.eclipse.jface.text.Position#delete()
+                */
+               @Override
+               public void delete() {
+                       synchronized (fLock) {
+                               super.delete();
+                       }
+               }
+
+               /*
+                * @see org.eclipse.jface.text.Position#undelete()
+                */
+               @Override
+               public void undelete() {
+                       synchronized (fLock) {
+                               super.undelete();
+                       }
+               }
+
+               /**
+                * @return Returns the highlighting.
+                */
+               public HighlightingStyle getHighlighting() {
+                       return fStyle;
+               }
+       }
+
+       /**
+        * Highlighted ranges.
+        */
+       public static class HighlightedRange extends Region {
+               /** The highlighting key as returned by {@link SemanticHighlighting#getPreferenceKey()}. */
+               private String fKey;
+
+               /**
+                * Initialize with the given offset, length and highlighting key.
+                *
+                * @param offset
+                * @param length
+                * @param key the highlighting key as returned by {@link SemanticHighlighting#getPreferenceKey()}
+                */
+               public HighlightedRange(int offset, int length, String key) {
+                       super(offset, length);
+                       fKey= key;
+               }
+
+               /**
+                * @return the highlighting key as returned by {@link SemanticHighlighting#getPreferenceKey()}
+                */
+               public String getKey() {
+                       return fKey;
+               }
+
+               /*
+                * @see org.eclipse.jface.text.Region#equals(java.lang.Object)
+                */
+               @Override
+               public boolean equals(Object o) {
+                       return super.equals(o) && o instanceof HighlightedRange && fKey.equals(((HighlightedRange)o).getKey());
+               }
+
+               /*
+                * @see org.eclipse.jface.text.Region#hashCode()
+                */
+               @Override
+               public int hashCode() {
+                       return super.hashCode() | fKey.hashCode();
+               }
+       }
+
+       /** Semantic highlighting presenter */
+       private SemanticHighlightingPresenter fPresenter;
+       /** Semantic highlighting reconciler */
+       private SemanticHighlightingReconciler fReconciler;
+
+       /** Semantic highlightings */
+       private SemanticHighlighting[] fSemanticHighlightings;
+       /** Highlightings */
+       private HighlightingStyle[] fHighlightings;
+
+       /** The editor */
+       private CEditor fEditor;
+       /** The source viewer */
+       private CSourceViewer fSourceViewer;
+       /** The color manager */
+       private IColorManager fColorManager;
+       /** The preference store */
+       private IPreferenceStore fPreferenceStore;
+       /** The source viewer configuration */
+       private CSourceViewerConfiguration fConfiguration;
+       /** The presentation reconciler */
+       private CPresentationReconciler fPresentationReconciler;
+
+       /** The hard-coded ranges */
+       private HighlightedRange[][] fHardcodedRanges;
+
+       /**
+        * Install the semantic highlighting on the given editor infrastructure
+        *
+        * @param editor The C editor
+        * @param sourceViewer The source viewer
+        * @param colorManager The color manager
+        * @param preferenceStore The preference store
+        */
+       public void install(CEditor editor, CSourceViewer sourceViewer, IColorManager colorManager, IPreferenceStore preferenceStore) {
+               fEditor= editor;
+               fSourceViewer= sourceViewer;
+               fColorManager= colorManager;
+               fPreferenceStore= preferenceStore;
+               if (fEditor != null) {
+                       fConfiguration= new CSourceViewerScalableConfiguration(colorManager, preferenceStore, editor, ICPartitions.C_PARTITIONING);
+                       fPresentationReconciler= (CPresentationReconciler) fConfiguration.getPresentationReconciler(sourceViewer);
+               } else {
+                       fConfiguration= null;
+                       fPresentationReconciler= null;
+               }
+
+               fPreferenceStore.addPropertyChangeListener(this);
+
+               if (isEnabled())
+                       enable();
+       }
+
+       /**
+        * Install the semantic highlighting on the given source viewer infrastructure. No reconciliation will be performed.
+        *
+        * @param sourceViewer the source viewer
+        * @param colorManager the color manager
+        * @param preferenceStore the preference store
+        * @param hardcodedRanges the hard-coded ranges to be highlighted
+        */
+       public void install(CSourceViewer sourceViewer, IColorManager colorManager, IPreferenceStore preferenceStore, HighlightedRange[][] hardcodedRanges) {
+               fHardcodedRanges= hardcodedRanges;
+               install(null, sourceViewer, colorManager, preferenceStore);
+       }
+
+       /**
+        * Enable semantic highlighting.
+        */
+       private void enable() {
+               initializeHighlightings();
+
+               fPresenter= new SemanticHighlightingPresenter();
+               fPresenter.install(fSourceViewer, fPresentationReconciler);
+
+               if (fEditor != null) {
+                       fReconciler= new SemanticHighlightingReconciler();
+                       fReconciler.install(fEditor, fSourceViewer, fPresenter, fSemanticHighlightings, fHighlightings);
+               } else {
+                       fPresenter.updatePresentation(null, createHardcodedPositions(), new HighlightedPosition[0]);
+               }
+       }
+
+       /**
+        * Computes the hard-coded positions from the hard-coded ranges
+        *
+        * @return the hard-coded positions
+        */
+       private HighlightedPosition[] createHardcodedPositions() {
+               List<HighlightedPosition> positions= new ArrayList<HighlightedPosition>();
+               for (int i= 0; i < fHardcodedRanges.length; i++) {
+                       HighlightedRange range= null;
+                       HighlightingStyle hl= null;
+                       for (int j= 0; j < fHardcodedRanges[i].length; j++ ) {
+                               hl= getHighlighting(fHardcodedRanges[i][j].getKey());
+                               if (hl.isEnabled()) {
+                                       range= fHardcodedRanges[i][j];
+                                       break;
+                               }
+                       }
+
+                       if (range != null)
+                               positions.add(fPresenter.createHighlightedPosition(range.getOffset(), range.getLength(), hl));
+               }
+               return positions.toArray(new HighlightedPosition[positions.size()]);
+       }
+
+       /**
+        * Returns the highlighting corresponding to the given key.
+        *
+        * @param key the highlighting key as returned by {@link SemanticHighlighting#getPreferenceKey()}
+        * @return the corresponding highlighting
+        */
+       private HighlightingStyle getHighlighting(String key) {
+               for (int i= 0; i < fSemanticHighlightings.length; i++) {
+                       SemanticHighlighting semanticHighlighting= fSemanticHighlightings[i];
+                       if (key.equals(semanticHighlighting.getPreferenceKey()))
+                               return fHighlightings[i];
+               }
+               return null;
+       }
+
+       /**
+        * Uninstall the semantic highlighting
+        */
+       public void uninstall() {
+               disable();
+
+               if (fPreferenceStore != null) {
+                       fPreferenceStore.removePropertyChangeListener(this);
+                       fPreferenceStore= null;
+               }
+
+               fEditor= null;
+               fSourceViewer= null;
+               fColorManager= null;
+               fConfiguration= null;
+               fPresentationReconciler= null;
+               fHardcodedRanges= null;
+       }
+
+       /**
+        * Disable semantic highlighting.
+        */
+       private void disable() {
+               if (fReconciler != null) {
+                       fReconciler.uninstall();
+                       fReconciler= null;
+               }
+
+               if (fPresenter != null) {
+                       fPresenter.uninstall();
+                       fPresenter= null;
+               }
+
+               if (fSemanticHighlightings != null)
+                       disposeHighlightings();
+       }
+
+       /**
+        * @return <code>true</code> iff semantic highlighting is enabled in the preferences
+        */
+       private boolean isEnabled() {
+               return SemanticHighlightings.isEnabled(fPreferenceStore);
+       }
+
+       /**
+        * Initialize semantic highlightings.
+        */
+       private void initializeHighlightings() {
+               fSemanticHighlightings= SemanticHighlightings.getSemanticHighlightings();
+               fHighlightings= new HighlightingStyle[fSemanticHighlightings.length];
+
+               for (int i= 0, n= fSemanticHighlightings.length; i < n; i++) {
+                       SemanticHighlighting semanticHighlighting= fSemanticHighlightings[i];
+                       String colorKey= SemanticHighlightings.getColorPreferenceKey(semanticHighlighting);
+                       addColor(colorKey);
+
+                       String boldKey= SemanticHighlightings.getBoldPreferenceKey(semanticHighlighting);
+                       int style= fPreferenceStore.getBoolean(boldKey) ? SWT.BOLD : SWT.NORMAL;
+
+                       String italicKey= SemanticHighlightings.getItalicPreferenceKey(semanticHighlighting);
+                       if (fPreferenceStore.getBoolean(italicKey))
+                               style |= SWT.ITALIC;
+
+                       String strikethroughKey= SemanticHighlightings.getStrikethroughPreferenceKey(semanticHighlighting);
+                       if (fPreferenceStore.getBoolean(strikethroughKey))
+                               style |= TextAttribute.STRIKETHROUGH;
+
+                       String underlineKey= SemanticHighlightings.getUnderlinePreferenceKey(semanticHighlighting);
+                       if (fPreferenceStore.getBoolean(underlineKey))
+                               style |= TextAttribute.UNDERLINE;
+
+                       boolean isEnabled= fPreferenceStore.getBoolean(SemanticHighlightings.getEnabledPreferenceKey(semanticHighlighting));
+
+                       fHighlightings[i]= new HighlightingStyle(new TextAttribute(fColorManager.getColor(PreferenceConverter.getColor(fPreferenceStore, colorKey)), null, style), isEnabled);
+               }
+       }
+
+       /**
+        * Dispose the semantic highlightings.
+        */
+       private void disposeHighlightings() {
+               for (int i= 0, n= fSemanticHighlightings.length; i < n; i++)
+                       removeColor(SemanticHighlightings.getColorPreferenceKey(fSemanticHighlightings[i]));
+
+               fSemanticHighlightings= null;
+               fHighlightings= null;
+       }
+
+       /*
+        * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+        */
+       public void propertyChange(PropertyChangeEvent event) {
+               handlePropertyChangeEvent(event);
+       }
+
+       /**
+        * Handle the given property change event
+        *
+        * @param event The event
+        */
+       private void handlePropertyChangeEvent(PropertyChangeEvent event) {
+               if (fPreferenceStore == null)
+                       return; // Uninstalled during event notification
+
+               if (fConfiguration != null)
+                       fConfiguration.handlePropertyChangeEvent(event);
+
+               if (SemanticHighlightings.affectsEnablement(fPreferenceStore, event)) {
+                       if (isEnabled())
+                               enable();
+                       else
+                               disable();
+               }
+
+               if (!isEnabled())
+                       return;
+               
+               boolean refreshNeeded= false;
+
+               for (int i= 0, n= fSemanticHighlightings.length; i < n; i++) {
+                       SemanticHighlighting semanticHighlighting= fSemanticHighlightings[i];
+
+                       String colorKey= SemanticHighlightings.getColorPreferenceKey(semanticHighlighting);
+                       if (colorKey.equals(event.getProperty())) {
+                               adaptToTextForegroundChange(fHighlightings[i], event);
+                               fPresenter.highlightingStyleChanged(fHighlightings[i]);
+                               refreshNeeded= true;
+                               continue;
+                       }
+
+                       String boldKey= SemanticHighlightings.getBoldPreferenceKey(semanticHighlighting);
+                       if (boldKey.equals(event.getProperty())) {
+                               adaptToTextStyleChange(fHighlightings[i], event, SWT.BOLD);
+                               fPresenter.highlightingStyleChanged(fHighlightings[i]);
+                               refreshNeeded= true;
+                               continue;
+                       }
+
+                       String italicKey= SemanticHighlightings.getItalicPreferenceKey(semanticHighlighting);
+                       if (italicKey.equals(event.getProperty())) {
+                               adaptToTextStyleChange(fHighlightings[i], event, SWT.ITALIC);
+                               fPresenter.highlightingStyleChanged(fHighlightings[i]);
+                               refreshNeeded= true;
+                               continue;
+                       }
+
+                       String strikethroughKey= SemanticHighlightings.getStrikethroughPreferenceKey(semanticHighlighting);
+                       if (strikethroughKey.equals(event.getProperty())) {
+                               adaptToTextStyleChange(fHighlightings[i], event, TextAttribute.STRIKETHROUGH);
+                               fPresenter.highlightingStyleChanged(fHighlightings[i]);
+                               refreshNeeded= true;
+                               continue;
+                       }
+
+                       String underlineKey= SemanticHighlightings.getUnderlinePreferenceKey(semanticHighlighting);
+                       if (underlineKey.equals(event.getProperty())) {
+                               adaptToTextStyleChange(fHighlightings[i], event, TextAttribute.UNDERLINE);
+                               fPresenter.highlightingStyleChanged(fHighlightings[i]);
+                               refreshNeeded= true;
+                               continue;
+                       }
+
+                       String enabledKey= SemanticHighlightings.getEnabledPreferenceKey(semanticHighlighting);
+                       if (enabledKey.equals(event.getProperty())) {
+                               adaptToEnablementChange(fHighlightings[i], event);
+                               fPresenter.highlightingStyleChanged(fHighlightings[i]);
+                               refreshNeeded= true;
+                               continue;
+                       }
+               }
+               
+               if (refreshNeeded && fReconciler != null)
+                       fReconciler.refresh();
+       }
+
+       private void adaptToEnablementChange(HighlightingStyle highlighting, PropertyChangeEvent event) {
+               Object value= event.getNewValue();
+               boolean eventValue;
+               if (value instanceof Boolean)
+                       eventValue= ((Boolean) value).booleanValue();
+               else if (IPreferenceStore.TRUE.equals(value))
+                       eventValue= true;
+               else
+                       eventValue= false;
+               highlighting.setEnabled(eventValue);
+       }
+
+       private void adaptToTextForegroundChange(HighlightingStyle highlighting, PropertyChangeEvent event) {
+               RGB rgb= null;
+
+               Object value= event.getNewValue();
+               if (value instanceof RGB)
+                       rgb= (RGB) value;
+               else if (value instanceof String)
+                       rgb= StringConverter.asRGB((String) value);
+
+               if (rgb != null) {
+
+                       String property= event.getProperty();
+                       Color color= fColorManager.getColor(property);
+
+                       if ((color == null || !rgb.equals(color.getRGB()))) {
+                               fColorManager.unbindColor(property);
+                               fColorManager.bindColor(property, rgb);
+                               color= fColorManager.getColor(property);
+                       }
+
+                       TextAttribute oldAttr= highlighting.getTextAttribute();
+                       highlighting.setTextAttribute(new TextAttribute(color, oldAttr.getBackground(), oldAttr.getStyle()));
+               }
+       }
+
+       private void adaptToTextStyleChange(HighlightingStyle highlighting, PropertyChangeEvent event, int styleAttribute) {
+               boolean eventValue= false;
+               Object value= event.getNewValue();
+               if (value instanceof Boolean)
+                       eventValue= ((Boolean) value).booleanValue();
+               else if (IPreferenceStore.TRUE.equals(value))
+                       eventValue= true;
+
+               TextAttribute oldAttr= highlighting.getTextAttribute();
+               boolean activeValue= (oldAttr.getStyle() & styleAttribute) == styleAttribute;
+
+               if (activeValue != eventValue)
+                       highlighting.setTextAttribute(new TextAttribute(oldAttr.getForeground(), oldAttr.getBackground(), eventValue ? oldAttr.getStyle() | styleAttribute : oldAttr.getStyle() & ~styleAttribute));
+       }
+
+       private void addColor(String colorKey) {
+               if (fColorManager != null && colorKey != null && fColorManager.getColor(colorKey) == null) {
+                       RGB rgb= PreferenceConverter.getColor(fPreferenceStore, colorKey);
+                       fColorManager.unbindColor(colorKey);
+                       fColorManager.bindColor(colorKey, rgb);
+               }
+       }
+
+       private void removeColor(String colorKey) {
+               fColorManager.unbindColor(colorKey);
+       }
+
+       /**
+        * Force refresh of highlighting.
+        */
+       public void refresh() {
+               if (fReconciler != null) {
+                       fReconciler.refresh();
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingPresenter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingPresenter.java
new file mode 100644 (file)
index 0000000..e65bdb6
--- /dev/null
@@ -0,0 +1,778 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems) - Adapted for CDT
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.editor;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.BadPositionCategoryException;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentListener;
+import org.eclipse.jface.text.IPositionUpdater;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ISynchronizable;
+import org.eclipse.jface.text.ITextInputListener;
+import org.eclipse.jface.text.ITextPresentationListener;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TextPresentation;
+import org.eclipse.swt.custom.StyleRange;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingManager.HighlightedPosition;
+import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingManager.HighlightingStyle;
+import org.eclipse.cdt.internal.ui.text.CPresentationReconciler;
+
+
+/**
+ * Semantic highlighting presenter - UI thread implementation.
+ * Cloned from JDT.
+ * 
+ * @since 4.0
+ */
+public class SemanticHighlightingPresenter implements ITextPresentationListener, ITextInputListener, IDocumentListener {
+
+       /**
+        * Semantic highlighting position updater.
+        */
+       private class HighlightingPositionUpdater implements IPositionUpdater {
+
+               /** The position category. */
+               private final String fCategory;
+
+               /**
+                * Creates a new updater for the given <code>category</code>.
+                *
+                * @param category the new category.
+                */
+               public HighlightingPositionUpdater(String category) {
+                       fCategory= category;
+               }
+
+               /*
+                * @see org.eclipse.jface.text.IPositionUpdater#update(org.eclipse.jface.text.DocumentEvent)
+                */
+               public void update(DocumentEvent event) {
+
+                       int eventOffset= event.getOffset();
+                       int eventOldLength= event.getLength();
+                       int eventEnd= eventOffset + eventOldLength;
+
+                       try {
+                               Position[] positions= event.getDocument().getPositions(fCategory);
+
+                               for (int i= 0; i != positions.length; i++) {
+
+                                       HighlightedPosition position= (HighlightedPosition) positions[i];
+
+                                       // Also update deleted positions because they get deleted by the background thread and removed/invalidated only in the UI runnable
+//                                     if (position.isDeleted())
+//                                             continue;
+
+                                       int offset= position.getOffset();
+                                       int length= position.getLength();
+                                       int end= offset + length;
+
+                                       if (offset > eventEnd)
+                                               updateWithPrecedingEvent(position, event);
+                                       else if (end < eventOffset)
+                                               updateWithSucceedingEvent(position, event);
+                                       else if (offset <= eventOffset && end >= eventEnd)
+                                               updateWithIncludedEvent(position, event);
+                                       else if (offset <= eventOffset)
+                                               updateWithOverEndEvent(position, event);
+                                       else if (end >= eventEnd)
+                                               updateWithOverStartEvent(position, event);
+                                       else
+                                               updateWithIncludingEvent(position, event);
+                               }
+                       } catch (BadPositionCategoryException e) {
+                               // ignore and return
+                       }
+               }
+
+               /**
+                * Update the given position with the given event. The event precedes the position.
+                *
+                * @param position The position
+                * @param event The event
+                */
+               private void updateWithPrecedingEvent(HighlightedPosition position, DocumentEvent event) {
+                       String newText= event.getText();
+                       int eventNewLength= newText != null ? newText.length() : 0;
+                       int deltaLength= eventNewLength - event.getLength();
+
+                       position.setOffset(position.getOffset() + deltaLength);
+               }
+
+               /**
+                * Update the given position with the given event. The event succeeds the position.
+                *
+                * @param position The position
+                * @param event The event
+                */
+               private void updateWithSucceedingEvent(HighlightedPosition position, DocumentEvent event) {
+               }
+
+               /**
+                * Update the given position with the given event. The event is included by the position.
+                *
+                * @param position The position
+                * @param event The event
+                */
+               private void updateWithIncludedEvent(HighlightedPosition position, DocumentEvent event) {
+                       int eventOffset= event.getOffset();
+                       String newText= event.getText();
+                       if (newText == null)
+                               newText= ""; //$NON-NLS-1$
+                       int eventNewLength= newText.length();
+
+                       int deltaLength= eventNewLength - event.getLength();
+
+                       int offset= position.getOffset();
+                       int length= position.getLength();
+                       int end= offset + length;
+
+                       int includedLength= 0;
+                       while (includedLength < eventNewLength && Character.isJavaIdentifierPart(newText.charAt(includedLength)))
+                               includedLength++;
+                       if (includedLength == eventNewLength)
+                               position.setLength(length + deltaLength);
+                       else {
+                               int newLeftLength= eventOffset - offset + includedLength;
+
+                               int excludedLength= eventNewLength;
+                               while (excludedLength > 0 && Character.isJavaIdentifierPart(newText.charAt(excludedLength - 1)))
+                                       excludedLength--;
+                               int newRightOffset= eventOffset + excludedLength;
+                               int newRightLength= end + deltaLength - newRightOffset;
+
+                               if (newRightLength == 0) {
+                                       position.setLength(newLeftLength);
+                               } else {
+                                       if (newLeftLength == 0) {
+                                               position.update(newRightOffset, newRightLength);
+                                       } else {
+                                               position.setLength(newLeftLength);
+                                               addPositionFromUI(newRightOffset, newRightLength, position.getHighlighting());
+                                       }
+                               }
+                       }
+               }
+
+               /**
+                * Update the given position with the given event. The event overlaps with the end of the position.
+                *
+                * @param position The position
+                * @param event The event
+                */
+               private void updateWithOverEndEvent(HighlightedPosition position, DocumentEvent event) {
+                       String newText= event.getText();
+                       if (newText == null)
+                               newText= ""; //$NON-NLS-1$
+                       int eventNewLength= newText.length();
+
+                       int includedLength= 0;
+                       while (includedLength < eventNewLength && Character.isJavaIdentifierPart(newText.charAt(includedLength)))
+                               includedLength++;
+                       position.setLength(event.getOffset() - position.getOffset() + includedLength);
+               }
+
+               /**
+                * Update the given position with the given event. The event overlaps with the start of the position.
+                *
+                * @param position The position
+                * @param event The event
+                */
+               private void updateWithOverStartEvent(HighlightedPosition position, DocumentEvent event) {
+                       int eventOffset= event.getOffset();
+                       int eventEnd= eventOffset + event.getLength();
+
+                       String newText= event.getText();
+                       if (newText == null)
+                               newText= ""; //$NON-NLS-1$
+                       int eventNewLength= newText.length();
+
+                       int excludedLength= eventNewLength;
+                       while (excludedLength > 0 && Character.isJavaIdentifierPart(newText.charAt(excludedLength - 1)))
+                               excludedLength--;
+                       int deleted= eventEnd - position.getOffset();
+                       int inserted= eventNewLength - excludedLength;
+                       position.update(eventOffset + excludedLength, position.getLength() - deleted + inserted);
+               }
+
+               /**
+                * Update the given position with the given event. The event includes the position.
+                *
+                * @param position The position
+                * @param event The event
+                */
+               private void updateWithIncludingEvent(HighlightedPosition position, DocumentEvent event) {
+                       position.delete();
+                       position.update(event.getOffset(), 0);
+               }
+       }
+
+       /** Position updater */
+       private IPositionUpdater fPositionUpdater= new HighlightingPositionUpdater(getPositionCategory());
+
+       /** The source viewer this semantic highlighting reconciler is installed on */
+       private CSourceViewer fSourceViewer;
+       /** The background presentation reconciler */
+       private CPresentationReconciler fPresentationReconciler;
+
+       /** UI's current highlighted positions - can contain <code>null</code> elements */
+       private List<HighlightedPosition> fPositions= new ArrayList<HighlightedPosition>();
+       /** UI position lock */
+       private Object fPositionLock= new Object();
+
+       /** <code>true</code> iff the current reconcile is canceled. */
+       private boolean fIsCanceled= false;
+
+       /**
+        * Creates and returns a new highlighted position with the given offset, length and highlighting.
+        * <p>
+        * NOTE: Also called from background thread.
+        * </p>
+        *
+        * @param offset The offset
+        * @param length The length
+        * @param highlighting The highlighting
+        * @return The new highlighted position
+        */
+       public HighlightedPosition createHighlightedPosition(int offset, int length, HighlightingStyle highlighting) {
+               // TODO: reuse deleted positions
+               return new HighlightedPosition(offset, length, highlighting, fPositionUpdater);
+       }
+
+       /**
+        * Adds all current positions to the given list.
+        * <p>
+        * NOTE: Called from background thread.
+        * </p>
+        *
+        * @param list The list
+        */
+       public void addAllPositions(List<? super HighlightedPosition> list) {
+               synchronized (fPositionLock) {
+                       list.addAll(fPositions);
+               }
+       }
+
+       /**
+        * Create a text presentation in the background.
+        * <p>
+        * NOTE: Called from background thread.
+        * </p>
+        *
+        * @param addedPositions the added positions
+        * @param removedPositions the removed positions
+        * @return the text presentation or <code>null</code>, if reconciliation should be canceled
+        */
+       public TextPresentation createPresentation(List<? extends Position> addedPositions, List<? extends Position> removedPositions) {
+               CSourceViewer sourceViewer= fSourceViewer;
+               CPresentationReconciler presentationReconciler= fPresentationReconciler;
+               if (sourceViewer == null || presentationReconciler == null)
+                       return null;
+
+               if (isCanceled())
+                       return null;
+
+               IDocument document= sourceViewer.getDocument();
+               if (document == null)
+                       return null;
+
+               int minStart= Integer.MAX_VALUE;
+               int maxEnd= Integer.MIN_VALUE;
+               for (int i= 0, n= removedPositions.size(); i < n; i++) {
+                       Position position= removedPositions.get(i);
+                       int offset= position.getOffset();
+                       minStart= Math.min(minStart, offset);
+                       maxEnd= Math.max(maxEnd, offset + position.getLength());
+               }
+               for (int i= 0, n= addedPositions.size(); i < n; i++) {
+                       Position position= addedPositions.get(i);
+                       int offset= position.getOffset();
+                       minStart= Math.min(minStart, offset);
+                       maxEnd= Math.max(maxEnd, offset + position.getLength());
+               }
+
+               if (minStart < maxEnd)
+                       try {
+                               return presentationReconciler.createRepairDescription(new Region(minStart, maxEnd - minStart), document);
+                       } catch (RuntimeException e) {
+                               // Assume concurrent modification from UI thread
+                       }
+
+               return null;
+       }
+
+       /**
+        * Create a runnable for updating the presentation.
+        * <p>
+        * NOTE: Called from background thread.
+        * </p>
+        * @param textPresentation the text presentation
+        * @param addedPositions the added positions
+        * @param removedPositions the removed positions
+        * @return the runnable or <code>null</code>, if reconciliation should be canceled
+        */
+       public Runnable createUpdateRunnable(final TextPresentation textPresentation, List<HighlightedPosition> addedPositions, List<HighlightedPosition> removedPositions) {
+               if (fSourceViewer == null || textPresentation == null)
+                       return null;
+
+               // TODO: do clustering of positions and post multiple fast runnables
+               final HighlightedPosition[] added= addedPositions.toArray(new HighlightedPosition[addedPositions.size()]);
+               final HighlightedPosition[] removed= removedPositions.toArray(new HighlightedPosition[removedPositions.size()]);
+
+               if (isCanceled())
+                       return null;
+
+               Runnable runnable= new Runnable() {
+                       public void run() {
+                               updatePresentation(textPresentation, added, removed);
+                       }
+               };
+               return runnable;
+       }
+
+       /**
+        * Invalidate the presentation of the positions based on the given added positions and the existing deleted positions.
+        * Also unregisters the deleted positions from the document and patches the positions of this presenter.
+        * <p>
+        * NOTE: Indirectly called from background thread by UI runnable.
+        * </p>
+        * @param textPresentation the text presentation or <code>null</code>, if the presentation should computed in the UI thread
+        * @param addedPositions the added positions
+        * @param removedPositions the removed positions
+        */
+       public void updatePresentation(TextPresentation textPresentation, HighlightedPosition[] addedPositions, HighlightedPosition[] removedPositions) {
+               if (fSourceViewer == null)
+                       return;
+
+//             checkOrdering("added positions: ", Arrays.asList(addedPositions)); //$NON-NLS-1$
+//             checkOrdering("removed positions: ", Arrays.asList(removedPositions)); //$NON-NLS-1$
+//             checkOrdering("old positions: ", fPositions); //$NON-NLS-1$
+
+               // TODO: double-check consistency with document.getPositions(...)
+               // TODO: reuse removed positions
+               if (isCanceled())
+                       return;
+
+               IDocument document= fSourceViewer.getDocument();
+               if (document == null)
+                       return;
+
+               String positionCategory= getPositionCategory();
+
+               List<HighlightedPosition> removedPositionsList= Arrays.asList(removedPositions);
+
+               try {
+                       synchronized (fPositionLock) {
+                               List<HighlightedPosition> oldPositions= fPositions;
+                               int newSize= Math.max(fPositions.size() + addedPositions.length - removedPositions.length, 10);
+                               
+                               /*
+                                * The following loop is a kind of merge sort: it merges two List<Position>, each
+                                * sorted by position.offset, into one new list. The first of the two is the
+                                * previous list of positions (oldPositions), from which any deleted positions get
+                                * removed on the fly. The second of two is the list of added positions. The result
+                                * is stored in newPositions.
+                                */
+                               List<HighlightedPosition> newPositions= new ArrayList<HighlightedPosition>(newSize);
+                               HighlightedPosition position= null;
+                               HighlightedPosition addedPosition= null;
+                               for (int i= 0, j= 0, n= oldPositions.size(), m= addedPositions.length; i < n || position != null || j < m || addedPosition != null;) {
+                                       // loop variant: i + j < old(i + j)
+                                       
+                                       // a) find the next non-deleted Position from the old list
+                                       while (position == null && i < n) {
+                                               position= oldPositions.get(i++);
+                                               if (position.isDeleted() || contain(removedPositionsList, position)) {
+                                                       document.removePosition(positionCategory, position);
+                                                       position= null;
+                                               }
+                                       }
+                                       
+                                       // b) find the next Position from the added list
+                                       if (addedPosition == null && j < m) {
+                                               addedPosition= addedPositions[j++];
+                                               document.addPosition(positionCategory, addedPosition);
+                                       }
+                                       
+                                       // c) merge: add the next of position/addedPosition with the lower offset
+                                       if (position != null) {
+                                               if (addedPosition != null)
+                                                       if (position.getOffset() <= addedPosition.getOffset()) {
+                                                               newPositions.add(position);
+                                                               position= null;
+                                                       } else {
+                                                               newPositions.add(addedPosition);
+                                                               addedPosition= null;
+                                                       }
+                                               else {
+                                                       newPositions.add(position);
+                                                       position= null;
+                                               }
+                                       } else if (addedPosition != null) {
+                                               newPositions.add(addedPosition);
+                                               addedPosition= null;
+                                       }
+                               }
+                               fPositions= newPositions;
+                       }
+               } catch (BadPositionCategoryException e) {
+                       // Should not happen
+                       CUIPlugin.log(e);
+               } catch (BadLocationException e) {
+                       // Should not happen
+                       CUIPlugin.log(e);
+               }
+//             checkOrdering("new positions: ", fPositions); //$NON-NLS-1$
+
+               if (textPresentation != null)
+                       fSourceViewer.changeTextPresentation(textPresentation, false);
+               else
+                       fSourceViewer.invalidateTextPresentation();
+       }
+
+//     private void checkOrdering(String s, List positions) {
+//             Position previous= null;
+//             for (int i= 0, n= positions.size(); i < n; i++) {
+//                     Position current= (Position) positions.get(i);
+//                     if (previous != null && previous.getOffset() + previous.getLength() > current.getOffset())
+//                             return;
+//             }
+//     }
+
+       /**
+        * Returns <code>true</code> iff the positions contain the position.
+        * @param positions the positions, must be ordered by offset but may overlap
+        * @param position the position
+        * @return <code>true</code> iff the positions contain the position
+        */
+       private boolean contain(List<? extends Position> positions, Position position) {
+               return indexOf(positions, position) != -1;
+       }
+
+       /**
+        * Returns index of the position in the positions, <code>-1</code> if not found.
+        * @param positions the positions, must be ordered by offset but may overlap
+        * @param position the position
+        * @return the index
+        */
+       private int indexOf(List<? extends Position> positions, Position position) {
+               int index= computeIndexAtOffset(positions, position.getOffset());
+               int size= positions.size();
+               while (index < size) {
+                       if (positions.get(index) == position) 
+                               return index;
+                       index++;
+               }
+               return -1;
+       }
+
+       /**
+        * Insert the given position in <code>fPositions</code>, s.t. the offsets remain in linear order.
+        *
+        * @param position The position for insertion
+        */
+       private void insertPosition(HighlightedPosition position) {
+               int i= computeIndexAfterOffset(fPositions, position.getOffset());
+               fPositions.add(i, position);
+       }
+
+       /**
+        * Returns the index of the first position with an offset greater than the given offset.
+        *
+        * @param positions the positions, must be ordered by offset and must not overlap
+        * @param offset the offset
+        * @return the index of the last position with an offset greater than the given offset
+        */
+       private int computeIndexAfterOffset(List<? extends Position> positions, int offset) {
+               int i= -1;
+               int j= positions.size();
+               while (j - i > 1) {
+                       int k= (i + j) >> 1;
+                       Position position= positions.get(k);
+                       if (position.getOffset() > offset)
+                               j= k;
+                       else
+                               i= k;
+               }
+               return j;
+       }
+
+       /**
+        * Returns the index of the first position with an offset equal or greater than the given offset.
+        *
+        * @param positions the positions, must be ordered by offset and must not overlap
+        * @param offset the offset
+        * @return the index of the last position with an offset equal or greater than the given offset
+        */
+       private int computeIndexAtOffset(List<? extends Position> positions, int offset) {
+               int i= -1;
+               int j= positions.size();
+               while (j - i > 1) {
+                       int k= (i + j) >> 1;
+                       Position position= positions.get(k);
+                       if (position.getOffset() >= offset)
+                               j= k;
+                       else
+                               i= k;
+               }
+               return j;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.ITextPresentationListener#applyTextPresentation(org.eclipse.jface.text.TextPresentation)
+        */
+       public void applyTextPresentation(TextPresentation textPresentation) {
+               IRegion region= textPresentation.getExtent();
+               int i= computeIndexAtOffset(fPositions, region.getOffset()), n= computeIndexAtOffset(fPositions, region.getOffset() + region.getLength());
+               if (n - i > 2) {
+                       List<StyleRange> ranges= new ArrayList<StyleRange>(n - i);
+                       for (; i < n; i++) {
+                               HighlightedPosition position= fPositions.get(i);
+                               if (!position.isDeleted())
+                                       ranges.add(position.createStyleRange());
+                       }
+                       StyleRange[] array= new StyleRange[ranges.size()];
+                       array= ranges.toArray(array);
+                       textPresentation.replaceStyleRanges(array);
+               } else {
+                       for (; i < n; i++) {
+                               HighlightedPosition position= fPositions.get(i);
+                               if (!position.isDeleted())
+                                       textPresentation.replaceStyleRange(position.createStyleRange());
+                       }
+               }
+       }
+
+       /*
+        * @see org.eclipse.jface.text.ITextInputListener#inputDocumentAboutToBeChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument)
+        */
+       public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
+               setCanceled(true);
+               releaseDocument(oldInput);
+               resetState();
+       }
+
+       /*
+        * @see org.eclipse.jface.text.ITextInputListener#inputDocumentChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument)
+        */
+       public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
+               manageDocument(newInput);
+       }
+
+       /*
+        * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
+        */
+       public void documentAboutToBeChanged(DocumentEvent event) {
+               setCanceled(true);
+       }
+
+       /*
+        * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent)
+        */
+       public void documentChanged(DocumentEvent event) {
+       }
+
+       /**
+        * @return Returns <code>true</code> iff the current reconcile is canceled.
+        * <p>
+        * NOTE: Also called from background thread.
+        * </p>
+        */
+       public boolean isCanceled() {
+               IDocument document= fSourceViewer != null ? fSourceViewer.getDocument() : null;
+               if (document == null)
+                       return fIsCanceled;
+
+               synchronized (getLockObject(document)) {
+                       return fIsCanceled;
+               }
+       }
+
+       /**
+        * Set whether or not the current reconcile is canceled.
+        *
+        * @param isCanceled <code>true</code> iff the current reconcile is canceled
+        */
+       public void setCanceled(boolean isCanceled) {
+               IDocument document= fSourceViewer != null ? fSourceViewer.getDocument() : null;
+               if (document == null) {
+                       fIsCanceled= isCanceled;
+                       return;
+               }
+
+               synchronized (getLockObject(document)) {
+                       fIsCanceled= isCanceled;
+               }
+       }
+
+       /**
+        * @param document the document
+        * @return the document's lock object
+        */
+       private Object getLockObject(IDocument document) {
+               if (document instanceof ISynchronizable) {
+                       Object lock= ((ISynchronizable)document).getLockObject();
+                       if (lock != null)
+                               return lock;
+               }
+               return document;
+       }
+
+       /**
+        * Install this presenter on the given source viewer and background presentation
+        * reconciler.
+        *
+        * @param sourceViewer the source viewer
+        * @param backgroundPresentationReconciler the background presentation reconciler,
+        *      can be <code>null</code>, in that case {@link SemanticHighlightingPresenter#createPresentation(List, List)}
+        *      should not be called
+        */
+       public void install(CSourceViewer sourceViewer, CPresentationReconciler backgroundPresentationReconciler) {
+               fSourceViewer= sourceViewer;
+               fPresentationReconciler= backgroundPresentationReconciler;
+
+               fSourceViewer.prependTextPresentationListener(this);
+               fSourceViewer.addTextInputListener(this);
+               manageDocument(fSourceViewer.getDocument());
+       }
+
+       /**
+        * Uninstall this presenter.
+        */
+       public void uninstall() {
+               setCanceled(true);
+
+               if (fSourceViewer != null) {
+                       fSourceViewer.removeTextPresentationListener(this);
+                       releaseDocument(fSourceViewer.getDocument());
+                       invalidateTextPresentation();
+                       resetState();
+
+                       fSourceViewer.removeTextInputListener(this);
+                       fSourceViewer= null;
+               }
+       }
+
+       /**
+        * Invalidate text presentation of positions with the given highlighting.
+        *
+        * @param highlighting The highlighting
+        */
+       public void highlightingStyleChanged(HighlightingStyle highlighting) {
+               for (int i= 0, n= fPositions.size(); i < n; i++) {
+                       HighlightedPosition position= fPositions.get(i);
+                       if (position.getHighlighting() == highlighting)
+                               fSourceViewer.invalidateTextPresentation(position.getOffset(), position.getLength());
+               }
+       }
+
+       /**
+        * Invalidate text presentation of all positions.
+        */
+       private void invalidateTextPresentation() {
+               if (fPositions.size() > 1000) {
+                       fSourceViewer.invalidateTextPresentation();
+               } else {
+                       for (int i= 0, n= fPositions.size(); i < n; i++) {
+                               Position position= fPositions.get(i);
+                               fSourceViewer.invalidateTextPresentation(position.getOffset(), position.getLength());
+                       }
+               }
+       }
+
+       /**
+        * Add a position with the given range and highlighting unconditionally, only from UI thread.
+        * The position will also be registered on the document. The text presentation is not invalidated.
+        *
+        * @param offset The range offset
+        * @param length The range length
+        * @param highlighting
+        */
+       private void addPositionFromUI(int offset, int length, HighlightingStyle highlighting) {
+               HighlightedPosition position= createHighlightedPosition(offset, length, highlighting);
+               synchronized (fPositionLock) {
+                       insertPosition(position);
+               }
+
+               IDocument document= fSourceViewer.getDocument();
+               if (document == null)
+                       return;
+               String positionCategory= getPositionCategory();
+               try {
+                       document.addPosition(positionCategory, position);
+               } catch (BadLocationException e) {
+                       // Should not happen
+                       CUIPlugin.log(e);
+               } catch (BadPositionCategoryException e) {
+                       // Should not happen
+                       CUIPlugin.log(e);
+               }
+       }
+
+       /**
+        * Reset to initial state.
+        */
+       private void resetState() {
+               synchronized (fPositionLock) {
+                       fPositions.clear();
+               }
+       }
+
+       /**
+        * Start managing the given document.
+        *
+        * @param document The document
+        */
+       private void manageDocument(IDocument document) {
+               if (document != null) {
+                       document.addPositionCategory(getPositionCategory());
+                       document.addPositionUpdater(fPositionUpdater);
+                       document.addDocumentListener(this);
+               }
+       }
+
+       /**
+        * Stop managing the given document.
+        *
+        * @param document The document
+        */
+       private void releaseDocument(IDocument document) {
+               if (document != null) {
+                       document.removeDocumentListener(this);
+                       document.removePositionUpdater(fPositionUpdater);
+                       try {
+                               document.removePositionCategory(getPositionCategory());
+                       } catch (BadPositionCategoryException e) {
+                               // Should not happen
+                               CUIPlugin.log(e);
+                       }
+               }
+       }
+
+       /**
+        * @return The semantic reconciler position's category.
+        */
+       private String getPositionCategory() {
+               return toString();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconciler.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightingReconciler.java
new file mode 100644 (file)
index 0000000..14c0ff1
--- /dev/null
@@ -0,0 +1,552 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems) - Adapted for CDT
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.TextPresentation;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPartSite;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTImageLocation;
+import org.eclipse.cdt.core.dom.ast.IASTMacroExpansionLocation;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroExpansion;
+import org.eclipse.cdt.core.dom.ast.IASTStatement;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.model.ASTCache;
+
+import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingManager.HighlightedPosition;
+import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingManager.HighlightingStyle;
+import org.eclipse.cdt.internal.ui.text.ICReconcilingListener;
+
+
+/**
+ * Semantic highlighting reconciler - Background thread implementation.
+ * Cloned from JDT.
+ * 
+ * @since 4.0
+ */
+public class SemanticHighlightingReconciler implements ICReconcilingListener {
+
+       /**
+        * Collects positions from the AST.
+        */
+       private class PositionCollector extends ASTVisitor {
+
+               /** The semantic token */
+               private SemanticToken fToken= new SemanticToken();
+               private int fMinLocation;
+               
+               public PositionCollector(boolean visitImplicitNames) {
+                       fMinLocation= -1;
+                       shouldVisitTranslationUnit= true;
+                       shouldVisitNames= true;
+                       shouldVisitDeclarations= true;
+                       shouldVisitExpressions= true;
+                       shouldVisitStatements= true;
+                       shouldVisitDeclarators= true;
+                       shouldVisitNamespaces= true;
+                       shouldVisitImplicitNames = visitImplicitNames;
+                       shouldVisitImplicitNameAlternates = visitImplicitNames;
+               }
+
+               /*
+                * @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTTranslationUnit)
+                */
+               @Override
+               public int visit(IASTTranslationUnit tu) {
+                       
+                       // visit macro definitions
+                       IASTPreprocessorMacroDefinition[] macroDefs= tu.getMacroDefinitions();
+                       for (IASTPreprocessorMacroDefinition macroDef : macroDefs) {
+                               if (macroDef.isPartOfTranslationUnitFile()) {
+                                       visitNode(macroDef.getName());
+                               }
+                       }
+                       fMinLocation= -1;
+
+                       // visit macro expansions
+                       IASTPreprocessorMacroExpansion[] macroExps= tu.getMacroExpansions();
+                       for (IASTPreprocessorMacroExpansion macroExp : macroExps) {
+                               if (macroExp.isPartOfTranslationUnitFile()) {
+                                       IASTName macroRef= macroExp.getMacroReference();
+                                       visitNode(macroRef);
+                                       IASTName[] nestedMacroRefs= macroExp.getNestedMacroReferences();
+                                       for (IASTName nestedMacroRef : nestedMacroRefs) {
+                                               visitNode(nestedMacroRef);
+                                       }
+                               }
+                       }
+                       fMinLocation= -1;
+
+                       // visit ordinary code
+                       return super.visit(tu);
+               }
+
+               /*
+                * @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTDeclaration)
+                */
+               @Override
+               public int visit(IASTDeclaration declaration) {
+                       if (!declaration.isPartOfTranslationUnitFile()) {
+                               return PROCESS_SKIP;
+                       }
+                       return PROCESS_CONTINUE;
+               }
+
+               /*
+                * @see org.eclipse.cdt.core.dom.ast.ASTVisitor#leave(org.eclipse.cdt.core.dom.ast.IASTDeclaration)
+                */
+               @Override
+               public int leave(IASTDeclaration declaration) {
+//                     if (!shouldVisitCatchHandlers && declaration instanceof IASTFunctionDefinition) {
+//                             shouldVisitCatchHandlers= true;
+//                             IASTFunctionDefinition functionDef= (IASTFunctionDefinition) declaration;
+//                             ICPPASTFunctionTryBlockDeclarator declarator= (ICPPASTFunctionTryBlockDeclarator) functionDef.getDeclarator();
+//                             ICPPASTCatchHandler[] catchHandlers= declarator.getCatchHandlers();
+//                             for (ICPPASTCatchHandler catchHandler : catchHandlers) {
+//                                     catchHandler.accept(this);
+//                             }
+//                     }
+                       return PROCESS_CONTINUE;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor#visit(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition)
+                */
+               @Override
+               public int visit(ICPPASTNamespaceDefinition namespace) {
+                       if (!namespace.isPartOfTranslationUnitFile()) {
+                               return PROCESS_SKIP;
+                       }
+                       return PROCESS_CONTINUE;
+               }
+
+               /*
+                * @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTDeclarator)
+                */
+               @Override
+               public int visit(IASTDeclarator declarator) {
+//                     if (declarator instanceof ICPPASTFunctionTryBlockDeclarator) {
+//                             shouldVisitCatchHandlers= false;
+//                     }
+                       return PROCESS_CONTINUE;
+               }
+
+               /*
+                * @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTStatement)
+                */
+               @Override
+               public int visit(IASTStatement statement) {
+//                     if (!shouldVisitCatchHandlers && statement instanceof ICPPASTCatchHandler) {
+//                             return PROCESS_SKIP;
+//                     }
+                       return PROCESS_CONTINUE;
+               }
+
+               /*
+                * @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTName)
+                */
+               @Override
+               public int visit(IASTName name) {
+                       if (visitNode(name)) {
+                               return PROCESS_SKIP;
+                       }
+                       return PROCESS_CONTINUE;
+               }
+               
+               private boolean visitNode(IASTNode node) {
+                       boolean consumed= false;
+                       fToken.update(node);
+                       for (int i= 0, n= fJobSemanticHighlightings.length; i < n; ++i) {
+                               SemanticHighlighting semanticHighlighting= fJobSemanticHighlightings[i];
+                               if (fJobHighlightings[i].isEnabled() && semanticHighlighting.consumes(fToken)) {
+                                       if (node instanceof IASTName) {
+                                               addNameLocation((IASTName)node, fJobHighlightings[i]);
+                                       } else {
+                                               addNodeLocation(node.getFileLocation(), fJobHighlightings[i]);
+                                       }
+                                       consumed= true;
+                                       break;
+                               }
+                       }
+                       fToken.clear();
+                       return consumed;
+               }
+
+               /**
+                * Add the a location range for the given name.
+                * 
+                * @param name  The name
+                * @param highlighting The highlighting
+                */
+               private void addNameLocation(IASTName name, HighlightingStyle highlightingStyle) {
+                       IASTImageLocation imageLocation= name.getImageLocation();
+                       if (imageLocation != null) {
+                               if (imageLocation.getLocationKind() != IASTImageLocation.MACRO_DEFINITION) {
+                                       int offset= imageLocation.getNodeOffset();
+                                       if (offset >= fMinLocation) {
+                                               int length= imageLocation.getNodeLength();
+                                               if (offset > -1 && length > 0) {
+                                                       fMinLocation= offset + length;
+                                                       addPosition(offset, length, highlightingStyle);
+                                               }
+                                       }
+                               }
+                       } else {
+                               // fallback in case no image location available
+                               IASTNodeLocation[] nodeLocations= name.getNodeLocations();
+                               if (nodeLocations.length == 1 && !(nodeLocations[0] instanceof IASTMacroExpansionLocation)) {
+                                       addNodeLocation(nodeLocations[0], highlightingStyle);
+                               }
+                       }
+               }
+
+               /**
+                * Add the a location range for the given highlighting.
+                * 
+                * @param nodeLocation  The node location
+                * @param highlighting The highlighting
+                */
+               private void addNodeLocation(IASTNodeLocation nodeLocation, HighlightingStyle highlighting) {
+                       if (nodeLocation == null) {
+                               return;
+                       }
+                       int offset= nodeLocation.getNodeOffset();
+                       if (offset >= fMinLocation) {
+                               int length= nodeLocation.getNodeLength();
+                               if (offset > -1 && length > 0) {
+                                       fMinLocation= offset + length;
+                                       addPosition(offset, length, highlighting);
+                               }
+                       }
+               }
+
+               /**
+                * Add a position with the given range and highlighting iff it does not exist already.
+                * 
+                * @param offset The range offset
+                * @param length The range length
+                * @param highlighting The highlighting
+                */
+               private void addPosition(int offset, int length, HighlightingStyle highlighting) {
+                       boolean isExisting= false;
+                       // TODO: use binary search
+                       for (int i= 0, n= fRemovedPositions.size(); i < n; i++) {
+                               HighlightedPosition position= fRemovedPositions.get(i);
+                               if (position == null)
+                                       continue;
+                               if (position.isEqual(offset, length, highlighting)) {
+                                       isExisting= true;
+                                       fRemovedPositions.set(i, null);
+                                       fNOfRemovedPositions--;
+                                       break;
+                               }
+                       }
+
+                       if (!isExisting) {
+                               HighlightedPosition position= fJobPresenter.createHighlightedPosition(offset, length, highlighting);
+                               fAddedPositions.add(position);
+                       }
+               }
+
+       }
+
+       /** The C editor this semantic highlighting reconciler is installed on */
+       private CEditor fEditor;
+       /** The semantic highlighting presenter */
+       private SemanticHighlightingPresenter fPresenter;
+       /** Semantic highlightings */
+       private SemanticHighlighting[] fSemanticHighlightings;
+       /** Highlightings */
+       private HighlightingStyle[] fHighlightings;
+
+       /** Background job's added highlighted positions */
+       private List<HighlightedPosition> fAddedPositions= new ArrayList<HighlightedPosition>();
+       /** Background job's removed highlighted positions */
+       private List<HighlightedPosition> fRemovedPositions= new ArrayList<HighlightedPosition>();
+       /** Number of removed positions */
+       private int fNOfRemovedPositions;
+
+       /** Background job */
+       private Job fJob;
+       /** Background job lock */
+       private final Object fJobLock= new Object();
+       /** Reconcile operation lock. */
+       private final Object fReconcileLock= new Object();
+       /**
+        * <code>true</code> if any thread is executing
+        * <code>reconcile</code>, <code>false</code> otherwise.
+        */
+       private boolean fIsReconciling= false;
+
+       /** The semantic highlighting presenter - cache for background thread, only valid during {@link #reconciled(IASTTranslationUnit, boolean, IProgressMonitor)} */
+       private SemanticHighlightingPresenter fJobPresenter;
+       /** Semantic highlightings - cache for background thread, only valid during {@link #reconciled(IASTTranslationUnit, boolean, IProgressMonitor)} */
+       private SemanticHighlighting[] fJobSemanticHighlightings;
+       /** Highlightings - cache for background thread, only valid during {@link #reconciled(IASTTranslationUnit, boolean, IProgressMonitor)} */
+       private HighlightingStyle[] fJobHighlightings;
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.java.ICReconcilingListener#aboutToBeReconciled()
+        */
+       public void aboutToBeReconciled() {
+               // Do nothing
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#reconciled(IASTTranslationUnit, boolean, IProgressMonitor)
+        */
+       public void reconciled(IASTTranslationUnit ast, boolean force, IProgressMonitor progressMonitor) {
+               // ensure at most one thread can be reconciling at any time
+               synchronized (fReconcileLock) {
+                       if (fIsReconciling)
+                               return;
+                       fIsReconciling= true;
+               }
+               fJobPresenter= fPresenter;
+               fJobSemanticHighlightings= fSemanticHighlightings;
+               fJobHighlightings= fHighlightings;
+               
+               try {
+                       if (fJobPresenter == null || fJobSemanticHighlightings == null || fJobHighlightings == null)
+                               return;
+                       
+                       fJobPresenter.setCanceled(progressMonitor != null && progressMonitor.isCanceled());
+                       
+                       if (ast == null || fJobPresenter.isCanceled())
+                               return;
+                       
+                       PositionCollector collector= new PositionCollector(requiresImplicitNames());
+
+                       startReconcilingPositions();
+                       
+                       if (!fJobPresenter.isCanceled())
+                               reconcilePositions(ast, collector);
+                       
+                       TextPresentation textPresentation= null;
+                       if (!fJobPresenter.isCanceled())
+                               textPresentation= fJobPresenter.createPresentation(fAddedPositions, fRemovedPositions);
+                       
+                       if (!fJobPresenter.isCanceled())
+                               updatePresentation(textPresentation, fAddedPositions, fRemovedPositions);
+                       
+                       stopReconcilingPositions();
+               } finally {
+                       fJobPresenter= null;
+                       fJobSemanticHighlightings= null;
+                       fJobHighlightings= null;
+                       synchronized (fReconcileLock) {
+                               fIsReconciling= false;
+                       }
+               }
+       }
+
+       private boolean requiresImplicitNames() {
+               for (int i = 0; i < fSemanticHighlightings.length; i++) {
+                       SemanticHighlighting sh = fSemanticHighlightings[i];
+                       if (sh.requiresImplicitNames() && fHighlightings[i].isEnabled()) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+       /**
+        * Start reconciling positions.
+        */
+       private void startReconcilingPositions() {
+               fJobPresenter.addAllPositions(fRemovedPositions);
+               fNOfRemovedPositions= fRemovedPositions.size();
+       }
+
+       /**
+        * Reconcile positions based on the AST.
+        *
+        * @param ast  the AST
+        * @param visitor  the AST visitor
+        */
+       private void reconcilePositions(IASTTranslationUnit ast, PositionCollector visitor) {
+               ast.accept(visitor);
+               List<HighlightedPosition> oldPositions= fRemovedPositions;
+               List<HighlightedPosition> newPositions= new ArrayList<HighlightedPosition>(fNOfRemovedPositions);
+               for (int i= 0, n= oldPositions.size(); i < n; i ++) {
+                       HighlightedPosition current= oldPositions.get(i);
+                       if (current != null)
+                               newPositions.add(current);
+               }
+               fRemovedPositions= newPositions;
+               // positions need to be sorted by ascending offset
+               Collections.sort(fAddedPositions, new Comparator<Position>() {
+                       public int compare(final Position p1, final Position p2) {
+                               return p1.getOffset() - p2.getOffset();
+                       }});
+       }
+
+       /**
+        * Update the presentation.
+        *
+        * @param textPresentation the text presentation
+        * @param addedPositions the added positions
+        * @param removedPositions the removed positions
+        */
+       private void updatePresentation(TextPresentation textPresentation, List<HighlightedPosition> addedPositions, List<HighlightedPosition> removedPositions) {
+               Runnable runnable= fJobPresenter.createUpdateRunnable(textPresentation, addedPositions, removedPositions);
+               if (runnable == null)
+                       return;
+
+               CEditor editor= fEditor;
+               if (editor == null)
+                       return;
+
+               IWorkbenchPartSite site= editor.getSite();
+               if (site == null)
+                       return;
+
+               Shell shell= site.getShell();
+               if (shell == null || shell.isDisposed())
+                       return;
+
+               Display display= shell.getDisplay();
+               if (display == null || display.isDisposed())
+                       return;
+
+               display.asyncExec(runnable);
+       }
+
+       /**
+        * Stop reconciling positions.
+        */
+       private void stopReconcilingPositions() {
+               fRemovedPositions.clear();
+               fNOfRemovedPositions= 0;
+               fAddedPositions.clear();
+       }
+
+       /**
+        * Install this reconciler on the given editor, presenter and highlightings.
+        * @param editor the editor
+        * @param sourceViewer the source viewer
+        * @param presenter the semantic highlighting presenter
+        * @param semanticHighlightings the semantic highlightings
+        * @param highlightings the highlightings
+        */
+       public void install(CEditor editor, ISourceViewer sourceViewer, SemanticHighlightingPresenter presenter, SemanticHighlighting[] semanticHighlightings, HighlightingStyle[] highlightings) {
+               fPresenter= presenter;
+               fSemanticHighlightings= semanticHighlightings;
+               fHighlightings= highlightings;
+
+               fEditor= editor;
+
+               if (fEditor != null) {
+                       fEditor.addReconcileListener(this);
+               }
+       }
+
+       /**
+        * Uninstall this reconciler from the editor
+        */
+       public void uninstall() {
+               if (fPresenter != null)
+                       fPresenter.setCanceled(true);
+
+               if (fEditor != null) {
+                       fEditor.removeReconcileListener(this);
+                       fEditor= null;
+               }
+
+               fSemanticHighlightings= null;
+               fHighlightings= null;
+               fPresenter= null;
+       }
+
+       /**
+        * Schedule a background job for retrieving the AST and reconciling the Semantic Highlighting model.
+        */
+       private void scheduleJob() {
+               final ICElement element= fEditor.getInputCElement();
+
+               synchronized (fJobLock) {
+                       final Job oldJob= fJob;
+                       if (fJob != null) {
+                               fJob.cancel();
+                               fJob= null;
+                       }
+                       
+                       if (element != null) {
+                               fJob= new Job(CEditorMessages.SemanticHighlighting_job) { 
+                                       @Override
+                                       protected IStatus run(final IProgressMonitor monitor) {
+                                               if (oldJob != null) {
+                                                       try {
+                                                               oldJob.join();
+                                                       } catch (InterruptedException e) {
+                                                               CUIPlugin.log(e);
+                                                               return Status.CANCEL_STATUS;
+                                                       }
+                                               }
+                                               if (monitor.isCanceled())
+                                                       return Status.CANCEL_STATUS;
+                                               
+                                               final Job me= this;
+                                               ASTProvider astProvider= CUIPlugin.getDefault().getASTProvider();
+                                               IStatus status= astProvider.runOnAST(element, ASTProvider.WAIT_IF_OPEN, monitor, new ASTCache.ASTRunnable() {
+                                                       public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
+                                                               reconciled(ast, true, monitor);
+                                                               synchronized (fJobLock) {
+                                                                       // allow the job to be gc'ed
+                                                                       if (fJob == me)
+                                                                               fJob= null;
+                                                               }
+                                                               return Status.OK_STATUS;
+                                                       }
+                                               });
+                                               return status;
+                                       }
+                               };
+//                             fJob.setSystem(true);
+                               fJob.setPriority(Job.SHORT);
+                               fJob.schedule();
+                       }
+               }
+       }
+
+       /**
+        * Refreshes the highlighting.
+        */
+       public void refresh() {
+               scheduleJob();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java
new file mode 100644 (file)
index 0000000..8d872ec
--- /dev/null
@@ -0,0 +1,2179 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems) - Adapted for CDT
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.editor;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.graphics.RGB;
+
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTImplicitName;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTProblem;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IEnumeration;
+import org.eclipse.cdt.core.dom.ast.IEnumerator;
+import org.eclipse.cdt.core.dom.ast.IField;
+import org.eclipse.cdt.core.dom.ast.IFunction;
+import org.eclipse.cdt.core.dom.ast.ILabel;
+import org.eclipse.cdt.core.dom.ast.IMacroBinding;
+import org.eclipse.cdt.core.dom.ast.IParameter;
+import org.eclipse.cdt.core.dom.ast.IProblemBinding;
+import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.core.dom.ast.ITypedef;
+import org.eclipse.cdt.core.dom.ast.IVariable;
+import org.eclipse.cdt.core.dom.ast.c.ICExternalBinding;
+import org.eclipse.cdt.core.dom.ast.c.ICFunctionScope;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexBinding;
+import org.eclipse.cdt.core.index.IIndexFile;
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
+
+/**
+ * Semantic highlightings.
+ * Derived from JDT.
+ * 
+ * @since 4.0
+ */
+public class SemanticHighlightings {
+
+       private static final RGB RGB_BLACK = new RGB(0, 0, 0);
+
+       /**
+        * A named preference part that controls the highlighting of static fields.
+        */
+       public static final String STATIC_FIELD="staticField"; //$NON-NLS-1$
+
+       /**
+        * A named preference part that controls the highlighting of fields.
+        */
+       public static final String FIELD="field"; //$NON-NLS-1$
+
+       /**
+        * A named preference part that controls the highlighting of method declarations.
+        */
+       public static final String METHOD_DECLARATION="methodDeclaration"; //$NON-NLS-1$
+
+       /**
+        * A named preference part that controls the highlighting of static method invocations.
+        */
+       public static final String STATIC_METHOD_INVOCATION="staticMethod"; //$NON-NLS-1$
+
+       /**
+        * A named preference part that controls the highlighting of function declarations.
+        */
+       public static final String FUNCTION_DECLARATION="functionDeclaration"; //$NON-NLS-1$
+
+       /**
+        * A named preference part that controls the highlighting of functions.
+        */
+       public static final String FUNCTION="function"; //$NON-NLS-1$
+
+       /**
+        * A named preference part that controls the highlighting of local variables.
+        */
+       public static final String LOCAL_VARIABLE_DECLARATION="localVariableDeclaration"; //$NON-NLS-1$
+
+       /**
+        * A named preference part that controls the highlighting of local variable references.
+        */
+       public static final String LOCAL_VARIABLE="localVariable"; //$NON-NLS-1$
+
+       /**
+        * A named preference part that controls the highlighting of global variables.
+        */
+       public static final String GLOBAL_VARIABLE="globalVariable"; //$NON-NLS-1$
+
+       /**
+        * A named preference part that controls the highlighting of parameter variables.
+        */
+       public static final String PARAMETER_VARIABLE="parameterVariable"; //$NON-NLS-1$
+
+       /**
+        * A named preference part that controls the highlighting of template parameters.
+        */
+       public static final String TEMPLATE_PARAMETER="templateParameter"; //$NON-NLS-1$
+
+       /**
+        * A named preference part that controls the highlighting of methods.
+        */
+       public static final String METHOD="method"; //$NON-NLS-1$
+
+       /**
+        * A named preference part that controls the highlighting of classes.
+        */
+       public static final String CLASS="class"; //$NON-NLS-1$
+       
+       /**
+        * A named preference part that controls the highlighting of enums.
+        */
+       public static final String ENUM="enum"; //$NON-NLS-1$
+       
+       /**
+        * A named preference part that controls the highlighting of macro references.
+        */
+       public static final String MACRO_REFERENCE="macroSubstitution"; //$NON-NLS-1$
+
+       /**
+        * A named preference part that controls the highlighting of macro definitions.
+        */
+       public static final String MACRO_DEFINITION="macroDefinition"; //$NON-NLS-1$
+
+       /**
+        * A named preference part that controls the highlighting of typedefs.
+        */
+       public static final String TYPEDEF="typedef"; //$NON-NLS-1$
+
+       /**
+        * A named preference part that controls the highlighting of namespaces.
+        */
+       public static final String NAMESPACE="namespace"; //$NON-NLS-1$
+
+       /**
+        * A named preference part that controls the highlighting of labels.
+        */
+       public static final String LABEL="label"; //$NON-NLS-1$
+
+       /**
+        * A named preference part that controls the highlighting of enumerators.
+        */
+       public static final String ENUMERATOR="enumerator"; //$NON-NLS-1$
+
+       /**
+        * A named preference part that controls the highlighting of problems.
+        */
+       public static final String PROBLEM="problem"; //$NON-NLS-1$
+
+       /**
+        * A named preference part that controls the highlighting of external SDK.
+        */
+       public static final String EXTERNAL_SDK="externalSDK"; //$NON-NLS-1$
+       
+       /**
+        * A named preference part that controls the highlighting of operators that have been overloaded.
+        */
+       public static final String OVERLOADED_OPERATOR="overloadedOperator"; //$NON-NLS-1$
+       
+
+       /** Init debugging mode */
+       private static final boolean DEBUG= "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.cdt.ui/debug/SemanticHighlighting"));  //$NON-NLS-1$//$NON-NLS-2$
+       
+       /**
+        * Semantic highlightings
+        */
+       private static SemanticHighlighting[] fgSemanticHighlightings;
+
+       /**
+        * Semantic highlighting for static fields.
+        */
+       private static final class StaticFieldHighlighting extends SemanticHighlighting {
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey()
+                */
+               @Override
+               public String getPreferenceKey() {
+                       return STATIC_FIELD;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor()
+                */
+               @Override
+               public RGB getDefaultTextColor() {
+                       return new RGB(0, 0, 192);
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold()
+                */
+               @Override
+               public boolean isBoldByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault()
+                */
+               @Override
+               public boolean isItalicByDefault() {
+                       return true;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault()
+                */
+               @Override
+               public boolean isEnabledByDefault() {
+                       return true;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName()
+                */
+               @Override
+               public String getDisplayName() {
+                       return CEditorMessages.SemanticHighlighting_staticField; 
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken)
+                */
+               @Override
+               public boolean consumes(SemanticToken token) {
+                       IASTNode node= token.getNode();
+                       if (node instanceof IASTName) {
+                               IASTName name= (IASTName)node;
+                               if (name instanceof ICPPASTQualifiedName && name.isReference()) {
+                                       return false;
+                               }
+                               IBinding binding= token.getBinding();
+                               if (binding instanceof IField && !(binding instanceof IProblemBinding)) {
+                                       return ((IField)binding).isStatic();
+                               }
+                       }
+                       return false;
+               }
+       }
+
+       /**
+        * Semantic highlighting for fields.
+        */
+       private static final class FieldHighlighting extends SemanticHighlighting {
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey()
+                */
+               @Override
+               public String getPreferenceKey() {
+                       return FIELD;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor()
+                */
+               @Override
+               public RGB getDefaultTextColor() {
+                       return new RGB(0, 0, 192);
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold()
+                */
+               @Override
+               public boolean isBoldByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault()
+                */
+               @Override
+               public boolean isItalicByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault()
+                */
+               @Override
+               public boolean isEnabledByDefault() {
+                       return true;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName()
+                */
+               @Override
+               public String getDisplayName() {
+                       return CEditorMessages.SemanticHighlighting_field; 
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken)
+                */
+               @Override
+               public boolean consumes(SemanticToken token) {
+                       IASTNode node= token.getNode();
+                       if (node instanceof IASTName) {
+                               IASTName name= (IASTName)node;
+                               if (name instanceof ICPPASTQualifiedName && name.isReference()) {
+                                       return false;
+                               }
+                               IBinding binding= token.getBinding();
+                               if (binding instanceof IField) {
+                                       return true;
+                               }
+                       }
+                       return false;
+               }
+       }
+
+       /**
+        * Semantic highlighting for method declarations.
+        */
+       private static final class MethodDeclarationHighlighting extends SemanticHighlighting {
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey()
+                */
+               @Override
+               public String getPreferenceKey() {
+                       return METHOD_DECLARATION;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor()
+                */
+               @Override
+               public RGB getDefaultTextColor() {
+                       return RGB_BLACK;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold()
+                */
+               @Override
+               public boolean isBoldByDefault() {
+                       return true;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault()
+                */
+               @Override
+               public boolean isItalicByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault()
+                */
+               @Override
+               public boolean isEnabledByDefault() {
+                       return true;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName()
+                */
+               @Override
+               public String getDisplayName() {
+                       return CEditorMessages.SemanticHighlighting_methodDeclaration; 
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken)
+                */
+               @Override
+               public boolean consumes(SemanticToken token) {
+                       IASTNode node= token.getNode();
+                       if (node instanceof IASTImplicitName)
+                               return false;
+
+                       if (node instanceof IASTName) {
+                               IASTName name= (IASTName)node;
+                               if (!name.isReference()) {
+                                       IBinding binding= token.getBinding();
+                                       if (binding instanceof ICPPMethod) {
+                                               return true;
+                                       } else if (binding instanceof IProblemBinding) {
+                                               // try to be derive from AST
+                                               node= name.getParent();
+                                               while (node instanceof IASTName) {
+                                                       node= node.getParent();
+                                               }
+                                               if (node instanceof ICPPASTFunctionDeclarator) {
+                                                       if (name instanceof ICPPASTQualifiedName) {
+                                                               ICPPASTQualifiedName qName= (ICPPASTQualifiedName)name;
+                                                               IASTName[] names= qName.getNames();
+                                                               if (names.length > 1) {
+                                                                       if (names[names.length - 2].getBinding() instanceof ICPPClassType) {
+                                                                               return true;
+                                                                       }
+                                                               }
+                                                       } else {
+                                                               while (node != token.getRoot() && !(node.getParent() instanceof IASTDeclSpecifier)) {
+                                                                       node= node.getParent();
+                                                               }
+                                                               if (node instanceof ICPPASTCompositeTypeSpecifier) {
+                                                                       return true;
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+                       return false;
+               }
+       }
+
+       /**
+        * Semantic highlighting for static method invocations.
+        */
+       private static final class StaticMethodInvocationHighlighting extends SemanticHighlighting {
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey()
+                */
+               @Override
+               public String getPreferenceKey() {
+                       return STATIC_METHOD_INVOCATION;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor()
+                */
+               @Override
+               public RGB getDefaultTextColor() {
+                       return RGB_BLACK;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold()
+                */
+               @Override
+               public boolean isBoldByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault()
+                */
+               @Override
+               public boolean isItalicByDefault() {
+                       return true;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault()
+                */
+               @Override
+               public boolean isEnabledByDefault() {
+                       return true;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName()
+                */
+               @Override
+               public String getDisplayName() {
+                       return CEditorMessages.SemanticHighlighting_staticMethodInvocation; 
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken)
+                */
+               @Override
+               public boolean consumes(SemanticToken token) {
+                       IASTNode node= token.getNode();
+                       if (node instanceof IASTName) {
+                               IASTName name= (IASTName)node;
+                               if (name instanceof ICPPASTQualifiedName) {
+                                       return false;
+                               }
+                               if (!name.isReference()) {
+                                       return false;
+                               }
+                               IBinding binding= token.getBinding();
+                               if (binding instanceof ICPPMethod && !(binding instanceof IProblemBinding)) {
+                                       return ((ICPPMethod)binding).isStatic();
+                               }
+                       }
+                       return false;
+               }
+       }
+
+       /**
+        * Semantic highlighting for methods.
+        */
+       private static final class MethodHighlighting extends SemanticHighlighting {
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey()
+                */
+               @Override
+               public String getPreferenceKey() {
+                       return METHOD;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor()
+                */
+               @Override
+               public RGB getDefaultTextColor() {
+                       return RGB_BLACK;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold()
+                */
+               @Override
+               public boolean isBoldByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault()
+                */
+               @Override
+               public boolean isItalicByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault()
+                */
+               @Override
+               public boolean isEnabledByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName()
+                */
+               @Override
+               public String getDisplayName() {
+                       return CEditorMessages.SemanticHighlighting_method; 
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken)
+                */
+               @Override
+               public boolean consumes(SemanticToken token) {
+                       IASTNode node= token.getNode();
+                       if (node instanceof IASTImplicitName)
+                               return false;
+                       if (node instanceof IASTName) {
+                               IASTName name= (IASTName)node;
+                               if (name instanceof ICPPASTQualifiedName && name.isReference()) {
+                                       return false;
+                               }
+                               IBinding binding= token.getBinding();
+                               if (binding instanceof ICPPMethod) {
+                                       return true;
+                               }
+                       }
+                       return false;
+               }
+
+       }
+
+       /**
+        * Semantic highlighting for function declarations.
+        */
+       private static final class FunctionDeclarationHighlighting extends SemanticHighlighting {
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey()
+                */
+               @Override
+               public String getPreferenceKey() {
+                       return FUNCTION_DECLARATION;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor()
+                */
+               @Override
+               public RGB getDefaultTextColor() {
+                       return RGB_BLACK;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold()
+                */
+               @Override
+               public boolean isBoldByDefault() {
+                       return true;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault()
+                */
+               @Override
+               public boolean isItalicByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault()
+                */
+               @Override
+               public boolean isEnabledByDefault() {
+                       return true;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName()
+                */
+               @Override
+               public String getDisplayName() {
+                       return CEditorMessages.SemanticHighlighting_functionDeclaration; 
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken)
+                */
+               @Override
+               public boolean consumes(SemanticToken token) {
+                       IASTNode node= token.getNode();
+                       if (node instanceof IASTImplicitName)
+                               return false;
+
+                       if (node instanceof IASTName) {
+                               IASTName name= (IASTName)node;
+                               if (name.isDeclaration()) {
+                                       IBinding binding= token.getBinding();
+                                       if (binding instanceof IFunction 
+                                                       && !(binding instanceof ICPPMethod)) {
+                                               return true;
+                                       } else if (binding instanceof IProblemBinding) {
+                                               // try to derive from AST
+                                               if (name instanceof ICPPASTQualifiedName) {
+                                                       return false;
+                                               }
+                                               node= name.getParent();
+                                               while (node instanceof IASTName) {
+                                                       node= node.getParent();
+                                               }
+                                               if (node instanceof IASTFunctionDeclarator) {
+                                                       while (node != token.getRoot() && !(node.getParent() instanceof IASTDeclSpecifier)) {
+                                                               node= node.getParent();
+                                                       }
+                                                       if (node instanceof ICPPASTCompositeTypeSpecifier) {
+                                                               return false;
+                                                       }
+                                                       return true;
+                                               }
+                                       }
+                               }
+                       }
+                       return false;
+               }
+       }
+
+       /**
+        * Semantic highlighting for functions.
+        */
+       private static final class FunctionHighlighting extends SemanticHighlighting {
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey()
+                */
+               @Override
+               public String getPreferenceKey() {
+                       return FUNCTION;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor()
+                */
+               @Override
+               public RGB getDefaultTextColor() {
+                       return RGB_BLACK;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold()
+                */
+               @Override
+               public boolean isBoldByDefault() {
+                       return true;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault()
+                */
+               @Override
+               public boolean isItalicByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault()
+                */
+               @Override
+               public boolean isEnabledByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName()
+                */
+               @Override
+               public String getDisplayName() {
+                       return CEditorMessages.SemanticHighlighting_function; 
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken)
+                */
+               @Override
+               public boolean consumes(SemanticToken token) {
+                       IASTNode node= token.getNode();
+                       if (node instanceof IASTImplicitName)
+                               return false;
+                       if (node instanceof IASTName) {
+                               IASTName name= (IASTName)node;
+                               if (name instanceof ICPPASTQualifiedName && name.isReference()) {
+                                       return false;
+                               }
+                               IBinding binding= token.getBinding();
+                               if (binding instanceof IFunction && !(binding instanceof ICPPMethod)) {
+                                       return true;
+                               }
+                       }
+                       return false;
+               }
+       }
+       
+       /**
+        * Semantic highlighting for local variable declarations.
+        */
+       private static final class LocalVariableDeclarationHighlighting extends SemanticHighlighting {
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey()
+                */
+               @Override
+               public String getPreferenceKey() {
+                       return LOCAL_VARIABLE_DECLARATION;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor()
+                */
+               @Override
+               public RGB getDefaultTextColor() {
+                       return new RGB(128, 0, 0);
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold()
+                */
+               @Override
+               public boolean isBoldByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault()
+                */
+               @Override
+               public boolean isItalicByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault()
+                */
+               @Override
+               public boolean isEnabledByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName()
+                */
+               @Override
+               public String getDisplayName() {
+                       return CEditorMessages.SemanticHighlighting_localVariableDeclaration; 
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken)
+                */
+               @Override
+               public boolean consumes(SemanticToken token) {
+                       IASTNode node= token.getNode();
+                       if (node instanceof IASTName) {
+                               IASTName name= (IASTName)node;
+                               if (name.isDeclaration()) {
+                                       IBinding binding= token.getBinding();
+                                       if (binding instanceof IVariable
+                                                       && !(binding instanceof IField)
+                                                       && !(binding instanceof IParameter)
+                                                       && !(binding instanceof IProblemBinding)) {
+                                               try {
+                                                       IScope scope= binding.getScope();
+                                                       if (LocalVariableHighlighting.isLocalScope(scope)) {
+                                                               return true;
+                                                       }
+                                               } catch (DOMException exc) {
+                                                       CUIPlugin.log(exc);
+                                               } 
+                                       }
+                               }
+                       }
+                       return false;
+               }
+
+}
+
+       /**
+        * Semantic highlighting for local variables.
+        */
+       private static final class LocalVariableHighlighting extends SemanticHighlighting {
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey()
+                */
+               @Override
+               public String getPreferenceKey() {
+                       return LOCAL_VARIABLE;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor()
+                */
+               @Override
+               public RGB getDefaultTextColor() {
+                       return RGB_BLACK;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold()
+                */
+               @Override
+               public boolean isBoldByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault()
+                */
+               @Override
+               public boolean isItalicByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault()
+                */
+               @Override
+               public boolean isEnabledByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName()
+                */
+               @Override
+               public String getDisplayName() {
+                       return CEditorMessages.SemanticHighlighting_localVariable; 
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken)
+                */
+               @Override
+               public boolean consumes(SemanticToken token) {
+                       IASTNode node= token.getNode();
+                       if (node instanceof IASTName) {
+                               IASTName name= (IASTName)node;
+                               if (name.isReference()) {
+                                       IBinding binding= token.getBinding();
+                                       if (binding instanceof IVariable
+                                                       && !(binding instanceof IField)
+                                                       && !(binding instanceof IParameter)
+                                                       && !(binding instanceof IProblemBinding)) {
+                                               try {
+                                                       IScope scope= binding.getScope();
+                                                       if (isLocalScope(scope)) {
+                                                               return true;
+                                                       }
+                                               } catch (DOMException exc) {
+                                                       CUIPlugin.log(exc);
+                                               } 
+                                       }
+                               }
+                       }
+                       return false;
+               }
+
+           public static boolean isLocalScope(IScope scope) {
+               while (scope != null) {
+                   if (scope instanceof ICPPFunctionScope ||
+                           scope instanceof ICPPBlockScope ||
+                           scope instanceof ICFunctionScope) {
+                       return true;
+                   }
+                   try {
+                       scope= scope.getParent();
+                   } catch (DOMException e) {
+                       scope= null;
+                   }
+               }
+               return false;
+           }
+}
+
+       /**
+        * Semantic highlighting for global variables.
+        */
+       private static final class GlobalVariableHighlighting extends SemanticHighlighting {
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey()
+                */
+               @Override
+               public String getPreferenceKey() {
+                       return GLOBAL_VARIABLE;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor()
+                */
+               @Override
+               public RGB getDefaultTextColor() {
+                       return RGB_BLACK;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold()
+                */
+               @Override
+               public boolean isBoldByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault()
+                */
+               @Override
+               public boolean isItalicByDefault() {
+                       return true;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault()
+                */
+               @Override
+               public boolean isEnabledByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName()
+                */
+               @Override
+               public String getDisplayName() {
+                       return CEditorMessages.SemanticHighlighting_globalVariable; 
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken)
+                */
+               @Override
+               public boolean consumes(SemanticToken token) {
+                       IASTNode node= token.getNode();
+                       if (node instanceof IASTName) {
+                               IASTName name= (IASTName)node;
+                               if (name instanceof ICPPASTQualifiedName) {
+                                       return false;
+                               }
+                               IBinding binding= token.getBinding();
+                               if (binding instanceof IVariable
+                                               && !(binding instanceof IField)
+                                               && !(binding instanceof IParameter)
+                                               && !(binding instanceof ICPPTemplateNonTypeParameter)
+                                               && !(binding instanceof IProblemBinding)) {
+                                       try {
+                                               IScope scope= binding.getScope();
+                                               if (!LocalVariableHighlighting.isLocalScope(scope)) {
+                                                       return true;
+                                               }
+                                       } catch (DOMException exc) {
+                                               CUIPlugin.log(exc);
+                                       } 
+                               }
+                       }
+                       return false;
+               }
+               
+       }
+
+       /**
+        * Semantic highlighting for parameter variables.
+        */
+       private static final class ParameterVariableHighlighting extends SemanticHighlighting {
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey()
+                */
+               @Override
+               public String getPreferenceKey() {
+                       return PARAMETER_VARIABLE;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor()
+                */
+               @Override
+               public RGB getDefaultTextColor() {
+                       return RGB_BLACK;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold()
+                */
+               @Override
+               public boolean isBoldByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault()
+                */
+               @Override
+               public boolean isItalicByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault()
+                */
+               @Override
+               public boolean isEnabledByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName()
+                */
+               @Override
+               public String getDisplayName() {
+                       return CEditorMessages.SemanticHighlighting_parameterVariable; 
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken)
+                */
+               @Override
+               public boolean consumes(SemanticToken token) {
+                       IBinding binding= token.getBinding();
+                       if (binding instanceof IParameter) {
+                               return true;
+                       }
+                       return false;
+               }
+       }
+
+       /**
+        * Semantic highlighting for template parameters.
+        */
+       private static final class TemplateParameterHighlighting extends SemanticHighlighting {
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey()
+                */
+               @Override
+               public String getPreferenceKey() {
+                       return TEMPLATE_PARAMETER;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor()
+                */
+               @Override
+               public RGB getDefaultTextColor() {
+                       return new RGB(100, 70, 50);
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold()
+                */
+               @Override
+               public boolean isBoldByDefault() {
+                       return true;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault()
+                */
+               @Override
+               public boolean isItalicByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault()
+                */
+               @Override
+               public boolean isEnabledByDefault() {
+                       return true;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName()
+                */
+               @Override
+               public String getDisplayName() {
+                       return CEditorMessages.SemanticHighlighting_templateParameter; 
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken)
+                */
+               @Override
+               public boolean consumes(SemanticToken token) {
+                       IASTNode node= token.getNode();
+                       if (node instanceof IASTName) {
+                               IBinding binding= token.getBinding();
+                               if (binding instanceof ICPPTemplateParameter) {
+                                       return true;
+                               }
+                       }
+                       return false;
+               }
+       }
+       
+       /**
+        * Semantic highlighting for classes.
+        */
+       private static final class ClassHighlighting extends SemanticHighlighting {
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey()
+                */
+               @Override
+               public String getPreferenceKey() {
+                       return CLASS;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor()
+                */
+               @Override
+               public RGB getDefaultTextColor() {
+                       return new RGB(0, 80, 50);
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold()
+                */
+               @Override
+               public boolean isBoldByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault()
+                */
+               @Override
+               public boolean isItalicByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault()
+                */
+               @Override
+               public boolean isEnabledByDefault() {
+                       return true;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName()
+                */
+               @Override
+               public String getDisplayName() {
+                       return CEditorMessages.SemanticHighlighting_classes; 
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken)
+                */
+               @Override
+               public boolean consumes(SemanticToken token) {
+                       IASTNode node= token.getNode();
+                       if (node instanceof ICPPASTQualifiedName || node instanceof ICPPASTTemplateId) {
+                               return false;
+                       }
+                       if (node instanceof IASTName) {
+                               IBinding binding= token.getBinding();
+                               if (binding instanceof ICPPClassType && !(binding instanceof ICPPTemplateParameter)) {
+                                       return true;
+                               }
+                       }
+                       return false;
+               }
+       }
+
+       /**
+        * Semantic highlighting for enums.
+        */
+       private static final class EnumHighlighting extends SemanticHighlighting {
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey()
+                */
+               @Override
+               public String getPreferenceKey() {
+                       return ENUM;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor()
+                */
+               @Override
+               public RGB getDefaultTextColor() {
+                       return new RGB(100, 70, 50);
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold()
+                */
+               @Override
+               public boolean isBoldByDefault() {
+                       return false;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault()
+                */
+               @Override
+               public boolean isItalicByDefault() {
+                       return false;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault()
+                */
+               @Override
+               public boolean isEnabledByDefault() {
+                       return false;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName()
+                */
+               @Override
+               public String getDisplayName() {
+                       return CEditorMessages.SemanticHighlighting_enums; 
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken)
+                */
+               @Override
+               public boolean consumes(SemanticToken token) {
+                       IASTNode node= token.getNode();
+                       if (node instanceof IASTName) {
+                               IBinding binding= token.getBinding();
+                               if (binding instanceof IEnumeration) {
+                                       return true;
+                               }
+                       }
+                       return false;
+               }
+       }
+       
+       /**
+        * Semantic highlighting for macro references.
+        */
+       private static final class MacroReferenceHighlighting extends SemanticHighlighting {
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey()
+                */
+               @Override
+               public String getPreferenceKey() {
+                       return MACRO_REFERENCE;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor()
+                */
+               @Override
+               public RGB getDefaultTextColor() {
+                       return RGB_BLACK;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold()
+                */
+               @Override
+               public boolean isBoldByDefault() {
+                       return false;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault()
+                */
+               @Override
+               public boolean isItalicByDefault() {
+                       return false;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault()
+                */
+               @Override
+               public boolean isEnabledByDefault() {
+                       return false;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName()
+                */
+               @Override
+               public String getDisplayName() {
+                       return CEditorMessages.SemanticHighlighting_macroSubstitution; 
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken)
+                */
+               @Override
+               public boolean consumes(SemanticToken token) {
+                       IBinding binding= token.getBinding();
+                       if (binding instanceof IMacroBinding) {
+                               IASTName name= (IASTName)token.getNode();
+                               if (name.isReference()) {
+                                       return true;
+                               }
+                       }
+                       return false;
+               }
+       }
+       
+       /**
+        * Semantic highlighting for macro definitions.
+        */
+       private static final class MacroDefinitionHighlighting extends SemanticHighlighting {
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey()
+                */
+               @Override
+               public String getPreferenceKey() {
+                       return MACRO_DEFINITION;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor()
+                */
+               @Override
+               public RGB getDefaultTextColor() {
+                       return RGB_BLACK;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold()
+                */
+               @Override
+               public boolean isBoldByDefault() {
+                       return false;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault()
+                */
+               @Override
+               public boolean isItalicByDefault() {
+                       return false;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault()
+                */
+               @Override
+               public boolean isEnabledByDefault() {
+                       return false;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName()
+                */
+               @Override
+               public String getDisplayName() {
+                       return CEditorMessages.SemanticHighlighting_macroDefintion; 
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken)
+                */
+               @Override
+               public boolean consumes(SemanticToken token) {
+                       IBinding binding= token.getBinding();
+                       if (binding instanceof IMacroBinding) {
+                               IASTName name= (IASTName)token.getNode();
+                               if (!name.isReference()) {
+                                       return true;
+                               }
+                       }
+                       return false;
+               }
+       }
+       
+       /**
+        * Semantic highlighting for typedefs.
+        */
+       private static final class TypedefHighlighting extends SemanticHighlighting {
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey()
+                */
+               @Override
+               public String getPreferenceKey() {
+                       return TYPEDEF;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor()
+                */
+               @Override
+               public RGB getDefaultTextColor() {
+                       return new RGB(0, 80, 50);
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold()
+                */
+               @Override
+               public boolean isBoldByDefault() {
+                       return false;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault()
+                */
+               @Override
+               public boolean isItalicByDefault() {
+                       return false;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault()
+                */
+               @Override
+               public boolean isEnabledByDefault() {
+                       return true;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName()
+                */
+               @Override
+               public String getDisplayName() {
+                       return CEditorMessages.SemanticHighlighting_typeDef; 
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken)
+                */
+               @Override
+               public boolean consumes(SemanticToken token) {
+                       IASTNode node= token.getNode();
+                       if (node instanceof IASTName) {
+                               IASTName name= (IASTName)node;
+                               if (name instanceof ICPPASTQualifiedName) {
+                                       return false;
+                               }
+                               IBinding binding= token.getBinding();
+                               if (binding instanceof ITypedef) {
+                                       return true;
+                               }
+                       }
+                       return false;
+               }
+       }
+       
+       /**
+        * Semantic highlighting for namespaces.
+        */
+       private static final class NamespaceHighlighting extends SemanticHighlighting {
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey()
+                */
+               @Override
+               public String getPreferenceKey() {
+                       return NAMESPACE;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor()
+                */
+               @Override
+               public RGB getDefaultTextColor() {
+                       return RGB_BLACK;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold()
+                */
+               @Override
+               public boolean isBoldByDefault() {
+                       return false;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault()
+                */
+               @Override
+               public boolean isItalicByDefault() {
+                       return false;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault()
+                */
+               @Override
+               public boolean isEnabledByDefault() {
+                       return false;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName()
+                */
+               @Override
+               public String getDisplayName() {
+                       return CEditorMessages.SemanticHighlighting_namespace; 
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken)
+                */
+               @Override
+               public boolean consumes(SemanticToken token) {
+                       IBinding binding= token.getBinding();
+                       if (binding instanceof ICPPNamespace) {
+                               return true;
+                       }
+                       return false;
+               }
+       }
+       
+       /**
+        * Semantic highlighting for labels.
+        */
+       private static final class LabelHighlighting extends SemanticHighlighting {
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey()
+                */
+               @Override
+               public String getPreferenceKey() {
+                       return LABEL;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor()
+                */
+               @Override
+               public RGB getDefaultTextColor() {
+                       return RGB_BLACK;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold()
+                */
+               @Override
+               public boolean isBoldByDefault() {
+                       return false;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault()
+                */
+               @Override
+               public boolean isItalicByDefault() {
+                       return false;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault()
+                */
+               @Override
+               public boolean isEnabledByDefault() {
+                       return false;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName()
+                */
+               @Override
+               public String getDisplayName() {
+                       return CEditorMessages.SemanticHighlighting_label; 
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken)
+                */
+               @Override
+               public boolean consumes(SemanticToken token) {
+                       IBinding binding= token.getBinding();
+                       if (binding instanceof ILabel) {
+                               return true;
+                       }
+                       return false;
+               }
+       }
+       
+       /**
+        * Semantic highlighting for enumerators.
+        */
+       private static final class EnumeratorHighlighting extends SemanticHighlighting {
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey()
+                */
+               @Override
+               public String getPreferenceKey() {
+                       return ENUMERATOR;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor()
+                */
+               @Override
+               public RGB getDefaultTextColor() {
+                       return new RGB(0, 0, 192);
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold()
+                */
+               @Override
+               public boolean isBoldByDefault() {
+                       return false;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault()
+                */
+               @Override
+               public boolean isItalicByDefault() {
+                       return true;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault()
+                */
+               @Override
+               public boolean isEnabledByDefault() {
+                       return true;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName()
+                */
+               @Override
+               public String getDisplayName() {
+                       return CEditorMessages.SemanticHighlighting_enumerator; 
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken)
+                */
+               @Override
+               public boolean consumes(SemanticToken token) {
+                       IASTNode node= token.getNode();
+                       if (node instanceof IASTName) {
+                               IASTName name= (IASTName)node;
+                               if (name instanceof ICPPASTQualifiedName) {
+                                       return false;
+                               }
+                               IBinding binding= token.getBinding();
+                               if (binding instanceof IEnumerator) {
+                                       return true;
+                               }
+                       }
+                       return false;
+               }
+       }
+       
+       /**
+        * Semantic highlighting for problems.
+        */
+       private static final class ProblemHighlighting extends SemanticHighlighting {
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey()
+                */
+               @Override
+               public String getPreferenceKey() {
+                       return PROBLEM;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor()
+                */
+               @Override
+               public RGB getDefaultTextColor() {
+                       return new RGB(224, 0, 0);
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold()
+                */
+               @Override
+               public boolean isBoldByDefault() {
+                       return true;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isStrikethroughByDefault()
+                */
+               @Override
+               public boolean isStrikethroughByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault()
+                */
+               @Override
+               public boolean isItalicByDefault() {
+                       return false;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault()
+                */
+               @Override
+               public boolean isEnabledByDefault() {
+                       return false;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName()
+                */
+               @Override
+               public String getDisplayName() {
+                       return CEditorMessages.SemanticHighlighting_problem; 
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken)
+                */
+               @Override
+               public boolean consumes(SemanticToken token) {
+                       IASTNode node= token.getNode();
+                       if (node instanceof IASTProblem) {
+                               return true;
+                       }
+                       IBinding binding= token.getBinding();
+                       if (binding instanceof IProblemBinding) {
+                               return true;
+                       }
+                       return false;
+               }
+       }
+       
+       /**
+        * Semantic highlighting for external SDK references.
+        */
+       private static final class ExternalSDKHighlighting extends SemanticHighlighting {
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey()
+                */
+               @Override
+               public String getPreferenceKey() {
+                       return EXTERNAL_SDK;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor()
+                */
+               @Override
+               public RGB getDefaultTextColor() {
+                       return new RGB(100, 40, 128);
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold()
+                */
+               @Override
+               public boolean isBoldByDefault() {
+                       return true;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isStrikethroughByDefault()
+                */
+               @Override
+               public boolean isStrikethroughByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault()
+                */
+               @Override
+               public boolean isItalicByDefault() {
+                       return false;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault()
+                */
+               @Override
+               public boolean isEnabledByDefault() {
+                       return true;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName()
+                */
+               @Override
+               public String getDisplayName() {
+                       return CEditorMessages.SemanticHighlighting_externalSDK; 
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken)
+                */
+               @Override
+               public boolean consumes(SemanticToken token) {
+                       IASTNode node= token.getNode();
+                       if (node instanceof IASTName) {
+                               IASTName name= (IASTName)node;
+                               if (name instanceof ICPPASTQualifiedName) {
+                                       return false;
+                               }
+                               if (name instanceof IASTImplicitName) {
+                                       return false;
+                               }
+                               if (name.isReference()) {
+                                       IBinding binding= token.getBinding();
+                                       IIndex index= token.getRoot().getIndex();
+                                       return isExternalSDKReference(binding, index);
+                               }
+                       }
+                       return false;
+               }
+
+               private boolean isExternalSDKReference(IBinding binding, IIndex index) {
+                       if (binding instanceof IFunction) {
+                               try {
+                                       if (binding instanceof IIndexBinding) {
+                                               if (((IIndexBinding) binding).isFileLocal()) {
+                                                       return false;
+                                               }
+                                       }
+                                       else if (!(binding instanceof ICExternalBinding)) {
+                                               return false;
+                                       }
+                                       IIndexName[] decls= index.findNames(binding, IIndex.FIND_DECLARATIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
+                                       for (IIndexName decl : decls) {
+                                               IIndexFile indexFile= decl.getFile();
+                                               if (indexFile != null && indexFile.getLocation().getFullPath() != null) {
+                                                       return false;
+                                               }
+                                       }
+                                       if (decls.length != 0) {
+                                               return true;
+                                       }
+                               } catch (CoreException exc) {
+                                       CUIPlugin.log(exc.getStatus());
+                                       return false;
+                               }
+                       }
+                       return false;
+               }
+       }
+       
+       /**
+        * Semantic highlighting for functions.
+        */
+       private static final class OverloadedOperatorHighlighting extends SemanticHighlighting {
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey()
+                */
+               @Override
+               public String getPreferenceKey() {
+                       return OVERLOADED_OPERATOR;
+               }
+
+               
+               @Override
+               public boolean requiresImplicitNames() {
+                       return true;
+               }
+
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor()
+                */
+               @Override
+               public RGB getDefaultTextColor() {
+                       return new RGB(200, 100, 0); // orange
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold()
+                */
+               @Override
+               public boolean isBoldByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault()
+                */
+               @Override
+               public boolean isItalicByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault()
+                */
+               @Override
+               public boolean isEnabledByDefault() {
+                       return false;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName()
+                */
+               @Override
+               public String getDisplayName() {
+                       return CEditorMessages.SemanticHighlighting_overloadedOperators; 
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken)
+                */
+               @Override
+               public boolean consumes(SemanticToken token) {
+                       IASTNode node = token.getNode();
+                       // so far we only have implicit names for overloaded operators and destructors, so this works
+                       if (node instanceof IASTImplicitName) {
+                               IASTImplicitName name = (IASTImplicitName) node;
+                               if (name.isReference() && name.isOperator()) {
+                                       IBinding binding = name.resolveBinding();
+                                       if (binding instanceof ICPPMethod && !(binding instanceof IProblemBinding)
+                                                       && ((ICPPMethod) binding).isImplicit()) {
+                                               return false;
+                                       }
+                                       if (binding instanceof ICPPUnknownBinding)
+                                               return false;
+                                       char[] chars = name.toCharArray();
+                                       if (chars[0] == '~' || OverloadableOperator.isNew(chars)
+                                                       || OverloadableOperator.isDelete(chars)) {
+                                               return false;
+                                       }
+                                       return true;
+                               }
+                       }
+                       return false;
+               }
+       }
+       
+       /**
+        * A named preference that controls the given semantic highlighting's color.
+        *
+        * @param semanticHighlighting the semantic highlighting
+        * @return the color preference key
+        */
+       public static String getColorPreferenceKey(SemanticHighlighting semanticHighlighting) {
+               return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey() + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_COLOR_SUFFIX;
+       }
+
+       /**
+        * A named preference that controls if the given semantic highlighting has the text attribute bold.
+        *
+        * @param semanticHighlighting the semantic highlighting
+        * @return the bold preference key
+        */
+       public static String getBoldPreferenceKey(SemanticHighlighting semanticHighlighting) {
+               return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey() + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_BOLD_SUFFIX;
+       }
+
+       /**
+        * A named preference that controls if the given semantic highlighting has the text attribute italic.
+        *
+        * @param semanticHighlighting the semantic highlighting
+        * @return the italic preference key
+        */
+       public static String getItalicPreferenceKey(SemanticHighlighting semanticHighlighting) {
+               return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey() + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ITALIC_SUFFIX;
+       }
+
+       /**
+        * A named preference that controls if the given semantic highlighting has the text attribute strikethrough.
+        *
+        * @param semanticHighlighting the semantic highlighting
+        * @return the strikethrough preference key
+        */
+       public static String getStrikethroughPreferenceKey(SemanticHighlighting semanticHighlighting) {
+               return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey() + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_STRIKETHROUGH_SUFFIX;
+       }
+
+       /**
+        * A named preference that controls if the given semantic highlighting has the text attribute underline.
+        *
+        * @param semanticHighlighting the semantic highlighting
+        * @return the underline preference key
+        */
+       public static String getUnderlinePreferenceKey(SemanticHighlighting semanticHighlighting) {
+               return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey() + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_UNDERLINE_SUFFIX;
+       }
+
+       /**
+        * A named preference that controls if the given semantic highlighting is enabled.
+        *
+        * @param semanticHighlighting the semantic highlighting
+        * @return the enabled preference key
+        */
+       public static String getEnabledPreferenceKey(SemanticHighlighting semanticHighlighting) {
+               return PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + semanticHighlighting.getPreferenceKey() + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED_SUFFIX;
+       }
+
+       /**
+        * @return The semantic highlightings, the order defines the precedence of matches, the first match wins.
+        */
+       public static SemanticHighlighting[] getSemanticHighlightings() {
+               if (fgSemanticHighlightings == null)
+                       fgSemanticHighlightings= new SemanticHighlighting[] {
+                               new MacroReferenceHighlighting(),  // before all others!
+                               new ProblemHighlighting(),
+                               new ExternalSDKHighlighting(),
+                               new ClassHighlighting(),
+                               new StaticFieldHighlighting(),
+                               new FieldHighlighting(),  // after all other fields
+                               new MethodDeclarationHighlighting(),
+                               new StaticMethodInvocationHighlighting(),
+                               new ParameterVariableHighlighting(),  // before local variables
+                               new LocalVariableDeclarationHighlighting(),
+                               new LocalVariableHighlighting(),
+                               new GlobalVariableHighlighting(),
+                               new TemplateParameterHighlighting(), // before template arguments!
+                               new OverloadedOperatorHighlighting(), // before both method and function
+                               new MethodHighlighting(), // before types to get ctors
+                               new EnumHighlighting(),
+                               new MacroDefinitionHighlighting(),
+                               new FunctionDeclarationHighlighting(),
+                               new FunctionHighlighting(),
+                               new TypedefHighlighting(),
+                               new NamespaceHighlighting(),
+                               new LabelHighlighting(),
+                               new EnumeratorHighlighting(),
+                       };
+               return fgSemanticHighlightings;
+       }
+
+       /**
+        * Initialize default preferences in the given preference store.
+        * @param store The preference store
+        */
+       public static void initDefaults(IPreferenceStore store) {
+               store.setDefault(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED, true);
+
+               SemanticHighlighting[] semanticHighlightings= getSemanticHighlightings();
+               for (SemanticHighlighting semanticHighlighting : semanticHighlightings) {
+                       store.setDefault(SemanticHighlightings.getEnabledPreferenceKey(semanticHighlighting), DEBUG || semanticHighlighting.isEnabledByDefault());
+                       PreferenceConverter.setDefault(store, SemanticHighlightings.getColorPreferenceKey(semanticHighlighting), semanticHighlighting.getDefaultTextColor());
+                       store.setDefault(SemanticHighlightings.getBoldPreferenceKey(semanticHighlighting), semanticHighlighting.isBoldByDefault());
+                       store.setDefault(SemanticHighlightings.getItalicPreferenceKey(semanticHighlighting), semanticHighlighting.isItalicByDefault());
+                       store.setDefault(SemanticHighlightings.getStrikethroughPreferenceKey(semanticHighlighting), semanticHighlighting.isStrikethroughByDefault());
+                       store.setDefault(SemanticHighlightings.getUnderlinePreferenceKey(semanticHighlighting), DEBUG || semanticHighlighting.isUnderlineByDefault());
+               }
+       }
+
+       /**
+        * Tests whether <code>event</code> in <code>store</code> affects the
+        * enablement of semantic highlighting.
+        *
+        * @param store the preference store where <code>event</code> was observed
+        * @param event the property change under examination
+        * @return <code>true</code> if <code>event</code> changed semantic
+        *         highlighting enablement, <code>false</code> if it did not
+        */
+       public static boolean affectsEnablement(IPreferenceStore store, PropertyChangeEvent event) {
+               if (event.getProperty().equals(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED)) {
+                       return true;
+               }
+               String relevantKey= null;
+               SemanticHighlighting[] highlightings= getSemanticHighlightings();
+               for (SemanticHighlighting highlighting : highlightings) {
+                       if (event.getProperty().equals(getEnabledPreferenceKey(highlighting))) {
+                               relevantKey= event.getProperty();
+                               break;
+                       }
+               }
+               if (relevantKey == null)
+                       return false;
+
+               for (SemanticHighlighting highlighting : highlightings) {
+                       String key= getEnabledPreferenceKey(highlighting);
+                       if (key.equals(relevantKey))
+                               continue;
+                       if (store.getBoolean(key))
+                               return false; // another is still enabled or was enabled before
+               }
+
+               // all others are disabled, so toggling relevantKey affects the enablement
+               return true;
+       }
+
+       /**
+        * Tests whether semantic highlighting is currently enabled.
+        *
+        * @param store the preference store to consult
+        * @return <code>true</code> if semantic highlighting is enabled,
+        *         <code>false</code> if it is not
+        */
+       public static boolean isEnabled(IPreferenceStore store) {
+               if (!store.getBoolean(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED)) {
+                       return false;
+               }
+               SemanticHighlighting[] highlightings= getSemanticHighlightings();
+               boolean enable= false;
+               for (SemanticHighlighting highlighting : highlightings) {
+                       String enabledKey= getEnabledPreferenceKey(highlighting);
+                       if (store.getBoolean(enabledKey)) {
+                               enable= true;
+                               break;
+                       }
+               }
+
+               return enable;
+       }
+
+       /**
+        * Do not instantiate
+        */
+       private SemanticHighlightings() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticToken.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticToken.java
new file mode 100644 (file)
index 0000000..1bac7ae
--- /dev/null
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems) - Adapted for CDT
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.editor;
+
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+
+/**
+ * Semantic token.
+ * Cloned from JDT.
+ * 
+ * @since 4.0
+ */
+public final class SemanticToken {
+
+       /** AST node */
+       private IASTNode fNode;
+
+       /** Binding */
+       private IBinding fBinding;
+       /** Is the binding resolved? */
+       private boolean fIsBindingResolved= false;
+
+       /** AST root */
+       private IASTTranslationUnit fRoot;
+       private boolean fIsRootResolved= false;
+
+       /**
+        * @return Returns the binding, can be <code>null</code>.
+        */
+       public IBinding getBinding() {
+               if (!fIsBindingResolved) {
+                       fIsBindingResolved= true;
+                       if (fNode instanceof IASTName)
+                               fBinding= ((IASTName)fNode).resolveBinding();
+               }
+               
+               return fBinding;
+       }
+
+       /**
+        * @return the AST node
+        */
+       public IASTNode getNode() {
+               return fNode;
+       }
+       
+       /**
+        * @return the AST root
+        */
+       public IASTTranslationUnit getRoot() {
+               if (!fIsRootResolved) {
+                       fIsRootResolved= true;
+                       if (fNode != null) {
+                               fRoot= fNode.getTranslationUnit();
+                       }
+               }
+               return fRoot;
+       }
+
+       /**
+        * Update this token with the given AST node.
+        * <p>
+        * NOTE: Allowed to be used by {@link SemanticHighlightingReconciler} only.
+        * </p>
+        *
+        * @param node the AST node
+        */
+       void update(IASTNode node) {
+               clear();
+               fNode= node;
+       }
+
+       /**
+        * Clears this token.
+        * <p>
+        * NOTE: Allowed to be used by {@link SemanticHighlightingReconciler} only.
+        * </p>
+        */
+       void clear() {
+               fNode= null;
+               fBinding= null;
+               fIsBindingResolved= false;
+               fRoot= null;
+               fIsRootResolved= false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SortLinesAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SortLinesAction.java
new file mode 100644 (file)
index 0000000..2a1ffd0
--- /dev/null
@@ -0,0 +1,333 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Google, Inc and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *        Sergey Prigogin (Google) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import java.util.Arrays;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TextSelection;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.text.edits.ReplaceEdit;
+import org.eclipse.text.undo.DocumentUndoManagerRegistry;
+import org.eclipse.text.undo.IDocumentUndoManager;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.TextEditorAction;
+
+import com.ibm.icu.text.Collator;
+
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
+import org.eclipse.cdt.internal.corext.util.Strings;
+
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+
+/**
+ * Sorts selected lines in alphabetical order. If both, comment and non-comment lines
+ * are selected, the non-comment lines are sorted, and the comments are moved together
+ * with the non-comment lines they precede.
+ *
+ * @since 5.2
+ */
+public final class SortLinesAction extends TextEditorAction {
+
+       public SortLinesAction(ITextEditor editor) {
+               super(CEditorMessages.getBundleForConstructedKeys(), "SortLines.", editor); //$NON-NLS-1$
+       }
+
+       /**
+        * Sorts selected lines.
+        */
+       @Override
+       public void run() {
+               ITextEditor editor= getTextEditor();
+               if (editor == null)
+                       return;
+
+               ISelection selection = editor.getSelectionProvider().getSelection();
+               if (!(selection instanceof ITextSelection))
+                       return;
+
+               ITextSelection textSelection= (ITextSelection) selection;
+               if (textSelection.getStartLine() < 0 || textSelection.getEndLine() < 0)
+                       return;
+
+               IEditorInput editorInput = editor.getEditorInput();
+               ICProject cProject = EditorUtility.getCProject(editorInput);
+               IDocument document= editor.getDocumentProvider().getDocument(editorInput);
+               try {
+                       IRegion block= getTextBlockFromSelection(textSelection, document);
+                       SortElement[] elements = createSortElements(block, document,
+                                       CodeFormatterUtil.getTabWidth(cProject));
+                       if (elements.length <= 1)
+                               return;
+
+                       Arrays.sort(elements);
+                       StringBuilder buf = new StringBuilder();
+                       for (SortElement element : elements) {
+                               buf.append(document.get(element.getOffset(), element.getLength()));
+                               if (!isLastLineTerminated(element, document)) {
+                                       buf.append(TextUtilities.getDefaultLineDelimiter(document));
+                               }
+                       }
+                       String replacement = buf.toString();
+                       if (replacement.equals(document.get(block.getOffset(), block.getLength())))
+                               return;
+                       if (!validateEditorInputState())
+                               return;
+
+                       ReplaceEdit edit = new ReplaceEdit(block.getOffset(), block.getLength(), replacement);
+                       IDocumentUndoManager manager= DocumentUndoManagerRegistry.getDocumentUndoManager(document);
+                       manager.beginCompoundChange();
+                       edit.apply(document);
+                       editor.getSelectionProvider().setSelection(new TextSelection(block.getOffset(), buf.length()));
+                       manager.endCompoundChange();
+               } catch (BadLocationException e) {
+                       CUIPlugin.log(e);
+               }
+       }
+
+       /**
+        * Creates a region describing the text block (something that consists of full lines)
+        * completely containing the current selection.
+        *
+        * @param selection The selection to use
+        * @param document The document
+        * @return the region describing the text block comprising the given selection
+        */
+       private IRegion getTextBlockFromSelection(ITextSelection selection, IDocument document) {
+               try {
+                       IRegion firstLine= document.getLineInformationOfOffset(selection.getOffset());
+                       int selectionEnd = selection.getOffset() + selection.getLength();
+                       IRegion lastLine= document.getLineInformationOfOffset(selectionEnd);
+                       int length = lastLine.getOffset() - firstLine.getOffset();
+                       if (selectionEnd > lastLine.getOffset()) {
+                                // Last line is included with the line delimiter.
+                               length += document.getLineLength(document.getLineOfOffset(selectionEnd));
+                       }
+                       return new Region(firstLine.getOffset(), length);
+               } catch (BadLocationException e) {
+                       CUIPlugin.log(e);  // Should not happen
+               }
+               return null;
+       }
+
+       private SortElement[] createSortElements(IRegion block, IDocument document, int tabWidth)
+                       throws BadLocationException {
+               ITypedRegion[] regions= TextUtilities.computePartitioning(document, ICPartitions.C_PARTITIONING,
+                               block.getOffset(), block.getLength(), false);
+
+               int numLines = document.getNumberOfLines(block.getOffset(), block.getLength());
+               if (endOf(block) <= document.getLineInformationOfOffset(endOf(block)).getOffset()) {
+                       numLines--;  // Last line is excluded
+               }
+               LineInfo[] lineDescriptors = new LineInfo[numLines];
+               int numNonCommentLines = 0;
+               int i = 0;
+               int k = 0;
+               int line = document.getLineOfOffset(block.getOffset());
+               int endLine = line + numLines;
+               for (; line < endLine; line++) {
+                       LineInfo lineInfo = new LineInfo(document, line);
+                       lineDescriptors[k++] = lineInfo;
+                       while (i < regions.length && endOf(regions[i]) <= lineInfo.getTrimmedOffset())
+                               i++;
+                       for (; i < regions.length && regions[i].getOffset() < lineInfo.getTrimmedEndOffset(); i++) {
+                               ITypedRegion region = regions[i];
+                               if (region.getType() != ICPartitions.C_MULTI_LINE_COMMENT &&
+                                               region.getType() != ICPartitions.C_MULTI_LINE_DOC_COMMENT &&
+                                               region.getType() != ICPartitions.C_SINGLE_LINE_COMMENT &&
+                                               region.getType() != ICPartitions.C_SINGLE_LINE_DOC_COMMENT) {
+                                       lineInfo.nonComment = true;
+                                       break;
+                               }
+                       }
+                       if (lineInfo.nonComment) {
+                               numNonCommentLines++;
+                       }
+               }
+               SortElement[] elements;
+               if (numNonCommentLines > 1) {
+                       elements = new SortElement[numNonCommentLines];
+                       k = 0;
+                       int offset = block.getOffset();
+                       for (int j = 0; j < lineDescriptors.length; j++) {
+                               LineInfo lineInfo = lineDescriptors[j];
+                               if (lineInfo.nonComment) {
+                                       int endOffset = k < numNonCommentLines - 1 ?
+                                                       lineInfo.getEndOffset() : block.getOffset() + block.getLength();
+                                       elements[k++] = new SortElement(new Region(offset, endOffset - offset), lineInfo,
+                                                       document, tabWidth);
+                                       offset = lineInfo.getEndOffset();
+                               }
+                       }
+               } else {
+                       elements = new SortElement[numLines];
+                       for (int j = 0; j < lineDescriptors.length; j++) {
+                               LineInfo lineInfo = lineDescriptors[j];
+                               elements[j] = new SortElement(lineInfo, lineInfo, document, tabWidth);
+                       }
+               }
+               return elements;
+       }
+
+       /**
+        * Returns end offset of a region.
+        */
+       private int endOf(IRegion region) {
+               return region.getOffset() + region.getLength();
+       }
+
+       /**
+        * Returns <code>true</code> if the given region is terminated by a line delimiter.
+        */
+       private static boolean isLastLineTerminated(IRegion region, IDocument document) throws BadLocationException {
+               int offset = region.getOffset() + region.getLength();
+               IRegion nextLine = document.getLineInformationOfOffset(offset);
+               return nextLine.getOffset() == offset;
+       }
+
+       @Override
+       public void update() {
+               if (!canModifyEditor()) {
+                       setEnabled(false);
+                       return;
+               }
+
+               // Enable if two or more lines are selected.
+               boolean enabled = false;
+               ITextEditor editor = getTextEditor();
+               if (editor != null) {
+                       ISelection selection = editor.getSelectionProvider().getSelection();
+                       if (selection instanceof ITextSelection) {
+                               ITextSelection textSelection= (ITextSelection) selection;
+                               int startLine = textSelection.getStartLine();
+                               int endLine = textSelection.getEndLine();
+                               if (startLine >= 0 && endLine > startLine) {
+                                       if (endLine == startLine + 1) {
+                                               IDocument document= editor.getDocumentProvider().getDocument(editor.getEditorInput());
+                                               try {
+                                                       if (textSelection.getOffset() + textSelection.getLength() > document.getLineOffset(endLine)) {
+                                                               enabled = true;
+                                                       }
+                                               } catch (BadLocationException e) {
+                                                       CUIPlugin.log(e);
+                                               }
+                                       } else {
+                                               enabled = true;
+                                       }
+                               }
+                       }
+               }
+               setEnabled(enabled);
+       }
+
+       /*
+        * @see TextEditorAction#setEditor(ITextEditor)
+        */
+       @Override
+       public void setEditor(ITextEditor editor) {
+               super.setEditor(editor);
+       }
+
+       private static class SortElement implements Comparable<SortElement>, IRegion {
+               private static final Collator collator = Collator.getInstance();
+               private final IRegion region;
+               private final String collationKey;
+
+               public SortElement(IRegion region, IRegion collationLine, IDocument document, int tabWidth)
+                               throws BadLocationException {
+                       super();
+                       this.region = region;
+                       this.collationKey = Strings.convertTabsToSpaces(Strings.trimTrailingTabsAndSpaces(
+                                       document.get(collationLine.getOffset(), collationLine.getLength())), tabWidth);
+               }
+
+               public int compareTo(SortElement other) {
+                       return collator.compare(collationKey, other.collationKey);
+               }
+
+               public int getOffset() {
+                       return region.getOffset();
+               }
+
+               public int getLength() {
+                       return region.getLength();
+               }
+       }
+
+       private static class LineInfo implements IRegion {
+               final int offset;
+               final int length;
+               final int trimmedOffset;
+               final int trimmedEndOffset;
+               boolean nonComment;
+
+               LineInfo(IDocument document, int line) throws BadLocationException {
+                       offset = document.getLineOffset(line);
+                       length = document.getLineLength(line);
+                       int begin = offset;
+                       int end = offset + length;
+                       while (--end >= begin && Character.isWhitespace(document.getChar(end))) {
+                       }
+                       end++;
+                       while (begin < end && Character.isWhitespace(document.getChar(begin))) {
+                               begin++;
+                       }
+                       trimmedOffset = begin;
+                       trimmedEndOffset = end;
+               }
+
+               /**
+                * Offset of the line in the document.
+                */
+               public int getOffset() {
+                       return offset;
+               }
+
+               /**
+                * Length of the line including line delimiter.
+                */
+               public int getLength() {
+                       return length;
+               }
+
+               /**
+                * End offset of the line including line delimiter.
+                */
+               public int getEndOffset() {
+                       return offset + length;
+               }
+
+               /**
+                * Document offset of the first non-whitespace character of the line.
+                */
+               public int getTrimmedOffset() {
+                       return trimmedOffset;
+               }
+
+               /**
+                * Document offset after the last non-whitespace character of the line.
+                */
+               public int getTrimmedEndOffset() {
+                       return trimmedEndOffset;
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SourceHeaderPartnerFinder.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SourceHeaderPartnerFinder.java
new file mode 100644 (file)
index 0000000..c544dae
--- /dev/null
@@ -0,0 +1,355 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *     Marc-Andre Laperle - Extracted Util class from ToggleSourceHeaderAction
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceProxy;
+import org.eclipse.core.resources.IResourceProxyVisitor;
+import org.eclipse.core.resources.IWorkspaceRoot;
+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.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.core.runtime.content.IContentTypeManager;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IProblemBinding;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
+
+import org.eclipse.cdt.internal.ui.refactoring.RefactoringASTCache;
+
+/**
+ * A collection of static methods for finding the source file corresponding to a header
+ * and vice versa.
+ */
+public final class SourceHeaderPartnerFinder {
+       
+       private static class Counter {
+               public int fCount;
+       }
+       
+       private SourceHeaderPartnerFinder() {
+       }
+       
+       /**
+        * Compute the partner file for a translation unit.
+        * The partner file is the corresponding source or header file
+        * based on heuristics.
+        *
+        * @since 4.0
+        */
+       private static class PartnerFileComputer implements ASTRunnable {
+               PartnerFileVisitor fVisitor = null;
+               
+               public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
+                       if (ast != null && ast.getIndex() != null) {
+                               fVisitor = new PartnerFileVisitor();
+                               ast.accept(fVisitor);
+                       }
+                       return Status.OK_STATUS;
+               }
+
+               public IPath getPartnerFileLocation() {
+                       if(fVisitor != null) {
+                               return fVisitor.getPartnerFileLocation();
+                       }
+                       
+                       return null;
+               }
+       }
+       
+       private static class PartnerFileVisitor extends ASTVisitor {
+               /** 
+                * When this many times the same partner file is hit, 
+                * we are confident enough to take it.
+                */
+               private static final int CONFIDENCE_LIMIT = 15;
+               /** 
+                * When this many times no match was found in the index, 
+                * we suspect that we won't get a good partner.
+                */
+               private static final int SUSPECT_LIMIT = 15;
+
+               private IIndex fIndex;
+               private IPath fFilePath;
+               private Map<IPath, Counter> fMap;
+               /** The confidence level == number of hits */
+               private int fConfidence;
+               /** Suspect level == number of no index matches */
+               private int fSuspect;
+               /** The current favorite partner file */
+               private IPath fFavoriteLocation;
+               
+               {
+                       shouldVisitDeclarators= true;
+                       shouldVisitTranslationUnit = true;
+               }
+               public PartnerFileVisitor() {
+                       fMap= new HashMap<IPath, Counter>();
+               }
+
+               @Override
+               public int visit(IASTTranslationUnit tu) {
+                       fIndex= tu.getIndex();
+                       if(fIndex == null) {
+                               return PROCESS_ABORT;   
+                       }
+                       
+                       fFilePath= Path.fromOSString(tu.getFilePath());
+                       return super.visit(tu);
+               }
+
+               public IPath getPartnerFileLocation() {
+                       return fFavoriteLocation;
+               }
+
+               /*
+                * @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTDeclarator)
+                */
+               @Override
+               public int visit(IASTDeclarator declarator) {
+                       if (declarator instanceof IASTFunctionDeclarator) {
+                               IASTName name= declarator.getName();
+                               if (name != null && declarator.getNestedDeclarator() == null) {
+                                       IBinding binding= name.resolveBinding();
+                                       if (binding != null && !(binding instanceof IProblemBinding)) {
+                                               boolean isDefinition= name.isDefinition();
+                                               final IIndexName[] partnerNames;
+                                               try {
+                                                       if (isDefinition) {
+                                                               partnerNames= fIndex.findNames(binding,
+                                                                               IIndex.FIND_DECLARATIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
+                                                       } else {
+                                                               partnerNames= fIndex.findNames(binding,
+                                                                               IIndex.FIND_DEFINITIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
+                                                       }
+                                                       if (partnerNames.length == 0) {
+                                                               ++fSuspect;
+                                                               if (fSuspect == SUSPECT_LIMIT) {
+                                                                       fFavoriteLocation= null;
+                                                                       return PROCESS_ABORT;
+                                                               }
+                                                       }
+                                                       for (int i= 0; i < partnerNames.length; i++) {
+                                                               IIndexName partnerName= partnerNames[i];
+                                                               IASTFileLocation partnerLocation= partnerName.getFileLocation();
+                                                               if (partnerLocation != null) {
+                                                                       IPath partnerFileLocation= Path.fromOSString(partnerLocation.getFileName());
+                                                                       if (!fFilePath.equals(partnerFileLocation)) {
+                                                                               addPotentialPartnerFileLocation(partnerFileLocation);
+                                                                               if (fConfidence == CONFIDENCE_LIMIT) {
+                                                                                       return PROCESS_ABORT;
+                                                                               }
+                                                                       }
+                                                               }
+                                                       }
+                                               } catch (CoreException exc) {
+                                                       CUIPlugin.log(exc.getStatus());
+                                               }
+                                       }
+                               }
+                       }
+                       return PROCESS_SKIP;
+               }
+
+               private void addPotentialPartnerFileLocation(IPath partnerFileLocation) {
+                       Counter counter= fMap.get(partnerFileLocation);
+                       if (counter == null) {
+                               counter= new Counter();
+                               fMap.put(partnerFileLocation, counter);
+                       }
+                       ++counter.fCount;
+                       if (counter.fCount > fConfidence) {
+                               fConfidence= counter.fCount;
+                               fFavoriteLocation= partnerFileLocation;
+                       }
+               }
+       }
+       
+       /**
+        * Finds a file in the given resource container for the given basename.
+        * 
+        * @param container
+        * @param basename
+        * @return a matching {@link IFile} or <code>null</code>, if no matching file was found
+        */
+       private static IFile findInContainer(IContainer container, final String basename) {
+               final IFile[] result= { null };
+               IResourceProxyVisitor visitor= new IResourceProxyVisitor() {
+                       public boolean visit(IResourceProxy proxy) throws CoreException {
+                               if (result[0] != null) {
+                                       return false;
+                               }
+                               if (!proxy.isAccessible()) {
+                                       return false;
+                               }
+                               if (proxy.getType() == IResource.FILE && proxy.getName().equals(basename)) {
+                                       result[0]= (IFile)proxy.requestResource();
+                                       return false;
+                               }
+                               return true;
+                       }};
+               try {
+                       container.accept(visitor, 0);
+               } catch (CoreException exc) {
+                       // ignore
+               }
+               return result[0];
+       }
+       
+       private static IContentType[] getPartnerContentTypes(String contentTypeId) {
+               IContentTypeManager mgr= Platform.getContentTypeManager();
+               if (contentTypeId.equals(CCorePlugin.CONTENT_TYPE_CHEADER)) {
+                       return new IContentType[] {
+                                       mgr.getContentType(CCorePlugin.CONTENT_TYPE_CSOURCE),
+                                       mgr.getContentType(CCorePlugin.CONTENT_TYPE_CXXSOURCE)
+                       };
+               }
+               if (contentTypeId.equals(CCorePlugin.CONTENT_TYPE_CSOURCE)) {
+                       return new IContentType[] {
+                                       mgr.getContentType(CCorePlugin.CONTENT_TYPE_CHEADER),
+                                       mgr.getContentType(CCorePlugin.CONTENT_TYPE_CXXHEADER)
+                       };
+               }
+               if (contentTypeId.equals(CCorePlugin.CONTENT_TYPE_CXXHEADER)) {
+                       return new IContentType[] {
+                                       mgr.getContentType(CCorePlugin.CONTENT_TYPE_CXXSOURCE),
+                                       mgr.getContentType(CCorePlugin.CONTENT_TYPE_CSOURCE)
+                       };
+               }
+               if (contentTypeId.equals(CCorePlugin.CONTENT_TYPE_CXXSOURCE)) {
+                       return new IContentType[] {
+                                       mgr.getContentType(CCorePlugin.CONTENT_TYPE_CXXHEADER),
+                                       mgr.getContentType(CCorePlugin.CONTENT_TYPE_CHEADER)
+                       };
+               }
+               return new IContentType[0];
+       }
+       
+       /**
+        * Finds a partner translation unit based on filename/extension matching.
+        * 
+        * @param a partner translation unit or <code>null</code>
+        */
+       private static ITranslationUnit getPartnerFileFromFilename(ITranslationUnit tu) {
+               IPath sourceFileLocation= tu.getLocation();
+               if (sourceFileLocation == null) {
+                       return null;
+               }
+               IPath partnerBasePath= sourceFileLocation.removeFileExtension();
+               IContentType[] contentTypes= getPartnerContentTypes(tu.getContentTypeId());
+               HashSet<String> extensionsTried= new HashSet<String>();
+               for (int j = 0; j < contentTypes.length; j++) {
+                       IContentType contentType= contentTypes[j];
+                       String[] partnerExtensions;
+                       partnerExtensions= contentType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
+                       for (int i= 0; i < partnerExtensions.length; i++) {
+                               String ext= partnerExtensions[i];
+                               if (extensionsTried.add(ext)) {
+                                       String partnerFileBasename= partnerBasePath.addFileExtension(ext).lastSegment();
+                                       
+                                       IFile partnerFile= null;
+                                       IResource resource = tu.getResource();
+                                       IContainer container = resource != null ? resource.getParent() : null;
+                                       while (container != null && partnerFile == null && !(container instanceof IWorkspaceRoot)) {
+                                               partnerFile= findInContainer(container, partnerFileBasename);
+                                               container = container.getParent();
+                                       }
+
+                                       if (partnerFile != null) {
+                                               ITranslationUnit partnerUnit= (ITranslationUnit) CoreModel.getDefault().create(partnerFile);
+                                               if (partnerUnit != null) {
+                                                       return partnerUnit;
+                                               }
+                                       }
+                                       // External translation unit - try in same directory
+                                       if (resource == null) {
+                                               IPath partnerFileLoation= partnerBasePath.removeLastSegments(1).append(partnerFileBasename);
+                                               ITranslationUnit partnerUnit= CoreModel.getDefault().createTranslationUnitFrom(
+                                                               tu.getCProject(), partnerFileLoation);
+                                               if (partnerUnit != null) {
+                                                       return partnerUnit;
+                                               }
+                                       }
+                               }
+                       }
+               }
+               return null;
+       }
+
+       public static ITranslationUnit getPartnerTranslationUnit(ITranslationUnit tu) {
+               ITranslationUnit partnerUnit= getPartnerFileFromFilename(tu);
+
+               if (partnerUnit == null) {
+                       // Search partner file based on definition/declaration association
+                       IProgressMonitor monitor= new NullProgressMonitor();
+                       PartnerFileComputer computer= new PartnerFileComputer();
+                       ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_ACTIVE_ONLY, monitor, computer);
+                       partnerUnit = createTranslationUnit(computer.getPartnerFileLocation(), tu.getCProject());
+               }
+               return partnerUnit;
+       }
+       
+       public static ITranslationUnit getPartnerTranslationUnit(ITranslationUnit tu,
+                       RefactoringASTCache astCache) throws CoreException {
+               ITranslationUnit partnerUnit= getPartnerFileFromFilename(tu);
+
+               if (partnerUnit == null) {
+                       // Search partner file based on definition/declaration association
+                       IProgressMonitor monitor= new NullProgressMonitor();
+                       IASTTranslationUnit ast = astCache.getAST(tu, monitor);
+                       PartnerFileVisitor visitor = new PartnerFileVisitor();
+                       ast.accept(visitor);
+                       partnerUnit = createTranslationUnit(visitor.getPartnerFileLocation(), tu.getCProject());
+               }
+               return partnerUnit;
+       }
+       
+       private static ITranslationUnit createTranslationUnit(IPath partnerFileLoation, ICProject cProject) {
+               ITranslationUnit partnerUnit = null;
+               if (partnerFileLoation != null) {
+                       partnerUnit= (ITranslationUnit) CoreModel.getDefault().create(partnerFileLoation);
+                       if (partnerUnit == null) {
+                               partnerUnit= CoreModel.getDefault().createTranslationUnitFrom(cProject.getCProject(),
+                                               partnerFileLoation);
+                       }
+               }
+               return partnerUnit;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SpecificContentAssistAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SpecificContentAssistAction.java
new file mode 100644 (file)
index 0000000..01f2908
--- /dev/null
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextOperationTarget;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.IUpdate;
+
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+import org.eclipse.cdt.internal.ui.text.contentassist.CompletionProposalCategory;
+import org.eclipse.cdt.internal.ui.text.contentassist.CompletionProposalComputerRegistry;
+
+/**
+ * Action to run content assist on a specific proposal category.
+ * 
+ * @since 4.0
+ */
+final class SpecificContentAssistAction extends Action implements IUpdate {
+       /**
+        * The category represented by this action.
+        */
+       private final CompletionProposalCategory fCategory;
+       /**
+        * The content assist executor.
+        */
+       private final SpecificContentAssistExecutor fExecutor= new SpecificContentAssistExecutor(CompletionProposalComputerRegistry.getDefault());
+       /**
+        * The editor.
+        */
+       private CEditor fEditor;
+       
+       /**
+        * Creates a new action for a certain proposal category.
+        * 
+        * @param category
+        */
+       public SpecificContentAssistAction(CompletionProposalCategory category) {
+               fCategory= category;
+               setText(category.getName());
+               setImageDescriptor(category.getImageDescriptor());
+               setActionDefinitionId("org.eclipse.cdt.ui.specific_content_assist.command"); //$NON-NLS-1$
+       }
+
+       /*
+        * @see org.eclipse.jface.action.Action#run()
+        */
+       @Override
+       public void run() {
+               ITextEditor editor= getActiveEditor();
+               if (editor == null)
+                       return;
+               
+               fExecutor.invokeContentAssist(editor, fCategory.getId());
+               
+               return;
+       }
+
+       private ITextEditor getActiveEditor() {
+               return fEditor;
+       }
+
+       /**
+        * Sets the active editor part.
+        * 
+        * @param part the editor, possibly <code>null</code>
+        */
+       public void setActiveEditor(IEditorPart part) {
+               CEditor editor;
+               if (part instanceof CEditor)
+                       editor= (CEditor) part;
+               else
+                       editor= null;
+               fEditor= editor;
+               setEnabled(computeEnablement(fEditor));
+       }
+       
+       private boolean computeEnablement(ITextEditor editor) {
+               if (editor == null)
+                       return false;
+               ITextOperationTarget target= (ITextOperationTarget) editor.getAdapter(ITextOperationTarget.class);
+               boolean hasContentAssist= target != null && target.canDoOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
+               if (!hasContentAssist)
+                       return false;
+               
+               ISelection selection= editor.getSelectionProvider().getSelection();
+               return isValidSelection(selection);
+       }
+
+    /**
+        * Computes the partition type at the selection start and checks whether the proposal category
+        * has any computers for this partition.
+        * 
+        * @param selection the selection
+        * @return <code>true</code> if there are any computers for the selection
+        */
+    private boolean isValidSelection(ISelection selection) {
+       if (!(selection instanceof ITextSelection))
+               return false;
+       int offset= ((ITextSelection) selection).getOffset();
+       
+       IDocument document= getDocument();
+       if (document == null)
+               return false;
+       
+       String contentType;
+       try {
+               contentType= TextUtilities.getContentType(document, ICPartitions.C_PARTITIONING, offset, true);
+        } catch (BadLocationException x) {
+               return false;
+        }
+        
+        return fCategory.hasComputers(contentType);
+    }
+    
+       private IDocument getDocument() {
+               Assert.isTrue(fEditor != null);
+           IDocumentProvider provider= fEditor.getDocumentProvider();
+           if (provider == null)
+               return null;
+           
+               IDocument document= provider.getDocument(fEditor.getEditorInput());
+           return document;
+    }
+
+       /*
+     * @see org.eclipse.ui.texteditor.IUpdate#update()
+     */
+    public void update() {
+       setEnabled(computeEnablement(fEditor));
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SpecificContentAssistExecutor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SpecificContentAssistExecutor.java
new file mode 100644 (file)
index 0000000..0bbd56c
--- /dev/null
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.text.ITextOperationTarget;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.internal.ui.text.contentassist.CompletionProposalCategory;
+import org.eclipse.cdt.internal.ui.text.contentassist.CompletionProposalComputerRegistry;
+
+
+/**
+ * A content assist executor can invoke content assist for a specific proposal category on an editor.
+ *  
+ * @since 4.0
+ */
+public final class SpecificContentAssistExecutor {
+
+       private final CompletionProposalComputerRegistry fRegistry;
+
+       /**
+        * Creates a new executor.
+        * 
+        * @param registry the computer registry to use for the enablement of proposal categories
+        */
+       public SpecificContentAssistExecutor(CompletionProposalComputerRegistry registry) {
+               Assert.isNotNull(registry);
+               fRegistry= registry;
+       }
+
+       /**
+        * Invokes content assist on <code>editor</code>, showing only proposals computed by the
+        * <code>CompletionProposalCategory</code> with the given <code>categoryId</code>.
+        * 
+        * @param editor the editor to invoke code assist on
+        * @param categoryId the id of the proposal category to show proposals for
+        */
+       public void invokeContentAssist(final ITextEditor editor, String categoryId) {
+               Collection<CompletionProposalCategory> categories= fRegistry.getProposalCategories();
+               boolean[] inclusionState= new boolean[categories.size()];
+               boolean[] separateState= new boolean[categories.size()];
+               int i= 0;
+               for (Iterator<CompletionProposalCategory> it= categories.iterator(); it.hasNext(); i++) {
+                       CompletionProposalCategory cat= it.next();
+                       inclusionState[i]= cat.isIncluded();
+                       cat.setIncluded(cat.getId().equals(categoryId));
+                       separateState[i]= cat.isSeparateCommand();
+                       cat.setSeparateCommand(false);
+               }
+               
+               try {
+                       ITextOperationTarget target= (ITextOperationTarget) editor.getAdapter(ITextOperationTarget.class);
+                       if (target != null && target.canDoOperation(ISourceViewer.CONTENTASSIST_PROPOSALS))
+                               target.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
+               } finally {
+                       i= 0;
+                       for (Iterator<CompletionProposalCategory> it= categories.iterator(); it.hasNext(); i++) {
+                               CompletionProposalCategory cat= it.next();
+                               cat.setIncluded(inclusionState[i]);
+                               cat.setSeparateCommand(separateState[i]);
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ToggleCommentAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ToggleCommentAction.java
new file mode 100644 (file)
index 0000000..545c86e
--- /dev/null
@@ -0,0 +1,368 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.editor;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.ResourceBundle;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextOperationTarget;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.text.TextViewer;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.ResourceAction;
+import org.eclipse.ui.texteditor.TextEditorAction;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * An action which toggles comment prefixes on the selected lines.
+ *
+ * @since 4.0.0
+ */
+public final class ToggleCommentAction extends TextEditorAction {
+       /** The text operation target */
+       private ITextOperationTarget fOperationTarget;
+       /** The document partitioning */
+       private String fDocumentPartitioning;
+       /** The comment prefixes */
+       private Map<String, String[]> fPrefixesMap;
+
+       /**
+        * Creates and initializes the action for the given text editor. The action
+        * configures its visual representation from the given resource bundle.
+        *
+        * @param bundle the resource bundle
+        * @param prefix a prefix to be prepended to the various resource keys
+        *   (described in <code>ResourceAction</code> constructor), or
+        *   <code>null</code> if none
+        * @param editor the text editor
+        * @see ResourceAction#ResourceAction(ResourceBundle, String, int)
+        */
+       public ToggleCommentAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
+               super(bundle, prefix, editor);
+       }
+
+       /**
+        * Implementation of the <code>IAction</code> prototype. Checks if the selected
+        * lines are all commented or not and uncomments/comments them respectively.
+        */
+       @Override
+       public void run() {
+               if (fOperationTarget == null || fDocumentPartitioning == null || fPrefixesMap == null)
+                       return;
+
+               ITextEditor editor= getTextEditor();
+               if (editor == null)
+                       return;
+
+               if (!validateEditorInputState())
+                       return;
+
+               final int operationCode;
+               if (isSelectionCommented(editor.getSelectionProvider().getSelection()))
+                       operationCode= ITextOperationTarget.STRIP_PREFIX;
+               else
+                       operationCode= ITextOperationTarget.PREFIX;
+
+               Shell shell= editor.getSite().getShell();
+               if (!fOperationTarget.canDoOperation(operationCode)) {
+                       if (shell != null) {
+                               MessageDialog.openError(shell, CEditorMessages.ToggleComment_error_title,
+                                               CEditorMessages.ToggleComment_error_message);
+                       }
+                       return;
+               }
+
+               Display display= null;
+               if (shell != null && !shell.isDisposed())
+                       display= shell.getDisplay();
+
+               BusyIndicator.showWhile(display, new Runnable() {
+                       public void run() {
+                               fOperationTarget.doOperation(operationCode);
+                       }
+               });
+       }
+
+       /**
+        * Is the given selection single-line commented?
+        *
+        * @param selection Selection to check
+        * @return <code>true</code> iff all selected lines are commented
+        */
+       private boolean isSelectionCommented(ISelection selection) {
+               if (!(selection instanceof ITextSelection))
+                       return false;
+
+               ITextSelection textSelection= (ITextSelection) selection;
+               if (textSelection.getStartLine() < 0 || textSelection.getEndLine() < 0)
+                       return false;
+
+               IDocument document= getTextEditor().getDocumentProvider().getDocument(getTextEditor().getEditorInput());
+
+               try {
+                       IRegion block= getTextBlockFromSelection(textSelection, document);
+                       ITypedRegion[] regions= TextUtilities.computePartitioning(document, fDocumentPartitioning,
+                                       block.getOffset(), block.getLength(), false);
+
+                       int[] lines= new int[regions.length * 2]; // [startline, endline, startline, endline, ...]
+
+                       // For each partition in the text selection, figure out the startline and endline.
+                       // Count the number of lines that are selected.
+                       for (int i = 0, j = 0; i < regions.length; i++, j+= 2) {
+                               // Start line of region
+                               lines[j]= getFirstCompleteLineOfRegion(regions[i], document);
+                               // End line of region
+                               int length= regions[i].getLength();
+                               int offset= regions[i].getOffset() + length;
+                               if (length > 0)
+                                       offset--;
+
+                               // If there is no startline for this region (startline = -1),
+                               // then there is no endline,
+                               // otherwise, get the line number of the endline and store it in the array.
+                               lines[j + 1]= (lines[j] == -1 ? -1 : document.getLineOfOffset(offset));
+
+                               // We could count the number of lines that are selected in this region
+                               // lineCount += lines[j + 1] - lines[j] + 1;
+
+                               assert i < regions.length;
+                               assert j < regions.length * 2;
+                       }
+
+                       // Perform the check
+                       boolean hasComment= false;
+                       for (int i = 0, j = 0; i < regions.length; i++, j += 2) {
+                               String[] prefixes= fPrefixesMap.get(regions[i].getType());
+                               if (prefixes != null && prefixes.length > 0 && lines[j] >= 0 && lines[j + 1] >= 0) {
+                                       if (isBlockCommented(lines[j], lines[j + 1], prefixes, document)) {
+                                               hasComment= true;
+                                       } else if (!isBlockEmpty(lines[j], lines[j + 1], document)) {
+                                               return false;
+                                       }
+                               }
+                       }
+                       return hasComment;
+               } catch (BadLocationException e) {
+                       CUIPlugin.log(e);  // Should not happen
+               }
+
+               return false;
+       }
+
+       /**
+        * Creates a region describing the text block (something that starts at
+        * the beginning of a line) completely containing the current selection.
+        *
+        * Note, the implementation has to match {@link TextViewer}.getTextBlockFromSelection().
+        * 
+        * @param selection The selection to use
+        * @param document The document
+        * @return the region describing the text block comprising the given selection
+        * @throws BadLocationException
+        */
+       private IRegion getTextBlockFromSelection(ITextSelection selection, IDocument document) throws BadLocationException {
+               int start= document.getLineOffset(selection.getStartLine());
+               int end;
+               int endLine= selection.getEndLine();
+               if (document.getNumberOfLines() > endLine+1) {
+                       end= document.getLineOffset(endLine+1);
+               } else {
+                       end= document.getLength();
+               }
+               return new Region(start, end - start);
+       }
+
+       /**
+        * Returns the index of the first line whose start offset is in the given text range.
+        *
+        * @param region the text range in characters where to find the line
+        * @param document The document
+        * @return the first line whose start index is in the given range, -1 if there is no such line
+        */
+       private int getFirstCompleteLineOfRegion(IRegion region, IDocument document) {
+               try {
+                       int startLine= document.getLineOfOffset(region.getOffset());
+
+                       int offset= document.getLineOffset(startLine);
+                       if (offset >= region.getOffset())
+                               return startLine;
+
+                       offset= document.getLineOffset(startLine + 1);
+                       return (offset > region.getOffset() + region.getLength() ? -1 : startLine + 1);
+               } catch (BadLocationException e) {
+                       CUIPlugin.log(e);  // Should not happen
+               }
+
+               return -1;
+       }
+
+       /**
+        * Determines whether each line is prefixed by one of the prefixes.
+        *
+        * @param startLine Start line in document
+        * @param endLine End line in document
+        * @param prefixes Possible comment prefixes
+        * @param document The document
+        * @return <code>true</code> iff each line from <code>startLine</code>
+        *             to and including <code>endLine</code> is prepended by one
+        *             of the <code>prefixes</code>, ignoring whitespace at the
+        *             begin of line
+        */
+       private boolean isBlockCommented(int startLine, int endLine, String[] prefixes, IDocument document) {
+               try {
+                       // Check for occurrences of prefixes in the given lines
+                       boolean hasComment = false;
+                       for (int i= startLine; i <= endLine; i++) {
+                               IRegion line= document.getLineInformation(i);
+                               String text= document.get(line.getOffset(), line.getLength());
+
+                               boolean isEmptyLine = text.trim().length() == 0;
+                               if(isEmptyLine) {
+                                       continue;
+                               }
+                               
+                               int[] found= TextUtilities.indexOf(prefixes, text, 0);
+
+                               if (found[0] == -1) {
+                                       // Found a line which is not commented
+                                       return false;
+                               }
+                               String s= document.get(line.getOffset(), found[0]);
+                               s= s.trim();
+                               if (s.length() != 0) {
+                                       // Found a line which is not commented
+                                       return false;
+                               }
+                               hasComment = true;
+                       }
+                       return hasComment;
+               } catch (BadLocationException e) {
+                       CUIPlugin.log(e);  // Should not happen
+               }
+
+               return false;
+       }
+
+       /**
+        * Determines whether each line is empty
+        *
+        * @param startLine Start line in document
+        * @param endLine End line in document
+        * @param document The document
+        * @return <code>true</code> if each line from <code>startLine</code>
+        *             to and including <code>endLine</code> is empty
+        */
+       private boolean isBlockEmpty(int startLine, int endLine, IDocument document) {
+               try {
+                       for (int i= startLine; i <= endLine; i++) {
+                               IRegion line= document.getLineInformation(i);
+                               String text= document.get(line.getOffset(), line.getLength());
+       
+                               boolean isEmptyLine = text.trim().length() == 0;
+                               if(!isEmptyLine) {
+                                       return false;
+                               }
+                       }
+                       return true;
+               } catch (BadLocationException e) {
+                       CUIPlugin.log(e);  // Should not happen
+               }
+       
+               return false;
+       }
+
+       /**
+        * Implementation of the <code>IUpdate</code> prototype method discovers
+        * the operation through the current editor's
+        * <code>ITextOperationTarget</code> adapter, and sets the enabled state
+        * accordingly.
+        */
+       @Override
+       public void update() {
+               super.update();
+
+               if (!canModifyEditor()) {
+                       setEnabled(false);
+                       return;
+               }
+
+               ITextEditor editor= getTextEditor();
+               if (fOperationTarget == null && editor != null)
+                       fOperationTarget= (ITextOperationTarget) editor.getAdapter(ITextOperationTarget.class);
+
+               boolean isEnabled= (fOperationTarget != null && fOperationTarget.canDoOperation(ITextOperationTarget.PREFIX) &&
+                               fOperationTarget.canDoOperation(ITextOperationTarget.STRIP_PREFIX));
+               setEnabled(isEnabled);
+       }
+
+       /*
+        * @see TextEditorAction#setEditor(ITextEditor)
+        */
+       @Override
+       public void setEditor(ITextEditor editor) {
+               super.setEditor(editor);
+               fOperationTarget= null;
+       }
+
+       /**
+        * For the different content types, get its default comment prefix and store the prefixes.
+        * @param sourceViewer
+        * @param configuration
+        */
+       public void configure(ISourceViewer sourceViewer, SourceViewerConfiguration configuration) {
+               fPrefixesMap= null;
+
+               String[] types= configuration.getConfiguredContentTypes(sourceViewer);
+               Map<String, String[]> prefixesMap= new HashMap<String, String[]>(types.length);
+               for (String type : types) {
+                       String[] prefixes= configuration.getDefaultPrefixes(sourceViewer, type);
+                       if (prefixes != null && prefixes.length > 0) {
+                               int emptyPrefixes= 0;
+                               for (String prefixe : prefixes) {
+                                       if (prefixe.length() == 0)
+                                               emptyPrefixes++;
+                               }
+
+                               if (emptyPrefixes > 0) {
+                                       String[] nonemptyPrefixes= new String[prefixes.length - emptyPrefixes];
+                                       for (int j= 0, k= 0; j < prefixes.length; j++) {
+                                               String prefix= prefixes[j];
+                                               if (prefix.length() != 0) {
+                                                       nonemptyPrefixes[k]= prefix;
+                                                       k++;
+                                               }
+                                       }
+                                       prefixes= nonemptyPrefixes;
+                               }
+
+                               prefixesMap.put(type, prefixes);
+                       }
+               }
+               fDocumentPartitioning= configuration.getConfiguredDocumentPartitioning(sourceViewer);
+               fPrefixesMap= prefixesMap;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ToggleMarkOccurrencesAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ToggleMarkOccurrencesAction.java
new file mode 100644 (file)
index 0000000..575f5a3
--- /dev/null
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.TextEditorAction;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+
+
+/**
+ * A toolbar action which toggles the {@linkplain org.eclipse.cdt.ui.PreferenceConstants#EDITOR_MARK_OCCURRENCES mark occurrences preference}.
+ *
+ * @since 5.0
+ */
+public class ToggleMarkOccurrencesAction extends TextEditorAction implements IPropertyChangeListener {
+
+       private IPreferenceStore fStore;
+
+       /**
+        * Constructs and updates the action.
+        */
+       public ToggleMarkOccurrencesAction() {
+               super(ConstructedCEditorMessages.getResourceBundle(), "ToggleMarkOccurrencesAction.", null, IAction.AS_CHECK_BOX); //$NON-NLS-1$
+               CPluginImages.setToolImageDescriptors(this, "mark_occurrences.gif"); //$NON-NLS-1$
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.TOGGLE_MARK_OCCURRENCES_ACTION);
+               update();
+       }
+
+       /*
+        * @see IAction#actionPerformed
+        */
+       @Override
+       public void run() {
+               fStore.setValue(PreferenceConstants.EDITOR_MARK_OCCURRENCES, isChecked());
+       }
+
+       /*
+        * @see TextEditorAction#update
+        */
+       @Override
+       public void update() {
+               ITextEditor editor= getTextEditor();
+
+               boolean checked= false;
+               if (editor instanceof CEditor)
+                       checked= ((CEditor)editor).isMarkingOccurrences();
+
+               setChecked(checked);
+               setEnabled(editor != null);
+       }
+
+       /*
+        * @see TextEditorAction#setEditor(ITextEditor)
+        */
+       @Override
+       public void setEditor(ITextEditor editor) {
+
+               super.setEditor(editor);
+
+               if (editor != null) {
+
+                       if (fStore == null) {
+                               fStore= CUIPlugin.getDefault().getPreferenceStore();
+                               fStore.addPropertyChangeListener(this);
+                       }
+
+               } else if (fStore != null) {
+                       fStore.removePropertyChangeListener(this);
+                       fStore= null;
+               }
+
+               update();
+       }
+
+       /*
+        * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
+        */
+       public void propertyChange(PropertyChangeEvent event) {
+               if (event.getProperty().equals(PreferenceConstants.EDITOR_MARK_OCCURRENCES))
+                       setChecked(Boolean.valueOf(event.getNewValue().toString()).booleanValue());
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/TogglePresentationAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/TogglePresentationAction.java
new file mode 100644 (file)
index 0000000..2c78a5a
--- /dev/null
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
+import org.eclipse.ui.texteditor.TextEditorAction;
+
+
+/**
+ * A toolbar action which toggles the presentation model of the
+ * connected text editor. The editor shows either the highlight range
+ * only or always the whole document.
+ */
+public class TogglePresentationAction extends TextEditorAction implements IPropertyChangeListener {
+               
+       private IPreferenceStore fStore;
+
+       /**
+        * Constructs and updates the action.
+        */
+       public TogglePresentationAction() {
+               super(ConstructedCEditorMessages.getResourceBundle(), "TogglePresentation.", null); //$NON-NLS-1$
+               CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_SEGMENT_EDIT);
+               setActionDefinitionId(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.TOGGLE_PRESENTATION_ACTION);           
+               update();
+       }
+       
+       /*
+        * @see IAction#actionPerformed
+        */
+       @Override
+       public void run() {
+               
+               ITextEditor editor= getTextEditor();
+               if (editor == null)
+                       return;
+               
+               IRegion remembered= editor.getHighlightRange();
+               editor.resetHighlightRange();
+               
+               boolean showAll= !editor.showsHighlightRangeOnly();
+               setChecked(showAll);
+               
+               editor.showHighlightRangeOnly(showAll);
+               if (remembered != null)
+                       editor.setHighlightRange(remembered.getOffset(), remembered.getLength(), true);
+               
+               fStore.removePropertyChangeListener(this);
+               fStore.setValue(PreferenceConstants.EDITOR_SHOW_SEGMENTS, showAll);
+               fStore.addPropertyChangeListener(this);
+       }
+       
+       /*
+        * @see TextEditorAction#update
+        */
+       @Override
+       public void update() {
+               ITextEditor editor= getTextEditor();
+               boolean checked= (editor != null && editor.showsHighlightRangeOnly());
+               setChecked(checked);
+               setEnabled(editor != null);
+       }
+       
+       /*
+        * @see TextEditorAction#setEditor(ITextEditor)
+        */
+       @Override
+       public void setEditor(ITextEditor editor) {
+               
+               super.setEditor(editor);
+               
+               if (editor != null) {
+                       
+                       if (fStore == null) {
+                               fStore= CUIPlugin.getDefault().getPreferenceStore();
+                               fStore.addPropertyChangeListener(this);
+                       }
+                       synchronizeWithPreference(editor);
+                       
+               } else if (fStore != null) {
+                       fStore.removePropertyChangeListener(this);
+                       fStore= null;
+               }
+               
+               update();
+       }
+       
+       /**
+        * Synchronizes the appearance of the editor with what the preference store tells him.
+        */
+       private void synchronizeWithPreference(ITextEditor editor) {
+               
+               if (editor == null)
+                       return;
+               
+               boolean showSegments= fStore.getBoolean(PreferenceConstants.EDITOR_SHOW_SEGMENTS);
+               setChecked(showSegments);
+               
+               if (editor.showsHighlightRangeOnly() != showSegments) {
+                       IRegion remembered= editor.getHighlightRange();
+                       editor.resetHighlightRange();
+                       editor.showHighlightRangeOnly(showSegments);
+                       if (remembered != null)
+                               editor.setHighlightRange(remembered.getOffset(), remembered.getLength(), true);
+               }
+       }
+
+       /*
+        * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
+        */
+       public void propertyChange(PropertyChangeEvent event) {
+               if (event.getProperty().equals(PreferenceConstants.EDITOR_SHOW_SEGMENTS))
+                       synchronizeWithPreference(getTextEditor());
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ToggleSourceAndHeaderAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/ToggleSourceAndHeaderAction.java
new file mode 100644 (file)
index 0000000..beafb9e
--- /dev/null
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.editor;
+
+import java.util.ResourceBundle;
+
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.TextEditorAction;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.IWorkingCopyManager;
+
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+
+/**
+ * Editor action to toggle between source and header files.
+ * 
+ * @since 4.0
+ */
+public class ToggleSourceAndHeaderAction extends TextEditorAction {
+
+       private static ITranslationUnit fgLastPartnerUnit;
+       private static ITranslationUnit fgLastSourceUnit;
+
+       /**
+        * Create a toggle source/header action for the given editor.
+        * 
+        * @param bundle  the resource bundle to take the label, tooltip and description from.
+        * @param prefix  the prefix to be prepended to the resource bundle keys
+        * @param editor  the text editor this action is associated with
+        * @see TextEditorAction#TextEditorAction(ResourceBundle, String, ITextEditor)
+        */
+       public ToggleSourceAndHeaderAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
+               super(bundle, prefix, editor);
+       }
+
+       /*
+        * @see org.eclipse.jface.action.Action#run()
+        */
+       @Override
+       public void run() {
+               IWorkingCopy currentUnit= getWorkingCopy();
+               if (currentUnit == null) {
+                       return;
+               }
+               ITranslationUnit partnerUnit= computePartnerFile(currentUnit);
+               if (partnerUnit != null) {
+                       fgLastSourceUnit= currentUnit.getOriginalElement();
+                       fgLastPartnerUnit= partnerUnit;
+                       try {
+                               EditorUtility.openInEditor(partnerUnit);
+                       } catch (PartInitException exc) {
+                               CUIPlugin.log(exc.getStatus());
+                       } catch (CModelException exc) {
+                               CUIPlugin.log(exc.getStatus());
+                       }
+               }
+       }
+
+       private IWorkingCopy getWorkingCopy() {
+               IEditorPart editor = getTextEditor();
+               if (editor == null) {
+                       return null;
+               }
+               IEditorInput input= editor.getEditorInput();
+               IWorkingCopyManager manager= CUIPlugin.getDefault().getWorkingCopyManager();                            
+               return manager.getWorkingCopy(input);
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.TextEditorAction#update()
+        */
+       @Override
+       public void update() {
+               setEnabled(getWorkingCopy() != null);
+       }
+
+       /**
+        * Compute the corresponding translation unit for the given unit.
+        * 
+        * @param tUnit  the current source/header translation unit
+        * @return the partner translation unit
+        */
+       private ITranslationUnit computePartnerFile(ITranslationUnit tUnit) {
+               // try shortcut for fast toggling
+               if (fgLastPartnerUnit != null) {
+                       final ITranslationUnit originalUnit;
+                       if (tUnit instanceof IWorkingCopy) {
+                               originalUnit= ((IWorkingCopy)tUnit).getOriginalElement();
+                       } else {
+                               originalUnit= tUnit;
+                       }
+                       if (originalUnit.getTranslationUnit().equals(fgLastPartnerUnit)) {
+                               if (fgLastSourceUnit.exists()) {
+                                       // toggle back
+                                       return fgLastSourceUnit;
+                               }
+                       }
+               }
+
+               // search partner file based on filename/extension
+               return SourceHeaderPartnerFinder.getPartnerTranslationUnit(tUnit);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/TranslationUnitAnnotationModelEvent.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/TranslationUnitAnnotationModelEvent.java
new file mode 100644 (file)
index 0000000..03202de
--- /dev/null
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.editor;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.AnnotationModelEvent;
+import org.eclipse.jface.text.source.IAnnotationModel;
+
+import org.eclipse.ui.texteditor.MarkerAnnotation;
+
+
+/**
+ *
+ * TranslationUnitAnnotationModelEvent
+ *
+ * Event sent out by changes of the compilation unit annotation model.
+ */
+public class TranslationUnitAnnotationModelEvent  extends AnnotationModelEvent {
+       
+       private boolean fIncludesProblemMarkerAnnotations;
+       private IResource fUnderlyingResource;
+       
+       /**
+        * Constructor for CompilationUnitAnnotationModelEvent.
+        * @param model
+        * @param underlyingResource The annotation model's underlying resource 
+        */
+       public TranslationUnitAnnotationModelEvent(IAnnotationModel model, IResource underlyingResource) {
+               super(model);
+               fUnderlyingResource= underlyingResource;
+               fIncludesProblemMarkerAnnotations= false;
+       }
+       
+       private void testIfProblemMarker(Annotation annotation) {
+               if (fIncludesProblemMarkerAnnotations) {
+                       return;
+               }
+               if (annotation instanceof CMarkerAnnotation) {
+                       fIncludesProblemMarkerAnnotations= ((CMarkerAnnotation) annotation).isProblem();
+               } else if (annotation instanceof MarkerAnnotation) {
+                       try {
+                               IMarker marker= ((MarkerAnnotation) annotation).getMarker();
+                               if (!marker.exists() || marker.isSubtypeOf(IMarker.PROBLEM)) {
+                                       fIncludesProblemMarkerAnnotations= true;
+                               }
+                       } catch (CoreException e) {
+                               CUIPlugin.log(e);
+                       }
+               }       
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.source.AnnotationModelEvent#annotationAdded(org.eclipse.jface.text.source.Annotation)
+        */
+       @Override
+       public void annotationAdded(Annotation annotation) {
+               super.annotationAdded(annotation);
+               testIfProblemMarker(annotation);
+       }
+
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.text.source.AnnotationModelEvent#annotationRemoved(org.eclipse.jface.text.source.Annotation, org.eclipse.jface.text.Position)
+        */
+       @Override
+       public void annotationRemoved(Annotation annotation, Position position) {
+               super.annotationRemoved(annotation, position);
+               testIfProblemMarker(annotation);
+       }
+
+       /*
+        * @see org.eclipse.jface.text.source.AnnotationModelEvent#annotationRemoved(org.eclipse.jface.text.source.Annotation)
+        */
+       @Override
+       public void annotationRemoved(Annotation annotation) {
+               super.annotationRemoved(annotation);
+               testIfProblemMarker(annotation);
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.source.AnnotationModelEvent#annotationChanged(org.eclipse.jface.text.source.Annotation)
+        */
+       @Override
+       public void annotationChanged(Annotation annotation) {
+               testIfProblemMarker(annotation);
+               super.annotationChanged(annotation);
+       }
+               
+       /**
+        * Returns whether the change included problem marker annotations.
+        * 
+        * @return <code>true</code> if the change included marker annotations
+        */
+       public boolean includesProblemMarkerAnnotationChanges() {
+               return fIncludesProblemMarkerAnnotations;
+       }
+       
+       /**
+        * Returns the annotation model's underlying resource
+        */
+       public IResource getUnderlyingResource() {
+               return fUnderlyingResource;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/WorkingCopyManager.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/WorkingCopyManager.java
new file mode 100644 (file)
index 0000000..02623ac
--- /dev/null
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor;
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.ui.IEditorInput;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.IProblemRequestor;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.IWorkingCopyManager;
+import org.eclipse.cdt.ui.IWorkingCopyManagerExtension;
+
+import org.eclipse.cdt.internal.core.model.CModelManager;
+import org.eclipse.cdt.internal.core.model.IBufferFactory;
+
+
+/**
+ * This working copy manager works together with a given compilation unit document provider and
+ * additionally offers to "overwrite" the working copy provided by this document provider.
+ */
+public class WorkingCopyManager implements IWorkingCopyManager, IWorkingCopyManagerExtension {
+       
+       private CDocumentProvider fDocumentProvider;
+       private Map<IEditorInput, IWorkingCopy> fMap;
+       private boolean fIsShuttingDown;
+       private IBufferFactory fBufferFactory;
+
+       /**
+        * Creates a new working copy manager that co-operates with the given
+        * compilation unit document provider.
+        * 
+        * @param provider the provider
+        */
+       public WorkingCopyManager(CDocumentProvider provider) {
+               Assert.isNotNull(provider);
+               fDocumentProvider= provider;
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.IWorkingCopyManager#connect(org.eclipse.ui.IEditorInput)
+        */
+       public void connect(IEditorInput input) throws CoreException {
+               fDocumentProvider.connect(input);
+       }
+       
+       /*
+        * @see org.eclipse.cdt.ui.IWorkingCopyManager#disconnect(org.eclipse.ui.IEditorInput)
+        */
+       public void disconnect(IEditorInput input) {
+               fDocumentProvider.disconnect(input);
+       }
+       
+       /*
+        * @see org.eclipse.cdt.ui.IWorkingCopyManager#shutdown()
+        */
+       public void shutdown() {
+               if (!fIsShuttingDown) {
+                       fIsShuttingDown= true;
+                       try {
+                               if (fMap != null) {
+                                       fMap.clear();
+                                       fMap= null;
+                               }
+                               fDocumentProvider.shutdown();
+                       } finally {
+                               fIsShuttingDown= false;
+                       }
+               }
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.IWorkingCopyManager#getWorkingCopy(org.eclipse.ui.IEditorInput)
+        */
+       public IWorkingCopy getWorkingCopy(IEditorInput input) {
+               IWorkingCopy unit= fMap == null ? null : fMap.get(input);
+               return unit != null ? unit : fDocumentProvider.getWorkingCopy(input);
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.editor.IWorkingCopyManagerExtension#setWorkingCopy(org.eclipse.ui.IEditorInput, org.eclipse.cdt.core.model.ITranslationUnit)
+        */
+       public void setWorkingCopy(IEditorInput input, IWorkingCopy workingCopy) {
+               if (fDocumentProvider.getDocument(input) != null) {
+                       if (fMap == null)
+                               fMap= new HashMap<IEditorInput, IWorkingCopy>();
+                       fMap.put(input, workingCopy);
+               }
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.editor.IWorkingCopyManagerExtension#removeWorkingCopy(org.eclipse.ui.IEditorInput)
+        */
+       public void removeWorkingCopy(IEditorInput input) {
+               fMap.remove(input);
+               if (fMap.isEmpty())
+                       fMap= null;
+       }
+
+       public IBufferFactory getBufferFactory() {              
+               if (fBufferFactory == null) {
+                       synchronized (this) {
+                               if (fBufferFactory == null)
+                                       fBufferFactory= new CustomBufferFactory();
+                       }
+               }
+               return fBufferFactory;
+       }
+
+       public IWorkingCopy findSharedWorkingCopy(ITranslationUnit tu) {
+               return CModelManager.getDefault().findSharedWorkingCopy(getBufferFactory(), tu);
+       }
+
+       public IWorkingCopy[] getSharedWorkingCopies() {
+               return CModelManager.getDefault().getSharedWorkingCopies(getBufferFactory());
+       }
+
+       public IWorkingCopy getSharedWorkingCopy(ITranslationUnit original, IProblemRequestor requestor,
+                       IProgressMonitor progressMonitor) throws CModelException {
+               return CModelManager.getDefault().getSharedWorkingCopy(getBufferFactory(), original, requestor, progressMonitor);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/ASMEditorActionContributor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/ASMEditorActionContributor.java
new file mode 100644 (file)
index 0000000..3cb3bf4
--- /dev/null
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor.asm;
+
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.editors.text.TextEditorActionContributor;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
+
+import org.eclipse.cdt.internal.ui.editor.TogglePresentationAction;
+
+public class ASMEditorActionContributor extends TextEditorActionContributor {
+
+       private TogglePresentationAction fTogglePresentation;
+
+       /**
+        * Default constructor is mandatory (executable extension).
+        */
+       public ASMEditorActionContributor() {
+               fTogglePresentation= new TogglePresentationAction();
+               fTogglePresentation.setActionDefinitionId(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY);
+       }
+       
+       /*
+        * @see org.eclipse.ui.editors.text.TextEditorActionContributor#init(org.eclipse.ui.IActionBars)
+        */
+       @Override
+       public void init(IActionBars bars) {
+               super.init(bars);
+               bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY, fTogglePresentation);
+       }
+       
+       /*
+        * @see org.eclipse.ui.editors.text.TextEditorActionContributor#setActiveEditor(org.eclipse.ui.IEditorPart)
+        */
+       @Override
+       public void setActiveEditor(IEditorPart part) {
+               super.setActiveEditor(part);
+               internalSetActiveEditor(part);
+       }
+       
+       private void internalSetActiveEditor(IEditorPart part) {
+               ITextEditor textEditor= null;
+               if (part instanceof ITextEditor)
+                       textEditor= (ITextEditor) part;
+               
+               fTogglePresentation.setEditor(textEditor);
+       }
+       
+       /*
+        * @see org.eclipse.ui.editors.text.TextEditorActionContributor#dispose()
+        */
+       @Override
+       public void dispose() {
+               internalSetActiveEditor(null);
+               super.dispose();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmCodeScanner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmCodeScanner.java
new file mode 100644 (file)
index 0000000..dab1869
--- /dev/null
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ *  Copyright (c) 2005, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *     Andrew Ferguson (Symbian)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor.asm;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.text.rules.EndOfLineRule;
+import org.eclipse.jface.text.rules.IRule;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.WordPatternRule;
+import org.eclipse.jface.text.rules.WordRule;
+
+import org.eclipse.cdt.core.model.IAsmLanguage;
+import org.eclipse.cdt.ui.text.AbstractCScanner;
+import org.eclipse.cdt.ui.text.ICColorConstants;
+import org.eclipse.cdt.ui.text.ITokenStoreFactory;
+
+import org.eclipse.cdt.internal.ui.text.CWhitespaceRule;
+
+
+/*
+ * An assembly code scanner.
+ */
+public final class AsmCodeScanner extends AbstractCScanner {
+       
+       private static String[] fgTokenProperties= {
+               ICColorConstants.ASM_DIRECTIVE,
+               ICColorConstants.ASM_LABEL,
+               ICColorConstants.C_KEYWORD,
+               ICColorConstants.C_SINGLE_LINE_COMMENT,
+               ICColorConstants.C_DEFAULT
+       };
+
+       private IAsmLanguage fAsmLanguage;
+       
+       /**
+        * Creates an assembly code scanner.
+        */
+       public AsmCodeScanner(ITokenStoreFactory factory, IAsmLanguage asmLanguage) {
+               super(factory.createTokenStore(fgTokenProperties));
+               fAsmLanguage= asmLanguage;
+               setRules(createRules());
+       }
+
+       protected List<IRule> createRules() {
+               IToken token;
+               List<IRule> rules= new ArrayList<IRule>();
+
+               // Add rule(s) for single line comments
+               token= getToken(ICColorConstants.C_SINGLE_LINE_COMMENT);
+               char[] lineCommentChars= fAsmLanguage.getLineCommentCharacters();
+               for (int i= 0; i < lineCommentChars.length; i++) {
+                       rules.add(new EndOfLineRule(new String(new char [] {lineCommentChars[i]}), token));
+               }
+
+               final IToken other= getToken(ICColorConstants.C_DEFAULT);               
+
+               // Add generic whitespace rule.
+               rules.add(new CWhitespaceRule(other));
+
+               // Add rule for labels
+               token= getToken(ICColorConstants.ASM_LABEL);
+               IRule labelRule= new AsmLabelRule(new AsmWordDetector(false), token, other);
+               rules.add(labelRule);
+               
+               // Add word rule for keywords
+               token= getToken(ICColorConstants.ASM_DIRECTIVE);
+               String[] keywords= fAsmLanguage.getDirectiveKeywords();
+               WordRule wordRule= new WordRule(new AsmWordDetector('.'), other);
+               for (int i=0; i<keywords.length; i++)
+                       wordRule.addWord(keywords[i], token);
+               rules.add(wordRule);
+
+               // TODO use extra color?
+               token= getToken(ICColorConstants.C_KEYWORD);
+               WordPatternRule regPattern= new WordPatternRule(new AsmWordDetector('%', (char)0), "%", null, token); //$NON-NLS-1$
+               rules.add(regPattern);
+
+               setDefaultReturnToken(other);
+               return rules;
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmContentOutlinePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmContentOutlinePage.java
new file mode 100644 (file)
index 0000000..47b991b
--- /dev/null
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor.asm;
+
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.ui.actions.CustomFiltersActionGroup;
+import org.eclipse.cdt.ui.actions.OpenViewActionGroup;
+
+import org.eclipse.cdt.internal.ui.editor.AbstractCModelOutlinePage;
+
+/**
+ * Content outline page for assembly translation units.
+ *
+ * @since 5.0
+ */
+public class AsmContentOutlinePage extends AbstractCModelOutlinePage {
+
+       /**
+        * Creates a new outline page for the given editor.
+        * @param editor
+        */
+       public AsmContentOutlinePage(ITextEditor editor) {
+               super("#ASMOutlineContext", editor); //$NON-NLS-1$
+       }
+
+       @Override
+       protected OpenViewActionGroup createOpenViewActionGroup() {
+               OpenViewActionGroup ovag= new OpenViewActionGroup(this);
+               ovag.setEnableIncludeBrowser(false);
+               ovag.setSuppressCallHierarchy(true);
+               ovag.setSuppressTypeHierarchy(true);
+               return ovag;
+       }
+
+       @Override
+       protected ActionGroup createCustomFiltersActionGroup() {
+               return new CustomFiltersActionGroup("org.eclipse.cdt.ui.AsmOutlinePage", getTreeViewer()); //$NON-NLS-1$
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmDocumentSetupParticipant.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmDocumentSetupParticipant.java
new file mode 100644 (file)
index 0000000..0622492
--- /dev/null
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor.asm;
+
+import org.eclipse.core.filebuffers.IDocumentSetupParticipant;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentExtension3;
+import org.eclipse.jface.text.IDocumentPartitioner;
+
+import org.eclipse.cdt.ui.CDTUITools;
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+/**
+ * Document setup participant for asesembly content.
+ */
+public class AsmDocumentSetupParticipant implements IDocumentSetupParticipant, IExecutableExtension {
+       /**
+        * Manadatory default constructor.
+        */
+       public AsmDocumentSetupParticipant() {
+       }
+       
+       /*
+        * @see org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup(org.eclipse.jface.text.IDocument)
+        */
+       public void setup(IDocument document) {
+               IDocumentPartitioner partitioner= CDTUITools.createAsmDocumentPartitioner();
+               if (document instanceof IDocumentExtension3) {
+                       IDocumentExtension3 extension3= (IDocumentExtension3) document;
+                       extension3.setDocumentPartitioner(ICPartitions.C_PARTITIONING, partitioner);
+               } else {
+                       document.setDocumentPartitioner(partitioner);
+               }
+               partitioner.connect(document);
+       }
+
+       /*
+        * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
+        */
+       public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
+               // prepared for partitioner configuration
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmLabelRule.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmLabelRule.java
new file mode 100644 (file)
index 0000000..8881b86
--- /dev/null
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor.asm;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.text.rules.IRule;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.IWordDetector;
+import org.eclipse.jface.text.rules.Token;
+
+/**
+ * A word rule matching assembly labels.
+ *
+ * @since 5.0
+ */
+final class AsmLabelRule implements IRule {
+
+       /** The word detector used by this rule. */
+       protected IWordDetector fDetector;
+       /** The token to be returned when a label has been matched. */
+       protected IToken fLabelToken;
+       /** The default token to be returned when no label could be matched. */
+       protected IToken fDefaultToken;
+
+       /**
+        * @param detector
+        * @param defaultToken
+        */
+       AsmLabelRule(IWordDetector detector, IToken labelToken, IToken defaultToken) {
+               Assert.isNotNull(detector);
+               Assert.isNotNull(labelToken);
+               Assert.isNotNull(defaultToken);
+
+               fDetector= detector;
+               fLabelToken= labelToken;
+               fDefaultToken= defaultToken;
+       }
+
+       /*
+        * @see IRule#evaluate
+        */
+       public IToken evaluate(ICharacterScanner scanner) {
+               int c= scanner.read();
+               if (fDetector.isWordStart((char) c)) {
+                       int count= 1;
+                       do {
+                               c= scanner.read();
+                               ++count;
+                       } while (fDetector.isWordPart((char) c));
+                       if(c == ':') {
+                               return fLabelToken;
+                       }
+                       if (fDefaultToken.isUndefined()) {
+                               while (count-- > 0) {
+                                       scanner.unread();
+                               }
+                       }
+                       return fDefaultToken;
+               }
+               
+               scanner.unread();
+               return Token.UNDEFINED;
+       }
+
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmPreprocessorScanner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmPreprocessorScanner.java
new file mode 100644 (file)
index 0000000..af087f7
--- /dev/null
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *     Andrew Ferguson (Symbian)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor.asm;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.text.rules.EndOfLineRule;
+import org.eclipse.jface.text.rules.IRule;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.cdt.core.model.IAsmLanguage;
+import org.eclipse.cdt.ui.text.AbstractCScanner;
+import org.eclipse.cdt.ui.text.ICColorConstants;
+import org.eclipse.cdt.ui.text.ITokenStoreFactory;
+
+import org.eclipse.cdt.internal.ui.text.CHeaderRule;
+import org.eclipse.cdt.internal.ui.text.CWhitespaceRule;
+import org.eclipse.cdt.internal.ui.text.PreprocessorRule;
+import org.eclipse.cdt.internal.ui.text.util.CWordDetector;
+
+/**
+ * A preprocessor directive scanner for Asm source.
+ *
+ * @since 4.0
+ */
+public class AsmPreprocessorScanner extends AbstractCScanner {
+
+       /** Properties for tokens. */
+       private static final String[] fgTokenProperties= {
+               ICColorConstants.C_SINGLE_LINE_COMMENT,
+               ICColorConstants.PP_DIRECTIVE,
+               ICColorConstants.C_STRING,
+               ICColorConstants.PP_HEADER,
+               ICColorConstants.PP_DEFAULT,
+       };
+
+       private IAsmLanguage fAsmLanguage;
+
+       /**
+        * Create a preprocessor directive scanner.
+        * @param factory
+        * @param asmLanguage
+        */
+       public AsmPreprocessorScanner(ITokenStoreFactory factory, IAsmLanguage asmLanguage) {
+               super(factory.createTokenStore(fgTokenProperties));
+               Assert.isNotNull(asmLanguage);
+               fAsmLanguage= asmLanguage;
+               setRules(createRules());
+       }
+
+       /**
+        * Creates rules used in this RulesBasedScanner
+        */
+       protected List<IRule> createRules() {
+               List<IRule> rules= new ArrayList<IRule>();
+               IToken defaultToken= getToken(ICColorConstants.PP_DEFAULT);
+               IToken token;
+
+               // Add generic white space rule.
+               rules.add(new CWhitespaceRule(defaultToken));
+
+               token= getToken(ICColorConstants.PP_DIRECTIVE);
+               PreprocessorRule preprocessorRule= new PreprocessorRule(new CWordDetector(), defaultToken, getToken(ICColorConstants.C_SINGLE_LINE_COMMENT));
+               String[] ppKeywords= fAsmLanguage.getPreprocessorKeywords();
+               for (int i= 0; i < ppKeywords.length; i++) {
+                       String ppKeyword= ppKeywords[i];
+                       if (ppKeyword.length() > 1) {
+                               preprocessorRule.addWord(ppKeyword, token);
+                       }
+               }
+               // add ## operator
+               preprocessorRule.addWord("##", token); //$NON-NLS-1$
+               rules.add(preprocessorRule);
+
+               token = getToken(ICColorConstants.PP_HEADER);
+               CHeaderRule headerRule = new CHeaderRule(token);
+               rules.add(headerRule);
+
+               token = getToken(ICColorConstants.C_SINGLE_LINE_COMMENT);
+               IRule lineCommentRule= new EndOfLineRule("#", token); //$NON-NLS-1$
+               rules.add(lineCommentRule);
+
+               //        token = getToken(ICColorConstants.C_MULTI_LINE_COMMENT);
+               //        IRule blockCommentRule = new MultiLineRule("/*", "*/", token, '\\'); //$NON-NLS-1$ //$NON-NLS-2$
+               //        rules.add(blockCommentRule);
+
+               setDefaultReturnToken(defaultToken);
+               return rules;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmReconcilingStrategy.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmReconcilingStrategy.java
new file mode 100644 (file)
index 0000000..574799e
--- /dev/null
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor.asm;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.reconciler.DirtyRegion;
+import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
+import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.IWorkingCopyManager;
+
+/**
+ * Reconciling strategy for assembly translation units.
+ *
+ * @since 5.0
+ */
+public class AsmReconcilingStrategy implements IReconcilingStrategy, IReconcilingStrategyExtension {
+
+       private ITextEditor fEditor;
+
+       public AsmReconcilingStrategy(ITextEditor editor) {
+               fEditor= editor;
+       }
+
+       private IProgressMonitor fProgressMonitor;
+
+       /*
+        * @see IReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion)
+        */
+       public void reconcile(IRegion partition) {
+               reconcile(false);
+       }
+
+       /*
+        * @see IReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion)
+        */
+       public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
+               // unused - non-incremental reconciler
+       }
+
+       /*
+        * @see IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument)
+        */
+       public void setDocument(IDocument document) {
+               // no-op
+       }
+
+       /*
+        * @see IReconcilingStrategyExtension#setProgressMonitor(IProgressMonitor)
+        */
+       public void setProgressMonitor(IProgressMonitor monitor) {
+               fProgressMonitor= monitor;
+       }
+
+       /*
+        * @see IReconcilingStrategyExtension#initialReconcile()
+        */
+       public void initialReconcile() {
+               reconcile(true);
+       }
+
+       private void reconcile(final boolean initialReconcile) {
+               IWorkingCopyManager fManager = CUIPlugin.getDefault().getWorkingCopyManager();
+               IWorkingCopy workingCopy= fManager.getWorkingCopy(fEditor.getEditorInput());
+               if (workingCopy == null) {
+                       return;
+               }
+               try {
+                       // reconcile
+                       synchronized (workingCopy) {
+                               workingCopy.reconcile(false, true, fProgressMonitor);
+                       }
+               } catch (OperationCanceledException oce) {
+                       // document was modified while parsing
+               } catch (CModelException e) {
+                       IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK, "Error in CDT UI during reconcile", e);  //$NON-NLS-1$
+                       CUIPlugin.log(status);
+               }
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextEditor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextEditor.java
new file mode 100644 (file)
index 0000000..e3f0d4d
--- /dev/null
@@ -0,0 +1,554 @@
+/*******************************************************************************
+ *  Copyright (c) 2005, 2011 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Wind River Systems
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor.asm;
+
+
+import java.util.Iterator;
+
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IStatusLineManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.ITextViewerExtension5;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.text.source.IAnnotationModelExtension2;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IEditorActionBarContributor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPartService;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.editors.text.TextEditor;
+import org.eclipse.ui.navigator.ICommonMenuConstants;
+import org.eclipse.ui.part.EditorActionBarContributor;
+import org.eclipse.ui.texteditor.ITextEditorActionConstants;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ISourceRange;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.CDTUITools;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.IWorkingCopyManager;
+import org.eclipse.cdt.ui.text.AsmSourceViewerConfiguration;
+import org.eclipse.cdt.ui.text.ICPartitions;
+import org.eclipse.cdt.ui.text.IColorManager;
+
+import org.eclipse.cdt.internal.ui.IContextMenuConstants;
+import org.eclipse.cdt.internal.ui.editor.AbstractCModelOutlinePage;
+import org.eclipse.cdt.internal.ui.editor.CAnnotationIterator;
+import org.eclipse.cdt.internal.ui.editor.ICAnnotation;
+
+
+/**
+ * Assembly text editor.
+ */
+public class AsmTextEditor extends TextEditor implements ISelectionChangedListener {   
+
+       /**
+        * Updates the outline page selection and this editor's range indicator.
+        */
+       private class EditorSelectionChangedListener extends AbstractSelectionChangedListener {
+               /*
+                * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+                */
+               public void selectionChanged(SelectionChangedEvent event) {
+                       AsmTextEditor.this.selectionChanged();
+               }
+       }
+       
+       private AbstractCModelOutlinePage fOutlinePage;
+       private EditorSelectionChangedListener fEditorSelectionChangedListener;
+
+       /**
+        * Creates a new assembly text editor.
+        */
+       public AsmTextEditor() {
+               super();
+       }
+       
+       /**
+        * Initializes this editor.
+        */
+       @Override
+       protected void initializeEditor() {
+               IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
+               // FIXME: Should this editor have a different preference store ?
+               // For now we are sharing with the CEditor and any changes in the
+               // setting of the CEditor will be reflected in this editor.
+               setPreferenceStore(store);
+               final IColorManager colorManager = CDTUITools.getColorManager();
+               setSourceViewerConfiguration(new AsmSourceViewerConfiguration(colorManager, store, this, ICPartitions.C_PARTITIONING));
+               setDocumentProvider(CUIPlugin.getDefault().getDocumentProvider());
+               setEditorContextMenuId("#ASMEditorContext"); //$NON-NLS-1$
+               setRulerContextMenuId("#ASMEditorRulerContext"); //$NON-NLS-1$
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#collectContextMenuPreferencePages()
+        */
+       @Override
+       protected String[] collectContextMenuPreferencePages() {
+               // Add Assembly Editor relevant pages
+               String[] parentPrefPageIds = super.collectContextMenuPreferencePages();
+               String[] prefPageIds = new String[parentPrefPageIds.length + 1];
+               int nIds = 0;
+               prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.CodeColoringPreferencePage"; //$NON-NLS-1$
+               System.arraycopy(parentPrefPageIds, 0, prefPageIds, nIds, parentPrefPageIds.length);
+               return prefPageIds;
+       }
+
+       /*
+        * @see org.eclipse.ui.editors.text.TextEditor#getAdapter(java.lang.Class)
+        */
+       @SuppressWarnings("rawtypes")
+       @Override
+       public Object getAdapter(Class adapter) {
+               if (IContentOutlinePage.class.equals(adapter)) {
+                       return getOutlinePage();
+               }
+               return super.getAdapter(adapter);
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#createPartControl(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       public void createPartControl(Composite parent) {
+               super.createPartControl(parent);
+
+//             PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ICHelpContextIds.ASMEDITOR_VIEW);
+
+               fEditorSelectionChangedListener = new EditorSelectionChangedListener();
+               fEditorSelectionChangedListener.install(getSelectionProvider());
+       }
+
+       /*
+        * @see org.eclipse.ui.editors.text.TextEditor#dispose()
+        */
+       @Override
+       public void dispose() {
+               if (fOutlinePage != null) {
+                       fOutlinePage.dispose();
+                       fOutlinePage = null;
+               }
+               if (fEditorSelectionChangedListener != null)  {
+                       fEditorSelectionChangedListener.uninstall(getSelectionProvider());
+                       fEditorSelectionChangedListener = null;
+               }
+               super.dispose();
+       }
+
+       /*
+        * @see AbstractTextEditor#affectsTextPresentation(PropertyChangeEvent)
+        * Pulled in from 2.0
+        */
+       @Override
+       protected boolean affectsTextPresentation(PropertyChangeEvent event) {
+               SourceViewerConfiguration configuration = getSourceViewerConfiguration();
+               if (configuration instanceof AsmSourceViewerConfiguration) {
+                       return ((AsmSourceViewerConfiguration)configuration).affectsTextPresentation(event);
+               }
+               return false;
+       }
+
+       /*
+        * @see org.eclipse.ui.editors.text.TextEditor#handlePreferenceStoreChanged(org.eclipse.jface.util.PropertyChangeEvent)
+        */
+       @Override
+       protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
+               SourceViewerConfiguration configuration = getSourceViewerConfiguration();
+               if (configuration instanceof AsmSourceViewerConfiguration) {
+                       ((AsmSourceViewerConfiguration)configuration).handlePropertyChangeEvent(event);
+               }
+               super.handlePreferenceStoreChanged(event);
+       }
+
+       /*
+        * @see org.eclipse.ui.editors.text.TextEditor#editorContextMenuAboutToShow(org.eclipse.jface.action.IMenuManager)
+        */
+       @Override
+       protected void editorContextMenuAboutToShow(IMenuManager menu) {
+               // marker for contributions to the top
+               menu.add(new GroupMarker(ICommonMenuConstants.GROUP_TOP));
+               // separator for debug related actions (similar to ruler context menu)
+               menu.add(new Separator(IContextMenuConstants.GROUP_DEBUG));
+               menu.add(new GroupMarker(IContextMenuConstants.GROUP_DEBUG+".end")); //$NON-NLS-1$
+
+               super.editorContextMenuAboutToShow(menu);
+       }
+
+       /**
+        * Gets the outline page for this editor.
+     * @return Outline page.
+        */
+       public AbstractCModelOutlinePage getOutlinePage() {
+               if (fOutlinePage == null) {
+                       fOutlinePage = new AsmContentOutlinePage(this);
+                       fOutlinePage.addSelectionChangedListener(this);
+               }
+               setOutlinePageInput(fOutlinePage, getEditorInput());
+               return fOutlinePage;
+       }
+
+       /**
+     * Sets an input for the outline page.
+        * @param page Page to set the input.
+        * @param input Input to set.
+        */
+       public static void setOutlinePageInput(AbstractCModelOutlinePage page, IEditorInput input) {
+               if (page != null) {
+                       IWorkingCopyManager manager = CUIPlugin.getDefault().getWorkingCopyManager();
+                       page.setInput(manager.getWorkingCopy(input));
+               }
+       }
+
+       /**
+        * React to changed selection in the editor.
+        */
+       protected void selectionChanged() {
+               if (getSelectionProvider() == null)
+                       return;
+               ISourceReference element= computeHighlightRangeSourceReference();
+               updateStatusLine();
+               synchronizeOutlinePage();
+               setSelection(element, false);
+       }
+
+       /**
+        * Synchronizes the outline view selection with the given element
+        * position in the editor.
+        */
+       protected void synchronizeOutlinePage() {
+               if(fOutlinePage != null && fOutlinePage.isLinkingEnabled()) {
+                       fOutlinePage.removeSelectionChangedListener(this);
+                       fOutlinePage.synchronizeSelectionWithEditor();
+                       fOutlinePage.addSelectionChangedListener(this);
+               }
+       }       
+       
+       protected void updateStatusLine() {
+               ITextSelection selection = (ITextSelection) getSelectionProvider().getSelection();
+               Annotation annotation = getAnnotation(selection.getOffset(), selection.getLength());
+               setStatusLineErrorMessage(null);
+               setStatusLineMessage(null);
+               if (annotation != null) {
+                       updateMarkerViews(annotation);
+                       if (annotation instanceof ICAnnotation && ((ICAnnotation) annotation).isProblem())
+                               setStatusLineMessage(annotation.getText());
+               }
+       }
+
+       /**
+        * Returns the annotation overlapping with the given range or <code>null</code>.
+        * 
+        * @param offset the region offset
+        * @param length the region length
+        * @return the found annotation or <code>null</code>
+        */
+       private Annotation getAnnotation(int offset, int length) {
+               IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput());
+               if (model == null)
+                       return null;
+               
+               @SuppressWarnings("rawtypes")
+               Iterator parent;
+               if (model instanceof IAnnotationModelExtension2) {
+                       parent= ((IAnnotationModelExtension2)model).getAnnotationIterator(offset, length, true, true);
+               } else {
+                       parent= model.getAnnotationIterator();
+               }
+
+               @SuppressWarnings("unchecked")
+               Iterator<Annotation> e= new CAnnotationIterator(parent, false);
+               while (e.hasNext()) {
+                       Annotation a = e.next();
+                       if (!isNavigationTarget(a))
+                               continue;
+                               
+                       Position p = model.getPosition(a);
+                       if (p != null && p.overlapsWith(offset, length))
+                               return a;
+               }
+               
+               return null;
+       }
+
+       /**
+        * Get the StatusLineManager.
+        */
+       @Override
+       protected IStatusLineManager getStatusLineManager() {
+               IEditorActionBarContributor contributor = getEditorSite().getActionBarContributor();
+               if (contributor instanceof EditorActionBarContributor) {
+                       return ((EditorActionBarContributor) contributor).getActionBars().getStatusLineManager();
+               }
+               return null;
+       }
+       
+
+       /**
+        * Computes and returns the source reference that includes the caret and
+        * serves as provider for the outline page selection and the editor range
+        * indication.
+        *
+        * @return the computed source reference
+        */
+       protected ISourceReference computeHighlightRangeSourceReference() {
+               ISourceViewer sourceViewer= getSourceViewer();
+               if (sourceViewer == null)
+                       return null;
+
+               StyledText styledText= sourceViewer.getTextWidget();
+               if (styledText == null)
+                       return null;
+
+               int caret= 0;
+               if (sourceViewer instanceof ITextViewerExtension5) {
+                       ITextViewerExtension5 extension= (ITextViewerExtension5)sourceViewer;
+                       caret= extension.widgetOffset2ModelOffset(styledText.getSelection().x);
+               } else {
+                       int offset= sourceViewer.getVisibleRegion().getOffset();
+                       caret= offset + styledText.getSelection().x;
+               }
+
+               ICElement element= getElementAt(caret, false);
+
+               if ( !(element instanceof ISourceReference))
+                       return null;
+
+               return (ISourceReference) element;
+       }
+
+       /**
+        * Returns the most narrow element including the given offset.  If <code>reconcile</code>
+        * is <code>true</code> the editor's input element is reconciled in advance. If it is
+        * <code>false</code> this method only returns a result if the editor's input element
+        * does not need to be reconciled.
+        *
+        * @param offset the offset included by the retrieved element
+        * @param reconcile <code>true</code> if working copy should be reconciled
+        * @return the most narrow element which includes the given offset
+        */
+       protected ICElement getElementAt(int offset, boolean reconcile) {
+               ITranslationUnit unit= (ITranslationUnit)getInputCElement();
+
+               if (unit != null) {
+                       try {
+                               if (reconcile && unit instanceof IWorkingCopy) {
+                                       synchronized (unit) {
+                                               ((IWorkingCopy) unit).reconcile();
+                                       }
+                                       return unit.getElementAtOffset(offset);
+                               } else if (unit.isConsistent()) {
+                                       return unit.getElementAtOffset(offset);
+                               }
+                       } catch (CModelException x) {
+                               CUIPlugin.log(x.getStatus());
+                               // nothing found, be tolerant and go on
+                       }
+               }
+
+               return null;
+       }
+
+       /**
+        * Returns the C element wrapped by this editors input.
+        *
+        * @return the C element wrapped by this editors input.
+        */
+       public ICElement getInputCElement () {
+               return CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(getEditorInput());
+       }
+
+       /**
+        * React to changed selection in the outline view.
+        * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+        */
+       public void selectionChanged(SelectionChangedEvent event) {
+               ISelection sel = event.getSelection();
+               if (sel instanceof IStructuredSelection) {
+                       IStructuredSelection selection = (IStructuredSelection) sel;
+                       Object obj = selection.getFirstElement();
+                       if (obj instanceof ISourceReference) {
+                               try {
+                                       ISourceRange range = ((ISourceReference) obj).getSourceRange();
+                                       if (range != null) {
+                                               setSelection(range, !isActivePart());
+                                       }
+                               } catch (CModelException e) {
+                    // Selection change not applied.
+                               }
+                       }
+               }
+       }
+
+       /**
+     * Checks is the editor active part. 
+     * @return <code>true</code> if editor is the active part of the workbench.
+        */
+    private boolean isActivePart() {
+               IWorkbenchWindow window = getSite().getWorkbenchWindow();
+               IPartService service = window.getPartService();
+               return (this == service.getActivePart());
+       }
+
+       /**
+     * Sets selection for C element. 
+     * @param element Element to select.
+        */
+    public void setSelection(ICElement element) {
+               if (element instanceof ISourceReference && !(element instanceof ITranslationUnit)) {
+                       ISourceReference reference = (ISourceReference) element;
+                       // set hightlight range
+                       setSelection(reference, true);
+               }
+       }
+
+    /**
+     * Sets selection for source reference.
+     * @param element Source reference to set.
+     * @param moveCursor Should cursor be moved.
+     */
+    public void setSelection(ISourceReference element, boolean moveCursor) {
+               if (element != null) {
+                       StyledText  textWidget = null;
+                       
+                       ISourceViewer sourceViewer = getSourceViewer();
+                       if (sourceViewer != null)
+                               textWidget = sourceViewer.getTextWidget();
+                       
+                       if (textWidget == null)
+                               return;
+
+                       try {
+                               setSelection(element.getSourceRange(), moveCursor);
+                       } catch (CModelException e) {
+                // Selection not applied.
+                       }
+               }
+       }
+
+       /**
+        * Sets the current editor selection to the source range. Optionally
+        * sets the current editor position.
+        *
+        * @param element the source range to be shown in the editor, can be null.
+        * @param moveCursor if true the editor is scrolled to show the range.
+        */
+       public void setSelection(ISourceRange element, boolean moveCursor) {
+               if (getSelectionProvider() == null)
+                       return;
+
+               ISelection selection= getSelectionProvider().getSelection();
+               if (selection instanceof ITextSelection) {
+                       ITextSelection textSelection= (ITextSelection) selection;
+                       // PR 39995: [navigation] Forward history cleared after going back in navigation history:
+                       // mark only in navigation history if the cursor is being moved (which it isn't if
+                       // this is called from a PostSelectionEvent that should only update the magnet)
+                       if (moveCursor && (textSelection.getOffset() != 0 || textSelection.getLength() != 0))
+                               markInNavigationHistory();
+               }
+
+               if (element != null) {
+                       
+                       StyledText textWidget= null;
+                       
+                       ISourceViewer sourceViewer= getSourceViewer();
+                       if (sourceViewer == null)
+                               return;
+                       
+                       textWidget= sourceViewer.getTextWidget();
+                       if (textWidget == null)
+                               return;
+
+                       try {
+                               IRegion alternateRegion = null;
+                               int start = element.getStartPos();
+                               int length = element.getLength();
+       
+                               // Sanity check sometimes the parser may throw wrong numbers.
+                               if (start < 0 || length < 0) {
+                                       start = 0;
+                                       length = 0;
+                               }
+       
+                               // 0 length and start and non-zero start line says we know
+                               // the line for some reason, but not the offset.
+                               if (length == 0 && start == 0 && element.getStartLine() > 0) {
+                                       // We have the information in term of lines, we can work it out.
+                                       // Binary elements return the first executable statement so we have to subtract -1
+                                       start = getDocumentProvider().getDocument(getEditorInput()).getLineOffset(element.getStartLine() - 1);
+                                       if (element.getEndLine() > 0) {
+                                               length = getDocumentProvider().getDocument(getEditorInput()).getLineOffset(element.getEndLine()) - start;
+                                       } else {
+                                               length = start;
+                                       }
+                                       // create an alternate region for the keyword highlight.
+                                       alternateRegion = getDocumentProvider().getDocument(getEditorInput()).getLineInformation(element.getStartLine() - 1);
+                                       if (start == length || length < 0) {
+                                               if (alternateRegion != null) {
+                                                       start = alternateRegion.getOffset();
+                                                       length = alternateRegion.getLength();
+                                               }
+                                       }
+                               }
+                               setHighlightRange(start, length, moveCursor);
+       
+                               if (moveCursor) {
+                                       start = element.getIdStartPos();
+                                       length = element.getIdLength();
+                                       if (start == 0 && length == 0 && alternateRegion != null) {
+                                               start = alternateRegion.getOffset();
+                                               length = alternateRegion.getLength();
+                                       }
+                                       if (start > -1 && length > 0) {
+                                               try  {
+                                                       textWidget.setRedraw(false);
+                                                       sourceViewer.revealRange(start, length);
+                                                       sourceViewer.setSelectedRange(start, length);
+                                               } finally {
+                                                       textWidget.setRedraw(true);
+                                               }
+                                               markInNavigationHistory();
+                                       }
+                                       updateStatusField(ITextEditorActionConstants.STATUS_CATEGORY_INPUT_POSITION);
+                               }
+                       } catch (IllegalArgumentException x) {
+                   // No information to the user
+                       } catch (BadLocationException e) {
+                   // No information to the user
+                       }
+               } else if (moveCursor) {
+                       resetHighlightRange();
+                       markInNavigationHistory();
+               }
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextTools.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextTools.java
new file mode 100644 (file)
index 0000000..b43ba7d
--- /dev/null
@@ -0,0 +1,214 @@
+/*******************************************************************************
+ *  Copyright (c) 2005, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Wind River Systems, Inc.
+ *     Andrew Ferguson (Symbian)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor.asm;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.jface.text.rules.FastPartitioner;
+import org.eclipse.jface.text.rules.RuleBasedScanner;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+import org.eclipse.cdt.core.model.AssemblyLanguage;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.ICColorConstants;
+import org.eclipse.cdt.ui.text.ICPartitions;
+import org.eclipse.cdt.ui.text.ITokenStore;
+import org.eclipse.cdt.ui.text.ITokenStoreFactory;
+
+import org.eclipse.cdt.internal.ui.text.CCommentScanner;
+import org.eclipse.cdt.internal.ui.text.SingleTokenCScanner;
+import org.eclipse.cdt.internal.ui.text.TokenStore;
+import org.eclipse.cdt.internal.ui.text.asm.AsmPartitionScanner;
+import org.eclipse.cdt.internal.ui.text.util.CColorManager;
+
+
+/**
+ * This type shares all scanners and the color manager between
+ * its clients.
+ * 
+ * @deprecated No longer used within CDT.
+ */
+@Deprecated
+public class AsmTextTools {
+       
+    private class PreferenceListener implements IPropertyChangeListener {
+        public void propertyChange(PropertyChangeEvent event) {
+            adaptToPreferenceChange(event);
+        }
+    }
+    
+       /** The color manager -- use the same as for C code */
+       private CColorManager fColorManager;
+       /** The Asm source code scanner */
+       private AsmCodeScanner fCodeScanner;
+       /** The ASM multiline comment scanner */
+       private CCommentScanner fMultilineCommentScanner;
+       /** The ASM singleline comment scanner */
+       private CCommentScanner fSinglelineCommentScanner;
+       /** The ASM string scanner */
+       private SingleTokenCScanner fStringScanner;
+       /** The ASM preprocessor scanner */
+       private AsmPreprocessorScanner fPreprocessorScanner;
+       
+       /** The preference store */
+       private IPreferenceStore fPreferenceStore;
+       /** The preference change listener */
+       private PreferenceListener fPreferenceListener= new PreferenceListener();
+       
+       
+    /**
+     * Creates a new Asm text tools collection and eagerly creates 
+     * and initializes all members of this collection.
+     */
+    public AsmTextTools(IPreferenceStore store) {
+       fPreferenceStore = store != null ? store : CUIPlugin.getDefault().getCombinedPreferenceStore();
+       fColorManager= new CColorManager();
+       
+               ITokenStoreFactory factory= new ITokenStoreFactory() {
+                       public ITokenStore createTokenStore(String[] propertyColorNames) {
+                               return new TokenStore(fColorManager, fPreferenceStore, propertyColorNames);
+                       }
+               };
+
+               fCodeScanner= new AsmCodeScanner(factory, AssemblyLanguage.getDefault());
+               fPreprocessorScanner= new AsmPreprocessorScanner(factory, AssemblyLanguage.getDefault());
+        fMultilineCommentScanner= new CCommentScanner(factory, ICColorConstants.C_MULTI_LINE_COMMENT);
+        fSinglelineCommentScanner= new CCommentScanner(factory, ICColorConstants.C_SINGLE_LINE_COMMENT);
+               fStringScanner= new SingleTokenCScanner(factory, ICColorConstants.C_STRING);
+
+               // listener must be registered after initializing scanners
+        fPreferenceStore.addPropertyChangeListener(fPreferenceListener);
+    }
+       
+       /**
+        * Creates a new Asm text tools collection and eagerly creates 
+        * and initializes all members of this collection.
+        */
+       public AsmTextTools() {
+               this((IPreferenceStore)null);
+       }
+       /**
+        * Disposes all members of this tools collection.
+        */
+       public void dispose() {
+               
+               fCodeScanner= null;
+               
+               fMultilineCommentScanner= null;
+               fSinglelineCommentScanner= null;
+               fStringScanner= null;
+               
+               if (fColorManager != null) {
+                       fColorManager.dispose();
+                       fColorManager= null;
+               }
+               
+               if (fPreferenceStore != null) {
+                       fPreferenceStore.removePropertyChangeListener(fPreferenceListener);
+                       fPreferenceStore= null;
+            
+                       fPreferenceListener= null;
+               }
+       }
+       
+       /**
+        * Gets the color manager.
+        */
+       public CColorManager getColorManager() {
+               return fColorManager;
+       }
+       
+       /**
+        * Gets the code scanner used.
+        */
+       public RuleBasedScanner getCodeScanner() {
+               return fCodeScanner;
+       }
+               
+       /**
+        * Returns a scanner which is configured to scan multiline comments.
+        *
+        * @return a multiline comment scanner
+        */
+       public RuleBasedScanner getMultilineCommentScanner() {
+               return fMultilineCommentScanner;
+       }
+
+       /**
+        * Returns a scanner which is configured to scan singleline comments.
+        *
+        * @return a singleline comment scanner
+        */
+       public RuleBasedScanner getSinglelineCommentScanner() {
+               return fSinglelineCommentScanner;
+       }
+       
+       /**
+        * Returns a scanner which is configured to scan strings.
+        *
+        * @return a string scanner
+        */
+       public RuleBasedScanner getStringScanner() {
+               return fStringScanner;
+       }
+
+       /**
+        * Returns a scanner which is configured to scan Asm preprocessor directives.
+        *
+        * @return an Asm preprocessor directives scanner
+        */
+       public RuleBasedScanner getPreprocessorScanner() {
+               return fPreprocessorScanner;
+       }
+
+       /**
+        * Determines whether the preference change encoded by the given event
+        * changes the behavior of one its contained components.
+        * 
+        * @param event the event to be investigated
+        * @return <code>true</code> if event causes a behavioral change
+        */
+       public boolean affectsBehavior(PropertyChangeEvent event) {
+               return  fCodeScanner.affectsBehavior(event) ||
+                                       fMultilineCommentScanner.affectsBehavior(event) ||
+                                       fSinglelineCommentScanner.affectsBehavior(event) ||
+                                       fStringScanner.affectsBehavior(event) ||
+                                       fPreprocessorScanner.affectsBehavior(event);
+       }
+       
+       /**
+        * Adapts the behavior of the contained components to the change
+        * encoded in the given event.
+        * 
+        * @param event the event to whch to adapt
+        */
+       protected void adaptToPreferenceChange(PropertyChangeEvent event) {
+               if (fCodeScanner.affectsBehavior(event))
+                       fCodeScanner.adaptToPreferenceChange(event);
+               if (fMultilineCommentScanner.affectsBehavior(event))
+                       fMultilineCommentScanner.adaptToPreferenceChange(event);
+               if (fSinglelineCommentScanner.affectsBehavior(event))
+                       fSinglelineCommentScanner.adaptToPreferenceChange(event);
+               if (fStringScanner.affectsBehavior(event))
+                       fStringScanner.adaptToPreferenceChange(event);
+               if (fPreprocessorScanner.affectsBehavior(event))
+                       fPreprocessorScanner.adaptToPreferenceChange(event);
+       }
+
+       public IDocumentPartitioner createDocumentPartitioner() {
+               return new FastPartitioner(new AsmPartitionScanner(), ICPartitions.ALL_ASM_PARTITIONS);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmWordDetector.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmWordDetector.java
new file mode 100644 (file)
index 0000000..b687af5
--- /dev/null
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.editor.asm;
+
+import org.eclipse.jface.text.rules.IWordDetector;
+
+
+/**
+ * A C aware word detector.
+ */
+public class AsmWordDetector implements IWordDetector {
+       private char fPrefix = 0;
+       private char fExtra = 0;
+       private boolean fStrictStart = true;
+
+       public AsmWordDetector() {
+       }
+       
+       public AsmWordDetector(boolean strict) {
+               fStrictStart = strict;
+       }
+       
+       public AsmWordDetector(char extra) {
+               fExtra = extra;
+       }
+       
+       public AsmWordDetector(char prefix, char extra) {
+               fPrefix = prefix;
+               fExtra = extra;
+       }
+       /*
+        * @see org.eclipse.jface.text.rules.IWordDetector#isWordStart(char)
+        */
+       public boolean isWordStart(char c) {
+               if(fPrefix != 0) {
+                       return (fPrefix == c);
+               }
+               if(fStrictStart) {
+                       return (Character.isJavaIdentifierStart(c) || (c == fExtra));
+               }
+               return (Character.isJavaIdentifierPart(c) || (c == fExtra));
+       }
+       /*
+        * @see org.eclipse.jface.text.rules.IWordDetector#isWordPart(char)
+        */
+       public boolean isWordPart(char c) {
+               return Character.isJavaIdentifierPart(c);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ArchiveFilter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ArchiveFilter.java
new file mode 100644 (file)
index 0000000..fc1ba0e
--- /dev/null
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.filters;
+
+import org.eclipse.cdt.core.model.IArchive;
+import org.eclipse.cdt.core.model.IArchiveContainer;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+
+
+/**
+ * The ArchiveFilter is a filter used to determine whether
+ * a C Archive is shown
+ */
+public class ArchiveFilter extends ViewerFilter {
+       
+       /* (non-Javadoc)
+        * Method declared on ViewerFilter.
+        */
+       @Override
+       public boolean select(Viewer viewer, Object parentElement, Object element) {
+               if (element instanceof IArchive) {
+                       if (! (parentElement instanceof IArchiveContainer)) {
+                               return false;
+                       }
+               }
+               return true;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ClosedProjectFilter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ClosedProjectFilter.java
new file mode 100644 (file)
index 0000000..d3188ad
--- /dev/null
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.filters;
+
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.core.resources.IResource;
+
+
+/**
+ * Filters closed projects
+ */
+public class ClosedProjectFilter extends ViewerFilter {
+
+       /*
+        * @see ViewerFilter
+        */
+       @Override
+       public boolean select(Viewer viewer, Object parent, Object element) {
+               if (element instanceof ICElement) 
+                       return ((ICElement)element).getCProject().getProject().isOpen();
+               if (element instanceof IResource)
+                       return ((IResource)element).getProject().isOpen();
+               return true;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/CustomFiltersDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/CustomFiltersDialog.java
new file mode 100644 (file)
index 0000000..c767270
--- /dev/null
@@ -0,0 +1,383 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.filters;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.Stack;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.SelectionDialog;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.util.SWTUtil;
+
+public class CustomFiltersDialog extends SelectionDialog {
+
+       private static final String SEPARATOR= ",";  //$NON-NLS-1$
+
+       private String fViewId;
+       private boolean fEnablePatterns;
+       private String[] fPatterns;
+       private String[] fEnabledFilterIds;
+
+       FilterDescriptor[] fBuiltInFilters;
+
+       CheckboxTableViewer fCheckBoxList;
+       Button fEnableUserDefinedPatterns;
+       Text fUserDefinedPatterns;
+
+       Stack<FilterDescriptor> fFilterDescriptorChangeHistory;
+
+       
+       /**
+        * Creates a dialog to customize Java element filters.
+        *
+        * @param shell the parent shell
+        */
+       public CustomFiltersDialog(
+                       Shell shell,
+                       String viewId,
+                       boolean enablePatterns,
+                       String[] patterns,
+                       String[] enabledFilterIds) {
+
+               super(shell);
+               Assert.isNotNull(viewId);
+               Assert.isNotNull(patterns);
+               Assert.isNotNull(enabledFilterIds);
+
+               fViewId= viewId;
+               fPatterns= patterns;
+               fEnablePatterns= enablePatterns;
+               fEnabledFilterIds= enabledFilterIds;
+
+               fBuiltInFilters= FilterDescriptor.getFilterDescriptors(fViewId);
+               fFilterDescriptorChangeHistory= new Stack<FilterDescriptor>();
+               setShellStyle(getShellStyle() | SWT.RESIZE);
+       }
+
+       @Override
+       protected void configureShell(Shell shell) {
+               setTitle(FilterMessages.CustomFiltersDialog_title);  
+               setMessage(FilterMessages.CustomFiltersDialog_filterList_label); 
+               super.configureShell(shell);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, ICHelpContextIds.CUSTOM_FILTERS_DIALOG);
+       }
+
+       /**
+        * Overrides method in Dialog
+        * 
+        * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(Composite)
+        */     
+       @Override
+       protected Control createDialogArea(Composite parent) {
+               initializeDialogUnits(parent);
+               // create a composite with standard margins and spacing
+               Composite composite= new Composite(parent, SWT.NONE);
+               GridLayout layout= new GridLayout();
+               layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+               layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+               layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
+               layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+               composite.setLayout(layout);
+               composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+               composite.setFont(parent.getFont());
+               Composite group= composite;
+               
+               // Checkbox
+               fEnableUserDefinedPatterns= new Button(group, SWT.CHECK);
+               fEnableUserDefinedPatterns.setText(FilterMessages.CustomFiltersDialog_enableUserDefinedPattern); 
+               
+               // Pattern      field
+               fUserDefinedPatterns= new Text(group, SWT.SINGLE | SWT.BORDER);
+               GridData  data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
+               data.widthHint= convertWidthInCharsToPixels(59);
+               fUserDefinedPatterns.setLayoutData(data);
+               String patterns= convertToString(fPatterns, SEPARATOR);
+               fUserDefinedPatterns.setText(patterns);
+
+               // Info text
+               final Label info= new Label(group, SWT.LEFT);
+               info.setText(FilterMessages.CustomFiltersDialog_patternInfo); 
+
+               // Enabling / disabling of pattern group
+               fEnableUserDefinedPatterns.setSelection(fEnablePatterns);
+               fUserDefinedPatterns.setEnabled(fEnablePatterns);
+               info.setEnabled(fEnablePatterns);
+               fEnableUserDefinedPatterns.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               boolean state= fEnableUserDefinedPatterns.getSelection();
+                               fUserDefinedPatterns.setEnabled(state);
+                               info.setEnabled(fEnableUserDefinedPatterns.getSelection());
+                               if (state)
+                                       fUserDefinedPatterns.setFocus();
+                       }
+               });
+
+               // Filters provided by extension point
+               if (fBuiltInFilters.length > 0)
+                       createCheckBoxList(group);
+                               
+               applyDialogFont(parent);                
+               return parent;
+       }
+
+       private void createCheckBoxList(Composite parent) {
+               // Filler
+               new Label(parent, SWT.NONE);
+               
+               Label info= new Label(parent, SWT.LEFT);
+               info.setText(FilterMessages.CustomFiltersDialog_filterList_label);  
+               
+               fCheckBoxList= CheckboxTableViewer.newCheckList(parent, SWT.BORDER);
+               GridData data= new GridData(GridData.FILL_BOTH);
+               data.heightHint= fCheckBoxList.getTable().getItemHeight() * 10;
+               fCheckBoxList.getTable().setLayoutData(data);
+
+               fCheckBoxList.setLabelProvider(createLabelPrivder());
+               fCheckBoxList.setContentProvider(new ArrayContentProvider());
+
+               fCheckBoxList.setInput(fBuiltInFilters);
+               setInitialSelections(getEnabledFilterDescriptors());
+               
+               List<?> initialSelection= getInitialElementSelections();
+               if (initialSelection != null && !initialSelection.isEmpty())
+                       checkInitialSelections();
+
+               // Description
+               info= new Label(parent, SWT.LEFT);
+               info.setText(FilterMessages.CustomFiltersDialog_description_label);  
+               final Text description= new Text(parent, SWT.LEFT | SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.VERTICAL);
+               data = new GridData(GridData.FILL_HORIZONTAL);
+               data.heightHint= convertHeightInCharsToPixels(3);
+               description.setLayoutData(data);
+               fCheckBoxList.addSelectionChangedListener(new ISelectionChangedListener() {
+                       public void selectionChanged(SelectionChangedEvent event) {
+                               ISelection selection= event.getSelection();
+                               if (selection instanceof IStructuredSelection) {
+                                       Object selectedElement= ((IStructuredSelection)selection).getFirstElement();
+                                       if (selectedElement instanceof FilterDescriptor)
+                                               description.setText(((FilterDescriptor)selectedElement).getDescription());
+                               }
+                       }
+               });
+               fCheckBoxList.addCheckStateListener(new ICheckStateListener() {
+                       /*
+                        * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent)
+                        */
+                       public void checkStateChanged(CheckStateChangedEvent event) {
+                               Object element= event.getElement();
+                               if (element instanceof FilterDescriptor) {
+                                       // renew if already touched
+                                       if (fFilterDescriptorChangeHistory.contains(element)) {
+                                               fFilterDescriptorChangeHistory.remove(element);
+                                       }
+                                       fFilterDescriptorChangeHistory.push((FilterDescriptor)element);
+                               }
+                       }});
+
+               addSelectionButtons(parent);
+       }
+
+       private void addSelectionButtons(Composite composite) {
+               Composite buttonComposite= new Composite(composite, SWT.RIGHT);
+               GridLayout layout= new GridLayout();
+               layout.numColumns= 2;
+               buttonComposite.setLayout(layout);
+               GridData data= new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL);
+               data.grabExcessHorizontalSpace= true;
+               composite.setData(data);
+
+               // Select All button
+               String label= FilterMessages.CustomFiltersDialog_SelectAllButton_label; 
+               Button selectButton= createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID, label, false);
+               SWTUtil.setButtonDimensionHint(selectButton);
+               SelectionListener listener= new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               fCheckBoxList.setAllChecked(true);
+                               fFilterDescriptorChangeHistory.clear();
+                               for (FilterDescriptor builtInFilter : fBuiltInFilters) {
+                                       fFilterDescriptorChangeHistory.push(builtInFilter);
+                               }
+                       }
+               };
+               selectButton.addSelectionListener(listener);
+
+               // Deselect All button
+               label= FilterMessages.CustomFiltersDialog_DeselectAllButton_label; 
+               Button deselectButton= createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID, label, false);
+               SWTUtil.setButtonDimensionHint(deselectButton);
+               listener= new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               fCheckBoxList.setAllChecked(false);
+                               fFilterDescriptorChangeHistory.clear();
+                               for (FilterDescriptor builtInFilter : fBuiltInFilters)
+                                       fFilterDescriptorChangeHistory.push(builtInFilter);
+                       }
+               };
+               deselectButton.addSelectionListener(listener);
+       }
+
+       private void checkInitialSelections() {
+               Iterator<?> itemsToCheck= getInitialElementSelections().iterator();
+               while (itemsToCheck.hasNext())
+                       fCheckBoxList.setChecked(itemsToCheck.next(),true);
+       }
+
+       @Override
+       protected void okPressed() {
+               if (fBuiltInFilters != null) {
+                       ArrayList<FilterDescriptor> result= new ArrayList<FilterDescriptor>();
+                       for (int i= 0; i < fBuiltInFilters.length; ++i) {
+                               if (fCheckBoxList.getChecked(fBuiltInFilters[i]))
+                                       result.add(fBuiltInFilters[i]);
+                       }
+                       setResult(result);
+               }
+               super.okPressed();
+       }
+       
+       private ILabelProvider createLabelPrivder() {
+               return 
+                       new LabelProvider() {
+                               @Override
+                               public Image getImage(Object element) {
+                                       return null;
+                               }
+                               @Override
+                               public String getText(Object element) {
+                                       if (element instanceof FilterDescriptor)
+                                               return ((FilterDescriptor)element).getName();
+                                       return null;
+                               }
+                       };
+       }
+
+       // ---------- result handling ----------
+       
+       @SuppressWarnings("rawtypes")
+       @Override
+       protected void setResult(List newResult) {
+               super.setResult(newResult);
+               if (fUserDefinedPatterns.getText().length() > 0) {
+                       fEnablePatterns= fEnableUserDefinedPatterns.getSelection();
+                       fPatterns= convertFromString(fUserDefinedPatterns.getText(), SEPARATOR);
+               } else {
+                       fEnablePatterns= false;
+                       fPatterns= new String[0];
+               }                       
+       }
+
+
+       /**
+        * @return the patterns which have been entered by the user
+        */
+       public String[] getUserDefinedPatterns() {
+               return fPatterns;
+       }
+
+       /**
+        * @return the ids of the enabled built-in filters
+        */
+       public String[] getEnabledFilterIds() {
+               Object[] result= getResult();
+               Set<String> enabledIds= new HashSet<String>(result.length);
+               for (Object element : result)
+                       enabledIds.add(((FilterDescriptor)element).getId());
+               return enabledIds.toArray(new String[enabledIds.size()]);
+       }
+
+       /**
+        * @return <code>true</code> if the user-defined patterns are disabled
+        */
+       public boolean areUserDefinedPatternsEnabled() {
+               return fEnablePatterns;
+       }
+       
+       /**
+        * @return a stack with the filter descriptor check history
+        * @since 3.0
+        */
+       public Stack<FilterDescriptor> getFilterDescriptorChangeHistory() {
+               return fFilterDescriptorChangeHistory;
+       }
+
+       private FilterDescriptor[] getEnabledFilterDescriptors() {
+               FilterDescriptor[] filterDescs= fBuiltInFilters;
+               List<FilterDescriptor> result= new ArrayList<FilterDescriptor>(filterDescs.length);
+               List<String> enabledFilterIds= Arrays.asList(fEnabledFilterIds);
+               for (FilterDescriptor filterDesc : filterDescs) {
+                       String id= filterDesc.getId();
+                       if (enabledFilterIds.contains(id))
+                               result.add(filterDesc);
+               }
+               return result.toArray(new FilterDescriptor[result.size()]);
+       }
+
+
+       public static String[] convertFromString(String patterns, String separator) {
+               StringTokenizer tokenizer= new StringTokenizer(patterns, separator);
+               String[] result= new String[tokenizer.countTokens()];
+               for (int i= 0; i < result.length; i++)
+                       result[i]= tokenizer.nextToken().trim();
+               return result;
+       }
+
+       public static String convertToString(String[] patterns, String separator) {
+               int length= patterns.length;
+               StringBuffer strBuf= new StringBuffer();
+               if (length > 0)
+                       strBuf.append(patterns[0]);
+               else
+                       return ""; //$NON-NLS-1$
+               int i= 1;
+               while (i < length) {
+                       strBuf.append(separator);
+                       strBuf.append(" "); //$NON-NLS-1$
+                       strBuf.append(patterns[i++]);
+               }
+               return strBuf.toString();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ExecutableFilter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ExecutableFilter.java
new file mode 100644 (file)
index 0000000..cbe0d9d
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.filters;
+
+import org.eclipse.cdt.core.model.IBinary;
+import org.eclipse.cdt.core.model.IBinaryContainer;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+
+
+/**
+ * The ExecutableFilter is a filter used to determine whether
+ * an executable is shown
+ */
+public class ExecutableFilter extends ViewerFilter {
+       
+       /* (non-Javadoc)
+        * Method declared on ViewerFilter.
+        */
+       @Override
+       public boolean select(Viewer viewer, Object parentElement, Object element) {
+               if (element instanceof IBinary) {
+                       IBinary bin = (IBinary)element;
+                       if (! (parentElement instanceof IBinaryContainer)) {
+                               if (bin.isExecutable()) {
+                                       return false;
+                               }
+                       }
+               }
+               return true;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/FilterDescriptor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/FilterDescriptor.java
new file mode 100644 (file)
index 0000000..711c77b
--- /dev/null
@@ -0,0 +1,265 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.filters;
+
+import com.ibm.icu.text.Collator;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.ISafeRunnable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.util.SafeRunnable;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.osgi.util.NLS;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+
+/**
+ * Represents a custom filter which is provided by the
+ * "org.eclipse.jdt.ui.javaElementFilters" extension point.
+ * 
+ * since 2.0
+ */
+public class FilterDescriptor implements Comparable<FilterDescriptor> {
+
+       private static String PATTERN_FILTER_ID_PREFIX= "_patternFilterId_"; //$NON-NLS-1$
+
+
+       private static final String EXTENSION_POINT_NAME= "CElementFilters"; //$NON-NLS-1$
+
+       private static final String FILTER_TAG= "filter"; //$NON-NLS-1$
+
+       private static final String PATTERN_ATTRIBUTE= "pattern"; //$NON-NLS-1$ 
+       private static final String ID_ATTRIBUTE= "id"; //$NON-NLS-1$
+       /**
+        * @deprecated as of 3.0 use {@link FilterDescriptor#TARGET_ID_ATTRIBUTE}
+        */
+       @Deprecated
+       private static final String VIEW_ID_ATTRIBUTE= "viewId"; //$NON-NLS-1$
+       private static final String TARGET_ID_ATTRIBUTE= "targetId"; //$NON-NLS-1$
+       private static final String CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$
+       private static final String NAME_ATTRIBUTE= "name"; //$NON-NLS-1$
+       private static final String ENABLED_ATTRIBUTE= "enabled"; //$NON-NLS-1$
+       private static final String DESCRIPTION_ATTRIBUTE= "description"; //$NON-NLS-1$ 
+       /**
+        * @deprecated  use "enabled" instead
+        */
+       @Deprecated
+       private static final String SELECTED_ATTRIBUTE= "selected"; //$NON-NLS-1$
+
+       private static FilterDescriptor[] fgFilterDescriptors;
+
+
+       IConfigurationElement fElement;
+
+       /**
+        * Returns all contributed Java element filters.
+        */
+       public static FilterDescriptor[] getFilterDescriptors() {
+               if (fgFilterDescriptors == null) {
+                       IExtensionRegistry registory= Platform.getExtensionRegistry();
+                       IConfigurationElement[] elements= registory.getConfigurationElementsFor(CUIPlugin.PLUGIN_ID, EXTENSION_POINT_NAME);
+                       fgFilterDescriptors= createFilterDescriptors(elements);
+               }       
+               return fgFilterDescriptors;
+       } 
+       /**
+        * Returns all Java element filters which
+        * are contributed to the given view.
+        */
+       public static FilterDescriptor[] getFilterDescriptors(String targetId) {
+               FilterDescriptor[] filterDescs= FilterDescriptor.getFilterDescriptors();
+               List<FilterDescriptor> result= new ArrayList<FilterDescriptor>(filterDescs.length);
+               for (int i= 0; i < filterDescs.length; i++) {
+                       String tid= filterDescs[i].getTargetId();
+                       if (tid == null || tid.equals(targetId))
+                               result.add(filterDescs[i]);
+               }
+               return result.toArray(new FilterDescriptor[result.size()]);
+       }
+       
+       /**
+        * Creates a new filter descriptor for the given configuration element.
+        */
+       FilterDescriptor(IConfigurationElement element) {
+               fElement= element;
+               // it is either a pattern filter or a custom filter
+               Assert.isTrue(isPatternFilter() ^ isCustomFilter(), "An extension for extension-point org.eclipse.cdt.ui.CElementFilters does not specify a correct filter"); //$NON-NLS-1$
+               Assert.isNotNull(getId(), "An extension for extension-point org.eclipse.cdt.ui.CElementFilters does not provide a valid ID"); //$NON-NLS-1$
+               Assert.isNotNull(getName(), "An extension for extension-point org.eclipse.cdt.ui.CElementFilters does not provide a valid name"); //$NON-NLS-1$
+       }
+
+       /**
+        * Creates a new <code>ViewerFilter</code>.
+        * This method is only valid for viewer filters.
+        */
+       public ViewerFilter createViewerFilter() {
+               if (!isCustomFilter())
+                       return null;
+               
+               final ViewerFilter[] result= new ViewerFilter[1];
+               String message= NLS.bind(FilterMessages.FilterDescriptor_filterCreationError_message, getId()); 
+               ISafeRunnable code= new SafeRunnable(message) {
+                       /*
+                        * @see org.eclipse.core.runtime.ISafeRunnable#run()
+                        */
+                       public void run() throws Exception {
+                               result[0]= (ViewerFilter)fElement.createExecutableExtension(CLASS_ATTRIBUTE);
+                       }
+                       
+               };
+               SafeRunnable.run(code);
+               return result[0];
+       }
+       
+       //---- XML Attribute accessors ---------------------------------------------
+       
+       /**
+        * Returns the filter's id.
+        * <p>
+        * This attribute is mandatory for custom filters.
+        * The ID for pattern filters is
+        * PATTERN_FILTER_ID_PREFIX plus the pattern itself.
+        * </p>
+        */
+       public String getId() {
+               if (isPatternFilter()) {
+                       String targetId= getTargetId();
+                       if (targetId == null)
+                               return PATTERN_FILTER_ID_PREFIX + getPattern();
+                       return targetId + PATTERN_FILTER_ID_PREFIX + getPattern();
+               }
+               return fElement.getAttribute(ID_ATTRIBUTE);
+       }
+       
+       /**
+        * Returns the filter's name.
+        * <p>
+        * If the name of a pattern filter is missing
+        * then the pattern is used as its name.
+        * </p>
+        */
+       public String getName() {
+               String name= fElement.getAttribute(NAME_ATTRIBUTE);
+               if (name == null && isPatternFilter())
+                       name= getPattern();
+               return name;
+       }
+
+       /**
+        * Returns the filter's pattern.
+        * 
+        * @return the pattern string or <code>null</code> if it's not a pattern filter
+        */
+       public String getPattern() {
+               return fElement.getAttribute(PATTERN_ATTRIBUTE);
+       }
+
+       /**
+        * Returns the filter's viewId.
+        * 
+        * @return the view ID or <code>null</code> if the filter is for all views
+        * @since 3.0
+        */
+       public String getTargetId() {
+               String tid= fElement.getAttribute(TARGET_ID_ATTRIBUTE);
+               
+               if (tid != null)
+                       return tid;
+               
+               // Backwards compatibility code
+               return fElement.getAttribute(VIEW_ID_ATTRIBUTE);
+               
+       }
+
+       /**
+        * Returns the filter's description.
+        * 
+        * @return the description or <code>null</code> if no description is provided
+        */
+       public String getDescription() {
+               String description= fElement.getAttribute(DESCRIPTION_ATTRIBUTE);
+               if (description == null)
+                       description= ""; //$NON-NLS-1$
+               return description;
+       }
+
+       /**
+        * @return <code>true</code> if this filter is a custom filter.
+        */
+       public boolean isPatternFilter() {
+               return getPattern() != null;
+       }
+
+       /**
+        * @return <code>true</code> if this filter is a pattern filter.
+        */
+       public boolean isCustomFilter() {
+               return fElement.getAttribute(CLASS_ATTRIBUTE) != null;
+       }
+
+       /**
+        * Returns <code>true</code> if the filter
+        * is initially enabled.
+        * 
+        * This attribute is optional and defaults to <code>true</code>.
+        */
+       public boolean isEnabled() {
+               String strVal= fElement.getAttribute(ENABLED_ATTRIBUTE);
+               if (strVal == null)
+                       // backward compatibility
+                       strVal= fElement.getAttribute(SELECTED_ATTRIBUTE);
+               return strVal == null || Boolean.valueOf(strVal).booleanValue();
+       }
+
+       /* 
+        * Implements a method from IComparable 
+        */ 
+       public int compareTo(FilterDescriptor o) {
+               return Collator.getInstance().compare(getName(), (o).getName());
+       }
+
+       //---- initialization ---------------------------------------------------
+       
+       /**
+        * Creates the filter descriptors.
+        */
+       private static FilterDescriptor[] createFilterDescriptors(IConfigurationElement[] elements) {
+               List<FilterDescriptor> result= new ArrayList<FilterDescriptor>(5);
+               Set<String> descIds= new HashSet<String>(5);
+               for (int i= 0; i < elements.length; i++) {
+                       final IConfigurationElement element= elements[i];
+                       if (FILTER_TAG.equals(element.getName())) {
+
+                               final FilterDescriptor[] desc= new FilterDescriptor[1];
+                               SafeRunnable.run(new SafeRunnable(FilterMessages.FilterDescriptor_filterDescriptionCreationError_message) { 
+                                       public void run() throws Exception {
+                                               desc[0]= new FilterDescriptor(element);
+                                       }
+                               });
+
+                               if (desc[0] != null && !descIds.contains(desc[0].getId())) {
+                                       result.add(desc[0]);
+                                       descIds.add(desc[0].getId());
+                               }
+                       }
+               }
+               Collections.sort(result);
+               return result.toArray(new FilterDescriptor[result.size()]);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/FilterMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/FilterMessages.java
new file mode 100644 (file)
index 0000000..9a015aa
--- /dev/null
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.filters;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class FilterMessages extends NLS {
+
+       private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.filters.FilterMessages";//$NON-NLS-1$
+
+       private FilterMessages() {
+               // Do not instantiate
+       }
+
+       public static String CustomFiltersDialog_title;
+       public static String CustomFiltersDialog_patternInfo;
+       public static String CustomFiltersDialog_enableUserDefinedPattern;
+       public static String CustomFiltersDialog_filterList_label;
+       public static String CustomFiltersDialog_description_label;
+       public static String CustomFiltersDialog_SelectAllButton_label;
+       public static String CustomFiltersDialog_DeselectAllButton_label;
+       public static String OpenCustomFiltersDialogAction_text;
+       public static String FilterDescriptor_filterDescriptionCreationError_message;
+       public static String FilterDescriptor_filterCreationError_message;
+
+       static {
+               NLS.initializeMessages(BUNDLE_NAME, FilterMessages.class);
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/FilterMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/FilterMessages.properties
new file mode 100644 (file)
index 0000000..68019c4
--- /dev/null
@@ -0,0 +1,24 @@
+###############################################################################
+# Copyright (c) 2000, 2008 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+#     Anton Leherbauer (Wind River Systems)
+###############################################################################
+
+CustomFiltersDialog_title= C Element Filters
+CustomFiltersDialog_patternInfo= The patterns are separated by comma (* = any string, ? = any character)
+CustomFiltersDialog_enableUserDefinedPattern= &Name filter patterns (matching names will be hidden):
+CustomFiltersDialog_filterList_label= S&elect the elements to exclude from the view:
+CustomFiltersDialog_description_label= Filter description:
+CustomFiltersDialog_SelectAllButton_label= &Select All
+CustomFiltersDialog_DeselectAllButton_label= &Deselect All
+
+OpenCustomFiltersDialogAction_text= &Filters...
+
+FilterDescriptor_filterDescriptionCreationError_message= One of the extensions for extension-point org.eclipse.cdt.ui.CElementFilters is incorrect.
+FilterDescriptor_filterCreationError_message= The org.eclipse.cdt.ui.CElementFilters plug-in extension "{0}" specifies a viewer filter class which does not exist.
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ForwardDeclarationFilter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ForwardDeclarationFilter.java
new file mode 100644 (file)
index 0000000..4fef712
--- /dev/null
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Eclipse CDT Project and others 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Patrick Hofer - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.filters;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+/**
+ * Filter for forward declarations
+ */
+public class ForwardDeclarationFilter extends ViewerFilter {
+
+       /*
+        * @see ViewerFilter
+        */
+       @Override
+       public boolean select(Viewer viewer, Object parent, Object element) {
+               if (!(element instanceof ICElement)) 
+                       return true;
+               
+               final ICElement celem= (ICElement) element;
+               ICElement tu= celem;
+               while (tu != null && !(tu instanceof ITranslationUnit)) {
+                       tu= tu.getParent();
+               }
+               
+               // Don't filter forward declarations in header file
+               if (tu instanceof ITranslationUnit && ((ITranslationUnit) tu).isHeaderUnit())
+                       return true;
+
+               switch (celem.getElementType()) {
+               case ICElement.C_FUNCTION_DECLARATION:
+               case ICElement.C_TEMPLATE_FUNCTION_DECLARATION:
+                       
+               case ICElement.C_STRUCT_DECLARATION:
+               case ICElement.C_UNION_DECLARATION:
+               case ICElement.C_CLASS_DECLARATION:
+               case ICElement.C_TEMPLATE_CLASS_DECLARATION:
+               case ICElement.C_TEMPLATE_STRUCT_DECLARATION:
+               case ICElement.C_TEMPLATE_UNION_DECLARATION:
+                       
+               case ICElement.C_VARIABLE_DECLARATION:
+                       return false;
+               }
+               
+               return true;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/MacroDirectiveFilter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/MacroDirectiveFilter.java
new file mode 100644 (file)
index 0000000..caa7a4e
--- /dev/null
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.filters;
+
+import org.eclipse.cdt.core.model.IMacro;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+/**
+ * Filter
+ */
+public class MacroDirectiveFilter extends ViewerFilter {
+
+       /*
+        * @see ViewerFilter
+        */
+       @Override
+       public boolean select(Viewer viewer, Object parent, Object element) {
+               return !(element instanceof IMacro);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/NamePatternFilter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/NamePatternFilter.java
new file mode 100644 (file)
index 0000000..7caba73
--- /dev/null
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.filters;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.internal.ui.util.StringMatcher;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+/**
+ * The NamePatternFilter selects the elements which
+ * match the given string patterns.
+ * <p>
+ * The following characters have special meaning:
+ *   ? => any character
+ *   * => any string
+ * </p>
+ * 
+ * @since 2.0
+ */
+public class NamePatternFilter extends ViewerFilter {
+       private String[] fPatterns;
+       private StringMatcher[] fMatchers;
+       
+       /**
+        * Return the currently configured StringMatchers.
+        */
+       private StringMatcher[] getMatchers() {
+               return fMatchers;
+       }
+       
+       /**
+        * Gets the patterns for the receiver.
+        */
+       public String[] getPatterns() {
+               return fPatterns;
+       }
+       
+       
+       /* (non-Javadoc)
+        * Method declared on ViewerFilter.
+        */
+       @Override
+       public boolean select(Viewer viewer, Object parentElement, Object element) {
+               String matchName= null;
+               if (element instanceof ICElement) {
+                       matchName= ((ICElement) element).getElementName();
+               } else if (element instanceof IAdaptable) {
+                       IAdaptable adaptable= (IAdaptable) element;
+                       ICElement javaElement= (ICElement)adaptable.getAdapter(ICElement.class);
+                       if (javaElement != null)
+                               matchName= javaElement.getElementName();
+                       else {
+                               IResource resource= (IResource)adaptable.getAdapter(IResource.class);
+                               if (resource != null)
+                                       matchName= resource.getName();
+                       }
+               }
+               if (matchName != null) {
+                       StringMatcher[] testMatchers= getMatchers();
+                       for (int i = 0; i < testMatchers.length; i++) {
+                               if (testMatchers[i].match(matchName))
+                                       return false;
+                       }
+                       return true;
+               }
+               return true;
+       }
+       
+       /**
+        * Sets the patterns to filter out for the receiver.
+        * <p>
+        * The following characters have special meaning:
+        *   ? => any character
+        *   * => any string
+        * </p>
+        */
+       public void setPatterns(String[] newPatterns) {
+               fPatterns = newPatterns;
+               fMatchers = new StringMatcher[newPatterns.length];
+               for (int i = 0; i < newPatterns.length; i++) {
+                       //Reset the matchers to prevent constructor overhead
+                       fMatchers[i]= new StringMatcher(newPatterns[i], true, false);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/NonCElementFilter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/NonCElementFilter.java
new file mode 100644 (file)
index 0000000..10d4b9a
--- /dev/null
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.filters;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IStorage;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+
+
+/**
+ * Filters out all non-C elements.
+ */
+public class NonCElementFilter  extends ViewerFilter {
+       
+       /**
+        * Returns the result of this filter, when applied to the
+        * given inputs.
+        *
+        * @return Returns true if element should be included in filtered set
+        */
+       @Override
+       public boolean select(Viewer viewer, Object parent, Object element) {
+               if (element instanceof ICElement)
+                       return true;
+
+               if (element instanceof IProject) {
+                       IProject project = (IProject)element;
+                       if (!project.isOpen() || CoreModel.hasCNature(project)) {
+                               return true;
+                       }
+                       return false;
+               } else if (element instanceof IResource) {
+                       IProject project= ((IResource)element).getProject();
+                       return project == null || !project.isOpen();
+               }
+
+               // Exclude all IStorage elements which are neither C elements nor resources
+               if (element instanceof IStorage)
+                       return false;
+                       
+               return true;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/NonCProjectsFilter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/NonCProjectsFilter.java
new file mode 100644 (file)
index 0000000..8b49664
--- /dev/null
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.filters;
+
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICProject;
+
+
+/**
+ * Filters (open) non-C projects.
+ */
+public class NonCProjectsFilter extends ViewerFilter {
+
+       /*
+        * @see ViewerFilter
+        */
+       @Override
+       public boolean select(Viewer viewer, Object parent, Object element) {
+               if (element instanceof ICProject) {
+                       return true;
+               } else if (element instanceof IProject) {
+                       IProject project = (IProject)element;
+                       if (!project.isOpen()) {
+                               return true;
+                       }
+                       if (CoreModel.hasCNature(project)) {
+                               return true;
+                       }
+                       return false;
+               }
+               return true;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ObjectFilter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/ObjectFilter.java
new file mode 100644 (file)
index 0000000..bace0a9
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.filters;
+
+import org.eclipse.cdt.core.model.IBinary;
+import org.eclipse.cdt.core.model.IBinaryContainer;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+
+
+/**
+ * The ObjectFilter is a filter used to determine whether
+ * a Object is shown
+ */
+public class ObjectFilter extends ViewerFilter {
+       
+       /* (non-Javadoc)
+        * Method declared on ViewerFilter.
+        */
+       @Override
+       public boolean select(Viewer viewer, Object parentElement, Object element) {
+               if (element instanceof IBinary) {
+                       IBinary bin = (IBinary)element;
+                       if (! (parentElement instanceof IBinaryContainer)) {
+                               if (bin.isObject()) {
+                                       return false;
+                               }
+                       }
+               }
+               return true;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/SharedFilter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/SharedFilter.java
new file mode 100644 (file)
index 0000000..419743e
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.filters;
+
+import org.eclipse.cdt.core.model.IBinary;
+import org.eclipse.cdt.core.model.IBinaryContainer;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+
+
+/**
+ * The SharedFilter is a filter used to determine whether
+ * a Shared object is shown
+ */
+public class SharedFilter extends ViewerFilter {
+       
+       /* (non-Javadoc)
+        * Method declared on ViewerFilter.
+        */
+       @Override
+       public boolean select(Viewer viewer, Object parentElement, Object element) {
+               if (element instanceof IBinary) {
+                       IBinary bin = (IBinary)element;
+                       if (! (parentElement instanceof IBinaryContainer)) {
+                               if (bin.isSharedLib()) {
+                                       return false;
+                               }
+                       }
+               }
+               return true;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/UsingDirectiveFilter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/UsingDirectiveFilter.java
new file mode 100644 (file)
index 0000000..be21b9f
--- /dev/null
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.filters;
+
+import org.eclipse.cdt.core.model.IUsing;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+/**
+ * Filters package declarations
+ */
+public class UsingDirectiveFilter extends ViewerFilter {
+
+       /*
+        * @see ViewerFilter
+        */
+       @Override
+       public boolean select(Viewer viewer, Object parent, Object element) {
+               return !(element instanceof IUsing);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CFunctionSummary.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CFunctionSummary.java
new file mode 100644 (file)
index 0000000..92f4448
--- /dev/null
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.help;
+
+import java.util.ArrayList;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import org.eclipse.cdt.ui.FunctionPrototypeSummary;
+import org.eclipse.cdt.ui.IFunctionSummary;
+import org.eclipse.cdt.ui.IRequiredInclude;
+
+public class CFunctionSummary implements IFunctionSummary {
+       private static final String ATTR_STD = "standard"; //$NON-NLS-1$
+       private static final String NODE_NAME = "name"; //$NON-NLS-1$
+       private static final String NODE_DESC = "description"; //$NON-NLS-1$
+       private static final String NODE_INCL = "include"; //$NON-NLS-1$
+       private static final String NODE_TYPE = "returnType"; //$NON-NLS-1$
+       private static final String NODE_ARGS = "arguments"; //$NON-NLS-1$
+
+       private static final String SP = " "; //$NON-NLS-1$
+       private static final String LB = "("; //$NON-NLS-1$
+       private static final String RB = ")"; //$NON-NLS-1$
+       
+       private String name = null;
+       private String desc = null;
+       private IRequiredInclude[] incs = null;
+       IFunctionPrototypeSummary fps = null;
+       
+       public CFunctionSummary(Element e, String defName) {
+               name = defName; // if there's no "name" tag, keyword used instead
+               String args = null;
+               String type = null;
+               NodeList list = e.getChildNodes();
+               ArrayList<IRequiredInclude> incList = new ArrayList<IRequiredInclude>();
+               for(int j = 0; j < list.getLength(); j++){
+                       Node node = list.item(j);
+                       if(node.getNodeType() != Node.ELEMENT_NODE)     
+                               continue;
+                       String s = node.getNodeName().trim();
+                       String t = node.getFirstChild().getNodeValue().trim();
+                       if(NODE_NAME.equals(s)){
+                               name = t;
+                       } else if(NODE_DESC.equals(s)){
+                               desc = t;
+                       } else if(NODE_ARGS.equals(s)){
+                               args = t;
+                       } else if(NODE_TYPE.equals(s)){
+                               type = t;
+                       } else if(NODE_INCL.equals(s)){
+                               boolean std = true;
+                               if (((Element)node).hasAttribute(ATTR_STD)) {
+                                       String st = ((Element)node).getAttribute(ATTR_STD);
+                                       std = (st == null  || st.equalsIgnoreCase("true") //$NON-NLS-1$
+                                                       || st.equalsIgnoreCase("yes"));           //$NON-NLS-1$
+                               }
+                               incList.add(new RequiredInclude(t, std));
+                       }
+               }
+               if (incList.size() > 0) 
+                       incs = incList.toArray(new IRequiredInclude[incList.size()]);
+               fps = new FunctionPrototypeSummary(type + SP + name + LB + args + RB);  
+       }
+       
+       public String getDescription() {
+               return desc;
+       }
+       public IRequiredInclude[] getIncludes() { 
+               return incs; 
+       }
+       public String getName() {
+               return name;
+       }
+       public String getNamespace() {
+               return null;
+       }
+       public IFunctionPrototypeSummary getPrototype() {
+               return fps;
+       }
+       
+       /**
+        * This class implements IRequiredInclude interface 
+        */
+       private class RequiredInclude implements IRequiredInclude {
+               private String iname;
+               private boolean std;
+               
+               private RequiredInclude(String s, boolean b) {
+                       iname = s;
+                       std = b;
+               }
+               public String getIncludeName() {
+                       return iname;
+               }
+               public boolean isStandard() {
+                       return std;
+               }
+               @Override
+               public String toString() {
+                       if (std) 
+                               return "#include <" + iname + ">";   //$NON-NLS-1$ //$NON-NLS-2$
+                       return "#include \"" + iname + "\""; //$NON-NLS-1$ //$NON-NLS-2$
+               }               
+       }
+       @Override
+       public String toString() {
+               return "<functionSummary> : " + getPrototype().getPrototypeString(false); //$NON-NLS-1$
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpBook.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpBook.java
new file mode 100644 (file)
index 0000000..385a8e7
--- /dev/null
@@ -0,0 +1,171 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.help;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import org.eclipse.help.IHelpResource;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import org.eclipse.cdt.ui.ICHelpBook;
+import org.eclipse.cdt.ui.ICHelpResourceDescriptor;
+import org.eclipse.cdt.ui.IFunctionSummary;
+import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
+
+public class CHelpBook implements ICHelpBook {
+       private static final String ATTR_TITLE = "title"; //$NON-NLS-1$
+       private static final String ATTR_BTYPE = "type";  //$NON-NLS-1$
+       private static final String NODE_ENTRY = "entry"; //$NON-NLS-1$
+       private static final String TYPE_C   = "HELP_TYPE_C"; //$NON-NLS-1$
+       private static final String TYPE_CPP = "HELP_TYPE_CPP"; //$NON-NLS-1$
+       private static final String TYPE_ASM = "HELP_TYPE_ASM"; //$NON-NLS-1$
+       private static final int DEFAULT_VAL  = ICHelpBook.HELP_TYPE_C;
+
+       private int type;
+       private String title;
+       private TreeMap<String, CHelpEntry> entries; 
+       
+       public CHelpBook(Element e) {
+               entries = new TreeMap<String, CHelpEntry>();
+
+               if (e.hasAttribute(ATTR_TITLE))
+                       title = e.getAttribute(ATTR_TITLE).trim();
+               if (e.hasAttribute(ATTR_BTYPE)) {
+                       String s = e.getAttribute(ATTR_BTYPE);
+                       try {
+                               type = Integer.parseInt(s);
+                               if (type < DEFAULT_VAL ||
+                                       type > ICHelpBook.HELP_TYPE_ASM)
+                                       type = DEFAULT_VAL;
+                       } catch (NumberFormatException ee) {
+                               if (TYPE_C.equalsIgnoreCase(s))
+                                       type = ICHelpBook.HELP_TYPE_C;
+                               else if (TYPE_CPP.equalsIgnoreCase(s))
+                                       type = ICHelpBook.HELP_TYPE_CPP;
+                               else if (TYPE_ASM.equalsIgnoreCase(s))
+                                       type = ICHelpBook.HELP_TYPE_ASM;
+                               else
+                                       type = DEFAULT_VAL;
+                       }
+               }
+               NodeList list = e.getChildNodes();
+               for(int i = 0; i < list.getLength(); i++){
+                       Node node = list.item(i);
+                       if(node.getNodeType() != Node.ELEMENT_NODE)     continue;
+                       if(NODE_ENTRY.equals(node.getNodeName())) {
+                               CHelpEntry he = new CHelpEntry((Element)node);
+                               if (he.isValid()) 
+                                       entries.put(he.getKeyword(), he);
+                       }
+               }
+       }
+       
+       public int getCHelpType() {
+               return type;
+       }
+       
+       public String getTitle() {
+               return title;
+       }
+       
+       public IFunctionSummary getFunctionInfo(
+                       ICHelpInvocationContext context,
+                       String name) {
+               
+               if (entries.containsKey(name)) {
+                       CHelpEntry he = entries.get(name);
+                       IFunctionSummary[] fs = he.getFunctionSummary();
+                       if (fs != null && fs.length > 0)
+                               return fs[0]; 
+               }
+               return null;
+       }
+       
+       /**
+        * Temporary implementation with slow search
+        * @param context
+        * @param prefix
+        * @return matching functions
+        */
+       public List<IFunctionSummary> getMatchingFunctions(
+                       ICHelpInvocationContext context,
+                       String prefix) {
+               
+               Collection<CHelpEntry> col = null;
+               if (prefix == null || prefix.trim().length() == 0) {
+                       // return whole data
+                       col = entries.values();
+               } else {
+                       String pr1 = prefix.trim();
+                       byte[] bs = pr1.getBytes();
+                       int i = bs.length - 1;
+                       while (i >= 0) {
+                          byte b = bs[i];
+                          if (++b > bs[i]) { // no overflow
+                                  bs[i] = b;
+                                  break;
+                          }
+                          i--;
+                       }
+                       SortedMap<String, CHelpEntry> sm = (i>-1) ?
+                               entries.subMap(pr1, new String(bs)) :
+                               entries.tailMap(pr1);
+                       col = sm.values();      
+               }
+                               
+               if (col.size() > 0) {
+                       ArrayList<IFunctionSummary> out = new ArrayList<IFunctionSummary>(col.size());
+                       for (CHelpEntry he: col) 
+                               for (IFunctionSummary fs : he.getFunctionSummary())
+                                       out.add(fs);
+                       return out;
+               }
+               return null;
+       }
+
+       public ICHelpResourceDescriptor getHelpResources(
+                       ICHelpInvocationContext context, String name) {
+               if (entries.containsKey(name)) {
+                       CHelpEntry he = entries.get(name);
+                       IHelpResource[] hr = he.getHelpResource();
+                       if (hr != null && hr.length > 0)
+                               return new HRDescriptor(this, hr); 
+               }
+               return null;
+       }
+       
+       private class HRDescriptor implements ICHelpResourceDescriptor {
+               private ICHelpBook book;
+               private IHelpResource[] res;
+               HRDescriptor(ICHelpBook _book, IHelpResource[] _res) {
+                       book = _book;
+                       res  = _res;
+               }
+               public ICHelpBook getCHelpBook() {
+                       return book;
+               }
+               public IHelpResource[] getHelpResources() {
+                       return res;
+               }
+       }
+
+       @Override
+       public String toString() {
+               return "<helpBook title=\"" +title +"\" type=\"" + type + "\">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpEntry.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpEntry.java
new file mode 100644 (file)
index 0000000..5a4156d
--- /dev/null
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.help;
+
+import java.util.ArrayList;
+
+import org.eclipse.help.IHelpResource;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import org.eclipse.cdt.ui.IFunctionSummary;
+
+public class CHelpEntry {
+       private static final String ATTR_KEYWD = "keyword"; //$NON-NLS-1$
+       private static final String NODE_TOPIC = "topic"; //$NON-NLS-1$
+       private static final String NODE_FSUMM = "functionSummary"; //$NON-NLS-1$
+
+       private String keyword = null;
+       private boolean isValid = true;
+       private CHelpTopic[] hts = null;
+       private CFunctionSummary[] fss = null;
+       
+       public CHelpEntry(Element e) {
+               keyword = e.getAttribute(ATTR_KEYWD).trim();
+               ArrayList<CFunctionSummary> obs1 = new ArrayList<CFunctionSummary>();
+               ArrayList<CHelpTopic> obs2 = new ArrayList<CHelpTopic>();
+               NodeList list = e.getChildNodes();
+               for(int i = 0; i < list.getLength(); i++){
+                       Node node = list.item(i);
+                       if (node.getNodeType() != Node.ELEMENT_NODE)
+                               continue;
+                       if (NODE_FSUMM.equals(node.getNodeName())){
+                               obs1.add(new CFunctionSummary((Element)node, keyword));
+                       } else if (NODE_TOPIC.equals(node.getNodeName())) {
+                               obs2.add(new CHelpTopic((Element)node, keyword));
+                       }
+               }
+               fss = obs1.toArray(new CFunctionSummary[obs1.size()]);
+               hts = obs2.toArray(new CHelpTopic[obs2.size()]);
+               
+               if (fss.length == 0 && hts.length == 0)
+                       isValid = false; // nothing to display
+       }
+
+       /**
+        * Returns true if help entry is correct
+        * Returns false if entry is empty or when 
+        *   subsequent processing failed somehow. 
+        * @return entry state
+        */
+       public boolean isValid() {
+               return isValid;
+       }
+       public String getKeyword() {
+               return keyword;
+       }
+       public IFunctionSummary[] getFunctionSummary() {
+               return fss;
+       }
+       public IHelpResource[] getHelpResource() {
+               return hts;
+       }
+       @Override
+       public String toString() {
+               return "<entry keyword=\"" + keyword + "\">"; //$NON-NLS-1$ //$NON-NLS-2$
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpProvider.java
new file mode 100644 (file)
index 0000000..cd325f0
--- /dev/null
@@ -0,0 +1,188 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.help;
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import org.eclipse.cdt.ui.ICHelpBook;
+import org.eclipse.cdt.ui.ICHelpProvider;
+import org.eclipse.cdt.ui.ICHelpResourceDescriptor;
+import org.eclipse.cdt.ui.IFunctionSummary;
+import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
+
+public class CHelpProvider implements ICHelpProvider {
+
+       private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.ui.HelpInfo"; //$NON-NLS-1$
+       private static final String ELEMENT_NAME  = "helpInfo"; //$NON-NLS-1$
+       private static final String ATTRIB_FILE   = "file"; //$NON-NLS-1$
+       private static final String NODE_HEAD = "documentation"; //$NON-NLS-1$
+       private static final String NODE_BOOK = "helpBook"; //$NON-NLS-1$
+
+       private boolean Done = false;
+       
+       ICHelpBook[] hbs = null;
+       
+       public ICHelpBook[] getCHelpBooks() {
+               waitForDone();
+               return hbs;
+       }
+
+       public IFunctionSummary getFunctionInfo(
+                       ICHelpInvocationContext context,
+                       ICHelpBook[] helpBooks, 
+                       String name) {
+               for (int i=0; i<helpBooks.length; i++) {
+                       if (helpBooks[i] instanceof CHelpBook) {
+                               IFunctionSummary fs = ((CHelpBook)helpBooks[i]).getFunctionInfo(context, name);
+                               if (fs != null) // if null, try with another book
+                                       return fs;
+                       }
+               }
+               return null;
+       }
+
+       public ICHelpResourceDescriptor[] getHelpResources(
+                       ICHelpInvocationContext context, ICHelpBook[] helpBooks, String name) {
+
+               ArrayList<ICHelpResourceDescriptor> lst = new ArrayList<ICHelpResourceDescriptor>();
+               for (ICHelpBook h : helpBooks) {
+                       if (h instanceof CHelpBook) {
+                               ICHelpResourceDescriptor hrd = 
+                                       ((CHelpBook)h).getHelpResources(context, name);
+                               if (hrd != null)
+                                       lst.add(hrd);
+                       }
+               }
+               if (lst.size() > 0)
+                       return lst.toArray(new ICHelpResourceDescriptor[lst.size()]);
+               return null;
+       }
+
+       public IFunctionSummary[] getMatchingFunctions(
+                       ICHelpInvocationContext context, ICHelpBook[] helpBooks,
+                       String prefix) {
+               ArrayList<IFunctionSummary> lst = new ArrayList<IFunctionSummary>();
+               for (int i=0; i<helpBooks.length; i++) {
+                       if (helpBooks[i] instanceof CHelpBook) {
+                               List<IFunctionSummary> fs = ((CHelpBook)helpBooks[i]).getMatchingFunctions(context, prefix);
+                               if (fs != null) // if null, try with another book
+                                       lst.addAll(fs);
+                       }
+               }
+               if (lst.size() > 0)
+                       return lst.toArray(new IFunctionSummary[lst.size()]);
+               return null;
+       }
+
+       public void initialize() {
+//             (new Thread() {
+//             public void run() {
+                       loadExtensions();
+//               }
+//         }).run();
+       }
+
+       private void waitForDone() {
+               if (hbs != null)
+                       return;
+               try {
+                       while (! Done ) Thread.sleep(10);
+               } catch (InterruptedException e) {}
+       }
+       
+       private void loadExtensions()
+       {
+               try {
+                       IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
+                       .getExtensionPoint(EXTENSION_POINT_ID);
+                       if (extensionPoint != null) {
+                               IExtension[] extensions = extensionPoint.getExtensions();
+                               if (extensions != null) {
+                                       ArrayList<ICHelpBook> chbl = new ArrayList<ICHelpBook>();
+                                       for (IExtension ex: extensions) {
+                                               String pluginId = ex.getNamespaceIdentifier();                  
+                                               for (IConfigurationElement el : ex.getConfigurationElements()) {
+                                                       if (el.getName().equals(ELEMENT_NAME)) {
+                                                               loadFile(el, chbl, pluginId);
+                                                       }
+                                               }
+                                       }
+                                       if (chbl.size() > 0) {
+                                               hbs = chbl.toArray(new ICHelpBook[chbl.size()]);
+                                       }
+                               }
+                       }
+               } finally {
+                       Done = true;
+               }
+       }
+       
+       private void loadFile(IConfigurationElement el, ArrayList<ICHelpBook> chbl, String pluginId) {
+               String fname = el.getAttribute(ATTRIB_FILE);
+               if (fname == null || fname.trim().length() == 0) return;
+               URL x = FileLocator.find(Platform.getBundle(pluginId), new Path(fname), null);
+               if (x == null) return;
+               try { x = FileLocator.toFileURL(x);
+               } catch (IOException e) { return; }
+               fname = x.getPath();
+               if (fname == null || fname.trim().length() == 0) return;
+
+               // format is not supported for now 
+               // String format = el.getAttribute(ATTRIB_FORMAT);
+               
+               Document doc = null;
+               try {
+                       InputStream stream = new FileInputStream(fname);
+                       BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
+                       InputSource src = new InputSource(reader);
+                       DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+                       doc = builder.parse(src);
+                       Element e = doc.getDocumentElement();
+                       if(NODE_HEAD.equals(e.getNodeName())){
+                               NodeList list = e.getChildNodes();
+                               for(int j = 0; j < list.getLength(); j++){
+                                       Node node = list.item(j);
+                                       if(node.getNodeType() != Node.ELEMENT_NODE)     continue;
+                                       if(NODE_BOOK.equals(node.getNodeName())){
+                                               chbl.add(new CHelpBook((Element)node));
+                                       }
+                               }
+                       }
+               } catch (ParserConfigurationException e) {
+               } catch (SAXException e) {
+               } catch (IOException e) {
+               }
+       }       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpTopic.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/help/CHelpTopic.java
new file mode 100644 (file)
index 0000000..854f9be
--- /dev/null
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.help;
+
+import org.eclipse.help.IHelpResource;
+import org.w3c.dom.Element;
+
+public class CHelpTopic implements IHelpResource {
+       private static final String ATTR_TITLE = "title"; //$NON-NLS-1$
+       private static final String ATTR_HREF  = "href"; //$NON-NLS-1$
+
+       private String href = null;
+       private String title = null;
+       
+       public CHelpTopic(Element e, String defTitle) {
+               href  = e.getAttribute(ATTR_HREF).trim();
+               title = e.getAttribute(ATTR_TITLE).trim();
+               if (title == null || title.length() == 0)
+                       title = defTitle;
+       }
+       public String getHref() {
+               return href;
+       }
+       public String getLabel() {
+               return title;
+       }
+       @Override
+       public String toString() {
+               return "<topic href=\"" + href + "\" title=\"" + title + "\">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBContentProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBContentProvider.java
new file mode 100644 (file)
index 0000000..fe3b332
--- /dev/null
@@ -0,0 +1,214 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.includebrowser;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexFile;
+import org.eclipse.cdt.core.index.IIndexFileLocation;
+import org.eclipse.cdt.core.index.IIndexInclude;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.viewsupport.AsyncTreeContentProvider;
+
+/** 
+ * This is the content provider for the include browser.
+ */
+public class IBContentProvider extends AsyncTreeContentProvider {
+
+       private static final IProgressMonitor NPM = new NullProgressMonitor();
+       private boolean fComputeIncludedBy = true;
+
+       /**
+        * Constructs the content provider.
+        */
+       public IBContentProvider(Display disp) {
+               super(disp);
+       }
+
+       @Override
+       public Object getParent(Object element) {
+               if (element instanceof IBNode) {
+                       IBNode node = (IBNode) element;
+                       return node.getParent();
+               }
+               return super.getParent(element);
+       }
+
+       @Override
+       protected Object[] syncronouslyComputeChildren(Object parentElement) {
+               if (parentElement instanceof ITranslationUnit) {
+                       ITranslationUnit tu = (ITranslationUnit) parentElement;
+                       return new Object[] { new IBNode(null, new IBFile(tu), null, 0, 0, 0) };
+               }
+               if (parentElement instanceof IBNode) {
+                       IBNode node = (IBNode) parentElement;
+                       if (node.isRecursive() || node.getRepresentedIFL() == null) {
+                               return NO_CHILDREN;
+                       }
+               }
+               // allow for async computation
+               return null;
+       }
+
+       @Override
+       protected Object[] asyncronouslyComputeChildren(Object parentElement, IProgressMonitor monitor) {
+               if (parentElement instanceof IBNode) {
+                       IBNode node = (IBNode) parentElement;
+                       IIndexFileLocation ifl= node.getRepresentedIFL();
+                       ICProject project= node.getCProject();
+                       if (ifl == null) {
+                               return NO_CHILDREN;
+                       }
+                       
+                       IIndex index;
+                       try {
+                               ICProject[] scope= CoreModel.getDefault().getCModel().getCProjects();
+                               index= CCorePlugin.getIndexManager().getIndex(scope);
+                               index.acquireReadLock();
+                       } catch (CoreException e) {
+                               CUIPlugin.log(e);
+                               return NO_CHILDREN;
+                       } catch (InterruptedException e) {
+                               return NO_CHILDREN;
+                       }
+                       
+                       try {
+                               IBFile directiveFile= null;
+                               IBFile targetFile= null;
+                               IIndexInclude[] includes;
+                               if (fComputeIncludedBy) {
+                                       includes= findIncludedBy(index, ifl, NPM);
+                               }
+                               else {
+                                       includes= findIncludesTo(index, ifl, NPM);
+                                       directiveFile= node.getRepresentedFile();
+                               }
+                               if (includes.length > 0) {
+                                       ArrayList<IBNode> result= new ArrayList<IBNode>(includes.length);
+                                       for (int i = 0; i < includes.length; i++) {
+                                               IIndexInclude include = includes[i];
+                                               try {
+                                                       if (fComputeIncludedBy) {
+                                                               directiveFile= targetFile= new IBFile(project, include.getIncludedByLocation());
+                                                       }
+                                                       else {
+                                                               IIndexFileLocation includesPath= include.getIncludesLocation();
+                                                               if (includesPath == null) {
+                                                                       targetFile= new IBFile(include.getFullName());
+                                                               }
+                                                               else {
+                                                                       targetFile= new IBFile(project, includesPath);
+                                                               }
+                                                       }
+                                                       IBNode newnode= new IBNode(node, targetFile, directiveFile, 
+                                                                       include.getNameOffset(), 
+                                                                       include.getNameLength(), 
+                                                                       include.getIncludedBy().getTimestamp());
+                                                       newnode.setIsActiveCode(include.isActive());
+                                                       newnode.setIsSystemInclude(include.isSystemInclude());
+                                                       result.add(newnode);
+                                               }
+                                               catch (CoreException e) {
+                                                       CUIPlugin.log(e);
+                                               }
+                                       }
+
+                                       return result.toArray();
+                               }
+                       }
+                       finally {
+                               index.releaseReadLock();
+                       }
+               }
+               return NO_CHILDREN;
+       }
+
+       
+       
+       public void setComputeIncludedBy(boolean value) {
+               fComputeIncludedBy = value;
+       }
+
+       public boolean getComputeIncludedBy() {
+               return fComputeIncludedBy;
+       }
+       
+       
+       private IIndexInclude[] findIncludedBy(IIndex index, IIndexFileLocation ifl, IProgressMonitor pm) {
+               try {
+                       if (ifl != null) {
+                               IIndexFile[] files= index.getFiles(ifl);
+                               if (files.length == 1) {
+                                       return index.findIncludedBy(files[0]);
+                               }
+                               if (files.length > 0) {
+                                       ArrayList<IIndexInclude> list= new ArrayList<IIndexInclude>();
+                                       HashSet<IIndexFileLocation> handled= new HashSet<IIndexFileLocation>();
+                                       for (int i = 0; i < files.length; i++) {
+                                               final IIndexInclude[] includes = index.findIncludedBy(files[i]);
+                                               for (int j = 0; j < includes.length; j++) {
+                                                       IIndexInclude indexInclude = includes[j];
+                                                       if (handled.add(indexInclude.getIncludedByLocation())) {
+                                                               list.add(indexInclude);
+                                                       }
+                                               }
+                                       }
+                                       return list.toArray(new IIndexInclude[list.size()]);
+                               }
+                       }
+               }
+               catch (CoreException e) {
+                       CUIPlugin.log(e);
+               } 
+               return new IIndexInclude[0];
+       }
+
+       public IIndexInclude[] findIncludesTo(IIndex index, IIndexFileLocation ifl, IProgressMonitor pm) {
+               try {
+                       if (ifl != null) {
+                               IIndexFile[] files= index.getFiles(ifl);
+                               if (files.length == 1) {
+                                       return index.findIncludes(files[0]);
+                               }
+                               if (files.length > 0) {
+                                       ArrayList<IIndexInclude> list= new ArrayList<IIndexInclude>();
+                                       HashSet<IIndexFileLocation> handled= new HashSet<IIndexFileLocation>();
+                                       for (int i = 0; i < files.length; i++) {
+                                               final IIndexInclude[] includes = index.findIncludes(files[i]);
+                                               for (int j = 0; j < includes.length; j++) {
+                                                       IIndexInclude indexInclude = includes[j];
+                                                       if (handled.add(indexInclude.getIncludesLocation())) {
+                                                               list.add(indexInclude);
+                                                       }
+                                               }
+                                       }
+                                       return list.toArray(new IIndexInclude[list.size()]);
+                               }
+                       }
+               }
+               catch (CoreException e) {
+                       CUIPlugin.log(e);
+               } 
+               return new IIndexInclude[0];
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBConversions.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBConversions.java
new file mode 100644 (file)
index 0000000..d3fc56d
--- /dev/null
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.includebrowser;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.editors.text.ILocationProvider;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModelUtil;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+public class IBConversions {
+
+    public static IBNode selectionToNode(ISelection sel) {
+        if (sel instanceof IStructuredSelection) {
+            IStructuredSelection ssel= (IStructuredSelection) sel;
+            for (Iterator<?> iter = ssel.iterator(); iter.hasNext();) {
+                Object o= iter.next();
+                if (o instanceof IBNode) {
+                    IBNode node = (IBNode) o;
+                    return node;
+                }
+            }
+        }
+        return null;
+    }
+
+    public static ITranslationUnit selectionToTU(ISelection sel) {
+        if (sel instanceof IStructuredSelection) {
+            IStructuredSelection ssel= (IStructuredSelection) sel;
+            for (Iterator<?> iter = ssel.iterator(); iter.hasNext();) {
+                ITranslationUnit tu= objectToTU(iter.next());
+                if (tu != null) {
+                    return tu;
+                }
+            }
+        }
+        return null;
+    }
+
+    public static ISelection nodeSelectionToRepresentedTUSelection(ISelection sel) {
+        if (sel instanceof IStructuredSelection) {
+            IStructuredSelection ssel= (IStructuredSelection) sel;
+            ArrayList<ITranslationUnit> tus= new ArrayList<ITranslationUnit>();
+            for (Iterator<?> iter = ssel.iterator(); iter.hasNext();) {
+               Object obj= iter.next();
+               if (obj instanceof IBNode) {
+                       ITranslationUnit tu= ((IBNode) obj).getRepresentedTranslationUnit();
+                       if (tu != null) {
+                               tus.add(tu);
+                       }
+               }
+            }
+            return new StructuredSelection(tus);
+        }
+        return StructuredSelection.EMPTY;
+    }
+
+    public static ITranslationUnit objectToTU(Object object) {
+        if (object instanceof ITranslationUnit) {
+            return (ITranslationUnit) object;
+        }
+        if (object instanceof IFile) {
+               return CoreModelUtil.findTranslationUnit((IFile) object);
+        }
+        if (object instanceof IAdaptable) {
+            IAdaptable adaptable = (IAdaptable) object;
+            ITranslationUnit result= (ITranslationUnit) adaptable.getAdapter(ITranslationUnit.class);
+            if (result != null) {
+                return result;
+            }
+            IFile file= (IFile) adaptable.getAdapter(IFile.class);
+            if (file != null) {
+                return CoreModelUtil.findTranslationUnit(file);
+            }
+
+            ILocationProvider locProvider= (ILocationProvider) adaptable.getAdapter(ILocationProvider.class);
+            if (locProvider != null) {
+               IPath path= locProvider.getPath(locProvider);
+               if (path != null) {
+                       try {
+                                               return CoreModelUtil.findTranslationUnitForLocation(path, null);
+                                       } catch (CModelException e) {
+                                               CUIPlugin.log(e);
+                                       }
+               }
+            }
+        }
+        return null;
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBDragSourceListener.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBDragSourceListener.java
new file mode 100644 (file)
index 0000000..d425c29
--- /dev/null
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.includebrowser;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.dnd.DragSourceListener;
+import org.eclipse.swt.dnd.FileTransfer;
+import org.eclipse.ui.part.ResourceTransfer;
+
+import org.eclipse.cdt.core.index.IIndexFileLocation;
+import org.eclipse.cdt.core.index.IndexLocationFactory;
+
+public class IBDragSourceListener implements DragSourceListener {
+
+    private TreeViewer fTreeViewer;
+    private ArrayList<IBNode> fSelectedNodes= new ArrayList<IBNode>();
+       private IBDropTargetListener fDropTargetListener;
+
+    public IBDragSourceListener(TreeViewer viewer) {
+        fTreeViewer= viewer;
+    }
+
+    public void dragStart(DragSourceEvent event) {
+       if (fDropTargetListener != null) {
+               fDropTargetListener.setEnabled(false);
+       }
+        fSelectedNodes.clear();
+        if (event.doit) {
+            IStructuredSelection sel= (IStructuredSelection) fTreeViewer.getSelection();
+            for (Iterator<?> iter = sel.iterator(); iter.hasNext();) {
+                Object element = iter.next();
+                if (element instanceof IBNode) {
+                    fSelectedNodes.add((IBNode) element);
+                }
+            }
+            event.doit= !fSelectedNodes.isEmpty();
+        }
+    }
+
+    public void setDependentDropTargetListener(IBDropTargetListener dl) {
+       fDropTargetListener= dl;
+    }
+    
+    public void dragSetData(DragSourceEvent event) {
+        if (ResourceTransfer.getInstance().isSupportedType(event.dataType)) {
+            event.data= getResources();
+        }
+        else if (FileTransfer.getInstance().isSupportedType(event.dataType)) {
+            event.data= getFiles();
+        }
+    }
+
+    private String[] getFiles() {
+        ArrayList<String> files= new ArrayList<String>(fSelectedNodes.size());
+        for (Iterator<IBNode> iter = fSelectedNodes.iterator(); iter.hasNext();) {
+            IBNode node = iter.next();
+            IIndexFileLocation ifl= (IIndexFileLocation) node.getAdapter(IIndexFileLocation.class);
+            if (ifl != null) {
+                IPath location= IndexLocationFactory.getAbsolutePath(ifl);
+                if (location != null) {
+                    files.add(location.toOSString());
+                }
+            }
+        }
+        return files.toArray(new String[files.size()]);
+    }
+
+    private IFile[] getResources() {
+        ArrayList<IFile> files= new ArrayList<IFile>(fSelectedNodes.size());
+        for (Iterator<IBNode> iter = fSelectedNodes.iterator(); iter.hasNext();) {
+            IBNode node = iter.next();
+            IFile file= (IFile) node.getAdapter(IFile.class);
+            if (file != null) {
+                files.add(file);
+            }
+        }
+        return files.toArray(new IFile[files.size()]);
+    }
+
+    public void dragFinished(DragSourceEvent event) {
+       if (fDropTargetListener != null) {
+               fDropTargetListener.setEnabled(true);
+       }
+        fSelectedNodes.clear();
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBDropTargetListener.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBDropTargetListener.java
new file mode 100644 (file)
index 0000000..db4d945
--- /dev/null
@@ -0,0 +1,161 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.includebrowser;
+
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.DropTargetListener;
+import org.eclipse.swt.dnd.FileTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.dnd.TransferData;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.part.ResourceTransfer;
+
+import org.eclipse.cdt.core.model.CoreModelUtil;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+import org.eclipse.cdt.internal.core.resources.ResourceLookup;
+
+public class IBDropTargetListener implements DropTargetListener {
+    
+    private IBViewPart fIncludeBrowser;
+       private ITranslationUnit fTranslationUnit;
+       private boolean fEnabled= true;
+
+    public IBDropTargetListener(IBViewPart view) {
+        fIncludeBrowser= view;
+    }
+    
+    public void setEnabled(boolean val) {
+       fEnabled= val;
+    }
+    
+    public void dragEnter(DropTargetEvent event) {
+        fTranslationUnit= null;
+        checkOperation(event);
+        if (event.detail != DND.DROP_NONE) {
+                       if (LocalSelectionTransfer.getTransfer().isSupportedType(event.currentDataType)) {
+                               fTranslationUnit= checkLocalSelection();
+                               if (fTranslationUnit == null) {
+                                       TransferData alternateDataType = checkForAlternateDataType(event.dataTypes, 
+                                                       new Transfer[] {ResourceTransfer.getInstance(), FileTransfer.getInstance()});
+                                       if (alternateDataType == null) {
+                                               event.detail= DND.DROP_NONE;
+                                       }
+                                       else {
+                                               event.currentDataType= alternateDataType;
+                                       }
+                               }
+               }
+        }
+    }
+
+       private TransferData checkForAlternateDataType(TransferData[] dataTypes, Transfer[] transfers) {
+               for (int i = 0; i < dataTypes.length; i++) {
+                       TransferData dataType = dataTypes[i];
+                       for (int j = 0; j < transfers.length; j++) {
+                               Transfer transfer = transfers[j];
+                               if (transfer.isSupportedType(dataType)) {
+                                       return dataType;
+                               }
+                       }
+               }
+               return null;
+       }
+
+       private ITranslationUnit checkLocalSelection() {
+               ISelection sel= LocalSelectionTransfer.getTransfer().getSelection();
+               if (sel instanceof IStructuredSelection) {
+                       for (Iterator<?> iter = ((IStructuredSelection)sel).iterator(); iter.hasNext();) {
+                               Object element = iter.next();
+                               if (element instanceof ITranslationUnit) {
+                                       return (ITranslationUnit) element;
+                               }
+                       }
+               }
+               return null;
+       }
+
+    public void dragLeave(DropTargetEvent event) {
+    }
+
+    public void dragOperationChanged(DropTargetEvent event) {
+        checkOperation(event);
+    }
+
+    public void dragOver(DropTargetEvent event) {
+    }
+
+    public void drop(DropTargetEvent event) {
+       if (fTranslationUnit == null) {
+               fTranslationUnit= findFirstTranslationUnit(event.data);
+       }            
+        if (fTranslationUnit == null) {
+            fIncludeBrowser.setMessage(IBMessages.IBViewPart_falseInputMessage);
+            Display.getCurrent().beep();
+        }
+        else {
+            fIncludeBrowser.setInput(fTranslationUnit);
+        }
+    }
+
+    private ITranslationUnit findFirstTranslationUnit(Object o) {
+        if (o instanceof String[]) {
+            String[] filePaths= (String[]) o;
+            for (int i = 0; i < filePaths.length; i++) {
+                String filePath = filePaths[i];
+                ITranslationUnit tu= findTranslationUnit(ResourceLookup.findFilesForLocation(Path.fromOSString(filePath)));
+                if (tu != null) {
+                    return tu;
+                }
+            }
+            return null;
+        }
+        if (o instanceof IResource[]) {
+            return findTranslationUnit((IResource[]) o);
+        }
+        return null;
+    }
+
+    private ITranslationUnit findTranslationUnit(IResource[] files) {
+        for (int i = 0; i < files.length; i++) {
+            IResource resource = files[i];
+            if (resource.getType() == IResource.FILE) {
+                ITranslationUnit tu= CoreModelUtil.findTranslationUnit((IFile) resource);
+                if (tu != null) {
+                    return tu;
+                }
+            }
+        }
+        return null;
+    }
+
+    public void dropAccept(DropTargetEvent event) {
+    }
+    
+    private void checkOperation(DropTargetEvent event) {
+        if (fEnabled && (event.operations & DND.DROP_COPY) != 0) {
+            event.detail= DND.DROP_COPY;
+        }
+        else {
+            event.detail= DND.DROP_NONE;
+        }
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBFile.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBFile.java
new file mode 100644 (file)
index 0000000..9e89e17
--- /dev/null
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.includebrowser;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.cdt.core.index.IIndexFileLocation;
+import org.eclipse.cdt.core.index.IndexLocationFactory;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModelUtil;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+import org.eclipse.cdt.internal.ui.util.CoreUtility;
+
+public class IBFile {
+       final public ITranslationUnit fTU;
+       final public IIndexFileLocation fLocation;
+       final public String fName;
+       
+       public IBFile(ITranslationUnit tu) {
+               fTU= tu;
+               fLocation= IndexLocationFactory.getIFL(tu);
+               fName= tu.getElementName();
+       }
+       
+       public IBFile(ICProject preferredProject, IIndexFileLocation location) throws CModelException {
+               fLocation= location;
+               fTU= CoreModelUtil.findTranslationUnitForLocation(location, preferredProject);
+               String name= fLocation.getURI().getPath();
+               fName= name.substring(name.lastIndexOf('/')+1);
+       }
+
+       public IBFile(String name) {
+               fName= name;
+               fLocation= null;
+               fTU= null;
+       }
+       
+       public IIndexFileLocation getLocation() {
+               return fLocation;
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               if (obj instanceof IBFile) {
+                       IBFile file = (IBFile) obj;
+                       return (CoreUtility.safeEquals(fLocation, file.fLocation) &&
+                                       CoreUtility.safeEquals(fTU, file.fTU));
+               }
+               return super.equals(obj);
+       }
+
+       @Override
+       public int hashCode() {
+               return CoreUtility.safeHashcode(fLocation)
+                       + 31* (CoreUtility.safeHashcode(fTU) 
+                       + 31* CoreUtility.safeHashcode(fName));
+       }
+
+       public ITranslationUnit getTranslationUnit() {
+               return fTU;
+       }
+
+       public IFile getResource() {
+               if (fLocation != null) {
+                       String fullPath= fLocation.getFullPath();
+                       if (fullPath != null) {
+                               IResource file= ResourcesPlugin.getWorkspace().getRoot().findMember(fullPath);
+                               if (file instanceof IFile) {
+                                       return (IFile) file;
+                               }
+                       }
+               }
+               return null;
+       }
+       
+       public String getName() {
+               return fName;
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryAction.java
new file mode 100644 (file)
index 0000000..6020d18
--- /dev/null
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.includebrowser;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
+
+
+/**
+ * Action used for the include browser forward / backward buttons
+ */
+public class IBHistoryAction extends Action {
+
+       private IBViewPart fViewPart;
+       private ITranslationUnit fElement;
+       
+       public IBHistoryAction(IBViewPart viewPart, ITranslationUnit element) {
+        super("", AS_RADIO_BUTTON); //$NON-NLS-1$
+               fViewPart= viewPart;
+               fElement= element;              
+               
+               String elementName= CElementLabels.getElementLabel(element, CElementLabels.ALL_POST_QUALIFIED);
+               setText(elementName);
+               setImageDescriptor(getImageDescriptor(element));
+       }
+       
+       private ImageDescriptor getImageDescriptor(ITranslationUnit elem) {
+               CElementImageProvider imageProvider= new CElementImageProvider();
+               ImageDescriptor desc= imageProvider.getBaseImageDescriptor(elem, 0);
+               imageProvider.dispose();
+               return desc;
+       }
+       
+       /*
+        * @see Action#run()
+        */
+       @Override
+       public void run() {
+               fViewPart.setInput(fElement);
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryDropDownAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryDropDownAction.java
new file mode 100644 (file)
index 0000000..7e5d7c2
--- /dev/null
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.includebrowser;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IMenuCreator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+
+public class IBHistoryDropDownAction extends Action implements IMenuCreator {
+       
+       public static class ClearHistoryAction extends Action {
+
+               private IBViewPart fView;
+               
+               public ClearHistoryAction(IBViewPart view) {
+                       super(IBMessages.IBHistoryDropDownAction_ClearHistory_label);
+                       fView= view;
+               }
+                       
+               @Override
+               public void run() {
+                       fView.setHistoryEntries(new ITranslationUnit[0]);
+                       fView.setInput(null);
+               }
+       }
+
+       public static final int RESULTS_IN_DROP_DOWN= 10;
+
+       private IBViewPart fHierarchyView;
+       private Menu fMenu;
+       
+       public IBHistoryDropDownAction(IBViewPart view) {
+               fHierarchyView= view;
+               fMenu= null;
+               setToolTipText(IBMessages.IBHistoryDropDownAction_tooltip); 
+               CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "history_list.gif"); //$NON-NLS-1$
+               setMenuCreator(this);
+       }
+
+       public void dispose() {
+               // action is reused, can be called several times.
+               if (fMenu != null) {
+                       fMenu.dispose();
+                       fMenu= null;
+               }
+       }
+
+       public Menu getMenu(Menu parent) {
+               return null;
+       }
+
+       public Menu getMenu(Control parent) {
+               if (fMenu != null) {
+                       fMenu.dispose();
+               }
+               fMenu= new Menu(parent);
+               ITranslationUnit[] elements= fHierarchyView.getHistoryEntries();
+               addEntries(fMenu, elements);
+               new MenuItem(fMenu, SWT.SEPARATOR);
+               addActionToMenu(fMenu, new IBHistoryListAction(fHierarchyView));
+               addActionToMenu(fMenu, new ClearHistoryAction(fHierarchyView));
+               return fMenu;
+       }
+       
+       private boolean addEntries(Menu menu, ITranslationUnit[] elements) {
+               boolean checked= false;
+               
+               int min= Math.min(elements.length, RESULTS_IN_DROP_DOWN);
+               for (int i= 0; i < min; i++) {
+                       IBHistoryAction action= new IBHistoryAction(fHierarchyView, elements[i]);
+                       action.setChecked(elements[i].equals(fHierarchyView.getInput()));
+                       checked= checked || action.isChecked();
+                       addActionToMenu(menu, action);
+               }
+               
+               
+               return checked;
+       }
+       
+
+       protected void addActionToMenu(Menu parent, Action action) {
+               ActionContributionItem item= new ActionContributionItem(action);
+               item.fill(parent, -1);
+       }
+
+       @Override
+       public void run() {
+               (new IBHistoryListAction(fHierarchyView)).run();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.java
new file mode 100644 (file)
index 0000000..2c6fca2
--- /dev/null
@@ -0,0 +1,182 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.includebrowser;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.StatusDialog;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
+
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
+
+public class IBHistoryListAction extends Action {
+       
+       private class HistoryListDialog extends StatusDialog {
+               private ListDialogField<ITranslationUnit> fHistoryList;
+               private IStatus fHistoryStatus;
+               private ITranslationUnit fResult;
+               
+               private HistoryListDialog(Shell shell, ITranslationUnit[] elements) {
+                       super(shell);
+                       setHelpAvailable(false);                        
+                       setTitle(IBMessages.IBHistoryListAction_HistoryDialog_title); 
+                       String[] buttonLabels= new String[] { 
+                               IBMessages.IBHistoryListAction_Remove_label, 
+                       };
+                                       
+                       IListAdapter<ITranslationUnit> adapter= new IListAdapter<ITranslationUnit>() {
+                               public void customButtonPressed(ListDialogField<ITranslationUnit> field, int index) {
+                                       doCustomButtonPressed();
+                               }
+                               public void selectionChanged(ListDialogField<ITranslationUnit> field) {
+                                       doSelectionChanged();
+                               }
+                               
+                               public void doubleClicked(ListDialogField<ITranslationUnit> field) {
+                                       doDoubleClicked();
+                               }                               
+                       };
+               
+                       ILabelProvider labelProvider= new CUILabelProvider(CElementLabels.APPEND_ROOT_PATH, CElementImageProvider.OVERLAY_ICONS);
+                       
+                       fHistoryList= new ListDialogField<ITranslationUnit>(adapter, buttonLabels, labelProvider);
+                       fHistoryList.setLabelText(IBMessages.IBHistoryListAction_HistoryList_label); 
+                       fHistoryList.setElements(Arrays.asList(elements));
+                       
+                       ISelection sel;
+                       if (elements.length > 0) {
+                               sel= new StructuredSelection(elements[0]);
+                       } else {
+                               sel= new StructuredSelection();
+                       }
+                       
+                       fHistoryList.selectElements(sel);
+               }
+                       
+               /*
+                * @see Dialog#createDialogArea(Composite)
+                */
+               @Override
+               protected Control createDialogArea(Composite parent) {
+                       initializeDialogUnits(parent);
+                       
+                       Composite composite= (Composite) super.createDialogArea(parent);
+                       
+                       Composite inner= new Composite(composite, SWT.NONE);
+                       inner.setFont(parent.getFont());
+                       
+                       inner.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+                       LayoutUtil.doDefaultLayout(inner, new DialogField[] { fHistoryList }, true, 0, 0);
+                       LayoutUtil.setHeightHint(fHistoryList.getListControl(null), convertHeightInCharsToPixels(12));
+                       LayoutUtil.setHorizontalGrabbing(fHistoryList.getListControl(null), true);
+
+                       applyDialogFont(composite);             
+                       return composite;
+               }
+
+               /**
+                * Method doCustomButtonPressed.
+                */
+               private void doCustomButtonPressed() {
+                       fHistoryList.removeElements(fHistoryList.getSelectedElements());
+               }
+               
+               private void doDoubleClicked() {
+                       if (fHistoryStatus.isOK()) {
+                               okPressed();
+                       }
+               }
+               
+               private void doSelectionChanged() {
+                       StatusInfo status= new StatusInfo();
+                       List<ITranslationUnit> selected= fHistoryList.getSelectedElements();
+                       if (selected.size() != 1) {
+                               status.setError(""); //$NON-NLS-1$
+                               fResult= null;
+                       } else {
+                               fResult= selected.get(0);
+                       }
+                       fHistoryList.enableButton(0, fHistoryList.getSize() > selected.size() && selected.size() != 0);                 
+                       fHistoryStatus= status;
+                       updateStatus(status);   
+               }
+                               
+               public ITranslationUnit getResult() {
+                       return fResult;
+               }
+               
+               public ITranslationUnit[] getRemaining() {
+                       List<ITranslationUnit> elems= fHistoryList.getElements();
+                       return elems.toArray(new ITranslationUnit[elems.size()]);
+               }       
+               
+               /*
+                * @see org.eclipse.jface.window.Window#configureShell(Shell)
+                */
+               @Override
+               protected void configureShell(Shell newShell) {
+                       super.configureShell(newShell);
+//                     PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, ...);
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.window.Window#create()
+                */
+               @Override
+               public void create() {
+                       setShellStyle(getShellStyle() | SWT.RESIZE);
+                       super.create();
+               }
+       }
+       
+       private IBViewPart fView;
+       
+       public IBHistoryListAction(IBViewPart view) {
+               fView= view;
+               setText(IBMessages.IBHistoryListAction_label); 
+       }
+               
+       /*
+        * @see IAction#run()
+        */
+       @Override
+       public void run() {
+           ITranslationUnit[] historyEntries= fView.getHistoryEntries();
+               HistoryListDialog dialog= new HistoryListDialog(fView.getSite().getShell(), historyEntries);
+               if (dialog.open() == Window.OK) {
+                       fView.setHistoryEntries(dialog.getRemaining());
+                       fView.setInput(dialog.getResult());
+               }
+       }
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBLabelProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBLabelProvider.java
new file mode 100644 (file)
index 0000000..ed23e11
--- /dev/null
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.includebrowser;
+
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IColorProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CElementImageDescriptor;
+import org.eclipse.cdt.ui.CElementLabelProvider;
+
+import org.eclipse.cdt.internal.ui.viewsupport.ImageImageDescriptor;
+
+public class IBLabelProvider extends LabelProvider implements IColorProvider {
+    private CElementLabelProvider fCLabelProvider= new CElementLabelProvider();
+    private Color fColorInactive;
+    private IBContentProvider fContentProvider;
+    private HashMap<String, Image> fCachedImages= new HashMap<String, Image>();
+    private boolean fShowFolders;
+    
+    public IBLabelProvider(Display display, IBContentProvider cp) {
+        fColorInactive= display.getSystemColor(SWT.COLOR_DARK_GRAY);
+        fContentProvider= cp;
+    }
+    
+    @Override
+       public Image getImage(Object element) {
+        if (element instanceof IBNode) {
+            IBNode node= (IBNode) element;
+            ITranslationUnit tu= node.getRepresentedTranslationUnit();
+            Image image= tu != null ? fCLabelProvider.getImage(tu) : CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_TUNIT_HEADER);
+            return decorateImage(image, node);
+        }
+        return super.getImage(element);
+    }
+
+    @Override
+       public String getText(Object element) {
+        if (element instanceof IBNode) {
+            IBNode node= (IBNode) element;
+            IPath path= node.getRepresentedPath();
+            if (path != null) {
+               if (fShowFolders) {
+                       return path.lastSegment() + " (" + path.removeLastSegments(1) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+               }
+               return path.lastSegment();
+            }
+            return node.getDirectiveName();
+        }
+        return super.getText(element);
+    }
+    
+    @Override
+       public void dispose() {
+        fCLabelProvider.dispose();
+        for (Iterator<Image> iter = fCachedImages.values().iterator(); iter.hasNext();) {
+            Image image = iter.next();
+            image.dispose();
+        }
+        fCachedImages.clear();
+        super.dispose();
+    }
+
+    private Image decorateImage(Image image, IBNode node) {
+        int flags= 0;
+        if (node.isSystemInclude()) {
+            flags |= CElementImageDescriptor.SYSTEM_INCLUDE;
+        }
+        if (!node.isActiveCode()) {
+            flags |= CElementImageDescriptor.INACTIVE;
+        }
+        
+        if (node.isRecursive()) {
+            flags |= CElementImageDescriptor.RECURSIVE_RELATION;
+        }
+        else if (fContentProvider.hasChildren(node)) {
+            if (fContentProvider.getComputeIncludedBy()) {
+                flags |= CElementImageDescriptor.REFERENCED_BY;
+            }
+            else {
+                flags |= CElementImageDescriptor.RELATES_TO;
+            }
+        }
+
+        if (node.isActiveCode() && node.getRepresentedIFL() == null) {
+               flags |= CElementImageDescriptor.WARNING;
+        }
+
+        if (flags == 0) {
+            return image;
+        }
+        String key= image.toString()+String.valueOf(flags);
+        Image result= fCachedImages.get(key);
+        if (result == null) {
+            ImageDescriptor desc= new CElementImageDescriptor(
+                    new ImageImageDescriptor(image), flags, new Point(20,16));
+            result= desc.createImage();
+            fCachedImages.put(key, result);
+        }
+        return result;
+    }
+
+    public Color getBackground(Object element) {
+        return null;
+    }
+
+    public Color getForeground(Object element) {
+        if (element instanceof IBNode) {
+            IBNode node= (IBNode) element;
+            if (!node.isActiveCode()) {
+                return fColorInactive;
+            }
+        }
+        return null;
+    }
+
+    public void setShowFolders(boolean show) {
+        fShowFolders= show;
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBMessages.java
new file mode 100644 (file)
index 0000000..56c4b03
--- /dev/null
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.includebrowser;
+
+import org.eclipse.osgi.util.NLS;
+
+public class IBMessages extends NLS {
+       private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.includebrowser.IBMessages"; //$NON-NLS-1$
+
+       public static String IBHistoryDropDownAction_ClearHistory_label;
+       public static String IBHistoryDropDownAction_tooltip;
+       public static String IBHistoryListAction_HistoryDialog_title;
+       public static String IBHistoryListAction_HistoryList_label;
+       public static String IBHistoryListAction_label;
+       public static String IBHistoryListAction_Remove_label;
+       public static String IBViewPart_falseInputMessage;
+       public static String IBViewPart_FocusOn_label;
+       public static String IBViewPart_hideInactive_label;
+       public static String IBViewPart_hideInactive_tooltip;
+       public static String IBViewPart_hideSystem_label;
+       public static String IBViewPart_hideSystem_tooltip;
+       public static String IBViewPart_IncludedByContentDescription;
+       public static String IBViewPart_IncludesToContentDescription;
+       public static String IBViewPart_instructionMessage;
+
+       public static String IBViewPart_jobCheckInput;
+       public static String IBViewPart_nextMatch_label;
+       public static String IBViewPart_nextMatch_tooltip;
+       public static String IBViewPart_previousMatch_label;
+       public static String IBViewPart_previousMatch_tooltip;
+       public static String IBViewPart_refresh_label;
+       public static String IBViewPart_refresh_tooltip;
+       public static String IBViewPart_showFolders_label;
+       public static String IBViewPart_showFolders_tooltip;
+       public static String IBViewPart_showInclude_label;
+       public static String IBViewPart_showIncludedBy_label;
+       public static String IBViewPart_showIncludedBy_tooltip;
+       public static String IBViewPart_showIncludesTo_label;
+       public static String IBViewPart_showIncludesTo_tooltip;
+       public static String IBViewPart_ShowInMenu_label;
+
+       public static String IBViewPart_waitingOnIndexerMessage;
+       public static String IBViewPart_workspaceScope;
+
+       public static String OpenIncludeBrowserAction_label;
+
+       public static String OpenIncludeBrowserAction_tooltip;
+
+       static {
+               // initialize resource bundle
+               NLS.initializeMessages(BUNDLE_NAME, IBMessages.class);
+       }
+
+       private IBMessages() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBMessages.properties
new file mode 100644 (file)
index 0000000..2e945d4
--- /dev/null
@@ -0,0 +1,45 @@
+###############################################################################
+# Copyright (c) 2006, 2008 Wind River Systems, Inc and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#    Markus Schorn - Initial API and implementation
+###############################################################################
+
+IBViewPart_instructionMessage=To display an include hierarchy, drop a c/c++-file onto this view.
+IBViewPart_showIncludedBy_label=Show Includers
+IBViewPart_showIncludedBy_tooltip=Show Includers
+IBViewPart_showIncludesTo_label=Show Files Included
+IBViewPart_showInclude_label=Open Include
+IBViewPart_showFolders_label=Show Folders
+IBViewPart_showFolders_tooltip=Show Folders
+IBViewPart_previousMatch_label=Previous Include
+IBViewPart_showIncludesTo_tooltip=Show Files Included
+IBViewPart_waitingOnIndexerMessage=Waiting for indexer to complete.
+IBViewPart_IncludedByContentDescription=Files including ''{0}'' - in {1}
+IBViewPart_IncludesToContentDescription=Files included by ''{0}'' - in {1}
+IBViewPart_hideInactive_tooltip=Hide Includes from Inactive Code
+IBViewPart_previousMatch_tooltip=Show Previous Include
+IBViewPart_hideInactive_label=Hide Inactive Includes
+IBViewPart_hideSystem_tooltip=Hide System Includes
+IBViewPart_ShowInMenu_label=Show In
+IBViewPart_hideSystem_label=Hide System Includes
+IBViewPart_workspaceScope=workspace
+IBViewPart_refresh_label=Refresh
+IBViewPart_FocusOn_label=Focus On ''{0}''
+IBViewPart_jobCheckInput=Check Include Browser input
+IBViewPart_nextMatch_label=Next Include
+IBViewPart_refresh_tooltip=Refresh View Content
+IBViewPart_falseInputMessage=Include Hierarchies can be shown for C or C++ files, only. They have to be part of the workspace.
+IBViewPart_nextMatch_tooltip=Show Next Include
+IBHistoryListAction_HistoryDialog_title=Include Browser History
+IBHistoryDropDownAction_ClearHistory_label=Clear History
+IBHistoryListAction_Remove_label=Remove
+IBHistoryDropDownAction_tooltip=Show History List
+IBHistoryListAction_HistoryList_label=Select a file to show in the Include Browser:
+IBHistoryListAction_label=Open History...
+OpenIncludeBrowserAction_label=Open Inc&lude Browser
+OpenIncludeBrowserAction_tooltip=Open Include Browser
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBNode.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBNode.java
new file mode 100644 (file)
index 0000000..14c1938
--- /dev/null
@@ -0,0 +1,210 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.includebrowser;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+
+import org.eclipse.cdt.core.index.IIndexFileLocation;
+import org.eclipse.cdt.core.index.IndexLocationFactory;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+import org.eclipse.cdt.internal.ui.util.CoreUtility;
+
+/**
+ * Represents a node in the include browser
+ */
+public class IBNode implements IAdaptable {
+       private IBNode fParent;
+    private IBFile fRepresentedFile;
+    
+    // navigation info
+    private IBFile fDirectiveFile;
+    private int fDirectiveCharacterOffset;
+    private int fDirectiveLength;
+    private int fHashCode;
+    
+    private boolean fIsSystemInclude= false;
+    private boolean fIsActive= true;
+    private boolean fIsRecursive;
+    private long fTimestamp;
+
+    /**
+     * Creates a new node for the include browser
+     */
+    public IBNode(IBNode parent, IBFile represents, IBFile fileOfDirective, 
+               int charOffset, int length, long timestamp) {
+       assert represents != null;
+        fParent= parent;
+        fRepresentedFile= represents;
+        fDirectiveFile= fileOfDirective;
+        fDirectiveCharacterOffset= charOffset;
+        fDirectiveLength= length;
+        fIsRecursive= computeIsRecursive(fParent, represents.getLocation());
+        fHashCode= computeHashCode();
+        fTimestamp= timestamp;
+    }
+    
+    private int computeHashCode() {
+        int hashCode= 0;
+        if (fParent != null) {
+            hashCode= fParent.hashCode() * 31;
+        }
+        hashCode+= fRepresentedFile.hashCode();
+        return hashCode;
+    }   
+
+    @Override
+       public int hashCode() {
+        return fHashCode;
+    }
+    
+    @Override
+       public boolean equals(Object o) {
+               if (!(o instanceof IBNode)) {
+                       return false;
+               }
+
+               IBNode rhs = (IBNode) o;
+               if (fHashCode != rhs.fHashCode) {
+                       return false;
+               }
+
+               return CoreUtility.safeEquals(fRepresentedFile, rhs.fRepresentedFile); 
+       }
+    
+    private boolean computeIsRecursive(IBNode parent, IIndexFileLocation ifl) {
+        if (parent == null || ifl == null) {
+            return false;
+        }
+        if (ifl.equals(parent.getRepresentedFile().getLocation())) {
+            return true;
+        }
+        return computeIsRecursive(parent.fParent, ifl);
+    }
+
+       /**
+     * Returns the parent node or <code>null</code> for the root node.
+     */
+    public IBNode getParent() {
+        return fParent;
+    }
+
+    /**
+     * Returns the translation unit that requests the inclusion
+     */
+    public IBFile getRepresentedFile() {
+        return fRepresentedFile;
+    }
+        
+    /**
+     * Returns whether this is a system include (angle-brackets).
+     */
+    public boolean isSystemInclude() {
+        return fIsSystemInclude;
+    }
+    
+    /**
+     * Defines whether this is a system include (angle-brackets).
+     */
+    public void setIsSystemInclude(boolean isSystemInclude) {
+        fIsSystemInclude= isSystemInclude;
+    }
+    
+    /**
+     * Returns whether this inclusion is actually performed with the current set
+     * of macro definitions. This is true unless the include directive appears within
+     * a conditional compilation construct (#ifdef/#endif).
+     */
+    public boolean isActiveCode() {
+        return fIsActive;
+    }
+
+    /**
+     * Defines whether the inclusion appears in active code.
+     */
+    public void setIsActiveCode(boolean isActiveCode) {
+        fIsActive= isActiveCode;
+    }
+
+    public boolean isRecursive() {
+        return fIsRecursive;
+    }
+
+    public int getDirectiveCharacterOffset() {
+        return fDirectiveCharacterOffset;
+    }
+    
+    public int getDirectiveLength() {
+       return fDirectiveLength;
+    }
+
+    public IBFile getDirectiveFile() {
+        return fDirectiveFile;
+    }
+
+    public String getDirectiveName() {
+        return fRepresentedFile.getName();
+    }
+
+    @SuppressWarnings({ "unchecked", "rawtypes" })
+       public Object getAdapter(Class adapter) {
+        if (fRepresentedFile != null) {
+            if (adapter.isAssignableFrom(ITranslationUnit.class)) {
+                return fRepresentedFile.getTranslationUnit();
+            }
+            if (adapter.isAssignableFrom(IFile.class)) {
+                return fRepresentedFile.getResource();
+            }
+            if (adapter.isAssignableFrom(IIndexFileLocation.class)) {
+               return fRepresentedFile.getLocation();
+            }
+        }
+        return null;
+    }
+
+       public ITranslationUnit getRepresentedTranslationUnit() {
+               return fRepresentedFile == null ? null : fRepresentedFile.getTranslationUnit();
+       }
+
+       public IPath getRepresentedPath() {
+               if (fRepresentedFile == null) {
+                       return null;
+               }
+               IIndexFileLocation ifl= fRepresentedFile.getLocation();
+               if (ifl != null) {
+                       return IndexLocationFactory.getPath(ifl);
+               }
+               return null;
+       }
+       
+       public IIndexFileLocation getRepresentedIFL() {
+               return fRepresentedFile == null ? null : fRepresentedFile.getLocation();
+       }
+
+       public long getTimestamp() {
+               return fTimestamp;
+       }
+
+       public ICProject getCProject() {
+               ITranslationUnit tu= getRepresentedTranslationUnit();
+               if (tu != null) {
+                       return tu.getCProject();
+               }
+               IBNode parent= getParent();
+               if (parent != null) {
+                       return parent.getCProject();
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBSetInputJob.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBSetInputJob.java
new file mode 100644 (file)
index 0000000..0b2afb8
--- /dev/null
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.includebrowser;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.swt.SWTException;
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.index.IIndexManager;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+public class IBSetInputJob extends Job {
+
+       private ITranslationUnit fInput;
+       private Display fDisplay;
+       private IBViewPart fViewPart;
+
+
+       public IBSetInputJob(IBViewPart viewPart, Display disp) {
+               super(IBMessages.IBViewPart_waitingOnIndexerMessage);
+               setSystem(true);
+               fViewPart= viewPart;
+               fDisplay= disp;
+       }
+       
+       @Override
+       protected IStatus run(IProgressMonitor monitor) {
+       if (CCorePlugin.getIndexManager().joinIndexer(IIndexManager.FOREVER, monitor)) {
+               try {
+                               fDisplay.asyncExec(new Runnable() {
+                                       public void run() {
+                                               fViewPart.setInput(fInput);
+                                       }
+                               });
+                       } catch (SWTException e) {
+                               // display may be disposed
+                       }
+               }
+       return Status.OK_STATUS;
+       }
+
+       public void setInput(ITranslationUnit input) {
+               fInput= input;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBViewPart.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBViewPart.java
new file mode 100644 (file)
index 0000000..62f1811
--- /dev/null
@@ -0,0 +1,871 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2011 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.includebrowser;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+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.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.IOpenListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.OpenEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.search.ui.IContextMenuConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DropTarget;
+import org.eclipse.swt.dnd.FileTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.ContributionItemFactory;
+import org.eclipse.ui.actions.OpenFileAction;
+import org.eclipse.ui.contexts.IContextActivation;
+import org.eclipse.ui.contexts.IContextService;
+import org.eclipse.ui.navigator.resources.ProjectExplorer;
+import org.eclipse.ui.part.IShowInSource;
+import org.eclipse.ui.part.IShowInTarget;
+import org.eclipse.ui.part.IShowInTargetList;
+import org.eclipse.ui.part.PageBook;
+import org.eclipse.ui.part.ResourceTransfer;
+import org.eclipse.ui.part.ShowInContext;
+import org.eclipse.ui.part.ViewPart;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexFileLocation;
+import org.eclipse.cdt.core.index.IndexLocationFactory;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.CoreModelUtil;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.navigator.OpenCElementAction;
+import org.eclipse.cdt.internal.ui.util.Messages;
+import org.eclipse.cdt.internal.ui.viewsupport.EditorOpener;
+import org.eclipse.cdt.internal.ui.viewsupport.ExtendedTreeViewer;
+import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
+import org.eclipse.cdt.internal.ui.viewsupport.TreeNavigator;
+import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
+
+/**
+ * The view part for the include browser.
+ */
+public class IBViewPart extends ViewPart 
+        implements IShowInSource, IShowInTarget, IShowInTargetList {
+
+       private static final int MAX_HISTORY_SIZE = 10;
+    private static final String TRUE = "true"; //$NON-NLS-1$
+    private static final String FALSE = "false"; //$NON-NLS-1$
+    private static final String KEY_WORKING_SET_FILTER = "workingSetFilter"; //$NON-NLS-1$
+    private static final String KEY_FILTER_SYSTEM = "systemFilter"; //$NON-NLS-1$
+    private static final String KEY_FILTER_INACTIVE = "inactiveFilter"; //$NON-NLS-1$
+    private static final String KEY_INPUT_PATH= "inputPath"; //$NON-NLS-1$
+       private static final String KEY_INCLUDED_BY = "includedBy"; //$NON-NLS-1$
+       private static final String KEY_SHOW_FOLDERS = "showFolders"; //$NON-NLS-1$
+    
+    private IMemento fMemento;
+    private boolean fShowsMessage;
+    private IBNode fLastNavigationNode;
+       private ArrayList<ITranslationUnit> fHistoryEntries= new ArrayList<ITranslationUnit>(MAX_HISTORY_SIZE);
+
+    // widgets
+    private PageBook fPagebook;
+    private Composite fViewerPage;
+    private Label fInfoText;
+
+    // treeviewer
+    private IBContentProvider fContentProvider;
+    private IBLabelProvider fLabelProvider;
+    private ExtendedTreeViewer fTreeViewer;
+
+    // filters, sorter
+    private IBWorkingSetFilter fWorkingSetFilter;
+    private ViewerFilter fInactiveFilter;
+    private ViewerFilter fSystemFilter;
+    private ViewerComparator fSorterAlphaNumeric;
+    private ViewerComparator fSorterReferencePosition;
+
+    // actions
+    private Action fIncludedByAction;
+    private Action fIncludesToAction;
+    private Action fFilterInactiveAction;
+    private Action fFilterSystemAction;
+    private Action fShowFolderInLabelsAction;
+    private Action fNextAction;
+    private Action fPreviousAction;
+    private Action fRefreshAction;
+       private Action fHistoryAction;
+       private IContextActivation fContextActivation;
+       private WorkingSetFilterUI fWorkingSetFilterUI;
+       private IBSetInputJob fSetInputJob;
+
+    
+    @Override
+       public void setFocus() {
+        fPagebook.setFocus();
+    }
+
+    public void setMessage(String msg) {
+        fInfoText.setText(msg);
+        fPagebook.showPage(fInfoText);
+        fShowsMessage= true;
+        updateActionEnablement();
+        updateDescription();
+    }
+    
+    public void setInput(ITranslationUnit input) {
+       if (fPagebook.isDisposed()) {
+               return;
+       }
+       if (input instanceof IWorkingCopy) {
+               input= ((IWorkingCopy) input).getOriginalElement();
+       }
+       fSetInputJob.cancel();
+       if (input == null) {
+               setMessage(IBMessages.IBViewPart_instructionMessage);
+               fTreeViewer.setInput(null);
+               return;
+       }
+       
+       if (CCorePlugin.getIndexManager().isIndexerIdle()) {
+               setInputIndexerIdle(input);
+       }
+       else {
+               setMessage(IBMessages.IBViewPart_waitingOnIndexerMessage);
+               fSetInputJob.setInput(input);
+               fSetInputJob.schedule();
+       }
+    }
+
+       private void setInputIndexerIdle(final ITranslationUnit input) {
+               fShowsMessage= false;
+        boolean isHeader= input.isHeaderUnit();
+        
+        fTreeViewer.setInput(null);
+        if (!isHeader) {
+               fContentProvider.setComputeIncludedBy(isHeader);
+               fIncludedByAction.setChecked(isHeader);
+               fIncludesToAction.setChecked(!isHeader);
+               fIncludedByAction.setEnabled(false);
+               updateSorter();
+        }
+        else {
+               fIncludedByAction.setEnabled(true);
+        }
+        fTreeViewer.setInput(input);
+        fPagebook.showPage(fViewerPage);
+        updateHistory(input);
+
+        updateActionEnablement();
+        updateDescription();
+        final Display display= Display.getCurrent();
+        Job job= new Job(IBMessages.IBViewPart_jobCheckInput) {
+                       @Override
+                       protected IStatus run(IProgressMonitor monitor) {
+                               try {
+                                       final ICProject[] projects= CoreModel.getDefault().getCModel().getCProjects();
+                                       IIndex index= CCorePlugin.getIndexManager().getIndex(projects);
+                                       index.acquireReadLock();
+                                       try {
+                                               if (!IndexUI.isIndexed(index, input)) {
+                                                       // Bug 306879: Try to find an alternative translation unit for the file by the location.
+                                                       final ITranslationUnit alt= CoreModelUtil.findTranslationUnitForLocation(input.getLocation(), input.getCProject());
+                                                       if (alt != null && IndexUI.isIndexed(index, alt)) {
+                                                               display.asyncExec(new Runnable() {
+                                                                       public void run() {
+                                                                               if (fTreeViewer.getInput() == input) {
+                                                                                       setInput(alt);
+                                                                               }
+                                                                       }
+                                                               });
+                                                       } else {
+                                                               final String msg = IndexUI.getFileNotIndexedMessage(input);
+                                                               display.asyncExec(new Runnable() {
+                                                                       public void run() {
+                                                                               if (fTreeViewer.getInput() == input) {
+                                                                                       setMessage(msg);
+                                                                                       fTreeViewer.setInput(null);
+                                                                               }
+                                                                       }
+                                                               });
+                                                       }
+                                               }
+                                               return Status.OK_STATUS;
+                                       } finally {
+                                               index.releaseReadLock();
+                                       }
+                               } catch (CoreException e) {
+                                       return Status.OK_STATUS;
+                               } catch (InterruptedException e) {
+                                       Thread.currentThread().interrupt();
+                                       return Status.CANCEL_STATUS;
+                               } 
+                       }
+        };
+        job.setSystem(true);
+        job.schedule();
+       }
+
+       private void updateActionEnablement() {
+               fHistoryAction.setEnabled(!fHistoryEntries.isEmpty());
+               fNextAction.setEnabled(!fShowsMessage);
+               fPreviousAction.setEnabled(!fShowsMessage);
+               fRefreshAction.setEnabled(!fShowsMessage);
+       }
+
+       @Override
+       public void createPartControl(Composite parent) {
+               fSetInputJob= new IBSetInputJob(this, Display.getCurrent());
+               
+        fPagebook = new PageBook(parent, SWT.NULL);
+        createInfoPage();
+        createViewerPage();
+                
+        initDragAndDrop();
+        createActions();
+        createContextMenu();
+
+        getSite().setSelectionProvider(fTreeViewer);
+        setMessage(IBMessages.IBViewPart_instructionMessage);
+        
+        initializeActionStates();
+        restoreInput();
+        fMemento= null;
+
+       IContextService ctxService = (IContextService) getSite().getService(IContextService.class);
+       if (ctxService != null) {
+               fContextActivation= ctxService.activateContext(CUIPlugin.CVIEWS_SCOPE);
+       }
+
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(fPagebook, ICHelpContextIds.INCLUDE_BROWSER_VIEW);
+       }
+       
+       @Override
+       public void dispose() {
+               putDialogSettings();
+               if (fContextActivation != null) {
+                       IContextService ctxService = (IContextService)getSite().getService(IContextService.class);
+               if (ctxService != null) {
+                       ctxService.deactivateContext(fContextActivation);
+               }
+               }
+               if (fWorkingSetFilterUI != null) {
+                       fWorkingSetFilterUI.dispose();
+               }
+       }
+       
+    private void initializeActionStates() {
+        IDialogSettings ds= getDialogSettings();
+
+        boolean includedBy= !FALSE.equals(ds.get(KEY_INCLUDED_BY));
+        fIncludedByAction.setChecked(includedBy);
+        fIncludesToAction.setChecked(!includedBy);
+        fContentProvider.setComputeIncludedBy(includedBy);
+        
+        fFilterInactiveAction.setChecked(TRUE.equals(ds.get(KEY_FILTER_INACTIVE)));
+        fFilterInactiveAction.run();
+        fFilterSystemAction.setChecked(TRUE.equals(ds.get(KEY_FILTER_SYSTEM)));
+        fFilterSystemAction.run();
+        fShowFolderInLabelsAction.setChecked(TRUE.equals((ds.get(KEY_SHOW_FOLDERS))));
+        fShowFolderInLabelsAction.run();
+        updateSorter();
+    }
+    
+    private void restoreInput() {
+        if (fMemento != null) {
+            String pathStr= fMemento.getString(KEY_INPUT_PATH);
+            if (pathStr != null) {
+                IPath path= Path.fromPortableString(pathStr);
+                if (path.segmentCount() > 1) {
+                    String name= path.segment(0);
+                    ICProject project= CoreModel.getDefault().getCModel().getCProject(name);
+                    if (project != null) {
+                        ICElement celement;
+                        try {
+                            celement = project.findElement(path);
+                            if (celement instanceof ITranslationUnit) {
+                                setInput((ITranslationUnit) celement);
+                            }
+                        } catch (CModelException e) {
+                            // ignore
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+
+    @Override
+       public void init(IViewSite site, IMemento memento) throws PartInitException {
+        fMemento= memento;
+        super.init(site, memento);
+    }
+
+
+    @Override
+       public void saveState(IMemento memento) {
+       putDialogSettings();
+       if (memento != null) {
+               if (fWorkingSetFilter != null) {
+                       fWorkingSetFilter.getUI().saveState(memento, KEY_WORKING_SET_FILTER);
+               }
+            ITranslationUnit input= getInput();
+            if (input != null) {
+                IPath path= input.getPath();
+                if (path != null) {
+                    memento.putString(KEY_INPUT_PATH, path.toPortableString());
+                }
+            }
+       }
+        super.saveState(memento);
+    }
+    
+    private void putDialogSettings() {
+       IDialogSettings ds= getDialogSettings();
+        ds.put(KEY_FILTER_INACTIVE, String.valueOf(fFilterInactiveAction.isChecked()));
+        ds.put(KEY_FILTER_SYSTEM, String.valueOf(fFilterSystemAction.isChecked()));
+        ds.put(KEY_INCLUDED_BY, String.valueOf(fIncludedByAction.isChecked()));
+        ds.put(KEY_SHOW_FOLDERS, String.valueOf(fShowFolderInLabelsAction.isChecked()));
+    }
+
+       private IDialogSettings getDialogSettings() {
+               IDialogSettings ds= CUIPlugin.getDefault().getDialogSettings();
+               final String name = IBViewPart.class.getName();
+               IDialogSettings result= ds.getSection(name);
+               if (result == null) {
+                       result= ds.addNewSection(name);
+               }
+               return result;
+       }
+
+       private void createContextMenu() {
+        MenuManager manager = new MenuManager();
+        manager.setRemoveAllWhenShown(true);
+        manager.addMenuListener(new IMenuListener() {
+            public void menuAboutToShow(IMenuManager m) {
+                onContextMenuAboutToShow(m);
+            }
+        });
+        Menu menu = manager.createContextMenu(fTreeViewer.getControl());
+        fTreeViewer.getControl().setMenu(menu);
+        IWorkbenchPartSite site = getSite();
+        site.registerContextMenu(CUIPlugin.ID_INCLUDE_BROWSER, manager, fTreeViewer); 
+    }
+
+    private void createViewerPage() {
+        Display display= getSite().getShell().getDisplay();
+        fViewerPage = new Composite(fPagebook, SWT.NULL);
+        fViewerPage.setLayoutData(new GridData(GridData.FILL_BOTH));
+        fViewerPage.setSize(100, 100);
+        fViewerPage.setLayout(new FillLayout());
+
+        fContentProvider= new IBContentProvider(display); 
+        fLabelProvider= new IBLabelProvider(display, fContentProvider);
+        fTreeViewer= new ExtendedTreeViewer(fViewerPage);
+        fTreeViewer.setUseHashlookup(true);
+        fTreeViewer.setContentProvider(fContentProvider);
+        fTreeViewer.setLabelProvider(fLabelProvider);
+        fTreeViewer.setAutoExpandLevel(2);     
+        fTreeViewer.addOpenListener(new IOpenListener() {
+            public void open(OpenEvent event) {
+                onShowInclude(event.getSelection());
+            }
+        });
+    }
+    
+    private void createInfoPage() {
+       fInfoText = new Label(fPagebook, SWT.TOP | SWT.LEFT | SWT.WRAP);
+    }
+
+    private void initDragAndDrop() {
+        IBDropTargetListener dropListener= new IBDropTargetListener(this);
+        Transfer[] dropTransfers= new Transfer[] {
+                LocalSelectionTransfer.getTransfer(),
+                ResourceTransfer.getInstance(), 
+                FileTransfer.getInstance()};
+        DropTarget dropTarget = new DropTarget(fPagebook, DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT);
+        dropTarget.setTransfer(dropTransfers);
+        dropTarget.addDropListener(dropListener);
+
+        Transfer[] dragTransfers= new Transfer[] {
+                ResourceTransfer.getInstance(), 
+                FileTransfer.getInstance()};
+        IBDragSourceListener dragListener= new IBDragSourceListener(fTreeViewer);
+        dragListener.setDependentDropTargetListener(dropListener);
+        fTreeViewer.addDragSupport(DND.DROP_COPY, dragTransfers, dragListener);
+    }
+
+    private void createActions() {
+        fWorkingSetFilterUI= new WorkingSetFilterUI(this, fMemento, KEY_WORKING_SET_FILTER) {
+            @Override
+                       protected void onWorkingSetChange() {
+                updateWorkingSetFilter(this);
+            }
+            @Override
+                       protected void onWorkingSetNameChange() {
+                updateDescription();
+            }
+        }; 
+
+        fIncludedByAction= 
+            new Action(IBMessages.IBViewPart_showIncludedBy_label, IAction.AS_RADIO_BUTTON) { 
+                @Override
+                               public void run() {
+                    if (isChecked()) {
+                        onSetDirection(true);
+                    }
+                }
+        };
+        fIncludedByAction.setToolTipText(IBMessages.IBViewPart_showIncludedBy_tooltip);
+        CPluginImages.setImageDescriptors(fIncludedByAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_REF_BY);       
+
+        fIncludesToAction= 
+            new Action(IBMessages.IBViewPart_showIncludesTo_label, IAction.AS_RADIO_BUTTON) { 
+                @Override
+                               public void run() {
+                    if (isChecked()) {
+                        onSetDirection(false);
+                    }
+                }
+        };
+        fIncludesToAction.setToolTipText(IBMessages.IBViewPart_showIncludesTo_tooltip);
+        CPluginImages.setImageDescriptors(fIncludesToAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_RELATES_TO);       
+
+        fInactiveFilter= new ViewerFilter() {
+            @Override
+                       public boolean select(Viewer viewer, Object parentElement, Object element) {
+                if (element instanceof IBNode) {
+                    IBNode node= (IBNode) element;
+                    return node.isActiveCode();
+                }
+                return true;
+            }
+        };
+        fFilterInactiveAction= new Action(IBMessages.IBViewPart_hideInactive_label, IAction.AS_CHECK_BOX) {
+            @Override
+                       public void run() {
+                if (isChecked()) {
+                    fTreeViewer.addFilter(fInactiveFilter);
+                }
+                else {
+                    fTreeViewer.removeFilter(fInactiveFilter);
+                }
+            }
+        };
+        fFilterInactiveAction.setToolTipText(IBMessages.IBViewPart_hideInactive_tooltip);
+        CPluginImages.setImageDescriptors(fFilterInactiveAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_INACTIVE);       
+
+        fSystemFilter= new ViewerFilter() {
+            @Override
+                       public boolean select(Viewer viewer, Object parentElement, Object element) {
+                if (element instanceof IBNode) {
+                    IBNode node= (IBNode) element;
+                    return !node.isSystemInclude();
+                }
+                return true;
+            }
+        };
+        fFilterSystemAction= new Action(IBMessages.IBViewPart_hideSystem_label, IAction.AS_CHECK_BOX) {
+            @Override
+                       public void run() {
+                if (isChecked()) {
+                    fTreeViewer.addFilter(fSystemFilter);
+                }
+                else {
+                    fTreeViewer.removeFilter(fSystemFilter);
+                }
+            }
+        };
+        fFilterSystemAction.setToolTipText(IBMessages.IBViewPart_hideSystem_tooltip);
+        CPluginImages.setImageDescriptors(fFilterSystemAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_SYSTEM);       
+        
+        fSorterAlphaNumeric= new ViewerComparator();
+        fSorterReferencePosition= new ViewerComparator() {
+            @Override
+                       public int category(Object element) {
+                if (element instanceof IBNode) {
+                    return 0;
+                }
+                return 1;
+            }
+            @Override
+                       public int compare(Viewer viewer, Object e1, Object e2) {
+                if (!(e1 instanceof IBNode)) {
+                    if (!(e2 instanceof IBNode)) {
+                        return 0;
+                    }
+                    return -1;
+                }
+                if (!(e2 instanceof IBNode)) {
+                    return 1;
+                }
+                IBNode n1= (IBNode) e1;
+                IBNode n2= (IBNode) e2;
+                return n1.getDirectiveCharacterOffset() - n2.getDirectiveCharacterOffset();
+            }
+        };
+        
+        fShowFolderInLabelsAction= new Action(IBMessages.IBViewPart_showFolders_label, IAction.AS_CHECK_BOX) {
+            @Override
+                       public void run() {
+                onShowFolderInLabels(isChecked());
+            }
+        };
+        fShowFolderInLabelsAction.setToolTipText(IBMessages.IBViewPart_showFolders_tooltip);
+        fNextAction = new Action(IBMessages.IBViewPart_nextMatch_label) {
+            @Override
+                       public void run() {
+                onNextOrPrevious(true);
+            }
+        };
+        fNextAction.setToolTipText(IBMessages.IBViewPart_nextMatch_tooltip); 
+        CPluginImages.setImageDescriptors(fNextAction, CPluginImages.T_LCL, CPluginImages.IMG_SHOW_NEXT);       
+
+        fPreviousAction = new Action(IBMessages.IBViewPart_previousMatch_label) {
+            @Override
+                       public void run() {
+                onNextOrPrevious(false);
+            }
+        };
+        fPreviousAction.setToolTipText(IBMessages.IBViewPart_previousMatch_tooltip); 
+        CPluginImages.setImageDescriptors(fPreviousAction, CPluginImages.T_LCL, CPluginImages.IMG_SHOW_PREV);       
+
+        fRefreshAction = new Action(IBMessages.IBViewPart_refresh_label) {
+            @Override
+                       public void run() {
+                onRefresh();
+            }
+        };
+        fRefreshAction.setToolTipText(IBMessages.IBViewPart_refresh_tooltip); 
+        CPluginImages.setImageDescriptors(fRefreshAction, CPluginImages.T_LCL, CPluginImages.IMG_REFRESH);       
+
+        fHistoryAction= new IBHistoryDropDownAction(this);
+        
+        // setup action bar
+        // global action hooks
+        IActionBars actionBars = getViewSite().getActionBars();
+        actionBars.setGlobalActionHandler(ActionFactory.NEXT.getId(), fNextAction);
+        actionBars.setGlobalActionHandler(ActionFactory.PREVIOUS.getId(), fPreviousAction);
+        actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), fRefreshAction);
+        actionBars.updateActionBars();
+        
+        // local toolbar
+        IToolBarManager tm = actionBars.getToolBarManager();
+        tm.add(fNextAction);
+        tm.add(fPreviousAction);
+        tm.add(new Separator());
+        tm.add(fFilterSystemAction);
+        tm.add(fFilterInactiveAction);
+        tm.add(new Separator());
+        tm.add(fIncludedByAction);
+        tm.add(fIncludesToAction);
+        tm.add(fHistoryAction);
+        tm.add(fRefreshAction);
+
+        // local menu
+        IMenuManager mm = actionBars.getMenuManager();
+
+        fWorkingSetFilterUI.fillActionBars(actionBars);
+        mm.add(fIncludedByAction);
+        mm.add(fIncludesToAction);
+        mm.add(new Separator());
+        mm.add(fShowFolderInLabelsAction);
+        mm.add(new Separator());
+        mm.add(fFilterSystemAction);
+        mm.add(fFilterInactiveAction);
+    }
+    
+    private IBNode getNextNode(boolean forward) {
+       TreeNavigator navigator= new TreeNavigator(fTreeViewer.getTree(), IBNode.class);
+       TreeItem selectedItem= navigator.getSelectedItemOrFirstOnLevel(1, forward);
+       if (selectedItem == null) {
+               return null;
+       }
+       
+        if (selectedItem.getData().equals(fLastNavigationNode)) {
+               selectedItem= navigator.getNextSibbling(selectedItem, forward);
+        }
+        
+        return selectedItem == null ? null : (IBNode) selectedItem.getData();
+    }
+        
+    protected void onNextOrPrevious(boolean forward) {
+       IBNode nextItem= getNextNode(forward);
+        if (nextItem != null) {
+            StructuredSelection sel= new StructuredSelection(nextItem);
+            fTreeViewer.setSelection(sel);
+            onShowInclude(sel);
+        }
+    }
+
+    protected void onRefresh() {
+        fContentProvider.recompute();
+    }
+    
+    protected void onShowFolderInLabels(boolean show) {
+        fLabelProvider.setShowFolders(show);
+        fTreeViewer.refresh();
+    }
+
+    private void updateHistory(ITranslationUnit input) {
+       if (input != null) {
+               fHistoryEntries.remove(input);
+               fHistoryEntries.add(0, input);
+               if (fHistoryEntries.size() > MAX_HISTORY_SIZE) {
+                       fHistoryEntries.remove(MAX_HISTORY_SIZE-1);
+               }
+       }
+       }
+
+    private void updateSorter() {
+        if (fIncludedByAction.isChecked()) {
+            fTreeViewer.setComparator(fSorterAlphaNumeric);
+        }
+        else {
+            fTreeViewer.setComparator(fSorterReferencePosition);
+        }
+    }
+    
+    private void updateDescription() {
+        String message= ""; //$NON-NLS-1$
+        if (!fShowsMessage) {
+               ITranslationUnit tu= getInput();
+            if (tu != null) {
+                IPath path= tu.getPath();
+                if (path != null) {
+                    String format, file, scope;
+                    
+                    file= path.lastSegment() + "(" + path.removeLastSegments(1) + ")";  //$NON-NLS-1$//$NON-NLS-2$
+                    if (fWorkingSetFilter == null) {
+                        scope= IBMessages.IBViewPart_workspaceScope;
+                    }
+                    else {
+                        scope= fWorkingSetFilter.getLabel();
+                    }
+                    
+                    if (fIncludedByAction.isChecked()) {
+                        format= IBMessages.IBViewPart_IncludedByContentDescription;
+                    }
+                    else {
+                        format= IBMessages.IBViewPart_IncludesToContentDescription;
+                    }
+                    message= Messages.format(format, file, scope);
+                }
+            }
+        }
+        setContentDescription(message);
+    }
+
+    private void updateWorkingSetFilter(WorkingSetFilterUI filterUI) {
+        if (filterUI.getWorkingSet() == null) {
+            if (fWorkingSetFilter != null) {
+                fTreeViewer.removeFilter(fWorkingSetFilter);
+                fWorkingSetFilter= null;
+            }
+        }
+        else {
+            if (fWorkingSetFilter != null) {
+                fTreeViewer.refresh();
+            }
+            else {
+                fWorkingSetFilter= new IBWorkingSetFilter(filterUI);
+                fTreeViewer.addFilter(fWorkingSetFilter);
+            }
+        }
+    }
+    
+    public void onSetDirection(boolean includedBy) {
+        if (includedBy != fContentProvider.getComputeIncludedBy()) {
+            Object input= fTreeViewer.getInput();
+            fTreeViewer.setInput(null);
+            fContentProvider.setComputeIncludedBy(includedBy);
+            updateSorter();
+            fTreeViewer.setInput(input);
+            updateDescription();
+        }
+    }
+
+    protected void onContextMenuAboutToShow(IMenuManager m) {
+        final IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
+        final IBNode node= IBConversions.selectionToNode(selection);
+        
+        if (node != null) {
+            final IWorkbenchPage page = getSite().getPage();
+            
+            // open include
+            if (node.getParent() != null && node.getDirectiveFile() != null) {
+                m.add(new Action(IBMessages.IBViewPart_showInclude_label) {
+                    @Override
+                                       public void run() {
+                        onShowInclude(selection);
+                    }
+                });
+            }
+
+            final ITranslationUnit tu= node.getRepresentedTranslationUnit();
+            if (tu != null) {
+                // open
+                OpenCElementAction ofa= new OpenCElementAction(page);
+                ofa.selectionChanged(selection);
+                m.add(ofa);
+
+                // show in
+                IMenuManager submenu= new MenuManager(IBMessages.IBViewPart_ShowInMenu_label);
+                submenu.add(ContributionItemFactory.VIEWS_SHOW_IN.create(getSite().getWorkbenchWindow()));
+                m.add(submenu);
+               if (node.getParent() != null) {
+                    m.add(new Separator());
+                       m.add(new Action(Messages.format(IBMessages.IBViewPart_FocusOn_label, tu.getPath().lastSegment())) {
+                               @Override
+                                               public void run() {
+                                       setInput(tu);
+                               }
+                       });
+               }
+
+            }
+        }
+        m.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
+    }
+    
+    protected void onShowInclude(ISelection selection) {
+        IBNode node= IBConversions.selectionToNode(selection);
+        if (node != null) {
+               fLastNavigationNode= node;
+
+            IWorkbenchPage page= getSite().getPage();
+               IBFile ibf= node.getDirectiveFile();
+            if (ibf != null) {
+                IRegion region= new Region(node.getDirectiveCharacterOffset(), node.getDirectiveLength());
+                long timestamp= node.getTimestamp();
+
+                IFile f= ibf.getResource();
+                if (f != null) {
+                       EditorOpener.open(page, f, region, timestamp);
+                }
+                else {
+                    IIndexFileLocation ifl = ibf.getLocation();
+                    if (ifl != null) {
+                       IPath location= IndexLocationFactory.getAbsolutePath(ifl);
+                       if (location != null) {
+                               EditorOpener.openExternalFile(page, location, region, timestamp);
+                       }
+                    }
+                }
+            }
+            else {
+               ITranslationUnit tu= IBConversions.selectionToTU(selection);
+               if (tu != null) {
+                       IResource r= tu.getResource();
+                       if (r != null) {
+                               OpenFileAction ofa= new OpenFileAction(page);
+                               ofa.selectionChanged((IStructuredSelection) selection);
+                               ofa.run();
+                       }
+               }
+            }
+        }
+    }
+
+    public ShowInContext getShowInContext() {
+        return new ShowInContext(null, IBConversions.nodeSelectionToRepresentedTUSelection(fTreeViewer.getSelection()));
+    }
+
+    public boolean show(ShowInContext context) {
+        ITranslationUnit tu= IBConversions.selectionToTU(context.getSelection());
+        if (tu == null) {
+            tu= IBConversions.objectToTU(context.getInput());
+            if (tu == null) {
+                setMessage(IBMessages.IBViewPart_falseInputMessage);
+                return false;
+            }
+        }
+
+        setInput(tu);
+        return true;
+    }
+    
+    public String[] getShowInTargetIds() {
+        return new String[] {
+                       ProjectExplorer.VIEW_ID, 
+                       IPageLayout.ID_PROJECT_EXPLORER
+        };
+    }
+
+    // access for tests
+       public TreeViewer getTreeViewer() {
+               return fTreeViewer;
+       }
+
+       public ITranslationUnit[] getHistoryEntries() {
+               return fHistoryEntries.toArray(new ITranslationUnit[fHistoryEntries.size()]);
+       }
+
+       public void setHistoryEntries(ITranslationUnit[] remaining) {
+               fHistoryEntries.clear();
+               fHistoryEntries.addAll(Arrays.asList(remaining));
+       }
+
+       public ITranslationUnit getInput() {
+        Object input= fTreeViewer.getInput();
+        if (input instanceof ITranslationUnit) {
+               return (ITranslationUnit) input;
+        }
+        return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBWorkingSetFilter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBWorkingSetFilter.java
new file mode 100644 (file)
index 0000000..b257a7b
--- /dev/null
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.includebrowser;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.ui.IWorkingSet;
+
+import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
+
+public class IBWorkingSetFilter extends ViewerFilter {
+
+    private WorkingSetFilterUI fWorkingSetFilter;
+    
+    public IBWorkingSetFilter(WorkingSetFilterUI wsFilter) {
+        fWorkingSetFilter= wsFilter;
+    }
+    
+    @Override
+       public boolean select(Viewer viewer, Object parentElement, Object element) {
+        if (parentElement instanceof IBNode && element instanceof IBNode) {
+            IBNode node= (IBNode) element;
+            if (!fWorkingSetFilter.isPartOfWorkingSet(node.getRepresentedTranslationUnit())) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    public WorkingSetFilterUI getUI() {
+        return fWorkingSetFilter;
+    }
+
+    public String getLabel() {
+        IWorkingSet ws= fWorkingSetFilter.getWorkingSet();
+        if (ws != null) {
+            return ws.getLabel();
+        }
+        return IBMessages.IBViewPart_workspaceScope;
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IncludeBrowserUI.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IncludeBrowserUI.java
new file mode 100644 (file)
index 0000000..cc81a59
--- /dev/null
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.includebrowser;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexFileLocation;
+import org.eclipse.cdt.core.index.IIndexInclude;
+import org.eclipse.cdt.core.model.CoreModelUtil;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IInclude;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
+import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
+
+public class IncludeBrowserUI {
+
+       public static void open(final IWorkbenchWindow window, final ICElement input) {
+        try {
+               ITranslationUnit tu= convertToTranslationUnit(input);
+               if (tu != null) {
+                       IWorkbenchPage page= window.getActivePage();
+                       IBViewPart result= (IBViewPart)page.showView(CUIPlugin.ID_INCLUDE_BROWSER);
+                       result.setInput(tu);
+               }
+        } catch (CoreException e) {
+            ExceptionHandler.handle(e, window.getShell(), IBMessages.OpenIncludeBrowserAction_label, null); 
+        } catch (InterruptedException e) {
+               Thread.currentThread().interrupt();
+               }
+    }
+
+       public static void open(final ITextEditor editor, final ITextSelection sel) {
+               if (editor != null) {
+                       ICElement inputCElement = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
+                       open (editor.getSite().getWorkbenchWindow(), inputCElement);
+               }
+    }
+
+    private static ITranslationUnit convertToTranslationUnit(ICElement input) throws CoreException, InterruptedException {
+       ITranslationUnit result= null;
+       if (input instanceof IInclude) {
+               result= findTargetTranslationUnit((IInclude) input);
+       }
+       if (result == null && input instanceof ISourceReference) {
+               result= ((ISourceReference) input).getTranslationUnit();
+       }
+               return result;
+       }
+
+       private static ITranslationUnit findTargetTranslationUnit(IInclude input) throws CoreException, InterruptedException {
+               ICProject project= input.getCProject();
+               if (project != null) {
+                       IIndex index= CCorePlugin.getIndexManager().getIndex(project);
+                       index.acquireReadLock();
+                       try {
+                               IIndexInclude include= IndexUI.elementToInclude(index, input);
+                               if (include != null) {
+                                       IIndexFileLocation loc= include.getIncludesLocation();
+                                       if (loc != null) {
+                                               return CoreModelUtil.findTranslationUnitForLocation(loc, project);
+                                       }
+                               }
+                       }
+                       finally {
+                               index.releaseReadLock();
+                       }
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/OpenIncludeBrowserAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/OpenIncludeBrowserAction.java
new file mode 100644 (file)
index 0000000..4e9bfd3
--- /dev/null
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.includebrowser;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.actions.SelectionDispatchAction;
+
+
+public class OpenIncludeBrowserAction extends SelectionDispatchAction {
+
+       private ITextEditor fEditor;
+
+       public OpenIncludeBrowserAction(IWorkbenchSite site) {
+               super(site);
+               setText(IBMessages.OpenIncludeBrowserAction_label);
+               setToolTipText(IBMessages.OpenIncludeBrowserAction_tooltip);
+       }
+       
+       public OpenIncludeBrowserAction(ITextEditor editor) {
+               this(editor.getSite());
+               fEditor= editor;
+               setEnabled(fEditor != null && CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput()) != null);
+       }
+
+       @Override
+       public void run(ITextSelection sel) {
+               IncludeBrowserUI.open(fEditor, sel);
+       }
+       
+       @Override
+       public void run(IStructuredSelection selection) {
+               if (!selection.isEmpty()) {
+                       Object selectedObject= selection.getFirstElement();
+                       ICElement elem= (ICElement) getAdapter(selectedObject, ICElement.class);
+                       if (elem != null) {
+                               IncludeBrowserUI.open(getSite().getWorkbenchWindow(), elem);
+                       }
+               }
+       }
+
+       @Override
+       public void selectionChanged(ITextSelection sel) {
+       }
+                       
+       @Override
+       public void selectionChanged(IStructuredSelection selection) {
+               if (selection.isEmpty()) {
+                       setEnabled(false);
+                       return;
+               }
+               
+               Object selectedObject= selection.getFirstElement();
+               ICElement elem= (ICElement) getAdapter(selectedObject, ICElement.class);
+               if (elem != null) {
+                       setEnabled(isValidElement(elem));
+               }
+               else {
+                       setEnabled(false);
+               }
+       }
+
+       private boolean isValidElement(ICElement elem) {
+               if (elem instanceof ISourceReference) {
+                       return true;
+               }
+               return false;
+       }
+
+       @SuppressWarnings("rawtypes")
+       private Object getAdapter(Object object, Class desiredClass) {
+               if (desiredClass.isInstance(object)) {
+                       return object;
+               }
+               if (object instanceof IAdaptable) {
+                       IAdaptable adaptable= (IAdaptable) object;
+                       return adaptable.getAdapter(desiredClass);
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/CountNodeAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/CountNodeAction.java
new file mode 100644 (file)
index 0000000..fd3cb1f
--- /dev/null
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 QNX Software Systems
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.indexview;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+
+import org.eclipse.cdt.core.dom.IPDOMNode;
+import org.eclipse.cdt.core.dom.IPDOMVisitor;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.CCoreInternals;
+import org.eclipse.cdt.internal.core.pdom.IPDOM;
+import org.eclipse.cdt.internal.core.pdom.PDOM;
+import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
+import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
+import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
+import org.eclipse.cdt.internal.core.pdom.dom.PDOMMacro;
+import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
+
+/**
+ * @author dschaefer
+ *
+ */
+public class CountNodeAction extends IndexAction {
+
+       public CountNodeAction(IndexView view, TreeViewer viewer) {
+               super(view, viewer, CUIPlugin.getResourceString("IndexView.CountSymbols.name")); //$NON-NLS-1$
+       }
+
+       @Override
+       public boolean valid() {
+               ISelection selection = viewer.getSelection();
+               if (!(selection instanceof IStructuredSelection))
+                       return false;
+               Object[] objs = ((IStructuredSelection)selection).toArray();
+               for (int i = 0; i < objs.length; ++i)
+                       if (objs[i] instanceof ICProject)
+                               return true;
+               return false;
+       }
+
+       static final int FILES = 0;
+       static final int MACROS = 1;
+       static final int SYMBOLS = 2;
+       static final int REFS = 3;
+       static final int DECLS = 4;
+       static final int DEFS = 5;
+       
+       @Override
+       public void run() {
+               final int[] count = new int[6];
+               
+               try {
+                       ISelection selection = viewer.getSelection();
+                       if (!(selection instanceof IStructuredSelection))
+                               return;
+
+                       Object[] objs = ((IStructuredSelection)selection).toArray();
+                       for (int i = 0; i < objs.length; ++i) {
+                               if (!(objs[i] instanceof ICProject))
+                                       continue;
+
+                               ICProject project = (ICProject)objs[i];
+                               IPDOM ipdom= CCoreInternals.getPDOMManager().getPDOM(project);
+                               if (!(ipdom instanceof PDOM)) {
+                                       continue;
+                               }
+                               final PDOM pdom = (PDOM) ipdom;
+                               //pdom.getDB().reportFreeBlocks();
+
+                               pdom.acquireReadLock();
+                               try {
+                                       pdom.getFileIndex().accept(new IBTreeVisitor() {
+                                               public int compare(long record) throws CoreException {
+                                                       return 0;
+                                               }
+
+                                               public boolean visit(long record) throws CoreException {
+                                                       if (record != 0) {
+                                                               PDOMFile file = PDOMFile.recreateFile(pdom, record);
+                                                               ++count[FILES];
+                                                               PDOMMacro macro = file.getFirstMacro();
+                                                               while (macro != null) {
+                                                                       ++count[MACROS];
+                                                                       macro = macro.getNextMacro();
+                                                               }
+                                                       }
+                                                       return true;
+                                               }
+                                       });
+                                       pdom.accept(new IPDOMVisitor() {
+                                               public boolean visit(IPDOMNode node)
+                                                               throws CoreException {
+                                                       ++count[SYMBOLS];
+                                                       if (node instanceof PDOMBinding) {
+                                                               PDOMBinding binding = (PDOMBinding) node;
+                                                               for (PDOMName name = binding
+                                                                               .getFirstReference(); name != null; name = name
+                                                                               .getNextInBinding())
+                                                                       ++count[REFS];
+                                                               for (PDOMName name = binding
+                                                                               .getFirstDeclaration(); name != null; name = name
+                                                                               .getNextInBinding())
+                                                                       ++count[DECLS];
+                                                               for (PDOMName name = binding
+                                                                               .getFirstDefinition(); name != null; name = name
+                                                                               .getNextInBinding())
+                                                                       ++count[DEFS];
+                                                       }
+                                                       return true;
+                                               }
+
+                                               public void leave(IPDOMNode node) throws CoreException {
+                                               }
+                                       });
+                               } finally {
+                                       pdom.releaseReadLock();
+                               }
+                       }
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               } catch (InterruptedException e) {
+                       Thread.currentThread().interrupt();
+                       return;
+               }
+               
+               MessageDialog.openInformation(null,
+                               CUIPlugin.getResourceString("IndexView.CountSymbols.title"), //$NON-NLS-1$
+                               CUIPlugin.getFormattedString("IndexView.CountSymbols.message", //$NON-NLS-1$
+                                               new String[] {
+                                                       String.valueOf(count[0]),
+                                                       String.valueOf(count[1]),
+                                                       String.valueOf(count[2]),
+                                                       String.valueOf(count[3]),
+                                                       String.valueOf(count[4]),
+                                                       String.valueOf(count[5])
+                                               }));
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/DiscardExternalDefsAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/DiscardExternalDefsAction.java
new file mode 100644 (file)
index 0000000..3f0413d
--- /dev/null
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM - Initial API and implementation
+ *    Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.indexview;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+
+
+/**
+ * @author David Daoust
+ *
+ */
+public class DiscardExternalDefsAction extends IndexAction {
+       public DiscardExternalDefsAction(TreeViewer viewer, IndexView view) {
+               super(view, viewer, CUIPlugin.getResourceString("IndexView.ToggleExternals.name"), IAction.AS_CHECK_BOX); //$NON-NLS-1$
+               setToolTipText(CUIPlugin.getResourceString("IndexView.ToggleExternals.tooltip")); //$NON-NLS-1$
+               CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "public_co.gif"); //$NON-NLS-1$    
+       }
+       
+       @Override
+       public void run() {
+               ISelection selection = viewer.getSelection();
+               if (!(selection instanceof IStructuredSelection))
+                       return;
+               indexView.toggleExternalDefs();
+       }
+       
+       @Override
+       public boolean valid() {
+               return false;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindDeclarationsAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindDeclarationsAction.java
new file mode 100644 (file)
index 0000000..6715736
--- /dev/null
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    QNX - Initial API and implementation
+ *    Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.indexview;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.search.ui.NewSearchUI;
+
+import org.eclipse.cdt.core.index.IIndexBinding;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.search.PDOMSearchQuery;
+
+/**
+ * @author Doug Schaefer
+ *
+ */
+public class FindDeclarationsAction extends IndexAction {
+
+       public FindDeclarationsAction(IndexView view, TreeViewer viewer) {
+               super(view, viewer, CUIPlugin.getResourceString("IndexView.findDeclarations.name")); //$NON-NLS-1$
+       }
+       
+       private IndexNode getBindingNode() {
+               ISelection selection = viewer.getSelection();
+               if (!(selection instanceof IStructuredSelection))
+                       return null;
+               Object[] objs = ((IStructuredSelection)selection).toArray();
+               if (objs.length == 1 && objs[0] instanceof IndexNode) {
+                       IndexNode node= (IndexNode) objs[0];
+                       if (node.fObject instanceof IIndexBinding) {
+                               return node;
+                       }
+               }
+               return null;
+       }
+       
+       @Override
+       public void run() {
+               IndexNode binding = getBindingNode();
+               if (binding != null) {
+                       ICProject cproject= binding.getProject();
+                       if (cproject != null) {
+                               IndexViewSearchQuery query = new IndexViewSearchQuery(
+                                               null,
+                                               cproject, indexView.getLastWriteAccess(cproject),
+                                               (IIndexBinding) binding.fObject, binding.fText,
+                                               PDOMSearchQuery.FIND_DECLARATIONS | PDOMSearchQuery.FIND_DEFINITIONS);
+
+                               NewSearchUI.activateSearchResultView();
+                               NewSearchUI.runQueryInBackground(query);
+                       }
+               }
+       }
+       
+       @Override
+       public boolean valid() {
+               return getBindingNode() != null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindReferencesAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/FindReferencesAction.java
new file mode 100644 (file)
index 0000000..2bb5bae
--- /dev/null
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    QNX - Initial API and implementation
+ *    Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.indexview;
+
+import org.eclipse.cdt.internal.ui.search.PDOMSearchQuery;
+
+import org.eclipse.cdt.core.index.IIndexBinding;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.search.ui.NewSearchUI;
+
+/**
+ * @author Doug Schaefer
+ *
+ */
+public class FindReferencesAction extends IndexAction {
+
+       public FindReferencesAction(IndexView view, TreeViewer viewer) {
+               super(view, viewer, CUIPlugin.getResourceString("IndexView.findReferences.name")); //$NON-NLS-1$
+       }
+
+       private IndexNode getBindingNode() {
+               ISelection selection = viewer.getSelection();
+               if (!(selection instanceof IStructuredSelection))
+                       return null;
+               Object[] objs = ((IStructuredSelection)selection).toArray();
+               if (objs.length == 1 && objs[0] instanceof IndexNode) {
+                       IndexNode node= (IndexNode) objs[0];
+                       if (node.fObject instanceof IIndexBinding) {
+                               return node;
+                       }
+               }
+               return null;
+       }
+       
+       @Override
+       public void run() {
+               IndexNode binding = getBindingNode();
+               if (binding != null) {
+                       ICProject cproject= binding.getProject();
+                       if (cproject != null) {
+                               IndexViewSearchQuery query = new IndexViewSearchQuery(
+                                               null,
+                                               cproject, indexView.getLastWriteAccess(cproject),
+                                               (IIndexBinding) binding.fObject, binding.fText,
+                                               PDOMSearchQuery.FIND_REFERENCES);
+
+                               NewSearchUI.activateSearchResultView();
+                               NewSearchUI.runQueryInBackground(query);
+                       }
+               }
+       }
+       
+       @Override
+       public boolean valid() {
+               return getBindingNode() != null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexAction.java
new file mode 100644 (file)
index 0000000..d401c19
--- /dev/null
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2007 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    QNX - Initial API and implementation
+ *    Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.indexview;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.TreeViewer;
+
+/**
+ * @author Doug Schaefer
+ * 
+ * Root class for Index View Actions. Add an check to make sure the
+ * action is valid with the current context.
+ */
+public abstract class IndexAction extends Action {
+
+       final protected IndexView indexView;
+       final protected TreeViewer viewer;
+       
+       protected IndexAction(IndexView view, TreeViewer viewer) {
+               super();
+               this.indexView= view;
+               this.viewer = viewer;
+       }
+
+       protected IndexAction(IndexView view, TreeViewer viewer, String text) {
+               super(text);
+               this.indexView= view;
+               this.viewer = viewer;
+       }
+
+       protected IndexAction(IndexView view, TreeViewer viewer, String text, ImageDescriptor image) {
+               super(text, image);
+               this.indexView= view;
+               this.viewer = viewer;
+       }
+
+       protected IndexAction(IndexView view, TreeViewer viewer, String text, int style) {
+               super(text, style);
+               this.indexView= view;
+               this.viewer = viewer;
+       }
+
+       public abstract boolean valid();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexLabelProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexLabelProvider.java
new file mode 100644 (file)
index 0000000..cc12058
--- /dev/null
@@ -0,0 +1,199 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    QNX - Initial API and implementation
+ *    Markus Schorn (Wind River Systems)
+ *    IBM Corporation
+ *    Andrew Ferguson (Symbian)
+ *    Bryan Wilkinson (QNX)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.indexview;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.core.dom.IPDOMNode;
+import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.ICompositeType;
+import org.eclipse.cdt.core.dom.ast.IEnumeration;
+import org.eclipse.cdt.core.dom.ast.IEnumerator;
+import org.eclipse.cdt.core.dom.ast.IFunction;
+import org.eclipse.cdt.core.dom.ast.ITypedef;
+import org.eclipse.cdt.core.dom.ast.IVariable;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
+import org.eclipse.cdt.core.model.ICContainer;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
+import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
+import org.eclipse.cdt.internal.core.pdom.dom.PDOMNamedNode;
+
+import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
+
+/**
+ * Common label provider for index based viewers.
+ * 
+ * @author Doug Schaefer
+ */
+public class IndexLabelProvider extends LabelProvider {
+       @Override
+       public String getText(Object element) {
+               if (element instanceof IndexNode) {
+                       return ((IndexNode) element).fText;
+               }
+               return super.getText(element);
+       }
+       
+       @Override
+       public Image getImage(Object element) {
+               if (element instanceof IndexNode) {
+                       return ((IndexNode) element).fImage;
+               }
+               ImageDescriptor desc= null;
+               if (element instanceof ICProject)
+                       desc = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_SEARCHPROJECT);
+               else if (element instanceof ICContainer)
+                       desc = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_SEARCHFOLDER);
+               else if (element instanceof ITranslationUnit) {
+                       ITranslationUnit tu = (ITranslationUnit)element;
+                       desc = tu.isHeaderUnit()
+                               ? CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT_HEADER)
+                               : CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT);
+               }
+               
+               if (desc != null)
+                       return CUIPlugin.getImageDescriptorRegistry().get(desc);
+               
+               return super.getImage(element);
+       }
+
+       public static String getText(IPDOMNode element) {
+               if (element instanceof PDOMNamedNode) {
+                       try {
+                               String result = ((PDOMNamedNode)element).getDBName().getString();
+
+                               if (element instanceof ICPPTemplateInstance) {
+                                       StringBuffer buffer = null;
+                                       if (element instanceof ICPPDeferredClassInstance) {
+                                               buffer = new StringBuffer("Dfrd: "); //$NON-NLS-1$
+                                       } else {
+                                               buffer = new StringBuffer("Inst: "); //$NON-NLS-1$      
+                                       }
+                                       buffer.append(result);
+                                       buffer.append('<');
+                                       ICPPTemplateArgument[] types = ((ICPPTemplateInstance) element).getTemplateArguments();
+                                       for (int i = 0; i < types.length; i++) {
+                                               if (i > 0)
+                                                       buffer.append(',');
+                                               buffer.append(ASTTypeUtil.getArgumentString(types[i], false));
+                                       }
+                                       buffer.append('>');
+                                       result = buffer.toString();
+                               } else if (element instanceof ICPPClassTemplatePartialSpecialization) {
+                                       StringBuffer buffer = new StringBuffer("Part: "); //$NON-NLS-1$
+                                       buffer.append(result);
+                                       buffer.append('<');
+                                       try {
+                                               ICPPTemplateArgument[] types = ((ICPPClassTemplatePartialSpecialization) element).getTemplateArguments();
+                                               for (int i = 0; i < types.length; i++) {
+                                                       if (i > 0)
+                                                               buffer.append(',');
+                                                       buffer.append(ASTTypeUtil.getArgumentString(types[i], false));
+                                               }
+                                       } catch (DOMException e) {
+                                               buffer.append(e.getProblem().toString());
+                                       }
+                                       buffer.append('>');
+                                       result = buffer.toString();
+                               } else if (element instanceof ICPPSpecialization) {
+                                       ICPPSpecialization spec = (ICPPSpecialization) element;
+                                       
+                                       StringBuffer buffer = null;
+                                       buffer = new StringBuffer("Spec: "); //$NON-NLS-1$
+                                       buffer.append(result);
+                                       
+                                       if (!(spec instanceof ICPPTemplateDefinition)
+                                                       && spec.getSpecializedBinding() instanceof ICPPTemplateDefinition) {
+                                               buffer.append('<');
+                                               buffer.append(((ICPPSpecialization) element).getTemplateParameterMap().toString());
+                                               buffer.append('>');
+                                       }
+                                       
+                                       result = buffer.toString();
+                               }
+                               
+                               /*
+                                * aftodo - Ideally here we'd call ASTTypeUtil.getType but
+                                * we don't currently store return types
+                                */
+                               if(element instanceof IFunction) {
+                                       result += " "+ASTTypeUtil.getParameterTypeString(((IFunction) element).getType()); //$NON-NLS-1$
+                               }
+                               
+                               return result;
+                       } catch (CoreException e) {
+                               return e.getMessage();
+                       }
+               } 
+               return ""; //$NON-NLS-1$
+       }
+       
+       public static Image getImage(IPDOMNode element) {
+               ImageDescriptor desc = null;
+       
+               if (element instanceof IVariable)
+                       desc = CElementImageProvider.getVariableImageDescriptor();
+               else if (element instanceof IFunction)
+                       desc = CElementImageProvider.getFunctionImageDescriptor();
+               else if (element instanceof ICPPClassType) {
+                       switch (((ICPPClassType)element).getKey()) {
+                       case ICPPClassType.k_class:
+                               desc = CElementImageProvider.getClassImageDescriptor();
+                               break;
+                       case ICompositeType.k_struct:
+                               desc = CElementImageProvider.getStructImageDescriptor();
+                               break;
+                       case ICompositeType.k_union:
+                               desc = CElementImageProvider.getUnionImageDescriptor();
+                               break;
+                       }
+               }
+               else if (element instanceof ICompositeType)
+                       desc = CElementImageProvider.getStructImageDescriptor();
+               else if (element instanceof ICPPNamespace)
+                       desc = CElementImageProvider.getNamespaceImageDescriptor();
+               else if (element instanceof IEnumeration)
+                       desc = CElementImageProvider.getEnumerationImageDescriptor();
+               else if (element instanceof IEnumerator)
+                       desc = CElementImageProvider.getEnumeratorImageDescriptor();
+               else if (element instanceof ITypedef)
+                       desc = CElementImageProvider.getTypedefImageDescriptor();
+               
+               if (desc != null)
+                       return CUIPlugin.getImageDescriptorRegistry().get(desc);
+               else if (element instanceof PDOMLinkage)
+                       return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT);
+
+               return null;
+       }
+       
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexNode.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexNode.java
new file mode 100644 (file)
index 0000000..ac281fe
--- /dev/null
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.indexview;
+
+import org.eclipse.swt.graphics.Image;
+
+import org.eclipse.cdt.core.dom.IPDOMNode;
+import org.eclipse.cdt.core.model.ICProject;
+
+class IndexNode {
+       Object fParent;
+       IPDOMNode fObject;
+       String fText;
+       Image fImage;
+       boolean fHasDeclarationInProject;
+       int fBindingKind= 0;
+       
+       public ICProject getProject() {
+               if (fParent instanceof IndexNode) {
+                       return ((IndexNode) fParent).getProject();
+               }
+               if (fParent instanceof ICProject) {
+                       return (ICProject) fParent;
+               }
+               return null;
+       }
+
+       @Override
+       public int hashCode() {
+               final int prime = 31;
+               int result = 1;
+               result = prime * result + ((fParent == null) ? 0 : fParent.hashCode());
+               result = prime * result + ((fText == null) ? 0 : fText.hashCode());
+               result = prime * result + fBindingKind;
+               return result;
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj)
+                       return true;
+               if (obj == null)
+                       return false;
+               if (getClass() != obj.getClass())
+                       return false;
+               final IndexNode other = (IndexNode) obj;
+               if (fBindingKind != other.fBindingKind) {
+                       return false;
+               }
+               if (fParent == null) {
+                       if (other.fParent != null)
+                               return false;
+               } else if (!fParent.equals(other.fParent))
+                       return false;
+               if (fText == null) {
+                       if (other.fText != null)
+                               return false;
+               } else if (!fText.equals(other.fText))
+                       return false;
+               return true;
+       }
+       
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexView.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexView.java
new file mode 100644 (file)
index 0000000..44720bd
--- /dev/null
@@ -0,0 +1,473 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    QNX - Initial API and implementation
+ *    Andrew Ferguson (Symbian)
+ *    Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.indexview;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.part.ViewPart;
+
+import org.eclipse.cdt.core.dom.IPDOMNode;
+import org.eclipse.cdt.core.dom.IPDOMVisitor;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ElementChangedEvent;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICElementDelta;
+import org.eclipse.cdt.core.model.ICModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IElementChangedListener;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.CCoreInternals;
+import org.eclipse.cdt.internal.core.pdom.IPDOM;
+import org.eclipse.cdt.internal.core.pdom.PDOM;
+import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
+import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
+import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
+
+import org.eclipse.cdt.internal.ui.viewsupport.AsyncTreeContentProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.ExtendedTreeViewer;
+
+/**
+ * @author Doug Schaefer
+ *
+ */
+public class IndexView extends ViewPart implements PDOM.IListener, IElementChangedListener {
+
+       private TreeViewer viewer;
+       private ToggleLinkingAction toggleLinkingAction;
+       private IndexAction countSymbolsAction;
+       private IndexAction discardExternalDefsAction;
+       private IndexAction openDefinitionAction;
+       private IndexAction findDeclarationsAction;
+       private IndexAction findReferencesAction;
+       Filter filter = new Filter();
+       public boolean isLinking = false;
+       private volatile boolean fUpdateRequested= false;
+       private Map<String, Long> fTimestampPerProject= new HashMap<String, Long>();
+       private IndexContentProvider contentProvider;
+
+       
+       public void toggleExternalDefs() {
+               filter.showExternalDefs = ! filter.showExternalDefs;
+               if (!filter.showExternalDefs) {
+                       viewer.addFilter(filter);
+               } else {
+                       viewer.removeFilter(filter);
+               }
+       }
+       
+       public void toggleLinking() {
+               isLinking = ! isLinking;
+               if (isLinking) {
+                       openDefinitionAction.run();
+               }
+       }
+       
+       /**
+        * Handles selection changed in viewer. Updates global actions. Links to
+        * editor (if option enabled)
+        */
+       void handleSelectionChanged(SelectionChangedEvent event) {
+               if (isLinking) {
+                       openDefinitionAction.run();
+               }
+       }
+       
+       private static class Filter extends ViewerFilter {
+               public boolean showExternalDefs = false;
+               @Override
+               public boolean select(Viewer viewer, Object parentElement, Object element) {
+                       if (element instanceof IndexNode) {
+                               IndexNode node= (IndexNode)element;
+                               return node.fHasDeclarationInProject;
+                       }
+                       return true;
+               }
+               public static boolean hasDeclarationInProject(IPDOMNode element) {
+                       if (element instanceof PDOMBinding) {
+                               try {
+                                       PDOMBinding binding = (PDOMBinding)element;
+                                       final PDOM pdom= binding.getPDOM();
+                                       IIndexName[] names= pdom.findNames(binding, IIndex.FIND_DECLARATIONS);
+                                       for (int i = 0; i < names.length; i++) {
+                                               IIndexName name = names[i];
+                                               if (name.getFile().getLocation().getFullPath() != null) {
+                                                       return true;
+                                               }
+                                       }
+                                       names= pdom.findNames(binding, IIndex.FIND_DEFINITIONS);
+                                       for (int i = 0; i < names.length; i++) {
+                                               IIndexName name = names[i];
+                                               if (name.getFile().getLocation().getFullPath() != null) {
+                                                       return true;
+                                               }
+                                       }
+                               } catch (CoreException e) {
+                                       CUIPlugin.log(e);
+                               }
+                       }
+                       else if (element instanceof PDOMLinkage) {
+                               return true;
+                       }
+                       return false;
+               }
+       }
+               
+       private static class Children implements IPDOMVisitor {
+               private ArrayList<IPDOMNode> fNodes;
+               public Children() {
+                       fNodes= new ArrayList<IPDOMNode>();
+               }
+               public boolean visit(IPDOMNode node) throws CoreException {
+                       fNodes.add(node);
+                       return false;
+               }
+               public void leave(IPDOMNode node) throws CoreException {
+               }
+               public IPDOMNode[] getNodes() {
+                       return fNodes.toArray(new IPDOMNode[fNodes.size()]);
+               }
+       }
+                       
+       private class IndexContentProvider extends AsyncTreeContentProvider {
+               public IndexContentProvider(Display disp) {
+                       super(disp);
+               }
+               
+               @Override
+               public Object getParent(Object element) {
+                       if (element instanceof IndexNode) {
+                               return ((IndexNode) element).fParent;
+                       }
+                       if (element instanceof ICElement) {
+                               return ((ICElement) element).getParent();
+                       }
+                       return null;
+               }
+
+               @Override
+               protected Object[] syncronouslyComputeChildren(Object parentElement) {
+                       if (parentElement instanceof ICModel) {
+                               ICModel element = (ICModel) parentElement;
+                               try {
+                                       return element.getCProjects();
+                               } catch (CModelException e) {
+                                       CUIPlugin.log(e);
+                                       return new Object[0];
+                               }
+                       }
+                       else if (parentElement instanceof IndexNode) {
+                               final IndexNode node= (IndexNode) parentElement;
+                               if (node.fObject instanceof PDOMBinding) {
+                                       final PDOMBinding binding= (PDOMBinding) node.fObject;
+                                       if (!binding.mayHaveChildren()) {
+                                               return new Object[0];
+                                       }
+                               }
+                       }
+                       // allow for async computation
+                       return null;
+               }
+
+
+               @Override
+               protected Object[] asyncronouslyComputeChildren(Object parentElement, IProgressMonitor monitor) {
+                       try {
+                               if (parentElement instanceof ICProject) {
+                                       ICProject cproject= (ICProject)parentElement;
+                                       if (!cproject.getProject().isOpen()) {
+                                               return new Object[0];
+                                       }
+                                       return computeChildren(cproject);
+                               }
+                               else if (parentElement instanceof IndexNode) {
+                                       IndexNode node= (IndexNode) parentElement;
+                                       ICProject cproject= node.getProject();
+                                       if (cproject != null && cproject.getProject().isOpen()) {
+                                               Long ts= fTimestampPerProject.get(cproject.getElementName());
+                                               IPDOM pdom= CCoreInternals.getPDOMManager().getPDOM(cproject);
+                                               pdom.acquireReadLock();
+                                               try {
+                                                       if (ts == null || ts.longValue() == pdom.getLastWriteAccess()) {
+                                                               return computeChildren(parentElement, node.fObject);
+                                                       }
+                                               }
+                                               finally {
+                                                       pdom.releaseReadLock();
+                                               }
+                                       }
+                               }
+                       } catch (CoreException e) {
+                               CUIPlugin.log(e);
+                       } catch (InterruptedException e) {
+                               Thread.currentThread().interrupt();
+                       }
+                       return new Object[0];
+               }
+
+               private Object[] computeChildren(ICProject cproject) throws CoreException, InterruptedException {
+                       IPDOM pdom = CCoreInternals.getPDOMManager().getPDOM(cproject);
+                       pdom.acquireReadLock();
+                       try {
+                               fTimestampPerProject.put(cproject.getElementName(), new Long(pdom.getLastWriteAccess()));
+                               IPDOMNode[] linkages= pdom.getLinkageImpls();
+                               if (linkages.length == 1) {
+                                       // Skip linkages in hierarchy if there is only one
+                                       return computeChildren(cproject, linkages[0]);
+                               }
+                               return wrap(cproject, linkages);
+                       }
+                       finally {
+                               pdom.releaseReadLock();
+                       }
+               }
+
+               private Object[] computeChildren(Object parent, IPDOMNode node) throws CoreException {
+                       Children collector = new Children();
+                       node.accept(collector);
+                       return wrap(parent, collector.getNodes());
+               }
+
+               private Object[] wrap(Object parent, IPDOMNode[] nodes) {
+                       if (nodes.length == 0) {
+                               return nodes;
+                       }
+                       IndexNode[] result= new IndexNode[nodes.length];
+                       for (int i = 0; i < result.length; i++) {
+                               final IndexNode indexNode = result[i]= new IndexNode();
+                               final IPDOMNode node= nodes[i];
+                               indexNode.fParent= parent;
+                               indexNode.fObject= node;
+                               indexNode.fText= IndexLabelProvider.getText(node);
+                               indexNode.fImage= IndexLabelProvider.getImage(node);
+                               indexNode.fHasDeclarationInProject= Filter.hasDeclarationInProject(node);
+                               if (node instanceof PDOMNode) {
+                                       indexNode.fBindingKind= ((PDOMNode) node).getNodeType();
+                               }
+                       }
+                       return result;
+               }
+       }
+       
+       @Override
+       public void createPartControl(Composite parent) {
+               viewer = new ExtendedTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+               contentProvider= new IndexContentProvider(getSite().getShell().getDisplay());
+               viewer.setContentProvider(contentProvider);
+               viewer.setLabelProvider(new IndexLabelProvider());
+               viewer.setUseHashlookup(true);
+               
+               ICModel model = CoreModel.getDefault().getCModel();
+               viewer.setInput(model);
+               viewer.addFilter(filter);
+               try {
+                       ICProject[] projects = model.getCProjects();
+                       for (int i = 0; i < projects.length; ++i) {
+                               IPDOM pdom = CCoreInternals.getPDOMManager().getPDOM(projects[i]); 
+                               pdom.addListener(this);
+                       }
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }
+               CoreModel.getDefault().addElementChangedListener(this);
+               
+               makeActions();
+               hookContextMenu();
+               hookDoubleClickAction();
+               contributeToActionBars();
+               
+               // Menu
+        MenuManager menuMgr = new MenuManager();
+        menuMgr.setRemoveAllWhenShown(true);
+        menuMgr.addMenuListener(new IMenuListener() {
+            private void hideMenuItems(IMenuManager manager) {
+            }
+
+            public void menuAboutToShow(IMenuManager manager) {
+                IndexView.this.fillContextMenu(manager);
+                hideMenuItems(manager);
+            }
+        });
+        Menu menu = menuMgr.createContextMenu(viewer.getControl());
+        viewer.getControl().setMenu(menu);
+        getSite().registerContextMenu(menuMgr, viewer);
+        
+        getSite().setSelectionProvider(viewer);
+               viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+                       public void selectionChanged(SelectionChangedEvent event) {
+                               handleSelectionChanged(event);
+                       }
+               });
+       }
+       
+       @Override
+       public void dispose() {
+               super.dispose();
+               ICModel model = CoreModel.getDefault().getCModel();
+               try {
+                       ICProject[] projects = model.getCProjects();
+                       for (int i = 0; i < projects.length; ++i) {
+                               IPDOM pdom = CCoreInternals.getPDOMManager().getPDOM(projects[i]); 
+                               pdom.removeListener(this);
+                       }
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }
+               CoreModel.getDefault().removeElementChangedListener(this);
+       }
+       
+       private void makeActions() {
+               countSymbolsAction = new CountNodeAction(this, viewer);
+               discardExternalDefsAction = new DiscardExternalDefsAction(viewer, this);
+               toggleLinkingAction = new ToggleLinkingAction(this);
+               openDefinitionAction = new OpenDefinitionAction(this, viewer);
+               findDeclarationsAction = new FindDeclarationsAction(this, viewer);
+               findReferencesAction = new FindReferencesAction(this, viewer);
+       }
+
+       private void hookContextMenu() {
+               MenuManager menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
+               menuMgr.setRemoveAllWhenShown(true);
+               menuMgr.addMenuListener(new IMenuListener() {
+                       public void menuAboutToShow(IMenuManager manager) {
+                               IndexView.this.fillContextMenu(manager);
+                       }
+               });
+               Menu menu = menuMgr.createContextMenu(viewer.getControl());
+               viewer.getControl().setMenu(menu);
+               getSite().registerContextMenu(menuMgr, viewer);
+       }
+       
+       private void fillContextMenu(IMenuManager manager) {
+               if (countSymbolsAction.valid())
+                       manager.add(countSymbolsAction);
+               if (discardExternalDefsAction.valid())
+                       manager.add(discardExternalDefsAction);
+               if (openDefinitionAction.valid())
+                       manager.add(openDefinitionAction);
+               if (findDeclarationsAction.valid())
+                       manager.add(findDeclarationsAction);
+               if (findReferencesAction.valid())
+                       manager.add(findReferencesAction);
+               manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+       }
+       
+       private void hookDoubleClickAction() {
+               viewer.addDoubleClickListener(new IDoubleClickListener() {
+                       public void doubleClick(DoubleClickEvent event) {
+                               openDefinitionAction.run();
+                       }
+               });
+       }
+
+       private void contributeToActionBars() {
+               IActionBars bars = getViewSite().getActionBars();
+               //fillLocalPullDown(bars.getMenuManager());
+               fillLocalToolBar(bars.getToolBarManager());
+       }
+       
+       private void fillLocalToolBar(IToolBarManager manager) {
+//             drillDownAdapter.addNavigationActions(manager);
+               manager.add(toggleLinkingAction);
+               manager.add(discardExternalDefsAction);
+       }
+       
+       @Override
+       public void setFocus() {
+               viewer.getControl().setFocus();
+       }
+
+       public void handleChange(PDOM pdom, PDOM.ChangeEvent e) {
+               requestUpdate();
+       }
+
+       private void requestUpdate() {
+               if (!fUpdateRequested) {
+                       fUpdateRequested= true;
+                       viewer.getControl().getDisplay().asyncExec(new Runnable() {
+                               public void run() {
+                                       fUpdateRequested= false;
+                                       if (!viewer.getControl().isDisposed()) {
+                                               contentProvider.recompute();
+                                       }
+                               }
+                       });
+               }
+       }
+       
+       public void elementChanged(ElementChangedEvent event) {
+               // Only respond to post change events
+               if (event.getType() != ElementChangedEvent.POST_CHANGE)
+                       return;
+
+               // TODO we'll get fancier when we do a virtual tree.
+               processDelta(event.getDelta());
+       }
+       
+       private void processDelta(ICElementDelta delta) {
+               int type = delta.getElement().getElementType();
+               switch (type) {
+               case ICElement.C_MODEL:
+                       // Loop through the children
+                       ICElementDelta[] children = delta.getAffectedChildren();
+                       for (int i = 0; i < children.length; ++i)
+                               processDelta(children[i]);
+                       break;
+               case ICElement.C_PROJECT:
+                       switch (delta.getKind()) {
+                       case ICElementDelta.ADDED:
+                               try {
+                                       IPDOM pdom = CCoreInternals.getPDOMManager().getPDOM((ICProject)delta.getElement());
+                                       pdom.addListener(this);
+                                       handleChange(null, null);
+                               } catch (CoreException e) {
+                               }
+                               break;
+                       case ICElementDelta.REMOVED:
+                               handleChange(null, null);
+                               break;
+                       }
+               }
+       }
+
+       public long getLastWriteAccess(ICProject cproject) {
+               Long result= fTimestampPerProject.get(cproject.getElementName());
+               return result == null ? -1 : result.longValue();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexViewSearchQuery.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/IndexViewSearchQuery.java
new file mode 100644 (file)
index 0000000..bdd370a
--- /dev/null
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX - Initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.indexview;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexBinding;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.CCoreInternals;
+
+import org.eclipse.cdt.internal.ui.search.PDOMSearchQuery;
+
+/**
+ * @author Doug Schaefer
+ * 
+ * This is the search query to be used for searching the PDOM.
+ */
+public class IndexViewSearchQuery extends PDOMSearchQuery {
+
+       private IIndexBinding fBinding;
+       private long fLastWrite;
+       private String fName;
+       private ICProject fProject;
+       
+       public IndexViewSearchQuery(ICElement[] scope, ICProject project, long pdomLastWrite, IIndexBinding binding, String name, int flags) {
+               super(scope, flags);
+               fProject= project;
+               fBinding = binding;
+               fLastWrite= pdomLastWrite;
+               fName= name;
+       }
+       
+       @Override
+       public IStatus runWithIndex(IIndex index, IProgressMonitor monitor) throws OperationCanceledException {
+               try {
+                       if (CCoreInternals.getPDOMManager().getPDOM(fProject).getLastWriteAccess() == fLastWrite) {
+                               createMatches(index, fBinding);
+                       }
+                       return Status.OK_STATUS;
+               } catch (CoreException e) {
+                       return new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, e.getLocalizedMessage(), e);
+               }
+       }
+
+       @Override
+       public String getResultLabel(int numMatches) {
+               return super.getResultLabel(fName, numMatches);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/OpenDefinitionAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/OpenDefinitionAction.java
new file mode 100644 (file)
index 0000000..751ee9b
--- /dev/null
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    QNX - Initial API and implementation
+ *    Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.indexview;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexBinding;
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.core.index.IndexLocationFactory;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.CCoreInternals;
+
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+
+/**
+ * @author Doug Schaefer
+ *
+ */
+public class OpenDefinitionAction extends IndexAction {
+
+       public OpenDefinitionAction(IndexView view, TreeViewer viewer) {
+               super(view, viewer, CUIPlugin.getResourceString("IndexView.openDefinition.name"));//$NON-NLS-1$
+       }
+       
+       private IndexNode getBindingNode() {
+               ISelection selection = viewer.getSelection();
+               if (!(selection instanceof IStructuredSelection))
+                       return null;
+               Object[] objs = ((IStructuredSelection)selection).toArray();
+               if (objs.length == 1 && objs[0] instanceof IndexNode) {
+                       IndexNode node= (IndexNode) objs[0];
+                       if (node.fObject instanceof IIndexBinding) {
+                               return node;
+                       }
+               }
+               return null;
+       }
+
+       @Override
+       public void run() {
+               IndexNode bindingNode= getBindingNode();
+               if (bindingNode == null) {
+                       return;
+               }
+               try {
+                       ICProject cproject= bindingNode.getProject();
+                       if (cproject != null) {
+                               IIndex index= CCorePlugin.getIndexManager().getIndex(cproject);
+                               if (!openDefinition(cproject, bindingNode, index)) {
+                                       index= CCorePlugin.getIndexManager().getIndex(CoreModel.getDefault().getCModel().getCProjects());
+                                       openDefinition(cproject, bindingNode, index);
+                               }
+                       }
+               }
+               catch (CoreException e) {
+                       CUIPlugin.log(e);
+               } 
+               catch (InterruptedException e) {
+               }
+       }
+
+       private boolean openDefinition(ICProject cproject, IndexNode bindingNode, IIndex index) 
+                       throws InterruptedException, CoreException, CModelException, PartInitException {
+               index.acquireReadLock();
+               try {
+                       if (indexView.getLastWriteAccess(cproject) != CCoreInternals.getPDOMManager().getPDOM(cproject).getLastWriteAccess()) {
+                               return true;
+                       }
+                       IIndexName[] defs= index.findDefinitions((IIndexBinding) bindingNode.fObject);
+                       if (defs.length > 0) {
+                               showInEditor(defs[0]);
+                               return true;
+                       }
+                       defs= index.findDeclarations((IIndexBinding) bindingNode.fObject);
+                       if (defs.length > 0) {
+                               showInEditor(defs[0]);
+                               return true;
+                       }
+               } finally {
+                       index.releaseReadLock();
+               }
+               return false;
+       }
+
+       private void showInEditor(IIndexName name) throws CModelException, PartInitException, CoreException {
+               IPath path = IndexLocationFactory.getPath(name.getFile().getLocation());
+               if(path!=null) {
+                       IEditorPart editor = EditorUtility.openInEditor(path, null);
+                       if (editor != null && editor instanceof ITextEditor) {
+                               ITextEditor textEditor = (ITextEditor)editor;
+                               int nodeOffset = name.getNodeOffset();
+                               int nodeLength = name.getNodeLength();
+                               try {
+                                       if (nodeLength == -1) {
+                                               // This means the offset is actually a line number
+                                               IDocument document = textEditor.getDocumentProvider().getDocument(editor.getEditorInput());
+                                               nodeOffset = document.getLineOffset(nodeOffset);
+                                               nodeLength = document.getLineLength(nodeOffset);
+                                       } 
+                                       textEditor.selectAndReveal(nodeOffset, nodeLength);
+                               } catch (BadLocationException e) {
+                                       CUIPlugin.log(e);
+                               }
+                       }
+               }
+       }
+       
+       @Override
+       public boolean valid() {
+               return getBindingNode() != null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/ToggleLinkingAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/indexview/ToggleLinkingAction.java
new file mode 100644 (file)
index 0000000..8171a53
--- /dev/null
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.indexview;
+
+import org.eclipse.cdt.internal.ui.actions.AbstractToggleLinkingAction;
+
+/**
+ * This action toggles whether this navigator links its selection to the active
+ * editor.
+ * 
+ */
+public class ToggleLinkingAction extends AbstractToggleLinkingAction {
+       
+    IndexView fCView;
+    
+       /**
+        * Constructs a new action.
+        */
+       public ToggleLinkingAction(IndexView cView) {
+               fCView = cView;
+               setChecked(cView.isLinking);
+       }
+
+       /**
+        * Runs the action.
+        */
+       @Override
+       public void run() {
+           fCView.toggleLinking();
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ContentTypeMappingDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ContentTypeMappingDialog.java
new file mode 100644 (file)
index 0000000..801d82f
--- /dev/null
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ *  Copyright (c) 2007, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.language;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.LanguageManager;
+
+import org.eclipse.cdt.internal.ui.preferences.PreferencesMessages;
+
+public abstract class ContentTypeMappingDialog extends Dialog {
+
+       Combo fContentType;
+       Combo fLanguage;
+       String fSelectedContentTypeName;
+       String fSelectedContentTypeID;
+       String fSelectedLanguageName;
+       String fSelectedLanguageID;
+       String fSelectedConfigurationID;
+       String fSelectedConfigurationName;
+       Map<String, String> fContentTypeNamesToIDsMap;
+       Map<String, String> fLanguageNamesToIDsMap;
+
+       public ContentTypeMappingDialog(Shell parentShell) {
+               super(parentShell);
+               fContentTypeNamesToIDsMap = new HashMap<String, String>();
+               fLanguageNamesToIDsMap = new HashMap<String, String>();
+       }
+
+       public String getSelectedContentTypeName() {
+               return fSelectedContentTypeName;
+       }
+
+       public String getContentTypeID() {
+               return fSelectedContentTypeID;
+       }
+
+       public String getSelectedLanguageName() {
+               return fSelectedLanguageName;
+       }
+
+       public String getLanguageID() {
+               return fSelectedLanguageID;
+       }
+
+       @Override
+       protected void configureShell(Shell newShell) {
+               super.configureShell(newShell);
+               newShell.setText(PreferencesMessages.ContentTypeMappingsDialog_title);
+       }
+
+       @Override
+       protected void createButtonsForButtonBar(Composite parent) {
+               createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,
+                               true);
+               createButton(parent, IDialogConstants.CANCEL_ID,
+                               IDialogConstants.CANCEL_LABEL, false);
+
+               getButton(IDialogConstants.OK_ID).setEnabled(false);
+       }
+
+       protected String[] getLanguages() {
+               ILanguage[] languages = LanguageManager.getInstance()
+                               .getRegisteredLanguages();
+               String[] descriptions = new String[languages.length];
+               
+               for (int i = 0; i < descriptions.length; i++) {
+                       descriptions[i] = languages[i].getName();
+                       fLanguageNamesToIDsMap.put(descriptions[i], languages[i].getId());
+               }
+               Arrays.sort(descriptions);
+               return descriptions;
+       }
+
+       protected abstract boolean isValidSelection();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/FileLanguageMappingPropertyPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/FileLanguageMappingPropertyPage.java
new file mode 100644 (file)
index 0000000..f1fa6c1
--- /dev/null
@@ -0,0 +1,427 @@
+/*******************************************************************************
+ *  Copyright (c) 2007, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *  IBM Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.language;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.jface.layout.TableColumnLayout;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleAdapter;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.custom.TableEditor;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+import org.eclipse.cdt.core.language.ProjectLanguageConfiguration;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.LanguageManager;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.CContentTypes;
+import org.eclipse.cdt.internal.core.Util;
+import org.eclipse.cdt.internal.core.language.LanguageMapping;
+import org.eclipse.cdt.internal.core.language.LanguageMappingResolver;
+
+import org.eclipse.cdt.internal.ui.preferences.PreferencesMessages;
+import org.eclipse.cdt.internal.ui.util.Messages;
+
+public class FileLanguageMappingPropertyPage extends PropertyPage {
+
+       private static final int MINIMUM_COLUMN_WIDTH = 150;
+       private static final int LANGUAGE_COLUMN = 1;
+       private static final int CONFIGURATION_COLUMN = 0;
+       
+       private static final int LANGUAGE_ID = 0;
+       private static final int LANGUAGE_NAME = 1;
+       
+       private static final String ALL_CONFIGURATIONS = ""; //$NON-NLS-1$
+       
+       private IContentType fContentType;
+       private Composite fContents;
+       private Table fTable;
+       private ILanguage[] fLanguages;
+       private Map<String, ILanguage> fLanguageIds;
+       private boolean fHasChanges;
+       
+       public FileLanguageMappingPropertyPage() {
+               super();
+               fLanguages = LanguageManager.getInstance().getRegisteredLanguages();
+               fLanguageIds = LanguageVerifier.computeAvailableLanguages();
+       }
+       
+       @Override
+       protected Control createContents(Composite parent) {
+               IFile file = getFile();
+               IProject project = file.getProject();
+               fContentType = CContentTypes.getContentType(project, file.getName());
+               
+               fContents = new Composite(parent, SWT.NONE);
+               fContents.setLayout(new GridLayout(2, false));
+
+               Label contentTypeLabel = new Label(fContents, SWT.NONE);
+               contentTypeLabel.setText(PreferencesMessages.FileLanguagesPropertyPage_contentTypeLabel);
+               contentTypeLabel.setLayoutData(new GridData(SWT.TRAIL, SWT.CENTER, false, false));
+               
+               Label contentTypeDescriptionLabel = new Label(fContents, SWT.NONE);
+               contentTypeDescriptionLabel.setText(fContentType.getName());
+               contentTypeDescriptionLabel.setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, false, false));
+               
+               try {
+                       createMappingTable(fContents, file);
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }
+               
+               Link link = new Link(fContents, SWT.NONE);
+               link.setText(PreferencesMessages.FileLanguagesPropertyPage_description);
+               link.addListener(SWT.Selection, new LanguageMappingLinkListener(parent.getShell(), project) {
+                       @Override
+                       protected void refresh() {
+                               try {
+                                       refreshMappings();
+                               } catch (CoreException e) {
+                                       CUIPlugin.log(e);
+                               }
+                       }
+               });
+               
+               link.setLayoutData(new GridData(SWT.LEAD, SWT.CENTER, false, false, 2, 1));
+               
+               fContents.pack();
+               return fContents;
+       }
+
+       private void createMappingTable(Composite contents, final IFile file) throws CoreException {
+               Composite tableParent = new Composite(contents, SWT.NONE);
+               tableParent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
+
+               fTable = new Table(tableParent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.FULL_SELECTION);
+               fTable.setHeaderVisible(true);
+               fTable.setLinesVisible(true);
+               fTable.getAccessible().addAccessibleListener(new AccessibleAdapter() {
+                       @Override
+                       public void getName(AccessibleEvent e) {
+                               e.result = PreferencesMessages.FileLanguagesPropertyPage_mappingTableTitle;
+                       }
+               });
+               fTable.setToolTipText(PreferencesMessages.FileLanguagesPropertyPage_mappingTableTitle);
+
+               TableColumn contentTypeColumn = new TableColumn(fTable, SWT.LEAD);
+               contentTypeColumn.setText(PreferencesMessages.FileLanguagesPropertyPage_configurationColumn);
+
+               TableColumn languageColumn = new TableColumn(fTable, SWT.LEAD);
+               languageColumn.setText(PreferencesMessages.ProjectLanguagesPropertyPage_languageColumn);
+
+               TableColumnLayout layout = new TableColumnLayout();
+               layout.setColumnData(contentTypeColumn, new ColumnWeightData(1, MINIMUM_COLUMN_WIDTH, true));
+               layout.setColumnData(languageColumn, new ColumnWeightData(1, MINIMUM_COLUMN_WIDTH, true));
+               tableParent.setLayout(layout);
+               
+               final TableEditor editor = new TableEditor(fTable);
+               editor.grabHorizontal = true;
+               editor.grabVertical = true;
+               editor.setColumn(LANGUAGE_COLUMN);
+               
+               final IProject project = file.getProject();
+
+               fTable.addListener(SWT.Selection, new Listener() {
+                       public void handleEvent(Event event) {
+                               Control oldEditor = editor.getEditor();
+                               if (oldEditor != null) {
+                                       oldEditor.dispose();
+                               }
+                               
+                               TableItem item = (TableItem) event.item;
+                               if (item == null) {
+                                       return;
+                               }
+
+                               LanguageTableData data = (LanguageTableData) item.getData();
+                               CCombo newEditor = new CCombo(fTable, SWT.READ_ONLY);
+                               populateLanguages(project, file, data.configuration, data.languageId, newEditor);
+                               
+                               newEditor.addListener(SWT.Selection, new Listener() {
+                                       public void handleEvent(Event event) {
+                                               CCombo combo = (CCombo) editor.getEditor();
+                                               int index = combo.getSelectionIndex();
+                                               if (index != -1) {
+                                                       TableItem item = editor.getItem();
+                                                       item.setText(LANGUAGE_COLUMN, combo.getText());
+                                                       
+                                                       String selectedLanguage = ((String[]) combo.getData())[index];
+                                                       LanguageTableData data = (LanguageTableData) item.getData();
+                                                       data.languageId = selectedLanguage;
+                                                       fHasChanges = true;
+                                                       
+                                                       try {
+                                                               refreshMappings();
+                                                       } catch (CoreException e) {
+                                                               CUIPlugin.log(e);
+                                                       }
+                                               }
+                                       }
+                               });
+                               
+                               newEditor.setFocus();
+                               editor.setEditor(newEditor, item, LANGUAGE_COLUMN);
+                       }
+               });
+               
+               populateLanguageTable(fTable);
+               refreshMappings();
+       }
+
+       private void populateLanguageTable(Table table) throws CoreException {
+               IFile file = getFile();
+               IProject project = file.getProject();
+               ICProjectDescription description = CoreModel.getDefault().getProjectDescription(project);
+               ICConfigurationDescription[] configurations = description.getConfigurations();
+               
+               TableItem defaultItem = new TableItem(table, SWT.NONE);
+               defaultItem.setText(CONFIGURATION_COLUMN, PreferencesMessages.FileLanguagesPropertyPage_defaultMapping);
+               
+               ProjectLanguageConfiguration config = LanguageManager.getInstance().getLanguageConfiguration(project);
+               
+               Set<String> missingLanguages = LanguageVerifier.removeMissingLanguages(config, description, fLanguageIds);
+               if (missingLanguages.size() > 0) {
+                       MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK);
+                       messageBox.setText(PreferencesMessages.LanguageMappings_missingLanguageTitle);
+                       String affectedLanguages = LanguageVerifier.computeAffectedLanguages(missingLanguages);
+                       messageBox.setMessage(Messages.format(PreferencesMessages.FileLanguagesPropertyPage_missingLanguage, affectedLanguages));
+                       messageBox.open();
+               }
+               
+               String defaultLanguageId = config.getLanguageForFile(null, file);
+               LanguageTableData defaultData = new LanguageTableData(null, defaultLanguageId );
+               defaultItem.setData(defaultData);
+               
+               for (int i = 0; i < configurations.length; i++) {
+                       TableItem item = new TableItem(table, SWT.NONE);
+                       item.setText(CONFIGURATION_COLUMN, configurations[i].getName());
+                       String languageId = config.getLanguageForFile(configurations[i], file);
+                       
+                       if (languageId != null) {
+                               ILanguage language = fLanguageIds.get(languageId);
+                               String languageName =  language.getName();
+                               item.setText(LANGUAGE_COLUMN, languageName);
+                       }
+                       
+                       LanguageTableData data = new LanguageTableData(configurations[i], languageId);
+                       item.setData(data);
+               }
+       }
+
+       private void populateLanguages(IProject project, IFile file, ICConfigurationDescription configuration, String selectedLanguage, CCombo combo) {
+               try {
+                       String[][] languageInfo = getLanguages(project, file, configuration);
+                       combo.setItems(languageInfo[LANGUAGE_NAME]);
+                       combo.setData(languageInfo[LANGUAGE_ID]);
+                       
+                       findSelection(configuration, selectedLanguage, combo);
+                       fContents.layout();
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }
+       }
+       
+       private void refreshMappings() throws CoreException {
+               IFile file = getFile();
+               IProject project = file.getProject();
+               
+               LanguageManager manager = LanguageManager.getInstance();
+               TableItem[] items = fTable.getItems();
+               for (int i = 0; i < items.length; i++) {
+                       TableItem item = items[i];
+                       LanguageTableData data = (LanguageTableData) item.getData();
+                       if (data.languageId == null) {
+                               LanguageMapping mapping = computeInheritedMapping(project, file, data.configuration);
+                               item.setText(LANGUAGE_COLUMN, computeInheritedFrom(data.configuration, mapping));
+                       } else {
+                               ILanguage language = manager.getLanguage(data.languageId);
+                               item.setText(LANGUAGE_COLUMN, language.getName());
+                       }
+               }
+       }
+
+       private void findSelection(ICConfigurationDescription configuration, String languageId, CCombo combo) throws CoreException {
+//             if (languageId == null) {
+//                     TableItem[] items = fTable.getItems();
+//                     for (int i = 0; i < items.length; i++) {
+//                             LanguageTableData data = (LanguageTableData) items[i].getData();
+//                             if (configuration == null && data.configuration == null) {
+//                                     languageId = data.languageId;
+//                                     break;
+//                             } else if (configuration != null && data.configuration != null) {
+//                                     languageId = data.languageId;
+//                                     break;
+//                             }
+//                     }
+//             }
+               
+               if (languageId == null) {
+                       // No mapping was defined so we'll choose the default.
+                       combo.select(0);
+                       return;
+               }
+               
+               LanguageManager manager = LanguageManager.getInstance();
+               ILanguage language = manager.getLanguage(languageId);
+               String name = language.getName();
+               
+               for (int i = 1; i < combo.getItemCount(); i++) {
+                       if (name.equals(combo.getItem(i))) {
+                               combo.select(i);
+                               return;
+                       }
+               }
+               
+               // Couldn't find the mapping so we'll choose the default.
+               combo.select(0);
+       }
+
+       @Override
+       public boolean performOk() {
+               try {
+                       if (!fHasChanges) {
+                               return true;
+                       }
+                       
+                       IFile file = getFile();
+                       IProject project = file.getProject();
+                       LanguageManager manager = LanguageManager.getInstance();
+                       ProjectLanguageConfiguration config = manager.getLanguageConfiguration(project);
+                       
+                       Map<String, String> mappings = new TreeMap<String, String>();
+                       TableItem[] items = fTable.getItems();
+                       for (int i = 0; i < items.length; i++) {
+                               TableItem item = items[i];
+                               LanguageTableData data = (LanguageTableData) item.getData();
+                               if (data.languageId == null) {
+                                       continue;
+                               }
+                               String configurationId;
+                               if (data.configuration == null) {
+                                       configurationId = ALL_CONFIGURATIONS;
+                               } else {
+                                       configurationId = data.configuration.getId();
+                               }
+                               mappings.put(configurationId, data.languageId);
+                       }
+                       config.setFileMappings(file, mappings);
+                       manager.storeLanguageMappingConfiguration(file);
+                       fHasChanges = false;
+                       return true;
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+                       return false;
+               }
+       }
+       
+       private IFile getFile() {
+               return (IFile) getElement().getAdapter(IFile.class);
+       }
+
+       @Override
+       protected void performDefaults() {
+               super.performDefaults();
+       }
+       
+       private String computeInheritedFrom(ICConfigurationDescription configuration, LanguageMapping mapping) throws CoreException {
+               String inheritedFrom;
+               ILanguage language;
+               
+               LanguageTableData data = (LanguageTableData) fTable.getItem(0).getData();
+               if (configuration != null && data.languageId != null) {
+                       inheritedFrom = PreferencesMessages.FileLanguagesPropertyPage_inheritedFromFile;
+                       language = LanguageManager.getInstance().getLanguage(data.languageId);
+               } else {
+                       language = mapping.language;
+                       switch (mapping.inheritedFrom) {
+                       case LanguageMappingResolver.DEFAULT_MAPPING:
+                               inheritedFrom = PreferencesMessages.FileLanguagesPropertyPage_inheritedFromSystem;
+                               break;
+                       case LanguageMappingResolver.PROJECT_MAPPING:
+                               inheritedFrom = PreferencesMessages.FileLanguagesPropertyPage_inheritedFromProject;
+                               break;
+                       case LanguageMappingResolver.WORKSPACE_MAPPING:
+                               inheritedFrom = PreferencesMessages.FileLanguagesPropertyPage_inheritedFromWorkspace;
+                               break;
+                       default:
+                               throw new CoreException(Util.createStatus(new IllegalArgumentException()));
+                       }
+               }
+               return Messages.format(inheritedFrom, language.getName());
+       }
+       
+       private LanguageMapping computeInheritedMapping(IProject project, IFile file, ICConfigurationDescription configuration) throws CoreException {
+               LanguageMapping mappings[] = LanguageMappingResolver.computeLanguage(project, file.getProjectRelativePath().toPortableString(), configuration, fContentType.getId(), true);
+               LanguageMapping inheritedMapping = mappings[0];
+               
+               // Skip over the file mapping because we want to know what mapping the file
+               // mapping overrides.
+               if (inheritedMapping.inheritedFrom == LanguageMappingResolver.FILE_MAPPING ) {
+                       inheritedMapping = mappings[1];
+               }
+               
+               return inheritedMapping;
+       }
+       
+       private String[][] getLanguages(IProject project, IFile file, ICConfigurationDescription configuration) throws CoreException {
+               String[][] descriptions = new String[2][fLanguages.length + 1];
+               
+               LanguageMapping inheritedMapping = computeInheritedMapping(project, file, configuration);
+               
+               int index = 0;
+               descriptions[LANGUAGE_ID][index] = null;
+               descriptions[LANGUAGE_NAME][index] = computeInheritedFrom(configuration, inheritedMapping);
+
+               index++;
+               for (int i = 0; i < fLanguages.length; i++) {
+                       descriptions[LANGUAGE_ID][index] = fLanguages[i].getId();
+                       descriptions[LANGUAGE_NAME][index] = fLanguages[i].getName();
+                       index++;
+               }
+               return descriptions;
+       }
+       
+       private static class LanguageTableData {
+               ICConfigurationDescription configuration;
+               String languageId;
+               
+               LanguageTableData(ICConfigurationDescription configuration, String languageId) {
+                       this.configuration = configuration;
+                       this.languageId = languageId;
+               }
+       }
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageMappingLinkListener.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageMappingLinkListener.java
new file mode 100644 (file)
index 0000000..6453cef
--- /dev/null
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.language;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+public class LanguageMappingLinkListener implements Listener {
+
+       private static final String WORKSPACE_PREFERENCE_PAGE = "org.eclipse.cdt.ui.preferences.LanguageMappings"; //$NON-NLS-1$
+       private static final String PROJECT_PROPERTY_PAGE = "org.eclipse.cdt.ui.projectLanguageMappings"; //$NON-NLS-1$
+       
+       private static final String WORKSPACE_LINK = "workspace"; //$NON-NLS-1$
+       private static final String PROJECT_LINK = "project"; //$NON-NLS-1$
+       
+       private Shell fShell;
+       private IAdaptable fElement;
+
+       public LanguageMappingLinkListener(Shell shell, IAdaptable element) {
+               fShell = shell;
+               fElement = element;
+       }
+
+       public void handleEvent(Event event) {
+               if (WORKSPACE_LINK.equals(event.text)) {
+                       PreferencesUtil.createPreferenceDialogOn(fShell, WORKSPACE_PREFERENCE_PAGE, null, null).open();
+               } else if (PROJECT_LINK.equals(event.text)) {
+                       PreferencesUtil.createPropertyDialogOn(fShell, fElement, PROJECT_PROPERTY_PAGE, null, null).open();
+               }
+               refresh();
+       }
+
+       protected void refresh() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageMappingWidget.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageMappingWidget.java
new file mode 100644 (file)
index 0000000..f62317e
--- /dev/null
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.language;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.core.runtime.content.IContentTypeManager;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Table;
+
+import org.eclipse.cdt.core.model.LanguageManager;
+
+public abstract class LanguageMappingWidget {
+
+       protected static final int MINIMUM_COLUMN_WIDTH = 150;
+       protected Composite fContents;
+       protected boolean fIsReadOnly;
+       
+       protected Table fTable;
+       protected HashMap<String, String> fContentTypeNamesToIDsMap;
+       protected Set<IContentType> fAffectedContentTypes;
+       protected Font fOverriddenFont;
+       protected LanguageMappingWidget fChild;
+       protected IAdaptable fElement;
+       
+       protected Set<String> fOverriddenContentTypes;
+       
+       private boolean fIsChanged;
+       
+       public LanguageMappingWidget() {
+               fOverriddenFont = JFaceResources.getFontRegistry().getItalic(JFaceResources.DIALOG_FONT);
+               fOverriddenContentTypes = Collections.emptySet();
+               
+               // keep a mapping of all registered content types and their names
+               fContentTypeNamesToIDsMap = new HashMap<String, String>();
+               String[] contentTypesIDs = LanguageManager.getInstance().getRegisteredContentTypeIds();
+
+               IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
+
+               for (int i = 0; i < contentTypesIDs.length; i++) {
+
+                       String name = contentTypeManager.getContentType(contentTypesIDs[i]).getName();
+
+                       // keep track of what ID this name corresponds to so that when we
+                       // setup the mapping
+                       // later based upon user selection, we'll know what ID to use
+                       fContentTypeNamesToIDsMap.put(name, contentTypesIDs[i]);
+               }
+
+               fAffectedContentTypes = new HashSet<IContentType>();
+       }
+
+       public IAdaptable getElement() {
+               return fElement;
+       }
+       
+       public void setElement(IAdaptable element) {
+               fElement = element;
+       }
+       
+       public void setOverriddenContentTypes(Set<String> contentTypes) {
+               fOverriddenContentTypes = contentTypes;
+       }
+       
+       public IContentType[] getAffectedContentTypes() {
+               return fAffectedContentTypes.toArray(new IContentType[fAffectedContentTypes.size()]);
+       }
+
+       public void setReadOnly(boolean isReadOnly) {
+               fIsReadOnly = isReadOnly;
+       }
+       
+       public void setChild(LanguageMappingWidget child) {
+               fChild = child;
+       }
+       
+       public boolean isChanged() {
+               return fIsChanged;
+       }
+
+       public void setChanged(boolean changed) {
+               fIsChanged = changed;
+       }
+       
+       protected void createHeader(Composite parent, String description) {
+               Link link = new Link(fContents, SWT.NONE);
+               link.setText(description);
+
+               link.addListener(SWT.Selection, new LanguageMappingLinkListener(fContents.getShell(), getElement()) {
+                       @Override
+                       protected void refresh() {
+                               refreshMappings();
+                       }
+               });
+
+               GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
+               gridData.widthHint = MINIMUM_COLUMN_WIDTH * 2;
+               gridData.horizontalSpan = 2;
+               link.setLayoutData(gridData);
+       }
+       
+       public abstract Composite createContents(Composite parent, String description);
+       public abstract void refreshMappings();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageVerifier.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageVerifier.java
new file mode 100644 (file)
index 0000000..59662f4
--- /dev/null
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.language;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.Map.Entry;
+
+import org.eclipse.cdt.core.language.ProjectLanguageConfiguration;
+import org.eclipse.cdt.core.language.WorkspaceLanguageConfiguration;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.LanguageManager;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+
+/**
+ * Analyzes and repairs language mapping configurations.
+ */
+public class LanguageVerifier {
+       
+       public static Map<String, ILanguage> computeAvailableLanguages() {
+               ILanguage[] registeredLanguages = LanguageManager.getInstance().getRegisteredLanguages();
+               Map<String, ILanguage> languages = new TreeMap<String, ILanguage>();
+               for (int i = 0; i < registeredLanguages.length; i++) {
+                       languages.put(registeredLanguages[i].getId(), registeredLanguages[i]);
+               }
+               return languages;
+       }
+       
+       public static String computeAffectedLanguages(Set<String> missingLanguages) {
+               Iterator<String> languages = missingLanguages.iterator();
+               StringBuffer buffer = new StringBuffer();
+               while (languages.hasNext()) {
+                       buffer.append('\n');
+                       buffer.append(languages.next());
+               }
+               return buffer.toString();
+       }
+
+       public static Set<String> removeMissingLanguages(ProjectLanguageConfiguration config, ICProjectDescription description, Map<String, ILanguage> availableLanguages) {
+               Set<String> missingLanguages = new TreeSet<String>();
+               
+               // Check file mappings
+               Iterator<Entry<String, Map<String, String>>> fileConfigurationMappings = config.getFileMappings().entrySet().iterator();
+               while (fileConfigurationMappings.hasNext()) {
+                       Entry<String, Map<String, String>> entry = fileConfigurationMappings.next();
+                       String path = entry.getKey();
+                       Map<String, String> configurationLanguageMappings = entry.getValue();
+                       Iterator<Entry<String, String>> mappings = configurationLanguageMappings.entrySet().iterator();
+                       while (mappings.hasNext()) {
+                               Entry<String, String> mapping = mappings.next();
+                               String configurationId = mapping.getKey();
+                               String languageId = mapping.getValue();
+                               if (!availableLanguages.containsKey(languageId)) {
+                                       missingLanguages.add(languageId);
+                                       ICConfigurationDescription configuration = description.getConfigurationById(configurationId);
+                                       config.removeFileMapping(configuration, path);
+                               }
+                       }
+               }
+               
+               // Check content type mappings
+               Iterator<Entry<String, Map<String, String>>> configurationContentTypeMappings = config.getContentTypeMappings().entrySet().iterator();
+               while (configurationContentTypeMappings.hasNext()) {
+                       Entry<String, Map<String, String>> entry = configurationContentTypeMappings.next();
+                       String configurationId = entry.getKey();
+                       Map<String, String> contentTypeLanguageMappings = entry.getValue();
+                       Iterator<Entry<String, String>> mappings = contentTypeLanguageMappings.entrySet().iterator();
+                       while (mappings.hasNext()) {
+                               Entry<String, String> mapping = mappings.next();
+                               String contentTypeId = mapping.getKey();
+                               String languageId = mapping.getValue();
+                               if (!availableLanguages.containsKey(languageId)) {
+                                       missingLanguages.add(languageId);
+                                       ICConfigurationDescription configuration = description.getConfigurationById(configurationId);
+                                       config.removeContentTypeMapping(configuration, contentTypeId);
+                               }
+                       }
+               }
+               
+               return missingLanguages;
+       }
+
+       public static Set<String> removeMissingLanguages(WorkspaceLanguageConfiguration config, Map<String, ILanguage> availableLanguages) {
+               Set<String> missingLanguages = new TreeSet<String>();
+               
+               // Check content type mappings
+               Iterator<Entry<String, String>> contentTypeMappings = config.getWorkspaceMappings().entrySet().iterator();
+               while (contentTypeMappings.hasNext()) {
+                       Entry<String, String> entry = contentTypeMappings.next();
+                       String contentTypeId = entry.getKey();
+                       String languageId = entry.getValue();
+                       if (!availableLanguages.containsKey(languageId)) {
+                               missingLanguages.add(languageId);
+                               config.removeWorkspaceMapping(contentTypeId);
+                       }
+               }
+               
+               return missingLanguages;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectContentTypeMappingDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectContentTypeMappingDialog.java
new file mode 100644 (file)
index 0000000..a4d99ca
--- /dev/null
@@ -0,0 +1,171 @@
+/*******************************************************************************
+ *  Copyright (c) 2007, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *   IBM Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.language;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentTypeManager;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.cdt.core.model.LanguageManager;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+
+import org.eclipse.cdt.internal.ui.preferences.PreferencesMessages;
+
+public class ProjectContentTypeMappingDialog extends ContentTypeMappingDialog {
+       
+       private Combo fConfiguration;
+       private ICConfigurationDescription[] fConfigurations;
+       private String[] fContentTypesIDs;
+       private Set<String> fFilteredContentTypes;
+
+       public ProjectContentTypeMappingDialog(Shell parentShell, ICConfigurationDescription[] configurations) {
+               super(parentShell);
+               fConfigurations = configurations;
+               
+               fContentTypesIDs = LanguageManager.getInstance().getRegisteredContentTypeIds();
+               IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
+
+               for (int i = 0; i < fContentTypesIDs.length; i++) {
+                       String name = contentTypeManager.getContentType(fContentTypesIDs[i]).getName();
+                       
+                       // keep track of what ID this name corresponds to so that when
+                       // we setup the mapping
+                       // later based upon user selection, we'll know what ID to use
+                       fContentTypeNamesToIDsMap.put(name, fContentTypesIDs[i]);
+               }
+       }
+
+       private void configureConfigurations(Combo combo) {
+               combo.add(PreferencesMessages.ContentTypeMappingsDialog_allConfigurations);
+               for (int i = 0; i < fConfigurations.length; i++) {
+                       combo.add(fConfigurations[i].getName());
+               }
+       }
+
+       @Override
+       protected Control createDialogArea(Composite parent) {
+               Composite area = new Composite(parent, SWT.NONE);
+               area.setLayout(new GridLayout(2, false));
+
+               Label configurationLabel = new Label(area, SWT.TRAIL);
+               configurationLabel.setText(PreferencesMessages.ContentTypeMappingsDialog_configuration);
+               fConfiguration = new Combo(area, SWT.DROP_DOWN | SWT.READ_ONLY);
+               fConfiguration.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               configureConfigurations(fConfiguration);
+               fConfiguration.addListener(SWT.Selection, new Listener() {
+                       public void handleEvent(Event event) {
+                               int index = fConfiguration.getSelectionIndex();
+                               if (index <= 0) {
+                                       fSelectedConfigurationName = null;
+                                       fSelectedConfigurationID = null;
+                                       configureContentTypes(fContentType, null);
+                                       getButton(IDialogConstants.OK_ID).setEnabled(false);
+                                       return;
+                               }
+                               
+                               // Shift index by one because of "All configurations" entry. 
+                               int configurationIndex = index - 1;
+                               ICConfigurationDescription configuration = fConfigurations[configurationIndex];
+                               
+                               fSelectedConfigurationName = configuration.getName();
+                               fSelectedConfigurationID = configuration.getId();
+                               configureContentTypes(fContentType, configuration);
+
+                               getButton(IDialogConstants.OK_ID).setEnabled(isValidSelection());
+                       }
+               });
+               fConfiguration.select(0);
+               
+               Label contentTypeLabel = new Label(area, SWT.TRAIL);
+               contentTypeLabel.setText(PreferencesMessages.ContentTypeMappingsDialog_contentType);
+
+               fContentType = new Combo(area, SWT.DROP_DOWN | SWT.READ_ONLY);
+               fContentType.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               
+               fContentType.addListener(SWT.Selection, new Listener() {
+                       public void handleEvent(Event event) {
+                               fSelectedContentTypeName = fContentType.getText();
+                               fSelectedContentTypeID = fContentTypeNamesToIDsMap.get(fSelectedContentTypeName);
+                               getButton(IDialogConstants.OK_ID).setEnabled(isValidSelection());
+                       }
+               });
+               configureContentTypes(fContentType, null);
+
+               Label languageLabel = new Label(area, SWT.TRAIL);
+               languageLabel.setText(PreferencesMessages.ContentTypeMappingsDialog_language);
+
+               fLanguage = new Combo(area, SWT.DROP_DOWN | SWT.READ_ONLY);
+               fLanguage.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               fLanguage.setItems(getLanguages());
+               fLanguage.addListener(SWT.Selection, new Listener() {
+                       public void handleEvent(Event event) {
+                               fSelectedLanguageName = fLanguage.getText();
+                               fSelectedLanguageID = fLanguageNamesToIDsMap.get(fSelectedLanguageName);
+                               getButton(IDialogConstants.OK_ID).setEnabled(isValidSelection());
+                       }
+               });
+
+               return area;
+       }
+       
+       private void configureContentTypes(Combo combo, ICConfigurationDescription configuration) {
+               combo.removeAll();
+               IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
+               List<String> names = new LinkedList<String>();
+               
+               for (int i = 0; i < fContentTypesIDs.length; i++) {
+                       String contentTypeId = fContentTypesIDs[i];
+                       String name = contentTypeManager.getContentType(contentTypeId).getName();
+                       
+                       if (configuration != null) {
+                               String key = ProjectLanguageMappingWidget.createFilterKey(configuration.getId(), contentTypeId);
+                               if (!fFilteredContentTypes.contains(key)) {
+                                       names.add(name);
+                               }
+                       } else {
+                               names.add(name);
+                       }
+               }
+               
+               Collections.sort(names);
+               for(String name : names) {
+                       combo.add(name);
+               }
+       }
+
+       @Override
+       protected boolean isValidSelection() {
+               return fContentType.getSelectionIndex() != -1 && fLanguage.getSelectionIndex() != -1 && fConfiguration.getSelectionIndex() != -1;
+       }
+
+       public void setContentTypeFilter(Set<String> contentTypeFilter) {
+               fFilteredContentTypes = contentTypeFilter;
+       }
+
+       public String getConfigurationID() {
+               return fSelectedConfigurationID;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingPropertyPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingPropertyPage.java
new file mode 100644 (file)
index 0000000..3522cd6
--- /dev/null
@@ -0,0 +1,192 @@
+/*******************************************************************************
+ *  Copyright (c) 2007, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *  IBM Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.language;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+import org.eclipse.cdt.core.language.ProjectLanguageConfiguration;
+import org.eclipse.cdt.core.language.WorkspaceLanguageConfiguration;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.ILanguageMappingChangeEvent;
+import org.eclipse.cdt.core.model.ILanguageMappingChangeListener;
+import org.eclipse.cdt.core.model.LanguageManager;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.preferences.PreferencesMessages;
+import org.eclipse.cdt.internal.ui.util.Messages;
+
+public class ProjectLanguageMappingPropertyPage extends PropertyPage {
+
+       private ProjectLanguageMappingWidget fMappingWidget;
+       private WorkspaceLanguageMappingWidget fInheritedMappingWidget;
+       private ProjectLanguageConfiguration fMappings;
+       private ILanguageMappingChangeListener fInheritedMappingsChangeListener;
+       
+       public ProjectLanguageMappingPropertyPage() {
+               super();
+               fMappingWidget = new ProjectLanguageMappingWidget();
+               
+               fInheritedMappingWidget = new WorkspaceLanguageMappingWidget();
+               fInheritedMappingWidget.setReadOnly(true);
+               
+               fMappingWidget.setChild(fInheritedMappingWidget);
+       }
+
+       /**
+        * @see PreferencePage#createContents(Composite)
+        */
+       @Override
+       protected Control createContents(Composite parent) {
+               fMappingWidget.setElement(getProject());
+               
+               Composite contents = new Composite(parent, SWT.NONE);
+               contents.setLayout(new GridLayout(1, false));
+               
+               fetchMappings(getProject());
+               Composite contentTypeMappings = fMappingWidget.createContents(contents, PreferencesMessages.ProjectLanguagesPropertyPage_description);
+               contentTypeMappings.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               
+               Group group = new Group(contents, SWT.SHADOW_IN);
+               group.setText(PreferencesMessages.ProjectLanguagesPropertyPage_inheritedWorkspaceMappingsGroup);
+               group.setLayout(new FillLayout());
+               group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               
+               fetchWorkspaceMappings();
+               fInheritedMappingWidget.createContents(group, null);
+               fInheritedMappingsChangeListener = new ILanguageMappingChangeListener() {
+                       public void handleLanguageMappingChangeEvent(final ILanguageMappingChangeEvent event) {
+                               if (event.getType() == ILanguageMappingChangeEvent.TYPE_WORKSPACE) {
+                                       if (ProjectLanguageMappingPropertyPage.this.isControlCreated()) {
+                                               Display.getDefault().asyncExec(new Runnable() {
+                                                       public void run() {
+                                                               if (!ProjectLanguageMappingPropertyPage.this.getControl().isDisposed()) {
+                                                                       fetchWorkspaceMappings();
+                                                                       fInheritedMappingWidget.refreshMappings();
+                                                               }
+                                                       }
+                                               });
+                                       }
+                               }
+                               else if (event.getType() == ILanguageMappingChangeEvent.TYPE_PROJECT) {
+                                       if (ProjectLanguageMappingPropertyPage.this.isControlCreated()) {
+                                               Display.getDefault().asyncExec(new Runnable() {
+                                                       public void run() {
+                                                               if (!ProjectLanguageMappingPropertyPage.this.getControl().isDisposed()) {
+                                                                       fetchMappings(event.getProject());
+                                                                       fMappingWidget.refreshMappings();
+                                                               }
+                                                       }
+                                               });
+                                       }
+                               }
+                       }
+               };
+               LanguageManager.getInstance().registerLanguageChangeListener(fInheritedMappingsChangeListener);
+               
+               return contents;
+       }
+
+       private void fetchMappings(IProject project) {
+               try {
+                       LanguageManager manager = LanguageManager.getInstance();
+                       fMappings = manager.getLanguageConfiguration(project);
+                       
+                       ICProjectDescription description = CoreModel.getDefault().getProjectDescription(project);
+                       Map<String, ILanguage> availableLanguages = LanguageVerifier.computeAvailableLanguages();
+                       Set<String> missingLanguages = LanguageVerifier.removeMissingLanguages(fMappings, description, availableLanguages);
+                       if (missingLanguages.size() > 0) {
+                               MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK);
+                               messageBox.setText(PreferencesMessages.LanguageMappings_missingLanguageTitle);
+                               String affectedLanguages = LanguageVerifier.computeAffectedLanguages(missingLanguages);
+                               messageBox.setMessage(Messages.format(PreferencesMessages.ProjectLanguagesPropertyPage_missingLanguage, affectedLanguages));
+                               messageBox.open();
+                       }
+
+                       fMappingWidget.setMappings(fMappings.getContentTypeMappings());
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }
+       }
+       
+       private void fetchWorkspaceMappings() {
+               try {
+                       LanguageManager manager = LanguageManager.getInstance();
+                       WorkspaceLanguageConfiguration workspaceMappings = manager.getWorkspaceLanguageConfiguration();
+
+                       Map<String, ILanguage> availableLanguages = LanguageVerifier.computeAvailableLanguages();
+                       Set<String> missingLanguages = LanguageVerifier.removeMissingLanguages(workspaceMappings, availableLanguages);
+                       if (missingLanguages.size() > 0) {
+                               MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK);
+                               messageBox.setText(PreferencesMessages.LanguageMappings_missingLanguageTitle);
+                               String affectedLanguages = LanguageVerifier.computeAffectedLanguages(missingLanguages);
+                               messageBox.setMessage(Messages.format(PreferencesMessages.WorkspaceLanguagesPreferencePage_missingLanguage, affectedLanguages));
+                               messageBox.open();
+                       }
+
+                       fInheritedMappingWidget.setMappings(workspaceMappings.getWorkspaceMappings());
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }
+       }
+
+       @Override
+       protected void performDefaults() {
+               super.performDefaults();
+               fetchMappings(getProject());
+               fMappingWidget.refreshMappings();
+       }
+
+       @Override
+       public boolean performOk() {
+               try {
+                       if (!fMappingWidget.isChanged()) {
+                               return true;
+                       }
+                       
+                       fMappings.setContentTypeMappings(fMappingWidget.getContentTypeMappings());
+                       IContentType[] affectedContentTypes = fMappingWidget.getAffectedContentTypes();
+                       LanguageManager.getInstance().storeLanguageMappingConfiguration(getProject(), affectedContentTypes);
+                       fMappingWidget.setChanged(false);
+                       return true;
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+                       return false;
+               }
+       }
+       
+       @Override
+       public void dispose() {
+               super.dispose();
+               LanguageManager.getInstance().unregisterLanguageChangeListener(fInheritedMappingsChangeListener);
+       }
+
+       private IProject getProject() {
+               return (IProject) getElement().getAdapter(IProject.class);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingWidget.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingWidget.java
new file mode 100644 (file)
index 0000000..f5c35b5
--- /dev/null
@@ -0,0 +1,278 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.language;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.Map.Entry;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentTypeManager;
+import org.eclipse.jface.layout.TableColumnLayout;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleAdapter;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.LanguageManager;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+
+import org.eclipse.cdt.internal.ui.preferences.PreferencesMessages;
+import org.eclipse.cdt.internal.ui.util.Messages;
+
+public class ProjectLanguageMappingWidget extends LanguageMappingWidget {
+
+       static final String CONTENT_TYPE_KEY_DELIMITER = "::"; //$NON-NLS-1$
+
+       private static final String ALL_CONFIGURATIONS = ""; //$NON-NLS-1$
+
+       private static final int CONFIGURATION_COLUMN = 0;
+
+       private static final int CONTENT_TYPE_COLUMN = 1;
+
+       private static final int LANGUAGE_COLUMN = 2;
+       
+       private Map<String, Map<String, String>> fConfigurationContentTypeMappings;
+
+       public void setMappings(Map<String, Map<String, String>> contentTypeMappings) {
+               fConfigurationContentTypeMappings = contentTypeMappings;
+       }
+
+       public Map<String, Map<String, String>> getContentTypeMappings() {
+               return fConfigurationContentTypeMappings;
+       }
+
+       @Override
+       public Composite createContents(Composite parent, String description) {
+               fContents = new Composite(parent, SWT.NONE);
+               fContents.setLayout(new GridLayout(2, false));
+
+               if (description != null) {
+                       createHeader(parent, description);
+               }
+
+               Composite tableParent = new Composite(fContents, SWT.NONE);
+               tableParent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+               fTable = new Table(tableParent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.FULL_SELECTION);
+               fTable.setHeaderVisible(true);
+               fTable.setLinesVisible(true);
+               fTable.getAccessible().addAccessibleListener(new AccessibleAdapter() {
+                       @Override
+                       public void getName(AccessibleEvent e) {
+                               e.result = PreferencesMessages.ProjectLanguagesPropertyPage_mappingTableTitle;
+                       }
+               });
+               fTable.setToolTipText(PreferencesMessages.ProjectLanguagesPropertyPage_mappingTableTitle);
+
+               TableColumn configurationColumn = new TableColumn(fTable, SWT.LEAD);
+               configurationColumn.setText(PreferencesMessages.ProjectLanguagesPropertyPage_configurationColumn);
+               
+               TableColumn contentTypeColumn = new TableColumn(fTable, SWT.LEAD);
+               contentTypeColumn.setText(PreferencesMessages.ProjectLanguagesPropertyPage_contentTypeColumn);
+
+               TableColumn languageColumn = new TableColumn(fTable, SWT.LEAD);
+               languageColumn.setText(PreferencesMessages.ProjectLanguagesPropertyPage_languageColumn);
+
+               TableColumnLayout layout = new TableColumnLayout();
+               layout.setColumnData(configurationColumn, new ColumnWeightData(1, MINIMUM_COLUMN_WIDTH, true));
+               layout.setColumnData(contentTypeColumn, new ColumnWeightData(1, MINIMUM_COLUMN_WIDTH, true));
+               layout.setColumnData(languageColumn, new ColumnWeightData(1, MINIMUM_COLUMN_WIDTH, true));
+               tableParent.setLayout(layout);
+
+               Composite buttons = new Composite(fContents, SWT.NONE);
+               buttons.setLayout(new GridLayout());
+               buttons.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));
+
+               Button addButton = new Button(buttons, SWT.PUSH);
+               addButton.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
+               addButton.setText(PreferencesMessages.ProjectLanguagesPropertyPage_addMappingButton);
+               addButton.addListener(SWT.Selection, new Listener() {
+                       public void handleEvent(Event event) {
+                               IProject project = (IProject) getElement().getAdapter(IProject.class);
+                               ICProjectDescription description = CoreModel.getDefault().getProjectDescription(project, false);
+                               ICConfigurationDescription[] configurations = description.getConfigurations();
+                               ProjectContentTypeMappingDialog dialog = new ProjectContentTypeMappingDialog(fContents.getShell(), configurations);
+                               
+                               dialog.setContentTypeFilter(createContentTypeFilter(fConfigurationContentTypeMappings));
+                               dialog.setBlockOnOpen(true);
+
+                               if (dialog.open() == Window.OK) {
+                                       String contentType = dialog.getContentTypeID();
+                                       String language = dialog.getLanguageID();
+                                       String configuration = dialog.getConfigurationID();
+                                       if (configuration == null) {
+                                               configuration = ALL_CONFIGURATIONS;
+                                       }
+                                       Map<String, String> contentTypeMappings = fConfigurationContentTypeMappings.get(configuration);
+                                       if (contentTypeMappings == null) {
+                                               contentTypeMappings = new TreeMap<String, String>();
+                                               fConfigurationContentTypeMappings.put(configuration, contentTypeMappings);
+                                       }
+                                       contentTypeMappings.put(contentType, language);
+                                       setChanged(true);
+                                       
+                                       IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
+                                       fAffectedContentTypes.add(contentTypeManager.getContentType(contentType));
+                                       refreshMappings();
+                               }
+                       }
+               });
+
+               Button removeButton = new Button(buttons, SWT.PUSH);
+               removeButton.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
+               removeButton.setText(PreferencesMessages.ProjectLanguagesPropertyPage_removeMappingButton);
+               removeButton.addListener(SWT.Selection, new Listener() {
+
+                       public void handleEvent(Event event) {
+                               TableItem[] selection = fTable.getSelection();
+
+                               for (int i = 0; i < selection.length; i++) {
+                                       LanguageTableData data = (LanguageTableData) selection[i].getData();
+                                       String contentType = data.contentTypeId;
+
+                                       String configurationId;
+                                       if (data.configuration == null) {
+                                               configurationId = ALL_CONFIGURATIONS;
+                                       } else {
+                                               configurationId = data.configuration.getId();
+                                       }
+                                       
+                                       Map<String, String> contentTypeMappings = fConfigurationContentTypeMappings.get(configurationId);
+                                       if (contentTypeMappings != null) {
+                                               contentTypeMappings.remove(contentType);
+                                       }
+
+                                       IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
+                                       fAffectedContentTypes.add(contentTypeManager.getContentType(contentType));
+                               }
+                               
+                               if (selection.length > 0) {
+                                       setChanged(true);
+                               }
+
+                               refreshMappings();
+                       }
+               });
+
+               refreshMappings();
+               return fContents;
+       }
+
+       private Set<String> createContentTypeFilter(Map<String, Map<String, String>> mappings) {
+               Set<String> filter = new HashSet<String>();
+               Iterator<Entry<String, Map<String, String>>> configurationContentTypeMappings = mappings.entrySet().iterator();
+               while (configurationContentTypeMappings.hasNext()) {
+                       Entry<String, Map<String, String>> entry = configurationContentTypeMappings.next();
+                       String configuration = entry.getKey();
+                       Iterator<Entry<String, String>> contentTypeMappings = entry.getValue().entrySet().iterator();
+                       while (contentTypeMappings.hasNext()) {
+                               Entry<String, String> contentTypeEntry = contentTypeMappings.next();
+                               String contentType = contentTypeEntry.getKey();
+                               filter.add(createFilterKey(configuration, contentType));
+                       }
+               }
+               return filter;
+       }
+       
+       @Override
+       public void refreshMappings() {
+               if (fTable == null) {
+                       return;
+               }
+               
+               fTable.removeAll();
+               Iterator<Entry<String, Map<String, String>>> mappings = fConfigurationContentTypeMappings.entrySet().iterator();
+
+               IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
+
+               IProject project = (IProject) getElement().getAdapter(IProject.class);
+               ICProjectDescription description = CoreModel.getDefault().getProjectDescription(project, false);
+
+               while (mappings.hasNext()) {
+                       Entry<String, Map<String, String>> configurationEntry = mappings.next();
+                       String configurationId = configurationEntry.getKey();
+                       Iterator<Entry<String, String>> contentTypeMappings = configurationEntry.getValue().entrySet().iterator();
+                       while (contentTypeMappings.hasNext()) {
+                               Entry<String, String> entry = contentTypeMappings.next();
+                               TableItem item = new TableItem(fTable, SWT.NONE);
+       
+                               String contentType = entry.getKey();
+                               String contentTypeName = contentTypeManager.getContentType(contentType).getName();
+                               String languageId = entry.getValue();
+                               String languageName = LanguageManager.getInstance().getLanguage(languageId).getName();
+                               
+                               ICConfigurationDescription configuration = description.getConfigurationById(configurationId);
+                               
+                               item.setData(new LanguageTableData(configuration, contentType, languageId));
+                               
+                               if (configuration == null) {
+                                       item.setText(CONFIGURATION_COLUMN, PreferencesMessages.ContentTypeMappingsDialog_allConfigurations);
+                               } else {
+                                       item.setText(CONFIGURATION_COLUMN, configuration.getName());
+                               }
+                               
+                               if (fOverriddenContentTypes.contains(contentType)) {
+                                       item.setText(CONTENT_TYPE_COLUMN, Messages.format(PreferencesMessages.ProjectLanguagesPropertyPage_overriddenContentType, contentTypeName));
+                                       item.setFont(fOverriddenFont);
+                               } else {
+                                       item.setText(CONTENT_TYPE_COLUMN, contentTypeName);
+                               }
+                               item.setText(LANGUAGE_COLUMN, languageName);
+                       }
+               }
+               
+               if (fChild != null) {
+                       Set<String> overrides = new HashSet<String>(createWorkspaceContentTypeFilter(fConfigurationContentTypeMappings));
+                       fChild.setOverriddenContentTypes(overrides);
+                       fChild.refreshMappings();
+               }
+       }
+       
+       private Set<String> createWorkspaceContentTypeFilter(Map<String, Map<String, String>> configurationContentTypeMappings) {
+               Map<String, String> contentTypeMappings = configurationContentTypeMappings.get(ALL_CONFIGURATIONS);
+               if (contentTypeMappings == null) {
+                       return Collections.emptySet();
+               }
+               return contentTypeMappings.keySet();
+       }
+
+       static String createFilterKey(String configurationId, String contentTypeId) {
+               return configurationId + CONTENT_TYPE_KEY_DELIMITER + contentTypeId;
+       }
+       
+       private static class LanguageTableData {
+               ICConfigurationDescription configuration;
+               String contentTypeId;
+               
+               LanguageTableData(ICConfigurationDescription configuration, String contentTypeId, String languageId) {
+                       this.configuration = configuration;
+                       this.contentTypeId = contentTypeId;
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceContentTypeMappingDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceContentTypeMappingDialog.java
new file mode 100644 (file)
index 0000000..bff6cc1
--- /dev/null
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.language;
+
+import java.util.Collections;
+import java.util.Set;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentTypeManager;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.cdt.core.model.LanguageManager;
+
+import org.eclipse.cdt.internal.ui.preferences.PreferencesMessages;
+
+public class WorkspaceContentTypeMappingDialog extends ContentTypeMappingDialog {
+       private Set<String> fFilteredContentTypes;
+
+       public WorkspaceContentTypeMappingDialog(Shell parentShell) {
+               super(parentShell);
+               fFilteredContentTypes = Collections.emptySet();
+       }
+
+       @Override
+       protected Control createDialogArea(Composite parent) {
+               Composite area = new Composite(parent, SWT.NONE);
+               area.setLayout(new GridLayout(2, false));
+
+               Label contentTypeLabel = new Label(area, SWT.TRAIL);
+               contentTypeLabel.setText(PreferencesMessages.ContentTypeMappingsDialog_contentType);
+
+               fContentType = new Combo(area, SWT.DROP_DOWN | SWT.READ_ONLY);
+               fContentType.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               configureContentTypes(fContentType);
+               fContentType.addListener(SWT.Selection, new Listener() {
+                       public void handleEvent(Event event) {
+                               fSelectedContentTypeName = fContentType.getText();
+                               fSelectedContentTypeID = fContentTypeNamesToIDsMap.get(fSelectedContentTypeName);
+                               getButton(IDialogConstants.OK_ID).setEnabled(isValidSelection());
+                       }
+               });
+
+               Label languageLabel = new Label(area, SWT.TRAIL);
+               languageLabel.setText(PreferencesMessages.ContentTypeMappingsDialog_language);
+
+               fLanguage = new Combo(area, SWT.DROP_DOWN | SWT.READ_ONLY);
+               fLanguage.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               fLanguage.setItems(getLanguages());
+               fLanguage.addListener(SWT.Selection, new Listener() {
+                       public void handleEvent(Event event) {
+                               fSelectedLanguageName = fLanguage.getText();
+                               fSelectedLanguageID = fLanguageNamesToIDsMap.get(fSelectedLanguageName);
+                               getButton(IDialogConstants.OK_ID).setEnabled(isValidSelection());
+                       }
+               });
+
+               return area;
+       }
+       
+       private void configureContentTypes(Combo combo) {
+               combo.removeAll();
+               String[] contentTypesIDs = LanguageManager.getInstance()
+                               .getRegisteredContentTypeIds();
+
+               IContentTypeManager contentTypeManager = Platform
+                               .getContentTypeManager();
+
+               for (int i = 0; i < contentTypesIDs.length; i++) {
+                       if (!fFilteredContentTypes.contains(contentTypesIDs[i])) {
+
+                               String name = contentTypeManager.getContentType(
+                                               contentTypesIDs[i]).getName();
+
+                               combo.add(name);
+
+                               // keep track of what ID this name corresponds to so that when
+                               // we setup the mapping
+                               // later based upon user selection, we'll know what ID to use
+                               fContentTypeNamesToIDsMap.put(name, contentTypesIDs[i]);
+                       }
+               }
+       }
+
+       public void setContentTypeFilter(Set<String> contentTypes) {
+               fFilteredContentTypes = contentTypes;
+       }
+
+       @Override
+       protected boolean isValidSelection() {
+               return fContentType.getSelectionIndex() != -1 && fLanguage.getSelectionIndex() != -1;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingPreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingPreferencePage.java
new file mode 100644 (file)
index 0000000..59d8a79
--- /dev/null
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.language;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.CCorePreferenceConstants;
+import org.eclipse.cdt.core.language.WorkspaceLanguageConfiguration;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.LanguageManager;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.language.LanguageMappingStore;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.preferences.PreferencesMessages;
+import org.eclipse.cdt.internal.ui.util.Messages;
+
+public class WorkspaceLanguageMappingPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+
+       WorkspaceLanguageConfiguration fMappings;
+       WorkspaceLanguageMappingWidget fMappingWidget;
+       
+       public WorkspaceLanguageMappingPreferencePage() {
+               fMappingWidget = new WorkspaceLanguageMappingWidget();
+       }
+       
+       @Override
+       public void createControl(Composite parent) {
+               super.createControl(parent);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.LANGUAGE_MAPPING_PREFERENCE_PAGE);
+       }
+
+       @Override
+       protected Control createContents(Composite parent) {
+               try {
+                       fetchMappings();
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }
+               return fMappingWidget.createContents(parent, PreferencesMessages.WorkspaceLanguagesPreferencePage_description);
+       }
+       
+       private void fetchMappings() throws CoreException {
+               fMappings = LanguageManager.getInstance().getWorkspaceLanguageConfiguration();
+               
+               Map<String, ILanguage> availableLanguages = LanguageVerifier.computeAvailableLanguages();
+               Set<String> missingLanguages = LanguageVerifier.removeMissingLanguages(fMappings, availableLanguages);
+               if (missingLanguages.size() > 0) {
+                       MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_WARNING | SWT.OK);
+                       messageBox.setText(PreferencesMessages.LanguageMappings_missingLanguageTitle);
+                       String affectedLanguages = LanguageVerifier.computeAffectedLanguages(missingLanguages);
+                       messageBox.setMessage(Messages.format(PreferencesMessages.WorkspaceLanguagesPreferencePage_missingLanguage, affectedLanguages));
+                       messageBox.open();
+               }
+               
+               fMappingWidget.setMappings(fMappings.getWorkspaceMappings());
+       }
+
+       public void init(IWorkbench workbench) {
+       }
+       
+       @Override
+       public boolean performOk() {
+               try {
+                       if (!fMappingWidget.isChanged()) {
+                               return true;
+                       }
+                       
+                       IContentType[] affectedContentTypes = fMappingWidget.getAffectedContentTypes();
+                       LanguageManager manager = LanguageManager.getInstance();
+                       WorkspaceLanguageConfiguration config = manager.getWorkspaceLanguageConfiguration();
+                       config.setWorkspaceMappings(fMappingWidget.getContentTypeMappings());
+                       manager.storeWorkspaceLanguageConfiguration(affectedContentTypes);
+                       fMappingWidget.setChanged(false);
+                       return true;
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+                       return false;
+               }
+       }
+       
+       @Override
+       protected void performDefaults() {
+               super.performDefaults();
+               // set to default
+               IEclipsePreferences node = InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID);
+               node.remove(CCorePreferenceConstants.WORKSPACE_LANGUAGE_MAPPINGS);
+               try {
+                       // remove workspace mappings
+                       Map<String,String> currentMappings= fMappings.getWorkspaceMappings();
+                       Set<String> keys = currentMappings.keySet();
+                       String[] contentTypeIds = keys.toArray(new String[keys.size()]);
+                       for (String contentTypeId : contentTypeIds) {
+                               fMappings.removeWorkspaceMapping(contentTypeId);
+                       }
+                       // add default mappings
+                       LanguageMappingStore store = new LanguageMappingStore();
+                       WorkspaceLanguageConfiguration defaultConfig = store.decodeWorkspaceMappings();
+                       Map<String,String> defaultMappings= defaultConfig.getWorkspaceMappings();
+                       for (String contentTypeId : defaultMappings.keySet()) {
+                               String language= defaultMappings.get(contentTypeId);
+                               fMappings.addWorkspaceMapping(contentTypeId, language);
+                       }
+                       fetchMappings();
+                       fMappingWidget.refreshMappings();
+                       fMappingWidget.setChanged(false);
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingWidget.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingWidget.java
new file mode 100644 (file)
index 0000000..05b069a
--- /dev/null
@@ -0,0 +1,187 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.language;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.Map.Entry;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentTypeManager;
+import org.eclipse.jface.layout.TableColumnLayout;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleAdapter;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+import org.eclipse.cdt.core.model.LanguageManager;
+
+import org.eclipse.cdt.internal.ui.preferences.PreferencesMessages;
+import org.eclipse.cdt.internal.ui.util.Messages;
+
+public class WorkspaceLanguageMappingWidget extends LanguageMappingWidget {
+       private Map<String, String> fContentTypeMappings;
+       
+       public WorkspaceLanguageMappingWidget() {
+               super();
+               fContentTypeMappings = new TreeMap<String, String>();
+       }
+       
+       @Override
+       public Composite createContents(Composite parent, String description) {
+               fContents = new Composite(parent, SWT.NONE);
+               fContents.setLayout(new GridLayout(2, false));
+
+               if (description != null) {
+                       createHeader(parent, description);
+               }
+
+               Composite tableParent = new Composite(fContents, SWT.NONE);
+               tableParent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+               fTable = new Table(tableParent, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.FULL_SELECTION);
+               fTable.setHeaderVisible(true);
+               fTable.setLinesVisible(true);
+               fTable.getAccessible().addAccessibleListener(new AccessibleAdapter() {
+                       @Override
+                       public void getName(AccessibleEvent e) {
+                               e.result = PreferencesMessages.WorkspaceLanguagesPreferencePage_mappingTableTitle;
+                       }
+               });
+               fTable.setToolTipText(PreferencesMessages.WorkspaceLanguagesPreferencePage_mappingTableTitle);
+               
+
+               TableColumn contentTypeColumn = new TableColumn(fTable, SWT.LEAD);
+               contentTypeColumn.setText(PreferencesMessages.ProjectLanguagesPropertyPage_contentTypeColumn);
+
+               TableColumn languageColumn = new TableColumn(fTable, SWT.LEAD);
+               languageColumn.setText(PreferencesMessages.ProjectLanguagesPropertyPage_languageColumn);
+
+               TableColumnLayout layout = new TableColumnLayout();
+               layout.setColumnData(contentTypeColumn, new ColumnWeightData(1, MINIMUM_COLUMN_WIDTH, true));
+               layout.setColumnData(languageColumn, new ColumnWeightData(1, MINIMUM_COLUMN_WIDTH, true));
+               tableParent.setLayout(layout);
+
+               if (!fIsReadOnly) {
+                       Composite buttons = new Composite(fContents, SWT.NONE);
+                       buttons.setLayout(new GridLayout());
+                       buttons.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));
+       
+                       Button addButton = new Button(buttons, SWT.PUSH);
+                       addButton.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
+                       addButton.setText(PreferencesMessages.ProjectLanguagesPropertyPage_addMappingButton);
+                       addButton.addListener(SWT.Selection, new Listener() {
+                               public void handleEvent(Event event) {
+                                       WorkspaceContentTypeMappingDialog dialog = new WorkspaceContentTypeMappingDialog(fContents.getShell());
+                                       dialog.setContentTypeFilter(fContentTypeMappings.keySet());
+                                       dialog.setBlockOnOpen(true);
+       
+                                       if (dialog.open() == Window.OK) {
+                                               String contentType = dialog.getContentTypeID();
+                                               String language = dialog.getLanguageID();
+                                               fContentTypeMappings.put(contentType, language);
+                                               setChanged(true);
+                                               IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
+                                               fAffectedContentTypes.add(contentTypeManager.getContentType(contentType));
+                                               refreshMappings();
+                                       }
+                               }
+                       });
+       
+                       Button removeButton = new Button(buttons, SWT.PUSH);
+                       removeButton.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
+                       removeButton.setText(PreferencesMessages.ProjectLanguagesPropertyPage_removeMappingButton);
+                       removeButton.addListener(SWT.Selection, new Listener() {
+       
+                               public void handleEvent(Event event) {
+                                       TableItem[] selection = fTable.getSelection();
+       
+                                       for (int i = 0; i < selection.length; i++) {
+                                               String contentType = fContentTypeNamesToIDsMap.get(selection[i].getText(0));
+       
+                                               fContentTypeMappings.remove(contentType);
+       
+                                               IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
+                                               fAffectedContentTypes.add(contentTypeManager.getContentType(contentType));
+                                       }
+                                       
+                                       if (selection.length > 0) {
+                                               setChanged(true);
+                                       }
+       
+                                       refreshMappings();
+                               }
+                       });
+               }
+
+               refreshMappings();
+               return fContents;
+       }
+
+       @Override
+       public void refreshMappings() {
+               if (fTable == null) {
+                       return;
+               }
+               
+               fTable.removeAll();
+               Iterator<Entry<String, String>> mappings = fContentTypeMappings.entrySet().iterator();
+
+               IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
+
+               while (mappings.hasNext()) {
+                       Entry<String, String> entry = mappings.next();
+
+                       TableItem item = new TableItem(fTable, SWT.NONE);
+
+                       String contentType = entry.getKey();
+                       String contentTypeName = contentTypeManager.getContentType(contentType).getName();
+                       String languageName = LanguageManager.getInstance().getLanguage(entry.getValue()).getName();
+
+                       if (fOverriddenContentTypes.contains(contentType)) {
+                               item.setText(0, Messages.format(PreferencesMessages.ProjectLanguagesPropertyPage_overriddenContentType, contentTypeName));
+                               item.setFont(fOverriddenFont);
+                       } else {
+                               item.setText(0, contentTypeName);
+                       }
+                       item.setText(1, languageName);
+               }
+               
+               if (fChild != null) {
+                       Set<String> overrides = new HashSet<String>(fContentTypeMappings.keySet());
+                       overrides.addAll(fOverriddenContentTypes);
+                       fChild.setOverriddenContentTypes(overrides);
+                       fChild.refreshMappings();
+               }
+       }
+       
+       public void setMappings(Map<String, String> mappings) {
+               fContentTypeMappings = new TreeMap<String, String>(mappings);
+       }
+
+       public Map<String, String> getContentTypeMappings() {
+               return Collections.unmodifiableMap(fContentTypeMappings);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/AbstractCNavigatorActionGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/AbstractCNavigatorActionGroup.java
new file mode 100644 (file)
index 0000000..77b8810
--- /dev/null
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems) - adaptations for Common Navigator
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.navigator;
+
+import java.net.URL;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.actions.ActionGroup;
+
+/**
+ * A basic abstract action group implementation similar to 
+ * {@link org.eclipse.cdt.internal.ui.cview.CViewActionGroup}, avoiding
+ * the explicit dependency on {@link org.eclipse.cdt.internal.ui.cview.CView} to
+ * allow reuse in the Common Navigator.
+ * 
+ * @see org.eclipse.cdt.internal.ui.cview.CViewActionGroup
+ */
+public abstract class AbstractCNavigatorActionGroup extends ActionGroup {
+
+       /**
+        * The view part this action group is associated with.
+        */
+       private final IViewPart fViewPart;
+
+       /**
+        * Create a new action group associated  with given view part.
+        * 
+        * @param viewPart
+        *            the view part this action group is associated with, may not be
+        *            <code>null</code>.
+        */
+       public AbstractCNavigatorActionGroup(IViewPart viewPart) {
+               Assert.isNotNull(viewPart);
+               fViewPart = viewPart;
+               makeActions();
+       }
+
+       /**
+        * Provide access to the view part this action group has been registered with.
+        * 
+        * @return the view part
+        */
+       protected IViewPart getViewPart() {
+               return fViewPart;
+       }
+
+       /**
+        * Returns the image descriptor with the given relative path.
+        */
+       protected ImageDescriptor getImageDescriptor(String relativePath) {
+               String iconPath = "/icons/" + relativePath; //$NON-NLS-1$
+               URL iconURL = FileLocator.find(CUIPlugin.getDefault().getBundle(), new Path(iconPath), null);
+               // it's safe to pass null
+               return ImageDescriptor.createFromURL(iconURL);
+       }
+
+       /**
+        * Makes the actions contained in this action group.
+        */
+       protected abstract void makeActions();
+       
+       /*
+        * @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
+        */
+       @Override
+       public abstract void fillContextMenu(IMenuManager menu);
+
+       /*
+        * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars)
+        */
+       @Override
+       public abstract void fillActionBars(IActionBars actionBars);
+
+       /*
+        * @see org.eclipse.ui.actions.ActionGroup#updateActionBars()
+        */
+       @Override
+       public abstract void updateActionBars();
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionGroup.java
new file mode 100644 (file)
index 0000000..3121c21
--- /dev/null
@@ -0,0 +1,172 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems) - adaptations for Common Navigator
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.navigator;
+
+import java.util.Iterator;
+
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.actions.BuildAction;
+import org.eclipse.ui.ide.IDEActionFactory;
+import org.eclipse.ui.navigator.ICommonMenuConstants;
+
+import org.eclipse.cdt.internal.ui.cview.BuildGroup;
+import org.eclipse.cdt.internal.ui.cview.CViewMessages;
+
+/**
+ * Common Navigator compatible clone of {@link org.eclipse.cdt.internal.ui.cview.BuildGroup}.
+ * <p>
+ * Adds action "Clean Project" and group marker "buildGroup" to the context menu.
+ * </p>
+ * @see org.eclipse.cdt.internal.ui.cview.BuildGroup
+ * @see org.eclipse.ui.actions.BuildAction
+ */
+public class CNavigatorBuildActionGroup extends AbstractCNavigatorActionGroup {
+
+       private BuildAction fBuildAction;
+       private BuildAction fCleanAction;
+
+       // Menu tags for the build
+       final String BUILD_GROUP_MARKER= "buildGroup"; //$NON-NLS-1$
+       final String BUILD_GROUP_MARKER_END= "end-buildGroup"; //$NON-NLS-1$
+
+       /**
+        * Create action group associated with given view part.
+        * @param viewPart
+        */
+       public CNavigatorBuildActionGroup(IViewPart viewPart) {
+               super(viewPart);
+       }
+
+       @Override
+       public void fillActionBars(IActionBars actionBars) {
+               // register a CDT Build project action which prevents projects with refs from being built twice
+               actionBars.setGlobalActionHandler(IDEActionFactory.BUILD_PROJECT.getId(), fBuildAction);
+               updateActionBars();
+       }
+
+       /**
+        * Adds the build actions to the context menu.
+        * <p>
+        * The following conditions apply: build-only projects selected, auto build
+        * disabled, at least one * builder present
+        * </p>
+        * <p>
+        * No disabled action should be on the context menu.
+        * </p>
+        *
+        * @param menu
+        *            context menu to add actions to
+        */
+       @Override
+       public void fillContextMenu(IMenuManager menu) {
+               IStructuredSelection selection= (IStructuredSelection) getContext().getSelection();
+               boolean isProjectSelection= true;
+               boolean hasOpenProjects= false;
+               boolean hasClosedProjects= false;
+               boolean hasBuilder= true; // false if any project is closed or does
+               // not have builder
+
+               Iterator<?> resources= selection.iterator();
+               while (resources.hasNext() && (!hasOpenProjects || !hasClosedProjects || hasBuilder || isProjectSelection)) {
+                       Object next= resources.next();
+                       IProject project= null;
+
+                       if (next instanceof IProject) {
+                               project= (IProject) next;
+                       } else if (next instanceof IAdaptable) {
+                               IResource res= (IResource)((IAdaptable)next).getAdapter(IResource.class);
+                               if (res instanceof IProject) {
+                                       project= (IProject) res;
+                               }
+                       }
+
+                       if (project == null) {
+                               isProjectSelection= false;
+                               continue;
+                       }
+                       if (project.isOpen()) {
+                               hasOpenProjects= true;
+                               if (hasBuilder && !hasBuilder(project)) {
+                                       hasBuilder= false;
+                               }
+                       } else {
+                               hasClosedProjects= true;
+                               hasBuilder= false;
+                       }
+               }
+
+               if (!selection.isEmpty() && isProjectSelection && hasBuilder) {
+                       fCleanAction.selectionChanged(selection);
+                       if (fCleanAction.isEnabled()) {
+                               IContributionItem oldBuild = menu.find(BuildAction.ID_BUILD);
+                               if (oldBuild != null) {
+                                       menu.insertAfter(BuildAction.ID_BUILD, fCleanAction);
+                                       // Replace ResourceMgmtActionProvier's build action with our own
+                                       if (oldBuild instanceof ActionContributionItem &&
+                                                       ((ActionContributionItem)oldBuild).getAction() instanceof BuildAction) {
+                                               menu.remove(oldBuild);
+                                               menu.insertBefore(fCleanAction.getId(), fBuildAction);
+                                       }
+                               } else {
+                                       menu.insertAfter(ICommonMenuConstants.GROUP_BUILD, fCleanAction);
+                                       menu.insertAfter(ICommonMenuConstants.GROUP_BUILD, fBuildAction);
+                               }
+                       }
+               }
+               menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, new Separator(BUILD_GROUP_MARKER));
+               menu.appendToGroup(BUILD_GROUP_MARKER, new GroupMarker(BUILD_GROUP_MARKER_END));
+       }
+
+       /**
+        * Returns whether there are builders configured on the given project.
+        *
+        * @return <code>true</code> if it has builders, <code>false</code> if
+        *         not, or if this could not be determined
+        */
+       boolean hasBuilder(IProject project) {
+               try {
+                       ICommand[] commands= project.getDescription().getBuildSpec();
+                       if (commands.length > 0) return true;
+               } catch (CoreException e) {
+                       // Cannot determine if project has builders. Project is closed
+                       // or does not exist. Fall through to return false.
+               }
+               return false;
+       }
+
+       @Override
+       protected void makeActions() {
+               fBuildAction = new BuildGroup.CDTBuildAction(getViewPart().getSite(), IncrementalProjectBuilder.INCREMENTAL_BUILD);
+               fCleanAction= new BuildGroup.CDTBuildAction(getViewPart().getSite(), IncrementalProjectBuilder.CLEAN_BUILD);
+               fCleanAction.setText(CViewMessages.CleanAction_label);
+       }
+
+       @Override
+       public void updateActionBars() {
+               IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
+               fBuildAction.selectionChanged(selection);
+               fCleanAction.selectionChanged(selection);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionProvider.java
new file mode 100644 (file)
index 0000000..3d91033
--- /dev/null
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.navigator;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
+
+/**
+ * A Common Navigator action provider providing the contributions
+ * from the build action group.
+ * 
+ * @see CNavigatorBuildActionGroup
+ */
+public class CNavigatorBuildActionProvider extends CommonActionProvider {
+
+       private CNavigatorBuildActionGroup fBuildGroup;
+
+       /*
+        * @see org.eclipse.ui.navigator.CommonActionProvider#init(org.eclipse.ui.navigator.ICommonActionExtensionSite)
+        */
+       @Override
+       public void init(ICommonActionExtensionSite site) {
+               ICommonViewerWorkbenchSite workbenchSite= null;
+               if (site.getViewSite() instanceof ICommonViewerWorkbenchSite) {
+                       workbenchSite= (ICommonViewerWorkbenchSite) site.getViewSite();
+               }
+               if (workbenchSite != null) {
+                       if (workbenchSite.getPart() != null && workbenchSite.getPart() instanceof IViewPart) {
+                               IViewPart viewPart= (IViewPart) workbenchSite.getPart();
+
+                               fBuildGroup= new CNavigatorBuildActionGroup(viewPart);
+                       }
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.actions.ActionGroup#dispose()
+        */
+       @Override
+       public void dispose() {
+               if (fBuildGroup != null) {
+                       fBuildGroup.dispose();
+                       fBuildGroup = null;
+               }
+               super.dispose();
+       }
+
+       /*
+        * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars)
+        */
+       @Override
+       public void fillActionBars(IActionBars actionBars) {
+               if (fBuildGroup != null) {
+                       fBuildGroup.fillActionBars(actionBars);
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
+        */
+       @Override
+       public void fillContextMenu(IMenuManager menu) {
+               if (fBuildGroup != null) {
+                       fBuildGroup.fillContextMenu(menu);
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.actions.ActionGroup#setContext(org.eclipse.ui.actions.ActionContext)
+        */
+       @Override
+       public void setContext(ActionContext context) {
+               super.setContext(context);
+               if (fBuildGroup != null) {
+                       fBuildGroup.setContext(context);
+               }
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorContentProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorContentProvider.java
new file mode 100644 (file)
index 0000000..a9a8047
--- /dev/null
@@ -0,0 +1,483 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2011 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.navigator;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.navigator.ICommonContentExtensionSite;
+import org.eclipse.ui.navigator.IPipelinedTreeContentProvider;
+import org.eclipse.ui.navigator.PipelinedShapeModification;
+import org.eclipse.ui.navigator.PipelinedViewerUpdate;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.CCorePreferenceConstants;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IParent;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+import org.eclipse.cdt.internal.ui.cview.CViewContentProvider;
+
+/**
+ * A content provider populating a Common Navigator view with CDT model content.
+ */
+public class CNavigatorContentProvider extends CViewContentProvider implements IPipelinedTreeContentProvider {
+
+       /** The input object as supplied in the call to {@link #inputChanged()} */
+       private Object fRealInput;
+       private IPropertyChangeListener fPropertyChangeListener;
+       private IPreferenceChangeListener fPreferenceChangeListener;
+
+       /*
+        * @see org.eclipse.ui.navigator.ICommonContentProvider#init(org.eclipse.ui.navigator.ICommonContentExtensionSite)
+        */
+       public void init(ICommonContentExtensionSite commonContentExtensionSite) {
+               IMemento memento= commonContentExtensionSite.getMemento();
+               restoreState(memento);
+
+               fPropertyChangeListener= new IPropertyChangeListener() {
+                       public void propertyChange(PropertyChangeEvent event) {
+                               boolean refreshViewer= false;
+                               String property= event.getProperty();
+                               Object newValue= event.getNewValue();
+                               
+                               if (property.equals(PreferenceConstants.PREF_SHOW_CU_CHILDREN)) {
+                                       boolean showCUChildren= newValue instanceof Boolean ? ((Boolean)newValue).booleanValue() : false;
+                                       setProvideMembers(showCUChildren);
+                                       refreshViewer= true;
+                               } else if (property.equals(PreferenceConstants.CVIEW_GROUP_INCLUDES)) {
+                                       boolean groupIncludes= newValue instanceof Boolean ? ((Boolean)newValue).booleanValue() : false;
+                                       setIncludesGrouping(groupIncludes);
+                                       refreshViewer= true;
+                               } else if (property.equals(PreferenceConstants.CVIEW_GROUP_MACROS)) {
+                                       boolean groupMacros = newValue instanceof Boolean ? ((Boolean)newValue).booleanValue() : false;
+                                       setMacroGrouping(groupMacros);
+                                       refreshViewer= true;
+                               }
+
+                               if (refreshViewer && getViewer() != null) {
+                                       getViewer().refresh();
+                               }
+                       }
+               };
+               CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPropertyChangeListener);
+               
+               // Note that this listener listens to CCorePlugin preferences
+               fPreferenceChangeListener = new IPreferenceChangeListener() {
+                       public void preferenceChange(PreferenceChangeEvent event) {
+                               if (event.getKey().equals(CCorePreferenceConstants.SHOW_SOURCE_ROOTS_AT_TOP_LEVEL_OF_PROJECT)) {
+                                       Display.getDefault().asyncExec(new Runnable() {
+                                               public void run() {
+                                                       getViewer().refresh();
+                                               }
+                                       });
+                               }
+                       }
+               };
+               InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).addPreferenceChangeListener(fPreferenceChangeListener);
+
+               // TLETODO [CN] use extension state model for view options persistence
+//             fStateModel.addPropertyChangeListener(listener);
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.CElementContentProvider#dispose()
+        */
+       @Override
+       public void dispose() {
+               InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).removePreferenceChangeListener(fPreferenceChangeListener);
+               
+               CUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener);
+               // TLETODO [CN] use extension state model for view options persistence
+//             fStateModel.removePropertyChangeListener(fPropertyChangeListener);
+               super.dispose();
+       }
+
+       /*
+        * @see org.eclipse.ui.navigator.IMementoAware#restoreState(org.eclipse.ui.IMemento)
+        */
+       public void restoreState(IMemento memento) {
+               IPreferenceStore store= PreferenceConstants.getPreferenceStore();
+               boolean showCUChildren= store.getBoolean(PreferenceConstants.PREF_SHOW_CU_CHILDREN);
+               boolean groupIncludes= store.getBoolean(PreferenceConstants.CVIEW_GROUP_INCLUDES);
+               boolean groupMacros= store.getBoolean(PreferenceConstants.CVIEW_GROUP_MACROS);
+               if (memento != null) {
+                       // options controlled by preference only
+//                     String mementoValue= memento.getString(PreferenceConstants.PREF_SHOW_CU_CHILDREN);
+//                     if (mementoValue != null) {
+//                             showCUChildren= Boolean.valueOf(mementoValue).booleanValue();
+//                     }
+//                     mementoValue= memento.getString(PreferenceConstants.CVIEW_GROUP_INCLUDES);
+//                     if (mementoValue != null) {
+//                             groupIncludes= Boolean.valueOf(mementoValue).booleanValue();
+//                     }
+               }
+               setProvideMembers(showCUChildren);
+               setIncludesGrouping(groupIncludes);
+               setMacroGrouping(groupMacros);
+               setProvideWorkingCopy(true);
+       }
+
+       /*
+        * @see org.eclipse.ui.navigator.IMementoAware#saveState(org.eclipse.ui.IMemento)
+        */
+       public void saveState(IMemento memento) {
+               if (memento != null) {
+                       memento.putString(PreferenceConstants.PREF_SHOW_CU_CHILDREN, String.valueOf(getProvideMembers()));
+                       memento.putString(PreferenceConstants.CVIEW_GROUP_INCLUDES, String.valueOf(areIncludesGroup()));
+                       memento.putString(PreferenceConstants.CVIEW_GROUP_MACROS, String.valueOf(isMacroGroupingEnabled()));
+               }
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.CElementContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+        */
+       @Override
+       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+               fRealInput= newInput;
+               super.inputChanged(viewer, oldInput, findInputElement(newInput));
+       }
+
+       private Object findInputElement(Object newInput) {
+               if (newInput instanceof IWorkspaceRoot) {
+                       return CoreModel.create((IWorkspaceRoot) newInput);
+               }
+               return newInput;
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.BaseCElementContentProvider#getParent(java.lang.Object)
+        */
+       @Override
+       public Object getParent(Object element) {
+               Object parent= super.getParent(element);
+               if (parent instanceof ICModel) {
+                       return getViewerInput() != null ? fRealInput : parent;
+               } else if (parent instanceof ICProject)
+                       return ((ICProject)parent).getProject();
+               return parent;
+       }
+
+       /**
+        * Access the viewer input.
+        * @return the viewer input
+        */
+       protected Object getViewerInput() {
+               return fInput;
+       }
+
+       /**
+        * Access the viewer.
+        * @return the viewer
+        */
+       protected Viewer getViewer() {
+               return fViewer;
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.BaseCElementContentProvider#getElements(java.lang.Object)
+        */
+       @Override
+       public Object[] getElements(Object parent) {
+               if (parent instanceof IWorkspaceRoot) {
+                       return ((IWorkspaceRoot)parent).getProjects();
+               } else if (parent instanceof IProject) {
+                       return super.getChildren(CoreModel.getDefault().create((IProject)parent));
+               }
+               return super.getElements(parent);
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.cview.CViewContentProvider#getChildren(java.lang.Object)
+        */
+       @Override
+       public Object[] getChildren(Object element) {
+               Object children[];
+               if (element instanceof IWorkspaceRoot) {
+                       return ((IWorkspaceRoot)element).getProjects();
+               } else if (element instanceof IProject) {
+                       return super.getChildren(CoreModel.getDefault().create((IProject)element));
+               } else {
+                       children = super.getChildren(element);
+               }
+               return children;
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.cview.CViewContentProvider#hasChildren(java.lang.Object)
+        */
+       @Override
+       public boolean hasChildren(Object element) {
+               if (element instanceof IProject) {
+                       IProject project= (IProject) element;
+                       return project.isAccessible();
+               }
+               return super.hasChildren(element);
+       }
+       
+       /*
+        * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#getPipelinedChildren(java.lang.Object, java.util.Set)
+        */
+       @SuppressWarnings({ "unchecked", "rawtypes" })
+       public void getPipelinedChildren(Object parent, Set currentChildren) {
+               customizeCElements(getChildren(parent), currentChildren);
+       }
+
+       /*
+        * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#getPipelinedElements(java.lang.Object, java.util.Set)
+        */
+       @SuppressWarnings({ "unchecked", "rawtypes" })
+       public void getPipelinedElements(Object input, Set currentElements) {
+               // only replace plain resource elements with custom elements
+               // and avoid duplicating elements already customized
+               // by upstream content providers
+               customizeCElements(getElements(input), currentElements);
+       }
+
+       private void customizeCElements(Object[] cChildren, Set<Object> proposedChildren) {
+               List<Object> elementList= Arrays.asList(cChildren);
+               for (Object element : proposedChildren) {
+                       IResource resource= null;
+                       if (element instanceof IResource) {
+                               resource= (IResource)element;
+                       } else if (element instanceof IAdaptable) {
+                               resource= (IResource)((IAdaptable)element).getAdapter(IResource.class);
+                       }
+                       if (resource != null) {
+                               int i= elementList.indexOf(resource);
+                               if (i >= 0) {
+                                       cChildren[i]= null;
+                               }
+                       }
+               }
+               for (Object element : cChildren) {
+                       if (element instanceof ICElement) {
+                               ICElement cElement= (ICElement)element;
+                               IResource resource= cElement.getResource();
+                               if (resource != null) {
+                                       proposedChildren.remove(resource);
+                               }
+                               proposedChildren.add(element);
+                       } else if (element != null) {
+                               proposedChildren.add(element);
+                       }
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#getPipelinedParent(java.lang.Object, java.lang.Object)
+        */
+       public Object getPipelinedParent(Object object, Object suggestedParent) {
+               return getParent(object);
+       }
+
+       /*
+        * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#interceptAdd(org.eclipse.ui.navigator.PipelinedShapeModification)
+        */
+       public PipelinedShapeModification interceptAdd(PipelinedShapeModification addModification) {
+               Object parent = addModification.getParent();
+               if (parent instanceof ICProject) {
+                       if (fRealInput instanceof IWorkspaceRoot) {
+                               addModification.setParent(((ICProject)parent).getProject());
+                       }
+               } else if (parent instanceof IProject || parent instanceof IFolder) {
+                       // ignore adds to C projects (we are issuing a refresh)
+                       IProject project= ((IResource) parent).getProject();
+                       if (CoreModel.hasCNature(project)) {
+                               addModification.getChildren().clear();
+                               return addModification;
+                       }
+               } else if (parent instanceof IWorkspaceRoot) {
+                       // ignore adds of C projects (we are issuing a refresh)
+                       for (Iterator<?> iterator = addModification.getChildren().iterator(); iterator.hasNext();) {
+                               Object child= iterator.next();
+                               if (child instanceof IProject) {
+                                       if (CoreModel.hasCNature((IProject)child)) {
+                                               iterator.remove();
+                                       }
+                               }
+                       }
+               }
+               convertToCElements(addModification);
+               return addModification;
+       }
+
+       /*
+        * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#interceptRefresh(org.eclipse.ui.navigator.PipelinedViewerUpdate)
+        */
+       public boolean interceptRefresh(PipelinedViewerUpdate refreshSynchronization) {
+               @SuppressWarnings("unchecked")
+               final Set<Object> refreshTargets = refreshSynchronization.getRefreshTargets();
+               return convertToCElements(refreshTargets);
+       }
+
+       /*
+        * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#interceptRemove(org.eclipse.ui.navigator.PipelinedShapeModification)
+        */
+       public PipelinedShapeModification interceptRemove(PipelinedShapeModification removeModification) {
+               @SuppressWarnings("unchecked")
+               final Set<Object> children = removeModification.getChildren();
+               convertToCElements(children);
+               return removeModification;
+       }
+
+       /*
+        * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#interceptUpdate(org.eclipse.ui.navigator.PipelinedViewerUpdate)
+        */
+       public boolean interceptUpdate(PipelinedViewerUpdate updateSynchronization) {
+               @SuppressWarnings("unchecked")
+               final Set<Object> refreshTargets = updateSynchronization.getRefreshTargets();
+               return convertToCElements(refreshTargets);
+       }
+
+       /**
+        * Converts the shape modification to use ICElements.
+        * 
+        * @param modification
+        *            the shape modification to convert
+        * @return <code>true</code> if the shape modification set was modified
+        */
+       private boolean convertToCElements(
+                       PipelinedShapeModification modification) {
+               Object parent= modification.getParent();
+               // don't convert projects
+               if (parent instanceof IContainer) {
+                       IContainer container= (IContainer)parent;
+                       IProject project= container.getProject();
+                       if (project != null && CoreModel.hasCNature(project)) {
+                               ICElement element= CoreModel.getDefault().create(container);
+                               if (element != null) {
+                                       // don't convert the root
+                                       if( !(element instanceof ICModel) && !(element instanceof ICProject) ) {
+                                               modification.setParent(element);
+                                       }
+                                       @SuppressWarnings("unchecked")
+                                       final Set<Object> children = modification.getChildren();
+                                       return convertToCElements(children);
+                               }
+                       }
+               }
+               return false;
+       }
+
+       /**
+        * Converts the given set to ICElements.
+        * 
+        * @param currentChildren
+        *            The set of current children that would be contributed or
+        *            refreshed in the viewer.
+        * @return <code>true</code> if the input set was modified
+        */
+       private boolean convertToCElements(Set<Object> currentChildren) {
+               LinkedHashSet<ICElement> convertedChildren= new LinkedHashSet<ICElement>();
+               ICElement newChild;
+               for (Iterator<Object> iter= currentChildren.iterator(); iter.hasNext();) {
+                       Object child= iter.next();
+                       // do not convert IProject
+                       if (child instanceof IFile || child instanceof IFolder) {
+                               IResource resource= (IResource)child;
+                               if (resource.isAccessible() && CoreModel.hasCNature(resource.getProject())) {
+                                       if ((newChild= CoreModel.getDefault().create(resource)) != null) {
+                                               iter.remove();
+                                               convertedChildren.add(newChild);
+                                       }
+                               }
+                       }
+               }
+               if (!convertedChildren.isEmpty()) {
+                       currentChildren.addAll(convertedChildren);
+                       return true;
+               }
+               return false;
+       }
+
+       @Override
+       protected void postContainerRefresh(final IParent container, final ICProject cproject) {
+               postRefreshable(new RefreshContainer(container, cproject.getProject()));
+       }
+       @Override
+       protected void postRefresh(final Object element) {
+               if (element instanceof ICModel) {
+                       // don't refresh workspace root
+//                     super.postRefresh(fRealInput);
+               } else if (element instanceof ICProject) {
+                       super.postRefresh(((ICProject)element).getProject());
+               } else if (element instanceof ICElement) {
+                       super.postRefresh(element);
+               } else if (element instanceof IResource) {
+                       IProject project= ((IResource)element).getProject();
+                       if (CoreModel.hasCNature(project)) {
+                               super.postRefresh(element);
+                       }
+               }
+       }
+
+       @Override
+       protected void postAdd(final Object parent, final Object element) {
+               if (parent instanceof ICModel) {
+                       if (element instanceof ICElement) {
+                               super.postAdd(fRealInput, element);
+                       } else if (element instanceof IProject) {
+                               if (CoreModel.hasCNature((IProject)element)) {
+                                       super.postAdd(fRealInput, element);
+                               }
+                       }
+               } else if (parent instanceof ICProject) {
+                       super.postAdd(((ICProject)parent).getProject(), element);
+               } else if (parent instanceof ICElement) {
+                       super.postAdd(parent, element);
+               } else if (element instanceof IResource) {
+                       IProject project= ((IResource)element).getProject();
+                       if (CoreModel.hasCNature(project)) {
+                               super.postAdd(parent, element);
+                       }
+               }
+       }
+
+       @Override
+       protected void postRemove(final Object element) {
+               postRefresh(internalGetParent(element));
+       }
+
+       @Override
+       protected void postProjectStateChanged(final Object element) {
+               if (element instanceof ICModel) {
+                       super.postProjectStateChanged(fRealInput);
+               } else if (element instanceof ICProject) {
+                       super.postProjectStateChanged(((ICProject)element).getProject());
+               } else {
+                       super.postProjectStateChanged(element);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDragAdapterAssistant.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDragAdapterAssistant.java
new file mode 100644 (file)
index 0000000..6243705
--- /dev/null
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.navigator;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.dnd.FileTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.ui.navigator.CommonDragAdapterAssistant;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+/**
+ * A Common Navigator drag assistant supporting <code>LocalSelectionTransfer</code> of 
+ * <code>ICElement</code>s being also <code>ISourceReference</code>s and 
+ * <code>FileTransfer</code> for external translation units.
+ * 
+ * @see org.eclipse.cdt.internal.ui.cview.SelectionTransferDragAdapter
+ */
+public class CNavigatorDragAdapterAssistant extends CommonDragAdapterAssistant {
+
+       private static final Transfer[] TRANSFERS = new Transfer[] {
+               LocalSelectionTransfer.getTransfer(),
+               FileTransfer.getInstance()
+       };
+
+       /*
+        * @see org.eclipse.ui.navigator.CommonDragAdapterAssistant#getSupportedTransferTypes()
+        */
+       @Override
+       public Transfer[] getSupportedTransferTypes() {
+               return TRANSFERS;
+       }
+
+       /*
+        * @see org.eclipse.ui.navigator.CommonDragAdapterAssistant#setDragData(org.eclipse.swt.dnd.DragSourceEvent, org.eclipse.jface.viewers.IStructuredSelection)
+        */
+       @Override
+       public boolean setDragData(DragSourceEvent event, IStructuredSelection selection) {
+               if (selection != null) {
+                       if (LocalSelectionTransfer.getTransfer().isSupportedType(event.dataType)) {
+                               boolean applicable= false;
+                               for (Iterator<?> iter= (selection).iterator(); iter.hasNext();) {
+                                       Object element= iter.next();
+                                       if (element instanceof ICElement) {
+                                               if (element instanceof ITranslationUnit) {
+                                                       continue;
+                                               }
+                                               if (!(element instanceof ISourceReference)) {
+                                                       return false;
+                                               }
+                                               applicable= true;
+                                       }
+                               }
+                               if (applicable) {
+                                       event.data = selection;
+                                       return true;
+                               }
+                       } else if (FileTransfer.getInstance().isSupportedType(event.dataType)) {
+                               List<String> files= new ArrayList<String>();
+                               for (Iterator<?> iter= (selection).iterator(); iter.hasNext();) {
+                                       Object element= iter.next();
+                                       if (element instanceof ITranslationUnit) {
+                                               ITranslationUnit tu= (ITranslationUnit) element;
+                                               IPath location= tu.getLocation();
+                                               if (location != null) {
+                                                       files.add(location.toOSString());
+                                               }
+                                       }
+                               }
+                               if (!files.isEmpty()) {
+                                       event.data = files.toArray(new String[files.size()]);
+                                       return true;
+                               }
+                       }
+               }
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDropAdapterAssistant.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDropAdapterAssistant.java
new file mode 100644 (file)
index 0000000..4458122
--- /dev/null
@@ -0,0 +1,530 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.navigator;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.FileTransfer;
+import org.eclipse.swt.dnd.TransferData;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.actions.CopyFilesAndFoldersOperation;
+import org.eclipse.ui.actions.MoveFilesAndFoldersOperation;
+import org.eclipse.ui.actions.ReadOnlyStateChecker;
+import org.eclipse.ui.ide.dialogs.ImportTypeDialog;
+import org.eclipse.ui.navigator.CommonDropAdapter;
+import org.eclipse.ui.navigator.CommonDropAdapterAssistant;
+import org.eclipse.ui.part.ResourceTransfer;
+
+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.ISourceReference;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+import org.eclipse.cdt.internal.ui.cview.CViewMessages;
+import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
+
+/**
+ * A Common Navigator drop adapter assistant handling dropping of <code>ICElement</code>s.
+ * 
+ * @see org.eclipse.cdt.internal.ui.cview.SelectionTransferDropAdapter
+ */
+public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant {
+
+       private static final IResource[] NO_RESOURCES = new IResource[0];
+
+       /*
+        * @see org.eclipse.ui.navigator.CommonDropAdapterAssistant#isSupportedType(org.eclipse.swt.dnd.TransferData)
+        */
+       @Override
+       public boolean isSupportedType(TransferData transferType) {
+               return super.isSupportedType(transferType)
+                               || ResourceTransfer.getInstance().isSupportedType(transferType)
+                               || FileTransfer.getInstance().isSupportedType(transferType);
+       }
+
+       /*
+        * @see org.eclipse.ui.navigator.CommonDropAdapterAssistant#handleDrop(org.eclipse.ui.navigator.CommonDropAdapter, org.eclipse.swt.dnd.DropTargetEvent, java.lang.Object)
+        */
+       @Override
+       public IStatus handleDrop(CommonDropAdapter dropAdapter,
+                       DropTargetEvent event, Object target) {
+
+               try {
+                       // drop in folder
+                       if (target instanceof ICContainer || 
+                                       target instanceof ICProject || 
+                                       target instanceof IContainer ||
+                                       (dropAdapter.getCurrentOperation() == DND.DROP_COPY && (
+                                                       target instanceof IFile ||
+                                                       target instanceof ITranslationUnit))) {
+       
+                               final Object data= event.data;
+                               if (data == null) {
+                                       return Status.CANCEL_STATUS;
+                               }
+                               final IContainer destination= getDestination(target);
+                               if (destination == null) {
+                                       return Status.CANCEL_STATUS;
+                               }
+                               IResource[] resources = null;
+                               TransferData currentTransfer = dropAdapter.getCurrentTransfer();
+                               final int dropOperation = dropAdapter.getCurrentOperation();
+                               if (LocalSelectionTransfer.getTransfer().isSupportedType(
+                                               currentTransfer)) {
+                                       resources = getSelectedResources();
+                                       if (target instanceof ITranslationUnit) {
+                                               if (handleDropCopy(target, event).isOK()) {
+                                                       // drop inside translation unit - we are done
+                                                       return Status.OK_STATUS;
+                                               }
+                                       }
+                               } else if (ResourceTransfer.getInstance().isSupportedType(
+                                               currentTransfer)) {
+                                       resources = (IResource[]) event.data;
+                               }
+                               if (FileTransfer.getInstance().isSupportedType(currentTransfer)) {
+                                       final String[] names = (String[]) data;
+                                       // Run the import operation asynchronously. 
+                                       // Otherwise the drag source (e.g., Windows Explorer) will be blocked 
+                                       // while the operation executes. Fixes bug 35796.
+                                       Display.getCurrent().asyncExec(new Runnable() {
+                                               public void run() {
+                                                       getShell().forceActive();
+                                                       CopyFilesAndFoldersOperation op= new CopyFilesAndFoldersOperation(getShell());
+                                                       op.copyOrLinkFiles(names, destination, dropOperation);
+                                               }
+                                       });
+                               } else if (event.detail == DND.DROP_COPY || event.detail == DND.DROP_LINK) {
+                                       return performResourceCopy(dropAdapter, getShell(), resources);
+                               } else {
+                                       ReadOnlyStateChecker checker = new ReadOnlyStateChecker(
+                                               getShell(), 
+                                               "Move Resource Action", //$NON-NLS-1$
+                                               "Move Resource Action");//$NON-NLS-1$   
+                                       resources = checker.checkReadOnlyResources(resources);
+                                       MoveFilesAndFoldersOperation operation = new MoveFilesAndFoldersOperation(getShell());
+                                       operation.copyResources(resources, destination);
+                               }
+                               return Status.OK_STATUS;
+                       }
+               
+                       switch(event.detail) {
+                               case DND.DROP_MOVE:
+                                       return handleDropMove(target, event);
+                               case DND.DROP_COPY:
+                                       return handleDropCopy(target, event);
+                       }
+               } catch (CModelException e){
+                       ExceptionHandler.handle(e, CViewMessages.SelectionTransferDropAdapter_error_title, CViewMessages.SelectionTransferDropAdapter_error_message); 
+                       return e.getStatus();
+               } catch(InvocationTargetException e) {
+                       ExceptionHandler.handle(e, CViewMessages.SelectionTransferDropAdapter_error_title, CViewMessages.SelectionTransferDropAdapter_error_exception); 
+                       return Status.CANCEL_STATUS;
+               } catch (InterruptedException e) {
+                       //ok
+               } finally {
+                       // The drag source listener must not perform any operation
+                       // since this drop adapter did the remove of the source even
+                       // if we moved something.
+                       event.detail= DND.DROP_NONE;
+               }
+               return Status.CANCEL_STATUS;
+       }
+
+       /*
+        * @see org.eclipse.ui.navigator.CommonDropAdapterAssistant#validateDrop(java.lang.Object, int, org.eclipse.swt.dnd.TransferData)
+        */
+       @Override
+       public IStatus validateDrop(Object target, int operation,
+                       TransferData transferType) {
+
+               // drop in folder
+               if (target instanceof ICContainer || 
+                               target instanceof ICProject || 
+                               target instanceof IContainer ||
+                               (operation == DND.DROP_COPY && (
+                                               target instanceof IFile ||
+                                               target instanceof ITranslationUnit))) {
+                       IContainer destination= getDestination(target);
+                       if (LocalSelectionTransfer.getTransfer().isSupportedType(transferType)) {
+                               IResource[] selectedResources= getSelectedResources();
+                               if (selectedResources.length > 0) {
+                                       for (IResource res : selectedResources) {
+                                               if(res instanceof IProject) {
+                                                       // drop of projects not supported on other IResources
+                                                       // "Path for project must have only one segment."
+                                                       return Status.CANCEL_STATUS;
+                                               }
+                                       }
+                                       if (operation == DND.DROP_COPY || operation == DND.DROP_LINK) {
+                                               CopyFilesAndFoldersOperation op = new CopyFilesAndFoldersOperation(getShell());
+                                               if (op.validateDestination(destination, selectedResources) == null) {
+                                                       return Status.OK_STATUS;
+                                               }
+                                       } else {
+                                               MoveFilesAndFoldersOperation op = new MoveFilesAndFoldersOperation(getShell());
+                                               if (op.validateDestination(destination, selectedResources) == null) {
+                                                       return Status.OK_STATUS;
+                                               }
+                                       }
+                               }
+                       } else if (FileTransfer.getInstance().isSupportedType(transferType)) {
+                               String[] sourceNames = (String[]) FileTransfer.getInstance().nativeToJava(transferType);
+                               if (sourceNames == null) {
+                                       // source names will be null on Linux. Use empty names to do
+                                       // destination validation.
+                                       // Fixes bug 29778
+                                       sourceNames = new String[0];
+                               }
+                               CopyFilesAndFoldersOperation copyOperation = new CopyFilesAndFoldersOperation(
+                                               getShell());
+                               if (null != copyOperation.validateImportDestination(destination,
+                                               sourceNames)) {
+                                       return Status.CANCEL_STATUS;
+                               }
+                               return Status.OK_STATUS;
+                       }
+               }
+
+               if (LocalSelectionTransfer.getTransfer().isSupportedType(transferType)) {
+                       try {
+                               switch(operation) {
+                                       case DND.DROP_DEFAULT:
+                                               return handleValidateMove(target); 
+                                       case DND.DROP_COPY:
+                                               return handleValidateCopy(target);
+                                       case DND.DROP_MOVE:
+                                               return handleValidateMove(target);
+                               }
+                       } catch (CModelException e){
+                               ExceptionHandler.handle(e, CViewMessages.SelectionTransferDropAdapter_error_title, CViewMessages.SelectionTransferDropAdapter_error_message); 
+                       }
+               }
+               return Status.CANCEL_STATUS;
+       }
+
+       private IStatus handleValidateCopy(Object target) throws CModelException{
+               if (target != null) {
+
+                       ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
+                       ICElement[] cElements= getCElements(selection);
+                       
+                       if (cElements == null || cElements.length == 0) {
+                               return Status.CANCEL_STATUS;    
+                       }
+                       if (!canCopyElements(cElements))
+                               return Status.CANCEL_STATUS;    
+       
+                       if (target instanceof ISourceReference) {
+                               for (ICElement cElement : cElements) {
+                                       if (cElement.getElementType() <= ICElement.C_UNIT) {
+                                               return Status.CANCEL_STATUS;
+                                       }
+                               }
+                               return Status.OK_STATUS;
+                       }
+               
+               }
+               return Status.CANCEL_STATUS;
+       }
+
+       private IStatus handleValidateMove(Object target) throws CModelException {
+               if (target != null) {
+
+                       ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
+                       ICElement[] cElements= getCElements(selection);
+
+                       if (cElements == null || cElements.length == 0) {
+                               return Status.CANCEL_STATUS;    
+                       }
+                       if (Arrays.asList(cElements).contains(target)) {
+                               return Status.CANCEL_STATUS;    
+                       }
+                       if (!canMoveElements(cElements)) {
+                               return Status.CANCEL_STATUS;    
+                       }
+                       if (target instanceof ISourceReference) {
+                               for (ICElement cElement : cElements) {
+                                       if (cElement.getElementType() <= ICElement.C_UNIT) {
+                                               return Status.CANCEL_STATUS;
+                                       }
+                               }
+                               return Status.OK_STATUS;
+                       }
+               
+               }
+               return Status.CANCEL_STATUS;
+       }
+
+       /**
+        * Performs a resource copy.
+        * Cloned from ResourceDropAdapterAssistant to support linked resources (bug 319405).
+        */
+       private IStatus performResourceCopy(CommonDropAdapter dropAdapter,
+                       Shell shell, IResource[] sources) {
+               IContainer target = getDestination(dropAdapter.getCurrentTarget());
+               if (target == null) {
+                       return Status.CANCEL_STATUS;
+               }
+               
+               boolean shouldLinkAutomatically = false;
+               if (target.isVirtual()) {
+                       shouldLinkAutomatically = true;
+                       for (int i = 0; i < sources.length; i++) {
+                               if ((sources[i].getType() != IResource.FILE) && (sources[i].getLocation() != null)) {
+                                       // If the source is a folder, but the location is null (a
+                                       // broken link, for example),
+                                       // we still generate a link automatically (the best option).
+                                       shouldLinkAutomatically = false;
+                                       break;
+                               }
+                       }
+               }
+
+               CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(shell);
+               // if the target is a virtual folder and all sources are files, then
+               // automatically create links
+               if (shouldLinkAutomatically) {
+                       operation.setCreateLinks(true);
+                       operation.copyResources(sources, target);
+               } else {
+                       boolean allSourceAreLinksOrVirtualFolders = true;
+                       for (int i = 0; i < sources.length; i++) {
+                               if (!sources[i].isVirtual() && !sources[i].isLinked()) {
+                                       allSourceAreLinksOrVirtualFolders = false;
+                                       break;
+                               }
+                       }
+                       // if all sources are either links or groups, copy then normally,
+                       // don't show the dialog
+                       if (!allSourceAreLinksOrVirtualFolders) {
+                               ImportTypeDialog dialog = new ImportTypeDialog(getShell(), dropAdapter.getCurrentOperation(), sources, target);
+                               dialog.setResource(target);
+                               if (dialog.open() == Window.OK) {
+                                       if (dialog.getSelection() == ImportTypeDialog.IMPORT_VIRTUAL_FOLDERS_AND_LINKS)
+                                               operation.setVirtualFolders(true);
+                                       if (dialog.getSelection() == ImportTypeDialog.IMPORT_LINK)
+                                               operation.setCreateLinks(true);
+                                       if (dialog.getVariable() != null)
+                                               operation.setRelativeVariable(dialog.getVariable());
+                                       operation.copyResources(sources, target);
+                               } else
+                                       return Status.CANCEL_STATUS;
+                       } else
+                               operation.copyResources(sources, target);
+               }
+
+               return Status.OK_STATUS;
+       }
+
+       private IStatus handleDropCopy(final Object target, DropTargetEvent event) throws CModelException, InvocationTargetException, InterruptedException{
+               ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
+               final ICElement[] cElements= getCElements(selection);
+
+               if (target instanceof ICElement && cElements.length > 0) {
+                       ICElement cTarget = (ICElement)target;
+                       ICElement parent = cTarget;
+                       boolean isTargetTranslationUnit = cTarget instanceof ITranslationUnit;
+                       if (!isTargetTranslationUnit) {
+                               parent = cTarget.getParent();
+                       }
+                       final ICElement[] containers = new ICElement[cElements.length];
+                       for (int i = 0; i < containers.length; ++i) {
+                               containers[i] = parent;
+                       }
+                       ICElement[] neighbours = null;
+                       if (!isTargetTranslationUnit) {
+                               neighbours = new ICElement[cElements.length];
+                               for (int i = 0; i < neighbours.length; ++i) {
+                                       neighbours[i] = cTarget;
+                               }
+                       }
+                       final ICElement[] siblings = neighbours;
+                       IRunnableWithProgress runnable = new IRunnableWithProgress() {
+                               public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+                                       try {
+                                               CoreModel.getDefault().getCModel().copy(cElements, containers, siblings, null, false, monitor);
+                                       } catch (CModelException e) {
+                                               throw new InvocationTargetException(e);
+                                       }
+                               }
+                       };
+                       run(runnable);
+                       return Status.OK_STATUS;
+               }
+               return Status.CANCEL_STATUS;
+       }
+
+       private IStatus handleDropMove(final Object target, DropTargetEvent event) throws CModelException, InvocationTargetException, InterruptedException{
+               ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
+               final ICElement[] cElements= getCElements(selection);
+               
+               if (target instanceof ICElement) {
+                       ICElement cTarget = (ICElement)target;
+                       ICElement parent = cTarget;
+                       boolean isTargetTranslationUnit = cTarget instanceof ITranslationUnit;
+                       if (!isTargetTranslationUnit) {
+                               parent = cTarget.getParent();
+                       }
+                       final ICElement[] containers = new ICElement[cElements.length];
+                       for (int i = 0; i < containers.length; ++i) {
+                               containers[i] = parent;
+                       }
+                       ICElement[] neighbours = null;
+                       if (!isTargetTranslationUnit) {
+                               neighbours = new ICElement[cElements.length];
+                               for (int i = 0; i < neighbours.length; ++i) {
+                                       neighbours[i] = cTarget;
+                               }
+                       }
+                       final ICElement[] siblings = neighbours;
+                       IRunnableWithProgress runnable = new IRunnableWithProgress() {
+                               public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+                                       try {
+                                               CoreModel.getDefault().getCModel().move(cElements, containers, siblings, null, false, monitor);
+                                       } catch (CModelException e) {
+                                               throw new InvocationTargetException(e);
+                                       }
+                               }
+                       };
+                       run(runnable);
+                       return Status.OK_STATUS;
+               }
+               return Status.CANCEL_STATUS;
+       }
+
+       public void run(IRunnableWithProgress runnable) throws InterruptedException, InvocationTargetException {
+               IRunnableContext context= new ProgressMonitorDialog(getShell());
+               context.run(true, true, runnable);
+       }
+
+       public static ICElement[] getCElements(ISelection selection) {
+               if (!(selection instanceof IStructuredSelection)) {
+                       return null;
+               }
+               List<?> elements = ((IStructuredSelection)selection).toList();
+               List<Object> resources= new ArrayList<Object>(elements.size());
+               for (Object element : elements) {
+                       if (element instanceof ITranslationUnit) {
+                               continue;
+                       }
+                       if (element instanceof ICElement)
+                               resources.add(element);
+               }
+               return resources.toArray(new ICElement[resources.size()]);
+       }
+
+       private static boolean canCopyElements(ICElement[] cElements) {
+               if (cElements != null) {
+                       return hasCommonParent(cElements);
+               }
+               return false;
+       }               
+       
+       private static boolean canMoveElements(ICElement[] cElements) {
+               if (cElements != null) {
+                       return hasCommonParent(cElements);
+               }
+               return false;
+       }               
+       
+       private static boolean hasCommonParent(ICElement[] elements) {
+               if (elements.length > 1) {
+                       ICElement parent = elements[0];
+                       for (int i = 0; i < elements.length; ++i) {
+                               ICElement p = elements[i].getParent();
+                               if (parent == null) {
+                                       if (p!= null) 
+                                               return false;
+                               } 
+                               else if (!parent.equals(p))
+                                       return false;
+                       }
+               }
+               return true;
+       }
+
+       private IContainer getDestination(Object dropTarget) {
+               if (dropTarget instanceof IContainer) {
+                       return (IContainer)dropTarget;
+               } else if (dropTarget instanceof ICElement) {
+                       return getDestination(((ICElement)dropTarget).getResource());
+               } else if (dropTarget instanceof IFile) {
+                       return ((IFile)dropTarget).getParent();
+               }
+               return null;
+       }
+
+       /**
+        * Returns the resource selection from the LocalSelectionTransfer.
+        * 
+        * @return the resource selection from the LocalSelectionTransfer
+        */
+       private IResource[] getSelectedResources() {
+
+               ISelection selection = LocalSelectionTransfer.getTransfer()
+                               .getSelection();
+               if (selection instanceof IStructuredSelection) {
+                       return getSelectedResources((IStructuredSelection)selection);
+               } 
+               return NO_RESOURCES;
+       }
+
+       /**
+        * Returns the resource selection from the LocalSelectionTransfer.
+        * 
+        * @return the resource selection from the LocalSelectionTransfer
+        */
+       private IResource[] getSelectedResources(IStructuredSelection selection) {
+               ArrayList<Object> selectedResources = new ArrayList<Object>();
+
+               for (Iterator<?> i = selection.iterator(); i.hasNext();) {
+                       Object o = i.next();
+                       if (o instanceof IResource) {
+                               selectedResources.add(o);
+                       } else if (o instanceof IAdaptable) {
+                               IAdaptable a = (IAdaptable) o;
+                               IResource r = (IResource) a.getAdapter(IResource.class);
+                               if (r != null) {
+                                       selectedResources.add(r);
+                               }
+                       }
+               }
+               return selectedResources
+                               .toArray(new IResource[selectedResources.size()]);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorEditActionGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorEditActionGroup.java
new file mode 100644 (file)
index 0000000..be58d08
--- /dev/null
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.navigator;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.SameShellProvider;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IWorkbenchCommandConstants;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.actions.DeleteResourceAction;
+import org.eclipse.ui.actions.TextActionHandler;
+import org.eclipse.ui.ide.ResourceSelectionUtil;
+import org.eclipse.ui.navigator.ICommonMenuConstants;
+
+import org.eclipse.cdt.internal.ui.cview.CopyAction;
+import org.eclipse.cdt.internal.ui.cview.PasteAction;
+
+/**
+ * Provides clipboard actions.
+ *
+ * A clone of org.eclipse.ui.internal.navigator.resources.actions.EditActionGroup.
+ */
+public class CNavigatorEditActionGroup extends ActionGroup {
+       private Clipboard clipboard;
+
+       private CopyAction copyAction;
+
+       private DeleteResourceAction deleteAction;
+
+       private PasteAction pasteAction; 
+
+       private TextActionHandler textActionHandler;
+
+       private Shell shell;
+
+       /**
+        * @param aShell
+        */
+       public CNavigatorEditActionGroup(Shell aShell) {
+               shell = aShell; 
+               makeActions();
+       }
+
+       @Override
+       public void dispose() {
+               if (clipboard != null) {
+                       clipboard.dispose();
+                       clipboard = null;
+               }
+               super.dispose();
+       }
+
+       @Override
+       public void fillContextMenu(IMenuManager menu) {
+               IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
+
+               boolean anyResourceSelected = !selection.isEmpty()
+                               && ResourceSelectionUtil.allResourcesAreOfType(selection,
+                                               IResource.PROJECT | IResource.FOLDER | IResource.FILE);
+
+               copyAction.selectionChanged(selection);
+               menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, copyAction);
+               pasteAction.selectionChanged(selection);
+               //menu.insertAfter(copyAction.getId(), pasteAction);
+               menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, pasteAction);
+
+               if (anyResourceSelected) {
+                       deleteAction.selectionChanged(selection);
+                       //menu.insertAfter(pasteAction.getId(), deleteAction);
+                       menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, deleteAction);
+               }
+       }
+
+       @Override
+       public void fillActionBars(IActionBars actionBars) {
+               if (textActionHandler == null) {
+                       textActionHandler = new TextActionHandler(actionBars); // hook handlers
+               }
+               textActionHandler.setCopyAction(copyAction);
+               textActionHandler.setPasteAction(pasteAction);
+               textActionHandler.setDeleteAction(deleteAction);
+               //renameAction.setTextActionHandler(textActionHandler);
+               updateActionBars();
+
+//             textActionHandler.updateActionBars();
+               actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyAction);
+               actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), pasteAction);
+               actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteAction);
+       }
+
+       protected void makeActions() {
+               final SameShellProvider shellProvider= new SameShellProvider(shell);
+               clipboard = new Clipboard(shell.getDisplay());
+
+               pasteAction = new PasteAction(shell, clipboard);
+               ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
+               pasteAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED));
+               pasteAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
+               pasteAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_PASTE);
+
+               copyAction = new CopyAction(shell, clipboard, pasteAction);
+               copyAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED));
+               copyAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
+               copyAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY);
+               deleteAction = new DeleteResourceAction(shellProvider);
+               deleteAction.setDisabledImageDescriptor(
+                               images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
+               deleteAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
+               deleteAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_DELETE);
+       }
+
+       @Override
+       public void updateActionBars() {
+               IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
+
+               copyAction.selectionChanged(selection);
+               pasteAction.selectionChanged(selection);
+               deleteAction.selectionChanged(selection); 
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorEditActionProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorEditActionProvider.java
new file mode 100644 (file)
index 0000000..906901c
--- /dev/null
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.navigator;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
+
+import org.eclipse.cdt.ui.actions.GenerateActionGroup;
+
+import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
+
+/**
+ * Common Navigator action provider for clipboard actions.
+ */
+public class CNavigatorEditActionProvider extends CommonActionProvider {
+        
+       private CNavigatorEditActionGroup fEditGroup;
+       private GenerateActionGroup fGenerateGroup;
+
+       /*
+        * @see org.eclipse.ui.navigator.CommonActionProvider#init(org.eclipse.ui.navigator.ICommonActionExtensionSite)
+        */
+       @Override
+       public void init(ICommonActionExtensionSite anActionSite) {
+               super.init(anActionSite);
+               
+               fEditGroup = new CNavigatorEditActionGroup(anActionSite.getViewSite().getShell());
+
+               ICommonViewerWorkbenchSite workbenchSite= null;
+               if (anActionSite.getViewSite() instanceof ICommonViewerWorkbenchSite) {
+                       workbenchSite= (ICommonViewerWorkbenchSite) anActionSite.getViewSite();
+               }
+               if (workbenchSite != null) {
+                       if (workbenchSite.getPart() != null && workbenchSite.getPart() instanceof IViewPart) {
+                               IViewPart viewPart= (IViewPart) workbenchSite.getPart();
+
+                               fGenerateGroup = new GenerateActionGroup(viewPart);
+                       }
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.actions.ActionGroup#dispose()
+        */
+       @Override
+       public void dispose() {
+               fEditGroup.dispose();
+               if (fGenerateGroup != null) {
+                       fGenerateGroup.dispose();
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars)
+        */
+       @Override
+       public void fillActionBars(IActionBars actionBars) { 
+               fEditGroup.fillActionBars(actionBars);
+               if (fGenerateGroup != null) {
+                       fGenerateGroup.fillActionBars(actionBars);
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
+        */
+       @Override
+       public void fillContextMenu(IMenuManager menu) { 
+               fEditGroup.fillContextMenu(menu);
+               if (fGenerateGroup != null) {
+                       fGenerateGroup.fillContextMenu(menu);
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.actions.ActionGroup#setContext(org.eclipse.ui.actions.ActionContext)
+        */
+       @Override
+       public void setContext(ActionContext context) { 
+               if (context != null) {
+                       // convert non-IResource to IResources on the fly
+                       ISelection selection = SelectionConverter.convertSelectionToResources(context.getSelection());
+                       fEditGroup.setContext(new ActionContext(selection));
+               } else {
+                       fEditGroup.setContext(context);
+               }
+               if (fGenerateGroup != null) {
+                       fGenerateGroup.setContext(context);
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.actions.ActionGroup#updateActionBars()
+        */
+       @Override
+       public void updateActionBars() { 
+               fEditGroup.updateActionBars();
+               if (fGenerateGroup != null) {
+                       fGenerateGroup.updateActionBars();
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorLabelProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorLabelProvider.java
new file mode 100644 (file)
index 0000000..1b96300
--- /dev/null
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.navigator;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.eclipse.ui.navigator.ICommonContentExtensionSite;
+import org.eclipse.ui.navigator.ICommonLabelProvider;
+
+import org.eclipse.cdt.core.model.IArchiveContainer;
+import org.eclipse.cdt.core.model.IBinary;
+import org.eclipse.cdt.core.model.IBinaryContainer;
+import org.eclipse.cdt.core.model.IBinaryModule;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+
+import org.eclipse.cdt.internal.ui.cview.CViewLabelProvider;
+import org.eclipse.cdt.internal.ui.cview.CViewMessages;
+import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
+
+/**
+ * A label provider suitable for the Common Navigator providing also
+ * status message text for the current selected item.
+ * 
+ * @see org.eclipse.cdt.internal.ui.cview.CView#createLabelProvider
+ * @see org.eclipse.cdt.internal.ui.cview.CView#getStatusLineMessage
+ */
+public class CNavigatorLabelProvider extends CViewLabelProvider implements ICommonLabelProvider {
+
+       /**
+        * Create a default label provider.
+        */
+       public CNavigatorLabelProvider() {
+               super(AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS,
+                               AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS
+                                               | CElementImageProvider.SMALL_ICONS);
+               addLabelDecorator(new CNavigatorProblemsLabelDecorator());
+       }
+
+       /*
+        * @see org.eclipse.ui.navigator.ICommonLabelProvider#init(org.eclipse.ui.navigator.ICommonContentExtensionSite)
+        */
+       public void init(ICommonContentExtensionSite extensionSite) {
+               // no-op
+       }
+
+       /*
+        * @see org.eclipse.ui.navigator.IMementoAware#restoreState(org.eclipse.ui.IMemento)
+        */
+       public void restoreState(IMemento memento) {
+               // no-op
+       }
+
+       /*
+        * @see org.eclipse.ui.navigator.IMementoAware#saveState(org.eclipse.ui.IMemento)
+        */
+       public void saveState(IMemento memento) {
+               // no-op
+       }
+
+       /*
+        * @see org.eclipse.ui.navigator.IDescriptionProvider#getDescription(java.lang.Object)
+        */
+       public String getDescription(Object element) {
+               if (element instanceof IResource) {
+                       return ((IResource) element).getFullPath().makeRelative().toString();
+               } else if (element instanceof ICElement) {
+                       ICElement celement = (ICElement) element;
+                       IResource res = (IResource) celement.getAdapter(IResource.class);
+                       if (res != null) {
+                               return res.getFullPath().toString();
+                       } else if (celement.getElementType() == ICElement.C_VCONTAINER) {
+                               if (celement instanceof IBinaryContainer) {
+                                       ICProject cproj = celement.getCProject();
+                                       if (cproj != null) {
+                                               return cproj.getPath() + CViewMessages.CView_binaries; 
+                                       }
+                               } else if (celement instanceof IArchiveContainer) {
+                                       ICProject cproj = celement.getCProject();
+                                       if (cproj != null) {
+                                               return cproj.getPath() + CViewMessages.CView_archives; 
+                                       }
+                               } else if (celement instanceof IBinaryModule) {
+                                       IBinary bin = ((IBinaryModule) celement).getBinary();
+                                       return bin.getPath() + ":" + celement.getElementName(); //$NON-NLS-1$
+                               }
+                       } else if (celement.getElementType() > ICElement.C_UNIT) {
+                               return celement.getPath().toString() + " - [" + celement.getElementName() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
+                       }
+                       return celement.getElementName();
+               } else if (element instanceof IWorkbenchAdapter) {
+                       IWorkbenchAdapter wAdapter = (IWorkbenchAdapter)element;
+                       return wAdapter.getLabel(element);
+               }
+               return null;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorLinkHelper.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorLinkHelper.java
new file mode 100644 (file)
index 0000000..80aac59
--- /dev/null
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.navigator;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.ide.ResourceUtil;
+import org.eclipse.ui.navigator.ILinkHelper;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.IWorkingCopyManager;
+
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+
+/**
+ * Provide support for linking view selection with active editor.
+ * 
+ * @since 4.0
+ */
+public class CNavigatorLinkHelper implements ILinkHelper {
+
+       /*
+        * @see org.eclipse.ui.navigator.ILinkHelper#activateEditor(org.eclipse.ui.IWorkbenchPage, org.eclipse.jface.viewers.IStructuredSelection)
+        */
+       public void activateEditor(IWorkbenchPage page, IStructuredSelection selection) {
+               if (selection == null || selection.isEmpty())
+                       return;
+               Object element= selection.getFirstElement();
+               IEditorPart part= EditorUtility.isOpenInEditor(element);
+               if (part != null) {
+                       page.bringToTop(part);
+                       if (element instanceof ICElement && !(element instanceof ITranslationUnit)) {
+                               EditorUtility.revealInEditor(part, (ICElement) element);
+                       }
+               }
+
+       }
+
+       /*
+        * @see org.eclipse.ui.navigator.ILinkHelper#findSelection(org.eclipse.ui.IEditorInput)
+        */
+       public IStructuredSelection findSelection(IEditorInput input) {
+               IWorkingCopyManager mgr= CUIPlugin.getDefault().getWorkingCopyManager();
+               Object element= mgr.getWorkingCopy(input);
+               if (element == null) {
+                       IFile file = ResourceUtil.getFile(input);
+                       if (file != null && CoreModel.hasCNature(file.getProject())) {
+                               element= CoreModel.getDefault().create(file);
+                       }
+               } else {
+                       ITranslationUnit tUnit= ((IWorkingCopy) element).getOriginalElement();
+                       IFile file= (IFile) tUnit.getResource();
+                       if (file != null) {
+                               element= CoreModel.getDefault().create(file);
+                               if (element == null) {
+                                       element= file;
+                               }
+                       } else {
+                               element= tUnit;
+                       }
+               }
+               return (element != null) ? new StructuredSelection(element) : StructuredSelection.EMPTY;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenActionProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenActionProvider.java
new file mode 100644 (file)
index 0000000..25bfb64
--- /dev/null
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.navigator;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.ICommonActionConstants;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
+
+/**
+ * A Common Navigator action provider providing the contributions
+ * from the open editor action group.
+ * 
+ * @see CNavigatorOpenEditorActionGroup
+ */
+public class CNavigatorOpenActionProvider extends CommonActionProvider {
+
+       private CNavigatorOpenEditorActionGroup fOpenGroup;
+
+       /*
+        * @see org.eclipse.ui.navigator.CommonActionProvider#init(org.eclipse.ui.navigator.ICommonActionExtensionSite)
+        */
+       @Override
+       public void init(ICommonActionExtensionSite site) {
+               ICommonViewerWorkbenchSite workbenchSite = null;
+               if (site.getViewSite() instanceof ICommonViewerWorkbenchSite) {
+                       workbenchSite = (ICommonViewerWorkbenchSite) site.getViewSite();
+               }
+               if (workbenchSite != null) {
+                       if (workbenchSite.getPart() != null && workbenchSite.getPart() instanceof IViewPart) {
+                               IViewPart viewPart = (IViewPart) workbenchSite.getPart();
+
+                               fOpenGroup = new CNavigatorOpenEditorActionGroup(viewPart);
+                       }
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.actions.ActionGroup#dispose()
+        */
+       @Override
+       public void dispose() {
+               if (fOpenGroup != null) {
+                       fOpenGroup.dispose();
+                       fOpenGroup = null;
+               }
+               super.dispose();
+       }
+
+       /*
+        * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars)
+        */
+       @Override
+       public void fillActionBars(IActionBars actionBars) {
+               if (fOpenGroup != null) {
+                       fOpenGroup.updateActionBars();
+                       if (fOpenGroup.getOpenAction().isEnabled()) {
+                               actionBars.setGlobalActionHandler(ICommonActionConstants.OPEN, fOpenGroup.getOpenAction());
+                       }
+               }
+
+       }
+
+       /*
+        * @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
+        */
+       @Override
+       public void fillContextMenu(IMenuManager menu) {
+               if (fOpenGroup != null) {
+                       fOpenGroup.fillContextMenu(menu);
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.actions.ActionGroup#setContext(org.eclipse.ui.actions.ActionContext)
+        */
+       @Override
+       public void setContext(ActionContext context) {
+               super.setContext(context);
+               if (fOpenGroup != null) {
+                       fOpenGroup.setContext(context);
+               }
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenEditorActionGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenEditorActionGroup.java
new file mode 100644 (file)
index 0000000..8ec337b
--- /dev/null
@@ -0,0 +1,159 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems) - adaptations for Common Navigator
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.navigator;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.actions.OpenFileAction;
+import org.eclipse.ui.actions.OpenInNewWindowAction;
+import org.eclipse.ui.actions.OpenWithMenu;
+import org.eclipse.ui.navigator.ICommonMenuConstants;
+
+import org.eclipse.cdt.core.model.ICElement;
+
+import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
+import org.eclipse.cdt.internal.ui.cview.CViewMessages;
+
+
+/**
+ * This is basically a clone of {@link org.eclipse.cdt.internal.ui.cview.OpenFileGroup},
+ * but without explicit dependency on CView. This opens it up for use in the
+ * Common Navigator framework.
+ * <p>
+ * Contributes an "Open" action for the default editor, an "Open With" sub-menu
+ * for all applicable editors if one or more files are selected.
+ * For all container selections, an "Open In New Window" action is contributed.
+ * </p>
+ * 
+ * @see org.eclipse.cdt.internal.ui.cview.OpenFileGroup
+ * @see org.eclipse.ui.actions.OpenFileAction
+ * @see org.eclipse.ui.actions.OpenWithMenu
+ * @see org.eclipse.ui.actions.OpenInNewWindowAction
+ */
+public class CNavigatorOpenEditorActionGroup extends AbstractCNavigatorActionGroup {
+
+       /** The open file action. */
+       private OpenFileAction fOpenFileAction;
+
+       /**
+        * Create an action group for the given view part.
+        * 
+        * @param viewPart
+        */
+       public CNavigatorOpenEditorActionGroup(IViewPart viewPart) {
+               super(viewPart);
+       }
+
+       @Override
+       protected void makeActions() {
+               fOpenFileAction= new OpenCElementAction(getViewPart().getSite().getPage());
+       }
+
+       @Override
+       public void fillContextMenu(IMenuManager menu) {
+        IStructuredSelection celements= (IStructuredSelection) getContext().getSelection();
+               IStructuredSelection selection= SelectionConverter.convertSelectionToResources(celements);
+
+               fOpenFileAction.selectionChanged(celements);
+               if (fOpenFileAction.isEnabled()) {
+                       menu.appendToGroup(ICommonMenuConstants.GROUP_OPEN, fOpenFileAction);
+                       fillOpenWithMenu(menu, selection);
+               }
+
+               addNewWindowAction(menu, selection);
+       }
+
+       /**
+        * Adds the OpenWith submenu to the context menu.
+        * 
+        * @param menu
+        *            the context menu
+        * @param selection
+        *            the current selection
+        */
+       private void fillOpenWithMenu(IMenuManager menu, IStructuredSelection selection) {
+               // Only supported if exactly one file is selected.
+               if (selection.size() != 1) {
+                       return;
+               }
+               Object element= selection.getFirstElement();
+               if (!(element instanceof IFile)) {
+                       return;
+               }
+
+               MenuManager submenu= new MenuManager(CViewMessages.OpenWithMenu_label, ICommonMenuConstants.GROUP_OPEN_WITH); 
+               submenu.add(new OpenWithMenu(getViewPart().getSite().getPage(), (IFile) element));
+               menu.insertAfter(ICommonMenuConstants.GROUP_OPEN_WITH, submenu);
+       }
+
+       /**
+        * Adds the Open in New Window action to the context menu.
+        * 
+        * @param menu
+        *            the context menu
+        * @param selection
+        *            the current selection
+        */
+       private void addNewWindowAction(IMenuManager menu, IStructuredSelection selection) {
+
+               // Only supported if exactly one container (i.e open project or folder) is selected.
+               if (selection.size() != 1) {
+                       return;
+               }
+               Object element= selection.getFirstElement();
+               if (element instanceof ICElement) {
+                       element= ((ICElement)element).getResource();
+               }
+               if (!(element instanceof IContainer)) {
+                       return;
+               }
+               if (element instanceof IProject && !(((IProject) element).isOpen())) {
+                       return;
+               }
+
+               menu.appendToGroup(ICommonMenuConstants.GROUP_OPEN, new OpenInNewWindowAction(getViewPart().getSite().getWorkbenchWindow(), (IContainer) element));
+       }
+
+    /*
+     * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars)
+     */
+    @Override
+       public void fillActionBars(IActionBars actionBars) {
+    }
+
+    /*
+     * @see org.eclipse.ui.actions.ActionGroup#updateActionBars()
+     */
+    @Override
+       public void updateActionBars() {
+        IStructuredSelection celements= (IStructuredSelection) getContext().getSelection();
+               fOpenFileAction.selectionChanged(celements);
+    }
+
+       /**
+        * Returns the open action managed by this action group. 
+        *
+        * @return the open action
+        */
+       IAction getOpenAction() {
+               return fOpenFileAction;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenViewActionProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenViewActionProvider.java
new file mode 100644 (file)
index 0000000..1233a41
--- /dev/null
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.navigator;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
+
+import org.eclipse.cdt.ui.actions.OpenViewActionGroup;
+
+public class CNavigatorOpenViewActionProvider extends CommonActionProvider {
+
+       private OpenViewActionGroup fOpenViewActionGroup;
+       
+       /*
+        * @see org.eclipse.ui.navigator.CommonActionProvider#init(org.eclipse.ui.navigator.ICommonActionExtensionSite)
+        */
+       @Override
+       public void init(ICommonActionExtensionSite site) {
+               ICommonViewerWorkbenchSite workbenchSite= null;
+               if (site.getViewSite() instanceof ICommonViewerWorkbenchSite) {
+                       workbenchSite= (ICommonViewerWorkbenchSite) site.getViewSite();
+               }
+               if (workbenchSite != null) {
+                       if (workbenchSite.getPart() != null && workbenchSite.getPart() instanceof IViewPart) {
+                               fOpenViewActionGroup= new OpenViewActionGroup(workbenchSite.getPart());
+                               // properties action is already provided by resource extensions
+                               fOpenViewActionGroup.setSuppressProperties(true);
+                       }
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.actions.ActionGroup#dispose()
+        */
+       @Override
+       public void dispose() {
+               if (fOpenViewActionGroup != null) {
+                       fOpenViewActionGroup.dispose();
+                       fOpenViewActionGroup = null;
+               }
+               super.dispose();
+       }
+
+       /*
+        * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars)
+        */
+       @Override
+       public void fillActionBars(IActionBars actionBars) {
+               if (fOpenViewActionGroup != null) {
+                       fOpenViewActionGroup.fillActionBars(actionBars);
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
+        */
+       @Override
+       public void fillContextMenu(IMenuManager menu) {
+               if (fOpenViewActionGroup != null) {
+                       ISelection selection = getContext().getSelection();
+                       if (OpenViewActionGroup.canActionBeAdded(selection)){
+                               fOpenViewActionGroup.fillContextMenu(menu);
+                       }
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.actions.ActionGroup#setContext(org.eclipse.ui.actions.ActionContext)
+        */
+       @Override
+       public void setContext(ActionContext context) {
+               super.setContext(context);
+               if (fOpenViewActionGroup != null) {
+                       fOpenViewActionGroup.setContext(context);
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.actions.ActionGroup#updateActionBars()
+        */
+       @Override
+       public void updateActionBars() {
+               if (fOpenViewActionGroup != null) {
+                       fOpenViewActionGroup.updateActionBars();
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorProblemsLabelDecorator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorProblemsLabelDecorator.java
new file mode 100644 (file)
index 0000000..8f8aa2e
--- /dev/null
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.navigator;
+
+import org.eclipse.core.resources.IResource;
+
+import org.eclipse.cdt.internal.ui.viewsupport.ProblemsLabelDecorator;
+
+/**
+ * A {@link ProblemsLabelDecorator} optimized for use with the Common Navigator.
+ *
+ * @since 4.0
+ */
+public class CNavigatorProblemsLabelDecorator extends ProblemsLabelDecorator {
+
+       /**
+        * Create a problems label decorator for the Common Navigator.
+        */
+       public CNavigatorProblemsLabelDecorator() {
+               super(null);
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.viewsupport.ProblemsLabelDecorator#fireProblemsChanged(org.eclipse.core.resources.IResource[], boolean)
+        */
+       @Override
+       protected void fireProblemsChanged(IResource[] changedResources,
+                       boolean isMarkerChange) {
+               // performance: if the number of changed resources is large, it is faster
+               // to trigger a viewer refresh by setting changedResources to null
+               if (changedResources != null && changedResources.length > 500) {
+                       changedResources= null;
+               }
+               super.fireProblemsChanged(changedResources, isMarkerChange);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorRefactorActionGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorRefactorActionGroup.java
new file mode 100644 (file)
index 0000000..b7f5183
--- /dev/null
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sebastian Davids <sdavids@gmx.de> - Images for menu items (27481)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.navigator;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchCommandConstants;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.actions.MoveResourceAction;
+import org.eclipse.ui.actions.RenameResourceAction;
+import org.eclipse.ui.ide.ResourceSelectionUtil;
+import org.eclipse.ui.navigator.ICommonMenuConstants;
+
+/**
+ * This is the action group for refactor actions move and rename.
+ * 
+ * A clone of org.eclipse.ui.internal.navigator.resources.actions.RefactorActionGroup.
+ */
+public class CNavigatorRefactorActionGroup extends ActionGroup {
+
+       private RenameResourceAction renameAction;
+
+       private MoveResourceAction moveAction;
+
+       private IShellProvider shellProvider;
+
+       private Tree tree;
+
+       /**
+        *  
+        * @param aShell
+        * @param aTree
+        */
+       public CNavigatorRefactorActionGroup(IShellProvider aShell, Tree aTree) {
+               shellProvider = aShell;
+               tree = aTree;
+               makeActions();
+       }
+
+       @Override
+       public void fillContextMenu(IMenuManager menu) {
+               IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
+               boolean anyResourceSelected = !selection.isEmpty()
+                               && ResourceSelectionUtil.allResourcesAreOfType(selection,
+                                               IResource.PROJECT | IResource.FOLDER | IResource.FILE);
+
+               if (anyResourceSelected) {
+                       moveAction.selectionChanged(selection);
+                       menu.appendToGroup(ICommonMenuConstants.GROUP_REORGANIZE, moveAction);
+                       renameAction.selectionChanged(selection);
+                       menu.insertAfter(moveAction.getId(), renameAction);
+               }
+       }
+
+       @Override
+       public void fillActionBars(IActionBars actionBars) {
+               updateActionBars();
+
+//             textActionHandler.updateActionBars();
+               actionBars.setGlobalActionHandler(ActionFactory.MOVE.getId(), moveAction);
+               actionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(), renameAction);
+       }
+
+       protected void makeActions() {
+               moveAction = new MoveResourceAction(shellProvider);
+               moveAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_MOVE);
+               
+               renameAction = new RenameResourceAction(shellProvider, tree);
+               renameAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_RENAME);
+       }
+
+       @Override
+       public void updateActionBars() {
+               IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
+
+               moveAction.selectionChanged(selection);
+               renameAction.selectionChanged(selection);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorRefactorActionProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorRefactorActionProvider.java
new file mode 100644 (file)
index 0000000..27da16e
--- /dev/null
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.navigator;
+
+import org.eclipse.core.commands.operations.IUndoContext;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
+import org.eclipse.ui.operations.UndoRedoActionGroup;
+
+import org.eclipse.cdt.ui.refactoring.actions.CRefactoringActionGroup;
+
+import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
+
+/**
+ * A clone of org.eclipse.ui.internal.navigator.resources.actions.RefactorActionProvider.
+ */
+public class CNavigatorRefactorActionProvider extends CommonActionProvider {
+
+       private UndoRedoActionGroup undoRedoGroup;
+       private CNavigatorRefactorActionGroup resourceRefactorGroup;
+       private CRefactoringActionGroup cElementRefactorGroup;
+
+       /*
+        * @see org.eclipse.ui.navigator.CommonActionProvider#init(org.eclipse.ui.navigator.ICommonActionExtensionSite)
+        */
+       @Override
+       public void init(ICommonActionExtensionSite actionSite) {
+               super.init(actionSite);
+               ICommonViewerWorkbenchSite workbenchSite= null;
+               if (actionSite.getViewSite() instanceof ICommonViewerWorkbenchSite) {
+                       workbenchSite = (ICommonViewerWorkbenchSite) actionSite.getViewSite();
+               }
+               if (workbenchSite != null) {
+                       final IWorkbenchPartSite partSite= workbenchSite.getSite();
+                       resourceRefactorGroup= new CNavigatorRefactorActionGroup(partSite, (Tree)actionSite.getStructuredViewer().getControl());
+                       IUndoContext workspaceContext= (IUndoContext) ResourcesPlugin.getWorkspace().getAdapter(IUndoContext.class);
+                       undoRedoGroup = new UndoRedoActionGroup(partSite, workspaceContext, true);
+                       cElementRefactorGroup= new CRefactoringActionGroup(workbenchSite.getPart());
+               }
+       }
+
+       @Override
+       public void dispose() {
+               undoRedoGroup.dispose();
+               resourceRefactorGroup.dispose();
+               cElementRefactorGroup.dispose();
+       }
+
+       @Override
+       public void fillActionBars(IActionBars actionBars) {
+               undoRedoGroup.fillActionBars(actionBars);
+               resourceRefactorGroup.fillActionBars(actionBars);
+               cElementRefactorGroup.updateActionBars();
+               cElementRefactorGroup.fillActionBars(actionBars);
+       }
+
+       @Override
+       public void fillContextMenu(IMenuManager menu) {
+               undoRedoGroup.fillContextMenu(menu);
+               resourceRefactorGroup.fillContextMenu(menu);
+               cElementRefactorGroup.fillContextMenu(menu);
+       }
+
+       @Override
+       public void setContext(ActionContext context) {
+               undoRedoGroup.setContext(context);
+               resourceRefactorGroup.setContext(convertToResources(context));
+               cElementRefactorGroup.setContext(context);
+       }
+
+       @Override
+       public void updateActionBars() {
+               undoRedoGroup.updateActionBars();
+               resourceRefactorGroup.updateActionBars();
+               cElementRefactorGroup.updateActionBars();
+       }
+
+       /**
+        * @param context
+        * @return context with selection elements converted to IResources
+        */
+       private ActionContext convertToResources(ActionContext context) {
+               if (context != null) {
+                       // convert non-IResource to IResources
+                       ISelection selection = SelectionConverter.convertSelectionToResources(context.getSelection());
+                       return new ActionContext(selection);
+               }
+               return null;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorSearchActionProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorSearchActionProvider.java
new file mode 100644 (file)
index 0000000..817504c
--- /dev/null
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.navigator;
+
+import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
+
+/**
+ * Common Navigator action provider for the C-search sub menus.
+ * 
+ * @see org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup
+ */
+public class CNavigatorSearchActionProvider extends CommonActionProvider {
+
+       private SelectionSearchGroup fSearchGroup;
+       
+       /*
+        * @see org.eclipse.ui.navigator.CommonActionProvider#init(org.eclipse.ui.navigator.ICommonActionExtensionSite)
+        */
+       @Override
+       public void init(ICommonActionExtensionSite site) {
+               ICommonViewerWorkbenchSite workbenchSite= null;
+               if (site.getViewSite() instanceof ICommonViewerWorkbenchSite) {
+                       workbenchSite= (ICommonViewerWorkbenchSite) site.getViewSite();
+               }
+               if (workbenchSite != null) {
+                       if (workbenchSite.getPart() != null && workbenchSite.getPart() instanceof IViewPart) {
+                               fSearchGroup= new SelectionSearchGroup(workbenchSite.getSite());
+                       }
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.actions.ActionGroup#dispose()
+        */
+       @Override
+       public void dispose() {
+               if (fSearchGroup != null) {
+                       fSearchGroup.dispose();
+                       fSearchGroup = null;
+               }
+               super.dispose();
+       }
+
+       /*
+        * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars)
+        */
+       @Override
+       public void fillActionBars(IActionBars actionBars) {
+               if (fSearchGroup != null) {
+                       fSearchGroup.fillActionBars(actionBars);
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
+        */
+       @Override
+       public void fillContextMenu(IMenuManager menu) {
+               if (fSearchGroup != null) {
+                       ISelection selection = getContext().getSelection();
+                       if (SelectionSearchGroup.canActionBeAdded(selection)){
+                               fSearchGroup.fillContextMenu(menu);
+                       }
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.actions.ActionGroup#setContext(org.eclipse.ui.actions.ActionContext)
+        */
+       @Override
+       public void setContext(ActionContext context) {
+               super.setContext(context);
+               if (fSearchGroup != null) {
+                       fSearchGroup.setContext(context);
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.actions.ActionGroup#updateActionBars()
+        */
+       @Override
+       public void updateActionBars() {
+               if (fSearchGroup != null) {
+                       fSearchGroup.updateActionBars();
+               }
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/OpenCElementAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/OpenCElementAction.java
new file mode 100644 (file)
index 0000000..1b2106f
--- /dev/null
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *     Ed Swartz (Nokia)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.navigator;
+
+import org.eclipse.cdt.core.model.IBinary;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.actions.OpenFileAction;
+
+/**
+ * Open an editor and navigate to the source location of
+ * the currently selected <code>ICElement</code>.
+ * In case of multiple selections, opening is delegated to
+ * the base class {@link OpenFileAction}.
+ */
+public class OpenCElementAction extends OpenFileAction {
+
+       private ICElement fOpenElement;
+       /**
+        * @param page
+        */
+       public OpenCElementAction(IWorkbenchPage page) {
+               super(page);
+       }
+
+       /*
+        * @see org.eclipse.ui.actions.OpenSystemEditorAction#run()
+        */
+       @Override
+       public void run() {
+               if (fOpenElement != null) {
+                       IEditorPart part;
+                       try {
+                               part= EditorUtility.openInEditor(fOpenElement);
+                               if (fOpenElement instanceof ISourceReference && !(fOpenElement instanceof ITranslationUnit)) {
+                                       EditorUtility.revealInEditor(part, fOpenElement);
+                               }
+                       } catch (CoreException exc) {
+                               CUIPlugin.log(exc.getStatus());
+                       }
+               } else {
+                       super.run();
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.actions.OpenSystemEditorAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
+        */
+       @Override
+       protected boolean updateSelection(IStructuredSelection selection) {
+               fOpenElement = null;
+               if (selection.size() == 1) {
+                       Object element = selection.getFirstElement();
+                       if (!(element instanceof ICElement)     && element instanceof IAdaptable) {
+                               element = ((IAdaptable) element).getAdapter(ICElement.class);
+                       }
+                       if (element instanceof ICElement
+                                       && (element instanceof ISourceReference || element instanceof IBinary)) {
+                               fOpenElement = (ICElement) element;
+                       }
+               }
+               return fOpenElement != null || super.updateSelection(selection);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/Messages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/Messages.java
new file mode 100644 (file)
index 0000000..fe48a3b
--- /dev/null
@@ -0,0 +1,272 @@
+/*******************************************************************************
+ *  Copyright (c) 2010, 2011 Andrew Gvozdev and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *  Andrew Gvozdev - Initial API and implementation
+ *  IBM Corporation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.newui;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+       public static String AbstractCPropertyTab_0;
+       public static String AbstractCPropertyTab_1;
+       public static String AbstractCPropertyTab_2;
+       public static String AbstractExportTab_0;
+       public static String AbstractExportTab_1;
+       public static String AbstractExportTab_2;
+       public static String AbstractExportTab_3;
+       public static String AbstractLangsListTab_ShowBuiltin;
+       public static String AbstractLangsListTab_Languages;
+       public static String AbstractLangsListTab_Export;
+       public static String AbstractLangsListTab_ExportIndicator;
+       public static String AbstractLangsListTab_Unexport;
+       public static String AbstractLangsListTab_Conjunction;
+       public static String AbstractLangsListTab_Disjunction;
+       public static String AbstractLangsListTab_Modify;
+       public static String AbstractLangsListTab_MultiConfigStringListModeLinkHint;
+       public static String AbstractLangsListTab_Replace;
+       public static String AbstractLangsListTab_StringListMode;
+       public static String AbstractLangsListTab_UnknownMode;
+       public static String AbstractPage_0;
+       public static String AbstractPage_10;
+       public static String AbstractPage_11;
+       public static String AbstractPage_12;
+       public static String AbstractPage_13;
+       public static String AbstractPage_14;
+       public static String AbstractPage_15;
+       public static String AbstractPage_16;
+       public static String AbstractPage_2;
+       public static String AbstractPage_3;
+       public static String AbstractPage_4;
+       public static String AbstractPage_5;
+       public static String AbstractPage_6;
+       public static String AbstractPage_7;
+       public static String AbstractPage_8;
+       public static String AbstractPage_9;
+       public static String AbstractPage_rebuildIndex_question;
+       public static String BinaryParsTab_0;
+       public static String BrowseEntryDialog_dir_title_add;
+       public static String BrowseEntryDialog_dir_title_edit;
+       public static String BrowseEntryDialog_file_title_add;
+       public static String BrowseEntryDialog_file_title_edit;
+       public static String BrowseEntryDialog_fs_dir_dlg_msg;
+       public static String BrowseEntryDialog_message_directory;
+       public static String BrowseEntryDialog_message_file;
+       public static String BrowseEntryDialog_wsp_dir_dlg_err;
+       public static String BrowseEntryDialog_wsp_dir_dlg_msg;
+       public static String BrowseEntryDialog_wsp_dir_dlg_title;
+       public static String BrowseEntryDialog_wsp_file_dlg_err;
+       public static String BrowseEntryDialog_wsp_file_dlg_msg;
+       public static String BrowseEntryDialog_wsp_file_dlg_title;
+       public static String BuildPropertyCommon_label_new;
+       public static String BuildPropertyCommon_label_remove;
+       public static String BuildPropertyCommon_label_title;
+       public static String BuildVarListDialog_0;
+       public static String BuildVarListDialog_1;
+       public static String BuildVarListDialog_2;
+       public static String BuildVarListDialog_3;
+       public static String BuildVarListDialog_4;
+       public static String BuildVarListDialog_5;
+       public static String BuildVarListDialog_6;
+       public static String BuildVarListDialog_7;
+       public static String BuildVarListDialog_8;
+       public static String BuildVarListDialog_10;
+       public static String BuildVarListDialog_11;
+       public static String CCProjectWizard_0;
+       public static String CDTCommonProjectWizard_0;
+       public static String CDTCommonProjectWizard_1;
+       public static String CDTCommonProjectWizard_creatingProject;
+       public static String CDTMainWizardPage_0;
+       public static String CDTMainWizardPage_1;
+       public static String CLocationOutputTab_0;
+       public static String CLocationSourceTab_0;
+       public static String CLocationTab_0;
+       public static String CLocationTab_1;
+       public static String CLocationTab_2;
+       public static String CLocationTab_3;
+       public static String CLocationTab_4;
+       public static String CLocationTab_5;
+       public static String CLocationTab_6;
+       public static String CLocationTab_7;
+       public static String CLocationTab_8;
+       public static String CMainWizardPage_0;
+       public static String CMainWizardPage_1;
+       public static String CMainWizardPage_10;
+       public static String CMainWizardPage_3;
+       public static String CMainWizardPage_5;
+       public static String CMainWizardPage_6;
+       public static String CMainWizardPage_7;
+       public static String ConfigDescriptionTab_0;
+       public static String ConfigDescriptionTab_1;
+       public static String ConfigDescriptionTab_2;
+       public static String ConfigMultiSelectionDialog_0;
+       public static String ConfigMultiSelectionDialog_1;
+       public static String CProjectWizard_0;
+       public static String EnvDialog_0;
+       public static String EnvDialog_1;
+       public static String EnvDialog_2;
+       public static String EnvDialog_3;
+       public static String EnvironmentTab_0;
+       public static String EnvironmentTab_1;
+       public static String EnvironmentTab_10;
+       public static String EnvironmentTab_11;
+       public static String EnvironmentTab_12;
+       public static String EnvironmentTab_13;
+       public static String EnvironmentTab_14;
+       public static String EnvironmentTab_15;
+       public static String EnvironmentTab_16;
+       public static String EnvironmentTab_17;
+       public static String EnvironmentTab_18;
+       public static String EnvironmentTab_19;
+       public static String EnvironmentTab_2;
+       public static String EnvironmentTab_20;
+       public static String EnvironmentTab_21;
+       public static String EnvironmentTab_22;
+       public static String EnvironmentTab_23;
+       public static String EnvironmentTab_24;
+       public static String EnvironmentTab_3;
+       public static String EnvironmentTab_4;
+       public static String EnvironmentTab_5;
+       public static String EnvironmentTab_6;
+       public static String EnvironmentTab_7;
+       public static String EnvironmentTab_8;
+       public static String EnvironmentTab_9;
+       public static String ErrorParsTab_error_IllegalCharacter;
+       public static String ErrorParsTab_error_NonAccessibleID;
+       public static String ErrorParsTab_error_NonEmptyName;
+       public static String ErrorParsTab_error_NonUniqueID;
+       public static String ErrorParsTab_error_OnApplyingSettings;
+       public static String ErrorParsTab_error_OnRestoring;
+       public static String ErrorParsTab_label_DefaultRegexErrorParserName;
+       public static String ErrorParsTab_label_EnterName;
+       public static String ErrorParsTab_message_ConfirmReset;
+       public static String ErrorParsTab_Reset;
+       public static String ErrorParsTab_title_Add;
+       public static String ErrorParsTab_title_ConfirmReset;
+       public static String ErrorParsTab_title_Edit;
+       public static String ExpDialog_0;
+       public static String ExpDialog_1;
+       public static String ExpDialog_10;
+       public static String ExpDialog_2;
+       public static String ExpDialog_3;
+       public static String ExpDialog_4;
+       public static String ExpDialog_5;
+       public static String ExpDialog_6;
+       public static String ExpDialog_7;
+       public static String ExpDialog_8;
+       public static String ExpDialog_9;
+       public static String FileListControl_add;
+       public static String FileListControl_BrowseEntryDialog_wsp_dir_dlg_msg;
+       public static String FileListControl_BrowseEntryDialog_wsp_file_dlg_err;
+       public static String FileListControl_BrowseEntryDialog_wsp_file_dlg_msg;
+       public static String FileListControl_button_fs;
+       public static String FileListControl_button_workspace;
+       public static String FileListControl_delete;
+       public static String FileListControl_deletedialog_message;
+       public static String FileListControl_deletedialog_title;
+       public static String FileListControl_edit;
+       public static String FileListControl_editdialog_title;
+       public static String FileListControl_movedown;
+       public static String FileListControl_moveup;
+       public static String IncludeDialog_0;
+       public static String IncludeDialog_1;
+       public static String IncludeDialog_2;
+       public static String IncludeDialog_3;
+       public static String IncludeFileTab_0;
+       public static String IncludeFileTab_1;
+       public static String IncludeFileTab_2;
+       public static String IncludeTab_0;
+       public static String IncludeTab_1;
+       public static String IncludeTab_2;
+       public static String IncludeTab_export;
+       public static String IncludeTab_import;
+       public static String LanguagesTab_0;
+       public static String LanguagesTab_1;
+       public static String LibraryPathTab_1;
+       public static String LibraryPathTab_2;
+       public static String LibraryTab_1;
+       public static String LibraryTab_2;
+       public static String ManageConfig_deletedialog_message;
+       public static String ManageConfig_deletedialog_title;
+       public static String ManageConfig_label_new_config_dialog;
+       public static String ManageConfig_label_rename_config_dialog;
+       public static String ManageConfig_label_rename;
+       public static String ManageConfigDialog_0;
+       public static String ManageConfigDialog_1;
+       public static String ManageConfigDialog_2;
+       public static String ManageConfigDialog_3;
+       public static String ManageConfigDialog_4;
+       public static String ManageConfigDialog_5;
+       public static String Multiline_error_message;
+       public static String NewConfiguration_error_caseName;
+       public static String NewConfiguration_error_duplicateName;
+       public static String NewConfiguration_error_invalidName;
+       public static String NewConfiguration_label_description;
+       public static String NewConfiguration_label_group;
+       public static String NewConfiguration_label_name;
+       public static String NewConfiguration_label_warning;
+       public static String NewModelProjectWizard_0;
+       public static String NewModelProjectWizard_1;
+       public static String NewModelProjectWizard_2;
+       public static String NewModelProjectWizard_3;
+       public static String NewModelProjectWizard_4;
+       public static String NewModelProjectWizard_5;
+       public static String ProjectContentsArea_0;
+       public static String ProjectContentsArea_1;
+       public static String ProjectContentsArea_2;
+       public static String ProjectContentsArea_3;
+       public static String ProjectContentsArea_4;
+       public static String ProjectContentsArea_5;
+       public static String ProjectContentsArea_6;
+       public static String ProjectContentsArea_7;
+       public static String ProjectContentsArea_8;
+       public static String ProjectContentsArea_9;
+       public static String RefsTab_ExpandAll;
+       public static String RefsTab_CollapseAll;
+       public static String RefsTab_Active;
+       public static String RefsTab_ProjectsList;
+       public static String RefsTab_ConfigurationsAccessError;
+       public static String RenameConfiguration_error_caseName;
+       public static String RenameConfiguration_error_duplicateName;
+       public static String RenameConfiguration_error_invalidName;
+       public static String RenameConfiguration_label_description;
+       public static String RenameConfiguration_label_name;
+       public static String RenameConfiguration_label_warning;
+       public static String StringVariableSelectionDialog_columnDescription;
+       public static String StringVariableSelectionDialog_message;
+       public static String StructureTreeTab_0;
+       public static String StructureTreeTab_1;
+       public static String StructureTreeTab_10;
+       public static String StructureTreeTab_11;
+       public static String StructureTreeTab_2;
+       public static String StructureTreeTab_3;
+       public static String StructureTreeTab_4;
+       public static String StructureTreeTab_5;
+       public static String StructureTreeTab_6;
+       public static String StructureTreeTab_7;
+       public static String StructureTreeTab_8;
+       public static String StructureTreeTab_9;
+       public static String SymbolDialog_0;
+       public static String SymbolDialog_1;
+       public static String SymbolTab_0;
+       public static String SymbolTab_1;
+       public static String SymbolTab_2;
+       public static String SymbolTab_3;
+       public static String WorkingSetConfigAction_21;
+       public static String WorkingSetConfigAction_22;
+
+       static {
+               // Initialize resource bundle.
+               NLS.initializeMessages(Messages.class.getName(), Messages.class);
+       }
+
+       private Messages() {
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/Messages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/newui/Messages.properties
new file mode 100644 (file)
index 0000000..80f166a
--- /dev/null
@@ -0,0 +1,278 @@
+###############################################################################
+# Copyright (c) 2000, 2011 IBM Corporation, QNX Software Systems, and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM - Initial API and implementation
+# QNX Software Systems - [272416] Rework the working set configurations
+# Andrew Gvozdev (Quoin Inc.) - Converted to NLS message format, bug 318802, bug 318812
+###############################################################################
+
+# ----------- Entry Dialog -----------
+BrowseEntryDialog_message_file = File:
+BrowseEntryDialog_message_directory = Directory:
+BrowseEntryDialog_file_title_add=Add file path
+BrowseEntryDialog_dir_title_add=Add directory path
+BrowseEntryDialog_file_title_edit=Edit file path
+BrowseEntryDialog_dir_title_edit=Edit directory path
+BrowseEntryDialog_wsp_dir_dlg_title=Folder selection
+BrowseEntryDialog_wsp_file_dlg_title=File selection
+BrowseEntryDialog_wsp_dir_dlg_msg=Select a folder from workspace:
+BrowseEntryDialog_wsp_file_dlg_msg=Select a file from workspace:
+BrowseEntryDialog_wsp_file_dlg_err=The selected element is not a file.
+BrowseEntryDialog_wsp_dir_dlg_err=The selected element is not a directory.
+BrowseEntryDialog_fs_dir_dlg_msg=Select a folder from file system:
+
+# ----------- New Configuration -----------
+NewConfiguration_label_name=Name:
+NewConfiguration_label_description=Description:
+NewConfiguration_label_group=Copy settings from
+NewConfiguration_label_warning=Note: The configuration name will be used as a directory name in the file system.  Please ensure that it is valid for your platform. 
+NewConfiguration_error_duplicateName=A configuration named "{0}" already exists.
+NewConfiguration_error_caseName=A configuration name that differs only in case to "{0}" exists.
+NewConfiguration_error_invalidName=The name "{0}" is invalid.
+
+# ----------- Rename Configuration -----------
+RenameConfiguration_label_name=Name:
+RenameConfiguration_label_description=Description:
+RenameConfiguration_label_warning=Note: The configuration name will be used as a directory name in the file system.  Please ensure that it is valid for your platform. 
+RenameConfiguration_error_duplicateName=A configuration named "{0}" already exists.
+RenameConfiguration_error_caseName=A configuration name that differs only in case to "{0}" exists.
+RenameConfiguration_error_invalidName=The name "{0}" is invalid.
+
+# ----------- Target/Config management dialog -----------------
+ManageConfig_label_rename=Rename...
+ManageConfig_label_new_config_dialog=Create Configuration
+ManageConfig_label_rename_config_dialog=Rename Configuration
+ManageConfig_deletedialog_message=Are you sure you want to delete the "{0}" configuration?
+ManageConfig_deletedialog_title=Confirm Delete
+ManageConfigDialog_1=Configuration
+ManageConfigDialog_2=Description
+ManageConfigDialog_3=Status
+ManageConfigDialog_4=Set Active
+ManageConfigDialog_5=Active
+ManageConfigDialog_0=Manage Configurations
+
+# ----------- Build Property Common -----------
+BuildPropertyCommon_label_title=Enter Value
+BuildPropertyCommon_label_new=New...
+BuildPropertyCommon_label_remove=Delete
+
+# ----------- Field Editors -----------
+Multiline_error_message=Please give correct input
+
+# ----------- File List Control -----------
+FileListControl_add=Add...
+FileListControl_delete=Delete
+FileListControl_edit=Edit...
+FileListControl_moveup=Move Up
+FileListControl_movedown=Move Down
+FileListControl_deletedialog_message=Are you sure you want to remove the selected entries?
+FileListControl_deletedialog_title=Confirm Remove
+FileListControl_editdialog_title=Edit Dialog
+FileListControl_button_workspace=Workspace...
+FileListControl_button_fs=File system...
+FileListControl_BrowseEntryDialog_wsp_dir_dlg_msg=Select one or more Workspace Folders
+FileListControl_BrowseEntryDialog_wsp_file_dlg_msg=Select one or more Workspace Files
+FileListControl_BrowseEntryDialog_wsp_file_dlg_err=One of the elements selected isn't a file
+
+AbstractCPropertyTab_0=Select build variable
+AbstractCPropertyTab_1=Variables...
+AbstractCPropertyTab_2=This tab is not supported in multi-configuration mode
+AbstractPage_0=Unknown element selected
+AbstractPage_12=Manage Configurations...
+AbstractPage_11=setProjectDescription: 
+AbstractPage_10=Cannot create resource configuration for 
+AbstractPage_13=Cannot load 
+AbstractPage_14=Cannot create page: 
+AbstractPage_15=element not initialized.
+AbstractPage_16=[ Active ]
+AbstractPage_2=This project is not a CDT project
+AbstractPage_3=Error while accessing new configuration. <Apply> cannot work. Use <OK>.
+AbstractPage_4=[ All configurations ]
+AbstractPage_5=[ Multiple configurations...]
+AbstractPage_6=Configuration: 
+AbstractPage_7=Exclude resource from build
+AbstractPage_8=Cannot apply
+AbstractPage_9=Internal error
+AbstractPage_rebuildIndex_question=Changes to the include search paths or defined symbols will not be reflected in the index until it is rebuilt. Do you wish to rebuild it now?
+
+AbstractLangsListTab_ShowBuiltin=Show built-in values
+AbstractLangsListTab_Languages=Languages
+AbstractLangsListTab_Export=Export
+AbstractLangsListTab_ExportIndicator=\ [exp]
+AbstractLangsListTab_Unexport=Unexport
+AbstractLangsListTab_Conjunction=Conjunction
+AbstractLangsListTab_Disjunction=Disjunction
+AbstractLangsListTab_Modify=Modify
+AbstractLangsListTab_MultiConfigStringListModeLinkHint=Multiple configurations string list mode. Click on link to change or for more info.
+AbstractLangsListTab_Replace=Replace
+AbstractLangsListTab_StringListMode=String List Mode:
+AbstractLangsListTab_UnknownMode=Unknown
+AbstractExportTab_0=[All]
+AbstractExportTab_1=[List]
+AbstractExportTab_2=Create...
+AbstractExportTab_3=Edit...
+CLocationTab_0=Filter (empty)
+CLocationTab_1=Filter (
+CLocationTab_2=, 
+CLocationTab_3=)
+CLocationTab_4=Add Folder...
+CLocationTab_5=Link Folder...
+CLocationTab_6=Edit Filter...
+CLocationTab_7=Delete
+CLocationTab_8=<root folder>
+CLocationSourceTab_0=Source folders on build path:
+CLocationOutputTab_0=Output folders on build path:
+EnvDialog_0=Name:
+EnvDialog_1=Value:
+EnvDialog_2=Variables
+EnvDialog_3=Add to all configurations
+EnvironmentTab_0=Environment variables to set
+EnvironmentTab_1=Variable
+EnvironmentTab_10=New variable
+EnvironmentTab_11=Edit variable
+EnvironmentTab_12=Variables list
+EnvironmentTab_13=Add to all configurations
+EnvironmentTab_14=Select variables
+EnvironmentTab_15=Current String List DISPLAY mode. Double-click to change
+EnvironmentTab_16=Origin
+EnvironmentTab_17=CONJ.
+EnvironmentTab_18=DISJ.
+EnvironmentTab_19=DISPL mode: 
+EnvironmentTab_2=Value
+EnvironmentTab_20=<UNDEFINED> 
+EnvironmentTab_21=REPLACE
+EnvironmentTab_22=WRITE mode: 
+EnvironmentTab_23=Current String List WRITE mode. Double-click to change
+EnvironmentTab_24=MODIFY
+EnvironmentTab_3=Append variables to native environment
+EnvironmentTab_4=Replace native environment with specified one
+EnvironmentTab_5=Add...
+EnvironmentTab_6=Select...
+EnvironmentTab_7=Edit...
+EnvironmentTab_8=Delete
+EnvironmentTab_9=Undefine
+IncludeTab_0=Include directories
+IncludeTab_1=Add directory path
+IncludeTab_2=Change directory path
+IncludeFileTab_0=Include files
+IncludeFileTab_1=Add include file
+IncludeFileTab_2=Change include file
+IncludeDialog_0=Directory:
+IncludeDialog_1=File:
+IncludeDialog_2=Add to all configurations
+IncludeDialog_3=Add to all languages
+LanguagesTab_0=Content type
+LanguagesTab_1=Language
+LibraryPathTab_1=Add...
+LibraryPathTab_2=Edit...
+LibraryTab_1=Add...
+LibraryTab_2=Edit...
+RefsTab_ExpandAll=Expand All
+RefsTab_CollapseAll=Collapse All
+RefsTab_Active=Active
+RefsTab_ProjectsList=Projects list
+RefsTab_ConfigurationsAccessError=Internal error trying access configurations of project 
+SymbolTab_0=Symbol
+SymbolTab_1=Value
+SymbolTab_2=Add symbol
+SymbolTab_3=Change symbol
+ExpDialog_0=To all configurations
+ExpDialog_1=Save to: 
+ExpDialog_2=Languages
+ExpDialog_3=Content types
+ExpDialog_4=Is a workspace path
+ExpDialog_5=Apply to all
+ExpDialog_6=Name:
+ExpDialog_7=Value:
+ExpDialog_8=Name cannot be empty.
+ExpDialog_9=The same name already exists.
+ExpDialog_10=Value cannot be empty.
+ConfigMultiSelectionDialog_0=Select configurations
+ConfigMultiSelectionDialog_1=At least 2 configurations should be selected
+SymbolDialog_0=Name:
+SymbolDialog_1=Value:
+ConfigDescriptionTab_0=Project Description
+ConfigDescriptionTab_1=Configuration Description
+ConfigDescriptionTab_2=Resource Description
+BinaryParsTab_0=Binary parser:
+ErrorParsTab_error_NonEmptyName=Specify non empty name
+ErrorParsTab_error_NonUniqueID=Error parser ID is not unique, specify different name
+ErrorParsTab_error_OnApplyingSettings=Error applying Error Parser Tab settings
+ErrorParsTab_error_OnRestoring=Error restoring default Error Parser Tab settings
+ErrorParsTab_error_NonAccessibleID=[ Not accessible id={0} ]
+ErrorParsTab_error_IllegalCharacter=Special character ''{0}'' is not allowed
+ErrorParsTab_label_EnterName=Enter name of new error parser:
+ErrorParsTab_label_DefaultRegexErrorParserName=Regex Error Parser
+ErrorParsTab_message_ConfirmReset=Are you sure you want to delete all customized error parsers?
+ErrorParsTab_Reset=Reset
+ErrorParsTab_title_Add=Add Regex Error Parser
+ErrorParsTab_title_ConfirmReset=Confirm Resetting Error Parsers
+ErrorParsTab_title_Edit=Edit Regex Error Parser name
+StructureTreeTab_0=Level: 
+StructureTreeTab_1=Maximal tree nesting
+StructureTreeTab_2=Long
+StructureTreeTab_3=String
+StructureTreeTab_4=Object to view: 
+StructureTreeTab_5=Expand all
+StructureTreeTab_6=Expand level...
+StructureTreeTab_7=Collapse all
+StructureTreeTab_8=Property
+StructureTreeTab_9=Value
+StructureTreeTab_10=Class
+StructureTreeTab_11=Wait...
+
+CMainWizardPage_0=Project type:
+CMainWizardPage_1=Show project types and toolchains only if they are supported on the platform
+CMainWizardPage_10=A project with that name already exists in the workspace.
+CMainWizardPage_3=No project types available. Project cannot be created
+CMainWizardPage_5=Cannot create ICProjectTypeHandler: 
+CMainWizardPage_6=File with specified name already exists.
+CMainWizardPage_7=Directory with specified name already exists.
+
+ProjectContentsArea_0=Browse...
+ProjectContentsArea_1=Use default location
+ProjectContentsArea_2=Location:
+ProjectContentsArea_3=Invalid location path
+ProjectContentsArea_4=Project contents directory must be specified
+ProjectContentsArea_5=Select directory:
+ProjectContentsArea_6=Project path should be absolute
+ProjectContentsArea_7=Project path is not valid
+ProjectContentsArea_8=Cannot create given path
+ProjectContentsArea_9=File with given name already exists
+
+CDTCommonProjectWizard_0=Old project will be overridden
+CDTCommonProjectWizard_1=Existing project settings will be overridden.\nImport feature can be used instead to preserve old settings.\nOK to override ?
+CDTCommonProjectWizard_creatingProject=Creating project
+NewModelProjectWizard_0=CDT Project
+NewModelProjectWizard_1=Create CDT project of selected type
+NewModelProjectWizard_2=C++ Project
+NewModelProjectWizard_3=Create C++ project of selected type
+NewModelProjectWizard_4=C Project
+NewModelProjectWizard_5=Create C project of selected type
+BuildVarListDialog_0=Type:
+BuildVarListDialog_1=Text list
+BuildVarListDialog_2=File path
+BuildVarListDialog_3=List of File paths
+BuildVarListDialog_4=Directory path
+BuildVarListDialog_5=List of Directory paths
+BuildVarListDialog_6=Any path
+BuildVarListDialog_7=List of any paths
+BuildVarListDialog_8=Text
+BuildVarListDialog_10=<not available>
+BuildVarListDialog_11=Build variables
+StringVariableSelectionDialog_message=&Choose a variable (? = any character, * = any string):
+StringVariableSelectionDialog_columnDescription=&Variable Description:
+CDTMainWizardPage_0=Project name cannot contain '\#' symbol
+CDTMainWizardPage_1=Project category is selected. Expand the category and select a concrete project type.
+CProjectWizard_0=Add C Project Nature
+CCProjectWizard_0=Add CC Project Nature
+WorkingSetConfigAction_21=Building project 
+WorkingSetConfigAction_22=Build error
+IncludeTab_export=Export Settings...
+IncludeTab_import=Import Settings...
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlock.java
new file mode 100644 (file)
index 0000000..2aa3322
--- /dev/null
@@ -0,0 +1,470 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin, Google
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.events.ExpansionAdapter;
+import org.eclipse.ui.forms.events.ExpansionEvent;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
+
+/**
+ * Abstract implementation of a generic {@link IPreferenceConfigurationBlock}.
+ * 
+ * @since 4.0
+ */
+abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlock {
+
+       /**
+        * Use as follows:
+        * 
+        * <pre>
+        * SectionManager manager= new SectionManager();
+        * Composite composite= manager.createSectionComposite(parent);
+        * 
+        * Composite xSection= manager.createSection("section X"));
+        * xSection.setLayout(new FillLayout());
+        * new Button(xSection, SWT.PUSH); // add controls to section..
+        * 
+        * [...]
+        * 
+        * return composite; // return main composite
+        * </pre>
+        */
+       protected final class SectionManager {
+               /** The preference setting for keeping no section open. */
+               private static final String __NONE= "__none"; //$NON-NLS-1$
+               private Set<ExpandableComposite> fSections= new HashSet<ExpandableComposite>();
+               private boolean fIsBeingManaged= false;
+               private ExpansionAdapter fListener= new ExpansionAdapter() {
+                       @Override
+                       public void expansionStateChanged(ExpansionEvent e) {
+                               ExpandableComposite source= (ExpandableComposite) e.getSource();
+                               updateSectionStyle(source);
+                               if (fIsBeingManaged)
+                                       return;
+                               if (e.getState()) {
+                                       try {
+                                               fIsBeingManaged= true;
+                                               for (ExpandableComposite composite : fSections) {
+                                                       if (composite != source)
+                                                               composite.setExpanded(false);
+                                               }
+                                       } finally {
+                                               fIsBeingManaged= false;
+                                       }
+                                       if (fLastOpenKey != null && fDialogSettingsStore != null)
+                                               fDialogSettingsStore.setValue(fLastOpenKey, source.getText());
+                               } else {
+                                       if (!fIsBeingManaged && fLastOpenKey != null && fDialogSettingsStore != null)
+                                               fDialogSettingsStore.setValue(fLastOpenKey, __NONE);
+                               }
+                               ExpandableComposite exComp= getParentExpandableComposite(source);
+                               if (exComp != null)
+                                       exComp.layout(true, true);
+                               ScrolledPageContent parentScrolledComposite= getParentScrolledComposite(source);
+                               if (parentScrolledComposite != null) {
+                                       parentScrolledComposite.reflow(true);
+                               }
+                       }
+               };
+               private Composite fBody;
+               private final String fLastOpenKey;
+               private final IPreferenceStore fDialogSettingsStore;
+               private ExpandableComposite fFirstChild= null;
+               /**
+                * Creates a new section manager.
+                */
+               public SectionManager() {
+                       this(null, null);
+               }
+               /**
+                * Creates a new section manager.
+                */
+               public SectionManager(IPreferenceStore dialogSettingsStore, String lastOpenKey) {
+                       fDialogSettingsStore= dialogSettingsStore;
+                       fLastOpenKey= lastOpenKey;
+               }
+               private void manage(ExpandableComposite section) {
+                       if (section == null)
+                               throw new NullPointerException();
+                       if (fSections.add(section))
+                               section.addExpansionListener(fListener);
+                       makeScrollableCompositeAware(section);
+               }
+               
+               /**
+                * Creates a new composite that can contain a set of expandable
+                * sections. A <code>ScrolledPageComposite</code> is created and a new
+                * composite within that, to ensure that expanding the sections will
+                * always have enough space, unless there already is a
+                * <code>ScrolledComposite</code> along the parent chain of
+                * <code>parent</code>, in which case a normal <code>Composite</code>
+                * is created.
+                * <p>
+                * The receiver keeps a reference to the inner body composite, so that
+                * new sections can be added via <code>createSection</code>.
+                * </p>
+                * 
+                * @param parent the parent composite
+                * @return the newly created composite
+                */
+               public Composite createSectionComposite(Composite parent) {
+                       Assert.isTrue(fBody == null);
+                       boolean isNested= isNestedInScrolledComposite(parent);
+                       Composite composite;
+                       if (isNested) {
+                               composite= new Composite(parent, SWT.NONE);
+                               fBody= composite;
+                       } else {
+                               composite= new ScrolledPageContent(parent);
+                               fBody= ((ScrolledPageContent) composite).getBody();
+                       }
+                       
+                       fBody.setLayout(new GridLayout());
+                       
+                       return composite;
+               }
+               
+               /**
+                * Creates an expandable section within the parent created previously by
+                * calling <code>createSectionComposite</code>. Controls can be added 
+                * directly to the returned composite, which has no layout initially.
+                * 
+                * @param label the display name of the section
+                * @return a composite within the expandable section
+                */
+               public Composite createSection(String label) {
+                       Assert.isNotNull(fBody);
+                       final ExpandableComposite excomposite= new ExpandableComposite(fBody, SWT.NONE, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT | ExpandableComposite.COMPACT);
+                       if (fFirstChild == null)
+                               fFirstChild= excomposite;
+                       excomposite.setText(label);
+                       String last= null;
+                       if (fLastOpenKey != null && fDialogSettingsStore != null)
+                               last= fDialogSettingsStore.getString(fLastOpenKey);
+                       
+                       if (fFirstChild == excomposite && !__NONE.equals(last) || label.equals(last)) {
+                               excomposite.setExpanded(true);
+                               if (fFirstChild != excomposite)
+                                       fFirstChild.setExpanded(false);
+                       } else {
+                               excomposite.setExpanded(false);
+                       }
+                       excomposite.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
+                       
+                       updateSectionStyle(excomposite);
+                       manage(excomposite);
+                       
+                       Composite contents= new Composite(excomposite, SWT.NONE);
+                       excomposite.setClient(contents);
+                       
+                       return contents;
+               }
+       }
+
+       protected static final int INDENT= 20;
+       private OverlayPreferenceStore fStore;
+       
+       private Map<Object, String> fCheckBoxes= new HashMap<Object, String>();
+       private SelectionListener fCheckBoxListener= new SelectionListener() {
+               public void widgetDefaultSelected(SelectionEvent e) {
+               }
+               public void widgetSelected(SelectionEvent e) {
+                       Button button= (Button) e.widget;
+                       fStore.setValue(fCheckBoxes.get(button), button.getSelection());
+               }
+       };
+       
+       
+       private Map<Object, String> fTextFields= new HashMap<Object, String>();
+       private ModifyListener fTextFieldListener= new ModifyListener() {
+               public void modifyText(ModifyEvent e) {
+                       Text text= (Text) e.widget;
+                       fStore.setValue(fTextFields.get(text), text.getText());
+               }
+       };
+
+       private ArrayList<Text> fNumberFields= new ArrayList<Text>();
+       private ModifyListener fNumberFieldListener= new ModifyListener() {
+               public void modifyText(ModifyEvent e) {
+                       numberFieldChanged((Text) e.widget);
+               }
+       };
+       
+       /**
+        * List of master/slave listeners when there's a dependency.
+        * 
+        * @see #createDependency(Button, Control)
+        * @since 3.0
+        */
+       private ArrayList<Object> fMasterSlaveListeners= new ArrayList<Object>();
+       
+       private StatusInfo fStatus;
+       private final PreferencePage fMainPage;
+
+       public AbstractConfigurationBlock(OverlayPreferenceStore store) {
+               Assert.isNotNull(store);
+               fStore= store;
+               fMainPage= null;
+       }
+       
+       public AbstractConfigurationBlock(OverlayPreferenceStore store, PreferencePage mainPreferencePage) {
+               Assert.isNotNull(store);
+               Assert.isNotNull(mainPreferencePage);
+               fStore= store;
+               fMainPage= mainPreferencePage;
+       }
+
+       protected final ScrolledPageContent getParentScrolledComposite(Control control) {
+               Control parent= control.getParent();
+               while (!(parent instanceof ScrolledPageContent) && parent != null) {
+                       parent= parent.getParent();
+               }
+               if (parent instanceof ScrolledPageContent) {
+                       return (ScrolledPageContent) parent;
+               }
+               return null;
+       }
+
+       private final ExpandableComposite getParentExpandableComposite(Control control) {
+               Control parent= control.getParent();
+               while (!(parent instanceof ExpandableComposite) && parent != null) {
+                       parent= parent.getParent();
+               }
+               if (parent instanceof ExpandableComposite) {
+                       return (ExpandableComposite) parent;
+               }
+               return null;
+       }
+
+       protected void updateSectionStyle(ExpandableComposite excomposite) {
+               excomposite.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
+       }
+       
+       private void makeScrollableCompositeAware(Control control) {
+               ScrolledPageContent parentScrolledComposite= getParentScrolledComposite(control);
+               if (parentScrolledComposite != null) {
+                       parentScrolledComposite.adaptChild(control);
+               }
+       }
+       
+       private boolean isNestedInScrolledComposite(Composite parent) {
+               return getParentScrolledComposite(parent) != null;
+       }
+       
+       protected Button addCheckBox(Composite parent, String label, String key, int indentation) {             
+               Button checkBox= new Button(parent, SWT.CHECK);
+               checkBox.setText(label);
+               
+               GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+               gd.horizontalIndent= indentation;
+               gd.horizontalSpan= 2;
+               checkBox.setLayoutData(gd);
+               checkBox.addSelectionListener(fCheckBoxListener);
+               makeScrollableCompositeAware(checkBox);
+
+               fCheckBoxes.put(checkBox, key);
+               
+               return checkBox;
+       }
+
+       /**
+        * Returns an array of size 2:
+        *  - first element is of type <code>Label</code>
+        *  - second element is of type <code>Text</code>
+        * Use <code>getLabelControl</code> and <code>getTextControl</code> to get the 2 controls.
+        * 
+        * @param composite     the parent composite
+        * @param label                 the text field's label
+        * @param key                   the preference key
+        * @param textLimit             the text limit
+        * @param indentation   the field's indentation
+        * @param isNumber              <code>true</code> iff this text field is used to e4dit a number
+        * @return the controls added
+        */
+       protected Control[] addLabelledTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) {
+               
+               PixelConverter pixelConverter= new PixelConverter(composite);
+               
+               Label labelControl= new Label(composite, SWT.NONE);
+               labelControl.setText(label);
+               GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+               gd.horizontalIndent= indentation;
+               labelControl.setLayoutData(gd);
+               
+               Text textControl= new Text(composite, SWT.BORDER | SWT.SINGLE);         
+               gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+               gd.widthHint= pixelConverter.convertWidthInCharsToPixels(textLimit + 1);
+               textControl.setLayoutData(gd);
+               textControl.setTextLimit(textLimit);
+               fTextFields.put(textControl, key);
+               if (isNumber) {
+                       fNumberFields.add(textControl);
+                       textControl.addModifyListener(fNumberFieldListener);
+               } else {
+                       textControl.addModifyListener(fTextFieldListener);
+               }
+                       
+               return new Control[]{labelControl, textControl};
+       }
+
+       protected void createDependency(final Button master, final Control slave) {
+               createDependency(master, new Control[] {slave});
+       }
+       
+       protected void createDependency(final Button master, final Control[] slaves) {
+               Assert.isTrue(slaves.length > 0);
+               indent(slaves[0]);
+               SelectionListener listener= new SelectionListener() {
+                       public void widgetSelected(SelectionEvent e) {
+                               boolean state= master.getSelection();
+                               for (Control slave : slaves) {
+                                       slave.setEnabled(state);
+                               }
+                       }
+
+                       public void widgetDefaultSelected(SelectionEvent e) {}
+               };
+               master.addSelectionListener(listener);
+               fMasterSlaveListeners.add(listener);
+       }
+
+       protected static void indent(Control control) {
+               ((GridData) control.getLayoutData()).horizontalIndent+= INDENT;
+       }
+
+       public void initialize() {
+               initializeFields();
+       }
+
+       private void initializeFields() {
+               
+               Iterator<Object> iter= fCheckBoxes.keySet().iterator();
+               while (iter.hasNext()) {
+                       Button b= (Button) iter.next();
+                       String key= fCheckBoxes.get(b);
+                       b.setSelection(fStore.getBoolean(key));
+               }
+               
+               iter= fTextFields.keySet().iterator();
+               while (iter.hasNext()) {
+                       Text t= (Text) iter.next();
+                       String key= fTextFields.get(t);
+                       t.setText(fStore.getString(key));
+               }
+               
+        // Update slaves
+        iter= fMasterSlaveListeners.iterator();
+        while (iter.hasNext()) {
+            SelectionListener listener= (SelectionListener)iter.next();
+            listener.widgetSelected(null);
+        }
+     
+        updateStatus(new StatusInfo());
+       }
+
+       public void performOk() {
+       }
+
+       public void performDefaults() {
+               initializeFields();
+       }
+
+       IStatus getStatus() {
+               if (fStatus == null)
+                       fStatus= new StatusInfo();
+               return fStatus;
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#dispose()
+        */
+       public void dispose() {
+       }
+       
+       private void numberFieldChanged(Text textControl) {
+               String number= textControl.getText();
+               IStatus status= validatePositiveNumber(number);
+               if (!status.matches(IStatus.ERROR))
+                       fStore.setValue(fTextFields.get(textControl), number);
+               updateStatus(status);
+       }
+       
+       private IStatus validatePositiveNumber(String number) {
+               StatusInfo status= new StatusInfo();
+               if (number.length() == 0) {
+                       status.setError(PreferencesMessages.CEditorPreferencePage_empty_input); 
+               } else {
+                       try {
+                               int value= Integer.parseInt(number);
+                               if (value < 0)
+                                       status.setError(NLS.bind(PreferencesMessages.CEditorPreferencePage_invalid_input, number)); 
+                       } catch (NumberFormatException e) {
+                               status.setError(NLS.bind(PreferencesMessages.CEditorPreferencePage_invalid_input, number)); 
+                       }
+               }
+               return status;
+       }
+
+       protected void updateStatus(IStatus status) {
+               if (fMainPage == null)
+                       return;
+               fMainPage.setValid(status.isOK());
+               StatusUtil.applyToStatusLine(fMainPage, status);
+       }
+       
+       protected final OverlayPreferenceStore getPreferenceStore() {
+               return fStore;
+       }
+
+       protected Composite createSubsection(Composite parent, SectionManager manager, String label) {
+               if (manager != null) {
+                       return manager.createSection(label);
+               }
+               Group group= new Group(parent, SWT.SHADOW_NONE);
+               group.setText(label);
+               GridData data= new GridData(SWT.FILL, SWT.CENTER, true, false);
+               group.setLayoutData(data);
+               return group;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlockPreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlockPreferencePage.java
new file mode 100644 (file)
index 0000000..d72b3de
--- /dev/null
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin, Google
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.preference.PreferencePage;
+
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Abstract preference page which is used to wrap a
+ * {@link org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock}.
+ * 
+ * @since 4.0
+ */
+public abstract class AbstractConfigurationBlockPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+       
+       
+       private IPreferenceConfigurationBlock fConfigurationBlock;
+       private OverlayPreferenceStore fOverlayStore;
+       
+
+       /**
+        * Creates a new preference page.
+        */
+       public AbstractConfigurationBlockPreferencePage() {
+               setDescription();
+               setPreferenceStore();
+               fOverlayStore= new OverlayPreferenceStore(getPreferenceStore(), new OverlayPreferenceStore.OverlayKey[] {});
+               fConfigurationBlock= createConfigurationBlock(fOverlayStore);
+       }
+               
+       protected abstract IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore);
+       protected abstract String getHelpId();
+       protected abstract void setDescription();
+       protected abstract void setPreferenceStore();
+       
+       /*
+        * @see IWorkbenchPreferencePage#init()
+        */     
+       public void init(IWorkbench workbench) {
+       }
+
+       /*
+        * @see PreferencePage#createControl(Composite)
+        */
+       @Override
+       public void createControl(Composite parent) {
+               super.createControl(parent);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), getHelpId());
+       }
+       
+       /*
+        * @see PreferencePage#createContents(Composite)
+        */
+       @Override
+       protected Control createContents(Composite parent) {
+               
+               fOverlayStore.load();
+               fOverlayStore.start();
+               
+               Control content= fConfigurationBlock.createControl(parent);
+               
+               initialize();
+               
+               Dialog.applyDialogFont(content);
+               return content;
+       }
+       
+       private void initialize() {
+               fConfigurationBlock.initialize();
+       }
+       
+    /*
+        * @see PreferencePage#performOk()
+        */
+       @Override
+       public boolean performOk() {
+               
+               fConfigurationBlock.performOk();
+
+               fOverlayStore.propagate();
+               
+               return true;
+       }
+       
+       /*
+        * @see PreferencePage#performDefaults()
+        */
+       @Override
+       public void performDefaults() {
+               
+               fOverlayStore.loadDefaults();
+               fConfigurationBlock.performDefaults();
+
+               super.performDefaults();
+       }
+       
+       /*
+        * @see DialogPage#dispose()
+        */
+       @Override
+       public void dispose() {
+               
+               fConfigurationBlock.dispose();
+               
+               if (fOverlayStore != null) {
+                       fOverlayStore.stop();
+                       fOverlayStore= null;
+               }
+               
+               super.dispose();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractMixedPreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractMixedPreferencePage.java
new file mode 100644 (file)
index 0000000..c531330
--- /dev/null
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Jens Elmenthaler and others
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Jens Elmenthaler - initial API and implementation
+ *                       (http://bugs.eclipse.org/173458, camel case completion)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
+
+import org.eclipse.cdt.core.CCorePlugin;
+
+/**
+ * A preference that on preference from the UI plugin, as well the CDT core.
+ * 
+ * Currently only supporting boolean preferences.
+ */
+public abstract class AbstractMixedPreferencePage extends AbstractPreferencePage {
+
+       protected OverlayPreferenceStore corePrefsOverlayStore;
+
+       private Map<Button, String> corePrefsCheckBoxes = new HashMap<Button, String>();
+       private SelectionListener corePrefsCheckBoxListener = new SelectionListener() {
+               public void widgetDefaultSelected(SelectionEvent e) {
+               }
+
+               public void widgetSelected(SelectionEvent e) {
+                       Button button = (Button) e.widget;
+                       corePrefsOverlayStore.setValue(corePrefsCheckBoxes.get(button), button.getSelection());
+               }
+       };
+
+       public AbstractMixedPreferencePage() {
+               corePrefsOverlayStore = new OverlayPreferenceStore(new ScopedPreferenceStore(InstanceScope.INSTANCE,
+                               CCorePlugin.PLUGIN_ID), createCorePrefsOverlayStoreKeys());
+       }
+
+       protected Button addCorePrefsCheckBox(Composite parent, String label, String key, int indentation) {
+               Button checkBox = new Button(parent, SWT.CHECK);
+               checkBox.setText(label);
+
+               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalIndent = indentation;
+               gd.horizontalSpan = 2;
+               checkBox.setLayoutData(gd);
+               checkBox.addSelectionListener(corePrefsCheckBoxListener);
+
+               corePrefsCheckBoxes.put(checkBox, key);
+
+               return checkBox;
+       }
+
+       protected abstract OverlayPreferenceStore.OverlayKey[] createCorePrefsOverlayStoreKeys();
+       
+       @Override
+       protected void initializeFields() {
+               super.initializeFields();
+
+               Iterator<Button> e = corePrefsCheckBoxes.keySet().iterator();
+               while (e.hasNext()) {
+                       Button b = e.next();
+                       String key = corePrefsCheckBoxes.get(b);
+                       b.setSelection(corePrefsOverlayStore.getBoolean(key));
+               }
+       }
+       
+       @Override
+       public boolean performOk() {
+               corePrefsOverlayStore.propagate();
+               return super.performOk();
+       }
+       
+       @Override
+       protected void performDefaults() {
+               corePrefsOverlayStore.loadDefaults();
+               super.performDefaults();
+       }
+
+       @Override
+       public void dispose() {
+               if (corePrefsOverlayStore != null) {
+                       corePrefsOverlayStore.stop();
+                       corePrefsOverlayStore = null;
+               }
+               super.dispose();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractPreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractPreferencePage.java
new file mode 100644 (file)
index 0000000..edd80e8
--- /dev/null
@@ -0,0 +1,378 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     IBM Corporation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.preference.ColorSelector;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
+
+/**
+ * AbstractPreferencePage
+ */
+public abstract class AbstractPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+
+       protected OverlayPreferenceStore fOverlayStore;
+
+       /**
+        * List of master/slave listeners when there's a dependency.
+        * 
+        * @see #createDependency(Button, String, Control)
+        * @since 3.0
+        */
+       private ArrayList<SelectionListener> fMasterSlaveListeners= new ArrayList<SelectionListener>();
+
+       protected Map<Object, String> fTextFields = new HashMap<Object, String>();
+       private ModifyListener fTextFieldListener = new ModifyListener() {
+               public void modifyText(ModifyEvent e) {
+                       Text text = (Text) e.widget;
+                       fOverlayStore.setValue(fTextFields.get(text), text.getText());
+               }
+       };
+       
+       protected Map<Object, String> fComboBoxes = new HashMap<Object, String>();
+       private ModifyListener fComboBoxListener = new ModifyListener() {
+               public void modifyText(ModifyEvent e) {
+                       Combo combo = (Combo) e.widget;
+                       String state = ProposalFilterPreferencesUtil.comboStateAsString(combo);
+                       fOverlayStore.setValue(fComboBoxes.get(combo), state);
+               }
+       };
+       
+
+       protected Map<Object, String> fCheckBoxes = new HashMap<Object, String>();
+       private SelectionListener fCheckBoxListener = new SelectionListener() {
+               public void widgetDefaultSelected(SelectionEvent e) {
+               }
+               public void widgetSelected(SelectionEvent e) {
+                       Button button = (Button) e.widget;
+                       fOverlayStore.setValue(fCheckBoxes.get(button), button.getSelection());
+               }
+       };
+
+       protected ArrayList<Text> fNumberFields = new ArrayList<Text>();
+       private ModifyListener fNumberFieldListener = new ModifyListener() {
+               public void modifyText(ModifyEvent e) {
+                       numberFieldChanged((Text) e.widget);
+               }
+       };
+
+       protected Map<Object, String> fColorButtons = new HashMap<Object, String>();
+       private SelectionListener fColorButtonListener = new SelectionListener() {
+               public void widgetDefaultSelected(SelectionEvent e) {
+               }
+               public void widgetSelected(SelectionEvent e) {
+                       ColorSelector editor = (ColorSelector) e.widget.getData();
+                       PreferenceConverter.setValue(fOverlayStore, fColorButtons.get(editor), editor.getColorValue());
+               }
+       };
+
+       protected static final int NO_TEXT_LIMIT = -1;
+
+       protected Button addRadioButton(Composite parent, String label, String key, int indentation) {
+               Button radioButton = new Button(parent, SWT.RADIO);
+               radioButton.setText(label);
+
+               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalIndent = indentation;
+               gd.horizontalSpan = 2;
+               radioButton.setLayoutData(gd);
+               radioButton.addSelectionListener(fCheckBoxListener);
+
+               if (key != null)
+                       fCheckBoxes.put(radioButton, key);
+
+               return radioButton;
+       }
+       
+       protected Button addCheckBox(Composite parent, String label, String key, int indentation) {
+               Button checkBox = new Button(parent, SWT.CHECK);
+               checkBox.setText(label);
+
+               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalIndent = indentation;
+               gd.horizontalSpan = 2;
+               checkBox.setLayoutData(gd);
+               checkBox.addSelectionListener(fCheckBoxListener);
+
+               fCheckBoxes.put(checkBox, key);
+
+               return checkBox;
+       }
+
+       protected Group addGroupBox(Composite parent, String label, int nColumns) {
+               Group group = new Group(parent, SWT.NONE);
+               group.setText(label);
+               GridLayout layout = new GridLayout();
+               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = 2;
+               layout.numColumns = nColumns;
+               group.setLayout(layout);
+               group.setLayoutData(gd);
+               return group;
+       }
+
+       protected Control addTextField(Composite composite, String label, String key, int textLimit,
+                       int indentation, boolean isNumber) {
+               Label labelControl = new Label(composite, SWT.NONE);
+               labelControl.setText(label);
+               GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+               gd.horizontalIndent = indentation;
+               labelControl.setLayoutData(gd);
+
+               Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE);
+               gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+               gd.widthHint = convertWidthInCharsToPixels(textLimit + 1);
+               textControl.setLayoutData(gd);
+               textControl.setTextLimit(textLimit);
+               fTextFields.put(textControl, key);
+               if (isNumber) {
+                       fNumberFields.add(textControl);
+                       textControl.addModifyListener(fNumberFieldListener);
+               } else {
+                       textControl.addModifyListener(fTextFieldListener);
+               }
+
+               return textControl;
+       }
+
+       protected void addComboBox(Composite composite, String label, String key, int textLimit,
+                       int indentation) {
+               Label labelControl = new Label(composite, SWT.NONE);
+               labelControl.setText(label);
+               GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+               gd.horizontalIndent = indentation;
+               labelControl.setLayoutData(gd);
+
+               Combo comboControl = new Combo(composite, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);  // TODO: When will the combo be disposed?
+               gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
+               if (textLimit != NO_TEXT_LIMIT) {
+                       gd.widthHint = convertWidthInCharsToPixels(textLimit + 1);
+                       comboControl.setTextLimit(textLimit);
+               }
+               comboControl.setLayoutData(gd);
+               fComboBoxes.put(comboControl, key);
+               comboControl.addModifyListener(fComboBoxListener);  // TODO: When will the listener be removed? 
+       }
+
+       protected void addFiller(Composite composite) {
+               PixelConverter pixelConverter= new PixelConverter(composite);
+               Label filler= new Label(composite, SWT.LEFT );
+               GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               gd.horizontalSpan= 2;
+               gd.heightHint= pixelConverter.convertHeightInCharsToPixels(1) / 2;
+               filler.setLayoutData(gd);
+       }
+
+       protected void createDependency(final Button master, String masterKey, final Control slave) {
+               indent(slave);
+               boolean masterState= fOverlayStore.getBoolean(masterKey);
+               slave.setEnabled(masterState);
+               SelectionListener listener= new SelectionListener() {
+                       public void widgetSelected(SelectionEvent e) {
+                               slave.setEnabled(master.getSelection());
+                       }
+
+                       public void widgetDefaultSelected(SelectionEvent e) {}
+               };
+               master.addSelectionListener(listener);
+               fMasterSlaveListeners.add(listener);
+       }
+
+       protected void numberFieldChanged(Text textControl) {
+               String number = textControl.getText();
+               IStatus status = validatePositiveNumber(number);
+               if (!status.matches(IStatus.ERROR))
+                       fOverlayStore.setValue(fTextFields.get(textControl), number);
+               updateStatus(status);
+       }
+
+       private IStatus validatePositiveNumber(String number) {
+               StatusInfo status = new StatusInfo();
+               if (number.length() == 0) {
+                       status.setError(PreferencesMessages.CEditorPreferencePage_empty_input); 
+               } else {
+                       try {
+                               int value = Integer.parseInt(number);
+                               if (value < 0)
+                                       status.setError(NLS.bind(PreferencesMessages.CEditorPreferencePage_invalid_input, number)); 
+                       } catch (NumberFormatException e) {
+                               status.setError(NLS.bind(PreferencesMessages.CEditorPreferencePage_invalid_input, number)); 
+                       }
+               }
+               return status;
+       }
+
+       protected void updateStatus(IStatus status) {
+               if (!status.matches(IStatus.ERROR)) {
+                       for (int i = 0; i < fNumberFields.size(); i++) {
+                               Text text = fNumberFields.get(i);
+                               IStatus s = validatePositiveNumber(text.getText());
+                               status = StatusUtil.getMoreSevere(s, status);
+                       }
+               }
+               //status= StatusUtil.getMoreSevere(fCEditorHoverConfigurationBlock.getStatus(), status);
+               setValid(!status.matches(IStatus.ERROR));
+               StatusUtil.applyToStatusLine(this, status);
+       }
+
+       protected void indent(Control control) {
+               GridData gridData= new GridData();
+               gridData.horizontalIndent= 20;
+               control.setLayoutData(gridData);                
+       }
+
+       protected Control addColorButton(Composite parent, String label, String key, int indentation) {
+
+               Composite composite = new Composite(parent, SWT.NONE);
+               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = 2;
+               composite.setLayoutData(gd);
+
+               GridLayout layout = new GridLayout();
+               layout.numColumns = 2;
+               layout.marginWidth = 0;
+               layout.marginHeight = 0;
+               composite.setLayout(layout);
+
+               Label labelControl = new Label(composite, SWT.NONE);
+               labelControl.setText(label);
+
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalIndent = indentation;
+               labelControl.setLayoutData(gd);
+
+               ColorSelector editor = new ColorSelector(composite);
+               Button button = editor.getButton();
+               button.setData(editor);
+
+               gd = new GridData();
+               gd.horizontalAlignment = GridData.END;
+               button.setLayoutData(gd);
+               button.addSelectionListener(fColorButtonListener);
+
+               fColorButtons.put(editor, key);
+
+               return composite;
+       }
+
+       public AbstractPreferencePage() {
+               super();                
+               setPreferenceStore(PreferenceConstants.getPreferenceStore());
+               fOverlayStore = new OverlayPreferenceStore(getPreferenceStore(), createOverlayStoreKeys());
+       }
+
+       protected abstract OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys();
+       
+       protected void initializeFields() {
+               Iterator<Object> e = fColorButtons.keySet().iterator();
+               while (e.hasNext()) {
+                       ColorSelector c = (ColorSelector) e.next();
+                       String key = fColorButtons.get(c);
+                       RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
+                       c.setColorValue(rgb);
+               }
+
+               e = fCheckBoxes.keySet().iterator();
+               while (e.hasNext()) {
+                       Button b = (Button) e.next();
+                       String key = fCheckBoxes.get(b);
+                       b.setSelection(fOverlayStore.getBoolean(key));
+               }
+
+               e = fTextFields.keySet().iterator();
+               while (e.hasNext()) {
+                       Text t = (Text) e.next();
+                       String key = fTextFields.get(t);
+                       t.setText(fOverlayStore.getString(key));
+               }
+
+               e = fComboBoxes.keySet().iterator();
+               while (e.hasNext()) {
+                       Combo c = (Combo) e.next();
+                       String key = fComboBoxes.get(c);
+                       String state = fOverlayStore.getString(key);
+                       // Interpret the state string as a Combo state description
+                       ProposalFilterPreferencesUtil.restoreComboFromString(c, state);
+               }
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+        */
+       public void init(IWorkbench workbench) {
+       }
+
+       /*
+        * @see PreferencePage#performOk()
+        */
+       @Override
+       public boolean performOk() {
+               fOverlayStore.propagate();
+               return true;
+       }
+
+       /*
+        * @see PreferencePage#performDefaults()
+        */
+       @Override
+       protected void performDefaults() {
+               fOverlayStore.loadDefaults();
+               initializeFields();
+               super.performDefaults();
+       }
+
+       /*
+        * @see DialogPage#dispose()
+        */
+       @Override
+       public void dispose() {
+               if (fOverlayStore != null) {
+                       fOverlayStore.stop();
+                       fOverlayStore = null;
+               }
+               super.dispose();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AppearancePreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AppearancePreferencePage.java
new file mode 100644 (file)
index 0000000..bf05078
--- /dev/null
@@ -0,0 +1,247 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.PlatformUI;
+import org.osgi.service.prefs.BackingStoreException;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.CCorePreferenceConstants;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
+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.SelectionButtonDialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.Separator;
+
+public class AppearancePreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+
+       private SelectionButtonDialogField fShowTUChildren;
+       private SelectionButtonDialogField fOutlineGroupIncludes;
+       private SelectionButtonDialogField fOutlineGroupNamespaces;
+       private SelectionButtonDialogField fCViewGroupIncludes;
+       private SelectionButtonDialogField fCViewSeparateHeaderAndSource;
+       private SelectionButtonDialogField fCViewGroupMacros;
+       private SelectionButtonDialogField fOutlineGroupMembers;
+       private SelectionButtonDialogField fOutlineGroupMacros;
+       private SelectionButtonDialogField fShowSourceRootsAtTopOfProject;
+       private SelectionButtonDialogField fCViewSortOrderOfExcludedFiles;
+
+       
+       public AppearancePreferencePage() {
+               setPreferenceStore(PreferenceConstants.getPreferenceStore());
+               setDescription(PreferencesMessages.AppearancePreferencePage_description); 
+       
+               IDialogFieldListener listener= new IDialogFieldListener() {
+                       public void dialogFieldChanged(DialogField field) {
+                               doDialogFieldChanged(field);
+                       }
+               };
+
+               fShowTUChildren= new SelectionButtonDialogField(SWT.CHECK);
+               fShowTUChildren.setDialogFieldListener(listener);
+               fShowTUChildren.setLabelText(PreferencesMessages.AppearancePreferencePage_showTUChildren_label); 
+
+               fOutlineGroupIncludes= new SelectionButtonDialogField(SWT.CHECK);
+               fOutlineGroupIncludes.setDialogFieldListener(listener);
+               fOutlineGroupIncludes.setLabelText(PreferencesMessages.AppearancePreferencePage_outlineGroupIncludes_label); 
+
+               fOutlineGroupNamespaces= new SelectionButtonDialogField(SWT.CHECK);
+               fOutlineGroupNamespaces.setDialogFieldListener(listener);
+               fOutlineGroupNamespaces.setLabelText(PreferencesMessages.AppearancePreferencePage_outlineGroupNamespaces_label); 
+
+               fOutlineGroupMembers= new SelectionButtonDialogField(SWT.CHECK);
+               fOutlineGroupMembers.setDialogFieldListener(listener);
+               fOutlineGroupMembers.setLabelText(PreferencesMessages.AppearancePreferencePage_outlineGroupMethods_label); 
+
+               fCViewGroupIncludes= new SelectionButtonDialogField(SWT.CHECK);
+               fCViewGroupIncludes.setDialogFieldListener(listener);
+               fCViewGroupIncludes.setLabelText(PreferencesMessages.AppearancePreferencePage_cviewGroupIncludes_label); 
+               
+               fCViewSeparateHeaderAndSource= new SelectionButtonDialogField(SWT.CHECK);
+               fCViewSeparateHeaderAndSource.setDialogFieldListener(listener);
+               fCViewSeparateHeaderAndSource.setLabelText(PreferencesMessages.AppearancePreferencePage_cviewSeparateHeaderAndSource_label); 
+
+               fShowSourceRootsAtTopOfProject= new SelectionButtonDialogField(SWT.CHECK);
+               fShowSourceRootsAtTopOfProject.setDialogFieldListener(listener);
+               fShowSourceRootsAtTopOfProject.setLabelText(PreferencesMessages.AppearancePreferencePage_showSourceRootsAtTopOfProject_label); 
+               
+               fOutlineGroupMacros= new SelectionButtonDialogField(SWT.CHECK);
+               fOutlineGroupMacros.setDialogFieldListener(listener);
+               fOutlineGroupMacros.setLabelText(PreferencesMessages.AppearancePreferencePage_outlineGroupMacros_label);
+               
+               fCViewGroupMacros= new SelectionButtonDialogField(SWT.CHECK);
+               fCViewGroupMacros.setDialogFieldListener(listener);
+               fCViewGroupMacros.setLabelText(PreferencesMessages.AppearancePreferencePage_cviewGroupMacros_label);
+               
+               fCViewSortOrderOfExcludedFiles= new SelectionButtonDialogField(SWT.CHECK);
+               fCViewSortOrderOfExcludedFiles.setDialogFieldListener(listener);
+               fCViewSortOrderOfExcludedFiles.setLabelText(PreferencesMessages.AppearancePreferencePage_cviewKeepSortOrderOfExcludedFiles_label);
+       }
+
+       private void initFields() {
+               IPreferenceStore prefs= getPreferenceStore();
+               fShowTUChildren.setSelection(prefs.getBoolean(PreferenceConstants.PREF_SHOW_CU_CHILDREN));
+               fCViewGroupIncludes.setSelection(prefs.getBoolean(PreferenceConstants.CVIEW_GROUP_INCLUDES));
+               fCViewSeparateHeaderAndSource.setSelection(prefs.getBoolean(PreferenceConstants.CVIEW_SEPARATE_HEADER_AND_SOURCE));
+               fCViewGroupMacros.setSelection(prefs.getBoolean(PreferenceConstants.CVIEW_GROUP_MACROS));
+               fOutlineGroupIncludes.setSelection(prefs.getBoolean(PreferenceConstants.OUTLINE_GROUP_INCLUDES));
+               fOutlineGroupNamespaces.setSelection(prefs.getBoolean(PreferenceConstants.OUTLINE_GROUP_NAMESPACES));
+               fOutlineGroupMembers.setSelection(prefs.getBoolean(PreferenceConstants.OUTLINE_GROUP_MEMBERS));
+               fOutlineGroupMacros.setSelection(prefs.getBoolean(PreferenceConstants.OUTLINE_GROUP_MACROS));
+               boolean showSourceRootsAtTopOfProject = CCorePlugin.showSourceRootsAtTopOfProject();
+               fShowSourceRootsAtTopOfProject.setSelection(showSourceRootsAtTopOfProject);
+               fCViewSortOrderOfExcludedFiles.setSelection(prefs.getBoolean(PreferenceConstants.SORT_ORDER_OF_EXCLUDED_FILES));
+       }
+       
+       /*
+        * @see PreferencePage#createControl(Composite)
+        */
+       @Override
+       public void createControl(Composite parent) {
+               super.createControl(parent);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.APPEARANCE_PREFERENCE_PAGE);
+       }       
+
+       /*
+        * @see PreferencePage#createContents(Composite)
+        */
+       @Override
+       protected Control createContents(Composite parent) {
+               initializeDialogUnits(parent);
+               int nColumns= 1;
+                               
+               Composite result= new Composite(parent, SWT.NONE);
+               GridLayout layout= new GridLayout();
+               layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+               layout.marginWidth= 0;
+               layout.numColumns= nColumns;
+               result.setLayout(layout);
+                               
+               fShowTUChildren.doFillIntoGrid(result, nColumns);
+               fCViewGroupIncludes.doFillIntoGrid(result, nColumns);
+               fOutlineGroupIncludes.doFillIntoGrid(result, nColumns);
+               fOutlineGroupNamespaces.doFillIntoGrid(result, nColumns);
+               fOutlineGroupMembers.doFillIntoGrid(result, nColumns);
+               fCViewGroupMacros.doFillIntoGrid(result, nColumns);
+               fOutlineGroupMacros.doFillIntoGrid(result, nColumns);
+
+               new Separator().doFillIntoGrid(result, nColumns);
+               
+               fCViewSeparateHeaderAndSource.doFillIntoGrid(result, nColumns);
+               fCViewSortOrderOfExcludedFiles.doFillIntoGrid(result, nColumns);
+               
+               String noteTitle= PreferencesMessages.AppearancePreferencePage_note;
+               String noteMessage= PreferencesMessages.AppearancePreferencePage_preferenceOnlyForNewViews; 
+               Composite noteControl= createNoteComposite(JFaceResources.getDialogFont(), result, noteTitle, noteMessage);
+               GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               gd.horizontalSpan= 2;
+               noteControl.setLayoutData(gd);
+               
+               
+               new Separator().doFillIntoGrid(result, nColumns);
+               fShowSourceRootsAtTopOfProject.doFillIntoGrid(result, nColumns);
+               
+               initFields();
+               
+               Dialog.applyDialogFont(result);
+               return result;
+       }
+       
+       void doDialogFieldChanged(DialogField field) {  
+               updateStatus(getValidationStatus());
+       }
+       
+       private IStatus getValidationStatus(){
+               return new StatusInfo();
+       }
+       
+       private void updateStatus(IStatus status) {
+               setValid(!status.matches(IStatus.ERROR));
+               StatusUtil.applyToStatusLine(this, status);
+       }               
+       
+       /*
+        * @see IWorkbenchPreferencePage#init(IWorkbench)
+        */
+       public void init(IWorkbench workbench) {
+       }
+       
+       /*
+        * @see IPreferencePage#performOk()
+        */
+       @Override
+       public boolean performOk() {
+               IPreferenceStore prefs= getPreferenceStore();
+               prefs.setValue(PreferenceConstants.PREF_SHOW_CU_CHILDREN, fShowTUChildren.isSelected());
+               prefs.setValue(PreferenceConstants.CVIEW_GROUP_INCLUDES, fCViewGroupIncludes.isSelected());
+               prefs.setValue(PreferenceConstants.CVIEW_SEPARATE_HEADER_AND_SOURCE, fCViewSeparateHeaderAndSource.isSelected());
+               prefs.setValue(PreferenceConstants.CVIEW_GROUP_MACROS, fCViewGroupMacros.isSelected());
+               prefs.setValue(PreferenceConstants.OUTLINE_GROUP_INCLUDES, fOutlineGroupIncludes.isSelected());
+               prefs.setValue(PreferenceConstants.OUTLINE_GROUP_NAMESPACES, fOutlineGroupNamespaces.isSelected());
+               prefs.setValue(PreferenceConstants.OUTLINE_GROUP_MEMBERS, fOutlineGroupMembers.isSelected());
+               prefs.setValue(PreferenceConstants.OUTLINE_GROUP_MACROS, fOutlineGroupMacros.isSelected());
+               prefs.setValue(PreferenceConstants.SORT_ORDER_OF_EXCLUDED_FILES, fCViewSortOrderOfExcludedFiles.isSelected());
+               try {
+                       InstanceScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID).flush();
+                       IEclipsePreferences corePluginNode = InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID);
+                       corePluginNode.putBoolean(
+                                       CCorePreferenceConstants.SHOW_SOURCE_ROOTS_AT_TOP_LEVEL_OF_PROJECT, 
+                                       fShowSourceRootsAtTopOfProject.isSelected());
+                       corePluginNode.flush();
+               } catch (BackingStoreException exc) {
+                       CUIPlugin.log(exc);
+               }
+               return super.performOk();
+       }
+       
+       /*
+        * @see PreferencePage#performDefaults()
+        */
+       @Override
+       protected void performDefaults() {
+               IPreferenceStore prefs= getPreferenceStore();
+               fShowTUChildren.setSelection(prefs.getDefaultBoolean(PreferenceConstants.PREF_SHOW_CU_CHILDREN));
+               fCViewGroupIncludes.setSelection(prefs.getDefaultBoolean(PreferenceConstants.CVIEW_GROUP_INCLUDES));
+               fCViewSeparateHeaderAndSource.setSelection(prefs.getDefaultBoolean(PreferenceConstants.CVIEW_SEPARATE_HEADER_AND_SOURCE));
+               fCViewGroupMacros.setSelection(prefs.getDefaultBoolean(PreferenceConstants.CVIEW_GROUP_MACROS));
+               fOutlineGroupIncludes.setSelection(prefs.getDefaultBoolean(PreferenceConstants.OUTLINE_GROUP_INCLUDES));
+               fOutlineGroupNamespaces.setSelection(prefs.getDefaultBoolean(PreferenceConstants.OUTLINE_GROUP_NAMESPACES));
+               fOutlineGroupMembers.setSelection(prefs.getDefaultBoolean(PreferenceConstants.OUTLINE_GROUP_MEMBERS));
+               fOutlineGroupMacros.setSelection(prefs.getDefaultBoolean(PreferenceConstants.OUTLINE_GROUP_MACROS));
+               boolean showSourceRootsPref = DefaultScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).getBoolean(CCorePreferenceConstants.SHOW_SOURCE_ROOTS_AT_TOP_LEVEL_OF_PROJECT, true);
+               fShowSourceRootsAtTopOfProject.setSelection(showSourceRootsPref);
+               fCViewSortOrderOfExcludedFiles.setSelection(prefs.getDefaultBoolean(PreferenceConstants.SORT_ORDER_OF_EXCLUDED_FILES));
+               super.performDefaults();
+       }
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildConsolePreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildConsolePreferencePage.java
new file mode 100644 (file)
index 0000000..8b025ee
--- /dev/null
@@ -0,0 +1,167 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.ColorFieldEditor;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.IntegerFieldEditor;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.PlatformUI;
+
+public class BuildConsolePreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
+
+       private static final String PREF_CLEAR_CONSOLE = "clearConsole"; //$NON-NLS-1$
+       private static final String PREF_CONSOLE_ON_TOP = "consoleOnTop"; //$NON-NLS-1$
+       private static final String PREF_AUTO_OPEN_CONSOLE = "autoOpenConsole"; //$NON-NLS-1$
+
+       // In font registry
+       public static final String PREF_BUILDCONSOLE_FONT = "org.eclipse.cdt.ui.buildconsole.ConsoleFont"; //$NON-NLS-1$
+
+       public static final String PREF_BUILDCONSOLE_TAB_WIDTH = "buildConsoleTabWith"; //$NON-NLS-1$
+       public static final String PREF_BUILDCONSOLE_LINES = "buildConsoleLines"; //$NON-NLS-1$
+       public static final String PREF_BUILDCONSOLE_INFO_COLOR = "buildConsoleInfoStreamColor"; //$NON-NLS-1$
+       public static final String PREF_BUILDCONSOLE_OUTPUT_COLOR = "buildConsoleOutputStreamColor"; //$NON-NLS-1$
+       public static final String PREF_BUILDCONSOLE_ERROR_COLOR = "buildConsoleErrorStreamColor"; //$NON-NLS-1$
+       public static final String PREF_BUILDCONSOLE_BACKGROUND_COLOR = "buildConsoleBackgroundColor"; //$NON-NLS-1$
+       public static final String PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR = "buildConsoleProblemBackgroundColor"; //$NON-NLS-1$
+       public static final String PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR = "buildConsoleProblemWarningBackgroundColor"; //$NON-NLS-1$
+       public static final String PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR = "buildConsoleProblemInfoBackgroundColor"; //$NON-NLS-1$
+       public static final String PREF_BUILDCONSOLE_PROBLEM_HIGHLIGHTED_COLOR = "buildConsoleProblemHighlightedColor"; //$NON-NLS-1$
+
+       public BuildConsolePreferencePage() {
+               super(GRID);
+               setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
+       }
+
+       @Override
+       public void createControl(Composite parent) {
+               super.createControl(parent);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.BUILD_CONSOLE_PREFERENCE_PAGE);
+       }
+
+       @Override
+       protected void createFieldEditors() {
+               Composite parent = getFieldEditorParent();
+               BooleanFieldEditor clearConsole = new BooleanFieldEditor(PREF_CLEAR_CONSOLE,
+                               CUIPlugin.getResourceString("ConsolePreferencePage.clearConsole.label"), parent); //$NON-NLS-1$
+               addField(clearConsole);
+
+               BooleanFieldEditor autoOpenConsole = new BooleanFieldEditor(PREF_AUTO_OPEN_CONSOLE,
+                               CUIPlugin.getResourceString("ConsolePreferencePage.autoOpenConsole.label"), parent); //$NON-NLS-1$
+               addField(autoOpenConsole);
+               BooleanFieldEditor consoleOnTop = new BooleanFieldEditor(PREF_CONSOLE_ON_TOP,
+                               CUIPlugin.getResourceString("ConsolePreferencePage.consoleOnTop.label"), parent); //$NON-NLS-1$
+               addField(consoleOnTop);
+
+               IntegerFieldEditor buildCount = new IntegerFieldEditor(PREF_BUILDCONSOLE_LINES,
+                               CUIPlugin.getResourceString("ConsolePreferencePage.consoleLines.label"), parent); //$NON-NLS-1$
+               buildCount.setErrorMessage(CUIPlugin.getResourceString("ConsolePreferencePage.consoleLines.errorMessage")); //$NON-NLS-1$
+               buildCount.setValidRange(10, Integer.MAX_VALUE);
+               addField(buildCount);
+
+               IntegerFieldEditor tabSize = new IntegerFieldEditor(PREF_BUILDCONSOLE_TAB_WIDTH,
+                               CUIPlugin.getResourceString("ConsolePreferencePage.tabWidth.label"), parent); //$NON-NLS-1$
+               addField(tabSize);
+               tabSize.setValidRange(1, 100);
+               tabSize.setErrorMessage(CUIPlugin.getResourceString("ConsolePreferencePage.tabWidth.errorMessage")); //$NON-NLS-1$
+
+               createLabel(parent, CUIPlugin.getResourceString("ConsolePreferencePage.colorSettings.label")); //$NON-NLS-1$
+
+               addField(createColorFieldEditor(PREF_BUILDCONSOLE_OUTPUT_COLOR,
+                               CUIPlugin.getResourceString("ConsolePreferencePage.outputColor.label"), parent)); //$NON-NLS-1$
+               addField(createColorFieldEditor(PREF_BUILDCONSOLE_INFO_COLOR,
+                               CUIPlugin.getResourceString("ConsolePreferencePage.infoColor.label"), parent)); //$NON-NLS-1$
+               addField(createColorFieldEditor(PREF_BUILDCONSOLE_ERROR_COLOR,
+                               CUIPlugin.getResourceString("ConsolePreferencePage.errorColor.label"), parent)); //$NON-NLS-1$
+               addField(createColorFieldEditor(PREF_BUILDCONSOLE_BACKGROUND_COLOR,
+                               CUIPlugin.getResourceString("ConsolePreferencePage.backgroundColor.label"), parent)); //$NON-NLS-1$
+               addField(createColorFieldEditor(PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR,
+                               CUIPlugin.getResourceString("ConsolePreferencePage.problemBackgroundColor.label"), parent)); //$NON-NLS-1$
+               addField(createColorFieldEditor(PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR,
+                               CUIPlugin.getResourceString("ConsolePreferencePage.problemWarningBackgroundColor.label"), parent)); //$NON-NLS-1$
+               addField(createColorFieldEditor(PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR,
+                               CUIPlugin.getResourceString("ConsolePreferencePage.problemInfoBackgroundColor.label"), parent)); //$NON-NLS-1$
+               addField(createColorFieldEditor(PREF_BUILDCONSOLE_PROBLEM_HIGHLIGHTED_COLOR,
+                               CUIPlugin.getResourceString("ConsolePreferencePage.problemHighlightedColor.label"), parent)); //$NON-NLS-1$
+       }
+
+       private Label createLabel(Composite parent, String text) {
+               Label label = new Label(parent, SWT.LEFT);
+               label.setText(text);
+               GridData data = new GridData();
+               data.horizontalSpan = 2;
+               data.horizontalAlignment = GridData.FILL;
+               label.setLayoutData(data);
+               return label;
+       }
+       /**
+        * Creates a new color field editor.
+        */
+       private ColorFieldEditor createColorFieldEditor(String preferenceName, String label, Composite parent) {
+               ColorFieldEditor editor = new ColorFieldEditor(preferenceName, label, parent);
+               editor.setPage(this);
+               editor.setPreferenceStore(getPreferenceStore());
+               return editor;
+       }
+
+       /**
+        * Returns the current preference setting if the build console should be
+        * cleared before each build.
+        */
+       public static boolean isClearBuildConsole() {
+               return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PREF_CLEAR_CONSOLE);
+       }
+       public static boolean isAutoOpenConsole() {
+               return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PREF_AUTO_OPEN_CONSOLE);
+       }
+
+       public static boolean isConsoleOnTop() {
+               return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PREF_CONSOLE_ON_TOP);
+       }
+
+       public static int buildConsoleLines() {
+               return CUIPlugin.getDefault().getPreferenceStore().getInt(PREF_BUILDCONSOLE_LINES);
+       }
+
+       public void init(IWorkbench workbench) {
+       }
+
+       public static void initDefaults(IPreferenceStore prefs) {
+               prefs.setDefault(PREF_CLEAR_CONSOLE, true);
+               prefs.setDefault(PREF_AUTO_OPEN_CONSOLE, true);
+               prefs.setDefault(PREF_CONSOLE_ON_TOP, false);
+               prefs.setDefault(PREF_BUILDCONSOLE_LINES, 500);
+               prefs.setDefault(PREF_BUILDCONSOLE_TAB_WIDTH, 4);
+               PreferenceConverter.setDefault(prefs, PREF_BUILDCONSOLE_OUTPUT_COLOR, new RGB(0, 0, 0));
+               PreferenceConverter.setDefault(prefs, PREF_BUILDCONSOLE_INFO_COLOR, new RGB(0, 0, 255));
+               PreferenceConverter.setDefault(prefs, PREF_BUILDCONSOLE_ERROR_COLOR, new RGB(255, 0, 0));
+               PreferenceConverter.setDefault(prefs, PREF_BUILDCONSOLE_BACKGROUND_COLOR, new RGB(255, 255, 255));
+               PreferenceConverter.setDefault(prefs, PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR, new RGB(254, 231, 224));
+               PreferenceConverter.setDefault(prefs, PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR, new RGB(254, 243, 218));
+               PreferenceConverter.setDefault(prefs, PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR, new RGB(244, 247, 254));
+               PreferenceConverter.setDefault(prefs, PREF_BUILDCONSOLE_PROBLEM_HIGHLIGHTED_COLOR, new RGB(255, 0, 0));
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildLogPreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildLogPreferencePage.java
new file mode 100644 (file)
index 0000000..357062e
--- /dev/null
@@ -0,0 +1,178 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Andrew Gvozdev and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Andrew Gvozdev (Quoin Inc.) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.PropertyPage;
+import org.osgi.service.prefs.BackingStoreException;
+import org.osgi.service.prefs.Preferences;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+
+import org.eclipse.cdt.internal.ui.buildconsole.BuildConsoleManager;
+
+/**
+ * Preference page defining build log properties.
+ */
+public class BuildLogPreferencePage extends PropertyPage implements ICOptionContainer {
+       private boolean isProjectLevel;
+       private Button enableLoggingCheckbox;
+       private Button browseButton;
+       private Text logLocationText;
+       private Label logLocationLabel;
+
+       @Override
+       protected Control createContents(Composite parent) {
+               IProject project = getProject();
+               isProjectLevel= project != null;
+               if(isProjectLevel) {
+                       BuildConsoleManager consoleManager = getConsoleManager();
+                       Preferences prefs = consoleManager.getBuildLogPreferences(project);
+
+                       Composite contents = ControlFactory.createCompositeEx(parent, 3, GridData.FILL_BOTH);
+                       ((GridLayout) contents.getLayout()).makeColumnsEqualWidth = false;
+
+                       ControlFactory.createEmptySpace(contents, 3);
+
+                       // [v] Enable Logging
+                       enableLoggingCheckbox = ControlFactory.createCheckBox(contents, PreferencesMessages.BuildLogPreferencePage_EnableLogging);
+                       ((GridData) enableLoggingCheckbox.getLayoutData()).horizontalSpan = 2;
+                       boolean keepLog = prefs.getBoolean(BuildConsoleManager.KEY_KEEP_LOG, BuildConsoleManager.CONSOLE_KEEP_LOG_DEFAULT);
+                       enableLoggingCheckbox.setSelection(keepLog);
+                       enableLoggingCheckbox.addSelectionListener(new SelectionAdapter() {
+                               @Override
+                               public void widgetSelected(SelectionEvent e) {
+                                       updateEnablements();
+                               }
+                       });
+
+                       ControlFactory.createEmptySpace(contents, 3);
+
+                       // Log file location: [....................]
+                       logLocationLabel = ControlFactory.createLabel(contents, PreferencesMessages.BuildLogPreferencePage_LogLocation);
+                       ((GridData) logLocationLabel.getLayoutData()).grabExcessHorizontalSpace = false;
+
+                       logLocationText = ControlFactory.createTextField(contents, SWT.SINGLE | SWT.BORDER);
+                       String logLocation = prefs.get(BuildConsoleManager.KEY_LOG_LOCATION, consoleManager.getDefaultConsoleLogLocation(project));
+                       logLocationText.setText(logLocation);
+                       logLocationText.addModifyListener(new ModifyListener() {
+                               public void modifyText(ModifyEvent e) {
+                               }
+                       });
+
+                       // [Browse...]
+                       browseButton = ControlFactory.createPushButton(contents, PreferencesMessages.BuildLogPreferencePage_Browse);
+                       ((GridData) browseButton.getLayoutData()).horizontalAlignment = GridData.END;
+                       browseButton.addSelectionListener(new SelectionAdapter() {
+                               @Override
+                               public void widgetSelected(SelectionEvent event) {
+                                       FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
+                                       dialog.setText(PreferencesMessages.BuildLogPreferencePage_ChooseLogFile);
+                                       String fileName = logLocationText.getText();
+                                       IPath logFolder = new Path(fileName).removeLastSegments(1);
+                                       dialog.setFilterPath(logFolder.toOSString());
+                                       String chosenFile = dialog.open();
+                                       if (chosenFile != null) {
+                                               logLocationText.setText(chosenFile);
+                                       }
+                               }
+
+                       });
+
+                       updateEnablements();
+               }
+               return parent;
+       }
+
+       @Override
+       protected void performDefaults() {
+               if(isProjectLevel) {
+                       IProject project = getProject();
+                       BuildConsoleManager consoleManager = getConsoleManager();
+                       Preferences prefs = consoleManager.getBuildLogPreferences(project);
+                       prefs.put(BuildConsoleManager.KEY_LOG_LOCATION, consoleManager.getDefaultConsoleLogLocation(project));
+                       prefs.putBoolean(BuildConsoleManager.KEY_KEEP_LOG, BuildConsoleManager.CONSOLE_KEEP_LOG_DEFAULT);
+                       try {
+                               prefs.flush();
+                       } catch (BackingStoreException e) {
+                               CUIPlugin.log(e);
+                       }
+                       logLocationText.setText(prefs.get(BuildConsoleManager.KEY_LOG_LOCATION, consoleManager.getDefaultConsoleLogLocation(project)));
+                       enableLoggingCheckbox.setSelection(prefs.getBoolean(BuildConsoleManager.KEY_KEEP_LOG, BuildConsoleManager.CONSOLE_KEEP_LOG_DEFAULT));
+                       updateEnablements();
+               }
+               super.performDefaults();
+       }
+
+       @Override
+       public boolean performOk() {
+               if(isProjectLevel) {
+                       BuildConsoleManager consoleManager = getConsoleManager();
+                       Preferences prefs = consoleManager.getBuildLogPreferences(getProject());
+                       prefs.put(BuildConsoleManager.KEY_LOG_LOCATION, logLocationText.getText());
+                       prefs.putBoolean(BuildConsoleManager.KEY_KEEP_LOG, enableLoggingCheckbox.getSelection());
+                       try {
+                               prefs.flush();
+                       } catch (BackingStoreException e) {
+                               CUIPlugin.log(e);
+                       }
+               }
+               return true;
+       }
+
+       public IProject getProject(){
+               IProject project= null;
+               IAdaptable elem = getElement();
+               if (elem instanceof IProject) {
+                       project= (IProject) elem;
+               } else if (elem != null) {
+                       project= (IProject) elem.getAdapter(IProject.class);
+               }
+               return project;
+       }
+
+       private BuildConsoleManager getConsoleManager() {
+               return (BuildConsoleManager)CUIPlugin.getDefault().getConsoleManager();
+       }
+
+       @Deprecated
+       public org.eclipse.core.runtime.Preferences getPreferences() {
+               throw new UnsupportedOperationException();
+       }
+
+       public void updateContainer() {
+       }
+
+       private void updateEnablements() {
+               boolean isLoggingEnabled = enableLoggingCheckbox.getSelection();
+               logLocationLabel.setEnabled(isLoggingEnabled);
+               logLocationText.setEnabled(isLoggingEnabled);
+               browseButton.setEnabled(isLoggingEnabled);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java
new file mode 100644 (file)
index 0000000..baa9ca3
--- /dev/null
@@ -0,0 +1,962 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems
+ *     Andrew Ferguson (Symbian)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.preference.ColorSelector;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.viewers.IColorProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontMetrics;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.ScrollBar;
+import org.eclipse.swt.widgets.Scrollable;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.texteditor.ChainedPreferenceStore;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.ICPartitions;
+import org.eclipse.cdt.ui.text.IColorManager;
+import org.eclipse.cdt.ui.text.doctools.doxygen.DoxygenHelper;
+
+import org.eclipse.cdt.internal.ui.editor.CSourceViewer;
+import org.eclipse.cdt.internal.ui.editor.SemanticHighlighting;
+import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingManager;
+import org.eclipse.cdt.internal.ui.editor.SemanticHighlightingManager.HighlightedRange;
+import org.eclipse.cdt.internal.ui.editor.SemanticHighlightings;
+import org.eclipse.cdt.internal.ui.text.SimpleCSourceViewerConfiguration;
+import org.eclipse.cdt.internal.ui.text.util.CColorManager;
+
+/**
+ * Configures C/C++ Editor code coloring preferences.
+ * 
+ * @since 4.0
+ */
+class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock {
+       
+       /**
+        * Item in the highlighting color list.
+        */
+       private static class HighlightingColorListItem {
+               /** Display name */
+               private String fDisplayName;
+               /** Color preference key */
+               private String fColorKey;
+               /** Bold preference key */
+               private String fBoldKey;
+               /** Italic preference key */
+               private String fItalicKey;
+               /** Strikethrough preference key */
+               private String fStrikethroughKey;
+               /** Underline preference key */
+               private String fUnderlineKey;
+               
+               /**
+                * Initialize the item with the given values.
+                * @param displayName the display name
+                * @param colorKey the color preference key
+                * @param boldKey the bold preference key
+                * @param italicKey the italic preference key
+                * @param strikethroughKey the strikethrough preference key
+                * @param underlineKey the underline preference key
+                */
+               public HighlightingColorListItem(String displayName, String colorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey) {
+                       fDisplayName= displayName;
+                       fColorKey= colorKey;
+                       fBoldKey= boldKey;
+                       fItalicKey= italicKey;
+                       fStrikethroughKey= strikethroughKey;
+                       fUnderlineKey= underlineKey;
+               }
+               
+               /**
+                * @return the bold preference key
+                */
+               public String getBoldKey() {
+                       return fBoldKey;
+               }
+               
+               /**
+                * @return the bold preference key
+                */
+               public String getItalicKey() {
+                       return fItalicKey;
+               }
+               
+               /**
+                * @return the strikethrough preference key
+                */
+               public String getStrikethroughKey() {
+                       return fStrikethroughKey;
+               }
+               
+               /**
+                * @return the underline preference key
+                */
+               public String getUnderlineKey() {
+                       return fUnderlineKey;
+               }
+               
+               /**
+                * @return the color preference key
+                */
+               public String getColorKey() {
+                       return fColorKey;
+               }
+               
+               /**
+                * @return the display name
+                */
+               public String getDisplayName() {
+                       return fDisplayName;
+               }
+       }
+       
+       private static class SemanticHighlightingColorListItem extends HighlightingColorListItem {
+       
+               /** Enablement preference key */
+               private final String fEnableKey;
+               
+               /**
+                * Initialize the item with the given values.
+                * @param displayName the display name
+                * @param colorKey the color preference key
+                * @param boldKey the bold preference key
+                * @param italicKey the italic preference key
+                * @param strikethroughKey the strikethroughKey preference key
+                * @param underlineKey the underlineKey preference key
+                * @param enableKey the enable preference key
+                */
+               public SemanticHighlightingColorListItem(String displayName, String colorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey, String enableKey) {
+                       super(displayName, colorKey, boldKey, italicKey, strikethroughKey, underlineKey);
+                       fEnableKey= enableKey;
+               }
+       
+               /**
+                * @return the enablement preference key
+                */
+               public String getEnableKey() {
+                       return fEnableKey;
+               }
+       }
+
+       /**
+        * Color list label provider.
+        */
+       private class ColorListLabelProvider extends LabelProvider implements IColorProvider {
+               /*
+                * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
+                */
+               @Override
+               public String getText(Object element) {
+                       if (element instanceof String)
+                               return (String) element;
+                       return ((HighlightingColorListItem)element).getDisplayName();
+               }
+
+               /*
+                * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
+                */
+               public Color getBackground(Object element) {
+                       return null;
+               }
+
+               /*
+                * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
+                */
+               public Color getForeground(Object element) {
+                       if (element instanceof SemanticHighlightingColorListItem) {
+                               if (!getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED)) {
+                                       return Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
+                               }
+                       }
+                       return null;
+               }
+       }
+
+       /**
+        * Color list content provider.
+        */
+       private class ColorListContentProvider implements ITreeContentProvider {
+       
+               /*
+                * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+                */
+               public Object[] getElements(Object inputElement) {
+                       return new String[] {fCodeCategory, fAssemblyCategory, fCommentsCategory, fPreprocessorCategory, fDoxygenCategory};
+               }
+       
+               /*
+                * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+                */
+               public void dispose() {
+               }
+       
+               /*
+                * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+                */
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+               }
+
+               public Object[] getChildren(Object parentElement) {
+                       if (parentElement instanceof String) {
+                               String entry= (String) parentElement;
+                               if (fCodeCategory.equals(entry))
+                                       return fListModel.subList(11, fListModel.size()).toArray();
+                               if (fAssemblyCategory.equals(entry))
+                                       return fListModel.subList(6, 8).toArray();
+                               if (fCommentsCategory.equals(entry))
+                                       return fListModel.subList(0, 3).toArray();
+                               if (fPreprocessorCategory.equals(entry))
+                                       return fListModel.subList(3, 6).toArray();
+                               if (fDoxygenCategory.equals(entry))
+                                       return fListModel.subList(8, 11).toArray();
+                       }
+                       return new Object[0];
+               }
+
+               public Object getParent(Object element) {
+                       if (element instanceof String)
+                               return null;
+                       int index= fListModel.indexOf(element);
+                       if (index >= 11)
+                               return fCodeCategory;
+                       if (index >= 8)
+                               return fDoxygenCategory;
+                       if (index >= 6)
+                               return fAssemblyCategory;
+                       if (index >= 3)
+                               return fPreprocessorCategory;
+                       return fCommentsCategory;
+               }
+
+               public boolean hasChildren(Object element) {
+                       return element instanceof String;
+               }
+       }
+
+       /**
+        * Preference key suffix for bold preferences.
+        */
+       private static final String BOLD= PreferenceConstants.EDITOR_BOLD_SUFFIX;
+       /**
+        * Preference key suffix for italic preferences.
+        */
+       private static final String ITALIC= PreferenceConstants.EDITOR_ITALIC_SUFFIX;
+       /**
+        * Preference key suffix for strikethrough preferences.
+        */
+       private static final String STRIKETHROUGH= PreferenceConstants.EDITOR_STRIKETHROUGH_SUFFIX;
+       /**
+        * Preference key suffix for underline preferences.
+        */
+       private static final String UNDERLINE= PreferenceConstants.EDITOR_UNDERLINE_SUFFIX;
+       
+       /**
+        * The keys of the overlay store.
+        */
+       private final String[][] fSyntaxColorListModel= new String[][] {
+                       { PreferencesMessages.CEditorColoringConfigurationBlock_MultiLine, PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR },
+                       { PreferencesMessages.CEditorColoringConfigurationBlock_singleLine, PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR },
+                       { PreferencesMessages.CEditorColoringConfigurationBlock_cCommentTaskTags, PreferenceConstants.EDITOR_TASK_TAG_COLOR },
+                       { PreferencesMessages.CEditorColoringConfigurationBlock_ppDirectives, PreferenceConstants.EDITOR_PP_DIRECTIVE_COLOR },
+                       { PreferencesMessages.CEditorColoringConfigurationBlock_ppOthers, PreferenceConstants.EDITOR_PP_DEFAULT_COLOR },
+                       { PreferencesMessages.CEditorColoringConfigurationBlock_ppHeaders, PreferenceConstants.EDITOR_PP_HEADER_COLOR },
+                       { PreferencesMessages.CEditorColoringConfigurationBlock_asmLabels, PreferenceConstants.EDITOR_ASM_LABEL_COLOR },
+                       { PreferencesMessages.CEditorColoringConfigurationBlock_asmDirectives, PreferenceConstants.EDITOR_ASM_DIRECTIVE_COLOR },
+               { PreferencesMessages.CEditorColoringConfigurationBlock_DoxygenTagRecognized, DoxygenHelper.DOXYGEN_TAG_RECOGNIZED },
+                       { PreferencesMessages.CEditorColoringConfigurationBlock_DoxygenSingleLineComment, DoxygenHelper.DOXYGEN_SINGLE_TOKEN },
+                       { PreferencesMessages.CEditorColoringConfigurationBlock_DoxygenMultiLineComment, DoxygenHelper.DOXYGEN_MULTI_TOKEN },
+                       { PreferencesMessages.CEditorColoringConfigurationBlock_keywords, PreferenceConstants.EDITOR_C_KEYWORD_COLOR },
+//                     { PreferencesMessages.CEditorColoringConfigurationBlock_returnKeyword, PreferenceConstants.EDITOR_C_KEYWORD_RETURN_COLOR },
+                       { PreferencesMessages.CEditorColoringConfigurationBlock_builtInTypes, PreferenceConstants.EDITOR_C_BUILTIN_TYPE_COLOR },
+                       { PreferencesMessages.CEditorColoringConfigurationBlock_operators, PreferenceConstants.EDITOR_C_OPERATOR_COLOR },
+                       { PreferencesMessages.CEditorColoringConfigurationBlock_strings, PreferenceConstants.EDITOR_C_STRING_COLOR },
+                       { PreferencesMessages.CEditorColoringConfigurationBlock_braces, PreferenceConstants.EDITOR_C_BRACES_COLOR },
+                       { PreferencesMessages.CEditorColoringConfigurationBlock_numbers, PreferenceConstants.EDITOR_C_NUMBER_COLOR },
+                       { PreferencesMessages.CEditorColoringConfigurationBlock_others, PreferenceConstants.EDITOR_C_DEFAULT_COLOR },
+       };
+               
+       private final String fCodeCategory= PreferencesMessages.CEditorColoringConfigurationBlock_coloring_category_code;
+       private final String fCommentsCategory= PreferencesMessages.CEditorColoringConfigurationBlock_coloring_category_comments;
+       private final String fPreprocessorCategory= PreferencesMessages.CEditorColoringConfigurationBlock_coloring_category_preprocessor;
+       private final String fAssemblyCategory= PreferencesMessages.CEditorColoringConfigurationBlock_coloring_category_assembly;
+       private final String fDoxygenCategory= PreferencesMessages.CEditorColoringConfigurationBlock_coloring_category_doxygen;
+       
+       private ColorSelector fSyntaxForegroundColorEditor;
+       private Label fColorEditorLabel;
+       private Button fEnableSemanticHighlightingCheckbox;
+       private Button fBoldCheckBox;
+       private Button fEnableCheckbox;
+       /**
+        * Check box for italic preference.
+        */
+       private Button fItalicCheckBox;
+       /**
+        * Check box for strikethrough preference.
+        */
+       private Button fStrikethroughCheckBox;
+       /**
+        * Check box for underline preference.
+        */
+       private Button fUnderlineCheckBox;
+       /**
+        * Highlighting color list
+        */
+       private final java.util.List<HighlightingColorListItem> fListModel= new ArrayList<HighlightingColorListItem>();
+       /**
+        * Highlighting color list viewer
+        */
+       private StructuredViewer fListViewer;
+       /**
+        * Semantic highlighting manager
+        */
+       private SemanticHighlightingManager fSemanticHighlightingManager;
+       /**
+        * The previewer.
+        */
+       private CSourceViewer fPreviewViewer;
+       /**
+        * The color manager.
+        */
+       private IColorManager fColorManager;
+       /**
+        * The font metrics.
+        */
+       private FontMetrics fFontMetrics;
+
+       public CEditorColoringConfigurationBlock(OverlayPreferenceStore store) {
+               super(store);
+               
+               fColorManager= new CColorManager(false);
+               
+               for (String[] element : fSyntaxColorListModel)
+                       fListModel.add(new HighlightingColorListItem (
+                                       element[0],
+                                       element[1],
+                                       element[1] + BOLD,
+                                       element[1] + ITALIC,
+                                       element[1] + STRIKETHROUGH,
+                                       element[1] + UNDERLINE));
+
+               SemanticHighlighting[] semanticHighlightings= SemanticHighlightings.getSemanticHighlightings();
+               for (SemanticHighlighting semanticHighlighting : semanticHighlightings)
+                       fListModel.add(
+                                       new SemanticHighlightingColorListItem(
+                                                       semanticHighlighting.getDisplayName(),
+                                                       SemanticHighlightings.getColorPreferenceKey(semanticHighlighting),
+                                                       SemanticHighlightings.getBoldPreferenceKey(semanticHighlighting),
+                                                       SemanticHighlightings.getItalicPreferenceKey(semanticHighlighting),
+                                                       SemanticHighlightings.getStrikethroughPreferenceKey(semanticHighlighting),
+                                                       SemanticHighlightings.getUnderlinePreferenceKey(semanticHighlighting),
+                                                       SemanticHighlightings.getEnabledPreferenceKey(semanticHighlighting)
+                                       ));
+               
+               store.addKeys(createOverlayStoreKeys());
+       }
+
+       private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
+               List<OverlayPreferenceStore.OverlayKey> overlayKeys= new ArrayList<OverlayPreferenceStore.OverlayKey>();
+
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED));
+               
+               for (int i= 0, n= fListModel.size(); i < n; i++) {
+                       HighlightingColorListItem item= fListModel.get(i);
+                       overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, item.getColorKey()));
+                       overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, item.getBoldKey()));
+                       overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, item.getItalicKey()));
+                       overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, item.getStrikethroughKey()));
+                       overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, item.getUnderlineKey()));
+                       
+                       if (item instanceof SemanticHighlightingColorListItem)
+                               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ((SemanticHighlightingColorListItem) item).getEnableKey()));
+               }
+               
+               OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
+               overlayKeys.toArray(keys);
+               return keys;
+       }
+
+       /**
+        * Creates page for hover preferences.
+        * 
+        * @param parent the parent composite
+        * @return the control for the preference page
+        */
+       public Control createControl(Composite parent) {
+               initializeDialogUnits(parent);
+               return createSyntaxPage(parent);
+       }
+       
+       /**
+     * Returns the number of pixels corresponding to the width of the given
+     * number of characters.
+     * <p>
+     * This method may only be called after <code>initializeDialogUnits</code>
+     * has been called.
+     * </p>
+     * <p>
+     * Clients may call this framework method, but should not override it.
+     * </p>
+     * 
+     * @param chars
+     *            the number of characters
+     * @return the number of pixels
+     */
+    private int convertWidthInCharsToPixels(int chars) {
+        // test for failure to initialize for backward compatibility
+        if (fFontMetrics == null)
+            return 0;
+        return Dialog.convertWidthInCharsToPixels(fFontMetrics, chars);
+    }
+
+       /**
+     * Returns the number of pixels corresponding to the height of the given
+     * number of characters.
+     * <p>
+     * This method may only be called after <code>initializeDialogUnits</code>
+     * has been called.
+     * </p>
+     * <p>
+     * Clients may call this framework method, but should not override it.
+     * </p>
+     * 
+     * @param chars
+     *            the number of characters
+     * @return the number of pixels
+     */
+    private int convertHeightInCharsToPixels(int chars) {
+        // test for failure to initialize for backward compatibility
+        if (fFontMetrics == null)
+            return 0;
+        return Dialog.convertHeightInCharsToPixels(fFontMetrics, chars);
+    }
+    
+       @Override
+       public void initialize() {
+               super.initialize();
+               
+               fListViewer.setInput(fListModel);
+               fListViewer.setSelection(new StructuredSelection(fCodeCategory));
+       }
+
+       @Override
+       public void performDefaults() {
+               super.performDefaults();
+               
+               fListViewer.refresh();
+
+               handleSyntaxColorListSelection();
+
+               uninstallSemanticHighlighting();
+               installSemanticHighlighting();
+
+               fPreviewViewer.invalidateTextPresentation();
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#dispose()
+        */
+       @Override
+       public void dispose() {
+               uninstallSemanticHighlighting();
+               fColorManager.dispose();
+
+               super.dispose();
+       }
+
+       private void handleSyntaxColorListSelection() {
+               HighlightingColorListItem item= getHighlightingColorListItem();
+               if (item == null) {
+                       fEnableCheckbox.setEnabled(false);
+                       fSyntaxForegroundColorEditor.getButton().setEnabled(false);
+                       fColorEditorLabel.setEnabled(false);
+                       fBoldCheckBox.setEnabled(false);
+                       fItalicCheckBox.setEnabled(false);
+                       fStrikethroughCheckBox.setEnabled(false);
+                       fUnderlineCheckBox.setEnabled(false);
+                       return;
+               }
+               RGB rgb= PreferenceConverter.getColor(getPreferenceStore(), item.getColorKey());
+               fSyntaxForegroundColorEditor.setColorValue(rgb);
+               fBoldCheckBox.setSelection(getPreferenceStore().getBoolean(item.getBoldKey()));
+               fItalicCheckBox.setSelection(getPreferenceStore().getBoolean(item.getItalicKey()));
+               fStrikethroughCheckBox.setSelection(getPreferenceStore().getBoolean(item.getStrikethroughKey()));
+               fUnderlineCheckBox.setSelection(getPreferenceStore().getBoolean(item.getUnderlineKey()));
+               if (item instanceof SemanticHighlightingColorListItem) {
+                       boolean semanticHighlightingEnabled= getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED);
+                       fEnableCheckbox.setEnabled(semanticHighlightingEnabled);
+                       boolean enable= semanticHighlightingEnabled && getPreferenceStore().getBoolean(((SemanticHighlightingColorListItem) item).getEnableKey());
+                       fEnableCheckbox.setSelection(enable);
+                       fSyntaxForegroundColorEditor.getButton().setEnabled(enable);
+                       fColorEditorLabel.setEnabled(enable);
+                       fBoldCheckBox.setEnabled(enable);
+                       fItalicCheckBox.setEnabled(enable);
+                       fStrikethroughCheckBox.setEnabled(enable);
+                       fUnderlineCheckBox.setEnabled(enable);
+               } else {
+                       fSyntaxForegroundColorEditor.getButton().setEnabled(true);
+                       fColorEditorLabel.setEnabled(true);
+                       fBoldCheckBox.setEnabled(true);
+                       fItalicCheckBox.setEnabled(true);
+                       fStrikethroughCheckBox.setEnabled(true);
+                       fUnderlineCheckBox.setEnabled(true);
+                       fEnableCheckbox.setEnabled(false);
+                       fEnableCheckbox.setSelection(true);
+               }
+       }
+       
+       private Control createSyntaxPage(final Composite parent) {
+               
+               Composite colorComposite= new Composite(parent, SWT.NONE);
+               GridLayout layout= new GridLayout();
+               layout.marginHeight= 0;
+               layout.marginWidth= 0;
+               colorComposite.setLayout(layout);
+
+               Link link= new Link(colorComposite, SWT.NONE);
+               link.setText(PreferencesMessages.CEditorColoringConfigurationBlock_link);
+               link.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               PreferencesUtil.createPreferenceDialogOn(parent.getShell(), e.text, null, null);
+                       }
+               });
+               // TODO replace by link-specific tooltips when
+               // bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=88866 gets fixed
+//             link.setToolTipText(PreferencesMessages.CEditorColoringConfigurationBlock_link_tooltip);
+               
+               GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
+               gridData.widthHint= 150; // only expand further if anyone else requires it
+               gridData.horizontalSpan= 2;
+               link.setLayoutData(gridData);
+
+               addFiller(colorComposite, 1);
+
+               fEnableSemanticHighlightingCheckbox= addCheckBox(colorComposite,
+                               PreferencesMessages.CEditorColoringConfigurationBlock_enable_semantic_highlighting,
+                               PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED, 0);
+               
+               Label label;
+               label= new Label(colorComposite, SWT.LEFT);
+               label.setText(PreferencesMessages.CEditorColoringConfigurationBlock_coloring_element);
+               label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+       
+               Composite editorComposite= new Composite(colorComposite, SWT.NONE);
+               layout= new GridLayout();
+               layout.numColumns= 2;
+               layout.marginHeight= 0;
+               layout.marginWidth= 0;
+               editorComposite.setLayout(layout);
+               GridData gd= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
+               editorComposite.setLayoutData(gd);
+       
+               fListViewer= new TreeViewer(editorComposite, SWT.SINGLE | SWT.BORDER);
+               fListViewer.setLabelProvider(new ColorListLabelProvider());
+               fListViewer.setContentProvider(new ColorListContentProvider());
+               fListViewer.setSorter(new ViewerSorter() {
+                       @Override
+                       public int category(Object element) {
+                               // don't sort the top level categories
+                               if (fCodeCategory.equals(element))
+                                       return 0;
+                               if (fAssemblyCategory.equals(element))
+                                       return 1;
+                               if (fCommentsCategory.equals(element))
+                                       return 2;
+                               if (fPreprocessorCategory.equals(element))
+                                       return 3;
+                               if (fDoxygenCategory.equals(element))
+                                       return 4;
+                               return 0;
+                       }
+               });
+               gd= new GridData(SWT.BEGINNING, SWT.BEGINNING, false, true);
+               gd.heightHint= convertHeightInCharsToPixels(9);
+               int maxWidth= 0;
+               for (HighlightingColorListItem item : fListModel) {
+                       maxWidth= Math.max(maxWidth, convertWidthInCharsToPixels(item.getDisplayName().length()));
+               }
+               ScrollBar vBar= ((Scrollable) fListViewer.getControl()).getVerticalBar();
+               if (vBar != null)
+                       maxWidth += vBar.getSize().x * 3; // scrollbars and tree indentation guess
+               gd.widthHint= maxWidth;
+               
+               fListViewer.getControl().setLayoutData(gd);
+               
+               Composite stylesComposite= new Composite(editorComposite, SWT.NONE);
+               layout= new GridLayout();
+               layout.marginHeight= 0;
+               layout.marginWidth= 0;
+               layout.numColumns= 2;
+               stylesComposite.setLayout(layout);
+               stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+               
+               fEnableCheckbox= new Button(stylesComposite, SWT.CHECK);
+               fEnableCheckbox.setText(PreferencesMessages.CEditorColoringConfigurationBlock_enable);
+               gd= new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalAlignment= GridData.BEGINNING;
+               gd.horizontalSpan= 2;
+               fEnableCheckbox.setLayoutData(gd);
+               
+               fColorEditorLabel= new Label(stylesComposite, SWT.LEFT);
+               fColorEditorLabel.setText(PreferencesMessages.CEditorColoringConfigurationBlock_color);
+               gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+               gd.horizontalIndent= 20;
+               fColorEditorLabel.setLayoutData(gd);
+       
+               fSyntaxForegroundColorEditor= new ColorSelector(stylesComposite);
+               Button foregroundColorButton= fSyntaxForegroundColorEditor.getButton();
+               gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+               foregroundColorButton.setLayoutData(gd);
+               
+               fBoldCheckBox= new Button(stylesComposite, SWT.CHECK);
+               fBoldCheckBox.setText(PreferencesMessages.CEditorColoringConfigurationBlock_bold);
+               gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+               gd.horizontalIndent= 20;
+               gd.horizontalSpan= 2;
+               fBoldCheckBox.setLayoutData(gd);
+               
+               fItalicCheckBox= new Button(stylesComposite, SWT.CHECK);
+               fItalicCheckBox.setText(PreferencesMessages.CEditorColoringConfigurationBlock_italic);
+               gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+               gd.horizontalIndent= 20;
+               gd.horizontalSpan= 2;
+               fItalicCheckBox.setLayoutData(gd);
+               
+               fStrikethroughCheckBox= new Button(stylesComposite, SWT.CHECK);
+               fStrikethroughCheckBox.setText(PreferencesMessages.CEditorColoringConfigurationBlock_strikethrough);
+               gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+               gd.horizontalIndent= 20;
+               gd.horizontalSpan= 2;
+               fStrikethroughCheckBox.setLayoutData(gd);
+               
+               fUnderlineCheckBox= new Button(stylesComposite, SWT.CHECK);
+               fUnderlineCheckBox.setText(PreferencesMessages.CEditorColoringConfigurationBlock_underline);
+               gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+               gd.horizontalIndent= 20;
+               gd.horizontalSpan= 2;
+               fUnderlineCheckBox.setLayoutData(gd);
+               
+               label= new Label(colorComposite, SWT.LEFT);
+               label.setText(PreferencesMessages.CEditorColoringConfigurationBlock_preview);
+               label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               
+               Control previewer= createPreviewer(colorComposite);
+               gd= new GridData(GridData.FILL_BOTH);
+               gd.widthHint= convertWidthInCharsToPixels(20);
+               gd.heightHint= convertHeightInCharsToPixels(5);
+               previewer.setLayoutData(gd);
+               
+               fListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+                       public void selectionChanged(SelectionChangedEvent event) {
+                               handleSyntaxColorListSelection();
+                       }
+               });
+               
+               foregroundColorButton.addSelectionListener(new SelectionListener() {
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               // do nothing
+                       }
+                       public void widgetSelected(SelectionEvent e) {
+                               HighlightingColorListItem item= getHighlightingColorListItem();
+                               PreferenceConverter.setValue(getPreferenceStore(), item.getColorKey(), fSyntaxForegroundColorEditor.getColorValue());
+                       }
+               });
+       
+               fBoldCheckBox.addSelectionListener(new SelectionListener() {
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               // do nothing
+                       }
+                       public void widgetSelected(SelectionEvent e) {
+                               HighlightingColorListItem item= getHighlightingColorListItem();
+                               getPreferenceStore().setValue(item.getBoldKey(), fBoldCheckBox.getSelection());
+                       }
+               });
+                               
+               fItalicCheckBox.addSelectionListener(new SelectionListener() {
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               // do nothing
+                       }
+                       public void widgetSelected(SelectionEvent e) {
+                               HighlightingColorListItem item= getHighlightingColorListItem();
+                               getPreferenceStore().setValue(item.getItalicKey(), fItalicCheckBox.getSelection());
+                       }
+               });
+               fStrikethroughCheckBox.addSelectionListener(new SelectionListener() {
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               // do nothing
+                       }
+                       public void widgetSelected(SelectionEvent e) {
+                               HighlightingColorListItem item= getHighlightingColorListItem();
+                               getPreferenceStore().setValue(item.getStrikethroughKey(), fStrikethroughCheckBox.getSelection());
+                       }
+               });
+               
+               fUnderlineCheckBox.addSelectionListener(new SelectionListener() {
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               // do nothing
+                       }
+                       public void widgetSelected(SelectionEvent e) {
+                               HighlightingColorListItem item= getHighlightingColorListItem();
+                               getPreferenceStore().setValue(item.getUnderlineKey(), fUnderlineCheckBox.getSelection());
+                       }
+               });
+                               
+               fEnableCheckbox.addSelectionListener(new SelectionListener() {
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               // do nothing
+                       }
+                       public void widgetSelected(SelectionEvent e) {
+                               HighlightingColorListItem item= getHighlightingColorListItem();
+                               if (item instanceof SemanticHighlightingColorListItem) {
+                                       boolean enable= fEnableCheckbox.getSelection();
+                                       getPreferenceStore().setValue(((SemanticHighlightingColorListItem) item).getEnableKey(), enable);
+                                       fEnableCheckbox.setSelection(enable);
+                                       fSyntaxForegroundColorEditor.getButton().setEnabled(enable);
+                                       fColorEditorLabel.setEnabled(enable);
+                                       fBoldCheckBox.setEnabled(enable);
+                                       fItalicCheckBox.setEnabled(enable);
+                                       fStrikethroughCheckBox.setEnabled(enable);
+                                       fUnderlineCheckBox.setEnabled(enable);
+                                       uninstallSemanticHighlighting();
+                                       installSemanticHighlighting();
+                               }
+                       }
+               });
+               
+               fEnableSemanticHighlightingCheckbox.addSelectionListener(new SelectionListener() {
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               // do nothing
+                       }
+                       public void widgetSelected(SelectionEvent e) {
+                               fListViewer.refresh(true);
+                               HighlightingColorListItem item= getHighlightingColorListItem();
+                               if (item instanceof SemanticHighlightingColorListItem) {
+                                       handleSyntaxColorListSelection();
+                                       uninstallSemanticHighlighting();
+                                       installSemanticHighlighting();
+                               }
+                       }
+               });
+               
+               colorComposite.layout(false);
+                               
+               return colorComposite;
+       }
+       
+       private void addFiller(Composite composite, int horizontalSpan) {
+               PixelConverter pixelConverter= new PixelConverter(composite);
+               Label filler= new Label(composite, SWT.LEFT );
+               GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               gd.horizontalSpan= horizontalSpan;
+               gd.heightHint= pixelConverter.convertHeightInCharsToPixels(1) / 2;
+               filler.setLayoutData(gd);
+       }
+
+       private Control createPreviewer(Composite parent) {
+               IPreferenceStore generalTextStore= EditorsUI.getPreferenceStore();
+               IPreferenceStore store= new ChainedPreferenceStore(new IPreferenceStore[] { getPreferenceStore(), generalTextStore });
+               fPreviewViewer = new CSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store);
+               SimpleCSourceViewerConfiguration configuration = new SimpleCSourceViewerConfiguration(fColorManager, store, null, ICPartitions.C_PARTITIONING, false);
+               fPreviewViewer.configure(configuration);
+               Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
+               fPreviewViewer.getTextWidget().setFont(font);
+               CSourcePreviewerUpdater.registerPreviewer(fPreviewViewer, configuration, store);
+               fPreviewViewer.setEditable(false);
+               
+               String content= loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
+               IDocument document= new Document(content);
+               CUIPlugin.getDefault().getTextTools().setupCDocumentPartitioner(document, ICPartitions.C_PARTITIONING, null);
+               fPreviewViewer.setDocument(document);
+       
+               installSemanticHighlighting();
+               
+               return fPreviewViewer.getControl();
+       }
+
+       private String loadPreviewContentFromFile(String filename) {
+               String line;
+               String separator= System.getProperty("line.separator"); //$NON-NLS-1$
+               StringBuffer buffer= new StringBuffer(512);
+               BufferedReader reader= null;
+               try {
+                       reader= new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename)));
+                       while ((line= reader.readLine()) != null) {
+                               buffer.append(line);
+                               buffer.append(separator);
+                       }
+               } catch (IOException io) {
+                       CUIPlugin.log(io);
+               } finally {
+                       if (reader != null) {
+                               try { reader.close(); } catch (IOException e) {}
+                       }
+               }
+               return buffer.toString();
+       }
+
+       /**
+        * Install Semantic Highlighting on the previewer
+        */
+       private void installSemanticHighlighting() {
+               if (fSemanticHighlightingManager == null) {
+                       fSemanticHighlightingManager= new SemanticHighlightingManager();
+                       fSemanticHighlightingManager.install(fPreviewViewer, fColorManager, getPreferenceStore(), createPreviewerRanges());
+               }
+       }
+
+       /**
+        * Uninstall Semantic Highlighting from the previewer
+        */
+       private void uninstallSemanticHighlighting() {
+               if (fSemanticHighlightingManager != null) {
+                       fSemanticHighlightingManager.uninstall();
+                       fSemanticHighlightingManager= null;
+               }
+       }
+
+       /**
+        * Create the hard coded previewer ranges. Must be sorted by ascending offset.
+        * 
+        * @return the hard coded previewer ranges
+        */
+       private SemanticHighlightingManager.HighlightedRange[][] createPreviewerRanges() {
+               return new SemanticHighlightingManager.HighlightedRange[][] {
+                       { createHighlightedRange( 2,  8,  5, SemanticHighlightings.MACRO_DEFINITION) },
+                       { createHighlightedRange( 3, 16,  3, SemanticHighlightings.NAMESPACE) },
+                       { createHighlightedRange( 5, 21,  4, SemanticHighlightings.TYPEDEF) },
+                       { createHighlightedRange( 6, 11,  6, SemanticHighlightings.FUNCTION_DECLARATION),  createHighlightedRange( 6, 11,  6, SemanticHighlightings.FUNCTION) },
+                       { createHighlightedRange( 6, 18,  4, SemanticHighlightings.TYPEDEF) },
+                       { createHighlightedRange( 6, 23,  9, SemanticHighlightings.PARAMETER_VARIABLE) },
+                       { createHighlightedRange( 7,  6,  9, SemanticHighlightings.PARAMETER_VARIABLE) },
+                       { createHighlightedRange( 7, 22,  7, SemanticHighlightings.EXTERNAL_SDK), createHighlightedRange( 7, 22,  7, SemanticHighlightings.FUNCTION) },
+                       { createHighlightedRange( 7, 30,  6, SemanticHighlightings.GLOBAL_VARIABLE) },
+                       { createHighlightedRange( 8, 2,   4, SemanticHighlightings.GLOBAL_VARIABLE) },
+                       { createHighlightedRange( 8, 7,   2, SemanticHighlightings.OVERLOADED_OPERATOR) },
+                       { createHighlightedRange( 9,  9,  9, SemanticHighlightings.PARAMETER_VARIABLE) },
+                       { createHighlightedRange(11,  6,  7, SemanticHighlightings.CLASS) },
+                       { createHighlightedRange(13,  7,  6, SemanticHighlightings.ENUM) },
+                       { createHighlightedRange(13, 16,  4, SemanticHighlightings.ENUMERATOR) },
+                       { createHighlightedRange(13, 22,  3, SemanticHighlightings.ENUMERATOR) },
+                       { createHighlightedRange(13, 27,  3, SemanticHighlightings.ENUMERATOR) },
+                       { createHighlightedRange(14, 14, 11, SemanticHighlightings.STATIC_FIELD), createHighlightedRange(13, 14, 11, SemanticHighlightings.FIELD) },
+                       { createHighlightedRange(15,  6,  5, SemanticHighlightings.FIELD) },
+                       { createHighlightedRange(16, 10,  6, SemanticHighlightings.ENUM) },
+                       { createHighlightedRange(16, 17,  7, SemanticHighlightings.METHOD_DECLARATION), createHighlightedRange(15, 17,  7, SemanticHighlightings.METHOD) },
+                       { createHighlightedRange(17,  7,  6, SemanticHighlightings.METHOD_DECLARATION), createHighlightedRange(16,  7,  6, SemanticHighlightings.METHOD) },
+                       { createHighlightedRange(17, 14,  6, SemanticHighlightings.ENUM) },
+                       { createHighlightedRange(17, 21,  1, SemanticHighlightings.PARAMETER_VARIABLE) },
+                       { createHighlightedRange(18,  8,  5, SemanticHighlightings.LOCAL_VARIABLE_DECLARATION) },
+                       { createHighlightedRange(18, 20,  5, SemanticHighlightings.MACRO_REFERENCE) },
+                       { createHighlightedRange(19,  0,  5, SemanticHighlightings.LABEL) },
+                       { createHighlightedRange(19,  7,  6, SemanticHighlightings.FUNCTION) },
+                       { createHighlightedRange(19, 14,  5, SemanticHighlightings.LOCAL_VARIABLE) },
+                       { createHighlightedRange(20,  4,  7, SemanticHighlightings.METHOD) },
+                       { createHighlightedRange(21,  4, 12, SemanticHighlightings.STATIC_METHOD_INVOCATION), createHighlightedRange(20,  4, 12, SemanticHighlightings.METHOD) },
+                       { createHighlightedRange(22,  4,  7, SemanticHighlightings.PROBLEM) },
+                       { createHighlightedRange(24, 14, 12, SemanticHighlightings.METHOD_DECLARATION), createHighlightedRange(23, 14, 12, SemanticHighlightings.METHOD) },
+               };
+       }
+
+       /**
+        * Create a highlighted range on the previewers document with the given line, column, length and key.
+        * 
+        * @param line the line
+        * @param column the column
+        * @param length the length
+        * @param key the key
+        * @return the highlighted range
+        */
+       private HighlightedRange createHighlightedRange(int line, int column, int length, String key) {
+               try {
+                       IDocument document= fPreviewViewer.getDocument();
+                       int offset= document.getLineOffset(line) + column;
+                       return new HighlightedRange(offset, length, key);
+               } catch (BadLocationException x) {
+                       CUIPlugin.log(x);
+               }
+               return null;
+       }
+
+       /**
+        * Returns the current highlighting color list item.
+        * 
+        * @return the current highlighting color list item
+        */
+       private HighlightingColorListItem getHighlightingColorListItem() {
+               IStructuredSelection selection= (IStructuredSelection) fListViewer.getSelection();
+               Object element= selection.getFirstElement();
+               if (element instanceof String)
+                       return null;
+               return (HighlightingColorListItem) element;
+       }
+       
+       /**
+     * Initializes the computation of horizontal and vertical dialog units based
+     * on the size of current font.
+     * <p>
+     * This method must be called before any of the dialog unit based conversion
+     * methods are called.
+     * </p>
+     * 
+     * @param testControl
+     *            a control from which to obtain the current font
+     */
+    private void initializeDialogUnits(Control testControl) {
+        // Compute and store a font metric
+        GC gc = new GC(testControl);
+        gc.setFont(JFaceResources.getDialogFont());
+        fFontMetrics = gc.getFontMetrics();
+        gc.dispose();
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringPreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringPreferencePage.java
new file mode 100644 (file)
index 0000000..899beb8
--- /dev/null
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+
+
+
+/**
+ * Code coloring preference page.
+ * <p>
+ * Note: Must be public since it is referenced from plugin.xml
+ * </p>
+ * 
+ * @since 4.0
+ */
+public class CEditorColoringPreferencePage extends AbstractConfigurationBlockPreferencePage {
+
+       /*
+        * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#getHelpId()
+        */
+       @Override
+       protected String getHelpId() {
+               return ICHelpContextIds.C_EDITOR_COLORS_PREF_PAGE;
+       }
+
+       /*
+        * @see org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setDescription()
+        */
+       @Override
+       protected void setDescription() {
+               String description= PreferencesMessages.CEditorPreferencePage_colors; 
+               setDescription(description);
+       }
+       
+       
+       @Override
+       protected Label createDescriptionLabel(Composite parent) {
+               return null;
+       }
+       
+       /*
+        * @see org.org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setPreferenceStore()
+        */
+       @Override
+       protected void setPreferenceStore() {
+               setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
+       }
+
+       /*
+        * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#createConfigurationBlock(org.eclipse.ui.internal.editors.text.OverlayPreferenceStore)
+        */
+       @Override
+       protected IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore) {
+               return new CEditorColoringConfigurationBlock(overlayPreferenceStore);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java
new file mode 100644 (file)
index 0000000..f0a9430
--- /dev/null
@@ -0,0 +1,548 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ * Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
+import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey;
+import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverDescriptor;
+import org.eclipse.cdt.internal.ui.util.SWTUtil;
+import org.eclipse.cdt.internal.ui.util.TableLayoutComposite;
+
+/**
+ * Configures C/C++ Editor hover preferences.
+ */
+public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationBlock {
+       static final String DELIMITER= PreferencesMessages.CEditorHoverConfigurationBlock_delimiter; 
+
+       private static final int ENABLED_PROP= 0;
+       private static final int MODIFIER_PROP= 1;
+
+       // Data structure to hold the values which are edited by the user
+       private static class HoverConfig {
+               
+               String fModifierString;
+               boolean fIsEnabled;
+               int fStateMask;
+
+               private HoverConfig(String modifier, int stateMask, boolean enabled) {
+                       fModifierString= modifier;
+                       fIsEnabled= enabled;
+                       fStateMask= stateMask;
+               }
+       }
+       
+       
+       private class CEditorTextHoverDescriptorLabelProvider implements ITableLabelProvider {
+
+               public Image getColumnImage(Object element, int columnIndex) {
+                       return null;
+               }
+               
+               public String getColumnText(Object element, int columnIndex) {
+                       switch (columnIndex) {
+                       case ENABLED_PROP:
+                               return ((CEditorTextHoverDescriptor)element).getLabel();
+
+                       case MODIFIER_PROP:
+                               TableItem item= (TableItem)fHoverTableViewer.testFindItem(element);
+                               int index= fHoverTable.indexOf(item);
+                               return fHoverConfigs[index].fModifierString;
+
+                       default:
+                               break;
+                       }
+                       
+                       return null;
+               }
+
+               public void addListener(ILabelProviderListener listener) {
+               }
+               
+               public void dispose() {
+               }
+
+               public boolean isLabelProperty(Object element, String property) {
+                       return false;
+               }
+
+               public void removeListener(ILabelProviderListener listener) {
+               }
+       }
+       
+       
+       private class CEditorTextHoverDescriptorContentProvider implements IStructuredContentProvider {
+               
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+                       // Do nothing since the viewer listens to resource deltas
+               }
+               
+               public void dispose() {
+               }
+                               
+               public Object[] getElements(Object element) {
+                       return (Object[])element;
+               }
+       }
+
+       
+       OverlayPreferenceStore fStore;
+       HoverConfig[] fHoverConfigs;
+       Text fModifierEditor;
+       Table fHoverTable;
+       TableViewer fHoverTableViewer;
+       private TableColumn fNameColumn;
+       private TableColumn fModifierColumn;
+       private Text fDescription;
+       
+       private PreferencePage fMainPreferencePage;
+
+       private StatusInfo fStatus;
+       
+       public CEditorHoverConfigurationBlock(PreferencePage mainPreferencePage, OverlayPreferenceStore store) {
+               Assert.isNotNull(mainPreferencePage);
+               Assert.isNotNull(store);
+               fMainPreferencePage= mainPreferencePage;
+               fStore= store;
+               fStore.addKeys(createOverlayStoreKeys());
+       }
+
+
+       private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
+               
+               ArrayList<OverlayKey> overlayKeys= new ArrayList<OverlayKey>();
+       
+               //overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS));
+               
+               OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
+               overlayKeys.toArray(keys);
+               return keys;
+       }
+
+       /**
+        * Creates page for hover preferences.
+        *
+        * @param parent the parent composite
+        * @return the control for the preference page
+        */
+       public Control createControl(Composite parent) {
+
+               ScrolledPageContent scrolled= new ScrolledPageContent(parent, SWT.H_SCROLL | SWT.V_SCROLL);
+               scrolled.setExpandHorizontal(true);
+               scrolled.setExpandVertical(true);
+
+
+               Composite hoverComposite= new Composite(scrolled, SWT.NONE);
+               GridLayout layout= new GridLayout();
+               layout.numColumns= 2;
+               layout.marginWidth= 0;
+               layout.marginHeight= 0;
+               hoverComposite.setLayout(layout);
+               hoverComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+               
+               //String rollOverLabel= PreferencesMessages.getString("CEditorHoverConfigurationBlock.annotationRollover"); //$NON-NLS-1$
+               //addCheckBox(hoverComposite, rollOverLabel, PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER, 0); //$NON-NLS-1$
+
+               //addFiller(hoverComposite);
+
+               Label label= new Label(hoverComposite, SWT.NONE);
+               label.setText(PreferencesMessages.CEditorHoverConfigurationBlock_hoverPreferences); 
+               GridData gd= new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalAlignment= GridData.BEGINNING;
+               gd.horizontalSpan= 2;
+               label.setLayoutData(gd);
+
+               TableLayoutComposite layouter= new TableLayoutComposite(hoverComposite, SWT.NONE);
+               addColumnLayoutData(layouter);
+
+               // Hover table
+               fHoverTable= new Table(layouter, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION | SWT.CHECK);
+               fHoverTable.setHeaderVisible(true);
+               fHoverTable.setLinesVisible(true);
+
+               gd= new GridData(GridData.FILL_HORIZONTAL);
+               gd.heightHint= SWTUtil.getTableHeightHint(fHoverTable, 10);
+               gd.horizontalSpan= 2;
+               gd.widthHint= new PixelConverter(parent).convertWidthInCharsToPixels(30);
+               layouter.setLayoutData(gd);
+
+               fHoverTable.addSelectionListener(new SelectionListener() {
+                       public void widgetSelected(SelectionEvent e) {
+                               handleHoverListSelection();
+                       }
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                       }
+               });
+
+               TableLayout tableLayout= new TableLayout();
+               fHoverTable.setLayout(tableLayout);
+
+               fNameColumn= new TableColumn(fHoverTable, SWT.NONE);
+               fNameColumn.setText(PreferencesMessages.CEditorHoverConfigurationBlock_nameColumnTitle); 
+               fNameColumn.setResizable(true);
+
+               fModifierColumn= new TableColumn(fHoverTable, SWT.NONE);
+               fModifierColumn.setText(PreferencesMessages.CEditorHoverConfigurationBlock_modifierColumnTitle); 
+               fModifierColumn.setResizable(true);
+
+               fHoverTableViewer= new CheckboxTableViewer(fHoverTable);
+               fHoverTableViewer.setUseHashlookup(true);
+               fHoverTableViewer.setContentProvider(new CEditorTextHoverDescriptorContentProvider());
+               fHoverTableViewer.setLabelProvider(new CEditorTextHoverDescriptorLabelProvider());
+               
+               ((CheckboxTableViewer)fHoverTableViewer).addCheckStateListener(new ICheckStateListener() {
+                       /*
+                        * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent)
+                        */
+                       public void checkStateChanged(CheckStateChangedEvent event) {
+                               String id= ((CEditorTextHoverDescriptor)event.getElement()).getId();
+                               if (id == null)
+                                       return;
+                               CEditorTextHoverDescriptor[] descriptors= getContributedHovers();
+                               HoverConfig hoverConfig = null;
+                               int i= 0, length= fHoverConfigs.length;
+                               while (i < length) {
+                                       if (id.equals(descriptors[i].getId())) {
+                                               hoverConfig = fHoverConfigs[i];
+                                               hoverConfig.fIsEnabled= event.getChecked();
+                                               fModifierEditor.setEnabled(event.getChecked());
+                                               break;
+                                       }
+                                       i++;
+                               }
+                               updateStatus(hoverConfig);
+                       }
+               });
+               
+               // Text field for modifier string
+               label= new Label(hoverComposite, SWT.LEFT);
+               label.setText(PreferencesMessages.CEditorHoverConfigurationBlock_keyModifier); 
+               fModifierEditor= new Text(hoverComposite, SWT.BORDER);
+               gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               fModifierEditor.setLayoutData(gd);
+
+               fModifierEditor.addKeyListener(new KeyListener() {
+                       private boolean isModifierCandidate;
+                       public void keyPressed(KeyEvent e) {
+                               isModifierCandidate= e.keyCode > 0 && e.character == 0 && e.stateMask == 0;
+                       }
+               
+                       public void keyReleased(KeyEvent e) {
+                               if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask && e.character == 0) {// && e.time -time < 1000) {
+                                       String text= fModifierEditor.getText();
+                                       Point selection= fModifierEditor.getSelection();
+                                       int i= selection.x - 1;
+                                       while (i > -1 && Character.isWhitespace(text.charAt(i))) {
+                                               i--;
+                                       }
+                                       boolean needsPrefixDelimiter= i > -1 && !String.valueOf(text.charAt(i)).equals(DELIMITER);
+
+                                       i= selection.y;
+                                       while (i < text.length() && Character.isWhitespace(text.charAt(i))) {
+                                               i++;
+                                       }
+                                       boolean needsPostfixDelimiter= i < text.length() && !String.valueOf(text.charAt(i)).equals(DELIMITER);
+
+                                       String insertString;
+
+                                       if (needsPrefixDelimiter && needsPostfixDelimiter)
+                                               insertString= NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_insertDelimiterAndModifierAndDelimiter, new String[] {Action.findModifierString(e.stateMask)}); 
+                                       else if (needsPrefixDelimiter)
+                                               insertString= NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_insertDelimiterAndModifier, new String[] {Action.findModifierString(e.stateMask)}); 
+                                       else if (needsPostfixDelimiter)
+                                               insertString= NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_insertModifierAndDelimiter, new String[] {Action.findModifierString(e.stateMask)}); 
+                                       else
+                                               insertString= Action.findModifierString(e.stateMask);
+
+                                       if (insertString != null)
+                                               fModifierEditor.insert(insertString);
+                               }
+                       }
+               });
+
+               fModifierEditor.addModifyListener(new ModifyListener() {
+                       public void modifyText(ModifyEvent e) {
+                               handleModifierModified();
+                       }
+               });
+
+               // Description
+               Label descriptionLabel= new Label(hoverComposite, SWT.LEFT);
+               descriptionLabel.setText(PreferencesMessages.CEditorHoverConfigurationBlock_description); 
+               gd= new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
+               gd.horizontalSpan= 2;
+               descriptionLabel.setLayoutData(gd);
+               fDescription= new Text(hoverComposite, SWT.LEFT | SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.BORDER);
+               gd= new GridData(GridData.FILL_BOTH);
+               gd.horizontalSpan= 2;
+               fDescription.setLayoutData(gd);
+
+               initialize();
+
+               scrolled.setContent(hoverComposite);
+               final Point size= hoverComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+               scrolled.setMinSize(size.x, size.y);
+
+               Dialog.applyDialogFont(scrolled);
+               
+               return scrolled;
+       }
+       
+       private void addColumnLayoutData(TableLayoutComposite layouter) {
+               layouter.addColumnData(new ColumnWeightData(40, true));
+               layouter.addColumnData(new ColumnWeightData(60, true));
+       }
+
+       CEditorTextHoverDescriptor[] getContributedHovers() {
+               return CUIPlugin.getDefault().getCEditorTextHoverDescriptors();
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#initialize()
+        */
+       public void initialize() {
+               CEditorTextHoverDescriptor[] hoverDescs= getContributedHovers();
+               fHoverConfigs= new HoverConfig[hoverDescs.length];
+               for (int i= 0; i < hoverDescs.length; i++)
+                       fHoverConfigs[i]= new HoverConfig(hoverDescs[i].getModifierString(), hoverDescs[i].getStateMask(), hoverDescs[i].isEnabled());
+
+               fHoverTableViewer.setInput(hoverDescs);
+               
+               initializeFields();
+       }
+
+       void initializeFields() {
+               fModifierEditor.setEnabled(false);
+               
+               CEditorTextHoverDescriptor[] hoverDescs= getContributedHovers();
+               for (int i= 0; i < hoverDescs.length; i++)
+                       fHoverTable.getItem(i).setChecked(hoverDescs[i].isEnabled());
+               fHoverTableViewer.refresh();
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#performOk()
+        */
+       public void performOk() {
+               StringBuffer buf= new StringBuffer();
+               StringBuffer maskBuf= new StringBuffer();
+               for (int i= 0; i < fHoverConfigs.length; i++) {
+                       buf.append(getContributedHovers()[i].getId());
+                       buf.append(CEditorTextHoverDescriptor.VALUE_SEPARATOR);
+                       if (!fHoverConfigs[i].fIsEnabled)
+                               buf.append(CEditorTextHoverDescriptor.DISABLED_TAG);
+                       String modifier= fHoverConfigs[i].fModifierString;
+                       if (modifier == null || modifier.length() == 0)
+                               modifier= CEditorTextHoverDescriptor.NO_MODIFIER;
+                       buf.append(modifier);
+                       buf.append(CEditorTextHoverDescriptor.VALUE_SEPARATOR);
+                       
+                       maskBuf.append(getContributedHovers()[i].getId());
+                       maskBuf.append(CEditorTextHoverDescriptor.VALUE_SEPARATOR);
+                       maskBuf.append(fHoverConfigs[i].fStateMask);
+                       maskBuf.append(CEditorTextHoverDescriptor.VALUE_SEPARATOR);
+               }
+               fStore.setValue(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS, buf.toString());
+               fStore.setValue(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS, maskBuf.toString());
+               
+               CUIPlugin.getDefault().resetCEditorTextHoverDescriptors();
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#performDefaults()
+        */
+       public void performDefaults() {
+               restoreFromPreferences();
+               initializeFields();
+               updateStatus(null);
+       }
+
+       private void restoreFromPreferences() {
+               String compiledTextHoverModifiers= fStore.getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS);
+               
+               StringTokenizer tokenizer= new StringTokenizer(compiledTextHoverModifiers, CEditorTextHoverDescriptor.VALUE_SEPARATOR);
+               HashMap<String, String> idToModifier= new HashMap<String, String>(tokenizer.countTokens() / 2);
+
+               while (tokenizer.hasMoreTokens()) {
+                       String id= tokenizer.nextToken();
+                       if (tokenizer.hasMoreTokens())
+                               idToModifier.put(id, tokenizer.nextToken());
+               }
+
+               String compiledTextHoverModifierMasks= CUIPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS);
+
+               tokenizer= new StringTokenizer(compiledTextHoverModifierMasks, CEditorTextHoverDescriptor.VALUE_SEPARATOR);
+               HashMap<String, String> idToModifierMask= new HashMap<String, String>(tokenizer.countTokens() / 2);
+
+               while (tokenizer.hasMoreTokens()) {
+                       String id= tokenizer.nextToken();
+                       if (tokenizer.hasMoreTokens())
+                               idToModifierMask.put(id, tokenizer.nextToken());
+               }
+
+               for (int i= 0; i < fHoverConfigs.length; i++) {
+                       String modifierString= idToModifier.get(getContributedHovers()[i].getId());
+                       boolean enabled= true;
+                       if (modifierString == null)
+                               modifierString= CEditorTextHoverDescriptor.DISABLED_TAG;
+                       
+                       if (modifierString.startsWith(CEditorTextHoverDescriptor.DISABLED_TAG)) {
+                               enabled= false;
+                               modifierString= modifierString.substring(1);
+                       }
+
+                       if (modifierString.equals(CEditorTextHoverDescriptor.NO_MODIFIER))
+                               modifierString= ""; //$NON-NLS-1$
+
+                       fHoverConfigs[i].fModifierString= modifierString;
+                       fHoverConfigs[i].fIsEnabled= enabled;
+                       fHoverConfigs[i].fStateMask= CEditorTextHoverDescriptor.computeStateMask(modifierString);
+
+                       if (fHoverConfigs[i].fStateMask == -1) {
+                               try {
+                                       fHoverConfigs[i].fStateMask= Integer.parseInt(idToModifierMask.get(getContributedHovers()[i].getId()));
+                               } catch (NumberFormatException ex) {
+                                       fHoverConfigs[i].fStateMask= -1;
+                               }
+                       }
+               }
+       }
+
+       void handleModifierModified() {
+               int i= fHoverTable.getSelectionIndex();
+               String modifiers= fModifierEditor.getText();
+               fHoverConfigs[i].fModifierString= modifiers;
+               fHoverConfigs[i].fStateMask= CEditorTextHoverDescriptor.computeStateMask(modifiers);
+               if (fHoverConfigs[i].fIsEnabled && fHoverConfigs[i].fStateMask == -1)
+                       fStatus= new StatusInfo(IStatus.ERROR, NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_modifierIsNotValid, fHoverConfigs[i].fModifierString)); 
+               else
+                       fStatus= new StatusInfo();
+               
+               // update table
+               fHoverTableViewer.refresh(getContributedHovers()[i]);
+               
+               updateStatus(fHoverConfigs[i]);
+       }
+
+       void handleHoverListSelection() {       
+               int i= fHoverTable.getSelectionIndex();
+               
+               if (i < 0) {
+                       if (fHoverTable.getSelectionCount() == 0)
+                               fModifierEditor.setEnabled(false);
+                       return;
+               }
+               
+               boolean enabled= fHoverConfigs[i].fIsEnabled;
+               fModifierEditor.setEnabled(enabled);
+               fModifierEditor.setText(fHoverConfigs[i].fModifierString);
+               String description= getContributedHovers()[i].getDescription();
+               if (description == null)
+                       description= ""; //$NON-NLS-1$
+               fDescription.setText(description);
+       }
+
+       IStatus getStatus() {
+               if (fStatus == null)
+                       fStatus= new StatusInfo();
+               return fStatus;
+       }
+
+       void updateStatus(HoverConfig hoverConfig) {
+               if (hoverConfig != null && hoverConfig.fIsEnabled && hoverConfig.fStateMask == -1)
+                       fStatus= new StatusInfo(IStatus.ERROR, NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_modifierIsNotValid, hoverConfig.fModifierString)); 
+               else
+                       fStatus= new StatusInfo();
+
+               int i= 0;
+               HashMap<Integer, String> stateMasks= new HashMap<Integer, String>(fHoverConfigs.length);
+               while (fStatus.isOK() && i < fHoverConfigs.length) {
+                       if (fHoverConfigs[i].fIsEnabled) {
+                               String label= getContributedHovers()[i].getLabel();
+                               Integer stateMask= new Integer(fHoverConfigs[i].fStateMask);
+                               if (fHoverConfigs[i].fStateMask == -1)
+                                       fStatus= new StatusInfo(IStatus.ERROR, NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_modifierIsNotValidForHover, new String[] {fHoverConfigs[i].fModifierString, label})); 
+                               else if (stateMasks.containsKey(stateMask))
+                                       fStatus= new StatusInfo(IStatus.ERROR, NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_duplicateModifier, new String[] {label, stateMasks.get(stateMask)})); 
+                               else
+                                       stateMasks.put(stateMask, label);
+                       }
+                       i++;
+               }
+
+               fMainPreferencePage.setValid(fStatus.isOK());
+               StatusUtil.applyToStatusLine(fMainPreferencePage, fStatus);
+       }
+       
+       
+//     private void addFiller(Composite composite) {
+//             PixelConverter pixelConverter= new PixelConverter(composite);
+//             Label filler= new Label(composite, SWT.LEFT );
+//             GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+//             gd.horizontalSpan= 2;
+//             gd.heightHint= pixelConverter.convertHeightInCharsToPixels(1) / 2;
+//             filler.setLayoutData(gd);
+//     }
+       
+       /*
+        * @see DialogPage#dispose()
+        */
+       public void dispose() {
+               // nothing to dispose
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverPreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverPreferencePage.java
new file mode 100644 (file)
index 0000000..a445465
--- /dev/null
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+
+/**
+ * The page for setting the editor hover options.
+ */
+public final class CEditorHoverPreferencePage extends AbstractConfigurationBlockPreferencePage {
+       
+       /*
+        * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#getHelpId()
+        */
+       @Override
+       protected String getHelpId() {
+               return ICHelpContextIds.C_EDITOR_HOVERS_PAGE;
+       }
+
+       /*
+        * @see org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setDescription()
+        */
+       @Override
+       protected void setDescription() {
+               String description= PreferencesMessages.CEditorPreferencePage_hover_title; 
+               setDescription(description);
+       }
+       
+       /*
+        * @see org.org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setPreferenceStore()
+        */
+       @Override
+       protected void setPreferenceStore() {
+               setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
+       }
+       
+       
+       @Override
+       protected Label createDescriptionLabel(Composite parent) {
+               return null; // no description for new look.
+       }
+
+       /*
+        * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#createConfigurationBlock(org.eclipse.ui.internal.editors.text.OverlayPreferenceStore)
+        */
+       @Override
+       protected IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore) {
+               return new CEditorHoverConfigurationBlock(this, overlayPreferenceStore);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java
new file mode 100644 (file)
index 0000000..104a1c6
--- /dev/null
@@ -0,0 +1,346 @@
+/*******************************************************************************
+ *  Copyright (c) 2005, 2010 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *     Andrew Ferguson (Symbian)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.util.ArrayList;
+
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.preference.ColorSelector;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.dialogs.DocCommentOwnerComposite;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey;
+import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
+import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
+
+/*
+ * The page for setting the editor options.
+ */
+public class CEditorPreferencePage extends AbstractPreferencePage {
+
+       protected final String[][] fAppearanceColorListModel = new String[][] {
+                       {PreferencesMessages.CEditorPreferencePage_behaviorPage_matchingBracketColor, CEditor.MATCHING_BRACKETS_COLOR, null },
+                       {PreferencesMessages.CEditorPreferencePage_behaviorPage_inactiveCodeColor, CEditor.INACTIVE_CODE_COLOR, null },
+                       {PreferencesMessages.CEditorPreferencePage_ContentAssistPage_completionProposalBackgroundColor, ContentAssistPreference.PROPOSALS_BACKGROUND, null },
+                       {PreferencesMessages.CEditorPreferencePage_ContentAssistPage_completionProposalForegroundColor, ContentAssistPreference.PROPOSALS_FOREGROUND, null },
+                       {PreferencesMessages.CEditorPreferencePage_ContentAssistPage_parameterBackgroundColor, ContentAssistPreference.PARAMETERS_BACKGROUND, null },
+                       {PreferencesMessages.CEditorPreferencePage_ContentAssistPage_parameterForegroundColor, ContentAssistPreference.PARAMETERS_FOREGROUND, null },
+                       {PreferencesMessages.CEditorPreferencePage_sourceHoverBackgroundColor, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT},
+       };
+
+       private List fAppearanceColorList;
+       private ColorSelector fAppearanceColorEditor;
+       private Button fAppearanceColorDefault;
+       private DocCommentOwnerComposite fDocCommentOwnerComposite;
+       
+       public CEditorPreferencePage() {
+               super();
+       }
+
+       @Override
+       protected OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
+               ArrayList<OverlayKey> overlayKeys = new ArrayList<OverlayKey>();
+
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.SUB_WORD_NAVIGATION));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_EVALUATE_TEMPORARY_PROBLEMS));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CEditor.MATCHING_BRACKETS_COLOR));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.MATCHING_BRACKETS));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CEditor.INACTIVE_CODE_COLOR));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.INACTIVE_CODE_ENABLE));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PROPOSALS_BACKGROUND));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PROPOSALS_FOREGROUND));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PARAMETERS_BACKGROUND));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PARAMETERS_FOREGROUND));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT));
+
+        OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
+               overlayKeys.toArray(keys);
+               return keys;
+       }
+
+       public static void initDefaults(IPreferenceStore store) {
+               store.setDefault(CEditor.SUB_WORD_NAVIGATION, true);
+
+               store.setDefault(CEditor.MATCHING_BRACKETS, true);
+               PreferenceConverter.setDefault(store, CEditor.MATCHING_BRACKETS_COLOR, new RGB(170,170,170));
+
+               store.setDefault(CEditor.INACTIVE_CODE_ENABLE, true);
+               PreferenceConverter.setDefault(store, CEditor.INACTIVE_CODE_COLOR, new RGB(224, 224, 224));
+       }
+
+       /*
+        * @see PreferencePage#createControl(Composite)
+        */
+       @Override
+       public void createControl(Composite parent) {
+               super.createControl(parent);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.C_EDITOR_PREF_PAGE);
+       }
+
+       // sets enabled flag for a control and all its sub-tree
+       protected static void setEnabled(Control control, boolean enable) {
+               control.setEnabled(enable);
+               if (control instanceof Composite) {
+                       Composite composite = (Composite) control;
+                       Control[] children = composite.getChildren();
+                       for (Control element : children)
+                               setEnabled(element, enable);
+               }
+       }
+
+       private Control createBehaviorBlock(Composite parent) {
+               Composite behaviorComposite= ControlFactory.createGroup(parent, PreferencesMessages.CEditorPreferencePage_GeneralAppearanceGroupTitle, 1);
+               
+               GridLayout layout = new GridLayout();
+               layout.numColumns = 2;
+               behaviorComposite.setLayout(layout);
+
+               String label= PreferencesMessages.CEditorPreferencePage_behaviorPage_subWordNavigation;
+               addCheckBox(behaviorComposite, label, CEditor.SUB_WORD_NAVIGATION, 0);
+
+               label = PreferencesMessages.CEditorPreferencePage_behaviourPage_EnableEditorProblemAnnotation; 
+               addCheckBox(behaviorComposite, label, PreferenceConstants.EDITOR_EVALUATE_TEMPORARY_PROBLEMS, 0);
+
+               label = PreferencesMessages.CEditorPreferencePage_behaviorPage_matchingBrackets;
+               addCheckBox(behaviorComposite, label, CEditor.MATCHING_BRACKETS, 0);
+
+               label = PreferencesMessages.CEditorPreferencePage_behaviorPage_inactiveCode;
+               addCheckBox(behaviorComposite, label, CEditor.INACTIVE_CODE_ENABLE, 0);
+
+               Label l = new Label(behaviorComposite, SWT.LEFT);
+               GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               gd.horizontalSpan = 2;
+               gd.heightHint = convertHeightInCharsToPixels(1) / 2;
+               l.setLayoutData(gd);
+
+               l = new Label(behaviorComposite, SWT.LEFT);
+               l.setText(PreferencesMessages.CEditorPreferencePage_behaviorPage_appearanceColorOptions);
+               gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               gd.horizontalSpan = 2;
+               l.setLayoutData(gd);
+
+               Composite editorComposite = new Composite(behaviorComposite, SWT.NONE);
+               layout = new GridLayout();
+               layout.numColumns = 2;
+               layout.marginHeight = 0;
+               layout.marginWidth = 0;
+               editorComposite.setLayout(layout);
+               gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
+               gd.horizontalSpan = 2;
+               editorComposite.setLayoutData(gd);
+
+               fAppearanceColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
+               gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
+               gd.heightHint = convertHeightInCharsToPixels(8);
+               fAppearanceColorList.setLayoutData(gd);
+
+               Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
+               layout = new GridLayout();
+               layout.marginHeight = 0;
+               layout.marginWidth = 0;
+               layout.numColumns = 2;
+               stylesComposite.setLayout(layout);
+               stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+               l = new Label(stylesComposite, SWT.LEFT);
+               l.setText(PreferencesMessages.CEditorPreferencePage_behaviorPage_Color);
+               gd = new GridData();
+               gd.horizontalAlignment = GridData.BEGINNING;
+               l.setLayoutData(gd);
+
+               fAppearanceColorEditor = new ColorSelector(stylesComposite);
+               Button foregroundColorButton = fAppearanceColorEditor.getButton();
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalAlignment = GridData.BEGINNING;
+               foregroundColorButton.setLayoutData(gd);
+
+               SelectionListener colorDefaultSelectionListener= new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               boolean systemDefault= fAppearanceColorDefault.getSelection();
+                               fAppearanceColorEditor.getButton().setEnabled(!systemDefault);
+
+                               int i= fAppearanceColorList.getSelectionIndex();
+                               String key= fAppearanceColorListModel[i][2];
+                               if (key != null)
+                                       fOverlayStore.setValue(key, systemDefault);
+                       }
+               };
+
+               fAppearanceColorDefault= new Button(stylesComposite, SWT.CHECK);
+               fAppearanceColorDefault.setText(PreferencesMessages.CEditorPreferencePage_colorPage_systemDefault);
+               gd= new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalAlignment= GridData.BEGINNING;
+               gd.horizontalSpan= 2;
+               fAppearanceColorDefault.setLayoutData(gd);
+               fAppearanceColorDefault.setVisible(false);
+               fAppearanceColorDefault.addSelectionListener(colorDefaultSelectionListener);
+
+               fAppearanceColorList.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               handleAppearanceColorListSelection();
+                       }
+               });
+               foregroundColorButton.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               int i = fAppearanceColorList.getSelectionIndex();
+                               String key = fAppearanceColorListModel[i][1];
+
+                               PreferenceConverter.setValue(fOverlayStore, key, fAppearanceColorEditor.getColorValue());
+                       }
+               });
+               return behaviorComposite;
+       }
+
+       private void handleAppearanceColorListSelection() {
+               int i = fAppearanceColorList.getSelectionIndex();
+               String key = fAppearanceColorListModel[i][1];
+               RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
+               fAppearanceColorEditor.setColorValue(rgb);
+               updateAppearanceColorWidgets(fAppearanceColorListModel[i][2]);
+       }
+
+       private void updateAppearanceColorWidgets(String systemDefaultKey) {
+               if (systemDefaultKey == null) {
+                       fAppearanceColorDefault.setSelection(false);
+                       fAppearanceColorDefault.setVisible(false);
+                       fAppearanceColorEditor.getButton().setEnabled(true);
+               } else {
+                       boolean systemDefault= fOverlayStore.getBoolean(systemDefaultKey);
+                       fAppearanceColorDefault.setSelection(systemDefault);
+                       fAppearanceColorDefault.setVisible(true);
+                       fAppearanceColorEditor.getButton().setEnabled(!systemDefault);
+               }
+       }
+
+       private Control createHeader(Composite parent) {
+               String text = PreferencesMessages.CEditorPreferencePage_link;
+               Link link = new Link(parent, SWT.NONE);
+               link.setText(text);
+               link.addListener (SWT.Selection, new Listener () {
+                       public void handleEvent(Event event) {
+                               String u = event.text;
+                               PreferencesUtil.createPreferenceDialogOn(getShell(), u, null, null);
+                       }
+               });
+               // TODO replace by link-specific tooltips when
+               // bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=88866 gets fixed
+               link.setToolTipText(PreferencesMessages.CEditorPreferencePage_link_tooltip);
+
+               GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
+               gridData.widthHint= 150; // only expand further if anyone else requires it
+               link.setLayoutData(gridData);
+               return link;
+       }
+
+       /*
+        * @see PreferencePage#createContents(Composite)
+        */
+       @Override
+       protected Control createContents(Composite parent) {
+               fOverlayStore.load();
+               fOverlayStore.start();
+
+               Composite contents= ControlFactory.createComposite(parent, 1);
+               contents.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+               createHeader(contents);
+
+               ControlFactory.createEmptySpace(contents, 2);
+               createBehaviorBlock(contents);
+
+               ControlFactory.createEmptySpace(contents, 2);
+               
+               String dsc= PreferencesMessages.CEditorPreferencePage_SelectDocToolDescription;
+               String msg= PreferencesMessages.CEditorPreferencePage_WorkspaceDefaultLabel;
+               IDocCommentOwner workspaceOwner= DocCommentOwnerManager.getInstance().getWorkspaceCommentOwner();
+               fDocCommentOwnerComposite= new DocCommentOwnerComposite(contents, workspaceOwner, dsc, msg);
+               fDocCommentOwnerComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
+               
+               initialize();
+
+               return contents;
+       }
+
+       private void initialize() {
+               initializeFields();
+               initializeDefaultColors();
+
+               for (String[] element : fAppearanceColorListModel) {
+                       fAppearanceColorList.add(element[0]);
+               }
+               fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
+                       public void run() {
+                               fAppearanceColorList.select(0);
+                               handleAppearanceColorListSelection();
+                       }
+               });
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.AbstractPreferencePage#performOk()
+        */
+       @Override
+       public boolean performOk() {
+               DocCommentOwnerManager.getInstance().setWorkspaceCommentOwner(fDocCommentOwnerComposite.getSelectedDocCommentOwner());
+               return super.performOk();
+       }
+
+       /**
+        * Initializes the default colors.
+        */
+       private void initializeDefaultColors() {
+               if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT)) {
+                       RGB rgb= fAppearanceColorList.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB();
+                       PreferenceConverter.setValue(getPreferenceStore(), PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR, rgb);
+               }
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.AbstractPreferencePage#performDefaults()
+        */
+       @Override
+       protected void performDefaults() {
+               super.performDefaults();
+               initializeDefaultColors();
+               handleAppearanceColorListSelection();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypeAssociation.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypeAssociation.java
new file mode 100644 (file)
index 0000000..767418c
--- /dev/null
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 QNX Software System and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software System - Initial implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences;
+
+import org.eclipse.core.runtime.content.IContentType;
+
+public class CFileTypeAssociation {
+
+       public CFileTypeAssociation(String spec, int type, IContentType contentType) {
+               super();
+               fSpec = spec;
+               fType = type;
+               fContentType = contentType;
+       }
+
+       private String fSpec;
+       private int fType;
+       private IContentType fContentType;
+
+       @Override
+       public int hashCode() {
+               final int PRIME = 31;
+               int result = 1;
+               result = PRIME * result + ((fContentType == null) ? 0 : fContentType.getId().hashCode());
+               result = PRIME * result + ((fSpec == null) ? 0 : fSpec.hashCode());
+               result = PRIME * result + fType;
+               return result;
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj)
+                       return true;
+               if (obj == null)
+                       return false;
+               if (getClass() != obj.getClass())
+                       return false;
+               final CFileTypeAssociation other = (CFileTypeAssociation) obj;
+               if (!fContentType.getId().equals(other.fContentType.getId())) {
+                       return false;
+               }
+               if (!fSpec.equals(other.fSpec)) {
+                       return false;
+               }
+               if (fType != other.fType) {
+                       return false;
+               }
+               return true;
+       }
+
+       public boolean equalsIgnoreCaseOfSpec(CFileTypeAssociation other) {
+               if (!fContentType.getId().equals(other.fContentType.getId())) {
+                       return false;
+               }
+               if (!fSpec.equalsIgnoreCase(other.fSpec)) {
+                       return false;
+               }
+               if (fType != other.fType) {
+                       return false;
+               }
+               return true;
+       }
+
+
+       /**
+        * @return Returns the fSettings.
+        */
+       public IContentType getContentType() {
+               return fContentType;
+       }
+
+       /**
+        * @return Returns the fSpec.
+        */
+       public String getSpec() {
+               return fSpec;
+       }
+
+       public String getPattern() {
+               String pattern = getSpec();
+               if (isExtSpec()) {
+                       return "*." + pattern; //$NON-NLS-1$
+               }
+               return pattern;
+               
+       }
+
+       public boolean isFileSpec() {
+               return (fType & IContentType.FILE_NAME_SPEC) != 0;
+       }
+
+       public boolean isExtSpec() {
+               return (fType & IContentType.FILE_EXTENSION_SPEC) != 0;
+       }
+
+       public boolean isPredefined() {
+               return (fType & IContentType.IGNORE_USER_DEFINED) != 0;
+       }
+
+       public boolean isUserDefined() {
+               return (fType & IContentType.IGNORE_PRE_DEFINED) != 0;
+       }
+
+       /**
+        * @return Returns the description.
+        */
+       public String getDescription() {
+               return fContentType.getName();
+       }
+
+       /**
+        * Returns {@link IContentType#FILE_NAME_SPEC} or {@link IContentType#FILE_EXTENSION_SPEC}.
+        */
+       public int getFileSpecType() {
+               return fType & (IContentType.FILE_NAME_SPEC | IContentType.FILE_EXTENSION_SPEC);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypeDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypeDialog.java
new file mode 100644 (file)
index 0000000..7517042
--- /dev/null
@@ -0,0 +1,174 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 TimeSys Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     TimeSys Corporation - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.core.runtime.content.IContentTypeManager;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.core.model.CoreModel;
+
+public class CFileTypeDialog extends Dialog {
+       
+       public CFileTypeDialog(Shell parentShell) {
+               super(parentShell);
+       }
+
+       private Text            fTextPattern;
+       private Combo           fComboType;
+
+       private String          fPattern;
+       private IContentType fType;
+       
+       @Override
+       protected void configureShell(Shell newShell) {
+               super.configureShell(newShell);
+               newShell.setText(PreferencesMessages.CFileTypeDialog_title); 
+       }
+
+       @Override
+       protected void createButtonsForButtonBar(Composite parent) {
+               createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+               createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+
+               getOkayButton().setEnabled(getPatternFromControl().length() > 0);
+       }
+
+       @Override
+       protected Control createDialogArea(Composite parent) {
+               Composite composite = (Composite) super.createDialogArea(parent);
+               ((GridLayout) composite.getLayout()).numColumns = 2;
+
+               // Pattern row
+               
+               Label pattern = new Label(composite, SWT.NONE);
+                               
+               pattern.setText(PreferencesMessages.CFileTypeDialog_patternLabel); 
+
+               fTextPattern = new Text(composite, SWT.BORDER | SWT.SINGLE);
+               
+               fTextPattern.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               
+               if (null != fPattern) {
+                       fTextPattern.setText(fPattern);
+               }
+
+               fTextPattern.addModifyListener(new ModifyListener() {
+                       public void modifyText(ModifyEvent e) {
+                               getOkayButton().setEnabled(getPatternFromControl().length() > 0);
+                       }
+               });
+               
+               // Type row
+               
+               Label type = new Label(composite, SWT.NONE);
+               
+               type.setText(PreferencesMessages.CFileTypeDialog_typeLabel); 
+               
+               fComboType = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.SINGLE);
+
+               fComboType.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+               populateTypesCombo();
+               
+               return composite;
+       }
+
+       public void setPattern(String pattern) {
+               fPattern = pattern;
+       }
+
+       public String getPattern() {
+               return fPattern;
+       }
+       
+       public IContentType getContentType() {
+               return fType;
+       }
+
+       private void populateTypesCombo() {
+               IContentTypeManager manager = Platform.getContentTypeManager();
+               String[]        ids = CoreModel.getRegistedContentTypeIds();
+               ArrayList<IContentType> list = new ArrayList<IContentType>(ids.length);
+               for (String id : ids) {
+                       IContentType ctype = manager.getContentType(id);
+                       if (ctype != null) {
+                               list.add(ctype);
+                       }
+               }
+
+               IContentType[] ctypes = new IContentType[list.size()];
+               list.toArray(ctypes);
+               int     index = -1;
+
+               for (IContentType ctype : ctypes) {
+                       fComboType.add(ctype.getName());
+               }
+               
+               fComboType.setData(ctypes);
+
+               if (null != fType) {
+                       index = fComboType.indexOf(fType.getName());
+               }
+
+               fComboType.select((index < 0) ? 0 : index);
+       }
+
+       Button getOkayButton() {
+               return getButton(IDialogConstants.OK_ID);
+       }
+       
+       String getPatternFromControl() {
+               return fTextPattern.getText().trim();
+       }
+       
+       private IContentType getTypeFromControl() {
+               IContentType type       = null;
+               int             index   = fComboType.getSelectionIndex();
+               
+               if (-1 != index) {
+                       String                  name    = fComboType.getItem(index);
+                       IContentType[]  types   = (IContentType[]) fComboType.getData();
+                       for (IContentType type2 : types) {
+                               if (name.equals(type2.getName())) {
+                                       type = type2;
+                               }
+                       }
+               }
+               return type;
+       }
+       
+       @Override
+       protected void okPressed() {
+               fPattern        =       getPatternFromControl();
+               fType           =       getTypeFromControl();
+               
+               super.okPressed();
+       }
+
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java
new file mode 100644 (file)
index 0000000..27409aa
--- /dev/null
@@ -0,0 +1,565 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 TimeSys Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     TimeSys Corporation - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.core.runtime.content.IContentTypeManager;
+import org.eclipse.core.runtime.content.IContentTypeSettings;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+import org.eclipse.cdt.core.model.CoreModel;
+
+import org.eclipse.cdt.internal.ui.util.Messages;
+import org.eclipse.cdt.internal.ui.util.SWTUtil;
+
+/*
+ * Preference block that encapsulates the controls used
+ * for displaying/editing CDT file type associations
+ */
+public class CFileTypesPreferenceBlock {
+
+       private static final int        COL_PATTERN             = 0;
+       private static final int        COL_DESCRIPTION = 1;
+       private static final int        COL_STATUS      = 2;
+       
+       private ArrayList<CFileTypeAssociation> fAddAssoc;
+       private ArrayList<CFileTypeAssociation> fRemoveAssoc;
+       private boolean         fDirty = false;
+       private IProject        fInput;
+       private IContentType[] fContentTypes;
+
+       private TableViewer             fAssocViewer;
+       private Button                          fBtnNew;
+       private Button                          fBtnRemove;
+
+       private class AssocSorter extends ViewerSorter {
+               @Override
+               public int category(Object element) {
+                       if (element instanceof CFileTypeAssociation) {
+                               CFileTypeAssociation assoc = (CFileTypeAssociation) element;
+                               if (assoc.isExtSpec()) {
+                                       return 10;
+                               }
+                               return 20;
+                       }
+                       return 30;
+               }
+       }
+       
+       private class AssocContentProvider implements IStructuredContentProvider {
+               CFileTypeAssociation[] assocs;
+               
+               public Object[] getElements(Object inputElement) {
+                       return assocs;
+               }
+
+               public void dispose() {
+                       assocs = null;
+               }
+
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+                       if (newInput instanceof CFileTypeAssociation[]) {       
+                               assocs = (CFileTypeAssociation[]) newInput;
+                       }
+               }
+       }
+       
+       private class AssocLabelProvider implements ILabelProvider, ITableLabelProvider {
+               private ListenerList listeners = new ListenerList();
+               
+               public Image getColumnImage(Object element, int columnIndex) {
+                       if (element instanceof CFileTypeAssociation) {
+                               if (COL_PATTERN == columnIndex) {
+                                       return null;
+                               }
+                       }
+                       return null;
+               }
+
+               public String getColumnText(Object element, int columnIndex) {
+                       if (element instanceof CFileTypeAssociation) {
+                               CFileTypeAssociation assoc = (CFileTypeAssociation) element;
+                               switch (columnIndex) {
+                                       case COL_PATTERN:
+                                               return assoc.getPattern();
+                                       
+                                       case COL_DESCRIPTION:
+                                               return assoc.getDescription();
+                                               
+                                       case COL_STATUS:
+                                               if (assoc.isUserDefined()) {
+                                                       return PreferencesMessages.CFileTypesPreferencePage_userDefined; 
+                                               } else if (assoc.isPredefined()) {
+                                                       return PreferencesMessages.CFileTypesPreferencePage_preDefined; 
+                                               }
+                                               return new String();
+                               }
+                       }
+                       return element.toString();
+               }
+
+               public void addListener(ILabelProviderListener listener) {
+                       listeners.add(listener);
+               }
+
+               public void dispose() {
+                       listeners.clear();
+                       listeners = null;
+               }
+
+               public boolean isLabelProperty(Object element, String property) {
+                       return false;
+               }
+
+               public void removeListener(ILabelProviderListener listener) {
+                       listeners.remove(listener);
+               }
+
+               public Image getImage(Object element) {
+                       return getColumnImage(element, 0);
+               }
+
+               public String getText(Object element) {
+                       return getColumnText(element, 0);
+               }
+
+       }
+
+       public CFileTypesPreferenceBlock() {
+               this(null);
+       }
+
+       public CFileTypesPreferenceBlock(IProject input) {
+               fAddAssoc = new ArrayList<CFileTypeAssociation>();
+               fRemoveAssoc = new ArrayList<CFileTypeAssociation>();
+               fInput = input;
+               setDirty(false);
+       }
+
+       public Control createControl(Composite parent) {
+               Composite       control                 = new Composite(parent, SWT.NONE);
+               GridLayout      controlLayout   = new GridLayout(2, false);
+
+               controlLayout.marginHeight = 0;
+               controlLayout.marginWidth  = 0;
+
+               control.setLayout(controlLayout);
+               control.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL));
+               
+               // Create the table viewer for file associations
+               
+               Composite       tablePane               = new Composite(control, SWT.NONE);
+               GridLayout      tablePaneLayout = new GridLayout();
+               GridData        gridData                = new GridData(GridData.FILL_BOTH);
+               
+               tablePaneLayout.marginHeight = 0;
+               tablePaneLayout.marginWidth  = 0;
+               
+               tablePane.setLayout(tablePaneLayout);
+               tablePane.setLayoutData(gridData);
+
+               Table table = new Table(tablePane, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
+               
+               TableLayout     tblLayout       = new TableLayout();
+               TableColumn     col                     = null;
+               
+               gridData = new GridData(GridData.FILL_BOTH);
+               gridData.grabExcessHorizontalSpace = true;
+               gridData.grabExcessVerticalSpace = true;
+               gridData.heightHint = SWTUtil.getTableHeightHint(table, 25);
+               gridData.widthHint = new PixelConverter(parent).convertWidthInCharsToPixels(60);
+               
+               tblLayout.addColumnData(new ColumnWeightData(20));
+               tblLayout.addColumnData(new ColumnWeightData(60));
+               tblLayout.addColumnData(new ColumnWeightData(20));
+               
+               table.setLayout(tblLayout);
+               table.setLayoutData(gridData);
+               table.setHeaderVisible(true);
+               table.setLinesVisible(true);            
+               
+               col = new TableColumn(table, SWT.LEFT);
+               col.setText(PreferencesMessages.CFileTypesPreferencePage_colTitlePattern); 
+               
+               col = new TableColumn(table, SWT.LEFT);
+               col.setText(PreferencesMessages.CFileTypesPreferencePage_colTitleDescription); 
+               
+               col = new TableColumn(table, SWT.LEFT);
+               col.setText(PreferencesMessages.CFileTypesPreferencePage_colTitleStatus); 
+
+               // Create the button pane
+
+               Composite       buttonPane                      = new Composite(control, SWT.NONE);
+               GridLayout      buttonPaneLayout        = new GridLayout();
+               
+               buttonPaneLayout.marginHeight = 0;
+               buttonPaneLayout.marginWidth  = 0;
+               
+               buttonPane.setLayout(buttonPaneLayout);
+               buttonPane.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+
+               // New button
+               
+               fBtnNew         = new Button(buttonPane, SWT.PUSH);
+               fBtnNew.setText(PreferencesMessages.CFileTypesPreferenceBlock_New___);  
+               
+               gridData        = new GridData(GridData.FILL_HORIZONTAL);
+               gridData.widthHint      = SWTUtil.getButtonWidthHint(fBtnNew);
+               fBtnNew.setLayoutData(gridData);
+               
+               fBtnNew.addListener(SWT.Selection, new Listener() {
+                       public void handleEvent(Event e) {
+                               handleAdd();
+                       }
+               });
+
+               // Remove button
+               
+               fBtnRemove      = new Button(buttonPane, SWT.PUSH);
+               fBtnRemove.setText(PreferencesMessages.CFileTypesPreferenceBlock_Remove);  
+               
+               gridData        = new GridData(GridData.FILL_HORIZONTAL);
+               gridData.widthHint      = SWTUtil.getButtonWidthHint(fBtnRemove);
+               fBtnRemove.setLayoutData(gridData);
+               
+               fBtnRemove.addListener(SWT.Selection, new Listener() {
+                       public void handleEvent(Event e) {
+                               handleRemove();
+                       }
+               });
+
+               // Hook up the viewer
+               
+               fAssocViewer = new TableViewer(table);
+               
+               fAssocViewer.setSorter(new AssocSorter());
+               fAssocViewer.setContentProvider(new AssocContentProvider());
+               fAssocViewer.setLabelProvider(new AssocLabelProvider());
+               fAssocViewer.setInput(getCFileTypeAssociations());
+
+               fAssocViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+                       public void selectionChanged(SelectionChangedEvent event) {
+                               handleSelectionChanged();
+                       }
+               });
+               
+               handleSelectionChanged();
+               
+               return control;
+       }
+
+       public void setEnabled(boolean enabled) {
+               fAssocViewer.getTable().setEnabled(enabled);
+               fBtnNew.setEnabled(enabled);
+               fBtnRemove.setEnabled(enabled);
+               setDirty(enabled);
+       }
+       
+       public void setInput(IProject input) {
+               fAddAssoc.clear();
+               fRemoveAssoc.clear();
+               fInput = input;
+               if (null != fAssocViewer) {
+                       fAssocViewer.setInput(getCFileTypeAssociations());
+               }
+               setDirty(true);
+       }
+
+       private void setDirty(boolean dirty) {
+               fDirty = dirty;
+       }
+       
+       public boolean performOk() {
+               boolean changed = fDirty;
+               
+               if (fDirty) {
+                       CFileTypeAssociation[] add = fAddAssoc.toArray(new CFileTypeAssociation[fAddAssoc.size()]);
+                       CFileTypeAssociation[] rem = fRemoveAssoc.toArray(new CFileTypeAssociation[fRemoveAssoc.size()]);
+                       
+                       changed = add.length > 0 || rem.length > 0;
+                       adjustAssociations(add, rem);
+       
+                       fAddAssoc.clear();
+                       fRemoveAssoc.clear();
+
+                       setDirty(false);
+               }               
+               return changed;
+       }
+       
+       private CFileTypeAssociation[] getCFileTypeAssociations() {
+               ArrayList<CFileTypeAssociation> list = new ArrayList<CFileTypeAssociation>();
+               if (fInput == null) {
+                       fillWithUserDefinedCFileTypeAssociations(list);
+                       fillWithPredefinedCFileTypeAssociations(list);
+               } else {
+                       fillWithProjectCFileTypeAssociations(list, fInput);
+               }
+               CFileTypeAssociation[] assocs = new CFileTypeAssociation[list.size()];
+               list.toArray(assocs);
+               return assocs;
+       }
+
+       protected void adjustAssociations(CFileTypeAssociation[] add, CFileTypeAssociation[] rem) {
+               IScopeContext context = null;
+               if (fInput != null) {
+                       context = new ProjectScope(fInput);
+               }
+               removeAssociations(rem, context);
+               addAssociations(add, context);
+       }
+
+       final protected void addAssociations(CFileTypeAssociation[] add, IScopeContext context) {
+               for (int i = 0; i < add.length; ++i) {
+                       CFileTypeAssociation assoc = add[i];
+                       String spec = assoc.getSpec();
+                       IContentType contentType = assoc.getContentType();
+                       int type = IContentType.FILE_NAME_SPEC;
+                       if (assoc.isExtSpec()) {
+                               type = IContentType.FILE_EXTENSION_SPEC;
+                       }                       
+                       addAssociation(context, contentType, spec, type);
+               }
+       }
+
+       protected void addAssociation(IScopeContext context, IContentType contentType, String spec, int type) {
+               try {
+                       IContentTypeSettings settings = contentType.getSettings(context);
+                       settings.addFileSpec(spec, type);
+               } catch (CoreException e) {
+                       // ignore ??
+               }
+       }
+
+       protected void removeAssociations(CFileTypeAssociation[] rem, IScopeContext context) {
+               for (int i = 0; i < rem.length; ++i) {
+                       CFileTypeAssociation assoc = rem[i];
+                       IContentType contentType = assoc.getContentType();
+                       String spec = assoc.getSpec();
+                       int type = IContentType.FILE_NAME_SPEC;
+                       if (assoc.isExtSpec()) {
+                               type = IContentType.FILE_EXTENSION_SPEC;
+                       }
+                       removeAssociation(context, contentType, spec, type);
+               }
+       }
+
+       protected void removeAssociation(IScopeContext context, IContentType contentType, String spec, int type) {
+               try {
+                       IContentTypeSettings settings = contentType.getSettings(context);
+                       settings.removeFileSpec(spec, type);
+               } catch (CoreException e) {
+                       // ignore ??
+               }
+       }
+
+       public IContentType[] getRegistedContentTypes() {
+               if (fContentTypes == null) {
+                       String [] ids = CoreModel.getRegistedContentTypeIds();
+                       IContentTypeManager manager = Platform.getContentTypeManager();
+                       IContentType [] ctypes = new IContentType[ids.length];
+                       for (int i = 0; i < ids.length; i++) {
+                               ctypes[i] = manager.getContentType(ids[i]);
+                       }
+                       fContentTypes = ctypes;
+               }
+               return fContentTypes;
+       }
+
+       private void fillWithUserDefinedCFileTypeAssociations(ArrayList<CFileTypeAssociation> list) {
+               IContentType[] ctypes = getRegistedContentTypes();
+               fillWithCFileTypeAssociations(ctypes, null, IContentType.IGNORE_PRE_DEFINED | IContentType.FILE_EXTENSION_SPEC, list);
+               fillWithCFileTypeAssociations(ctypes, null, IContentType.IGNORE_PRE_DEFINED | IContentType.FILE_NAME_SPEC, list);
+       }
+
+       private void fillWithPredefinedCFileTypeAssociations(ArrayList<CFileTypeAssociation> list) {
+               IContentType[] ctypes = getRegistedContentTypes();
+               fillWithCFileTypeAssociations(ctypes, null, IContentType.IGNORE_USER_DEFINED | IContentType.FILE_EXTENSION_SPEC, list);
+               fillWithCFileTypeAssociations(ctypes, null, IContentType.IGNORE_USER_DEFINED | IContentType.FILE_NAME_SPEC, list);
+       }
+
+       private void fillWithProjectCFileTypeAssociations(ArrayList<CFileTypeAssociation> list, IProject project) {
+               IContentType[] ctypes = getRegistedContentTypes();
+               IScopeContext context = new ProjectScope(project);
+               fillWithCFileTypeAssociations(ctypes, context, IContentType.IGNORE_PRE_DEFINED | IContentType.FILE_EXTENSION_SPEC, list);
+               fillWithCFileTypeAssociations(ctypes, context, IContentType.IGNORE_PRE_DEFINED | IContentType.FILE_NAME_SPEC, list);
+       }
+
+       private void fillWithCFileTypeAssociations(IContentType[] ctypes, IScopeContext context, int type, ArrayList<CFileTypeAssociation> list) {
+               for (IContentType ctype : ctypes) {
+                       try {
+                               IContentTypeSettings setting = ctype.getSettings(context);
+                               String[] specs = setting.getFileSpecs(type);
+                               for (String spec : specs) {
+                                       CFileTypeAssociation assoc = new CFileTypeAssociation(spec, type, ctype);
+                                       list.add(assoc);
+                               }
+                       } catch (CoreException e) {
+                               // skip over it.
+                       }
+               }
+       }
+
+       private CFileTypeAssociation createAssociation(String pattern, IContentType contentType) {
+               int type = IContentType.FILE_NAME_SPEC;
+               if (pattern.startsWith("*.")) { //$NON-NLS-1$
+                       pattern = pattern.substring(2);
+                       type = IContentType.FILE_EXTENSION_SPEC;
+               }
+               return new CFileTypeAssociation(pattern, type | IContentType.IGNORE_PRE_DEFINED, contentType);
+       }
+
+       protected void handleSelectionChanged() {
+               IStructuredSelection sel = getSelection();
+               if (sel.isEmpty()) {
+                       fBtnRemove.setEnabled(false);
+               } else {
+                       boolean enabled = true;
+                       List<?> elements = sel.toList();
+                       for (Object element : elements) {
+                               CFileTypeAssociation assoc = (CFileTypeAssociation) element;
+                               if (assoc.isPredefined())
+                                       enabled = false;
+                       }
+                       fBtnRemove.setEnabled(enabled);
+               }
+       }
+
+       final protected void handleAdd() {
+               CFileTypeAssociation assoc = null;
+
+               CFileTypeDialog dlg = new CFileTypeDialog(fBtnNew.getParent().getShell());
+               
+               if (Window.OK == dlg.open()) {
+                       assoc = createAssociation(dlg.getPattern(), dlg.getContentType());
+                       if (handleAdd(assoc)) {
+                               fAssocViewer.add(assoc);
+                               setDirty(true);
+                       }
+               }
+       }
+       
+       private boolean handleAdd(CFileTypeAssociation assoc) {
+               // assoc is marked to be added.
+               if (containsIgnoreCaseOfSpec(fAddAssoc, assoc)) {
+                       reportDuplicateAssociation(assoc);
+                       return false;
+               }                       
+               // assoc exists, but is marked to be removed.
+               if (containsIgnoreCaseOfSpec(fRemoveAssoc, assoc)) {
+                       if (!fRemoveAssoc.remove(assoc)) {
+                               fAddAssoc.add(assoc);
+                       }
+                       return true;
+               }
+
+               // analyze current settings
+               IContentTypeSettings settings;
+               if (fInput == null) {
+                       settings= assoc.getContentType();
+               }
+               else {
+                       try {
+                               settings= assoc.getContentType().getSettings(new ProjectScope(fInput));
+                       } catch (CoreException e) {
+                               ErrorDialog.openError(fBtnNew.getParent().getShell(),
+                                               PreferencesMessages.CFileTypesPreferenceBlock_addAssociationError_title, 
+                                               null, e.getStatus());
+                               return false;
+                       }
+               }
+               String newSpec= assoc.getSpec();
+               String[] specs= settings.getFileSpecs(assoc.getFileSpecType());
+               for (String spec : specs) {
+                       if (spec.equalsIgnoreCase(newSpec)) {
+                               reportDuplicateAssociation(assoc);
+                               return false;
+                       }                               
+               }
+               fAddAssoc.add(assoc);
+               return true;
+       }       
+       
+       private boolean containsIgnoreCaseOfSpec(Collection<CFileTypeAssociation> collection, CFileTypeAssociation assoc) {
+               for (CFileTypeAssociation existing : collection) {
+                       if (assoc.equalsIgnoreCaseOfSpec(existing)) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+       private void reportDuplicateAssociation(CFileTypeAssociation assoc) {
+               MessageDialog.openError(fBtnNew.getParent().getShell(),
+                               PreferencesMessages.CFileTypesPreferenceBlock_addAssociationError_title, 
+                               Messages.format(PreferencesMessages.CFileTypesPreferenceBlock_addAssociationErrorMessage,  
+                                               assoc.getPattern(), assoc.getContentType().getName()));
+       }
+
+       final protected void handleRemove() {
+               IStructuredSelection sel = getSelection();
+               if ((null != sel) && (!sel.isEmpty())) {
+                       for (Iterator<?> iter = sel.iterator(); iter.hasNext();) {
+                               CFileTypeAssociation assoc = (CFileTypeAssociation) iter.next();
+                               handleRemove(assoc);
+                               fAssocViewer.remove(assoc);
+                               setDirty(true);
+                       }
+               }
+       }
+
+       private void handleRemove(CFileTypeAssociation assoc) {
+               if (!fAddAssoc.remove(assoc)) {
+                       fRemoveAssoc.add(assoc);
+               }
+       }
+
+       private IStructuredSelection getSelection() {
+               return (IStructuredSelection) fAssocViewer.getSelection();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferencePage.java
new file mode 100644 (file)
index 0000000..0abfcc2
--- /dev/null
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 TimeSys Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     TimeSys Corporation - Initial implementation
+ *     Qnx Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.PlatformUI;
+
+/*
+ * The preference page used for displaying/editing CDT file
+ * type associations for the workspace
+ */
+public class CFileTypesPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+
+       private CFileTypesPreferenceBlock fPrefsBlock;
+
+       public CFileTypesPreferencePage() {
+               setDescription(PreferencesMessages.CFileTypesPreferencePage_description); 
+               noDefaultAndApplyButton();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected Control createContents(Composite parent) {
+               Composite topPane = new Composite(parent, SWT.NONE);
+
+               topPane.setLayout(new GridLayout());
+               topPane.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+               fPrefsBlock = new CFileTypesPreferenceBlock(null);
+
+               PlatformUI.getWorkbench().getHelpSystem().setHelp( topPane, ICHelpContextIds.FILE_TYPES_PREF_PAGE );
+               return fPrefsBlock.createControl(topPane);
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+        */
+       public void init(IWorkbench workbench) {
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
+        */
+       @Override
+       protected void performDefaults() {
+               super.performDefaults();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.preference.IPreferencePage#performOk()
+        */
+       @Override
+       public boolean performOk() {
+               
+               if (fPrefsBlock.performOk()) {
+               }
+               
+               return super.performOk();
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java
new file mode 100644 (file)
index 0000000..9e6714c
--- /dev/null
@@ -0,0 +1,283 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 TimeSys Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     TimeSys Corporation - Initial implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.core.runtime.content.IContentTypeManager;
+import org.eclipse.core.runtime.content.IContentTypeSettings;
+import org.eclipse.core.runtime.content.IContentTypeManager.ContentTypeChangeEvent;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.CoreModel;
+
+import org.eclipse.cdt.internal.core.model.CModelManager;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+
+/*
+ * The preference page used for displaying/editing CDT file
+ * type associations for a project
+ */
+public class CFileTypesPropertyPage extends PropertyPage {
+
+       class FixCFileTypesPreferenceBlock extends CFileTypesPreferenceBlock {
+               ArrayList<ContentTypeChangeEvent> list = new ArrayList<ContentTypeChangeEvent>();
+
+               public FixCFileTypesPreferenceBlock() {
+                       super();
+               }
+
+               public FixCFileTypesPreferenceBlock(IProject input) {
+                       super(input);
+               }
+
+               private IContentTypeManager.ContentTypeChangeEvent newContentTypeChangeEvent(IContentType source, IScopeContext context) {
+                       return new IContentTypeManager.ContentTypeChangeEvent(source, context);
+               }
+
+               @Override
+               public boolean performOk() {
+                       boolean changed = super.performOk();
+                       if (changed) {
+                               int size = list.size();
+                               if (size > 0) {
+                                       IContentTypeManager.ContentTypeChangeEvent[] events = new IContentTypeManager.ContentTypeChangeEvent[size];
+                                       list.toArray(events);
+                                       CModelManager.getDefault().contentTypeChanged(events);
+                               }
+                       }
+                       return changed;
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.cdt.internal.ui.preferences.CFileTypesPreferenceBlock#addAssociation(org.eclipse.core.runtime.preferences.IScopeContext, org.eclipse.core.runtime.content.IContentType, java.lang.String, int)
+                */
+               @Override
+               protected void addAssociation(IScopeContext context, IContentType contentType, String spec, int type) {
+                       super.addAssociation(context, contentType, spec, type);
+                       // accumulate the events
+                       list.add(newContentTypeChangeEvent(contentType, context));
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.cdt.internal.ui.preferences.CFileTypesPreferenceBlock#removeAssociation(org.eclipse.core.runtime.preferences.IScopeContext, org.eclipse.core.runtime.content.IContentType, java.lang.String, int)
+                */
+               @Override
+               protected void removeAssociation(IScopeContext context, IContentType contentType, String spec, int type) {
+                       super.removeAssociation(context, contentType, spec, type);
+                       // accumulate the events
+                       list.add(newContentTypeChangeEvent(contentType, context));
+               }
+               
+       }
+
+       protected Button fUseWorkspace;
+       protected Button fUseProject;
+       protected FixCFileTypesPreferenceBlock fPrefsBlock;
+       
+       public CFileTypesPropertyPage(){
+               super();
+               noDefaultAndApplyButton();
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected Control createContents(Composite parent) {
+               Composite topPane = new Composite(parent, SWT.NONE);
+
+               topPane.setLayout(new GridLayout());
+               topPane.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+               // Workspace radio buttons
+               
+               Composite radioPane = new Composite(topPane, SWT.NONE);
+
+               radioPane.setLayout(new GridLayout());
+               radioPane.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               
+               fUseWorkspace = new Button(radioPane, SWT.RADIO);
+               fUseWorkspace.setText(PreferencesMessages.CFileTypesPropertyPage_useWorkspaceSettings); 
+               fUseWorkspace.addListener(SWT.Selection, new Listener() {
+                       public void handleEvent(Event e) {
+                               if (fUseWorkspace.getSelection()) {
+                                       fPrefsBlock.setInput(null);
+                                       fPrefsBlock.setEnabled(false);
+                               }
+                       }
+               });
+
+               final IProject project = getProject(); 
+               boolean custom = CCorePlugin.usesProjectSpecificContentTypes(project);
+
+               fUseProject = new Button(radioPane, SWT.RADIO);
+               fUseProject.setText(PreferencesMessages.CFileTypesPropertyPage_useProjectSettings); 
+               fUseProject.addListener(SWT.Selection, new Listener() {
+                       public void handleEvent(Event e) {
+                               if (fUseProject.getSelection()) {
+                                       fPrefsBlock.setInput(project);
+                                       fPrefsBlock.setEnabled(true);
+                               }
+                       }
+               });
+               
+               Composite blockPane = new Composite(topPane, SWT.NONE);
+
+               blockPane.setLayout(new GridLayout());
+               blockPane.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+               if (custom) {
+                       fPrefsBlock = new FixCFileTypesPreferenceBlock(project);
+               } else {
+                       fPrefsBlock = new FixCFileTypesPreferenceBlock();
+               }
+
+               fPrefsBlock.createControl(blockPane);
+       
+               fUseWorkspace.setSelection(!custom);
+               fUseProject.setSelection(custom);
+               fPrefsBlock.setEnabled(custom);
+       
+               PlatformUI.getWorkbench().getHelpSystem().setHelp( topPane, ICHelpContextIds.FILE_TYPES_STD_PAGE );
+               return topPane;
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
+        */
+       @Override
+       protected void performDefaults() {
+               fUseWorkspace.setSelection(true);
+               fUseProject.setSelection(false);
+               fPrefsBlock.setInput(null);
+               fPrefsBlock.setEnabled(false);
+               super.performDefaults();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.preference.IPreferencePage#performOk()
+        */
+       @Override
+       public boolean performOk() {
+               boolean useProjectContentTypes= fUseProject.getSelection();
+               IProject project = getProject();
+               if (CCorePlugin.usesProjectSpecificContentTypes(project) != useProjectContentTypes) {
+                       CCorePlugin.setUseProjectSpecificContentTypes(project, useProjectContentTypes);
+                       computeEvents(project);
+               }
+               if (useProjectContentTypes) {
+                       fPrefsBlock.performOk();
+               }
+               return super.performOk();
+       }
+       
+       private IProject getProject(){
+               Object          element = getElement();
+               IProject        project = null;
+               
+               if (element instanceof IProject) {
+                       project = (IProject) element;
+               } else if (element instanceof IAdaptable) {
+                       project= (IProject) ((IAdaptable)element).getAdapter(IProject.class);
+               }
+               return project;
+       }
+
+       public IContentType[] getRegistedContentTypes() {
+               String [] ids = CoreModel.getRegistedContentTypeIds();
+               IContentTypeManager manager = Platform.getContentTypeManager();
+               IContentType [] ctypes = new IContentType[ids.length];
+               for (int i = 0; i < ids.length; i++) {
+                       ctypes[i] = manager.getContentType(ids[i]);
+               }
+               return ctypes;
+       }
+
+       /**
+        * We are looking at the association from the project, if we have any
+        * we should generate an event.
+        * @param project
+        */
+       void computeEvents(IProject project) {
+               IScopeContext projectScope = new ProjectScope(project);
+               IContentType[] ctypes = getRegistedContentTypes();
+               ArrayList<IContentType> list = new ArrayList<IContentType>(ctypes.length);
+               for (IContentType ctype : ctypes) {
+                       try {
+                               IContentTypeSettings projectSettings = ctype.getSettings(projectScope);
+                               String[] projectSpecs = projectSettings.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
+                               if (projectSpecs!= null && projectSpecs.length > 0) {
+                                       list.add(ctype);
+                               } else {
+                                       projectSpecs = projectSettings.getFileSpecs(IContentType.FILE_NAME_SPEC);
+                                       if (projectSpecs != null && projectSpecs.length > 0) {
+                                               list.add(ctype);
+                                       }
+                               }
+                       } catch (CoreException e) {
+                               // ignore ?
+                       }
+               }
+
+               // fire the events
+               if (list.size() > 0) {
+                       IContentTypeManager.ContentTypeChangeEvent[] events =  new IContentTypeManager.ContentTypeChangeEvent[list.size()];
+                       for (int i = 0; i < list.size(); ++i) {
+                               IContentType source = list.get(i);
+                               events[i] =  new IContentTypeManager.ContentTypeChangeEvent(source, projectScope);
+                       }
+                       CModelManager.getDefault().contentTypeChanged(events);
+               }
+       }
+
+       boolean isSpecsChanged(String[] newSpecs, String[] oldSpecs) {
+               if (newSpecs.length != oldSpecs.length) {
+                       return true;
+               }
+               for (int i = 0; i < newSpecs.length; ++i) {
+                       String newSpec = newSpecs[i];
+                       boolean found = false;
+                       for (int j = 0; j < oldSpecs.length; ++j) {
+                               String oldSpec = oldSpecs[j];
+                               if (newSpec.equalsIgnoreCase(oldSpec)) {
+                                       found = true;
+                                       break;
+                               }
+                       }
+                       if (!found) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CParserPreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CParserPreferencePage.java
new file mode 100644 (file)
index 0000000..b356b64
--- /dev/null
@@ -0,0 +1,177 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.CDOM;
+import org.eclipse.cdt.core.parser.CodeReaderCache;
+import org.eclipse.cdt.core.parser.ICodeReaderCache;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey;
+
+/**
+ * @author dsteffle
+ * @deprecated the one preference found on the page was moved to the 
+ * indexer preference page.
+ */
+@Deprecated
+public class CParserPreferencePage extends PreferencePage implements
+               IWorkbenchPreferencePage {
+       
+       protected OverlayPreferenceStore fOverlayStore;
+       private Text bufferTextControl;
+       
+       public CParserPreferencePage(){
+               setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
+               fOverlayStore  = createOverlayStore();
+       }
+
+       private OverlayPreferenceStore createOverlayStore() {
+               ArrayList<OverlayKey> overlayKeys = new ArrayList<OverlayKey>();                
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CodeReaderCache.CODE_READER_BUFFER));
+       
+        OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
+               overlayKeys.toArray(keys);
+               return new OverlayPreferenceStore(getPreferenceStore(), keys);
+       }
+
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected Control createContents(Composite parent) {
+               fOverlayStore.load();
+               fOverlayStore.start();
+               
+               initializeDialogUnits(parent);
+               
+               Composite result= new Composite(parent, SWT.NONE);
+               GridLayout layout= new GridLayout();
+               layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+               layout.marginWidth= 0;
+               layout.verticalSpacing= convertVerticalDLUsToPixels(10);
+               layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+               result.setLayout(layout);
+               
+               Group bufferGroup= new Group(result, SWT.NONE);
+               bufferGroup.setLayout(new GridLayout());
+               bufferGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               bufferGroup.setText(PreferencesMessages.CBufferPreferences_CodeReaderBuffer_CodeReaderBufferGroup); 
+       
+               bufferTextControl = (Text) addTextField( bufferGroup, PreferencesMessages.CBufferPreferences_CodeReaderBuffer_Size,6,0); 
+               
+               initialize(); 
+               
+               return result;
+       
+       }
+       
+       private void initialize(){
+               bufferTextControl.setText(fOverlayStore.getString(CodeReaderCache.CODE_READER_BUFFER));
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+        */
+       public void init(IWorkbench workbench) {
+               // TODO Auto-generated method stub
+       }
+       
+       private Control addTextField(Composite composite, String label, int textLimit, int indentation) {
+
+               Label labelControl = new Label(composite, SWT.NONE);
+               labelControl.setText(label);
+               GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+               gd.horizontalIndent = indentation;
+               labelControl.setLayoutData(gd);
+
+               Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE);
+               gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+               gd.widthHint = convertWidthInCharsToPixels(textLimit + 1);
+               textControl.setLayoutData(gd);
+               textControl.setTextLimit(textLimit);
+
+               return textControl;
+       }
+       
+       /*
+        * @see IPreferencePage#performOk()
+        */
+       @Override
+       public boolean performOk() {
+               Preferences prefs = CCorePlugin.getDefault().getPluginPreferences();
+               
+               String bufferSize = bufferTextControl.getText();
+               fOverlayStore.setValue(CodeReaderCache.CODE_READER_BUFFER, bufferSize);
+               prefs.setValue(CodeReaderCache.CODE_READER_BUFFER, bufferSize);
+
+               ICodeReaderCache cache = CDOM.getInstance().getCodeReaderFactory(CDOM.PARSE_SAVED_RESOURCES).getCodeReaderCache();
+               if (cache instanceof CodeReaderCache) {
+                       try {
+                               // Check the string number
+                               int size = Integer.parseInt(bufferSize);
+                               if (size >= 0) {
+                                       ((CodeReaderCache)cache).setCacheSize(size);
+                               } else {
+                                       ((CodeReaderCache)cache).setCacheSize(CodeReaderCache.DEFAULT_CACHE_SIZE_IN_MB);
+                                       prefs.setValue(CodeReaderCache.CODE_READER_BUFFER, CodeReaderCache.DEFAULT_CACHE_SIZE_IN_MB);
+                                       fOverlayStore.setValue(CodeReaderCache.CODE_READER_BUFFER, CodeReaderCache.DEFAULT_CACHE_SIZE_IN_MB);
+                               }
+                       } catch (NumberFormatException ex){
+                               ((CodeReaderCache)cache).setCacheSize(CodeReaderCache.DEFAULT_CACHE_SIZE_IN_MB);
+                               prefs.setValue(CodeReaderCache.CODE_READER_BUFFER, CodeReaderCache.DEFAULT_CACHE_SIZE_IN_MB);
+                               fOverlayStore.setValue(CodeReaderCache.CODE_READER_BUFFER, CodeReaderCache.DEFAULT_CACHE_SIZE_IN_MB);
+                       }       
+               }
+               
+               fOverlayStore.propagate();
+               CCorePlugin.getDefault().savePluginPreferences();
+               
+               return true;
+       }
+       
+       /**
+        * @param store
+        */
+       public static void initDefaults(IPreferenceStore store) {
+               store.setDefault(CodeReaderCache.CODE_READER_BUFFER,CodeReaderCache.DEFAULT_CACHE_SIZE_IN_MB_STRING);
+       }
+       
+       /*
+        * @see PreferencePage#performDefaults()
+        */
+       @Override
+       protected void performDefaults() {
+               fOverlayStore.loadDefaults();
+               initialize();
+               super.performDefaults();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java
new file mode 100644 (file)
index 0000000..530d8db
--- /dev/null
@@ -0,0 +1,230 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *     James Blackburn (Broadcom Corp.)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.util.ArrayList;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.dialogs.OptionalMessageDialog;
+import org.eclipse.cdt.internal.ui.util.SWTUtil;
+
+/**
+ * The page for general C/C++ preferences.
+ */
+public class CPluginPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+       public static final String C_BASE_PREF_PAGE_ID= "org.eclipse.cdt.ui.preferences.CPluginPreferencePage"; //$NON-NLS-1$
+       
+       private static final int GROUP_VINDENT = 5;
+       private ArrayList<Button> fCheckBoxes;
+
+       public CPluginPreferencePage() {
+               super();
+               setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
+               setDescription(PreferencesMessages.CPluginPreferencePage_description);
+
+               fCheckBoxes= new ArrayList<Button>();
+       }
+       
+       @Override
+       public void createControl(Composite parent) {
+               super.createControl(parent);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.C_PREF_PAGE);
+       }       
+
+       @Override
+       protected Control createContents(Composite parent) {
+               initializeDialogUnits(parent);
+
+               Composite container= new Composite(parent, SWT.NONE);
+               GridLayout layout= new GridLayout();
+               layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+               layout.marginWidth= 0;
+               layout.verticalSpacing= convertVerticalDLUsToPixels(10);
+               layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+               container.setLayout(layout);
+
+               Group outlineViewGroup = addGroup(container, PreferencesMessages.CPluginPreferencePage_outline_view);
+               addCheckBox(outlineViewGroup, PreferencesMessages.CPluginPreferencePage_structuralParseMode_label,
+                               PreferenceConstants.PREF_USE_STRUCTURAL_PARSE_MODE);
+               
+               addNote(outlineViewGroup, PreferencesMessages.CPluginPreferencePage_performanceHint);
+
+               // Refactoring.
+               Group refactoringGroup = addGroup(container, PreferencesMessages.CPluginPreferencePage_refactoring_title);
+               addCheckBox(refactoringGroup,
+                               PreferencesMessages.CPluginPreferencePage_refactoring_auto_save,
+                               PreferenceConstants.REFACTOR_SAVE_ALL_EDITORS);
+               addCheckBox(refactoringGroup,
+                               PreferencesMessages.CPluginPreferencePage_refactoring_lightweight,
+                               PreferenceConstants.REFACTOR_LIGHTWEIGHT);
+               
+               Group dontAskGroup= addGroup(container, PreferencesMessages.CPluginPreferencePage_cdtDialogs_group, 2);
+               Label label= new Label(dontAskGroup, SWT.WRAP);
+               label.setText(PreferencesMessages.CPluginPreferencePage_clearDoNotShowAgainSettings_label);
+               GridData data= new GridData(GridData.FILL, GridData.CENTER, true, false);
+               data.widthHint= convertVerticalDLUsToPixels(50);
+               label.setLayoutData(data);
+
+               Button clearButton= new Button(dontAskGroup, SWT.PUSH);
+               clearButton.setText(PreferencesMessages.CPluginPreferencePage_clear_button);
+               clearButton.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false));
+               clearButton.addSelectionListener(new SelectionListener() {
+                       public void widgetSelected(SelectionEvent e) {
+                               OptionalMessageDialog.clearAllRememberedStates();
+                       }
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               OptionalMessageDialog.clearAllRememberedStates();
+                       }
+               });
+               SWTUtil.setButtonDimensionHint(clearButton);
+               Dialog.applyDialogFont(container);
+               return container;
+       }
+
+       private void addNote(Group parent, String noteMessage) {
+               Composite noteControl= createNoteComposite(JFaceResources.getDialogFont(), parent,
+                               PreferencesMessages.CPluginPreferencePage_note, noteMessage);
+               GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               gd.verticalIndent = GROUP_VINDENT;
+               noteControl.setLayoutData(gd);
+       }
+
+       @Override
+       protected Composite createNoteComposite(Font font, Composite composite, String title, String message) {
+               Composite messageComposite = super.createNoteComposite(font, composite, title, message);
+               Control[] children = messageComposite.getChildren();
+               if (children.length == 2 && (children[1] instanceof Label)) {
+                       // this is temporary fix for problem that 3 line note does not displayed properly within the group
+                       Label messageLabel = (Label) children[1];
+                       GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+                       gd.widthHint=500;
+                       messageLabel.setLayoutData(gd);
+               }
+               return messageComposite;
+       }
+       
+       private Group addGroup(Composite parent, String label) {
+               return addGroup(parent, label, 1);
+       }
+
+       private Group addGroup(Composite parent, String label, int numColumns) {
+               Group group = new Group(parent, SWT.NONE);
+               group.setText(label);
+               group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               group.setLayout(new GridLayout(numColumns, false));
+               return group;
+       }
+
+       private Button addCheckBox(Composite parent, String label, String key) {
+               Button button= new Button(parent, SWT.CHECK);
+               button.setText(label);
+               button.setData(key);
+               button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+
+               button.setSelection(getPreferenceStore().getBoolean(key));
+
+               fCheckBoxes.add(button);
+               return button;
+       }
+
+       protected void addFiller(Composite composite) {
+               PixelConverter pixelConverter= new PixelConverter(composite);
+               Label filler= new Label(composite, SWT.LEFT );
+               GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               gd.horizontalSpan= 1;
+               gd.heightHint= pixelConverter.convertHeightInCharsToPixels(1) / 2;
+               filler.setLayoutData(gd);
+       }
+
+       public static boolean isLinkToEditor() {
+               return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREF_LINK_TO_EDITOR);
+       }
+
+       public static void setLinkingEnabled(boolean enable) {
+               CUIPlugin.getDefault().getPreferenceStore().setValue(PreferenceConstants.PREF_LINK_TO_EDITOR, enable);
+       }
+
+       public static boolean useStructuralParseMode() {
+               return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREF_USE_STRUCTURAL_PARSE_MODE);
+       }
+
+       /**
+        * @see IWorkbenchPreferencePage#init
+        */
+       public void init(IWorkbench workbench) {
+       }
+       
+       /**
+        * Initializes the default values of this page in the preference bundle.
+        */
+       public static void initDefaults(IPreferenceStore prefs) {
+               prefs.setDefault(PreferenceConstants.PREF_LINK_TO_EDITOR, false);
+               prefs.setDefault(PreferenceConstants.PREF_USE_STRUCTURAL_PARSE_MODE, false);
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.preference.IPreferencePage#performOk()
+        */
+       @Override
+       public boolean performOk() {
+               if (!super.performOk())
+                       return false;
+               IPreferenceStore store= getPreferenceStore();
+               for (int i= 0; i < fCheckBoxes.size(); i++) {
+                       Button button= fCheckBoxes.get(i);
+                       String key= (String) button.getData();
+                       store.setValue(key, button.getSelection());
+               }
+               // tell the Core Plugin about this preference
+               CCorePlugin.getDefault().setStructuralParseMode(useStructuralParseMode());
+               return true;
+       }
+
+    @Override
+       protected void performDefaults() {
+       super.performDefaults();
+               IPreferenceStore store= getPreferenceStore();
+               for (int i= 0; i < fCheckBoxes.size(); i++) {
+                       Button button= fCheckBoxes.get(i);
+                       String key= (String) button.getData();
+                       button.setSelection(store.getDefaultBoolean(key));
+               }
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CSourcePreviewerUpdater.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CSourcePreviewerUpdater.java
new file mode 100644 (file)
index 0000000..80212e9
--- /dev/null
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.graphics.Font;
+
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.CSourceViewerConfiguration;
+
+
+public class CSourcePreviewerUpdater {
+
+       /**
+        * Handles editor font changes for source preview viewers.
+        * 
+        * @param viewer
+        * @param configuration
+        * @param store
+        */
+       public CSourcePreviewerUpdater(SourceViewer viewer, CSourceViewerConfiguration configuration, IPreferenceStore store) {
+               registerPreviewer(viewer, configuration, store);
+       }
+
+       /**
+        * Registers a source preview updater for the given viewer, configuration and preference store.
+        *
+        * @param viewer the viewer
+        * @param configuration the configuration
+        * @param preferenceStore the preference store
+        */
+       static public void registerPreviewer(final SourceViewer viewer, final CSourceViewerConfiguration configuration, final IPreferenceStore preferenceStore) {
+               Assert.isNotNull(viewer);
+               Assert.isNotNull(configuration);
+               Assert.isNotNull(preferenceStore);
+               final IPropertyChangeListener fontChangeListener= new IPropertyChangeListener() {
+                       /*
+                        * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+                        */
+                       public void propertyChange(PropertyChangeEvent event) {
+                               if (event.getProperty().equals(PreferenceConstants.EDITOR_TEXT_FONT)) {
+                                       Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
+                                       viewer.getTextWidget().setFont(font);
+                               }
+                       }
+               };
+               final IPropertyChangeListener propertyChangeListener= new IPropertyChangeListener() {
+                       /*
+                        * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+                        */
+                       public void propertyChange(PropertyChangeEvent event) {
+                               if (configuration.affectsTextPresentation(event)) {
+                                       configuration.handlePropertyChangeEvent(event);
+                                       viewer.invalidateTextPresentation();
+                               }
+                       }
+               };
+               viewer.getTextWidget().addDisposeListener(new DisposeListener() {
+                       /*
+                        * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
+                        */
+                       public void widgetDisposed(DisposeEvent e) {
+                               preferenceStore.removePropertyChangeListener(propertyChangeListener);
+                               JFaceResources.getFontRegistry().removeListener(fontChangeListener);
+                       }
+               });
+               JFaceResources.getFontRegistry().addListener(fontChangeListener);
+               preferenceStore.addPropertyChangeListener(propertyChangeListener);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CTemplatePreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CTemplatePreferencePage.java
new file mode 100644 (file)
index 0000000..428d54f
--- /dev/null
@@ -0,0 +1,163 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ * Wind River Systems, Inc. - Bug fixes
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.ContentAssistant;
+import org.eclipse.jface.text.contentassist.IContentAssistant;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.text.templates.ContextTypeRegistry;
+import org.eclipse.jface.text.templates.Template;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleAdapter;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.texteditor.templates.TemplatePreferencePage;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.CSourceViewerConfiguration;
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.editor.CSourceViewer;
+import org.eclipse.cdt.internal.ui.text.CTextTools;
+
+/**
+ * Template preference page for C/C++ editor templates.
+ */
+public class CTemplatePreferencePage extends TemplatePreferencePage {
+
+       /**
+        * A dialog to edit a template.
+        */
+       protected class CEditTemplateDialog extends EditTemplateDialog {
+
+               public CEditTemplateDialog(Shell shell, Template template,
+                               boolean edit, boolean isNameModifiable,
+                               ContextTypeRegistry contextTypeRegistry) {
+                       super(shell, template, edit, isNameModifiable, contextTypeRegistry);
+               }
+               /*
+                * @see org.eclipse.ui.texteditor.templates.TemplatePreferencePage.EditTemplateDialog#createViewer(org.eclipse.swt.widgets.Composite)
+                */
+               @Override
+               protected SourceViewer createViewer(Composite parent) {
+                       IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
+                       CSourceViewer viewer= new CSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store);
+                       CTextTools tools= CUIPlugin.getDefault().getTextTools();
+                       CSourceViewerConfiguration configuration= new CSourceViewerConfiguration(tools.getColorManager(), store, null, tools.getDocumentPartitioning()) {
+                               @Override
+                               public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
+                                       ContentAssistant assistant= new ContentAssistant();
+                                       assistant.enableAutoActivation(true);
+                                       assistant.enableAutoInsert(true);
+                                       assistant.setContentAssistProcessor(getTemplateProcessor(), IDocument.DEFAULT_CONTENT_TYPE);
+                                       assistant.setContentAssistProcessor(getTemplateProcessor(), ICPartitions.C_MULTI_LINE_COMMENT);
+                                       assistant.setContentAssistProcessor(getTemplateProcessor(), ICPartitions.C_SINGLE_LINE_COMMENT);
+                                       assistant.setContentAssistProcessor(getTemplateProcessor(), ICPartitions.C_PREPROCESSOR);
+                                       return assistant;
+                               }
+                       };
+                       IDocument document = new Document();
+                       tools.setupCDocument(document);
+                       viewer.configure(configuration);
+                       viewer.setEditable(true);
+                       viewer.setDocument(document);
+               
+                       Font font= JFaceResources.getFontRegistry().get(PreferenceConstants.EDITOR_TEXT_FONT);
+                       viewer.getTextWidget().setFont(font);
+               
+                       CSourcePreviewerUpdater.registerPreviewer(viewer, configuration, CUIPlugin.getDefault().getCombinedPreferenceStore());
+                       return viewer;
+               }
+       }
+
+       public CTemplatePreferencePage() {
+               setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
+               setTemplateStore(CUIPlugin.getDefault().getTemplateStore());
+               setContextTypeRegistry(CUIPlugin.getDefault().getTemplateContextRegistry());
+       }
+       
+       /*
+        * @see PreferencePage#createControl(Composite)
+        */
+       @Override
+       public void createControl(Composite parent) {
+               super.createControl(parent);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.TEMPLATE_PREFERENCE_PAGE);
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.templates.TemplatePreferencePage#getFormatterPreferenceKey()
+        */
+       @Override
+       protected String getFormatterPreferenceKey() {
+               return PreferenceConstants.TEMPLATES_USE_CODEFORMATTER;
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.templates.TemplatePreferencePage#createTemplateEditDialog2(org.eclipse.jface.text.templates.Template, boolean, boolean)
+        */
+       @Override
+       protected Template editTemplate(Template template, boolean edit, boolean isNameModifiable) {
+               CEditTemplateDialog dialog= new CEditTemplateDialog(getShell(), template, edit, isNameModifiable, getContextTypeRegistry());
+               if (dialog.open() == Window.OK) {
+                       return dialog.getTemplate();
+               }
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.templates.TemplatePreferencePage#createViewer(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected SourceViewer createViewer(Composite parent) {
+               IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
+               CSourceViewer viewer= new CSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store);
+               CTextTools tools= CUIPlugin.getDefault().getTextTools();
+               CSourceViewerConfiguration configuration = new CSourceViewerConfiguration(tools.getColorManager(), store, null, tools.getDocumentPartitioning());
+               IDocument document = new Document();
+               tools.setupCDocument(document);
+               viewer.configure(configuration);
+               viewer.setEditable(false);
+               viewer.setDocument(document);
+       
+               Font font= JFaceResources.getFontRegistry().get(PreferenceConstants.EDITOR_TEXT_FONT);
+               viewer.getTextWidget().setFont(font);
+               
+               Control control= viewer.getControl();
+               GridData data= new GridData(GridData.FILL_BOTH);
+               data.heightHint= convertHeightInCharsToPixels(5);
+               control.setLayoutData(data);
+       
+               control.getAccessible().addAccessibleListener(new AccessibleAdapter() {                 
+                       @Override
+                       public void getName(AccessibleEvent e) {
+                               e.result = PreferencesMessages.TemplatePreferencePage_Viewer_preview; 
+               }});
+               
+               CSourcePreviewerUpdater.registerPreviewer(viewer, configuration, CUIPlugin.getDefault().getCombinedPreferenceStore());
+               return viewer;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java
new file mode 100644 (file)
index 0000000..b05adda
--- /dev/null
@@ -0,0 +1,728 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.CommandManager;
+import org.eclipse.core.commands.IParameter;
+import org.eclipse.core.commands.Parameterization;
+import org.eclipse.core.commands.ParameterizedCommand;
+import org.eclipse.core.commands.common.NotDefinedException;
+import org.eclipse.core.commands.contexts.ContextManager;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.bindings.BindingManager;
+import org.eclipse.jface.bindings.Scheme;
+import org.eclipse.jface.bindings.TriggerSequence;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.eclipse.ui.keys.IBindingService;
+import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
+import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
+import org.eclipse.cdt.internal.ui.text.contentassist.CompletionProposalCategory;
+import org.eclipse.cdt.internal.ui.text.contentassist.CompletionProposalComputerRegistry;
+import org.eclipse.cdt.internal.ui.util.Messages;
+import org.eclipse.cdt.internal.ui.util.SWTUtil;
+
+
+/**
+ *     
+ * @since 3.2
+ */
+final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlock {
+       
+       private static final Key PREF_EXCLUDED_CATEGORIES= getCDTUIKey(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
+       private static final Key PREF_CATEGORY_ORDER= getCDTUIKey(PreferenceConstants.CODEASSIST_CATEGORY_ORDER);
+       
+       private static Key[] getAllKeys() {
+               return new Key[] {
+                               PREF_EXCLUDED_CATEGORIES,
+                               PREF_CATEGORY_ORDER,
+               };
+       }
+
+       private final class DefaultTableLabelProvider extends LabelProvider implements ITableLabelProvider {
+
+               /*
+                * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
+                */
+               public Image getColumnImage(Object element, int columnIndex) {
+                       if (columnIndex == 0)
+                               return ((ModelElement) element).getImage();
+                       return null;
+               }
+
+               /*
+                * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
+                */
+               public String getColumnText(Object element, int columnIndex) {
+                       switch (columnIndex) {
+                   case 0:
+                       return ((ModelElement) element).getName();
+                   case 1:
+                       return ((ModelElement) element).getKeybindingAsString();
+                   default:
+                       Assert.isTrue(false);
+                       return null;
+            }
+               }
+               
+               /*
+                * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
+                */
+               @Override
+               public String getText(Object element) {
+                   return getColumnText(element, 0); // needed to make the sorter work
+               }
+       }
+
+       private final class SeparateTableLabelProvider extends LabelProvider implements ITableLabelProvider {
+               
+               /*
+                * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
+                */
+               public Image getColumnImage(Object element, int columnIndex) {
+                       if (columnIndex == 0)
+                               return ((ModelElement) element).getImage();
+                       return null;
+               }
+               
+               /*
+                * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
+                */
+               public String getColumnText(Object element, int columnIndex) {
+                       switch (columnIndex) {
+                               case 0:
+                                       return ((ModelElement) element).getName();
+                               default:
+                                       Assert.isTrue(false);
+                               return null;
+                       }
+               }
+       }
+
+       private final Comparator<ModelElement> fCategoryComparator= new Comparator<ModelElement>() {
+               public int compare(ModelElement o1, ModelElement o2) {
+                       return o1.getRank() - o2.getRank();
+               }
+       };
+       
+       private final class PreferenceModel {
+               private static final int LIMIT= 0xffff;
+               private static final String COLON= ":"; //$NON-NLS-1$
+               private static final String SEPARATOR= "\0"; //$NON-NLS-1$
+
+               private final List<ModelElement> fElements;
+               /**
+                * The read-only list of elements.
+                */
+               final List<ModelElement> elements;
+               
+               public PreferenceModel(CompletionProposalComputerRegistry registry) {
+                       List<CompletionProposalCategory> categories= registry.getProposalCategories();
+                       fElements= new ArrayList<ModelElement>();
+                       for (CompletionProposalCategory category : categories) {
+                               if (category.hasComputers()) {
+                                       fElements.add(new ModelElement(category, this));
+                               }
+                       }
+                       Collections.sort(fElements, fCategoryComparator);
+                       elements= Collections.unmodifiableList(fElements);
+               }
+               
+        public void moveUp(ModelElement category) {
+               int index= fElements.indexOf(category);
+                       if (index > 0) {
+                               ModelElement item= fElements.remove(index);
+                               fElements.add(index - 1, item);
+                               writeOrderPreference(null, false);
+                       }
+        }
+
+        public void moveDown(ModelElement category) {
+               int index= fElements.indexOf(category);
+                       if (index < fElements.size() - 1) {
+                               ModelElement item= fElements.remove(index);
+                               fElements.add(index + 1, item);
+                               writeOrderPreference(null, false);
+                       }
+        }
+
+       private void writeInclusionPreference(ModelElement changed, boolean isInDefaultCategory) {
+               StringBuffer buf= new StringBuffer();
+               for (Object element : fElements) {
+                       ModelElement item= (ModelElement) element;
+                       boolean included= changed == item ? isInDefaultCategory : item.isInDefaultCategory();
+                       if (!included)
+                               buf.append(item.getId() + SEPARATOR);
+               }
+               
+               String newValue= buf.toString();
+               String oldValue= setValue(PREF_EXCLUDED_CATEGORIES, newValue);
+               validateSettings(PREF_EXCLUDED_CATEGORIES, oldValue, newValue);
+       }
+       
+       private void writeOrderPreference(ModelElement changed, boolean isSeparate) {
+               StringBuffer buf= new StringBuffer();
+               int i= 0;
+               for (Iterator<ModelElement> it= fElements.iterator(); it.hasNext(); i++) {
+                       ModelElement item= it.next();
+                       boolean separate= changed == item ? isSeparate : item.isSeparateCommand();
+                       int rank= separate ? i : i + LIMIT;
+                       buf.append(item.getId() + COLON + rank + SEPARATOR);
+               }
+               
+               String newValue= buf.toString();
+               String oldValue= setValue(PREF_CATEGORY_ORDER, newValue);
+               validateSettings(PREF_CATEGORY_ORDER, oldValue, newValue);
+       }
+       
+
+       private boolean readInclusionPreference(CompletionProposalCategory cat) {
+               String[] ids= getTokens(getValue(PREF_EXCLUDED_CATEGORIES), SEPARATOR);
+               for (String id : ids) {
+                       if (id.equals(cat.getId()))
+                               return false;
+               }
+               return true;
+       }
+       
+       private int readOrderPreference(CompletionProposalCategory cat) {
+               String[] sortOrderIds= getTokens(getValue(PREF_CATEGORY_ORDER), SEPARATOR);
+               for (String sortOrderId : sortOrderIds) {
+                       String[] idAndRank= getTokens(sortOrderId, COLON);
+                       if (idAndRank[0].equals(cat.getId()))
+                               return Integer.parseInt(idAndRank[1]);
+               }
+               return LIMIT + 1;
+       }
+
+        public void update() {
+                       Collections.sort(fElements, fCategoryComparator);
+        }
+       }
+       
+       private final class ModelElement {
+               private final CompletionProposalCategory fCategory;
+               private final Command fCommand;
+               private final IParameter fParam;
+               private final PreferenceModel fPreferenceModel;
+               
+               ModelElement(CompletionProposalCategory category, PreferenceModel model) {
+                       fCategory= category;
+                       ICommandService commandSvc= (ICommandService) PlatformUI.getWorkbench().getAdapter(ICommandService.class);
+                       fCommand= commandSvc.getCommand("org.eclipse.cdt.ui.specific_content_assist.command"); //$NON-NLS-1$
+                       IParameter type;
+                       try {
+                               type= fCommand.getParameters()[0];
+                       } catch (NotDefinedException x) {
+                               Assert.isTrue(false);
+                               type= null;
+                       }
+                       fParam= type;
+                       fPreferenceModel= model;
+               }
+               Image getImage() {
+                       return CodeAssistAdvancedConfigurationBlock.this.getImage(fCategory.getImageDescriptor());
+               }
+               String getName() {
+                       return fCategory.getDisplayName();
+               }
+               String getKeybindingAsString() {
+                       final Parameterization[] params= { new Parameterization(fParam, fCategory.getId()) };
+                       final ParameterizedCommand pCmd= new ParameterizedCommand(fCommand, params);
+                       String key= getKeyboardShortcut(pCmd);
+                       return key;
+               }
+               boolean isInDefaultCategory() {
+                       return fPreferenceModel.readInclusionPreference(fCategory);
+               }
+               void setInDefaultCategory(boolean included) {
+                       if (included != isInDefaultCategory())
+                               fPreferenceModel.writeInclusionPreference(this, included);
+               }
+               String getId() {
+                       return fCategory.getId();
+               }
+               int getRank() {
+                       int rank= getInternalRank();
+                       if (rank > PreferenceModel.LIMIT)
+                               return rank - PreferenceModel.LIMIT;
+                       return rank;
+               }
+               void moveUp() {
+                       fPreferenceModel.moveUp(this);
+               }
+               void moveDown() {
+                       fPreferenceModel.moveDown(this);
+               }
+               private int getInternalRank() {
+                       return fPreferenceModel.readOrderPreference(fCategory);
+               }
+               boolean isSeparateCommand() {
+                       return getInternalRank() < PreferenceModel.LIMIT;
+               }
+               
+               void setSeparateCommand(boolean separate) {
+                       if (separate != isSeparateCommand())
+                               fPreferenceModel.writeOrderPreference(this, separate);
+               }
+               
+               void update() {
+                       fCategory.setIncluded(isInDefaultCategory());
+                       int rank= getInternalRank();
+                       fCategory.setSortOrder(rank);
+                       fCategory.setSeparateCommand(rank < PreferenceModel.LIMIT);
+               }
+       }
+       
+       /** element type: {@link ModelElement}. */
+       private final PreferenceModel fModel;
+       private final Map<ImageDescriptor, Image> fImages= new HashMap<ImageDescriptor, Image>();
+
+       private CheckboxTableViewer fDefaultViewer;
+       private CheckboxTableViewer fSeparateViewer;
+       private Button fUpButton;
+       private Button fDownButton;
+       
+       CodeAssistAdvancedConfigurationBlock(IStatusChangeListener statusListener, IWorkbenchPreferenceContainer container) {
+               super(statusListener, null, getAllKeys(), container);
+               fModel= new PreferenceModel(CompletionProposalComputerRegistry.getDefault());
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock#createContents(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected Control createContents(Composite parent) {
+               
+               ScrolledPageContent scrolled= new ScrolledPageContent(parent, SWT.H_SCROLL | SWT.V_SCROLL);
+               
+               scrolled.setExpandHorizontal(true);
+               scrolled.setExpandVertical(true);
+               
+               Composite composite= new Composite(scrolled, SWT.NONE);
+               int columns= 2;
+               GridLayout layout= new GridLayout(columns, false);
+               layout.marginWidth= 0;
+               layout.marginHeight= 0;
+               composite.setLayout(layout);
+               
+               
+               createDefaultLabel(composite, columns);
+               createDefaultViewer(composite, columns);
+               createKeysLink(composite, columns);
+               
+               createFiller(composite, columns);
+               
+               createSeparateLabel(composite, columns);
+        createSeparateSection(composite);
+        
+        createFiller(composite, columns);
+               
+               updateControls();
+               if (fModel.elements.size() > 0) {
+                       fDefaultViewer.getTable().select(0);
+                       fSeparateViewer.getTable().select(0);
+                       handleTableSelection();
+               }
+               
+               scrolled.setContent(composite);
+               scrolled.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
+               return scrolled;
+       }
+       
+       private void createDefaultLabel(Composite composite, int h_span) {
+           final ICommandService commandSvc= (ICommandService) PlatformUI.getWorkbench().getAdapter(ICommandService.class);
+               final Command command= commandSvc.getCommand(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
+               ParameterizedCommand pCmd= new ParameterizedCommand(command, null);
+               String key= getKeyboardShortcut(pCmd);
+               if (key == null)
+                       key= PreferencesMessages.CodeAssistAdvancedConfigurationBlock_no_shortcut;
+
+               PixelConverter pixelConverter= new PixelConverter(composite);
+               int width= pixelConverter.convertWidthInCharsToPixels(40);
+               
+               Label label= new Label(composite, SWT.NONE | SWT.WRAP);
+               label.setText(Messages.format(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_page_description, new Object[] { key }));
+               GridData gd= new GridData(GridData.FILL, GridData.FILL, true, false, h_span, 1);
+               gd.widthHint= width;
+               label.setLayoutData(gd);
+               
+               createFiller(composite, h_span);
+
+               label= new Label(composite, SWT.NONE | SWT.WRAP);
+               label.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_default_table_description);
+               gd= new GridData(GridData.FILL, GridData.FILL, true, false, h_span, 1);
+               gd.widthHint= width;
+               label.setLayoutData(gd);
+    }
+
+       private void createDefaultViewer(Composite composite, int h_span) {
+               fDefaultViewer= CheckboxTableViewer.newCheckList(composite, SWT.SINGLE | SWT.BORDER);
+               Table table= fDefaultViewer.getTable();
+               table.setHeaderVisible(true);
+               table.setLinesVisible(false);
+               table.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, h_span, 1));
+               
+               TableColumn nameColumn= new TableColumn(table, SWT.NONE);
+               nameColumn.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_default_table_category_column_title);
+               nameColumn.setResizable(false);
+               TableColumn keyColumn= new TableColumn(table, SWT.NONE);
+               keyColumn.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_default_table_keybinding_column_title);
+               keyColumn.setResizable(true);
+               
+               fDefaultViewer.addCheckStateListener(new ICheckStateListener() {
+                       public void checkStateChanged(CheckStateChangedEvent event) {
+                               boolean checked= event.getChecked();
+                               ModelElement element= (ModelElement) event.getElement();
+                               element.setInDefaultCategory(checked);
+                       }
+               });
+               
+               fDefaultViewer.setContentProvider(new ArrayContentProvider());
+               
+               DefaultTableLabelProvider labelProvider= new DefaultTableLabelProvider();
+               fDefaultViewer.setLabelProvider(labelProvider);
+               fDefaultViewer.setInput(fModel.elements);
+               fDefaultViewer.setComparator(new ViewerComparator()); // sort alphabetically
+               
+               final int ICON_AND_CHECKBOX_WITH= 50;
+               final int HEADER_MARGIN= 20;
+               int minNameWidth= computeWidth(table, nameColumn.getText()) + HEADER_MARGIN;
+               int minKeyWidth= computeWidth(table, keyColumn.getText()) + HEADER_MARGIN;
+               for (int i= 0; i < fModel.elements.size(); i++) {
+                       minNameWidth= Math.max(minNameWidth, computeWidth(table, labelProvider.getColumnText(fModel.elements.get(i), 0)) + ICON_AND_CHECKBOX_WITH);
+                       minKeyWidth= Math.max(minKeyWidth, computeWidth(table, labelProvider.getColumnText(fModel.elements.get(i), 1)));
+               }
+               
+               nameColumn.setWidth(minNameWidth);
+               keyColumn.setWidth(minKeyWidth);
+       }
+       
+       private void createKeysLink(Composite composite, int h_span) {
+           Link link= new Link(composite, SWT.NONE | SWT.WRAP);
+               link.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_key_binding_hint);
+               link.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               PreferencesUtil.createPreferenceDialogOn(getShell(), e.text, null, null);
+                       }
+               });
+               
+               PixelConverter pixelConverter= new PixelConverter(composite);
+               int width= pixelConverter.convertWidthInCharsToPixels(40);
+
+               // limit the size of the Link as it would take all it can get
+               GridData gd= new GridData(GridData.FILL, GridData.FILL, false, false, h_span, 1);
+               gd.widthHint= width;
+               link.setLayoutData(gd);
+    }
+
+       private void createFiller(Composite composite, int h_span) {
+           Label filler= new Label(composite, SWT.NONE);
+               filler.setVisible(false);
+               filler.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, h_span, 1));
+    }
+
+       private void createSeparateLabel(Composite composite, int h_span) {
+               PixelConverter pixelConverter= new PixelConverter(composite);
+               int width= pixelConverter.convertWidthInCharsToPixels(40);
+               
+               Label label= new Label(composite, SWT.NONE | SWT.WRAP);
+               label.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_separate_table_description);
+               GridData gd= new GridData(GridData.FILL, GridData.FILL, false, false, h_span, 1);
+               gd.widthHint= width;
+               label.setLayoutData(gd);
+       }
+       
+       private void createSeparateSection(Composite composite) {
+               createSeparateViewer(composite);
+               createButtonList(composite);
+       }
+
+       private void createSeparateViewer(Composite composite) {
+               fSeparateViewer= CheckboxTableViewer.newCheckList(composite, SWT.SINGLE | SWT.BORDER);
+               Table table= fSeparateViewer.getTable();
+               table.setHeaderVisible(false);
+               table.setLinesVisible(false);
+               table.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false, 1, 1));
+               
+               TableColumn nameColumn= new TableColumn(table, SWT.NONE);
+               nameColumn.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_separate_table_category_column_title);
+               nameColumn.setResizable(false);
+               
+               fSeparateViewer.setContentProvider(new ArrayContentProvider());
+               
+               ITableLabelProvider labelProvider= new SeparateTableLabelProvider();
+               fSeparateViewer.setLabelProvider(labelProvider);
+               fSeparateViewer.setInput(fModel.elements);
+               
+               final int ICON_AND_CHECKBOX_WITH= 50;
+               final int HEADER_MARGIN= 20;
+               int minNameWidth= computeWidth(table, nameColumn.getText()) + HEADER_MARGIN;
+               for (int i= 0; i < fModel.elements.size(); i++) {
+                       minNameWidth= Math.max(minNameWidth, computeWidth(table, labelProvider.getColumnText(fModel.elements.get(i), 0)) + ICON_AND_CHECKBOX_WITH);
+               }
+               
+               nameColumn.setWidth(minNameWidth);
+               
+               fSeparateViewer.addCheckStateListener(new ICheckStateListener() {
+                       public void checkStateChanged(CheckStateChangedEvent event) {
+                               boolean checked= event.getChecked();
+                               ModelElement element= (ModelElement) event.getElement();
+                               element.setSeparateCommand(checked);
+                       }
+               });
+               
+               table.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               handleTableSelection();
+                       }
+               });
+               
+       }
+       
+       private void createButtonList(Composite parent) {
+               Composite composite= new Composite(parent, SWT.NONE);
+               composite.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));
+               
+               GridLayout layout= new GridLayout();
+               layout.marginWidth= 0;
+               layout.marginHeight= 0;
+               composite.setLayout(layout);
+               
+               fUpButton= new Button(composite, SWT.PUSH | SWT.CENTER);
+        fUpButton.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_Up);
+        fUpButton.addSelectionListener(new SelectionAdapter() {
+               @Override
+                       public void widgetSelected(SelectionEvent e) {
+                       int index= getSelectionIndex();
+                       if (index != -1) {
+                               (fModel.elements.get(index)).moveUp();
+                               fSeparateViewer.refresh();
+                               handleTableSelection();
+                       }
+               }               
+        });
+        fUpButton.setLayoutData(new GridData());
+        SWTUtil.setButtonDimensionHint(fUpButton);
+        
+        fDownButton= new Button(composite, SWT.PUSH | SWT.CENTER);
+        fDownButton.setText(PreferencesMessages.CodeAssistAdvancedConfigurationBlock_Down);
+        fDownButton.addSelectionListener(new SelectionAdapter() {
+               @Override
+                       public void widgetSelected(SelectionEvent e) {
+                       int index= getSelectionIndex();
+                       if (index != -1) {
+                               (fModel.elements.get(index)).moveDown();
+                               fSeparateViewer.refresh();
+                               handleTableSelection();
+                       }
+               }               
+        });
+        fDownButton.setLayoutData(new GridData());
+        SWTUtil.setButtonDimensionHint(fDownButton);
+       }
+
+       private void handleTableSelection() {
+               ModelElement item= getSelectedItem();
+               if (item != null) {
+                       int index= getSelectionIndex();
+                       fUpButton.setEnabled(index > 0);
+                       fDownButton.setEnabled(index < fModel.elements.size() - 1);
+               } else {
+                       fUpButton.setEnabled(false);
+                       fDownButton.setEnabled(false);
+               }
+       }
+       
+       private ModelElement getSelectedItem() {
+               return (ModelElement) ((IStructuredSelection) fSeparateViewer.getSelection()).getFirstElement();
+       }
+       
+       private int getSelectionIndex() {
+               return fSeparateViewer.getTable().getSelectionIndex();
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock#updateControls()
+        */
+       @Override
+       protected void updateControls() {
+               super.updateControls();
+
+               fModel.update();
+               updateCheckedState();
+               fDefaultViewer.refresh();
+               fSeparateViewer.refresh();
+               handleTableSelection();
+       }
+       
+       private void updateCheckedState() {
+               final int size= fModel.elements.size();
+               List<ModelElement> defaultChecked= new ArrayList<ModelElement>(size);
+               List<ModelElement> separateChecked= new ArrayList<ModelElement>(size);
+
+               for (Object element2 : fModel.elements) {
+                       ModelElement element= (ModelElement) element2;
+                       if (element.isInDefaultCategory())
+                               defaultChecked.add(element);
+                       if (element.isSeparateCommand())
+                               separateChecked.add(element);
+               }
+
+               fDefaultViewer.setCheckedElements(defaultChecked.toArray(new Object[defaultChecked.size()]));
+               fSeparateViewer.setCheckedElements(separateChecked.toArray(new Object[separateChecked.size()]));
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock#processChanges(org.eclipse.ui.preferences.IWorkbenchPreferenceContainer)
+        */
+       @Override
+       protected boolean processChanges(IWorkbenchPreferenceContainer container) {
+               for (Object element : fModel.elements) {
+                       ModelElement item= (ModelElement) element;
+                       item.update();
+               }
+               
+               return super.processChanges(container);
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock#validateSettings(org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock.Key, java.lang.String, java.lang.String)
+        */
+       @Override
+       protected void validateSettings(Key changedKey, String oldValue, String newValue) {
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock#getFullBuildDialogStrings(boolean)
+        */
+       protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
+               // no builds triggered by our settings
+               return null;
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock#dispose()
+        */
+       @Override
+       public void dispose() {
+               for (Image image : fImages.values()) {
+                       image.dispose();
+               }
+               
+               super.dispose();
+       }
+
+       private int computeWidth(Control control, String name) {
+               if (name == null)
+                       return 0;
+               GC gc= new GC(control);
+               try {
+                       gc.setFont(JFaceResources.getDialogFont());
+                       return gc.stringExtent(name).x + 10;
+               } finally {
+                       gc.dispose();
+               }
+       }
+
+       private static BindingManager fgLocalBindingManager;
+       static {
+               fgLocalBindingManager= new BindingManager(new ContextManager(), new CommandManager());
+               final IBindingService bindingService= (IBindingService)PlatformUI.getWorkbench().getService(IBindingService.class);
+               final Scheme[] definedSchemes= bindingService.getDefinedSchemes();
+               if (definedSchemes != null) {
+                       try {
+                               for (int i = 0; i < definedSchemes.length; i++) {
+                                       final Scheme scheme= definedSchemes[i];
+                                       final Scheme copy= fgLocalBindingManager.getScheme(scheme.getId());
+                                       copy.define(scheme.getName(), scheme.getDescription(), scheme.getParentId());
+                               }
+                       } catch (final NotDefinedException e) {
+                               CUIPlugin.log(e);
+                       }
+               }
+               fgLocalBindingManager.setLocale(bindingService.getLocale());
+               fgLocalBindingManager.setPlatform(bindingService.getPlatform());
+       }
+
+       private static String getKeyboardShortcut(ParameterizedCommand command) {
+               IBindingService bindingService= (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class);
+               fgLocalBindingManager.setBindings(bindingService.getBindings());
+               try {
+                       Scheme activeScheme= bindingService.getActiveScheme();
+                       if (activeScheme != null)
+                               fgLocalBindingManager.setActiveScheme(activeScheme);
+               } catch (NotDefinedException e) {
+                       CUIPlugin.log(e);
+               }
+               
+               TriggerSequence[] bindings= fgLocalBindingManager.getActiveBindingsDisregardingContextFor(command);
+               if (bindings.length > 0)
+                       return bindings[0].format();
+               return null;
+       }
+       
+       private Image getImage(ImageDescriptor imgDesc) {
+               if (imgDesc == null)
+                       return null;
+               
+               Image img= fImages.get(imgDesc);
+               if (img == null) {
+                       img= imgDesc.createImage(false);
+                       fImages.put(imgDesc, img);
+               }
+               return img;
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedPreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedPreferencePage.java
new file mode 100644 (file)
index 0000000..7f3a303
--- /dev/null
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import org.eclipse.core.resources.IProject;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+
+public final class CodeAssistAdvancedPreferencePage extends PropertyAndPreferencePage  {
+
+       private CodeAssistAdvancedConfigurationBlock fConfigurationBlock;
+
+       @Override
+       public void createControl(Composite parent) {
+               IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer();
+               fConfigurationBlock= new CodeAssistAdvancedConfigurationBlock(getNewStatusChangedListener(), container);
+               
+               super.createControl(parent);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.C_EDITOR_PREF_PAGE);
+       }
+
+       @Override
+       protected Control createPreferenceContent(Composite composite) {
+               return fConfigurationBlock.createContents(composite);
+       }
+
+       @Override
+       protected boolean hasProjectSpecificOptions(IProject project) {
+               return false;
+       }
+
+       @Override
+       protected String getPreferencePageID() {
+               return "org.eclipse.cdt.ui.preferences.CodeAssistPreferenceAdvanced"; //$NON-NLS-1$
+       }
+
+       @Override
+       protected String getPropertyPageID() {
+               // no project settings supported
+               return null;
+       }
+       
+       /*
+        * @see org.eclipse.jface.dialogs.DialogPage#dispose()
+        */
+       @Override
+       public void dispose() {
+               if (fConfigurationBlock != null) {
+                       fConfigurationBlock.dispose();
+               }
+               super.dispose();
+       }
+       
+       /*
+        * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
+        */
+       @Override
+       protected void performDefaults() {
+               super.performDefaults();
+               if (fConfigurationBlock != null) {
+                       fConfigurationBlock.performDefaults();
+               }
+       }
+
+       /*
+        * @see org.eclipse.jface.preference.IPreferencePage#performOk()
+        */
+       @Override
+       public boolean performOk() {
+               if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) {
+                       return false;
+               }       
+               return super.performOk();
+       }
+       
+       /*
+        * @see org.eclipse.jface.preference.IPreferencePage#performApply()
+        */
+       @Override
+       public void performApply() {
+               if (fConfigurationBlock != null) {
+                       fConfigurationBlock.performApply();
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistPreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistPreferencePage.java
new file mode 100644 (file)
index 0000000..3dbef4b
--- /dev/null
@@ -0,0 +1,183 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2011 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     IBM Corporation
+ *     Kirk Beitz (Nokia)
+ *     Jens Elmenthaler - http://bugs.eclipse.org/173458 (camel case completion)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.util.ArrayList;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
+
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey;
+import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
+
+/**
+ * CodeAssistPreferencePage
+ */
+public class CodeAssistPreferencePage extends AbstractPreferencePage {
+
+       /**
+        * 
+        */
+       public CodeAssistPreferencePage() {
+               super();
+               //setDescription(PreferencesMessages.getString("CodeAssistPreferencePage.description")); //$NON-NLS-1$
+       }
+
+       @Override
+       protected OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
+               ArrayList<OverlayKey> overlayKeys = new ArrayList<OverlayKey>();
+
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, ContentAssistPreference.AUTOACTIVATION_DELAY));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.AUTOINSERT));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.PREFIX_COMPLETION));
+//             overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, ContentAssistPreference.TIMEOUT_DELAY));              
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOT));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_ARROW));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOUBLECOLON));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW));
+//             overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.SHOW_DOCUMENTED_PROPOSALS));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.ORDER_PROPOSALS));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.SHOW_CAMEL_CASE_MATCHES));
+//             overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.ADD_INCLUDE));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE));        
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.PROJECT_SEARCH_SCOPE));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.PROPOSALS_FILTER));
+
+        OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
+               overlayKeys.toArray(keys);
+               return keys;
+
+       }
+               
+       /*
+        * @see PreferencePage#createControl(Composite)
+        */
+       @Override
+       public void createControl(Composite parent) {
+               super.createControl(parent);            
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.C_EDITOR_CONTENT_ASSIST_PREF_PAGE);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected Control createContents(Composite parent) {
+               fOverlayStore.load();
+               fOverlayStore.start();
+                               
+               Composite contentAssistComposite = new Composite(parent, SWT.NULL);
+               GridLayout layout = new GridLayout();
+               layout.numColumns = 2;
+               contentAssistComposite.setLayout(layout);
+
+               String label;
+               //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
+               // search scope (no longer supported)
+               // The following three radio buttons are grouped together
+//             label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_searchGroupTitle; 
+//             Group searchGroup = addGroupBox(contentAssistComposite, label, 2);
+//             
+//             label= PreferencesMessages.CEditorPreferencePage_ContentAssistPage_searchGroupCurrentFileOption; 
+//             addRadioButton(searchGroup, label, ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE, 0);
+//             
+//             label= PreferencesMessages.CEditorPreferencePage_ContentAssistPage_searchGroupCurrentProjectOption; 
+//             addRadioButton(searchGroup, label, ContentAssistPreference.PROJECT_SEARCH_SCOPE, 0);
+               
+               //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
+               label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_insertionGroupTitle; 
+               Group insertionGroup = addGroupBox(contentAssistComposite, label, 2);
+               
+               label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_insertSingleProposalAutomatically; 
+               addCheckBox(insertionGroup, label, ContentAssistPreference.AUTOINSERT, 0);
+
+               label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_insertCommonProposalAutomatically; 
+               addCheckBox(insertionGroup, label, ContentAssistPreference.PREFIX_COMPLETION, 0);
+
+               //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
+               // sorting and filtering
+               label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_sortingSection_title; 
+               Group sortingGroup = addGroupBox(contentAssistComposite, label, 2);
+
+               label= PreferencesMessages.CEditorPreferencePage_ContentAssistPage_showProposalsInAlphabeticalOrder; 
+               addCheckBox(sortingGroup, label, ContentAssistPreference.ORDER_PROPOSALS, 0);
+
+               label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_proposalFilterSelect ; 
+               addComboBox(sortingGroup, label, ContentAssistPreference.PROPOSALS_FILTER, NO_TEXT_LIMIT, 0);
+
+               label= PreferencesMessages.CEditorPreferencePage_ContentAssistPage_showCamelCaseMatches;
+               addCheckBox(sortingGroup, label, ContentAssistPreference.SHOW_CAMEL_CASE_MATCHES, 0);
+
+               //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
+               // The following items are grouped for Auto Activation
+               label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationGroupTitle; 
+               Group enableGroup = addGroupBox(contentAssistComposite, label, 2);
+               
+               label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationEnableDot; 
+               addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOT, 0);
+
+               label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationEnableArrow; 
+               addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_ARROW, 0);
+               
+               label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationEnableDoubleColon; 
+               addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOUBLECOLON, 0);
+
+               label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationEnableReplaceDotWithArrow;
+               addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW, 0);
+
+               label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationDelay; 
+               addTextField(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_DELAY, 4, 0, true);
+
+               initializeFields();
+
+               return contentAssistComposite;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+        */
+       @Override
+       public void init(IWorkbench workbench) {
+               // Nothing to do.
+       }
+
+       public static void initDefaults(IPreferenceStore store) {
+               store.setDefault(ContentAssistPreference.CURRENT_FILE_SEARCH_SCOPE, true);
+               store.setDefault(ContentAssistPreference.PROJECT_SEARCH_SCOPE, false);
+
+               store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOT, true);
+               store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_ARROW, true);
+               store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOUBLECOLON, true);
+               store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW, true);
+               store.setDefault(ContentAssistPreference.AUTOACTIVATION_DELAY, 500);
+
+               store.setDefault(ContentAssistPreference.AUTOINSERT, true);
+               store.setDefault(ContentAssistPreference.PREFIX_COMPLETION, true);
+               store.setDefault(ContentAssistPreference.ORDER_PROPOSALS, false);
+               store.setDefault(ContentAssistPreference.PROPOSALS_FILTER, ProposalFilterPreferencesUtil.getProposalFilternamesAsString());  // $NON_NLS 1$
+               store.setDefault(ContentAssistPreference.SHOW_CAMEL_CASE_MATCHES, true);
+               
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeFormatterPreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeFormatterPreferencePage.java
new file mode 100644 (file)
index 0000000..792ec6c
--- /dev/null
@@ -0,0 +1,161 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Sergey Prigogin, Google
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences;
+
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.preference.IPreferencePageContainer;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
+import org.eclipse.ui.preferences.IWorkingCopyManager;
+import org.eclipse.ui.preferences.WorkingCopyManager;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.preferences.formatter.CodeFormatterConfigurationBlock;
+
+/*
+ * The page to configure the code formatter options.
+ */
+public class CodeFormatterPreferencePage extends PropertyAndPreferencePage {
+
+       public static final String PREF_ID= "org.eclipse.cdt.ui.preferences.CodeFormatterPreferencePage"; //$NON-NLS-1$
+       public static final String PROP_ID= "org.eclipse.cdt.ui.propertyPages.CodeFormatterPreferencePage"; //$NON-NLS-1$
+       
+       private CodeFormatterConfigurationBlock fConfigurationBlock;
+
+       public CodeFormatterPreferencePage() {
+               setDescription(PreferencesMessages.CodeFormatterPreferencePage_description); 
+               
+               // only used when page is shown programatically
+               setTitle(PreferencesMessages.CodeFormatterPreferencePage_title);                 
+       }
+
+       /*
+        * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       public void createControl(Composite parent) {
+               IPreferencePageContainer container= getContainer();
+               IWorkingCopyManager workingCopyManager;
+               if (container instanceof IWorkbenchPreferenceContainer) {
+                       workingCopyManager= ((IWorkbenchPreferenceContainer) container).getWorkingCopyManager();
+               } else {
+                       workingCopyManager= new WorkingCopyManager(); // non shared 
+               }
+               PreferencesAccess access= PreferencesAccess.getWorkingCopyPreferences(workingCopyManager);
+               fConfigurationBlock= new CodeFormatterConfigurationBlock(getProject(), access);
+               
+               super.createControl(parent);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.CODEFORMATTER_PREFERENCE_PAGE);
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#createPreferenceContent(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected Control createPreferenceContent(Composite composite) {
+               return fConfigurationBlock.createContents(composite);
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#hasProjectSpecificOptions(org.eclipse.core.resources.IProject)
+        */
+       @Override
+       protected boolean hasProjectSpecificOptions(IProject project) {
+               return fConfigurationBlock.hasProjectSpecificOptions(project);
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#enableProjectSpecificSettings(boolean)
+        */
+       @Override
+       protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
+               super.enableProjectSpecificSettings(useProjectSpecificSettings);
+               if (fConfigurationBlock != null) {
+                       fConfigurationBlock.enableProjectSpecificSettings(useProjectSpecificSettings);
+               }
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
+        */
+       @Override
+       protected String getPreferencePageID() {
+               return PREF_ID;
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
+        */
+       @Override
+       protected String getPropertyPageID() {
+               return PROP_ID;
+       }
+       
+       /*
+        * @see org.eclipse.jface.dialogs.DialogPage#dispose()
+        */
+       @Override
+       public void dispose() {
+               if (fConfigurationBlock != null) {
+                       fConfigurationBlock.dispose();
+               }
+               super.dispose();
+       }
+       
+       /*
+        * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
+        */
+       @Override
+       protected void performDefaults() {
+               if (fConfigurationBlock != null) {
+                       fConfigurationBlock.performDefaults();
+               }
+               super.performDefaults();
+       }
+
+       /*
+        * @see org.eclipse.jface.preference.IPreferencePage#performOk()
+        */
+       @Override
+       public boolean performOk() {
+               if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) {
+                       return false;
+               }       
+               return super.performOk();
+       }
+       
+       /*
+        * @see org.eclipse.jface.preference.IPreferencePage#performOk()
+        */
+       @Override
+       public void performApply() {
+               if (fConfigurationBlock != null) {
+                       fConfigurationBlock.performApply();
+               }       
+               super.performApply();
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#setElement(org.eclipse.core.runtime.IAdaptable)
+        */
+       @Override
+       public void setElement(IAdaptable element) {
+               super.setElement(element);
+               setDescription(null); // no description for property page
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateBlock.java
new file mode 100644 (file)
index 0000000..e081001
--- /dev/null
@@ -0,0 +1,846 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Andrew Ferguson (Symbian)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.text.templates.ContextTypeRegistry;
+import org.eclipse.jface.text.templates.Template;
+import org.eclipse.jface.text.templates.TemplateContextType;
+import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData;
+import org.eclipse.jface.text.templates.persistence.TemplateReaderWriter;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+import org.eclipse.cdt.internal.corext.template.c.CodeTemplateContextType;
+import org.eclipse.cdt.internal.corext.template.c.FileTemplateContextType;
+import org.eclipse.cdt.internal.corext.util.Messages;
+
+import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
+import org.eclipse.cdt.internal.ui.editor.CSourceViewer;
+import org.eclipse.cdt.internal.ui.text.CTextTools;
+import org.eclipse.cdt.internal.ui.text.template.TemplateVariableProcessor;
+import org.eclipse.cdt.internal.ui.viewsupport.ProjectTemplateStore;
+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.ITreeListAdapter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
+
+/**
+ */
+public class CodeTemplateBlock extends OptionsConfigurationBlock {
+       
+       private class CodeTemplateAdapter extends ViewerComparator
+                       implements ITreeListAdapter<Object>, IDialogFieldListener {
+               private final Object[] NO_CHILDREN= new Object[0];
+
+               public void customButtonPressed(TreeListDialogField<Object> field, int index) {
+                       doButtonPressed(index, field.getSelectedElements());
+               }
+               
+               public void selectionChanged(TreeListDialogField<Object> field) {
+                       List<Object> selected= field.getSelectedElements();
+                       field.enableButton(IDX_ADD, canAdd(selected));
+                       field.enableButton(IDX_EDIT, canEdit(selected));
+                       field.enableButton(IDX_REMOVE, canRemove(selected));
+                       field.enableButton(IDX_EXPORT, !selected.isEmpty());
+                       
+                       updateSourceViewerInput(selected);
+               }
+
+               public void doubleClicked(TreeListDialogField<Object> field) {
+                       List<Object> selected= field.getSelectedElements();
+                       if (canEdit(selected)) {
+                               doButtonPressed(IDX_EDIT, selected);
+                       }
+               }
+
+               public Object[] getChildren(TreeListDialogField<Object> field, Object element) {
+                       if (element == COMMENT_NODE || element == CODE_NODE) {
+                               return getCodeTemplatesOfCategory(element == COMMENT_NODE);
+                       } else if (element == FILE_NODE) {
+                               return getFileTemplateContextTypes();
+                       } else if (element instanceof TemplateContextType) {
+                               return getTemplatesOfContextType(((TemplateContextType) element).getId());
+                       }
+                       return NO_CHILDREN;
+               }
+
+               public Object getParent(TreeListDialogField<Object> field, Object element) {
+                       if (element instanceof TemplatePersistenceData) {
+                               TemplatePersistenceData data= (TemplatePersistenceData) element;
+                               if (data.getTemplate().getName().endsWith(CodeTemplateContextType.COMMENT_SUFFIX)) {
+                                       return COMMENT_NODE;
+                               }
+                               if (FileTemplateContextType.isFileTemplateContextType(data.getTemplate().getContextTypeId())) {
+                                       return getFileTemplateContextRegistry().getContextType(data.getTemplate().getContextTypeId());
+                               }
+                               return CODE_NODE;
+                       } else if (element instanceof TemplateContextType) {
+                               return FILE_NODE;
+                       }
+                       return null;
+               }
+
+               public boolean hasChildren(TreeListDialogField<Object> field, Object element) {
+                       return (element == COMMENT_NODE || element == CODE_NODE || element == FILE_NODE || element instanceof TemplateContextType);
+               }
+
+               public void dialogFieldChanged(DialogField field) {
+                       if (field == fGenerateComments) {
+                               setValue(PREF_GENERATE_COMMENTS, fGenerateComments.isSelected());
+                       }
+               }
+
+               public void keyPressed(TreeListDialogField<Object> field, KeyEvent event) {
+               }
+               
+               /*
+                * @see org.eclipse.jface.viewers.ViewerComparator#category(java.lang.Object)
+                */
+               @Override
+               public int category(Object element) {
+                       if (element == COMMENT_NODE) {
+                               return 1;
+                       } else if (element == CODE_NODE) {
+                               return 2;
+                       } else if (element == FILE_NODE) {
+                               return 3;
+                       } else if (element instanceof TemplateContextType) {
+                               TemplateContextType type= (TemplateContextType) element;
+                               String id= type.getId();
+                               if (CodeTemplateContextType.CPPSOURCEFILE_CONTEXTTYPE.equals(id)) {
+                                       return 1;
+                               } else if (CodeTemplateContextType.CPPHEADERFILE_CONTEXTTYPE.equals(id)) {
+                                       return 2;
+                               } else if (CodeTemplateContextType.CSOURCEFILE_CONTEXTTYPE.equals(id)) {
+                                       return 10;
+                               } else if (CodeTemplateContextType.CHEADERFILE_CONTEXTTYPE.equals(id)) {
+                                       return 11;
+                               } else if (CodeTemplateContextType.ASMSOURCEFILE_CONTEXTTYPE.equals(id)) {
+                                       return 100;
+                               } else if (id.startsWith("org.eclipse.cdt.")) { //$NON-NLS-1$
+                                       return 101;
+                               }
+                               return 1000;
+                       }
+                       
+                       TemplatePersistenceData data= (TemplatePersistenceData) element;
+                       String id= data.getId();
+                       
+                       if (CodeTemplateContextType.ASMSOURCEFILE_CONTEXTTYPE.equals(id)) {
+                               return 105;
+                       } else if (CodeTemplateContextType.NAMESPACE_BEGIN_ID.equals(id)) {
+                               return 106;
+                       } else if (CodeTemplateContextType.NAMESPACE_END_ID.equals(id)) {
+                               return 107;
+                       } else if (CodeTemplateContextType.CLASS_BODY_ID.equals(id)) {
+                               return 108;
+                       } else if (CodeTemplateContextType.METHODSTUB_ID.equals(id)) {
+                               return 109;
+                       } else if (CodeTemplateContextType.CONSTRUCTORSTUB_ID.equals(id)) {
+                               return 110;
+                       } else if (CodeTemplateContextType.DESTRUCTORSTUB_ID.equals(id)) {
+                               return 111;
+                       } else if (CodeTemplateContextType.FILECOMMENT_ID.equals(id)) {
+                               return 1;
+                       } else if (CodeTemplateContextType.TYPECOMMENT_ID.equals(id)) {
+                               return 2;
+                       } else if (CodeTemplateContextType.FIELDCOMMENT_ID.equals(id)) {
+                               return 3;
+                       } else if (CodeTemplateContextType.METHODCOMMENT_ID.equals(id)) {
+                               return 4;
+                       } else if (CodeTemplateContextType.CONSTRUCTORCOMMENT_ID.equals(id)) {
+                               return 5;
+                       } else if (CodeTemplateContextType.DESTRUCTORCOMMENT_ID.equals(id)) {
+                               return 6;
+                       }
+                       return 1000;
+               }
+       }
+
+       private static class CodeTemplateLabelProvider extends LabelProvider {
+               /*
+                * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
+                */
+               @Override
+               public Image getImage(Object element) {
+//                     if (element == COMMENT_NODE || element == CODE_NODE || element == FILE_NODE) {
+//                             return null;
+//                     }
+//                     if (element instanceof TemplateContextType) {
+//                             String id= ((TemplateContextType)element).getId();
+//                             if (FileTemplateContextType.isFileTemplateContextType(id)) {
+//                                     IContentType contentType= FileTemplateContextType.getContentTypeFromConextType(id);
+//                                     if (contentType != null) {
+//                                             String dummyFileName;
+//                                             String[] fileSpecs= contentType.getFileSpecs(IContentType.FILE_NAME_SPEC);
+//                                             if (fileSpecs.length > 0) {
+//                                                     dummyFileName= fileSpecs[0];
+//                                             } else {
+//                                                     String[] extSpecs= contentType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
+//                                                     if (extSpecs.length > 0) {
+//                                                             dummyFileName= "dummy" + extSpecs[0]; //$NON-NLS-1$
+//                                                     } else {
+//                                                             dummyFileName= "dummy"; //$NON-NLS-1$
+//                                                     }
+//                                             }
+//                                             IEditorRegistry editorRegistry= PlatformUI.getWorkbench().getEditorRegistry();
+//                                             IEditorDescriptor[] editorDesc= editorRegistry.getEditors(dummyFileName, contentType);
+//                                             if (editorDesc.length > 0) {
+//                                                     ImageDescriptor desc= editorDesc[0].getImageDescriptor();
+//                                                     return CUIPlugin.getImageDescriptorRegistry().get(desc);
+//                                             }
+//                                     }
+//                             }
+//                     }
+                       return null;
+               }
+
+               /*
+                * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
+                */
+               @Override
+               public String getText(Object element) {
+                       if (element == COMMENT_NODE || element == CODE_NODE || element == FILE_NODE) {
+                               return (String) element;
+                       }
+                       if (element instanceof TemplateContextType) {
+                               return ((TemplateContextType) element).getName();
+                       }
+                       TemplatePersistenceData data= (TemplatePersistenceData) element;
+                       String id= data.getId();
+                       if (FileTemplateContextType.isFileTemplateContextType(data.getTemplate().getContextTypeId())) {
+                               return data.getTemplate().getName();
+                       } else if (CodeTemplateContextType.NAMESPACE_BEGIN_ID.equals(id)) {
+                               return PreferencesMessages.CodeTemplateBlock_namespace_begin_label;
+                       } else if (CodeTemplateContextType.NAMESPACE_END_ID.equals(id)) {
+                               return PreferencesMessages.CodeTemplateBlock_namespace_end_label;
+                       } else if (CodeTemplateContextType.CLASS_BODY_ID.equals(id)) {
+                               return PreferencesMessages.CodeTemplateBlock_class_body_label;
+                       } else if (CodeTemplateContextType.CONSTRUCTORSTUB_ID.equals(id)) {
+                               return PreferencesMessages.CodeTemplateBlock_constructorstub_label;
+                       } else if (CodeTemplateContextType.DESTRUCTORSTUB_ID.equals(id)) {
+                               return PreferencesMessages.CodeTemplateBlock_destructorstub_label;
+                       } else if (CodeTemplateContextType.METHODSTUB_ID.equals(id)) {
+                               return PreferencesMessages.CodeTemplateBlock_methodstub_label;
+                       } else if (CodeTemplateContextType.FILECOMMENT_ID.equals(id)) {
+                               return PreferencesMessages.CodeTemplateBlock_filecomment_label;
+                       } else if (CodeTemplateContextType.TYPECOMMENT_ID.equals(id)) {
+                               return PreferencesMessages.CodeTemplateBlock_typecomment_label;
+                       } else if (CodeTemplateContextType.FIELDCOMMENT_ID.equals(id)) {
+                               return PreferencesMessages.CodeTemplateBlock_fieldcomment_label;
+                       } else if (CodeTemplateContextType.METHODCOMMENT_ID.equals(id)) {
+                               return PreferencesMessages.CodeTemplateBlock_methodcomment_label;
+                       } else if (CodeTemplateContextType.CONSTRUCTORCOMMENT_ID.equals(id)) {
+                               return PreferencesMessages.CodeTemplateBlock_constructorcomment_label;
+                       } else if (CodeTemplateContextType.DESTRUCTORCOMMENT_ID.equals(id)) {
+                               return PreferencesMessages.CodeTemplateBlock_destructorcomment_label;
+                       }
+                       return data.getTemplate().getName();
+               }
+       }               
+       
+       private static final Key PREF_GENERATE_COMMENTS= getCDTUIKey(PreferenceConstants.CODEGEN_ADD_COMMENTS);
+       
+       private static Key[] getAllKeys() {
+               return new Key[] {
+                       PREF_GENERATE_COMMENTS
+               };      
+       }       
+       
+       private final static int IDX_ADD= 0;
+       private final static int IDX_EDIT= 1;
+       private final static int IDX_REMOVE= 2;
+       private final static int IDX_IMPORT= 3;
+       private final static int IDX_EXPORT= 4;
+       private final static int IDX_EXPORTALL= 5;
+       
+       protected final static Object COMMENT_NODE= PreferencesMessages.CodeTemplateBlock_templates_comment_node; 
+       protected final static Object CODE_NODE= PreferencesMessages.CodeTemplateBlock_templates_code_node; 
+       protected final static Object FILE_NODE= PreferencesMessages.CodeTemplateBlock_templates_file_node; 
+
+       private TreeListDialogField<Object> fCodeTemplateTree;
+       private SelectionButtonDialogField fGenerateComments;
+       
+       protected ProjectTemplateStore fTemplateStore;
+       
+       private PixelConverter fPixelConverter;
+       private SourceViewer fPatternViewer;
+
+       private TemplateVariableProcessor fTemplateProcessor;
+       private ContextTypeRegistry fFileTemplateContextTypes;
+       
+       public CodeTemplateBlock(IStatusChangeListener context, IProject project,
+                       IWorkbenchPreferenceContainer container) {
+               super(context, project, getAllKeys(), container);
+               
+               fTemplateStore= new ProjectTemplateStore(project);
+               try {
+                       fTemplateStore.load();
+               } catch (IOException e) {
+                       CUIPlugin.log(e);
+               }
+               
+               fTemplateProcessor= new TemplateVariableProcessor();
+               
+               CodeTemplateAdapter adapter= new CodeTemplateAdapter();
+
+               String[] buttonLabels= new String[] {
+                       PreferencesMessages.CodeTemplateBlock_templates_new_button,     
+                       PreferencesMessages.CodeTemplateBlock_templates_edit_button,
+                       PreferencesMessages.CodeTemplateBlock_templates_remove_button,  
+                       PreferencesMessages.CodeTemplateBlock_templates_import_button, 
+                       PreferencesMessages.CodeTemplateBlock_templates_export_button, 
+                       PreferencesMessages.CodeTemplateBlock_templates_exportall_button
+               };              
+               fCodeTemplateTree= new TreeListDialogField<Object>(adapter, buttonLabels, new CodeTemplateLabelProvider());
+               fCodeTemplateTree.setDialogFieldListener(adapter);
+               fCodeTemplateTree.setLabelText(PreferencesMessages.CodeTemplateBlock_templates_label);
+               fCodeTemplateTree.setViewerComparator(adapter);
+
+               fCodeTemplateTree.enableButton(IDX_EXPORT, false);
+               fCodeTemplateTree.enableButton(IDX_ADD, false);
+               fCodeTemplateTree.enableButton(IDX_EDIT, false);
+               fCodeTemplateTree.enableButton(IDX_REMOVE, false);
+               
+               fCodeTemplateTree.addElement(COMMENT_NODE);
+               fCodeTemplateTree.addElement(CODE_NODE);
+               fCodeTemplateTree.addElement(FILE_NODE);
+
+               fCodeTemplateTree.selectFirstElement(); 
+               
+               fGenerateComments= new SelectionButtonDialogField(SWT.CHECK | SWT.WRAP);
+               fGenerateComments.setDialogFieldListener(adapter);
+               fGenerateComments.setLabelText(PreferencesMessages.CodeTemplateBlock_createcomment_label); 
+               
+               updateControls();
+       }
+
+       public void postSetSelection(Object element) {
+               fCodeTemplateTree.postSetSelection(new StructuredSelection(element));
+       }
+
+       @Override
+       public boolean hasProjectSpecificOptions(IProject project) {
+               if (super.hasProjectSpecificOptions(project))
+                       return true;
+               
+               if (project != null) {
+                       return ProjectTemplateStore.hasProjectSpecificTempates(project);
+               }
+               return false;
+       }       
+       
+       @Override
+       protected Control createContents(Composite parent) {
+               fPixelConverter=  new PixelConverter(parent);
+
+               setShell(parent.getShell());
+               
+               Composite composite=  new Composite(parent, SWT.NONE);
+               composite.setFont(parent.getFont());
+               
+               GridLayout layout= new GridLayout();
+               layout.marginHeight= 0;
+               layout.marginWidth= 0;
+               layout.numColumns= 2;
+               composite.setLayout(layout);
+               
+               fCodeTemplateTree.doFillIntoGrid(composite, 3);
+               LayoutUtil.setHorizontalSpan(fCodeTemplateTree.getLabelControl(null), 2);
+               LayoutUtil.setHorizontalGrabbing(fCodeTemplateTree.getTreeControl(null), true);
+               
+               fPatternViewer= createViewer(composite, 2);
+               
+               fGenerateComments.doFillIntoGrid(composite, 2);
+               
+               return composite;
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock#updateControls()
+        */
+       @Override
+       protected void updateControls() {
+               fGenerateComments.setSelection(getBooleanValue(PREF_GENERATE_COMMENTS));
+       }
+       
+       private SourceViewer createViewer(Composite parent, int nColumns) {
+               Label label= new Label(parent, SWT.NONE);
+               label.setText(PreferencesMessages.CodeTemplateBlock_preview); 
+               GridData data= new GridData();
+               data.horizontalSpan= nColumns;
+               label.setLayoutData(data);
+               
+               IDocument document= new Document();
+               CTextTools tools= CUIPlugin.getDefault().getTextTools();
+               tools.setupCDocumentPartitioner(document, ICPartitions.C_PARTITIONING, null);
+               IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
+               SourceViewer viewer= new CSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store);
+               CodeTemplateSourceViewerConfiguration configuration= new CodeTemplateSourceViewerConfiguration(tools.getColorManager(), store, null, fTemplateProcessor);
+               viewer.configure(configuration);
+               viewer.setEditable(false);
+               viewer.setDocument(document);
+       
+               Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
+               viewer.getTextWidget().setFont(font);
+               new CSourcePreviewerUpdater(viewer, configuration, store);
+               
+               Control control= viewer.getControl();
+               data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
+               data.horizontalSpan= nColumns;
+               data.heightHint= fPixelConverter.convertHeightInCharsToPixels(5);
+               control.setLayoutData(data);
+               
+               return viewer;
+       }
+
+       private void reconfigurePatternViewer() {
+               if (fPatternViewer == null)
+                       return;
+               CTextTools tools= CUIPlugin.getDefault().getTextTools();
+               IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
+               CodeTemplateSourceViewerConfiguration configuration= new CodeTemplateSourceViewerConfiguration(tools.getColorManager(), store, null, fTemplateProcessor);
+               fPatternViewer.unconfigure();
+               fPatternViewer.configure(configuration);
+               fPatternViewer.invalidateTextPresentation();
+       }
+
+       protected TemplatePersistenceData[] getCodeTemplatesOfCategory(boolean isComment) {
+               ArrayList<TemplatePersistenceData> res=  new ArrayList<TemplatePersistenceData>();
+               TemplatePersistenceData[] templates= fTemplateStore.getTemplateData();
+               for (TemplatePersistenceData curr : templates) {
+                       boolean isUserAdded= curr.getId() == null;
+                       boolean isFileTemplate= FileTemplateContextType.isFileTemplateContextType(curr.getTemplate().getContextTypeId());
+                       if (!isUserAdded && !isFileTemplate && isComment == curr.getTemplate().getName().endsWith(CodeTemplateContextType.COMMENT_SUFFIX)) {
+                               res.add(curr);
+                       }
+               }
+               return res.toArray(new TemplatePersistenceData[res.size()]);
+       }
+       
+       private TemplatePersistenceData[] getTemplatesOfContextType(TemplateContextType contextType) {
+               return getTemplatesOfContextType(contextType.getId());
+       }
+
+       protected TemplatePersistenceData[] getTemplatesOfContextType(String contextTypeId) {
+               ArrayList<TemplatePersistenceData> res=  new ArrayList<TemplatePersistenceData>();
+               TemplatePersistenceData[] templates= fTemplateStore.getTemplateData();
+               for (TemplatePersistenceData curr : templates) {
+                       if (contextTypeId.equals(curr.getTemplate().getContextTypeId())) {
+                               res.add(curr);
+                       }
+               }
+               return res.toArray(new TemplatePersistenceData[res.size()]);
+       }
+
+       protected ContextTypeRegistry getFileTemplateContextRegistry() {
+               if (fFileTemplateContextTypes == null) {
+                       fFileTemplateContextTypes= new ContextTypeRegistry();
+                       Iterator<?> contextTypesIter= CUIPlugin.getDefault().getCodeTemplateContextRegistry().contextTypes();
+                       while(contextTypesIter.hasNext()) {
+                               TemplateContextType contextType= (TemplateContextType)contextTypesIter.next();
+                               final String contextTypeId= contextType.getId();
+                               // add if at least one template registered
+                               if (FileTemplateContextType.isFileTemplateContextType(contextTypeId)) {
+                                       fFileTemplateContextTypes.addContextType(contextType);
+                               }
+                       }
+               }
+               return fFileTemplateContextTypes;
+       }
+       
+       protected TemplateContextType[] getFileTemplateContextTypes() {
+               Iterator<?> iter= getFileTemplateContextRegistry().contextTypes();
+               ArrayList<TemplateContextType> result= new ArrayList<TemplateContextType>();
+               while (iter.hasNext()) {
+                       TemplateContextType contextType= (TemplateContextType)iter.next();
+                       if (getTemplatesOfContextType(contextType).length > 0) {
+                               result.add(contextType);
+                       }
+               }
+               return result.toArray(new TemplateContextType[0]);
+       }
+
+       protected static boolean canAdd(List<Object> selected) {
+               if (selected.size() == 1) {
+                       Object element= selected.get(0);
+                       if (element instanceof TemplateContextType || element == FILE_NODE) {
+                               return true;
+                       }
+                       if (element instanceof TemplatePersistenceData) {
+                               TemplatePersistenceData data = (TemplatePersistenceData) element;
+                               if (FileTemplateContextType.isFileTemplateContextType(data.getTemplate().getContextTypeId())) {
+                                       return true;
+                               }
+                       }
+               }
+               return false;
+       }       
+       
+       protected static boolean canEdit(List<Object> selected) {
+               return selected.size() == 1 && (selected.get(0) instanceof TemplatePersistenceData);
+       }       
+       
+       protected static boolean canRemove(List<Object> selected) {
+               if (selected.size() == 1 && (selected.get(0) instanceof TemplatePersistenceData)) {
+                       TemplatePersistenceData data= (TemplatePersistenceData)selected.get(0);
+                       return data.isUserAdded();
+               }
+               return false;
+       }
+       
+       protected void updateSourceViewerInput(List<Object> selection) {
+               if (fPatternViewer == null || fPatternViewer.getTextWidget().isDisposed()) {
+                       return;
+               }
+               if (selection.size() == 1 && selection.get(0) instanceof TemplatePersistenceData) {
+                       TemplatePersistenceData data= (TemplatePersistenceData) selection.get(0);
+                       Template template= data.getTemplate();
+                       TemplateContextType type= CUIPlugin.getDefault().getCodeTemplateContextRegistry().getContextType(template.getContextTypeId());
+                       fTemplateProcessor.setContextType(type);
+                       reconfigurePatternViewer();
+                       fPatternViewer.getDocument().set(template.getPattern());
+               } else {
+                       fPatternViewer.getDocument().set(""); //$NON-NLS-1$
+               }               
+       }
+
+       protected void doButtonPressed(int buttonIndex, List<Object> selected) {
+               switch (buttonIndex) {
+               case IDX_EDIT:
+                       edit((TemplatePersistenceData) selected.get(0), false);
+                       break;
+               case IDX_ADD: {
+                       Object element= selected.get(0);
+                       Template orig= null;
+                       String contextTypeId;
+                       if (element instanceof TemplatePersistenceData) {
+                               orig= ((TemplatePersistenceData)element).getTemplate();
+                               contextTypeId= orig.getContextTypeId();
+                       } else if (element instanceof TemplateContextType) {
+                               TemplateContextType type= (TemplateContextType)selected.get(0);
+                               contextTypeId= type.getId();
+                       } else {
+                               // default: text file
+                               contextTypeId= FileTemplateContextType.TEXTFILE_CONTEXTTYPE;
+                       }
+                       Template newTemplate;
+                       if (orig != null) {
+                               newTemplate= new Template("", "", contextTypeId, orig.getPattern(), false);  //$NON-NLS-1$//$NON-NLS-2$
+                       } else {
+                               newTemplate= new Template("", "", contextTypeId, "", false);   //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+                       }
+                       TemplatePersistenceData newData= new TemplatePersistenceData(newTemplate, true);
+                       edit(newData, true);
+                       break;
+               }
+               case IDX_REMOVE:
+                       remove((TemplatePersistenceData) selected.get(0));
+                       break;
+               case IDX_EXPORT:
+                       export(selected);
+                       break;
+               case IDX_EXPORTALL:
+                       exportAll();
+                       break;
+               case IDX_IMPORT:
+                       import_();
+                       break;
+               }
+       }
+       
+       private void remove(TemplatePersistenceData data) {
+               if (data.isUserAdded()) {
+                       fTemplateStore.delete(data);
+                       fCodeTemplateTree.refresh();
+               }
+       }
+
+       private void edit(TemplatePersistenceData data, boolean isNew) {
+               Template newTemplate= new Template(data.getTemplate());
+               boolean isFileTemplate= FileTemplateContextType.isFileTemplateContextType(newTemplate.getContextTypeId());
+               ContextTypeRegistry contextTypeRegistry;
+               if (isFileTemplate) {
+                       contextTypeRegistry= getFileTemplateContextRegistry();
+               } else {
+                       contextTypeRegistry= CUIPlugin.getDefault().getCodeTemplateContextRegistry();
+               }
+               EditTemplateDialog dialog= new EditTemplateDialog(getShell(), newTemplate, !isNew, data.isUserAdded(), isFileTemplate, contextTypeRegistry);
+               if (dialog.open() == Window.OK) {
+                       // changed
+                       data.setTemplate(dialog.getTemplate());
+                       if (isNew) {
+                               // add to store
+                               fTemplateStore.addTemplateData(data);
+                       }
+                       if (isNew || isFileTemplate) {
+                               fCodeTemplateTree.refresh();
+                       } else {
+                               fCodeTemplateTree.refresh(data);
+                       }
+                       fCodeTemplateTree.selectElements(new StructuredSelection(data));
+               }
+       }
+               
+       private void import_() {
+               FileDialog dialog= new FileDialog(getShell());
+               dialog.setText(PreferencesMessages.CodeTemplateBlock_import_title); 
+               dialog.setFilterExtensions(new String[] {PreferencesMessages.CodeTemplateBlock_import_extension}); 
+               String path= dialog.open();
+               
+               if (path == null)
+                       return;
+               
+               try {
+                       TemplateReaderWriter reader= new TemplateReaderWriter();
+                       File file= new File(path);
+                       if (file.exists()) {
+                               InputStream input= new BufferedInputStream(new FileInputStream(file));
+                               try {
+                                       TemplatePersistenceData[] datas= reader.read(input, null);
+                                       for (TemplatePersistenceData data : datas) {
+                                               updateTemplate(data);
+                                       }
+                               } finally {
+                                       try {
+                                               input.close();
+                                       } catch (IOException x) {
+                                       }
+                               }
+                       }
+
+                       fCodeTemplateTree.refresh();
+                       updateSourceViewerInput(fCodeTemplateTree.getSelectedElements());
+               } catch (FileNotFoundException e) {
+                       openReadErrorDialog(e);
+               } catch (IOException e) {
+                       openReadErrorDialog(e);
+               }
+       }
+       
+       private void updateTemplate(TemplatePersistenceData data) {
+               String dataId= data.getId();
+               TemplatePersistenceData[] datas= fTemplateStore.getTemplateData();
+               if (dataId != null) {
+                       // predefined
+                       for (TemplatePersistenceData data2 : datas) {
+                               String id= data2.getId();
+                               if (id != null && id.equals(dataId)) {
+                                       data2.setTemplate(data.getTemplate());
+                                       return;
+                               }
+                       }
+               } else {
+                       // user added
+                       String dataName= data.getTemplate().getName();
+                       for (TemplatePersistenceData data2 : datas) {
+                               if (data2.getId() == null) {
+                                       String name= data2.getTemplate().getName();
+                                       String contextTypeId= data2.getTemplate().getContextTypeId();
+                                       if (name != null && name.equals(dataName) && contextTypeId.equals(data.getTemplate().getContextTypeId())) {
+                                               data2.setTemplate(data.getTemplate());
+                                               return;
+                                       }
+                               }
+                       }
+                       // new
+                       fTemplateStore.addTemplateData(data);
+               }
+       }
+       
+       private void exportAll() {
+               export(fTemplateStore.getTemplateData());       
+       }
+       
+       private void export(List<Object> selected) {
+               Set<Object> datas= new HashSet<Object>();
+               for (int i= 0; i < selected.size(); i++) {
+                       Object curr= selected.get(i);
+                       if (curr instanceof TemplatePersistenceData) {
+                               datas.add(curr);
+                       } else if (curr instanceof TemplateContextType) {
+                               TemplatePersistenceData[] cat= getTemplatesOfContextType((TemplateContextType)curr);
+                               datas.addAll(Arrays.asList(cat));
+                       } else if (curr == FILE_NODE) {
+                               TemplateContextType[] types= getFileTemplateContextTypes();
+                               for (TemplateContextType contextType : types) {
+                                       TemplatePersistenceData[] cat= getTemplatesOfContextType(contextType);
+                                       datas.addAll(Arrays.asList(cat));
+                               }
+                       } else if (curr == COMMENT_NODE || curr == CODE_NODE) {
+                               TemplatePersistenceData[] cat= getCodeTemplatesOfCategory(curr == COMMENT_NODE);
+                               datas.addAll(Arrays.asList(cat));
+                       }
+               }
+               export(datas.toArray(new TemplatePersistenceData[datas.size()]));
+       }
+       
+       private void export(TemplatePersistenceData[] templates) {
+               FileDialog dialog= new FileDialog(getShell(), SWT.SAVE);
+               dialog.setText(Messages.format(PreferencesMessages.CodeTemplateBlock_export_title, String.valueOf(templates.length))); 
+               dialog.setFilterExtensions(new String[] {PreferencesMessages.CodeTemplateBlock_export_extension}); 
+               dialog.setFileName(PreferencesMessages.CodeTemplateBlock_export_filename); 
+               String path= dialog.open();
+
+               if (path == null)
+                       return;
+               
+               File file= new File(path);              
+
+               if (file.isHidden()) {
+                       String title= PreferencesMessages.CodeTemplateBlock_export_error_title; 
+                       String message= Messages.format(PreferencesMessages.CodeTemplateBlock_export_error_hidden, file.getAbsolutePath()); 
+                       MessageDialog.openError(getShell(), title, message);
+                       return;
+               }
+               
+               if (file.exists() && !file.canWrite()) {
+                       String title= PreferencesMessages.CodeTemplateBlock_export_error_title; 
+                       String message= Messages.format(PreferencesMessages.CodeTemplateBlock_export_error_canNotWrite, file.getAbsolutePath()); 
+                       MessageDialog.openError(getShell(), title, message);
+                       return;
+               }
+
+               if (!file.exists() || confirmOverwrite(file)) {
+                       OutputStream output= null;
+                       try {
+                               output= new BufferedOutputStream(new FileOutputStream(file));
+                               TemplateReaderWriter writer= new TemplateReaderWriter();
+                               writer.save(templates, output);
+                               output.close();
+                       } catch (IOException e) {
+                               if (output != null) {
+                                       try {
+                                               output.close();
+                                       } catch (IOException e2) {
+                                               // ignore 
+                                       }
+                               }
+                               openWriteErrorDialog();
+                       }
+               }
+       }
+
+       private boolean confirmOverwrite(File file) {
+               return MessageDialog.openQuestion(getShell(),
+                       PreferencesMessages.CodeTemplateBlock_export_exists_title, 
+                       Messages.format(PreferencesMessages.CodeTemplateBlock_export_exists_message, file.getAbsolutePath())); 
+       }
+
+       @Override
+       public void performDefaults() {
+               super.performDefaults();
+               fTemplateStore.restoreDefaults();
+               
+               // refresh
+               fCodeTemplateTree.refresh();
+               updateSourceViewerInput(fCodeTemplateTree.getSelectedElements());
+       }
+       
+       public boolean performOk(boolean enabled) {
+               boolean res= super.performOk();
+               if (!res)
+                       return false;
+               
+               if (fProject != null) {
+                       TemplatePersistenceData[] templateData= fTemplateStore.getTemplateData();
+                       for (TemplatePersistenceData element : templateData) {
+                               fTemplateStore.setProjectSpecific(element.getId(), enabled);
+                       }
+               }
+               try {
+                       fTemplateStore.save();
+               } catch (IOException e) {
+                       CUIPlugin.log(e);
+                       openWriteErrorDialog();
+               }
+               return true;
+       }
+       
+       public void performCancel() {
+               try {
+                       fTemplateStore.revertChanges();
+               } catch (IOException e) {
+                       openReadErrorDialog(e);
+               }
+       }
+       
+       private void openReadErrorDialog(Exception e) {
+               String title= PreferencesMessages.CodeTemplateBlock_error_read_title; 
+               
+               String message= e.getLocalizedMessage();
+               if (message != null)
+                       message= Messages.format(PreferencesMessages.CodeTemplateBlock_error_parse_message, message); 
+               else
+                       message= PreferencesMessages.CodeTemplateBlock_error_read_message; 
+               MessageDialog.openError(getShell(), title, message);
+       }
+       
+       private void openWriteErrorDialog() {
+               String title= PreferencesMessages.CodeTemplateBlock_error_write_title; 
+               String message= PreferencesMessages.CodeTemplateBlock_error_write_message; 
+               MessageDialog.openError(getShell(), title, message);
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock#validateSettings(java.lang.String, java.lang.String)
+        */
+       @Override
+       protected void validateSettings(Key changedKey, String oldValue, String newValue) {
+               // no validation here
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplatePreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplatePreferencePage.java
new file mode 100644 (file)
index 0000000..e4eb29a
--- /dev/null
@@ -0,0 +1,177 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
+
+/*
+ * The page to configure the code templates.
+ */
+public class CodeTemplatePreferencePage extends PropertyAndPreferencePage {
+       public static final String PREF_ID= "org.eclipse.cdt.ui.preferences.CodeTemplatePreferencePage"; //$NON-NLS-1$
+       public static final String PROP_ID= "org.eclipse.cdt.ui.propertyPages.CodeTemplatePreferencePage"; //$NON-NLS-1$
+       
+       public static final String DATA_SELECT_TEMPLATE= "CodeTemplatePreferencePage.select_template"; //$NON-NLS-1$
+       
+       private CodeTemplateBlock fCodeTemplateConfigurationBlock;
+
+       public CodeTemplatePreferencePage() {
+               setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
+               // Only used when page is shown programmatically
+               setTitle(PreferencesMessages.CodeTemplatesPreferencePage_title);                 
+       }
+
+       /*
+        * @see PreferencePage#createControl(Composite)
+        */
+       @Override
+       public void createControl(Composite parent) {
+               IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer();
+               fCodeTemplateConfigurationBlock= new CodeTemplateBlock(getNewStatusChangedListener(),
+                               getProject(), container);
+               
+               super.createControl(parent);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
+                               ICHelpContextIds.CODE_TEMPLATES_PREFERENCE_PAGE);
+       }       
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#createPreferenceContent(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected Control createPreferenceContent(Composite composite) {
+               return fCodeTemplateConfigurationBlock.createContents(composite);
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#enableProjectSpecificSettings(boolean)
+        */
+       @Override
+       protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
+               super.enableProjectSpecificSettings(useProjectSpecificSettings);
+               if (fCodeTemplateConfigurationBlock != null) {
+                       fCodeTemplateConfigurationBlock.useProjectSpecificSettings(useProjectSpecificSettings);
+               }
+       }
+       
+       /*
+        * @see IPreferencePage#performOk()
+        */
+       @Override
+       public boolean performOk() {
+               if (fCodeTemplateConfigurationBlock != null) {
+                       return fCodeTemplateConfigurationBlock.performOk(useProjectSettings());
+               }
+               return true;
+       }
+       
+       /*
+        * @see PreferencePage#performDefaults()
+        */
+       @Override
+       protected void performDefaults() {
+               super.performDefaults();
+               if (fCodeTemplateConfigurationBlock != null) {
+                       fCodeTemplateConfigurationBlock.performDefaults();
+               }
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.DialogPage#dispose()
+        */
+       @Override
+       public void dispose() {
+               if (fCodeTemplateConfigurationBlock != null) {
+                       fCodeTemplateConfigurationBlock.dispose();
+               }
+               super.dispose();
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.wizards.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus)
+        */
+       public void statusChanged(IStatus status) {
+               setValid(!status.matches(IStatus.ERROR));
+               StatusUtil.applyToStatusLine(this, status);             
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.preference.IPreferencePage#performCancel()
+        */
+       @Override
+       public boolean performCancel() {
+               if (fCodeTemplateConfigurationBlock != null) {
+                       fCodeTemplateConfigurationBlock.performCancel();
+               }
+               return super.performCancel();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#hasProjectSpecificOptions(org.eclipse.core.resources.IProject)
+        */
+       @Override
+       protected boolean hasProjectSpecificOptions(IProject project) {
+               return fCodeTemplateConfigurationBlock.hasProjectSpecificOptions(project);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
+        */
+       @Override
+       protected String getPreferencePageID() {
+               return PREF_ID;
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
+        */
+       @Override
+       protected String getPropertyPageID() {
+               return null;
+               // TODO project specific settings
+//             return PROP_ID;
+       }
+
+       /*
+        * @see org.eclipse.jface.preference.PreferencePage#applyData(java.lang.Object)
+        */
+       @Override
+       public void applyData(Object data) {
+               if (data instanceof Map<?, ?>) {
+                       Object id= ((Map<?, ?>) data).get(DATA_SELECT_TEMPLATE);
+                       if (id instanceof String) {
+                               final TemplatePersistenceData[] templates=
+                                               fCodeTemplateConfigurationBlock.fTemplateStore.getTemplateData();
+                               for (TemplatePersistenceData template : templates) {
+                                       if (id.equals(template.getId()) || id.equals(template.getTemplate().getName())) {
+                                               fCodeTemplateConfigurationBlock.postSetSelection(template);
+                                               break;
+                                       }
+                               }
+                       }
+               }
+               super.applyData(data);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateSourceViewerConfiguration.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateSourceViewerConfiguration.java
new file mode 100644 (file)
index 0000000..c382062
--- /dev/null
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.util.Iterator;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DefaultInformationControl;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IInformationControl;
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextHover;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ContentAssistant;
+import org.eclipse.jface.text.contentassist.IContentAssistant;
+import org.eclipse.jface.text.presentation.IPresentationReconciler;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.templates.TemplateContextType;
+import org.eclipse.jface.text.templates.TemplateVariableResolver;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.ICPartitions;
+import org.eclipse.cdt.ui.text.IColorManager;
+
+import org.eclipse.cdt.internal.corext.template.c.CodeTemplateContextType;
+
+import org.eclipse.cdt.internal.ui.text.CWordFinder;
+import org.eclipse.cdt.internal.ui.text.SimpleCSourceViewerConfiguration;
+import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
+import org.eclipse.cdt.internal.ui.text.template.TemplateVariableProcessor;
+
+
+public class CodeTemplateSourceViewerConfiguration extends SimpleCSourceViewerConfiguration {
+
+       private static class TemplateVariableTextHover implements ITextHover {
+
+               private TemplateVariableProcessor fProcessor;
+
+               /**
+                * @param processor the template variable processor
+                */
+               public TemplateVariableTextHover(TemplateVariableProcessor processor) {
+                       fProcessor= processor;
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.text.ITextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
+                */
+               public String getHoverInfo(ITextViewer textViewer, IRegion subject) {
+                       try {
+                               IDocument doc= textViewer.getDocument();
+                               int offset= subject.getOffset();
+                               if (offset >= 2 && "${".equals(doc.get(offset-2, 2))) { //$NON-NLS-1$
+                                       String varName= doc.get(offset, subject.getLength());
+                                       TemplateContextType contextType= fProcessor.getContextType();
+                                       if (contextType != null) {
+                                               Iterator<?> iter= contextType.resolvers();
+                                               while (iter.hasNext()) {
+                                                       TemplateVariableResolver var= (TemplateVariableResolver) iter.next();
+                                                       if (varName.equals(var.getType())) {
+                                                               return var.getDescription();
+                                                       }
+                                               }
+                                       }
+                               }                               
+                       } catch (BadLocationException e) {
+                       }
+                       return null;
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.text.ITextHover#getHoverRegion(org.eclipse.jface.text.ITextViewer, int)
+                */
+               public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
+                       if (textViewer != null) {
+                               return CWordFinder.findWord(textViewer.getDocument(), offset);
+                       }
+                       return null;    
+               }
+               
+       } 
+       
+       private final TemplateVariableProcessor fProcessor;
+
+       public CodeTemplateSourceViewerConfiguration(IColorManager colorManager, IPreferenceStore store, ITextEditor editor, TemplateVariableProcessor processor) {
+               super(colorManager, store, editor, ICPartitions.C_PARTITIONING, false);
+               fProcessor= processor;
+       }
+       
+       /*
+        * @see SourceViewerConfiguration#getContentAssistant(ISourceViewer)
+        */
+       @Override
+       public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
+
+               IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+               
+
+               ContentAssistant assistant= new ContentAssistant();
+               assistant.setContentAssistProcessor(fProcessor, IDocument.DEFAULT_CONTENT_TYPE);
+                       // Register the same processor for strings and single line comments to get code completion at the start of those partitions.
+               assistant.setContentAssistProcessor(fProcessor, ICPartitions.C_STRING);
+               assistant.setContentAssistProcessor(fProcessor, ICPartitions.C_CHARACTER);
+               assistant.setContentAssistProcessor(fProcessor, ICPartitions.C_SINGLE_LINE_COMMENT);
+               assistant.setContentAssistProcessor(fProcessor, ICPartitions.C_MULTI_LINE_COMMENT);
+               assistant.setContentAssistProcessor(fProcessor, ICPartitions.C_PREPROCESSOR);
+
+               ContentAssistPreference.configure(assistant, store);
+
+               assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
+               assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
+               assistant.setInformationControlCreator(new IInformationControlCreator() {
+                       public IInformationControl createInformationControl(Shell parent) {
+                               return new DefaultInformationControl(parent, false);
+                       }
+               });
+
+               return assistant;
+       }       
+
+       /*
+        * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String, int)
+        */
+       @Override
+       public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) {
+               return new TemplateVariableTextHover(fProcessor);
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration#getPresentationReconciler(org.eclipse.jface.text.source.ISourceViewer)
+        */
+       @Override
+       public IPresentationReconciler getPresentationReconciler( ISourceViewer sourceViewer) {
+               if (fProcessor.getContextType() instanceof CodeTemplateContextType) {
+                       return super.getPresentationReconciler(sourceViewer);
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ColorSettingPreviewCode.txt b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ColorSettingPreviewCode.txt
new file mode 100644 (file)
index 0000000..bf98516
--- /dev/null
@@ -0,0 +1,26 @@
+/* This is sample C++ code */
+#include <cstdio>
+#define MACRO(x) x
+using namespace std;
+// This comment may span only this line
+typedef unsigned int uint;
+int static myfunc(uint parameter) {
+  if (parameter == 0) fprintf(stdout, "zero\n");
+  cout << "hello\n";
+  return parameter - 1;
+}
+class MyClass {
+public:
+  enum Number { ZERO, ONE, TWO };
+  static char staticField;
+  int field;
+  virtual Number vmethod();
+  void method(Number n) const {
+    int local= (int)MACRO('\0');
+label: myfunc(local);
+    vmethod();
+    staticMethod();
+    problem();
+  }
+  static void staticMethod();
+};
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog.java
new file mode 100644 (file)
index 0000000..f340225
--- /dev/null
@@ -0,0 +1,668 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.expressions.Expression;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.commands.ActionHandler;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.StatusDialog;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextListener;
+import org.eclipse.jface.text.ITextOperationTarget;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.TextEvent;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.text.templates.ContextTypeRegistry;
+import org.eclipse.jface.text.templates.Template;
+import org.eclipse.jface.text.templates.TemplateContextType;
+import org.eclipse.jface.text.templates.TemplateException;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Widget;
+import org.eclipse.ui.ActiveShellExpression;
+import org.eclipse.ui.IWorkbenchCommandConstants;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.IHandlerActivation;
+import org.eclipse.ui.handlers.IHandlerService;
+import org.eclipse.ui.texteditor.ITextEditorActionConstants;
+import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
+import org.eclipse.ui.texteditor.IUpdate;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.IContextMenuConstants;
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.editor.CSourceViewer;
+import org.eclipse.cdt.internal.ui.text.CTextTools;
+import org.eclipse.cdt.internal.ui.text.template.TemplateVariableProcessor;
+
+/**
+ * Dialog to edit a template.
+ * @since 5.2
+ */
+public class EditTemplateDialog extends StatusDialog {
+
+       private static class TextViewerAction extends Action implements IUpdate {
+       
+               private int fOperationCode= -1;
+               private ITextOperationTarget fOperationTarget;
+       
+               /**
+                * Creates a new action.
+                * 
+                * @param viewer the viewer
+                * @param operationCode the opcode
+                */
+               public TextViewerAction(ITextViewer viewer, int operationCode) {
+                       fOperationCode= operationCode;
+                       fOperationTarget= viewer.getTextOperationTarget();
+                       update();
+               }
+       
+               /**
+                * Updates the enabled state of the action.
+                * Fires a property change if the enabled state changes.
+                * 
+                * @see Action#firePropertyChange(String, Object, Object)
+                */
+               public void update() {
+                       // XXX: workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=206111
+                       if (fOperationCode == ITextOperationTarget.REDO)
+                               return;
+
+                       boolean wasEnabled= isEnabled();
+                       boolean isEnabled= (fOperationTarget != null && fOperationTarget.canDoOperation(fOperationCode));
+                       setEnabled(isEnabled);
+       
+                       if (wasEnabled != isEnabled) {
+                               firePropertyChange(ENABLED, wasEnabled ? Boolean.TRUE : Boolean.FALSE, isEnabled ? Boolean.TRUE : Boolean.FALSE);
+                       }
+               }
+               
+               /**
+                * @see Action#run()
+                */
+               @Override
+               public void run() {
+                       if (fOperationCode != -1 && fOperationTarget != null) {
+                               fOperationTarget.doOperation(fOperationCode);
+                       }
+               }
+       }
+
+       private Template fTemplate;
+       
+       private Text fNameText;
+       private Text fDescriptionText;
+       private Combo fContextCombo;
+       private SourceViewer fPatternEditor;
+       private Button fInsertVariableButton;
+       private Button fAutoInsertCheckbox;
+       private boolean fIsNameModifiable;
+       private boolean fIsContextTypeModifiable;
+
+       private StatusInfo fValidationStatus;
+       private boolean fSuppressError= true; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=4354
+       private Map<String, TextViewerAction> fGlobalActions= new HashMap<String, TextViewerAction>(10);
+       private List<String> fSelectionActions = new ArrayList<String>(3);
+       private String[][] fContextTypes;
+       
+       private ContextTypeRegistry fContextTypeRegistry;
+       
+       private final TemplateVariableProcessor fTemplateProcessor= new TemplateVariableProcessor();
+
+       /**
+        * Creates a new dialog.
+        * 
+        * @param parent the shell parent of the dialog
+        * @param template the template to edit
+        * @param edit whether this is a new template or an existing being edited
+        * @param isNameModifiable whether the name of the template may be modified
+        * @param isContextTypeModifiable whether the context type of the template may be modified
+        * @param registry the context type registry to use
+        */
+       public EditTemplateDialog(Shell parent, Template template, boolean edit, boolean isNameModifiable, boolean isContextTypeModifiable, ContextTypeRegistry registry) {
+               super(parent);
+               
+               String title= edit
+                       ? PreferencesMessages.EditTemplateDialog_title_edit
+                       : PreferencesMessages.EditTemplateDialog_title_new;
+               setTitle(title);
+
+               fTemplate= template;
+               fIsNameModifiable= isNameModifiable;
+               fIsContextTypeModifiable= isContextTypeModifiable;
+       
+//             String delim= new Document().getLegalLineDelimiters()[0];
+               
+               List<String[]> contexts= new ArrayList<String[]>();
+               for (Iterator<?> it= registry.contextTypes(); it.hasNext();) {
+                       TemplateContextType type= (TemplateContextType) it.next();
+                       // TODO cppdoc? doxygen?
+//                     if (type.getId().equals("javadoc")) //$NON-NLS-1$
+//                             contexts.add(new String[] { type.getId(), type.getName(), "/**" + delim }); //$NON-NLS-1$
+//                     else
+                               contexts.add(0, new String[] { type.getId(), type.getName(), "" }); //$NON-NLS-1$
+               }
+               Collections.sort(contexts, new Comparator<String[]>() {
+                       public int compare(String[] s1, String[] s2) {
+                               return s1[1].compareTo(s2[1]);
+                       }});
+               fContextTypes= contexts.toArray(new String[contexts.size()][]);
+               
+               fValidationStatus= new StatusInfo();
+               
+               fContextTypeRegistry= registry;
+               
+               TemplateContextType type= fContextTypeRegistry.getContextType(template.getContextTypeId());
+               fTemplateProcessor.setContextType(type);
+       }
+
+       /*
+        * @see org.eclipse.jface.dialogs.Dialog#isResizable()
+        */
+       @Override
+       protected boolean isResizable() {
+               return true;
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.dialogs.StatusDialog#create()
+        */
+       @Override
+       public void create() {
+               super.create();
+               updateStatusAndButtons();
+               getButton(IDialogConstants.OK_ID).setEnabled(getStatus().isOK());
+       }
+       
+       /*
+        * @see Dialog#createDialogArea(Composite)
+        */
+       @Override
+       protected Control createDialogArea(Composite ancestor) {
+               Composite parent= new Composite(ancestor, SWT.NONE);
+               GridLayout layout= new GridLayout();
+               layout.numColumns= 2;
+               parent.setLayout(layout);
+               parent.setLayoutData(new GridData(GridData.FILL_BOTH));
+               
+               ModifyListener listener= new ModifyListener() {
+                       public void modifyText(ModifyEvent e) {
+                               doTextWidgetChanged(e.widget);
+                       }
+               };
+               
+               if (fIsNameModifiable) {
+                       createLabel(parent, PreferencesMessages.EditTemplateDialog_name);
+                       
+                       Composite composite= new Composite(parent, SWT.NONE);
+                       composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+                       layout= new GridLayout();
+                       layout.numColumns= fIsContextTypeModifiable ? 3 : 1;
+                       layout.marginWidth= 0;
+                       layout.marginHeight= 0;
+                       composite.setLayout(layout);
+                       
+                       fNameText= createText(composite);
+                       fNameText.addFocusListener(new FocusListener() {
+                               
+                               public void focusGained(FocusEvent e) {
+                               }
+                               
+                               public void focusLost(FocusEvent e) {
+                                       if (fSuppressError) {
+                                               fSuppressError= false;
+                                               updateStatusAndButtons();
+                                       }
+                               }
+                       });
+                       
+                       if (fIsContextTypeModifiable) {
+                               createLabel(composite, PreferencesMessages.EditTemplateDialog_contextType);
+                               fContextCombo= new Combo(composite, SWT.READ_ONLY);
+                               fContextCombo.setVisibleItemCount(10);
+                               for (String[] contextType : fContextTypes) {
+                                       fContextCombo.add(contextType[1]);
+                               }
+               
+                               fContextCombo.addModifyListener(listener);
+                               
+//                             fAutoInsertCheckbox= createCheckbox(composite, PreferencesMessages.EditTemplateDialog_autoinsert);
+//                             fAutoInsertCheckbox.setSelection(fTemplate.isAutoInsertable());
+                       }
+               }
+               
+               createLabel(parent, PreferencesMessages.EditTemplateDialog_description);
+               
+               int descFlags= fIsNameModifiable ? SWT.BORDER : SWT.BORDER | SWT.READ_ONLY;
+               fDescriptionText= new Text(parent, descFlags );
+               fDescriptionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               
+               fDescriptionText.addModifyListener(listener);
+
+               Label patternLabel= createLabel(parent, PreferencesMessages.EditTemplateDialog_pattern);
+               patternLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+               fPatternEditor= createEditor(parent);
+               
+               Label filler= new Label(parent, SWT.NONE);
+               filler.setLayoutData(new GridData());
+               
+               Composite composite= new Composite(parent, SWT.NONE);
+               layout= new GridLayout();
+               layout.marginWidth= 0;
+               layout.marginHeight= 0;
+               composite.setLayout(layout);
+               composite.setLayoutData(new GridData());
+               
+               fInsertVariableButton= new Button(composite, SWT.NONE);
+               fInsertVariableButton.setLayoutData(getButtonGridData());
+               fInsertVariableButton.setText(PreferencesMessages.EditTemplateDialog_insert_variable);
+               fInsertVariableButton.addSelectionListener(new SelectionListener() {
+                       public void widgetSelected(SelectionEvent e) {
+                               fPatternEditor.getTextWidget().setFocus();
+                               fPatternEditor.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
+                       }
+
+                       public void widgetDefaultSelected(SelectionEvent e) {}
+               });
+
+               fDescriptionText.setText(fTemplate.getDescription());
+               if (fIsNameModifiable) {
+                       fNameText.setText(fTemplate.getName());
+                       fNameText.addModifyListener(listener);
+                       if (fContextCombo != null) {
+                               fContextCombo.select(getIndex(fTemplate.getContextTypeId()));
+                       }
+               } else {
+                       fPatternEditor.getControl().setFocus();
+               }
+               initializeActions();
+
+               applyDialogFont(parent);
+               return composite;
+       }
+       
+       protected void doTextWidgetChanged(Widget w) {
+               if (w == fNameText) {
+                       fSuppressError= false;
+                       updateStatusAndButtons();
+               } else if (w == fContextCombo) {
+                       String contextId= getContextId();
+                       fTemplateProcessor.setContextType(fContextTypeRegistry.getContextType(contextId));
+                       reconfigurePatternEditor();
+                       IDocument document= fPatternEditor.getDocument();
+                       String prefix= getPrefix();
+                       document.set(prefix + getPattern());
+                       fPatternEditor.setVisibleRegion(prefix.length(), document.getLength() - prefix.length());
+                       updateStatusAndButtons();
+               } else if (w == fDescriptionText) {
+                       // nothing
+               }
+       }
+       
+       private String getContextId() {
+               if (fContextCombo != null && !fContextCombo.isDisposed()) {
+                       String name= fContextCombo.getText();
+                       for (String[] contextType : fContextTypes) {
+                               if (name.equals(contextType[1])) {
+                                       return contextType[0];
+                               }
+                       }
+               }
+               
+               return fTemplate.getContextTypeId();
+       }
+
+       protected void doSourceChanged(IDocument document) {
+               String text= document.get();
+               fValidationStatus.setOK();
+               TemplateContextType contextType= fContextTypeRegistry.getContextType(getContextId());
+               if (contextType != null) {
+                       try {
+                               contextType.validate(text);
+                       } catch (TemplateException e) {
+                               fValidationStatus.setError(e.getLocalizedMessage());
+                       }
+               }
+
+               updateAction(ITextEditorActionConstants.UNDO);
+               updateStatusAndButtons();
+       }
+
+       private static GridData getButtonGridData() {
+               GridData data= new GridData(GridData.FILL_HORIZONTAL);
+               return data;
+       }
+
+       private static Label createLabel(Composite parent, String name) {
+               Label label= new Label(parent, SWT.NULL);
+               label.setText(name);
+               label.setLayoutData(new GridData());
+
+               return label;
+       }
+
+//     private static Button createCheckbox(Composite parent, String name) {
+//             Button button= new Button(parent, SWT.CHECK);
+//             button.setText(name);
+//             button.setLayoutData(new GridData());
+//             
+//             return button;
+//     }
+       
+       private Text createText(Composite parent) {
+               Text text= new Text(parent, SWT.BORDER);
+               final GridData gd= new GridData(GridData.FILL_HORIZONTAL);
+               gd.widthHint= convertWidthInCharsToPixels(20);
+               text.setLayoutData(gd);
+               return text;
+       }
+
+       private SourceViewer createEditor(Composite parent) {
+               String prefix= getPrefix();
+               IDocument document= new Document(prefix + fTemplate.getPattern());
+               CTextTools tools= CUIPlugin.getDefault().getTextTools();
+               tools.setupCDocumentPartitioner(document, ICPartitions.C_PARTITIONING, null);
+               IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
+               SourceViewer viewer= new CSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store);
+               CodeTemplateSourceViewerConfiguration configuration= new CodeTemplateSourceViewerConfiguration(tools.getColorManager(), store, null, fTemplateProcessor);
+               viewer.configure(configuration);
+               viewer.setEditable(true);
+               viewer.setDocument(document, prefix.length(), document.getLength() - prefix.length());
+               
+               Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
+               viewer.getTextWidget().setFont(font);
+               new CSourcePreviewerUpdater(viewer, configuration, store);
+               
+               int nLines= document.getNumberOfLines();
+               if (nLines < 5) {
+                       nLines= 5;
+               } else if (nLines > 12) {
+                       nLines= 12;
+               }
+
+               Control control= viewer.getControl();
+               GridData data= new GridData(GridData.FILL_BOTH);
+               data.widthHint= convertWidthInCharsToPixels(80);
+               data.heightHint= convertHeightInCharsToPixels(nLines);
+               control.setLayoutData(data);
+               
+               viewer.addTextListener(new ITextListener() {
+                       public void textChanged(TextEvent event) {
+                               if (event .getDocumentEvent() != null)
+                                       doSourceChanged(event.getDocumentEvent().getDocument());
+                       }
+               });
+
+               viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+                       public void selectionChanged(SelectionChangedEvent event) {
+                               updateSelectionDependentActions();
+                       }
+               });
+
+               return viewer;
+       }
+
+       private void reconfigurePatternEditor() {
+               if (fPatternEditor == null)
+                       return;
+               CTextTools tools= CUIPlugin.getDefault().getTextTools();
+               IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
+               CodeTemplateSourceViewerConfiguration configuration= new CodeTemplateSourceViewerConfiguration(tools.getColorManager(), store, null, fTemplateProcessor);
+               fPatternEditor.unconfigure();
+               fPatternEditor.configure(configuration);
+               fPatternEditor.invalidateTextPresentation();
+       }
+       
+       private String getPrefix() {
+               String id= getContextId();
+               int idx= getIndex(id);
+               if (idx != -1)
+                       return fContextTypes[idx][2];
+               return ""; //$NON-NLS-1$
+       }
+
+       private void initializeActions() {
+               final ArrayList<IHandlerActivation> handlerActivations= new ArrayList<IHandlerActivation>(3);
+               final IHandlerService handlerService= (IHandlerService) PlatformUI.getWorkbench().getAdapter(IHandlerService.class);
+               getShell().addDisposeListener(new DisposeListener() {
+                       public void widgetDisposed(DisposeEvent e) {
+                               handlerService.deactivateHandlers(handlerActivations);
+                       }
+               });
+               
+               Expression expression= new ActiveShellExpression(fPatternEditor.getControl().getShell());
+
+               TextViewerAction action= new TextViewerAction(fPatternEditor, ITextOperationTarget.UNDO);
+               action.setText(PreferencesMessages.EditTemplateDialog_undo);
+               fGlobalActions.put(ITextEditorActionConstants.UNDO, action);
+               handlerActivations.add(handlerService.activateHandler(IWorkbenchCommandConstants.EDIT_UNDO, new ActionHandler(action), expression));
+
+               action= new TextViewerAction(fPatternEditor, ITextOperationTarget.REDO);
+               action.setText(PreferencesMessages.EditTemplateDialog_redo);
+               fGlobalActions.put(ITextEditorActionConstants.REDO, action);
+               handlerActivations.add(handlerService.activateHandler(IWorkbenchCommandConstants.EDIT_REDO, new ActionHandler(action), expression));
+
+               action= new TextViewerAction(fPatternEditor, ITextOperationTarget.CUT);
+               action.setText(PreferencesMessages.EditTemplateDialog_cut);
+               fGlobalActions.put(ITextEditorActionConstants.CUT, action);
+
+               action= new TextViewerAction(fPatternEditor, ITextOperationTarget.COPY);
+               action.setText(PreferencesMessages.EditTemplateDialog_copy);
+               fGlobalActions.put(ITextEditorActionConstants.COPY, action);
+
+               action= new TextViewerAction(fPatternEditor, ITextOperationTarget.PASTE);
+               action.setText(PreferencesMessages.EditTemplateDialog_paste);
+               fGlobalActions.put(ITextEditorActionConstants.PASTE, action);
+
+               action= new TextViewerAction(fPatternEditor, ITextOperationTarget.SELECT_ALL);
+               action.setText(PreferencesMessages.EditTemplateDialog_select_all);
+               fGlobalActions.put(ITextEditorActionConstants.SELECT_ALL, action);
+
+               action= new TextViewerAction(fPatternEditor, ISourceViewer.CONTENTASSIST_PROPOSALS);
+               action.setText(PreferencesMessages.EditTemplateDialog_content_assist);
+               fGlobalActions.put("ContentAssistProposal", action); //$NON-NLS-1$
+               handlerActivations.add(handlerService.activateHandler(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, new ActionHandler(action), expression));
+
+               fSelectionActions.add(ITextEditorActionConstants.CUT);
+               fSelectionActions.add(ITextEditorActionConstants.COPY);
+               fSelectionActions.add(ITextEditorActionConstants.PASTE);
+               
+               // create context menu
+               MenuManager manager= new MenuManager(null, null);
+               manager.setRemoveAllWhenShown(true);
+               manager.addMenuListener(new IMenuListener() {
+                       public void menuAboutToShow(IMenuManager mgr) {
+                               fillContextMenu(mgr);
+                       }
+               });
+
+               StyledText text= fPatternEditor.getTextWidget();
+               Menu menu= manager.createContextMenu(text);
+               text.setMenu(menu);
+       }
+
+       private void fillContextMenu(IMenuManager menu) {
+               menu.add(new GroupMarker(ITextEditorActionConstants.GROUP_UNDO));
+               menu.appendToGroup(ITextEditorActionConstants.GROUP_UNDO, fGlobalActions.get(ITextEditorActionConstants.UNDO));
+               menu.appendToGroup(ITextEditorActionConstants.GROUP_UNDO, fGlobalActions.get(ITextEditorActionConstants.REDO));
+               
+               menu.add(new Separator(ITextEditorActionConstants.GROUP_EDIT));
+               menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, fGlobalActions.get(ITextEditorActionConstants.CUT));
+               menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, fGlobalActions.get(ITextEditorActionConstants.COPY));
+               menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, fGlobalActions.get(ITextEditorActionConstants.PASTE));
+               menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, fGlobalActions.get(ITextEditorActionConstants.SELECT_ALL));
+
+               menu.add(new Separator(IContextMenuConstants.GROUP_GENERATE));
+               menu.appendToGroup(IContextMenuConstants.GROUP_GENERATE, fGlobalActions.get("ContentAssistProposal")); //$NON-NLS-1$
+       }
+       
+
+       protected void updateSelectionDependentActions() {
+               Iterator<String> iterator= fSelectionActions.iterator();
+               while (iterator.hasNext())
+                       updateAction(iterator.next());
+       }
+
+       protected void updateAction(String actionId) {
+               IAction action= fGlobalActions.get(actionId);
+               if (action instanceof IUpdate)
+                       ((IUpdate) action).update();
+       }
+
+       private int getIndex(String contextid) {
+               
+               if (contextid == null)
+                       return -1;
+               
+               for (int i= 0; i < fContextTypes.length; i++) {
+                       if (contextid.equals(fContextTypes[i][0])) {
+                               return i;
+                       }
+               }
+               return -1;
+       }
+       
+       @Override
+       protected void okPressed() {
+               String name= fNameText == null ? fTemplate.getName() : fNameText.getText();
+               boolean isAutoInsertable= fAutoInsertCheckbox != null && fAutoInsertCheckbox.getSelection();
+               fTemplate= new Template(name, fDescriptionText.getText(), getContextId(), getPattern(), isAutoInsertable);
+               super.okPressed();
+       }
+       
+       private void updateStatusAndButtons() {
+               StatusInfo status= fValidationStatus;
+               boolean isEmpty= fNameText != null && fNameText.getText().length() == 0;
+               if (!fSuppressError && isEmpty) {
+                       status= new StatusInfo();
+                       status.setError(PreferencesMessages.EditTemplateDialog_error_noname);
+               } else if (fNameText != null && !isValidTemplateName(fNameText.getText())) {
+                       status= new StatusInfo();
+                       status.setError(PreferencesMessages.EditTemplateDialog_error_invalidName);
+               }
+               updateStatus(status);
+       }
+
+       /**
+        * Checks whether the given string is a valid
+        * template name.
+        * 
+        * @param name the string to test
+        * @return <code>true</code> if the name is valid
+        */
+       private boolean isValidTemplateName(String name) {
+               return true;
+       }
+
+       /*
+        * @see org.eclipse.jface.window.Window#configureShell(Shell)
+        */
+       @Override
+       protected void configureShell(Shell newShell) {
+               super.configureShell(newShell);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, ICHelpContextIds.EDIT_TEMPLATE_DIALOG);
+       }
+
+       /**
+        * Returns the created template.
+        * 
+        * @return the created template
+        */
+       public Template getTemplate() {
+               return fTemplate;
+       }
+       
+       private String getPattern() {
+               IDocument doc= fPatternEditor.getDocument();
+               IRegion visible= fPatternEditor.getVisibleRegion();
+               try {
+                       return doc.get(visible.getOffset(), doc.getLength() - visible.getOffset());
+               } catch (BadLocationException e) {
+                       return ""; //$NON-NLS-1$
+               }
+       }
+       
+       /*
+        * @see org.eclipse.jface.dialogs.Dialog#getInitialSize()
+        */
+       @Override
+       protected Point getInitialSize() {
+               Point defaultSize= getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
+               Point restoredSize= super.getInitialSize();
+               if (defaultSize.x > restoredSize.x) {
+                       restoredSize.x= defaultSize.x;
+               }
+               return restoredSize;
+       }
+
+       /*
+        * @see org.eclipse.jface.dialogs.Dialog#getDialogBoundsSettings()
+        */
+       @Override
+       protected IDialogSettings getDialogBoundsSettings() {
+               String sectionName= getClass().getName() + "_dialogBounds"; //$NON-NLS-1$
+               IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings();
+               IDialogSettings section= settings.getSection(sectionName);
+               if (section == null)
+                       section= settings.addNewSection(sectionName);
+               return section;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBlock.java
new file mode 100644 (file)
index 0000000..f25c708
--- /dev/null
@@ -0,0 +1,363 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StackLayout;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.folding.ICFoldingPreferenceBlock;
+
+import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey;
+import org.eclipse.cdt.internal.ui.text.folding.CFoldingStructureProviderDescriptor;
+import org.eclipse.cdt.internal.ui.text.folding.CFoldingStructureProviderRegistry;
+
+/**
+ * Configures C Editor folding preferences.
+ * 
+ * @since 3.0
+ */
+class FoldingConfigurationBlock implements IPreferenceConfigurationBlock {
+       
+       private static class ErrorPreferences implements ICFoldingPreferenceBlock {
+               private String fMessage;
+               
+               protected ErrorPreferences(String message) {
+                       fMessage= message;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.text.folding.ICFoldingPreferences#createControl(org.eclipse.swt.widgets.Group)
+                */
+               public Control createControl(Composite composite) {
+                       Composite inner= new Composite(composite, SWT.NONE);
+                       inner.setLayout(new FillLayout(SWT.VERTICAL));
+
+                       Label label= new Label(inner, SWT.CENTER);
+                       label.setText(fMessage);
+                       
+                       return inner;
+               }
+
+               public void initialize() {
+               }
+
+               public void performOk() {
+               }
+
+               public void performDefaults() {
+               }
+
+               public void dispose() {
+               }
+               
+       }
+
+       /** The overlay preference store. */
+       protected final OverlayPreferenceStore fStore;
+       
+       /* The controls */
+       private Combo fProviderCombo;
+       protected Button fFoldingCheckbox;
+       private ComboViewer fProviderViewer;
+       protected Map<String, CFoldingStructureProviderDescriptor> fProviderDescriptors;
+       private Composite fGroup;
+       private Map<String, ICFoldingPreferenceBlock> fProviderPreferences;
+       private Map<String, Control> fProviderControls;
+       private StackLayout fStackLayout;
+       
+
+       public FoldingConfigurationBlock(OverlayPreferenceStore store) {
+               Assert.isNotNull(store);
+               fStore= store;
+               fStore.addKeys(createOverlayStoreKeys());
+               fProviderDescriptors= createListModel();
+               fProviderPreferences= new HashMap<String, ICFoldingPreferenceBlock>();
+               fProviderControls= new HashMap<String, Control>();
+       }
+
+       private Map<String, CFoldingStructureProviderDescriptor> createListModel() {
+               CFoldingStructureProviderRegistry reg= CUIPlugin.getDefault().getFoldingStructureProviderRegistry();
+               reg.reloadExtensions();
+               CFoldingStructureProviderDescriptor[] descs= reg.getFoldingProviderDescriptors();
+               Map<String, CFoldingStructureProviderDescriptor> map= new HashMap<String, CFoldingStructureProviderDescriptor>();
+               for (int i= 0; i < descs.length; i++) {
+                       map.put(descs[i].getId(), descs[i]);
+               }
+               return map;
+       }
+
+       private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
+               
+               ArrayList<OverlayKey> overlayKeys= new ArrayList<OverlayKey>();
+
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_ENABLED));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_FOLDING_PROVIDER));
+               
+               OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
+               overlayKeys.toArray(keys);
+               return keys;
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#createControl(org.eclipse.swt.widgets.Composite)
+        */
+       public Control createControl(Composite parent) {
+
+               Composite composite= new Composite(parent, SWT.NULL);
+               // assume parent page uses griddata
+               GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_FILL);
+               composite.setLayoutData(gd);
+               GridLayout layout= new GridLayout();
+               layout.numColumns= 2;
+               PixelConverter pc= new PixelConverter(composite);
+               layout.verticalSpacing= pc.convertHeightInCharsToPixels(1) / 2;
+               composite.setLayout(layout);
+               
+               
+               /* check box for new editors */
+               fFoldingCheckbox= new Button(composite, SWT.CHECK);
+               fFoldingCheckbox.setText(PreferencesMessages.FoldingConfigurationBlock_enable); 
+               gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
+               fFoldingCheckbox.setLayoutData(gd);
+               fFoldingCheckbox.addSelectionListener(new SelectionListener() {
+                       public void widgetSelected(SelectionEvent e) {
+                               boolean enabled= fFoldingCheckbox.getSelection(); 
+                               fStore.setValue(PreferenceConstants.EDITOR_FOLDING_ENABLED, enabled);
+                               updateCheckboxDependencies();
+                       }
+
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                       }
+               });
+               
+               Label label= new Label(composite, SWT.CENTER);
+               gd= new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
+               label.setLayoutData(gd);
+
+               /* list */
+               Composite comboComp= new Composite(composite, SWT.NONE);
+               gd= new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
+               GridLayout gridLayout= new GridLayout(2, false);
+               gridLayout.marginWidth= 0;
+               comboComp.setLayout(gridLayout);
+               
+               Label comboLabel= new Label(comboComp, SWT.CENTER);
+               gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_CENTER);
+               comboLabel.setLayoutData(gd);
+               comboLabel.setText(PreferencesMessages.FoldingConfigurationBlock_combo_caption); 
+               
+               label= new Label(composite, SWT.CENTER);
+               gd= new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
+               label.setLayoutData(gd);
+
+               fProviderCombo= new Combo(comboComp, SWT.READ_ONLY | SWT.DROP_DOWN);
+               gd= new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_CENTER);
+               fProviderCombo.setLayoutData(gd);
+
+               /* list viewer */
+               fProviderViewer= new ComboViewer(fProviderCombo);
+               fProviderViewer.setContentProvider(new IStructuredContentProvider() {
+
+                       /*
+                        * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+                        */
+                       public void dispose() {
+                       }
+
+                       /*
+                        * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+                        */
+                       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+                       }
+
+                       /*
+                        * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+                        */
+                       public Object[] getElements(Object inputElement) {
+                               return fProviderDescriptors.values().toArray();
+                       }
+               });
+               fProviderViewer.setLabelProvider(new LabelProvider() {
+                       /*
+                        * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
+                        */
+                       @Override
+                       public Image getImage(Object element) {
+                               return null;
+                       }
+                       
+                       /*
+                        * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
+                        */
+                       @Override
+                       public String getText(Object element) {
+                               return ((CFoldingStructureProviderDescriptor) element).getName();
+                       }
+               });
+               fProviderViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+                       public void selectionChanged(SelectionChangedEvent event) {
+                               IStructuredSelection sel= (IStructuredSelection) event.getSelection();
+                               if (!sel.isEmpty()) {
+                                       fStore.setValue(PreferenceConstants.EDITOR_FOLDING_PROVIDER, ((CFoldingStructureProviderDescriptor) sel.getFirstElement()).getId());
+                                       updateListDependencies();
+                               }
+                       }
+               });
+               fProviderViewer.setInput(fProviderDescriptors);
+               fProviderViewer.refresh();
+               
+               Composite groupComp= new Composite(composite, SWT.NONE);
+               gd= new GridData(GridData.FILL_BOTH);
+               gd.horizontalSpan= 2;
+               groupComp.setLayoutData(gd);
+               gridLayout= new GridLayout(1, false);
+               gridLayout.marginWidth= 0;
+               groupComp.setLayout(gridLayout);
+               
+               /* contributed provider preferences. */
+               fGroup= new Composite(groupComp, SWT.NONE);
+               gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
+               fGroup.setLayoutData(gd);
+               fStackLayout= new StackLayout();
+               fGroup.setLayout(fStackLayout);
+               
+               return composite;
+       }
+
+       protected void updateCheckboxDependencies() {
+       }
+
+       void updateListDependencies() {
+               String id= fStore.getString(PreferenceConstants.EDITOR_FOLDING_PROVIDER);
+               CFoldingStructureProviderDescriptor desc= fProviderDescriptors.get(id);
+               ICFoldingPreferenceBlock prefs;
+               
+               if (desc == null) {
+                       // safety in case there is no such descriptor
+                       String message= PreferencesMessages.FoldingConfigurationBlock_error_not_exist; 
+                       CUIPlugin.log(new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, message, null));
+                       prefs= new ErrorPreferences(message);
+               } else {
+                       prefs= fProviderPreferences.get(id);
+                       if (prefs == null) {
+                               try {
+                                       prefs= desc.createPreferences();
+                                       fProviderPreferences.put(id, prefs);
+                               } catch (CoreException e) {
+                                       CUIPlugin.log(e);
+                                       prefs= new ErrorPreferences(e.getLocalizedMessage());
+                               }
+                       }
+               }
+               
+               Control control= fProviderControls.get(id);
+               if (control == null) {
+                       control= prefs.createControl(fGroup);
+                       if (control == null) {
+                               String message= PreferencesMessages.FoldingConfigurationBlock_info_no_preferences; 
+                               control= new ErrorPreferences(message).createControl(fGroup);
+                       } else {
+                               fProviderControls.put(id, control);
+                       }
+               }
+               fStackLayout.topControl= control;
+               control.pack();
+               fGroup.layout();
+               fGroup.getParent().layout();
+               
+               prefs.initialize();
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#initialize()
+        */
+       public void initialize() {
+               restoreFromPreferences();
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#performOk()
+        */
+       public void performOk() {
+               for (Iterator<ICFoldingPreferenceBlock> it= fProviderPreferences.values().iterator(); it.hasNext();) {
+                       ICFoldingPreferenceBlock prefs= it.next();
+                       prefs.performOk();
+               }
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#performDefaults()
+        */
+       public void performDefaults() {
+               restoreFromPreferences();
+               for (Iterator<ICFoldingPreferenceBlock> it= fProviderPreferences.values().iterator(); it.hasNext();) {
+                       ICFoldingPreferenceBlock prefs= it.next();
+                       prefs.performDefaults();
+               }
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#dispose()
+        */
+       public void dispose() {
+               for (Iterator<ICFoldingPreferenceBlock> it= fProviderPreferences.values().iterator(); it.hasNext();) {
+                       ICFoldingPreferenceBlock prefs= it.next();
+                       prefs.dispose();
+               }
+       }
+
+       private void restoreFromPreferences() {
+               boolean enabled= fStore.getBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED);
+               fFoldingCheckbox.setSelection(enabled);
+               updateCheckboxDependencies();
+               
+               String id= fStore.getString(PreferenceConstants.EDITOR_FOLDING_PROVIDER);
+               Object provider= fProviderDescriptors.get(id);
+               if (provider != null) {
+                       fProviderViewer.setSelection(new StructuredSelection(provider), true);
+                       updateListDependencies();
+               }
+       }
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingPreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingPreferencePage.java
new file mode 100644 (file)
index 0000000..f78f6a1
--- /dev/null
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+
+/**
+ * The page for setting the editor folding options.
+ */
+public final class FoldingPreferencePage extends AbstractConfigurationBlockPreferencePage {
+       
+       /*
+        * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#getHelpId()
+        */
+       @Override
+       protected String getHelpId() {
+               return ICHelpContextIds.C_EDITOR_FOLDING_PAGE;
+       }
+
+       /*
+        * @see org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setDescription()
+        */
+       @Override
+       protected void setDescription() {
+               String description= PreferencesMessages.CEditorPreferencePage_folding_title; 
+               setDescription(description);
+       }
+       
+       /*
+        * @see org.org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setPreferenceStore()
+        */
+       @Override
+       protected void setPreferenceStore() {
+               setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
+       }
+       
+       
+       @Override
+       protected Label createDescriptionLabel(Composite parent) {
+               return null; // no description for new look.
+       }
+
+       /*
+        * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#createConfigurationBlock(org.eclipse.ui.internal.editors.text.OverlayPreferenceStore)
+        */
+       @Override
+       protected IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore) {
+               return new FoldingConfigurationBlock(overlayPreferenceStore);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/GlobalBuildLogPreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/GlobalBuildLogPreferencePage.java
new file mode 100644 (file)
index 0000000..8bd9929
--- /dev/null
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Broadcom Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alex Collins (Broadcom Corp.) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.StringButtonFieldEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+import org.eclipse.cdt.internal.ui.buildconsole.BuildConsoleManager;
+import org.eclipse.cdt.internal.ui.buildconsole.GlobalBuildConsoleManager;
+
+/**
+ * Preference page for build logging options, such as whether the
+ * global build console should be logged and, if so, where.
+ */
+public class GlobalBuildLogPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
+       public GlobalBuildLogPreferencePage() {
+               super(GRID);
+               setPreferenceStore(GlobalBuildConsoleManager.getBuildLogPreferenceStore());
+       }
+
+       /**
+        * A file path field with choose button that does not require the chosen file to exist.
+        */
+       static private class FilePathEditor extends StringButtonFieldEditor {
+               public FilePathEditor(String name, String label, Composite parent) {
+                       super(name, label, parent);
+               }
+
+               @Override
+               protected String changePressed() {
+                       FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
+                       dialog.setText(getLabelText());
+                       String fileName = super.oldValue;
+                       IPath logFolder = new Path(fileName).removeLastSegments(1);
+                       dialog.setFilterPath(logFolder.toOSString());
+                       return dialog.open();
+               }
+       }
+
+       @Override
+       protected void createFieldEditors() {
+               Composite parent = getFieldEditorParent();
+               BooleanFieldEditor keepLog = new BooleanFieldEditor(BuildConsoleManager.KEY_KEEP_LOG,
+                               PreferencesMessages.GlobalBuildLogPreferencePage_EnableLogging, parent);
+               addField(keepLog);
+               FilePathEditor logLocation = new FilePathEditor(BuildConsoleManager.KEY_LOG_LOCATION,
+                               PreferencesMessages.GlobalBuildLogPreferencePage_LogLocation, parent);
+               addField(logLocation);
+       }
+
+       public void init(IWorkbench workbench) {
+               initDefaults(GlobalBuildConsoleManager.getBuildLogPreferenceStore());
+       }
+
+       public static void initDefaults(IPreferenceStore prefs) {
+               prefs.setDefault(BuildConsoleManager.KEY_KEEP_LOG, BuildConsoleManager.CONSOLE_KEEP_LOG_DEFAULT);
+               prefs.setDefault(BuildConsoleManager.KEY_LOG_LOCATION,
+                               GlobalBuildConsoleManager.getDefaultConsoleLogLocation());
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IPreferenceConfigurationBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IPreferenceConfigurationBlock.java
new file mode 100644 (file)
index 0000000..b794a87
--- /dev/null
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin, Google
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+
+/**
+ * Interface for preference configuration blocks which can either be
+ * wrapped by a {@link org.eclipse.cdt.internal.ui.preferences.AbstractConfigurationBlockPreferencePage}
+ * or be included some preference page.
+ * <p>
+ * Clients may implement this interface.
+ * </p>
+ * 
+ * @since 3.0
+ */
+public interface IPreferenceConfigurationBlock {
+       
+       /**
+        * Creates the preference control.
+        * 
+        * @param parent the parent composite to which to add the preferences control
+        * @return the control that was added to <code>parent</code> 
+        */
+       Control createControl(Composite parent);
+       
+       /**
+        * Called after creating the control. Implementations should load the 
+        * preferences values and update the controls accordingly.
+        */
+       void initialize();
+       
+       /**
+        * Called when the <code>OK</code> button is pressed on the preference
+        * page. Implementations should commit the configured preference settings
+        * into their form of preference storage.
+        */
+       void performOk();
+       
+       /**
+        * Called when the <code>Defaults</code> button is pressed on the
+        * preference page. Implementation should reset any preference settings to
+        * their default values and adjust the controls accordingly.
+        */
+       void performDefaults();
+       
+       /**
+        * Called when the preference page is being disposed. Implementations should
+        * free any resources they are holding on to.
+        */
+       void dispose();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerPreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerPreferencePage.java
new file mode 100644 (file)
index 0000000..bcc0da7
--- /dev/null
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.activities.IIdentifier;
+import org.eclipse.ui.activities.IWorkbenchActivitySupport;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.dialogs.CacheSizeBlock;
+import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
+import org.eclipse.cdt.ui.dialogs.IndexerBlock;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+
+public class IndexerPreferencePage extends PreferencePage implements
+               IWorkbenchPreferencePage, ICOptionContainer {
+       // bug 217860, allow to hide build configuration
+       private static final String SHOW_BUILD_SPECIFIC_CONFIG = "show.build.specific.indexer.config"; //$NON-NLS-1$
+
+       private IndexerBlock fOptionBlock;
+       private CacheSizeBlock fCacheBlock;
+       private IndexerStrategyBlock fStrategyBlock;
+       
+       public IndexerPreferencePage(){
+               fOptionBlock = new IndexerBlock();
+               fOptionBlock.setContainer(this);
+               fStrategyBlock= new IndexerStrategyBlock(this);
+               fCacheBlock= new CacheSizeBlock(this);
+       }
+       
+       @Override
+       public void createControl(Composite parent) {
+               super.createControl(parent);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.INDEXER_PREFERENCE_PAGE);
+       }
+
+       @Override
+       protected Control createContents(Composite parent) {
+               GridLayout gl;
+               Composite composite = new Composite(parent, SWT.NONE);
+               composite.setLayout(gl= new GridLayout());
+               composite.setLayoutData(new GridData());
+               gl.verticalSpacing= 0;
+       
+               fOptionBlock.createControl(composite);
+               fStrategyBlock.createControl(composite);
+               fCacheBlock.createControl(composite);
+               
+               return composite;
+       }
+
+       public void init(IWorkbench workbench) {
+       }
+
+       public void updateContainer() {
+               if (!fOptionBlock.isValid()) {
+                       setErrorMessage(fOptionBlock.getErrorMessage());
+                       setValid(false);
+               }
+               else if (!fStrategyBlock.isValid()) {
+                       setErrorMessage(fStrategyBlock.getErrorMessage());
+                       setValid(false);
+               }
+               else if (!fCacheBlock.isValid()) {
+                       setErrorMessage(fCacheBlock.getErrorMessage());
+                       setValid(false);
+               }
+               else {
+                       setErrorMessage(null);
+                       setValid(true);
+               }
+       }
+
+       public IProject getProject() {
+               return null;
+       }
+
+       @SuppressWarnings("deprecation")
+       public org.eclipse.core.runtime.Preferences getPreferences() {
+               throw new UnsupportedOperationException();
+       }
+
+       @Override
+       public boolean performOk() {
+               try {
+                       fOptionBlock.performApply(new NullProgressMonitor());
+                       fStrategyBlock.performApply(new NullProgressMonitor());
+                       fCacheBlock.performApply(new NullProgressMonitor());
+               } catch (CoreException e) {}
+               return true;
+       }
+       
+       @Override
+       public void performDefaults() {
+               fOptionBlock.performDefaults();
+               fStrategyBlock.performDefaults();
+               fCacheBlock.performDefaults();
+               updateContainer();
+       }
+
+       /**
+        * Returns whether the capability for showing build configurations is enabled.
+        * @since 5.0
+        */
+       public static boolean showBuildConfiguration() {
+               IWorkbenchActivitySupport activitySupport= PlatformUI.getWorkbench().getActivitySupport();
+               IIdentifier identifier= activitySupport.getActivityManager().getIdentifier(
+                               CUIPlugin.getPluginId() + '/' + SHOW_BUILD_SPECIFIC_CONFIG);
+               return identifier.isEnabled();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerStrategyBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerStrategyBlock.java
new file mode 100644 (file)
index 0000000..71ef2dc
--- /dev/null
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.preferences;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
+import org.eclipse.cdt.core.settings.model.ICProjectDescriptionPreferences;
+import org.eclipse.cdt.core.settings.model.ICProjectDescriptionWorkspacePreferences;
+import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
+import org.eclipse.cdt.ui.dialogs.DialogsMessages;
+import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+
+import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
+
+/**
+ * This OptionPage is used in the IndexerPreference page to allow for adjusting
+ * various parsing related caches.
+ */
+public class IndexerStrategyBlock extends AbstractCOptionPage {
+    private Button fAutoUpdateButton;
+       private Button fImmediateUpdateButton;
+       private Button fUseActiveBuildButton;
+       private Button fUseFixedBuildConfig;
+
+       public IndexerStrategyBlock(ICOptionContainer container) {
+       setContainer(container);
+    }
+
+    @Override
+       public void createControl(Composite parent) {
+       GridData gd;
+       GridLayout gl;
+        Composite composite = ControlFactory.createComposite(parent, 1);
+               gl=  (GridLayout)composite.getLayout();
+               gl.marginWidth= 0;
+               gl.verticalSpacing= gl.marginHeight*2;
+               
+               gd= (GridData) composite.getLayoutData();
+               gd.grabExcessHorizontalSpace= false;
+               gd.horizontalAlignment= GridData.FILL;
+
+               setControl(composite);
+      
+               SelectionListener updateEnablement= new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               updateEnablement();
+                       }
+               };
+
+               Group group= ControlFactory.createGroup(composite, DialogsMessages.IndexerStrategyBlock_strategyGroup, 1);
+               gd= (GridData) group.getLayoutData();
+               gd.grabExcessHorizontalSpace= true;
+               gd.horizontalAlignment= GridData.FILL;  
+               fAutoUpdateButton= ControlFactory.createCheckBox(group, DialogsMessages.IndexerStrategyBlock_autoUpdate);
+               fImmediateUpdateButton= ControlFactory.createCheckBox(group, DialogsMessages.IndexerStrategyBlock_immediateUpdate);
+               fAutoUpdateButton.addSelectionListener(updateEnablement);
+               
+               if (IndexerPreferencePage.showBuildConfiguration()) {
+                       group= ControlFactory.createGroup(composite, DialogsMessages.IndexerStrategyBlock_buildConfigGroup, 1);
+                       gd= (GridData) group.getLayoutData();
+                       gd.grabExcessHorizontalSpace= true;
+                       gd.horizontalAlignment= GridData.FILL;
+                       fUseActiveBuildButton= ControlFactory.createRadioButton(group, DialogsMessages.IndexerStrategyBlock_activeBuildConfig, null, null);
+                       fUseFixedBuildConfig= ControlFactory.createRadioButton(group, DialogsMessages.IndexerStrategyBlock_specificBuildConfig, null, null);
+               }               
+               initializeValues();
+    }
+
+    protected void updateEnablement() {
+       fImmediateUpdateButton.setEnabled(fAutoUpdateButton.getSelection());
+       }
+
+       private void initializeValues() {
+       int updatePolicy= IndexerPreferences.getUpdatePolicy(null);
+       initUpdatePolicy(updatePolicy);
+
+       if (fUseActiveBuildButton != null) {
+               ICProjectDescriptionManager prjDescMgr= CCorePlugin.getDefault().getProjectDescriptionManager();
+               ICProjectDescriptionWorkspacePreferences prefs= prjDescMgr.getProjectDescriptionWorkspacePreferences(false);
+               boolean useActive= prefs.getConfigurationRelations() == ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE;
+               fUseActiveBuildButton.setSelection(useActive);
+               fUseFixedBuildConfig.setSelection(!useActive);
+       }       
+       updateEnablement();
+       }
+
+       private void initUpdatePolicy(int updatePolicy) {
+               fAutoUpdateButton.setSelection(updatePolicy != IndexerPreferences.UPDATE_POLICY_MANUAL);
+       fImmediateUpdateButton.setSelection(updatePolicy == IndexerPreferences.UPDATE_POLICY_IMMEDIATE);
+       }
+
+       @Override
+       public void performApply(IProgressMonitor monitor) throws CoreException {
+               int updatePolicy;
+               if (!fAutoUpdateButton.getSelection()) {
+                       updatePolicy= IndexerPreferences.UPDATE_POLICY_MANUAL;
+               } else if (fImmediateUpdateButton.getSelection()) {
+                       updatePolicy= IndexerPreferences.UPDATE_POLICY_IMMEDIATE;
+               } else {
+                       updatePolicy= IndexerPreferences.UPDATE_POLICY_LAZY;
+               }                       
+               IndexerPreferences.setUpdatePolicy(null, updatePolicy);
+
+       if (fUseActiveBuildButton != null) {
+               boolean useActive= fUseActiveBuildButton.getSelection();
+               int relation= useActive ?
+                               ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE :
+                               ICProjectDescriptionPreferences.CONFIGS_INDEPENDENT;
+               ICProjectDescriptionManager prjDescMgr= CCorePlugin.getDefault().getProjectDescriptionManager();
+               ICProjectDescriptionWorkspacePreferences prefs= prjDescMgr.getProjectDescriptionWorkspacePreferences(true);
+               prefs.setConfigurationRelations(relation);
+               prjDescMgr.setProjectDescriptionWorkspacePreferences(prefs, false, new NullProgressMonitor());
+       }
+       }
+
+    @Override
+       public void performDefaults() {
+       initUpdatePolicy(IndexerPreferences.getDefaultUpdatePolicy());
+       if (fUseActiveBuildButton != null) {
+               fUseActiveBuildButton.setSelection(false);
+               fUseFixedBuildConfig.setSelection(true);
+       }
+       updateEnablement();
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesConfigurationBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesConfigurationBlock.java
new file mode 100644 (file)
index 0000000..8069cb5
--- /dev/null
@@ -0,0 +1,230 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2010 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey;
+
+/**
+ * Configures C/C++ Editor mark occurrences preferences.
+ * 
+ * @since 5.0
+ */
+class MarkOccurrencesConfigurationBlock implements IPreferenceConfigurationBlock {
+
+       private OverlayPreferenceStore fStore;
+       
+       
+       private Map<Object, String> fCheckBoxes= new HashMap<Object, String>();
+       private SelectionListener fCheckBoxListener= new SelectionListener() {
+               public void widgetDefaultSelected(SelectionEvent e) {
+               }
+               public void widgetSelected(SelectionEvent e) {
+                       Button button= (Button) e.widget;
+                       fStore.setValue(fCheckBoxes.get(button), button.getSelection());
+               }
+       };
+       
+       /**
+        * List of master/slave listeners when there's a dependency.
+        * 
+        * @see #createDependency(Button, String, Control)
+        */
+       private ArrayList<Object> fMasterSlaveListeners= new ArrayList<Object>();
+       
+       private StatusInfo fStatus;
+
+       public MarkOccurrencesConfigurationBlock(OverlayPreferenceStore store) {
+               Assert.isNotNull(store);
+               fStore= store;
+               
+               fStore.addKeys(createOverlayStoreKeys());
+       }
+       
+       private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
+               
+               ArrayList<OverlayKey> overlayKeys= new ArrayList<OverlayKey>();
+
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MARK_OCCURRENCES));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MARK_OVERLOADED_OPERATOR_OCCURRENCES));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STICKY_OCCURRENCES));
+               
+               OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
+               overlayKeys.toArray(keys);
+               return keys;
+       }       
+
+       /**
+        * Creates page for mark occurrences preferences.
+        * 
+        * @param parent the parent composite
+        * @return the control for the preference page
+        */
+       public Control createControl(final Composite parent) {
+       
+               Composite composite= new Composite(parent, SWT.NONE);
+               GridLayout layout= new GridLayout();
+               layout.numColumns= 1;
+               layout.marginHeight= 0;
+               layout.marginWidth= 0;
+               composite.setLayout(layout);
+               
+               Link link= new Link(composite, SWT.NONE);
+               link.setText(PreferencesMessages.MarkOccurrencesConfigurationBlock_link);
+               link.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               PreferencesUtil.createPreferenceDialogOn(parent.getShell(), e.text, null, null); 
+                       }
+               });
+               // TODO replace by link-specific tooltips when
+               // bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=88866 gets fixed
+               link.setToolTipText(PreferencesMessages.MarkOccurrencesConfigurationBlock_link_tooltip); 
+               
+               addFiller(composite);
+               
+               String label;
+               
+               label= PreferencesMessages.MarkOccurrencesConfigurationBlock_markOccurrences; 
+               Button master= addCheckBox(composite, label, PreferenceConstants.EDITOR_MARK_OCCURRENCES, 0);
+               
+               addFiller(composite);
+               
+               label= PreferencesMessages.MarkOccurrencesConfigurationBlock_markOverloadOccurrences; 
+               Button slave = addCheckBox(composite, label, PreferenceConstants.EDITOR_MARK_OVERLOADED_OPERATOR_OCCURRENCES, 0); 
+               createDependency(master, PreferenceConstants.EDITOR_MARK_OVERLOADED_OPERATOR_OCCURRENCES, slave);
+
+               addFiller(composite);
+               
+               label= PreferencesMessages.MarkOccurrencesConfigurationBlock_stickyOccurrences; 
+               slave = addCheckBox(composite, label, PreferenceConstants.EDITOR_STICKY_OCCURRENCES, 0); 
+               createDependency(master, PreferenceConstants.EDITOR_STICKY_OCCURRENCES, slave);
+
+               return composite;
+       }
+       
+       private void addFiller(Composite composite) {
+               PixelConverter pixelConverter= new PixelConverter(composite);
+               
+               Label filler= new Label(composite, SWT.LEFT );
+               GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               gd.horizontalSpan= 2;
+               gd.heightHint= pixelConverter.convertHeightInCharsToPixels(1) / 2;
+               filler.setLayoutData(gd);
+       }
+
+       private Button addCheckBox(Composite parent, String label, String key, int indentation) {               
+               Button checkBox= new Button(parent, SWT.CHECK);
+               checkBox.setText(label);
+               
+               GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+               gd.horizontalIndent= indentation;
+               gd.horizontalSpan= 2;
+               checkBox.setLayoutData(gd);
+               checkBox.addSelectionListener(fCheckBoxListener);
+               
+               fCheckBoxes.put(checkBox, key);
+               
+               return checkBox;
+       }
+
+       private void createDependency(final Button master, String masterKey, final Control slave) {
+               indent(slave);
+               boolean masterState= fStore.getBoolean(masterKey);
+               slave.setEnabled(masterState);
+               SelectionListener listener= new SelectionListener() {
+                       public void widgetSelected(SelectionEvent e) {
+                               slave.setEnabled(master.getSelection());
+                       }
+
+                       public void widgetDefaultSelected(SelectionEvent e) {}
+               };
+               master.addSelectionListener(listener);
+               fMasterSlaveListeners.add(listener);
+       }
+
+       private static void indent(Control control) {
+               GridData gridData= new GridData();
+               gridData.horizontalIndent= 10;
+               control.setLayoutData(gridData);                
+       }
+
+       public void initialize() {
+               initializeFields();
+       }
+
+       void initializeFields() {
+               
+               Iterator<Object> iter= fCheckBoxes.keySet().iterator();
+               while (iter.hasNext()) {
+                       Button b= (Button) iter.next();
+                       String key= fCheckBoxes.get(b);
+                       b.setSelection(fStore.getBoolean(key));
+               }
+               
+        // Update slaves
+        iter= fMasterSlaveListeners.iterator();
+        while (iter.hasNext()) {
+            SelectionListener listener= (SelectionListener)iter.next();
+            listener.widgetSelected(null);
+        }
+        
+       }
+
+       public void performOk() {
+       }
+
+       public void performDefaults() {
+               restoreFromPreferences();
+               initializeFields();
+       }
+
+       private void restoreFromPreferences() {
+
+       }
+
+       IStatus getStatus() {
+               if (fStatus == null)
+                       fStatus= new StatusInfo();
+               return fStatus;
+       }
+
+       /*
+        * @see org.eclipse.jdt.internal.ui.preferences.IPreferenceConfigurationBlock#dispose()
+        */
+       public void dispose() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesPreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesPreferencePage.java
new file mode 100644 (file)
index 0000000..8136045
--- /dev/null
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences;
+
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+
+/**
+ * The page for setting the editor options.
+ */
+public final class MarkOccurrencesPreferencePage extends AbstractConfigurationBlockPreferencePage {
+       
+       /*
+        * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#getHelpId()
+        */
+       @Override
+       protected String getHelpId() {
+               return ICHelpContextIds.C_EDITOR_PREF_PAGE;
+       }
+
+       /*
+        * @see org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setDescription()
+        */
+       @Override
+       protected void setDescription() {
+               String description= PreferencesMessages.MarkOccurrencesConfigurationBlock_title; 
+               setDescription(description);
+       }
+       
+       /*
+        * @see org.org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setPreferenceStore()
+        */
+       @Override
+       protected void setPreferenceStore() {
+               setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
+       }
+       
+       
+       @Override
+       protected Label createDescriptionLabel(Composite parent) {
+               return null; // no description for new look.
+       }
+
+       /*
+        * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#createConfigurationBlock(org.eclipse.ui.internal.editors.text.OverlayPreferenceStore)
+        */
+       @Override
+       protected IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore) {
+               return new MarkOccurrencesConfigurationBlock(overlayPreferenceStore);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/NameStyleBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/NameStyleBlock.java
new file mode 100644 (file)
index 0000000..f0f168e
--- /dev/null
@@ -0,0 +1,678 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Google, Inc and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *        Sergey Prigogin (Google) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StackLayout;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
+
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+
+import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.util.NameComposer;
+import org.eclipse.cdt.internal.ui.viewsupport.ProjectTemplateStore;
+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.ITreeListAdapter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
+
+/**
+ * The preference block for configuring styles of names.
+ */
+public class NameStyleBlock extends OptionsConfigurationBlock {
+       private static final String EXAMPLE_CONSTANT_NAME = "MY_CONSTANT"; //$NON-NLS-1$
+       private static final String EXAMPLE_VARIABLE_NAME = "myVariable"; //$NON-NLS-1$
+       private static final String EXAMPLE_FIELD_NAME = "myField"; //$NON-NLS-1$
+       private static final String EXAMPLE_CLASS_NAME = "MyClass"; //$NON-NLS-1$
+
+       private final String[] CAPITALIZATION_VALUES = {
+                       String.valueOf(PreferenceConstants.NAME_STYLE_CAPITALIZATION_ORIGINAL),
+                       String.valueOf(PreferenceConstants.NAME_STYLE_CAPITALIZATION_UPPER_CASE),
+                       String.valueOf(PreferenceConstants.NAME_STYLE_CAPITALIZATION_LOWER_CASE),
+                       String.valueOf(PreferenceConstants.NAME_STYLE_CAPITALIZATION_CAMEL_CASE),
+                       String.valueOf(PreferenceConstants.NAME_STYLE_CAPITALIZATION_LOWER_CAMEL_CASE),
+               };
+
+       private final String[] CAPITALIZATION_LABELS = {
+                       String.valueOf(PreferencesMessages.NameStyleBlock_capitalization_original),
+                       String.valueOf(PreferencesMessages.NameStyleBlock_capitalization_upper_case),
+                       String.valueOf(PreferencesMessages.NameStyleBlock_capitalization_lower_case),
+                       String.valueOf(PreferencesMessages.NameStyleBlock_capitalization_camel_case),
+                       String.valueOf(PreferencesMessages.NameStyleBlock_capitalization_lower_camel_case),
+               };
+
+       private static final Key KEY_CONSTANT_CAPITALIZATION = getCDTUIKey(PreferenceConstants.NAME_STYLE_CONSTANT_CAPITALIZATION);
+       private static final Key KEY_CONSTANT_WORD_DELIMITER = getCDTUIKey(PreferenceConstants.NAME_STYLE_CONSTANT_WORD_DELIMITER);
+       private static final Key KEY_CONSTANT_PREFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_CONSTANT_PREFIX);
+       private static final Key KEY_CONSTANT_SUFFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_CONSTANT_SUFFIX);
+       private static final Key KEY_VARIABLE_CAPITALIZATION = getCDTUIKey(PreferenceConstants.NAME_STYLE_VARIABLE_CAPITALIZATION);
+       private static final Key KEY_VARIABLE_WORD_DELIMITER = getCDTUIKey(PreferenceConstants.NAME_STYLE_VARIABLE_WORD_DELIMITER);
+       private static final Key KEY_VARIABLE_PREFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_VARIABLE_PREFIX);
+       private static final Key KEY_VARIABLE_SUFFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_VARIABLE_SUFFIX);
+       private static final Key KEY_FIELD_CAPITALIZATION = getCDTUIKey(PreferenceConstants.NAME_STYLE_FIELD_CAPITALIZATION);
+       private static final Key KEY_FIELD_WORD_DELIMITER = getCDTUIKey(PreferenceConstants.NAME_STYLE_FIELD_WORD_DELIMITER);
+       private static final Key KEY_FIELD_PREFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_FIELD_PREFIX);
+       private static final Key KEY_FIELD_SUFFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_FIELD_SUFFIX);
+       private static final Key KEY_GETTER_CAPITALIZATION = getCDTUIKey(PreferenceConstants.NAME_STYLE_GETTER_CAPITALIZATION);
+       private static final Key KEY_GETTER_WORD_DELIMITER = getCDTUIKey(PreferenceConstants.NAME_STYLE_GETTER_WORD_DELIMITER);
+       private static final Key KEY_GETTER_PREFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_GETTER_PREFIX);
+       private static final Key KEY_GETTER_PREFIX_FOR_BOOLEAN = getCDTUIKey(PreferenceConstants.NAME_STYLE_GETTER_PREFIX_FOR_BOOLEAN);
+       private static final Key KEY_GETTER_SUFFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_GETTER_SUFFIX);
+       private static final Key KEY_SETTER_CAPITALIZATION = getCDTUIKey(PreferenceConstants.NAME_STYLE_SETTER_CAPITALIZATION);
+       private static final Key KEY_SETTER_WORD_DELIMITER = getCDTUIKey(PreferenceConstants.NAME_STYLE_SETTER_WORD_DELIMITER);
+       private static final Key KEY_SETTER_PREFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_SETTER_PREFIX);
+       private static final Key KEY_SETTER_SUFFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_SETTER_SUFFIX);
+       private static final Key KEY_CPP_SOURCE_CAPITALIZATION = getCDTUIKey(PreferenceConstants.NAME_STYLE_CPP_SOURCE_CAPITALIZATION);
+       private static final Key KEY_CPP_SOURCE_WORD_DELIMITER = getCDTUIKey(PreferenceConstants.NAME_STYLE_CPP_SOURCE_WORD_DELIMITER);
+       private static final Key KEY_CPP_SOURCE_PREFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_CPP_SOURCE_PREFIX);
+       private static final Key KEY_CPP_SOURCE_SUFFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_CPP_SOURCE_SUFFIX);
+       private static final Key KEY_CPP_HEADER_CAPITALIZATION = getCDTUIKey(PreferenceConstants.NAME_STYLE_CPP_HEADER_CAPITALIZATION);
+       private static final Key KEY_CPP_HEADER_WORD_DELIMITER = getCDTUIKey(PreferenceConstants.NAME_STYLE_CPP_HEADER_WORD_DELIMITER);
+       private static final Key KEY_CPP_HEADER_PREFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_CPP_HEADER_PREFIX);
+       private static final Key KEY_CPP_HEADER_SUFFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_CPP_HEADER_SUFFIX);
+       private static final Key KEY_CPP_TEST_CAPITALIZATION = getCDTUIKey(PreferenceConstants.NAME_STYLE_CPP_TEST_CAPITALIZATION);
+       private static final Key KEY_CPP_TEST_WORD_DELIMITER = getCDTUIKey(PreferenceConstants.NAME_STYLE_CPP_TEST_WORD_DELIMITER);
+       private static final Key KEY_CPP_TEST_PREFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_CPP_TEST_PREFIX);
+       private static final Key KEY_CPP_TEST_SUFFIX = getCDTUIKey(PreferenceConstants.NAME_STYLE_CPP_TEST_SUFFIX);
+
+       private static final IdentifierValidator IDENTIFIER_VALIDATOR = new IdentifierValidator();
+       private static final FilenameValidator FILENAME_VALIDATOR = new FilenameValidator();
+
+       private static Key[] getAllKeys() {
+               return new Key[] {
+                               KEY_CONSTANT_CAPITALIZATION,
+                               KEY_CONSTANT_WORD_DELIMITER,
+                               KEY_CONSTANT_PREFIX,
+                               KEY_CONSTANT_SUFFIX,
+                               KEY_VARIABLE_CAPITALIZATION,
+                               KEY_VARIABLE_WORD_DELIMITER,
+                               KEY_VARIABLE_PREFIX,
+                               KEY_VARIABLE_SUFFIX,
+                               KEY_FIELD_CAPITALIZATION,
+                               KEY_FIELD_WORD_DELIMITER,
+                               KEY_FIELD_PREFIX,
+                               KEY_FIELD_SUFFIX,
+                               KEY_GETTER_CAPITALIZATION,
+                               KEY_GETTER_WORD_DELIMITER,
+                               KEY_GETTER_PREFIX,
+                               KEY_GETTER_PREFIX_FOR_BOOLEAN,
+                               KEY_GETTER_SUFFIX,
+                               KEY_SETTER_CAPITALIZATION,
+                               KEY_SETTER_WORD_DELIMITER,
+                               KEY_SETTER_PREFIX,
+                               KEY_SETTER_SUFFIX,
+                               KEY_CPP_SOURCE_CAPITALIZATION,
+                               KEY_CPP_SOURCE_WORD_DELIMITER,
+                               KEY_CPP_SOURCE_PREFIX,
+                               KEY_CPP_SOURCE_SUFFIX,
+                               KEY_CPP_HEADER_CAPITALIZATION,
+                               KEY_CPP_HEADER_WORD_DELIMITER,
+                               KEY_CPP_HEADER_PREFIX,
+                               KEY_CPP_HEADER_SUFFIX,
+                               KEY_CPP_TEST_CAPITALIZATION,
+                               KEY_CPP_TEST_WORD_DELIMITER,
+                               KEY_CPP_TEST_PREFIX,
+                               KEY_CPP_TEST_SUFFIX,
+                       };
+       }
+
+       private final Category[] rootCategories; 
+       private TreeListDialogField<Category> categoryTree;
+       private PixelConverter pixelConverter;
+       private StackLayout editorAreaStack;
+       private Category selectedCategory;
+
+       public NameStyleBlock(IStatusChangeListener context, IProject project,
+                       IWorkbenchPreferenceContainer container) {
+               super(context, project, getAllKeys(), container);
+               rootCategories = createCategories();
+       }
+
+       private static Category[] createCategories() {
+               Category codeCategory = new Category(PreferencesMessages.NameStyleBlock_code_node); 
+               new Category(PreferencesMessages.NameStyleBlock_constant_node,
+                               PreferencesMessages.NameStyleBlock_constant_node_description, EXAMPLE_CONSTANT_NAME,
+                               codeCategory)
+                               .setCapitalizationKey(KEY_CONSTANT_CAPITALIZATION)
+                               .setWordDelimiterKey(KEY_CONSTANT_WORD_DELIMITER)
+                               .setPrefixKey(KEY_CONSTANT_PREFIX)
+                               .setSuffixKey(KEY_CONSTANT_SUFFIX)
+                               .setNameValidator(IDENTIFIER_VALIDATOR);
+               new Category(PreferencesMessages.NameStyleBlock_variable_node,
+                               PreferencesMessages.NameStyleBlock_variable_node_description, EXAMPLE_VARIABLE_NAME,
+                               codeCategory)
+                               .setCapitalizationKey(KEY_VARIABLE_CAPITALIZATION)
+                               .setWordDelimiterKey(KEY_VARIABLE_WORD_DELIMITER)
+                               .setPrefixKey(KEY_VARIABLE_PREFIX)
+                               .setSuffixKey(KEY_VARIABLE_SUFFIX)
+                               .setNameValidator(IDENTIFIER_VALIDATOR);
+               Category fieldCategory = new Category(PreferencesMessages.NameStyleBlock_field_node,
+                               PreferencesMessages.NameStyleBlock_field_node_description, EXAMPLE_FIELD_NAME,
+                               codeCategory)
+                               .setCapitalizationKey(KEY_FIELD_CAPITALIZATION)
+                               .setWordDelimiterKey(KEY_FIELD_WORD_DELIMITER)
+                               .setPrefixKey(KEY_FIELD_PREFIX)
+                               .setSuffixKey(KEY_FIELD_SUFFIX)
+                               .setNameValidator(IDENTIFIER_VALIDATOR);
+               new Category(PreferencesMessages.NameStyleBlock_getter_node,
+                               PreferencesMessages.NameStyleBlock_getter_node_description, EXAMPLE_FIELD_NAME,
+                               codeCategory)
+                               .setCapitalizationKey(KEY_GETTER_CAPITALIZATION)
+                               .setWordDelimiterKey(KEY_GETTER_WORD_DELIMITER)
+                               .setPrefixKey(KEY_GETTER_PREFIX)
+                               .setAlternativePrefixKey(KEY_GETTER_PREFIX_FOR_BOOLEAN)
+                               .setSuffixKey(KEY_GETTER_SUFFIX)
+                               .setSeedNameGenerator(fieldCategory)
+                               .setNameValidator(IDENTIFIER_VALIDATOR)
+                               .setTrimFieldName(true);
+               new Category(PreferencesMessages.NameStyleBlock_setter_node,
+                               PreferencesMessages.NameStyleBlock_setter_node_description, EXAMPLE_FIELD_NAME,
+                               codeCategory)
+                               .setCapitalizationKey(KEY_SETTER_CAPITALIZATION)
+                               .setWordDelimiterKey(KEY_SETTER_WORD_DELIMITER)
+                               .setPrefixKey(KEY_SETTER_PREFIX)
+                               .setSuffixKey(KEY_SETTER_SUFFIX)
+                               .setSeedNameGenerator(fieldCategory)
+                               .setNameValidator(IDENTIFIER_VALIDATOR)
+                               .setTrimFieldName(true);
+               Category fileCategory = new Category(PreferencesMessages.NameStyleBlock_files_node);
+               new Category(PreferencesMessages.NameStyleBlock_cpp_header_node,
+                               PreferencesMessages.NameStyleBlock_cpp_header_node_description, EXAMPLE_CLASS_NAME,
+                               fileCategory)
+                               .setCapitalizationKey(KEY_CPP_HEADER_CAPITALIZATION)
+                               .setWordDelimiterKey(KEY_CPP_HEADER_WORD_DELIMITER)
+                               .setPrefixKey(KEY_CPP_HEADER_PREFIX)
+                               .setSuffixKey(KEY_CPP_HEADER_SUFFIX)
+                               .setNameValidator(FILENAME_VALIDATOR);
+               new Category(PreferencesMessages.NameStyleBlock_cpp_source_node,
+                               PreferencesMessages.NameStyleBlock_cpp_source_node_description, EXAMPLE_CLASS_NAME,
+                               fileCategory)
+                               .setCapitalizationKey(KEY_CPP_SOURCE_CAPITALIZATION)
+                               .setWordDelimiterKey(KEY_CPP_SOURCE_WORD_DELIMITER)
+                               .setPrefixKey(KEY_CPP_SOURCE_PREFIX)
+                               .setSuffixKey(KEY_CPP_SOURCE_SUFFIX)
+                               .setNameValidator(FILENAME_VALIDATOR);
+               new Category(PreferencesMessages.NameStyleBlock_cpp_test_node,
+                               PreferencesMessages.NameStyleBlock_cpp_test_node_description, EXAMPLE_CLASS_NAME,
+                               fileCategory)
+                               .setCapitalizationKey(KEY_CPP_TEST_CAPITALIZATION)
+                               .setWordDelimiterKey(KEY_CPP_TEST_WORD_DELIMITER)
+                               .setPrefixKey(KEY_CPP_TEST_PREFIX)
+                               .setSuffixKey(KEY_CPP_TEST_SUFFIX)
+                               .setNameValidator(FILENAME_VALIDATOR);
+               return new Category[] { codeCategory, fileCategory };
+       }
+
+       public void postSetSelection(Object element) {
+               categoryTree.postSetSelection(new StructuredSelection(element));
+       }
+
+       @Override
+       public boolean hasProjectSpecificOptions(IProject project) {
+               if (super.hasProjectSpecificOptions(project))
+                       return true;
+
+               if (project != null) {
+                       return ProjectTemplateStore.hasProjectSpecificTempates(project);
+               }
+               return false;
+       }
+
+       @Override
+       protected Control createContents(Composite parent) {
+               pixelConverter =  new PixelConverter(parent);
+
+               setShell(parent.getShell());
+
+               Composite composite =  new Composite(parent, SWT.NONE);
+               composite.setFont(parent.getFont());
+
+               GridLayout layout = new GridLayout();
+               layout.marginHeight = 0;
+               layout.marginWidth = 0;
+               composite.setLayout(layout);
+
+               NameStyleAdapter adapter = new NameStyleAdapter();
+               categoryTree = new TreeListDialogField<Category>(adapter, null, new NameStyleLabelProvider());
+               categoryTree.setDialogFieldListener(adapter);
+               categoryTree.setLabelText(PreferencesMessages.NameStyleBlock_categories_label);
+               categoryTree.setViewerComparator(adapter);
+
+               createCategories();
+
+               for (Category category : rootCategories) {
+                       categoryTree.addElement(category);
+               }
+
+               Label label = categoryTree.getLabelControl(composite);
+               GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               gd.verticalAlignment = GridData.BEGINNING;
+               label.setLayoutData(gd);
+
+               Control tree = categoryTree.getTreeControl(composite);
+               gd = new GridData();
+               gd.horizontalAlignment = GridData.FILL;
+               gd.grabExcessHorizontalSpace = true;
+               gd.verticalAlignment = GridData.FILL;
+               gd.grabExcessVerticalSpace = false;
+               gd.widthHint = pixelConverter.convertWidthInCharsToPixels(50);
+               gd.heightHint = pixelConverter.convertHeightInCharsToPixels(12);
+               tree.setLayoutData(gd);
+
+               createCategoryEditorArea(composite);
+
+               categoryTree.setTreeExpansionLevel(2);
+               categoryTree.selectFirstElement();
+
+               updateControls();
+               return composite;
+       }
+
+       private void createCategoryEditorArea(Composite parent) {
+               Composite editorArea =  new Composite(parent, SWT.NONE);
+               editorArea.setLayoutData(new GridData(GridData.FILL_BOTH));
+               editorArea.setFont(parent.getFont());
+               editorAreaStack = new StackLayout();
+               editorArea.setLayout(editorAreaStack);
+               for (Category category : rootCategories) {
+                       createCategoryEditor(editorArea, category);
+               }
+       }
+
+       private void createCategoryEditor(Composite parent, Category category) {
+               Composite composite =  new Composite(parent, SWT.NONE);
+               GridLayout layout = new GridLayout();
+               layout.marginHeight = pixelConverter.convertHeightInCharsToPixels(1);
+               layout.marginWidth = 0;
+               composite.setLayout(layout);
+               composite.setFont(parent.getFont());
+
+               if (category.isConcrete()) {
+                       Group group = ControlFactory.createGroup(composite,     category.description, 1);
+
+                       Composite envelope = new Composite(group, SWT.NONE);
+                       layout = new GridLayout(4, false);
+                       layout.marginHeight = 0;
+                       layout.marginWidth = 0;
+                       envelope.setLayout(layout);
+
+                       Control control = addComboBox(envelope, PreferencesMessages.NameStyleBlock_capitalization_label,
+                                       category.getCapitalizationKey(), CAPITALIZATION_VALUES,
+                                       CAPITALIZATION_LABELS, 0);
+                       LayoutUtil.setHorizontalSpan(getLabel(control), 1);
+                       LayoutUtil.setHorizontalSpan(control, 3);
+                       control = addTextField(envelope, PreferencesMessages.NameStyleBlock_word_delimiter_label,
+                                       category.getWordDelimiterKey(), 0, pixelConverter.convertWidthInCharsToPixels(10));
+                       LayoutUtil.setHorizontalSpan(control, 3);
+                       LayoutUtil.setHorizontalAlignment(control, SWT.BEGINNING);
+                       control = addTextField(envelope, PreferencesMessages.NameStyleBlock_prefix_label,
+                                       category.getPrefixKey(), 0, pixelConverter.convertWidthInCharsToPixels(10));
+                       boolean getter = PreferencesMessages.NameStyleBlock_getter_node.equals(category.name);
+                       LayoutUtil.setHorizontalSpan(control, getter ? 1 : 3);
+                       LayoutUtil.setHorizontalAlignment(control, SWT.BEGINNING);
+                       if (getter) {
+                               control = addTextField(envelope, PreferencesMessages.NameStyleBlock_prefix_for_boolean_label,
+                                               category.getAlternativePrefixKey(), pixelConverter.convertWidthInCharsToPixels(2),
+                                               pixelConverter.convertWidthInCharsToPixels(10));
+                               LayoutUtil.setHorizontalSpan(control, 1);
+                               LayoutUtil.setHorizontalAlignment(control, SWT.BEGINNING);
+                       }
+                       control = addTextField(envelope, PreferencesMessages.NameStyleBlock_suffix_label,
+                                       category.getSuffixKey(), 0, pixelConverter.convertWidthInCharsToPixels(10));
+                       LayoutUtil.setHorizontalSpan(control, 3);
+                       LayoutUtil.setHorizontalAlignment(control, SWT.BEGINNING);
+
+                       ControlFactory.insertSpace(envelope, 4, pixelConverter.convertHeightInCharsToPixels(1));
+                       ControlFactory.createLabel(envelope, PreferencesMessages.NameStyleBlock_preview_label);
+                       Text previewText = ControlFactory.createTextField(envelope, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);
+                       LayoutUtil.setWidthHint(previewText, pixelConverter.convertWidthInCharsToPixels(35));
+                       LayoutUtil.setHorizontalSpan(previewText, 3);
+                       category.setPreviewControl(previewText);
+               } else {
+                       ControlFactory.createLabel(composite, PreferencesMessages.NameStyleBlock_select_concrete_category);
+               }
+               category.setEditorArea(composite);
+
+               for (Category child : category.getChildren()) {
+                       createCategoryEditor(parent, child);
+               }
+       }
+
+       @Override
+       protected void updateControls() {
+               super.updateControls();
+               updatePreview();
+       }
+
+       private void updateConfigurationBlock(List<Object> selection) {
+               if (selection.size() == 0)
+                       return;
+               selectedCategory = (Category) selection.get(0);
+               editorAreaStack.topControl = selectedCategory.getEditorArea();
+               editorAreaStack.topControl.getParent().layout();
+               updatePreview();
+       }
+
+       private void updatePreview() {
+               Text text = selectedCategory.getPreviewControl();
+               if (text != null) {
+                       text.setText(selectedCategory.composeExampleName(this));
+               }
+       }
+
+       @Override
+       public void performDefaults() {
+               super.performDefaults();
+
+               // Refresh
+               categoryTree.refresh();
+               updateConfigurationBlock(categoryTree.getSelectedElements());
+       }
+
+       @Override
+       public boolean performOk() {
+               return super.performOk();
+       }
+
+       @Override
+       protected void validateSettings(Key changedKey, String oldValue, String newValue) {
+               StatusInfo status = new StatusInfo();
+               if (selectedCategory != null) {
+                       NameValidator validator = selectedCategory.getNameValidator();
+                       if (changedKey.equals(selectedCategory.getPrefixKey()) ||
+                                       changedKey.equals(selectedCategory.getAlternativePrefixKey())) {
+                               if (!validator.isValidStart(newValue)) {
+                                       status.setError(PreferencesMessages.NameStyleBlock_invalid_prefix);
+                               }
+                       } else if (changedKey.equals(selectedCategory.getWordDelimiterKey())) {
+                               if (!validator.isValidPart(newValue)) {
+                                       status.setError(PreferencesMessages.NameStyleBlock_invalid_word_delimiter);
+                               }
+                       } else if (changedKey.equals(selectedCategory.getSuffixKey())) {
+                               if (!validator.isValidPart(newValue)) {
+                                       status.setError(PreferencesMessages.NameStyleBlock_invalid_suffix);
+                               }
+                       }
+               }
+               updatePreview();
+               fContext.statusChanged(status);
+       }
+
+    /**
+     * Represents a category of settings.
+     */
+       private final static class Category {
+               public final String name;
+               public final String description;
+               public final Category parent;
+               public final int index;  // Index in the siblings list
+               private final List<Category> children;
+               private Key capitalizationKey;
+               private Key wordDelimiterKey;
+               private Key prefixKey;
+               private Key alternativePrefixKey;
+               private Key suffixKey;
+               private String seedName;
+               private Category seedNameGenerator;
+               private NameValidator nameValidator;
+
+               private Text previewText;
+               private Composite editorArea;
+               private boolean trimFieldName = false;
+
+               Category(String name, String description, String seedName, Category parent) {
+                       this.name = name;
+                       this.description = description;
+                       this.seedName = seedName;
+                       this.parent = parent;
+                       children = new ArrayList<Category>();
+                       index = parent != null ? parent.addChild(this) : 0;
+               }
+
+               /**
+                * @param name Category name
+                */
+               Category(String name) {
+                   this(name, null, null, null);
+               }
+
+               private int addChild(Category category) {
+                       children.add(category);
+                       return children.size() - 1;
+               }
+
+               Category[] getChildren() {
+                       return children.toArray(new Category[children.size()]);
+               }
+
+               boolean hasChildren() {
+                       return !children.isEmpty();
+               }
+
+               @Override
+               public String toString() {
+                       return name;
+               }
+
+               Key getCapitalizationKey() {
+                       return capitalizationKey;
+               }
+
+               Category setCapitalizationKey(Key capitalizationKey) {
+                       this.capitalizationKey = capitalizationKey;
+                       return this;
+               }
+
+               Key getWordDelimiterKey() {
+                       return wordDelimiterKey;
+               }
+
+               Category setWordDelimiterKey(Key wordDelimiterKey) {
+                       this.wordDelimiterKey = wordDelimiterKey;
+                       return this;
+               }
+
+               Key getPrefixKey() {
+                       return prefixKey;
+               }
+
+               Category setPrefixKey(Key prefixKey) {
+                       this.prefixKey = prefixKey;
+                       return this;
+               }
+
+               Key getAlternativePrefixKey() {
+                       return alternativePrefixKey;
+               }
+
+               Category setAlternativePrefixKey(Key alternativePrefixKey) {
+                       this.alternativePrefixKey = alternativePrefixKey;
+                       return this;
+               }
+
+               Key getSuffixKey() {
+                       return suffixKey;
+               }
+
+               Category setSuffixKey(Key suffixKey) {
+                       this.suffixKey = suffixKey;
+                       return this;
+               }
+
+               boolean isConcrete() {
+                       return capitalizationKey != null;
+               }
+
+               Composite getEditorArea() {
+                       return editorArea;
+               }
+
+               Category setEditorArea(Composite editorArea) {
+                       this.editorArea = editorArea;
+                       return this;
+               }
+
+               Text getPreviewControl() {
+                       return previewText;
+               }
+
+               Category setPreviewControl(Text previewText) {
+                       this.previewText = previewText;
+                       return this;
+               }
+
+               NameValidator getNameValidator() {
+                       return nameValidator;
+               }
+
+               Category setNameValidator(NameValidator nameValidator) {
+                       this.nameValidator = nameValidator;
+                       return this;
+               }
+
+               Category setSeedNameGenerator(Category seedNameGenerator) {
+                       this.seedNameGenerator = seedNameGenerator;
+                       return this;
+               }
+
+               String composeExampleName(NameStyleBlock settings) {
+                       int capitalization = Integer.parseInt(settings.getValue(capitalizationKey));
+                       String wordDelimiter = settings.getValue(wordDelimiterKey);
+                       String prefix = settings.getValue(prefixKey);
+                       String suffix = settings.getValue(suffixKey);
+                       NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
+                       String name = seedNameGenerator != null ?
+                                       seedNameGenerator.composeExampleName(settings) : seedName;
+                       if (trimFieldName) {
+                               name = NameComposer.trimFieldName(name);
+                       }
+                       return composer.compose(name);
+               }
+
+               void setTrimFieldName(boolean trimSeedName) {
+                       this.trimFieldName = trimSeedName;
+               }
+       }
+
+       private abstract static class NameValidator {
+               boolean isValidStart(String prefix) {
+                       for (int i = 0; i < prefix.length(); i++) {
+                               if (i == 0 ? !isValidStart(prefix.charAt(i)) : !isValidPart(prefix.charAt(i)))
+                                       return false;
+                       }
+                       return true;
+               }
+
+               boolean isValidPart(String part) {
+                       for (int i = 0; i < part.length(); i++) {
+                               if (!isValidPart(part.charAt(i)))
+                                       return false;
+                       }
+                       return true;
+               }
+
+               abstract boolean isValidStart(char ch);
+               abstract boolean isValidPart(char ch);
+       }
+
+       private static class IdentifierValidator extends NameValidator {
+               @Override
+               boolean isValidStart(char ch) {
+                       return Character.isJavaIdentifierStart(ch);
+               }
+
+               @Override
+               boolean isValidPart(char ch) {
+                       return Character.isJavaIdentifierPart(ch);
+               }
+       }
+
+       private static class FilenameValidator extends NameValidator {
+               @Override
+               boolean isValidStart(char ch) {
+                       return isValidPart(ch);
+               }
+
+               @Override
+               boolean isValidPart(char ch) {
+                       return "\\/:*?<>|\" ".indexOf(ch) == -1; //$NON-NLS-1$
+               }
+       }
+
+       private class NameStyleAdapter extends ViewerComparator
+                       implements ITreeListAdapter<Category>, IDialogFieldListener {
+
+               public void selectionChanged(TreeListDialogField<Category> field) {
+                       updateConfigurationBlock(field.getSelectedElements());
+               }
+
+               public void customButtonPressed(TreeListDialogField<Category> field, int index) {
+               }
+
+               public void doubleClicked(TreeListDialogField<Category> field) {
+               }
+
+               public Category[] getChildren(TreeListDialogField<Category> field, Object element) {
+                       return ((Category) element).getChildren();
+               }
+
+               public Category getParent(TreeListDialogField<Category> field, Object element) {
+                       return ((Category) element).parent;
+               }
+
+               public boolean hasChildren(TreeListDialogField<Category> field, Object element) {
+                       return ((Category) element).hasChildren();
+               }
+
+               public void dialogFieldChanged(DialogField field) {
+               }
+
+               public void keyPressed(TreeListDialogField<Category> field, KeyEvent event) {
+               }
+
+               @Override
+               public int category(Object element) {
+                       return ((Category) element).index;
+               }
+       }
+
+       private static class NameStyleLabelProvider extends LabelProvider {
+               @Override
+               public Image getImage(Object element) {
+                       return null;
+               }
+
+               @Override
+               public String getText(Object element) {
+                       return ((Category) element).name;
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/NameStylePreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/NameStylePreferencePage.java
new file mode 100644 (file)
index 0000000..b501ace
--- /dev/null
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Google, Inc and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *        Sergey Prigogin (Google) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
+
+/*
+ * The preference page for configuring styles of names.
+ */
+public class NameStylePreferencePage extends PropertyAndPreferencePage {
+       public static final String PREF_ID= "org.eclipse.cdt.ui.preferences.NameStylePreferencePage"; //$NON-NLS-1$
+       public static final String PROP_ID= "org.eclipse.cdt.ui.propertyPages.NameStylePreferencePage"; //$NON-NLS-1$
+
+       private NameStyleBlock fConfigurationBlock;
+
+       public NameStylePreferencePage() {
+               setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
+               // Only used when the page is shown programmatically.
+               setTitle(PreferencesMessages.NameStylePreferencePage_title);             
+       }
+
+       @Override
+       public void createControl(Composite parent) {
+               IWorkbenchPreferenceContainer container= (IWorkbenchPreferenceContainer) getContainer();
+               fConfigurationBlock= new NameStyleBlock(getNewStatusChangedListener(),
+                               getProject(), container);
+
+               super.createControl(parent);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
+                               ICHelpContextIds.NAME_STYLE_PREFERENCE_PAGE);
+       }
+
+       @Override
+       protected Control createPreferenceContent(Composite composite) {
+               return fConfigurationBlock.createContents(composite);
+       }
+
+       @Override
+       protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
+               super.enableProjectSpecificSettings(useProjectSpecificSettings);
+               if (fConfigurationBlock != null) {
+                       fConfigurationBlock.useProjectSpecificSettings(useProjectSpecificSettings);
+               }
+       }
+
+       @Override
+       public boolean performOk() {
+               if (fConfigurationBlock != null) {
+                       return fConfigurationBlock.performOk();
+               }
+               return true;
+       }
+
+       @Override
+       protected void performDefaults() {
+               super.performDefaults();
+               if (fConfigurationBlock != null) {
+                       fConfigurationBlock.performDefaults();
+               }
+       }
+
+       @Override
+       public void dispose() {
+               if (fConfigurationBlock != null) {
+                       fConfigurationBlock.dispose();
+               }
+               super.dispose();
+       }
+
+       public void statusChanged(IStatus status) {
+               setValid(!status.matches(IStatus.ERROR));
+               StatusUtil.applyToStatusLine(this, status);
+       }
+
+       @Override
+       public void performApply() {
+               if (fConfigurationBlock != null) {
+                       fConfigurationBlock.performApply();
+               }
+       }
+
+       @Override
+       protected boolean hasProjectSpecificOptions(IProject project) {
+               return fConfigurationBlock.hasProjectSpecificOptions(project);
+       }
+
+       @Override
+       protected String getPreferencePageID() {
+               return PREF_ID;
+       }
+
+       @Override
+       protected String getPropertyPageID() {
+               return null;
+               // TODO(sprigogin): Project specific settings
+//             return PROP_ID;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBlock.java
new file mode 100644 (file)
index 0000000..9bec48d
--- /dev/null
@@ -0,0 +1,897 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.IdentityHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Widget;
+import org.eclipse.ui.forms.events.ExpansionAdapter;
+import org.eclipse.ui.forms.events.ExpansionEvent;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
+import org.eclipse.ui.preferences.IWorkingCopyManager;
+import org.eclipse.ui.preferences.WorkingCopyManager;
+import org.osgi.service.prefs.BackingStoreException;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
+
+/**
+ * Abstract options configuration block providing a general implementation for setting up
+ * an options configuration page.
+ */
+public abstract class OptionsConfigurationBlock {
+
+       public static final class Key {
+               private String fQualifier;
+               private String fKey;
+
+               public Key(String qualifier, String key) {
+                       fQualifier= qualifier;
+                       fKey= key;
+               }
+
+               public String getName() {
+                       return fKey;
+               }
+
+               private IEclipsePreferences getNode(IScopeContext context, IWorkingCopyManager manager) {
+                       IEclipsePreferences node= context.getNode(fQualifier);
+                       if (manager != null) {
+                               return manager.getWorkingCopy(node);
+                       }
+                       return node;
+               }
+
+               public String getStoredValue(IScopeContext context, IWorkingCopyManager manager) {
+                       return getNode(context, manager).get(fKey, null);
+               }
+
+               public String getStoredValue(IScopeContext[] lookupOrder, boolean ignoreTopScope, IWorkingCopyManager manager) {
+                       for (int i= ignoreTopScope ? 1 : 0; i < lookupOrder.length; i++) {
+                               String value= getStoredValue(lookupOrder[i], manager);
+                               if (value != null) {
+                                       return value;
+                               }
+                       }
+                       return null;
+               }
+
+               public void setStoredValue(IScopeContext context, String value, IWorkingCopyManager manager) {
+                       if (value != null) {
+                               getNode(context, manager).put(fKey, value);
+                       } else {
+                               getNode(context, manager).remove(fKey);
+                       }
+               }
+
+               /* (non-Javadoc)
+                * @see java.lang.Object#toString()
+                */
+               @Override
+               public String toString() {
+                       return fQualifier + '/' + fKey;
+               }
+
+               public String getQualifier() {
+                       return fQualifier;
+               }
+       }
+
+       protected static class ControlData {
+               private Key fKey;
+               private String[] fValues;
+
+               public ControlData(Key key, String[] values) {
+                       fKey= key;
+                       fValues= values;
+               }
+
+               public Key getKey() {
+                       return fKey;
+               }
+
+               public String getValue(boolean selection) {
+                       int index= selection ? 0 : 1;
+                       return fValues[index];
+               }
+
+               public String getValue(int index) {
+                       return fValues[index];
+               }
+
+               public int getSelection(String value) {
+                       if (value != null) {
+                               for (int i= 0; i < fValues.length; i++) {
+                                       if (value.equals(fValues[i])) {
+                                               return i;
+                                       }
+                               }
+                       }
+                       return fValues.length -1; // assume the last option is the least severe
+               }
+       }
+
+       private static final String REBUILD_COUNT_KEY= "preferences_build_requested"; //$NON-NLS-1$
+
+       private static final String SETTINGS_EXPANDED= "expanded"; //$NON-NLS-1$
+
+       protected final ArrayList<Button> fCheckBoxes;
+       protected final ArrayList<Combo> fComboBoxes;
+       protected final ArrayList<Text> fTextBoxes;
+       protected final HashMap<Control, Label> fLabels;
+       protected final ArrayList<ExpandableComposite> fExpandedComposites;
+
+       private SelectionListener fSelectionListener;
+       private ModifyListener fTextModifyListener;
+
+       protected IStatusChangeListener fContext;
+       protected final IProject fProject; // project or null
+       protected final Key[] fAllKeys;
+
+       private IScopeContext[] fLookupOrder;
+
+       private Shell fShell;
+
+       private final IWorkingCopyManager fManager;
+       private IWorkbenchPreferenceContainer fContainer;
+
+       private Map<Key, String> fDisabledProjectSettings; // null when project specific settings are turned off
+
+       private int fRebuildCount; // used to prevent multiple dialogs that ask for a rebuild
+
+       public OptionsConfigurationBlock(IStatusChangeListener context, IProject project, Key[] allKeys,
+                       IWorkbenchPreferenceContainer container) {
+               fContext= context;
+               fProject= project;
+               fAllKeys= allKeys;
+               fContainer= container;
+               if (container == null) {
+                       fManager= new WorkingCopyManager();
+               } else {
+                       fManager= container.getWorkingCopyManager();
+               }
+
+               if (fProject != null) {
+                       fLookupOrder= new IScopeContext[] {
+                               new ProjectScope(fProject),
+                               InstanceScope.INSTANCE,
+                               DefaultScope.INSTANCE
+                       };
+               } else {
+                       fLookupOrder= new IScopeContext[] {
+                               InstanceScope.INSTANCE,
+                               DefaultScope.INSTANCE
+                       };
+               }
+
+               checkIfOptionsComplete(allKeys);
+               if (fProject == null || hasProjectSpecificOptions(fProject)) {
+                       fDisabledProjectSettings= null;
+               } else {
+                       fDisabledProjectSettings= new IdentityHashMap<Key, String>();
+                       for (int i= 0; i < allKeys.length; i++) {
+                               Key curr= allKeys[i];
+                               fDisabledProjectSettings.put(curr, curr.getStoredValue(fLookupOrder, false, fManager));
+                       }
+               }
+
+               settingsUpdated();
+
+               fCheckBoxes= new ArrayList<Button>();
+               fComboBoxes= new ArrayList<Combo>();
+               fTextBoxes= new ArrayList<Text>(2);
+               fLabels= new HashMap<Control, Label>();
+               fExpandedComposites= new ArrayList<ExpandableComposite>();
+
+               fRebuildCount= getRebuildCount();
+       }
+
+       protected final IWorkbenchPreferenceContainer getPreferenceContainer() {
+               return fContainer;
+       }
+
+       protected static Key getKey(String plugin, String key) {
+               return new Key(plugin, key);
+       }
+
+       protected final static Key getCDTCoreKey(String key) {
+               return getKey(CCorePlugin.PLUGIN_ID, key);
+       }
+
+       protected final static Key getCDTUIKey(String key) {
+               return getKey(CUIPlugin.PLUGIN_ID, key);
+       }
+
+       private void checkIfOptionsComplete(Key[] allKeys) {
+               for (int i= 0; i < allKeys.length; i++) {
+                       if (allKeys[i].getStoredValue(fLookupOrder, false, fManager) == null) {
+                               CUIPlugin.logError("Preference option missing: " + allKeys[i] + " (" + this.getClass().getName() +')');  //$NON-NLS-1$//$NON-NLS-2$
+                       }
+               }
+       }
+
+       private int getRebuildCount() {
+               return fManager.getWorkingCopy(DefaultScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID)).getInt(REBUILD_COUNT_KEY, 0);
+       }
+
+       private void incrementRebuildCount() {
+               fRebuildCount++;
+               fManager.getWorkingCopy(DefaultScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID)).putInt(REBUILD_COUNT_KEY, fRebuildCount);
+       }
+
+       protected void settingsUpdated() {
+       }
+
+       public void selectOption(String key, String qualifier) {
+               for (int i= 0; i < fAllKeys.length; i++) {
+                       Key curr= fAllKeys[i];
+                       if (curr.getName().equals(key) && curr.getQualifier().equals(qualifier)) {
+                               selectOption(curr);
+                       }
+               }
+       }
+
+       public void selectOption(Key key) {
+               Control control= findControl(key);
+               if (control != null) {
+                       if (!fExpandedComposites.isEmpty()) {
+                               ExpandableComposite expandable= getParentExpandableComposite(control);
+                               if (expandable != null) {
+                                       for (int i= 0; i < fExpandedComposites.size(); i++) {
+                                               ExpandableComposite curr= fExpandedComposites.get(i);
+                                               curr.setExpanded(curr == expandable);
+                                       }
+                                       expandedStateChanged(expandable);
+                               }
+                       }
+                       control.setFocus();
+               }
+       }
+
+       public boolean hasProjectSpecificOptions(IProject project) {
+               if (project != null) {
+                       IScopeContext projectContext= new ProjectScope(project);
+                       Key[] allKeys= fAllKeys;
+                       for (int i= 0; i < allKeys.length; i++) {
+                               if (allKeys[i].getStoredValue(projectContext, fManager) != null) {
+                                       return true;
+                               }
+                       }
+               }
+               return false;
+       }
+
+       protected Shell getShell() {
+               return fShell;
+       }
+
+       protected void setShell(Shell shell) {
+               fShell= shell;
+       }
+
+       protected abstract Control createContents(Composite parent);
+
+       protected Button addCheckBox(Composite parent, String label, Key key, String[] values, int indent) {
+               ControlData data= new ControlData(key, values);
+
+               GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               gd.horizontalSpan= 3;
+               gd.horizontalIndent= indent;
+
+               Button checkBox= new Button(parent, SWT.CHECK);
+               checkBox.setFont(JFaceResources.getDialogFont());
+               checkBox.setText(label);
+               checkBox.setData(data);
+               checkBox.setLayoutData(gd);
+               checkBox.addSelectionListener(getSelectionListener());
+
+               makeScrollableCompositeAware(checkBox);
+
+               String currValue= getValue(key);
+               checkBox.setSelection(data.getSelection(currValue) == 0);
+
+               fCheckBoxes.add(checkBox);
+
+               return checkBox;
+       }
+
+       protected Button addCheckBoxWithLink(Composite parent, String label, Key key, String[] values,
+                       int indent, int widthHint, SelectionListener listener) {
+               ControlData data= new ControlData(key, values);
+
+               GridData gd= new GridData(GridData.FILL, GridData.FILL, true, false);
+               gd.horizontalSpan= 3;
+               gd.horizontalIndent= indent;
+
+               Composite composite= new Composite(parent, SWT.NONE);
+               GridLayout layout= new GridLayout();
+               layout.marginHeight= 0;
+               layout.marginWidth= 0;
+               layout.numColumns= 2;
+               composite.setLayout(layout);
+               composite.setLayoutData(gd);
+
+               Button checkBox= new Button(composite, SWT.CHECK);
+               checkBox.setFont(JFaceResources.getDialogFont());
+               checkBox.setData(data);
+               checkBox.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false));
+               checkBox.addSelectionListener(getSelectionListener());
+
+               gd= new GridData(GridData.FILL, GridData.CENTER, true, false);
+               gd.widthHint= widthHint;
+
+               Link link= new Link(composite, SWT.NONE);
+               link.setText(label);
+               link.setLayoutData(gd);
+               if (listener != null) {
+                       link.addSelectionListener(listener);
+               }
+
+               makeScrollableCompositeAware(link);
+               makeScrollableCompositeAware(checkBox);
+
+               String currValue= getValue(key);
+               checkBox.setSelection(data.getSelection(currValue) == 0);
+
+               fCheckBoxes.add(checkBox);
+
+               return checkBox;
+       }
+
+       protected Combo addComboBox(Composite parent, String label, Key key, String[] values,
+                       String[] valueLabels, int indent) {
+               GridData gd= new GridData(GridData.FILL, GridData.CENTER, false, false, 2, 1);
+               gd.horizontalIndent= indent;
+
+               Label labelControl= new Label(parent, SWT.LEFT);
+               labelControl.setFont(JFaceResources.getDialogFont());
+               labelControl.setText(label);
+               labelControl.setLayoutData(gd);
+
+               Combo comboBox= newComboControl(parent, key, values, valueLabels);
+               comboBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+
+               fLabels.put(comboBox, labelControl);
+
+               return comboBox;
+       }
+
+       protected Combo addInversedComboBox(Composite parent, String label, Key key, String[] values,
+                       String[] valueLabels, int indent) {
+               GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+               gd.horizontalIndent= indent;
+               gd.horizontalSpan= 3;
+
+               Composite composite= new Composite(parent, SWT.NONE);
+               GridLayout layout= new GridLayout();
+               layout.marginHeight= 0;
+               layout.marginWidth= 0;
+               layout.numColumns= 2;
+               composite.setLayout(layout);
+               composite.setLayoutData(gd);
+
+               Combo comboBox= newComboControl(composite, key, values, valueLabels);
+               comboBox.setFont(JFaceResources.getDialogFont());
+               comboBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+
+               Label labelControl= new Label(composite, SWT.LEFT | SWT.WRAP);
+               labelControl.setText(label);
+               labelControl.setLayoutData(new GridData());
+
+               fLabels.put(comboBox, labelControl);
+               return comboBox;
+       }
+
+       protected Combo newComboControl(Composite composite, Key key, String[] values, String[] valueLabels) {
+               ControlData data= new ControlData(key, values);
+
+               Combo comboBox= new Combo(composite, SWT.READ_ONLY);
+               comboBox.setItems(valueLabels);
+               comboBox.setData(data);
+               comboBox.addSelectionListener(getSelectionListener());
+               comboBox.setFont(JFaceResources.getDialogFont());
+
+               makeScrollableCompositeAware(comboBox);
+
+               String currValue= getValue(key);
+               comboBox.select(data.getSelection(currValue));
+
+               fComboBoxes.add(comboBox);
+               return comboBox;
+       }
+
+       protected Text addTextField(Composite parent, String label, Key key, int indent, int widthHint) {
+               return addTextField(parent, label, key, indent, widthHint, SWT.NONE);
+       }
+
+       protected Text addTextField(Composite parent, String label, Key key, int indent, int widthHint,
+                       int extraStyle) {
+               Label labelControl= new Label(parent, SWT.WRAP);
+               labelControl.setText(label);
+               labelControl.setFont(JFaceResources.getDialogFont());
+               GridData data= new GridData();
+               data.horizontalIndent= indent;
+               labelControl.setLayoutData(data);
+
+               Text textBox= new Text(parent, SWT.BORDER | SWT.SINGLE | extraStyle);
+               textBox.setData(key);
+
+               makeScrollableCompositeAware(textBox);
+
+               fLabels.put(textBox, labelControl);
+
+               if (key != null) {
+                       String currValue= getValue(key);
+                       if (currValue != null) {
+                               textBox.setText(currValue);
+                       }
+                       textBox.addModifyListener(getTextModifyListener());
+               }
+
+               data= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               if (widthHint != 0) {
+                       data.widthHint= widthHint;
+               }
+               data.horizontalSpan= 2;
+               textBox.setLayoutData(data);
+
+               fTextBoxes.add(textBox);
+               return textBox;
+       }
+
+       protected ScrolledPageContent getParentScrolledComposite(Control control) {
+               Control parent= control.getParent();
+               while (!(parent instanceof ScrolledPageContent) && parent != null) {
+                       parent= parent.getParent();
+               }
+               if (parent instanceof ScrolledPageContent) {
+                       return (ScrolledPageContent) parent;
+               }
+               return null;
+       }
+
+       protected ExpandableComposite getParentExpandableComposite(Control control) {
+               Control parent= control.getParent();
+               while (!(parent instanceof ExpandableComposite) && parent != null) {
+                       parent= parent.getParent();
+               }
+               if (parent instanceof ExpandableComposite) {
+                       return (ExpandableComposite) parent;
+               }
+               return null;
+       }
+
+       private void makeScrollableCompositeAware(Control control) {
+               ScrolledPageContent parentScrolledComposite= getParentScrolledComposite(control);
+               if (parentScrolledComposite != null) {
+                       parentScrolledComposite.adaptChild(control);
+               }
+       }
+
+       protected ExpandableComposite createStyleSection(Composite parent, String label, int nColumns) {
+               ExpandableComposite excomposite= new ExpandableComposite(parent, SWT.NONE,
+                               ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
+               excomposite.setText(label);
+               excomposite.setExpanded(false);
+               excomposite.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
+               excomposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, nColumns, 1));
+               excomposite.addExpansionListener(new ExpansionAdapter() {
+                       @Override
+                       public void expansionStateChanged(ExpansionEvent e) {
+                               expandedStateChanged((ExpandableComposite) e.getSource());
+                       }
+               });
+               fExpandedComposites.add(excomposite);
+               makeScrollableCompositeAware(excomposite);
+               return excomposite;
+       }
+
+       protected final void expandedStateChanged(ExpandableComposite expandable) {
+               ScrolledPageContent parentScrolledComposite= getParentScrolledComposite(expandable);
+               if (parentScrolledComposite != null) {
+                       parentScrolledComposite.reflow(true);
+               }
+       }
+
+       protected void restoreSectionExpansionStates(IDialogSettings settings) {
+               for (int i= 0; i < fExpandedComposites.size(); i++) {
+                       ExpandableComposite excomposite= fExpandedComposites.get(i);
+                       if (settings == null) {
+                               excomposite.setExpanded(i == 0); // only expand the first node by default
+                       } else {
+                               excomposite.setExpanded(settings.getBoolean(SETTINGS_EXPANDED + String.valueOf(i)));
+                       }
+               }
+       }
+
+       protected void storeSectionExpansionStates(IDialogSettings settings) {
+               for (int i= 0; i < fExpandedComposites.size(); i++) {
+                       ExpandableComposite curr= fExpandedComposites.get(i);
+                       settings.put(SETTINGS_EXPANDED + String.valueOf(i), curr.isExpanded());
+               }
+       }
+
+       protected SelectionListener getSelectionListener() {
+               if (fSelectionListener == null) {
+                       fSelectionListener= new SelectionListener() {
+                               public void widgetDefaultSelected(SelectionEvent e) {}
+
+                               public void widgetSelected(SelectionEvent e) {
+                                       controlChanged(e.widget);
+                               }
+                       };
+               }
+               return fSelectionListener;
+       }
+
+       protected ModifyListener getTextModifyListener() {
+               if (fTextModifyListener == null) {
+                       fTextModifyListener= new ModifyListener() {
+                               public void modifyText(ModifyEvent e) {
+                                       textChanged((Text) e.widget);
+                               }
+                       };
+               }
+               return fTextModifyListener;
+       }
+
+       protected void controlChanged(Widget widget) {
+               ControlData data= (ControlData) widget.getData();
+               String newValue= null;
+               if (widget instanceof Button) {
+                       newValue= data.getValue(((Button) widget).getSelection());
+               } else if (widget instanceof Combo) {
+                       newValue= data.getValue(((Combo) widget).getSelectionIndex());
+               } else {
+                       return;
+               }
+               String oldValue= setValue(data.getKey(), newValue);
+               validateSettings(data.getKey(), oldValue, newValue);
+       }
+
+       protected void textChanged(Text textControl) {
+               Key key= (Key) textControl.getData();
+               if (key != null) {
+                       String newValue= textControl.getText();
+                       String oldValue= setValue(key, newValue);
+                       validateSettings(key, oldValue, newValue);
+               }
+       }
+
+       protected boolean checkValue(Key key, String value) {
+               return value.equals(getValue(key));
+       }
+
+       protected String getValue(Key key) {
+               if (fDisabledProjectSettings != null) {
+                       return fDisabledProjectSettings.get(key);
+               }
+               return key.getStoredValue(fLookupOrder, false, fManager);
+       }
+
+
+       protected boolean getBooleanValue(Key key) {
+               return Boolean.valueOf(getValue(key)).booleanValue();
+       }
+
+       protected String setValue(Key key, String value) {
+               if (fDisabledProjectSettings != null) {
+                       return fDisabledProjectSettings.put(key, value);
+               }
+               String oldValue= getValue(key);
+               key.setStoredValue(fLookupOrder[0], value, fManager);
+               return oldValue;
+       }
+
+       protected String setValue(Key key, boolean value) {
+               return setValue(key, String.valueOf(value));
+       }
+
+       /**
+        * Returns the value as actually stored in the preference store.
+        * @param key
+        * @return the value as actually stored in the preference store.
+        */
+       protected String getStoredValue(Key key) {
+               return key.getStoredValue(fLookupOrder, false, fManager);
+       }
+
+       /**
+        * Update fields and validate.
+        * @param changedKey Key that changed, or null, if all changed.
+        */
+       protected abstract void validateSettings(Key changedKey, String oldValue, String newValue);
+
+       protected String[] getTokens(String text, String separator) {
+               StringTokenizer tok= new StringTokenizer(text, separator); 
+               int nTokens= tok.countTokens();
+               String[] res= new String[nTokens];
+               for (int i= 0; i < res.length; i++) {
+                       res[i]= tok.nextToken().trim();
+               }
+               return res;
+       }
+
+       private boolean getChanges(IScopeContext currContext, List<Key> changedSettings) {
+               boolean needsBuild= false;
+               for (int i= 0; i < fAllKeys.length; i++) {
+                       Key key= fAllKeys[i];
+                       String oldVal= key.getStoredValue(currContext, null);
+                       String val= key.getStoredValue(currContext, fManager);
+                       if (val == null) {
+                               if (oldVal != null) {
+                                       changedSettings.add(key);
+                                       needsBuild |= !oldVal.equals(key.getStoredValue(fLookupOrder, true, fManager));
+                               }
+                       } else if (!val.equals(oldVal)) {
+                               changedSettings.add(key);
+                               needsBuild |= oldVal != null || !val.equals(key.getStoredValue(fLookupOrder, true, fManager));
+                       }
+               }
+               return needsBuild;
+       }
+
+       public void useProjectSpecificSettings(boolean enable) {
+               boolean hasProjectSpecificOption= fDisabledProjectSettings == null;
+               if (enable != hasProjectSpecificOption && fProject != null) {
+                       if (enable) {
+                               for (int i= 0; i < fAllKeys.length; i++) {
+                                       Key curr= fAllKeys[i];
+                                       String val= fDisabledProjectSettings.get(curr);
+                                       curr.setStoredValue(fLookupOrder[0], val, fManager);
+                               }
+                               fDisabledProjectSettings= null;
+                               updateControls();
+                               validateSettings(null, null, null);
+                       } else {
+                               fDisabledProjectSettings= new IdentityHashMap<Key, String>();
+                               for (int i= 0; i < fAllKeys.length; i++) {
+                                       Key curr= fAllKeys[i];
+                                       String oldSetting= curr.getStoredValue(fLookupOrder, false, fManager);
+                                       fDisabledProjectSettings.put(curr, oldSetting);
+                                       curr.setStoredValue(fLookupOrder[0], null, fManager); // clear project settings
+                               }
+                       }
+               }
+       }
+
+       public boolean areSettingsEnabled() {
+               return fDisabledProjectSettings == null || fProject == null;
+       }
+
+       public boolean performOk() {
+               return processChanges(fContainer);
+       }
+
+       public boolean performApply() {
+               return processChanges(null); // apply directly
+       }
+
+       protected boolean processChanges(IWorkbenchPreferenceContainer container) {
+               IScopeContext currContext= fLookupOrder[0];
+
+               List<Key> changedOptions= new ArrayList<Key>();
+               boolean needsBuild= getChanges(currContext, changedOptions);
+               if (changedOptions.isEmpty()) {
+                       return true;
+               }
+               if (needsBuild) {
+                       int count= getRebuildCount();
+                       if (count > fRebuildCount) {
+                               needsBuild= false; // build already requested
+                               fRebuildCount= count;
+                       }
+               }
+
+               boolean doBuild= false;
+               if (needsBuild) {
+                       String[] strings= getFullBuildDialogStrings(fProject == null);
+                       if (strings != null) {
+                               MessageDialog dialog= new MessageDialog(getShell(), strings[0], null, strings[1], MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2);
+                               int res= dialog.open();
+                               if (res == 0) {
+                                       doBuild= true;
+                               } else if (res != 1) {
+                                       return false; // cancel pressed
+                               }
+                       }
+               }
+               if (container != null) {
+                       // no need to apply the changes to the original store: will be done by the page container
+                       if (doBuild) { // post build
+                               incrementRebuildCount();
+                               // do a re-index?
+//                             container.registerUpdateJob(CoreUtility.getBuildJob(fProject));
+                       }
+               } else {
+                       // apply changes right away
+                       try {
+                               fManager.applyChanges();
+                       } catch (BackingStoreException e) {
+                               CUIPlugin.log(e);
+                               return false;
+                       }
+                       if (doBuild) {
+                               // do a re-index?
+//                             CoreUtility.getBuildJob(fProject).schedule();
+                       }
+
+               }
+               return true;
+       }
+
+       private final String[] getFullBuildDialogStrings(boolean workspaceSettings) {
+               // rebuild (re-index) is not implemented
+               // no builds triggered by our settings
+               return null;
+       }
+
+       public void performDefaults() {
+               for (int i= 0; i < fAllKeys.length; i++) {
+                       Key curr= fAllKeys[i];
+                       String defValue= curr.getStoredValue(fLookupOrder, true, fManager);
+                       setValue(curr, defValue);
+               }
+
+               settingsUpdated();
+               updateControls();
+               validateSettings(null, null, null);
+       }
+
+       /**
+        * @since 3.1
+        */
+       public void performRevert() {
+               for (int i= 0; i < fAllKeys.length; i++) {
+                       Key curr= fAllKeys[i];
+                       String origValue= curr.getStoredValue(fLookupOrder, false, null);
+                       setValue(curr, origValue);
+               }
+
+               settingsUpdated();
+               updateControls();
+               validateSettings(null, null, null);
+       }
+
+       public void dispose() {
+       }
+
+       protected void updateControls() {
+               // update the UI
+               for (int i= fCheckBoxes.size() - 1; i >= 0; i--) {
+                       updateCheckBox(fCheckBoxes.get(i));
+               }
+               for (int i= fComboBoxes.size() - 1; i >= 0; i--) {
+                       updateCombo(fComboBoxes.get(i));
+               }
+               for (int i= fTextBoxes.size() - 1; i >= 0; i--) {
+                       updateText(fTextBoxes.get(i));
+               }
+       }
+
+       protected void updateCombo(Combo curr) {
+               ControlData data= (ControlData) curr.getData();
+
+               String currValue= getValue(data.getKey());
+               curr.select(data.getSelection(currValue));
+       }
+
+       protected void updateCheckBox(Button curr) {
+               ControlData data= (ControlData) curr.getData();
+
+               String currValue= getValue(data.getKey());
+               curr.setSelection(data.getSelection(currValue) == 0);
+       }
+
+       protected void updateText(Text curr) {
+               Key key= (Key) curr.getData();
+               if (key != null) {
+                       String currValue= getValue(key);
+                       if (currValue != null) {
+                               curr.setText(currValue);
+                       }
+               }
+       }
+
+       protected Button getCheckBox(Key key) {
+               for (int i= fCheckBoxes.size() - 1; i >= 0; i--) {
+                       Button curr= fCheckBoxes.get(i);
+                       ControlData data= (ControlData) curr.getData();
+                       if (key.equals(data.getKey())) {
+                               return curr;
+                       }
+               }
+               return null;
+       }
+
+       protected Combo getComboBox(Key key) {
+               for (int i= fComboBoxes.size() - 1; i >= 0; i--) {
+                       Combo curr= fComboBoxes.get(i);
+                       ControlData data= (ControlData) curr.getData();
+                       if (key.equals(data.getKey())) {
+                               return curr;
+                       }
+               }
+               return null;
+       }
+
+       protected Text getTextControl(Key key) {
+               for (int i= fTextBoxes.size() - 1; i >= 0; i--) {
+                       Text curr= fTextBoxes.get(i);
+                       ControlData data= (ControlData) curr.getData();
+                       if (key.equals(data.getKey())) {
+                               return curr;
+                       }
+               }
+               return null;
+       }
+
+       protected Control findControl(Key key) {
+               Combo comboBox= getComboBox(key);
+               if (comboBox != null) {
+                       return comboBox;
+               }
+               Button checkBox= getCheckBox(key);
+               if (checkBox != null) {
+                       return checkBox;
+               }
+               Text text= getTextControl(key);
+               if (text != null) {
+                       return text;
+               }
+               return null;
+       }
+
+       protected Control getLabel(Control control) {
+               return fLabels.get(control);
+       }
+
+       protected void setComboEnabled(Key key, boolean enabled) {
+               Combo combo= getComboBox(key);
+               Label label= fLabels.get(combo);
+               combo.setEnabled(enabled);
+               label.setEnabled(enabled);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OverlayPreferenceStore.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OverlayPreferenceStore.java
new file mode 100644 (file)
index 0000000..e3acfd7
--- /dev/null
@@ -0,0 +1,485 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+/**
+ * An overlaying preference store.
+ */
+public class OverlayPreferenceStore  implements IPreferenceStore {
+       
+       
+       public static final class TypeDescriptor {
+               protected TypeDescriptor() {
+               }
+       }
+       
+       public static final TypeDescriptor BOOLEAN= new TypeDescriptor();
+       public static final TypeDescriptor DOUBLE= new TypeDescriptor();
+       public static final TypeDescriptor FLOAT= new TypeDescriptor();
+       public static final TypeDescriptor INT= new TypeDescriptor();
+       public static final TypeDescriptor LONG= new TypeDescriptor();
+       public static final TypeDescriptor STRING= new TypeDescriptor();
+       
+       public static class OverlayKey {
+               
+               TypeDescriptor fDescriptor;
+               String fKey;
+               
+               public OverlayKey(TypeDescriptor descriptor, String key) {
+                       fDescriptor= descriptor;
+                       fKey= key;
+               }
+       }
+       
+       private class PropertyListener implements IPropertyChangeListener {
+                               
+               /*
+                * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
+                */
+               public void propertyChange(PropertyChangeEvent event) {
+                       OverlayKey key= findOverlayKey(event.getProperty());
+                       if (key != null)
+                               propagateProperty(fParent, key, fStore); 
+               }
+       }
+       
+       
+       protected IPreferenceStore fParent;
+       protected IPreferenceStore fStore;
+       private OverlayKey[] fOverlayKeys;
+       private boolean fLoaded;
+       private PropertyListener fPropertyListener;
+       
+       
+       public OverlayPreferenceStore(IPreferenceStore parent, OverlayKey[] overlayKeys) {
+               fParent= parent;
+               fOverlayKeys= overlayKeys;
+               fStore= new PreferenceStore();
+       }
+       
+       protected OverlayKey findOverlayKey(String key) {
+               for (int i= 0; i < fOverlayKeys.length; i++) {
+                       if (fOverlayKeys[i].fKey.equals(key))
+                               return fOverlayKeys[i];
+               }
+               return null;
+       }
+       
+       private boolean covers(String key) {
+               return (findOverlayKey(key) != null);
+       }
+       
+       protected void propagateProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target) {
+               
+               if (orgin.isDefault(key.fKey)) {
+                       if (!target.isDefault(key.fKey))
+                               target.setToDefault(key.fKey);
+                       return;
+               }
+               
+               TypeDescriptor d= key.fDescriptor;
+               if (BOOLEAN == d) {
+                       
+                       boolean originValue= orgin.getBoolean(key.fKey);
+                       boolean targetValue= target.getBoolean(key.fKey);
+                       if (targetValue != originValue)
+                               target.setValue(key.fKey, originValue);
+                               
+               } else if (DOUBLE == d) {
+                       
+                       double originValue= orgin.getDouble(key.fKey);
+                       double targetValue= target.getDouble(key.fKey);
+                       if (targetValue != originValue)
+                               target.setValue(key.fKey, originValue);
+               
+               } else if (FLOAT == d) {
+                       
+                       float originValue= orgin.getFloat(key.fKey);
+                       float targetValue= target.getFloat(key.fKey);
+                       if (targetValue != originValue)
+                               target.setValue(key.fKey, originValue);
+                               
+               } else if (INT == d) {
+
+                       int originValue= orgin.getInt(key.fKey);
+                       int targetValue= target.getInt(key.fKey);
+                       if (targetValue != originValue)
+                               target.setValue(key.fKey, originValue);
+
+               } else if (LONG == d) {
+
+                       long originValue= orgin.getLong(key.fKey);
+                       long targetValue= target.getLong(key.fKey);
+                       if (targetValue != originValue)
+                               target.setValue(key.fKey, originValue);
+
+               } else if (STRING == d) {
+
+                       String originValue= orgin.getString(key.fKey);
+                       String targetValue= target.getString(key.fKey);
+                       if (targetValue != null && originValue != null && !targetValue.equals(originValue))
+                               target.setValue(key.fKey, originValue);
+
+               }
+       }
+       
+       public void propagate() {
+               for (int i= 0; i < fOverlayKeys.length; i++)
+                       propagateProperty(fStore, fOverlayKeys[i], fParent);
+       }
+       
+       private void loadProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target, boolean forceInitialization) {
+               TypeDescriptor d= key.fDescriptor;
+               if (BOOLEAN == d) {
+                       
+                       if (forceInitialization)
+                               target.setValue(key.fKey, true);
+                       target.setValue(key.fKey, orgin.getBoolean(key.fKey));
+                       target.setDefault(key.fKey, orgin.getDefaultBoolean(key.fKey));
+                       
+               } else if (DOUBLE == d) {
+                       
+                       if (forceInitialization)
+                               target.setValue(key.fKey, 1.0D);
+                       target.setValue(key.fKey, orgin.getDouble(key.fKey));
+                       target.setDefault(key.fKey, orgin.getDefaultDouble(key.fKey));
+                       
+               } else if (FLOAT == d) {
+                       
+                       if (forceInitialization)
+                               target.setValue(key.fKey, 1.0F);
+                       target.setValue(key.fKey, orgin.getFloat(key.fKey));
+                       target.setDefault(key.fKey, orgin.getDefaultFloat(key.fKey));
+                       
+               } else if (INT == d) {
+                       
+                       if (forceInitialization)
+                               target.setValue(key.fKey, 1);
+                       target.setValue(key.fKey, orgin.getInt(key.fKey));
+                       target.setDefault(key.fKey, orgin.getDefaultInt(key.fKey));
+                       
+               } else if (LONG == d) {
+                       
+                       if (forceInitialization)
+                               target.setValue(key.fKey, 1L);
+                       target.setValue(key.fKey, orgin.getLong(key.fKey));
+                       target.setDefault(key.fKey, orgin.getDefaultLong(key.fKey));
+                       
+               } else if (STRING == d) {
+                       
+                       if (forceInitialization)
+                               target.setValue(key.fKey, "1"); //$NON-NLS-1$
+                       target.setValue(key.fKey, orgin.getString(key.fKey));
+                       target.setDefault(key.fKey, orgin.getDefaultString(key.fKey));
+                       
+               }
+       }
+       
+       public void load() {
+               for (int i= 0; i < fOverlayKeys.length; i++)
+                       loadProperty(fParent, fOverlayKeys[i], fStore, true);
+
+               fLoaded= true;
+       }
+       
+       public void loadDefaults() {
+               for (int i= 0; i < fOverlayKeys.length; i++)
+                       setToDefault(fOverlayKeys[i].fKey);
+       }
+       
+       public void start() {
+               if (fPropertyListener == null) {
+                       fPropertyListener= new PropertyListener();
+                       fParent.addPropertyChangeListener(fPropertyListener);
+               }
+       }
+       
+       public void stop() {
+               if (fPropertyListener != null)  {
+                       fParent.removePropertyChangeListener(fPropertyListener);
+                       fPropertyListener= null;
+               }
+       }
+       
+       /*
+        * @see IPreferenceStore#addPropertyChangeListener(IPropertyChangeListener)
+        */
+       public void addPropertyChangeListener(IPropertyChangeListener listener) {
+               fStore.addPropertyChangeListener(listener);
+       }
+       
+       /*
+        * @see IPreferenceStore#removePropertyChangeListener(IPropertyChangeListener)
+        */
+       public void removePropertyChangeListener(IPropertyChangeListener listener) {
+               fStore.removePropertyChangeListener(listener);
+       }
+       
+       /*
+        * @see IPreferenceStore#firePropertyChangeEvent(String, Object, Object)
+        */
+       public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {
+               fStore.firePropertyChangeEvent(name, oldValue, newValue);
+       }
+
+       /*
+        * @see IPreferenceStore#contains(String)
+        */
+       public boolean contains(String name) {
+               return fStore.contains(name);
+       }
+       
+       /*
+        * @see IPreferenceStore#getBoolean(String)
+        */
+       public boolean getBoolean(String name) {
+               return fStore.getBoolean(name);
+       }
+
+       /*
+        * @see IPreferenceStore#getDefaultBoolean(String)
+        */
+       public boolean getDefaultBoolean(String name) {
+               return fStore.getDefaultBoolean(name);
+       }
+
+       /*
+        * @see IPreferenceStore#getDefaultDouble(String)
+        */
+       public double getDefaultDouble(String name) {
+               return fStore.getDefaultDouble(name);
+       }
+
+       /*
+        * @see IPreferenceStore#getDefaultFloat(String)
+        */
+       public float getDefaultFloat(String name) {
+               return fStore.getDefaultFloat(name);
+       }
+
+       /*
+        * @see IPreferenceStore#getDefaultInt(String)
+        */
+       public int getDefaultInt(String name) {
+               return fStore.getDefaultInt(name);
+       }
+
+       /*
+        * @see IPreferenceStore#getDefaultLong(String)
+        */
+       public long getDefaultLong(String name) {
+               return fStore.getDefaultLong(name);
+       }
+
+       /*
+        * @see IPreferenceStore#getDefaultString(String)
+        */
+       public String getDefaultString(String name) {
+               return fStore.getDefaultString(name);
+       }
+
+       /*
+        * @see IPreferenceStore#getDouble(String)
+        */
+       public double getDouble(String name) {
+               return fStore.getDouble(name);
+       }
+
+       /*
+        * @see IPreferenceStore#getFloat(String)
+        */
+       public float getFloat(String name) {
+               return fStore.getFloat(name);
+       }
+
+       /*
+        * @see IPreferenceStore#getInt(String)
+        */
+       public int getInt(String name) {
+               return fStore.getInt(name);
+       }
+
+       /*
+        * @see IPreferenceStore#getLong(String)
+        */
+       public long getLong(String name) {
+               return fStore.getLong(name);
+       }
+
+       /*
+        * @see IPreferenceStore#getString(String)
+        */
+       public String getString(String name) {
+               return fStore.getString(name);
+       }
+
+       /*
+        * @see IPreferenceStore#isDefault(String)
+        */
+       public boolean isDefault(String name) {
+               return fStore.isDefault(name);
+       }
+
+       /*
+        * @see IPreferenceStore#needsSaving()
+        */
+       public boolean needsSaving() {
+               return fStore.needsSaving();
+       }
+
+       /*
+        * @see IPreferenceStore#putValue(String, String)
+        */
+       public void putValue(String name, String value) {
+               if (covers(name))
+                       fStore.putValue(name, value);
+       }
+
+       /*
+        * @see IPreferenceStore#setDefault(String, double)
+        */
+       public void setDefault(String name, double value) {
+               if (covers(name))
+                       fStore.setDefault(name, value);
+       }
+
+       /*
+        * @see IPreferenceStore#setDefault(String, float)
+        */
+       public void setDefault(String name, float value) {
+               if (covers(name))
+                       fStore.setDefault(name, value);
+       }
+
+       /*
+        * @see IPreferenceStore#setDefault(String, int)
+        */
+       public void setDefault(String name, int value) {
+               if (covers(name))
+                       fStore.setDefault(name, value);
+       }
+
+       /*
+        * @see IPreferenceStore#setDefault(String, long)
+        */
+       public void setDefault(String name, long value) {
+               if (covers(name))
+                       fStore.setDefault(name, value);
+       }
+
+       /*
+        * @see IPreferenceStore#setDefault(String, String)
+        */
+       public void setDefault(String name, String value) {
+               if (covers(name))
+                       fStore.setDefault(name, value);
+       }
+
+       /*
+        * @see IPreferenceStore#setDefault(String, boolean)
+        */
+       public void setDefault(String name, boolean value) {
+               if (covers(name))
+                       fStore.setDefault(name, value);
+       }
+
+       /*
+        * @see IPreferenceStore#setToDefault(String)
+        */
+       public void setToDefault(String name) {
+               fStore.setToDefault(name);
+       }
+
+       /*
+        * @see IPreferenceStore#setValue(String, double)
+        */
+       public void setValue(String name, double value) {
+               if (covers(name))
+                       fStore.setValue(name, value);
+       }
+
+       /*
+        * @see IPreferenceStore#setValue(String, float)
+        */
+       public void setValue(String name, float value) {
+               if (covers(name))
+                       fStore.setValue(name, value);
+       }
+
+       /*
+        * @see IPreferenceStore#setValue(String, int)
+        */
+       public void setValue(String name, int value) {
+               if (covers(name))
+                       fStore.setValue(name, value);
+       }
+
+       /*
+        * @see IPreferenceStore#setValue(String, long)
+        */
+       public void setValue(String name, long value) {
+               if (covers(name))
+                       fStore.setValue(name, value);
+       }
+
+       /*
+        * @see IPreferenceStore#setValue(String, String)
+        */
+       public void setValue(String name, String value) {
+               if (covers(name))
+                       fStore.setValue(name, value);
+       }
+
+       /*
+        * @see IPreferenceStore#setValue(String, boolean)
+        */
+       public void setValue(String name, boolean value) {
+               if (covers(name))
+                       fStore.setValue(name, value);
+       }
+
+       /**
+        * The keys to add to the list of overlay keys.
+        * <p>
+        * Note: This method must be called before {@link #load()} is called. 
+        * </p>
+        * 
+        * @param keys
+        * @since 3.0
+        */
+       public void addKeys(OverlayKey[] keys) {
+               Assert.isTrue(!fLoaded);
+               Assert.isNotNull(keys);
+               
+               int overlayKeysLength= fOverlayKeys.length;
+               OverlayKey[] result= new OverlayKey[keys.length + overlayKeysLength];
+
+               for (int i= 0, length= overlayKeysLength; i < length; i++)
+                       result[i]= fOverlayKeys[i];
+               
+               for (int i= 0, length= keys.length; i < length; i++)
+                       result[overlayKeysLength + i]= keys[i];
+               
+               fOverlayKeys= result;
+               
+               if (fLoaded)
+                       load();
+       }
+
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariableDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariableDialog.java
new file mode 100644 (file)
index 0000000..1c520d4
--- /dev/null
@@ -0,0 +1,576 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.io.File;
+import java.util.Set;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @deprecated in CDT 8.0. This class appears to be never used.
+ */
+@Deprecated
+public class PathEntryVariableDialog extends TitleAreaDialog {
+       
+       // UI widgets
+       private Button okButton;
+       
+       private Label variableNameLabel;
+       
+       private Label variableValueLabel;
+       
+       private Text variableNameField;
+       
+       private Text variableValueField;
+       
+       private Button fileButton;
+       
+       private Button folderButton;
+       
+       /**
+        * This dialog type: <code>NEW_VARIABLE</code> or
+        * <code>EXISTING_VARIABLE</code>.
+        */
+       private int type;
+       
+       /**
+        * The type of variable that can be edited in this dialog.
+        * <code>IResource.FILE</code> or <code>IResource.FOLDER</code>
+        */
+       private int variableType;
+       
+       /**
+        * The name of the variable being edited.
+        */
+       private String variableName;
+       
+       /**
+        * The value of the variable being edited.
+        */
+       private String variableValue;
+       
+       /**
+        * The original name of the variable being edited. It is used when testing
+        * if the current variable's name is already in use.
+        */
+       private String originalName;
+       
+       /**
+        * Used to select the proper message depending on the current mode
+        * (new/existing variable).
+        */
+       private boolean newVariable;
+       
+       /**
+        * Set of variable names currently in use. Used when warning the user that
+        * the currently selected name is already in use by another variable.
+        */
+       private Set<String> namesInUse;
+       
+       /**
+        * The current validation status. Its value can be one of the following:<ul>
+        * <li><code>IMessageProvider.NONE</code> (default);</li>
+        * <li><code>IMessageProvider.WARNING</code>;</li>
+        * <li><code>IMessageProvider.ERROR</code>;</li>
+        * </ul>
+        * Used when validating the user input.
+        */
+       private int validationStatus;
+       
+       /**
+        * The current validation message generated by the last
+        * call to a <code>validate</code> method.
+        */
+       private String validationMessage;
+       
+       /**
+        * Whether a variable name has been entered.  
+        */
+       private boolean nameEntered = false;
+       
+       /**
+        * Whether a variable location has been entered.  
+        */
+       private boolean locationEntered = false;
+       
+       /**
+        * The standard message to be shown when there are no problems being
+        * reported.
+        */
+       final private String standardMessage;
+       
+       /**
+        * Constant for defining this dialog as intended to create a new variable
+        * (value = 1).
+        */
+       public final static int NEW_VARIABLE = 1;
+       
+       /**
+        * Constant for defining this dialog as intended to edit an existing
+        * variable (value = 2).
+        */
+       public final static int EXISTING_VARIABLE = 2;
+       
+       /**
+        * Constructs a dialog for editing a new/existing path variable.
+        * 
+        * @param parentShell the parent shell
+        * @param type the dialog type: <code>NEW_VARIABLE</code> or
+        *      <code>EXISTING_VARIABLE</code>
+        * @param variableType the type of variable that can be edited in 
+        *      this dialog. <code>IResource.FILE</code> or <code>IResource.FOLDER</code>
+        * @param namesInUse a set of variable names currently in use 
+        */
+       public PathEntryVariableDialog(Shell parentShell, int type, int variableType, Set<String> namesInUse) {
+               super(parentShell);
+               this.type = type;
+               this.newVariable = type == NEW_VARIABLE;
+               this.variableName = ""; //$NON-NLS-1$
+               this.variableValue = ""; //$NON-NLS-1$
+               this.variableType = variableType;
+               this.namesInUse = namesInUse;
+               
+               if (newVariable)
+                       this.standardMessage = PreferencesMessages.PathEntryVariableDialog_message_newVariable; 
+               else
+                       this.standardMessage = PreferencesMessages.PathEntryVariableDialog_message_existingVariable; 
+       }
+       
+       /**
+        * Configures this dialog's shell, setting the shell's text.
+        * 
+        * @see org.eclipse.jface.window.Window#configureShell(Shell)
+        */
+       @Override
+       protected void configureShell(Shell shell) {
+               super.configureShell(shell);
+               if (newVariable)
+                       shell.setText(PreferencesMessages.PathEntryVariableDialog_shellTitle_newVariable); 
+               else
+                       shell
+                       .setText(PreferencesMessages.PathEntryVariableDialog_shellTitle_existingVariable); 
+       }
+       
+       /**
+        * Creates and returns the contents of this dialog (except for the button bar).
+        * 
+        * @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea
+        */
+       @Override
+       protected Control createDialogArea(Composite parent) {
+               // top level composite
+               Composite parentComposite = (Composite) super.createDialogArea(parent);
+               
+               // creates dialog area composite
+               Composite contents = createComposite(parentComposite);
+               
+               // creates and lay outs dialog area widgets 
+               createWidgets(contents, parent.getFont());
+               
+               // validate possibly already incorrect variable definitions
+               if (type == EXISTING_VARIABLE) {
+                       nameEntered = locationEntered = true;
+                       validateVariableValue();
+               }
+               
+               return contents;
+       }
+       
+       /**
+        * Creates and configures this dialog's main composite.
+        * 
+        * @param parentComposite parent's composite
+        * @return this dialog's main composite
+        */
+       private Composite createComposite(Composite parentComposite) {
+               // creates a composite with standard margins and spacing
+               Composite contents = new Composite(parentComposite, SWT.NONE);
+               
+               FormLayout layout = new FormLayout();
+               
+               layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+               layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+               
+               contents.setLayout(layout);
+               contents.setFont(parentComposite.getFont());
+               
+               if (newVariable)
+                       setTitle(PreferencesMessages.PathEntryVariableDialog_dialogTitle_newVariable); 
+               else
+                       setTitle(PreferencesMessages.PathEntryVariableDialog_dialogTitle_existingVariable); 
+               setMessage(standardMessage);
+               return contents;
+       }
+       
+       /**
+        * Creates widgets for this dialog.
+        * 
+        * @param parent the parent composite where to create widgets
+        * @param contents 
+        */
+       private void createWidgets(Composite contents, Font font) {
+               FormData data;
+               
+               String nameLabelText = PreferencesMessages.PathEntryVariableDialog_variableName; 
+               String valueLabelText = PreferencesMessages.PathEntryVariableDialog_variableValue; 
+               
+               // variable name label
+               variableNameLabel = new Label(contents, SWT.LEFT);
+               variableNameLabel.setText(nameLabelText);
+               
+               data = new FormData();
+               variableNameLabel.setLayoutData(data);
+               variableNameLabel.setFont(font);
+               
+               // variable value label
+               variableValueLabel = new Label(contents, SWT.LEFT);
+               variableValueLabel.setText(valueLabelText);
+               
+               data = new FormData();
+               data.top = new FormAttachment(variableNameLabel,
+                               convertVerticalDLUsToPixels(10));
+               variableValueLabel.setLayoutData(data);
+               variableValueLabel.setFont(font);
+               
+               // the larger label will be used in the left attachments for the fields  
+               Label largerLabel = nameLabelText.length() > valueLabelText.length() ? variableNameLabel
+                               : variableValueLabel;
+               
+               // variable name field
+               variableNameField = new Text(contents, SWT.SINGLE | SWT.BORDER);
+               variableNameField.setText(variableName);
+               
+               data = new FormData();
+               data.width = convertWidthInCharsToPixels(50);
+               data.left = new FormAttachment(largerLabel,
+                               convertHorizontalDLUsToPixels(5));
+               variableNameField.setLayoutData(data);
+               variableNameField.setFont(font);
+               variableNameField.setFocus();
+               
+               variableNameField.addModifyListener(new ModifyListener() {
+                       public void modifyText(ModifyEvent event) {
+                               variableNameModified();
+                       }
+               });
+               
+               // variable value field
+               variableValueField = new Text(contents, SWT.SINGLE | SWT.BORDER);
+               variableValueField.setText(variableValue);
+               
+               data = new FormData();
+               data.width = convertWidthInCharsToPixels(50);
+               data.left = new FormAttachment(largerLabel,
+                               convertHorizontalDLUsToPixels(5));
+               data.top = new FormAttachment(variableNameLabel,
+                               convertVerticalDLUsToPixels(10));
+               variableValueField.setLayoutData(data);
+               variableValueField.setFont(font);
+               
+               variableValueField.addModifyListener(new ModifyListener() {
+                       public void modifyText(ModifyEvent event) {
+                               variableValueModified();
+                       }
+               });
+               
+               // select file path button
+               fileButton = new Button(contents, SWT.PUSH);
+               fileButton.setText(PreferencesMessages.PathEntryVariableDialog_file); 
+               if ((variableType & IResource.FILE) == 0)
+                       fileButton.setEnabled(false);
+               
+               data = setButtonFormLayoutData(fileButton);
+               data.top = new FormAttachment(variableNameLabel,
+                               convertVerticalDLUsToPixels(10));
+               data.left = new FormAttachment(variableValueField,
+                               convertHorizontalDLUsToPixels(10));
+               data.right = new FormAttachment(100, -5);
+               fileButton.setLayoutData(data);
+               fileButton.setFont(font);
+               
+               fileButton.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               selectFile();
+                       }
+               });
+               
+               // select folder path button
+               folderButton = new Button(contents, SWT.PUSH);
+               folderButton.setText(PreferencesMessages.PathEntryVariableDialog_folder); 
+               if ((variableType & IResource.FOLDER) == 0)
+                       folderButton.setEnabled(false);
+               
+               data = setButtonFormLayoutData(folderButton);
+               data.top = new FormAttachment(variableValueLabel,
+                               convertVerticalDLUsToPixels(10));
+               data.left = new FormAttachment(variableValueField,
+                               convertHorizontalDLUsToPixels(10));
+               data.right = new FormAttachment(100, -5);
+               folderButton.setLayoutData(data);
+               folderButton.setFont(font);
+               
+               folderButton.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               selectFolder();
+                       }
+               });
+       }
+       
+       /**
+        * Sets the <code>FormData</code> on the specified button to be one that is
+        * spaced for the current dialog page units. The method
+        * <code>initializeDialogUnits</code> must be called once before calling this
+        * method for the first time.
+        * 
+        * @param button the button to set the <code>FormData</code>
+        * @return the <code>FormData</code> set on the specified button
+        */
+       private FormData setButtonFormLayoutData(Button button) {
+               FormData data = new FormData();
+               int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
+               data.width = Math.max(widthHint, button.computeSize(SWT.DEFAULT,
+                               SWT.DEFAULT, true).x);
+               button.setLayoutData(data);
+               return data;
+       }
+       
+       /**
+        * Fires validations (variable name first) and updates enabled state for the
+        * "Ok" button accordingly.
+        */
+       protected void variableNameModified() {
+               // updates and validates the variable name
+               variableName = variableNameField.getText().trim();
+               validationStatus = IMessageProvider.NONE;
+               okButton.setEnabled(validateVariableName() && validateVariableValue());
+               nameEntered = true;
+       }
+       
+       /**
+        * Fires validations (variable value first) and updates enabled state for the
+        * "Ok" button accordingly.
+        */
+       protected void variableValueModified() {
+               // updates and validates the variable value
+               variableValue = variableValueField.getText().trim();
+               validationStatus = IMessageProvider.NONE;
+               okButton.setEnabled(validateVariableValue() && validateVariableName());
+               locationEntered = true;
+       }
+       
+       /**
+        * Opens a dialog where the user can select a folder path.
+        */
+       protected void selectFolder() {
+               DirectoryDialog dialog = new DirectoryDialog(getShell());
+               dialog.setText(PreferencesMessages.PathEntryVariableDialog_selectFolderTitle); 
+               dialog.setMessage(PreferencesMessages.PathEntryVariableDialog_selectFolderMessage); 
+               dialog.setFilterPath(variableValue);
+               String res = dialog.open();
+               if (res != null) {
+                       variableValue = new Path(res).makeAbsolute().toOSString();
+                       variableValueField.setText(variableValue);
+               }
+       }
+       
+       /**
+        * Opens a dialog where the user can select a file path.
+        */
+       protected void selectFile() {
+               FileDialog dialog = new FileDialog(getShell());
+               dialog.setText(PreferencesMessages.PathEntryVariableDialog_selectFileTitle); 
+               dialog.setFilterPath(variableValue);
+               String res = dialog.open();
+               if (res != null) {
+                       variableValue = new Path(res).makeAbsolute().toOSString();
+                       variableValueField.setText(variableValue);
+               }
+       }
+       
+       /**
+        * Adds buttons to this dialog's button bar.
+        * 
+        * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar
+        */
+       @Override
+       protected void createButtonsForButtonBar(Composite parent) {
+               okButton = createButton(parent, IDialogConstants.OK_ID,
+                               IDialogConstants.OK_LABEL, true);
+               okButton.setEnabled(type == EXISTING_VARIABLE);
+               
+               createButton(parent, IDialogConstants.CANCEL_ID,
+                               IDialogConstants.CANCEL_LABEL, false);
+       }
+       
+       /**
+        * Validates the current variable name, and updates this dialog's message.
+        * 
+        * @return true if the name is valid, false otherwise
+        */
+       private boolean validateVariableName() {
+               boolean allowFinish = false;
+               
+               // if the current validationStatus is ERROR, no additional validation applies
+               if (validationStatus == IMessageProvider.ERROR)
+                       return false;
+               
+               // assumes everything will be ok
+               String message = standardMessage;
+               int newValidationStatus = IMessageProvider.NONE;
+               
+               if (variableName.length() == 0) {
+                       // the variable name is empty
+                       if (nameEntered) {
+                               // a name was entered before and is now empty
+                               newValidationStatus = IMessageProvider.ERROR;
+                               message = PreferencesMessages.PathEntryVariableDialog_variableNameEmptyMessage; 
+                       }
+               } else {
+                       if (namesInUse.contains(variableName)
+                                       && !variableName.equals(originalName)) {
+                               // the variable name is already in use
+                               message = PreferencesMessages.PathEntryVariableDialog_variableAlreadyExistsMessage; 
+                               newValidationStatus = IMessageProvider.ERROR;
+                       } else {
+                               allowFinish = true;
+                       }
+               }
+               
+               // overwrite the current validation status / message only if everything is ok (clearing them)
+               // or if we have a more serious problem than the current one
+               if (validationStatus == IMessageProvider.NONE
+                               || newValidationStatus == IMessageProvider.ERROR) {
+                       validationStatus = newValidationStatus;
+                       validationMessage = message;
+               }
+               // only set the message here if it is not going to be set in 
+               // validateVariableValue to avoid flashing.
+               if (allowFinish == false)
+                       setMessage(validationMessage, validationStatus);
+               return allowFinish;
+       }
+       
+       /**
+        * Validates the current variable value, and updates this dialog's message.
+        * 
+        * @return true if the value is valid, false otherwise
+        */
+       private boolean validateVariableValue() {
+               boolean allowFinish = false;
+               
+               // if the current validationStatus is ERROR, no additional validation applies
+               if (validationStatus == IMessageProvider.ERROR)
+                       return false;
+               
+               // assumes everything will be ok
+               String message = standardMessage;
+               int newValidationStatus = IMessageProvider.NONE;
+               
+               if (variableValue.length() == 0) {
+                       // the variable value is empty
+                       if (locationEntered) {
+                               // a location value was entered before and is now empty
+                               newValidationStatus = IMessageProvider.ERROR;
+                               message = PreferencesMessages.PathEntryVariableDialog_variableValueEmptyMessage; 
+                       }
+               } else if (!Path.EMPTY.isValidPath(variableValue)) {
+                       // the variable value is an invalid path
+                       message = PreferencesMessages.PathEntryVariableDialog_variableValueInvalidMessage; 
+                       newValidationStatus = IMessageProvider.ERROR;
+               } else if (!new Path(variableValue).isAbsolute()) {
+                       // the variable value is a relative path
+                       message = PreferencesMessages.PathEntryVariableDialog_pathIsRelativeMessage; 
+                       newValidationStatus = IMessageProvider.ERROR;
+               } else if (!new File(variableValue).exists()) {
+                       // the path does not exist (warning)
+                       message = PreferencesMessages.PathEntryVariableDialog_pathDoesNotExistMessage; 
+                       newValidationStatus = IMessageProvider.WARNING;
+                       allowFinish = true;
+               } else {
+                       allowFinish = true;
+               }
+               
+               // overwrite the current validation status / message only if everything is ok (clearing them)
+               // or if we have a more serious problem than the current one
+               if (validationStatus == IMessageProvider.NONE
+                               || newValidationStatus > validationStatus) {
+                       validationStatus = newValidationStatus;
+                       validationMessage = message;
+               }
+               setMessage(validationMessage, validationStatus);
+               return allowFinish;
+       }
+       
+       /**
+        * Returns the variable name.
+        * 
+        * @return the variable name
+        */
+       public String getVariableName() {
+               return variableName;
+       }
+       
+       /**
+        * Returns the variable value.
+        * 
+        * @return the variable value
+        */
+       public String getVariableValue() {
+               return variableValue;
+       }
+       
+       /**
+        * Sets the variable name.
+        * 
+        * @param variableName the new variable name
+        */
+       public void setVariableName(String variableName) {
+               this.variableName = variableName.trim();
+               this.originalName = this.variableName;
+       }
+       
+       /**
+        * Sets the variable value.
+        * 
+        * @param variableValue the new variable value
+        */
+       public void setVariableValue(String variableValue) {
+               this.variableValue = variableValue;
+       }
+       
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariablePreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariablePreferencePage.java
new file mode 100644 (file)
index 0000000..2298e73
--- /dev/null
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+
+/**
+ * @deprecated in CDT 8.0. This class appears to be never used.
+ */
+@Deprecated
+public class PathEntryVariablePreferencePage extends PreferencePage 
+implements IWorkbenchPreferencePage {
+       
+       private Label topLabel;
+       
+       private PathEntryVariablesGroup pathEntryVariablesGroup;
+       
+       /**
+        * Constructs a preference page of path variables.
+        * Omits "Restore Defaults"/"Apply Changes" buttons.
+        */
+       public PathEntryVariablePreferencePage() {
+               pathEntryVariablesGroup = new PathEntryVariablesGroup(true, IResource.FILE | IResource.FOLDER);
+               this.noDefaultAndApplyButton();
+       }
+       
+       /**
+        * Resets this page's internal state and creates its UI contents.
+        * 
+        * @see PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected Control createContents(Composite parent) {
+               Font font = parent.getFont();
+               
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ICHelpContextIds.PATHENTRY_VARIABLES_PREFERENCE_PAGE);
+       
+               // define container & its gridding
+               Composite pageComponent = new Composite(parent, SWT.NULL);
+               GridLayout layout = new GridLayout();
+               layout.marginWidth = 0;
+               layout.marginHeight = 0;
+               pageComponent.setLayout(layout);
+               GridData data = new GridData();
+               data.verticalAlignment = GridData.FILL;
+               data.horizontalAlignment = GridData.FILL;
+               pageComponent.setLayoutData(data);
+               pageComponent.setFont(font);
+               
+               
+               topLabel = new Label(pageComponent, SWT.NONE);
+               topLabel.setText(PreferencesMessages.PathEntryVariablePreference_explanation); 
+               data = new GridData();
+               data.verticalAlignment = GridData.FILL;
+               data.horizontalAlignment = GridData.FILL;
+               topLabel.setLayoutData(data);
+               topLabel.setFont(font);
+               
+               pathEntryVariablesGroup.createContents(pageComponent);
+               
+               return pageComponent;
+       }
+       
+       /**
+        * Creates a tab of one horizontal spans.
+        *
+        * @param parent  the parent in which the tab should be created
+        */
+       protected static void createSpace(Composite parent) {
+               Label vfiller = new Label(parent, SWT.LEFT);
+               GridData gridData = new GridData();
+               gridData = new GridData();
+               gridData.horizontalAlignment = GridData.BEGINNING;
+               gridData.grabExcessHorizontalSpace = false;
+               gridData.verticalAlignment = GridData.CENTER;
+               gridData.grabExcessVerticalSpace = false;
+               vfiller.setLayoutData(gridData);
+       }
+       
+       /**
+        * Disposes the path variables group.
+        * @see org.eclipse.jface.dialogs.IDialogPage#dispose()
+        */
+       @Override
+       public void dispose() {
+               pathEntryVariablesGroup.dispose();
+               super.dispose();
+       }
+       
+       /**
+        * Empty implementation. This page does not use the workbench.
+        * 
+        * @see IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+        */
+       public void init(IWorkbench workbench) {
+       }
+       
+       /**
+        * Commits the temporary state to the path variable manager in response to user
+        * confirmation.
+        * 
+        * @see PreferencePage#performOk()
+        */
+       @Override
+       public boolean performOk() {
+               return pathEntryVariablesGroup.performOk();
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariablesGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariablesGroup.java
new file mode 100644 (file)
index 0000000..9d25dcd
--- /dev/null
@@ -0,0 +1,564 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.Map.Entry;
+
+import org.eclipse.core.resources.IPathVariableManager;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontMetrics;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.resources.IPathEntryVariableManager;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+
+/**
+ * @deprecated in CDT 8.0. This class appears to be never used.
+ */
+@Deprecated
+public class PathEntryVariablesGroup {
+       
+       /**
+        * Simple data structure that holds a path variable name/value pair.
+        */
+       public static class PathEntryVariableElement {
+               public String name;
+               
+               public IPath path;
+       }
+       
+       // sizing constants
+       private static final int SIZING_SELECTION_PANE_WIDTH = 400;
+       
+       // parent shell
+       private Shell shell;
+       
+       private Label variableLabel;
+       
+       private Table variableTable;
+       
+       private Button addButton;
+       
+       private Button editButton;
+       
+       private Button removeButton;
+       
+       // used to compute layout sizes
+       private FontMetrics fontMetrics;
+       
+       // create a multi select table
+       private boolean multiSelect;
+       
+       // IResource.FILE and/or IResource.FOLDER
+       private int variableType;
+       
+       // External listener called when the table selection changes
+       protected Listener selectionListener;
+       
+       // temporary collection for keeping currently defined variables
+       private SortedMap<String, IPath> tempPathVariables;
+       
+       // set of removed variables' names
+       private Set<String> removedVariableNames;
+       
+       // reference to the workspace's path variable manager
+       private IPathEntryVariableManager pathEntryVariableManager;
+       
+       // file image
+       private final Image FILE_IMG = PlatformUI.getWorkbench().getSharedImages()
+       .getImage(ISharedImages.IMG_OBJ_FILE);
+       
+       // folder image
+       private final Image FOLDER_IMG = PlatformUI.getWorkbench()
+       .getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
+       
+       // unknown (non-existent) image. created locally, dispose locally
+       private Image imageUnkown;
+       
+       /**
+        * Creates a new PathVariablesGroup.
+        *
+        * @param multiSelect create a multi select tree
+        * @param variableType the type of variables that are displayed in 
+        *      the widget group. <code>IResource.FILE</code> and/or <code>IResource.FOLDER</code>
+        *      logically ORed together.
+        */
+       public PathEntryVariablesGroup(boolean multiSelect, int variableType) {
+               this.multiSelect = multiSelect;
+               this.variableType = variableType;
+               pathEntryVariableManager = CCorePlugin.getDefault().getPathEntryVariableManager();
+               removedVariableNames = new HashSet<String>();
+               tempPathVariables = new TreeMap<String, IPath>();
+               // initialize internal model
+               initTemporaryState();
+       }
+       
+       /**
+        * Creates a new PathVariablesGroup.
+        *
+        * @param multiSelect create a multi select tree
+        * @param variableType the type of variables that are displayed in 
+        *      the widget group. <code>IResource.FILE</code> and/or <code>IResource.FOLDER</code>
+        *      logically ORed together.
+        * @param selectionListener listener notified when the selection changes
+        *      in the variables list.
+        */
+       public PathEntryVariablesGroup(boolean multiSelect, int variableType,
+                       Listener selectionListener) {
+               this(multiSelect, variableType);
+               this.selectionListener = selectionListener;
+       }
+       
+       /**
+        * Opens a dialog for creating a new variable.
+        */
+       protected void addNewVariable() {
+               // constructs a dialog for editing the new variable's current name and value
+               PathEntryVariableDialog dialog = new PathEntryVariableDialog(shell,
+                               PathEntryVariableDialog.NEW_VARIABLE, variableType, tempPathVariables.keySet());
+               
+               // opens the dialog - just returns if the user cancels it
+               if (dialog.open() == Window.CANCEL)
+                       return;
+               
+               // otherwise, adds the new variable (or updates an existing one) in the
+               // temporary collection of currently defined variables
+               String newVariableName = dialog.getVariableName();
+               IPath newVariableValue = new Path(dialog.getVariableValue());
+               tempPathVariables.put(newVariableName, newVariableValue);
+               
+               // the UI must be updated
+               updateWidgetState(newVariableName);
+       }
+       
+       /**
+        * Creates the widget group.
+        * Callers must call <code>dispose</code> when the group is no 
+        * longer needed.
+        * 
+        * @param parent the widget parent
+        * @return container of the widgets 
+        */
+       public Control createContents(Composite parent) {
+               Font font = parent.getFont();
+               
+               if (imageUnkown == null) {
+                       ImageDescriptor descriptor = CPluginImages.DESC_OVR_WARNING;
+                       imageUnkown = descriptor.createImage();
+               }
+               initializeDialogUnits(parent);
+               shell = parent.getShell();
+               
+               // define container & its layout
+               Composite pageComponent = new Composite(parent, SWT.NULL);
+               GridLayout layout = new GridLayout();
+               layout.numColumns = 2;
+               layout.marginWidth = 0;
+               layout.marginHeight = 0;
+               pageComponent.setLayout(layout);
+               GridData data = new GridData(GridData.FILL_BOTH);
+               data.widthHint = SIZING_SELECTION_PANE_WIDTH;
+               pageComponent.setLayoutData(data);
+               pageComponent.setFont(font);
+               
+               // layout the table & its buttons
+               variableLabel = new Label(pageComponent, SWT.LEFT);
+               variableLabel.setText(PreferencesMessages.PathEntryVariablesBlock_variablesLabel); 
+               data = new GridData();
+               data.horizontalAlignment = GridData.FILL;
+               data.horizontalSpan = 2;
+               variableLabel.setLayoutData(data);
+               variableLabel.setFont(font);
+               
+               int tableStyle = SWT.BORDER | SWT.FULL_SELECTION;
+               if (multiSelect) {
+                       tableStyle |= SWT.MULTI;
+               }
+               variableTable = new Table(pageComponent, tableStyle);
+               variableTable.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               updateEnabledState();
+                               if (selectionListener != null)
+                                       selectionListener.handleEvent(new Event());
+                       }
+               });
+               data = new GridData(GridData.FILL_BOTH);
+               data.heightHint = variableTable.getItemHeight() * 7;
+               variableTable.setLayoutData(data);
+               variableTable.setFont(font);
+               
+               createButtonGroup(pageComponent);
+               // populate table with current internal state and set buttons' initial state
+               updateWidgetState(null);
+               
+               return pageComponent;
+       }
+       
+       /**
+        * Disposes the group's resources. 
+        */
+       public void dispose() {
+               if (imageUnkown != null) {
+                       imageUnkown.dispose();
+                       imageUnkown = null;
+               }
+       }
+       
+       /**
+        * Opens a dialog for editing an existing variable.
+        *
+        * @see PathEntryVariableDialog
+        */
+       protected void editSelectedVariable() {
+               // retrieves the name and value for the currently selected variable
+               TableItem item = variableTable.getItem(variableTable
+                               .getSelectionIndex());
+               String variableName = (String) item.getData();
+               IPath variableValue = tempPathVariables.get(variableName);
+               
+               // constructs a dialog for editing the variable's current name and value
+               PathEntryVariableDialog dialog = new PathEntryVariableDialog(shell,
+                               PathEntryVariableDialog.EXISTING_VARIABLE, variableType, tempPathVariables.keySet());
+               dialog.setVariableName(variableName);
+               dialog.setVariableValue(variableValue.toOSString());
+               
+               // opens the dialog - just returns if the user cancels it
+               if (dialog.open() == Window.CANCEL)
+                       return;
+               
+               // the name can be changed, so we remove the current variable definition...
+               removedVariableNames.add(variableName);
+               tempPathVariables.remove(variableName);
+               
+               String newVariableName = dialog.getVariableName();
+               IPath newVariableValue = new Path(dialog.getVariableValue());
+               
+               // and add it again (maybe with a different name)
+               tempPathVariables.put(newVariableName, newVariableValue);
+               
+               // now we must refresh the UI state
+               updateWidgetState(newVariableName);
+               
+       }
+       
+       /**
+        * Returns the enabled state of the group's widgets.
+        * Returns <code>true</code> if called prior to calling 
+        * <code>createContents</code>.
+        * 
+        * @return boolean the enabled state of the group's widgets.
+        *       <code>true</code> if called prior to calling <code>createContents</code>.
+        */
+       public boolean getEnabled() {
+               if (variableTable != null && !variableTable.isDisposed()) {
+                       return variableTable.getEnabled();
+               }
+               return true;
+       }
+       
+       /**
+        * Returns the selected variables.
+        *  
+        * @return the selected variables. Returns an empty array if 
+        *      the widget group has not been created yet by calling 
+        *      <code>createContents</code>
+        */
+       public PathEntryVariableElement[] getSelection() {
+               if (variableTable == null) {
+                       return new PathEntryVariableElement[0];
+               }
+               TableItem[] items = variableTable.getSelection();
+               PathEntryVariableElement[] selection = new PathEntryVariableElement[items.length];
+               
+               for (int i = 0; i < items.length; i++) {
+                       String name = (String) items[i].getData();
+                       selection[i] = new PathEntryVariableElement();
+                       selection[i].name = name;
+                       selection[i].path = tempPathVariables.get(name);
+               }
+               return selection;
+       }
+       
+       /**
+        * Creates the add/edit/remove buttons
+        * 
+        * @param parent the widget parent
+        */
+       private void createButtonGroup(Composite parent) {
+               Font font = parent.getFont();
+               Composite groupComponent = new Composite(parent, SWT.NULL);
+               GridLayout groupLayout = new GridLayout();
+               groupLayout.marginWidth = 0;
+               groupLayout.marginHeight = 0;
+               groupComponent.setLayout(groupLayout);
+               GridData data = new GridData();
+               data.verticalAlignment = GridData.FILL;
+               data.horizontalAlignment = GridData.FILL;
+               groupComponent.setLayoutData(data);
+               groupComponent.setFont(font);
+               
+               addButton = new Button(groupComponent, SWT.PUSH);
+               addButton.setText(PreferencesMessages.PathEntryVariablesBlock_addVariableButton); 
+               addButton.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               addNewVariable();
+                       }
+               });
+               addButton.setFont(font);
+               setButtonLayoutData(addButton);
+               
+               editButton = new Button(groupComponent, SWT.PUSH);
+               editButton.setText(PreferencesMessages.PathEntryVariablesBlock_editVariableButton); 
+               editButton.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               editSelectedVariable();
+                       }
+               });
+               editButton.setFont(font);
+               setButtonLayoutData(editButton);
+               
+               removeButton = new Button(groupComponent, SWT.PUSH);
+               removeButton.setText(PreferencesMessages.PathEntryVariablesBlock_removeVariableButton); 
+               removeButton.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               removeSelectedVariables();
+                       }
+               });
+               removeButton.setFont(font);
+               setButtonLayoutData(removeButton);
+       }
+       
+       /**
+        * Initializes the computation of horizontal and vertical dialog units
+        * based on the size of current font.
+        * <p>
+        * This method must be called before <code>setButtonLayoutData</code> 
+        * is called.
+        * </p>
+        *
+        * @param control a control from which to obtain the current font
+        */
+       protected void initializeDialogUnits(Control control) {
+               // Compute and store a font metric
+               GC gc = new GC(control);
+               gc.setFont(control.getFont());
+               fontMetrics = gc.getFontMetrics();
+               gc.dispose();
+       }
+       
+       /**
+        * (Re-)Initialize collections used to mantain temporary variable state.
+        */
+       private void initTemporaryState() {
+               String[] varNames = pathEntryVariableManager.getVariableNames();
+               
+               tempPathVariables.clear();
+               for (String varName : varNames) {
+                       IPath value = pathEntryVariableManager.getValue(varName);
+                       
+                       // the value may not exist any more
+                       if (value != null) {
+                               boolean isFile = value.toFile().isFile();
+                               if ((isFile && (variableType & IResource.FILE) != 0)
+                                               || (isFile == false && (variableType & IResource.FOLDER) != 0)) {
+                                       
+                                       tempPathVariables.put(varName, value);
+                               }
+                       }
+               }
+               removedVariableNames.clear();
+       }
+       
+       /**
+        * Updates button enabled state, depending on the number of currently selected
+        * variables in the table.
+        */
+       protected void updateEnabledState() {
+               int itemsSelectedCount = variableTable.getSelectionCount();
+               editButton.setEnabled(itemsSelectedCount == 1);
+               removeButton.setEnabled(itemsSelectedCount > 0);
+       }
+       
+       /**
+        * Rebuilds table widget state with the current list of variables (reflecting
+        * any changes, additions and removals), and selects the item corresponding to
+        * the given variable name. If the variable name is <code>null</code>, the
+        * first item (if any) will be selected.
+        * 
+        * @param selectedVarName the name for the variable to be selected (may be
+        * <code>null</code>)
+        * @see IPathVariableManager#getPathVariableNames()
+        * @see IPathVariableManager#getValue(String)
+        */
+       private void updateVariableTable(String selectedVarName) {
+               variableTable.removeAll();
+               int selectedVarIndex = 0;
+               for (String varName : tempPathVariables.keySet()) {
+                       TableItem item = new TableItem(variableTable, SWT.NONE);
+                       IPath value = tempPathVariables.get(varName);
+                       File file = value.toFile();
+                       
+                       item.setText(varName + " - " + value.toOSString()); //$NON-NLS-1$ 
+                       // the corresponding variable name is stored in each table widget item
+                       item.setData(varName);
+                       item.setImage(file.exists() ? (file.isFile() ? FILE_IMG
+                                       : FOLDER_IMG) : imageUnkown);
+                       if (varName.equals(selectedVarName))
+                               selectedVarIndex = variableTable.getItemCount() - 1;
+               }
+               if (variableTable.getItemCount() > selectedVarIndex) {
+                       variableTable.setSelection(selectedVarIndex);
+                       if (selectionListener != null)
+                               selectionListener.handleEvent(new Event());
+               } else if (variableTable.getItemCount() == 0
+                               && selectionListener != null)
+                       selectionListener.handleEvent(new Event());
+       }
+       
+       /**
+        * Commits the temporary state to the path variable manager in response to user
+        * confirmation.
+        *
+        * @see IPathEntryVariableManager#setValue(String, IPath)
+        */
+       public boolean performOk() {
+               try {
+                       // first process removed variables  
+                       for (String removedVariableName : removedVariableNames) {
+                               // only removes variables that have not been added again
+                               if (!tempPathVariables.containsKey(removedVariableName))
+                                       pathEntryVariableManager.setValue(removedVariableName, null);
+                       }
+                       
+                       // then process the current collection of variables, adding/updating them
+                       for (Entry<String, IPath> entry : tempPathVariables.entrySet()) {
+                               String variableName = entry.getKey();
+                               IPath variableValue = entry.getValue();
+                               pathEntryVariableManager.setValue(variableName, variableValue);
+                       }
+                       // re-initialize temporary state
+                       initTemporaryState();
+                       
+                       // performOk accepted
+                       return true;
+               } catch (CoreException ce) {
+                       ErrorDialog.openError(shell, null, null, ce.getStatus());
+               }
+               return false;
+       }
+       
+       /**
+        * Removes the currently selected variables.
+        */
+       protected void removeSelectedVariables() {
+               // remove each selected element
+               int[] selectedIndices = variableTable.getSelectionIndices();
+               for (int selectedIndice : selectedIndices) {
+                       TableItem selectedItem = variableTable.getItem(selectedIndice);
+                       String varName = (String) selectedItem.getData();
+                       removedVariableNames.add(varName);
+                       tempPathVariables.remove(varName);
+               }
+               updateWidgetState(null);
+       }
+       
+       /**
+        * Sets the <code>GridData</code> on the specified button to
+        * be one that is spaced for the current dialog page units. The
+        * method <code>initializeDialogUnits</code> must be called once
+        * before calling this method for the first time.
+        *
+        * @param button the button to set the <code>GridData</code>
+        * @return the <code>GridData</code> set on the specified button
+        */
+       private GridData setButtonLayoutData(Button button) {
+               GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics,
+                               IDialogConstants.BUTTON_WIDTH);
+               data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT,
+                               SWT.DEFAULT, true).x);
+               button.setLayoutData(data);
+               return data;
+       }
+       
+       /**
+        * Sets the enabled state of the group's widgets.
+        * Does nothing if called prior to calling <code>createContents</code>.
+        * 
+        * @param enabled the new enabled state of the group's widgets
+        */
+       public void setEnabled(boolean enabled) {
+               if (variableTable != null && !variableTable.isDisposed()) {
+                       variableLabel.setEnabled(enabled);
+                       variableTable.setEnabled(enabled);
+                       addButton.setEnabled(enabled);
+                       if (enabled)
+                               updateEnabledState();
+                       else {
+                               editButton.setEnabled(enabled);
+                               removeButton.setEnabled(enabled);
+                       }
+               }
+       }
+       
+       /**
+        * Updates the widget's current state: refreshes the table with the current 
+        * defined variables, selects the item corresponding to the given variable 
+        * (selects the first item if <code>null</code> is provided) and updates 
+        * the enabled state for the Add/Remove/Edit buttons.
+        * 
+        * @param selectedVarName the name of the variable to be selected (may be null)
+        */
+       private void updateWidgetState(String selectedVarName) {
+               updateVariableTable(selectedVarName);
+               updateEnabledState();
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesAccess.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesAccess.java
new file mode 100644 (file)
index 0000000..bede9ca
--- /dev/null
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin, Google
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
+
+import org.eclipse.ui.preferences.IWorkingCopyManager;
+
+import org.osgi.service.prefs.BackingStoreException;
+
+/**
+ * 
+ */
+public class PreferencesAccess {
+       
+       public static PreferencesAccess getOriginalPreferences() {
+               return new PreferencesAccess();
+       }
+       
+       public static PreferencesAccess getWorkingCopyPreferences(IWorkingCopyManager workingCopyManager) {
+               return new WorkingCopyPreferencesAccess(workingCopyManager);
+       }
+               
+       private PreferencesAccess() {
+               // can only extends in this file
+       }
+       
+       public IScopeContext getDefaultScope() {
+               return DefaultScope.INSTANCE;
+       }
+       
+       public IScopeContext getInstanceScope() {
+               return InstanceScope.INSTANCE;
+       }
+       
+       public IScopeContext getProjectScope(IProject project) {
+               return new ProjectScope(project);
+       }
+       
+       public void applyChanges() throws BackingStoreException {
+       }
+       
+       
+       private static class WorkingCopyPreferencesAccess extends PreferencesAccess {
+               
+               private final IWorkingCopyManager fWorkingCopyManager;
+
+               private WorkingCopyPreferencesAccess(IWorkingCopyManager workingCopyManager) {
+                       fWorkingCopyManager= workingCopyManager;
+               }
+               
+               private final IScopeContext getWorkingCopyScopeContext(IScopeContext original) {
+                       return new WorkingCopyScopeContext(fWorkingCopyManager, original);
+               }
+               
+               @Override
+               public IScopeContext getDefaultScope() {
+                       return getWorkingCopyScopeContext(super.getDefaultScope());
+               }
+               
+               @Override
+               public IScopeContext getInstanceScope() {
+                       return getWorkingCopyScopeContext(super.getInstanceScope());
+               }
+               
+               @Override
+               public IScopeContext getProjectScope(IProject project) {
+                       return getWorkingCopyScopeContext(super.getProjectScope(project));
+               }
+               
+               /* (non-Javadoc)
+                * @see org.eclipse.cdt.internal.ui.preferences.PreferencesAccess#applyChanges()
+                */
+               @Override
+               public void applyChanges() throws BackingStoreException {
+                       fWorkingCopyManager.applyChanges();
+               }
+       }
+       
+       private static class WorkingCopyScopeContext implements IScopeContext {
+               
+               private final IWorkingCopyManager fWorkingCopyManager;
+               private final IScopeContext fOriginal;
+
+               public WorkingCopyScopeContext(IWorkingCopyManager workingCopyManager, IScopeContext original) {
+                       fWorkingCopyManager= workingCopyManager;
+                       fOriginal= original;    
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.core.runtime.preferences.IScopeContext#getName()
+                */
+               public String getName() {
+                       return fOriginal.getName();
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.core.runtime.preferences.IScopeContext#getNode(java.lang.String)
+                */
+               public IEclipsePreferences getNode(String qualifier) {
+                       return fWorkingCopyManager.getWorkingCopy(fOriginal.getNode(qualifier));
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.core.runtime.preferences.IScopeContext#getLocation()
+                */
+               public IPath getLocation() {
+                       return fOriginal.getLocation();
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java
new file mode 100644 (file)
index 0000000..01357de
--- /dev/null
@@ -0,0 +1,460 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Markus Schorn (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *     Andrew Ferguson (Symbian)
+ *     Kirk Beitz (Nokia)
+ *     James Blackburn (Broadcom Corp.)
+ *     Jens Elmenthaler - http://bugs.eclipse.org/173458 (camel case completion)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class PreferencesMessages extends NLS {
+       public static String CodeAssistAdvancedConfigurationBlock_default_table_category_column_title;
+       public static String CodeAssistAdvancedConfigurationBlock_default_table_description;
+       public static String CodeAssistAdvancedConfigurationBlock_default_table_keybinding_column_title;
+       public static String CodeAssistAdvancedConfigurationBlock_key_binding_hint;
+       public static String CodeAssistAdvancedConfigurationBlock_page_description;
+       public static String CodeAssistAdvancedConfigurationBlock_separate_table_category_column_title;
+       public static String CodeAssistAdvancedConfigurationBlock_separate_table_description;
+       public static String CodeAssistAdvancedConfigurationBlock_no_shortcut;
+       public static String CodeAssistAdvancedConfigurationBlock_Up;
+       public static String CodeAssistAdvancedConfigurationBlock_Down;
+       public static String CEditorPreferencePage_link;
+       public static String CEditorPreferencePage_link_tooltip;
+       public static String CEditorPreferencePage_colors;
+       public static String CEditorPreferencePage_invalid_input;
+       public static String CEditorPreferencePage_empty_input;
+//     public static String CEditorPreferencePage_ContentAssistPage_searchGroupTitle;
+//     public static String CEditorPreferencePage_ContentAssistPage_searchGroupCurrentFileOption;
+//     public static String CEditorPreferencePage_ContentAssistPage_searchGroupCurrentProjectOption;
+       public static String CEditorPreferencePage_ContentAssistPage_insertionGroupTitle;
+       public static String CEditorPreferencePage_ContentAssistPage_insertSingleProposalAutomatically;
+       public static String CEditorPreferencePage_ContentAssistPage_insertCommonProposalAutomatically;
+       public static String CEditorPreferencePage_ContentAssistPage_showProposalsInAlphabeticalOrder;
+       public static String CEditorPreferencePage_ContentAssistPage_showCamelCaseMatches;
+       public static String CEditorPreferencePage_ContentAssistPage_autoActivationGroupTitle;
+       public static String CEditorPreferencePage_ContentAssistPage_autoActivationEnableDot;
+       public static String CEditorPreferencePage_ContentAssistPage_autoActivationEnableArrow;
+       public static String CEditorPreferencePage_ContentAssistPage_autoActivationEnableDoubleColon;
+       public static String CEditorPreferencePage_ContentAssistPage_autoActivationEnableReplaceDotWithArrow;
+       public static String CEditorPreferencePage_ContentAssistPage_autoActivationDelay;
+       public static String CEditorPreferencePage_ContentAssistPage_proposalFilterSelect;
+       public static String CEditorPreferencePage_ContentAssistPage_completionProposalBackgroundColor;
+       public static String CEditorPreferencePage_ContentAssistPage_completionProposalForegroundColor;
+       public static String CEditorPreferencePage_ContentAssistPage_parameterBackgroundColor;
+       public static String CEditorPreferencePage_ContentAssistPage_parameterForegroundColor;
+       public static String CEditorPreferencePage_ContentAssistPage_sortingSection_title;
+       public static String CEditorPreferencePage_sourceHoverBackgroundColor;
+       public static String CEditorColoringConfigurationBlock_MultiLine;
+       public static String CEditorColoringConfigurationBlock_singleLine;
+       public static String CEditorColoringConfigurationBlock_keywords;
+       public static String CEditorColoringConfigurationBlock_builtInTypes;
+       public static String CEditorColoringConfigurationBlock_strings;
+       public static String CEditorColoringConfigurationBlock_operators;
+       public static String CEditorColoringConfigurationBlock_braces;
+       public static String CEditorColoringConfigurationBlock_numbers;
+       public static String CEditorColoringConfigurationBlock_asmLabels;
+       public static String CEditorColoringConfigurationBlock_asmDirectives;
+       public static String CEditorColoringConfigurationBlock_others;
+       public static String CEditorColoringConfigurationBlock_ppDirectives;
+       public static String CEditorColoringConfigurationBlock_ppOthers;
+       public static String CEditorColoringConfigurationBlock_ppHeaders;
+       public static String CEditorColoringConfigurationBlock_cCommentTaskTags;
+       public static String CEditorColoringConfigurationBlock_DoxygenTagRecognized;
+       public static String CEditorColoringConfigurationBlock_DoxygenSingleLineComment;
+       public static String CEditorColoringConfigurationBlock_DoxygenMultiLineComment;
+       public static String CEditorColoringConfigurationBlock_coloring_category_code;
+       public static String CEditorColoringConfigurationBlock_coloring_category_comments;
+       public static String CEditorColoringConfigurationBlock_coloring_category_preprocessor;
+       public static String CEditorColoringConfigurationBlock_coloring_category_assembly;
+       public static String CEditorColoringConfigurationBlock_coloring_category_doxygen;
+       public static String CEditorColoringConfigurationBlock_coloring_element;
+       public static String CEditorColoringConfigurationBlock_link;
+       public static String CEditorColoringConfigurationBlock_enable_semantic_highlighting;
+       public static String CEditorColoringConfigurationBlock_enable;
+       public static String CEditorColoringConfigurationBlock_preview;
+       public static String CEditorColoringConfigurationBlock_color;
+       public static String CEditorColoringConfigurationBlock_bold;
+       public static String CEditorColoringConfigurationBlock_italic;
+       public static String CEditorColoringConfigurationBlock_underline;
+       public static String CEditorColoringConfigurationBlock_strikethrough;
+       public static String CEditorPreferencePage_colorPage_systemDefault;
+       public static String CEditorPreferencePage_behaviorPage_matchingBrackets;
+       public static String CEditorPreferencePage_behaviorPage_subWordNavigation;
+       public static String CEditorPreferencePage_behaviorPage_inactiveCode;
+       public static String CEditorPreferencePage_behaviorPage_appearanceColorOptions;
+       public static String CEditorPreferencePage_behaviorPage_matchingBracketColor;
+       public static String CEditorPreferencePage_behaviorPage_inactiveCodeColor;
+       public static String CEditorPreferencePage_behaviorPage_Color;
+       public static String TemplatePreferencePage_Viewer_preview;
+       public static String CFileTypesPreferencePage_description;
+       public static String CFileTypesPreferenceBlock_New___;
+       public static String CFileTypesPreferenceBlock_Remove;
+       public static String CFileTypesPreferencePage_colTitlePattern;
+       public static String CFileTypesPreferencePage_colTitleDescription;
+       public static String CFileTypesPreferenceBlock_addAssociationError_title;
+       public static String CFileTypesPreferenceBlock_addAssociationErrorMessage;
+       public static String CFileTypesPreferencePage_colTitleStatus;
+       public static String CFileTypesPreferencePage_userDefined;
+       public static String CFileTypesPreferencePage_preDefined;
+       public static String CFileTypesPropertyPage_useWorkspaceSettings;
+       public static String CFileTypesPropertyPage_useProjectSettings;
+       public static String CFileTypeDialog_title;
+       public static String CFileTypeDialog_patternLabel;
+       public static String CFileTypeDialog_typeLabel;
+       public static String CEditorPreferencePage_hover_title;
+       public static String CEditorHoverConfigurationBlock_hoverPreferences;
+       public static String CEditorHoverConfigurationBlock_keyModifier;
+       public static String CEditorHoverConfigurationBlock_description;
+       public static String CEditorHoverConfigurationBlock_modifierIsNotValid;
+       public static String CEditorHoverConfigurationBlock_modifierIsNotValidForHover;
+       public static String CEditorHoverConfigurationBlock_duplicateModifier;
+       public static String CEditorHoverConfigurationBlock_nameColumnTitle;
+       public static String CEditorHoverConfigurationBlock_modifierColumnTitle;
+       public static String CEditorHoverConfigurationBlock_delimiter;
+       public static String CEditorHoverConfigurationBlock_insertDelimiterAndModifierAndDelimiter;
+       public static String CEditorHoverConfigurationBlock_insertModifierAndDelimiter;
+       public static String CEditorHoverConfigurationBlock_insertDelimiterAndModifier;
+       public static String CBufferPreferences_CodeReaderBuffer_CodeReaderBufferGroup;
+       public static String CBufferPreferences_CodeReaderBuffer_Size;
+       public static String CEditorPreferencePage_behaviourPage_EnableEditorProblemAnnotation;
+       public static String AppearancePreferencePage_description;
+       public static String AppearancePreferencePage_showTUChildren_label;
+       public static String AppearancePreferencePage_cviewGroupIncludes_label;
+       public static String AppearancePreferencePage_cviewSeparateHeaderAndSource_label;
+       public static String AppearancePreferencePage_cviewKeepSortOrderOfExcludedFiles_label;
+       public static String AppearancePreferencePage_cviewGroupMacros_label;
+       public static String AppearancePreferencePage_outlineGroupIncludes_label;
+       public static String AppearancePreferencePage_outlineGroupMethods_label;
+       public static String AppearancePreferencePage_outlineGroupNamespaces_label;
+       public static String AppearancePreferencePage_outlineGroupMacros_label;
+       public static String AppearancePreferencePage_note;
+       public static String AppearancePreferencePage_preferenceOnlyForNewViews;
+       public static String AppearancePreferencePage_showSourceRootsAtTopOfProject_label;
+       public static String BuildLogPreferencePage_Browse;
+       public static String BuildLogPreferencePage_ChooseLogFile;
+       public static String BuildLogPreferencePage_EnableLogging;
+       public static String BuildLogPreferencePage_LogLocation;
+       public static String GlobalBuildLogPreferencePage_EnableLogging;
+       public static String GlobalBuildLogPreferencePage_LogLocation;
+       public static String CEditorPreferencePage_folding_title;
+       public static String FoldingConfigurationBlock_enable;
+       public static String FoldingConfigurationBlock_combo_caption;
+       public static String FoldingConfigurationBlock_info_no_preferences;
+       public static String FoldingConfigurationBlock_error_not_exist;
+       public static String PathEntryVariablePreference_explanation;
+       public static String PathEntryVariableDialog_shellTitle_newVariable;
+       public static String PathEntryVariableDialog_shellTitle_existingVariable;
+       public static String PathEntryVariableDialog_dialogTitle_newVariable;
+       public static String PathEntryVariableDialog_dialogTitle_existingVariable;
+       public static String PathEntryVariableDialog_message_newVariable;
+       public static String PathEntryVariableDialog_message_existingVariable;
+       public static String PathEntryVariableDialog_variableName;
+       public static String PathEntryVariableDialog_variableValue;
+       public static String PathEntryVariableDialog_variableNameEmptyMessage;
+       public static String PathEntryVariableDialog_variableValueEmptyMessage;
+       public static String PathEntryVariableDialog_variableValueInvalidMessage;
+       public static String PathEntryVariableDialog_file;
+       public static String PathEntryVariableDialog_folder;
+       public static String PathEntryVariableDialog_selectFileTitle;
+       public static String PathEntryVariableDialog_selectFolderTitle;
+       public static String PathEntryVariableDialog_selectFolderMessage;
+       public static String PathEntryVariableDialog_variableAlreadyExistsMessage;
+       public static String PathEntryVariableDialog_pathIsRelativeMessage;
+       public static String PathEntryVariableDialog_pathDoesNotExistMessage;
+       public static String PathEntryVariablesBlock_variablesLabel;
+       public static String PathEntryVariablesBlock_addVariableButton;
+       public static String PathEntryVariablesBlock_editVariableButton;
+       public static String PathEntryVariablesBlock_removeVariableButton;
+       public static String ProposalFilterPreferencesUtil_defaultFilterName;
+
+       public static String CEditorPreferencePage_typing_tabTitle;
+       public static String CEditorPreferencePage_closeStrings;
+       public static String CEditorPreferencePage_closeBrackets;
+       public static String CEditorPreferencePage_closeAngularBrackets;
+       public static String CEditorPreferencePage_closeBraces;
+       public static String CEditorPreferencePage_wrapStrings;
+       public static String CEditorPreferencePage_escapeStrings;
+       public static String CEditorPreferencePage_GeneralAppearanceGroupTitle;
+       public static String CEditorPreferencePage_SaveActionsTitle;
+       public static String CEditorPreferencePage_SelectDocToolDescription;
+       public static String CEditorPreferencePage_smartPaste;
+
+       public static String CEditorPreferencePage_typing_smartTab;
+       public static String CEditorPreferencePage_WorkspaceDefaultLabel;
+
+       public static String SaveActionsPreferencePage_removeTrailingWhitespace;
+       public static String SaveActionsPreferencePage_inEditedLines;
+       public static String SaveActionsPreferencePage_inAllLines;
+       public static String SaveActionsPreferencePage_ensureNewline;
+
+       public static String SmartTypingConfigurationBlock_autoclose_title;
+       public static String SmartTypingConfigurationBlock_autoindent_newlines;
+       public static String SmartTypingConfigurationBlock_autoindent_title;
+       public static String SmartTypingConfigurationBlock_tabs_title;
+       public static String SmartTypingConfigurationBlock_tabs_message_tab_text;
+       public static String SmartTypingConfigurationBlock_tabs_message_others_text;
+       public static String SmartTypingConfigurationBlock_tabs_message_tooltip;
+       public static String SmartTypingConfigurationBlock_tabs_message_spaces;
+       public static String SmartTypingConfigurationBlock_tabs_message_tabs;
+       public static String SmartTypingConfigurationBlock_tabs_message_tabsAndSpaces;
+       public static String SmartTypingConfigurationBlock_pasting_title;
+       public static String SmartTypingConfigurationBlock_strings_title;
+
+       public static String CodeFormatterPreferencePage_title;
+       public static String CodeFormatterPreferencePage_description;
+
+       public static String TodoTaskPreferencePage_title;
+       public static String TodoTaskPreferencePage_description;
+       public static String TodoTaskConfigurationBlock_markers_tasks_high_priority;
+       public static String TodoTaskConfigurationBlock_markers_tasks_normal_priority;
+       public static String TodoTaskConfigurationBlock_markers_tasks_low_priority;
+       public static String TodoTaskConfigurationBlock_markers_tasks_add_button;
+       public static String TodoTaskConfigurationBlock_markers_tasks_remove_button;
+       public static String TodoTaskConfigurationBlock_markers_tasks_edit_button;
+       public static String TodoTaskConfigurationBlock_markers_tasks_name_column;
+       public static String TodoTaskConfigurationBlock_markers_tasks_priority_column;
+       public static String TodoTaskConfigurationBlock_markers_tasks_setdefault_button;
+       public static String TodoTaskConfigurationBlock_casesensitive_label;
+       public static String TodoTaskConfigurationBlock_tasks_default;
+
+       public static String TodoTaskInputDialog_new_title;
+       public static String TodoTaskInputDialog_edit_title;
+       public static String TodoTaskInputDialog_name_label;
+       public static String TodoTaskInputDialog_priority_label;
+       public static String TodoTaskInputDialog_priority_high;
+       public static String TodoTaskInputDialog_priority_normal;
+       public static String TodoTaskInputDialog_priority_low;
+       public static String TodoTaskInputDialog_error_enterName;
+       public static String TodoTaskInputDialog_error_comma;
+       public static String TodoTaskInputDialog_error_entryExists;
+       public static String TodoTaskInputDialog_error_noSpace;
+
+       public static String SpellingPreferencePage_empty_threshold;
+       public static String SpellingPreferencePage_invalid_threshold;
+       public static String SpellingPreferencePage_ignore_digits_label;
+       public static String SpellingPreferencePage_ignore_mixed_label;
+       public static String SpellingPreferencePage_ignore_sentence_label;
+       public static String SpellingPreferencePage_ignore_upper_label;
+       public static String SpellingPreferencePage_ignore_url_label;
+       public static String SpellingPreferencePage_ignore_non_letters_label;
+       public static String SpellingPreferencePage_ignore_single_letters_label;
+       public static String SpellingPreferencePage_ignore_string_literals_label;
+       public static String SpellingPreferencePage_proposals_threshold;
+       public static String SpellingPreferencePage_problems_threshold;
+       public static String SpellingPreferencePage_dictionary_label;
+       public static String SpellingPreferencePage_encoding_label;
+       public static String SpellingPreferencePage_workspace_dictionary_label;
+       public static String SpellingPreferencePage_browse_label;
+       public static String SpellingPreferencePage_dictionary_error;
+       public static String SpellingPreferencePage_dictionary_none;
+       public static String SpellingPreferencePage_locale_error;
+       public static String SpellingPreferencePage_filedialog_title;
+       public static String SpellingPreferencePage_enable_contentassist_label;
+       public static String SpellingPreferencePage_group_user;
+       public static String SpellingPreferencePage_group_dictionary;
+       public static String SpellingPreferencePage_group_dictionaries;
+       public static String SpellingPreferencePage_group_advanced;
+       public static String SpellingPreferencePage_user_dictionary_description;
+       public static String SpellingPreferencePage_variables;
+
+       public static String LanguageMappings_missingLanguageTitle;
+
+       public static String WorkspaceLanguagesPreferencePage_description;
+       public static String WorkspaceLanguagesPreferencePage_missingLanguage;
+       public static String WorkspaceLanguagesPreferencePage_mappingTableTitle;
+
+       public static String ProjectLanguagesPropertyPage_description;
+       public static String ProjectLanguagesPropertyPage_configurationColumn;
+       public static String ProjectLanguagesPropertyPage_contentTypeColumn;
+       public static String ProjectLanguagesPropertyPage_languageColumn;
+       public static String ProjectLanguagesPropertyPage_addMappingButton;
+       public static String ProjectLanguagesPropertyPage_removeMappingButton;
+       public static String ProjectLanguagesPropertyPage_inheritedWorkspaceMappingsGroup;
+       public static String ProjectLanguagesPropertyPage_overriddenContentType;
+       public static String ProjectLanguagesPropertyPage_missingLanguage;
+       public static String ProjectLanguagesPropertyPage_mappingTableTitle;
+
+       public static String ContentTypeMappingsDialog_title;
+       public static String ContentTypeMappingsDialog_configuration;
+       public static String ContentTypeMappingsDialog_contentType;
+       public static String ContentTypeMappingsDialog_language;
+       public static String ContentTypeMappingsDialog_allConfigurations;
+
+       public static String FileLanguagesPropertyPage_contentTypeLabel;
+       public static String FileLanguagesPropertyPage_inheritedFromSystem;
+       public static String FileLanguagesPropertyPage_inheritedFromProject;
+       public static String FileLanguagesPropertyPage_inheritedFromWorkspace;
+       public static String FileLanguagesPropertyPage_inheritedFromFile;
+       public static String FileLanguagesPropertyPage_description;
+       public static String FileLanguagesPropertyPage_configurationColumn;
+       public static String FileLanguagesPropertyPage_defaultMapping;
+       public static String FileLanguagesPropertyPage_missingLanguage;
+       public static String FileLanguagesPropertyPage_mappingTableTitle;
+
+       public static String CBuildPreferencePage_description;
+
+       public static String CPluginPreferencePage_outline_view;
+       public static String CPluginPreferencePage_build_scope;
+       public static String CPluginPreferencePage_1;
+       public static String CPluginPreferencePage_2;
+       public static String CPluginPreferencePage_3;
+       public static String CPluginPreferencePage_4;
+       public static String CPluginPreferencePage_building_configurations;
+       public static String CPluginPreferencePage_7;
+       public static String CPluginPreferencePage_description;
+       public static String CPluginPreferencePage_cdtDialogs_group;
+       public static String CPluginPreferencePage_clear_button;
+       public static String CPluginPreferencePage_clearDoNotShowAgainSettings_label;
+       public static String CPluginPreferencePage_structuralParseMode_label;
+       public static String CPluginPreferencePage_note;
+       public static String CPluginPreferencePage_performanceHint;
+       public static String CPluginPreferencePage_refactoring_title;
+       public static String CPluginPreferencePage_refactoring_auto_save;
+       public static String CPluginPreferencePage_refactoring_lightweight;
+
+       public static String PropertyAndPreferencePage_useworkspacesettings_change;
+       public static String PropertyAndPreferencePage_showprojectspecificsettings_label;
+       public static String PropertyAndPreferencePage_useprojectsettings_label;
+
+       public static String ProjectSelectionDialog_title;
+       public static String ProjectSelectionDialog_desciption;
+       public static String ProjectSelectionDialog_filter;
+
+       public static String CodeTemplatesPreferencePage_title;
+       public static String CodeTemplateBlock_templates_comment_node;
+       public static String CodeTemplateBlock_templates_code_node;
+       public static String CodeTemplateBlock_templates_file_node;
+
+       public static String CodeTemplateBlock_namespace_begin_label;
+       public static String CodeTemplateBlock_namespace_end_label;
+       public static String CodeTemplateBlock_class_body_label;
+       public static String CodeTemplateBlock_constructorstub_label;
+       public static String CodeTemplateBlock_destructorstub_label;
+       public static String CodeTemplateBlock_methodstub_label;
+       public static String CodeTemplateBlock_typecomment_label;
+       public static String CodeTemplateBlock_fieldcomment_label;
+       public static String CodeTemplateBlock_filecomment_label;
+       public static String CodeTemplateBlock_methodcomment_label;
+       public static String CodeTemplateBlock_constructorcomment_label;
+       public static String CodeTemplateBlock_destructorcomment_label;
+       public static String CodeTemplateBlock_templates_new_button;
+       public static String CodeTemplateBlock_templates_edit_button;
+       public static String CodeTemplateBlock_templates_remove_button;
+       public static String CodeTemplateBlock_templates_import_button;
+       public static String CodeTemplateBlock_templates_export_button;
+       public static String CodeTemplateBlock_templates_exportall_button;
+       public static String CodeTemplateBlock_createcomment_label;
+       public static String CodeTemplateBlock_templates_label;
+       public static String CodeTemplateBlock_preview;
+       public static String CodeTemplateBlock_import_title;
+       public static String CodeTemplateBlock_import_extension;
+       public static String CodeTemplateBlock_export_title;
+       public static String CodeTemplateBlock_export_filename;
+       public static String CodeTemplateBlock_export_extension;
+       public static String CodeTemplateBlock_export_exists_title;
+       public static String CodeTemplateBlock_export_exists_message;
+       public static String CodeTemplateBlock_error_read_title;
+       public static String CodeTemplateBlock_error_read_message;
+       public static String CodeTemplateBlock_error_parse_message;
+       public static String CodeTemplateBlock_error_write_title;
+       public static String CodeTemplateBlock_error_write_message;
+       public static String CodeTemplateBlock_export_error_title;
+       public static String CodeTemplateBlock_export_error_hidden;
+       public static String CodeTemplateBlock_export_error_canNotWrite;
+
+       public static String NameStylePreferencePage_title;
+       public static String NameStyleBlock_code_node;
+       public static String NameStyleBlock_files_node;
+       public static String NameStyleBlock_constant_node;
+       public static String NameStyleBlock_constant_node_description;
+       public static String NameStyleBlock_variable_node;
+       public static String NameStyleBlock_variable_node_description;
+       public static String NameStyleBlock_field_node;
+       public static String NameStyleBlock_field_node_description;
+       public static String NameStyleBlock_getter_node;
+       public static String NameStyleBlock_getter_node_description;
+       public static String NameStyleBlock_setter_node;
+       public static String NameStyleBlock_setter_node_description;
+       public static String NameStyleBlock_cpp_source_node;
+       public static String NameStyleBlock_cpp_source_node_description;
+       public static String NameStyleBlock_cpp_header_node;
+       public static String NameStyleBlock_cpp_header_node_description;
+       public static String NameStyleBlock_cpp_test_node;
+       public static String NameStyleBlock_cpp_test_node_description;
+       public static String NameStyleBlock_categories_label;
+       public static String NameStyleBlock_capitalization_label;
+       public static String NameStyleBlock_capitalization_original;
+       public static String NameStyleBlock_capitalization_upper_case;
+       public static String NameStyleBlock_capitalization_lower_case;
+       public static String NameStyleBlock_capitalization_camel_case;
+       public static String NameStyleBlock_capitalization_lower_camel_case;
+       public static String NameStyleBlock_word_delimiter_label;
+       public static String NameStyleBlock_prefix_label;
+       public static String NameStyleBlock_prefix_for_boolean_label;
+       public static String NameStyleBlock_suffix_label;
+       public static String NameStyleBlock_preview_label;
+       public static String NameStyleBlock_select_concrete_category;
+       public static String NameStyleBlock_invalid_prefix;
+       public static String NameStyleBlock_invalid_word_delimiter;
+       public static String NameStyleBlock_invalid_suffix;
+
+       public static String EditTemplateDialog_error_noname;
+       public static String EditTemplateDialog_error_invalidName;
+       public static String EditTemplateDialog_title_new;
+       public static String EditTemplateDialog_title_edit;
+       public static String EditTemplateDialog_name;
+       public static String EditTemplateDialog_description;
+       public static String EditTemplateDialog_contextType;
+       public static String EditTemplateDialog_pattern;
+       public static String EditTemplateDialog_insert_variable;
+       public static String EditTemplateDialog_undo;
+       public static String EditTemplateDialog_redo;
+       public static String EditTemplateDialog_cut;
+       public static String EditTemplateDialog_copy;
+       public static String EditTemplateDialog_paste;
+       public static String EditTemplateDialog_select_all;
+       public static String EditTemplateDialog_content_assist;
+//     public static String EditTemplateDialog_autoinsert;
+
+       public static String MarkOccurrencesConfigurationBlock_title;
+       public static String MarkOccurrencesConfigurationBlock_link;
+       public static String MarkOccurrencesConfigurationBlock_link_tooltip;
+       public static String MarkOccurrencesConfigurationBlock_markOccurrences;
+       public static String MarkOccurrencesConfigurationBlock_markOverloadOccurrences;
+       public static String MarkOccurrencesConfigurationBlock_stickyOccurrences;
+       
+       public static String ScalabilityPreferencePage_description;
+       public static String ScalabilityPreferencePage_detection_label;
+       public static String ScalabilityPreferencePage_detection_group_label;
+       public static String ScalabilityPreferencePage_trigger_lines_label;
+       public static String ScalabilityPreferencePage_error;
+       public static String ScalabilityPreferencePage_scalabilityMode_group_label;
+       public static String ScalabilityPreferencePage_scalabilityMode_label;
+       public static String ScalabilityPreferencePage_reconciler_label;
+       public static String ScalabilityPreferencePage_syntaxColor_label;
+       public static String ScalabilityPreferencePage_semanticHighlighting_label;
+       public static String ScalabilityPreferencePage_contentAssist_label;
+       public static String ScalabilityPreferencePage_note;
+       public static String ScalabilityPreferencePage_preferenceOnlyForNewEditors;
+       public static String ScalabilityPreferencePage_contentAssist_autoActivation;
+       
+       private PreferencesMessages() {
+               // Do not instantiate
+       }
+
+       static {
+               NLS.initializeMessages(PreferencesMessages.class.getName(), PreferencesMessages.class);
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties
new file mode 100644 (file)
index 0000000..8731803
--- /dev/null
@@ -0,0 +1,521 @@
+###############################################################################
+# Copyright (c) 2000, 2011 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+#     Anton Leherbauer (Wind River Systems)
+#     Markus Schorn (Wind River Systems)
+#     Sergey Prigogin (Google)
+#     Andrew Ferguson (Symbian)
+#     Kirk Beitz (Nokia)
+#     James Blackburn (Broadcom Corp.)
+#     Jens Elmenthaler - http://bugs.eclipse.org/173458 (camel case completion)
+###############################################################################
+
+CEditorPreferencePage_link=C/C++ Editor Preferences. General preferences may be set via <a href="org.eclipse.ui.preferencePages.GeneralTextEditor">Text Editors</a>.
+CEditorPreferencePage_link_tooltip=Show the shared text editor preferences
+
+CEditorPreferencePage_colors=Synta&x
+
+#CEditorPreferencePage_ContentAssistPage_searchGroupTitle=Search scope for completion proposals:
+#CEditorPreferencePage_ContentAssistPage_searchGroupCurrentFileOption=S&earch current file and included files
+#CEditorPreferencePage_ContentAssistPage_searchGroupCurrentProjectOption=Search current &project
+CEditorPreferencePage_ContentAssistPage_insertionGroupTitle=Insertion
+CEditorPreferencePage_ContentAssistPage_insertSingleProposalAutomatically=&Insert single proposals automatically
+CEditorPreferencePage_ContentAssistPage_insertCommonProposalAutomatically=I&nsert common prefixes automatically
+CEditorPreferencePage_ContentAssistPage_showProposalsInAlphabeticalOrder=Present proposals in a&lphabetical order
+CEditorPreferencePage_ContentAssistPage_showCamelCaseMatches=Show ca&mel case matches
+CEditorPreferencePage_ContentAssistPage_autoActivationGroupTitle=Auto-Activation
+CEditorPreferencePage_ContentAssistPage_autoActivationEnableDot=Enable "." as &trigger
+CEditorPreferencePage_ContentAssistPage_autoActivationEnableArrow=Enable "->" as tri&gger
+CEditorPreferencePage_ContentAssistPage_autoActivationEnableDoubleColon=Enable "::" as trigg&er
+CEditorPreferencePage_ContentAssistPage_autoActivationEnableReplaceDotWithArrow=Enable aut&o-replace of '.' with '->' for pointer types
+CEditorPreferencePage_ContentAssistPage_autoActivationDelay=Dela&y (ms)
+CEditorPreferencePage_ContentAssistPage_proposalFilterSelect=Completion Proposal Filter:
+CEditorPreferencePage_ContentAssistPage_completionProposalBackgroundColor=Completion proposal background
+CEditorPreferencePage_ContentAssistPage_completionProposalForegroundColor=Completion proposal foreground
+CEditorPreferencePage_ContentAssistPage_parameterBackgroundColor=Parameter hint background
+CEditorPreferencePage_ContentAssistPage_parameterForegroundColor=Parameter hint foreground
+CEditorPreferencePage_ContentAssistPage_sortingSection_title=Sorting and Filtering
+CEditorPreferencePage_sourceHoverBackgroundColor=Source hover background
+
+# {0} will be replaced by the keyboard shortcut for the command (e.g. "Ctrl+Space", or "no shortcut") 
+CodeAssistAdvancedConfigurationBlock_page_description=Configure the behavior of the content assist ({0}) command.
+# stand-in text if there is no keyboard shortcut in above statement
+CodeAssistAdvancedConfigurationBlock_no_shortcut=no shortcut
+CodeAssistAdvancedConfigurationBlock_default_table_description=Select the proposal kinds contained in the 'default' content assist list:
+CodeAssistAdvancedConfigurationBlock_default_table_category_column_title=Default Proposal Kinds
+CodeAssistAdvancedConfigurationBlock_default_table_keybinding_column_title=Key Binding
+# do not translate the href argument (org.eclipse.ui.preferencePages.Keys)
+CodeAssistAdvancedConfigurationBlock_key_binding_hint=Individual key bindings can be assigned to each proposal kind on the <a href="org.eclipse.ui.preferencePages.Keys">Keys</a> preference page.
+CodeAssistAdvancedConfigurationBlock_separate_table_description=Content assist cycling: Select the proposal kinds that are cycled through when repeatedly invoking content assist:
+CodeAssistAdvancedConfigurationBlock_separate_table_category_column_title=Separate Proposal Kinds
+CodeAssistAdvancedConfigurationBlock_Up=&Up
+CodeAssistAdvancedConfigurationBlock_Down=D&own
+
+CEditorColoringConfigurationBlock_MultiLine=Multi-line comment
+CEditorColoringConfigurationBlock_singleLine=Single-line comment
+CEditorColoringConfigurationBlock_keywords=Keywords
+CEditorColoringConfigurationBlock_builtInTypes=Built-in types
+CEditorColoringConfigurationBlock_strings=Strings
+CEditorColoringConfigurationBlock_operators=Operators
+CEditorColoringConfigurationBlock_braces=Braces
+CEditorColoringConfigurationBlock_numbers=Numbers
+CEditorColoringConfigurationBlock_others=Others
+CEditorColoringConfigurationBlock_asmLabels=Labels
+CEditorColoringConfigurationBlock_asmDirectives=Directives
+CEditorColoringConfigurationBlock_ppDirectives=Directives
+CEditorColoringConfigurationBlock_ppHeaders=Headers
+CEditorColoringConfigurationBlock_ppOthers=Others
+CEditorColoringConfigurationBlock_cCommentTaskTags=Task Tags
+CEditorColoringConfigurationBlock_DoxygenTagRecognized=Doxygen Tag
+CEditorColoringConfigurationBlock_DoxygenSingleLineComment=Doxygen Single-line Comment
+CEditorColoringConfigurationBlock_DoxygenMultiLineComment=Doxygen Multi-line Comment
+CEditorColoringConfigurationBlock_coloring_category_code=Code
+CEditorColoringConfigurationBlock_coloring_category_comments=Comments
+CEditorColoringConfigurationBlock_coloring_category_preprocessor=Preprocessor
+CEditorColoringConfigurationBlock_coloring_category_assembly=Assembly
+CEditorColoringConfigurationBlock_coloring_category_doxygen=Doxygen
+CEditorColoringConfigurationBlock_coloring_element=Element:
+# DO NOT TRANSLATE "org.eclipse.ui.preferencePages.GeneralTextEditor" and "org.eclipse.ui.preferencePages.ColorsAndFonts" 
+CEditorColoringConfigurationBlock_link=Default colors and font can be configured on the <a href=\"org.eclipse.ui.preferencePages.GeneralTextEditor\">Text Editors</a> and on the <a href=\"org.eclipse.ui.preferencePages.ColorsAndFonts\">Colors and Fonts</a> preference page.
+CEditorColoringConfigurationBlock_enable_semantic_highlighting=Enable semantic highlighting
+CEditorColoringConfigurationBlock_enable=Enab&le
+CEditorColoringConfigurationBlock_preview=Previe&w:
+CEditorColoringConfigurationBlock_color=C&olor:
+CEditorColoringConfigurationBlock_bold=&Bold
+CEditorColoringConfigurationBlock_italic=&Italic
+CEditorColoringConfigurationBlock_underline=&Underline
+CEditorColoringConfigurationBlock_strikethrough=&Strikethrough
+
+CEditorPreferencePage_colorPage_systemDefault=S&ystem Default
+CEditorPreferencePage_behaviorPage_matchingBrackets=Highlight &matching brackets
+CEditorPreferencePage_behaviorPage_subWordNavigation=Smart &caret positioning in identifiers
+CEditorPreferencePage_behaviorPage_inactiveCode=Highlight &inactive code
+CEditorPreferencePage_behaviorPage_appearanceColorOptions=Appearance color options:
+CEditorPreferencePage_behaviorPage_matchingBracketColor=Matching brackets highlight
+CEditorPreferencePage_behaviorPage_inactiveCodeColor=Inactive code highlight
+CEditorPreferencePage_behaviorPage_Color=Color:
+
+SaveActionsPreferencePage_removeTrailingWhitespace=Remove trailing &whitespace
+SaveActionsPreferencePage_inEditedLines=In &edited lines
+SaveActionsPreferencePage_inAllLines=In a&ll lines
+SaveActionsPreferencePage_ensureNewline=Ensure &newline at the end of file
+
+TemplatePreferencePage_Viewer_preview=Preview:
+
+CFileTypesPreferencePage_description=C/C++ File Types
+CFileTypesPreferenceBlock_New___=New...
+CFileTypesPreferenceBlock_Remove=Remove
+CFileTypesPreferencePage_colTitlePattern=Filename
+CFileTypesPreferencePage_colTitleDescription=Description
+CFileTypesPreferenceBlock_addAssociationError_title=Create file association
+CFileTypesPreferenceBlock_addAssociationErrorMessage=The association between ''{0}'' and ''{1}'' already exists
+CFileTypesPreferencePage_colTitleStatus=Status
+CFileTypesPreferencePage_userDefined=User Defined
+CFileTypesPreferencePage_preDefined=Locked
+
+CFileTypesPropertyPage_useWorkspaceSettings=Use workspace settings
+CFileTypesPropertyPage_useProjectSettings=Use project settings
+
+CFileTypeDialog_title=C/C++ File Type
+CFileTypeDialog_patternLabel=Pattern:
+CFileTypeDialog_typeLabel=Type:
+
+# Hover page
+CEditorPreferencePage_hover_title= Ho&vers
+CEditorHoverConfigurationBlock_hoverPreferences= Text &Hover key modifier preferences:
+CEditorHoverConfigurationBlock_keyModifier= Pressed key &modifier while hovering:
+CEditorHoverConfigurationBlock_description= Description:
+CEditorHoverConfigurationBlock_modifierIsNotValid= Modifier ''{0}'' is not valid.
+CEditorHoverConfigurationBlock_modifierIsNotValidForHover= Modifier ''{0}'' for ''{1}'' hover is not valid.
+CEditorHoverConfigurationBlock_duplicateModifier= ''{0}'' hover uses the same modifier as ''{1}'' hover.
+CEditorHoverConfigurationBlock_nameColumnTitle= Text Hover Name
+CEditorHoverConfigurationBlock_modifierColumnTitle= Pressed Key Modifier While Hovering
+
+CEditorHoverConfigurationBlock_delimiter= +
+CEditorHoverConfigurationBlock_insertDelimiterAndModifierAndDelimiter= \ + {0} +
+CEditorHoverConfigurationBlock_insertModifierAndDelimiter= \ {0} +
+CEditorHoverConfigurationBlock_insertDelimiterAndModifier= \ + {0}
+
+
+#Search Preferences
+
+#Buffer Preferences
+CBufferPreferences_CodeReaderBuffer_CodeReaderBufferGroup=CodeReader Buffer Size
+CBufferPreferences_CodeReaderBuffer_Size=Size (MB)
+
+#Open Type Preferences
+
+#Editor Preferences
+CEditorPreferencePage_behaviourPage_EnableEditorProblemAnnotation=Report &problems as you type
+
+#Appearance Preferences
+AppearancePreferencePage_description= Appearance of C/C++ elements in viewers:
+#AppearancePreferencePage.methodreturntype.label= Show &method return types
+AppearancePreferencePage_showTUChildren_label= Show translation unit members
+AppearancePreferencePage_cviewGroupIncludes_label= Group include directives in Project Explorer and C/C++ Projects view
+AppearancePreferencePage_cviewKeepSortOrderOfExcludedFiles_label=Keep sort order of excluded sources in Project Explorer and C/C++ Projects view
+AppearancePreferencePage_cviewSeparateHeaderAndSource_label= Sort header files before source files in Project Explorer and C/C++ Projects view
+AppearancePreferencePage_cviewGroupMacros_label= Group macro definitions in Project Explorer and C/C++ Projects view
+AppearancePreferencePage_outlineGroupIncludes_label= Group include directives in the Outline view
+AppearancePreferencePage_outlineGroupMethods_label=Group method definitions in the Outline view
+AppearancePreferencePage_outlineGroupNamespaces_label= Group namespaces in the Outline view
+AppearancePreferencePage_note=Note:
+AppearancePreferencePage_preferenceOnlyForNewViews=These two preferences do not affect open views
+AppearancePreferencePage_outlineGroupMacros_label=Group macro definitions in the Outline view
+AppearancePreferencePage_showSourceRootsAtTopOfProject_label=Show source roots at top of project
+
+#Build Logging
+BuildLogPreferencePage_Browse=&Browse...
+BuildLogPreferencePage_ChooseLogFile=Choose Log File
+BuildLogPreferencePage_EnableLogging=Enable build &logging
+BuildLogPreferencePage_LogLocation=Log &file location:
+
+#Global build logging
+GlobalBuildLogPreferencePage_EnableLogging=Enable global build &logging
+GlobalBuildLogPreferencePage_LogLocation=Log &file location:
+
+#Folding
+CEditorPreferencePage_folding_title= &Folding
+
+FoldingConfigurationBlock_enable= Enable folding when &opening a new editor
+FoldingConfigurationBlock_combo_caption= Select folding to &use:
+FoldingConfigurationBlock_info_no_preferences= The selected folding provider did not provide a preference control
+FoldingConfigurationBlock_error_not_exist= The selected folding provider does not exist
+
+# Smart typing block
+SmartTypingConfigurationBlock_autoclose_title=Automatically close
+SmartTypingConfigurationBlock_autoindent_newlines=New lines and braces
+SmartTypingConfigurationBlock_autoindent_title=Automatically indent
+SmartTypingConfigurationBlock_tabs_title=Tabulators
+# The argument will be replaced by the tab display size
+SmartTypingConfigurationBlock_tabs_message_tab_text=The tab display value (currently {0}) and whether spaces are used to indent lines are configured on the <a>code style preference page</a>. The current indentation mode uses tabs.
+# The first argument will be replaced by the tab display size, the second by the indent size and the third by the NLSed string of 'SmartTypingConfigurationBlock_tabs_message_spaces' or 'SmartTypingConfigurationBlock_tabs_message_tabs' (see below)  
+SmartTypingConfigurationBlock_tabs_message_others_text=The tab display value (currently {0}) and whether spaces are used to indent lines are configured on the <a>code style preference page</a>. The current indentation size is {1}, using {2}.
+SmartTypingConfigurationBlock_tabs_message_tooltip=Go to the code style preference page
+SmartTypingConfigurationBlock_tabs_message_spaces=spaces
+SmartTypingConfigurationBlock_tabs_message_tabs=tabs
+SmartTypingConfigurationBlock_tabs_message_tabsAndSpaces=tabs and spaces
+SmartTypingConfigurationBlock_pasting_title=When pasting
+SmartTypingConfigurationBlock_strings_title=In string literals
+
+CEditorPreferencePage_empty_input=Empty input
+CEditorPreferencePage_invalid_input="{0}" is not a valid input.
+CEditorPreferencePage_typing_tabTitle=T&yping
+CEditorPreferencePage_closeStrings="&Strings"
+CEditorPreferencePage_closeBrackets=(&Parentheses) and [square] brackets
+CEditorPreferencePage_closeAngularBrackets=<A&ngle> brackets
+CEditorPreferencePage_closeBraces={B&races}
+CEditorPreferencePage_wrapStrings=&Wrap automatically
+CEditorPreferencePage_escapeStrings=Escape text w&hen pasting into a string literal
+CEditorPreferencePage_GeneralAppearanceGroupTitle=General behavior
+CEditorPreferencePage_SaveActionsTitle=Save actions
+CEditorPreferencePage_SelectDocToolDescription=Select the documentation tool to be used to determine editor behaviors when no project preference overrides exist
+CEditorPreferencePage_smartPaste=Adjust &indentation
+
+CEditorPreferencePage_typing_smartTab= &Tab key adjusts indentation of the current line
+CEditorPreferencePage_WorkspaceDefaultLabel=Workspace default:
+
+# Code Formatting
+CodeFormatterPreferencePage_title=Code Style
+CodeFormatterPreferencePage_description=Sele&ct a profile:
+
+# Task tags.
+TodoTaskPreferencePage_title=Task Tags
+TodoTaskPreferencePage_description=&Strings indicating tasks in C/C++ comments. The entry marked as default will be used in the code templates.
+
+TodoTaskConfigurationBlock_markers_tasks_high_priority=High
+TodoTaskConfigurationBlock_markers_tasks_normal_priority=Normal
+TodoTaskConfigurationBlock_markers_tasks_low_priority=Low
+TodoTaskConfigurationBlock_markers_tasks_add_button=&New...
+TodoTaskConfigurationBlock_markers_tasks_remove_button=&Remove
+TodoTaskConfigurationBlock_markers_tasks_edit_button=&Edit...
+TodoTaskConfigurationBlock_markers_tasks_name_column=Tag
+TodoTaskConfigurationBlock_markers_tasks_priority_column=Priority
+TodoTaskConfigurationBlock_markers_tasks_setdefault_button=Defa&ult
+TodoTaskConfigurationBlock_casesensitive_label=&Case sensitive task tag names
+
+TodoTaskConfigurationBlock_tasks_default={0} (default)
+
+TodoTaskInputDialog_new_title=New Task Tag
+TodoTaskInputDialog_edit_title=Edit Task Tag
+TodoTaskInputDialog_name_label=T&ag:
+TodoTaskInputDialog_priority_label=&Priority:
+TodoTaskInputDialog_priority_high=High
+TodoTaskInputDialog_priority_normal=Normal
+TodoTaskInputDialog_priority_low=Low
+TodoTaskInputDialog_error_enterName=Enter task tag name.
+TodoTaskInputDialog_error_comma=Name cannot contain a comma.
+TodoTaskInputDialog_error_entryExists=An entry with the same name already exists.
+TodoTaskInputDialog_error_noSpace=Name cannot begin or end with a whitespace.
+
+# --- Linked Resources ---
+PathEntryVariablePreference_explanation = PathEntry variables.
+
+# The following six keys are marked as unused by the NLS search, but they are indirectly used
+# and should be removed.
+PathEntryVariableDialog_shellTitle_newVariable = New PathEntry Variable
+PathEntryVariableDialog_shellTitle_existingVariable = Edit PathEntry Variable
+PathEntryVariableDialog_dialogTitle_newVariable = Define a New PathEntry Variable
+PathEntryVariableDialog_dialogTitle_existingVariable = Edit an Existing PathEntry Variable
+PathEntryVariableDialog_message_newVariable = Enter a new PathEntry variable name and its associated location.
+PathEntryVariableDialog_message_existingVariable = Edit PathEntry variable's name and path value.
+
+PathEntryVariableDialog_variableName = &Name:
+PathEntryVariableDialog_variableValue = &Location:
+PathEntryVariableDialog_variableNameEmptyMessage = You must provide a variable name.
+PathEntryVariableDialog_variableValueEmptyMessage = You must provide a file or folder path as variable value.
+PathEntryVariableDialog_variableValueInvalidMessage = The provided value is not a valid path.
+PathEntryVariableDialog_file = &File...
+PathEntryVariableDialog_folder = F&older...
+PathEntryVariableDialog_selectFileTitle = File selection
+PathEntryVariableDialog_selectFolderTitle = Folder selection
+PathEntryVariableDialog_selectFolderMessage = Specify the folder to be represented by the variable.
+PathEntryVariableDialog_variableAlreadyExistsMessage = This variable name is already in use.
+PathEntryVariableDialog_pathIsRelativeMessage = Path must be absolute.
+PathEntryVariableDialog_pathDoesNotExistMessage = Path does not exist.
+
+PathEntryVariablesBlock_variablesLabel = &Defined PathEntry variables:
+PathEntryVariablesBlock_addVariableButton = &New...
+PathEntryVariablesBlock_editVariableButton = Edi&t...
+PathEntryVariablesBlock_removeVariableButton = &Remove
+
+# Spelling
+SpellingPreferencePage_empty_threshold= A positive integer must be specified.
+SpellingPreferencePage_invalid_threshold=''{0}'' is not a valid positive integer.
+SpellingPreferencePage_ignore_digits_label=Ignore &words with digits
+SpellingPreferencePage_ignore_mixed_label=Ignore &mixed case words
+SpellingPreferencePage_ignore_sentence_label=Ignore &sentence capitalization
+SpellingPreferencePage_ignore_upper_label=Ignore u&pper case words
+SpellingPreferencePage_ignore_url_label=Ignore &internet addresses
+SpellingPreferencePage_ignore_single_letters_label=I&gnore single letters
+SpellingPreferencePage_ignore_string_literals_label=Ignore string &literals
+SpellingPreferencePage_ignore_non_letters_label=Ignore &non-letters at word boundaries
+SpellingPreferencePage_proposals_threshold= Ma&ximum number of correction proposals:
+SpellingPreferencePage_problems_threshold= Maximum number of problems repor&ted per file:
+SpellingPreferencePage_dictionary_label=Plat&form dictionary:
+SpellingPreferencePage_workspace_dictionary_label=Use&r defined dictionary:
+SpellingPreferencePage_browse_label=&Browse...
+SpellingPreferencePage_dictionary_error=The dictionary file must be read/write accessible.
+SpellingPreferencePage_dictionary_none=none
+SpellingPreferencePage_encoding_label=En&coding:
+SpellingPreferencePage_locale_error=There is no dictionary available for this language.
+SpellingPreferencePage_filedialog_title=Select User Dictionary
+SpellingPreferencePage_enable_contentassist_label=Ma&ke dictionary available to content assist
+SpellingPreferencePage_group_user=Options
+SpellingPreferencePage_group_dictionary=Dictionary
+SpellingPreferencePage_group_dictionaries=Dictionaries
+SpellingPreferencePage_group_advanced=Advanced
+SpellingPreferencePage_variables=&Variables...
+SpellingPreferencePage_user_dictionary_description=The user dictionary is a text file with one word on each line
+
+# Language settings
+LanguageMappings_missingLanguageTitle = Missing Languages
+
+WorkspaceLanguagesPreferencePage_description = These settings are global to the entire workspace.  They are overridden by project-specific language mappings.
+WorkspaceLanguagesPreferencePage_missingLanguage = The workspace contains mappings to one or more languages that are not currently installed.  References to these languages will be removed:\n{0}
+WorkspaceLanguagesPreferencePage_mappingTableTitle = Language mappings for the workspace
+
+ProjectLanguagesPropertyPage_description = These settings are project-specific.  The mappings listed here override <a href="workspace">workspace-wide</a> language mappings.
+ProjectLanguagesPropertyPage_configurationColumn = Configuration
+ProjectLanguagesPropertyPage_contentTypeColumn = Content Type
+ProjectLanguagesPropertyPage_languageColumn = Language
+ProjectLanguagesPropertyPage_addMappingButton = &Add...
+ProjectLanguagesPropertyPage_removeMappingButton = &Remove
+ProjectLanguagesPropertyPage_inheritedWorkspaceMappingsGroup = Language settings inherited from the workspace
+ProjectLanguagesPropertyPage_overriddenContentType = (Overridden) {0}
+ProjectLanguagesPropertyPage_missingLanguage = This project contains mappings to one or more languages that are not currently installed.  References to these languages will be removed:\n{0}
+ProjectLanguagesPropertyPage_mappingTableTitle = Language mappings for this project
+
+ContentTypeMappingsDialog_title = Add Mapping
+ContentTypeMappingsDialog_configuration = Configuration
+ContentTypeMappingsDialog_contentType = Content type
+ContentTypeMappingsDialog_language = Language
+ContentTypeMappingsDialog_allConfigurations = (All)
+
+FileLanguagesPropertyPage_description = This language assignment overrides all <a href="project">project-wide</a> and <a href="workspace">workspace-wide</a> language mappings.
+FileLanguagesPropertyPage_contentTypeLabel = Content Type:
+FileLanguagesPropertyPage_inheritedFromSystem = Inherited from the system ({0})
+FileLanguagesPropertyPage_inheritedFromProject = Inherited from the project ({0})
+FileLanguagesPropertyPage_inheritedFromWorkspace = Inherited from the workspace ({0})
+FileLanguagesPropertyPage_inheritedFromFile = Inherited from (Default) ({0})
+FileLanguagesPropertyPage_configurationColumn = Configuration
+FileLanguagesPropertyPage_defaultMapping = (Default)
+FileLanguagesPropertyPage_missingLanguage = This project contains files that are mapped to one or more languages that are not currently installed.  References to these languages will be removed:\n{0}
+FileLanguagesPropertyPage_mappingTableTitle = Language mappings for this file
+
+# Others
+ProposalFilterPreferencesUtil_defaultFilterName=<Default Filter>
+
+# C/C++ Preferences
+CBuildPreferencePage_description=General build settings for C/C++ development:
+
+CPluginPreferencePage_outline_view=Outline view
+CPluginPreferencePage_build_scope=Build scope
+CPluginPreferencePage_1=Commands 'Build project', 'Build All', 'Build Working Set':
+CPluginPreferencePage_2=Build a&ctive configuration in each project
+CPluginPreferencePage_3=Build a&ll configurations in each project
+CPluginPreferencePage_4=This feature is applicable only to projects that support separate configurations.
+CPluginPreferencePage_building_configurations=Building project configurations
+CPluginPreferencePage_7=Build configurations only when there are Eclipse resource changes within the project and its references
+CPluginPreferencePage_description=General settings for C/C++ development:
+CPluginPreferencePage_cdtDialogs_group=C/C++ dialogs
+CPluginPreferencePage_clear_button=Clear
+CPluginPreferencePage_clearDoNotShowAgainSettings_label=Clear all 'do not show again' settings and show all hidden dialogs again
+CPluginPreferencePage_structuralParseMode_label=&Follow unindexed header files when producing the outline view
+CPluginPreferencePage_note=Note:
+CPluginPreferencePage_performanceHint=Enabling this preference may have negative impact on performance.
+CPluginPreferencePage_refactoring_title=Refactoring C/C++ code
+CPluginPreferencePage_refactoring_auto_save=&Save all modified resources automatically prior to refactoring
+CPluginPreferencePage_refactoring_lightweight=Rename in editor &without dialog
+
+PropertyAndPreferencePage_useworkspacesettings_change=Configure Workspace Settings...
+PropertyAndPreferencePage_showprojectspecificsettings_label=Configure Project Specific Settings...
+PropertyAndPreferencePage_useprojectsettings_label=Enable pr&oject specific settings
+
+ProjectSelectionDialog_title=Project Specific Configuration
+ProjectSelectionDialog_desciption=&Select the project to configure:
+ProjectSelectionDialog_filter=Show only &projects with project specific settings
+
+# Code Templates
+CodeTemplatesPreferencePage_title=Code Templates
+
+CodeTemplateBlock_templates_comment_node=Comments
+CodeTemplateBlock_templates_code_node=Code
+CodeTemplateBlock_templates_file_node=Files
+
+CodeTemplateBlock_namespace_begin_label=Beginning of namespace declaration
+CodeTemplateBlock_namespace_end_label=End of namespace declaration
+CodeTemplateBlock_class_body_label=Class body
+CodeTemplateBlock_constructorstub_label=Constructor body
+CodeTemplateBlock_destructorstub_label=Destructor body
+CodeTemplateBlock_methodstub_label=Method body
+CodeTemplateBlock_typecomment_label=Types
+CodeTemplateBlock_fieldcomment_label=Fields
+CodeTemplateBlock_filecomment_label=Files
+CodeTemplateBlock_methodcomment_label=Methods
+CodeTemplateBlock_constructorcomment_label=Constructors
+CodeTemplateBlock_destructorcomment_label=Destructors
+
+CodeTemplateBlock_templates_new_button=&New...
+CodeTemplateBlock_templates_edit_button=&Edit...
+CodeTemplateBlock_templates_remove_button=&Remove
+CodeTemplateBlock_templates_import_button=I&mport...
+CodeTemplateBlock_templates_export_button=E&xport...
+CodeTemplateBlock_templates_exportall_button=Ex&port All...
+
+CodeTemplateBlock_createcomment_label=&Automatically add comments for new methods and classes
+CodeTemplateBlock_templates_label=&Configure generated code and comments:
+CodeTemplateBlock_preview=Pa&ttern:
+
+CodeTemplateBlock_import_title=Import Templates
+CodeTemplateBlock_import_extension=*.xml
+
+CodeTemplateBlock_export_title=Export {0} Code Template(s)
+CodeTemplateBlock_export_filename=codetemplates.xml
+CodeTemplateBlock_export_extension=*.xml
+
+CodeTemplateBlock_export_exists_title=Export Code Templates
+CodeTemplateBlock_export_exists_message={0} already exists.\nDo you want to replace it?
+
+CodeTemplateBlock_error_read_title= Code Templates
+CodeTemplateBlock_error_read_message= Failed to read templates.
+
+CodeTemplateBlock_error_parse_message= Failed to parse templates:\n{0}
+
+CodeTemplateBlock_error_write_title=Code Templates
+CodeTemplateBlock_error_write_message=Failed to write templates.
+
+CodeTemplateBlock_export_error_title= Export Templates
+CodeTemplateBlock_export_error_hidden= Export failed.\n{0} is a hidden file.
+CodeTemplateBlock_export_error_canNotWrite= Export failed.\n{0} cannot be modified.
+
+NameStylePreferencePage_title=Name Style
+NameStyleBlock_code_node=Code
+NameStyleBlock_files_node=Files
+NameStyleBlock_constant_node=Constant
+NameStyleBlock_constant_node_description=Constant name 
+NameStyleBlock_variable_node=Variable
+NameStyleBlock_variable_node_description=Variable name 
+NameStyleBlock_field_node=Class field
+NameStyleBlock_field_node_description=Class field name 
+NameStyleBlock_getter_node=Getter Method
+NameStyleBlock_getter_node_description=Getter name based on the field name 
+NameStyleBlock_setter_node=Setter Method
+NameStyleBlock_setter_node_description=Setter name based on the field name
+NameStyleBlock_cpp_source_node=C++ Source File
+NameStyleBlock_cpp_source_node_description=C++ source file name based on the class name
+NameStyleBlock_cpp_header_node=C++ Header File
+NameStyleBlock_cpp_header_node_description=C++ header file name based on the class name
+NameStyleBlock_cpp_test_node=C++ Test File
+NameStyleBlock_cpp_test_node_description=C++ test file name based on the class name
+NameStyleBlock_categories_label=Name &Categories:
+NameStyleBlock_capitalization_label=C&apitalization:
+NameStyleBlock_capitalization_original=Original
+NameStyleBlock_capitalization_upper_case=Upper Case
+NameStyleBlock_capitalization_lower_case=Lower Case
+NameStyleBlock_capitalization_camel_case=Camel Case
+NameStyleBlock_capitalization_lower_camel_case=Lower Camel Case
+NameStyleBlock_word_delimiter_label=Word &Delimiter:
+NameStyleBlock_prefix_label=&Prefix:
+NameStyleBlock_prefix_for_boolean_label=For &Boolean:
+NameStyleBlock_suffix_label=&Suffix:
+NameStyleBlock_preview_label=Pre&view:
+NameStyleBlock_select_concrete_category=Select a specific name category
+NameStyleBlock_invalid_prefix=Invalid prefix
+NameStyleBlock_invalid_word_delimiter=Invalid word delimiter
+NameStyleBlock_invalid_suffix=Invalid suffix
+
+# edit template dialog
+EditTemplateDialog_error_noname=Template name cannot be empty.
+EditTemplateDialog_error_invalidName=Template name contains invalid characters.
+EditTemplateDialog_title_new=New Template
+EditTemplateDialog_title_edit=Edit Template
+
+EditTemplateDialog_name=&Name:
+EditTemplateDialog_description=&Description:
+EditTemplateDialog_contextType=&Type:
+EditTemplateDialog_pattern=&Pattern:
+EditTemplateDialog_insert_variable=Insert &Variable...
+
+EditTemplateDialog_undo=&Undo
+EditTemplateDialog_redo=&Redo
+EditTemplateDialog_cut=Cu&t
+EditTemplateDialog_copy=&Copy
+EditTemplateDialog_paste=&Paste
+EditTemplateDialog_select_all=Select &All
+#EditTemplateDialog_autoinsert=Auto&matically insert
+EditTemplateDialog_content_assist=Insert &Variable...
+
+# Mark Occurrences preference page
+MarkOccurrencesConfigurationBlock_title= &Mark Occurrences
+
+# DO NOT TRANSLATE "org.eclipse.ui.editors.preferencePages.Annotations"
+MarkOccurrencesConfigurationBlock_link= The appearance can be configured on the <a href=\"org.eclipse.ui.editors.preferencePages.Annotations\">Annotations</a> preference page.
+
+MarkOccurrencesConfigurationBlock_link_tooltip=Show the annotations preferences
+MarkOccurrencesConfigurationBlock_markOccurrences= Mark &occurrences of the selected element in the current file.
+MarkOccurrencesConfigurationBlock_markOverloadOccurrences= Mark o&verloaded operators
+MarkOccurrencesConfigurationBlock_stickyOccurrences= &Keep marks when the selection changes
+
+#Scalability Preferences
+ScalabilityPreferencePage_description= Settings for editor scalability
+ScalabilityPreferencePage_detection_group_label= Scalability mode detection
+ScalabilityPreferencePage_detection_label= Alert me when scalability mode will be turned on
+ScalabilityPreferencePage_trigger_lines_label= Enable scalability mode when the number of lines in the file is more than:
+ScalabilityPreferencePage_error=Value must be an integer between {0} and {1}.
+ScalabilityPreferencePage_scalabilityMode_group_label= Scalability mode settings 
+ScalabilityPreferencePage_scalabilityMode_label= Enable all scalability mode options
+ScalabilityPreferencePage_reconciler_label= Disable editor live parsing (Outline view, semantic highlighting and folding will also be disabled)
+ScalabilityPreferencePage_syntaxColor_label= Disable syntax coloring in editor
+ScalabilityPreferencePage_semanticHighlighting_label= Disable semantic highlighting in editor
+ScalabilityPreferencePage_contentAssist_label= Disable parsing-based content assist proposals
+ScalabilityPreferencePage_contentAssist_autoActivation= Disable content assist auto-activation
+ScalabilityPreferencePage_note=Note:
+ScalabilityPreferencePage_preferenceOnlyForNewEditors=Some options do not affect open editors
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreviewSourceViewer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreviewSourceViewer.java
new file mode 100644 (file)
index 0000000..1edac3a
--- /dev/null
@@ -0,0 +1,275 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 QnX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Qnx Software Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
+import org.eclipse.ui.texteditor.AbstractTextEditor;
+
+/**
+ * @deprecated Use {@link org.eclipse.cdt.internal.ui.editor.CSourceViewer} instead.
+ */
+@Deprecated
+class PreviewSourceViewer extends SourceViewer implements IPropertyChangeListener {
+
+       /**
+        * This viewer's foreground color.
+        * 
+        * @since 3.0
+        */
+       private Color fForegroundColor;
+
+       /**
+        * The viewer's background color.
+        * 
+        * @since 3.0
+        */
+       private Color fBackgroundColor;
+
+       /**
+        * This viewer's selection foreground color.
+        * 
+        * @since 3.0
+        */
+       private Color fSelectionForegroundColor;
+
+       /**
+        * The viewer's selection background color.
+        * 
+        * @since 3.0
+        */
+       private Color fSelectionBackgroundColor;
+
+       /**
+        * The preference store.
+        * 
+        * @since 3.0
+        */
+       private IPreferenceStore fPreferenceStore;
+
+       /**
+        * Is this source viewer configured?
+        * 
+        * @since 3.0
+        */
+       private boolean fIsConfigured;
+
+       public PreviewSourceViewer(Composite parent, int styles) {
+               super(parent, null, styles);
+       }
+
+       protected void initializeViewerColors() {
+               if (fPreferenceStore != null) {
+
+                       StyledText styledText = getTextWidget();
+
+                       // ----------- foreground color --------------------
+                       Color color = fPreferenceStore
+                                       .getBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT) ? null
+                                       : createColor(fPreferenceStore,
+                                                       AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND,
+                                                       styledText.getDisplay());
+                       styledText.setForeground(color);
+
+                       if (fForegroundColor != null)
+                               fForegroundColor.dispose();
+
+                       fForegroundColor = color;
+
+                       // ---------- background color ----------------------
+                       color = fPreferenceStore
+                                       .getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT) ? null
+                                       : createColor(fPreferenceStore,
+                                                       AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND,
+                                                       styledText.getDisplay());
+                       styledText.setBackground(color);
+
+                       if (fBackgroundColor != null)
+                               fBackgroundColor.dispose();
+
+                       fBackgroundColor = color;
+
+                       // ----------- selection foreground color --------------------
+                       color = fPreferenceStore
+                                       .getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR) ? null
+                                       : createColor(
+                                                       fPreferenceStore,
+                                                       AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR,
+                                                       styledText.getDisplay());
+                       styledText.setSelectionForeground(color);
+
+                       if (fSelectionForegroundColor != null)
+                               fSelectionForegroundColor.dispose();
+
+                       fSelectionForegroundColor = color;
+
+                       // ---------- selection background color ----------------------
+                       color = fPreferenceStore
+                                       .getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR) ? null
+                                       : createColor(
+                                                       fPreferenceStore,
+                                                       AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR,
+                                                       styledText.getDisplay());
+                       styledText.setSelectionBackground(color);
+
+                       if (fSelectionBackgroundColor != null)
+                               fSelectionBackgroundColor.dispose();
+
+                       fSelectionBackgroundColor = color;
+               }
+       }
+
+       /*
+        * @see ISourceViewer#configure(SourceViewerConfiguration)
+        */
+       @Override
+       public void configure(SourceViewerConfiguration configuration) {
+
+               /*
+                * Prevent access to colors disposed in unconfigure(), see:
+                * https://bugs.eclipse.org/bugs/show_bug.cgi?id=53641
+                * https://bugs.eclipse.org/bugs/show_bug.cgi?id=86177
+                */
+               StyledText textWidget = getTextWidget();
+               if (textWidget != null && !textWidget.isDisposed()) {
+                       Color foregroundColor = textWidget.getForeground();
+                       if (foregroundColor != null && foregroundColor.isDisposed())
+                               textWidget.setForeground(null);
+                       Color backgroundColor = textWidget.getBackground();
+                       if (backgroundColor != null && backgroundColor.isDisposed())
+                               textWidget.setBackground(null);
+               }
+
+               super.configure(configuration);
+
+               if (fPreferenceStore != null) {
+                       fPreferenceStore.addPropertyChangeListener(this);
+                       initializeViewerColors();
+               }
+
+               fIsConfigured = true;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.source.ISourceViewerExtension2#unconfigure()
+        * @since 3.0
+        */
+       @Override
+       public void unconfigure() {
+               if (fForegroundColor != null) {
+                       fForegroundColor.dispose();
+                       fForegroundColor = null;
+               }
+               if (fBackgroundColor != null) {
+                       fBackgroundColor.dispose();
+                       fBackgroundColor = null;
+               }
+
+                if (fPreferenceStore != null) {
+                        fPreferenceStore.removePropertyChangeListener(this);
+                }
+
+               super.unconfigure();
+
+               fIsConfigured = false;
+       }
+
+       /**
+        * Creates a color from the information stored in the given preference
+        * store. Returns <code>null</code> if there is no such information
+        * available.
+        * 
+        * @param store
+        *            the store to read from
+        * @param key
+        *            the key used for the lookup in the preference store
+        * @param display
+        *            the display used create the color
+        * @return the created color according to the specification in the
+        *         preference store
+        * @since 3.0
+        */
+       private Color createColor(IPreferenceStore store, String key,
+                       Display display) {
+
+               RGB rgb = null;
+
+               if (store.contains(key)) {
+
+                       if (store.isDefault(key))
+                               rgb = PreferenceConverter.getDefaultColor(store, key);
+                       else
+                               rgb = PreferenceConverter.getColor(store, key);
+
+                       if (rgb != null)
+                               return new Color(display, rgb);
+               }
+
+               return null;
+       }
+
+       /**
+        * Sets the preference store on this viewer.
+        * 
+        * @param store
+        *            the preference store
+        * 
+        * @since 3.0
+        */
+       public void setPreferenceStore(IPreferenceStore store) {
+               if (fIsConfigured && fPreferenceStore != null) {
+                       fPreferenceStore.removePropertyChangeListener(this);
+               }
+
+               fPreferenceStore = store;
+
+               if (fIsConfigured && fPreferenceStore != null) {
+                       fPreferenceStore.addPropertyChangeListener(this);
+                       initializeViewerColors();
+               }
+       }
+
+       /*
+        * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+        */
+       public void propertyChange(PropertyChangeEvent event) {
+               String property = event.getProperty();
+               if (AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND.equals(property)
+                               || AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT
+                                               .equals(property)
+                               || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND
+                                               .equals(property)
+                               || AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT
+                                               .equals(property)
+                               || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR
+                                               .equals(property)
+                               || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR
+                                               .equals(property)
+                               || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR
+                                               .equals(property)
+                               || AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR
+                                               .equals(property)) {
+                       initializeViewerColors();
+               }
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProjectSelectionDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProjectSelectionDialog.java
new file mode 100644 (file)
index 0000000..760a1b8
--- /dev/null
@@ -0,0 +1,160 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.util.Set;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.SelectionStatusDialog;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.ui.CElementContentProvider;
+import org.eclipse.cdt.ui.CElementLabelProvider;
+import org.eclipse.cdt.ui.CElementSorter;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+
+public class ProjectSelectionDialog extends SelectionStatusDialog {
+
+       // the visual selection widget group
+       private TableViewer fTableViewer;
+       private Set<ICProject> fProjectsWithSpecifics;
+
+       // sizing constants
+       private final static int SIZING_SELECTION_WIDGET_HEIGHT= 250;
+       private final static int SIZING_SELECTION_WIDGET_WIDTH= 300;
+       
+       private final static String DIALOG_SETTINGS_SHOW_ALL= "ProjectSelectionDialog.show_all"; //$NON-NLS-1$
+
+       private ViewerFilter fFilter;
+
+       public ProjectSelectionDialog(Shell parentShell, Set<ICProject> projectsWithSpecifics) {
+               super(parentShell);
+               setTitle(PreferencesMessages.ProjectSelectionDialog_title);  
+               setMessage(PreferencesMessages.ProjectSelectionDialog_desciption); 
+               fProjectsWithSpecifics= projectsWithSpecifics;
+               
+               fFilter= new ViewerFilter() {
+                       @Override
+                       public boolean select(Viewer viewer, Object parentElement, Object element) {
+                               return fProjectsWithSpecifics.contains(element);
+                       }
+               };
+       }
+       
+
+       /* (non-Javadoc)
+        * Method declared on Dialog.
+        */
+       @Override
+       protected Control createDialogArea(Composite parent) {
+               // page group
+               Composite composite= (Composite) super.createDialogArea(parent);
+
+               Font font= parent.getFont();
+               composite.setFont(font);
+
+               createMessageArea(composite);
+
+               fTableViewer= new TableViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+               fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+                       public void selectionChanged(SelectionChangedEvent event) {
+                               doSelectionChanged(((IStructuredSelection) event.getSelection()).toArray());
+                       }
+               });
+               fTableViewer.addDoubleClickListener(new IDoubleClickListener() {
+                       public void doubleClick(DoubleClickEvent event) {
+                okPressed();
+                       }
+               });
+               GridData data= new GridData(SWT.FILL, SWT.FILL, true, true);
+               data.heightHint= SIZING_SELECTION_WIDGET_HEIGHT;
+               data.widthHint= SIZING_SELECTION_WIDGET_WIDTH;
+               fTableViewer.getTable().setLayoutData(data);
+
+               fTableViewer.setLabelProvider(new CElementLabelProvider());
+               fTableViewer.setContentProvider(new CElementContentProvider());
+               fTableViewer.setComparator(new CElementSorter());
+               fTableViewer.getControl().setFont(font);
+
+               Button checkbox= new Button(composite, SWT.CHECK);
+               checkbox.setText(PreferencesMessages.ProjectSelectionDialog_filter); 
+               checkbox.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));
+               checkbox.addSelectionListener(new SelectionListener() {
+                       public void widgetSelected(SelectionEvent e) {
+                               updateFilter(((Button) e.widget).getSelection());
+                       }
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               updateFilter(((Button) e.widget).getSelection());
+                       }
+               });
+               IDialogSettings dialogSettings= CUIPlugin.getDefault().getDialogSettings();
+               boolean doFilter= !dialogSettings.getBoolean(DIALOG_SETTINGS_SHOW_ALL) && !fProjectsWithSpecifics.isEmpty();
+               checkbox.setSelection(doFilter);
+               updateFilter(doFilter);
+               
+               ICModel input= CoreModel.getDefault().getCModel();
+               fTableViewer.setInput(input);
+               
+               doSelectionChanged(new Object[0]);
+               Dialog.applyDialogFont(composite);
+               return composite;
+       }
+       
+       protected void updateFilter(boolean selected) {
+               if (selected) {
+                       fTableViewer.addFilter(fFilter);
+               } else {
+                       fTableViewer.removeFilter(fFilter);
+               }
+               CUIPlugin.getDefault().getDialogSettings().put(DIALOG_SETTINGS_SHOW_ALL, !selected);
+       }
+
+       private void doSelectionChanged(Object[] objects) {
+               if (objects.length != 1) {
+                       updateStatus(new StatusInfo(IStatus.ERROR, "")); //$NON-NLS-1$
+                       setSelectionResult(null);
+               } else {
+                       updateStatus(new StatusInfo()); 
+                       setSelectionResult(objects);
+               }
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.dialogs.SelectionStatusDialog#computeResult()
+        */
+       @Override
+       protected void computeResult() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PropertyAndPreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PropertyAndPreferencePage.java
new file mode 100644 (file)
index 0000000..2bb8834
--- /dev/null
@@ -0,0 +1,349 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin, Google
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.ControlEnableState;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.IWorkbenchPropertyPage;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICProject;
+
+import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
+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.SelectionButtonDialogField;
+
+/**
+ * Base for project property and preference pages
+ */
+public abstract class PropertyAndPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, IWorkbenchPropertyPage {
+       
+       private Control fConfigurationBlockControl;
+       private ControlEnableState fBlockEnableState;
+       private Link fChangeWorkspaceSettings;
+       private SelectionButtonDialogField fUseProjectSettings;
+       private IStatus fBlockStatus;
+       private Composite fParentComposite;
+       
+       private IProject fProject; // project or null
+       private Map <?,?> fData; // page data
+       
+       public static final String DATA_NO_LINK= "PropertyAndPreferencePage.nolink"; //$NON-NLS-1$
+       
+       public PropertyAndPreferencePage() {
+               fBlockStatus= new StatusInfo();
+               fBlockEnableState= null;
+               fProject= null;
+               fData= null;
+       }
+
+       protected abstract Control createPreferenceContent(Composite composite);
+       protected abstract boolean hasProjectSpecificOptions(IProject project);
+       
+       protected abstract String getPreferencePageID();
+       protected abstract String getPropertyPageID();
+       
+       protected boolean supportsProjectSpecificOptions() {
+               return getPropertyPageID() != null;
+       }
+       
+       protected boolean offerLink() {
+               return fData == null || !Boolean.TRUE.equals(fData.get(DATA_NO_LINK));
+       }
+       
+    @Override
+       protected Label createDescriptionLabel(Composite parent) {
+               fParentComposite= parent;
+               if (isProjectPreferencePage()) {
+                       Composite composite= new Composite(parent, SWT.NONE);
+                       composite.setFont(parent.getFont());
+                       GridLayout layout= new GridLayout();
+                       layout.marginHeight= 0;
+                       layout.marginWidth= 0;
+                       layout.numColumns= 2;
+                       composite.setLayout(layout);
+                       composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+                       
+                       IDialogFieldListener listener= new IDialogFieldListener() {
+                               public void dialogFieldChanged(DialogField field) {
+                                       enableProjectSpecificSettings(((SelectionButtonDialogField)field).isSelected());
+                               }
+                       };
+                       
+                       fUseProjectSettings= new SelectionButtonDialogField(SWT.CHECK);
+                       fUseProjectSettings.setDialogFieldListener(listener);
+                       fUseProjectSettings.setLabelText(PreferencesMessages.PropertyAndPreferencePage_useprojectsettings_label);
+                       fUseProjectSettings.doFillIntoGrid(composite, 1);
+                       LayoutUtil.setHorizontalGrabbing(fUseProjectSettings.getSelectionButton(null), true);
+                       
+                       if (offerLink()) {
+                               fChangeWorkspaceSettings= createLink(composite, PreferencesMessages.PropertyAndPreferencePage_useworkspacesettings_change);
+                               fChangeWorkspaceSettings.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
+                       } else {
+                               LayoutUtil.setHorizontalSpan(fUseProjectSettings.getSelectionButton(null), 2);
+                       }
+                       
+                       Label horizontalLine= new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
+                       horizontalLine.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
+                       horizontalLine.setFont(composite.getFont());
+               } else if (supportsProjectSpecificOptions() && offerLink()) {
+                       fChangeWorkspaceSettings= createLink(parent, PreferencesMessages.PropertyAndPreferencePage_showprojectspecificsettings_label);
+                       fChangeWorkspaceSettings.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false));
+               }
+
+               return super.createDescriptionLabel(parent);
+    }
+       
+       /*
+        * @see org.eclipse.jface.preference.IPreferencePage#createContents(Composite)
+        */
+       @Override
+       protected Control createContents(Composite parent) {
+               Composite composite= new Composite(parent, SWT.NONE);
+               GridLayout layout= new GridLayout();
+               layout.marginHeight= 0;
+               layout.marginWidth= 0;
+               composite.setLayout(layout);
+               composite.setFont(parent.getFont());
+                       
+               GridData data= new GridData(GridData.FILL, GridData.FILL, true, true);
+               
+               fConfigurationBlockControl= createPreferenceContent(composite);
+               fConfigurationBlockControl.setLayoutData(data);
+
+               if (isProjectPreferencePage()) {
+                       boolean useProjectSettings= hasProjectSpecificOptions(getProject());
+                       enableProjectSpecificSettings(useProjectSettings);
+               }
+
+               Dialog.applyDialogFont(composite);
+               return composite;
+       }
+
+       private Link createLink(Composite composite, String text) {
+               Link link= new Link(composite, SWT.NONE);
+               link.setFont(composite.getFont());
+               link.setText("<A>" + text + "</A>");  //$NON-NLS-1$//$NON-NLS-2$
+               link.addSelectionListener(new SelectionListener() {
+                       public void widgetSelected(SelectionEvent e) {
+                               doLinkActivated((Link) e.widget);
+                       }
+
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               doLinkActivated((Link) e.widget);
+                       }
+               });
+               return link;
+       }
+       
+       protected boolean useProjectSettings() {
+               return isProjectPreferencePage() && fUseProjectSettings != null && fUseProjectSettings.isSelected();
+       }
+       
+       protected boolean isProjectPreferencePage() {
+               return fProject != null;
+       }
+       
+       protected IProject getProject() {
+               return fProject;
+       }
+       
+       /**
+        * Handle link activation.
+        * 
+        * @param link the link
+        */
+       final void doLinkActivated(Link link) {
+               Map<String, Boolean> data= new HashMap<String, Boolean>();
+               data.put(DATA_NO_LINK, Boolean.TRUE);
+               
+               if (isProjectPreferencePage()) {
+                       openWorkspacePreferences(data);
+               } else {
+                       HashSet<ICProject> projectsWithSpecifics= new HashSet<ICProject>();
+                       try {
+                               ICProject[] projects= CoreModel.getDefault().getCModel().getCProjects();
+                               for (ICProject curr : projects) {
+                                       if (hasProjectSpecificOptions(curr.getProject())) {
+                                               projectsWithSpecifics.add(curr);
+                                       }
+                               }
+                       } catch (CModelException e) {
+                               // ignore
+                       }
+                       ProjectSelectionDialog dialog= new ProjectSelectionDialog(getShell(), projectsWithSpecifics);
+                       if (dialog.open() == Window.OK) {
+                               ICProject res= (ICProject) dialog.getFirstResult();
+                               openProjectProperties(res.getProject(), data);
+                       }
+               }
+       }
+       
+       protected final void openWorkspacePreferences(Object data) {
+               String id= getPreferencePageID();
+               PreferencesUtil.createPreferenceDialogOn(getShell(), id, new String[] { id }, data).open();
+       }
+       
+       protected final void openProjectProperties(IProject project, Object data) {
+               String id= getPropertyPageID();
+               if (id != null) {
+                       PreferencesUtil.createPropertyDialogOn(getShell(), project, id, new String[] { id }, data).open();
+               }
+       }
+       
+       
+       protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
+               fUseProjectSettings.setSelection(useProjectSpecificSettings);
+               enablePreferenceContent(useProjectSpecificSettings);
+               updateLinkVisibility();
+               doStatusChanged();
+       }
+       
+       private void updateLinkVisibility() {
+               if (fChangeWorkspaceSettings == null || fChangeWorkspaceSettings.isDisposed()) {
+                       return;
+               }
+               
+               if (isProjectPreferencePage()) {
+                       fChangeWorkspaceSettings.setEnabled(!useProjectSettings());
+               }
+       }
+       
+
+       protected void setPreferenceContentStatus(IStatus status) {
+               fBlockStatus= status;
+               doStatusChanged();
+       }
+       
+       /**
+        * Returns a new status change listener that calls {@link #setPreferenceContentStatus(IStatus)}
+        * when the status has changed
+        * @return The new listener
+        */
+       protected IStatusChangeListener getNewStatusChangedListener() {
+               return new IStatusChangeListener() {
+                       public void statusChanged(IStatus status) {
+                               setPreferenceContentStatus(status);
+                       }
+               };
+       }
+       
+       protected IStatus getPreferenceContentStatus() {
+               return fBlockStatus;
+       }
+
+       protected void doStatusChanged() {
+               if (!isProjectPreferencePage() || useProjectSettings()) {
+                       updateStatus(fBlockStatus);
+               } else {
+                       updateStatus(new StatusInfo());
+               }
+       }
+               
+       protected void enablePreferenceContent(boolean enable) {
+               if (enable) {
+                       if (fBlockEnableState != null) {
+                               fBlockEnableState.restore();
+                               fBlockEnableState= null;
+                       }
+               } else {
+                       if (fBlockEnableState == null) {
+                               fBlockEnableState= ControlEnableState.disable(fConfigurationBlockControl);
+                       }
+               }
+       }
+       
+       /*
+        * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
+        */
+       @Override
+       protected void performDefaults() {
+               if (useProjectSettings()) {
+                       enableProjectSpecificSettings(false);
+               }
+               super.performDefaults();
+       }
+
+       private void updateStatus(IStatus status) {
+               setValid(!status.matches(IStatus.ERROR));
+               StatusUtil.applyToStatusLine(this, status);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+        */
+       public void init(IWorkbench workbench) {
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchPropertyPage#getElement()
+        */
+       public IAdaptable getElement() {
+               return fProject;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchPropertyPage#setElement(org.eclipse.core.runtime.IAdaptable)
+        */
+       public void setElement(IAdaptable element) {
+               fProject= (IProject) element.getAdapter(IResource.class);
+       }
+       
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.preference.PreferencePage#applyData(java.lang.Object)
+        */
+       @Override
+       public void applyData(Object data) {
+               if (data instanceof Map<?, ?>) {
+                       fData= (Map<?,?>) data;
+               }
+               if (fChangeWorkspaceSettings != null) {
+                       if (!offerLink()) {
+                               fChangeWorkspaceSettings.dispose();
+                               fParentComposite.layout(true, true);
+                       }
+               }
+       }
+       
+       protected Map<?,?> getData() {
+               return fData;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProposalFilterPreferencesUtil.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProposalFilterPreferencesUtil.java
new file mode 100644 (file)
index 0000000..14a0918
--- /dev/null
@@ -0,0 +1,238 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 QNX Software Systems
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.InvalidRegistryObjectException;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.widgets.Combo;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
+
+/**
+ * A class which encapsulates several utility functions
+ * related to code completion preference settings.
+ */
+public class ProposalFilterPreferencesUtil {
+
+       /**
+        * Private default constructor prevents instantiation
+        */
+       private ProposalFilterPreferencesUtil() {
+       }
+
+       /**
+        * Get an array of proposal filter names
+        * (i.e. the human-readable text for display
+        * to fill into the Combo)
+        */
+       public static String[] getProposalFilterNames() {
+               ArrayList<String> names = new ArrayList<String>();
+               try {
+                       IExtensionPoint point = Platform.getExtensionRegistry()
+                                       .getExtensionPoint(CUIPlugin.PLUGIN_ID, "ProposalFilter"); //$NON-NLS-1$
+                       if (point != null) {
+                               IExtension[] extensions = point.getExtensions();
+                               for (IExtension extension : extensions) {
+                                       IConfigurationElement[] elements = extension.getConfigurationElements();
+                                       for (int j = 0; j < elements.length; ++j) {
+                                               IConfigurationElement element = elements[j];
+                                               if ("ProposalFilter".equals(element.getName())) { //$NON-NLS-1$
+                                                       String filterName = element.getAttribute("name"); //$NON-NLS-1$
+                                                       if (null != filterName) {
+                                                               names.add(filterName);
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               } catch (InvalidRegistryObjectException e) {
+                       // No action required since we will at least be using the fail-safe default filter
+                       CUIPlugin.log(e);
+               }
+               String[] filterNames = names.toArray(new String[names.size()]);
+               return filterNames;
+       }
+
+       /**
+        * Look up all contributed completion proposal filters 
+        * and return their names as a semicolon-separated list
+        * plus a leading entry for the selected index 0,
+        * plus a leading <default> entry. <br>
+        * A Combo may be initialized from this string.
+        * @return The list of filter names
+        */
+       public static String getProposalFilternamesAsString() {
+               StringBuffer filterNames = new StringBuffer("0;"); //$NON-NLS-1$
+               filterNames.append(PreferencesMessages.ProposalFilterPreferencesUtil_defaultFilterName);
+               String[] names = getProposalFilterNames();
+               for (String name : names) {
+                       filterNames.append(";"); //$NON-NLS-1$
+                       filterNames.append(name);
+               }
+               return filterNames.toString();
+       }
+
+       /**
+        * Return the configuration element which corresponds 
+        * to the human-readable filter name
+        * @param filterName The human-readable filter name
+        * @return The configuration element, or null if there is none
+        */
+       public static IConfigurationElement getElementForName(String filterName) {
+               IConfigurationElement element = null;
+               IExtensionPoint point = Platform.getExtensionRegistry()
+                               .getExtensionPoint(CUIPlugin.PLUGIN_ID, "ProposalFilter"); //$NON-NLS-1$
+               if (point != null) {
+                       try {
+                               IExtension[] extensions = point.getExtensions();
+                               if (extensions.length >= 1) {
+                                       for (IExtension extension : extensions) {
+                                               IConfigurationElement[] elements = extension
+                                                               .getConfigurationElements();
+
+                                               for (int j = 0; j < elements.length; ++j) {
+                                                       IConfigurationElement testElement = elements[j];
+                                                       if ("ProposalFilter".equals(testElement.getName())) { //$NON-NLS-1$
+                                                               String testName = testElement
+                                                                               .getAttribute("name"); //$NON-NLS-1$
+                                                               if ((null != testName)
+                                                                               && (filterName.equals(testName))) {
+                                                                       element = testElement;
+                                                                       break;
+                                                               }
+                                                       }
+                                               }
+                                               // Did we find the corresponding element?
+                                               if (null != element)
+                                                       break;
+                                       }
+                               }
+                       } catch (InvalidRegistryObjectException e) {
+                               // In case of failure we'll just return null
+                       }
+               }
+
+               return element;
+       }
+
+       /**
+        * The state of a Combo consists of the list of entries
+        * and the index of the selected entry.
+        * This method converts the state of the given Combo 
+        * to a string representation for storage in a preference store. <br>
+        * The string contains a semicolon-separated list of entries.
+        * The first entry is the index of the selected entry.
+        * The following entries are the texts of the individual fields. <br>
+        * Since the semicolon is the separator, the entries cannot contain semicolons.
+        * This method will replace semicolons with commas if any are found.
+        * @param combo The Combo whose state shall be converted
+        * @return A string representation of the Combo state
+        */
+       public static String comboStateAsString(Combo combo) {
+               StringBuffer text = new StringBuffer();
+               int selectionIndex = combo.getSelectionIndex();
+               text.append(selectionIndex);
+               String[] entries = combo.getItems();
+               for (String entrie : entries) {
+                       text.append(";"); //$NON-NLS-1$
+                       String entry = entrie.replaceAll(";", ","); //$NON-NLS-1$ //$NON-NLS-2$
+                       text.append(entry);
+               }
+               return text.toString();
+       }
+
+       /**
+        * The state of a Combo consists of the list of entries
+        * and the index of the selected entry.
+        * This method takes a string representation of the state (e.g. from a preference store)
+        * and restores it into the Combo. <br>
+        * For a description of the text format see method comboStateAsString().
+        * @param combo The combo to be restored.
+        * @param text The text representation of the state.
+        */
+       public static void restoreComboFromString(Combo combo, String text) {
+               try {
+                       int endFirstEntry = text.indexOf(";"); //$NON-NLS-1$
+                       if (endFirstEntry > 0) { // First entry must contain at least one character
+                               String selectedString = text.substring(0, endFirstEntry);
+                               int selectedIndex = Integer.parseInt(selectedString);
+                               String[] entryList = text.substring(endFirstEntry + 1,
+                                               text.length()).split(";"); //$NON-NLS-1$
+                               combo.setItems(entryList);
+                               combo.select(selectedIndex);
+                       }
+               } catch (NumberFormatException e) {
+                       // If this fails we just return the unmodified Combo
+               }
+       }
+
+       /**
+        * Convenience class wraps the data to initialize a Combo
+        */
+       public static class ComboState {
+               public int selectedIndex;
+
+               public String[] items;
+       }
+
+       /** 
+        * Convenience method to extract the state of a Combo
+        * from the state string stored e.g. in a preference store
+        * @param comboPreference The state string
+        * @return A ComboState instance. 
+        */
+       public static ComboState getComboState(String comboPreference) {
+               ComboState state = new ComboState();
+               try {
+                       int endFirstEntry = comboPreference.indexOf(";"); //$NON-NLS-1$
+                       if (endFirstEntry > 0) { // First entry must contain at least one character
+                               String selectedString = comboPreference.substring(0,
+                                               endFirstEntry);
+                               state.selectedIndex = Integer.parseInt(selectedString);
+                               state.items = comboPreference.substring(endFirstEntry + 1,
+                                               comboPreference.length()).split(";"); //$NON-NLS-1$
+                       }
+               } catch (NumberFormatException e) {
+                       // If this fails we return an empty ComboState
+                       state.items = new String[0];
+               }
+               return state;
+       }
+
+       /**
+        * Look up the setting for the preferred proposal filter
+        * and return it's configuration element.
+        * @return The configuration element, or null if none is found.
+        */
+       public static IConfigurationElement getPreferredFilterElement() {
+               IConfigurationElement preferredElement = null;
+               try {
+                       IPreferenceStore store = CUIPlugin.getDefault()
+                                       .getPreferenceStore();
+                       String filterComboStateString = store
+                                       .getString(ContentAssistPreference.PROPOSALS_FILTER);
+                       ComboState state = getComboState(filterComboStateString);
+                       preferredElement = getElementForName(state.items[state.selectedIndex]);
+               } catch (Exception e) {
+                       // If anything goes wrong we'll just return null
+               }
+               return preferredElement;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SaveActionsPreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SaveActionsPreferencePage.java
new file mode 100644 (file)
index 0000000..3bb657f
--- /dev/null
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Google, Inc and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *        Sergey Prigogin (Google) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.util.ArrayList;
+
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey;
+
+/*
+ * The page for configuring actions performed when a C/C++ file is saved.
+ */
+public class SaveActionsPreferencePage extends AbstractPreferencePage {
+       private Button fRadioEditedLines;
+       private Button fRadioAllLines;
+
+       public SaveActionsPreferencePage() {
+               super();
+       }
+
+       @Override
+       protected OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
+               ArrayList<OverlayKey> overlayKeys = new ArrayList<OverlayKey>();
+
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+                               PreferenceConstants.REMOVE_TRAILING_WHITESPACE));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+                               PreferenceConstants.REMOVE_TRAILING_WHITESPACE_LIMIT_TO_EDITED_LINES));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN,
+                               PreferenceConstants.ENSURE_NEWLINE_AT_EOF));
+
+        OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
+               overlayKeys.toArray(keys);
+               return keys;
+       }
+
+       /*
+        * @see PreferencePage#createControl(Composite)
+        */
+       @Override
+       public void createControl(Composite parent) {
+               super.createControl(parent);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
+                               ICHelpContextIds.SAVE_ACTIONS_PREFERENCE_PAGE);
+       }
+
+       // sets enabled flag for a control and all its sub-tree
+       protected static void setEnabled(Control control, boolean enable) {
+               control.setEnabled(enable);
+               if (control instanceof Composite) {
+                       Composite composite = (Composite) control;
+                       Control[] children = composite.getChildren();
+                       for (Control element : children)
+                               setEnabled(element, enable);
+               }
+       }
+
+       private Control createConfigurationBlock(Composite parent) {
+               Composite composite= ControlFactory.createComposite(parent, 1);
+               composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+               
+               String label = PreferencesMessages.SaveActionsPreferencePage_removeTrailingWhitespace;
+               Button checkboxTrailingWhitespace = addCheckBox(composite, label,
+                               PreferenceConstants.REMOVE_TRAILING_WHITESPACE, 0);
+               fRadioEditedLines = addRadioButton(composite, PreferencesMessages.SaveActionsPreferencePage_inEditedLines,
+                               PreferenceConstants.REMOVE_TRAILING_WHITESPACE_LIMIT_TO_EDITED_LINES, 0);
+               fRadioAllLines = addRadioButton(composite, PreferencesMessages.SaveActionsPreferencePage_inAllLines,
+                               null, 0);
+               createDependency(checkboxTrailingWhitespace,
+                               PreferenceConstants.REMOVE_TRAILING_WHITESPACE, fRadioEditedLines);
+               createDependency(checkboxTrailingWhitespace,
+                               PreferenceConstants.REMOVE_TRAILING_WHITESPACE, fRadioAllLines);
+
+               ControlFactory.createEmptySpace(composite, 1);
+
+               label = PreferencesMessages.SaveActionsPreferencePage_ensureNewline;
+               addCheckBox(composite, label, PreferenceConstants.ENSURE_NEWLINE_AT_EOF, 0);
+               
+               return composite;
+       }
+
+       /*
+        * @see PreferencePage#createContents(Composite)
+        */
+       @Override
+       protected Control createContents(Composite parent) {
+               fOverlayStore.load();
+               fOverlayStore.start();
+
+               createConfigurationBlock(parent);
+               
+               initialize();
+               return parent;
+       }
+
+       private void initialize() {
+               initializeFields();
+               fRadioAllLines.setSelection(!fRadioEditedLines.getSelection());
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ScalabilityPreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ScalabilityPreferencePage.java
new file mode 100644 (file)
index 0000000..fe242e8
--- /dev/null
@@ -0,0 +1,306 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences;
+
+import com.ibm.icu.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.IntegerFieldEditor;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.Separator;
+
+public class ScalabilityPreferencePage extends PreferencePage implements
+               IWorkbenchPreferencePage {
+       
+       // Files with this number of lines will trigger scalability mode
+       private IntegerFieldEditor fLinesToTrigger;
+       
+       private Button fEnableAll;
+       
+       private Button fReconciler;
+       
+       private Button fSyntaxColor;
+       
+       private Button fSemanticHighlighting;
+       
+       private Button fContentAssist;
+       
+       private Button fContentAssistAutoActivation;
+       
+       private Map<Object, String> fCheckBoxes= new HashMap<Object, String>();
+       
+       /**
+        * List of master/slave listeners when there's a dependency.
+        * 
+        * @see #createDependency(Button, String, Control)
+        */
+       private ArrayList<Object> fMasterSlaveListeners= new ArrayList<Object>();
+       
+       public ScalabilityPreferencePage() {
+               setPreferenceStore(PreferenceConstants.getPreferenceStore());
+               setDescription(PreferencesMessages.ScalabilityPreferencePage_description);
+       }
+       
+       /**
+        * Creates a button with the given label and sets the default configuration data.
+        */
+       private Button createCheckButton( Composite parent, String label, String key ) {
+               Button button = new Button( parent, SWT.CHECK | SWT.LEFT );
+               button.setText( label );
+               // FieldEditor GridData
+               GridData data = new GridData();
+               button.setLayoutData( data );
+               fCheckBoxes.put(button, key);
+               return button;
+       }
+       
+       private void initFields() {
+               IPreferenceStore prefs=getPreferenceStore();
+
+               Iterator<Object> iter= fCheckBoxes.keySet().iterator();
+               while (iter.hasNext()) {
+                       Button b= (Button) iter.next();
+                       String key= fCheckBoxes.get(b);
+                       b.setSelection(prefs.getBoolean(key));
+               }
+               
+        // Update slaves
+        iter= fMasterSlaveListeners.iterator();
+        while (iter.hasNext()) {
+            SelectionListener listener= (SelectionListener)iter.next();
+            listener.widgetSelected(null);
+        }
+        fLinesToTrigger.setStringValue(Integer.toString(prefs.getInt(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES)));
+       }
+
+       /*
+        * @see PreferencePage#createControl(Composite)
+        */
+       @Override
+       public void createControl(Composite parent) {
+               super.createControl(parent);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.SCALABILITY_PREFERENCE_PAGE);
+       }
+
+       /*
+        * @see PreferencePage#createContents(Composite)
+        */
+       @Override
+       protected Control createContents(Composite parent) {
+               initializeDialogUnits(parent);
+               int nColumns= 1;
+                               
+               Composite composite= new Composite(parent, SWT.NONE);
+               GridLayout layout= new GridLayout();
+               layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+               layout.marginWidth= 0;
+               layout.numColumns= nColumns;
+               composite.setLayout(layout);
+               
+               GridData data = new GridData();
+               data.verticalAlignment = GridData.FILL;
+               data.horizontalAlignment = GridData.FILL;
+               composite.setLayoutData( data );
+               
+               createDetectionSettings(composite);
+
+               new Separator().doFillIntoGrid(composite, nColumns);
+               
+               createScalabilityModeSettings(composite);
+
+               new Separator().doFillIntoGrid(composite, nColumns);
+               
+               String noteTitle= PreferencesMessages.ScalabilityPreferencePage_note;
+               String noteMessage= PreferencesMessages.ScalabilityPreferencePage_preferenceOnlyForNewEditors;
+               Composite noteControl= createNoteComposite(JFaceResources.getDialogFont(), composite, noteTitle, noteMessage);
+               GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               gd.horizontalSpan= 2;
+               noteControl.setLayoutData(gd);
+               
+               initFields();
+               
+               Dialog.applyDialogFont(composite);
+               return composite;
+       }
+       
+       /**
+        * Creates composite group and sets the default layout data.
+        * 
+        * @param parent
+        *            the parent of the new composite
+        * @param numColumns
+        *            the number of columns for the new composite
+        * @param labelText
+        *            the text label of the new composite
+        * @return the newly-created composite
+        */
+       private Composite createGroupComposite( Composite parent, int numColumns, String labelText ) {
+               return ControlFactory.createGroup( parent, labelText, numColumns );
+       }
+       
+       /**
+        * Create the view setting preferences composite widget
+        */
+       private void createDetectionSettings( Composite parent ) {
+               Composite group = createGroupComposite( parent, 1, PreferencesMessages.ScalabilityPreferencePage_detection_group_label );
+               createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_detection_label,PreferenceConstants.SCALABILITY_ALERT);
+
+               Composite comp= new Composite(group, SWT.NONE);
+               fLinesToTrigger = new IntegerFieldEditor( PreferenceConstants.SCALABILITY_NUMBER_OF_LINES, PreferencesMessages.ScalabilityPreferencePage_trigger_lines_label, comp);
+               GridData data = (GridData)fLinesToTrigger.getTextControl( comp ).getLayoutData();
+               data.horizontalAlignment = GridData.BEGINNING;
+               data.widthHint = convertWidthInCharsToPixels( 11 );
+               fLinesToTrigger.setPage( this );
+               fLinesToTrigger.setValidateStrategy( StringFieldEditor.VALIDATE_ON_KEY_STROKE );
+               fLinesToTrigger.setValidRange( 1, Integer.MAX_VALUE );
+               String minValue = Integer.toString( 1 );
+               String maxValue = Integer.toString( Integer.MAX_VALUE );
+               fLinesToTrigger.setErrorMessage( MessageFormat.format(PreferencesMessages.ScalabilityPreferencePage_error, new Object[] {minValue, maxValue}) );
+               fLinesToTrigger.load();
+               fLinesToTrigger.setPropertyChangeListener( new IPropertyChangeListener() {
+
+                       public void propertyChange( PropertyChangeEvent event ) {
+                               if ( event.getProperty().equals( FieldEditor.IS_VALID ) )
+                                       setValid( fLinesToTrigger.isValid() );
+                       }
+               } );
+               
+       }
+       
+       /**
+        * Create the view setting preferences composite widget
+        */
+       private void createScalabilityModeSettings( Composite parent ) {
+               Composite group = createGroupComposite( parent, 1, PreferencesMessages.ScalabilityPreferencePage_scalabilityMode_group_label );
+               
+               fEnableAll = createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_scalabilityMode_label, PreferenceConstants.SCALABILITY_ENABLE_ALL);
+               fReconciler = createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_reconciler_label, PreferenceConstants.SCALABILITY_RECONCILER);
+               createDependency(fEnableAll, PreferenceConstants.SCALABILITY_ENABLE_ALL, fReconciler, true);
+               
+               fSemanticHighlighting = createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_semanticHighlighting_label, PreferenceConstants.SCALABILITY_SEMANTIC_HIGHLIGHT);
+               createDependency(fEnableAll, PreferenceConstants.SCALABILITY_ENABLE_ALL, fSemanticHighlighting, true);
+               
+               fSyntaxColor = createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_syntaxColor_label, PreferenceConstants.SCALABILITY_SYNTAX_COLOR);
+               createDependency(fEnableAll, PreferenceConstants.SCALABILITY_ENABLE_ALL, fSyntaxColor, true);
+               
+               fContentAssist = createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_contentAssist_label, PreferenceConstants.SCALABILITY_PARSER_BASED_CONTENT_ASSIST);
+               createDependency(fEnableAll, PreferenceConstants.SCALABILITY_ENABLE_ALL, fContentAssist, true);
+               
+               fContentAssistAutoActivation = createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_contentAssist_autoActivation, PreferenceConstants.SCALABILITY_CONTENT_ASSIST_AUTO_ACTIVATION);
+               createDependency(fContentAssist, PreferenceConstants.SCALABILITY_PARSER_BASED_CONTENT_ASSIST, fContentAssistAutoActivation, true);
+               createDependency(fEnableAll, PreferenceConstants.SCALABILITY_ENABLE_ALL, fContentAssistAutoActivation, false);
+       }
+       
+       private static void indent(Control control, GridData masterLayoutData) {
+               GridData gridData= new GridData();
+               gridData.horizontalIndent= masterLayoutData.horizontalIndent + 20;
+               control.setLayoutData(gridData);
+       }
+       
+       private void createDependency(final Button master, String masterKey, final Control slave, boolean indent) {
+               if (indent) {
+                       indent(slave, (GridData)master.getLayoutData());
+               }
+               boolean masterState= getPreferenceStore().getBoolean(masterKey);
+               slave.setEnabled(!masterState);
+               
+               if (masterState) {
+                       ((Button)slave).setSelection(masterState);
+               }
+               
+               SelectionListener listener= new SelectionListener() {
+                       public void widgetSelected(SelectionEvent e) {
+                               slave.setEnabled(!master.getSelection());
+                               if (master.getSelection()) {
+                                       ((Button)slave).setSelection(master.getSelection());
+                               }
+                       }
+
+                       public void widgetDefaultSelected(SelectionEvent e) {}
+               };
+               master.addSelectionListener(listener);
+               fMasterSlaveListeners.add(listener);
+       }
+       
+       /*
+        * @see IWorkbenchPreferencePage#init(IWorkbench)
+        */
+       public void init(IWorkbench workbench) {
+       }
+       
+       /*
+        * @see IPreferencePage#performOk()
+        */
+       @Override
+       public boolean performOk() {
+               IPreferenceStore prefs= getPreferenceStore();
+               Iterator<Object> iter= fCheckBoxes.keySet().iterator();
+               while (iter.hasNext()) {
+                       Button b= (Button) iter.next();
+                       String key= fCheckBoxes.get(b);
+                       prefs.setValue(key, b.getSelection());
+               }
+               prefs.setValue(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES, fLinesToTrigger.getIntValue());
+               return super.performOk();
+       }
+       
+       /*
+        * @see PreferencePage#performDefaults()
+        */
+       @Override
+       protected void performDefaults() {
+               IPreferenceStore prefs= getPreferenceStore();
+
+               Iterator<Object> iter= fCheckBoxes.keySet().iterator();
+               while (iter.hasNext()) {
+                       Button b= (Button) iter.next();
+                       String key= fCheckBoxes.get(b);
+                       b.setSelection(prefs.getDefaultBoolean(key));
+               }
+               
+        // Update slaves
+        iter= fMasterSlaveListeners.iterator();
+        while (iter.hasNext()) {
+            SelectionListener listener= (SelectionListener)iter.next();
+            listener.widgetSelected(null);
+        }
+        fLinesToTrigger.setStringValue(Integer.toString(prefs.getDefaultInt(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES)));
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ScrolledPageContent.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ScrolledPageContent.java
new file mode 100644 (file)
index 0000000..7de7e0a
--- /dev/null
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin, Google
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+import org.eclipse.ui.forms.FormColors;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.SharedScrolledComposite;
+
+
+public class ScrolledPageContent extends SharedScrolledComposite {
+
+       private FormToolkit fToolkit;
+       
+       public ScrolledPageContent(Composite parent) {
+               this(parent, SWT.V_SCROLL | SWT.H_SCROLL);
+       }
+       
+       public ScrolledPageContent(Composite parent, int style) {
+               super(parent, style);
+               
+               setFont(parent.getFont());
+               
+               FormColors colors= new FormColors(parent.getDisplay());
+               colors.setBackground(null);
+               colors.setForeground(null);
+               
+               fToolkit= new FormToolkit(colors);
+               
+               setExpandHorizontal(true);
+               setExpandVertical(true);
+               
+               Composite body= new Composite(this, SWT.NONE);
+               body.setFont(parent.getFont());
+               setContent(body);
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.swt.widgets.Widget#dispose()
+        */
+       @Override
+       public void dispose() {
+               fToolkit.dispose();
+               super.dispose();
+       }
+       
+       public void adaptChild(Control childControl) {
+               fToolkit.adapt(childControl, true, true);
+       }
+       
+       public Composite getBody() {
+               return (Composite) getContent();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SmartTypingConfigurationBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SmartTypingConfigurationBlock.java
new file mode 100644 (file)
index 0000000..ee24187
--- /dev/null
@@ -0,0 +1,262 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin, Google
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
+
+import org.eclipse.cdt.internal.ui.util.Messages;
+
+/**
+ * Configures C Editor typing preferences.
+ */
+class SmartTypingConfigurationBlock extends AbstractConfigurationBlock {
+
+       public SmartTypingConfigurationBlock(OverlayPreferenceStore store) {
+               super(store);
+               store.addKeys(createOverlayStoreKeys());
+       }
+       
+       private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
+               return new OverlayPreferenceStore.OverlayKey[] {
+                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_PASTE),
+                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_AUTO_INDENT),
+                       
+                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_STRINGS),
+                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_BRACKETS),
+                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_ANGULAR_BRACKETS),
+                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_BRACES),
+                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_STRINGS),
+                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ESCAPE_STRINGS),
+                       
+//                     new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_SEMICOLON),
+                       new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_TAB),
+//                     new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_OPENING_BRACE),
+               };
+       }       
+
+       /**
+        * Creates page for mark occurrences preferences.
+        * 
+        * @param parent the parent composite
+        * @return the control for the preference page
+        */
+       public Control createControl(Composite parent) {
+               ScrolledPageContent scrolled= new ScrolledPageContent(parent, SWT.H_SCROLL | SWT.V_SCROLL);
+               scrolled.setExpandHorizontal(true);
+               scrolled.setExpandVertical(true);
+               
+               Composite control= new Composite(scrolled, SWT.NONE);
+               GridLayout layout= new GridLayout();
+               control.setLayout(layout);
+
+               Composite composite;
+               
+               composite= createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_autoclose_title); 
+               addAutoclosingSection(composite);
+               
+//             composite= createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_automove_title); 
+//             addAutopositionSection(composite);
+               
+               composite= createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_tabs_title); 
+               addTabSection(composite);
+
+               composite= createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_pasting_title); 
+               addPasteSection(composite);
+               
+               composite= createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_strings_title); 
+               addStringsSection(composite);
+
+               composite= createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_autoindent_title); 
+               addAutoIndentSection(composite);
+
+               scrolled.setContent(control);
+               final Point size= control.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+               scrolled.setMinSize(size.x, size.y);
+               return scrolled;
+       }
+
+       private void addAutoIndentSection(Composite composite) {
+               GridLayout layout= new GridLayout();
+               composite.setLayout(layout);
+
+               String label;
+               label= PreferencesMessages.SmartTypingConfigurationBlock_autoindent_newlines;
+               addCheckBox(composite, label, PreferenceConstants.EDITOR_AUTO_INDENT, 0);
+       }
+
+       private void addStringsSection(Composite composite) {
+               GridLayout layout= new GridLayout();
+               composite.setLayout(layout);
+
+               String label;
+               Button master, slave;
+               label= PreferencesMessages.CEditorPreferencePage_wrapStrings; 
+               master= addCheckBox(composite, label, PreferenceConstants.EDITOR_WRAP_STRINGS, 0);
+               
+               label= PreferencesMessages.CEditorPreferencePage_escapeStrings; 
+               slave= addCheckBox(composite, label, PreferenceConstants.EDITOR_ESCAPE_STRINGS, 0);
+               createDependency(master, slave);
+       }
+
+       private void addPasteSection(Composite composite) {
+               GridLayout layout= new GridLayout();
+               composite.setLayout(layout);
+
+               String label;
+               label= PreferencesMessages.CEditorPreferencePage_smartPaste; 
+               addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_PASTE, 0);
+       }
+
+       private void addTabSection(Composite composite) {
+               GridLayout layout= new GridLayout();
+               composite.setLayout(layout);
+
+               String label;
+               label= PreferencesMessages.CEditorPreferencePage_typing_smartTab; 
+               addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_TAB, 0);
+               
+               createMessage(composite);
+       }
+
+//     private void addAutopositionSection(Composite composite) {
+//             GridLayout layout= new GridLayout();
+//             composite.setLayout(layout);
+//
+//             String label;
+//             
+//             label= PreferencesMessages.CEditorPreferencePage_typing_smartSemicolon; 
+//             addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_SEMICOLON, 0);
+//             
+//             label= PreferencesMessages.CEditorPreferencePage_typing_smartOpeningBrace; 
+//             addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_OPENING_BRACE, 0);
+//     }
+
+       private void addAutoclosingSection(Composite composite) {
+               GridLayout layout= new GridLayout();
+               layout.numColumns= 1;
+               composite.setLayout(layout);
+
+               String label;
+
+               label= PreferencesMessages.CEditorPreferencePage_closeStrings;
+               addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_STRINGS, 0);
+
+               label= PreferencesMessages.CEditorPreferencePage_closeBrackets; 
+               addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_BRACKETS, 0);
+
+               label= PreferencesMessages.CEditorPreferencePage_closeAngularBrackets; 
+               addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_ANGULAR_BRACKETS, 0);
+
+               label= PreferencesMessages.CEditorPreferencePage_closeBraces; 
+               addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_BRACES, 0);
+       }
+       
+       private void createMessage(final Composite composite) {
+               // TODO create a link with an argument, so the formatter preference page can open the 
+               // current profile automatically.
+               String linkTooltip= PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_tooltip; 
+               String text;
+               String indentMode= CUIPlugin.getDefault().getCombinedPreferenceStore().getString(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
+               if (CCorePlugin.TAB.equals(indentMode))
+                       text= Messages.format(PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_tab_text, Integer.toString(getTabDisplaySize()));
+               else
+                       text= Messages.format(PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_others_text, Integer.toString(getTabDisplaySize()), Integer.toString(getIndentSize()), getIndentMode()); 
+               
+               final Link link= new Link(composite, SWT.NONE);
+               link.setText(text);
+               link.setToolTipText(linkTooltip);
+               GridData gd= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
+               gd.widthHint= 300; // don't get wider initially
+               link.setLayoutData(gd);
+               link.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               PreferencesUtil.createPreferenceDialogOn(link.getShell(), "org.eclipse.cdt.ui.preferences.CodeFormatterPreferencePage", null, null); //$NON-NLS-1$
+                       }
+               });
+               
+               final IPreferenceStore combinedStore= CUIPlugin.getDefault().getCombinedPreferenceStore();
+               final IPropertyChangeListener propertyChangeListener= new IPropertyChangeListener() {
+                       private boolean fHasRun= false;
+                       public void propertyChange(PropertyChangeEvent event) {
+                               if (fHasRun)
+                                       return;
+                               if (composite.isDisposed())
+                                       return;
+                               String property= event.getProperty();
+                               if (DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR.equals(property)
+                                               || DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE.equals(property)) {
+                                       fHasRun= true;
+                                       link.dispose();
+                                       createMessage(composite);
+                                       Dialog.applyDialogFont(composite);
+                                       composite.redraw();
+                                       composite.layout();
+                               }
+                       }
+               };
+               combinedStore.addPropertyChangeListener(propertyChangeListener);
+               link.addDisposeListener(new DisposeListener() {
+                       public void widgetDisposed(org.eclipse.swt.events.DisposeEvent e) {
+                               combinedStore.removePropertyChangeListener(propertyChangeListener);
+                       }
+               });
+       }
+
+       private String getIndentMode() {
+               String indentMode= CUIPlugin.getDefault().getCombinedPreferenceStore().getString(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
+               
+               if (CCorePlugin.SPACE.equals(indentMode))
+                       return PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_spaces; 
+               
+               if (CCorePlugin.TAB.equals(indentMode))
+                       return PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_tabs;
+               
+               if (DefaultCodeFormatterConstants.MIXED.equals(indentMode))
+                       return PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_tabsAndSpaces;
+
+               Assert.isTrue(false, "Illegal indent mode - must not happen"); //$NON-NLS-1$
+               return null;
+       }
+
+       private int getIndentSize() {
+               return CodeFormatterUtil.getIndentWidth(null);
+       }
+       
+       private int getTabDisplaySize() {
+               return CodeFormatterUtil.getTabWidth(null);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SmartTypingPreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SmartTypingPreferencePage.java
new file mode 100644 (file)
index 0000000..ad3547c
--- /dev/null
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporatio - initial API and implementation
+ *     Sergey Prigogin, Google
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * The page for setting the editor options.
+ */
+public final class SmartTypingPreferencePage extends AbstractConfigurationBlockPreferencePage {
+       
+       /*
+        * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#getHelpId()
+        */
+       @Override
+       protected String getHelpId() {
+               return ICHelpContextIds.C_EDITOR_TYPING_PAGE;
+       }
+
+       /*
+        * @see org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setDescription()
+        */
+       @Override
+       protected void setDescription() {
+               String description= PreferencesMessages.CEditorPreferencePage_typing_tabTitle; 
+               setDescription(description);
+       }
+       
+       /*
+        * @see org.org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setPreferenceStore()
+        */
+       @Override
+       protected void setPreferenceStore() {
+               setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
+       }
+       
+       
+       @Override
+       protected Label createDescriptionLabel(Composite parent) {
+               return null; // no description for new look.
+       }
+       
+       /*
+        * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#createConfigurationBlock(org.eclipse.ui.internal.editors.text.OverlayPreferenceStore)
+        */
+       @Override
+       protected IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore) {
+               return new SmartTypingConfigurationBlock(overlayPreferenceStore);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SpellingConfigurationBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SpellingConfigurationBlock.java
new file mode 100644 (file)
index 0000000..fd59f90
--- /dev/null
@@ -0,0 +1,639 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *        Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Set;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.variables.IStringVariableManager;
+import org.eclipse.core.variables.VariablesPlugin;
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceStore;
+import org.eclipse.jface.window.Window;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.dialogs.EncodingFieldEditor;
+import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
+
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
+import org.eclipse.cdt.internal.ui.text.spelling.SpellCheckEngine;
+import org.eclipse.cdt.internal.ui.util.SWTUtil;
+import org.eclipse.cdt.internal.ui.wizards.indexwizards.StringVariableSelectionDialog;
+
+/**
+ * Options configuration block for spell check related settings.
+ */
+public class SpellingConfigurationBlock extends OptionsConfigurationBlock {
+       /**
+        * Tells whether content assist proposal block should be shown.
+        * Currently the spelling engine cannot return word proposals but
+        * only correction proposals and hence this is disabled.
+        */
+       private static final boolean SUPPORT_CONTENT_ASSIST_PROPOSALS= false;
+       
+       /** Preference keys for the preferences in this block */
+       private static final Key PREF_SPELLING_IGNORE_DIGITS= getCDTUIKey(PreferenceConstants.SPELLING_IGNORE_DIGITS);
+       private static final Key PREF_SPELLING_IGNORE_MIXED= getCDTUIKey(PreferenceConstants.SPELLING_IGNORE_MIXED);
+       private static final Key PREF_SPELLING_IGNORE_SENTENCE= getCDTUIKey(PreferenceConstants.SPELLING_IGNORE_SENTENCE);
+       private static final Key PREF_SPELLING_IGNORE_UPPER= getCDTUIKey(PreferenceConstants.SPELLING_IGNORE_UPPER);
+       private static final Key PREF_SPELLING_IGNORE_STRING_LITERALS= getCDTUIKey(PreferenceConstants.SPELLING_IGNORE_STRING_LITERALS);
+       private static final Key PREF_SPELLING_IGNORE_SINGLE_LETTERS= getCDTUIKey(PreferenceConstants.SPELLING_IGNORE_SINGLE_LETTERS);
+       private static final Key PREF_SPELLING_IGNORE_NON_LETTERS= getCDTUIKey(PreferenceConstants.SPELLING_IGNORE_NON_LETTERS);
+       private static final Key PREF_SPELLING_IGNORE_URLS= getCDTUIKey(PreferenceConstants.SPELLING_IGNORE_URLS);
+       private static final Key PREF_SPELLING_LOCALE= getCDTUIKey(PreferenceConstants.SPELLING_LOCALE);
+       private static final Key PREF_SPELLING_PROPOSAL_THRESHOLD= getCDTUIKey(PreferenceConstants.SPELLING_PROPOSAL_THRESHOLD);
+       private static final Key PREF_SPELLING_PROBLEMS_THRESHOLD= getCDTUIKey(PreferenceConstants.SPELLING_PROBLEMS_THRESHOLD);
+       private static final Key PREF_SPELLING_USER_DICTIONARY= getCDTUIKey(PreferenceConstants.SPELLING_USER_DICTIONARY);
+       private static final Key PREF_SPELLING_USER_DICTIONARY_ENCODING= getCDTUIKey(PreferenceConstants.SPELLING_USER_DICTIONARY_ENCODING);
+       private static final Key PREF_SPELLING_ENABLE_CONTENTASSIST= getCDTUIKey(PreferenceConstants.SPELLING_ENABLE_CONTENTASSIST);
+
+       /**
+        * The value for no platform dictionary.
+        */
+       private static final String PREF_VALUE_NO_LOCALE= ""; //$NON-NLS-1$
+
+       /**
+        * Creates a selection dependency between a master and a slave control.
+        * 
+        * @param master     The master button that controls the state of the slave
+        * @param slave      The slave control that is enabled only if the master is
+        *                   selected
+        */
+       protected static void createSelectionDependency(final Button master, final Control slave) {
+               master.addSelectionListener(new SelectionListener() {
+                       public void widgetDefaultSelected(SelectionEvent event) {
+                               // Do nothing
+                       }
+
+                       public void widgetSelected(SelectionEvent event) {
+                               slave.setEnabled(master.getSelection());
+                       }
+               });
+               slave.setEnabled(master.getSelection());
+       }
+
+       /**
+        * Returns the locale codes for the locale list.
+        * 
+        * @param locales
+        *                   The list of locales
+        * @return Array of locale codes for the list
+        */
+       protected static String[] getDictionaryCodes(final Set<Locale> locales) {
+               int index= 0;
+
+               final String[] codes= new String[locales.size() + 1];
+               for (Locale locale : locales) {
+                       codes[index++]= locale.toString();
+               }
+               codes[index++]= PREF_VALUE_NO_LOCALE;
+               return codes;
+       }
+
+       /**
+        * Returns the display labels for the locale list.
+        * 
+        * @param locales    The list of locales
+        * @return Array of display labels for the list
+        */
+       protected static String[] getDictionaryLabels(final Set<Locale> locales) {
+               int index= 0;
+
+               final String[] labels= new String[locales.size() + 1];
+               for (Locale locale : locales) {
+                       labels[index++]= locale.getDisplayName();
+               }
+               labels[index++]= PreferencesMessages.SpellingPreferencePage_dictionary_none;
+               return labels;
+       }
+
+       /**
+        * Validates that the file with the specified absolute path exists and can
+        * be opened.
+        * 
+        * @param path       The path of the file to validate
+        * @return a status without error if the path is valid
+        */
+       protected static IStatus validateAbsoluteFilePath(String path) {
+               final StatusInfo status= new StatusInfo();
+               IStringVariableManager variableManager= VariablesPlugin.getDefault().getStringVariableManager();
+               try {
+                       path= variableManager.performStringSubstitution(path);
+                       if (path.length() > 0) {
+                               
+                               final File file= new File(path);
+                               if (!file.exists() && (!file.isAbsolute() || !file.getParentFile().canWrite()))
+                                       status.setError(PreferencesMessages.SpellingPreferencePage_dictionary_error);
+                               else if (file.exists() && (!file.isFile() || !file.isAbsolute() || !file.canRead() || !file.canWrite()))
+                                       status.setError(PreferencesMessages.SpellingPreferencePage_dictionary_error);
+                       }
+               } catch (CoreException e) {
+                       status.setError(e.getLocalizedMessage());
+               }
+               return status;
+       }
+
+       /**
+        * Validates that the specified locale is available.
+        * 
+        * @param localeString the locale to validate
+        * @return The status of the validation
+        */
+       private static IStatus validateLocale(final String localeString) {
+               if (PREF_VALUE_NO_LOCALE.equals(localeString))
+                       return new StatusInfo(); 
+
+               Locale locale= SpellCheckEngine.convertToLocale(localeString);
+               
+               if (SpellCheckEngine.findClosestLocale(locale) != null)
+                       return new StatusInfo();
+               
+               return new StatusInfo(IStatus.ERROR, PreferencesMessages.SpellingPreferencePage_locale_error);
+       }
+       
+       /**
+        * Validates that the specified number is positive.
+        * 
+        * @param number the number to validate
+        * @return The status of the validation
+        */
+       protected static IStatus validatePositiveNumber(final String number) {
+               final StatusInfo status= new StatusInfo();
+               if (number.length() == 0) {
+                       status.setError(PreferencesMessages.SpellingPreferencePage_empty_threshold); 
+               } else {
+                       try {
+                               final int value= Integer.parseInt(number);
+                               if (value < 0) {
+                                       status.setError(NLS.bind(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number)); 
+                               }
+                       } catch (NumberFormatException exception) {
+                               status.setError(NLS.bind(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number)); 
+                       }
+               }
+               return status;
+       }
+
+       /** The dictionary path field */
+       private Text fDictionaryPath= null;
+
+       /** The status for the workspace dictionary file */
+       private IStatus fFileStatus= new StatusInfo();
+
+       /** The status for the proposal threshold */
+       private IStatus fThresholdStatus= new StatusInfo();
+       
+       /** The status for the encoding field editor */
+       private IStatus fEncodingFieldEditorStatus= new StatusInfo();
+       
+       /** The encoding field editor. */
+       private EncodingFieldEditor fEncodingEditor;    
+       /** The encoding field editor's parent. */
+       private Composite fEncodingEditorParent;        
+
+       /**
+        * All controls
+        */
+       private Control[] fAllControls;
+       
+       /**
+        * All previously enabled controls
+        */
+       private Control[] fEnabledControls;
+       
+       /**
+        * Creates a new spelling configuration block.
+        * 
+        * @param context the status change listener
+        * @param project the Java project
+        * @param container the preference container
+        */
+       public SpellingConfigurationBlock(final IStatusChangeListener context, final IProject project, IWorkbenchPreferenceContainer container) {
+               super(context, project, getAllKeys(), container);
+
+               IStatus status= validateAbsoluteFilePath(getValue(PREF_SPELLING_USER_DICTIONARY));
+               if (status.getSeverity() != IStatus.OK)
+                       setValue(PREF_SPELLING_USER_DICTIONARY, ""); //$NON-NLS-1$
+
+               status= validateLocale(getValue(PREF_SPELLING_LOCALE));
+               if (status.getSeverity() != IStatus.OK)
+                       setValue(PREF_SPELLING_LOCALE, SpellCheckEngine.getDefaultLocale().toString());
+       }
+
+       @Override
+       protected Combo addComboBox(Composite parent, String label, Key key, String[] values, String[] valueLabels, int indent) {
+               ControlData data= new ControlData(key, values);
+               
+               GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+               gd.horizontalIndent= indent;
+                               
+               Label labelControl= new Label(parent, SWT.LEFT | SWT.WRAP);
+               labelControl.setText(label);
+               labelControl.setLayoutData(gd);
+               
+               Combo comboBox= new Combo(parent, SWT.READ_ONLY);
+               comboBox.setItems(valueLabels);
+               comboBox.setData(data);
+               gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               gd.horizontalSpan= 2;
+               comboBox.setLayoutData(gd);
+               comboBox.addSelectionListener(getSelectionListener());
+               
+               fLabels.put(comboBox, labelControl);
+               
+               String currValue= getValue(key);
+               
+               Locale locale= SpellCheckEngine.convertToLocale(currValue);
+               locale= SpellCheckEngine.findClosestLocale(locale);
+               if (locale != null)
+                       currValue= locale.toString();
+               
+               comboBox.select(data.getSelection(currValue));
+               
+               fComboBoxes.add(comboBox);
+               return comboBox;
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock#createContents(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected Control createContents(final Composite parent) {
+               Composite composite= new Composite(parent, SWT.NONE);
+               composite.setLayout(new GridLayout());
+
+               List<Control> allControls= new ArrayList<Control>();
+               final PixelConverter converter= new PixelConverter(parent);
+
+               final String[] trueFalse= new String[] { IPreferenceStore.TRUE, IPreferenceStore.FALSE };
+
+               Group user= new Group(composite, SWT.NONE);
+               user.setText(PreferencesMessages.SpellingPreferencePage_group_user); 
+               user.setLayout(new GridLayout());               
+               user.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               allControls.add(user);
+
+               String label= PreferencesMessages.SpellingPreferencePage_ignore_digits_label; 
+               Control slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_DIGITS, trueFalse, 0);
+               allControls.add(slave);
+
+               label= PreferencesMessages.SpellingPreferencePage_ignore_mixed_label; 
+               slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_MIXED, trueFalse, 0);
+               allControls.add(slave);
+
+               label= PreferencesMessages.SpellingPreferencePage_ignore_sentence_label; 
+               slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_SENTENCE, trueFalse, 0);
+               allControls.add(slave);
+
+               label= PreferencesMessages.SpellingPreferencePage_ignore_upper_label; 
+               slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_UPPER, trueFalse, 0);
+               allControls.add(slave);
+
+               label= PreferencesMessages.SpellingPreferencePage_ignore_url_label; 
+               slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_URLS, trueFalse, 0);
+               allControls.add(slave);
+               
+               label= PreferencesMessages.SpellingPreferencePage_ignore_non_letters_label; 
+               slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_NON_LETTERS, trueFalse, 0);
+               allControls.add(slave);
+               
+               label= PreferencesMessages.SpellingPreferencePage_ignore_single_letters_label; 
+               slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_SINGLE_LETTERS, trueFalse, 0);
+               allControls.add(slave);
+               
+               label= PreferencesMessages.SpellingPreferencePage_ignore_string_literals_label; 
+               slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_STRING_LITERALS, trueFalse, 0);
+               allControls.add(slave);
+               
+               final Set<Locale> locales= SpellCheckEngine.getLocalesWithInstalledDictionaries();
+               boolean hasPlaformDictionaries= locales.size() > 0;
+               
+               final Group engine= new Group(composite, SWT.NONE);
+               if (hasPlaformDictionaries)
+                       engine.setText(PreferencesMessages.SpellingPreferencePage_group_dictionaries);
+               else
+                       engine.setText(PreferencesMessages.SpellingPreferencePage_group_dictionary);
+               engine.setLayout(new GridLayout(4, false));
+               engine.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               allControls.add(engine);
+
+               if (hasPlaformDictionaries) {
+                       label= PreferencesMessages.SpellingPreferencePage_dictionary_label; 
+                       Combo combo= addComboBox(engine, label, PREF_SPELLING_LOCALE, getDictionaryCodes(locales), getDictionaryLabels(locales), 0);
+                       combo.setEnabled(locales.size() > 0);
+                       allControls.add(combo);
+                       allControls.add(fLabels.get(combo));
+                       
+                       new Label(engine, SWT.NONE); // placeholder
+               }
+               
+               label= PreferencesMessages.SpellingPreferencePage_workspace_dictionary_label; 
+               fDictionaryPath= addTextField(engine, label, PREF_SPELLING_USER_DICTIONARY, 0, 0);
+               GridData gd= (GridData) fDictionaryPath.getLayoutData();
+               gd.grabExcessHorizontalSpace= true;
+               gd.widthHint= converter.convertWidthInCharsToPixels(40);
+               allControls.add(fDictionaryPath);
+               allControls.add(fLabels.get(fDictionaryPath));
+
+               Composite buttons=new Composite(engine, SWT.NONE);
+               buttons.setLayout(new GridLayout(2,true));
+               buttons.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
+               
+               Button button= new Button(buttons, SWT.PUSH);
+               button.setText(PreferencesMessages.SpellingPreferencePage_browse_label); 
+               button.addSelectionListener(new SelectionAdapter() {
+
+                       @Override
+                       public void widgetSelected(final SelectionEvent event) {
+                               handleBrowseButtonSelected();
+                       }
+               });
+               SWTUtil.setButtonDimensionHint(button);
+               button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+               allControls.add(button);
+               
+               button=new Button(buttons, SWT.PUSH);
+               button.setText(PreferencesMessages.SpellingPreferencePage_variables);
+               button.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               handleVariablesButtonSelected();
+                       }
+               });
+               SWTUtil.setButtonDimensionHint(button);
+               button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+               allControls.add(button);
+               
+               // Description for user dictionary
+               new Label(engine, SWT.NONE); // filler
+               Label description= new Label(engine, SWT.NONE);
+               gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               gd.horizontalSpan= 3;
+               description.setLayoutData(gd);
+               description.setText(PreferencesMessages.SpellingPreferencePage_user_dictionary_description);
+               allControls.add(description);
+               
+               createEncodingFieldEditor(engine, allControls);
+
+               Group advanced= new Group(composite, SWT.NONE);
+               advanced.setText(PreferencesMessages.SpellingPreferencePage_group_advanced); 
+               advanced.setLayout(new GridLayout(3, false));
+               advanced.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               allControls.add(advanced);
+
+               label= PreferencesMessages.SpellingPreferencePage_problems_threshold; 
+               int digits= 4;
+               Text  text= addTextField(advanced, label, PREF_SPELLING_PROBLEMS_THRESHOLD, 0, converter.convertWidthInCharsToPixels(digits+1));
+               text.setTextLimit(digits);
+               allControls.add(text);
+               allControls.add(fLabels.get(text));
+
+               label= PreferencesMessages.SpellingPreferencePage_proposals_threshold; 
+               digits= 3;
+               text= addTextField(advanced, label, PREF_SPELLING_PROPOSAL_THRESHOLD, 0, converter.convertWidthInCharsToPixels(digits+1));
+               text.setTextLimit(digits);
+               gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+               allControls.add(text);
+               allControls.add(fLabels.get(text));
+
+               if (SUPPORT_CONTENT_ASSIST_PROPOSALS) {
+                       label= PreferencesMessages.SpellingPreferencePage_enable_contentassist_label; 
+                       button= addCheckBox(advanced, label, PREF_SPELLING_ENABLE_CONTENTASSIST, trueFalse, 0);
+                       allControls.add(button);
+               }
+
+               fAllControls= allControls.toArray(new Control[allControls.size()]);
+               
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.SPELLING_CONFIGURATION_BLOCK);
+               return composite;
+       }
+
+       /**
+        * Creates the encoding field editor.
+        * 
+        * @param composite the parent composite
+        * @param allControls list with all controls
+        */
+       private void createEncodingFieldEditor(Composite composite, List<Control> allControls) {
+               Label filler= new Label(composite, SWT.NONE);
+               GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               gd.horizontalSpan= 4;
+               filler.setLayoutData(gd);
+               
+               Label label= new Label(composite, SWT.NONE);
+               label.setText(PreferencesMessages.SpellingPreferencePage_encoding_label);
+               label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+               allControls.add(label);
+               
+               fEncodingEditorParent= new Composite(composite, SWT.NONE);
+               GridLayout layout= new GridLayout(2, false);
+               layout.marginWidth= 0;
+               layout.marginHeight= 0;
+               fEncodingEditorParent.setLayout(layout);
+               gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               gd.horizontalSpan= 3;
+               fEncodingEditorParent.setLayoutData(gd);
+               
+               fEncodingEditor= new EncodingFieldEditor(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName(), "", null, fEncodingEditorParent); //$NON-NLS-1$
+               
+               PreferenceStore store= new PreferenceStore();
+               String defaultEncoding= ResourcesPlugin.getEncoding();
+               store.setDefault(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName(), defaultEncoding);
+               String encoding= getValue(PREF_SPELLING_USER_DICTIONARY_ENCODING);
+               if (encoding != null && encoding.length() > 0)
+                       store.setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName(), encoding);
+
+               fEncodingEditor.setPreferenceStore(store);
+
+               // Redirect status messages from the field editor to the status change listener  
+               DialogPage fakePage= new DialogPage() {
+                       public void createControl(Composite c) {
+                       }
+                       @Override
+                       public void setErrorMessage(String newMessage) {
+                               StatusInfo status= new StatusInfo();
+                               if (newMessage != null)
+                                       status.setError(newMessage);
+                               fEncodingFieldEditorStatus= status;
+                               fContext.statusChanged(StatusUtil.getMostSevere(new IStatus[] { fThresholdStatus, fFileStatus, fEncodingFieldEditorStatus }));
+                       }
+               };
+               fEncodingEditor.setPage(fakePage);
+               
+               fEncodingEditor.load();
+               
+               if (encoding == null || encoding.equals(defaultEncoding) || encoding.length() == 0)
+                       fEncodingEditor.loadDefault();
+       }
+
+       private static Key[] getAllKeys() {
+               if (SUPPORT_CONTENT_ASSIST_PROPOSALS)
+                       return new Key[] { PREF_SPELLING_USER_DICTIONARY, PREF_SPELLING_USER_DICTIONARY_ENCODING, PREF_SPELLING_IGNORE_DIGITS, PREF_SPELLING_IGNORE_MIXED, PREF_SPELLING_IGNORE_SENTENCE, PREF_SPELLING_IGNORE_UPPER, PREF_SPELLING_IGNORE_URLS, PREF_SPELLING_IGNORE_NON_LETTERS, PREF_SPELLING_IGNORE_SINGLE_LETTERS, PREF_SPELLING_LOCALE, PREF_SPELLING_PROPOSAL_THRESHOLD, PREF_SPELLING_PROBLEMS_THRESHOLD, PREF_SPELLING_ENABLE_CONTENTASSIST, PREF_SPELLING_IGNORE_STRING_LITERALS };
+               return new Key[] { PREF_SPELLING_USER_DICTIONARY, PREF_SPELLING_USER_DICTIONARY_ENCODING, PREF_SPELLING_IGNORE_DIGITS, PREF_SPELLING_IGNORE_MIXED, PREF_SPELLING_IGNORE_SENTENCE, PREF_SPELLING_IGNORE_UPPER, PREF_SPELLING_IGNORE_URLS, PREF_SPELLING_IGNORE_NON_LETTERS, PREF_SPELLING_IGNORE_SINGLE_LETTERS, PREF_SPELLING_LOCALE, PREF_SPELLING_PROPOSAL_THRESHOLD, PREF_SPELLING_PROBLEMS_THRESHOLD, PREF_SPELLING_IGNORE_STRING_LITERALS };
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock#getFullBuildDialogStrings(boolean)
+        */
+       protected final String[] getFullBuildDialogStrings(final boolean workspace) {
+               return null;
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock#performOk()
+        */
+       @Override
+       public boolean performOk() {
+               fEncodingEditor.store();
+               if (fEncodingEditor.presentsDefaultValue())
+                       setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING, ""); //$NON-NLS-1$
+               else
+                       setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING, fEncodingEditor.getPreferenceStore().getString(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName()));
+               return super.performOk();
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock#performApply()
+        */
+       @Override
+       public boolean performApply() {
+               fEncodingEditor.store();
+               if (fEncodingEditor.presentsDefaultValue())
+                       setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING, ""); //$NON-NLS-1$
+               else
+                       setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING, fEncodingEditor.getPreferenceStore().getString(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName()));
+               return super.performApply();
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock#performDefaults()
+        */
+       @Override
+       public void performDefaults() {
+               super.performDefaults();
+               
+               setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING, ""); //$NON-NLS-1$
+               
+               fEncodingEditor.getPreferenceStore().setValue(fEncodingEditor.getPreferenceName(), ResourcesPlugin.getEncoding());
+               fEncodingEditor.load();
+               
+               fEncodingEditor.loadDefault();
+       }
+
+       protected void handleVariablesButtonSelected() {
+               StringVariableSelectionDialog dialog= new StringVariableSelectionDialog(fDictionaryPath.getShell());
+               if (dialog.open() == Window.OK)
+                       fDictionaryPath.setText(fDictionaryPath.getText() + dialog.getVariableExpression());
+       }
+       
+       /**
+        * Handles selections of the browse button.
+        */
+       protected void handleBrowseButtonSelected() {
+               final FileDialog dialog= new FileDialog(fDictionaryPath.getShell(), SWT.OPEN);
+               dialog.setText(PreferencesMessages.SpellingPreferencePage_filedialog_title); 
+               dialog.setFilterPath(fDictionaryPath.getText());
+
+               final String path= dialog.open();
+               if (path != null)
+                       fDictionaryPath.setText(path);
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock#validateSettings(java.lang.String,java.lang.String)
+        */
+       @Override
+       protected void validateSettings(final Key key, final String oldValue, final String newValue) {
+               if (key == null || PREF_SPELLING_PROPOSAL_THRESHOLD.equals(key))
+                       fThresholdStatus= validatePositiveNumber(getValue(PREF_SPELLING_PROPOSAL_THRESHOLD));
+               else
+                       fThresholdStatus= new StatusInfo();
+               
+               if (key == null || PREF_SPELLING_PROBLEMS_THRESHOLD.equals(key)) {
+                       IStatus status= validatePositiveNumber(getValue(PREF_SPELLING_PROBLEMS_THRESHOLD)); 
+                       fThresholdStatus= StatusUtil.getMostSevere(new IStatus[] {fThresholdStatus, status});
+               }
+
+               if (key == null || PREF_SPELLING_USER_DICTIONARY.equals(key))
+                       fFileStatus= validateAbsoluteFilePath(getValue(PREF_SPELLING_USER_DICTIONARY));
+
+               fContext.statusChanged(StatusUtil.getMostSevere(new IStatus[] { fThresholdStatus, fFileStatus, fEncodingFieldEditorStatus }));
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock#updateCheckBox(org.eclipse.swt.widgets.Button)
+        */
+       @Override
+       protected void updateCheckBox(Button curr) {
+               super.updateCheckBox(curr);
+               Event event= new Event();
+               event.type= SWT.Selection;
+               event.display= curr.getDisplay();
+               event.widget= curr;
+               curr.notifyListeners(SWT.Selection, event);
+       }
+       
+       /**
+        * Sets the enabled state.
+        * 
+        * @param enabled the new state
+        */
+       protected void setEnabled(boolean enabled) {
+               fEncodingEditor.setEnabled(enabled, fEncodingEditorParent);
+               
+               if (enabled && fEnabledControls != null) {
+                       for (int i= fEnabledControls.length - 1; i >= 0; i--)
+                               fEnabledControls[i].setEnabled(true);
+                       fEnabledControls= null;
+               }
+               if (!enabled && fEnabledControls == null) {
+                       List<Control> enabledControls= new ArrayList<Control>();
+                       for (int i= fAllControls.length - 1; i >= 0; i--) {
+                               Control control= fAllControls[i];
+                               if (control.isEnabled()) {
+                                       enabledControls.add(control);
+                                       control.setEnabled(false);
+                               }
+                       }
+                       fEnabledControls= enabledControls.toArray(new Control[enabledControls.size()]);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SpellingPreferenceBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SpellingPreferenceBlock.java
new file mode 100644 (file)
index 0000000..e9b9655
--- /dev/null
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *        Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences;
+
+import org.eclipse.core.runtime.IStatus;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+import org.eclipse.ui.texteditor.spelling.IPreferenceStatusMonitor;
+import org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock;
+
+import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
+
+/**
+ * Spelling preference block
+ */
+public class SpellingPreferenceBlock implements ISpellingPreferenceBlock {
+       
+       private class NullStatusChangeListener implements IStatusChangeListener {
+               /*
+                * @see org.eclipse.cdt.internal.ui.wizards.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus)
+                */
+               public void statusChanged(IStatus status) {
+               }
+       }
+
+       private class StatusChangeListenerAdapter implements IStatusChangeListener {
+               private IPreferenceStatusMonitor fMonitor;
+               
+               private IStatus fStatus;
+               
+               public StatusChangeListenerAdapter(IPreferenceStatusMonitor monitor) {
+                       super();
+                       fMonitor= monitor;
+               }
+               
+               /*
+                * @see org.eclipse.cdt.internal.ui.wizards.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus)
+                */
+               public void statusChanged(IStatus status) {
+                       fStatus= status;
+                       fMonitor.statusChanged(status);
+               }
+               
+               public IStatus getStatus() {
+                       return fStatus;
+               }
+       }
+
+       private SpellingConfigurationBlock fBlock= new SpellingConfigurationBlock(new NullStatusChangeListener(), null, null);
+       
+       private SpellingPreferenceBlock.StatusChangeListenerAdapter fStatusMonitor;
+       
+       /*
+        * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#createControl(org.eclipse.swt.widgets.Composite)
+        */
+       public Control createControl(Composite parent) {
+               return fBlock.createContents(parent);
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#initialize(org.eclipse.ui.texteditor.spelling.IPreferenceStatusMonitor)
+        */
+       public void initialize(IPreferenceStatusMonitor statusMonitor) {
+               fStatusMonitor= new StatusChangeListenerAdapter(statusMonitor);
+               fBlock.fContext= fStatusMonitor;
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#canPerformOk()
+        */
+       public boolean canPerformOk() {
+               return fStatusMonitor == null || fStatusMonitor.getStatus() == null || !fStatusMonitor.getStatus().matches(IStatus.ERROR);
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#performOk()
+        */
+       public void performOk() {
+               fBlock.performOk();
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#performDefaults()
+        */
+       public void performDefaults() {
+               fBlock.performDefaults();
+       }
+       
+       /*
+        * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#performRevert()
+        */
+       public void performRevert() {
+               fBlock.performRevert();
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#dispose()
+        */
+       public void dispose() {
+               fBlock.dispose();
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.spelling.ISpellingPreferenceBlock#setEnabled(boolean)
+        */
+       public void setEnabled(boolean enabled) {
+               fBlock.setEnabled(enabled);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlock.java
new file mode 100644 (file)
index 0000000..c21e4a6
--- /dev/null
@@ -0,0 +1,362 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.IFontProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
+
+import org.eclipse.cdt.core.CCorePreferenceConstants;
+
+import org.eclipse.cdt.internal.corext.util.Messages;
+
+import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
+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.IListAdapter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
+
+/**
+ * UI for editing task tags.
+ */
+public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock {
+       private static final Key PREF_TODO_TASK_TAGS = getCDTCoreKey(CCorePreferenceConstants.TODO_TASK_TAGS);
+       private static final Key PREF_TODO_TASK_PRIORITIES = getCDTCoreKey(CCorePreferenceConstants.TODO_TASK_PRIORITIES);
+       
+       private static final Key PREF_TODO_TASK_CASE_SENSITIVE = getCDTCoreKey(CCorePreferenceConstants.TODO_TASK_CASE_SENSITIVE);      
+       
+       private static final String TASK_PRIORITY_HIGH = CCorePreferenceConstants.TASK_PRIORITY_HIGH;
+       private static final String TASK_PRIORITY_NORMAL = CCorePreferenceConstants.TASK_PRIORITY_NORMAL;
+       private static final String TASK_PRIORITY_LOW = CCorePreferenceConstants.TASK_PRIORITY_LOW;
+       
+       public static class TodoTask {
+               public String name;
+               public String priority;
+       }
+       
+       private class TodoTaskLabelProvider extends LabelProvider implements ITableLabelProvider, IFontProvider {
+
+               public TodoTaskLabelProvider() {
+               }
+               
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
+                */
+               @Override
+               public Image getImage(Object element) {
+                       return null; // JavaPluginImages.get(JavaPluginImages.IMG_OBJS_REFACTORING_INFO);
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
+                */
+               @Override
+               public String getText(Object element) {
+                       return getColumnText(element, 0);
+               }
+               
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
+                */
+               public Image getColumnImage(Object element, int columnIndex) {
+                       return null;
+               }
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
+                */
+               public String getColumnText(Object element, int columnIndex) {
+                       TodoTask task = (TodoTask) element;
+                       if (columnIndex == 0) {
+                               String name = task.name;
+                               if (isDefaultTask(task)) {
+                                       name = Messages.format(PreferencesMessages.TodoTaskConfigurationBlock_tasks_default, name); 
+                               }
+                               return name;
+                       }
+                       if (TASK_PRIORITY_HIGH.equals(task.priority)) {
+                               return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_high_priority; 
+                       } else if (TASK_PRIORITY_NORMAL.equals(task.priority)) {
+                               return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_normal_priority; 
+                       } else if (TASK_PRIORITY_LOW.equals(task.priority)) {
+                               return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_low_priority; 
+                       }
+                       return ""; //$NON-NLS-1$        
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
+                */
+               public Font getFont(Object element) {
+                       if (isDefaultTask((TodoTask) element)) {
+                               return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
+                       }
+                       return null;
+               }
+       }
+       
+       private static class TodoTaskSorter extends ViewerComparator {
+               @SuppressWarnings("unchecked")
+               @Override
+               public int compare(Viewer viewer, Object e1, Object e2) {
+                       return getComparator().compare(((TodoTask) e1).name, ((TodoTask) e2).name);
+               }
+       }
+       
+       private static final int IDX_ADD = 0;
+       private static final int IDX_EDIT = 1;
+       private static final int IDX_REMOVE = 2;
+       private static final int IDX_DEFAULT = 4;
+       
+       private IStatus fTaskTagsStatus;
+       private ListDialogField<TodoTask> fTodoTasksList;
+       private SelectionButtonDialogField fCaseSensitiveCheckBox;
+
+
+       public TodoTaskConfigurationBlock(IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container) {
+               super(context, project, getKeys(), container);
+                                               
+               TaskTagAdapter adapter = new TaskTagAdapter();
+               String[] buttons = new String[] {
+                       PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_add_button, 
+                       PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_edit_button, 
+                       PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_remove_button, 
+                       null,
+                       PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_setdefault_button, 
+               };
+               fTodoTasksList = new ListDialogField<TodoTask>(adapter, buttons, new TodoTaskLabelProvider());
+               fTodoTasksList.setDialogFieldListener(adapter);
+               fTodoTasksList.setRemoveButtonIndex(IDX_REMOVE);
+               
+               String[] columnsHeaders = new String[] {
+                       PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_name_column, 
+                       PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_priority_column, 
+               };
+               
+               fTodoTasksList.setTableColumns(new ListDialogField.ColumnsDescription(columnsHeaders, true));
+               fTodoTasksList.setViewerComparator(new TodoTaskSorter());
+               
+               fCaseSensitiveCheckBox = new SelectionButtonDialogField(SWT.CHECK);
+               fCaseSensitiveCheckBox.setLabelText(PreferencesMessages.TodoTaskConfigurationBlock_casesensitive_label); 
+               fCaseSensitiveCheckBox.setDialogFieldListener(adapter);
+               
+               unpackTodoTasks();
+               if (fTodoTasksList.getSize() > 0) {
+                       fTodoTasksList.selectFirstElement();
+               } else {
+                       fTodoTasksList.enableButton(IDX_EDIT, false);
+                       fTodoTasksList.enableButton(IDX_DEFAULT, false);
+               }
+               
+               fTaskTagsStatus = new StatusInfo();             
+       }
+       
+       public void setEnabled(boolean isEnabled) {
+               fTodoTasksList.setEnabled(isEnabled);
+               fCaseSensitiveCheckBox.setEnabled(isEnabled);
+       }
+       
+       final boolean isDefaultTask(TodoTask task) {
+               return fTodoTasksList.getIndexOfElement(task) == 0;
+       }
+       
+       private void setToDefaultTask(TodoTask task) {
+               List<TodoTask> elements = fTodoTasksList.getElements();
+               elements.remove(task);
+               elements.add(0, task);
+               fTodoTasksList.setElements(elements);
+               fTodoTasksList.enableButton(IDX_DEFAULT, false);
+       }
+       
+       private static Key[] getKeys() {
+               return new Key[] {
+                       PREF_TODO_TASK_TAGS, PREF_TODO_TASK_PRIORITIES, PREF_TODO_TASK_CASE_SENSITIVE
+               };      
+       }       
+       
+       public class TaskTagAdapter implements IListAdapter<TodoTask>, IDialogFieldListener {
+               private boolean canEdit(List<TodoTask> selectedElements) {
+                       return selectedElements.size() == 1;
+               }
+               
+               private boolean canSetToDefault(List<TodoTask> selectedElements) {
+                       return selectedElements.size() == 1 && !isDefaultTask(selectedElements.get(0));
+               }
+
+               public void customButtonPressed(ListDialogField<TodoTask> field, int index) {
+                       doTodoButtonPressed(index);
+               }
+
+               public void selectionChanged(ListDialogField<TodoTask> field) {
+                       List<TodoTask> selectedElements = field.getSelectedElements();
+                       field.enableButton(IDX_EDIT, canEdit(selectedElements));
+                       field.enableButton(IDX_DEFAULT, canSetToDefault(selectedElements));
+               }
+                       
+               public void doubleClicked(ListDialogField<TodoTask> field) {
+                       if (canEdit(field.getSelectedElements())) {
+                               doTodoButtonPressed(IDX_EDIT);
+                       }
+               }
+
+               public void dialogFieldChanged(DialogField field) {
+                       updateModel(field);
+               }                       
+       }
+               
+       @Override
+       protected Control createContents(Composite parent) {
+               setShell(parent.getShell());
+               
+               Composite markersComposite = createMarkersTabContent(parent);
+               
+               validateSettings(null, null, null);
+       
+               return markersComposite;
+       }
+
+       private Composite createMarkersTabContent(Composite folder) {
+               GridLayout layout = new GridLayout();
+               layout.marginHeight = 0;
+               layout.marginWidth = 0;
+               layout.numColumns = 2;
+               
+               PixelConverter conv = new PixelConverter(folder);
+               
+               Composite markersComposite = new Composite(folder, SWT.NULL);
+               markersComposite.setLayout(layout);
+               markersComposite.setFont(folder.getFont());
+               
+               GridData data = new GridData(GridData.FILL_BOTH);
+               data.widthHint = conv.convertWidthInCharsToPixels(50);
+               Control listControl = fTodoTasksList.getListControl(markersComposite);
+               listControl.setLayoutData(data);
+
+               Control buttonsControl = fTodoTasksList.getButtonBox(markersComposite);
+               buttonsControl.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING));
+               
+               fCaseSensitiveCheckBox.doFillIntoGrid(markersComposite, 2);
+
+               return markersComposite;
+       }
+
+       @Override
+       protected void validateSettings(Key changedKey, String oldValue, String newValue) {
+               if (!areSettingsEnabled()) {
+                       return;
+               }
+               
+               if (changedKey != null) {
+                       if (PREF_TODO_TASK_TAGS.equals(changedKey)) {
+                               fTaskTagsStatus = validateTaskTags();
+                       } else {
+                               return;
+                       }
+               } else {
+                       fTaskTagsStatus = validateTaskTags();
+               }               
+               IStatus status = fTaskTagsStatus; //StatusUtil.getMostSevere(new IStatus[] { fTaskTagsStatus });
+               fContext.statusChanged(status);
+       }
+       
+       private IStatus validateTaskTags() {
+               return new StatusInfo();
+       }
+       
+       protected final void updateModel(DialogField field) {
+               if (field == fTodoTasksList) {
+                       StringBuffer tags = new StringBuffer();
+                       StringBuffer prios = new StringBuffer();
+                       List<TodoTask> list = fTodoTasksList.getElements();
+                       for (int i = 0; i < list.size(); i++) {
+                               if (i > 0) {
+                                       tags.append(',');
+                                       prios.append(',');
+                               }
+                               TodoTask elem = list.get(i);
+                               tags.append(elem.name);
+                               prios.append(elem.priority);
+                       }
+                       setValue(PREF_TODO_TASK_TAGS, tags.toString());
+                       setValue(PREF_TODO_TASK_PRIORITIES, prios.toString());
+                       validateSettings(PREF_TODO_TASK_TAGS, null, null);
+               } else if (field == fCaseSensitiveCheckBox) {
+                       String state = String.valueOf(fCaseSensitiveCheckBox.isSelected());
+                       setValue(PREF_TODO_TASK_CASE_SENSITIVE, state);
+               }
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.preferences.OptionsConfigurationBlock#updateControls()
+        */
+       @Override
+       protected void updateControls() {
+               unpackTodoTasks();
+       }
+       
+       private void unpackTodoTasks() {
+               String currTags = getValue(PREF_TODO_TASK_TAGS);        
+               String currPrios = getValue(PREF_TODO_TASK_PRIORITIES);
+               String[] tags = getTokens(currTags, ","); //$NON-NLS-1$
+               String[] prios = getTokens(currPrios, ","); //$NON-NLS-1$
+               ArrayList<TodoTask> elements = new ArrayList<TodoTask>(tags.length);
+               for (int i = 0; i < tags.length; i++) {
+                       TodoTask task = new TodoTask();
+                       task.name = tags[i].trim();
+                       task.priority = (i < prios.length) ? prios[i] : TASK_PRIORITY_NORMAL;
+                       elements.add(task);
+               }
+               fTodoTasksList.setElements(elements);
+               
+               boolean isCaseSensitive = getBooleanValue(PREF_TODO_TASK_CASE_SENSITIVE);
+               fCaseSensitiveCheckBox.setSelection(isCaseSensitive);
+       }
+       
+       private void doTodoButtonPressed(int index) {
+               TodoTask edited = null;
+               if (index != IDX_ADD) {
+                       edited = fTodoTasksList.getSelectedElements().get(0);
+               }
+               if (index == IDX_ADD || index == IDX_EDIT) {
+                       TodoTaskInputDialog dialog = new TodoTaskInputDialog(getShell(), edited, fTodoTasksList.getElements());
+                       if (dialog.open() == Window.OK) {
+                               if (edited != null) {
+                                       fTodoTasksList.replaceElement(edited, dialog.getResult());
+                               } else {
+                                       fTodoTasksList.addElement(dialog.getResult());
+                               }
+                       }
+               } else if (index == IDX_DEFAULT) {
+                       setToDefaultTask(edited);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskInputDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskInputDialog.java
new file mode 100644 (file)
index 0000000..18722bf
--- /dev/null
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.StatusDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.core.CCorePreferenceConstants;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.preferences.TodoTaskConfigurationBlock.TodoTask;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.ComboDialogField;
+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;
+
+/**
+ * Dialog to enter a new task tag.
+ */
+public class TodoTaskInputDialog extends StatusDialog {
+       
+       private class CompilerTodoTaskInputAdapter implements IDialogFieldListener {
+               public void dialogFieldChanged(DialogField field) {
+                       doValidation();
+               }                       
+       }
+       
+       private StringDialogField fNameDialogField;
+       private ComboDialogField fPriorityDialogField;
+       
+       private List<String> fExistingNames;
+               
+       public TodoTaskInputDialog(Shell parent, TodoTask task, List<TodoTask> existingEntries) {
+               super(parent);
+               
+               fExistingNames = new ArrayList<String>(existingEntries.size());
+               for (int i = 0; i < existingEntries.size(); i++) {
+                       TodoTask curr = existingEntries.get(i);
+                       if (!curr.equals(task)) {
+                               fExistingNames.add(curr.name);
+                       }
+               }
+               
+               if (task == null) {
+                       setTitle(PreferencesMessages.TodoTaskInputDialog_new_title); 
+               } else {
+                       setTitle(PreferencesMessages.TodoTaskInputDialog_edit_title); 
+               }
+
+               CompilerTodoTaskInputAdapter adapter = new CompilerTodoTaskInputAdapter();
+
+               fNameDialogField = new StringDialogField();
+               fNameDialogField.setLabelText(PreferencesMessages.TodoTaskInputDialog_name_label); 
+               fNameDialogField.setDialogFieldListener(adapter);
+               
+               fNameDialogField.setText((task != null) ? task.name : ""); //$NON-NLS-1$
+               
+               String[] items = new String[] {
+                       PreferencesMessages.TodoTaskInputDialog_priority_high, 
+                       PreferencesMessages.TodoTaskInputDialog_priority_normal, 
+                       PreferencesMessages.TodoTaskInputDialog_priority_low
+               };
+               
+               fPriorityDialogField = new ComboDialogField(SWT.READ_ONLY);
+               fPriorityDialogField.setLabelText(PreferencesMessages.TodoTaskInputDialog_priority_label); 
+               fPriorityDialogField.setItems(items);
+               if (task != null) {
+                       if (CCorePreferenceConstants.TASK_PRIORITY_HIGH.equals(task.priority)) {
+                               fPriorityDialogField.selectItem(0);
+                       } else if (CCorePreferenceConstants.TASK_PRIORITY_NORMAL.equals(task.priority)) {
+                               fPriorityDialogField.selectItem(1);
+                       } else {
+                               fPriorityDialogField.selectItem(2);
+                       }
+               } else {
+                       fPriorityDialogField.selectItem(1);
+               }
+       }
+       
+       public TodoTask getResult() {
+               TodoTask task = new TodoTask();
+               task.name = fNameDialogField.getText().trim();
+               switch (fPriorityDialogField.getSelectionIndex()) {
+               case 0:
+                       task.priority = CCorePreferenceConstants.TASK_PRIORITY_HIGH;
+                       break;
+               case 1:
+                       task.priority = CCorePreferenceConstants.TASK_PRIORITY_NORMAL;
+                       break;
+               default:
+                       task.priority = CCorePreferenceConstants.TASK_PRIORITY_LOW;
+                       break;                          
+               }
+               return task;
+       }
+       
+       @Override
+       protected Control createDialogArea(Composite parent) {
+               Composite composite = (Composite) super.createDialogArea(parent);
+               
+               Composite inner = new Composite(composite, SWT.NONE);
+               GridLayout layout = new GridLayout();
+               layout.marginHeight = 0;
+               layout.marginWidth = 0;
+               layout.numColumns = 2;
+               inner.setLayout(layout);
+               
+               fNameDialogField.doFillIntoGrid(inner, 2);
+               fPriorityDialogField.doFillIntoGrid(inner, 2);
+               
+               LayoutUtil.setHorizontalGrabbing(fNameDialogField.getTextControl(null), true);
+               LayoutUtil.setWidthHint(fNameDialogField.getTextControl(null), convertWidthInCharsToPixels(45));
+               
+               fNameDialogField.postSetFocusOnDialogField(parent.getDisplay());
+               
+               applyDialogFont(composite);             
+               
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.TODO_TASK_INPUT_DIALOG);
+               
+               return composite;
+       }
+               
+       private void doValidation() {
+               StatusInfo status = new StatusInfo();
+               String newText = fNameDialogField.getText();
+               if (newText.length() == 0) {
+                       status.setError(PreferencesMessages.TodoTaskInputDialog_error_enterName); 
+               } else {
+                       if (newText.indexOf(',') != -1) {
+                               status.setError(PreferencesMessages.TodoTaskInputDialog_error_comma); 
+                       } else if (fExistingNames.contains(newText)) {
+                               status.setError(PreferencesMessages.TodoTaskInputDialog_error_entryExists); 
+                       } else if (Character.isWhitespace(newText.charAt(0)) ||  Character.isWhitespace(newText.charAt(newText.length() - 1))) {
+                               status.setError(PreferencesMessages.TodoTaskInputDialog_error_noSpace); 
+                       }
+               }
+               updateStatus(status);
+       }
+
+       /*
+        * @see org.eclipse.jface.window.Window#configureShell(Shell)
+        */
+       @Override
+       protected void configureShell(Shell newShell) {
+               super.configureShell(newShell);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, ICHelpContextIds.TODO_TASK_INPUT_DIALOG);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskPreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskPreferencePage.java
new file mode 100644 (file)
index 0000000..5e531ed
--- /dev/null
@@ -0,0 +1,160 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences;
+
+import org.eclipse.core.runtime.IAdaptable;
+
+import org.eclipse.core.resources.IProject;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/*
+ * The page to configure the task tags
+ */
+public class TodoTaskPreferencePage extends PropertyAndPreferencePage {
+
+       public static final String PREF_ID = "org.eclipse.cdt.ui.preferences.TodoTaskPreferencePage"; //$NON-NLS-1$
+       public static final String PROP_ID = "org.eclipse.cdt.ui.propertyPages.TodoTaskPreferencePage"; //$NON-NLS-1$
+       
+       private TodoTaskConfigurationBlock fConfigurationBlock;
+
+       public TodoTaskPreferencePage() {
+               setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
+               setDescription(PreferencesMessages.TodoTaskPreferencePage_description); 
+               
+               // only used when page is shown programatically
+               setTitle(PreferencesMessages.TodoTaskPreferencePage_title); 
+       }
+                       
+       /*
+        * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       public void createControl(Composite parent) {
+               IWorkbenchPreferenceContainer container = (IWorkbenchPreferenceContainer) getContainer();
+               fConfigurationBlock = new TodoTaskConfigurationBlock(getNewStatusChangedListener(), getProject(), container);
+               
+               super.createControl(parent);
+               
+               if (isProjectPreferencePage()) {
+                       PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.TODO_TASK_PROPERTY_PAGE);
+               } else {
+                       PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.TODO_TASK_PREFERENCE_PAGE);
+               }
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#createPreferenceContent(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected Control createPreferenceContent(Composite composite) {
+               return fConfigurationBlock.createContents(composite);
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#hasProjectSpecificOptions(org.eclipse.core.resources.IProject)
+        */
+       @Override
+       protected boolean hasProjectSpecificOptions(IProject project) {
+               return fConfigurationBlock.hasProjectSpecificOptions(project);
+       }
+       
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
+        */
+       @Override
+       protected String getPreferencePageID() {
+               return PREF_ID;
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
+        */
+       @Override
+       protected String getPropertyPageID() {
+       //  TODO: Project specific settings are not supported yet.
+//             return PROP_ID;
+               return null;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#enableProjectSpecificSettings(boolean)
+        */
+       @Override
+       protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
+               super.enableProjectSpecificSettings(useProjectSpecificSettings);
+               if (fConfigurationBlock != null) {
+                       fConfigurationBlock.useProjectSpecificSettings(useProjectSpecificSettings);
+               }
+       }       
+                       
+       /*
+        * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
+        */
+       @Override
+       protected void performDefaults() {
+               super.performDefaults();
+               if (fConfigurationBlock != null) {
+                       fConfigurationBlock.performDefaults();
+               }
+       }
+
+       /*
+        * @see org.eclipse.jface.preference.IPreferencePage#performOk()
+        */
+       @Override
+       public boolean performOk() {
+               if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) {
+                       return false;
+               }       
+               return super.performOk();
+       }
+       
+       /*
+        * @see org.eclipse.jface.preference.IPreferencePage#performApply()
+        */
+       @Override
+       public void performApply() {
+               if (fConfigurationBlock != null) {
+                       fConfigurationBlock.performApply();
+               }
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.DialogPage#dispose()
+        */
+       @Override
+       public void dispose() {
+               if (fConfigurationBlock != null) {
+                       fConfigurationBlock.dispose();
+               }
+               super.dispose();
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#setElement(org.eclipse.core.runtime.IAdaptable)
+        */
+       @Override
+       public void setElement(IAdaptable element) {
+               super.setElement(element);
+               setDescription(null); // no description for property page
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/WorkInProgressPreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/WorkInProgressPreferencePage.java
new file mode 100644 (file)
index 0000000..18ec578
--- /dev/null
@@ -0,0 +1,170 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * Preference page for work in progress.
+ */
+public class WorkInProgressPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+
+       private List<Button> fCheckBoxes;
+       private List<Button> fRadioButtons;
+       private List<Text> fTextControls;
+       
+       /**
+        * creates a new preference page.
+        */
+       public WorkInProgressPreferencePage() {
+               setPreferenceStore(getPreferenceStore());
+               fRadioButtons= new ArrayList<Button>();
+               fCheckBoxes= new ArrayList<Button>();
+               fTextControls= new ArrayList<Text>();
+       }
+
+       Button addCheckBox(Composite parent, String label, String key) { 
+               GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               
+               Button button= new Button(parent, SWT.CHECK);
+               button.setText(label);
+               button.setData(key);
+               button.setLayoutData(gd);
+
+               button.setSelection(getPreferenceStore().getBoolean(key));
+               
+               fCheckBoxes.add(button);
+               return button;
+       }
+       
+       /*
+        * @see PreferencePage#createControl(Composite)
+        */
+       @Override
+       public void createControl(Composite parent) {
+               super.createControl(parent);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), "WORK_IN_PROGRESS_PREFERENCE_PAGE"); //$NON-NLS-1$
+       }
+
+       @Override
+       protected Control createContents(Composite parent) {
+               initializeDialogUnits(parent);
+               
+               Composite result= new Composite(parent, SWT.NONE);
+               GridLayout layout= new GridLayout();
+               layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+               layout.marginWidth= 0;
+               layout.verticalSpacing= convertVerticalDLUsToPixels(10);
+               layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+               result.setLayout(layout);
+
+               // Add your controls here
+               
+               applyDialogFont(result);
+               return result;
+       }
+       
+       /*
+        * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+        */
+       public void init(IWorkbench workbench) {
+       }
+
+       protected void createSpacer(Composite composite, int columnSpan) {
+               Label label= new Label(composite, SWT.NONE);
+               GridData gd= new GridData();
+               gd.horizontalSpan= columnSpan;
+               label.setLayoutData(gd);
+       }
+
+       /*
+        * @see org.eclipse.jface.preference.PreferencePage#doGetPreferenceStore()
+        */
+       @Override
+       protected IPreferenceStore doGetPreferenceStore() {
+               return CUIPlugin.getDefault().getPreferenceStore();
+       }
+
+       /*
+        * @see PreferencePage#performDefaults()
+        */
+       @Override
+       protected void performDefaults() {
+               IPreferenceStore store= getPreferenceStore();
+               for (int i= 0; i < fCheckBoxes.size(); i++) {
+                       Button button= fCheckBoxes.get(i);
+                       String key= (String) button.getData();
+                       button.setSelection(store.getDefaultBoolean(key));
+               }
+               for (int i= 0; i < fRadioButtons.size(); i++) {
+                       Button button= fRadioButtons.get(i);
+                       String[] info= (String[]) button.getData();
+                       button.setSelection(info[1].equals(store.getDefaultString(info[0])));
+               }
+               for (int i= 0; i < fTextControls.size(); i++) {
+                       Text text= fTextControls.get(i);
+                       String key= (String) text.getData();
+                       text.setText(store.getDefaultString(key));
+               }
+               
+               super.performDefaults();
+       }
+
+       /*
+        * @see IPreferencePage#performOk()
+        */
+       @Override
+       public boolean performOk() {
+               IPreferenceStore store= getPreferenceStore();
+               for (int i= 0; i < fCheckBoxes.size(); i++) {
+                       Button button= fCheckBoxes.get(i);
+                       String key= (String) button.getData();
+                       store.setValue(key, button.getSelection());
+               }
+               for (int i= 0; i < fRadioButtons.size(); i++) {
+                       Button button= fRadioButtons.get(i);
+                       if (button.getSelection()) {
+                               String[] info= (String[]) button.getData();
+                               store.setValue(info[0], info[1]);
+                       }
+               }
+               for (int i= 0; i < fTextControls.size(); i++) {
+                       Text text= fTextControls.get(i);
+                       String key= (String) text.getData();
+                       store.setValue(key, text.getText());
+               }
+               return super.performOk();
+       }
+
+       public static void initDefaults(IPreferenceStore store) {
+               // Initialize your defaults here
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/AlreadyExistsDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/AlreadyExistsDialog.java
new file mode 100644 (file)
index 0000000..a570967
--- /dev/null
@@ -0,0 +1,197 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin, Google
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences.formatter;
+
+import org.eclipse.core.runtime.IStatus;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.StatusDialog;
+
+import org.eclipse.cdt.internal.ui.util.Messages;
+
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
+
+/**
+ * The dialog to rename an imported profile. 
+ */
+public class AlreadyExistsDialog extends StatusDialog {
+       
+       private Composite fComposite;
+       protected Text fNameText;
+       private Button fRenameRadio, fOverwriteRadio;
+       
+       private final int NUM_COLUMNS= 2;
+       
+       private final StatusInfo fOk;
+       private final StatusInfo fEmpty;
+       private final StatusInfo fDuplicate;
+       
+       private final CustomProfile fProfile;
+       private final ProfileManager fProfileManager;
+       
+       public AlreadyExistsDialog(Shell parentShell, CustomProfile profile, ProfileManager profileManager) {
+               super(parentShell);
+               fProfile= profile;
+               fProfileManager= profileManager;
+               fOk= new StatusInfo();
+               fDuplicate= new StatusInfo(IStatus.ERROR, FormatterMessages.AlreadyExistsDialog_message_profile_already_exists); 
+               fEmpty= new StatusInfo(IStatus.ERROR, FormatterMessages.AlreadyExistsDialog_message_profile_name_empty); 
+       }
+       
+       
+       @Override
+       public void create() {
+               super.create();
+               setTitle(FormatterMessages.AlreadyExistsDialog_dialog_title); 
+       }
+       
+       @Override
+       public Control createDialogArea(Composite parent) {
+                               
+               initializeComposite(parent);
+               
+               createLabel(Messages.format(FormatterMessages.AlreadyExistsDialog_dialog_label, fProfile.getName())); 
+
+               fRenameRadio= createRadioButton(FormatterMessages.AlreadyExistsDialog_rename_radio_button_desc); 
+               fNameText= createTextField();
+
+               fOverwriteRadio= createRadioButton(FormatterMessages.AlreadyExistsDialog_overwrite_radio_button_desc); 
+
+               fRenameRadio.setSelection(true);
+               
+               fNameText.setText(fProfile.getName());
+               fNameText.setSelection(0, fProfile.getName().length());
+               fNameText.setFocus();
+               
+               fNameText.addModifyListener( new ModifyListener() {
+                       public void modifyText(ModifyEvent e) {
+                               doValidation();
+                       }
+               });
+               
+               fRenameRadio.addSelectionListener(new SelectionListener() {
+                       public void widgetSelected(SelectionEvent e) {
+                               fNameText.setEnabled(true);
+                               fNameText.setFocus();
+                               fNameText.setSelection(0, fNameText.getText().length());
+                               doValidation();
+                       }
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                       }
+               });
+               
+               fOverwriteRadio.addSelectionListener(new SelectionListener() {
+                       public void widgetSelected(SelectionEvent e) {
+                               fNameText.setEnabled(false);
+                               doValidation();
+                       }
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                       }
+               });
+               
+               updateStatus(fDuplicate);
+               
+               applyDialogFont(fComposite);
+               
+               return fComposite;
+       }
+       
+       private void initializeComposite(Composite parent) {
+               fComposite= new Composite(parent, SWT.NULL);
+               
+               final GridLayout layout= new GridLayout();
+               layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+               layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+               layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
+               layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+               layout.numColumns= NUM_COLUMNS;
+               
+               fComposite.setLayout(layout);
+       }
+       
+       private Label createLabel(String text) {
+               final GridData gd= new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan= NUM_COLUMNS;
+               gd.widthHint= convertWidthInCharsToPixels(60);
+               final Label label= new Label(fComposite, SWT.WRAP);
+               label.setText(text);
+               label.setLayoutData(gd);
+               return label;
+       }
+       
+       private Button createRadioButton(String text) {
+               final GridData gd = new GridData();
+               gd.horizontalSpan = NUM_COLUMNS;
+               gd.widthHint= convertWidthInCharsToPixels(60);
+               final Button radio= new Button(fComposite, SWT.RADIO);
+               radio.setLayoutData(gd);
+               radio.setText(text);
+               return radio;
+       }
+       
+       private Text createTextField() {
+               final GridData gd = new GridData( GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan= NUM_COLUMNS;
+               final Text text= new Text(fComposite, SWT.SINGLE | SWT.BORDER);
+               text.setLayoutData(gd);
+               return text;
+       }
+
+       /**
+        * Validate the current settings
+        */
+       protected void doValidation() {
+
+               if (fOverwriteRadio.getSelection()) {
+                       updateStatus(fOk);
+                       return;
+               }
+
+               final String name= fNameText.getText().trim();
+               
+               if (name.length() == 0) {
+                       updateStatus(fEmpty);
+                       return;
+               }
+               
+               if (fProfileManager.containsName(name)) {
+                       updateStatus(fDuplicate);
+                       return;
+               }
+               
+               updateStatus(fOk);
+       }
+       
+       @Override
+       protected void okPressed() {
+               if (!getStatus().isOK()) 
+                       return;
+               if (fRenameRadio.getSelection())
+                       fProfile.rename(fNameText.getText().trim(), fProfileManager);
+               super.okPressed();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/BracesTabPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/BracesTabPage.java
new file mode 100644 (file)
index 0000000..e207f26
--- /dev/null
@@ -0,0 +1,175 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences.formatter;
+import java.util.Map;
+import java.util.Observable;
+import java.util.Observer;
+
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
+
+public class BracesTabPage extends FormatterTabPage {
+       
+       /**
+        * Some C++ source code used for preview.
+        */
+       private final static String PREVIEW=
+               createPreviewHeader(FormatterMessages.BracesTabPage_preview_header) + 
+               "#include <math.h>\n\n" + //$NON-NLS-1$
+               "int digits[]= { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };" + //$NON-NLS-1$
+               "\n\n" +  //$NON-NLS-1$
+               "class Point {" +  //$NON-NLS-1$
+               "public:" +  //$NON-NLS-1$
+               "Point(double x, double y) : x(x), y(y) {}" + //$NON-NLS-1$ 
+               "double distance(const Point& other) const;" + //$NON-NLS-1$
+               "int compareX(const Point& other) const;" + //$NON-NLS-1$
+               "double x;" +  //$NON-NLS-1$
+               "double y;" +  //$NON-NLS-1$
+               "};" +  //$NON-NLS-1$
+               "\n\n" + //$NON-NLS-1$
+               "double Point::distance(const Point& other) const {" + //$NON-NLS-1$
+               "double dx = x - other.x;" + //$NON-NLS-1$
+               "double dy = y - other.y;" + //$NON-NLS-1$
+               "return sqrt(dx * dx + dy * dy);" + //$NON-NLS-1$
+               "}"+ //$NON-NLS-1$
+               "\n\n" +  //$NON-NLS-1$
+               "int Point::compareX(const Point& other) const {" + //$NON-NLS-1$
+               "if(x < other.x) {" + //$NON-NLS-1$
+               "return -1;" + //$NON-NLS-1$
+               "} else if(x > other.x){" + //$NON-NLS-1$
+               "return 1;" + //$NON-NLS-1$
+               "} else {" + //$NON-NLS-1$
+               "return 0;" + //$NON-NLS-1$
+               "}"+ //$NON-NLS-1$
+               "}"+ //$NON-NLS-1$
+               "\n\n" +  //$NON-NLS-1$
+               "namespace FOO {"+ //$NON-NLS-1$
+               "int foo(int bar) const {" + //$NON-NLS-1$
+               "switch(bar) {" + //$NON-NLS-1$
+               "case 0:" + //$NON-NLS-1$
+               "++bar;" + //$NON-NLS-1$
+               "break;" + //$NON-NLS-1$
+               "case 1:" + //$NON-NLS-1$
+               "--bar;" + //$NON-NLS-1$
+               "default: {" + //$NON-NLS-1$
+               "bar += bar;" + //$NON-NLS-1$
+               "break;" + //$NON-NLS-1$
+               "}"+ //$NON-NLS-1$
+               "}"+ //$NON-NLS-1$
+               "}"+ //$NON-NLS-1$
+               "} // end namespace FOO"; //$NON-NLS-1$
+
+       private TranslationUnitPreview fPreview;
+       
+       private final String[] fBracePositions= {
+           DefaultCodeFormatterConstants.END_OF_LINE,
+           DefaultCodeFormatterConstants.NEXT_LINE,
+           DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED
+       };
+       
+       private final String[] fExtendedBracePositions= {
+               DefaultCodeFormatterConstants.END_OF_LINE,
+           DefaultCodeFormatterConstants.NEXT_LINE,
+           DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED, 
+               DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP
+       };
+       
+       private final String[] fBracePositionNames= {
+           FormatterMessages.BracesTabPage_position_same_line, 
+           FormatterMessages.BracesTabPage_position_next_line, 
+           FormatterMessages.BracesTabPage_position_next_line_indented
+       };
+       
+       private final String[] fExtendedBracePositionNames= {
+           FormatterMessages.BracesTabPage_position_same_line, 
+           FormatterMessages.BracesTabPage_position_next_line, 
+           FormatterMessages.BracesTabPage_position_next_line_indented, 
+               FormatterMessages.BracesTabPage_position_next_line_on_wrap
+       };
+       
+       /**
+        * Create a new BracesTabPage.
+        * @param modifyDialog
+        * @param workingValues
+        */
+       public BracesTabPage(ModifyDialog modifyDialog, Map<String, String> workingValues) {
+               super(modifyDialog, workingValues);
+       }
+       
+       @Override
+       protected void doCreatePreferences(Composite composite, int numColumns) {
+               final Group group= createGroup(numColumns, composite, FormatterMessages.BracesTabPage_group_brace_positions_title); 
+               createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_class_declaration, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION); 
+               createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_namespace_declaration, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_NAMESPACE_DECLARATION); 
+//             createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_constructor_declaration, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION); 
+               createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_function_declaration, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION); 
+//             createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_enum_declaration, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ENUM_DECLARATION); 
+//             createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_enumconst_declaration, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ENUM_CONSTANT); 
+//             createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_annotation_type_declaration, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ANNOTATION_TYPE_DECLARATION); 
+               createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_blocks, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK); 
+               createExtendedBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_blocks_in_case, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK_IN_CASE); 
+               createBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_switch_case, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH); 
+               
+               ComboPreference arrayInitOption= createBracesCombo(group, numColumns, FormatterMessages.BracesTabPage_option_initializer_list, DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_INITIALIZER_LIST); 
+               final CheckboxPreference arrayInitCheckBox= createIndentedCheckboxPref(group, numColumns, FormatterMessages.BracesTabPage_option_keep_empty_initializer_list_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_EMPTY_INITIALIZER_LIST_ON_ONE_LINE, FALSE_TRUE); 
+
+               arrayInitOption.addObserver(new Observer() {
+                       public void update(Observable o, Object arg) {
+                               updateOptionEnablement((ComboPreference) o, arrayInitCheckBox);
+                       }
+               });
+               updateOptionEnablement(arrayInitOption, arrayInitCheckBox);
+       }
+       
+       /**
+        * @param arrayInitOption
+        * @param arrayInitCheckBox
+        */
+       protected final void updateOptionEnablement(ComboPreference arrayInitOption, CheckboxPreference arrayInitCheckBox) {
+               arrayInitCheckBox.setEnabled(!arrayInitOption.hasValue(DefaultCodeFormatterConstants.END_OF_LINE));
+       }
+
+       @Override
+       protected void initializePage() {
+           fPreview.setPreviewText(PREVIEW);
+       }
+       
+       @Override
+       protected CPreview doCreateCPreview(Composite parent) {
+           fPreview= new TranslationUnitPreview(fWorkingValues, parent);
+           return fPreview;
+       }
+       
+       private ComboPreference createBracesCombo(Composite composite, int numColumns, String message, String key) {
+               return createComboPref(composite, numColumns, message, key, fBracePositions, fBracePositionNames);
+       }
+       
+       private ComboPreference createExtendedBracesCombo(Composite composite, int numColumns, String message, String key) {
+               return createComboPref(composite, numColumns, message, key, fExtendedBracePositions, fExtendedBracePositionNames);
+       }
+       
+       private CheckboxPreference createIndentedCheckboxPref(Composite composite, int numColumns, String message, String key, String[] values) {
+               CheckboxPreference pref= createCheckboxPref(composite, numColumns, message, key, values);
+               GridData data= (GridData) pref.getControl().getLayoutData();
+               data.horizontalIndent= fPixelConverter.convertWidthInCharsToPixels(1);
+               return pref;
+       }
+
+    @Override
+       protected void doUpdatePreview() {
+        fPreview.update();
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CPreview.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CPreview.java
new file mode 100644 (file)
index 0000000..3dc01a0
--- /dev/null
@@ -0,0 +1,213 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin, Google
+ *     Anton Leherbauer (Wind River Systems)
+ *     Andrew Ferguson (Symbian)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences.formatter;
+
+import java.util.Map;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.preference.PreferenceStore;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.MarginPainter;
+import org.eclipse.jface.text.WhitespaceCharacterPainter;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
+import org.eclipse.ui.texteditor.ChainedPreferenceStore;
+
+import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+import org.eclipse.cdt.internal.ui.editor.CSourceViewer;
+import org.eclipse.cdt.internal.ui.text.CTextTools;
+import org.eclipse.cdt.internal.ui.text.SimpleCSourceViewerConfiguration;
+
+/**
+ * Abstract previewer for C/C++ source code formatting.
+ * 
+ * @since 4.0
+ */
+public abstract class CPreview {
+
+       private final class CSourcePreviewerUpdater {
+
+           final IPropertyChangeListener fontListener= new IPropertyChangeListener() {
+               public void propertyChange(PropertyChangeEvent event) {
+                   if (event.getProperty().equals(PreferenceConstants.EDITOR_TEXT_FONT)) {
+                                       final Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
+                                       fSourceViewer.getTextWidget().setFont(font);
+                                       if (fMarginPainter != null) {
+                                               fMarginPainter.initialize();
+                                       }
+                               }
+                       }
+               };
+               
+           final IPropertyChangeListener propertyListener= new IPropertyChangeListener() {
+                       public void propertyChange(PropertyChangeEvent event) {
+                               if (fViewerConfiguration.affectsTextPresentation(event)) {
+                                       fViewerConfiguration.handlePropertyChangeEvent(event);
+                                       fSourceViewer.invalidateTextPresentation();
+                               }
+                       }
+               };
+               
+               public CSourcePreviewerUpdater() {
+                   JFaceResources.getFontRegistry().addListener(fontListener);
+                   fPreferenceStore.addPropertyChangeListener(propertyListener);
+                       
+                       fSourceViewer.getTextWidget().addDisposeListener(new DisposeListener() {
+                               public void widgetDisposed(DisposeEvent e) {
+                                       JFaceResources.getFontRegistry().removeListener(fontListener);
+                                       fPreferenceStore.removePropertyChangeListener(propertyListener);
+                               }
+                       });
+               }
+       }
+       
+       protected final SimpleCSourceViewerConfiguration fViewerConfiguration;
+       protected final Document fPreviewDocument;
+       protected final SourceViewer fSourceViewer;
+       protected final IPreferenceStore fPreferenceStore;
+       
+       protected final MarginPainter fMarginPainter;
+       
+       protected Map<String, String> fWorkingValues;
+
+       private int fTabSize= 0;
+       private WhitespaceCharacterPainter fWhitespaceCharacterPainter;
+       
+       /**
+        * Create a new C preview
+        * @param workingValues
+        * @param parent
+        */
+       public CPreview(Map<String, String> workingValues, Composite parent) {
+               CTextTools tools= CUIPlugin.getDefault().getTextTools();
+               fPreviewDocument= new Document();
+               fWorkingValues= workingValues;
+               tools.setupCDocumentPartitioner(fPreviewDocument, ICPartitions.C_PARTITIONING, null);   
+               
+               PreferenceStore prioritizedSettings= new PreferenceStore();
+               
+               IPreferenceStore[] chain= { prioritizedSettings, CUIPlugin.getDefault().getCombinedPreferenceStore() };
+               fPreferenceStore= new ChainedPreferenceStore(chain);
+               fSourceViewer= new CSourceViewer(parent, null, null, false, SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, fPreferenceStore);
+               fViewerConfiguration= new SimpleCSourceViewerConfiguration(tools.getColorManager(), fPreferenceStore, null, ICPartitions.C_PARTITIONING, true);
+               fSourceViewer.configure(fViewerConfiguration);
+               fSourceViewer.getTextWidget().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
+               
+               fMarginPainter= new MarginPainter(fSourceViewer);
+               final RGB rgb= PreferenceConverter.getColor(fPreferenceStore, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR);
+               fMarginPainter.setMarginRulerColor(tools.getColorManager().getColor(rgb));
+               fSourceViewer.addPainter(fMarginPainter);
+               
+               new CSourcePreviewerUpdater();
+               fSourceViewer.setDocument(fPreviewDocument);
+       }
+       
+       public Control getControl() {
+           return fSourceViewer.getControl();
+       }
+       
+       public void update() {
+               if (fWorkingValues == null) {
+                   fPreviewDocument.set(""); //$NON-NLS-1$
+                   return;
+               }
+               
+               // update the print margin
+               final String value= fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT);
+               final int lineWidth= getPositiveIntValue(value, 0);
+               fMarginPainter.setMarginRulerColumn(lineWidth);
+               
+               // update the tab size
+               final int tabSize= getPositiveIntValue(fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE), 0);
+               if (tabSize != fTabSize)
+                       fSourceViewer.getTextWidget().setTabs(tabSize);
+               fTabSize= tabSize;
+               
+               final StyledText widget= (StyledText) fSourceViewer.getControl();
+               final int height= widget.getClientArea().height;
+               final int top0= widget.getTopPixel();
+               
+               final int totalPixels0= getHeightOfAllLines(widget);
+               final int topPixelRange0= totalPixels0 > height ? totalPixels0 - height : 0;
+               
+               widget.setRedraw(false);
+               doFormatPreview();
+               fSourceViewer.setSelection(null);
+               
+               final int totalPixels1= getHeightOfAllLines(widget);
+               final int topPixelRange1= totalPixels1 > height ? totalPixels1 - height : 0;
+
+               final int top1= topPixelRange0 > 0 ? (int) (topPixelRange1 * top0 / (double) topPixelRange0) : 0;
+               widget.setTopPixel(top1);
+               widget.setRedraw(true);
+       }
+       
+       private int getHeightOfAllLines(StyledText styledText) {
+               int height= 0;
+               int lineCount= styledText.getLineCount();
+               for (int i= 0; i < lineCount; i++)
+                       height= height + styledText.getLineHeight(styledText.getOffsetAtLine(i));
+               return height;
+       }
+       
+       protected abstract void doFormatPreview();
+
+       private static int getPositiveIntValue(String string, int defaultValue) {
+           try {
+               int i= Integer.parseInt(string);
+               if (i >= 0) {
+                   return i;
+               }
+           } catch (NumberFormatException e) {
+           }
+           return defaultValue;
+       }               
+       
+       public Map<String, String> getWorkingValues() {
+               return fWorkingValues;
+       }
+       
+       
+       public void setWorkingValues(Map<String, String> workingValues) {
+               fWorkingValues= workingValues;
+       }
+
+       public void showInvisibleCharacters(boolean enable) {
+               if (enable) {
+                       if (fWhitespaceCharacterPainter == null) {
+                               fWhitespaceCharacterPainter= new WhitespaceCharacterPainter(fSourceViewer);
+                               fSourceViewer.addPainter(fWhitespaceCharacterPainter);
+                       }
+               } else {
+                       fSourceViewer.removePainter(fWhitespaceCharacterPainter);
+                       fWhitespaceCharacterPainter= null;
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CodeFormatterConfigurationBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CodeFormatterConfigurationBlock.java
new file mode 100644 (file)
index 0000000..7349e8e
--- /dev/null
@@ -0,0 +1,177 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Aaron Luchko, aluchko@redhat.com - 105926 [Formatter] Exporting Unnamed profile fails silently
+ *     Sergey Prigogin, Google
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences.formatter;
+
+import java.util.List;
+import java.util.Observable;
+import java.util.Observer;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.preferences.PreferencesAccess;
+import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.Profile;
+
+/**
+ * The code formatter preference page. 
+ */
+public class CodeFormatterConfigurationBlock extends ProfileConfigurationBlock {
+    
+    private static final String FORMATTER_DIALOG_PREFERENCE_KEY= "formatter_page"; //$NON-NLS-1$
+
+    private static final String DIALOGSTORE_LASTSAVELOADPATH= CUIPlugin.PLUGIN_ID + ".codeformatter.savepath"; //$NON-NLS-1$
+
+       private class PreviewController implements Observer {
+
+               public PreviewController(ProfileManager profileManager) {
+                       profileManager.addObserver(this);
+                       fCustomCodeFormatterBlock.addObserver(this);
+                       fCodeStylePreview.setWorkingValues(profileManager.getSelected().getSettings());
+                       fCodeStylePreview.update();
+               }
+               
+               public void update(Observable o, Object arg) {
+                       if (o == fCustomCodeFormatterBlock) {
+                               fCodeStylePreview.setFormatterId((String)arg);
+                               fCodeStylePreview.update();
+                               return;
+                       }
+                       final int value= ((Integer)arg).intValue();
+                       switch (value) {
+                               case ProfileManager.PROFILE_CREATED_EVENT:
+                               case ProfileManager.PROFILE_DELETED_EVENT:
+                               case ProfileManager.SELECTION_CHANGED_EVENT:
+                               case ProfileManager.SETTINGS_CHANGED_EVENT:
+                                       fCodeStylePreview.setWorkingValues(((ProfileManager)o).getSelected().getSettings());
+                                       fCodeStylePreview.update();
+                       }
+               }
+       }
+       
+       /**
+        * Some C++ source code used for preview.
+        */
+       private final static String PREVIEW=
+               "/*\n* " + //$NON-NLS-1$
+               FormatterMessages.CodingStyleConfigurationBlock_preview_title + 
+               "\n*/\n" + //$NON-NLS-1$
+               "#include <math.h>\n\n" + //$NON-NLS-1$
+               "class Point {" +  //$NON-NLS-1$
+               "public:" +  //$NON-NLS-1$
+               "Point(double x, double y) : x(x), y(y) {}" + //$NON-NLS-1$ 
+               "double distance(const Point& other) const;" + //$NON-NLS-1$
+               "\n\n" +  //$NON-NLS-1$
+               "double x;" +  //$NON-NLS-1$
+               "double y;" +  //$NON-NLS-1$
+               "};" +  //$NON-NLS-1$
+               "\n\n" +  //$NON-NLS-1$
+               "double Point::distance(const Point& other) const {" + //$NON-NLS-1$
+               "double dx = x - other.x;" + //$NON-NLS-1$
+               "double dy = y - other.y;" + //$NON-NLS-1$
+               "return sqrt(dx * dx + dy * dy);" + //$NON-NLS-1$
+               "}"; //$NON-NLS-1$
+
+       /**
+        * The CPreview.
+        */
+       protected TranslationUnitPreview fCodeStylePreview;
+       
+       protected CustomCodeFormatterBlock fCustomCodeFormatterBlock;
+       /**
+        * Create a new <code>CodeFormatterConfigurationBlock</code>.
+        */
+       public CodeFormatterConfigurationBlock(IProject project, PreferencesAccess access) {
+               super(project, access, DIALOGSTORE_LASTSAVELOADPATH);
+               fCustomCodeFormatterBlock= new CustomCodeFormatterBlock(project, access);
+       }
+
+       @Override
+       protected IProfileVersioner createProfileVersioner() {
+           return new ProfileVersioner();
+    }
+       
+       @Override
+       protected ProfileStore createProfileStore(IProfileVersioner versioner) {
+           return new FormatterProfileStore(versioner);
+    }
+       
+       @Override
+       protected ProfileManager createProfileManager(List<Profile> profiles, IScopeContext context, PreferencesAccess access, IProfileVersioner profileVersioner) {
+           return new FormatterProfileManager(profiles, context, access, profileVersioner);
+    }
+       
+       @Override
+       protected void configurePreview(Composite composite, int numColumns, ProfileManager profileManager) {
+               fCustomCodeFormatterBlock.createContents(composite);
+
+               createLabel(composite, FormatterMessages.CodingStyleConfigurationBlock_preview_label_text, numColumns);
+               TranslationUnitPreview result= new TranslationUnitPreview(profileManager.getSelected().getSettings(), composite);
+               result.setFormatterId(fCustomCodeFormatterBlock.getFormatterId());
+        result.setPreviewText(PREVIEW);
+        fCodeStylePreview= result;
+
+               final GridData gd = new GridData(GridData.FILL_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL);
+               gd.horizontalSpan = numColumns;
+               gd.verticalSpan= 7;
+               gd.widthHint = 0;
+               gd.heightHint = 0;
+               fCodeStylePreview.getControl().setLayoutData(gd);
+               
+               new PreviewController(profileManager);
+       }
+
+    @Override
+       protected ModifyDialog createModifyDialog(Shell shell, Profile profile, ProfileManager profileManager, ProfileStore profileStore, boolean newProfile) {
+        return new FormatterModifyDialog(shell, profile, profileManager, profileStore, newProfile, FORMATTER_DIALOG_PREFERENCE_KEY, DIALOGSTORE_LASTSAVELOADPATH);
+    }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.formatter.ProfileConfigurationBlock#performApply()
+        */
+       @Override
+       public void performApply() {
+               if (fCustomCodeFormatterBlock != null) {
+                       fCustomCodeFormatterBlock.performOk();
+               }
+               super.performApply();
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.formatter.ProfileConfigurationBlock#performDefaults()
+        */
+       @Override
+       public void performDefaults() {
+               if (fCustomCodeFormatterBlock != null) {
+                       fCustomCodeFormatterBlock.performDefaults();
+               }
+               super.performDefaults();
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.formatter.ProfileConfigurationBlock#performOk()
+        */
+       @Override
+       public boolean performOk() {
+               if (fCustomCodeFormatterBlock != null) {
+                       fCustomCodeFormatterBlock.performOk();
+               }
+               return super.performOk();
+       }
+    
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CommentsTabPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CommentsTabPage.java
new file mode 100644 (file)
index 0000000..1a7edbf
--- /dev/null
@@ -0,0 +1,229 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences.formatter;
+
+import java.util.Map;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
+
+/**
+ * Tab page for the comment formatter settings.
+ */
+public class CommentsTabPage extends FormatterTabPage {
+
+//     private static abstract class Controller implements Observer {
+//             private final Collection<CheckboxPreference> fMasters;
+//             private final Collection<Object> fSlaves;
+//
+//             public Controller(Collection<CheckboxPreference> masters, Collection<Object> slaves) {
+//                     fMasters= masters;
+//                     fSlaves= slaves;
+//                     for (CheckboxPreference pref : fMasters) {
+//                             pref.addObserver(this);
+//                     }
+//             }
+//
+//             public void update(Observable o, Object arg) {
+//                     boolean enabled= areSlavesEnabled();
+//
+//                     for (Object slave : fSlaves) {
+//                             if (slave instanceof Preference) {
+//                                     ((Preference) slave).setEnabled(enabled);
+//                             } else if (slave instanceof Control) {
+//                                     ((Group) slave).setEnabled(enabled);
+//                             }
+//                     }
+//             }
+//
+//             public Collection<CheckboxPreference> getMasters() {
+//                     return fMasters;
+//             }
+//
+//             protected abstract boolean areSlavesEnabled();
+//     }
+//
+//     private final static class OrController extends Controller {
+//             public OrController(Collection<CheckboxPreference> masters, Collection<Object> slaves) {
+//                     super(masters, slaves);
+//                     update(null, null);
+//             }
+//
+//             @Override
+//             protected boolean areSlavesEnabled() {
+//                     for (CheckboxPreference pref : getMasters()) {
+//                             if (pref.getChecked())
+//                                     return true;
+//                     }
+//                     return false;
+//             }
+//     }
+
+       private final String PREVIEW=
+               createPreviewHeader(FormatterMessages.CommentsTabPage_preview_header) + 
+               "void lineComments() {\n" +  //$NON-NLS-1$
+               "\tprintf(\"%d\\n\", 1234);   \t\t// Integer number\n" +  //$NON-NLS-1$
+               "\tprintf(\"%.5g\\n\", 12.34);\t\t// Floating point number\n" +  //$NON-NLS-1$
+               "}\n"; //$NON-NLS-1$
+
+       private TranslationUnitPreview fPreview;
+
+       public CommentsTabPage(ModifyDialog modifyDialog, Map<String, String> workingValues) {
+               super(modifyDialog, workingValues);
+       }
+
+       @Override
+       protected void doCreatePreferences(Composite composite, int numColumns) {
+//             final int indent= fPixelConverter.convertWidthInCharsToPixels(4);
+
+               // Global group
+//             final Group globalGroup= createGroup(numColumns, composite, FormatterMessages.CommentsTabPage_group1_title);
+//             createPrefFalseTrue(globalGroup, numColumns, FormatterMessages.CommentsTabPage_do_not_join_lines, DefaultCodeFormatterConstants.FORMATTER_JOIN_LINES_IN_COMMENTS, true);
+
+               // Line comment group
+               final Group lineCommentGroup= createGroup(numColumns, composite, FormatterMessages.CommentsTabPage_group1_title);
+//             final CheckboxPreference singleLineCommentsOnFirstColumn= createPrefFalseTrue(lineCommentGroup, numColumns, FormatterMessages.CommentsTabPage_format_line_comments_on_first_column, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT_STARTING_ON_FIRST_COLUMN, false);
+//             ((GridData) singleLineCommentsOnFirstColumn.getControl().getLayoutData()).horizontalIndent= indent;
+               createPrefFalseTrue(lineCommentGroup, numColumns, FormatterMessages.CommentsTabPage_preserve_white_space_before_line_comment, DefaultCodeFormatterConstants.FORMATTER_COMMENT_PRESERVE_WHITE_SPACE_BETWEEN_CODE_AND_LINE_COMMENT, false);
+               createNumberPref(lineCommentGroup, numColumns, FormatterMessages.CommentsTabPage_line_width, DefaultCodeFormatterConstants.FORMATTER_COMMENT_MIN_DISTANCE_BETWEEN_CODE_AND_LINE_COMMENT, 0, 9999);
+//             final CheckboxPreference singleLineComments= createPrefFalseTrue(lineCommentGroup, numColumns, FormatterMessages.CommentsTabPage_enable_line_comment_formatting, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT, false);
+//             createPrefFalseTrue(lineCommentGroup, numColumns, FormatterMessages.CommentsTabPage_never_indent_line_comments_on_first_column, DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN, false);
+
+               // Block comment settings
+//             final Group blockSettingsGroup= createGroup(numColumns, composite, FormatterMessages.CommentsTabPage_group4_title);
+//             final CheckboxPreference header= createPrefFalseTrue(blockSettingsGroup, numColumns, FormatterMessages.CommentsTabPage_format_header, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HEADER, false);
+//             GridData spacerData= new GridData(0, 0);
+//             spacerData.horizontalSpan= numColumns;
+//             final CheckboxPreference blockComment= createPrefFalseTrue(blockSettingsGroup, numColumns, FormatterMessages.CommentsTabPage_enable_block_comment_formatting, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_BLOCK_COMMENT, false);
+//             final CheckboxPreference nlBoundariesBlock= createPrefFalseTrue(blockSettingsGroup, numColumns, FormatterMessages.CommentsTabPage_new_lines_at_comment_boundaries, DefaultCodeFormatterConstants.FORMATTER_COMMENT_NEW_LINES_AT_BLOCK_BOUNDARIES, false);
+//             final CheckboxPreference blankLinesBlock= createPrefFalseTrue(blockSettingsGroup, numColumns, FormatterMessages.CommentsTabPage_remove_blank_block_comment_lines, DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_BLOCK_COMMENT, false);
+
+               // Doxygen comment formatting settings
+//             final Group settingsGroup= createGroup(numColumns, composite, FormatterMessages.CommentsTabPage_group2_title);
+//             final CheckboxPreference doxygen= createPrefFalseTrue(globalGroup, numColumns, FormatterMessages.commentsTabPage_enable_javadoc_comment_formatting, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_JAVADOC_COMMENT, false);
+//             final CheckboxPreference html= createPrefFalseTrue(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_format_html, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HTML, false);
+//             final CheckboxPreference code= createPrefFalseTrue(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_format_code_snippets, DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_SOURCE, false);
+//             final CheckboxPreference blankDoxygen= createPrefInsert(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_blank_line_before_doxygen_tags, DefaultCodeFormatterConstants.FORMATTER_COMMENT_INSERT_EMPTY_LINE_BEFORE_ROOT_TAGS);
+//             final CheckboxPreference indentDoxygen= createPrefFalseTrue(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_indent_doxygen_tags, DefaultCodeFormatterConstants.FORMATTER_COMMENT_INDENT_ROOT_TAGS, false);
+//             final CheckboxPreference indentDesc= createPrefFalseTrue(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_indent_description_after_param, DefaultCodeFormatterConstants.FORMATTER_COMMENT_INDENT_PARAMETER_DESCRIPTION, false);
+//             ((GridData) indentDesc.getControl().getLayoutData()).horizontalIndent= indent;
+//             final CheckboxPreference nlParam= createPrefInsert(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_new_line_after_param_tags, DefaultCodeFormatterConstants.FORMATTER_COMMENT_INSERT_NEW_LINE_FOR_PARAMETER);
+//             final CheckboxPreference nlBoundariesDoxygen= createPrefFalseTrue(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_new_lines_at_doxygen_boundaries, DefaultCodeFormatterConstants.FORMATTER_COMMENT_NEW_LINES_AT_JAVADOC_BOUNDARIES, false);
+//             final CheckboxPreference blankLinesDoxygen= createPrefFalseTrue(settingsGroup, numColumns, FormatterMessages.CommentsTabPage_clear_blank_lines, DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_JAVADOC_COMMENT, false);
+
+               // Line width settings
+//             final Group widthGroup= createGroup(numColumns, composite, FormatterMessages.CommentsTabPage_group3_title);
+//             final NumberPreference lineWidth= createNumberPref(widthGroup, numColumns, FormatterMessages.CommentsTabPage_line_width, DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, 0, 9999);
+
+//             ArrayList<CheckboxPreference> lineFirstColumnMasters= new ArrayList<CheckboxPreference>();
+//             lineFirstColumnMasters.add(singleLineComments);
+//
+//             ArrayList<Object> lineFirstColumnSlaves= new ArrayList<Object>();
+//             lineFirstColumnSlaves.add(singleLineCommentsOnFirstColumn);
+//
+//             new Controller(lineFirstColumnMasters, lineFirstColumnSlaves) {
+//                     @Override
+//                     protected boolean areSlavesEnabled() {
+//                             return singleLineComments.getChecked();
+//            }
+//             }.update(null, null);
+//
+//             ArrayList<CheckboxPreference> doxygenMaster= new ArrayList<CheckboxPreference>();
+//             doxygenMaster.add(doxygen);
+//             doxygenMaster.add(header);
+//
+//             ArrayList<Object> doxygenSlaves= new ArrayList<Object>();
+//             doxygenSlaves.add(settingsGroup);
+//             doxygenSlaves.add(html);
+//             doxygenSlaves.add(code);
+//             doxygenSlaves.add(blankDoxygen);
+//             doxygenSlaves.add(indentDoxygen);
+//             doxygenSlaves.add(nlParam);
+//             doxygenSlaves.add(nlBoundariesDoxygen);
+//             doxygenSlaves.add(blankLinesDoxygen);
+//
+//             new OrController(doxygenMaster, doxygenSlaves);
+//
+//             ArrayList<CheckboxPreference> indentMasters= new ArrayList<CheckboxPreference>();
+//             indentMasters.add(doxygen);
+//             indentMasters.add(header);
+//             indentMasters.add(indentDoxygen);
+//
+//             ArrayList<Object> indentSlaves= new ArrayList<Object>();
+//             indentSlaves.add(indentDesc);
+//
+//             new Controller(indentMasters, indentSlaves) {
+//                     @Override
+//                     protected boolean areSlavesEnabled() {
+//                             return (doxygen.getChecked() || header.getChecked()) && indentDoxygen.getChecked();
+//            }
+//             }.update(null, null);
+//
+//             ArrayList<CheckboxPreference> blockMasters= new ArrayList<CheckboxPreference>();
+//             blockMasters.add(blockComment);
+//             blockMasters.add(header);
+//
+//             ArrayList<Object> blockSlaves= new ArrayList<Object>();
+//             blockSlaves.add(blockSettingsGroup);
+//             blockSlaves.add(nlBoundariesBlock);
+//             blockSlaves.add(blankLinesBlock);
+//
+//             new OrController(blockMasters, blockSlaves);
+//
+//             ArrayList<CheckboxPreference> lineWidthMasters= new ArrayList<CheckboxPreference>();
+//             lineWidthMasters.add(doxygen);
+//             lineWidthMasters.add(blockComment);
+//             lineWidthMasters.add(singleLineComments);
+//             lineWidthMasters.add(header);
+//
+//             ArrayList<Object> lineWidthSlaves= new ArrayList<Object>();
+//             lineWidthSlaves.add(widthGroup);
+//             lineWidthSlaves.add(lineWidth);
+//
+//             new OrController(lineWidthMasters, lineWidthSlaves);
+       }
+
+       @Override
+       protected void initializePage() {
+               fPreview.setPreviewText(PREVIEW);
+       }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doCreateCPreview(org.eclipse.swt.widgets.Composite)
+     */
+    @Override
+       protected CPreview doCreateCPreview(Composite parent) {
+        fPreview= new TranslationUnitPreview(fWorkingValues, parent);
+        return fPreview;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doUpdatePreview()
+     */
+    @Override
+       protected void doUpdatePreview() {
+       super.doUpdatePreview();
+        fPreview.update();
+    }
+
+       private CheckboxPreference createPrefFalseTrue(Composite composite, int numColumns, String text, String key, boolean invertPreference) {
+               if (invertPreference)
+                       return createCheckboxPref(composite, numColumns, text, key, TRUE_FALSE);
+               return createCheckboxPref(composite, numColumns, text, key, FALSE_TRUE);
+       }
+
+//    private CheckboxPreference createPrefInsert(Composite composite, int numColumns, String text, String key) {
+//        return createCheckboxPref(composite, numColumns, text, key, DO_NOT_INSERT_INSERT);
+//    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ControlStatementsTabPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ControlStatementsTabPage.java
new file mode 100644 (file)
index 0000000..b32bd7d
--- /dev/null
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences.formatter;
+
+import java.util.Map;
+import java.util.Observable;
+import java.util.Observer;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+
+import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
+
+public class ControlStatementsTabPage extends FormatterTabPage {
+       
+       private final String PREVIEW=
+       createPreviewHeader(FormatterMessages.ControlStatementsTabPage_preview_header) + 
+       "class Example {" +     //$NON-NLS-1$   
+       "  void bar() {" +      //$NON-NLS-1$
+       "    do {} while (true);" +     //$NON-NLS-1$
+       "    try {} catch (...) { }" +  //$NON-NLS-1$
+       "  }" + //$NON-NLS-1$
+       "  void foo2() {" +     //$NON-NLS-1$
+       "    if (true) { " + //$NON-NLS-1$
+       "      return;" + //$NON-NLS-1$
+       "    }" + //$NON-NLS-1$
+       "    if (true) {" + //$NON-NLS-1$
+       "      return;" + //$NON-NLS-1$
+       "    } else if (false) {" +     //$NON-NLS-1$
+       "      return; " + //$NON-NLS-1$
+       "    } else {" + //$NON-NLS-1$
+       "      return;" + //$NON-NLS-1$
+       "    }" + //$NON-NLS-1$
+       "  }" + //$NON-NLS-1$
+       "  void foo(int state) {" + //$NON-NLS-1$
+       "    if (true) return;" + //$NON-NLS-1$
+       "    if (true) " + //$NON-NLS-1$
+       "      return;" + //$NON-NLS-1$
+       "    else if (false)" + //$NON-NLS-1$
+       "      return;" + //$NON-NLS-1$
+       "    else return;" + //$NON-NLS-1$
+       "  }" + //$NON-NLS-1$
+       "};"; //$NON-NLS-1$
+       
+       
+       private TranslationUnitPreview fPreview;
+       
+       protected CheckboxPreference fThenStatementPref, fSimpleIfPref;
+
+       
+       public ControlStatementsTabPage(ModifyDialog modifyDialog, Map<String, String> workingValues) {
+               super(modifyDialog, workingValues);
+       }
+
+       @Override
+       protected void doCreatePreferences(Composite composite, int numColumns) {
+               
+               final Group generalGroup= createGroup(numColumns, composite, FormatterMessages.ControlStatementsTabPage_general_group_title); 
+               createOption(generalGroup, numColumns, FormatterMessages.ControlStatementsTabPage_general_group_insert_new_line_before_else_statements, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT, DO_NOT_INSERT_INSERT); 
+               createOption(generalGroup, numColumns, FormatterMessages.ControlStatementsTabPage_general_group_insert_new_line_before_catch_statements, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, DO_NOT_INSERT_INSERT); 
+               createOption(generalGroup, numColumns, FormatterMessages.ControlStatementsTabPage_general_group_insert_new_line_before_while_in_do_statements, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, DO_NOT_INSERT_INSERT); 
+                               
+               final Group ifElseGroup= createGroup(numColumns, composite, FormatterMessages.ControlStatementsTabPage_if_else_group_title); 
+               fThenStatementPref= createOption(ifElseGroup, numColumns, FormatterMessages.ControlStatementsTabPage_if_else_group_keep_then_on_same_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_THEN_STATEMENT_ON_SAME_LINE, FALSE_TRUE); 
+               
+               Label l= new Label(ifElseGroup, SWT.NONE);
+               GridData gd= new GridData();
+               gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(4);
+               l.setLayoutData(gd);
+               
+               fSimpleIfPref= createOption(ifElseGroup, numColumns - 1, FormatterMessages.ControlStatementsTabPage_if_else_group_keep_simple_if_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_SIMPLE_IF_ON_ONE_LINE, FALSE_TRUE); 
+               
+               fThenStatementPref.addObserver( new Observer() {
+                       public void update(Observable o, Object arg) {
+                               fSimpleIfPref.setEnabled(!fThenStatementPref.getChecked());
+                       }
+                       
+               });
+               
+               fSimpleIfPref.setEnabled(!fThenStatementPref.getChecked());
+               
+               createOption(ifElseGroup, numColumns, FormatterMessages.ControlStatementsTabPage_if_else_group_keep_else_on_same_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_ELSE_STATEMENT_ON_SAME_LINE, FALSE_TRUE); 
+               createCheckboxPref(ifElseGroup, numColumns, FormatterMessages.ControlStatementsTabPage_if_else_group_keep_else_if_on_one_line, DefaultCodeFormatterConstants.FORMATTER_COMPACT_ELSE_IF, FALSE_TRUE); 
+//             createCheckboxPref(ifElseGroup, numColumns, FormatterMessages.ControlStatementsTabPage_if_else_group_keep_guardian_clause_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_GUARDIAN_CLAUSE_ON_ONE_LINE, FALSE_TRUE); 
+       }
+       
+       @Override
+       protected void initializePage() {
+           fPreview.setPreviewText(PREVIEW);
+       }
+
+    /*
+     * @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doCreateCPreview(org.eclipse.swt.widgets.Composite)
+     */
+    @Override
+       protected CPreview doCreateCPreview(Composite parent) {
+        fPreview= new TranslationUnitPreview(fWorkingValues, parent);
+        return fPreview;
+    }
+
+    /*
+     * @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doUpdatePreview()
+     */
+    @Override
+       protected void doUpdatePreview() {
+       super.doUpdatePreview();
+        fPreview.update();
+    }
+
+    private CheckboxPreference createOption(Composite composite, int span, String name, String key, String [] values) {
+               return createCheckboxPref(composite, span, name, key, values);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CreateProfileDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CreateProfileDialog.java
new file mode 100644 (file)
index 0000000..b01476a
--- /dev/null
@@ -0,0 +1,204 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin, Google
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences.formatter;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.StatusDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
+import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.Profile;
+
+/**
+ * The dialog to create a new profile. 
+ */
+public class CreateProfileDialog extends StatusDialog {
+    
+    private static final String PREF_OPEN_EDIT_DIALOG= CUIPlugin.PLUGIN_ID + ".codeformatter.create_profile_dialog.open_edit"; //$NON-NLS-1$
+    
+       private Text fNameText;
+       private Combo fProfileCombo;
+       private Button fEditCheckbox;
+       
+       private final static StatusInfo fOk= new StatusInfo();
+       private final static StatusInfo fEmpty= new StatusInfo(IStatus.ERROR, FormatterMessages.CreateProfileDialog_status_message_profile_name_is_empty); 
+       private final static StatusInfo fDuplicate= new StatusInfo(IStatus.ERROR, FormatterMessages.CreateProfileDialog_status_message_profile_with_this_name_already_exists); 
+
+       private final ProfileManager fProfileManager;
+       private final List<Profile> fSortedProfiles;
+       private final String [] fSortedNames;
+       
+       private CustomProfile fCreatedProfile;
+       protected boolean fOpenEditDialog;
+
+       private final IProfileVersioner fProfileVersioner;
+       
+       public CreateProfileDialog(Shell parentShell, ProfileManager profileManager, IProfileVersioner profileVersioner) {
+               super(parentShell);
+               fProfileManager= profileManager;
+               fProfileVersioner= profileVersioner;
+               fSortedProfiles= fProfileManager.getSortedProfiles();
+               fSortedNames= fProfileManager.getSortedDisplayNames();
+               setShellStyle(getShellStyle() | SWT.RESIZE);
+       }
+       
+       
+       @Override
+       public void create() {
+               super.create();
+               setTitle(FormatterMessages.CreateProfileDialog_dialog_title); 
+       }
+       
+       @Override
+       public Control createDialogArea(Composite parent) {
+                               
+               final int numColumns= 2;
+               
+               GridData gd;
+               
+               final GridLayout layout= new GridLayout(numColumns, false);
+               layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+               layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+               layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
+               layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+
+               final Composite composite= new Composite(parent, SWT.NONE);
+               composite.setLayout(layout);
+               
+               // Create "Profile name:" label
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = numColumns;
+               gd.widthHint= convertWidthInCharsToPixels(60);
+               final Label nameLabel = new Label(composite, SWT.WRAP);
+               nameLabel.setText(FormatterMessages.CreateProfileDialog_profile_name_label_text); 
+               nameLabel.setLayoutData(gd);
+               
+               // Create text field to enter name
+               gd = new GridData( GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan= numColumns;
+               fNameText= new Text(composite, SWT.SINGLE | SWT.BORDER);
+               fNameText.setLayoutData(gd);
+               fNameText.addModifyListener( new ModifyListener() {
+                       public void modifyText(ModifyEvent e) {
+                               doValidation();
+                       }
+               });
+               
+               // Create "Initialize settings ..." label
+               gd = new GridData();
+               gd.horizontalSpan = numColumns;
+               Label profileLabel = new Label(composite, SWT.WRAP);
+               profileLabel.setText(FormatterMessages.CreateProfileDialog_base_profile_label_text); 
+               profileLabel.setLayoutData(gd);
+               
+               gd= new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan= numColumns;
+               fProfileCombo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
+               fProfileCombo.setLayoutData(gd);
+               
+               
+               // "Open the edit dialog now" checkbox
+               gd= new GridData();
+               gd.horizontalSpan= numColumns;
+               fEditCheckbox= new Button(composite, SWT.CHECK);
+               fEditCheckbox.setText(FormatterMessages.CreateProfileDialog_open_edit_dialog_checkbox_text); 
+               fEditCheckbox.addSelectionListener(new SelectionListener() {
+                       public void widgetSelected(SelectionEvent e) {
+                               fOpenEditDialog= ((Button)e.widget).getSelection();
+                       }
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                       }
+               });
+               
+               final IDialogSettings dialogSettings= CUIPlugin.getDefault().getDialogSettings();//.get(PREF_OPEN_EDIT_DIALOG);
+               if (dialogSettings.get(PREF_OPEN_EDIT_DIALOG) != null) {
+                   fOpenEditDialog= dialogSettings.getBoolean(PREF_OPEN_EDIT_DIALOG);
+               } else {
+                   fOpenEditDialog= true;
+               }
+               fEditCheckbox.setSelection(fOpenEditDialog);
+               
+               fProfileCombo.setItems(fSortedNames);
+               fProfileCombo.setText(fProfileManager.getDefaultProfile().getName());
+               updateStatus(fEmpty);
+               
+               applyDialogFont(composite);
+               
+               fNameText.setFocus();
+               
+               return composite;
+       }
+
+
+       /**
+        * Validate the current settings
+        */
+       protected void doValidation() {
+               final String name= fNameText.getText().trim();
+               
+               if (fProfileManager.containsName(name)) {
+                       updateStatus(fDuplicate);
+                       return;
+               }
+               if (name.length() == 0) {
+                       updateStatus(fEmpty);
+                       return;
+               }
+               updateStatus(fOk);
+       }
+       
+       @Override
+       protected void okPressed() {
+               if (!getStatus().isOK()) 
+                       return;
+
+               CUIPlugin.getDefault().getDialogSettings().put(PREF_OPEN_EDIT_DIALOG, fOpenEditDialog);
+
+               final Map<String, String> baseSettings= new HashMap<String, String>((fSortedProfiles.get(fProfileCombo.getSelectionIndex())).getSettings());
+               final String profileName= fNameText.getText();
+               
+               fCreatedProfile= new CustomProfile(profileName, baseSettings, fProfileVersioner.getCurrentVersion(), fProfileVersioner.getProfileKind());
+               fProfileManager.addProfile(fCreatedProfile);
+               super.okPressed();
+       }
+       
+       public final CustomProfile getCreatedProfile() {
+               return fCreatedProfile;
+       }
+       
+       public final boolean openEditDialog() {
+               return fOpenEditDialog;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CustomCodeFormatterBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/CustomCodeFormatterBlock.java
new file mode 100644 (file)
index 0000000..f4f7894
--- /dev/null
@@ -0,0 +1,214 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Sergey Prigogin, Google
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences.formatter;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Observable;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.CCorePreferenceConstants;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.preferences.PreferencesAccess;
+
+/**
+ * Allows to choose the formatter in a combo box.
+ * If no formatter is contributed, nothing is shown.
+ */
+public class CustomCodeFormatterBlock extends Observable {
+
+       private HashMap<String, String> idMap = new HashMap<String, String>();
+       private IEclipsePreferences fPrefs;
+       private String fDefaultFormatterId;
+       private Combo fFormatterCombo;
+       private static final String ATTR_NAME = "name"; //$NON-NLS-1$
+       private static final String ATTR_ID = "id"; //$NON-NLS-1$
+       private static final String DEFAULT = FormatterMessages.CustomCodeFormatterBlock_default_formatter;
+
+       public CustomCodeFormatterBlock(IProject project, PreferencesAccess access) {
+               final IScopeContext scope;
+               final IEclipsePreferences defaults;
+               if (project != null) {
+                       scope= access.getProjectScope(project);
+                       defaults= access.getInstanceScope().getNode(CCorePlugin.PLUGIN_ID);
+               } else {
+                       scope= access.getInstanceScope();
+                       defaults= access.getDefaultScope().getNode(CCorePlugin.PLUGIN_ID);
+               }
+               fPrefs= scope.getNode(CCorePlugin.PLUGIN_ID);
+               fDefaultFormatterId= defaults.get(CCorePreferenceConstants.CODE_FORMATTER, null);
+               if (fDefaultFormatterId == null) {
+                       // backward compatibility: use UI prefs
+                       IEclipsePreferences instance= access.getInstanceScope().getNode(CUIPlugin.PLUGIN_ID);
+                       fDefaultFormatterId= instance.get(CCorePreferenceConstants.CODE_FORMATTER, null);
+                       if (fDefaultFormatterId != null) {
+                               instance.remove(CCorePreferenceConstants.CODE_FORMATTER);
+                               if (project != null) {
+                                       defaults.put(CCorePreferenceConstants.CODE_FORMATTER, fDefaultFormatterId);
+                               }
+                       }
+               }
+               initializeFormatters();
+       }
+
+       public void performOk() {
+               if (fFormatterCombo == null) {
+                       return;
+               }
+               String text = fFormatterCombo.getText();
+               String formatterId = idMap.get(text);
+               if (formatterId != null && !formatterId.equals(fDefaultFormatterId)) {
+                       fPrefs.put(CCorePreferenceConstants.CODE_FORMATTER, formatterId);
+               } else {
+                       // simply reset to the default one.
+                       performDefaults();
+               }
+       }
+
+       public void performDefaults() {
+               fPrefs.remove(CCorePreferenceConstants.CODE_FORMATTER);
+
+               if (fFormatterCombo == null) {
+                       return;
+               }
+               fFormatterCombo.clearSelection();
+               fFormatterCombo.setText(DEFAULT);
+               Iterator<Map.Entry<String,String>> iterator = idMap.entrySet().iterator();
+               while (iterator.hasNext()) {
+                       Map.Entry<String,String> entry = iterator.next();
+                       String val = entry.getValue();
+                       if (val != null && val.equals(fDefaultFormatterId)) {
+                               fFormatterCombo.setText(entry.getKey());
+                       }
+               }
+               handleFormatterChanged();
+       }
+
+
+       /**
+        * Get the currently selected formatter id.
+        * 
+        * @return the selected formatter id or <code>null</code> if the default is selected.
+        */
+       public String getFormatterId() {
+               if (fFormatterCombo == null) {
+                       return fPrefs.get(CCorePreferenceConstants.CODE_FORMATTER, fDefaultFormatterId);
+               }
+               String formatterId= idMap.get(fFormatterCombo.getText());
+               return formatterId;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+        */
+       public Control createContents(Composite parent) {
+               if (getNumberOfAvailableFormatters() == 0) {
+                       return parent;
+               }
+               Composite composite = ControlFactory.createGroup(parent, FormatterMessages.CustomCodeFormatterBlock_formatter_name, 1);
+               ((GridData)composite.getLayoutData()).horizontalSpan = 5;
+
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.CODEFORMATTER_PREFERENCE_PAGE);
+
+               fFormatterCombo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
+               fFormatterCombo.setFont(parent.getFont());
+               fFormatterCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               fFormatterCombo.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               handleFormatterChanged();
+                       }
+               });
+               Iterator<String> items = idMap.keySet().iterator();
+               while (items.hasNext()) {
+                       fFormatterCombo.add(items.next());
+               }
+
+               final String noteTitle= FormatterMessages.CustomCodeFormatterBlock_formatter_note;
+               final String noteMessage= FormatterMessages.CustomCodeFormatterBlock_contributed_formatter_warning;
+               ControlFactory.createNoteComposite(JFaceResources.getDialogFont(), composite, noteTitle, noteMessage);
+               
+               initDefault();
+               
+               return composite;
+       }
+
+       private void handleFormatterChanged() {
+               setChanged();
+               String formatterId= getFormatterId();
+               notifyObservers(formatterId);
+       }
+
+       private void initDefault() {
+               boolean init = false;
+               String formatterID= fPrefs.get(CCorePreferenceConstants.CODE_FORMATTER, fDefaultFormatterId);
+               if (formatterID != null) {
+                       Iterator<Map.Entry<String,String>> iterator = idMap.entrySet().iterator();
+                       while (iterator.hasNext()) {
+                               Map.Entry<String, String> entry = iterator.next();
+                               String val = entry.getValue();
+                               if (val != null && val.equals(formatterID)) {
+                                       fFormatterCombo.setText(entry.getKey());
+                                       init = true;
+                               }
+                       }
+               }
+               if (!init) {
+                       formatterID= null;
+                       fFormatterCombo.setText(DEFAULT);
+               }
+       }
+
+       private void initializeFormatters() {
+               idMap = new HashMap<String, String>();
+               idMap.put(DEFAULT, CCorePreferenceConstants.DEFAULT_CODE_FORMATTER);
+               IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, CCorePlugin.FORMATTER_EXTPOINT_ID);
+               if (point != null) {
+                       IExtension[] exts = point.getExtensions();
+                       for (IExtension ext : exts) {
+                               IConfigurationElement[] elements = ext.getConfigurationElements();
+                               for (int j = 0; j < elements.length; ++j) {
+                                       String name = elements[j].getAttribute(ATTR_NAME);
+                                       String id= elements[j].getAttribute(ATTR_ID);
+                                       idMap.put(name, id);
+                               }
+                       }
+               }
+       }
+       
+       private final int getNumberOfAvailableFormatters() {
+               return idMap.size() - 1;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.java
new file mode 100644 (file)
index 0000000..f038737
--- /dev/null
@@ -0,0 +1,408 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences.formatter;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Helper class to get NLSed messages.
+ */
+final class FormatterMessages extends NLS {
+
+       public static String FormatterTabPage_ShowInvisibleCharacters_label;
+       public static String ModifyDialog_BuiltIn_Status;
+       public static String ModifyDialog_Duplicate_Status;
+       public static String ModifyDialog_EmptyName_Status;
+       public static String ModifyDialog_Export_Button;
+       public static String ModifyDialog_NewCreated_Status;
+       public static String ModifyDialog_ProfileName_Label;
+       public static String ModifyDialog_Shared_Status;
+       public static String ProfileConfigurationBlock_load_profile_wrong_profile_message;
+       public static String WhiteSpaceTabPage_assignments;
+       public static String WhiteSpaceTabPage_assignments_before_assignment_operator;
+       public static String WhiteSpaceTabPage_assignments_after_assignment_operator;
+       public static String WhiteSpaceTabPage_operators;
+       public static String WhiteSpaceTabPage_operators_before_binary_operators;
+       public static String WhiteSpaceTabPage_operators_after_binary_operators;
+       public static String WhiteSpaceTabPage_operators_before_unary_operators;
+       public static String WhiteSpaceTabPage_operators_after_unary_operators;
+       public static String WhiteSpaceTabPage_operators_before_prefix_operators;
+       public static String WhiteSpaceTabPage_operators_after_prefix_operators;
+       public static String WhiteSpaceTabPage_operators_before_postfix_operators;
+       public static String WhiteSpaceTabPage_operators_after_postfix_operators;
+       public static String WhiteSpaceTabPage_classes;
+       public static String WhiteSpaceTabPage_classes_before_opening_brace_of_a_class;
+       public static String WhiteSpaceTabPage_classes_before_colon_of_base_clause;
+       public static String WhiteSpaceTabPage_classes_after_colon_of_base_clause;
+       public static String WhiteSpaceTabPage_classes_before_comma_base_types;
+       public static String WhiteSpaceTabPage_classes_after_comma_base_types;
+       public static String WhiteSpaceTabPage_functions;
+       public static String WhiteSpaceTabPage_exception_specifications;
+       public static String WhiteSpaceTabPage_declarator_list;
+       public static String WhiteSpaceTabPage_declarator_list_before_comma;
+       public static String WhiteSpaceTabPage_declarator_list_after_comma;
+       public static String WhiteSpaceTabPage_expression_list;
+       public static String WhiteSpaceTabPage_expression_list_before_comma;
+       public static String WhiteSpaceTabPage_expression_list_after_comma;
+       public static String WhiteSpaceTabPage_initializer_list;
+       public static String WhiteSpaceTabPage_calls;
+       public static String WhiteSpaceTabPage_calls_before_comma_in_function_args;
+       public static String WhiteSpaceTabPage_calls_after_comma_in_function_args;
+       public static String WhiteSpaceTabPage_statements;
+       public static String WhiteSpaceTabPage_blocks;
+       public static String WhiteSpaceTabPage_switch;
+       public static String WhiteSpaceTabPage_switch_before_case_colon;
+       public static String WhiteSpaceTabPage_switch_before_default_colon;
+       public static String WhiteSpaceTabPage_do;
+       public static String WhiteSpaceTabPage_try;
+       public static String WhiteSpaceTabPage_if;
+       public static String WhiteSpaceTabPage_for;
+       public static String WhiteSpaceTabPage_labels;
+       public static String WhiteSpaceTabPage_template_arguments;
+       public static String WhiteSpaceTabPage_template_parameters;
+       public static String WhiteSpaceTabPage_conditionals;
+       public static String WhiteSpaceTabPage_typecasts;
+       public static String WhiteSpaceTabPage_parenexpr;
+       public static String WhiteSpaceTabPage_declarations;
+       public static String WhiteSpaceTabPage_expressions;
+       public static String WhiteSpaceTabPage_arrays;
+       public static String WhiteSpaceTabPage_templates;
+       public static String WhiteSpaceTabPage_after_opening_brace;
+       public static String WhiteSpaceTabPage_after_closing_brace;
+       public static String WhiteSpaceTabPage_before_opening_brace;
+       public static String WhiteSpaceTabPage_before_closing_brace;
+       public static String WhiteSpaceTabPage_between_empty_braces;
+       public static String WhiteSpaceTabPage_after_opening_paren;
+       public static String WhiteSpaceTabPage_after_closing_paren;
+       public static String WhiteSpaceTabPage_before_opening_paren;
+       public static String WhiteSpaceTabPage_before_closing_paren;
+       public static String WhiteSpaceTabPage_between_empty_parens;
+       public static String WhiteSpaceTabPage_after_opening_bracket;
+       public static String WhiteSpaceTabPage_before_opening_bracket;
+       public static String WhiteSpaceTabPage_before_closing_bracket;
+       public static String WhiteSpaceTabPage_between_empty_brackets;
+       public static String WhiteSpaceTabPage_before_comma_in_params;
+       public static String WhiteSpaceTabPage_after_comma_in_params;
+       public static String WhiteSpaceTabPage_before_comma;
+       public static String WhiteSpaceTabPage_after_comma;
+       public static String WhiteSpaceTabPage_after_semicolon;
+       public static String WhiteSpaceTabPage_before_semicolon;
+       public static String WhiteSpaceTabPage_before_colon;
+       public static String WhiteSpaceTabPage_after_colon;
+       public static String WhiteSpaceTabPage_before_question;
+       public static String WhiteSpaceTabPage_after_question;
+       public static String WhiteSpaceTabPage_after_opening_angle_bracket;
+       public static String WhiteSpaceTabPage_after_closing_angle_bracket;
+       public static String WhiteSpaceTabPage_before_opening_angle_bracket;
+       public static String WhiteSpaceTabPage_before_closing_angle_bracket;
+//     public static String WhiteSpaceTabPage_before_parenthesized_expressions;
+       public static String WhiteSpaceTabPage_insert_space;
+       public static String WhiteSpaceTabPage_sort_by_c_element;
+       public static String WhiteSpaceTabPage_sort_by_syntax_element;
+//     public static String WhiteSpaceOptions_return;
+//     public static String WhiteSpaceOptions_throw;
+       public static String WhiteSpaceOptions_base_clause;
+       public static String WhiteSpaceOptions_before;
+       public static String WhiteSpaceOptions_after;
+       public static String WhiteSpaceOptions_operator;
+       public static String WhiteSpaceOptions_assignment_operator;
+       public static String WhiteSpaceOptions_binary_operator;
+       public static String WhiteSpaceOptions_unary_operator;
+       public static String WhiteSpaceOptions_prefix_operator;
+       public static String WhiteSpaceOptions_postfix_operator;
+       public static String WhiteSpaceOptions_opening_paren;
+       public static String WhiteSpaceOptions_catch;
+       public static String WhiteSpaceOptions_for;
+       public static String WhiteSpaceOptions_if;
+       public static String WhiteSpaceOptions_switch;
+       public static String WhiteSpaceOptions_while;
+       public static String WhiteSpaceOptions_function_declaration;
+       public static String WhiteSpaceOptions_exception_specification;
+       public static String WhiteSpaceOptions_function;
+       public static String WhiteSpaceOptions_function_call;
+       public static String WhiteSpaceOptions_paren_expr;
+       public static String WhiteSpaceOptions_type_cast;
+       public static String WhiteSpaceOptions_template_arguments;
+       public static String WhiteSpaceOptions_template_parameters;
+       public static String WhiteSpaceOptions_closing_paren;
+       public static String WhiteSpaceOptions_opening_brace;
+       public static String WhiteSpaceOptions_closing_brace;
+       public static String WhiteSpaceOptions_opening_bracket;
+       public static String WhiteSpaceOptions_closing_bracket;
+       public static String WhiteSpaceOptions_class_decl;
+       public static String WhiteSpaceOptions_initializer_list;
+       public static String WhiteSpaceOptions_block;
+       public static String WhiteSpaceOptions_arrays;
+       public static String WhiteSpaceOptions_arguments;
+       public static String WhiteSpaceOptions_parameters;
+       public static String WhiteSpaceOptions_lists;
+       public static String WhiteSpaceOptions_expression_list;
+       public static String WhiteSpaceOptions_declarator_list;
+       public static String WhiteSpaceOptions_colon;
+       public static String WhiteSpaceOptions_conditional;
+       public static String WhiteSpaceOptions_label;
+       public static String WhiteSpaceOptions_comma;
+       public static String WhiteSpaceOptions_semicolon;
+       public static String WhiteSpaceOptions_question_mark;
+       public static String WhiteSpaceOptions_between_empty_parens;
+       public static String WhiteSpaceOptions_between_empty_braces;
+       public static String WhiteSpaceOptions_between_empty_brackets;
+       public static String WhiteSpaceOptions_function_decl;
+       public static String WhiteSpaceOptions_case;
+       public static String WhiteSpaceOptions_default;
+       public static String WhiteSpaceOptions_statements;
+       public static String WhiteSpaceOptions_before_opening_paren;
+       public static String WhiteSpaceOptions_after_opening_paren;
+       public static String WhiteSpaceOptions_before_closing_paren;
+       public static String WhiteSpaceOptions_after_closing_paren;
+       public static String WhiteSpaceOptions_before_opening_brace;
+       public static String WhiteSpaceOptions_after_opening_brace;
+       public static String WhiteSpaceOptions_after_closing_brace;
+       public static String WhiteSpaceOptions_before_closing_brace;
+       public static String WhiteSpaceOptions_before_opening_bracket;
+       public static String WhiteSpaceOptions_after_opening_bracket;
+       public static String WhiteSpaceOptions_before_closing_bracket;
+       public static String WhiteSpaceOptions_before_opening_angle_bracket;
+       public static String WhiteSpaceOptions_after_opening_angle_bracket;
+       public static String WhiteSpaceOptions_before_closing_angle_bracket;
+       public static String WhiteSpaceOptions_after_closing_angle_bracket;
+       public static String WhiteSpaceOptions_before_operator;
+       public static String WhiteSpaceOptions_after_operator;
+       public static String WhiteSpaceOptions_before_comma;
+       public static String WhiteSpaceOptions_after_comma;
+       public static String WhiteSpaceOptions_after_colon;
+       public static String WhiteSpaceOptions_before_colon;
+       public static String WhiteSpaceOptions_before_semicolon;
+       public static String WhiteSpaceOptions_after_semicolon;
+       public static String WhiteSpaceOptions_before_question_mark;
+       public static String WhiteSpaceOptions_after_question_mark;
+//     public static String WhiteSpaceOptions_before_ellipsis;
+//     public static String WhiteSpaceOptions_after_ellipsis;
+//     public static String WhiteSpaceOptions_return_with_parenthesized_expression;
+//     public static String WhiteSpaceOptions_throw_with_parenthesized_expression;
+       public static String LineWrappingTabPage_base_clause;
+//     public static String LineWrappingTabPage_compact_if_else;
+       public static String LineWrappingTabPage_parameters;
+       public static String LineWrappingTabPage_arguments;
+       public static String LineWrappingTabPage_throws_clause;
+       public static String LineWrappingTabPage_constructor_initializer_list;
+       public static String LineWrappingTabPage_enum_decls;
+       public static String LineWrappingTabPage_enumerator_list;
+       public static String LineWrappingTabPage_initializer_list;
+       public static String LineWrappingTabPage_binary_exprs;
+       public static String LineWrappingTabPage_conditionals;
+       public static String LineWrappingTabPage_member_access;
+       public static String LineWrappingTabPage_stream_output;
+       public static String LineWrappingTabPage_indentation_default;
+       public static String LineWrappingTabPage_indentation_on_column;
+       public static String LineWrappingTabPage_indentation_by_one;
+       public static String LineWrappingTabPage_class_decls;
+       public static String LineWrappingTabPage_function_decls;
+       public static String LineWrappingTabPage_function_calls;
+       public static String LineWrappingTabPage_expressions;
+//     public static String LineWrappingTabPage_statements;
+       public static String LineWrappingTabPage_do_not_join_lines;
+       
+       public static String LineWrappingTabPage_base_clause_lowercase;
+//     public static String LineWrappingTabPage_compact_if_else_lowercase;
+       public static String LineWrappingTabPage_parameters_lowercase;
+       public static String LineWrappingTabPage_arguments_lowercase;
+       public static String LineWrappingTabPage_throws_clause_lowercase;
+       public static String LineWrappingTabPage_constructor_initializer_list_lowercase;
+       public static String LineWrappingTabPage_enum_decls_lowercase;
+       public static String LineWrappingTabPage_enumerator_list_lowercase;
+       public static String LineWrappingTabPage_initializer_list_lowercase;
+       public static String LineWrappingTabPage_binary_exprs_lowercase;
+       public static String LineWrappingTabPage_conditionals_lowercase;
+       public static String LineWrappingTabPage_member_access_lowercase;
+       public static String LineWrappingTabPage_stream_output_lowercase;
+       public static String LineWrappingTabPage_indentation_default_lowercase;
+       public static String LineWrappingTabPage_indentation_on_column_lowercase;
+       public static String LineWrappingTabPage_indentation_by_one_lowercase;
+       public static String LineWrappingTabPage_class_decls_lowercase;
+       public static String LineWrappingTabPage_function_decls_lowercase;
+       public static String LineWrappingTabPage_function_calls_lowercase;
+       public static String LineWrappingTabPage_expressions_lowercase;
+//     public static String LineWrappingTabPage_statements_lowercase;
+       public static String LineWrappingTabPage_assignment_alignment_lowercase;
+
+       public static String LineWrappingTabPage_wrapping_policy_label_text;
+       public static String LineWrappingTabPage_indentation_policy_label_text;
+       public static String LineWrappingTabPage_force_split_checkbox_text;
+       public static String LineWrappingTabPage_force_split_checkbox_multi_text;
+       public static String LineWrappingTabPage_line_width_for_preview_label_text;
+       public static String LineWrappingTabPage_line_width_for_preview_label_unit_text;
+       public static String LineWrappingTabPage_group;
+       public static String LineWrappingTabPage_multi_group;
+       public static String LineWrappingTabPage_multiple_selections;
+       public static String LineWrappingTabPage_occurences;
+       public static String LineWrappingTabPage_splitting_do_not_split;
+       public static String LineWrappingTabPage_splitting_wrap_when_necessary;
+       public static String LineWrappingTabPage_splitting_always_wrap_first_others_when_necessary;
+       public static String LineWrappingTabPage_splitting_wrap_always;
+       public static String LineWrappingTabPage_splitting_wrap_always_indent_all_but_first;
+       public static String LineWrappingTabPage_splitting_wrap_always_except_first_only_if_necessary;
+       public static String LineWrappingTabPage_width_indent;
+       public static String LineWrappingTabPage_width_indent_option_max_line_width;
+       public static String LineWrappingTabPage_width_indent_option_default_indent_wrapped;
+       public static String LineWrappingTabPage_width_indent_option_default_indent_array;
+       public static String LineWrappingTabPage_error_invalid_value;
+       public static String LineWrappingTabPage_assignment_alignment;
+       public static String AlreadyExistsDialog_message_profile_already_exists;
+       public static String AlreadyExistsDialog_message_profile_name_empty;
+       public static String AlreadyExistsDialog_dialog_title;
+       public static String AlreadyExistsDialog_dialog_label;
+       public static String AlreadyExistsDialog_rename_radio_button_desc;
+       public static String AlreadyExistsDialog_overwrite_radio_button_desc;
+//     public static String BlankLinesTabPage_preview_header;
+//     public static String BlankLinesTabPage_compilation_unit_group_title;
+//     public static String BlankLinesTabPage_compilation_unit_option_before_package;
+//     public static String BlankLinesTabPage_compilation_unit_option_after_package;
+//     public static String BlankLinesTabPage_compilation_unit_option_before_import;
+//     public static String BlankLinesTabPage_compilation_unit_option_after_import;
+//     public static String BlankLinesTabPage_compilation_unit_option_between_type_declarations;
+//     public static String BlankLinesTabPage_class_group_title;
+//     public static String BlankLinesTabPage_class_option_before_first_decl;
+//     public static String BlankLinesTabPage_class_option_before_decls_of_same_kind;
+//     public static String BlankLinesTabPage_class_option_before_member_class_decls;
+//     public static String BlankLinesTabPage_class_option_before_field_decls;
+//     public static String BlankLinesTabPage_class_option_before_method_decls;
+//     public static String BlankLinesTabPage_class_option_at_beginning_of_method_body;
+//     public static String BlankLinesTabPage_blank_lines_group_title;
+//     public static String BlankLinesTabPage_blank_lines_option_empty_lines_to_preserve;
+       public static String BracesTabPage_preview_header;
+       public static String BracesTabPage_position_same_line;
+       public static String BracesTabPage_position_next_line;
+       public static String BracesTabPage_position_next_line_indented;
+       public static String BracesTabPage_position_next_line_on_wrap;
+       public static String BracesTabPage_group_brace_positions_title;
+       public static String BracesTabPage_option_class_declaration;
+       public static String BracesTabPage_option_namespace_declaration;
+       public static String BracesTabPage_option_function_declaration;
+       public static String BracesTabPage_option_blocks;
+       public static String BracesTabPage_option_blocks_in_case;
+       public static String BracesTabPage_option_switch_case;
+       public static String BracesTabPage_option_initializer_list;
+       public static String BracesTabPage_option_keep_empty_initializer_list_on_one_line;
+       public static String CodingStyleConfigurationBlock_save_profile_dialog_title;
+       public static String CodingStyleConfigurationBlock_save_profile_error_title;
+       public static String CodingStyleConfigurationBlock_save_profile_error_message;
+       public static String CodingStyleConfigurationBlock_load_profile_dialog_title;
+       public static String CodingStyleConfigurationBlock_load_profile_error_title;
+       public static String CodingStyleConfigurationBlock_load_profile_error_message;
+       public static String CodingStyleConfigurationBlock_load_profile_error_too_new_title;
+       public static String CodingStyleConfigurationBlock_load_profile_error_too_new_message;
+       public static String CodingStyleConfigurationBlock_preview_title;
+       public static String CodingStyleConfigurationBlock_save_profile_overwrite_title;
+       public static String CodingStyleConfigurationBlock_save_profile_overwrite_message;
+       public static String CodingStyleConfigurationBlock_edit_button_desc;
+       public static String CodingStyleConfigurationBlock_remove_button_desc;
+       public static String CodingStyleConfigurationBlock_new_button_desc;
+       public static String CodingStyleConfigurationBlock_load_button_desc;
+       public static String CodingStyleConfigurationBlock_preview_label_text;
+       public static String CodingStyleConfigurationBlock_error_reading_xml_message;
+       public static String CodingStyleConfigurationBlock_error_serializing_xml_message;
+       public static String CodingStyleConfigurationBlock_delete_confirmation_title;
+       public static String CodingStyleConfigurationBlock_delete_confirmation_question;
+       public static String CommentsTabPage_preview_header;
+       public static String CommentsTabPage_group1_title;
+       public static String CommentsTabPage_preserve_white_space_before_line_comment;
+       public static String CommentsTabPage_line_width;
+       public static String CustomCodeFormatterBlock_formatter_name;
+       public static String CustomCodeFormatterBlock_default_formatter;
+       public static String CustomCodeFormatterBlock_formatter_note;
+       public static String CustomCodeFormatterBlock_contributed_formatter_warning;
+       public static String ControlStatementsTabPage_preview_header;
+       public static String ControlStatementsTabPage_general_group_title;
+       public static String ControlStatementsTabPage_general_group_insert_new_line_before_else_statements;
+       public static String ControlStatementsTabPage_general_group_insert_new_line_before_catch_statements;
+       public static String ControlStatementsTabPage_general_group_insert_new_line_before_while_in_do_statements;
+       public static String ControlStatementsTabPage_if_else_group_title;
+       public static String ControlStatementsTabPage_if_else_group_keep_then_on_same_line;
+       public static String ControlStatementsTabPage_if_else_group_keep_simple_if_on_one_line;
+       public static String ControlStatementsTabPage_if_else_group_keep_else_on_same_line;
+       public static String ControlStatementsTabPage_if_else_group_keep_else_if_on_one_line;
+//     public static String ControlStatementsTabPage_if_else_group_keep_guardian_clause_on_one_line;
+       public static String CreateProfileDialog_status_message_profile_with_this_name_already_exists;
+       public static String CreateProfileDialog_status_message_profile_name_is_empty;
+       public static String CreateProfileDialog_dialog_title;
+       public static String CreateProfileDialog_profile_name_label_text;
+       public static String CreateProfileDialog_base_profile_label_text;
+       public static String CreateProfileDialog_open_edit_dialog_checkbox_text;
+       public static String IndentationTabPage_preview_header;
+       public static String IndentationTabPage_general_group_title;
+       public static String IndentationTabPage_general_group_option_tab_policy;
+       public static String IndentationTabPage_general_group_option_tab_policy_SPACE;
+       public static String IndentationTabPage_general_group_option_tab_policy_TAB;
+       public static String IndentationTabPage_general_group_option_tab_policy_MIXED;
+       public static String IndentationTabPage_general_group_option_tab_size;
+       public static String IndentationTabPage_general_group_option_indent_size;
+//     public static String IndentationTabPage_field_alignment_group_title;
+//     public static String IndentationTabPage_field_alignment_group_align_fields_in_columns;
+       public static String IndentationTabPage_indent_group_title;
+       public static String IndentationTabPage_class_group_option_indent_access_specifiers_within_class_body;
+       public static String IndentationTabPage_class_group_option_indent_declarations_compare_to_access_specifiers;
+       public static String IndentationTabPage_block_group_option_indent_statements_compare_to_body;
+       public static String IndentationTabPage_block_group_option_indent_statements_compare_to_block;
+       public static String IndentationTabPage_switch_group_option_indent_statements_within_switch_body;
+       public static String IndentationTabPage_switch_group_option_indent_statements_within_case_body;
+       public static String IndentationTabPage_switch_group_option_indent_break_statements;
+       public static String IndentationTabPage_namespace_group_option_indent_declarations_within_namespace;
+    public static String IndentationTabPage_indent_empty_lines;
+       public static String IndentationTabPage_use_tabs_only_for_leading_indentations;
+       public static String ModifyDialog_dialog_title;
+       public static String ModifyDialog_apply_button;
+       public static String ModifyDialog_tabpage_braces_title;
+       public static String ModifyDialog_tabpage_indentation_title;
+       public static String ModifyDialog_tabpage_whitespace_title;
+//     public static String ModifyDialog_tabpage_blank_lines_title;
+       public static String ModifyDialog_tabpage_new_lines_title;
+       public static String ModifyDialog_tabpage_control_statements_title;
+       public static String ModifyDialog_tabpage_line_wrapping_title;
+       public static String ModifyDialog_tabpage_comments_title;
+       public static String ModifyDialogTabPage_preview_label_text;
+       public static String ModifyDialogTabPage_error_msg_values_text_unassigned;
+       public static String ModifyDialogTabPage_error_msg_values_items_text_unassigned;
+       public static String ModifyDialogTabPage_NumberPreference_error_invalid_key;
+       public static String ModifyDialogTabPage_NumberPreference_error_invalid_value;
+       public static String NewLinesTabPage_preview_header;
+       public static String NewLinesTabPage_newlines_group_title;
+       public static String NewLinesTabPage_newlines_group_option_before_colon_in_constructor_initializer_list;
+//     public static String NewLinesTabPage_newlines_group_option_empty_class_body;
+//     public static String NewLinesTabPage_newlines_group_option_empty_method_body;
+//     public static String NewLinesTabPage_newlines_group_option_empty_block;
+//     public static String NewLinesTabPage_newlines_group_option_empty_end_of_file;
+//     public static String NewLinesTabPage_empty_statement_group_title;
+//     public static String NewLinesTabPage_emtpy_statement_group_option_empty_statement_on_new_line;
+//     public static String NewLinesTabPage_arrayInitializer_group_title;
+//     public static String NewLinesTabPage_array_group_option_after_opening_brace_of_array_initializer;
+//     public static String NewLinesTabPage_array_group_option_before_closing_brace_of_array_initializer;
+//     public static String NewLinesTabPage_annotations_group_title;
+//     public static String NewLinesTabPage_annotations_group_option_after_annotation;
+       public static String ProfileManager_kandr_profile_name;
+       public static String ProfileManager_allman_profile_name;
+       public static String ProfileManager_gnu_profile_name;
+       public static String ProfileManager_whitesmiths_profile_name;
+       public static String ProfileManager_unmanaged_profile;
+       public static String ProfileManager_unmanaged_profile_with_name;
+
+       public static String CPreview_formatter_exception;
+
+       private FormatterMessages() {
+               // Do not instantiate
+       }
+
+       static {
+               NLS.initializeMessages(FormatterMessages.class.getName(), FormatterMessages.class);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.properties
new file mode 100644 (file)
index 0000000..779d7ef
--- /dev/null
@@ -0,0 +1,474 @@
+###############################################################################
+# Copyright (c) 2000, 2011 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+#     istvan@benedek-home.de - 103706 [formatter] indent empty lines
+#     Aaron Luchko, aluchko@redhat.com - 105926 [Formatter] Exporting Unnamed profile fails silently
+#     Sergey Prigogin (Google)
+#     Anton Leherbauer (Wind River Systems)
+###############################################################################
+
+WhiteSpaceTabPage_assignments=Assignments
+WhiteSpaceTabPage_assignments_before_assignment_operator=before assignment operator
+WhiteSpaceTabPage_assignments_after_assignment_operator=after assignment operator
+
+WhiteSpaceTabPage_operators=Operators
+WhiteSpaceTabPage_operators_before_binary_operators=before binary operators
+WhiteSpaceTabPage_operators_after_binary_operators=after binary operators
+WhiteSpaceTabPage_operators_before_unary_operators=before unary operators
+WhiteSpaceTabPage_operators_after_unary_operators=after unary operators
+WhiteSpaceTabPage_operators_before_prefix_operators=before prefix operators
+WhiteSpaceTabPage_operators_after_prefix_operators=after prefix operators
+WhiteSpaceTabPage_operators_before_postfix_operators=before postfix operators
+WhiteSpaceTabPage_operators_after_postfix_operators=after postfix operators
+
+WhiteSpaceTabPage_classes=Types
+WhiteSpaceTabPage_classes_before_opening_brace_of_a_class=before opening brace of a class
+WhiteSpaceTabPage_classes_before_colon_of_base_clause=before colon of base clause
+WhiteSpaceTabPage_classes_after_colon_of_base_clause=after colon of base clause
+WhiteSpaceTabPage_classes_before_comma_base_types=before comma in base clause
+WhiteSpaceTabPage_classes_after_comma_base_types=after comma in base clause
+WhiteSpaceTabPage_functions=Functions
+WhiteSpaceTabPage_declarator_list=Declarator list
+WhiteSpaceTabPage_declarator_list_before_comma=before comma in declarator list
+WhiteSpaceTabPage_declarator_list_after_comma=after comma in declarator list
+WhiteSpaceTabPage_expression_list=Expression list
+WhiteSpaceTabPage_expression_list_before_comma=before comma in expression list
+WhiteSpaceTabPage_expression_list_after_comma=after comma in expression list
+WhiteSpaceTabPage_initializer_list=Initializer list
+WhiteSpaceTabPage_exception_specifications=Exception specifications
+
+WhiteSpaceTabPage_calls=Function invocations
+
+WhiteSpaceTabPage_calls_before_comma_in_function_args=before comma in function arguments
+WhiteSpaceTabPage_calls_after_comma_in_function_args=after comma in function arguments
+WhiteSpaceTabPage_statements=Control statements
+
+WhiteSpaceTabPage_blocks=Blocks
+
+WhiteSpaceTabPage_switch='switch'
+WhiteSpaceTabPage_switch_before_case_colon=before colon in case
+WhiteSpaceTabPage_switch_before_default_colon=before colon in default
+
+WhiteSpaceTabPage_do='while' & 'do while'
+
+WhiteSpaceTabPage_try='catch'
+
+WhiteSpaceTabPage_if='if else'
+
+WhiteSpaceTabPage_for='for'
+#WhiteSpaceTabPage_for_before_comma_init=before comma in initialization
+#WhiteSpaceTabPage_for_after_comma_init=after comma in initialization
+#WhiteSpaceTabPage_for_before_comma_inc=before comma in increments
+#WhiteSpaceTabPage_for_after_comma_inc=after comma in increments
+
+WhiteSpaceTabPage_labels=Labels
+WhiteSpaceTabPage_template_arguments=Template arguments
+WhiteSpaceTabPage_template_parameters=Template parameters
+
+WhiteSpaceTabPage_conditionals=Conditionals
+
+WhiteSpaceTabPage_typecasts=Type casts
+
+WhiteSpaceTabPage_parenexpr=Parenthesized expressions
+WhiteSpaceTabPage_declarations=Declarations
+WhiteSpaceTabPage_expressions=Expressions
+WhiteSpaceTabPage_arrays=Arrays
+WhiteSpaceTabPage_templates=Templates
+WhiteSpaceTabPage_after_opening_brace=after opening brace
+WhiteSpaceTabPage_after_closing_brace=after closing brace
+WhiteSpaceTabPage_before_opening_brace=before opening brace
+WhiteSpaceTabPage_before_closing_brace=before closing brace
+WhiteSpaceTabPage_between_empty_braces=between empty braces
+
+WhiteSpaceTabPage_after_opening_paren=after opening parenthesis
+WhiteSpaceTabPage_after_closing_paren=after closing parenthesis
+WhiteSpaceTabPage_before_opening_paren=before opening parenthesis
+WhiteSpaceTabPage_before_closing_paren=before closing parenthesis
+WhiteSpaceTabPage_between_empty_parens=between empty parenthesis
+
+WhiteSpaceTabPage_after_opening_bracket=after opening bracket
+WhiteSpaceTabPage_before_opening_bracket=before opening bracket
+WhiteSpaceTabPage_before_closing_bracket=before closing bracket
+WhiteSpaceTabPage_between_empty_brackets=between empty brackets
+
+WhiteSpaceTabPage_before_comma_in_params=before comma in parameters
+WhiteSpaceTabPage_after_comma_in_params=after comma in parameters
+
+WhiteSpaceTabPage_before_comma=before comma
+WhiteSpaceTabPage_after_comma=after comma
+
+WhiteSpaceTabPage_after_semicolon=after semicolon
+WhiteSpaceTabPage_before_semicolon=before semicolon
+
+WhiteSpaceTabPage_before_colon=before colon
+WhiteSpaceTabPage_after_colon=after colon
+
+WhiteSpaceTabPage_before_question=before question mark
+WhiteSpaceTabPage_after_question=after question mark
+
+WhiteSpaceTabPage_after_opening_angle_bracket=after opening angle bracket
+WhiteSpaceTabPage_after_closing_angle_bracket=after closing angle bracket
+WhiteSpaceTabPage_before_opening_angle_bracket=before opening angle bracket
+WhiteSpaceTabPage_before_closing_angle_bracket=before closing angle bracket
+#WhiteSpaceTabPage_before_parenthesized_expressions=before parenthesized expressions
+
+WhiteSpaceTabPage_sort_by_c_element=Sort options by C/C++ element
+WhiteSpaceTabPage_sort_by_syntax_element=Sort options by Syntax element
+
+WhiteSpaceOptions_base_clause=Base clause
+WhiteSpaceOptions_before=Before
+WhiteSpaceOptions_after=After
+
+WhiteSpaceOptions_operator=Operator
+WhiteSpaceOptions_assignment_operator=Assignment operator
+WhiteSpaceOptions_binary_operator=Binary operator
+WhiteSpaceOptions_unary_operator=Unary operator
+WhiteSpaceOptions_prefix_operator=Prefix operator
+WhiteSpaceOptions_postfix_operator=Postfix operator
+
+WhiteSpaceOptions_opening_paren=Opening parenthesis
+WhiteSpaceOptions_catch='catch'
+WhiteSpaceOptions_for='for'
+WhiteSpaceOptions_if='if'
+WhiteSpaceOptions_switch='switch'
+WhiteSpaceOptions_while='while'
+WhiteSpaceOptions_function_declaration=Function declaration
+WhiteSpaceOptions_function=Function
+WhiteSpaceOptions_exception_specification=Exception specification
+WhiteSpaceOptions_function_call=Function call
+WhiteSpaceOptions_paren_expr=Parenthesized expression
+
+WhiteSpaceOptions_type_cast=Type cast
+WhiteSpaceOptions_template_arguments=Template arguments
+WhiteSpaceOptions_template_parameters=Template parameters
+
+WhiteSpaceOptions_closing_paren=Closing parenthesis
+
+WhiteSpaceOptions_opening_brace=Opening brace
+WhiteSpaceOptions_closing_brace=Closing brace
+WhiteSpaceOptions_opening_bracket=Opening bracket
+WhiteSpaceOptions_closing_bracket=Closing bracket
+WhiteSpaceOptions_class_decl=Type declaration
+WhiteSpaceOptions_initializer_list=Initializer list
+WhiteSpaceOptions_block=Block
+
+WhiteSpaceOptions_arrays=Arrays
+WhiteSpaceOptions_arguments=Arguments
+#WhiteSpaceOptions_initialization=Initialization
+#WhiteSpaceOptions_incrementation=Increment
+WhiteSpaceOptions_parameters=Parameters
+
+WhiteSpaceOptions_lists=Lists
+WhiteSpaceOptions_expression_list=Expression list
+WhiteSpaceOptions_declarator_list=Declarator list
+#WhiteSpaceOptions_return='return'
+#WhiteSpaceOptions_throw='throw'
+WhiteSpaceOptions_colon=Colon
+WhiteSpaceOptions_conditional=Conditional
+WhiteSpaceOptions_label=Label
+WhiteSpaceOptions_comma=Comma
+
+WhiteSpaceOptions_semicolon=Semicolon
+WhiteSpaceOptions_question_mark=Question mark
+WhiteSpaceOptions_between_empty_parens=Between empty parenthesis
+WhiteSpaceOptions_between_empty_braces=Between empty braces
+WhiteSpaceOptions_between_empty_brackets=Between empty brackets
+WhiteSpaceOptions_function_decl=Function declaration
+WhiteSpaceOptions_case='case'
+WhiteSpaceOptions_default='default'
+WhiteSpaceOptions_statements=Statements
+
+WhiteSpaceOptions_before_opening_paren=Before opening parenthesis
+WhiteSpaceOptions_after_opening_paren=After opening parenthesis
+WhiteSpaceOptions_before_closing_paren=Before closing parenthesis
+
+WhiteSpaceOptions_after_closing_paren=After closing parenthesis
+WhiteSpaceOptions_before_opening_brace=Before opening brace
+WhiteSpaceOptions_after_opening_brace=After opening brace
+WhiteSpaceOptions_after_closing_brace=After closing brace
+WhiteSpaceOptions_before_closing_brace=Before closing brace
+WhiteSpaceOptions_before_opening_bracket=Before opening bracket
+WhiteSpaceOptions_after_opening_bracket=After opening bracket
+WhiteSpaceOptions_before_closing_bracket=Before closing bracket
+
+WhiteSpaceOptions_before_opening_angle_bracket=Before opening angle bracket
+WhiteSpaceOptions_after_opening_angle_bracket=After opening angle bracket
+WhiteSpaceOptions_before_closing_angle_bracket=Before closing angle bracket
+#WhiteSpaceOptions_return_with_parenthesized_expression='return' with parenthesized expression
+#WhiteSpaceOptions_throw_with_parenthesized_expression='throws' with parenthesized expression
+WhiteSpaceOptions_after_closing_angle_bracket=After closing angle bracket
+
+WhiteSpaceOptions_before_operator=Before operator
+WhiteSpaceOptions_after_operator=After operator
+WhiteSpaceOptions_before_comma=Before comma
+WhiteSpaceOptions_after_comma=After comma
+WhiteSpaceOptions_after_colon=After colon
+WhiteSpaceOptions_before_colon=Before colon
+WhiteSpaceOptions_before_semicolon=Before semicolon
+WhiteSpaceOptions_after_semicolon=After semicolon
+WhiteSpaceOptions_before_question_mark=Before question mark
+WhiteSpaceOptions_after_question_mark=After question mark
+
+#WhiteSpaceOptions_before_ellipsis=Before Ellipsis
+#WhiteSpaceOptions_after_ellipsis=After Ellipsis
+
+WhiteSpaceTabPage_insert_space=&Insert space:
+
+LineWrappingTabPage_base_clause=Base-clause
+#LineWrappingTabPage_compact_if_else=Compact 'if else'
+LineWrappingTabPage_parameters=Parameters
+LineWrappingTabPage_arguments=Arguments
+LineWrappingTabPage_throws_clause=Exception specification
+LineWrappingTabPage_constructor_initializer_list=Constructor initializer list
+#LineWrappingTabPage_object_allocation=Object allocation arguments
+LineWrappingTabPage_enum_decls='enum' declaration
+LineWrappingTabPage_enumerator_list=Enumerator list
+LineWrappingTabPage_initializer_list=Initializer list
+LineWrappingTabPage_binary_exprs=Binary expressions
+LineWrappingTabPage_conditionals=Conditionals
+LineWrappingTabPage_member_access=Member access
+LineWrappingTabPage_stream_output=Stream output
+LineWrappingTabPage_indentation_default=Default indentation
+LineWrappingTabPage_indentation_on_column=Indent on column
+LineWrappingTabPage_indentation_by_one=Indent by one
+LineWrappingTabPage_class_decls=Class declarations
+LineWrappingTabPage_function_decls=Function declarations
+LineWrappingTabPage_function_calls=Function calls
+LineWrappingTabPage_expressions=Expressions
+#LineWrappingTabPage_statements=Statements
+LineWrappingTabPage_do_not_join_lines=Never join already wrapped lin&es
+
+#lower case table entries description;
+LineWrappingTabPage_base_clause_lowercase=base-clause
+#LineWrappingTabPage_compact_if_else_lowercase=compact 'if else'
+LineWrappingTabPage_parameters_lowercase=parameters
+LineWrappingTabPage_arguments_lowercase=arguments
+LineWrappingTabPage_throws_clause_lowercase=exception specification
+LineWrappingTabPage_constructor_initializer_list_lowercase=constructor initializer list
+#LineWrappingTabPage_object_allocation_lowercase=object allocation arguments
+LineWrappingTabPage_enum_decls_lowercase='enum' declaration
+LineWrappingTabPage_enumerator_list_lowercase=enumerator list
+LineWrappingTabPage_initializer_list_lowercase=initializer list
+LineWrappingTabPage_binary_exprs_lowercase=binary expressions
+LineWrappingTabPage_conditionals_lowercase=conditionals
+LineWrappingTabPage_member_access_lowercase=member access
+LineWrappingTabPage_stream_output_lowercase=stream output
+LineWrappingTabPage_indentation_default_lowercase=default indentation
+LineWrappingTabPage_indentation_on_column_lowercase=indent on column
+LineWrappingTabPage_indentation_by_one_lowercase=indent by one
+LineWrappingTabPage_class_decls_lowercase=class declarations
+LineWrappingTabPage_function_decls_lowercase=function declarations
+LineWrappingTabPage_function_calls_lowercase=function calls
+LineWrappingTabPage_expressions_lowercase=expressions
+#LineWrappingTabPage_statements_lowercase=statements
+LineWrappingTabPage_assignment_alignment_lowercase=assignments
+
+LineWrappingTabPage_wrapping_policy_label_text=Lin&e wrapping policy:
+LineWrappingTabPage_indentation_policy_label_text=Indent&ation policy:
+LineWrappingTabPage_force_split_checkbox_text=&Force split, even if line is shorter than maximum width
+LineWrappingTabPage_force_split_checkbox_multi_text=&Force split, even if line is shorter than maximum width
+LineWrappingTabPage_line_width_for_preview_label_text=&Set line width for preview window:
+LineWrappingTabPage_line_width_for_preview_label_unit_text=character(s)
+LineWrappingTabPage_group=Settings for {0}
+LineWrappingTabPage_multi_group=Settings for {0} ({1} items)
+LineWrappingTabPage_multiple_selections=Settings for multiple selections ({0} items)
+LineWrappingTabPage_occurences={0} ({1} of {2})
+LineWrappingTabPage_splitting_do_not_split=Do not wrap
+LineWrappingTabPage_splitting_wrap_when_necessary=Wrap only when necessary
+LineWrappingTabPage_splitting_always_wrap_first_others_when_necessary=Always wrap first element, others when necessary
+LineWrappingTabPage_splitting_wrap_always=Wrap all elements, every element on a new line
+LineWrappingTabPage_splitting_wrap_always_indent_all_but_first=Wrap all elements, indent all but the first element
+LineWrappingTabPage_splitting_wrap_always_except_first_only_if_necessary=Wrap all elements, except first element if not necessary
+LineWrappingTabPage_width_indent=Line width and indentation levels
+LineWrappingTabPage_width_indent_option_max_line_width=Ma&ximum line width:
+LineWrappingTabPage_width_indent_option_default_indent_wrapped=Defa&ult indentation for wrapped lines:
+LineWrappingTabPage_width_indent_option_default_indent_array=Default indentation for initializer lists:
+LineWrappingTabPage_error_invalid_value=The key ''{0}'' contained an invalid value; resetting to defaults.
+LineWrappingTabPage_assignment_alignment=Assignments
+
+
+AlreadyExistsDialog_message_profile_already_exists=A profile with this name already exists.
+AlreadyExistsDialog_message_profile_name_empty=Profile name is empty
+AlreadyExistsDialog_dialog_title=Load Profile
+AlreadyExistsDialog_dialog_label=A profile with the name ''{0}'' already exists in this workspace. What would you like to do?
+AlreadyExistsDialog_rename_radio_button_desc=&Rename the imported profile:
+AlreadyExistsDialog_overwrite_radio_button_desc=&Overwrite the existing profile.
+
+
+#BlankLinesTabPage_preview_header=Blank Lines
+#BlankLinesTabPage_compilation_unit_group_title=Blank lines in compilation unit
+#BlankLinesTabPage_compilation_unit_option_before_package=Before p&ackage declaration:
+#BlankLinesTabPage_compilation_unit_option_after_package=After packa&ge declaration:
+#BlankLinesTabPage_compilation_unit_option_before_import=&Before import declaration:
+#BlankLinesTabPage_compilation_unit_option_after_import=After import de&claration:
+#BlankLinesTabPage_compilation_unit_option_between_type_declarations=Between class declarat&ions:
+
+#BlankLinesTabPage_class_group_title=Blank lines within class declarations
+#BlankLinesTabPage_class_option_before_first_decl=Before &first declaration:
+#BlankLinesTabPage_class_option_before_decls_of_same_kind=Before declarations of the same &kind:
+#BlankLinesTabPage_class_option_before_member_class_decls=Before member cla&ss declarations:
+#BlankLinesTabPage_class_option_before_field_decls=B&efore field declarations:
+#BlankLinesTabPage_class_option_before_method_decls=Before met&hod declarations:
+#BlankLinesTabPage_class_option_at_beginning_of_method_body= At beginning of method bod&y:
+
+#BlankLinesTabPage_blank_lines_group_title=Existing blank lines
+#BlankLinesTabPage_blank_lines_option_empty_lines_to_preserve=N&umber of empty lines to preserve:
+
+BracesTabPage_preview_header=Braces
+BracesTabPage_position_same_line=Same line
+BracesTabPage_position_next_line=Next line
+BracesTabPage_position_next_line_indented=Next line indented
+BracesTabPage_position_next_line_on_wrap=Next line on wrap
+
+BracesTabPage_group_brace_positions_title=Brace positions
+BracesTabPage_option_class_declaration=&Class declaration:
+BracesTabPage_option_namespace_declaration=&Namespace declaration:
+BracesTabPage_option_function_declaration=&Function declaration:
+BracesTabPage_option_blocks=&Blocks:
+BracesTabPage_option_blocks_in_case=Bloc&ks in case statement:
+BracesTabPage_option_switch_case='&switch' statement:
+BracesTabPage_option_initializer_list=Initiali&zer list:
+BracesTabPage_option_keep_empty_initializer_list_on_one_line=Keep empty &initializer list on one line
+CodingStyleConfigurationBlock_save_profile_dialog_title=Export Profile
+CodingStyleConfigurationBlock_save_profile_error_title=Export Profile
+CodingStyleConfigurationBlock_save_profile_error_message=Could not export the profiles.
+CodingStyleConfigurationBlock_load_profile_dialog_title=Import Profile
+CodingStyleConfigurationBlock_load_profile_error_title=Import Profile
+CodingStyleConfigurationBlock_load_profile_error_message=Import failed. Not a valid profile.
+CodingStyleConfigurationBlock_load_profile_error_too_new_title=Importing Profile
+CodingStyleConfigurationBlock_load_profile_error_too_new_message=This profile has been created with \
+a more recent CDT build than the one you are using. Due to changes in the code formatter, \
+some older settings might be reset to their default values and newer settings are ignored. Please note \
+that upgrading profiles from older to newer builds is fully supported.
+CodingStyleConfigurationBlock_preview_title=A sample source file for the code formatter preview
+CodingStyleConfigurationBlock_save_profile_overwrite_title=Export Profile
+CodingStyleConfigurationBlock_save_profile_overwrite_message={0} " already exists.\nDo you want to replace it?"
+CodingStyleConfigurationBlock_edit_button_desc=&Edit...
+CodingStyleConfigurationBlock_remove_button_desc=&Remove
+CodingStyleConfigurationBlock_new_button_desc=Ne&w...
+CodingStyleConfigurationBlock_load_button_desc=I&mport...
+CodingStyleConfigurationBlock_preview_label_text=Prev&iew:
+CodingStyleConfigurationBlock_error_reading_xml_message=Problems reading profiles from XML
+CodingStyleConfigurationBlock_error_serializing_xml_message=Problems serializing the profiles to XML
+CodingStyleConfigurationBlock_delete_confirmation_title=Confirm Remove
+CodingStyleConfigurationBlock_delete_confirmation_question=Are you sure you want to remove profile ''{0}''?
+
+CustomCodeFormatterBlock_formatter_name=Code &Formatter:
+CustomCodeFormatterBlock_default_formatter=[built-in]
+CustomCodeFormatterBlock_formatter_note=Note:
+CustomCodeFormatterBlock_contributed_formatter_warning=Contributed formatters may not respect all code style settings.
+
+
+CommentsTabPage_preview_header=Comments
+CommentsTabPage_group1_title=Line comments
+CommentsTabPage_preserve_white_space_before_line_comment=Preserve white space between code and line comments if possible
+CommentsTabPage_line_width=Minimum distance between code and line comments:
+
+
+ControlStatementsTabPage_preview_header=If...else
+ControlStatementsTabPage_general_group_title=General
+ControlStatementsTabPage_general_group_insert_new_line_before_else_statements=Insert new line before '&else' in an 'if' statement
+ControlStatementsTabPage_general_group_insert_new_line_before_catch_statements=Insert new line before '&catch' in a 'try' statement
+ControlStatementsTabPage_general_group_insert_new_line_before_while_in_do_statements=Insert new line before 'w&hile' in a 'do' statement
+
+ControlStatementsTabPage_if_else_group_title='if else'
+ControlStatementsTabPage_if_else_group_keep_then_on_same_line=Keep 'then' statement &on same line
+ControlStatementsTabPage_if_else_group_keep_simple_if_on_one_line=Keep &simple 'if' on one line
+ControlStatementsTabPage_if_else_group_keep_else_on_same_line=Keep 'else' st&atement on same line
+ControlStatementsTabPage_if_else_group_keep_else_if_on_one_line=&Keep 'else if' on one line
+#ControlStatementsTabPage_if_else_group_keep_guardian_clause_on_one_line=Keep 'return' or 'throw' cla&use on one line
+
+CreateProfileDialog_status_message_profile_with_this_name_already_exists=A profile with this name already exists.
+CreateProfileDialog_status_message_profile_name_is_empty=Profile name is empty
+CreateProfileDialog_dialog_title=New Code Formatter Profile
+CreateProfileDialog_profile_name_label_text=&Profile name:
+CreateProfileDialog_base_profile_label_text=I&nitialize settings with the following profile:
+CreateProfileDialog_open_edit_dialog_checkbox_text=&Open the edit dialog now
+
+IndentationTabPage_preview_header=Indentation
+
+IndentationTabPage_general_group_title=General settings
+IndentationTabPage_general_group_option_tab_policy=Tab polic&y:
+IndentationTabPage_general_group_option_tab_policy_SPACE=Spaces only
+IndentationTabPage_general_group_option_tab_policy_TAB=Tabs only
+IndentationTabPage_general_group_option_tab_policy_MIXED=Mixed
+IndentationTabPage_general_group_option_tab_size=Tab &size:
+IndentationTabPage_general_group_option_indent_size=&Indentation size:
+
+#IndentationTabPage_field_alignment_group_title=Alignment of fields in class declarations
+#IndentationTabPage_field_alignment_group_align_fields_in_columns=&Align fields in columns
+
+IndentationTabPage_indent_group_title=Indent
+
+IndentationTabPage_class_group_option_indent_access_specifiers_within_class_body='public', 'protected', 'private' within class &body
+IndentationTabPage_class_group_option_indent_declarations_compare_to_access_specifiers=De&clarations relative to 'public', 'protected', 'private'
+IndentationTabPage_block_group_option_indent_statements_compare_to_body=Stat&ements within function body
+IndentationTabPage_block_group_option_indent_statements_compare_to_block=Statements within bl&ocks
+IndentationTabPage_namespace_group_option_indent_declarations_within_namespace=Declarations within '&namespace' definition
+IndentationTabPage_indent_empty_lines=Empty lines
+
+IndentationTabPage_switch_group_option_indent_statements_within_switch_body=Statements wit&hin 'switch' body
+IndentationTabPage_switch_group_option_indent_statements_within_case_body=Statements within 'c&ase' body
+IndentationTabPage_switch_group_option_indent_break_statements='brea&k' statements
+
+IndentationTabPage_use_tabs_only_for_leading_indentations=Use tabs only for leading indentations
+
+ModifyDialog_tabpage_braces_title=B&races
+ModifyDialog_ProfileName_Label=&Profile name:
+ModifyDialog_NewCreated_Status=A new profile will be created.
+ModifyDialog_tabpage_indentation_title=In&dentation
+ModifyDialog_tabpage_whitespace_title=&White Space
+#ModifyDialog_tabpage_blank_lines_title=Bla&nk Lines
+ModifyDialog_tabpage_new_lines_title=New &Lines
+ModifyDialog_tabpage_control_statements_title=Con&trol Statements
+ModifyDialog_tabpage_line_wrapping_title=Line Wra&pping
+ModifyDialog_tabpage_comments_title=Co&mments
+
+ModifyDialog_dialog_title=Profile ''{0}''
+ModifyDialog_apply_button=Apply
+ModifyDialog_Export_Button=&Export...
+ModifyDialog_Duplicate_Status=A profile with this name already exists.
+ModifyDialog_BuiltIn_Status=This is a built-in profile, change the name to create a new profile.
+ModifyDialog_Shared_Status=This is a shared profile, change the name to create a new profile.
+ModifyDialog_EmptyName_Status=Profile name is empty.
+
+ModifyDialogTabPage_preview_label_text=Pre&view:
+ModifyDialogTabPage_error_msg_values_text_unassigned=Values and text must be assigned.
+ModifyDialogTabPage_error_msg_values_items_text_unassigned=Values, items and text must be assigned.
+ModifyDialogTabPage_NumberPreference_error_invalid_key=The key {0} does not yield a valid integer value.
+ModifyDialogTabPage_NumberPreference_error_invalid_value=Invalid value: Please enter a number between {0} and {1}.
+
+NewLinesTabPage_preview_header=New lines
+NewLinesTabPage_newlines_group_title=Insert new line
+
+NewLinesTabPage_newlines_group_option_before_colon_in_constructor_initializer_list=before colon in constructor initializer list
+#NewLinesTabPage_newlines_group_option_empty_class_body=in empty &class body
+#NewLinesTabPage_newlines_group_option_empty_method_body=in empt&y method body
+#NewLinesTabPage_newlines_group_option_empty_block=in empty &block
+#NewLinesTabPage_newlines_group_option_empty_end_of_file=at end of &file
+#NewLinesTabPage_empty_statement_group_title=Empty statements
+#NewLinesTabPage_emtpy_statement_group_option_empty_statement_on_new_line=Put empty &statement on new line
+
+#NewLinesTabPage_arrayInitializer_group_title=Initializer list
+#NewLinesTabPage_array_group_option_after_opening_brace_of_array_initializer=Insert new line after openin&g brace of initializer list
+#NewLinesTabPage_array_group_option_before_closing_brace_of_array_initializer=Insert new line before closing brace of initiali&zer list
+
+
+ProfileManager_kandr_profile_name=K&R [built-in]
+ProfileManager_allman_profile_name=BSD/Allman [built-in]
+ProfileManager_gnu_profile_name=GNU [built-in]
+ProfileManager_whitesmiths_profile_name=Whitesmiths [built-in]
+
+ProfileManager_unmanaged_profile=Unmanaged profile
+ProfileManager_unmanaged_profile_with_name=Unmanaged profile "{0}"
+
+CPreview_formatter_exception=The formatter threw an unhandled exception while formatting the preview.
+
+ProfileConfigurationBlock_load_profile_wrong_profile_message=Import failed. This is not a valid profile: Expected ''{0}'' but encountered ''{1}''.
+FormatterTabPage_ShowInvisibleCharacters_label=Show &invisible characters
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterModifyDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterModifyDialog.java
new file mode 100644 (file)
index 0000000..36fe18a
--- /dev/null
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences.formatter;
+
+import java.util.Map;
+
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.Profile;
+
+public class FormatterModifyDialog extends ModifyDialog {
+    
+    public FormatterModifyDialog(Shell parentShell, Profile profile, ProfileManager profileManager, ProfileStore profileStore, boolean newProfile, String dialogPreferencesKey, String lastSavePathKey) {
+               super(parentShell, profile, profileManager, profileStore, newProfile, dialogPreferencesKey, lastSavePathKey);
+       }
+       
+       @Override
+       protected void addPages(Map<String, String> values) {
+           addTabPage(FormatterMessages.ModifyDialog_tabpage_indentation_title, new IndentationTabPage(this, values)); 
+               addTabPage(FormatterMessages.ModifyDialog_tabpage_braces_title, new BracesTabPage(this, values)); 
+               addTabPage(FormatterMessages.ModifyDialog_tabpage_whitespace_title, new WhiteSpaceTabPage(this, values)); 
+//             addTabPage(FormatterMessages.ModifyDialog_tabpage_blank_lines_title, new BlankLinesTabPage(this, values)); 
+               addTabPage(FormatterMessages.ModifyDialog_tabpage_new_lines_title, new NewLinesTabPage(this, values)); 
+               addTabPage(FormatterMessages.ModifyDialog_tabpage_control_statements_title, new ControlStatementsTabPage(this, values)); 
+               addTabPage(FormatterMessages.ModifyDialog_tabpage_line_wrapping_title, new LineWrappingTabPage(this, values)); 
+               addTabPage(FormatterMessages.ModifyDialog_tabpage_comments_title, new CommentsTabPage(this, values));
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterProfileManager.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterProfileManager.java
new file mode 100644 (file)
index 0000000..4dcc427
--- /dev/null
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences.formatter;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+import org.eclipse.cdt.internal.ui.preferences.PreferencesAccess;
+
+public class FormatterProfileManager extends ProfileManager {
+       private static final List<String> EMPTY_LIST = Collections.emptyList();
+
+       public final static String KANDR_PROFILE= "org.eclipse.cdt.ui.default.kandr_profile"; //$NON-NLS-1$
+       public final static String ALLMAN_PROFILE= "org.eclipse.cdt.ui.default.allman_profile"; //$NON-NLS-1$
+       public final static String GNU_PROFILE= "org.eclipse.cdt.ui.default.gnu_profile"; //$NON-NLS-1$
+       public final static String WHITESMITHS_PROFILE= "org.eclipse.cdt.ui.default.whitesmites_profile"; //$NON-NLS-1$
+
+       public final static String DEFAULT_PROFILE= KANDR_PROFILE;
+       
+       private final static KeySet[] KEY_SETS= new KeySet[] {
+               new KeySet(CCorePlugin.PLUGIN_ID, new ArrayList<String>(DefaultCodeFormatterConstants.getDefaultSettings().keySet())),
+               new KeySet(CUIPlugin.PLUGIN_ID, EMPTY_LIST)     
+       };
+       
+       private final static String PROFILE_KEY= PreferenceConstants.FORMATTER_PROFILE;
+       private final static String FORMATTER_SETTINGS_VERSION= "formatter_settings_version";  //$NON-NLS-1$
+
+       public FormatterProfileManager(List<Profile> profiles, IScopeContext context, PreferencesAccess preferencesAccess, IProfileVersioner profileVersioner) {
+           super(addBuiltinProfiles(profiles, profileVersioner), context, preferencesAccess, profileVersioner, KEY_SETS, PROFILE_KEY, FORMATTER_SETTINGS_VERSION);
+    }
+       
+       private static List<Profile> addBuiltinProfiles(List<Profile> profiles, IProfileVersioner profileVersioner) {
+               final Profile kandrProfile= new BuiltInProfile(KANDR_PROFILE, FormatterMessages.ProfileManager_kandr_profile_name, getKandRSettings(), 2, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind()); 
+               profiles.add(kandrProfile);
+               final Profile allmanProfile= new BuiltInProfile(ALLMAN_PROFILE, FormatterMessages.ProfileManager_allman_profile_name, getAllmanSettings(), 2, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind()); 
+               profiles.add(allmanProfile);
+               final Profile gnuProfile= new BuiltInProfile(GNU_PROFILE, FormatterMessages.ProfileManager_gnu_profile_name, getGNUSettings(), 2, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind()); 
+               profiles.add(gnuProfile);
+               final Profile whitesmithsProfile= new BuiltInProfile(WHITESMITHS_PROFILE, FormatterMessages.ProfileManager_whitesmiths_profile_name, getWhitesmithsSettings(), 2, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind()); 
+               profiles.add(whitesmithsProfile);
+
+               // Add the Profiles which are at default scope and hence are contributed by a product.
+       try {
+           List<Profile> defaultProfiles= new FormatterProfileStore(profileVersioner).readProfiles(DefaultScope.INSTANCE);
+           if (defaultProfiles != null) {
+               Map<String, Profile> profMap= new LinkedHashMap<String, Profile>();
+               // Add the already loaded / created profiles to a map 
+               for (Profile p : profiles)
+                       profMap.put(p.getID(), p);
+
+               // Default profiles override any colliding profiles already in the list
+                       for (Profile p : defaultProfiles)
+                               profMap.put(p.getID(), new BuiltInProfile(p.getName(), p.getName(), p.getSettings(), 2, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind()));
+                       profiles= new ArrayList<Profile>(profMap.values());
+           }
+       } catch (CoreException e) {
+               CUIPlugin.log(e);
+       }
+
+               return profiles;
+       }
+       
+       /** 
+        * @return Returns the default settings.
+        */
+       public static Map<String, String> getDefaultSettings() {
+               return DefaultCodeFormatterConstants.getDefaultSettings();
+       }
+
+       /** 
+        * @return Returns the K&R settings.
+        */
+       public static Map<String, String> getKandRSettings() {
+               return DefaultCodeFormatterConstants.getKandRSettings();
+       }
+
+       /** 
+        * @return Returns the ANSI settings.
+        */
+       public static Map<String, String> getAllmanSettings() {
+               return DefaultCodeFormatterConstants.getAllmanSettings();
+       }
+
+       /** 
+        * @return Returns the GNU settings.
+        */
+       public static Map<String, String> getGNUSettings() {
+               return DefaultCodeFormatterConstants.getGNUSettings();
+       }
+
+       /** 
+        * @return Returns the Whitesmiths settings.
+        */
+       public static Map<String, String> getWhitesmithsSettings() {
+               return DefaultCodeFormatterConstants.getWhitesmithsSettings();
+       }
+
+       /* (non-Javadoc)
+     * @see org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager#getSelectedProfileId(org.eclipse.core.runtime.preferences.IScopeContext)
+     */
+       @Override
+       protected String getSelectedProfileId(IScopeContext instanceScope) { 
+               String profileId= instanceScope.getNode(CUIPlugin.PLUGIN_ID).get(PROFILE_KEY, null);
+               if (profileId == null) {
+                       // request from bug 129427
+                       profileId= DefaultScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID).get(PROFILE_KEY, null);
+                       // fix for bug 89739
+//                     if (DEFAULT_PROFILE.equals(profileId)) { // default default: 
+//                             IEclipsePreferences node= instanceScope.getNode(CCorePlugin.PLUGIN_ID);
+//                             if (node != null) {
+//                                     String tabSetting= node.get(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, null);
+//                                     if (CCorePlugin.SPACE.equals(tabSetting)) {
+//                                             profileId= TAB_WIDTH_8_PROFILE;
+//                                     }
+//                             }
+//                     }
+               }
+           return profileId;
+    }
+
+       /* (non-Javadoc)
+     * @see org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager#getDefaultProfile()
+     */
+    @Override
+       public Profile getDefaultProfile() {
+       Profile p = super.getDefaultProfile();
+       if (p != null)
+               return p;
+           return getProfile(DEFAULT_PROFILE);
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterProfileStore.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterProfileStore.java
new file mode 100644 (file)
index 0000000..e8e518f
--- /dev/null
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences.formatter;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.osgi.service.prefs.BackingStoreException;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.Profile;
+
+
+public class FormatterProfileStore extends ProfileStore {
+
+       /**
+        * Preference key where all profiles are stored
+        */
+       private static final String PREF_FORMATTER_PROFILES= "org.eclipse.cdt.ui.formatterprofiles"; //$NON-NLS-1$
+       private static final String PREF_FORMATTER_PROFILES_OLD= "org.eclipse.jdt.ui.formatterprofiles"; //$NON-NLS-1$
+       
+       public FormatterProfileStore(IProfileVersioner profileVersioner) {
+               super(PREF_FORMATTER_PROFILES, profileVersioner);
+       }
+       
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public List<Profile> readProfiles(IScopeContext scope) throws CoreException {
+               final IEclipsePreferences node= scope.getNode(CUIPlugin.PLUGIN_ID);
+               final String profilesValue= node.get(PREF_FORMATTER_PROFILES_OLD, null);
+               if (profilesValue != null) {
+                       // migrate to new preference key
+                       final String versionKeyOld = PREF_FORMATTER_PROFILES_OLD + VERSION_KEY_SUFFIX;
+                       String version= node.get(versionKeyOld, null);
+                       node.put(PREF_FORMATTER_PROFILES, profilesValue);
+                       node.put(PREF_FORMATTER_PROFILES + VERSION_KEY_SUFFIX, version);
+                       node.remove(PREF_FORMATTER_PROFILES_OLD);
+                       node.remove(versionKeyOld);
+                       try {
+                               node.flush();
+                       } catch (BackingStoreException exc) {
+                               return readProfilesFromString(profilesValue);
+                       }
+               }
+           return super.readProfiles(scope);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterTabPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterTabPage.java
new file mode 100644 (file)
index 0000000..b2d46cc
--- /dev/null
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences.formatter;
+
+import java.util.Map;
+
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+public abstract class FormatterTabPage extends ModifyDialogTabPage {
+       private final static String SHOW_INVISIBLE_PREFERENCE_KEY= CUIPlugin.PLUGIN_ID + ".formatter_page.show_invisible_characters"; //$NON-NLS-1$
+
+    /**
+     * Constant array for boolean true/false selection.
+     * 
+     * @since 5.3
+     */
+    protected static String[] TRUE_FALSE= { DefaultCodeFormatterConstants.TRUE, DefaultCodeFormatterConstants.FALSE };
+
+    /**
+     * Constant array for boolean true/false selection.
+     * 
+     * @since 5.3
+     */
+    protected static String[] FALSE_TRUE= { DefaultCodeFormatterConstants.FALSE, DefaultCodeFormatterConstants.TRUE };
+
+       /**
+        * Constant array for insert / not_insert.
+        */
+       protected static String[] DO_NOT_INSERT_INSERT= { CCorePlugin.DO_NOT_INSERT, CCorePlugin.INSERT };
+
+       private CPreview fPreview;
+       private final IDialogSettings fDialogSettings;
+       private Button fShowInvisibleButton;
+
+       public FormatterTabPage(IModifyDialogTabPage.IModificationListener modifyListener,
+                       Map<String, String> workingValues) {
+               super(modifyListener, workingValues);
+               fDialogSettings= CUIPlugin.getDefault().getDialogSettings();
+       }
+
+       @Override
+       protected Composite doCreatePreviewPane(Composite composite, int numColumns) {
+               createLabel(numColumns - 1, composite, FormatterMessages.ModifyDialogTabPage_preview_label_text);  
+               
+               fShowInvisibleButton= new Button(composite, SWT.CHECK);
+               fShowInvisibleButton.setText(FormatterMessages.FormatterTabPage_ShowInvisibleCharacters_label);
+               fShowInvisibleButton.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, true, false));
+               fShowInvisibleButton.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               fPreview.showInvisibleCharacters(fShowInvisibleButton.getSelection());
+                               fDialogSettings.put(SHOW_INVISIBLE_PREFERENCE_KEY, fShowInvisibleButton.getSelection());
+                               doUpdatePreview();
+                       }
+               });
+               fShowInvisibleButton.setSelection(isShowInvisible());
+               
+               fPreview= doCreateCPreview(composite);
+               fDefaultFocusManager.add(fPreview.getControl());
+               fPreview.showInvisibleCharacters(fShowInvisibleButton.getSelection());
+               
+               final GridData gd= createGridData(numColumns, GridData.FILL_BOTH, 0);
+               gd.widthHint= 0;
+               gd.heightHint=0;
+               fPreview.getControl().setLayoutData(gd);
+               
+               return composite;
+       }
+
+       private boolean isShowInvisible() {
+               return fDialogSettings.getBoolean(SHOW_INVISIBLE_PREFERENCE_KEY);
+       }
+       
+       @Override
+       protected void doUpdatePreview() {
+               boolean showInvisible= isShowInvisible();
+               fPreview.showInvisibleCharacters(showInvisible);
+               fShowInvisibleButton.setSelection(showInvisible);
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/IModifyDialogTabPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/IModifyDialogTabPage.java
new file mode 100644 (file)
index 0000000..b2094e6
--- /dev/null
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences.formatter;
+
+import java.util.Map;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @since 5.0
+ */
+public interface IModifyDialogTabPage {
+
+       public interface IModificationListener {
+       
+               void updateStatus(IStatus status);
+       
+               void valuesModified();
+       
+       }
+
+       /**
+        * A map containing key value pairs this tab page
+        * is must modify.
+        * 
+        * @param workingValues the values to work with
+        */
+       public void setWorkingValues(Map<String, String> workingValues);
+
+       /**
+        * A modify listener which must be informed whenever
+        * a value in the map passed to {@link #setWorkingValues(Map)}
+        * changes. The listener can also be informed about status
+        * changes.
+        * 
+        * @param modifyListener the listener to inform
+        */
+       public void setModifyListener(IModificationListener modifyListener);
+
+       /**
+        * Create the contents of this tab page.
+        * 
+        * @param parent the parent composite
+        * @return created content control
+        */
+       public Composite createContents(Composite parent);
+
+       /**
+        * This is called when the page becomes visible. 
+        * Common tasks to do include:
+        * <ul><li>Updating the preview.</li>
+        * <li>Setting the focus</li>
+        * </ul>
+        */
+       public void makeVisible();
+
+       /**
+        * Each tab page should remember where its last focus was, and reset it
+        * correctly within this method. This method is only called after
+        * initialization on the first tab page to be displayed in order to restore
+        * the focus of the last session.
+        */
+       public void setInitialFocus();
+
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/IProfileVersioner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/IProfileVersioner.java
new file mode 100644 (file)
index 0000000..09a1106
--- /dev/null
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences.formatter;
+
+import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
+
+public interface IProfileVersioner {
+
+       public int getFirstVersion();
+
+       public int getCurrentVersion();
+       
+    public String getProfileKind();
+
+       /**
+        * Update the <code>profile</code> to the 
+        * current version number
+        */
+       public void update(CustomProfile profile);
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/IndentationTabPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/IndentationTabPage.java
new file mode 100644 (file)
index 0000000..2286cb7
--- /dev/null
@@ -0,0 +1,207 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     istvan@benedek-home.de - 103706 [formatter] indent empty lines
+ *     Sergey Prigogin (Google)
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences.formatter;
+
+import java.util.Map;
+import java.util.Observable;
+import java.util.Observer;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
+
+public class IndentationTabPage extends FormatterTabPage {
+       
+       /**
+        * Some C++ source code used for preview.
+        */
+       private final static String PREVIEW=
+               createPreviewHeader(FormatterMessages.IndentationTabPage_preview_header) + 
+               "#include <math.h>\n\n" + //$NON-NLS-1$
+               "class Point {" +  //$NON-NLS-1$
+               "public:" +  //$NON-NLS-1$
+               "Point(double x, double y) : x(x), y(y) {}" + //$NON-NLS-1$ 
+               "\n\n" +  //$NON-NLS-1$
+               "double distance(const Point& other) const;" + //$NON-NLS-1$
+               "int compareX(const Point& other) const;" + //$NON-NLS-1$
+               "double x;" +  //$NON-NLS-1$
+               "double y;" +  //$NON-NLS-1$
+               "};" + //$NON-NLS-1$
+               "\n\n" +  //$NON-NLS-1$
+               "double Point::distance(const Point& other) const {" + //$NON-NLS-1$
+               "double dx = x - other.x;" + //$NON-NLS-1$
+               "double dy = y - other.y;" + //$NON-NLS-1$
+               "\n\n" +  //$NON-NLS-1$
+               "return sqrt(dx * dx + dy * dy);" + //$NON-NLS-1$
+               "}"+ //$NON-NLS-1$
+               "\n\n" +  //$NON-NLS-1$
+               "int Point::compareX(const Point& other) const {" + //$NON-NLS-1$
+               "if(x < other.x) {" + //$NON-NLS-1$
+               "return -1;" + //$NON-NLS-1$
+               "} else if(x > other.x){" + //$NON-NLS-1$
+               "return 1;" + //$NON-NLS-1$
+               "} else {" + //$NON-NLS-1$
+               "return 0;" + //$NON-NLS-1$
+               "}"+ //$NON-NLS-1$
+               "}"+ //$NON-NLS-1$
+               "\n\n" +  //$NON-NLS-1$
+               "namespace FOO {"+ //$NON-NLS-1$
+               "int foo(int bar) const {" + //$NON-NLS-1$
+               "switch(bar) {" + //$NON-NLS-1$
+               "case 0:" + //$NON-NLS-1$
+               "++bar;" + //$NON-NLS-1$
+               "break;" + //$NON-NLS-1$
+               "case 1:" + //$NON-NLS-1$
+               "--bar;" + //$NON-NLS-1$
+               "default: {" + //$NON-NLS-1$
+               "bar += bar;" + //$NON-NLS-1$
+               "break;" + //$NON-NLS-1$
+               "}"+ //$NON-NLS-1$
+               "}"+ //$NON-NLS-1$
+               "}"+ //$NON-NLS-1$
+               "} // end namespace FOO"; //$NON-NLS-1$
+
+       private TranslationUnitPreview fPreview;
+       private String fOldTabChar= null;
+       
+       public IndentationTabPage(ModifyDialog modifyDialog, Map<String,String> workingValues) {
+               super(modifyDialog, workingValues);
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doCreatePreferences(org.eclipse.swt.widgets.Composite, int)
+        */
+       @Override
+       protected void doCreatePreferences(Composite composite, int numColumns) {
+
+               final Group generalGroup= createGroup(numColumns, composite, FormatterMessages.IndentationTabPage_general_group_title); 
+               
+               final String[] tabPolicyValues= new String[] {CCorePlugin.SPACE, CCorePlugin.TAB, DefaultCodeFormatterConstants.MIXED};
+               final String[] tabPolicyLabels= new String[] {
+                               FormatterMessages.IndentationTabPage_general_group_option_tab_policy_SPACE, 
+                               FormatterMessages.IndentationTabPage_general_group_option_tab_policy_TAB, 
+                               FormatterMessages.IndentationTabPage_general_group_option_tab_policy_MIXED
+               };
+               final ComboPreference tabPolicy= createComboPref(generalGroup, numColumns, FormatterMessages.IndentationTabPage_general_group_option_tab_policy, DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, tabPolicyValues, tabPolicyLabels);
+               final CheckboxPreference onlyForLeading= createCheckboxPref(generalGroup, numColumns, FormatterMessages.IndentationTabPage_use_tabs_only_for_leading_indentations, DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS, FALSE_TRUE);
+               final NumberPreference indentSize= createNumberPref(generalGroup, numColumns, FormatterMessages.IndentationTabPage_general_group_option_indent_size, DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, 0, 32); 
+               final NumberPreference tabSize= createNumberPref(generalGroup, numColumns, FormatterMessages.IndentationTabPage_general_group_option_tab_size, DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, 0, 32);
+               
+               String tabchar= fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
+               updateTabPreferences(tabchar, tabSize, indentSize, onlyForLeading);
+               tabPolicy.addObserver(new Observer() {
+                       public void update(Observable o, Object arg) {
+                               updateTabPreferences((String) arg, tabSize, indentSize, onlyForLeading);
+                       }
+               });
+               tabSize.addObserver(new Observer() {
+                       public void update(Observable o, Object arg) {
+                               indentSize.updateWidget();
+                       }
+               });
+               
+//             final Group typeMemberGroup= createGroup(numColumns, composite, FormatterMessages.IndentationTabPage_field_alignment_group_title); 
+//             createCheckboxPref(typeMemberGroup, numColumns, FormatterMessages.IndentationTabPage_field_alignment_group_align_fields_in_columns, DefaultCodeFormatterConstants.FORMATTER_ALIGN_TYPE_MEMBERS_ON_COLUMNS, FALSE_TRUE); 
+               
+               final Group classGroup = createGroup(numColumns, composite, FormatterMessages.IndentationTabPage_indent_group_title); 
+               createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_class_group_option_indent_access_specifiers_within_class_body, DefaultCodeFormatterConstants.FORMATTER_INDENT_ACCESS_SPECIFIER_COMPARE_TO_TYPE_HEADER, FALSE_TRUE); 
+               createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_class_group_option_indent_declarations_compare_to_access_specifiers, DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ACCESS_SPECIFIER, FALSE_TRUE); 
+
+               createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_block_group_option_indent_statements_compare_to_body, DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY, FALSE_TRUE); 
+               createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_block_group_option_indent_statements_compare_to_block, DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK, FALSE_TRUE); 
+
+               createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_switch_group_option_indent_statements_within_switch_body, DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH, FALSE_TRUE); 
+               createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_switch_group_option_indent_statements_within_case_body, DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES, FALSE_TRUE); 
+               createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_switch_group_option_indent_break_statements, DefaultCodeFormatterConstants.FORMATTER_INDENT_BREAKS_COMPARE_TO_CASES, FALSE_TRUE); 
+
+               createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_namespace_group_option_indent_declarations_within_namespace, DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_NAMESPACE_HEADER, FALSE_TRUE); 
+
+               createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_indent_empty_lines, DefaultCodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES, FALSE_TRUE); 
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#initializePage()
+        */
+       @Override
+       public void initializePage() {
+           fPreview.setPreviewText(PREVIEW);
+       }
+
+    /*
+     * @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doCreateCPreview(org.eclipse.swt.widgets.Composite)
+     */
+    @Override
+       protected CPreview doCreateCPreview(Composite parent) {
+        fPreview= new TranslationUnitPreview(fWorkingValues, parent);
+        return fPreview;
+    }
+
+    /*
+     * @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doUpdatePreview()
+     */
+    @Override
+       protected void doUpdatePreview() {
+        fPreview.update();
+    }
+
+       private void updateTabPreferences(String tabPolicy, NumberPreference tabPreference, NumberPreference indentPreference, CheckboxPreference onlyForLeading) {
+               /*
+                * If the tab-char is SPACE (or TAB), INDENTATION_SIZE
+                * preference is not used by the core formatter. We piggy back the
+                * visual tab length setting in that preference in that case. If the
+                * user selects MIXED, we use the previous TAB_SIZE preference as the
+                * new INDENTATION_SIZE (as this is what it really is) and set the 
+                * visual tab size to the value piggy backed in the INDENTATION_SIZE
+                * preference. See also CodeFormatterUtil. 
+                */
+               if (DefaultCodeFormatterConstants.MIXED.equals(tabPolicy)) {
+                       if (CCorePlugin.SPACE.equals(fOldTabChar) || CCorePlugin.TAB.equals(fOldTabChar))
+                               swapTabValues();
+                       tabPreference.setEnabled(true);
+                       tabPreference.setKey(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE);
+                       indentPreference.setEnabled(true);
+                       indentPreference.setKey(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE);
+                       onlyForLeading.setEnabled(true);
+               } else if (CCorePlugin.SPACE.equals(tabPolicy)) {
+                       if (DefaultCodeFormatterConstants.MIXED.equals(fOldTabChar))
+                               swapTabValues();
+                       tabPreference.setEnabled(true);
+                       tabPreference.setKey(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE);
+                       indentPreference.setEnabled(true);
+                       indentPreference.setKey(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE);
+                       onlyForLeading.setEnabled(false);
+               } else if (CCorePlugin.TAB.equals(tabPolicy)) {
+                       if (DefaultCodeFormatterConstants.MIXED.equals(fOldTabChar))
+                               swapTabValues();
+                       tabPreference.setEnabled(true);
+                       tabPreference.setKey(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE);
+                       indentPreference.setEnabled(false);
+                       indentPreference.setKey(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE);
+                       onlyForLeading.setEnabled(true);
+               } else {
+                       Assert.isTrue(false);
+               }
+               fOldTabChar= tabPolicy;
+       }
+
+       private void swapTabValues() {
+               String tabSize= fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE);
+               String indentSize= fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE);
+               fWorkingValues.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, indentSize);
+               fWorkingValues.put(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, tabSize);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/LineWrappingTabPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/LineWrappingTabPage.java
new file mode 100644 (file)
index 0000000..c0628e7
--- /dev/null
@@ -0,0 +1,928 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences.formatter;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Observable;
+import java.util.Observer;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+
+import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.corext.util.Messages;
+
+/**
+ * The line wrapping tab page.
+ */
+public class LineWrappingTabPage extends FormatterTabPage {
+    /**
+     * Represents a line wrapping category.
+     */
+       private final static class Category {
+               public final String key;
+               public final String name;
+               public final String previewText;
+               public final String prologue;
+               public final String description; // bug 235453: for categories' labels
+               public final List<Category> children;
+
+               public int index;
+
+               public Category(String key, String prologue, String previewText, String name, String description) {
+                       this.key= key;
+                       this.name= name;
+                       this.prologue = prologue;
+                       this.previewText= previewText != null ? createPreviewHeader(name) + previewText : null;
+                       this.description = description;
+                       children= new ArrayList<Category>();
+               }
+               
+               public Category(String key, String previewText, String name, String description) {
+                       this(key, null, previewText, name, description);
+               }
+               
+               /**
+                * @param name Category name
+                */
+               public Category(String name, String description) {
+                   this(null, null, name, description);
+               }
+               
+               @Override
+               public String toString() {
+                       return name;
+               }
+       }
+       
+
+       private final static String PREF_CATEGORY_INDEX= CUIPlugin.PLUGIN_ID + "formatter_page.line_wrapping_tab_page.last_category_index"; //$NON-NLS-1$ 
+       
+       private final class CategoryListener implements ISelectionChangedListener, IDoubleClickListener {
+               private final List<Category> fCategoriesList;
+               private int fIndex= 0;
+               
+               public CategoryListener(List<Category> categoriesTree) {
+                       fCategoriesList= new ArrayList<Category>();
+                       flatten(fCategoriesList, categoriesTree);
+               }
+               
+               private void flatten(List<Category> categoriesList, List<Category> categoriesTree) {
+                       for (Category category2 : categoriesTree) {
+                               final Category category= category2;
+                               category.index= fIndex++;
+                               categoriesList.add(category);
+                               flatten(categoriesList, category.children);
+                       }       
+               }
+
+//             public void add(Category category) {
+//                     category.index= fIndex++;
+//                     fCategoriesList.add(category);
+//             }
+
+               public void selectionChanged(SelectionChangedEvent event) {
+                   if (event != null)
+                       fSelection= (IStructuredSelection)event.getSelection();
+                   
+                   if (fSelection.size() == 0) {
+                       disableAll();
+                       return;
+                   }
+                   
+                   if (!fOptionsGroup.isEnabled())
+                       enableDefaultComponents(true);
+                   
+                   fSelectionState.refreshState(fSelection);
+                   
+                       final Category category= (Category) fSelection.getFirstElement();
+                       fDialogSettings.put(PREF_CATEGORY_INDEX, category.index);
+                       
+                       fOptionsGroup.setText(getGroupLabel(category));
+               }
+               
+               private String getGroupLabel(Category category) {
+                   if (fSelection.size() == 1) {
+                           if (fSelectionState.getElements().size() == 1)
+                               return NLS.bind(FormatterMessages.LineWrappingTabPage_group, category.description); 
+                           return NLS.bind(FormatterMessages.LineWrappingTabPage_multi_group, category.description,
+                                       String.valueOf(fSelectionState.getElements().size())); 
+                   }
+                       return NLS.bind(FormatterMessages.LineWrappingTabPage_multiple_selections,
+                                       String.valueOf(fSelectionState.getElements().size())); 
+               }
+        
+        private void disableAll() {
+            enableDefaultComponents(false);
+            fIndentStyleCombo.setEnabled(false);       
+            fForceSplit.setEnabled(false);
+        }
+        
+        private void enableDefaultComponents(boolean enabled) {
+            fOptionsGroup.setEnabled(enabled);
+            fWrappingStyleCombo.setEnabled(enabled);
+            fWrappingStylePolicy.setEnabled(enabled);
+        }
+
+        public void restoreSelection() {
+                       int index;
+                       try {
+                               index= fDialogSettings.getInt(PREF_CATEGORY_INDEX);
+                       } catch (NumberFormatException e) {
+                               index= -1;
+                       }
+                       if (index < 0 || index > fCategoriesList.size() - 1) {
+                               index= 1; // In order to select a category with preview initially
+                       }
+                       final Category category= fCategoriesList.get(index);
+                       fCategoriesViewer.setSelection(new StructuredSelection(new Category[] { category }));
+               }
+
+        public void doubleClick(DoubleClickEvent event) {
+            final ISelection selection= event.getSelection();
+            if (selection instanceof IStructuredSelection) {
+                final Category node= (Category)((IStructuredSelection)selection).getFirstElement();
+                fCategoriesViewer.setExpandedState(node, !fCategoriesViewer.getExpandedState(node));
+            }
+        }
+       }
+       
+       private class SelectionState {
+           private List<Category> fElements= new ArrayList<Category>();
+           
+           public void refreshState(IStructuredSelection selection) {
+               Map<Object, Integer> wrappingStyleMap= new HashMap<Object, Integer>();
+                   Map<Object, Integer> indentStyleMap= new HashMap<Object, Integer>();
+                   Map<Object, Integer> forceWrappingMap= new HashMap<Object, Integer>();
+               fElements.clear();
+               evaluateElements(selection.iterator());
+               evaluateMaps(wrappingStyleMap, indentStyleMap, forceWrappingMap);
+            evaluatePreviewText();
+               refreshControls(wrappingStyleMap, indentStyleMap, forceWrappingMap);
+           }
+
+           public List<Category> getElements() {
+               return fElements;
+           }
+           
+           private void evaluateElements(Iterator<?> iterator) {
+            Category category;
+            String value;
+            while (iterator.hasNext()) {
+               Object next= iterator.next();
+               if (next instanceof Category) {
+                       category= (Category) next;
+                       value= fWorkingValues.get(category.key);
+                       if (value != null) {
+                               if (!fElements.contains(category))
+                                       fElements.add(category);
+                       } else {
+                               evaluateElements(category.children.iterator());
+                       }
+               }
+            }
+        }
+           
+           private void evaluateMaps(Map<Object, Integer> wrappingStyleMap, Map<Object, Integer> indentStyleMap,
+                       Map<Object, Integer> forceWrappingMap) {
+            for (Category category : fElements) {
+                insertIntoMap(wrappingStyleMap, indentStyleMap, forceWrappingMap, category);
+            }
+           }
+  
+               private void evaluatePreviewText() {
+                       StringBuilder previewText = new StringBuilder();
+            for (Category category : fElements) {
+               if (category.prologue != null) {
+                       previewText.append(category.prologue);
+                       previewText.append("\n\n"); //$NON-NLS-1$
+               }
+            }
+            int offset = previewText.length();
+            for (Category category : fElements) {
+                previewText.append(category.previewText);
+                previewText.append("\n\n"); //$NON-NLS-1$
+            }
+               setPreviewText(previewText.toString(), offset);
+               }
+           
+        private void insertIntoMap(Map<Object, Integer> wrappingMap, Map<Object, Integer> indentMap,
+                       Map<Object, Integer> forceMap, Category category) {
+            final String value= fWorkingValues.get(category.key);
+            Integer wrappingStyle;
+            Integer indentStyle;
+            Boolean forceWrapping;
+            
+            try {
+                wrappingStyle= new Integer(DefaultCodeFormatterConstants.getWrappingStyle(value));
+                indentStyle= new Integer(DefaultCodeFormatterConstants.getIndentStyle(value));
+                forceWrapping= new Boolean(DefaultCodeFormatterConstants.getForceWrapping(value));
+            } catch (IllegalArgumentException e) {
+                               forceWrapping= new Boolean(false);
+                               indentStyle= new Integer(DefaultCodeFormatterConstants.INDENT_DEFAULT);
+                               wrappingStyle= new Integer(DefaultCodeFormatterConstants.WRAP_NO_SPLIT);
+                       } 
+                       
+            increaseMapEntry(wrappingMap, wrappingStyle);
+            increaseMapEntry(indentMap, indentStyle);
+            increaseMapEntry(forceMap, forceWrapping);
+        }
+        
+        private void increaseMapEntry(Map<Object, Integer> map, Object type) {
+            Integer count= map.get(type);
+            if (count == null) // not in map yet -> count == 0
+                map.put(type, new Integer(1));
+            else
+                map.put(type, new Integer(count.intValue() + 1));
+        }
+                
+        private void refreshControls(Map<Object, Integer> wrappingStyleMap, Map<Object, Integer> indentStyleMap,
+                       Map<Object, Integer> forceWrappingMap) {
+            updateCombos(wrappingStyleMap, indentStyleMap);
+            updateButton(forceWrappingMap);
+            Integer wrappingStyleMax= getWrappingStyleMax(wrappingStyleMap);
+                       boolean isInhomogeneous= (fElements.size() != wrappingStyleMap.get(wrappingStyleMax).intValue());
+                       updateControlEnablement(isInhomogeneous, wrappingStyleMax.intValue());
+                   doUpdatePreview();
+                       notifyValuesModified();
+        }
+        
+        private Integer getWrappingStyleMax(Map<Object, Integer> wrappingStyleMap) {
+            int maxCount= 0, maxStyle= 0;
+            for (int i= 0; i < WRAPPING_NAMES.length; i++) {
+                Integer count= wrappingStyleMap.get(new Integer(i));
+                if (count == null)
+                    continue;
+                if (count.intValue() > maxCount) {
+                    maxCount= count.intValue();
+                    maxStyle= i;
+                }
+            }
+            return new Integer(maxStyle);
+        }
+        
+        private void updateButton(Map<Object, Integer> forceWrappingMap) {
+            Integer nrOfTrue= forceWrappingMap.get(Boolean.TRUE);
+            Integer nrOfFalse= forceWrappingMap.get(Boolean.FALSE);
+            
+            if (nrOfTrue == null || nrOfFalse == null)
+                fForceSplit.setSelection(nrOfTrue != null);
+            else
+                fForceSplit.setSelection(nrOfTrue.intValue() > nrOfFalse.intValue());
+            
+            int max= getMax(nrOfTrue, nrOfFalse);
+            String label= FormatterMessages.LineWrappingTabPage_force_split_checkbox_multi_text; 
+            fForceSplit.setText(getLabelText(label, max, fElements.size())); 
+        }
+        
+        private String getLabelText(String label, int count, int nElements) {
+            if (nElements == 1 || count == 0)
+                return label;
+            return Messages.format(FormatterMessages.LineWrappingTabPage_occurences,
+                       new String[] {label, String.valueOf(count), String.valueOf(nElements)}); 
+        }
+        
+        private int getMax(Integer nrOfTrue, Integer nrOfFalse) {
+            if (nrOfTrue == null)
+                return nrOfFalse.intValue();
+            if (nrOfFalse == null)
+                return nrOfTrue.intValue();
+            if (nrOfTrue.compareTo(nrOfFalse) >= 0)
+                return nrOfTrue.intValue();
+            return nrOfFalse.intValue();
+        }
+        
+        private void updateCombos(Map<Object, Integer> wrappingStyleMap, Map<Object, Integer> indentStyleMap) {
+            updateCombo(fWrappingStyleCombo, wrappingStyleMap, WRAPPING_NAMES);
+            updateCombo(fIndentStyleCombo, indentStyleMap, INDENT_NAMES);
+        }
+        
+        private void updateCombo(Combo combo, Map<Object, Integer> map, final String[] items) {
+            String[] newItems= new String[items.length];
+            int maxCount= 0, maxStyle= 0;
+                        
+            for(int i = 0; i < items.length; i++) {
+                Integer count= map.get(new Integer(i));
+                int val= (count == null) ? 0 : count.intValue();
+                if (val > maxCount) {
+                    maxCount= val;
+                    maxStyle= i;
+                }                
+                newItems[i]= getLabelText(items[i], val, fElements.size()); 
+            }
+            combo.setItems(newItems);
+            combo.setText(newItems[maxStyle]);
+        }
+       }
+       
+       protected static final String[] INDENT_NAMES = {
+           FormatterMessages.LineWrappingTabPage_indentation_default, 
+           FormatterMessages.LineWrappingTabPage_indentation_on_column, 
+           FormatterMessages.LineWrappingTabPage_indentation_by_one
+       };
+
+       protected static final String[] WRAPPING_NAMES = { 
+           FormatterMessages.LineWrappingTabPage_splitting_do_not_split, 
+           FormatterMessages.LineWrappingTabPage_splitting_wrap_when_necessary, // COMPACT_SPLIT 
+           FormatterMessages.LineWrappingTabPage_splitting_always_wrap_first_others_when_necessary, // COMPACT_FIRST_BREAK_SPLIT  
+           FormatterMessages.LineWrappingTabPage_splitting_wrap_always, // ONE_PER_LINE_SPLIT  
+           FormatterMessages.LineWrappingTabPage_splitting_wrap_always_indent_all_but_first, // NEXT_SHIFTED_SPLIT  
+           FormatterMessages.LineWrappingTabPage_splitting_wrap_always_except_first_only_if_necessary
+       };      
+
+//     private final Category fCompactIfCategory= new Category(
+//                 DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_COMPACT_IF,
+//                 "int foo(int argument) {" + //$NON-NLS-1$
+//                 "  if (argument==0) return 0;" + //$NON-NLS-1$
+//                 "  if (argument==1) return 42; else return 43;" + //$NON-NLS-1$     
+//                 "}", //$NON-NLS-1$
+//                 FormatterMessages.LineWrappingTabPage_compact_if_else,
+//                     FormatterMessages.LineWrappingTabPage_compact_if_else_lowercase
+//             );
+
+       private final Category fTypeDeclarationBaseClauseCategory= new Category(
+                   DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_BASE_CLAUSE_IN_TYPE_DECLARATION,
+                   "class Example : public FooClass, virtual protected BarClass {};", //$NON-NLS-1$
+                   FormatterMessages.LineWrappingTabPage_base_clause, 
+                   FormatterMessages.LineWrappingTabPage_base_clause_lowercase
+               );      
+
+//     private final Category fConstructorDeclarationsParametersCategory= new Category(
+//             DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION,
+//             "class Example {Example(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6) { this();}" + //$NON-NLS-1$
+//             "Example() {}}", //$NON-NLS-1$
+//             FormatterMessages.LineWrappingTabPage_parameters,
+//                     FormatterMessages.LineWrappingTabPage_parameters_lowercase
+//             );
+
+       private final Category fMethodDeclarationsParametersCategory= new Category(
+                   DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION,
+                   "class Example {void foo(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6) {}};", //$NON-NLS-1$
+                   FormatterMessages.LineWrappingTabPage_parameters,
+                   FormatterMessages.LineWrappingTabPage_parameters_lowercase
+               ); 
+       
+       private final Category fMessageSendArgumentsCategory= new Category(
+                   DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION,
+                   "class Other {static void bar(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9) {}};"+ //$NON-NLS-1$
+                   "void foo() {Other::bar(100, 200, 300, 400, 500, 600, 700, 800, 900);}", //$NON-NLS-1$
+                   FormatterMessages.LineWrappingTabPage_arguments,
+                   FormatterMessages.LineWrappingTabPage_arguments_lowercase
+               ); 
+
+       private final Category fMethodThrowsClauseCategory= new Category(
+                   DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION, 
+                   "class Example {" + //$NON-NLS-1$
+                   "int foo() throw(FirstException, SecondException, ThirdException) {" + //$NON-NLS-1$
+                   "  return Other::doSomething();}};", //$NON-NLS-1$
+                   FormatterMessages.LineWrappingTabPage_throws_clause, 
+                   FormatterMessages.LineWrappingTabPage_throws_clause_lowercase
+               );
+
+       private final Category fConstructorInitializerListCategory= new Category(
+                   DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONSTRUCTOR_INITIALIZER_LIST, 
+                   "class Point {" + //$NON-NLS-1$
+                   "public:" + //$NON-NLS-1$
+                   "Point(double x, double y) : x(x), y(y) {" + //$NON-NLS-1$
+                   "}\n\n" + //$NON-NLS-1$
+                   "private:" + //$NON-NLS-1$
+                   "double x;" + //$NON-NLS-1$
+                   "double y;" + //$NON-NLS-1$
+                   "};", //$NON-NLS-1$
+                   FormatterMessages.LineWrappingTabPage_constructor_initializer_list, 
+                   FormatterMessages.LineWrappingTabPage_constructor_initializer_list_lowercase
+               );
+
+//     private final Category fConstructorThrowsClauseCategory= new Category(
+//             DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_CONSTRUCTOR_DECLARATION, 
+//             "class Example {" + //$NON-NLS-1$
+//             "Example() throws FirstException, SecondException, ThirdException {" + //$NON-NLS-1$
+//             "  return Other.doSomething();}}", //$NON-NLS-1$
+//             FormatterMessages.LineWrappingTabPage_throws_clause
+//                     FormatterMessages.LineWrappingTabPage_throws_clause_lowercase
+//             );
+
+//     private final Category fAllocationExpressionArgumentsCategory= new Category(
+//             DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION,
+//             "class Example {SomeClass foo() {return new SomeClass(100, 200, 300, 400, 500, 600, 700, 800, 900 );}}", //$NON-NLS-1$
+//             FormatterMessages.LineWrappingTabPage_object_allocation
+//             FormatterMessages.LineWrappingTabPage_object_allocation_lowercase
+//             );
+       
+       private final Category fInitializerListExpressionsCategory= new Category(
+                   DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_INITIALIZER_LIST,
+                   "int array[]= {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};", //$NON-NLS-1$
+                   FormatterMessages.LineWrappingTabPage_initializer_list,
+                   FormatterMessages.LineWrappingTabPage_initializer_list_lowercase
+               );
+       
+//     private final Category fExplicitConstructorArgumentsCategory= new Category(
+//             DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_EXPLICIT_CONSTRUCTOR_CALL,
+//             "class Example extends AnotherClass {Example() {super(100, 200, 300, 400, 500, 600, 700);}}", //$NON-NLS-1$
+//             FormatterMessages.LineWrappingTabPage_explicit_constructor_invocations
+//             FormatterMessages.LineWrappingTabPage_explicit_constructor_invocations_lowercase
+//             );
+
+       private final Category fConditionalExpressionCategory= new Category(
+                   DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION,
+                   "int compare(int argument, int argument2) {return argument > argument2 ? 100000 : 200000;}", //$NON-NLS-1$
+                   FormatterMessages.LineWrappingTabPage_conditionals,
+                   FormatterMessages.LineWrappingTabPage_conditionals_lowercase
+               );
+
+       private final Category fBinaryExpressionCategory= new Category(
+                   DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION,
+                   "int foo() {" + //$NON-NLS-1$
+                   "  int sum= 100 + 200 + 300 + 400 + 500 + 600 + 700 + 800;" + //$NON-NLS-1$
+                   "  int product= 1 * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10;" + //$NON-NLS-1$
+                   "  bool val= true && false && true && false && true;" +  //$NON-NLS-1$
+                   "  return product / sum;" + //$NON-NLS-1$
+                   "}", //$NON-NLS-1$
+                   FormatterMessages.LineWrappingTabPage_binary_exprs,
+               FormatterMessages.LineWrappingTabPage_binary_exprs_lowercase
+               );
+
+       private final Category fMemberAccessExpressionCategory= new Category(
+                   DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_MEMBER_ACCESS,
+                   "class TreeNode {" + //$NON-NLS-1$
+                   "public:" + //$NON-NLS-1$
+                   "TreeNode* getParent();" + //$NON-NLS-1$
+                   "TreeNode* getFirstChild();" + //$NON-NLS-1$
+                   "};\n\n" + //$NON-NLS-1$
+                   "TreeNode* firstUncle(TreeNode& node) {" + //$NON-NLS-1$
+                   "return node.getParent()->getParent()->getFirstChild();" + //$NON-NLS-1$
+                   "}", //$NON-NLS-1$
+                   FormatterMessages.LineWrappingTabPage_member_access,
+               FormatterMessages.LineWrappingTabPage_member_access_lowercase
+               );
+
+       private final Category fStreamOutputExpressionCategory= new Category(
+                   DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_OVERLOADED_LEFT_SHIFT_CHAIN,
+                   // Invisible code 
+                   "namespace std {\n" +  //$NON-NLS-1$
+                   "class ostream {\n" +  //$NON-NLS-1$
+                   "    ostream& operator<<(int);\n" +  //$NON-NLS-1$
+                   "    ostream& operator<<(char);\n" +  //$NON-NLS-1$
+                   "    ostream& operator<<(const char*);\n" +  //$NON-NLS-1$
+                   "};\n" +  //$NON-NLS-1$
+                   "int setfill(char);\n" +  //$NON-NLS-1$
+                   "int setw(int);\n" +  //$NON-NLS-1$
+                   "extern char endl;\n" +  //$NON-NLS-1$
+                   "extern ostream cout;\n" +  //$NON-NLS-1$
+                   "}", //$NON-NLS-1$
+                   // Visible code
+                   "#include <iostream>\n" + //$NON-NLS-1$
+                   "#include <iomanip>\n" + //$NON-NLS-1$
+                   "\n" + //$NON-NLS-1$
+                   "using namespace std;\n" + //$NON-NLS-1$
+                   "\n" + //$NON-NLS-1$
+                   "void PrintDate(int year, int month, int day) {" + //$NON-NLS-1$
+                   "cout << setfill('0') << setw(4) << year << '/' << setw(2) << month" + //$NON-NLS-1$
+                   " << '/' << setw(2) << day << endl;" + //$NON-NLS-1$
+                   "}", //$NON-NLS-1$
+                   FormatterMessages.LineWrappingTabPage_stream_output,
+               FormatterMessages.LineWrappingTabPage_stream_output_lowercase
+               );
+
+//     private final Category fEnumConstArgumentsCategory= new Category(
+//             DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ENUM_CONSTANT,
+//             "enum Example {" + //$NON-NLS-1$
+//             "GREEN(0, 255, 0), RED(255, 0, 0)  }", //$NON-NLS-1$
+//             FormatterMessages.LineWrappingTabPage_enum_constant_arguments,
+//             FormatterMessages.LineWrappingTabPage_enum_constant_arguments_lowercase
+//             );
+       
+//     private final Category fEnumDeclInterfacesCategory= new Category(
+//             DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_ENUM_DECLARATION,
+//             "enum Example implements A, B, C {" + //$NON-NLS-1$
+//             "}", //$NON-NLS-1$
+//             FormatterMessages.LineWrappingTabPage_enum_superinterfaces,
+//             FormatterMessages.LineWrappingTabPage_enum_superinterfaces_lowercase
+//             );
+       
+       private final Category fEnumeratorsCategory= new Category(
+                   DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUMERATOR_LIST,
+                   "enum Example {" + //$NON-NLS-1$
+                   "CANCELLED, RUNNING, WAITING, FINISHED };", //$NON-NLS-1$
+                   FormatterMessages.LineWrappingTabPage_enumerator_list,
+                   FormatterMessages.LineWrappingTabPage_enumerator_list_lowercase
+               );
+
+       private final Category fAssignmentCategory= new Category(
+                   DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ASSIGNMENT,
+                   "static char* string = \"text text text text\";" + //$NON-NLS-1$
+                   "class Example {" + //$NON-NLS-1$
+                   "void foo() {" + //$NON-NLS-1$
+                   "for (int i = 0; i < 10; i++) {}" + //$NON-NLS-1$
+                   "const char* character_string;" + //$NON-NLS-1$
+                   "character_string = \"text text text text\";}}", //$NON-NLS-1$
+               FormatterMessages.LineWrappingTabPage_assignment_alignment,
+               FormatterMessages.LineWrappingTabPage_assignment_alignment_lowercase
+               );
+
+       /**
+        * The default preview line width.
+        */
+       private static int DEFAULT_PREVIEW_WINDOW_LINE_WIDTH= 40;
+       
+       /**
+        * The key to save the user's preview window width in the dialog settings.
+        */
+       private static final String PREF_PREVIEW_LINE_WIDTH=
+                       CUIPlugin.PLUGIN_ID + ".codeformatter.line_wrapping_tab_page.preview_line_width"; //$NON-NLS-1$
+       
+       /**
+        * The dialog settings.
+        */
+       protected final IDialogSettings fDialogSettings;        
+       
+       protected TreeViewer fCategoriesViewer;
+       protected Label fWrappingStylePolicy;
+       protected Combo fWrappingStyleCombo;
+       protected Label fIndentStylePolicy;
+       protected Combo fIndentStyleCombo;
+       protected Button fForceSplit;
+
+       protected TranslationUnitPreview fPreview;
+
+       protected Group fOptionsGroup;
+
+       /**
+        * A collection containing the categories tree. This is used as model for the tree viewer.
+        * @see TreeViewer
+        */
+       private final List<Category> fCategories;
+       
+       /**
+        * The category listener which makes the selection persistent.
+        */
+       protected final CategoryListener fCategoryListener;
+       
+       /**
+        * The current selection of elements. 
+        */
+       protected IStructuredSelection fSelection;
+       
+       /**
+        * An object containing the state for the UI.
+        */
+       SelectionState fSelectionState;
+       
+       /**
+        * A special options store wherein the preview line width is kept.
+        */
+       protected final Map<String,String> fPreviewPreferences;
+       
+       /**
+        * The key for the preview line width.
+        */
+       private final String LINE_SPLIT= DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT;
+       
+       /**
+        * Create a new line wrapping tab page.
+        * @param modifyDialog
+        * @param workingValues
+        */
+       public LineWrappingTabPage(ModifyDialog modifyDialog, Map<String,String> workingValues) {
+               super(modifyDialog, workingValues);
+
+               fDialogSettings= CUIPlugin.getDefault().getDialogSettings();
+               
+               final String previewLineWidth= fDialogSettings.get(PREF_PREVIEW_LINE_WIDTH);
+               
+               fPreviewPreferences= new HashMap<String, String>();
+               fPreviewPreferences.put(LINE_SPLIT, previewLineWidth != null ?
+                               previewLineWidth : String.valueOf(DEFAULT_PREVIEW_WINDOW_LINE_WIDTH));
+               
+               fCategories= createCategories();
+               fCategoryListener= new CategoryListener(fCategories);
+       }
+       
+       /**
+        * @return Create the categories tree.
+        */
+       protected List<Category> createCategories() {
+               final Category classDeclarations= new Category(FormatterMessages.LineWrappingTabPage_class_decls,
+                               FormatterMessages.LineWrappingTabPage_class_decls_lowercase); 
+               classDeclarations.children.add(fTypeDeclarationBaseClauseCategory);
+               
+//             final Category constructorDeclarations= new Category(null, null, FormatterMessages.LineWrappingTabPage_constructor_decls); 
+//             constructorDeclarations.children.add(fConstructorDeclarationsParametersCategory);
+//             constructorDeclarations.children.add(fConstructorThrowsClauseCategory);
+//             constructorDeclarations.children.add(fConstructorInitializerListCategory);
+
+               final Category methodDeclarations= new Category(null, null, FormatterMessages.LineWrappingTabPage_function_decls,
+                               FormatterMessages.LineWrappingTabPage_function_decls_lowercase); 
+               methodDeclarations.children.add(fMethodDeclarationsParametersCategory);
+               methodDeclarations.children.add(fMethodThrowsClauseCategory);
+               methodDeclarations.children.add(fConstructorInitializerListCategory);
+
+               final Category enumDeclarations= new Category(FormatterMessages.LineWrappingTabPage_enum_decls,
+                               FormatterMessages.LineWrappingTabPage_enum_decls_lowercase); 
+               enumDeclarations.children.add(fEnumeratorsCategory);
+//             enumDeclarations.children.add(fEnumDeclInterfacesCategory);
+//             enumDeclarations.children.add(fEnumConstArgumentsCategory);
+               
+               final Category functionCalls= new Category(FormatterMessages.LineWrappingTabPage_function_calls,
+                               FormatterMessages.LineWrappingTabPage_function_calls_lowercase); 
+               functionCalls.children.add(fMessageSendArgumentsCategory);
+//             functionCalls.children.add(fMessageSendSelectorCategory);
+//             functionCalls.children.add(fExplicitConstructorArgumentsCategory);
+//             functionCalls.children.add(fAllocationExpressionArgumentsCategory);
+//             functionCalls.children.add(fQualifiedAllocationExpressionCategory);
+               
+               final Category expressions= new Category(FormatterMessages.LineWrappingTabPage_expressions,
+                               FormatterMessages.LineWrappingTabPage_expressions_lowercase); 
+               expressions.children.add(fBinaryExpressionCategory);
+               expressions.children.add(fConditionalExpressionCategory);
+               expressions.children.add(fAssignmentCategory);
+               expressions.children.add(fInitializerListExpressionsCategory);
+               expressions.children.add(fStreamOutputExpressionCategory);
+               expressions.children.add(fMemberAccessExpressionCategory);
+               
+//             final Category statements= new Category(FormatterMessages.LineWrappingTabPage_statements); 
+//             statements.children.add(fCompactIfCategory);
+               
+               final List<Category> root= new ArrayList<Category>();
+               root.add(classDeclarations);
+//             root.add(constructorDeclarations);
+               root.add(methodDeclarations);
+               root.add(enumDeclarations);
+               root.add(functionCalls);
+               root.add(expressions);
+//             root.add(statements);
+               
+               return root;
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doCreatePreferences(org.eclipse.swt.widgets.Composite, int)
+        */
+       @Override
+       protected void doCreatePreferences(Composite composite, int numColumns) {
+               final Group lineWidthGroup= createGroup(numColumns, composite, FormatterMessages.LineWrappingTabPage_width_indent); 
+
+               createNumberPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_width_indent_option_max_line_width, DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, 0, 9999); 
+               createNumberPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_width_indent_option_default_indent_wrapped, DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION, 0, 9999); 
+               createNumberPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_width_indent_option_default_indent_array, DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_INITIALIZER_LIST, 0, 9999); 
+               createCheckboxPref(lineWidthGroup, numColumns, FormatterMessages.LineWrappingTabPage_do_not_join_lines, DefaultCodeFormatterConstants.FORMATTER_JOIN_WRAPPED_LINES, TRUE_FALSE);
+
+               fCategoriesViewer= new TreeViewer(composite /*categoryGroup*/, SWT.MULTI | SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL );
+               fCategoriesViewer.setContentProvider(new ITreeContentProvider() {
+                       public Object[] getElements(Object inputElement) {
+                               return ((Collection<?>) inputElement).toArray();
+                       }
+                       public Object[] getChildren(Object parentElement) {
+                               return ((Category) parentElement).children.toArray();
+                       }
+                       public Object getParent(Object element) { return null; }
+                       public boolean hasChildren(Object element) {
+                               return !((Category) element).children.isEmpty();
+                       }
+                       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+                       public void dispose() {}
+               });
+               fCategoriesViewer.setLabelProvider(new LabelProvider());
+               fCategoriesViewer.setInput(fCategories);
+               
+               fCategoriesViewer.setExpandedElements(fCategories.toArray());
+
+               final GridData gd= createGridData(numColumns, GridData.FILL_BOTH, SWT.DEFAULT);
+               fCategoriesViewer.getControl().setLayoutData(gd);
+
+               fOptionsGroup = createGroup(numColumns, composite, "");  //$NON-NLS-1$
+               
+               // label "Select split style:"
+               fWrappingStylePolicy= createLabel(numColumns, fOptionsGroup,
+                               FormatterMessages.LineWrappingTabPage_wrapping_policy_label_text); 
+       
+               // combo SplitStyleCombo
+               fWrappingStyleCombo= new Combo(fOptionsGroup, SWT.SINGLE | SWT.READ_ONLY);
+               fWrappingStyleCombo.setItems(WRAPPING_NAMES);
+               fWrappingStyleCombo.setLayoutData(createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL, 0));
+               
+               // checkbox "Force split"
+               fForceSplit= new Button(fOptionsGroup, SWT.CHECK);
+               fForceSplit.setLayoutData(createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL, 0));
+               fForceSplit.setText(FormatterMessages.LineWrappingTabPage_force_split_checkbox_text); 
+               
+               // label "Select indentation style:"
+               fIndentStylePolicy= createLabel(numColumns, fOptionsGroup,
+                               FormatterMessages.LineWrappingTabPage_indentation_policy_label_text); 
+               
+               // combo IndentStyleCombo
+               fIndentStyleCombo= new Combo(fOptionsGroup, SWT.SINGLE | SWT.READ_ONLY);
+               fIndentStyleCombo.setItems(INDENT_NAMES);
+               fIndentStyleCombo.setLayoutData(createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL, 0));
+
+               // selection state object
+               fSelectionState= new SelectionState();
+       }
+               
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doCreatePreviewPane(org.eclipse.swt.widgets.Composite, int)
+        */
+       @Override
+       protected Composite doCreatePreviewPane(Composite composite, int numColumns) {
+               super.doCreatePreviewPane(composite, numColumns);
+               
+               final NumberPreference previewLineWidth= new NumberPreference(composite, numColumns / 2,
+                               fPreviewPreferences, LINE_SPLIT, 0, 9999,
+                               FormatterMessages.LineWrappingTabPage_line_width_for_preview_label_text); 
+               fDefaultFocusManager.add(previewLineWidth);
+               previewLineWidth.addObserver(fUpdater);
+               previewLineWidth.addObserver(new Observer() {
+                       public void update(Observable o, Object arg) {
+                               fDialogSettings.put(PREF_PREVIEW_LINE_WIDTH, fPreviewPreferences.get(LINE_SPLIT));
+                       }
+               });
+               Label label = new Label(composite, SWT.WRAP);
+        label.setText(FormatterMessages.LineWrappingTabPage_line_width_for_preview_label_unit_text);
+               
+               return composite;
+       }
+       
+    /*
+     * @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doCreateCPreview(org.eclipse.swt.widgets.Composite)
+     */
+    @Override
+       protected CPreview doCreateCPreview(Composite parent) {
+        fPreview= new TranslationUnitPreview(fWorkingValues, parent);
+        return fPreview;
+    }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#initializePage()
+        */
+       @Override
+       protected void initializePage() {
+               fCategoriesViewer.addSelectionChangedListener(fCategoryListener);
+               fCategoriesViewer.addDoubleClickListener(fCategoryListener);
+               
+               fForceSplit.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               forceSplitChanged(fForceSplit.getSelection());
+                       }
+               });
+               fIndentStyleCombo.addSelectionListener( new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               indentStyleChanged(((Combo)e.widget).getSelectionIndex());
+                       }
+               });
+               fWrappingStyleCombo.addSelectionListener( new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               wrappingStyleChanged(((Combo)e.widget).getSelectionIndex());
+                       }
+               });
+               
+               fCategoryListener.restoreSelection();
+               
+               fDefaultFocusManager.add(fCategoriesViewer.getControl());
+               fDefaultFocusManager.add(fWrappingStyleCombo);
+               fDefaultFocusManager.add(fIndentStyleCombo);
+               fDefaultFocusManager.add(fForceSplit);
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doUpdatePreview()
+        */
+       @Override
+       protected void doUpdatePreview() {
+               final String normalSetting= fWorkingValues.get(LINE_SPLIT);
+               fWorkingValues.put(LINE_SPLIT, fPreviewPreferences.get(LINE_SPLIT));
+               fPreview.update();
+               fWorkingValues.put(LINE_SPLIT, normalSetting);
+       }
+       
+        void setPreviewText(String text) {
+               setPreviewText(text, 0);
+       }
+
+       void setPreviewText(String text, int offset) {
+               final String normalSetting= fWorkingValues.get(LINE_SPLIT);
+               fWorkingValues.put(LINE_SPLIT, fPreviewPreferences.get(LINE_SPLIT));
+               fPreview.setPreviewText(text, offset);
+               fWorkingValues.put(LINE_SPLIT, normalSetting);
+       }
+       
+       protected void forceSplitChanged(boolean forceSplit) {
+           Iterator<Category> iterator= fSelectionState.fElements.iterator();
+           String currentKey;
+        while (iterator.hasNext()) {
+            currentKey= (iterator.next()).key;
+            try {
+                changeForceSplit(currentKey, forceSplit);
+            } catch (IllegalArgumentException e) {
+                       fWorkingValues.put(currentKey, DefaultCodeFormatterConstants.createAlignmentValue(forceSplit, DefaultCodeFormatterConstants.WRAP_NO_SPLIT, DefaultCodeFormatterConstants.INDENT_DEFAULT));
+                       CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK, 
+                               Messages.format(FormatterMessages.LineWrappingTabPage_error_invalid_value, currentKey), e)); 
+               }
+        }
+        fSelectionState.refreshState(fSelection);
+       }
+       
+       private void changeForceSplit(String currentKey, boolean forceSplit) throws IllegalArgumentException{
+               String value= fWorkingValues.get(currentKey);
+               value= DefaultCodeFormatterConstants.setForceWrapping(value, forceSplit);
+               if (value == null)
+                   throw new IllegalArgumentException();
+               fWorkingValues.put(currentKey, value);
+       }
+       
+       protected void wrappingStyleChanged(int wrappingStyle) {
+              Iterator<Category> iterator= fSelectionState.fElements.iterator();
+              String currentKey;
+               while (iterator.hasNext()) {
+                       currentKey= (iterator.next()).key;
+                       try {
+                           changeWrappingStyle(currentKey, wrappingStyle);
+                       } catch (IllegalArgumentException e) {
+                               fWorkingValues.put(currentKey, DefaultCodeFormatterConstants.createAlignmentValue(false, wrappingStyle, DefaultCodeFormatterConstants.INDENT_DEFAULT));
+                               CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK, 
+                                       Messages.format(FormatterMessages.LineWrappingTabPage_error_invalid_value, currentKey), e)); 
+                       }
+               }
+               fSelectionState.refreshState(fSelection);
+       }
+       
+       private void changeWrappingStyle(String currentKey, int wrappingStyle) throws IllegalArgumentException {
+           String value= fWorkingValues.get(currentKey);
+               value= DefaultCodeFormatterConstants.setWrappingStyle(value, wrappingStyle);
+               if (value == null)
+                   throw new IllegalArgumentException();
+               fWorkingValues.put(currentKey, value);
+       }
+       
+       protected void indentStyleChanged(int indentStyle) {
+           Iterator<Category> iterator= fSelectionState.fElements.iterator();
+           String currentKey;
+        while (iterator.hasNext()) {
+            currentKey= iterator.next().key;
+               try {
+               changeIndentStyle(currentKey, indentStyle);
+               } catch (IllegalArgumentException e) {
+                       fWorkingValues.put(currentKey, DefaultCodeFormatterConstants.createAlignmentValue(false, DefaultCodeFormatterConstants.WRAP_NO_SPLIT, indentStyle));
+                       CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK, 
+                               Messages.format(FormatterMessages.LineWrappingTabPage_error_invalid_value, currentKey), e)); 
+               }
+        }
+        fSelectionState.refreshState(fSelection);
+       }
+       
+       private void changeIndentStyle(String currentKey, int indentStyle) throws IllegalArgumentException{
+               String value= fWorkingValues.get(currentKey);
+               value= DefaultCodeFormatterConstants.setIndentStyle(value, indentStyle);
+               if (value == null)
+                   throw new IllegalArgumentException();
+               fWorkingValues.put(currentKey, value);
+       }
+    
+    protected void updateControlEnablement(boolean inhomogenous, int wrappingStyle) {
+           boolean doSplit= wrappingStyle != DefaultCodeFormatterConstants.WRAP_NO_SPLIT;
+           fIndentStylePolicy.setEnabled(true);
+           fIndentStyleCombo.setEnabled(inhomogenous || doSplit);
+           fForceSplit.setEnabled(inhomogenous || doSplit);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialog.java
new file mode 100644 (file)
index 0000000..151dc1a
--- /dev/null
@@ -0,0 +1,406 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin, Google
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences.formatter;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.StatusDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
+import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.Profile;
+import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
+import org.eclipse.cdt.internal.ui.util.Messages;
+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.StringDialogField;
+
+public abstract class ModifyDialog extends StatusDialog implements IModifyDialogTabPage.IModificationListener {
+    
+    /**
+     * The keys to retrieve the preferred area from the dialog settings.
+     */
+    private static final String DS_KEY_PREFERRED_WIDTH= "modify_dialog.preferred_width"; //$NON-NLS-1$
+    private static final String DS_KEY_PREFERRED_HEIGHT= "modify_dialog.preferred_height"; //$NON-NLS-1$
+    private static final String DS_KEY_PREFERRED_X= "modify_dialog.preferred_x"; //$NON-NLS-1$
+    private static final String DS_KEY_PREFERRED_Y= "modify_dialog.preferred_y"; //$NON-NLS-1$
+    
+    
+    /**
+     * The key to store the number (beginning at 0) of the tab page which had the 
+     * focus last time.
+     */
+    private static final String DS_KEY_LAST_FOCUS= "modify_dialog.last_focus"; //$NON-NLS-1$
+    
+    private static final int APPLAY_BUTTON_ID= IDialogConstants.CLIENT_ID;
+    private static final int SAVE_BUTTON_ID= IDialogConstants.CLIENT_ID + 1;
+
+       private final String fKeyPreferredWidth;
+       private final String fKeyPreferredHight;
+       private final String fKeyPreferredX;
+       private final String fKeyPreferredY;
+       private final String fKeyLastFocus;
+       private final String fLastSaveLoadPathKey;
+       private final ProfileStore fProfileStore;
+       private final boolean fNewProfile;
+       private Profile fProfile;
+       private final Map<String, String> fWorkingValues;
+       private final List<IModifyDialogTabPage> fTabPages;
+       private final IDialogSettings fDialogSettings;
+       private TabFolder fTabFolder;
+       private final ProfileManager fProfileManager;
+       private Button fApplyButton;
+       private Button fSaveButton;
+       private StringDialogField fProfileNameField;
+
+       protected ModifyDialog(Shell parentShell, Profile profile, ProfileManager profileManager, ProfileStore profileStore, boolean newProfile, String dialogPreferencesKey, String lastSavePathKey) {
+               super(parentShell);
+               
+               fProfileStore= profileStore;
+               fLastSaveLoadPathKey= lastSavePathKey;
+
+               fKeyPreferredWidth= CUIPlugin.PLUGIN_ID + dialogPreferencesKey + DS_KEY_PREFERRED_WIDTH;
+               fKeyPreferredHight= CUIPlugin.PLUGIN_ID + dialogPreferencesKey + DS_KEY_PREFERRED_HEIGHT;
+               fKeyPreferredX= CUIPlugin.PLUGIN_ID + dialogPreferencesKey + DS_KEY_PREFERRED_X;
+               fKeyPreferredY= CUIPlugin.PLUGIN_ID + dialogPreferencesKey + DS_KEY_PREFERRED_Y;
+               fKeyLastFocus= CUIPlugin.PLUGIN_ID + dialogPreferencesKey + DS_KEY_LAST_FOCUS;
+
+               fProfileManager= profileManager;
+               fNewProfile= newProfile;
+               setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX );
+                               
+               fProfile= profile;
+               setTitle(Messages.format(FormatterMessages.ModifyDialog_dialog_title, profile.getName()));
+               fWorkingValues= new HashMap<String, String>(fProfile.getSettings());
+               setStatusLineAboveButtons(false);
+               fTabPages= new ArrayList<IModifyDialogTabPage>();
+               fDialogSettings= CUIPlugin.getDefault().getDialogSettings();    
+       }
+
+       protected abstract void addPages(Map<String, String> values);
+
+       @Override
+       public void create() {
+               super.create();
+               int lastFocusNr= 0;
+               try {
+                       lastFocusNr= fDialogSettings.getInt(fKeyLastFocus);
+                       if (lastFocusNr < 0) lastFocusNr= 0;
+                       if (lastFocusNr > fTabPages.size() - 1) lastFocusNr= fTabPages.size() - 1;
+               } catch (NumberFormatException x) {
+                       lastFocusNr= 0;
+               }
+               
+               if (!fNewProfile) {
+                       fTabFolder.setSelection(lastFocusNr);
+                       ((IModifyDialogTabPage)fTabFolder.getSelection()[0].getData()).setInitialFocus();
+               }
+       }
+       
+       @Override
+       protected Control createDialogArea(Composite parent) {
+               
+               final Composite composite= (Composite)super.createDialogArea(parent);
+               
+               Composite nameComposite= new Composite(composite, SWT.NONE);
+               nameComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+               nameComposite.setLayout(new GridLayout(3, false));
+               
+               fProfileNameField= new StringDialogField();
+               fProfileNameField.setLabelText(FormatterMessages.ModifyDialog_ProfileName_Label);
+               fProfileNameField.setText(fProfile.getName());
+               fProfileNameField.getLabelControl(nameComposite).setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
+               fProfileNameField.getTextControl(nameComposite).setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+               fProfileNameField.setDialogFieldListener(new IDialogFieldListener() {
+                       public void dialogFieldChanged(DialogField field) {
+                               doValidate();
+            }
+               });
+               
+               fSaveButton= createButton(nameComposite, SAVE_BUTTON_ID, FormatterMessages.ModifyDialog_Export_Button, false);
+               
+               fTabFolder = new TabFolder(composite, SWT.NONE);
+               fTabFolder.setFont(composite.getFont());
+               fTabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+               addPages(fWorkingValues); 
+
+               applyDialogFont(composite);
+               
+               fTabFolder.addSelectionListener(new SelectionListener() {
+                       public void widgetDefaultSelected(SelectionEvent e) {}
+                       public void widgetSelected(SelectionEvent e) {
+                               final TabItem tabItem= (TabItem)e.item;
+                               final IModifyDialogTabPage page= (IModifyDialogTabPage)tabItem.getData();
+                               //                              page.fSashForm.setWeights();
+                               fDialogSettings.put(fKeyLastFocus, fTabPages.indexOf(page));
+                               page.makeVisible();
+                       }
+               });
+               
+               doValidate();
+               
+               return composite;
+       }
+       
+       @Override
+       public void updateStatus(IStatus status) {
+               if (status == null) {
+                       doValidate();
+               } else {
+               super.updateStatus(status);
+               }
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.window.Window#getInitialSize()
+        */
+       @Override
+       protected Point getInitialSize() {
+               Point initialSize= super.getInitialSize();
+               try {
+                       int lastWidth= fDialogSettings.getInt(fKeyPreferredWidth);
+                       if (initialSize.x > lastWidth)
+                               lastWidth= initialSize.x;
+                       int lastHeight= fDialogSettings.getInt(fKeyPreferredHight);
+                       if (initialSize.y > lastHeight)
+                               lastHeight= initialSize.y;
+                       return new Point(lastWidth, lastHeight);
+               } catch (NumberFormatException ex) {
+               }
+               return initialSize;
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.window.Window#getInitialLocation(org.eclipse.swt.graphics.Point)
+        */
+       @Override
+       protected Point getInitialLocation(Point initialSize) {
+               try {
+                       return new Point(fDialogSettings.getInt(fKeyPreferredX), fDialogSettings.getInt(fKeyPreferredY));
+               } catch (NumberFormatException ex) {
+                       return super.getInitialLocation(initialSize);
+               }
+       }
+           
+       @Override
+       public boolean close() {
+               final Rectangle shell= getShell().getBounds();
+
+               fDialogSettings.put(fKeyPreferredWidth, shell.width);
+               fDialogSettings.put(fKeyPreferredHight, shell.height);
+               fDialogSettings.put(fKeyPreferredX, shell.x);
+               fDialogSettings.put(fKeyPreferredY, shell.y);
+
+               return super.close();
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+        */
+       @Override
+       protected void okPressed() {
+               applyPressed();
+               super.okPressed();
+       }
+       
+    @Override
+       protected void buttonPressed(int buttonId) {
+               if (buttonId == APPLAY_BUTTON_ID) {
+                       applyPressed();
+                       setTitle(Messages.format(FormatterMessages.ModifyDialog_dialog_title, fProfile.getName()));
+               } else if (buttonId == SAVE_BUTTON_ID) {
+                       saveButtonPressed();
+               } else {
+                       super.buttonPressed(buttonId);
+               }
+    }
+       
+       private void applyPressed() {
+               if (!fProfile.getName().equals(fProfileNameField.getText())) {
+                       fProfile= fProfile.rename(fProfileNameField.getText(), fProfileManager);
+               }
+               fProfile.setSettings(new HashMap<String, String>(fWorkingValues));
+               fProfileManager.setSelected(fProfile);
+               doValidate();
+       }
+       
+       private void saveButtonPressed() {
+               Profile selected= new CustomProfile(fProfileNameField.getText(), new HashMap<String, String>(fWorkingValues), fProfile.getVersion(), fProfileManager.getProfileVersioner().getProfileKind());
+               
+               final FileDialog dialog= new FileDialog(getShell(), SWT.SAVE);
+               dialog.setText(FormatterMessages.CodingStyleConfigurationBlock_save_profile_dialog_title); 
+               dialog.setFilterExtensions(new String [] {"*.xml"}); //$NON-NLS-1$
+
+               final String lastPath= CUIPlugin.getDefault().getDialogSettings().get(fLastSaveLoadPathKey + ".savepath"); //$NON-NLS-1$
+               if (lastPath != null) {
+                       dialog.setFilterPath(lastPath);
+               }
+               final String path= dialog.open();
+               if (path == null) 
+                       return;
+
+               CUIPlugin.getDefault().getDialogSettings().put(fLastSaveLoadPathKey + ".savepath", dialog.getFilterPath()); //$NON-NLS-1$
+
+               final File file= new File(path);
+               if (file.exists() && !MessageDialog.openQuestion(getShell(), FormatterMessages.CodingStyleConfigurationBlock_save_profile_overwrite_title, Messages.format(FormatterMessages.CodingStyleConfigurationBlock_save_profile_overwrite_message, path))) { 
+                       return;
+               }
+               String encoding= ProfileStore.ENCODING;
+               final IContentType type= Platform.getContentTypeManager().getContentType("org.eclipse.core.runtime.xml"); //$NON-NLS-1$
+               if (type != null)
+                       encoding= type.getDefaultCharset();
+               final Collection<Profile> profiles= new ArrayList<Profile>();
+               profiles.add(selected);
+               try {
+                       fProfileStore.writeProfilesToFile(profiles, file, encoding);
+               } catch (CoreException e) {
+                       final String title= FormatterMessages.CodingStyleConfigurationBlock_save_profile_error_title;
+                       final String message= FormatterMessages.CodingStyleConfigurationBlock_save_profile_error_message;
+                       ExceptionHandler.handle(e, getShell(), title, message);
+               }
+       }
+    
+    @Override
+       protected void createButtonsForButtonBar(Composite parent) {
+           fApplyButton= createButton(parent, APPLAY_BUTTON_ID, FormatterMessages.ModifyDialog_apply_button, false); 
+               fApplyButton.setEnabled(false);
+               
+               GridLayout layout= (GridLayout) parent.getLayout();
+               layout.numColumns++;
+               layout.makeColumnsEqualWidth= false;
+               Label label= new Label(parent, SWT.NONE);
+               GridData data= new GridData();
+               data.widthHint= layout.horizontalSpacing;
+               label.setLayoutData(data);
+               super.createButtonsForButtonBar(parent);
+       }
+
+       protected final void addTabPage(String title, IModifyDialogTabPage tabPage) {
+               final TabItem tabItem= new TabItem(fTabFolder, SWT.NONE);
+               applyDialogFont(tabItem.getControl());
+               tabItem.setText(title);
+               tabItem.setData(tabPage);
+               tabItem.setControl(tabPage.createContents(fTabFolder));
+               fTabPages.add(tabPage);
+       }
+
+       public void valuesModified() {
+               doValidate();
+       }
+
+       @Override
+       protected void updateButtonsEnableState(IStatus status) {
+           super.updateButtonsEnableState(status);
+           if (fApplyButton != null && !fApplyButton.isDisposed()) {
+               fApplyButton.setEnabled(hasChanges() && !status.matches(IStatus.ERROR));
+               }
+           if (fSaveButton != null && !fSaveButton.isDisposed()) {
+               fSaveButton.setEnabled(!validateProfileName().matches(IStatus.ERROR));
+           }
+       }
+       
+    private void doValidate() {
+       String name= fProfileNameField.getText().trim();
+               if (name.equals(fProfile.getName()) && fProfile.hasEqualSettings(fWorkingValues, fWorkingValues.keySet())) {
+                       updateStatus(StatusInfo.OK_STATUS);
+                       return;
+               }
+       
+       IStatus status= validateProfileName();
+       if (status.matches(IStatus.ERROR)) {
+               updateStatus(status);
+               return;
+       }
+       
+               if (!name.equals(fProfile.getName()) && fProfileManager.containsName(name)) {
+                       updateStatus(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, FormatterMessages.ModifyDialog_Duplicate_Status, null));
+                       return;
+               }
+               
+               if (fProfile.isBuiltInProfile() || fProfile.isSharedProfile()) {
+                       updateStatus(new Status(IStatus.INFO, CUIPlugin.PLUGIN_ID, 0, FormatterMessages.ModifyDialog_NewCreated_Status, null));
+                       return;
+               }
+
+           updateStatus(StatusInfo.OK_STATUS);
+    }
+
+    private IStatus validateProfileName() {
+       final String name= fProfileNameField.getText().trim();
+       
+           if (fProfile.isBuiltInProfile()) {
+                       if (fProfile.getName().equals(name)) { 
+                               return new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, FormatterMessages.ModifyDialog_BuiltIn_Status, null);
+                       }       
+       }
+       
+       if (fProfile.isSharedProfile()) {
+                       if (fProfile.getName().equals(name)) { 
+                               return new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, FormatterMessages.ModifyDialog_Shared_Status, null);
+                       }
+       }
+               
+               if (name.length() == 0) {
+                       return new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, FormatterMessages.ModifyDialog_EmptyName_Status, null);
+               }
+               
+               return StatusInfo.OK_STATUS;
+    }
+
+       private boolean hasChanges() {
+               if (!fProfileNameField.getText().trim().equals(fProfile.getName()))
+                       return true;
+               
+               Iterator<Map.Entry<String, String>> iter= fProfile.getSettings().entrySet().iterator();
+               for (;iter.hasNext();) {
+                       Map.Entry<String, String> curr= iter.next();
+                       if (!fWorkingValues.get(curr.getKey()).equals(curr.getValue())) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialogTabPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialogTabPage.java
new file mode 100644 (file)
index 0000000..382caf0
--- /dev/null
@@ -0,0 +1,936 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin, Google
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences.formatter;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Observable;
+import java.util.Observer;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Layout;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.util.Messages;
+
+
+public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {    
+       /**
+        * This is the default listener for any of the Preference
+        * classes. It is added by the respective factory methods and
+        * updates the page's preview on each change. 
+        */
+       protected final Observer fUpdater= new Observer() {
+               public void update(Observable o, Object arg) {
+                       doUpdatePreview();
+                       notifyValuesModified();
+               }
+       };
+       
+       /**
+        * The base class of all Preference classes. A preference class provides a wrapper
+        * around one or more SWT widgets and handles the input of values for some key.
+        * On each change, the new value is written to the map and the listeners are notified.
+        */
+       protected abstract class Preference extends Observable {
+           private final Map<String, String> fPreferences;
+           private boolean fEnabled;
+           private String fKey;
+           
+           /**
+            * Create a new Preference.
+            * @param preferences The map where the value is written.
+            * @param key The key for which a value is managed.
+            */
+           public Preference(Map<String, String> preferences, String key) {
+               fPreferences= preferences;
+               fEnabled= true;
+               fKey= key;
+           }
+           /**
+            * @return Gets the map of this Preference.
+            */
+           protected final Map<String, String> getPreferences() {
+               return fPreferences;
+           }
+
+           /**
+            * Set the enabled state of all SWT widgets of this preference. 
+            * @param enabled new value
+            */
+           public final void setEnabled(boolean enabled) {
+               fEnabled= enabled;
+               updateWidget();
+           }
+           
+           /**
+            * @return Gets the enabled state of all SWT widgets of this Preference.
+            */
+           public final boolean getEnabled() {
+               return fEnabled;
+           }
+           
+           /**
+            * Set the key which is used to store the value.
+            * @param key New value
+            */
+           public final void setKey(String key) {
+               if (key == null || !fKey.equals(key)) {
+                   fKey= key;
+                   updateWidget();
+               }
+           }
+           /**
+            * @return Gets the currently used key which is used to store the value.
+            */     
+           public final String getKey() {
+               return fKey;
+           }
+           
+           /**
+            * Returns the main control of a preference, which is mainly used to 
+            * manage the focus. This may be <code>null</code> if the preference doesn't
+            * have a control which is able to have the focus. 
+            * @return The main control
+            */
+           public abstract Control getControl();
+           
+           /**
+            * To be implemented in subclasses. Update the SWT widgets when the state 
+            * of this object has changed (enabled, key, ...).
+            */
+           protected abstract void updateWidget();
+       }
+       
+       /**
+        * Wrapper around a checkbox and a label. 
+        */     
+       protected class ButtonPreference extends Preference {
+               private final String[] fValues;
+               private final Button fCheckbox;
+               
+               /**
+                * Create a new CheckboxPreference.
+                * @param composite The composite on which the SWT widgets are added.
+                * @param numColumns The number of columns in the composite's GridLayout.
+                * @param preferences The map to store the values.
+                * @param key The key to store the values.
+                * @param values An array of two elements indicating the values to store on unchecked/checked.
+                * @param text The label text for this Preference.
+                * @param style SWT style flag for the button
+                */
+               public ButtonPreference(Composite composite, int numColumns,
+                                                                 Map<String, String> preferences, String key, 
+                                                                 String [] values, String text, int style) {
+                   super(preferences, key);
+                   if (values == null || text == null) 
+                       throw new IllegalArgumentException(FormatterMessages.ModifyDialogTabPage_error_msg_values_text_unassigned); 
+                       fValues= values;
+
+                       fCheckbox= new Button(composite, style);
+                       fCheckbox.setText(text);
+                       fCheckbox.setLayoutData(createGridData(numColumns, GridData.FILL_HORIZONTAL, SWT.DEFAULT));
+                       fCheckbox.setFont(composite.getFont());
+                       
+                       updateWidget();
+
+                       fCheckbox.addSelectionListener(new SelectionAdapter() {
+                               @Override
+                               public void widgetSelected(SelectionEvent e) {
+                                       checkboxChecked(((Button)e.widget).getSelection());
+                               }
+                       });
+               }
+               
+               protected void checkboxChecked(boolean state) {
+                       getPreferences().put(getKey(), state ? fValues[1] : fValues[0]);
+                       setChanged();
+                       notifyObservers();
+               }
+               
+               @Override
+               protected void updateWidget() {
+                       if (getKey() != null) {
+                               fCheckbox.setEnabled(getEnabled());
+                               fCheckbox.setSelection(getChecked());
+                       } else {
+                               fCheckbox.setSelection(false);
+                               fCheckbox.setEnabled(false);
+                       }
+               }
+               
+               public boolean getChecked() {
+                       return fValues[1].equals(getPreferences().get(getKey()));
+               }
+               
+               public void setChecked(boolean checked) {
+                       getPreferences().put(getKey(), checked ? fValues[1] : fValues[0]);
+                       updateWidget();
+                       checkboxChecked(checked);       
+               }
+               
+               @Override
+               public Control getControl() {
+                       return fCheckbox;
+               }
+       }
+       
+       protected final class CheckboxPreference extends ButtonPreference {
+               public CheckboxPreference(Composite composite, int numColumns, Map<String, String> preferences, String key, String[] values, String text) {
+               super(composite, numColumns, preferences, key, values, text, SWT.CHECK);
+        }
+       }
+       
+       protected final class RadioPreference extends ButtonPreference {
+               public RadioPreference(Composite composite, int numColumns, Map<String, String> preferences, String key, String[] values, String text) {
+               super(composite, numColumns, preferences, key, values, text, SWT.RADIO);
+        }      
+       }
+       
+       /**
+        * Wrapper around a Combo box.
+        */
+       protected final class ComboPreference extends Preference {
+               private final String [] fItems;
+               private final String[] fValues;
+               private final Combo fCombo;
+               
+               /**
+                * Create a new ComboPreference.
+                * @param composite The composite on which the SWT widgets are added.
+                * @param numColumns The number of columns in the composite's GridLayout.
+                * @param preferences The map to store the values.
+                * @param key The key to store the values.
+                * @param values An array of n elements indicating the values to store for each selection.
+                * @param text The label text for this Preference.
+                * @param items An array of n elements indicating the text to be written in the combo box.
+                */
+               public ComboPreference(Composite composite, int numColumns,
+                                                                 Map<String, String> preferences, String key, 
+                                                                 String [] values, String text, String [] items) {
+                   super(preferences, key);
+                   if (values == null || items == null || text == null) 
+                       throw new IllegalArgumentException(FormatterMessages.ModifyDialogTabPage_error_msg_values_items_text_unassigned); 
+                       fValues= values;
+                       fItems= items;
+                       createLabel(numColumns - 1, composite, text);
+                       fCombo= new Combo(composite, SWT.SINGLE | SWT.READ_ONLY);
+                       fCombo.setFont(composite.getFont());
+                       fCombo.setItems(items);
+                       
+                       int max= 0;
+                       for (String item : items)
+                               if (item.length() > max) max= item.length();
+                       
+                       fCombo.setLayoutData(createGridData(1, GridData.HORIZONTAL_ALIGN_FILL, fCombo.computeSize(SWT.DEFAULT, SWT.DEFAULT).x));                        
+
+                       updateWidget();
+
+                       fCombo.addSelectionListener(new SelectionAdapter() {
+                               @Override
+                               public void widgetSelected(SelectionEvent e) {
+                                       comboSelected(((Combo)e.widget).getSelectionIndex());
+                               }
+                       });
+               }
+               
+               protected void comboSelected(int index) {
+                       getPreferences().put(getKey(), fValues[index]);
+                       setChanged();
+                       notifyObservers(fValues[index]);
+               }
+               
+               @Override
+               protected void updateWidget() {
+                       if (getKey() != null) {
+                               fCombo.setEnabled(getEnabled());
+                               fCombo.setText(getSelectedItem());
+                       } else {
+                               fCombo.setText(""); //$NON-NLS-1$
+                               fCombo.setEnabled(false);
+                       }
+               }
+               
+               public String getSelectedItem() {
+                       final String selected= getPreferences().get(getKey());
+                       for (int i= 0; i < fValues.length; i++) {
+                               if (fValues[i].equals(selected)) {
+                                       return fItems[i];
+                               }
+                       }
+                       return ""; //$NON-NLS-1$
+               }
+               
+               public boolean hasValue(String value) {
+                       return value.equals(getPreferences().get(getKey()));
+               }
+               
+               @Override
+               public Control getControl() {
+                       return fCombo;
+               }
+       }
+       
+       /**
+        * Wrapper around a textfied which requests an integer input of a given range.
+        */
+       protected final class NumberPreference extends Preference {
+               
+               private final int fMinValue, fMaxValue;
+               private final Label fNumberLabel;
+               private final Text fNumberText;
+
+               protected int fSelected;
+        protected int fOldSelected;
+        
+        
+               /**
+                * Create a new NumberPreference.
+                * @param composite The composite on which the SWT widgets are added.
+                * @param numColumns The number of columns in the composite's GridLayout.
+                * @param preferences The map to store the values.
+                * @param key The key to store the values.
+                * @param minValue The minimum value which is valid input.
+                * @param maxValue The maximum value which is valid input.
+                * @param text The label text for this Preference.
+                */
+               public NumberPreference(Composite composite, int numColumns,
+                                                          Map<String, String> preferences, String key, 
+                                                          int minValue, int maxValue, String text) {
+                   super(preferences, key);
+                   
+                       fNumberLabel= createLabel(numColumns - 1, composite, text, GridData.FILL_HORIZONTAL);
+                       fNumberText= new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.RIGHT);
+                       fNumberText.setFont(composite.getFont());
+
+                       final int length= Integer.toString(maxValue).length() + 3; 
+                       fNumberText.setLayoutData(createGridData(1, GridData.HORIZONTAL_ALIGN_END, fPixelConverter.convertWidthInCharsToPixels(length)));
+                       
+                       fMinValue= minValue;
+                       fMaxValue= maxValue;
+                       
+                       updateWidget();
+                       
+                       fNumberText.addFocusListener(new FocusListener() {
+                               public void focusGained(FocusEvent e) {
+                                   NumberPreference.this.focusGained();
+                               }
+                public void focusLost(FocusEvent e) {
+                                   NumberPreference.this.focusLost();
+                               }
+                       });
+                       
+                       fNumberText.addModifyListener(new ModifyListener() {
+                               public void modifyText(ModifyEvent e) {
+                                       fieldModified();
+                               }
+                       });
+               }
+               
+               private IStatus createErrorStatus() {
+                   return new Status(IStatus.ERROR, CUIPlugin.getPluginId(), 0, Messages.format(FormatterMessages.ModifyDialogTabPage_NumberPreference_error_invalid_value, Integer.toString(fMinValue), Integer.toString(fMaxValue)), null); 
+               }
+
+               protected void focusGained() {
+                   fOldSelected= fSelected;
+                   fNumberText.setSelection(0, fNumberText.getCharCount());
+               }
+               
+               protected void focusLost() {
+                   updateStatus(null);
+                   final String input= fNumberText.getText();
+                   if (!validInput(input))
+                       fSelected= fOldSelected;
+                   else
+                       fSelected= Integer.parseInt(input);
+                   if (fSelected != fOldSelected) {
+                       saveSelected();
+                       fNumberText.setText(Integer.toString(fSelected));
+                   }
+               }
+               
+               
+               protected void fieldModified() {
+                   final String trimInput= fNumberText.getText().trim();
+                   final boolean valid= validInput(trimInput);
+                   
+                   updateStatus(valid ? null : createErrorStatus());
+
+                   if (valid) {
+                       final int number= Integer.parseInt(trimInput);
+                       if (fSelected != number) {
+                           fSelected= number;
+                           saveSelected();
+                       }
+                   }
+               }
+               
+               private boolean validInput(String trimInput) {
+                   int number;
+                   
+                   try {
+                       number= Integer.parseInt(trimInput);
+                   } catch (NumberFormatException x) {
+                       return false;
+                   }
+                   
+                   if (number < fMinValue) return false;
+                   if (number > fMaxValue) return false;
+                   return true;
+               }
+               
+               private void saveSelected() {
+                       getPreferences().put(getKey(), Integer.toString(fSelected));
+                       setChanged();
+                       notifyObservers();
+               }
+               
+               @Override
+               protected void updateWidget() {
+                   final boolean hasKey= getKey() != null;
+
+                   fNumberLabel.setEnabled(hasKey && getEnabled());
+                       fNumberText.setEnabled(hasKey && getEnabled());
+
+                       if (hasKey) {
+                           String s= getPreferences().get(getKey());
+                           try {
+                               fSelected= Integer.parseInt(s);
+                           } catch (NumberFormatException e) {
+                               final String message= Messages.format(FormatterMessages.ModifyDialogTabPage_NumberPreference_error_invalid_key, getKey()); 
+                               CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK, message, e));
+                               s= ""; //$NON-NLS-1$
+                           }
+                           fNumberText.setText(s);
+                       } else {
+                           fNumberText.setText(""); //$NON-NLS-1$
+                       }
+               }
+               
+               @Override
+               public Control getControl() {
+                       return fNumberText;
+               }
+       }
+
+       
+       /**
+        * This class provides the default way to preserve and re-establish the focus
+        * over multiple modify sessions. Each ModifyDialogTabPage has its own instance,
+        * and it should add all relevant controls upon creation, always in the same sequence.
+        * This established a mapping of controls to indexes, which allows to restore the focus
+        * in a later session. 
+        * The index is saved in the dialog settings, and there is only one common preference for 
+        * all tab pages. It is always the currently active tab page which stores its focus
+        * index. 
+        */
+       protected final static class DefaultFocusManager extends FocusAdapter {
+               
+               private final static String PREF_LAST_FOCUS_INDEX= "formatter_page.modify_dialog_tab_page.last_focus_index"; //$NON-NLS-1$ 
+               
+               private final IDialogSettings fDialogSettings;
+               
+               private final Map<Control, Integer> fItemMap;
+               private final List<Control> fItemList;
+               
+               private int fIndex;
+               
+               public DefaultFocusManager() {
+                       fDialogSettings= CUIPlugin.getDefault().getDialogSettings();
+                       fItemMap= new HashMap<Control, Integer>();
+                       fItemList= new ArrayList<Control>();
+                       fIndex= 0;
+               }
+
+               @Override
+               public void focusGained(FocusEvent e) {
+                       fDialogSettings.put(PREF_LAST_FOCUS_INDEX, fItemMap.get(e.widget).intValue());
+               }
+               
+               public void add(Control control) {
+                       control.addFocusListener(this);
+                       fItemList.add(fIndex, control);
+                       fItemMap.put(control, new Integer(fIndex++));
+               }
+               
+               public void add(Preference preference) {
+                       final Control control= preference.getControl();
+                       if (control != null) 
+                               add(control);
+               }
+               
+               public boolean isUsed() {
+                       return fIndex != 0;
+               }
+               
+               public void restoreFocus() {
+                       int index= 0;
+                       try {
+                               index= fDialogSettings.getInt(PREF_LAST_FOCUS_INDEX);
+                               // make sure the value is within the range
+                               if ((index >= 0) && (index <= fItemList.size() - 1)) {
+                                       fItemList.get(index).setFocus();
+                               }
+                       } catch (NumberFormatException ex) {
+                               // this is the first time
+                       }
+               }
+               
+               public void resetFocus() {
+                       fDialogSettings.put(PREF_LAST_FOCUS_INDEX, -1);
+               }
+       }
+       
+       /**
+        * Layout used for the settings part. Makes sure to show scrollbars
+        * if necessary. The settings part needs to be layouted on resize.
+        */
+       private static class PageLayout extends Layout {
+               
+               private final ScrolledComposite fContainer;
+               private final int fMinimalWidth;
+               private final int fMinimalHight;
+
+               private PageLayout(ScrolledComposite container, int minimalWidth, int minimalHight) {
+                       fContainer= container;
+                       fMinimalWidth= minimalWidth;
+                       fMinimalHight= minimalHight;
+               }
+               
+               @Override
+               public Point computeSize(Composite composite, int wHint, int hHint, boolean force) {
+                       if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) {
+                               return new Point(wHint, hHint);
+                       }
+                       
+                       int x = fMinimalWidth;
+                       int y = fMinimalHight;
+                       Control[] children = composite.getChildren();
+                       for (Control element : children) {
+                               Point size = element.computeSize(SWT.DEFAULT, SWT.DEFAULT, force);
+                               x = Math.max(x, size.x);
+                               y = Math.max(y, size.y);
+                       }
+                       
+                       Rectangle area= fContainer.getClientArea();
+                       if (area.width > x) {
+                               fContainer.setExpandHorizontal(true);
+                       } else {
+                               fContainer.setExpandHorizontal(false);
+                       }
+                       
+                       if (area.height > y) {
+                               fContainer.setExpandVertical(true);
+                       } else {
+                               fContainer.setExpandVertical(false);
+                       }
+                       
+                       if (wHint != SWT.DEFAULT) {
+                               x = wHint;
+                       }
+                       if (hHint != SWT.DEFAULT) {
+                               y = hHint;
+                       }
+                       
+                       return new Point(x, y);
+               }
+
+               @Override
+               public void layout(Composite composite, boolean force) {
+                       Rectangle rect = composite.getClientArea();
+                       Control[] children = composite.getChildren();
+                       for (Control element : children) {
+                               element.setSize(rect.width, rect.height);
+                       }
+               }
+       }
+
+       /**
+        * The default focus manager. This widget knows all widgets which can have the focus
+        * and listens for focusGained events, on which it stores the index of the current
+        * focus holder. When the dialog is restarted, <code>restoreFocus()</code> sets the 
+        * focus to the last control which had it.
+        * 
+        * The standard Preference object are managed by this focus manager if they are created
+        * using the respective factory methods. Other SWT widgets can be added in subclasses 
+        * when they are created.
+        */
+       protected final DefaultFocusManager fDefaultFocusManager;
+
+       /**
+        * A pixel converter for layout calculations
+        */
+       protected PixelConverter fPixelConverter;
+       
+       
+       /**
+        * The map where the current settings are stored.
+        */
+       protected Map<String, String> fWorkingValues;
+       
+       /**
+        * The modify dialog where we can display status messages.
+        */
+       private IModifyDialogTabPage.IModificationListener fModifyListener;
+
+
+       /*
+        * Create a new <code>ModifyDialogTabPage</code>
+        */
+       public ModifyDialogTabPage(IModifyDialogTabPage.IModificationListener modifyListener, Map<String, String> workingValues) {
+               fWorkingValues= workingValues;
+               fModifyListener= modifyListener;
+               fDefaultFocusManager= new DefaultFocusManager();
+       }
+       
+       public ModifyDialogTabPage() {
+               fDefaultFocusManager= new DefaultFocusManager();
+       }
+       
+       /**
+        * {@inheritDoc}
+        */
+       public void setWorkingValues(Map<String, String> workingValues) {
+               fWorkingValues= workingValues;
+       }
+       
+       /**
+        * {@inheritDoc}
+        */
+       public void setModifyListener(IModifyDialogTabPage.IModificationListener modifyListener) {
+               fModifyListener= modifyListener;
+       }
+       
+       /**
+        * Create the contents of this tab page. Subclasses cannot override this, 
+        * instead they must implement <code>doCreatePreferences</code>. <code>doCreatePreview</code> may also
+        * be overridden as necessary.
+        * @param parent The parent composite
+        * @return Created content control
+        */
+       public final Composite createContents(Composite parent) {
+               final int numColumns= 4;
+               
+               if (fPixelConverter == null) {
+                   fPixelConverter= new PixelConverter(parent);
+               }
+               
+               final SashForm sashForm = new SashForm(parent, SWT.HORIZONTAL);
+               sashForm.setFont(parent.getFont());
+               
+               Composite scrollContainer = new Composite(sashForm, SWT.NONE);
+               
+               GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
+               scrollContainer.setLayoutData(gridData);
+                               
+               GridLayout layout= new GridLayout(2, false);
+               layout.marginHeight= 0;
+               layout.marginWidth= 0;
+               layout.horizontalSpacing= 0;
+               layout.verticalSpacing= 0;
+               scrollContainer.setLayout(layout);
+               
+               ScrolledComposite scroll= new ScrolledComposite(scrollContainer, SWT.V_SCROLL | SWT.H_SCROLL);
+               scroll.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));             
+               scroll.setExpandHorizontal(true);
+               scroll.setExpandVertical(true);
+
+               final Composite settingsContainer= new Composite(scroll, SWT.NONE);
+               settingsContainer.setFont(sashForm.getFont());
+               
+               scroll.setContent(settingsContainer);
+               
+               settingsContainer.setLayout(new PageLayout(scroll, 400, 400));
+               settingsContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               
+               Composite settingsPane= new Composite(settingsContainer, SWT.NONE);
+               settingsPane.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               
+               layout= new GridLayout(numColumns, false);
+               layout.verticalSpacing= (int)(1.5 * fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING));
+               layout.horizontalSpacing= fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+               layout.marginHeight= fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+               layout.marginWidth= fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+               settingsPane.setLayout(layout);
+               doCreatePreferences(settingsPane, numColumns);
+               
+               settingsContainer.setSize(settingsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT));     
+               
+               scroll.addControlListener(new ControlListener() {
+
+                       public void controlMoved(ControlEvent e) {
+                       }
+
+                       public void controlResized(ControlEvent e) {
+                               settingsContainer.setSize(settingsContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT));     
+                       }
+               });
+               
+               Label sashHandle = new Label(scrollContainer, SWT.SEPARATOR | SWT.VERTICAL);
+               gridData= new GridData(SWT.RIGHT, SWT.FILL, false, true);
+               sashHandle.setLayoutData(gridData);
+
+               final Composite previewPane= new Composite(sashForm, SWT.NONE);
+               previewPane.setLayout(createGridLayout(numColumns, true));
+               previewPane.setFont(sashForm.getFont());
+               doCreatePreviewPane(previewPane, numColumns);
+
+               initializePage();
+       
+               sashForm.setWeights(new int [] {3, 3});
+               return sashForm;
+       }
+       
+       /**
+        * This method is called after all controls have been allocated, including the preview. 
+        * It can be used to set the preview text and to create listeners.
+        *
+        */
+       protected abstract void initializePage();
+       
+
+       /**
+        * Create the left side of the modify dialog. This is meant to be implemented by subclasses. 
+        * @param composite Composite to create in
+        * @param numColumns Number of columns to use
+        */
+       protected abstract void doCreatePreferences(Composite composite, int numColumns);
+       
+
+       /**
+        * Create the right side of the modify dialog. By default, the preview is displayed there.
+        * Subclasses can override this method in order to customize the right-hand side of the 
+        * dialog.
+        * @param composite Composite to create in
+        * @param numColumns Number of columns to use
+        * @return Created composite
+        */
+       protected Composite doCreatePreviewPane(Composite composite, int numColumns) {
+               createLabel(numColumns, composite, FormatterMessages.ModifyDialogTabPage_preview_label_text);  
+               
+               final CPreview preview= doCreateCPreview(composite);
+               fDefaultFocusManager.add(preview.getControl());
+               
+               final GridData gd= createGridData(numColumns, GridData.FILL_BOTH, 0);
+               gd.widthHint= 0;
+               gd.heightHint=0;
+               preview.getControl().setLayoutData(gd);
+               
+               return composite;
+       }
+
+       /**
+        * To be implemented by subclasses. This method should return an instance of CPreview.
+        * Currently, the choice is between CompilationUnitPreview which contains a valid compilation
+        * unit, or a SnippetPreview which formats several independent code snippets and displays them 
+        * in the same window.
+        * @param parent Parent composite
+        * @return Created preview
+        */
+       protected abstract CPreview doCreateCPreview(Composite parent);
+       
+       /**
+        * {@inheritDoc}
+        */
+       final public void makeVisible() {
+               fDefaultFocusManager.resetFocus();
+               doUpdatePreview();
+       }
+       
+       /**
+        * Update the preview. To be implemented by subclasses.
+        */
+       protected abstract void doUpdatePreview();
+       
+       protected void notifyValuesModified() {
+               fModifyListener.valuesModified();
+       }
+    /**
+        * {@inheritDoc}
+        */
+    public void setInitialFocus() {
+               if (fDefaultFocusManager.isUsed()) {
+                       fDefaultFocusManager.restoreFocus();
+               }
+       }
+       
+
+    /**
+     * Set the status field on the dialog. This can be used by tab pages to report 
+     * inconsistent input. The OK button is disabled if the kind is IStatus.ERROR. 
+     * @param status Status describing the current page error state
+     */
+       protected void updateStatus(IStatus status) {
+               fModifyListener.updateStatus(status);
+       }
+       
+       /*
+        * Factory methods to make GUI construction easier
+        */
+       
+       /*
+        * Create a GridLayout with the default margin and spacing settings, as
+        * well as the specified number of columns.
+        */
+       protected GridLayout createGridLayout(int numColumns, boolean margins) {
+               final GridLayout layout= new GridLayout(numColumns, false);
+               layout.verticalSpacing= fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
+               layout.horizontalSpacing= fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+               if (margins) {
+                       layout.marginHeight= fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+                       layout.marginWidth= fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+               } else {
+                       layout.marginHeight= 0;
+                       layout.marginWidth= 0;
+               }
+               return layout;
+       }
+
+       /*
+        * Convenience method to create a GridData.
+        */
+       protected static GridData createGridData(int numColumns, int style, int widthHint) {
+               final GridData gd= new GridData(style);
+               gd.horizontalSpan= numColumns;
+               gd.widthHint= widthHint;
+               return gd;              
+       }
+
+
+       /* 
+        * Convenience method to create a label.  
+        */
+       protected static Label createLabel(int numColumns, Composite parent, String text) {
+               return createLabel(numColumns, parent, text, GridData.FILL_HORIZONTAL);
+       }
+       
+       /*
+        * Convenience method to create a label
+        */
+       protected static Label createLabel(int numColumns, Composite parent, String text, int gridDataStyle) {
+               final Label label= new Label(parent, SWT.WRAP);
+               label.setFont(parent.getFont());
+               label.setText(text);
+               
+               PixelConverter pixelConverter= new PixelConverter(parent);
+               label.setLayoutData(createGridData(numColumns, gridDataStyle, pixelConverter.convertHorizontalDLUsToPixels(150)));
+               return label;
+       }
+
+       /*
+        * Convenience method to create a group
+        */
+       protected Group createGroup(int numColumns, Composite parent, String text ) {
+               final Group group= new Group(parent, SWT.NONE);
+               group.setFont(parent.getFont());
+               group.setLayoutData(createGridData(numColumns, GridData.FILL_HORIZONTAL, SWT.DEFAULT));
+               
+               final GridLayout layout= new GridLayout(numColumns, false);
+               layout.verticalSpacing=  fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
+               layout.horizontalSpacing= fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+               layout.marginHeight=  fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
+
+               //layout.marginHeight= fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+               //layout.marginWidth= fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+               
+               group.setLayout(layout);//createGridLayout(numColumns, true));
+               group.setText(text);
+               return group;
+       }
+       
+       /*
+        * Convenience method to create a NumberPreference. The widget is registered as 
+        * a potential focus holder, and the default updater is added.
+        */
+       protected NumberPreference createNumberPref(Composite composite, int numColumns, String name, String key,
+                                                                                               int minValue, int maxValue) {
+               final NumberPreference pref= new NumberPreference(composite, numColumns, fWorkingValues, 
+                       key, minValue, maxValue, name);
+               fDefaultFocusManager.add(pref);
+               pref.addObserver(fUpdater);
+               return pref;
+       }
+       
+       /*
+        * Convenience method to create a ComboPreference. The widget is registered as 
+        * a potential focus holder, and the default updater is added.
+        */
+       protected ComboPreference createComboPref(Composite composite, int numColumns, String name, 
+                                                                                         String key, String [] values, String [] items) {
+               final ComboPreference pref= new ComboPreference(composite, numColumns, 
+                       fWorkingValues, key, values, name, items);
+               fDefaultFocusManager.add(pref);
+               pref.addObserver(fUpdater);
+               return pref;
+       }
+
+       /*
+        * Convenience method to create a CheckboxPreference. The widget is registered as 
+        * a potential focus holder, and the default updater is added.
+        */
+       protected CheckboxPreference createCheckboxPref(Composite composite, int numColumns, String name, String key,
+                                                                                                       String [] values) {
+               final CheckboxPreference pref= new CheckboxPreference(composite, numColumns, 
+                       fWorkingValues, key, values, name);
+               fDefaultFocusManager.add(pref);
+               pref.addObserver(fUpdater);
+               return pref;
+       }
+       
+       protected RadioPreference createRadioPref(Composite composite, int numColumns, String name, String key,
+                       String [] values) {
+               final RadioPreference pref= new RadioPreference(composite, numColumns, 
+                               fWorkingValues, key, values, name);
+               fDefaultFocusManager.add(pref);
+               pref.addObserver(fUpdater);
+               return pref;
+       }
+       
+
+       /*
+        * Create a nice javadoc comment for some string.
+        */
+       protected static String createPreviewHeader(String title) {
+               return "/*\n* " + title + "\n*/\n"; //$NON-NLS-1$ //$NON-NLS-2$
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/NewLinesTabPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/NewLinesTabPage.java
new file mode 100644 (file)
index 0000000..6f169e8
--- /dev/null
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences.formatter;
+
+import java.util.Map;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
+
+public class NewLinesTabPage extends FormatterTabPage {
+
+       private final String PREVIEW=
+               createPreviewHeader(FormatterMessages.NewLinesTabPage_preview_header) +
+           "class Point {" + //$NON-NLS-1$
+           "public:" + //$NON-NLS-1$
+           "Point(double x, double y) : x(x), y(y) {" + //$NON-NLS-1$
+           "}\n\n" + //$NON-NLS-1$
+           "private:" + //$NON-NLS-1$
+           "double x;" + //$NON-NLS-1$
+           "double y;" + //$NON-NLS-1$
+           "};"; //$NON-NLS-1$
+
+       protected CheckboxPreference fThenStatementPref;
+       protected CheckboxPreference fSimpleIfPref;
+
+       private TranslationUnitPreview fPreview;
+
+       public NewLinesTabPage(ModifyDialog modifyDialog, Map<String, String> workingValues) {
+               super(modifyDialog, workingValues);
+       }
+
+       @Override
+       protected void doCreatePreferences(Composite composite, int numColumns) {
+               final Group newlinesGroup= createGroup(numColumns, composite, FormatterMessages.NewLinesTabPage_newlines_group_title);
+               createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_before_colon_in_constructor_initializer_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_COLON_IN_CONSTRUCTOR_INITIALIZER_LIST, DO_NOT_INSERT_INSERT);
+//             createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_class_body, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_TYPE_DECLARATION, DO_NOT_INSERT_INSERT);
+//             createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_anonymous_class_body, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANONYMOUS_TYPE_DECLARATION, DO_NOT_INSERT_INSERT);
+//             createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_method_body, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_METHOD_BODY, DO_NOT_INSERT_INSERT);
+//             createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_block, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_BLOCK, DO_NOT_INSERT_INSERT);
+//             createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_label, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_LABEL, DO_NOT_INSERT_INSERT);
+//             createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_enum_declaration, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_DECLARATION, DO_NOT_INSERT_INSERT);
+//             createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_enum_constant, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_CONSTANT, DO_NOT_INSERT_INSERT);
+//             createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_annotation_decl_body, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANNOTATION_DECLARATION, DO_NOT_INSERT_INSERT);
+//             createPref(newlinesGroup, numColumns, FormatterMessages.NewLinesTabPage_newlines_group_option_empty_end_of_file, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING, DO_NOT_INSERT_INSERT);
+
+//             final Group arrayInitializerGroup= createGroup(numColumns, composite, FormatterMessages.NewLinesTabPage_arrayInitializer_group_title);
+//             createPref(arrayInitializerGroup, numColumns, FormatterMessages.NewLinesTabPage_array_group_option_after_opening_brace_of_array_initializer, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, DO_NOT_INSERT_INSERT);
+//             createPref(arrayInitializerGroup, numColumns, FormatterMessages.NewLinesTabPage_array_group_option_before_closing_brace_of_array_initializer, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, DO_NOT_INSERT_INSERT);
+
+//             final Group emptyStatementsGroup= createGroup(numColumns, composite, FormatterMessages.NewLinesTabPage_empty_statement_group_title);
+//             createPref(emptyStatementsGroup, numColumns, FormatterMessages.NewLinesTabPage_emtpy_statement_group_option_empty_statement_on_new_line, DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, FALSE_TRUE);
+
+//             final Group annotationsGroup= createGroup(numColumns, composite, FormatterMessages.NewLinesTabPage_annotations_group_title);
+//             createPref(annotationsGroup, numColumns, FormatterMessages.NewLinesTabPage_annotations_group_packages, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE, DO_NOT_INSERT_INSERT);
+//             createPref(annotationsGroup, numColumns, FormatterMessages.NewLinesTabPage_annotations_group_types, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE, DO_NOT_INSERT_INSERT);
+//             createPref(annotationsGroup, numColumns, FormatterMessages.NewLinesTabPage_annotations_group_fields, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD, DO_NOT_INSERT_INSERT);
+//             createPref(annotationsGroup, numColumns, FormatterMessages.NewLinesTabPage_annotations_group_methods, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD, DO_NOT_INSERT_INSERT);
+//             createPref(annotationsGroup, numColumns, FormatterMessages.NewLinesTabPage_annotations_group_paramters, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER, DO_NOT_INSERT_INSERT);
+//             createPref(annotationsGroup, numColumns, FormatterMessages.NewLinesTabPage_annotations_group_local_variables, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE, DO_NOT_INSERT_INSERT);
+       }
+
+       @Override
+       protected void initializePage() {
+           fPreview.setPreviewText(PREVIEW);
+       }
+
+    @Override
+       protected CPreview doCreateCPreview(Composite parent) {
+        fPreview= new TranslationUnitPreview(fWorkingValues, parent);
+        return fPreview;
+    }
+
+    @Override
+       protected void doUpdatePreview() {
+       super.doUpdatePreview();
+        fPreview.update();
+    }
+
+       private CheckboxPreference createPref(Composite composite, int numColumns, String message, String key, String[] values) {
+               return createCheckboxPref(composite, numColumns, message, key, values);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileConfigurationBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileConfigurationBlock.java
new file mode 100644 (file)
index 0000000..a26d722
--- /dev/null
@@ -0,0 +1,439 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences.formatter;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Observable;
+import java.util.Observer;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.StatusDialog;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.osgi.service.prefs.BackingStoreException;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.corext.util.Messages;
+
+import org.eclipse.cdt.internal.ui.preferences.PreferencesAccess;
+import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
+import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.Profile;
+import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
+import org.eclipse.cdt.internal.ui.util.SWTUtil;
+
+public abstract class ProfileConfigurationBlock {
+
+       private class StoreUpdater implements Observer {
+
+               public StoreUpdater() {
+                       fProfileManager.addObserver(this);
+               }
+
+               public void update(Observable o, Object arg) {
+                       try {
+                               fPreferenceListenerEnabled= false;
+                       final int value= ((Integer)arg).intValue();
+                       switch (value) {
+                       case ProfileManager.PROFILE_DELETED_EVENT:
+                       case ProfileManager.PROFILE_RENAMED_EVENT:
+                       case ProfileManager.PROFILE_CREATED_EVENT:
+                       case ProfileManager.SETTINGS_CHANGED_EVENT:
+                               try {
+                                       fProfileStore.writeProfiles(fProfileManager.getSortedProfiles(), fInstanceScope); // update profile store
+                                       fProfileManager.commitChanges(fCurrContext); 
+                               } catch (CoreException x) {
+                                       CUIPlugin.log(x);
+                               }
+                               break;
+                       case ProfileManager.SELECTION_CHANGED_EVENT:
+                               fProfileManager.commitChanges(fCurrContext);
+                               break;
+                       }
+                       } finally {
+                               fPreferenceListenerEnabled= true;
+                       }
+               }
+       }
+
+       class ProfileComboController implements Observer, SelectionListener {
+
+               private final List<Profile> fSortedProfiles;
+
+               public ProfileComboController() {
+                       fSortedProfiles= fProfileManager.getSortedProfiles();
+                       fProfileCombo.addSelectionListener(this);
+                       fProfileManager.addObserver(this);
+                       updateProfiles();
+                       updateSelection();
+               }
+
+               public void widgetSelected(SelectionEvent e) {
+                       final int index= fProfileCombo.getSelectionIndex();
+                       fProfileManager.setSelected(fSortedProfiles.get(index));
+               }
+
+               public void widgetDefaultSelected(SelectionEvent e) {}
+
+               public void update(Observable o, Object arg) {
+                       if (arg == null) return;
+                       final int value= ((Integer)arg).intValue();
+                       switch (value) {
+                       case ProfileManager.PROFILE_CREATED_EVENT:
+                       case ProfileManager.PROFILE_DELETED_EVENT:
+                       case ProfileManager.PROFILE_RENAMED_EVENT:
+                               updateProfiles();
+                               updateSelection();
+                               break;
+                       case ProfileManager.SELECTION_CHANGED_EVENT:
+                               updateSelection();
+                               break;
+                       }
+               }
+
+               private void updateProfiles() {
+                       fProfileCombo.setItems(fProfileManager.getSortedDisplayNames());
+               }
+
+               private void updateSelection() {
+                       fProfileCombo.setText(fProfileManager.getSelected().getName());
+               }
+       }
+
+       class ButtonController implements Observer, SelectionListener {
+
+               public ButtonController() {
+                       fProfileManager.addObserver(this);
+                       fNewButton.addSelectionListener(this);
+                       fEditButton.addSelectionListener(this);
+                       fDeleteButton.addSelectionListener(this);
+                       fLoadButton.addSelectionListener(this);
+                       update(fProfileManager, null);
+               }
+
+               public void update(Observable o, Object arg) {
+                       Profile selected= ((ProfileManager)o).getSelected();
+                       final boolean notBuiltIn= !selected.isBuiltInProfile(); 
+                       fDeleteButton.setEnabled(notBuiltIn);
+               }
+
+               public void widgetSelected(SelectionEvent e) {
+                       final Button button= (Button)e.widget;
+                       if (button == fEditButton)
+                               modifyButtonPressed();
+                       else if (button == fDeleteButton) 
+                               deleteButtonPressed();
+                       else if (button == fNewButton)
+                               newButtonPressed();
+                       else if (button == fLoadButton)
+                               loadButtonPressed();
+               }
+
+               public void widgetDefaultSelected(SelectionEvent e) {
+               }
+
+               private void modifyButtonPressed() {
+                       final StatusDialog modifyDialog= createModifyDialog(fComposite.getShell(), fProfileManager.getSelected(), fProfileManager, fProfileStore, false);
+                       modifyDialog.open();
+               }
+
+               private void deleteButtonPressed() {
+                       if (MessageDialog.openQuestion(
+                                       fComposite.getShell(), 
+                                       FormatterMessages.CodingStyleConfigurationBlock_delete_confirmation_title, 
+                                       Messages.format(FormatterMessages.CodingStyleConfigurationBlock_delete_confirmation_question, fProfileManager.getSelected().getName()))) { 
+                               fProfileManager.deleteSelected();
+                       }
+               }
+
+               private void newButtonPressed() {
+                       final CreateProfileDialog p= new CreateProfileDialog(fComposite.getShell(), fProfileManager, fProfileVersioner);
+                       if (p.open() != Window.OK) 
+                               return;
+                       if (!p.openEditDialog()) 
+                               return;
+                       final StatusDialog modifyDialog= createModifyDialog(fComposite.getShell(), p.getCreatedProfile(), fProfileManager, fProfileStore, true);
+                       modifyDialog.open();
+               }
+
+               private void loadButtonPressed() {
+                       final FileDialog dialog= new FileDialog(fComposite.getShell(), SWT.OPEN);
+                       dialog.setText(FormatterMessages.CodingStyleConfigurationBlock_load_profile_dialog_title); 
+                       dialog.setFilterExtensions(new String [] {"*.xml"}); //$NON-NLS-1$
+                       final String lastPath= CUIPlugin.getDefault().getDialogSettings().get(fLastSaveLoadPathKey + ".loadpath"); //$NON-NLS-1$
+                       if (lastPath != null) {
+                               dialog.setFilterPath(lastPath);
+                       }
+                       final String path= dialog.open();
+                       if (path == null) 
+                               return;
+                       CUIPlugin.getDefault().getDialogSettings().put(fLastSaveLoadPathKey + ".loadpath", dialog.getFilterPath()); //$NON-NLS-1$
+
+                       final File file= new File(path);
+                       Collection<Profile> profiles= null;
+                       try {
+                               profiles= fProfileStore.readProfilesFromFile(file);
+                       } catch (CoreException e) {
+                               final String title= FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_title; 
+                               final String message= FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_message; 
+                               ExceptionHandler.handle(e, fComposite.getShell(), title, message);
+                       }
+                       if (profiles == null || profiles.isEmpty())
+                               return;
+
+                       final CustomProfile profile= (CustomProfile)profiles.iterator().next();
+                       
+                       if (!fProfileVersioner.getProfileKind().equals(profile.getKind())) {
+                               final String title= FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_title; 
+                               final String message= Messages.format(FormatterMessages.ProfileConfigurationBlock_load_profile_wrong_profile_message, new String[] {fProfileVersioner.getProfileKind(), profile.getKind()});
+                               MessageDialog.openError(fComposite.getShell(), title, message);
+                               return;
+                       }
+
+                       if (profile.getVersion() > fProfileVersioner.getCurrentVersion()) {
+                               final String title= FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_too_new_title; 
+                               final String message= FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_too_new_message; 
+                               MessageDialog.openWarning(fComposite.getShell(), title, message);
+                       }
+
+                       if (fProfileManager.containsName(profile.getName())) {
+                               final AlreadyExistsDialog aeDialog= new AlreadyExistsDialog(fComposite.getShell(), profile, fProfileManager);
+                               if (aeDialog.open() != Window.OK) 
+                                       return;
+                       }
+                       fProfileVersioner.update(profile);
+                       fProfileManager.addProfile(profile);
+               }
+       }
+
+       /**
+        * The GUI controls
+        */
+       private Composite fComposite;
+       private Combo fProfileCombo;
+       private Button fEditButton;
+       private Button fDeleteButton;
+       private Button fNewButton;
+       private Button fLoadButton;
+       
+       private PixelConverter fPixConv;
+       /**
+        * The ProfileManager, the model of this page.
+        */
+       private final ProfileManager fProfileManager;
+       private final IScopeContext fCurrContext;
+       private final IScopeContext fInstanceScope;
+       private final ProfileStore fProfileStore;
+       private final IProfileVersioner fProfileVersioner;
+       private final String fLastSaveLoadPathKey;
+       private IPreferenceChangeListener fPreferenceListener;
+       private final PreferencesAccess fPreferenceAccess;
+       private boolean fPreferenceListenerEnabled;
+
+       public ProfileConfigurationBlock(IProject project, final PreferencesAccess access, String lastSaveLoadPathKey) {
+
+               fPreferenceAccess= access;
+               fLastSaveLoadPathKey= lastSaveLoadPathKey;
+
+               fProfileVersioner= createProfileVersioner();
+               fProfileStore= createProfileStore(fProfileVersioner);
+               fInstanceScope= access.getInstanceScope();
+               if (project != null) {
+                       fCurrContext= access.getProjectScope(project);
+               } else {
+                       fCurrContext= fInstanceScope;
+               }
+
+               List<Profile> profiles= null;
+        try {
+            profiles= fProfileStore.readProfiles(fInstanceScope);
+        } catch (CoreException e) {
+               CUIPlugin.log(e);
+        }
+        
+        if (profiles == null) 
+            profiles= new ArrayList<Profile>();
+
+               fProfileManager= createProfileManager(profiles, fCurrContext, access, fProfileVersioner);
+
+               new StoreUpdater();
+               
+               fPreferenceListenerEnabled= true;
+               fPreferenceListener= new IPreferenceChangeListener() {
+                       public void preferenceChange(PreferenceChangeEvent event) {
+                               if (fPreferenceListenerEnabled) {
+                                       preferenceChanged(event);
+                               }
+                       }
+               };
+               access.getInstanceScope().getNode(CUIPlugin.PLUGIN_ID).addPreferenceChangeListener(fPreferenceListener);
+
+       }
+
+       protected void preferenceChanged(PreferenceChangeEvent event) {
+               
+       }
+
+       protected abstract IProfileVersioner createProfileVersioner();
+       
+       protected abstract ProfileStore createProfileStore(IProfileVersioner versioner);
+       
+       protected abstract ProfileManager createProfileManager(List<Profile> profiles, IScopeContext context, PreferencesAccess access, IProfileVersioner profileVersioner);
+       
+       protected abstract ModifyDialog createModifyDialog(Shell shell, Profile profile, ProfileManager profileManager, ProfileStore profileStore, boolean newProfile);
+
+       protected abstract void configurePreview(Composite composite, int numColumns, ProfileManager profileManager);
+
+       private static Button createButton(Composite composite, String text, final int style) {
+               final Button button= new Button(composite, SWT.PUSH);
+               button.setFont(composite.getFont());
+               button.setText(text);
+
+               final GridData gd= new GridData(style);
+               gd.widthHint= SWTUtil.getButtonWidthHint(button);
+               button.setLayoutData(gd);
+               return button;
+       }
+
+       /**
+        * Create the contents
+        * @param parent Parent composite
+        * @return Created control
+        */
+       public Composite createContents(Composite parent) {
+
+               final int numColumns = 5;
+
+               fPixConv = new PixelConverter(parent);
+               fComposite = createComposite(parent, numColumns);
+
+               fProfileCombo= createProfileCombo(fComposite, 3, fPixConv.convertWidthInCharsToPixels(20));
+               fEditButton= createButton(fComposite, FormatterMessages.CodingStyleConfigurationBlock_edit_button_desc, GridData.HORIZONTAL_ALIGN_BEGINNING);  
+               fDeleteButton= createButton(fComposite, FormatterMessages.CodingStyleConfigurationBlock_remove_button_desc, GridData.HORIZONTAL_ALIGN_BEGINNING); 
+
+               fNewButton= createButton(fComposite, FormatterMessages.CodingStyleConfigurationBlock_new_button_desc, GridData.HORIZONTAL_ALIGN_BEGINNING);
+               fLoadButton= createButton(fComposite, FormatterMessages.CodingStyleConfigurationBlock_load_button_desc, GridData.HORIZONTAL_ALIGN_END);
+               createLabel(fComposite, "", 3); //$NON-NLS-1$
+
+               configurePreview(fComposite, numColumns, fProfileManager);
+
+               new ButtonController();
+               new ProfileComboController();
+
+               return fComposite;
+       }
+
+       private static Combo createProfileCombo(Composite composite, int span, int widthHint) {
+               final GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = span;
+               gd.widthHint= widthHint;
+
+               final Combo combo= new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY );
+               combo.setFont(composite.getFont());
+               combo.setLayoutData(gd);
+               return combo;
+       }
+
+       protected static Label createLabel(Composite composite, String text, int numColumns) {
+               final GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               gd.horizontalSpan = numColumns;
+               gd.widthHint= 0;
+
+               final Label label = new Label(composite, SWT.WRAP);
+               label.setFont(composite.getFont());
+               label.setText(text);
+               label.setLayoutData(gd);
+               return label;           
+       }
+
+       private Composite createComposite(Composite parent, int numColumns) {
+               final Composite composite = new Composite(parent, SWT.NONE);
+               composite.setFont(parent.getFont());
+
+               final GridLayout layout = new GridLayout(numColumns, false);
+               layout.marginHeight = 0;
+               layout.marginWidth = 0;
+               composite.setLayout(layout);
+               return composite;
+       }
+
+       public final boolean hasProjectSpecificOptions(IProject project) {
+               if (project != null) {
+                       return fProfileManager.hasProjectSpecificSettings(new ProjectScope(project));
+               }
+               return false;
+       }
+
+       public boolean performOk() {
+               return true;
+       }
+
+       public void performApply() {
+               try {
+                       fCurrContext.getNode(CUIPlugin.PLUGIN_ID).flush();
+                       fCurrContext.getNode(CCorePlugin.PLUGIN_ID).flush();
+                       if (fCurrContext != fInstanceScope) {
+                               fInstanceScope.getNode(CUIPlugin.PLUGIN_ID).flush();
+                               fInstanceScope.getNode(CCorePlugin.PLUGIN_ID).flush();
+                       }
+               } catch (BackingStoreException e) {
+                       CUIPlugin.log(e);
+               }
+       }
+
+       public void performDefaults() {
+               Profile profile= fProfileManager.getDefaultProfile();
+               if (profile != null) {
+                       int defaultIndex= fProfileManager.getSortedProfiles().indexOf(profile);
+                       if (defaultIndex != -1) {
+                               fProfileManager.setSelected(profile);
+                       }
+               }
+       }
+
+       public void dispose() {
+               if (fPreferenceListener != null) {
+                       fPreferenceAccess.getInstanceScope().getNode(CUIPlugin.PLUGIN_ID).removePreferenceChangeListener(fPreferenceListener);
+                       fPreferenceListener= null;
+               }
+       }
+
+       public void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
+               if (useProjectSpecificSettings) {
+                       fProfileManager.commitChanges(fCurrContext);
+               } else {
+                       fProfileManager.clearAllSettings(fCurrContext);
+               }
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileManager.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileManager.java
new file mode 100644 (file)
index 0000000..c032bd1
--- /dev/null
@@ -0,0 +1,807 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences.formatter;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Observable;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.osgi.util.TextProcessor;
+import org.osgi.service.prefs.BackingStoreException;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.preferences.PreferencesAccess;
+import org.eclipse.cdt.internal.ui.util.Messages;
+
+/**
+ * The model for the set of profiles which are available in the workbench.
+ */
+public abstract class ProfileManager extends Observable {
+       private static final Map<String, String> EMPTY_MAP = Collections.emptyMap();
+       
+    public static final class KeySet {
+
+               private final List<String> fKeys;
+               private final String fNodeName;
+
+               public KeySet(String nodeName, List<String> keys) {
+                       fNodeName= nodeName;
+                       fKeys= keys;
+        }
+
+        public String getNodeName() {
+               return fNodeName;
+        }
+
+        public List<String> getKeys() {
+               return fKeys;
+        }
+    }
+       
+    /**
+     * A prefix which is prepended to every ID of a user-defined profile, in order
+     * to differentiate it from a built-in profile.
+     */
+       private final static String ID_PREFIX= "_"; //$NON-NLS-1$
+       
+       /**
+        * Represents a profile with a unique ID, a name and a map 
+        * containing the code formatter settings.
+        */
+       public static abstract class Profile implements Comparable<Profile> {
+               
+               public abstract String getName();
+               public abstract Profile rename(String name, ProfileManager manager);
+               
+               public abstract Map<String,String> getSettings();
+               public abstract void setSettings(Map<String,String> settings);
+               
+               public abstract int getVersion();
+               
+               public boolean hasEqualSettings(Map<String,String> otherMap, Collection<String> allKeys) {
+                       Map<String,String> settings= getSettings();
+                       for (Object element : allKeys) {
+                               String key= (String) element;
+                               Object other= otherMap.get(key);
+                               Object curr= settings.get(key);
+                               if (other == null) {
+                                       if (curr != null) {
+                                               return false;
+                                       }
+                               } else if (!other.equals(curr)) {
+                                       return false;
+                               }
+                       }
+                       return true;
+               }
+               
+               public abstract boolean isProfileToSave();
+               
+               public abstract String getID();
+               
+               public boolean isSharedProfile() {
+                       return false;
+               }
+               
+               public boolean isBuiltInProfile() {
+                       return false;
+               }
+       }
+       
+       /**
+        * Represents a built-in profile. The state of a built-in profile 
+        * cannot be changed after instantiation.
+        */
+       public final static class BuiltInProfile extends Profile {
+               private final String fName;
+               private final String fID;
+               private final Map<String,String> fSettings;
+               private final int fOrder;
+               private final int fCurrentVersion;
+               private final String fProfileKind;
+               
+               protected BuiltInProfile(String ID, String name, Map<String,String> settings, int order, int currentVersion, String profileKind) {
+                       fName= TextProcessor.process(name);
+                       fID= ID;
+                       fSettings= settings;
+                       fOrder= order;
+                       fCurrentVersion= currentVersion;
+                       fProfileKind= profileKind;
+               }
+               
+               @Override
+               public String getName() { 
+                       return fName;   
+               }
+               
+               @Override
+               public Profile rename(String name, ProfileManager manager) {
+                       final String trimmed= name.trim();
+                       CustomProfile newProfile= new CustomProfile(trimmed, fSettings, fCurrentVersion, fProfileKind);
+                       manager.addProfile(newProfile);
+                       return newProfile;
+               }
+               
+               @Override
+               public Map<String,String> getSettings() {
+                       return fSettings;
+               }
+       
+               @Override
+               public void setSettings(Map<String,String> settings) {
+               }
+       
+               @Override
+               public String getID() { 
+                       return fID; 
+               }
+               
+               public final int compareTo(Profile o) {
+                       if (o instanceof BuiltInProfile) {
+                               return fOrder - ((BuiltInProfile)o).fOrder;
+                       }
+                       return -1;
+               }
+
+               @Override
+               public boolean isProfileToSave() {
+                       return false;
+               }
+               
+               @Override
+               public boolean isBuiltInProfile() {
+                       return true;
+               }
+
+        @Override
+               public int getVersion() {
+               return fCurrentVersion;
+        }
+       
+       }
+
+       /**
+        * Represents a user-defined profile. A custom profile can be modified after instantiation.
+        */
+       public static class CustomProfile extends Profile {
+               private String fName;
+               private Map<String,String> fSettings;
+               protected ProfileManager fManager;
+               private int fVersion;
+               private final String fKind;
+
+               public CustomProfile(String name, Map<String,String> settings, int version, String kind) {
+                       fName= name;
+                       fSettings= settings;
+                       fVersion= version;
+                       fKind= kind;
+               }
+               
+               @Override
+               public String getName() {
+                       return fName;
+               }
+               
+               @Override
+               public Profile rename(String name, ProfileManager manager) {
+                       final String trimmed= name.trim();
+                       if (trimmed.equals(getName())) 
+                               return this;
+                       
+                       String oldID= getID(); // remember old id before changing name
+                       fName= trimmed;
+                       
+                       manager.profileRenamed(this, oldID);
+                       return this;
+               }
+
+               @Override
+               public Map<String,String> getSettings() { 
+                       return fSettings;
+               }
+               
+               @Override
+               public void setSettings(Map<String,String> settings) {
+                       if (settings == null)
+                               throw new IllegalArgumentException();
+                       fSettings= settings;
+                       if (fManager != null) {
+                               fManager.profileChanged(this);
+                       }
+               }
+               
+               @Override
+               public String getID() { 
+                       return ID_PREFIX + fName;
+               }
+               
+               public void setManager(ProfileManager profileManager) {
+                       fManager= profileManager;
+               }
+               
+               public ProfileManager getManager() {
+                       return fManager;
+               }
+
+               @Override
+               public int getVersion() {
+                       return fVersion;
+               }
+               
+               public void setVersion(int version)     {
+                       fVersion= version;
+               }
+               
+               public int compareTo(Profile o) {
+                       if (o instanceof SharedProfile) {
+                               return -1;
+                       }
+                       if (o instanceof CustomProfile) {
+                               return getName().compareToIgnoreCase((o).getName());
+                       }
+                       return 1;
+               }
+               
+               @Override
+               public boolean isProfileToSave() {
+                       return true;
+               }
+
+        public String getKind() {
+               return fKind;
+        }
+
+       }
+       
+       public final static class SharedProfile extends CustomProfile {
+               
+               public SharedProfile(String oldName, Map<String,String> options, int version, String profileKind) {
+                       super(oldName, options, version, profileKind);
+               }
+               
+               @Override
+               public Profile rename(String name, ProfileManager manager) {
+                       CustomProfile profile= new CustomProfile(name.trim(), getSettings(), getVersion(), getKind());
+
+                       manager.profileReplaced(this, profile);
+                       return profile;
+               }
+                               
+               @Override
+               public String getID() { 
+                       return SHARED_PROFILE;
+               }
+               
+               @Override
+               public final int compareTo(Profile o) {
+                       return 1;
+               }
+               
+               @Override
+               public boolean isProfileToSave() {
+                       return false;
+               }
+               
+               @Override
+               public boolean isSharedProfile() {
+                       return true;
+               }
+       }
+       
+
+       /**
+        * The possible events for observers listening to this class.
+        */
+       public final static int SELECTION_CHANGED_EVENT= 1;
+       public final static int PROFILE_DELETED_EVENT= 2;
+       public final static int PROFILE_RENAMED_EVENT= 3;
+       public final static int PROFILE_CREATED_EVENT= 4;
+       public final static int SETTINGS_CHANGED_EVENT= 5;
+
+       
+       /**
+        * The key of the preference where the selected profile is stored.
+        */
+       private final String fProfileKey;
+       
+       /**
+        * The key of the preference where the version of the current settings is stored
+        */
+       private final String fProfileVersionKey;
+
+       public final static String SHARED_PROFILE= "org.eclipse.cdt.ui.default.shared"; //$NON-NLS-1$
+       
+       /**
+        * A map containing the available profiles, using the IDs as keys.
+        */
+       private final Map<String,Profile> fProfiles;
+       
+       /**
+        * The available profiles, sorted by name.
+        */
+       private final List<Profile> fProfilesByName;
+       
+       /**
+        * The currently selected profile. 
+        */
+       private Profile fSelected;
+       
+       /**
+        * The keys of the options to be saved with each profile
+        */
+       private final KeySet[] fKeySets;
+
+       private final PreferencesAccess fPreferencesAccess;
+       private final IProfileVersioner fProfileVersioner;
+       
+       /**
+        * Create and initialize a new profile manager.
+        * @param profiles Initial custom profiles (List of type <code>CustomProfile</code>)
+        * @param profileVersioner 
+        */
+       public ProfileManager(
+                       List<Profile> profiles, 
+                       IScopeContext context, 
+                       PreferencesAccess preferencesAccess, 
+                       IProfileVersioner profileVersioner,
+                       KeySet[] keySets,
+                       String profileKey,
+                       String profileVersionKey) {
+               
+               fPreferencesAccess= preferencesAccess;
+               fProfileVersioner= profileVersioner;
+               fKeySets= keySets;
+               fProfileKey= profileKey;
+               fProfileVersionKey= profileVersionKey;
+               
+               fProfiles= new HashMap<String, Profile>();
+               fProfilesByName= new ArrayList<Profile>();
+       
+               for (Object element : profiles) {
+                       final Profile profile= (Profile) element;
+                       if (profile instanceof CustomProfile) {
+                               ((CustomProfile)profile).setManager(this);
+                       }
+                       fProfiles.put(profile.getID(), profile);
+                       fProfilesByName.add(profile);
+               }
+
+               Collections.sort(fProfilesByName);
+               
+               String profileId= getSelectedProfileId(fPreferencesAccess.getInstanceScope());
+               
+               Profile profile= fProfiles.get(profileId);
+               if (profile == null) {
+                       profile= getDefaultProfile();
+               }
+               fSelected= profile;
+               
+               if (context.getName() == ProjectScope.SCOPE && hasProjectSpecificSettings(context)) {
+                       Map<String, String> map= readFromPreferenceStore(context, profile);
+                       if (map != null) {
+                               
+                               List<String> allKeys= new ArrayList<String>();
+                               for (KeySet keySet : fKeySets) {
+                               allKeys.addAll(keySet.getKeys());
+                       }
+                       Collections.sort(allKeys);
+                               
+                               Profile matching= null;
+                       
+                               String projProfileId= context.getNode(CUIPlugin.PLUGIN_ID).get(fProfileKey, null);
+                               if (projProfileId != null) {
+                                       Profile curr= fProfiles.get(projProfileId);
+                                       if (curr != null && (curr.isBuiltInProfile() || curr.hasEqualSettings(map, allKeys))) {
+                                               matching= curr;
+                                       }
+                               } else {
+                                       // old version: look for similar
+                                       for (Object element : fProfilesByName) {
+                                               Profile curr= (Profile) element;
+                                               if (curr.hasEqualSettings(map, allKeys)) {
+                                                       matching= curr;
+                                                       break;
+                                               }
+                                       }
+                               }
+                               if (matching == null) {
+                                       String name;
+                                       if (projProfileId != null && !fProfiles.containsKey(projProfileId)) {
+                                               name= Messages.format(FormatterMessages.ProfileManager_unmanaged_profile_with_name, projProfileId.substring(ID_PREFIX.length()));
+                                       } else {
+                                               name= FormatterMessages.ProfileManager_unmanaged_profile;
+                                       }
+                                       // current settings do not correspond to any profile -> create a 'team' profile
+                                       SharedProfile shared= new SharedProfile(name, map, fProfileVersioner.getCurrentVersion(), fProfileVersioner.getProfileKind());
+                                       shared.setManager(this);
+                                       fProfiles.put(shared.getID(), shared);
+                                       fProfilesByName.add(shared); // add last
+                                       matching= shared;
+                               }
+                               fSelected= matching;
+                       }
+               }
+       }
+       
+       protected String getSelectedProfileId(IScopeContext instanceScope) {
+               String profileId= instanceScope.getNode(CUIPlugin.PLUGIN_ID).get(fProfileKey, null);
+               if (profileId == null) {
+                       // request from bug 129427
+                       profileId= DefaultScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID).get(fProfileKey, null);
+               }
+           return profileId;
+    }
+
+       /**
+        * Notify observers with a message. The message must be one of the following:
+        * @param message Message to send out
+        * 
+        * @see #SELECTION_CHANGED_EVENT
+        * @see #PROFILE_DELETED_EVENT
+        * @see #PROFILE_RENAMED_EVENT
+        * @see #PROFILE_CREATED_EVENT
+        * @see #SETTINGS_CHANGED_EVENT
+        */
+       protected void notifyObservers(int message) {
+               setChanged();
+               notifyObservers(new Integer(message));
+       }
+       
+       public static boolean hasProjectSpecificSettings(IScopeContext context, KeySet[] keySets) {
+               for (KeySet keySet : keySets) {
+               IEclipsePreferences preferences= context.getNode(keySet.getNodeName());
+               for (Object element : keySet.getKeys()) {
+                   final String key= (String)element;
+                   Object val= preferences.get(key, null);
+                   if (val != null) {
+                       return true;
+                   }
+            }
+        }
+               return false;
+       }
+       
+       public boolean hasProjectSpecificSettings(IScopeContext context) {
+               return hasProjectSpecificSettings(context, fKeySets);
+       }
+
+       /**
+        * Only to read project specific settings to find out to what profile it matches.
+        * @param context The project context
+        */
+       public Map<String, String> readFromPreferenceStore(IScopeContext context, Profile workspaceProfile) {
+               final Map<String, String> profileOptions= new HashMap<String, String>();
+               IEclipsePreferences uiPrefs= context.getNode(CUIPlugin.PLUGIN_ID);
+                               
+               int version= uiPrefs.getInt(fProfileVersionKey, fProfileVersioner.getFirstVersion());
+               if (version != fProfileVersioner.getCurrentVersion()) {
+                       Map<String, String> allOptions= new HashMap<String, String>();
+                       for (KeySet keySet : fKeySets) {
+                   addAll(context.getNode(keySet.getNodeName()), allOptions);
+            }
+                       CustomProfile profile= new CustomProfile("tmp", allOptions, version, fProfileVersioner.getProfileKind()); //$NON-NLS-1$
+                       fProfileVersioner.update(profile);
+                       return profile.getSettings();
+               }
+               
+               boolean hasValues= false;
+               for (KeySet keySet : fKeySets) {
+               IEclipsePreferences preferences= context.getNode(keySet.getNodeName());
+               for (Object element : keySet.getKeys()) {
+                               final String key= (String) element;
+                               String val= preferences.get(key, null);
+                               if (val != null) {
+                                       hasValues= true;
+                               } else {
+                                       val= workspaceProfile.getSettings().get(key);
+                               }
+                               profileOptions.put(key, val);
+                       }
+        }
+               
+               if (!hasValues) {
+                       return null;
+               }
+
+               return profileOptions;
+       }
+       
+       /**
+        * @param uiPrefs
+        * @param allOptions
+        */
+       private void addAll(IEclipsePreferences uiPrefs, Map<String,String> allOptions) {
+               try {
+                       String[] keys= uiPrefs.keys();
+                       for (String key : keys) {
+                               String val= uiPrefs.get(key, null);
+                               if (val != null) {
+                                       allOptions.put(key, val);
+                               }
+                       }
+               } catch (BackingStoreException e) {
+                       // ignore
+               }
+       }
+
+       private boolean updatePreferences(IEclipsePreferences prefs, List<String> keys, Map<String,String> profileOptions) {
+               boolean hasChanges= false;
+               for (Object element : keys) {
+                       final String key= (String) element;
+                       final String oldVal= prefs.get(key, null);
+                       final String val= profileOptions.get(key);
+                       if (val == null) {
+                               if (oldVal != null) {
+                                       prefs.remove(key);
+                                       hasChanges= true;
+                               }
+                       } else if (!val.equals(oldVal)) {
+                               prefs.put(key, val);
+                               hasChanges= true;
+                       }
+               }
+               return hasChanges;
+       }
+       
+       /**
+        * Update all formatter settings with the settings of the specified profile. 
+        * @param profile The profile to write to the preference store
+        */
+       private void writeToPreferenceStore(Profile profile, IScopeContext context) {
+               final Map<String,String> profileOptions= profile.getSettings();
+               
+               for (KeySet keySet : fKeySets) {
+               updatePreferences(context.getNode(keySet.getNodeName()), keySet.getKeys(), profileOptions);
+        }
+               
+               final IEclipsePreferences uiPrefs= context.getNode(CUIPlugin.PLUGIN_ID);
+               if (uiPrefs.getInt(fProfileVersionKey, 0) != fProfileVersioner.getCurrentVersion()) {
+                       uiPrefs.putInt(fProfileVersionKey, fProfileVersioner.getCurrentVersion());
+               }
+               
+               if (context.getName() == InstanceScope.SCOPE) {
+                       uiPrefs.put(fProfileKey, profile.getID());
+               } else if (context.getName() == ProjectScope.SCOPE && !profile.isSharedProfile()) {
+                       uiPrefs.put(fProfileKey, profile.getID());
+               }
+       }
+       
+       /** 
+        * Get an immutable list as view on all profiles, sorted alphabetically. Unless the set 
+        * of profiles has been modified between the two calls, the sequence is guaranteed to 
+        * correspond to the one returned by <code>getSortedNames</code>.
+        * @return a list of elements of type <code>Profile</code>
+        * 
+        * @see #getSortedDisplayNames()
+        */
+       public List<Profile> getSortedProfiles() {
+               return Collections.unmodifiableList(fProfilesByName);
+       }
+
+       /**
+        * Get the names of all profiles stored in this profile manager, sorted alphabetically. Unless the set of 
+        * profiles has been modified between the two calls, the sequence is guaranteed to correspond to the one 
+        * returned by <code>getSortedProfiles</code>.
+        * @return All names, sorted alphabetically
+        * @see #getSortedProfiles()  
+        */     
+       public String[] getSortedDisplayNames() {
+               final String[] sortedNames= new String[fProfilesByName.size()];
+               int i= 0;
+               for (Object element : fProfilesByName) {
+                       Profile curr= (Profile) element;
+                       sortedNames[i++]= curr.getName();
+               }
+               return sortedNames;
+       }
+       
+       /**
+        * Get the profile for this profile id.
+        * @param ID The profile ID
+        * @return The profile with the given ID or <code>null</code> 
+        */
+       public Profile getProfile(String ID) {
+               return fProfiles.get(ID);
+       }
+       
+       /**
+        * Activate the selected profile, update all necessary options in
+        * preferences and save profiles to disk.
+        */
+       public void commitChanges(IScopeContext scopeContext) {
+               if (fSelected != null) {
+                       writeToPreferenceStore(fSelected, scopeContext);
+               }
+       }
+       
+       public void clearAllSettings(IScopeContext context) {
+               for (KeySet keySet : fKeySets) {
+               updatePreferences(context.getNode(keySet.getNodeName()), keySet.getKeys(), EMPTY_MAP);
+        }
+               
+               final IEclipsePreferences uiPrefs= context.getNode(CUIPlugin.PLUGIN_ID);
+               uiPrefs.remove(fProfileKey);
+       }
+       
+       /**
+        * Get the currently selected profile.
+        * @return The currently selected profile.
+        */
+       public Profile getSelected() {
+               return fSelected;
+       }
+
+       /**
+        * Set the selected profile. The profile must already be contained in this profile manager.
+        * @param profile The profile to select
+        */
+       public void setSelected(Profile profile) {
+               final Profile newSelected= fProfiles.get(profile.getID());
+               if (newSelected != null && !newSelected.equals(fSelected)) {
+                       fSelected= newSelected;
+                       notifyObservers(SELECTION_CHANGED_EVENT);
+               }
+       }
+
+       /**
+        * Check whether a user-defined profile in this profile manager
+        * already has this name.
+        * @param name The name to test for
+        * @return Returns <code>true</code> if a profile with the given name exists
+        */
+       public boolean containsName(String name) {
+               for (Object element : fProfilesByName) {
+                       Profile curr= (Profile) element;
+                       if (name.equals(curr.getName())) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+       
+       /**
+        * Add a new custom profile to this profile manager.
+        * @param profile The profile to add
+        */     
+       public void addProfile(CustomProfile profile) {
+               profile.setManager(this);
+               final CustomProfile oldProfile= (CustomProfile)fProfiles.get(profile.getID());
+               if (oldProfile != null) {
+                       fProfiles.remove(oldProfile.getID());
+                       fProfilesByName.remove(oldProfile);
+                       oldProfile.setManager(null);
+               }
+               fProfiles.put(profile.getID(), profile);
+               fProfilesByName.add(profile);
+               Collections.sort(fProfilesByName);
+               fSelected= profile;
+               notifyObservers(PROFILE_CREATED_EVENT);
+       }
+       
+       /**
+        * Delete the currently selected profile from this profile manager. The next profile
+        * in the list is selected.
+        * @return true if the profile has been successfully removed, false otherwise.
+        */
+       public boolean deleteSelected() {
+               if (!(fSelected instanceof CustomProfile)) 
+                       return false;
+               
+               return deleteProfile((CustomProfile)fSelected);
+       }
+
+       public boolean deleteProfile(CustomProfile profile) {
+           int index= fProfilesByName.indexOf(profile);
+               
+               fProfiles.remove(profile.getID());
+               fProfilesByName.remove(profile);
+               
+               profile.setManager(null);
+               
+               if (index >= fProfilesByName.size())
+                       index--;
+               fSelected= fProfilesByName.get(index);
+
+               if (!profile.isSharedProfile()) {
+                       updateProfilesWithName(profile.getID(), null, false);
+               }
+               
+               notifyObservers(PROFILE_DELETED_EVENT);
+               return true;
+    }
+       
+       public void profileRenamed(CustomProfile profile, String oldID) {
+               fProfiles.remove(oldID);
+               fProfiles.put(profile.getID(), profile);
+
+               if (!profile.isSharedProfile()) {
+                       updateProfilesWithName(oldID, profile, false);
+               }
+               
+               Collections.sort(fProfilesByName);
+               notifyObservers(PROFILE_RENAMED_EVENT);
+       }
+       
+       public void profileReplaced(CustomProfile oldProfile, CustomProfile newProfile) {
+               fProfiles.remove(oldProfile.getID());
+               fProfiles.put(newProfile.getID(), newProfile);
+               fProfilesByName.remove(oldProfile);
+               fProfilesByName.add(newProfile);
+               Collections.sort(fProfilesByName);
+               
+               if (!oldProfile.isSharedProfile()) {
+                       updateProfilesWithName(oldProfile.getID(), null, false);
+               }
+               
+               setSelected(newProfile);
+               notifyObservers(PROFILE_CREATED_EVENT);
+               notifyObservers(SELECTION_CHANGED_EVENT);
+       }
+       
+       public void profileChanged(CustomProfile profile) {
+               if (!profile.isSharedProfile()) {
+                       updateProfilesWithName(profile.getID(), profile, true);
+               }
+               
+               notifyObservers(SETTINGS_CHANGED_EVENT);
+       }
+       
+       private void updateProfilesWithName(String oldName, Profile newProfile, boolean applySettings) {
+               IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects();
+               for (IProject project : projects) {
+                       IScopeContext projectScope= fPreferencesAccess.getProjectScope(project);
+                       IEclipsePreferences node= projectScope.getNode(CUIPlugin.PLUGIN_ID);
+                       String profileId= node.get(fProfileKey, null);
+                       if (oldName.equals(profileId)) {
+                               if (newProfile == null) {
+                                       node.remove(fProfileKey);
+                               } else {
+                                       if (applySettings) {
+                                               writeToPreferenceStore(newProfile, projectScope);
+                                       } else {
+                                               node.put(fProfileKey, newProfile.getID());
+                                       }
+                               }
+                       }
+               }
+               
+               IScopeContext instanceScope= fPreferencesAccess.getInstanceScope();
+               final IEclipsePreferences uiPrefs= instanceScope.getNode(CUIPlugin.PLUGIN_ID);
+               if (newProfile != null && oldName.equals(uiPrefs.get(fProfileKey, null))) {
+                       writeToPreferenceStore(newProfile, instanceScope);
+               }
+       }
+
+       /**
+        * @return Default scoped profile or null
+        */
+    public Profile getDefaultProfile() {
+               return getProfile(fPreferencesAccess.getDefaultScope().getNode(CUIPlugin.PLUGIN_ID).get(fProfileKey, "")); //$NON-NLS-1$
+    }
+
+       public IProfileVersioner getProfileVersioner() {
+       return fProfileVersioner;
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileStore.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileStore.java
new file mode 100644 (file)
index 0000000..b3754b1
--- /dev/null
@@ -0,0 +1,335 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin, Google
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences.formatter;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.CUIException;
+import org.eclipse.cdt.internal.ui.CUIStatus;
+import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
+import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.Profile;
+
+
+public class ProfileStore {
+       /** The default encoding to use */
+       public static final String ENCODING= "UTF-8"; //$NON-NLS-1$
+       
+       protected static final String VERSION_KEY_SUFFIX= ".version"; //$NON-NLS-1$
+       
+       /**
+        * A SAX event handler to parse the xml format for profiles. 
+        */
+       private final static class ProfileDefaultHandler extends DefaultHandler {
+               private List<Profile> fProfiles;
+               private int fVersion;
+               
+               private String fName;
+               private Map<String, String> fSettings;
+               private String fKind;
+
+               @Override
+               public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
+
+                       if (qName.equals(XML_NODE_SETTING)) {
+
+                               final String key= attributes.getValue(XML_ATTRIBUTE_ID);
+                               final String value= attributes.getValue(XML_ATTRIBUTE_VALUE);
+                               fSettings.put(key, value);
+
+                       } else if (qName.equals(XML_NODE_PROFILE)) {
+
+                               fName= attributes.getValue(XML_ATTRIBUTE_NAME);
+                               fKind= attributes.getValue(XML_ATTRIBUTE_PROFILE_KIND);
+                               if (fKind == null) //Can only be an CodeFormatterProfile created pre 20061106
+                                       fKind= ProfileVersioner.CODE_FORMATTER_PROFILE_KIND;
+                               
+                               fSettings= new HashMap<String, String>(200);
+
+                       }
+                       else if (qName.equals(XML_NODE_ROOT)) {
+
+                               fProfiles= new ArrayList<Profile>();
+                               try {
+                                       fVersion= Integer.parseInt(attributes.getValue(XML_ATTRIBUTE_VERSION));
+                               } catch (NumberFormatException ex) {
+                                       throw new SAXException(ex);
+                               }
+
+                       }
+               }
+               
+               @Override
+               public void endElement(String uri, String localName, String qName) {
+                       if (qName.equals(XML_NODE_PROFILE)) {
+                               fProfiles.add(new CustomProfile(fName, fSettings, fVersion, fKind));
+                               fName= null;
+                               fSettings= null;
+                               fKind= null;
+                       }
+               }
+               
+               public List<Profile> getProfiles() {
+                       return fProfiles;
+               }
+       }
+
+       /**
+        * Identifiers for the XML file.
+        */
+       private final static String XML_NODE_ROOT= "profiles"; //$NON-NLS-1$
+       private final static String XML_NODE_PROFILE= "profile"; //$NON-NLS-1$
+       private final static String XML_NODE_SETTING= "setting"; //$NON-NLS-1$
+       
+       private final static String XML_ATTRIBUTE_VERSION= "version"; //$NON-NLS-1$
+       private final static String XML_ATTRIBUTE_ID= "id"; //$NON-NLS-1$
+       private final static String XML_ATTRIBUTE_NAME= "name"; //$NON-NLS-1$
+       private final static String XML_ATTRIBUTE_PROFILE_KIND= "kind"; //$NON-NLS-1$
+       private final static String XML_ATTRIBUTE_VALUE= "value"; //$NON-NLS-1$
+       
+       private final IProfileVersioner fProfileVersioner;
+       private final String fProfilesKey;
+       private final String fProfilesVersionKey;
+               
+               
+       public ProfileStore(String profilesKey, IProfileVersioner profileVersioner) {
+               fProfilesKey= profilesKey;
+               fProfileVersioner= profileVersioner;
+               fProfilesVersionKey= profilesKey + VERSION_KEY_SUFFIX;
+       }
+       
+       /**
+        * @return Returns the collection of profiles currently stored in the preference store or
+        * <code>null</code> if the loading failed. The elements are of type {@link ProfileManager.CustomProfile}
+        * and are all updated to the latest version.
+        * @throws CoreException
+        */
+       public List<Profile> readProfiles(IScopeContext scope) throws CoreException {
+               return readProfilesFromString(scope.getNode(CUIPlugin.PLUGIN_ID).get(fProfilesKey, null));
+       }
+       
+       public void writeProfiles(Collection<Profile> profiles, IScopeContext instanceScope) throws CoreException {
+               ByteArrayOutputStream stream= new ByteArrayOutputStream(2000);
+               try {
+                       writeProfilesToStream(profiles, stream, ENCODING, fProfileVersioner);
+                       String val;
+                       try {
+                               val= stream.toString(ENCODING);
+                       } catch (UnsupportedEncodingException e) {
+                               val= stream.toString(); 
+                       }
+                       IEclipsePreferences uiPreferences = instanceScope.getNode(CUIPlugin.PLUGIN_ID);
+                       uiPreferences.put(fProfilesKey, val);
+                       uiPreferences.putInt(fProfilesVersionKey, fProfileVersioner.getCurrentVersion());
+               } finally {
+                       try { stream.close(); } catch (IOException e) { /* ignore */ }
+               }
+       }
+       
+       public List<Profile> readProfilesFromString(String profiles) throws CoreException {
+           if (profiles != null && profiles.length() > 0) {
+                       byte[] bytes;
+                       try {
+                               bytes= profiles.getBytes(ENCODING);
+                       } catch (UnsupportedEncodingException e) {
+                               bytes= profiles.getBytes();
+                       }
+                       InputStream is= new ByteArrayInputStream(bytes);
+                       try {
+                               List<Profile> res= readProfilesFromStream(new InputSource(is));
+                               if (res != null) {
+                                       for (int i= 0; i < res.size(); i++) {
+                                               fProfileVersioner.update((CustomProfile) res.get(i));
+                                       }
+                               }
+                               return res;
+                       } finally {
+                               try { is.close(); } catch (IOException e) { /* ignore */ }
+                       }
+               }
+               return null;
+       }       
+
+       /**
+        * Read the available profiles from the internal XML file and return them
+        * as collection or <code>null</code> if the file is not a profile file.
+        * @param file The file to read from
+        * @return returns a list of <code>CustomProfile</code> or <code>null</code>
+        * @throws CoreException
+        */
+       public List<Profile> readProfilesFromFile(File file) throws CoreException {
+               try {
+                       final FileInputStream reader= new FileInputStream(file); 
+                       try {
+                               return readProfilesFromStream(new InputSource(reader));
+                       } finally {
+                               try { reader.close(); } catch (IOException e) { /* ignore */ }
+                       }
+               } catch (IOException e) {
+                       throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_reading_xml_message);  
+               }
+       }
+       
+       /**
+        * Load profiles from a XML stream and add them to a map or <code>null</code> if the source is not a profile store.
+        * @param inputSource The input stream
+        * @return returns a list of <code>CustomProfile</code> or <code>null</code>
+        * @throws CoreException
+        */
+       protected static List<Profile> readProfilesFromStream(InputSource inputSource) throws CoreException {
+               final ProfileDefaultHandler handler= new ProfileDefaultHandler();
+               try {
+                   final SAXParserFactory factory= SAXParserFactory.newInstance();
+                       final SAXParser parser= factory.newSAXParser();
+                       parser.parse(inputSource, handler);
+               } catch (SAXException e) {
+                       throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_reading_xml_message);  
+               } catch (IOException e) {
+                       throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_reading_xml_message);  
+               } catch (ParserConfigurationException e) {
+                       throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_reading_xml_message);  
+               }
+               return handler.getProfiles();
+       }
+       
+       /**
+        * Write the available profiles to the internal XML file.
+        * @param profiles List of <code>CustomProfile</code>
+        * @param file File to write
+        * @param encoding the encoding to use
+        * @throws CoreException
+        */
+       public void writeProfilesToFile(Collection<Profile> profiles, File file, String encoding) throws CoreException {
+               final OutputStream stream;
+               try {
+                       stream= new FileOutputStream(file);
+                       try {
+                               writeProfilesToStream(profiles, stream, encoding, fProfileVersioner);
+                       } finally {
+                               try { stream.close(); } catch (IOException e) { /* ignore */ }
+                       }
+               } catch (IOException e) {
+                       throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_serializing_xml_message);  
+               }
+       }
+       
+       /**
+        * Save profiles to an XML stream
+        * @param profiles List of <code>CustomProfile</code>
+        * @param stream Stream to write
+        * @param encoding the encoding to use
+        * @throws CoreException
+        */
+       private static void writeProfilesToStream(Collection<Profile> profiles, OutputStream stream, String encoding, IProfileVersioner profileVersioner) throws CoreException {
+               try {
+                       final DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance();
+                       final DocumentBuilder builder= factory.newDocumentBuilder();            
+                       final Document document= builder.newDocument();
+                       
+                       final Element rootElement = document.createElement(XML_NODE_ROOT);
+                       rootElement.setAttribute(XML_ATTRIBUTE_VERSION, Integer.toString(profileVersioner.getCurrentVersion()));
+
+                       document.appendChild(rootElement);
+                       
+                       for (Object element : profiles) {
+                               final Profile profile= (Profile)element;
+                               if (profile.isProfileToSave()) {
+                                       final Element profileElement= createProfileElement(profile, document, profileVersioner);
+                                       rootElement.appendChild(profileElement);
+                               }
+                       }
+
+                       Transformer transformer=TransformerFactory.newInstance().newTransformer();
+                       transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
+                       transformer.setOutputProperty(OutputKeys.ENCODING, encoding);
+                       transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
+                       transformer.transform(new DOMSource(document), new StreamResult(stream));
+               } catch (TransformerException e) {
+                       throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_serializing_xml_message);  
+               } catch (ParserConfigurationException e) {
+                       throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_serializing_xml_message);  
+               }
+       }
+       
+       /*
+        * Create a new profile element in the specified document. The profile is not added
+        * to the document by this method. 
+        */
+       private static Element createProfileElement(Profile profile, Document document, IProfileVersioner profileVersioner) {
+               final Element element= document.createElement(XML_NODE_PROFILE);
+               element.setAttribute(XML_ATTRIBUTE_NAME, profile.getName());
+               element.setAttribute(XML_ATTRIBUTE_VERSION, Integer.toString(profile.getVersion()));
+               element.setAttribute(XML_ATTRIBUTE_PROFILE_KIND, profileVersioner.getProfileKind());
+               
+               final Iterator<String> keyIter= profile.getSettings().keySet().iterator();
+               
+               while (keyIter.hasNext()) {
+                       final String key= keyIter.next();
+                       final String value= profile.getSettings().get(key);
+                       if (value != null) {
+                               final Element setting= document.createElement(XML_NODE_SETTING);
+                               setting.setAttribute(XML_ATTRIBUTE_ID, key);
+                               setting.setAttribute(XML_ATTRIBUTE_VALUE, value);
+                               element.appendChild(setting);
+                       } else {
+                               CUIPlugin.logError("ProfileStore: Profile does not contain value for key " + key); //$NON-NLS-1$
+                       }
+               }
+               return element;
+       }
+       
+       /*
+        * Creates a UI exception for logging purposes
+        */
+       private static CUIException createException(Throwable t, String message) {
+               return new CUIException(CUIStatus.createError(IStatus.ERROR, message, t));
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileVersioner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileVersioner.java
new file mode 100644 (file)
index 0000000..6bc7aeb
--- /dev/null
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin, Google
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences.formatter;
+
+import java.util.Map;
+
+import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
+
+
+public class ProfileVersioner implements IProfileVersioner {
+       
+       public static final String CODE_FORMATTER_PROFILE_KIND= "CodeFormatterProfile"; //$NON-NLS-1$
+       
+       public static final int VERSION_1= 1; // < 20061106 (pre CDT 4.0M3)
+       
+       public static final int CURRENT_VERSION= VERSION_1;
+       
+       
+       public int getFirstVersion() {
+           return VERSION_1;
+    }
+
+       public int getCurrentVersion() {
+           return CURRENT_VERSION;
+    }
+       
+       /**
+     * {@inheritDoc}
+     */
+    public String getProfileKind() {
+           return CODE_FORMATTER_PROFILE_KIND;
+    }
+
+       public void update(CustomProfile profile) {
+               final Map<String, String> oldSettings= profile.getSettings();
+               Map<String, String> newSettings= updateAndComplete(oldSettings, profile.getVersion());
+               profile.setVersion(CURRENT_VERSION);
+               profile.setSettings(newSettings);
+       }
+       
+       public static int getVersionStatus(CustomProfile profile) {
+               final int version= profile.getVersion();
+               if (version < CURRENT_VERSION) 
+                       return -1;
+               else if (version > CURRENT_VERSION)
+                       return 1;
+               else 
+                       return 0;
+       }
+       
+       public static void updateAndComplete(CustomProfile profile) {
+               final Map<String, String> oldSettings= profile.getSettings();
+               Map<String, String> newSettings= updateAndComplete(oldSettings, profile.getVersion());
+               profile.setVersion(CURRENT_VERSION);
+               profile.setSettings(newSettings);
+       }
+       
+       public static Map<String, String> updateAndComplete(Map<String, String> oldSettings, int version) {
+               final Map<String, String> newSettings= FormatterProfileManager.getDefaultSettings();
+               
+               switch (version) {
+                   
+               default:
+                   for (Object element : oldSettings.keySet()) {
+                                   final String key= (String)element;
+                                   if (!newSettings.containsKey(key)) 
+                                       continue;
+                                   
+                                   final String value= oldSettings.get(key);
+                                   if (value != null) {
+                                       newSettings.put(key, value);
+                                   }
+                               }
+               }
+               return newSettings;
+       }
+ }
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/SnippetPreview.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/SnippetPreview.java
new file mode 100644 (file)
index 0000000..a42f412
--- /dev/null
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences.formatter;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.text.Document;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.text.edits.TextEdit;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
+
+import org.eclipse.cdt.internal.ui.ICStatusConstants;
+
+public class SnippetPreview extends CPreview {
+  
+    public final static class PreviewSnippet {
+        public String header;
+        public final String source;
+        public final int kind;
+        
+        public PreviewSnippet(int kind, String source) {
+            this.kind= kind;
+            this.source= source;
+        }
+    }
+    
+    private ArrayList<PreviewSnippet> fSnippets;
+
+    public SnippetPreview(Map<String, String> workingValues, Composite parent) {
+        super(workingValues, parent);
+        fSnippets= new ArrayList<PreviewSnippet>();
+    }
+
+    @Override
+       protected void doFormatPreview() {
+        if (fSnippets.isEmpty()) { 
+            fPreviewDocument.set(""); //$NON-NLS-1$
+            return;
+        }
+        
+        // This delimiter looks best for invisible characters
+        final String delimiter= "\n"; //$NON-NLS-1$
+        
+        final StringBuffer buffer= new StringBuffer();
+        for (PreviewSnippet snippet: fSnippets) {
+            String formattedSource;
+            try {
+                TextEdit edit= CodeFormatterUtil.format(snippet.kind, snippet.source, 0, delimiter,
+                               fWorkingValues);
+                       if (edit == null) {
+                               formattedSource= snippet.source;
+                       } else {
+                               Document document= new Document(snippet.source);
+                               edit.apply(document, TextEdit.NONE);
+                               formattedSource= document.get();
+                       }
+            } catch (Exception e) {
+                final IStatus status= new Status(IStatus.ERROR, CUIPlugin.getPluginId(),
+                               ICStatusConstants.INTERNAL_ERROR,
+                               FormatterMessages.CPreview_formatter_exception, e); 
+                CUIPlugin.log(status);
+                continue;
+            }
+            buffer.append(delimiter);            
+            buffer.append(formattedSource);
+            buffer.append(delimiter);            
+            buffer.append(delimiter);
+        }
+        fPreviewDocument.set(buffer.toString());
+    }
+
+    public void add(PreviewSnippet snippet) {
+        fSnippets.add(snippet);
+    }
+    
+    public void remove(PreviewSnippet snippet) {
+        fSnippets.remove(snippet);
+    }
+    
+    public void addAll(Collection<PreviewSnippet> snippets) {
+        fSnippets.addAll(snippets);
+    }
+    
+    public void clear() {
+        fSnippets.clear();
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/TranslationUnitPreview.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/TranslationUnitPreview.java
new file mode 100644 (file)
index 0000000..816d08c
--- /dev/null
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin, Google
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences.formatter;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.formatter.FormattingContext;
+import org.eclipse.jface.text.formatter.FormattingContextProperties;
+import org.eclipse.jface.text.formatter.IContentFormatter;
+import org.eclipse.jface.text.formatter.IContentFormatterExtension;
+import org.eclipse.jface.text.formatter.IFormattingContext;
+import org.eclipse.swt.widgets.Composite;
+
+import org.eclipse.cdt.core.CCorePreferenceConstants;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.ICStatusConstants;
+
+public class TranslationUnitPreview extends CPreview {
+    private String fPreviewText;
+    private int fPreviewTextOffset;
+       private String fFormatterId;
+
+    /**
+     * @param workingValues
+     * @param parent
+     */
+    public TranslationUnitPreview(Map<String, String> workingValues, Composite parent) {
+        super(workingValues, parent);
+    }
+
+    @Override
+       protected void doFormatPreview() {
+        if (fPreviewText == null) {
+            fPreviewDocument.set(""); //$NON-NLS-1$
+            return;
+        }
+        fPreviewDocument.set(fPreviewText);
+               
+               fSourceViewer.setVisibleRegion(fPreviewTextOffset, fPreviewText.length() - fPreviewTextOffset);
+               fSourceViewer.setRedraw(false);
+               final IFormattingContext context = new FormattingContext();
+               try {
+                       final IContentFormatter formatter =     fViewerConfiguration.getContentFormatter(fSourceViewer);
+                       if (formatter instanceof IContentFormatterExtension) {
+                               final IContentFormatterExtension extension = (IContentFormatterExtension) formatter;
+                               Map<String, String> prefs= fWorkingValues;
+                               if (fFormatterId != null) {
+                                       prefs= new HashMap<String, String>(fWorkingValues);
+                                       prefs.put(CCorePreferenceConstants.CODE_FORMATTER, fFormatterId);
+                               }
+                               context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, prefs);
+                               context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.valueOf(true));
+                               extension.format(fPreviewDocument, context);
+                       } else {
+                               formatter.format(fPreviewDocument, new Region(0, fPreviewDocument.getLength()));
+                       }
+               } catch (Exception e) {
+                       final IStatus status= new Status(IStatus.ERROR, CUIPlugin.getPluginId(), ICStatusConstants.INTERNAL_ERROR, 
+                               FormatterMessages.CPreview_formatter_exception, e); 
+                       CUIPlugin.log(status);
+               } finally {
+                   context.dispose();
+                   fSourceViewer.setRedraw(true);
+               }
+    }
+    
+    public void setPreviewText(String previewText) {
+               setPreviewText(previewText, 0);
+       }
+
+       public void setPreviewText(String previewText, int previewTextOffset) {
+        fPreviewText= previewText;
+        fPreviewTextOffset = previewTextOffset;
+        update();
+    }
+
+       /**
+        * @param formatterId
+        */
+       public void setFormatterId(String formatterId) {
+               fFormatterId= formatterId;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceOptions.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceOptions.java
new file mode 100644 (file)
index 0000000..4014ffd
--- /dev/null
@@ -0,0 +1,986 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.preferences.formatter;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.formatter.CodeFormatter;
+import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
+
+import org.eclipse.cdt.internal.ui.preferences.formatter.SnippetPreview.PreviewSnippet;
+
+
+/**
+ * Manage code formatter white space options on a higher level. 
+ */
+public final class WhiteSpaceOptions {
+
+    /**
+     * Represents a node in the options tree.
+     */
+       public abstract static class Node {
+           
+           private final InnerNode fParent;
+           private final String fName;
+           
+           public int index;
+           
+           protected final Map<String,String> fWorkingValues;
+           protected final ArrayList<Node> fChildren;
+
+           public Node(InnerNode parent, Map<String,String> workingValues, String message) {
+               if (workingValues == null || message == null)
+                   throw new IllegalArgumentException();
+               fParent= parent;
+               fWorkingValues= workingValues;
+               fName= message;
+               fChildren= new ArrayList<Node>();
+               if (fParent != null)
+                   fParent.add(this);
+           }
+           
+           public abstract void setChecked(boolean checked);
+
+           public boolean hasChildren() { 
+               return !fChildren.isEmpty();
+           }
+           
+           public List<Node> getChildren() {
+               return Collections.unmodifiableList(fChildren);
+           }
+           
+           public InnerNode getParent() {
+               return fParent;
+           }
+
+           @Override
+               public final String toString() {
+               return fName;
+           }
+           
+           public abstract List<PreviewSnippet> getSnippets();
+           
+           public abstract void getCheckedLeafs(List<OptionNode> list);
+       }
+       
+       /**
+        * A node representing a group of options in the tree.
+        */
+       public static class InnerNode extends Node {
+           
+        public InnerNode(InnerNode parent, Map<String,String> workingValues, String messageKey) {
+            super(parent, workingValues, messageKey);
+        }
+
+           @Override
+               public void setChecked(boolean checked) {
+               for (Object element : fChildren)
+                               ((Node)element).setChecked(checked);
+           }
+
+           public void add(Node child) {
+               fChildren.add(child);
+           }
+
+        @Override
+               public List<PreviewSnippet> getSnippets() {
+            final ArrayList<PreviewSnippet> snippets= new ArrayList<PreviewSnippet>(fChildren.size());
+            for (Object element : fChildren) {
+                final List<PreviewSnippet> childSnippets= ((Node)element).getSnippets();
+                for (PreviewSnippet snippet : childSnippets) {
+                    if (!snippets.contains(snippet)) 
+                        snippets.add(snippet);
+                }
+            }
+            return snippets;
+        }
+        
+        @Override
+               public void getCheckedLeafs(List<OptionNode> list) {
+            for (Node element : fChildren) {
+                element.getCheckedLeafs(list);
+            }
+        }
+       }
+
+       
+       /**
+        * A node representing a concrete white space option in the tree.
+        */
+       public static class OptionNode extends Node {
+           private final String fKey;
+           private final ArrayList<PreviewSnippet> fSnippets;
+           
+           public OptionNode(InnerNode parent, Map<String, String> workingValues, String messageKey, String key, PreviewSnippet snippet) {
+               super(parent, workingValues, messageKey);
+               fKey= key;
+               fSnippets= new ArrayList<PreviewSnippet>(1);
+               fSnippets.add(snippet);
+           }
+           
+        @Override
+               public void setChecked(boolean checked) {
+               fWorkingValues.put(fKey, checked ? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT);
+        }
+        
+        public boolean getChecked() {
+            return CCorePlugin.INSERT.equals(fWorkingValues.get(fKey));
+        }
+        
+        @Override
+               public List<PreviewSnippet> getSnippets() {
+            return fSnippets;
+        }
+        
+        @Override
+               public void getCheckedLeafs(List<OptionNode> list) {
+            if (getChecked()) 
+                list.add(this);
+        }
+       }
+       
+       
+       
+       /**
+        * Preview snippets.
+        */
+       
+    private final PreviewSnippet FOR_PREVIEW= new PreviewSnippet(
+    CodeFormatter.K_STATEMENTS, 
+    "for (int i= 0, j= argc; i < argc; i++, j--) {}" //$NON-NLS-1$
+    );
+
+    private final PreviewSnippet WHILE_PREVIEW= new PreviewSnippet(
+    CodeFormatter.K_STATEMENTS, 
+    "while (condition) {} do {} while (condition);" //$NON-NLS-1$
+    );
+
+    private final PreviewSnippet CATCH_PREVIEW= new PreviewSnippet(
+    CodeFormatter.K_STATEMENTS, 
+    "try { number= Math::parseInt(value); } catch (Math::Exception e) {}"); //$NON-NLS-1$
+
+    private final PreviewSnippet IF_PREVIEW= new PreviewSnippet(
+    CodeFormatter.K_STATEMENTS, 
+    "if (condition) { return foo; } else {return bar;}"); //$NON-NLS-1$
+
+    private final PreviewSnippet SWITCH_PREVIEW= new PreviewSnippet(
+    CodeFormatter.K_STATEMENTS, 
+    "switch (number) { case RED: return GREEN; case GREEN: return BLUE; case BLUE: return RED; default: return BLACK;}"); //$NON-NLS-1$
+
+    private final PreviewSnippet METHOD_DECL_PREVIEW= new PreviewSnippet(
+    CodeFormatter.K_CLASS_BODY_DECLARATIONS, 
+    "void foo() throw(E0, E1) {}" +  //$NON-NLS-1$
+    "void bar(int x, int y) throw() {}"); //$NON-NLS-1$
+
+    private final PreviewSnippet INITIALIZER_LIST_PREVIEW= new PreviewSnippet(
+    CodeFormatter.K_STATEMENTS, 
+    "int array[]= {1, 2, 3};");  //$NON-NLS-1$
+
+    private final PreviewSnippet ARRAY_PREVIEW= new PreviewSnippet(
+    CodeFormatter.K_STATEMENTS, 
+    "int array[]= {1, 2, 3};\n" + //$NON-NLS-1$
+    "array [2] = 0;\n" + //$NON-NLS-1$
+    "int * parray= new int[3];" + //$NON-NLS-1$
+    "delete[] parray;"); //$NON-NLS-1$
+
+    private final PreviewSnippet METHOD_CALL_PREVIEW= new PreviewSnippet(
+    CodeFormatter.K_STATEMENTS, 
+    "foo();\n" +  //$NON-NLS-1$
+    "bar(x, y);"); //$NON-NLS-1$
+
+    private final PreviewSnippet LABEL_PREVIEW= new PreviewSnippet(
+    CodeFormatter.K_STATEMENTS, 
+    "label: for (int i= 0; i<argc; i++) goto label;"); //$NON-NLS-1$
+
+    private final PreviewSnippet SEMICOLON_PREVIEW= new PreviewSnippet(
+    CodeFormatter.K_STATEMENTS, 
+    "int a= 4; foo(); bar(x, y);"); //$NON-NLS-1$
+
+    private final PreviewSnippet CONDITIONAL_PREVIEW= new PreviewSnippet(
+    CodeFormatter.K_TRANSLATION_UNIT, 
+    "bool value= condition ? true : false;"); //$NON-NLS-1$
+
+    private final PreviewSnippet CLASS_DECL_PREVIEW= new PreviewSnippet(
+    CodeFormatter.K_TRANSLATION_UNIT, 
+    "class MyClass : Base1, Base2 {};"); //$NON-NLS-1$
+
+    private final PreviewSnippet OPERATOR_PREVIEW= new PreviewSnippet(
+    CodeFormatter.K_STATEMENTS, 
+    "int a= -4 + -9; b= a++ / --number; c += 4; bool value= true && false;"); //$NON-NLS-1$
+
+    private final PreviewSnippet CAST_PREVIEW= new PreviewSnippet(
+    CodeFormatter.K_STATEMENTS, 
+    "char * s= ((char *)object);"); //$NON-NLS-1$
+
+    private final PreviewSnippet EXPRESSION_LIST_PREVIEW= new PreviewSnippet(
+    CodeFormatter.K_STATEMENTS, 
+    "a= 0, b= 1, c= 2, d= 3;"); //$NON-NLS-1$
+
+    private final PreviewSnippet DECLARATOR_LIST_PREVIEW= new PreviewSnippet(
+    CodeFormatter.K_STATEMENTS, 
+    "int a=0,b=1,c=2,d=3;"); //$NON-NLS-1$
+
+    private final PreviewSnippet BLOCK_PREVIEW= new PreviewSnippet(
+    CodeFormatter.K_STATEMENTS, 
+    "if (true) { return 1; } else { return 2; }"); //$NON-NLS-1$
+
+    private final PreviewSnippet PAREN_EXPR_PREVIEW= new PreviewSnippet(
+    CodeFormatter.K_STATEMENTS, 
+    "result= (a *( b +  c + d) * (e + f));"); //$NON-NLS-1$
+
+    private final PreviewSnippet TEMPLATES_PREVIEW= new PreviewSnippet(
+       CodeFormatter.K_TRANSLATION_UNIT,
+       "template<typename T1,typename T2> class map {};\n" +  //$NON-NLS-1$
+       "map<int,int> m;" //$NON-NLS-1$
+    );
+               
+       /**
+        * Create the tree, in this order: syntax element - position - abstract element
+        * @param workingValues
+        * @return returns roots (type <code>Node</code>)
+        */
+       public List<InnerNode> createTreeBySyntaxElem(Map<String, String> workingValues) {
+        final ArrayList<InnerNode> roots= new ArrayList<InnerNode>();
+        
+        InnerNode element;
+
+        element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_opening_paren); 
+        createBeforeOpenParenTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before)); 
+        createAfterOpenParenTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after)); 
+        roots.add(element);
+        
+        element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_closing_paren); 
+        createBeforeClosingParenTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before)); 
+        createAfterCloseParenTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after)); 
+        roots.add(element);
+        
+        element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_opening_brace); 
+        createBeforeOpenBraceTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before)); 
+        createAfterOpenBraceTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after)); 
+        roots.add(element);
+        
+        element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_closing_brace); 
+        createBeforeClosingBraceTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before)); 
+        createAfterCloseBraceTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after)); 
+        roots.add(element);
+        
+        element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_opening_bracket);         
+        createBeforeOpenBracketTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before)); 
+        createAfterOpenBracketTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after)); 
+        roots.add(element);
+        
+        element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_closing_bracket);         
+        createBeforeClosingBracketTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before)); 
+        roots.add(element);
+        
+        element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_operator);         
+        createBeforeOperatorTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before)); 
+        createAfterOperatorTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after)); 
+        roots.add(element);
+        
+        element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_comma);         
+        createBeforeCommaTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before)); 
+        createAfterCommaTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after)); 
+        roots.add(element);
+        
+        element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_colon);         
+        createBeforeColonTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before)); 
+        createAfterColonTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after)); 
+        roots.add(element);
+        
+        element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_semicolon);         
+        createBeforeSemicolonTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before)); 
+        createAfterSemicolonTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after)); 
+        roots.add(element);
+        
+        element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_question_mark);         
+        createBeforeQuestionTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_before)); 
+        createAfterQuestionTree(workingValues, createChild(element, workingValues, FormatterMessages.WhiteSpaceOptions_after)); 
+        roots.add(element);
+
+        element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_between_empty_parens);         
+        createBetweenEmptyParenTree(workingValues, element);
+        roots.add(element);
+
+        element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_between_empty_braces);         
+        createBetweenEmptyBracesTree(workingValues, element);
+        roots.add(element);
+        
+        element= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceOptions_between_empty_brackets);         
+        createBetweenEmptyBracketsTree(workingValues, element);
+        roots.add(element);
+
+        return roots;
+       }
+       
+    /**
+     * Create the tree, in this order: position - syntax element - abstract
+     * element
+     * @param workingValues
+     * @return returns roots (type <code>Node</code>)
+     */
+    public List<InnerNode> createAltTree(Map<String, String> workingValues) {
+
+        final ArrayList<InnerNode> roots= new ArrayList<InnerNode>();
+        
+        InnerNode parent;
+        
+        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_opening_paren); 
+        createBeforeOpenParenTree(workingValues, parent);
+
+        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_opening_paren); 
+        createAfterOpenParenTree(workingValues, parent);
+        
+        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_closing_paren); 
+        createBeforeClosingParenTree(workingValues, parent); 
+        
+        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_closing_paren); 
+        createAfterCloseParenTree(workingValues, parent);
+        
+        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_between_empty_parens); 
+        createBetweenEmptyParenTree(workingValues, parent);
+        
+        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_opening_brace); 
+        createBeforeOpenBraceTree(workingValues, parent);
+        
+        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_opening_brace); 
+        createAfterOpenBraceTree(workingValues, parent);
+
+        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_closing_brace); 
+        createBeforeClosingBraceTree(workingValues, parent);
+        
+        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_closing_brace); 
+        createAfterCloseBraceTree(workingValues, parent);
+
+        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_between_empty_braces); 
+        createBetweenEmptyBracesTree(workingValues, parent);
+
+        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_opening_bracket); 
+        createBeforeOpenBracketTree(workingValues, parent);
+
+        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_opening_bracket); 
+        createAfterOpenBracketTree(workingValues, parent);
+        
+        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_closing_bracket); 
+        createBeforeClosingBracketTree(workingValues, parent);
+        
+        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_between_empty_brackets); 
+        createBetweenEmptyBracketsTree(workingValues, parent);
+
+        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_opening_angle_bracket); 
+        createBeforeOpenAngleBracketTree(workingValues, parent);
+
+        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_opening_angle_bracket); 
+        createAfterOpenAngleBracketTree(workingValues, parent);
+        
+        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_closing_angle_bracket); 
+        createBeforeClosingAngleBracketTree(workingValues, parent);
+        
+        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_closing_angle_bracket); 
+        createAfterClosingAngleBracketTree(workingValues, parent);
+        
+        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_operator); 
+        createBeforeOperatorTree(workingValues, parent);
+        
+        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_operator); 
+        createAfterOperatorTree(workingValues, parent);
+        
+        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_comma); 
+        createBeforeCommaTree(workingValues, parent);
+        
+        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_comma); 
+        createAfterCommaTree(workingValues, parent); 
+        
+        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_colon); 
+        createAfterColonTree(workingValues, parent); 
+        
+        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_colon); 
+        createBeforeColonTree(workingValues, parent);
+        
+        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_semicolon); 
+        createBeforeSemicolonTree(workingValues, parent);
+        
+        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_semicolon); 
+        createAfterSemicolonTree(workingValues, parent); 
+        
+        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_question_mark); 
+        createBeforeQuestionTree(workingValues, parent); 
+        
+        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_question_mark); 
+        createAfterQuestionTree(workingValues, parent); 
+        
+//        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_before_ellipsis); 
+//        createBeforeEllipsis(workingValues, parent);
+//        
+//        parent= createParentNode(roots, workingValues, FormatterMessages.WhiteSpaceOptions_after_ellipsis); 
+//        createAfterEllipsis(workingValues, parent);
+        
+        return roots;
+       }
+
+       private InnerNode createParentNode(List<InnerNode> roots, Map<String, String> workingValues, String text) {
+        final InnerNode parent= new InnerNode(null, workingValues, text);
+        roots.add(parent);
+        return parent;
+    }
+
+    public ArrayList<InnerNode> createTreeByCElement(Map<String, String> workingValues) {
+
+        final InnerNode declarations= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceTabPage_declarations); 
+        createClassTree(workingValues, declarations);
+        createDeclaratorListTree(workingValues, declarations);
+//        createConstructorTree(workingValues, declarations);
+        createMethodDeclTree(workingValues, declarations);
+        createExceptionSpecificationTree(workingValues, declarations);
+        createLabelTree(workingValues, declarations);
+        
+        final InnerNode statements= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceTabPage_statements); 
+        createOption(statements, workingValues, FormatterMessages.WhiteSpaceOptions_before_semicolon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON, SEMICOLON_PREVIEW); 
+        createBlockTree(workingValues, statements);
+        createIfStatementTree(workingValues, statements);
+        createForStatementTree(workingValues, statements);
+        createSwitchStatementTree(workingValues, statements);
+        createDoWhileTree(workingValues, statements);
+        createTryStatementTree(workingValues, statements);
+//        createReturnTree(workingValues, statements);
+//        createThrowTree(workingValues, statements);
+        
+        final InnerNode expressions= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceTabPage_expressions); 
+        createFunctionCallTree(workingValues, expressions);
+               createAssignmentTree(workingValues, expressions);
+               createInitializerListTree(workingValues, expressions);
+               createOperatorTree(workingValues, expressions);
+               createParenthesizedExpressionTree(workingValues, expressions);
+               createTypecastTree(workingValues, expressions);
+               createConditionalTree(workingValues, expressions);
+        createExpressionListTree(workingValues, expressions);
+               
+               final InnerNode arrays= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceTabPage_arrays); 
+               createArrayTree(workingValues, arrays);
+               
+               final InnerNode templates= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceTabPage_templates); 
+               createTemplateArgumentTree(workingValues, templates);
+               createTemplateParameterTree(workingValues, templates);
+               
+        final ArrayList<InnerNode> roots= new ArrayList<InnerNode>();
+               roots.add(declarations);
+               roots.add(statements);
+               roots.add(expressions);
+               roots.add(arrays);
+               roots.add(templates);
+        return roots;
+    }
+       
+       private void createBeforeQuestionTree(Map<String, String> workingValues, final InnerNode parent) {
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_conditional, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_CONDITIONAL, CONDITIONAL_PREVIEW); 
+       }
+       
+    private void createBeforeSemicolonTree(Map<String, String> workingValues, final InnerNode parent) {
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_FOR, FOR_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_statements, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON, SEMICOLON_PREVIEW); 
+    }
+
+    private void createBeforeColonTree(Map<String, String> workingValues, final InnerNode parent) {
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_conditional, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CONDITIONAL, CONDITIONAL_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_label, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_base_clause, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_BASE_CLAUSE, CLASS_DECL_PREVIEW); 
+
+        final InnerNode switchStatement= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_switch); 
+        createOption(switchStatement, workingValues, FormatterMessages.WhiteSpaceOptions_case, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CASE, SWITCH_PREVIEW); 
+        createOption(switchStatement, workingValues, FormatterMessages.WhiteSpaceOptions_default, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_DEFAULT, SWITCH_PREVIEW); 
+    }
+
+    private void createBeforeCommaTree(Map<String, String> workingValues, final InnerNode parent) {
+
+//        final InnerNode forStatement= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for);  
+//        createOption(forStatement, workingValues, FormatterMessages.WhiteSpaceOptions_initialization, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INITS, FOR_PREVIEW); 
+//        createOption(forStatement, workingValues, FormatterMessages.WhiteSpaceOptions_incrementation, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INCREMENTS, FOR_PREVIEW); 
+            
+        final InnerNode invocation= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arguments);  
+        createOption(invocation, workingValues, FormatterMessages.WhiteSpaceOptions_function_call, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_INVOCATION_ARGUMENTS, METHOD_CALL_PREVIEW); 
+        createOption(invocation, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW); 
+
+        final InnerNode decl= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_parameters); 
+        createOption(decl, workingValues, FormatterMessages.WhiteSpaceOptions_function, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_PARAMETERS, METHOD_DECL_PREVIEW); 
+        createOption(decl, workingValues, FormatterMessages.WhiteSpaceOptions_template_parameters, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW); 
+
+        final InnerNode lists= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_lists);
+        createOption(lists, workingValues, FormatterMessages.WhiteSpaceOptions_declarator_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_DECLARATOR_LIST, DECLARATOR_LIST_PREVIEW); 
+        createOption(lists, workingValues, FormatterMessages.WhiteSpaceOptions_expression_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_EXPRESSION_LIST, EXPRESSION_LIST_PREVIEW); 
+        createOption(lists, workingValues, FormatterMessages.WhiteSpaceOptions_initializer_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_INITIALIZER_LIST, INITIALIZER_LIST_PREVIEW); 
+        
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_exception_specification, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_THROWS, METHOD_DECL_PREVIEW); 
+     }
+
+    private void createBeforeOperatorTree(Map<String, String> workingValues, final InnerNode parent) {
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_assignment_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_unary_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_UNARY_OPERATOR, OPERATOR_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_binary_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR, OPERATOR_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_prefix_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PREFIX_OPERATOR, OPERATOR_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_postfix_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_POSTFIX_OPERATOR, OPERATOR_PREVIEW); 
+    }
+
+    private void createBeforeClosingBracketTree(Map<String, String> workingValues, final InnerNode parent) {
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arrays, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET, ARRAY_PREVIEW); 
+    }
+
+    private void createBeforeClosingAngleBracketTree(Map<String, String> workingValues, final InnerNode parent) {
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_parameters, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW); 
+    }
+    
+    
+    private void createBeforeOpenBracketTree(Map<String, String> workingValues, final InnerNode parent) {
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arrays, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET, ARRAY_PREVIEW); 
+    }
+    
+    private void createBeforeOpenAngleBracketTree(Map<String, String> workingValues, final InnerNode parent) {
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_parameters, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW); 
+    }
+
+    private void createBeforeClosingBraceTree(Map<String, String> workingValues, final InnerNode parent) {
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_initializer_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_INITIALIZER_LIST, CLASS_DECL_PREVIEW); 
+    }
+    
+    private void createBeforeOpenBraceTree(Map<String, String> workingValues, final InnerNode parent) {
+
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_class_decl, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_TYPE_DECLARATION, CLASS_DECL_PREVIEW); 
+
+        final InnerNode functionDecl= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_function_declaration); { 
+            createOption(functionDecl, workingValues, FormatterMessages.WhiteSpaceOptions_function, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); 
+        }
+        
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_initializer_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_INITIALIZER_LIST, INITIALIZER_LIST_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_block, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK, BLOCK_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_switch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_SWITCH, SWITCH_PREVIEW); 
+    }
+
+    private void createBeforeClosingParenTree(Map<String, String> workingValues, final InnerNode parent) {
+
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_catch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CATCH, CATCH_PREVIEW);  
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR, FOR_PREVIEW);  
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_if, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_IF, IF_PREVIEW);  
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_switch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SWITCH, SWITCH_PREVIEW);  
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_while, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_WHILE, WHILE_PREVIEW); 
+       
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_cast, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CAST, CAST_PREVIEW); 
+                   
+        final InnerNode decl= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_function_declaration); 
+        createOption(decl, workingValues, FormatterMessages.WhiteSpaceOptions_function, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW);  
+        createOption(decl, workingValues, FormatterMessages.WhiteSpaceOptions_exception_specification, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_EXCEPTION_SPECIFICATION, METHOD_DECL_PREVIEW);  
+
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_function_call, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW);  
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_paren_expr, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW);  
+    }
+
+    private void createBeforeOpenParenTree(Map<String, String> workingValues, final InnerNode parent) {
+
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_catch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR, FOR_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_if, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_IF, IF_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_switch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SWITCH, SWITCH_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_while, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW);
+//        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_return_with_parenthesized_expression, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_RETURN, RETURN_PREVIEW);
+//        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_throw_with_parenthesized_expression, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_THROW, THROW_PREVIEW);
+
+        final InnerNode decls= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_function_declaration);  
+        createOption(decls, workingValues, FormatterMessages.WhiteSpaceOptions_function, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); 
+        createOption(decls, workingValues, FormatterMessages.WhiteSpaceOptions_exception_specification, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_EXCEPTION_SPECIFICATION, METHOD_DECL_PREVIEW); 
+        
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_function_call, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_paren_expr, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW); 
+    }
+
+       private void createAfterQuestionTree(Map<String, String> workingValues, final InnerNode parent) {
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_conditional, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_CONDITIONAL, CONDITIONAL_PREVIEW); 
+       }
+
+//     private void createBeforeEllipsis(Map workingValues, InnerNode parent) {
+//             createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_vararg_parameter, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ELLIPSIS, VARARG_PARAMETER_PREVIEW); 
+//     }
+//     
+//     private void createAfterEllipsis(Map workingValues, InnerNode parent) {
+//             createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_vararg_parameter, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ELLIPSIS, VARARG_PARAMETER_PREVIEW); 
+//     }
+       
+    private void createAfterSemicolonTree(Map<String, String> workingValues, final InnerNode parent) {
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR, FOR_PREVIEW); 
+    }
+
+    private void createAfterColonTree(Map<String, String> workingValues, final InnerNode parent) {
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_conditional, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CONDITIONAL, CONDITIONAL_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_label, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_base_clause, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_BASE_CLAUSE, CLASS_DECL_PREVIEW); 
+    }
+
+    private void createAfterCommaTree(Map<String, String> workingValues, final InnerNode parent) {
+
+//        final InnerNode forStatement= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for); { 
+//            createOption(forStatement, workingValues, FormatterMessages.WhiteSpaceOptions_initialization, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INITS, FOR_PREVIEW); 
+//            createOption(forStatement, workingValues, FormatterMessages.WhiteSpaceOptions_incrementation, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INCREMENTS, FOR_PREVIEW); 
+//        }
+        final InnerNode invocation= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arguments); { 
+            createOption(invocation, workingValues, FormatterMessages.WhiteSpaceOptions_function, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_INVOCATION_ARGUMENTS, METHOD_CALL_PREVIEW); 
+           createOption(invocation, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW); 
+        }
+        final InnerNode decl= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_parameters); { 
+            createOption(decl, workingValues, FormatterMessages.WhiteSpaceOptions_function, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_PARAMETERS, METHOD_DECL_PREVIEW); 
+            createOption(decl, workingValues, FormatterMessages.WhiteSpaceOptions_template_parameters, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW); 
+        }
+        final InnerNode lists= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_lists); { 
+            createOption(lists, workingValues, FormatterMessages.WhiteSpaceOptions_declarator_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_DECLARATOR_LIST, DECLARATOR_LIST_PREVIEW); 
+            createOption(lists, workingValues, FormatterMessages.WhiteSpaceOptions_expression_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_EXPRESSION_LIST, EXPRESSION_LIST_PREVIEW); 
+            createOption(lists, workingValues, FormatterMessages.WhiteSpaceOptions_initializer_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_INITIALIZER_LIST, INITIALIZER_LIST_PREVIEW); 
+        }
+
+           createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_exception_specification, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_THROWS, METHOD_DECL_PREVIEW); 
+    }
+
+    private void createAfterOperatorTree(Map<String, String> workingValues, final InnerNode parent) {
+
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_assignment_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_unary_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_UNARY_OPERATOR, OPERATOR_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_binary_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR, OPERATOR_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_prefix_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_PREFIX_OPERATOR, OPERATOR_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_postfix_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_POSTFIX_OPERATOR, OPERATOR_PREVIEW); 
+    }
+    
+    private void createAfterOpenBracketTree(Map<String, String> workingValues, final InnerNode parent) {
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arrays, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET, ARRAY_PREVIEW); 
+    }
+    
+    private void createAfterOpenAngleBracketTree(Map<String, String> workingValues, final InnerNode parent) {
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_parameters, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW); 
+    }
+    
+
+    
+    private void createAfterOpenBraceTree(Map<String, String> workingValues, final InnerNode parent) {
+        
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_initializer_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_INITIALIZER_LIST, INITIALIZER_LIST_PREVIEW); 
+    }
+    
+    private void createAfterCloseBraceTree(Map<String, String> workingValues, final InnerNode parent) {
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_block, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK, BLOCK_PREVIEW); 
+    }
+    
+    private void createAfterCloseParenTree(Map<String, String> workingValues, final InnerNode parent) {
+        
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_cast, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_CAST, CAST_PREVIEW); 
+    }
+    
+    private void createAfterClosingAngleBracketTree(Map<String, String> workingValues, final InnerNode parent) {
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_parameters, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW); 
+        //createOption(parent, workingValues, "WhiteSpaceOptions.parameterized_type", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE, TYPE_ARGUMENTS_PREVIEW); //$NON-NLS-1$
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW); 
+    }
+    
+    private void createAfterOpenParenTree(Map<String, String> workingValues, final InnerNode parent) {
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_catch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR, FOR_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_if, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF, IF_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_switch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SWITCH, SWITCH_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_while, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW); 
+        
+        final InnerNode decls= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_function_declaration); { 
+            createOption(decls, workingValues, FormatterMessages.WhiteSpaceOptions_function, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); 
+            createOption(decls, workingValues, FormatterMessages.WhiteSpaceOptions_exception_specification, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_EXCEPTION_SPECIFICATION, METHOD_DECL_PREVIEW); 
+        }
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_cast, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CAST, CAST_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_function_call, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_paren_expr, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW); 
+    }
+    
+    private void createBetweenEmptyParenTree(Map<String, String> workingValues, final InnerNode parent) {
+        
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_function_decl, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_function_call, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_exception_specification, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_EXCEPTION_SPECIFICATION, METHOD_CALL_PREVIEW); 
+    }
+    
+    private void createBetweenEmptyBracketsTree(Map<String, String> workingValues, final InnerNode parent) {
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arrays, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACKETS, ARRAY_PREVIEW); 
+    }
+    
+    private void createBetweenEmptyBracesTree(Map<String, String> workingValues, final InnerNode parent) {
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_initializer_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_INITIALIZER_LIST, INITIALIZER_LIST_PREVIEW); 
+    }
+    
+    // syntax element tree
+
+    private InnerNode createClassTree(Map<String, String> workingValues, InnerNode parent) {
+        final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_classes); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_classes_before_opening_brace_of_a_class, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_TYPE_DECLARATION, CLASS_DECL_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_classes_before_colon_of_base_clause, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_BASE_CLAUSE, CLASS_DECL_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_classes_after_colon_of_base_clause, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_BASE_CLAUSE, CLASS_DECL_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_classes_before_comma_base_types, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_BASE_TYPES, CLASS_DECL_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_classes_after_comma_base_types, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_BASE_TYPES, CLASS_DECL_PREVIEW); 
+        return root;
+    }
+    
+    private InnerNode createAssignmentTree(Map<String, String> workingValues, InnerNode parent) {
+        final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_assignments); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_assignments_before_assignment_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_assignments_after_assignment_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW); 
+        return root;
+    }
+    
+    private InnerNode createOperatorTree(Map<String, String> workingValues, InnerNode parent) {
+        final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_operators); 
+        
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_before_binary_operators, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR, OPERATOR_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_after_binary_operators, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR, OPERATOR_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_before_unary_operators, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_UNARY_OPERATOR, OPERATOR_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_after_unary_operators, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_UNARY_OPERATOR, OPERATOR_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_before_prefix_operators, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PREFIX_OPERATOR, OPERATOR_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_after_prefix_operators, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_PREFIX_OPERATOR, OPERATOR_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_before_postfix_operators, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_POSTFIX_OPERATOR, OPERATOR_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_after_postfix_operators, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_POSTFIX_OPERATOR, OPERATOR_PREVIEW); 
+        return root;
+    }
+    
+    private InnerNode createMethodDeclTree(Map<String, String> workingValues, InnerNode parent) {
+        final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_functions); 
+        
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_between_empty_parens, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); 
+        
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_comma_in_params, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_PARAMETERS, METHOD_DECL_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_comma_in_params, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_PARAMETERS, METHOD_DECL_PREVIEW); 
+        return root;
+    }
+
+    private InnerNode createExceptionSpecificationTree(Map<String, String> workingValues, InnerNode parent) {
+        final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_exception_specifications); 
+        
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_EXCEPTION_SPECIFICATION, METHOD_DECL_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_EXCEPTION_SPECIFICATION, METHOD_DECL_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_EXCEPTION_SPECIFICATION, METHOD_DECL_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_between_empty_parens, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_EXCEPTION_SPECIFICATION, METHOD_DECL_PREVIEW); 
+        
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_comma_in_params, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_THROWS, METHOD_DECL_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_comma_in_params, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_THROWS, METHOD_DECL_PREVIEW); 
+        return root;
+    }
+
+    private InnerNode createDeclaratorListTree(Map<String, String> workingValues, InnerNode parent) {
+        final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_declarator_list); 
+        
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_declarator_list_before_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_DECLARATOR_LIST, DECLARATOR_LIST_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_declarator_list_after_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_DECLARATOR_LIST, DECLARATOR_LIST_PREVIEW); 
+        return root;
+    }  
+    
+    private InnerNode createExpressionListTree(Map<String, String> workingValues, InnerNode parent) {
+        final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_expression_list); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_expression_list_before_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_EXPRESSION_LIST, EXPRESSION_LIST_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_expression_list_after_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_EXPRESSION_LIST, EXPRESSION_LIST_PREVIEW); 
+        return root;
+    }
+   
+    private InnerNode createInitializerListTree(Map<String, String> workingValues, InnerNode parent) {
+        final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_initializer_list); 
+   
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_INITIALIZER_LIST, INITIALIZER_LIST_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_INITIALIZER_LIST, INITIALIZER_LIST_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_INITIALIZER_LIST, INITIALIZER_LIST_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_INITIALIZER_LIST, INITIALIZER_LIST_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_INITIALIZER_LIST, INITIALIZER_LIST_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_between_empty_braces, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_INITIALIZER_LIST, INITIALIZER_LIST_PREVIEW); 
+        return root;
+    }
+    
+    private InnerNode createArrayTree(Map<String, String> workingValues, InnerNode parent) {
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET, ARRAY_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET, ARRAY_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET, ARRAY_PREVIEW); 
+        createOption(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_between_empty_brackets, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACKETS, ARRAY_PREVIEW); 
+       return parent;
+    }
+   
+    private InnerNode createFunctionCallTree(Map<String, String> workingValues, InnerNode parent) {
+        final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_calls); 
+        
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_between_empty_parens, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_calls_before_comma_in_function_args, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_INVOCATION_ARGUMENTS, METHOD_CALL_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_calls_after_comma_in_function_args, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_INVOCATION_ARGUMENTS, METHOD_CALL_PREVIEW); 
+//        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_calls_before_comma_in_alloc, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ALLOCATION_EXPRESSION, ALLOC_PREVIEW); 
+//        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_calls_after_comma_in_alloc, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ALLOCATION_EXPRESSION, ALLOC_PREVIEW); 
+        return root;
+    }
+    
+    private InnerNode createBlockTree(Map<String, String> workingValues, InnerNode parent) {
+        final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_blocks); 
+        
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK, BLOCK_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_closing_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK, BLOCK_PREVIEW); 
+        return root;
+    }
+    
+    private InnerNode createSwitchStatementTree(Map<String, String> workingValues, InnerNode parent) {
+        final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_switch); 
+        
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_switch_before_case_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CASE, SWITCH_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_switch_before_default_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_DEFAULT, SWITCH_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_SWITCH, SWITCH_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SWITCH, SWITCH_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SWITCH, SWITCH_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SWITCH, SWITCH_PREVIEW); 
+        return root;
+    }
+    
+    private InnerNode createDoWhileTree(Map<String, String> workingValues, InnerNode parent) {
+        final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_do); 
+        
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_WHILE, WHILE_PREVIEW); 
+        
+        return root;
+    }
+    
+    private InnerNode createTryStatementTree(Map<String, String> workingValues, InnerNode parent) {
+        final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_try); 
+        
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CATCH, CATCH_PREVIEW); 
+        return root;
+    }
+    private InnerNode createIfStatementTree(Map<String, String> workingValues, InnerNode parent) {
+        final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_if); 
+        
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_IF, IF_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF, IF_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_IF, IF_PREVIEW); 
+        return root;
+    }
+    
+    private InnerNode createForStatementTree(Map<String, String> workingValues, InnerNode parent) {
+        final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_for); 
+        
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR, FOR_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR, FOR_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR, FOR_PREVIEW); 
+//        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_for_before_comma_init, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INITS, FOR_PREVIEW); 
+//        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_for_after_comma_init, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INITS, FOR_PREVIEW); 
+//        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_for_before_comma_inc, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INCREMENTS, FOR_PREVIEW); 
+//        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_for_after_comma_inc, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INCREMENTS, FOR_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_semicolon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_FOR, FOR_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_semicolon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR, FOR_PREVIEW); 
+        
+        return root;
+    }
+    
+//    private InnerNode createReturnTree(Map workingValues, InnerNode parent) {
+//     final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceOptions_return); 
+//     createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_parenthesized_expressions, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_RETURN, RETURN_PREVIEW);
+//     return root;
+//    }
+    
+//    private InnerNode createThrowTree(Map workingValues, InnerNode parent) {
+//     final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceOptions_throw); 
+//     createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_parenthesized_expressions, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_THROW, THROW_PREVIEW);
+//     return root;
+//    }
+
+    private InnerNode createLabelTree(Map<String, String> workingValues, InnerNode parent) {
+        final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_labels); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW); 
+        return root;
+    }
+    
+    private InnerNode createTemplateArgumentTree(Map<String, String> workingValues, InnerNode parent) {
+        final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_template_arguments); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_closing_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW); 
+        return root;
+    }
+    
+    private InnerNode createTemplateParameterTree(Map<String, String> workingValues, InnerNode parent) {
+        final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_template_parameters); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_closing_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW); 
+        return root;
+    }
+
+    private InnerNode createConditionalTree(Map<String, String> workingValues, InnerNode parent) {
+        final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_conditionals); 
+        
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_question, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_CONDITIONAL, CONDITIONAL_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_question, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_CONDITIONAL, CONDITIONAL_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CONDITIONAL, CONDITIONAL_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CONDITIONAL, CONDITIONAL_PREVIEW); 
+        return root;
+    }
+    
+    
+    private InnerNode createTypecastTree(Map<String, String> workingValues, InnerNode parent) {
+        final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_typecasts); 
+        
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CAST, CAST_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CAST, CAST_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_CAST, CAST_PREVIEW); 
+        return root;
+    }
+    
+    
+    private InnerNode createParenthesizedExpressionTree(Map<String, String> workingValues, InnerNode parent) {
+        final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_parenexpr); 
+        
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW); 
+        createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW); 
+        return root;
+       }
+    
+    
+    
+    private static InnerNode createChild(InnerNode root, Map<String, String> workingValues, String message) {
+           return new InnerNode(root, workingValues, message);
+       }
+       
+       private static OptionNode createOption(InnerNode root, Map<String, String> workingValues, String message, String key, PreviewSnippet snippet) {
+           return new OptionNode(root, workingValues, message, key, snippet);
+       }
+
+       public static void makeIndexForNodes(List<? extends Node> tree, List<Node> flatList) {
+        for (Node node : tree) {
+            node.index= flatList.size();
+            flatList.add(node);
+            makeIndexForNodes(node.getChildren(), flatList);
+        }
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceTabPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/formatter/WhiteSpaceTabPage.java
new file mode 100644 (file)
index 0000000..ff3c5e0
--- /dev/null
@@ -0,0 +1,478 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences.formatter;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.dialogs.ContainerCheckedTreeViewer;
+import org.eclipse.ui.part.PageBook;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.preferences.formatter.WhiteSpaceOptions.InnerNode;
+import org.eclipse.cdt.internal.ui.preferences.formatter.WhiteSpaceOptions.Node;
+import org.eclipse.cdt.internal.ui.preferences.formatter.WhiteSpaceOptions.OptionNode;
+
+
+public class WhiteSpaceTabPage extends FormatterTabPage {
+       
+    
+    /**
+     * Encapsulates a view of the options tree which is structured by
+     * syntactical element.
+     */
+       
+       private final class SyntaxComponent implements ISelectionChangedListener, ICheckStateListener, IDoubleClickListener {
+
+           private final String PREF_NODE_KEY= CUIPlugin.PLUGIN_ID + "formatter_page.white_space_tab_page.node"; //$NON-NLS-1$
+           
+           private final List<Node> fIndexedNodeList;
+               private final List<? extends Node> fTree;
+               
+               private ContainerCheckedTreeViewer fTreeViewer;
+               private Composite fComposite;
+               
+           private Node fLastSelected= null;
+
+           public SyntaxComponent() {
+               fIndexedNodeList= new ArrayList<Node>();
+                       fTree= new WhiteSpaceOptions().createAltTree(fWorkingValues);
+                       WhiteSpaceOptions.makeIndexForNodes(fTree, fIndexedNodeList);
+               }
+           
+               public void createContents(final int numColumns, final Composite parent) {
+                       fComposite= new Composite(parent, SWT.NONE);
+                       fComposite.setLayoutData(createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL, SWT.DEFAULT));
+                       fComposite.setLayout(createGridLayout(numColumns, false));
+                   
+            createLabel(numColumns, fComposite, FormatterMessages.WhiteSpaceTabPage_insert_space); 
+            
+               fTreeViewer= new ContainerCheckedTreeViewer(fComposite, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
+                       fTreeViewer.setContentProvider(new ITreeContentProvider() {
+                               public Object[] getElements(Object inputElement) {
+                                       return ((Collection<?>)inputElement).toArray();
+                               }
+                               public Object[] getChildren(Object parentElement) {
+                                       return ((Node)parentElement).getChildren().toArray();
+                               }
+                               public Object getParent(Object element) {
+                                   return ((Node)element).getParent(); 
+                               }
+                               public boolean hasChildren(Object element) {
+                                       return ((Node)element).hasChildren();
+                               }
+                               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+                               public void dispose() {}
+                       });
+                       fTreeViewer.setLabelProvider(new LabelProvider());
+                       fTreeViewer.getControl().setLayoutData(createGridData(numColumns, GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL, SWT.DEFAULT));
+                       fDefaultFocusManager.add(fTreeViewer.getControl());
+           }
+               
+               public void initialize() {
+                       fTreeViewer.addCheckStateListener(this);
+                       fTreeViewer.addSelectionChangedListener(this);
+                       fTreeViewer.addDoubleClickListener(this);
+                   fTreeViewer.setInput(fTree);
+                   restoreSelection();
+                   refreshState();
+               }
+               
+               public void refreshState() {
+                   final ArrayList<OptionNode> checked= new ArrayList<OptionNode>(100);
+                   for (Node node : fTree)
+                               (node).getCheckedLeafs(checked);
+                   fTreeViewer.setGrayedElements(new Object[0]);
+                   fTreeViewer.setCheckedElements(checked.toArray());
+                   fPreview.clear();
+                   if (fLastSelected != null) {
+                       fPreview.addAll(fLastSelected.getSnippets());
+                   }
+                   doUpdatePreview();
+               }
+
+               public void selectionChanged(SelectionChangedEvent event) {
+                   final IStructuredSelection selection= (IStructuredSelection)event.getSelection();
+                   if (selection.isEmpty())
+                       return;
+                   final Node node= (Node)selection.getFirstElement();
+                   if (node == fLastSelected)
+                       return;
+                   fDialogSettings.put(PREF_NODE_KEY, node.index);
+                   fPreview.clear();
+                   fPreview.addAll(node.getSnippets());
+                   doUpdatePreview();
+                   fLastSelected= node;
+               }
+
+               public void checkStateChanged(CheckStateChangedEvent event) {
+                       final Node node= (Node)event.getElement();
+                       node.setChecked(event.getChecked());
+                       doUpdatePreview();
+                       notifyValuesModified();
+               }
+
+               public void restoreSelection() {
+                       int index;
+                       try {
+                               index= fDialogSettings.getInt(PREF_NODE_KEY);
+                       } catch (NumberFormatException ex) {
+                               index= -1;
+                       }
+                       if (index < 0 || index > fIndexedNodeList.size() - 1) {
+                               index= 0;
+                       }
+                       final Node node= fIndexedNodeList.get(index);
+                       if (node != null) {
+                           fTreeViewer.expandToLevel(node, 0);
+                           fTreeViewer.setSelection(new StructuredSelection(new Node [] {node}));
+                           fLastSelected= node;
+                       }
+               }
+
+        public void doubleClick(DoubleClickEvent event) {
+            final ISelection selection= event.getSelection();
+            if (selection instanceof IStructuredSelection) {
+                final Node node= (Node)((IStructuredSelection)selection).getFirstElement();
+                fTreeViewer.setExpandedState(node, !fTreeViewer.getExpandedState(node));
+            }
+        }
+        
+        public Control getControl() {
+            return fComposite;
+        }
+       }
+       
+       
+       
+       private final class CElementComponent implements ISelectionChangedListener, ICheckStateListener {
+           
+           private final String PREF_INNER_INDEX= CUIPlugin.PLUGIN_ID + "formatter_page.white_space.c_view.inner"; //$NON-NLS-1$ 
+               private final String PREF_OPTION_INDEX= CUIPlugin.PLUGIN_ID + "formatter_page.white_space.c_view.option"; //$NON-NLS-1$
+               
+           private final ArrayList<Node> fIndexedNodeList;
+           private final ArrayList<InnerNode> fTree;
+           
+           private InnerNode fLastSelected;
+           
+           private TreeViewer fInnerViewer;
+           private CheckboxTableViewer fOptionsViewer;
+           
+           private Composite fComposite;
+           
+           public CElementComponent() {
+                       fIndexedNodeList= new ArrayList<Node>();
+                       fTree= new WhiteSpaceOptions().createTreeByCElement(fWorkingValues);
+                       WhiteSpaceOptions.makeIndexForNodes(fTree, fIndexedNodeList);
+           }
+
+           public void createContents(int numColumns, Composite parent) {
+                       
+                       fComposite= new Composite(parent, SWT.NONE);
+                       fComposite.setLayoutData(createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL, SWT.DEFAULT));
+                       fComposite.setLayout(createGridLayout(numColumns, false));
+                       
+            createLabel(numColumns, fComposite, FormatterMessages.WhiteSpaceTabPage_insert_space, GridData.HORIZONTAL_ALIGN_BEGINNING); 
+                       
+                       final SashForm sashForm= new SashForm(fComposite, SWT.VERTICAL);
+                       sashForm.setLayoutData(createGridData(numColumns, GridData.FILL_BOTH, SWT.DEFAULT));
+                       
+                       fInnerViewer= new TreeViewer(sashForm, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
+
+                       fInnerViewer.setContentProvider(new ITreeContentProvider() {
+                               public Object[] getElements(Object inputElement) {
+                                       return ((Collection<?>)inputElement).toArray();
+                               }
+                               public Object[] getChildren(Object parentElement) {
+                                   final List<Node> children= ((Node)parentElement).getChildren();
+                                   final ArrayList<Object> innerChildren= new ArrayList<Object>();
+                                   for (Object o : children) { 
+                        if (o instanceof InnerNode) innerChildren.add(o);
+                    }
+                                   return innerChildren.toArray();
+                               }
+                               public Object getParent(Object element) {
+                                   if (element instanceof InnerNode)
+                                       return ((InnerNode)element).getParent();
+                                   return null;
+                               }
+                               public boolean hasChildren(Object element) {
+                                   final List<?> children= ((Node)element).getChildren();
+                                   for (Object child : children)
+                                               if (child instanceof InnerNode) return true;
+                                   return false;
+                               }
+                               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+                               public void dispose() {}
+                       });
+                       
+                       fInnerViewer.setLabelProvider(new LabelProvider());
+                       
+                       final GridData innerGd= createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL, SWT.DEFAULT);
+                       innerGd.heightHint= fPixelConverter.convertHeightInCharsToPixels(3);
+                       fInnerViewer.getControl().setLayoutData(innerGd);
+                       
+                       fOptionsViewer= CheckboxTableViewer.newCheckList(sashForm, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL);
+                       fOptionsViewer.setContentProvider(new ArrayContentProvider());
+                       fOptionsViewer.setLabelProvider(new LabelProvider());
+                       
+                       final GridData optionsGd= createGridData(numColumns, GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL, SWT.DEFAULT);
+                       optionsGd.heightHint= fPixelConverter.convertHeightInCharsToPixels(3);
+                       fOptionsViewer.getControl().setLayoutData(optionsGd);
+               
+                       fDefaultFocusManager.add(fInnerViewer.getControl());
+               fDefaultFocusManager.add(fOptionsViewer.getControl());
+                       
+                       fInnerViewer.setInput(fTree);
+               }
+           
+           public void refreshState() {
+               if (fLastSelected != null) {
+                       innerViewerChanged(fLastSelected);
+               }
+           }
+           
+           public void initialize() {
+               fInnerViewer.addSelectionChangedListener(this);
+               fOptionsViewer.addSelectionChangedListener(this);
+               fOptionsViewer.addCheckStateListener(this);
+               restoreSelections();
+               refreshState();
+           }
+           
+           private void restoreSelections() {
+               Node node;
+               final int innerIndex= getValidatedIndex(PREF_INNER_INDEX);
+                       node= fIndexedNodeList.get(innerIndex);
+                       if (node instanceof InnerNode) {
+                           fInnerViewer.expandToLevel(node, 0);
+                           fInnerViewer.setSelection(new StructuredSelection(new Object[] {node}));
+                           fLastSelected= (InnerNode)node;
+                       }
+                       
+               final int optionIndex= getValidatedIndex(PREF_OPTION_INDEX);
+                       node= fIndexedNodeList.get(optionIndex);
+                       if (node instanceof OptionNode) {
+                           fOptionsViewer.setSelection(new StructuredSelection(new Object[] {node}));
+                       }
+
+           }
+           
+           private int getValidatedIndex(String key) {
+                       int index;
+                       try {
+                               index= fDialogSettings.getInt(key);
+                       } catch (NumberFormatException ex) {
+                               index= 0;
+                       }
+                       if (index < 0 || index > fIndexedNodeList.size() - 1) {
+                               index= 0; 
+                       }
+                       return index;
+           }
+           
+           public Control getControl() {
+               return fComposite;
+           }
+
+        public void selectionChanged(SelectionChangedEvent event) {
+            final IStructuredSelection selection= (IStructuredSelection)event.getSelection();
+
+            if (selection.isEmpty() || !(selection.getFirstElement() instanceof Node))
+                return;
+
+            final Node selected= (Node)selection.getFirstElement();
+
+            if (selected == null || selected == fLastSelected) 
+                           return;
+            
+            
+            if (event.getSource() == fInnerViewer && selected instanceof InnerNode) {
+                fLastSelected= (InnerNode)selected;
+                fDialogSettings.put(PREF_INNER_INDEX, selected.index);
+                innerViewerChanged((InnerNode)selected);
+            }
+            else if (event.getSource() == fOptionsViewer && selected instanceof OptionNode)
+                fDialogSettings.put(PREF_OPTION_INDEX, selected.index);
+        }
+       
+        private void innerViewerChanged(InnerNode selectedNode) {
+            
+                       final List<Node> children= selectedNode.getChildren();
+                       
+                       final ArrayList<OptionNode> optionsChildren= new ArrayList<OptionNode>();
+                       for (Object o : children) {
+                           if (o instanceof OptionNode) optionsChildren.add((OptionNode) o);
+                       }
+                       
+                       fOptionsViewer.setInput(optionsChildren.toArray());
+                       
+                       for (OptionNode child : optionsChildren) {
+                               fOptionsViewer.setChecked(child, child.getChecked());
+                       }
+                       
+                       fPreview.clear();
+                       fPreview.addAll(selectedNode.getSnippets());
+                       doUpdatePreview();
+        }
+        
+        public void checkStateChanged(CheckStateChangedEvent event) {
+                       final OptionNode option= (OptionNode)event.getElement();
+                       if (option != null)
+                           option.setChecked(event.getChecked());
+                       doUpdatePreview();
+                       notifyValuesModified();
+        }
+       }
+       
+       
+
+       /**
+        * This component switches between the two view and is responsible for delegating
+        * the appropriate update requests.
+        */
+       private final class SwitchComponent extends SelectionAdapter {
+           private final String PREF_VIEW_KEY= CUIPlugin.PLUGIN_ID + "formatter_page.white_space_tab_page.view"; //$NON-NLS-1$
+           private final String [] fItems= new String [] {
+               FormatterMessages.WhiteSpaceTabPage_sort_by_c_element, 
+               FormatterMessages.WhiteSpaceTabPage_sort_by_syntax_element
+           };
+           
+           private Combo fSwitchCombo; 
+           private PageBook fPageBook;
+           private final SyntaxComponent fSyntaxComponent;
+           private final CElementComponent fCElementComponent;
+           
+           public SwitchComponent() {
+               fSyntaxComponent= new SyntaxComponent();
+               fCElementComponent= new CElementComponent();
+           }
+           
+        @Override
+               public void widgetSelected(SelectionEvent e) {
+            final int index= fSwitchCombo.getSelectionIndex();
+            if (index == 0) {
+                   fDialogSettings.put(PREF_VIEW_KEY, false);
+                   fCElementComponent.refreshState();
+                fPageBook.showPage(fCElementComponent.getControl());
+            }
+            else if (index == 1) { 
+                   fDialogSettings.put(PREF_VIEW_KEY, true);
+                   fSyntaxComponent.refreshState();
+                fPageBook.showPage(fSyntaxComponent.getControl());
+            }
+        }
+
+        public void createContents(int numColumns, Composite parent) {
+             
+            fPageBook= new PageBook(parent, SWT.NONE);
+            fPageBook.setLayoutData(createGridData(numColumns, GridData.FILL_BOTH, SWT.DEFAULT));
+            
+            fCElementComponent.createContents(numColumns, fPageBook);          
+            fSyntaxComponent.createContents(numColumns, fPageBook);
+            
+            fSwitchCombo= new Combo(parent, SWT.READ_ONLY);
+            final GridData gd= createGridData(numColumns, GridData.HORIZONTAL_ALIGN_END, SWT.DEFAULT);
+            fSwitchCombo.setLayoutData(gd);
+            fSwitchCombo.setItems(fItems);
+        }
+        
+        public void initialize() {
+            fSwitchCombo.addSelectionListener(this);
+           fCElementComponent.initialize();
+           fSyntaxComponent.initialize();
+           restoreSelection();
+        }
+
+        private void restoreSelection() {
+            final boolean selectSyntax= fDialogSettings.getBoolean(PREF_VIEW_KEY);
+            if (selectSyntax) {
+               fSyntaxComponent.refreshState();
+                fSwitchCombo.setText(fItems[1]);
+                fPageBook.showPage(fSyntaxComponent.getControl());
+                       } else {
+               fCElementComponent.refreshState();
+                           fSwitchCombo.setText(fItems[0]);
+                           fPageBook.showPage(fCElementComponent.getControl());
+                       }
+        }
+       }
+       
+
+       
+       
+       private final SwitchComponent fSwitchComponent;
+       protected final IDialogSettings fDialogSettings; 
+
+       protected SnippetPreview fPreview;
+
+
+       /**
+        * Create a new white space dialog page.
+        * @param modifyDialog
+        * @param workingValues
+        */
+       public WhiteSpaceTabPage(ModifyDialog modifyDialog, Map<String,String> workingValues) {
+               super(modifyDialog, workingValues);
+               fDialogSettings= CUIPlugin.getDefault().getDialogSettings();
+               fSwitchComponent= new SwitchComponent();
+       }
+
+       @Override
+       protected void doCreatePreferences(Composite composite, int numColumns) {
+               fSwitchComponent.createContents(numColumns, composite);
+       }
+
+       @Override
+       protected void initializePage() {
+        fSwitchComponent.initialize();
+       }
+       
+    @Override
+       protected CPreview doCreateCPreview(Composite parent) {
+        fPreview= new SnippetPreview(fWorkingValues, parent);
+        return fPreview;
+    }
+
+    @Override
+       protected void doUpdatePreview() {
+       super.doUpdatePreview();
+        fPreview.update();
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/AddDeclarationNodeToClassChange.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/AddDeclarationNodeToClassChange.java
new file mode 100644 (file)
index 0000000..7160e69
--- /dev/null
@@ -0,0 +1,170 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *     Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.text.edits.TextEditGroup;
+
+import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
+import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
+
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTVisibilityLabel;
+
+import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
+
+/**
+ * Adds a declaration to an existing class via the ModificationCollector. It automatically searches 
+ * the correct insertion point for the desired visibility.
+ * 
+ * @author Mirko Stocker
+ */
+public class AddDeclarationNodeToClassChange {
+       private final ICPPASTCompositeTypeSpecifier nodeClass;
+       private final VisibilityEnum visibility;
+       private List<IASTNode> fieldNodes = new ArrayList<IASTNode>();
+       private final ModificationCollector collector;
+       
+       public static void createChange(ICPPASTCompositeTypeSpecifier nodeClass,
+                       VisibilityEnum visibility, IASTNode fieldNodes, boolean isField,
+                       ModificationCollector collector) {
+               new AddDeclarationNodeToClassChange(nodeClass, visibility, fieldNodes, collector, isField);
+       }
+
+       public static void createChange(ICPPASTCompositeTypeSpecifier nodeClass,
+                       VisibilityEnum visibility, List<IASTNode> fieldNodes, boolean isField,
+                       ModificationCollector collector) {
+               new AddDeclarationNodeToClassChange(nodeClass, visibility, fieldNodes, collector, isField);
+       }       
+
+       private AddDeclarationNodeToClassChange(ICPPASTCompositeTypeSpecifier nodeClass,
+                       VisibilityEnum visibility, List<IASTNode> fieldNodes,
+                       ModificationCollector collector, boolean isField) {
+               this.fieldNodes = fieldNodes;
+               this.nodeClass = nodeClass;             
+               this.visibility = visibility;
+               this.collector = collector;
+               createRewrites(isField);
+       }
+       
+       private AddDeclarationNodeToClassChange(ICPPASTCompositeTypeSpecifier nodeClass,
+                       VisibilityEnum visibility, IASTNode fieldNodes, ModificationCollector collector,
+                       boolean isField) {
+               this.nodeClass = nodeClass;             
+               this.visibility = visibility;
+               this.fieldNodes.add(fieldNodes);
+               this.collector = collector;
+               createRewrites(isField);
+       }
+       
+       private void createRewrites(boolean isField) {
+               int lastFunctionDeclaration = -1;
+               int lastFieldDeclaration = -1;
+               IASTDeclaration[] members = nodeClass.getMembers();
+               
+               VisibilityEnum currentVisibility = VisibilityEnum.v_private;
+               if (IASTCompositeTypeSpecifier.k_struct == nodeClass.getKey()) {
+                       currentVisibility = VisibilityEnum.v_public;
+               }       
+       
+               // Find the insert location by iterating over the elements of the class 
+               // and remembering the last element with the matching visibility
+               for (int i = 0; i < members.length; i++) {
+                       IASTDeclaration declaration = members[i];
+                       
+                       if (declaration instanceof ICPPASTVisibilityLabel) {
+                               currentVisibility = VisibilityEnum.from((ICPPASTVisibilityLabel) declaration);
+                       }
+                       
+                       if (declaration instanceof IASTSimpleDeclaration) {
+                               IASTSimpleDeclaration simple = (IASTSimpleDeclaration) declaration;
+                               IASTDeclarator[] declarators = simple.getDeclarators();
+                               if (declarators.length > 0 && declarators[0] != null &&
+                                               declarators[0] instanceof IASTFunctionDeclarator) {
+                                       if (currentVisibility.equals(visibility)) {
+                                               lastFunctionDeclaration = i;
+                                       }
+                               } else if (declarators.length > 0 && declarators[0] != null) {
+                                       if (currentVisibility.equals(visibility)) {
+                                               lastFieldDeclaration = i;
+                                       }
+                               }
+                       }
+               }
+
+               IASTDeclaration nextFunctionDeclaration = null;
+               if (lastFunctionDeclaration < members.length - 1 && lastFunctionDeclaration >= 0)
+                       nextFunctionDeclaration = members[lastFunctionDeclaration + 1];
+
+               IASTDeclaration nextFieldDeclaration = null;
+               if (lastFieldDeclaration < members.length - 1 && lastFieldDeclaration >= 0)
+                       nextFieldDeclaration = members[lastFieldDeclaration + 1];
+               
+               createInsert(isField, nextFunctionDeclaration, nextFieldDeclaration, currentVisibility);
+       }
+
+       private void createInsert(boolean isField, IASTDeclaration nextFunctionDeclaration,
+                       IASTDeclaration nextFieldDeclaration, VisibilityEnum currentVisibility) {
+               if (isField) {
+                       if (nextFieldDeclaration != null) {
+                               insertBefore(nextFieldDeclaration);
+                       } else if (nextFunctionDeclaration != null) {
+                               insertBefore(nextFunctionDeclaration);
+                       } else {
+                               insertAtTheEnd(currentVisibility);
+                       }
+               } else {
+                       if (nextFunctionDeclaration != null) {
+                               insertBefore(nextFunctionDeclaration);
+                       } else if (nextFieldDeclaration != null) {
+                               insertBefore(nextFieldDeclaration);
+                       } else {
+                               insertAtTheEnd(currentVisibility);
+                       }
+               }
+       }
+
+       private void insertBefore(IASTNode nearestNode) {                       
+               ASTRewrite rewrite = collector.rewriterForTranslationUnit(nearestNode.getTranslationUnit());
+               for (IASTNode node : fieldNodes) {
+                       rewrite.insertBefore(nearestNode.getParent(), nearestNode, node, createEditDescription());
+               }
+       }
+
+       private void insertAtTheEnd(VisibilityEnum currentVisibility) {
+               ASTRewrite rewrite = collector.rewriterForTranslationUnit(nodeClass.getTranslationUnit());
+               
+               if (!currentVisibility.equals(visibility)) {
+                       ICPPASTVisibilityLabel label =
+                                       new CPPASTVisibilityLabel(visibility.getICPPASTVisiblityLabelVisibility());
+                       rewrite.insertBefore(nodeClass, null, label, createEditDescription());
+               }
+               
+               for (IASTNode node : fieldNodes) {
+                       rewrite.insertBefore(nodeClass, null, node, createEditDescription());
+               }
+       }
+       
+       private TextEditGroup createEditDescription() {
+               return new TextEditGroup(NLS.bind(Messages.AddDeclarationNodeToClassChange_AddDeclaration,
+                               nodeClass.getName()));
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CCompositeChange.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CCompositeChange.java
new file mode 100644 (file)
index 0000000..d1c036d
--- /dev/null
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ * Institute for Software (IFS)- initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.ChangeDescriptor;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
+import org.eclipse.ltk.core.refactoring.RefactoringChangeDescriptor;
+
+/**
+ * @author Emanuel Graf IFS
+ *
+ */
+public class CCompositeChange extends CompositeChange {
+       
+       private RefactoringChangeDescriptor desc;
+       
+       public CCompositeChange(String name, Change[] children) {
+               super(name, children);
+       }
+
+       public CCompositeChange(String name) {
+               super(name);
+       }
+
+       public void setDescription(RefactoringChangeDescriptor descriptor) {
+               desc = descriptor;
+       }
+
+       @Override
+       public ChangeDescriptor getDescriptor() {
+               if(desc == null) {
+                       return super.getDescriptor();
+               }else {
+                       return desc;
+               }
+       }
+       
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java
new file mode 100644 (file)
index 0000000..eac0efc
--- /dev/null
@@ -0,0 +1,332 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.Refactoring;
+import org.eclipse.ltk.core.refactoring.RefactoringChangeDescriptor;
+import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.osgi.util.NLS;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTProblem;
+import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTProblemExpression;
+import org.eclipse.cdt.core.dom.ast.IASTProblemStatement;
+import org.eclipse.cdt.core.dom.ast.IASTProblemTypeId;
+import org.eclipse.cdt.core.dom.ast.IASTStatement;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IASTTypeId;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ISourceRange;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.refactoring.utils.SelectionHelper;
+
+/**
+ * The base class for all other refactorings, provides some common implementations for
+ * condition checking, change generating, selection handling and translation unit loading.
+ * @deprecated Use CRefactoring2.
+ */
+@Deprecated
+public abstract class CRefactoring extends Refactoring {
+       private static final int AST_STYLE =
+                       ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT | ITranslationUnit.AST_SKIP_INDEXED_HEADERS;
+
+       protected String name = Messages.Refactoring_name; 
+       protected IFile file;
+       protected Region region;
+       protected RefactoringStatus initStatus;
+       protected IASTTranslationUnit ast;
+       protected ICProject project;
+       private IIndex fIndex;
+
+       public CRefactoring(IFile file, ISelection selection, ICElement element, ICProject proj) {
+               project = proj;
+               if (element instanceof ISourceReference) {
+                       ISourceReference sourceRef= (ISourceReference) element;
+                       ITranslationUnit tu = sourceRef.getTranslationUnit();
+                       IResource res= tu.getResource();
+                       if (res instanceof IFile) 
+                               this.file= (IFile) res;
+               
+                       try {
+                               final ISourceRange sourceRange = sourceRef.getSourceRange();
+                               this.region = new Region(sourceRange.getIdStartPos(), sourceRange.getIdLength());
+                       } catch (CModelException e) {
+                               CUIPlugin.log(e);
+                       }
+               } else {
+                       this.file = file;
+                       this.region = SelectionHelper.getRegion(selection);
+               }
+
+               this.initStatus= new RefactoringStatus();
+               if (this.file == null || region == null) {
+                       initStatus.addFatalError(Messages.Refactoring_SelectionNotValid);  
+               }
+       }
+
+       private class ProblemFinder extends ASTVisitor {
+               private boolean problemFound = false;
+               private final RefactoringStatus status;
+               
+               public ProblemFinder(RefactoringStatus status) {
+                       this.status = status;
+               }
+               
+               {
+                       shouldVisitProblems = true;
+                       shouldVisitDeclarations = true;
+                       shouldVisitExpressions = true;
+                       shouldVisitStatements = true;
+                       shouldVisitTypeIds = true;
+               }
+
+               @Override
+               public int visit(IASTProblem problem) {
+                       addWarningToState();
+                       return ASTVisitor.PROCESS_CONTINUE;
+               }
+               
+               @Override
+               public int visit(IASTDeclaration declaration) {
+                       if (declaration instanceof IASTProblemDeclaration) {
+                               addWarningToState();
+                       }
+                       return ASTVisitor.PROCESS_CONTINUE;
+               }
+               
+               @Override
+               public int visit(IASTExpression expression) {
+                       if (expression instanceof IASTProblemExpression) {
+                               addWarningToState();
+                       }
+                       return ASTVisitor.PROCESS_CONTINUE;
+               }
+
+               @Override
+               public int visit(IASTStatement statement) {
+                       if (statement instanceof IASTProblemStatement) {
+                               addWarningToState();
+                       }
+                       return ASTVisitor.PROCESS_CONTINUE;
+               }
+
+               @Override
+               public int visit(IASTTypeId typeId) {
+                       if (typeId instanceof IASTProblemTypeId) {
+                               addWarningToState();
+                       }
+                       return ASTVisitor.PROCESS_CONTINUE;
+               }
+
+               public boolean hasProblem() {
+                       return problemFound;
+               }
+               
+               private void addWarningToState() {
+                       if (!problemFound) {
+                               status.addWarning(Messages.Refactoring_CompileErrorInTU); 
+                               problemFound = true;
+                       }
+               }
+       }
+       
+       @Override
+       public RefactoringStatus checkFinalConditions(IProgressMonitor pm)
+                       throws CoreException, OperationCanceledException {
+               RefactoringStatus status = new RefactoringStatus();
+               return status;
+       }
+
+       @Override
+       public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
+                       throws CoreException, OperationCanceledException {
+               SubMonitor sm = SubMonitor.convert(pm, 10);
+               sm.subTask(Messages.Refactoring_PM_LoadTU); 
+               if (isProgressMonitorCanceld(sm, initStatus)) {
+                       return initStatus;
+               }
+               if (!loadTranslationUnit(initStatus, sm.newChild(8))) {
+                       initStatus.addError(Messages.Refactoring_CantLoadTU);  
+                       return initStatus;
+               }
+               if (isProgressMonitorCanceld(sm, initStatus)) {
+                       return initStatus;
+               }
+               sm.subTask(Messages.Refactoring_PM_CheckTU); 
+               translationUnitHasProblem();
+               if (translationUnitIsAmbiguous()) {
+                       initStatus.addError(Messages.Refactoring_Ambiguity); 
+               }
+               sm.worked(2);
+               sm.subTask(Messages.Refactoring_PM_InitRef); 
+               sm.done();
+               return initStatus;
+       }
+
+       protected static boolean isProgressMonitorCanceld(IProgressMonitor sm, RefactoringStatus status) {
+               if (sm.isCanceled()) {
+                       status.addFatalError(Messages.Refactoring_CanceledByUser); 
+                       return true;
+               }
+               return false;
+       }
+
+       @Override
+       public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
+               ModificationCollector collector = new ModificationCollector();
+               collectModifications(pm, collector);
+               CCompositeChange finalChange = null;
+               try {
+                       lockIndex();
+                       finalChange = collector.createFinalChange();
+               } catch (InterruptedException e) {
+                       throw new OperationCanceledException();
+               } finally {
+                       unlockIndex();
+               }
+               
+               finalChange.setDescription(new RefactoringChangeDescriptor(getRefactoringDescriptor()));
+               return finalChange;
+       }
+       
+       abstract protected RefactoringDescriptor getRefactoringDescriptor();
+
+       abstract protected void collectModifications(IProgressMonitor pm, ModificationCollector collector)
+                       throws CoreException, OperationCanceledException;
+
+       @Override
+       public String getName() {
+               return name;
+       }
+
+       protected boolean loadTranslationUnit(RefactoringStatus status, IProgressMonitor mon) {
+               SubMonitor subMonitor = SubMonitor.convert(mon, 10);
+               if (file != null) {
+                       try {
+                               subMonitor.subTask(Messages.Refactoring_PM_ParseTU);
+                               ast = loadTranslationUnit(file);
+                               if (ast == null) {
+                                       subMonitor.done();
+                                       return false;
+                               }
+                               subMonitor.worked(2);
+                               if (isProgressMonitorCanceld(subMonitor, initStatus)) {
+                                       return true;
+                               }
+                               subMonitor.subTask(Messages.Refactoring_PM_MergeComments); 
+
+                               subMonitor.worked(8);
+                       } catch (CoreException e) {
+                               status.addFatalError(e.getMessage()); 
+                               subMonitor.done();
+                               return false;
+                       }
+               } else {
+                       status.addFatalError(Messages.NO_FILE); 
+                       subMonitor.done();
+                       return false;
+               }
+               subMonitor.done();
+               return true;
+       }
+
+       protected IASTTranslationUnit loadTranslationUnit(IFile file) throws CoreException {
+               ITranslationUnit tu = (ITranslationUnit) CCorePlugin.getDefault().getCoreModel().create(file);
+               if (tu == null) {
+                       initStatus.addFatalError(NLS.bind(Messages.CRefactoring_FileNotFound, file.getName()));
+                       return null;
+               }
+               return tu.getAST(fIndex, AST_STYLE);
+       }
+
+       protected boolean translationUnitHasProblem() {
+               ProblemFinder pf = new ProblemFinder(initStatus);
+               ast.accept(pf);         
+               return pf.hasProblem();
+       }
+       
+       protected boolean translationUnitIsAmbiguous() {
+               // ambiguities are resolved before the tu is passed to the refactoring.
+               return false;
+       }
+       
+       public void lockIndex() throws CoreException, InterruptedException {
+               if (fIndex == null) {
+                       ICProject[] projects= CoreModel.getDefault().getCModel().getCProjects();
+                       fIndex= CCorePlugin.getIndexManager().getIndex(projects);
+               }
+               fIndex.acquireReadLock();
+       }
+       
+       public void unlockIndex() {
+               if (fIndex != null) {
+                       fIndex.releaseReadLock();
+               }
+               // Marc-Andre Laperle : I don't think we want to null this out, 
+               // if the lock is acquired twice then the lock can only be released once
+               //fIndex= null;
+       }
+
+       public IIndex getIndex() {
+               return fIndex;
+       }
+       
+       public IASTTranslationUnit getUnit() {
+               return ast;
+       }
+
+       protected ArrayList<IASTName> findAllMarkedNames() {
+               final ArrayList<IASTName> namesVector = new ArrayList<IASTName>();
+
+               ast.accept(new ASTVisitor() {
+                       {
+                               shouldVisitNames = true;
+                       }
+
+                       @Override
+                       public int visit(IASTName name) {
+                               if (SelectionHelper.isInSameFileSelection(region, name, file)) {
+                                       if (!(name instanceof ICPPASTQualifiedName)) {
+                                               namesVector.add(name);
+                                       }
+                               }
+                               return super.visit(name);
+                       }
+               });
+               return namesVector;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring2.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring2.java
new file mode 100644 (file)
index 0000000..cb2d941
--- /dev/null
@@ -0,0 +1,280 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *        Institute for Software - initial API and implementation
+ *        Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.Refactoring;
+import org.eclipse.ltk.core.refactoring.RefactoringChangeDescriptor;
+import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+import org.eclipse.ltk.core.refactoring.participants.ResourceChangeChecker;
+import org.eclipse.ltk.core.refactoring.participants.ValidateEditChecker;
+import org.eclipse.osgi.util.NLS;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTProblem;
+import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTProblemExpression;
+import org.eclipse.cdt.core.dom.ast.IASTProblemStatement;
+import org.eclipse.cdt.core.dom.ast.IASTProblemTypeId;
+import org.eclipse.cdt.core.dom.ast.IASTStatement;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IASTTypeId;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ISourceRange;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.corext.util.CModelUtil;
+
+import org.eclipse.cdt.internal.ui.refactoring.utils.SelectionHelper;
+
+/**
+ * The base class for all AST based refactorings, provides some common implementations for
+ * AST creation, condition checking, change generating, and selection handling.
+ * This class is intended as a replacement for CRefactoring.
+ */
+public abstract class CRefactoring2 extends Refactoring {
+       protected String name = Messages.Refactoring_name; 
+       protected final ICProject project;
+       protected final ITranslationUnit tu;
+       protected final RefactoringStatus initStatus;
+       protected final RefactoringASTCache astCache;
+       protected Region selectedRegion;
+
+       public CRefactoring2(ICElement element, ISelection selection, ICProject project, 
+                       RefactoringASTCache astCache) {
+               this.project = project;
+               this.astCache = astCache;
+               this.initStatus= new RefactoringStatus();
+               if (!(element instanceof ISourceReference)) {
+                       this.tu = null;
+                       initStatus.addFatalError(Messages.Refactoring_SelectionNotValid);
+                       return;
+               }
+
+               ISourceReference sourceRef= (ISourceReference) element;
+               tu = CModelUtil.toWorkingCopy(sourceRef.getTranslationUnit());
+
+               if (selection instanceof ITextSelection) {
+                       this.selectedRegion = SelectionHelper.getRegion(selection);
+               } else {
+                       try {
+                               ISourceRange sourceRange = sourceRef.getSourceRange();
+                               this.selectedRegion = new Region(sourceRange.getIdStartPos(), sourceRange.getIdLength());
+                       } catch (CModelException e) {
+                               CUIPlugin.log(e);
+                       }
+               }
+       }
+
+       private class ProblemFinder extends ASTVisitor {
+               private boolean problemFound = false;
+               private final RefactoringStatus status;
+               
+               public ProblemFinder(RefactoringStatus status) {
+                       this.status = status;
+               }
+
+               {
+                       shouldVisitProblems = true;
+                       shouldVisitDeclarations = true;
+                       shouldVisitExpressions = true;
+                       shouldVisitStatements = true;
+                       shouldVisitTypeIds = true;
+               }
+
+               @Override
+               public int visit(IASTProblem problem) {
+                       addWarningToState();
+                       return ASTVisitor.PROCESS_CONTINUE;
+               }
+
+               @Override
+               public int visit(IASTDeclaration declaration) {
+                       if (declaration instanceof IASTProblemDeclaration) {
+                               addWarningToState();
+                       }
+                       return ASTVisitor.PROCESS_CONTINUE;
+               }
+
+               @Override
+               public int visit(IASTExpression expression) {
+                       if (expression instanceof IASTProblemExpression) {
+                               addWarningToState();
+                       }
+                       return ASTVisitor.PROCESS_CONTINUE;
+               }
+
+               @Override
+               public int visit(IASTStatement statement) {
+                       if (statement instanceof IASTProblemStatement) {
+                               addWarningToState();
+                       }
+                       return ASTVisitor.PROCESS_CONTINUE;
+               }
+
+               @Override
+               public int visit(IASTTypeId typeId) {
+                       if (typeId instanceof IASTProblemTypeId) {
+                               addWarningToState();
+                       }
+                       return ASTVisitor.PROCESS_CONTINUE;
+               }
+
+               public boolean hasProblem() {
+                       return problemFound;
+               }
+
+               private void addWarningToState() {
+                       if (!problemFound) {
+                               status.addWarning(Messages.Refactoring_CompileErrorInTU); 
+                               problemFound = true;
+                       }
+               }
+       }
+
+       @Override
+       public RefactoringStatus checkFinalConditions(IProgressMonitor pm)
+                       throws CoreException, OperationCanceledException {
+               if (pm == null)
+                       pm = new NullProgressMonitor();
+               pm.beginTask(Messages.CRefactoring_checking_final_conditions, 6);
+
+               CheckConditionsContext context = createCheckConditionsContext();
+               RefactoringStatus result = checkFinalConditions(new SubProgressMonitor(pm, 5), context);
+               if (result.hasFatalError()) {
+                       pm.done();
+                       return result;
+               }
+               if (pm.isCanceled())
+                       throw new OperationCanceledException();
+
+               result.merge(context.check(new SubProgressMonitor(pm, 1)));
+               pm.done();
+               return result;
+       }
+
+       protected abstract RefactoringStatus checkFinalConditions(IProgressMonitor subProgressMonitor,
+                       CheckConditionsContext checkContext) throws CoreException, OperationCanceledException;
+
+       @Override
+       public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
+                       throws CoreException, OperationCanceledException {
+               SubMonitor sm = SubMonitor.convert(pm, 10);
+               sm.subTask(Messages.Refactoring_PM_LoadTU); 
+               if (isProgressMonitorCanceld(sm, initStatus)) {
+                       return initStatus;
+               }
+               IASTTranslationUnit ast = getAST(tu, sm);
+               if (ast == null) {
+                       initStatus.addError(NLS.bind(Messages.Refactoring_ParsingError, tu.getPath()));
+                       return initStatus;
+               }
+               if (isProgressMonitorCanceld(sm, initStatus)) {
+                       return initStatus;
+               }
+               sm.subTask(Messages.Refactoring_PM_CheckTU); 
+               checkAST(ast);
+               sm.worked(2);
+               sm.subTask(Messages.Refactoring_PM_InitRef); 
+               sm.done();
+               return initStatus;
+       }
+
+       protected static boolean isProgressMonitorCanceld(IProgressMonitor sm, RefactoringStatus status) {
+               if (sm.isCanceled()) {
+                       status.addFatalError(Messages.Refactoring_CanceledByUser); 
+                       return true;
+               }
+               return false;
+       }
+
+       @Override
+       public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
+               ModificationCollector collector = new ModificationCollector();
+               collectModifications(pm, collector);
+               CCompositeChange finalChange = collector.createFinalChange();
+               finalChange.setDescription(new RefactoringChangeDescriptor(getRefactoringDescriptor()));
+               return finalChange;
+       }
+
+       abstract protected RefactoringDescriptor getRefactoringDescriptor();
+
+       abstract protected void collectModifications(IProgressMonitor pm, ModificationCollector collector)
+                       throws CoreException, OperationCanceledException;
+
+       @Override
+       public String getName() {
+               return name;
+       }
+
+       protected IASTTranslationUnit getAST(ITranslationUnit tu, IProgressMonitor pm)
+                       throws CoreException, OperationCanceledException {
+               return astCache.getAST(tu, pm);
+       }
+
+       protected boolean checkAST(IASTTranslationUnit ast) {
+               ProblemFinder problemFinder = new ProblemFinder(initStatus);
+               ast.accept(problemFinder);              
+               return problemFinder.hasProblem();
+       }
+
+       protected List<IASTName> findAllMarkedNames(IASTTranslationUnit ast) {
+               final List<IASTName> names = new ArrayList<IASTName>();
+
+               ast.accept(new ASTVisitor() {
+                       {
+                               shouldVisitNames = true;
+                       }
+
+                       @Override
+                       public int visit(IASTName name) {
+                               if (name.isPartOfTranslationUnitFile() &&
+                                               SelectionHelper.isSelectionOnExpression(selectedRegion, name) &&
+                                               !(name instanceof ICPPASTQualifiedName)) {
+                                       names.add(name);
+                               }
+                               return super.visit(name);
+                       }
+               });
+               return names;
+       }
+
+       private CheckConditionsContext createCheckConditionsContext() throws CoreException {
+               CheckConditionsContext result= new CheckConditionsContext();
+               result.add(new ValidateEditChecker(getValidationContext()));
+               result.add(new ResourceChangeChecker());
+               return result;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringContribution.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringContribution.java
new file mode 100644 (file)
index 0000000..ea8c33c
--- /dev/null
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ * Institute for Software (IFS)- initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+import java.util.Map;
+
+import org.eclipse.ltk.core.refactoring.RefactoringContribution;
+import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
+
+/**
+ * @author Emanuel Graf IFS
+ *
+ */
+public abstract class CRefactoringContribution extends RefactoringContribution {
+
+       public CRefactoringContribution() {
+               super();
+       }
+
+       @SuppressWarnings("rawtypes")
+       @Override
+       public Map retrieveArgumentMap(RefactoringDescriptor descriptor) {
+               if (descriptor instanceof CRefactoringDescription) {
+                       CRefactoringDescription refDesc = (CRefactoringDescription) descriptor;
+                       return refDesc.getParameterMap();
+               }else {
+                       return super.retrieveArgumentMap(descriptor);
+               }
+       }
+
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringDescription.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoringDescription.java
new file mode 100644 (file)
index 0000000..ab6355e
--- /dev/null
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ * Institute for Software (IFS)- initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.text.TextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * @author Emanuel Graf IFS
+ */
+public abstract class CRefactoringDescription extends RefactoringDescriptor {
+       public static final String FILE_NAME = "fileName"; //$NON-NLS-1$
+       public static final String SELECTION = "selection"; //$NON-NLS-1$
+       protected Map<String, String> arguments;
+
+       public CRefactoringDescription(String id, String project, String description, String comment, int flags,
+                       Map<String, String> arguments) {
+               super(id, project, description, comment, flags);
+               this.arguments = arguments;
+       }
+
+       public Map<String, String> getParameterMap() {
+               return arguments;
+       }
+
+       protected ISelection getSelection() throws CoreException {
+               ISelection selection;
+               String selectStrings[] = arguments.get(SELECTION).split(","); //$NON-NLS-1$
+               if (selectStrings.length >= 2) {
+                       int offset = Integer.parseInt(selectStrings[0]);
+                       int length = Integer.parseInt(selectStrings[1]);
+                       selection = new TextSelection(offset, length);
+               } else {
+                       throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, "Illegal Selection")); //$NON-NLS-1$
+               }
+               return selection;
+       }
+
+       protected ICProject getCProject() throws CoreException {
+               ICProject proj;
+               IProject iProject = ResourcesPlugin.getWorkspace().getRoot().getProject(getProject());
+               proj = CoreModel.getDefault().create(iProject);
+               if (proj == null) {
+                       throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, "Unknown Project")); //$NON-NLS-1$
+               }
+               return proj;
+       }
+
+       protected IFile getFile() throws CoreException {
+               IFile file;
+               try {
+                       file = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(new URI(arguments.get(FILE_NAME)))[0];
+               } catch (URISyntaxException e) {
+                       throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, e.getMessage(), e));
+               }
+               return file;
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CTextFileChangeFactory.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CTextFileChangeFactory.java
new file mode 100644 (file)
index 0000000..41868e1
--- /dev/null
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.refactoring;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.ltk.core.refactoring.TextFileChange;
+
+import org.eclipse.cdt.ui.refactoring.CTextFileChange;
+
+import org.eclipse.cdt.internal.core.dom.rewrite.ICTextFileChangeFactory;
+
+/**
+ * Factory provided to the core plugin to create appropriate text file changes.
+ * @since 5.0
+ */
+public class CTextFileChangeFactory implements ICTextFileChangeFactory {
+
+       public TextFileChange createCTextFileChange(IFile file) {
+               return new CTextFileChange(file.getName(), file);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeExceptionHandler.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeExceptionHandler.java
new file mode 100644 (file)
index 0000000..29cc0c8
--- /dev/null
@@ -0,0 +1,172 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.ProgressMonitorWrapper;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
+import org.eclipse.ltk.core.refactoring.Refactoring;
+import org.eclipse.osgi.util.NLS;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.actions.WorkbenchRunnableAdapter;
+import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
+
+/**
+ * Copy of org.eclipse.ltk.internal.ui.refactoring.ChangeExceptionHandler
+ */
+public class ChangeExceptionHandler {
+
+       public static class NotCancelableProgressMonitor extends ProgressMonitorWrapper {
+               public NotCancelableProgressMonitor(IProgressMonitor monitor) {
+                       super(monitor);
+               }
+               @Override
+               public void setCanceled(boolean b) {
+                       // ignore set cancel
+               }
+               @Override
+               public boolean isCanceled() {
+                       return false;
+               }
+       }
+
+       private Shell fParent;
+       private String fName;
+
+       private static class RefactorErrorDialog extends ErrorDialog {
+               public RefactorErrorDialog(Shell parentShell, String dialogTitle, String dialogMessage, IStatus status, int displayMask) {
+                       super(parentShell, dialogTitle, dialogMessage, status, displayMask);
+               }
+               
+               @Override
+               protected void createButtonsForButtonBar(Composite parent) {
+                       super.createButtonsForButtonBar(parent);
+                       Button ok= getButton(IDialogConstants.OK_ID);
+                       ok.setText(Messages.ChangeExceptionHandler_undo_button);
+                       Button abort= createButton(parent, IDialogConstants.CANCEL_ID, Messages.ChangeExceptionHandler_abort_button, true);
+                       abort.moveBelow(ok);
+                       abort.setFocus();
+               }
+               
+               @Override
+               protected Control createMessageArea(Composite parent) {
+                       Control result= super.createMessageArea(parent);
+                       new Label(parent, SWT.NONE); // filler
+                       Label label= new Label(parent, SWT.NONE);
+                       label.setText(Messages.ChangeExceptionHandler_message);
+                       label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+                       applyDialogFont(result);
+                       return result;
+               }
+       }
+
+       public ChangeExceptionHandler(Shell parent, Refactoring refactoring) {
+               fParent= parent;
+               fName= refactoring.getName();
+       }
+
+       public void handle(Change change, RuntimeException exception) {
+               CUIPlugin.log(exception);
+               IStatus status= null;
+               if (exception.getMessage() == null) {
+                       status= new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.ERROR,
+                               Messages.ChangeExceptionHandler_status_without_detail, exception);
+               } else {
+                       status= new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.ERROR,
+                               exception.getMessage(), exception);
+               }
+               handle(change, status);
+       }
+
+       public void handle(Change change, CoreException exception) {
+               CUIPlugin.log(exception);
+               handle(change, exception.getStatus());
+       }
+
+       private void handle(Change change, IStatus status) {
+               if (change instanceof CompositeChange) {
+                       Change undo= ((CompositeChange)change).getUndoUntilException();
+                       if (undo != null) {
+                               CUIPlugin.log(status);
+                               final ErrorDialog dialog= new RefactorErrorDialog(fParent,
+                                       Messages.ChangeExceptionHandler_dialog_title,
+                                       NLS.bind(Messages.ChangeExceptionHandler_dialog_message, fName),
+                                       status, IStatus.OK | IStatus.INFO | IStatus.WARNING | IStatus.ERROR);
+                               int result= dialog.open();
+                               if (result == IDialogConstants.OK_ID) {
+                                       performUndo(undo);
+                               }
+                               return;
+                       }
+               }
+               ErrorDialog dialog= new ErrorDialog(fParent,
+                       Messages.ChangeExceptionHandler_dialog_title,
+                       NLS.bind(Messages.ChangeExceptionHandler_dialog_message, fName),
+                       status, IStatus.OK | IStatus.INFO | IStatus.WARNING | IStatus.ERROR);
+               dialog.open();
+       }
+
+       private void performUndo(final Change undo) {
+               IWorkspaceRunnable runnable= new IWorkspaceRunnable() {
+                       public void run(IProgressMonitor monitor) throws CoreException {
+                               monitor.beginTask("", 11);  //$NON-NLS-1$
+                               try {
+                                       undo.initializeValidationData(new NotCancelableProgressMonitor(new SubProgressMonitor(monitor, 1)));
+                                       if (undo.isValid(new SubProgressMonitor(monitor,1)).hasFatalError()) {
+                                               monitor.done();
+                                               return;
+                                       }
+                                       undo.perform(new SubProgressMonitor(monitor, 9));
+                               } finally {
+                                       undo.dispose();
+                               }
+                       }
+               };
+               WorkbenchRunnableAdapter adapter= new WorkbenchRunnableAdapter(runnable,
+                       ResourcesPlugin.getWorkspace().getRoot());
+               ProgressMonitorDialog dialog= new ProgressMonitorDialog(fParent);
+               try {
+                       dialog.run(false, false, adapter);
+               } catch (InvocationTargetException e) {
+                       ExceptionHandler.handle(e, fParent,
+                               Messages.ChangeExceptionHandler_undo_dialog_title,
+                               NLS.bind(Messages.ChangeExceptionHandler_undo_dialog_message, fName));
+               } catch (InterruptedException e) {
+                       // can't happen
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeTreeSet.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeTreeSet.java
new file mode 100644 (file)
index 0000000..3e5ea98
--- /dev/null
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+import java.util.Comparator;
+import java.util.TreeSet;
+
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
+
+import org.eclipse.cdt.ui.refactoring.CTextFileChange;
+
+/**
+ * @author Emanuel Graf
+ *
+ */
+public class ChangeTreeSet {
+       
+       private static final class ChangePositionComparator implements Comparator<CTextFileChange> {
+               public int compare(CTextFileChange o1, CTextFileChange o2) {
+                       if(o1.getFile().equals(o2.getFile())){
+                               return o2.getEdit().getOffset() - o1.getEdit().getOffset();
+                       }
+                       return o2.getFile().hashCode() - o1.getFile().hashCode();
+               }
+       }
+       
+       private final TreeSet<CTextFileChange> changes = new TreeSet<CTextFileChange>(new ChangePositionComparator());
+       
+       public void add(CTextFileChange change) {
+               changes.add(change);
+       }
+       
+       public CompositeChange getCompositeChange(String name) {
+               CompositeChange allChanges = new CompositeChange(name);
+               
+               for (Change change : changes) {
+                       allChanges.add(change);
+               }
+               return allChanges;
+       }
+
+       @Override
+       public String toString() {
+               return changes.toString();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Container.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Container.java
new file mode 100644 (file)
index 0000000..e753f25
--- /dev/null
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+/**
+ * Simple container for one Object, with getters and setters.
+ * 
+ * @author Mirko Stocker
+ *
+ * @param <T> The type of the encapsulated node.
+ */
+public class Container<T> {
+       private T object;
+       
+       public Container(T object) {
+               this.object = object;
+       }
+
+       public Container() {
+       }
+
+       public T getObject() {
+               return object;
+       }
+
+       public void setObject(T object) {
+               this.object = object;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CreateFileChange.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CreateFileChange.java
new file mode 100644 (file)
index 0000000..f72c1b8
--- /dev/null
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.net.URI;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * A Change for creating a new file with the given name, content and encoding at the specified path.
+ *
+ * @author Emanuel Graf
+ */
+public class CreateFileChange extends Change {
+       private String name;
+       private final IPath path;
+       private final String source;
+       private final String encoding;
+
+       public CreateFileChange(String name, IPath path, String source, String encoding) {
+               super();
+               this.name = name;
+               this.path = path;
+               this.source = source;
+               this.encoding = encoding;
+       }
+
+       public CreateFileChange(IPath path, String source, String encoding) {
+               this(null, path, source, encoding);
+       }
+
+       @Override
+       public Object getModifiedElement() {
+               return ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+       }
+
+       @Override
+       public String getName() {
+               if (name == null) {
+                       return NLS.bind(Messages.CreateFileChange_CreateFile, path.toOSString());
+               }
+               return name;
+       }
+
+       @Override
+       public void initializeValidationData(IProgressMonitor pm) {
+       }
+
+       @Override
+       public RefactoringStatus isValid(IProgressMonitor pm)
+                       throws CoreException, OperationCanceledException {
+               RefactoringStatus result= new RefactoringStatus();
+               IFile file= ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+
+               URI location= file.getLocationURI();
+               if (location == null) {
+                       result.addFatalError(NLS.bind(Messages.CreateFileChange_UnknownLoc, file.getFullPath().toString()));
+                       return result;
+               }
+
+               if (file.exists()) {
+                       result.addFatalError(NLS.bind(Messages.CreateFileChange_FileExists, file.getFullPath().toString()));
+                       return result;
+               }
+               return result;
+       }
+
+       @Override
+       public Change perform(IProgressMonitor pm) throws CoreException {
+               IFile file= ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+               InputStream is = new ByteArrayInputStream(source.getBytes());
+               file.create(is, false, new SubProgressMonitor(pm, 1));
+               if (encoding != null) {
+                       file.setCharset(encoding, new SubProgressMonitor(pm,1));
+               }
+               return new DeleteFileChange(file.getFullPath());
+       }
+
+       public String getSource() {
+               return source;
+       }
+
+       public void setName(String name) {
+               this.name = name;
+       }
+
+       @Override
+       public String toString() {
+               return getName();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/DeleteFileChange.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/DeleteFileChange.java
new file mode 100644 (file)
index 0000000..fead3c6
--- /dev/null
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+
+/**
+ * The counterpart to the CreateFileChange, a change to delete a file. 
+ * 
+ * @author Emanuel Graf
+ *
+ */
+public class DeleteFileChange extends Change {
+       
+       private final IPath path;
+       private String source;
+
+       public DeleteFileChange(IPath path) {
+               this.path = path;
+       }
+
+       @Override
+       public Object getModifiedElement() {
+               return path;
+       }
+
+
+       @Override
+       public String getName() {
+               return Messages.DeleteFileChange_0 + path.toOSString(); 
+       }
+
+
+       @Override
+       public void initializeValidationData(IProgressMonitor pm) {
+               // Nothing to do
+       }
+
+       @Override
+       public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException,
+                       OperationCanceledException {
+               RefactoringStatus status = new RefactoringStatus();
+               IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+               if(!file.exists()) {
+                       status.addFatalError(Messages.DeleteFileChange_1 + path.toString()); 
+               }
+               return status;
+       }
+       
+       private String getSource(IFile file) throws CoreException {
+               String encoding= null;
+               try {
+                       encoding= file.getCharset();
+               } catch (CoreException ex) {
+                       // fall through. Take default encoding.
+               }
+               StringBuffer sb= new StringBuffer();
+               BufferedReader br= null;
+               InputStream in= null;
+               try {
+                       in= file.getContents();
+                   if (encoding != null)
+                       br= new BufferedReader(new InputStreamReader(in, encoding));    
+                   else
+                       br= new BufferedReader(new InputStreamReader(in));      
+                       int read= 0;
+                       while ((read= br.read()) != -1) {
+                               sb.append((char) read);
+                       }
+                       br.close();
+               } catch (IOException e){
+                       
+               }
+               return sb.toString();
+       }
+
+       @Override
+       public Change perform(IProgressMonitor pm) throws CoreException {
+               IFile file= ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+               source = getSource(file);
+               Change undo = new CreateFileChange(file.getFullPath(), source, file.getCharset());
+               file.delete(true,true, pm);
+               return undo;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/DocumentAdapter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/DocumentAdapter.java
new file mode 100644 (file)
index 0000000..12e40b4
--- /dev/null
@@ -0,0 +1,495 @@
+/*******************************************************************************
+ *  Copyright (c) 2002, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *  Rational Software - Initial API and implementation
+ *  Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.core.filebuffers.ITextFileBuffer;
+import org.eclipse.core.filebuffers.ITextFileBufferManager;
+import org.eclipse.core.filebuffers.LocationKind;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourceAttributes;
+import org.eclipse.core.runtime.Assert;
+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.NullProgressMonitor;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DefaultLineTracker;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentListener;
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.cdt.core.model.BufferChangedEvent;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.IBuffer;
+import org.eclipse.cdt.core.model.IBufferChangedListener;
+import org.eclipse.cdt.core.model.IOpenable;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.model.IBufferFactory;
+
+
+/**
+ * Adapts <code>IDocument</code> to <code>IBuffer</code>. Uses the
+ * same algorithm as the text widget to determine the buffer's line delimiter. 
+ * All text inserted into the buffer is converted to this line delimiter.
+ * This class is <code>public</code> for test purposes only.
+ * 
+ * This class is similar to the JDT DocumentAdapter class.
+ */
+public class DocumentAdapter implements IBuffer, IAdaptable, IDocumentListener {
+
+       /**
+        *  Executes a document set content call in the ui thread.
+        */
+       protected class DocumentSetCommand implements Runnable {
+               
+               private String fContents;
+               
+               public void run() {
+                       fDocument.set(fContents);
+               }
+       
+               public void set(String contents) {
+                       fContents= contents;
+                       Display.getDefault().syncExec(this);
+               }
+       }
+
+       /**
+        * Executes a document replace call in the ui thread.
+        */
+       protected class DocumentReplaceCommand implements Runnable {
+               
+               private int fOffset;
+               private int fLength;
+               private String fText;
+               
+               public void run() {
+                       try {
+                               fDocument.replace(fOffset, fLength, fText);
+                       } catch (BadLocationException x) {
+                               // ignore
+                       }
+               }
+               
+               public void replace(int offset, int length, String text) {
+                       fOffset= offset;
+                       fLength= length;
+                       fText= text;
+                       Display.getDefault().syncExec(this);
+               }
+       }
+
+       private static final boolean DEBUG_LINE_DELIMITERS= true;
+       public static final IBuffer NULL_BUFFER = new IBuffer(){
+               public void addBufferChangedListener(IBufferChangedListener listener) {}
+               public void append(char[] text) {}
+               public void append(String text) {}
+               public void close() {}
+               public char getChar(int position) {return 0;}
+               public char[] getCharacters() {return new char[0];}
+               public String getContents() {return "";} //$NON-NLS-1$
+               public int getLength() {return 0;}
+               public IOpenable getOwner() {return null;}
+               public String getText(int offset, int length) {return "";} //$NON-NLS-1$
+               public IResource getUnderlyingResource() {return null;}
+               public boolean hasUnsavedChanges() {return false;}
+               public boolean isClosed() {return false;}
+               public boolean isReadOnly() {return true;}
+               public void removeBufferChangedListener(IBufferChangedListener listener) {}
+               public void replace(int position, int length, char[] text) {}
+               public void replace(int position, int length, String text) {}
+               public void save(IProgressMonitor progress, boolean force) throws CModelException {}
+               public void setContents(char[] contents) {}
+               public void setContents(String contents) {}
+       };
+
+    public static IBufferFactory FACTORY= new IBufferFactory() {
+        public IBuffer createBuffer(IOpenable owner) {
+               if (owner instanceof IWorkingCopy) {
+                       IWorkingCopy wc= (IWorkingCopy) owner;
+                       ITranslationUnit tu= wc.getOriginalElement();
+                       if (tu != null) {
+                               IResource r= tu.getResource();
+                               if (r instanceof IFile) {
+                                       return new DocumentAdapter(wc, (IFile) r);
+                               }
+                       }
+               }
+               assert false;
+               return DocumentAdapter.NULL_BUFFER;
+        }
+    };
+
+       private ITranslationUnit fTranslationUnit;
+       private IWorkingCopy fOwner;
+       private IFile fFile;
+       private ITextFileBuffer fTextFileBuffer;
+       IDocument fDocument;
+
+       private DocumentSetCommand fSetCmd= new DocumentSetCommand();
+       private DocumentReplaceCommand fReplaceCmd= new DocumentReplaceCommand();
+
+       private Set<String> fLegalLineDelimiters;
+
+       private List<IBufferChangedListener> fBufferListeners= new ArrayList<IBufferChangedListener>(3);
+       private IStatus fStatus;
+
+       
+       public DocumentAdapter(IWorkingCopy owner, IFile file) {
+               fOwner= owner;
+               fFile= file;
+               fTranslationUnit= owner.getOriginalElement();
+               if (fTranslationUnit != null) {
+                       addBufferChangedListener(fTranslationUnit);
+               }
+               initialize();                   
+       }
+
+       private void initialize() {
+               ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
+               IPath location= fFile.getFullPath();
+               try {
+                       manager.connect(location, LocationKind.IFILE, new NullProgressMonitor());
+                       fTextFileBuffer= manager.getTextFileBuffer(location, LocationKind.IFILE);
+                       fDocument= fTextFileBuffer.getDocument();
+               } catch (CoreException x) {
+                       fStatus= x.getStatus();
+                       fDocument= manager.createEmptyDocument(location, LocationKind.IFILE);
+               }
+               fDocument.addPrenotifiedDocumentListener(this);
+       }
+
+       /**
+        * Returns the status of this document adapter.
+        */
+       public IStatus getStatus() {
+               if (fStatus != null)
+                       return fStatus;
+               if (fTextFileBuffer != null)
+                       return fTextFileBuffer.getStatus();
+               return null;
+       }
+       
+       /**
+        * Returns the adapted document.
+        * 
+        * @return the adapted document
+        */
+       public IDocument getDocument() {
+               return fDocument;
+       }
+
+       /*
+        * @see IBuffer#addBufferChangedListener(IBufferChangedListener)
+        */
+       public void addBufferChangedListener(IBufferChangedListener listener) {
+               Assert.isNotNull(listener);
+               if (!fBufferListeners.contains(listener))
+                       fBufferListeners.add(listener);
+       }
+       
+       /*
+        * @see IBuffer#removeBufferChangedListener(IBufferChangedListener)
+        */
+       public void removeBufferChangedListener(IBufferChangedListener listener) {
+               Assert.isNotNull(listener);
+               fBufferListeners.remove(listener);
+       }
+       
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#append(char[])
+        */
+       public void append(char[] text) {
+               append(new String(text));               
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#append(java.lang.String)
+        */
+       public void append(String text) {
+               if (DEBUG_LINE_DELIMITERS) {
+                       validateLineDelimiters(text);
+               }
+               fReplaceCmd.replace(fDocument.getLength(), 0, text);            
+       }
+
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#close()
+        */
+       public void close() {
+               
+               if (isClosed())
+                       return;
+                       
+               IDocument d= fDocument;
+               fDocument= null;
+               d.removePrenotifiedDocumentListener(this);
+               
+               if (fTextFileBuffer != null) {
+                       ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
+                       try {
+                               manager.disconnect(fTextFileBuffer.getLocation(), LocationKind.IFILE, new NullProgressMonitor());
+                       } catch (CoreException x) {
+                               // ignore
+                       }
+                       fTextFileBuffer= null;
+               }
+               
+               fireBufferChanged(new BufferChangedEvent(this, 0, 0, null));
+               fBufferListeners.clear();
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#getChar(int)
+        */
+       public char getChar(int position) {
+               try {
+                       return fDocument.getChar(position);
+               } catch (BadLocationException x) {
+                       throw new ArrayIndexOutOfBoundsException();
+               }
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#getCharacters()
+        */
+       public char[] getCharacters() {
+               String content= getContents();
+               return content == null ? null : content.toCharArray();
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#getContents()
+        */
+       public String getContents() {
+               return fDocument.get();
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#getLength()
+        */
+       public int getLength() {
+               return fDocument.getLength();
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#getOwner()
+        */
+       public IOpenable getOwner() {
+               return fOwner;
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#getText(int, int)
+        */
+       public String getText(int offset, int length) {
+               try {
+                       return fDocument.get(offset, length);
+               } catch (BadLocationException x) {
+                       throw new ArrayIndexOutOfBoundsException();
+               }
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#getUnderlyingResource()
+        */
+       public IResource getUnderlyingResource() {
+               return fFile;
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#hasUnsavedChanges()
+        */
+       public boolean hasUnsavedChanges() {
+               return fTextFileBuffer != null ? fTextFileBuffer.isDirty() : false;
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#isClosed()
+        */
+       public boolean isClosed() {
+               return fDocument == null;
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#isReadOnly()
+        */
+       public boolean isReadOnly() {
+               IResource resource= getUnderlyingResource();
+               if (resource != null) {
+                       ResourceAttributes attributes = resource.getResourceAttributes();
+                       if (attributes != null) {
+                               return attributes.isReadOnly();
+                       }
+               }
+               return false;           
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#replace(int, int, char[])
+        */
+       public void replace(int position, int length, char[] text) {
+               replace(position, length, new String(text));            
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#replace(int, int, java.lang.String)
+        */
+       public void replace(int position, int length, String text) {
+               if (DEBUG_LINE_DELIMITERS) {
+                       validateLineDelimiters(text);
+               }
+               fReplaceCmd.replace(position, length, text);
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#save(org.eclipse.core.runtime.IProgressMonitor, boolean)
+        */
+       public void save(IProgressMonitor progress, boolean force) throws CModelException {
+               try {
+                       if (fTextFileBuffer != null)
+                               fTextFileBuffer.commit(progress, force);
+               } catch (CoreException e) {
+                       throw new CModelException(e);
+               }
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#setContents(char[])
+        */
+       public void setContents(char[] contents) {
+               setContents(new String(contents));              
+       }
+
+       /**
+        * @see org.eclipse.cdt.core.model.IBuffer#setContents(java.lang.String)
+        */
+       public void setContents(String contents) {
+               int oldLength= fDocument.getLength();
+               
+               if (contents == null) {
+                       
+                       if (oldLength != 0)
+                               fSetCmd.set(""); //$NON-NLS-1$
+               
+               } else {
+                       // set only if different
+                       if (DEBUG_LINE_DELIMITERS) {
+                               validateLineDelimiters(contents);
+                       }
+                       
+                       int newLength= contents.length();
+                       if (oldLength != newLength || !contents.equals(fDocument.get()))
+                               fSetCmd.set(contents);
+                       
+               }
+       }
+
+       private void validateLineDelimiters(String contents) {
+
+               if (fLegalLineDelimiters == null) {
+                       // collect all line delimiters in the document
+                       HashSet<String> existingDelimiters= new HashSet<String>();
+
+                       for (int i= fDocument.getNumberOfLines() - 1; i >= 0; i-- ) {
+                               try {
+                                       String curr= fDocument.getLineDelimiter(i);
+                                       if (curr != null) {
+                                               existingDelimiters.add(curr);
+                                       }
+                               } catch (BadLocationException e) {
+                                       CUIPlugin.log(e);
+                               }
+                       }
+                       if (existingDelimiters.isEmpty()) {
+                               return; // first insertion of a line delimiter: no test
+                       }
+                       fLegalLineDelimiters= existingDelimiters;
+                       
+               }
+               
+               DefaultLineTracker tracker= new DefaultLineTracker();
+               tracker.set(contents);
+               
+               int lines= tracker.getNumberOfLines();
+               if (lines <= 1)
+                       return;
+               
+               for (int i= 0; i < lines; i++) {
+                       try {
+                               String curr= tracker.getLineDelimiter(i);
+                               if (curr != null && !fLegalLineDelimiters.contains(curr)) {
+                                       StringBuffer buf= new StringBuffer("New line delimiter added to new code: "); //$NON-NLS-1$
+                                       for (int k= 0; k < curr.length(); k++) {
+                                               buf.append(String.valueOf((int) curr.charAt(k)));
+                                       }
+                                       CUIPlugin.log(new Exception(buf.toString()));
+                               }
+                       } catch (BadLocationException e) {
+                CUIPlugin.log(e);
+                       }
+               }
+       }
+
+       /*
+        * @see IDocumentListener#documentAboutToBeChanged(DocumentEvent)
+        */
+       public void documentAboutToBeChanged(DocumentEvent event) {
+               // there is nothing to do here
+       }
+
+       /*
+        * @see IDocumentListener#documentChanged(DocumentEvent)
+        */
+       public void documentChanged(DocumentEvent event) {
+               fireBufferChanged(new BufferChangedEvent(this, event.getOffset(), event.getLength(), event.getText()));
+       }
+       
+       private void fireBufferChanged(BufferChangedEvent event) {
+               if (fBufferListeners != null && fBufferListeners.size() > 0) {
+                       Iterator<IBufferChangedListener> e= new ArrayList<IBufferChangedListener>(fBufferListeners).iterator();
+                       while (e.hasNext())
+                               e.next().bufferChanged(event);
+               }
+       }
+
+       public ITextFileBuffer getTextFileBuffer() {
+               return fTextFileBuffer;
+       }
+
+       @SuppressWarnings({ "unchecked", "rawtypes" })
+       public Object getAdapter(Class adapter) {
+               if (adapter.isAssignableFrom(ITextFileBuffer.class)) {
+                       return fTextFileBuffer;
+               } else if (adapter.isAssignableFrom(IDocument.class)) {
+                       return fDocument;
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/EqualityChecker.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/EqualityChecker.java
new file mode 100644 (file)
index 0000000..42f5d0e
--- /dev/null
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+public interface EqualityChecker<T> {
+       boolean isEquals(T object1, T object2);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/IScheduledRefactoring.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/IScheduledRefactoring.java
new file mode 100644 (file)
index 0000000..4a95de3
--- /dev/null
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+
+public interface IScheduledRefactoring {
+
+       /**
+        * The scheduling rule used to perform the
+        * refactoring.
+        *
+        * @return {@link ISchedulingRule} not null
+        */
+       public ISchedulingRule getSchedulingRule();
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/IndexToASTNameHelper.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/IndexToASTNameHelper.java
new file mode 100644 (file)
index 0000000..ae56eb1
--- /dev/null
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.cdt.core.dom.IName;
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.core.parser.util.CharArrayUtils;
+
+public class IndexToASTNameHelper {
+
+       public static List<IASTName> findNamesIn(IASTTranslationUnit tu, IBinding binding, IIndex index) {
+               BindingToAstNameMatcher visitor = new BindingToAstNameMatcher(binding, index);
+               tu.accept(visitor);
+               return visitor.getMatches();
+       }
+
+       public static IASTName findMatchingASTName(IASTTranslationUnit tu, IName name, IIndex index) throws CoreException {
+               if (name instanceof IASTName) {
+                       return (IASTName) name;
+               } else if (!(name instanceof IIndexName)) {
+                       return null;
+               }
+
+               IndexNameToAstNameMatcher visitor = new IndexNameToAstNameMatcher(tu, (IIndexName) name, index);
+               tu.accept(visitor);
+               return visitor.getMatch();
+       }
+
+       static boolean shouldConsiderName(IASTName candidate) {
+               return !isQualifiedName(candidate) && isLastNameInQualifiedName(candidate) && !isUnnamedName(candidate);
+       }
+
+       private static boolean isLastNameInQualifiedName(IASTName name) {
+               if (name.getParent() instanceof ICPPASTQualifiedName) {
+                       ICPPASTQualifiedName qName = (ICPPASTQualifiedName) name.getParent();
+                       return name.equals(qName.getLastName());
+               }
+               return true;
+       }
+
+       private static boolean isUnnamedName(IASTName name) {
+               return name.getFileLocation() == null && "".equals(name.toString()); //$NON-NLS-1$
+       }
+
+       private static boolean isQualifiedName(IASTName name) {
+               return name instanceof ICPPASTQualifiedName;
+       }
+}
+
+class IndexNameToAstNameMatcher extends ASTVisitor {
+
+       private IASTName result;
+       private IBinding bindingToFind;
+       private char[] charNameToFind;
+       private IIndex index;
+       private IASTFileLocation locationToFind;
+
+       public IndexNameToAstNameMatcher(IASTTranslationUnit tu, IIndexName indexName, IIndex index) throws CoreException {
+               super(true);
+               locationToFind = indexName.getFileLocation();
+               bindingToFind = index.findBinding(indexName);
+               this.index = index;
+               charNameToFind = bindingToFind.getNameCharArray();
+               shouldVisitImplicitNames = true;
+               shouldVisitImplicitNameAlternates = true;
+       }
+
+       @Override
+       public int visit(IASTName candidate) {
+               if (!IndexToASTNameHelper.shouldConsiderName(candidate)) {
+                       return PROCESS_CONTINUE;
+               }
+               if (isEquivalent(candidate)) {
+                       result = candidate;
+                       return PROCESS_ABORT;
+               }
+               return PROCESS_CONTINUE;
+       }
+
+       private boolean isEquivalent(IASTName candidate) {
+               return matchesIndexName(candidate) && bindingToFind.equals(index.adaptBinding(candidate.resolveBinding()));
+       }
+
+       private boolean matchesIndexName(IASTName candidate) {
+               IASTFileLocation candidateLocation = candidate.getFileLocation();
+               return locationToFind.getNodeOffset() == candidateLocation.getNodeOffset() && locationToFind.getNodeLength() == candidateLocation.getNodeLength()
+                               && locationToFind.getFileName().equals(candidateLocation.getFileName()) && CharArrayUtils.equals(candidate.getLookupKey(), charNameToFind);
+       }
+
+       public IASTName getMatch() {
+               return result;
+       }
+}
+
+class BindingToAstNameMatcher extends ASTVisitor {
+
+       private List<IASTName> results = new ArrayList<IASTName>();
+       private IBinding bindingToFind;
+       private char[] toFindName;
+       private IIndex index;
+
+       public BindingToAstNameMatcher(IBinding binding, IIndex index) {
+               super(true);
+               bindingToFind = index.adaptBinding(binding);
+               this.index = index;
+               toFindName = binding.getNameCharArray();
+               shouldVisitImplicitNames = true;
+               shouldVisitImplicitNameAlternates = true;
+       }
+
+       @Override
+       public int visit(IASTName candidate) {
+               if (!IndexToASTNameHelper.shouldConsiderName(candidate)) {
+                       return PROCESS_CONTINUE;
+               }
+               if (isEquivalent(candidate)) {
+                       results.add(candidate);
+               }
+               return PROCESS_CONTINUE;
+       }
+
+       private boolean isEquivalent(IASTName candidate) {
+               return CharArrayUtils.equals(candidate.getSimpleID(), toFindName) && bindingToFind.equals(index.adaptBinding(candidate.resolveBinding()));
+       }
+
+       public List<IASTName> getMatches() {
+               return results;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Messages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Messages.java
new file mode 100644 (file)
index 0000000..13d0d67
--- /dev/null
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *        Institute for Software - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class Messages extends NLS {
+       public static String DeleteFileChange_0;
+       public static String DeleteFileChange_1;
+       public static String Refactoring_name;
+       public static String Refactoring_PM_LoadTU;
+       public static String Refactoring_PM_CheckTU;
+       public static String Refactoring_PM_InitRef;
+       public static String Refactoring_PM_ParseTU;
+       public static String Refactoring_PM_MergeComments;
+       public static String Refactoring_CanceledByUser;
+       public static String Refactoring_CompileErrorInTU;
+       public static String AddDeclarationNodeToClassChange_AddDeclaration;
+       public static String CreateFileChange_CreateFile;
+       public static String CreateFileChange_UnknownLoc;
+       public static String CreateFileChange_FileExists;
+       public static String CRefactoring_FileNotFound;
+       public static String CRefactoring_checking_final_conditions;
+       public static String Refactoring_SelectionNotValid;
+       public static String Refactoring_CantLoadTU;
+       public static String Refactoring_Ambiguity;
+       public static String Refactoring_ParsingError;
+       public static String NodeContainer_Name;
+       public static String NO_FILE;
+       public static String RefactoringSaveHelper_unexpected_exception;
+       public static String RefactoringSaveHelper_saving;
+       public static String RefactoringSaveHelper_always_save;
+       public static String RefactoringSaveHelper_save_all_resources;
+       public static String RefactoringSaveHelper_must_save;
+       public static String ChangeExceptionHandler_abort_button;
+       public static String ChangeExceptionHandler_dialog_message;
+       public static String ChangeExceptionHandler_dialog_title;
+       public static String ChangeExceptionHandler_message;
+       public static String ChangeExceptionHandler_status_without_detail;
+       public static String ChangeExceptionHandler_undo_button;
+       public static String ChangeExceptionHandler_undo_dialog_message;
+       public static String ChangeExceptionHandler_undo_dialog_title;
+       public static String RefactoringExecutionHelper_cannot_execute;
+
+       static {
+               NLS.initializeMessages(Messages.class.getName(), Messages.class);
+       }
+
+       // Do not instantiate
+       private Messages() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Messages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Messages.properties
new file mode 100644 (file)
index 0000000..6ae45bc
--- /dev/null
@@ -0,0 +1,48 @@
+###############################################################################
+# Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik
+# Rapperswil, University of applied sciences and others
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     Institute for Software - initial API and implementation
+#     Sergey Prigogin (Google)
+###############################################################################
+DeleteFileChange_0=Delete File
+DeleteFileChange_1=File doesn't exist.
+Refactoring_name=Refactoring
+Refactoring_PM_LoadTU=Load Translation Unit
+Refactoring_PM_CheckTU=Check Translation Unit
+Refactoring_PM_InitRef=Initialize Refactoring
+Refactoring_PM_ParseTU=Parse Translation Unit
+Refactoring_PM_MergeComments=Merge Comments
+Refactoring_CanceledByUser=Refactoring canceled by user.
+Refactoring_CompileErrorInTU=The translation unit contains one or several problems. This can be caused by a syntax error in the code or a parser flaw. The refactoring will possibly fail.
+AddDeclarationNodeToClassChange_AddDeclaration=Add Declaration to Class {0}.
+CreateFileChange_CreateFile=Create file: {0}
+CreateFileChange_UnknownLoc=Unknown Location: {0}
+CreateFileChange_FileExists=File already exists: {0}
+CRefactoring_FileNotFound=The file {0} is not on the build path of a C/C++ project.
+CRefactoring_checking_final_conditions=Checking preconditions...
+Refactoring_SelectionNotValid=Selection is not valid.
+Refactoring_CantLoadTU=Can not load translation unit.
+Refactoring_Ambiguity=Translation unit is ambiguous.
+Refactoring_ParsingError=Unable to parse {0}.
+NO_FILE=File not found.
+NodeContainer_Name=name:
+RefactoringSaveHelper_unexpected_exception=An unexpected exception occurred. See the error log for more details.
+RefactoringSaveHelper_saving=Saving Resources
+RefactoringSaveHelper_always_save=&Always save all modified resources automatically prior to refactoring
+RefactoringSaveHelper_save_all_resources=Save Modified Resources
+RefactoringSaveHelper_must_save=Some modified resources must be saved before this operation.
+ChangeExceptionHandler_undo_button=Undo
+ChangeExceptionHandler_abort_button=Abort
+ChangeExceptionHandler_message=\n Click 'Undo' to undo all successfully executed changes of the current refactoring.\n Click 'Abort' to abort the current refactoring.
+ChangeExceptionHandler_dialog_title=Refactoring
+ChangeExceptionHandler_status_without_detail=Exception does not provide a detail message
+ChangeExceptionHandler_undo_dialog_title=Undo Refactoring
+ChangeExceptionHandler_undo_dialog_message=An unexpected exception occurred while undoing the refactoring ''{0}''
+ChangeExceptionHandler_dialog_message=An exception has been caught while processing the refactoring ''{0}''.
+RefactoringExecutionHelper_cannot_execute=The operation cannot be performed due to the following problem:\n\n{0}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/MethodContext.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/MethodContext.java
new file mode 100644 (file)
index 0000000..e73b521
--- /dev/null
@@ -0,0 +1,206 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *     Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
+
+import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTVisibilityLabel;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
+
+/**
+ * Represents a function or method and adds some useful helper methods to
+ * determine if methods are in the same class.
+ */
+public class MethodContext {
+       public enum ContextType { NONE, FUNCTION, METHOD }
+
+       private ContextType type;
+       private IASTName declarationName;
+       private ICPPASTQualifiedName qname;
+
+       public ContextType getType() {
+               return type;
+       }
+
+       public void setType(ContextType type) {
+               this.type = type;
+       }
+
+       public void setMethodDeclarationName(IASTName tmpname) {
+               this.declarationName = tmpname;
+       }
+
+       public IASTName getMethodDeclarationName() {
+               return declarationName;
+       }
+       
+       public IASTDeclaration getMethodDeclaration() {
+               IASTNode parent = declarationName.getParent().getParent();
+               if (parent instanceof IASTDeclaration) {
+                       return (IASTDeclaration) parent;
+               }
+               return null;
+       }
+       
+       public ICPPASTVisibilityLabel getMethodDeclarationASTVisibility() {
+               ICPPASTVisibilityLabel label = new CPPASTVisibilityLabel();
+               ICPPMember member = (ICPPMember) qname.resolveBinding();                        
+               label.setVisibility(member.getVisibility());
+               return label;
+       }
+       
+       public Visibility getMethodDeclarationVisibility() {
+               return Visibility.getVisibility(declarationName);
+       }
+
+       public void setMethodQName(ICPPASTQualifiedName qname) {
+               this.qname = qname;
+       }
+       
+       public ICPPASTQualifiedName getMethodQName() {
+               return qname;
+       }
+       
+       public static boolean isSameClass(ICPPASTQualifiedName qname1, ICPPASTQualifiedName qname2) {
+               ICPPClassType bind1 = getClassBinding(qname1);
+               ICPPClassType bind2 = getClassBinding(qname2);
+               return bind1.equals(bind2);
+       }
+       
+       public static boolean isSameOrSubClass(MethodContext context1, MethodContext contextOfSameOrSubclass) {
+               ICPPInternalBinding bind1 = getICPPInternalBinding(context1);
+               ICPPInternalBinding subclassBind = getICPPInternalBinding(contextOfSameOrSubclass);
+               if (isSameClass(bind1,subclassBind)) {
+                       return true;
+               }
+               return isSubclass(bind1,subclassBind);
+       }
+       
+       private static boolean isSubclass(ICPPInternalBinding bind1, ICPPInternalBinding subclassBind) {
+               if (subclassBind instanceof ICPPClassType) {
+                       ICPPClassType classType = (ICPPClassType) subclassBind;
+                       ICPPBase[] bases;
+                       bases = classType.getBases();
+                       for (ICPPBase base : bases) {
+                               if (isSameClass(base,bind1)) {
+                                       return true;
+                               }
+                       }
+               }
+               return false;
+       }
+
+       public static boolean isSameClass(MethodContext context1, MethodContext context2) {
+               ICPPInternalBinding bind1 = getICPPInternalBinding(context1);
+               ICPPInternalBinding bind2 = getICPPInternalBinding(context2);
+               return isSameClass(bind1,bind2);
+       }
+       
+       private static boolean isSameClass(ICPPBase base, ICPPInternalBinding bind2) {
+               try {
+                       IBinding bind1 = base.getBaseClass();
+                       IScope scope1 = bind1.getScope();
+                       if (scope1 == null)
+                               return false;
+                       IASTNode node1 = ASTInternal.getPhysicalNodeOfScope(scope1);
+                       
+                       IScope scope2 = bind2.getScope();
+                       if (scope2 == null)
+                               return false;
+                       IASTNode node2 = ASTInternal.getPhysicalNodeOfScope(scope2);
+                       
+                       if (node1.equals(node2)) {
+                               if (bind1 instanceof ICPPInternalBinding) {
+                                       ICPPInternalBinding bind1int = (ICPPInternalBinding) bind1;
+                                       return bind1int.getDefinition().equals(bind2.getDefinition());
+                               }
+                               return false;
+                       }
+                       return false;
+               } catch (DOMException e) {
+                       return false;
+               }       
+       }
+       
+       private static boolean isSameClass(ICPPInternalBinding bind1, ICPPInternalBinding bind2) {
+               try {
+                       IScope scope1 = bind1.getScope();
+                       if (scope1 == null)
+                               return false;
+                       IASTNode node1 = ASTInternal.getPhysicalNodeOfScope(scope1);
+                       
+                       IScope scope2 = bind2.getScope();
+                       if (scope2 == null)
+                               return false;
+                       IASTNode node2 = ASTInternal.getPhysicalNodeOfScope(scope2);
+                       
+                       if (node1.equals(node2)) {
+                               return bind1.getDefinition().equals(bind2.getDefinition());
+                       }
+                       return false;
+               } catch (DOMException e) {
+                       return false;
+               }       
+       }
+       
+       public static ICPPInternalBinding getICPPInternalBinding(MethodContext context) {
+               IASTName decl = context.getMethodDeclarationName();
+               IASTNode node = decl;
+               while (node != null) {
+                       if (node instanceof ICPPASTCompositeTypeSpecifier) {
+                               ICPPASTCompositeTypeSpecifier type = (ICPPASTCompositeTypeSpecifier) node;
+                               IASTName classname = type.getName();
+                               return (ICPPInternalBinding)classname.resolveBinding();
+                       }
+                       node = node.getParent();
+               }
+               
+               return null;
+       }
+       
+       public boolean isInline() {
+               return qname == null;
+       }
+       
+       private static ICPPClassType getClassBinding(ICPPASTQualifiedName qname) {
+               IASTName classname = qname.getNames()[qname.getNames().length - 2];
+               ICPPClassType bind = (ICPPClassType)classname.resolveBinding(); 
+               return bind;
+       }
+
+       public static boolean isSameClass(IASTName declName1, IASTName declName2) {
+               ICPPClassType bind1 = getClassBinding(declName1);
+               ICPPClassType bind2 = getClassBinding(declName2);
+               return bind1.equals(bind2);
+       }
+
+       private static ICPPClassType getClassBinding(IASTName declName1) {
+               if (declName1.getParent().getParent().getParent() instanceof ICPPASTCompositeTypeSpecifier) {
+                       ICPPASTCompositeTypeSpecifier compTypeSpec =
+                                       (ICPPASTCompositeTypeSpecifier) declName1.getParent().getParent().getParent();
+                       return (ICPPClassType) compTypeSpec.getName().resolveBinding();
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ModificationCollector.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ModificationCollector.java
new file mode 100644 (file)
index 0000000..7a8864b
--- /dev/null
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
+
+/**
+ * A ModificationCollector can be passed through a refactoring and manages the rewriters
+ * and additional changes a refactoring can create.
+ *
+ * @author Mirko Stocker
+ */
+public class ModificationCollector {
+       // Each translation unit can have only one ASTRewrite
+       private final Map<IASTTranslationUnit, ASTRewrite> rewriters =
+                       new HashMap<IASTTranslationUnit, ASTRewrite>();
+
+       private Collection<CreateFileChange> changes;
+
+       public ASTRewrite rewriterForTranslationUnit(IASTTranslationUnit ast) {
+               if (!rewriters.containsKey(ast)) {
+                       rewriters.put(ast, ASTRewrite.create(ast));
+               }
+               return rewriters.get(ast);
+       }
+
+       // Creating new files doesn't concern the rewriter, the refactorings can add them here as needed.
+       public void addFileChange(CreateFileChange change) {
+               if (changes == null) {
+                       changes = new ArrayList<CreateFileChange>();
+               }
+               changes.add(change);
+       }
+
+       public CCompositeChange createFinalChange() {
+               // Synthetic changes aren't displayed and therefore don't need a name
+               CCompositeChange result = new CCompositeChange(""); //$NON-NLS-1$
+               result.markAsSynthetic();
+
+               if (changes != null) {
+                       for (Change change : changes) {
+                               addFlattened(change, result);
+                       }
+               }
+
+               for (ASTRewrite each : rewriters.values()) {
+                       Change change = each.rewriteAST();
+                       addFlattened(change, result);
+               }
+
+               return result;
+       }
+
+       /**
+        * If {@code change} is a CompositeChange, merges it into the {@code receiver}, otherwise
+        * adds it to the {@code receiver}.
+        * @param change The change being added.
+        * @param receiver The composite change that receives the addition.
+        */
+       private void addFlattened(Change change, CompositeChange receiver) {
+               if (change instanceof CompositeChange) {
+                       receiver.merge((CompositeChange) change);
+               } else {
+                       receiver.add(change);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NameNVisibilityInformation.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NameNVisibilityInformation.java
new file mode 100644 (file)
index 0000000..95674e6
--- /dev/null
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+import java.util.ArrayList;
+
+import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
+
+/**
+ * Associate a name with a visibility and holds a list of used names.
+ *
+ */
+public class NameNVisibilityInformation {
+       
+       private String name = "";        //$NON-NLS-1$
+       private VisibilityEnum visibility = VisibilityEnum.v_public;
+       private final ArrayList<String> usedNames = new ArrayList<String>();
+
+       public String getName() {
+               return name; 
+       }
+
+       public void setName(String name) {
+               this.name = name;
+       }
+
+       public VisibilityEnum getVisibility() {
+               return visibility;
+       }
+
+       public void setVisibility(VisibilityEnum visibility) {
+               this.visibility = visibility;
+       }
+       
+       public ArrayList<String> getUsedNames(){
+               return usedNames;
+       }
+       
+       public void addNameToUsedNames(String name) {
+               usedNames.add(name);
+       }
+       
+       public void addNamesToUsedNames(ArrayList<String> names) {
+               usedNames.addAll(names);
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NodeContainer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NodeContainer.java
new file mode 100644 (file)
index 0000000..169f140
--- /dev/null
@@ -0,0 +1,523 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *     Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.ILog;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTMacroExpansionLocation;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTNode.CopyStyle;
+import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
+import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.INodeFactory;
+import org.eclipse.cdt.core.dom.ast.IVariable;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPNodeFactory;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
+import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ASTWriter;
+
+public class NodeContainer {
+       public final NameInformation NULL_NAME_INFORMATION = new NameInformation(new CPPASTName());
+
+       private final ArrayList<IASTNode> vec;
+       private final ArrayList<NameInformation> names;
+
+       public class NameInformation {
+               private IASTName name;
+               private IASTName declaration;
+               private final ArrayList<IASTName> references;
+               private ArrayList<IASTName> referencesAfterCached;
+               private int lastCachedReferencesHash;
+               private boolean isReference;
+               private boolean isReturnValue;
+               private boolean isConst;
+               private boolean isWriteAccess;
+
+               private boolean userSetIsReference;
+               private boolean userSetIsReturnValue;
+               private String userSetName;
+               private int userOrder;
+
+               public int getUserOrder() {
+                       return userOrder;
+               }
+
+               public void setUserOrder(int userOrder) {
+                       this.userOrder = userOrder;
+               }
+
+               public NameInformation(IASTName name) {
+                       super();
+                       this.name = name;
+                       references = new ArrayList<IASTName>();
+               }
+
+               public IASTName getDeclaration() {
+                       return declaration;
+               }
+
+               public void setDeclaration(IASTName declaration) {
+                       this.declaration = declaration;
+               }
+
+               public IASTName getName() {
+                       return name;
+               }
+
+               public void setName(IASTName name) {
+                       this.name = name;
+               }
+
+               public void addReference(IASTName name) {
+                       references.add(name);
+               }
+
+               public ArrayList<IASTName> getReferencesAfterSelection() {
+                       if (referencesAfterCached == null
+                                       || lastCachedReferencesHash != references.hashCode()) {
+                               lastCachedReferencesHash = references.hashCode();
+                               referencesAfterCached = new ArrayList<IASTName>();
+                               for (IASTName ref : references) {
+                                       IASTFileLocation loc = ref.getFileLocation();
+                                       if (loc.getNodeOffset() >= getEndOffset()) {
+                                               referencesAfterCached.add(ref);
+                                       }
+                               }
+                       }
+                       return referencesAfterCached;
+               }
+
+               public boolean isUsedAfterReferences() {
+                       return getReferencesAfterSelection().size() > 0;
+               }
+
+               public IASTParameterDeclaration getParameterDeclaration(boolean isReference,
+                               INodeFactory nodeFactory) {
+                       IASTDeclarator sourceDeclarator = (IASTDeclarator) getDeclaration().getParent();
+
+                       IASTDeclSpecifier declSpec= null;
+                       IASTDeclarator declarator= null;
+                       
+                       if (sourceDeclarator.getParent() instanceof IASTSimpleDeclaration) {
+                               IASTSimpleDeclaration decl = (IASTSimpleDeclaration) sourceDeclarator.getParent();
+                               declSpec = decl.getDeclSpecifier().copy(CopyStyle.withLocations);
+                       } else if (sourceDeclarator.getParent() instanceof IASTParameterDeclaration) {
+                               IASTParameterDeclaration decl = (IASTParameterDeclaration) sourceDeclarator.getParent();
+                               declSpec = decl.getDeclSpecifier().copy(CopyStyle.withLocations);
+                       }
+
+                       IASTName name= nodeFactory.newName(getDeclaration().toCharArray());
+                       if (sourceDeclarator instanceof IASTArrayDeclarator) {
+                               IASTArrayDeclarator arrDeclarator = (IASTArrayDeclarator) sourceDeclarator;
+                               IASTArrayDeclarator arrayDtor = nodeFactory.newArrayDeclarator(name);
+                               IASTArrayModifier[] arrayModifiers = arrDeclarator.getArrayModifiers();
+                               for (IASTArrayModifier arrayModifier : arrayModifiers) {
+                                       arrayDtor.addArrayModifier(arrayModifier.copy(CopyStyle.withLocations));
+                               }
+                               declarator= arrayDtor;
+                       } else {
+                               declarator = nodeFactory.newDeclarator(name);
+                       }
+                       for (IASTPointerOperator pointerOp : sourceDeclarator.getPointerOperators()) {
+                               declarator.addPointerOperator(pointerOp.copy(CopyStyle.withLocations));
+                       }
+
+                       if (isReference && !hasReferenceOperartor(declarator)) {
+                               if (nodeFactory instanceof ICPPNodeFactory) {
+                                       declarator.addPointerOperator(((ICPPNodeFactory) nodeFactory).newReferenceOperator(false));
+                               } else {
+                                       declarator.addPointerOperator(nodeFactory.newPointer());
+                               }
+                       }
+
+                       declarator.setNestedDeclarator(sourceDeclarator.getNestedDeclarator());
+
+                       return nodeFactory.newParameterDeclaration(declSpec, declarator);
+               }
+
+               public boolean hasReferenceOperartor(IASTDeclarator declarator) {
+                       for (IASTPointerOperator pOp : declarator.getPointerOperators()) {
+                               if (pOp instanceof ICPPASTReferenceOperator) {
+                                       return true;
+                               }
+                       }
+                       return false;
+               }
+
+               public String getType() {
+                       IASTDeclSpecifier declSpec = null;
+
+                       IASTNode node = getDeclaration().getParent();
+                       if (node instanceof ICPPASTSimpleTypeTemplateParameter) {
+                               ICPPASTSimpleTypeTemplateParameter parameter = (ICPPASTSimpleTypeTemplateParameter) node;
+                               return parameter.getName().toString();
+                       }
+                       IASTDeclarator sourceDeclarator = (IASTDeclarator) node;
+                       if (sourceDeclarator.getParent() instanceof IASTSimpleDeclaration) {
+                               IASTSimpleDeclaration decl = (IASTSimpleDeclaration) sourceDeclarator.getParent();
+                               declSpec = decl.getDeclSpecifier();
+                       } else if (sourceDeclarator.getParent() instanceof IASTParameterDeclaration) {
+                               IASTParameterDeclaration decl = (IASTParameterDeclaration) sourceDeclarator.getParent();
+                               declSpec = decl.getDeclSpecifier();
+                       }
+
+                       ASTWriter writer = new ASTWriter();
+                       return writer.write(declSpec);
+               }
+
+               public boolean isDeclarationInScope() {
+                       if (declaration != null && declaration.toCharArray().length > 0) {
+                               int declOffset = declaration.getFileLocation().getNodeOffset();
+                               return declOffset >= getStartOffset()
+                               && declOffset <= getEndOffset();
+                       }
+                       return true;
+               }
+
+               @Override
+               public String toString() {
+                       return Messages.NodeContainer_Name + name + ' ' + isDeclarationInScope();
+               }
+
+               public boolean isReference() {
+                       return isReference;
+               }
+
+               public void setReference(boolean isReference) {
+                       this.isReference = isReference;
+               }
+
+               public boolean isReturnValue() {
+                       return isReturnValue;
+               }
+
+               public void setReturnValue(boolean isReturnValue) {
+                       this.isReturnValue = isReturnValue;
+               }
+
+               public boolean isUserSetIsReference() {
+                       return userSetIsReference;
+               }
+
+               public void setUserSetIsReference(boolean userSetIsReference) {
+                       this.userSetIsReference = userSetIsReference;
+               }
+
+               public boolean isUserSetIsReturnValue() {
+                       return userSetIsReturnValue;
+               }
+
+               public void setUserSetIsReturnValue(boolean userSetIsReturnValue) {
+                       this.userSetIsReturnValue = userSetIsReturnValue;
+               }
+
+               public String getUserSetName() {
+                       return userSetName;
+               }
+
+               public void setUserSetName(String userSetName) {
+                       this.userSetName = userSetName;
+               }
+
+               public boolean isConst() {
+                       return isConst;
+               }
+
+               public void setConst(boolean isConst) {
+                       this.isConst = isConst;
+               }
+
+               public boolean isWriteAccess() {
+                       return isWriteAccess;
+               }
+
+               public void setWriteAccess(boolean isWriteAceess) {
+                       this.isWriteAccess = isWriteAceess;
+               }
+       }
+
+       public NodeContainer() {
+               super();
+               vec = new ArrayList<IASTNode>();
+               names = new ArrayList<NameInformation>();
+       }
+
+       public final int size() {
+               return vec.size();
+       }
+
+       public final boolean isEmpty() {
+               return vec.isEmpty();
+       }
+
+       public void add(IASTNode node) {
+               vec.add(node);
+       }
+
+       public void findAllNames() {
+               for (IASTNode node : vec) {
+                       node.accept(new ASTVisitor() {
+                               {
+                                       shouldVisitNames = true;
+                               }
+
+                               @Override
+                               public int visit(IASTName name) {
+                                       IBinding bind = name.resolveBinding();
+
+                                       if (bind instanceof ICPPBinding
+                                                       && !(bind instanceof ICPPTemplateTypeParameter)) {
+                                               ICPPBinding cppBind = (ICPPBinding) bind;
+                                               try {
+                                                       if (!cppBind.isGloballyQualified()) {
+                                                               NameInformation nameInformation = new NameInformation(name);
+                                                               IASTName[] refs = name.getTranslationUnit().getReferences(bind);
+                                                               for (IASTName ref : refs) {
+                                                                       nameInformation.addReference(ref);
+                                                               }
+                                                               names.add(nameInformation);
+                                                       }
+                                               } catch (DOMException e) {
+                                                       ILog logger = CUIPlugin.getDefault().getLog();
+                                                       IStatus status = new Status(IStatus.WARNING,
+                                                                       CUIPlugin.PLUGIN_ID, IStatus.OK, e.getMessage(), e);
+                                                       logger.log(status);
+                                               }
+                                       } else if (bind instanceof IVariable) {
+                                               NameInformation nameInformation = new NameInformation(name);
+
+                                               IASTName[] refs = name.getTranslationUnit().getReferences(bind);
+                                               for (IASTName ref : refs) {
+                                                       nameInformation.addReference(ref);
+                                               }
+                                               names.add(nameInformation);
+                                       }
+                                       return super.visit(name);
+                               }
+                       });
+               }
+
+               for (NameInformation nameInf : names) {
+                       IASTName name = nameInf.getName();
+
+                       IASTTranslationUnit unit = name.getTranslationUnit();
+                       IASTName[] decls = unit.getDeclarationsInAST(name.resolveBinding());
+                       for (IASTName declaration : decls) {
+                               nameInf.setDeclaration(declaration);
+                       }
+               }
+       }
+
+       /*
+        * Returns all local names in the selection which will be used after the
+        * selection expected the ones which are pointers
+        */
+       public ArrayList<NameInformation> getAllAfterUsedNames() {
+               ArrayList<IASTName> declarations = new ArrayList<IASTName>();
+               ArrayList<NameInformation> usedAfter = new ArrayList<NameInformation>();
+
+               if (names.size() <= 0) {
+                       findAllNames();
+               }
+
+               for (NameInformation nameInf : names) {
+                       if (!declarations.contains(nameInf.getDeclaration())) {
+                               declarations.add(nameInf.getDeclaration());
+                               if (nameInf.isUsedAfterReferences()) {
+                                       usedAfter.add(nameInf);
+                                       nameInf.setReference(true);
+                               }
+                       }
+               }
+
+               return usedAfter;
+       }
+
+       public ArrayList<NameInformation> getAllAfterUsedNamesChoosenByUser() {
+               ArrayList<IASTName> declarations = new ArrayList<IASTName>();
+               ArrayList<NameInformation> usedAfter = new ArrayList<NameInformation>();
+
+               for (NameInformation nameInf : names) {
+                       if (!declarations.contains(nameInf.getDeclaration())) {
+
+                               declarations.add(nameInf.getDeclaration());
+                               if (nameInf.isUserSetIsReference() || nameInf.isUserSetIsReturnValue()) {
+                                       usedAfter.add(nameInf);
+                               }
+                       }
+               }
+
+               return usedAfter;
+       }
+
+       public ArrayList<NameInformation> getUsedNamesUnique() {
+               ArrayList<IASTName> declarations = new ArrayList<IASTName>();
+               ArrayList<NameInformation> usedAfter = new ArrayList<NameInformation>();
+
+               if (names.size() <= 0) {
+                       findAllNames();
+               }
+
+               for (NameInformation nameInf : names) {
+                       if (!declarations.contains(nameInf.getDeclaration())) {
+                               declarations.add(nameInf.getDeclaration());
+                               usedAfter.add(nameInf);
+                       } else {
+                               for (NameInformation nameInformation : usedAfter) {
+                                       if (nameInf.isWriteAccess()
+                                                       && nameInf.getDeclaration() == nameInformation.getDeclaration()) {
+                                               nameInformation.setWriteAccess(true);
+                                       }
+                               }
+                       }
+               }
+
+               return usedAfter;
+       }
+
+       /*
+        * Returns all local names in the selection which will be used after the
+        * selection expected the ones which are pointers
+        * XXX Was soll dieser Kommentar aussagen? --Mirko
+        */
+       public ArrayList<NameInformation> getAllDeclaredInScope() {
+               ArrayList<IASTName> declarations = new ArrayList<IASTName>();
+               ArrayList<NameInformation> usedAfter = new ArrayList<NameInformation>();
+
+               for (NameInformation nameInf : names) {
+                       if (nameInf.isDeclarationInScope()
+                                       && !declarations.contains(nameInf.getDeclaration()) && nameInf.isUsedAfterReferences()) {
+                               declarations.add(nameInf.getDeclaration());
+                               usedAfter.add(nameInf);
+                               // is return value candidate, set return value to true and reference to false
+                               nameInf.setReturnValue(true);
+                               nameInf.setReference(false);
+                       }
+               }
+
+               return usedAfter;
+       }
+
+       public List<IASTNode> getNodesToWrite() {
+               return vec;
+       }
+
+       public int getStartOffset() {
+               return getOffset(false);
+       }
+
+       public int getStartOffsetIncludingComments() {
+               return getOffset(true);
+       }
+
+       private int getOffset(boolean includeComments) {
+               int start = Integer.MAX_VALUE;
+
+               for (IASTNode node : vec) {
+                       int nodeStart = Integer.MAX_VALUE;
+
+                       IASTNodeLocation[] nodeLocations = node.getNodeLocations();
+                       if (nodeLocations.length != 1) {
+                               for (IASTNodeLocation location : nodeLocations) {
+                                       int nodeOffset;
+                                       if (location instanceof IASTMacroExpansionLocation) {
+                                               IASTMacroExpansionLocation macroLoc = (IASTMacroExpansionLocation) location;
+                                               nodeOffset = macroLoc.asFileLocation().getNodeOffset();
+                                       } else {
+                                               nodeOffset = node.getFileLocation().getNodeOffset();
+                                       }
+                                       if (nodeOffset <  nodeStart) {
+                                               nodeStart = nodeOffset;
+                                       }
+                               }
+                       } else {
+                               nodeStart = node.getFileLocation().getNodeOffset();
+                       }
+                       if (nodeStart < start) {
+                               start = nodeStart;
+                       }
+               }
+
+               return start;
+       }
+
+       public int getEndOffset() {
+               return getEndOffset(false);
+       }
+       
+       public int getEndOffsetIncludingComments() {
+               return getEndOffset(true);
+       }
+
+       private int getEndOffset(boolean includeComments) {
+               int end = 0;
+
+               for (IASTNode node : vec) {
+                       int fileOffset = 0;
+                       int length = 0;
+
+                       IASTNodeLocation[] nodeLocations = node.getNodeLocations();
+                       for (IASTNodeLocation location : nodeLocations) {
+                               int nodeOffset, nodeLength;
+                               if (location instanceof IASTMacroExpansionLocation) {
+                                       IASTMacroExpansionLocation macroLoc = (IASTMacroExpansionLocation) location;
+                                       nodeOffset = macroLoc.asFileLocation().getNodeOffset();
+                                       nodeLength = macroLoc.asFileLocation().getNodeLength();
+                               } else {
+                                       nodeOffset = location.getNodeOffset();
+                                       nodeLength = location.getNodeLength();
+                               }
+                               if (fileOffset < nodeOffset) {
+                                       fileOffset = nodeOffset;
+                                       length = nodeLength;
+                               }
+                       }
+                       int endNode = fileOffset + length;
+                       if (endNode > end) {
+                               end = endNode;
+                       }
+               }
+
+               return end;
+       }
+
+       @Override
+       public String toString() {
+               return vec.toString();
+       }
+
+       public List<NameInformation> getNames() {
+               return names;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringASTCache.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringASTCache.java
new file mode 100644 (file)
index 0000000..1b56aa3
--- /dev/null
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 Google, Inc and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *        Sergey Prigogin (Google) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.ui.services.IDisposable;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.corext.util.CModelUtil;
+
+import org.eclipse.cdt.internal.ui.editor.ASTProvider;
+
+/**
+ * Cache containing ASTs for the translation units participating in refactoring.
+ * The cache object has to be disposed of after use. Failure to do so may cause
+ * loss of index lock.
+ * <p>
+ * This class is not thread-safe.
+ */
+public class RefactoringASTCache implements IDisposable {
+       private static final int PARSE_MODE = ITranslationUnit.AST_SKIP_ALL_HEADERS
+                       | ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT
+                       | ITranslationUnit.AST_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS
+                       | ITranslationUnit.AST_PARSE_INACTIVE_CODE;
+
+       private final Map<ITranslationUnit, IASTTranslationUnit> fASTCache;
+       private IIndex fIndex;
+       private IASTTranslationUnit fSharedAST;
+       private boolean fDisposed;
+
+       public RefactoringASTCache() {
+               fASTCache = new ConcurrentHashMap<ITranslationUnit, IASTTranslationUnit>();
+       }
+
+       /**
+        * Returns an AST for the given translation unit. The AST is built for the working
+        * copy of the translation unit if such working copy exists. The returned AST is
+        * a shared one whenever possible.
+        * <p>
+        * An AST returned by this method should not be accessed concurrently by multiple threads.
+        * <p>
+        * <b>NOTE</b>: No references to the AST or its nodes can be kept after calling
+        * the {@link #dispose()} method.
+        *
+        * @param tu The translation unit.
+        * @param pm A progress monitor.
+        * @return An AST, or <code>null</code> if the AST cannot be obtained.
+        */
+       public IASTTranslationUnit getAST(ITranslationUnit tu, IProgressMonitor pm)
+                       throws CoreException, OperationCanceledException {
+        Assert.isTrue(!fDisposed, "RefactoringASTCache is already disposed"); //$NON-NLS-1$
+        getIndex();  // Make sure the index is locked.
+               if (pm != null && pm.isCanceled())
+                       throw new OperationCanceledException();
+
+               tu= CModelUtil.toWorkingCopy(tu);
+       // Try to get a shared AST before creating our own.
+       IASTTranslationUnit ast= fASTCache.get(tu);
+       if (ast == null) {
+               if (fSharedAST != null && tu.equals(fSharedAST.getOriginatingTranslationUnit())) {
+                       ast = fSharedAST;
+               } else {
+                       ast = ASTProvider.getASTProvider().acquireSharedAST(tu, fIndex,
+                                       ASTProvider.WAIT_ACTIVE_ONLY, pm);
+                       if (ast == null) {
+                                       if (pm != null && pm.isCanceled())
+                                               throw new OperationCanceledException();
+                                       ast= tu.getAST(fIndex, PARSE_MODE);
+                               fASTCache.put(tu, ast);
+                       } else {
+                               if (fSharedAST != null) {
+                                       ASTProvider.getASTProvider().releaseSharedAST(fSharedAST);
+                               }
+                               fSharedAST = ast;
+                       }
+               }
+       }
+        if (pm != null) {
+               pm.done();
+        }
+               return ast;
+    }
+
+       /**
+        * Returns the index that can be safely used for reading until the cache is disposed.
+        * 
+        * @return The index.
+        */
+       public IIndex getIndex() throws CoreException, OperationCanceledException {
+        Assert.isTrue(!fDisposed, "RefactoringASTCache is already disposed"); //$NON-NLS-1$
+               if (fIndex == null) {
+                       ICProject[] projects = CoreModel.getDefault().getCModel().getCProjects();
+                       IIndex index = CCorePlugin.getIndexManager().getIndex(projects);
+                       try {
+                               index.acquireReadLock();
+                       } catch (InterruptedException e) {
+                               throw new OperationCanceledException();
+                       }
+                       fIndex = index;
+               }
+               return fIndex;
+       }
+
+       /**
+        * @see IDisposable#dispose()
+        */
+       public void dispose() {
+        Assert.isTrue(!fDisposed, "RefactoringASTCache.dispose() called more than once"); //$NON-NLS-1$
+               fDisposed = true;
+               if (fSharedAST != null) {
+                       ASTProvider.getASTProvider().releaseSharedAST(fSharedAST);
+               }
+               if (fIndex != null) {
+                       fIndex.releaseReadLock();
+               }
+       }
+
+       @Override
+       protected void finalize() throws Throwable {
+               if (!fDisposed)
+                       CUIPlugin.logError("RefactoringASTCache was not disposed"); //$NON-NLS-1$
+               super.finalize();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringAvailabilityTester.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringAvailabilityTester.java
new file mode 100644 (file)
index 0000000..89e59ff
--- /dev/null
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+import org.eclipse.cdt.core.model.ICElement;
+
+/**
+ * Helper class to detect whether a certain refactoring can be enabled on
+ * a selection.
+ * <p>
+ * This class has been introduced to decouple actions from the refactoring code,
+ * in order not to eagerly load refactoring classes during action
+ * initialization.
+ * </p>
+ *
+ * @since 5.3
+ */
+public final class RefactoringAvailabilityTester {
+
+       public static boolean isRenameElementAvailable(ICElement element) {
+               return true;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringExecutionHelper.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringExecutionHelper.java
new file mode 100644 (file)
index 0000000..2e81f37
--- /dev/null
@@ -0,0 +1,225 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.runtime.jobs.IJobManager;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.Job;
+
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableContext;
+
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.PerformChangeOperation;
+import org.eclipse.ltk.core.refactoring.Refactoring;
+import org.eclipse.ltk.core.refactoring.RefactoringCore;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.ui.refactoring.RefactoringUI;
+import org.eclipse.osgi.util.NLS;
+
+import org.eclipse.cdt.internal.ui.actions.WorkbenchRunnableAdapter;
+
+/**
+ * A helper class to execute a refactoring. The class takes care of pushing the
+ * undo change onto the undo stack and folding editor edits into one editor
+ * undo object.
+ */
+public class RefactoringExecutionHelper {
+       private final Refactoring fRefactoring;
+       private final Shell fParent;
+       private final IRunnableContext fExecContext;
+       private final int fStopSeverity;
+       private final int fSaveMode;
+
+       private class Operation implements IWorkspaceRunnable {
+               public Change fChange;
+               public PerformChangeOperation fPerformChangeOperation;
+               private final boolean fForked;
+               private final boolean fForkChangeExecution;
+
+               public Operation(boolean forked, boolean forkChangeExecution) {
+                       fForked= forked;
+                       fForkChangeExecution= forkChangeExecution;
+        }
+
+               public void run(IProgressMonitor pm) throws CoreException {
+                       try {
+                               pm.beginTask("", fForked && !fForkChangeExecution ? 7 : 11); //$NON-NLS-1$
+                               pm.subTask(""); //$NON-NLS-1$
+
+                               final RefactoringStatus status= fRefactoring.checkAllConditions(new SubProgressMonitor(pm, 4, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
+                               if (status.getSeverity() >= fStopSeverity) {
+                                       final boolean[] canceled= { false };
+                                       if (fForked) {
+                                               fParent.getDisplay().syncExec(new Runnable() {
+                                                       public void run() {
+                                                               canceled[0]= showStatusDialog(status);
+                                                       }
+                                               });
+                                       } else {
+                                               canceled[0]= showStatusDialog(status);
+                                       }
+                                       if (canceled[0]) {
+                                               throw new OperationCanceledException();
+                                       }
+                               }
+
+                               fChange= fRefactoring.createChange(new SubProgressMonitor(pm, 2, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
+                               fChange.initializeValidationData(new SubProgressMonitor(pm, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
+
+                               fPerformChangeOperation= new PerformChangeOperation(fChange);//RefactoringUI.createUIAwareChangeOperation(fChange);
+                               fPerformChangeOperation.setUndoManager(RefactoringCore.getUndoManager(), fRefactoring.getName());
+                               if (fRefactoring instanceof IScheduledRefactoring)
+                                       fPerformChangeOperation.setSchedulingRule(((IScheduledRefactoring) fRefactoring).getSchedulingRule());
+
+                               if (!fForked || fForkChangeExecution)
+                                       fPerformChangeOperation.run(new SubProgressMonitor(pm, 4, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
+                       } finally {
+                               pm.done();
+                       }
+               }
+
+               /**
+                * @param status the status to show
+                * @return <code>true</code> iff the operation should be cancelled
+                */
+               private boolean showStatusDialog(RefactoringStatus status) {
+                       Dialog dialog= RefactoringUI.createRefactoringStatusDialog(status, fParent, fRefactoring.getName(), false);
+                       return dialog.open() == IDialogConstants.CANCEL_ID;
+               }
+       }
+
+       /**
+        * Creates a new refactoring execution helper.
+        *
+        * @param refactoring the refactoring
+        * @param stopSeverity a refactoring status constant from {@link RefactoringStatus}
+        * @param saveMode a save mode from {@link RefactoringSaveHelper}
+        * @param parent the parent shell
+        * @param context the runnable context
+        */
+       public RefactoringExecutionHelper(Refactoring refactoring, int stopSeverity, int saveMode, Shell parent,
+                       IRunnableContext context) {
+               super();
+               Assert.isNotNull(refactoring);
+               Assert.isNotNull(parent);
+               Assert.isNotNull(context);
+               fRefactoring= refactoring;
+               fStopSeverity= stopSeverity;
+               fParent= parent;
+               fExecContext= context;
+               fSaveMode= saveMode;
+       }
+
+       /**
+        * Must be called in the UI thread.
+        * @param fork if set, the operation will be forked
+        * @param cancelable  if set, the operation will be cancelable
+        * @throws InterruptedException thrown when the operation is canceled
+        * @throws InvocationTargetException thrown when the operation failed to execute
+        */
+       public void perform(boolean fork, boolean cancelable) throws InterruptedException, InvocationTargetException {
+               perform(fork, false, cancelable);
+       }
+
+       /**
+        * Must be called in the UI thread.<br>
+        * <strong>Use {@link #perform(boolean, boolean)} unless you know exactly what you are doing!</strong>
+        *
+        * @param fork if set, the operation will be forked
+        * @param forkChangeExecution if the change should not be executed in the UI thread: This may not work in any case
+        * @param cancelable  if set, the operation will be cancelable
+        * @throws InterruptedException thrown when the operation is canceled
+        * @throws InvocationTargetException thrown when the operation failed to execute
+        */
+       public void perform(boolean fork, boolean forkChangeExecution, boolean cancelable) throws InterruptedException, InvocationTargetException {
+               Assert.isTrue(Display.getCurrent() != null);
+               final IJobManager manager= Job.getJobManager();
+               final ISchedulingRule rule;
+               if (fRefactoring instanceof IScheduledRefactoring) {
+                       rule= ((IScheduledRefactoring) fRefactoring).getSchedulingRule();
+               } else {
+                       rule= ResourcesPlugin.getWorkspace().getRoot();
+               }
+               try {
+                       try {
+                               Runnable r= new Runnable() {
+                                       public void run() {
+                                               manager.beginRule(rule, null);
+                                       }
+                               };
+                               BusyIndicator.showWhile(fParent.getDisplay(), r);
+                       } catch (OperationCanceledException e) {
+                               throw new InterruptedException(e.getMessage());
+                       }
+
+                       RefactoringSaveHelper saveHelper= new RefactoringSaveHelper(fSaveMode);
+                       if (!saveHelper.saveEditors(fParent))
+                               throw new InterruptedException();
+                       final Operation op= new Operation(fork, forkChangeExecution);
+                       fRefactoring.setValidationContext(fParent);
+                       try {
+                               fExecContext.run(fork, cancelable, new WorkbenchRunnableAdapter(op, rule, true));
+                               if (fork && !forkChangeExecution && op.fPerformChangeOperation != null)
+                                       fExecContext.run(false, false, new WorkbenchRunnableAdapter(op.fPerformChangeOperation, rule, true));
+
+                               if (op.fPerformChangeOperation != null) {
+                                       RefactoringStatus validationStatus= op.fPerformChangeOperation.getValidationStatus();
+                                       if (validationStatus != null && validationStatus.hasFatalError()) {
+                                               MessageDialog.openError(fParent, fRefactoring.getName(),
+                                                               NLS.bind(Messages.RefactoringExecutionHelper_cannot_execute,
+                                                                               validationStatus.getMessageMatchingSeverity(RefactoringStatus.FATAL)));
+                                               throw new InterruptedException();
+                                       }
+                               }
+                       } catch (InvocationTargetException e) {
+                               PerformChangeOperation pco= op.fPerformChangeOperation;
+                               if (pco != null && pco.changeExecutionFailed()) {
+                                       ChangeExceptionHandler handler= new ChangeExceptionHandler(fParent, fRefactoring);
+                                       Throwable inner= e.getTargetException();
+                                       if (inner instanceof RuntimeException) {
+                                               handler.handle(pco.getChange(), (RuntimeException)inner);
+                                       } else if (inner instanceof CoreException) {
+                                               handler.handle(pco.getChange(), (CoreException)inner);
+                                       } else {
+                                               throw e;
+                                       }
+                               } else {
+                                       throw e;
+                               }
+                       } catch (OperationCanceledException e) {
+                               throw new InterruptedException(e.getMessage());
+                       } finally {
+                               saveHelper.triggerIncrementalBuild();
+                       }
+               } finally {
+                       manager.endRule(rule);
+                       fRefactoring.setValidationContext(null);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringRunner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringRunner.java
new file mode 100644 (file)
index 0000000..38cbefd
--- /dev/null
@@ -0,0 +1,46 @@
+/*******************************************************************************\r
+ * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik  \r
+ * Rapperswil, University of applied sciences and others\r
+ * All rights reserved. This program and the accompanying materials \r
+ * are made available under the terms of the Eclipse Public License v1.0 \r
+ * which accompanies this distribution, and is available at \r
+ * http://www.eclipse.org/legal/epl-v10.html  \r
+ *  \r
+ * Contributors: \r
+ * Institute for Software - initial API and implementation\r
+ *******************************************************************************/\r
+package org.eclipse.cdt.internal.ui.refactoring;\r
+\r
+import org.eclipse.core.resources.IFile;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.jface.window.IShellProvider;\r
+\r
+import org.eclipse.cdt.core.model.ICElement;\r
+import org.eclipse.cdt.core.model.ICProject;\r
+\r
+/**\r
+ * Base class for all refactoring runners.\r
+ * \r
+ * @deprecated Use RefactoringRunner2.\r
+ * \r
+ * @author Emanuel Graf\r
+ */\r
+@Deprecated\r
+public abstract class RefactoringRunner {\r
+       protected IFile file;\r
+       protected ISelection selection;\r
+       protected ICElement celement;\r
+       protected IShellProvider shellProvider;\r
+       protected ICProject project;\r
+\r
+       public RefactoringRunner(IFile file, ISelection selection, ICElement element,\r
+                       IShellProvider shellProvider, ICProject cProject) {\r
+               this.file = file;\r
+               this.selection = selection;\r
+               this.celement= element;\r
+               this.shellProvider= shellProvider;\r
+               this.project = cProject;\r
+       }\r
+\r
+       public abstract void run();\r
+}\r
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringRunner2.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringRunner2.java
new file mode 100644 (file)
index 0000000..678114f
--- /dev/null
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Google, Inc and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *        Sergey Prigogin (Google) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.window.IShellProvider;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+
+/**
+ * Base class for all refactoring runners. This class is intended as a replacement
+ * for RefactoringRunner.
+ */
+public abstract class RefactoringRunner2 {
+       protected final ISelection selection;
+       protected final ICElement element;
+       protected final IShellProvider shellProvider;
+       protected final ICProject project;
+       protected final RefactoringStarter starter;
+
+       public RefactoringRunner2(ICElement element, ISelection selection, IShellProvider shellProvider,
+                       ICProject cProject) {
+               this.selection = selection;
+               this.element= element;
+               this.shellProvider= shellProvider;
+               this.project = cProject;
+               this.starter = new RefactoringStarter();
+       }
+
+       public final void run() {
+               RefactoringASTCache astCache = new RefactoringASTCache();
+               try {
+                       run(astCache);
+               } finally {
+                       astCache.dispose();
+               }
+       }
+
+       protected abstract void run(RefactoringASTCache astCache);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringSaveHelper.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringSaveHelper.java
new file mode 100644 (file)
index 0000000..fd07b08
--- /dev/null
@@ -0,0 +1,223 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.window.Window;
+
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.GlobalBuildAction;
+import org.eclipse.ui.dialogs.ListDialog;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
+
+/**
+ * Helper to save dirty editors prior to starting a refactoring.
+ * 
+ * @see PreferenceConstants#REFACTOR_SAVE_ALL_EDITORS
+ * @since 5.3
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class RefactoringSaveHelper {
+       private boolean fFilesSaved;
+       private final int fSaveMode;
+
+       /**
+        * Save mode to save all dirty editors (always ask).
+        */
+       public static final int SAVE_ALL_ALWAYS_ASK= 1;
+
+       /**
+        * Save mode to save all dirty editors.
+        */
+       public static final int SAVE_ALL= 2;
+
+       /**
+        * Save mode to not save any editors.
+        */
+       public static final int SAVE_NOTHING= 3;
+       
+       /**
+        * Save mode to save all editors that are known to cause trouble for C refactorings, e.g.
+        * editors on compilation units that are not in working copy mode.
+        */
+       public static final int SAVE_REFACTORING= 4;
+       
+       /**
+        * Creates a refactoring save helper with the given save mode.
+        * 
+        * @param saveMode one of the SAVE_* constants
+        */
+       public RefactoringSaveHelper(int saveMode) {
+               Assert.isLegal(saveMode == SAVE_ALL_ALWAYS_ASK
+                               || saveMode == SAVE_ALL
+                               || saveMode == SAVE_NOTHING
+                               || saveMode == SAVE_REFACTORING);
+               fSaveMode= saveMode;
+       }
+
+       /**
+        * Saves all editors. Depending on the {@link PreferenceConstants#REFACTOR_SAVE_ALL_EDITORS}
+        * preference, the user is asked to save affected dirty editors.
+        * 
+        * @param shell the parent shell for the confirmation dialog
+        * @return <code>true</code> if save was successful and refactoring can proceed;
+        *              false if the refactoring must be canceled
+        */
+       public boolean saveEditors(Shell shell) {
+               final IEditorPart[] dirtyEditors;
+               switch (fSaveMode) {
+                       case SAVE_ALL_ALWAYS_ASK:
+                       case SAVE_ALL:
+                               dirtyEditors= EditorUtility.getDirtyEditors(true);
+                               break;
+
+                       case SAVE_REFACTORING:
+                               dirtyEditors= EditorUtility.getDirtyEditorsToSave(false); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=175495
+                               break;
+
+                       case SAVE_NOTHING:
+                               return true;
+
+                       default:
+                               throw new IllegalStateException(Integer.toString(fSaveMode));
+               }
+               if (dirtyEditors.length == 0)
+                       return true;
+               if (!askSaveAllDirtyEditors(shell, dirtyEditors))
+                       return false;
+               // Save isn't cancelable.
+               if (fSaveMode == SAVE_ALL_ALWAYS_ASK || fSaveMode == SAVE_ALL
+                               || RefactoringSavePreferences.getSaveAllEditors()) {
+                       if (!CUIPlugin.getActiveWorkbenchWindow().getWorkbench().saveAllEditors(false))
+                               return false;
+               } else {
+                       IRunnableWithProgress runnable= new IRunnableWithProgress() {
+                               public void run(IProgressMonitor pm) throws InterruptedException {
+                                       int count= dirtyEditors.length;
+                                       pm.beginTask("", count); //$NON-NLS-1$
+                                       for (int i= 0; i < count; i++) {
+                                               IEditorPart editor= dirtyEditors[i];
+                                               editor.doSave(new SubProgressMonitor(pm, 1));
+                                               if (pm.isCanceled())
+                                                       throw new InterruptedException();
+                                       }
+                                       pm.done();
+                               }
+                       };
+                       try {
+                               PlatformUI.getWorkbench().getProgressService().runInUI(CUIPlugin.getActiveWorkbenchWindow(), runnable, null);
+                       } catch (InterruptedException e) {
+                               return false;
+                       } catch (InvocationTargetException e) {
+                               ExceptionHandler.handle(e, shell,
+                                               Messages.RefactoringSaveHelper_saving, Messages.RefactoringSaveHelper_unexpected_exception);
+                               return false;
+                       }
+               }
+               fFilesSaved= true;
+               return true;
+       }
+
+       /**
+        * Triggers an incremental build if this save helper did save files before.
+        */
+       public void triggerIncrementalBuild() {
+               if (fFilesSaved && ResourcesPlugin.getWorkspace().getDescription().isAutoBuilding()) {
+                       new GlobalBuildAction(CUIPlugin.getActiveWorkbenchWindow(), IncrementalProjectBuilder.INCREMENTAL_BUILD).run();
+               }
+       }
+
+       /**
+        * Returns whether this save helper did actually save any files.
+        * 
+        * @return <code>true</code> iff files have been saved
+        */
+       public boolean didSaveFiles() {
+               return fFilesSaved;
+       }
+       
+       private boolean askSaveAllDirtyEditors(Shell shell, IEditorPart[] dirtyEditors) {
+               final boolean canSaveAutomatically= fSaveMode != SAVE_ALL_ALWAYS_ASK;
+               if (canSaveAutomatically && RefactoringSavePreferences.getSaveAllEditors()) //must save everything
+                       return true;
+               ListDialog dialog= new ListDialog(shell) {
+                       {
+                               setShellStyle(getShellStyle() | SWT.APPLICATION_MODAL);
+                       }
+                       @Override
+                       protected Control createDialogArea(Composite parent) {
+                               Composite result= (Composite) super.createDialogArea(parent);
+                               if (canSaveAutomatically) {
+                                       final Button check= new Button(result, SWT.CHECK);
+                                       check.setText(Messages.RefactoringSaveHelper_always_save);
+                                       check.setSelection(RefactoringSavePreferences.getSaveAllEditors());
+                                       check.addSelectionListener(new SelectionAdapter() {
+                                               @Override
+                                               public void widgetSelected(SelectionEvent e) {
+                                                       RefactoringSavePreferences.setSaveAllEditors(check.getSelection());
+                                               }
+                                       });
+                                       applyDialogFont(result);
+                               }
+                               return result;
+                       }
+               };
+               dialog.setTitle(Messages.RefactoringSaveHelper_save_all_resources);
+               dialog.setLabelProvider(createDialogLabelProvider());
+               dialog.setMessage(Messages.RefactoringSaveHelper_must_save);
+               dialog.setContentProvider(new ArrayContentProvider());
+               dialog.setInput(Arrays.asList(dirtyEditors));
+               return dialog.open() == Window.OK;
+       }
+
+       private ILabelProvider createDialogLabelProvider() {
+               return new LabelProvider() {
+                       @Override
+                       public Image getImage(Object element) {
+                               return ((IEditorPart) element).getTitleImage();
+                       }
+                       @Override
+                       public String getText(Object element) {
+                               return ((IEditorPart) element).getTitle();
+                       }
+               };
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringSavePreferences.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringSavePreferences.java
new file mode 100644 (file)
index 0000000..d883f4d
--- /dev/null
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+public class RefactoringSavePreferences {
+       public static final String PREF_SAVE_ALL_EDITORS= PreferenceConstants.REFACTOR_SAVE_ALL_EDITORS;
+
+       public static boolean getSaveAllEditors() {
+               IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+               return store.getBoolean(PREF_SAVE_ALL_EDITORS);
+       }
+
+       public static void setSaveAllEditors(boolean save) {
+               IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+               store.setValue(PREF_SAVE_ALL_EDITORS, save);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringStarter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringStarter.java
new file mode 100644 (file)
index 0000000..e719c4d
--- /dev/null
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
+
+/**
+ * A helper class to activate the UI of a refactoring
+ */
+public class RefactoringStarter {
+       private RefactoringStatus fStatus;
+
+       public boolean activate(RefactoringWizard wizard, Shell parent, String dialogTitle, int saveMode) {
+               RefactoringSaveHelper saveHelper= new RefactoringSaveHelper(saveMode);
+               if (!canActivate(saveHelper, parent))
+                       return false;
+
+               try {
+                       RefactoringWizardOpenOperation op= new RefactoringWizardOpenOperation(wizard);
+                       int result= op.run(parent, dialogTitle);
+                       fStatus= op.getInitialConditionCheckingStatus();
+                       if (result == IDialogConstants.CANCEL_ID || result == RefactoringWizardOpenOperation.INITIAL_CONDITION_CHECKING_FAILED) {
+                               saveHelper.triggerIncrementalBuild();
+                               return false;
+                       } else {
+                               return true;
+                       }
+               } catch (InterruptedException e) {
+                       return false; // User action got canceled
+               }
+       }
+
+       public RefactoringStatus getInitialConditionCheckingStatus() {
+               return fStatus;
+       }
+
+       private boolean canActivate(RefactoringSaveHelper saveHelper, Shell shell) {
+               return saveHelper.saveEditors(shell);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/UndoCTextFileChange.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/UndoCTextFileChange.java
new file mode 100644 (file)
index 0000000..c2a0f00
--- /dev/null
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ *  Copyright (c) 2006, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *    IBM Corporation - Initial API and implementation
+ *    Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.ContentStamp;
+import org.eclipse.ltk.core.refactoring.UndoTextFileChange;
+import org.eclipse.text.edits.MalformedTreeException;
+import org.eclipse.text.edits.TextEdit;
+import org.eclipse.text.edits.UndoEdit;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.IBuffer;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.model.TranslationUnit;
+
+/**
+ * UndoCTextFileChange that uses a working copy in order to generate CModel events. 
+ * @author janees
+ */
+public class UndoCTextFileChange
+    extends UndoTextFileChange {
+    
+    UndoEdit mUndoEdit = null;
+
+    public UndoCTextFileChange(String name, IFile file, UndoEdit undo, ContentStamp stamp, int saveMode) {
+        super(name, file, undo, stamp, saveMode);
+        mUndoEdit = undo;
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.ltk.core.refactoring.UndoTextFileChange#perform(org.eclipse.core.runtime.IProgressMonitor)
+     */
+    @Override
+       public Change perform(IProgressMonitor pm)
+        throws CoreException {
+        if (pm == null){
+            pm= new NullProgressMonitor();
+        }
+        Object obj = getModifiedElement();
+        if(!(obj instanceof IFile)){
+            throw new IllegalArgumentException();
+        }
+        final IFile file = (IFile) obj;
+        ICElement element = CoreModel.getDefault().create(file);
+        if (!(element instanceof TranslationUnit)) {
+            return super.perform(pm);
+        }
+
+        final TranslationUnit tu = (TranslationUnit) element;
+        IWorkingCopy wc= tu.getWorkingCopy(pm, DocumentAdapter.FACTORY);
+        final IBuffer buffer= wc.getBuffer();
+        assert buffer instanceof DocumentAdapter;
+        if (buffer instanceof DocumentAdapter) {
+               IDocument document= ((DocumentAdapter) buffer).getDocument();
+               try {
+                       UndoEdit redo= mUndoEdit.apply(document, TextEdit.CREATE_UNDO);
+                       wc.commit(false, pm);
+                       return new UndoCTextFileChange(getName(), file, redo, null, getSaveMode());
+               } catch (MalformedTreeException e) {
+                       CUIPlugin.log(e);
+               } catch (BadLocationException e) {
+                       CUIPlugin.log(e);
+               }
+               finally {
+                       wc.destroy();
+               }
+        }
+        return null;
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Visibility.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/Visibility.java
new file mode 100644 (file)
index 0000000..5c17dff
--- /dev/null
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring;
+
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
+
+/**
+ * Represents the visibility of an IASTName.
+ * 
+ */
+public class Visibility {
+
+       /**
+        * The visibility public.
+        */
+       public static final Visibility PUBLIC = new Visibility(){
+               @Override
+               public String stringValue(){
+                       return "public"; //$NON-NLS-1$
+               }
+       };
+       
+       /**
+        * The visibility protected.
+        */
+       public static final Visibility PROTECTED = new Visibility(){
+               @Override
+               public String stringValue(){
+                       return "protected"; //$NON-NLS-1$
+               }
+       };
+       
+       /**
+        * The visibility private.
+        */
+       public static final Visibility PRIVATE = new Visibility(){
+               @Override
+               public String stringValue(){
+                       return "private"; //$NON-NLS-1$
+               }
+       };
+       
+       /**
+        * The visibility unknown, cause of parsing error.
+        */
+       public static final Visibility UNKNOWN = new Visibility(){ };
+       
+       private Visibility(){}
+       
+       public static Visibility getVisibility(IASTName name){
+               try {
+                       ICPPMember member = ((ICPPMember)name.resolveBinding());                        
+                       
+                       switch (member.getVisibility()){
+                               case ICPPASTVisibilityLabel.v_public:
+                                       return PUBLIC;
+                               case ICPPASTVisibilityLabel.v_protected:
+                                       return PROTECTED;
+                               case ICPPASTVisibilityLabel.v_private:
+                                       return PRIVATE;
+                               default:
+                                       return UNKNOWN;
+                       }
+                       
+               } catch (RuntimeException e){
+                       return UNKNOWN;
+               }
+       }
+       
+       public String stringValue(){
+               return ""; //$NON-NLS-1$
+       }
+
+       @Override
+       public String toString() {
+               return stringValue();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/CTextEditChangePreviewViewer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/CTextEditChangePreviewViewer.java
new file mode 100644 (file)
index 0000000..368e54a
--- /dev/null
@@ -0,0 +1,264 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *    Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.dialogs;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.CompareViewerPane;
+import org.eclipse.compare.IEncodedStreamContentAccessor;
+import org.eclipse.compare.IResourceProvider;
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.compare.contentmergeviewer.IMergeViewerContentProvider;
+import org.eclipse.compare.structuremergeviewer.DiffNode;
+import org.eclipse.compare.structuremergeviewer.ICompareInput;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.TextViewer;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.ui.refactoring.ChangePreviewViewerInput;
+import org.eclipse.ltk.ui.refactoring.IChangePreviewViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+import org.eclipse.cdt.ui.CElementLabelProvider;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.refactoring.CTextFileChange;
+import org.eclipse.cdt.ui.text.CSourceViewerConfiguration;
+
+import org.eclipse.cdt.internal.ui.compare.CMergeViewer;
+import org.eclipse.cdt.internal.ui.text.CTextTools;
+
+/**
+ * @author Emanuel Graf
+ *
+ */
+public class CTextEditChangePreviewViewer  implements IChangePreviewViewer {
+       
+       private CPPMergeViewer viewer;
+       private CTextEditChangePane viewerPane;
+       private CTextEditChangePreviewViewerContentProvider textEditChangeContentProvider;
+       
+       private static class CTextEditChangePane extends CompareViewerPane{
+
+               /**
+                * @param parent
+                * @param style
+                */
+               public CTextEditChangePane(Composite parent, int style) {
+                       super(parent, style);
+               }
+               
+       }
+       
+       private class CPPMergeViewer extends CMergeViewer{
+
+               /**
+                * @param parent
+                * @param styles
+                * @param mp
+                */
+               public CPPMergeViewer(Composite parent, int styles, CompareConfiguration mp) {
+                       super(parent, styles, mp);
+               }
+
+               @Override
+               protected CSourceViewerConfiguration getSourceViewerConfiguration() {
+                       CTextTools tools= CUIPlugin.getDefault().getTextTools();
+                       IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
+                       return new CSourceViewerConfiguration(tools.getColorManager(), store, null, tools.getDocumentPartitioning());
+               }
+
+               @Override
+               protected void configureTextViewer(TextViewer textViewer) {
+                       if (textViewer instanceof SourceViewer) {
+                               ((SourceViewer)textViewer).configure(getSourceViewerConfiguration());
+                       }
+               }
+               
+               
+       }
+
+       
+       private class CTextEditChangePreviewViewerContentProvider implements IMergeViewerContentProvider{
+
+               public Object getAncestorContent(Object input) {
+                       if (input instanceof ICompareInput)
+                               return ((ICompareInput) input).getAncestor();
+                       return null;
+               }
+
+               public Image getAncestorImage(Object input) {
+                       if (input instanceof ICompareInput) {
+                               ITypedElement ancestor = ((ICompareInput) input).getAncestor();
+                               if(ancestor != null) {
+                                       return ancestor.getImage();
+                               }
+                       }
+                       return null;
+               }
+
+               public String getAncestorLabel(Object input) {
+                       if (input instanceof ICompareInput) {
+                               ITypedElement ancestor = ((ICompareInput) input).getAncestor();
+                               if(ancestor != null) {
+                                       return ancestor.getName();
+                               }
+                       }
+                       return null;
+               }
+
+               public Object getLeftContent(Object input) {
+                       if (input instanceof ICompareInput)
+                               return ((ICompareInput) input).getLeft();
+                       return null;
+               }
+
+               public Image getLeftImage(Object input) {
+                       if (input instanceof ICompareInput)
+                               return ((ICompareInput) input).getLeft().getImage();
+                       return null;
+               }
+
+               public String getLeftLabel(Object input) {
+                       return Messages.CTextEditChangePreviewViewer_OrgSource; 
+               }
+
+               public Object getRightContent(Object input) {
+                       if (input instanceof ICompareInput)
+                               return ((ICompareInput) input).getRight();
+                       return null;
+               }
+
+               public Image getRightImage(Object input) {
+                       if (input instanceof ICompareInput)
+                               return ((ICompareInput) input).getRight().getImage();
+                       return null;
+               }
+
+               public String getRightLabel(Object input) {
+                       return Messages.CTextEditChangePreviewViewer_RefactoredSource; 
+               }
+
+               public boolean isLeftEditable(Object input) {
+                       return false;
+               }
+
+               public boolean isRightEditable(Object input) {
+                       return false;
+               }
+
+               public void saveLeftContent(Object input, byte[] bytes) {
+                       //No Edits
+               }
+
+               public void saveRightContent(Object input, byte[] bytes) {
+                       //No Edits
+               }
+
+               public boolean showAncestor(Object input) {
+                       //no Ancestor
+                       return false;
+               }
+
+               public void dispose() {
+                       //
+               }
+
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+                       //Nothing to do
+               }
+               
+       }
+       
+       private static class CompareElement implements ITypedElement, IEncodedStreamContentAccessor, IResourceProvider {
+               private static final String ENCODING= "UTF-8"; //$NON-NLS-1$
+               private final String fContent;
+               private final String fType;
+               private final IResource fResource;
+               public CompareElement(String content, String type, IResource resource) {
+                       fContent= content;
+                       fType= type;
+                       fResource= resource;
+               }
+               public String getName() {
+                       return ""; //$NON-NLS-1$
+               }
+               public Image getImage() {
+                       return null;
+               }
+               public String getType() {
+                       return fType;
+               }
+               public InputStream getContents() throws CoreException {
+                       try {
+                               return new ByteArrayInputStream(fContent.getBytes(ENCODING));
+                       } catch (UnsupportedEncodingException e) {
+                               return new ByteArrayInputStream(fContent.getBytes());
+                       }
+               }
+               public String getCharset() {
+                       return ENCODING;
+               }
+               public IResource getResource() {
+                       return fResource;
+               }
+       }
+
+       public void createControl(Composite parent) {
+               CompareConfiguration compConfig = new CompareConfiguration();
+               compConfig.setLeftEditable(false);
+               compConfig.setRightEditable(false);
+               viewerPane = new CTextEditChangePane(parent, SWT.BORDER | SWT.FLAT);
+               viewer =  new CPPMergeViewer(viewerPane,SWT.MULTI | SWT.FULL_SELECTION, compConfig);
+               textEditChangeContentProvider = new CTextEditChangePreviewViewerContentProvider();
+               viewer.setContentProvider(textEditChangeContentProvider);
+               viewerPane.setContent(viewer.getControl());
+       }
+
+       public Control getControl() {
+               return viewerPane;
+       }
+
+       public void setInput(ChangePreviewViewerInput input) {
+               try {
+                       Change change= input.getChange();
+                       if (change instanceof CTextFileChange) {
+                               CTextFileChange editChange= (CTextFileChange)change;
+                               setInput(editChange, editChange.getCurrentContent(new NullProgressMonitor()), editChange.getPreviewContent(new NullProgressMonitor()), editChange.getTextType());
+                               return;
+                       }
+                       viewer.setInput(null);
+               } catch (CoreException e) {
+                       viewer.setInput(null);
+               }
+       }
+
+       private void setInput(CTextFileChange change, String left, String right, String type) {
+               IFile resource = change.getFile();
+               viewerPane.setText(resource.getName());
+               viewerPane.setImage(new CElementLabelProvider().getImage(resource));
+               viewer.setInput(new DiffNode(
+                       new CompareElement(left, type, resource),
+                       new CompareElement(right, type, resource)));
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/CreateFileChangePreview.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/CreateFileChangePreview.java
new file mode 100644 (file)
index 0000000..200a4b0
--- /dev/null
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *    Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.dialogs;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.ui.refactoring.ChangePreviewViewerInput;
+import org.eclipse.ltk.ui.refactoring.IChangePreviewViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.CSourceViewerConfiguration;
+
+import org.eclipse.cdt.internal.ui.editor.CSourceViewer;
+import org.eclipse.cdt.internal.ui.refactoring.CreateFileChange;
+import org.eclipse.cdt.internal.ui.text.CTextTools;
+import org.eclipse.cdt.internal.ui.util.ViewerPane;
+
+/**
+ * @author Emanuel Graf
+ *
+ */
+public class CreateFileChangePreview implements IChangePreviewViewer {
+       
+       private static class CreateFileChangePane extends ViewerPane{
+
+               /**
+                * @param parent
+                * @param style
+                */
+               public CreateFileChangePane(Composite parent, int style) {
+                       super(parent, style);
+               }
+               
+       }
+       
+       private CreateFileChangePane control;
+       private SourceViewer srcViewer;
+       private CTextTools textTools;
+       
+       public void createControl(Composite parent) {
+               control =  new CreateFileChangePane(parent, SWT.BORDER | SWT.FLAT);
+               Dialog.applyDialogFont(control);
+               srcViewer= new CSourceViewer(control, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.FULL_SELECTION, CUIPlugin.getDefault().getPreferenceStore());
+               textTools = CUIPlugin.getDefault().getTextTools();
+               IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
+               CSourceViewerConfiguration sourceViewerConfiguration = new CSourceViewerConfiguration(textTools.getColorManager(), store, null, textTools.getDocumentPartitioning());
+               srcViewer.configure(sourceViewerConfiguration);
+               srcViewer.setEditable(false);
+               control.setContent(srcViewer.getControl());
+       }
+
+       public Control getControl() {
+               return control;
+       }
+
+       public void setInput(ChangePreviewViewerInput input) {
+               Assert.isNotNull(input);
+               if(control != null) {
+                       Change change = input.getChange();
+                       if (change instanceof CreateFileChange) {
+                               CreateFileChange createFileChange = (CreateFileChange) change;
+                               control.setText(createFileChange.getName());
+                               Document document = new Document(createFileChange.getSource());
+                               textTools.setupCDocument(document);
+                               srcViewer.setDocument(document);
+                       }
+               }
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/ExtractInputPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/ExtractInputPage.java
new file mode 100644 (file)
index 0000000..fe52f91
--- /dev/null
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *    Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.dialogs;
+
+
+import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+import org.eclipse.cdt.internal.ui.refactoring.NameNVisibilityInformation;
+import org.eclipse.cdt.internal.ui.refactoring.utils.IdentifierHelper;
+import org.eclipse.cdt.internal.ui.refactoring.utils.IdentifierResult;
+import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
+
+/**
+ * Holds a NameAndVisibilityComposite and deals with the extract refactoring
+ * specific implementation and propagates the inputs made in the wizard ui back
+ * to the refactoring via the NameNVisibilityInformation object.
+ *     
+ * @author Emanuel Graf
+ */
+public abstract class ExtractInputPage extends UserInputWizardPage {
+
+       protected NameAndVisibilityComposite control;
+       protected NameNVisibilityInformation info;
+       protected String label = Messages.ExtractInputPage_ReplaceInSubclass; 
+       protected String errorLabel = Messages.ExtractInputPage_EnterName; 
+
+       public ExtractInputPage(String name, NameNVisibilityInformation info) {
+               super(name);
+               this.info = info;
+       }
+
+       public void createControl(Composite parent) {
+               control = new NameAndVisibilityComposite(parent, label, info.getName());
+               setTitle(getName());
+               setPageComplete(false);
+               control.getConstantNameText().addModifyListener(new ModifyListener() {
+       
+                       public void modifyText(ModifyEvent e) {
+                               info.setName(control.getConstantNameText().getText());
+                               checkName();
+                       }
+                       
+               });
+               
+               for (Control buttons : control.getVisibiltyGroup().getChildren()) {
+                       buttons.addMouseListener(new MouseAdapter() {
+       
+                               @Override
+                               public void mouseUp(MouseEvent e) {
+                                       String text = ((Button)e.getSource()).getText();
+                                       visibilityChange(text);
+                               }
+                               
+                       });
+               }
+
+               checkName();
+               setControl(control);
+       }
+
+       protected void checkName() {
+               String methodName = control.getConstantNameText().getText();
+               IdentifierResult result = IdentifierHelper.checkIdentifierName(methodName);
+               if(result.isCorrect()){
+                       setErrorMessage(null);
+                       setPageComplete(true);
+                       verifyName(methodName);
+               }
+               else{
+                       setErrorMessage(NLS.bind(Messages.ExtractInputPage_CheckName, result.getMessage())); 
+                       setPageComplete(false);
+               }
+       }
+       
+       abstract protected void verifyName(String name);
+
+       protected void visibilityChange(String visibilityText) {
+               info.setVisibility(VisibilityEnum.getEnumForStringRepresentation(visibilityText));
+       } 
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/LabeledTextField.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/LabeledTextField.java
new file mode 100644 (file)
index 0000000..478fbba
--- /dev/null
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *    Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.dialogs;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * A text field with an associated label, displayed side-by-side.
+ *
+ * @author Mirko Stocker
+ *
+ */
+public class LabeledTextField extends Composite {
+       
+       private final Text textField;
+
+       public LabeledTextField(Composite parent, String labelName, String textContent) {
+               super(parent, SWT.NONE);
+               
+               GridLayout layout = new GridLayout();
+               layout.numColumns = 2;
+               layout.marginWidth = 0;
+               setLayout(layout);
+                               
+               Label label = new Label(this, SWT.NONE);
+               label.setText(labelName);
+               label.setLayoutData(new GridData());
+       
+               textField = new Text(this, SWT.BORDER |SWT.SINGLE);
+               textField.setText(textContent);
+               textField.selectAll();
+               GridData textData = new GridData(GridData.FILL_HORIZONTAL);             
+               textData.grabExcessHorizontalSpace = true;
+               textField.setLayoutData(textData);
+       }
+       
+       public LabeledTextField(Composite parent, String labelName)     {
+               this(parent, labelName, ""); //$NON-NLS-1$
+       }
+       
+       public Text getText()   {
+               return textField;
+       }
+
+       public String getFieldContent(){
+               return textField.getText();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/Messages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/Messages.java
new file mode 100644 (file)
index 0000000..93fa308
--- /dev/null
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *     Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.dialogs;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class Messages extends NLS {
+       public static String CTextEditChangePreviewViewer_OrgSource;
+       public static String CTextEditChangePreviewViewer_RefactoredSource;
+       public static String ExtractInputPage_ReplaceInSubclass;
+       public static String ExtractInputPage_EnterName;
+       public static String ExtractInputPage_CheckName;
+       public static String VisibilitySelectionPanel_AccessModifier;
+       public static String ValidatingLabeledTextField_CantBeEmpty;
+       public static String ValidatingLabeledTextField_InvalidCharacters;
+       public static String ValidatingLabeledTextField_DuplicatedNames;
+       public static String ValidatingLabeledTextField_IsKeyword;
+
+       static {
+               NLS.initializeMessages(Messages.class.getName(), Messages.class);
+       }
+
+       // Do not instantiate
+       private Messages() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/Messages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/Messages.properties
new file mode 100644 (file)
index 0000000..7ad17a0
--- /dev/null
@@ -0,0 +1,21 @@
+###############################################################################
+# Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
+# Rapperswil, University of applied sciences and others
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#    Institute for Software - initial API and implementation
+###############################################################################
+CTextEditChangePreviewViewer_OrgSource=Original Source
+CTextEditChangePreviewViewer_RefactoredSource=Refactored Source
+ExtractInputPage_ReplaceInSubclass=Replace in subclass:
+ExtractInputPage_EnterName=Enter a name
+ExtractInputPage_CheckName=Check Name: {0}
+VisibilitySelectionPanel_AccessModifier=&Access modifier:
+ValidatingLabeledTextField_CantBeEmpty=Cannot be empty
+ValidatingLabeledTextField_InvalidCharacters=Invalid characters
+ValidatingLabeledTextField_DuplicatedNames=Duplicated name
+ValidatingLabeledTextField_IsKeyword=Keyword
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/NameAndVisibilityComposite.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/NameAndVisibilityComposite.java
new file mode 100644 (file)
index 0000000..3bc3343
--- /dev/null
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.dialogs;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
+
+/**
+  * Composite to query for a name and visibility.
+  * 
+  * @author Thomas Corbat
+  *
+  */
+public class NameAndVisibilityComposite extends Composite {
+       
+       private LabeledTextField constantName;
+       private final String labelName;
+       private final VisibilitySelectionPanel visibilityPanel;
+       
+       public NameAndVisibilityComposite(Composite parent, String labelName, String defaultName) {
+               this(parent, labelName, VisibilityEnum.v_public, defaultName);
+       }
+       
+       public NameAndVisibilityComposite(Composite parent, String labelName, VisibilityEnum defaultVisibility, String defaultName){
+
+               super(parent, SWT.NONE);
+               
+               this.labelName = labelName;
+               
+               setLayout(new GridLayout());
+               
+               createNewMethodNameComposite(this, defaultName);
+               visibilityPanel = new VisibilitySelectionPanel(this, defaultVisibility,SWT.NONE);
+       }
+       
+
+       public Text getConstantNameText() {
+               return constantName.getText();
+       }
+       
+       public Group getVisibiltyGroup() {
+               return visibilityPanel.getGroup();
+       }
+       
+       public void visibilityPanelsetVisible(boolean visible) {
+               visibilityPanel.setVisible(visible);
+       }
+
+
+       private void createNewMethodNameComposite(Composite control, String defaultName) {
+               Composite methodNameComposite = new Composite(control, SWT.NONE);
+               FillLayout compositeLayout = new FillLayout(SWT.HORIZONTAL);
+               GridData gridData = new GridData(SWT.FILL,SWT.BEGINNING, true, false);
+               gridData.horizontalAlignment = GridData.FILL;
+               methodNameComposite.setLayoutData(gridData);
+               methodNameComposite.setLayout(compositeLayout);
+               constantName = new LabeledTextField(methodNameComposite, labelName, defaultName);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/ValidatingLabeledTextField.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/ValidatingLabeledTextField.java
new file mode 100644 (file)
index 0000000..14762df
--- /dev/null
@@ -0,0 +1,208 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+
+
+package org.eclipse.cdt.internal.ui.refactoring.dialogs;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.internal.ui.refactoring.utils.NameHelper;
+
+
+/**
+ * @author Mirko Stocker
+ * 
+ * Text field with a description and error handling using the Validator-Callback. Can also be used for multiple inputs.
+ *
+ */
+public class ValidatingLabeledTextField extends Composite {
+       
+       private static final String EMPTY_STRING = ""; //$NON-NLS-1$
+
+       private final Map<Text, Boolean> validationStatus = new HashMap<Text, Boolean>();
+       
+       private final ArrayList<Listener> inputTextListeners = new ArrayList<Listener>();
+       
+       private final Color errorColor = new Color(getShell().getDisplay(), new RGB(255, 208, 196));
+       
+       /**
+        * The Validator is used for feedback about the validation status of the inputs and to validate the input.
+        */
+       public static abstract class Validator {
+
+               /**
+                * Is called if all input texts contain valid input.
+                */
+               public void hasErrors() {}
+               
+               /**
+                * Is called if any input text contains invalid input.
+                */
+               public void hasNoErrors() {}
+               
+               /**
+                * @param text the new value of the field
+                * @return whether the value is valid or not
+                */
+               public boolean isValidInput(String text) { return true; }
+
+               public String errorMessageForEmptyField() {
+                       return Messages.ValidatingLabeledTextField_CantBeEmpty; 
+               }
+
+               public String errorMessageForInvalidInput() {
+                       return Messages.ValidatingLabeledTextField_InvalidCharacters; 
+               }
+
+               public String errorMessageForDuplicateValues() {
+                       return Messages.ValidatingLabeledTextField_DuplicatedNames; 
+               }
+
+               public String errorIsKeywordMessage() {
+                       return Messages.ValidatingLabeledTextField_IsKeyword;
+               }
+       }
+
+       public ValidatingLabeledTextField(Composite parent, int style) {
+               super(parent, style);
+               
+           GridLayout gridLayout = new GridLayout();
+           gridLayout.numColumns = 4;
+            
+           setLayout(gridLayout);
+       }
+
+       public ValidatingLabeledTextField(Composite parent) {
+               this(parent, SWT.NONE);
+       }
+       
+       public void addElement(String description, String initialText, boolean readOnly, final Validator validator) {
+               
+               Label label = new Label(this, SWT.NONE);
+               label.setText(description);
+               label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+
+               final Text textField = new Text(this, SWT.BORDER |SWT.SINGLE);
+               textField.setText(initialText);
+               textField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               
+               if(readOnly) {
+                       //readOnly inputs are always valid:
+                       validationStatus.put(textField, Boolean.TRUE);
+                       textField.setEnabled(false);
+                       return;
+               }
+               validationStatus.put(textField, Boolean.FALSE);
+               
+               final Label errorImageLabel = new Label(this, SWT.NONE);
+               errorImageLabel.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR));
+               errorImageLabel.setLayoutData(new GridData());
+               errorImageLabel.setVisible(false);
+               
+               final Label errorLabel = new Label(this, SWT.NONE);
+               errorLabel.setLayoutData(new GridData());
+
+               final Color defaultColor = textField.getBackground();
+               
+               Listener listener = new Listener(){
+                       
+                       @SuppressWarnings("unchecked")
+                       public void checkField() {
+                               String newName = textField.getText();
+                               
+
+                               boolean isEmpty = (newName.length() == 0);
+
+                               boolean isNameAlreadyInUse = nameAlreadyInUse(textField, newName);
+                               boolean isValid = validator.isValidInput(newName);
+                               boolean isKeyword = NameHelper.isKeyword(newName);
+                               boolean isValidName = NameHelper.isValidLocalVariableName(newName);
+
+                               boolean isOk = isValid && !isNameAlreadyInUse && !isEmpty && !isKeyword && isValidName;
+                               if (isOk) {
+                                       setErrorStatus(EMPTY_STRING);
+                               } else if (isEmpty) {
+                                       setErrorStatus(validator.errorMessageForEmptyField());
+                               } else if (!isValid  || !isValidName) {
+                                       setErrorStatus(validator.errorMessageForInvalidInput());
+                               } else if (isKeyword) {
+                                       setErrorStatus(validator.errorIsKeywordMessage());
+                               }else if (isNameAlreadyInUse) {
+                                       setErrorStatus(validator.errorMessageForDuplicateValues());
+                               } 
+                               validationStatus.put(textField, isOk);
+                               
+                               if(validationStatus.values().contains(Boolean.FALSE) || isEmpty || isNameAlreadyInUse || isKeyword || !isValidName) {
+                                       validator.hasErrors();
+                               } else {
+                                       validator.hasNoErrors();
+                               }
+                               
+                               layout();
+                               
+                               // recheck all other listeners in case duplicate names have been resolved, 
+                               // but remove this first to avoid an infinite loop
+                               inputTextListeners.remove(this);
+                               for(Listener listener : (ArrayList<Listener>) inputTextListeners.clone()) {
+                                       listener.handleEvent(null);
+                               }
+                               inputTextListeners.add(this);
+                       }
+
+                       private boolean nameAlreadyInUse(final Text textField, String newName) {
+                               for (Text text : validationStatus.keySet()) {
+                                       if(text != textField && text.getText().equals(newName)) {
+                                               return true;
+                                       }
+                               }
+                               return false;
+                       }
+
+                       private void setErrorStatus(String errorMessage) {
+                               if (EMPTY_STRING.equals(errorMessage)) {
+                                       textField.setBackground(defaultColor);
+                                       errorLabel.setText(EMPTY_STRING);
+                                       errorImageLabel.setVisible(false);
+                               } else {
+                                       textField.setBackground(errorColor);
+                                       errorLabel.setText(errorMessage);
+                                       errorImageLabel.setVisible(true);
+                               }
+                       }
+                       
+                       public void handleEvent(Event event) {
+                               checkField();
+                       }};
+                       
+               //we need to keep a list of all listeners so we get access from other textfields to resolve duplicate names
+               inputTextListeners.add(listener);
+                       
+               listener.handleEvent(null);
+               
+               textField.addListener(SWT.Modify, listener);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/VisibilitySelectionPanel.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/VisibilitySelectionPanel.java
new file mode 100644 (file)
index 0000000..76ab8f8
--- /dev/null
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *    Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.dialogs;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
+
+/**
+ * 3 radio buttons in a group, labeled according to the corresponding visibility name (public, private, protected).
+ * 
+ * @author Thomas Corbat
+ *
+ */
+public class VisibilitySelectionPanel extends Composite {
+
+
+       private Button publicAccessRadioButton;
+       private Button protectedAccessRadioButton;
+       private Button privateAccessRadioButton;
+       private Group accessModifierGroup;
+
+       public VisibilitySelectionPanel(Composite parent, VisibilityEnum defaultVisibility, int style) {
+               super(parent, style);
+               
+               FillLayout compositeLayout = new FillLayout(SWT.HORIZONTAL);
+               setLayout(compositeLayout);
+               GridData gridData = new GridData(SWT.FILL,SWT.BEGINNING, true, false);
+               gridData.horizontalAlignment = GridData.FILL;
+               setLayoutData(gridData);
+               
+               createAccessModifierComposite(this);
+               setSelected(defaultVisibility);
+               
+       }
+
+       private void createAccessModifierComposite(Composite control) {
+
+               accessModifierGroup = new Group(this, SWT.SHADOW_NONE );
+               RowLayout groupLayout = new RowLayout(SWT.HORIZONTAL);
+               groupLayout.fill = true;
+               accessModifierGroup.setLayout(groupLayout);
+               accessModifierGroup.setText(Messages.VisibilitySelectionPanel_AccessModifier); 
+               
+               publicAccessRadioButton = new Button(accessModifierGroup, SWT.RADIO | SWT.LEFT);
+               publicAccessRadioButton.setText(VisibilityEnum.v_public.toString());
+               
+               protectedAccessRadioButton = new Button(accessModifierGroup, SWT.RADIO | SWT.LEFT);
+               protectedAccessRadioButton.setText(VisibilityEnum.v_protected.toString());
+               
+               privateAccessRadioButton = new Button(accessModifierGroup, SWT.RADIO | SWT.LEFT);
+               privateAccessRadioButton.setText(VisibilityEnum.v_private.toString());
+               
+       }
+
+       private void setSelected(VisibilityEnum defaultVisibility) {
+               switch (defaultVisibility){
+               case v_public:
+                       publicAccessRadioButton.setSelection(true);
+                       break;
+               case v_protected:
+                       protectedAccessRadioButton.setSelection(true);
+                       break;
+               case v_private:
+                       privateAccessRadioButton.setSelection(true);
+                       break;
+               }               
+       }
+
+       public Group getGroup() {
+               return accessModifierGroup;
+       }       
+       
+       @Override
+       public void setEnabled(boolean enabled){
+               accessModifierGroup.setEnabled(enabled);
+               publicAccessRadioButton.setEnabled(enabled);
+               protectedAccessRadioButton.setEnabled(enabled);
+               privateAccessRadioButton.setEnabled(enabled);
+               super.setEnabled(enabled);
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantInfo.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantInfo.java
new file mode 100644 (file)
index 0000000..29cf04b
--- /dev/null
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ * Institute for Software (IFS)- initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractconstant;
+
+import org.eclipse.cdt.internal.ui.refactoring.MethodContext;
+import org.eclipse.cdt.internal.ui.refactoring.NameNVisibilityInformation;
+
+/**
+ * @author Emanuel Graf IFS
+ *
+ */
+public class ExtractConstantInfo extends NameNVisibilityInformation{
+       
+       private MethodContext mContext;
+
+       public MethodContext getMContext() {
+               return mContext;
+       }
+       public void setMContext(MethodContext context) {
+               mContext = context;
+       }
+       
+       
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoring.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoring.java
new file mode 100644 (file)
index 0000000..3adaf1e
--- /dev/null
@@ -0,0 +1,415 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *    Institute for Software - initial API and implementation
+ *    Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractconstant;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.core.runtime.preferences.IPreferencesService;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.text.edits.TextEditGroup;
+
+import org.eclipse.cdt.core.dom.ast.ASTNodeFactoryFactory;
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
+import org.eclipse.cdt.core.dom.ast.IASTMacroExpansionLocation;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.INodeFactory;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPNodeFactory;
+import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
+import org.eclipse.cdt.core.dom.rewrite.DeclarationGenerator;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTEqualsInitializer;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclaration;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethod;
+
+import org.eclipse.cdt.internal.ui.refactoring.AddDeclarationNodeToClassChange;
+import org.eclipse.cdt.internal.ui.refactoring.CRefactoring;
+import org.eclipse.cdt.internal.ui.refactoring.CRefactoringDescription;
+import org.eclipse.cdt.internal.ui.refactoring.MethodContext;
+import org.eclipse.cdt.internal.ui.refactoring.ModificationCollector;
+import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.GetterSetterNameGenerator;
+import org.eclipse.cdt.internal.ui.refactoring.utils.NodeHelper;
+import org.eclipse.cdt.internal.ui.refactoring.utils.SelectionHelper;
+import org.eclipse.cdt.internal.ui.refactoring.utils.TranslationUnitHelper;
+import org.eclipse.cdt.internal.ui.util.NameComposer;
+
+/**
+ * The central class of the Extract Constant Refactoring. Does all the work like checking pre- and 
+ * postconditions and collecting/creating the modifications to the AST.
+ * 
+ * @author Mirko Stocker
+ */
+public class ExtractConstantRefactoring extends CRefactoring {
+       public static final String ID = "org.eclipse.cdt.ui.refactoring.extractconstant.ExtractConstantRefactoring"; //$NON-NLS-1$
+       
+       private IASTLiteralExpression target = null;
+       private final ArrayList<IASTExpression> literalsToReplace = new ArrayList<IASTExpression>();
+       private final ExtractConstantInfo info;
+       
+       
+       public ExtractConstantRefactoring(IFile file, ISelection selection, ExtractConstantInfo info, ICProject proj) {
+               super(file,selection, null, proj);
+               this.info = info;
+               this.project = proj;
+               name = Messages.ExtractConstantRefactoring_ExtractConst; 
+       }
+
+       @Override
+       public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException {
+               SubMonitor sm = SubMonitor.convert(pm, 9);
+               try {
+                       lockIndex();
+                       try {
+                               RefactoringStatus status = super.checkInitialConditions(sm.newChild(6));
+                               if (status.hasError()) {
+                                       return status;
+                               }
+
+                               Collection<IASTLiteralExpression> literalExpressionCollection = findAllLiterals();
+                               if (literalExpressionCollection.isEmpty()) {
+                                       initStatus.addFatalError(Messages.ExtractConstantRefactoring_LiteralMustBeSelected); 
+                                       return initStatus;
+                               }
+                               sm.worked(1);
+                               if (isProgressMonitorCanceld(sm, initStatus)) return initStatus;
+
+                               boolean oneMarked = region != null && isOneMarked(literalExpressionCollection, region);
+                               if (!oneMarked) { 
+                                       //No or more than one marked
+                                       if (target == null) {
+                                               //No Selection found;
+                                               initStatus.addFatalError(Messages.ExtractConstantRefactoring_NoLiteralSelected); 
+                                       } else {
+                                               //To many selection found
+                                               initStatus.addFatalError(Messages.ExtractConstantRefactoring_TooManyLiteralSelected); 
+                                       }
+                                       return initStatus;
+                               }
+                               sm.worked(1);
+
+                               if (isProgressMonitorCanceld(sm, initStatus)) return initStatus;
+
+                               findAllNodesForReplacement(literalExpressionCollection);
+
+                               info.addNamesToUsedNames(findAllDeclaredNames());
+                               if (info.getName().length() == 0) {
+                                       info.setName(getDefaultName(target));
+                               }
+                               info.setMContext(NodeHelper.findMethodContext(target, getIndex()));
+                               sm.done();
+                       }
+                       finally {
+                               unlockIndex();
+                       }
+               } catch (InterruptedException e) {
+                       Thread.currentThread().interrupt();
+               }
+               return initStatus;
+       }
+
+       private String getDefaultName(IASTLiteralExpression literal) {
+               String nameString = literal.toString();
+               switch (literal.getKind()) {
+               case IASTLiteralExpression.lk_char_constant:
+               case IASTLiteralExpression.lk_string_literal:
+                       int beginIndex = 1;
+                       if (nameString.startsWith("L")) {  //$NON-NLS-1$
+                               beginIndex = 2;
+                       }
+                       final int len= nameString.length();
+                       if (beginIndex < len && len > 0) {
+                               nameString = nameString.substring(beginIndex, len - 1);
+                       }
+                       break;
+
+               default:
+                       break;
+               }
+
+       IPreferencesService preferences = Platform.getPreferencesService();
+       int capitalization = preferences.getInt(CUIPlugin.PLUGIN_ID,
+                       PreferenceConstants.NAME_STYLE_CONSTANT_CAPITALIZATION,
+                       PreferenceConstants.NAME_STYLE_CAPITALIZATION_UPPER_CASE, null);
+       String wordDelimiter = preferences.getString(CUIPlugin.PLUGIN_ID,
+                       PreferenceConstants.NAME_STYLE_CONSTANT_WORD_DELIMITER, "_", null); //$NON-NLS-1$
+       String prefix = preferences.getString(CUIPlugin.PLUGIN_ID,
+                                               PreferenceConstants.NAME_STYLE_CONSTANT_PREFIX, "", null); //$NON-NLS-1$
+       String suffix = preferences.getString(CUIPlugin.PLUGIN_ID,
+                       PreferenceConstants.NAME_STYLE_CONSTANT_SUFFIX, "", null); //$NON-NLS-1$
+       NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
+       return composer.compose(nameString);
+       }
+
+       private ArrayList<String> findAllDeclaredNames() {
+               ArrayList<String>names = new ArrayList<String>();
+               IASTFunctionDefinition funcDef = NodeHelper.findFunctionDefinitionInAncestors(target);
+               ICPPASTCompositeTypeSpecifier comTypeSpec = getCompositeTypeSpecifier(funcDef);
+               if (comTypeSpec != null) {
+                       for(IASTDeclaration dec : comTypeSpec.getMembers()) {
+                               if (dec instanceof IASTSimpleDeclaration) {
+                                       IASTSimpleDeclaration simpDec = (IASTSimpleDeclaration) dec;
+                                       for(IASTDeclarator decor : simpDec.getDeclarators()) {
+                                               names.add(decor.getName().getRawSignature());
+                                       }
+                               }
+                       }
+               }
+               return names;
+       }
+
+       private ICPPASTCompositeTypeSpecifier getCompositeTypeSpecifier(IASTFunctionDefinition funcDef) {
+               if (funcDef != null) {
+                       IBinding binding = funcDef.getDeclarator().getName().resolveBinding();
+                       if (binding instanceof CPPMethod) {
+                               CPPMethod methode = (CPPMethod) binding;
+                               IASTNode[] declarations = methode.getDeclarations();
+                               
+                               IASTNode decl;
+                               if (declarations != null) {
+                                       decl = declarations[0];
+                               } else {
+                                       decl = methode.getDefinition();
+                               }
+                                                               
+                               IASTNode spec = decl.getParent().getParent();
+                               if (spec instanceof ICPPASTCompositeTypeSpecifier) {
+                                       ICPPASTCompositeTypeSpecifier compTypeSpec = (ICPPASTCompositeTypeSpecifier) spec;
+                                       return compTypeSpec;
+                               }
+                       }
+               }
+               return null;
+       }
+
+       private void findAllNodesForReplacement(Collection<IASTLiteralExpression> literalExpressionCollection) {
+               if (target.getParent() instanceof IASTUnaryExpression) {
+                       IASTUnaryExpression unary = (IASTUnaryExpression) target.getParent();
+                       for (IASTLiteralExpression expression : literalExpressionCollection) {
+                               if (target.getKind() == expression.getKind()
+                                               && target.toString().equals(expression.toString()) 
+                                               && expression.getParent() instanceof IASTUnaryExpression
+                                               && unary.getOperator() == ((IASTUnaryExpression)expression.getParent()).getOperator()) {
+                                       literalsToReplace.add(((IASTUnaryExpression)expression.getParent()));
+                               }       
+                       }
+               } else {
+                       for (IASTLiteralExpression expression : literalExpressionCollection) {
+                               if (target.getKind() == expression.getKind()
+                                               && target.toString().equals(expression.toString())) {
+                                       literalsToReplace.add(expression);
+                               }       
+                       }
+               }
+       }
+
+       private boolean isOneMarked(Collection<IASTLiteralExpression> literalExpressionCollection, Region textSelection) {
+               boolean oneMarked = false;
+               for (IASTLiteralExpression expression : literalExpressionCollection) {
+                       boolean isInSameFileSelection = SelectionHelper.isInSameFileSelection(textSelection, expression, file);
+                       if (isInSameFileSelection) {
+                               if (target == null) {
+                                       target = expression;
+                                       oneMarked = true;
+                               } else {
+                                       oneMarked = false;
+                               }
+                       }
+               }
+               return oneMarked;
+       }
+
+       private Collection<IASTLiteralExpression> findAllLiterals() {
+               final Collection<IASTLiteralExpression> result = new ArrayList<IASTLiteralExpression>();                
+               
+               ast.accept(new ASTVisitor() {
+                       {
+                               shouldVisitExpressions = true;
+                       }
+                       @Override
+                       public int visit(IASTExpression expression) {
+                               if (expression instanceof IASTLiteralExpression) {
+                                       if (!(expression.getNodeLocations().length == 1
+                                                       && expression.getNodeLocations()[0] instanceof IASTMacroExpansionLocation)) {
+                                               IASTLiteralExpression literal = (IASTLiteralExpression) expression;
+                                               result.add(literal);
+                                       }
+                               }
+                               return super.visit(expression);
+                       }
+               });
+               
+               return result;
+       }
+
+       @Override
+       protected void collectModifications(IProgressMonitor pm, ModificationCollector collector)
+                       throws CoreException, OperationCanceledException{
+               try {
+                       lockIndex();
+                       try {
+                               MethodContext context = info.getMContext();
+                               Collection<IASTExpression> locLiteralsToReplace = new ArrayList<IASTExpression>();
+
+                               if (context.getType() == MethodContext.ContextType.METHOD) {
+                                       for (IASTExpression expression : literalsToReplace) {
+                                               MethodContext exprContext = NodeHelper.findMethodContext(expression, getIndex());
+                                               if (exprContext.getType() == MethodContext.ContextType.METHOD) {
+                                                       if (context.getMethodQName() != null) {
+                                                               if (MethodContext.isSameClass(exprContext.getMethodQName(), context.getMethodQName())) {
+                                                                       locLiteralsToReplace.add(expression);
+                                                               }
+                                                       } else {
+                                                               if (MethodContext.isSameClass(exprContext.getMethodDeclarationName(), context.getMethodDeclarationName())) {
+                                                                       locLiteralsToReplace.add(expression);
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               } else {
+                                       for (IASTExpression expression : literalsToReplace) {
+                                               IPath path = new Path(expression.getContainingFilename());
+                                               IFile expressionFile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
+                                               //expressionFile may be null if the file is NOT in the workspace
+                                               if (expressionFile != null && expressionFile.equals(file)) {
+                                                       locLiteralsToReplace.add(expression);
+                                               }
+                                       }
+                               }
+
+                               // Create all Changes for literals
+                               String constName = info.getName();
+                               createLiteralToConstantChanges(constName, locLiteralsToReplace, collector);
+
+                               if (context.getType() == MethodContext.ContextType.METHOD) {
+                                       ICPPASTCompositeTypeSpecifier classDefinition = (ICPPASTCompositeTypeSpecifier) context.getMethodDeclaration().getParent();
+                                       AddDeclarationNodeToClassChange.createChange(classDefinition, info.getVisibility(), getConstNodesClass(constName), true, collector);
+                               } else {
+                                       IASTDeclaration nodes = getConstNodesGlobal(constName);
+                                       ASTRewrite rewriter = collector.rewriterForTranslationUnit(ast);
+                                       rewriter.insertBefore(ast, TranslationUnitHelper.getFirstNode(ast), nodes, new TextEditGroup(Messages.ExtractConstantRefactoring_CreateConstant));
+                               }
+                       } finally {
+                               unlockIndex();
+                       }
+               } catch (InterruptedException e) {
+                       Thread.currentThread().interrupt();
+               }
+       }
+       
+       @Override
+       protected RefactoringDescriptor getRefactoringDescriptor() {
+               Map<String, String> arguments = getArgumentMap();
+               RefactoringDescriptor desc = new ExtractConstantRefactoringDescription(project.getProject().getName(),
+                               "Extract Constant Refactoring", "Create constant for " + target.getRawSignature(), arguments);  //$NON-NLS-1$//$NON-NLS-2$
+               return desc;
+       }
+
+       private Map<String, String> getArgumentMap() {
+               Map<String, String> arguments = new HashMap<String, String>();
+               arguments.put(CRefactoringDescription.FILE_NAME, file.getLocationURI().toString());
+               arguments.put(CRefactoringDescription.SELECTION, region.getOffset() + "," + region.getLength()); //$NON-NLS-1$
+               arguments.put(ExtractConstantRefactoringDescription.NAME, info.getName());
+               arguments.put(ExtractConstantRefactoringDescription.VISIBILITY, info.getVisibility().toString());
+               return arguments;
+       }
+
+       private void createLiteralToConstantChanges(String constName,
+                       Iterable<? extends IASTExpression> literals, ModificationCollector collector) {
+               for (IASTExpression each : literals) {
+                       ASTRewrite rewrite = collector.rewriterForTranslationUnit(each.getTranslationUnit());
+                       CPPASTIdExpression idExpression = new CPPASTIdExpression(new CPPASTName(constName.toCharArray()));
+                       rewrite.replace(each, idExpression, new TextEditGroup(Messages.ExtractConstantRefactoring_ReplaceLiteral));                     
+               }
+       }
+
+       private IASTSimpleDeclaration getConstNodes(String newName) {
+               ICPPNodeFactory factory = ASTNodeFactoryFactory.getDefaultCPPNodeFactory();
+               DeclarationGenerator generator = DeclarationGenerator.create(factory);
+               
+               IType type = target.getExpressionType();
+               
+               IASTDeclSpecifier declSpec = generator.createDeclSpecFromType(type);
+               declSpec.setConst(true);
+               
+               IASTDeclarator declarator = generator.createDeclaratorFromType(type, newName.toCharArray());
+
+               IASTSimpleDeclaration simple = new CPPASTSimpleDeclaration();
+               simple.setDeclSpecifier(declSpec);
+               
+               IASTEqualsInitializer init = new CPPASTEqualsInitializer(); 
+               if (target.getParent() instanceof IASTUnaryExpression) {
+                       IASTUnaryExpression unary = (IASTUnaryExpression) target.getParent();
+                       init.setInitializerClause(unary);
+               } else {
+                       CPPASTLiteralExpression expression = new CPPASTLiteralExpression(target.getKind(), target.getValue());
+                       init.setInitializerClause(expression);
+               }
+               declarator.setInitializer(init);
+               simple.addDeclarator(declarator);
+               
+               return simple;
+       }
+       
+       private IASTDeclaration getConstNodesGlobal(String newName) {
+               IASTSimpleDeclaration simple = getConstNodes(newName);
+
+               INodeFactory factory= ast.getASTNodeFactory();
+               if (factory instanceof ICPPNodeFactory) {
+                       ICPPASTNamespaceDefinition namespace = ((ICPPNodeFactory) factory).newNamespaceDefinition(new CPPASTName());
+                       namespace.addDeclaration(simple);
+                       return namespace;
+               }
+               
+               simple.getDeclSpecifier().setStorageClass(IASTDeclSpecifier.sc_static);
+               return simple;
+       }
+       
+       private IASTDeclaration getConstNodesClass(String newName) {
+               IASTSimpleDeclaration simple = getConstNodes(newName);
+               simple.getDeclSpecifier().setStorageClass(IASTDeclSpecifier.sc_static);
+               return simple;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringContribution.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringContribution.java
new file mode 100644 (file)
index 0000000..a0e1be6
--- /dev/null
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ * Institute for Software (IFS)- initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractconstant;
+
+import java.util.Map;
+
+import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
+
+import org.eclipse.cdt.internal.ui.refactoring.CRefactoringContribution;
+
+/**
+ * @author Emanuel Graf IFS
+ *
+ */
+public class ExtractConstantRefactoringContribution extends
+               CRefactoringContribution {
+
+       @SuppressWarnings({ "unchecked", "rawtypes" })
+       @Override
+       public RefactoringDescriptor createDescriptor(String id, String project,
+                       String description, String comment, Map arguments, int flags)
+                       throws IllegalArgumentException {
+               if(id.equals(ExtractConstantRefactoring.ID)) {
+                       return new ExtractConstantRefactoringDescription(project, description, comment, arguments);
+               }else {
+                       return null;
+               }
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringDescription.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringDescription.java
new file mode 100644 (file)
index 0000000..33db162
--- /dev/null
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ * Institute for Software (IFS)- initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractconstant;
+
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ltk.core.refactoring.Refactoring;
+import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+
+import org.eclipse.cdt.core.model.ICProject;
+
+import org.eclipse.cdt.internal.ui.refactoring.CRefactoringDescription;
+import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
+
+/**
+ * @author Emanuel Graf IFS
+ *
+ */
+public class ExtractConstantRefactoringDescription extends
+               CRefactoringDescription {
+       protected static final String NAME = "name"; //$NON-NLS-1$
+       protected static final String VISIBILITY = "visibility"; //$NON-NLS-1$
+       
+       protected ExtractConstantRefactoringDescription(String project,
+                       String description, String comment, Map<String, String> arguments) {
+               super(ExtractConstantRefactoring.ID, project, description, comment, RefactoringDescriptor.MULTI_CHANGE, arguments);
+       }
+       
+       @Override
+       public Refactoring createRefactoring(RefactoringStatus status)
+                       throws CoreException {
+               IFile file;
+               ExtractConstantInfo info = new ExtractConstantInfo();
+               ICProject proj;
+               
+               info.setName(arguments.get(NAME));
+               info.setVisibility(VisibilityEnum.getEnumForStringRepresentation(arguments.get(VISIBILITY)));
+               
+               proj = getCProject();
+               
+               file = getFile();
+               
+               ISelection selection = getSelection();
+               return new ExtractConstantRefactoring(file, selection, info, proj);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringRunner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringRunner.java
new file mode 100644 (file)
index 0000000..6668dd5
--- /dev/null
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractconstant;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
+
+import org.eclipse.cdt.core.model.ICProject;
+
+import org.eclipse.cdt.internal.ui.refactoring.CRefactoring;
+import org.eclipse.cdt.internal.ui.refactoring.RefactoringRunner;
+
+/**
+ * @author Emanuel Graf
+ */
+public class ExtractConstantRefactoringRunner extends RefactoringRunner  {
+
+       public ExtractConstantRefactoringRunner(IFile file, ISelection selection,
+                       IShellProvider shellProvider, ICProject cProject) {
+               super(file, selection, null, shellProvider, cProject);
+       }
+
+       @Override
+       public void run() {
+               ExtractConstantInfo info = new ExtractConstantInfo();
+               CRefactoring refactoring = new ExtractConstantRefactoring(file,selection,info, project);
+               ExtractConstantRefactoringWizard wizard = new ExtractConstantRefactoringWizard(refactoring, info);
+               RefactoringWizardOpenOperation operator = new RefactoringWizardOpenOperation(wizard);
+
+               try {
+                       operator.run(shellProvider.getShell(), refactoring.getName());
+               } catch (InterruptedException e) {
+                       Thread.currentThread().interrupt();
+               } 
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoringWizard.java
new file mode 100644 (file)
index 0000000..f8d25ab
--- /dev/null
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractconstant;
+
+import org.eclipse.ltk.core.refactoring.Refactoring;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
+
+import org.eclipse.cdt.internal.ui.refactoring.MethodContext.ContextType;
+import org.eclipse.cdt.internal.ui.refactoring.dialogs.ExtractInputPage;
+
+/**
+ * The wizard page for Extract Constant Refactoring, creates the UI page.
+ */
+public class ExtractConstantRefactoringWizard extends RefactoringWizard {
+
+       private ExtractInputPage page;
+       private final ExtractConstantInfo info;
+
+       public ExtractConstantRefactoringWizard(Refactoring refactoring, ExtractConstantInfo info) {
+               super(refactoring, WIZARD_BASED_USER_INTERFACE);
+               this.info = info;
+       }
+
+       @Override
+       protected void addUserInputPages() {
+               page = new InputPage(Messages.ExtractConstantRefactoring_ExtractConst, info, info.getMContext().getType() == ContextType.METHOD); 
+               addPage(page);
+
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/InputPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/InputPage.java
new file mode 100644 (file)
index 0000000..5baa300
--- /dev/null
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractconstant;
+
+import java.util.ArrayList;
+
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Composite;
+
+import org.eclipse.cdt.internal.ui.refactoring.NameNVisibilityInformation;
+import org.eclipse.cdt.internal.ui.refactoring.dialogs.ExtractInputPage;
+
+public class InputPage extends ExtractInputPage {
+
+       private final ArrayList<String> usedNames;
+       private boolean showVisibilityPane;
+
+       public InputPage(String name, NameNVisibilityInformation info) {
+               this(name, info, true);
+       }
+
+       public InputPage(String name, NameNVisibilityInformation info, boolean showVisibilityPane) {
+               super(name, info);
+               label = Messages.InputPage_ConstName;
+               errorLabel = Messages.InputPage_EnterContName;
+               usedNames = info.getUsedNames();
+               this.showVisibilityPane = showVisibilityPane;
+       }
+       
+       
+
+       @Override
+       public void createControl(Composite parent) {
+               super.createControl(parent);
+               control.getVisibiltyGroup().setVisible(showVisibilityPane);
+       }
+
+       @Override
+       protected void verifyName(String name) {
+               if(usedNames.contains(name)) {
+                       setErrorMessage(NLS.bind(Messages.InputPage_NameAlreadyDefined, name)); 
+                       setPageComplete(false);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/Messages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/Messages.java
new file mode 100644 (file)
index 0000000..cd6bc23
--- /dev/null
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *     Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractconstant;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class Messages extends NLS {
+       public static String InputPage_ConstName;
+       public static String InputPage_EnterContName;
+       public static String InputPage_NameAlreadyDefined;
+       public static String ExtractConstantRefactoring_ExtractConst;
+       public static String ExtractConstantRefactoring_LiteralMustBeSelected;
+       public static String ExtractConstantRefactoring_NoLiteralSelected;
+       public static String ExtractConstantRefactoring_TooManyLiteralSelected;
+       public static String ExtractConstantRefactoring_CreateConstant;
+       public static String ExtractConstantRefactoring_ReplaceLiteral;
+
+       private Messages() {
+               // Do not instantiate
+       }
+
+       static {
+               NLS.initializeMessages(Messages.class.getName(), Messages.class);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/Messages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/Messages.properties
new file mode 100644 (file)
index 0000000..df54787
--- /dev/null
@@ -0,0 +1,22 @@
+###############################################################################
+# Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
+# Rapperswil, University of applied sciences and others
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#    Institute for Software - initial API and implementation
+#    IBM Corporation
+###############################################################################
+InputPage_ConstName=Constant &name:
+InputPage_EnterContName=Enter a name for the new constant
+InputPage_NameAlreadyDefined=An element named ''{0}'' is already defined in this scope.
+ExtractConstantRefactoring_ExtractConst=Extract Constant
+ExtractConstantRefactoring_LiteralMustBeSelected=An literal expression must be selected to activate this refactoring.
+ExtractConstantRefactoring_NoLiteralSelected=No selected literal.
+ExtractConstantRefactoring_TooManyLiteralSelected=Too many literals selected.
+ExtractConstantRefactoring_CreateConstant=Create constant
+ExtractConstantRefactoring_ReplaceLiteral=Replace a literal
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ChooserComposite.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ChooserComposite.java
new file mode 100644 (file)
index 0000000..7a13731
--- /dev/null
@@ -0,0 +1,240 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractfunction;
+
+import java.util.ArrayList;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.TableEditor;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+
+import org.eclipse.cdt.internal.ui.refactoring.NodeContainer.NameInformation;
+
+
+public class ChooserComposite extends Composite {
+
+       private static final String COLUMN_RETURN = Messages.ChooserComposite_Return;
+       private static final String COLUMN_REFERENCE = Messages.ChooserComposite_CallByRef;
+       private static final String COLUMN_NAME = Messages.ChooserComposite_Name;
+       private static final String COLUMN_TYPE = Messages.ChooserComposite_Type;
+
+
+       private Button voidReturn;
+
+       private final ExtractFunctionInputPage ip;
+
+       public ChooserComposite(Composite parent,
+                       final ExtractFunctionInformation info, ExtractFunctionInputPage ip) {
+               super(parent, SWT.NONE);
+
+               this.ip = ip;
+               
+               GridLayout layout = new GridLayout();           
+               setLayout(layout);
+
+               boolean hasNoPredefinedReturnValue = true;
+               if (info.getInScopeDeclaredVariable() != null) {
+                       hasNoPredefinedReturnValue = false;
+               }
+
+               final ArrayList<Button> returnButtons = new ArrayList<Button>();
+               final ArrayList<Button> referenceButtons = new ArrayList<Button>();
+
+               final Table table = new Table(parent, SWT.BORDER | SWT.MULTI | SWT.FILL);
+               
+               GridData tableLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
+               table.setLayoutData(tableLayoutData);
+               
+               table.setLinesVisible(true);
+               table.setHeaderVisible(true);
+
+               addColumnToTable(table, COLUMN_TYPE);
+               addColumnToTable(table, COLUMN_NAME);
+               addColumnToTable(table, COLUMN_REFERENCE);
+               addColumnToTable(table, Messages.ChooserComposite_const);
+               if(!info.isExtractExpression()) {
+                       addColumnToTable(table, COLUMN_RETURN);
+               }
+               addColumnToTable(table, ""); //$NON-NLS-1$
+               
+               for (int i = 0; i < info.getAllUsedNames().size(); i++) {
+                       if (!info.getAllUsedNames().get(i).isDeclarationInScope()) {
+                               TableItem item = new TableItem(table, SWT.NONE);
+
+                               TableEditor editor = new TableEditor(table);
+                               int columnIndex = 0;
+
+                               final NameInformation name = info.getAllUsedNames().get(i);
+
+                               // Text
+                               item.setText(columnIndex++, name.getType());
+                               item.setText(columnIndex++, name.getName().toString());
+
+                               // Button
+                               editor = new TableEditor(table);
+                               final Button referenceButton = new Button(table, SWT.CHECK);
+                               if(name.hasReferenceOperartor((IASTDeclarator) name.getDeclaration().getParent()))
+                               {
+                                       referenceButton.setSelection(true);
+                                       referenceButton.setEnabled(false);
+                               }else {
+                                       referenceButton.setSelection(name.isReference());
+                               }
+                               referenceButton.setBackground(table.getBackground());
+                               referenceButton.addSelectionListener(new SelectionListener() {
+
+                                       public void widgetDefaultSelected(SelectionEvent e) {
+                                               name.setUserSetIsReference(referenceButton
+                                                               .getSelection());
+                                               onVisibilityOrReturnChange(info.getAllUsedNames());
+                                       }
+
+                                       public void widgetSelected(SelectionEvent e) {
+                                               widgetDefaultSelected(e);
+                                       }
+
+                               });
+                               referenceButton.pack();
+                               editor.minimumWidth = referenceButton.getSize().x;
+                               editor.horizontalAlignment = SWT.CENTER;
+                               referenceButtons.add(referenceButton);
+                               editor.setEditor(referenceButton, item, columnIndex++);
+                               
+                               // Cosnt Button
+                               editor = new TableEditor(table);
+                               final Button constButton = new Button(table, SWT.CHECK);
+                               
+                               constButton.setSelection(name.isConst());
+                               constButton.setEnabled(!name.isWriteAccess());
+
+                               constButton.setBackground(table.getBackground());
+                               constButton.addSelectionListener(new SelectionListener() {
+
+                                       public void widgetDefaultSelected(SelectionEvent e) {
+                                               name.setConst(constButton
+                                                               .getSelection());
+                                               onVisibilityOrReturnChange(info.getAllUsedNames());
+                                       }
+
+                                       public void widgetSelected(SelectionEvent e) {
+                                               widgetDefaultSelected(e);
+                                       }
+
+                               });
+                               constButton.pack();
+                               editor.minimumWidth = constButton.getSize().x;
+                               editor.horizontalAlignment = SWT.CENTER;
+//                             referenceButtons.add(referenceButton);
+                               editor.setEditor(constButton, item, columnIndex++);
+                               
+
+                               if(info.isExtractExpression())
+                                       continue; // Skip the return radiobutton
+                                       
+                               // Button
+                               editor = new TableEditor(table);
+                               final Button returnButton = new Button(table, SWT.RADIO);
+                               returnButton.setSelection(name.isReturnValue());
+                               name.setUserSetIsReference(name.isReference());
+                               returnButton.setEnabled(hasNoPredefinedReturnValue);
+                               returnButton.setBackground(table.getBackground());
+                               returnButton.addSelectionListener(new SelectionListener() {
+
+                                       public void widgetDefaultSelected(SelectionEvent e) {
+                                               name.setUserSetIsReturnValue(returnButton
+                                                               .getSelection());
+                                               if (returnButton.getSelection()) {
+                                                       referenceButton.setSelection(false);
+                                                       referenceButton.notifyListeners(SWT.Selection,
+                                                                       new Event());
+                                               } else {
+                                                       if (name.isReference()) {
+                                                               referenceButton.setSelection(true);
+                                                               referenceButton.notifyListeners(SWT.Selection,
+                                                                               new Event());
+                                                       }
+                                               }
+                                               onVisibilityOrReturnChange(info.getAllUsedNames());
+                                       }
+
+                                       public void widgetSelected(SelectionEvent e) {
+                                               widgetDefaultSelected(e);
+                                       }
+
+                               });
+                               returnButton.pack();
+                               editor.minimumWidth = returnButton.getSize().x;
+                               editor.horizontalAlignment = SWT.CENTER;
+                               returnButtons.add(returnButton);
+                               editor.setEditor(returnButton, item, columnIndex++);
+                       }
+               }
+               
+               if(!info.isExtractExpression()) {
+                       voidReturn = new Button(parent, SWT.CHECK | SWT.LEFT);
+                       voidReturn.setText(Messages.ChooserComposite_NoReturnValue);
+                       voidReturn.setEnabled(hasNoPredefinedReturnValue);
+                       voidReturn.addSelectionListener(new SelectionListener() {
+       
+                               public void widgetDefaultSelected(SelectionEvent e) {
+                                       info.setReturnVariable(null);
+       
+                                       for (Button button : returnButtons) {
+                                               if (voidReturn.getSelection()) {
+                                                       button.setSelection(false);
+                                                       button.notifyListeners(SWT.Selection, new Event());
+                                               }
+                                               button.setEnabled(!voidReturn.getSelection());
+       
+                                       }
+                               }
+       
+                               public void widgetSelected(SelectionEvent e) {
+                                       widgetDefaultSelected(e);
+                               }
+       
+                       });
+               }
+               
+               layout();
+       }
+
+       private void addColumnToTable(final Table table, String string) {
+               TableColumn column = new TableColumn(table, SWT.NONE);
+               column.setText(string);
+               column.setWidth(100);
+       }
+       
+       void onVisibilityOrReturnChange(ArrayList<NameInformation> name){
+               String variableUsedAfterBlock = null;
+               for (NameInformation information : name) {
+                       if(information.isUsedAfterReferences() 
+                                       && !(information.isUserSetIsReference() || information.isUserSetIsReturnValue())){
+                               variableUsedAfterBlock = information.getName().toString();
+                       }
+               }
+               
+               ip.errorWithAfterUsedVariable(variableUsedAfterBlock);
+
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractExpression.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractExpression.java
new file mode 100644 (file)
index 0000000..cd582f5
--- /dev/null
@@ -0,0 +1,200 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *    Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractfunction;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.text.edits.TextEditGroup;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
+import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
+import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
+import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTNode.CopyStyle;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IBasicType;
+import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.INodeFactory;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.ITypedef;
+import org.eclipse.cdt.core.dom.ast.IVariable;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
+import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
+import org.eclipse.cdt.core.dom.rewrite.DeclarationGenerator;
+
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTBinaryExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFieldReference;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDefinition;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTReturnStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclSpecifier;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclaration;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction;
+
+import org.eclipse.cdt.internal.ui.refactoring.NodeContainer.NameInformation;
+
+/**
+ * Handles the extraction of expression nodes, like return type determination.
+ * 
+ * @author Mirko Stocker
+ * 
+ */
+public class ExtractExpression extends ExtractedFunctionConstructionHelper {
+       
+       final static char[] ZERO= {'0'};
+
+       @Override
+       public void constructMethodBody(IASTCompoundStatement compound,
+                       List<IASTNode> list, ASTRewrite rewrite, TextEditGroup group) {
+
+               CPPASTReturnStatement statement = new CPPASTReturnStatement();
+               IASTExpression nullReturnExp = new CPPASTLiteralExpression(IASTLiteralExpression.lk_integer_constant, ZERO); 
+               statement.setReturnValue(nullReturnExp);
+               ASTRewrite nestedRewrite = rewrite.insertBefore(compound, null, statement, group);
+               
+               nestedRewrite.replace(nullReturnExp, getExpression(list), group);
+               
+       }
+
+       private IASTExpression getExpression(List<IASTNode> list) {
+               if(list.size()> 1 ) {
+                       CPPASTBinaryExpression bExp = new CPPASTBinaryExpression();
+                       bExp.setParent(list.get(0).getParent());
+                       bExp.setOperand1((IASTExpression) list.get(0).copy(CopyStyle.withLocations));
+                       bExp.setOperator(((IASTBinaryExpression)list.get(1).getParent()).getOperator());
+                       bExp.setOperand2(getExpression(list.subList(1, list.size())));
+                       return bExp;
+               }else {
+                       return (IASTExpression) list.get(0).copy(CopyStyle.withLocations);
+               }
+               
+       }
+
+       @Override
+       public IASTDeclSpecifier determineReturnType(IASTNode extractedNode, NameInformation _) {
+               List<ITypedef> typdefs = getTypdefs(extractedNode);
+               if (extractedNode instanceof IASTExpression) {
+                       IASTExpression exp = (IASTExpression) extractedNode;
+                       INodeFactory factory = extractedNode.getTranslationUnit().getASTNodeFactory();
+                       DeclarationGenerator generator = DeclarationGenerator.create(factory);
+                       IType expressionType = exp.getExpressionType();
+                       for (ITypedef typedef : typdefs) {
+                               if (typedef.getType().isSameType(expressionType)) {
+                                       return generator.createDeclSpecFromType(typedef);
+                               }
+                       }
+                       return generator.createDeclSpecFromType(expressionType);
+               } else {// Fallback
+                       return createSimpleDeclSpecifier(Kind.eVoid);
+               }
+       }
+
+       private List<ITypedef> getTypdefs(IASTNode extractedNode) {
+               final ArrayList<ITypedef> typeDefs = new ArrayList<ITypedef>();
+               extractedNode.accept(new ASTVisitor() {
+                       {
+                               shouldVisitExpressions = true;
+                       }
+                       
+                       @Override
+                       public int visit(IASTExpression expression) {
+                               if (expression instanceof IASTIdExpression) {
+                                       IASTIdExpression id = (IASTIdExpression) expression;
+                                       IBinding binding = id.getName().resolveBinding();
+                                       IType expressionType = null;
+                                       if (binding instanceof IVariable) {
+                                               expressionType = ((IVariable) binding).getType();
+                                       }
+                                       if (binding instanceof IType) {
+                                               expressionType = (IType) binding;
+                                       }
+                                       if (expressionType != null && expressionType instanceof ITypedef) {
+                                               ITypedef typdef = (ITypedef) expressionType;
+                                               typeDefs.add(typdef);
+                                       }
+                               }
+                               return PROCESS_CONTINUE;
+                       }
+               });
+               return typeDefs;
+       }
+
+       private static IASTDeclSpecifier createSimpleDeclSpecifier(IBasicType.Kind type) {
+               IASTSimpleDeclSpecifier declSpec = new CPPASTSimpleDeclSpecifier();
+               declSpec.setType(type);
+               return declSpec;
+       }
+       
+       private static IASTName findCalledFunctionName(IASTFunctionCallExpression callExpression) {
+               IASTExpression functionNameExpression = callExpression.getFunctionNameExpression();
+               IASTName functionName = null;
+               
+               if(functionNameExpression instanceof CPPASTIdExpression) {
+                       CPPASTIdExpression idExpression = (CPPASTIdExpression) functionNameExpression;
+                       functionName = idExpression.getName();
+               } else  if(functionNameExpression instanceof CPPASTFieldReference) {
+                       CPPASTFieldReference fieldReference = (CPPASTFieldReference) functionNameExpression;
+                       functionName = fieldReference.getFieldName();
+               }               
+               return functionName;
+       }
+
+       @Override
+       protected boolean isReturnTypeAPointer(IASTNode node) {
+               if(node instanceof ICPPASTNewExpression) {
+                       return true;
+               } else if(!(node instanceof IASTFunctionCallExpression)) {
+                       return false;
+               }
+
+               IASTName functionName = findCalledFunctionName((IASTFunctionCallExpression) node);
+               if(functionName != null) {
+                       IBinding binding = functionName.resolveBinding();
+                       if (binding instanceof CPPFunction) {
+                               CPPFunction function =  (CPPFunction) binding;
+                               if(function.getDefinition() != null) {
+                                       IASTNode parent = function.getDefinition().getParent();
+                                       if(parent instanceof CPPASTFunctionDefinition) {
+                                               CPPASTFunctionDefinition definition = (CPPASTFunctionDefinition) parent;
+                                               return definition.getDeclarator().getPointerOperators().length > 0;
+                                       }
+                               } else if(hasDeclaration(function)) {
+                                       IASTNode parent = function.getDeclarations()[0].getParent();
+                                       if (parent instanceof CPPASTSimpleDeclaration) {
+                                               CPPASTSimpleDeclaration declaration = (CPPASTSimpleDeclaration) parent;
+                                               return declaration.getDeclarators().length > 0 && declaration.getDeclarators()[0].getPointerOperators().length > 0;
+                                       }
+                               }
+                       }
+               }
+               return false;
+       }
+
+       private static boolean hasDeclaration(CPPFunction function) {
+               return function != null && function.getDeclarations() != null && function.getDeclarations().length > 0;
+       }
+       
+       @Override
+       public IASTNode createReturnAssignment(IASTNode node, IASTExpressionStatement stmt, IASTExpression callExpression) {
+               return callExpression;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionComposite.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionComposite.java
new file mode 100644 (file)
index 0000000..83d3a81
--- /dev/null
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractfunction;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.internal.ui.refactoring.MethodContext;
+import org.eclipse.cdt.internal.ui.refactoring.dialogs.NameAndVisibilityComposite;
+import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
+
+public class ExtractFunctionComposite extends Composite {
+       
+       private Button replaceSimilar;
+       private ChooserComposite comp;
+       private NameAndVisibilityComposite nameVisiComp;
+       private final ExtractFunctionInformation info;
+       
+       public ExtractFunctionComposite(Composite parent, ExtractFunctionInformation info, ExtractFunctionInputPage ip) {
+               super(parent, SWT.NONE);
+               this.info = info;
+               setLayout(new GridLayout());
+
+               createNewMethodNameComposite(this);
+
+               Group returnGroup = createReturnGroup(nameVisiComp);
+               createReturnValueChooser(returnGroup, info, ip);                
+
+               createReplaceCheckBox(nameVisiComp);
+               
+               if (info.getMethodContext().getType() == MethodContext.ContextType.METHOD) {
+                       visibilityPanelSetVisible(true);
+               }else {
+                       visibilityPanelSetVisible(false);
+               }
+               layout();
+       }
+
+
+       private Group createReturnGroup(Composite parent) {
+               Group returnGroup = new Group(parent,SWT.NONE);
+       
+               returnGroup.setText(Messages.ExtractFunctionComposite_ReturnValue); 
+               returnGroup.setLayout(new GridLayout());
+               GridData gridData = new GridData();
+               gridData.horizontalAlignment = GridData.FILL;
+               gridData.grabExcessHorizontalSpace = true;
+               returnGroup.setLayoutData(gridData);
+               return returnGroup;
+       }
+
+
+       private void createReturnValueChooser(Composite parent, ExtractFunctionInformation info, ExtractFunctionInputPage ip) {
+               
+               GridData gridData = new GridData();
+               gridData.horizontalAlignment = GridData.FILL;
+               gridData.grabExcessHorizontalSpace = true;
+               comp = new ChooserComposite(parent, info, ip);
+               comp.setLayoutData(gridData);
+               comp.redraw();
+
+       }
+
+
+       public Text getMethodNameText() {
+               return nameVisiComp.getConstantNameText();
+       }
+       
+       public Button getReplaceSimilarButton() {
+               return replaceSimilar;
+       }
+       
+       public void visibilityPanelSetVisible(boolean visible) {
+               nameVisiComp.visibilityPanelsetVisible(visible);
+       }
+
+       private void createNewMethodNameComposite(Composite parent) {
+
+               String label;
+               if (info.getMethodContext().getType() == MethodContext.ContextType.METHOD) {
+                       label = Messages.ExtractFunctionComposite_MethodName;
+               }else {
+                       label = Messages.ExtractFunctionComposite_FunctionName;
+               }
+               nameVisiComp = new NameAndVisibilityComposite(parent, label, VisibilityEnum.v_private, "");  //$NON-NLS-1$
+               GridData gridData = new GridData();
+               gridData.horizontalAlignment = GridData.FILL;
+               gridData.grabExcessHorizontalSpace = true;
+               nameVisiComp.setLayoutData(gridData);
+               final Button virtual = new Button(nameVisiComp, SWT.CHECK);
+               virtual.setText(Messages.ExtractFunctionComposite_Virtual);
+               virtual.addSelectionListener(new SelectionAdapter() {
+
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               info.setVirtual(virtual.getSelection());
+                       }
+                       
+               });
+       }
+
+       
+       private void createReplaceCheckBox(Composite parent) {
+               replaceSimilar = new Button(parent, SWT.CHECK | SWT.LEFT);
+               GridData buttonLayoutData = new GridData(SWT.None);
+               buttonLayoutData.verticalIndent = 5;
+               replaceSimilar.setLayoutData(buttonLayoutData);
+               replaceSimilar.setText(Messages.ExtractFunctionComposite_ReplaceDuplicates);
+       }
+
+       
+       public ChooserComposite getReturnChooser() {
+               return comp;
+       }
+       
+       public String getMethodName(){
+               return nameVisiComp.getConstantNameText().getText();
+       }
+
+
+       public Composite getVisibiltyGroup() {
+               
+               return nameVisiComp.getVisibiltyGroup();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionInformation.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionInformation.java
new file mode 100644 (file)
index 0000000..b32a19b
--- /dev/null
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractfunction;
+
+import java.util.ArrayList;
+
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
+
+import org.eclipse.cdt.internal.ui.refactoring.MethodContext;
+import org.eclipse.cdt.internal.ui.refactoring.NodeContainer.NameInformation;
+import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
+
+
+public class ExtractFunctionInformation {
+
+       public final int VISIBILITY_PRIVATE = 1;
+       public final int VISIBILITY_PROTECTED = 3;
+       public final int VISIBILITY_PUBLIC = 2;
+       
+       private VisibilityEnum visibility = VisibilityEnum.v_private;
+       private String methodName;
+       private boolean replaceDuplicates;
+       private ArrayList<NameInformation> allAfterUsedNames;
+       private ArrayList<NameInformation> allUsedNames;
+       private NameInformation inScopeDeclaredVariable; 
+       private NameInformation returnVariable;
+       private ICPPASTFunctionDeclarator declarator;
+       private MethodContext context;
+       private boolean isExtractExpression;
+       private boolean virtual;
+
+       /**
+        * Returns the function declarator of the method / function from were the statements
+        * are extacted from.
+        * @return the function declarator or null
+        */
+       public ICPPASTFunctionDeclarator getDeclarator() {
+               return declarator;
+       }
+
+       public void setDeclarator(ICPPASTFunctionDeclarator declarator) {
+               this.declarator = declarator;
+       }
+
+       public String getMethodName() {
+               return methodName;
+       }
+
+       public void setMethodName(String methodName) {
+               this.methodName = methodName;
+       }
+
+       public boolean isReplaceDuplicates() {
+               return replaceDuplicates;
+       }
+
+       public void setReplaceDuplicates(boolean replaceDuplicates) {
+               this.replaceDuplicates = replaceDuplicates;
+       }
+
+       public ArrayList<NameInformation> getAllAfterUsedNames() {
+               if(allAfterUsedNames == null){
+                       allAfterUsedNames = new ArrayList<NameInformation>();
+                       for (NameInformation name : getAllUsedNames()) {
+                               if(name.isReference()||name.isReturnValue()){
+                                       allAfterUsedNames.add(name);
+                               }
+                       }
+               }
+               
+               return allAfterUsedNames;
+       }
+
+       public void setAllAfterUsedNames(ArrayList<NameInformation> allAfterUsedNames) {
+               this.allAfterUsedNames = allAfterUsedNames;
+       }
+
+       public NameInformation getReturnVariable() {
+               return returnVariable;
+       }
+
+       public void setReturnVariable(NameInformation returnVariable) {
+               if(returnVariable != null) {
+                       returnVariable.setUserSetIsReturnValue(true);
+               }
+               this.returnVariable = returnVariable;
+       }
+
+       public NameInformation getInScopeDeclaredVariable() {
+               return inScopeDeclaredVariable;
+       }
+
+       public void setInScopeDeclaredVariable(NameInformation inScopeDeclaredVariable) {
+               this.inScopeDeclaredVariable = inScopeDeclaredVariable;
+       }
+
+       public ArrayList<NameInformation> getAllUsedNames() {
+               return allUsedNames;
+       }
+
+       public void setAllUsedNames(ArrayList<NameInformation> allUsedNames) {
+               this.allUsedNames = allUsedNames;
+       }
+
+       public VisibilityEnum getVisibility() {
+               return visibility;
+       }
+
+       public void setVisibility(VisibilityEnum visibility) {
+               this.visibility = visibility;
+       }
+
+       public MethodContext getMethodContext() {
+               return context;
+       }
+
+       public void setMethodContext(MethodContext context) {
+               this.context = context;
+       }
+
+       public boolean isExtractExpression() {
+               return isExtractExpression;
+       }
+
+       public void setExtractExpression(boolean isExtractExpression) {
+               this.isExtractExpression = isExtractExpression;
+       }
+
+       public boolean isVirtual() {
+               return virtual;
+       }
+
+       public void setVirtual(boolean isVirtual) {
+               this.virtual = isVirtual;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionInputPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionInputPage.java
new file mode 100644 (file)
index 0000000..c877b46
--- /dev/null
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ * IBM Corporation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractfunction;
+
+import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+import org.eclipse.cdt.internal.ui.refactoring.utils.IdentifierHelper;
+import org.eclipse.cdt.internal.ui.refactoring.utils.IdentifierResult;
+import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
+
+
+public class ExtractFunctionInputPage extends UserInputWizardPage {
+
+       private final ExtractFunctionInformation info;
+       private ExtractFunctionComposite comp;
+       protected final String NO_NAME_ERROR_LABEL = Messages.ExtractFunctionInputPage_EnterName; 
+
+
+       public ExtractFunctionInputPage(String name, ExtractFunctionInformation info) {
+               super(name);
+               this.info = info;
+       }
+
+       public void createControl(final Composite parent) {
+
+               comp = new ExtractFunctionComposite(parent, info, this);
+               
+               setPageComplete(false);
+               
+               comp.getMethodNameText().addModifyListener(new ModifyListener() {
+
+                       public void modifyText(ModifyEvent e) {
+                               info.setMethodName(comp.getMethodName());       
+                               checkName();
+                       }
+                       
+               });
+               
+               
+               for (Control buttons : comp.getVisibiltyGroup().getChildren()) {
+                       buttons.addMouseListener(new MouseAdapter() {
+
+                               @Override
+                               public void mouseUp(MouseEvent e) {
+                                       String text = ((Button)e.getSource()).getText();
+                                       visibilityChange(text);
+                               }                               
+                       });
+               }
+               
+               comp.getReplaceSimilarButton().addSelectionListener(new SelectionListener(){
+
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               info.setReplaceDuplicates(comp.getReplaceSimilarButton().isEnabled());  
+                       }
+
+                       public void widgetSelected(SelectionEvent e) {
+                               widgetDefaultSelected(e);               
+                       }
+                       
+               });
+               
+               setControl(comp);
+               
+       }
+
+       protected void visibilityChange(String text) {
+               info.setVisibility(VisibilityEnum.getEnumForStringRepresentation(text));
+               
+       }
+
+       private void checkName() {
+
+               String methodName = comp.getMethodName();
+               IdentifierResult result = IdentifierHelper.checkIdentifierName(methodName);
+               if(result.isCorrect()){
+                       setErrorMessage(null);
+                       setPageComplete(true);
+               }
+               else{
+                       setErrorMessage(Messages.ExtractFunctionInputPage_CheckFunctionName + " " + result.getMessage());  //$NON-NLS-1$
+                       setPageComplete(false);
+               }
+       }
+       
+       public void errorWithAfterUsedVariable(String variableUsedAfterBlock ) {
+               if(variableUsedAfterBlock == null) {
+                       setErrorMessage(null);
+                       checkName();    
+               }else {
+                       setErrorMessage("The parameter '" + variableUsedAfterBlock + "' " + Messages.ExtractFunctionInputPage_1);  //$NON-NLS-1$ //$NON-NLS-2$
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoring.java
new file mode 100644 (file)
index 0000000..650042f
--- /dev/null
@@ -0,0 +1,891 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *     Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractfunction;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Vector;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.text.edits.TextEditGroup;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
+import org.eclipse.cdt.core.dom.ast.IASTComment;
+import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTNode.CopyStyle;
+import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
+import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTStatement;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IField;
+import org.eclipse.cdt.core.dom.ast.INodeFactory;
+import org.eclipse.cdt.core.dom.ast.IParameter;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.model.ICProject;
+
+import org.eclipse.cdt.internal.core.dom.parser.c.CASTBinaryExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTBinaryExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCompoundStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDeclarationStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDeclarator;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTEqualsInitializer;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTExpressionStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionCallExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDefinition;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTQualifiedName;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTReturnStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclaration;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTemplateDeclaration;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPNodeFactory;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVariableReadWriteFlags;
+import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
+
+import org.eclipse.cdt.internal.ui.refactoring.AddDeclarationNodeToClassChange;
+import org.eclipse.cdt.internal.ui.refactoring.CRefactoring;
+import org.eclipse.cdt.internal.ui.refactoring.CRefactoringDescription;
+import org.eclipse.cdt.internal.ui.refactoring.Container;
+import org.eclipse.cdt.internal.ui.refactoring.MethodContext;
+import org.eclipse.cdt.internal.ui.refactoring.MethodContext.ContextType;
+import org.eclipse.cdt.internal.ui.refactoring.ModificationCollector;
+import org.eclipse.cdt.internal.ui.refactoring.NodeContainer;
+import org.eclipse.cdt.internal.ui.refactoring.NodeContainer.NameInformation;
+import org.eclipse.cdt.internal.ui.refactoring.utils.ASTHelper;
+import org.eclipse.cdt.internal.ui.refactoring.utils.CPPASTAllVisitor;
+import org.eclipse.cdt.internal.ui.refactoring.utils.NodeHelper;
+import org.eclipse.cdt.internal.ui.refactoring.utils.SelectionHelper;
+
+public class ExtractFunctionRefactoring extends CRefactoring {
+       public static final String ID = "org.eclipse.cdt.internal.ui.refactoring.extractfunction.ExtractFunctionRefactoring"; //$NON-NLS-1$
+
+       static final Integer NULL_INTEGER = Integer.valueOf(0);
+       static final char[] ZERO= "0".toCharArray(); //$NON-NLS-1$
+
+       NodeContainer container;
+       final ExtractFunctionInformation info;
+
+       final Map<String, Integer> names;
+       final Container<Integer> namesCounter;
+       final Container<Integer> trailPos;
+       private final Container<Integer> returnNumber;
+
+       protected boolean hasNameResolvingForSimilarError = false;
+
+       HashMap<String, Integer> nameTrail;
+
+       private ExtractedFunctionConstructionHelper extractedFunctionConstructionHelper;
+       private final INodeFactory factory = CPPNodeFactory.getDefault();
+
+       public ExtractFunctionRefactoring(IFile file, ISelection selection,
+                       ExtractFunctionInformation info, ICProject project) {
+               super(file, selection, null, project);
+               this.info = info;
+               name = Messages.ExtractFunctionRefactoring_ExtractFunction;
+               names = new HashMap<String, Integer>();
+               namesCounter = new Container<Integer>(NULL_INTEGER);
+               trailPos = new Container<Integer>(NULL_INTEGER);
+               returnNumber = new Container<Integer>(NULL_INTEGER);
+       }
+
+       @Override
+       public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
+       throws CoreException, OperationCanceledException {
+               SubMonitor sm = SubMonitor.convert(pm, 10);
+               try {
+                       lockIndex();
+
+                       try {
+                               RefactoringStatus status = super.checkInitialConditions(sm.newChild(6));
+                               if (status.hasError()) {
+                                       return status;
+                               }
+
+                               container = findExtractableNodes();
+                               sm.worked(1);
+
+                               if (isProgressMonitorCanceld(sm, initStatus))
+                                       return initStatus;
+
+                               checkForNonExtractableStatements(container, initStatus);
+                               sm.worked(1);
+
+                               if (isProgressMonitorCanceld(sm, initStatus))
+                                       return initStatus;
+
+                               container.findAllNames();
+                               markWriteAccess();
+                               sm.worked(1);
+
+                               if (isProgressMonitorCanceld(sm, initStatus))
+                                       return initStatus;
+
+                               container.getAllAfterUsedNames();
+                               info.setAllUsedNames(container.getUsedNamesUnique());
+
+                               if (container.size() < 1) {
+                                       initStatus.addFatalError(Messages.ExtractFunctionRefactoring_NoStmtSelected);
+                                       sm.done();
+                                       return initStatus;
+                               }
+
+                               if (container.getAllDeclaredInScope().size() > 1) {
+                                       initStatus.addFatalError(Messages.ExtractFunctionRefactoring_TooManySelected);
+                               } else if (container.getAllDeclaredInScope().size() == 1) {
+                                       info.setInScopeDeclaredVariable(container.getAllDeclaredInScope().get(0));
+                               }
+
+                               extractedFunctionConstructionHelper =
+                                               ExtractedFunctionConstructionHelper.createFor(container.getNodesToWrite());
+
+                               boolean isExtractExpression = container.getNodesToWrite().get(0) instanceof IASTExpression;
+                               info.setExtractExpression(isExtractExpression);
+
+                               info.setDeclarator(getDeclaration(container.getNodesToWrite().get(0)));
+                               MethodContext context = NodeHelper.findMethodContext(container.getNodesToWrite().get(0), getIndex());
+                               info.setMethodContext(context);
+
+                               if (info.getInScopeDeclaredVariable() != null) {
+                                       info.getInScopeDeclaredVariable().setUserSetIsReturnValue(true);
+                               }
+                               for (int i = 0; i < info.getAllUsedNames().size(); i++) {
+                                       if (!info.getAllUsedNames().get(i).isDeclarationInScope()) {
+                                               NameInformation name = info.getAllUsedNames().get(i);
+                                               if (!name.isReturnValue()) {
+                                                       name.setUserSetIsReference(name.isReference());
+                                               }
+                                       }
+                               }
+                               sm.done();
+                       } finally {
+                               unlockIndex();
+                       }
+               } catch (InterruptedException e) {
+                       Thread.currentThread().interrupt();
+               }
+               return initStatus;
+       }
+
+       private void markWriteAccess() throws CoreException {
+               List<NameInformation> paras = container.getNames();
+
+               for (NameInformation name : paras) {
+                       int flag = CPPVariableReadWriteFlags.getReadWriteFlags(name.getName());
+                       if ((flag & PDOMName.WRITE_ACCESS) != 0) {
+                               name.setWriteAccess(true);
+                       }
+               }
+       }
+
+       private void checkForNonExtractableStatements(NodeContainer cont, RefactoringStatus status) {
+               NonExtractableStmtFinder vis = new NonExtractableStmtFinder();
+               for (IASTNode node : cont.getNodesToWrite()) {
+                       node.accept(vis);
+                       if (vis.containsContinue()) {
+                               initStatus.addFatalError(Messages.ExtractFunctionRefactoring_Error_Continue);
+                               break;
+                       } else if (vis.containsBreak()) {
+                               initStatus.addFatalError(Messages.ExtractFunctionRefactoring_Error_Break);
+                               break;
+                       }
+               }
+
+               ReturnStatementFinder rFinder = new ReturnStatementFinder();
+               for (IASTNode node : cont.getNodesToWrite()) {
+                       node.accept(rFinder);
+                       if (rFinder.containsReturn()) {
+                               initStatus.addFatalError(Messages.ExtractFunctionRefactoring_Error_Return);
+                               break;
+                       }
+               }
+       }
+
+       private ICPPASTFunctionDeclarator getDeclaration(IASTNode node) {
+               while (node != null && !(node instanceof IASTFunctionDefinition)) {
+                       node = node.getParent();
+               }
+               if (node != null) {
+                       IASTFunctionDeclarator declarator = ((IASTFunctionDefinition) node).getDeclarator();
+                       if (declarator instanceof ICPPASTFunctionDeclarator) {
+                               return (ICPPASTFunctionDeclarator) declarator;
+                       }
+               }
+               return null;
+       }
+
+       @Override
+       public RefactoringStatus checkFinalConditions(IProgressMonitor pm)
+       throws CoreException, OperationCanceledException {
+               RefactoringStatus finalConditions = null;
+               try {
+                       lockIndex();
+                       try {
+                               finalConditions = super.checkFinalConditions(pm);
+
+                               final IASTName astMethodName = new CPPASTName(info.getMethodName().toCharArray());
+                               MethodContext context = NodeHelper.findMethodContext(container.getNodesToWrite().get(0), getIndex());
+
+                               if (context.getType() == ContextType.METHOD && !context.isInline()) {
+                                       ICPPASTCompositeTypeSpecifier classDeclaration =
+                                                       (ICPPASTCompositeTypeSpecifier) context.getMethodDeclaration().getParent();
+                                       IASTSimpleDeclaration methodDeclaration = getDeclaration(astMethodName);
+
+                                       if (isMethodAllreadyDefined(methodDeclaration, classDeclaration, getIndex())) {
+                                               finalConditions.addError(Messages.ExtractFunctionRefactoring_NameInUse);
+                                               return finalConditions;
+                                       }
+                               }
+                               for (NameInformation name : info.getAllUsedNames()) {
+                                       if (name.isUserSetIsReturnValue()) {
+                                               info.setReturnVariable(name);
+                                       }
+                               }
+                       } finally {
+                               unlockIndex();
+                       }
+               } catch (InterruptedException e) {
+                       Thread.currentThread().interrupt();
+               }
+               return finalConditions;
+       }
+
+       @Override
+       protected void collectModifications(IProgressMonitor pm,
+                       ModificationCollector collector) throws CoreException,
+                       OperationCanceledException {
+               try {
+                       lockIndex();
+                       try {
+                               final IASTName astMethodName = new CPPASTName(info.getMethodName().toCharArray());
+
+                               MethodContext context = NodeHelper.findMethodContext(container.getNodesToWrite().get(0), getIndex());
+
+                               // Create Declaration in Class
+                               if (context.getType() == ContextType.METHOD && !context.isInline()) {
+                                       createMethodDeclaration(astMethodName, context, collector);
+                               }
+                               // Create Method Definition
+                               IASTNode firstNode = container.getNodesToWrite().get(0);
+                               IPath implPath = new Path(firstNode.getContainingFilename());
+                               final IFile implementationFile =
+                                               ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(implPath);
+
+                               createMethodDefinition(astMethodName, context, firstNode, implementationFile,
+                                               collector);
+
+                               createMethodCalls(astMethodName, implementationFile, context, collector);
+                       } finally {
+                               unlockIndex();
+                       }
+               } catch (InterruptedException e) {
+                       Thread.currentThread().interrupt();
+               }
+       }
+
+       private void createMethodCalls(final IASTName astMethodName,
+                       final IFile implementationFile, MethodContext context,
+                       ModificationCollector collector) throws CoreException {
+               String title;
+               if (context.getType() == MethodContext.ContextType.METHOD) {
+                       title = Messages.ExtractFunctionRefactoring_CreateMethodCall;
+               } else {
+                       title = Messages.ExtractFunctionRefactoring_CreateFunctionCall;
+               }
+
+               IASTNode methodCall = getMethodCall(astMethodName);
+
+               IASTNode firstNodeToWrite = container.getNodesToWrite().get(0);
+               ASTRewrite rewriter = collector.rewriterForTranslationUnit(
+                               firstNodeToWrite.getTranslationUnit());
+               TextEditGroup editGroup = new TextEditGroup(title);
+               if (methodCall instanceof IASTDeclaration){
+                       CPPASTDeclarationStatement declarationStatement = new CPPASTDeclarationStatement((IASTDeclaration) methodCall);
+                       methodCall = declarationStatement;
+               }
+               insertCallintoTree(methodCall, container.getNodesToWrite(), rewriter, editGroup);
+
+               if (info.isReplaceDuplicates()) {
+                       replaceSimilar(collector, astMethodName, implementationFile, context.getType());
+               }
+
+               for (IASTNode node : container.getNodesToWrite()) {
+                       if (node != firstNodeToWrite) {
+                               rewriter.remove(node, editGroup);
+                       }
+               }               
+       }
+
+       private void insertCallintoTree(IASTNode methodCall, List<IASTNode> list,
+                       ASTRewrite rewriter, TextEditGroup editGroup) {
+               IASTNode firstNode = list.get(0);
+               if (list.size() > 1 && firstNode.getParent() instanceof IASTBinaryExpression &&
+                               firstNode.getParent().getParent() instanceof IASTBinaryExpression) {
+                       IASTBinaryExpression parent = (IASTBinaryExpression) firstNode.getParent();
+                       IASTExpression leftSubTree = parent.getOperand1();
+                       int op = parent.getOperator();
+                       IASTBinaryExpression newParentNode = new CPPASTBinaryExpression();
+                       IASTBinaryExpression rootBinExp = getRootBinExp(parent, list);
+                       newParentNode.setParent(rootBinExp.getParent());
+                       newParentNode.setOperand1(leftSubTree.copy(CopyStyle.withLocations));
+                       newParentNode.setOperator(op);
+                       newParentNode.setOperand2((IASTExpression) methodCall);
+                       rewriter.replace(rootBinExp, newParentNode, editGroup);
+               } else {
+                       rewriter.replace(firstNode, methodCall, editGroup);
+               }
+       }
+
+       private IASTBinaryExpression getRootBinExp(IASTBinaryExpression binExp, List<IASTNode> nodeList) {
+               while(binExp.getParent() instanceof IASTBinaryExpression && nodeList.contains(((IASTBinaryExpression) binExp.getParent()).getOperand2())) {
+                       binExp = (IASTBinaryExpression) binExp.getParent();
+               }
+               return binExp;
+       }
+
+       private void createMethodDefinition(final IASTName astMethodName,
+                       MethodContext context, IASTNode firstNode,
+                       final IFile implementationFile, ModificationCollector collector) {
+               IASTFunctionDefinition node = NodeHelper.findFunctionDefinitionInAncestors(firstNode); 
+               if (node != null) { 
+                       String title;
+                       if (context.getType() == MethodContext.ContextType.METHOD) {
+                               title = Messages.ExtractFunctionRefactoring_CreateMethodDef;
+                       } else {
+                               title = Messages.ExtractFunctionRefactoring_CreateFunctionDef;
+                       }
+
+                       ASTRewrite rewriter = collector.rewriterForTranslationUnit(node.getTranslationUnit());
+                       addMethod(astMethodName, context, rewriter, node, new TextEditGroup(title));
+               }
+       }
+
+       private void createMethodDeclaration(final IASTName astMethodName,
+                       MethodContext context, ModificationCollector collector) {
+               ICPPASTCompositeTypeSpecifier classDeclaration = (ICPPASTCompositeTypeSpecifier) context
+                               .getMethodDeclaration().getParent();
+
+               IASTSimpleDeclaration methodDeclaration = getDeclaration(collector, astMethodName);
+
+               AddDeclarationNodeToClassChange.createChange(classDeclaration, info.getVisibility(),
+                               methodDeclaration, false, collector);
+       }
+
+       private void replaceSimilar(ModificationCollector collector, final IASTName astMethodName,
+                       final IFile implementationFile, final ContextType contextType) {
+               // Find similar code
+               final List<IASTNode> nodesToRewriteWithoutComments = new LinkedList<IASTNode>();
+
+               for (IASTNode node : container.getNodesToWrite()) {
+                       if (!(node instanceof IASTComment)) {
+                               nodesToRewriteWithoutComments.add(node);
+                       }
+               }
+
+               final Vector<IASTNode> initTrail = getTrail(nodesToRewriteWithoutComments);
+               final String title;
+               if (contextType == MethodContext.ContextType.METHOD) {
+                       title = Messages.ExtractFunctionRefactoring_CreateMethodCall;
+               } else {
+                       title = Messages.ExtractFunctionRefactoring_CreateFunctionCall;
+               }
+
+               if (!hasNameResolvingForSimilarError) {
+                       ast.accept(new SimilarFinderVisitor(this, collector, initTrail, implementationFile,
+                                       astMethodName, nodesToRewriteWithoutComments, title));
+               }
+       }
+
+       protected Vector<IASTNode> getTrail(List<IASTNode> stmts) {
+               final Vector<IASTNode> trail = new Vector<IASTNode>();
+               nameTrail = new HashMap<String, Integer>();
+               final Container<Integer> trailCounter = new Container<Integer>(NULL_INTEGER);
+
+               for (IASTNode node : stmts) {
+                       node.accept(new CPPASTAllVisitor() {
+                               @Override
+                               public int visitAll(IASTNode node) {
+                                       if (node instanceof IASTComment) {
+                                               // Visit Comment, but don't add them to the trail
+                                               return super.visitAll(node);
+                                       } else if (node instanceof IASTNamedTypeSpecifier) {
+                                               // Skip if somewhere is a named Type Specifier
+                                               trail.add(node);
+                                               return PROCESS_SKIP;
+                                       } else if (node instanceof IASTName) {
+                                               if (node instanceof ICPPASTConversionName && node instanceof ICPPASTOperatorName
+                                                               && node instanceof ICPPASTTemplateId) {
+                                                       trail.add(node);
+                                                       return super.visitAll(node);
+                                               } else {
+                                                       // Save Name Sequence Number
+                                                       IASTName name = (IASTName) node;
+                                                       TrailName trailName = new TrailName(name);
+                                                       int actCount = trailCounter.getObject().intValue();
+                                                       if (nameTrail.containsKey(name.getRawSignature())) {
+                                                               Integer value = nameTrail.get(name.getRawSignature());
+                                                               actCount = value.intValue();
+                                                       } else {
+                                                               trailCounter.setObject(Integer.valueOf(++actCount));
+                                                               nameTrail.put(name.getRawSignature(), trailCounter.getObject());
+                                                       }
+                                                       trailName.setNameNumber(actCount);
+
+                                                       if (info.getReturnVariable() != null
+                                                                       && info.getReturnVariable().getName().getRawSignature().equals(
+                                                                                       name.getRawSignature())) {
+                                                               returnNumber.setObject(Integer.valueOf(actCount));
+                                                       }
+
+                                                       trail.add(trailName);
+                                                       return PROCESS_SKIP;
+                                               }
+                                       } else {
+                                               trail.add(node);
+                                               return super.visitAll(node);
+                                       }
+                               }
+                       });
+
+               }
+
+               return trail;
+       }
+
+       protected boolean isStatementInTrail(IASTStatement stmt, final Vector<IASTNode> trail, IIndex index) {
+               final Container<Boolean> same = new Container<Boolean>(Boolean.TRUE);
+               final TrailNodeEqualityChecker equalityChecker = new TrailNodeEqualityChecker(names, namesCounter, index);
+
+               stmt.accept(new CPPASTAllVisitor() {
+                       @Override
+                       public int visitAll(IASTNode node) {
+                               int pos = trailPos.getObject().intValue();
+
+                               if (trail.size() <= 0 || pos >= trail.size()) {
+                                       same.setObject(Boolean.FALSE);
+                                       return PROCESS_ABORT;
+                               }
+
+                               if (node instanceof IASTComment) {
+                                       // Visit Comment, but they are not in the trail
+                                       return super.visitAll(node);
+                               }
+
+                               IASTNode trailNode = trail.get(pos);
+                               trailPos.setObject(Integer.valueOf(pos + 1));
+
+                               if (equalityChecker.isEquals(trailNode, node)) {
+                                       if (node instanceof ICPPASTQualifiedName || node instanceof IASTNamedTypeSpecifier) {
+                                               return PROCESS_SKIP;
+                                       } else {
+                                               return super.visitAll(node);
+                                       }
+                               } else {
+                                       same.setObject(new Boolean(false));
+                                       return PROCESS_ABORT;
+                               }
+                       }
+               });
+
+               return same.getObject().booleanValue();
+       }
+
+       private boolean isMethodAllreadyDefined(IASTSimpleDeclaration methodDeclaration,
+                       ICPPASTCompositeTypeSpecifier classDeclaration, IIndex index) {
+               TrailNodeEqualityChecker equalityChecker = new TrailNodeEqualityChecker(
+                               names, namesCounter, index);
+
+               IBinding bind = classDeclaration.getName().resolveBinding();
+               IASTStandardFunctionDeclarator declarator =
+                               (IASTStandardFunctionDeclarator) methodDeclaration.getDeclarators()[0];
+               String name = new String(declarator.getName().toCharArray());
+               if (bind instanceof ICPPClassType) {
+                       ICPPClassType classBind = (ICPPClassType) bind;
+                       IField[] fields = classBind.getFields();
+                       for (IField field : fields) {
+                               if (field.getName().equals(name)) {
+                                       return true;
+                               }
+                       }
+                       ICPPMethod[] methods = classBind.getAllDeclaredMethods();
+                       for (ICPPMethod method : methods) {
+                               if (!method.takesVarArgs() && name.equals(method.getName())) {
+                                       IParameter[] parameters = method.getParameters();
+                                       if (parameters.length == declarator.getParameters().length) {
+                                               for (int i = 0; i < parameters.length; i++) {
+                                                       IASTName[] origParameterName = ast.getDeclarationsInAST(parameters[i]);
+                                                       IASTParameterDeclaration origParameter =
+                                                                       (IASTParameterDeclaration) origParameterName[0].getParent().getParent();
+                                                       IASTParameterDeclaration newParameter = declarator.getParameters()[i];
+
+                                                       // if not the same break;
+                                                       if (!(equalityChecker.isEquals(origParameter.getDeclSpecifier(),
+                                                                       newParameter.getDeclSpecifier()) &&
+                                                                       ASTHelper.samePointers(origParameter.getDeclarator().getPointerOperators(),
+                                                                                       newParameter.getDeclarator().getPointerOperators(),
+                                                                                       equalityChecker))) {
+                                                               break;
+                                                       }
+
+                                                       if (!(i < (parameters.length - 1))) {
+                                                               return true;
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+                       return false;
+               }
+               return true;
+       }
+
+       private void addMethod(IASTName astMethodName, MethodContext context,
+                       ASTRewrite rewriter, IASTNode insertpoint, TextEditGroup group) {
+               ICPPASTQualifiedName qname = new CPPASTQualifiedName();
+               if (context.getType() == ContextType.METHOD) {
+                       if (context.getMethodQName() != null) {
+                               for (int i = 0; i < (context.getMethodQName().getNames().length - 1); i++) {
+                                       qname.addName(new CPPASTName(context.getMethodQName().getNames()[i].toCharArray()));
+                               }
+                       }
+               }
+               qname.addName(astMethodName);
+
+               IASTFunctionDefinition func = new CPPASTFunctionDefinition();
+               func.setParent(ast);
+
+               IASTDeclSpecifier returnType = getReturnType();
+               func.setDeclSpecifier(returnType);
+               
+               IASTStandardFunctionDeclarator createdFunctionDeclarator = extractedFunctionConstructionHelper
+                               .createFunctionDeclarator(qname, info.getDeclarator(), info
+                                               .getReturnVariable(), container.getNodesToWrite(), info
+                                               .getAllUsedNames(), ast.getASTNodeFactory());
+               func.setDeclarator(createdFunctionDeclarator);
+
+               IASTCompoundStatement compound = new CPPASTCompoundStatement();
+               func.setBody(compound);
+               
+               ASTRewrite subRW;
+               if (insertpoint.getParent() instanceof ICPPASTTemplateDeclaration) {
+                       CPPASTTemplateDeclaration templateDeclaration = new CPPASTTemplateDeclaration();
+                       templateDeclaration.setParent(ast);
+                       
+                       for (ICPPASTTemplateParameter templateParameter : ((ICPPASTTemplateDeclaration) insertpoint.getParent()).getTemplateParameters()) {
+                               templateDeclaration.addTemplateParameter(templateParameter.copy(CopyStyle.withLocations));
+                       }
+                       
+                       templateDeclaration.setDeclaration(func);
+                       subRW = rewriter.insertBefore(insertpoint.getParent().getParent(), insertpoint.getParent(),
+                                       templateDeclaration, group);
+               } else {
+                       subRW = rewriter.insertBefore(insertpoint.getParent(), insertpoint, func, group);
+               }
+               
+               extractedFunctionConstructionHelper.constructMethodBody(compound,
+                               container.getNodesToWrite(), subRW, group);
+
+               // Set return value
+               NameInformation returnVariable = info.getReturnVariable();
+               if (returnVariable != null) {
+                       IASTReturnStatement returnStmt = new CPPASTReturnStatement();
+                       if (returnVariable.getDeclaration().getParent() instanceof IASTExpression) {
+                               IASTExpression returnValue = (IASTExpression) returnVariable.getDeclaration().getParent();
+                               returnStmt.setReturnValue(returnValue);
+                       } else {
+                               IASTIdExpression expr = new CPPASTIdExpression();
+                               if (returnVariable.getUserSetName() == null) {
+                                       expr.setName(newName(returnVariable.getName()));
+                               } else {
+                                       expr.setName(new CPPASTName(returnVariable.getUserSetName().toCharArray()));
+                               }
+                               returnStmt.setReturnValue(expr);
+                       }
+                       subRW.insertBefore(compound, null, returnStmt, group);
+               }
+       }
+
+       private IASTName newName(IASTName declaration) {
+               return new CPPASTName(declaration.toCharArray());
+       }
+
+       private IASTDeclSpecifier getReturnType() {
+               IASTNode firstNodeToWrite = container.getNodesToWrite().get(0);
+               NameInformation returnVariable = info.getReturnVariable();
+
+               return extractedFunctionConstructionHelper.determineReturnType(firstNodeToWrite, returnVariable);
+       }
+
+       protected IASTNode getMethodCall(IASTName astMethodName,
+                       Map<String, Integer> trailNameTable,
+                       Map<String, Integer> similarNameTable, NodeContainer myContainer,
+                       NodeContainer mySimilarContainer) {
+               IASTExpressionStatement stmt = new CPPASTExpressionStatement();
+               IASTFunctionCallExpression callExpression = new CPPASTFunctionCallExpression();
+               IASTIdExpression idExpression = new CPPASTIdExpression();
+               idExpression.setName(astMethodName);
+               List<IASTInitializerClause> args = new ArrayList<IASTInitializerClause>();
+
+               Vector<IASTName> declarations = new Vector<IASTName>();
+               IASTName retName = null;
+               boolean theRetName = false;
+
+               for (NameInformation nameInfo : myContainer.getNames()) {
+                       Integer trailSeqNumber = trailNameTable.get(nameInfo.getDeclaration().getRawSignature());
+                       String orgName = null;
+                       for (Entry<String, Integer> entry : similarNameTable.entrySet()) {
+                               if (entry.getValue().equals(trailSeqNumber)) {
+                                       orgName = entry.getKey();
+                                       if (info.getReturnVariable() != null
+                                                       && trailSeqNumber.equals(returnNumber.getObject())) {
+                                               theRetName = true;
+                                       }
+                               }
+                       }
+
+                       if (orgName != null) {
+                               boolean found = false;
+                               for (NameInformation simNameInfo : mySimilarContainer.getNames()) {
+                                       if (orgName.equals(simNameInfo.getDeclaration()
+                                                       .getRawSignature())) {
+                                               addAParameterIfPossible(args, declarations,
+                                                               simNameInfo);
+                                               found = true;
+
+                                               if (theRetName) {
+                                                       theRetName = false;
+                                                       retName = new CPPASTName(
+                                                                       simNameInfo.getDeclaration().getRawSignature().toCharArray());
+                                               }
+                                       }
+                               }
+
+                               if (!found) {
+                                       // should be a field, use the old name
+                                       IASTIdExpression expression = new CPPASTIdExpression();
+                                       CPPASTName fieldName = new CPPASTName(orgName.toCharArray());
+                                       expression.setName(fieldName);
+                                       args.add(expression);
+
+                                       if (theRetName) {
+                                               theRetName = false;
+                                               retName = fieldName;
+                                       }
+                               }
+                       }
+               }
+
+               callExpression.setArguments(args.toArray(new IASTInitializerClause[args.size()]));
+               callExpression.setFunctionNameExpression(idExpression);
+
+               if (info.getReturnVariable() == null) {
+                       return getReturnAssignment(stmt, callExpression);
+               }
+               return getReturnAssignment(stmt, callExpression, retName);
+       }
+
+       private IASTNode getMethodCall(IASTName astMethodName) {
+               IASTExpressionStatement stmt = new CPPASTExpressionStatement();
+
+               IASTFunctionCallExpression callExpression = new CPPASTFunctionCallExpression();
+               IASTIdExpression idExpression = new CPPASTIdExpression();
+               idExpression.setName(new CPPASTName(astMethodName.toCharArray()));
+               List<IASTInitializerClause> args = getCallParameters();
+               callExpression.setArguments(args.toArray(new IASTInitializerClause[args.size()]));
+               callExpression.setFunctionNameExpression(idExpression);
+
+               if (info.getReturnVariable() == null) {
+                       return getReturnAssignment(stmt, callExpression);
+               }
+               IASTName retname = newName(info.getReturnVariable().getName());
+               return getReturnAssignment(stmt, callExpression, retname);
+       }
+
+       private IASTNode getReturnAssignment(IASTExpressionStatement stmt,
+                       IASTFunctionCallExpression callExpression, IASTName retname) {
+               if (info.getReturnVariable().equals(info.getInScopeDeclaredVariable())) {
+                       IASTSimpleDeclaration orgDecl = NodeHelper.findSimpleDeclarationInParents(info
+                                       .getReturnVariable().getDeclaration());
+                       IASTSimpleDeclaration decl = new CPPASTSimpleDeclaration();
+
+                       decl.setDeclSpecifier(orgDecl.getDeclSpecifier().copy(CopyStyle.withLocations));
+
+                       IASTDeclarator declarator = new CPPASTDeclarator();
+
+                       declarator.setName(retname);
+
+                       for (IASTPointerOperator pointer : orgDecl.getDeclarators()[0].getPointerOperators()) {
+                               declarator.addPointerOperator(pointer.copy(CopyStyle.withLocations));
+                       }
+
+                       IASTEqualsInitializer initializer = new CPPASTEqualsInitializer();
+                       initializer.setInitializerClause(callExpression);
+                       declarator.setInitializer(initializer);
+
+                       decl.addDeclarator(declarator);
+
+                       return decl;
+               }
+               IASTBinaryExpression binaryExpression = new CASTBinaryExpression();
+               binaryExpression.setOperator(IASTBinaryExpression.op_assign);
+               IASTIdExpression nameExpression = new CPPASTIdExpression();
+
+               nameExpression.setName(retname);
+               binaryExpression.setOperand1(nameExpression);
+               binaryExpression.setOperand2(callExpression);
+
+               return getReturnAssignment(stmt, binaryExpression);
+       }
+
+       private IASTNode getReturnAssignment(IASTExpressionStatement stmt,
+                       IASTExpression callExpression) {
+               IASTNode node = container.getNodesToWrite().get(0);
+               return extractedFunctionConstructionHelper.createReturnAssignment(node,
+                               stmt, callExpression);
+       }
+       
+       private IASTSimpleDeclaration getDeclaration(IASTName name) {
+               IASTSimpleDeclaration simpleDecl = new CPPASTSimpleDeclaration();
+               IASTStandardFunctionDeclarator declarator =
+                               extractedFunctionConstructionHelper.createFunctionDeclarator(name,
+                                               info.getDeclarator(), info.getReturnVariable(),
+                                               container.getNodesToWrite(), info.getAllUsedNames(), ast.getASTNodeFactory());
+               simpleDecl.addDeclarator(declarator);
+               return simpleDecl;
+       }
+
+       private IASTSimpleDeclaration getDeclaration(ModificationCollector collector,IASTName name) {
+               IASTDeclSpecifier declSpec = getReturnType();
+               IASTSimpleDeclaration simpleDecl = factory.newSimpleDeclaration(declSpec);
+               if (info.isVirtual() && declSpec instanceof ICPPASTDeclSpecifier) {
+                       ((ICPPASTDeclSpecifier)declSpec).setVirtual(true);
+               }
+               simpleDecl.setParent(ast);
+               IASTStandardFunctionDeclarator declarator = extractedFunctionConstructionHelper
+                               .createFunctionDeclarator(name, info.getDeclarator(), info
+                                               .getReturnVariable(), container.getNodesToWrite(), info
+                                               .getAllUsedNames(), ast.getASTNodeFactory());
+               simpleDecl.addDeclarator(declarator);
+               return simpleDecl;
+       }
+
+       private NodeContainer findExtractableNodes() {
+               final NodeContainer container = new NodeContainer();
+               ast.accept(new ASTVisitor() {
+                       {
+                               shouldVisitStatements = true;
+                               shouldVisitExpressions = true;
+                       }
+
+                       @Override
+                       public int visit(IASTStatement stmt) {
+                               if ( SelectionHelper.isSelectedFile(region, stmt, file)) {
+                                       container.add(stmt);
+                                       return PROCESS_SKIP;
+                               }
+                               return super.visit(stmt);
+                       }
+
+                       @Override
+                       public int visit(IASTExpression expression) {
+                               if (SelectionHelper.isSelectedFile(region, expression, file)) {
+                                       container.add(expression);
+                                       return PROCESS_SKIP;
+                               }
+                               return super.visit(expression);
+                       }
+               });
+               return container;
+       }
+
+       public List<IASTInitializerClause> getCallParameters() {
+               List<IASTInitializerClause> args = new ArrayList<IASTInitializerClause>();
+               Vector<IASTName> declarations = new Vector<IASTName>();
+               for (NameInformation nameInf : container.getNames()) {
+                       addAParameterIfPossible(args, declarations, nameInf);
+               }
+               return args;
+       }
+
+       private void addAParameterIfPossible(List<IASTInitializerClause> args,
+                       Vector<IASTName> declarations, NameInformation nameInf) {
+               if (!nameInf.isDeclarationInScope()) {
+                       IASTName declaration = nameInf.getDeclaration();
+                       if (!declarations.contains(declaration)) {
+                               declarations.add(declaration);
+                               IASTIdExpression expression = new CPPASTIdExpression();
+                               expression.setName(newName(declaration));
+                               args.add(expression);
+                       }
+               }
+       }
+
+       @Override
+       protected RefactoringDescriptor getRefactoringDescriptor() {
+               Map<String, String> arguments = getArgumentMap();
+               RefactoringDescriptor desc = new ExtractFunctionRefactoringDescription( project.getProject().getName(), "Extract Method Refactoring", "Create method " + info.getMethodName(), arguments);  //$NON-NLS-1$//$NON-NLS-2$
+               return desc;
+       }
+
+       private Map<String, String> getArgumentMap() {
+               Map<String, String> arguments = new HashMap<String, String>();
+               arguments.put(CRefactoringDescription.FILE_NAME, file.getLocationURI().toString());
+               arguments.put(CRefactoringDescription.SELECTION, region.getOffset() + "," + region.getLength()); //$NON-NLS-1$
+               arguments.put(ExtractFunctionRefactoringDescription.NAME, info.getMethodName());
+               arguments.put(ExtractFunctionRefactoringDescription.VISIBILITY, info.getVisibility().toString());
+               arguments.put(ExtractFunctionRefactoringDescription.REPLACE_DUBLICATES, Boolean.toString(info.isReplaceDuplicates()));
+               return arguments;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringContribution.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringContribution.java
new file mode 100644 (file)
index 0000000..344b327
--- /dev/null
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ * Institute for Software (IFS)- initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractfunction;
+
+import java.util.Map;
+
+import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
+
+import org.eclipse.cdt.internal.ui.refactoring.CRefactoringContribution;
+
+/**
+ * @author Emanuel Graf IFS
+ *
+ */
+public class ExtractFunctionRefactoringContribution extends CRefactoringContribution {
+
+       @SuppressWarnings({ "unchecked", "rawtypes" })
+       @Override
+       public RefactoringDescriptor createDescriptor(String id, String project, String description,
+                       String comment, Map arguments, int flags) throws IllegalArgumentException {
+               if(id.equals(ExtractFunctionRefactoring.ID)) {
+                       return new ExtractFunctionRefactoringDescription(project, description, comment, arguments);
+               }else {
+                       return null;
+               }
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringDescription.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringDescription.java
new file mode 100644 (file)
index 0000000..ab64145
--- /dev/null
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ * Institute for Software (IFS)- initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractfunction;
+
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ltk.core.refactoring.Refactoring;
+import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+
+import org.eclipse.cdt.core.model.ICProject;
+
+import org.eclipse.cdt.internal.ui.refactoring.CRefactoringDescription;
+import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
+
+/**
+ * @author Emanuel Graf IFS
+ *
+ */
+public class ExtractFunctionRefactoringDescription extends CRefactoringDescription {
+       protected static final String NAME = "name"; //$NON-NLS-1$
+       protected static final String VISIBILITY = "visibility"; //$NON-NLS-1$
+       protected static final String REPLACE_DUBLICATES = "replaceDuplicates"; //$NON-NLS-1$
+
+       public ExtractFunctionRefactoringDescription(String project, String description,
+                       String comment, Map<String, String> arguments) {
+               super(ExtractFunctionRefactoring.ID, project, description, comment, RefactoringDescriptor.MULTI_CHANGE, arguments);
+       }
+
+       @Override
+       public Refactoring createRefactoring(RefactoringStatus status) throws CoreException {
+               IFile file;
+               ExtractFunctionInformation info = new ExtractFunctionInformation();
+               ICProject proj;
+               
+               info.setMethodName(arguments.get(NAME));
+               info.setVisibility(VisibilityEnum.getEnumForStringRepresentation(arguments.get(VISIBILITY)));
+               info.setReplaceDuplicates(Boolean.parseBoolean(arguments.get(REPLACE_DUBLICATES)));
+               
+               proj = getCProject();
+               file = getFile();
+               
+               ISelection selection = getSelection();
+               return new ExtractFunctionRefactoring(file, selection, info, proj);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringRunner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringRunner.java
new file mode 100644 (file)
index 0000000..f7d0342
--- /dev/null
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractfunction;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
+
+import org.eclipse.cdt.core.model.ICProject;
+
+import org.eclipse.cdt.internal.ui.refactoring.CRefactoring;
+import org.eclipse.cdt.internal.ui.refactoring.RefactoringRunner;
+
+/**
+ * @author Emanuel Graf
+ */
+public class ExtractFunctionRefactoringRunner extends RefactoringRunner  {
+
+       public ExtractFunctionRefactoringRunner(IFile file, ISelection selection,
+                       IShellProvider shellProvider, ICProject cProject) {
+               super(file, selection, null, shellProvider, cProject);
+       }
+
+       @Override
+       public void run() {
+               ExtractFunctionInformation info = new ExtractFunctionInformation();
+               
+               CRefactoring refactoring = new ExtractFunctionRefactoring(file,selection,info, project);
+               ExtractFunctionRefactoringWizard wizard = new ExtractFunctionRefactoringWizard(refactoring,info);
+               RefactoringWizardOpenOperation operator = new RefactoringWizardOpenOperation(wizard);
+               
+               try {
+                       operator.run(shellProvider.getShell(), refactoring.getName());
+               } catch (InterruptedException e) {
+                       //initial condition checking got canceled by the user.
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractFunctionRefactoringWizard.java
new file mode 100644 (file)
index 0000000..627a893
--- /dev/null
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractfunction;
+
+import org.eclipse.ltk.core.refactoring.Refactoring;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
+import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
+
+public class ExtractFunctionRefactoringWizard extends RefactoringWizard {
+
+       private ExtractFunctionInformation info;
+
+       public ExtractFunctionRefactoringWizard(Refactoring refactoring, ExtractFunctionInformation info) {
+               super(refactoring, WIZARD_BASED_USER_INTERFACE);
+               this.info = info;
+       }
+
+       @Override
+       protected void addUserInputPages() {
+               UserInputWizardPage page = new ExtractFunctionInputPage(Messages.ExtractFunctionRefactoringWizard_FunctionName,info); 
+               page.setTitle(Messages.ExtractFunctionRefactoringWizard_FunctionName); 
+               addPage(page);
+
+       }
+
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractStatement.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractStatement.java
new file mode 100644 (file)
index 0000000..aa39434
--- /dev/null
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractfunction;
+
+import java.util.List;
+
+import org.eclipse.text.edits.TextEditGroup;
+
+import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTNode.CopyStyle;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
+import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
+
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclSpecifier;
+
+import org.eclipse.cdt.internal.ui.refactoring.NodeContainer.NameInformation;
+import org.eclipse.cdt.internal.ui.refactoring.utils.ASTHelper;
+
+/**
+ * @author Mirko Stocker
+ * 
+ */
+public class ExtractStatement extends ExtractedFunctionConstructionHelper {
+
+       @Override
+       public void constructMethodBody(IASTCompoundStatement compound,
+                       List<IASTNode> list, ASTRewrite rewrite, TextEditGroup group) {
+
+               for (IASTNode each : list) {
+                       rewrite.insertBefore(compound, null, each, group);
+               }
+       }
+
+       @Override
+       public IASTDeclSpecifier determineReturnType(IASTNode extractedNode, NameInformation returnVariable) {
+               
+               if(returnVariable != null) {
+                       IASTNode decl = ASTHelper.getDeclarationForNode(returnVariable.getDeclaration());
+                       return ASTHelper.getDeclarationSpecifier(decl).copy(CopyStyle.withLocations);
+               }
+               IASTDeclSpecifier declSpec = new CPPASTSimpleDeclSpecifier();
+               ((IASTSimpleDeclSpecifier)declSpec).setType(IASTSimpleDeclSpecifier.t_void);
+               return declSpec.copy(CopyStyle.withLocations);
+       }
+
+       @Override
+       public IASTNode createReturnAssignment(IASTNode node, IASTExpressionStatement stmt, IASTExpression callExpression) {
+               stmt.setExpression(callExpression);
+               return stmt;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractedFunctionConstructionHelper.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractedFunctionConstructionHelper.java
new file mode 100644 (file)
index 0000000..6888cd1
--- /dev/null
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractfunction;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.text.edits.TextEditGroup;
+
+import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTNode.CopyStyle;
+import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
+import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.INodeFactory;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
+
+import org.eclipse.cdt.internal.ui.refactoring.NodeContainer.NameInformation;
+
+/**
+ * @author Mirko Stocker
+ * 
+ */
+public abstract class ExtractedFunctionConstructionHelper {
+       
+       public static ExtractedFunctionConstructionHelper createFor (List<IASTNode> list) {
+               if(list.get(0) instanceof IASTExpression) {
+                       return new ExtractExpression();
+               }
+               return new ExtractStatement();
+       }
+       
+       public abstract void constructMethodBody(IASTCompoundStatement compound,
+                       List<IASTNode> list, ASTRewrite rewrite, TextEditGroup group);
+
+       public abstract IASTDeclSpecifier determineReturnType(IASTNode extractedNode, NameInformation returnVariable);
+
+       public abstract IASTNode createReturnAssignment(IASTNode node, IASTExpressionStatement stmt, IASTExpression callExpression);
+       
+       protected boolean isReturnTypeAPointer(IASTNode node) {
+               return false;
+       }
+
+       IASTStandardFunctionDeclarator createFunctionDeclarator(IASTName name, IASTStandardFunctionDeclarator functionDeclarator, NameInformation returnVariable, List<IASTNode> nodesToWrite, Collection<NameInformation> allUsedNames, INodeFactory nodeFactory) {
+               IASTStandardFunctionDeclarator declarator = nodeFactory.newFunctionDeclarator(name);
+       
+               if (functionDeclarator instanceof ICPPASTFunctionDeclarator && declarator instanceof ICPPASTFunctionDeclarator) {
+                       if (((ICPPASTFunctionDeclarator) functionDeclarator).isConst()) {
+                               ((ICPPASTFunctionDeclarator) declarator).setConst(true);
+                       }
+               }
+               
+               if(returnVariable != null) {
+                       IASTDeclarator decl = (IASTDeclarator) returnVariable.getDeclaration().getParent();
+                       IASTPointerOperator[] pointers = decl.getPointerOperators();
+                       for (IASTPointerOperator operator : pointers) {
+                               declarator.addPointerOperator(operator.copy(CopyStyle.withLocations));
+                       }
+               }
+       
+               for (IASTParameterDeclaration param : getParameterDeclarations(allUsedNames, nodeFactory)) {
+                       declarator.addParameterDeclaration(param);
+               }
+               
+               if(isReturnTypeAPointer(nodesToWrite.get(0))) {
+                       declarator.addPointerOperator(nodeFactory.newPointer());
+               }
+               
+               return declarator;
+       }
+       
+       public Collection<IASTParameterDeclaration> getParameterDeclarations(Collection<NameInformation> allUsedNames, INodeFactory nodeFactory) {
+               Collection<IASTParameterDeclaration> result = new ArrayList<IASTParameterDeclaration>();                
+               for (NameInformation name : allUsedNames) {
+                       if(!name.isDeclarationInScope()){
+                               result.add(name.getParameterDeclaration(name.isUserSetIsReference(), nodeFactory));
+                       }
+               }
+               return result;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/Messages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/Messages.java
new file mode 100644 (file)
index 0000000..1efab26
--- /dev/null
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *     Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractfunction;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class Messages extends NLS {
+       public static String ExtractFunctionRefactoringWizard_FunctionName;
+       public static String ExtractFunctionRefactoring_ExtractFunction;
+       public static String ExtractFunctionRefactoring_NoStmtSelected;
+       public static String ExtractFunctionRefactoring_TooManySelected;
+       public static String ExtractFunctionRefactoring_NameInUse;
+       public static String ExtractFunctionComposite_MethodName;
+       public static String ExtractFunctionComposite_FunctionName;
+       public static String ExtractFunctionInputPage_EnterName;
+       public static String ExtractFunctionInputPage_CheckFunctionName;
+       public static String ExtractFunctionInputPage_1;
+       public static String ExtractFunctionComposite_ReturnValue;
+       public static String ExtractFunctionRefactoring_CreateMethodDef;
+       public static String ExtractFunctionRefactoring_CreateFunctionDef;
+       public static String ExtractFunctionComposite_ReplaceDuplicates;
+       public static String ExtractFunctionComposite_Virtual;
+       public static String ExtractFunctionRefactoring_CreateMethodCall;
+       public static String ExtractFunctionRefactoring_CreateFunctionCall;
+       public static String ChooserComposite_Return;
+       public static String ChooserComposite_CallByRef;
+       public static String ChooserComposite_const;
+       public static String ChooserComposite_Name;
+       public static String ChooserComposite_Type;
+       public static String ChooserComposite_NoReturnValue;
+       public static String ExtractFunctionRefactoring_Error_Return;
+       public static String ExtractFunctionRefactoring_Error_Continue;
+       public static String ExtractFunctionRefactoring_Error_Break;
+       public static String SimilarFinderVisitor_replaceDuplicateCode;
+
+       static {
+               NLS.initializeMessages(Messages.class.getName(), Messages.class);
+       }
+
+       // Do not instantiate
+       private Messages() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/Messages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/Messages.properties
new file mode 100644 (file)
index 0000000..05eade1
--- /dev/null
@@ -0,0 +1,38 @@
+###############################################################################
+# Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik
+# Rapperswil, University of applied sciences and others
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Institute for Software - initial API and implementation
+###############################################################################
+ExtractFunctionRefactoringWizard_FunctionName=Function Name
+ExtractFunctionRefactoring_ExtractFunction=Extract Function
+ExtractFunctionRefactoring_NoStmtSelected=No statement selected
+ExtractFunctionRefactoring_TooManySelected=Too many declarations in selection.
+ExtractFunctionRefactoring_NameInUse=Name already in use.
+ExtractFunctionComposite_MethodName=Method &name:
+ExtractFunctionComposite_FunctionName=Function &name:
+ExtractFunctionInputPage_EnterName=Enter a name
+ExtractFunctionInputPage_CheckFunctionName=Check Function Name:
+ExtractFunctionInputPage_1=is used after the extracted block - it needs to be passed by reference or must be the return value.
+ExtractFunctionComposite_ReturnValue=Return value:
+ExtractFunctionRefactoring_CreateMethodDef=Create Method Definition
+ExtractFunctionRefactoring_CreateFunctionDef=Create Function Definition
+ExtractFunctionComposite_ReplaceDuplicates=Replace all occurrences of statements with method.
+ExtractFunctionComposite_Virtual=virtual
+ExtractFunctionRefactoring_CreateMethodCall=Create Method Call
+ExtractFunctionRefactoring_CreateFunctionCall=Create Function Call
+ChooserComposite_Return=Return
+ChooserComposite_CallByRef=Call by Reference
+ChooserComposite_const=const
+ChooserComposite_Name=Name
+ChooserComposite_Type=Type
+ChooserComposite_NoReturnValue=No return-value (void)
+ExtractFunctionRefactoring_Error_Return=Extracting return statements is not supported
+ExtractFunctionRefactoring_Error_Continue=Extracting cotinue statements without the surrounding loop is not possible. Please adjust your selection.
+ExtractFunctionRefactoring_Error_Break=Extracting break statements without the surrounding loop is not possible. Please adjust your selection.
+SimilarFinderVisitor_replaceDuplicateCode=Replace Duplicated Code
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/NonExtractableStmtFinder.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/NonExtractableStmtFinder.java
new file mode 100644 (file)
index 0000000..df474c8
--- /dev/null
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ * Institute for Software - initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractfunction;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTBreakStatement;
+import org.eclipse.cdt.core.dom.ast.IASTContinueStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDoStatement;
+import org.eclipse.cdt.core.dom.ast.IASTForStatement;
+import org.eclipse.cdt.core.dom.ast.IASTStatement;
+import org.eclipse.cdt.core.dom.ast.IASTSwitchStatement;
+import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
+
+/**
+ * @author Emanuel Graf IFS
+ *
+ */
+class NonExtractableStmtFinder extends ASTVisitor{
+
+       private boolean containsContinueStmt = false;
+       private boolean containsBreakStmt = false;
+       
+       {
+               shouldVisitStatements = true;
+       }
+
+       @Override
+       public int visit(IASTStatement statement) {
+               if (statement instanceof IASTContinueStatement) {
+                       containsContinueStmt = true;
+                       return ASTVisitor.PROCESS_SKIP;
+               }else if (statement instanceof IASTBreakStatement) {
+                       containsBreakStmt = true;
+                       return ASTVisitor.PROCESS_SKIP;
+               }else if(statement instanceof IASTForStatement||  //Extracting hole loop statements is ok
+                               statement instanceof IASTWhileStatement||
+                               statement instanceof IASTSwitchStatement||
+                               statement instanceof IASTDoStatement) {
+                       return ASTVisitor.PROCESS_SKIP;
+               }
+               return ASTVisitor.PROCESS_CONTINUE;
+       }
+
+       public boolean containsContinue() {
+               return containsContinueStmt;
+       }
+       
+       public boolean containsBreak() {
+               return containsBreakStmt;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ReturnStatementFinder.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ReturnStatementFinder.java
new file mode 100644 (file)
index 0000000..0f901d1
--- /dev/null
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ * Institute for Software - initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractfunction;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
+import org.eclipse.cdt.core.dom.ast.IASTStatement;
+
+/**
+ * @author Emanuel Graf IFS
+ *
+ */
+class ReturnStatementFinder extends ASTVisitor{
+
+       private boolean containsReturnStmt = false;
+
+       
+       {
+               shouldVisitStatements = true;
+       }
+
+       @Override
+       public int visit(IASTStatement statement) {
+               if (statement instanceof IASTReturnStatement) {
+                       containsReturnStmt = true;
+                       return ASTVisitor.PROCESS_SKIP;
+               }
+               return ASTVisitor.PROCESS_CONTINUE;
+       }
+       
+       public boolean containsReturn() {
+               return containsReturnStmt;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/SimilarFinderVisitor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/SimilarFinderVisitor.java
new file mode 100644 (file)
index 0000000..3d6d179
--- /dev/null
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractfunction;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Vector;
+import java.util.Map.Entry;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.text.edits.TextEditGroup;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTStatement;
+import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
+
+import org.eclipse.cdt.internal.ui.refactoring.ModificationCollector;
+import org.eclipse.cdt.internal.ui.refactoring.NodeContainer;
+import org.eclipse.cdt.internal.ui.refactoring.NodeContainer.NameInformation;
+
+final class SimilarFinderVisitor extends ASTVisitor {
+
+               private final ExtractFunctionRefactoring refactoring;
+
+               private final Vector<IASTNode> trail;
+               private final IASTName name;
+               private final List<IASTNode> stmts;
+               private int i = 0;
+               private NodeContainer similarContainer;
+       private final List<IASTStatement> stmtToReplace = new ArrayList<IASTStatement>();
+
+       private final ModificationCollector collector;
+
+       SimilarFinderVisitor(ExtractFunctionRefactoring refactoring,
+                       ModificationCollector collector, Vector<IASTNode> trail, IFile file, IASTName name,
+                       List<IASTNode> stmts, String title) {
+               this.refactoring = refactoring;
+               this.trail = trail;
+               this.name = name;
+               this.stmts = stmts;
+               this.collector = collector;
+               this.similarContainer = new NodeContainer();
+       }
+
+               {
+                       shouldVisitStatements = true;
+               }
+
+               @Override
+               public int visit(IASTStatement stmt) {
+                       
+                       boolean isAllreadyInMainRefactoring = isInSelection(stmt);
+                       
+                       if( (!isAllreadyInMainRefactoring)
+                                       && this.refactoring.isStatementInTrail(stmt, trail, this.refactoring.getIndex())){
+                               stmtToReplace.add(stmt);
+                               similarContainer.add(stmt);     
+                               ++i;
+                               
+                               if(i==stmts.size()){
+                                       //found similar code
+                                       
+                                       boolean similarOnReturnWays = true;
+                                       for (NameInformation nameInfo : similarContainer.getAllAfterUsedNames()) {
+                                               if(this.refactoring.names.containsKey(nameInfo.getDeclaration().getRawSignature())){
+                                                       Integer nameOrderNumber = this.refactoring.names.get(nameInfo.getDeclaration().getRawSignature());
+                                                       if(this.refactoring.nameTrail.containsValue(nameOrderNumber)){
+                                                               String orgName = null;
+                                                               boolean found = false;
+                                                               for (Entry<String, Integer> entry : this.refactoring.nameTrail.entrySet()) {
+                                                                       if(entry.getValue().equals(nameOrderNumber)){
+                                                                               orgName = entry.getKey();
+                                                                       }
+                                                               }
+                                                               if(orgName != null){
+                                                                       for (NameInformation orgNameInfo : this.refactoring.container.getAllAfterUsedNamesChoosenByUser()) {
+                                                                               if( orgName.equals(orgNameInfo.getDeclaration().getRawSignature()) ){
+                                                                                       found = true;
+                                                                               }
+                                                                       }
+                                                               }
+                                                               
+                                                               if(!found){
+                                                                       similarOnReturnWays = false;
+                                                               }
+                                                       }
+                                               }
+                                       }
+                                                                               
+                                       if(similarOnReturnWays){
+                                               IASTNode call = refactoring.getMethodCall(name,
+                                                               this.refactoring.nameTrail, this.refactoring.names,
+                                                               this.refactoring.container, similarContainer);
+                                               ASTRewrite rewrite = collector.rewriterForTranslationUnit(stmtToReplace.get(0)
+                                                               .getTranslationUnit());
+                                               TextEditGroup editGroup = new TextEditGroup(Messages.SimilarFinderVisitor_replaceDuplicateCode);
+                                               rewrite.replace(stmtToReplace.get(0), call, editGroup);
+                                               if (stmtToReplace.size() > 1) {
+                                                       for (int i = 1; i < stmtToReplace.size(); ++i) {
+                                                               rewrite.remove(stmtToReplace.get(i), editGroup);
+                                                       }
+                                               }
+                                       }
+
+                                       clear();
+                               }
+
+                               return PROCESS_SKIP;
+                       } else {
+                               clear();
+                               return super.visit(stmt);
+                       }
+                       
+               }
+
+               private boolean isInSelection(IASTStatement stmt) {
+                       List<IASTNode>nodes = this.refactoring.container.getNodesToWrite();
+                       for (IASTNode node : nodes) {
+                               if(node.equals(stmt)) {
+                                       return true;
+                               }
+                       }
+                       return false;
+               }
+
+               private void clear() {
+                       i = 0;
+                       this.refactoring.names.clear();
+                       similarContainer = new NodeContainer();
+                       this.refactoring.namesCounter.setObject(ExtractFunctionRefactoring.NULL_INTEGER);
+                       this.refactoring.trailPos.setObject(ExtractFunctionRefactoring.NULL_INTEGER);
+               stmtToReplace.clear();
+               }
+       }
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailName.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailName.java
new file mode 100644 (file)
index 0000000..26755e5
--- /dev/null
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractfunction;
+
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
+
+import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
+
+import org.eclipse.cdt.internal.ui.refactoring.utils.ASTHelper;
+
+class TrailName extends ASTNode{
+
+       private int nameNumber;
+       private IASTNode declaration = null;
+       private IASTName realName = null;
+       
+       public TrailName(IASTName realName) {
+               super();
+               this.realName = realName;
+       }
+
+       public int getNameNumber() {
+               return nameNumber;
+       }
+
+       public void setNameNumber(int nameNumber) {
+               this.nameNumber = nameNumber;
+       }
+
+       public IASTDeclSpecifier getDeclSpecifier() {
+               return ASTHelper.getDeclarationSpecifier(declaration);
+       }
+
+       public IASTName getRealName() {
+               return realName;
+       }
+
+       public boolean isGloballyQualified() {
+               IBinding bind = realName.resolveBinding();
+               try {
+                       if (bind instanceof ICPPBinding) {
+                               ICPPBinding cppBind = (ICPPBinding) bind;
+                               return cppBind.isGloballyQualified();
+                       }
+               } catch (DOMException e) {
+               }                       
+               return false;
+       }
+
+       public IASTNode copy() {
+               throw new UnsupportedOperationException();
+       }
+
+       public IASTNode copy(CopyStyle style) {
+               throw new UnsupportedOperationException();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailNodeEqualityChecker.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/TrailNodeEqualityChecker.java
new file mode 100644 (file)
index 0000000..d4e03b6
--- /dev/null
@@ -0,0 +1,427 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *    Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractfunction;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
+import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTPointer;
+import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTStatement;
+import org.eclipse.cdt.core.dom.ast.IASTTypeIdExpression;
+import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.c.ICASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexName;
+
+import org.eclipse.cdt.internal.ui.refactoring.Container;
+import org.eclipse.cdt.internal.ui.refactoring.EqualityChecker;
+
+public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
+
+       private final Map<String, Integer> names;
+       private final Container<Integer> namesCounter;
+       private IIndex index;
+       
+       public TrailNodeEqualityChecker(Map<String, Integer> names, Container<Integer> namesCounter, IIndex index) {
+               super();
+               this.names = names;
+               this.namesCounter = namesCounter;
+               this.index = index;
+       }
+       
+       public boolean isEquals(IASTNode trailNode, IASTNode node) {
+               if( (trailNode instanceof TrailName && node instanceof IASTName)
+                               || Arrays.equals(getInterfaces(node), getInterfaces(trailNode)) ) {
+                       //Is same type
+                       if(node instanceof IASTExpression){
+                               return isExpressionEquals(trailNode, node);
+                       } else if(node instanceof IASTStatement){
+                               return isStatementEquals(trailNode, node);
+                       } else if(node instanceof IASTPointerOperator){
+                               return isPointerOperatorEquals(trailNode, node);
+                       } else if(node instanceof IASTDeclaration){
+                               return isDeclarationEquals(trailNode, node);
+                       } else if(node instanceof IASTDeclarator){      
+                               return isDeclaratorEquals(trailNode, node);
+                       } else if(node instanceof IASTInitializer){
+                               //no speciality, is the same type return true
+                               return true;
+                       } else if(node instanceof IASTDeclSpecifier){
+                               return isDeclSpecifierEquals(trailNode, node);
+                       } else if(node instanceof IASTName){
+                               return isNameEquals(trailNode, node);
+                       } else {
+                               Assert.isLegal(false, "Unexpected Node, this code shoud nod reached"); //$NON-NLS-1$
+                               return true;
+                       }
+               }
+               return false;
+               
+               
+       }
+
+       private boolean isNameEquals(IASTNode trailNode, IASTNode node) {
+               if(trailNode instanceof ICPPASTConversionName) {
+                       return true;
+               } else if(trailNode instanceof ICPPASTOperatorName) {
+                       ICPPASTOperatorName trailName= ( ICPPASTOperatorName )trailNode;
+                       ICPPASTOperatorName name = ( ICPPASTOperatorName )node;
+
+                       return trailName.equals(name);
+               } else if(trailNode instanceof TrailName && node instanceof IASTName) {
+                       TrailName trailName = (TrailName) trailNode;
+                       IASTName name = (IASTName)node;
+                       
+                       return isNameEquals(trailName, name); 
+               } else {
+                       return true;
+               }
+       }
+
+       private boolean isDeclSpecifierEquals(IASTNode trailNode, IASTNode node) {
+               if (trailNode instanceof IASTSimpleDeclSpecifier) {
+                       IASTSimpleDeclSpecifier trailDecl = (IASTSimpleDeclSpecifier) trailNode;
+                       IASTSimpleDeclSpecifier decl = (IASTSimpleDeclSpecifier) node;
+                       
+                       return isSimpleDeclSpecifierEquals(trailDecl, decl);
+               } else if (trailNode instanceof ICPPASTNamedTypeSpecifier) {
+                       ICPPASTNamedTypeSpecifier trailDecl = (ICPPASTNamedTypeSpecifier) trailNode;
+                       ICPPASTNamedTypeSpecifier decl = (ICPPASTNamedTypeSpecifier) node;
+                       
+                       
+                       return isDeclSpecifierEquals(trailDecl, decl)
+                                                               && isSameNamedTypeSpecifierName(trailDecl, decl)
+                                                               && trailDecl.isTypename()       == decl.isTypename()
+                                                               && trailDecl.isExplicit()       == decl.isExplicit()
+                                                               && trailDecl.isFriend()         == decl.isFriend()
+                                                               && trailDecl.isVirtual()        == decl.isVirtual();
+               } else if (trailNode instanceof IASTNamedTypeSpecifier) {
+                       IASTNamedTypeSpecifier trailDecl = (IASTNamedTypeSpecifier) trailNode;
+                       IASTNamedTypeSpecifier decl = (IASTNamedTypeSpecifier) node;
+                       
+                       return isDeclSpecifierEquals(trailDecl, decl)
+                               && isSameNamedTypeSpecifierName(trailDecl, decl);
+               } else if (trailNode instanceof IASTElaboratedTypeSpecifier) {
+                       IASTElaboratedTypeSpecifier trailDecl = (IASTElaboratedTypeSpecifier) trailNode;
+                       IASTElaboratedTypeSpecifier decl = (IASTElaboratedTypeSpecifier) node;
+                       
+                       return isDeclSpecifierEquals(trailDecl, decl)
+                               && trailDecl.getKind()  == decl.getKind();
+               } else if (trailNode instanceof IASTCompositeTypeSpecifier) {
+                       IASTCompositeTypeSpecifier trailDecl = (IASTCompositeTypeSpecifier) trailNode;
+                       IASTCompositeTypeSpecifier decl = (IASTCompositeTypeSpecifier) node;
+                       
+                       return isDeclSpecifierEquals(trailDecl, decl)
+                               && trailDecl.getKey()   == decl.getKey();
+               } else if (trailNode instanceof ICPPASTDeclSpecifier) {
+                       ICPPASTDeclSpecifier trailDecl = (ICPPASTDeclSpecifier) trailNode;
+                       ICPPASTDeclSpecifier decl = (ICPPASTDeclSpecifier) node;
+                       
+                       return isDeclSpecifierEquals(trailDecl, decl)
+                               && trailDecl.isExplicit()       == decl.isExplicit()
+                               && trailDecl.isFriend()         == decl.isFriend()
+                               && trailDecl.isVirtual()        == decl.isVirtual();
+               } else if (trailNode instanceof ICASTDeclSpecifier) {
+                       ICASTDeclSpecifier trailDecl = (ICASTDeclSpecifier) trailNode;
+                       ICASTDeclSpecifier decl = (ICASTDeclSpecifier) node;
+                       
+                       return isDeclSpecifierEquals(trailDecl, decl)
+                               && trailDecl.isRestrict()       == decl.isRestrict();
+               } else if (trailNode instanceof IASTDeclSpecifier) {
+                       IASTDeclSpecifier trailDecl = (IASTDeclSpecifier) trailNode;
+                       IASTDeclSpecifier decl = (IASTDeclSpecifier) node;
+                       
+                       return isDeclSpecifierEquals(trailDecl, decl);
+               } else {
+                       //is same
+                       return true;
+               }
+       }
+
+       private boolean isDeclaratorEquals(IASTNode trailNode, IASTNode node) {
+               if (trailNode instanceof IASTStandardFunctionDeclarator) {
+                       IASTStandardFunctionDeclarator trailFunc = (IASTStandardFunctionDeclarator) trailNode;
+                       IASTStandardFunctionDeclarator func = (IASTStandardFunctionDeclarator) node;
+                       
+                       return trailFunc.takesVarArgs() == func.takesVarArgs();
+               } else if (trailNode instanceof ICPPASTFunctionDeclarator) {
+                       ICPPASTFunctionDeclarator trailFunc = (ICPPASTFunctionDeclarator) trailNode;
+                       ICPPASTFunctionDeclarator func = (ICPPASTFunctionDeclarator) node;
+                       
+                       return trailFunc.isConst() == func.isConst()
+                               && trailFunc.isPureVirtual() == func.isPureVirtual()
+                               && trailFunc.isVolatile() == func.isVolatile();
+               } else {
+                       //same type
+                       return true;
+               }
+       }
+
+       private boolean isDeclarationEquals(IASTNode trailNode, IASTNode node) {
+               if (trailNode instanceof IASTASMDeclaration) {
+                       IASTASMDeclaration trailASMDecl = (IASTASMDeclaration) trailNode;
+                       IASTASMDeclaration asmDecl = (IASTASMDeclaration) node;
+                       
+                       return trailASMDecl.getAssembly().equals(asmDecl.getAssembly());
+               } else if (trailNode instanceof ICPPASTExplicitTemplateInstantiation) {
+                       ICPPASTExplicitTemplateInstantiation trailTempl = (ICPPASTExplicitTemplateInstantiation) trailNode;
+                       ICPPASTExplicitTemplateInstantiation templ = (ICPPASTExplicitTemplateInstantiation) node;
+                       
+                       return trailTempl.getModifier() == templ.getModifier();
+               } else if (trailNode instanceof ICPPASTLinkageSpecification) {
+                       ICPPASTLinkageSpecification trailLink = (ICPPASTLinkageSpecification) trailNode;
+                       ICPPASTLinkageSpecification link = (ICPPASTLinkageSpecification) node;
+                       
+                       return trailLink.getLiteral().equals(link.getLiteral());
+               } else if (trailNode instanceof ICPPASTTemplateDeclaration) {
+                       ICPPASTTemplateDeclaration trailTempl = (ICPPASTTemplateDeclaration) trailNode;
+                       ICPPASTTemplateDeclaration templ = (ICPPASTTemplateDeclaration) node;
+                       
+                       return trailTempl.isExported() == templ.isExported();
+               } else if (trailNode instanceof ICPPASTUsingDeclaration) {
+                       ICPPASTUsingDeclaration trailUsing = (ICPPASTUsingDeclaration) trailNode;
+                       ICPPASTUsingDeclaration using = (ICPPASTUsingDeclaration) node;
+                       
+                       return trailUsing.isTypename() == using.isTypename();
+               } else if (trailNode instanceof ICPPASTVisibilityLabel) {
+                       ICPPASTVisibilityLabel trailVisibility = (ICPPASTVisibilityLabel) trailNode;
+                       ICPPASTVisibilityLabel visibility = (ICPPASTVisibilityLabel) node;
+                       
+                       return trailVisibility.getVisibility() == visibility.getVisibility();
+               } else {
+                       //same type
+                       return true;
+               }
+       }
+
+       private boolean isPointerOperatorEquals(IASTNode trailNode, IASTNode node) {
+               if (trailNode instanceof IASTPointer) {
+                       IASTPointer trailGPointer = (IASTPointer) trailNode;
+                       IASTPointer gPointer = (IASTPointer) node;
+                       
+                       return trailGPointer.isConst() == gPointer.isConst()
+                               && trailGPointer.isRestrict() == gPointer.isRestrict()
+                               && trailGPointer.isVolatile() == gPointer.isVolatile();
+               } else {
+                       //same type
+                       return true;
+               }
+       }
+
+       private boolean isStatementEquals(IASTNode trailNode, IASTNode node) {
+               if (trailNode instanceof ICPPASTCatchHandler) {
+                       ICPPASTCatchHandler trailCatch = (ICPPASTCatchHandler) trailNode;
+                       ICPPASTCatchHandler nodeCatch = (ICPPASTCatchHandler) node;
+                       
+                       return trailCatch.isCatchAll() == nodeCatch.isCatchAll();
+               }
+               //same type
+               return true;
+       }
+
+       private boolean isExpressionEquals(IASTNode trailNode, IASTNode node) {
+               if (trailNode instanceof IASTBinaryExpression) {
+                       IASTBinaryExpression trailExpr = (IASTBinaryExpression) trailNode;
+                       IASTBinaryExpression expr = (IASTBinaryExpression) node;
+                       
+                       return trailExpr.getOperator() == expr.getOperator();
+               } else if (trailNode instanceof ICPPASTFieldReference) {
+                       ICPPASTFieldReference trailFieldRef = (ICPPASTFieldReference) trailNode;
+                       ICPPASTFieldReference fieldRef = (ICPPASTFieldReference) node;
+                       
+                       return trailFieldRef.isPointerDereference() == fieldRef.isPointerDereference()
+                               && trailFieldRef.isTemplate() == fieldRef.isTemplate();
+               } else if (trailNode instanceof IASTFieldReference) {
+                       IASTFieldReference trailFieldRef = (IASTFieldReference) trailNode;
+                       IASTFieldReference fieldRef = (IASTFieldReference) node;
+                       
+                       return trailFieldRef.isPointerDereference() == fieldRef.isPointerDereference();
+               } else if (trailNode instanceof IASTLiteralExpression) {
+                       IASTLiteralExpression trailLiteral = (IASTLiteralExpression) trailNode;
+                       IASTLiteralExpression literal = (IASTLiteralExpression) node;
+                       
+                       return trailLiteral.getKind() == literal.getKind() && trailLiteral.toString().equals(literal.toString());
+               } else if (trailNode instanceof IASTUnaryExpression) {
+                       IASTUnaryExpression trailExpr = (IASTUnaryExpression) trailNode;
+                       IASTUnaryExpression expr = (IASTUnaryExpression) node;
+                       
+                       return  trailExpr.getOperator() == expr.getOperator();
+               } else if (trailNode instanceof IASTTypeIdExpression) {
+                       IASTTypeIdExpression trailIdExpr = (IASTTypeIdExpression) trailNode;
+                       IASTTypeIdExpression idExpr = (IASTTypeIdExpression) node;
+                       
+                       return trailIdExpr.getTypeId() == idExpr.getTypeId();
+               } else if (trailNode instanceof ICPPASTDeleteExpression) {
+                       ICPPASTDeleteExpression trailDelete = (ICPPASTDeleteExpression) trailNode;
+                       ICPPASTDeleteExpression delete = (ICPPASTDeleteExpression) node;
+                       
+                       return trailDelete.isGlobal() == delete.isGlobal() && trailDelete.isVectored() == delete.isVectored();
+               } else if (trailNode instanceof ICPPASTNewExpression) {
+                       ICPPASTNewExpression trailNew = (ICPPASTNewExpression) trailNode;
+                       ICPPASTNewExpression nodeNew = (ICPPASTNewExpression) node;
+                       
+                       return trailNew.isGlobal() == nodeNew.isGlobal() && trailNew.isNewTypeId() == nodeNew.isNewTypeId();
+               } else if (trailNode instanceof ICPPASTSimpleTypeConstructorExpression) {
+                       ICPPASTSimpleTypeConstructorExpression trailConsExpr = (ICPPASTSimpleTypeConstructorExpression) trailNode;
+                       ICPPASTSimpleTypeConstructorExpression consExpr = (ICPPASTSimpleTypeConstructorExpression) node;
+                       
+                       return isDeclSpecifierEquals(trailConsExpr.getDeclSpecifier(), consExpr.getDeclSpecifier());
+               } else {
+//                     same type
+                       return true;
+               }
+       }
+
+       private boolean isSameNamedTypeSpecifierName(IASTNamedTypeSpecifier trailDecl, IASTNamedTypeSpecifier decl) {
+               return trailDecl.getName().getRawSignature().equals(decl.getName().getRawSignature());
+       }
+
+       private Class<?>[] getInterfaces(IASTNode node) {
+               Class<?>[] interfaces = node.getClass().getInterfaces();
+               List<Class<?>> interfaceList = Arrays.asList(interfaces);
+               Class<?>[] returnArray = new Class[interfaceList.size()];
+               return interfaceList.toArray(returnArray);
+       }
+       
+       private boolean isDeclSpecifierEquals(IASTDeclSpecifier trailDeclSpeci, IASTDeclSpecifier declSpeci){
+               if (trailDeclSpeci instanceof ICPPASTDeclSpecifier) {
+                       ICPPASTDeclSpecifier trailCppDecl= (ICPPASTDeclSpecifier) trailDeclSpeci;
+                       ICPPASTDeclSpecifier cppDecl= (ICPPASTDeclSpecifier) declSpeci;
+                       if (trailCppDecl.isExplicit() == cppDecl.isExplicit()
+                       && trailCppDecl.isFriend()      == cppDecl.isFriend()
+                       && trailCppDecl.isVirtual()     == cppDecl.isVirtual()) {
+                               // ok
+                       } else {
+                               return false;
+                       }
+               }
+               return  trailDeclSpeci.isConst()        == declSpeci.isConst()
+               && trailDeclSpeci.isInline()            == declSpeci.isInline()
+               && trailDeclSpeci.isVolatile()          == declSpeci.isVolatile()
+               && trailDeclSpeci.isRestrict()  == declSpeci.isRestrict()
+               && trailDeclSpeci.getStorageClass() == declSpeci.getStorageClass();
+       }
+
+       private boolean isSimpleDeclSpecifierEquals(IASTSimpleDeclSpecifier trailDeclSpeci, IASTSimpleDeclSpecifier declSpeci){
+               return isDeclSpecifierEquals(trailDeclSpeci, declSpeci)
+               && trailDeclSpeci.isLong()                      == declSpeci.isLong()
+               && trailDeclSpeci.isShort()             == declSpeci.isShort()
+               && trailDeclSpeci.isSigned()            == declSpeci.isSigned()
+               && trailDeclSpeci.isUnsigned()          == declSpeci.isUnsigned()
+               && trailDeclSpeci.getType()             == declSpeci.getType()
+               && trailDeclSpeci.isComplex() == declSpeci.isComplex()
+               && trailDeclSpeci.isImaginary() == declSpeci.isImaginary()
+               && trailDeclSpeci.isLongLong() == declSpeci.isLongLong();
+       }
+       
+       private boolean isNameEquals(TrailName trailName, IASTName name) {
+               int actCount = namesCounter.getObject().intValue();
+               if(names.containsKey(name.getRawSignature())){
+                       Integer nameId = names.get(name.getRawSignature());
+                       actCount = nameId.intValue();
+               } else {
+                       ++actCount;
+                       namesCounter.setObject(Integer.valueOf(actCount));
+                       names.put(name.getRawSignature(), namesCounter.getObject());
+               }
+
+               if(actCount != trailName.getNameNumber()){
+                       return false;
+               } 
+               
+               if(trailName.isGloballyQualified()) {
+                       IBinding realBind = trailName.getRealName().resolveBinding();
+                       IBinding nameBind = name.resolveBinding();
+                       try {
+                               index.acquireReadLock();
+                               IIndexName[] realDecs = index.findDeclarations(realBind);
+                               IIndexName[] nameDecs = index.findDeclarations(nameBind);
+                               if(realDecs.length == nameDecs.length) {
+                                       for(int i = 0; i < realDecs.length; ++i) {
+                                               IASTFileLocation rfl = realDecs[i].getFileLocation();
+                                               IASTFileLocation nfl = nameDecs[i].getFileLocation();
+                                               if(rfl.getNodeOffset() == nfl.getNodeOffset() && rfl.getFileName().equals(nfl.getFileName())) {
+                                                       continue;
+                                               }else {
+                                                       return false;
+                                               }
+                                       }
+                                       return true;
+                               }else {
+                                       return false;
+                               }
+                       } catch (InterruptedException e) {}
+                       catch (CoreException e) {}
+                       finally {
+                               index.releaseReadLock();
+                       }
+               }else {
+                       IType oType = getType(trailName.getRealName().resolveBinding());
+                       IType nType = getType(name.resolveBinding());
+                       if (oType == null || nType == null)
+                               return false;
+                       
+                       if(oType.isSameType(nType)) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+       private IType getType(IBinding binding) {
+               if (binding instanceof ICPPVariable) {
+                       ICPPVariable var = (ICPPVariable) binding;
+                       return var.getType();
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoring.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoring.java
new file mode 100644 (file)
index 0000000..b2bf274
--- /dev/null
@@ -0,0 +1,527 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Google and others. All rights reserved. This program and
+ * the accompanying materials are made available under the terms of the Eclipse
+ * Public License v1.0 which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Google - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.refactoring.extractlocalvariable;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.core.runtime.preferences.IPreferencesService;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.text.edits.TextEditGroup;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarationStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTEqualsInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTForStatement;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
+import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTNode.CopyStyle;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTStatement;
+import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.INodeFactory;
+import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionCallExpression;
+import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
+import org.eclipse.cdt.core.dom.rewrite.DeclarationGenerator;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDeclarationStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTEqualsInitializer;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction;
+
+import org.eclipse.cdt.internal.ui.refactoring.CRefactoring;
+import org.eclipse.cdt.internal.ui.refactoring.CRefactoringDescription;
+import org.eclipse.cdt.internal.ui.refactoring.ModificationCollector;
+import org.eclipse.cdt.internal.ui.refactoring.NameNVisibilityInformation;
+import org.eclipse.cdt.internal.ui.refactoring.NodeContainer;
+import org.eclipse.cdt.internal.ui.refactoring.utils.NodeHelper;
+import org.eclipse.cdt.internal.ui.refactoring.utils.SelectionHelper;
+import org.eclipse.cdt.internal.ui.util.NameComposer;
+
+/**
+ * The main class for the Extract Local Variable refactoring. This refactoring
+ * differs from the Extract Constant refactoring in that any valid expression
+ * which can be used to initialize a local variable can be extracted.
+ *
+ * @author Tom Ball
+ */
+public class ExtractLocalVariableRefactoring extends CRefactoring {
+       public static final String ID =
+                       "org.eclipse.cdt.internal.ui.refactoring.extractlocalvariable.ExtractLocalVariableRefactoring"; //$NON-NLS-1$
+       
+       private IASTExpression target;
+       private final NameNVisibilityInformation info;
+       private NodeContainer container;
+
+       public ExtractLocalVariableRefactoring(IFile file, ISelection selection, NameNVisibilityInformation info,
+                       ICProject project) {
+               super(file, selection, null, project);
+               this.info = info;
+               name = Messages.ExtractLocalVariable;
+       }
+
+       @Override
+       public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
+                       throws CoreException, OperationCanceledException {
+               SubMonitor sm = SubMonitor.convert(pm, 9);
+               try {
+                       lockIndex();
+                       try {
+                               RefactoringStatus status = super.checkInitialConditions(sm.newChild(6));
+                               if (status.hasError()) {
+                                       return status;
+                               }
+
+                               container = findAllExpressions();
+                               if (container.size() < 1) {
+                                       initStatus.addFatalError(Messages.ExpressionMustBeSelected);
+                                       return initStatus;
+                               }
+
+                               sm.worked(1);
+                               if (isProgressMonitorCanceld(sm, initStatus))
+                                       return initStatus;
+
+                               boolean oneMarked = region != null && isOneMarked(container.getNodesToWrite(), region);
+                               if (!oneMarked) {
+                                       if (target == null) {
+                                               initStatus.addFatalError(Messages.NoExpressionSelected);
+                                       } else {
+                                               initStatus.addFatalError(Messages.TooManyExpressionsSelected);
+                                       }
+                                       return initStatus;
+                               }
+                               sm.worked(1);
+
+                               if (isProgressMonitorCanceld(sm, initStatus))
+                                       return initStatus;
+
+                               container.findAllNames();
+                               sm.worked(1);
+
+                               container.getAllAfterUsedNames();
+                               info.addNamesToUsedNames(findAllDeclaredNames());
+                               sm.worked(1);
+
+                               NodeHelper.findMethodContext(container.getNodesToWrite().get(0), getIndex());
+                               sm.worked(1);
+
+                               info.setName(guessTempName());
+                               sm.done();
+                       } finally {
+                               unlockIndex();
+                       }
+               } catch (InterruptedException e) {
+                       Thread.currentThread().interrupt();
+               }
+               return initStatus;
+       }
+
+       private ArrayList<String> findAllDeclaredNames() {
+               ArrayList<String> names = new ArrayList<String>();
+               IASTFunctionDefinition funcDef = NodeHelper.findFunctionDefinitionInAncestors(target);
+               ICPPASTCompositeTypeSpecifier comTypeSpec = getCompositeTypeSpecifier(funcDef);
+               if (comTypeSpec != null) {
+                       for (IASTDeclaration dec : comTypeSpec.getMembers()) {
+                               if (dec instanceof IASTSimpleDeclaration) {
+                                       IASTSimpleDeclaration simpDec = (IASTSimpleDeclaration) dec;
+                                       for (IASTDeclarator decor : simpDec.getDeclarators()) {
+                                               names.add(decor.getName().getRawSignature());
+                                       }
+                               }
+                       }
+               }
+               return names;
+       }
+
+       private ICPPASTCompositeTypeSpecifier getCompositeTypeSpecifier(IASTFunctionDefinition funcDef) {
+               if (funcDef != null) {
+                       IBinding binding = funcDef.getDeclarator().getName().resolveBinding();
+                       if (binding instanceof CPPFunction) {
+                               CPPFunction function = (CPPFunction) binding;
+                               IASTNode[] decls = function.getDeclarations();
+                               if (decls != null && decls.length > 0) {
+                                       IASTNode spec = decls[0].getParent().getParent();
+                                       if (spec instanceof ICPPASTCompositeTypeSpecifier) {
+                                               return (ICPPASTCompositeTypeSpecifier) spec;
+                                       }
+                               }
+                       }
+               }
+               return null;
+       }
+
+       private boolean isOneMarked(List<IASTNode> selectedNodes, Region textSelection) {
+               boolean oneMarked = false;
+               for (IASTNode node : selectedNodes) {
+                       if (node instanceof IASTExpression) {
+                               IASTExpression expression = (IASTExpression) node;
+                               boolean isInSameFileSelection =
+                                               SelectionHelper.isInSameFileSelection(textSelection, expression, file);
+                               if (isInSameFileSelection && isExpressionInSelection(expression, textSelection)) {
+                                       if (target == null) {
+                                               target = expression;
+                                               oneMarked = true;
+                                       } else if (!isTargetChild(expression)) {
+                                               oneMarked = false;
+                                       }
+                               }
+                       }
+               }
+               return oneMarked;
+       }
+
+       private boolean isExpressionInSelection(IASTExpression expression, Region selection) {
+               IASTFileLocation location = expression.getFileLocation();
+               int e1 = location.getNodeOffset();
+               int e2 = location.getNodeOffset() + location.getNodeLength();
+               int s1 = selection.getOffset();
+               int s2 = selection.getOffset() + selection.getLength();
+               return e1 >= s1 && e2 <= s2;
+       }
+
+       private boolean isTargetChild(IASTExpression child) {
+               if (target == null) {
+                       return false;
+               }
+               IASTNode node = child;
+               while (node != null) {
+                       if (node.getParent() == target)
+                               return true;
+                       node = node.getParent();
+               }
+               return false;
+       }
+
+       private NodeContainer findAllExpressions() {
+               final NodeContainer container = new NodeContainer();
+
+               ast.accept(new ASTVisitor() {
+                       {
+                               shouldVisitExpressions = true;
+                       }
+
+                       @Override
+                       public int visit(IASTExpression expression) {
+                               if (SelectionHelper.isSelectedFile(region, expression, file)) {
+                                       container.add(expression);
+                                       return PROCESS_SKIP;
+                               }
+                               return super.visit(expression);
+                       }
+               });
+
+               return container;
+       }
+
+       @Override
+       protected void collectModifications(IProgressMonitor pm, ModificationCollector collector)
+                       throws CoreException, OperationCanceledException {
+               try {
+                       lockIndex();
+                       try {
+                               String variableName = info.getName();
+                               TextEditGroup editGroup = new TextEditGroup(Messages.CreateLocalVariable);
+
+                               // Define temporary variable declaration and insert it
+                               IASTStatement declInsertPoint = getParentStatement(target);
+                               IASTDeclarationStatement declaration = getVariableNodes(variableName);
+                               declaration.setParent(declInsertPoint.getParent());
+                               ASTRewrite rewriter = collector.rewriterForTranslationUnit(ast);
+                               rewriter.insertBefore(declInsertPoint.getParent(), declInsertPoint, declaration, editGroup);
+
+                               // Replace target with reference to temporary variable
+                               CPPASTIdExpression idExpression =
+                                               new CPPASTIdExpression(new CPPASTName(variableName.toCharArray()));
+                               rewriter.replace(target, idExpression, editGroup);
+                       } finally {
+                               unlockIndex();
+                       }
+               } catch (InterruptedException e) {
+                       Thread.currentThread().interrupt();
+               }
+       }
+
+       private IASTStatement getParentStatement(IASTNode node) {
+               while (node != null) {
+                       if (node instanceof IASTStatement && !(node.getParent() instanceof IASTForStatement))
+                               return (IASTStatement) node;
+                       node = node.getParent();
+               }
+               return null;
+       }
+
+       private IASTDeclarationStatement getVariableNodes(String newName) {
+               INodeFactory factory = this.ast.getASTNodeFactory();
+               
+               IASTSimpleDeclaration simple = factory.newSimpleDeclaration(null);
+
+               DeclarationGenerator generator = DeclarationGenerator.create(factory);
+               
+               IASTDeclSpecifier declSpec = generator.createDeclSpecFromType(target.getExpressionType());
+               declSpec.setStorageClass(IASTDeclSpecifier.sc_unspecified);
+               simple.setDeclSpecifier(declSpec);
+
+               IASTDeclarator decl = generator.createDeclaratorFromType(target.getExpressionType(),
+                               newName.toCharArray());
+
+               IASTEqualsInitializer init = new CPPASTEqualsInitializer();
+               init.setInitializerClause(deblock(target.copy(CopyStyle.withLocations)));
+               decl.setInitializer(init);
+               simple.addDeclarator(decl);
+
+               return new CPPASTDeclarationStatement(simple);
+       }
+
+       /**
+        * Removes surrounding parentheses from an expression.  If the expression
+        * does not have surrounding parentheses, the original expression is returned.
+        */
+       private static IASTExpression deblock(IASTExpression expression) {
+               if (expression instanceof IASTUnaryExpression) {
+                       IASTUnaryExpression unary = (IASTUnaryExpression)expression;
+                       if (unary.getOperator() == IASTUnaryExpression.op_bracketedPrimary) {
+                               return deblock(unary.getOperand());
+                       }
+               }
+               return expression;
+       }
+
+       public String guessTempName() {
+               String[] proposals= guessTempNames();
+               if (proposals.length == 0) {
+                       return info.getName();
+               } else {
+                       String name = proposals[proposals.length - 1];
+                       return name;
+               }
+       }
+
+       private String[] getPrefixes() {
+               // In Future we could use user preferences to define the prefixes
+               String[] prefixes = { "get", "is" }; //$NON-NLS-1$//$NON-NLS-2$
+               return prefixes;
+       }
+
+       /**
+        * @return proposed variable names (may be empty, but not null). The first
+        *         proposal should be used as "best guess" (if it exists).
+        */
+       public String[] guessTempNames() {
+               final List<String> guessedTempNames = new ArrayList<String>();
+               final List<String> usedNames = new ArrayList<String>();
+               IASTFunctionDefinition funcDef = NodeHelper.findFunctionDefinitionInAncestors(target);
+               final IScope scope;
+               if (funcDef != null && funcDef.getBody() instanceof IASTCompoundStatement) {
+                       IASTCompoundStatement body = (IASTCompoundStatement)funcDef.getBody();
+                       scope = body.getScope();
+               } else {
+                       scope = null;
+               }
+
+               if (target != null) {
+                       target.accept(new ASTVisitor() {
+                               {
+                                       shouldVisitNames = true;
+                                       shouldVisitExpressions = true;
+                               }
+
+                               @Override
+                               public int visit(IASTName name) {
+                                       addTempName(name.getLastName().toString());
+                                       return super.visit(name);
+                               }
+
+                               @Override
+                               public int visit(IASTExpression expression) {
+                                       // If the expression starts with a function call with a name, we should only
+                                       // need to guess this name
+                                       if (expression == target && expression instanceof ICPPASTFunctionCallExpression) {
+                                               ICPPASTFunctionCallExpression functionCallExpression = (ICPPASTFunctionCallExpression) expression;
+                                               IASTExpression functionNameExpression = functionCallExpression.getFunctionNameExpression();
+                                               if (functionNameExpression instanceof IASTIdExpression) {
+                                                       IASTIdExpression idExpression = (IASTIdExpression) functionNameExpression;
+                                                       if (idExpression.getName() != null) {
+                                                               addTempName(idExpression.getName().getLastName().toString());
+                                                               if (guessedTempNames.size() > 0) {
+                                                                       return PROCESS_ABORT;
+                                                               }
+                                                       }
+                                               }
+                                       }
+                                       
+                                       if (expression instanceof CPPASTLiteralExpression) {
+                                               CPPASTLiteralExpression literal = (CPPASTLiteralExpression) expression;
+                                               String name = null;
+                                               char[] value = literal.getValue();
+                                               switch (literal.getKind()) {
+                                         case IASTLiteralExpression.lk_char_constant:
+                                             name = Character.toString(value[0]);
+                                             break;
+                                         case IASTLiteralExpression.lk_float_constant:
+                                             name = "f"; //$NON-NLS-1$
+                                             break;
+                                         case IASTLiteralExpression.lk_integer_constant:
+                                             name = "i"; //$NON-NLS-1$
+                                             break;
+                                         case IASTLiteralExpression.lk_string_literal:
+                                             name = literal.toString();
+                                             break;
+                                         case IASTLiteralExpression.lk_false:
+                                         case IASTLiteralExpression.lk_true:
+                                             name = "b"; //$NON-NLS-1$
+                                             break;
+                                               }
+                                               if (name != null) {
+                                                       addTempName(name);
+                                               }
+                                       }
+                                       return super.visit(expression);
+                               }
+
+                               private void addTempName(String name) {
+                                       name = trimPrefixes(name);
+
+                               IPreferencesService preferences = Platform.getPreferencesService();
+                               int capitalization = preferences.getInt(CUIPlugin.PLUGIN_ID,
+                                               PreferenceConstants.NAME_STYLE_VARIABLE_CAPITALIZATION,
+                                               PreferenceConstants.NAME_STYLE_CAPITALIZATION_LOWER_CAMEL_CASE, null);
+                               String wordDelimiter = preferences.getString(CUIPlugin.PLUGIN_ID,
+                                               PreferenceConstants.NAME_STYLE_VARIABLE_WORD_DELIMITER, "", null); //$NON-NLS-1$
+                               String prefix = preferences.getString(CUIPlugin.PLUGIN_ID,
+                                                                       PreferenceConstants.NAME_STYLE_VARIABLE_PREFIX, "", null); //$NON-NLS-1$
+                               String suffix = preferences.getString(CUIPlugin.PLUGIN_ID,
+                                               PreferenceConstants.NAME_STYLE_VARIABLE_SUFFIX, "", null); //$NON-NLS-1$
+                               NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
+                               name = composer.compose(name);
+                                       
+                                       if (name.length() > 0) {
+                                               if (nameAvailable(name, guessedTempNames, scope)) {
+                                                       guessedTempNames.add(name);
+                                               } else {
+                                                       usedNames.add(name);
+                                               }
+                                       }
+                               }
+
+                       });
+               }
+               if (guessedTempNames.isEmpty()) {
+                       String name = makeTempName(usedNames, scope);
+                       if (name != null) {
+                               guessedTempNames.add(name);
+                       }
+               }
+               return guessedTempNames.toArray(new String[guessedTempNames.size()]);
+       }
+
+       private String trimPrefixes(String name) {
+               String lower = name.toLowerCase();
+               int start = 0;
+               for (String prefix : getPrefixes()) {
+                       if (lower.startsWith(prefix)) {
+                               if (name.length() > prefix.length()) {
+                                       start = prefix.length();
+                               }
+                       }
+                       prefix = prefix + "_"; //$NON-NLS-1$
+                       if (lower.startsWith(prefix)) {
+                               if (name.length() > prefix.length()) {
+                                       start = prefix.length();
+                               }
+                       }
+               }
+
+               if (start > 0) {
+                       String nameWithoutPrefix = name.substring(start);
+                       if (Character.isUpperCase(nameWithoutPrefix.charAt(0))) {
+                               nameWithoutPrefix = nameWithoutPrefix.substring(0, 1).toLowerCase()
+                                               + nameWithoutPrefix.substring(1);
+                       }
+
+                       if (!Character.isJavaIdentifierStart(nameWithoutPrefix.charAt(0))) {
+                               nameWithoutPrefix = "_" + nameWithoutPrefix; //$NON-NLS-1$
+                       }
+                       return nameWithoutPrefix;
+               } else {
+                       return name;
+               }
+       }
+
+       private boolean nameAvailable(String name, List<String> guessedNames, IScope scope) {
+               if (guessedNames.contains(name) || info.getUsedNames().contains(name)) {
+                       return false;
+               }
+               if (scope != null) {
+                       IBinding[] bindings = scope.find(name);
+                       return bindings == null || bindings.length == 0;
+               }
+               return true; // no name references found
+       }
+
+       private String makeTempName(List<String> usedNames, IScope scope) {
+               List<String> noNames = new ArrayList<String>();
+               for (int i = 0; i < 10; i++) {
+                       for (String used : usedNames) {
+                               String name = used + i;   // such as "i2"
+                               if (nameAvailable(name, noNames, scope)) {
+                                       return name;
+                               }
+                       }
+               }
+               return null;
+       }
+
+       @Override
+       protected RefactoringDescriptor getRefactoringDescriptor() {
+               Map<String, String> arguments = getArgumentMap();
+               RefactoringDescriptor desc = new ExtractLocalVariableRefactoringDescription(project.getProject().getName(),
+                               "Extract Local Variable Refactoring", "Extract " + target.getRawSignature(), arguments);  //$NON-NLS-1$//$NON-NLS-2$
+               return desc;
+       }
+
+       private Map<String, String> getArgumentMap() {
+               Map<String, String> arguments = new HashMap<String, String>();
+               arguments.put(CRefactoringDescription.FILE_NAME, file.getLocationURI().toString());
+               arguments.put(CRefactoringDescription.SELECTION, region.getOffset() + "," + region.getLength()); //$NON-NLS-1$
+               arguments.put(ExtractLocalVariableRefactoringDescription.NAME, info.getName());
+               return arguments;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringContribution.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringContribution.java
new file mode 100644 (file)
index 0000000..51c4559
--- /dev/null
@@ -0,0 +1,35 @@
+/*******************************************************************************\r
+ * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik  \r
+ * Rapperswil, University of applied sciences and others.\r
+ * All rights reserved. This program and the accompanying materials \r
+ * are made available under the terms of the Eclipse Public License v1.0 \r
+ * which accompanies this distribution, and is available at \r
+ * http://www.eclipse.org/legal/epl-v10.html  \r
+ * \r
+ * Contributors: \r
+ * Institute for Software (IFS)- initial API and implementation \r
+ ******************************************************************************/\r
+package org.eclipse.cdt.internal.ui.refactoring.extractlocalvariable;\r
+\r
+import java.util.Map;\r
+\r
+import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;\r
+\r
+import org.eclipse.cdt.internal.ui.refactoring.CRefactoringContribution;\r
+\r
+/**\r
+ * @author Emanuel Graf IFS\r
+ */\r
+public class ExtractLocalVariableRefactoringContribution extends CRefactoringContribution {\r
+\r
+       @SuppressWarnings({ "unchecked", "rawtypes" })\r
+       @Override\r
+       public RefactoringDescriptor createDescriptor(String id, String project, String description,\r
+                       String comment, Map arguments, int flags) throws IllegalArgumentException {\r
+               if (id.equals(ExtractLocalVariableRefactoring.ID)) {\r
+                       return new ExtractLocalVariableRefactoringDescription(project, description, comment, arguments);\r
+               } else {\r
+                       return null;\r
+               }\r
+       }\r
+}\r
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringDescription.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringDescription.java
new file mode 100644 (file)
index 0000000..86e7220
--- /dev/null
@@ -0,0 +1,56 @@
+/*******************************************************************************\r
+ * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik  \r
+ * Rapperswil, University of applied sciences and others.\r
+ * All rights reserved. This program and the accompanying materials \r
+ * are made available under the terms of the Eclipse Public License v1.0 \r
+ * which accompanies this distribution, and is available at \r
+ * http://www.eclipse.org/legal/epl-v10.html  \r
+ * \r
+ * Contributors: \r
+ * Institute for Software (IFS)- initial API and implementation \r
+ ******************************************************************************/\r
+package org.eclipse.cdt.internal.ui.refactoring.extractlocalvariable;\r
+\r
+import java.util.Map;\r
+\r
+import org.eclipse.core.resources.IFile;\r
+import org.eclipse.core.runtime.CoreException;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.ltk.core.refactoring.Refactoring;\r
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;\r
+\r
+import org.eclipse.cdt.core.model.ICProject;\r
+\r
+import org.eclipse.cdt.internal.ui.refactoring.CRefactoringDescription;\r
+import org.eclipse.cdt.internal.ui.refactoring.NameNVisibilityInformation;\r
+\r
+/**\r
+ * @author Emanuel Graf IFS\r
+ *\r
+ */\r
+public class ExtractLocalVariableRefactoringDescription extends CRefactoringDescription {\r
+       \r
+       static protected final String NAME = "name";  //$NON-NLS-1$\r
+\r
+       public ExtractLocalVariableRefactoringDescription(String project, String description,\r
+                       String comment, Map<String, String> arguments) {\r
+               super(ExtractLocalVariableRefactoring.ID, project, description, comment,\r
+                               CRefactoringDescription.MULTI_CHANGE, arguments);\r
+       }\r
+\r
+       @Override\r
+       public Refactoring createRefactoring(RefactoringStatus status) throws CoreException {\r
+               IFile file;\r
+               NameNVisibilityInformation info = new NameNVisibilityInformation();\r
+               ICProject proj;\r
+               \r
+               info.setName(arguments.get(NAME));\r
+               \r
+               proj = getCProject();\r
+               \r
+               file = getFile();\r
+               \r
+               ISelection selection = getSelection();\r
+               return new ExtractLocalVariableRefactoring(file, selection, info, proj);\r
+       }\r
+}\r
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringRunner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringRunner.java
new file mode 100644 (file)
index 0000000..238bd66
--- /dev/null
@@ -0,0 +1,51 @@
+/*******************************************************************************\r
+ * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik  \r
+ * Rapperswil, University of applied sciences and others\r
+ * All rights reserved. This program and the accompanying materials \r
+ * are made available under the terms of the Eclipse Public License v1.0 \r
+ * which accompanies this distribution, and is available at \r
+ * http://www.eclipse.org/legal/epl-v10.html  \r
+ *  \r
+ * Contributors: \r
+ * Institute for Software - initial API and implementation\r
+ *******************************************************************************/\r
+package org.eclipse.cdt.internal.ui.refactoring.extractlocalvariable;\r
+\r
+import org.eclipse.core.resources.IFile;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.jface.window.IShellProvider;\r
+import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;\r
+\r
+import org.eclipse.cdt.core.model.ICProject;\r
+\r
+import org.eclipse.cdt.internal.ui.refactoring.CRefactoring;\r
+import org.eclipse.cdt.internal.ui.refactoring.NameNVisibilityInformation;\r
+import org.eclipse.cdt.internal.ui.refactoring.RefactoringRunner;\r
+\r
+/**\r
+ * Extract Local Variable refactoring runner.\r
+ * \r
+ * @author Tom Ball\r
+ */\r
+public class ExtractLocalVariableRefactoringRunner extends RefactoringRunner {\r
+\r
+       public ExtractLocalVariableRefactoringRunner(IFile file, ISelection selection,\r
+                       IShellProvider shellProvider, ICProject cProject) {\r
+               super(file, selection, null, shellProvider, cProject);\r
+       }\r
+\r
+       @Override\r
+       public void run() {\r
+               NameNVisibilityInformation info = new NameNVisibilityInformation();\r
+               CRefactoring refactoring = new ExtractLocalVariableRefactoring(file, selection, info, project);\r
+               ExtractLocalVariableRefactoringWizard wizard = new ExtractLocalVariableRefactoringWizard(\r
+                               refactoring, info);\r
+               RefactoringWizardOpenOperation operator = new RefactoringWizardOpenOperation(wizard);\r
+\r
+               try {\r
+                       operator.run(shellProvider.getShell(), refactoring.getName());\r
+               } catch (InterruptedException e) {\r
+                       // initial condition checking got canceled by the user.\r
+               }\r
+       }\r
+}\r
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/ExtractLocalVariableRefactoringWizard.java
new file mode 100644 (file)
index 0000000..f4d05a1
--- /dev/null
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractlocalvariable;
+
+import org.eclipse.ltk.core.refactoring.Refactoring;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
+
+import org.eclipse.cdt.internal.ui.refactoring.NameNVisibilityInformation;
+
+/**
+ * The wizard page for Extract Local Variable Refactoring, creates the UI page.
+ * 
+ * @author Tom Ball
+ */
+public class ExtractLocalVariableRefactoringWizard extends RefactoringWizard {
+       private InputPage page;
+       private final NameNVisibilityInformation info;
+
+       public ExtractLocalVariableRefactoringWizard(Refactoring refactoring,
+                       NameNVisibilityInformation info) {
+               super(refactoring, WIZARD_BASED_USER_INTERFACE);
+               this.info = info;
+       }
+
+       @Override
+       protected void addUserInputPages() {
+               page = new InputPage(Messages.ExtractLocalVariable, info);
+               addPage(page);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/InputPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/InputPage.java
new file mode 100644 (file)
index 0000000..2120354
--- /dev/null
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *     Institute for Software - initial API and implementation
+ *     Google
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractlocalvariable;
+
+import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.internal.ui.refactoring.NameNVisibilityInformation;
+import org.eclipse.cdt.internal.ui.refactoring.dialogs.LabeledTextField;
+import org.eclipse.cdt.internal.ui.refactoring.utils.IdentifierHelper;
+import org.eclipse.cdt.internal.ui.refactoring.utils.IdentifierResult;
+
+/**
+ * Input verification page for the ExtractLocalVariable refactoring, cloned
+ * from org.eclipse.cdt.internal.ui.refactoring.extractconstant.InputPage.
+ * 
+ * @author Tom Ball
+ */
+public class InputPage extends UserInputWizardPage {
+       private String label = Messages.VariableName;
+       private final NameNVisibilityInformation info;
+       private InputForm control;
+
+       public InputPage(String name, NameNVisibilityInformation info) {
+               super(name);
+               this.info = info;
+       }
+
+       public String getVariableName() {
+               return info.getName();
+       }
+
+       public void createControl(Composite parent) {
+               control = new InputForm(parent, label);
+
+               setTitle(getName());
+               setMessage(Messages.EnterVariableName);
+               setPageComplete(false);
+               Text nameText = control.getVariableNameText();
+               nameText.setText(info.getName());
+               nameText.addModifyListener(new ModifyListener() {
+                       public void modifyText(ModifyEvent e) {
+                               info.setName(control.getVariableNameText().getText());
+                               checkName();
+                       }
+               });
+
+               nameText.selectAll();
+               checkName();
+               setControl(control);
+       }
+
+       private void verifyName(String name) {
+               if (info.getUsedNames().contains(name)) {
+                       setErrorMessage(NLS.bind(Messages.NameAlreadyDefined, name));
+                       setPageComplete(false);
+               }
+       }
+
+       private void checkName() {
+               String methodName = control.getVariableNameText().getText();
+               IdentifierResult result = IdentifierHelper
+                               .checkIdentifierName(methodName);
+               if (result.isCorrect()) {
+                       setErrorMessage(null);
+                       setPageComplete(true);
+                       verifyName(methodName);
+               } else {
+                       setErrorMessage(NLS.bind(Messages.CheckName, result.getMessage()));
+                       setPageComplete(false);
+               }
+       }
+
+       private static class InputForm extends Composite {
+               LabeledTextField variableName;
+
+               InputForm(Composite parent, String label) {
+                       super(parent, SWT.NONE);
+                       FillLayout layout = new FillLayout(SWT.HORIZONTAL);
+                       GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true,
+                                       false);
+                       gridData.horizontalAlignment = GridData.FILL;
+                       setLayoutData(gridData);
+                       setLayout(layout);
+                       variableName = new LabeledTextField(this, label, ""); //$NON-NLS-1$
+               }
+
+               Text getVariableNameText() {
+                       return variableName.getText();
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/Messages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/Messages.java
new file mode 100644 (file)
index 0000000..04df31e
--- /dev/null
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *     Institute for Software - initial API and implementation
+ *     Google
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.extractlocalvariable;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class Messages extends NLS {
+       public static String CheckName;
+       public static String CreateLocalVariable;
+       public static String EnterVariableName;
+       public static String ExpressionMustBeSelected;
+       public static String ExtractLocalVariable;
+       public static String NameAlreadyDefined;
+       public static String NoExpressionSelected;
+       public static String ReplaceExpression;
+       public static String TooManyExpressionsSelected;
+       public static String VariableName;
+
+       static {
+               NLS.initializeMessages(Messages.class.getName(), Messages.class);
+       }
+
+       // Do not instantiate
+       private Messages() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/Messages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractlocalvariable/Messages.properties
new file mode 100644 (file)
index 0000000..f5ea2ee
--- /dev/null
@@ -0,0 +1,23 @@
+###############################################################################
+# Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
+# Rapperswil, University of applied sciences and others
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#    Institute for Software - initial API and implementation
+#    IBM Corporation
+#    Google
+###############################################################################
+VariableName=Variable &name:
+EnterVariableName=Enter a name for the new variable
+CheckName=Check Name: {0}
+NameAlreadyDefined=An element named ''{0}'' is already defined in this scope.
+ExtractLocalVariable=Extract Local Variable
+ExpressionMustBeSelected=An expression must be selected to activate this refactoring.
+NoExpressionSelected=No expression selected.
+TooManyExpressionsSelected=Too many expressions selected.
+CreateLocalVariable=Create Local Variable
+ReplaceExpression=Replace an expression
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/FunctionFactory.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/FunctionFactory.java
new file mode 100644 (file)
index 0000000..83fed44
--- /dev/null
@@ -0,0 +1,196 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *     Institute for Software - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters;
+
+import java.util.Arrays;
+
+import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode.CopyStyle;
+import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.parser.Keywords;
+
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTBinaryExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCompoundStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTExpressionStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFieldReference;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDeclarator;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDefinition;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTParameterDeclaration;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTReturnStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclSpecifier;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclaration;
+
+public class FunctionFactory {
+
+       public static IASTFunctionDefinition createGetterDefinition(IASTName fieldName,
+                       IASTSimpleDeclaration fieldDeclaration, ICPPASTQualifiedName name) {
+               IASTFunctionDefinition getter = new CPPASTFunctionDefinition();
+               
+               getter.setDeclSpecifier(fieldDeclaration.getDeclSpecifier().copy(CopyStyle.withLocations));
+               IASTDeclarator getterDeclarator = getGetterDeclarator(fieldName, fieldDeclaration, name);
+               // IASTFunctionDefinition. expects the outermost IASTFunctionDeclarator in declarator hierarchy
+               while (!(getterDeclarator instanceof IASTFunctionDeclarator)) {
+                       getterDeclarator = getterDeclarator.getNestedDeclarator();
+               }
+               getter.setDeclarator((IASTFunctionDeclarator) getterDeclarator);
+               getter.setBody(getGetterBody(fieldName));
+               return getter;
+       }
+
+       private static CPPASTCompoundStatement getGetterBody(IASTName fieldName) {
+               CPPASTCompoundStatement compound = new CPPASTCompoundStatement();
+               CPPASTReturnStatement returnStatement = new CPPASTReturnStatement();
+               CPPASTIdExpression idExpr = new CPPASTIdExpression();
+               CPPASTName returnVal = new CPPASTName();
+               returnVal.setName(fieldName.toCharArray());
+               idExpr.setName(returnVal);
+               returnStatement.setReturnValue(idExpr);
+               compound.addStatement(returnStatement);
+               return compound;
+       }
+
+       private static IASTDeclarator getGetterDeclarator(IASTName fieldName,
+                       IASTSimpleDeclaration fieldDeclaration, ICPPASTQualifiedName name) {
+               CPPASTName getterName = new CPPASTName();
+               getterName.setName(GetterSetterNameGenerator.generateGetterName(fieldName).toCharArray());
+
+               // copy declarator hierarchy
+               IASTDeclarator topDeclarator = fieldDeclaration.getDeclarators()[0].copy(CopyStyle.withLocations);
+               
+               // find the innermost declarator in hierarchy
+               IASTDeclarator innermost = topDeclarator;
+               while (innermost.getNestedDeclarator() != null) {
+                       innermost = innermost.getNestedDeclarator();
+               }
+               
+               // create a new innermost function declarator basing on the field declarator 
+               CPPASTFunctionDeclarator functionDeclarator = new CPPASTFunctionDeclarator();
+               functionDeclarator.setConst(true);
+               if (name != null) {
+                       name.addName(getterName);
+                       functionDeclarator.setName(name);
+               } else {
+                       functionDeclarator.setName(getterName);
+               }
+               for (IASTPointerOperator pointer : innermost.getPointerOperators()){
+                       functionDeclarator.addPointerOperator(pointer.copy(CopyStyle.withLocations));
+               }
+               
+               // replace innermost with functionDeclarator and return the whole declarator tree
+               if (innermost == topDeclarator) {
+                       // no tree
+                       return functionDeclarator;
+               } else {
+                       IASTDeclarator parent = (IASTDeclarator) innermost.getParent();
+                       parent.setNestedDeclarator(functionDeclarator);
+                       return topDeclarator;
+               }
+       }
+
+       public static IASTFunctionDefinition createSetterDefinition(IASTName fieldName,
+                       IASTSimpleDeclaration fieldDeclaration, ICPPASTQualifiedName name) {
+               IASTFunctionDefinition setter = new CPPASTFunctionDefinition();
+               setter.setDeclSpecifier(getVoidDeclSpec());             
+               setter.setDeclarator(getSetterDeclarator(fieldName, fieldDeclaration, name));
+               setter.setBody(getSetterBody(fieldDeclaration));
+               return setter;
+       }
+
+       private static CPPASTCompoundStatement getSetterBody(IASTSimpleDeclaration fieldDeclaration) {
+               CPPASTCompoundStatement compound = new CPPASTCompoundStatement();
+               CPPASTExpressionStatement exprStmt = new CPPASTExpressionStatement();
+               CPPASTBinaryExpression binExpr = new CPPASTBinaryExpression();
+               IASTDeclarator innerDeclarator = fieldDeclaration.getDeclarators()[0];
+               while (innerDeclarator.getNestedDeclarator() != null) {
+                       innerDeclarator = innerDeclarator.getNestedDeclarator();
+               }
+               IASTName fieldName = innerDeclarator.getName();
+               CPPASTName parameterName = getSetterParameterName(fieldName);
+               if (Arrays.equals(fieldName.getSimpleID(), parameterName.getSimpleID())) {
+                       CPPASTFieldReference fieldRef = new CPPASTFieldReference();
+                       CPPASTLiteralExpression litExpr = new CPPASTLiteralExpression();
+                       litExpr.setValue(Keywords.cTHIS); 
+                       fieldRef.setFieldOwner(litExpr);
+                       fieldRef.setIsPointerDereference(true);
+                       fieldRef.setFieldName(fieldName.copy(CopyStyle.withLocations));
+                       binExpr.setOperand1(fieldRef);
+               } else {
+                       CPPASTIdExpression idExpr = new CPPASTIdExpression(fieldName.copy(CopyStyle.withLocations));
+                       binExpr.setOperand1(idExpr);
+               }
+               binExpr.setOperator(IASTBinaryExpression.op_assign);
+               CPPASTIdExpression idExpr = new CPPASTIdExpression(parameterName);
+               binExpr.setOperand2(idExpr);
+               exprStmt.setExpression(binExpr);
+               compound.addStatement(exprStmt);
+               return compound;
+       }
+
+       private static CPPASTFunctionDeclarator getSetterDeclarator(IASTName fieldName,
+                       IASTSimpleDeclaration fieldDeclaration, ICPPASTQualifiedName name) {
+               CPPASTName setterName = new CPPASTName();
+               setterName.setName(GetterSetterNameGenerator.generateSetterName(fieldName).toCharArray());
+               CPPASTFunctionDeclarator declarator = new CPPASTFunctionDeclarator();
+               if (name != null) {
+                       name.addName(setterName);
+                       declarator.setName(name);
+               } else {
+                       declarator.setName(setterName);
+               }
+               CPPASTParameterDeclaration parameterDeclaration = new CPPASTParameterDeclaration();
+               IASTDeclarator parameterDeclarator = fieldDeclaration.getDeclarators()[0].copy(CopyStyle.withLocations);
+               parameterDeclarator.setName(getSetterParameterName(fieldName));
+               parameterDeclaration.setDeclarator(parameterDeclarator);
+               parameterDeclaration.setDeclSpecifier(fieldDeclaration.getDeclSpecifier().copy(
+                               CopyStyle.withLocations));
+               declarator.addParameterDeclaration(parameterDeclaration.copy(CopyStyle.withLocations));
+               return declarator;
+       }
+
+       private static CPPASTName getSetterParameterName(IASTName fieldName) {
+               String parameterName = GetterSetterNameGenerator.generateSetterParameterName(fieldName);
+               return new CPPASTName(parameterName.toCharArray());
+       }
+
+       private static CPPASTSimpleDeclSpecifier getVoidDeclSpec() {
+               CPPASTSimpleDeclSpecifier declSpecifier = new CPPASTSimpleDeclSpecifier();
+               declSpecifier.setType(IASTSimpleDeclSpecifier.t_void);
+               return declSpecifier;
+       }
+
+       public static IASTSimpleDeclaration createGetterDeclaration(IASTName fieldName,
+                       IASTSimpleDeclaration fieldDeclaration) {
+               IASTSimpleDeclaration getter = new CPPASTSimpleDeclaration();
+               getter.setDeclSpecifier(fieldDeclaration.getDeclSpecifier().copy(CopyStyle.withLocations));
+               getter.addDeclarator(getGetterDeclarator(fieldName, fieldDeclaration, null));
+               return getter;
+       }
+
+       public static IASTSimpleDeclaration createSetterDeclaration(IASTName fieldName,
+                       IASTSimpleDeclaration fieldDeclaration) {
+               IASTSimpleDeclaration setter = new CPPASTSimpleDeclaration();
+               setter.setDeclSpecifier(getVoidDeclSpec());             
+               setter.addDeclarator(getSetterDeclarator(fieldName, fieldDeclaration, null));
+               return setter;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersInputPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersInputPage.java
new file mode 100644 (file)
index 0000000..5b272b2
--- /dev/null
@@ -0,0 +1,232 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *     Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters;
+
+import java.util.Set;
+import java.util.SortedSet;
+
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.ui.dialogs.ContainerCheckedTreeViewer;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.preferences.NameStylePreferencePage;
+import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.GetterSetterContext.FieldWrapper;
+import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.GetterSetterInsertEditProvider.AccessorKind;
+
+public class GenerateGettersAndSettersInputPage extends UserInputWizardPage implements IPreferenceChangeListener {
+       private GetterSetterContext context;
+       private ContainerCheckedTreeViewer variableSelectionView;
+       private GetterSetterLabelProvider labelProvider;
+
+       public GenerateGettersAndSettersInputPage(GetterSetterContext context) {
+               super(Messages.GettersAndSetters_Name); 
+               this.context = context;
+               IEclipsePreferences node = InstanceScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID);
+               // We are listening for changes in the Name Style preferences
+               node.addPreferenceChangeListener(this);
+       }
+
+       public void createControl(Composite parent) {
+               Composite comp = new Composite(parent, SWT.NONE);
+               
+               setTitle(Messages.GettersAndSetters_Name);
+               setMessage(Messages.GenerateGettersAndSettersInputPage_header);
+               
+               comp.setLayout(new GridLayout(2, false));
+               createTree(comp);
+               GridData gd = new GridData(GridData.FILL_BOTH);
+               variableSelectionView.getTree().setLayoutData(gd);
+               
+               Composite btComp = createButtonComposite(comp);
+               gd = new GridData();
+               gd.verticalAlignment = SWT.TOP;
+               btComp.setLayoutData(gd);
+               
+               final Button placeImplemetation = new Button(comp, SWT.CHECK);
+               placeImplemetation.setText(Messages.GenerateGettersAndSettersInputPage_PlaceImplHeader);
+               gd = new GridData();
+               gd.horizontalSpan = 2;
+               gd.heightHint = 40;
+               placeImplemetation.setLayoutData(gd);
+               placeImplemetation.setSelection(context.isImplementationInHeader());
+               placeImplemetation.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               context.setImplementationInHeader(placeImplemetation.getSelection());
+                       }
+               });
+
+               Link link= new Link(comp, SWT.WRAP);
+               link.setText(Messages.GenerateGettersAndSettersInputPage_LinkDescription);
+               link.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               String id = NameStylePreferencePage.PREF_ID;
+                               PreferencesUtil.createPreferenceDialogOn(getShell(), id, new String [] { id }, null).open();
+                       }
+               });
+               link.setToolTipText(Messages.GenerateGettersAndSettersInputPage_LinkTooltip);
+
+               gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
+               gd.grabExcessHorizontalSpace = true;
+               link.setLayoutData(gd);
+
+               setControl(comp);
+       }
+
+       private Composite createButtonComposite(Composite comp) {
+               Composite btComp = new Composite(comp, SWT.NONE);
+               FillLayout layout = new FillLayout(SWT.VERTICAL);
+               layout.spacing = 4;
+               btComp.setLayout(layout);
+               
+               Button selectAll = new Button(btComp, SWT.PUSH);
+               selectAll.setText(Messages.GenerateGettersAndSettersInputPage_SelectAll);
+               selectAll.addSelectionListener(new SelectionAdapter(){
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               Object[] items = context.getElements(null);
+                               SortedSet<GetterSetterInsertEditProvider> checkedFunctions = context.selectedFunctions;
+                               for (Object treeItem : items) {
+                                       variableSelectionView.setChecked(treeItem, true);
+                                       Object[] childs = context.getChildren(treeItem);
+                                       for(Object currentElement : childs){
+                                               if (currentElement instanceof GetterSetterInsertEditProvider) {
+                                                       GetterSetterInsertEditProvider editProvider = (GetterSetterInsertEditProvider) currentElement;
+                                                       checkedFunctions.add(editProvider);
+                                               }
+                                       }
+                               }
+                       }
+               });
+               
+               Button deselectAll = new Button(btComp, SWT.PUSH);
+               deselectAll.setText(Messages.GenerateGettersAndSettersInputPage_DeselectAll);
+               deselectAll.addSelectionListener(new SelectionAdapter(){
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               Object[] items = context.getElements(null);
+                               for (Object treeItem : items) {
+                                       variableSelectionView.setChecked(treeItem, false);
+                               }
+                               context.selectedFunctions.clear();
+                       }
+               });
+               
+               Button selectGetter = new Button(btComp, SWT.PUSH);
+               selectGetter.setText(Messages.GenerateGettersAndSettersInputPage_SelectGetters);
+               selectGetter.addSelectionListener(new SelectionAdapter(){
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               selectMethods(AccessorKind.GETTER);
+                       }
+               });
+               
+               Button selectSetter = new Button(btComp, SWT.PUSH);
+               selectSetter.setText(Messages.GenerateGettersAndSettersInputPage_SelectSetters);
+               selectSetter.addSelectionListener(new SelectionAdapter(){
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               selectMethods(AccessorKind.SETTER);
+                       }
+               });
+               
+               return btComp;
+       }
+       
+       private void selectMethods(AccessorKind type) {
+               Object[] items = context.getElements(null);
+               Set<GetterSetterInsertEditProvider> checked = context.selectedFunctions;
+               for (Object treeItem : items) {
+                       if (treeItem instanceof FieldWrapper) {
+                               FieldWrapper field = (FieldWrapper) treeItem;
+                               Object[] funtions = context.getChildren(field);
+                               for (Object funct : funtions) {
+                                       if (funct instanceof GetterSetterInsertEditProvider) {
+                                               GetterSetterInsertEditProvider getSet = (GetterSetterInsertEditProvider) funct;
+                                               if(getSet.getType() == type) {
+                                                       checked.add(getSet);
+                                                       variableSelectionView.setChecked(getSet, true);
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+
+       private void createTree(Composite comp) {
+               variableSelectionView = new ContainerCheckedTreeViewer(comp, SWT.BORDER);
+               labelProvider = new GetterSetterLabelProvider();
+               variableSelectionView.setContentProvider(context);
+               variableSelectionView.setLabelProvider(labelProvider);
+
+               variableSelectionView.setAutoExpandLevel(3);
+               variableSelectionView.setInput(""); //$NON-NLS-1$
+               if (context.selectedName != null) {
+                       String rawSignature = context.selectedName.getRawSignature();
+                       for (Object obj : variableSelectionView.getVisibleExpandedElements()) {
+                               if (obj instanceof FieldWrapper) {
+                                       if (obj.toString().contains(rawSignature)) {
+                                               variableSelectionView.setSubtreeChecked(obj, true);
+                                       }
+                               }
+                       }
+               }
+               Set<GetterSetterInsertEditProvider> checkedFunctions = context.selectedFunctions;
+               for (Object currentElement : variableSelectionView.getCheckedElements()) {
+                       if (currentElement instanceof GetterSetterInsertEditProvider) {
+                               GetterSetterInsertEditProvider editProvider = (GetterSetterInsertEditProvider) currentElement;
+                               checkedFunctions.add(editProvider);
+                       }
+               }
+               variableSelectionView.addCheckStateListener(new ICheckStateListener() {
+
+                       public void checkStateChanged(CheckStateChangedEvent event) {
+                               Set<GetterSetterInsertEditProvider> checkedFunctions = context.selectedFunctions;
+                               for (Object currentElement : variableSelectionView.getCheckedElements()) {
+                                       if (currentElement instanceof GetterSetterInsertEditProvider) {
+                                               GetterSetterInsertEditProvider editProvider = (GetterSetterInsertEditProvider) currentElement;
+                                               checkedFunctions.add(editProvider);
+                                       }
+                               }
+                       }
+               });
+       }
+
+       public void preferenceChange(PreferenceChangeEvent event) {
+               if (variableSelectionView.getTree().isDisposed()) {
+                       return;
+               }
+               
+               if (GetterSetterNameGenerator.getGenerateGetterSettersPreferenceKeys().contains(event.getKey())) {
+                       context.refresh();
+                       variableSelectionView.refresh();
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoring.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoring.java
new file mode 100644 (file)
index 0000000..674491b
--- /dev/null
@@ -0,0 +1,290 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *        Institute for Software - initial API and implementation
+ *        Sergey Prigogin (Google)
+ *        Marc-Andre Laperle - do not search for definition insert location twice. 
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+
+import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+
+import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ContainerNode;
+
+import org.eclipse.cdt.internal.ui.refactoring.CRefactoring2;
+import org.eclipse.cdt.internal.ui.refactoring.AddDeclarationNodeToClassChange;
+import org.eclipse.cdt.internal.ui.refactoring.Container;
+import org.eclipse.cdt.internal.ui.refactoring.ModificationCollector;
+import org.eclipse.cdt.internal.ui.refactoring.RefactoringASTCache;
+import org.eclipse.cdt.internal.ui.refactoring.implementmethod.InsertLocation;
+import org.eclipse.cdt.internal.ui.refactoring.implementmethod.MethodDefinitionInsertLocationFinder;
+import org.eclipse.cdt.internal.ui.refactoring.utils.Checks;
+import org.eclipse.cdt.internal.ui.refactoring.utils.NodeHelper;
+import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
+
+/**
+ * @author Thomas Corbat
+ */
+public class GenerateGettersAndSettersRefactoring extends CRefactoring2 {
+
+       private final class CompositeTypeSpecFinder extends ASTVisitor {
+               private final int start;
+               private final Container<IASTCompositeTypeSpecifier> container;
+               {
+                       shouldVisitDeclSpecifiers = true;
+               }
+
+               private CompositeTypeSpecFinder(int start, Container<IASTCompositeTypeSpecifier> container) {
+                       this.start = start;
+                       this.container = container;
+               }
+
+               @Override
+               public int visit(IASTDeclSpecifier declSpec) {
+                       if (declSpec instanceof IASTCompositeTypeSpecifier) {
+                               IASTFileLocation loc = declSpec.getFileLocation();
+                               if (start > loc.getNodeOffset() && start < loc.getNodeOffset() + loc.getNodeLength()) {
+                                       container.setObject((IASTCompositeTypeSpecifier) declSpec);
+                                       return ASTVisitor.PROCESS_ABORT;
+                               }
+                       }
+                       
+                       return super.visit(declSpec);
+               }
+       }
+
+       private static final String MEMBER_DECLARATION = "MEMBER_DECLARATION"; //$NON-NLS-1$
+       private final GetterSetterContext context;
+       private InsertLocation definitionInsertLocation;        
+       
+       public GenerateGettersAndSettersRefactoring(ICElement element, ISelection selection,
+                       ICProject project, RefactoringASTCache astCache) {
+               super(element, selection, project, astCache);
+               context = new GetterSetterContext();
+       }
+       
+       @Override
+       public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
+                       throws CoreException, OperationCanceledException {
+               SubMonitor sm = SubMonitor.convert(pm, 10);
+
+               RefactoringStatus status = super.checkInitialConditions(sm.newChild(6));
+               if (status.hasError()) {
+                       return status;
+               }
+
+               if (!initStatus.hasFatalError()) {
+                       initRefactoring(pm);            
+                       if (context.existingFields.isEmpty()) {
+                               initStatus.addFatalError(Messages.GenerateGettersAndSettersRefactoring_NoFields);
+                       }
+               }               
+               return initStatus;
+       }
+
+       @Override
+       public RefactoringStatus checkFinalConditions(IProgressMonitor pm,
+                       CheckConditionsContext checkContext) throws CoreException, OperationCanceledException {
+               RefactoringStatus result = new RefactoringStatus();
+               if (!context.isImplementationInHeader()) {
+                       findDefinitionInsertLocation(pm);
+                       if (definitionInsertLocation == null || tu.equals(definitionInsertLocation.getTranslationUnit())) {
+                               result.addInfo(Messages.GenerateGettersAndSettersRefactoring_NoImplFile);
+                       }
+               }
+               Checks.addModifiedFilesToChecker(getAllFilesToModify(), checkContext);
+               return result;
+       }
+
+       private IFile[] getAllFilesToModify() {
+               List<IFile> files = new ArrayList<IFile>(2);
+               IFile file = (IFile) tu.getResource();
+               if (file != null) {
+                       files.add(file);
+               }
+               if (definitionInsertLocation != null) {
+                       file = definitionInsertLocation.getFile();
+                       if (file != null) {
+                               files.add(file);
+                       }
+               }
+               return files.toArray(new IFile[files.size()]);
+       }
+
+       private void initRefactoring(IProgressMonitor pm) throws OperationCanceledException, CoreException {
+               IASTTranslationUnit ast = astCache.getAST(tu, null);
+               context.selectedName = getSelectedName(ast);
+               IASTCompositeTypeSpecifier compositeTypeSpecifier = null;
+               if (context.selectedName != null) {
+                       compositeTypeSpecifier = getCompositeTypeSpecifier(context.selectedName);
+               } else {
+                       compositeTypeSpecifier = findCurrentCompositeTypeSpecifier(ast);
+               }
+               if (compositeTypeSpecifier != null) {
+                       findDeclarations(compositeTypeSpecifier);
+               } else {
+                       initStatus.addFatalError(Messages.GenerateGettersAndSettersRefactoring_NoCassDefFound);
+               }
+       }
+       
+       private IASTCompositeTypeSpecifier findCurrentCompositeTypeSpecifier(IASTTranslationUnit ast)
+                       throws OperationCanceledException, CoreException {
+               final int start = selectedRegion.getOffset();
+               Container<IASTCompositeTypeSpecifier> container = new Container<IASTCompositeTypeSpecifier>();
+               ast.accept(new CompositeTypeSpecFinder(start, container));
+               return container.getObject();
+       }
+
+       private IASTCompositeTypeSpecifier getCompositeTypeSpecifier(IASTName selectedName) {
+               IASTNode node = selectedName;
+               while(node != null && !(node instanceof IASTCompositeTypeSpecifier)) {
+                       node = node.getParent();
+               }
+               return (IASTCompositeTypeSpecifier) node;
+       }
+
+       private IASTName getSelectedName(IASTTranslationUnit ast) {
+               List<IASTName> names = findAllMarkedNames(ast);
+               if (names.size() < 1) {
+                       return null;
+               }
+               return names.get(names.size() - 1);
+       }
+
+       protected void findDeclarations(IASTCompositeTypeSpecifier compositeTypeSpecifier) {
+               compositeTypeSpecifier.accept(new ASTVisitor() {
+                       {
+                               shouldVisitDeclarations = true;
+                       }
+
+                       @Override
+                       public int visit(IASTDeclaration declaration) {
+                               if (declaration instanceof IASTSimpleDeclaration) {
+                                       IASTSimpleDeclaration fieldDeclaration = (IASTSimpleDeclaration) declaration;
+                                       ASTNodeProperty props = fieldDeclaration.getPropertyInParent();
+                                       if (props.getName().contains(MEMBER_DECLARATION)) {
+                                               final IASTDeclarator[] declarators = fieldDeclaration.getDeclarators();
+                                               if (declarators.length > 0) {
+                                                       IASTDeclarator innermostDeclarator = declarators[0];
+                                                       while (innermostDeclarator.getNestedDeclarator() != null) {
+                                                               innermostDeclarator = innermostDeclarator.getNestedDeclarator();
+                                                       }
+                                                       if ((innermostDeclarator instanceof IASTFunctionDeclarator)) {
+                                                               context.existingFunctionDeclarations.add(fieldDeclaration);
+                                                       } else if (fieldDeclaration.isPartOfTranslationUnitFile()) {
+                                                               context.existingFields.add(fieldDeclaration);
+                                                       }
+                                               }
+                                       }
+                               }
+                               if (declaration instanceof IASTFunctionDefinition) {
+                                       IASTFunctionDefinition functionDefinition = (IASTFunctionDefinition) declaration;
+                                       ASTNodeProperty props = functionDefinition.getPropertyInParent();
+                                       if (props.getName().contains(MEMBER_DECLARATION)) {
+                                               context.existingFunctionDefinitions.add(functionDefinition);
+                                       }
+                               }
+                               return super.visit(declaration);
+                       }
+               });
+       }
+
+       @Override
+       protected void collectModifications(IProgressMonitor pm,ModificationCollector collector)
+                       throws CoreException, OperationCanceledException {
+               List<IASTNode> getterAndSetters = new ArrayList<IASTNode>();
+               List<IASTFunctionDefinition> definitions = new ArrayList<IASTFunctionDefinition>();
+               for (GetterSetterInsertEditProvider currentProvider : context.selectedFunctions) {
+                       if (context.isImplementationInHeader()) {
+                               getterAndSetters.add(currentProvider.getFunctionDefinition(false));
+                       } else {
+                               getterAndSetters.add(currentProvider.getFunctionDeclaration());
+                               definitions.add(currentProvider.getFunctionDefinition(true));
+                       }
+               }
+               if (!context.isImplementationInHeader()) {
+                       addDefinition(collector, definitions, pm);
+               }
+               ICPPASTCompositeTypeSpecifier classDefinition =
+                               (ICPPASTCompositeTypeSpecifier) context.existingFields.get(context.existingFields.size() - 1).getParent();
+
+               AddDeclarationNodeToClassChange.createChange(classDefinition, VisibilityEnum.v_public,
+                               getterAndSetters, false, collector);
+       }
+
+       private void addDefinition(ModificationCollector collector, List<IASTFunctionDefinition> definitions, IProgressMonitor pm)
+                       throws CoreException {
+               findDefinitionInsertLocation(pm);
+               IASTNode parent = definitionInsertLocation.getParentOfNodeToInsertBefore();
+               IASTTranslationUnit ast = parent.getTranslationUnit();
+               ASTRewrite rewrite = collector.rewriterForTranslationUnit(ast);
+               IASTNode nodeToInsertBefore = definitionInsertLocation.getNodeToInsertBefore();
+               ContainerNode cont = new ContainerNode();
+               for (IASTFunctionDefinition functionDefinition : definitions) {
+                       cont.addNode(functionDefinition);
+               }
+               rewrite = rewrite.insertBefore(parent, nodeToInsertBefore, cont, null);
+       }
+
+       public GetterSetterContext getContext() {
+               return context;
+       }
+       
+       private void findDefinitionInsertLocation(IProgressMonitor pm) throws CoreException {
+               if (definitionInsertLocation != null) {
+                       return;
+               }
+               
+               IASTSimpleDeclaration decl = context.existingFields.get(0);
+               MethodDefinitionInsertLocationFinder methodDefinitionInsertLocationFinder = new MethodDefinitionInsertLocationFinder();
+               InsertLocation location = methodDefinitionInsertLocationFinder.find(
+                               tu, decl.getFileLocation(), decl.getParent(), astCache, pm);
+
+               if (location.getFile() == null || NodeHelper.isContainedInTemplateDeclaration(decl)) {
+                       location.setNodeToInsertAfter(NodeHelper.findTopLevelParent(decl), tu);
+               }
+               
+               definitionInsertLocation = location;
+       }
+
+       @Override
+       protected RefactoringDescriptor getRefactoringDescriptor() {
+               // TODO egraf add Descriptor
+               return null;
+       }       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoringRunner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoringRunner.java
new file mode 100644 (file)
index 0000000..04684f8
--- /dev/null
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *        Institute for Software - initial API and implementation
+ *        Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+
+import org.eclipse.cdt.internal.ui.refactoring.RefactoringRunner2;
+import org.eclipse.cdt.internal.ui.refactoring.RefactoringASTCache;
+import org.eclipse.cdt.internal.ui.refactoring.RefactoringSaveHelper;
+
+/**
+ * @author Thomas Corbat
+ */
+public class GenerateGettersAndSettersRefactoringRunner extends RefactoringRunner2 {
+
+       public GenerateGettersAndSettersRefactoringRunner(ICElement element, ISelection selection,
+                       IShellProvider shellProvider, ICProject cProject) {
+               super(element, selection, shellProvider, cProject);
+       }
+
+       @Override
+       public void run(RefactoringASTCache astCache) {
+               if (getActiveEditor() instanceof ITextEditor) {
+                       GenerateGettersAndSettersRefactoring refactoring =
+                                       new GenerateGettersAndSettersRefactoring(element, selection, project, astCache);
+                       GenerateGettersAndSettersRefactoringWizard wizard =
+                                       new GenerateGettersAndSettersRefactoringWizard(refactoring);
+                       starter.activate(wizard, shellProvider.getShell(), refactoring.getName(),
+                                       RefactoringSaveHelper.SAVE_REFACTORING);
+               }
+       }
+
+       private IEditorPart getActiveEditor() {
+               return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoringWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoringWizard.java
new file mode 100644 (file)
index 0000000..f1a8174
--- /dev/null
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *     Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters;
+
+import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
+import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
+
+/**
+ * @author Thomas Corbat
+ */
+public class GenerateGettersAndSettersRefactoringWizard extends        RefactoringWizard {
+       public GenerateGettersAndSettersRefactoringWizard(
+                       GenerateGettersAndSettersRefactoring refactoring) {
+               super(refactoring, WIZARD_BASED_USER_INTERFACE);
+       }
+
+       @Override
+       protected void addUserInputPages() {
+               UserInputWizardPage page = new GenerateGettersAndSettersInputPage(
+                               ((GenerateGettersAndSettersRefactoring) getRefactoring()).getContext());
+               addPage(page);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterContext.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterContext.java
new file mode 100644 (file)
index 0000000..757619c
--- /dev/null
@@ -0,0 +1,191 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *     Institute for Software - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters;
+
+import java.util.ArrayList;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+
+import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.GetterSetterInsertEditProvider.AccessorKind;
+
+public class GetterSetterContext implements ITreeContentProvider {
+       public ArrayList<IASTSimpleDeclaration> existingFields = new ArrayList<IASTSimpleDeclaration>();
+       public ArrayList<IASTFunctionDefinition> existingFunctionDefinitions = new ArrayList<IASTFunctionDefinition>();
+       public ArrayList<IASTSimpleDeclaration> existingFunctionDeclarations = new ArrayList<IASTSimpleDeclaration>();
+       public SortedSet<GetterSetterInsertEditProvider> selectedFunctions = new TreeSet<GetterSetterInsertEditProvider>();
+       public IASTName selectedName;
+       private ArrayList<FieldWrapper> wrappedFields;
+       private boolean implementationInHeader = false;
+
+       public Object[] getChildren(Object parentElement) {
+               ArrayList<GetterSetterInsertEditProvider> children = new ArrayList<GetterSetterInsertEditProvider>();
+               if (parentElement instanceof FieldWrapper) {
+                       FieldWrapper wrapper = (FieldWrapper) parentElement;
+                       
+                       if (wrapper.getChildNodes().isEmpty()) {
+                               if (!wrapper.getter.exists()) {
+                                       wrapper.childNodes.add(createGetterInserter(wrapper.field));
+                               }
+                               if (!wrapper.setter.exists() && !wrapper.field.getDeclSpecifier().isConst()) {
+                                       wrapper.childNodes.add(createSetterInserter(wrapper.field));
+                               }
+                       }
+                       children = wrapper.getChildNodes();
+               }
+               return children.toArray();
+       }
+
+       public GetterSetterInsertEditProvider createGetterInserter(IASTSimpleDeclaration simpleDeclaration) {
+               IASTName fieldName = getFieldDeclarationName(simpleDeclaration);
+               return new GetterSetterInsertEditProvider(fieldName, simpleDeclaration, AccessorKind.GETTER);
+       }
+
+       public GetterSetterInsertEditProvider createSetterInserter(IASTSimpleDeclaration simpleDeclaration) {
+               IASTName fieldName = getFieldDeclarationName(simpleDeclaration);
+               return new GetterSetterInsertEditProvider(fieldName, simpleDeclaration, AccessorKind.SETTER);
+       }
+
+       public Object getParent(Object element) {
+               return null;
+       }
+
+       public boolean hasChildren(Object element) {
+               if (element instanceof FieldWrapper) {
+                       FieldWrapper wrapper = (FieldWrapper) element;
+                       return wrapper.missingGetterOrSetter();
+               }
+               return false;
+       }
+
+       public Object[] getElements(Object inputElement) {
+               return getWrappedFields().toArray();
+       }
+       
+       public void refresh() {
+               // We only recreate the function declarations instead of recreating GetterSetterInsertEditProviders.
+               // That way, selectedFunctions is still valid. Also, the objects inside the TreeViewer are still the same
+               // which is convenient because that way we don't need to save then restore the collapsed/expanded+checked/unchecked state of the TreeViewer.
+               for (FieldWrapper wrapper : wrappedFields) {
+                       for (GetterSetterInsertEditProvider provider : wrapper.childNodes) {
+                               provider.createFunctionDeclaration();
+                       }
+               }
+       }
+
+       public void dispose() {
+       }
+
+       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+       }
+       
+       public boolean isImplementationInHeader() {
+               return implementationInHeader;
+       }
+
+       public void setImplementationInHeader(boolean implementationInHeader) {
+               this.implementationInHeader = implementationInHeader;
+       }
+
+       private ArrayList<FieldWrapper> getWrappedFields() {
+               if (wrappedFields == null) {
+                       wrappedFields = new ArrayList<FieldWrapper>();
+                       for (IASTSimpleDeclaration currentField : existingFields) {
+                               FieldWrapper wrapper = new FieldWrapper();
+                               wrapper.field = currentField;
+                               wrapper.getter = getGetterForField(currentField);
+                               wrapper.setter = getSetterForField(currentField);
+                               if (wrapper.missingGetterOrSetter()) {
+                                       wrappedFields.add(wrapper);
+                               }
+                       }
+               }
+               return wrappedFields;
+       }
+
+       private FunctionWrapper getGetterForField(IASTSimpleDeclaration currentField) {
+               FunctionWrapper wrapper = new FunctionWrapper();
+               String name = GetterSetterNameGenerator.generateGetterName(getFieldDeclarationName(currentField));
+               setFunctionToWrapper(wrapper, name);
+               return wrapper;
+       }
+
+       private IASTName getFieldDeclarationName(IASTSimpleDeclaration fieldDeclaration) {
+               IASTDeclarator declarator = fieldDeclaration.getDeclarators()[0];
+               while (declarator.getNestedDeclarator() != null) {
+                       declarator = declarator.getNestedDeclarator();
+               }
+               return declarator.getName();
+       }
+       
+       private FunctionWrapper getSetterForField(IASTSimpleDeclaration currentField) {
+               FunctionWrapper wrapper = new FunctionWrapper();
+               String name = GetterSetterNameGenerator.generateSetterName(getFieldDeclarationName(currentField));
+               setFunctionToWrapper(wrapper, name);
+               return wrapper;
+       }
+
+       private void setFunctionToWrapper(FunctionWrapper wrapper, String getterName) {
+               for (IASTFunctionDefinition currentDefinition : existingFunctionDefinitions) {
+                       if (currentDefinition.getDeclarator().getName().toString().endsWith(getterName)) {
+                               wrapper.functionDefinition = currentDefinition;
+                       }
+               }
+               
+               for (IASTSimpleDeclaration currentDeclaration : existingFunctionDeclarations) {
+                       if (getFieldDeclarationName(currentDeclaration).toString().endsWith(getterName)) {
+                               wrapper.functionDeclaration = currentDeclaration;
+                       }
+               }
+       }
+
+       protected class FieldWrapper {
+               protected IASTSimpleDeclaration field;
+               protected FunctionWrapper getter;
+               protected FunctionWrapper setter;
+               protected ArrayList<GetterSetterInsertEditProvider> childNodes = new ArrayList<GetterSetterInsertEditProvider>(2);
+               
+               @Override
+               public String toString() {
+                       IASTDeclarator declarator = field.getDeclarators()[0];
+                       while (declarator.getNestedDeclarator() != null) {
+                               declarator = declarator.getNestedDeclarator();
+                       }
+                       return declarator.getName().toString();
+               }
+
+               public ArrayList<GetterSetterInsertEditProvider> getChildNodes() {
+                       return childNodes;
+               }
+
+               public boolean missingGetterOrSetter() {
+                       return !getter.exists() || !setter.exists();
+               }
+       }
+       
+       protected class FunctionWrapper {
+               protected IASTSimpleDeclaration functionDeclaration;
+               protected IASTFunctionDefinition functionDefinition;
+               
+               public boolean exists() {
+                       return functionDeclaration != null || functionDefinition != null;
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterInsertEditProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterInsertEditProvider.java
new file mode 100644 (file)
index 0000000..05eb4e9
--- /dev/null
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *     Institute for Software - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters;
+
+import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTNode.CopyStyle;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTQualifiedName;
+
+public class GetterSetterInsertEditProvider implements Comparable<GetterSetterInsertEditProvider> {
+       public enum AccessorKind {
+               GETTER,
+               SETTER;
+       }
+       
+       private IASTSimpleDeclaration functionDeclaration;
+       private AccessorKind kind;
+       private IASTName fieldName;
+       private IASTSimpleDeclaration fieldDeclaration;
+       
+       public GetterSetterInsertEditProvider(IASTName fieldName, IASTSimpleDeclaration fieldDeclaration,
+                       AccessorKind kind) {
+               this.kind = kind;
+               this.fieldName = fieldName;
+               this.fieldDeclaration = fieldDeclaration;
+               
+               createFunctionDeclaration();
+       }
+
+       public void createFunctionDeclaration() {
+               switch (this.kind) {
+               case GETTER:
+                       this.functionDeclaration = FunctionFactory.createGetterDeclaration(fieldName, fieldDeclaration);
+                       break;
+               case SETTER:
+                       this.functionDeclaration = FunctionFactory.createSetterDeclaration(fieldName, fieldDeclaration);
+                       break;
+               }
+       }
+       
+       @Override
+       public String toString() {
+               IASTDeclarator declarator = functionDeclaration.getDeclarators()[0];
+               while (declarator.getNestedDeclarator() != null) {
+                       declarator = declarator.getNestedDeclarator();
+               }
+               return declarator.getName().toString();
+       }
+
+       public IASTFunctionDefinition getFunctionDefinition(boolean qualifedName) {
+               IASTFunctionDefinition definition = null;
+               ICPPASTQualifiedName qname;
+               if (qualifedName) {
+                       qname = getClassname();
+               } else {
+                       qname = null;
+               }
+               
+               switch (kind) {
+               case GETTER:
+                       definition = FunctionFactory.createGetterDefinition(fieldName, fieldDeclaration, qname);
+                       break;
+               case SETTER:
+                       definition = FunctionFactory.createSetterDefinition(fieldName, fieldDeclaration, qname);
+                       break;
+               }
+               return definition;
+       }
+       
+       private ICPPASTQualifiedName getClassname() {
+               IASTNode n = fieldDeclaration.getParent();
+               while (!(n instanceof IASTCompositeTypeSpecifier)) {
+                       n = n.getParent();
+               }
+               IASTCompositeTypeSpecifier comp = (IASTCompositeTypeSpecifier) n;
+               
+               CPPASTQualifiedName qname = new CPPASTQualifiedName();
+               qname.addName(comp.getName().copy(CopyStyle.withLocations));
+               return qname;
+       }
+
+       public IASTSimpleDeclaration getFunctionDeclaration() {
+               return functionDeclaration;
+       }
+
+       public AccessorKind getType() {
+               return kind;
+       }
+
+       public int compareTo(GetterSetterInsertEditProvider o) {
+               return toString().compareTo(o.toString());
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterLabelProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterLabelProvider.java
new file mode 100644 (file)
index 0000000..927579f
--- /dev/null
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *     Institute for Software (IFS)- initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters;
+
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
+
+import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
+
+/**
+ * @author Emanuel Graf IFS
+ */
+public class GetterSetterLabelProvider extends LabelProvider {
+
+       @Override
+       public Image getImage(Object element) {
+               if (element instanceof GetterSetterInsertEditProvider) {
+                       return CElementImageProvider.getMethodImageDescriptor(ASTAccessVisibility.PUBLIC).createImage();
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterNameGenerator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterNameGenerator.java
new file mode 100644 (file)
index 0000000..229fe84
--- /dev/null
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2011 Google, Inc and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *        Sergey Prigogin (Google) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.IPreferencesService;
+
+
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IBasicType;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
+
+import org.eclipse.cdt.internal.ui.util.NameComposer;
+
+public class GetterSetterNameGenerator {
+
+       // Do not instantiate.
+       private GetterSetterNameGenerator() {
+       }
+       
+       private static Set<String> generateGetterSettersPreferenceKeys = new HashSet<String>();
+       static {
+               generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_GETTER_CAPITALIZATION);
+               generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_GETTER_WORD_DELIMITER);
+               generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_GETTER_PREFIX_FOR_BOOLEAN);
+               generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_GETTER_PREFIX);
+               generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_GETTER_SUFFIX);
+               generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_SETTER_CAPITALIZATION);
+               generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_SETTER_WORD_DELIMITER);
+               generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_SETTER_PREFIX);
+               generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_SETTER_SUFFIX);
+               generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_VARIABLE_CAPITALIZATION);
+               generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_VARIABLE_WORD_DELIMITER);
+               generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_VARIABLE_PREFIX);
+               generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_VARIABLE_SUFFIX);
+       }
+
+       public static Set<String> getGenerateGetterSettersPreferenceKeys() {
+               return generateGetterSettersPreferenceKeys;
+       }
+       
+       public static String generateGetterName(IASTName fieldName) {
+       IPreferencesService preferences = Platform.getPreferencesService();
+       int capitalization = preferences.getInt(CUIPlugin.PLUGIN_ID,
+                       PreferenceConstants.NAME_STYLE_GETTER_CAPITALIZATION,
+                       PreferenceConstants.NAME_STYLE_CAPITALIZATION_CAMEL_CASE, null);
+       String wordDelimiter = preferences.getString(CUIPlugin.PLUGIN_ID,
+                       PreferenceConstants.NAME_STYLE_GETTER_WORD_DELIMITER, "", null); //$NON-NLS-1$
+       String prefix = isBooleanDecaratorName(fieldName) ?
+                       preferences.getString(CUIPlugin.PLUGIN_ID,
+                                       PreferenceConstants.NAME_STYLE_GETTER_PREFIX_FOR_BOOLEAN, "is", null) : //$NON-NLS-1$
+                               preferences.getString(CUIPlugin.PLUGIN_ID,
+                                               PreferenceConstants.NAME_STYLE_GETTER_PREFIX, "get", null); //$NON-NLS-1$
+       String suffix = preferences.getString(CUIPlugin.PLUGIN_ID,
+                       PreferenceConstants.NAME_STYLE_GETTER_SUFFIX, "", null); //$NON-NLS-1$
+       NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
+       String name = NameComposer.trimFieldName(fieldName.toString());
+       return composer.compose(name);
+       }
+       
+       private static boolean isBooleanDecaratorName(IASTName name) {
+               if (IASTDeclarator.DECLARATOR_NAME.equals(name.getPropertyInParent())) {
+                       IASTDeclarator declarator = (IASTDeclarator) name.getParent();
+                       IType type = CPPVisitor.createType(declarator);
+                       if (type instanceof IBasicType && ((IBasicType) type).getKind() == IBasicType.Kind.eBoolean) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+       public static String generateSetterName(IASTName fieldName) {
+               IPreferencesService preferences = Platform.getPreferencesService();
+               int capitalization = preferences.getInt(CUIPlugin.PLUGIN_ID,
+                               PreferenceConstants.NAME_STYLE_SETTER_CAPITALIZATION,
+                               PreferenceConstants.NAME_STYLE_CAPITALIZATION_CAMEL_CASE, null);
+               String wordDelimiter = preferences.getString(CUIPlugin.PLUGIN_ID,
+                               PreferenceConstants.NAME_STYLE_SETTER_WORD_DELIMITER, "", null); //$NON-NLS-1$
+               String prefix = preferences.getString(CUIPlugin.PLUGIN_ID,
+                               PreferenceConstants.NAME_STYLE_SETTER_PREFIX, "set", null); //$NON-NLS-1$
+               String suffix = preferences.getString(CUIPlugin.PLUGIN_ID,
+                               PreferenceConstants.NAME_STYLE_SETTER_SUFFIX, "", null); //$NON-NLS-1$
+               NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
+               String name = NameComposer.trimFieldName(fieldName.toString());
+               return composer.compose(name);
+       }
+
+       public static String generateSetterParameterName(IASTName fieldName) {
+               IPreferencesService preferences = Platform.getPreferencesService();
+               int capitalization = preferences.getInt(CUIPlugin.PLUGIN_ID,
+                               PreferenceConstants.NAME_STYLE_VARIABLE_CAPITALIZATION,
+                               PreferenceConstants.NAME_STYLE_CAPITALIZATION_ORIGINAL, null);
+               String wordDelimiter = preferences.getString(CUIPlugin.PLUGIN_ID,
+                               PreferenceConstants.NAME_STYLE_VARIABLE_WORD_DELIMITER, "", null); //$NON-NLS-1$
+               String prefix = preferences.getString(CUIPlugin.PLUGIN_ID,
+                               PreferenceConstants.NAME_STYLE_VARIABLE_PREFIX, "", null); //$NON-NLS-1$
+               String suffix = preferences.getString(CUIPlugin.PLUGIN_ID,
+                               PreferenceConstants.NAME_STYLE_VARIABLE_SUFFIX, "", null); //$NON-NLS-1$
+               NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
+               String name = NameComposer.trimFieldName(fieldName.toString());
+               return composer.compose(name);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.java
new file mode 100644 (file)
index 0000000..8094488
--- /dev/null
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *     Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class Messages extends NLS {
+       public static String GenerateGettersAndSettersInputPage_DeselectAll;
+       public static String GenerateGettersAndSettersInputPage_header;
+       public static String GenerateGettersAndSettersInputPage_PlaceImplHeader;
+       public static String GenerateGettersAndSettersInputPage_SelectAll;
+       public static String GenerateGettersAndSettersInputPage_SelectGetters;
+       public static String GenerateGettersAndSettersInputPage_SelectSetters;
+       public static String GenerateGettersAndSettersInputPage_LinkDescription;
+       public static String GenerateGettersAndSettersInputPage_LinkTooltip;
+       public static String GenerateGettersAndSettersRefactoring_NoCassDefFound;
+       public static String GenerateGettersAndSettersRefactoring_NoFields;
+       public static String GenerateGettersAndSettersRefactoring_NoImplFile;
+       public static String GettersAndSetters_Name;
+
+       static {
+               NLS.initializeMessages(Messages.class.getName(), Messages.class);
+       }
+
+       // Do not instantiate
+       private Messages() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.properties
new file mode 100644 (file)
index 0000000..c9cf1f7
--- /dev/null
@@ -0,0 +1,23 @@
+###############################################################################
+# Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
+# Rapperswil, University of applied sciences and others
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Institute for Software - initial API and implementation
+###############################################################################
+GettersAndSetters_Name=Generate getters and setters
+GenerateGettersAndSettersInputPage_DeselectAll=Deselect All
+GenerateGettersAndSettersInputPage_header=Select getters and setters to create:
+GenerateGettersAndSettersInputPage_PlaceImplHeader=Place implementation in header file
+GenerateGettersAndSettersInputPage_SelectAll=Select All
+GenerateGettersAndSettersInputPage_SelectGetters=Select Getters
+GenerateGettersAndSettersInputPage_SelectSetters=Select Setters
+GenerateGettersAndSettersInputPage_LinkDescription=The names of getters and setters may be configured on the <a>Name Style</a> preference page.
+GenerateGettersAndSettersInputPage_LinkTooltip=Show the name style preferences.
+GenerateGettersAndSettersRefactoring_NoCassDefFound=No class definition found
+GenerateGettersAndSettersRefactoring_NoFields=The class does not contain any fields.
+GenerateGettersAndSettersRefactoring_NoImplFile=No implementation file found. Inserting definition into the header file.
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoring.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoring.java
new file mode 100644 (file)
index 0000000..c9de2a7
--- /dev/null
@@ -0,0 +1,304 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.hidemethod;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.text.edits.TextEditGroup;
+
+import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
+import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
+import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
+
+import org.eclipse.cdt.internal.ui.refactoring.AddDeclarationNodeToClassChange;
+import org.eclipse.cdt.internal.ui.refactoring.CRefactoring;
+import org.eclipse.cdt.internal.ui.refactoring.CRefactoringDescription;
+import org.eclipse.cdt.internal.ui.refactoring.ModificationCollector;
+import org.eclipse.cdt.internal.ui.refactoring.utils.DeclarationFinder;
+import org.eclipse.cdt.internal.ui.refactoring.utils.DeclarationFinderDO;
+import org.eclipse.cdt.internal.ui.refactoring.utils.ExpressionFinder;
+import org.eclipse.cdt.internal.ui.refactoring.utils.NodeHelper;
+import org.eclipse.cdt.internal.ui.refactoring.utils.TranslationUnitHelper;
+import org.eclipse.cdt.internal.ui.refactoring.utils.VisibilityEnum;
+
+/**
+ * @author Guido Zgraggen IFS
+ */
+public class HideMethodRefactoring extends CRefactoring {
+       public static final String ID = "org.eclipse.cdt.internal.ui.refactoring.hidemethod.HideMethodRefactoring"; //$NON-NLS-1$
+
+       private IASTName methodToHide;
+       private IASTDeclaration methodToHideDecl;
+       private DeclarationFinderDO declData;
+
+       public HideMethodRefactoring(IFile file, ISelection selection, ICElement element, ICProject project) {
+               super(file, selection, element, project);
+               name = Messages.HideMethodRefactoring_HIDE_METHOD;
+       }
+       
+       @Override
+       public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException {
+               SubMonitor sm = SubMonitor.convert(pm, 10);
+               try {
+                       lockIndex();
+                       try {
+                               super.checkInitialConditions(sm.newChild(6));
+
+                               if (initStatus.hasFatalError()) {
+                                       return initStatus;
+                               }
+
+                               if (isProgressMonitorCanceld(sm, initStatus)) return initStatus;
+
+                               IASTName name;
+                               ArrayList<IASTName> names = findAllMarkedNames();
+                               if (names.size() < 1) {
+                                       initStatus.addFatalError(Messages.HideMethodRefactoring_NoNameSelected);  
+                                       return initStatus;
+                               }
+                               name = names.get(names.size()-1);
+                               sm.worked(1);
+                               if (isProgressMonitorCanceld(sm, initStatus)) return initStatus;
+
+                               declData = DeclarationFinder.getDeclaration(name, getIndex());
+
+                               if (declData == null || declData.name == null) {
+                                       initStatus.addFatalError(Messages.HideMethodRefactoring_NoMethodNameSelected); 
+                                       return initStatus;
+                               }
+
+                               methodToHide = declData.name;
+                               sm.worked(1);
+                               methodToHideDecl = NodeHelper.findSimpleDeclarationInParents(methodToHide);
+                               if (methodToHideDecl == null) {
+                                       initStatus.addFatalError(Messages.HideMethodRefactoring_CanOnlyHideMethods); 
+                                       return initStatus;
+                               }
+                               if (!(methodToHideDecl.getParent() instanceof ICPPASTCompositeTypeSpecifier)) {
+                                       methodToHideDecl = NodeHelper.findFunctionDefinitionInAncestors(methodToHide);
+                               }
+
+                               if (isProgressMonitorCanceld(sm, initStatus)) return initStatus;
+                               sm.worked(1);
+                               if (methodToHideDecl instanceof IASTFunctionDefinition) {
+                                       IASTDeclarator declarator = ((IASTFunctionDefinition)methodToHideDecl).getDeclarator();
+                                       if (CPPVisitor.findInnermostDeclarator(declarator).getName().getRawSignature().equals(name.getRawSignature())) {
+                                               if (!(declarator instanceof IASTFunctionDeclarator)) {
+                                                       initStatus.addFatalError(Messages.HideMethodRefactoring_CanOnlyHideMethods); 
+                                                       return initStatus;
+                                               }
+                                       }
+                               } else if (methodToHideDecl instanceof IASTSimpleDeclaration) {
+                                       for(IASTDeclarator declarator : ((IASTSimpleDeclaration) methodToHideDecl).getDeclarators()) {
+                                               if (declarator.getName().getRawSignature().equals(name.getRawSignature())) {
+                                                       if (!(declarator instanceof IASTFunctionDeclarator)) {
+                                                               initStatus.addFatalError(Messages.HideMethodRefactoring_CanOnlyHideMethods); 
+                                                               return initStatus;
+                                                       }
+                                               }
+                                       }                       
+                               } else {
+                                       initStatus.addFatalError(Messages.HideMethodRefactoring_CanOnlyHideMethods); 
+                                       return initStatus;
+                               }
+
+                               sm.worked(1);           
+
+                               IASTCompositeTypeSpecifier classNode = NodeHelper.findClassInAncestors(methodToHide);
+                               if (classNode == null) {
+                                       initStatus.addError(Messages.HideMethodRefactoring_EnclosingClassNotFound);
+                               }
+
+                               if (checkIfPrivate(classNode, methodToHideDecl)) {
+                                       initStatus.addError(Messages.HideMethodRefactoring_IsAlreadyPrivate);
+                               }
+                               sm.done();
+                       } finally {
+                               unlockIndex();
+                       }
+               } catch (InterruptedException e) {
+                       Thread.currentThread().interrupt();
+               }
+               return initStatus;
+       }
+       
+       private boolean checkIfPrivate(IASTCompositeTypeSpecifier classNode, IASTDeclaration decl) {
+               IASTDeclaration[] members = classNode.getMembers();
+               int currentVisibility = ICPPASTVisibilityLabel.v_private;
+               if (IASTCompositeTypeSpecifier.k_struct == classNode.getKey()) {
+                       currentVisibility = ICPPASTVisibilityLabel.v_public;
+               }               
+               for (IASTDeclaration declaration : members) {
+                       if (declaration instanceof ICPPASTVisibilityLabel) {
+                               currentVisibility =((ICPPASTVisibilityLabel) declaration).getVisibility();
+                       }
+                       
+                       if (declaration != null) {
+                               if (decl == declaration) {
+                                       break;
+                               }
+                       }
+               }
+               if (ICPPASTVisibilityLabel.v_private == currentVisibility) {
+                       return true;
+               }
+               return false;
+       }
+       
+       @Override
+       public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException {
+               RefactoringStatus finalConditions = null;
+               try {
+                       lockIndex();
+                       try {
+                               finalConditions = super.checkFinalConditions(pm);
+
+                               for(IIndexName pdomref : declData.allNamesPDom) {
+                                       declData.filename = pdomref.getFileLocation().getFileName();
+
+                                       if (pdomref instanceof PDOMName) {
+                                               PDOMName pdomName = (PDOMName)pdomref;
+                                               if (pdomName.isDeclaration()) {
+                                                       continue;
+                                               }
+                                               if (pdomName.isDefinition()) {
+                                                       continue;
+                                               }
+                                       }                       
+
+                                       IASTTranslationUnit transUtmp = TranslationUnitHelper.loadTranslationUnit(declData.filename, false);
+                                       IASTName expName = ExpressionFinder.findExpressionInTranslationUnit(transUtmp, pdomref);
+
+                                       IASTFunctionDeclarator funcDec = findEnclosingFunction(expName);
+                                       IASTCompositeTypeSpecifier encClass2;
+                                       if (funcDec == null) {
+                                               encClass2 = NodeHelper.findClassInAncestors(expName);
+                                       }
+                                       else {
+                                               encClass2 = NodeHelper.findClassInAncestors(funcDec);
+                                       }
+
+                                       IASTCompositeTypeSpecifier encClass = NodeHelper.findClassInAncestors(methodToHide);
+
+                                       if (!NodeHelper.isSameNode(encClass, encClass2)) {
+                                               finalConditions.addWarning(Messages.HideMethodRefactoring_HasExternalReferences);
+                                               break;
+                                       }
+                               }
+
+                               return finalConditions; 
+                       } finally {
+                               unlockIndex();
+                       }
+               } catch (InterruptedException e) {
+                       Thread.currentThread().interrupt();
+               }
+               return finalConditions;
+       }
+
+       private IASTFunctionDeclarator findEnclosingFunction(IASTNode node) throws CoreException {
+               IASTCompoundStatement compStat = NodeHelper.findCompoundStatementInAncestors(node);
+               if (compStat == null) {
+                       return null;
+               }
+
+               IASTNode parent = compStat.getParent();
+               if (parent instanceof IASTFunctionDefinition) {
+                       IASTDeclarator declarator = ((IASTFunctionDefinition)parent).getDeclarator();
+                       IASTName declaratorName = getLastName(CPPVisitor.findInnermostDeclarator(declarator));
+
+                       DeclarationFinderDO data = DeclarationFinder.getDeclaration(declaratorName, getIndex());
+
+                       if (data == null || data.name == null) {
+                               return null;
+                       }
+                       
+                       if (data.name.getParent() instanceof IASTFunctionDeclarator) {
+                               return (IASTFunctionDeclarator) data.name.getParent();
+                       }                       
+                       return null;
+               } else if (parent instanceof IASTTranslationUnit) {
+                       return null;
+               }
+               return findEnclosingFunction(parent);
+       }
+
+       private IASTName getLastName(IASTDeclarator declarator) {
+               IASTName declaratorName = declarator.getName();
+               if (declaratorName instanceof ICPPASTQualifiedName) {
+                       IASTName[] declaratorNames = ((ICPPASTQualifiedName) declaratorName).getNames();
+                       declaratorName = declaratorNames[declaratorNames.length-1];
+               }
+               return declaratorName;
+       }
+
+       @Override
+       protected void collectModifications(IProgressMonitor pm, ModificationCollector collector) throws CoreException, OperationCanceledException {
+               try {
+                       lockIndex();
+                       try {
+                               ASTRewrite rewriter = collector.rewriterForTranslationUnit(declData.transUnit);
+                               TextEditGroup editGroup = new TextEditGroup(Messages.HideMethodRefactoring_FILE_CHANGE_TEXT+ methodToHide.getRawSignature());
+
+                               ICPPASTCompositeTypeSpecifier classDefinition = (ICPPASTCompositeTypeSpecifier) methodToHideDecl.getParent();
+                               AddDeclarationNodeToClassChange.createChange(classDefinition, VisibilityEnum.v_private, methodToHideDecl, false, collector);
+
+                               rewriter.remove(methodToHideDecl, editGroup);
+                       } finally {
+                               unlockIndex();
+                       }
+               } catch (InterruptedException e) {
+                       Thread.currentThread().interrupt();
+               }
+       }
+
+       @Override
+       protected RefactoringDescriptor getRefactoringDescriptor() {
+               Map<String, String> arguments = getArgumentMap();
+               RefactoringDescriptor desc = new HideMethodRefactoringDescription( project.getProject().getName(), "Hide Method Refactoring", "Hide Method " + methodToHide.getRawSignature(), arguments);  //$NON-NLS-1$//$NON-NLS-2$
+               return desc;
+       }
+
+       private Map<String, String> getArgumentMap() {
+               Map<String, String> arguments = new HashMap<String, String>();
+               arguments.put(CRefactoringDescription.FILE_NAME, file.getLocationURI().toString());
+               arguments.put(CRefactoringDescription.SELECTION, region.getOffset() + "," + region.getLength()); //$NON-NLS-1$
+               return arguments;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringContribution.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringContribution.java
new file mode 100644 (file)
index 0000000..0bc51da
--- /dev/null
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ * Institute for Software (IFS)- initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.hidemethod;
+
+import java.util.Map;
+
+import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
+
+import org.eclipse.cdt.internal.ui.refactoring.CRefactoringContribution;
+
+/**
+ * @author Emanuel Graf IFS
+ *
+ */
+public class HideMethodRefactoringContribution extends CRefactoringContribution {
+
+       @SuppressWarnings({ "unchecked", "rawtypes" })
+       @Override
+       public RefactoringDescriptor createDescriptor(String id, String project, String description,
+                       String comment, Map arguments, int flags) throws IllegalArgumentException {
+               if(id.equals(HideMethodRefactoring.ID)) {
+                       return new HideMethodRefactoringDescription(project, description, comment, arguments);
+               }else {
+                       return null;
+               }
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringDescription.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringDescription.java
new file mode 100644 (file)
index 0000000..b20cc69
--- /dev/null
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ * Institute for Software (IFS)- initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.hidemethod;
+
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ltk.core.refactoring.Refactoring;
+import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+
+import org.eclipse.cdt.core.model.ICProject;
+
+import org.eclipse.cdt.internal.ui.refactoring.CRefactoringDescription;
+
+/**
+ * @author Emanuel Graf IFS
+ *
+ */
+public class HideMethodRefactoringDescription extends CRefactoringDescription {
+
+       public HideMethodRefactoringDescription(String project, String description, String comment,
+                       Map<String, String> arguments) {
+               super(HideMethodRefactoring.ID, project, description, comment, RefactoringDescriptor.STRUCTURAL_CHANGE, arguments);
+       }
+
+       @Override
+       public Refactoring createRefactoring(RefactoringStatus status) throws CoreException {
+               IFile file;
+               ICProject proj;
+               
+               proj = getCProject();
+               file = getFile();
+               ISelection selection = getSelection();
+               return new HideMethodRefactoring(file, selection, null, proj);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringRunner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringRunner.java
new file mode 100644 (file)
index 0000000..848a107
--- /dev/null
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.hidemethod;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+
+import org.eclipse.cdt.internal.ui.refactoring.CRefactoring;
+import org.eclipse.cdt.internal.ui.refactoring.RefactoringRunner;
+
+/**
+ * @author Guido Zgraggen IFS
+ */
+public class HideMethodRefactoringRunner extends RefactoringRunner {
+
+       public HideMethodRefactoringRunner(IFile file, ISelection selection, ICElement element,
+                       IShellProvider shellProvider, ICProject cProject) {
+               super(file, selection, element, shellProvider, cProject);
+       }
+
+
+       @Override
+       public void run() {
+               CRefactoring refactoring= new HideMethodRefactoring(file, selection, celement, project);
+               HideMethodRefactoringWizard wizard = new HideMethodRefactoringWizard(refactoring);
+               RefactoringWizardOpenOperation operator = new RefactoringWizardOpenOperation(wizard);
+               try {
+                       operator.run(shellProvider.getShell(), refactoring.getName());
+               } catch (InterruptedException e) {
+                       Thread.currentThread().interrupt();
+               } 
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/HideMethodRefactoringWizard.java
new file mode 100644 (file)
index 0000000..0e73249
--- /dev/null
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.hidemethod;
+
+import org.eclipse.ltk.core.refactoring.Refactoring;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
+
+/**
+ * @author Guido Zgraggen IFS
+ *
+ */
+public class HideMethodRefactoringWizard extends RefactoringWizard {
+
+       public HideMethodRefactoringWizard(Refactoring refactoring) {
+               super(refactoring, WIZARD_BASED_USER_INTERFACE);
+       }
+
+       @Override
+       protected void addUserInputPages() {
+               //No spezial User Wizard to add
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/Messages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/Messages.java
new file mode 100644 (file)
index 0000000..f5b09d9
--- /dev/null
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *     Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.hidemethod;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class Messages extends NLS {
+       public static String HideMethodRefactoring_HasExternalReferences;
+       public static String HideMethodRefactoring_HIDE_METHOD;
+       public static String HideMethodRefactoring_NoNameSelected;
+       public static String HideMethodRefactoring_NoMethodNameSelected;
+       public static String HideMethodRefactoring_CanOnlyHideMethods;
+       public static String HideMethodRefactoring_FILE_CHANGE_TEXT;
+       public static String HideMethodRefactoring_EnclosingClassNotFound;
+       public static String HideMethodRefactoring_IsAlreadyPrivate;
+
+       static {
+               NLS.initializeMessages(Messages.class.getName(), Messages.class);
+       }
+
+       // Do not instantiate
+       private Messages() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/Messages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/hidemethod/Messages.properties
new file mode 100644 (file)
index 0000000..def8343
--- /dev/null
@@ -0,0 +1,20 @@
+###############################################################################
+# Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
+# Rapperswil, University of applied sciences and others
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Institute for Software - initial API and implementation
+###############################################################################
+HideMethodRefactoring_HasExternalReferences=This method might be referenced from outside of the class and therefor compilation error can occure.
+HideMethodRefactoring_HIDE_METHOD=Hide Method
+HideMethodRefactoring_NoNameSelected=No names selected.
+HideMethodRefactoring_NoMethodNameSelected=No method name selected.
+HideMethodRefactoring_CanOnlyHideMethods=Hide Method can only hide Member Functions.
+HideMethodRefactoring_FILE_CHANGE_TEXT=Hide
+HideMethodRefactoring_EnclosingClassNotFound=Enclosing class not found.
+HideMethodRefactoring_IsAlreadyPrivate=Method is already private.
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodData.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodData.java
new file mode 100644 (file)
index 0000000..c9794e8
--- /dev/null
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ * Institute for Software (IFS)- initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.implementmethod;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+
+/**
+ * @author Emanuel Graf IFS
+ *
+ */
+public class ImplementMethodData implements ITreeContentProvider{
+
+       public ImplementMethodData() {
+       }
+
+
+       private List<MethodToImplementConfig> methodDeclarations;
+
+       public void setMethodDeclarations(List<IASTSimpleDeclaration> methodDeclarations) {
+               this.methodDeclarations = new ArrayList<MethodToImplementConfig>();
+               
+               for (IASTSimpleDeclaration declaration : methodDeclarations) {
+                       this.methodDeclarations.add(new MethodToImplementConfig(declaration, new ParameterHandler(declaration)));
+               }
+               
+               // Only one declaration available, might as well check it
+               if (this.methodDeclarations.size() == 1) {
+                       this.methodDeclarations.get(0).setChecked(true);
+               }
+       }
+
+       public List<MethodToImplementConfig> getMethodDeclarations() {
+               return methodDeclarations;
+       }
+
+       public Object[] getChildren(Object parentElement) {
+               return null;
+       }
+
+       public Object getParent(Object element) {
+               return null;
+       }
+
+       public boolean hasChildren(Object element) {
+               return false;
+       }
+
+       public Object[] getElements(Object inputElement) {
+               return methodDeclarations.toArray();
+       }
+
+       public void dispose() {
+       }
+
+       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+
+       }
+       
+       public List<MethodToImplementConfig> getMethodsToImplement() {
+               List<MethodToImplementConfig> ret = new ArrayList<MethodToImplementConfig>();
+               for (MethodToImplementConfig config : methodDeclarations) {
+                       if(config.isChecked()) {
+                               ret.add(config);
+                       }
+               }
+               return ret;
+       }
+       
+       public boolean needParameterInput() {
+               for (MethodToImplementConfig config : getMethodsToImplement()) {
+                       if(config.getParaHandler().needsAdditionalArgumentNames())return true;
+               }
+               return false;
+       }
+       
+       public MethodToImplementConfig getNextConfigNeedingParameterNames(MethodToImplementConfig currentConfig) {
+               int i = 0;
+               List<MethodToImplementConfig> methodsToImplement = getMethodsToImplement();
+               for(;i < methodsToImplement.size();++i) {
+                       if(currentConfig == methodsToImplement.get(i)) {
+                               ++i;
+                               break;
+                       }
+               }
+               
+               for(;i < methodsToImplement.size();++i) {
+                       if(methodsToImplement.get(i).getParaHandler().needsAdditionalArgumentNames()) {
+                               return methodsToImplement.get(i);
+                       }
+               }
+               return null;
+       }
+
+
+       public MethodToImplementConfig getFirstConfigNeedingParameterNames() {
+               List<MethodToImplementConfig> methodsToImplement = getMethodsToImplement();
+               for (MethodToImplementConfig config : methodsToImplement) {
+                       if(config.getParaHandler().needsAdditionalArgumentNames()) {
+                               return config;
+                       }
+               }
+               return null;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodInputPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodInputPage.java
new file mode 100644 (file)
index 0000000..9cf86af
--- /dev/null
@@ -0,0 +1,160 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ * Institute for Software (IFS)- initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.implementmethod;
+
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.dialogs.ContainerCheckedTreeViewer;
+
+/**
+ * @author Emanuel Graf IFS
+ *
+ */
+public class ImplementMethodInputPage extends UserInputWizardPage{
+       
+       private ImplementMethodData data;
+       private ImplementMethodRefactoringWizard wizard;
+       private ContainerCheckedTreeViewer tree;
+
+       public ImplementMethodInputPage(ImplementMethodData data, ImplementMethodRefactoringWizard implementMethodRefactoringWizard) {
+               super(Messages.ImplementMethodInputPage_PageTitle);
+               this.setData(data);
+               wizard = implementMethodRefactoringWizard;
+       }
+
+       
+
+       @Override
+       public boolean canFlipToNextPage() {
+               if(data.needParameterInput()) {
+                       return super.canFlipToNextPage();
+               }else {//getNextPage call is too expensive in this case.
+                       return isPageComplete();
+               }
+       }
+
+
+
+       public void createControl(Composite parent) {
+               
+               setTitle(Messages.ImplementMethodInputPage_PageTitle);
+               setMessage(Messages.ImplementMethodInputPage_Header);
+               
+               Composite comp = new Composite(parent, SWT.NONE );
+               comp.setLayout(new GridLayout(2, false));
+               createTree(comp);
+               createFieldManagementButtonsComposite(comp);
+               
+               setControl(comp);
+               checkPage();
+       }
+       
+       private Composite createFieldManagementButtonsComposite(Composite comp) {
+               Composite btComp = new Composite(comp, SWT.NONE);
+               FillLayout layout = new FillLayout(SWT.VERTICAL);
+               layout.spacing = 4;
+               btComp.setLayout(layout);
+               
+               GridData gd = new GridData();
+               gd.verticalAlignment = SWT.TOP;
+               btComp.setLayoutData(gd);
+               
+               final Button selectAll = new Button(btComp, SWT.PUSH);
+               selectAll.setText(Messages.ImplementMethodInputPage_SelectAll);
+               selectAll.addSelectionListener(new SelectionAdapter(){
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               Object[] items = data.getElements(null);
+                               for (Object treeItem : items) {
+                                       MethodToImplementConfig method = (MethodToImplementConfig)treeItem;
+                                       method.setChecked(true);
+                                       tree.setChecked(treeItem, true);
+                               }
+                               checkPage();
+                       }
+               });
+               
+               final Button deselectAll = new Button(btComp, SWT.PUSH);
+               deselectAll.setText(Messages.ImplementMethodInputPage_DeselectAll);
+               deselectAll.addSelectionListener(new SelectionAdapter(){
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               Object[] items = data.getElements(null);
+                               for (Object treeItem : items) {
+                                       MethodToImplementConfig method = (MethodToImplementConfig)treeItem;
+                                       method.setChecked(false);
+                                       tree.setChecked(treeItem, false);
+                               }
+                               checkPage();
+                       }
+               });
+               
+               return btComp;
+       }
+
+       private void createTree(Composite comp) {
+               tree = new ContainerCheckedTreeViewer(comp);
+               tree.setContentProvider(data);
+               tree.setAutoExpandLevel(2);
+               tree.setInput(""); //$NON-NLS-1$
+               tree.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
+               
+               tree.addCheckStateListener(new ICheckStateListener() {
+
+                       public void checkStateChanged(CheckStateChangedEvent event) {
+                               MethodToImplementConfig config = ((MethodToImplementConfig)event.getElement());
+                               config.setChecked(event.getChecked());
+                               checkPage();
+                       }});
+               
+               for (MethodToImplementConfig config : data.getMethodsToImplement()) {
+                       tree.setChecked(config, config.isChecked());
+               }
+               
+       }
+
+       @Override
+       public IWizardPage getNextPage() {
+               if(data.needParameterInput()) {
+                       return wizard.getPageForConfig(data.getFirstConfigNeedingParameterNames());
+               }else {
+                       return computeSuccessorPage();
+               }
+       }
+
+       public void setData(ImplementMethodData data) {
+               this.data = data;
+       }
+
+       public ImplementMethodData getData() {
+               return data;
+       }
+
+       private void checkPage() {
+               if(data.getMethodsToImplement().size() > 0) {
+                       setPageComplete(true);
+               }else {
+                       setPageComplete(false);
+               }
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoring.java
new file mode 100644 (file)
index 0000000..510c842
--- /dev/null
@@ -0,0 +1,342 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ * Marc-Andre Laperle
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.implementmethod;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+
+import org.eclipse.cdt.core.dom.ast.ASTNodeFactoryFactory;
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTNode.CopyStyle;
+import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPNodeFactory;
+import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.refactoring.CRefactoring2;
+import org.eclipse.cdt.internal.ui.refactoring.ModificationCollector;
+import org.eclipse.cdt.internal.ui.refactoring.RefactoringASTCache;
+import org.eclipse.cdt.internal.ui.refactoring.utils.Checks;
+import org.eclipse.cdt.internal.ui.refactoring.utils.NameHelper;
+import org.eclipse.cdt.internal.ui.refactoring.utils.NodeHelper;
+import org.eclipse.cdt.internal.ui.refactoring.utils.SelectionHelper;
+
+/**
+ * Main class of the ImplementMethodRefactoring (Source generator).
+ * Checks conditions, finds insert location and generates the ImplementationNode.
+ * 
+ * @author Mirko Stocker, Lukas Felber, Emanuel Graf
+ */
+public class ImplementMethodRefactoring extends CRefactoring2 {
+       private ICPPASTFunctionDeclarator createdMethodDeclarator;
+       private ImplementMethodData data;
+       private MethodDefinitionInsertLocationFinder methodDefinitionInsertLocationFinder;
+       private Map<IASTSimpleDeclaration, InsertLocation> insertLocations;
+       private static ICPPNodeFactory nodeFactory = ASTNodeFactoryFactory.getDefaultCPPNodeFactory();
+       
+       public ImplementMethodRefactoring(ICElement element, ISelection selection, ICProject project, RefactoringASTCache astCache) {
+               super(element, selection, project, astCache);
+               data = new ImplementMethodData();
+               methodDefinitionInsertLocationFinder = new MethodDefinitionInsertLocationFinder();
+               insertLocations = new HashMap<IASTSimpleDeclaration, InsertLocation>();
+       }
+       
+       @Override
+       public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException {
+               SubMonitor sm = SubMonitor.convert(pm, 10);
+               super.checkInitialConditions(sm.newChild(6));
+
+               if (!initStatus.hasFatalError()) {
+                       data.setMethodDeclarations(findUnimplementedMethodDeclarations(pm));
+
+                       if (selectedRegion.getLength() > 0) {
+                               IASTSimpleDeclaration methodDeclaration = SelectionHelper.findFirstSelectedDeclaration(selectedRegion, astCache.getAST(tu, pm));
+                               if (NodeHelper.isMethodDeclaration(methodDeclaration)) {
+                                       for (MethodToImplementConfig config : data.getMethodDeclarations()) {
+                                               if (config.getDeclaration() == methodDeclaration) {
+                                                       config.setChecked(true);
+                                               }
+                                       }
+                               }
+                       }
+               }
+               sm.done();
+               return initStatus;
+       }
+
+       private List<IASTSimpleDeclaration> findUnimplementedMethodDeclarations(IProgressMonitor pm) throws OperationCanceledException, CoreException {
+               IASTTranslationUnit ast = astCache.getAST(tu, pm);
+               final List<IASTSimpleDeclaration> list = new ArrayList<IASTSimpleDeclaration>();
+               ast.accept(new ASTVisitor() {
+                       {
+                               shouldVisitDeclarations = true;
+                       }
+
+                       @Override
+                       public int visit(IASTDeclaration declaration) {
+                               if (declaration instanceof IASTSimpleDeclaration) {
+                                       IASTSimpleDeclaration simpleDeclaration = (IASTSimpleDeclaration) declaration;
+                                       if (NodeHelper.isMethodDeclaration(simpleDeclaration)) {
+                                               IASTDeclarator[] declarators = simpleDeclaration.getDeclarators();
+                                               IBinding binding = declarators[0].getName().resolveBinding();
+                                               if (isUnimplementedMethodBinding(binding)) {
+                                                       list.add(simpleDeclaration);
+                                                       return ASTVisitor.PROCESS_SKIP; 
+                                               }
+                                       }
+                               }
+                               return ASTVisitor.PROCESS_CONTINUE;
+                       }
+               });
+               return list;
+       }
+       
+       private boolean isUnimplementedMethodBinding(IBinding binding) {
+               if (binding instanceof ICPPFunction) {
+                       if (binding instanceof ICPPMethod) {
+                               ICPPMethod methodBinding = (ICPPMethod) binding;
+                               if (methodBinding.isPureVirtual()) {
+                                       return false; // Pure virtual not handled for now, see bug 303870
+                               }
+                       }
+                       
+                       try {
+                               IIndexName[] indexNames = astCache.getIndex().findNames(binding, IIndex.FIND_DEFINITIONS
+                                                               | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
+                               if (indexNames.length == 0) {
+                                       return true;
+                               }
+                       } catch (CoreException e) {
+                               CUIPlugin.log(e);
+                       }
+               }
+               
+               return false;
+       }
+
+       @Override
+       protected void collectModifications(IProgressMonitor pm, ModificationCollector collector)
+                       throws CoreException,   OperationCanceledException {
+               List<MethodToImplementConfig> methodsToImplement = data.getMethodsToImplement();
+               SubMonitor sm = SubMonitor.convert(pm, 4 * methodsToImplement.size());
+               for (MethodToImplementConfig config : methodsToImplement) {
+                       createDefinition(collector, config, sm.newChild(4));
+               }
+       }
+
+       protected void createDefinition(ModificationCollector collector,
+                       MethodToImplementConfig config, IProgressMonitor subMonitor) throws CoreException, OperationCanceledException {
+               if (subMonitor.isCanceled()) {
+                       throw new OperationCanceledException();
+               }
+               IASTSimpleDeclaration decl = config.getDeclaration();
+               InsertLocation insertLocation = findInsertLocation(decl, subMonitor);
+               if (subMonitor.isCanceled()) {
+                       throw new OperationCanceledException();
+               }
+               
+               subMonitor.worked(1);
+               IASTNode parent = insertLocation.getParentOfNodeToInsertBefore();
+               IASTTranslationUnit ast = parent.getTranslationUnit();
+               ASTRewrite translationUnitRewrite = collector.rewriterForTranslationUnit(ast);
+               subMonitor.worked(1);
+               if (subMonitor.isCanceled()) {
+                       throw new OperationCanceledException();
+               }
+
+               IASTNode nodeToInsertBefore = insertLocation.getNodeToInsertBefore();
+               IASTNode createdMethodDefinition = createFunctionDefinition(ast, decl, insertLocation);
+               subMonitor.worked(1);
+               ASTRewrite methodRewrite = translationUnitRewrite.insertBefore(parent, nodeToInsertBefore, createdMethodDefinition , null);
+               createParameterModifications(methodRewrite, config.getParaHandler());
+               subMonitor.done();
+       }
+       
+       private void createParameterModifications(ASTRewrite methodRewrite, ParameterHandler handler) {
+               for (ParameterInfo actParameterInfo : handler.getParameterInfos()) {
+                       ASTRewrite parameterRewrite = methodRewrite.insertBefore(createdMethodDeclarator, null, actParameterInfo.getParameter(), null);
+                       createNewNameInsertModification(actParameterInfo, parameterRewrite);
+                       createRemoveDefaultValueModification(actParameterInfo, parameterRewrite);
+               }
+       }
+
+       private void createRemoveDefaultValueModification(ParameterInfo parameterInfo, ASTRewrite parameterRewrite) {
+               if (parameterInfo.hasDefaultValue()) {
+                       parameterRewrite.remove(parameterInfo.getDefaultValueNode(), null);
+               }
+       }
+
+       private void createNewNameInsertModification(ParameterInfo parameterInfo, ASTRewrite parameterRewrite) {
+               if (parameterInfo.hasNewName()) {
+                       IASTNode insertNode = parameterInfo.getNewNameNode();
+                       IASTName replaceNode = parameterInfo.getNameNode();
+                       parameterRewrite.replace(replaceNode, insertNode, null);
+               }
+       }
+
+       private InsertLocation findInsertLocation(IASTSimpleDeclaration methodDeclaration, IProgressMonitor subMonitor) throws CoreException {
+               if (insertLocations.containsKey(methodDeclaration)) {
+                       return insertLocations.get(methodDeclaration);
+               }
+               InsertLocation insertLocation = methodDefinitionInsertLocationFinder.find(tu, methodDeclaration.getFileLocation(), methodDeclaration.getParent(), astCache, subMonitor);
+               
+               if (insertLocation.getTranslationUnit() == null || NodeHelper.isContainedInTemplateDeclaration(methodDeclaration)) {
+                       insertLocation.setNodeToInsertAfter(NodeHelper.findTopLevelParent(methodDeclaration), tu);
+               }
+               insertLocations.put(methodDeclaration, insertLocation);
+               return insertLocation;
+       }
+
+       private IASTDeclaration createFunctionDefinition(IASTTranslationUnit unit, IASTSimpleDeclaration methodDeclaration, InsertLocation insertLocation) throws CoreException {
+               IASTDeclSpecifier declSpecifier = methodDeclaration.getDeclSpecifier().copy(CopyStyle.withLocations);
+               ICPPASTFunctionDeclarator functionDeclarator = (ICPPASTFunctionDeclarator) methodDeclaration.getDeclarators()[0];
+               IASTNode declarationParent = methodDeclaration.getParent();
+               
+               if (declSpecifier instanceof ICPPASTDeclSpecifier) {
+                       ((ICPPASTDeclSpecifier) declSpecifier).setVirtual(false); 
+               }
+               
+               String currentFileName = declarationParent.getNodeLocations()[0].asFileLocation().getFileName();
+               if (Path.fromOSString(currentFileName).equals(insertLocation.getFile().getLocation())) {
+                       declSpecifier.setInline(true);
+               }
+               
+               if (declSpecifier.getStorageClass() == IASTDeclSpecifier.sc_static) {
+                       declSpecifier.setStorageClass(IASTDeclSpecifier.sc_unspecified);
+               }
+               
+               ICPPASTQualifiedName qName = createQualifiedNameFor(functionDeclarator, declarationParent, insertLocation);
+               
+               createdMethodDeclarator = nodeFactory.newFunctionDeclarator(qName);
+               createdMethodDeclarator.setConst(functionDeclarator.isConst());
+               for (IASTPointerOperator pop : functionDeclarator.getPointerOperators()) {
+                       createdMethodDeclarator.addPointerOperator(pop.copy(CopyStyle.withLocations));
+               }
+               
+               IASTFunctionDefinition functionDefinition = nodeFactory.newFunctionDefinition(declSpecifier, createdMethodDeclarator, nodeFactory.newCompoundStatement());
+               functionDefinition.setParent(unit);
+               
+               ICPPASTTemplateDeclaration templateDeclaration = NodeHelper.findContainedTemplateDecalaration(declarationParent);
+               if (templateDeclaration != null) {
+                       ICPPASTTemplateDeclaration newTemplateDeclaration = nodeFactory.newTemplateDeclaration(functionDefinition);
+                       newTemplateDeclaration.setParent(unit);
+                       
+                       for (ICPPASTTemplateParameter templateParameter : templateDeclaration.getTemplateParameters()) {
+                               newTemplateDeclaration.addTemplateParameter(templateParameter.copy(CopyStyle.withLocations));
+                       }
+                       
+                       return newTemplateDeclaration;
+               }
+               return functionDefinition;
+       }
+
+       private ICPPASTQualifiedName createQualifiedNameFor(IASTFunctionDeclarator functionDeclarator,
+                       IASTNode declarationParent, InsertLocation insertLocation)      throws CoreException {
+               int insertOffset = insertLocation.getInsertPosition();
+               return NameHelper.createQualifiedNameFor(
+                               functionDeclarator.getName(), tu, functionDeclarator.getFileLocation().getNodeOffset(),
+                               insertLocation.getTranslationUnit(), insertOffset, astCache);
+       }
+       
+       public ImplementMethodData getRefactoringData() {
+               return data;
+       }
+
+       @Override
+       protected RefactoringDescriptor getRefactoringDescriptor() {
+               // TODO egraf add Descriptor
+               return null;
+       }
+       
+       private IFile[] getAllFilesToModify() {
+               List<IFile> files = new ArrayList<IFile>(2);
+               IFile file = (IFile) tu.getResource();
+               if (file != null) {
+                       files.add(file);
+               }
+               
+               for (InsertLocation insertLocation : insertLocations.values()) {
+                       if (insertLocation != null) {
+                               file = insertLocation.getFile();
+                               if (file != null) {
+                                       files.add(file);
+                               }
+                       }                       
+               }
+
+               return files.toArray(new IFile[files.size()]);
+       }
+
+       @Override
+       protected RefactoringStatus checkFinalConditions(IProgressMonitor subProgressMonitor,
+                       CheckConditionsContext checkContext) throws CoreException, OperationCanceledException {
+               RefactoringStatus result = new RefactoringStatus();
+               if (isOneOrMoreImplementationInHeader(subProgressMonitor)) {
+                       result.addInfo(Messages.ImplementMethodRefactoring_NoImplFile);
+               }
+               Checks.addModifiedFilesToChecker(getAllFilesToModify(), checkContext);
+               return result;
+       }
+       
+       private boolean isOneOrMoreImplementationInHeader(IProgressMonitor subProgressMonitor) throws CoreException {
+               for (MethodToImplementConfig config : data.getMethodsToImplement()) {
+                       IASTSimpleDeclaration decl = config.getDeclaration();
+                       findInsertLocation(decl, subProgressMonitor);   
+               }
+               
+               if (insertLocations.isEmpty()) {
+                       return true;
+               }
+               
+               for (InsertLocation insertLocation : insertLocations.values()) {
+                       if (insertLocation != null && tu.equals(insertLocation.getTranslationUnit())) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoringRunner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoringRunner.java
new file mode 100644 (file)
index 0000000..58cf32b
--- /dev/null
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *     Institute for Software - initial API and implementation
+ *     Marc-Andre Laperle
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.implementmethod;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.internal.ui.refactoring.RefactoringASTCache;
+import org.eclipse.cdt.internal.ui.refactoring.RefactoringRunner2;
+
+/**
+ * @author Lukas Felber
+ */
+public class ImplementMethodRefactoringRunner extends RefactoringRunner2 {
+
+       public ImplementMethodRefactoringRunner(ICElement element, ISelection selection,
+                       IShellProvider shellProvider, ICProject cProject) {
+               super(element, selection, shellProvider, cProject);
+       }
+
+       @Override
+       public void run(RefactoringASTCache astCache) {
+               ImplementMethodRefactoring refactoring = new ImplementMethodRefactoring(element, selection, project, astCache);
+               ImplementMethodRefactoringWizard wizard = new ImplementMethodRefactoringWizard(refactoring);
+               RefactoringWizardOpenOperation operator = new RefactoringWizardOpenOperation(wizard);
+
+               try {
+                       operator.run(shellProvider.getShell(), refactoring.getName());
+               } catch (InterruptedException e) {
+                       Thread.currentThread().interrupt();
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoringWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ImplementMethodRefactoringWizard.java
new file mode 100644 (file)
index 0000000..30caf05
--- /dev/null
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *     Institute for Software - initial API and implementation
+ *     Marc-Andre Laperle
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.implementmethod;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * @author Mirko Stocker
+ */
+public class ImplementMethodRefactoringWizard extends RefactoringWizard {
+   private final ImplementMethodRefactoring refactoring;
+   private Map<MethodToImplementConfig, ParameterNamesInputPage>pagesMap =
+                  new HashMap<MethodToImplementConfig, ParameterNamesInputPage>();
+
+       public ImplementMethodRefactoringWizard(ImplementMethodRefactoring refactoring) {
+          super(refactoring, WIZARD_BASED_USER_INTERFACE);
+          this.refactoring = refactoring;
+       }
+
+       @Override
+       protected void addUserInputPages() {
+               addPage(new ImplementMethodInputPage(refactoring.getRefactoringData(), this));
+               ImplementMethodData data = refactoring.getRefactoringData();
+               for (MethodToImplementConfig config : data.getMethodDeclarations()) {
+                       if (config.getParaHandler().needsAdditionalArgumentNames()) {
+                               ParameterNamesInputPage page = new ParameterNamesInputPage(config, this);
+                               pagesMap.put(config, page);
+                               addPage(page);
+                       }
+               }
+       }
+       
+       public ParameterNamesInputPage getPageForConfig(MethodToImplementConfig config) {
+               return pagesMap.get(config);
+       }
+
+       /**
+        * When canceling the wizard, RefactoringASTCache gets disposed and releases the lock on
+        * the index but the preview jobs might still be running and access the index or an index-based
+        * AST so we need to make sure they are done before disposing the cache
+        * <p> 
+        * When proceeding to the last page and finishing the wizard, the refactoring will run
+        * and possibly use concurrently the same ASTs that the jobs use, so we need to make
+        * sure the jobs are joined.
+        */
+       protected void cancelAndJoinPreviewJobs() {
+               boolean isOnePreviewJobRunning = false;
+               for (ParameterNamesInputPage parameterNamesInputPage : pagesMap.values()) {
+                       isOnePreviewJobRunning |= parameterNamesInputPage.cancelPreviewJob();
+               }
+               
+               // There are good chances that one job is still running, show a progress bar to the user,
+               // join everything.
+               if (isOnePreviewJobRunning) {
+                       try {
+                               getContainer().run(false, false, new IRunnableWithProgress() {
+                                       public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+                                               monitor.beginTask(Messages.ImplementMethodRefactoringWizard_CancelingPreviewGeneration,
+                                                               pagesMap.size() + 1);
+                                               monitor.worked(1);
+
+                                               for (ParameterNamesInputPage parameterNamesInputPage : pagesMap.values()) {
+                                                       parameterNamesInputPage.joinPreviewJob();
+                                                       monitor.worked(1);
+                                               }
+
+                                               monitor.done();
+                                       }
+                               });
+                       } catch (InvocationTargetException e) {
+                               CUIPlugin.log(e);
+                       } catch (InterruptedException e) {
+                               // ignore since not cancelable
+                       }
+               } else {
+                       // We don't take any chances, we still join everything. But there are good chances that
+                       // the jobs are stopped so we don't show a progress bar.
+                       for (ParameterNamesInputPage parameterNamesInputPage : pagesMap.values()) {
+                               parameterNamesInputPage.joinPreviewJob();
+                       }
+               }
+       }
+
+       @Override
+       public boolean performCancel() {
+               cancelAndJoinPreviewJobs();
+               return super.performCancel();
+       }
+
+       @Override
+       public boolean performFinish() {
+               cancelAndJoinPreviewJobs();
+               return super.performFinish();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/InsertLocation.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/InsertLocation.java
new file mode 100644 (file)
index 0000000..50fdb35
--- /dev/null
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *     Institute for Software - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.implementmethod;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+/**
+ * Is returned when using the find method of the MethodDefinitionInsertLocationFinder.
+ * Contains all the information needed to insert at the correct position.
+ * 
+ * @author Lukas Felber
+ */
+public class InsertLocation {
+       private IASTNode nodeToInsertAfter;
+       private IASTNode nodeToInsertBefore;
+       private IASTNode parentNode;
+       private ITranslationUnit tu;
+
+       public InsertLocation() {
+       }
+
+       public boolean hasAnyNode() {
+               return nodeToInsertAfter != null || nodeToInsertBefore != null;
+       }
+
+       public IASTNode getNodeToInsertBefore() {
+               return nodeToInsertBefore;
+       }
+
+       public IASTNode getParentOfNodeToInsertBefore() throws CoreException {
+               IASTNode node = nodeToInsertBefore != null ? nodeToInsertBefore : nodeToInsertAfter;
+               return node != null ? node.getParent() : parentNode;
+       }
+
+       public ITranslationUnit getTranslationUnit() {
+               return tu;
+       }
+       
+       public IFile getFile() {
+               return tu != null ? (IFile) tu.getResource() : null;
+       }
+
+       public int getInsertPosition() {
+               if (nodeToInsertBefore != null) {
+                       return nodeToInsertBefore.getFileLocation().getNodeOffset();
+               } else if (nodeToInsertAfter != null) {
+                       IASTFileLocation fileLocation = nodeToInsertAfter.getFileLocation();
+                       return fileLocation.getNodeOffset() + fileLocation.getNodeLength();
+               }
+               return 0;
+       }
+
+       public void setNodeToInsertAfter(IASTNode nodeToInsertAfter, ITranslationUnit tu) {
+               this.nodeToInsertAfter = nodeToInsertAfter;
+               this.tu = tu;
+       }
+
+       public void setNodeToInsertBefore(IASTNode nodeToInsertBefore, ITranslationUnit tu) {
+               this.nodeToInsertBefore = nodeToInsertBefore;
+               this.tu = tu;
+       }
+
+       public void setParentNode(IASTNode parentNode, ITranslationUnit tu) {
+               this.parentNode = parentNode;
+               this.tu = tu;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/Messages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/Messages.java
new file mode 100644 (file)
index 0000000..52e3420
--- /dev/null
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ *  Copyright (c) 2005, 2011 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *      IBM - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.implementmethod;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class Messages extends NLS {
+       public static String ParameterNamesInputPage_Title;
+       public static String ParameterNamesInputPage_CompleteMissingMails;
+       public static String ImplementMethodInputPage_PageTitle;
+       public static String ImplementMethodInputPage_SelectAll;
+       public static String ImplementMethodInputPage_DeselectAll;
+       public static String ImplementMethodRefactoringPage_GeneratingPreview;
+       public static String ImplementMethodRefactoringPage_PreviewCanceled;
+       public static String ImplementMethodRefactoringPage_PreviewGenerationNotPossible;
+       public static String ImplementMethodRefactoring_NoMethodSelected;
+       public static String ImplementMethodRefactoring_MethodHasImpl;
+       public static String ImplementMethodRefactoring_NoImplFile;
+       public static String ImplementMethodRefactoringWizard_CancelingPreviewGeneration;
+       public static String ImplementMethodInputPage_Header;
+
+       static {
+               NLS.initializeMessages(Messages.class.getName(), Messages.class);
+       }
+
+       // Do not instantiate
+       private Messages() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/Messages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/Messages.properties
new file mode 100644 (file)
index 0000000..1b60d0f
--- /dev/null
@@ -0,0 +1,26 @@
+###############################################################################
+# Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
+# Rapperswil, University of applied sciences and others
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#    Institute for Software - initial API and implementation
+#    IBM Corporation
+#    Marc-Andre Laperle
+###############################################################################
+ParameterNamesInputPage_Title=Implement Method
+ImplementMethodInputPage_Header=Select Methods to implement:
+ParameterNamesInputPage_CompleteMissingMails=Please complete the missing variable names:
+ImplementMethodInputPage_PageTitle=Implement Method
+ImplementMethodInputPage_SelectAll=Select All
+ImplementMethodInputPage_DeselectAll=Deselect All
+ImplementMethodRefactoringPage_PreviewGenerationNotPossible=Preview generation not possible
+ImplementMethodRefactoringPage_GeneratingPreview=Generating preview...
+ImplementMethodRefactoringPage_PreviewCanceled=Preview canceled
+ImplementMethodRefactoring_NoMethodSelected=No method declaration selected
+ImplementMethodRefactoring_MethodHasImpl=This method already has an implementation.
+ImplementMethodRefactoring_NoImplFile=No implementation file found for one or more method. Inserting definition(s) into the header file.
+ImplementMethodRefactoringWizard_CancelingPreviewGeneration=Canceling preview generation
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/MethodDefinitionInsertLocationFinder.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/MethodDefinitionInsertLocationFinder.java
new file mode 100644 (file)
index 0000000..2430e7b
--- /dev/null
@@ -0,0 +1,193 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *     Institute for Software - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *     Marc-Andre Laperle
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.implementmethod;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+import org.eclipse.cdt.internal.ui.editor.SourceHeaderPartnerFinder;
+import org.eclipse.cdt.internal.ui.refactoring.RefactoringASTCache;
+import org.eclipse.cdt.internal.ui.refactoring.utils.DefinitionFinder;
+import org.eclipse.cdt.internal.ui.refactoring.utils.NodeHelper;
+
+/**
+ * Finds the information that are needed to tell where a method definition of a certain
+ * method declaration should be inserted.
+ * 
+ * @author Mirko Stocker, Lukas Felber
+ */
+public class MethodDefinitionInsertLocationFinder {
+       // We cache DefinitionFinder.getDefinition results because refactorings like Implement Method
+       // might want to find multiple insert locations in the same translation unit. This prevents
+       // many redundant calls to DefinitionFinder.getDefinition and speeds up the process quite
+       // a bit. Unfortunately, this has the minor side-effect or having to instantiate this class.
+       Map<IASTSimpleDeclaration, IASTName> cachedDeclarationToDefinition =
+                       new HashMap<IASTSimpleDeclaration, IASTName>();
+
+       public InsertLocation find(ITranslationUnit declarationTu, IASTFileLocation methodDeclarationLocation,
+                       IASTNode parent, RefactoringASTCache astCache, IProgressMonitor pm) throws CoreException {
+               IASTDeclaration[] declarations = NodeHelper.getDeclarations(parent);
+               InsertLocation insertLocation = new InsertLocation();
+
+               Collection<IASTSimpleDeclaration> allPreviousSimpleDeclarationsFromClassInReverseOrder =
+                               getAllPreviousSimpleDeclarationsFromClassInReverseOrder(declarations, methodDeclarationLocation, pm);
+               Collection<IASTSimpleDeclaration> allFollowingSimpleDeclarationsFromClass =
+                               getAllFollowingSimpleDeclarationsFromClass(declarations, methodDeclarationLocation, pm);
+
+               for (IASTSimpleDeclaration simpleDeclaration : allPreviousSimpleDeclarationsFromClassInReverseOrder) {
+                       if (pm != null && pm.isCanceled()) {
+                               throw new OperationCanceledException();
+                       }
+
+                       IASTName definition = null;
+                       if (cachedDeclarationToDefinition.containsKey(simpleDeclaration)) {
+                               definition = cachedDeclarationToDefinition.get(simpleDeclaration);
+                       } else {
+                               definition = DefinitionFinder.getDefinition(simpleDeclaration, astCache, pm);
+                               if (definition != null) {
+                                       cachedDeclarationToDefinition.put(simpleDeclaration, definition);       
+                               }
+                       }
+
+                       if (definition != null) {
+                               insertLocation.setNodeToInsertAfter(findFirstSurroundingParentFunctionNode(
+                                               definition), definition.getTranslationUnit().getOriginatingTranslationUnit());
+                       }
+               }
+
+               for (IASTSimpleDeclaration simpleDeclaration : allFollowingSimpleDeclarationsFromClass) {
+                       if (pm != null && pm.isCanceled()) {
+                               throw new OperationCanceledException();
+                       }
+
+                       IASTName definition = null;
+                       if (cachedDeclarationToDefinition.containsKey(simpleDeclaration)) {
+                               definition = cachedDeclarationToDefinition.get(simpleDeclaration);
+                       } else {
+                               definition = DefinitionFinder.getDefinition(simpleDeclaration, astCache, pm);
+                               if (definition != null) {
+                                       cachedDeclarationToDefinition.put(simpleDeclaration, definition);
+                               }
+                       }
+
+                       if (definition != null) {
+                               insertLocation.setNodeToInsertBefore(findFirstSurroundingParentFunctionNode(definition),
+                                               definition.getTranslationUnit().getOriginatingTranslationUnit());
+                       }
+               }
+
+               if (insertLocation.getTranslationUnit() == null) {
+                       ITranslationUnit partner = SourceHeaderPartnerFinder.getPartnerTranslationUnit(
+                                       declarationTu, astCache);
+                       if (partner != null) {
+                               insertLocation.setParentNode(astCache.getAST(partner, null), partner);
+                       }       
+               }
+
+               return insertLocation;
+       }
+
+       private static IASTNode findFunctionDefinitionInParents(IASTNode node) {
+               if (node == null) {
+                       return null;
+               } else if (node instanceof IASTFunctionDefinition) {
+                       if (node.getParent() instanceof ICPPASTTemplateDeclaration) {
+                               node = node.getParent();
+                       }
+                       return node;
+               }
+               return findFunctionDefinitionInParents(node.getParent());
+       }
+
+       private static IASTNode findFirstSurroundingParentFunctionNode(IASTNode definition) {
+               IASTNode functionDefinitionInParents = findFunctionDefinitionInParents(definition);
+               if (functionDefinitionInParents == null) {
+                       return null;
+               }
+               if (functionDefinitionInParents.getNodeLocations().length == 0) {
+                       return null;
+               }
+               return functionDefinitionInParents;
+       }
+
+       /**
+        * Searches the given class for all IASTSimpleDeclarations occurring before 'method'
+        * and returns them in reverse order.
+        * 
+        * @param declarations to be searched
+        * @param methodPosition on which the search aborts
+        * @param pm 
+        * @return all declarations, sorted in reverse order
+        */
+       private static Collection<IASTSimpleDeclaration> getAllPreviousSimpleDeclarationsFromClassInReverseOrder(
+                       IASTDeclaration[] declarations, IASTFileLocation methodPosition, IProgressMonitor pm) {
+               ArrayList<IASTSimpleDeclaration> outputDeclarations = new ArrayList<IASTSimpleDeclaration>();
+               if (declarations.length >= 0) {
+                       for (IASTDeclaration decl : declarations) {
+                               if (pm != null && pm.isCanceled()) {
+                                       return outputDeclarations;
+                               }
+                               if (decl.getFileLocation().getStartingLineNumber() >= methodPosition.getStartingLineNumber()) {
+                                       break;
+                               }
+                               if (isMemberFunctionDeclaration(decl)) {
+                                       outputDeclarations.add((IASTSimpleDeclaration) decl);
+                               }
+                       }
+               }
+               Collections.reverse(outputDeclarations);
+               return outputDeclarations;
+       }
+
+       private static Collection<IASTSimpleDeclaration> getAllFollowingSimpleDeclarationsFromClass(
+                       IASTDeclaration[] declarations, IASTFileLocation methodPosition, IProgressMonitor pm) {
+               ArrayList<IASTSimpleDeclaration> outputDeclarations = new ArrayList<IASTSimpleDeclaration>();
+
+               if (declarations.length >= 0) {
+                       for (IASTDeclaration decl : declarations) {
+                               if (pm != null && pm.isCanceled()) {
+                                       return outputDeclarations;
+                               }
+                               if (isMemberFunctionDeclaration(decl) &&
+                                               decl.getFileLocation().getStartingLineNumber() > methodPosition.getStartingLineNumber() ) {
+                                       outputDeclarations.add((IASTSimpleDeclaration) decl);
+                               }
+                       }
+               }
+               return outputDeclarations;
+       }
+       
+       private static boolean isMemberFunctionDeclaration(IASTDeclaration decl) {
+               return decl instanceof IASTSimpleDeclaration &&
+                               ((IASTSimpleDeclaration) decl).getDeclarators().length > 0 &&
+                               ((IASTSimpleDeclaration) decl).getDeclarators()[0] instanceof IASTFunctionDeclarator;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/MethodToImplementConfig.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/MethodToImplementConfig.java
new file mode 100644 (file)
index 0000000..9f04cca
--- /dev/null
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ * Institute for Software (IFS)- initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.implementmethod;
+
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+
+/**
+ * @author Emanuel Graf IFS
+ *
+ */
+public class MethodToImplementConfig {
+       
+       private IASTSimpleDeclaration declaration;
+       private ParameterHandler paraHandler;
+       private boolean checked;
+       
+       public MethodToImplementConfig(IASTSimpleDeclaration declaration,
+                       ParameterHandler paraHandler) {
+               super();
+               this.declaration = declaration;
+               this.paraHandler = paraHandler;
+       }
+
+       public IASTSimpleDeclaration getDeclaration() {
+               return declaration;
+       }
+
+       public ParameterHandler getParaHandler() {
+               return paraHandler;
+       }
+       
+       @Override
+       public String toString() {
+               return declaration.getRawSignature();
+       }
+       
+       public boolean isChecked() {
+               return checked;
+       }
+
+       public void setChecked(boolean checked) {
+               this.checked = checked;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterHandler.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterHandler.java
new file mode 100644 (file)
index 0000000..2868e82
--- /dev/null
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.implementmethod;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
+
+import org.eclipse.cdt.internal.ui.refactoring.utils.NameHelper;
+import org.eclipse.cdt.internal.ui.refactoring.utils.PseudoNameGenerator;
+
+/**
+ * Manages and creates Method Parameter Infos.
+ * 
+ * @author Lukas Felber
+ *
+ */
+public class ParameterHandler {
+       private boolean needsAditionalArgumentNames;
+       private PseudoNameGenerator pseudoNameGenerator;
+       private ArrayList<ParameterInfo> parameterInfos;
+       private IASTSimpleDeclaration method;
+       
+       public ParameterHandler(IASTSimpleDeclaration method) {
+               this.method = method;
+               initArgumentNames();
+       }
+       
+       public boolean needsAdditionalArgumentNames() {
+               return needsAditionalArgumentNames;
+       }
+       
+       public void initArgumentNames() {
+               if(parameterInfos != null) {
+                       return;
+               }
+               needsAditionalArgumentNames = false; 
+               parameterInfos = new ArrayList<ParameterInfo>();
+               for(IASTParameterDeclaration actParam : getParametersFromMethodNode()) {
+                       String actName = actParam.getDeclarator().getName().toString();
+                       boolean isChangable = false;
+                       if(actParam.getDeclSpecifier()instanceof IASTSimpleDeclSpecifier && ((IASTSimpleDeclSpecifier)actParam.getDeclSpecifier()).getType() == IASTSimpleDeclSpecifier.t_void) {
+                               actName = ""; //$NON-NLS-1$
+                               isChangable = false;
+                       }else if(actName.length() == 0) {
+                               needsAditionalArgumentNames = true;
+                               isChangable = true;
+                               actName = findNameForParameter(NameHelper.getTypeName(actParam));
+                       }
+                       parameterInfos.add(new ParameterInfo(actParam, actName, isChangable));
+               }
+       }
+
+       private String findNameForParameter(String typeName) {
+               if(pseudoNameGenerator == null) {
+                       pseudoNameGenerator = new PseudoNameGenerator();
+
+                       for(IASTParameterDeclaration parameter : getParametersFromMethodNode()) {
+                               if(parameter.getDeclarator().getName().toString().length() != 0) {
+                                       pseudoNameGenerator.addExistingName(parameter.getDeclarator().getName().toString());
+                               }
+                       }
+               }
+               return pseudoNameGenerator.generateNewName(typeName);
+       }
+       
+       private IASTParameterDeclaration[] getParametersFromMethodNode() {
+               if(method.getDeclarators().length < 1) {
+                       return null;
+               }
+               return ((ICPPASTFunctionDeclarator) method.getDeclarators()[0]).getParameters();
+       }
+
+       public Collection<ParameterInfo> getParameterInfos() {
+               return parameterInfos;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterInfo.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterInfo.java
new file mode 100644 (file)
index 0000000..55adcb1
--- /dev/null
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.implementmethod;
+
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
+
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
+
+import org.eclipse.cdt.internal.ui.refactoring.utils.NameHelper;
+
+/**
+ * @author Lukas Felber
+ * 
+ */
+public class ParameterInfo {
+       private IASTParameterDeclaration parameter;
+       private boolean hasNewName;
+       private String parameterName;
+       
+       public ParameterInfo(IASTParameterDeclaration parameter, String parameterName, boolean HasNewName) {
+               this.parameter = parameter;
+               this.hasNewName = HasNewName;
+               this.parameterName = parameterName;
+       }
+       
+       public boolean hasNewName() {
+               return hasNewName;
+       }
+       
+       public boolean hasDefaultValue() {
+               return getDefaultValueNode() != null;
+       }
+
+       public String getTypeName() {
+               return NameHelper.getTypeName(parameter);
+       }
+
+       public String getParameterName() {
+               return parameterName;
+       }
+
+       public void setParameterName(String newName) {
+               this.parameterName = newName;
+       }
+
+       public IASTParameterDeclaration getParameter() {
+               return parameter;
+       }
+
+       public IASTName getNameNode() {
+               return parameter.getDeclarator().getName();
+       }
+
+       public IASTName getNewNameNode() {
+               return new CPPASTName(parameterName.toCharArray());
+       }
+
+       public IASTNode getDefaultValueNode() {
+               return parameter.getDeclarator().getInitializer();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterNamesInputPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterNamesInputPage.java
new file mode 100644 (file)
index 0000000..8247988
--- /dev/null
@@ -0,0 +1,221 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *     Institute for Software - initial API and implementation
+ *     Marc-Andre Laperle
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.implementmethod;
+
+import java.util.HashMap;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
+import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.text.edits.InsertEdit;
+import org.eclipse.text.edits.MultiTextEdit;
+import org.eclipse.text.edits.TextEdit;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.refactoring.CTextFileChange;
+
+import org.eclipse.cdt.internal.ui.preferences.formatter.TranslationUnitPreview;
+import org.eclipse.cdt.internal.ui.refactoring.CCompositeChange;
+import org.eclipse.cdt.internal.ui.refactoring.ModificationCollector;
+import org.eclipse.cdt.internal.ui.refactoring.dialogs.ValidatingLabeledTextField;
+
+/**
+ * InputPage used by the ImplementMethod refactoring if its necessary to enter additional parameter names.
+ * 
+ * @author Mirko Stocker
+ *
+ */
+public class ParameterNamesInputPage extends UserInputWizardPage {
+
+       private static final int PREVIEW_UPDATE_DELAY = 500;
+       private MethodToImplementConfig config;
+       private TranslationUnitPreview translationUnitPreview;
+       private Job delayedPreviewUpdater;
+       private ImplementMethodRefactoringWizard wizard;
+
+       public ParameterNamesInputPage(MethodToImplementConfig config, ImplementMethodRefactoringWizard wizard) {
+               super(Messages.ParameterNamesInputPage_Title);
+               this.config = config;
+               this.wizard = wizard;
+       }
+
+       public void createControl(Composite parent) {
+               
+               Composite superComposite = new Composite(parent, SWT.NONE);
+               
+           superComposite.setLayout(new GridLayout());
+               
+               setTitle(Messages.ImplementMethodInputPage_PageTitle);
+               setMessage(Messages.ParameterNamesInputPage_CompleteMissingMails);
+       
+               ValidatingLabeledTextField validatingLabeledTextField = new ValidatingLabeledTextField(superComposite);
+               validatingLabeledTextField.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
+               
+               for (final ParameterInfo actParameterInfo : config.getParaHandler().getParameterInfos()) {
+
+                       String type = actParameterInfo.getTypeName();
+                       String content = actParameterInfo.getParameterName();
+                       boolean readOnly = !actParameterInfo.hasNewName();
+                       
+                       validatingLabeledTextField.addElement(type, content, readOnly, new ValidatingLabeledTextField.Validator(){
+
+                               @Override
+                               public void hasErrors() {
+                                       setPageComplete(false);
+                               }
+
+                               @Override
+                               public void hasNoErrors() {
+                                       setPageComplete(true);
+                               }
+
+                               @Override
+                               public boolean isValidInput(String newName) {
+                                       actParameterInfo.setParameterName(newName);
+                                       updatePreview();
+                                       return true;
+                               }});
+               }
+
+               createPreview(superComposite);
+               
+               setControl(superComposite);
+       }
+       
+       private InsertEdit getInsertEdit(CompositeChange compositeChange) {
+               for (Change actChange : compositeChange.getChildren()) {
+                       if (actChange instanceof CompositeChange) {
+                               return getInsertEdit((CompositeChange) actChange);
+                       } else if (actChange instanceof CTextFileChange) {
+                               CTextFileChange textFileChange = (CTextFileChange) actChange;
+                               TextEdit edit = textFileChange.getEdit();
+                               if (edit instanceof MultiTextEdit) {
+                                       MultiTextEdit multiEdit = (MultiTextEdit) edit;
+                                       if (multiEdit.getChildrenSize() == 0) {
+                                               continue;
+                                       }
+                                       TextEdit textEdit = multiEdit.getChildren()[0];
+                                       if (textEdit instanceof InsertEdit) {
+                                               return (InsertEdit) textEdit;
+                                       }
+                               }
+                       }
+               }
+               return null;
+       }       
+       
+       public String createFunctionDefinitionSignature(IProgressMonitor monitor) {
+               try {
+                       ModificationCollector collector = new ModificationCollector();
+                       ImplementMethodRefactoring implementMethodRefactoring = (ImplementMethodRefactoring)wizard.getRefactoring();
+                       CCompositeChange finalChange = null;
+                       // We can have multiple preview jobs. We don't
+                       // want multiple jobs concurrently using the same ASTs
+                       synchronized (implementMethodRefactoring) {
+                               implementMethodRefactoring.createDefinition(collector, config, monitor);
+                               finalChange = collector.createFinalChange();    
+                       }
+                       InsertEdit insertEdit = getInsertEdit(finalChange);
+                       if (insertEdit == null) {
+                               return Messages.ImplementMethodRefactoringPage_PreviewGenerationNotPossible;
+                       }
+                       
+                       return insertEdit.getText().trim();
+               } catch (OperationCanceledException e) {
+                       return Messages.ImplementMethodRefactoringPage_PreviewCanceled;
+               } catch (CoreException e) {
+                       return Messages.ImplementMethodRefactoringPage_PreviewGenerationNotPossible;
+               }
+       }
+
+       private void createPreview(Composite superComposite) {
+               translationUnitPreview = new TranslationUnitPreview(new HashMap<String, String>(), superComposite);
+               translationUnitPreview.getControl().setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
+               
+               delayedPreviewUpdater = new Job(Messages.ImplementMethodRefactoringPage_GeneratingPreview) {
+                       @Override
+                       protected IStatus run(IProgressMonitor monitor) {
+                               setPreviewText(Messages.ImplementMethodRefactoringPage_GeneratingPreview);
+                               String functionDefinitionSignature = createFunctionDefinitionSignature(monitor);
+                               if (monitor.isCanceled()) {
+                                       return Status.CANCEL_STATUS;
+                               }
+                               setPreviewText(functionDefinitionSignature);
+                               return Status.OK_STATUS;
+                       }
+                       private void setPreviewText(final String text) {
+                               if (getShell() != null && getShell().getDisplay() != null) {
+                                       getShell().getDisplay().asyncExec(new Runnable() {
+                                               public void run() {
+                                                       if (translationUnitPreview.getControl() != null && !translationUnitPreview.getControl().isDisposed()) {
+                                                               translationUnitPreview.setPreviewText(text);
+                                                       }
+                                               }});
+                               }
+                       }
+               };
+               
+               delayedPreviewUpdater.schedule(PREVIEW_UPDATE_DELAY);
+       }
+       
+       @Override
+       public boolean canFlipToNextPage() {
+               return isPageComplete();
+       }
+       
+       @Override
+       public IWizardPage getNextPage() {
+               MethodToImplementConfig nextConfig = ((ImplementMethodRefactoring)wizard.getRefactoring()).getRefactoringData().getNextConfigNeedingParameterNames(config);
+               if (nextConfig != null) {
+                       return wizard.getPageForConfig(nextConfig);
+               } else {
+                       wizard.cancelAndJoinPreviewJobs();
+                       return computeSuccessorPage();
+               }
+       }
+
+       protected boolean cancelPreviewJob() {
+               // We cannot rely on getState being accurate in all cases so we only use this
+               // as a hint to change the preview text
+               if (delayedPreviewUpdater.getState() != Job.NONE) {
+                       translationUnitPreview.setPreviewText(Messages.ImplementMethodRefactoringPage_PreviewCanceled);
+               }
+               return !delayedPreviewUpdater.cancel();
+       }
+       
+       protected void joinPreviewJob() {
+               try {
+                       delayedPreviewUpdater.join();
+               } catch (InterruptedException e1) {
+                       CUIPlugin.log(e1);
+               }
+       }
+
+       private void updatePreview() {
+               if (translationUnitPreview == null) {
+                       return;
+               }
+               delayedPreviewUpdater.schedule(PREVIEW_UPDATE_DELAY);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java
new file mode 100644 (file)
index 0000000..af94f75
--- /dev/null
@@ -0,0 +1,1525 @@
+/******************************************************************************* 
+ * Copyright (c) 2005, 2011 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *     Markus Schorn - initial API and implementation 
+ *     IBM Corporation
+ *     Sergey Prigogin (Google)
+ ******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.RefactoringStatusEntry;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.services.IDisposable;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionStyleMacroParameter;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
+import org.eclipse.cdt.core.dom.ast.IASTNodeSelector;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorElifStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorFunctionStyleMacroDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIfStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIfdefStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIfndefStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IArrayType;
+import org.eclipse.cdt.core.dom.ast.IBasicType;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.ICompositeType;
+import org.eclipse.cdt.core.dom.ast.IEnumeration;
+import org.eclipse.cdt.core.dom.ast.IEnumerator;
+import org.eclipse.cdt.core.dom.ast.IField;
+import org.eclipse.cdt.core.dom.ast.IFunction;
+import org.eclipse.cdt.core.dom.ast.IFunctionType;
+import org.eclipse.cdt.core.dom.ast.IMacroBinding;
+import org.eclipse.cdt.core.dom.ast.IParameter;
+import org.eclipse.cdt.core.dom.ast.IPointerType;
+import org.eclipse.cdt.core.dom.ast.IProblemBinding;
+import org.eclipse.cdt.core.dom.ast.IQualifierType;
+import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.ITypedef;
+import org.eclipse.cdt.core.dom.ast.IVariable;
+import org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope;
+import org.eclipse.cdt.core.dom.ast.c.ICFunctionPrototypeScope;
+import org.eclipse.cdt.core.dom.ast.c.ICFunctionScope;
+import org.eclipse.cdt.core.dom.ast.c.ICScope;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
+import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPImplicitMethod;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethod;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
+import org.eclipse.cdt.internal.core.index.IIndexScope;
+import org.eclipse.cdt.internal.corext.util.CModelUtil;
+
+import org.eclipse.cdt.internal.ui.editor.ASTProvider;
+
+/**
+ * Used for refactoring to cache the IASTTranslationUnits.
+ * Contains a collection of methods operating on ASTNodes.
+ * The object has to be disposed of after use.
+ */
+public class ASTManager implements IDisposable {
+       private static final int PARSE_MODE = ITranslationUnit.AST_SKIP_ALL_HEADERS
+                       | ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT
+                       | ITranslationUnit.AST_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS
+                       | ITranslationUnit.AST_PARSE_INACTIVE_CODE;
+
+       public final static int TRUE= 1;
+    public final static int FALSE= 0;
+    public final static int UNKNOWN= -1;
+    
+       private IASTTranslationUnit fSharedAST;
+    private Map<IFile, IASTTranslationUnit> fTranslationUnits= new HashMap<IFile, IASTTranslationUnit>();
+    private HashSet<String> fProblemUnits= new HashSet<String>();
+    private CRefactoringArgument fArgument;
+    private IBinding[] fValidBindings;
+    private String fRenameTo;
+    private HashMap<IBinding, Integer> fKnownBindings;
+    private HashSet<IBinding> fConflictingBinding;
+       private boolean fDisposed;
+
+    public static String nth_of_m(int n, int m) {
+        StringBuilder nofm= new StringBuilder();
+        append_nth_of_m(n, m, nofm);
+        return nofm.toString();
+    }
+
+    static void append_nth_of_m(int n, int m, StringBuilder buf) {
+        buf.append(n);
+        switch (n) {
+            case 1:
+                buf.append("st"); //$NON-NLS-1$
+                break;
+            case 2:
+                buf.append("nd"); //$NON-NLS-1$
+                break;
+            case 3:
+                buf.append("rd"); //$NON-NLS-1$
+                break;
+            default:
+                buf.append("th"); //$NON-NLS-1$
+                break;
+        }
+        buf.append(" of "); //$NON-NLS-1$
+        buf.append(m);
+    }
+    
+    public static IASTFileLocation getLocationInTranslationUnit(IASTNode node) {
+        return node.getFileLocation();
+    }    
+
+    public static IASTName getSimpleName(IASTName name) {
+        if (name instanceof ICPPASTQualifiedName) {
+            IASTName names[]= ((ICPPASTQualifiedName) name).getNames();
+            if (names.length > 0) {
+                name= names[names.length - 1];
+            }
+        }
+        return name;
+    }
+    
+    /**
+     * Returns TRUE, FALSE or UNKNOWN.
+     * @throws DOMException 
+     */
+    public static int isSameBinding(IBinding b1, IBinding b2) throws DOMException {
+        if (b1 == null || b2 == null) {
+            return UNKNOWN;
+        }
+        if (b1.equals(b2)) {
+            return TRUE;
+        }
+        String n1= b1.getName();
+        String n2= b2.getName();
+        if (n1 == null || n2 == null) {
+            return UNKNOWN;
+        }
+        if (!n1.equals(n2)) {
+            return FALSE;
+        }
+        if (b1 instanceof ICompositeType) {
+            if (!(b2 instanceof ICompositeType)) {
+                return FALSE;
+            }
+            ICompositeType c1= (ICompositeType) b1;
+            ICompositeType c2= (ICompositeType) b2;
+            if (c1.getKey() != c2.getKey()) {
+                return FALSE;
+            }
+            IScope s1= c1.getCompositeScope();
+            if (s1 != null) s1= s1.getParent();
+            IScope s2= c2.getCompositeScope();
+            if (s2 != null) s2= s2.getParent();
+            return isSameScope(s1, s2, false);
+        }
+
+        if (b1 instanceof IFunction) {
+            if (!(b2 instanceof IFunction)) {
+                return FALSE;
+            }
+            boolean isStatic= false;
+            boolean checkSig= true;
+            IFunction c1= (IFunction) b1;
+            IFunction c2= (IFunction) b2;
+            if (b1 instanceof ICPPMethod) {
+                if (!(b2 instanceof ICPPMethod)) {
+                    return FALSE;
+                }
+            } else {
+                if (b2 instanceof ICPPMethod) {
+                    return FALSE;
+                }
+                isStatic= c1.isStatic() || c2.isStatic();
+                if (!(b1 instanceof ICPPFunction) && !(b2 instanceof ICPPFunction)) {
+                    checkSig= false;
+                }
+            }
+            
+            int r1= isSameScope(b1.getScope(), b2.getScope(), isStatic);
+            if (r1 == FALSE) {
+                return FALSE;
+            }
+            
+            int r2= checkSig ? hasSameSignature(c1, c2) : TRUE;
+            if (r2 == FALSE) {
+                return FALSE;
+            }
+            if (r1 != r2) {
+                return UNKNOWN;
+            }
+            return r1;
+        }
+        
+        if (b1 instanceof IVariable) {
+            boolean fileStatic= false;
+            if (!(b2 instanceof IVariable)) {
+                return FALSE;
+            }
+
+            IVariable c1= (IVariable) b1;
+            IVariable c2= (IVariable) b2;
+            if (b1 instanceof IField) {
+                if (!(b2 instanceof IField)) {
+                    return FALSE;
+                }
+            } else if (b1 instanceof IParameter) {
+                if (!(b2 instanceof IParameter)) {
+                    return FALSE;
+                }
+            } else {
+                if (b2 instanceof IField || b2 instanceof IParameter) {
+                    return FALSE;
+                }
+                fileStatic= c1.isStatic() || c2.isStatic();
+            }
+            int result= isSameScope(c1.getScope(), c2.getScope(), fileStatic);
+            return result == UNKNOWN ? TRUE : result;
+        }
+
+        if (b1 instanceof IEnumerator) {
+            if (!(b2 instanceof IEnumerator)) {
+                return FALSE;
+            }
+            return isSameScope(b1.getScope(), b2.getScope(), false);
+        }
+        
+        if (b1 instanceof ITypedef) {
+            if (!(b2 instanceof ITypedef)) {
+                return FALSE;
+            }
+            return isSameScope(b1.getScope(), b2.getScope(), false);
+        }
+        
+        if (b1 instanceof IMacroBinding) {
+            if (!(b2 instanceof IMacroBinding)) {
+                return FALSE;
+            }
+            return TRUE;
+        }
+        if (b1 instanceof IEnumeration) {
+            if (!(b2 instanceof IEnumeration)) {
+                return FALSE;
+            }
+            return isSameScope(b1.getScope(), b2.getScope(), false);
+        }
+        int scopeCmp= isSameScope(b1.getScope(), b2.getScope(), false);
+        if (scopeCmp != TRUE) {
+            return scopeCmp;
+        }
+        
+        if (b1.getClass().equals(b2.getClass())) {
+            return TRUE;
+        }
+        return UNKNOWN;
+    }
+    
+    public static int isSameScope(IScope s1, IScope s2, boolean fileStatic) throws DOMException {
+        if (s1 == s2) {
+            return TRUE;
+        }
+        IASTNode node1= ASTInternal.getPhysicalNodeOfScope(s1);
+        IASTNode node2= ASTInternal.getPhysicalNodeOfScope(s2);
+
+        // forward declarations do not have parent scopes.
+        if (s1 == null) {
+            if (!fileStatic && node2 instanceof IASTTranslationUnit) {
+                return TRUE;
+            }
+            return UNKNOWN;
+        }
+        if (s2 == null) {
+            if (!fileStatic && node1 instanceof IASTTranslationUnit) {
+                return TRUE;
+            }
+            return UNKNOWN;
+        }
+        
+        if (s1.equals(s2)) {
+            return TRUE;
+        }
+
+        if (node1 instanceof IASTTranslationUnit && node2 instanceof IASTTranslationUnit) {
+            return hasSameLocation(node1, node2, fileStatic);
+        }
+        
+        String name1= getName(s1);
+        String name2= getName(s2);
+        
+        if (s1 instanceof ICPPBlockScope) {
+            if (s2 instanceof ICPPBlockScope) {
+                return hasSameLocation(node1, node2, fileStatic);
+            }
+            return FALSE;
+        }
+        if (s1 instanceof ICPPNamespaceScope) {
+            if (s2 instanceof ICPPNamespaceScope) {
+                ICPPNamespaceScope n1= (ICPPNamespaceScope) s1;
+                ICPPNamespaceScope n2= (ICPPNamespaceScope) s2;
+                int r1= hasSameLocation(node1, node2, fileStatic);
+                if (r1 == TRUE) {
+                    return r1;
+                }
+                if (!name1.equals(name2)) {
+                    return FALSE;
+                }
+                return isSameScope(n1.getParent(), n2.getParent(), fileStatic);
+            }
+            return FALSE;
+        }
+
+        if (!name1.equals(name2)) {
+            return FALSE;
+        }
+
+        // classes
+        if (s1 instanceof ICPPClassScope || s1 instanceof ICCompositeTypeScope) {
+            if (s2 instanceof ICPPClassScope || s2 instanceof ICCompositeTypeScope) {
+                return isSameScope(s1.getParent(), s2.getParent(), fileStatic);
+            }
+            return FALSE;
+        }
+        if (s1 instanceof ICPPFunctionScope) {
+            if (s2 instanceof ICPPFunctionScope) {
+                return hasSameLocation(node1, node2, true);
+            }
+            return FALSE;
+        }
+        if (s1 instanceof ICFunctionScope || s1 instanceof ICFunctionPrototypeScope
+                       || s1 instanceof ICScope) {
+            if (s2 instanceof ICFunctionScope || s2 instanceof ICFunctionPrototypeScope
+                    || s2 instanceof ICScope) {
+                return hasSameLocation(node1, node2, true);
+            }
+            return FALSE;
+        }
+        
+        return isSameScope(s1.getParent(), s2.getParent(), fileStatic);
+    }
+
+    public static String getName(IScope s1) {
+        String name= null;
+        if (s1 instanceof IIndexScope) {
+                       IIndexScope indexScope= (IIndexScope) s1;
+                       final IIndexName scopeName = indexScope.getScopeName();
+                       if (scopeName != null) {
+                               name= scopeName.toString();
+                       }
+               } else {
+                       name= getNameOrNull(ASTInternal.getPhysicalNodeOfScope(s1));
+               }
+        return name == null ? s1.toString() : name;
+    }
+
+    public static int hasSameSignature(IFunction b1, IFunction b2) throws DOMException {
+       if (b1.takesVarArgs() != b2.takesVarArgs())
+               return FALSE;
+
+        if (b1 instanceof ICPPMethod != b2 instanceof ICPPMethod) 
+               return FALSE;
+
+        return hasSameSignature(b1.getType(), b2.getType());
+    }
+
+    public static int hasSameSignature(IFunctionType b1, IFunctionType b2) throws DOMException {
+       if (b1 instanceof ICPPFunctionType && b2 instanceof ICPPFunctionType) {
+               ICPPFunctionType cppb1= (ICPPFunctionType) b1;
+               ICPPFunctionType cppb2= (ICPPFunctionType) b2;
+               if (cppb1.isConst() != cppb2.isConst())
+                       return FALSE;
+               if (cppb1.isVolatile() != cppb2.isVolatile())
+                       return FALSE;
+       }
+        return isSameParameterList(b1.getParameterTypes(), b2.getParameterTypes());
+    }        
+
+    private static int isSameParameterList(IType[] p1, IType[] p2) throws DOMException {
+        if (p1 == p2) {
+            return TRUE;
+        }
+        if (p1 == null || p2 == null) {
+            return UNKNOWN;
+        }
+        if (p1.length != p2.length) {
+            return FALSE;
+        }
+        int retval= TRUE;
+        for (int i = 0; i < p2.length; i++) {
+            switch (isSameType(p1[i], p2[i])) {
+            case FALSE:
+                return FALSE;
+            case UNKNOWN:
+                retval= UNKNOWN;
+                break;
+            }
+        }
+        
+        return retval;
+    }
+
+    private static int isSameType(IType t1, IType t2) throws DOMException {
+        if (t1 != null && t2 != null && t1.isSameType(t2)) {
+            return TRUE;
+        }
+        t1= getRealType(t1);
+        t2= getRealType(t2);
+        if (t1 == t2) {
+            return TRUE;
+        }
+        if (t1 == null || t2 == null || t1 instanceof ISemanticProblem || t2 instanceof ISemanticProblem) {
+            return UNKNOWN;
+        }
+        
+        if (t1 instanceof IArrayType) {
+            if (t2 instanceof IArrayType) {
+                IArrayType a1= (IArrayType) t1;
+                IArrayType a2= (IArrayType) t2;
+                return isSameType(a1.getType(), a2.getType());
+            }
+            return FALSE;
+        }
+        
+        if (t1 instanceof IBasicType) {
+            if (t2 instanceof IBasicType) {
+                IBasicType a1= (IBasicType) t1;
+                IBasicType a2= (IBasicType) t2;
+                if (a1.getKind() != a2.getKind()) {
+                    return FALSE;
+                }
+                if (getSigned(a1) != getSigned(a2) || a1.isUnsigned() != a2.isUnsigned()) {
+                    return FALSE;
+                }
+                if (a1.isLong() != a2.isLong() || a1.isShort() != a2.isShort()) {
+                    return FALSE;
+                }
+                return TRUE;
+            }
+            return FALSE;
+        }
+
+        if (t1 instanceof ICompositeType) {
+            if (t2 instanceof ICompositeType) {
+                ICompositeType a1= (ICompositeType) t1;
+                ICompositeType a2= (ICompositeType) t2;
+                if (a1.getKey() != a2.getKey()) {
+                    return FALSE;
+                }
+                return isSameScope(a1.getCompositeScope(), a2.getCompositeScope(), false);
+            }
+            return FALSE;
+        }
+
+        if (t1 instanceof ICPPReferenceType) {
+            if (t2 instanceof ICPPReferenceType) {
+                ICPPReferenceType a1= (ICPPReferenceType) t1;
+                ICPPReferenceType a2= (ICPPReferenceType) t2;
+                return isSameType(a1.getType(), a2.getType());
+            }
+            return FALSE;
+        }
+
+        if (t1 instanceof ICPPTemplateTypeParameter) {
+            if (t2 instanceof ICPPTemplateTypeParameter) {
+                return TRUE;
+            }
+            return FALSE;
+        }
+
+        if (t1 instanceof IEnumeration) {
+            if (t2 instanceof IEnumeration) {
+                IEnumeration a1= (IEnumeration) t1;
+                IEnumeration a2= (IEnumeration) t2;
+                
+                return isSameScope(a1.getScope(), a2.getScope(), false);
+            }
+            return FALSE;
+        }
+
+        if (t1 instanceof IFunctionType) {
+            if (t2 instanceof IFunctionType) {
+                IFunctionType a1= (IFunctionType) t1;
+                IFunctionType a2= (IFunctionType) t2;
+                return hasSameSignature(a1, a2);
+            }
+            return FALSE;
+        }
+
+        if (t1 instanceof IPointerType) {
+            if (t2 instanceof IPointerType) {
+                IPointerType a1= (IPointerType) t1;
+                IPointerType a2= (IPointerType) t2;
+                if (a1.isConst() != a2.isConst() || a1.isVolatile() != a2.isVolatile() || a1.isRestrict() != a2.isRestrict()) {
+                    return FALSE;
+                }
+                return isSameType(a1.getType(), a2.getType());
+            }
+            return FALSE;
+        }
+
+        if (t1 instanceof IQualifierType) {
+            if (t2 instanceof IQualifierType) {
+                IQualifierType a1= (IQualifierType) t1;
+                IQualifierType a2= (IQualifierType) t2;
+                if (a1.isConst() != a2.isConst() || a1.isVolatile() != a2.isVolatile()) {
+                    return FALSE;
+                }
+                return isSameType(a1.getType(), a2.getType());
+            }
+            return FALSE;
+        }
+        
+        return UNKNOWN;
+    }
+
+    private static boolean getSigned(IBasicType a2) {
+        if (a2.isSigned()) {
+            return true;
+        }
+        if (a2.isUnsigned()) {
+            return false;
+        }
+        switch (a2.getKind()) {
+        case eInt:
+        case eUnspecified:
+            return true;
+        default:
+               break;
+        }
+        return false;
+    }
+
+    private static IType getRealType(IType t) {
+        while(t instanceof ITypedef) {
+            t= ((ITypedef) t).getType();
+        }
+        return t;
+    }
+
+    private static String getNameOrNull(IASTNode node) {
+        if (node instanceof IASTDeclarator) {
+            return getSimpleName(((IASTDeclarator) node).getName()).toString();
+        }        
+        if (node instanceof IASTNamedTypeSpecifier) {
+            return getSimpleName(((IASTNamedTypeSpecifier) node).getName()).toString();
+        }
+        if (node instanceof IASTCompositeTypeSpecifier) {
+            return getSimpleName(((IASTCompositeTypeSpecifier) node).getName()).toString();
+        }
+        if (node instanceof ICPPASTNamespaceDefinition) {
+               return getSimpleName(((ICPPASTNamespaceDefinition) node).getName()).toString();
+        }
+        if (node instanceof IASTTranslationUnit) {
+            return ((IASTTranslationUnit) node).getFilePath();
+        }
+        return null;
+    }
+
+    private static int hasSameLocation(IASTNode node1, IASTNode node2, boolean fileStatic) {
+        if (node1 == null || node2 == null) {
+            return UNKNOWN;
+        }
+        if (!fileStatic && node1 instanceof IASTTranslationUnit &&
+                node2 instanceof IASTTranslationUnit) {
+            return TRUE;
+        }
+        
+        IASTFileLocation l1= node1.getNodeLocations()[0].asFileLocation();
+        IASTFileLocation l2= node2.getNodeLocations()[0].asFileLocation();
+        if (l1 == null || l2 == null) {
+            return UNKNOWN;
+        }
+        if (!l1.getFileName().equals(l2.getFileName())) {
+            return FALSE;
+        }
+        if (l1.getNodeOffset() != l2.getNodeOffset()) {
+            return FALSE;
+        }
+        if (l1.getNodeLength() != l2.getNodeLength()) {
+            return FALSE;
+        }
+        return TRUE;
+    }
+
+    private static IScope getContainingScope(IASTName name) {
+        IASTTranslationUnit tu= name.getTranslationUnit();
+        if (tu == null) {
+            return null;
+        }
+        if (tu instanceof ICPPASTTranslationUnit) {
+            return CPPVisitor.getContainingScope(name);
+        }
+        return CVisitor.getContainingScope(name);
+    }
+        
+    public static int isVirtualMethod(ICPPMethod method) throws DOMException {
+        IASTDeclaration decl= null;
+               if (method instanceof CPPMethod) {
+                       decl = ((CPPMethod) method).getPrimaryDeclaration();
+               } else if (method instanceof CPPImplicitMethod) {
+                       decl = ((CPPImplicitMethod) method).getPrimaryDeclaration();
+               }
+                       
+        IASTDeclSpecifier spec= null;
+        if (decl instanceof IASTFunctionDefinition) {
+            IASTFunctionDefinition def = (IASTFunctionDefinition) decl;
+            spec= def.getDeclSpecifier();
+        } else if (decl instanceof IASTSimpleDeclaration) {
+            IASTSimpleDeclaration sdecl = (IASTSimpleDeclaration) decl;
+            spec= sdecl.getDeclSpecifier();
+        }
+        if (spec instanceof ICPPASTDeclSpecifier) {
+            ICPPASTDeclSpecifier cppSpec = (ICPPASTDeclSpecifier) spec;
+            if (cppSpec.isVirtual()) {
+                return TRUE;
+            }
+        }
+            
+        IScope scope= method.getScope();
+        if (scope instanceof ICPPClassScope) {
+            ICPPClassScope classScope = (ICPPClassScope) scope;
+            ICPPClassType classType= classScope.getClassType();
+            ICPPBase[] bases= classType.getBases();
+            for (ICPPBase base : bases) {
+                if (!(base.getBaseClass() instanceof ICPPClassType))
+                       continue;
+                ICPPClassType baseType= (ICPPClassType) base.getBaseClass();
+                if (baseType != null) {
+                    IScope baseScope= baseType.getCompositeScope();
+                    if (baseScope != null) {
+                        IBinding[] alternates= baseScope.find(method.getName());
+                        for (IBinding binding : alternates) {
+                            if (binding instanceof CPPMethod) {
+                                CPPMethod alternateMethod = (CPPMethod) binding;
+                                if (hasSameSignature(method, alternateMethod) != FALSE) {
+                                    if (isVirtualMethod(alternateMethod) == TRUE) {
+                                        return TRUE;
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        return FALSE;
+    }
+
+    public static boolean isLocalVariable(IVariable v, IScope scope) {
+        if (v instanceof IParameter) {
+            return false;
+        }
+        while (scope != null) {
+            if (scope instanceof ICPPFunctionScope ||
+                    scope instanceof ICPPBlockScope ||
+                    scope instanceof ICFunctionScope) {
+                return true;
+            }
+            try {
+                scope= scope.getParent();
+            } catch (DOMException e) {
+                scope= null;
+            }
+        }
+        return false;
+    }
+
+    public static boolean isLocalVariable(IVariable v) {
+        try {
+            return isLocalVariable(v, v.getScope());
+        } catch (DOMException e) {
+            return false;
+        }
+    }
+
+    public static IBinding[] findInScope(final IScope scope, String name, boolean removeGlobalsWhenClassScope)
+               throws DOMException {
+        IBinding[] result= null;
+        result = scope.find(name);
+        if (result == null || result.length == 0) {
+            return result;
+        }
+        
+        // eliminate global bindings when looking up in a class type
+        if (removeGlobalsWhenClassScope &&
+                (scope instanceof ICPPClassScope || 
+                        scope instanceof ICCompositeTypeScope)) {
+            int count= 0;
+            for (int i = 0; i < result.length; i++) {
+                IBinding binding = result[i];
+                IScope bscope= binding.getScope();
+                if (! (bscope instanceof ICPPClassScope || bscope instanceof ICCompositeTypeScope)) {
+                    result[i]= null;
+                } else {
+                    count++;
+                }
+            }
+            if (count < result.length) {
+                IBinding[] copy= new IBinding[count];
+                int i=0;
+                for (IBinding b : result) {
+                    if (b != null) {
+                        copy[i++]= b;
+                    }
+                }
+                result= copy;
+            }
+        }        
+        
+        // try to find constructors
+        if (scope instanceof ICPPBlockScope) {
+            for (int i = 0; i < result.length; i++) {
+                IBinding binding = result[i];
+                if (binding instanceof ICPPClassType) {
+                    ICPPClassType classType= (ICPPClassType) binding;
+                    if (classType.getKey() == ICPPClassType.k_class) {
+                        IBinding[] cons= classType.getConstructors();
+                        if (cons.length > 0 && ! (cons[0] instanceof IProblemBinding)) {
+                            result[i]= cons[0];
+                        }
+                    }
+                }
+            }
+        }
+
+        return result;
+    }
+    
+    public ASTManager(CRefactoringArgument arg) {
+        fArgument= arg;
+    }
+
+       /**
+        * @see IDisposable#dispose()
+        */
+       public void dispose() {
+        Assert.isTrue(!fDisposed, "ASTManager.dispose() called more than once"); //$NON-NLS-1$
+               fDisposed = true;
+               if (fSharedAST != null) {
+                       ASTProvider.getASTProvider().releaseSharedAST(fSharedAST);
+               }
+       }
+
+       @Override
+       protected void finalize() throws Throwable {
+               if (!fDisposed)
+                       CUIPlugin.logError("ASTManager was not disposed"); //$NON-NLS-1$
+               super.finalize();
+       }
+
+       void analyzeArgument(IIndex index, IProgressMonitor pm, RefactoringStatus status) {
+        if (fArgument == null) {
+            return;
+        }
+         
+        if (fArgument.getArgumentKind() != CRefactory.ARGUMENT_UNKNOWN) {
+            return;
+        }
+        
+        if (fArgument.getSourceFile() == null)
+            return;
+
+        pm.beginTask(RenameMessages.ASTManager_task_analyze, 2);
+        IASTTranslationUnit tu= getTranslationUnit(index, fArgument.getSourceFile(), true, status);
+        pm.worked(1);
+        if (tu != null) {
+               final IASTNodeSelector nodeSelector = tu.getNodeSelector(tu.getFilePath());
+                       final int offset = fArgument.getOffset();
+                       final int length = fArgument.getLength();
+                       IASTName name= nodeSelector.findEnclosingName(offset, length);
+               if (name != null) {
+                       if (name instanceof ICPPASTQualifiedName) {
+                               IASTName[] na= ((ICPPASTQualifiedName) name).getNames();
+                               name= na[na.length - 1];
+                       }
+               } else {
+                       IASTNode node= nodeSelector.findEnclosingNode(offset, length);
+                       if (node instanceof IASTPreprocessorMacroDefinition ||
+                                       node instanceof IASTPreprocessorElifStatement ||
+                                       node instanceof IASTPreprocessorIfdefStatement ||
+                                       node instanceof IASTPreprocessorIfndefStatement ||
+                                       node instanceof IASTPreprocessorIfStatement) {
+                               final IASTFileLocation fileLocation = node.getFileLocation();
+                               if (fileLocation != null) {
+                                       final String ident= extractIdentifier(node.getRawSignature(),
+                                                       offset - fileLocation.getNodeOffset(), length);
+                                       if (ident != null) {
+                                               IASTPreprocessorMacroDefinition[] mdefs= tu.getMacroDefinitions();
+                                               for (IASTPreprocessorMacroDefinition mdef : mdefs) {
+                                                       IASTName n= mdef.getName();
+                                                       if (ident.equals(n.toString())) {
+                                                               name= n;
+                                                               break;
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+               if (name != null) {
+                       fArgument.setName(name);
+                       IBinding binding= name.resolveBinding();
+                       if (binding != null) {
+                               IScope scope= null;
+                               try {
+                                       scope = binding.getScope();
+                               } catch (DOMException e) {
+                                       handleDOMException(tu, e, status);
+                               }
+                               fArgument.setBinding(name.getTranslationUnit(), binding, scope);
+                       }
+               }
+        }
+        pm.worked(1);
+        pm.done();
+    }
+
+       private String extractIdentifier(String rawSignature, int offset, int length) {
+               char[] sig= rawSignature.toCharArray();
+               int end= offset + length;
+               if (offset < 0 || end > sig.length)
+                       return null;
+               
+               for (int i = offset; i < end; i++) {
+                       if (!Character.isJavaIdentifierPart(sig[i]))
+                               return null;
+               }
+               while(offset > 0) {
+                       if (Character.isJavaIdentifierPart(sig[offset-1]))
+                               offset--;
+                       else 
+                               break;
+               }
+               while(end < sig.length) {
+                       if (Character.isJavaIdentifierPart(sig[end]))
+                               end++;
+                       else
+                               break;
+               }
+               return rawSignature.substring(offset, end);
+       }
+
+       private IASTTranslationUnit getTranslationUnit(IIndex index, IFile sourceFile, boolean cacheit,
+                       RefactoringStatus status) {
+        IASTTranslationUnit ast=  fTranslationUnits.get(sourceFile);
+        if (ast == null) {
+            ICElement celem= CoreModel.getDefault().create(sourceFile);
+            if (celem instanceof ITranslationUnit) {
+               ITranslationUnit tu= CModelUtil.toWorkingCopy((ITranslationUnit) celem);
+                       if (fSharedAST != null && tu.equals(fSharedAST.getOriginatingTranslationUnit())) {
+                               ast = fSharedAST;
+                       } else {
+                       // Try to get a shared AST before creating our own.
+                       ast = ASTProvider.getASTProvider().acquireSharedAST(tu, index,
+                                       ASTProvider.WAIT_ACTIVE_ONLY, null);
+                       if (ast == null) {
+                                       try {
+                                                       ast= tu.getAST(index, PARSE_MODE);
+                                               } catch (CoreException e) {
+                                       status.addError(e.getMessage());
+                                               }
+                       if (cacheit) {
+                               fTranslationUnits.put(sourceFile, ast);
+                       }
+                       } else {
+                               if (fSharedAST != null) {
+                                       ASTProvider.getASTProvider().releaseSharedAST(fSharedAST);
+                               }
+                               fSharedAST = ast;
+                       }
+                       }
+            }
+        }
+        return ast;
+    }
+
+    public void analyzeTextMatches(IIndex index, Collection<CRefactoringMatch> matches,
+               IProgressMonitor monitor, RefactoringStatus status) {
+        CRefactoringMatchStore store= new CRefactoringMatchStore();
+        for (CRefactoringMatch match : matches) {
+            store.addMatch(match);
+        }
+        
+        int count= store.getFileCount();
+        String taskName= RenameMessages.ASTManager_task_generateAst;
+        monitor.beginTask(taskName, 2 * count);
+        monitor.setTaskName(taskName);
+
+        List<IFile> files= store.getFileList();
+        int cc= 0;
+        long now= System.currentTimeMillis();
+        long update= now;
+        for (IFile file : files) {
+            cc++;
+            if (store.contains(file)) {
+                if ((now = System.currentTimeMillis()) > update) {
+                    String nofm= nth_of_m(cc, count);
+                    String taskname= NLS.bind(RenameMessages.ASTManager_subtask_analyzing, nofm);
+                    monitor.subTask(taskname); 
+                    update= now + 1000;
+                }
+                boolean doParse= false;
+                Collection<CRefactoringMatch> fm= store.getMatchesForFile(file);
+                for (Iterator<CRefactoringMatch> iterator = fm.iterator(); !doParse && iterator.hasNext();) {
+                    CRefactoringMatch match = iterator.next();
+                    switch (match.getLocation()) {
+                    case CRefactory.OPTION_IN_COMMENT:
+                    case CRefactory.OPTION_IN_INCLUDE_DIRECTIVE:
+                    case CRefactory.OPTION_IN_STRING_LITERAL:
+                        break;
+                    default:
+                        doParse= true;
+                    }
+                }
+
+                if (doParse) {
+                    IASTTranslationUnit tu= getTranslationUnit(index, file, false, status);
+                    monitor.worked(1);
+                    analyzeTextMatchesOfTranslationUnit(tu, store, status);
+                    if (status.hasFatalError()) {
+                        return;
+                    }
+                    monitor.worked(1);
+                } else {
+                    monitor.worked(2);
+                }
+                if (monitor.isCanceled()) {
+                    throw new OperationCanceledException();
+                }
+            } else {
+                monitor.worked(2);
+            }
+        }
+        monitor.done();
+    }
+
+    private void analyzeTextMatchesOfTranslationUnit(IASTTranslationUnit tu, 
+            final CRefactoringMatchStore store, final RefactoringStatus status) {
+        fKnownBindings= new HashMap<IBinding, Integer>();
+        fConflictingBinding= new HashSet<IBinding>();
+        final Set<IPath> paths= new HashSet<IPath>();
+        boolean renamesMacro= fArgument.getArgumentKind() == CRefactory.ARGUMENT_MACRO;
+        
+        analyzeMacroMatches(tu, store, paths, status);
+        if (status.hasFatalError()) return;
+
+        if (renamesMacro) {
+            findConflictingBindingsWithNewName(tu, store, paths, status);
+            if (status.hasFatalError()) return;
+        }
+
+        analyzeLanguageMatches(tu, store, paths, status);
+        if (status.hasFatalError()) return;
+
+        for (IPath path : paths) {
+            if (path != null) {
+                store.removePath(path);
+            }
+        }
+        handleConflictingBindings(tu, status);
+        fKnownBindings= null;
+        fConflictingBinding= null;
+    }
+
+    private void analyzeLanguageMatches(IASTTranslationUnit tu, final CRefactoringMatchStore store,
+               final Set<IPath> paths, final RefactoringStatus status) {
+        ASTNameVisitor nv = new ASTSpecificNameVisitor(fArgument.getName()) {
+            @Override
+                       protected int visitName(IASTName name, boolean isDestructor) {
+                IPath path= analyzeAstMatch(name, store, isDestructor, status);
+                paths.add(path);
+                return ASTVisitor.PROCESS_CONTINUE;
+            }
+        };
+        tu.accept(nv);
+    }
+
+    private void analyzeMacroMatches(IASTTranslationUnit tu, final CRefactoringMatchStore store,
+               final Set<IPath> pathsVisited, final RefactoringStatus status) {
+        String lookfor= fArgument.getName();
+        IASTPreprocessorMacroDefinition[] mdefs= tu.getMacroDefinitions();
+        for (IASTPreprocessorMacroDefinition mdef : mdefs) {
+            IASTName macroName= mdef.getName();
+            String macroNameStr= macroName.toString();
+            if (fRenameTo.equals(macroNameStr)) {
+                status.addFatalError(NLS.bind(RenameMessages.ASTManager_error_macro_name_conflict, fRenameTo));
+                return;
+            } else if (lookfor.equals(macroNameStr)) {
+                IPath path= analyzeAstMatch(macroName, store, false, status);
+                pathsVisited.add(path);
+                IBinding macroBinding= macroName.resolveBinding();
+                if (macroBinding != null) {
+                    IASTName[] refs= tu.getReferences(macroBinding);
+                    for (IASTName ref : refs) {
+                        path= analyzeAstMatch(ref, store, false, status);
+                        pathsVisited.add(path);
+                    }
+                }
+            }
+            if (mdef instanceof IASTPreprocessorFunctionStyleMacroDefinition) {
+                boolean nameIsPar= false;
+                IASTPreprocessorFunctionStyleMacroDefinition fm= (IASTPreprocessorFunctionStyleMacroDefinition) mdef;
+                IASTFunctionStyleMacroParameter[] pars= fm.getParameters();
+                if (pars != null) {
+                    for (int j = 0; !nameIsPar && j<pars.length; j++) {
+                        IASTFunctionStyleMacroParameter par = pars[j];
+                        String name= par.getParameter();
+                        if (lookfor.equals(name)) {
+                            nameIsPar= true;
+                        }
+                    }
+                    if (nameIsPar) {
+                        IASTFileLocation floc= mdef.getNodeLocations()[0].asFileLocation();
+                        int offset= floc.getNodeOffset();
+                        int end= offset+ floc.getNodeLength();
+                        Collection<CRefactoringMatch> matches= store.findMatchesInRange(
+                                new Path(floc.getFileName()), offset, end);
+                        for (CRefactoringMatch match : matches) {
+                            match.setASTInformation(CRefactoringMatch.AST_REFERENCE_OTHER);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+//    private void markPreprocessorMatchesAsReference(
+//            IASTTranslationUnit tu, final CRefactoringMatchStore store, 
+//            final Set pathsVisited, final RefactoringStatus status) {
+//        IASTPreprocessorStatement[] pdefs= tu.getAllPreprocessorStatements();
+//        for (int i = 0; i < pdefs.length; i++) {
+//            IASTPreprocessorStatement pdef = pdefs[i];
+//            if (pdef instanceof IASTPreprocessorIfdefStatement
+//                    || pdef instanceof IASTPreprocessorIfndefStatement
+//                    || pdef instanceof IASTPreprocessorIfStatement
+//                    || pdef instanceof IASTPreprocessorElifStatement
+////                  || pdef instanceof IASTPreprocessorElseStatement
+//                    || pdef instanceof IASTPreprocessorUndefStatement) {
+//        IPath path= new Path(tu.getContainingFilename());
+//                if (!store.getMatchesForPath(path).isEmpty()) {
+//                    IASTFileLocation floc= pdef.getNodeLocations()[0].asFileLocation();
+//                    int offset= floc.getNodeOffset();
+//                    int end= offset+ floc.getNodeLength();
+//                    Collection matches= store.findMatchesInRange(
+//                            new Path(floc.getFileName()), offset, end);
+//                    for (Iterator iter = matches.iterator(); iter.hasNext();) {
+//                        CRefactoringMatch match = (CRefactoringMatch) iter.next();
+//                        match.setASTInformation(CRefactoringMatch.AST_REFERENCE);
+//                    }
+//                }
+//            }
+//        }
+//    }
+
+    private void findConflictingBindingsWithNewName(IASTTranslationUnit tu, CRefactoringMatchStore store,
+               final Set<IPath> paths, final RefactoringStatus status) {
+        ASTNameVisitor nv = new ASTSpecificNameVisitor(fRenameTo) {
+            @Override
+                       protected int visitName(IASTName name, boolean isDestructor) {
+                IPath path= addConflictingBindingForName(status, name);
+                paths.add(path);
+                return ASTVisitor.PROCESS_CONTINUE;
+            }
+        };
+        tu.accept(nv);
+    }
+
+    protected IPath addConflictingBindingForName(final RefactoringStatus status, IASTName name) {
+        IASTNodeLocation[] locations= name.getNodeLocations();
+        IPath path= null;
+        if (locations != null && locations.length == 1) {
+            IASTNodeLocation loc= locations[0];
+            IASTFileLocation floc= loc.asFileLocation();
+            if (floc != null) {
+                path= new Path(floc.getFileName());
+                IBinding binding= name.resolveBinding();
+                if (binding instanceof IProblemBinding) {
+                       handleProblemBinding(name.getTranslationUnit(), (IProblemBinding) binding, status);
+                } else if (binding != null) {
+                       fConflictingBinding.add(binding);
+                }
+            }
+        }
+        return path;
+    }
+
+    protected IPath analyzeAstMatch(IASTName name, CRefactoringMatchStore store, boolean isDestructor,
+               RefactoringStatus status) {
+        IPath path= null;
+        CRefactoringMatch match= null;
+        
+        IASTFileLocation loc = getImageFileLocation(name);
+        if (loc != null) {
+               path= new Path(loc.getFileName());
+               match= store.findMatch(path, loc.getNodeOffset() + (isDestructor ? 1 : 0));
+               if (match != null) {
+                       analyzeAstTextMatchPair(match, name, status);
+               }
+        }
+        return path;
+    }
+
+       static IASTFileLocation getImageFileLocation(IASTName name) {
+               return name.getImageLocation();
+       }
+
+    private void analyzeAstTextMatchPair(CRefactoringMatch match, IASTName name, RefactoringStatus status) {
+        IBinding binding= name.resolveBinding();
+        int cmp= FALSE;
+        Integer cmpObj= fKnownBindings.get(binding);
+        if (cmpObj != null) {
+            cmp= cmpObj.intValue();
+        } else if (binding instanceof IProblemBinding) {
+            cmp= UNKNOWN;
+            handleProblemBinding(name.getTranslationUnit(), (IProblemBinding) binding, status);
+        } else {
+               // check whether a qualifier has a problem binding
+               boolean problemInQualifier= false;
+               IASTNode parent= name.getParent();
+               if (parent instanceof ICPPASTQualifiedName) {
+                       IASTName[] names= ((ICPPASTQualifiedName) parent).getNames();
+                       for (IASTName n : names) {
+                                       if (n == name)
+                                               break;
+                                       final IBinding b = n.resolveBinding();
+                                       if (b instanceof IProblemBinding) {
+                                               handleProblemBinding(name.getTranslationUnit(), (IProblemBinding) b, status);
+                                               problemInQualifier= true;
+                                               break;
+                                       }
+                               }
+               }
+               if (problemInQualifier) {
+                       cmp= UNKNOWN;
+               } else {
+                       for (IBinding renameBinding : fValidBindings) {
+                               try {
+                                       int cmp0= isSameBinding(binding, renameBinding);
+                                       if (cmp0 != FALSE) {
+                                               cmp= cmp0;
+                                       }
+                                       if (cmp0 == TRUE) {
+                                               break;
+                                       }
+                               } catch (DOMException e) {
+                                       handleDOMException(name.getTranslationUnit(), e, status);
+                                       cmp= UNKNOWN;
+                               }
+                       }
+               }
+            fKnownBindings.put(binding, new Integer(cmp));
+        }
+        switch (cmp) {
+        case TRUE:
+            match.setASTInformation(CRefactoringMatch.AST_REFERENCE);
+            if (fRenameTo != null) {
+                IScope scope= getContainingScope(name);
+                if (scope != null) {
+                    IBinding[] conflicting= null;
+                    try {
+                        conflicting= findInScope(scope, fRenameTo, true);
+                    } catch (Exception e) {
+                       CUIPlugin.log(e);
+                    }
+                    if (conflicting != null && conflicting.length > 0) {
+                        fConflictingBinding.addAll(Arrays.asList(conflicting));
+                    }
+                }
+            }
+            break;
+        case FALSE:
+            match.setASTInformation(CRefactoringMatch.AST_REFERENCE_OTHER);
+            break;
+        }
+    }
+
+    public void handleDOMException(IASTTranslationUnit tu, final DOMException e, RefactoringStatus status) {
+        handleProblemBinding(tu, e.getProblem(), status);
+    }
+
+    public void handleProblemBinding(IASTTranslationUnit tu, final IProblemBinding pb,
+               RefactoringStatus status) {
+        if (tu != null) {
+            String fpath= tu.getFilePath();
+            if (fProblemUnits.add(fpath)) {
+                String msg= pb.getMessage();
+                if (msg != null && msg.length() > 0) {
+                    msg= NLS.bind(RenameMessages.ASTManager_warning_parsingError_detailed, msg);
+                } else {
+                    msg= RenameMessages.ASTManager_warning_parsingError;
+                }
+                int line= pb.getLineNumber();
+                if (line >= 1) {
+                    msg= NLS.bind(RenameMessages.ASTManager_warning_parsingError_withFileAndLine,
+                               new Object[] { msg, fpath, line });
+                } else {
+                    msg= NLS.bind(RenameMessages.ASTManager_warning_parsingError_withFile, msg, fpath);
+                }
+                status.addWarning(msg);
+            }
+        }
+    }
+
+       @SuppressWarnings("unchecked")
+       protected void handleConflictingBindings(IASTTranslationUnit tu, RefactoringStatus status) {   
+        if (fConflictingBinding.isEmpty()) {
+            return;
+        }
+        
+        int argKind= fArgument.getArgumentKind();
+        boolean isVarParEnumerator= false;
+        boolean isLocalVarPar= false;
+        boolean isFunction= false;
+        boolean isContainer = false;
+        boolean isMacro= false;
+
+        switch (argKind) {
+        case CRefactory.ARGUMENT_LOCAL_VAR:  
+        case CRefactory.ARGUMENT_PARAMETER:
+            isLocalVarPar= true;
+            isVarParEnumerator= true;
+            break;
+        case CRefactory.ARGUMENT_FILE_LOCAL_VAR:    
+        case CRefactory.ARGUMENT_GLOBAL_VAR:
+        case CRefactory.ARGUMENT_FIELD:     
+        case CRefactory.ARGUMENT_ENUMERATOR:         
+            isVarParEnumerator= true;
+            break;
+        case CRefactory.ARGUMENT_FILE_LOCAL_FUNCTION:
+        case CRefactory.ARGUMENT_GLOBAL_FUNCTION:
+        case CRefactory.ARGUMENT_VIRTUAL_METHOD:     
+        case CRefactory.ARGUMENT_NON_VIRTUAL_METHOD:
+            isFunction= true;
+            break;
+        case CRefactory.ARGUMENT_TYPE:
+        case CRefactory.ARGUMENT_CLASS_TYPE:
+        case CRefactory.ARGUMENT_NAMESPACE:
+            isContainer = true;
+            break;
+        case CRefactory.ARGUMENT_MACRO:      
+            isMacro= true;
+            break;
+        case CRefactory.ARGUMENT_INCLUDE_DIRECTIVE:  
+            break;
+        }
+        
+        Collection<IBinding>[] cflc=
+                       new Collection[] { new HashSet<IBinding>(), new ArrayList<IBinding>(),
+                                         new ArrayList<IBinding>() };
+        String[] errs= null;
+        if (isMacro) {
+            errs= new String[] { RenameMessages.CRenameLocalProcessor_error_conflict };
+            cflc[0]= fConflictingBinding;
+        } else {
+            errs= new String[] {
+                    RenameMessages.CRenameLocalProcessor_error_shadow,
+                    RenameMessages.CRenameLocalProcessor_error_redeclare,
+                    RenameMessages.CRenameLocalProcessor_error_isShadowed,
+                    RenameMessages.CRenameLocalProcessor_error_overloads };
+            classifyConflictingBindings(tu, (Set<IBinding>) cflc[0], (List<IBinding>) cflc[1],
+                               (List<IBinding>) cflc[2], status);
+        }
+        
+        for (int i = 0; i < 3; i++) {
+            Collection<?> coll= cflc[i];
+            for (Object name : coll) {
+                boolean warn= false;
+                String msg= errs[i];
+                IBinding conflict = (IBinding) name;
+                String what= null;
+                if (conflict instanceof IEnumerator) {
+                    if (isVarParEnumerator || isFunction || isMacro) {
+                        what= RenameMessages.CRenameLocalProcessor_enumerator;
+                    }
+                } else if (conflict instanceof ICPPField) {
+                    if (isVarParEnumerator || isFunction || isMacro) {
+                        what= RenameMessages.CRenameLocalProcessor_field;
+                    }
+                } else if (conflict instanceof IParameter) {
+                    if (isVarParEnumerator || isFunction || isMacro) {
+                        if (i == 1 && argKind == CRefactory.ARGUMENT_LOCAL_VAR) {
+                            msg= errs[0];
+                        }
+                        what= RenameMessages.CRenameLocalProcessor_parameter;
+                    }
+                } else if (conflict instanceof IVariable) {
+                    if (isVarParEnumerator || isFunction || isMacro) {
+                        IVariable conflictingVar= (IVariable) conflict;
+                        what= RenameMessages.CRenameLocalProcessor_globalVariable;
+                        if (ASTManager.isLocalVariable(conflictingVar)) {
+                            if (i == 1 && argKind == CRefactory.ARGUMENT_PARAMETER) {
+                                msg= errs[2];
+                            }
+                            what= RenameMessages.CRenameLocalProcessor_localVariable;
+                        } else {
+                            if (conflictingVar.isStatic()) {
+                                                           what= RenameMessages.CRenameProcessorDelegate_fileStaticVariable;
+                                                       }
+                        }
+                    }
+                } else if (conflict instanceof ICPPConstructor) {
+                    if (isVarParEnumerator || isFunction || isMacro) {
+                        what= RenameMessages.CRenameLocalProcessor_constructor;
+                    }
+                } else if (conflict instanceof ICPPMethod) {
+                    if (isVarParEnumerator || isFunction || isMacro) {
+                        if (i == 1) {
+                            IBinding r= fArgument.getBinding();
+                            if (r instanceof ICPPMethod) {
+                                try {
+                                    if (ASTManager.hasSameSignature((ICPPMethod) r, 
+                                            (ICPPMethod) conflict) == ASTManager.FALSE) {
+                                        msg= errs[3];
+                                        warn= true;
+                                    }
+                                } catch (DOMException e) {
+                                }
+                            }
+                        }
+                        what= RenameMessages.CRenameLocalProcessor_method;
+                    }
+                } else if (conflict instanceof IFunction) {
+                    if (isVarParEnumerator || isFunction || isMacro) {
+                        boolean ignore= false;
+                        if (isLocalVarPar) {
+                            IASTName[] refs= 
+                                fArgument.getTranslationUnit().getReferences(conflict);
+                            if (refs == null || refs.length == 0) {
+                                ignore= true;
+                            }
+                        }
+                        if (!ignore) {
+                            IFunction conflictingFunction= (IFunction) conflict;
+                            if (i == 1 && conflict instanceof ICPPFunction) {
+                                IBinding r= fArgument.getBinding();
+                                if (r instanceof ICPPFunction) {
+                                    try {
+                                        if (ASTManager.hasSameSignature((ICPPFunction) r, 
+                                                conflictingFunction) == ASTManager.FALSE) {
+                                            msg= errs[3];
+                                            warn= true;
+                                        }
+                                    } catch (DOMException e) {
+                                    }
+                                }
+                            }
+
+                            boolean isStatic= conflictingFunction.isStatic();
+                            if (isStatic) {
+                                what= RenameMessages.CRenameProcessorDelegate_fileStaticFunction;
+                            } else {
+                                what= RenameMessages.CRenameProcessorDelegate_globalFunction;
+                            }
+                        }
+                    }
+                } else if (conflict instanceof ICompositeType ||
+                        conflict instanceof IEnumeration ||
+                        conflict instanceof ITypedef) {
+                    if (isContainer || isMacro) {
+                        what= RenameMessages.CRenameProcessorDelegate_type;
+                    }
+                } else if (conflict instanceof ICPPNamespace) {
+                    if (isContainer || isMacro) {
+                        what= RenameMessages.CRenameProcessorDelegate_namespace;
+                        if (argKind == CRefactory.ARGUMENT_NAMESPACE) {
+                            warn= true;
+                        }
+                    }
+                }
+                if (what != null) {
+                       String message = RenameMessages.CRenameLocalProcessor_error_message;
+                       String message1 = NLS.bind(RenameMessages.CRenameLocalProcessor_error_message1, msg);
+                       String message2 = NLS.bind(RenameMessages.CRenameLocalProcessor_error_message2, conflict.getName());
+                       String message3 = NLS.bind(RenameMessages.CRenameLocalProcessor_error_message3, what);
+                       String space = "  \n"; //$NON-NLS-1$
+                       String formatted = message + space + message1 + space + message2 + space +  message3;
+                    RefactoringStatusEntry[] entries= status.getEntries();
+                    for (RefactoringStatusEntry entry : entries) {
+                        if (formatted.equals(entry.getMessage())) {
+                            formatted= null;
+                            break;
+                        }
+                    }
+                    if (formatted != null) {
+                        if (warn) {
+                            status.addWarning(formatted);
+                        } else {
+                            status.addError(formatted);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    protected void classifyConflictingBindings(IASTTranslationUnit tu, Set<IBinding> shadows,
+               Collection<IBinding> redecl, Collection<IBinding> barriers, RefactoringStatus status) {
+        // collect bindings on higher or equal level
+        String name= fArgument.getName();
+        IBinding[] newBindingsAboverOrEqual= null;
+        IScope oldBindingsScope= null;
+        for (Map.Entry<IBinding, Integer> entry : fKnownBindings.entrySet()) {
+            IBinding oldBinding= entry.getKey();
+            Integer value= entry.getValue();
+            if (value.intValue() == TRUE && oldBinding.getName().equals(name)) {
+                try {
+                    oldBindingsScope = oldBinding.getScope();
+                    if (oldBindingsScope != null) {
+                        newBindingsAboverOrEqual = ASTManager.findInScope(oldBindingsScope, fRenameTo, false);
+                    }
+                } catch (DOMException e) {
+                    handleDOMException(tu, e, status);
+                }
+            }            
+
+            if (newBindingsAboverOrEqual != null && newBindingsAboverOrEqual.length>0) {
+                break;
+            }
+        }
+        if (newBindingsAboverOrEqual == null) {
+            newBindingsAboverOrEqual= new IBinding[0];
+        }
+        
+        // check conflicting bindings for being from above or equal level.
+        for (IBinding conflictingBinding : fConflictingBinding) {
+            if (conflictingBinding != null) {
+                boolean isAboveOrEqual= false;
+                for (int i = 0; !isAboveOrEqual && i<newBindingsAboverOrEqual.length; i++) {
+                    IBinding aboveBinding = newBindingsAboverOrEqual[i];
+                    try {
+                        if (isSameBinding(aboveBinding, conflictingBinding) == TRUE) {
+                            isAboveOrEqual= true;
+                        }
+                    } catch (DOMException e) {
+                        handleDOMException(tu, e, status);
+                    }
+                }
+                if (!isAboveOrEqual) {
+                    barriers.add(conflictingBinding);
+                }
+            }
+        }
+
+        // find bindings on same level
+        for (IBinding aboveBinding : newBindingsAboverOrEqual) {
+            IScope aboveScope;
+            try {
+                aboveScope = aboveBinding.getScope();
+                if (isSameScope(aboveScope, oldBindingsScope, false) == TRUE) {
+                    redecl.add(aboveBinding);
+                } else {
+                    shadows.add(aboveBinding);
+                }
+            } catch (DOMException e) {
+                handleDOMException(tu, e, status);
+            }
+        }
+    }
+
+    public void setValidBindings(IBinding[] validBindings) {
+        fValidBindings= validBindings;
+    }
+
+    public void setRenameTo(String renameTo) {
+        fRenameTo= renameTo;
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTNameVisitor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTNameVisitor.java
new file mode 100644 (file)
index 0000000..2c53ee2
--- /dev/null
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 Wind River Systems, Inc.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *    Markus Schorn - initial API and implementation 
+ ******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+
+/**
+ * Visitor to prefer simple ASTNames over the qualified ones. This is different
+ * to the strategy used within the dom-package. 
+ */
+abstract public class ASTNameVisitor extends ASTVisitor {
+    private int fOffset= -1;
+    private String fFileName;
+
+    public ASTNameVisitor(String fileName) {
+        this(fileName, -1);
+    }
+    
+    public ASTNameVisitor(String fileName, int offset) {
+        fFileName= fileName;
+        fOffset= offset;
+        shouldVisitNames=true;
+    }
+    
+    abstract protected int visitName(IASTName name);
+    
+    @Override
+       final public int visit(IASTName name) {
+        if (name instanceof ICPPASTQualifiedName) {
+            ICPPASTQualifiedName qn= (ICPPASTQualifiedName) name;
+            IASTName[] names= qn.getNames();
+            boolean visited= false;
+            for (int i = 0; i < names.length; i++) {
+                if (checkLocation(names[i])) {
+                    if (visitName(names[i]) == PROCESS_ABORT) {
+                        return PROCESS_ABORT;
+                    }
+                    visited= true;
+                }
+            }
+            if (!visited && names.length>0) {
+                if (checkLocation(name)) {
+                    return visitName(names[names.length-1]);
+                }
+            }
+        }
+        else if (checkLocation(name)) {
+            return visitName(name);
+        }
+        return PROCESS_CONTINUE;
+    }
+        
+    private boolean checkLocation(IASTNode node) {
+        if (fFileName==null) {
+            return true;
+        }
+        if (!fFileName.equals(node.getContainingFilename())) {
+            return false;
+        }
+        IASTFileLocation loc= null;
+        if (node instanceof IASTName) {
+               loc= ASTManager.getImageFileLocation((IASTName) node);
+        }
+        else {
+            IASTNodeLocation[] locs= node.getNodeLocations();
+            if (locs!=null && locs.length==1) {
+               if (locs[0] instanceof IASTFileLocation) {
+                       loc= (IASTFileLocation) locs[0];
+               }
+            }
+        }
+        if (loc==null) {
+            return false;
+        }
+        if (fOffset==-1) {
+            return true;
+        }
+        int off= loc.getNodeOffset();
+        int len = loc.getNodeLength();
+        return off <= fOffset && fOffset < off+len;
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTSpecificNameVisitor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTSpecificNameVisitor.java
new file mode 100644 (file)
index 0000000..19bc167
--- /dev/null
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 Wind River Systems, Inc.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ * Markus Schorn - initial API and implementation 
+ ******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
+
+public abstract class ASTSpecificNameVisitor extends ASTNameVisitor {
+    private String fSearchForName;
+
+    public ASTSpecificNameVisitor(String name) {
+        super(null);
+        fSearchForName= name;
+    }
+    
+    @Override
+       final public int visitName(IASTName name) {
+       if (name instanceof ICPPASTTemplateId || name instanceof ICPPASTQualifiedName)
+               return PROCESS_CONTINUE;
+       
+        String nameStr= name.toString();
+        if (nameStr != null) {
+            final int len= nameStr.length();
+            final int searchForLen= fSearchForName.length();
+            if (len == searchForLen) {
+                if (nameStr.equals(fSearchForName)) {
+                    return visitName(name, false);
+                }
+            } else if (len == searchForLen + 1) {
+                if (nameStr.charAt(0) == '~' && nameStr.endsWith(fSearchForName)) {
+                    return visitName(name, true);
+                }
+            }
+        }
+        return ASTVisitor.PROCESS_CONTINUE;
+    }
+
+    protected abstract int visitName(IASTName name, boolean isDestructor);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringArgument.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringArgument.java
new file mode 100644 (file)
index 0000000..96e57d0
--- /dev/null
@@ -0,0 +1,172 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *    Markus Schorn - initial API and implementation 
+ ******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+import org.eclipse.core.resources.IFile;
+
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.ICompositeType;
+import org.eclipse.cdt.core.dom.ast.IEnumeration;
+import org.eclipse.cdt.core.dom.ast.IEnumerator;
+import org.eclipse.cdt.core.dom.ast.IField;
+import org.eclipse.cdt.core.dom.ast.IFunction;
+import org.eclipse.cdt.core.dom.ast.IMacroBinding;
+import org.eclipse.cdt.core.dom.ast.IParameter;
+import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.core.dom.ast.ITypedef;
+import org.eclipse.cdt.core.dom.ast.IVariable;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ISourceRange;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * Represents the input to a refactoring. Important is file and offset the rest
+ * can be calculated from the AST.
+ */
+public class CRefactoringArgument {
+    private int fOffset= 0;
+    private int fLength= 0;
+    private String fText= ""; //$NON-NLS-1$
+    private int fKind= CRefactory.ARGUMENT_UNKNOWN;
+    private IFile fFile;
+    
+    private IBinding fBinding;
+    private IScope fScope;
+    private IASTTranslationUnit fTranslationUnit;
+
+    public CRefactoringArgument(IFile file, int offset, int length) {
+        fKind= CRefactory.ARGUMENT_UNKNOWN;
+        fFile= file;
+        fOffset= offset;
+        fLength= length;
+    }
+    
+    public CRefactoringArgument(ICElement elem) {
+        fKind= CRefactory.ARGUMENT_UNKNOWN;
+        if (elem instanceof ISourceReference) {
+               ISourceReference sref= (ISourceReference) elem;
+               ISourceRange sr;
+                       try {
+                               sr = sref.getSourceRange();
+                       fFile= (IFile) sref.getTranslationUnit().getResource();
+                       fOffset= sr.getIdStartPos();
+                       fLength= sr.getIdLength();
+                       } catch (CModelException e) {
+                               CUIPlugin.log(e);
+                       }
+        }
+    }
+        
+    // overrider
+    public String getName() {
+        return fText;
+    }
+
+    // overrider
+    public IFile getSourceFile() {
+        return fFile;
+    }
+
+    // overrider
+    public int getArgumentKind() {
+        return fKind;
+    }
+
+    // overrider
+    public int getOffset() {
+        return fOffset;
+    }
+    
+    public int getLength() {
+       return fLength;
+    }
+
+    public void setName(IASTName name) {
+        fText= name.toString();
+    }
+    
+    public void setBinding(IASTTranslationUnit tu, IBinding binding, IScope scope) {
+        fTranslationUnit= tu;
+        fBinding= binding;
+        fScope= scope;
+        if (binding instanceof IVariable) {
+            IVariable var= (IVariable) binding;
+            if (binding instanceof IField) {
+                fKind= CRefactory.ARGUMENT_FIELD;
+            } else if (binding instanceof IParameter) {
+                fKind= CRefactory.ARGUMENT_PARAMETER;
+            } else {
+                if (ASTManager.isLocalVariable(var, scope)) {
+                    fKind= CRefactory.ARGUMENT_LOCAL_VAR;
+                } else {
+                    boolean isStatic= false;
+                    isStatic= var.isStatic();
+                    if (isStatic) {
+                        fKind= CRefactory.ARGUMENT_FILE_LOCAL_VAR;
+                    } else {
+                        fKind= CRefactory.ARGUMENT_GLOBAL_VAR;
+                    }
+                }
+            }
+        } else if (binding instanceof IEnumerator) {
+            fKind= CRefactory.ARGUMENT_ENUMERATOR;
+        } else if (binding instanceof IFunction) {
+            fKind= CRefactory.ARGUMENT_NON_VIRTUAL_METHOD;
+            IFunction func= (IFunction) binding;
+            if (binding instanceof ICPPMethod) {
+                ICPPMethod method= (ICPPMethod) binding;
+                int isVirtual= ASTManager.UNKNOWN;
+                try {
+                    isVirtual = ASTManager.isVirtualMethod(method);
+                } catch (DOMException e) {
+                }
+                if (isVirtual == ASTManager.TRUE) {
+                    fKind= CRefactory.ARGUMENT_VIRTUAL_METHOD;
+                }
+            } else {
+                boolean isStatic= false;
+                isStatic= func.isStatic();
+                if (isStatic) {
+                    fKind= CRefactory.ARGUMENT_FILE_LOCAL_FUNCTION;
+                } else {
+                    fKind= CRefactory.ARGUMENT_GLOBAL_FUNCTION;
+                }
+            }
+        } else if (binding instanceof ICompositeType) {
+            fKind= CRefactory.ARGUMENT_CLASS_TYPE;
+        } else if (binding instanceof IEnumeration || binding instanceof ITypedef) {
+            fKind= CRefactory.ARGUMENT_TYPE;
+        } else if (binding instanceof ICPPNamespace) {
+            fKind= CRefactory.ARGUMENT_NAMESPACE;
+        } else if (binding instanceof IMacroBinding) {
+            fKind= CRefactory.ARGUMENT_MACRO;
+        }
+    }
+
+    public IScope getScope() {
+        return fScope;
+    }
+
+    public IBinding getBinding() {
+        return fBinding;
+    }
+
+    public IASTTranslationUnit getTranslationUnit() {
+        return fTranslationUnit;
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatch.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatch.java
new file mode 100644 (file)
index 0000000..63cc8de
--- /dev/null
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *    Markus Schorn - initial API and implementation 
+ ******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+import org.eclipse.core.resources.IFile;
+
+/**
+ * A refactoring match initially is a plain text match. In the course of refactoring
+ * it will be classified with a location (comment, code, ...) and with the information
+ * whether it has been verified via AST or not.
+ */
+public class CRefactoringMatch {
+    public static final int POTENTIAL= 0;
+    public static final int AST_REFERENCE= 1;
+    public static final int AST_REFERENCE_OTHER= 2;
+    public static final int AST_REFEREENCE_CONFLICTING= 3;
+    public static final int IN_COMMENT = 4;
+    
+    private static String[] LABELS= {
+        RenameMessages.CRefactoringMatch_label_potentialOccurrence,
+        RenameMessages.CRefactoringMatch_label_occurrence,
+        "", //$NON-NLS-1$
+        RenameMessages.CRefactoringMatch_label_potentialOccurrence,
+        RenameMessages.CRefactoringMatch_label_comment };
+    
+    private IFile fFile;
+    private int fOffset;
+    private int fLength;
+    private int fLocation;
+    private int fAstInformation= 0;
+
+    public int getAstInformation() {
+        return fAstInformation;
+    }
+    
+    public CRefactoringMatch(IFile file, int offset, int length, int location) {
+        fFile= file;
+        fOffset= offset;
+        fLength= length;
+        fLocation= location;
+    }
+    public int getOffset() {
+        return fOffset;
+    }
+    public void setLocation(int location) {
+        fLocation= location;   
+    }
+    public int getLocation() {
+        return fLocation;   
+    }
+    public int getLength() {
+        return fLength;
+    }
+    public IFile getFile() {
+        return fFile;
+    }
+    public void setASTInformation(int val) {
+       switch(fAstInformation) {
+       case AST_REFERENCE:
+       case AST_REFERENCE_OTHER:
+       case AST_REFEREENCE_CONFLICTING:
+               if (val != fAstInformation) {
+                       fAstInformation= AST_REFEREENCE_CONFLICTING;
+               }
+               break;
+       default:
+            fAstInformation= val;
+               break;
+       }
+    }
+    public String getLabel() {
+        if (fAstInformation == AST_REFERENCE) {
+            return LABELS[AST_REFERENCE];
+        }
+        if (isInComment()) {
+            return LABELS[IN_COMMENT];
+        }
+        return LABELS[POTENTIAL];
+    }
+
+    public boolean isInComment() {
+        return (fLocation & CRefactory.OPTION_IN_COMMENT) != 0;
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatchStore.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatchStore.java
new file mode 100644 (file)
index 0000000..7caeed0
--- /dev/null
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ * Markus Schorn - initial API and implementation 
+ ******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
+
+public class CRefactoringMatchStore {
+    private Map<IFile, IPath> fFileToPathMap= new HashMap<IFile, IPath>();
+    private Map<IPath, SortedMap<CRefactoringMatch, CRefactoringMatch>> fPathToMatches= new HashMap<IPath, SortedMap<CRefactoringMatch, CRefactoringMatch>>();
+    private Comparator<CRefactoringMatch> fOffsetComparator;
+
+    public CRefactoringMatchStore() {
+        fOffsetComparator= new Comparator<CRefactoringMatch>() {
+            public int compare(CRefactoringMatch o1, CRefactoringMatch o2) {
+                return o1.getOffset() - o2.getOffset();
+            }
+        };
+    }
+    
+    public void addMatch(CRefactoringMatch match) {
+        IPath path= resolvePath(match.getFile());
+        if (path != null) {
+            Map<CRefactoringMatch, CRefactoringMatch> matchesForPath= getMapForPath(path, true);
+            matchesForPath.put(match, match);
+        }
+    }
+        
+    private Map<CRefactoringMatch, CRefactoringMatch> getMapForPath(IPath path, boolean create) {
+        SortedMap<CRefactoringMatch, CRefactoringMatch> map= fPathToMatches.get(path);
+        if (map == null && create) {
+            map= new TreeMap<CRefactoringMatch, CRefactoringMatch>(fOffsetComparator);
+            fPathToMatches.put(path, map);
+        }
+        return map;
+    }
+
+    private IPath resolvePath(IFile file) {
+        IPath path= fFileToPathMap.get(file);
+        if (path == null) {
+            path= file.getLocation();
+            if (path == null) {
+                path= file.getFullPath();
+            }
+            fFileToPathMap.put(file, path);
+        }
+        return path;
+    }
+
+    public int getFileCount() {
+        return fFileToPathMap.size();
+    }
+
+    public List<IFile> getFileList() {
+        return new ArrayList<IFile>(fFileToPathMap.keySet());
+    }
+
+    public boolean contains(IResource file) {
+        return fFileToPathMap.containsKey(file);
+    }
+
+    public Collection<CRefactoringMatch> getMatchesForFile(IResource file) {
+        return getMatchesForPath(fFileToPathMap.get(file));
+    }
+
+    public Collection<CRefactoringMatch> getMatchesForPath(IPath path) {
+        if (path != null) {
+            Map<CRefactoringMatch, CRefactoringMatch> map= fPathToMatches.get(path);
+            if (map != null) {
+                return map.keySet();
+            }
+        }
+        return Collections.emptySet();
+    }
+
+    public CRefactoringMatch findMatch(IPath path, int nodeOffset) {
+        Map<CRefactoringMatch, CRefactoringMatch> map= fPathToMatches.get(path);
+        if (map != null) {
+            return map.get(new CRefactoringMatch(null, nodeOffset, 0, 0));
+        }
+        return null;
+    }
+
+    public void removePath(IPath path) {
+        Map<CRefactoringMatch, CRefactoringMatch> map= fPathToMatches.remove(path);
+        if (map != null && !map.isEmpty()) {
+            IFile file= (map.values().iterator().next()).getFile();
+            fFileToPathMap.remove(file);
+        }
+    }
+
+    public Collection<CRefactoringMatch> findMatchesInRange(Path path, int offset, int end) {
+        if (path != null) {
+            SortedMap<CRefactoringMatch, CRefactoringMatch> map= fPathToMatches.get(path);
+            if (map != null) {
+                return map.subMap(new CRefactoringMatch(null, offset, 0, 0),
+                        new CRefactoringMatch(null, end, 0, 0)).keySet();
+            }
+        }
+        return Collections.emptySet();
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringUtils.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringUtils.java
new file mode 100644 (file)
index 0000000..a608964
--- /dev/null
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *    Markus Schorn - initial API and implementation 
+ ******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+/**
+ * Collects some basic functionality.
+ */
+public class CRefactoringUtils {
+
+    public static boolean isIdentifierChar(char c) {
+        return isLeadingIdentifierChar(c) || ('0'<=c && c<='9');
+    }
+
+    public static boolean isLeadingIdentifierChar(char c) {
+        return ('A'<=c && c<='Z') || ('a'<=c && c<='z') || c=='_';
+    }
+
+    public static boolean checkIdentifier(String id) {
+        if (id.length() == 0) {
+            return false;
+        }
+        if (!isLeadingIdentifierChar(id.charAt(0))) {
+            return false;
+        }
+        for (int i= 1; i < id.length(); i++) {
+            if (!isIdentifierChar(id.charAt(i))) {
+                return false;
+            }
+        }
+        return true;
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactory.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactory.java
new file mode 100644 (file)
index 0000000..e0514e8
--- /dev/null
@@ -0,0 +1,183 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *    Markus Schorn - initial API and implementation
+ *    Sergey Prigogin (Google)
+ ******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.ide.IDE;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.refactoring.RefactoringStarter;
+
+/**
+ * Serves to launch the various refactorings.
+ */
+public class CRefactory {
+    public static final int OPTION_ASK_SCOPE                                   = 0x01;
+    public static final int OPTION_IN_COMMENT                                  = 0x02;
+    public static final int OPTION_IN_STRING_LITERAL                   = 0x04;
+    public static final int OPTION_IN_INCLUDE_DIRECTIVE                = 0x08;
+    public static final int OPTION_IN_MACRO_DEFINITION                         = 0x10;
+    public static final int OPTION_IN_PREPROCESSOR_DIRECTIVE   = 0x20;
+    public static final int OPTION_IN_INACTIVE_CODE                    = 0x40;
+    public static final int OPTION_IN_CODE                                             = 0x80;
+    public static final int OPTION_DO_VIRTUAL                                  = 0x100;
+    public static final int OPTION_EXHAUSTIVE_FILE_SEARCH              = 0x200;
+
+    public static final int ARGUMENT_UNKNOWN                           =  0;
+    public static final int ARGUMENT_LOCAL_VAR                         =  1;
+    public static final int ARGUMENT_PARAMETER                                 =  2;
+    public static final int ARGUMENT_FILE_LOCAL_VAR            =  3;
+    public static final int ARGUMENT_GLOBAL_VAR                        =  4;
+    public static final int ARGUMENT_FIELD                                     =  5;
+    public static final int ARGUMENT_FILE_LOCAL_FUNCTION       =  6;
+    public static final int ARGUMENT_GLOBAL_FUNCTION           =  7;
+    public static final int ARGUMENT_VIRTUAL_METHOD            =  8;
+    public static final int ARGUMENT_NON_VIRTUAL_METHOD        =  9;
+    public static final int ARGUMENT_TYPE                                      = 10;
+    public static final int ARGUMENT_MACRO                                     = 11;
+    public static final int ARGUMENT_INCLUDE_DIRECTIVE                 = 12;
+    public static final int ARGUMENT_ENUMERATOR             = 13;
+    public static final int ARGUMENT_CLASS_TYPE             = 14;
+    public static final int ARGUMENT_NAMESPACE              = 15;
+    
+    private static CRefactory sInstance= new CRefactory();
+    private TextSearchWrapper fTextSearch;
+    
+    public static CRefactory getInstance() {
+        return sInstance;
+    }
+    
+    private CRefactory() {
+    }
+    
+    // Runs the rename refactoring.
+    public void rename(Shell shell, ICElement arg) {
+        if (!IDE.saveAllEditors(new IResource[] { ResourcesPlugin.getWorkspace().getRoot() }, false)) {
+            return;
+        }
+        CRefactoringArgument iarg= new CRefactoringArgument(arg);
+        final CRenameProcessor processor = new CRenameProcessor(this, iarg);
+               CRenameRefactoring refactoring= new CRenameRefactoring(processor);
+        openDialog(shell, refactoring, false);
+    }
+    
+       public void rename(Shell shell, IWorkingCopy workingCopy, ITextSelection selection) {
+        IResource res= workingCopy.getResource();
+        if (!(res instanceof IFile)) {
+               return;
+        }
+        if (!IDE.saveAllEditors(new IResource[] { ResourcesPlugin.getWorkspace().getRoot() }, false)) {
+            return;
+        }
+        CRefactoringArgument iarg=
+               new CRefactoringArgument((IFile) res, selection.getOffset(), selection.getLength());
+        final CRenameProcessor processor = new CRenameProcessor(this, iarg);
+               CRenameRefactoring refactoring= new CRenameRefactoring(processor);
+        openDialog(shell, refactoring, false);
+       }
+
+       /**
+        * Opens the refactoring dialog.
+        *
+        * <p>
+        * This method has to be called from within the UI thread.
+        * </p>
+        *
+        * @param shell a shell used as a parent for the refactoring, preview, or error dialog
+        * @param showPreviewOnly if <code>true</code>, the dialog skips all user input pages and
+        * directly shows the preview or error page. Otherwise, shows all pages.
+        * @return <code>true</code> if the refactoring has been executed successfully,
+        * or <code>false</code> if it has been canceled.
+        */
+       static boolean openDialog(Shell shell, CRenameRefactoring refactoring, boolean showPreviewOnly) {
+               try {
+               CRenameRefactoringWizard wizard;
+               if (!showPreviewOnly) {
+                       wizard = new CRenameRefactoringWizard(refactoring);
+               } else {
+                       wizard = new CRenameRefactoringWizard(refactoring) {
+                               @Override
+                                       protected void addUserInputPages() {
+                                       // nothing to add
+                               }
+                       };
+                       wizard.setForcePreviewReview(showPreviewOnly);
+               }
+               RefactoringStarter starter = new RefactoringStarter();
+                       CRenameProcessor processor = (CRenameProcessor) refactoring.getProcessor();
+               processor.lockIndex();
+               try {
+                       processor.checkInitialConditions(new NullProgressMonitor());
+                       return starter.activate(wizard, shell, RenameMessages.CRefactory_title_rename, processor.getSaveMode());
+               } finally {
+                       processor.unlockIndex();
+               }
+        } catch (InterruptedException e) {
+                       Thread.currentThread().interrupt();
+        } catch (CoreException e) {
+               CUIPlugin.log(e);
+               }
+        return false;
+       }
+
+    public TextSearchWrapper getTextSearch() {
+        if (fTextSearch == null) {
+            return new TextSearchWrapper();
+        }
+        return fTextSearch;
+    }
+    
+    public String[] getCCppPatterns() {
+        IContentType[] cts= Platform.getContentTypeManager().getAllContentTypes();
+        HashSet<String> all= new HashSet<String>();
+        for (IContentType type : cts) {
+            boolean useit= false;
+            while (!useit && type != null) {
+                String id= type.getId();
+                if (id.equals(CCorePlugin.CONTENT_TYPE_CHEADER) ||
+                        id.equals(CCorePlugin.CONTENT_TYPE_CSOURCE) ||
+                        id.equals(CCorePlugin.CONTENT_TYPE_CXXHEADER) ||
+                        id.equals(CCorePlugin.CONTENT_TYPE_CXXSOURCE)) {
+                       useit= true;
+                } else {
+                    type= type.getBaseType();
+                }
+            }
+            if (useit) {
+                String exts[] = type.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
+                all.addAll(Arrays.asList(exts));
+            }
+        }
+        String[] result= new String[all.size()];
+        Iterator<String> it= all.iterator();
+        for (int i= 0; i < result.length; i++) {
+            result[i]= "*." + it.next(); //$NON-NLS-1$
+        }
+        return result;
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameClassProcessor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameClassProcessor.java
new file mode 100644 (file)
index 0000000..222d6de
--- /dev/null
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ * Markus Schorn - initial API and implementation 
+ ******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
+
+
+/**
+ * Processor adding constructor and destructor to the bindings to be renamed.
+ */
+public class CRenameClassProcessor extends CRenameTypeProcessor {
+
+    public CRenameClassProcessor(CRenameProcessor processor, String kind) {
+        super(processor, kind);
+    }
+    
+    @Override
+       protected IBinding[] getBindingsToBeRenamed(RefactoringStatus status) {
+        CRefactoringArgument argument= getArgument();
+        IBinding binding= argument.getBinding();
+        ArrayList<IBinding> bindings= new ArrayList<IBinding>();
+        if (binding != null) {
+            bindings.add(binding);
+        }
+        if (binding instanceof ICPPClassType) {
+            ICPPClassType ctype= (ICPPClassType) binding;
+            ICPPConstructor[] ctors= ctype.getConstructors();
+                       if (ctors != null) {
+                           bindings.addAll(Arrays.asList(ctors));
+                       }
+                       
+                       IScope scope= ctype.getCompositeScope();
+                       if (scope != null) {
+                           IBinding[] dtors= scope.find("~" + argument.getName()); //$NON-NLS-1$
+                           if (dtors != null) {
+                               bindings.addAll(Arrays.asList(dtors));
+                           }
+                       }
+        }
+        return bindings.toArray(new IBinding[bindings.size()]);
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameGlobalProcessor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameGlobalProcessor.java
new file mode 100644 (file)
index 0000000..ccc62c5
--- /dev/null
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *     Markus Schorn - initial API and implementation
+ *     Sergey Prigogin (Google)
+ ******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+import org.eclipse.cdt.internal.ui.refactoring.RefactoringSaveHelper;
+
+
+/**
+ * Rename processor that sets up the input page for renaming a global entity.
+ */
+public class CRenameGlobalProcessor extends CRenameProcessorDelegate {
+
+    public CRenameGlobalProcessor(CRenameProcessor processor, String name) {
+        super(processor, name);
+        setAvailableOptions(CRefactory.OPTION_ASK_SCOPE |
+                       CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH |
+                CRefactory.OPTION_IN_CODE |
+                CRefactory.OPTION_IN_COMMENT | 
+                CRefactory.OPTION_IN_MACRO_DEFINITION);
+    }
+
+       @Override
+       public int getSaveMode() {
+               return RefactoringSaveHelper.SAVE_REFACTORING;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameIncludeProcessor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameIncludeProcessor.java
new file mode 100644 (file)
index 0000000..3ebe3d1
--- /dev/null
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *     Markus Schorn - initial API and implementation
+ *     Sergey Prigogin (Google)
+ ******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+import org.eclipse.cdt.internal.ui.refactoring.RefactoringSaveHelper;
+
+/**
+ * Rename processor setting up input page for renaming include directives.
+ */
+public class CRenameIncludeProcessor extends CRenameProcessorDelegate {
+    
+    public CRenameIncludeProcessor(CRenameProcessor input, String kind) {
+        super(input, kind);
+        setAvailableOptions(CRefactory.OPTION_ASK_SCOPE | 
+                       CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH |
+                CRefactory.OPTION_IN_COMMENT | 
+                CRefactory.OPTION_IN_MACRO_DEFINITION);
+        setOptionsForcingPreview(-1);
+        setOptionsEnablingScope(-1);
+    }
+
+    @Override
+       protected int getAcceptedLocations(int selectedOptions) {
+        return selectedOptions | CRefactory.OPTION_IN_INCLUDE_DIRECTIVE;
+    }
+
+       @Override
+       public int getSaveMode() {
+               // TODO(sprigogin): Should it be SAVE_REFACTORING?
+               return RefactoringSaveHelper.SAVE_ALL;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java
new file mode 100644 (file)
index 0000000..6baeebd
--- /dev/null
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *     Markus Schorn - initial API and implementation
+ *     Sergey Prigogin (Google)
+ ******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IParameter;
+import org.eclipse.cdt.core.dom.ast.IScope;
+
+import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
+
+import org.eclipse.cdt.internal.ui.refactoring.RefactoringSaveHelper;
+
+
+/**
+ * Rename processor, setting up input page for a local rename.
+ */
+public class CRenameLocalProcessor extends CRenameProcessorDelegate {
+    private IScope fScope;
+    public CRenameLocalProcessor(CRenameProcessor input, String kind, IScope scope) {
+        super(input, kind);
+        fScope= scope;
+        setAvailableOptions(0);
+        setOptionsForcingPreview(0);
+    }
+    
+    // overrider
+    @Override
+       protected int getAcceptedLocations(int selectedOptions) {
+        return CRefactory.OPTION_IN_CODE | CRefactory.OPTION_IN_MACRO_DEFINITION | selectedOptions;
+    }
+    
+    // overrider
+    @Override
+       protected int getSearchScope() {
+        return TextSearchWrapper.SCOPE_FILE;
+    }
+    
+       @Override
+       protected void analyzeTextMatches(IBinding[] renameBindings, Collection<CRefactoringMatch> matches,
+                       IProgressMonitor monitor, RefactoringStatus status) {
+       super.analyzeTextMatches(renameBindings, matches, monitor, status);
+        if (fScope != null) {
+            CRefactoringArgument argument = getArgument();
+            int[] result= new int[] {0, Integer.MAX_VALUE};
+            IScope scope= argument.getScope();
+            IASTNode node= null;
+            node = ASTInternal.getPhysicalNodeOfScope(scope);
+                       if (argument.getBinding() instanceof IParameter) {
+                           node= node.getParent();
+                       }
+            if (node != null) {
+                IASTFileLocation loc= ASTManager.getLocationInTranslationUnit(node);
+                if (loc != null) {
+                    result[0]= loc.getNodeOffset();
+                    result[1]= result[0] + loc.getNodeLength();
+                }
+            }
+            int[] range= result;
+            for (Iterator<CRefactoringMatch> iter = matches.iterator(); iter.hasNext();) {
+                CRefactoringMatch m = iter.next();
+                if (m.getAstInformation() != CRefactoringMatch.AST_REFERENCE) {
+                       int off= m.getOffset();
+                       if (off < range[0] || off > range[1]) {
+                               iter.remove();
+                       }
+                }
+            }
+        }
+    }
+
+       @Override
+       public int getSaveMode() {
+               return RefactoringSaveHelper.SAVE_NOTHING;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMacroProcessor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMacroProcessor.java
new file mode 100644 (file)
index 0000000..3bebc37
--- /dev/null
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2010 Wind River Systems, Inc and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Markus Schorn - initial API and implementation
+ *     Sergey Prigogin (Google) 
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+import java.util.Collection;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+
+import org.eclipse.cdt.core.dom.ast.IBinding;
+
+
+/**
+ * Rename processor that sets up the input page for renaming a global entity.
+ */
+public class CRenameMacroProcessor extends CRenameGlobalProcessor {
+
+    public CRenameMacroProcessor(CRenameProcessor processor, String name) {
+        super(processor, name);
+        setAvailableOptions(CRefactory.OPTION_ASK_SCOPE | 
+                       CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH |
+                CRefactory.OPTION_IN_CODE |
+                CRefactory.OPTION_IN_COMMENT | 
+                CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE);
+    }
+    
+    @Override
+       protected int getAcceptedLocations(int selectedOptions) {
+        return selectedOptions | CRefactory.OPTION_IN_MACRO_DEFINITION;
+    }
+
+       @Override
+       protected void analyzeTextMatches(IBinding[] renameBindings, Collection<CRefactoringMatch> matches,
+                       IProgressMonitor monitor, RefactoringStatus status) {
+        for (CRefactoringMatch m : matches) {
+            if ((m.getLocation() & CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE) != 0) {
+                m.setASTInformation(CRefactoringMatch.AST_REFERENCE);
+            }
+        }
+        super.analyzeTextMatches(renameBindings, matches, monitor, status);
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java
new file mode 100644 (file)
index 0000000..fa58c0f
--- /dev/null
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *     Markus Schorn - initial API and implementation
+ *     Sergey Prigogin (Google) 
+ ******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+
+import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+
+import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
+
+
+/**
+ * Rename processor for methods.
+ */
+public class CRenameMethodProcessor extends CRenameGlobalProcessor {
+    public CRenameMethodProcessor(CRenameProcessor processor, String kind, boolean isVirtual) {
+        super(processor, kind);
+        if (isVirtual)
+               setAvailableOptions(getAvailableOptions() | CRefactory.OPTION_DO_VIRTUAL);
+    }
+
+    @Override
+       public RefactoringStatus checkInitialConditions(IProgressMonitor pm) 
+            throws OperationCanceledException, CoreException {
+        CRefactoringArgument argument= getArgument();
+        IBinding binding= argument.getBinding();
+        if (binding instanceof ICPPConstructor) {
+            return RefactoringStatus.createFatalErrorStatus(RenameMessages.CRenameMethodProcessor_fatalError_renameConstructor);
+        }
+        String identifier= argument.getName();
+        if (identifier.startsWith("~")) { //$NON-NLS-1$
+            return RefactoringStatus.createFatalErrorStatus(RenameMessages.CRenameMethodProcessor_fatalError_renameDestructor);
+        }
+        if (identifier.startsWith("operator") && //$NON-NLS-1$
+                identifier.length() > 8 && 
+                !CRefactoringUtils.isIdentifierChar(identifier.charAt(8))) { 
+            return RefactoringStatus.createFatalErrorStatus(RenameMessages.CRenameMethodProcessor_fatalError_renameOperator);
+        }
+        return super.checkInitialConditions(pm);
+    }
+    
+    @Override
+       public RefactoringStatus checkFinalConditions(IProgressMonitor monitor, CheckConditionsContext context)
+               throws OperationCanceledException, CoreException {
+        CRefactoringArgument argument= getArgument();
+        RefactoringStatus result= new RefactoringStatus();
+        IScope scope= argument.getScope();
+        if (scope != null) {
+            IASTNode node= ASTInternal.getPhysicalNodeOfScope(scope);
+            if (node instanceof IASTCompositeTypeSpecifier) {
+                IASTCompositeTypeSpecifier se= (IASTCompositeTypeSpecifier) node;
+                IASTName name= ASTManager.getSimpleName(se.getName());
+                if (getReplacementText().equals(name.toString())) {
+                    return RefactoringStatus.createFatalErrorStatus(RenameMessages.CRenameMethodProcessor_fatalError_renameToConstructor);
+                }
+                if (getReplacementText().startsWith("~")) { //$NON-NLS-1$
+                    return RefactoringStatus.createFatalErrorStatus(RenameMessages.CRenameMethodProcessor_fatalError_renameToDestructor);
+                }
+                if (!CRefactoringUtils.checkIdentifier(getReplacementText())) {
+                    result.merge(RefactoringStatus.createErrorStatus(RenameMessages.CRenameMethodProcessor_warning_illegalCharacters));
+                }
+            }                
+        }
+        if (argument.getArgumentKind() == CRefactory.ARGUMENT_VIRTUAL_METHOD &&
+                       (getSelectedOptions() & CRefactory.OPTION_DO_VIRTUAL) == 0) {
+            result.merge(RefactoringStatus.createWarningStatus(RenameMessages.CRenameMethodProcessor_warning_renameVirtual));
+        }
+
+        result.merge(super.checkFinalConditions(monitor, context));
+        return result;
+    }
+    
+    @Override
+       protected IBinding[] getBindingsToBeRenamed(RefactoringStatus status) {
+       if ((getSelectedOptions() & CRefactory.OPTION_DO_VIRTUAL) == 0) {
+               return super.getBindingsToBeRenamed(status);
+       }
+       
+        CRefactoringArgument argument= getArgument();
+        IBinding binding= argument.getBinding();
+        ArrayList<IBinding> bindings= new ArrayList<IBinding>();
+        if (binding != null) {
+            bindings.add(binding);
+        }
+        if (binding instanceof ICPPMethod) {
+               ICPPMethod m= (ICPPMethod) binding;
+               try {
+                       IBinding[] bs= ClassTypeHelper.findOverridden(m);
+                       bindings.addAll(Arrays.asList(bs));
+                       bs= ClassTypeHelper.findOverriders(getIndex(), m);
+                       bindings.addAll(Arrays.asList(bs));
+            } catch (CoreException e) {
+               status.addError(e.getMessage());
+            }
+        }
+        return bindings.toArray(new IBinding[bindings.size()]);
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessor.java
new file mode 100644 (file)
index 0000000..2b9c0b5
--- /dev/null
@@ -0,0 +1,320 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Markus Schorn - initial API and implementation 
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+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.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+import org.eclipse.ltk.core.refactoring.participants.ParticipantManager;
+import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant;
+import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
+import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
+import org.eclipse.ltk.core.refactoring.participants.RenameProcessor;
+import org.eclipse.ltk.core.refactoring.participants.SharableParticipants;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.IWorkingSetManager;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.core.CCProjectNature;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.CProjectNature;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICProject;
+
+/**
+ * This is the processor used for the rename. It decides which of the delegates to
+ * use and forwards further calls to the delegate.
+ */
+public class CRenameProcessor extends RenameProcessor {
+    public static final String IDENTIFIER= "org.eclips.cdt.refactoring.RenameProcessor"; //$NON-NLS-1$
+
+    private final CRefactoringArgument fArgument;
+    private CRenameProcessorDelegate fDelegate;
+    private String fReplacementText;
+    private String fWorkingSet;
+    private int fScope;
+    private int fSelectedOptions;
+    private final CRefactory fManager;
+    private final ASTManager fAstManager;
+       private IIndex fIndex;
+       private RefactoringStatus fInitialConditionsStatus;
+    
+    public CRenameProcessor(CRefactory refactoringManager, CRefactoringArgument arg) {
+        fManager= refactoringManager;
+        fArgument= arg;
+        fAstManager= new ASTManager(arg);
+    }
+    
+    public CRefactoringArgument getArgument() {
+        return fArgument;
+    }
+
+    // overrider
+    @Override
+       public Object[] getElements() {
+        return new Object[] { fArgument.getBinding() };
+    }
+
+    // overrider
+    @Override
+       public String getProcessorName() {
+        String result= null;
+        if (fDelegate != null) { 
+            result= fDelegate.getProcessorName();
+        }
+        if (result == null) {
+            String identifier= getArgument().getName();
+            if (identifier != null && identifier.length() > 0) {
+                result= NLS.bind(RenameMessages.CRenameTopProcessor_wizard_title, identifier);
+            }
+        }
+        if (result == null) {
+            result= RenameMessages.CRenameTopProcessor_wizard_backup_title;
+        }
+
+        return result;
+    }
+
+    @Override
+       public boolean isApplicable() throws CoreException {
+        return true;
+    }
+
+    @Override
+       public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
+            throws CoreException, OperationCanceledException {
+       if (fInitialConditionsStatus != null) {
+               return fInitialConditionsStatus; // Already checked.
+       }
+        String identifier= null;
+        fInitialConditionsStatus= new RefactoringStatus();
+        if (fArgument != null) {
+            fAstManager.analyzeArgument(fIndex, pm, fInitialConditionsStatus);
+            identifier= fArgument.getName();
+        }
+        if (identifier == null || identifier.length() == 0) {
+               fInitialConditionsStatus.addFatalError(RenameMessages.CRenameTopProcessor_error_invalidTextSelection);
+            return fInitialConditionsStatus;
+        }
+        IFile file= fArgument.getSourceFile();
+        IPath path= null;
+        if (file != null) {
+            path= file.getLocation();
+        }
+        if (path == null) {
+            return RefactoringStatus.createFatalErrorStatus(RenameMessages.CRenameTopProcessor_error_renameWithoutSourceFile);
+        }
+        
+        fDelegate= createDelegate();
+        if (fDelegate == null) {
+               fInitialConditionsStatus.addFatalError(RenameMessages.CRenameTopProcessor_error_invalidName);
+            return fInitialConditionsStatus;
+        }            
+        RefactoringStatus status= fDelegate.checkInitialConditions(new NullProgressMonitor());
+        fInitialConditionsStatus.merge(status);
+        return fInitialConditionsStatus;
+    }
+
+    private CRenameProcessorDelegate createDelegate() {
+        switch (fArgument.getArgumentKind()) {
+               case CRefactory.ARGUMENT_LOCAL_VAR: 
+                return new CRenameLocalProcessor(this, 
+                        RenameMessages.CRenameTopProcessor_localVar,
+                        fArgument.getScope());
+               case CRefactory.ARGUMENT_PARAMETER:
+                return new CRenameLocalProcessor(this, 
+                        RenameMessages.CRenameTopProcessor_parameter,
+                        fArgument.getScope());
+               case CRefactory.ARGUMENT_FILE_LOCAL_VAR:
+                return new CRenameLocalProcessor(this, 
+                        RenameMessages.CRenameTopProcessor_filelocalVar,
+                        null);
+               case CRefactory.ARGUMENT_GLOBAL_VAR:
+                return new CRenameGlobalProcessor(this, RenameMessages.CRenameTopProcessor_globalVar);
+            case CRefactory.ARGUMENT_ENUMERATOR:
+                return new CRenameGlobalProcessor(this, RenameMessages.CRenameTopProcessor_enumerator);
+               case CRefactory.ARGUMENT_FIELD:
+                return new CRenameGlobalProcessor(this, RenameMessages.CRenameTopProcessor_field);
+               case CRefactory.ARGUMENT_FILE_LOCAL_FUNCTION:
+                return new CRenameLocalProcessor(this, 
+                        RenameMessages.CRenameTopProcessor_filelocalFunction,
+                        null);
+               case CRefactory.ARGUMENT_GLOBAL_FUNCTION:
+                return new CRenameGlobalProcessor(this, RenameMessages.CRenameTopProcessor_globalFunction);
+               case CRefactory.ARGUMENT_VIRTUAL_METHOD:
+                return new CRenameMethodProcessor(this, RenameMessages.CRenameTopProcessor_virtualMethod, true);
+               case CRefactory.ARGUMENT_NON_VIRTUAL_METHOD:
+                return new CRenameMethodProcessor(this, RenameMessages.CRenameTopProcessor_method, false);
+            case CRefactory.ARGUMENT_CLASS_TYPE:                
+                return new CRenameClassProcessor(this, RenameMessages.CRenameTopProcessor_type);
+            case CRefactory.ARGUMENT_NAMESPACE:
+                return new CRenameTypeProcessor(this, RenameMessages.CRenameTopProcessor_namespace);
+               case CRefactory.ARGUMENT_TYPE:
+                return new CRenameTypeProcessor(this, RenameMessages.CRenameTopProcessor_type);
+               case CRefactory.ARGUMENT_MACRO:
+                return new CRenameMacroProcessor(this, RenameMessages.CRenameTopProcessor_macro);
+               case CRefactory.ARGUMENT_INCLUDE_DIRECTIVE:
+                return new CRenameIncludeProcessor(this, RenameMessages.CRenameIncludeProcessor_includeDirective);
+               default:
+                return null;
+        }
+    }
+
+    @Override
+       public RefactoringStatus checkFinalConditions(IProgressMonitor pm, CheckConditionsContext context)
+               throws CoreException, OperationCanceledException {
+        return fDelegate.checkFinalConditions(pm, context);
+    }
+
+    @Override
+       public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
+        return fDelegate.createChange(pm);
+    }
+
+    @Override
+       public RefactoringParticipant[] loadParticipants(RefactoringStatus status,
+            SharableParticipants sharedParticipants) throws CoreException {
+        RenameArguments arguments= new RenameArguments(getReplacementText(), true);
+        final String[] natures= {CCProjectNature.CC_NATURE_ID, CProjectNature.C_NATURE_ID};
+        List<RenameParticipant> result= new ArrayList<RenameParticipant>();
+        IBinding binding= getArgument().getBinding();
+        if (binding != null) {
+            result.addAll(Arrays.asList(ParticipantManager.loadRenameParticipants(status, 
+                    this,  binding, arguments, natures, sharedParticipants)));
+        }
+        return result.toArray(new RefactoringParticipant[result.size()]);
+    }
+
+    // options for the input page in the refactoring wizard
+    public int getAvailableOptions() {
+        if (fDelegate == null) {
+            return 0;
+        }
+        return fDelegate.getAvailableOptions();
+    }
+
+    // options for the input page that trigger the preview
+    public int getOptionsForcingPreview() {
+        if (fDelegate == null) {
+            return 0;
+        }
+        return fDelegate.getOptionsForcingPreview();
+    }
+
+    // options for the input page that trigger the preview
+    public int getOptionsEnablingScope() {
+        if (fDelegate == null) {
+            return 0;
+        }
+        return fDelegate.getOptionsEnablingScope();
+    }
+
+    @Override
+       public String getIdentifier() {
+        return IDENTIFIER;
+    }
+
+    public int getScope() {
+        return fScope;
+    }
+
+    public void setScope(int scope) {
+        fScope = scope;
+    }
+
+    public int getSelectedOptions() {
+        return fSelectedOptions;
+    }
+
+    public void setSelectedOptions(int selectedOptions) {
+        fSelectedOptions = selectedOptions;
+    }
+
+    public String getWorkingSet() {
+        return fWorkingSet;
+    }
+
+    /**
+     * Sets the name of the working set. If the name of the working set is invalid,
+     * it's set to an empty string. 
+     */
+    public void setWorkingSet(String workingSet) {
+        fWorkingSet = checkWorkingSet(workingSet);
+    }
+
+    public String getReplacementText() {
+        return fReplacementText;
+    }
+
+    public void setReplacementText(String replacementText) {
+        fReplacementText = replacementText;
+    }
+
+    public CRefactory getManager() {
+        return fManager;
+    }
+
+    public ASTManager getAstManager() {
+        return fAstManager;
+    }
+
+       public void lockIndex() throws CoreException, InterruptedException {
+               if (fIndex == null) {
+                       ICProject[] projects= CoreModel.getDefault().getCModel().getCProjects();
+                       fIndex= CCorePlugin.getIndexManager().getIndex(projects);
+               }
+               fIndex.acquireReadLock();
+       }
+       
+       public void unlockIndex() {
+               if (fAstManager != null) {
+                       fAstManager.dispose();
+               }
+               if (fIndex != null) {
+                       fIndex.releaseReadLock();
+               }
+               fIndex= null;
+       }
+
+       public IIndex getIndex() {
+               return fIndex;
+       }
+
+       /**
+        * @return a save mode from {@link org.eclipse.cdt.internal.ui.refactoring.RefactoringSaveHelper}
+        */
+       public int getSaveMode() {
+               return fDelegate.getSaveMode();
+       }
+       
+    private String checkWorkingSet(String workingSet) {
+               if (workingSet != null && workingSet.length() > 0) {
+                   IWorkingSetManager wsManager= PlatformUI.getWorkbench().getWorkingSetManager();
+                   if (wsManager.getWorkingSet(workingSet) != null) {
+                       return workingSet;
+                   }
+               }
+           return ""; //$NON-NLS-1$
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java
new file mode 100644 (file)
index 0000000..4d7fd99
--- /dev/null
@@ -0,0 +1,387 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *     Markus Schorn - initial API and implementation 
+ *     IBM Corporation - Bug 112366
+ *     Sergey Prigogin (Google)
+ ******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+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.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.TextEditChangeGroup;
+import org.eclipse.ltk.core.refactoring.TextFileChange;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+import org.eclipse.ltk.core.refactoring.participants.ValidateEditChecker;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.text.edits.MultiTextEdit;
+import org.eclipse.text.edits.ReplaceEdit;
+import org.eclipse.text.edits.TextEditGroup;
+
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexFileLocation;
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.ui.refactoring.CTextFileChange;
+
+
+/**
+ * Abstract base for all different rename processors used by the top processor.
+ */
+public abstract class CRenameProcessorDelegate {
+    private CRenameProcessor fTopProcessor;
+    private ArrayList<CRefactoringMatch> fMatches;
+    protected String fProcessorBaseName;
+    private int fAvailableOptions=         
+               CRefactory.OPTION_ASK_SCOPE | 
+               CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH | 
+               CRefactory.OPTION_IN_CODE |
+               CRefactory.OPTION_IN_COMMENT | 
+               CRefactory.OPTION_IN_MACRO_DEFINITION |
+               CRefactory.OPTION_IN_STRING_LITERAL;
+
+    private int fOptionsForcingPreview=
+               CRefactory.OPTION_IN_INACTIVE_CODE |
+               CRefactory.OPTION_IN_COMMENT | 
+               CRefactory.OPTION_IN_MACRO_DEFINITION |
+               CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE |
+               CRefactory.OPTION_IN_STRING_LITERAL;
+    
+    private int fOptionsEnablingScope= fOptionsForcingPreview;        
+
+
+    protected CRenameProcessorDelegate(CRenameProcessor topProcessor, String name) {
+        fTopProcessor= topProcessor;
+        fProcessorBaseName= name;
+    }
+    
+    final public CRefactoringArgument getArgument() {
+        return fTopProcessor.getArgument();
+    }
+
+    final public String getReplacementText() {
+        return fTopProcessor.getReplacementText();
+    }
+
+    final public int getSelectedScope() {
+        return fTopProcessor.getScope();
+    }
+
+    final public int getSelectedOptions() {
+        return fTopProcessor.getSelectedOptions();
+    }
+
+    final public String getSelectedWorkingSet() {
+        return fTopProcessor.getWorkingSet();
+    }
+
+    final public CRefactory getManager() {
+        return fTopProcessor.getManager();
+    }
+
+    final public ASTManager getAstManager() {
+        return fTopProcessor.getAstManager();
+    }
+
+    final public IIndex getIndex() {
+       return fTopProcessor.getIndex();
+    }
+
+    final public String getProcessorName() {
+        String identifier= getArgument().getName();
+        if (identifier != null) {
+            return NLS.bind(RenameMessages.CRenameProcessorDelegate_wizard_title, fProcessorBaseName,
+                       identifier);
+        }
+        return null;
+    }
+
+    /**
+     * The options presented by the page in the refactoring wizard.
+     */
+    public void setAvailableOptions(int options) {
+        fAvailableOptions= options;
+    }
+
+    final int getAvailableOptions() {
+        return fAvailableOptions;
+    }
+
+    /**
+     * The options each of which forces the preview, when selected.
+     */
+    public void setOptionsForcingPreview(int options) {
+        fOptionsForcingPreview= options;
+    }
+    
+    final int getOptionsForcingPreview() {
+       return fOptionsForcingPreview;
+    }
+
+    /**
+     * The options that need the scope definition. When one of them is 
+     * selected, the scope options are enabled.
+     */
+    public void setOptionsEnablingScope(int options) {
+        fOptionsEnablingScope= options;
+    }
+    
+    final int getOptionsEnablingScope() {
+        return fOptionsEnablingScope;
+    }
+
+    protected int getSearchScope() {
+        return getSelectedScope();
+    }
+
+    /**
+     * Builds an index-based file filter for the name search.
+     * @param bindings bindings being renamed
+     * @return A set of files containing references to the bindings, or <code>null</code> if
+     * exhaustive file search is requested.
+     */
+    private Collection<IResource> getFileFilter(IBinding[] bindings) {
+       if ((getSelectedOptions() & CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH) != 0) {
+               return null;
+       }
+       IIndex index = getIndex();
+       if (index == null) {
+               return null;
+       }
+               Set<IIndexFileLocation> locations = new HashSet<IIndexFileLocation>();
+       try {
+               index.acquireReadLock();
+               for (IBinding binding : bindings) {
+                               IIndexName[] names = index.findNames(binding,
+                                               IIndex.FIND_ALL_OCCURRENCES | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
+                               for (IIndexName name : names) {
+                                       locations.add(name.getFile().getLocation());
+                               }
+               }
+               } catch (InterruptedException e) {
+                       return null;
+               } catch (CoreException e) {
+                       return null;
+               } finally {
+               index.releaseReadLock();
+       }
+
+               ArrayList<IResource> files = new ArrayList<IResource>(locations.size());
+               IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+               for (IIndexFileLocation location : locations) {
+                       String fullPath= location.getFullPath();
+                       if (fullPath != null) {
+                               IResource file= workspaceRoot.findMember(fullPath);
+                               if (file != null) {
+                                       files.add(file);
+                               }
+                       }
+               }
+
+               return files;
+       }
+
+    public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException {
+        return new RefactoringStatus();
+    }
+
+    public RefactoringStatus checkFinalConditions(IProgressMonitor monitor, CheckConditionsContext context)
+               throws CoreException, OperationCanceledException {
+        RefactoringStatus result= new RefactoringStatus();
+        monitor.beginTask(RenameMessages.CRenameProcessorDelegate_task_checkFinalCondition, 2);
+        IFile file= getArgument().getSourceFile();
+        //assert file!=null;
+
+        IBinding[] renameBindings= getBindingsToBeRenamed(result);
+
+        // perform text-search
+        fMatches= new ArrayList<CRefactoringMatch>();
+        TextSearchWrapper txtSearch= getManager().getTextSearch();
+        Collection<IResource> fileFilter = getFileFilter(renameBindings);
+        if (fileFilter != null && !fileFilter.contains(file)) {
+               fileFilter.add(file);
+        }
+        IStatus stat= txtSearch.searchWord(getSearchScope(), file, getSelectedWorkingSet(), 
+                       fileFilter != null ? fileFilter.toArray(new IResource[fileFilter.size()]) : null,
+                       getManager().getCCppPatterns(),
+                       getArgument().getName(), new SubProgressMonitor(monitor, 1), fMatches);
+        if (monitor.isCanceled()) {
+            throw new OperationCanceledException();
+        }
+        result.merge(RefactoringStatus.create(stat));
+        if (result.hasFatalError()) {
+            return result;
+        }
+        selectMatchesByLocation(fMatches);
+        analyzeTextMatches(renameBindings, fMatches, new SubProgressMonitor(monitor, 1), result);
+        if (result.hasFatalError()) {
+            return result;
+        }
+        
+        HashSet<IFile> fileset= new HashSet<IFile>();
+        int potentialMatchCount= 0;
+        int commentCount= 0;
+        for (Iterator<CRefactoringMatch> iter = fMatches.iterator(); iter.hasNext();) {
+            CRefactoringMatch tm = iter.next();
+            if (tm.isInComment()) {
+                commentCount++;
+                fileset.add(tm.getFile());
+            } else {
+                switch (tm.getAstInformation()) {
+                case CRefactoringMatch.AST_REFERENCE_OTHER:
+                    iter.remove();
+                    break;
+                case CRefactoringMatch.POTENTIAL:
+                    potentialMatchCount++;
+                    fileset.add(tm.getFile());
+                    break;
+                default:
+                    fileset.add(tm.getFile());
+                    break;
+                }
+            }
+        }
+        if (potentialMatchCount != 0) {
+            String msg= null;
+            if (potentialMatchCount == 1) {
+                msg= RenameMessages.CRenameProcessorDelegate_warning_potentialMatch_singular;
+            } else {
+                msg= NLS.bind(RenameMessages.CRenameProcessorDelegate_warning_potentialMatch_plural,
+                               potentialMatchCount);
+            }
+            result.addWarning(msg);
+        }
+        if (commentCount != 0) {
+            String msg= null;
+            if (commentCount == 1) {
+                msg= RenameMessages.CRenameProcessorDelegate_warning_commentMatch_singular;
+            } else {
+                msg= NLS.bind(RenameMessages.CRenameProcessorDelegate_warning_commentMatch_plural,
+                               commentCount);
+            }
+            result.addWarning(msg);
+        }
+        IFile[] files= fileset.toArray(new IFile[fileset.size()]);
+        if (context != null) {
+            ValidateEditChecker editChecker=
+                       (ValidateEditChecker) context.getChecker(ValidateEditChecker.class);
+            editChecker.addFiles(files);
+        }
+        monitor.done();
+        return result;
+    }
+
+       protected void analyzeTextMatches(IBinding[] renameBindings, Collection<CRefactoringMatch> matches,
+                       IProgressMonitor monitor, RefactoringStatus status) {
+        if (renameBindings.length > 0 && getArgument().getArgumentKind() != CRefactory.ARGUMENT_UNKNOWN) {
+            ASTManager mngr= getAstManager();
+            mngr.setValidBindings(renameBindings);
+            mngr.setRenameTo(getReplacementText());
+            mngr.analyzeTextMatches(fTopProcessor.getIndex(), matches, monitor, status);
+        }
+    }
+
+    private void selectMatchesByLocation(Collection<CRefactoringMatch> matches) {
+        int acceptTextLocation= getAcceptedLocations(getSelectedOptions());
+        for (Iterator<CRefactoringMatch> iter = matches.iterator(); iter.hasNext();) {
+            CRefactoringMatch match = iter.next();
+            int location= match.getLocation();
+            if (location != 0 && (location & acceptTextLocation) == 0) {
+                iter.remove();
+            }
+        }
+    }
+
+    protected int getAcceptedLocations(int selectedOptions) {
+        return selectedOptions;
+    }
+
+    public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
+        if (fMatches.isEmpty()) {
+            return null;
+        }
+        Collections.sort(fMatches, new Comparator<CRefactoringMatch>() {
+            public int compare(CRefactoringMatch m1, CRefactoringMatch m2) {
+                IFile f1= m1.getFile();
+                IFile f2= m2.getFile();
+                int cmp= f1.getName().compareTo(f2.getName());
+                if (cmp != 0) return cmp;
+    
+                cmp= f1.getFullPath().toString().compareTo(f2.getFullPath().toString());   
+                if (cmp != 0) return cmp;
+                
+                return m1.getOffset() - m2.getOffset();
+            }});
+        pm.beginTask(RenameMessages.CRenameProcessorDelegate_task_createChange, fMatches.size());
+        final String identifier= getArgument().getName();
+        final String replacement= getReplacementText();
+        CompositeChange overallChange= new CompositeChange(getProcessorName()); 
+        IFile file= null;
+        TextFileChange fileChange= null;
+        MultiTextEdit fileEdit= null;
+        for (CRefactoringMatch match : fMatches) {
+            switch (match.getAstInformation()) {
+            case CRefactoringMatch.AST_REFERENCE_OTHER:
+                continue;
+            case CRefactoringMatch.IN_COMMENT:
+            case CRefactoringMatch.POTENTIAL:
+                break;
+            case CRefactoringMatch.AST_REFERENCE:
+                break;
+            }
+            if (match.getAstInformation() != CRefactoringMatch.AST_REFERENCE_OTHER) {
+                IFile mfile= match.getFile();
+                if (file==null || !file.equals(mfile) || fileEdit == null || fileChange == null) {
+                    file= mfile;
+                    fileEdit= new MultiTextEdit();
+                    fileChange = new CTextFileChange(file.getName(), file);
+                    fileChange.setEdit(fileEdit);
+                    overallChange.add(fileChange);
+                }
+                
+                ReplaceEdit replaceEdit= new ReplaceEdit(match.getOffset(), identifier.length(), replacement);
+                fileEdit.addChild(replaceEdit);
+                TextEditGroup editGroup= new TextEditGroup(match.getLabel(), replaceEdit);
+                TextEditChangeGroup changeGroup= new TextEditChangeGroup(fileChange, editGroup);
+                fileChange.addTextEditChangeGroup(changeGroup);
+            }
+            pm.worked(1);
+        }
+        return overallChange;
+    }
+
+    /**
+     * Returns the array of bindings that must be renamed.
+     */
+    protected IBinding[] getBindingsToBeRenamed(RefactoringStatus status) {
+        return new IBinding[] { getArgument().getBinding() };
+    }
+
+       /**
+        * @return a save mode from {@link org.eclipse.cdt.internal.ui.refactoring.RefactoringSaveHelper}
+        */
+       public abstract int getSaveMode();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoring.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoring.java
new file mode 100644 (file)
index 0000000..9425d1f
--- /dev/null
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *    Markus Schorn - initial API and implementation
+ *    Sergey Prigogin (Google) 
+ ******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+import org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring;
+
+/**
+ * Refactoring implementation using a refactoring processor.
+ */
+public class CRenameRefactoring extends ProcessorBasedRefactoring {
+       public static final String ID = "org.eclipse.cdt.internal.ui.refactoring.rename.CRenameRefactoring"; //$NON-NLS-1$
+
+    public CRenameRefactoring(CRenameProcessor processor) {
+        super(processor);
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java
new file mode 100644 (file)
index 0000000..b875cf2
--- /dev/null
@@ -0,0 +1,493 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *    Markus Schorn - initial API and implementation 
+ *    Emanuel Graf (Institute for Software, HSR Hochschule fuer Technik)
+ *    Sergey Prigogin (Google)
+ ******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetManager;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog;
+
+import org.eclipse.cdt.core.CConventions;
+
+/**
+ * Input page added to the standard refactoring wizard.
+ */
+public class CRenameRefactoringInputPage extends UserInputWizardPage {
+       public static final String PAGE_NAME = "RenameRefactoringPage"; //$NON-NLS-1$
+    
+       final CRenameRefactoringPreferences fPreferences;
+       private String fSearchString;
+    private int fOptions;
+    private int fForcePreviewOptions= 0;
+    private int fEnableScopeOptions;
+
+    private Text fNewName;
+       private Button fDoVirtual;
+    private Button fWorkspace;
+    private Button fDependent;
+    private Button fInComment;
+    private Button fInString;
+    private Button fInInclude;
+    private Button fInInactiveCode;
+    private Button fReferences;
+    private Button fSingle;
+    private Button fWorkingSet;
+    private Text fWorkingSetSpec;
+    private Button fWorkingSetButton;
+    private Button fInMacro;
+    private Button fInPreprocessor;
+    private Button fExhausiveFileSearch;
+
+    public CRenameRefactoringInputPage() {
+        super(PAGE_NAME);
+        fPreferences = new CRenameRefactoringPreferences();
+    }
+    private boolean hasOption(int options) {
+        return (fOptions & options) == options;
+    }
+
+    // overrider
+    public void createControl(Composite parent) {
+        CRenameProcessor processor= getRenameProcessor();
+        fSearchString= processor.getArgument().getName();
+        fOptions= processor.getAvailableOptions();
+        fForcePreviewOptions= processor.getOptionsForcingPreview();
+        fEnableScopeOptions= processor.getOptionsEnablingScope();
+        
+        Composite top= new Composite(parent, SWT.NONE);
+        initializeDialogUnits(top);
+        setControl(top);
+
+        top.setLayout(new GridLayout(2, false));
+
+        // new name
+        Composite group= top;
+        GridData gd;
+        GridLayout gl;
+
+        Label label= new Label(top, SWT.NONE);
+        label.setText(RenameMessages.CRenameRefactoringInputPage_label_newName);
+        fNewName= new Text(top, SWT.BORDER);
+        fNewName.setText(fSearchString);
+        fNewName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));        
+        fNewName.selectAll();
+        
+        if (hasOption(CRefactory.OPTION_DO_VIRTUAL)) {
+               fDoVirtual= new Button(top, SWT.CHECK);
+               fDoVirtual.setText(RenameMessages.CRenameRefactoringInputPage_renameBaseAndDerivedMethods);
+               fDoVirtual.setLayoutData(gd= new GridData());
+               gd.horizontalSpan= 2;
+        }
+
+        if (hasOption(CRefactory.OPTION_ASK_SCOPE)) {          
+            // Specify the scope.
+            skipLine(top);
+            label = new Label(top, SWT.NONE);
+            label.setText(RenameMessages.CRenameRefactoringInputPage_label_scope);
+            label.setLayoutData(gd= new GridData(GridData.FILL_HORIZONTAL));
+            gd.horizontalSpan= 2;
+            
+            group= new Composite(top, SWT.NONE);
+            group.setLayoutData(gd= new GridData(GridData.FILL_HORIZONTAL));
+            gd.horizontalSpan= 2;
+            group.setLayout(gl= new GridLayout(4, false));
+            gl.marginHeight= 0;
+            gl.marginLeft = gl.marginWidth;
+            gl.marginWidth = 0;
+
+            fWorkspace= new Button(group, SWT.RADIO);
+            fWorkspace.setText(RenameMessages.CRenameRefactoringInputPage_button_workspace);
+            fWorkspace.setLayoutData(gd= new GridData());
+            
+            fDependent= new Button(group, SWT.RADIO);
+            fDependent.setText(RenameMessages.CRenameRefactoringInputPage_button_relatedProjects);
+            fDependent.setLayoutData(gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+               gd.horizontalIndent= 8;
+
+            fSingle= new Button(group, SWT.RADIO);
+            fSingle.setText(RenameMessages.CRenameRefactoringInputPage_button_singleProject);
+            fSingle.setLayoutData(gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+               gd.horizontalIndent= 8;
+               gd.horizontalSpan= 2;
+
+            fWorkingSet= new Button(group, SWT.RADIO);
+            fWorkingSet.setText(RenameMessages.CRenameRefactoringInputPage_button_workingSet);
+
+            fWorkingSetSpec= new Text(group, SWT.SINGLE|SWT.BORDER|SWT.READ_ONLY);
+            fWorkingSetSpec.setLayoutData(gd= new GridData(GridData.FILL_HORIZONTAL));
+               gd.horizontalIndent= 8;
+               gd.horizontalSpan= 2;
+            fWorkingSetButton= new Button(group, SWT.PUSH);
+            fWorkingSetButton.setText(RenameMessages.CRenameRefactoringInputPage_button_chooseWorkingSet);
+            setButtonLayoutData(fWorkingSetButton);
+        }
+
+        boolean skippedLine= false;
+        group= null;
+        if (hasOption(CRefactory.OPTION_IN_CODE)) {
+            group= createLabelAndGroup(group, skippedLine, top);
+               fReferences= new Button(group, SWT.CHECK);
+               fReferences.setText(RenameMessages.CRenameRefactoringInputPage_button_sourceCode);
+        }
+       if (hasOption(CRefactory.OPTION_IN_INACTIVE_CODE)) {
+            group= createLabelAndGroup(group, skippedLine, top);
+           fInInactiveCode= new Button(group, SWT.CHECK);
+           fInInactiveCode.setText(RenameMessages.CRenameRefactoringInputPage_button_inactiveCode);
+       }
+        if (hasOption(CRefactory.OPTION_IN_COMMENT)) {
+            group= createLabelAndGroup(group, skippedLine, top);
+            fInComment= new Button(group, SWT.CHECK);
+            fInComment.setText(RenameMessages.CRenameRefactoringInputPage_button_comments);
+        }
+        if (hasOption(CRefactory.OPTION_IN_STRING_LITERAL)) {
+            group= createLabelAndGroup(group, skippedLine, top);
+            fInString= new Button(group, SWT.CHECK);
+            fInString.setText(RenameMessages.CRenameRefactoringInputPage_button_strings);
+        }
+        if (hasOption(CRefactory.OPTION_IN_MACRO_DEFINITION)) {
+            group= createLabelAndGroup(group, skippedLine, top);
+            fInMacro= new Button(group, SWT.CHECK);
+            fInMacro.setText(RenameMessages.CRenameRefactoringInputPage_button_macroDefinitions);
+        }
+        if (hasOption(CRefactory.OPTION_IN_INCLUDE_DIRECTIVE)) {
+            group= createLabelAndGroup(group, skippedLine, top);
+            fInInclude= new Button(group, SWT.CHECK);
+            fInInclude.setText(RenameMessages.CRenameRefactoringInputPage_button_includes);
+        }
+        if (hasOption(CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE)) {
+            group= createLabelAndGroup(group, skippedLine, top);
+            fInPreprocessor= new Button(group, SWT.CHECK);
+            fInPreprocessor.setText(RenameMessages.CRenameRefactoringInputPage_button_preprocessor);
+        }
+
+        if (hasOption(CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH)) {
+               skipLine(top);
+            fExhausiveFileSearch= new Button(top, SWT.CHECK);
+            fExhausiveFileSearch.setText(RenameMessages.CRenameRefactoringInputPage_button_exhaustiveFileSearch);
+            fExhausiveFileSearch.setLayoutData(gd= new GridData());
+               gd.horizontalIndent= 5;
+               gd.horizontalSpan= 2;
+       }
+
+        Dialog.applyDialogFont(top);
+        hookSelectionListeners();
+        readPreferences();
+        onSelectOption();      // transfers the option to the refactoring / enablement
+        updatePageComplete();
+    }
+
+    private Composite createLabelAndGroup(Composite group, boolean skippedLine, Composite top) {
+        if (group != null) {
+            return group;
+        }
+        if (!skippedLine) {
+            skipLine(top);
+        }
+        GridData gd;
+        Label label = new Label(top, SWT.NONE);
+        label.setText(RenameMessages.CRenameRefactoringInputPage_label_updateWithin);
+        label.setLayoutData(gd= new GridData());
+        gd.horizontalSpan= 2;
+        group= new Composite(top, SWT.NONE);
+        group.setLayoutData(gd= new GridData());
+        gd.horizontalSpan= 2;
+        group.setLayout(new GridLayout(1, true));
+        return group;
+    }
+
+    private void skipLine(Composite top) {
+        new Label(top, SWT.NONE);
+        new Label(top, SWT.NONE);
+    }
+
+    private void hookSelectionListeners() {
+       fNewName.addModifyListener(new ModifyListener() {
+               
+                       public void modifyText(ModifyEvent e) {
+                               onKeyReleaseInNameField();
+                       }
+               });
+
+        registerScopeListener(fWorkspace, TextSearchWrapper.SCOPE_WORKSPACE);
+        registerScopeListener(fDependent, TextSearchWrapper.SCOPE_RELATED_PROJECTS);
+        registerScopeListener(fSingle, TextSearchWrapper.SCOPE_SINGLE_PROJECT);
+        registerScopeListener(fWorkingSet, TextSearchWrapper.SCOPE_WORKING_SET);
+            
+        if (fWorkingSetButton != null) {    
+            fWorkingSetButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                               public void widgetSelected(SelectionEvent e) {
+                    onSelectWorkingSet();
+                }
+            });
+        }
+        SelectionListener listenOption= new SelectionAdapter() {
+            @Override
+                       public void widgetSelected(SelectionEvent e) {
+                onSelectOption();
+            }
+        };
+        registerOptionListener(fDoVirtual, listenOption);
+        registerOptionListener(fReferences, listenOption);
+        registerOptionListener(fInComment, listenOption);
+        registerOptionListener(fInInactiveCode, listenOption);
+        registerOptionListener(fInInclude, listenOption);
+        registerOptionListener(fInMacro, listenOption);
+        registerOptionListener(fInString, listenOption);
+        registerOptionListener(fInPreprocessor, listenOption);
+        registerOptionListener(fExhausiveFileSearch, listenOption);
+    }
+
+    private void registerScopeListener(Button button, final int scope) {
+        if (button != null) {
+            button.addSelectionListener(new SelectionAdapter() {
+                @Override
+                               public void widgetSelected(SelectionEvent e) {
+                    onSelectedScope(scope);
+                }
+            });
+        }
+    }
+
+    private void registerOptionListener(Button button, SelectionListener listenOption) {
+        if (button != null) {
+            button.addSelectionListener(listenOption);
+        }
+    }
+
+    protected void onSelectedScope(int scope) {
+        getRenameProcessor().setScope(scope);
+        updateEnablement();
+    }
+
+    private void onSelectOption() {
+        int selectedOptions= computeSelectedOptions();
+        boolean forcePreview= fForcePreviewOptions == -1 ||
+                               (selectedOptions & fForcePreviewOptions) != 0;
+        getRenameProcessor().setSelectedOptions(selectedOptions);
+        getRefactoringWizard().setForcePreviewReview(forcePreview);
+        updateEnablement();
+    }            
+
+    protected void onKeyReleaseInNameField() {
+        getRenameProcessor().setReplacementText(fNewName.getText());
+        updatePageComplete();
+    }
+
+    @Override
+       public void dispose() {
+        storePreferences();
+        super.dispose();
+    }
+    
+    private void readPreferences() {
+        CRenameProcessor processor= getRenameProcessor();
+        
+        if (fWorkspace != null) {
+            int scope = fPreferences.getScope();
+            
+            switch (scope) {
+            case TextSearchWrapper.SCOPE_WORKSPACE:
+                fWorkspace.setSelection(true);
+                break;
+            case TextSearchWrapper.SCOPE_SINGLE_PROJECT:
+                fSingle.setSelection(true);
+                break;
+            case TextSearchWrapper.SCOPE_WORKING_SET:
+                fWorkingSet.setSelection(true);
+                break;
+            default:
+                scope= TextSearchWrapper.SCOPE_RELATED_PROJECTS;
+                fDependent.setSelection(true);
+                break;
+            }
+            processor.setScope(scope);
+       
+            String workingSet= fPreferences.getWorkingSet();
+           processor.setWorkingSet(workingSet);  // CRenameProcessor validates the working set name.
+            fWorkingSetSpec.setText(processor.getWorkingSet());
+        }
+        
+        if (fDoVirtual != null) {
+            boolean val= !fPreferences.getBoolean(CRenameRefactoringPreferences.KEY_IGNORE_VIRTUAL);
+            fDoVirtual.setSelection(val);
+        }
+        if (fReferences != null) {
+            boolean val= !fPreferences.getBoolean(CRenameRefactoringPreferences.KEY_REFERENCES_INV);
+            fReferences.setSelection(val);
+        }
+        initOption(fInComment, CRenameRefactoringPreferences.KEY_COMMENT);
+        initOption(fInString, CRenameRefactoringPreferences.KEY_STRING);
+        initOption(fInInclude, CRenameRefactoringPreferences.KEY_INCLUDE);
+        initOption(fInMacro, CRenameRefactoringPreferences.KEY_MACRO_DEFINITION);
+        initOption(fInPreprocessor, CRenameRefactoringPreferences.KEY_PREPROCESSOR);
+        initOption(fInInactiveCode, CRenameRefactoringPreferences.KEY_INACTIVE);
+        initOption(fExhausiveFileSearch, CRenameRefactoringPreferences.KEY_EXHAUSTIVE_FILE_SEARCH);
+    }
+
+    private int computeSelectedOptions() {
+        int options= 0;
+        options |= computeOption(fDoVirtual, CRefactory.OPTION_DO_VIRTUAL);
+        options |= computeOption(fReferences, CRefactory.OPTION_IN_CODE);
+        options |= computeOption(fInComment, CRefactory.OPTION_IN_COMMENT);
+        options |= computeOption(fInString, CRefactory.OPTION_IN_STRING_LITERAL);
+        options |= computeOption(fInInclude, CRefactory.OPTION_IN_INCLUDE_DIRECTIVE);
+        options |= computeOption(fInMacro, CRefactory.OPTION_IN_MACRO_DEFINITION);
+        options |= computeOption(fInPreprocessor, CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE);
+        options |= computeOption(fInInactiveCode, CRefactory.OPTION_IN_INACTIVE_CODE);
+        options |= computeOption(fExhausiveFileSearch, CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH);
+        return options;
+    }
+
+    private int computeOption(Button button, int option) {
+        if (button != null && button.getSelection()) {
+            return option;
+        }
+        return 0;
+    }
+
+    private void initOption(Button button, String key) {
+        boolean val= false;
+        if (button != null) {
+            val= fPreferences.getBoolean(key);
+            button.setSelection(val);
+        }
+    }
+
+    private void storePreferences() {
+        if (fWorkspace != null) {
+            int choice= TextSearchWrapper.SCOPE_RELATED_PROJECTS;
+            if (fWorkspace.getSelection()) {
+                choice= TextSearchWrapper.SCOPE_WORKSPACE;
+            } else if (fSingle.getSelection()) {
+                choice= TextSearchWrapper.SCOPE_SINGLE_PROJECT;
+            } else if (fWorkingSet.getSelection()) {
+                choice= TextSearchWrapper.SCOPE_WORKING_SET;   
+            }
+            fPreferences.put(CRenameRefactoringPreferences.KEY_SCOPE, choice);
+            fPreferences.put(CRenameRefactoringPreferences.KEY_WORKING_SET_NAME, fWorkingSetSpec.getText());
+        }
+        if (fDoVirtual != null) {
+            fPreferences.put(CRenameRefactoringPreferences.KEY_IGNORE_VIRTUAL, !fDoVirtual.getSelection());
+        }
+        if (fReferences != null) {
+            fPreferences.put(CRenameRefactoringPreferences.KEY_REFERENCES_INV, !fReferences.getSelection());
+        }
+        if (fInComment != null) {
+            fPreferences.put(CRenameRefactoringPreferences.KEY_COMMENT, fInComment.getSelection());
+        }
+        if (fInString != null) {
+            fPreferences.put(CRenameRefactoringPreferences.KEY_STRING, fInString.getSelection());
+        }
+        if (fInInclude != null) {
+            fPreferences.put(CRenameRefactoringPreferences.KEY_INCLUDE, fInInclude.getSelection());
+        }
+        if (fInPreprocessor != null) {
+            fPreferences.put(CRenameRefactoringPreferences.KEY_PREPROCESSOR, fInPreprocessor.getSelection());
+        }
+        if (fInMacro != null) {
+            fPreferences.put(CRenameRefactoringPreferences.KEY_MACRO_DEFINITION, fInMacro.getSelection());
+        }
+        if (fInInactiveCode != null) {
+            fPreferences.put(CRenameRefactoringPreferences.KEY_INACTIVE, fInInactiveCode.getSelection());
+        }
+        if (fExhausiveFileSearch != null) {
+            fPreferences.put(CRenameRefactoringPreferences.KEY_EXHAUSTIVE_FILE_SEARCH, fExhausiveFileSearch.getSelection());
+        }
+    }
+
+    protected void onSelectWorkingSet() {
+               CRenameProcessor processor= getRenameProcessor();
+        String wsName= fWorkingSetSpec.getText();
+               IWorkingSetManager wsManager= PlatformUI.getWorkbench().getWorkingSetManager();
+               IWorkingSetSelectionDialog dlg= 
+                   wsManager.createWorkingSetSelectionDialog(getShell(), false);
+               IWorkingSet currentWorkingSet= wsManager.getWorkingSet(wsName);
+               if (currentWorkingSet != null) {
+                       dlg.setSelection(new IWorkingSet[] { currentWorkingSet });
+               }
+               IWorkingSet ws= null;
+               if (dlg.open() == Window.OK) {
+                       IWorkingSet wsa[]= dlg.getSelection();
+                       if (wsa != null && wsa.length > 0) {
+                               ws= wsa[0];
+                       }
+                       if (ws != null) {
+                           fWorkspace.setSelection(false);
+                           fDependent.setSelection(false);
+                           fSingle.setSelection(false);
+                           fWorkingSet.setSelection(true);
+                           processor.setScope(TextSearchWrapper.SCOPE_WORKING_SET);
+                           wsName= ws.getName();
+                       }
+               }
+           
+           processor.setWorkingSet(wsName);  // CRenameProcessor validates the working set name.
+               fWorkingSetSpec.setText(processor.getWorkingSet());
+           updateEnablement();
+    }
+
+    protected void updatePageComplete() {
+        String txt= fNewName.getText();
+        if (txt.length() == 0 || txt.equals(fSearchString)) {
+               setErrorMessage(null);
+               setPageComplete(false);
+        } else if (!CConventions.isValidIdentifier(txt)) {
+               setErrorMessage(NLS.bind(RenameMessages.CRenameRefactoringInputPage_errorInvalidIdentifier, txt));
+               setPageComplete(false);
+        } else {
+               setErrorMessage(null);
+               setPageComplete(true);
+        }
+    }
+
+    protected void updateEnablement() {
+        boolean enable= fEnableScopeOptions == -1 ||
+                       (computeSelectedOptions() & fEnableScopeOptions) != 0;
+        
+        if (fWorkspace != null) {
+            fWorkspace.setEnabled(enable);
+            fDependent.setEnabled(enable);
+            fSingle.setEnabled(enable);
+
+            boolean enableSpec= false;
+            fWorkingSet.setEnabled(enable);
+            if (enable && fWorkingSet.getSelection()) {
+                enableSpec= true;
+            }
+            fWorkingSetSpec.setEnabled(enableSpec);
+            fWorkingSetButton.setEnabled(enable);
+        }
+    }
+    
+    private CRenameProcessor getRenameProcessor() {
+        return (CRenameProcessor) ((CRenameRefactoring) getRefactoring()).getProcessor();
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringPreferences.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringPreferences.java
new file mode 100644 (file)
index 0000000..1aa3681
--- /dev/null
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Google, Inc and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *        Sergey Prigogin (Google) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+import org.eclipse.jface.dialogs.IDialogSettings;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+public class CRenameRefactoringPreferences {
+       private static final String DIALOG_SETTINGS_KEY = "CRenameRefactoringInputPage"; //$NON-NLS-1$
+
+    public static final String KEY_IGNORE_VIRTUAL = "ignoreVirtual"; //$NON-NLS-1$
+    public static final String KEY_REFERENCES_INV = "references_inv"; //$NON-NLS-1$
+    public static final String KEY_COMMENT = "comment"; //$NON-NLS-1$
+    public static final String KEY_STRING = "string"; //$NON-NLS-1$
+    public static final String KEY_INACTIVE = "inactive"; //$NON-NLS-1$
+    public static final String KEY_SCOPE = "scope"; //$NON-NLS-1$
+    public static final String KEY_WORKING_SET_NAME = "workingset"; //$NON-NLS-1$
+
+    public static final String KEY_INCLUDE = "include"; //$NON-NLS-1$
+    public static final String KEY_MACRO_DEFINITION = "macroDefinition"; //$NON-NLS-1$
+    public static final String KEY_PREPROCESSOR = "preprocessor"; //$NON-NLS-1$
+    public static final String KEY_EXHAUSTIVE_FILE_SEARCH = "exhausiveFileSearch"; //$NON-NLS-1$
+
+    private IDialogSettings fDialogSettings;
+
+    public CRenameRefactoringPreferences() {
+               super();
+        IDialogSettings ds= CUIPlugin.getDefault().getDialogSettings();
+        fDialogSettings= ds.getSection(DIALOG_SETTINGS_KEY);
+        if (fDialogSettings == null) {
+            fDialogSettings= ds.addNewSection(DIALOG_SETTINGS_KEY);
+        }
+       }
+
+       public boolean getBoolean(String key) {
+               return fDialogSettings.getBoolean(key);
+       }
+
+       public void put(String key, int value) {
+               fDialogSettings.put(key, value);
+       }
+
+       public void put(String key, String value) {
+               fDialogSettings.put(key, value);
+       }
+
+       public void put(String key, boolean value) {
+               fDialogSettings.put(key, value);
+       }
+
+       public int getScope() {
+           try {
+               return fDialogSettings.getInt(KEY_SCOPE);
+           } catch (Exception e) {
+               return TextSearchWrapper.SCOPE_RELATED_PROJECTS;
+           }
+       }
+
+       public String getWorkingSet() {
+               return fDialogSettings.get(KEY_WORKING_SET_NAME);
+       }
+
+       public int getOptions() {
+        int options= 0;
+        if (!getBoolean(KEY_IGNORE_VIRTUAL))
+               options |= CRefactory.OPTION_DO_VIRTUAL;
+        if (!getBoolean(KEY_REFERENCES_INV))
+               options |= CRefactory.OPTION_IN_CODE;
+        if (getBoolean(KEY_COMMENT))
+               options |= CRefactory.OPTION_IN_COMMENT;
+        if (getBoolean(KEY_STRING))
+               options |= CRefactory.OPTION_IN_STRING_LITERAL;
+        if (getBoolean(KEY_INCLUDE))
+               options |= CRefactory.OPTION_IN_INCLUDE_DIRECTIVE;
+        if (getBoolean(KEY_MACRO_DEFINITION))
+               options |= CRefactory.OPTION_IN_MACRO_DEFINITION;
+        if (getBoolean(KEY_PREPROCESSOR))
+               options |= CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE;
+        if (getBoolean(KEY_INACTIVE))
+               options |= CRefactory.OPTION_IN_INACTIVE_CODE;
+        if (getBoolean(KEY_EXHAUSTIVE_FILE_SEARCH))
+               options |= CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH;
+        return options;
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringWizard.java
new file mode 100644 (file)
index 0000000..788ccd1
--- /dev/null
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ * Markus Schorn - initial API and implementation 
+ ******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
+
+/**
+ * Refactoring Wizard adding the input page.
+ */
+public class CRenameRefactoringWizard extends RefactoringWizard {
+
+    public CRenameRefactoringWizard(CRenameRefactoring r) {
+        super(r, DIALOG_BASED_USER_INTERFACE);
+    }
+
+    // overrider
+    @Override
+       protected void addUserInputPages() {
+        setDefaultPageTitle(getRefactoring().getName());
+        CRenameRefactoringInputPage page= new CRenameRefactoringInputPage();
+        addPage(page);
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameTypeProcessor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameTypeProcessor.java
new file mode 100644 (file)
index 0000000..97c094a
--- /dev/null
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 Wind River Systems, Inc. and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ * Markus Schorn - initial API and implementation 
+ ******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+/**
+ * Handles conflicting bindings for types.
+ */
+public class CRenameTypeProcessor extends CRenameGlobalProcessor {
+
+    public CRenameTypeProcessor(CRenameProcessor processor, String kind) {
+        super(processor, kind);
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameCSourceFolderChange.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameCSourceFolderChange.java
new file mode 100644 (file)
index 0000000..bb9b1c7
--- /dev/null
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ * Institute for Software (IFS)- initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+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.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.osgi.util.NLS;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.settings.model.CSourceEntry;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICSourceEntry;
+import org.eclipse.cdt.core.settings.model.WriteAccessException;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * @author Emanuel Graf IFS
+ */
+public class RenameCSourceFolderChange extends Change {
+       private IPath oldName;
+       private IPath newName;
+       private IProject project;
+       private IFolder folder;
+
+       public RenameCSourceFolderChange(IPath oldFolderPath, IPath newFolderPath, IProject project, IFolder oldFolder) {
+               super();
+               this.oldName = oldFolderPath;
+               this.newName = newFolderPath;
+               this.project = project;
+               folder = oldFolder;
+       }
+
+       @Override
+       public Object getModifiedElement() {
+               return folder;
+       }
+
+       @Override
+       public String getName() {
+               return NLS.bind(RenameMessages.RenameCSourceFolderChange_Name0, oldName.lastSegment(), newName.lastSegment());
+       }
+
+       @Override
+       public void initializeValidationData(IProgressMonitor pm) {
+       }
+
+       @Override
+       public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException {
+               if (folder.exists()) {
+                       return RefactoringStatus.create(Status.OK_STATUS); 
+               } else {
+                       return RefactoringStatus.create(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID,
+                                       NLS.bind(RenameMessages.RenameCSourceFolderChange_ErrorMsg, folder.getName())));
+               }
+       }
+
+       @Override
+       public Change perform(IProgressMonitor pm) throws CoreException {
+               changeEntryInAllCfgs(CCorePlugin.getDefault().getProjectDescription(project, true));
+               IFolder folder2 = project.getFolder(newName.lastSegment());
+               return new RenameCSourceFolderChange(newName, oldName, project, folder2);
+       }
+       
+       private void changeEntryInAllCfgs(ICProjectDescription des) throws WriteAccessException, CoreException{
+               ICConfigurationDescription cfgs[] = des.getConfigurations();
+               for (ICConfigurationDescription cfg : cfgs){
+                       ICSourceEntry[] entries = cfg.getSourceEntries();
+                       entries = renameEntry(entries);
+                       cfg.setSourceEntries(entries);
+               }
+               CCorePlugin.getDefault().setProjectDescription(project, des, false, new NullProgressMonitor());
+       }
+       
+       private ICSourceEntry[] renameEntry(ICSourceEntry[] entries){
+               Set<ICSourceEntry> set = new HashSet<ICSourceEntry>();
+               for (ICSourceEntry se : entries){
+                       String seLocation = se.getName();
+                       if(seLocation.equals(oldName.toPortableString())) {
+                               ICSourceEntry newSE = new CSourceEntry(newName, se.getExclusionPatterns(), se.getFlags());
+                               set.add(newSE);
+                       } else {
+                               Set<IPath> exPatters = new HashSet<IPath>();
+                               for (IPath filter : se.getExclusionPatterns()) {
+                                       IPath oldSegments = oldName.removeFirstSegments(oldName.segmentCount() -1);
+                                       if (filter.equals(oldSegments)) {
+                                               exPatters.add(newName.removeFirstSegments(newName.segmentCount() - 1));
+                                       } else {
+                                               exPatters.add(filter);
+                                       }
+                               }
+                               
+                               set.add(new CSourceEntry(se.getValue(), exPatters.toArray(new IPath[exPatters.size()]), se.getFlags()));
+                       }
+               }
+               return set.toArray(new ICSourceEntry[set.size()]);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformationPopup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformationPopup.java
new file mode 100644 (file)
index 0000000..9b9fa47
--- /dev/null
@@ -0,0 +1,856 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyleRange;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.ShellAdapter;
+import org.eclipse.swt.events.ShellEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.graphics.Region;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+import org.eclipse.swt.widgets.Tracker;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuListener2;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.bindings.keys.IKeyLookup;
+import org.eclipse.jface.bindings.keys.KeyLookupFactory;
+import org.eclipse.jface.bindings.keys.KeyStroke;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.util.Geometry;
+import org.eclipse.jface.util.Util;
+
+import org.eclipse.jface.text.ITextListener;
+import org.eclipse.jface.text.ITextViewerExtension5;
+import org.eclipse.jface.text.IViewportListener;
+import org.eclipse.jface.text.IWidgetTokenKeeper;
+import org.eclipse.jface.text.IWidgetTokenKeeperExtension;
+import org.eclipse.jface.text.IWidgetTokenOwner;
+import org.eclipse.jface.text.IWidgetTokenOwnerExtension;
+import org.eclipse.jface.text.TextEvent;
+import org.eclipse.jface.text.link.LinkedPosition;
+import org.eclipse.jface.text.source.ISourceViewer;
+
+import org.eclipse.ui.IPartListener2;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartReference;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.eclipse.ui.keys.IBindingService;
+import org.eclipse.ui.progress.UIJob;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
+import org.eclipse.cdt.internal.ui.preferences.CPluginPreferencePage;
+
+public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenKeeperExtension {
+
+       private class PopupVisibilityManager implements IPartListener2, ControlListener, MouseListener, KeyListener, ITextListener, IViewportListener {
+
+               public void start() {
+                       fEditor.getSite().getWorkbenchWindow().getPartService().addPartListener(this);
+                       final ISourceViewer viewer= fEditor.getViewer();
+                       final StyledText textWidget= viewer.getTextWidget();
+                       textWidget.addControlListener(this);
+                       textWidget.addMouseListener(this);
+                       textWidget.addKeyListener(this);
+                       fEditor.getSite().getShell().addControlListener(this);
+                       viewer.addTextListener(this);
+                       viewer.addViewportListener(this);
+                       fPopup.addDisposeListener(new DisposeListener() {
+                               public void widgetDisposed(DisposeEvent e) {
+                                       fEditor.getSite().getWorkbenchWindow().getPartService().removePartListener(PopupVisibilityManager.this);
+                                       if (!textWidget.isDisposed()) {
+                                               textWidget.removeControlListener(PopupVisibilityManager.this);
+                                               textWidget.removeMouseListener(PopupVisibilityManager.this);
+                                               textWidget.removeKeyListener(PopupVisibilityManager.this);
+                                       }
+                                       fEditor.getSite().getShell().removeControlListener(PopupVisibilityManager.this);
+                                       viewer.removeTextListener(PopupVisibilityManager.this);
+                                       viewer.removeViewportListener(PopupVisibilityManager.this);
+                                       if (fMenuImage != null) {
+                                               fMenuImage.dispose();
+                                               fMenuImage= null;
+                                       }
+                                       if (fMenuManager != null) {
+                                               fMenuManager.dispose();
+                                               fMenuManager= null;
+                                       }
+                                       fRenameLinkedMode.cancel();
+                               }
+                       });
+               }
+
+               public void partActivated(IWorkbenchPartReference partRef) {
+                       IWorkbenchPart fPart= fEditor.getEditorSite().getPart();
+                       if (partRef.getPart(false) == fPart) {
+                               updateVisibility();
+                       }
+               }
+
+               public void partBroughtToTop(IWorkbenchPartReference partRef) {
+               }
+
+               public void partClosed(IWorkbenchPartReference partRef) {
+               }
+
+               public void partDeactivated(IWorkbenchPartReference partRef) {
+                       IWorkbenchPart fPart= fEditor.getEditorSite().getPart();
+                       if (fPopup != null && !fPopup.isDisposed() && partRef.getPart(false) == fPart) {
+                               fPopup.setVisible(false);
+                       }
+               }
+
+               public void partHidden(IWorkbenchPartReference partRef) {
+               }
+
+               public void partInputChanged(IWorkbenchPartReference partRef) {
+               }
+
+               public void partOpened(IWorkbenchPartReference partRef) {
+               }
+
+               public void partVisible(IWorkbenchPartReference partRef) {
+               }
+
+               public void controlMoved(ControlEvent e) {
+                       updatePopupLocation(true);
+                       updateVisibility(); //only for hiding outside editor area
+               }
+
+               public void controlResized(ControlEvent e) {
+                       updatePopupLocation(true);
+                       updateVisibility(); //only for hiding outside editor area
+               }
+
+               public void mouseDoubleClick(MouseEvent e) {
+               }
+
+               public void mouseDown(MouseEvent e) {
+               }
+
+               public void mouseUp(MouseEvent e) {
+                       updatePopupLocation(false);
+                       updateVisibility();
+               }
+
+               public void keyPressed(KeyEvent e) {
+                       updatePopupLocation(false);
+                       updateVisibility();
+               }
+
+               public void keyReleased(KeyEvent e) {
+               }
+
+               public void textChanged(TextEvent event) {
+                       if (!event.getViewerRedrawState())
+                               return;
+                       updatePopupLocation(false);
+                       updateVisibility(); //only for hiding outside editor area
+               }
+
+               public void viewportChanged(int verticalOffset) {
+                       updatePopupLocation(true);
+                       updateVisibility(); //only for hiding outside editor area
+               }
+       }
+
+       /**
+        * Cached platform flag for dealing with platform-specific issue:
+        * https://bugs.eclipse.org/bugs/show_bug.cgi?id=219326 : Shell with custom region and SWT.NO_TRIM still has border
+        */
+       private static boolean MAC = Util.isMac();
+
+       private static final int WIDGET_PRIORITY= 1000;
+
+       private static final String DIALOG_SETTINGS_SECTION= "RenameInformationPopup"; //$NON-NLS-1$
+       private static final String SNAP_POSITION_KEY= "snap_position"; //$NON-NLS-1$
+
+       private static final int SNAP_POSITION_UNDER_RIGHT_FIELD= 0;
+       private static final int SNAP_POSITION_OVER_RIGHT_FIELD= 1;
+       private static final int SNAP_POSITION_UNDER_LEFT_FIELD= 2;
+       private static final int SNAP_POSITION_OVER_LEFT_FIELD= 3;
+       private static final int SNAP_POSITION_LOWER_RIGHT= 4;
+
+       private static final int POPUP_VISIBILITY_DELAY= 300;
+
+       /**
+        * Offset of info hover arrow from the left or right side.
+        */
+       private static final int HAO= 10;
+
+       /**
+        * Width of info hover arrow.
+        */
+       private static final int HAW= 8;
+
+       /**
+        * Height of info hover arrow.
+        */
+       private static final int HAH= 10;
+
+       /**
+        * Gap between linked position and popup.
+        */
+       private static final int GAP= 2;
+
+       private final CEditor fEditor;
+       private final RenameLinkedMode fRenameLinkedMode;
+
+       private int fSnapPosition;
+       private boolean fSnapPositionChanged;
+       private Shell fPopup;
+       private GridLayout fPopupLayout;
+       private Region fRegion;
+
+       private Image fMenuImage;
+       private MenuManager fMenuManager;
+       private ToolBar fToolBar;
+       private String fOpenDialogBinding= ""; //$NON-NLS-1$
+       private boolean fIsMenuUp= false;
+
+       private boolean fDelayJobFinished= false;
+
+       public RenameInformationPopup(CEditor editor, RenameLinkedMode renameLinkedMode) {
+               fEditor= editor;
+               fRenameLinkedMode= renameLinkedMode;
+               restoreSnapPosition();
+       }
+
+       private void restoreSnapPosition() {
+               IDialogSettings settings= getDialogSettings();
+               try {
+                       fSnapPosition= settings.getInt(SNAP_POSITION_KEY);
+               } catch (NumberFormatException e) {
+                       // default:
+                       fSnapPosition= SNAP_POSITION_UNDER_LEFT_FIELD;
+               }
+               fSnapPositionChanged= true;
+       }
+
+       private IDialogSettings getDialogSettings() {
+               return CUIPlugin.getDefault().getDialogSettingsSection(DIALOG_SETTINGS_SECTION);
+       }
+
+       public void open() {
+               // Must cache here, since editor context is not available in menu from popup shell:
+               fOpenDialogBinding= getOpenDialogBinding();
+
+               Shell workbenchShell= fEditor.getSite().getShell();
+               final Display display= workbenchShell.getDisplay();
+
+               fPopup= new Shell(workbenchShell, SWT.ON_TOP | SWT.NO_TRIM | SWT.TOOL);
+               fPopupLayout= new GridLayout(2, false);
+               fPopupLayout.marginWidth= 1;
+               fPopupLayout.marginHeight= 1;
+               fPopupLayout.marginLeft= 4;
+               fPopupLayout.horizontalSpacing= 0;
+               fPopup.setLayout(fPopupLayout);
+
+               createContent(fPopup);
+               updatePopupLocation(true);
+               new PopupVisibilityManager().start();
+
+               // Leave linked mode when popup loses focus
+               // (except when focus goes back to workbench window or menu is open):
+               fPopup.addShellListener(new ShellAdapter() {
+                       @Override
+                       public void shellDeactivated(ShellEvent e) {
+                               if (fIsMenuUp)
+                                       return;
+
+                               final Shell editorShell= fEditor.getSite().getShell();
+                               display.asyncExec(new Runnable() {
+                                       // post to UI thread since editor shell only gets activated after popup has lost focus
+                                       public void run() {
+                                               Shell activeShell= display.getActiveShell();
+                                               if (activeShell != editorShell) {
+                                                       fRenameLinkedMode.cancel();
+                                               }
+                                       }
+                               });
+                       }
+               });
+
+               if (!MAC) { // carbon and cocoa draw their own border...
+                       fPopup.addPaintListener(new PaintListener() {
+                               public void paintControl(PaintEvent pe) {
+                                       pe.gc.drawPolygon(getPolygon(true));
+                               }
+                       });
+               }
+
+//             fPopup.moveBelow(null); // make sure hovers are on top of the info popup
+//             XXX workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=170774
+//             fPopup.moveBelow(workbenchShell.getShells()[0]);
+
+               UIJob delayJob= new UIJob(display, RenameMessages.RenameInformationPopup_delayJobName) {
+                       @Override
+                       public IStatus runInUIThread(IProgressMonitor monitor) {
+                               fDelayJobFinished= true;
+                               if (fPopup != null && !fPopup.isDisposed()) {
+                                       updateVisibility();
+                               }
+                               return Status.OK_STATUS;
+                       }
+               };
+               delayJob.setSystem(true);
+               delayJob.setPriority(Job.INTERACTIVE);
+               delayJob.schedule(POPUP_VISIBILITY_DELAY);
+       }
+
+       public void close() {
+               if (fPopup != null) {
+                       if (!fPopup.isDisposed()) {
+                               fPopup.close();
+                       }
+                       fPopup= null;
+               }
+               releaseWidgetToken();
+               if (fRegion != null) {
+                       if (!fRegion.isDisposed()) {
+                               fRegion.dispose();
+                       }
+               }
+       }
+
+       public Shell getShell() {
+               return fPopup;
+       }
+
+       private void updatePopupLocation(boolean force) {
+               if (!force && fSnapPosition == SNAP_POSITION_LOWER_RIGHT)
+                       return;
+
+               packPopup();
+               Point loc= computePopupLocation(fSnapPosition);
+               if (loc != null && !loc.equals(fPopup.getLocation())) {
+                       fPopup.setLocation(loc);
+                       // XXX workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=170774
+//                     fPopup.moveBelow(fEditor.getSite().getShell().getShells()[0]);
+               }
+       }
+
+       private void updateVisibility() {
+               if (fPopup != null && !fPopup.isDisposed() && fDelayJobFinished) {
+                       boolean visible= false;
+                       //TODO: Check for visibility of linked position, not whether popup is outside of editor?
+                       if (fRenameLinkedMode.isCaretInLinkedPosition()) {
+                               StyledText textWidget= fEditor.getViewer().getTextWidget();
+                               Rectangle eArea= Geometry.toDisplay(textWidget, textWidget.getClientArea());
+                               Rectangle pBounds= fPopup.getBounds();
+                               pBounds.x -= GAP;
+                               pBounds.y -= GAP;
+                               pBounds.width += 2 * GAP;
+                               pBounds.height += 2 * GAP;
+                               if (eArea.intersects(pBounds)) {
+                                       visible= true;
+                               }
+                       }
+                       if (visible && !fPopup.isVisible()) {
+                               ISourceViewer viewer= fEditor.getViewer();
+                               if (viewer instanceof IWidgetTokenOwnerExtension) {
+                                       IWidgetTokenOwnerExtension widgetTokenOwnerExtension= (IWidgetTokenOwnerExtension) viewer;
+                                       widgetTokenOwnerExtension.requestWidgetToken(this, WIDGET_PRIORITY);
+                               }
+                       } else if (!visible && fPopup.isVisible()) {
+                               releaseWidgetToken();
+                       }
+                       fPopup.setVisible(visible);
+               }
+       }
+
+       private void releaseWidgetToken() {
+               ISourceViewer viewer= fEditor.getViewer();
+               if (viewer instanceof IWidgetTokenOwner) {
+                       IWidgetTokenOwner widgetTokenOwner= (IWidgetTokenOwner) viewer;
+                       widgetTokenOwner.releaseWidgetToken(this);
+               }
+       }
+
+       /**
+        * @param snapPosition one of the SNAP_POSITION_* constants
+        * @return the location in display coordinates or <code>null</code> iff not visible
+        */
+       private Point computePopupLocation(int snapPosition) {
+               if (fPopup == null || fPopup.isDisposed())
+                       return null;
+
+               switch (snapPosition) {
+                       case SNAP_POSITION_LOWER_RIGHT:
+                       {
+                               StyledText eWidget= fEditor.getViewer().getTextWidget();
+                               Rectangle eBounds= eWidget.getClientArea();
+                               Point eLowerRight= eWidget.toDisplay(eBounds.x + eBounds.width, eBounds.y + eBounds.height);
+                               Point pSize= getExtent();
+                               return new Point(eLowerRight.x - pSize.x - 5, eLowerRight.y - pSize.y - 5);
+                       }
+
+                       case SNAP_POSITION_UNDER_RIGHT_FIELD:
+                       case SNAP_POSITION_OVER_RIGHT_FIELD:
+                       {
+                               LinkedPosition position= fRenameLinkedMode.getCurrentLinkedPosition();
+                               if (position == null)
+                                       return null;
+                               ISourceViewer viewer= fEditor.getViewer();
+                               ITextViewerExtension5 viewer5= (ITextViewerExtension5) viewer;
+                               int widgetOffset= viewer5.modelOffset2WidgetOffset(position.offset + position.length);
+
+                               StyledText textWidget= viewer.getTextWidget();
+                               Point pos= textWidget.getLocationAtOffset(widgetOffset);
+                               Point pSize= getExtent();
+                               if (snapPosition == SNAP_POSITION_OVER_RIGHT_FIELD) {
+                                       pos.y-= pSize.y + GAP;
+                               } else {
+                                       pos.y+= textWidget.getLineHeight(widgetOffset) + GAP;
+                               }
+                               pos.x+= GAP;
+                               Point dPos= textWidget.toDisplay(pos);
+                               Rectangle displayBounds= textWidget.getDisplay().getClientArea();
+                               Rectangle dPopupRect= Geometry.createRectangle(dPos, pSize);
+                               Geometry.moveInside(dPopupRect, displayBounds);
+                               return new Point(dPopupRect.x, dPopupRect.y);
+                       }
+
+                       case SNAP_POSITION_UNDER_LEFT_FIELD:
+                       case SNAP_POSITION_OVER_LEFT_FIELD:
+                       default: // same as SNAP_POSITION_UNDER_LEFT_FIELD
+                       {
+                               LinkedPosition position= fRenameLinkedMode.getCurrentLinkedPosition();
+                               if (position == null)
+                                       return null;
+                               ISourceViewer viewer= fEditor.getViewer();
+                               ITextViewerExtension5 viewer5= (ITextViewerExtension5) viewer;
+                               int widgetOffset= viewer5.modelOffset2WidgetOffset(position.offset/* + position.length*/);
+
+                               StyledText textWidget= viewer.getTextWidget();
+                               Point pos= textWidget.getLocationAtOffset(widgetOffset);
+                               Point pSize= getExtent();
+                               pSize.y+= HAH + 1;
+                               pos.x-= HAO;
+                               if (snapPosition == SNAP_POSITION_OVER_LEFT_FIELD) {
+                                       pos.y-= pSize.y;
+                               } else {
+                                       pos.y+= textWidget.getLineHeight(widgetOffset);
+                               }
+                               Point dPos= textWidget.toDisplay(pos);
+                               Rectangle displayBounds= textWidget.getDisplay().getClientArea();
+                               Rectangle dPopupRect= Geometry.createRectangle(dPos, pSize);
+                               Geometry.moveInside(dPopupRect, displayBounds);
+                               return new Point(dPopupRect.x, dPopupRect.y);
+                       }
+               }
+       }
+
+       private void addMoveSupport(final Shell popupShell, final Control movedControl) {
+               movedControl.addMouseListener(new MouseAdapter() {
+
+                       @Override
+                       public void mouseDown(final MouseEvent downEvent) {
+                               if (downEvent.button != 1) {
+                                       return;
+                               }
+
+                               final Point POPUP_SOURCE= popupShell.getLocation();
+                               final StyledText textWidget= fEditor.getViewer().getTextWidget();
+                               Point pSize= getExtent();
+                               int originalSnapPosition= fSnapPosition;
+
+                               /*
+                                * Feature in Tracker: it is not possible to directly control the feedback,
+                                * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=121300
+                                * and https://bugs.eclipse.org/bugs/show_bug.cgi?id=121298#c1 .
+                                *
+                                * Workaround is to have an offscreen rectangle for tracking mouse movement
+                                * and a manually updated rectangle for the actual drop target.
+                                */
+                               final Tracker tracker= new Tracker(textWidget, SWT.NONE);
+
+                               final Point[] LOCATIONS= {
+                                               textWidget.toControl(computePopupLocation(SNAP_POSITION_UNDER_RIGHT_FIELD)),
+                                               textWidget.toControl(computePopupLocation(SNAP_POSITION_OVER_RIGHT_FIELD)),
+                                               textWidget.toControl(computePopupLocation(SNAP_POSITION_UNDER_LEFT_FIELD)),
+                                               textWidget.toControl(computePopupLocation(SNAP_POSITION_OVER_LEFT_FIELD)),
+                                               textWidget.toControl(computePopupLocation(SNAP_POSITION_LOWER_RIGHT))
+                               };
+
+                               final Rectangle[] DROP_TARGETS= {
+                                       Geometry.createRectangle(LOCATIONS[0], pSize),
+                                       Geometry.createRectangle(LOCATIONS[1], pSize),
+                                       new Rectangle(LOCATIONS[2].x, LOCATIONS[2].y + HAH, pSize.x, pSize.y),
+                                       Geometry.createRectangle(LOCATIONS[3], pSize),
+                                       Geometry.createRectangle(LOCATIONS[4], pSize)
+                               };
+                               final Rectangle MOUSE_MOVE_SOURCE= new Rectangle(1000000, 0, 0, 0);
+                               tracker.setRectangles(new Rectangle[] { MOUSE_MOVE_SOURCE, DROP_TARGETS[fSnapPosition] });
+                               tracker.setStippled(true);
+
+                               ControlListener moveListener= new ControlAdapter() {
+                                       /*
+                                        * @see org.eclipse.swt.events.ControlAdapter#controlMoved(org.eclipse.swt.events.ControlEvent)
+                                        */
+                                       @Override
+                                       public void controlMoved(ControlEvent moveEvent) {
+                                               Rectangle[] currentRects= tracker.getRectangles();
+                                               final Rectangle mouseMoveCurrent= currentRects[0];
+                                               Point popupLoc= new Point(
+                                                               POPUP_SOURCE.x + mouseMoveCurrent.x - MOUSE_MOVE_SOURCE.x,
+                                                               POPUP_SOURCE.y + mouseMoveCurrent.y - MOUSE_MOVE_SOURCE.y);
+
+                                               popupShell.setLocation(popupLoc);
+
+                                               Point ePopupLoc= textWidget.toControl(popupLoc);
+                                               int minDist= Integer.MAX_VALUE;
+                                               for (int snapPos= 0; snapPos < DROP_TARGETS.length; snapPos++) {
+                                                       int dist= Geometry.distanceSquared(ePopupLoc, LOCATIONS[snapPos]);
+                                                       if (dist < minDist) {
+                                                               minDist= dist;
+                                                               fSnapPosition= snapPos;
+                                                               fSnapPositionChanged= true;
+                                                               currentRects[1]= DROP_TARGETS[snapPos];
+                                                       }
+                                               }
+                                               tracker.setRectangles(currentRects);
+                                       }
+                               };
+                               tracker.addControlListener(moveListener);
+                               boolean committed= tracker.open();
+                               tracker.close();
+                               tracker.dispose();
+                               if (committed) {
+                                       getDialogSettings().put(SNAP_POSITION_KEY, fSnapPosition);
+                               } else {
+                                       fSnapPosition= originalSnapPosition;
+                                       fSnapPositionChanged= true;
+                               }
+                               updatePopupLocation(true);
+                               activateEditor();
+                       }
+               });
+       }
+
+       private void packPopup() {
+               if (!fSnapPositionChanged) {
+                       return;
+               }
+               fSnapPositionChanged= false;
+               
+               boolean isUnderLeft= fSnapPosition == SNAP_POSITION_UNDER_LEFT_FIELD;
+               boolean isOverLeft= fSnapPosition == SNAP_POSITION_OVER_LEFT_FIELD;
+               fPopupLayout.marginTop= isUnderLeft ? HAH : 0;
+               fPopupLayout.marginBottom= isOverLeft ? HAH + 1 : 0;
+               fPopup.pack();
+
+               Region oldRegion= fRegion;
+               if (isUnderLeft || isOverLeft) {
+                       fRegion= new Region();
+                       fRegion.add(getPolygon(false));
+                       fPopup.setRegion(fRegion);
+                       Rectangle bounds= fRegion.getBounds();
+                       fPopup.setSize(bounds.width, bounds.height + 1);
+               } else {
+                       fRegion= null;
+                       fPopup.setRegion(null);
+               }
+
+               if (oldRegion != null) {
+                       oldRegion.dispose();
+               }
+       }
+
+       private Point getExtent() {
+               Point e = fPopup.getSize();
+               switch (fSnapPosition) {
+                       case SNAP_POSITION_UNDER_LEFT_FIELD:
+                               e.y -= HAH;
+                               break;
+                       case SNAP_POSITION_OVER_LEFT_FIELD:
+                               e.y -= HAH + 1;
+                               break;
+               }
+               return e;
+       }
+
+       private int[] getPolygon(boolean border) {
+               Point e = getExtent();
+               int b = border ? 1 : 0;
+               boolean isRTL= (fPopup.getStyle() & SWT.RIGHT_TO_LEFT) != 0;
+               int ha1= isRTL ? e.x - HAO :           HAO + HAW;
+               int ha2= isRTL ? e.x - HAO - HAW / 2 : HAO + HAW / 2;
+               int ha3= isRTL ? e.x - HAO - HAW :     HAO;
+                       int[] poly;
+                       switch (fSnapPosition) {
+                               case SNAP_POSITION_OVER_LEFT_FIELD:
+                                       poly= new int[] {
+                                                       0, 0,
+                                                       e.x - b, 0,
+                                                       e.x - b, e.y - b,
+                                                       ha1, e.y - b,
+                                                       ha2, e.y + HAH - b,
+                                                       ha3, e.y - b,
+                                                       0, e.y - b,
+                                                       0, 0 };
+                                       break;
+
+                               case SNAP_POSITION_UNDER_LEFT_FIELD:
+                                       poly= new int[] {
+                                                       0, HAH,
+                                                       ha3 + b, HAH,
+                                                       ha2, b,
+                                                       ha1 - b, HAH,
+                                                       e.x - b, HAH,
+                                                       e.x - b, e.y + HAH - b,
+                                                       0, e.y + HAH - b,
+                                                       0, HAH };
+                                       break;
+
+                               default:
+                                       poly= new int[] {
+                                                       0, 0,
+                                                       e.x - b, 0,
+                                                       e.x - b, e.y - b,
+                                                       0, e.y - b,
+                                                       0, 0 };
+                                       break;
+                       }
+               return poly;
+       }
+
+       private void createContent(Composite parent) {
+               Display display= parent.getDisplay();
+               Color foreground= display.getSystemColor(SWT.COLOR_INFO_FOREGROUND);
+               Color background= display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
+               addMoveSupport(fPopup, parent);
+
+               StyledText hint= new StyledText(fPopup, SWT.READ_ONLY | SWT.SINGLE);
+               String enterKeyName= getEnterBinding();
+               String hintTemplate= RenameMessages.RenameInformationPopup_EnterNewName;
+               hint.setText(NLS.bind(hintTemplate, enterKeyName));
+               hint.setForeground(foreground);
+               hint.setStyleRange(new StyleRange(hintTemplate.indexOf("{0}"), enterKeyName.length(), null, null, SWT.BOLD)); //$NON-NLS-1$
+               hint.setEnabled(false); // text must not be selectable
+               addMoveSupport(fPopup, hint);
+
+               addViewMenu(parent);
+
+               recursiveSetBackgroundColor(parent, background);
+       }
+
+       private ToolBar addViewMenu(final Composite parent) {
+               fToolBar= new ToolBar(parent, SWT.FLAT);
+               final ToolItem menuButton = new ToolItem(fToolBar, SWT.PUSH, 0);
+               fMenuImage= CPluginImages.DESC_ELCL_VIEW_MENU.createImage();
+               menuButton.setImage(fMenuImage);
+               menuButton.setToolTipText(RenameMessages.RenameInformationPopup_menu);
+               fToolBar.addMouseListener(new MouseAdapter() {
+                       @Override
+                       public void mouseDown(MouseEvent e) {
+                               showMenu(fToolBar);
+                       }
+               });
+               menuButton.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               showMenu(fToolBar);
+                       }
+               });
+               fToolBar.pack();
+               return fToolBar;
+       }
+
+       private void showMenu(ToolBar toolBar) {
+               Menu menu= getMenuManager().createContextMenu(toolBar);
+               menu.setLocation(toolBar.toDisplay(0, toolBar.getSize().y));
+               fIsMenuUp= true;
+               menu.setVisible(true);
+       }
+
+       private MenuManager getMenuManager() {
+               if (fMenuManager != null) {
+                       return fMenuManager;
+               }
+
+               fMenuManager= new MenuManager();
+               fMenuManager.setRemoveAllWhenShown(true);
+
+               fMenuManager.addMenuListener(new IMenuListener2() {
+                       public void menuAboutToHide(IMenuManager manager) {
+                               fIsMenuUp= false;
+                       }
+                       public void menuAboutToShow(IMenuManager manager) {
+                               boolean canRefactor= !fRenameLinkedMode.isOriginalName();
+                               
+                               IAction refactorAction= new Action(RenameMessages.RenameInformationPopup_RenameInWorkspace) {
+                                       @Override
+                                       public void run() {
+                                               activateEditor();
+                                               fRenameLinkedMode.doRename(false);
+                                       }
+                               };
+                               refactorAction.setAccelerator(SWT.CR);
+                               refactorAction.setEnabled(canRefactor);
+                               manager.add(refactorAction);
+
+                               IAction previewAction= new Action(RenameMessages.RenameInformationPopup_Preview) {
+                                       @Override
+                                       public void run() {
+                                               activateEditor();
+                                               fRenameLinkedMode.doRename(true);
+                                       }
+                               };
+                               previewAction.setAccelerator(SWT.CTRL | SWT.CR);
+                               previewAction.setEnabled(canRefactor);
+                               manager.add(previewAction);
+
+                               IAction openDialogAction= new Action(RenameMessages.RenameInformationPopup_OpenDialog + '\t' + fOpenDialogBinding) {
+                                       @Override
+                                       public void run() {
+                                               activateEditor();
+                                               fRenameLinkedMode.startFullDialog();
+                                       }
+                               };
+                               manager.add(openDialogAction);
+
+                               manager.add(new Separator());
+
+                               MenuManager subMenuManager= new MenuManager(RenameMessages.RenameInformationPopup_SnapTo);
+                               addMoveMenuItem(subMenuManager, SNAP_POSITION_UNDER_LEFT_FIELD, RenameMessages.RenameInformationPopup_snap_under_left);
+                               addMoveMenuItem(subMenuManager, SNAP_POSITION_UNDER_RIGHT_FIELD, RenameMessages.RenameInformationPopup_snap_under_right);
+                               addMoveMenuItem(subMenuManager, SNAP_POSITION_OVER_LEFT_FIELD, RenameMessages.RenameInformationPopup_snap_over_left);
+                               addMoveMenuItem(subMenuManager, SNAP_POSITION_OVER_RIGHT_FIELD, RenameMessages.RenameInformationPopup_snap_over_right);
+                               addMoveMenuItem(subMenuManager, SNAP_POSITION_LOWER_RIGHT, RenameMessages.RenameInformationPopup_snap_bottom_right);
+                               manager.add(subMenuManager);
+
+                               IAction prefsAction= new Action(RenameMessages.RenameInformationPopup_preferences) {
+                                       @Override
+                                       public void run() {
+                                               fRenameLinkedMode.cancel();
+                                               String linkedModePrefPageID= "org.eclipse.ui.editors.preferencePages.LinkedModePreferencePage"; //$NON-NLS-1$
+                                               String refactoringPrefPageID= CPluginPreferencePage.C_BASE_PREF_PAGE_ID;
+                                               PreferencesUtil.createPreferenceDialogOn(fEditor.getSite().getShell(), refactoringPrefPageID, new String[] { linkedModePrefPageID, refactoringPrefPageID }, null).open();
+                                       }
+                               };
+                               manager.add(prefsAction);
+                       }
+               });
+               return fMenuManager;
+       }
+
+       private void addMoveMenuItem(IMenuManager manager, final int snapPosition, String text) {
+               IAction action= new Action(text, IAction.AS_RADIO_BUTTON) {
+                       @Override
+                       public void run() {
+                               fSnapPosition= snapPosition;
+                               fSnapPositionChanged= true;
+                               getDialogSettings().put(SNAP_POSITION_KEY, fSnapPosition);
+                               updatePopupLocation(true);
+                               activateEditor();
+                       }
+               };
+               action.setChecked(fSnapPosition == snapPosition);
+               manager.add(action);
+       }
+
+       private static String getEnterBinding() {
+               return KeyStroke.getInstance(KeyLookupFactory.getDefault().formalKeyLookup(IKeyLookup.CR_NAME)).format();
+       }
+
+       /**
+        * WARNING: only works in workbench window context!
+        * @return the keybinding for Refactor &gt; Rename
+        */
+       private static String getOpenDialogBinding() {
+               IBindingService bindingService= (IBindingService)PlatformUI.getWorkbench().getAdapter(IBindingService.class);
+               if (bindingService == null)
+                       return ""; //$NON-NLS-1$
+               String binding= bindingService.getBestActiveBindingFormattedFor(ICEditorActionDefinitionIds.RENAME_ELEMENT);
+               return binding == null ? "" : binding; //$NON-NLS-1$
+       }
+
+       private static void recursiveSetBackgroundColor(Control control, Color color) {
+               control.setBackground(color);
+               if (control instanceof Composite) {
+                       Control[] children= ((Composite) control).getChildren();
+                       for (int i= 0; i < children.length; i++) {
+                               recursiveSetBackgroundColor(children[i], color);
+                       }
+               }
+       }
+
+       public boolean ownsFocusShell() {
+               if (fIsMenuUp)
+                       return true;
+               if (fPopup == null || fPopup.isDisposed())
+                       return false;
+               Shell activeShell= fPopup.getDisplay().getActiveShell();
+               if (fPopup == activeShell)
+                       return true;
+               return false;
+       }
+
+       private void activateEditor() {
+               fEditor.getSite().getShell().setActive();
+       }
+
+       public boolean requestWidgetToken(IWidgetTokenOwner owner) {
+               return false;
+       }
+
+       public boolean requestWidgetToken(IWidgetTokenOwner owner, int priority) {
+               return false;
+       }
+
+       public boolean setFocus(IWidgetTokenOwner owner) {
+               if (fToolBar != null && !fToolBar.isDisposed())
+                       showMenu(fToolBar);
+               return true;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameLinkedMode.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameLinkedMode.java
new file mode 100644 (file)
index 0000000..a8e9592
--- /dev/null
@@ -0,0 +1,533 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
+import java.util.Comparator;
+
+import org.eclipse.core.commands.operations.IOperationHistory;
+import org.eclipse.core.commands.operations.IUndoContext;
+import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.commands.operations.OperationHistoryFactory;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IEditingSupport;
+import org.eclipse.jface.text.IEditingSupportRegistry;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewerExtension6;
+import org.eclipse.jface.text.IUndoManager;
+import org.eclipse.jface.text.IUndoManagerExtension;
+import org.eclipse.jface.text.link.ILinkedModeListener;
+import org.eclipse.jface.text.link.LinkedModeModel;
+import org.eclipse.jface.text.link.LinkedModeUI;
+import org.eclipse.jface.text.link.LinkedModeUI.ExitFlags;
+import org.eclipse.jface.text.link.LinkedPosition;
+import org.eclipse.jface.text.link.LinkedPositionGroup;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.texteditor.link.EditorLinkedModeUI;
+
+import org.eclipse.cdt.core.CConventions;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNodeSelector;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
+import org.eclipse.cdt.core.dom.parser.AbstractCLikeLanguage;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.IWorkingCopyManager;
+
+import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
+
+import org.eclipse.cdt.internal.ui.editor.ASTProvider;
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.editor.EditorHighlightingSynchronizer;
+import org.eclipse.cdt.internal.ui.search.LinkedNamesFinder;
+import org.eclipse.cdt.internal.ui.text.correction.proposals.LinkedNamesAssistProposal.DeleteBlockingExitPolicy;
+
+public class RenameLinkedMode {
+
+       private class FocusEditingSupport implements IEditingSupport {
+               public boolean ownsFocusShell() {
+                       if (fInfoPopup == null)
+                               return false;
+                       if (fInfoPopup.ownsFocusShell()) {
+                               return true;
+                       }
+
+                       Shell editorShell= fEditor.getSite().getShell();
+                       Shell activeShell= editorShell.getDisplay().getActiveShell();
+                       if (editorShell == activeShell)
+                               return true;
+                       return false;
+               }
+
+               public boolean isOriginator(DocumentEvent event, IRegion subjectRegion) {
+                       return false; //leave on external modification outside positions
+               }
+       }
+
+       private class EditorSynchronizer implements ILinkedModeListener {
+               public void left(LinkedModeModel model, int flags) {
+                       linkedModeLeft();
+                       if ((flags & ILinkedModeListener.UPDATE_CARET) != 0) {
+                               doRename(fShowPreview);
+                       }
+               }
+
+               public void resume(LinkedModeModel model, int flags) {
+               }
+
+               public void suspend(LinkedModeModel model) {
+               }
+       }
+
+       private class ExitPolicy extends DeleteBlockingExitPolicy {
+               public ExitPolicy(IDocument document) {
+                       super(document);
+               }
+
+               @Override
+               public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) {
+                       fShowPreview= (event.stateMask & SWT.CTRL) != 0
+                                                       && (event.character == SWT.CR || event.character == SWT.LF);
+                       return super.doExit(model, event, offset, length);
+               }
+       }
+
+
+       private static RenameLinkedMode fgActiveLinkedMode;
+
+       private final CEditor fEditor;
+       
+       private RenameInformationPopup fInfoPopup;
+
+       private Point fOriginalSelection;
+       private String fOriginalName;
+
+       private LinkedPosition fNamePosition;
+       private LinkedModeModel fLinkedModeModel;
+       private LinkedPositionGroup fLinkedPositionGroup;
+       private final FocusEditingSupport fFocusEditingSupport;
+       private boolean fShowPreview;
+
+       /**
+        * The operation on top of the undo stack when the rename is {@link #start()}ed, or
+        * <code>null</code> if rename has not been started or the undo stack was empty.
+        */
+       private IUndoableOperation fStartingUndoOperation;
+       private IRegion[] fLocations;
+
+       public RenameLinkedMode(CEditor editor) {
+               Assert.isNotNull(editor);
+               fEditor= editor;
+               fFocusEditingSupport= new FocusEditingSupport();
+       }
+
+       public static RenameLinkedMode getActiveLinkedMode() {
+               if (fgActiveLinkedMode != null) {
+                       ISourceViewer viewer= fgActiveLinkedMode.fEditor.getViewer();
+                       if (viewer != null) {
+                               StyledText textWidget= viewer.getTextWidget();
+                               if (textWidget != null && !textWidget.isDisposed()) {
+                                       return fgActiveLinkedMode;
+                               }
+                       }
+                       // Make sure we don't hold onto the active linked mode if anything went wrong with canceling.
+                       fgActiveLinkedMode= null;
+               }
+               return null;
+       }
+
+       public void start() {
+               if (getActiveLinkedMode() != null) {
+                       // For safety; should already be handled in CRenameAction
+                       fgActiveLinkedMode.startFullDialog();
+                       return;
+               }
+
+               ISourceViewer viewer= fEditor.getViewer();
+               fOriginalSelection= viewer.getSelectedRange();
+               final int offset= fOriginalSelection.x;
+
+               try {
+                       fLocations = null;
+                       Point selection= viewer.getSelectedRange();
+                       final int secectionOffset = selection.x;
+                       final int selectionLength = selection.y;
+                       final IDocument document= viewer.getDocument();
+
+                       ASTProvider.getASTProvider().runOnAST(fEditor.getInputCElement(), ASTProvider.WAIT_ACTIVE_ONLY,
+                                       new NullProgressMonitor(), new ASTRunnable() {
+
+                               public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
+                                       if (astRoot == null)
+                                               return Status.CANCEL_STATUS;
+                                       
+                                       IASTNodeSelector selector= astRoot.getNodeSelector(null);
+                                       IASTName name= selector.findEnclosingName(secectionOffset, selectionLength);
+                                       if (name != null) {
+                                               fOriginalName = name.toString();
+                                               fLocations = LinkedNamesFinder.findByName(astRoot, name);
+                                       }
+                                       return Status.OK_STATUS;
+                               }
+                       });
+
+                       if (fLocations == null || fLocations.length == 0) {
+                               return;
+                       }
+
+                       if (viewer instanceof ITextViewerExtension6) {
+                               IUndoManager undoManager= ((ITextViewerExtension6) viewer).getUndoManager();
+                               if (undoManager instanceof IUndoManagerExtension) {
+                                       IUndoManagerExtension undoManagerExtension= (IUndoManagerExtension) undoManager;
+                                       IUndoContext undoContext= undoManagerExtension.getUndoContext();
+                                       IOperationHistory operationHistory= OperationHistoryFactory.getOperationHistory();
+                                       fStartingUndoOperation= operationHistory.getUndoOperation(undoContext);
+                               }
+                       }
+
+                       // Sort the locations starting with the one @ offset.
+                       Arrays.sort(fLocations, new Comparator<IRegion>() {
+
+                               public int compare(IRegion n1, IRegion n2) {
+                                       return rank(n1) - rank(n2);
+                               }
+
+                               /**
+                                * Returns the absolute rank of a location. Location preceding <code>offset</code>
+                                * are ranked last.
+                                *
+                                * @param location the location to compute the rank for
+                                * @return the rank of the location with respect to the invocation offset
+                                */
+                               private int rank(IRegion location) {
+                                       int relativeRank= location.getOffset() + location.getLength() - offset;
+                                       if (relativeRank < 0)
+                                               return Integer.MAX_VALUE + relativeRank;
+                                       else
+                                               return relativeRank;
+                               }
+                       });
+                       
+                       fLinkedPositionGroup= new LinkedPositionGroup();
+                       for (int i= 0; i < fLocations.length; i++) {
+                               IRegion item= fLocations[i];
+                               LinkedPosition linkedPosition = new LinkedPosition(document, item.getOffset(), item.getLength(), i);
+                               if (i == 0) {
+                                       fNamePosition= linkedPosition;
+                               }
+                               fLinkedPositionGroup.addPosition(linkedPosition);
+                       }
+
+                       fLinkedModeModel= new LinkedModeModel();
+                       fLinkedModeModel.addGroup(fLinkedPositionGroup);
+                       fLinkedModeModel.forceInstall();
+                       fLinkedModeModel.addLinkingListener(new EditorHighlightingSynchronizer(fEditor));
+                       fLinkedModeModel.addLinkingListener(new EditorSynchronizer());
+                       
+                       LinkedModeUI ui= new EditorLinkedModeUI(fLinkedModeModel, viewer);
+                       ui.setExitPolicy(new ExitPolicy(document));
+                       ui.setExitPosition(viewer, offset, 0, LinkedPositionGroup.NO_STOP);
+                       ui.enter();
+
+                       // By default full word is selected, restore original selection.
+                       viewer.setSelectedRange(selection.x, selection.y);
+
+                       if (viewer instanceof IEditingSupportRegistry) {
+                               IEditingSupportRegistry registry= (IEditingSupportRegistry) viewer;
+                               registry.register(fFocusEditingSupport);
+                       }
+
+                       openSecondaryPopup();
+                       fgActiveLinkedMode= this;
+               } catch (BadLocationException e) {
+                       CUIPlugin.log(e);
+               }
+       }
+
+       void doRename(boolean showPreview) {
+               cancel();
+
+               Image image= null;
+               Label label= null;
+
+               fShowPreview|= showPreview;
+               try {
+                       ISourceViewer viewer= fEditor.getViewer();
+                       if (viewer instanceof SourceViewer) {
+                               SourceViewer sourceViewer= (SourceViewer) viewer;
+                               Control viewerControl= sourceViewer.getControl();
+                               if (viewerControl instanceof Composite) {
+                                       Composite composite= (Composite) viewerControl;
+                                       Display display= composite.getDisplay();
+
+                                       // Flush pending redraw requests:
+                                       while (!display.isDisposed() && display.readAndDispatch()) {
+                                       }
+
+                                       // Copy editor area:
+                                       GC gc= new GC(composite);
+                                       Point size;
+                                       try {
+                                               size= composite.getSize();
+                                               image= new Image(gc.getDevice(), size.x, size.y);
+                                               gc.copyArea(image, 0, 0);
+                                       } finally {
+                                               gc.dispose();
+                                               gc= null;
+                                       }
+
+                                       // Persist editor area while executing refactoring:
+                                       label= new Label(composite, SWT.NONE);
+                                       label.setImage(image);
+                                       label.setBounds(0, 0, size.x, size.y);
+                                       label.moveAbove(null);
+                               }
+                       }
+
+                       String newName= fNamePosition.getContent();
+                       if (fOriginalName.equals(newName))
+                               return;
+                       RenameSupport renameSupport= undoAndCreateRenameSupport(newName);
+                       if (renameSupport == null)
+                               return;
+
+                       Shell shell= fEditor.getSite().getShell();
+                       boolean executed;
+                       if (fShowPreview) { // could have been updated by undoAndCreateRenameSupport(..)
+                               executed= renameSupport.openDialog(shell, true);
+                       } else {
+                               renameSupport.perform(shell, fEditor.getSite().getWorkbenchWindow());
+                               executed= true;
+                       }
+                       if (executed) {
+                               restoreFullSelection();
+                       }
+                       reconcile();
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               } catch (InterruptedException e) {
+                       // canceling is OK -> redo text changes in that case?
+               } catch (InvocationTargetException e) {
+                       CUIPlugin.log(e);
+               } catch (BadLocationException e) {
+                       CUIPlugin.log(e);
+               } finally {
+                       if (label != null)
+                               label.dispose();
+                       if (image != null)
+                               image.dispose();
+               }
+       }
+
+       public void cancel() {
+               if (fLinkedModeModel != null) {
+                       fLinkedModeModel.exit(ILinkedModeListener.NONE);
+               }
+               linkedModeLeft();
+       }
+
+       private void restoreFullSelection() {
+               if (fOriginalSelection.y != 0) {
+                       int originalOffset= fOriginalSelection.x;
+                       LinkedPosition[] positions= fLinkedPositionGroup.getPositions();
+                       for (int i= 0; i < positions.length; i++) {
+                               LinkedPosition position= positions[i];
+                               if (!position.isDeleted() && position.includes(originalOffset)) {
+                                       fEditor.getViewer().setSelectedRange(position.offset, position.length);
+                                       return;
+                               }
+                       }
+               }
+       }
+
+       private RenameSupport undoAndCreateRenameSupport(String newName) throws CoreException {
+               // Assumption: the linked mode model should be shut down by now.
+               final ISourceViewer viewer= fEditor.getViewer();
+
+               try {
+                       if (!fOriginalName.equals(newName)) {
+                               fEditor.getSite().getWorkbenchWindow().run(false, true, new IRunnableWithProgress() {
+                                       public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+                                               if (viewer instanceof ITextViewerExtension6) {
+                                                       IUndoManager undoManager= ((ITextViewerExtension6) viewer).getUndoManager();
+                                                       if (undoManager instanceof IUndoManagerExtension) {
+                                                               IUndoManagerExtension undoManagerExtension= (IUndoManagerExtension) undoManager;
+                                                               IUndoContext undoContext= undoManagerExtension.getUndoContext();
+                                                               IOperationHistory operationHistory= OperationHistoryFactory.getOperationHistory();
+                                                               while (undoManager.undoable()) {
+                                                                       if (fStartingUndoOperation != null &&
+                                                                                       fStartingUndoOperation.equals(operationHistory.getUndoOperation(undoContext)))
+                                                                               return;
+                                                                       undoManager.undo();
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               });
+                       }
+               } catch (InvocationTargetException e) {
+                       throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.getPluginId(),
+                                       RenameMessages.RenameLinkedMode_error_saving_editor, e));
+               } catch (InterruptedException e) {
+                       // canceling is OK
+                       return null;
+               } finally {
+                       reconcile();
+               }
+
+               viewer.setSelectedRange(fOriginalSelection.x, fOriginalSelection.y);
+
+               if (newName.length() == 0)
+                       return null;
+
+               IWorkingCopy workingCopy = getWorkingCopy();
+        IResource resource= workingCopy.getResource();
+        if (!(resource instanceof IFile)) {
+               return null;
+        }
+       CRefactoringArgument arg=
+               new CRefactoringArgument((IFile) resource, fOriginalSelection.x, fOriginalSelection.y);
+        CRenameProcessor processor= new CRenameProcessor(CRefactory.getInstance(), arg);
+        processor.setReplacementText(newName);
+        CRenameRefactoringPreferences preferences = new CRenameRefactoringPreferences();
+        processor.setSelectedOptions(preferences.getOptions());
+        processor.setScope(preferences.getScope());
+        processor.setWorkingSet(preferences.getWorkingSet());
+               RenameSupport renameSupport= RenameSupport.create(processor);
+               return renameSupport;
+       }
+
+       private void reconcile() throws CModelException {
+               IWorkingCopy workingCopy = getWorkingCopy();
+               synchronized (workingCopy) {
+                       workingCopy.reconcile();
+               }
+       }
+
+       private IWorkingCopy getWorkingCopy() {
+               IEditorInput input = fEditor.getEditorInput();
+               IWorkingCopyManager manager = CUIPlugin.getDefault().getWorkingCopyManager();
+               return manager.getWorkingCopy(input);
+       }
+
+       public void startFullDialog() {
+               cancel();
+
+               try {
+                       String newName= fNamePosition.getContent();
+                       RenameSupport renameSupport= undoAndCreateRenameSupport(newName);
+                       if (renameSupport != null)
+                               renameSupport.openDialog(fEditor.getSite().getShell());
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               } catch (BadLocationException e) {
+                       CUIPlugin.log(e);
+               }
+       }
+
+       private void linkedModeLeft() {
+               fgActiveLinkedMode= null;
+               if (fInfoPopup != null) {
+                       fInfoPopup.close();
+               }
+
+               ISourceViewer viewer= fEditor.getViewer();
+               if (viewer instanceof IEditingSupportRegistry) {
+                       IEditingSupportRegistry registry= (IEditingSupportRegistry) viewer;
+                       registry.unregister(fFocusEditingSupport);
+               }
+       }
+
+       private void openSecondaryPopup() {
+               fInfoPopup= new RenameInformationPopup(fEditor, this);
+               fInfoPopup.open();
+       }
+
+       public boolean isCaretInLinkedPosition() {
+               return getCurrentLinkedPosition() != null;
+       }
+
+       public LinkedPosition getCurrentLinkedPosition() {
+               Point selection= fEditor.getViewer().getSelectedRange();
+               int start= selection.x;
+               int end= start + selection.y;
+               LinkedPosition[] positions= fLinkedPositionGroup.getPositions();
+               for (int i= 0; i < positions.length; i++) {
+                       LinkedPosition position= positions[i];
+                       if (position.includes(start) && position.includes(end))
+                               return position;
+               }
+               return null;
+       }
+
+       public boolean isEnabled() {
+               try {
+                       String newName= fNamePosition.getContent();
+                       if (fOriginalName.equals(newName))
+                               return false;
+                       return CConventions.validateIdentifier(newName, getLanguage()).isOK();
+               } catch (BadLocationException e) {
+                       return false;
+               }
+       }
+
+       private AbstractCLikeLanguage getLanguage() {
+               ITranslationUnit tu = (ITranslationUnit) fEditor.getInputCElement();
+               ILanguage language = null;
+               try {
+                       language = tu.getLanguage();
+               } catch (CoreException e) {
+               }
+               if (language instanceof AbstractCLikeLanguage) {
+                       return (AbstractCLikeLanguage) language;
+               }
+               return GPPLanguage.getDefault();
+       }
+       
+       public boolean isOriginalName() {
+               try {
+                       String newName= fNamePosition.getContent();
+                       return fOriginalName.equals(newName);
+               } catch (BadLocationException e) {
+                       return false;
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.java
new file mode 100644 (file)
index 0000000..b4c6489
--- /dev/null
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 Wind River Systems, Inc.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *     Markus Schorn - initial API and implementation
+ *     Sergey Prigogin (Google)
+ ******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+import org.eclipse.osgi.util.NLS;
+
+public class RenameMessages extends NLS {
+    public static String ASTManager_error_macro_name_conflict;
+       public static String ASTManager_subtask_analyzing;
+       public static String ASTManager_task_analyze;
+       public static String ASTManager_task_generateAst;
+       public static String ASTManager_warning_parsingError_detailed;
+       public static String ASTManager_warning_parsingError_withFile;
+       public static String ASTManager_warning_parsingError_withFileAndLine;
+       public static String ASTManager_warning_parsingError;
+       public static String CRefactoringMatch_label_comment;
+       public static String CRefactoringMatch_label_occurrence;
+       public static String CRefactoringMatch_label_potentialOccurrence;
+       public static String CRefactory_title_rename;
+       public static String CRenameIncludeProcessor_includeDirective;
+       public static String CRenameLocalProcessor_constructor;
+       public static String CRenameLocalProcessor_enumerator;
+       public static String CRenameLocalProcessor_error_conflict;
+       public static String CRenameLocalProcessor_error_isShadowed;
+       public static String CRenameLocalProcessor_error_message;
+       public static String CRenameLocalProcessor_error_message1;
+       public static String CRenameLocalProcessor_error_message2;
+       public static String CRenameLocalProcessor_error_message3;
+       public static String CRenameLocalProcessor_error_overloads;
+       public static String CRenameLocalProcessor_error_redeclare;
+       public static String CRenameLocalProcessor_error_shadow;
+       public static String CRenameLocalProcessor_field;
+       public static String CRenameLocalProcessor_globalVariable;
+       public static String CRenameLocalProcessor_localVariable;
+       public static String CRenameLocalProcessor_method;
+       public static String CRenameLocalProcessor_parameter;
+       public static String CRenameMethodProcessor_fatalError_renameConstructor;
+       public static String CRenameMethodProcessor_fatalError_renameDestructor;
+       public static String CRenameMethodProcessor_fatalError_renameOperator;
+       public static String CRenameMethodProcessor_fatalError_renameToConstructor;
+       public static String CRenameMethodProcessor_fatalError_renameToDestructor;
+       public static String CRenameMethodProcessor_warning_illegalCharacters;
+       public static String CRenameMethodProcessor_warning_renameVirtual;
+       public static String CRenameProcessorDelegate_fileStaticFunction;
+       public static String CRenameProcessorDelegate_fileStaticVariable;
+       public static String CRenameProcessorDelegate_globalFunction;
+       public static String CRenameProcessorDelegate_namespace;
+       public static String CRenameProcessorDelegate_task_checkFinalCondition;
+       public static String CRenameProcessorDelegate_task_createChange;
+       public static String CRenameProcessorDelegate_type;
+       public static String CRenameProcessorDelegate_warning_commentMatch_plural;
+       public static String CRenameProcessorDelegate_warning_commentMatch_singular;
+       public static String CRenameProcessorDelegate_warning_potentialMatch_plural;
+       public static String CRenameProcessorDelegate_warning_potentialMatch_singular;
+       public static String CRenameProcessorDelegate_wizard_title;
+       public static String CRenameRefactoringInputPage_button_chooseWorkingSet;
+       public static String CRenameRefactoringInputPage_button_comments;
+       public static String CRenameRefactoringInputPage_button_sourceCode;
+       public static String CRenameRefactoringInputPage_button_inactiveCode;
+       public static String CRenameRefactoringInputPage_button_includes;
+       public static String CRenameRefactoringInputPage_button_macroDefinitions;
+       public static String CRenameRefactoringInputPage_button_preprocessor;
+       public static String CRenameRefactoringInputPage_button_strings;
+       public static String CRenameRefactoringInputPage_button_exhaustiveFileSearch;
+       public static String CRenameRefactoringInputPage_button_singleProject;
+       public static String CRenameRefactoringInputPage_button_relatedProjects;
+       public static String CRenameRefactoringInputPage_button_workspace;
+       public static String CRenameRefactoringInputPage_button_workingSet;
+       public static String CRenameRefactoringInputPage_errorInvalidIdentifier;
+       public static String CRenameRefactoringInputPage_label_newName;
+       public static String CRenameRefactoringInputPage_label_scope;
+       public static String CRenameRefactoringInputPage_label_updateWithin;
+       public static String CRenameRefactoringInputPage_renameBaseAndDerivedMethods;
+       public static String CRenameTopProcessor_enumerator;
+       public static String CRenameTopProcessor_error_invalidName;
+       public static String CRenameTopProcessor_error_invalidTextSelection;
+       public static String CRenameTopProcessor_error_renameWithoutSourceFile;
+       public static String CRenameTopProcessor_field;
+       public static String CRenameTopProcessor_filelocalFunction;
+       public static String CRenameTopProcessor_filelocalVar;
+       public static String CRenameTopProcessor_globalFunction;
+       public static String CRenameTopProcessor_globalVar;
+       public static String CRenameTopProcessor_localVar;
+       public static String CRenameTopProcessor_macro;
+       public static String CRenameTopProcessor_method;
+       public static String CRenameTopProcessor_namespace;
+       public static String CRenameTopProcessor_parameter;
+       public static String CRenameTopProcessor_type;
+       public static String CRenameTopProcessor_virtualMethod;
+       public static String CRenameTopProcessor_wizard_backup_title;
+       public static String CRenameTopProcessor_wizard_title;
+       public static String RenameCSourceFolderChange_ErrorMsg;
+       public static String RenameCSourceFolderChange_Name0;
+       public static String RenameSourceFolder_0;
+       public static String RenameInformationPopup_delayJobName;
+       public static String RenameInformationPopup_EnterNewName;
+       public static String RenameInformationPopup_menu;
+       public static String RenameInformationPopup_OpenDialog;
+       public static String RenameInformationPopup_preferences;
+       public static String RenameInformationPopup_Preview;
+       public static String RenameInformationPopup_RenameInWorkspace;
+       public static String RenameInformationPopup_snap_bottom_right;
+       public static String RenameInformationPopup_snap_over_left;
+       public static String RenameInformationPopup_snap_over_right;
+       public static String RenameInformationPopup_snap_under_left;
+       public static String RenameInformationPopup_snap_under_right;
+       public static String RenameInformationPopup_SnapTo;
+       public static String RenameLinkedMode_error_saving_editor;
+       public static String RenameSupport_not_available;
+       public static String RenameSupport_dialog_title;
+       public static String TextSearch_monitor_categorizeMatches;
+
+       static {
+               NLS.initializeMessages(RenameMessages.class.getName(), RenameMessages.class);
+       }
+
+       // Do not instantiate
+       private RenameMessages() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameMessages.properties
new file mode 100644 (file)
index 0000000..dcd80f1
--- /dev/null
@@ -0,0 +1,116 @@
+###############################################################################
+# Copyright (c) 2005, 2010 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+#     Markus Schorn, Wind River Systems Inc.
+#     Sergey Prigogin (Google)
+###############################################################################
+ASTManager_error_macro_name_conflict=''{0}'' conflicts with the name of an existing macro!
+ASTManager_subtask_analyzing=Analyzing {0} files
+ASTManager_task_analyze=Analyzing source code
+ASTManager_task_generateAst=Generating AST
+ASTManager_warning_parsingError_detailed=Parsing error - {0} - 
+ASTManager_warning_parsingError_withFile={0} in file ''{1}''
+ASTManager_warning_parsingError_withFileAndLine={0} in file ''{1}'' at line ''{2}''
+ASTManager_warning_parsingError=Parsing error
+CRefactoringMatch_label_comment=Rename in comment
+CRefactoringMatch_label_occurrence=Rename occurrence
+CRefactoringMatch_label_potentialOccurrence=Rename potential occurrence
+CRefactory_title_rename=Rename
+CRenameIncludeProcessor_includeDirective=include directive
+CRenameLocalProcessor_constructor=Constructor
+CRenameLocalProcessor_enumerator=Enumerator
+CRenameLocalProcessor_error_conflict=Name conflict
+CRenameLocalProcessor_error_isShadowed=Shadowing
+CRenameLocalProcessor_error_message=A conflict was encountered during refactoring.
+CRenameLocalProcessor_error_message1=Type of problem: {0}
+CRenameLocalProcessor_error_message2=New element: {0}
+CRenameLocalProcessor_error_message3=Conflicting element type: {0}
+CRenameLocalProcessor_error_overloads=Overloading
+CRenameLocalProcessor_error_redeclare=Redeclaration
+CRenameLocalProcessor_error_shadow=Shadowing
+CRenameLocalProcessor_field=Field
+CRenameLocalProcessor_globalVariable=Global variable
+CRenameLocalProcessor_localVariable=Local variable
+CRenameLocalProcessor_method=Method
+CRenameLocalProcessor_parameter=Parameter
+CRenameMethodProcessor_fatalError_renameConstructor=Constructor cannot be renamed.
+CRenameMethodProcessor_fatalError_renameDestructor=Destructor cannot be renamed.
+CRenameMethodProcessor_fatalError_renameOperator=Operators cannot be renamed.
+CRenameMethodProcessor_fatalError_renameToConstructor=Cannot rename method to constructor.
+CRenameMethodProcessor_fatalError_renameToDestructor=Cannot rename method to destructor.
+CRenameMethodProcessor_warning_illegalCharacters=Name contains illegal characters.
+CRenameMethodProcessor_warning_renameVirtual=Renaming a virtual method. Consider renaming the base and derived class methods (if any).
+CRenameProcessorDelegate_fileStaticFunction=File static function
+CRenameProcessorDelegate_fileStaticVariable=File static variable
+CRenameProcessorDelegate_globalFunction=Global function
+CRenameProcessorDelegate_namespace=Namespace
+CRenameProcessorDelegate_task_checkFinalCondition=Checking final conditions
+CRenameProcessorDelegate_task_createChange=creating changes
+CRenameProcessorDelegate_type=Type
+CRenameProcessorDelegate_warning_commentMatch_plural=Refactoring contains {0} matches within comments.
+CRenameProcessorDelegate_warning_commentMatch_singular=Refactoring contains 1 match within a comment.
+CRenameProcessorDelegate_warning_potentialMatch_plural=Refactoring contains {0} potential matches.
+CRenameProcessorDelegate_warning_potentialMatch_singular=Refactoring contains 1 potential match.
+CRenameProcessorDelegate_wizard_title=Rename {0} ''{1}''
+CRenameRefactoringInputPage_button_chooseWorkingSet=Choose...
+CRenameRefactoringInputPage_button_comments=Comments
+CRenameRefactoringInputPage_button_sourceCode=Source code
+CRenameRefactoringInputPage_button_inactiveCode=Inactive conditional compilation code branches
+CRenameRefactoringInputPage_button_includes=Include directives
+CRenameRefactoringInputPage_button_macroDefinitions=Macro definitions
+CRenameRefactoringInputPage_button_preprocessor=Other preprocessor directives
+CRenameRefactoringInputPage_button_strings=String literals
+CRenameRefactoringInputPage_button_exhaustiveFileSearch=Exhaustive file search (slow)
+CRenameRefactoringInputPage_button_singleProject=Project
+CRenameRefactoringInputPage_button_relatedProjects=Related projects
+CRenameRefactoringInputPage_button_workspace=All projects
+CRenameRefactoringInputPage_button_workingSet=Working set:
+CRenameRefactoringInputPage_errorInvalidIdentifier=''{0}'' is not a valid identifier
+CRenameRefactoringInputPage_label_newName=New Name: 
+CRenameRefactoringInputPage_label_scope=Scope of Rename:
+CRenameRefactoringInputPage_label_updateWithin=Update within:
+CRenameRefactoringInputPage_renameBaseAndDerivedMethods=Rename virtual methods in base and derived classes, also (if any).
+CRenameTopProcessor_enumerator=enumerator
+CRenameTopProcessor_error_invalidName=The selected name cannot be renamed.
+CRenameTopProcessor_error_invalidTextSelection=The selected name could not be analyzed.
+CRenameTopProcessor_error_renameWithoutSourceFile=No source
+CRenameTopProcessor_field=field
+CRenameTopProcessor_filelocalFunction=file local function
+CRenameTopProcessor_filelocalVar=file-local variable
+CRenameTopProcessor_globalFunction=global function
+CRenameTopProcessor_globalVar=global variable
+CRenameTopProcessor_localVar=local variable
+CRenameTopProcessor_macro=macro
+CRenameTopProcessor_method=method
+CRenameTopProcessor_namespace=namespace
+CRenameTopProcessor_parameter=parameter
+CRenameTopProcessor_type=type
+CRenameTopProcessor_virtualMethod=virtual method
+CRenameTopProcessor_wizard_backup_title=Rename
+CRenameTopProcessor_wizard_title=Rename ''{0}''
+RenameCSourceFolderChange_ErrorMsg=Folder {0} does not exist
+RenameCSourceFolderChange_Name0=Rename source folder {0} to {1}
+RenameSourceFolder_0=Rename C/C++ Source Folder
+RenameInformationPopup_SnapTo=&Snap To
+RenameInformationPopup_snap_under_left=&Under Left
+RenameInformationPopup_snap_under_right=U&nder Right
+RenameInformationPopup_snap_over_left=&Over Left
+RenameInformationPopup_snap_over_right=O&ver Right
+RenameInformationPopup_snap_bottom_right=&Bottom Right
+RenameInformationPopup_menu=Menu
+RenameInformationPopup_RenameInWorkspace=&Refactor
+RenameInformationPopup_Preview=Pre&view...
+RenameInformationPopup_OpenDialog=&Open Rename Dialog...
+RenameInformationPopup_preferences=&Preferences...
+RenameInformationPopup_EnterNewName=Enter new name, press {0} to refactor
+RenameInformationPopup_delayJobName=delayed RenameInformationPopup
+RenameLinkedMode_error_saving_editor=An error occurred while saving the editor.
+RenameSupport_not_available=The refactoring operation is not available
+RenameSupport_dialog_title=Rename Refactoring
+TextSearch_monitor_categorizeMatches=categorizing matches
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSourceFolder.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSourceFolder.java
new file mode 100644 (file)
index 0000000..a2ebb02
--- /dev/null
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ * Institute for Software (IFS)- initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
+import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
+
+/**
+ * @author Emanuel Graf IFS
+ */
+public class RenameSourceFolder extends RenameParticipant {
+
+       private IFolder oldFolder;
+       private String newName;
+
+       public RenameSourceFolder() {
+       }
+
+       @Override
+       public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context)
+                       throws OperationCanceledException {
+               RenameArguments arg = getArguments();
+               newName = arg.getNewName();             
+               return RefactoringStatus.create(Status.OK_STATUS);
+       }
+
+       @Override
+       public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
+               IPath oldFolderPath = oldFolder.getFullPath();
+               IPath newFolderPath = oldFolder.getFullPath().uptoSegment(oldFolder.getFullPath().segmentCount() - 1).append(newName);
+               return new RenameCSourceFolderChange(oldFolderPath, newFolderPath, oldFolder.getProject(), oldFolder);
+       }
+
+       @Override
+       public String getName() {
+               return RenameMessages.RenameSourceFolder_0;
+       }
+
+       @Override
+       protected boolean initialize(Object element) {
+               if (element instanceof IFolder) {
+                       oldFolder = (IFolder) element;
+                       return true;
+               }
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSupport.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSupport.java
new file mode 100644 (file)
index 0000000..e65517f
--- /dev/null
@@ -0,0 +1,204 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.ltk.core.refactoring.RefactoringCore;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.cdt.core.model.ICProject;
+
+import org.eclipse.cdt.internal.ui.refactoring.RefactoringExecutionHelper;
+
+/**
+ * Central access point to execute rename refactorings.
+ */
+public class RenameSupport {
+       /** Flag indication that no additional update is to be performed. */
+       public static final int NONE= 0;
+
+       /** Flag indicating that references are to be updated as well. */
+       public static final int UPDATE_REFERENCES= 1 << 0;
+
+       /**
+        * Flag indicating that textual matches in comments and in string literals
+        * are to be updated as well.
+        */
+       public static final int UPDATE_TEXTUAL_MATCHES= 1 << 6;
+
+       /** Flag indicating that the getter method is to be updated as well. */
+       public static final int UPDATE_GETTER_METHOD= 1 << 4;
+
+       /** Flag indicating that the setter method is to be updated as well. */
+       public static final int UPDATE_SETTER_METHOD= 1 << 5;
+
+       private CRenameRefactoring fRefactoring;
+       private RefactoringStatus fPreCheckStatus;
+
+       /**
+        * Executes some light weight precondition checking. If the returned status
+        * is an error then the refactoring can't be executed at all. However,
+        * returning an OK status doesn't guarantee that the refactoring can be
+        * executed. It may still fail while performing the exhaustive precondition
+        * checking done inside the methods <code>openDialog</code> or
+        * <code>perform</code>.
+        *
+        * The method is mainly used to determine enablement/disablement of actions.
+        *
+        * @return the result of the light weight precondition checking.
+        *
+        * @throws CoreException if an unexpected exception occurs while performing the checking.
+        *
+        * @see #openDialog(Shell)
+        * @see #perform(Shell, IRunnableContext)
+        */
+       public IStatus preCheck() throws CoreException {
+               ensureChecked();
+               if (fPreCheckStatus.hasFatalError())
+                       return fPreCheckStatus.getEntryMatchingSeverity(RefactoringStatus.FATAL).toStatus();
+               else
+                       return Status.OK_STATUS;
+       }
+
+       /**
+        * Opens the refactoring dialog for this rename support.
+        *
+        * @param parent a shell used as a parent for the refactoring dialog.
+        * @throws CoreException if an unexpected exception occurs while opening the
+        * dialog.
+        *
+        * @see #openDialog(Shell, boolean)
+        */
+       public void openDialog(Shell parent) throws CoreException {
+               openDialog(parent, false);
+       }
+
+       /**
+        * Opens the refactoring dialog for this rename support.
+        *
+        * <p>
+        * This method has to be called from within the UI thread.
+        * </p>
+        *
+        * @param shell a shell used as a parent for the refactoring, preview, or error dialog
+        * @param showPreviewOnly if <code>true</code>, the dialog skips all user input pages and
+        * directly shows the preview or error page. Otherwise, shows all pages.
+        * @return <code>true</code> if the refactoring has been executed successfully,
+        * <code>false</code> if it has been canceled or if an error has happened during
+        * initial conditions checking.
+        *
+        * @throws CoreException if an error occurred while executing the
+        * operation.
+        *
+        * @see #openDialog(Shell)
+        */
+       public boolean openDialog(Shell shell, boolean showPreviewOnly) throws CoreException {
+               ensureChecked();
+               if (fPreCheckStatus.hasFatalError()) {
+                       showInformation(shell, fPreCheckStatus);
+                       return false;
+               }
+
+        return CRefactory.openDialog(shell, fRefactoring, showPreviewOnly);
+       }
+
+       /**
+        * Executes the rename refactoring without showing a dialog to gather
+        * additional user input (for example the new name of the <tt>ICElement</tt>).
+        * Only an error dialog is shown (if necessary) to present the result
+        * of the refactoring's full precondition checking.
+        * <p>
+        * The method has to be called from within the UI thread.
+        * </p>
+        *
+        * @param parent a shell used as a parent for the error dialog.
+        * @param context a {@link IRunnableContext} to execute the operation.
+        *
+        * @throws InterruptedException if the operation has been canceled by the
+        * user.
+        * @throws InvocationTargetException if an error occurred while executing the
+        * operation.
+        *
+        * @see #openDialog(Shell)
+        * @see IRunnableContext#run(boolean, boolean, org.eclipse.jface.operation.IRunnableWithProgress)
+        */
+       public void perform(Shell parent, IRunnableContext context) throws InterruptedException, InvocationTargetException {
+               try {
+                       ensureChecked();
+                       if (fPreCheckStatus.hasFatalError()) {
+                               showInformation(parent, fPreCheckStatus);
+                               return;
+                       }
+
+                       CRenameProcessor renameProcessor = getRenameProcessor();
+                       try {
+                               renameProcessor.lockIndex();
+                               fPreCheckStatus = renameProcessor.checkInitialConditions(new NullProgressMonitor());
+                               if (fPreCheckStatus.hasFatalError()) {
+                                       showInformation(parent, fPreCheckStatus);
+                                       return;
+                               }
+                               RefactoringExecutionHelper helper= new RefactoringExecutionHelper(fRefactoring,
+                                               RefactoringCore.getConditionCheckingFailedSeverity(), renameProcessor.getSaveMode(),
+                                               parent, context);
+                               helper.perform(true, true);
+                       } finally {
+                               renameProcessor.unlockIndex();
+                       }
+               } catch (CoreException e) {
+                       throw new InvocationTargetException(e);
+               }
+       }
+
+       private RenameSupport(CRenameProcessor processor) {
+               fRefactoring= new CRenameRefactoring(processor);
+       }
+
+       private CRenameProcessor getRenameProcessor() {
+               return (CRenameProcessor) fRefactoring.getProcessor();
+       }
+
+       /**
+        * Creates a new rename support for the given {@link ICProject}.
+        *
+        * @param processor the {@link CRenameProcessor}
+        * @return the {@link RenameSupport}.
+        * @throws CoreException if an unexpected error occurred while creating
+        * the {@link RenameSupport}.
+        */
+       public static RenameSupport create(CRenameProcessor processor) throws CoreException {
+               return new RenameSupport(processor);
+       }
+
+       private void ensureChecked() throws CoreException {
+               if (fPreCheckStatus == null) {
+                       if (!fRefactoring.isApplicable()) {
+                               fPreCheckStatus= RefactoringStatus.createFatalErrorStatus(RenameMessages.RenameSupport_not_available);
+                       } else {
+                               fPreCheckStatus= new RefactoringStatus();
+                       }
+               }
+       }
+
+       private void showInformation(Shell parent, RefactoringStatus status) {
+               String message= status.getMessageMatchingSeverity(RefactoringStatus.FATAL);
+               MessageDialog.openInformation(parent, RenameMessages.RenameSupport_dialog_title, message);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/TextSearchWrapper.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/TextSearchWrapper.java
new file mode 100644 (file)
index 0000000..57af2ad
--- /dev/null
@@ -0,0 +1,396 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 Wind River Systems, Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *    Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.rename;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceProxy;
+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.SubProgressMonitor;
+import org.eclipse.search.core.text.TextSearchEngine;
+import org.eclipse.search.core.text.TextSearchMatchAccess;
+import org.eclipse.search.core.text.TextSearchRequestor;
+import org.eclipse.search.core.text.TextSearchScope;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetManager;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.utils.PathUtil;
+
+import org.eclipse.cdt.internal.formatter.scanner.SimpleScanner;
+import org.eclipse.cdt.internal.formatter.scanner.Token;
+
+/**
+ * Wraps the platform text search and uses a scanner to categorize the text-matches
+ * by location (comments, string-literals, etc.).
+ */
+public class TextSearchWrapper {
+    public final static int SCOPE_FILE = 1;
+    public final static int SCOPE_WORKSPACE = 2;
+    public final static int SCOPE_RELATED_PROJECTS = 3;
+    public final static int SCOPE_SINGLE_PROJECT = 4;
+    public final static int SCOPE_WORKING_SET = 5;
+
+    private static class SearchScope extends TextSearchScope {
+        public static SearchScope newSearchScope(IWorkingSet ws, IResource[] filter) {
+            IAdaptable[] adaptables= ws.getElements();
+            ArrayList<IResource> resources = new ArrayList<IResource>();
+            for (int i = 0; i < adaptables.length; i++) {
+                IAdaptable adaptable = adaptables[i];
+                IResource r= (IResource) adaptable.getAdapter(IResource.class);
+                if (r != null) {
+                    resources.add(r);
+                }
+            }
+            return newSearchScope(resources.toArray(new IResource[resources.size()]), filter);
+               }
+        
+               public static SearchScope newSearchScope(IResource[] roots, IResource[] filter) {
+                       if (filter != null) {
+                               ArrayList<IResource> files = new ArrayList<IResource>(filter.length);
+                               for (IResource file : filter) {
+                                       if (isInForest(file, roots)) {
+                                               files.add(file);
+                                       }
+                               }
+                               roots = files.toArray(new IResource[files.size()]);
+                       }
+                       return new SearchScope(roots);
+               }
+
+               /**
+                * Checks is a file belongs to one of the given containers.
+                */
+        private static boolean isInForest(IResource file, IResource[] roots) {
+               IPath filePath = file.getFullPath();
+               for (IResource root : roots) {
+                       if (PathUtil.isPrefix(root.getFullPath(), filePath)) {
+                               return true;
+                       }
+               }
+                       return false;
+               }
+
+               private IResource[] fRootResources;
+        private ArrayList<Matcher> fFileMatcher= new ArrayList<Matcher>();
+
+        private SearchScope(IResource[] roots) {
+            fRootResources= roots;
+        }
+
+               @Override
+               public IResource[] getRoots() {
+            return fRootResources;
+        }
+
+        @Override
+               public boolean contains(IResourceProxy proxy) {
+            if (proxy.isDerived()) {
+                return false;
+            }
+            if (proxy.getType() == IResource.FILE) {
+                return containsFile(proxy.getName());
+            }
+            return true;
+               }
+
+               private boolean containsFile(String name) {
+            for (Iterator<Matcher> iter = fFileMatcher.iterator(); iter.hasNext();) {
+                Matcher matcher = iter.next();
+                matcher.reset(name);
+                if (matcher.matches()) {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        public void addFileNamePattern(String filePattern) {
+            Pattern p= Pattern.compile(filePatternToRegex(filePattern));
+            fFileMatcher.add(p.matcher("")); //$NON-NLS-1$
+               }
+
+        private String filePatternToRegex(String filePattern) {
+            StringBuilder result = new StringBuilder();
+            for (int i = 0; i < filePattern.length(); i++) {
+                char c = filePattern.charAt(i);
+                switch (c) {
+                case '\\':
+                case '(':
+                case ')':
+                case '{':
+                case '}':
+                case '.':
+                case '[':
+                case ']':
+                case '$':
+                case '^':
+                case '+':
+                case '|':
+                    result.append('\\');
+                    result.append(c);
+                    break;
+                case '?':
+                    result.append('.');
+                    break;
+                case '*':
+                    result.append(".*"); //$NON-NLS-1$
+                    break;
+                default:
+                    result.append(c);
+                    break;
+                }
+            }
+            return result.toString();
+        }
+    }
+
+    public TextSearchWrapper() {
+    }
+    
+    private TextSearchScope createSearchScope(IFile file, int scope, String workingSetName,
+               IResource[] filter, String[] patterns) {
+        switch (scope) {
+               case SCOPE_WORKSPACE:
+                   return defineSearchScope(file.getWorkspace().getRoot(), filter, patterns);
+               case SCOPE_SINGLE_PROJECT:
+                   return defineSearchScope(file.getProject(), filter, patterns);
+               case SCOPE_FILE:
+                   return defineSearchScope(file, filter, patterns);
+               case SCOPE_WORKING_SET: {
+                   TextSearchScope result= defineWorkingSetAsSearchScope(workingSetName, filter, patterns);
+                   if (result == null) {
+                       result= defineSearchScope(file.getWorkspace().getRoot(), filter, patterns);
+                   }
+                       return result;
+               }
+        }
+           return defineRelatedProjectsAsSearchScope(file.getProject(), filter, patterns);
+    }
+    
+    private TextSearchScope defineRelatedProjectsAsSearchScope(IProject project, IResource[] filter, String[] patterns) {
+        HashSet<IProject> projects= new HashSet<IProject>();
+        LinkedList<IProject> workThrough= new LinkedList<IProject>();
+        workThrough.add(project);
+        while (!workThrough.isEmpty()) {
+            IProject prj= workThrough.removeLast();
+            if (projects.add(prj)) {
+                try {
+                    workThrough.addAll(Arrays.asList(prj.getReferencedProjects()));
+                    workThrough.addAll(Arrays.asList(prj.getReferencingProjects()));
+                } catch (CoreException e) {
+                    // need to ignore
+                }
+            }
+        }
+        IResource[] roots= projects.toArray(new IResource[projects.size()]);
+        return defineSearchScope(roots, filter, patterns);
+    }
+
+    private TextSearchScope defineWorkingSetAsSearchScope(String workingSetName, IResource[] filter, String[] patterns) {
+        if (workingSetName == null) {
+            return null;
+        }
+               IWorkingSetManager wsManager= PlatformUI.getWorkbench().getWorkingSetManager();
+               IWorkingSet ws= wsManager.getWorkingSet(workingSetName);
+               if (ws == null) {
+                   return null;
+               }
+               SearchScope result= SearchScope.newSearchScope(ws, filter); 
+               applyFilePatterns(result, patterns);
+               return result;
+    }
+
+    private void applyFilePatterns(SearchScope scope, String[] patterns) {
+        for (int i = 0; i < patterns.length; i++) {
+            String pattern = patterns[i];
+            scope.addFileNamePattern(pattern);
+        }
+    }
+
+    private TextSearchScope defineSearchScope(IResource root, IResource[] filter, String[] patterns) {
+       SearchScope result= SearchScope.newSearchScope(new IResource[] { root }, filter); 
+        applyFilePatterns(result, patterns);
+        return result;
+    }
+    
+    private TextSearchScope defineSearchScope(IResource[] roots, IResource[] filter, String[] patterns) {
+       SearchScope result= SearchScope.newSearchScope(roots, filter);           
+        applyFilePatterns(result, patterns);
+        return result;
+    }
+    
+    /**
+     * Searches for a given word.
+     * 
+     * @param scope One of SCOPE_FILE, SCOPE_WORKSPACE, SCOPE_RELATED_PROJECTS, SCOPE_SINGLE_PROJECT,
+     *     or SCOPE_WORKING_SET.
+     * @param file The file used as an anchor for the scope.
+     * @param workingSet The name of a working set. Ignored is scope is not SCOPE_WORKING_SET.
+     * @param filter If not null, further limits the scope of the search.
+     * @param patterns File name patterns.
+     * @param word The word to search for.
+     * @param monitor A progress monitor.
+     * @param target The list that gets populated with search results.
+     */
+    public IStatus searchWord(int scope, IFile file, String workingSet, IResource[] filter, String[] patterns,
+            String word, IProgressMonitor monitor, final List<CRefactoringMatch> target) {
+        int startPos= target.size();
+        TextSearchEngine engine= TextSearchEngine.create();
+        StringBuilder searchPattern= new StringBuilder(word.length() + 8);
+        searchPattern.append("\\b"); //$NON-NLS-1$
+        searchPattern.append("\\Q"); //$NON-NLS-1$
+        searchPattern.append(word);
+        searchPattern.append("\\E"); //$NON-NLS-1$
+        searchPattern.append("\\b"); //$NON-NLS-1$
+
+        Pattern pattern= Pattern.compile(searchPattern.toString());
+        
+        TextSearchScope searchscope= createSearchScope(file, scope, workingSet, filter, patterns);
+        TextSearchRequestor requestor= new TextSearchRequestor() {
+            @Override
+                       public boolean acceptPatternMatch(TextSearchMatchAccess access) {
+               IFile file= access.getFile();
+               ICElement elem= CoreModel.getDefault().create(file);
+               if (elem instanceof ITranslationUnit) {
+                       target.add(new CRefactoringMatch(file, 
+                                       access.getMatchOffset(), access.getMatchLength(), 0));
+               }
+               return true;
+            }
+        };
+        IStatus result= engine.search(searchscope, requestor, pattern, 
+                       new SubProgressMonitor(monitor, 95));
+        categorizeMatches(target.subList(startPos, target.size()), 
+                new SubProgressMonitor(monitor, 5));
+
+        return result;
+    }
+    
+    public void categorizeMatches(List<CRefactoringMatch> matches, IProgressMonitor monitor) {
+        monitor.beginTask(RenameMessages.TextSearch_monitor_categorizeMatches, matches.size());
+        IFile file= null;
+        ArrayList<int[]> locations= null;
+        for (Iterator<CRefactoringMatch> iter = matches.iterator(); iter.hasNext();) {
+            CRefactoringMatch match = iter.next();
+            IFile tfile= match.getFile();
+            if (file == null || !file.equals(tfile)) {
+                file= tfile;
+                locations= new ArrayList<int[]>(); 
+                computeLocations(file, locations);                
+            }
+            match.setLocation(findLocation(match, locations));            
+            monitor.worked(1);
+        }
+    }
+
+    final static Comparator<int[]> COMPARE_FIRST_INTEGER= new Comparator<int[]>() {
+        public int compare(int[] o1, int[] o2) {
+            return (o1)[0] - (o2)[0];
+        }
+    };
+
+    private int findLocation(CRefactoringMatch match, ArrayList<int[]> states) {
+        int pos = Collections.binarySearch(states, new int[] {match.getOffset()}, COMPARE_FIRST_INTEGER);
+        if (pos < 0) {
+            pos= -pos - 2;
+            if (pos < 0) {
+                pos = 0;
+            }
+        }
+        int endOffset= match.getOffset() + match.getLength();
+        int location= 0;
+        while (pos < states.size()) {
+            int[] info= states.get(pos);
+            if (info[0] >= endOffset) {
+                break;
+            }
+            location |= info[1];
+            pos++;
+        }
+        return location;
+    }
+
+    private void computeLocations(IFile file, ArrayList<int[]> locations) {
+        Reader reader;
+        SimpleScanner scanner= new SimpleScanner();
+        try {
+            reader = new BufferedReader(new InputStreamReader(file.getContents(), file.getCharset()));
+        } catch (CoreException e) {
+            return;
+        } catch (UnsupportedEncodingException e) {
+            return;
+        }
+        try {
+            scanner.initialize(reader, null);
+            scanner.setReuseToken(true);
+            Token token;
+            int lastState= 0;
+            while ((token= scanner.nextToken()) != null) {
+                int state= CRefactory.OPTION_IN_CODE;
+                switch (token.getType()) {
+                       case Token.tLINECOMMENT:
+                    case Token.tBLOCKCOMMENT:
+                        state= CRefactory.OPTION_IN_COMMENT;
+                               break;
+                    case Token.tSTRING:
+                    case Token.tLSTRING:
+                    case Token.tCHAR:
+                        state= CRefactory.OPTION_IN_STRING_LITERAL;
+                       break;
+                    case Token.tPREPROCESSOR:
+                        state= CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE;
+                        break;
+                    case Token.tPREPROCESSOR_DEFINE:
+                        state= CRefactory.OPTION_IN_MACRO_DEFINITION;
+                        break;
+                    case Token.tPREPROCESSOR_INCLUDE:
+                        state= CRefactory.OPTION_IN_INCLUDE_DIRECTIVE;
+                        break;
+                }
+                if (state != lastState) {
+                    locations.add(new int[] {token.getOffset(), state});
+                    lastState= state;
+                }
+            }
+        } finally {
+            try {
+                reader.close();
+            } catch (IOException e) {
+            }
+        }
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/DeclaratorFinder.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/DeclaratorFinder.java
new file mode 100644 (file)
index 0000000..fe09c6a
--- /dev/null
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *             Martin Schwab & Thomas Kallenberg - initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
+
+import org.eclipse.jface.text.ITextSelection;
+
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTStatement;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
+
+/**
+ * Given a selection and a translation unit, this class finds a
+ * ICPPASTFunctionDeclarator if possible. Special case: Nested local functions
+ * are skipped during search.
+ */
+public class DeclaratorFinder {
+
+       private IASTFunctionDeclarator foundDeclarator;
+
+       public DeclaratorFinder(ITextSelection selection, IASTTranslationUnit unit) {
+               foundDeclarator = findDeclaratorInSelection(selection, unit);
+
+               if (foundDeclarator == null) {
+                       throw new NotSupportedException(Messages.DeclaratorFinder_NoDeclarator);
+               }
+               if (isPartOfAStatement(foundDeclarator)) {
+                       throw new NotSupportedException(Messages.DeclaratorFinder_NestedFunction);
+               }
+       }
+
+       public IASTName getName() {
+               return foundDeclarator.getName();
+       }
+
+       private IASTFunctionDeclarator findDeclaratorInSelection(
+ITextSelection selection,
+                       IASTTranslationUnit unit) {
+               IASTNode firstNodeInsideSelection = unit.getNodeSelector(null)
+                               .findFirstContainedNode(selection.getOffset(),
+                                               selection.getLength());
+               IASTFunctionDeclarator declarator = findDeclaratorInAncestors(firstNodeInsideSelection);
+               
+               if (declarator == null) {
+                       firstNodeInsideSelection = unit.getNodeSelector(null).findEnclosingNode(
+                                       selection.getOffset(), selection.getLength());
+                       declarator = findDeclaratorInAncestors(firstNodeInsideSelection);
+               }
+               return declarator;
+       }
+
+       private IASTFunctionDeclarator findDeclaratorInAncestors(IASTNode node) {
+               while (node != null) {
+                       IASTFunctionDeclarator declarator = extractDeclarator(node);
+                       if (node instanceof ICPPASTTemplateDeclaration) {
+                               declarator = extractDeclarator(((ICPPASTTemplateDeclaration) node).getDeclaration());
+                       }
+                       if (declarator != null) {
+                               return declarator;
+                       }
+                       node = node.getParent();
+               }
+               return null;
+       }
+
+       private IASTFunctionDeclarator extractDeclarator(IASTNode node) {
+               if (node instanceof ICPPASTTemplateDeclaration) {
+                       node = ((ICPPASTTemplateDeclaration) node).getDeclaration();
+               }
+               if (node instanceof IASTFunctionDeclarator) {
+                       return (IASTFunctionDeclarator) node;
+               }
+               if (node instanceof IASTFunctionDefinition) {
+                       return ((IASTFunctionDefinition) node).getDeclarator();
+               }
+               if (node instanceof IASTSimpleDeclaration) {
+                       IASTDeclarator[] declarators = ((IASTSimpleDeclaration) node).getDeclarators();
+                       if (declarators.length > 1) {
+                               throw new NotSupportedException(Messages.DeclaratorFinder_MultipleDeclarators);
+                       }
+                       
+                       if (declarators.length == 1 && 
+                                       declarators[0] instanceof IASTFunctionDeclarator)
+                               return (IASTFunctionDeclarator) declarators[0];
+               }
+               return null;
+       }
+
+       private boolean isPartOfAStatement(IASTNode node) {
+               return ToggleNodeHelper.getAncestorOfType(node, IASTStatement.class) != null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/EmptyRefactoringDescription.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/EmptyRefactoringDescription.java
new file mode 100644 (file)
index 0000000..8d22493
--- /dev/null
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *             Martin Schwab & Thomas Kallenberg - initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
+
+import java.util.HashMap;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.TextSelection;
+import org.eclipse.ltk.core.refactoring.Refactoring;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+
+import org.eclipse.cdt.internal.ui.refactoring.CRefactoringDescription;
+
+class EmptyRefactoringDescription extends CRefactoringDescription {
+       @SuppressWarnings("nls")
+       public EmptyRefactoringDescription() {
+               super("id", "proj", "desc", "comment", 0, new HashMap<String, String>());
+       }
+
+       @Override
+       public Refactoring createRefactoring(RefactoringStatus status) throws CoreException {
+               return new ToggleRefactoring(getFile(), (TextSelection)getSelection(), getCProject());
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/IToggleRefactoringStrategy.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/IToggleRefactoringStrategy.java
new file mode 100644 (file)
index 0000000..29c1f66
--- /dev/null
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *             Martin Schwab & Thomas Kallenberg - initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
+
+import org.eclipse.cdt.internal.ui.refactoring.ModificationCollector;
+
+public interface IToggleRefactoringStrategy {
+       public void run(ModificationCollector modifications);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/InsertionPointFinder.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/InsertionPointFinder.java
new file mode 100644 (file)
index 0000000..4f39a6d
--- /dev/null
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *             Martin Schwab & Thomas Kallenberg - initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
+
+import java.util.ArrayList;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
+
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCompositeTypeSpecifier;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
+
+import org.eclipse.cdt.internal.ui.refactoring.Container;
+
+public class InsertionPointFinder {
+
+       private static ArrayList<ICPPASTFunctionDeclarator> allafterdeclarations;
+       private static ArrayList<ICPPASTFunctionDefinition> alldefinitionsoutside;
+       private static IASTDeclaration position;
+       
+       public static IASTDeclaration findInsertionPoint(IASTTranslationUnit classunit, IASTTranslationUnit functiondefunit, IASTFunctionDeclarator funcdecl) {
+               position = null;
+               findAllDeclarationsAfterInClass(classunit, funcdecl);
+               findAllDefinitionsoutSideClass(functiondefunit);
+               findRightPlace();
+               return position;
+       }
+       
+       private static void findRightPlace() {
+               if (allafterdeclarations == null || alldefinitionsoutside == null)
+                       return;
+               for(ICPPASTFunctionDeclarator decl: allafterdeclarations) {
+                       String decl_name = decl.getName().toString();
+                       for(ICPPASTFunctionDefinition def: alldefinitionsoutside) {
+                               String def_name = null;
+                               if (def.getDeclarator().getName() instanceof ICPPASTQualifiedName) {
+                                       ICPPASTQualifiedName qname = (ICPPASTQualifiedName) def.getDeclarator().getName();
+                                       def_name = qname.getNames()[1].toString(); 
+                               }
+                               else if (def.getDeclarator().getName() instanceof CPPASTName) {
+                                       def_name = def.getDeclarator().getName().toString();
+                               }
+
+                               if (decl_name.equals(def_name)) {
+                                       if (def.getParent() != null && def.getParent() instanceof ICPPASTTemplateDeclaration)
+                                               position = (IASTDeclaration) def.getParent();
+                                       else
+                                               position = def;
+                                       return;
+                               }
+                       }
+               }
+       }
+
+       private static void findAllDeclarationsAfterInClass(IASTTranslationUnit classunit, IASTFunctionDeclarator funcdecl) {
+               ICPPASTCompositeTypeSpecifier klass = getklass(classunit);
+               if (klass != null)
+                       allafterdeclarations = getDeclarationsInClass(klass, funcdecl);
+       }
+       
+       /**
+        * @param unit the translation unit where to find the definitions
+        */
+       private static void findAllDefinitionsoutSideClass(IASTTranslationUnit unit) {
+               final ArrayList<ICPPASTFunctionDefinition> definitions = new ArrayList<ICPPASTFunctionDefinition>();
+               if (unit == null) {
+                       alldefinitionsoutside = definitions;
+                       return;
+               }
+               unit.accept(
+                       new ASTVisitor() {
+                               {
+                                       shouldVisitDeclarations = true;
+                               }
+       
+                               @Override
+                               public int visit(IASTDeclaration declaration) {
+                                       if (declaration instanceof ICPPASTFunctionDefinition) {
+                                                       if (declaration.getParent() != null && ToggleNodeHelper.getAncestorOfType(declaration, CPPASTCompositeTypeSpecifier.class) != null)
+                                                       return PROCESS_CONTINUE;
+                                               definitions.add((ICPPASTFunctionDefinition) declaration);
+                                       }
+                                       return super.visit(declaration);
+                               }
+                       });
+               alldefinitionsoutside = definitions;
+       }
+
+       private static ArrayList<ICPPASTFunctionDeclarator> getDeclarationsInClass(ICPPASTCompositeTypeSpecifier klass, final IASTFunctionDeclarator selected) {
+               final ArrayList<ICPPASTFunctionDeclarator> declarations = new ArrayList<ICPPASTFunctionDeclarator>();
+               
+               klass.accept(
+                               new ASTVisitor() {
+                               {
+                                       shouldVisitDeclarators = true;
+                               }
+       
+                               boolean got = false;
+                               @Override
+                               public int visit(IASTDeclarator declarator) {
+                                       if (declarator instanceof ICPPASTFunctionDeclarator) {
+                                               if (((ICPPASTFunctionDeclarator) declarator) == selected) {
+                                                       got = true;
+                                               }
+                                               if (got) {
+                                                       declarations.add((ICPPASTFunctionDeclarator) declarator);
+                                               }
+                                       }
+                                       return super.visit(declarator);
+                               }
+               });
+               
+               return declarations;
+       }
+
+       private static ICPPASTCompositeTypeSpecifier getklass(IASTTranslationUnit unit) {
+               final Container<ICPPASTCompositeTypeSpecifier> result = new Container<ICPPASTCompositeTypeSpecifier>();
+
+               unit.accept(
+                       new ASTVisitor() {
+                       {
+                               shouldVisitDeclSpecifiers = true;
+                       }
+
+                       @Override
+                       public int visit(IASTDeclSpecifier declSpec) {
+                               if (declSpec instanceof ICPPASTCompositeTypeSpecifier) {
+                                       result.setObject((ICPPASTCompositeTypeSpecifier) declSpec);
+                                       return PROCESS_ABORT;
+                               }
+                               return super.visit(declSpec);
+                       }
+               });
+               return result.getObject();
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/Messages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/Messages.java
new file mode 100644 (file)
index 0000000..21d6207
--- /dev/null
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *        Emanuel Graf IFS - initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+       public static String DeclaratorFinder_NestedFunction;
+       public static String DeclaratorFinder_NoDeclarator;
+       public static String DeclaratorFinder_MultipleDeclarators;
+       public static String RefactoringJob_UndoName;
+       public static String ToggleFileCreator_andMove;
+       public static String ToggleFileCreator_CanNotCreateNewFile;
+       public static String ToggleFileCreator_CreateNewFile;
+       public static String ToggleFileCreator_NewImplFile;
+       public static String ToggleFileCreator_NoTuForSibling;
+       public static String ToggleFileCreator_QMark;
+       public static String ToggleFromClassToInHeaderStrategy_DefAndDecInsideClass;
+       public static String EditGroupName;
+       public static String ToggleFromImplementationToHeaderOrClassStrategy_CanNotCreateNewFile;
+       public static String ToggleFromImplementationToHeaderOrClassStrategy_CanNotToggle;
+       public static String ToggleFromInHeaderToClassStrategy_CanNotToggleTemplateFreeFunction;
+       public static String ToggleFromInHeaderToImplementationStrategy_CanNotCreateImplFile;
+       public static String ToggleRefactoring_AnalyseSelection;
+       public static String ToggleRefactoring_CalculateModifications;
+       public static String ToggleRefactoring_CanNotSaveFiles;
+       public static String ToggleRefactoring_InvalidSelection;
+       public static String ToggleRefactoring_NoIndex;
+       public static String ToggleRefactoring_WaitingForIndexer;
+       public static String ToggleRefactoringContext_MultipleDeclarations;
+       public static String ToggleRefactoringContext_MultipleDefinitions;
+       public static String ToggleRefactoringContext_NoDefinitionFound;
+       public static String ToggleRefactoringContext_NoTuFound;
+       public static String ToggleStrategyFactory_NoDefinitionFound;
+       public static String ToggleStrategyFactory_UnsupportedSituation;
+
+       static {
+               NLS.initializeMessages(Messages.class.getName(), Messages.class);
+       }
+
+       // Do not instantiate
+       private Messages() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/Messages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/Messages.properties
new file mode 100644 (file)
index 0000000..e7df79b
--- /dev/null
@@ -0,0 +1,39 @@
+###############################################################################
+# Copyright (c) 2011 Institute for Software, HSR Hochschule fuer Technik  
+# Rapperswil, University of applied sciences and others.
+# All rights reserved. This program and the accompanying materials 
+# are made available under the terms of the Eclipse Public License v1.0 
+# which accompanies this distribution, and is available at 
+# http://www.eclipse.org/legal/epl-v10.html  
+# 
+# Contributors: 
+#              Martin Schwab & Thomas Kallenberg - initial API and implementation 
+###############################################################################
+DeclaratorFinder_NestedFunction=Nested function declarations not supported
+DeclaratorFinder_NoDeclarator=cannot work without declarator
+DeclaratorFinder_MultipleDeclarators=cannot work with multiple declarators
+RefactoringJob_UndoName=toggle function definition
+ToggleFileCreator_andMove=\ and move 
+ToggleFileCreator_CanNotCreateNewFile=Cannot create new filechange
+ToggleFileCreator_CreateNewFile=Create a new file named: 
+ToggleFileCreator_NewImplFile=New Implementation file?
+ToggleFileCreator_NoTuForSibling=Cannot find translation unit for sibling file
+ToggleFileCreator_QMark=?
+ToggleFromClassToInHeaderStrategy_DefAndDecInsideClass=Definition and Declaration both inside class. Behavior is undefined.
+ToggleFromImplementationToHeaderOrClassStrategy_CanNotCreateNewFile=Cannot create new File
+ToggleFromImplementationToHeaderOrClassStrategy_CanNotToggle=Not a free function. Cannot decide where to toggle
+ToggleFromInHeaderToClassStrategy_CanNotToggleTemplateFreeFunction=Cannot toggle templated free function
+EditGroupName=Toggle function body placement
+ToggleFromInHeaderToImplementationStrategy_CanNotCreateImplFile=Cannot create new Implementation File
+ToggleRefactoring_AnalyseSelection=analyzing user text selection
+ToggleRefactoring_CalculateModifications=calculating required code modifications
+ToggleRefactoring_CanNotSaveFiles=Cannot save files
+ToggleRefactoring_InvalidSelection=Invalid selection
+ToggleRefactoring_NoIndex=cannot work without the indexer
+ToggleRefactoring_WaitingForIndexer=waiting for indexer
+ToggleRefactoringContext_MultipleDeclarations=multiple declarations would result in ambiguous results
+ToggleRefactoringContext_MultipleDefinitions=one-definition-rule broken
+ToggleRefactoringContext_NoDefinitionFound=cannot work without definition
+ToggleRefactoringContext_NoTuFound=cannot work without translation unit
+ToggleStrategyFactory_NoDefinitionFound=cannot work without function definition
+ToggleStrategyFactory_UnsupportedSituation=Unsupported situation for moving function body.
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/NotSupportedException.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/NotSupportedException.java
new file mode 100644 (file)
index 0000000..4c32593
--- /dev/null
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *             Martin Schwab & Thomas Kallenberg - initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
+
+/**
+ * Thrown when the developer had no time to implement a special case the user
+ * tried to refactor.
+ * 
+ */
+public class NotSupportedException extends RuntimeException {
+
+       private static final long serialVersionUID = -4359705945683270L;
+
+       public NotSupportedException(String message) {
+               super(message);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/RefactoringJob.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/RefactoringJob.java
new file mode 100644 (file)
index 0000000..633574d
--- /dev/null
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.IUndoManager;
+import org.eclipse.ltk.core.refactoring.NullChange;
+import org.eclipse.ltk.core.refactoring.Refactoring;
+import org.eclipse.ltk.core.refactoring.RefactoringCore;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+class RefactoringJob extends Job {
+       public final static Object FAMILY_TOGGLE_DEFINITION = new Object();
+       private final Refactoring refactoring;
+       
+       RefactoringJob(Refactoring refactoring) {
+               super("'toggle function definition' code automation"); //$NON-NLS-1$
+               this.refactoring = refactoring;
+               setPriority(Job.SHORT);
+       }
+       
+       @Override
+       public boolean belongsTo(Object family) {
+               return family == FAMILY_TOGGLE_DEFINITION;
+       }
+       
+       @Override
+       protected IStatus run(IProgressMonitor monitor) {
+               IUndoManager undoManager = RefactoringCore.getUndoManager();
+               Change change = new NullChange();
+               Change undoChange = new NullChange();
+               boolean success = false;
+               try {
+                       RefactoringStatus status = refactoring.checkAllConditions(monitor);
+                       if (status.hasFatalError())
+                               return new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, status.getMessageMatchingSeverity(RefactoringStatus.ERROR));
+                       change = refactoring.createChange(monitor);
+                       change.initializeValidationData(monitor);
+                       if (!change.isValid(monitor).isOK()) {
+                               return Status.CANCEL_STATUS;
+                       }
+                       undoManager.aboutToPerformChange(change);
+                       undoChange = change.perform(monitor);
+                       success = true;
+               } catch (IllegalStateException e) {
+                       CUIPlugin.log("Another refactoring is still in progress, aborting.", e); //$NON-NLS-1$
+               } catch (CoreException e) {
+                       CUIPlugin.log("Failure during generation of changes.", e); //$NON-NLS-1$
+               } finally {
+                       undoChange.initializeValidationData(monitor);
+                       undoManager.changePerformed(change, success);
+                       try {
+                               if (success && undoChange.isValid(monitor).isOK()) {
+                                       // Note: addUndo MUST be called AFTER changePerformed or
+                                       // the change won't be unlocked correctly. (17.11.2010)
+                                       undoManager.addUndo(Messages.RefactoringJob_UndoName, undoChange);
+                               }
+                       } catch (OperationCanceledException e) {
+                       } catch (CoreException e) {
+                       }
+               }
+               return Status.OK_STATUS;
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFileCreator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFileCreator.java
new file mode 100644 (file)
index 0000000..36d091d
--- /dev/null
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *             Martin Schwab & Thomas Kallenberg - initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModelUtil;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.refactoring.Container;
+import org.eclipse.cdt.internal.ui.refactoring.CreateFileChange;
+
+public class ToggleFileCreator {
+
+       private static final String EMPTY_STRING = ""; //$NON-NLS-1$
+       private static final String H = ".h"; //$NON-NLS-1$
+       private ToggleRefactoringContext context;
+       private String ending;
+
+       public ToggleFileCreator(ToggleRefactoringContext context, String ending) {
+               this.context = context;
+               this.ending = ending;
+       }
+       
+       public IASTTranslationUnit loadTranslationUnit() {
+               String filename;
+               if (context.getDeclaration() != null) {
+                       filename = context.getDeclaration().getContainingFilename();
+               } else {
+                       filename = context.getDefinition().getContainingFilename();
+               }
+               String other;
+               if (ending.equals(H)) {
+                       other = ".cpp"; //$NON-NLS-1$
+               } else {
+                       other = H;
+               }
+               filename = filename.replaceAll("\\w*" + other + "$", EMPTY_STRING) + getNewFileName();  //$NON-NLS-1$//$NON-NLS-2$
+               IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filename));
+               IASTTranslationUnit result = null;
+               try {
+                       result = CoreModelUtil.findTranslationUnitForLocation(file.getFullPath(), null).getAST();
+               } catch (CModelException e) {
+               } catch (CoreException e) {
+               }
+               if (result == null) {
+                       throw new NotSupportedException(Messages.ToggleFileCreator_NoTuForSibling);
+               }
+               return result;
+       }
+       
+       public void createNewFile() {
+               CreateFileChange change;
+               String filename = getNewFileName();
+               try {
+                       change = new CreateFileChange(filename, new     Path(getPath()+filename), 
+                                       EMPTY_STRING, context.getSelectionFile().getCharset());
+                       change.perform(new NullProgressMonitor());
+               } catch (CoreException e) {
+                       throw new NotSupportedException(Messages.ToggleFileCreator_CanNotCreateNewFile);
+               }
+       }
+       
+       public boolean askUserForFileCreation(final ToggleRefactoringContext context) {
+               if (context.isSettedDefaultAnswer()) {
+                       return context.getDefaultAnswer();
+               }
+               final Container<Boolean> answer = new Container<Boolean>();
+               Runnable r = new Runnable() {
+                       public void run() {
+                               Shell shell = CUIPlugin.getDefault().getWorkbench().getWorkbenchWindows()[0].getShell();
+                               String functionname;
+                               if (context.getDeclaration() != null) {
+                                       functionname = context.getDeclaration().getRawSignature();
+                               } else {
+                                       functionname = context.getDefinition().getDeclarator().getRawSignature();
+                               }
+                               boolean createnew = MessageDialog.openQuestion(shell, Messages.ToggleFileCreator_NewImplFile, 
+                                               Messages.ToggleFileCreator_CreateNewFile + getNewFileName() + Messages.ToggleFileCreator_andMove + functionname + Messages.ToggleFileCreator_QMark);
+                               answer.setObject(createnew);
+                       }
+               };
+               PlatformUI.getWorkbench().getDisplay().syncExec(r);
+               return answer.getObject();
+       }
+
+       public String getIncludeStatement() {
+               return "#include \"" + ToggleNodeHelper.getFilenameWithoutExtension(getNewFileName()) + ".h\"";  //$NON-NLS-1$//$NON-NLS-2$
+       }
+       
+       private String getNewFileName() {
+               return ToggleNodeHelper.getFilenameWithoutExtension(context.getSelectionFile().getFullPath().toString()) + ending;
+       }
+       
+       private String getPath() {
+               String result = context.getSelectionFile().getFullPath().toOSString();
+               return result.replaceAll("(\\w)*\\.(\\w)*", EMPTY_STRING); //$NON-NLS-1$
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromClassToInHeaderStrategy.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromClassToInHeaderStrategy.java
new file mode 100644 (file)
index 0000000..2c749f3
--- /dev/null
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *             Martin Schwab & Thomas Kallenberg - initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
+
+import org.eclipse.text.edits.TextEditGroup;
+
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTNode.CopyStyle;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.INodeFactory;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionWithTryBlock;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
+import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
+
+import org.eclipse.cdt.internal.ui.refactoring.ModificationCollector;
+
+public class ToggleFromClassToInHeaderStrategy implements IToggleRefactoringStrategy {
+
+       protected TextEditGroup infoText = new TextEditGroup(Messages.EditGroupName);
+       private ToggleRefactoringContext context;
+
+       public ToggleFromClassToInHeaderStrategy(ToggleRefactoringContext context) {
+               if (isInClass(context.getDeclaration()) && isInClass(context.getDefinition()))
+                       throw new NotSupportedException(Messages.ToggleFromClassToInHeaderStrategy_DefAndDecInsideClass);
+               this.context = context;
+       }
+
+       private boolean isInClass(IASTNode node) {
+               return ToggleNodeHelper.getAncestorOfType(node, 
+                               ICPPASTCompositeTypeSpecifier.class) != null;
+       }
+
+       public void run(ModificationCollector modifications) {
+               IASTNode parentNamespace = getParentNamespace();
+               IASTNode newDefinition = getNewDefinition(parentNamespace);
+               IASTSimpleDeclaration newDeclaration = getNewDeclaration();
+               ASTRewrite rewriter = replaceDefinitionWithDeclaration(modifications, newDeclaration);
+               IASTNode insertion_point = getInsertionPoint(parentNamespace);
+               rewriter.insertBefore(parentNamespace, 
+                               insertion_point, newDefinition, infoText);
+       }
+
+       private IASTNode getNewDefinition(IASTNode parentNamespace) {
+               IASTNode newDefinition = ToggleNodeHelper.getQualifiedNameDefinition(
+                               context.getDefinition(), context.getDefinitionUnit(), parentNamespace);
+               ((IASTFunctionDefinition) newDefinition).setBody(context.getDefinition().getBody()
+                               .copy(CopyStyle.withLocations));
+               if (newDefinition instanceof ICPPASTFunctionWithTryBlock) {
+                       ICPPASTFunctionWithTryBlock newTryFun = (ICPPASTFunctionWithTryBlock) newDefinition;
+                       ICPPASTFunctionWithTryBlock oldTryFun = (ICPPASTFunctionWithTryBlock) context.getDefinition();
+                       for (ICPPASTCatchHandler catchH : oldTryFun.getCatchHandlers()) {
+                               newTryFun.addCatchHandler(catchH.copy(CopyStyle.withLocations));
+                       }
+               }
+               ICPPASTTemplateDeclaration templdecl = ToggleNodeHelper.getTemplateDeclaration(
+                               context.getDefinition(), (IASTFunctionDefinition) newDefinition);
+               if (templdecl != null) {
+                       newDefinition = templdecl;
+               }
+               newDefinition.setParent(context.getDefinitionUnit());
+               return newDefinition;
+       }
+
+       private IASTNode getParentNamespace() {
+               IASTNode parentNamespace = ToggleNodeHelper.getAncestorOfType(
+                               context.getDefinition(), ICPPASTNamespaceDefinition.class);
+               if (parentNamespace == null)
+                       parentNamespace = context.getDefinitionUnit();
+               return parentNamespace;
+       }
+
+       private IASTNode getInsertionPoint(IASTNode parentNamespace) {
+               IASTTranslationUnit unit = parentNamespace.getTranslationUnit();
+               IASTNode insertion_point = InsertionPointFinder.findInsertionPoint(
+                               unit, unit, context.getDefinition().getDeclarator());
+               return insertion_point;
+       }
+
+       private ASTRewrite replaceDefinitionWithDeclaration(
+                       ModificationCollector modifications,
+                       IASTSimpleDeclaration newDeclaration) {
+               ASTRewrite rewriter = modifications.rewriterForTranslationUnit(
+                               context.getDefinitionUnit());
+               rewriter.replace(context.getDefinition(), newDeclaration, infoText);
+               return rewriter;
+       }
+
+       private IASTSimpleDeclaration getNewDeclaration() {
+               INodeFactory factory = context.getDefinitionUnit().getASTNodeFactory();
+               IASTDeclSpecifier newDeclSpecifier = context.getDefinition().getDeclSpecifier()
+                               .copy(CopyStyle.withLocations);
+               newDeclSpecifier.setInline(false);
+               IASTSimpleDeclaration newDeclaration = factory.newSimpleDeclaration(newDeclSpecifier);
+               IASTFunctionDeclarator newDeclarator = context.getDefinition().getDeclarator()
+                               .copy(CopyStyle.withLocations);
+               newDeclaration.addDeclarator(newDeclarator);
+               newDeclaration.setParent(context.getDefinition().getParent());
+               return newDeclaration;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromImplementationToHeaderOrClassStrategy.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromImplementationToHeaderOrClassStrategy.java
new file mode 100644 (file)
index 0000000..83de337
--- /dev/null
@@ -0,0 +1,180 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *             Martin Schwab & Thomas Kallenberg - initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
+
+import java.util.List;
+
+import org.eclipse.text.edits.TextEditGroup;
+
+import org.eclipse.cdt.core.dom.ast.IASTComment;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTNode.CopyStyle;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionWithTryBlock;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
+import org.eclipse.cdt.core.dom.rewrite.ASTRewrite.CommentPosition;
+
+import org.eclipse.cdt.internal.core.dom.rewrite.ASTLiteralNode;
+
+import org.eclipse.cdt.internal.ui.refactoring.ModificationCollector;
+import org.eclipse.cdt.internal.ui.refactoring.utils.CPPASTAllVisitor;
+
+public class ToggleFromImplementationToHeaderOrClassStrategy implements IToggleRefactoringStrategy {
+
+       private ToggleRefactoringContext context;
+       private TextEditGroup infoText;
+       private IASTTranslationUnit other_tu;
+       private ASTLiteralNode includenode;
+
+       public ToggleFromImplementationToHeaderOrClassStrategy(
+                       ToggleRefactoringContext context) {
+               this.context = context;
+               this.infoText = new TextEditGroup(Messages.EditGroupName);
+       }
+
+       private boolean isFreeFunction(IASTFunctionDefinition definition) {
+               return definition.getDeclarator().getName() instanceof ICPPASTQualifiedName;
+       }
+       
+       public void run(ModificationCollector modifications) {
+               newFileCheck();
+               ASTRewrite implast = modifications.rewriterForTranslationUnit(context.getDefinitionUnit());
+               List<IASTComment>leadingComments = implast.getComments(context.getDefinition(), CommentPosition.leading);
+               removeDefinitionFromImplementation(implast);
+               if (includenode != null) {
+                       implast.insertBefore(context.getDefinitionUnit(), 
+                                       context.getDefinitionUnit().getChildren()[0], includenode, infoText);
+               }
+               if (context.getDeclarationUnit() != null) {
+                       addDefinitionToClass(modifications, leadingComments);
+               } else {
+                       addDefinitionToHeader(modifications, leadingComments);
+               }
+       }
+
+       private void newFileCheck() {
+               if (context.getDeclarationUnit() == null) {
+                       if (isFreeFunction(context.getDefinition())) {
+                               throw new NotSupportedException(Messages.ToggleFromImplementationToHeaderOrClassStrategy_CanNotToggle);
+                       }
+                       other_tu = context.getTUForSiblingFile();
+                       if (other_tu == null) {
+                               ToggleFileCreator filecreator = new ToggleFileCreator(context, ".h"); //$NON-NLS-1$
+                               if (filecreator.askUserForFileCreation(context)) {
+                                       filecreator.createNewFile();
+                                       other_tu = filecreator.loadTranslationUnit();
+                                       includenode = new ASTLiteralNode(filecreator.getIncludeStatement() + "\n\n"); //$NON-NLS-1$
+                               } else {
+                                       throw new NotSupportedException(Messages.ToggleFromImplementationToHeaderOrClassStrategy_CanNotCreateNewFile);
+                               }
+                       }
+               }
+       }
+
+       private void addDefinitionToHeader(ModificationCollector modifications, List<IASTComment> leadingComments) {
+               ASTRewrite headerRewrite = modifications.rewriterForTranslationUnit(other_tu);
+               IASTFunctionDefinition newDefinition = ToggleNodeHelper.createFunctionSignatureWithEmptyBody(
+context
+                               .getDefinition().getDeclSpecifier().copy(CopyStyle.withLocations), context.getDefinition()
+                               .getDeclarator().copy(CopyStyle.withLocations),
+                               context.getDefinition().copy(CopyStyle.withLocations));
+               newDefinition.setParent(other_tu);
+               headerRewrite.insertBefore(other_tu.getTranslationUnit(), null, newDefinition, infoText);
+               restoreBody(headerRewrite, newDefinition, modifications);
+               for (IASTComment comment : leadingComments) {                   
+                       headerRewrite.addComment(newDefinition, comment, CommentPosition.leading);
+               }
+       }
+
+       private void addDefinitionToClass(ModificationCollector modifications, List<IASTComment> leadingComments) {
+               ASTRewrite headerRewrite = modifications.rewriterForTranslationUnit(
+                               context.getDeclarationUnit());
+               IASTFunctionDefinition newDefinition = ToggleNodeHelper.createInClassDefinition(
+                               context.getDeclaration(), context.getDefinition(), 
+                               context.getDeclarationUnit());
+               newDefinition.setParent(getParent());
+               restoreBody(headerRewrite, newDefinition, modifications);
+               headerRewrite.replace(context.getDeclaration().getParent(), newDefinition, infoText);
+               for (IASTComment comment : leadingComments) {                   
+                       headerRewrite.addComment(newDefinition, comment, CommentPosition.leading);
+               }
+       }
+
+       private IASTNode getParent() {
+               IASTNode parent = ToggleNodeHelper.getAncestorOfType(context.getDefinition(), 
+                               ICPPASTCompositeTypeSpecifier.class);
+               IASTNode parentnode = null;
+               if (parent != null) {
+                       parentnode  = parent;
+               }
+               else {
+                       parentnode =context.getDeclarationUnit();
+               }
+               return parentnode;
+       }
+
+       private void restoreBody(ASTRewrite headerRewrite, IASTFunctionDefinition newDefinition,
+                       ModificationCollector modifications) {
+               IASTFunctionDefinition oldDefinition = context.getDefinition();
+               newDefinition.setBody(oldDefinition.getBody().copy(CopyStyle.withLocations));
+               
+               if (newDefinition instanceof ICPPASTFunctionWithTryBlock && oldDefinition instanceof ICPPASTFunctionWithTryBlock) {
+                       ICPPASTFunctionWithTryBlock newTryDef = (ICPPASTFunctionWithTryBlock) newDefinition;
+                       ICPPASTFunctionWithTryBlock oldTryDef = (ICPPASTFunctionWithTryBlock) oldDefinition;
+                       for (ICPPASTCatchHandler handler : oldTryDef.getCatchHandlers()) {
+                               newTryDef.addCatchHandler(handler.copy(CopyStyle.withLocations));
+                       }
+               }
+               copyAllCommentsToNewLocation(oldDefinition, modifications.rewriterForTranslationUnit(oldDefinition.getTranslationUnit()), headerRewrite);
+       }
+       
+       private void copyAllCommentsToNewLocation(IASTNode node, final ASTRewrite oldRw, final ASTRewrite newRw) {
+               node.accept(new CPPASTAllVisitor() {
+                       @Override
+                       public int visitAll(IASTNode node){
+                               copyComments(oldRw, newRw, node, CommentPosition.leading);
+                               copyComments(oldRw, newRw, node, CommentPosition.trailing);
+                               copyComments(oldRw, newRw, node, CommentPosition.freestanding);
+                               return PROCESS_CONTINUE;
+                       }
+
+                       private void copyComments(final ASTRewrite oldRw, final ASTRewrite newRw, IASTNode node,
+                                       CommentPosition pos) {
+                               List<IASTComment> comments = oldRw.getComments(node, pos);
+                               for (IASTComment comment : comments) {
+                                       newRw.addComment(node, comment, pos);
+                               }
+                       }
+               });
+               
+       }
+
+       private void removeDefinitionFromImplementation(ASTRewrite implast) {
+               ICPPASTNamespaceDefinition ns = ToggleNodeHelper.getAncestorOfType(
+                               context.getDefinition(), ICPPASTNamespaceDefinition.class);
+               if (ns != null && isSingleElementInNamespace(ns, context.getDefinition())) {
+                       implast.remove(ns, infoText);
+               } else {
+                       implast.remove(context.getDefinition(), infoText);
+               }
+       }
+
+       private boolean isSingleElementInNamespace(ICPPASTNamespaceDefinition ns,
+                       IASTFunctionDefinition definition) {
+               return ns.getChildren().length == 2 && (ns.contains(definition));
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromInHeaderToClassStrategy.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromInHeaderToClassStrategy.java
new file mode 100644 (file)
index 0000000..b8aafee
--- /dev/null
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *             Martin Schwab & Thomas Kallenberg - initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
+
+import java.util.List;
+
+import org.eclipse.text.edits.TextEditGroup;
+
+import org.eclipse.cdt.core.dom.ast.IASTComment;
+import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTNode.CopyStyle;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionWithTryBlock;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
+import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
+import org.eclipse.cdt.core.dom.rewrite.ASTRewrite.CommentPosition;
+
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclaration;
+
+import org.eclipse.cdt.internal.ui.refactoring.ModificationCollector;
+
+public class ToggleFromInHeaderToClassStrategy implements IToggleRefactoringStrategy {
+
+       private TextEditGroup infoText;
+       private ToggleRefactoringContext context;
+
+       public ToggleFromInHeaderToClassStrategy(ToggleRefactoringContext context) {
+               if (isFreeFunction(context))
+                       throw new NotSupportedException(Messages.ToggleFromInHeaderToClassStrategy_CanNotToggleTemplateFreeFunction);
+               this.context = context;
+               this.infoText =  new TextEditGroup(Messages.EditGroupName);
+       }
+
+       private boolean isFreeFunction(ToggleRefactoringContext context) {
+               return isNotInsideAClass(context.getDefinition().getDeclarator(),
+                               context.getDeclaration());
+       }
+       
+       boolean isNotInsideAClass(IASTFunctionDeclarator declarator, IASTFunctionDeclarator backup) {
+               if (declarator.getName() instanceof ICPPASTQualifiedName) {
+                       declarator = backup;
+               }
+               return (ToggleNodeHelper.getAncestorOfType(declarator,
+                               IASTCompositeTypeSpecifier.class) == null);
+       }
+
+       public void run(ModificationCollector modifications) {
+               ASTRewrite rewriter = removeDefinition(modifications);
+               IASTFunctionDefinition newDefinition = getNewDefinition();
+               replaceDeclarationWithDefinition(rewriter, newDefinition);
+               
+               IASTNode parentTemplateDeclaration = 
+                       ToggleNodeHelper.getParentTemplateDeclaration(context.getDeclaration());
+               if (parentTemplateDeclaration instanceof ICPPASTTemplateDeclaration) {
+               } else {
+                       restoreLeadingComments(rewriter, newDefinition);
+               }
+       }
+
+       private void restoreLeadingComments(ASTRewrite rewriter, IASTFunctionDefinition newDefinition) {
+               List<IASTComment>comments = rewriter.getComments(context.getDefinition().getParent(), CommentPosition.leading);
+               if(comments != null) {
+                       for (IASTComment comment : comments) {
+                               rewriter.addComment(newDefinition, comment, CommentPosition.leading);
+                               rewriter.remove(comment, infoText);
+                       }
+               }
+       }
+
+       private ASTRewrite removeDefinition(ModificationCollector modifications) {
+               ASTRewrite rewriter = modifications.rewriterForTranslationUnit(context.getDefinitionUnit());
+               IASTNode parentRemovePoint = ToggleNodeHelper.getParentRemovePoint(context.getDefinition());
+               rewriter.remove(parentRemovePoint, infoText);
+               return rewriter;
+       }
+
+       private IASTFunctionDefinition getNewDefinition() {
+               IASTFunctionDefinition newDefinition = ToggleNodeHelper.createInClassDefinition(
+                               context.getDeclaration(), context.getDefinition(), context.getDefinitionUnit());
+               newDefinition.setBody(context.getDefinition().getBody().copy(CopyStyle.withLocations));
+               if (newDefinition instanceof ICPPASTFunctionWithTryBlock) {
+                       ICPPASTFunctionWithTryBlock newTryFun = (ICPPASTFunctionWithTryBlock) newDefinition;
+                       ICPPASTFunctionWithTryBlock oldTryFun = (ICPPASTFunctionWithTryBlock) context.getDefinition();
+                       for (ICPPASTCatchHandler catchH : oldTryFun.getCatchHandlers()) {
+                               newTryFun.addCatchHandler(catchH.copy(CopyStyle.withLocations));
+                       }
+               }
+               
+               IASTNode parent = ToggleNodeHelper.getAncestorOfType(context.getDefinition(), 
+                               ICPPASTCompositeTypeSpecifier.class);
+               if (parent != null) {
+                       newDefinition.setParent(parent);
+               }
+               else {
+                       newDefinition.setParent(context.getDefinitionUnit());
+               }
+               return newDefinition;
+       }
+
+       private ASTRewrite replaceDeclarationWithDefinition(ASTRewrite rewriter,
+                       IASTFunctionDefinition newDefinition) {
+               IASTSimpleDeclaration fullDeclaration = ToggleNodeHelper.getAncestorOfType(
+                               context.getDeclaration(), CPPASTSimpleDeclaration.class);
+               ASTRewrite newRewriter = rewriter.replace(fullDeclaration, newDefinition, infoText);
+               return newRewriter;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromInHeaderToImplementationStrategy.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromInHeaderToImplementationStrategy.java
new file mode 100644 (file)
index 0000000..36eba0e
--- /dev/null
@@ -0,0 +1,382 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *             Martin Schwab & Thomas Kallenberg - initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
+
+import java.util.List;
+
+import org.eclipse.text.edits.TextEditGroup;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTArrayModifier;
+import org.eclipse.cdt.core.dom.ast.IASTComment;
+import org.eclipse.cdt.core.dom.ast.IASTCopyLocation;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTNode.CopyStyle;
+import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
+import org.eclipse.cdt.core.dom.ast.IASTProblem;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTStatement;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IASTTypeId;
+import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCapture;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionWithTryBlock;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
+import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
+import org.eclipse.cdt.core.dom.rewrite.ASTRewrite.CommentPosition;
+
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNamespaceDefinition;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTQualifiedName;
+import org.eclipse.cdt.internal.core.dom.rewrite.ASTLiteralNode;
+
+import org.eclipse.cdt.internal.ui.refactoring.Container;
+import org.eclipse.cdt.internal.ui.refactoring.ModificationCollector;
+
+public class ToggleFromInHeaderToImplementationStrategy implements IToggleRefactoringStrategy {
+
+       private IASTTranslationUnit impl_unit;
+       private ToggleRefactoringContext context;
+       private TextEditGroup infoText;
+       private ASTLiteralNode includenode;
+
+       public ToggleFromInHeaderToImplementationStrategy(final ToggleRefactoringContext context) {
+               this.infoText = new TextEditGroup(Messages.EditGroupName);
+               this.context = context;
+       }
+
+       public void run(ModificationCollector collector) {
+               if(!newFileCheck()) {
+                       return;
+               }
+//             newFileCheck();
+               ICPPASTFunctionDefinition newDefinition = getNewDefinition();
+               if (context.getDeclaration() != null) {
+                       removeDefinitionFromHeader(collector);
+               }
+               else {
+                       replaceDefinitionWithDeclaration(collector);
+               }
+
+               ASTRewrite implRewrite = collector.rewriterForTranslationUnit(impl_unit);
+               if (includenode != null) {
+                       implRewrite.insertBefore(impl_unit, null, includenode, infoText);
+               }
+               
+               IASTNode insertionParent = null;
+               ICPPASTNamespaceDefinition parent = getParentNamespace();
+               
+               if (parent != null) {
+                       adaptQualifiedNameToNamespaceLevel(newDefinition, parent);
+                       insertionParent = searchNamespaceInImplementation(parent.getName());
+                       if (insertionParent == null) {
+                               insertionParent = createNamespace(parent);
+                               implRewrite = implRewrite.insertBefore(impl_unit.getTranslationUnit(), 
+                                               null, insertionParent, infoText);
+                       }
+               }
+               else {
+                       insertionParent = impl_unit.getTranslationUnit();
+               }
+               
+               newDefinition.setParent(insertionParent);
+               
+               IASTNode insertionPoint = findInsertionPoint(insertionParent, 
+                               context.getDeclarationUnit());
+               ASTRewrite newRewriter = implRewrite.insertBefore(insertionParent, 
+                               insertionPoint, newDefinition, infoText);
+               copyCommentsToNewFile(newDefinition, newRewriter, collector.rewriterForTranslationUnit(context.getDefinitionUnit()));
+               restoreLeadingComments(newDefinition, newRewriter, collector);
+       }
+
+       private void copyCommentsToNewFile(ICPPASTFunctionDefinition newDefinition, final ASTRewrite newRewriter,
+                       final ASTRewrite oldRewriter) {
+               newDefinition.accept(new ASTVisitor(true) {
+                       
+                       private void copy(IASTNode node) {
+                               copyComments(node, newRewriter, oldRewriter, CommentPosition.leading);
+                               copyComments(node, newRewriter, oldRewriter, CommentPosition.trailing);
+                               copyComments(node, newRewriter, oldRewriter, CommentPosition.freestanding);
+                       }
+
+                       private void copyComments(IASTNode node, ASTRewrite newRewriter, ASTRewrite oldRewriter,
+                                       CommentPosition pos) {
+                               if (node.getNodeLocations().length > 0 && node.getNodeLocations()[0] instanceof IASTCopyLocation) {
+                                       IASTCopyLocation copyLoc = (IASTCopyLocation) node.getNodeLocations()[0];
+                                       List<IASTComment> comments = oldRewriter.getComments(copyLoc.getOriginalNode(), pos);
+                                       for (IASTComment comment : comments) {
+                                               newRewriter.addComment(node, comment, pos);
+                                       }
+                               }
+                               
+                       }
+
+                       @Override
+                       public int visit(IASTName name) {
+                               copy(name);
+                               return super.visit(name);
+                       }
+
+                       @Override
+                       public int visit(IASTDeclaration declaration) {
+                               copy(declaration);
+                               return super.visit(declaration);
+                       }
+
+                       @Override
+                       public int visit(IASTInitializer initializer) {
+                               copy(initializer);
+                               return super.visit(initializer);
+                       }
+
+                       @Override
+                       public int visit(IASTParameterDeclaration parameterDeclaration) {
+                               copy(parameterDeclaration);
+                               return super.visit(parameterDeclaration);
+                       }
+
+                       @Override
+                       public int visit(IASTDeclarator declarator) {
+                               copy(declarator);
+                               return super.visit(declarator);
+                       }
+
+                       @Override
+                       public int visit(IASTDeclSpecifier declSpec) {
+                               copy(declSpec);
+                               return super.visit(declSpec);
+                       }
+
+                       @Override
+                       public int visit(IASTArrayModifier arrayModifier) {
+                               copy(arrayModifier);
+                               return super.visit(arrayModifier);
+                       }
+
+                       @Override
+                       public int visit(IASTPointerOperator ptrOperator) {
+                               copy(ptrOperator);
+                               return super.visit(ptrOperator);
+                       }
+
+                       @Override
+                       public int visit(IASTExpression expression) {
+                               copy(expression);
+                               return super.visit(expression);
+                       }
+
+                       @Override
+                       public int visit(IASTStatement statement) {
+                               copy(statement);
+                               return super.visit(statement);
+                       }
+
+                       @Override
+                       public int visit(IASTTypeId typeId) {
+                               copy(typeId);
+                               return super.visit(typeId);
+                       }
+
+                       @Override
+                       public int visit(IASTEnumerator enumerator) {
+                               copy(enumerator);
+                               return super.visit(enumerator);
+                       }
+
+                       @Override
+                       public int visit(IASTProblem problem) {
+                               copy(problem);
+                               return super.visit(problem);
+                       }
+
+                       @Override
+                       public int visit(ICPPASTBaseSpecifier baseSpecifier) {
+                               copy(baseSpecifier);
+                               return super.visit(baseSpecifier);
+                       }
+
+                       @Override
+                       public int visit(ICPPASTNamespaceDefinition namespaceDefinition) {
+                               copy(namespaceDefinition);
+                               return super.visit(namespaceDefinition);
+                       }
+
+                       @Override
+                       public int visit(ICPPASTTemplateParameter templateParameter) {
+                               copy(templateParameter);
+                               return super.visit(templateParameter);
+                       }
+
+                       @Override
+                       public int visit(ICPPASTCapture capture) {
+                               copy(capture);
+                               return super.visit(capture);
+                       }
+
+                       @Override
+                       public int visit(ICASTDesignator designator) {
+                               copy(designator);
+                               return super.visit(designator);
+                       }
+               });
+               
+       }
+
+       private boolean newFileCheck() {
+               impl_unit = context.getTUForSiblingFile();
+               if (this.impl_unit == null) {
+                       ToggleFileCreator filecreator = new ToggleFileCreator(context, ".cpp"); //$NON-NLS-1$
+                       if (filecreator.askUserForFileCreation(context)) {
+                               filecreator.createNewFile();
+                               impl_unit = filecreator.loadTranslationUnit();
+                               includenode = new ASTLiteralNode(filecreator.getIncludeStatement());
+                               return true;
+                       }else {
+                               return false;
+                       }
+               }
+               return true;
+       }
+
+       private ICPPASTNamespaceDefinition getParentNamespace() {
+               IASTNode toquery = context.getDeclaration();
+               if (toquery == null) {
+                       toquery = context.getDefinition();
+               }
+               return ToggleNodeHelper.getAncestorOfType(toquery, ICPPASTNamespaceDefinition.class);
+       }
+
+       private IASTNode findInsertionPoint(IASTNode insertionParent,
+                       IASTTranslationUnit unit) {
+               IASTFunctionDeclarator declarator = context.getDeclaration();
+               if (unit == null) {
+                       unit = context.getDefinitionUnit();
+               }
+               if (declarator == null) {
+                       declarator = context.getDefinition().getDeclarator();
+               }
+               IASTNode insertion_point = InsertionPointFinder.findInsertionPoint(
+                               unit, insertionParent.getTranslationUnit(), declarator);
+               return insertion_point;
+       }
+
+       private void restoreLeadingComments(
+                       ICPPASTFunctionDefinition newDefinition, ASTRewrite newRewriter, ModificationCollector collector) {
+               ASTRewrite rw = collector.rewriterForTranslationUnit(context.getDefinitionUnit());
+               List<IASTComment>comments = rw.getComments(context.getDefinition(), CommentPosition.leading);
+               if(comments != null) {
+                       for (IASTComment comment : comments) {
+                               newRewriter.addComment(newDefinition, comment, CommentPosition.leading);
+                               if(context.getDeclaration() != null) {
+                                       rw.remove(comment, infoText);
+                               }
+                       }
+               }
+       }
+
+       private void replaceDefinitionWithDeclaration(
+                       ModificationCollector collector) {
+               IASTSimpleDeclaration newdeclarator = 
+                       ToggleNodeHelper.createDeclarationFromDefinition(context.getDefinition());
+               ASTRewrite rewrite = collector.rewriterForTranslationUnit(context.getDefinitionUnit());
+               rewrite.replace(context.getDefinition(), newdeclarator, infoText);
+       }
+
+       private ICPPASTFunctionDefinition getNewDefinition() {
+               ICPPASTFunctionDefinition newDefinition =
+                       ToggleNodeHelper.createFunctionSignatureWithEmptyBody(
+                               context.getDefinition().getDeclSpecifier().copy(CopyStyle.withLocations), context
+                                               .getDefinition().getDeclarator().copy(CopyStyle.withLocations), context
+                                               .getDefinition().copy(CopyStyle.withLocations));
+               newDefinition.getDeclSpecifier().setInline(false);
+               newDefinition.setBody(context.getDefinition().getBody().copy(CopyStyle.withLocations));
+               if (newDefinition instanceof ICPPASTFunctionWithTryBlock) {
+                       ICPPASTFunctionWithTryBlock newTryFun = (ICPPASTFunctionWithTryBlock) newDefinition;
+                       ICPPASTFunctionWithTryBlock oldTryFun = (ICPPASTFunctionWithTryBlock) context.getDefinition();
+                       for (ICPPASTCatchHandler catchHandler : oldTryFun.getCatchHandlers()) {                         
+                               newTryFun.addCatchHandler(catchHandler.copy(CopyStyle.withLocations));
+                       }
+               }
+               return newDefinition;
+       }
+
+       private void adaptQualifiedNameToNamespaceLevel(
+                       IASTFunctionDefinition new_definition, IASTNode parent) {
+               if (parent instanceof ICPPASTNamespaceDefinition) {
+                       ICPPASTNamespaceDefinition ns = (ICPPASTNamespaceDefinition) parent;
+                       if (new_definition.getDeclarator().getName() instanceof ICPPASTQualifiedName) {
+                               ICPPASTQualifiedName qname = 
+                                       (ICPPASTQualifiedName) new_definition.getDeclarator().getName();
+                               ICPPASTQualifiedName qname_new = new CPPASTQualifiedName();
+                               boolean start = false;
+                               for(IASTName partname: qname.getNames()) {
+                                       if (partname.toString().equals(ns.getName().toString())) {
+                                               start = true;
+                                               continue;
+                                       }
+                                       if (start)
+                                               qname_new.addName(partname);
+                               }
+                               if (start)
+                                       new_definition.getDeclarator().setName(qname_new);
+                       }
+               }
+       }
+
+       private CPPASTNamespaceDefinition createNamespace(
+                       ICPPASTNamespaceDefinition parent_namespace) {
+               CPPASTNamespaceDefinition insertionParent = new CPPASTNamespaceDefinition(
+parent_namespace.getName()
+                               .copy(CopyStyle.withLocations));
+               insertionParent.setParent(impl_unit);
+               return insertionParent;
+       }
+
+       private void removeDefinitionFromHeader(ModificationCollector collector) {
+               ASTRewrite header_rewrite = collector.rewriterForTranslationUnit(
+                               context.getDefinitionUnit());
+               header_rewrite.remove(ToggleNodeHelper.getParentRemovePoint(context.getDefinition()), infoText);
+       }
+
+       private IASTNode searchNamespaceInImplementation(final IASTName name) {
+               final Container<IASTNode> result = new Container<IASTNode>();
+               this.impl_unit.accept(
+new ASTVisitor() {
+                                       {
+                                               shouldVisitNamespaces = true;
+                                       }
+                                       @Override
+                                       public int visit(ICPPASTNamespaceDefinition namespaceDefinition) {
+                                               if (name.toString().equals(namespaceDefinition.getName().toString())) {
+                                                       result.setObject(namespaceDefinition);
+                                                       return PROCESS_ABORT;
+                                               }
+                                               return super.visit(namespaceDefinition);
+                                       }
+               });
+               return result.getObject();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleNodeHelper.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleNodeHelper.java
new file mode 100644 (file)
index 0000000..f13fd5a
--- /dev/null
@@ -0,0 +1,477 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *             Martin Schwab & Thomas Kallenberg - initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Stack;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.ast.IASTComment;
+import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTNode.CopyStyle;
+import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionWithTryBlock;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
+import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
+import org.eclipse.cdt.core.dom.rewrite.ASTRewrite.CommentPosition;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexFile;
+import org.eclipse.cdt.core.index.IIndexInclude;
+import org.eclipse.cdt.core.index.IndexLocationFactory;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.CoreModelUtil;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCompoundStatement;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDefinition;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionWithTryBlock;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNamedTypeSpecifier;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTQualifiedName;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclaration;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTemplateId;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTypeId;
+import org.eclipse.cdt.internal.core.model.TranslationUnit;
+
+import org.eclipse.cdt.internal.ui.refactoring.ModificationCollector;
+import org.eclipse.cdt.internal.ui.refactoring.utils.NodeHelper;
+
+public class ToggleNodeHelper extends NodeHelper {
+       
+       private static final String EMPTY_STRING = ""; //$NON-NLS-1$
+
+       private static void removeParameterInitializations(IASTFunctionDeclarator funcDecl) {
+               for (IASTNode child : funcDecl.getChildren()) {
+                       if (child instanceof IASTParameterDeclaration) {
+                               IASTParameterDeclaration parameter = (IASTParameterDeclaration) child;
+                               parameter.getDeclarator().setInitializer(null);
+                       }
+               }
+       }
+
+       private static ArrayList<ICPPASTConstructorChainInitializer> 
+                       getInitializerList(IASTFunctionDefinition definition) {
+               ArrayList<ICPPASTConstructorChainInitializer> initalizers = 
+                       new ArrayList<ICPPASTConstructorChainInitializer>();
+       
+               for (IASTNode node : definition.getChildren()) {
+                       if (node instanceof ICPPASTConstructorChainInitializer) {
+                               initalizers.add(((ICPPASTConstructorChainInitializer) node).copy(CopyStyle.withLocations));
+                       }
+               }
+               return initalizers;
+       }
+
+       static IASTSimpleDeclaration createDeclarationFromDefinition(
+                       IASTFunctionDefinition oldDefinition) {
+               IASTDeclarator newDeclarator = oldDefinition.getDeclarator().copy(CopyStyle.withLocations);
+               IASTDeclSpecifier newDeclSpec = oldDefinition.getDeclSpecifier().copy(CopyStyle.withLocations);
+               IASTSimpleDeclaration newDeclaration = new CPPASTSimpleDeclaration(newDeclSpec);
+               newDeclaration.addDeclarator(newDeclarator);
+               return newDeclaration;
+       }
+
+       static ICPPASTFunctionDefinition createFunctionSignatureWithEmptyBody(
+                       IASTDeclSpecifier newDeclSpec, IASTFunctionDeclarator newFuncDecl, 
+                       IASTFunctionDefinition oldDefinition) {
+               ICPPASTFunctionDefinition newFunc = null;
+               newFuncDecl = adjustParamNames(newFuncDecl, oldDefinition);
+               if (oldDefinition instanceof ICPPASTFunctionWithTryBlock) {
+                       newFunc = new CPPASTFunctionWithTryBlock(newDeclSpec, newFuncDecl, 
+                                       new CPPASTCompoundStatement());
+               } else {
+                       newFunc = new CPPASTFunctionDefinition(newDeclSpec, newFuncDecl, 
+                                       new CPPASTCompoundStatement());
+               }
+               copyInitializerList(newFunc, oldDefinition);
+               return newFunc;
+       }
+       
+       private static IASTFunctionDeclarator adjustParamNames(IASTFunctionDeclarator newFuncDecl,
+                       IASTFunctionDefinition oldDefinition) {
+               if (oldDefinition.getDeclarator() instanceof IASTStandardFunctionDeclarator) {
+                       IASTStandardFunctionDeclarator oldStdDec = (IASTStandardFunctionDeclarator) oldDefinition.getDeclarator();
+                       IASTParameterDeclaration[] definitionParams = oldStdDec.getParameters();
+                       IASTParameterDeclaration[] declarationParams = ((IASTStandardFunctionDeclarator)newFuncDecl).getParameters();
+                       for(int i = 0; i < declarationParams.length; ++i) {
+                               declarationParams[i].getDeclarator().setName(definitionParams[i].getDeclarator().getName().copy(CopyStyle.withLocations));
+                       }
+               }
+               return newFuncDecl;
+       }
+
+       private static void copyInitializerList(ICPPASTFunctionDefinition newFunc, 
+                       IASTFunctionDefinition oldFunc) {
+               for (ICPPASTConstructorChainInitializer initializer : getInitializerList(oldFunc)) {
+                       initializer.setParent(newFunc);
+                       newFunc.addMemberInitializer(initializer);
+               }
+       }
+
+       static IASTFunctionDefinition getQualifiedNameDefinition(IASTFunctionDefinition oldDefinition, 
+                       IASTTranslationUnit definitionUnit, IASTNode nameSpace) {
+               
+               ICPPASTDeclSpecifier newDeclSpec = 
+ (ICPPASTDeclSpecifier) oldDefinition.getDeclSpecifier().copy(
+                               CopyStyle.withLocations);
+               
+               newDeclSpec.setVirtual(false);
+               newDeclSpec.setInline(true);
+               newDeclSpec.setStorageClass(IASTDeclSpecifier.sc_unspecified);
+               
+               IASTFunctionDeclarator newDeclarator = oldDefinition.getDeclarator().copy(CopyStyle.withLocations);
+               newDeclarator.setName(getQualifiedName(oldDefinition.getDeclarator(), nameSpace));
+               removeParameterInitializations(newDeclarator);
+               
+               ICPPASTFunctionDefinition newFunction = 
+                       createFunctionSignatureWithEmptyBody(newDeclSpec, newDeclarator, oldDefinition);
+       
+               return newFunction;
+       }
+
+       public static ICPPASTTemplateDeclaration getTemplateDeclaration(
+                       IASTFunctionDefinition oldFunction, IASTFunctionDefinition newFunction) {
+               ArrayList<ICPPASTTemplateDeclaration> templateDeclarations = getAllTemplateDeclaration(oldFunction);
+               return addTemplateDeclarationsInOrder(templateDeclarations, newFunction);
+       }
+
+       private static ICPPASTTemplateDeclaration addTemplateDeclarationsInOrder(
+                       ArrayList<ICPPASTTemplateDeclaration> templdecs, IASTFunctionDefinition newfunc) {
+               ListIterator<ICPPASTTemplateDeclaration> iter1 = templdecs.listIterator();
+               ICPPASTTemplateDeclaration child = null;
+               while(iter1.hasNext()) {
+                       child = iter1.next();
+                       child.setDeclaration(newfunc);
+                       ListIterator<ICPPASTTemplateDeclaration> iter2 = iter1;
+                       if (iter2.hasNext()) {
+                               ICPPASTTemplateDeclaration parent = iter2.next();
+                               child.setParent(parent);
+                               parent.setDeclaration(child);
+                               child = parent;
+                       }
+               }
+               return child;
+       }
+
+       private static ArrayList<ICPPASTTemplateDeclaration> getAllTemplateDeclaration(
+                       IASTNode node) {
+               ArrayList<ICPPASTTemplateDeclaration> templdecs = new ArrayList<ICPPASTTemplateDeclaration>();
+               while (node.getParent() != null) {
+                       node = node.getParent();
+                       if (node instanceof ICPPASTTemplateDeclaration) {
+                               templdecs.add((ICPPASTTemplateDeclaration) node.copy(CopyStyle.withLocations));
+                       }
+               }
+               return templdecs;
+       }
+
+       static IASTFunctionDefinition createInClassDefinition(
+                       IASTFunctionDeclarator dec, 
+                       IASTFunctionDefinition def, 
+                       IASTTranslationUnit insertionunit) {
+               IASTFunctionDeclarator declarator = dec.copy(CopyStyle.withLocations);
+               ICPPASTDeclSpecifier declSpec = (ICPPASTDeclSpecifier) def.getDeclSpecifier().copy(
+                               CopyStyle.withLocations);
+               declSpec.setInline(false);
+               if (ToggleNodeHelper.isVirtual(dec)) {
+                       declSpec.setVirtual(true);
+               }
+               declSpec.setStorageClass(getStorageClass(dec));
+               
+               return createFunctionSignatureWithEmptyBody(declSpec, declarator, def);
+       }
+
+       static boolean isVirtual(IASTFunctionDeclarator fdec) {
+               if (fdec.getParent() instanceof IASTSimpleDeclaration) {
+                       IASTSimpleDeclaration dec = (IASTSimpleDeclaration) fdec.getParent();
+                       return ((ICPPASTDeclSpecifier) dec.getDeclSpecifier()).isVirtual();
+               }
+               return false;
+       }
+       
+       static int getStorageClass(IASTFunctionDeclarator fdec) {
+               if (fdec.getParent() instanceof IASTSimpleDeclaration) {
+                       IASTSimpleDeclaration dec = (IASTSimpleDeclaration) fdec.getParent();
+                       return ((ICPPASTDeclSpecifier) dec.getDeclSpecifier()).getStorageClass();
+               }
+               return -1;
+       }
+
+       static IASTNode getParentRemovePoint(IASTFunctionDefinition definition) {
+               IASTNode toremove = definition;
+               while (toremove.getParent() != null && 
+                               toremove.getParent() instanceof ICPPASTTemplateDeclaration)
+                       toremove = toremove.getParent();
+               return toremove;
+       }
+
+       /**
+        * @param declarator the declarator from which the full qualified namespace should be fetched
+        * @param limiter set a limiter in the class hierarchy where the lookup will stop
+        * @return
+        */
+       static ICPPASTQualifiedName getQualifiedName(IASTFunctionDeclarator declarator, IASTNode limiter) {
+               Stack<IASTNode> nodes = getQualifiedNames(declarator, limiter, declarator);
+               CPPASTQualifiedName qName = reAssembleQualifiedName(nodes);
+               qName.addName(declarator.getName().copy(CopyStyle.withLocations));
+               return qName;
+       }
+
+       private static CPPASTQualifiedName reAssembleQualifiedName(Stack<IASTNode> nodes) {
+               CPPASTQualifiedName qName = new CPPASTQualifiedName();
+               while(!nodes.isEmpty()) {
+                       IASTNode nnode = nodes.pop();
+                       if (nnode instanceof IASTCompositeTypeSpecifier) {
+                               qName.addName(((IASTCompositeTypeSpecifier) nnode).getName());
+                       }
+                       else if (nnode instanceof ICPPASTNamespaceDefinition) {
+                               qName.addName(((ICPPASTNamespaceDefinition) nnode).getName());
+                       }
+                       else if (nnode instanceof ICPPASTTemplateId) {
+                               qName.addName((ICPPASTTemplateId) nnode);
+                       }
+               }
+               return qName;
+       }
+
+       private static Stack<IASTNode> getQualifiedNames(
+                       IASTFunctionDeclarator declarator, IASTNode limiter, IASTNode node) {
+               IASTName lastName = declarator.getName();
+               Stack<IASTNode> nodes = new Stack<IASTNode>();
+               while(node.getParent() != null && node.getParent() != limiter) {
+                       node = node.getParent();
+                       if (node instanceof IASTCompositeTypeSpecifier) {
+                               nodes.push(((IASTCompositeTypeSpecifier) node).copy(CopyStyle.withLocations));
+                               lastName = ((IASTCompositeTypeSpecifier) node).getName();
+                       }
+                       else if (node instanceof ICPPASTNamespaceDefinition) {
+                               nodes.push(((ICPPASTNamespaceDefinition) node).copy(CopyStyle.withLocations));
+                               lastName = ((ICPPASTNamespaceDefinition) node).getName();
+                       }
+                       else if (shouldAddTemplateBrackets(node)) {
+                               if (!nodes.isEmpty())
+                                       nodes.pop();
+                               ICPPASTTemplateId templateID = ToggleNodeHelper.getTemplateParameter(node, lastName);
+                               nodes.add(templateID);
+                       } 
+               }
+               return nodes;
+       }
+
+       private static boolean shouldAddTemplateBrackets(IASTNode node) {
+               return node instanceof ICPPASTTemplateDeclaration
+                               && !(((ICPPASTTemplateDeclaration) node).getDeclaration() 
+                                               instanceof CPPASTFunctionDefinition);
+       }
+
+       private static ICPPASTTemplateId getTemplateParameter(IASTNode node, IASTName name) {
+               ICPPASTTemplateId templateID = new CPPASTTemplateId();
+               templateID.setTemplateName(name.copy(CopyStyle.withLocations));
+               for(IASTNode child : node.getChildren()) {
+                       if (child instanceof ICPPASTSimpleTypeTemplateParameter) {
+                               ICPPASTSimpleTypeTemplateParameter tempcild = (ICPPASTSimpleTypeTemplateParameter) child;
+       
+                               CPPASTNamedTypeSpecifier namedTypeSpecifier = new CPPASTNamedTypeSpecifier();
+                               namedTypeSpecifier.setName(tempcild.getName().copy(CopyStyle.withLocations));
+                               
+                               CPPASTTypeId id = new CPPASTTypeId();
+                               id.setDeclSpecifier(namedTypeSpecifier);
+                               templateID.addTemplateArgument(id);
+                       }
+               }
+               return templateID;
+       }
+
+       static IASTTranslationUnit getSiblingFile(IFile file, IASTTranslationUnit asttu) throws CoreException {
+               ICProject cProject = CoreModel.getDefault().create(file).getCProject();
+               ICProject[] projects = CoreModel.getDefault().getCModel().getCProjects();
+               IIndex projectIndex = CCorePlugin.getIndexManager().getIndex(projects);
+               try {
+                       projectIndex.acquireReadLock();
+
+                       IIndexFile thisFile = projectIndex.getFile(asttu.getLinkage().getLinkageID(),
+                                       IndexLocationFactory.getWorkspaceIFL(file));
+                       String fileName = ToggleNodeHelper.getFilenameWithoutExtension(
+                                       file.getFullPath().toString());
+                       if (asttu.isHeaderUnit()) {
+                               for (IIndexInclude include : projectIndex.findIncludedBy(thisFile)) {
+                                       if (ToggleNodeHelper.getFilenameWithoutExtension(include.getIncludedBy().getLocation().getFullPath()).equals(fileName)) {
+                                               ITranslationUnit tu = CoreModelUtil.findTranslationUnitForLocation(include.getIncludedBy().getLocation().getURI(), cProject);
+                                               return tu.getAST(projectIndex, ITranslationUnit.AST_SKIP_ALL_HEADERS);
+                                       }
+                               }
+                       } else {
+                               for (IIndexInclude include : projectIndex.findIncludes(thisFile)) {
+                                       if (ToggleNodeHelper.getFilenameWithoutExtension(include.getFullName()).equals(fileName)) {
+                                               if (include.getIncludesLocation() == null){
+                                                       throw new NotSupportedException("The include file does not exist"); //$NON-NLS-1$
+                                               }
+                                               String loc = include.getIncludesLocation().getFullPath();
+                               ICElement tufile = CoreModel.getDefault().create(new Path(loc));
+                               if (tufile instanceof TranslationUnit) {
+                                          return ((TranslationUnit) tufile).getAST(null, ITranslationUnit.AST_SKIP_ALL_HEADERS);
+                               }
+                                       }
+                               }
+                       }
+               }catch (InterruptedException e) {
+                       e.printStackTrace();
+               } finally {
+                       projectIndex.releaseReadLock();
+               }
+               return null;
+       }
+
+       public static String getFilenameWithoutExtension(String filename) {
+               int indexP = filename.lastIndexOf('.');
+               int indexS = filename.lastIndexOf('/');
+               indexS++;
+               return filename.substring(indexS, indexP);
+       }
+
+       /**
+        * Will extract the innermost ICPPASTFunctionDefinition out of a template declaration.
+        * 
+        * template<typename T>                         // <-- input this node
+        * template<typename U>
+        * void function(T t, U u) { ... }  // <-- will find this node here 
+        * 
+        * @param declaration the template declaration that should be searched for the function definition.
+        * @return null if a declaration is found instead of a definition.
+        */
+       public static ICPPASTFunctionDefinition getFunctionDefinition(IASTNode declaration) {
+               IASTNode node = declaration;
+               while (node != null) {
+                       if (node instanceof ICPPASTTemplateDeclaration) {
+                               ICPPASTTemplateDeclaration templdec = (ICPPASTTemplateDeclaration) node;
+                               node = templdec.getDeclaration();
+                               continue;
+                       }
+                       if (node instanceof ICPPASTFunctionDefinition) {
+                               return (ICPPASTFunctionDefinition) node;
+                       } else {
+                               return null;
+                       }
+               }
+               return null;
+       }
+       
+       /**
+        * Gets comments inside the body of a function.
+        * @return The body as a string and all the catch handlers
+        */
+       public static String getBody(IASTFunctionDefinition oldDefinition, IASTTranslationUnit oldUnit,
+                       ModificationCollector modifications) {
+               return getBodyOnly(oldDefinition, oldUnit, modifications)
+                               + getCatchHandlers(oldDefinition, oldUnit, modifications);
+       }
+
+       private static String getBodyOnly(IASTFunctionDefinition oldDefinition, IASTTranslationUnit oldUnit,
+                       ModificationCollector modifications) {
+               String leadingComments = getCommentsAsString(getLeadingCommentsFromNode(oldDefinition.getBody(),
+                               oldUnit, modifications));
+               String trailingComments = getCommentsAsString(getTrailingComments(oldDefinition.getBody(), oldUnit,
+                               modifications));
+               return leadingComments + oldDefinition.getBody().getRawSignature() + trailingComments;
+       }
+
+       private static String getCatchHandlers(IASTFunctionDefinition oldDefinition, IASTTranslationUnit oldUnit,
+                       ModificationCollector modifications) {
+               if (oldDefinition instanceof ICPPASTFunctionWithTryBlock) {
+                       ICPPASTCatchHandler[] oldCatches = ((ICPPASTFunctionWithTryBlock) oldDefinition)
+                                       .getCatchHandlers();
+                       String allCatchHandlers = ""; //$NON-NLS-1$
+                       for (int i = 0; i < oldCatches.length; i++) {
+                               String lead = getCommentsAsString(getLeadingCommentsFromNode(oldCatches[i], oldUnit,
+                                               modifications));
+                               String trail = getCommentsAsString(getTrailingComments(oldCatches[i], oldUnit, modifications));
+                               allCatchHandlers += lead + oldCatches[i].getRawSignature() + trail;
+                       }
+                       return allCatchHandlers;
+               }
+               return ""; //$NON-NLS-1$
+       }
+
+       private static List<IASTComment> getLeadingCommentsFromNode(IASTNode existingNode,
+                       IASTTranslationUnit oldUnit, ModificationCollector modifications) {
+               ASTRewrite rw = modifications.rewriterForTranslationUnit(oldUnit);
+               return rw.getComments(existingNode, CommentPosition.leading);
+       }
+
+       private static List<IASTComment> getTrailingComments(IASTNode existingNode,
+                       IASTTranslationUnit oldUnit, ModificationCollector modifications) {
+               ASTRewrite rw = modifications.rewriterForTranslationUnit(oldUnit);
+               return rw.getComments(existingNode, CommentPosition.trailing);
+       }
+
+       
+       public static IASTNode getParentTemplateDeclaration(
+                       IASTNode def) {
+               if (def == null)
+                       return null;
+               IASTNode lastSeen = def;
+               IASTNode node = def.getParent();
+               while (node != null) {
+                       if (node instanceof ICPPASTTemplateDeclaration || 
+                                       node instanceof IASTSimpleDeclaration) {
+                               lastSeen = node;
+                               node = node.getParent();
+                               continue;
+                       }
+                       return lastSeen;
+               }
+               return lastSeen;
+       }
+       
+       private static String getCommentsAsString(List<IASTComment> commentList) {
+               String comments = EMPTY_STRING;
+               for (IASTComment c : commentList) {
+                       comments += c.getRawSignature() + System.getProperty("line.separator"); //$NON-NLS-1$
+               }
+               return comments;
+       }
+
+       @SuppressWarnings("unchecked")
+       public static <T> T getAncestorOfType(IASTNode node, Class<?> T) {
+               while(node != null) {
+                       if (T.isInstance(node)) {
+                               return (T) node;
+                       }
+                       node = node.getParent();
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleRefactoring.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleRefactoring.java
new file mode 100644 (file)
index 0000000..207b6cd
--- /dev/null
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *             Martin Schwab & Thomas Kallenberg - initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ui.ide.IDE;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexManager;
+import org.eclipse.cdt.core.model.ICProject;
+
+import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
+
+import org.eclipse.cdt.internal.ui.refactoring.CRefactoring;
+import org.eclipse.cdt.internal.ui.refactoring.ModificationCollector;
+
+/**
+ * Determines whether a valid function was selected by the user to be able to
+ * run the appropriate strategy for moving the function body to another
+ * position.
+ */
+public class ToggleRefactoring extends CRefactoring {
+
+       private ITextSelection selection;
+       private IToggleRefactoringStrategy strategy;
+       protected ToggleRefactoringContext context;
+       private IIndex fIndex;
+       
+       public ToggleRefactoring(IFile file, ITextSelection selection, ICProject proj) {
+               super(file, selection, null, proj);
+               if (selection == null || file == null || project == null)
+                       initStatus.addFatalError(Messages.ToggleRefactoring_InvalidSelection);
+               if (!IDE.saveAllEditors(new IResource[] {ResourcesPlugin.getWorkspace().getRoot()}, false))
+                       initStatus.addFatalError(Messages.ToggleRefactoring_CanNotSaveFiles);
+               this.selection = selection;
+       }
+
+       @Override
+       public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
+                       throws CoreException, OperationCanceledException {
+               try {
+                       pm.subTask(Messages.ToggleRefactoring_WaitingForIndexer);
+                       prepareIndexer(pm);
+                       pm.subTask(Messages.ToggleRefactoring_AnalyseSelection);
+                       context = new ToggleRefactoringContext(fIndex, file, selection);
+                       strategy = new ToggleStrategyFactory(context).getAppropriateStategy();
+               } catch (InterruptedException e) {
+               } catch (NotSupportedException e) {
+                       initStatus.addFatalError(e.getMessage());
+               } finally {
+                       fIndex.releaseReadLock();
+               }
+
+               return initStatus;
+       }
+
+       private void prepareIndexer(IProgressMonitor pm) throws CoreException, InterruptedException  {
+               IIndexManager im = CCorePlugin.getIndexManager();
+               while (!im.isProjectIndexed(project)) {
+                       im.joinIndexer(500, pm);
+                       if (pm.isCanceled())
+                               throw new NotSupportedException(Messages.ToggleRefactoring_NoIndex);
+               }
+               if (!im.isProjectIndexed(project))
+                       throw new NotSupportedException(Messages.ToggleRefactoring_NoIndex);
+               IndexerPreferences.set(project.getProject(), IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, Boolean.TRUE.toString());
+               fIndex = CCorePlugin.getIndexManager().getIndex(project);
+               fIndex.acquireReadLock();
+       }
+
+       @Override
+       protected void collectModifications(IProgressMonitor pm,
+                       ModificationCollector modifications) throws CoreException {
+               pm.subTask(Messages.ToggleRefactoring_CalculateModifications);
+               strategy.run(modifications);
+       }
+
+       @Override
+       protected RefactoringDescriptor getRefactoringDescriptor() {
+               return new EmptyRefactoringDescription();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleRefactoringContext.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleRefactoringContext.java
new file mode 100644 (file)
index 0000000..a263af8
--- /dev/null
@@ -0,0 +1,201 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *             Martin Schwab & Thomas Kallenberg - initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.text.ITextSelection;
+
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.refactoring.IndexToASTNameHelper;
+import org.eclipse.cdt.internal.ui.refactoring.utils.TranslationUnitHelper;
+
+public class ToggleRefactoringContext {
+
+       private IASTFunctionDefinition targetDefinition;
+       private IASTFunctionDeclarator targetDeclaration;
+       private IASTTranslationUnit targetDefinitionUnit;
+       private IASTTranslationUnit targetDeclarationUnit;
+       private IIndex index;
+       private IASTTranslationUnit selectionUnit;
+       private IFile selectionFile;
+       private IBinding binding;
+       private IASTName selectionName;
+       private boolean defaultAnswer;
+       private boolean settedDefaultAnswer;
+
+       public ToggleRefactoringContext(IIndex index, IFile file, ITextSelection selection) {
+               this.index = index;
+               this.selectionFile = file;
+               findSelectionUnit();
+               findSelectedFunctionDeclarator(selection);
+               findBinding();
+               findDeclaration();
+               findDefinition();
+       }
+
+       public void findSelectedFunctionDeclarator(ITextSelection selection) {
+               selectionName = new DeclaratorFinder(selection, selectionUnit).getName();
+       }
+
+       public void findBinding() {
+               try {
+                       binding = index.findBinding(selectionName);
+                       if(binding == null) {
+                               binding = selectionName.resolveBinding();
+                       }
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }
+       }
+
+       // Declaration may still be null afterwards, but thats ok.
+       public void findDeclaration() {
+               try {
+                       IIndexName[] decnames = index.findNames(binding, IIndex.FIND_DECLARATIONS);
+                       if (decnames.length > 1)
+                               throw new NotSupportedException(
+                                               Messages.ToggleRefactoringContext_MultipleDeclarations);
+                       for (IIndexName iname : decnames) {
+                               selectionUnit = getTUForNameinFile(iname);
+                               IASTName astname = IndexToASTNameHelper.findMatchingASTName(
+                                               selectionUnit, iname, index);
+                               if (astname != null) {
+                                       targetDeclaration = findFunctionDeclarator(astname);
+                                       targetDeclarationUnit = selectionUnit;
+                                       break;
+                               }
+                       }
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }
+       }
+
+       public void findDefinition() {
+               try {
+                       IIndexName[] defnames = index.findNames(binding, IIndex.FIND_DEFINITIONS);
+                       if (defnames.length > 1) {
+                               throw new NotSupportedException(Messages.ToggleRefactoringContext_MultipleDefinitions);
+                       }
+                       for (IIndexName iname : defnames) {
+                               IASTTranslationUnit unit = getTUForNameinFile(iname);
+                               IASTName astname = IndexToASTNameHelper.findMatchingASTName(
+                                               unit, iname, index);
+                               if (astname != null) {
+                                       targetDefinition = findFunctionDefinition(astname);
+                                       targetDefinitionUnit = unit;
+                                       break;
+                               }
+                       }
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }
+               if (targetDefinition == null)
+                       throw new NotSupportedException(Messages.ToggleRefactoringContext_NoDefinitionFound);
+       }
+
+       public IASTFunctionDeclarator getDeclaration() {
+               return targetDeclaration;
+       }
+
+       public IASTFunctionDefinition getDefinition() {
+               return targetDefinition;
+       }
+
+       public IASTTranslationUnit getDeclarationUnit() {
+               return targetDeclarationUnit;
+       }
+
+       public IASTTranslationUnit getDefinitionUnit() {
+               return targetDefinitionUnit;
+       }
+
+       public IFile getSelectionFile() {
+               return selectionFile;
+       }
+
+       public IASTTranslationUnit getTUForSiblingFile() {
+               IASTTranslationUnit unit = getDeclarationUnit();
+               if (unit == null)
+                       unit = getDefinitionUnit();
+               try {
+                       return ToggleNodeHelper.getSiblingFile(getSelectionFile(), unit);
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+                       return null;
+               }
+       }
+       
+       private void findSelectionUnit() {
+               try {
+                       selectionUnit = TranslationUnitHelper.loadTranslationUnit(
+                                       selectionFile, true);
+               } catch (Exception e) {
+               }
+               if (selectionUnit == null)
+                       throw new NotSupportedException(Messages.ToggleRefactoringContext_NoTuFound);
+       }
+
+       private IASTTranslationUnit getTUForNameinFile(IIndexName iname)
+                       throws CModelException, CoreException {
+               if (isSameFileAsInTU(iname)) {
+                       return selectionUnit;
+               }
+               IPath path = new Path(iname.getFileLocation().getFileName());
+               return TranslationUnitHelper.loadTranslationUnit(path.toString(), true);
+       }
+
+       private boolean isSameFileAsInTU(IIndexName iname) {
+               return iname.getFileLocation().getFileName().equals(
+                               selectionUnit.getFileLocation().getFileName());
+       }
+
+       private IASTFunctionDeclarator findFunctionDeclarator(IASTNode node) {
+               if (node instanceof IASTSimpleDeclaration) {
+                       return (IASTFunctionDeclarator) ((IASTSimpleDeclaration) node).getDeclarators()[0];
+               }
+               return ToggleNodeHelper.getAncestorOfType(node, IASTFunctionDeclarator.class);
+       }
+
+       private IASTFunctionDefinition findFunctionDefinition(IASTNode node) {
+               return ToggleNodeHelper.getAncestorOfType(node, IASTFunctionDefinition.class);
+       }
+
+       public void setDefaultAnswer(boolean defaultAnswer) {
+               this.defaultAnswer = defaultAnswer;
+       }
+
+       public boolean getDefaultAnswer() {
+               return defaultAnswer;
+       }
+
+       public void setSettedDefaultAnswer(boolean settedDefaultAnswer) {
+               this.settedDefaultAnswer = settedDefaultAnswer;
+       }
+
+       public boolean isSettedDefaultAnswer() {
+               return settedDefaultAnswer;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleRefactoringRunner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleRefactoringRunner.java
new file mode 100644 (file)
index 0000000..bdcec69
--- /dev/null
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *             Martin Schwab & Thomas Kallenberg - initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.window.IShellProvider;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.refactoring.RefactoringRunner;
+
+/**
+ * Responsible for scheduling a job which runs the ToggleRefactoring. Differs
+ * from other subclasses of RefactoringRunner in the way that it does not use a
+ * wizard but calls the refactoring directly.
+ */
+public class ToggleRefactoringRunner extends RefactoringRunner {
+
+       private ToggleRefactoring refactoring;
+
+       public ToggleRefactoringRunner(IFile file, ITextSelection selection,
+                       ICElement element, IShellProvider shellProvider, ICProject project) {
+               super(file, selection, element, shellProvider, project);
+               refactoring = new ToggleRefactoring(file, selection, project);
+       }
+
+       @Override
+       public void run() {
+               Job[] jobs = Job.getJobManager().find(RefactoringJob.FAMILY_TOGGLE_DEFINITION);
+               if (jobs.length > 0) {
+                       CUIPlugin.log("no concurrent toggling allowed", new NotSupportedException(""));  //$NON-NLS-1$//$NON-NLS-2$
+                       return;
+               }
+               new RefactoringJob(refactoring).schedule();
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleStrategyFactory.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleStrategyFactory.java
new file mode 100644 (file)
index 0000000..1940990
--- /dev/null
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *             Martin Schwab & Thomas Kallenberg - initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
+
+import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
+
+public class ToggleStrategyFactory {
+       
+       private ToggleRefactoringContext context;
+
+       public ToggleStrategyFactory(ToggleRefactoringContext context) {
+               this.context = context;
+       }
+
+       public IToggleRefactoringStrategy getAppropriateStategy() {
+               if (context.getDefinition() == null)
+                       throw new NotSupportedException(Messages.ToggleStrategyFactory_NoDefinitionFound);
+               if (!context.getDefinitionUnit().isHeaderUnit())
+                       return new ToggleFromImplementationToHeaderOrClassStrategy(context);
+               if (isInClassSituation())
+                       return new ToggleFromClassToInHeaderStrategy(context);
+               if (isTemplateSituation())
+                       return new ToggleFromInHeaderToClassStrategy(context);
+               if (isinHeaderSituation())
+                       return new ToggleFromInHeaderToImplementationStrategy(context);
+               throw new NotSupportedException(Messages.ToggleStrategyFactory_UnsupportedSituation);
+       }
+       
+       private boolean isinHeaderSituation() {
+               return (context.getDefinition() != null) 
+                       && (context.getDefinitionUnit().isHeaderUnit());
+       }
+
+       private boolean isInClassSituation() {
+               return (context.getDeclaration() == null) && 
+                       (ToggleNodeHelper.getAncestorOfType(context.getDefinition(), 
+                                       IASTCompositeTypeSpecifier.class) != null);
+       }
+
+       private boolean isTemplateSituation() {
+               return (ToggleNodeHelper.getAncestorOfType(context.getDefinition(), 
+                               ICPPASTTemplateDeclaration.class) != null);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/TogglingActionDelegate.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/TogglingActionDelegate.java
new file mode 100644 (file)
index 0000000..ee44cd6
--- /dev/null
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ *             Martin Schwab & Thomas Kallenberg - initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.text.TextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * Represents the interface between the user who invokes the action and the
+ * actual refactoring mechanism. Starts the ToggleRefactoringRunner.
+ * 
+ * Order of execution is: constructor, init, selectionChanged, run
+ */
+public class TogglingActionDelegate implements IWorkbenchWindowActionDelegate {
+
+       private IWorkbenchWindow window;
+       private TextSelection selection;
+       private ICProject project;
+       private IFile file;
+       
+       public void init(IWorkbenchWindow window) {
+               this.window = window;
+               assert (window != null);
+       }
+       
+       public void selectionChanged(IAction action, ISelection selection) {
+               boolean isTextSelection = selection != null
+                               && selection instanceof TextSelection;
+               action.setEnabled(isTextSelection);
+               if (!isTextSelection)
+                       return;
+               //get our own selection due to (a possible) bug??
+               this.selection = (TextSelection) CUIPlugin.getActivePage().getActiveEditor().getEditorSite().getSelectionProvider().getSelection();
+       }
+
+       public void run(IAction action) {
+               if (!isWorkbenchReady())
+                       return;
+               new ToggleRefactoringRunner(file, selection, project, window, project).run();
+       }
+       
+       private boolean isWorkbenchReady() {
+               IWorkbenchPage activePage = window.getActivePage();
+               if (activePage == null)
+                       return false;
+               IEditorPart editor = activePage.getActiveEditor();
+               if (editor == null || editor.getEditorInput() == null)
+                       return false;
+               IWorkingCopy wc = CUIPlugin.getDefault().getWorkingCopyManager()
+               .getWorkingCopy(editor.getEditorInput());
+               if (wc == null)
+                       return false;
+               project = wc.getCProject();
+               file = (IFile) wc.getResource();
+               return project != null && file != null;
+       }
+
+       public void dispose() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/ASTHelper.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/ASTHelper.java
new file mode 100644 (file)
index 0000000..95b3d41
--- /dev/null
@@ -0,0 +1,255 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.utils;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTPointerOperator;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
+
+import org.eclipse.cdt.internal.ui.refactoring.extractfunction.TrailNodeEqualityChecker;
+
+public class ASTHelper {
+       private ASTHelper() {
+       }
+
+       static public IASTNode getDeclarationForNode(IASTNode tmpNode) {
+               while (tmpNode != null && !(tmpNode instanceof IASTSimpleDeclaration) && !(tmpNode instanceof IASTParameterDeclaration)) {
+                       tmpNode = tmpNode.getParent();
+               }
+               return tmpNode;
+       }
+
+       static public IASTDeclarator getDeclaratorForNode(IASTNode aNode) {
+               IASTNode tmpNode = getDeclarationForNode(aNode);
+
+               IASTDeclarator declarator = null;
+               if (tmpNode instanceof IASTSimpleDeclaration) {
+                       IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tmpNode;
+                       if (decl.getDeclarators().length > 0) {
+                               declarator = decl.getDeclarators()[0];
+                       }
+               } else if (tmpNode instanceof IASTParameterDeclaration) {
+                       IASTParameterDeclaration decl = (IASTParameterDeclaration) tmpNode;
+                       declarator = decl.getDeclarator();
+               }
+               return declarator;
+       }
+
+       static public IASTDeclSpecifier getDeclarationSpecifier(IASTNode declaration) {
+               if (declaration != null) {
+                       if (declaration instanceof IASTSimpleDeclaration) {
+                               IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration) declaration;
+                               return simpleDecl.getDeclSpecifier();
+                       } else if (declaration instanceof ICPPASTParameterDeclaration) {
+                               ICPPASTParameterDeclaration paramDecl = (ICPPASTParameterDeclaration) declaration;
+                               return paramDecl.getDeclSpecifier();
+                       }
+               }
+               return null;
+       }
+
+       public static boolean samePointers(IASTPointerOperator[] pointerOperators1, IASTPointerOperator[] pointerOperators2, TrailNodeEqualityChecker checker) {
+               if (pointerOperators2.length == pointerOperators1.length) {
+                       for (int i = 0; i < pointerOperators2.length; i++) {
+                               IASTPointerOperator operator1 = pointerOperators1[i];
+                               IASTPointerOperator operator2 = pointerOperators2[i];
+                               if (!checker.isEquals(operator1, operator2)) {
+                                       return false;
+                               }
+                       }
+               } else {
+                       return false;
+               }
+
+               return true;
+       }
+
+       public static boolean isClassDeclarationName(IASTName astName) {
+               if (astName == null)
+                       return false;
+               IASTNode parent = astName.getParent();
+               if (parent instanceof ICPPASTCompositeTypeSpecifier) {
+                       ICPPASTCompositeTypeSpecifier typeSpecifier = (ICPPASTCompositeTypeSpecifier) parent;
+                       return typeSpecifier.getKey() == ICPPASTCompositeTypeSpecifier.k_class;
+               }
+               return false;
+       }
+
+       public static ArrayList<ICPPASTNamespaceDefinition> getNamespaces(IASTNode node) {
+               ArrayList<ICPPASTNamespaceDefinition> namespaces = new ArrayList<ICPPASTNamespaceDefinition>();
+               for (IASTNode aktNode = node; aktNode != null; aktNode = aktNode.getParent()) {
+                       if (aktNode instanceof ICPPASTNamespaceDefinition) {
+                               namespaces.add(0, (ICPPASTNamespaceDefinition) aktNode);
+                       } else if(aktNode instanceof ICPPASTQualifiedName) {
+                               namespaces.addAll(getNamespaces((ICPPASTQualifiedName) aktNode));
+                       }
+               }
+               return namespaces;
+       }
+       
+       public static ArrayList<ICPPASTNamespaceDefinition> getNamespaces(ICPPASTQualifiedName qualifiedName) {
+               ArrayList<ICPPASTNamespaceDefinition> namespaces = new ArrayList<ICPPASTNamespaceDefinition>();
+               for(IASTName aktQualifiedPartName : qualifiedName.getNames()) {
+                       IBinding binding = aktQualifiedPartName.resolveBinding();
+                       for(IASTName aktResolvedName : qualifiedName.getTranslationUnit().getDefinitionsInAST(binding)) {
+                               if(aktResolvedName.getParent() instanceof ICPPASTNamespaceDefinition) {
+                                       namespaces.add((ICPPASTNamespaceDefinition) aktResolvedName.getParent());
+                                       break;
+                               }
+                       }
+               }
+               return namespaces;
+       }
+
+       public static Collection<IASTDeclSpecifier> getCompositTypeSpecifiers(IASTNode baseNode) {
+               final Collection<IASTDeclSpecifier> specifiers = new ArrayList<IASTDeclSpecifier>();
+               ASTVisitor visitor = new ASTVisitor() {
+
+                       @Override
+                       public int visit(IASTDeclSpecifier declSpec) {
+                               specifiers.add(declSpec);
+                               return super.visit(declSpec);
+                       }
+               };
+               visitor.shouldVisitDeclSpecifiers = true;
+               baseNode.accept(visitor);
+               return specifiers;
+       }
+       
+       public static Collection<IASTPreprocessorStatement> getAllInFilePreprocessorStatements(IASTTranslationUnit unit, String aktFileName) {
+               Collection<IASTPreprocessorStatement> statements = new ArrayList<IASTPreprocessorStatement>();
+               for(IASTPreprocessorStatement aktStatement : unit.getAllPreprocessorStatements()) {
+                       if(aktStatement.getFileLocation() == null) {
+                               continue;
+                       } else if (aktStatement.getFileLocation().getFileName().equals(aktFileName)) {
+                               statements.add(aktStatement);
+                       }
+               }
+               return statements;
+       }
+       
+       public static Collection<IASTDeclaration> getAllInFileDeclarations(IASTTranslationUnit unit, String aktFileName) {
+               Collection<IASTDeclaration> decls = new ArrayList<IASTDeclaration>();
+               for(IASTDeclaration aktDecl: unit.getDeclarations()) {
+                       if(aktDecl.getFileLocation() == null) {
+                               continue;
+                       } else if(aktDecl.getFileLocation().getFileName().equals(aktFileName)) {
+                               decls.add(aktDecl);
+                       }
+               }
+               return decls;
+       }
+       
+       public static ICPPASTUsingDirective getActiveUsingDirecitveForNode(IASTNode node, IASTTranslationUnit unit) {
+               ICPPASTUsingDirective activeDirective = null;
+               for(IASTDeclaration aktDeclaration : getAllInFileDeclarations(unit, node.getFileLocation().getFileName())) {
+                       if(aktDeclaration.getFileLocation().getNodeOffset() >= node.getFileLocation().getNodeOffset()) {
+                               break;
+                       }
+                       if(aktDeclaration instanceof ICPPASTUsingDirective) {
+                               activeDirective = (ICPPASTUsingDirective) aktDeclaration;
+                       }
+               } 
+               return activeDirective;
+       }
+
+       public static Collection<ICPPASTUsingDeclaration> getUsingDeclarations(IASTTranslationUnit unit) {
+               Collection<ICPPASTUsingDeclaration> usingDecls = new ArrayList<ICPPASTUsingDeclaration>();
+               for(IASTDeclaration aktDecl : unit.getDeclarations()) {
+                       if (aktDecl instanceof ICPPASTUsingDeclaration) {
+                               usingDecls.add((ICPPASTUsingDeclaration) aktDecl);
+                       }
+               }
+               return usingDecls;
+       }
+
+       public static boolean isClassDefinitionName(IASTName name) {
+               try {
+                       if(!(name.getParent().getParent().getParent() instanceof IASTFunctionDefinition)) {
+                               return false;
+                       }
+                       ICPPASTQualifiedName qName = (ICPPASTQualifiedName) name.getParent();
+                       IASTName secondLastName = qName.getNames()[qName.getNames().length-2];
+                       if(!(name.equals(secondLastName))) {
+                               return false;
+                       }
+                       IBinding binding = name.resolveBinding();
+                       for(IASTName aktName : name.getTranslationUnit().getDeclarationsInAST(binding)) {
+                               if(!isClassDeclarationName(aktName)) {
+                                       return false;
+                               }
+                       }
+                       
+               } catch (NullPointerException e) {
+                       return false;
+               }
+               return true;
+       }
+       
+       public static IASTCompositeTypeSpecifier getCompositeTypeSpecifierForName(IASTName name) {
+               IBinding binding = name.resolveBinding();
+               for(IASTName aktName : name.getTranslationUnit().getDefinitionsInAST(binding)) {
+                       if(aktName.getParent() instanceof IASTCompositeTypeSpecifier) {
+                               return (IASTCompositeTypeSpecifier) aktName.getParent();
+                       }
+               }
+               return null;
+       }
+       
+       public static Collection<IASTFunctionDeclarator> getFunctionDeclaratorsForClass(IASTCompositeTypeSpecifier klass) {
+               Collection<IASTFunctionDeclarator> declarators = new ArrayList<IASTFunctionDeclarator>();
+               for(IASTDeclaration aktDeclaration : klass.getMembers()) {
+                       if(aktDeclaration instanceof IASTSimpleDeclaration) {
+                               for(IASTDeclarator aktDeclarator : ((IASTSimpleDeclaration) aktDeclaration).getDeclarators()) {
+                                       if(aktDeclarator instanceof IASTFunctionDeclarator) {
+                                               declarators.add((IASTFunctionDeclarator) aktDeclarator);
+                                       }
+                               }
+                       }
+               }
+               return declarators;
+       }
+       
+       public static Collection<IASTFunctionDefinition> getFunctionDefinitionsForClass(IASTCompositeTypeSpecifier klass) {
+               Collection<IASTFunctionDefinition> definitions = new ArrayList<IASTFunctionDefinition>();
+               for(IASTFunctionDeclarator aktDeclarator : getFunctionDeclaratorsForClass(klass)) {
+                       IBinding binding = aktDeclarator.getName().resolveBinding();
+                       for(IASTName aktName : aktDeclarator.getTranslationUnit().getDefinitionsInAST(binding)) {
+                               if(aktName.getParent().getParent().getParent() instanceof IASTFunctionDefinition) {
+                                       definitions.add((IASTFunctionDefinition) aktName.getParent().getParent().getParent());
+                               }
+                       }
+               }
+               return definitions;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/CPPASTAllVisitor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/CPPASTAllVisitor.java
new file mode 100644 (file)
index 0000000..d619db7
--- /dev/null
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.utils;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTComment;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTInitializer;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTProblem;
+import org.eclipse.cdt.core.dom.ast.IASTStatement;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IASTTypeId;
+import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
+
+public class CPPASTAllVisitor extends ASTVisitor {
+       
+       {
+               shouldVisitNames = true;
+               shouldVisitDeclarations = true;
+               shouldVisitInitializers = true;
+               shouldVisitParameterDeclarations = true;
+               shouldVisitDeclarators = true;
+               shouldVisitDeclSpecifiers = true;
+               shouldVisitExpressions = true;
+               shouldVisitStatements = true;
+               shouldVisitTypeIds = true;
+               shouldVisitEnumerators = true;
+               shouldVisitTranslationUnit = true;
+               shouldVisitProblems = true;
+
+               shouldVisitBaseSpecifiers = true;
+               shouldVisitNamespaces = true;
+               shouldVisitTemplateParameters = true;
+       }
+       
+       
+       @Override
+       public int visit(IASTTranslationUnit tu) {
+               return visitAll(tu);
+       }
+
+       @Override
+       public int visit(IASTName name) {
+               return visitAll(name);
+       }
+
+       @Override
+       public int visit(IASTDeclaration declaration) {
+               return visitAll(declaration);
+       }
+
+       @Override
+       public int visit(IASTInitializer initializer) {
+               return visitAll(initializer);
+       }
+
+       @Override
+       public int visit(IASTParameterDeclaration parameterDeclaration) {
+               return visitAll(parameterDeclaration);
+       }
+
+       @Override
+       public int visit(IASTDeclarator declarator) {
+               return visitAll(declarator);
+       }
+
+       @Override
+       public int visit(IASTDeclSpecifier declSpec) {
+               return visitAll(declSpec);
+       }
+
+       @Override
+       public int visit(IASTExpression expression) {
+               return visitAll(expression);
+       }
+
+       @Override
+       public int visit(IASTStatement statement) {
+               return visitAll(statement);
+       }
+
+       @Override
+       public int visit(IASTTypeId typeId) {
+               return visitAll(typeId);
+       }
+
+       @Override
+       public int visit(IASTEnumerator enumerator) {
+               return visitAll(enumerator);
+       }
+       
+       @Override
+       public int visit( IASTProblem problem ){
+               return visitAll(problem);
+       }
+       
+       @Override
+       public int visit( IASTComment comment ){
+               return visitAll(comment);
+       }
+       
+
+       /**
+        * Visit BaseSpecifiers.
+        */
+       @Override
+       public int visit(ICPPASTBaseSpecifier specifier) {
+               return visitAll(specifier);
+       }
+
+       /**
+        * Visit namespace definitions.
+        */
+       @Override
+       public int visit(ICPPASTNamespaceDefinition namespace) {
+               return visitAll(namespace);
+       }
+
+       /**
+        * Visit template parameter.
+        */
+       @Override
+       public int visit(ICPPASTTemplateParameter parameter) {
+               return visitAll(parameter);
+       }
+       
+       public int visitAll(IASTNode node){
+               return PROCESS_CONTINUE;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/Checks.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/Checks.java
new file mode 100644 (file)
index 0000000..49a98e8
--- /dev/null
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.utils;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourceAttributes;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
+import org.eclipse.ltk.core.refactoring.participants.ResourceChangeChecker;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+import org.eclipse.cdt.internal.corext.util.CModelUtil;
+import org.eclipse.cdt.internal.corext.util.Resources;
+
+/**
+ * This class defines a set of reusable static checks methods.
+ */
+public class Checks {
+
+       /*
+        * no instances
+        */
+       private Checks(){
+       }
+
+       public static boolean startsWithUpperCase(String s) {
+               if (s == null) {
+                       return false;
+               } else if ("".equals(s)) { //$NON-NLS-1$
+                       return false;
+               } else {
+                       // Workaround for JDK bug (see 26529)
+                       return s.charAt(0) == Character.toUpperCase(s.charAt(0));
+               }
+       }
+
+       public static boolean startsWithLowerCase(String s){
+               if (s == null) {
+                       return false;
+               } else if ("".equals(s)) { //$NON-NLS-1$
+                       return false;
+           } else {
+                       // Workaround for JDK bug (see 26529)
+                       return s.charAt(0) == Character.toLowerCase(s.charAt(0));
+               }
+       }
+
+       public static boolean resourceExists(IPath resourcePath){
+               return ResourcesPlugin.getWorkspace().getRoot().findMember(resourcePath) != null;
+       }
+
+       public static boolean isReadOnly(Object element) throws CModelException {
+               if (element instanceof IResource)
+                       return isReadOnly((IResource) element);
+
+               if (element instanceof ICElement) {
+                       return isReadOnly(((ICElement) element).getResource());
+               }
+
+               Assert.isTrue(false, "Not expected to get here"); //$NON-NLS-1$
+               return false;
+       }
+
+       public static boolean isReadOnly(IResource res) throws CModelException {
+               ResourceAttributes attributes= res.getResourceAttributes();
+               if (attributes != null && attributes.isReadOnly())
+                       return true;
+
+               if (! (res instanceof IContainer))
+                       return false;
+
+               IContainer container= (IContainer)res;
+               IResource[] children;
+               try {
+                       children = container.members();
+                       for (int i= 0; i < children.length; i++) {
+                               if (isReadOnly(children[i]))
+                                       return true;
+                       }
+               } catch (CModelException e){
+                       throw e;
+               } catch (CoreException e) {
+                       throw new CModelException(e);
+               }
+               return false;
+       }
+
+       //-------- validateEdit checks ----
+
+       public static RefactoringStatus validateModifiesFiles(IFile[] filesToModify, Object context) {
+               RefactoringStatus result= new RefactoringStatus();
+               IStatus status= Resources.checkInSync(filesToModify);
+               if (!status.isOK())
+                       result.merge(RefactoringStatus.create(status));
+               status= Resources.makeCommittable(filesToModify, context);
+               if (!status.isOK()) {
+                       result.merge(RefactoringStatus.create(status));
+                       if (!result.hasFatalError()) {
+                               result.addFatalError(Messages.Checks_validateEdit);
+                       }
+               }
+               return result;
+       }
+
+       public static void addModifiedFilesToChecker(IFile[] filesToModify, CheckConditionsContext context) {
+               ResourceChangeChecker checker= (ResourceChangeChecker) context.getChecker(ResourceChangeChecker.class);
+               IResourceChangeDescriptionFactory deltaFactory= checker.getDeltaFactory();
+
+               for (int i= 0; i < filesToModify.length; i++) {
+                       deltaFactory.change(filesToModify[i]);
+               }
+       }
+
+       public static RefactoringStatus validateEdit(ITranslationUnit tu, Object context) {
+               IResource resource= CModelUtil.toOriginal(tu).getResource();
+               RefactoringStatus result= new RefactoringStatus();
+               if (resource == null)
+                       return result;
+               IStatus status= Resources.checkInSync(resource);
+               if (!status.isOK())
+                       result.merge(RefactoringStatus.create(status));
+               status= Resources.makeCommittable(resource, context);
+               if (!status.isOK()) {
+                       result.merge(RefactoringStatus.create(status));
+                       if (!result.hasFatalError()) {
+                               result.addFatalError(Messages.Checks_validateEdit);
+                       }
+               }
+               return result;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/DeclarationFinder.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/DeclarationFinder.java
new file mode 100644 (file)
index 0000000..c94e870
--- /dev/null
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ * Institute for Software - initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.utils;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexBinding;
+import org.eclipse.cdt.core.index.IIndexName;
+
+import org.eclipse.cdt.internal.ui.refactoring.Container;
+
+/**
+ * @author Guido Zgraggen IFS
+ */
+public class DeclarationFinder {       
+       
+       public static DeclarationFinderDO getDeclaration(IASTName name, IIndex index) throws CoreException {
+               IIndexBinding binding = index.findBinding(name);
+               IIndexName[] pdomref = index.findDeclarations(binding);
+               
+               IIndexName[] allNamesPDom = index.findNames(binding, IIndex.FIND_REFERENCES);
+               
+               if (pdomref == null || pdomref.length < 1) {
+                       return null;
+               }
+               
+               String filename2 = pdomref[0].getFileLocation().getFileName();
+               IASTTranslationUnit transUnit = TranslationUnitHelper.loadTranslationUnit(filename2, false);
+               IASTName declName = DeclarationFinder.findDeclarationInTranslationUnit(transUnit, pdomref[0]);
+               
+               return new DeclarationFinderDO(allNamesPDom, transUnit, filename2, declName);
+       }
+       
+       public static IASTName findDeclarationInTranslationUnit(IASTTranslationUnit transUnit, final IIndexName indexName) {
+               final Container<IASTName> defName = new Container<IASTName>();
+               transUnit.accept(new ASTVisitor() {
+                       {
+                               shouldVisitNames = true;
+                       }
+
+                       @Override
+                       public int visit(IASTName name) {
+                               if (name.isDeclaration() && name.getNodeLocations().length > 0) {
+                                       IASTNodeLocation nodeLocation = name.getNodeLocations()[0];
+                                       if (indexName.getNodeOffset() == nodeLocation.getNodeOffset() 
+                                                       && indexName.getNodeLength() == nodeLocation.getNodeLength()
+                                                       && new Path(indexName.getFileLocation().getFileName()).equals(new Path(nodeLocation.asFileLocation().getFileName()))) {
+                                               defName.setObject(name);
+                                               return ASTVisitor.PROCESS_ABORT;
+                                       }
+                               }
+                               return ASTVisitor.PROCESS_CONTINUE;
+                       }
+
+               });
+               return defName.getObject();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/DeclarationFinderDO.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/DeclarationFinderDO.java
new file mode 100644 (file)
index 0000000..04fb80a
--- /dev/null
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ * Institute for Software - initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.utils;
+
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.index.IIndexName;
+
+/**
+ * @author Guido Zgraggen IFS
+ *
+ */
+public class DeclarationFinderDO {
+       public IASTTranslationUnit transUnit = null;
+       public String filename = null;
+       public IIndexName[] allNamesPDom = null;
+       public IASTName name = null;
+       
+       public DeclarationFinderDO(IIndexName[] allNamesPDom2, IASTTranslationUnit transUnit2, String filename2, IASTName name2) {
+               this.transUnit = transUnit2;
+               this.filename = filename2;
+               this.allNamesPDom = allNamesPDom2;
+               this.name = name2;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/DefinitionFinder.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/DefinitionFinder.java
new file mode 100644 (file)
index 0000000..f74cb21
--- /dev/null
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Google, Inc and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *        Sergey Prigogin (Google) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.utils;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+
+import org.eclipse.cdt.core.dom.IName;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexBinding;
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.core.model.CoreModelUtil;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+import org.eclipse.cdt.internal.corext.util.CModelUtil;
+
+import org.eclipse.cdt.internal.ui.editor.ITranslationUnitEditorInput;
+import org.eclipse.cdt.internal.ui.refactoring.RefactoringASTCache;
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+
+/**
+ * Helper class for finding definitions.
+ */
+public class DefinitionFinder {
+
+       public static IASTName getDefinition(IASTSimpleDeclaration simpleDeclaration,
+                       RefactoringASTCache astCache, IProgressMonitor pm) throws CoreException {
+               IIndex index = astCache.getIndex();
+               IASTDeclarator declarator = simpleDeclaration.getDeclarators()[0];
+               if (index == null) {
+                       return null;
+               }
+               IIndexBinding binding = index.adaptBinding(declarator.getName().resolveBinding());
+               if (binding == null) {
+                       return null;
+               }
+               return getDefinition(binding, astCache, index, pm);
+       }
+
+       private static IASTName getDefinition(IIndexBinding binding,
+                       RefactoringASTCache astCache, IIndex index, IProgressMonitor pm) throws CoreException {
+               Set<String> searchedFiles = new HashSet<String>();
+               List<IASTName> definitions = new ArrayList<IASTName>();
+               IEditorPart[] dirtyEditors = EditorUtility.getDirtyEditors(true);
+               for (IEditorPart editor : dirtyEditors) {
+                       if (pm != null && pm.isCanceled()) {
+                               throw new OperationCanceledException();
+                       }
+                       IEditorInput editorInput = editor.getEditorInput();
+                       if (editorInput instanceof ITranslationUnitEditorInput) {
+                               ITranslationUnit tu =
+                                               CModelUtil.toWorkingCopy(((ITranslationUnitEditorInput) editorInput).getTranslationUnit());
+                               findDefinitionsInTranslationUnit(binding, tu, astCache, definitions, null);
+                               searchedFiles.add(tu.getLocation().toOSString());
+                       }
+               }
+               
+               IIndexName[] definitionsFromIndex = index.findDefinitions(binding);
+               for (IIndexName name : definitionsFromIndex) {
+                       if (pm != null && pm.isCanceled()) {
+                               throw new OperationCanceledException();
+                       }
+                       ITranslationUnit tu = CoreModelUtil.findTranslationUnitForLocation(
+                                       name.getFile().getLocation(), null);
+                       if (searchedFiles.add(tu.getLocation().toOSString())) {
+                               findDefinitionsInTranslationUnit(binding, tu, astCache, definitions, pm);
+                       }
+               }
+
+               return definitions.size() == 1 ? definitions.get(0) : null;
+       }
+
+       private static void findDefinitionsInTranslationUnit(IIndexBinding binding, ITranslationUnit tu,
+                       RefactoringASTCache astCache, List<IASTName> definitions, IProgressMonitor pm)
+                       throws OperationCanceledException, CoreException {
+               IASTTranslationUnit ast = astCache.getAST(tu, pm);
+               findDefinitionsInAST(binding, ast, tu, definitions);
+       }
+
+       private static void findDefinitionsInAST(IIndexBinding binding, IASTTranslationUnit ast,
+                       ITranslationUnit tu, List<IASTName> definitions) {
+               for (IName definition : ast.getDefinitions(binding)) {
+                       if (definition instanceof IASTName) {
+                               definitions.add((IASTName) definition);
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/EclipseObjects.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/EclipseObjects.java
new file mode 100644 (file)
index 0000000..2502204
--- /dev/null
@@ -0,0 +1,174 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.utils;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.editors.text.TextEditor;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.model.ICElement;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+
+/**
+ * A collection of helper methods to interact with the 
+ * workbench's IDocuments and IFiles
+ *
+ */
+public class EclipseObjects {
+       static public IWorkbenchPage getActivePage() {
+               return getActiveWindow().getActivePage();
+       }
+       
+       /**
+        * @return the active, visible TextEditor
+        */
+       static public IEditorPart getActiveEditor() {
+               IEditorPart editor = null;
+
+               IWorkbenchPage page = getActivePage();
+               
+               if (page.isEditorAreaVisible()
+                               && page.getActiveEditor() != null
+                               && page.getActiveEditor() instanceof TextEditor) {
+                       editor = page.getActiveEditor();
+               }
+               return editor;
+       }
+       
+       /**
+        * Goes through all open editors to find the one with the specified file. 
+        * 
+        * @param file to search for
+        * @return the editor or null
+        */
+       static public IEditorPart getEditorForFile(IFile file) {
+               IWorkbenchPage page = getActivePage();
+               IEditorReference[] editors = page.getEditorReferences();
+               for (IEditorReference editor2 : editors) {
+                       IEditorPart editor = editor2.getEditor(false);
+                       if (editor instanceof CEditor) {
+                               CEditor edi = ((CEditor)editor);
+                               IResource resource = edi.getInputCElement().getResource();
+                               if (resource instanceof IFile) {
+                                       if( (( IFile )resource).equals(file) ){
+                                               return editor;
+                                       }       
+                               }
+                               
+                       }
+               }
+               return null;
+       }
+       
+       /**
+        * @return the file from the active editor
+        */
+       static public IFile getActiveFile(){
+               IEditorInput editorInput = getActiveEditor().getEditorInput();
+
+               IFile aFile = null;
+               if(editorInput instanceof IFileEditorInput){
+                       aFile = ((IFileEditorInput)editorInput).getFile();
+               }
+               
+               return aFile;
+       }
+       
+       /**
+        * @return the document from the currently active editor
+        */
+       static public IDocument getActiveDocument() {
+               return getDocument( getActiveEditor() );
+       }
+       
+       /**
+        * @return the document opened in the editor 
+        */
+       static public IDocument getDocument(IEditorPart editor) {
+               ITextEditor txtEditor = ((ITextEditor)editor);
+               IDocumentProvider prov = txtEditor.getDocumentProvider();
+               return prov.getDocument(txtEditor.getEditorInput());
+       }
+
+       public static IWorkbenchWindow getActiveWindow() {
+               return PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+       }
+
+       /**
+        * @return get the document that corresponds to the file
+        */
+       public static IDocument getDocument(IFile file) {
+               IEditorPart editor = getEditorForFile(file);
+               return getDocument(editor);
+       }
+       
+       /**
+        * @return return the file that contains the selection or the 
+        * active file if there is no present selection
+        */
+       static public IFile getFile(ISelection selection) {
+               if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
+                       IFile file = getFile((IStructuredSelection)selection);
+                       return file;
+               }
+               return EclipseObjects.getActiveFile();
+       }
+
+       static private IFile getFile(IStructuredSelection selection) {
+               IFile file = null;
+               Object o = selection.getFirstElement();
+               
+               if (o instanceof ICElement) {
+                       ICElement e= (ICElement) o;
+                   IResource r= e.getUnderlyingResource();
+                   if (r instanceof IFile) {
+                       file= (IFile) r;
+                   }
+               } 
+               
+               return file;
+       }
+       
+       /**
+        * @return the file at the specified path string
+        */
+       public static IFile getFileForPathString(String path) {
+               IPath ipath = new Path(path);
+               return ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(ipath);
+       }
+       
+       /**
+        * @return the file containing the node
+        */
+       public static IFile getFile(IASTNode node){
+               if(node == null)
+                       return null;
+               return getFileForPathString(node.getFileLocation().getFileName());
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/ExpressionFinder.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/ExpressionFinder.java
new file mode 100644 (file)
index 0000000..9be32c7
--- /dev/null
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ * Institute for Software - initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.utils;
+
+import org.eclipse.core.runtime.Path;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.index.IIndexName;
+
+import org.eclipse.cdt.internal.ui.refactoring.Container;
+
+/**
+ * @author Guido Zgraggen IFS
+ */
+public class ExpressionFinder {        
+       
+       public static IASTName findExpressionInTranslationUnit(IASTTranslationUnit transUnit, final IIndexName indexName) {
+               final Container<IASTName> expName = new Container<IASTName>();
+               transUnit.accept(new ASTVisitor() {
+                       {
+                               shouldVisitNames = true;
+                       }
+
+                       @Override
+                       public int visit(IASTName name) {
+                               if (name.isReference() && name.getNodeLocations().length > 0) {
+                                       IASTNodeLocation nodeLocation = name.getNodeLocations()[0];
+                                       if (indexName.getNodeOffset() == nodeLocation.getNodeOffset() 
+                                                       && indexName.getNodeLength() == nodeLocation.getNodeLength()
+                                                       && new Path(indexName.getFileLocation().getFileName()).equals(new Path(nodeLocation.asFileLocation().getFileName()))) {
+                                               expName.setObject(name);
+                                               return ASTVisitor.PROCESS_ABORT;
+                                       }
+                               }
+                               return ASTVisitor.PROCESS_CONTINUE;
+                       }
+
+               });
+               return expName.getObject();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/FileContentHelper.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/FileContentHelper.java
new file mode 100644 (file)
index 0000000..b8a26ff
--- /dev/null
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ * Institute for Software - initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.utils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * Some helper methods to access part of the content of an iFile 
+ * 
+ * @author Emanuel Graf
+ *
+ */
+public class FileContentHelper {
+       
+       private static final int bufferSize = 512;
+
+       public static String getContent(IFile file, int start) throws CoreException, IOException{
+               InputStreamReader reader = getReaderForFile(file);      
+               skip(start, reader);
+               return readRest(reader);
+       }
+       
+       public static String getContent(IFile file, int start, int length) {
+               try {
+                       InputStreamReader r = getReaderForFile(file);
+                       char[] bytes = new char[length];
+                       
+                       skip(start, r);
+                       
+                       read(length, r, bytes);
+                       
+                       return new String(bytes);
+               } catch (IOException e) {
+                       CUIPlugin.log(e);
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }
+               return ""; //$NON-NLS-1$
+       }
+
+       private static InputStreamReader getReaderForFile(IFile file)
+                       throws CoreException, UnsupportedEncodingException {
+               InputStream contents = file.getContents();
+               InputStreamReader r = new InputStreamReader(contents, file.getCharset());
+               return r;
+       }
+
+       private static String readRest(InputStreamReader reader) throws IOException{
+               StringBuilder content = new StringBuilder();
+               char[] buffer = new char[bufferSize];
+               int bytesRead = 0;
+               while((bytesRead = reader.read(buffer)) >= 0){
+                       content.append(buffer, 0, bytesRead);
+               }
+               return content.toString();
+       }
+       
+       private static void read(int length, InputStreamReader r, char[] bytes)
+                       throws IOException {
+               int bufferOffset = 0;
+               int charactersRead = 0;
+               while(charactersRead >= 0 && length > 0){
+                       charactersRead = r.read(bytes, bufferOffset, length);
+                       if(charactersRead > 0){
+                               bufferOffset += charactersRead;
+                               length -= charactersRead;
+                       }
+               }
+       }
+
+       private static void skip(int count, InputStreamReader r) throws IOException {
+               long skipped = 0;
+               while(skipped >= 0 && count > 0 && r.ready()){
+                       skipped = r.skip(count);
+                       if(skipped > 0){
+                               count -= skipped;
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/FileHelper.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/FileHelper.java
new file mode 100644 (file)
index 0000000..f80c9d5
--- /dev/null
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *    Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.utils;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+
+/**
+ * Helper class concerning files.
+ * 
+ * @author Lukas Felber
+ *
+ */
+public class FileHelper {
+
+       public static IFile getIFilefromIASTNode(IASTNode node) {
+               IPath implPath = new Path(node.getContainingFilename());
+               return ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(implPath);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/IdentifierHelper.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/IdentifierHelper.java
new file mode 100644 (file)
index 0000000..1b74eeb
--- /dev/null
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *     Institute for Software - initial API and implementation
+ *     IBM Corporation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.utils;
+
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.osgi.util.NLS;
+
+import org.eclipse.cdt.core.parser.KeywordSetKey;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+
+import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
+
+/**
+ * Class to verify that an identifier meets the C++ rules for valid names.
+ * 
+ * @author Thomas Corbat
+ */
+public class IdentifierHelper {
+
+       /**
+        * @param identifier to check
+        * @return an instance of IdentifierResult that holds the outcome of the validation
+        */
+       public static IdentifierResult checkIdentifierName(String identifier) {
+               if (identifier == null) {
+                       return null;
+               }
+               if (isCorrect(identifier)) {
+                       if (isKeyword(identifier)) {
+                               return new IdentifierResult(IdentifierResult.KEYWORD, NLS.bind(Messages.IdentifierHelper_isKeyword, identifier)); 
+                       }
+                       return new IdentifierResult(IdentifierResult.VALID, NLS.bind(Messages.IdentifierHelper_isValid, identifier));
+               } else if (isLeadingADigit(identifier)) {
+                       return new IdentifierResult(IdentifierResult.DIGIT_FIRST, NLS.bind(Messages.IdentifierHelper_leadingDigit, identifier)); 
+               } else if (identifier.length() == 0) {
+                       return new IdentifierResult(IdentifierResult.EMPTY, Messages.IdentifierHelper_emptyIdentifier); 
+               } else if (hasIllegalCharacters(identifier)) {
+                       return new IdentifierResult(IdentifierResult.ILLEGAL_CHARACTER, NLS.bind(Messages.IdentifierHelper_illegalCharacter, identifier)); 
+               }
+               
+               return new IdentifierResult(IdentifierResult.UNKNOWN, NLS.bind(Messages.IdentifierHelper_unidentifiedMistake, identifier)); 
+       }
+
+       private static boolean isKeyword(String identifier) {
+               for (String currentKeyword : getKeywords()) {
+                       if (identifier.equals(currentKeyword)) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+       private static boolean hasIllegalCharacters(String identifier) {
+               Pattern p = Pattern.compile("\\W"); //$NON-NLS-1$
+               Matcher m = p.matcher(identifier);
+               return m.find();
+       }
+
+       private static boolean isLeadingADigit(String identifier) {
+               Pattern p = Pattern.compile("\\d.*"); //$NON-NLS-1$
+               Matcher m = p.matcher(identifier);
+               return m.matches();
+       }
+
+       private static boolean isCorrect(String identifier) {
+               Pattern p = Pattern.compile("[a-zA-Z_]\\w*"); //$NON-NLS-1$
+               Matcher m = p.matcher(identifier);
+               return m.matches();
+       }
+       
+       public static String[] getKeywords() {
+               Set<String> keywords= KeywordSets.getKeywords(KeywordSetKey.KEYWORDS, ParserLanguage.CPP);
+               return keywords.toArray(new String[keywords.size()]);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/IdentifierResult.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/IdentifierResult.java
new file mode 100644 (file)
index 0000000..9003432
--- /dev/null
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.refactoring.utils;
+
+
+/**
+ * Holds the result of a name validation, used by the IdentifierHelper.
+ * 
+ * @author Thomas Corbat
+ *
+ */
+public class IdentifierResult {
+
+       public static final int VALID = 0;
+       public static final int EMPTY = 1;
+       public static final int ILLEGAL_CHARACTER = 2;
+       public static final int DIGIT_FIRST = 3;
+       public static final int KEYWORD = 4;
+       public static final int UNKNOWN = 5;
+       
+       
+       private final int result;
+       private final String message;
+       
+       public boolean isCorrect(){
+               return result == VALID;
+       }
+       
+       public int getResult(){
+               return result;
+       }
+       
+       public String getMessage(){
+               return message;
+       }
+
+       public IdentifierResult(int result, String message) {
+               this.result = result;
+               this.message = message;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/Messages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/Messages.java
new file mode 100644 (file)
index 0000000..f3aafe6
--- /dev/null
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *     Institute for Software - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.utils;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class Messages extends NLS {
+       public static String IdentifierHelper_isKeyword;
+       public static String IdentifierHelper_isValid;
+       public static String IdentifierHelper_leadingDigit;
+       public static String IdentifierHelper_emptyIdentifier;
+       public static String IdentifierHelper_illegalCharacter;
+       public static String IdentifierHelper_unidentifiedMistake;
+       public static String VisibilityEnum_public;
+       public static String VisibilityEnum_protected;
+       public static String VisibilityEnum_private;
+       public static String Checks_validateEdit;
+
+       static {
+               NLS.initializeMessages(Messages.class.getName(), Messages.class);
+       }
+
+       // Do not instantiate
+       private Messages() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/Messages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/Messages.properties
new file mode 100644 (file)
index 0000000..e57e90e
--- /dev/null
@@ -0,0 +1,22 @@
+###############################################################################
+# Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
+# Rapperswil, University of applied sciences and others
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#    Institute for Software - initial API and implementation
+#    IBM Corporation
+###############################################################################
+IdentifierHelper_isKeyword=''{0}'' is a keyword.
+IdentifierHelper_isValid=''{0}'' is valid.
+IdentifierHelper_leadingDigit=''{0}'' has a leading digit.
+IdentifierHelper_emptyIdentifier=Identifier must not be empty.
+IdentifierHelper_illegalCharacter=Illegal character found in ''{0}''.
+IdentifierHelper_unidentifiedMistake=''{0}'' contains an unidentified mistake.
+VisibilityEnum_public=public
+VisibilityEnum_protected=protected
+VisibilityEnum_private=private
+Checks_validateEdit=Team provider refused file modification.
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NameHelper.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NameHelper.java
new file mode 100644 (file)
index 0000000..a1b0ad6
--- /dev/null
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *     Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.utils;
+
+import java.util.Arrays;
+import java.util.regex.Pattern;
+
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode.CopyStyle;
+import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.IVariable;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.parser.Keywords;
+import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
+
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTQualifiedName;
+
+import org.eclipse.cdt.internal.ui.refactoring.RefactoringASTCache;
+
+/**
+ * Helps with IASTNames.
+ * 
+ * @author Mirko Stocker
+ */
+public class NameHelper {
+       private static final Pattern localVariableRegexp = Pattern.compile("[a-z_A-Z]\\w*"); //$NON-NLS-1$
+
+       public static boolean isValidLocalVariableName(String name) {
+               return localVariableRegexp.matcher(name).matches();
+       }
+       
+       public static boolean isKeyword(String name) {
+               CharArrayIntMap keywords = new CharArrayIntMap(0, -1);
+               Keywords.addKeywordsC(keywords);
+               Keywords.addKeywordsCpp(keywords);
+               Keywords.addKeywordsPreprocessor(keywords);
+               return keywords.containsKey(name.toCharArray());
+       }
+       
+       /**
+        * Constructs the fully qualified name from the given parameters. The file and offset parameters
+        * are used to determine the namespace at the declaration position and the target namespace at
+        * the target position.
+        * 
+        * @param declaratorName of the method or function
+        * @param declarationTu translation unit of the method or function declaration
+        * @param insertFileTu translation unit of the file where the implementation is being inserted
+        * @param selectionOffset the offset in the declarationFile, usually the position or selection
+        *              of the declaration
+        * @param insertLocation 
+        * @return the correct name for the target
+        * @throws CoreException 
+        */
+       public static ICPPASTQualifiedName createQualifiedNameFor(IASTName declaratorName,
+                       ITranslationUnit declarationTu, int selectionOffset, ITranslationUnit insertFileTu,
+                       int insertLocation, RefactoringASTCache astCache) throws CoreException {
+               ICPPASTQualifiedName qname = new CPPASTQualifiedName();
+               
+               IASTName[] declarationNames = NamespaceHelper.getSurroundingNamespace(declarationTu,
+                               selectionOffset, astCache).getNames();
+               IASTName[] implementationNames = NamespaceHelper.getSurroundingNamespace(insertFileTu,
+                               insertLocation, astCache).getNames();
+               
+               for (int i = 0; i < declarationNames.length; i++) {
+                       if (i >= implementationNames.length) {
+                               qname.addName(declarationNames[i]);
+                       } else if (!Arrays.equals(declarationNames[i].toCharArray(), implementationNames[i].toCharArray())) {
+                               qname.addName(declarationNames[i]);
+                       }
+               }
+
+               qname.addName(declaratorName.copy(CopyStyle.withLocations));
+               return qname;
+       }
+       
+       public static String getTypeName(IASTParameterDeclaration parameter) {
+               IASTName name = parameter.getDeclarator().getName();
+               IBinding binding = name.resolveBinding();
+               if (binding instanceof IVariable) {
+                       IType type = ((IVariable) binding).getType();
+                       if (type != null) {
+                               return ASTTypeUtil.getType(type);
+                       }
+               }
+               return ""; //$NON-NLS-1$
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NamespaceHelper.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NamespaceHelper.java
new file mode 100644 (file)
index 0000000..f8ce66a
--- /dev/null
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *     Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.utils;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTNode.CopyStyle;
+import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNamedTypeSpecifier;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTQualifiedName;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleTypeTemplateParameter;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTemplateId;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTypeId;
+
+import org.eclipse.cdt.internal.ui.refactoring.RefactoringASTCache;
+
+/**
+ * Helper class to find Namespace informations.
+ * @author Mirko Stocker
+ */
+public class NamespaceHelper {
+       /**
+        * Returns the qualified name of all namespaces that are defined at the specified translation unit and offset.
+        * 
+        * @param translationUnit
+        * @param offset
+        * @param astCache
+        * @return ICPPASTQualifiedName with the names of all namespaces
+        * @throws CoreException 
+        */
+       public static ICPPASTQualifiedName getSurroundingNamespace(final ITranslationUnit translationUnit, final int offset, RefactoringASTCache astCache)
+                       throws CoreException {
+               final CPPASTQualifiedName qualifiedName = new CPPASTQualifiedName();
+       
+               astCache.getAST(translationUnit, null).accept(new CPPASTAllVisitor() {
+                       @Override
+                       public int visit(IASTDeclSpecifier declSpec) {
+                               if (declSpec instanceof ICPPASTCompositeTypeSpecifier && checkFileNameAndLocation(translationUnit.getLocation(), offset, declSpec)) {
+                                               qualifiedName.addName(createNameWithTemplates(declSpec));
+                                       }
+                                       return super.visit(declSpec);
+                               }
+               
+                       @Override
+                       public int visit(ICPPASTNamespaceDefinition namespace) {
+                               if (checkFileNameAndLocation(translationUnit.getLocation(), offset, namespace)) {
+                                       qualifiedName.addName((namespace).getName().copy()); 
+                               }
+                               
+                               return super.visit(namespace);
+                       }
+               });
+               
+               return qualifiedName;
+       }
+       
+       private static boolean checkFileNameAndLocation(final IPath path, final int offset, IASTNode namespace) {
+               boolean fileNameOk = namespace.getFileLocation().getFileName().endsWith(path.toOSString());
+               if (!fileNameOk) {
+                       return false;
+               }
+               
+               for (IASTNodeLocation nodeLocation : namespace.getNodeLocations()) {
+                       int nodeOffset = nodeLocation.getNodeOffset();
+                       boolean locationOk = offset >= nodeOffset && offset < nodeOffset + nodeLocation.getNodeLength();
+                       if (locationOk) {
+                               return true;
+                       }
+               }
+               
+               return false;
+       }
+       
+       private static IASTName createNameWithTemplates(IASTNode declarationParent) {
+               IASTName parentName;
+               parentName = ((ICPPASTCompositeTypeSpecifier) declarationParent).getName().copy(
+                               CopyStyle.withLocations);
+               
+               if (classHasTemplates(declarationParent)) {
+                       CPPASTTemplateId templateId = new CPPASTTemplateId();
+                       templateId.setTemplateName(parentName);
+                               
+                       for (ICPPASTTemplateParameter templateParameter : ((ICPPASTTemplateDeclaration) declarationParent.getParent().getParent() ).getTemplateParameters()) {
+                                       
+                               if (templateParameter instanceof CPPASTSimpleTypeTemplateParameter) {
+                                       CPPASTSimpleTypeTemplateParameter simpleTypeTemplateParameter = (CPPASTSimpleTypeTemplateParameter) templateParameter;
+                                       
+                                       CPPASTTypeId id = new CPPASTTypeId();
+                                       
+                                       CPPASTNamedTypeSpecifier namedTypeSpecifier = new CPPASTNamedTypeSpecifier();
+                                       namedTypeSpecifier.setName(simpleTypeTemplateParameter.getName().copy(
+                                                       CopyStyle.withLocations));
+                                       id.setDeclSpecifier(namedTypeSpecifier);
+                                       
+                                       templateId.addTemplateArgument(id);
+                               }
+                       }
+                       
+                       parentName = templateId;
+               }
+               return parentName;
+       }
+
+       private static boolean classHasTemplates(IASTNode declarationParent) {
+               return declarationParent.getParent() != null 
+                       && declarationParent.getParent().getParent() instanceof ICPPASTTemplateDeclaration;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NodeHelper.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NodeHelper.java
new file mode 100644 (file)
index 0000000..3aad6f7
--- /dev/null
@@ -0,0 +1,227 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ *     Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.utils;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+
+import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexName;
+
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNamespaceDefinition;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTranslationUnit;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
+
+import org.eclipse.cdt.internal.ui.refactoring.MethodContext;
+
+/**
+ * General class for common Node operations.
+ * 
+ * @author Lukas Felber & Guido Zgraggen
+ */
+public class NodeHelper {
+
+       public static IASTDeclaration[] getDeclarations(IASTNode parent) {
+               if (parent instanceof ICPPASTCompositeTypeSpecifier) {
+                       return ((ICPPASTCompositeTypeSpecifier) parent).getMembers();
+               } else if (parent instanceof CPPASTTranslationUnit) {
+                       return ((CPPASTTranslationUnit) parent).getDeclarations();
+               } else if (parent instanceof CPPASTNamespaceDefinition) {
+                       return ((CPPASTNamespaceDefinition) parent).getDeclarations();
+               }
+               return IASTDeclaration.EMPTY_DECLARATION_ARRAY; 
+       }
+
+       public static IASTNode findFollowingNode(IASTNode currentNode) {
+               if (currentNode == null || currentNode.getParent() == null) {
+                       return null;
+               }
+               boolean match = false;
+               for (IASTNode actNode : getDeclarations(currentNode.getParent())) {
+                       if (match) {
+                               return actNode;
+                       }
+                       if (actNode.equals(currentNode)) {
+                               match = true;
+                       }
+               }
+               return null;
+       }
+
+       public static IASTNode findTopLevelParent(IASTNode currentNode) {
+               while (currentNode != null && currentNode.getParent() != null && currentNode.getParent().getParent() != null) {
+                       return findTopLevelParent(currentNode.getParent());
+               }
+               return currentNode;
+       }
+
+       public static boolean isSameNode(IASTNode node1, IASTNode node2) {
+               if (node1 == null || node2 == null) {
+                       return false;
+               }
+               return node1.getNodeLocations()[0].getNodeOffset() == node2.getNodeLocations()[0].getNodeOffset() 
+                       && node1.getNodeLocations()[0].getNodeLength() == node2.getNodeLocations()[0].getNodeLength()
+                       && new Path(node1.getFileLocation().getFileName()).equals(new Path(node2.getFileLocation().getFileName()));
+       }
+
+       public static IASTSimpleDeclaration findSimpleDeclarationInParents(IASTNode node) {
+               while (node != null) {
+                       if (node instanceof IASTSimpleDeclaration) {
+                               return (IASTSimpleDeclaration) node;
+                       }
+                       node = node.getParent();
+               }
+               return null;
+       }
+
+       public static MethodContext findMethodContext(IASTNode node, IIndex index) throws CoreException{
+               IASTTranslationUnit translationUnit = node.getTranslationUnit();
+               boolean found = false;
+               MethodContext context = new MethodContext();
+               context.setType(MethodContext.ContextType.NONE);
+               IASTName name = null;
+               while (node != null && !found) {
+                       node = node.getParent();
+                       if (node instanceof IASTFunctionDeclarator) {
+                               name = ((IASTFunctionDeclarator) node).getName();
+                               found = true;
+                               context.setType(MethodContext.ContextType.FUNCTION);
+                       } else if (node instanceof IASTFunctionDefinition) {
+                               name = CPPVisitor.findInnermostDeclarator(((IASTFunctionDefinition) node).getDeclarator()).getName();
+                               found = true;
+                               context.setType(MethodContext.ContextType.FUNCTION);
+                       } 
+               }
+               if (index != null) {
+                       getMethodContexWithIndex(index, translationUnit, context, name);
+               } else {
+                       getMethodContex(translationUnit, context, name);
+               }
+               return context;
+       }
+
+       private static void getMethodContex(IASTTranslationUnit translationUnit, MethodContext context,
+                       IASTName name) {
+               if (name instanceof ICPPASTQualifiedName) {
+                        ICPPASTQualifiedName qname = (ICPPASTQualifiedName) name;
+                        context.setMethodQName(qname);
+                        IBinding bind = qname.resolveBinding();
+                        IASTName[] decl = translationUnit.getDeclarationsInAST(bind);
+                        for (IASTName tmpname : decl) {
+                                IASTNode methodDefinition = tmpname.getParent().getParent();
+                                if (methodDefinition instanceof IASTSimpleDeclaration) {
+                                        context.setMethodDeclarationName(tmpname);
+                                        context.setType(MethodContext.ContextType.METHOD);
+                                }
+                        }
+                }
+       }
+
+       private static void getMethodContexWithIndex(IIndex index, IASTTranslationUnit translationUnit,
+                       MethodContext context, IASTName name) throws CoreException {
+               IBinding bind = name.resolveBinding();
+               if (bind instanceof ICPPMethod) {
+                       context.setType(MethodContext.ContextType.METHOD);
+                       IIndexName[] decl;
+                       decl = index.findDeclarations(bind);
+                       String tuFileLoc = translationUnit.getFileLocation().getFileName(); 
+                       if (decl.length == 0) {
+                               context.setMethodDeclarationName(name);
+                       }
+                       for (IIndexName tmpname : decl) {
+                               IASTTranslationUnit locTu = translationUnit;
+                               if (!tuFileLoc.equals(tmpname.getFileLocation().getFileName())) {
+                                       locTu = TranslationUnitHelper.loadTranslationUnit(tmpname.getFileLocation().getFileName(), false);
+                               }
+                               IASTName declName = DeclarationFinder.findDeclarationInTranslationUnit(locTu, tmpname);
+                               if (declName != null) {
+                                       IASTNode methoddefinition = declName.getParent().getParent();
+                                       if (methoddefinition instanceof IASTSimpleDeclaration ||
+                                                       methoddefinition instanceof IASTFunctionDefinition) {
+                                               context.setMethodDeclarationName(declName);
+                                       }
+                               }
+                       }
+               }
+               if (name instanceof ICPPASTQualifiedName) {
+                       ICPPASTQualifiedName qname = (ICPPASTQualifiedName) name;
+                       context.setMethodQName(qname);
+               }
+       }
+
+       public static IASTCompoundStatement findCompoundStatementInAncestors(IASTNode node) {
+               while (node != null) {
+                       if (node instanceof IASTCompoundStatement) {
+                               return (IASTCompoundStatement) node;
+                       }
+                       node = node.getParent();
+               }
+               return null;
+       }
+
+       public static IASTCompositeTypeSpecifier findClassInAncestors(IASTNode node) {
+               while (!(node instanceof IASTCompositeTypeSpecifier)) {
+                       if (node instanceof IASTTranslationUnit) {
+                               return null;
+                       }
+                       node = node.getParent();
+               }
+               return (IASTCompositeTypeSpecifier) node;
+       }
+
+       public static IASTFunctionDefinition findFunctionDefinitionInAncestors(IASTNode node) {
+               while (node != null) {
+                       if (node instanceof IASTFunctionDefinition) {
+                               return (IASTFunctionDefinition) node;
+                       }
+                       node = node.getParent();
+               }
+               return null;
+       }
+
+       public static boolean isMethodDeclaration(IASTSimpleDeclaration simpleDeclaration) {
+               if (simpleDeclaration == null) {
+                       return false;
+               }
+               return simpleDeclaration.getDeclarators().length == 1 &&
+                               simpleDeclaration.getDeclarators()[0] instanceof ICPPASTFunctionDeclarator;
+       }
+
+       public static boolean isContainedInTemplateDeclaration(IASTNode node) {
+               return findContainedTemplateDecalaration(node) != null;
+       }
+       
+       public static ICPPASTTemplateDeclaration findContainedTemplateDecalaration(IASTNode node) {
+               while (node != null) {
+                       if (node instanceof ICPPASTTemplateDeclaration) {
+                               return (ICPPASTTemplateDeclaration) node;
+                       }
+                       node = node.getParent();
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/PseudoNameGenerator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/PseudoNameGenerator.java
new file mode 100644 (file)
index 0000000..524fe63
--- /dev/null
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.utils;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Helps to generate new unused names.
+ * 
+ * @author Mirko Stocker
+ *
+ */
+public class PseudoNameGenerator {
+       
+       private final Set<String> names = new HashSet<String>();
+       
+       public void addExistingName(String name) {
+               names.add(name);
+       }
+       
+       public String generateNewName(String typeName) {
+               String[] nameParts = typeName.split("::"); //$NON-NLS-1$
+               typeName = nameParts[nameParts.length - 1];
+               if (typeName.contains("<")) { //$NON-NLS-1$
+                       typeName = typeName.substring(0, typeName.indexOf('<'));
+               }
+               if (typeName.length() != 0) {
+                       typeName = typeName.substring(0, 1).toLowerCase() + typeName.substring(1);
+               }
+
+               nameParts = typeName.split("\\s"); //$NON-NLS-1$
+               for (int i = 0; i < nameParts.length; i++) {
+                       if (i <= 0) {
+                               typeName = nameParts[i];
+                       } else {
+                               typeName = typeName.concat(nameParts[i].substring(0,1).toUpperCase());
+                               if (nameParts[i].length() > 1) {
+                                       typeName = typeName.concat(nameParts[i].substring(1));
+                               }
+                       }
+               }
+
+               String numberString = ""; //$NON-NLS-1$
+               String newNameCandidate;
+               int index = 0;
+               
+               do {
+                       newNameCandidate = typeName + numberString;
+                       if (!NameHelper.isValidLocalVariableName(newNameCandidate)) {
+                               return ""; //$NON-NLS-1$
+                       }
+                       index++;
+                       numberString = Integer.toString(index);
+               } while (names.contains(newNameCandidate) || NameHelper.isKeyword(newNameCandidate));
+               
+               names.add(newNameCandidate);
+               return newNameCandidate;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/SelectionHelper.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/SelectionHelper.java
new file mode 100644 (file)
index 0000000..8ee3ea7
--- /dev/null
@@ -0,0 +1,143 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.utils;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.viewers.ISelection;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTMacroExpansionLocation;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+
+import org.eclipse.cdt.internal.ui.refactoring.Container;
+
+/**
+ * Helper class to support operations concerning a selection.
+ * 
+ * @author Mirko Stocker, Lukas Felber
+ */
+public class SelectionHelper {
+
+       public static Region getRegion(ISelection selection) {
+               if (selection instanceof ITextSelection) {
+                       final ITextSelection txtSelection= (ITextSelection) selection;
+                       return new Region(txtSelection.getOffset(), txtSelection.getLength());
+               }
+               return null;
+       }
+       
+       public static IASTSimpleDeclaration findFirstSelectedDeclaration(final Region textSelection,
+                       IASTTranslationUnit translationUnit) {
+               final Container<IASTSimpleDeclaration> container = new Container<IASTSimpleDeclaration>();
+
+               translationUnit.accept(new ASTVisitor() {
+                       {
+                               shouldVisitDeclarations = true;
+                       }
+                       @Override
+                       public int visit(IASTDeclaration declaration) {
+                               if (declaration instanceof IASTSimpleDeclaration &&
+                                               isSelectionOnExpression(textSelection, declaration)) {
+                                       container.setObject((IASTSimpleDeclaration) declaration);
+                               }
+                               return super.visit(declaration);
+                       }
+               });
+
+               return container.getObject();
+       }
+       
+       public static boolean isSelectionOnExpression(Region textSelection, IASTNode expression) {
+               Region exprPos = createExpressionPosition(expression);
+               int exprStart = exprPos.getOffset();
+               int selStart = textSelection.getOffset();
+               int selEnd = selStart + textSelection.getLength();
+               return exprStart + exprPos.getLength() >= selStart && exprStart <= selEnd;
+       }
+       
+       public static boolean isExpressionWhollyInSelection(Region textSelection, IASTNode expression) {
+               Region exprPos = createExpressionPosition(expression);
+               int exprStart = exprPos.getOffset();
+               int selStart = textSelection.getOffset();
+               int selEnd = selStart + textSelection.getLength();
+               return exprStart >= selStart && exprStart + exprPos.getLength() <= selEnd;
+       }
+       
+       public static boolean isInSameFile(IASTNode node, IFile file) {
+               IPath path = new Path(node.getContainingFilename());
+               IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+               IFile locFile = workspaceRoot.getFile(file.getLocation());
+               IFile tmpFile = workspaceRoot.getFile(path);
+               return locFile.equals(tmpFile);
+       }
+       
+       public static boolean isInSameFileSelection(Region textSelection, IASTNode node, IFile file) {
+               if (isInSameFile(node, file)) {
+                       return SelectionHelper.isSelectionOnExpression(textSelection, node);
+               }
+               return false;
+       }
+       
+       public static boolean isSelectedFile(Region textSelection, IASTNode node, IFile file) {
+               if (isInSameFile(node, file)) {
+                       return isExpressionWhollyInSelection(textSelection, node);
+               }
+               return false;
+       }
+       
+       protected static Region createExpressionPosition(IASTNode expression) {
+               int start = Integer.MAX_VALUE;
+               int nodeLength = 0;
+               IASTNodeLocation[] nodeLocations = expression.getNodeLocations();
+               if (nodeLocations.length != 1) {
+                       for (IASTNodeLocation location : nodeLocations) {
+                               if (location instanceof IASTMacroExpansionLocation) {
+                                       IASTMacroExpansionLocation macroLoc = (IASTMacroExpansionLocation) location;
+                                       int nodeOffset = macroLoc.asFileLocation().getNodeOffset();
+                                       if (nodeOffset < start) {
+                                               start = nodeOffset;
+                                       }
+                                       nodeLength += macroLoc.asFileLocation().getNodeLength();
+                               } else {
+                                       IASTFileLocation loc = expression.getFileLocation();
+                                       int nodeOffset = loc.getNodeOffset();
+                                       if (nodeOffset < start) {
+                                               start = nodeOffset;
+                                       }
+                                       nodeLength = loc.getNodeLength();
+                               }
+                       }
+               } else {
+                       if (nodeLocations[0] instanceof IASTMacroExpansionLocation) {
+                               IASTMacroExpansionLocation macroLoc = (IASTMacroExpansionLocation) nodeLocations[0];
+                               start = macroLoc.asFileLocation().getNodeOffset();
+                               nodeLength = macroLoc.asFileLocation().getNodeLength();
+                       } else {
+                               IASTFileLocation loc = expression.getFileLocation();
+                               start = loc.getNodeOffset();
+                               nodeLength = loc.getNodeLength();
+                       }
+               }
+               return new Region(start, nodeLength);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/TranslationUnitHelper.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/TranslationUnitHelper.java
new file mode 100644 (file)
index 0000000..d872c9a
--- /dev/null
@@ -0,0 +1,170 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.refactoring.utils;
+
+import org.eclipse.core.filesystem.URIUtil;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.CDOM;
+import org.eclipse.cdt.core.dom.IASTServiceProvider.UnsupportedDialectException;
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.refactoring.Container;
+
+/**
+ * A collection of methods that deal with IASTTranslationUnits.
+ * 
+ * @author Mirko Stocker
+ */
+public class TranslationUnitHelper {
+       private static final int AST_STYLE = ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT | ITranslationUnit.AST_SKIP_INDEXED_HEADERS;
+
+       /**
+        * Visits all names in the TU to find the specified name
+        */
+       public static IASTName findNameInTranslationUnit(IASTTranslationUnit transUnit, IASTNode oldName) {
+               final String oldFileName = oldName.getFileLocation().getFileName();
+               final IASTFileLocation pos = oldName.getFileLocation();
+               final Container<IASTName> nameCon = new Container<IASTName>();
+
+               transUnit.accept(new ASTVisitor() {
+
+                       {
+                               shouldVisitNames = true;
+                       }
+
+                       @Override
+                       public int visit(IASTName locName) {
+                               IASTFileLocation locFileLocation = locName.getFileLocation();
+                               if (locFileLocation != null && oldFileName.equals(locFileLocation.getFileName()) && pos.getNodeOffset() == locFileLocation.getNodeOffset()
+                                               && pos.getNodeLength() == locFileLocation.getNodeLength()) {
+                                       nameCon.setObject(locName);
+                                       return PROCESS_ABORT;
+                               }
+                               return super.visit(locName);
+                       }
+
+               });
+               return nameCon.getObject();
+       }
+       
+       /**
+        * @return the first node in the translation unit or null
+        */
+       public static IASTNode getFirstNode(IASTTranslationUnit unit) {
+               IASTDeclaration firstNode = null;
+               for (IASTDeclaration each : unit.getDeclarations()) {
+                       if (firstNode == null) {
+                               firstNode = each;
+                       } else if (each.getNodeLocations() != null && 
+                                       each.getNodeLocations()[0].getNodeOffset() < firstNode.getNodeLocations()[0].getNodeOffset()) {
+                               firstNode = each;
+                       }
+               }
+               return firstNode;
+       }
+       
+       /**
+        * @param filename to load the translation unit from
+        * @return the translation unit for the file or null
+        * @throws CoreException 
+        * @deprecated Use RefactoringASTCache.
+        */
+       @Deprecated
+       public static IASTTranslationUnit loadTranslationUnit(String filename, boolean useIndex) throws CoreException{
+               if (filename != null) {
+                       IFile[] tmpFile = null;
+
+                       tmpFile = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(
+                                       URIUtil.toURI(filename));
+
+                       return loadTranslationUnit(tmpFile[0], useIndex);
+               }
+
+               return null;
+       }
+       
+       /**
+        * @param file to load the translation unit from
+        * @return the translation unit for the file or null
+        * @throws CoreException 
+        * @deprecated Use RefactoringASTCache.
+        */
+       @Deprecated
+       public static IASTTranslationUnit loadTranslationUnit(IFile file, boolean useIndex) throws CoreException {
+               if (file == null) {
+                       return null;
+               }
+               if (useIndex) {
+                       return loadIndexBasedTranslationUnit(file);
+               } else {
+                       return loadFileBasedTranslationUnit(file);
+               }
+       }
+
+       private static IASTTranslationUnit loadFileBasedTranslationUnit(IFile file) {
+               try {
+                       IASTTranslationUnit fileUnit = CDOM.getInstance().getTranslationUnit(file, CDOM.getInstance().getCodeReaderFactory(CDOM.PARSE_SAVED_RESOURCES), true);
+                       return fileUnit;
+               } catch (UnsupportedDialectException e) {
+                       return null;
+               }
+       }
+
+       private static IASTTranslationUnit loadIndexBasedTranslationUnit(IFile file) throws CoreException {
+               IIndex index = null;
+               try {
+                       index = lockIndex();
+                       ITranslationUnit tu = (ITranslationUnit) CCorePlugin.getDefault().getCoreModel().create(file);
+                       return tu.getAST(index, AST_STYLE);
+               } catch (InterruptedException e) {
+                       CUIPlugin.log(e);
+               } finally {
+                       unlockIndex(index);
+               }
+               return null;
+       }
+
+       private static IIndex lockIndex() throws CoreException, InterruptedException {
+               IIndex index;
+               ICProject[] projects= CoreModel.getDefault().getCModel().getCProjects();
+               index= CCorePlugin.getIndexManager().getIndex(projects);
+               try {
+                       index.acquireReadLock();
+               } catch (InterruptedException e) {
+                       // no lock was acquired
+                       index= null; 
+                       throw e;
+               }
+               return index;
+       }
+       
+       private static void unlockIndex(IIndex index) {
+               if (index != null) {
+                       index.releaseReadLock();
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/VisibilityEnum.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/VisibilityEnum.java
new file mode 100644 (file)
index 0000000..2203263
--- /dev/null
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.refactoring.utils;
+
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
+
+/**
+ * Enum that represents C++ visibilities, with methods to convert to
+ * and from ICPPASTVisiblityLabel.
+ *
+ */
+public enum VisibilityEnum {
+       
+       v_public(Messages.VisibilityEnum_public),  
+       v_protected(Messages.VisibilityEnum_protected),  
+       v_private(Messages.VisibilityEnum_private); 
+
+       private final String stringRepresentation;
+       
+       VisibilityEnum(String stringRepresentation) {
+               this.stringRepresentation = stringRepresentation;
+       }
+       
+       public static VisibilityEnum from(ICPPASTVisibilityLabel visibility) {
+               switch(visibility.getVisibility()){
+               case ICPPASTVisibilityLabel.v_private:
+                       return VisibilityEnum.v_private;
+               case ICPPASTVisibilityLabel.v_protected:
+                       return VisibilityEnum.v_protected;
+               case ICPPASTVisibilityLabel.v_public:
+                       return VisibilityEnum.v_public;
+               }
+               return null;
+       }
+       
+       public int getASTBaseSpecifierVisibility() {
+               switch (this) {
+               case v_private:
+                       return ICPPASTBaseSpecifier.v_private;
+               case v_protected:
+                       return ICPPASTBaseSpecifier.v_protected;
+               case v_public:
+                       return ICPPASTBaseSpecifier.v_public;
+               }
+               return 0;
+       }
+       
+       public int getICPPASTVisiblityLabelVisibility() {
+               switch (this) {
+               case v_private:
+                       return ICPPASTVisibilityLabel.v_private;
+               case v_protected:
+                       return ICPPASTVisibilityLabel.v_protected;
+               case v_public:
+                       return ICPPASTVisibilityLabel.v_public;
+               }
+               return 0;
+       }
+       
+       public static VisibilityEnum getEnumForStringRepresentation(String visibility){
+               if( VisibilityEnum.v_private.toString().equals( visibility ) ) {
+                       return VisibilityEnum.v_private;
+               }else if( VisibilityEnum.v_protected.toString().equals( visibility ) ) {
+                       return VisibilityEnum.v_protected;
+               }else if ( VisibilityEnum.v_public.toString().equals( visibility ) ) {
+                       return VisibilityEnum.v_public;
+               }
+               return null;
+       }
+       
+       @Override
+       public String toString() {
+               return stringRepresentation;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/resources/ResourceExclusionContributor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/resources/ResourceExclusionContributor.java
new file mode 100644 (file)
index 0000000..3f79319
--- /dev/null
@@ -0,0 +1,300 @@
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.resources;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.CheckedTreeSelectionDialog;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+
+import org.eclipse.cdt.core.resources.ExclusionInstance;
+import org.eclipse.cdt.core.resources.ExclusionType;
+import org.eclipse.cdt.core.resources.RefreshExclusion;
+import org.eclipse.cdt.ui.resources.Messages;
+import org.eclipse.cdt.ui.resources.RefreshExclusionContributor;
+
+import org.eclipse.cdt.internal.core.resources.ResourceExclusion;
+
+/**
+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as part of a work in progress. There
+ * is no guarantee that this API will work or that it will remain the same. Please do not use this API without
+ * consulting with the CDT team.
+ * 
+ * @author vkong
+ * @since 5.3
+ * 
+ */
+public class ResourceExclusionContributor extends RefreshExclusionContributor {
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.cdt.ui.resources.RefreshExclusionContributor#createExclusion()
+        */
+       @Override
+       public RefreshExclusion createExclusion() {
+               ResourceExclusion newExclusion = new ResourceExclusion();
+               newExclusion.setContributorId(getID());
+
+               // TODO change this for Phase 2
+               newExclusion.setExclusionType(ExclusionType.FOLDER);
+               return newExclusion;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * org.eclipse.cdt.ui.resources.RefreshExclusionContributor#createProperiesUI(org.eclipse.swt.widgets.
+        * Composite, org.eclipse.cdt.core.resources.RefreshExclusion)
+        */
+       @Override
+       public void createProperiesUI(Composite parent, final RefreshExclusion exclusion) {
+               final Shell shell = parent.getShell();
+
+               Group g = new Group(parent, SWT.NONE);
+               g.setText(Messages.RefreshPolicyExceptionDialog_exceptionTypeResources);
+               g.setLayout(new GridLayout(1, false));
+               GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
+               gridData.verticalAlignment = GridData.FILL;
+               gridData.horizontalSpan = 2;
+               gridData.verticalSpan = 2;
+               g.setLayoutData(gridData);
+
+               final List exceptionsList = new List(g, SWT.NONE);
+               gridData = new GridData();
+               gridData.verticalAlignment = GridData.FILL;
+               gridData.verticalSpan = 2;
+               gridData.grabExcessHorizontalSpace = true;
+               gridData.grabExcessVerticalSpace = true;
+               gridData.minimumHeight = 250;
+               gridData.minimumWidth = 275;
+               exceptionsList.setLayoutData(gridData);
+
+               final HashMap<String, ExclusionInstance> exclusionInstanceStrings = new LinkedHashMap<String, ExclusionInstance>();
+               final HashMap<String, Object> exclusionInstanceResources = new LinkedHashMap<String, Object>();
+
+               java.util.List<ExclusionInstance> exclusionInstances = exclusion.getExclusionInstances();
+
+               // populate exclusion instance list
+               if (exclusionInstances != null) {
+                       Iterator<ExclusionInstance> iterator = exclusionInstances.iterator();
+                       while (iterator.hasNext()) {
+                               ExclusionInstance exclusionInstance = iterator.next();
+                               String name = exclusionInstance.getDisplayString();
+                               exceptionsList.add(name);
+                               exclusionInstanceStrings.put(name, exclusionInstance);
+                               exclusionInstanceResources.put(name, exclusionInstance.getResource());
+                       }
+               }
+
+               Composite buttonComp = new Composite(parent, SWT.NONE);
+               buttonComp.setLayout(new GridLayout(1, false));
+               gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
+               gridData.minimumWidth = 100;
+               buttonComp.setLayoutData(gridData);
+
+               Button addButton = new Button(buttonComp, SWT.NONE);
+               gridData = new GridData();
+               gridData.horizontalAlignment = GridData.FILL;
+               gridData.grabExcessHorizontalSpace = true;
+               addButton.setLayoutData(gridData);
+               addButton.setText(Messages.RefreshPolicyExceptionDialog_addButtonLabel);
+
+               addButton.addSelectionListener(new SelectionAdapter() {
+
+                       /*
+                        * (non-Javadoc)
+                        * 
+                        * @see
+                        * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+                        */
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               CheckedTreeSelectionDialog dialog = new CheckedTreeSelectionDialog(shell,
+                                               WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(),
+                                               new ITreeContentProvider() {
+
+                                                       public void dispose() {
+                                                       }
+
+                                                       public Object[] getChildren(Object parentElement) {
+                                                               if (parentElement instanceof IContainer) {
+                                                                       IContainer container = (IContainer) parentElement;
+                                                                       if (container.isAccessible()) {
+                                                                               try {
+                                                                                       java.util.List<IResource> children = new ArrayList<IResource>();
+                                                                                       IResource[] members = container.members();
+                                                                                       for (int i = 0; i < members.length; i++) {
+                                                                                               if (members[i].getType() == IResource.FOLDER) {
+                                                                                                       children.add(members[i]);
+                                                                                               }
+                                                                                       }
+                                                                                       return children.toArray();
+                                                                               } catch (CoreException e) {
+                                                                                       // this should never happen because we call #isAccessible before
+                                                                                       // invoking #members
+                                                                               }
+                                                                       }
+                                                               }
+                                                               return new Object[0];
+                                                       }
+
+                                                       public Object[] getElements(Object inputElement) {
+                                                               return getChildren(inputElement);
+                                                       }
+
+                                                       public Object getParent(Object element) {
+                                                               if (element instanceof IResource) {
+                                                                       return ((IResource) element).getParent();
+                                                               }
+                                                               return null;
+                                                       }
+
+                                                       public boolean hasChildren(Object element) {
+                                                               return getChildren(element).length > 0;
+                                                       }
+
+                                                       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+                                                       }
+                                               });
+
+                               dialog.setInput(getResourceRoot(exclusion));
+
+                               if (exclusionInstanceResources.values().size() > 0) {
+                                       dialog.setInitialElementSelections(Arrays.asList(exclusionInstanceResources.values()
+                                                       .toArray()));
+                               }
+                               dialog.setMessage(Messages.RefreshPolicyExceptionDialog_SelectResourceDialogMessage);
+                               dialog.setTitle(Messages.RefreshPolicyExceptionDialog_SelectResourceDialogTitle);
+
+                               if (dialog.open() == Window.OK) {
+                                       Object[] selection = dialog.getResult();
+                                       exceptionsList.removeAll();
+                                       exclusionInstanceResources.clear();
+                                       final HashMap<String, ExclusionInstance> oldExclusionInstanceStrings = new LinkedHashMap<String, ExclusionInstance>(
+                                                       exclusionInstanceStrings);
+                                       exclusionInstanceStrings.clear();
+
+                                       for (int i = 0; i < selection.length; i++) {
+                                               Object selected = selection[i];
+                                               if (selected instanceof IFolder) {
+                                                       IPath path = ((IFolder) selected).getFullPath();
+                                                       IPath relativePath = path
+                                                                       .makeRelativeTo(getResourceRoot(exclusion).getFullPath());
+
+                                                       exceptionsList.add(relativePath.toString());
+                                                       ExclusionInstance instance = oldExclusionInstanceStrings.get(relativePath
+                                                                       .toString());
+                                                       if (instance == null) {
+                                                               instance = new ExclusionInstance();
+                                                               instance.setExclusionType(ExclusionType.FOLDER);
+                                                               instance.setParentExclusion(exclusion);
+                                                               instance.setResource((IResource) selected);
+                                                               instance.setDisplayString(relativePath.toString());
+                                                               exclusion.addExclusionInstance(instance);
+                                                       } else {
+                                                               oldExclusionInstanceStrings.remove(relativePath.toString());
+                                                       }
+
+                                                       exclusionInstanceStrings.put(instance.getDisplayString(), instance);
+                                                       exclusionInstanceResources.put(instance.getDisplayString(), selected);
+                                               }
+                                       }
+                                       // remove deprecated exclusion instances
+                                       oldExclusionInstanceStrings.keySet();
+                                       Iterator<String> iterator = oldExclusionInstanceStrings.keySet().iterator();
+                                       while (iterator.hasNext()) {
+                                               String toRemove = iterator.next();
+                                               ExclusionInstance instanceToRemove = oldExclusionInstanceStrings.get(toRemove);
+                                               exclusion.removeExclusionInstance(instanceToRemove);
+                                               iterator.remove();
+                                       }
+                               }
+                       }
+
+               });
+
+               Button deleteButton = new Button(buttonComp, SWT.NONE);
+               gridData = new GridData();
+               gridData.horizontalAlignment = GridData.FILL;
+               gridData.grabExcessHorizontalSpace = true;
+               deleteButton.setLayoutData(gridData);
+               deleteButton.setText(Messages.RefreshPolicyExceptionDialog_deleteButtonLabel);
+
+               deleteButton.addSelectionListener(new SelectionAdapter() {
+
+                       /*
+                        * (non-Javadoc)
+                        * 
+                        * @see
+                        * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+                        */
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               String[] selected = exceptionsList.getSelection();
+                               if (selected.length < 1)
+                                       return;
+
+                               for (int i = 0; i < selected.length; i++) {
+                                       String folderToRemove = selected[i];
+                                       ExclusionInstance instanceToRemove = exclusionInstanceStrings.get(folderToRemove);
+
+                                       // Iterator<Object> iterator = selectedFolders.iterator();
+
+                                       // while (iterator.hasNext()) {
+                                       // IPath path = ((IFolder)iterator.next()).getFullPath();
+                                       // IPath relativePath = path.makeRelativeTo(getResourceRoot(exclusionRoot).getFullPath());
+                                       // if (relativePath.toString().compareTo(folderToRemove) == 0) {
+                                       // iterator.remove();
+                                       // break;
+                                       // }
+                                       // }
+                                       exclusion.removeExclusionInstance(instanceToRemove);
+                                       exclusionInstanceStrings.remove(folderToRemove);
+                                       exclusionInstanceResources.remove(folderToRemove);
+                               }
+                               exceptionsList.remove(exceptionsList.getSelectionIndices());
+                       }
+
+               });
+       }
+
+       private IResource getResourceRoot(RefreshExclusion exclusion) {
+               if (exclusion.getParentExclusion() != null) {
+                       return getResourceRoot(exclusion.getParentExclusion());
+               }
+               return exclusion.getParentResource();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.java
new file mode 100644 (file)
index 0000000..132696f
--- /dev/null
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corp. - Rational Software - initial implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Andrey Eremchenko (LEDAS)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.search;
+
+import org.eclipse.osgi.util.NLS;
+
+
+public final class CSearchMessages extends NLS {
+    private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.search.CSearchMessages"; //$NON-NLS-1$
+       public static String group_declarations;
+       public static String group_references;
+       public static String CSearchResultCollector_matches;
+       public static String CSearchResultCollector_line;
+       public static String CSearchResultCollector_location;
+       public static String CSearchPage_searchFor_label;
+       public static String CSearchPage_searchFor_namespace;
+       public static String CSearchPage_searchFor_method;
+       public static String CSearchPage_searchFor_function;
+       public static String CSearchPage_searchFor_field;
+       public static String CSearchPage_searchFor_variable;
+       public static String CSearchPage_searchFor_union;
+       public static String CSearchPage_searchFor_enum;
+       public static String CSearchPage_searchFor_enumr;
+       public static String CSearchPage_searchFor_typedef;
+       public static String CSearchPage_searchFor_macro;
+       public static String CSearchPage_searchFor_any;
+       public static String CSearchPage_searchFor_classStruct;
+    public static String CSearchPage_label_note;
+    public static String CSearchPage_label_activeCodeRemark;
+       public static String CSearchPage_limitTo_label;
+       public static String CSearchPage_limitTo_declarations;
+       public static String CSearchPage_limitTo_definitions;
+       public static String CSearchPage_limitTo_references;
+       public static String CSearchPage_limitTo_allOccurrences;
+       public static String CSearchPage_expression_label;
+       public static String CSearchPage_expression_caseSensitive;
+       public static String CSearch_FindDeclarationAction_label;
+       public static String CSearch_FindDeclarationAction_tooltip;
+       public static String CSearch_FindDeclarationsProjectAction_label;
+       public static String CSearch_FindDeclarationsProjectAction_tooltip;
+       public static String CSearch_FindReferencesAction_label;
+       public static String CSearch_FindReferencesAction_tooltip;
+       public static String CSearch_FindReferencesProjectAction_label;
+       public static String CSearch_FindReferencesProjectAction_tooltip;
+       public static String CSearch_FindReferencesInWorkingSetAction_label;
+       public static String CSearch_FindReferencesInWorkingSetAction_tooltip;
+       public static String CSearchOperation_operationUnavailable_message;
+       public static String WorkspaceScope;
+       public static String WorkingSetScope;
+       public static String SelectionScope;
+       public static String ProjectScope;
+       public static String PDOMSearchQuery_refs_label;
+       public static String PDOMSearchQuery_defs_label;
+       public static String PDOMSearchQuery_decls_label;
+       public static String PDOMSearchQuery_refs_result_label;
+       public static String PDOMSearchQuery_defs_result_label;
+       public static String PDOMSearchQuery_decls_result_label;
+       public static String PDOMSearchQuery_decldefs_result_label;
+       public static String PDOMSearchQuery_occurrences_result_label;
+       public static String PDOMSearchElementQuery_something;
+       public static String PDOMSearchPatternQuery_PatternQuery_labelPatternInScope;
+       public static String PDOMSearch_query_pattern_error;
+       public static String SelectionParseAction_FileOpenFailure_format;
+       public static String SelectionParseAction_SelectedTextNotSymbol_message;
+       public static String SelectionParseAction_SymbolNotFoundInIndex_format;
+       public static String SelectionParseAction_IncludeNotFound_format;
+       public static String OccurrencesFinder_no_element;
+       public static String OccurrencesFinder_no_binding;
+       public static String OccurrencesFinder_searchfor;
+       public static String OccurrencesFinder_label_singular;
+       public static String OccurrencesFinder_label_plural;
+       public static String OccurrencesFinder_occurrence_description;
+       public static String OccurrencesFinder_occurrence_write_description;
+       public static String PDOMSearchListContentProvider_IndexerNotEnabledMessageFormat;
+       public static String PDOMSearchListContentProvider_ProjectClosedMessageFormat;
+       public static String CSearchMessages_IndexRunningIncompleteWarning;
+       public static String HidePolymorphicCalls_actionLabel;
+       public static String HidePolymorphicCalls_description;
+       public static String HidePolymorphicCalls_name;
+       public static String PDOMSearchViewPage_ShowEnclosingDefinitions_actionLabel;
+       public static String PDOMSearchViewPage_ShowEnclosingDefinitions_description;
+       public static String PDOMSearchViewPageLocationColumn_label;
+       public static String PDOMSearchViewPageDefinitionColumn_label;
+       public static String PDOMSearchViewPageMatchColumn_label;
+       public static String PDOMSearchTreeContentProvider_IndexerNotEnabledWarning;
+       public static String PDOMSearchTreeContentProvider_ProjectClosedWarning;
+       public static String PDOMSearchUnresolvedIncludesQuery_title;
+
+       static {
+               NLS.initializeMessages(BUNDLE_NAME, CSearchMessages.class);
+       }
+
+    private CSearchMessages() {
+        // Do not instantiate
+    }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchMessages.properties
new file mode 100644 (file)
index 0000000..4deb6dd
--- /dev/null
@@ -0,0 +1,113 @@
+###############################################################################
+# Copyright (c) 2000, 2011 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+#     Ed Swartz (Nokia)
+#     Anton Leherbauer (Wind River Systems)
+#     Andrey Eremchenko (LEDAS)
+###############################################################################
+
+group_declarations=Dec&larations
+group_references=Re&ferences
+
+
+# Examples of the display for the following value are
+# "(1 match)", where {0} is 1 and "(5 matches)", where {0} is 2 or more.
+CSearchResultCollector_matches= ({0} {0, choice, 0\#matches|1\#match|2\#matches})
+CSearchResultCollector_line= {0}line {1,number,######}
+CSearchResultCollector_location= {0}, line {1,number,######}
+
+CSearchPage_searchFor_label= Search For
+CSearchPage_searchFor_namespace= Names&pace
+CSearchPage_searchFor_method= &Method
+CSearchPage_searchFor_function= F&unction
+CSearchPage_searchFor_field= &Field
+CSearchPage_searchFor_variable= &Variable
+CSearchPage_searchFor_union= U&nion
+CSearchPage_searchFor_enum= &Enumeration
+CSearchPage_searchFor_enumr = Enume&rator
+CSearchPage_searchFor_typedef = &Typedef
+CSearchPage_searchFor_macro = M&acro
+CSearchPage_searchFor_any= An&y Element
+CSearchPage_searchFor_classStruct= &Class / Struct
+
+CSearchPage_limitTo_label= &Limit To
+CSearchPage_limitTo_declarations= Declarations
+CSearchPage_limitTo_definitions= Definitions
+CSearchPage_limitTo_references= References
+CSearchPage_limitTo_allOccurrences= All Occurrences
+
+CSearchPage_label_note=Note:
+CSearchPage_label_activeCodeRemark= The C/C++ Search only processes the active code!
+
+CSearchPage_expression_label= Search strin&g (* = any string, ? = any character):
+CSearchPage_expression_caseSensitive= Case sens&itive
+
+CSearch_FindDeclarationAction_label= &Workspace
+CSearch_FindDeclarationAction_tooltip= Search for Declarations of the Selected Element in the Workspace
+
+CSearch_FindDeclarationsProjectAction_label = &Project
+CSearch_FindDeclarationsProjectAction_tooltip = Search for Declarations of the Selected Element in the current project
+
+CSearch_FindReferencesAction_label= &Workspace
+CSearch_FindReferencesAction_tooltip= Search for References to the Selected Element in the Workspace
+
+CSearch_FindReferencesProjectAction_label= &Project
+CSearch_FindReferencesProjectAction_tooltip= Search for References to the Selected Element in the current project
+
+CSearch_FindReferencesInWorkingSetAction_label= Working &Set...
+CSearch_FindReferencesInWorkingSetAction_tooltip= Search for References to the Selected Element in a Working Set
+
+CSearchOperation_operationUnavailable_message= The operation is unavailable on the current selection.
+
+WorkspaceScope= workspace
+WorkingSetScope= working set - {0}
+SelectionScope= selection
+ProjectScope = project
+
+PDOMSearchQuery_refs_label = Search references
+PDOMSearchQuery_defs_label = Search definitions
+PDOMSearchQuery_decls_label = Search declarations
+PDOMSearchQuery_refs_result_label = References to ''{0}''
+PDOMSearchQuery_defs_result_label = Definitions of ''{0}''
+PDOMSearchQuery_decls_result_label = Declarations of ''{0}''
+PDOMSearchQuery_decldefs_result_label = Declarations and definitions of ''{0}''
+PDOMSearchQuery_occurrences_result_label = Occurrences of ''{0}''
+
+PDOMSearchElementQuery_something = something
+PDOMSearchPatternQuery_PatternQuery_labelPatternInScope={0} in {1}
+PDOMSearchTreeContentProvider_IndexerNotEnabledWarning=(unknown results: indexer is not enabled)
+PDOMSearchTreeContentProvider_ProjectClosedWarning=(unknown results: project is closed)
+PDOMSearchListContentProvider_IndexerNotEnabledMessageFormat=(project ''{0}'' - unknown results: indexer is not enabled)
+PDOMSearchListContentProvider_ProjectClosedMessageFormat=(project ''{0}'' - unknown results: project is closed)
+CSearchMessages_IndexRunningIncompleteWarning=(incomplete or inaccurate results: indexer was busy during search)
+HidePolymorphicCalls_actionLabel=Hide Potential Method Calls
+HidePolymorphicCalls_description=Hides potential method calls to virtual overriders
+HidePolymorphicCalls_name=Potential Method Calls
+PDOMSearchViewPage_ShowEnclosingDefinitions_actionLabel=Show Enclosing Definitions
+PDOMSearchViewPage_ShowEnclosingDefinitions_description=Shows enclosing definitions for matches
+PDOMSearchViewPageLocationColumn_label=Location
+PDOMSearchViewPageDefinitionColumn_label=Enclosing Definition
+PDOMSearchViewPageMatchColumn_label=Match
+PDOMSearch_query_pattern_error = Illegal Search String
+PDOMSearchUnresolvedIncludesQuery_title=Unresolved inclusions in {0}
+SelectionParseAction_FileOpenFailure_format=Could not open file ''{0}'', verify index is up-to-date
+SelectionParseAction_SelectedTextNotSymbol_message=Selected text cannot be mapped to a symbol name
+SelectionParseAction_SymbolNotFoundInIndex_format=Could not find symbol ''{0}'' in index
+SelectionParseAction_IncludeNotFound_format=Could not find include file ''{0}'' on include paths
+
+# Occurrences
+OccurrencesFinder_no_element= Cannot search for the current selection. Please select a valid C/C++ element name.
+OccurrencesFinder_no_binding= Selected C/C++ element is unknown.
+OccurrencesFinder_searchfor=Search for Occurrences in File
+# The first argument will be replaced by the element name and the second one by the file name
+OccurrencesFinder_label_singular=''{0}'' - 1 occurrence in ''{1}''
+# The first argument will be replaced by the element name, the second by the count and the last by the file name
+OccurrencesFinder_label_plural=''{0}'' - {1} occurrences in ''{2}''
+OccurrencesFinder_occurrence_description=Occurrence of ''{0}''
+OccurrencesFinder_occurrence_write_description=Write Occurrence of ''{0}''
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchUtil.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchUtil.java
new file mode 100644 (file)
index 0000000..0d839f7
--- /dev/null
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Andrew Niefer (Rational Software) - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.search;
+
+import org.eclipse.ui.IWorkingSet;
+
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
+
+import org.eclipse.cdt.internal.core.dom.parser.c.CVariableReadWriteFlags;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVariableReadWriteFlags;
+import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
+
+public class CSearchUtil {
+
+       public static int LRU_WORKINGSET_LIST_SIZE= 3;
+       private static LRUWorkingSets workingSetsCache;
+       
+       public CSearchUtil() {
+               super();
+       }
+
+       public static void updateLRUWorkingSets(IWorkingSet[] workingSets) {
+               if (workingSets == null || workingSets.length < 1)
+                       return;
+               
+               CSearchUtil.getLRUWorkingSets().add(workingSets);
+       }
+
+       public static LRUWorkingSets getLRUWorkingSets() {
+               if (CSearchUtil.workingSetsCache == null) {
+                       CSearchUtil.workingSetsCache = new LRUWorkingSets(CSearchUtil.LRU_WORKINGSET_LIST_SIZE);
+               }
+               return CSearchUtil.workingSetsCache;
+       }
+       
+       public static String toString(IWorkingSet[] workingSets) {
+               if( workingSets != null && workingSets.length > 0 ){
+                       String string = new String();
+                       for( int i = 0; i < workingSets.length; i++ ){
+                               if( i > 0 )
+                                       string += ", ";  //$NON-NLS-1$
+                               string += workingSets[i].getName();
+                       }
+                       
+                       return string;
+               }
+               
+               return null;
+       }
+
+       public static boolean isWriteOccurrence(IASTName node, IBinding binding) {
+               boolean isWrite;
+               if (binding instanceof ICPPVariable) {
+                       isWrite = ((CPPVariableReadWriteFlags.getReadWriteFlags(node) & PDOMName.WRITE_ACCESS) != 0);
+               }
+               else { 
+                       isWrite = ((CVariableReadWriteFlags.getReadWriteFlags(node) & PDOMName.WRITE_ACCESS) != 0);
+               }
+               return isWrite;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CountLabelProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CountLabelProvider.java
new file mode 100644 (file)
index 0000000..2da7745
--- /dev/null
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*
+ * Created on Apr 28, 2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.eclipse.cdt.internal.ui.search;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
+import org.eclipse.swt.graphics.Image;
+
+import org.eclipse.cdt.internal.ui.util.Messages;
+
+/**
+ * @author bgheorgh
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class CountLabelProvider extends LabelProvider {
+
+       private ILabelProvider fLabelProvider;
+       private AbstractTextSearchViewPage fPage;
+
+       public CountLabelProvider(AbstractTextSearchViewPage page, ILabelProvider inner) {
+               fPage= page;
+               fLabelProvider= inner;
+       }
+       
+       public ILabelProvider getLabelProvider() {
+               return fLabelProvider;
+       }
+
+       @Override
+       public Image getImage(Object element) {
+               return fLabelProvider.getImage(element);
+       }
+
+       @Override
+       public String getText(Object element) {
+               int c = fPage.getInput().getMatchCount(element);
+               
+               String text= fLabelProvider.getText(element);
+               if (c == 0)
+                       return text;
+               Integer matchCount= new Integer(c);
+               return fLabelProvider.getText(element) + " "+ Messages.format(CSearchMessages.CSearchResultCollector_matches, matchCount);  //$NON-NLS-1$
+       }
+
+       @Override
+       public void dispose() {
+               fLabelProvider.dispose();
+               super.dispose();
+       }
+       
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/HidePolymorphicCalls.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/HidePolymorphicCalls.java
new file mode 100644 (file)
index 0000000..ee64196
--- /dev/null
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.search;
+
+import org.eclipse.search.ui.text.Match;
+import org.eclipse.search.ui.text.MatchFilter;
+
+public class HidePolymorphicCalls extends MatchFilter {
+
+       public static final MatchFilter FILTER = new HidePolymorphicCalls();
+
+       @Override
+       public boolean filters(Match match) {
+               return match instanceof PDOMSearchMatch && ((PDOMSearchMatch) match).isPolymorphicCall();
+       }
+
+       @Override
+       public String getActionLabel() {
+               return CSearchMessages.HidePolymorphicCalls_actionLabel;
+       }
+
+       @Override
+       public String getDescription() {
+               return CSearchMessages.HidePolymorphicCalls_description;
+       }
+
+       @Override
+       public String getID() {
+               return "HidePolymorphicCalls"; //$NON-NLS-1$
+       }
+
+       @Override
+       public String getName() {
+               return CSearchMessages.HidePolymorphicCalls_name;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/IOccurrencesFinder.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/IOccurrencesFinder.java
new file mode 100644 (file)
index 0000000..4ca1328
--- /dev/null
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.search;
+
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+
+public interface IOccurrencesFinder {
+       
+       public static final int K_OCCURRENCE= 5;
+       
+       public static final int F_WRITE_OCCURRENCE= 1;
+       public static final int F_READ_OCCURRENCE= 2;
+
+       /**
+        * Element representing an occurrence
+        */
+       public static class OccurrenceLocation {
+               private final int fOffset;
+               private final int fLength;
+               private final int fFlags;
+               private final String fDescription;
+
+               public OccurrenceLocation(int offset, int length, int flags, String description) {
+                       fOffset= offset;
+                       fLength= length;
+                       fFlags= flags;
+                       fDescription= description;
+               }
+
+               public int getOffset() {
+                       return fOffset;
+               }
+
+               public int getLength() {
+                       return fLength;
+               }
+
+               public int getFlags() {
+                       return fFlags;
+               }
+
+               public String getDescription() {
+                       return fDescription;
+               }
+
+               @Override
+               public String toString() {
+                       return "[" + fOffset + " / " + fLength + "] " + fDescription; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+               }
+       }
+       
+       public String initialize(IASTTranslationUnit root, IASTNode node);
+
+       /**
+        * Returns the plural label for this finder with 3 placeholders:
+        * <ul>
+        * <li>{0} for the {@link #getElementName() element name}</li>
+        * <li>{1} for the number of results found</li>
+        * <li>{2} for the scope (name of the compilation unit)</li>
+        *  </ul>
+        * @return the unformatted label
+        */
+       public String getUnformattedPluralLabel();
+       
+       /**
+        * Returns the singular label for this finder with 2 placeholders:
+        * <ul>
+        * <li>{0} for the {@link #getElementName() element name}</li>
+        * <li>{1} for the scope (name of the compilation unit)</li>
+        *  </ul>
+        * @return the unformatted label
+        */
+       public String getUnformattedSingularLabel();
+       
+       /**
+        * Returns the name of the element to look for or <code>null</code> if the finder hasn't
+        * been initialized yet.
+        * @return the name of the element
+        */
+       public String getElementName();
+
+       /**
+        * Returns the AST root.
+        * 
+        * @return the AST root
+        */
+       public IASTTranslationUnit getASTRoot();
+
+       /**
+        * Returns the occurrences
+        * 
+        * @return the occurrences
+        */
+       public OccurrenceLocation[] getOccurrences();
+
+       public int getSearchKind();
+                       
+       /**
+        * Returns the id of this finder.
+        * @return returns the id of this finder.
+        */
+       public String getID();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/IPDOMSearchContentProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/IPDOMSearchContentProvider.java
new file mode 100644 (file)
index 0000000..0433048
--- /dev/null
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX - Initial API and implementation
+ * Ed Swartz (Nokia)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.search;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * The content in the tree and list views may be either:
+ * <p>
+ * IStatus - warnings or errors from the search<br>
+ * ICElement - for C/C++ elements, including TUs, folders, projects<br>
+ * IPath - directory container, full path<br>
+ *             IIndexFileLocation - for file entries inside IPath directory containers<br>
+ * {@link IPDOMSearchContentProvider#URI_CONTAINER} - container for URIs
+ *             URI - from IIndexFileLocations not resolvable to the local filesystem, under URI_CONTAINER<br>
+ * @author Doug Schaefer
+ * @author Ed Swartz
+ *
+ */
+public interface IPDOMSearchContentProvider {
+
+       /** This node encapsulates results in the search tree for results not resolvable to files. */
+       static Object URI_CONTAINER = new Object();
+       
+       /** This node appears in the tree when the indexer was running during the search
+        * to warn the user that the results are suspicious.  
+        * <p>
+        * TODO: it would be better if IIndexManager told us which projects specifically
+        * were being indexed at the time, so we could annotate per-project whose results are suspicious
+        * (which may be none at all for a given search).  
+        * See the handling of {@link PDOMSearchResult#wasIndexerBusy()}.
+        */
+       static IStatus INCOMPLETE_RESULTS_NODE = 
+               new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID,
+                               CSearchMessages.CSearchMessages_IndexRunningIncompleteWarning);
+
+       public void elementsChanged(Object[] elements);
+
+       public void clear();
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LRUWorkingSets.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LRUWorkingSets.java
new file mode 100644 (file)
index 0000000..0c99a91
--- /dev/null
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+/*
+ * Created on Aug 30, 2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.eclipse.cdt.internal.ui.search;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.PlatformUI;
+
+
+
+/**
+ * @author bgheorgh
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class LRUWorkingSets {
+       
+       ArrayList<IWorkingSet[]> workingSetsCache = null;
+       int size=0;
+       
+       public LRUWorkingSets(int size){
+               workingSetsCache = new ArrayList<IWorkingSet[]>(size);
+               this.size = size;
+       }
+       
+       public void add(IWorkingSet[] workingSet){
+               cleanUpCache();
+               //See if this working set has been previously added to the 
+               IWorkingSet[] existingWorkingSets= find(workingSetsCache, workingSet);
+               if (existingWorkingSets != null)
+                       workingSetsCache.remove(existingWorkingSets);
+               else if (workingSetsCache.size() == size)
+                       workingSetsCache.remove(size - 1);
+               workingSetsCache.add(0, workingSet);
+       }
+       
+       private IWorkingSet[] find(ArrayList<IWorkingSet[]> list, IWorkingSet[] workingSet) {
+               Set<IWorkingSet> workingSetList= new HashSet<IWorkingSet>(Arrays.asList(workingSet));
+               Iterator<IWorkingSet[]> iter= list.iterator();
+               while (iter.hasNext()) {
+                       IWorkingSet[] lruWorkingSets= iter.next();
+                       Set<IWorkingSet> lruWorkingSetList= new HashSet<IWorkingSet>(Arrays.asList(lruWorkingSets));
+                       if (lruWorkingSetList.equals(workingSetList))
+                               return lruWorkingSets;
+               }
+               return null;
+       }
+
+       private void cleanUpCache(){
+     //Remove any previously deleted entries
+        Iterator<IWorkingSet[]> iter = workingSetsCache.iterator();
+        while (iter.hasNext()){
+               IWorkingSet[] workingSet = iter.next();
+               for (int i= 0; i < workingSet.length; i++) {
+                       if (PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(workingSet[i].getName()) == null) {
+                               workingSetsCache.remove(workingSet);
+                               break;
+                       }
+               }
+        }
+       }
+
+       public Iterator<IWorkingSet[]> iterator() {
+               return workingSetsCache.iterator(); 
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LineSearchElement.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LineSearchElement.java
new file mode 100644 (file)
index 0000000..a1ab642
--- /dev/null
@@ -0,0 +1,293 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Andrey Eremchenko, kamre@ngs.ru - 222495 C/C++ search should show line matches and line numbers 
+ *     Markus Schorn (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.search;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+
+import org.eclipse.cdt.core.index.IIndexFileLocation;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.parser.FileContent;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.parser.scanner.AbstractCharArray;
+import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContent;
+
+/**
+ * Element representing a line with one ore more matches.
+ */
+public class LineSearchElement extends PDOMSearchElement {
+       public static final class Match {
+               private final int fOffset;
+               private final int fLength;
+               private final boolean fIsPolymorphicCall;
+               private final ICElement fEnclosingElement;
+               private final boolean fIsWriteAccess;
+
+               public Match(int offset, int length, boolean isPolymorphicCall, ICElement enclosingElement, boolean isWriteAccess) {
+                       fOffset = offset;
+                       fLength = length;
+                       fIsPolymorphicCall = isPolymorphicCall;
+                       fEnclosingElement = enclosingElement;
+                       fIsWriteAccess = isWriteAccess;
+               }
+
+               public int getOffset() {
+                       return fOffset;
+               }
+
+               public int getLength() {
+                       return fLength;
+               }
+
+               public boolean isPolymorphicCall() {
+                       return fIsPolymorphicCall;
+               }
+               
+               public ICElement getEnclosingElement() {
+                       return fEnclosingElement;
+               }
+
+               public boolean isWriteAccess() {
+                       return fIsWriteAccess;
+               }
+               
+               @Override
+               public boolean equals(Object obj) {
+                       if (!(obj instanceof Match))
+                               return false;
+                       Match m = (Match) obj;
+                       return fOffset == m.fOffset && fLength == m.fLength;
+               }
+
+               @Override
+               public int hashCode() {
+                       return 31 * fOffset + fLength;
+               }
+       }
+
+       private static final class MatchesComparator implements Comparator<Match> {
+               public int compare(Match m1, Match m2) {
+                       int diff= m1.getOffset() - m2.getOffset();
+                       if (diff == 0)
+                               diff= m2.getLength() -m1.getLength();
+                       return diff;
+               }
+       }
+
+       private final int fOffset;
+       private final int fNumber;
+       private final String fContent;
+       private final Match[] fMatches;
+       private final static MatchesComparator MATCHES_COMPARATOR = new MatchesComparator();
+
+       private LineSearchElement(IIndexFileLocation file, Match[] matches, int number, String content,
+                       int offset) {
+               super(file);
+               fMatches = matches;
+               fNumber = number;
+               // Skip whitespace at the beginning.
+               int index = 0;
+               int length = content.length();
+               int firstMatchOffset = matches[0].getOffset();
+               while (offset < firstMatchOffset && length > 0) {
+                       if (!Character.isWhitespace(content.charAt(index)))
+                               break;
+                       index++;
+                       offset++;
+                       length--;
+               }
+               fOffset = offset;
+               fContent = content.substring(index).trim();
+       }
+
+       public int getOffset() {
+               return fOffset;
+       }
+
+       public int getLineNumber() {
+               return fNumber;
+       }
+
+       public String getContent() {
+               return fContent;
+       }
+
+       public Match[] getMatches() {
+               return fMatches;
+       }
+
+       @Override
+       public String toString() {
+               return fNumber + ": " + fContent; //$NON-NLS-1$
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               if (!(obj instanceof LineSearchElement))
+                       return false;
+               LineSearchElement other = (LineSearchElement) obj;
+               return fOffset == other.fOffset && super.equals(obj) && fMatches.equals(other.fMatches);
+       }
+
+       @Override
+       public int hashCode() {
+               return fOffset + 31 * (super.hashCode() + 31 * fMatches.hashCode());
+       }
+
+       public static LineSearchElement[] createElements(IIndexFileLocation fileLocation, Match[] matches) {
+               // sort matches according to their offsets
+               Arrays.sort(matches, MATCHES_COMPARATOR);
+               LineSearchElement[] result = {};
+               
+               // read the content of file
+               FileContent content = FileContent.create(fileLocation);
+               if (content != null) {
+                       AbstractCharArray buf = ((InternalFileContent) content).getSource();
+                       if (buf != null)
+                               result = collectLineElements(buf, matches, fileLocation);
+               }
+               return result;
+       }
+
+       public static LineSearchElement[] createElements(IIndexFileLocation fileLocation, Match[] matches,
+                       IDocument document) {
+               // Sort matches according to their offsets
+               Arrays.sort(matches, MATCHES_COMPARATOR);
+               // Group all matches by lines and create LineSearchElements
+               List<LineSearchElement> result = new ArrayList<LineSearchElement>();
+               List<Match> matchCollector= new ArrayList<Match>();
+               int minOffset = 0;
+               int lineNumber = 0;
+               int lineOffset = 0;
+               int lineLength = 0;
+               int lineEndOffset = 0;
+
+               try {
+                       for (final Match match : matches) {
+                               final int offset= match.getOffset();
+                               if (offset < lineEndOffset) {
+                                       // Match on same line
+                                       if (offset < minOffset) {
+                                               // Match is not overlapped by previous one.
+                                               matchCollector.add(match);
+                                               minOffset= offset + match.getLength();
+                                       }
+                               } else {
+                                       // Match is on a new line
+                                       if (!matchCollector.isEmpty()) {
+                                               // Complete a line
+                                               String content = document.get(lineOffset, lineLength);
+                                               Match[] lineMatches= matchCollector.toArray(new Match[matchCollector.size()]);
+                                               result.add(new LineSearchElement(fileLocation, lineMatches, lineNumber + 1, content, lineOffset));
+                                               matchCollector.clear();
+                                       }
+                                       // Setup next line
+                                       lineNumber = document.getLineOfOffset(offset);
+                                       lineOffset = document.getLineOffset(lineNumber);
+                                       lineLength = document.getLineLength(lineNumber);
+                                       lineEndOffset = lineOffset + lineLength;
+                                       matchCollector.add(match);
+                               } 
+                       }
+                       if (!matchCollector.isEmpty()) {
+                               // Complete a line
+                               String content = document.get(lineOffset, lineLength);
+                               Match[] lineMatches= matchCollector.toArray(new Match[matchCollector.size()]);
+                               result.add(new LineSearchElement(fileLocation, lineMatches, lineNumber + 1, content, lineOffset));
+                               matchCollector.clear();
+                       }
+               } catch (BadLocationException e) {
+                       CUIPlugin.log(e);
+               }
+               return result.toArray(new LineSearchElement[result.size()]);
+       }
+
+       private static LineSearchElement[] collectLineElements(AbstractCharArray buf, Match[] matches,
+                       IIndexFileLocation fileLocation) {
+               List<LineSearchElement> result = new ArrayList<LineSearchElement>();
+               List<Match> matchCollector= new ArrayList<Match>();
+
+               boolean skipLF = false;
+               int lineNumber = 1;
+               int lineOffset = 0;
+               int i = 0;
+               Match match= matches[i];
+               int matchOffset = match.getOffset();
+               for (int pos = 0; buf.isValidOffset(pos); pos++) {
+                       if (matchOffset <= pos && match != null) {
+                               // We are on the line of the match, store it.
+                               matchCollector.add(match);
+                               final int minOffset= matchOffset + match.getLength();
+                               match= null;
+                               matchOffset= Integer.MAX_VALUE;
+                               for(i= i + 1; i < matches.length; i++) {
+                                       // Advance to next match that is not overlapped
+                                       final Match nextMatch= matches[i];
+                                       final int nextOffset= nextMatch.getOffset();
+                                       if (nextOffset >= minOffset) {
+                                               match= nextMatch;
+                                               matchOffset= nextOffset;
+                                               break;
+                                       }
+                               }
+                       }
+                               
+                       char c = buf.get(pos);
+                       // consider '\n' and '\r'
+                       if (skipLF) {
+                               skipLF = false;
+                               if (c == '\n') {
+                                       lineOffset = pos + 1;
+                                       continue;
+                               }
+                       }
+                       if (c == '\n' || c == '\r') {
+                               // Create new LineElement for collected matches on this line
+                               if (!matchCollector.isEmpty()) {
+                                       int lineLength = pos - lineOffset;
+                                       Match[] lineMatches= matchCollector.toArray(new Match[matchCollector.size()]);
+                                       char[] lineChars= new char[lineLength];
+                                       buf.arraycopy(lineOffset, lineChars, 0, lineLength);
+                                       String lineContent = new String(lineChars);
+                                       result.add(new LineSearchElement(fileLocation, lineMatches, lineNumber, lineContent,
+                                                       lineOffset));
+                                       matchCollector.clear();
+                                       if (match == null)
+                                               break;
+                               }
+                               lineNumber++;
+                               lineOffset = pos + 1;
+                               if (c == '\r')
+                                       skipLF = true;
+                               continue;
+                       }
+               }
+               // Create new LineElement for  matches on the last line
+               if (!matchCollector.isEmpty()) {
+                       int lineLength = buf.getLength() - lineOffset;
+                       Match[] lineMatches= matchCollector.toArray(new Match[matchCollector.size()]);
+                       char[] lineChars= new char[lineLength];
+                       buf.arraycopy(lineOffset, lineChars, 0, lineLength);
+                       String lineContent = new String(lineChars);
+                       result.add(new LineSearchElement(fileLocation, lineMatches, lineNumber, lineContent,
+                                       lineOffset));
+               }
+               return result.toArray(new LineSearchElement[result.size()]);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LinkedNamesFinder.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/LinkedNamesFinder.java
new file mode 100644 (file)
index 0000000..0bbfe23
--- /dev/null
@@ -0,0 +1,329 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Google, Inc and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *        Sergey Prigogin (Google) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.search;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTComment;
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorElseStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorEndifStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIfStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIfdefStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIfndefStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorUndefStatement;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IMacroBinding;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+
+import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
+
+/**
+ * Finds locations of linked names. Used by Rename in File and Rename in Workspace.
+ */
+public class LinkedNamesFinder {
+       private static final IRegion[] EMPTY_LOCATIONS_ARRAY = new IRegion[0];
+
+       private LinkedNamesFinder() {
+               super();
+       }
+
+       public static IRegion[] findByName(IASTTranslationUnit root, IASTName name) {
+               IBinding target = name.resolveBinding();
+               if (target == null) {
+                       return EMPTY_LOCATIONS_ARRAY;
+               }
+               BindingFinder bindingFinder = new BindingFinder(root);
+               bindingFinder.find(target);
+               return bindingFinder.getLocations();
+       }
+
+       private static class BindingFinder {
+               private final IASTTranslationUnit root;
+               private final List<IRegion> locations;
+
+               public BindingFinder(IASTTranslationUnit root) {
+                       this.root = root;
+                       locations = new ArrayList<IRegion>();
+               }
+
+               public void find(IBinding target) {
+                       if (target instanceof IMacroBinding) {
+                               findMacro((IMacroBinding) target);
+                               return;
+                       }
+
+                       if (target instanceof ICPPConstructor ||
+                                       target instanceof ICPPMethod && ((ICPPMethod) target).isDestructor()) {
+                               target = ((ICPPMethod) target).getClassOwner();
+                       }
+
+                       findBinding(target);
+                       if (target instanceof ICPPClassType) {
+                               ICPPConstructor[] constructors = ((ICPPClassType) target).getConstructors();
+                               for (ICPPConstructor ctor : constructors) {
+                                       if (!ctor.isImplicit()) {
+                                               findBinding(ctor);
+                                       }
+                               }
+                               ICPPMethod[] methods = ((ICPPClassType) target).getDeclaredMethods();
+                               for (ICPPMethod method : methods) {
+                                       if (method.isDestructor()) {
+                                               findBinding(method);
+                                       }
+                               }
+                       } else if (target instanceof ICPPMethod) {
+                       ICPPMethod method= (ICPPMethod) target;
+                       for (ICPPMethod m : ClassTypeHelper.findOverridden(method)) {
+                                       findBinding(m);
+                               }
+                       try {
+                                       for (ICPPMethod m : findOverridersInAST(method)) {
+                                               findBinding(m);
+                                       }
+                               } catch (DOMException e) {
+                                       // Ignore.
+                               }
+                       }
+               }
+
+               private ICPPMethod[] findOverridersInAST(ICPPMethod method) throws DOMException {
+                       if (!ClassTypeHelper.isVirtual(method))
+                               return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
+
+                       final ICPPClassType ownerClass = method.getClassOwner();
+                       if (ownerClass  == null) 
+                               return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
+
+                       SubclassFinder subclassFinder = new SubclassFinder(ownerClass);
+                       root.accept(subclassFinder);
+                       return ClassTypeHelper.findOverriders(subclassFinder.getSubclasses(), method);
+               }
+
+               public IRegion[] getLocations() {
+                       if (locations.isEmpty()) {
+                               return EMPTY_LOCATIONS_ARRAY;
+                       }
+                       return locations.toArray(new IRegion[locations.size()]);
+               }
+
+               private void findBinding(IBinding target) {
+                       IASTName[] names= root.getDeclarationsInAST(target);
+                       for (IASTName candidate : names) {
+                               if (candidate.isPartOfTranslationUnitFile()) {
+                                       addLocation(candidate);
+                               }
+                       }
+                       names= root.getReferences(target);
+                       for (IASTName candidate : names) {
+                               if (candidate.isPartOfTranslationUnitFile()) {
+                                       addLocation(candidate);
+                               }
+                       }
+               }
+
+               private void addLocation(IASTName name) {
+                       IBinding binding = name.resolveBinding();
+                       if (binding != null) {
+                               if (name instanceof ICPPASTTemplateId) {
+                                       name= ((ICPPASTTemplateId) name).getTemplateName();
+                               }
+                               IASTFileLocation fileLocation= name.getImageLocation();
+                               if (fileLocation == null || !root.getFilePath().equals(fileLocation.getFileName())) {
+                                       fileLocation= name.getFileLocation();
+                               }
+                               if (fileLocation != null) {
+                                       int offset= fileLocation.getNodeOffset();
+                                       int length= fileLocation.getNodeLength();
+                                       if (binding instanceof ICPPMethod && ((ICPPMethod) binding).isDestructor()) {
+                                               // Skip tilde.
+                                               offset++;
+                                               length--;
+                                       }
+                                       if (offset >= 0 && length > 0) {
+                                               locations.add(new Region(offset, length));
+                                       }
+                               }
+                       }
+               }
+
+               /**
+                * Adds all occurrences of a macro name to the list of locations. Macro occurrences
+                * may belong to multiple macro bindings with the same name. Macro names are also
+                * looked for in the comments of #else and #endif statements.
+                * Comments of #else and #endif statements related to #ifdef or #ifndef are searched
+                * for the macro name referenced by the #if[n]def. 
+                * @param target a binding representing a macro. 
+                */
+               private void findMacro(IMacroBinding target) {
+                       findBinding(target);
+                       char[] nameChars = target.getNameCharArray();
+                       List<IASTName> ifdefNameStack = new ArrayList<IASTName>();
+                       IASTPreprocessorStatement[] statements = root.getAllPreprocessorStatements();
+                       for (IASTPreprocessorStatement statement : statements) {
+                               if (!statement.isPartOfTranslationUnitFile()) {
+                                       continue;
+                               }
+                               IASTName macroName = null;
+                               boolean ifStatement = false;
+                               if (statement instanceof IASTPreprocessorIfdefStatement) {
+                                       macroName = ((IASTPreprocessorIfdefStatement) statement).getMacroReference();
+                                       ifStatement = true;
+                               } else if (statement instanceof IASTPreprocessorIfndefStatement) {
+                                       macroName = ((IASTPreprocessorIfndefStatement) statement).getMacroReference();
+                                       ifStatement = true;
+                               } else if (statement instanceof IASTPreprocessorMacroDefinition) {
+                                       macroName = ((IASTPreprocessorMacroDefinition) statement).getName();
+                               } else if (statement instanceof IASTPreprocessorUndefStatement) {
+                                       macroName = ((IASTPreprocessorUndefStatement) statement).getMacroName();
+                               } else if (statement instanceof IASTPreprocessorIfStatement) {
+                                       ifStatement = true;
+                               } else if (statement instanceof IASTPreprocessorEndifStatement) {
+                                       if (!ifdefNameStack.isEmpty())
+                                               if (ifdefNameStack.remove(ifdefNameStack.size() - 1) != null) {
+                                                       findInStatementComment(nameChars, statement);
+                                               }
+                               } else if (statement instanceof IASTPreprocessorElseStatement) {
+                                       if (!ifdefNameStack.isEmpty())
+                                               if (ifdefNameStack.get(ifdefNameStack.size() - 1) != null) {
+                                                       findInStatementComment(nameChars, statement);
+                                               }
+                               }
+                               if (macroName != null) {
+                                       if (Arrays.equals(nameChars, macroName.getSimpleID())) {
+                                               IBinding binding = macroName.resolveBinding();
+                                               if (!target.equals(binding)) {
+                                                       findBinding(binding);
+                                               }
+                                       } else {
+                                               macroName = null;
+                                       }
+                               }
+                               if (ifStatement) {
+                                       ifdefNameStack.add(macroName);
+                               }
+                       }
+               }
+
+               /**
+                * Finds locations of a given name in the comment of a preprocessor statement.
+                */
+               private void findInStatementComment(char[] nameChars, IASTPreprocessorStatement statement) {
+                       IASTFileLocation location = statement.getFileLocation();
+                       IASTComment comment = findComment(location.getNodeOffset() + location.getNodeLength());
+                       if (comment != null &&
+                                       comment.getFileLocation().getStartingLineNumber() == location.getStartingLineNumber()) {
+                               findInComment(nameChars, comment);
+                       }
+               }
+
+               /**
+                * Returns the first comment after the given offset.
+                * @param startOffset a file offset.
+                * @return a comment or <code>null</code>, if there are no comments after the offset.
+                */
+               private IASTComment findComment(int startOffset) {
+                       IASTComment[] comments = ((ASTTranslationUnit) root).getComments();
+                       int low = 0;
+                       int high = comments.length;
+                       while (low < high) {
+                               int mid = (low + high) / 2;
+                               int offset = comments[mid].getFileLocation().getNodeOffset();
+                               if (offset < startOffset) {
+                                       low = mid + 1;
+                               } else {
+                                       high = mid;
+                                       if (offset == startOffset) {
+                                               break;
+                                       }
+                               }
+                       }
+                       return high < comments.length ? comments[high] : null;
+               }
+
+               /**
+                * Adds all occurrences of a name in a comment to the list of locations.
+                */
+               private void findInComment(char[] name, IASTComment comment) {
+                       char[] text = comment.getComment();
+               int j = 0;
+               // First two characters are either /* or //
+               for (int i = 2; i <= text.length - name.length + j; i++) {
+                       char c = text[i];
+                               if (!Character.isJavaIdentifierPart(c)) {
+                                       j = 0;
+                               } else if (j >= 0 && j < name.length && name[j] == c) {
+                                       j++;
+                                       if (j == name.length &&
+                                                       (i + 1 == text.length || !Character.isJavaIdentifierPart(text[i + 1]))) {
+                                               int offset = comment.getFileLocation().getNodeOffset() + i + 1 - name.length;
+                                               locations.add(new Region(offset, name.length));
+                                               j = 0;
+                                       }
+                               } else {
+                                       j = -1;
+                               }
+               }
+               }
+       }
+
+       /**
+        * Finds subclasses of the given class referenced by the AST.
+        */
+       static class SubclassFinder extends ASTVisitor {
+               {
+                       shouldVisitNames= true;
+               }
+
+               private final ICPPClassType baseClass;
+               private Set<ICPPClassType> subclasses = new HashSet<ICPPClassType>();
+               private Set<IBinding> seenClasses = new HashSet<IBinding>();
+               
+               SubclassFinder(ICPPClassType baseClass) {
+                       this.baseClass = baseClass;
+               }
+
+               @Override
+               public int visit(IASTName name) {
+                       IBinding binding = name.resolveBinding();
+                       if (binding instanceof ICPPClassType) {
+                               if (seenClasses.add(binding)) {
+                                       ICPPClassType candidate = (ICPPClassType) binding;
+                                       if (ClassTypeHelper.isSubclass(candidate, baseClass)) {
+                                               subclasses.add(candidate);
+                                       }
+                               }
+                       }
+                       return PROCESS_CONTINUE;
+               }
+
+               public ICPPClassType[] getSubclasses() {
+                       return subclasses.toArray(new ICPPClassType[subclasses.size()]);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OccurrencesFinder.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OccurrencesFinder.java
new file mode 100644 (file)
index 0000000..a93b70a
--- /dev/null
@@ -0,0 +1,195 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.search;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IVariable;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
+import org.eclipse.cdt.core.parser.Keywords;
+import org.eclipse.cdt.core.parser.util.CharArrayUtils;
+
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
+
+import org.eclipse.cdt.internal.ui.util.Messages;
+
+public class OccurrencesFinder implements IOccurrencesFinder {
+       
+       public static final String ID= "OccurrencesFinder"; //$NON-NLS-1$
+       
+       /**
+        * If set, don't search for implicit references.
+        */
+       public static final int OPTION_EXCLUDE_IMPLICIT_REFERENCES = 1;
+       
+       private IASTTranslationUnit fRoot;
+       private IASTName fSelectedNode;
+       private IBinding fTarget;
+
+       private List<OccurrenceLocation> fResult;
+
+       private String fReadDescription;
+       private String fWriteDescription;
+       
+       private int fOptions;
+       
+       public OccurrencesFinder() {
+               super();
+       }
+       
+       public String initialize(IASTTranslationUnit root, IASTNode node) {
+               if (!(node instanceof IASTName))
+                       return CSearchMessages.OccurrencesFinder_no_element; 
+               fRoot= root;
+               fSelectedNode= (IASTName)node;
+               fTarget= fSelectedNode.resolveBinding();
+               if (fTarget == null)
+                       return CSearchMessages.OccurrencesFinder_no_binding; 
+               
+               fReadDescription= Messages.format(CSearchMessages.OccurrencesFinder_occurrence_description, fTarget.getName());
+               fWriteDescription= Messages.format(CSearchMessages.OccurrencesFinder_occurrence_write_description, fTarget.getName());
+               return null;
+       }
+       
+       /**
+        * Specify search options.
+        * 
+        * @param options
+        */
+       public void setOptions(int options) {
+               fOptions = options;
+       }
+       
+       private void performSearch() {
+               if (fResult == null) {
+                       fResult= new ArrayList<OccurrenceLocation>();
+                       IASTName[] names= fRoot.getDeclarationsInAST(fTarget);
+                       for (IASTName candidate : names) {
+                               if (candidate.isPartOfTranslationUnitFile()) {
+                                       addUsage(candidate, candidate.resolveBinding());
+                               }
+                       }
+                       names= fRoot.getReferences(fTarget);
+                       for (IASTName candidate : names) {
+                               if (candidate.isPartOfTranslationUnitFile()) {
+                                       addUsage(candidate, candidate.resolveBinding());
+                               }
+                       }
+                       if (needImplicitReferences() && canHaveImplicitReference(fTarget)) {
+                               names= CPPVisitor.getImplicitReferences(fRoot, fTarget);
+                               for (IASTName candidate : names) {
+                                       if (candidate.isPartOfTranslationUnitFile()) {
+                                               addUsage(candidate, candidate.resolveBinding());
+                                       }
+                               }
+                       }
+               }
+       }
+       
+       private boolean needImplicitReferences() {
+               return (fOptions & OPTION_EXCLUDE_IMPLICIT_REFERENCES) == 0;
+       }
+
+       private boolean canHaveImplicitReference(IBinding binding) {
+               final char[] op = Keywords.cOPERATOR;
+               final char[] nameCharArray = binding.getNameCharArray();
+               if (nameCharArray.length > 0) {
+                       if (nameCharArray[0] == '~') {
+                               return true;
+                       }
+                       if (CharArrayUtils.equals(nameCharArray, 0, op.length, op)) {
+                               return true;
+                       }
+               }
+               if (binding instanceof ICPPConstructor)
+                       return true;
+               
+               return false;
+       }
+
+       public OccurrenceLocation[] getOccurrences() {
+               performSearch();
+               if (fResult.isEmpty())
+                       return null;
+               return fResult.toArray(new OccurrenceLocation[fResult.size()]);
+       }
+
+       public IASTTranslationUnit getASTRoot() {
+               return fRoot;
+       }
+               
+       /*
+        * @see org.eclipse.cdt.internal.ui.search.IOccurrencesFinder#getJobLabel()
+        */
+       public String getJobLabel() {
+               return CSearchMessages.OccurrencesFinder_searchfor ; 
+       }
+       
+       public String getElementName() {
+               if (fSelectedNode != null) {
+                       return new String(fSelectedNode.toCharArray());
+               }
+               return null;
+       }
+       
+       public String getUnformattedPluralLabel() {
+               return CSearchMessages.OccurrencesFinder_label_plural;
+       }
+       
+       public String getUnformattedSingularLabel() {
+               return CSearchMessages.OccurrencesFinder_label_singular;
+       }
+       
+       private boolean addUsage(IASTName node, IBinding binding) {
+               if (binding != null /* && Bindings.equals(binding, fTarget) */) {
+                       if (node instanceof ICPPASTTemplateId) {
+                               node= ((ICPPASTTemplateId) node).getTemplateName();
+                       }
+                       IASTFileLocation fileLocation= node.getImageLocation();
+                       if (fileLocation == null || !fRoot.getFilePath().equals(fileLocation.getFileName())) {
+                               fileLocation= node.getFileLocation();
+                       }
+                       if (fileLocation != null) {
+                               final int offset= fileLocation.getNodeOffset();
+                               final int length= fileLocation.getNodeLength();
+                               if (offset >= 0 && length > 0) {
+                                       if (binding instanceof IVariable) {
+                                               final boolean isWriteOccurrence = CSearchUtil.isWriteOccurrence(node, binding);
+                                               int flag = isWriteOccurrence ? F_WRITE_OCCURRENCE : F_READ_OCCURRENCE;
+                                               String description = isWriteOccurrence ? fWriteDescription : fReadDescription;
+                                               fResult.add(new OccurrenceLocation(offset, length, flag, description));
+                                       }
+                                       else {
+                                               fResult.add(new OccurrenceLocation(offset, length, F_READ_OCCURRENCE, fWriteDescription));
+                                       }
+                               }
+                       }
+                       return true;
+               }
+               return false;
+       }
+
+       public int getSearchKind() {
+               return K_OCCURRENCE;
+       }
+       
+       public String getID() {
+               return ID;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OpenCSearchPageAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OpenCSearchPageAction.java
new file mode 100644 (file)
index 0000000..457450d
--- /dev/null
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*
+ * Created on Jul 11, 2003
+ */
+package org.eclipse.cdt.internal.ui.search;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.search.ui.NewSearchUI;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+
+/**
+ * @author bgheorgh
+ */
+public class OpenCSearchPageAction implements IWorkbenchWindowActionDelegate {
+
+       private IWorkbenchWindow fWindow;
+       
+       public OpenCSearchPageAction() {
+               super();
+               // TODO Auto-generated constructor stub
+       }
+
+       public void init(IWorkbenchWindow window) {
+               fWindow= window;
+       }
+
+       public void run(IAction action) {
+               if (fWindow == null || fWindow.getActivePage() == null) {
+                       beep();
+                       return;
+               }
+               NewSearchUI.openSearchDialog(fWindow, PDOMSearchPage.EXTENSION_ID);
+       }
+
+       public void selectionChanged(IAction action, ISelection selection) {
+               // do nothing since the action isn't selection dependent.
+       }
+
+       public void dispose() {
+               fWindow= null;
+       }
+
+       protected void beep() {
+               Shell shell= CUIPlugin.getActiveWorkbenchShell();
+               if (shell != null && shell.getDisplay() != null)
+                       shell.getDisplay().beep();
+       }       
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchElement.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchElement.java
new file mode 100644 (file)
index 0000000..b45ce53
--- /dev/null
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    QNX - Initial API and implementation
+ *    Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.search;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Path;
+
+import org.eclipse.cdt.core.index.IIndexFileLocation;
+
+/**
+ * Element class used to group matches.
+ *  
+ * @author Doug Schaefer
+ */
+public class PDOMSearchElement implements IAdaptable {
+
+       private final IIndexFileLocation location;
+       
+       public PDOMSearchElement(IIndexFileLocation loc) {
+               this.location= loc;
+       }
+       
+       @Override
+       public int hashCode() {
+               return location.hashCode();
+       }
+       
+       @Override
+       public boolean equals(Object obj) {
+               if (!(obj instanceof PDOMSearchElement))
+                       return false;
+               PDOMSearchElement other = (PDOMSearchElement)obj;
+               return location.equals(other.location);
+       }
+
+       final IIndexFileLocation getLocation() {
+               return location;
+       }
+       
+       @SuppressWarnings({ "unchecked", "rawtypes" })
+       public Object getAdapter(Class adapterType) {
+               if (adapterType.isAssignableFrom(IFile.class)) {
+                       String fullPath= location.getFullPath();
+                       if (fullPath != null) {
+                               return ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(fullPath));
+                       }
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchElementQuery.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchElementQuery.java
new file mode 100644 (file)
index 0000000..70a19c5
--- /dev/null
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX - Initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.search;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ISourceReference;
+
+import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
+
+/**
+ * @author Doug Schaefer
+ */
+public class PDOMSearchElementQuery extends PDOMSearchQuery {
+
+       private ISourceReference element;
+       private String label;
+       
+       public PDOMSearchElementQuery(ICElement[] scope, ISourceReference element, int flags) {
+               super(scope, flags | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
+               this.element = element;
+               this.label= (element instanceof ICElement) ?
+                               ((ICElement) element).getElementName() : CSearchMessages.PDOMSearchElementQuery_something;
+       }
+
+       @Override
+       public IStatus runWithIndex(IIndex index, IProgressMonitor monitor) throws OperationCanceledException {
+               try {
+                       if (element instanceof ICElement) {
+                               IBinding binding= IndexUI.elementToBinding(index, (ICElement) element);
+                               if (binding != null) {
+                                       label= labelForBinding(index, binding, label);
+                                       createMatches(index, binding);
+                               }
+                       }
+                       return Status.OK_STATUS;
+               } catch (CoreException e) {
+                       return e.getStatus();
+               }
+       }
+
+       @Override
+       public String getResultLabel(int numMatches) {
+               return getResultLabel(label, numMatches);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchLabelProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchLabelProvider.java
new file mode 100644 (file)
index 0000000..a1a1aad
--- /dev/null
@@ -0,0 +1,178 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Markus Schorn - initial API and implementation
+ *     Ed Swartz (Nokia)
+ *     Andrey Eremchenko (LEDAS)
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.search;
+
+import java.net.URI;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.jface.viewers.StyledString.Styler;
+import org.eclipse.search.ui.text.AbstractTextSearchResult;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.core.index.IIndexFileLocation;
+import org.eclipse.cdt.core.index.IndexLocationFactory;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoLabelProvider;
+
+import org.eclipse.cdt.internal.core.dom.parser.ASTProblem;
+import org.eclipse.cdt.internal.core.model.TranslationUnit;
+
+import org.eclipse.cdt.internal.ui.search.LineSearchElement.Match;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.ColoringLabelProvider;
+
+/**
+ * The content in the tree and list views may be either:
+ * <p>
+ * IStatus - warnings or errors from the search<br>
+ * ICElement - for C/C++ elements, including TUs, folders, projects<br>
+ * IPath - directory container, full path<br>
+ *             IIndexFileLocation - for file entries inside IPath directory containers<br>
+ * {@link IPDOMSearchContentProvider#URI_CONTAINER} - container for URIs<br>
+ *             URI - for IIndexFileLocations not resolvable to the local filesystem, under URI_CONTAINER<br>
+ * @author Doug Schaefer
+ * @author Ed Swartz
+ *
+ */
+public class PDOMSearchLabelProvider extends LabelProvider implements IStyledLabelProvider {
+
+       protected final PDOMSearchViewPage fPage;
+       private final TypeInfoLabelProvider fTypeInfoLabelProvider;
+       private final CUILabelProvider fCElementLabelProvider;
+       
+       public PDOMSearchLabelProvider(PDOMSearchViewPage page) {
+               fTypeInfoLabelProvider= new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_FULLY_QUALIFIED | TypeInfoLabelProvider.SHOW_PARAMETERS);
+               fCElementLabelProvider= new CUILabelProvider(0, CElementImageProvider.SMALL_ICONS);
+               fPage= page;
+       }
+       
+       @Override
+       public Image getImage(Object element) {
+               if (element instanceof LineSearchElement) {
+                       LineSearchElement lineSearchElement = (LineSearchElement) element;
+                       ICElement enclosingElement = lineSearchElement.getMatches()[0].getEnclosingElement();
+                       if (!fPage.isShowEnclosingDefinitions() || enclosingElement == null)
+                               return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_SEARCH_LINE);
+                       element = enclosingElement;
+               }
+               
+               if (element instanceof TypeInfoSearchElement)
+                       return fTypeInfoLabelProvider.getImage(((TypeInfoSearchElement)element).getTypeInfo());
+
+               if (element instanceof ProblemSearchElement) {
+                       return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_REFACTORING_WARNING);
+               }
+               
+               if (element instanceof IIndexFileLocation
+                               || element instanceof URI) {
+                       return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDE);
+               }
+               
+               if (element == IPDOMSearchContentProvider.URI_CONTAINER) {
+                       // TODO: perhaps a better icon?
+                       return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_CONTAINER);
+               }
+
+               if (element instanceof IPath) {
+                       return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER);
+               }
+               
+               if (element instanceof IStatus) {
+                       IStatus status = (IStatus) element;
+                       ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
+                       switch (status.getSeverity()) {
+                               case IStatus.WARNING:
+                                       return sharedImages.getImage(ISharedImages.IMG_OBJS_WARN_TSK);
+                               case IStatus.ERROR:
+                                       return sharedImages.getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
+                               default:
+                                       return sharedImages.getImage(ISharedImages.IMG_OBJS_INFO_TSK);
+                       }
+               }
+               
+               return fCElementLabelProvider.getImage(element);
+       }
+
+       @Override
+       public String getText(Object element) {
+               if (element instanceof LineSearchElement) {
+                       return element.toString();
+               }
+
+               if (element instanceof TypeInfoSearchElement) {
+                       return fTypeInfoLabelProvider.getText(((TypeInfoSearchElement)element).getTypeInfo());
+               }
+               else if (element instanceof ProblemSearchElement) {
+                       ProblemSearchElement pse= (ProblemSearchElement) element;
+                       return ASTProblem.getMessage(pse.getProblemID(), pse.getDetail()); 
+               }
+               
+               if (element instanceof IPath) {
+                       return ((IPath) element).toString();
+               }
+               
+               if (element instanceof IIndexFileLocation) {
+                       IPath path= IndexLocationFactory.getPath((IIndexFileLocation)element); 
+                       if (path != null) {
+                               // these are categorized into directories already
+                               return path.lastSegment();
+                       }
+               }
+               
+               if (element instanceof URI) {
+                       return ((URI) element).toString();
+               }
+               
+               if (element instanceof IStatus) {
+                       return ((IStatus) element).getMessage();
+               }
+               
+               return fCElementLabelProvider.getText(element);
+       }
+       
+       protected int getMatchCount(Object element) {
+               if (element instanceof TranslationUnit) {
+                       TranslationUnit translationUnit = (TranslationUnit) element;
+                       AbstractTextSearchResult searchResult = fPage.getInput();
+                       if (searchResult instanceof PDOMSearchResult) {
+                               PDOMSearchResult pdomSearchResult = (PDOMSearchResult)searchResult;
+                               return pdomSearchResult.computeContainedMatches(searchResult, translationUnit.getFile()).length;
+                       }
+               }
+               return fPage.getInput().getMatchCount(element);
+       }
+
+       public StyledString getStyledText(Object element) {
+               if (!(element instanceof LineSearchElement))
+                       return new StyledString(getText(element));
+               LineSearchElement lineElement = (LineSearchElement) element;
+               int lineOffset = lineElement.getOffset();
+               String lineContent = lineElement.getContent();
+               StyledString styled = new StyledString(lineContent);
+               for (Match match : lineElement.getMatches()) {
+                       int offset = Math.max(0, match.getOffset() - lineOffset);
+                       int length = Math.min(match.getLength(), lineContent.length() - offset);
+                       Styler style = match.isWriteAccess() ? ColoringLabelProvider.HIGHLIGHT_WRITE_STYLE : ColoringLabelProvider.HIGHLIGHT_STYLE;
+                       styled.setStyle(offset, length, style);
+               }
+               return styled;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchListContentProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchListContentProvider.java
new file mode 100644 (file)
index 0000000..53420cb
--- /dev/null
@@ -0,0 +1,136 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX - Initial API and implementation
+ * Ed Swartz (Nokia)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.search;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+
+import com.ibm.icu.text.MessageFormat;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * @author Doug Schaefer
+ *
+ */
+public class PDOMSearchListContentProvider implements
+               IStructuredContentProvider, IPDOMSearchContentProvider {
+
+       private TableViewer viewer;
+       private PDOMSearchResult result;
+       private final PDOMSearchViewPage fPage;
+
+       PDOMSearchListContentProvider(PDOMSearchViewPage page) {
+               fPage= page;
+       }
+
+       public Object[] getElements(Object inputElement) {
+               Set<String> uncoveredProjects = new HashSet<String>(); 
+               
+               PDOMSearchResult result = (PDOMSearchResult) inputElement;
+               
+               Object[] results = result.getElements();
+               List<Object> resultList = new ArrayList<Object>();
+       
+               // see which projects returned results
+               for (int i = 0; i < results.length; i++) {
+                       if (results[i] instanceof PDOMSearchElement) {
+                               PDOMSearchElement searchElement = (PDOMSearchElement) results[i];
+                               String path = searchElement.getLocation().getFullPath();
+                               if (path != null) {
+                                       uncoveredProjects.add(new Path(path).segment(0));
+                               }
+                               if (fPage.getDisplayedMatchCount(searchElement) > 0) {
+                                       resultList.add(searchElement);
+                               }
+                       }
+               }
+
+               // see if indexer was busy
+               if (result.wasIndexerBusy()) {
+                       resultList.add(IPDOMSearchContentProvider.INCOMPLETE_RESULTS_NODE);
+               }
+
+               // add message for all the projects which have no results
+               ICProject[] projects = ((PDOMSearchQuery)result.getQuery()).getProjects();
+               for (int i = 0; i < projects.length; ++i) {
+                       ICProject project = projects[i];
+                       boolean foundProject = uncoveredProjects.contains(project.getProject().getName());
+                       if (!foundProject) {
+                               if (project.isOpen()) {
+                                       if (!CCorePlugin.getIndexManager().isProjectIndexed(project)) {
+                                               resultList.add(createUnindexedProjectWarningElement(project));
+                                       }
+                               } else {
+                                       resultList.add(createClosedProjectWarningElement(project));
+                               }
+                       }
+               }
+               
+               return resultList.toArray();
+       }
+
+       private Status createUnindexedProjectWarningElement(ICProject project) {
+               return new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID,
+                               MessageFormat.format(
+                                       CSearchMessages.PDOMSearchListContentProvider_IndexerNotEnabledMessageFormat, 
+                                       new Object[] { project.getProject().getName() }));
+       }
+
+       private Status createClosedProjectWarningElement(ICProject project) {
+               return new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID,
+                               MessageFormat.format(
+                                       CSearchMessages.PDOMSearchListContentProvider_ProjectClosedMessageFormat, 
+                                       new Object[] { project.getProject().getName() }));
+       }
+
+       public void dispose() {
+       }
+
+       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+               this.viewer = (TableViewer)viewer;
+               result = (PDOMSearchResult)newInput;
+               viewer.refresh();
+       }
+
+       public void elementsChanged(Object[] elements) {
+               if (result == null)
+                       return;
+               
+               for (int i= 0; i < elements.length; i++) {
+                       if (fPage.getDisplayedMatchCount(elements[i]) > 0) {
+                               if (viewer.testFindItem(elements[i]) != null)
+                                       viewer.refresh(elements[i]);
+                               else
+                                       viewer.add(elements[i]);
+                       } else {
+                               viewer.remove(elements[i]);
+                       }
+               }
+       }
+       
+       public void clear() {
+               viewer.refresh();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchListLabelProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchListLabelProvider.java
new file mode 100644 (file)
index 0000000..82002aa
--- /dev/null
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX - Initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *     Ed Swartz (Nokia)
+ *     Andrey Eremchenko (LEDAS)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.search;
+
+import org.eclipse.jface.viewers.ViewerCell;
+
+import org.eclipse.cdt.core.index.IndexLocationFactory;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.ui.CDTSharedImages;
+
+import org.eclipse.cdt.internal.ui.util.Messages;
+import org.eclipse.cdt.internal.ui.viewsupport.ColoringLabelProvider;
+
+/**
+ * @author Doug Schaefer
+ */
+public class PDOMSearchListLabelProvider extends ColoringLabelProvider {
+       private final PDOMSearchViewPage fPage;
+       private final int fColumnIndex;
+       
+       public PDOMSearchListLabelProvider(PDOMSearchViewPage page, int columnIndex) {
+               super(new PDOMSearchLabelProvider(page));
+               fPage = page;
+               fColumnIndex = columnIndex;
+       }
+       
+       @Override
+       public void update(ViewerCell cell) {
+               Object element = cell.getElement();
+               switch (fColumnIndex) {
+               case PDOMSearchViewPage.LOCATION_COLUMN_INDEX:
+                       if (element instanceof LineSearchElement) {
+                               LineSearchElement lineElement = (LineSearchElement) element;
+                               String location = IndexLocationFactory.getPath(lineElement.getLocation()).toString();
+                               int lineNumber = lineElement.getLineNumber();
+                               cell.setText(Messages.format(CSearchMessages.CSearchResultCollector_location, location, lineNumber));
+                               cell.setImage(CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_SEARCH_LINE));
+                       }
+                       break;
+               case PDOMSearchViewPage.DEFINITION_COLUMN_INDEX:
+                       if (element instanceof LineSearchElement) {
+                               LineSearchElement lineElement = (LineSearchElement) element;
+                               ICElement enclosingElement = lineElement.getMatches()[0].getEnclosingElement();
+                               if (fPage.isShowEnclosingDefinitions() && enclosingElement != null) {
+                                       cell.setText(enclosingElement.getElementName());
+                                       cell.setImage(getImage(element));
+                               } else {
+                                       cell.setText(""); //$NON-NLS-1$
+                               }
+                       }
+                       break;
+               case PDOMSearchViewPage.MATCH_COLUMN_INDEX:
+                       super.update(cell);
+                       cell.setImage(null);
+                       break;
+               default:
+                       cell.setText(""); //$NON-NLS-1$
+                       break;
+               }
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchMatch.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchMatch.java
new file mode 100644 (file)
index 0000000..fe0fa3b
--- /dev/null
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    QNX - Initial API and implementation
+ *    Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.search;
+
+import org.eclipse.search.ui.text.Match;
+
+import org.eclipse.cdt.core.index.IIndexFileLocation;
+
+/**
+ * Base class for search matches found by various index searches. 
+ */
+public class PDOMSearchMatch extends Match {
+
+       private boolean fIsPolymorphicCall;
+
+       public PDOMSearchMatch(PDOMSearchElement elem, int offset, int length) {
+               super(elem, offset, length);
+       }
+
+       IIndexFileLocation getLocation() {
+               return ((PDOMSearchElement)getElement()).getLocation();
+       }
+       
+       @Override
+       public boolean equals(Object obj) {
+               if (obj == this)
+                       return true;
+               if (!(obj instanceof PDOMSearchMatch))
+                       return false;
+               PDOMSearchMatch other = (PDOMSearchMatch)obj;
+               return getElement().equals(other.getElement())
+                       && getOffset() == other.getOffset()
+                       && getLength() == other.getLength();
+       }
+
+       public void setIsPolymorphicCall() {
+               fIsPolymorphicCall= true;
+       }
+       
+       public boolean isPolymorphicCall() {
+               return fIsPolymorphicCall;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPage.java
new file mode 100644 (file)
index 0000000..da02b54
--- /dev/null
@@ -0,0 +1,777 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2011 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Doug Schaefer (QNX) - Initial API and implementation
+ *   Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.search;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.regex.PatternSyntaxException;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.action.IStatusLineManager;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.search.ui.ISearchPage;
+import org.eclipse.search.ui.ISearchPageContainer;
+import org.eclipse.search.ui.NewSearchUI;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.PlatformUI;
+
+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.ISourceReference;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.parser.Keywords;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.util.Messages;
+import org.eclipse.cdt.internal.ui.util.RowLayouter;
+
+/**
+ * @author Doug Schaefer
+ *
+ */
+public class PDOMSearchPage extends DialogPage implements ISearchPage {
+       
+       public static final String EXTENSION_ID = CUIPlugin.PLUGIN_ID + ".pdomSearchPage"; //$NON-NLS-1$
+       
+       //Dialog store id constants
+       private final static String PAGE_NAME = "PDOMSearchPage"; //$NON-NLS-1$
+       private final static String STORE_CASE_SENSITIVE = "caseSensitive"; //$NON-NLS-1$
+       private final static String STORE_PREVIOUS_PATTERNS = "previousPatterns"; //$NON-NLS-1$
+       private final static String STORE_SEARCH_FLAGS = "searchFlags"; //$NON-NLS-1$
+
+       /** Preference key for external marker enablement */
+    public final static String EXTERNALMATCH_ENABLED = "externMatchEnable"; //$NON-NLS-1$
+    /** Preference key for external marker visibilty */
+    public final static String EXTERNALMATCH_VISIBLE = "externMatchVisible"; //$NON-NLS-1$
+
+       private static final String[] searchForText= {
+               CSearchMessages.CSearchPage_searchFor_classStruct, 
+               CSearchMessages.CSearchPage_searchFor_function, 
+               CSearchMessages.CSearchPage_searchFor_variable,         
+               CSearchMessages.CSearchPage_searchFor_union,            
+               CSearchMessages.CSearchPage_searchFor_method,           
+               CSearchMessages.CSearchPage_searchFor_field,            
+               CSearchMessages.CSearchPage_searchFor_enum,             
+               CSearchMessages.CSearchPage_searchFor_enumr,            
+               CSearchMessages.CSearchPage_searchFor_namespace,        
+               CSearchMessages.CSearchPage_searchFor_typedef,  
+               CSearchMessages.CSearchPage_searchFor_macro,    
+               CSearchMessages.CSearchPage_searchFor_any
+       };
+
+       // These must be in the same order as the Text
+       private static final Integer[] searchForData = {
+               new Integer(PDOMSearchPatternQuery.FIND_CLASS_STRUCT),
+               new Integer(PDOMSearchPatternQuery.FIND_FUNCTION),
+               new Integer(PDOMSearchPatternQuery.FIND_VARIABLE),
+               new Integer(PDOMSearchPatternQuery.FIND_UNION),
+               new Integer(PDOMSearchPatternQuery.FIND_METHOD),
+               new Integer(PDOMSearchPatternQuery.FIND_FIELD),
+               new Integer(PDOMSearchPatternQuery.FIND_ENUM),
+               new Integer(PDOMSearchPatternQuery.FIND_ENUMERATOR),
+               new Integer(PDOMSearchPatternQuery.FIND_NAMESPACE),
+               new Integer(PDOMSearchPatternQuery.FIND_TYPEDEF),
+               new Integer(PDOMSearchPatternQuery.FIND_MACRO),
+               new Integer(PDOMSearchPatternQuery.FIND_ALL_TYPES)
+       };
+       
+       // the index of FIND_ALL_TYPES
+       private static final int searchAllButtonIndex = searchForData.length - 1;
+
+       private static String[] limitToText = {
+               CSearchMessages.CSearchPage_limitTo_declarations, 
+               CSearchMessages.CSearchPage_limitTo_definitions, 
+               CSearchMessages.CSearchPage_limitTo_references, 
+               CSearchMessages.CSearchPage_limitTo_allOccurrences
+       };
+
+       // Must be in the same order as the text
+       private static Integer[] limitToData = {
+               new Integer(PDOMSearchQuery.FIND_DECLARATIONS),
+               new Integer(PDOMSearchQuery.FIND_DEFINITIONS),
+               new Integer(PDOMSearchQuery.FIND_REFERENCES),
+               new Integer(PDOMSearchQuery.FIND_ALL_OCCURRENCES),
+       };
+       
+       // The index of FIND_ALL_OCCURANCES
+       private static final int limitToAllButtonIndex = limitToData.length - 1;
+       
+       private Combo patternCombo;
+       private String[] previousPatterns;
+       private Button caseSensitiveButton;
+       
+       private Button[] searchForButtons;
+       private Button[] limitToButtons;
+       
+       private boolean firstTime = true;
+       private IStructuredSelection structuredSelection;
+       private ITextSelection textSelection;
+
+       private ISearchPageContainer pageContainer;
+       
+       private IStatusLineManager fLineManager;
+
+       private static ICProject getProject(String name) {
+               return CoreModel.getDefault().create(ResourcesPlugin.getWorkspace().getRoot().getProject(name));
+       }
+       
+       private ICElement getElement(Object obj) {
+               if (obj instanceof IResource) {
+                       return CoreModel.getDefault().create((IResource)obj);
+               } 
+               if (obj instanceof ICElement) {
+                       ICElement elem= (ICElement) obj;
+                       if (elem instanceof ISourceReference)
+                               return ((ISourceReference) elem).getTranslationUnit();
+                       if (elem instanceof ITranslationUnit || elem instanceof ICContainer || elem instanceof ICProject)
+                               return elem;
+                       
+                       return elem.getCProject();
+               }
+               return null;
+       }
+
+
+       public boolean performAction() {
+           fLineManager.setErrorMessage(null);
+
+           boolean isCaseSensitive = caseSensitiveButton.getSelection();
+
+           // get the pattern and turn it into a regular expression
+           String patternStr = patternCombo.getText();
+
+           // Get search flags
+           int searchFlags = 0;
+           if (searchForButtons[searchAllButtonIndex].getSelection()) {
+               searchFlags |= PDOMSearchPatternQuery.FIND_ALL_TYPES;
+           } else {
+               for (int i = 0; i < searchForButtons.length; ++i) {
+                       if (searchForButtons[i].getSelection())
+                               searchFlags |= ((Integer)searchForButtons[i].getData()).intValue();
+               }
+           }
+           for (int i = 0; i < limitToButtons.length; ++i) {
+               if (limitToButtons[i].getSelection())
+                       searchFlags |= ((Integer) limitToButtons[i].getData()).intValue();
+           }
+           
+               // get the list of elements for the scope
+               Set<ICElement> elements = new HashSet<ICElement>();
+               String scopeDescription = ""; //$NON-NLS-1$
+               switch (getContainer().getSelectedScope()) {
+               case ISearchPageContainer.SELECTED_PROJECTS_SCOPE:
+                       final String[] prjNames = getContainer().getSelectedProjectNames();
+                       scopeDescription= CSearchMessages.ProjectScope;
+                       int ip= 0;
+                       for (String prjName: prjNames) {
+                               ICProject project = getProject(prjName);
+                               if (project != null) {
+                                       elements.add(project);
+                                       switch(ip++) {
+                                       case 0: 
+                                               scopeDescription+= " '" + prjName + "'";  //$NON-NLS-1$//$NON-NLS-2$
+                                               break;
+                                       case 1:
+                                               scopeDescription= scopeDescription + ", '" + prjName + "'"; //$NON-NLS-1$ //$NON-NLS-2$
+                                               break;
+                                       case 2:
+                                               scopeDescription+= ", ..."; //$NON-NLS-1$
+                                               break;
+                                       default:
+                                               break;
+                                       } 
+                               }
+                       }
+                       break;
+               case ISearchPageContainer.SELECTION_SCOPE:
+                       if (structuredSelection != null) {
+                               scopeDescription = CSearchMessages.SelectionScope; 
+                               int ie= 0;
+                               for (Object sel : structuredSelection.toList()) {
+                                       ICElement elem= getElement(sel);
+                                       if (elem != null) {
+                                               elements.add(elem);
+                                               switch(ie++) {
+                                               case 0: 
+                                                       scopeDescription= " '" + elem.toString() + "'";  //$NON-NLS-1$//$NON-NLS-2$
+                                                       break;
+                                               case 1:
+                                                       scopeDescription= scopeDescription + ", '" + elem.toString() + "'"; //$NON-NLS-1$ //$NON-NLS-2$
+                                                       break;
+                                               case 2:
+                                                       scopeDescription+= ", ..."; //$NON-NLS-1$
+                                                       break;
+                                               default:
+                                                       break;
+                                               } 
+                                       }
+                               }
+                               break;
+                       }
+                       break;
+               case ISearchPageContainer.WORKSPACE_SCOPE:
+                       scopeDescription = CSearchMessages.WorkspaceScope; 
+                       // Don't add anything
+                       break;
+               case ISearchPageContainer.WORKING_SET_SCOPE:
+                       IWorkingSet[] workingSets= getContainer().getSelectedWorkingSets();
+                       scopeDescription = Messages.format(CSearchMessages.WorkingSetScope, CSearchUtil.toString(workingSets)); 
+                       for (int i = 0; i < workingSets.length; ++i) {
+                               IAdaptable[] wsElements = workingSets[i].getElements();
+                               for (int j = 0; j < wsElements.length; ++j) {
+                                       ICElement elem = getElement(wsElements[j]);
+                                       if (elem != null)
+                                               elements.add(elem);
+                               }
+                       }
+                       break;
+               }
+               
+               ICElement[] scope = elements.isEmpty() ?
+                               null : elements.toArray(new ICElement[elements.size()]);
+               
+               try {
+                       PDOMSearchPatternQuery job = new PDOMSearchPatternQuery(scope, scopeDescription, patternStr, 
+                                       isCaseSensitive, searchFlags);
+
+                       NewSearchUI.activateSearchResultView();
+               
+                       NewSearchUI.runQueryInBackground(job);
+               } catch (PatternSyntaxException e) {
+                       fLineManager.setErrorMessage(CSearchMessages.PDOMSearch_query_pattern_error); 
+                       return false;
+               }
+               
+               // Save our settings
+               IDialogSettings settings = getDialogSettings();
+               settings.put(STORE_CASE_SENSITIVE, isCaseSensitive);
+               
+               if (previousPatterns == null) {
+                       previousPatterns = new String[] { patternStr };
+               } else {
+                       // Add only if we don't have it already
+                       boolean addit = true;
+                       for (int i = 0; i < previousPatterns.length; ++i) {
+                               if (patternStr.equals(previousPatterns[i])) {
+                                       addit = false;
+                                       break;
+                               }
+                       }
+                       if (addit) {
+                               // Insert it into the beginning of the list
+                               String[] newPatterns = new String[previousPatterns.length + 1];
+                               System.arraycopy(previousPatterns, 0, newPatterns, 1, previousPatterns.length);
+                               newPatterns[0] = patternStr;
+                               previousPatterns = newPatterns;
+                       }
+               }
+
+               settings.put(STORE_PREVIOUS_PATTERNS, previousPatterns);
+               
+               settings.put(STORE_SEARCH_FLAGS, searchFlags);
+
+               return true;
+       }
+
+       public void createControl(Composite parent) {
+               initializeDialogUnits(parent);
+               
+               GridData gd;
+               Composite  result = new Composite(parent, SWT.NONE);
+               GridLayout layout = new GridLayout(2, false);
+               layout.horizontalSpacing = 10;
+               result.setLayout(layout);
+               result.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               
+               RowLayouter layouter = new RowLayouter(layout.numColumns);
+               gd = new GridData();
+               gd.horizontalAlignment = GridData.FILL;
+               gd.verticalAlignment   = GridData.VERTICAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_FILL;
+       
+               layouter.setDefaultGridData(gd, 0);
+               layouter.setDefaultGridData(gd, 1);
+               layouter.setDefaultSpan();
+
+               layouter.perform(createExpression(result));
+               layouter.perform(createSearchFor(result), createLimitTo(result), -1);
+               
+               createNote(result);
+               
+               setControl(result);
+               
+               fLineManager = getStatusLineManager();
+               
+               Dialog.applyDialogFont(result);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(result, ICHelpContextIds.C_SEARCH_PAGE);      
+       }
+
+       private void createNote(Composite result) {
+               // Create a note that tells the user that this search only processes the active code (not grayed out in editor)
+               GridData gd;
+               String noteTitle= CSearchMessages.CSearchPage_label_note;
+               String noteMessage= CSearchMessages.CSearchPage_label_activeCodeRemark; 
+               Composite noteControl= createNoteComposite(JFaceResources.getDialogFont(), result, noteTitle, noteMessage);
+               gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               gd.horizontalSpan= 2;
+               noteControl.setLayoutData(gd);
+       }
+
+    /**
+     * Creates a composite with a highlighted Note entry and a message text.
+     * This is designed to take up the full width of the page.<br>
+     * This method has been copied from class {@link PreferencePage}
+     * 
+     * @param font the font to use
+     * @param composite the parent composite
+     * @param title the title of the note
+     * @param message the message for the note
+     * @return the composite for the note
+     */
+    protected Composite createNoteComposite(Font font, Composite composite,
+            String title, String message) {
+        Composite messageComposite = new Composite(composite, SWT.NONE);
+        GridLayout messageLayout = new GridLayout();
+        messageLayout.numColumns = 2;
+        messageLayout.marginWidth = 0;
+        messageLayout.marginHeight = 0;
+        messageComposite.setLayout(messageLayout);
+        messageComposite.setLayoutData(new GridData(
+                GridData.HORIZONTAL_ALIGN_FILL));
+        messageComposite.setFont(font);
+
+        final Label noteLabel = new Label(messageComposite, SWT.BOLD);
+        noteLabel.setText(title);
+        noteLabel.setFont(JFaceResources.getFontRegistry().getBold(
+                               JFaceResources.DIALOG_FONT));
+        noteLabel
+                .setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+
+        Label messageLabel = new Label(messageComposite, SWT.WRAP);
+        messageLabel.setText(message);
+        messageLabel.setFont(font);
+        return messageComposite;
+    }
+       
+       
+       private IStatusLineManager getStatusLineManager(){
+               
+               IWorkbenchWindow wbWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+               if (wbWindow != null) {
+                       IWorkbenchPage page= wbWindow.getActivePage();
+                       if (page != null) {
+                                IWorkbenchPartSite workbenchSite = page.getActivePart().getSite();
+                                if (workbenchSite instanceof IViewSite){
+                                       return ((IViewSite) workbenchSite).getActionBars().getStatusLineManager();
+                                } else if (workbenchSite instanceof IEditorSite){
+                                       return ((IEditorSite) workbenchSite).getActionBars().getStatusLineManager();
+                                }
+                       }
+               }
+               
+               return null;
+       }
+
+       private Control createExpression(Composite parent) {
+               Composite  result = new Composite(parent, SWT.NONE);
+               GridLayout layout = new GridLayout(2, false);
+               result.setLayout(layout);
+               GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
+               gd.horizontalSpan = 2;
+               gd.horizontalIndent = 0;
+               result.setLayoutData(gd);
+
+               // Pattern text + info
+               Label label = new Label(result, SWT.LEFT);
+               label.setText(CSearchMessages.CSearchPage_expression_label); 
+               gd = new GridData(GridData.BEGINNING);
+               gd.horizontalSpan = 2;
+               label.setLayoutData(gd);
+
+               // Pattern combo
+               patternCombo = new Combo(result, SWT.SINGLE | SWT.BORDER);
+               patternCombo.addVerifyListener(new VerifyListener() {
+                       public void verifyText(VerifyEvent event) {
+                               final String text = patternCombo.getText();
+                               final char[] newChars= event.text.toCharArray();
+                               final StringBuilder result= new StringBuilder(newChars.length);
+                               boolean relax= prefix(text, event.start, result).contains(Keywords.OPERATOR + " "); //$NON-NLS-1$
+                               for (final char c : newChars) {
+                                       switch (c) {
+                                       case  '_': 
+                                       case ':': // scope operator
+                                       case '?': case '*':  // wild cards
+                                       case '\\': // escaping wild-cards
+                                               result.append(c);
+                                               break;
+                                       case ' ':
+                                               if (prefix(text, event.start, result).endsWith(Keywords.OPERATOR)) {
+                                                       relax= true;
+                                                       result.append(c);
+                                               }
+                                               break;
+                                       case '&': case '|': case '+': case '-':
+                                       case '!': case '=': case '>': case '<':
+                                       case '%': case '^': case '(': case ')':
+                                       case '[': case ']': 
+                                               if (prefix(text, event.start, result).endsWith(Keywords.OPERATOR)) {
+                                                       result.append(' ');
+                                                       relax= true;
+                                               }
+                                               if (relax)
+                                                       result.append(c);
+                                               break;
+                                       case '~':
+                                       default:
+                                               if (Character.isLetterOrDigit(c)) {
+                                                       result.append(c);
+                                               }
+                                               break;
+                                       }
+                                       event.text= result.toString();
+                               }
+                       }
+
+                       private String prefix(String text, int len, StringBuilder rest) {
+                               StringBuilder result= new StringBuilder(len + rest.length());
+                               result.append(text, 0, len);
+                               result.append(rest);
+                               return result.toString();
+                       }
+               });
+               
+               patternCombo.addModifyListener(new ModifyListener() {
+                       public void modifyText(ModifyEvent e) {
+                               setPerformActionEnabled();
+                       }
+               });
+               
+               gd = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
+               gd.horizontalIndent = -gd.horizontalIndent;
+               patternCombo.setLayoutData(gd);
+
+
+               // Ignore case checkbox         
+               caseSensitiveButton= new Button(result, SWT.CHECK);
+               caseSensitiveButton.setText(CSearchMessages.CSearchPage_expression_caseSensitive); 
+               gd= new GridData();
+               caseSensitiveButton.setLayoutData(gd);
+               caseSensitiveButton.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+//                             isCaseSensitive = caseSensitiveButton.getSelection();
+                               setPerformActionEnabled();
+                       }
+               });
+       
+               return result;
+       }
+
+       private Control createLimitTo(Composite parent) {
+               Group result = new Group(parent, SWT.NONE);
+               result.setText(CSearchMessages.CSearchPage_limitTo_label); 
+               GridLayout layout = new GridLayout();
+               layout.numColumns = 2;
+               result.setLayout(layout);
+
+               Listener limitToListener = new Listener() {
+                       public void handleEvent(Event event) {
+                               Button me = (Button)event.widget;
+                               if (me == limitToButtons[limitToAllButtonIndex]) {
+                                       if (me.getSelection()) {
+                                               for (int i = 0; i < limitToButtons.length; ++i) {
+                                                       if (i != limitToAllButtonIndex) {
+                                                               limitToButtons[i].setSelection(true);
+                                                               limitToButtons[i].setEnabled(false);
+                                                       }
+                                               }
+                                       } else {
+                                               for (int i = 0; i < limitToButtons.length; ++i) {
+                                                       if (i != limitToAllButtonIndex) {
+                                                               limitToButtons[i].setSelection(false);
+                                                               limitToButtons[i].setEnabled(true);
+                                                       }
+                                               }
+                                       }
+                               }
+                               setPerformActionEnabled();
+                       }
+               };
+               
+               limitToButtons = new Button[limitToText.length];
+               for(int i = 0; i < limitToText.length; i++){
+                       Button button = new Button(result, SWT.CHECK);
+                       button.setText(limitToText[i]);
+                       button.setData(limitToData[i]);
+                       button.addListener(SWT.Selection, limitToListener);
+                       limitToButtons[i] = button;
+               }
+
+               return result;          
+       }
+       
+       private Control createSearchFor(Composite parent) {
+               Group result= new Group(parent, SWT.NONE);
+               result.setText(CSearchMessages.CSearchPage_searchFor_label); 
+               GridLayout layout= new GridLayout();
+               layout.numColumns= 3;
+               result.setLayout(layout);
+               
+               SelectionAdapter searchForSelectionAdapter = new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent event) {
+                               Button me = (Button)event.widget;
+                               if (me == searchForButtons[searchAllButtonIndex]) {
+                                       if (me.getSelection()) {
+                                               for (int i = 0; i < searchForButtons.length; ++i) {
+                                                       if (i != searchAllButtonIndex) {
+                                                               searchForButtons[i].setSelection(true);
+                                                               searchForButtons[i].setEnabled(false);
+                                                       }
+                                               }
+                                       } else {
+                                               for (int i = 0; i < searchForButtons.length; ++i) {
+                                                       if (i != searchAllButtonIndex) {
+                                                               searchForButtons[i].setSelection(false);
+                                                               searchForButtons[i].setEnabled(true);
+                                                       }
+                                               }
+                                       }
+                               }
+                               setPerformActionEnabled();
+                       }
+               };
+
+               searchForButtons= new Button[searchForText.length];
+               for (int i= 0; i < searchForText.length; i++) {
+                       Button button= new Button(result, SWT.CHECK);
+                       button.setText(searchForText[i]);
+                       button.setData(searchForData[i]);
+                       button.addSelectionListener(searchForSelectionAdapter);
+                       searchForButtons[i]= button;
+               }
+
+               return result;          
+       }
+       
+       public void setContainer(ISearchPageContainer container) {
+               pageContainer = container;
+       }
+       
+       private ISearchPageContainer getContainer() {
+               return pageContainer;
+       }
+       
+       private void setPerformActionEnabled() {
+               // Need a text string to search
+               if (this.patternCombo.getText().length() == 0) {
+                       getContainer().setPerformActionEnabled(false);
+                       return;
+               }
+               
+               // Need a type
+               boolean any = false;
+               for (int i = 0; i < this.searchForButtons.length; ++i) {
+                       if (this.searchForButtons[i].getSelection()) {
+                               any = true;
+                               break;
+                       }
+               }
+               if (!any) {
+                       getContainer().setPerformActionEnabled(false);
+                       return;
+               }
+               
+               // Set limit to
+               any = false;
+
+               for (int i = 0; i < this.limitToButtons.length; ++i) {
+                       if (this.limitToButtons[i].getSelection()) {
+                               any = true;
+                               break;
+                       }
+               }
+               if (!any) {
+                       getContainer().setPerformActionEnabled(false);
+                       return;
+               }
+               getContainer().setPerformActionEnabled(true);
+       }
+       
+       private IDialogSettings getDialogSettings() {
+               IDialogSettings settings = CUIPlugin.getDefault().getDialogSettings();
+               IDialogSettings searchSettings = settings.getSection(PAGE_NAME);
+               if (searchSettings == null)
+                       searchSettings = settings.addNewSection(PAGE_NAME);
+               return searchSettings;
+       }
+
+       @Override
+       public void setVisible(boolean visible) {
+               if (visible) {
+                       if (firstTime) {
+                               firstTime= false;
+                               
+                               IDialogSettings settings = getDialogSettings();
+                               
+                               int searchFlags = PDOMSearchPatternQuery.FIND_ALL_TYPES | PDOMSearchQuery.FIND_ALL_OCCURRENCES;
+                               try {
+                                       searchFlags = settings.getInt(STORE_SEARCH_FLAGS);
+                               } catch (NumberFormatException e) {
+                                       // was uninitialized, assume the defaults
+                               }
+
+                               previousPatterns = settings.getArray(STORE_PREVIOUS_PATTERNS);
+                               if (previousPatterns != null)
+                                       patternCombo.setItems(previousPatterns);
+                               
+                               patternCombo.setVisibleItemCount(15);
+
+                               // Initialize the selection
+                               ISelection selection = getContainer().getSelection();
+                               if (selection instanceof IStructuredSelection) {
+                                       structuredSelection = (IStructuredSelection)selection;
+                                       Object obj = structuredSelection.getFirstElement();
+                                       if (obj instanceof ICElement) {
+                                               ICElement element = (ICElement)obj;
+                                               patternCombo.setText(element.getElementName());
+                                               // Clear the type flags so we can set them correctly for what we have selected
+                                               searchFlags = searchFlags & ~PDOMSearchPatternQuery.FIND_ALL_TYPES;
+                                               switch (element.getElementType()) {
+                                               case ICElement.C_CLASS:
+                                               case ICElement.C_STRUCT:
+                                                       searchFlags |= PDOMSearchPatternQuery.FIND_CLASS_STRUCT;
+                                                       break;
+                                               case ICElement.C_FUNCTION:
+                                                       searchFlags |= PDOMSearchPatternQuery.FIND_FUNCTION;
+                                                       break;
+                                               case ICElement.C_VARIABLE:
+                                                       searchFlags |= PDOMSearchPatternQuery.FIND_VARIABLE;
+                                                       break;
+                                               case ICElement.C_UNION:
+                                                       searchFlags |= PDOMSearchPatternQuery.FIND_UNION;
+                                                       break;
+                                               case ICElement.C_METHOD:
+                                                       searchFlags |= PDOMSearchPatternQuery.FIND_METHOD;
+                                                       break;
+                                               case ICElement.C_FIELD:
+                                                       searchFlags |= PDOMSearchPatternQuery.FIND_FIELD;
+                                                       break;
+                                               case ICElement.C_ENUMERATION:
+                                                       searchFlags |= PDOMSearchPatternQuery.FIND_ENUM;
+                                                       break;
+                                               case ICElement.C_ENUMERATOR:
+                                                       searchFlags |= PDOMSearchPatternQuery.FIND_ENUMERATOR;
+                                                       break;
+                                               case ICElement.C_NAMESPACE:
+                                                       searchFlags |= PDOMSearchPatternQuery.FIND_NAMESPACE;
+                                                       break;
+                                               case ICElement.C_TYPEDEF:
+                                                       searchFlags |= PDOMSearchPatternQuery.FIND_TYPEDEF;
+                                                       break;
+                                               case ICElement.C_MACRO:
+                                                       searchFlags |= PDOMSearchPatternQuery.FIND_MACRO;
+                                                       break;
+                                               default:
+                                                       // Not sure, set to all
+                                                       searchFlags |= PDOMSearchPatternQuery.FIND_ALL_TYPES;
+                                                       patternCombo.setText(""); //$NON-NLS-1$
+                                               }
+                                       }
+                               } else if (selection instanceof ITextSelection) {
+                                       textSelection = (ITextSelection)selection;
+                                       patternCombo.setText(textSelection.getText());
+                                       // TODO it might be good to do a selection parse to ensure that
+                                       // the selection is valid.
+                               }
+                               if (patternCombo.getText().trim().length() == 0 && previousPatterns != null && previousPatterns.length > 0) {
+                                       patternCombo.setText(previousPatterns[0]);
+                               }
+
+                               caseSensitiveButton.setSelection(settings.getBoolean(STORE_CASE_SENSITIVE));
+                               
+                               if ((searchFlags & PDOMSearchPatternQuery.FIND_ALL_TYPES) == PDOMSearchPatternQuery.FIND_ALL_TYPES) {
+                                       searchForButtons[searchAllButtonIndex].setSelection(true);
+                                       for (int i = 0; i < searchForButtons.length; ++i) {
+                                               if (i != searchAllButtonIndex) {
+                                                       searchForButtons[i].setSelection(true);
+                                                       searchForButtons[i].setEnabled(false);
+                                               }
+                                       }
+                               } else {
+                                       searchForButtons[searchAllButtonIndex].setSelection(false);
+                                       for (int i = 0; i < searchForButtons.length; ++i) {
+                                               if (i != searchAllButtonIndex) {
+                                                       searchForButtons[i].setSelection(
+                                                               (searchFlags & ((Integer)searchForButtons[i].getData()).intValue()) != 0);
+                                               }
+                                       }
+                               }
+                               
+                               if ((searchFlags & PDOMSearchQuery.FIND_ALL_OCCURRENCES) == PDOMSearchQuery.FIND_ALL_OCCURRENCES) {
+                                       limitToButtons[limitToAllButtonIndex].setSelection(true);
+                                       for (int i = 0; i < limitToButtons.length; ++i) {
+                                               if (i != limitToAllButtonIndex) {
+                                                       limitToButtons[i].setSelection(true);
+                                                       limitToButtons[i].setEnabled(false);
+                                               }
+                                       }
+                               } else {
+                                       limitToButtons[limitToAllButtonIndex].setSelection(false);
+                                       for (int i = 0; i < limitToButtons.length - 1; ++i) {
+                                               limitToButtons[i].setSelection(
+                                                               (searchFlags & ((Integer)limitToButtons[i].getData()).intValue()) != 0);
+                                       }
+                               }
+                       }
+                       
+                       patternCombo.setFocus();
+                       setPerformActionEnabled();
+               }
+               super.setVisible(visible);
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPatternQuery.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPatternQuery.java
new file mode 100644 (file)
index 0000000..5db40ae
--- /dev/null
@@ -0,0 +1,201 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2011 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX - Initial API and implementation
+ *     IBM Corporation
+ *     Markus Schorn (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.search;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+
+import org.eclipse.cdt.core.dom.ast.ICompositeType;
+import org.eclipse.cdt.core.dom.ast.IEnumeration;
+import org.eclipse.cdt.core.dom.ast.IEnumerator;
+import org.eclipse.cdt.core.dom.ast.IField;
+import org.eclipse.cdt.core.dom.ast.IFunction;
+import org.eclipse.cdt.core.dom.ast.ITypedef;
+import org.eclipse.cdt.core.dom.ast.IVariable;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexBinding;
+import org.eclipse.cdt.core.index.IndexFilter;
+import org.eclipse.cdt.core.model.ICElement;
+
+
+/**
+ * @author Doug Schaefer
+ */
+public class PDOMSearchPatternQuery extends PDOMSearchQuery {
+
+       // First bit after the FINDs in PDOMSearchQuery.
+       public static final int FIND_CLASS_STRUCT = 0x10;
+       public static final int FIND_FUNCTION = 0x20;
+       public static final int FIND_VARIABLE = 0x40;
+       public static final int FIND_UNION = 0x100;
+       public static final int FIND_METHOD = 0x200;
+       public static final int FIND_FIELD = 0x400;
+       public static final int FIND_ENUM = 0x1000;
+       public static final int FIND_ENUMERATOR = 0x2000;
+       public static final int FIND_NAMESPACE = 0x4000;
+       public static final int FIND_TYPEDEF = 0x10000;
+       public static final int FIND_MACRO = 0x20000;
+       public static final int FIND_ALL_TYPES
+               = FIND_CLASS_STRUCT | FIND_FUNCTION | FIND_VARIABLE
+               | FIND_UNION | FIND_METHOD | FIND_FIELD | FIND_ENUM
+               | FIND_ENUMERATOR | FIND_NAMESPACE | FIND_TYPEDEF | FIND_MACRO;
+       
+       private String scopeDesc;
+       private String patternStr;
+       private Pattern[] pattern;
+       
+       public PDOMSearchPatternQuery(
+                       ICElement[] scope,
+                       String scopeDesc,
+                       String patternStr,
+                       boolean isCaseSensitive,
+                       int flags) throws PatternSyntaxException {
+               super(scope, flags);
+               this.scopeDesc = scopeDesc;
+               
+               // remove spurious whitespace, which will make the search fail 100% of the time
+               this.patternStr = patternStr.trim();
+               
+               // Parse the pattern string
+               List<Pattern> patternList = new ArrayList<Pattern>();
+       StringBuffer buff = new StringBuffer();
+       int n = patternStr.length();
+       for (int i = 0; i < n; ++i) {
+               char c = patternStr.charAt(i);
+               switch (c) {
+               case '\\':
+                       if (i+1 < n) {
+                               switch(patternStr.charAt(i+1)) {
+                               case '?':
+                                       buff.append("\\?"); //$NON-NLS-1$
+                                       break;
+                               case '*':
+                                       buff.append("\\*"); //$NON-NLS-1$
+                                       break;
+                               default:
+                                       buff.append('\\');
+                               }
+                       } else {
+                               buff.append('\\');
+                       }
+                       break;
+               case '*':
+                       buff.append(".*"); //$NON-NLS-1$
+                       break;
+               case '?':
+                       buff.append('.');
+                       break;
+               case ':':
+                       if (buff.length() > 0) {
+                               if (isCaseSensitive)
+                                       patternList.add(Pattern.compile(buff.toString()));
+                               else
+                                       patternList.add(Pattern.compile(buff.toString(),Pattern.CASE_INSENSITIVE));
+                               buff = new StringBuffer();
+                       }
+                       break;
+                       case '|': case '+': case '^': case '(': case ')': case '[': case ']': 
+                               buff.append('\\').append(c);
+                               break;
+                       default:
+                       buff.append(c);
+               }
+       }
+       
+       if (buff.length() > 0) {
+                       if (isCaseSensitive)
+                               patternList.add(Pattern.compile(buff.toString()));
+                       else
+                               patternList.add(Pattern.compile(buff.toString(),Pattern.CASE_INSENSITIVE));
+       }
+           
+       pattern = patternList.toArray(new Pattern[patternList.size()]); 
+       }
+       
+       @Override
+       public IStatus runWithIndex(IIndex index, IProgressMonitor monitor) throws OperationCanceledException {
+               try {
+                       IndexFilter filter= IndexFilter.ALL;
+                       IIndexBinding[] bindings = index.findBindings(pattern, false, filter, monitor);
+                       ArrayList<IIndexBinding> matchedBindings = new ArrayList<IIndexBinding>();
+                       for (int i = 0; i < bindings.length; ++i) {
+                               IIndexBinding pdomBinding = bindings[i];
+
+                               // Select the requested bindings  
+                               boolean matches= false;
+                               if ((flags & FIND_ALL_TYPES) == FIND_ALL_TYPES) {
+                                       matches= true;
+                               } else if (pdomBinding instanceof ICompositeType) {
+                                       ICompositeType ct= (ICompositeType) pdomBinding;
+                                       switch (ct.getKey()) {
+                                       case ICompositeType.k_struct:
+                                       case ICPPClassType.k_class:
+                                               matches= (flags & FIND_CLASS_STRUCT) != 0;
+                                               break;
+                                       case ICompositeType.k_union:
+                                               matches= (flags & FIND_UNION) != 0;
+                                               break;
+                                       }
+                               } else if (pdomBinding instanceof IEnumeration) {
+                                       matches= (flags & FIND_ENUM) != 0;
+                               } else if (pdomBinding instanceof IEnumerator) {
+                                       matches= (flags & FIND_ENUMERATOR) != 0;
+                               } else if (pdomBinding instanceof IField) {
+                                       matches= (flags & FIND_FIELD) != 0;
+                               } else if (pdomBinding instanceof ICPPMethod) {
+                                       matches= (flags & FIND_METHOD) != 0;
+                               } else if (pdomBinding instanceof IVariable) {
+                                       matches= (flags & FIND_VARIABLE) != 0;
+                               } else if (pdomBinding instanceof IFunction) {
+                                       matches= (flags & FIND_FUNCTION) != 0;
+                               } else if (pdomBinding instanceof ICPPNamespace || pdomBinding instanceof ICPPNamespaceAlias) {
+                                       matches= (flags & FIND_NAMESPACE) != 0;
+                               } else if (pdomBinding instanceof ITypedef) {
+                                       matches= (flags & FIND_TYPEDEF) != 0;
+                               }
+                               if (matches) {
+                                       matchedBindings.add(pdomBinding);
+                               }
+                       }
+                       if ((flags & FIND_MACRO) != 0 && pattern.length == 1) {
+                               bindings = index.findMacroContainers(pattern[0], filter, monitor);
+                               for (IIndexBinding indexBinding : bindings) {
+                                       matchedBindings.add(indexBinding);
+                               }
+                       }
+                       createMatches(index, matchedBindings.toArray(new IIndexBinding[matchedBindings.size()]));
+               } catch (CoreException e) {
+                       return e.getStatus();
+               }
+               
+               return Status.OK_STATUS;
+       }
+
+       @Override
+       public String getResultLabel(int numMatches) {
+               return getResultLabel(patternStr, scopeDesc, numMatches); 
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchQuery.java
new file mode 100644 (file)
index 0000000..796d54d
--- /dev/null
@@ -0,0 +1,539 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2011 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Doug Schaefer (QNX) - Initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *     Ed Swartz (Nokia)
+ *     Andrey Eremchenko (LEDAS)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.search;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+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.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.search.ui.ISearchQuery;
+import org.eclipse.search.ui.ISearchResult;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IPathEditorInput;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.IPositionConverter;
+import org.eclipse.cdt.core.browser.ITypeReference;
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexFile;
+import org.eclipse.cdt.core.index.IIndexFileLocation;
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.core.index.IndexLocationFactory;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.parser.util.ArrayUtil;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.browser.ASTTypeInfo;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
+import org.eclipse.cdt.internal.core.model.ext.ICElementHandle;
+
+import org.eclipse.cdt.internal.ui.search.LineSearchElement.Match;
+import org.eclipse.cdt.internal.ui.util.Messages;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
+import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
+
+
+public abstract class PDOMSearchQuery implements ISearchQuery {
+       public static final int FIND_DECLARATIONS = IIndex.FIND_DECLARATIONS;
+       public static final int FIND_DEFINITIONS = IIndex.FIND_DEFINITIONS;
+       public static final int FIND_REFERENCES = IIndex.FIND_REFERENCES;
+       public static final int FIND_DECLARATIONS_DEFINITIONS = FIND_DECLARATIONS | FIND_DEFINITIONS;
+       public static final int FIND_ALL_OCCURRENCES = FIND_DECLARATIONS | FIND_DEFINITIONS | FIND_REFERENCES;
+       
+       protected static final long LABEL_FLAGS= 
+                       CElementLabels.M_PARAMETER_TYPES | 
+                       CElementLabels.ALL_FULLY_QUALIFIED |
+                       CElementLabels.TEMPLATE_ARGUMENTS;
+
+       protected PDOMSearchResult result;
+       protected int flags;
+       
+       protected ICElement[] scope;
+       protected ICProject[] projects;
+       private Set<String> fullPathFilter;
+
+       protected PDOMSearchQuery(ICElement[] scope, int flags) {
+               result = new PDOMSearchResult(this);
+               this.flags = flags;
+               this.scope = scope;
+               
+               try {
+                       if (scope == null) {
+                               // All CDT projects in workspace
+                               ICProject[] allProjects = CoreModel.getDefault().getCModel().getCProjects();
+                               
+                               // Filter out closed projects for this case
+                               for (int i = 0; i < allProjects.length; i++) {
+                                       if (!allProjects[i].getProject().isOpen()) { 
+                                               allProjects[i] = null;
+                                       }
+                               }
+                               
+                               projects = (ICProject[]) ArrayUtil.removeNulls(ICProject.class, allProjects);
+                       } else {
+                               Map<String, ICProject> projectMap = new HashMap<String, ICProject>();
+                               Set<String> pathFilter = new HashSet<String>();
+                               boolean needFilter= false;
+                               for (int i = 0; i < scope.length; ++i) {
+                                       ICProject project = scope[i].getCProject();
+                                       if (project != null && project.getProject().isOpen()) {
+                                               IResource res= scope[i].getResource();
+                                               if (res != null) {
+                                                       pathFilter.add(res.getFullPath().toString());
+                                                       needFilter= needFilter || !(res instanceof IProject);
+                                               }
+                                               projectMap.put(project.getElementName(), project);
+                                       }
+                               }
+                               
+                               projects = projectMap.values().toArray(new ICProject[projectMap.size()]);
+                               if (needFilter) {
+                                       fullPathFilter= pathFilter;
+                               }
+                       }
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }
+       }
+       
+       protected String labelForBinding(final IIndex index, IBinding binding, String defaultLabel)
+                       throws CoreException {
+               IIndexName[] names= index.findNames(binding, IIndex.FIND_DECLARATIONS_DEFINITIONS);
+               if (names.length > 0) {
+                       ICElementHandle elem= IndexUI.getCElementForName((ICProject) null, index, names[0]);
+                       if (elem != null) {
+                               return CElementLabels.getElementLabel(elem, LABEL_FLAGS);
+                       }
+               }
+               return defaultLabel;
+       }
+
+       public String getLabel() {
+               String type;
+               if ((flags & FIND_REFERENCES) != 0)
+                       type = CSearchMessages.PDOMSearchQuery_refs_label; 
+               else if ((flags & FIND_DECLARATIONS) != 0)
+                       type = CSearchMessages.PDOMSearchQuery_decls_label; 
+               else
+                       type = CSearchMessages.PDOMSearchQuery_defs_label; 
+               return type;
+       }
+
+       public abstract String getResultLabel(int matchCount);
+
+       public String getResultLabel(String pattern, int matchCount) {
+               return getResultLabel(pattern, null, matchCount);
+       }
+
+       public String getResultLabel(String pattern, String scope, int matchCount) {
+               // Report pattern and number of matches
+               String label;
+               final int kindFlags= flags & FIND_ALL_OCCURRENCES;
+               switch (kindFlags) {
+               case FIND_REFERENCES:
+                       label = NLS.bind(CSearchMessages.PDOMSearchQuery_refs_result_label, pattern);
+                       break;
+               case FIND_DECLARATIONS:
+                       label = NLS.bind(CSearchMessages.PDOMSearchQuery_decls_result_label, pattern);
+                       break;
+               case FIND_DEFINITIONS:
+                       label = NLS.bind(CSearchMessages.PDOMSearchQuery_defs_result_label, pattern);
+                       break;
+               case FIND_DECLARATIONS_DEFINITIONS:
+                       label = NLS.bind(CSearchMessages.PDOMSearchQuery_decldefs_result_label, pattern);
+                       break;
+               default:
+                       label = NLS.bind(CSearchMessages.PDOMSearchQuery_occurrences_result_label, pattern);
+                       break;
+               }
+
+               if (scope != null) 
+                       label= NLS.bind(CSearchMessages.PDOMSearchPatternQuery_PatternQuery_labelPatternInScope, label, scope);
+
+               String countLabel = Messages.format(CSearchMessages.CSearchResultCollector_matches, new Integer(
+                               matchCount));
+               return label + " " + countLabel; //$NON-NLS-1$
+       }
+
+       public boolean canRerun() {
+               return true;
+       }
+
+       public boolean canRunInBackground() {
+               return true;
+       }
+
+       public ISearchResult getSearchResult() {
+               return result;
+       }
+
+       /**
+        * Return true to filter name out of the match list.
+        * Override in a subclass to add scoping.
+        * @param name
+        * @return true to filter name out of the match list
+        */
+       protected boolean filterName(IIndexName name) {
+               return false; // i.e. keep it
+       }
+
+       private void createMatchesFromNames(IIndex index, Map<IIndexFile, Set<Match>> fileMatches,
+                       Collection<IIndexName> names, boolean isPolymorphicOnly) throws CoreException {
+               if (names == null)
+                       return;
+
+               ICProject preferred = getPreferredProject();
+               for (IIndexName name : names) {
+                       if (!filterName(name)) {
+                               if (!isPolymorphicOnly || name.couldBePolymorphicMethodCall()) {
+                                       IASTFileLocation loc = name.getFileLocation();
+                                       IIndexFile file = name.getFile();
+                                       Set<Match> matches = fileMatches.get(file);
+                                       if (matches == null) {
+                                               matches = new HashSet<Match>();
+                                               fileMatches.put(file, matches);
+                                       }
+                                       int nodeOffset = loc.getNodeOffset();
+                                       int nodeLength = loc.getNodeLength();
+                                       ICElement enclosingElement = null;
+                                       IIndexName enclosingDefinition = name.getEnclosingDefinition();
+                                       if (enclosingDefinition != null) {
+                                               enclosingElement = IndexUI.getCElementForName(preferred, index, enclosingDefinition);
+                                       }
+                                       boolean isWriteAccess = name.isWriteAccess();
+                                       matches.add(new Match(nodeOffset, nodeLength, isPolymorphicOnly, enclosingElement,
+                                                       isWriteAccess));
+                               }
+                       }
+
+               }
+       }
+
+       private Set<Match> convertMatchesPositions(IIndexFile file, Set<Match> matches) throws CoreException {
+               IPath path = IndexLocationFactory.getPath(file.getLocation());
+               long timestamp = file.getTimestamp();
+               IPositionConverter converter = CCorePlugin.getPositionTrackerManager().findPositionConverter(path, timestamp);
+               if (converter != null) {
+                       Set<Match> convertedMatches = new HashSet<Match>();
+                       for (Match match : matches) {
+                               IRegion region = new Region(match.getOffset(), match.getLength());
+                               region = converter.historicToActual(region);
+                               int offset = region.getOffset();
+                               int length = region.getLength();
+                               boolean isPolymorphicCall = match.isPolymorphicCall();
+                               ICElement enclosingElement = match.getEnclosingElement();
+                               boolean isWriteAccess = match.isWriteAccess();
+                               convertedMatches.add(new Match(offset, length, isPolymorphicCall, enclosingElement, isWriteAccess));
+                       }
+                       matches = convertedMatches;
+               }
+               return matches;
+       }
+
+       private void collectNames(IIndex index, Collection<IIndexName> names,
+                       Collection<IIndexName> polymorphicNames) throws CoreException {
+               // group all matched names by files
+               Map<IIndexFile, Set<Match>> fileMatches = new HashMap<IIndexFile, Set<Match>>();
+               createMatchesFromNames(index, fileMatches, names, false);
+               createMatchesFromNames(index, fileMatches, polymorphicNames, true);
+               // compute mapping from paths to dirty text editors
+               IEditorPart[] dirtyEditors = CUIPlugin.getDirtyEditors();
+               Map<IPath, ITextEditor> pathsDirtyEditors = new HashMap<IPath, ITextEditor>();
+               for (IEditorPart editorPart : dirtyEditors) {
+                       if (editorPart instanceof ITextEditor) {
+                               ITextEditor textEditor = (ITextEditor)editorPart;
+                               IEditorInput editorInput = editorPart.getEditorInput();
+                               if (editorInput instanceof IPathEditorInput) {
+                                       IPathEditorInput pathEditorInput = (IPathEditorInput)editorInput;
+                                       pathsDirtyEditors.put(pathEditorInput.getPath(), textEditor);
+                               }
+                       }
+               }
+               // for each file with matches create line elements with matches
+               for (Entry<IIndexFile, Set<Match>> entry : fileMatches.entrySet()) {
+                       IIndexFile file = entry.getKey();
+                       Set<Match> matches = entry.getValue();
+                       LineSearchElement[] lineElements = {};
+                       // check if there is dirty text editor corresponding to file and convert matches
+                       IPath absolutePath = IndexLocationFactory.getAbsolutePath(file.getLocation());
+                       if (pathsDirtyEditors.containsKey(absolutePath)) {
+                               matches = convertMatchesPositions(file, matches);
+                               // scan dirty editor and group matches by line elements
+                               ITextEditor textEditor = pathsDirtyEditors.get(absolutePath);
+                               IEditorInput input = textEditor.getEditorInput(); 
+                               IDocument document = textEditor.getDocumentProvider().getDocument(input);
+                               Match[] matchesArray = matches.toArray(new Match[matches.size()]);
+                               lineElements = LineSearchElement.createElements(file.getLocation(), matchesArray, document);
+                       } else {
+                               // scan file and group matches by line elements
+                               Match[] matchesArray = matches.toArray(new Match[matches.size()]);
+                               lineElements = LineSearchElement.createElements(file.getLocation(), matchesArray);
+                       }
+                       // create real PDOMSearchMatch with corresponding line elements 
+                       for (LineSearchElement searchElement : lineElements) {
+                               for (Match lineMatch : searchElement.getMatches()) {
+                                       int offset = lineMatch.getOffset();
+                                       int length = lineMatch.getLength();
+                                       PDOMSearchMatch match = new PDOMSearchMatch(searchElement, offset, length);
+                                       if (lineMatch.isPolymorphicCall())
+                                               match.setIsPolymorphicCall();
+                                       result.addMatch(match);
+                               }
+                       }
+               }
+       }
+
+       protected void createMatches(IIndex index, IBinding binding) throws CoreException {
+               createMatches(index, new IBinding[] { binding });
+       }
+       
+       protected void createMatches(IIndex index, IBinding[] bindings) throws CoreException {
+               if (bindings == null)
+                       return;
+               List<IIndexName> names= new ArrayList<IIndexName>();
+               List<IIndexName> polymorphicNames= null;
+               HashSet<IBinding> handled= new HashSet<IBinding>();
+               
+               for (IBinding binding : bindings) {
+                       if (binding != null && handled.add(binding)) {
+                               createMatches1(index, binding, names);
+                       }
+               }
+               
+               if ((flags & FIND_REFERENCES) != 0) {
+                       for (IBinding binding : bindings) {
+                               if (binding != null) {
+                                       List<? extends IBinding> specializations = IndexUI.findSpecializations(binding);
+                                       for (IBinding spec : specializations) {
+                                               if (spec != null && handled.add(spec)) {
+                                                       createMatches1(index, spec, names);
+                                               }
+                                       }
+
+                                       if (binding instanceof ICPPMethod) {
+                                               ICPPMethod m= (ICPPMethod) binding;
+                                               ICPPMethod[] msInBases = ClassTypeHelper.findOverridden(m);
+                                               if (msInBases.length > 0) {
+                                                       if (polymorphicNames == null) {
+                                                               polymorphicNames= new ArrayList<IIndexName>();
+                                                       }
+                                                       for (ICPPMethod mInBase : msInBases) {
+                                                               if (mInBase != null && handled.add(mInBase)) {
+                                                                       createMatches1(index, mInBase, polymorphicNames);
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+               if (!names.isEmpty()) {
+                       collectNames(index, names, polymorphicNames);
+               }
+       }
+
+       private void createMatches1(IIndex index, IBinding binding, List<IIndexName> names) throws CoreException {
+               IIndexName[] bindingNames= index.findNames(binding, flags);
+               if (fullPathFilter == null) {
+                       names.addAll(Arrays.asList(bindingNames));
+               } else {
+                       for (IIndexName name : bindingNames) {
+                               String fullPath= name.getFile().getLocation().getFullPath();
+                               if (fullPath != null && accept(fullPath)) 
+                                       names.add(name);
+                       }
+               }
+       }
+
+       private boolean accept(String fullPath) {
+               for(;;) {
+                       if (fullPathFilter.contains(fullPath))
+                               return true;
+                       int idx= fullPath.lastIndexOf('/');
+                       if (idx < 0)
+                               return false;
+                       fullPath= fullPath.substring(0, idx);
+               } 
+       }
+
+       protected void createLocalMatches(IASTTranslationUnit ast, IBinding binding) throws CoreException {
+               if (binding != null) {
+                       Set<IASTName> names= new HashSet<IASTName>();
+                       names.addAll(Arrays.asList(ast.getDeclarationsInAST(binding)));
+                       names.addAll(Arrays.asList(ast.getDefinitionsInAST(binding)));
+                       names.addAll(Arrays.asList(ast.getReferences(binding)));
+                       // Collect local matches from AST
+                       IIndexFileLocation fileLocation = null; 
+                       Set<Match> localMatches = new HashSet<Match>();
+                       for (IASTName name : names) {
+                               if (((flags & FIND_DECLARATIONS) != 0 && name.isDeclaration()) ||
+                                               ((flags & FIND_DEFINITIONS) != 0 && name.isDefinition()) ||
+                                               ((flags & FIND_REFERENCES) != 0 && name.isReference())) {
+                                       ASTTypeInfo typeInfo= ASTTypeInfo.create(name);
+                                       if (typeInfo != null) {
+                                               ITypeReference ref= typeInfo.getResolvedReference();
+                                               if (ref != null) {
+                                                       ICElement element = null;
+                                                       IASTNode node = name;
+                                                       while (node != null && !(node instanceof IASTFunctionDefinition)) {
+                                                               node= node.getParent();
+                                                       }
+                                                       if (node != null) {
+                                                               IASTFunctionDefinition definition = (IASTFunctionDefinition) node;
+                                                               element = IndexUI.getCElementForName(getPreferredProject(),
+                                                                               ast.getIndex(), definition.getDeclarator().getName());
+                                                       }
+                                                       boolean isWrite = CSearchUtil.isWriteOccurrence(name, binding);
+                                                       localMatches.add(new Match(ref.getOffset(), ref.getLength(), false,
+                                                                       element, isWrite));
+                                                       fileLocation = typeInfo.getIFL();
+                                               }
+                                       }
+                               }
+                       }
+                       if (localMatches.isEmpty())
+                               return;
+                       // Search for dirty editor
+                       ITextEditor dirtyTextEditor = null;
+                       String fullPath = ast.getFilePath();
+                       for (IEditorPart editorPart : CUIPlugin.getDirtyEditors()) {
+                               if (editorPart instanceof ITextEditor) {
+                                       ITextEditor textEditor = (ITextEditor) editorPart;
+                                       IEditorInput editorInput = editorPart.getEditorInput();
+                                       if (editorInput instanceof IPathEditorInput) {
+                                               IPathEditorInput pathEditorInput = (IPathEditorInput) editorInput;
+                                               IPath path = pathEditorInput.getPath();
+                                               if (fullPath.equals(path.toOSString())) {
+                                                       dirtyTextEditor = textEditor;
+                                                       break;
+                                               }
+                                       }
+                               }
+                       }
+                       // Create line search elements
+                       Match[] matchesArray = localMatches.toArray(new Match[localMatches.size()]);
+                       LineSearchElement[] lineElements;
+                       if (dirtyTextEditor != null) {
+                               IEditorInput input = dirtyTextEditor.getEditorInput();
+                               IDocument document = dirtyTextEditor.getDocumentProvider().getDocument(input);
+                               lineElements = LineSearchElement.createElements(fileLocation, matchesArray, document);
+                       } else {
+                               lineElements = LineSearchElement.createElements(fileLocation, matchesArray);
+                       }
+                       // Create real PDOMSearchMatch with corresponding line elements 
+                       for (LineSearchElement searchElement : lineElements) {
+                               for (Match lineMatch : searchElement.getMatches()) {
+                                       int offset = lineMatch.getOffset();
+                                       int length = lineMatch.getLength();
+                                       PDOMSearchMatch match = new PDOMSearchMatch(searchElement, offset, length);
+                                       result.addMatch(match);
+                               }
+                       }
+               }
+       }
+
+       private ICProject getPreferredProject() {
+               ICProject preferred= null;
+               if (projects != null && projects.length == 1) {
+                       preferred= projects[0];
+               }
+               return preferred;
+       }
+
+       public final IStatus run(IProgressMonitor monitor) throws OperationCanceledException {
+               PDOMSearchResult result= (PDOMSearchResult) getSearchResult();
+               result.removeAll();
+               
+               result.setIndexerBusy(!CCorePlugin.getIndexManager().isIndexerIdle());
+               
+               try {
+                       IIndex index= CCorePlugin.getIndexManager().getIndex(projects, 0);
+                       try {
+                               index.acquireReadLock();
+                       } catch (InterruptedException e) {
+                               return Status.CANCEL_STATUS;
+                       }
+                       try {
+                               return runWithIndex(index, monitor);
+                       } finally {
+                               index.releaseReadLock();
+                       }
+               } catch (CoreException e) {
+                       return e.getStatus();
+               }
+       }
+
+       abstract protected IStatus runWithIndex(IIndex index, IProgressMonitor monitor);
+
+       /**
+        * Get the projects involved in the search.
+        * @return array, never <code>null</code>
+        */
+       public ICProject[] getProjects() {
+               return projects;
+       }
+       
+       public String getScopeDescription() {
+               StringBuilder buf= new StringBuilder();
+               switch (scope.length) {
+               case 0:
+                       break;
+               case 1:
+                       buf.append(scope[0].getElementName());
+                       break;
+               case 2:
+                       buf.append(scope[0].getElementName());
+                       buf.append(", "); //$NON-NLS-1$
+                       buf.append(scope[1].getElementName());
+                       break;
+               default:
+                       buf.append(scope[0].getElementName());
+                       buf.append(", "); //$NON-NLS-1$
+                       buf.append(scope[1].getElementName());
+                       buf.append(", ..."); //$NON-NLS-1$
+                       break;
+               }
+               return buf.toString();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchResult.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchResult.java
new file mode 100644 (file)
index 0000000..2329f0b
--- /dev/null
@@ -0,0 +1,228 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX - Initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *     Ed Swartz (Nokia)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.search;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.search.ui.ISearchQuery;
+import org.eclipse.search.ui.text.AbstractTextSearchResult;
+import org.eclipse.search.ui.text.IEditorMatchAdapter;
+import org.eclipse.search.ui.text.IFileMatchAdapter;
+import org.eclipse.search.ui.text.Match;
+import org.eclipse.search.ui.text.MatchFilter;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IPathEditorInput;
+import org.eclipse.ui.IStorageEditorInput;
+import org.eclipse.ui.editors.text.ILocationProvider;
+import org.eclipse.ui.part.FileEditorInput;
+
+import org.eclipse.cdt.core.index.IIndexFileLocation;
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.core.index.IndexLocationFactory;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
+
+/**
+ * @author Doug Schaefer
+ */
+public class PDOMSearchResult extends AbstractTextSearchResult implements IEditorMatchAdapter, IFileMatchAdapter {
+       private static final String KEY_SHOW_POLYMORPHIC_CALLS = "ShowPolymorphicCalls"; //$NON-NLS-1$
+       final static MatchFilter[] ALL_FILTERS = new MatchFilter[] {HidePolymorphicCalls.FILTER};
+       final static MatchFilter[] NO_FILTERS = {};
+
+       private PDOMSearchQuery query;
+       private boolean indexerBusy;
+       
+       public PDOMSearchResult(PDOMSearchQuery query) {
+               super();
+               this.query = query;
+       }
+
+       @Override
+       public IEditorMatchAdapter getEditorMatchAdapter() {
+               return this;
+       }
+
+       @Override
+       public IFileMatchAdapter getFileMatchAdapter() {
+               return this;
+       }
+
+       private String getFileName(IEditorPart editor) {
+               final IEditorInput input= editor.getEditorInput();
+               IPath path= null;
+               if (input instanceof FileEditorInput) {
+                       final FileEditorInput fileInput = (FileEditorInput)input;
+                       path= fileInput.getFile().getLocation();
+               } else if (input instanceof ExternalEditorInput) {
+                       final ExternalEditorInput extInput = (ExternalEditorInput)input;
+                       path= extInput.getPath();
+               } else if (input instanceof IStorageEditorInput) {
+                       try {
+                               final IStorage storage= ((IStorageEditorInput)input).getStorage();
+                               path= storage.getFullPath();
+                       } catch (CoreException exc) {
+                               // ignore
+                       }
+               } else if (input instanceof IPathEditorInput) {
+                       path= ((IPathEditorInput)input).getPath();
+               } else {
+                       ILocationProvider provider= (ILocationProvider) input.getAdapter(ILocationProvider.class);
+                       if (provider != null) {
+                               path= provider.getPath(input);
+                       }
+               }               
+               if (path != null)
+                       return path.toOSString();
+               
+               return null;
+       }
+       
+       public boolean isShownInEditor(Match match, IEditorPart editor) {
+               final String fileName= getFileName(editor);
+               if (fileName != null && match instanceof PDOMSearchMatch) {
+                       final IPath filePath= new Path(fileName);
+                       return filePath.equals(IndexLocationFactory.getAbsolutePath(((PDOMSearchMatch)match).getLocation()));
+               }
+               return false;
+       }
+       
+       private Match[] computeContainedMatches(AbstractTextSearchResult result, String filename) throws CoreException {
+               IPath pfilename= new Path(filename);
+               List<Match> list = new ArrayList<Match>(); 
+               Object[] elements = result.getElements();
+               for (int i = 0; i < elements.length; ++i) {
+                       if (pfilename.equals(IndexLocationFactory.getAbsolutePath(((PDOMSearchElement)elements[i]).getLocation()))) {
+                               Match[] matches = result.getMatches(elements[i]);
+                               for (int j = 0; j < matches.length; ++j) {
+                                       if (matches[j] instanceof PDOMSearchMatch) {
+                                               list.add(matches[j]);
+                                       }
+                               }
+                       }
+               }
+               return list.toArray(new Match[list.size()]);
+       }
+       
+       public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) {
+               try {
+                       String filename = getFileName(editor);
+                       if (filename != null)
+                               return computeContainedMatches(result, filename);
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }
+               return new Match[0];
+       }
+
+       public Match[] computeContainedMatches(AbstractTextSearchResult result, IFile file) {
+               try {
+                       String filename = file.getLocation().toOSString();
+                       return computeContainedMatches(result, filename);
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }
+               return new Match[0];
+       }
+
+       public IFile getFile(Object element) {
+               if (element instanceof IIndexName) {
+                       IIndexName name = (IIndexName)element;
+                       try {
+                               IIndexFileLocation location = name.getFile().getLocation();
+                               if(location.getFullPath()!=null) {
+                                       return ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(location.getFullPath()));
+                               }
+                       } catch(CoreException ce) { /* fall-through to return null */ }
+               } else if (element instanceof PDOMSearchElement) {
+                       PDOMSearchElement searchElement = (PDOMSearchElement)element;
+                       IIndexFileLocation location = searchElement.getLocation();
+                       if(location.getFullPath()!=null) {
+                               return ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(location.getFullPath()));
+                       }
+               }
+               return null;
+       }
+
+       public String getLabel() {
+               // Report pattern and number of matches
+               return query.getResultLabel(getMatchCount());
+       }
+
+       public String getTooltip() {
+               return null;
+       }
+
+       public ImageDescriptor getImageDescriptor() {
+               return null;
+       }
+
+       public ISearchQuery getQuery() {
+               return query;
+       }
+
+       /**
+        * Remember whether the indexer was busy when the search was performed.
+        * @param b
+        */
+       public void setIndexerBusy(boolean b) {
+               this.indexerBusy = b;
+       }
+       
+       /**
+        * Tell if the indexer was busy when search results were gathered.
+        */
+       public boolean wasIndexerBusy() {
+               return indexerBusy;
+       }
+
+       @Override
+       public MatchFilter[] getAllMatchFilters() {
+               return ALL_FILTERS;
+       }
+
+       @Override
+       public MatchFilter[] getActiveMatchFilters() {  
+               MatchFilter[] result = super.getActiveMatchFilters();
+               if (result == null) {
+                       if (CUIPlugin.getDefault().getDialogSettings().getBoolean(KEY_SHOW_POLYMORPHIC_CALLS)) {
+                               return ALL_FILTERS;
+                       }
+                       return NO_FILTERS;
+               }
+               return result;
+       }
+
+       @Override
+       public void setActiveMatchFilters(MatchFilter[] filters) {
+               boolean showPoly= false;
+               for (int i = 0; i < filters.length; i++) {
+                       if (filters[i] == HidePolymorphicCalls.FILTER) {
+                               showPoly= true;
+                       }
+               }
+               CUIPlugin.getDefault().getDialogSettings().put(KEY_SHOW_POLYMORPHIC_CALLS, showPoly);
+               super.setActiveMatchFilters(filters);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java
new file mode 100644 (file)
index 0000000..049400e
--- /dev/null
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX - Initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.search;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.text.ITextSelection;
+
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.EScopeKind;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IProblemBinding;
+import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
+import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
+
+import org.eclipse.cdt.internal.ui.editor.ASTProvider;
+
+/**
+ * Query for searching the index based on a text selection.
+ */
+public class PDOMSearchTextSelectionQuery extends PDOMSearchQuery {
+       private ITranslationUnit tu;
+       private ITextSelection selection;
+       private String label;
+       
+       public PDOMSearchTextSelectionQuery(ICElement[] scope, ITranslationUnit tu, ITextSelection selection, int flags) {
+               super(scope, flags | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
+               this.tu = tu;
+               this.selection = selection;
+               this.label= selection.getText();
+       }
+
+       @Override
+       protected IStatus runWithIndex(final IIndex index, IProgressMonitor monitor) {
+               return ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_ACTIVE_ONLY, monitor, new ASTRunnable() {
+                       public IStatus runOnAST(ILanguage language, IASTTranslationUnit ast) throws CoreException {
+                               if (ast != null) {
+                                       IASTName searchName= ast.getNodeSelector(null).findEnclosingName(selection.getOffset(), selection.getLength());
+                                       if (searchName != null) {
+                                               label= searchName.toString();
+                                               IBinding binding= searchName.resolveBinding();
+                                               if (binding instanceof IProblemBinding == false) {
+                                                       if (binding != null) {
+                                                               IScope scope= null;
+                                                               try {
+                                                                       scope = binding.getScope();
+                                                               } catch (DOMException e) {
+                                                               }
+                                                               if (scope != null && scope.getKind() == EScopeKind.eLocal) {
+                                                                       createLocalMatches(ast, binding);
+                                                                       return Status.OK_STATUS;
+                                                               }
+                                                       }
+                                                       binding = index.findBinding(searchName);
+                                                       binding= CPPTemplates.findDeclarationForSpecialization(binding);
+                                                       if (binding != null) {
+                                                               label= labelForBinding(index, binding, label);
+                                                               createMatches(index, binding);
+                                                               return Status.OK_STATUS;
+                                                       }
+                                               }
+                                       }
+                               }
+                               return Status.OK_STATUS;
+                       }
+               });
+       }
+
+       @Override
+       public String getResultLabel(int numMatches) {
+               return getResultLabel(label, numMatches);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTreeContentProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTreeContentProvider.java
new file mode 100644 (file)
index 0000000..e99b9aa
--- /dev/null
@@ -0,0 +1,257 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    QNX - Initial API and implementation
+ *    Markus Schorn (Wind River Systems)
+ *    Ed Swartz (Nokia)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.search;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.index.IIndexFileLocation;
+import org.eclipse.cdt.core.index.IndexLocationFactory;
+import org.eclipse.cdt.core.model.CoreModel;
+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.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.resources.ResourceLookup;
+
+/**
+ * @author Doug Schaefer
+ *
+ */
+public class PDOMSearchTreeContentProvider implements ITreeContentProvider, IPDOMSearchContentProvider {
+
+       private TreeViewer viewer;
+       private PDOMSearchResult result;
+       private Map<Object, Set<Object>> tree = new HashMap<Object, Set<Object>>();
+       private final PDOMSearchViewPage fPage;
+
+       PDOMSearchTreeContentProvider(PDOMSearchViewPage page) {
+               fPage= page;
+       }
+
+       public Object[] getChildren(Object parentElement) {
+               Set<Object> children = tree.get(parentElement);
+               if (children == null)
+                       return new Object[0];
+               return children.toArray();
+       }
+
+       public Object getParent(Object element) {
+               Iterator<Object> p = tree.keySet().iterator();
+               while (p.hasNext()) {
+                       Object parent = p.next();
+                       Set<Object> children = tree.get(parent);
+                       if (children.contains(element))
+                               return parent;
+               }
+               return null;
+       }
+
+       public boolean hasChildren(Object element) {
+               return tree.get(element) != null;
+       }
+
+       public Object[] getElements(Object inputElement) {
+               return getChildren(inputElement);
+       }
+
+       public void dispose() {
+       }
+
+       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+               this.viewer = (TreeViewer)viewer;
+               this.result = (PDOMSearchResult) newInput;
+               initialize(result);
+               viewer.refresh();
+       }
+
+       /**
+        * Add a message to a project node indicating it has no results because indexer is disabled.
+        * @param project
+        */
+       private void insertUnindexedProjectWarningElement(ICProject project) {
+               insertCElement(project);
+               insertChild(project, 
+                               new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID,
+                                               CSearchMessages.PDOMSearchTreeContentProvider_IndexerNotEnabledWarning));
+       }
+
+       /**
+        * Add a message to a project node indicating it has no results because project is closed
+        * @param project
+        */
+       private void insertClosedProjectWarningElement(ICProject project) {
+               insertCElement(project);
+               insertChild(project, 
+                               new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID,
+                                               CSearchMessages.PDOMSearchTreeContentProvider_ProjectClosedWarning));
+       }
+       
+       private boolean insertChild(Object parent, Object child) {
+               Set<Object> children = tree.get(parent);
+               if (children == null) {
+                       children = new HashSet<Object>();
+                       tree.put(parent, children);
+               }
+               return children.add(child);
+       }
+       
+       private void insertSearchElement(PDOMSearchElement element) {
+               IIndexFileLocation location= element.getLocation();
+               IFile[] files;
+               if(location.getFullPath()!=null) {
+                       files= new IFile[] {ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(location.getFullPath()))};
+               } else {
+                       IPath path= IndexLocationFactory.getAbsolutePath(element.getLocation());
+                       files= ResourceLookup.findFilesForLocation(path);
+               }
+               boolean handled= false;
+               if (files.length > 0) {
+                       for (int j = 0; j < files.length; ++j) {
+                               ICElement celement = CoreModel.getDefault().create(files[j]);
+                               if (celement != null) {
+                                       insertChild(celement, element);
+                                       insertCElement(celement);
+                                       handled= true;
+                               }
+                       }
+               } 
+               if (!handled) {
+                       // insert a folder and then the file under that
+                       IPath path = IndexLocationFactory.getAbsolutePath(location);
+                       if (path != null) {
+                               IPath directory = path.removeLastSegments(1);
+                               insertChild(location, element);
+                               insertChild(directory, location);
+                               insertChild(result, directory);
+                       } else {
+                               // URI not representable as a file
+                               insertChild(IPDOMSearchContentProvider.URI_CONTAINER, location.getURI());
+                               insertChild(result, IPDOMSearchContentProvider.URI_CONTAINER);
+                       }
+               }
+       }
+       
+       private void insertCElement(ICElement element) {
+               if (element instanceof ICProject)
+                       insertChild(result, element);
+               else {
+                       ICElement parent = element.getParent();
+                       if (parent instanceof ISourceRoot && parent.getUnderlyingResource() instanceof IProject)
+                               // Skip source roots that are projects
+                               parent = parent.getParent();
+                       insertChild(parent, element);
+                       insertCElement(parent);
+               }
+       }
+       
+       public void elementsChanged(Object[] elements) {
+               if (elements != null) {
+                       for (int i = 0; i < elements.length; ++i) {
+                               PDOMSearchElement element = (PDOMSearchElement)elements[i];
+                               if (fPage.getDisplayedMatchCount(element) > 0) {
+                                       insertSearchElement(element);
+                               } else {
+                                       boolean remove = true;
+                                       if (element instanceof ICProject) {
+                                               ICProject cProject = (ICProject) element;
+                                               remove = !addProjectWarningIfApplicable(cProject);
+                                       }
+                                       if (remove) {
+                                               remove(element);
+                                       }
+                               }
+                       }
+               }
+               if (!viewer.getTree().isDisposed()) {
+                       viewer.refresh();
+               }
+       }
+
+       private boolean addProjectWarningIfApplicable(ICProject cProject) {
+               if (cProject.getProject().isOpen()) {
+                       if (!CCorePlugin.getIndexManager().isProjectIndexed(cProject)) {
+                               insertUnindexedProjectWarningElement(cProject);
+                               return true;
+                       }
+               } else {
+                       insertClosedProjectWarningElement(cProject);
+                       return true;
+               }
+               return false;
+       }
+       
+       public void clear() {
+               initialize(result);
+       }
+       
+       private void initialize(final PDOMSearchResult result) {
+               this.result = result;
+               tree.clear();
+               if (result != null) {
+                       // if indexer was busy, record that
+                       if (result.wasIndexerBusy()) {
+                               insertChild(result, IPDOMSearchContentProvider.INCOMPLETE_RESULTS_NODE); 
+                       }
+                       
+                       Object[] elements = result.getElements();
+                       for (int i = 0; i < elements.length; ++i) {
+                               final PDOMSearchElement element = (PDOMSearchElement)elements[i];
+                               if (fPage.getDisplayedMatchCount(element) > 0)
+                                       insertSearchElement(element);
+                       }
+
+                       // add all the projects which have no results
+                       ICProject[] projects = ((PDOMSearchQuery)result.getQuery()).getProjects();
+                       for (int i = 0; i < projects.length; ++i) {
+                               ICProject project = projects[i];
+                               Object projectResults = tree.get(project);
+                               if (projectResults == null) {
+                                       addProjectWarningIfApplicable(project);
+                               }
+                       }
+               }
+       }
+       
+       protected void remove(Object element) {
+               Object parent = getParent(element);
+               if (parent == null)
+                       // reached the search result
+                       return;
+               
+               Set<Object> siblings = tree.get(parent);
+               siblings.remove(element);
+               
+               if (siblings.isEmpty()) {
+                       // remove the parent
+                       remove(parent);
+                       tree.remove(parent);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTreeLabelProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTreeLabelProvider.java
new file mode 100644 (file)
index 0000000..9db94a7
--- /dev/null
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Doug Schaefer (QNX) - Initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *     Ed Swartz (Nokia)
+ *     Andrey Eremchenko (LEDAS)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.search;
+
+import org.eclipse.jface.viewers.StyledString;
+
+import org.eclipse.cdt.core.model.ICElement;
+
+import org.eclipse.cdt.internal.core.model.TranslationUnit;
+
+import org.eclipse.cdt.internal.ui.util.Messages;
+
+public class PDOMSearchTreeLabelProvider extends PDOMSearchLabelProvider {
+       
+       public PDOMSearchTreeLabelProvider(PDOMSearchViewPage page) {
+               super(page);
+       }
+       
+       @Override
+       public String getText(Object element) {
+               final String text= super.getText(element);
+               final int count= getMatchCount(element);
+               if (count <= 1) {
+                       return text;
+               }
+               return text + " " //$NON-NLS-1$
+                               + Messages.format(CSearchMessages.CSearchResultCollector_matches, new Integer(count)); 
+       }
+
+       @Override
+       public StyledString getStyledText(Object element) {
+               if (element instanceof TranslationUnit) {
+                       StyledString styled = new StyledString(super.getText(element));
+                       final int count= getMatchCount(element);
+                       if (count > 1) {
+                               final String matchesCount = " " //$NON-NLS-1$
+                                       + Messages.format(CSearchMessages.CSearchResultCollector_matches, new Integer(count));
+                               styled.append(matchesCount, StyledString.COUNTER_STYLER);
+                               return styled;
+                       }
+               }
+               if (!(element instanceof LineSearchElement))
+                       return new StyledString(getText(element));
+               LineSearchElement lineElement = (LineSearchElement) element;
+               String enclosingName = ""; //$NON-NLS-1$
+               ICElement enclosingElement = lineElement.getMatches()[0].getEnclosingElement();
+               if (fPage.isShowEnclosingDefinitions() && enclosingElement != null) {
+                       enclosingName = enclosingElement.getElementName() + ", "; //$NON-NLS-1$
+               }
+               Integer lineNumber = lineElement.getLineNumber();
+               String prefix = Messages.format(CSearchMessages.CSearchResultCollector_line, enclosingName, lineNumber);
+               prefix += ":  "; //$NON-NLS-1$
+               StyledString location = new StyledString(prefix, StyledString.QUALIFIER_STYLER);
+               return location.append(super.getStyledText(element));
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchUnresolvedIncludesQuery.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchUnresolvedIncludesQuery.java
new file mode 100644 (file)
index 0000000..b519f32
--- /dev/null
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.search;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.osgi.util.NLS;
+
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexFile;
+import org.eclipse.cdt.core.index.IIndexInclude;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.parser.IProblem;
+
+import org.eclipse.cdt.internal.ui.util.Messages;
+
+/**
+ * Query for searching unresolved includes in projects.
+ * Could be extended to search resources selections.
+ */
+public class PDOMSearchUnresolvedIncludesQuery extends PDOMSearchQuery {
+
+       public PDOMSearchUnresolvedIncludesQuery(ICElement[] scope) {
+               super(scope, 0);
+       }
+
+       @Override
+       protected IStatus runWithIndex(final IIndex index, IProgressMonitor monitor) {
+               try {
+                       for (IIndexFile file : index.getAllFiles()) {
+                               for (IIndexInclude include : file.getIncludes()) {
+                                       if (include.isActive() && !include.isResolved()) {
+                                               result.addMatch(new PDOMSearchMatch(new ProblemSearchElement(
+                                                               IProblem.PREPROCESSOR_INCLUSION_NOT_FOUND, include.getFullName(),
+                                                               include.getIncludedByLocation()), 
+                                                               include.getNameOffset(), include.getNameLength()));
+                                       }
+                               }
+                       }
+               } catch (CoreException e) {
+                       return e.getStatus();
+               }
+               return Status.OK_STATUS;
+       }
+
+       @Override
+       public String getLabel() {
+               return NLS.bind(CSearchMessages.PDOMSearchUnresolvedIncludesQuery_title, getScopeDescription());
+       }
+
+       @Override
+       public String getResultLabel(int matchCount) {
+               String countLabel = Messages.format(CSearchMessages.CSearchResultCollector_matches, new Integer(matchCount));
+               return getLabel() + " " + countLabel; //$NON-NLS-1$
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchViewPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchViewPage.java
new file mode 100644 (file)
index 0000000..760b87e
--- /dev/null
@@ -0,0 +1,344 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX - Initial API and implementation
+ *     Ed Swartz (Nokia)
+ *     Andrey Eremchenko (LEDAS)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.search;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
+import org.eclipse.search.ui.text.Match;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.IPageSite;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.index.IIndexFileLocation;
+import org.eclipse.cdt.core.index.IndexLocationFactory;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+import org.eclipse.cdt.internal.ui.viewsupport.ColoringLabelProvider;
+
+/**
+ * Implementation of the search view page for index based searches.
+ */
+public class PDOMSearchViewPage extends AbstractTextSearchViewPage {
+       public static final int LOCATION_COLUMN_INDEX = 0; 
+       public static final int DEFINITION_COLUMN_INDEX = 1;
+       public static final int MATCH_COLUMN_INDEX = 2;
+
+       private static final String[] fColumnLabels = new String[] { 
+               CSearchMessages.PDOMSearchViewPageLocationColumn_label,
+               CSearchMessages.PDOMSearchViewPageDefinitionColumn_label,
+               CSearchMessages.PDOMSearchViewPageMatchColumn_label
+       };
+       
+       private static final String KEY_LOCATION_COLUMN_WIDTH = "locationColumnWidth"; //$NON-NLS-1$
+       private static final String KEY_DEFINITION_COLUMN_WIDTH = "definitionColumnWidth"; //$NON-NLS-1$
+       private static final String KEY_MATCH_COLUMN_WIDTH = "matchColumnWidth"; //$NON-NLS-1$
+       private static final String KEY_SHOW_ENCLOSING_DEFINITIONS = "showEnclosingDefinitions"; //$NON-NLS-1$
+
+       private IPDOMSearchContentProvider contentProvider;
+       private boolean fShowEnclosingDefinitions;
+       private ShowEnclosingDefinitionsAction fShowEnclosingDefinitionsAction;
+       private int[] fColumnWidths = { 300, 150, 300 };
+       
+       private class ShowEnclosingDefinitionsAction extends Action {
+               public ShowEnclosingDefinitionsAction() {
+                       super(CSearchMessages.PDOMSearchViewPage_ShowEnclosingDefinitions_actionLabel, SWT.CHECK);
+                       setChecked(fShowEnclosingDefinitions);
+               }
+               
+               @Override
+               public void run() {
+                       setShowEnclosingDefinitions(isChecked());
+               }
+       }
+       
+       public PDOMSearchViewPage(int supportedLayouts) {
+               super(supportedLayouts);
+       }
+
+       public PDOMSearchViewPage() {
+               super();
+       }
+
+       @Override
+       public void init(IPageSite pageSite) {
+               super.init(pageSite);
+               fShowEnclosingDefinitionsAction = new ShowEnclosingDefinitionsAction();
+               IMenuManager menuManager= pageSite.getActionBars().getMenuManager();
+               menuManager.add(fShowEnclosingDefinitionsAction);
+               menuManager.updateAll(true);
+               pageSite.getActionBars().updateActionBars();
+       }
+
+       @Override
+       public void restoreState(IMemento memento) {
+               super.restoreState(memento);
+               IDialogSettings settings = getSettings();
+               boolean showEnclosingDefinitions = true;
+               if (settings.get(KEY_SHOW_ENCLOSING_DEFINITIONS) != null)
+                       showEnclosingDefinitions = settings.getBoolean(KEY_SHOW_ENCLOSING_DEFINITIONS);
+               if (memento != null) {
+                       Boolean value = memento.getBoolean(KEY_SHOW_ENCLOSING_DEFINITIONS);
+                       if (value != null)
+                               showEnclosingDefinitions = value.booleanValue();
+                       String[] keys = { KEY_LOCATION_COLUMN_WIDTH, KEY_DEFINITION_COLUMN_WIDTH, KEY_MATCH_COLUMN_WIDTH };
+                       for (int i = 0; i < keys.length; i++) {
+                               Integer width = memento.getInteger(keys[i]);
+                               if (width == null)
+                                       continue;
+                               if (width > 0)
+                                       fColumnWidths[i] = width;
+                       }
+               }
+               setShowEnclosingDefinitions(showEnclosingDefinitions);
+       }
+       
+       @Override
+       public void saveState(IMemento memento) {
+               super.saveState(memento);
+               saveColumnWidths();
+               memento.putInteger(KEY_DEFINITION_COLUMN_WIDTH, fColumnWidths[DEFINITION_COLUMN_INDEX]);
+               memento.putInteger(KEY_LOCATION_COLUMN_WIDTH, fColumnWidths[LOCATION_COLUMN_INDEX]);
+               memento.putInteger(KEY_MATCH_COLUMN_WIDTH, fColumnWidths[MATCH_COLUMN_INDEX]);
+               memento.putBoolean(KEY_SHOW_ENCLOSING_DEFINITIONS, fShowEnclosingDefinitions);
+       }
+       
+       public void setShowEnclosingDefinitions(boolean showEnclosingDefinitions) {
+               if (fShowEnclosingDefinitions == showEnclosingDefinitions)
+                       return;
+               fShowEnclosingDefinitions = showEnclosingDefinitions;
+               getSettings().put(KEY_SHOW_ENCLOSING_DEFINITIONS, fShowEnclosingDefinitions);
+               if (fShowEnclosingDefinitionsAction.isChecked() != showEnclosingDefinitions)
+                       fShowEnclosingDefinitionsAction.setChecked(showEnclosingDefinitions);
+               StructuredViewer viewer = getViewer();
+               if (viewer instanceof TableViewer) {
+                       TableViewer tableViewer = (TableViewer) viewer;
+                       TableColumn tableColumn = tableViewer.getTable().getColumn(DEFINITION_COLUMN_INDEX);
+                       if (fShowEnclosingDefinitions) {
+                               tableColumn.setWidth(fColumnWidths[DEFINITION_COLUMN_INDEX]);
+                               tableColumn.setResizable(true);
+                       } else {
+                               fColumnWidths[DEFINITION_COLUMN_INDEX] = tableColumn.getWidth();
+                               tableColumn.setWidth(0);
+                               tableColumn.setResizable(false);
+                       }
+               }
+               if (viewer != null)
+                       viewer.refresh();
+       }
+
+       public boolean isShowEnclosingDefinitions() {
+               return fShowEnclosingDefinitions;
+       }
+
+       @Override
+       protected void elementsChanged(Object[] objects) {
+               if (contentProvider != null)
+                       contentProvider.elementsChanged(objects);
+       }
+
+       @Override
+       protected void clear() {
+               if (contentProvider != null)
+                       contentProvider.clear();
+       }
+
+       /**
+        * Supply a sorter for the list and tree content providers to supply some order to the
+        * large numbers of matches that may result.  
+        * <p>
+        * This sorter categorizes the different kinds of ICElement matches (as well as IStatus
+        * messages and External Files groups) to place them in groups.  The items within a
+        * category are sorted in the default way {@link ViewerSorter#compare(Viewer, Object, Object)} works,
+        * by comparing text labels.
+        * <p>
+        * A potential concern here is that, in sorting the elements by name, the user may 
+        * find himself randomly jumping around a file when navigating search results in order.
+        * As this only happens when a search matches different identifiers or identifiers of
+        * different types, and since the user can use a textual search within a file to navigate
+        * the same results (ignoring extraneous hits in comments or disabled code), I argue it's not
+        * a big deal.  Furthermore, usually it would be a wildcard search that would result in 
+        * this situation -- indicating the user doesn't know the identifier and wants to find it using
+        * search.  In such a case, a sorted list of results in much more friendly to navigate.
+        * @author eswartz
+        *
+        */
+       private class SearchViewerComparator extends ViewerComparator {
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+                */
+               @Override
+               public int compare(Viewer viewer, Object e1, Object e2) {
+                       if (e1 instanceof LineSearchElement && e2 instanceof LineSearchElement) {
+                               LineSearchElement l1 = (LineSearchElement) e1;
+                               LineSearchElement l2 = (LineSearchElement) e2;
+                               if (viewer instanceof TableViewer) {
+                                       String p1 = l1.getLocation().getURI().getPath();
+                                       String p2 = l2.getLocation().getURI().getPath();
+                                       int cmp = p1.compareTo(p2);
+                                       if (cmp != 0)
+                                               return cmp;
+                               }
+                               return l1.getLineNumber() - l2.getLineNumber();
+                       }
+                       return super.compare(viewer, e1, e2);
+               }
+               
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.viewers.ViewerComparator#category(java.lang.Object)
+                */
+               @Override
+               public int category(Object element) {
+                       // place status messages first
+                       if (element instanceof IStatus) { 
+                               return -1000;
+                       }
+                       
+                       // keep elements of the same type together
+                       if (element instanceof TypeInfoSearchElement) {
+                               TypeInfoSearchElement searchElement = (TypeInfoSearchElement)element;
+                               int type = searchElement.getTypeInfo().getCElementType();
+                               // handle unknown types
+                               if (type < 0) {
+                                       type = 0;
+                               }
+                               return type;
+                       } else if (element instanceof ICElement) {
+                               int type = ((ICElement) element).getElementType();
+                               // handle unknown types
+                               if (type < 0) {
+                                       type = 0;
+                               }
+                               return Math.min(Math.max(0, type), 900);
+                       }
+                       
+                       // place external folders next to last
+                       if (element instanceof IPath || element instanceof IIndexFileLocation) {
+                               return 999;
+                       }
+                       
+                       // place external file matches last
+                       if (element == IPDOMSearchContentProvider.URI_CONTAINER) {
+                               return 1000;
+                       }
+                       
+                       return 2000;
+               }
+       }
+       
+       @Override
+       protected void configureTreeViewer(TreeViewer viewer) {
+               contentProvider = new PDOMSearchTreeContentProvider(this);
+               viewer.setComparator(new SearchViewerComparator());
+               viewer.setContentProvider((PDOMSearchTreeContentProvider)contentProvider);
+               PDOMSearchTreeLabelProvider innerLabelProvider = new PDOMSearchTreeLabelProvider(this);
+               ColoringLabelProvider labelProvider = new ColoringLabelProvider(innerLabelProvider);
+               viewer.setLabelProvider(labelProvider);
+       }
+
+       @Override
+       protected void configureTableViewer(TableViewer viewer) {
+               createColumns(viewer);
+               contentProvider = new PDOMSearchListContentProvider(this);
+               viewer.setComparator(new SearchViewerComparator());
+               viewer.setContentProvider((PDOMSearchListContentProvider)contentProvider);
+       }
+       
+       @Override
+       protected TableViewer createTableViewer(Composite parent) {
+               TableViewer tableViewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
+               tableViewer.getControl().addDisposeListener(new DisposeListener() {
+                       public void widgetDisposed(DisposeEvent e) {
+                               saveColumnWidths();
+                       }
+               });
+               return tableViewer;
+       }
+       
+       private void saveColumnWidths() {
+               StructuredViewer viewer = getViewer();
+               if (viewer instanceof TableViewer) {
+                       TableViewer tableViewer = (TableViewer) viewer;
+                       for (int i = 0; i < fColumnLabels.length; i++) {
+                               if (i == DEFINITION_COLUMN_INDEX && !fShowEnclosingDefinitions)
+                                       continue;
+                               fColumnWidths[i] = tableViewer.getTable().getColumn(i).getWidth(); 
+                       }               
+               }
+       }
+
+       private void createColumns(TableViewer viewer) {
+               for (int i = 0; i < fColumnLabels.length; i++) {
+                       TableViewerColumn viewerColumn = new TableViewerColumn(viewer, SWT.NONE);
+                       viewerColumn.setLabelProvider(new PDOMSearchListLabelProvider(this, i));
+                       TableColumn tableColumn = viewerColumn.getColumn();
+                       tableColumn.setText(fColumnLabels[i]);
+                       tableColumn.setWidth(fColumnWidths[i]);
+                       tableColumn.setResizable(true);
+                       tableColumn.setMoveable(false);
+                       if (i == DEFINITION_COLUMN_INDEX && !fShowEnclosingDefinitions) {
+                               tableColumn.setWidth(0);
+                               tableColumn.setResizable(false);
+                       }
+               }
+               Table table = viewer.getTable();
+               table.setHeaderVisible(true);
+               table.setLinesVisible(true);
+       }
+
+       @Override
+       protected void showMatch(Match match, int currentOffset, int currentLength, boolean activate) throws PartInitException {
+               if (!(match instanceof PDOMSearchMatch))
+                       return;
+               
+               try {
+                       Object element= ((PDOMSearchMatch)match).getElement();
+                       IIndexFileLocation ifl= ((PDOMSearchElement)element).getLocation();
+                       IPath path = IndexLocationFactory.getPath(ifl);
+                       IEditorPart editor = EditorUtility.openInEditor(path, null, activate);
+                       if (editor instanceof ITextEditor) {
+                               ITextEditor textEditor = (ITextEditor)editor;
+                               textEditor.selectAndReveal(currentOffset, currentLength);
+                       }
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }
+       }
+       
+       @Override
+       public StructuredViewer getViewer() {
+               return super.getViewer();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/ProblemSearchElement.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/ProblemSearchElement.java
new file mode 100644 (file)
index 0000000..dcb1680
--- /dev/null
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.search;
+
+import org.eclipse.cdt.core.index.IIndexFileLocation;
+
+/**
+ * Represents a problem in a search.
+ */
+public class ProblemSearchElement extends PDOMSearchElement {
+
+       private final int fProblemID;
+       private final String fDetail;
+
+       public ProblemSearchElement(int problemID, String detail, IIndexFileLocation floc) {
+               super(floc);
+               fProblemID= problemID;
+               fDetail= detail;
+       }
+               
+       /* (non-Javadoc)
+        * @see java.lang.Object#hashCode()
+        */
+       @Override
+       public int hashCode() {
+               final int prime = 31;
+               int result = super.hashCode();
+               result = prime * result + ((fDetail == null) ? 0 : fDetail.hashCode());
+               result = prime * result + fProblemID;
+               return result;
+       }
+
+       /* (non-Javadoc)
+        * @see java.lang.Object#equals(java.lang.Object)
+        */
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj)
+                       return true;
+               if (!super.equals(obj))
+                       return false;
+               if (getClass() != obj.getClass())
+                       return false;
+               ProblemSearchElement other = (ProblemSearchElement) obj;
+               if (fDetail == null) {
+                       if (other.fDetail != null)
+                               return false;
+               } else if (!fDetail.equals(other.fDetail))
+                       return false;
+               if (fProblemID != other.fProblemID)
+                       return false;
+               return true;
+       }
+       
+       public final int getProblemID() {
+               return fProblemID;
+       }
+       
+       public final String getDetail() {
+               return fDetail;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/TypeInfoSearchElement.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/TypeInfoSearchElement.java
new file mode 100644 (file)
index 0000000..a9494c7
--- /dev/null
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.search;
+
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.cdt.core.browser.ITypeInfo;
+import org.eclipse.cdt.core.browser.IndexTypeInfo;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexBinding;
+import org.eclipse.cdt.core.index.IIndexName;
+
+import org.eclipse.cdt.internal.core.browser.ASTTypeInfo;
+
+/**
+ * Represents a a c/c++-entity in a search.
+ */
+public class TypeInfoSearchElement extends PDOMSearchElement {
+       private final ITypeInfo typeInfo;
+
+       public TypeInfoSearchElement(IIndex index, IIndexName name, IIndexBinding binding) throws CoreException {
+               super(name.getFile().getLocation());
+               this.typeInfo= IndexTypeInfo.create(index, binding);
+       }
+
+       public TypeInfoSearchElement(ASTTypeInfo typeInfo) {
+               super(typeInfo.getIFL());
+               this.typeInfo= typeInfo;
+       }
+
+       @Override
+       public int hashCode() {
+               return super.hashCode() + typeInfo.hashCode()*31;
+       }
+       
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj) {
+                       return true;
+               }
+               if (!(obj instanceof TypeInfoSearchElement))
+                       return false;
+               TypeInfoSearchElement other= (TypeInfoSearchElement)obj;
+               return super.equals(other) && typeInfo.equals(other.typeInfo);
+       }
+
+       public final ITypeInfo getTypeInfo() {
+               return typeInfo;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/DeclarationsSearchGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/DeclarationsSearchGroup.java
new file mode 100644 (file)
index 0000000..b4bf634
--- /dev/null
@@ -0,0 +1,143 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corp. - Rational Software - initial implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.search.actions;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.search.ui.IContextMenuConstants;
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.texteditor.ITextEditorActionConstants;
+
+import org.eclipse.cdt.core.model.ICElement;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
+import org.eclipse.cdt.internal.ui.search.CSearchMessages;
+import org.eclipse.cdt.internal.ui.search.CSearchUtil;
+
+
+public class DeclarationsSearchGroup extends ActionGroup {
+       
+       private CEditor fEditor;
+       private IWorkbenchSite fSite;
+       
+       private FindDeclarationsAction fFindDeclarationsAction;
+       private FindDeclarationsProjectAction fFindDeclarationsProjectAction;
+       private FindDeclarationsInWorkingSetAction fFindDeclarationsInWorkingSetAction;
+       
+       public DeclarationsSearchGroup(IWorkbenchSite site) {
+               fFindDeclarationsAction= new FindDeclarationsAction(site);
+               fFindDeclarationsProjectAction = new FindDeclarationsProjectAction(site);
+               fFindDeclarationsInWorkingSetAction = new FindDeclarationsInWorkingSetAction(site,null);
+               fSite = site;
+       }
+       /**
+        * @param editor
+        */
+       public DeclarationsSearchGroup(CEditor editor) {
+               fEditor = editor;
+
+               fFindDeclarationsAction= new FindDeclarationsAction(editor);
+               fFindDeclarationsAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_DECL);
+               if (editor != null){
+                       editor.setAction(ICEditorActionDefinitionIds.FIND_DECL, fFindDeclarationsAction);
+               }
+               
+               fFindDeclarationsProjectAction = new FindDeclarationsProjectAction(editor);
+               
+               fFindDeclarationsInWorkingSetAction = new FindDeclarationsInWorkingSetAction(editor,null);
+       }
+       /* 
+        * Method declared on ActionGroup.
+        */
+       @Override
+       public void fillContextMenu(IMenuManager menu) {
+               super.fillContextMenu(menu);
+               
+               IMenuManager incomingMenu = menu;
+       
+               IMenuManager declarationsMenu = new MenuManager(CSearchMessages.group_declarations, IContextMenuConstants.GROUP_SEARCH); 
+               
+               if (fEditor != null){
+                       menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, declarationsMenu);    
+               } else {
+                       incomingMenu.appendToGroup(IContextMenuConstants.GROUP_SEARCH, declarationsMenu);
+               }
+               incomingMenu = declarationsMenu;
+               
+               FindAction[] actions = getWorkingSetActions();
+               incomingMenu.add(fFindDeclarationsAction);
+               incomingMenu.add(fFindDeclarationsProjectAction);
+               incomingMenu.add(fFindDeclarationsInWorkingSetAction);
+               
+               for (FindAction action : actions) {
+                       incomingMenu.add(action);
+               }
+       }       
+       
+       private FindAction[] getWorkingSetActions() {
+               ArrayList<FindAction> actions= new ArrayList<FindAction>(CSearchUtil.LRU_WORKINGSET_LIST_SIZE);
+               
+               Iterator<IWorkingSet[]> iter= CSearchUtil.getLRUWorkingSets().iterator();
+               while (iter.hasNext()) {
+                       IWorkingSet[] workingSets= iter.next();
+                       FindAction action;
+                       if (fEditor != null)
+                               action= new WorkingSetFindAction(fEditor, new FindDeclarationsInWorkingSetAction(fEditor, workingSets), CSearchUtil.toString(workingSets));
+                       else
+                               action= new WorkingSetFindAction(fSite, new FindDeclarationsInWorkingSetAction(fSite, workingSets), CSearchUtil.toString(workingSets));
+                       
+                       actions.add(action);
+               }
+               
+               return actions.toArray(new FindAction[actions.size()]);
+       }
+       public static boolean canActionBeAdded(ISelection selection) {
+               if(selection instanceof ITextSelection) {
+                       return (((ITextSelection)selection).getLength() > 0);
+               }
+               return getElement(selection) != null;
+       }
+       
+       private static ICElement getElement(ISelection sel) {
+               if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
+                       List<?> list= ((IStructuredSelection)sel).toList();
+                       if (list.size() == 1) {
+                               Object element= list.get(0);
+                               if (element instanceof ICElement) {
+                                       return (ICElement)element;
+                               }
+                       }
+               }
+               return null;
+       }
+       
+       /* 
+        * Overrides method declared in ActionGroup
+        */
+       @Override
+       public void dispose() {
+               fFindDeclarationsAction= null;
+               fFindDeclarationsProjectAction=null;
+               fFindDeclarationsInWorkingSetAction= null;
+               super.dispose();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java
new file mode 100644 (file)
index 0000000..702d147
--- /dev/null
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corp. - Rational Software - initial implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.search.actions;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.TextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.search.ui.ISearchQuery;
+import org.eclipse.search.ui.NewSearchUI;
+import org.eclipse.ui.IWorkbenchSite;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.search.CSearchMessages;
+import org.eclipse.cdt.internal.ui.search.PDOMSearchElementQuery;
+import org.eclipse.cdt.internal.ui.search.PDOMSearchQuery;
+import org.eclipse.cdt.internal.ui.search.PDOMSearchTextSelectionQuery;
+import org.eclipse.cdt.internal.ui.text.CWordFinder;
+
+
+public abstract class FindAction extends SelectionParseAction {
+       public FindAction(CEditor editor){
+               super(editor);
+       }
+       
+       public FindAction(IWorkbenchSite site){
+               super(site);
+       }
+       
+       @Override
+       public void run() {
+               ISearchQuery searchJob = null;
+
+               ISelection selection = getSelection();
+               if (selection instanceof IStructuredSelection) {
+                       Object object = ((IStructuredSelection) selection).getFirstElement();
+                       if (object instanceof ISourceReference)
+                               searchJob = createQuery((ISourceReference) object);
+               } else if (selection instanceof ITextSelection) {
+                       ITextSelection selNode = (ITextSelection) selection;
+                       ICElement element = fEditor.getInputCElement();
+                       while (element != null && !(element instanceof ITranslationUnit))
+                               element = element.getParent();
+                       if (element != null) {
+                               if (selNode.getLength() == 0) {
+                                       IDocument document= fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
+                                       IRegion reg= CWordFinder.findWord(document, selNode.getOffset());
+                                       selNode = new TextSelection(document, reg.getOffset(), reg.getLength());
+                               }
+                               searchJob = createQuery(element, selNode);
+                       }
+               } 
+
+               if (searchJob == null) {
+                       showStatusLineMessage(CSearchMessages.CSearchOperation_operationUnavailable_message);
+                       return;
+               }
+
+        clearStatusLine();
+               NewSearchUI.activateSearchResultView();
+               NewSearchUI.runQueryInBackground(searchJob);
+       }
+
+       protected PDOMSearchQuery createQuery(ISourceReference object) {
+               return new PDOMSearchElementQuery(getScope(), object, getLimitTo());
+       }
+
+       protected PDOMSearchQuery createQuery(ICElement element, ITextSelection selNode) {
+               return new PDOMSearchTextSelectionQuery(getScope(),
+                               (ITranslationUnit) element, selNode, getLimitTo());
+       }
+       
+    abstract protected String getScopeDescription(); 
+
+       abstract protected ICElement[] getScope();
+       
+       abstract protected int getLimitTo();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsAction.java
new file mode 100644 (file)
index 0000000..db41f4f
--- /dev/null
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corp. - Rational Software - initial implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.search.actions;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.search.CSearchMessages;
+import org.eclipse.cdt.internal.ui.search.PDOMSearchQuery;
+import org.eclipse.ui.IWorkbenchSite;
+
+
+public class FindDeclarationsAction extends FindAction {
+       
+       public FindDeclarationsAction(CEditor editor, String label, String tooltip){
+               super(editor);
+               setText(label); 
+               setToolTipText(tooltip); 
+       }
+       
+       public FindDeclarationsAction(CEditor editor){
+               this(editor,
+                       CSearchMessages.CSearch_FindDeclarationAction_label, 
+                       CSearchMessages.CSearch_FindDeclarationAction_tooltip); 
+       }
+       
+       public FindDeclarationsAction(IWorkbenchSite site){
+               this(site,
+                       CSearchMessages.CSearch_FindDeclarationAction_label, 
+                       CSearchMessages.CSearch_FindDeclarationAction_tooltip); 
+       }
+
+       public FindDeclarationsAction(IWorkbenchSite site, String label, String tooltip) {
+               super(site);
+               setText(label);
+               setToolTipText(tooltip);
+       }
+
+       @Override
+       protected ICElement[] getScope() {
+               return null;
+       }
+       
+       @Override
+       protected String getScopeDescription() {
+               return CSearchMessages.WorkspaceScope; 
+       }
+       
+       @Override
+       protected int getLimitTo() {
+               return PDOMSearchQuery.FIND_DECLARATIONS_DEFINITIONS;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsInWorkingSetAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsInWorkingSetAction.java
new file mode 100644 (file)
index 0000000..602a560
--- /dev/null
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corp. - Rational Software - initial implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.search.actions;
+
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.IWorkingSet;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.search.CSearchMessages;
+import org.eclipse.cdt.internal.ui.search.PDOMSearchQuery;
+
+public class FindDeclarationsInWorkingSetAction extends FindInWorkingSetAction {
+
+       public FindDeclarationsInWorkingSetAction(IWorkbenchSite site, IWorkingSet[] workingSets) {
+               super(site,
+                               CSearchMessages.CSearch_FindReferencesInWorkingSetAction_label, 
+                               CSearchMessages.CSearch_FindReferencesInWorkingSetAction_tooltip, 
+                               workingSets);
+       }
+
+       public FindDeclarationsInWorkingSetAction(CEditor editor, IWorkingSet[] workingSets) {
+               super(editor,
+                               CSearchMessages.CSearch_FindReferencesInWorkingSetAction_label, 
+                               CSearchMessages.CSearch_FindReferencesInWorkingSetAction_tooltip, 
+                               workingSets);
+       }
+
+       @Override
+       protected int getLimitTo() {
+               return PDOMSearchQuery.FIND_DECLARATIONS_DEFINITIONS;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsProjectAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindDeclarationsProjectAction.java
new file mode 100644 (file)
index 0000000..f5833ec
--- /dev/null
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.search.actions;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.search.CSearchMessages;
+import org.eclipse.cdt.internal.ui.search.PDOMSearchQuery;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbenchSite;
+
+public class FindDeclarationsProjectAction extends FindAction {
+
+       public FindDeclarationsProjectAction(CEditor editor, String label, String tooltip){
+               super(editor);
+               setText(label); 
+               setToolTipText(tooltip); 
+       }
+       
+       public FindDeclarationsProjectAction(CEditor editor){
+               this(editor,
+                       CSearchMessages.CSearch_FindDeclarationsProjectAction_label, 
+                       CSearchMessages.CSearch_FindDeclarationsProjectAction_tooltip); 
+       }
+       
+       public FindDeclarationsProjectAction(IWorkbenchSite site){
+               this(site,
+                       CSearchMessages.CSearch_FindDeclarationsProjectAction_label, 
+                       CSearchMessages.CSearch_FindDeclarationsProjectAction_tooltip); 
+       }
+
+       public FindDeclarationsProjectAction(IWorkbenchSite site, String label, String tooltip) {
+               super(site);
+               setText(label);
+               setToolTipText(tooltip);
+       }
+
+       @Override
+       protected ICElement[] getScope() {
+               ICProject project = null;
+               if (fEditor != null) {
+                       project = fEditor.getInputCElement().getCProject();                      
+               } else if (fSite != null){
+                       ISelection selection = getSelection();
+                       if (selection instanceof IStructuredSelection) {
+                               Object element = ((IStructuredSelection)selection).getFirstElement();
+                               if (element instanceof IResource)
+                                       project = CoreModel.getDefault().create(((IResource)element).getProject());
+                               else if (element instanceof ICElement)
+                                       project = ((ICElement)element).getCProject();
+                       }
+               }
+               
+               return project != null ? new ICElement[] { project } : null;
+       }
+
+       @Override
+       protected String getScopeDescription() {
+               return CSearchMessages.ProjectScope; 
+       }
+
+       @Override
+       protected int getLimitTo() {
+               return PDOMSearchQuery.FIND_DECLARATIONS_DEFINITIONS;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindInWorkingSetAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindInWorkingSetAction.java
new file mode 100644 (file)
index 0000000..b5d8c71
--- /dev/null
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.search.actions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.window.Window;
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetManager;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog;
+
+import org.eclipse.cdt.core.model.ICElement;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.search.CSearchMessages;
+import org.eclipse.cdt.internal.ui.search.CSearchUtil;
+import org.eclipse.cdt.internal.ui.util.Messages;
+
+public abstract class FindInWorkingSetAction extends FindAction {
+       
+       private IWorkingSet[] fWorkingSets;
+       private String scopeDescription = ""; //$NON-NLS-1$
+       
+       public FindInWorkingSetAction(CEditor editor, String label, String tooltip, IWorkingSet[] workingSets) {
+               super(editor);
+               setText(label); 
+               setToolTipText(tooltip); 
+               fWorkingSets = workingSets;
+       }
+       
+       public FindInWorkingSetAction(IWorkbenchSite site, String label, String tooltip, IWorkingSet[] workingSets){
+               super(site);
+               setText(label); 
+               setToolTipText(tooltip); 
+               fWorkingSets= workingSets;
+       }
+       
+       @Override
+       final public void run() {
+               IWorkingSet[] initial= fWorkingSets;
+               if (fWorkingSets == null) {
+                       fWorkingSets= askForWorkingSets();
+               }
+               if (fWorkingSets != null) {
+                       scopeDescription = Messages.format(CSearchMessages.WorkingSetScope, CSearchUtil.toString(fWorkingSets)); 
+                       super.run();
+               }
+               fWorkingSets= initial;
+       }
+
+       @Override
+       final protected String getScopeDescription() {
+               return scopeDescription;
+       }
+
+       @Override
+       final protected ICElement[] getScope() {
+               if (fWorkingSets == null) {
+                       return new ICElement[0];
+               }
+               List<ICElement> scope = new ArrayList<ICElement>();
+               for (int i = 0; i < fWorkingSets.length; ++i) {
+                       IAdaptable[] elements = fWorkingSets[i].getElements();
+                       for (int j = 0; j < elements.length; ++j) {
+                               ICElement element = (ICElement)elements[j].getAdapter(ICElement.class);
+                               if (element != null)
+                                       scope.add(element);
+                       }
+               }
+               
+               return scope.toArray(new ICElement[scope.size()]);
+       }
+       
+       private IWorkingSet[] askForWorkingSets() {
+               IWorkingSetManager wsm= PlatformUI.getWorkbench().getWorkingSetManager();
+               IWorkingSetSelectionDialog dlg= 
+                       wsm.createWorkingSetSelectionDialog(getSite().getShell(), true);
+               IWorkingSet[] mru= wsm.getRecentWorkingSets();
+               if (mru != null && mru.length > 0) {
+                       dlg.setSelection(new IWorkingSet[] {mru[0]});
+               }
+               if (dlg.open() == Window.OK) {
+                       mru= dlg.getSelection();
+                       if (mru != null && mru.length == 1) {
+                               wsm.addRecentWorkingSet(mru[0]);
+                       }
+                       return mru;
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsAction.java
new file mode 100644 (file)
index 0000000..96f4924
--- /dev/null
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corp. - Rational Software - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.search.actions;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.search.CSearchMessages;
+import org.eclipse.cdt.internal.ui.search.PDOMSearchQuery;
+import org.eclipse.ui.IWorkbenchSite;
+
+public class FindRefsAction extends FindAction {
+
+       public FindRefsAction(CEditor editor) {
+               this(editor,
+               CSearchMessages.CSearch_FindReferencesAction_label, 
+               CSearchMessages.CSearch_FindReferencesAction_tooltip); 
+       }
+       
+       public FindRefsAction(IWorkbenchSite site){
+               this(site,
+               CSearchMessages.CSearch_FindReferencesAction_label, 
+               CSearchMessages.CSearch_FindReferencesAction_tooltip); 
+       } 
+
+       public FindRefsAction(CEditor editor, String label, String tooltip) {
+               super(editor);
+               setText(label); 
+               setToolTipText(tooltip); 
+       }
+
+       public FindRefsAction(IWorkbenchSite site, String label, String tooltip) {
+               super(site);
+               setText(label);
+               setToolTipText(tooltip);
+       }
+
+       @Override
+       protected String getScopeDescription() {
+               return CSearchMessages.WorkspaceScope; 
+       }
+
+       @Override
+       protected ICElement[] getScope() {
+        return null;
+    }
+
+       @Override
+       protected int getLimitTo() {
+               return PDOMSearchQuery.FIND_REFERENCES;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsInWorkingSetAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsInWorkingSetAction.java
new file mode 100644 (file)
index 0000000..78516f9
--- /dev/null
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corp. - Rational Software - initial implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.search.actions;
+
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.IWorkingSet;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.search.CSearchMessages;
+import org.eclipse.cdt.internal.ui.search.PDOMSearchQuery;
+
+public class FindRefsInWorkingSetAction extends FindInWorkingSetAction {
+       
+       public FindRefsInWorkingSetAction(CEditor editor, IWorkingSet[] workingSets) {
+               super(editor,
+                               CSearchMessages.CSearch_FindReferencesInWorkingSetAction_label, 
+                               CSearchMessages.CSearch_FindReferencesInWorkingSetAction_tooltip, 
+                               workingSets);
+       }
+       
+       public FindRefsInWorkingSetAction(IWorkbenchSite site, IWorkingSet[] workingSets){
+               super (site,
+                               CSearchMessages.CSearch_FindReferencesInWorkingSetAction_label, 
+                               CSearchMessages.CSearch_FindReferencesInWorkingSetAction_tooltip, 
+                               workingSets);
+       }
+       
+       @Override
+       protected int getLimitTo() {
+               return PDOMSearchQuery.FIND_REFERENCES;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsProjectAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsProjectAction.java
new file mode 100644 (file)
index 0000000..979813e
--- /dev/null
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.search.actions;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.search.CSearchMessages;
+import org.eclipse.cdt.internal.ui.search.PDOMSearchQuery;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbenchSite;
+
+public class FindRefsProjectAction extends FindAction {
+
+       public FindRefsProjectAction(CEditor editor, String label, String tooltip){
+               super(editor);
+               setText(label); 
+               setToolTipText(tooltip); 
+       }
+       
+       public FindRefsProjectAction(CEditor editor){
+               this(editor,
+                       CSearchMessages.CSearch_FindReferencesProjectAction_label, 
+                       CSearchMessages.CSearch_FindReferencesProjectAction_tooltip); 
+       }
+       
+       public FindRefsProjectAction(IWorkbenchSite site){
+               this(site,
+                       CSearchMessages.CSearch_FindReferencesProjectAction_label, 
+                       CSearchMessages.CSearch_FindReferencesProjectAction_tooltip); 
+       }
+
+       public FindRefsProjectAction(IWorkbenchSite site, String label, String tooltip) {
+               super(site);
+               setText(label);
+               setToolTipText(tooltip);
+       }
+
+       @Override
+       protected ICElement[] getScope() {
+               ICProject project = null;
+               if (fEditor != null) {
+                       project = fEditor.getInputCElement().getCProject();                      
+               } else if (fSite != null){
+                       ISelection selection = getSelection();
+                       if (selection instanceof IStructuredSelection) {
+                               Object element = ((IStructuredSelection)selection).getFirstElement();
+                               if (element instanceof IResource)
+                                       project = CoreModel.getDefault().create(((IResource)element).getProject());
+                               else if (element instanceof ICElement)
+                                       project = ((ICElement)element).getCProject();
+                       }
+               }
+               
+               return project != null ? new ICElement[] { project } : null;
+       }
+
+       @Override
+       protected String getScopeDescription() {
+               return CSearchMessages.ProjectScope; 
+       }
+
+       @Override
+       protected int getLimitTo() {
+               return PDOMSearchQuery.FIND_REFERENCES;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindUnresolvedIncludesProjectAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindUnresolvedIncludesProjectAction.java
new file mode 100644 (file)
index 0000000..243fff2
--- /dev/null
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.search.actions;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.search.ui.ISearchQuery;
+import org.eclipse.search.ui.NewSearchUI;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchSite;
+
+import org.eclipse.cdt.core.model.ICProject;
+
+import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
+import org.eclipse.cdt.internal.ui.search.CSearchMessages;
+import org.eclipse.cdt.internal.ui.search.PDOMSearchUnresolvedIncludesQuery;
+import org.eclipse.cdt.internal.ui.util.StatusLineHandler;
+
+/**
+ * Searches projects for unresolved includes.
+ * Could be extended to work on resource selections.
+ */
+public class FindUnresolvedIncludesProjectAction implements IObjectActionDelegate {
+
+       private ISelection fSelection;
+       private IWorkbenchSite fSite;
+
+       public FindUnresolvedIncludesProjectAction() {
+       }
+
+       public void run(IAction action) {
+               List<ICProject> projects= new ArrayList<ICProject>();
+               IStructuredSelection cElements= SelectionConverter.convertSelectionToCElements(fSelection);
+               for (Iterator<?> i = cElements.iterator(); i.hasNext();) {
+                       Object elem = i.next();
+                       if (elem instanceof ICProject) {
+                               projects.add((ICProject) elem);
+                       }
+               }
+               
+               if (projects.isEmpty()) {
+                       StatusLineHandler.showStatusLineMessage(fSite, CSearchMessages.CSearchOperation_operationUnavailable_message);
+                       return;
+               }
+
+               ISearchQuery searchJob= new PDOMSearchUnresolvedIncludesQuery(projects.toArray(new ICProject[projects.size()]));
+
+               StatusLineHandler.clearStatusLine(fSite);
+               NewSearchUI.activateSearchResultView();
+               NewSearchUI.runQueryInBackground(searchJob);
+       }
+
+       public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+               fSite= targetPart.getSite();
+       }
+
+       public void selectionChanged(IAction action, ISelection selection) {
+               fSelection= selection;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java
new file mode 100644 (file)
index 0000000..24277fa
--- /dev/null
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *     Ed Swartz (Nokia)
+ *     Mike Kucera (IBM)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.search.actions;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextSelection;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.editor.CEditorMessages;
+import org.eclipse.cdt.internal.ui.text.CWordFinder;
+
+/**
+ * Navigates to the definition of a name, or to the declaration if invoked on the definition.
+ */
+public class OpenDeclarationsAction extends SelectionParseAction {
+       public static boolean sIsJUnitTest = false;     
+
+       ITextSelection fTextSelection;
+
+       /**
+        * Creates a new action with the given editor
+        */
+       public OpenDeclarationsAction(CEditor editor) {
+               super(editor);
+               setText(CEditorMessages.OpenDeclarations_label); 
+               setToolTipText(CEditorMessages.OpenDeclarations_tooltip); 
+               setDescription(CEditorMessages.OpenDeclarations_description); 
+       }
+
+       @Override
+       public void run() {
+               OpenDeclarationsJob job = createJob();
+               if (job != null)
+                       job.schedule();
+       }
+
+       /**
+        * For the purpose of regression testing.
+        */
+       public void runSync() throws CoreException {
+               OpenDeclarationsJob job = createJob();
+               if (job != null)
+                       job.performNavigation(new NullProgressMonitor());
+       }
+
+       private OpenDeclarationsJob createJob() {
+               String text= computeSelectedWord();
+               OpenDeclarationsJob job= null;
+               ICElement elem= fEditor.getInputCElement();
+               if (elem instanceof ITranslationUnit && fTextSelection != null) {
+                       job= new OpenDeclarationsJob(this, (ITranslationUnit) elem, fTextSelection, text);
+               }
+               return job;
+       }
+
+       private String computeSelectedWord() {
+               fTextSelection = getSelectedStringFromEditor();
+               String text= null;
+               if (fTextSelection != null) {
+                       if (fTextSelection.getLength() > 0) {
+                               text= fTextSelection.getText();
+                       } else {
+                               IDocument document= fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
+                               IRegion reg= CWordFinder.findWord(document, fTextSelection.getOffset());
+                               if (reg != null && reg.getLength() > 0) {
+                                       try {
+                                               text= document.get(reg.getOffset(), reg.getLength());
+                                       } catch (BadLocationException e) {
+                                               CUIPlugin.log(e);
+                                       }
+                               }
+                       }
+               }
+               return text;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java
new file mode 100644 (file)
index 0000000..f1ee815
--- /dev/null
@@ -0,0 +1,756 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *       Sergey Prigogin (Google)
+******************************************************************************/
+package org.eclipse.cdt.internal.ui.search.actions;
+
+import static java.lang.Math.max;
+import static java.lang.Math.min;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+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.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.Region;
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.IName;
+import org.eclipse.cdt.core.dom.ast.ASTNameCollector;
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionStyleMacroParameter;
+import org.eclipse.cdt.core.dom.ast.IASTImplicitName;
+import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTNodeSelector;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorFunctionStyleMacroDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IParameter;
+import org.eclipse.cdt.core.dom.ast.IProblemBinding;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexBinding;
+import org.eclipse.cdt.core.index.IIndexMacro;
+import org.eclipse.cdt.core.index.IIndexManager;
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.core.index.IndexFilter;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.ISourceRange;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.parser.util.ArrayUtil;
+import org.eclipse.cdt.core.parser.util.CharArrayUtils;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.LookupData;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
+import org.eclipse.cdt.internal.core.index.IIndexFragmentName;
+import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
+import org.eclipse.cdt.internal.core.model.ext.CElementHandleFactory;
+import org.eclipse.cdt.internal.core.model.ext.ICElementHandle;
+
+import org.eclipse.cdt.internal.ui.actions.OpenActionUtil;
+import org.eclipse.cdt.internal.ui.editor.ASTProvider;
+import org.eclipse.cdt.internal.ui.editor.CEditorMessages;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
+import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
+
+class OpenDeclarationsJob extends Job implements ASTRunnable {
+
+       private enum NameKind { REFERENCE, DECLARATION, USING_DECL, DEFINITION }
+
+       private final SelectionParseAction fAction;
+       private IProgressMonitor fMonitor;
+       private final ITranslationUnit fTranslationUnit;
+       private IIndex fIndex;
+       private final ITextSelection fTextSelection;
+       private final String fSelectedText;
+
+       OpenDeclarationsJob(SelectionParseAction action, ITranslationUnit editorInput, ITextSelection textSelection, String text) {
+               super(CEditorMessages.OpenDeclarations_dialog_title);
+               fAction= action;
+               fTranslationUnit= editorInput;
+               fTextSelection= textSelection;
+               fSelectedText= text;
+       }
+
+       @Override
+       protected IStatus run(IProgressMonitor monitor) {
+               try {
+                       return performNavigation(monitor);
+               } catch (CoreException e) {
+                       return e.getStatus();
+               }
+       }
+
+       IStatus performNavigation(IProgressMonitor monitor) throws CoreException {
+               fAction.clearStatusLine();
+
+               assert fIndex == null;
+               if (fIndex != null)
+                       return Status.CANCEL_STATUS;
+
+               fMonitor= monitor;
+               fIndex= CCorePlugin.getIndexManager().getIndex(fTranslationUnit.getCProject(),
+                               IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT);
+
+               try {
+                       fIndex.acquireReadLock();
+               } catch (InterruptedException e) {
+                       return Status.CANCEL_STATUS;
+               }
+
+               try {
+                       return ASTProvider.getASTProvider().runOnAST(fTranslationUnit, ASTProvider.WAIT_ACTIVE_ONLY, monitor, this);
+               } finally {
+                       fIndex.releaseReadLock();
+               }
+       }
+
+       public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
+               if (ast == null) {
+                       return Status.OK_STATUS;
+               }
+               int selectionStart = fTextSelection.getOffset();
+               int selectionLength = fTextSelection.getLength();
+
+               final IASTNodeSelector nodeSelector = ast.getNodeSelector(null);
+
+               IASTName sourceName= nodeSelector.findEnclosingName(selectionStart, selectionLength);
+               IName[] implicitTargets = findImplicitTargets(ast, nodeSelector, selectionStart, selectionLength);
+               if (sourceName == null) {
+                       if (implicitTargets.length > 0) {
+                               if (navigateViaCElements(fTranslationUnit.getCProject(), fIndex, implicitTargets))
+                                       return Status.OK_STATUS;
+                       }
+               } else {
+                       boolean found= false;
+                       final IASTNode parent = sourceName.getParent();
+                       if (parent instanceof IASTPreprocessorIncludeStatement) {
+                               openInclude(((IASTPreprocessorIncludeStatement) parent));
+                               return Status.OK_STATUS;
+                       }
+                       NameKind kind = getNameKind(sourceName);
+                       IBinding b = sourceName.resolveBinding();
+                       IBinding[] bindings = new IBinding[] { b };
+                       if (b instanceof IProblemBinding) {
+                               IBinding[] candidateBindings = ((IProblemBinding) b).getCandidateBindings();
+                               if (candidateBindings.length != 0) {
+                                       bindings = candidateBindings;
+                               }
+                       } else if (kind == NameKind.DEFINITION && b instanceof IType) {
+                               // Don't navigate away from a type definition.
+                               // Select the name at the current location instead.
+                               navigateToName(sourceName);
+                               return Status.OK_STATUS;
+                       }
+                       IName[] targets = IName.EMPTY_ARRAY;
+                       String filename = ast.getFilePath();
+                       for (IBinding binding : bindings) {
+                               if (binding != null && !(binding instanceof IProblemBinding)) {
+                                       IName[] names = findDeclNames(ast, kind, binding);
+                                       for (final IName name : names) {
+                                               if (name != null) {
+                                                       if (name instanceof IIndexName &&
+                                                                       filename.equals(((IIndexName) name).getFileLocation().getFileName())) {
+                                                               // Exclude index names from the current file.
+                                                       } else if (areOverlappingNames(name, sourceName)) {
+                                                               // Exclude the current location.
+                                                       } else if (binding instanceof IParameter) {
+                                                               if (isInSameFunction(sourceName, name)) {
+                                                                       targets = ArrayUtil.append(targets, name);
+                                                               }
+                                                       } else if (binding instanceof ICPPTemplateParameter) {
+                                                               if (isInSameTemplate(sourceName, name)) {
+                                                                       targets = ArrayUtil.append(targets, name);
+                                                               }
+                                                       } else {
+                                                               targets = ArrayUtil.append(targets, name);
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+                       targets = ArrayUtil.trim(ArrayUtil.addAll(targets, implicitTargets));
+                       if (navigateViaCElements(fTranslationUnit.getCProject(), fIndex, targets)) {
+                               found= true;
+                       } else {
+                               // Leave old method as fallback for local variables, parameters and
+                               // everything else not covered by ICElementHandle.
+                               found = navigateOneLocation(targets);
+                       }
+                       if (!found && !navigationFallBack(ast, sourceName, kind)) {
+                               fAction.reportSymbolLookupFailure(new String(sourceName.toCharArray()));
+                       }
+                       return Status.OK_STATUS;
+               }
+
+               // No enclosing name, check if we're in an include statement
+               IASTNode node= nodeSelector.findEnclosingNode(selectionStart, selectionLength);
+               if (node instanceof IASTPreprocessorIncludeStatement) {
+                       openInclude((IASTPreprocessorIncludeStatement) node);
+                       return Status.OK_STATUS;
+               } else if (node instanceof IASTPreprocessorFunctionStyleMacroDefinition) {
+                       IASTPreprocessorFunctionStyleMacroDefinition mdef= (IASTPreprocessorFunctionStyleMacroDefinition) node;
+                       for (IASTFunctionStyleMacroParameter par: mdef.getParameters()) {
+                               String parName= par.getParameter();
+                               if (parName.equals(fSelectedText)) {
+                                       if (navigateToLocation(par.getFileLocation())) {
+                                               return Status.OK_STATUS;
+                                       }
+                               }
+                       }
+               }
+               if (!navigationFallBack(ast, null, NameKind.REFERENCE)) {
+                       fAction.reportSelectionMatchFailure();
+               }
+               return Status.OK_STATUS;
+       }
+
+       private IName[] findDeclNames(IASTTranslationUnit ast, NameKind kind, IBinding binding) throws CoreException {
+               IName[] declNames = findNames(fIndex, ast, kind, binding);
+               // Bug 207320, handle template instances.
+               while (declNames.length == 0 && binding instanceof ICPPSpecialization) {
+                       binding = ((ICPPSpecialization) binding).getSpecializedBinding();
+                       if (binding != null && !(binding instanceof IProblemBinding)) {
+                               declNames = findNames(fIndex, ast, NameKind.DEFINITION, binding);
+                       }
+               }
+               if (declNames.length == 0 && binding instanceof ICPPMethod) {
+                       // Bug 86829, handle implicit methods.
+                       ICPPMethod method= (ICPPMethod) binding;
+                       if (method.isImplicit()) {
+                               IBinding clsBinding= method.getClassOwner();
+                               if (clsBinding != null && !(clsBinding instanceof IProblemBinding)) {
+                                       declNames= findNames(fIndex, ast, NameKind.REFERENCE, clsBinding);
+                               }
+                       }
+               }
+               return declNames;
+       }
+
+       private IName[] findNames(IIndex index, IASTTranslationUnit ast, NameKind kind, IBinding binding) throws CoreException {
+               IName[] declNames;
+               if (kind == NameKind.DEFINITION) {
+                       declNames= findDeclarations(index, ast, binding);
+               } else {
+                       declNames= findDefinitions(index, ast, kind, binding);
+               }
+
+               if (declNames.length == 0) {
+                       if (kind == NameKind.DEFINITION) {
+                               declNames= findDefinitions(index, ast, kind, binding);
+                       } else {
+                               declNames= findDeclarations(index, ast, binding);
+                       }
+               }
+               return declNames;
+       }
+
+       private IName[] findDefinitions(IIndex index, IASTTranslationUnit ast, NameKind kind, IBinding binding) throws CoreException {
+               List<IASTName> declNames= new ArrayList<IASTName>();
+               declNames.addAll(Arrays.asList(ast.getDefinitionsInAST(binding)));
+               for (Iterator<IASTName> i = declNames.iterator(); i.hasNext();) {
+                       IASTName name= i.next();
+                       final IBinding b2 = name.resolveBinding();
+                       if (b2 instanceof ICPPUsingDeclaration) {
+                               i.remove();
+                       }
+                       if (binding != b2 && binding instanceof ICPPSpecialization) {
+                               // Make sure binding specializes b2 so that for instance we do not navigate from
+                               // one partial specialization to another.
+                               IBinding spec= binding;
+                               while (spec instanceof ICPPSpecialization) {
+                                       spec= ((ICPPSpecialization) spec).getSpecializedBinding();
+                                       if (spec == b2)
+                                               break;
+                               }
+                               if (!(spec instanceof ICPPSpecialization)) {
+                                       i.remove();
+                               }
+                       }
+               }
+               if (!declNames.isEmpty()) {
+                       return declNames.toArray(new IASTName[declNames.size()]);
+               }
+
+               // 2. Try definition in index.
+               return index.findNames(binding, IIndex.FIND_DEFINITIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
+       }
+
+       private IName[] findDeclarations(IIndex index, IASTTranslationUnit ast, IBinding binding) throws CoreException {
+               IName[] declNames= ast.getDeclarationsInAST(binding);
+               for (int i = 0; i < declNames.length; i++) {
+                       IName name = declNames[i];
+                       if (name.isDefinition())
+                               declNames[i]= null;
+               }
+               declNames= (IName[]) ArrayUtil.removeNulls(IName.class, declNames);
+               if (declNames.length == 0) {
+                       declNames= index.findNames(binding, IIndex.FIND_DECLARATIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
+               }
+               return declNames;
+       }
+
+       /**
+        * Returns definitions of bindings referenced by implicit name at the given location.
+        */
+       private IName[] findImplicitTargets(IASTTranslationUnit ast, IASTNodeSelector nodeSelector,
+                       int offset, int length) throws CoreException {
+               IName[] definitions = IName.EMPTY_ARRAY;
+               IASTName firstName = nodeSelector.findEnclosingImplicitName(offset, length);
+               if (firstName != null) {
+                       IASTImplicitNameOwner owner = (IASTImplicitNameOwner) firstName.getParent();
+                       for (IASTImplicitName name : owner.getImplicitNames()) {
+                               if (((ASTNode) name).getOffset() == ((ASTNode) firstName).getOffset()) {
+                                       IBinding binding = name.resolveBinding(); // Guaranteed to resolve.
+                                       IName[] declNames = findDeclNames(ast, NameKind.REFERENCE, binding);
+                                       definitions = ArrayUtil.addAll(definitions, declNames);
+                               }
+                       }
+               }
+               return ArrayUtil.trim(definitions);
+       }
+
+       private static NameKind getNameKind(IName name) {
+               if (name.isDefinition()) {
+                       if (getBinding(name) instanceof ICPPUsingDeclaration) {
+                               return NameKind.USING_DECL;
+                       } else {
+                               return NameKind.DEFINITION;
+                       }
+               } else if (name.isDeclaration()) {
+                       return NameKind.DECLARATION;
+               }
+               return NameKind.REFERENCE;
+       }
+
+       private static IBinding getBinding(IName name) {
+               if (name instanceof IASTName) {
+                       return ((IASTName) name).resolveBinding();
+               } else if (name instanceof IIndexFragmentName) {
+                       try {
+                               return ((IIndexFragmentName) name).getBinding();
+                       } catch (CoreException e) {
+                               // Fall through to return null.
+                       }
+               }
+               return null;
+       }
+
+       private boolean areOverlappingNames(IName n1, IName n2) {
+               if (n1 == n2)
+                       return true;
+
+               IASTFileLocation loc1 = n1.getFileLocation();
+               IASTFileLocation loc2 = n2.getFileLocation();
+               if (loc1 == null || loc2 == null)
+                       return false;
+               return loc1.getFileName().equals(loc2.getFileName()) &&
+                               max(loc1.getNodeOffset(), loc2.getNodeOffset()) <
+                               min(loc1.getNodeOffset() + loc1.getNodeLength(), loc2.getNodeOffset() + loc2.getNodeLength());
+       }
+
+       private static boolean isInSameFunction(IASTName refName, IName funcDeclName) {
+               if (funcDeclName instanceof IASTName) {
+                       IASTDeclaration fdef = getEnclosingFunctionDefinition((IASTNode) funcDeclName);
+                       return fdef != null && fdef.contains(refName);
+               } 
+               return false;
+       }
+
+       private static IASTDeclaration getEnclosingFunctionDefinition(IASTNode node) {
+               while (node != null && !(node instanceof IASTFunctionDefinition)) {
+                       node= node.getParent();
+               }
+               return (IASTDeclaration) node;
+       }
+
+       private static boolean isInSameTemplate(IASTName refName, IName templateDeclName) {
+               if (templateDeclName instanceof IASTName) {
+                       IASTDeclaration template = getEnclosingTemplateDeclaration(refName);
+                       return template != null && template.contains(refName);
+               } 
+               return false;
+       }
+
+       private static IASTDeclaration getEnclosingTemplateDeclaration(IASTNode node) {
+               while (node != null && !(node instanceof ICPPASTTemplateDeclaration)) {
+                       node= node.getParent();
+               }
+               return (IASTDeclaration) node;
+       }
+
+       private void convertToCElements(ICProject project, IIndex index, IName[] declNames, List<ICElement> elements) {
+               for (IName declName : declNames) {
+                       try {
+                               ICElement elem = getCElementForName(project, index, declName);
+                               if (elem instanceof ISourceReference) {
+                                       elements.add(elem);
+                               }
+                       } catch (CoreException e) {
+                               CUIPlugin.log(e);
+                       }
+               }
+       }
+
+       private ICElementHandle getCElementForName(ICProject project, IIndex index, IName declName) throws CoreException {
+               if (declName instanceof IIndexName) {
+                       return IndexUI.getCElementForName(project, index, (IIndexName) declName);
+               }
+               if (declName instanceof IASTName) {
+                       IASTName astName = (IASTName) declName;
+                       IBinding binding= astName.resolveBinding();
+                       if (binding != null) {
+                               ITranslationUnit tu= IndexUI.getTranslationUnit(project, astName);
+                               if (tu != null) {
+                                       IASTFileLocation loc= astName.getFileLocation();
+                                       IRegion region= new Region(loc.getNodeOffset(), loc.getNodeLength());
+                                       return CElementHandleFactory.create(tu, binding, astName.isDefinition(), region, 0);
+                               }
+                       }
+                       return null;
+               }
+               return null;
+       }
+
+       private boolean navigateViaCElements(ICProject project, IIndex index, IName[] declNames) {
+               final ArrayList<ICElement> elements= new ArrayList<ICElement>();
+               convertToCElements(project, index, declNames, elements);
+               return navigateCElements(elements);
+       }
+
+       private boolean navigateCElements(List<ICElement> elements) {
+               if (elements.isEmpty()) {
+                       return false;
+               }
+
+               final List<ICElement> uniqueElements;
+               if (elements.size() < 2) {
+                       uniqueElements= elements;
+               } else {
+                       // Make sure only one element per location is proposed
+                       Set<String> sigs= new HashSet<String>();
+                       sigs.add(null);
+                       
+                       uniqueElements= new ArrayList<ICElement>();
+                       for (ICElement elem : elements) {
+                               if (sigs.add(getLocationSignature((ISourceReference) elem))) {
+                                       uniqueElements.add(elem);
+                               }
+                       }
+               }
+               
+               runInUIThread(new Runnable() {
+                       public void run() {
+                               ISourceReference target= null;
+                               if (uniqueElements.size() == 1) {
+                                       target= (ISourceReference) uniqueElements.get(0);
+                               } else {
+                                       if (OpenDeclarationsAction.sIsJUnitTest) {
+                                               throw new RuntimeException("ambiguous input: " + uniqueElements.size()); //$NON-NLS-1$
+                                       }
+                                       ICElement[] elemArray= uniqueElements.toArray(new ICElement[uniqueElements.size()]);
+                                       target = (ISourceReference) OpenActionUtil.selectCElement(elemArray, fAction.getSite().getShell(),
+                                                       CEditorMessages.OpenDeclarationsAction_dialog_title, CEditorMessages.OpenDeclarationsAction_selectMessage,
+                                                       CElementLabels.ALL_DEFAULT | CElementLabels.ALL_FULLY_QUALIFIED | CElementLabels.MF_POST_FILE_QUALIFIED, 0);
+                               }
+                               if (target != null) {
+                                       ITranslationUnit tu= target.getTranslationUnit();
+                                       ISourceRange sourceRange;
+                                       try {
+                                               sourceRange = target.getSourceRange();
+                                               if (tu != null && sourceRange != null) {
+                                                       fAction.open(tu, sourceRange.getIdStartPos(), sourceRange.getIdLength());
+                                               }
+                                       } catch (CoreException e) {
+                                               CUIPlugin.log(e);
+                                       }
+                               }
+                       }
+               });
+               return true;
+       }
+
+       private String getLocationSignature(ISourceReference elem) {
+               ITranslationUnit tu= elem.getTranslationUnit();
+               ISourceRange sourceRange;
+               try {
+                       sourceRange = elem.getSourceRange();
+                       if (tu != null && sourceRange != null) {
+                               return tu.getPath().toString() + IPath.SEPARATOR + sourceRange.getIdStartPos() + IPath.SEPARATOR + sourceRange.getIdLength();
+                       }
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }
+               return null;
+       }
+
+       private boolean navigateOneLocation(IName[] names) {
+               for (IName name : names) {
+                       if (navigateToName(name)) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+       private boolean navigateToName(IName name) {
+               return navigateToLocation(name.getFileLocation());
+       }
+
+       private boolean navigateToLocation(IASTFileLocation fileloc) {
+               if (fileloc == null) {
+                       return false;
+               }
+               final IPath path = new Path(fileloc.getFileName());
+               final int offset = fileloc.getNodeOffset();
+               final int length = fileloc.getNodeLength();
+
+               runInUIThread(new Runnable() {
+                       public void run() {
+                               try {
+                                       fAction.open(path, offset, length);
+                               } catch (CoreException e) {
+                                       CUIPlugin.log(e);
+                               }
+                       }
+               });
+               return true;
+       }
+
+       private void runInUIThread(Runnable runnable) {
+               if (Display.getCurrent() != null) {
+                       runnable.run();
+               } else {
+                       Display.getDefault().asyncExec(runnable);
+               }
+       }
+
+       private void openInclude(IASTPreprocessorIncludeStatement incStmt) {
+               String name = null;
+               if (incStmt.isResolved())
+                       name = incStmt.getPath();
+
+               if (name != null) {
+                       final IPath path = new Path(name);
+                       runInUIThread(new Runnable() {
+                               public void run() {
+                                       try {
+                                               fAction.open(path, 0, 0);
+                                       } catch (CoreException e) {
+                                               CUIPlugin.log(e);
+                                       }
+                               }
+                       });
+               } else {
+                       fAction.reportIncludeLookupFailure(new String(incStmt.getName().toCharArray()));
+               }
+       }
+
+       private boolean navigationFallBack(IASTTranslationUnit ast, IASTName sourceName, NameKind kind) {
+               // Bug 102643, as a fall-back we look up the selected word in the index.
+               if (fSelectedText != null && fSelectedText.length() > 0) {
+                       try {
+                               final ICProject project = fTranslationUnit.getCProject();
+                               final char[] name = fSelectedText.toCharArray();
+                               List<ICElement> elems= new ArrayList<ICElement>();
+       
+                               // Bug 252549, search for names in the AST first.
+                               Set<IBinding> primaryBindings= new HashSet<IBinding>();
+                               ASTNameCollector nc= new ASTNameCollector(fSelectedText);
+                               ast.accept(nc);
+                               IASTName[] candidates= nc.getNames();
+                               for (IASTName astName : candidates) {
+                                       try {
+                                               IBinding b= astName.resolveBinding();
+                                               if (b != null && !(b instanceof IProblemBinding)) {
+                                                       primaryBindings.add(b);
+                                               }
+                                       } catch (RuntimeException e) {
+                                               CUIPlugin.log(e);
+                                       }
+                               }
+
+                               // Search the index, also.
+                               final IndexFilter filter = IndexFilter.getDeclaredBindingFilter(ast.getLinkage().getLinkageID(), false);
+                               final IIndexBinding[] idxBindings = fIndex.findBindings(name, false, filter, fMonitor);
+                               for (IIndexBinding idxBinding : idxBindings) {
+                                       primaryBindings.add(idxBinding);
+                               }
+
+                               // Search for a macro in the index.
+                               IIndexMacro[] macros= fIndex.findMacros(name, filter, fMonitor);
+                               for (IIndexMacro macro : macros) {
+                                       ICElement elem= IndexUI.getCElementForMacro(project, fIndex, macro);
+                                       if (elem != null) {
+                                               elems.add(elem);
+                                       }
+                               }
+
+                               Collection<IBinding> secondaryBindings;
+                               if (ast instanceof ICPPASTTranslationUnit) {
+                                       secondaryBindings= cppRemoveSecondaryBindings(primaryBindings, sourceName);
+                               } else {
+                                       secondaryBindings= defaultRemoveSecondaryBindings(primaryBindings, sourceName);
+                               }
+
+                               // Convert bindings to CElements.
+                               Collection<IBinding> bs= primaryBindings;
+                               for (int k = 0; k < 2; k++) {
+                                       for (IBinding binding : bs) {
+                                               IName[] names = findNames(fIndex, ast, kind, binding);
+                                               // Exclude names of the same kind.
+                                               for (int i = 0; i < names.length; i++) {
+                                                       if (getNameKind(names[i]) == kind) {
+                                                               names[i] = null;
+                                                       }
+                                               }
+                                               names = (IName[]) ArrayUtil.removeNulls(IName.class, names);
+                                               convertToCElements(project, fIndex, names, elems);
+                                       }
+                                       // In case we did not find anything, consider the secondary bindings.
+                                       if (!elems.isEmpty())
+                                               break;
+                                       bs= secondaryBindings;
+                               }
+                               if (navigateCElements(elems)) {
+                                       return true;
+                               }
+                               if (sourceName != null && sourceName.isDeclaration()) {
+                                       // Select the name at the current location as the last resort.
+                                       return navigateToName(sourceName);
+                               }
+                       } catch (CoreException e) {
+                               CUIPlugin.log(e);
+                       }
+               }
+               return false;
+       }
+
+       private Collection<IBinding> defaultRemoveSecondaryBindings(Set<IBinding> primaryBindings, IASTName sourceName) {
+               if (sourceName != null) {
+                       IBinding b= sourceName.resolveBinding();
+                       if (b != null && ! (b instanceof IProblemBinding)) {
+                               try {
+                                       for (Iterator<IBinding> iterator = primaryBindings.iterator(); iterator.hasNext();) {
+                                               if (!checkOwnerNames(b, iterator.next()))
+                                                       iterator.remove();
+                                       }
+                               } catch (DOMException e) {
+                                       // Ignore
+                               }
+                       }
+               }
+               return Collections.emptyList();
+       }
+
+       private boolean checkOwnerNames(IBinding b1, IBinding b2) throws DOMException {
+               IBinding o1 = b1.getOwner();
+               IBinding o2 = b2.getOwner();
+               if (o1 == o2)
+                       return true;
+
+               if (o1 == null || o2 == null)
+                       return false;
+
+               if (!CharArrayUtils.equals(o1.getNameCharArray(), o2.getNameCharArray()))
+                       return false;
+
+               return checkOwnerNames(o1, o2);
+       }
+
+       private Collection<IBinding> cppRemoveSecondaryBindings(Set<IBinding> primaryBindings, IASTName sourceName) {
+               List<IBinding> result= new ArrayList<IBinding>();
+               String[] sourceQualifiedName= null;
+               int funcArgCount= -1;
+               if (sourceName != null) {
+                       final IBinding binding = sourceName.resolveBinding();
+                       if (binding != null) {
+                               sourceQualifiedName= CPPVisitor.getQualifiedName(binding);
+                               if (binding instanceof ICPPUnknownBinding) {
+                                       LookupData data= CPPSemantics.createLookupData(sourceName);
+                                       if (data.isFunctionCall()) {
+                                               funcArgCount= data.getFunctionArgumentCount();
+                                       }
+                               }
+                       }
+               }
+
+               for (Iterator<IBinding> iterator = primaryBindings.iterator(); iterator.hasNext();) {
+                       IBinding binding = iterator.next();
+                       if (sourceQualifiedName != null) {
+                               String[] qualifiedName = CPPVisitor.getQualifiedName(binding);
+                               if (!Arrays.equals(qualifiedName, sourceQualifiedName)) {
+                                       iterator.remove();
+                                       continue;
+                               }
+                       }
+                       if (funcArgCount != -1) {
+                               // For c++ we can check the number of parameters.
+                               if (binding instanceof ICPPFunction) {
+                                       ICPPFunction f= (ICPPFunction) binding;
+                                       if (f.getRequiredArgumentCount() > funcArgCount) {
+                                               iterator.remove();
+                                               result.add(binding);
+                                               continue;
+                                       }
+                                       if (!f.takesVarArgs() && !f.hasParameterPack()) {
+                                               final IType[] parameterTypes = f.getType().getParameterTypes();
+                                               int maxArgs= parameterTypes.length;
+                                               if (maxArgs == 1 && SemanticUtil.isVoidType(parameterTypes[0])) {
+                                                       maxArgs= 0;
+                                               }
+                                               if (maxArgs < funcArgCount) {
+                                                       iterator.remove();
+                                                       result.add(binding);
+                                                       continue;
+                                               }
+                                       }
+                               }
+                       }
+               }
+
+               return result;
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/ReferencesSearchGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/ReferencesSearchGroup.java
new file mode 100644 (file)
index 0000000..1a1d1bb
--- /dev/null
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corp. - Rational Software - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.search.actions;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.search.ui.IContextMenuConstants;
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.texteditor.ITextEditorActionConstants;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
+import org.eclipse.cdt.internal.ui.search.CSearchMessages;
+import org.eclipse.cdt.internal.ui.search.CSearchUtil;
+
+public class ReferencesSearchGroup extends ActionGroup {
+
+       private FindRefsAction fFindRefsAction;
+       private FindRefsProjectAction fFindRefsProjectAction;
+       private FindRefsInWorkingSetAction fFindRefsInWorkingSetAction;
+       
+       private CEditor fEditor;
+       private IWorkbenchSite fSite;
+       
+       public ReferencesSearchGroup(IWorkbenchSite site) {
+               fFindRefsAction= new FindRefsAction(site);
+               fFindRefsProjectAction = new FindRefsProjectAction(site);
+               fFindRefsInWorkingSetAction = new FindRefsInWorkingSetAction(site, null);
+               fSite=site;
+       }
+       
+       /**
+        * @param editor
+        */
+       public ReferencesSearchGroup(CEditor editor) {
+               fEditor = editor;
+               
+               fFindRefsAction= new FindRefsAction(editor);
+               fFindRefsAction.setActionDefinitionId(ICEditorActionDefinitionIds.FIND_REFS);
+               if (editor != null){
+                       editor.setAction(ICEditorActionDefinitionIds.FIND_REFS, fFindRefsAction);
+               }
+               fFindRefsProjectAction = new FindRefsProjectAction(editor);
+               fFindRefsInWorkingSetAction = new FindRefsInWorkingSetAction(editor, null);
+       }
+       
+       /* 
+        * Method declared on ActionGroup.
+        */
+       @Override
+       public void fillContextMenu(IMenuManager menu) {
+               
+               super.fillContextMenu(menu);
+               
+               IMenuManager incomingMenu = menu;
+               
+               IMenuManager refsMenu = new MenuManager(CSearchMessages.group_references, IContextMenuConstants.GROUP_SEARCH); 
+               
+               if (fEditor != null){
+                       menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, refsMenu);    
+               } else {
+                       incomingMenu.appendToGroup(IContextMenuConstants.GROUP_SEARCH, refsMenu);
+               }
+               
+               incomingMenu = refsMenu;
+               
+               FindAction[] actions = getWorkingSetActions();
+               incomingMenu.add(fFindRefsAction);
+               incomingMenu.add(fFindRefsProjectAction);
+               incomingMenu.add(fFindRefsInWorkingSetAction);
+               
+               for (FindAction action : actions) {
+                       incomingMenu.add(action);
+               }
+               
+       }       
+       
+       private FindAction[] getWorkingSetActions() {
+               ArrayList<FindAction> actions= new ArrayList<FindAction>(CSearchUtil.LRU_WORKINGSET_LIST_SIZE);
+               
+               Iterator<IWorkingSet[]> iter= CSearchUtil.getLRUWorkingSets().iterator();
+               while (iter.hasNext()) {
+                       IWorkingSet[] workingSets= iter.next();
+                       FindAction action;
+                       if (fEditor != null)
+                               action= new WorkingSetFindAction(fEditor, new FindRefsInWorkingSetAction(fEditor, workingSets), CSearchUtil.toString(workingSets));
+                       else
+                               action= new WorkingSetFindAction(fSite, new FindRefsInWorkingSetAction(fSite, workingSets), CSearchUtil.toString(workingSets));
+                       
+                       actions.add(action);
+               }
+               
+               return actions.toArray(new FindAction[actions.size()]);
+       }
+       
+       /* 
+        * Overrides method declared in ActionGroup
+        */
+       @Override
+       public void dispose() {
+               fFindRefsAction= null;
+               fFindRefsProjectAction=null;
+               fFindRefsInWorkingSetAction= null;
+               super.dispose();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionParseAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionParseAction.java
new file mode 100644 (file)
index 0000000..7adfed8
--- /dev/null
@@ -0,0 +1,133 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corp. - Rational Software - initial implementation
+ *     Markus Schorn (Wind River Systems)
+ *     Ed Swartz (Nokia)
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.search.actions;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import com.ibm.icu.text.MessageFormat;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.search.CSearchMessages;
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+import org.eclipse.cdt.internal.ui.util.StatusLineHandler;
+
+/**
+ * @author aniefer
+ * Created on Jun 2, 2004
+ */
+public class SelectionParseAction extends Action {
+        
+       protected IWorkbenchSite fSite;
+       protected CEditor fEditor;
+
+       public SelectionParseAction() {
+               super();
+       }
+       
+       public SelectionParseAction(CEditor editor) {
+               super();
+               fEditor= editor;
+               fSite= editor.getSite();
+       }
+       
+       public SelectionParseAction(IWorkbenchSite site) {
+               super();
+               fSite= site;
+       }
+
+       public IWorkbenchSite getSite() {
+               return fSite;
+       }
+       
+       protected void showStatusLineMessage(final String message) {
+               StatusLineHandler.showStatusLineMessage(fSite, message);
+       }
+
+       protected void clearStatusLine() {
+               StatusLineHandler.clearStatusLine(fSite);
+       }
+       
+       protected ISelection getSelection() {
+               ISelection sel = null;
+               if (fSite != null && fSite.getSelectionProvider() != null) {
+                       sel = fSite.getSelectionProvider().getSelection();
+               }
+               
+               return sel;
+       }
+       
+    protected ITextSelection getSelectedStringFromEditor() {
+        ISelection selection = getSelection();
+        if (!(selection instanceof ITextSelection)) 
+               return null;
+
+        return (ITextSelection) selection;
+    }
+    
+       protected void open(IPath path, int currentOffset, int currentLength) throws CoreException {
+               clearStatusLine();
+
+               IEditorPart editor = EditorUtility.openInEditor(path, fEditor.getInputCElement());
+               if (editor instanceof ITextEditor) {
+                       ITextEditor textEditor = (ITextEditor) editor;
+                       textEditor.selectAndReveal(currentOffset, currentLength);
+               } else {
+                       reportSourceFileOpenFailure(path);
+               }
+       }
+
+       protected void open(ITranslationUnit tu, int currentOffset, int currentLength) throws CoreException {
+               clearStatusLine();
+
+               IEditorPart editor = EditorUtility.openInEditor(tu, true);
+               if (editor instanceof ITextEditor) {
+                       ITextEditor textEditor = (ITextEditor) editor;
+                       textEditor.selectAndReveal(currentOffset, currentLength);
+               } else {
+                       reportSourceFileOpenFailure(tu.getPath());
+               }
+       }
+
+    protected void reportSourceFileOpenFailure(IPath path) {
+       showStatusLineMessage(MessageFormat.format(
+                       CSearchMessages.SelectionParseAction_FileOpenFailure_format, 
+                       new Object[] { path.toOSString() }));
+    }
+    
+    protected void reportSelectionMatchFailure() {
+       showStatusLineMessage(CSearchMessages.SelectionParseAction_SelectedTextNotSymbol_message); 
+    }
+    
+    protected void reportSymbolLookupFailure(String symbol) {
+       showStatusLineMessage(MessageFormat.format(
+                       CSearchMessages.SelectionParseAction_SymbolNotFoundInIndex_format, 
+                       new Object[] { symbol }));
+    }
+    
+    protected void reportIncludeLookupFailure(String filename) {
+       showStatusLineMessage(MessageFormat.format(
+                       CSearchMessages.SelectionParseAction_IncludeNotFound_format, 
+                       new Object[] { filename }));
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionSearchGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/SelectionSearchGroup.java
new file mode 100644 (file)
index 0000000..4b90bf4
--- /dev/null
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corp. - Rational Software - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.search.actions;
+
+import java.util.List;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.part.Page;
+
+import org.eclipse.cdt.core.model.ICElement;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+
+public class SelectionSearchGroup extends ActionGroup {
+       
+       private CEditor fEditor;
+       
+       private DeclarationsSearchGroup fDeclarationsSearchGroup;
+       private ReferencesSearchGroup fRefSearchGroup;
+       
+       public SelectionSearchGroup(CEditor editor){
+               //TODO: Assert editor not null
+               fEditor= editor;
+       
+               fDeclarationsSearchGroup= new DeclarationsSearchGroup(fEditor);
+               fRefSearchGroup = new ReferencesSearchGroup(fEditor);
+       }
+       /**
+        * @param page
+        */
+       public SelectionSearchGroup(Page page) {
+               this(page.getSite());
+       }
+       /**
+        * @param site
+        */
+       public SelectionSearchGroup(IWorkbenchSite site) {
+               fDeclarationsSearchGroup= new DeclarationsSearchGroup(site);
+               fRefSearchGroup = new ReferencesSearchGroup(site);
+       }
+       /* 
+        * Method declared on ActionGroup.
+        */
+       @Override
+       public void fillContextMenu(IMenuManager menu) {
+               super.fillContextMenu(menu);
+               
+               fDeclarationsSearchGroup.fillContextMenu(menu);
+               fRefSearchGroup.fillContextMenu(menu);
+       }       
+       
+       public static boolean canActionBeAdded(ISelection selection) {
+               if(selection instanceof ITextSelection) {
+                       return (((ITextSelection)selection).getLength() > 0);
+               }
+               return getElement(selection) != null;
+       }
+       
+       private static ICElement getElement(ISelection sel) {
+               if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
+                       List<?> list= ((IStructuredSelection)sel).toList();
+                       if (list.size() == 1) {
+                               Object element= list.get(0);
+                               if (element instanceof ICElement) {
+                                       return (ICElement)element;
+                               }
+                       }
+               }
+               return null;
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.actions.ActionGroup#dispose()
+        */
+       @Override
+       public void dispose() {
+               if (fDeclarationsSearchGroup != null) {
+                       fDeclarationsSearchGroup.dispose();
+                       fDeclarationsSearchGroup= null;
+               }
+               
+               if (fRefSearchGroup != null) {
+                       fRefSearchGroup.dispose();
+                       fRefSearchGroup= null;
+               }
+               
+               fEditor= null;
+               
+               super.dispose();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/WorkingSetFindAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/WorkingSetFindAction.java
new file mode 100644 (file)
index 0000000..b1883a0
--- /dev/null
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+/*
+ * Created on Aug 31, 2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.eclipse.cdt.internal.ui.search.actions;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.ui.IWorkbenchSite;
+
+public class WorkingSetFindAction extends FindAction {
+
+       private FindAction findAction;
+       
+       public WorkingSetFindAction(CEditor editor, FindAction action, String string) {
+               super ( editor );
+               this.findAction = action;
+               setText(string); 
+       }
+
+       public WorkingSetFindAction(IWorkbenchSite site,FindAction action, String string) {
+               super(site);
+               this.findAction = action;
+               setText(string); 
+       }
+
+       @Override
+       protected String getScopeDescription() {
+               return findAction.getScopeDescription();
+       }
+
+       @Override
+       protected ICElement[] getScope() {
+               return findAction.getScope();
+       }
+
+       @Override
+       protected int getLimitTo() {
+               return findAction.getLimitTo();
+       }
+       
+       @Override
+       public void run() {
+               findAction.run();
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCompareViewerInformationControl.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCompareViewerInformationControl.java
new file mode 100644 (file)
index 0000000..8f6a551
--- /dev/null
@@ -0,0 +1,353 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.CompareUI;
+import org.eclipse.compare.structuremergeviewer.ICompareInput;
+import org.eclipse.jface.action.ToolBarManager;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.IInformationControlExtension2;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ViewForm;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseMoveListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+/**
+ * Abstract class for "quick" compare views in light-weight controls.
+ *
+ * @since 5.0
+ */
+public abstract class AbstractCompareViewerInformationControl extends org.eclipse.jface.text.AbstractInformationControl implements IInformationControlExtension2, DisposeListener {
+
+       protected class CompareViewerControl extends ViewForm {
+               private CompareConfiguration fCompareConfiguration;
+               private Viewer fViewer;
+               public CompareViewerControl(Composite parent, int styles, CompareConfiguration cc) {
+                       super(parent, styles & ~SWT.BORDER);
+                       verticalSpacing= 0;
+                       fCompareConfiguration= cc;
+               }
+               public CompareConfiguration getCompareConfiguration() {
+                       return fCompareConfiguration;
+               }
+               public void setInput(ICompareInput input) {
+                       if (fViewer == null) {
+                               fViewer= createContentViewer(this, input, fCompareConfiguration);
+                               setContent(fViewer.getControl());
+                       }
+                       fViewer.setInput(input);
+               }
+       }
+
+       private CompareViewerControl fCompareViewerControl;
+       private ICompareInput fCompareInput;
+
+       private Color fBackgroundColor;
+       private boolean fIsSystemBackgroundColor;
+
+       private Label fTitleLabel;
+
+       /**
+        * Creates a compare viewer information control with the given shell as parent.
+        *
+        * @param parent  the parent shell
+        * @param isResizable  flag indicating whether the control is resizable
+        */
+       public AbstractCompareViewerInformationControl(Shell parent, boolean isResizable) {
+               super(parent, isResizable);
+
+               // Create all controls
+               create();
+       }
+
+       /**
+        * Creates a compare viewer information control with the given shell as parent.
+        *
+        * @param parent
+        * @param toolBarManager
+        */
+       public AbstractCompareViewerInformationControl(Shell parent, ToolBarManager toolBarManager) {
+               super(parent, toolBarManager);
+
+               // Create all controls
+               create();
+       }
+
+       private void initializeColors() {
+               RGB bgRGB= getHoverBackgroundColorRGB();
+               if (bgRGB != null) {
+                       fBackgroundColor= new Color(getShell().getDisplay(), bgRGB);
+                       fIsSystemBackgroundColor= false;
+               } else {
+                       fBackgroundColor= getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND);
+                       fIsSystemBackgroundColor= true;
+               }
+       }
+       
+       private RGB getHoverBackgroundColorRGB() {
+               IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+               return store.getBoolean(PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT)
+                       ? null
+                       : PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR);
+       }
+
+       @Override
+       protected void createContent(Composite parent) {
+               initializeColors();
+               Composite content= new Composite(parent, SWT.NONE);
+               final GridLayout gridLayout= new GridLayout();
+               gridLayout.marginWidth= 0;
+               gridLayout.marginHeight= 0;
+               gridLayout.verticalSpacing= 0;
+               content.setLayout(gridLayout);
+
+               if (hasHeader()) {
+                       createTitleLabel(content);
+               }
+               CompareConfiguration compareConfig= new CompareConfiguration();
+               compareConfig.setLeftEditable(false);
+               compareConfig.setRightEditable(false);
+               fCompareViewerControl= createCompareViewerControl(content, SWT.NONE, compareConfig);
+
+               addDisposeListener(this);
+       }
+
+       protected CompareViewerControl createCompareViewerControl(Composite parent, int style, CompareConfiguration compareConfig) {
+               CompareViewerControl compareViewer= new CompareViewerControl(parent, style, compareConfig);
+               return compareViewer;
+       }
+
+       protected Viewer createContentViewer(Composite parent, ICompareInput input, CompareConfiguration cc) {
+               return CompareUI.findContentViewer(null, input, parent, cc);
+       }
+
+       private void createTitleLabel(Composite parent) {
+               fTitleLabel= new Label(parent, SWT.LEFT);
+               fTitleLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               Label separator= new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
+               separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+               fTitleLabel.setFont(JFaceResources.getDialogFont());
+
+               Display display= parent.getDisplay();
+               Color foreground= display.getSystemColor(SWT.COLOR_TITLE_FOREGROUND);
+               Color background= display.getSystemColor(SWT.COLOR_TITLE_BACKGROUND);
+               fTitleLabel.setForeground(foreground);
+               fTitleLabel.setBackground(background);
+               
+               addMoveSupport(fTitleLabel);
+       }
+
+       public void setTitleText(String titleText) {
+               if (fTitleLabel != null) {
+                       fTitleLabel.setText(titleText);
+               }
+       }
+
+       /**
+        * Returns the compare viewer.
+        * 
+        * @return the compare viewer.
+        */
+       protected final CompareViewerControl getCompareViewer() {
+               return fCompareViewerControl;
+       }
+
+       /**
+        * Returns the compare configuration.
+        * 
+        * @return the compare configuration.
+        */
+       protected final CompareConfiguration getCompareConfiguration() {
+               return fCompareViewerControl.getCompareConfiguration();
+       }
+
+       /**
+        * Returns <code>true</code> if the control has a header, <code>false</code> otherwise.
+        * <p>
+        * The default is to return <code>false</code>.
+        * </p>
+        * 
+        * @return <code>true</code> if the control has a header
+        */
+       protected boolean hasHeader() {
+               // default is to have no header
+               return false;
+       }
+
+       @Override
+       public void setInformation(String content) {
+       }
+
+       public void setInput(Object input) {
+               if (input instanceof ICompareInput) {
+                       fCompareInput= (ICompareInput) input;
+                       if (fCompareViewerControl != null) {
+                               fCompareViewerControl.setInput(fCompareInput);
+                       }
+               } else if (input instanceof String) {
+                       // do nothing
+               } else {
+                       fCompareInput= null;
+                       if (fCompareViewerControl != null) {
+                               fCompareViewerControl.setInput(fCompareInput);
+                       }
+               }
+       }
+
+       @Override
+       public void dispose() {
+               if (!fIsSystemBackgroundColor) {
+                       fBackgroundColor.dispose();
+               }
+               super.dispose();
+       }
+
+       /**
+        * {@inheritDoc}
+        * @param event can be null
+        * <p>
+        * Subclasses may extend.
+        * </p>
+        */
+       public void widgetDisposed(DisposeEvent event) {
+               fCompareViewerControl= null;
+       }
+
+       public boolean hasContents() {
+               return fCompareViewerControl != null && fCompareInput != null;
+       }
+
+       @Override
+       public Point computeSizeHint() {
+               // compute the preferred size
+               int x= SWT.DEFAULT;
+               int y= SWT.DEFAULT;
+               Point size= getShell().computeSize(x, y);
+               Point constraints= getSizeConstraints();
+               if (constraints != null) {
+                       if (size.x < constraints.x)
+                               x= constraints.x;
+                       if (size.y < constraints.y)
+                               y= constraints.y;
+               }
+               // recompute using the constraints if the preferred size is smaller than the constraints
+               if (x != SWT.DEFAULT || y != SWT.DEFAULT)
+                       size= getShell().computeSize(x, y, false);
+
+               return size;
+       }
+
+       @Override
+       public void setFocus() {
+               super.setFocus();
+               fCompareViewerControl.setFocus();
+       }
+
+       @Override
+       public Rectangle computeTrim() {
+               Rectangle trim= super.computeTrim();
+               addInternalTrim(trim);
+               return trim;
+       }
+
+       /**
+        * Adds the internal trimmings to the given trim of the shell.
+        * 
+        * @param trim the shell's trim, will be updated
+        * @since 5.0
+        */
+       private void addInternalTrim(Rectangle trim) {
+               Rectangle textTrim= fCompareViewerControl.computeTrim(0, 0, 0, 0);
+               trim.x+= textTrim.x;
+               trim.y+= textTrim.y;
+               trim.width+= textTrim.width;
+               trim.height+= textTrim.height;
+               if (fTitleLabel != null) {
+                       trim.height+= fTitleLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
+               }
+       }
+
+       @Override
+       public Point computeSizeConstraints(int widthInChars, int heightInChars) {
+               Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
+               GC gc= new GC(fCompareViewerControl);
+               gc.setFont(font);
+               int width= gc.getFontMetrics().getAverageCharWidth();
+               int height= gc.getFontMetrics().getHeight();
+               gc.dispose();
+
+               return new Point(widthInChars * width, heightInChars * height);
+       }
+
+       @Override
+       public IInformationControlCreator getInformationPresenterControlCreator() {
+               return null;
+       }
+
+       protected final void addMoveSupport(final Control control) {
+               MouseAdapter moveSupport= new MouseAdapter() {
+                       private MouseMoveListener fMoveListener;
+                       private final Control fShell= getShell();
+
+                       @Override
+                       public void mouseDown(MouseEvent e) {
+                               Point shellLoc= fShell.getLocation();
+                               final int shellX= shellLoc.x;
+                               final int shellY= shellLoc.y;
+                               Point mouseLoc= control.toDisplay(e.x, e.y);
+                               final int mouseX= mouseLoc.x;
+                               final int mouseY= mouseLoc.y;
+                               fMoveListener= new MouseMoveListener() {
+                                       public void mouseMove(MouseEvent e2) {
+                                               Point mouseLoc2= control.toDisplay(e2.x, e2.y);
+                                               int dx= mouseLoc2.x - mouseX;
+                                               int dy= mouseLoc2.y - mouseY;
+                                               fShell.setLocation(shellX + dx, shellY + dy);
+                                       }
+                               };
+                               control.addMouseMoveListener(fMoveListener);
+                       }
+
+                       @Override
+                       public void mouseUp(MouseEvent e) {
+                               control.removeMouseMoveListener(fMoveListener);
+                               fMoveListener= null;
+                       }
+               };
+               control.addMouseListener(moveSupport);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractInformationControl.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractInformationControl.java
new file mode 100644 (file)
index 0000000..4039fdd
--- /dev/null
@@ -0,0 +1,732 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2010 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *     Patrick Hofer [bug 325488]
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.bindings.TriggerSequence;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.PopupDialog;
+import org.eclipse.jface.text.IInformationControl;
+import org.eclipse.jface.text.IInformationControlExtension;
+import org.eclipse.jface.text.IInformationControlExtension2;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseMoveListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontMetrics;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Item;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.keys.IBindingService;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IParent;
+import org.eclipse.cdt.core.parser.Keywords;
+import org.eclipse.cdt.ui.CElementGrouping;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.actions.CustomFiltersActionGroup;
+
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+import org.eclipse.cdt.internal.ui.util.StringMatcher;
+
+/**
+ * Abstract class for "quick" views in light-weight controls.
+ *
+ * @since 4.0
+ */
+public abstract class AbstractInformationControl extends PopupDialog implements IInformationControl, IInformationControlExtension, IInformationControlExtension2, DisposeListener {
+       private final String COLON_COLON = String.valueOf(Keywords.cpCOLONCOLON);
+       private final Pattern PATTERN_COLON_COLON = Pattern.compile(COLON_COLON);
+
+       /**
+        * The NamePatternFilter selects the elements which
+        * match the given string patterns.
+        */
+       protected class NamePatternFilter extends ViewerFilter {
+
+               public NamePatternFilter() {
+               }
+
+               /*
+                * Method declared on ViewerFilter.
+                */
+               @Override
+               public boolean select(Viewer viewer, Object parentElement, Object element) {
+                       StringMatcher matcher= getMatcher();
+                       if (matcher == null || !(viewer instanceof TreeViewer))
+                               return true;
+                       TreeViewer treeViewer= (TreeViewer) viewer;
+
+                       String matchName= ((ILabelProvider) treeViewer.getLabelProvider()).getText(element);
+                       if (matchName != null) {
+                               if (nameMatches(matchName, matcher))
+                                       return true;
+                       }
+
+                       return hasUnfilteredChild(treeViewer, element);
+               }
+
+               private boolean hasUnfilteredChild(TreeViewer viewer, Object element) {
+                       if (element instanceof IParent || element instanceof CElementGrouping) {
+                               Object[] children=  ((ITreeContentProvider) viewer.getContentProvider()).getChildren(element);
+                               for (Object element2 : children)
+                                       if (select(viewer, element, element2))
+                                               return true;
+                       }
+                       return false;
+               }
+       }
+
+       /** The control's text widget */
+       private Text fFilterText;
+       /** The control's tree widget */
+       private TreeViewer fTreeViewer;
+       /** The current string matcher */
+       protected StringMatcher fStringMatcher;
+
+       /**
+        * Fields that support the dialog menu
+        *  - now appended to framework menu
+        */
+       private Composite fViewMenuButtonComposite;
+
+       private CustomFiltersActionGroup fCustomFiltersActionGroup;
+
+       /**
+        * Field for tree style since it must be remembered by the instance.
+        */
+       private int fTreeStyle;
+       private Command fInvokingCommand;
+       private TriggerSequence fInvokingTriggerSequence; 
+       
+       /**
+        * Creates a tree information control with the given shell as parent. The given
+        * styles are applied to the shell and the tree widget.
+        *
+        * @param parent the parent shell
+        * @param shellStyle the additional styles for the shell
+        * @param treeStyle the additional styles for the tree widget
+        * @param invokingCommandId the id of the command that invoked this control or <code>null</code>
+        * @param showStatusField <code>true</code> if the control has a status field at the bottom
+        */
+       public AbstractInformationControl(Shell parent, int shellStyle, int treeStyle, String invokingCommandId, boolean showStatusField) {
+               super(parent, shellStyle, true, true, true, true, true, null, null);
+               if (invokingCommandId != null) {
+                       IWorkbench workbench = PlatformUI.getWorkbench();
+                       ICommandService commandSupport = (ICommandService)workbench.getAdapter(ICommandService.class);
+                       if (commandSupport != null)     {
+                               fInvokingCommand = commandSupport.getCommand(invokingCommandId);
+                               if (fInvokingCommand != null && !fInvokingCommand.isDefined())
+                                       fInvokingCommand= null;
+                               else {
+                                       IBindingService bindingService = (IBindingService) workbench.getService(IBindingService.class);
+                                       fInvokingTriggerSequence = bindingService.getBestActiveBindingFor(invokingCommandId);
+                               }
+                       }
+               }
+               fTreeStyle= treeStyle;
+               // Title and status text must be set to get the title label created, so force empty values here. 
+               if (hasHeader())
+                       setTitleText(""); //$NON-NLS-1$
+               setInfoText(""); //  //$NON-NLS-1$
+
+               // Create all controls early to preserve the life cycle of the original implementation.
+               create();
+
+               // Status field text can only be computed after widgets are created.
+               setInfoText(getStatusFieldText());
+       }
+
+       /**
+        * Create the main content for this information control.
+        * 
+        * @param parent The parent composite
+        * @return The control representing the main content.
+        * 
+        */
+       @Override
+       protected Control createDialogArea(Composite parent) {
+               fTreeViewer= createTreeViewer(parent, fTreeStyle);
+
+               fCustomFiltersActionGroup= new CustomFiltersActionGroup(getId(), fTreeViewer);
+
+               final Tree tree= fTreeViewer.getTree();
+               tree.addKeyListener(new KeyListener() {
+                       public void keyPressed(KeyEvent e)  {
+                               if (e.character == 0x1B) // ESC
+                                       dispose();
+                       }
+                       public void keyReleased(KeyEvent e) {
+                               // do nothing
+                       }
+               });
+
+               tree.addSelectionListener(new SelectionListener() {
+                       public void widgetSelected(SelectionEvent e) {
+                               // do nothing
+                       }
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               gotoSelectedElement();
+                       }
+               });
+
+               tree.addMouseMoveListener(new MouseMoveListener()        {
+                       TreeItem fLastItem= null;
+                       public void mouseMove(MouseEvent e) {
+                               if (tree.equals(e.getSource())) {
+                                       Object o= tree.getItem(new Point(e.x, e.y));
+                                       if (o instanceof TreeItem) {
+                                               if (!o.equals(fLastItem)) {
+                                                       fLastItem= (TreeItem)o;
+                                                       tree.setSelection(new TreeItem[] { fLastItem });
+                                               } else if (e.y < tree.getItemHeight() / 4) {
+                                                       // Scroll up
+                                                       Point p= tree.toDisplay(e.x, e.y);
+                                                       Item item= fTreeViewer.scrollUp(p.x, p.y);
+                                                       if (item instanceof TreeItem) {
+                                                               fLastItem= (TreeItem)item;
+                                                               tree.setSelection(new TreeItem[] { fLastItem });
+                                                       }
+                                               } else if (e.y > tree.getBounds().height - tree.getItemHeight() / 4) {
+                                                       // Scroll down
+                                                       Point p= tree.toDisplay(e.x, e.y);
+                                                       Item item= fTreeViewer.scrollDown(p.x, p.y);
+                                                       if (item instanceof TreeItem) {
+                                                               fLastItem= (TreeItem)item;
+                                                               tree.setSelection(new TreeItem[] { fLastItem });
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               });
+
+               tree.addMouseListener(new MouseAdapter() {
+                       @Override
+                       public void mouseUp(MouseEvent e) {
+
+                               if (tree.getSelectionCount() < 1)
+                                       return;
+
+                               if (e.button != 1)
+                                       return;
+
+                               if (tree.equals(e.getSource())) {
+                                       Object o= tree.getItem(new Point(e.x, e.y));
+                                       TreeItem selection= tree.getSelection()[0];
+                                       if (selection.equals(o))
+                                               gotoSelectedElement();
+                               }
+                       }
+               });
+
+               installFilter();
+
+               addDisposeListener(this);
+               return fTreeViewer.getControl();
+       }
+       
+       /**
+        * Creates a tree information control with the given shell as parent. The given
+        * styles are applied to the shell and the tree widget.
+        *
+        * @param parent the parent shell
+        * @param shellStyle the additional styles for the shell
+        * @param treeStyle the additional styles for the tree widget
+        */
+       public AbstractInformationControl(Shell parent, int shellStyle, int treeStyle) {
+               this(parent, shellStyle, treeStyle, null, false);
+       }
+
+       protected abstract TreeViewer createTreeViewer(Composite parent, int style);
+
+       /**
+        * Returns the name of the dialog settings section.
+        *
+        * @return the name of the dialog settings section
+        */
+       protected abstract String getId();
+
+       protected TreeViewer getTreeViewer() {
+               return fTreeViewer;
+       }
+
+       /**
+        * Returns <code>true</code> if the control has a header, <code>false</code> otherwise.
+        * <p>
+        * The default is to return <code>false</code>.
+        * </p>
+        * 
+        * @return <code>true</code> if the control has a header
+        */
+       protected boolean hasHeader() {
+               // default is to have no header
+               return false;
+       }
+
+       protected Text getFilterText() {
+               return fFilterText;
+       }
+
+       protected Text createFilterText(Composite parent) {
+               fFilterText= new Text(parent, SWT.NONE);
+
+               GridData data= new GridData(GridData.FILL_HORIZONTAL);
+               GC gc= new GC(parent);
+               gc.setFont(parent.getFont());
+               FontMetrics fontMetrics= gc.getFontMetrics();
+               gc.dispose();
+
+               data.heightHint= Dialog.convertHeightInCharsToPixels(fontMetrics, 1);
+               data.horizontalAlignment= GridData.FILL;
+               data.verticalAlignment= GridData.CENTER;
+               fFilterText.setLayoutData(data);
+
+               fFilterText.addKeyListener(new KeyListener() {
+                       public void keyPressed(KeyEvent e) {
+                               if (e.keyCode == 0x0D) // return
+                                       gotoSelectedElement();
+                               if (e.keyCode == SWT.ARROW_DOWN)
+                                       fTreeViewer.getTree().setFocus();
+                               if (e.keyCode == SWT.ARROW_UP)
+                                       fTreeViewer.getTree().setFocus();
+                               if (e.character == 0x1B) // ESC
+                                       dispose();
+                       }
+                       public void keyReleased(KeyEvent e) {
+                               // do nothing
+                       }
+               });
+
+               return fFilterText;
+       }
+
+       protected void updateStatusFieldText() {
+               setInfoText(getStatusFieldText());
+       }
+       
+       protected String getStatusFieldText() {
+               return ""; //$NON-NLS-1$
+       }
+
+       private void installFilter() {
+               fFilterText.setText(""); //$NON-NLS-1$
+
+               fFilterText.addModifyListener(new ModifyListener() {
+                       public void modifyText(ModifyEvent e) {
+                               String text= ((Text) e.widget).getText();
+                               int length= text.length();
+                               if (length > 0 && text.charAt(length -1 ) != '*') {
+                                       text= text + '*';
+                               }
+                               setMatcherString(text, true);
+                       }
+               });
+       }
+
+       /**
+        * The string matcher has been modified. The default implementation
+        * refreshes the view and selects the first matched element
+        */
+       protected void stringMatcherUpdated() {
+               // refresh viewer to re-filter
+               fTreeViewer.getControl().setRedraw(false);
+               fTreeViewer.refresh();
+               fTreeViewer.expandAll();
+               selectFirstMatch();
+               fTreeViewer.getControl().setRedraw(true);
+       }
+
+       /**
+        * Sets the patterns to filter out for the receiver.
+        * <p>
+        * The following characters have special meaning:
+        *   ? => any character
+        *   * => any string
+        * </p>
+        *
+        * @param pattern the pattern
+        * @param update <code>true</code> if the viewer should be updated
+        */
+       protected void setMatcherString(String pattern, boolean update) {
+               if (pattern.length() == 0) {
+                       fStringMatcher= null;
+               } else {
+                       boolean ignoreCase= pattern.toLowerCase().equals(pattern);
+                       fStringMatcher= new StringMatcher(pattern, ignoreCase, false);
+               }
+               
+               if (update)
+                       stringMatcherUpdated();
+       }
+
+       protected StringMatcher getMatcher() {
+               return fStringMatcher;
+       }
+
+       /**
+        * Implementers can modify
+        *
+        * @return the selected element
+        */
+       protected Object getSelectedElement() {
+               if (fTreeViewer == null)
+                       return null;
+
+               return ((IStructuredSelection) fTreeViewer.getSelection()).getFirstElement();
+       }
+
+       private void gotoSelectedElement() {
+               Object selectedElement= getSelectedElement();
+               if (selectedElement != null) {
+                       try {
+                               dispose();
+                               IEditorPart part= EditorUtility.openInEditor(selectedElement, true);
+                               if (part != null && selectedElement instanceof ICElement)
+                                       EditorUtility.revealInEditor(part, (ICElement) selectedElement);
+                       } catch (CoreException ex) {
+                               CUIPlugin.log(ex);
+                       }
+               }
+       }
+
+       /**
+        * Selects the first element in the tree which
+        * matches the current filter pattern.
+        */
+       protected void selectFirstMatch() {
+               Tree tree= fTreeViewer.getTree();
+               Object element= findElement(tree.getItems());
+               if (element != null)
+                       fTreeViewer.setSelection(new StructuredSelection(element), true);
+               else
+                       fTreeViewer.setSelection(StructuredSelection.EMPTY);
+       }
+
+       private ICElement findElement(TreeItem[] items) {
+               ILabelProvider labelProvider= (ILabelProvider)fTreeViewer.getLabelProvider();
+               for (TreeItem treeItem : items) {
+                       Object data= treeItem.getData();
+                       ICElement element= null;
+                       if (data instanceof ICElement) {
+                               element= (ICElement)data;
+                               if (fStringMatcher == null)
+                                       return element;
+       
+                               String label= labelProvider.getText(element);
+                               if (label != null && nameMatches(label, fStringMatcher))
+                                       return element;
+                       }
+                       element= findElement(treeItem.getItems());
+                       if (element != null)
+                               return element;
+               }
+               return null;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void setInformation(String information) {
+               // this method is ignored, see IInformationControlExtension2
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public abstract void setInput(Object information);
+
+       /**
+        * Fills the view menu.
+        * Clients can extend or override.
+        *
+        * @param viewMenu the menu manager that manages the menu
+        */
+       protected void fillViewMenu(IMenuManager viewMenu) {
+               fCustomFiltersActionGroup.fillViewMenu(viewMenu);
+       }
+
+       /*
+        * Overridden to call the old framework method.
+        * 
+        * @see org.eclipse.jface.dialogs.PopupDialog#fillDialogMenu(IMenuManager)
+        * 
+        */
+       @Override
+       protected void fillDialogMenu(IMenuManager dialogMenu) {
+               super.fillDialogMenu(dialogMenu);
+               fillViewMenu(dialogMenu);
+       }
+
+       protected void inputChanged(Object newInput, Object newSelection) {
+               fFilterText.setText(""); //$NON-NLS-1$
+               fTreeViewer.setInput(newInput);
+               if (newSelection != null) {
+                       fTreeViewer.setSelection(new StructuredSelection(newSelection));
+               }
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void setVisible(boolean visible) {
+               if (visible) {
+                       open();
+               } else {
+                       saveDialogBounds(getShell());
+                       getShell().setVisible(false);
+               }
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public final void dispose() {
+               close();
+       }
+
+       /**
+        * {@inheritDoc}
+        * @param event can be null
+        * <p>
+        * Subclasses may extend.
+        * </p>
+        */
+       public void widgetDisposed(DisposeEvent event) {
+               fTreeViewer= null;
+               fFilterText= null;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public boolean hasContents() {
+               return fTreeViewer != null && fTreeViewer.getInput() != null;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void setSizeConstraints(int maxWidth, int maxHeight) {
+               // ignore
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public Point computeSizeHint() {
+               // return the shell's size - note that it already has the persisted size if persisting
+               // is enabled.
+               return getShell().getSize();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void setLocation(Point location) {
+               /*
+                * If the location is persisted, it gets managed by PopupDialog - fine. Otherwise, the location is
+                * computed in Window#getInitialLocation, which will center it in the parent shell / main
+                * monitor, which is wrong for two reasons:
+                * - we want to center over the editor / subject control, not the parent shell
+                * - the center is computed via the initalSize, which may be also wrong since the size may 
+                *   have been updated since via min/max sizing of AbstractInformationControlManager.
+                * In that case, override the location with the one computed by the manager. Note that
+                * the call to constrainShellSize in PopupDialog.open will still ensure that the shell is
+                * entirely visible.
+                */
+               if (!getPersistLocation() || getDialogSettings() == null)
+                       getShell().setLocation(location);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void setSize(int width, int height) {
+               getShell().setSize(width, height);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void addDisposeListener(DisposeListener listener) {
+               getShell().addDisposeListener(listener);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void removeDisposeListener(DisposeListener listener) {
+               getShell().removeDisposeListener(listener);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void setForegroundColor(Color foreground) {
+               applyForegroundColor(foreground, getContents());
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void setBackgroundColor(Color background) {
+               applyBackgroundColor(background, getContents());
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public boolean isFocusControl() {
+               return fTreeViewer.getControl().isFocusControl() || fFilterText.isFocusControl();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void setFocus() {
+               getShell().forceFocus();
+               fFilterText.setFocus();
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void addFocusListener(FocusListener listener) {
+               getShell().addFocusListener(listener);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void removeFocusListener(FocusListener listener) {
+               getShell().removeFocusListener(listener);
+       }
+
+       final protected Command getInvokingCommand() {
+               return fInvokingCommand;
+       }
+       
+       final protected TriggerSequence getInvokingCommandTriggerSequence() {
+               return fInvokingTriggerSequence;
+       }
+       
+       /*
+        * @see org.eclipse.jface.dialogs.PopupDialog#getDialogSettings()
+        */
+       @Override
+       protected IDialogSettings getDialogSettings() {
+               String sectionName= getId();
+
+               IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings().getSection(sectionName);
+               if (settings == null)
+                       settings= CUIPlugin.getDefault().getDialogSettings().addNewSection(sectionName);
+
+               return settings;
+       }
+       
+       /*
+        * Overridden to insert the filter text into the title and menu area.
+        */
+       @Override
+       protected Control createTitleMenuArea(Composite parent) {
+               fViewMenuButtonComposite= (Composite) super.createTitleMenuArea(parent);
+
+               // If there is a header, then the filter text must be created
+               // underneath the title and menu area.
+
+               if (hasHeader()) {
+                       fFilterText= createFilterText(parent);
+               }
+
+               return fViewMenuButtonComposite;
+       }
+
+       /*
+        * Overridden to insert the filter text into the title control
+        * if there is no header specified.
+        * 
+        */
+       @Override
+       protected Control createTitleControl(Composite parent) {
+               if (hasHeader()) {
+                       return super.createTitleControl(parent);
+               }
+               fFilterText= createFilterText(parent);
+               return fFilterText;
+       }
+       
+       /*
+        * @see org.eclipse.jface.dialogs.PopupDialog#setTabOrder(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected void setTabOrder(Composite composite) {
+               if (hasHeader()) {
+                       composite.setTabList(new Control[] { fFilterText, fTreeViewer.getTree() });
+               } else {
+                       fViewMenuButtonComposite.setTabList(new Control[] { fFilterText });
+                       composite.setTabList(new Control[] { fViewMenuButtonComposite, fTreeViewer.getTree() });
+               }
+       }
+
+       /**
+        * Checks whether a given name is selected by the matcher
+        */
+       boolean nameMatches(String name, StringMatcher matcher) {
+               if (matcher.match(name))
+                       return true;
+               
+               Matcher match = PATTERN_COLON_COLON.matcher(name);
+               while(match.find())     {
+                       int idx = match.start();
+                       if (matcher.match(name.substring(idx+COLON_COLON.length())))
+                               return true;
+               }
+
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractSourceViewerInformationControl.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractSourceViewerInformationControl.java
new file mode 100644 (file)
index 0000000..5a379c0
--- /dev/null
@@ -0,0 +1,271 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IInformationControlExtension2;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+import org.eclipse.cdt.internal.ui.editor.CSourceViewer;
+
+/**
+ * Abstract class for "quick" source views in light-weight controls.
+ *
+ * @since 5.0
+ */
+public abstract class AbstractSourceViewerInformationControl extends org.eclipse.jface.text.AbstractInformationControl implements IInformationControlExtension2, DisposeListener {
+
+       private ISourceViewer fSourceViewer;
+
+       private Color fBackgroundColor;
+
+       private boolean fIsSystemBackgroundColor;
+
+       private Font fTextFont;
+
+       private StyledText fText;
+
+       private Label fTitleLabel;
+
+       /**
+        * Creates a source viewer information control with the given shell as parent. The given
+        * styles are applied to the shell and the source viewer.
+        *
+        * @param parent  the parent shell
+        * @param statusFieldText
+        */
+       public AbstractSourceViewerInformationControl(Shell parent, String statusFieldText) {
+               super(parent, statusFieldText);
+               // Create all controls
+               create();
+       }
+
+       /**
+        * Creates a source viewer information control with the given shell as parent. The given
+        * styles are applied to the shell and the source viewer.
+        *
+        * @param parent  the parent shell
+        * @param isResizable  whether the control should be resizable
+        */
+       public AbstractSourceViewerInformationControl(Shell parent, boolean isResizable) {
+               super(parent, isResizable);
+               // Create all controls
+               create();
+       }
+
+       /**
+        * @return <code>true</code> if the control should have a title label
+        */
+       protected boolean hasHeader() {
+               return false;
+       }
+
+       private void initializeColors() {
+               RGB bgRGB= getHoverBackgroundColorRGB();
+               if (bgRGB != null) {
+                       fBackgroundColor= new Color(getShell().getDisplay(), bgRGB);
+                       fIsSystemBackgroundColor= false;
+               } else {
+                       fBackgroundColor= getShell().getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND);
+                       fIsSystemBackgroundColor= true;
+               }
+       }
+       
+       private RGB getHoverBackgroundColorRGB() {
+               IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+               return store.getBoolean(PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT)
+                       ? null
+                       : PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR);
+       }
+
+       @Override
+       public void createContent(Composite parent) {
+               Composite content= new Composite(parent, SWT.NONE);
+               final GridLayout gridLayout= new GridLayout();
+               gridLayout.marginWidth= 0;
+               gridLayout.marginHeight= 0;
+               gridLayout.verticalSpacing= 0;
+               content.setLayout(gridLayout);
+
+               if (hasHeader()) {
+                       createTitleLabel(content);
+               }
+               fSourceViewer= createSourceViewer(content, SWT.NONE);
+
+               final StyledText text= fSourceViewer.getTextWidget();
+               text.addKeyListener(new KeyListener() {
+                       public void keyPressed(KeyEvent e)  {
+                               if (e.character == 0x1B) // ESC
+                                       dispose();
+                       }
+                       public void keyReleased(KeyEvent e) {
+                               // do nothing
+                       }
+               });
+
+               addDisposeListener(this);
+       }
+       
+       protected final ISourceViewer createSourceViewer(Composite parent, int style) {
+               IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
+               SourceViewer sourceViewer= new CSourceViewer(parent, null, null, false, style, store);
+               CTextTools tools= CUIPlugin.getDefault().getTextTools();
+               sourceViewer.configure(new SimpleCSourceViewerConfiguration(tools.getColorManager(), store, null, ICPartitions.C_PARTITIONING, false));
+               sourceViewer.setEditable(false);
+
+               fText= sourceViewer.getTextWidget();
+               GridData gd= new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
+               fText.setLayoutData(gd);
+               initializeColors();
+               fText.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
+               fText.setBackground(fBackgroundColor);
+               
+               fTextFont= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
+               fText.setFont(fTextFont);
+
+               return sourceViewer;
+       }
+
+       private void createTitleLabel(Composite parent) {
+               fTitleLabel= new Label(parent, SWT.LEFT);
+               fTitleLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               Label separator= new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
+               separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+               fTitleLabel.setFont(JFaceResources.getDialogFont());
+
+               Display display= parent.getDisplay();
+               Color foreground= display.getSystemColor(SWT.COLOR_INFO_FOREGROUND);
+               Color background= display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
+               fTitleLabel.setForeground(foreground);
+               fTitleLabel.setBackground(background);
+       }
+
+       public void setTitleText(String titleText) {
+               if (fTitleLabel != null) {
+                       fTitleLabel.setText(titleText);
+               }
+       }
+
+       /**
+        * Returns the source viewer.
+        * 
+        * @return the source viewer.
+        */
+       protected final ISourceViewer getSourceViewer() {
+               return fSourceViewer;
+       }
+
+       @Override
+       public void setInformation(String content) {
+               if (content == null) {
+                       fSourceViewer.setDocument(null);
+                       return;
+               }
+
+               IDocument doc= new Document(content);
+               CUIPlugin.getDefault().getTextTools().setupCDocument(doc);
+               fSourceViewer.setDocument(doc);
+       }
+
+       public void setInput(Object input) {
+               if (input instanceof String)
+                       setInformation((String)input);
+               else
+                       setInformation(null);
+       }
+
+       @Override
+       public final void dispose() {
+               if (!fIsSystemBackgroundColor) {
+                       fBackgroundColor.dispose();
+               }
+               super.dispose();
+       }
+
+       /**
+        * {@inheritDoc}
+        * @param event can be null
+        * <p>
+        * Subclasses may extend.
+        * </p>
+        */
+       public void widgetDisposed(DisposeEvent event) {
+               fSourceViewer= null;
+       }
+
+       public boolean hasContents() {
+               return fSourceViewer != null && fSourceViewer.getDocument() != null;
+       }
+
+       @Override
+       public void setFocus() {
+               super.setFocus();
+               fSourceViewer.getTextWidget().setFocus();
+       }
+
+       @Override
+       public Point computeSizeConstraints(int widthInChars, int heightInChars) {
+               GC gc= new GC(fText);
+               gc.setFont(fTextFont);
+               int width= gc.getFontMetrics().getAverageCharWidth();
+               int height= gc.getFontMetrics().getHeight();
+               gc.dispose();
+
+               return new Point(widthInChars * width, heightInChars * height);
+       }
+
+       @Override
+       public Point computeSizeHint() {
+               // compute the preferred size
+               int x= SWT.DEFAULT;
+               int y= SWT.DEFAULT;
+               Point size= getShell().computeSize(x, y);
+               Point constraints= getSizeConstraints();
+               if (constraints != null) {
+                       if (size.x > constraints.x)
+                               x= constraints.x;
+                       if (size.y > constraints.y)
+                               y= constraints.y;
+               }
+               // recompute using the constraints if the preferred size is larger than the constraints
+               if (x != SWT.DEFAULT || y != SWT.DEFAULT)
+                       size= getShell().computeSize(x, y, false);
+
+               return size;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/BufferedDocumentScanner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/BufferedDocumentScanner.java
new file mode 100644 (file)
index 0000000..1736bb2
--- /dev/null
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.core.runtime.Assert;
+
+/**
+ * A buffered document scanner. The buffer always contains a section 
+ * of a fixed size of the document to be scanned.
+ */
+public final class BufferedDocumentScanner implements ICharacterScanner {
+
+    /** The document being scanned. */
+    private IDocument fDocument;
+    /** The offset of the document range to scan. */
+    private int fRangeOffset;
+    /** The length of the document range to scan. */
+    private int fRangeLength;
+    /** The delimiters of the document. */
+    private char[][] fDelimiters;
+    
+    /** The buffer. */
+    private final char[] fBuffer;
+    /** The offset of the buffer within the document. */
+    private int fBufferOffset;
+    /** The valid length of the buffer for access. */
+    private int fBufferLength;
+    /** The offset of the scanner within the buffer. */
+    private int fOffset;
+    
+    /**
+     * Creates a new buffered document scanner.
+     * The buffer size is set to the given number of characters.
+     *
+     * @param size the buffer size
+     */
+    public BufferedDocumentScanner(int size) {
+        Assert.isTrue(size >= 1);
+        fBuffer= new char[size];
+    }
+    
+    /**
+     * Fills the buffer with the contents of the document starting at the given offset.
+     *
+     * @param offset the document offset at which the buffer starts
+     */
+    private final void updateBuffer(int offset) {
+        
+        // Clamp at start of the file document range
+        if (offset < 0)
+            offset = 0;
+
+        fBufferOffset= offset;
+        fBufferLength= fBuffer.length;
+        
+        // assert(offset >= fRangeOffset && offset < fRangeOffset + fRangeLength);
+
+        if (fBufferOffset + fBufferLength > fRangeOffset + fRangeLength)
+            fBufferLength= fRangeOffset + fRangeLength - fBufferOffset;
+                
+        try {
+            final String content= fDocument.get(fBufferOffset, fBufferLength);
+            content.getChars(0, fBufferLength, fBuffer, 0);
+            
+        } catch (BadLocationException e) {
+        }
+    }
+    
+    /**
+     * Configures the scanner by providing access to the document range over which to scan.
+     *
+     * @param document the document to scan
+     * @param offset the offset of the document range to scan
+     * @param length the length of the document range to scan
+     */
+    public final void setRange(IDocument document, int offset, int length) {
+
+        fDocument= document;
+        fRangeOffset= offset;
+        fRangeLength= length;
+        
+        // Clamp at end of the real document
+        if (fRangeLength + fRangeOffset > fDocument.getLength())
+            fRangeLength = fDocument.getLength() - fRangeOffset;
+
+        String[] delimiters= document.getLegalLineDelimiters();
+        fDelimiters= new char[delimiters.length][];
+        for (int i= 0; i < delimiters.length; i++)
+            fDelimiters[i]= delimiters[i].toCharArray();
+
+        updateBuffer(offset);
+        fOffset= 0;
+    }
+    
+    /*
+     * @see ICharacterScanner#read()
+     */
+    public final int read() {
+        
+        if (fOffset >= fBufferLength) {
+            if (fBufferOffset + fBufferLength >= fRangeOffset + fRangeLength)
+                return EOF;
+            updateBuffer(fBufferOffset + fBufferLength);
+            fOffset= 0;
+        }
+                    
+        return fBuffer[fOffset++];
+    }
+    
+    /*
+     * @see ICharacterScanner#unread
+     */
+    public final void unread() {
+
+        if (fOffset <= 0) {
+            if (fBufferOffset <= fRangeOffset) {
+                // error: BOF
+            } else {
+                updateBuffer(fBufferOffset - fBuffer.length);
+                fOffset = fBuffer.length - 1; // should always be a valid place
+            }
+        } else {            
+            --fOffset;
+        }
+    }
+
+    /*
+     * @see ICharacterScanner#getColumn()
+     */
+    public final int getColumn() {
+
+        try {
+            final int offset= fBufferOffset + fOffset;
+            final int line= fDocument.getLineOfOffset(offset);
+            final int start= fDocument.getLineOffset(line);
+                
+            return offset - start;
+                
+        } catch (BadLocationException e) {
+        }
+
+        return -1;
+    }
+
+    /*
+     * @see ICharacterScanner#getLegalLineDelimiters()
+     */
+    public final char[][] getLegalLineDelimiters() {
+        return fDelimiters;
+    }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CAutoIndentStrategy.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CAutoIndentStrategy.java
new file mode 100644 (file)
index 0000000..2bfb8fa
--- /dev/null
@@ -0,0 +1,1233 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *     Andrew Ferguson (Symbian)
+ *     Andrew Gvozdev
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.DocumentCommand;
+import org.eclipse.jface.text.DocumentRewriteSession;
+import org.eclipse.jface.text.DocumentRewriteSessionType;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.text.rules.FastPartitioner;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.part.MultiPageEditorPart;
+import org.eclipse.ui.texteditor.ITextEditorExtension3;
+
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
+
+import org.eclipse.cdt.internal.ui.editor.IndentUtil;
+
+/**
+ * Auto indent strategy sensitive to brackets.
+ */
+public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
+       /** The line comment introducer. Value is "{@value}" */
+       private static final String LINE_COMMENT= "//"; //$NON-NLS-1$
+//     private static final GCCScannerExtensionConfiguration C_GNU_SCANNER_EXTENSION = new GCCScannerExtensionConfiguration();
+
+//     private static class CompilationUnitInfo {
+//             char[] buffer;
+//             int delta;
+//
+//             CompilationUnitInfo(char[] buffer, int delta) {
+//                     this.buffer = buffer;
+//                     this.delta = delta;
+//             }
+//     }
+
+       private boolean fCloseBrace;
+       private boolean fIsSmartMode;
+
+       private String fPartitioning;
+       private final ICProject fProject;
+
+       /**
+        * Creates a new C auto indent strategy for the given document partitioning.
+        *
+        * @param partitioning the document partitioning
+        * @param project the project to get formatting preferences from, or null to use default preferences
+        */
+       public CAutoIndentStrategy(String partitioning, ICProject project) {
+               fPartitioning = partitioning;
+               fProject = project;
+       }
+
+       private int getBracketCount(IDocument d, int start, int end, boolean ignoreCloseBrackets) throws BadLocationException {
+               int bracketcount = 0;
+               while (start < end) {
+                       char curr = d.getChar(start);
+                       start++;
+                       switch (curr) {
+                               case '/' :
+                                       if (start < end) {
+                                               char next = d.getChar(start);
+                                               if (next == '*') {
+                                                       // a comment starts, advance to the comment end
+                                                       start = getCommentEnd(d, start + 1, end);
+                                               } else if (next == '/') {
+                                                       // '//'-comment: nothing to do anymore on this line
+                                                       start = end;
+                                               }
+                                       }
+                                       break;
+                               case '*' :
+                                       if (start < end) {
+                                               char next = d.getChar(start);
+                                               if (next == '/') {
+                                                       // we have been in a comment: forget what we read before
+                                                       bracketcount = 0;
+                                                       start++;
+                                               }
+                                       }
+                                       break;
+                               case '{' :
+                                       bracketcount++;
+                                       ignoreCloseBrackets = false;
+                                       break;
+                               case '}' :
+                                       if (!ignoreCloseBrackets) {
+                                               bracketcount--;
+                                       }
+                                       break;
+                               case '"' :
+                               case '\'' :
+                                       start = getStringEnd(d, start, end, curr);
+                                       break;
+                               default :
+                       }
+               }
+               return bracketcount;
+       }
+
+       // ----------- bracket counting ------------------------------------------------------
+
+       private int getCommentEnd(IDocument d, int pos, int end) throws BadLocationException {
+               while (pos < end) {
+                       char curr = d.getChar(pos);
+                       pos++;
+                       if (curr == '*') {
+                               if (pos < end && d.getChar(pos) == '/') {
+                                       return pos + 1;
+                               }
+                       }
+               }
+               return end;
+       }
+
+       private String getIndentOfLine(IDocument d, int line) throws BadLocationException {
+               if (line > -1) {
+                       int start = d.getLineOffset(line);
+                       int end = start + d.getLineLength(line) - 1;
+                       int whiteend = findEndOfWhiteSpace(d, start, end);
+                       return d.get(start, whiteend - start);
+               }
+               return ""; //$NON-NLS-1$
+       }
+
+       private int getStringEnd(IDocument d, int pos, int end, char ch) throws BadLocationException {
+               while (pos < end) {
+                       char curr = d.getChar(pos);
+                       pos++;
+                       if (curr == '\\') {
+                               // ignore escaped characters
+                               pos++;
+                       } else if (curr == ch) {
+                               return pos;
+                       }
+               }
+               return end;
+       }
+
+       private void smartIndentAfterClosingBracket(IDocument d, DocumentCommand c) {
+               if (c.offset == -1 || d.getLength() == 0)
+                       return;
+
+               try {
+                       int p = (c.offset == d.getLength() ? c.offset - 1 : c.offset);
+                       int line = d.getLineOfOffset(p);
+                       int start = d.getLineOffset(line);
+                       int whiteend = findEndOfWhiteSpace(d, start, c.offset);
+
+                       CHeuristicScanner scanner= new CHeuristicScanner(d);
+                       ITypedRegion partition= TextUtilities.getPartition(d, fPartitioning, p, false);
+                       if (ICPartitions.C_PREPROCESSOR.equals(partition.getType())) {
+                               scanner = new CHeuristicScanner(d, fPartitioning, ICPartitions.C_PREPROCESSOR);
+                       }
+                       CIndenter indenter = new CIndenter(d, scanner, fProject);
+
+                       // shift only when line does not contain any text up to the closing bracket
+                       if (whiteend == c.offset) {
+                               // evaluate the line with the opening bracket that matches out closing bracket
+                               int reference = indenter.findReferencePosition(c.offset, false, true, false, false, false);
+                               int indLine = d.getLineOfOffset(reference);
+                               if (indLine != -1 && indLine != line) {
+                                       // take the indent of the found line
+                                       StringBuilder replaceText = new StringBuilder(getIndentOfLine(d, indLine));
+                                       // add the rest of the current line including the just added close bracket
+                                       replaceText.append(d.get(whiteend, c.offset - whiteend));
+                                       replaceText.append(c.text);
+                                       // modify document command
+                                       c.length += c.offset - start;
+                                       c.offset = start;
+                                       c.text = replaceText.toString();
+                               }
+                       }
+               } catch (BadLocationException e) {
+                       CUIPlugin.log(e);
+               }
+       }
+
+       private void smartIndentAfterOpeningBracket(IDocument d, DocumentCommand c) {
+               if (c.offset < 1 || d.getLength() == 0)
+                       return;
+
+               int p = (c.offset == d.getLength() ? c.offset - 1 : c.offset);
+
+               try {
+                       CHeuristicScanner scanner= new CHeuristicScanner(d);
+                       ITypedRegion partition= TextUtilities.getPartition(d, fPartitioning, p, false);
+                       if (ICPartitions.C_PREPROCESSOR.equals(partition.getType())) {
+                               scanner = new CHeuristicScanner(d, fPartitioning, ICPartitions.C_PREPROCESSOR);
+                       }
+                       // current line
+                       int line = d.getLineOfOffset(c.offset);
+                       int lineOffset = d.getLineOffset(line);
+
+                       // make sure we don't have any leading comments etc.
+                       if (d.get(lineOffset, c.offset - lineOffset).trim().length() != 0)
+                               return;
+
+                       // Line of last C code
+                       int pos = scanner.findNonWhitespaceBackward(p, CHeuristicScanner.UNBOUND);
+                       if (pos == -1)
+                               return;
+                       int lastLine = d.getLineOfOffset(pos);
+
+                       // Only shift if the last C line is further up and is a braceless block candidate
+                       if (lastLine < line) {
+                               CIndenter indenter = new CIndenter(d, scanner, fProject);
+                               StringBuilder indent = indenter.computeIndentation(p, true);
+                               String toDelete = d.get(lineOffset, c.offset - lineOffset);
+                               if (indent != null && !indent.toString().equals(toDelete)) {
+                                       c.text = indent.append(c.text).toString();
+                                       c.length += c.offset - lineOffset;
+                                       c.offset = lineOffset;
+                               }
+                       }
+               } catch (BadLocationException e) {
+                       CUIPlugin.log(e);
+               }
+       }
+
+       private void smartIndentAfterNewLine(IDocument d, DocumentCommand c) {
+               int docLength = d.getLength();
+               if (c.offset == -1 || docLength == 0)
+                       return;
+
+               int addIndent= 0;
+               CHeuristicScanner scanner= new CHeuristicScanner(d);
+               try {
+                       ITypedRegion partition= TextUtilities.getPartition(d, fPartitioning, c.offset, false);
+                       if (ICPartitions.C_PREPROCESSOR.equals(partition.getType()) && c.offset > 0 && d.getChar(c.offset-1) == '\\') {
+                               scanner = new CHeuristicScanner(d, fPartitioning, ICPartitions.C_PREPROCESSOR);
+                               addIndent= 1;
+                       }
+
+                       int line = d.getLineOfOffset(c.offset);
+                       IRegion reg = d.getLineInformation(line);
+                       int start = reg.getOffset();
+                       int lineEnd = start + reg.getLength();
+
+                       StringBuilder indent= null;
+                       CIndenter indenter= new CIndenter(d, scanner, fProject);
+                       if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_AUTO_INDENT)) {
+                               indent= indenter.computeIndentation(c.offset);
+                       } else {
+                               // reuse existing indent
+                               int wsEnd= findEndOfWhiteSpace(d, start, c.offset);
+                               if (wsEnd > start) {
+                                       indent= new StringBuilder(d.get(start, wsEnd - start));
+                                       addIndent= 0;
+                               }
+                       }
+                       if (indent == null) {
+                               indent= new StringBuilder();
+                       }
+                       if (addIndent > 0 && indent.length() == 0) {
+                               indent= indenter.createReusingIndent(indent, addIndent, 0);
+                       }
+
+                       StringBuilder buf = new StringBuilder(c.text + indent);
+                       int contentStart = findEndOfWhiteSpace(d, c.offset, lineEnd);
+                       c.length =  Math.max(contentStart - c.offset, 0);
+
+                       // insert closing brace on new line after an unclosed opening brace
+                       if (getBracketCount(d, start, c.offset, true) > 0 && fCloseBrace && !isClosedBrace(d, c.offset, c.length)) {
+                               c.caretOffset = c.offset + buf.length();
+                               c.shiftsCaret = false;
+
+                               // copy old content of line behind insertion point to new line
+                               // unless we think we are inserting an anonymous type definition
+                               if (c.offset == 0 || !(computeAnonymousPosition(d, c.offset - 1, fPartitioning, lineEnd) != -1)) {
+                                       if (lineEnd - contentStart > 0) {
+                                               c.length =  lineEnd - c.offset;
+                                               buf.append(d.get(contentStart, lineEnd - contentStart).toCharArray());
+                                       }
+                               }
+
+                               buf.append(TextUtilities.getDefaultLineDelimiter(d));
+                               StringBuilder reference = null;
+                               int nonWS = findEndOfWhiteSpace(d, start, lineEnd);
+                               if (nonWS < c.offset && d.getChar(nonWS) == '{')
+                                       reference = new StringBuilder(d.get(start, nonWS - start));
+                               else
+                                       reference = indenter.getReferenceIndentation(c.offset);
+                               if (reference != null)
+                                       buf.append(reference);
+                               buf.append('}');
+                               int bound= c.offset > 200 ? c.offset - 200 : CHeuristicScanner.UNBOUND;
+                               int bracePos = scanner.findOpeningPeer(c.offset - 1, bound, '{', '}');
+                               if (bracePos != CHeuristicScanner.NOT_FOUND) {
+                                       if (scanner.looksLikeCompositeTypeDefinitionBackward(bracePos, bound) ||
+                                                       scanner.previousToken(bracePos - 1, bound) == Symbols.TokenEQUAL) {
+                                               buf.append(';');
+                                       }
+                               }
+                       }
+                       // insert extra line upon new line between two braces
+                       else if (c.offset > start && contentStart < lineEnd && d.getChar(contentStart) == '}') {
+                               int firstCharPos = scanner.findNonWhitespaceBackward(c.offset - 1, start);
+                               if (firstCharPos != CHeuristicScanner.NOT_FOUND && d.getChar(firstCharPos) == '{') {
+                                       c.caretOffset = c.offset + buf.length();
+                                       c.shiftsCaret = false;
+
+                                       StringBuilder reference = null;
+                                       int nonWS = findEndOfWhiteSpace(d, start, lineEnd);
+                                       if (nonWS < c.offset && d.getChar(nonWS) == '{')
+                                               reference = new StringBuilder(d.get(start, nonWS - start));
+                                       else
+                                               reference = indenter.getReferenceIndentation(c.offset);
+
+                                       buf.append(TextUtilities.getDefaultLineDelimiter(d));
+
+                                       if (reference != null)
+                                               buf.append(reference);
+                               }
+                       }
+                       c.text = buf.toString();
+
+               } catch (BadLocationException e) {
+                       CUIPlugin.log(e);
+               }
+       }
+       
+       /**
+        * Computes an insert position for an opening brace if <code>offset</code> maps to a position in
+        * <code>document</code> with a expression in parenthesis that will take a block after the closing parenthesis.
+        *
+        * @param document the document being modified
+        * @param offset the offset of the caret position, relative to the line start.
+        * @param partitioning the document partitioning
+        * @param max the max position
+        * @return an insert position relative to the line start if <code>line</code> contains a parenthesized expression that can be followed by a block, -1 otherwise
+        */
+       private static int computeAnonymousPosition(IDocument document, int offset, String partitioning,  int max) {
+               // find the opening parenthesis for every closing parenthesis on the current line after offset
+               // return the position behind the closing parenthesis if it looks like a method declaration
+               // or an expression for an if, while, for, catch statement
+
+               CHeuristicScanner scanner = new CHeuristicScanner(document);
+               int pos = offset;
+               int length = max;
+               int scanTo = scanner.scanForward(pos, length, '}');
+               if (scanTo == -1)
+                       scanTo = length;
+
+               int closingParen = findClosingParenToLeft(scanner, pos) - 1;
+
+               while (true) {
+                       int startScan = closingParen + 1;
+                       closingParen = scanner.scanForward(startScan, scanTo, ')');
+                       if (closingParen == -1)
+                               break;
+
+                       int openingParen = scanner.findOpeningPeer(closingParen - 1, '(', ')');
+
+                       // no way an expression at the beginning of the document can mean anything
+                       if (openingParen < 1)
+                               break;
+
+                       // only select insert positions for parenthesis currently embracing the caret
+                       if (openingParen > pos)
+                               continue;
+               }
+
+               return -1;
+       }
+
+       /**
+        * Finds a closing parenthesis to the left of <code>position</code> in document, where that parenthesis is only
+        * separated by whitespace from <code>position</code>. If no such parenthesis can be found, <code>position</code> is returned.
+        *
+        * @param scanner the C heuristic scanner set up on the document
+        * @param position the first character position in <code>document</code> to be considered
+        * @return the position of a closing parenthesis left to <code>position</code> separated only by whitespace, or <code>position</code> if no parenthesis can be found
+        */
+       private static int findClosingParenToLeft(CHeuristicScanner scanner, int position) {
+               if (position < 1)
+                       return position;
+
+               if (scanner.previousToken(position - 1, CHeuristicScanner.UNBOUND) == Symbols.TokenRPAREN)
+                       return scanner.getPosition() + 1;
+               return position;
+       }
+
+       private boolean isClosedBrace(IDocument document, int offset, int length) {
+               return getBlockBalance(document, offset, fPartitioning) <= 0;
+               //TODO: Use smarter algorithm based on
+//             CompilationUnitInfo info = getCompilationUnitForMethod(document, offset, fPartitioning);
+//             if (info == null)
+//                     return false;
+//
+//             CodeReader reader = new CodeReader(info.buffer);
+//             ICodeReaderFactory fileCreator = CDOM.getInstance().getCodeReaderFactory(CDOM.PARSE_WORKING_COPY_WHENEVER_POSSIBLE);
+//
+//             IScanner domScanner = new DOMScanner(reader, new ScannerInfo(), ParserMode.COMPLETE_PARSE,
+//                             ParserLanguage.C, ParserFactory.createDefaultLogService(),
+//                             C_GNU_SCANNER_EXTENSION, fileCreator);
+//
+//             ISourceCodeParser parser = new GNUCPPSourceParser(
+//                             domScanner,
+//                             ParserMode.COMPLETE_PARSE,
+//                             ParserUtil.getParserLogService(),
+//                             new GPPParserExtensionConfiguration());
+//
+//             IASTTranslationUnit translationUnit = parser.parse();
+//             final int relativeOffset = offset - info.delta;
+//         IASTNode node = translationUnit.selectNodeForLocation(reader.getPath(), relativeOffset, length);
+//
+//             if (node == null)
+//                     return false;
+//
+//             if (node instanceof IASTCompoundStatement) {
+//                     return getBlockBalance(document, offset, fPartitioning) <= 0;
+//             } else if (node instanceof IASTIfStatement) {
+//                     IASTIfStatement ifStatement = (IASTIfStatement) node;
+//                     IASTExpression expression = ifStatement.getConditionExpression();
+//                     IRegion expressionRegion = createRegion(expression, info.delta);
+//                     IASTStatement thenStatement = ifStatement.getThenClause();
+//                     IRegion thenRegion = createRegion(thenStatement, info.delta);
+//
+//                     // Between expression and then statement
+//                     if (expressionRegion.getOffset() + expressionRegion.getLength() <= offset && offset + length <= thenRegion.getOffset())
+//                             return thenStatement != null;
+//
+//                     IASTStatement elseStatement = ifStatement.getElseClause();
+//                     IRegion elseRegion = createRegion(elseStatement, info.delta);
+//
+//                     if (elseStatement != null) {
+//                             int sourceOffset = thenRegion.getOffset() + thenRegion.getLength();
+//                             int sourceLength = elseRegion.getOffset() - sourceOffset;
+//                             CHeuristicScanner scanner = new CHeuristicScanner(new SimpleDocument(info.buffer));
+//                             int pos = sourceOffset;
+//                             int id;
+//                             while ((id = scanner.nextToken(pos, sourceOffset + sourceLength - pos)) != CHeuristicScanner.TokenEOF) {
+//                                     if (id == CHeuristicScanner.TokenELSE) {
+//                                             pos = scanner.getPosition();
+//                                             // Between 'else' token and else statement.
+//                                             return pos <= offset && offset + length < elseRegion.getOffset();
+//                                     }
+//                             }
+//
+//                             return true;
+//                     }
+//             } else if (node instanceof IASTForStatement) {
+//                     IASTExpression expression = ((IASTForStatement) node).getConditionExpression();
+//                     IRegion expressionRegion = createRegion(expression, info.delta);
+//                     IASTStatement body = ((IASTForStatement) node).getBody();
+//                     IRegion bodyRegion = createRegion(body, info.delta);
+//
+//                     // Between expression and body statement
+//                     if (expressionRegion.getOffset() + expressionRegion.getLength() <= offset && offset + length <= bodyRegion.getOffset()) {
+//                             return body != null;
+//                     }
+//             } else if (node instanceof IASTWhileStatement) {
+//                     IASTExpression expression = ((IASTWhileStatement) node).getCondition();
+//                     IRegion expressionRegion = createRegion(expression, info.delta);
+//                     IASTStatement body = ((IASTWhileStatement) node).getBody();
+//                     IRegion bodyRegion = createRegion(body, info.delta);
+//
+//                     // Between expression and body statement
+//                     if (expressionRegion.getOffset() + expressionRegion.getLength() <= offset && offset + length <= bodyRegion.getOffset()) {
+//                             return body != null;
+//                     }
+//             } else if (node instanceof IASTDoStatement) {
+//                     IASTDoStatement doStatement = (IASTDoStatement) node;
+//                     IRegion doRegion = createRegion(doStatement, info.delta);
+//                     IASTStatement body = doStatement.getBody();
+//                     IRegion bodyRegion = createRegion(body, info.delta);
+//
+//                     // Between 'do' and body statement.
+//                     if (doRegion.getOffset() + doRegion.getLength() <= offset && offset + length <= bodyRegion.getOffset()) {
+//                             return body != null;
+//                     }
+//             }
+//
+//             return true;
+       }
+
+    private boolean isLineDelimiter(IDocument document, String text) {
+               String[] delimiters = document.getLegalLineDelimiters();
+               if (delimiters != null)
+                       return TextUtilities.equals(delimiters, text) > -1;
+               return false;
+       }
+
+       /**
+        * Installs a C partitioner with <code>document</code>.
+        *
+        * @param document the document
+        */
+       private static void installCPartitioner(Document document) {
+               String[] types= new String[] {
+                   ICPartitions.C_MULTI_LINE_COMMENT,
+                       ICPartitions.C_SINGLE_LINE_COMMENT,
+                       ICPartitions.C_STRING,
+                       ICPartitions.C_CHARACTER,
+                       ICPartitions.C_PREPROCESSOR,
+                       IDocument.DEFAULT_CONTENT_TYPE
+               };
+               FastPartitioner partitioner= new FastPartitioner(new FastCPartitionScanner(), types);
+               partitioner.connect(document);
+               document.setDocumentPartitioner(ICPartitions.C_PARTITIONING, partitioner);
+       }
+
+       /**
+        * Installs a C partitioner with <code>document</code>.
+        *
+        * @param document the document
+        */
+       private static void removeCPartitioner(Document document) {
+               document.setDocumentPartitioner(ICPartitions.C_PARTITIONING, null);
+       }
+       
+       private void smartPaste(IDocument document, DocumentCommand command) {
+               int newOffset= command.offset;
+               int newLength= command.length;
+               String newText= command.text;
+
+               try {
+                       CHeuristicScanner scanner= new CHeuristicScanner(document);
+                       CIndenter indenter= new CIndenter(document, scanner, fProject);
+                       int offset= newOffset;
+
+                       // reference position to get the indent from
+                       int refOffset= indenter.findReferencePosition(offset);
+                       if (refOffset == CHeuristicScanner.NOT_FOUND)
+                               return;
+                       int peerOffset= getPeerPosition(document, command);
+                       peerOffset= indenter.findReferencePosition(peerOffset);
+                       if (peerOffset == CHeuristicScanner.NOT_FOUND)
+                               return;
+                       refOffset= Math.min(refOffset, peerOffset);
+
+                       // eat any WS before the insertion to the beginning of the line
+                       int firstLine= 1; // don't format the first line per default, as it has other content before it
+                       IRegion line= document.getLineInformationOfOffset(offset);
+                       String notSelected= document.get(line.getOffset(), offset - line.getOffset());
+                       if (notSelected.trim().length() == 0) {
+                               newLength += notSelected.length();
+                               newOffset= line.getOffset();
+                               firstLine= 0;
+                       }
+
+                       // Prefix: the part we need for formatting but won't paste.
+                       // Take up to 100 previous lines to preserve enough context.
+                       int firstPrefixLine= Math.max(document.getLineOfOffset(refOffset) - 100, 0);
+                       int prefixOffset= document.getLineInformation(firstPrefixLine).getOffset();
+                       String prefix= document.get(prefixOffset, newOffset - prefixOffset);
+
+                       // Handle the indentation computation inside a temporary document
+                       Document temp= new Document(prefix + newText);
+                       DocumentRewriteSession session= temp.startRewriteSession(DocumentRewriteSessionType.STRICTLY_SEQUENTIAL);
+                       scanner= new CHeuristicScanner(temp);
+                       indenter= new CIndenter(temp, scanner, fProject);
+                       installCPartitioner(temp);
+
+                       // Indent the first and second line
+                       // compute the relative indentation difference from the second line
+                       // (as the first might be partially selected) and use the value to
+                       // indent all other lines.
+                       boolean isIndentDetected= false;
+                       StringBuilder addition= new StringBuilder();
+                       int insertLength= 0;
+                       int first= document.computeNumberOfLines(prefix) + firstLine; // don't format first line
+                       int lines= temp.getNumberOfLines();
+                       boolean changed= false;
+                       boolean indentInsideLineComments= IndentUtil.indentInsideLineComments(fProject);
+
+                       for (int l= first; l < lines; l++) { // we don't change the number of lines while adding indents
+                               IRegion r= temp.getLineInformation(l);
+                               int lineOffset= r.getOffset();
+                               int lineLength= r.getLength();
+
+                               if (lineLength == 0) // don't modify empty lines
+                                       continue;
+
+                               if (!isIndentDetected) {
+                                       // indent the first pasted line
+                                       String current= IndentUtil.getCurrentIndent(temp, l, indentInsideLineComments);
+                                       StringBuilder correct= new StringBuilder(IndentUtil.computeIndent(temp, l, indenter, scanner));
+
+                                       insertLength= subtractIndent(correct, current, addition);
+                                       // workaround for bug 181139
+                                       if (/*l != first && */temp.get(lineOffset, lineLength).trim().length() != 0) {
+                                               isIndentDetected= true;
+                                               if (insertLength == 0) {
+                                                        // no adjustment needed, bail out
+                                                       if (firstLine == 0) {
+                                                               // but we still need to adjust the first line
+                                                               command.offset= newOffset;
+                                                               command.length= newLength;
+                                                               if (changed)
+                                                                       break; // still need to get the leading indent of the first line
+                                                       }
+                                                       return;
+                                               }
+                                               removeCPartitioner(temp);
+                                       } else {
+                                               changed= insertLength != 0;
+                                       }
+                               }
+
+                               // relatively indent all pasted lines
+                               if (insertLength > 0)
+                                       addIndent(temp, l, addition, indentInsideLineComments);
+                               else if (insertLength < 0)
+                                       cutIndent(temp, l, -insertLength, indentInsideLineComments);
+                       }
+
+                       temp.stopRewriteSession(session);
+                       newText= temp.get(prefix.length(), temp.getLength() - prefix.length());
+
+                       command.offset= newOffset;
+                       command.length= newLength;
+                       command.text= newText;
+               } catch (BadLocationException e) {
+                       CUIPlugin.log(e);
+               }
+       }
+
+       /**
+        * Computes the difference of two indentations and returns the difference in
+        * length of current and correct. If the return value is positive, <code>addition</code>
+        * is initialized with a substring of that length of <code>correct</code>.
+        *
+        * @param correct the correct indentation
+        * @param current the current indentation (migth contain non-whitespace)
+        * @param difference a string buffer - if the return value is positive, it will be cleared and set to the substring of <code>current</code> of that length
+        * @return the difference in lenght of <code>correct</code> and <code>current</code>
+        */
+       private int subtractIndent(CharSequence correct, CharSequence current, StringBuilder difference) {
+               int c1= computeVisualLength(correct);
+               int c2= computeVisualLength(current);
+               int diff= c1 - c2;
+               if (diff <= 0)
+                       return diff;
+
+               difference.setLength(0);
+               int len= 0, i= 0;
+               while (len < diff) {
+                       char c= correct.charAt(i++);
+                       difference.append(c);
+                       len += computeVisualLength(c);
+               }
+
+               return diff;
+       }
+
+       /**
+        * Indents line <code>line</code> in <code>document</code> with <code>indent</code>.
+        * Leaves leading comment signs alone.
+        *
+        * @param document the document
+        * @param line the line
+        * @param indent the indentation to insert
+        * @param indentInsideLineComments option whether to indent inside line comments starting at column 0
+        * @throws BadLocationException on concurrent document modification
+        */
+       private static void addIndent(Document document, int line, CharSequence indent, boolean indentInsideLineComments) throws BadLocationException {
+               IRegion region= document.getLineInformation(line);
+               int insert= region.getOffset();
+               int endOffset= region.getOffset() + region.getLength();
+
+               if (indentInsideLineComments) {
+                       // go behind line comments
+                       while (insert < endOffset - 2 && document.get(insert, 2).equals(LINE_COMMENT))
+                               insert += 2;
+               }
+
+               // insert indent
+               document.replace(insert, 0, indent.toString());
+       }
+
+       /**
+        * Cuts the visual equivalent of <code>toDelete</code> characters out of the
+        * indentation of line <code>line</code> in <code>document</code>. Leaves
+        * leading comment signs alone.
+        *
+        * @param document the document
+        * @param line the line
+        * @param toDelete the number of space equivalents to delete.
+        * @param indentInsideLineComments option whether to indent inside line comments starting at column 0
+        * @throws BadLocationException on concurrent document modification
+        */
+       private void cutIndent(Document document, int line, int toDelete, boolean indentInsideLineComments) throws BadLocationException {
+               IRegion region= document.getLineInformation(line);
+               int from= region.getOffset();
+               int endOffset= region.getOffset() + region.getLength();
+
+               if (indentInsideLineComments) {
+                       // go behind line comments
+                       while (from < endOffset - 2 && document.get(from, 2).equals(LINE_COMMENT))
+                               from += 2;
+               }
+
+               int to= from;
+               while (toDelete > 0 && to < endOffset) {
+                       char ch= document.getChar(to);
+                       if (!Character.isWhitespace(ch))
+                               break;
+                       toDelete -= computeVisualLength(ch);
+                       if (toDelete >= 0)
+                               to++;
+                       else
+                               break;
+               }
+
+               document.replace(from, to - from, null);
+       }
+
+       /**
+        * Returns the visual length of a given <code>CharSequence</code> taking into
+        * account the visual tabulator length.
+        *
+        * @param seq the string to measure
+        * @return the visual length of <code>seq</code>
+        */
+       private int computeVisualLength(CharSequence seq) {
+               int size= 0;
+               int tablen= getVisualTabLengthPreference();
+
+               for (int i= 0; i < seq.length(); i++) {
+                       char ch= seq.charAt(i);
+                       if (ch == '\t') {
+                               if (tablen != 0)
+                                       size += tablen - size % tablen;
+                               // else: size stays the same
+                       } else {
+                               size++;
+                       }
+               }
+               return size;
+       }
+
+       /**
+        * Returns the visual length of a given character taking into
+        * account the visual tabulator length.
+        *
+        * @param ch the character to measure
+        * @return the visual length of <code>ch</code>
+        */
+       private int computeVisualLength(char ch) {
+               if (ch == '\t')
+                       return getVisualTabLengthPreference();
+               return 1;
+       }
+
+       /**
+        * The preference setting for the visual tabulator display.
+        *
+        * @return the number of spaces displayed for a tabulator in the editor
+        */
+       private int getVisualTabLengthPreference() {
+               return CodeFormatterUtil.getTabWidth(fProject);
+       }
+
+       private int getPeerPosition(IDocument document, DocumentCommand command) {
+               if (document.getLength() == 0)
+                       return 0;
+       /*
+        * Search for scope closers in the pasted text and find their opening peers
+        * in the document.
+        */
+       Document pasted= new Document(command.text);
+       installCPartitioner(pasted);
+       int firstPeer= command.offset;
+
+       CHeuristicScanner pScanner= new CHeuristicScanner(pasted);
+       CHeuristicScanner dScanner= new CHeuristicScanner(document);
+
+       // add scope relevant after context to peer search
+       int afterToken= dScanner.nextToken(command.offset + command.length, CHeuristicScanner.UNBOUND);
+       try {
+                       switch (afterToken) {
+                       case Symbols.TokenRBRACE:
+                               pasted.replace(pasted.getLength(), 0, "}"); //$NON-NLS-1$
+                               break;
+                       case Symbols.TokenRPAREN:
+                               pasted.replace(pasted.getLength(), 0, ")"); //$NON-NLS-1$
+                               break;
+                       case Symbols.TokenRBRACKET:
+                               pasted.replace(pasted.getLength(), 0, "]"); //$NON-NLS-1$
+                               break;
+                       }
+               } catch (BadLocationException e) {
+                       // cannot happen
+                       Assert.isTrue(false);
+               }
+
+       int pPos= 0; // paste text position (increasing from 0)
+       int dPos= Math.max(0, command.offset - 1); // document position (decreasing from paste offset)
+       while (true) {
+               int token= pScanner.nextToken(pPos, CHeuristicScanner.UNBOUND);
+                       pPos= pScanner.getPosition();
+               switch (token) {
+                       case Symbols.TokenLBRACE:
+                       case Symbols.TokenLBRACKET:
+                       case Symbols.TokenLPAREN:
+                               pPos= skipScope(pScanner, pPos, token);
+                               if (pPos == CHeuristicScanner.NOT_FOUND)
+                                       return firstPeer;
+                               break; // closed scope -> keep searching
+                       case Symbols.TokenRBRACE:
+                               int peer= dScanner.findOpeningPeer(dPos, '{', '}');
+                               dPos= peer - 1;
+                               if (peer == CHeuristicScanner.NOT_FOUND)
+                                       return firstPeer;
+                               firstPeer= peer;
+                               break; // keep searching
+                       case Symbols.TokenRBRACKET:
+                               peer= dScanner.findOpeningPeer(dPos, '[', ']');
+                               dPos= peer - 1;
+                               if (peer == CHeuristicScanner.NOT_FOUND)
+                                       return firstPeer;
+                               firstPeer= peer;
+                               break; // keep searching
+                       case Symbols.TokenRPAREN:
+                               peer= dScanner.findOpeningPeer(dPos, '(', ')');
+                               dPos= peer - 1;
+                               if (peer == CHeuristicScanner.NOT_FOUND)
+                                       return firstPeer;
+                               firstPeer= peer;
+                               break; // keep searching
+                               
+                       case Symbols.TokenCASE:
+                       case Symbols.TokenDEFAULT:
+                           {
+                                       CIndenter indenter= new CIndenter(document, dScanner, fProject);
+                                       peer= indenter.findReferencePosition(dPos, false, false, false, true, false);
+                                       if (peer == CHeuristicScanner.NOT_FOUND)
+                                               return firstPeer;
+                                       firstPeer= peer;
+                               }
+                               break; // keep searching
+
+                       case Symbols.TokenPUBLIC:
+                       case Symbols.TokenPROTECTED:
+                       case Symbols.TokenPRIVATE:
+                                   {
+                                               CIndenter indenter= new CIndenter(document, dScanner, fProject);
+                                               peer= indenter.findReferencePosition(dPos, false, false, false, false, true);
+                                               if (peer == CHeuristicScanner.NOT_FOUND)
+                                                       return firstPeer;
+                                               firstPeer= peer;
+                                       }
+                               break; // keep searching
+                               
+                       case Symbols.TokenEOF:
+                               return firstPeer;
+                       default:
+                               // keep searching
+               }
+       }
+    }
+
+    /**
+     * Skips the scope opened by <code>token</code> in <code>document</code>,
+     * returns either the position of the
+     * @param pos
+     * @param token
+     * @return the position after the scope
+     */
+    private static int skipScope(CHeuristicScanner scanner, int pos, int token) {
+       int openToken= token;
+       int closeToken;
+       switch (token) {
+               case Symbols.TokenLPAREN:
+                       closeToken= Symbols.TokenRPAREN;
+                       break;
+               case Symbols.TokenLBRACKET:
+                       closeToken= Symbols.TokenRBRACKET;
+                       break;
+               case Symbols.TokenLBRACE:
+                       closeToken= Symbols.TokenRBRACE;
+                       break;
+               default:
+                       Assert.isTrue(false);
+                       return -1; // dummy
+       }
+
+       int depth= 1;
+       int p= pos;
+
+       while (true) {
+               int tok= scanner.nextToken(p, CHeuristicScanner.UNBOUND);
+               p= scanner.getPosition();
+
+               if (tok == openToken) {
+                       depth++;
+               } else if (tok == closeToken) {
+                       depth--;
+                       if (depth == 0)
+                               return p + 1;
+               } else if (tok == Symbols.TokenEOF) {
+                       return CHeuristicScanner.NOT_FOUND;
+               }
+       }
+    }
+
+       private void smartIndentOnKeypress(IDocument document, DocumentCommand command) {
+               switch (command.text.charAt(0)) {
+                       case '}':
+                               smartIndentAfterClosingBracket(document, command);
+                               break;
+                       case '{':
+                               smartIndentAfterOpeningBracket(document, command);
+                               break;
+                       case 'e':
+                               smartIndentUponE(document, command);
+                               break;
+                       case ':':
+                               smartIndentAfterColumn(document, command);
+                               break;
+                       case '#':
+                               smartIndentAfterHash(document, command);
+                               break;
+               }
+       }
+
+       private void smartIndentUponE(IDocument doc, DocumentCommand c) {
+               if (c.offset < 4 || doc.getLength() == 0)
+                       return;
+
+               try {
+                       String content = doc.get(c.offset - 3, 3);
+                       if (content.equals("els")) { //$NON-NLS-1$
+                               CHeuristicScanner scanner = new CHeuristicScanner(doc);
+                               int p = c.offset - 3;
+
+                               // current line
+                               int line = doc.getLineOfOffset(p);
+                               int lineOffset = doc.getLineOffset(line);
+
+                               // make sure we don't have any leading comments etc.
+                               if (doc.get(lineOffset, p - lineOffset).trim().length() != 0)
+                                       return;
+
+                               // Line of last C code
+                               int pos = scanner.findNonWhitespaceBackward(p - 1, CHeuristicScanner.UNBOUND);
+                               if (pos == -1)
+                                       return;
+                               int lastLine = doc.getLineOfOffset(pos);
+
+                               // Only shift if the last C line is further up and is a braceless block candidate
+                               if (lastLine < line) {
+                                       CIndenter indenter = new CIndenter(doc, scanner, fProject);
+                                       int ref = indenter.findReferencePosition(p, true, false, false, false, false);
+                                       if (ref == CHeuristicScanner.NOT_FOUND)
+                                               return;
+                                       int refLine = doc.getLineOfOffset(ref);
+                                       String indent = getIndentOfLine(doc, refLine);
+
+                                       if (indent != null) {
+                                               c.text = indent.toString() + "else"; //$NON-NLS-1$
+                                               c.length += c.offset - lineOffset;
+                                               c.offset = lineOffset;
+                                       }
+                               }
+
+                               return;
+                       }
+
+                       if (content.equals("cas")) { //$NON-NLS-1$
+                               CHeuristicScanner scanner = new CHeuristicScanner(doc);
+                               int p = c.offset - 3;
+
+                               // current line
+                               int line = doc.getLineOfOffset(p);
+                               int lineOffset = doc.getLineOffset(line);
+
+                               // make sure we don't have any leading comments etc.
+                               if (doc.get(lineOffset, p - lineOffset).trim().length() != 0)
+                                       return;
+
+                               // Line of last C code
+                               int pos = scanner.findNonWhitespaceBackward(p - 1, CHeuristicScanner.UNBOUND);
+                               if (pos == -1)
+                                       return;
+                               int lastLine = doc.getLineOfOffset(pos);
+
+                               // Only shift if the last C line is further up and is a braceless block candidate
+                               if (lastLine < line) {
+                                       CIndenter indenter = new CIndenter(doc, scanner, fProject);
+                                       int ref = indenter.findReferencePosition(p, false, false, false, true, false);
+                                       if (ref == CHeuristicScanner.NOT_FOUND)
+                                               return;
+                                       int refLine = doc.getLineOfOffset(ref);
+                                       int nextToken = scanner.nextToken(ref, CHeuristicScanner.UNBOUND);
+                                       String indent;
+                                       if (nextToken == Symbols.TokenCASE || nextToken == Symbols.TokenDEFAULT)
+                                               indent = getIndentOfLine(doc, refLine);
+                                       else // at the brace of the switch
+                                               indent = indenter.computeIndentation(p).toString();
+
+                                       if (indent != null) {
+                                               c.text = indent.toString() + "case"; //$NON-NLS-1$
+                                               c.length += c.offset - lineOffset;
+                                               c.offset = lineOffset;
+                                       }
+                               }
+
+                               return;
+                       }
+               } catch (BadLocationException e) {
+                       CUIPlugin.log(e);
+               }
+       }
+
+       private void smartIndentAfterColumn(IDocument doc, DocumentCommand c) {
+               try {
+                       int offset = c.offset;
+                       // Current line
+                       int line = doc.getLineOfOffset(offset);
+                       IRegion startLine = doc.getLineInformationOfOffset(offset);
+                       int lineOffset = startLine.getOffset();
+
+                       CHeuristicScanner scanner = new CHeuristicScanner(doc);
+                       int prevToken = scanner.previousToken(offset - 1, lineOffset);
+                       switch (prevToken) {
+                               case Symbols.TokenDEFAULT:
+                               case Symbols.TokenPUBLIC:
+                               case Symbols.TokenPROTECTED:
+                               case Symbols.TokenPRIVATE:
+                                       break;
+                                       
+                               default:
+                                       return;
+                       }
+                       
+                       int p = scanner.getPosition() + 1;
+
+                       // Make sure we don't have any leading comments etc.
+                       if (doc.get(lineOffset, p - lineOffset).trim().length() != 0)
+                               return;
+                       
+                       // Line of last C code
+                       int pos = scanner.findNonWhitespaceBackward(p - 1, CHeuristicScanner.UNBOUND);
+                       if (pos == -1)
+                               return;
+                       int lastLine = doc.getLineOfOffset(pos);
+
+                       // Only shift if the last C line is further up and is a braceless block candidate
+                       if (lastLine < line) {
+                               CIndenter indenter = new CIndenter(doc, scanner, fProject);
+                               int ref;
+                               if (prevToken == Symbols.TokenDEFAULT)
+                                       ref = indenter.findReferencePosition(p, false, false, false, true, false);
+                               else
+                                       ref = indenter.findReferencePosition(p, false, false, false, false, true);
+                               if (ref == CHeuristicScanner.NOT_FOUND)
+                                       return;
+                               int refLine = doc.getLineOfOffset(ref);
+                               int nextToken = scanner.nextToken(ref, CHeuristicScanner.UNBOUND);
+                               String indent;
+                               if (nextToken == Symbols.TokenCASE || nextToken == Symbols.TokenDEFAULT ||
+                                               nextToken == Symbols.TokenPUBLIC || nextToken == Symbols.TokenPROTECTED ||
+                                               nextToken == Symbols.TokenPRIVATE) {
+                                       indent = getIndentOfLine(doc, refLine);
+                               } else { // at the brace of the switch or the class
+                                       indent = indenter.computeIndentation(p).toString();
+                               }
+
+                               if (indent != null) {
+                                       c.text = indent.toString() + doc.get(p, offset - p) + c.text;
+                                       c.length += c.offset - lineOffset;
+                                       c.offset = lineOffset;
+                               }
+                       }
+
+                       return;
+               } catch (BadLocationException e) {
+                       CUIPlugin.log(e);
+               }
+       }
+
+       private void smartIndentAfterHash(IDocument doc, DocumentCommand c) {
+               try {
+                       ITypedRegion partition= TextUtilities.getPartition(doc, fPartitioning, c.offset, false);
+                       if (IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType())) {
+                               IRegion startLine= doc.getLineInformationOfOffset(c.offset);
+                               String indent= doc.get(startLine.getOffset(), c.offset - startLine.getOffset());
+                               if (indent.trim().length() == 0) {
+                                       c.offset -= indent.length();
+                                       c.length += indent.length();
+                               }
+                       }
+               } catch (BadLocationException e) {
+                       CUIPlugin.log(e);
+               }
+       }
+
+       /*
+        * @see org.eclipse.jface.text.IAutoEditStrategy#customizeDocumentCommand(IDocument, DocumentCommand)
+        */
+       @Override
+       public void customizeDocumentCommand(IDocument d, DocumentCommand c) {
+               if (!c.doit)
+                       return;
+
+               clearCachedValues();
+               if (!fIsSmartMode) {
+                       super.customizeDocumentCommand(d, c);
+                       return;
+               }
+               
+               boolean isNewLine= c.length == 0 && c.text != null && isLineDelimiter(d, c.text);
+               if (isNewLine) {
+                       smartIndentAfterNewLine(d, c);
+               } else if (c.text.length() == 1 && getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_AUTO_INDENT)) {
+                       smartIndentOnKeypress(d, c);
+               } else if (c.text.length() > 1
+                               && getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SMART_PASTE)
+                               && c.text.trim().length() != 0) {
+                       smartPaste(d, c); // no smart backspace for paste
+               }
+       }
+
+       private static IPreferenceStore getPreferenceStore() {
+               return CUIPlugin.getDefault().getCombinedPreferenceStore();
+       }
+
+       private void clearCachedValues() {
+        IPreferenceStore preferenceStore = getPreferenceStore();
+               fCloseBrace = preferenceStore.getBoolean(PreferenceConstants.EDITOR_CLOSE_BRACES);
+               fIsSmartMode = computeSmartMode();
+       }
+
+       private boolean computeSmartMode() {
+               IWorkbenchPage page = CUIPlugin.getActivePage();
+               if (page != null)  {
+                       IEditorPart part = page.getActiveEditor();
+                       if (part instanceof MultiPageEditorPart) {
+                               part= (IEditorPart)part.getAdapter(ITextEditorExtension3.class);
+                       }
+                       if (part instanceof ITextEditorExtension3) {
+                               ITextEditorExtension3 extension = (ITextEditorExtension3) part;
+                               return extension.getInsertMode() == ITextEditorExtension3.SMART_INSERT;
+                       }
+                       if (part == null) {
+                               // TODO: Remove this if statement once CAutoIndentTest is fixed so that getActiveEditor does not return null.
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+//     private static CompilationUnitInfo getCompilationUnitForMethod(IDocument document, int offset, String partitioning) {
+//             try {
+//                     CHeuristicScanner scanner = new CHeuristicScanner(document);
+//
+//                     IRegion sourceRange = scanner.findSurroundingBlock(offset);
+//                     if (sourceRange == null)
+//                             return null;
+//                     String source = document.get(sourceRange.getOffset(), sourceRange.getLength());
+//
+//                     StringBuilder contents = new StringBuilder();
+//                     contents.append("class ____C{void ____m()"); //$NON-NLS-1$
+//                     final int methodOffset = contents.length();
+//                     contents.append(source);
+//                     contents.append("};"); //$NON-NLS-1$
+//
+//                     char[] buffer = contents.toString().toCharArray();
+//                     return new CompilationUnitInfo(buffer, sourceRange.getOffset() - methodOffset);
+//             } catch (BadLocationException e) {
+//                     CUIPlugin.log(e);
+//             }
+//
+//             return null;
+//     }
+
+       /**
+        * Returns the block balance, i.e. zero if the blocks are balanced at
+        * <code>offset</code>, a negative number if there are more closing than opening
+        * braces, and a positive number if there are more opening than closing braces.
+        *
+        * @param document
+        * @param offset
+        * @param partitioning
+        * @return the block balance
+        */
+       private static int getBlockBalance(IDocument document, int offset, String partitioning) {
+               if (offset < 1)
+                       return -1;
+               if (offset >= document.getLength())
+                       return 1;
+
+               int begin = offset;
+               int end = offset - 1;
+
+               CHeuristicScanner scanner = new CHeuristicScanner(document);
+
+               while (true) {
+                       begin = scanner.findOpeningPeer(begin - 1, '{', '}');
+                       end = scanner.findClosingPeer(end + 1, '{', '}');
+                       if (begin == -1 && end == -1)
+                               return 0;
+                       if (begin == -1)
+                               return -1;
+                       if (end == -1)
+                               return 1;
+               }
+       }
+
+//     private static IRegion createRegion(IASTNode node, int delta) {
+//             IASTNodeLocation nodeLocation = node.getNodeLocations()[0];
+//             return node == null ? null : new Region(nodeLocation.getNodeOffset() + delta, nodeLocation.getNodeLength());
+//     }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CBraceRule.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CBraceRule.java
new file mode 100644 (file)
index 0000000..f60e4fd
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.jface.text.rules.IToken;
+
+/**
+ * Braces rule.
+ *
+ * @author P.Tomaszewski
+ */
+public class CBraceRule extends SingleCharRule
+{
+
+    /**
+     * Creates new rule. 
+     * @param token Style token.
+     */
+    public CBraceRule(IToken token)
+    {
+        super(token);
+    }
+
+    /**
+     * @see org.eclipse.cdt.internal.ui.text.SingleCharRule#isRuleChar(int)
+     */
+    @Override
+       protected boolean isRuleChar(int ch)
+    {
+        return ch == '{' || ch == '}' || ch == '[' || ch == ']' || ch == '(' || ch == ')';
+    }
+
+    
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CBreakIterator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CBreakIterator.java
new file mode 100644 (file)
index 0000000..a870b9e
--- /dev/null
@@ -0,0 +1,470 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin, Google
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import java.text.CharacterIterator;
+
+import org.eclipse.core.runtime.Assert;
+
+import com.ibm.icu.text.BreakIterator;
+
+
+/**
+ * A C break iterator. It returns all breaks, including before and after
+ * whitespace, and it returns all camel case breaks.
+ * <p>
+ * A line break may be any of "\n", "\r", "\r\n", "\n\r".
+ * </p>
+ *
+ * @since 4.0
+ */
+public class CBreakIterator extends BreakIterator {
+
+       /**
+        * A run of common characters.
+        */
+       protected static abstract class Run {
+               /** The length of this run. */
+               protected int length;
+
+               public Run() {
+                       init();
+               }
+
+               /**
+                * Returns <code>true</code> if this run consumes <code>ch</code>,
+                * <code>false</code> otherwise. If <code>true</code> is returned,
+                * the length of the receiver is adjusted accordingly.
+                *
+                * @param ch the character to test
+                * @return <code>true</code> if <code>ch</code> was consumed
+                */
+               protected boolean consume(char ch) {
+                       if (isValid(ch)) {
+                               length++;
+                               return true;
+                       }
+                       return false;
+               }
+
+               /**
+                * Whether this run accepts that character; does not update state. Called
+                * from the default implementation of <code>consume</code>.
+                *
+                * @param ch the character to test
+                * @return <code>true</code> if <code>ch</code> is accepted
+                */
+               protected abstract boolean isValid(char ch);
+
+               /**
+                * Resets this run to the initial state.
+                */
+               protected void init() {
+                       length= 0;
+               }
+       }
+
+       static final class Whitespace extends Run {
+               @Override
+               protected boolean isValid(char ch) {
+                       return Character.isWhitespace(ch) && ch != '\n' && ch != '\r';
+               }
+       }
+
+       static final class LineDelimiter extends Run {
+               /** State: INIT -> delimiter -> EXIT. */
+               private char fState;
+               private static final char INIT= '\0';
+               private static final char EXIT= '\1';
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.text.CBreakIterator.Run#init()
+                */
+               @Override
+               protected void init() {
+                       super.init();
+                       fState= INIT;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.text.CBreakIterator.Run#consume(char)
+                */
+               @Override
+               protected boolean consume(char ch) {
+                       if (!isValid(ch) || fState == EXIT)
+                               return false;
+
+                       if (fState == INIT) {
+                               fState= ch;
+                               length++;
+                               return true;
+                       } else if (fState != ch) {
+                               fState= EXIT;
+                               length++;
+                               return true;
+                       } else {
+                               return false;
+                       }
+               }
+
+               @Override
+               protected boolean isValid(char ch) {
+                       return ch == '\n' || ch == '\r';
+               }
+       }
+
+       static final class Identifier extends Run {
+               /*
+                * @see org.eclipse.cdt.internal.ui.text.CBreakIterator.Run#isValid(char)
+                */
+               @Override
+               protected boolean isValid(char ch) {
+                       return Character.isJavaIdentifierPart(ch);
+               }
+       }
+
+       static final class CamelCaseIdentifier extends Run {
+               /* states */
+               private static final int S_INIT= 0;
+               private static final int S_LOWER= 1;
+               private static final int S_ONE_CAP= 2;
+               private static final int S_ALL_CAPS= 3;
+               private static final int S_UNDERSCORE= 4;
+               private static final int S_EXIT= 5;
+               private static final int S_EXIT_MINUS_ONE= 6;
+
+               /* character types */
+               private static final int K_INVALID= 0;
+               private static final int K_LOWER= 1;
+               private static final int K_UPPER= 2;
+               private static final int K_UNDERSCORE= 3;
+               private static final int K_OTHER= 4;
+
+               private int fState;
+
+               private final static int[][] MATRIX= new int[][] {
+                               // K_INVALID, K_LOWER,           K_UPPER,    K_UNDERSCORE, K_OTHER
+                               {  S_EXIT,    S_LOWER,           S_ONE_CAP,  S_UNDERSCORE, S_LOWER }, // S_INIT
+                               {  S_EXIT,    S_LOWER,           S_EXIT,     S_UNDERSCORE, S_LOWER }, // S_LOWER
+                               {  S_EXIT,    S_LOWER,           S_ALL_CAPS, S_UNDERSCORE, S_LOWER }, // S_ONE_CAP
+                               {  S_EXIT,    S_EXIT_MINUS_ONE,  S_ALL_CAPS, S_UNDERSCORE, S_LOWER }, // S_ALL_CAPS
+                               {  S_EXIT,    S_EXIT,            S_EXIT,     S_UNDERSCORE, S_EXIT  }, // S_UNDERSCORE
+               };
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.text.CBreakIterator.Run#init()
+                */
+               @Override
+               protected void init() {
+                       super.init();
+                       fState= S_INIT;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.text.CBreakIterator.Run#consumes(char)
+                */
+               @Override
+               protected boolean consume(char ch) {
+                       int kind= getKind(ch);
+                       fState= MATRIX[fState][kind];
+                       switch (fState) {
+                               case S_LOWER:
+                               case S_ONE_CAP:
+                               case S_ALL_CAPS:
+                               case S_UNDERSCORE:
+                                       length++;
+                                       return true;
+                               case S_EXIT:
+                                       return false;
+                               case S_EXIT_MINUS_ONE:
+                                       length--;
+                                       return false;
+                               default:
+                                       Assert.isTrue(false);
+                                       return false;
+                       }
+               }
+
+               /**
+                * Determines the kind of a character.
+                *
+                * @param ch the character to test
+                */
+               private int getKind(char ch) {
+                       if (Character.isUpperCase(ch))
+                               return K_UPPER;
+                       if (Character.isLowerCase(ch))
+                               return K_LOWER;
+                       if (ch == '_')
+                               return K_UNDERSCORE;
+                       if (Character.isJavaIdentifierPart(ch)) // digits...
+                               return K_OTHER;
+                       return K_INVALID;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.text.CBreakIterator.Run#isValid(char)
+                */
+               @Override
+               protected boolean isValid(char ch) {
+                       return Character.isJavaIdentifierPart(ch);
+               }
+       }
+
+       static final class Other extends Run {
+               /*
+                * @see org.eclipse.cdt.internal.ui.text.CBreakIterator.Run#isValid(char)
+                */
+               @Override
+               protected boolean isValid(char ch) {
+                       return !Character.isWhitespace(ch) && !Character.isJavaIdentifierPart(ch);
+               }
+       }
+
+       private static final Run WHITESPACE= new Whitespace();
+       private static final Run DELIMITER= new LineDelimiter();
+       private static final Run IDENTIFIER= new Identifier();
+       private static final Run CAMELCASE= new CamelCaseIdentifier();
+       private static final Run OTHER= new Other();
+
+       /** The platform break iterator (word instance) used as a base. */
+       protected final BreakIterator fIterator;
+       /** The text we operate on. */
+       protected CharSequence fText;
+       /** our current position for the stateful methods. */
+       private int fIndex;
+       /** Break on camel case word boundaries */
+       private boolean fCamelCaseBreakEnabled = true;
+
+
+       /**
+        * Creates a new break iterator.
+        */
+       public CBreakIterator() {
+               fIterator= BreakIterator.getWordInstance();
+               fIndex= fIterator.current();
+       }
+
+       /*
+        * @see com.ibm.icu.text.BreakIterator#current()
+        */
+       @Override
+       public int current() {
+               return fIndex;
+       }
+
+       /*
+        * @see com.ibm.icu.text.BreakIterator#first()
+        */
+       @Override
+       public int first() {
+               fIndex= fIterator.first();
+               return fIndex;
+       }
+
+       /*
+        * @see com.ibm.icu.text.BreakIterator#following(int)
+        */
+       @Override
+       public int following(int offset) {
+               // work around too eager IAEs in standard implementation
+               if (offset == getText().getEndIndex())
+                       return DONE;
+
+               int next= fIterator.following(offset);
+               if (next == DONE)
+                       return DONE;
+
+               // TODO deal with complex script word boundaries
+               // Math.min(offset + run.length, next) does not work
+               // since BreakIterator.getWordInstance considers _ as boundaries
+               // seems to work fine, however
+               Run run= consumeRun(offset);
+               return offset + run.length;
+
+       }
+
+       /**
+        * Consumes a run of characters at the limits of which we introduce a break.
+        * @param offset the offset to start at
+        * @return the run that was consumed
+        */
+       private Run consumeRun(int offset) {
+               // assert offset < length
+
+               char ch= fText.charAt(offset);
+               int length= fText.length();
+               Run run= getRun(ch);
+               while (run.consume(ch) && offset < length - 1) {
+                       offset++;
+                       ch= fText.charAt(offset);
+               }
+
+               return run;
+       }
+
+       /**
+        * Returns a run based on a character.
+        *
+        * @param ch the character to test
+        * @return the correct character given <code>ch</code>
+        */
+       private Run getRun(char ch) {
+               Run run;
+               if (WHITESPACE.isValid(ch))
+                       run= WHITESPACE;
+               else if (DELIMITER.isValid(ch))
+                       run= DELIMITER;
+               else if (IDENTIFIER.isValid(ch)) {
+                       if (fCamelCaseBreakEnabled)
+                               run= CAMELCASE;
+                       else
+                               run= IDENTIFIER;
+               }
+               else if (OTHER.isValid(ch))
+                       run= OTHER;
+               else {
+                       Assert.isTrue(false);
+                       return null;
+               }
+
+               run.init();
+               return run;
+       }
+
+       /*
+        * @see com.ibm.icu.text.BreakIterator#getText()
+        */
+       @Override
+       public CharacterIterator getText() {
+               return fIterator.getText();
+       }
+
+       /*
+        * @see com.ibm.icu.text.BreakIterator#isBoundary(int)
+        */
+       @Override
+       public boolean isBoundary(int offset) {
+        if (offset == getText().getBeginIndex())
+            return true;
+               return following(offset - 1) == offset;
+       }
+
+       /*
+        * @see com.ibm.icu.text.BreakIterator#last()
+        */
+       @Override
+       public int last() {
+               fIndex= fIterator.last();
+               return fIndex;
+       }
+
+       /*
+        * @see com.ibm.icu.text.BreakIterator#next()
+        */
+       @Override
+       public int next() {
+               fIndex= following(fIndex);
+               return fIndex;
+       }
+
+       /*
+        * @see com.ibm.icu.text.BreakIterator#next(int)
+        */
+       @Override
+       public int next(int n) {
+               return fIterator.next(n);
+       }
+
+       /*
+        * @see com.ibm.icu.text.BreakIterator#preceding(int)
+        */
+       @Override
+       public int preceding(int offset) {
+               if (offset == getText().getBeginIndex())
+                       return DONE;
+
+               if (isBoundary(offset - 1))
+                       return offset - 1;
+
+               int previous= offset - 1;
+               do {
+                       previous= fIterator.preceding(previous);
+               } while (!isBoundary(previous));
+
+               int last= DONE;
+               while (previous < offset) {
+                       last= previous;
+                       previous= following(previous);
+               }
+
+               return last;
+       }
+
+       /*
+        * @see com.ibm.icu.text.BreakIterator#previous()
+        */
+       @Override
+       public int previous() {
+               fIndex= preceding(fIndex);
+               return fIndex;
+       }
+
+       /*
+        * @see com.ibm.icu.text.BreakIterator#setText(java.lang.String)
+        */
+       @Override
+       public void setText(String newText) {
+               setText((CharSequence) newText);
+       }
+
+       /**
+        * Creates a break iterator given a char sequence.
+        * @param newText the new text
+        */
+       public void setText(CharSequence newText) {
+               fText= newText;
+               fIterator.setText(new SequenceCharacterIterator(newText));
+               first();
+       }
+
+       /*
+        * @see com.ibm.icu.text.BreakIterator#setText(java.text.CharacterIterator)
+        */
+       @Override
+       public void setText(CharacterIterator newText) {
+               if (newText instanceof CharSequence) {
+                       fText= (CharSequence) newText;
+                       fIterator.setText(newText);
+                       first();
+               } else {
+                       throw new UnsupportedOperationException("CharacterIterator not supported"); //$NON-NLS-1$
+               }
+       }
+
+       /**
+        * Enables breaks at word boundaries inside a camel case identifier.
+        *  
+        * @param camelCaseBreakEnabled <code>true</code> to enable, <code>false</code> to disable.
+        */
+       public void setCamelCaseBreakEnabled(boolean camelCaseBreakEnabled) {
+               fCamelCaseBreakEnabled = camelCaseBreakEnabled;
+       }
+
+       /**
+        * @return <code>true</code> if breaks at word boundaries inside
+        * a camel case identifier are enabled.
+        */
+       public boolean isCamelCaseBreakEnabled() {
+               return fCamelCaseBreakEnabled;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeReader.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeReader.java
new file mode 100644 (file)
index 0000000..2eaa20a
--- /dev/null
@@ -0,0 +1,238 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import java.io.IOException;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+
+/**
+ * Reads from a document either forwards or backwards. May be configured to
+ * skip comments and strings.
+ */
+public class CCodeReader extends SingleCharReader {
+       
+       /** The EOF character */
+       public static final int EOF= -1;
+       
+       private boolean fSkipComments= false;
+       private boolean fSkipStrings= false;
+       private boolean fForward= false;
+       
+       private IDocument fDocument;
+       private int fOffset;
+       
+       private int fEnd= -1;
+       private int fCachedLineNumber= -1;
+       private int fCachedLineOffset= -1;
+       
+       
+       public CCodeReader() {
+       }
+       
+       /**
+        * Returns the offset of the last read character. Should only be called after read has been called.
+        */
+       public int getOffset() {
+               return fForward ? fOffset -1 : fOffset;
+       }
+       
+       public void configureForwardReader(IDocument document, int offset, int length, boolean skipComments, boolean skipStrings) throws IOException {
+               fDocument= document;
+               fOffset= offset;
+               fSkipComments= skipComments;
+               fSkipStrings= skipStrings;
+               
+               fForward= true;
+               fEnd= Math.min(fDocument.getLength(), fOffset + length);                
+       }
+       
+       public void configureBackwardReader(IDocument document, int offset, boolean skipComments, boolean skipStrings) throws IOException {
+               fDocument= document;
+               fOffset= offset;
+               fSkipComments= skipComments;
+               fSkipStrings= skipStrings;
+               
+               fForward= false;
+               try {
+                       fCachedLineNumber= fDocument.getLineOfOffset(fOffset);
+               } catch (BadLocationException x) {
+                       throw new IOException(x.getMessage());
+               }
+       }
+       
+       /*
+        * @see Reader#close()
+        */
+       @Override
+       public void close() throws IOException {
+               fDocument= null;
+       }
+       
+       /*
+        * @see SingleCharReader#read()
+        */
+       @Override
+       public int read() throws IOException {
+               try {
+                       return fForward ? readForwards() : readBackwards();
+               } catch (BadLocationException x) {
+                       throw new IOException(x.getMessage());
+               }
+       }
+       
+       private void gotoCommentEnd() throws BadLocationException {
+               while (fOffset < fEnd) {
+                       char current= fDocument.getChar(fOffset++);
+                       if (current == '*') {
+                               if (fOffset < fEnd && fDocument.getChar(fOffset) == '/') {
+                                       ++ fOffset;
+                                       return;
+                               }
+                       }
+               }
+       }
+       
+       private void gotoStringEnd(char delimiter) throws BadLocationException {
+               while (fOffset < fEnd) {
+                       char current= fDocument.getChar(fOffset++);
+                       if (current == '\\') {
+                               // ignore escaped characters
+                               ++ fOffset;
+                       } else if (current == delimiter) {
+                               return;
+                       }
+               }
+       }
+       
+       private void gotoLineEnd() throws BadLocationException {
+               int line= fDocument.getLineOfOffset(fOffset);
+               fOffset= fDocument.getLineOffset(line + 1);
+       }
+       
+       private int readForwards() throws BadLocationException {
+               while (fOffset < fEnd) {
+                       char current= fDocument.getChar(fOffset++);
+                       
+                       switch (current) {
+                               case '/':
+                                       
+                                       if (fSkipComments && fOffset < fEnd) {
+                                               char next= fDocument.getChar(fOffset);
+                                               if (next == '*') {
+                                                       // a comment starts, advance to the comment end
+                                                       ++ fOffset;
+                                                       gotoCommentEnd();
+                                                       continue;
+                                               } else if (next == '/') {
+                                                       // '//'-comment starts, advance to the line end
+                                                       gotoLineEnd();
+                                                       continue;
+                                               }
+                                       }
+                                       
+                                       return current;
+                                       
+                               case '"':
+                               case '\'':
+                               
+                                       if (fSkipStrings) {
+                                               gotoStringEnd(current);
+                                               continue;
+                                       }
+                                       
+                                       return current;
+                       }
+                       
+                       return current;
+               }
+               
+               return EOF;
+       }
+       
+       private void handleSingleLineComment() throws BadLocationException {
+               int line= fDocument.getLineOfOffset(fOffset);
+               if (line < fCachedLineNumber) {
+                       fCachedLineNumber= line;
+                       fCachedLineOffset= fDocument.getLineOffset(line);
+                       int offset= fOffset;
+                       while (fCachedLineOffset < offset) {
+                               char current= fDocument.getChar(offset--);
+                               if (current == '/' && fCachedLineOffset <= offset && fDocument.getChar(offset) == '/') {
+                                       fOffset= offset;
+                                       return;
+                               }
+                       }
+               }
+       }
+       
+       private void gotoCommentStart() throws BadLocationException {
+               while (0 < fOffset) {
+                       char current= fDocument.getChar(fOffset--);
+                       if (current == '*' && 0 <= fOffset && fDocument.getChar(fOffset) == '/')
+                               return;
+               }
+       }
+       
+       private void gotoStringStart(char delimiter) throws BadLocationException {
+               while (0 < fOffset) {
+                       char current= fDocument.getChar(fOffset);
+                       if (current == delimiter) {
+                               if ( !(0 <= fOffset && fDocument.getChar(fOffset -1) == '\\'))
+                                       return;
+                       }
+                       -- fOffset;
+               }
+       }
+               
+       private int readBackwards() throws BadLocationException {
+               
+               while (0 < fOffset) {
+                       -- fOffset;
+                       
+                       handleSingleLineComment();
+                       
+                       char current= fDocument.getChar(fOffset);
+                       switch (current) {
+                               case '/':
+                                       
+                                       if (fSkipComments && fOffset > 1) {
+                                               char next= fDocument.getChar(fOffset - 1);
+                                               if (next == '*') {
+                                                       // a comment ends, advance to the comment start
+                                                       fOffset -= 2;
+                                                       gotoCommentStart();
+                                                       continue;
+                                               }
+                                       }
+                                       
+                                       return current;
+                                       
+                               case '"':
+                               case '\'':
+                               
+                                       if (fSkipStrings) {
+                                               -- fOffset;
+                                               gotoStringStart(current);
+                                               continue;
+                                       }
+                                       
+                                       return current;
+                       }
+                       
+                       return current;
+               }
+               
+               return EOF;
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeScanner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCodeScanner.java
new file mode 100644 (file)
index 0000000..7fa89c3
--- /dev/null
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *     Andrew Ferguson (Symbian)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.text.rules.IRule;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.WordRule;
+
+import org.eclipse.cdt.core.model.ICLanguageKeywords;
+import org.eclipse.cdt.ui.text.AbstractCScanner;
+import org.eclipse.cdt.ui.text.ICColorConstants;
+import org.eclipse.cdt.ui.text.ITokenStoreFactory;
+
+import org.eclipse.cdt.internal.ui.text.util.CWordDetector;
+
+
+/**
+ * A C/C++ code scanner.
+ */
+public final class CCodeScanner extends AbstractCScanner {
+       
+    /** Properties for tokens. */
+       private static String[] fgTokenProperties= {
+               ICColorConstants.C_KEYWORD,
+               ICColorConstants.C_TYPE,
+        ICColorConstants.C_OPERATOR,
+        ICColorConstants.C_BRACES,
+        ICColorConstants.C_NUMBER,
+               ICColorConstants.C_DEFAULT,
+       };
+       private ICLanguageKeywords fKeywords;
+
+       /**
+        * Creates a C/C++ code scanner.
+        * @param factory 
+     * @param keywords  the keywords defined by the language dialect
+        */
+       public CCodeScanner(ITokenStoreFactory factory, ICLanguageKeywords keywords) {
+               super(factory.createTokenStore(fgTokenProperties));
+               fKeywords= keywords;
+               setRules(createRules());
+       }
+       
+       /*
+        * @see AbstractCScanner#createRules()
+        */
+       protected List<IRule> createRules() {
+                               
+               List<IRule> rules= new ArrayList<IRule>();              
+               IToken token;
+               
+               token= getToken(ICColorConstants.C_DEFAULT);
+
+               // Add generic white space rule.
+               rules.add(new CWhitespaceRule(token));
+
+               // Add word rule for keywords, types, and constants.
+               WordRule wordRule= new WordRule(new CWordDetector(), token);
+               
+               token= getToken(ICColorConstants.C_KEYWORD);
+               String[] keywords= fKeywords.getKeywords();
+               for (int i = 0; i < keywords.length; i++) {
+                       wordRule.addWord(keywords[i], token);
+               }
+        token= getToken(ICColorConstants.C_TYPE);
+               String[] types= fKeywords.getBuiltinTypes();
+               for (int i = 0; i < types.length; i++) {
+                       wordRule.addWord(types[i], token);
+               }
+        rules.add(wordRule);
+
+        token = getToken(ICColorConstants.C_NUMBER);
+        NumberRule numberRule = new NumberRule(token);
+        rules.add(numberRule);
+        
+        token = getToken(ICColorConstants.C_OPERATOR);
+        COperatorRule opRule = new COperatorRule(token);
+        rules.add(opRule);
+
+        token = getToken(ICColorConstants.C_BRACES);
+        CBraceRule braceRule = new CBraceRule(token);
+        rules.add(braceRule);
+        
+               setDefaultReturnToken(getToken(ICColorConstants.C_DEFAULT));
+               return rules;
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCommentScanner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCommentScanner.java
new file mode 100644 (file)
index 0000000..4686f48
--- /dev/null
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Andrew Ferguson (Symbian)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.rules.IRule;
+
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.AbstractCScanner;
+import org.eclipse.cdt.ui.text.ITokenStoreFactory;
+
+/**
+ * Default token-scanner used for plain (non-documentation-comment) single and multi-line comments, with awareness of
+ * task tags.
+ */
+public class CCommentScanner extends AbstractCScanner {
+       private static String TASK_TAG_KEY= PreferenceConstants.EDITOR_TASK_TAG_COLOR;
+               
+       public CCommentScanner(ITokenStoreFactory tokenStoreFactory, String defaultTokenProperty) {
+               this(tokenStoreFactory, defaultTokenProperty, new String[] { defaultTokenProperty, TASK_TAG_KEY });
+       }
+
+       private CCommentScanner(ITokenStoreFactory tokenStoreFactory, String defaultTokenProperty, String[] tokenProperties) {
+               super(tokenStoreFactory.createTokenStore(tokenProperties));
+               setRules(createRules(defaultTokenProperty));
+       }
+
+        protected List<IRule> createRules(String defaultTokenProperty) {
+                setDefaultReturnToken(getToken(defaultTokenProperty));
+                IPreferenceStore store= fTokenStore.getPreferenceStore();
+                TaskTagRule taskTagRule= new TaskTagRule(getToken(TASK_TAG_KEY), fDefaultReturnToken, store, null);
+                addPropertyChangeParticipant(taskTagRule);
+                return Collections.singletonList((IRule) taskTagRule);
+        }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCompositeReconcilingStrategy.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CCompositeReconcilingStrategy.java
new file mode 100644 (file)
index 0000000..ace51e2
--- /dev/null
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.reconciler.DirtyRegion;
+import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.internal.ui.text.spelling.CSpellingReconcileStrategy;
+
+/**
+ * Reconciling strategy for C/C++ code. This is a composite strategy containing
+ * the regular C/C++ model reconciler and the comment spelling strategy.
+ */
+public class CCompositeReconcilingStrategy  extends CompositeReconcilingStrategy {
+       private ITextEditor fEditor;
+       private CReconcilingStrategy fCStrategy;
+
+       /**
+        * Creates a new C/C++ reconciling strategy.
+        *
+        * @param viewer the source viewer
+        * @param editor the editor of the strategy's reconciler
+        * @param documentPartitioning the document partitioning this strategy uses for configuration
+        */
+       public CCompositeReconcilingStrategy(ISourceViewer viewer, ITextEditor editor, String documentPartitioning) {
+               fEditor= editor;
+               fCStrategy= new CReconcilingStrategy(editor);
+               setReconcilingStrategies(new IReconcilingStrategy[] {
+                       fCStrategy,
+                       new CSpellingReconcileStrategy(viewer, editor)
+               });
+       }
+
+       /**
+        * Returns the problem requestor for the editor's input element.
+        *
+        * @return the problem requestor for the editor's input element
+        */
+       private IProblemRequestorExtension getProblemRequestorExtension() {
+               IDocumentProvider p = fEditor.getDocumentProvider();
+               if (p == null) {
+                       return null;
+               }
+               IAnnotationModel m = p.getAnnotationModel(fEditor.getEditorInput());
+               if (m instanceof IProblemRequestorExtension)
+                       return (IProblemRequestorExtension) m;
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.reconciler.CompositeReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion)
+        */
+       @Override
+       public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
+               IProblemRequestorExtension e= getProblemRequestorExtension();
+               if (e != null) {
+                       try {
+                               e.beginReportingSequence();
+                               super.reconcile(dirtyRegion, subRegion);
+                       } finally {
+                               e.endReportingSequence();
+                       }
+               } else {
+                       super.reconcile(dirtyRegion, subRegion);
+               }
+       }
+
+       /*
+        * @see org.eclipse.jface.text.reconciler.CompositeReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion)
+        */
+       @Override
+       public void reconcile(IRegion partition) {
+               IProblemRequestorExtension e= getProblemRequestorExtension();
+               if (e != null) {
+                       try {
+                               e.beginReportingSequence();
+                               super.reconcile(partition);
+                       } finally {
+                               e.endReportingSequence();
+                       }
+               } else {
+                       super.reconcile(partition);
+               }
+       }
+
+       /*
+        * @see org.eclipse.jface.text.reconciler.CompositeReconcilingStrategy#initialReconcile()
+        */
+       @Override
+       public void initialReconcile() {
+               IProblemRequestorExtension e = getProblemRequestorExtension();
+               if (e != null) {
+                       try {
+                               e.beginReportingSequence();
+                               super.initialReconcile();
+                       } finally {
+                               e.endReportingSequence();
+                       }
+               } else {
+                       super.initialReconcile();
+               }
+       }
+
+       /**
+        * Called before reconciling is started.
+        */
+       public void aboutToBeReconciled() {
+               fCStrategy.aboutToBeReconciled();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CDoubleClickSelector.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CDoubleClickSelector.java
new file mode 100644 (file)
index 0000000..9735644
--- /dev/null
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextDoubleClickStrategy;
+import org.eclipse.jface.text.ITextViewer;
+
+/**
+ * Double click strategy aware of C identifier syntax rules.
+ */
+public class CDoubleClickSelector implements ITextDoubleClickStrategy {
+
+       protected static char[] fgBrackets= {'{', '}', '(', ')', '[', ']', '<', '>'};
+       private CPairMatcher fPairMatcher= new CPairMatcher(fgBrackets);
+
+       public CDoubleClickSelector() {
+               super();
+       }
+
+       /*
+        * @see org.eclipse.jface.text.ITextDoubleClickStrategy#doubleClicked(org.eclipse.jface.text.ITextViewer)
+        */
+       public void doubleClicked(ITextViewer textViewer) {
+               int offset= textViewer.getSelectedRange().x;
+
+               if (offset < 0)
+                       return;
+
+               IDocument document= textViewer.getDocument();
+
+               IRegion region= fPairMatcher.match(document, offset);
+               if (region != null && region.getLength() >= 2) {
+                       textViewer.setSelectedRange(region.getOffset() + 1, region.getLength() - 2);
+               } else {
+                       region= selectWord(document, offset);
+                       if (region != null && region.getLength() > 0) {
+                               textViewer.setSelectedRange(region.getOffset(), region.getLength());
+                       }
+               }
+       }
+
+       protected IRegion selectWord(IDocument document, int offset) {
+               return CWordFinder.findWord(document, offset);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CFormattingStrategy.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CFormattingStrategy.java
new file mode 100644 (file)
index 0000000..120634e
--- /dev/null
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import java.util.LinkedList;
+import java.util.Map;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.text.TypedPosition;
+import org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy;
+import org.eclipse.jface.text.formatter.FormattingContextProperties;
+import org.eclipse.jface.text.formatter.IFormattingContext;
+import org.eclipse.text.edits.MalformedTreeException;
+import org.eclipse.text.edits.TextEdit;
+
+import org.eclipse.cdt.core.formatter.CodeFormatter;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
+
+/**
+ * @author AChapiro
+ */
+public class CFormattingStrategy extends ContextBasedFormattingStrategy {
+       /** Documents to be formatted by this strategy */
+       private final LinkedList<IDocument> fDocuments= new LinkedList<IDocument>();
+       /** Partitions to be formatted by this strategy */
+       private final LinkedList<TypedPosition> fPartitions= new LinkedList<TypedPosition>();
+
+       /**
+        * Creates a new java formatting strategy.
+        */
+       public CFormattingStrategy() {
+               super();
+       }
+
+       /*
+        * @see org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy#format()
+        */
+       @Override
+       public void format() {
+               super.format();
+               
+               final IDocument document= fDocuments.removeFirst();
+               final TypedPosition partition= fPartitions.removeFirst();
+               
+               if (document != null && partition != null) {
+                       try {
+                               @SuppressWarnings("unchecked")
+                               final Map<String, String> preferences = getPreferences();
+                               final TextEdit edit = CodeFormatterUtil.format(
+                                               CodeFormatter.K_TRANSLATION_UNIT, document.get(),
+                                               partition.getOffset(), partition.getLength(), 0,
+                                               TextUtilities.getDefaultLineDelimiter(document),
+                                               preferences);
+
+                               if (edit != null)
+                                       edit.apply(document);
+                       } catch (MalformedTreeException e) {
+                               CUIPlugin.log(e);
+                       } catch (BadLocationException e) {
+                               // Can only happen on concurrent document modification - log and
+                               // bail out
+                               CUIPlugin.log(e);
+                       }
+               }
+       }
+
+       /*
+        * @see org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy#formatterStarts(org.eclipse.jface.text.formatter.IFormattingContext)
+        */
+       @Override
+       public void formatterStarts(final IFormattingContext context) {
+               super.formatterStarts(context);
+               
+               Object property = context.getProperty(FormattingContextProperties.CONTEXT_PARTITION);
+               if (property instanceof TypedPosition) {
+                       fPartitions.addLast((TypedPosition) property);
+               }
+               property= context.getProperty(FormattingContextProperties.CONTEXT_MEDIUM);
+               if (property instanceof IDocument) {                    
+                       fDocuments.addLast((IDocument) property);
+               }
+       }
+
+       /*
+        * @see org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy#formatterStops()
+        */
+       @Override
+       public void formatterStops() {
+               super.formatterStops();
+
+               fPartitions.clear();
+               fDocuments.clear();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeaderRule.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeaderRule.java
new file mode 100644 (file)
index 0000000..6525916
--- /dev/null
@@ -0,0 +1,167 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.text.rules.IRule;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.Token;
+
+/**
+ * Recognizes headers specified using angle brackets (e.g. #include <stdio.h>).
+ */
+public class CHeaderRule implements IRule {
+
+       /** Style token. */
+       private IToken fToken;
+
+       /**
+        * Creates a new CHeaderRule.
+        * 
+        * @param token
+        *            Style token.
+        */
+       public CHeaderRule(IToken token) {
+               fToken = token;
+       }
+
+       /**
+        * @see org.eclipse.jface.text.rules.IRule#evaluate(org.eclipse.jface.text.rules.ICharacterScanner)
+        */
+       public IToken evaluate(ICharacterScanner scanner) {
+               int current = scanner.read();
+               int lookAhead = 1;
+               int contentLength = 0;
+
+               if (current == '<' || current == '"') {
+                       int expected = current == '<' ? '>' : current;
+                       do {
+                               current = scanner.read();
+                               lookAhead++;
+                               if (current == expected) {
+                                       if (contentLength < 1) {
+                                               break;
+                                       }
+                                       
+                                       // Rewind and check for an #include.
+                                       seek(scanner, -lookAhead);
+                                       if (!followsIncludeDirective(scanner)) {
+                                               return Token.UNDEFINED;
+                                       }
+                                       
+                                       seek(scanner, lookAhead);
+                                       return fToken;
+                               }
+                               contentLength++;
+                       } while (current != ICharacterScanner.EOF && current != '\n');
+               }
+
+               seek(scanner, -lookAhead);
+               return Token.UNDEFINED;
+       }
+
+       /**
+        * Repositions the scanner.
+        * 
+        * @param scanner
+        *            Scanner.
+        * @param characters
+        *            Number of characters to move ahead (if positive) or behind (if
+        *            negative).
+        */
+       private void seek(ICharacterScanner scanner, int characters) {
+               if (characters < 0) {
+                       while (characters < 0) {
+                               scanner.unread();
+                               characters++;
+                       }
+               } else {
+                       while (characters > 0) {
+                               scanner.read();
+                               characters--;
+                       }
+               }
+       }
+
+       /**
+        * Returns true if the previous contents of the scanner is an #include
+        * directive.
+        * 
+        * @param scanner
+        *            Scanner.
+        * @return true if the previous contents of the scanner is an #include
+        *         directive.
+        */
+       private boolean followsIncludeDirective(ICharacterScanner scanner) {
+               int lookBehind = 0;
+               boolean result = false;
+
+               int current = unread(scanner);
+               lookBehind++;
+               if (Character.isWhitespace((char) current)) {
+                       do {
+                               current = unread(scanner);
+                               lookBehind++;
+                       } while (Character.isWhitespace((char) current));
+               }
+               scanner.read();
+               --lookBehind;
+               if (current == 'e' && searchBackwards(scanner, "include") ||  //$NON-NLS-1$
+                               current == 't' && searchBackwards(scanner, "include_next")) { //$NON-NLS-1$
+                       result = true;
+               }
+
+               seek(scanner, lookBehind);
+               return result;
+       }
+
+       /**
+        * Returns true if the given String was the last String read from the
+        * scanner.
+        * 
+        * @param scanner
+        *            Scanner.
+        * @param string
+        *            Expected String.
+        * @return true if the given String was the last String read from the
+        *         scanner.
+        */
+       private boolean searchBackwards(ICharacterScanner scanner, String string) {
+               int offset = 0;
+               for (int i = string.length() - 1; i >= 0; i--) {
+                       offset++;
+                       if (string.charAt(i) != unread(scanner)) {
+                               seek(scanner, offset);
+                               return false;
+                       }
+               }
+               seek(scanner, offset);
+               return true;
+       }
+
+       /**
+        * Unreads a single character from the scanner.
+        * 
+        * @param scanner
+        *            Scanner.
+        * @return the last character read from the scanner.
+        */
+       private int unread(ICharacterScanner scanner) {
+               scanner.unread();
+               int character = scanner.read();
+               scanner.unread();
+               return character;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpBookDescriptor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpBookDescriptor.java
new file mode 100644 (file)
index 0000000..7f083b7
--- /dev/null
@@ -0,0 +1,133 @@
+/**********************************************************************
+ * Copyright (c) 2004, 2005 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *     Intel Corporation - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.cdt.core.CCProjectNature;
+import org.eclipse.cdt.core.CProjectNature;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.ICHelpBook;
+import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * This class represents the CHelpBook settings
+ * 
+ * @since 2.1
+ */
+public class CHelpBookDescriptor {
+       final private static String ELEMENT_BOOK = "book"; //$NON-NLS-1$
+       final private static String ATTRIBUTE_TITLE = "title"; //$NON-NLS-1$
+       final private static String ATTRIBUTE_ENABLED = "enabled"; //$NON-NLS-1$
+       final private static String VALUE_TRUE = "true"; //$NON-NLS-1$
+       final private static String VALUE_FALSE = "false"; //$NON-NLS-1$
+
+       private boolean fEnabled = true;
+       private ICHelpBook fCHelpBook;
+       
+       CHelpBookDescriptor(ICHelpBook book){
+               this(book,null);
+       }
+
+       CHelpBookDescriptor(ICHelpBook book, Element parentElement){
+               fCHelpBook = book;
+               
+               if(parentElement == null)
+                       return;
+               
+               NodeList bookElements = parentElement.getElementsByTagName(ELEMENT_BOOK);
+               if(bookElements.getLength() == 0)
+                       return;
+               
+               String title = book.getTitle();
+               for(int i = 0; i < bookElements.getLength(); i++){
+                       Element bookElement = (Element)bookElements.item(i);
+                       if(title.equals(bookElement.getAttribute(ATTRIBUTE_TITLE))){
+                               fEnabled = VALUE_TRUE.equalsIgnoreCase(bookElement.getAttribute(ATTRIBUTE_ENABLED));
+                               break;
+                       }
+               }
+       }
+       
+       public boolean isEnabled(){
+               return fEnabled;
+       }
+       
+       public boolean matches(ICHelpInvocationContext context){
+               ITranslationUnit unit = context.getTranslationUnit();
+               if(unit != null)
+                       return matches(unit);
+               IProject project = context.getProject();
+               if(project != null)
+                       return matches(project);
+               return true;
+       }
+       
+       public boolean matches(IProject project){
+               ICHelpBook book = getCHelpBook();
+               boolean bMatches = false;
+               switch(book.getCHelpType()){
+                       case ICHelpBook.HELP_TYPE_CPP:
+                               try{
+                                       bMatches = project.hasNature(CCProjectNature.CC_NATURE_ID);
+                               }catch(CoreException e){
+                               }
+                               break;
+                       case ICHelpBook.HELP_TYPE_C:
+                       case ICHelpBook.HELP_TYPE_ASM:
+                               try{
+                                       bMatches = project.hasNature(CProjectNature.C_NATURE_ID);
+                               }catch(CoreException e){
+                               }
+                               break;
+                       default:
+                               bMatches = true;
+               }
+               return bMatches;
+       }
+       
+       public boolean matches(ITranslationUnit unit){
+               ICHelpBook book = getCHelpBook();
+               boolean bMatches = false;
+               switch(book.getCHelpType()){
+                       case ICHelpBook.HELP_TYPE_CPP:
+                               bMatches = unit.isCXXLanguage();
+                               break;
+                       case ICHelpBook.HELP_TYPE_C:
+                               bMatches = unit.isCLanguage() || unit.isCXXLanguage();
+                               break;
+                       case ICHelpBook.HELP_TYPE_ASM:
+                               bMatches = unit.isASMLanguage();
+                               break;
+                       default:
+                               bMatches = true;
+               }
+               return bMatches;
+       }
+       
+       public void enable(boolean enable){
+               fEnabled = enable;
+       }
+       
+       public ICHelpBook getCHelpBook(){
+               return fCHelpBook;
+       }
+       
+       public void serialize(Document doc, Element parentElement){
+               Element bookElement = doc.createElement(ELEMENT_BOOK);
+               bookElement.setAttribute(ATTRIBUTE_TITLE,getCHelpBook().getTitle());
+               bookElement.setAttribute(ATTRIBUTE_ENABLED,fEnabled ? VALUE_TRUE : VALUE_FALSE);
+               parentElement.appendChild(bookElement);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpProviderDescriptor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpProviderDescriptor.java
new file mode 100644 (file)
index 0000000..8e939c9
--- /dev/null
@@ -0,0 +1,181 @@
+/**********************************************************************
+ * Copyright (c) 2004, 2008 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *     Intel Corporation - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.ISafeRunnable;
+import org.eclipse.core.runtime.SafeRunner;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import org.eclipse.cdt.ui.ICHelpBook;
+import org.eclipse.cdt.ui.ICHelpProvider;
+import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
+
+/**
+ * This class represents the CHelpProvider settings
+ * 
+ * @since 2.1
+ */
+public class CHelpProviderDescriptor {
+       private static final String CLASS= "class"; //$NON-NLS-1$
+
+       final private static String ELEMENT_PROVIDER = "provider"; //$NON-NLS-1$
+       final private static String ATTRIBUTE_ID = "id"; //$NON-NLS-1$
+
+       private static Map<String, ICHelpProvider> fProvidersMap = null;
+
+       private ICHelpProvider fHelpProvider = null;
+       private IConfigurationElement fConfigElement;
+       private CHelpBookDescriptor fHelpBookDescriptors[] = null;
+       private IProject fProject;
+
+       public CHelpProviderDescriptor(IProject project, IConfigurationElement element){
+               this(project,element,null);
+       }
+       
+       public CHelpProviderDescriptor(IProject project, IConfigurationElement configElement, Element parentElement){
+               fConfigElement = configElement;
+               fProject = project;
+               
+               if(parentElement == null)
+                       return;
+
+               Element projectElement = getDescriptorElement(parentElement);
+                       
+               if(projectElement == null)
+                       return;
+               
+               getCHelpBookDescriptors(projectElement);
+       }
+       
+       private Element getDescriptorElement(Element parentElement){
+               String id = getConfigurationElement().getAttribute(ATTRIBUTE_ID);
+               if(id == null || "".equals(id)) //$NON-NLS-1$
+                       return null;
+
+               NodeList nodes = parentElement.getElementsByTagName(ELEMENT_PROVIDER);
+               for(int i = 0; i < nodes.getLength(); i++){
+                       Element descriptorEl = (Element)nodes.item(i);
+                       if(id.equals(descriptorEl.getAttribute(ATTRIBUTE_ID))){
+                               return descriptorEl;
+                       }
+               }
+               return null;
+       }
+
+       private static Map<String, ICHelpProvider> getProvidersMap(){
+               if(fProvidersMap == null){
+                       fProvidersMap = new HashMap<String, ICHelpProvider>();
+               }
+               return fProvidersMap;
+       }
+       
+       private static ICHelpProvider getCHelpProvider(IConfigurationElement element){
+               String id = element.getAttribute(ATTRIBUTE_ID);
+               if(id == null || "".equals(id)) //$NON-NLS-1$
+                       return null;
+
+               Map<String, ICHelpProvider> providersMap = getProvidersMap();
+               try{
+                       ICHelpProvider provider = providersMap.get(id);
+                       if(provider == null){
+                               provider = (ICHelpProvider)element.createExecutableExtension(CLASS);
+                               providersMap.put(id,provider);
+
+                       final ICHelpProvider c = provider;
+                       // Run the initialiser the class
+                       ISafeRunnable runnable = new ISafeRunnable() {
+                               public void run() throws Exception {
+                                       // Initialize
+                                       c.initialize();
+                               }
+                               public void handleException(Throwable exception) {
+                               }
+                       };
+                       SafeRunner.run(runnable);
+                       }
+                       return provider;
+               }
+               catch(Exception e){
+                       return null;
+               }
+       }
+       
+       public IConfigurationElement getConfigurationElement(){
+               return fConfigElement;
+       }
+
+       public ICHelpProvider getCHelpProvider(){
+               if(fHelpProvider == null)
+                       fHelpProvider = getCHelpProvider(fConfigElement);
+               return fHelpProvider;
+       }
+       
+       public CHelpBookDescriptor [] getCHelpBookDescriptors(Element projectElement){
+               if (fHelpBookDescriptors == null || projectElement != null){
+                       ICHelpProvider provider = getCHelpProvider();
+                       if (provider != null && fProject != null) {
+                               ICHelpBook books[] = provider.getCHelpBooks();
+                               if(books != null){
+                                       List<CHelpBookDescriptor> descriptorList = new ArrayList<CHelpBookDescriptor>();
+                                       for(int i = 0; i < books.length; i++){
+                                               CHelpBookDescriptor des = new CHelpBookDescriptor(books[i],projectElement);
+                                               if(des.matches(fProject))
+                                                       descriptorList.add(des);
+                                       }
+                                       fHelpBookDescriptors = descriptorList.toArray(new CHelpBookDescriptor[descriptorList.size()]);
+                               }
+                       }
+                       if(fHelpBookDescriptors == null)
+                               fHelpBookDescriptors = new CHelpBookDescriptor[0];
+               }
+               return fHelpBookDescriptors;
+       }
+
+       public CHelpBookDescriptor [] getCHelpBookDescriptors(){
+               return getCHelpBookDescriptors(null);
+       }
+
+       ICHelpBook[] getEnabledMatchedCHelpBooks(ICHelpInvocationContext context){
+               CHelpBookDescriptor bookDescriptors[] = getCHelpBookDescriptors();
+               if(bookDescriptors.length == 0)
+                       return null;
+               List<ICHelpBook> bookList = new ArrayList<ICHelpBook>();
+               for(int i = 0; i < bookDescriptors.length; i++){
+                       if(bookDescriptors[i].isEnabled() && bookDescriptors[i].matches(context))
+                               bookList.add(bookDescriptors[i].getCHelpBook());
+               }
+               return bookList.toArray(new ICHelpBook[bookList.size()]);
+       }
+       
+       public void serialize(Document doc, Element parentElement){
+               String id = getConfigurationElement().getAttribute(ATTRIBUTE_ID);
+               if(id == null || "".equals(id)) //$NON-NLS-1$
+                       return;
+
+               CHelpBookDescriptor bookDescriptors[] = getCHelpBookDescriptors();
+               Element providerElement = doc.createElement(ELEMENT_PROVIDER);
+               providerElement.setAttribute(ATTRIBUTE_ID,id);
+               parentElement.appendChild(providerElement);
+               
+               for(int i = 0; i < bookDescriptors.length; i++){
+                       bookDescriptors[i].serialize(doc,providerElement);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpSettings.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpSettings.java
new file mode 100644 (file)
index 0000000..2f4838b
--- /dev/null
@@ -0,0 +1,186 @@
+/**********************************************************************
+ * Copyright (c) 2004, 2008 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *     Intel Corporation - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.ICHelpBook;
+import org.eclipse.cdt.ui.ICHelpProvider;
+import org.eclipse.cdt.ui.ICHelpResourceDescriptor;
+import org.eclipse.cdt.ui.IFunctionSummary;
+import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * This class represents the Help settings for the current project
+ * 
+ * @since 2.1
+ */
+public class CHelpSettings {
+       public static final String CONTRIBUTION_EXTENSION = "CHelpProvider"; //$NON-NLS-1$
+
+       final private static String ELEMENT_PROJECT = "project"; //$NON-NLS-1$
+       final private static String ATTRIBUTE_NAME = "name"; //$NON-NLS-1$
+
+       private IProject fProject;
+       private static IConfigurationElement fConfigElements[] = null;
+       private CHelpProviderDescriptor fProviderDescriptors[] = null;
+       
+       public CHelpSettings(IProject project){
+               this(project,null);
+       }
+       
+       public CHelpSettings(IProject project, Element parentElement){
+               fProject = project;
+               
+               if(parentElement == null)
+                       return;
+               
+               Element projectElement = getProjectElement(parentElement);
+               if(projectElement == null)
+                       return;
+               
+               getCHelpProviderDescriptors(projectElement);
+       }
+       
+       private Element getProjectElement(Element parentElement){
+               NodeList nodes = parentElement.getElementsByTagName(ELEMENT_PROJECT);
+               for(int i = 0; i < nodes.getLength(); i++){
+                       Element curProject = (Element)nodes.item(i);
+                       if(getProject().getName().equals(curProject.getAttribute(ATTRIBUTE_NAME)))
+                               return curProject;
+               }
+               return null;
+       }
+
+       public IProject getProject(){
+               return fProject;
+       }
+       
+       public CHelpProviderDescriptor[] getCHelpProviderDescriptors(Element projectElement){
+               if(fProviderDescriptors == null || projectElement != null){
+                       IConfigurationElement congifElements[] = getConfigElements();
+                       fProviderDescriptors = new CHelpProviderDescriptor[congifElements.length];
+                       for(int i = 0; i < congifElements.length; i++){
+                               fProviderDescriptors[i] = new CHelpProviderDescriptor(fProject,congifElements[i],projectElement);
+                       }
+               }
+               return fProviderDescriptors;
+       }
+
+       public CHelpProviderDescriptor[] getCHelpProviderDescriptors(){
+               return getCHelpProviderDescriptors(null);
+       }
+
+       public CHelpBookDescriptor[] getCHelpBookDescriptors(){
+               CHelpProviderDescriptor providerDescriptors[] = getCHelpProviderDescriptors();
+               if(providerDescriptors.length == 0)
+                       return new CHelpBookDescriptor[0];
+               
+               List<CHelpBookDescriptor> bookList = new ArrayList<CHelpBookDescriptor>();      
+               for(int i = 0; i < providerDescriptors.length; i++){
+                       CHelpBookDescriptor bookDescriptors[] = providerDescriptors[i].getCHelpBookDescriptors();
+                       if(bookDescriptors.length != 0)
+                               bookList.addAll(Arrays.asList(bookDescriptors));
+               }
+               return bookList.toArray(new CHelpBookDescriptor[bookList.size()]);
+       }
+       
+       private static IConfigurationElement[] getConfigElements(){
+               if(fConfigElements == null){
+                       fConfigElements= Platform.getExtensionRegistry().getConfigurationElementsFor(CUIPlugin.PLUGIN_ID, CONTRIBUTION_EXTENSION);
+                       if(fConfigElements == null)
+                               fConfigElements = new IConfigurationElement[0];
+               }
+               return fConfigElements;
+       }
+       
+       public IFunctionSummary getFunctionInfo(ICHelpInvocationContext context, String name){
+               CHelpProviderDescriptor providerDescriptors[] = getCHelpProviderDescriptors();
+               for(int i = 0; i < providerDescriptors.length; i++){
+                       ICHelpBook books[] = providerDescriptors[i].getEnabledMatchedCHelpBooks(context);
+                       if(books != null && books.length != 0){
+                               ICHelpProvider provider = providerDescriptors[i].getCHelpProvider();
+                               if(provider != null){
+                                       IFunctionSummary summary = provider.getFunctionInfo(context,books,name);
+                                       if(summary != null)
+                                               return summary;
+                               }
+                       }
+               }
+               return null;
+       }
+       
+       public IFunctionSummary[] getMatchingFunctions(ICHelpInvocationContext context, String frag){
+               CHelpProviderDescriptor providerDescriptors[] = getCHelpProviderDescriptors();
+               List<IFunctionSummary> sumaryList = new ArrayList<IFunctionSummary>();
+               for(int i = 0; i < providerDescriptors.length; i++){
+                       ICHelpBook books[] = providerDescriptors[i].getEnabledMatchedCHelpBooks(context);
+                       if(books != null && books.length != 0){
+                               ICHelpProvider provider = providerDescriptors[i].getCHelpProvider();
+                               if(provider != null){
+                                       IFunctionSummary summaries[] = provider.getMatchingFunctions(context,books,frag);
+                                       if(summaries != null && summaries.length != 0)
+                                               sumaryList.addAll(Arrays.asList(summaries));
+                               }
+                       }
+               }
+               if(sumaryList.size() == 0)
+                       return null;
+               
+               return sumaryList.toArray(new IFunctionSummary[sumaryList.size()]);
+       }
+       
+       public ICHelpResourceDescriptor[] getHelpResources(ICHelpInvocationContext context, String name){
+               CHelpProviderDescriptor providerDescriptors[] = getCHelpProviderDescriptors();
+               List<ICHelpResourceDescriptor> resourcesList = new ArrayList<ICHelpResourceDescriptor>();
+               for(int i = 0; i < providerDescriptors.length; i++){
+                       ICHelpBook books[] = providerDescriptors[i].getEnabledMatchedCHelpBooks(context);
+                       if(books != null && books.length != 0){
+                               ICHelpProvider provider = providerDescriptors[i].getCHelpProvider();
+                               if(provider != null){
+                                       ICHelpResourceDescriptor resources[] = provider.getHelpResources(context,books,name);
+                                       if(resources != null && resources.length != 0)
+                                               resourcesList.addAll(Arrays.asList(resources));
+                               }
+                       }
+               }
+               if(resourcesList.size() == 0)
+                       return null;
+               
+               return resourcesList.toArray(new ICHelpResourceDescriptor[resourcesList.size()]);
+       }
+       
+       public void serialize(Document doc, Element parentElement){
+               CHelpProviderDescriptor providerDescriptors[] = getCHelpProviderDescriptors();
+               Element oldProjectElement = getProjectElement(parentElement);
+
+               Element projectElement = doc.createElement(ELEMENT_PROJECT);
+               projectElement.setAttribute(ATTRIBUTE_NAME,getProject().getName());
+
+               if(oldProjectElement != null)
+                       parentElement.replaceChild(projectElement,oldProjectElement);
+               else
+                       parentElement.appendChild(projectElement);
+
+               for(int i = 0; i < providerDescriptors.length; i++){
+                       providerDescriptors[i].serialize(doc,projectElement);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeuristicScanner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeuristicScanner.java
new file mode 100644 (file)
index 0000000..9c14201
--- /dev/null
@@ -0,0 +1,1205 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin, Google
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import java.util.Arrays;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.text.TypedRegion;
+
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+/**
+ * Utility methods for heuristic based C manipulations in an incomplete C source file.
+ *
+ * <p>An instance holds some internal position in the document and is therefore not thread-safe.</p>
+ */
+public final class CHeuristicScanner implements Symbols {
+       /**
+        * Returned by all methods when the requested position could not be found, or if a
+        * {@link BadLocationException} was thrown while scanning.
+        */
+       public static final int NOT_FOUND= -1;
+
+       /**
+        * Special bound parameter that means either -1 (backward scanning) or
+        * <code>fDocument.getLength()</code> (forward scanning).
+        */
+       public static final int UNBOUND= -2;
+
+
+       /* character constants */
+       private static final char LBRACE= '{';
+       private static final char RBRACE= '}';
+       private static final char LPAREN= '(';
+       private static final char RPAREN= ')';
+       private static final char SEMICOLON= ';';
+       private static final char COLON= ':';
+       private static final char COMMA= ',';
+       private static final char LBRACKET= '[';
+       private static final char RBRACKET= ']';
+       private static final char QUESTIONMARK= '?';
+       private static final char EQUAL= '=';
+       private static final char LANGLE= '<';
+       private static final char RANGLE= '>';
+       private static final char DOT= '.';
+       private static final char MINUS= '-';
+       private static final char PLUS= '+';
+       private static final char TILDE= '~';
+
+       /**
+        * Specifies the stop condition, upon which the <code>scanXXX</code> methods will decide whether
+        * to keep scanning or not. This interface may implemented by clients.
+        */
+       private static abstract class StopCondition {
+               /**
+                * Instructs the scanner to return the current position.
+                *
+                * @param ch the char at the current position
+                * @param position the current position
+                * @param forward the iteration direction
+                * @return <code>true</code> if the stop condition is met.
+                */
+               public abstract boolean stop(char ch, int position, boolean forward);
+
+               /**
+                * Asks the condition to return the next position to query. The default
+                * is to return the next/previous position.
+                *
+                * @return the next position to scan
+                */
+               public int nextPosition(int position, boolean forward) {
+                       return forward ? position + 1 : position - 1;
+               }
+       }
+
+       /**
+        * Stops upon a non-whitespace (as defined by {@link Character#isWhitespace(char)}) character.
+        */
+       private static class NonWhitespace extends StopCondition {
+               /*
+                * @see org.eclipse.cdt.internal.ui.text.CHeuristicScanner.StopCondition#stop(char)
+                */
+               @Override
+               public boolean stop(char ch, int position, boolean forward) {
+                       return !Character.isWhitespace(ch);
+               }
+       }
+
+       /**
+        * Stops upon a non-whitespace character in the default partition.
+        *
+        * @see NonWhitespace
+        */
+       private final class NonWhitespaceDefaultPartition extends NonWhitespace {
+               /*
+                * @see org.eclipse.cdt.internal.ui.text.CHeuristicScanner.StopCondition#stop(char)
+                */
+               @Override
+               public boolean stop(char ch, int position, boolean forward) {
+                       return super.stop(ch, position, true) && isDefaultPartition(position);
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.text.CHeuristicScanner.StopCondition#nextPosition(int, boolean)
+                */
+               @Override
+               public int nextPosition(int position, boolean forward) {
+                       ITypedRegion partition= getPartition(position);
+                       if (fPartition.equals(partition.getType()))
+                               return super.nextPosition(position, forward);
+
+                       if (forward) {
+                               int end= partition.getOffset() + partition.getLength();
+                               if (position < end)
+                                       return end;
+                       } else {
+                               int offset= partition.getOffset();
+                               if (position > offset)
+                                       return offset - 1;
+                       }
+                       return super.nextPosition(position, forward);
+               }
+       }
+
+       /**
+        * Stops upon a non-java identifier (as defined by {@link Character#isJavaIdentifierPart(char)}) character.
+        */
+       private static class NonJavaIdentifierPart extends StopCondition {
+               /*
+                * @see org.eclipse.cdt.internal.ui.text.CHeuristicScanner.StopCondition#stop(char)
+                */
+               @Override
+               public boolean stop(char ch, int position, boolean forward) {
+                       return !Character.isJavaIdentifierPart(ch);
+               }
+       }
+
+       /**
+        * Stops upon a non-java identifier character in the default partition.
+        *
+        * @see NonJavaIdentifierPart
+        */
+       private final class NonJavaIdentifierPartDefaultPartition extends NonJavaIdentifierPart {
+               /*
+                * @see org.eclipse.cdt.internal.ui.text.CHeuristicScanner.StopCondition#stop(char)
+                */
+               @Override
+               public boolean stop(char ch, int position, boolean forward) {
+                       return super.stop(ch, position, true) || !isDefaultPartition(position);
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.text.CHeuristicScanner.StopCondition#nextPosition(int, boolean)
+                */
+               @Override
+               public int nextPosition(int position, boolean forward) {
+                       ITypedRegion partition= getPartition(position);
+                       if (fPartition.equals(partition.getType()))
+                               return super.nextPosition(position, forward);
+
+                       if (forward) {
+                               int end= partition.getOffset() + partition.getLength();
+                               if (position < end)
+                                       return end;
+                       } else {
+                               int offset= partition.getOffset();
+                               if (position > offset)
+                                       return offset - 1;
+                       }
+                       return super.nextPosition(position, forward);
+               }
+       }
+
+       /**
+        * Stops upon a character in the default partition that matches the given character list.
+        */
+       private final class CharacterMatch extends StopCondition {
+               private final char[] fChars;
+
+               /**
+                * Creates a new instance.
+                * @param ch the single character to match
+                */
+               public CharacterMatch(char ch) {
+                       this(new char[] {ch});
+               }
+
+               /**
+                * Creates a new instance.
+                * @param chars the chars to match.
+                */
+               public CharacterMatch(char[] chars) {
+                       Assert.isNotNull(chars);
+                       Assert.isTrue(chars.length > 0);
+                       fChars= chars;
+                       Arrays.sort(chars);
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.text.CHeuristicScanner.StopCondition#stop(char, int)
+                */
+               @Override
+               public boolean stop(char ch, int position, boolean forward) {
+                       return Arrays.binarySearch(fChars, ch) >= 0 && isDefaultPartition(position);
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.text.CHeuristicScanner.StopCondition#nextPosition(int, boolean)
+                */
+               @Override
+               public int nextPosition(int position, boolean forward) {
+                       ITypedRegion partition= getPartition(position);
+                       if (fPartition.equals(partition.getType()))
+                               return super.nextPosition(position, forward);
+
+                       if (forward) {
+                               int end= partition.getOffset() + partition.getLength();
+                               if (position < end)
+                                       return end;
+                       } else {
+                               int offset= partition.getOffset();
+                               if (position > offset)
+                                       return offset - 1;
+                       }
+                       return super.nextPosition(position, forward);
+               }
+       }
+
+       /** The document being scanned. */
+       private final IDocument fDocument;
+       /** The partitioning being used for scanning. */
+       private final String fPartitioning;
+       /** The partition to scan in. */
+       private final String fPartition;
+
+       /* internal scan state */
+
+       /** the most recently read character. */
+       private char fChar;
+       /** the most recently read position. */
+       private int fPos;
+       /**
+        * The most recently used partition.
+        */
+       private ITypedRegion fCachedPartition= new TypedRegion(-1, 0, "__no_partition_at_all"); //$NON-NLS-1$
+
+       /* preset stop conditions */
+       private final StopCondition fNonWSDefaultPart= new NonWhitespaceDefaultPartition();
+       private final static StopCondition fNonWS= new NonWhitespace();
+       private final StopCondition fNonIdent= new NonJavaIdentifierPartDefaultPartition();
+
+       /**
+        * Creates a new instance.
+        *
+        * @param document the document to scan
+        * @param partitioning the partitioning to use for scanning
+        * @param partition the partition to scan in
+        */
+       public CHeuristicScanner(IDocument document, String partitioning, String partition) {
+               Assert.isLegal(document != null);
+               Assert.isLegal(partitioning != null);
+               Assert.isLegal(partition != null);
+               fDocument= document;
+               fPartitioning= partitioning;
+               fPartition= partition;
+       }
+
+       /**
+        * Calls <code>this(document, ICPartitions.C_PARTITIONING, IDocument.DEFAULT_CONTENT_TYPE)</code>.
+        *
+        * @param document the document to scan.
+        */
+       public CHeuristicScanner(IDocument document) {
+               this(document, ICPartitions.C_PARTITIONING, IDocument.DEFAULT_CONTENT_TYPE);
+       }
+
+       /**
+        * Returns the most recent internal scan position.
+        *
+        * @return the most recent internal scan position.
+        */
+       public int getPosition() {
+               return fPos;
+       }
+
+       /**
+        * Returns the next token in forward direction, starting at <code>start</code>, and not extending
+        * further than <code>bound</code>. The return value is one of the constants defined in {@link Symbols}.
+        * After a call, {@link #getPosition()} will return the position just after the scanned token
+        * (i.e. the next position that will be scanned).
+        *
+        * @param start the first character position in the document to consider
+        * @param bound the first position not to consider any more
+        * @return a constant from {@link Symbols} describing the next token
+        */
+       public int nextToken(int start, int bound) {
+               int pos= scanForward(start, bound, fNonWS);
+               if (pos == NOT_FOUND)
+                       return TokenEOF;
+               try {
+                       // check for string or char literal
+                       char ch = fDocument.getChar(pos);
+                       if (ch == '"' || ch == '\'') {
+                               fChar= ch;
+                               fPos= fNonWSDefaultPart.nextPosition(pos, true);
+                               return TokenOTHER;
+                       }
+               } catch (BadLocationException exc) {
+               }
+               pos= scanForward(pos, bound, fNonWSDefaultPart);
+               if (pos == NOT_FOUND)
+                       return TokenEOF;
+
+               fPos++;
+
+               switch (fChar) {
+                       case LBRACE:
+                               return TokenLBRACE;
+                       case RBRACE:
+                               return TokenRBRACE;
+                       case LBRACKET:
+                               return TokenLBRACKET;
+                       case RBRACKET:
+                               return TokenRBRACKET;
+                       case LPAREN:
+                               return TokenLPAREN;
+                       case RPAREN:
+                               return TokenRPAREN;
+                       case SEMICOLON:
+                               return TokenSEMICOLON;
+                       case COLON:
+                               switch (peekNextChar()) {
+                               case COLON:
+                                       ++fPos;
+                                       return TokenDOUBLECOLON;
+                               }
+                               return TokenCOLON;
+                       case COMMA:
+                               return TokenCOMMA;
+                       case QUESTIONMARK:
+                               return TokenQUESTIONMARK;
+                       case EQUAL:
+                               return TokenEQUAL;
+                       case LANGLE:
+                               switch (peekNextChar()) {
+                               case LANGLE:
+                                       ++fPos;
+                                       return TokenSHIFTLEFT;
+                               case EQUAL:
+                                       ++fPos;
+                                       return TokenOTHER;
+                               }
+                               return TokenLESSTHAN;
+                       case RANGLE:
+                               switch (peekNextChar()) {
+                               case RANGLE:
+                                       ++fPos;
+                                       return TokenSHIFTRIGHT;
+                               case EQUAL:
+                                       ++fPos;
+                                       return TokenOTHER;
+                               }
+                               return TokenGREATERTHAN;
+                       case DOT:
+                               return TokenDOT;
+                       case MINUS:
+                               switch (peekNextChar()) {
+                               case RANGLE:
+                                       ++fPos;
+                                       return TokenARROW;
+                               }
+                               return TokenMINUS;
+                       case PLUS:
+                               return TokenPLUS;
+                       case TILDE:
+                               return TokenTILDE;
+               }
+
+               // else
+               if (Character.isJavaIdentifierPart(fChar)) {
+                       // assume an identifier or keyword
+                       int from= pos, to;
+                       pos= scanForward(pos + 1, bound, fNonIdent);
+                       if (pos == NOT_FOUND)
+                               to= bound == UNBOUND ? fDocument.getLength() : bound;
+                       else
+                               to= pos;
+
+                       String identOrKeyword;
+                       try {
+                               identOrKeyword= fDocument.get(from, to - from);
+                       } catch (BadLocationException e) {
+                               return TokenEOF;
+                       }
+
+                       return getToken(identOrKeyword);
+
+
+               }
+               // operators, number literals etc
+               return TokenOTHER;
+       }
+
+       /**
+        * Returns the next token in backward direction, starting at <code>start</code>, and not extending
+        * further than <code>bound</code>. The return value is one of the constants defined in {@link Symbols}.
+        * After a call, {@link #getPosition()} will return the position just before the scanned token
+        * starts (i.e. the next position that will be scanned).
+        *
+        * @param start the first character position in the document to consider
+        * @param bound the first position not to consider any more
+        * @return a constant from {@link Symbols} describing the previous token
+        */
+       public int previousToken(int start, int bound) {
+               int pos= scanBackward(start, bound, fNonWSDefaultPart);
+               if (pos == NOT_FOUND)
+                       return TokenEOF;
+
+               fPos--;
+
+               switch (fChar) {
+                       case LBRACE:
+                               return TokenLBRACE;
+                       case RBRACE:
+                               return TokenRBRACE;
+                       case LBRACKET:
+                               return TokenLBRACKET;
+                       case RBRACKET:
+                               return TokenRBRACKET;
+                       case LPAREN:
+                               return TokenLPAREN;
+                       case RPAREN:
+                               return TokenRPAREN;
+                       case SEMICOLON:
+                               return TokenSEMICOLON;
+                       case COLON:
+                               switch (peekPreviousChar()) {
+                               case COLON:
+                                       --fPos;
+                                       return TokenDOUBLECOLON;
+                               }
+                               return TokenCOLON;
+                       case COMMA:
+                               return TokenCOMMA;
+                       case QUESTIONMARK:
+                               return TokenQUESTIONMARK;
+                       case EQUAL:
+                               switch (peekPreviousChar()) {
+                               case RANGLE:
+                               case LANGLE:
+                                       --fPos;
+                                       return TokenOTHER;
+                               }
+                               return TokenEQUAL;
+                       case LANGLE:
+                               switch (peekPreviousChar()) {
+                               case LANGLE:
+                                       --fPos;
+                                       return TokenSHIFTLEFT;
+                               }
+                               return TokenLESSTHAN;
+                       case RANGLE:
+                               switch (peekPreviousChar()) {
+                               case RANGLE:
+                                       --fPos;
+                                       return TokenSHIFTRIGHT;
+                               case MINUS:
+                                       --fPos;
+                                       return TokenARROW;
+                               }
+                               return TokenGREATERTHAN;
+                       case DOT:
+                               return TokenDOT;
+                       case MINUS:
+                               return TokenMINUS;
+                       case PLUS:
+                               return TokenPLUS;
+                       case TILDE:
+                               return TokenTILDE;
+               }
+
+               // else
+               if (Character.isJavaIdentifierPart(fChar)) {
+                       // assume an ident or keyword
+                       int from, to= pos + 1;
+                       pos= scanBackward(pos - 1, bound, fNonIdent);
+                       if (pos == NOT_FOUND)
+                               from= bound == UNBOUND ? 0 : bound + 1;
+                       else
+                               from= pos + 1;
+
+                       String identOrKeyword;
+                       try {
+                               identOrKeyword= fDocument.get(from, to - from);
+                       } catch (BadLocationException e) {
+                               return TokenEOF;
+                       }
+
+                       return getToken(identOrKeyword);
+               }
+               // operators, number literals etc
+               return TokenOTHER;
+       }
+
+       /**
+        * @return the next char without shifting the position
+        */
+       private char peekNextChar() {
+               if (fPos + 1 < fDocument.getLength()) {
+                       try {
+                               return fDocument.getChar(fPos + 1);
+                       } catch (BadLocationException exc) {
+                       }
+               }
+               return (char)-1;
+       }
+
+       /**
+        * @return the previous char without shifting the position
+        */
+       private char peekPreviousChar() {
+               if (fPos >= 0) {
+                       try {
+                               return fDocument.getChar(fPos);
+                       } catch (BadLocationException e) {
+                       }
+               }
+               return (char)-1;
+       }
+
+       /**
+        * Returns one of the keyword constants or <code>TokenIDENT</code> for a scanned identifier.
+        *
+        * @param s a scanned identifier
+        * @return one of the constants defined in {@link Symbols}
+        */
+       private int getToken(String s) {
+               Assert.isNotNull(s);
+
+               switch (s.length()) {
+                       case 2:
+                               if ("if".equals(s)) //$NON-NLS-1$
+                                       return TokenIF;
+                               if ("do".equals(s)) //$NON-NLS-1$
+                                       return TokenDO;
+                               break;
+                       case 3:
+                               if ("for".equals(s)) //$NON-NLS-1$
+                                       return TokenFOR;
+                               if ("try".equals(s)) //$NON-NLS-1$
+                                       return TokenTRY;
+                               if ("new".equals(s)) //$NON-NLS-1$
+                                       return TokenNEW;
+                               break;
+                       case 4:
+                               if ("case".equals(s)) //$NON-NLS-1$
+                                       return TokenCASE;
+                               if ("else".equals(s)) //$NON-NLS-1$
+                                       return TokenELSE;
+                               if ("enum".equals(s)) //$NON-NLS-1$
+                                       return TokenENUM;
+                               if ("goto".equals(s)) //$NON-NLS-1$
+                                       return TokenGOTO;
+                               break;
+                       case 5:
+                               if ("break".equals(s)) //$NON-NLS-1$
+                                       return TokenBREAK;
+                               if ("catch".equals(s)) //$NON-NLS-1$
+                                       return TokenCATCH;
+                               if ("class".equals(s)) //$NON-NLS-1$
+                                       return TokenCLASS;
+                               if ("const".equals(s)) //$NON-NLS-1$
+                                       return TokenCONST;
+                               if ("while".equals(s)) //$NON-NLS-1$
+                                       return TokenWHILE;
+                               if ("union".equals(s)) //$NON-NLS-1$
+                                       return TokenUNION;
+                               if ("using".equals(s)) //$NON-NLS-1$
+                                       return TokenUSING;
+                               if ("throw".equals(s)) //$NON-NLS-1$
+                                       return TokenTHROW;
+                               break;
+                       case 6:
+                               if ("delete".equals(s)) //$NON-NLS-1$
+                                       return TokenDELETE;
+                               if ("public".equals(s)) //$NON-NLS-1$
+                                       return TokenPUBLIC;
+                               if ("return".equals(s)) //$NON-NLS-1$
+                                       return TokenRETURN;
+                               if ("static".equals(s)) //$NON-NLS-1$
+                                       return TokenSTATIC;
+                               if ("struct".equals(s)) //$NON-NLS-1$
+                                       return TokenSTRUCT;
+                               if ("switch".equals(s)) //$NON-NLS-1$
+                                       return TokenSWITCH;
+                               if ("extern".equals(s)) //$NON-NLS-1$
+                                       return TokenEXTERN;
+                               break;
+                       case 7:
+                               if ("default".equals(s)) //$NON-NLS-1$
+                                       return TokenDEFAULT;
+                               if ("private".equals(s)) //$NON-NLS-1$
+                                       return TokenPRIVATE;
+                               if ("typedef".equals(s)) //$NON-NLS-1$
+                                       return TokenTYPEDEF;
+                               if ("virtual".equals(s)) //$NON-NLS-1$
+                                       return TokenVIRTUAL;
+                               break;
+                       case 8:
+                               if ("operator".equals(s)) //$NON-NLS-1$
+                                       return TokenOPERATOR;
+                               if ("template".equals(s)) //$NON-NLS-1$
+                                       return TokenTEMPLATE;
+                               if ("typename".equals(s)) //$NON-NLS-1$
+                                       return TokenTYPENAME;
+                               break;
+                       case 9:
+                               if ("namespace".equals(s)) //$NON-NLS-1$
+                                       return TokenNAMESPACE;
+                               if ("protected".equals(s)) //$NON-NLS-1$
+                                       return TokenPROTECTED;
+               }
+               return TokenIDENT;
+       }
+
+       /**
+        * Returns the position of the closing peer character (forward search). Any scopes introduced
+        * by opening peers are skipped. All peers accounted for must reside in the default partition.
+        *
+        * <p>Note that <code>start</code> must not point to the opening peer, but to the first
+        * character being searched.</p>
+        *
+        * @param start the start position
+        * @param openingPeer the opening peer character (e.g. '{')
+        * @param closingPeer the closing peer character (e.g. '}')
+        * @return the matching peer character position, or <code>NOT_FOUND</code>
+        */
+       public int findClosingPeer(int start, final char openingPeer, final char closingPeer) {
+               return findClosingPeer(start, UNBOUND, openingPeer, closingPeer);
+       }
+
+       /**
+        * Returns the position of the closing peer character (forward search). Any scopes introduced by opening peers
+        * are skipped. All peers accounted for must reside in the default partition.
+        *
+        * <p>Note that <code>start</code> must not point to the opening peer, but to the first
+        * character being searched.</p>
+        *
+        * @param start the start position
+        * @param bound the bound
+        * @param openingPeer the opening peer character (e.g. '{')
+        * @param closingPeer the closing peer character (e.g. '}')
+        * @return the matching peer character position, or <code>NOT_FOUND</code>
+        */
+       public int findClosingPeer(int start, int bound, final char openingPeer, final char closingPeer) {
+               Assert.isLegal(start >= 0);
+
+               try {
+                       int depth= 1;
+                       start -= 1;
+                       while (true) {
+                               start= scanForward(start + 1, bound, new CharacterMatch(new char[] {openingPeer, closingPeer}));
+                               if (start == NOT_FOUND)
+                                       return NOT_FOUND;
+
+                               if (fDocument.getChar(start) == openingPeer)
+                                       depth++;
+                               else
+                                       depth--;
+
+                               if (depth == 0)
+                                       return start;
+                       }
+
+               } catch (BadLocationException e) {
+                       return NOT_FOUND;
+               }
+       }
+
+       /**
+        * Returns the position of the opening peer character (backward search). Any scopes introduced by closing peers
+        * are skipped. All peers accounted for must reside in the default partition.
+        *
+        * <p>Note that <code>start</code> must not point to the closing peer, but to the first
+        * character being searched.</p>
+        *
+        * @param start the start position
+        * @param openingPeer the opening peer character (e.g. '{')
+        * @param closingPeer the closing peer character (e.g. '}')
+        * @return the matching peer character position, or <code>NOT_FOUND</code>
+        */
+       public int findOpeningPeer(int start, char openingPeer, char closingPeer) {
+               return findOpeningPeer(start, CHeuristicScanner.UNBOUND, openingPeer, closingPeer);
+       }
+
+       /**
+        * Returns the position of the opening peer character (backward search). Any scopes introduced by closing peers
+        * are skipped. All peers accounted for must reside in the default partition.
+        *
+        * <p>Note that <code>start</code> must not point to the closing peer, but to the first
+        * character being searched.</p>
+        *
+        * @param start the start position
+        * @param bound the bound
+        * @param openingPeer the opening peer character (e.g. '{')
+        * @param closingPeer the closing peer character (e.g. '}')
+        * @return the matching peer character position, or <code>NOT_FOUND</code>
+        */
+       public int findOpeningPeer(int start, int bound, char openingPeer, char closingPeer) {
+               Assert.isLegal(start < fDocument.getLength());
+
+               try {
+                       final CharacterMatch match= new CharacterMatch(new char[] {openingPeer, closingPeer});
+                       int depth= 1;
+                       start += 1;
+                       while (true) {
+                               start= scanBackward(start - 1, bound, match);
+                               if (start == NOT_FOUND)
+                                       return NOT_FOUND;
+
+                               if (fDocument.getChar(start) == closingPeer)
+                                       depth++;
+                               else
+                                       depth--;
+
+                               if (depth == 0)
+                                       return start;
+                       }
+
+               } catch (BadLocationException e) {
+                       return NOT_FOUND;
+               }
+       }
+
+       /**
+        * Computes the surrounding block around <code>offset</code>. The search is started at the
+        * beginning of <code>offset</code>, i.e. an opening brace at <code>offset</code> will not be
+        * part of the surrounding block, but a closing brace will.
+        *
+        * @param offset the offset for which the surrounding block is computed
+        * @return a region describing the surrounding block, or <code>null</code> if none can be found
+        */
+       public IRegion findSurroundingBlock(int offset) {
+               if (offset < 1 || offset >= fDocument.getLength())
+                       return null;
+
+               int begin= findOpeningPeer(offset - 1, CHeuristicScanner.UNBOUND, LBRACE, RBRACE);
+               int end= findClosingPeer(offset, UNBOUND, LBRACE, RBRACE);
+               if (begin == NOT_FOUND || end == NOT_FOUND)
+                       return null;
+               return new Region(begin, end + 1 - begin);
+       }
+
+       /**
+        * Finds the smallest position in <code>fDocument</code> such that the position is &gt;= <code>position</code>
+        * and &lt; <code>bound</code> and <code>Character.isWhitespace(fDocument.getChar(pos))</code> evaluates to <code>false</code>
+        * and the position is in the default partition.
+        *
+        * @param position the first character position in <code>fDocument</code> to be considered
+        * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &gt; <code>position</code>, or <code>UNBOUND</code>
+        * @return the smallest position of a non-whitespace character in [<code>position</code>, <code>bound</code>) that resides in a C partition, or <code>NOT_FOUND</code> if none can be found
+        */
+       public int findNonWhitespaceForward(int position, int bound) {
+               return scanForward(position, bound, fNonWSDefaultPart);
+       }
+
+       /**
+        * Finds the smallest position in <code>fDocument</code> such that the position is &gt;= <code>position</code>
+        * and &lt; <code>bound</code> and <code>Character.isWhitespace(fDocument.getChar(pos))</code> evaluates to <code>false</code>.
+        *
+        * @param position the first character position in <code>fDocument</code> to be considered
+        * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &gt; <code>position</code>, or <code>UNBOUND</code>
+        * @return the smallest position of a non-whitespace character in [<code>position</code>, <code>bound</code>), or <code>NOT_FOUND</code> if none can be found
+        */
+       public int findNonWhitespaceForwardInAnyPartition(int position, int bound) {
+               return scanForward(position, bound, fNonWS);
+       }
+
+       /**
+        * Finds the highest position in <code>fDocument</code> such that the position is &lt;= <code>position</code>
+        * and &gt; <code>bound</code> and <code>Character.isWhitespace(fDocument.getChar(pos))</code> evaluates to <code>false</code>
+        * and the position is in the default partition.
+        *
+        * @param position the first character position in <code>fDocument</code> to be considered
+        * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &lt; <code>position</code>, or <code>UNBOUND</code>
+        * @return the highest position of a non-whitespace character in (<code>bound</code>, <code>position</code>] that resides in a C partition, or <code>NOT_FOUND</code> if none can be found
+        */
+       public int findNonWhitespaceBackward(int position, int bound) {
+               return scanBackward(position, bound, fNonWSDefaultPart);
+       }
+
+       /**
+        * Finds the lowest position <code>p</code> in <code>fDocument</code> such that <code>start</code> &lt;= p &lt;
+        * <code>bound</code> and <code>condition.stop(fDocument.getChar(p), p)</code> evaluates to <code>true</code>.
+        *
+        * @param start the first character position in <code>fDocument</code> to be considered
+        * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &gt; <code>start</code>, or <code>UNBOUND</code>
+        * @param condition the <code>StopCondition</code> to check
+        * @return the lowest position in [<code>start</code>, <code>bound</code>) for which <code>condition</code> holds, or <code>NOT_FOUND</code> if none can be found
+        */
+       public int scanForward(int start, int bound, StopCondition condition) {
+               Assert.isLegal(start >= 0);
+
+               if (bound == UNBOUND)
+                       bound= fDocument.getLength();
+
+               Assert.isLegal(bound <= fDocument.getLength());
+
+               try {
+                       fPos= start;
+                       while (fPos < bound) {
+
+                               fChar= fDocument.getChar(fPos);
+                               if (condition.stop(fChar, fPos, true))
+                                       return fPos;
+
+                               fPos= condition.nextPosition(fPos, true);
+                       }
+               } catch (BadLocationException e) {
+               }
+               return NOT_FOUND;
+       }
+
+
+       /**
+        * Finds the lowest position in <code>fDocument</code> such that the position is &gt;= <code>position</code>
+        * and &lt; <code>bound</code> and <code>fDocument.getChar(position) == ch</code> evaluates to <code>true</code>
+        * and the position is in the default partition.
+        *
+        * @param position the first character position in <code>fDocument</code> to be considered
+        * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &gt; <code>position</code>, or <code>UNBOUND</code>
+        * @param ch the <code>char</code> to search for
+        * @return the lowest position of <code>ch</code> in (<code>bound</code>, <code>position</code>] that resides in a C partition, or <code>NOT_FOUND</code> if none can be found
+        */
+       public int scanForward(int position, int bound, char ch) {
+               return scanForward(position, bound, new CharacterMatch(ch));
+       }
+
+       /**
+        * Finds the lowest position in <code>fDocument</code> such that the position is &gt;= <code>position</code>
+        * and &lt; <code>bound</code> and <code>fDocument.getChar(position) == ch</code> evaluates to <code>true</code> for at least one
+        * ch in <code>chars</code> and the position is in the default partition.
+        *
+        * @param position the first character position in <code>fDocument</code> to be considered
+        * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &gt; <code>position</code>, or <code>UNBOUND</code>
+        * @param chars an array of <code>char</code> to search for
+        * @return the lowest position of a non-whitespace character in [<code>position</code>, <code>bound</code>) that resides in a C partition, or <code>NOT_FOUND</code> if none can be found
+        */
+       public int scanForward(int position, int bound, char[] chars) {
+               return scanForward(position, bound, new CharacterMatch(chars));
+       }
+
+       /**
+        * Finds the highest position <code>p</code> in <code>fDocument</code> such that <code>bound</code> &lt; <code>p</code> &lt;= <code>start</code>
+        * and <code>condition.stop(fDocument.getChar(p), p)</code> evaluates to <code>true</code>.
+        *
+        * @param start the first character position in <code>fDocument</code> to be considered
+        * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &lt; <code>start</code>, or <code>UNBOUND</code>
+        * @param condition the <code>StopCondition</code> to check
+        * @return the highest position in (<code>bound</code>, <code>start</code> for which <code>condition</code> holds, or <code>NOT_FOUND</code> if none can be found
+        */
+       public int scanBackward(int start, int bound, StopCondition condition) {
+               if (bound == UNBOUND)
+                       bound= -1;
+
+               Assert.isLegal(bound >= -1);
+               Assert.isLegal(start < fDocument.getLength() );
+
+               try {
+                       fPos= start;
+                       while (fPos > bound) {
+
+                               fChar= fDocument.getChar(fPos);
+                               if (condition.stop(fChar, fPos, false))
+                                       return fPos;
+
+                               fPos= condition.nextPosition(fPos, false);
+                       }
+               } catch (BadLocationException e) {
+               }
+               return NOT_FOUND;
+       }
+
+       /**
+        * Finds the highest position in <code>fDocument</code> such that the position is &lt;= <code>position</code>
+        * and &gt; <code>bound</code> and <code>fDocument.getChar(position) == ch</code> evaluates to <code>true</code>
+        * and the position is in the default partition.
+        *
+        * @param position the first character position in <code>fDocument</code> to be considered
+        * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &lt; <code>position</code>, or <code>UNBOUND</code>
+        * @param ch the <code>char</code> to search for
+        * @return the highest position of one element in <code>chars</code> in (<code>bound</code>, <code>position</code>] that resides in a C partition, or <code>NOT_FOUND</code> if none can be found
+        */
+       public int scanBackward(int position, int bound, char ch) {
+               return scanBackward(position, bound, new CharacterMatch(ch));
+       }
+
+       /**
+        * Finds the highest position in <code>fDocument</code> such that the position is &lt;= <code>position</code>
+        * and &gt; <code>bound</code> and <code>fDocument.getChar(position) == ch</code> evaluates to <code>true</code> for at least one
+        * ch in <code>chars</code> and the position is in the default partition.
+        *
+        * @param position the first character position in <code>fDocument</code> to be considered
+        * @param bound the first position in <code>fDocument</code> to not consider any more, with <code>bound</code> &lt; <code>position</code>, or <code>UNBOUND</code>
+        * @param chars an array of <code>char</code> to search for
+        * @return the highest position of one element in <code>chars</code> in (<code>bound</code>, <code>position</code>] that resides in a C partition, or <code>NOT_FOUND</code> if none can be found
+        */
+       public int scanBackward(int position, int bound, char[] chars) {
+               return scanBackward(position, bound, new CharacterMatch(chars));
+       }
+
+       /**
+        * Checks whether <code>position</code> resides in a default (C) partition of <code>fDocument</code>.
+        *
+        * @param position the position to be checked
+        * @return <code>true</code> if <code>position</code> is in the default partition of <code>fDocument</code>, <code>false</code> otherwise
+        */
+       public boolean isDefaultPartition(int position) {
+               return fPartition.equals(getPartition(position).getType());
+       }
+
+       /**
+        * Returns the partition at <code>position</code>.
+        *
+        * @param position the position to get the partition for
+        * @return the partition at <code>position</code> or a dummy zero-length
+        *         partition if accessing the document fails
+        */
+       private ITypedRegion getPartition(int position) {
+               if (!contains(fCachedPartition, position)) {
+                       Assert.isTrue(position >= 0);
+                       Assert.isTrue(position <= fDocument.getLength());
+                       
+                       try {
+                               fCachedPartition= TextUtilities.getPartition(fDocument, fPartitioning, position, false);
+                       } catch (BadLocationException e) {
+                               fCachedPartition= new TypedRegion(position, 0, "__no_partition_at_all"); //$NON-NLS-1$
+                       }
+               }
+
+               return fCachedPartition;
+       }
+
+       /**
+        * Returns <code>true</code> if <code>region</code> contains <code>position</code>.
+        * 
+        * @param region a region
+        * @param position an offset
+        * @return <code>true</code> if <code>region</code> contains <code>position</code>
+        */
+       private boolean contains(IRegion region, int position) {
+               int offset= region.getOffset();
+               return offset <= position && position < offset + region.getLength();
+       }
+
+       /**
+        * Checks if the line seems to be an open condition not followed by a block (i.e. an if, while,
+        * or for statement with just one following statement, see example below).
+        *
+        * <pre>
+        * if (condition)
+        *     doStuff();
+        * </pre>
+        *
+        * <p>Algorithm: if the last non-WS, non-Comment code on the line is an if (condition), while (condition),
+        * for( expression), do, else, and there is no statement after that </p>
+        *
+        * @param position the insert position of the new character
+        * @param bound the lowest position to consider
+        * @return <code>true</code> if the code is a conditional statement or loop without a block, <code>false</code> otherwise
+        */
+       public boolean isBracelessBlockStart(int position, int bound) {
+               if (position < 1)
+                       return false;
+
+               switch (previousToken(position, bound)) {
+                       case TokenDO:
+                       case TokenELSE:
+                               return true;
+                       case TokenRPAREN:
+                               position= findOpeningPeer(fPos, CHeuristicScanner.UNBOUND, LPAREN, RPAREN);
+                               if (position > 0) {
+                                       switch (previousToken(position - 1, bound)) {
+                                               case TokenIF:
+                                               case TokenFOR:
+                                               case TokenWHILE:
+                                                       return true;
+                                       }
+                               }
+               }
+
+               return false;
+       }
+       
+       /**
+        * Returns <code>true</code> if the document, when scanned backwards from <code>start</code>
+        * appears to contain a class instance creation, i.e. a possibly qualified name preceded by a
+        * <code>new</code> keyword. The <code>start</code> must be at the end of the type name, and
+        * before any generic signature or constructor parameter list. The heuristic will return
+        * <code>true</code> if <code>start</code> is at the following positions (|):
+        * 
+        * <pre>
+        *  new std::vector&lt;std::string&gt;|(10)
+        *  new str_vector |(10)
+        *  new / * comment * / str_vector |(10)
+        * </pre>
+        * 
+        * but not the following:
+        * 
+        * <pre>
+        *  new std::vector&lt;std::string&gt;(10)|
+        *  new std::vector&lt;std::string&gt;|(10)
+        *  new vector (10)|
+        *  vector |(10)
+        * </pre>
+        * 
+        * @param start the position where the type name of the class instance creation supposedly ends
+        * @param bound the first position in <code>fDocument</code> to not consider any more, with
+        *        <code>bound</code> &lt; <code>start</code>, or <code>UNBOUND</code>
+        * @return <code>true</code> if the current position looks like after the type name of a class
+        *         instance creation
+        */
+       public boolean looksLikeClassInstanceCreationBackward(int start, int bound) {
+               int token= previousToken(start - 1, bound);
+               if (token == Symbols.TokenIDENT) { // type name
+                       token= previousToken(getPosition(), bound);
+                       while (token == Symbols.TokenDOUBLECOLON) { // qualification
+                               token= previousToken(getPosition(), bound);
+                               if (token != Symbols.TokenIDENT) // qualification name
+                                       return false;
+                               token= previousToken(getPosition(), bound);
+                       }
+                       return token == Symbols.TokenNEW;
+               }
+               return false;
+       }
+
+       /**
+        * Returns <code>true</code> if the document, when scanned backwards from <code>start</code>
+        * appears to contain a field reference, i.e. a (optional) name preceded by a <code>.</code> 
+        * or <code>-&gt;</code> or <code>::</code>.
+        * 
+        * @param start the position after the field reference operator.
+        * @param bound the first position in <code>fDocument</code> to not consider any more, with
+        *        <code>bound</code> &lt; <code>start</code>, or <code>UNBOUND</code>
+        * @return <code>true</code> if the current position looks like a field reference
+        */
+       public boolean looksLikeFieldReferenceBackward(int start, int bound) {
+               int token= previousToken(start - 1, bound);
+               if (token == Symbols.TokenIDENT) { // field name
+                       token= previousToken(getPosition(), bound);
+               }
+               if (token == Symbols.TokenDOT) {
+                       return true;
+               }
+               if (token == Symbols.TokenARROW) {
+                       return true;
+               } else if (token == Symbols.TokenDOUBLECOLON) {
+                       return true;
+               }
+               return false;
+       }
+       
+       /**
+        * Returns <code>true</code> if the document, when scanned backwards from <code>start</code>
+        * appears to be a composite type (class, struct, union) or enum definition. Examples:
+        * 
+        * <pre>
+        * class A {
+        * struct A {
+        * class A : B {
+        * class A : virtual public B, protected C&lt;T&gt; {
+        * enum E {
+        * </pre>
+        * 
+        * @param start the position of the opening brace.
+        * @param bound the first position in <code>fDocument</code> to not consider any more, with
+        *        <code>bound</code> &lt; <code>start</code>, or <code>UNBOUND</code>
+        * @return <code>true</code> if the current position looks like a composite type definition
+        */
+       public boolean looksLikeCompositeTypeDefinitionBackward(int start, int bound) {
+               int token= previousToken(start - 1, bound);
+               switch (token) {
+               case Symbols.TokenSTRUCT:
+               case Symbols.TokenUNION:
+               case Symbols.TokenENUM:
+                       return true; // anonymous
+               case Symbols.TokenIDENT:
+                       token= previousToken(getPosition(), bound);
+                       switch (token) {
+                       case Symbols.TokenCLASS:
+                       case Symbols.TokenSTRUCT:
+                       case Symbols.TokenUNION:
+                       case Symbols.TokenENUM:
+                               return true; // no base-clause
+                       default:
+                               // backtrack
+                               token= previousToken(start - 1, bound);
+                       }
+                       break;
+               default:
+                       // backtrack
+                       token= previousToken(start - 1, bound);
+                       break;
+               }
+               // match base-clause
+               if (token == Symbols.TokenGREATERTHAN) {
+                       findOpeningPeer(getPosition(), bound, '<', '>');
+                       token= previousToken(getPosition(), bound);
+                       if (token != Symbols.TokenLESSTHAN) {
+                               return false;
+                       }
+                       token= previousToken(getPosition(), bound);
+               }
+               outerWhile: while (token == Symbols.TokenIDENT) {// type name or base type
+                       token= previousToken(getPosition(), bound);
+                       // match nested-name-specifier
+                       while (token == Symbols.TokenCOLON) { // colon of qualification
+                               token= previousToken(getPosition(), bound);
+                               if (token != Symbols.TokenCOLON) { // second colon of qualification
+                                       break outerWhile;
+                               }
+                               token= previousToken(getPosition(), bound);
+                               if (token != Symbols.TokenIDENT) // qualification name?
+                                       break;
+                               token= previousToken(getPosition(), bound);
+                       }
+                       switch (token) {
+                       case Symbols.TokenVIRTUAL:
+                               token= previousToken(getPosition(), bound);
+                               //$FALL-THROUGH$
+                       case Symbols.TokenPUBLIC:
+                       case Symbols.TokenPROTECTED:
+                       case Symbols.TokenPRIVATE:
+                               token= previousToken(getPosition(), bound);
+                               if (token == Symbols.TokenVIRTUAL) {
+                                       token= previousToken(getPosition(), bound);
+                               }
+                               if (token == Symbols.TokenCOMMA) {
+                                       token= previousToken(getPosition(), bound);
+                                       if (token == Symbols.TokenGREATERTHAN) {
+                                               findOpeningPeer(getPosition(), bound, '<', '>');
+                                               token= previousToken(getPosition(), bound);
+                                               if (token != Symbols.TokenLESSTHAN) {
+                                                       return false;
+                                               }
+                                               token= previousToken(getPosition(), bound);
+                                       }
+                                       continue; // another base type
+                               }
+                               if (token != Symbols.TokenCOLON) // colon after class def identifier
+                                       return false;
+                               //$FALL-THROUGH$
+                       case Symbols.TokenCOLON:
+                               token= previousToken(getPosition(), bound);
+                               break outerWhile;
+                       case Symbols.TokenCOMMA:
+                               token= previousToken(getPosition(), bound);
+                               if (token == Symbols.TokenGREATERTHAN) {
+                                       findOpeningPeer(getPosition(), bound, '<', '>');
+                                       token= previousToken(getPosition(), bound);
+                                       if (token != Symbols.TokenLESSTHAN) {
+                                               return false;
+                                       }
+                                       token= previousToken(getPosition(), bound);
+                               }
+                               continue; // another base type
+                       case Symbols.TokenIDENT:
+                               break outerWhile;
+                       default:
+                               return false;
+                       }
+               }
+               if (token != Symbols.TokenIDENT) {
+                       return false;
+               }
+               token= previousToken(getPosition(), bound);
+               switch (token) {
+               case Symbols.TokenCLASS:
+               case Symbols.TokenSTRUCT:
+               case Symbols.TokenUNION:
+               case Symbols.TokenENUM:  // enum is actually not valid here
+                       return true;
+               default:
+                       return false;
+               }
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java
new file mode 100644 (file)
index 0000000..d32891c
--- /dev/null
@@ -0,0 +1,2270 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IPreferencesService;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
+import org.eclipse.cdt.core.model.ICProject;
+
+import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
+
+/**
+ * Uses the {@link org.eclipse.cdt.internal.ui.text.CHeuristicScanner} to
+ * get the indentation level for a certain position in a document.
+ *
+ * <p>
+ * An instance holds some internal position in the document and is therefore
+ * not thread-safe.
+ * </p>
+ */
+public final class CIndenter {
+       
+       /**
+        * The CDT Core preferences.
+        */
+       private final class CorePrefs {
+               final boolean prefUseTabs;
+               final int prefTabSize;
+               final int prefIndentationSize;
+               final boolean prefArrayDimensionsDeepIndent;
+               final int prefArrayIndent;
+               final boolean prefArrayDeepIndent;
+               final boolean prefTernaryDeepAlign;
+               final int prefTernaryIndent;
+               final int prefCaseIndent;
+               final int prefCaseBlockIndent;
+               final int prefAssignmentIndent;
+               final int prefSimpleIndent;
+               final int prefBracketIndent;
+               final boolean prefMethodDeclDeepIndent;
+               final boolean prefMethodDeclFirstParameterDeepIndent;
+               final int prefMethodDeclIndent;
+               final boolean prefMethodCallDeepIndent;
+               final boolean prefMethodCallFirstParameterDeepIndent;
+               final int prefMethodCallIndent;
+               final boolean prefParenthesisDeepIndent;
+               final int prefParenthesisIndent;
+               final int prefBlockIndent;
+               final int prefMethodBodyIndent;
+               final int prefTypeIndent;
+               final int prefAccessSpecifierIndent;
+               final int prefAccessSpecifierExtraSpaces;
+               final int prefNamespaceBodyIndent;
+               final boolean prefIndentBracesForBlocks;
+               final boolean prefIndentBracesForArrays;
+               final boolean prefIndentBracesForMethods;
+               final boolean prefIndentBracesForTypes;
+               final int prefContinuationIndent;
+               final boolean prefHasTemplates;
+               final String prefTabChar;
+               
+               private final IPreferencesService preferenceService;
+               private final IScopeContext[] preferenceContexts;
+               private final ICProject fProject;
+
+               /**
+                * Returns the possibly project-specific core preference defined under <code>key</code>.
+                *
+                * @param key the key of the preference
+                * @return the value of the preference
+                */
+               private String getCoreFormatterOption(String key) {
+                       return getCoreFormatterOption(key, null);
+               }
+
+               private String getCoreFormatterOption(String key, String defaultValue) {
+                       return preferenceService.getString(CCorePlugin.PLUGIN_ID, key, defaultValue, preferenceContexts);
+               }
+
+               private int getCoreFormatterOption(String key, int defaultValue) {
+                       return preferenceService.getInt(CCorePlugin.PLUGIN_ID, key, defaultValue, preferenceContexts);
+               }
+
+               CorePrefs(ICProject project) {
+                       preferenceService = Platform.getPreferencesService();
+                       preferenceContexts = project != null ?
+                                       new IScopeContext[] { new ProjectScope(project.getProject()),
+                                                                                 InstanceScope.INSTANCE, DefaultScope.INSTANCE } :
+                                       new IScopeContext[] { InstanceScope.INSTANCE, DefaultScope.INSTANCE };
+                       fProject= project;
+                       prefUseTabs= prefUseTabs();
+                       prefTabSize= prefTabSize();
+                       prefIndentationSize= prefIndentationSize();
+                       prefArrayDimensionsDeepIndent= prefArrayDimensionsDeepIndent();
+                       prefContinuationIndent= prefContinuationIndent();
+                       prefBlockIndent= prefBlockIndent();
+                       prefArrayIndent= prefArrayIndent();
+                       prefArrayDeepIndent= prefArrayDeepIndent();
+                       prefTernaryDeepAlign= false;
+                       prefTernaryIndent= prefContinuationIndent();
+                       prefCaseIndent= prefCaseIndent();
+                       prefCaseBlockIndent= prefCaseBlockIndent();
+                       prefAssignmentIndent= prefAssignmentIndent();
+                       prefIndentBracesForBlocks= prefIndentBracesForBlocks();
+                       prefSimpleIndent= prefSimpleIndent();
+                       prefBracketIndent= prefBracketIndent();
+                       prefMethodDeclDeepIndent= prefMethodDeclDeepIndent();
+                       prefMethodDeclFirstParameterDeepIndent= prefMethodDeclFirstParameterDeepIndent();
+                       prefMethodDeclIndent= prefMethodDeclIndent();
+                       prefMethodCallDeepIndent= prefMethodCallDeepIndent();
+                       prefMethodCallFirstParameterDeepIndent= prefMethodCallFirstParameterDeepIndent();
+                       prefMethodCallIndent= prefMethodCallIndent();
+                       prefParenthesisDeepIndent= prefParenthesisDeepIndent();
+                       prefParenthesisIndent= prefParenthesisIndent();
+                       prefMethodBodyIndent= prefMethodBodyIndent();
+                       prefTypeIndent= prefTypeIndent();
+                       prefAccessSpecifierIndent= prefAccessSpecifierIndent();
+                       prefAccessSpecifierExtraSpaces= prefAccessSpecifierExtraSpaces();
+                       prefNamespaceBodyIndent= prefNamespaceBodyIndent();
+                       prefIndentBracesForArrays= prefIndentBracesForArrays();
+                       prefIndentBracesForMethods= prefIndentBracesForMethods();
+                       prefIndentBracesForTypes= prefIndentBracesForTypes();
+                       prefHasTemplates= hasTemplates();
+                       prefTabChar= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
+               }
+               
+               private boolean prefUseTabs() {
+                       return !CCorePlugin.SPACE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR));
+               }
+
+               private int prefTabSize() {
+                       return CodeFormatterUtil.getTabWidth(fProject);
+               }
+
+               private int prefIndentationSize() {
+                       return CodeFormatterUtil.getIndentWidth(fProject);
+               }
+
+               private boolean prefArrayDimensionsDeepIndent() {
+                       return true; // sensible default, no formatter setting
+               }
+
+               private int prefArrayIndent() {
+                       String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_INITIALIZER_LIST);
+                       try {
+                               if (DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_BY_ONE)
+                                       return 1;
+                       } catch (IllegalArgumentException e) {
+                               // ignore and return default
+                       }
+
+                       return prefContinuationIndent(); // default
+               }
+
+               private boolean prefArrayDeepIndent() {
+                       String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_INITIALIZER_LIST);
+                       try {
+                               return DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_ON_COLUMN;
+                       } catch (IllegalArgumentException e) {
+                               // ignore and return default
+                       }
+
+                       return true;
+               }
+
+               private int prefCaseIndent() {
+                       if (DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH)))
+                               return 1;
+                       else
+                               return 0;
+               }
+
+               private int prefCaseBlockIndent() {
+                       if (DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES)))
+                               return 1;
+                       else
+                               return 0;
+               }
+
+               private int prefAssignmentIndent() {
+                       return prefContinuationIndent();
+               }
+
+               private int prefSimpleIndent() {
+                       if (prefIndentBracesForBlocks() && prefBlockIndent() == 0)
+                               return 1;
+                       else
+                               return prefBlockIndent();
+               }
+
+               private int prefBracketIndent() {
+                       return prefBlockIndent();
+               }
+
+               private boolean prefMethodDeclDeepIndent() {
+                       String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION);
+                       try {
+                               int indentStyle = DefaultCodeFormatterConstants.getIndentStyle(option);
+                               return indentStyle == DefaultCodeFormatterConstants.INDENT_ON_COLUMN;
+                       } catch (IllegalArgumentException e) {
+                               // ignore and return default
+                       }
+
+                       return false;
+               }
+
+               private boolean prefMethodDeclFirstParameterDeepIndent() {
+                       String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION);
+                       try {
+                               int indentStyle = DefaultCodeFormatterConstants.getIndentStyle(option);
+                               int wrappingStyle = DefaultCodeFormatterConstants.getWrappingStyle(option);
+                               return indentStyle == DefaultCodeFormatterConstants.INDENT_ON_COLUMN &&
+                                       (wrappingStyle == DefaultCodeFormatterConstants.WRAP_COMPACT_FIRST_BREAK ||
+                                       wrappingStyle == DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE);
+                       } catch (IllegalArgumentException e) {
+                               // ignore and return default
+                       }
+
+                       return false;
+               }
+
+               private int prefMethodDeclIndent() {
+                       String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION);
+                       try {
+                               if (DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_BY_ONE)
+                                       return 1;
+                               else
+                                       return prefContinuationIndent();
+                       } catch (IllegalArgumentException e) {
+                               // ignore and return default
+                       }
+                       return 1;
+               }
+
+               private boolean prefMethodCallDeepIndent() {
+                       String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION);
+                       try {
+                               int indentStyle = DefaultCodeFormatterConstants.getIndentStyle(option);
+                               return indentStyle == DefaultCodeFormatterConstants.INDENT_ON_COLUMN;
+                       } catch (IllegalArgumentException e) {
+                               // ignore and return default
+                       }
+                       return false; // sensible default
+               }
+
+               private boolean prefMethodCallFirstParameterDeepIndent() {
+                       String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION);
+                       try {
+                               int indentStyle = DefaultCodeFormatterConstants.getIndentStyle(option);
+                               int wrappingStyle = DefaultCodeFormatterConstants.getWrappingStyle(option);
+                               return indentStyle == DefaultCodeFormatterConstants.INDENT_ON_COLUMN &&
+                                       (wrappingStyle == DefaultCodeFormatterConstants.WRAP_COMPACT_FIRST_BREAK ||
+                                       wrappingStyle == DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE);
+                       } catch (IllegalArgumentException e) {
+                               // ignore and return default
+                       }
+                       return false; // sensible default
+               }
+
+               private int prefMethodCallIndent() {
+                       String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION);
+                       try {
+                               if (DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_BY_ONE)
+                                       return 1;
+                               else
+                                       return prefContinuationIndent();
+                       } catch (IllegalArgumentException e) {
+                               // ignore and return default
+                       }
+
+                       return 1; // sensible default
+               }
+
+               private boolean prefParenthesisDeepIndent() {
+                       // don't do parenthesis deep indentation
+//                     String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION);
+//                     try {
+//                             return DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_ON_COLUMN;
+//                     } catch (IllegalArgumentException e) {
+//                             // ignore and return default
+//                     }
+
+                       return false;
+               }
+
+               private int prefParenthesisIndent() {
+                       return prefContinuationIndent();
+               }
+
+               private int prefBlockIndent() {
+                       String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK);
+                       if (DefaultCodeFormatterConstants.FALSE.equals(option))
+                               return 0;
+
+                       return 1; // sensible default
+               }
+
+               private int prefMethodBodyIndent() {
+                       if (DefaultCodeFormatterConstants.FALSE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY)))
+                               return 0;
+
+                       return 1; // sensible default
+               }
+
+               private int prefTypeIndent() {
+                       String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ACCESS_SPECIFIER);
+                       if (DefaultCodeFormatterConstants.FALSE.equals(option))
+                               return 0;
+
+                       return 1; // sensible default
+               }
+               
+               private int prefAccessSpecifierIndent() {
+                       if (DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_ACCESS_SPECIFIER_COMPARE_TO_TYPE_HEADER)))
+                               return 1;
+                       else
+                               return 0;
+               }
+
+               private int prefAccessSpecifierExtraSpaces() {
+                       return getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_ACCESS_SPECIFIER_EXTRA_SPACES, 0);
+               }
+
+               private int prefNamespaceBodyIndent() {
+                       if (DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_NAMESPACE_HEADER)))
+                               return prefBlockIndent();
+                       else
+                               return 0;
+               }
+
+               private boolean prefIndentBracesForBlocks() {
+                       return DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK));
+               }
+
+               private boolean prefIndentBracesForArrays() {
+                       return DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_INITIALIZER_LIST));
+               }
+
+               private boolean prefIndentBracesForMethods() {
+                       return DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION));
+               }
+
+               private boolean prefIndentBracesForTypes() {
+                       return DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION));
+               }
+
+               private int prefContinuationIndent() {
+                       try {
+                               return Integer.parseInt(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION));
+                       } catch (NumberFormatException e) {
+                               // ignore and return default
+                       }
+
+                       return 2; // sensible default
+               }
+               
+               private boolean hasTemplates() {
+                       return true;
+               }
+       }
+
+       /** The document being scanned. */
+       private final IDocument fDocument;
+       /** The indentation accumulated by <code>findReferencePosition</code>. */
+       private int fIndent;
+       /** Extra spaces to add on top of fIndent */
+       private int fExtraSpaces;
+       /**
+        * The absolute (character-counted) indentation offset for special cases
+        * (method defs, array initializers)
+        */
+       private int fAlign;
+       /** The stateful scan position for the indentation methods. */
+       private int fPosition;
+       /** The previous position. */
+       private int fPreviousPos;
+       /** The most recent token. */
+       private int fToken;
+       /** The line of <code>fPosition</code>. */
+       private int fLine;
+       /**
+        * The scanner we will use to scan the document. It has to be installed
+        * on the same document as the one we get.
+        */
+       private final CHeuristicScanner fScanner;
+       /**
+        * The CDT Core preferences.
+        */
+       private final CorePrefs fPrefs;
+
+       /**
+        * Creates a new instance.
+        *
+        * @param document the document to scan
+        * @param scanner the {@link CHeuristicScanner} to be used for scanning
+        * the document. It must be installed on the same <code>IDocument</code>.
+        */
+       public CIndenter(IDocument document, CHeuristicScanner scanner) {
+               this(document, scanner, null);
+       }
+
+       /**
+        * Creates a new instance.
+        *
+        * @param document the document to scan
+        * @param scanner the {@link CHeuristicScanner} to be used for scanning
+        *        the document. It must be installed on the same
+        *        <code>IDocument</code>.
+        * @param project the C/C++ project to get the formatter preferences from, or
+        *        <code>null</code> to use the workspace settings
+        */
+       public CIndenter(IDocument document, CHeuristicScanner scanner, ICProject project) {
+               Assert.isNotNull(document);
+               Assert.isNotNull(scanner);
+               fDocument= document;
+               fScanner= scanner;
+               fPrefs= new CorePrefs(project);
+       }
+
+       /**
+        * Computes the indentation at the reference point of <code>position</code>.
+        *
+        * @param offset the offset in the document
+        * @return a String which reflects the indentation at the line in which the
+        *         reference position to <code>offset</code> resides, or <code>null</code>
+        *         if it cannot be determined
+        */
+       public StringBuilder getReferenceIndentation(int offset) {
+               return getReferenceIndentation(offset, false);
+       }
+
+       /**
+        * Computes the indentation at the reference point of <code>position</code>.
+        *
+        * @param offset the offset in the document
+        * @param assumeOpeningBrace <code>true</code> if an opening brace should be assumed
+        * @return a String which reflects the indentation at the line in which the
+        *         reference position to <code>offset</code> resides, or <code>null</code>
+        *         if it cannot be determined
+        */
+       private StringBuilder getReferenceIndentation(int offset, boolean assumeOpeningBrace) {
+               int unit;
+               if (assumeOpeningBrace)
+                       unit= findReferencePosition(offset, Symbols.TokenLBRACE);
+               else
+                       unit= findReferencePosition(offset, peekToken(offset));
+
+               // if we were unable to find anything, return null
+               if (unit == CHeuristicScanner.NOT_FOUND)
+                       return null;
+
+               return getLeadingWhitespace(unit);
+       }
+
+       /**
+        * Computes the indentation at <code>offset</code>.
+        *
+        * @param offset the offset in the document
+        * @return a String which reflects the correct indentation for the line in
+        *         which offset resides, or <code>null</code> if it cannot be
+        *         determined
+        */
+       public StringBuilder computeIndentation(int offset) {
+               return computeIndentation(offset, false);
+       }
+
+       /**
+        * Computes the indentation at <code>offset</code>.
+        *
+        * @param offset the offset in the document
+        * @param assumeOpeningBrace <code>true</code> if an opening brace should be assumed
+        * @return a String which reflects the correct indentation for the line in
+        *         which offset resides, or <code>null</code> if it cannot be
+        *         determined
+        */
+       public StringBuilder computeIndentation(int offset, boolean assumeOpeningBrace) {
+               StringBuilder reference= getReferenceIndentation(offset, assumeOpeningBrace);
+
+               // handle special alignment
+               if (fAlign != CHeuristicScanner.NOT_FOUND) {
+                       try {
+                               // a special case has been detected.
+                               IRegion line= fDocument.getLineInformationOfOffset(fAlign);
+                               int lineOffset= line.getOffset();
+                               return createIndent(lineOffset, fAlign, false);
+                       } catch (BadLocationException e) {
+                               return null;
+                       }
+               }
+
+               if (reference == null)
+                       return null;
+
+               // Add additional indent
+               return createReusingIndent(reference, fIndent, fExtraSpaces);
+       }
+
+       /**
+        * Computes the indentation for a continuation line at <code>offset</code>.
+        *
+        * @param offset the offset in the document
+        * @return a StringBuilder which reflects the correct indentation for
+        *         the line in  which offset resides, or <code>null</code> if it cannot be
+        *         determined.
+        * @throws BadLocationException
+        */
+       public StringBuilder computeContinuationLineIndentation(int offset) throws BadLocationException {
+               StringBuilder reference= getLeadingWhitespace(offset);
+               IRegion line= fDocument.getLineInformationOfOffset(offset);
+               String string= fDocument.get(line.getOffset(), offset - line.getOffset());
+               if (string.trim().length() == 0)
+                       return reference;
+               // Add additional indent
+               return createReusingIndent(reference, fPrefs.prefContinuationIndent, 0);
+       }
+       
+       /**
+        * Computes the length of a <code>CharacterSequence</code>, counting
+        * a tab character as the size until the next tab stop and every other
+        * character as one.
+        *
+        * @param indent the string to measure
+        * @return the visual length in characters
+        */
+       private int computeVisualLength(CharSequence indent) {
+               final int tabSize= fPrefs.prefTabSize;
+               int length= 0;
+               for (int i= 0; i < indent.length(); i++) {
+                       char ch= indent.charAt(i);
+                       switch (ch) {
+                       case '\t':
+                               if (tabSize > 0) {
+                                       int reminder= length % tabSize;
+                                       length += tabSize - reminder;
+                               }
+                               break;
+                       case ' ':
+                               length++;
+                               break;
+                       }
+               }
+               return length;
+       }
+
+       /**
+        * Strips any characters off the end of <code>reference</code> that exceed
+        * <code>indentLength</code>.
+        *
+        * @param reference the string to measure
+        * @param indentLength the maximum visual indentation length
+        * @return the stripped <code>reference</code>
+        */
+       private StringBuilder stripExceedingChars(StringBuilder reference, int indentLength) {
+               final int tabSize= fPrefs.prefTabSize;
+               int measured= 0;
+               int chars= reference.length();
+               int i= 0;
+               for (; measured < indentLength && i < chars; i++) {
+                       char ch= reference.charAt(i);
+                       switch (ch) {
+                       case '\t':
+                               if (tabSize > 0) {
+                                       int reminder= measured % tabSize;
+                                       measured += tabSize - reminder;
+                               }
+                               break;
+                       case ' ':
+                               measured++;
+                               break;
+                       }
+               }
+               int deleteFrom= measured > indentLength ? i - 1 : i;
+
+               return reference.delete(deleteFrom, chars);
+       }
+
+       /**
+        * Returns the indentation of the line at <code>offset</code> as a
+        * <code>StringBuilder</code>. If the offset is not valid, the empty string
+        * is returned.
+        *
+        * @param offset the offset in the document
+        * @return the indentation (leading whitespace) of the line in which
+        *                 <code>offset</code> is located
+        */
+       private StringBuilder getLeadingWhitespace(int offset) {
+               StringBuilder indent= new StringBuilder();
+               try {
+                       IRegion line= fDocument.getLineInformationOfOffset(offset);
+                       int lineOffset= line.getOffset();
+                       int nonWS= fScanner.findNonWhitespaceForwardInAnyPartition(lineOffset, lineOffset + line.getLength());
+                       indent.append(fDocument.get(lineOffset, nonWS - lineOffset));
+                       return indent;
+               } catch (BadLocationException e) {
+                       return indent;
+               }
+       }
+
+       /**
+        * Creates an indentation string of the length indent - start, consisting of
+        * the content in <code>fDocument</code> in the range [start, indent),
+        * with every character replaced by a space except for tabs, which are kept
+        * as such.
+        * <p>
+        * If <code>convertSpaceRunsToTabs</code> is <code>true</code>, every
+        * run of the number of spaces that make up a tab are replaced by a tab
+        * character. If it is not set, no conversion takes place, but tabs in the
+        * original range are still copied verbatim.
+        * </p>
+        *
+        * @param start the start of the document region to copy the indent from
+        * @param indent the exclusive end of the document region to copy the indent
+        *        from
+        * @param convertSpaceRunsToTabs whether to convert consecutive runs of
+        *        spaces to tabs
+        * @return the indentation corresponding to the document content specified
+        *         by <code>start</code> and <code>indent</code>
+        */
+       private StringBuilder createIndent(int start, final int indent, final boolean convertSpaceRunsToTabs) {
+               final boolean convertTabs= fPrefs.prefUseTabs && convertSpaceRunsToTabs;
+               final int tabLen= fPrefs.prefTabSize;
+               final StringBuilder ret= new StringBuilder();
+               try {
+                       int spaces= 0;
+                       while (start < indent) {
+                               char ch= fDocument.getChar(start);
+                               if (ch == '\t') {
+                                       ret.append('\t');
+                                       spaces= 0;
+                               } else if (convertTabs) {
+                                       spaces++;
+                                       if (spaces == tabLen) {
+                                               ret.append('\t');
+                                               spaces= 0;
+                                       }
+                               } else {
+                                       ret.append(' ');
+                               }
+
+                               start++;
+                       }
+                       // remainder
+                       while (spaces-- > 0)
+                               ret.append(' ');
+               } catch (BadLocationException e) {
+               }
+
+               return ret;
+       }
+
+       /**
+        * Creates a string with a visual length of the given
+        * <code>indentationSize</code>.
+        *
+        * @param buffer the original indent to reuse if possible
+        * @param additional the additional indentation units to add or subtract to
+        *        reference
+        * @param extraSpaces additional spaces to add to indentation.
+        * @return the modified <code>buffer</code> reflecting the indentation
+        *         adapted to <code>additional</code>
+        */
+       public StringBuilder createReusingIndent(StringBuilder buffer, int additional, int extraSpaces) {
+               int refLength= computeVisualLength(buffer);
+               int addLength= fPrefs.prefIndentationSize * additional + extraSpaces; // may be < 0
+               int totalLength= Math.max(0, refLength + addLength);
+
+               // copy the reference indentation for the indent up to the last tab
+               // stop within the maxCopy area
+               int minLength= Math.min(totalLength, refLength);
+               int tabSize= fPrefs.prefTabSize;
+               int maxCopyLength= tabSize > 0 ? minLength - minLength % tabSize : minLength; // maximum indent to copy
+               stripExceedingChars(buffer, maxCopyLength);
+
+               // add additional indent
+               int missing= totalLength - maxCopyLength;
+               final int tabs, spaces;
+               if (CCorePlugin.SPACE.equals(fPrefs.prefTabChar)) {
+                       tabs= 0;
+                       spaces= missing;
+               } else {
+                       tabs= tabSize > 0 ? missing / tabSize : 0;
+                       spaces= tabSize > 0 ? missing % tabSize : missing;
+               }
+               for (int i= 0; i < tabs; i++)
+                       buffer.append('\t');
+               for (int i= 0; i < spaces; i++)
+                       buffer.append(' ');
+               return buffer;
+       }
+
+       /**
+        * Returns relative indent of continuation lines.
+        * @return a number of indentation units.
+        */
+       public int getContinuationLineIndent() {
+               return fPrefs.prefContinuationIndent;
+       }
+
+       /**
+        * Returns the reference position regarding to indentation for <code>offset</code>,
+        * or <code>NOT_FOUND</code>. This method calls
+        * {@link #findReferencePosition(int, int) findReferencePosition(offset, nextChar)} where
+        * <code>nextChar</code> is the next character after <code>offset</code>.
+        *
+        * @param offset the offset for which the reference is computed
+        * @return the reference statement relative to which <code>offset</code>
+        *         should be indented, or {@link CHeuristicScanner#NOT_FOUND}
+        */
+       public int findReferencePosition(int offset) {
+               return findReferencePosition(offset, peekToken(offset));
+       }
+
+       /**
+        * Peeks the next token in the document that comes after <code>offset</code>
+        * on the same line as <code>offset</code>.
+        *
+        * @param offset the offset into document
+        * @return the token symbol of the next element, or TokenEOF if there is none
+        */
+       private int peekToken(int offset) {
+               if (offset < fDocument.getLength()) {
+                       try {
+                               IRegion line= fDocument.getLineInformationOfOffset(offset);
+                               int lineOffset= line.getOffset();
+                               int next= fScanner.nextToken(offset, lineOffset + line.getLength());
+                               return next;
+                       } catch (BadLocationException e) {
+                       }
+               }
+               return Symbols.TokenEOF;
+       }
+
+       /**
+        * Returns the reference position regarding to indentation for <code>position</code>,
+        * or <code>NOT_FOUND</code>.
+        *
+        * <p>If <code>peekNextChar</code> is <code>true</code>, the next token after
+        * <code>offset</code> is read and taken into account when computing the
+        * indentation. Currently, if the next token is the first token on the line
+        * (i.e. only preceded by whitespace), the following tokens are specially
+        * handled:
+        * <ul>
+        *      <li><code>switch</code> labels are indented relative to the switch block</li>
+        *      <li>opening curly braces are aligned correctly with the introducing code</li>
+        *      <li>closing curly braces are aligned properly with the introducing code of
+        *              the matching opening brace</li>
+        *      <li>closing parenthesis' are aligned with their opening peer</li>
+        *      <li>the <code>else</code> keyword is aligned with its <code>if</code>, anything
+        *              else is aligned normally (i.e. with the base of any introducing statements).</li>
+        *  <li>if there is no token on the same line after <code>offset</code>, the indentation
+        *              is the same as for an <code>else</code> keyword</li>
+        * </ul>
+        *
+        * @param offset the offset for which the reference is computed
+        * @param nextToken the next token to assume in the document
+        * @return the reference statement relative to which <code>offset</code>
+        *         should be indented, or {@link CHeuristicScanner#NOT_FOUND}
+        */
+       public int findReferencePosition(int offset, int nextToken) {
+               boolean danglingElse= false;
+               boolean cancelIndent= false; // If set to true, fIndent is ignored.
+               int extraIndent= 0; // Can be either positive or negative.
+               boolean matchBrace= false;
+               boolean matchParen= false;
+               boolean matchCase= false;
+               boolean matchAccessSpecifier= false;
+
+               // Account for un-indentation characters already typed in, but after position.
+               // If they are on a line by themselves, the indentation gets adjusted accordingly.
+               //
+               // Also account for a dangling else.
+               if (offset < fDocument.getLength()) {
+                       try {
+                               IRegion line= fDocument.getLineInformationOfOffset(offset);
+                               int lineOffset= line.getOffset();
+                               int prevPos= Math.max(offset - 1, 0);
+                               boolean isFirstTokenOnLine= fDocument.get(lineOffset, prevPos + 1 - lineOffset).trim().length() == 0;
+                               int prevToken= fScanner.previousToken(prevPos, CHeuristicScanner.UNBOUND);
+                               boolean bracelessBlockStart= fScanner.isBracelessBlockStart(prevPos, CHeuristicScanner.UNBOUND);
+
+                               switch (nextToken) {
+                               case Symbols.TokenELSE:
+                                       danglingElse= true;
+                                       break;
+                                       
+                               case Symbols.TokenCASE:
+                               case Symbols.TokenDEFAULT:
+                                       if (isFirstTokenOnLine)
+                                               matchCase= true;
+                                       break;
+                                       
+                               case Symbols.TokenPUBLIC:
+                               case Symbols.TokenPROTECTED:
+                               case Symbols.TokenPRIVATE:
+                                       if (isFirstTokenOnLine)
+                                               matchAccessSpecifier= true;
+                                       break;
+                                       
+                               case Symbols.TokenLBRACE: // for opening-brace-on-new-line style
+                                       if (bracelessBlockStart) {
+                                               extraIndent= fPrefs.prefIndentBracesForBlocks ? 0 : -1;
+                                       } else if (prevToken == Symbols.TokenCOLON && !fPrefs.prefIndentBracesForBlocks) {
+                                               extraIndent= -1;
+                                       } else if ((prevToken == Symbols.TokenEQUAL || prevToken == Symbols.TokenRBRACKET) &&
+                                                       !fPrefs.prefIndentBracesForArrays) {
+                                               cancelIndent= true;
+                                       } else if ((prevToken == Symbols.TokenRPAREN || prevToken == Symbols.TokenCONST) && fPrefs.prefIndentBracesForMethods) {
+                                               extraIndent= 1;
+                                       } else if (prevToken == Symbols.TokenIDENT && fPrefs.prefIndentBracesForTypes) {
+                                               extraIndent= 1;
+                                       }
+                                       break;
+                                       
+                               case Symbols.TokenRBRACE: // closing braces get unindented
+                                       if (isFirstTokenOnLine || prevToken != Symbols.TokenLBRACE)
+                                               matchBrace= true;
+                                       break;
+                                       
+                               case Symbols.TokenRPAREN:
+                                       if (isFirstTokenOnLine)
+                                               matchParen= true;
+                                       break;
+                               }
+                       } catch (BadLocationException e) {
+                       }
+               } else {
+                       // don't assume an else could come if we are at the end of file
+                       danglingElse= false;
+               }
+
+               int ref= findReferencePosition(offset, danglingElse, matchBrace, matchParen, matchCase,
+                               matchAccessSpecifier);
+               if (cancelIndent) {
+                       fIndent = 0;
+               } else if (extraIndent > 0) {
+                       fAlign= CHeuristicScanner.NOT_FOUND;
+                       fIndent += extraIndent;
+               } else {
+                       fIndent += extraIndent;
+               }
+               return ref;
+       }
+
+       /**
+        * Returns the reference position regarding to indentation for <code>position</code>,
+        * or <code>NOT_FOUND</code>.<code>fIndent</code> will contain the
+        * relative indentation (in indentation units, not characters) after the
+        * call. If there is a special alignment (e.g. for a method declaration
+        * where parameters should be aligned), <code>fAlign</code> will contain
+        * the absolute position of the alignment reference in <code>fDocument</code>,
+        * otherwise <code>fAlign</code> is set to <code>CHeuristicScanner.NOT_FOUND</code>.
+        *
+        * @param offset the offset for which the reference is computed
+        * @param danglingElse whether a dangling else should be assumed at <code>position</code>
+        * @param matchBrace whether the position of the matching brace should be
+        *            returned instead of doing code analysis
+        * @param matchParen whether the position of the matching parenthesis
+        *            should be returned instead of doing code analysis
+        * @param matchCase whether the position of a switch statement reference
+        *            should be returned (either an earlier case statement or the
+        *            switch block brace)
+        * @param matchAccessSpecifier whether the position of a class body reference
+        *            should be returned (either an earlier public/protected/private
+        *            or the class body brace)
+        * @return the reference statement relative to which <code>position</code>
+        *         should be indented, or {@link CHeuristicScanner#NOT_FOUND}
+        */
+       public int findReferencePosition(int offset, boolean danglingElse, boolean matchBrace, boolean matchParen,
+                       boolean matchCase, boolean matchAccessSpecifier) {
+               fIndent= 0; // the indentation modification
+               fAlign= CHeuristicScanner.NOT_FOUND;
+               fPosition= offset;
+
+               // forward cases
+               // An unindentation happens sometimes if the next token is special, namely on braces, parens and case
+               // labels align braces, but handle the case where we align with the method declaration start instead
+               // of the opening brace.
+               if (matchBrace) {
+                       if (skipScope(Symbols.TokenLBRACE, Symbols.TokenRBRACE)) {
+                               try {
+                                       // Align with the opening brace that is on a line by its own
+                                       int lineOffset= fDocument.getLineOffset(fLine);
+                                       if (lineOffset <= fPosition && fDocument.get(lineOffset, fPosition - lineOffset).trim().length() == 0)
+                                               return fPosition;
+                               } catch (BadLocationException e) {
+                                       // Concurrent modification - walk default path
+                               }
+                               // If the opening brace is not on the start of the line, skip to the start
+                               int pos= skipToStatementStart(true, true);
+                               fIndent= 0; // indent is aligned with reference position
+                               return pos;
+                       } else {
+                               // If we can't find the matching brace, the heuristic is to unindent
+                               // by one against the normal position
+                               int pos= findReferencePosition(offset, danglingElse, false, matchParen, matchCase,
+                                               matchAccessSpecifier);
+                               fIndent--;
+                               return pos;
+                       }
+               }
+
+               // Align parentheses
+               if (matchParen) {
+                       if (skipScope(Symbols.TokenLPAREN, Symbols.TokenRPAREN)) {
+                               return fPosition;
+                       } else {
+                               // if we can't find the matching paren, the heuristic is to unindent
+                               // by one against the normal position
+                               int pos= findReferencePosition(offset, danglingElse, matchBrace, false, matchCase,
+                                               matchAccessSpecifier);
+                               fIndent--;
+                               return pos;
+                       }
+               }
+
+               // The only reliable way to get case labels aligned (due to many different styles of using braces in
+               // a block) is to go for another case statement, or the scope opening brace.
+               if (matchCase) {
+                       return matchCaseAlignment();
+               }
+
+               // the only reliable way to get access specifiers aligned (due to many different styles of using
+               // braces in a block) is to go for another access specifier, or the scope opening brace.
+               if (matchAccessSpecifier) {
+                       return matchAccessSpecifierAlignment();
+               }
+               
+               nextToken();
+               // Skip access specifiers
+               while (fToken == Symbols.TokenCOLON && isAccessSpecifier()) {
+                       nextToken();
+               }
+
+               int line= fLine;
+               switch (fToken) {
+               case Symbols.TokenGREATERTHAN:
+               case Symbols.TokenRBRACE:
+                       // skip the block and fall through
+                       // if we can't complete the scope, reset the scan position
+                       int pos= fPosition;
+                       if (!skipScope())
+                               fPosition= pos;
+                       return skipToStatementStart(danglingElse, false);
+
+               case Symbols.TokenSEMICOLON:
+                       // this is the 90% case: after a statement block
+                       // the end of the previous statement / block previous.end
+                       // search to the end of the statement / block before the previous;
+                       // the token just after that is previous.start
+                       return skipToStatementStart(danglingElse, false);
+
+               // scope introduction: special treat who special is
+               case Symbols.TokenLPAREN:
+               case Symbols.TokenLBRACE:
+               case Symbols.TokenLBRACKET:
+                       return handleScopeIntroduction(Math.min(offset + 1, fDocument.getLength()), true);
+
+               case Symbols.TokenEOF:
+                       // trap when hitting start of document
+                       return CHeuristicScanner.NOT_FOUND;
+
+               case Symbols.TokenEQUAL:
+                       // indent assignments
+                       fIndent= fPrefs.prefAssignmentIndent;
+                       return fPosition;
+
+               case Symbols.TokenCOLON:
+                       pos= fPosition;
+                       if (looksLikeCaseStatement()) {
+                               fIndent= fPrefs.prefCaseBlockIndent;
+                               return pos;
+                       }
+                       fPosition= pos;
+                       if (looksLikeTypeInheritanceDecl()) {
+                               fIndent= fPrefs.prefBlockIndent;
+                               return pos;
+                       }
+                       fPosition= pos;
+                       if (looksLikeConstructorInitializer()) {
+                               fIndent= fPrefs.prefBlockIndent;
+                               return pos;
+                       }
+                       fPosition= pos;
+                       if (isConditional()) {
+                               fPosition= offset;
+                               fLine= line;
+                               return skipToPreviousListItemOrListStart();
+                       }
+                       fPosition= pos;
+                       return skipToPreviousListItemOrListStart();
+
+               case Symbols.TokenQUESTIONMARK:
+                       if (fPrefs.prefTernaryDeepAlign) {
+                               setFirstElementAlignment(fPosition, offset + 1);
+                       } else {
+                               fIndent= fPrefs.prefTernaryIndent;
+                       }
+                       return fPosition;
+
+               // Indentation for blockless introducers:
+               case Symbols.TokenDO:
+               case Symbols.TokenWHILE:
+               case Symbols.TokenELSE:
+                       fIndent= fPrefs.prefSimpleIndent;
+                       return fPosition;
+
+               case Symbols.TokenTRY:
+                       return skipToStatementStart(danglingElse, false);
+
+               case Symbols.TokenRETURN:
+               case Symbols.TokenTYPEDEF:
+               case Symbols.TokenUSING:
+                       fIndent = fPrefs.prefContinuationIndent;
+                       return fPosition;
+
+               case Symbols.TokenCONST:
+                       nextToken();
+                       if (fToken != Symbols.TokenRPAREN) {
+                               return skipToPreviousListItemOrListStart();
+                       }
+                       // could be const method decl
+                       //$FALL-THROUGH$
+               case Symbols.TokenRPAREN:
+                       if (skipScope(Symbols.TokenLPAREN, Symbols.TokenRPAREN)) {
+                               int scope= fPosition;
+                               nextToken();
+                               if (fToken == Symbols.TokenIF || fToken == Symbols.TokenWHILE || fToken == Symbols.TokenFOR) {
+                                       fIndent= fPrefs.prefSimpleIndent;
+                                       return fPosition;
+                               }
+                               if (fToken == Symbols.TokenSWITCH) {
+                                       return fPosition;
+                               }
+                               fPosition= scope;
+                               if (looksLikeMethodDecl()) {
+                                       return skipToStatementStart(danglingElse, false);
+                               }
+                               if (fToken == Symbols.TokenCATCH) {
+                                       return skipToStatementStart(danglingElse, false);
+                               }
+                               fPosition= scope;
+                               if (looksLikeAnonymousTypeDecl()) {
+                                       return skipToStatementStart(danglingElse, false);
+                               }
+                       }
+                       // restore
+                       fPosition= offset;
+                       fLine= line;
+                       // else: fall through to default
+                       return skipToPreviousListItemOrListStart();
+
+               case Symbols.TokenCOMMA:
+                       // Inside a list of some type.
+                       // Easy if there is already a list item before with its own indentation - we just align.
+                       // If not: take the start of the list (LPAREN, LBRACE, LBRACKET) and either align or
+                       // indent by list-indent.
+                       return skipToPreviousListItemOrListStart();
+
+               default:
+                       // Inside whatever we don't know about: similar to the list case:
+                       // if we are inside a continued expression, then either align with a previous line that
+                       // has indentation or indent from the expression start line (either a scope introducer
+                       // or the start of the expression).
+                       return skipToPreviousListItemOrListStart();
+               }
+       }
+
+       /**
+        * Test whether an identifier encountered during scanning is part of
+        * a type declaration, by scanning backward and ignoring any identifiers, commas,
+        * and colons until we hit <code>class</code>, <code>struct</code>, <code>union</code>,
+        * or <code>enum</code>.  If any braces, semicolons, or parentheses are encountered,
+        * this is not a type declaration.
+        * @return the reference offset of the start of the statement
+        */
+       private int matchTypeDeclaration() {
+               while (true) {
+                       nextToken();
+                       if (fToken == Symbols.TokenIDENT
+                                       || fToken == Symbols.TokenCOMMA
+                                       || fToken == Symbols.TokenCOLON
+                                       || fToken == Symbols.TokenPUBLIC
+                                       || fToken == Symbols.TokenPROTECTED
+                                       || fToken == Symbols.TokenPRIVATE) {
+                               continue;
+                       }
+                       if (fToken == Symbols.TokenCLASS
+                                       || fToken == Symbols.TokenSTRUCT
+                                       || fToken == Symbols.TokenUNION) {
+                               // inside a type declaration?  Only so if not preceded by '(' or ',' as in
+                               // a parameter list.  To be safe, only accept ';' or EOF
+                               int pos= fPosition;
+                               nextToken();
+                               if (fToken == Symbols.TokenSEMICOLON || fToken == Symbols.TokenEOF) {
+                                       return pos;
+                               } else {
+                                       return CHeuristicScanner.NOT_FOUND;
+                               }
+                       } else {
+                               return CHeuristicScanner.NOT_FOUND;
+                       }
+               }
+       }
+
+       /**
+        * Test whether the colon at the current position marks a case statement
+        * 
+        * @return <code>true</code> if this looks like a case statement
+        */
+       private boolean looksLikeCaseStatement() {
+               nextToken();
+               switch (fToken) {
+               case Symbols.TokenCASE:
+                       // char literal got skipped
+                       return true;
+               case Symbols.TokenIDENT:
+                       nextToken();
+                       while (skipQualifiers()) {
+                               nextToken();
+                       }
+                       while (fToken == Symbols.TokenMINUS || fToken == Symbols.TokenPLUS) {
+                               nextToken();
+                       }
+                       if (fToken == Symbols.TokenCASE) {
+                               return true;
+                       }
+                       break;
+               case Symbols.TokenOTHER:
+                       nextToken();
+                       if (fToken == Symbols.TokenCASE) {
+                               return true;
+                       }
+                       break;
+               case Symbols.TokenDEFAULT:
+                       return true;
+               }
+               return false;
+       }
+
+       /**
+        * Test whether the colon at the current position marks a type inheritance decl.
+        * 
+        * @return <code>true</code> if this looks like a type inheritance decl.
+        */
+       private boolean looksLikeTypeInheritanceDecl() {
+               nextToken();
+               switch (fToken) {
+               case Symbols.TokenIDENT:
+                       nextToken();
+                       while (skipQualifiers()) {
+                               nextToken();
+                       }
+                       switch (fToken) {
+                       case Symbols.TokenCLASS:
+                       case Symbols.TokenSTRUCT:
+                       case Symbols.TokenUNION:
+                               return true;
+                       }
+                       break;
+               }
+               return false;
+       }
+
+       /**
+        * Test whether the colon at the current position marks a constructor initializer list.
+        * 
+        * @return <code>true</code> if this looks like a constructor initializer list.
+        */
+       private boolean looksLikeConstructorInitializer() {
+               nextToken();
+               if (fToken != Symbols.TokenRPAREN) {
+                       return false;
+               }
+               if (!skipScope()) {
+                       return false;
+               }
+               nextToken();
+               if (fToken == Symbols.TokenTHROW) {
+                       nextToken();
+                       if (fToken != Symbols.TokenRPAREN) {
+                               return false;
+                       }
+                       if (!skipScope()) {
+                               return false;
+                       }
+                       nextToken();
+               }
+               if (fToken != Symbols.TokenIDENT) {
+                       return false;
+               }
+               nextToken();
+               switch (fToken) {
+               case Symbols.TokenCOLON:
+                       nextToken();
+                       switch (fToken) {
+                       case Symbols.TokenCOLON:  // A::A() :
+                       case Symbols.TokenPUBLIC:  // public: A() :
+                       case Symbols.TokenPROTECTED:
+                       case Symbols.TokenPRIVATE:
+                               return true;
+                       }
+                       return false;
+                       
+               case Symbols.TokenLBRACE:  // class A { A() :
+               case Symbols.TokenRBRACE:
+               case Symbols.TokenSEMICOLON:
+                       return true;
+               }
+               return false;
+       }
+
+       /**
+        * Test whether the left brace at the current position marks an enum decl.
+        * 
+        * @return <code>true</code> if this looks like an enum decl.
+        */
+       private boolean looksLikeEnumDeclaration() {
+               int pos = fPosition;
+               nextToken();
+               if (fToken == Symbols.TokenIDENT) {
+                       nextToken();
+                       while (skipQualifiers()) {
+                               nextToken();
+                       }
+               }
+               if (fToken == Symbols.TokenENUM) {
+                       fPosition = pos;
+                       return true;
+               }
+               fPosition = pos;
+               return false;
+       }
+
+
+       /**
+        * Test whether the colon at the current position marks an access specifier.
+        * 
+        * @return <code>true</code> if current position marks an access specifier
+        */
+       private boolean isAccessSpecifier() {
+               int pos= fPosition;
+               int token = fToken;
+               nextToken();
+               switch (fToken) {
+               case Symbols.TokenPUBLIC:
+               case Symbols.TokenPROTECTED:
+               case Symbols.TokenPRIVATE:
+                       return true;
+               }
+               fToken = token;
+               fPosition= pos;
+               return false;
+       }
+
+       /**
+        * Skips to the start of a statement that ends at the current position.
+        *
+        * @param danglingElse whether to indent aligned with the last <code>if</code>
+        * @param isInBlock whether the current position is inside a block, which limits the search scope to
+        *   the next scope introducer
+        * @return the reference offset of the start of the statement
+        */
+       private int skipToStatementStart(boolean danglingElse, boolean isInBlock) {
+               final int NOTHING= 0;
+               final int READ_PARENS= 1;
+               final int READ_IDENT= 2;
+               int mayBeMethodBody= NOTHING;
+               boolean isTypeBody= false;
+               int startLine = fLine;
+               while (true) {
+                       int prevToken= fToken;
+                       nextToken();
+
+                       if (isInBlock) {
+                               switch (fToken) {
+                               // exit on all block introducers
+                               case Symbols.TokenIF:
+                               case Symbols.TokenELSE:
+                               case Symbols.TokenCATCH:
+                               case Symbols.TokenDO:
+                               case Symbols.TokenWHILE:
+                               case Symbols.TokenFOR:
+                               case Symbols.TokenTRY:
+                                       fIndent += fPrefs.prefIndentBracesForBlocks ? 1 : 0;
+                                       return fPosition;
+                               case Symbols.TokenCLASS:
+                               case Symbols.TokenSTRUCT:
+                               case Symbols.TokenUNION:
+                                       isTypeBody= true;
+                                       break;
+
+                               case Symbols.TokenSWITCH:
+                                       fIndent= fPrefs.prefCaseIndent;
+                                       return fPosition;
+                               }
+                       }
+
+                       if (fToken == Symbols.TokenSEMICOLON && fLine == startLine) {
+                               // Skip semicolons on the same line. Otherwise we may never reach beginning of a 'for'
+                               // statement.
+                               continue;
+                       }
+
+                       switch (fToken) {
+                       // scope introduction through: LPAREN, LBRACE, LBRACKET
+                       // search stop on SEMICOLON, RBRACE, COLON, EOF
+                       // -> the next token is the start of the statement (i.e. previousPos when backward scanning)
+                       case Symbols.TokenLPAREN:
+                               if (peekToken() == Symbols.TokenFOR) {
+                                       nextToken();  // Consume 'for'
+                                       fIndent = fPrefs.prefContinuationIndent;
+                                       return fPosition;
+                               }
+                               break;
+
+                       case Symbols.TokenLBRACE:
+                       case Symbols.TokenSEMICOLON:
+                       case Symbols.TokenEOF:
+                               if (isInBlock)
+                                       fIndent= getBlockIndent(mayBeMethodBody == READ_IDENT, isTypeBody);
+                               return fPreviousPos;
+
+                       case Symbols.TokenCOLON:
+                               int pos= fPreviousPos;
+                               if (!isConditional())
+                                       return pos;
+                               break;
+
+                       case Symbols.TokenRBRACE:
+                               // RBRACE is a little tricky: it can be the end of an array definition, but
+                               // usually it is the end of a previous block
+                               pos= fPreviousPos; // store state
+                               if (skipScope()) {
+                                       if (looksLikeArrayInitializerIntro()) {
+                                               continue; // it's an array
+                                       }
+                                       if (prevToken == Symbols.TokenSEMICOLON) {
+                                               // end of type def
+                                               continue;
+                                       }
+                               }
+                               if (isInBlock)
+                                       fIndent= getBlockIndent(mayBeMethodBody == READ_IDENT, isTypeBody);
+                               return pos; // it's not - do as with all the above
+
+                       // scopes: skip them
+                       case Symbols.TokenRPAREN:
+                               if (isInBlock)
+                                       mayBeMethodBody= READ_PARENS;
+                               // fall thru
+                               pos= fPreviousPos;
+                               if (skipScope())
+                                       break;
+                               else
+                                       return pos;
+                       case Symbols.TokenRBRACKET:
+                               pos= fPreviousPos;
+                               if (skipScope())
+                                       break;
+                               else
+                                       return pos;
+
+                       // IF / ELSE: align the position after the conditional block with the if
+                       // so we are ready for an else, except if danglingElse is false
+                       // in order for this to work, we must skip an else to its if
+                       case Symbols.TokenIF:
+                               if (danglingElse)
+                                       return fPosition;
+                               else
+                                       break;
+                       case Symbols.TokenELSE:
+                               // skip behind the next if, as we have that one covered
+                               pos= fPosition;
+                               if (skipNextIF())
+                                       break;
+                               else
+                                       return pos;
+
+                       case Symbols.TokenDO:
+                               // align the WHILE position with its do
+                               return fPosition;
+
+                       case Symbols.TokenWHILE:
+                               // this one is tricky: while can be the start of a while loop
+                               // or the end of a do - while
+                               pos= fPosition;
+                               if (hasMatchingDo()) {
+                                       // continue searching from the DO on
+                                       break;
+                               } else {
+                                       // continue searching from the WHILE on
+                                       fPosition= pos;
+                                       break;
+                               }
+                       case Symbols.TokenIDENT:
+                               if (mayBeMethodBody == READ_PARENS)
+                                       mayBeMethodBody= READ_IDENT;
+                               break;
+
+                       default:
+                               // keep searching
+                       }
+               }
+       }
+
+       private int getBlockIndent(boolean isMethodBody, boolean isTypeBody) {
+               if (isTypeBody) {
+                       return fPrefs.prefTypeIndent + fPrefs.prefAccessSpecifierIndent;
+               } else if (isMethodBody) {
+                       return fPrefs.prefMethodBodyIndent + (fPrefs.prefIndentBracesForMethods ? 1 : 0);
+               } else {
+                       return fIndent;
+               }
+       }
+
+       /**
+        * Returns <code>true</code> if the colon at the current position is part of a conditional
+        * (ternary) expression, <code>false</code> otherwise.
+        *
+        * @return <code>true</code> if the colon at the current position is part of a conditional
+        */
+       private boolean isConditional() {
+               while (true) {
+                       int previous= fToken;
+                       nextToken();
+                       switch (fToken) {
+                       // search for case labels, which consist of (possibly qualified) identifiers or numbers
+                       case Symbols.TokenIDENT:
+                               if (previous == Symbols.TokenIDENT) {
+                                       return false;
+                               }
+                               // fall thru
+                               continue;
+                       case Symbols.TokenDOUBLECOLON:
+                       case Symbols.TokenOTHER:
+                       case Symbols.TokenMINUS:
+                       case Symbols.TokenPLUS:
+                               continue;
+                               
+                       case Symbols.TokenQUESTIONMARK:
+                               return true;
+                               
+                       case Symbols.TokenSEMICOLON:
+                       case Symbols.TokenLBRACE:
+                       case Symbols.TokenRBRACE:
+                       case Symbols.TokenCASE:
+                       case Symbols.TokenDEFAULT:
+                       case Symbols.TokenPUBLIC:
+                       case Symbols.TokenPROTECTED:
+                       case Symbols.TokenPRIVATE:
+                       case Symbols.TokenCLASS:
+                       case Symbols.TokenSTRUCT:
+                       case Symbols.TokenUNION:
+                               return false;
+
+                       default:
+                               return true;
+                       }
+               }
+       }
+
+       /**
+        * Returns as a reference any previous <code>switch</code> labels (<code>case</code>
+        * or <code>default</code>) or the offset of the brace that scopes the switch
+        * statement. Sets <code>fIndent</code> to <code>prefCaseIndent</code> upon
+        * a match.
+        *
+        * @return the reference offset for a <code>switch</code> label
+        */
+       private int matchCaseAlignment() {
+               while (true) {
+                       nextToken();
+                       switch (fToken) {
+                       // invalid cases: another case label or an LBRACE must come before a case
+                       // -> bail out with the current position
+                       case Symbols.TokenLPAREN:
+                       case Symbols.TokenLBRACKET:
+                       case Symbols.TokenEOF:
+                               return fPosition;
+                               
+                       case Symbols.TokenSWITCH:
+                               // start of switch statement
+                               fIndent= fPrefs.prefCaseIndent;
+                               return fPosition;
+                               
+                       case Symbols.TokenCASE:
+                       case Symbols.TokenDEFAULT:
+                               // align with previous label
+                               fIndent= 0;
+                               return fPosition;
+
+                       // scopes: skip them
+                       case Symbols.TokenRPAREN:
+                       case Symbols.TokenRBRACKET:
+                       case Symbols.TokenRBRACE:
+                               skipScope();
+                               break;
+
+                       default:
+                               // keep searching
+                               continue;
+                       }
+               }
+       }
+
+       /**
+        * Returns as a reference any previous access specifiers (<code>public</code>,
+        * <code>protected</code> or <code>default</code>) or the offset of the brace that
+        * scopes the class body.
+        * Sets <code>fIndent</code> to <code>prefAccessSpecifierIndent</code> upon
+        * a match.
+        *
+        * @return the reference offset for an access specifier (public/protected/private)
+        */
+       private int matchAccessSpecifierAlignment() {
+               while (true) {
+                       nextToken();
+                       switch (fToken) {
+                       // invalid cases: another access specifier or an LBRACE must come before an access specifier
+                       // -> bail out with the current position
+                       case Symbols.TokenLPAREN:
+                       case Symbols.TokenLBRACKET:
+                       case Symbols.TokenEOF:
+                               return fPosition;
+                               
+                       case Symbols.TokenLBRACE:
+                               // opening brace of class body
+                               int pos= fPosition;
+                               int typeDeclPos= matchTypeDeclaration();
+                               fIndent= fPrefs.prefAccessSpecifierIndent;
+                               fExtraSpaces = fPrefs.prefAccessSpecifierExtraSpaces;
+                               if (typeDeclPos != CHeuristicScanner.NOT_FOUND) {
+                                       return typeDeclPos;
+                               }
+                               return pos;
+                       case Symbols.TokenPUBLIC:
+                       case Symbols.TokenPROTECTED:
+                       case Symbols.TokenPRIVATE:
+                               // align with previous access specifier
+                               fIndent= 0;
+                               return fPosition;
+
+                       // scopes: skip them
+                       case Symbols.TokenRPAREN:
+                       case Symbols.TokenRBRACKET:
+                       case Symbols.TokenRBRACE:
+                               skipScope();
+                               break;
+
+                       default:
+                               // keep searching
+                               continue;
+                       }
+               }
+       }
+
+       /**
+        * Returns the reference position for a list element. The algorithm
+        * tries to match any previous indentation on the same list. If there is none,
+        * the reference position returned is determined depending on the type of list:
+        * The indentation will either match the list scope introducer (e.g. for
+        * method declarations), so called deep indents, or simply increase the
+        * indentation by a number of standard indents. See also {@link #handleScopeIntroduction(int, boolean)}.
+        * @return the reference position for a list item: either a previous list item
+        * that has its own indentation, or the list introduction start.
+        */
+       private int skipToPreviousListItemOrListStart() {
+               int startLine= fLine;
+               int startPosition= fPosition;
+               boolean continuationLineCandidate =
+                               fToken == Symbols.TokenEQUAL || fToken == Symbols.TokenSHIFTLEFT ||
+                               fToken == Symbols.TokenRPAREN;
+               while (true) {
+                       int previous = fToken;
+                       nextToken();
+
+                       // If any line item comes with its own indentation, adapt to it
+                       if (fLine < startLine) {
+                               try {
+                                       int lineOffset= fDocument.getLineOffset(startLine);
+                                       int bound= Math.min(fDocument.getLength(), startPosition + 1);
+                                       if ((fToken == Symbols.TokenSEMICOLON || fToken == Symbols.TokenRBRACE ||
+                                                       fToken == Symbols.TokenLBRACE && !looksLikeArrayInitializerIntro() && !looksLikeEnumDeclaration()) &&
+                                                       continuationLineCandidate) {
+                                               fIndent = fPrefs.prefContinuationIndent;
+                                       } else {
+                                               fAlign= fScanner.findNonWhitespaceForwardInAnyPartition(lineOffset, bound);
+                                               // If the reference line starts with a colon, skip the colon.  
+                                               if (peekToken(fAlign) == Symbols.TokenCOLON) {
+                                                       fAlign= fScanner.findNonWhitespaceForwardInAnyPartition(fAlign + 1, bound);
+                                               }
+                                       }
+                               } catch (BadLocationException e) {
+                                       // Ignore and return just the position
+                               }
+                               return startPosition;
+                       }
+
+                       switch (fToken) {
+                       // scopes: skip them
+                       case Symbols.TokenRPAREN:
+                               continuationLineCandidate = true;
+                               //$FALL-THROUGH$
+                       case Symbols.TokenRBRACKET:
+                       case Symbols.TokenRBRACE:
+                               skipScope();
+                               break;
+
+                       // scope introduction: special treat who special is
+                       case Symbols.TokenLPAREN:
+                       case Symbols.TokenLBRACE:
+                       case Symbols.TokenLBRACKET:
+                               return handleScopeIntroduction(startPosition + 1, false);
+
+                       case Symbols.TokenSEMICOLON:
+                               return fPosition;
+
+                       case Symbols.TokenQUESTIONMARK:
+                               if (fPrefs.prefTernaryDeepAlign) {
+                                       setFirstElementAlignment(fPosition - 1, fPosition + 1);
+                               } else {
+                                       fIndent= fPrefs.prefTernaryIndent;
+                               }
+                               return fPosition;
+
+                       case Symbols.TokenEQUAL:
+                       case Symbols.TokenSHIFTLEFT:
+                               continuationLineCandidate = true;
+                               break;
+
+                       case Symbols.TokenRETURN:
+                       case Symbols.TokenUSING:
+                               fIndent = fPrefs.prefContinuationIndent;
+                               return fPosition;
+
+                       case Symbols.TokenTYPEDEF:
+                               switch (previous) {
+                               case Symbols.TokenSTRUCT:
+                               case Symbols.TokenUNION:
+                               case Symbols.TokenCLASS:
+                               case Symbols.TokenENUM:
+                                       break;
+                               default:
+                                       fIndent = fPrefs.prefContinuationIndent;
+                               }
+                               return fPosition;
+
+                       case Symbols.TokenEOF:
+                               if (continuationLineCandidate) {
+                                       fIndent = fPrefs.prefContinuationIndent;
+                               }
+                               return 0;
+                       }
+               }
+       }
+
+       /**
+        * Skips a scope and positions the cursor (<code>fPosition</code>) on the
+        * token that opens the scope. Returns <code>true</code> if a matching peer
+        * could be found, <code>false</code> otherwise. The current token when calling
+        * must be one out of <code>Symbols.TokenRPAREN</code>, <code>Symbols.TokenRBRACE</code>,
+        * and <code>Symbols.TokenRBRACKET</code>.
+        *
+        * @return <code>true</code> if a matching peer was found, <code>false</code> otherwise
+        */
+       private boolean skipScope() {
+               switch (fToken) {
+               case Symbols.TokenRPAREN:
+                       return skipScope(Symbols.TokenLPAREN, Symbols.TokenRPAREN);
+               case Symbols.TokenRBRACKET:
+                       return skipScope(Symbols.TokenLBRACKET, Symbols.TokenRBRACKET);
+               case Symbols.TokenRBRACE:
+                       return skipScope(Symbols.TokenLBRACE, Symbols.TokenRBRACE);
+               case Symbols.TokenGREATERTHAN:
+                       if (!fPrefs.prefHasTemplates)
+                               return false;
+                       int storedPosition= fPosition;
+                       int storedToken= fToken;
+                       nextToken();
+                       switch (fToken) {
+                               case Symbols.TokenIDENT:
+                                       fPosition = storedPosition;
+                                       if (skipScope(Symbols.TokenLESSTHAN, Symbols.TokenGREATERTHAN))
+                                               return true;
+                                       break;
+                               case Symbols.TokenQUESTIONMARK:
+                               case Symbols.TokenGREATERTHAN:
+                                       fPosition = storedPosition;
+                                       if (skipScope(Symbols.TokenLESSTHAN, Symbols.TokenGREATERTHAN))
+                                               return true;
+                                       break;
+                       }
+                       // <> are harder to detect - restore the position if we fail
+                       fPosition= storedPosition;
+                       fToken= storedToken;
+                       return false;
+
+               default:
+                        // programming error
+                       Assert.isTrue(false);
+                       return false;
+               }
+       }
+
+       /**
+        * Returns the contents of the current token.
+        *
+        * @return the contents of the current token
+        */
+       private CharSequence getTokenContent() {
+               return new DocumentCharacterIterator(fDocument, fPosition, fPreviousPos);
+       }
+
+       /**
+        * Handles the introduction of a new scope. The current token must be one out
+        * of <code>Symbols.TokenLPAREN</code>, <code>Symbols.TokenLBRACE</code>,
+        * and <code>Symbols.TokenLBRACKET</code>. Returns as the reference position
+        * either the token introducing the scope or - if available - the first
+        * token after that.
+        *
+        * <p>Depending on the type of scope introduction, the indentation will align
+        * (deep indenting) with the reference position (<code>fAlign</code> will be
+        * set to the reference position) or <code>fIndent</code> will be set to
+        * the number of indentation units.
+        * </p>
+        *
+        * @param bound the bound for the search for the first token after the scope
+        * introduction.
+        * @param firstToken <code>true</code> if we are dealing with the first token after
+        * the opening parenthesis.
+        * @return the indent
+        */
+       private int handleScopeIntroduction(int bound, boolean firstToken) {
+               int pos= fPosition; // store
+
+               switch (fToken) {
+               // scope introduction: special treat who special is
+               case Symbols.TokenLPAREN:
+                       // special: method declaration deep indentation
+                       if (looksLikeMethodDecl()) {
+                               if (firstToken ? fPrefs.prefMethodDeclFirstParameterDeepIndent : fPrefs.prefMethodDeclDeepIndent) {
+                                       return setFirstElementAlignment(pos, bound);
+                               } else {
+                                       fIndent= fPrefs.prefMethodDeclIndent;
+                                       return pos;
+                               }
+                       } else {
+                               fPosition= pos;
+                               if (looksLikeMethodCall()) {
+                                       if (firstToken ? fPrefs.prefMethodCallFirstParameterDeepIndent : fPrefs.prefMethodCallDeepIndent) {
+                                               return setFirstElementAlignment(pos, bound);
+                                       } else {
+                                               fIndent= fPrefs.prefMethodCallIndent;
+                                               return pos;
+                                       }
+                               } else if (fPrefs.prefParenthesisDeepIndent) {
+                                       return setFirstElementAlignment(pos, bound);
+                               }
+                       }
+
+                       // normal: return the parenthesis as reference
+                       fIndent= fPrefs.prefParenthesisIndent;
+                       return pos;
+
+               case Symbols.TokenLBRACE:
+                       final boolean looksLikeArrayInitializerIntro= looksLikeArrayInitializerIntro();
+                       // special: array initializer
+                       if (looksLikeArrayInitializerIntro) {
+                               if (fPrefs.prefArrayDeepIndent)
+                                       return setFirstElementAlignment(pos, bound);
+                               else
+                                       fIndent= fPrefs.prefArrayIndent;
+                       } else if (isNamespace() || isLinkageSpec()) {
+                               fIndent= fPrefs.prefNamespaceBodyIndent;
+                       } else if (looksLikeEnumDeclaration()) {
+                               fIndent = fPrefs.prefTypeIndent;
+                       } else {
+                               int typeDeclPos = matchTypeDeclaration();
+                               if (typeDeclPos == CHeuristicScanner.NOT_FOUND) {
+                                       fIndent= fPrefs.prefBlockIndent;
+                               } else {
+                                       fIndent= fPrefs.prefAccessSpecifierIndent + fPrefs.prefTypeIndent;
+                               }
+                       }
+
+                       // normal: skip to the statement start before the scope introducer
+                       // opening braces are often on differently ending indents than e.g. a method definition
+                       if (!looksLikeArrayInitializerIntro) {
+                               fPosition= pos; // restore
+                               return skipToStatementStart(true, true); // set to true to match the first if
+                       } else {
+                               return pos;
+                       }
+
+               case Symbols.TokenLBRACKET:
+                       // special: method declaration deep indentation
+                       if (fPrefs.prefArrayDimensionsDeepIndent) {
+                               return setFirstElementAlignment(pos, bound);
+                       }
+
+                       // normal: return the bracket as reference
+                       fIndent= fPrefs.prefBracketIndent;
+                       return pos; // restore
+
+               default:
+                       // programming error
+                       Assert.isTrue(false);
+                       return -1; // dummy
+               }
+       }
+
+       /**
+        * Sets the deep indent offset (<code>fAlign</code>) to either the offset
+        * right after <code>scopeIntroducerOffset</code> or - if available - the
+        * first C token after <code>scopeIntroducerOffset</code>, but before
+        * <code>bound</code>.
+        *
+        * @param scopeIntroducerOffset the offset of the scope introducer
+        * @param bound the bound for the search for another element
+        * @return the reference position
+        */
+       private int setFirstElementAlignment(int scopeIntroducerOffset, int bound) {
+               int firstPossible= scopeIntroducerOffset + 1; // align with the first position after the scope intro
+               fAlign= fScanner.findNonWhitespaceForwardInAnyPartition(firstPossible, bound);
+               if (fAlign == CHeuristicScanner.NOT_FOUND) {
+                       fAlign= firstPossible;
+               } else {
+                       try {
+                               IRegion lineRegion = fDocument.getLineInformationOfOffset(scopeIntroducerOffset);
+                               if (fAlign > lineRegion.getOffset() + lineRegion.getLength()) {
+                                       fAlign= firstPossible; 
+                               }
+                       } catch (BadLocationException e) {
+                               // Ignore.
+                       }
+               }
+               return fAlign;
+       }
+
+       /**
+        * Returns <code>true</code> if the next token received after calling
+        * <code>nextToken</code> is either an equal sign, an opening brace,
+        * a comma or an array designator ('[]').
+        *
+        * @return <code>true</code> if the next elements look like the start of an array definition
+        */
+       private boolean looksLikeArrayInitializerIntro() {
+               int pos= fPosition;
+               nextToken();
+               switch (fToken) {
+               case Symbols.TokenEQUAL:
+                       return true;
+               case Symbols.TokenRBRACKET:
+                       return skipBrackets();
+               case Symbols.TokenLBRACE:
+                       if (looksLikeArrayInitializerIntro()) {
+                               fPosition= pos;
+                               return true;
+                       }
+                       return false;
+               case Symbols.TokenCOMMA:
+                       fPosition= pos;
+                       return true;
+               }
+               fPosition= pos;
+               return false;
+       }
+
+       /**
+        * Returns <code>true</code> if the the current token is "namespace", or the current token
+        * is an identifier and the previous token is "namespace".
+        *
+        * @return <code>true</code> if the next elements look like the start of a namespace declaration.
+        */
+       private boolean isNamespace() {
+               int pos = fPosition;
+               nextToken();
+               if (fToken == Symbols.TokenNAMESPACE) {
+                       fPosition = pos;
+                       return true;            // Anonymous namespace
+               } else if (fToken == Symbols.TokenIDENT) {
+                       nextToken();            // Get previous token
+                       if (fToken == Symbols.TokenNAMESPACE) {
+                               fPosition = pos;
+                               return true;    // Named namespace
+                       }
+               }
+               fPosition = pos;
+               return false;
+       }
+
+       /**
+        * Returns <code>true</code> if the current token is keyword "extern".
+        *
+        * @return <code>true</code> if the next elements look like the start of a linkage spec.
+        */
+       private boolean isLinkageSpec() {
+               int pos = fPosition;
+               nextToken();
+               if (fToken == Symbols.TokenEXTERN) {
+                       fPosition = pos;
+                       return true;
+               }
+               fPosition = pos;
+               return false;
+       }
+
+       /**
+        * Skips over the next <code>if</code> keyword. The current token when calling
+        * this method must be an <code>else</code> keyword. Returns <code>true</code>
+        * if a matching <code>if</code> could be found, <code>false</code> otherwise.
+        * The cursor (<code>fPosition</code>) is set to the offset of the <code>if</code>
+        * token.
+        *
+        * @return <code>true</code> if a matching <code>if</code> token was found, <code>false</code> otherwise
+        */
+       private boolean skipNextIF() {
+               Assert.isTrue(fToken == Symbols.TokenELSE);
+
+               while (true) {
+                       nextToken();
+                       switch (fToken) {
+                       // scopes: skip them
+                       case Symbols.TokenRPAREN:
+                       case Symbols.TokenRBRACKET:
+                       case Symbols.TokenRBRACE:
+                               skipScope();
+                               break;
+
+                       case Symbols.TokenIF:
+                               // found it, return
+                               return true;
+                       case Symbols.TokenELSE:
+                               // recursively skip else-if blocks
+                               skipNextIF();
+                               break;
+
+                       // shortcut scope starts
+                       case Symbols.TokenLPAREN:
+                       case Symbols.TokenLBRACE:
+                       case Symbols.TokenLBRACKET:
+                       case Symbols.TokenEOF:
+                               return false;
+                       }
+               }
+       }
+
+       /**
+        * while(condition); is ambiguous when parsed backwardly, as it is a valid
+        * statement by its own, so we have to check whether there is a matching
+        * do. A <code>do</code> can either be separated from the while by a
+        * block, or by a single statement, which limits our search distance.
+        *
+        * @return <code>true</code> if the <code>while</code> currently in
+        *         <code>fToken</code> has a matching <code>do</code>.
+        */
+       private boolean hasMatchingDo() {
+               Assert.isTrue(fToken == Symbols.TokenWHILE);
+               nextToken();
+               switch (fToken) {
+               case Symbols.TokenRBRACE:
+                       skipScope(); // and fall thru
+                       skipToStatementStart(false, false);
+                       return fToken == Symbols.TokenDO;
+
+               case Symbols.TokenSEMICOLON:
+                       skipToStatementStart(false, false);
+                       return fToken == Symbols.TokenDO;
+               }
+               return false;
+       }
+
+       /**
+        * Skips pointer operators if the current token is a pointer operator.
+        *
+        * @return <code>true</code> if a <code>*</code> or <code>&amp;</code> could be scanned, the
+        *         current token is left at the operator.
+        */
+       private boolean skipPointerOperators() {
+               if (fToken == Symbols.TokenOTHER) {
+                       CharSequence token= getTokenContent().toString().trim();
+                       if (token.length() == 1 && token.charAt(0) == '*' || token.charAt(0) == '&') {
+                               return true;
+                       }
+               } else if (fToken == Symbols.TokenCONST) {
+                       return true;
+               }
+               return false;
+       }
+
+       /**
+        * Skips brackets if the current token is a RBRACKET. There can be nothing
+        * but whitespace in between, this is only to be used for <code>[]</code> elements.
+        *
+        * @return <code>true</code> if a <code>[]</code> could be scanned, the
+        *         current token is left at the LBRACKET.
+        */
+       private boolean skipBrackets() {
+               if (fToken == Symbols.TokenRBRACKET) {
+                       nextToken();
+                       if (fToken == Symbols.TokenLBRACKET) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+       /**
+        * Skips scope qualifiers of identifiers.
+        * 
+        * @return <code>true</code> if a qualifier was encountered, the last token
+        *         will be an IDENT.
+        */
+       private boolean skipQualifiers() {
+               if (fToken == Symbols.TokenDOUBLECOLON) {
+                       nextToken();
+                       if (fToken == Symbols.TokenIDENT) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+       /**
+        * Reads the next token in backward direction from the heuristic scanner
+        * and sets the fields <code>fToken, fPreviousPosition</code> and <code>fPosition</code>
+        * accordingly.
+        */
+       private void nextToken() {
+               nextToken(fPosition);
+       }
+
+       /**
+        * Reads the next token in backward direction of <code>start</code> from
+        * the heuristic scanner and sets the fields <code>fToken, fPreviousPosition</code>
+        * and <code>fPosition</code> accordingly.
+        *
+        * @param start the start offset from which to scan backwards
+        */
+       private void nextToken(int start) {
+               fToken= fScanner.previousToken(start - 1, CHeuristicScanner.UNBOUND);
+               fPreviousPos= start;
+               fPosition= fScanner.getPosition() + 1;
+               try {
+                       fLine= fDocument.getLineOfOffset(fPosition);
+               } catch (BadLocationException e) {
+                       fLine= -1;
+               }
+       }
+
+       /**
+        * Reads the next token in backward direction from the heuristic scanner
+        * and returns that token without changing the current position.
+        */
+       private int peekToken() {
+               return fScanner.previousToken(fPosition - 1, CHeuristicScanner.UNBOUND);
+       }
+
+       /**
+        * Returns <code>true</code> if the current tokens look like a method
+        * declaration header (i.e. only the return type and method name). The
+        * heuristic calls <code>nextToken</code> and expects an identifier
+        * (method name) and an optional return type declaration.
+        *
+        * @return <code>true</code> if the current position looks like a method
+        *         declaration header.
+        */
+       private boolean looksLikeMethodDecl() {
+               nextToken();
+               switch (fToken) {
+               case Symbols.TokenIDENT: // method name
+                       int pos= fPosition;
+                       nextToken();
+                       // check destructor tilde
+                       if (fToken == Symbols.TokenTILDE) {
+                               return true;
+                       }
+                       if (skipQualifiers()) {
+                               return true;
+                       }
+                       // optional brackets for array valued return types
+                       while (skipBrackets()) {
+                               nextToken();
+                       }
+                       while (skipPointerOperators()) {
+                               nextToken();
+                       }
+                       switch (fToken) {
+                       case Symbols.TokenIDENT:
+                               return true;
+                       case Symbols.TokenSEMICOLON:
+                       case Symbols.TokenRBRACE:
+                               fPosition= pos;
+                               return true;
+                       case Symbols.TokenLBRACE:
+                               if (fScanner.looksLikeCompositeTypeDefinitionBackward(fPosition, CHeuristicScanner.UNBOUND)) {
+                                       fPosition= pos;
+                                       return true;
+                               }
+                               break;
+                       case Symbols.TokenCOMMA:
+                               nextToken();
+                               if (fToken == Symbols.TokenRPAREN) {
+                                       // field initializer
+                                       if (skipScope()) {
+                                               return looksLikeMethodDecl();
+                                       }
+                               }
+                               break;
+                       case Symbols.TokenCOLON:
+                               nextToken();
+                               switch (fToken) {
+                               case Symbols.TokenPUBLIC:
+                               case Symbols.TokenPROTECTED:
+                               case Symbols.TokenPRIVATE:
+                                       fPosition= pos;
+                                       return true;
+                               case Symbols.TokenRPAREN:
+                                       // constructor initializer
+                                       if (skipScope()) {
+                                               pos = fPosition;
+                                               nextToken();
+                                               // optional throw
+                                               if (fToken == Symbols.TokenTHROW) {
+                                                       nextToken();
+                                                       if (fToken != Symbols.TokenRPAREN || !skipScope()) {
+                                                               return false;
+                                                       }
+                                               } else {
+                                                       fPosition = pos;
+                                               }
+                                               return looksLikeMethodDecl();
+                                       }
+                                       break;
+                               }
+                       }
+                       break;
+               case Symbols.TokenARROW:
+               case Symbols.TokenCOMMA:
+               case Symbols.TokenEQUAL:
+               case Symbols.TokenGREATERTHAN:
+               case Symbols.TokenLESSTHAN:
+               case Symbols.TokenMINUS:
+               case Symbols.TokenPLUS:
+               case Symbols.TokenSHIFTRIGHT:
+               case Symbols.TokenSHIFTLEFT:
+               case Symbols.TokenDELETE:
+               case Symbols.TokenNEW:
+                       nextToken();
+                       return fToken == Symbols.TokenOPERATOR;
+               case Symbols.TokenRPAREN:
+                       nextToken();
+                       if (fToken != Symbols.TokenLPAREN)
+                               return false;
+                       nextToken();
+                       return fToken == Symbols.TokenOPERATOR;
+               case Symbols.TokenRBRACKET:
+                       nextToken();
+                       if (fToken != Symbols.TokenLBRACKET)
+                               return false;
+                       nextToken();
+                       if (fToken == Symbols.TokenNEW || fToken == Symbols.TokenDELETE)
+                               nextToken();
+                       return fToken == Symbols.TokenOPERATOR;
+               case Symbols.TokenOTHER:
+                       if (getTokenContent().length() == 1) {
+                               nextToken();
+                               if (fToken == Symbols.TokenOPERATOR)
+                                       return true;
+                       }
+                       if (getTokenContent().length() == 1) {
+                               nextToken();
+                               if (fToken == Symbols.TokenOPERATOR)
+                                       return true;
+                       }
+               }
+               return false;
+       }
+
+       /**
+        * Returns <code>true</code> if the current tokens look like an anonymous type declaration
+        * header (i.e. a type name (potentially qualified) and a new keyword). The heuristic calls
+        * <code>nextToken</code> and expects a possibly qualified identifier (type name) and a new
+        * keyword
+        * 
+        * @return <code>true</code> if the current position looks like a anonymous type declaration
+        *         header.
+        */
+       private boolean looksLikeAnonymousTypeDecl() {
+               nextToken();
+               if (fToken == Symbols.TokenIDENT) { // type name
+                       nextToken();
+                       while (fToken == Symbols.TokenOTHER) { // dot of qualification
+                               nextToken();
+                               if (fToken != Symbols.TokenIDENT) // qualifying name
+                                       return false;
+                               nextToken();
+                       }
+                       return fToken == Symbols.TokenNEW;
+               }
+               return false;
+       }
+
+       /**
+        * Returns <code>true</code> if the current tokens look like beginning of a method
+        * call (i.e. an identifier as opposed to a keyword taking parenthesized parameters
+        * such as <code>if</code>).
+        * <p>The heuristic calls <code>nextToken</code> and expects an identifier
+        * (method name).
+        *
+        * @return <code>true</code> if the current position looks like a method call
+        *         header.
+        */
+       private boolean looksLikeMethodCall() {
+               nextToken();
+               if (fToken == Symbols.TokenGREATERTHAN) {
+                       if (!skipScope())
+                               return false;
+                       nextToken();
+               }
+               return fToken == Symbols.TokenIDENT; // method name
+       }
+
+       /**
+        * Scans tokens for the matching opening peer. The internal cursor
+        * (<code>fPosition</code>) is set to the offset of the opening peer if found.
+        *
+        * @param openToken the opening peer token
+        * @param closeToken the closing peer token
+        * @return <code>true</code> if a matching token was found, <code>false</code>
+        *         otherwise
+        */
+       private boolean skipScope(int openToken, int closeToken) {
+               int depth= 1;
+
+               while (true) {
+                       nextToken();
+
+                       if (fToken == closeToken) {
+                               depth++;
+                       } else if (fToken == openToken) {
+                               depth--;
+                               if (depth == 0)
+                                       return true;
+                       } else if (fToken == Symbols.TokenEOF) {
+                               return false;
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COperatorRule.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COperatorRule.java
new file mode 100644 (file)
index 0000000..5dc1c91
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.jface.text.rules.IToken;
+
+/**
+ * Rule to recognize operators.
+ *
+ * @author P.Tomaszewski
+ */
+public class COperatorRule extends SingleCharRule
+{
+    /**
+     * Creates new rule.
+     * @param token Style token.
+     */
+    public COperatorRule(IToken token)
+    {
+        super(token);
+    }
+
+    /**
+     * @see org.eclipse.cdt.internal.ui.text.SingleCharRule#isRuleChar(int)
+     */
+    @Override
+       public boolean isRuleChar(int ch)
+    {
+        return (ch == ';' || ch == '.' || ch == ':' || ch == '=' || ch == '-'
+            || ch == '+' || ch == '\\' || ch == '*' || ch == '!' || ch == '%'
+            || ch == '^' || ch == '&' || ch == '~' || ch == '>' || ch == '<')
+            || ch == '|' || ch == '/' || ch == '?' || ch == ',';
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java
new file mode 100644 (file)
index 0000000..c2629ad
--- /dev/null
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2011 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Sergey Prigogin, Google
+ *     Anton Leherbauer (Wind River Systems)
+ *     Patrick Hofer (bug #345809)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.AbstractTreeViewer;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+import org.eclipse.cdt.internal.ui.editor.CContentOutlinerProvider;
+import org.eclipse.cdt.internal.ui.editor.LexicalSortingAction;
+import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
+import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
+import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCLabelProvider;
+
+/**
+ * Control which shows outline information in C/C++ editor. Based on
+ * AbstracInformationContol/JavaOutlineInformationControl from JDT.
+ * 
+ * @author P.Tomaszewski
+ */
+public class COutlineInformationControl extends AbstractInformationControl {
+
+       private static final long TEXT_FLAGS = AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | CElementLabels.F_APP_TYPE_SIGNATURE | CElementLabels.M_APP_RETURNTYPE;
+       private static final int IMAGE_FLAGS = AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS;
+
+       private ICElement fInput = null;
+       
+    private IContentProvider fOutlineContentProvider;
+
+    /** The action to toggle sorting */
+       private LexicalSortingAction fSortingAction;
+
+    /**
+     * Creates new outline control.
+     * 
+     * @param parent
+     *            Shell parent.
+     * @param shellStyle
+     *            Style of new shell.
+     * @param treeStyle
+     *            Style of the tree viewer.
+     */
+    public COutlineInformationControl(Shell parent, int shellStyle, int treeStyle) {
+        super(parent, shellStyle, treeStyle, null, false);
+    }
+
+       /**
+        * {@inheritDoc}
+        */
+    @Override
+       protected TreeViewer createTreeViewer(Composite parent, int treeStyle) {
+        TreeViewer treeViewer = new ProblemTreeViewer(parent, treeStyle);
+        final Tree tree = treeViewer.getTree();
+        tree.setLayoutData(new GridData(GridData.FILL_BOTH));
+        fOutlineContentProvider = new CContentOutlinerProvider(treeViewer);
+        treeViewer.setContentProvider(fOutlineContentProvider);
+        fSortingAction= new LexicalSortingAction(treeViewer, ".isChecked"); //$NON-NLS-1$
+               treeViewer.addFilter(new NamePatternFilter());
+               long textFlags = TEXT_FLAGS;
+               if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.OUTLINE_GROUP_MEMBERS))
+                       textFlags = textFlags | CElementLabels.M_SIMPLE_NAME | CElementLabels.F_SIMPLE_NAME;
+               treeViewer.setLabelProvider(new DecoratingCLabelProvider(new AppearanceAwareLabelProvider(textFlags,
+                               IMAGE_FLAGS), true));
+        treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
+        return treeViewer;
+    }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.AbstractInformationControl#getId()
+        */
+       @Override
+       protected String getId() {
+               return "org.eclipse.cdt.internal.ui.text.QuickOutline"; //$NON-NLS-1$
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public void setInput(Object information) {
+               if (information == null || information instanceof String) {
+                       inputChanged(null, null);
+                       return;
+               }
+               ICElement ce = (ICElement)information;
+               ITranslationUnit tu = (ITranslationUnit)ce.getAncestor(ICElement.C_UNIT);
+               if (tu != null)
+                       fInput = tu;
+
+               inputChanged(fInput, information);
+       }
+
+       /*
+        * @see org.eclipse.jdt.internal.ui.text.AbstractInformationControl#fillViewMenu(org.eclipse.jface.action.IMenuManager)
+        */
+       @Override
+       protected void fillViewMenu(IMenuManager viewMenu) {
+               super.fillViewMenu(viewMenu);
+
+               viewMenu.add(new Separator("Sorters")); //$NON-NLS-1$
+               viewMenu.add(fSortingAction);
+
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPairMatcher.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPairMatcher.java
new file mode 100644 (file)
index 0000000..97fea7f
--- /dev/null
@@ -0,0 +1,238 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.text.source.DefaultCharacterPairMatcher;
+import org.eclipse.jface.text.source.ICharacterPairMatcher;
+
+import org.eclipse.cdt.core.dom.ILinkage;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+/**
+ * Helper class to match pairs of characters.
+ */
+public class CPairMatcher extends DefaultCharacterPairMatcher {
+
+       private static final int ANGLE_BRACKETS_SEARCH_BOUND = 200;
+       
+       private boolean fMatchAngularBrackets= true;
+       private int fAnchor= -1;
+
+       public CPairMatcher(char[] pairs) {
+               super(pairs, ICPartitions.C_PARTITIONING);
+       }
+
+       /* @see ICharacterPairMatcher#match(IDocument, int) */
+       @Override
+       public IRegion match(IDocument document, int offset) {
+               try {
+                       return performMatch(document, offset);
+               } catch (BadLocationException ble) {
+                       return null;
+               }
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.source.DefaultCharacterPairMatcher#getAnchor()
+        */
+       @Override
+       public int getAnchor() {
+               if (fAnchor < 0) {
+                       return super.getAnchor();
+               }
+               return fAnchor;
+       }
+
+       /*
+        * Performs the actual work of matching for #match(IDocument, int).
+        */ 
+       private IRegion performMatch(IDocument document, int offset) throws BadLocationException {
+               if (offset < 0 || document == null) return null;
+               final char prevChar= document.getChar(Math.max(offset - 1, 0));
+               if ((prevChar == '<' || prevChar == '>') && !fMatchAngularBrackets)
+                       return null;
+               final IRegion region;
+               if (prevChar == '<') {
+                       region= findClosingAngleBracket(document, offset - 1);
+                       fAnchor= ICharacterPairMatcher.LEFT;
+               } else if (prevChar == '>') {
+                       region= findOpeningAngleBracket(document, offset - 1);
+                       fAnchor= ICharacterPairMatcher.RIGHT;
+               } else {
+                       region= super.match(document, offset);
+                       fAnchor= -1;
+               }
+               if (region != null) {
+                       if (prevChar == '>') {
+                               final int peer= region.getOffset();
+                               if (isLessThanOperator(document, peer))
+                                       return null;
+                       } else if (prevChar == '<') {
+                               final int peer= region.getOffset() + region.getLength() - 1;
+                               if (isGreaterThanOperator(document, peer))
+                                       return null;
+                       }
+               }
+               return region;
+       }
+
+       /**
+        * Returns the region enclosing the matching angle brackets.
+        * 
+        * @param document a document
+        * @param offset an offset within the document pointing after the closing angle bracket
+        * @return the matching region or {@link NullPointerException} if no match could be found
+        * @throws BadLocationException 
+        */
+       private IRegion findOpeningAngleBracket(IDocument document, int offset) throws BadLocationException {
+               if (offset < 0) return null;
+               final String contentType= TextUtilities.getContentType(document, ICPartitions.C_PARTITIONING, offset, false);
+               CHeuristicScanner scanner= new CHeuristicScanner(document, ICPartitions.C_PARTITIONING, contentType);
+               if (isTemplateParameterCloseBracket(offset, document, scanner)) {
+                       int pos= scanner.findOpeningPeer(offset - 1, Math.max(0, offset - ANGLE_BRACKETS_SEARCH_BOUND), '<', '>');
+                       if (pos != CHeuristicScanner.NOT_FOUND) {
+                               return new Region(pos, offset - pos + 1);
+                       }
+               }
+               return null;
+       }
+
+       /**
+        * Returns the region enclosing the matching angle brackets.
+        * 
+        * @param document a document
+        * @param offset an offset within the document pointing after the opening angle bracket
+        * @return the matching region or {@link NullPointerException} if no match could be found
+        * @throws BadLocationException 
+        */
+       private IRegion findClosingAngleBracket(IDocument document, int offset) throws BadLocationException {
+               if (offset < 0) return null;
+               final String contentType= TextUtilities.getContentType(document, ICPartitions.C_PARTITIONING, offset, false);
+               CHeuristicScanner scanner= new CHeuristicScanner(document, ICPartitions.C_PARTITIONING, contentType);
+               if (isTemplateParameterOpenBracket(offset, document, scanner)) {
+                       int pos= scanner.findClosingPeer(offset + 1, Math.min(document.getLength(), offset + ANGLE_BRACKETS_SEARCH_BOUND), '<', '>');
+                       if (pos != CHeuristicScanner.NOT_FOUND) {
+                               return new Region(offset, pos - offset + 1);
+                       }
+               }
+               return null;
+       }
+
+       /**
+        * Returns true if the character at the specified offset is a
+        * less-than sign, rather than an template parameter list open
+        * angle bracket.
+        * 
+        * @param document a document
+        * @param offset an offset within the document
+        * @return true if the character at the specified offset is not
+        *   a template parameter start bracket
+        * @throws BadLocationException
+        */
+       private boolean isLessThanOperator(IDocument document, int offset) throws BadLocationException {
+               if (offset < 0) return false;
+               final String contentType= TextUtilities.getContentType(document, ICPartitions.C_PARTITIONING, offset, false);
+               CHeuristicScanner scanner= new CHeuristicScanner(document, ICPartitions.C_PARTITIONING, contentType);
+               return !isTemplateParameterOpenBracket(offset, document, scanner);
+       }
+
+       /**
+        * Returns true if the character at the specified offset is a
+        * greater-than sign, rather than an template parameter list close
+        * angle bracket.
+        * 
+        * @param document a document
+        * @param offset an offset within the document
+        * @return true if the character at the specified offset is not
+        *   a template parameter end bracket
+        * @throws BadLocationException
+        */
+       private boolean isGreaterThanOperator(IDocument document, int offset) throws BadLocationException {
+               if (offset < 0) return false;
+               final String contentType= TextUtilities.getContentType(document, ICPartitions.C_PARTITIONING, offset, false);
+               CHeuristicScanner scanner= new CHeuristicScanner(document, ICPartitions.C_PARTITIONING, contentType);
+               return !isTemplateParameterCloseBracket(offset, document, scanner);
+       }
+
+       /**
+        * Checks if the angular bracket at <code>offset</code> is a template
+        * parameter bracket.
+        *
+        * @param offset the offset of the opening bracket
+        * @param document the document
+        * @param scanner a heuristic scanner on <code>document</code>
+        * @return <code>true</code> if the bracket is part of a template parameter,
+        *         <code>false</code> otherwise
+        */
+       private boolean isTemplateParameterOpenBracket(int offset, IDocument document, CHeuristicScanner scanner) {
+               int nextToken = scanner.nextToken(offset + 1, Math.min(document.getLength(), offset + ANGLE_BRACKETS_SEARCH_BOUND));
+               if (nextToken == Symbols.TokenSHIFTLEFT || nextToken == Symbols.TokenLESSTHAN)
+                       return false;
+               int prevToken= scanner.previousToken(offset - 1, Math.max(0, offset - ANGLE_BRACKETS_SEARCH_BOUND));
+               if (prevToken == Symbols.TokenIDENT || prevToken == Symbols.TokenTEMPLATE) {
+                       return true;
+               }
+
+               return false;
+       }
+
+       /**
+        * Checks if the angular bracket at <code>offset</code> is a template
+        * parameter bracket.
+        *
+        * @param offset the offset of the closing bracket
+        * @param document the document
+        * @param scanner a heuristic scanner on <code>document</code>
+        * @return <code>true</code> if the bracket is part of a template parameter,
+        *         <code>false</code> otherwise
+        */
+       private boolean isTemplateParameterCloseBracket(int offset, IDocument document, CHeuristicScanner scanner) {
+               if (offset >= document.getLength() - 1)
+                       return true;
+               int thisToken= scanner.previousToken(offset, Math.max(0, offset - ANGLE_BRACKETS_SEARCH_BOUND));
+               if (thisToken == Symbols.TokenSHIFTRIGHT)
+                       return true;
+               if (thisToken != Symbols.TokenGREATERTHAN)
+                       return false;
+               int prevToken= scanner.previousToken(scanner.getPosition(), Math.max(0, offset - ANGLE_BRACKETS_SEARCH_BOUND));
+               if (prevToken == Symbols.TokenGREATERTHAN)
+                       return true;
+               int nextToken= scanner.nextToken(offset + 1, Math.min(document.getLength(), offset + ANGLE_BRACKETS_SEARCH_BOUND));
+
+               switch (nextToken) {
+               case Symbols.TokenGREATERTHAN:
+               case Symbols.TokenCOMMA:
+               case Symbols.TokenSEMICOLON:
+               case Symbols.TokenCLASS:
+               case Symbols.TokenSTRUCT:
+               case Symbols.TokenUNION:
+                       return true;
+               }
+               return false;
+       }
+
+       /**
+        * Configure this bracket matcher for the given language.
+        * @param language
+        */
+       public void configure(ILanguage language) {
+               fMatchAngularBrackets= language != null && language.getLinkageID() == ILinkage.CPP_LINKAGE_ID;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CParameterListValidator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CParameterListValidator.java
new file mode 100644 (file)
index 0000000..31b76dc
--- /dev/null
@@ -0,0 +1,263 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyleRange;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.TextPresentation;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.contentassist.IContextInformationPresenter;
+import org.eclipse.jface.text.contentassist.IContextInformationValidator;
+
+/**
+ * This class provides the function parameter parsing for the C/C++ Editor hover
+ * It is based heavily on the Java class JavaParameterListValidator
+ * 
+ * @author thomasf
+ *
+ */
+public class CParameterListValidator implements IContextInformationValidator, IContextInformationPresenter {
+       private int fPosition;
+       private ITextViewer fViewer;
+       private IContextInformation fInformation;
+       
+       private int fCurrentParameter;
+       
+       public CParameterListValidator() {
+       }
+       
+       /**
+        * @see IContextInformationValidator#install(IContextInformation, ITextViewer, int)
+        * @see IContextInformationPresenter#install(IContextInformation, ITextViewer, int)
+        */
+       public void install(IContextInformation info, ITextViewer viewer, int documentPosition) {
+               
+               fPosition= documentPosition;
+               fViewer= viewer;
+               fInformation= info;
+               
+               fCurrentParameter= -1;
+       }
+       
+       private int getCommentEnd(IDocument d, int pos, int end) throws BadLocationException {
+               while (pos < end) {
+                       char curr= d.getChar(pos);
+                       pos++;
+                       if (curr == '*') {
+                               if (pos < end && d.getChar(pos) == '/') {
+                                       return pos + 1;
+                               }
+                       }
+               }
+               return end;
+       }
+
+       private int getStringEnd(IDocument d, int pos, int end, char ch) throws BadLocationException {
+               while (pos < end) {
+                       char curr= d.getChar(pos);
+                       pos++;
+                       if (curr == '\\') {
+                               // ignore escaped characters
+                               pos++;
+                       } else if (curr == ch) {
+                               return pos;
+                       }
+               }
+               return end;
+       }
+       
+       private int getCharCount(IDocument document, int start, int end, 
+                                                        char increment, char decrement, boolean considerNesting) throws BadLocationException {
+               
+               Assert.isTrue((increment != 0 || decrement != 0) && increment != decrement);
+               
+               int nestingLevel = 0;
+               int charCount = 0;
+               while (start < end) {
+                       char curr = document.getChar(start++);
+                       switch (curr) {
+                               case '/':
+                                       if (start < end) {
+                                               char next= document.getChar(start);
+                                               if (next == '*') {
+                                                       // a comment starts, advance to the comment end
+                                                       start= getCommentEnd(document, start + 1, end);
+                                               } else if (next == '/') {
+                                                       // '//'-comment: nothing to do anymore on this line 
+                                                       start= end;
+                                               }
+                                       }
+                                       break;
+                               case '*':
+                                       if (start < end) {
+                                               char next= document.getChar(start);
+                                               if (next == '/') {
+                                                       // we have been in a comment: forget what we read before
+                                                       charCount= 0;
+                                                       ++ start;
+                                               }
+                                       }
+                                       break;
+                               case '"':
+                               case '\'':
+                                       start= getStringEnd(document, start, end, curr);
+                                       break;
+                               default:
+                                       
+                                       if (considerNesting) {
+                                               
+                                               if ('(' == curr)
+                                                       ++ nestingLevel;
+                                               else if (')' == curr)
+                                                       -- nestingLevel;
+                                                       
+                                               if (nestingLevel != 0)
+                                                       break;
+                                       }
+                                       
+                                       if (increment != 0) {
+                                               if (curr == increment)
+                                                       ++ charCount;
+                                       }
+                                       
+                                       if (decrement != 0) {
+                                               if (curr == decrement)
+                                                       -- charCount;
+                                       }
+                       }
+               }
+               
+               return charCount;
+       }
+       
+       /**
+        * @see IContextInformationValidator#isContextInformationValid(int)
+        */
+       public boolean isContextInformationValid(int position) {                
+               
+               try {
+                       if (position < fPosition)
+                               return false;
+                               
+                       IDocument document= fViewer.getDocument();
+                               
+                       return (getCharCount(document, fPosition, position, '(', ')', false) >= 0);
+                       
+               } catch (BadLocationException x) {
+                       return false;
+               }
+       }
+       
+       /**
+        * @see IContextInformationPresenter#updatePresentation(int, TextPresentation)
+        */
+       public boolean updatePresentation(int position, TextPresentation presentation) {
+
+               int currentParameter= -1;
+               
+               try {
+                       currentParameter= getCharCount(fViewer.getDocument(), fPosition, position, ',', (char) 0, true);
+               } catch (BadLocationException x) {
+                       return false;
+               }
+               
+               if (fCurrentParameter != -1) {
+                       if (currentParameter == fCurrentParameter)
+                               return false;
+               }
+               
+               presentation.clear();
+               fCurrentParameter= currentParameter;
+               
+               //Don't presume what has been done to the string, rather use as is
+               String s= fInformation.getInformationDisplayString();
+               
+               int[] commas= computeCommaPositions(s);
+               if (commas.length - 2 < fCurrentParameter) {
+                       presentation.addStyleRange(new StyleRange(0, s.length(), null, null, SWT.NORMAL));
+                       return true;
+               }
+               
+               int start= commas[fCurrentParameter] + 1;
+               int end= commas[fCurrentParameter + 1];
+               if (start > 0)
+                       presentation.addStyleRange(new StyleRange(0, start, null, null, SWT.NORMAL));
+
+               if (end > start)
+                       presentation.addStyleRange(new StyleRange(start, end - start, null, null, SWT.BOLD));
+
+               if (end < s.length())
+                       presentation.addStyleRange(new StyleRange(end, s.length() - end, null, null, SWT.NORMAL));
+
+               return true;
+       }
+
+       private int[] computeCommaPositions(String code) {
+               final int length= code.length();
+           int pos= 0;
+               List<Integer> positions= new ArrayList<Integer>();
+               positions.add(new Integer(-1));
+               while (pos < length && pos != -1) {
+                       char ch= code.charAt(pos);
+                       switch (ch) {
+                   case ',':
+                           positions.add(new Integer(pos));
+                           break;
+                   case '(':
+                       pos= indexOfClosingPeer(code, '(', ')', pos);
+                       break;
+                   case '<':
+                       pos= indexOfClosingPeer(code, '<', '>', pos);
+                       break;
+                   case '[':
+                       pos= indexOfClosingPeer(code, '[', ']', pos);
+                       break;
+                   default:
+                       break;
+            }
+                       if (pos != -1)
+                               pos++;
+               }
+               positions.add(new Integer(length));
+               
+               int[] fields= new int[positions.size()];
+               for (int i= 0; i < fields.length; i++)
+               fields[i]= positions.get(i).intValue();
+           return fields;
+    }
+
+       private int indexOfClosingPeer(String code, char left, char right, int pos) {
+               int level= 0;
+               final int length= code.length();
+               while (pos < length) {
+                       char ch= code.charAt(pos);
+                       if (ch == left) {
+                               ++level;
+                       } else if (ch == right) {
+                               if (--level == 0) {
+                                       return pos;
+                               }
+                       }
+                       ++pos;
+               }
+               return -1;
+       }
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPreprocessorScanner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPreprocessorScanner.java
new file mode 100644 (file)
index 0000000..9df4664
--- /dev/null
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *     Andrew Ferguson (Symbian)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.text.rules.IRule;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.PatternRule;
+import org.eclipse.jface.text.rules.WordRule;
+
+import org.eclipse.cdt.core.model.ICLanguageKeywords;
+import org.eclipse.cdt.ui.text.AbstractCScanner;
+import org.eclipse.cdt.ui.text.ICColorConstants;
+import org.eclipse.cdt.ui.text.ITokenStoreFactory;
+
+import org.eclipse.cdt.internal.ui.text.util.CWordDetector;
+
+/**
+ * A scanner for preprocessor directives.
+ *
+ * @since 4.0
+ */
+public class CPreprocessorScanner extends AbstractCScanner {
+
+    /** Properties for tokens. */
+       private static String[] fgTokenProperties= {
+               ICColorConstants.C_KEYWORD,
+               ICColorConstants.PP_DIRECTIVE,
+               ICColorConstants.PP_DEFAULT,
+               ICColorConstants.C_TYPE,
+               ICColorConstants.C_STRING,
+        ICColorConstants.PP_HEADER
+       };
+       private ICLanguageKeywords fKeywords;
+       
+       /**
+        * Creates a C/C++ preprocessor scanner.
+     * @param keywords  the keywords defined by the language dialect
+        */
+       public CPreprocessorScanner(ITokenStoreFactory factory, ICLanguageKeywords keywords) {
+               super(factory.createTokenStore(fgTokenProperties));
+               fKeywords= keywords;
+               setRules(createRules());
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.AbstractCScanner#createRules()
+        */
+       protected List<IRule> createRules() {
+               IToken defaultToken= getToken(ICColorConstants.PP_DEFAULT);
+
+               List<IRule> rules= new ArrayList<IRule>();              
+               IToken token;
+               
+               // Add generic white space rule.
+               rules.add(new CWhitespaceRule(defaultToken));
+               
+               token= getToken(ICColorConstants.PP_DIRECTIVE);
+               PreprocessorRule preprocessorRule = new PreprocessorRule(new CWordDetector(), defaultToken);
+               String[] ppKeywords= fKeywords.getPreprocessorKeywords();
+               for (int i = 0; i < ppKeywords.length; i++) {
+                       preprocessorRule.addWord(ppKeywords[i], token);
+               }
+
+               // add ## operator
+               preprocessorRule.addWord("##", token); //$NON-NLS-1$
+               rules.add(preprocessorRule);
+
+               // Add word rule for keywords, types, and constants.
+               WordRule wordRule= new WordRule(new CWordDetector(), defaultToken);
+               
+               token= getToken(ICColorConstants.C_KEYWORD);
+               String[] keywords= fKeywords.getKeywords();
+               for (int i = 0; i < keywords.length; i++) {
+                       wordRule.addWord(keywords[i], token);
+               }
+        token= getToken(ICColorConstants.C_TYPE);
+               String[] types= fKeywords.getBuiltinTypes();
+               for (int i = 0; i < types.length; i++) {
+                       wordRule.addWord(types[i], token);
+               }
+        rules.add(wordRule);
+               
+        token = getToken(ICColorConstants.PP_HEADER);
+        CHeaderRule headerRule = new CHeaderRule(token);
+        rules.add(headerRule);
+
+        token = getToken(ICColorConstants.C_STRING);
+        IRule stringRule = new PatternRule("\"", "\"", token, '\\', true, true, true); //$NON-NLS-1$ //$NON-NLS-2$
+        rules.add(stringRule);
+
+        token = getToken(ICColorConstants.C_STRING);
+        IRule charRule = new PatternRule("'", "'", token, '\\', true, true, true); //$NON-NLS-1$ //$NON-NLS-2$
+        rules.add(charRule);
+
+        setDefaultReturnToken(defaultToken);
+               return rules;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPresentationReconciler.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CPresentationReconciler.java
new file mode 100644 (file)
index 0000000..ab8c580
--- /dev/null
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems) - Adapted for CDT
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.TextPresentation;
+import org.eclipse.jface.text.presentation.PresentationReconciler;
+
+
+/**
+ * Presentation reconciler, adding functionality for operation without a viewer.
+ * Cloned from JDT.
+ * 
+ * @since 4.0
+ */
+public class CPresentationReconciler extends PresentationReconciler {
+
+       /** Last used document */
+       private IDocument fLastDocument;
+
+       /**
+        * Constructs a "repair description" for the given damage and returns
+        * this description as a text presentation.
+        * <p>
+        * NOTE: Should not be used if this reconciler is installed on a viewer.
+        * </p>
+        *
+        * @param damage the damage to be repaired
+        * @param document the document whose presentation must be repaired
+        * @return the presentation repair description as text presentation
+        */
+       public TextPresentation createRepairDescription(IRegion damage, IDocument document) {
+               if (document != fLastDocument) {
+                       setDocumentToDamagers(document);
+                       setDocumentToRepairers(document);
+                       fLastDocument= document;
+               }
+               return createPresentation(damage, document);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconciler.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconciler.java
new file mode 100644 (file)
index 0000000..f921d4d
--- /dev/null
@@ -0,0 +1,501 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2011 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.reconciler.DirtyRegion;
+import org.eclipse.jface.text.reconciler.MonoReconciler;
+import org.eclipse.swt.events.ShellAdapter;
+import org.eclipse.swt.events.ShellEvent;
+import org.eclipse.swt.events.ShellListener;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPartListener2;
+import org.eclipse.ui.IWorkbenchPartReference;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.index.IIndexChangeEvent;
+import org.eclipse.cdt.core.index.IIndexChangeListener;
+import org.eclipse.cdt.core.index.IIndexerStateEvent;
+import org.eclipse.cdt.core.index.IIndexerStateListener;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ElementChangedEvent;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICElementDelta;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IElementChangedListener;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.IWorkingCopyManager;
+
+/**
+ * A single strategy C reconciler.
+ * 
+ * @since 4.0
+ */
+public class CReconciler extends MonoReconciler {
+
+       static class SingletonJob extends Job implements ISchedulingRule {
+               private Runnable fCode;
+
+               SingletonJob(String name, Runnable code) {
+                       super(name);
+                       fCode= code;
+                       setPriority(Job.SHORT);
+                       setRule(this);
+                       setUser(false);
+                       setSystem(true);
+               }
+
+               /*
+                * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
+                */
+               @Override
+               protected IStatus run(IProgressMonitor monitor) {
+                       if (!monitor.isCanceled()) {
+                               fCode.run();
+                       }
+                       return Status.OK_STATUS;
+               }
+
+               /*
+                * @see org.eclipse.core.runtime.jobs.ISchedulingRule#contains(org.eclipse.core.runtime.jobs.ISchedulingRule)
+                */
+               public boolean contains(ISchedulingRule rule) {
+                       return rule == this;
+               }
+
+               /*
+                * @see org.eclipse.core.runtime.jobs.ISchedulingRule#isConflicting(org.eclipse.core.runtime.jobs.ISchedulingRule)
+                */
+               public boolean isConflicting(ISchedulingRule rule) {
+                       return rule == this;
+               }
+               
+       }
+
+       /**
+        * Internal part listener for activating the reconciler.
+        */
+       private class PartListener implements IPartListener2 {
+               /*
+                * @see org.eclipse.ui.IPartListener2#partActivated(org.eclipse.ui.IWorkbenchPartReference)
+                */
+               public void partActivated(IWorkbenchPartReference partRef) {
+               }
+               /*
+                * @see org.eclipse.ui.IPartListener2#partBroughtToTop(org.eclipse.ui.IWorkbenchPartReference)
+                */
+               public void partBroughtToTop(IWorkbenchPartReference partRef) {
+               }
+               /*
+                * @see org.eclipse.ui.IPartListener2#partClosed(org.eclipse.ui.IWorkbenchPartReference)
+                */
+               public void partClosed(IWorkbenchPartReference partRef) {
+               }
+               /*
+                * @see org.eclipse.ui.IPartListener2#partDeactivated(org.eclipse.ui.IWorkbenchPartReference)
+                */
+               public void partDeactivated(IWorkbenchPartReference partRef) {
+               }
+               /*
+                * @see org.eclipse.ui.IPartListener2#partHidden(org.eclipse.ui.IWorkbenchPartReference)
+                */
+               public void partHidden(IWorkbenchPartReference partRef) {
+                       if (partRef.getPart(false) == fTextEditor) {
+                               setEditorActive(false);
+                       }
+               }
+               /*
+                * @see org.eclipse.ui.IPartListener2#partInputChanged(org.eclipse.ui.IWorkbenchPartReference)
+                */
+               public void partInputChanged(IWorkbenchPartReference partRef) {
+               }
+               /*
+                * @see org.eclipse.ui.IPartListener2#partOpened(org.eclipse.ui.IWorkbenchPartReference)
+                */
+               public void partOpened(IWorkbenchPartReference partRef) {
+               }
+               /*
+                * @see org.eclipse.ui.IPartListener2#partVisible(org.eclipse.ui.IWorkbenchPartReference)
+                */
+               public void partVisible(IWorkbenchPartReference partRef) {
+                       if (partRef.getPart(false) == fTextEditor) {
+                               CReconciler.this.scheduleReconciling();
+                               setEditorActive(true);
+                       }
+               }
+       }
+
+       /**
+        * Internal Shell activation listener for activating the reconciler.
+        */
+       private class ActivationListener extends ShellAdapter {
+
+               private Control fControl;
+
+               public ActivationListener(Control control) {
+                       Assert.isNotNull(control);
+                       fControl= control;
+               }
+
+               /*
+                * @see org.eclipse.swt.events.ShellListener#shellActivated(org.eclipse.swt.events.ShellEvent)
+                */
+               @Override
+               public void shellActivated(ShellEvent e) {
+                       if (!fControl.isDisposed() && fControl.isVisible()) {
+                               if (hasCModelChanged())
+                                       CReconciler.this.scheduleReconciling();
+                               setEditorActive(true);
+                       }
+               }
+
+               /*
+                * @see org.eclipse.swt.events.ShellListener#shellDeactivated(org.eclipse.swt.events.ShellEvent)
+                */
+               @Override
+               public void shellDeactivated(ShellEvent e) {
+                       if (!fControl.isDisposed() && fControl.getShell() == e.getSource()) {
+                               setEditorActive(false);
+                       }
+               }
+       }
+
+       /**
+        * Internal C element changed listener
+        */
+       private class ElementChangedListener implements IElementChangedListener {
+               /*
+                * @see org.eclipse.cdt.core.model.IElementChangedListener#elementChanged(org.eclipse.cdt.core.model.ElementChangedEvent)
+                */
+               public void elementChanged(ElementChangedEvent event) {
+                       if (event.getType() == ElementChangedEvent.POST_CHANGE) {
+                               if (isRelevantDelta(event.getDelta())) {
+                                       if (!fIsReconciling && isEditorActive() && fInitialProcessDone) {
+                                               CReconciler.this.scheduleReconciling();
+                                       } else {
+                                               setCModelChanged(true);
+                                       }
+                               }
+                       }
+               }
+
+               private boolean isRelevantDelta(ICElementDelta delta) {
+                       final int flags = delta.getFlags();
+                       if ((flags & ICElementDelta.F_CONTENT) != 0) {
+                               if (!fIsReconciling && isRelevantElement(delta.getElement())) {
+                                       // mark model changed, but don't update immediately
+                                       fIndexerListener.ignoreChanges(false);
+                                       setCModelChanged(true);
+                               } else if (delta.getElement() instanceof ITranslationUnit) {
+                                       fIndexerListener.ignoreChanges(true);
+                               }
+                       }
+                       if ((flags & (
+                                       ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE | 
+                                       ICElementDelta.F_CHANGED_PATHENTRY_MACRO
+                                       )) != 0) {
+                               if (isRelevantProject(delta.getElement().getCProject())) {
+                                       return true;
+                               }
+                       }
+                       if ((flags & ICElementDelta.F_CHILDREN) != 0) {
+                               ICElementDelta[] childDeltas= delta.getChangedChildren();
+                               for (int i = 0; i < childDeltas.length; i++) {
+                                       if (isRelevantDelta(childDeltas[i])) {
+                                               return true;
+                                       }
+                               }
+                       }
+                       return false;
+               }
+       }
+
+       private class IndexerListener implements IIndexerStateListener, IIndexChangeListener {
+               private boolean fIndexChanged;
+               private boolean fIgnoreChanges;
+
+               /*
+                * @see org.eclipse.cdt.core.index.IIndexerStateListener#indexChanged(org.eclipse.cdt.core.index.IIndexerStateEvent)
+                */
+               public void indexChanged(IIndexerStateEvent event) {
+                       if (event.indexerIsIdle()) {
+                               if (fIndexChanged || hasCModelChanged()) {
+                                       fIndexChanged= false;
+                                       if (!fIsReconciling && isEditorActive() && fInitialProcessDone) {
+                                               CReconciler.this.scheduleReconciling();
+                                       } else {
+                                               setCModelChanged(true);
+                                       }
+                               }
+                               fIgnoreChanges= false;
+                       }
+               }
+
+               public void ignoreChanges(boolean ignore) {
+                       fIgnoreChanges= ignore;
+               }
+
+               /*
+                * @see org.eclipse.cdt.core.index.IIndexChangeListener#indexChanged(org.eclipse.cdt.core.index.IIndexChangeEvent)
+                */
+               public void indexChanged(IIndexChangeEvent event) {
+                       if (!fIndexChanged && isRelevantProject(event.getAffectedProject())) {
+                               if (!fIgnoreChanges || event.isCleared() || event.isReloaded() || event.hasNewFile()) {
+                                       fIndexChanged= true;
+                               }
+                       }
+               }
+               
+       }
+
+       /** The reconciler's editor */
+       private ITextEditor fTextEditor;
+       /** The part listener */
+       private IPartListener2 fPartListener;
+       /** The shell listener */
+       private ShellListener fActivationListener;
+       /** The C element changed listener.  */
+       private IElementChangedListener fCElementChangedListener;
+       /** The indexer listener */
+       private IndexerListener fIndexerListener; 
+       /** Tells whether the C model might have changed. */
+       private volatile boolean fHasCModelChanged= false;
+       /** Tells whether this reconciler's editor is active. */
+       private volatile boolean fIsEditorActive= true;
+       /** Tells whether a reconcile is in progress. */
+       private volatile boolean fIsReconciling= false;
+       
+       private boolean fInitialProcessDone= false;
+       private Job fTriggerReconcilerJob;
+
+       /**
+        * Create a reconciler for the given editor and strategy.
+        * 
+        * @param editor the text editor
+        * @param strategy  the C reconciling strategy
+        */
+       public CReconciler(ITextEditor editor, CCompositeReconcilingStrategy strategy) {
+               super(strategy, false);
+               fTextEditor= editor;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.reconciler.IReconciler#install(org.eclipse.jface.text.ITextViewer)
+        */
+       @Override
+       public void install(ITextViewer textViewer) {
+               super.install(textViewer);
+               
+               fPartListener= new PartListener();
+               IWorkbenchPartSite site= fTextEditor.getSite();
+               IWorkbenchWindow window= site.getWorkbenchWindow();
+               window.getPartService().addPartListener(fPartListener);
+
+               fActivationListener= new ActivationListener(textViewer.getTextWidget());
+               Shell shell= window.getShell();
+               shell.addShellListener(fActivationListener);
+
+               fCElementChangedListener= new ElementChangedListener();
+               CoreModel.getDefault().addElementChangedListener(fCElementChangedListener);
+               
+               fIndexerListener= new IndexerListener();
+               CCorePlugin.getIndexManager().addIndexerStateListener(fIndexerListener);
+               CCorePlugin.getIndexManager().addIndexChangeListener(fIndexerListener);
+               
+               fTriggerReconcilerJob= new SingletonJob("Trigger Reconciler", new Runnable() { //$NON-NLS-1$
+                       public void run() {
+                               forceReconciling();
+                       }});
+       }
+
+       /*
+        * @see org.eclipse.jface.text.reconciler.IReconciler#uninstall()
+        */
+       @Override
+       public void uninstall() {
+               fTriggerReconcilerJob.cancel();
+               
+               IWorkbenchPartSite site= fTextEditor.getSite();
+               IWorkbenchWindow window= site.getWorkbenchWindow();
+               window.getPartService().removePartListener(fPartListener);
+               fPartListener= null;
+
+               Shell shell= window.getShell();
+               if (shell != null && !shell.isDisposed())
+                       shell.removeShellListener(fActivationListener);
+               fActivationListener= null;
+
+               CoreModel.getDefault().removeElementChangedListener(fCElementChangedListener);
+               fCElementChangedListener= null;
+
+               CCorePlugin.getIndexManager().removeIndexerStateListener(fIndexerListener);
+               CCorePlugin.getIndexManager().removeIndexChangeListener(fIndexerListener);
+               fIndexerListener= null;
+               super.uninstall();
+       }
+
+       protected void scheduleReconciling() {
+               if (!fInitialProcessDone)
+                       return;
+               if (fTriggerReconcilerJob.cancel()) {
+                       fTriggerReconcilerJob.schedule(50);
+               }
+       }
+
+       /*
+        * @see org.eclipse.jface.text.reconciler.AbstractReconciler#forceReconciling()
+        */
+       @Override
+       protected void forceReconciling() {
+               if (!fInitialProcessDone)
+                       return;
+               super.forceReconciling();
+       }
+
+       /*
+        * @see org.eclipse.jface.text.reconciler.AbstractReconciler#aboutToBeReconciled()
+        */
+       @Override
+       protected void aboutToBeReconciled() {
+               CCompositeReconcilingStrategy strategy= (CCompositeReconcilingStrategy)getReconcilingStrategy(IDocument.DEFAULT_CONTENT_TYPE);
+               strategy.aboutToBeReconciled();
+       }
+
+       /*
+        * @see org.eclipse.jface.text.reconciler.MonoReconciler#initialProcess()
+        */
+       @Override
+       protected void initialProcess() {
+               super.initialProcess();
+               fInitialProcessDone= true;
+               if (!fIsReconciling && isEditorActive() && hasCModelChanged()) {
+                       CReconciler.this.scheduleReconciling();
+               } 
+       }
+
+       /*
+        * @see org.eclipse.jface.text.reconciler.MonoReconciler#process(org.eclipse.jface.text.reconciler.DirtyRegion)
+        */
+       @Override
+       protected void process(DirtyRegion dirtyRegion) {
+               fIsReconciling= true;
+               setCModelChanged(false);
+               super.process(dirtyRegion);
+               fIsReconciling= false;
+       }
+
+       /**
+        * Tells whether the C Model has changed or not.
+        *
+        * @return <code>true</code> iff the C Model has changed
+        */
+       private synchronized boolean hasCModelChanged() {
+               return fHasCModelChanged;
+       }
+
+       /**
+        * Sets whether the C Model has changed or not.
+        *
+        * @param state <code>true</code> iff the C model has changed
+        */
+       private synchronized void setCModelChanged(boolean state) {
+               fHasCModelChanged= state;
+       }
+       
+       /**
+        * Tells whether this reconciler's editor is active.
+        *
+        * @return <code>true</code> iff the editor is active
+        */
+       private synchronized boolean isEditorActive() {
+               return fIsEditorActive;
+       }
+
+       /**
+        * Sets whether this reconciler's editor is active.
+        *
+        * @param state <code>true</code> iff the editor is active
+        */
+       private synchronized void setEditorActive(boolean active) {
+               fIsEditorActive= active;
+               if (!active) {
+                       fTriggerReconcilerJob.cancel();
+               }
+       }
+
+       public boolean isRelevantElement(ICElement element) {
+               if (!fInitialProcessDone) {
+                       return false;
+               }
+               if (element instanceof IWorkingCopy) {
+                       return false;
+               }
+               if (element instanceof ITranslationUnit) {
+                       IEditorInput input= fTextEditor.getEditorInput();
+                       IWorkingCopyManager manager= CUIPlugin.getDefault().getWorkingCopyManager();                            
+                       IWorkingCopy copy= manager.getWorkingCopy(input);
+                       if (copy == null || copy.getOriginalElement().equals(element)) {
+                               return false;
+                       }
+                       return isRelevantProject(copy.getCProject());
+               }
+               return false;
+       }
+
+
+       private boolean isRelevantProject(ICProject affectedProject) {
+               if (affectedProject == null) {
+                       return false;
+               }
+               IEditorInput input= fTextEditor.getEditorInput();
+               IWorkingCopyManager manager= CUIPlugin.getDefault().getWorkingCopyManager();                            
+               IWorkingCopy copy= manager.getWorkingCopy(input);
+               if (copy == null) {
+                       return false;
+               }
+               if (copy.getCProject().equals(affectedProject)) {
+                       return true;
+               }
+               IProject project= copy.getCProject().getProject();
+               if (project == null) {
+                       return false;
+               }
+               try {
+                       IProject[] referencedProjects= project.getReferencedProjects();
+                       for (int i= 0; i < referencedProjects.length; i++) {
+                               project= referencedProjects[i];
+                               if (project.equals(affectedProject.getProject())) {
+                                       return true;
+                               }
+                       }
+               } catch (CoreException exc) {
+               }
+               return false;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconcilingStrategy.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CReconcilingStrategy.java
new file mode 100644 (file)
index 0000000..4cf9d23
--- /dev/null
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.reconciler.DirtyRegion;
+import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
+import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.IWorkingCopyManager;
+
+import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit;
+
+
+public class CReconcilingStrategy implements IReconcilingStrategy, IReconcilingStrategyExtension {
+
+       private ITextEditor fEditor;
+       private IWorkingCopyManager fManager;
+       private IProgressMonitor fProgressMonitor;
+       // used by tests
+       protected boolean fInitialProcessDone;
+       
+       public CReconcilingStrategy(ITextEditor editor) {
+               fEditor= editor;
+               fManager= CUIPlugin.getDefault().getWorkingCopyManager();
+       }
+
+       /*
+        * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument)
+        */
+       public void setDocument(IDocument document) {
+       }
+
+       /*
+        * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion)
+        */
+       public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
+               // only called for incremental reconciler
+       }
+
+       /*
+        * @see IReconcilingStrategyExtension#setProgressMonitor(IProgressMonitor)
+        */
+       public void setProgressMonitor(IProgressMonitor monitor) {
+               fProgressMonitor= monitor;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion)
+        */
+       public void reconcile(IRegion region) {
+               reconcile(false);
+       }
+
+       private void reconcile(final boolean initialReconcile) {
+               boolean computeAST= fEditor instanceof ICReconcilingListener;
+               IASTTranslationUnit ast= null;
+               IWorkingCopy workingCopy= fManager.getWorkingCopy(fEditor.getEditorInput());
+               if (workingCopy == null) {
+                       return;
+               }
+               boolean forced= false;
+               try {
+                       // reconcile
+                       synchronized (workingCopy) {
+                               forced= workingCopy.isConsistent();
+                               ast= workingCopy.reconcile(computeAST, true, fProgressMonitor);
+                       }
+               } catch (OperationCanceledException oce) {
+                       // document was modified while parsing
+               } catch (CModelException e) {
+                       IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK, "Error in CDT UI during reconcile", e);  //$NON-NLS-1$
+                       CUIPlugin.log(status);
+               } finally {
+                       if (computeAST) {
+                               IIndex index= null;
+                               if (ast != null) {
+                                       index= ast.getIndex();
+                               }
+                               try {
+                                       final boolean canceled = fProgressMonitor.isCanceled();
+                                       if (ast == null || canceled) {
+                                               ((ICReconcilingListener)fEditor).reconciled(null, forced, fProgressMonitor);
+                                       } else {
+                                               ((ASTTranslationUnit) ast).beginExclusiveAccess();
+                                               try {
+                                                       ((ICReconcilingListener)fEditor).reconciled(ast, forced, fProgressMonitor);
+                                               } finally {
+                                                       ((ASTTranslationUnit) ast).endExclusiveAccess();
+                                               }
+                                       }
+                                       if (canceled) {
+                                               aboutToBeReconciled();
+                                       }
+                               } catch(Exception e) {
+                                       IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK, "Error in CDT UI during reconcile", e);  //$NON-NLS-1$
+                                       CUIPlugin.log(status);
+                               } finally {
+                                       if (index != null) {
+                                               index.releaseReadLock();
+                                       }
+                               }
+                       }
+               }
+       }
+
+       /*
+        * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#initialReconcile()
+        */
+       public void initialReconcile() {
+               reconcile(true);
+               fInitialProcessDone= true;
+       }
+
+       void aboutToBeReconciled() {
+               if (fEditor instanceof ICReconcilingListener) {
+                       ((ICReconcilingListener)fEditor).aboutToBeReconciled();
+               }
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerScalableConfiguration.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerScalableConfiguration.java
new file mode 100644 (file)
index 0000000..bc0cfa7
--- /dev/null
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ *  Copyright (c) 2008, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.presentation.IPresentationReconciler;
+import org.eclipse.jface.text.reconciler.IReconciler;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.CSourceViewerConfiguration;
+import org.eclipse.cdt.ui.text.IColorManager;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+
+/**
+ * Configuration for an <code>SourceViewer</code> which shows C/C++ code.
+ * It turns off some editor features when scalability mode options are enabled.
+ */
+public class CSourceViewerScalableConfiguration extends
+               CSourceViewerConfiguration {
+
+       public CSourceViewerScalableConfiguration(
+                       IColorManager colorManager, IPreferenceStore preferenceStore,
+                       ITextEditor editor, String partitioning) {
+               super(colorManager, preferenceStore, editor, partitioning);
+       }
+       
+       @Override
+       public IReconciler getReconciler(ISourceViewer sourceViewer) {
+               if (((CEditor)getEditor()).isEnableScalablilityMode() && fPreferenceStore.getBoolean(PreferenceConstants.SCALABILITY_RECONCILER))
+               return null;
+               return super.getReconciler(sourceViewer);
+       }
+       
+       /**
+     * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getPresentationReconciler(org.eclipse.jface.text.source.ISourceViewer)
+        */
+    @Override
+       public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
+       if (((CEditor)getEditor()).isEnableScalablilityMode() && fPreferenceStore.getBoolean(PreferenceConstants.SCALABILITY_SYNTAX_COLOR))
+               return null;
+               return super.getPresentationReconciler(sourceViewer);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CStringAutoIndentStrategy.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CStringAutoIndentStrategy.java
new file mode 100644 (file)
index 0000000..f934e29
--- /dev/null
@@ -0,0 +1,193 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin, Google
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy;
+import org.eclipse.jface.text.DocumentCommand;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.part.MultiPageEditorPart;
+import org.eclipse.ui.texteditor.ITextEditorExtension3;
+
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+/**
+ * Auto indent strategy for C strings
+ */
+public class CStringAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
+
+       private String fPartitioning;
+       private final ICProject fProject;
+
+       /**
+        * The input string doesn't contain any line delimiter.
+        *
+        * @param inputString the given input string
+        * @return the displayable string.
+        */
+       private String displayString(String inputString, CharSequence indentation, String delimiter) {
+               int length = inputString.length();
+               StringBuilder buffer = new StringBuilder(length);
+               java.util.StringTokenizer tokenizer = new java.util.StringTokenizer(inputString, "\n\r", true); //$NON-NLS-1$
+               while (tokenizer.hasMoreTokens()) {
+                       String token = tokenizer.nextToken();
+                       if (token.equals("\r")) { //$NON-NLS-1$
+                               buffer.append("\\r"); //$NON-NLS-1$
+                               if (tokenizer.hasMoreTokens()) {
+                                       token = tokenizer.nextToken();
+                                       if (token.equals("\n")) { //$NON-NLS-1$
+                                               buffer.append("\\n"); //$NON-NLS-1$
+                                               buffer.append("\"" + delimiter); //$NON-NLS-1$
+                                               buffer.append(indentation);
+                                               buffer.append("\""); //$NON-NLS-1$
+                                               continue;
+                                       }
+                                       buffer.append("\"" + delimiter); //$NON-NLS-1$
+                                       buffer.append(indentation);
+                                       buffer.append("\""); //$NON-NLS-1$
+                               } else {
+                                       continue;
+                               }
+                       } else if (token.equals("\n")) { //$NON-NLS-1$
+                               buffer.append("\\n"); //$NON-NLS-1$
+                               buffer.append("\"" + delimiter); //$NON-NLS-1$
+                               buffer.append(indentation);
+                               buffer.append("\""); //$NON-NLS-1$
+                               continue;
+                       }
+
+                       StringBuilder tokenBuffer = new StringBuilder();
+                       for (int i = 0; i < token.length(); i++){
+                               char c = token.charAt(i);
+                               switch (c) {
+                                       case '\r' :
+                                               tokenBuffer.append("\\r"); //$NON-NLS-1$
+                                               break;
+                                       case '\n' :
+                                               tokenBuffer.append("\\n"); //$NON-NLS-1$
+                                               break;
+                                       case '\b' :
+                                               tokenBuffer.append("\\b"); //$NON-NLS-1$
+                                               break;
+                                       case '\t' :
+                                               // keep tabs verbatim
+                                               tokenBuffer.append("\t"); //$NON-NLS-1$
+                                               break;
+                                       case '\f' :
+                                               tokenBuffer.append("\\f"); //$NON-NLS-1$
+                                               break;
+                                       case '\"' :
+                                               tokenBuffer.append("\\\""); //$NON-NLS-1$
+                                               break;
+                                       case '\'' :
+                                               tokenBuffer.append("\\'"); //$NON-NLS-1$
+                                               break;
+                                       case '\\' :
+                                               tokenBuffer.append("\\\\"); //$NON-NLS-1$
+                                               break;
+                                       default :
+                                               tokenBuffer.append(c);
+                               }
+                       }
+                       buffer.append(tokenBuffer);
+               }
+               return buffer.toString();
+       }
+
+       /**
+        * Creates a new C string auto indent strategy for the given document partitioning.
+        *
+        * @param partitioning the document partitioning
+        */
+       public CStringAutoIndentStrategy(String partitioning, ICProject project) {
+               super();
+               fPartitioning = partitioning;
+               fProject = project;
+       }
+
+       private boolean isLineDelimiter(IDocument document, String text) {
+               String[] delimiters= document.getLegalLineDelimiters();
+               if (delimiters != null)
+                       return TextUtilities.equals(delimiters, text) > -1;
+               return false;
+       }
+
+       private String getModifiedText(String string, CharSequence indentation, String delimiter) {
+               return displayString(string, indentation, delimiter);
+       }
+
+       private void indentStringAfterNewLine(IDocument document, DocumentCommand command) throws BadLocationException {
+               ITypedRegion partition= TextUtilities.getPartition(document, fPartitioning, command.offset, true);
+               int offset= partition.getOffset();
+               int length= partition.getLength();
+
+               if (command.offset == offset + length && document.getChar(offset + length - 1) == '\"')
+                       return;
+
+               if (offset > 0 && document.getChar(offset - 1) == 'R')  // raw string
+                       return;
+               
+               CHeuristicScanner scanner = new CHeuristicScanner(document);
+               CIndenter indenter = new CIndenter(document, scanner, fProject);
+               StringBuilder indentation = indenter.computeContinuationLineIndentation(offset);
+               if (indentation == null)
+                       indentation = new StringBuilder();
+
+               String delimiter= TextUtilities.getDefaultLineDelimiter(document);
+               IPreferenceStore preferenceStore= CUIPlugin.getDefault().getPreferenceStore();
+               if (isLineDelimiter(document, command.text))
+                       command.text= "\"" + command.text + indentation + "\"";  //$NON-NLS-1$//$NON-NLS-2$
+               else if (command.text.length() > 1 && preferenceStore.getBoolean(PreferenceConstants.EDITOR_ESCAPE_STRINGS))
+                       command.text= getModifiedText(command.text, indentation, delimiter);
+       }
+
+       private boolean isSmartMode() {
+               IWorkbenchPage page= CUIPlugin.getActivePage();
+               if (page != null)  {
+                       IEditorPart part= page.getActiveEditor();
+                       if (part instanceof MultiPageEditorPart) {
+                               part= (IEditorPart)part.getAdapter(ITextEditorExtension3.class);
+                       }
+                       if (part instanceof ITextEditorExtension3) {
+                               ITextEditorExtension3 extension= (ITextEditorExtension3) part;
+                               return extension.getInsertMode() == ITextEditorExtension3.SMART_INSERT;
+                       }
+               }
+               return false;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.IAutoIndentStrategy#customizeDocumentCommand(IDocument, DocumentCommand)
+        */
+       @Override
+       public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
+               try {
+                       if (command.length != 0 || command.text == null)
+                               return;
+
+                       IPreferenceStore preferenceStore= CUIPlugin.getDefault().getPreferenceStore();
+
+                       if (preferenceStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS) && isSmartMode()) {
+                               indentStringAfterNewLine(document, command);
+                       }
+               } catch (BadLocationException e) {
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CStringDoubleClickSelector.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CStringDoubleClickSelector.java
new file mode 100644 (file)
index 0000000..86e63b1
--- /dev/null
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextDoubleClickStrategy;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TextUtilities;
+
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+import org.eclipse.cdt.internal.ui.editor.CDocumentSetupParticipant;
+
+/**
+ * Double click strategy aware of string and character syntax rules.
+ *
+ * @since 4.0
+ */
+public class CStringDoubleClickSelector extends CDoubleClickSelector {
+
+       private String fPartitioning;
+       private ITextDoubleClickStrategy fFallbackStrategy;
+
+       /**
+        * Creates a new string double click selector for the given document partitioning.
+        *
+        * @param partitioning the document partitioning
+        */
+       public CStringDoubleClickSelector(String partitioning) {
+               this(partitioning, null);
+       }
+
+       /**
+        * Creates a new string double click selector for the given document partitioning.
+        *
+        * @param partitioning the document partitioning
+        * @param doubleClickStrategy  the fallback double click strategy
+        */
+       public CStringDoubleClickSelector(String partitioning,
+                       ITextDoubleClickStrategy doubleClickStrategy) {
+               fPartitioning= partitioning;
+               fFallbackStrategy= doubleClickStrategy;
+       }
+
+       /*
+        * @see ITextDoubleClickStrategy#doubleClicked(ITextViewer)
+        */
+       @Override
+       public void doubleClicked(ITextViewer textViewer) {
+               int offset= textViewer.getSelectedRange().x;
+
+               if (offset < 0)
+                       return;
+
+               IDocument document= textViewer.getDocument();
+
+               IRegion region= matchString(document, offset);
+               if (region != null) {
+                       if (region.getLength() >= 2) {
+                               textViewer.setSelectedRange(region.getOffset() + 1, region.getLength() - 2);
+                       }
+               } else if (fFallbackStrategy != null) {
+                       fFallbackStrategy.doubleClicked(textViewer);
+               } else {
+                       region= selectWord(document, offset);
+                       if (region != null) {
+                               textViewer.setSelectedRange(region.getOffset(), region.getLength());
+                       }
+               }
+       }
+
+       private IRegion matchString(IDocument document, int offset) {
+               try {
+                       if ((document.getChar(offset) == '"') || (document.getChar(offset) == '\'') ||
+                               (document.getChar(offset - 1) == '"') || (document.getChar(offset - 1) == '\''))
+                       {
+                               ITypedRegion region= TextUtilities.getPartition(document, fPartitioning, offset, true);
+                               // little hack: in case this strategy is used in preprocessor partitions, the string
+                               // partition inside the preprocessor partition must be computed in an extra step
+                               if (ICPartitions.C_PREPROCESSOR.equals(region.getType())) {
+                                       String ppDirective= document.get(region.getOffset(), region.getLength());
+                                       int hashIdx= ppDirective.indexOf('#');
+                                       document= new Document(ppDirective.substring(hashIdx+1));
+                                       new CDocumentSetupParticipant().setup(document);
+                                       int delta= region.getOffset() + hashIdx + 1;
+                                       region= TextUtilities.getPartition(document, fPartitioning, offset - delta, true);
+                                       return new Region(region.getOffset() + delta, region.getLength());
+                               }
+                               return region;
+                       }
+               } catch (BadLocationException e) {
+               }
+
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CTextTools.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CTextTools.java
new file mode 100644 (file)
index 0000000..19b66c6
--- /dev/null
@@ -0,0 +1,161 @@
+/*******************************************************************************
+ *  Copyright (c) 2005, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *     Andrew Ferguson (Symbian)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.core.filebuffers.LocationKind;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentExtension3;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.jface.text.rules.IPartitionTokenScanner;
+
+import org.eclipse.cdt.ui.text.CSourceViewerConfiguration;
+import org.eclipse.cdt.ui.text.ICPartitions;
+import org.eclipse.cdt.ui.text.IColorManager;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
+
+import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
+import org.eclipse.cdt.internal.ui.text.util.CColorManager;
+
+
+/**
+ * Tools required to configure a C/C++ source viewer.
+ * Scanners must be configured using a {@link CSourceViewerConfiguration}.
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ */
+public class CTextTools {
+
+       /** The color manager */
+       private CColorManager fColorManager;
+
+       /** The document partitioning used for the C partitioner */
+       private String fDocumentPartitioning = ICPartitions.C_PARTITIONING;
+
+       /**
+        * Creates a new C text tools instance.
+        */
+       public CTextTools() {
+               fColorManager= new CColorManager(true);
+       }
+
+       /**
+        * Disposes all members of this tools collection.
+        */
+       public void dispose() {
+               if (fColorManager != null) {
+                       fColorManager.dispose();
+                       fColorManager= null;
+               }
+       }
+
+       /**
+        * Gets the color manager.
+        */
+       public IColorManager getColorManager() {
+               return fColorManager;
+       }
+
+       /**
+        * Returns a scanner which is configured to scan 
+        * C-specific partitions, which are preprocessor directives, comments,
+        * and regular C source code.
+        *
+        * @param owner may be null
+        * @return a C partition scanner
+        */
+       public IPartitionTokenScanner getPartitionScanner(IDocCommentOwner owner) {
+               return new FastCPartitionScanner(owner);
+       }
+
+       /**
+        * Gets the document provider used.
+        */
+       public IDocumentPartitioner createDocumentPartitioner(IDocCommentOwner owner) {
+               return new FastCPartitioner(getPartitionScanner(owner), ICPartitions.ALL_CPARTITIONS);
+       }
+
+       /**
+        * Sets up the document partitioner for the given document for the given partitioning.
+        * 
+        * @param document
+        * @param partitioning
+        * @param owner may be null
+        */
+       public void setupCDocumentPartitioner(IDocument document, String partitioning, IDocCommentOwner owner) {
+               IDocumentPartitioner partitioner= createDocumentPartitioner(owner);
+               if (document instanceof IDocumentExtension3) {
+                       IDocumentExtension3 extension3= (IDocumentExtension3) document;
+                       extension3.setDocumentPartitioner(partitioning, partitioner);
+               } else {
+                       document.setDocumentPartitioner(partitioner);
+               }
+               partitioner.connect(document);
+       }
+
+       /**
+        * Sets up the given document for the default partitioning.
+        * 
+        * @param document the document to be set up
+        * @param location the path of the resource backing the document. May be null.
+        * @param locationKind the type of path specified above. May be null.
+        */
+       public void setupCDocument(IDocument document, IPath location, LocationKind locationKind) {
+               IDocCommentOwner owner= getDocumentationCommentOwner(location, locationKind);
+               setupCDocumentPartitioner(document, fDocumentPartitioning, owner);
+       }
+
+       /**
+        * Sets up the given document for the default partitioning.
+        * 
+        * @param document the document to be set up
+        */
+       public void setupCDocument(IDocument document) {
+               setupCDocumentPartitioner(document, fDocumentPartitioning, null);
+       }
+
+       /**
+        * Get the document partitioning used for the C partitioner.
+        * 
+        * @return the document partitioning used for the C partitioner
+        */
+       public String getDocumentPartitioning() {
+               return fDocumentPartitioning;
+       }
+
+       /**
+        * Set the document partitioning to be used for the C partitioner.
+        */
+       public void setDocumentPartitioning(String documentPartitioning) {
+               fDocumentPartitioning = documentPartitioning;
+       }
+       
+       /**
+        * @param location
+        * @param locationKind
+        * @return the documentation comment owner mapped to the specified location. If there is
+        * no mapping, or the <code>location</code>/<code>locationKind</code> is not available, the
+        * workspace default is returned.
+        */
+       private IDocCommentOwner getDocumentationCommentOwner(IPath location, LocationKind locationKind) {
+               if(location!=null && LocationKind.IFILE.equals(locationKind)) {
+                       IFile file= ResourcesPlugin.getWorkspace().getRoot().getFile(location);
+                       return DocCommentOwnerManager.getInstance().getCommentOwner(file);
+               }
+               return DocCommentOwnerManager.getInstance().getWorkspaceCommentOwner();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CWhitespaceRule.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CWhitespaceRule.java
new file mode 100644 (file)
index 0000000..db680f3
--- /dev/null
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.jface.text.rules.IToken;
+
+/**
+ * A simple whitespace rule with configurable token.
+ */
+public class CWhitespaceRule extends SingleCharRule {
+
+       public CWhitespaceRule(IToken token) {
+               super(token);
+       }
+
+       @Override
+       protected boolean isRuleChar(int ch) {
+               switch (ch) {
+               case ' ':
+               case '\t':
+               case '\r':
+               case '\n':
+                       return true;
+               default:
+                       return false;
+               }
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CWordFinder.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CWordFinder.java
new file mode 100644 (file)
index 0000000..354c453
--- /dev/null
@@ -0,0 +1,293 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+
+
+/**
+ * This is a helper class for the text editor to be able to determine, given a
+ * particular offset in a document, various candidates segments for things like
+ * context help, proposals and hovering.
+ */
+public class CWordFinder {
+       
+       private static final char CBRACE_L = '{';
+       private static final char CBRACE_R = '}';
+       private static final char PAREN_R  = ')';
+       
+       /**
+        * This method determines for a given offset into a given document what the
+        * region is which defines the current word. A word is defined as a contiguous
+        * sequence of C-identifier characters. So assuming that | indicates the current
+        * cursor position:
+        * <pre>
+        *   |afunction(int a, int b) --> word = afunction
+        *   afunc|tion(int a, int b) --> word = afunction
+        *   afunction|(int a, int b) --> word = afunction
+        *   afunction(|int a, int b) --> word = int
+        *   afunction(int a,| int b) --> word = length 0
+        *   afunction(|)             --> word = length 0
+        * </pre>
+        * 
+        * @param document
+        *            The document to be examined
+        * @param offset
+        *            The offset into the document where a word should be
+        *            identified.
+        * @return The region defining the current word, which may be a region of
+        *         length 0 if the offset is not in a word, or null if there is an
+        *         error accessing the document data.
+        */
+       public static IRegion findWord(IDocument document, int offset) {
+               int start = -2;
+               int end = -1;
+
+               try {
+                       int pos = offset;
+                       char c;
+
+                       while (--pos >= 0) {
+                               c = document.getChar(pos);
+                               if (!Character.isJavaIdentifierPart(c)) {
+                                       break;
+                               }
+                       }
+
+                       start = pos;
+
+                       pos = offset;
+                       int length = document.getLength();
+
+                       while (pos < length) {
+                               c = document.getChar(pos);
+                               if (!Character.isJavaIdentifierPart(c))
+                                       break;
+                               ++pos;
+                       }
+
+                       end = pos;
+               } catch (BadLocationException x) {
+               }
+
+               if (start >= -1 && end > -1) {
+                       if (start == offset && end == offset)
+                               return new Region(offset, 0);
+                       else if (start == offset)
+                               return new Region(start, end - start);
+                       else
+                               return new Region(start + 1, end - start - 1);
+               }
+
+               return null;
+       }
+
+       /**
+        * This method will determine the region for the name of the function within
+        * which the current offset is contained.
+        * 
+        * @param document
+        *            The document to be examined
+        * @param offset
+        *            The offset into the document where a word should be
+        *            identified.
+        * @return The region defining the current word, which may be a region of
+        *         length 0 if the offset is not in a function, or null if there is
+        *         an error accessing the document data.
+        */
+       public static IRegion findFunction(IDocument document, int offset) {
+               int leftbracket = -1;
+               int leftbracketcount = 0;
+               int rightbracket = -1;
+               int rightbracketcount = 0;
+               int functionstart = -1;
+               int functionend = -1;
+
+               try {
+                       int length = document.getLength();
+                       int pos;
+                       char c;
+
+                       //Find most relevant right bracket from our position
+                       pos = offset;
+                       rightbracketcount = leftbracketcount = 0;
+                       while (pos < length) {
+                               c = document.getChar(pos);
+
+                               if (c == ')') {
+                                       rightbracketcount++;
+                                       if (rightbracketcount >= leftbracketcount) {
+                                               rightbracket = pos;
+                                               break;
+                                       }
+                               }
+
+                               if (c == '(') {
+                                       leftbracketcount++;
+                               }
+
+                               if (c == ';') {
+                                       break;
+                               }
+
+                               pos++;
+                       }
+
+                       if (rightbracket == -1) {
+                               return new Region(offset, 0);
+                       }
+
+                       // Now backtrack our way from the right bracket to the left
+                       pos = rightbracket;
+                       rightbracketcount = leftbracketcount = 0;
+                       while (pos >= 0) {
+                               c = document.getChar(pos);
+
+                               if (c == ')') {
+                                       rightbracketcount++;
+                               }
+
+                               if (c == '(') {
+                                       leftbracketcount++;
+                                       if (leftbracketcount >= rightbracketcount) {
+                                               leftbracket = pos;
+                                               break;
+                                       }
+                               }
+
+                               if (c == ';') {
+                                       break;
+                               }
+
+                               pos--;
+                       }
+
+                       if (leftbracket == -1) {
+                               return new Region(offset, 0);
+                       }
+
+                       // Now work our way to the function name
+                       pos = leftbracket - 1;
+                       while (pos >= 0) {
+                               c = document.getChar(pos);
+                               if (functionend == -1 && c == ' ') {
+                                       pos--;
+                                       continue;
+                               }
+
+                               if (!Character.isJavaIdentifierPart(c)) {
+                                       break;
+                               }
+
+                               functionstart = pos;
+                               if (functionend == -1) {
+                                       functionend = pos;
+                               }
+
+                               pos--;
+                       }
+               } catch (BadLocationException x) {
+                       /* Ignore */
+               }
+
+               if (functionstart > -1 && functionend > -1) {
+                       return new Region(functionstart, functionend - functionstart + 1);
+               }
+
+               return null;
+       }
+
+       /**
+        * This method will determine whether current offset is contained 
+        * in any function's body or it's outside it. 
+        * 
+        * @param document
+        *            The document to be examined
+        * @param offset
+        *            The offset into the document
+        * @return 
+        *      <code>true</code> if there is no function body around offset 
+        *      <code>false</code> otherwise 
+        */
+       public static boolean isGlobal(IDocument document, int offset) {
+               try {
+                       int pos = offset;
+                       int bracketcount = 0;
+                       char c;
+
+                       // Find left curled brace from our position
+                       while (pos > 0) {
+                               c = document.getChar(pos--);
+
+                               if (c == CBRACE_R) {
+                                       bracketcount++; // take into account nested blocks
+                               } else if (c == CBRACE_L) {
+                                       if (bracketcount-- == 0) {
+                                               do {
+                                                       c = document.getChar(pos--);
+                                                       if (c == PAREN_R)
+                                                               return false;
+                                               } while (Character.isWhitespace(c));
+                                               // Container block seems to be not a function or statement body
+                                               pos++;             // step back one symbol
+                                               bracketcount = 0;  // let's search for upper block
+                                       }
+                               }
+                       }
+               } catch (BadLocationException x) {
+                       // Ignore
+               }
+               return true;  // return true in case of unknown result or exception 
+       }
+       
+       /**
+        * Searches for line feed symbols in string.
+        * First met '\r' or '\n' is treated as LF symbol
+        * 
+        * @param s
+        *                      string to search in.
+        * @return  number of LFs met.
+        */
+       public static int countLFs (String s) {
+               int counter = 0;
+               char lf = 0;
+               char c;
+               for (int i= 0; i < s.length(); i++) {
+                       c = s.charAt(i);
+                       if (lf == 0) {
+                               if (c == '\n' || c == '\r') {
+                                       lf = c;
+                                       counter++;
+                               }
+                       } else if (lf == c) {
+                               counter++;
+                       }
+               }
+               return counter;
+       }
+
+       /**
+        * Checks whether the string contains any C-block delimiters ( { } ) 
+        * 
+        * @param s 
+        *                      text to check
+        * @return  true if curled brace found.
+        */
+       public static boolean hasCBraces (String s) {
+               if (s.indexOf(CBRACE_L) > -1 || s.indexOf(CBRACE_R) > -1) 
+                       return true;
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CWordIterator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CWordIterator.java
new file mode 100644 (file)
index 0000000..2758e09
--- /dev/null
@@ -0,0 +1,249 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import com.ibm.icu.text.BreakIterator;
+import java.text.CharacterIterator;
+
+import org.eclipse.core.runtime.Assert;
+
+/**
+ * Breaks C text into word starts, also stops at line start and end. No
+ * direction dependency.
+ *
+ * @since 4.0
+ */
+public class CWordIterator extends BreakIterator {
+
+       /**
+        * The underlying C break iterator. It returns all breaks, including
+        * before and after every whitespace.
+        */
+       private CBreakIterator fIterator;
+       /** The current index for the stateful operations. */
+       private int fIndex;
+
+       /**
+        * Creates a new word iterator.
+        */
+       public CWordIterator() {
+               fIterator= new CBreakIterator();
+               first();
+       }
+
+       /*
+        * @see com.ibm.icu.text.BreakIterator#first()
+        */
+       @Override
+       public int first() {
+               fIndex= fIterator.first();
+               return fIndex;
+       }
+
+       /*
+        * @see com.ibm.icu.text.BreakIterator#last()
+        */
+       @Override
+       public int last() {
+               fIndex= fIterator.last();
+               return fIndex;
+       }
+
+       /*
+        * @see com.ibm.icu.text.BreakIterator#next(int)
+        */
+       @Override
+       public int next(int n) {
+               int next= 0;
+               while (--n > 0 && next != DONE) {
+                       next= next();
+               }
+               return next;
+       }
+
+       /*
+        * @see com.ibm.icu.text.BreakIterator#next()
+        */
+       @Override
+       public int next() {
+               fIndex= following(fIndex);
+               return fIndex;
+       }
+
+       /*
+        * @see com.ibm.icu.text.BreakIterator#previous()
+        */
+       @Override
+       public int previous() {
+               fIndex= preceding(fIndex);
+               return fIndex;
+       }
+
+
+       /*
+        * @see com.ibm.icu.text.BreakIterator#preceding(int)
+        */
+       @Override
+       public int preceding(int offset) {
+               int first= fIterator.preceding(offset);
+               if (isWhitespace(first, offset)) {
+                       int second= fIterator.preceding(first);
+                       if (second != DONE && !isDelimiter(second, first))
+                               return second;
+               }
+               return first;
+       }
+
+       /*
+        * @see com.ibm.icu.text.BreakIterator#following(int)
+        */
+       @Override
+       public int following(int offset) {
+               int first= fIterator.following(offset);
+               if (eatFollowingWhitespace(offset, first)) {
+                       int second= fIterator.following(first);
+                       if (isWhitespace(first, second))
+                               return second;
+               }
+               return first;
+       }
+
+       private boolean eatFollowingWhitespace(int offset, int exclusiveEnd) {
+               if (exclusiveEnd == DONE || offset == DONE)
+                       return false;
+
+               if (isWhitespace(offset, exclusiveEnd))
+                       return false;
+               if (isDelimiter(offset, exclusiveEnd))
+                       return false;
+
+               return true;
+       }
+
+       /**
+        * Returns <code>true</code> if the given sequence into the underlying text
+        * represents a delimiter, <code>false</code> otherwise.
+        *
+        * @param offset the offset
+        * @param exclusiveEnd the end offset
+        * @return <code>true</code> if the given range is a delimiter
+        */
+       private boolean isDelimiter(int offset, int exclusiveEnd) {
+               if (exclusiveEnd == DONE || offset == DONE)
+                       return false;
+
+               Assert.isTrue(offset >= 0);
+               Assert.isTrue(exclusiveEnd <= getText().getEndIndex());
+               Assert.isTrue(exclusiveEnd > offset);
+
+               CharSequence seq= fIterator.fText;
+
+               while (offset < exclusiveEnd) {
+                       char ch= seq.charAt(offset);
+                       if (ch != '\n' && ch != '\r')
+                               return false;
+                       offset++;
+               }
+
+               return true;
+       }
+
+       /**
+        * Returns <code>true</code> if the given sequence into the underlying text
+        * represents whitespace, but not a delimiter, <code>false</code> otherwise.
+        *
+        * @param offset the offset
+        * @param exclusiveEnd the end offset
+        * @return <code>true</code> if the given range is whitespace
+        */
+       private boolean isWhitespace(int offset, int exclusiveEnd) {
+               if (exclusiveEnd == DONE || offset == DONE)
+                       return false;
+
+               Assert.isTrue(offset >= 0);
+               Assert.isTrue(exclusiveEnd <= getText().getEndIndex());
+               Assert.isTrue(exclusiveEnd > offset);
+
+               CharSequence seq= fIterator.fText;
+
+               while (offset < exclusiveEnd) {
+                       char ch= seq.charAt(offset);
+                       if (!Character.isWhitespace(ch))
+                               return false;
+                       if (ch == '\n' || ch == '\r')
+                               return false;
+                       offset++;
+               }
+
+               return true;
+       }
+
+       /*
+        * @see com.ibm.icu.text.BreakIterator#current()
+        */
+       @Override
+       public int current() {
+               return fIndex;
+       }
+
+       /*
+        * @see com.ibm.icu.text.BreakIterator#getText()
+        */
+       @Override
+       public CharacterIterator getText() {
+               return fIterator.getText();
+       }
+
+       /**
+        * Sets the text as <code>CharSequence</code>.
+        * @param newText the new text
+        */
+       public void setText(CharSequence newText) {
+               fIterator.setText(newText);
+               first();
+       }
+
+       /*
+        * @see com.ibm.icu.text.BreakIterator#setText(java.text.CharacterIterator)
+        */
+       @Override
+       public void setText(CharacterIterator newText) {
+               fIterator.setText(newText);
+               first();
+       }
+
+       /*
+        * @see com.ibm.icu.text.BreakIterator#setText(java.lang.String)
+        */
+       @Override
+       public void setText(String newText) {
+               setText((CharSequence) newText);
+       }
+
+       /**
+        * Enables breaks at word boundaries inside a camel case identifier.
+        *  
+        * @param camelCaseBreakEnabled <code>true</code> to enable,
+        * <code>false</code> to disable.
+        */
+       public void setCamelCaseBreakEnabled(boolean camelCaseBreakEnabled) {
+               fIterator.setCamelCaseBreakEnabled(camelCaseBreakEnabled);
+       }
+
+       /**
+        * @return <code>true</code> if breaks at word boundaries inside
+        * a camel case identifier are enabled.
+        */
+       public boolean isCamelCaseBreakEnabled() {
+               return fIterator.isCamelCaseBreakEnabled();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CombinedWordRule.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CombinedWordRule.java
new file mode 100644 (file)
index 0000000..b3597b3
--- /dev/null
@@ -0,0 +1,370 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.text.rules.IRule;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.IWordDetector;
+import org.eclipse.jface.text.rules.Token;
+
+/**
+ * An implementation of <code>IRule</code> capable of detecting words.
+ * <p>
+ * Word rules also allow for the association of tokens with specific words.
+ * That is, not only can the rule be used to provide tokens for exact matches,
+ * but also for the generalized notion of a word in the context in which it is used.
+ * A word rules uses a word detector to determine what a word is.</p>
+ * <p>
+ * This word rule allows a word detector to be shared among different word matchers.
+ * Its up to the word matchers to decide if a word matches and, in this a case, which
+ * token is associated with that word.
+ * </p>
+ *
+ * @see IWordDetector
+ * @since 5.1
+ */
+public class CombinedWordRule implements IRule {
+
+       /**
+        * Word matcher, that associates matched words with tokens.
+        */
+       public static class WordMatcher {
+               /** The table of predefined words and token for this matcher */
+               private Map<CharacterBuffer, IToken> fWords= new HashMap<CharacterBuffer, IToken>();
+
+               /**
+                * Adds a word and the token to be returned if it is detected.
+                *
+                * @param word the word this rule will search for, may not be <code>null</code>
+                * @param token the token to be returned if the word has been found, may not be <code>null</code>
+                */
+               public void addWord(String word, IToken token) {
+                       Assert.isNotNull(word);
+                       Assert.isNotNull(token);
+
+                       fWords.put(new CharacterBuffer(word), token);
+               }
+
+               /**
+                * Returns the token associated to the given word and the scanner state.
+                *
+                * @param scanner the scanner
+                * @param word the word
+                * @return the token or <code>null</code> if none is associated by this matcher
+                */
+               public IToken evaluate(ICharacterScanner scanner, CharacterBuffer word) {
+                       IToken token= fWords.get(word);
+                       if (token != null)
+                               return token;
+                       return Token.UNDEFINED;
+               }
+
+               /**
+                * Removes all words.
+                */
+               public void clearWords() {
+                       fWords.clear();
+               }
+       }
+
+       /**
+        * Character buffer, mutable <b>or</b> suitable for use as key in hash maps.
+        */
+       public static class CharacterBuffer {
+               /** Buffer content */
+               private char[] fContent;
+               /** Buffer content size */
+               private int fLength= 0;
+
+               /** Is hash code cached? */
+               private boolean fIsHashCached= false;
+               /** The hash code */
+               private int fHashCode;
+
+               /**
+                * Initialize with the given capacity.
+                *
+                * @param capacity the initial capacity
+                */
+               public CharacterBuffer(int capacity) {
+                       fContent= new char[capacity];
+               }
+
+               /**
+                * Initialize with the given content.
+                *
+                * @param content the initial content
+                */
+               public CharacterBuffer(String content) {
+                       fContent= content.toCharArray();
+                       fLength= content.length();
+               }
+
+               /**
+                * Empties this buffer.
+                */
+               public void clear() {
+                       fIsHashCached= false;
+                       fLength= 0;
+               }
+
+               /**
+                * Appends the given character to the buffer.
+                *
+                * @param c the character
+                */
+               public void append(char c) {
+                       fIsHashCached= false;
+                       if (fLength == fContent.length) {
+                               char[] old= fContent;
+                               fContent= new char[old.length << 1];
+                               System.arraycopy(old, 0, fContent, 0, old.length);
+                       }
+                       fContent[fLength++]= c;
+               }
+
+               /**
+                * Returns the length of the content.
+                *
+                * @return the length
+                */
+               public int length() {
+                       return fLength;
+               }
+
+               /**
+                * Returns the content as string.
+                *
+                * @return the content
+                */
+               @Override
+               public String toString() {
+                       return new String(fContent, 0, fLength);
+               }
+
+               /**
+                * Returns the character at the given position.
+                *
+                * @param i the position
+                * @return the character at position <code>i</code>
+                */
+               public char charAt(int i) {
+                       return fContent[i];
+               }
+
+               /*
+                * @see java.lang.Object#hashCode()
+                */
+               @Override
+               public int hashCode() {
+                       if (fIsHashCached)
+                               return fHashCode;
+
+                       int hash= 0;
+                       for (int i= 0, n= fLength; i < n; i++)
+                               hash= 29*hash + fContent[i];
+                       fHashCode= hash;
+                       fIsHashCached= true;
+                       return hash;
+               }
+
+               /*
+                * @see java.lang.Object#equals(java.lang.Object)
+                */
+               @Override
+               public boolean equals(Object obj) {
+                       if (obj == this)
+                               return true;
+                       if (!(obj instanceof CharacterBuffer))
+                               return false;
+                       CharacterBuffer buffer= (CharacterBuffer) obj;
+                       int length= buffer.length();
+                       if (length != fLength)
+                               return false;
+                       for (int i= 0; i < length; i++)
+                               if (buffer.charAt(i) != fContent[i])
+                                       return false;
+                       return true;
+               }
+
+               /**
+                * Is the content equal to the given string?
+                *
+                * @param string the string
+                * @return <code>true</code> iff the content is the same character sequence as in the string
+                */
+               public boolean equals(String string) {
+                       int length= string.length();
+                       if (length != fLength)
+                               return false;
+                       for (int i= 0; i < length; i++)
+                               if (string.charAt(i) != fContent[i])
+                                       return false;
+                       return true;
+               }
+       }
+
+       /** Internal setting for the uninitialized column constraint */
+       private static final int UNDEFINED= -1;
+
+       /** The word detector used by this rule */
+       private IWordDetector fDetector;
+       /** The default token to be returned on success and if nothing else has been specified. */
+       private IToken fDefaultToken;
+       /** The column constraint */
+       private int fColumn= UNDEFINED;
+       /** Buffer used for pattern detection */
+       private CharacterBuffer fBuffer= new CharacterBuffer(16);
+
+       /** List of word matchers */
+       private List<WordMatcher> fMatchers= new ArrayList<WordMatcher>();
+
+       /**
+        * Creates a rule which, with the help of an word detector, will return the token
+        * associated with the detected word. If no token has been associated, the scanner
+        * will be rolled back and an undefined token will be returned in order to allow
+        * any subsequent rules to analyze the characters.
+        *
+        * @param detector the word detector to be used by this rule, may not be <code>null</code>
+        *
+        * @see WordMatcher#addWord(String, IToken)
+        */
+       public CombinedWordRule(IWordDetector detector) {
+               this(detector, null, Token.UNDEFINED);
+       }
+
+       /**
+        * Creates a rule which, with the help of an word detector, will return the token
+        * associated with the detected word. If no token has been associated, the
+        * specified default token will be returned.
+        *
+        * @param detector the word detector to be used by this rule, may not be <code>null</code>
+        * @param defaultToken the default token to be returned on success
+        *              if nothing else is specified, may not be <code>null</code>
+        *
+        * @see WordMatcher#addWord(String, IToken)
+        */
+       public CombinedWordRule(IWordDetector detector, IToken defaultToken) {
+               this(detector, null, defaultToken);
+       }
+
+       /**
+        * Creates a rule which, with the help of an word detector, will return the token
+        * associated with the detected word. If no token has been associated, the scanner
+        * will be rolled back and an undefined token will be returned in order to allow
+        * any subsequent rules to analyze the characters.
+        *
+        * @param detector the word detector to be used by this rule, may not be <code>null</code>
+        * @param matcher the initial word matcher
+        *
+        * @see WordMatcher#addWord(String, IToken)
+        */
+       public CombinedWordRule(IWordDetector detector, WordMatcher matcher) {
+               this(detector, matcher, Token.UNDEFINED);
+       }
+
+       /**
+        * Creates a rule which, with the help of an word detector, will return the token
+        * associated with the detected word. If no token has been associated, the
+        * specified default token will be returned.
+        *
+        * @param detector the word detector to be used by this rule, may not be <code>null</code>
+        * @param matcher the initial word matcher
+        * @param defaultToken the default token to be returned on success
+        *              if nothing else is specified, may not be <code>null</code>
+        *
+        * @see WordMatcher#addWord(String, IToken)
+        */
+       public CombinedWordRule(IWordDetector detector, WordMatcher matcher, IToken defaultToken) {
+
+               Assert.isNotNull(detector);
+               Assert.isNotNull(defaultToken);
+
+               fDetector= detector;
+               fDefaultToken= defaultToken;
+               if (matcher != null)
+                       addWordMatcher(matcher);
+       }
+
+       /**
+        * Adds the given matcher.
+        *
+        * @param matcher the matcher
+        */
+       public void addWordMatcher(WordMatcher matcher) {
+               fMatchers.add(matcher);
+       }
+
+       /**
+        * Sets a column constraint for this rule. If set, the rule's token
+        * will only be returned if the pattern is detected starting at the
+        * specified column. If the column is smaller then 0, the column
+        * constraint is considered removed.
+        *
+        * @param column the column in which the pattern starts
+        */
+       public void setColumnConstraint(int column) {
+               if (column < 0)
+                       column= UNDEFINED;
+               fColumn= column;
+       }
+
+       /*
+        * @see IRule#evaluate(ICharacterScanner)
+        */
+       public IToken evaluate(ICharacterScanner scanner) {
+               int c= scanner.read();
+               if (fDetector.isWordStart((char) c)) {
+                       if (fColumn == UNDEFINED || (fColumn == scanner.getColumn() - 1)) {
+
+                               fBuffer.clear();
+                               do {
+                                       fBuffer.append((char) c);
+                                       c= scanner.read();
+                               } while (c != ICharacterScanner.EOF && fDetector.isWordPart((char) c));
+                               scanner.unread();
+
+                               for (int i= 0, n= fMatchers.size(); i < n; i++) {
+                                       IToken token= fMatchers.get(i).evaluate(scanner, fBuffer);
+                                       if (!token.isUndefined())
+                                               return token;
+                               }
+
+                               if (fDefaultToken.isUndefined())
+                                       unreadBuffer(scanner);
+
+                               return fDefaultToken;
+                       }
+               }
+
+               scanner.unread();
+               return Token.UNDEFINED;
+       }
+
+       /**
+        * Returns the characters in the buffer to the scanner.
+        *
+        * @param scanner the scanner to be used
+        */
+       private void unreadBuffer(ICharacterScanner scanner) {
+               for (int i= fBuffer.length() - 1; i >= 0; i--)
+                       scanner.unread();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CompositeReconcilingStrategy.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CompositeReconcilingStrategy.java
new file mode 100644 (file)
index 0000000..c03488e
--- /dev/null
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.reconciler.DirtyRegion;
+import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
+import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension;
+
+/**
+ * A reconciling strategy consisting of a sequence of internal reconciling strategies.
+ * By default, all requests are passed on to the contained strategies.
+ */
+public class CompositeReconcilingStrategy  implements IReconcilingStrategy, IReconcilingStrategyExtension {
+
+       /** The list of internal reconciling strategies. */
+       private IReconcilingStrategy[] fStrategies;
+
+       /**
+        * Creates a new, empty composite reconciling strategy.
+        */
+       public CompositeReconcilingStrategy() {
+       }
+
+       /**
+        * Sets the reconciling strategies for this composite strategy.
+        *
+        * @param strategies the strategies to be set or <code>null</code>
+        */
+       public void setReconcilingStrategies(IReconcilingStrategy[] strategies) {
+               fStrategies= strategies;
+       }
+
+       /**
+        * Returns the previously set strategies or <code>null</code>.
+        *
+        * @return the contained strategies or <code>null</code>
+        */
+       public IReconcilingStrategy[] getReconcilingStrategies() {
+               return fStrategies;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument)
+        */
+       public void setDocument(IDocument document) {
+               if (fStrategies == null)
+                       return;
+
+               for (int i= 0; i < fStrategies.length; i++)
+                       fStrategies[i].setDocument(document);
+       }
+
+       /*
+        * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion)
+        */
+       public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
+               if (fStrategies == null)
+                       return;
+
+               for (int i= 0; i < fStrategies.length; i++)
+                       fStrategies[i].reconcile(dirtyRegion, subRegion);
+       }
+
+       /*
+        * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion)
+        */
+       public void reconcile(IRegion partition) {
+               if (fStrategies == null)
+                       return;
+
+               for (int i= 0; i < fStrategies.length; i++)
+                       fStrategies[i].reconcile(partition);
+       }
+
+       /*
+        * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor)
+        */
+       public void setProgressMonitor(IProgressMonitor monitor) {
+               if (fStrategies == null)
+                       return;
+
+               for (int i=0; i < fStrategies.length; i++) {
+                       if (fStrategies[i] instanceof IReconcilingStrategyExtension) {
+                               IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategies[i];
+                               extension.setProgressMonitor(monitor);
+                       }
+               }
+       }
+
+       /*
+        * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#initialReconcile()
+        */
+       public void initialReconcile() {
+               if (fStrategies == null)
+                       return;
+
+               for (int i = 0; i < fStrategies.length; i++) {
+                       if (fStrategies[i] instanceof IReconcilingStrategyExtension) {
+                               IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategies[i];
+                               extension.initialReconcile();
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/DocumentCharacterIterator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/DocumentCharacterIterator.java
new file mode 100644 (file)
index 0000000..27042e5
--- /dev/null
@@ -0,0 +1,233 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import java.text.CharacterIterator;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+
+
+/**
+ * An <code>IDocument</code> based implementation of
+ * <code>CharacterIterator</code> and <code>CharSequence</code>. Note that
+ * the supplied document is not copied; if the document is modified during the
+ * lifetime of a <code>DocumentCharacterIterator</code>, the methods
+ * returning document content may not always return the same values. Also, if
+ * accessing the document fails with a {@link BadLocationException}, any of
+ * <code>CharacterIterator</code> methods as well as <code>charAt</code>may
+ * return {@link CharacterIterator#DONE}.
+ *
+ * @since 4.0
+ */
+public class DocumentCharacterIterator implements CharacterIterator, CharSequence {
+
+       private int fIndex= -1;
+       private final IDocument fDocument;
+       private final int fFirst;
+       private final int fLast;
+
+       private void invariant() {
+               Assert.isTrue(fIndex >= fFirst);
+               Assert.isTrue(fIndex <= fLast);
+       }
+
+       /**
+        * Creates an iterator for the entire document.
+        *
+        * @param document the document backing this iterator
+        */
+       public DocumentCharacterIterator(IDocument document) {
+               this(document, 0);
+       }
+
+       /**
+        * Creates an iterator, starting at offset <code>first</code>.
+        *
+        * @param document the document backing this iterator
+        * @param first the first character to consider
+        * @throws IllegalArgumentException if the indices are out of bounds
+        */
+       public DocumentCharacterIterator(IDocument document, int first) throws IllegalArgumentException {
+               this(document, first, document.getLength());
+       }
+
+       /**
+        * Creates an iterator for the document contents from <code>first</code>
+        * (inclusive) to <code>last</code> (exclusive).
+        *
+        * @param document the document backing this iterator
+        * @param first the first character to consider
+        * @param last the last character index to consider
+        * @throws IllegalArgumentException if the indices are out of bounds
+        */
+       public DocumentCharacterIterator(IDocument document, int first, int last) throws IllegalArgumentException {
+               if (document == null)
+                       throw new NullPointerException();
+               if (first < 0 || first > last)
+                       throw new IllegalArgumentException();
+               if (last > document.getLength())
+                       throw new IllegalArgumentException();
+               fDocument= document;
+               fFirst= first;
+               fLast= last;
+               fIndex= first;
+               invariant();
+       }
+
+       /*
+        * @see java.text.CharacterIterator#first()
+        */
+       public char first() {
+               return setIndex(getBeginIndex());
+       }
+
+       /*
+        * @see java.text.CharacterIterator#last()
+        */
+       public char last() {
+               if (fFirst == fLast)
+                       return setIndex(getEndIndex());
+               return setIndex(getEndIndex() - 1);
+       }
+
+       /*
+        * @see java.text.CharacterIterator#current()
+        */
+       public char current() {
+               if (fIndex >= fFirst && fIndex < fLast)
+                       try {
+                               return fDocument.getChar(fIndex);
+                       } catch (BadLocationException e) {
+                               // ignore
+                       }
+               return DONE;
+       }
+
+       /*
+        * @see java.text.CharacterIterator#next()
+        */
+       public char next() {
+               return setIndex(Math.min(fIndex + 1, getEndIndex()));
+       }
+
+       /*
+        * @see java.text.CharacterIterator#previous()
+        */
+       public char previous() {
+               if (fIndex > getBeginIndex()) {
+                       return setIndex(fIndex - 1);
+               }
+               return DONE;
+       }
+
+       /*
+        * @see java.text.CharacterIterator#setIndex(int)
+        */
+       public char setIndex(int position) {
+               if (position >= getBeginIndex() && position <= getEndIndex())
+                       fIndex= position;
+               else
+                       throw new IllegalArgumentException();
+
+               invariant();
+               return current();
+       }
+
+       /*
+        * @see java.text.CharacterIterator#getBeginIndex()
+        */
+       public int getBeginIndex() {
+               return fFirst;
+       }
+
+       /*
+        * @see java.text.CharacterIterator#getEndIndex()
+        */
+       public int getEndIndex() {
+               return fLast;
+       }
+
+       /*
+        * @see java.text.CharacterIterator#getIndex()
+        */
+       public int getIndex() {
+               return fIndex;
+       }
+
+       /*
+        * @see java.text.CharacterIterator#clone()
+        */
+       @Override
+       public Object clone() {
+               try {
+                       return super.clone();
+               } catch (CloneNotSupportedException e) {
+                       throw new InternalError();
+               }
+       }
+
+       /*
+        * @see java.lang.CharSequence#length()
+        */
+       public int length() {
+               return getEndIndex() - getBeginIndex();
+       }
+
+       /**
+        * {@inheritDoc}
+        * <p>
+        * Note that, if the document is modified concurrently, this method may
+        * return {@link CharacterIterator#DONE} if a {@link BadLocationException}
+        * was thrown when accessing the backing document.
+        * </p>
+        *
+        * @param index {@inheritDoc}
+        * @return {@inheritDoc}
+        */
+       public char charAt(int index) {
+               if (index >= 0 && index < length())
+                       try {
+                               return fDocument.getChar(getBeginIndex() + index);
+                       } catch (BadLocationException e) {
+                               // ignore and return DONE
+                               return DONE;
+                       }
+               throw new IndexOutOfBoundsException();
+       }
+
+       /*
+        * @see java.lang.CharSequence#subSequence(int, int)
+        */
+       public CharSequence subSequence(int start, int end) {
+               if (start < 0)
+                       throw new IndexOutOfBoundsException();
+               if (end < start)
+                       throw new IndexOutOfBoundsException();
+               if (end > length())
+                       throw new IndexOutOfBoundsException();
+               return new DocumentCharacterIterator(fDocument, getBeginIndex() + start, getBeginIndex() + end);
+       }
+       
+       /*
+        * @see java.lang.CharSequence#toString()
+        */
+       @Override
+       public String toString() {
+               int length = length();
+               char[] chs = new char[length];
+               for (int i=0; i<length; ++i) {
+                       chs[i] = charAt(i);
+               }
+               return new String(chs);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitionScanner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitionScanner.java
new file mode 100644 (file)
index 0000000..ea24247
--- /dev/null
@@ -0,0 +1,766 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *     Andrew Ferguson (Symbian)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.text.rules.IPartitionTokenScanner;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.Token;
+
+import org.eclipse.cdt.ui.text.ICPartitions;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
+
+
+/**
+ * This scanner recognizes the C multi line comments, C single line comments,
+ * C strings, C characters and C preprocessor directives.
+ */
+public final class FastCPartitionScanner implements IPartitionTokenScanner, ICPartitions {
+
+       // states
+       private static final int CCODE= 0;
+       private static final int SINGLE_LINE_COMMENT= 1;
+       private static final int MULTI_LINE_COMMENT= 2;
+       private static final int CHARACTER= 3;
+       private static final int STRING= 4;
+       private static final int RAW_STRING= 5;
+       private static final int PREPROCESSOR= 6;
+       private static final int PREPROCESSOR_MULTI_LINE_COMMENT= 7;
+       private static final int PREPROCESSOR_STRING= 8;
+       private static final int SINGLE_LINE_DOC_COMMENT= 9;
+       private static final int MULTI_LINE_DOC_COMMENT= 10;
+       
+       /**
+        * Sub state for raw strings.
+        */
+       private enum RawStringState {
+               OPEN_DELIMITER,
+               CONTENT,
+               CLOSE_DELIMITER
+       }
+       
+       // beginning of prefixes and postfixes
+       private static final int NONE= 0;
+       private static final int BACKSLASH= 1; // postfix for STRING, CHARACTER and SINGLE_LINE_COMMENT
+       private static final int SLASH= 2; // prefix for SINGLE_LINE or MULTI_LINE
+       private static final int SLASH_STAR= 3; // prefix for MULTI_LINE_COMMENT
+       private static final int STAR= 4; // postfix for MULTI_LINE_COMMENT
+       private static final int CARRIAGE_RETURN=5; // postfix for STRING, CHARACTER and SINGLE_LINE_COMMENT
+       private static final int BACKSLASH_CR= 6; // postfix for STRING, CHARACTER and SINGLE_LINE_COMMENT
+       private static final int BACKSLASH_BACKSLASH= 7; // postfix for STRING, CHARACTER
+       private static final int RAW_STRING_R= 8; // prefix for RAW_STRING
+       private static final int IDENT= 9;
+       
+       /** The scanner. */
+       private final BufferedDocumentScanner fScanner= new BufferedDocumentScanner(1000);      // faster implementation
+       
+       /** The offset of the last returned token. */
+       private int fTokenOffset;
+       /** The length of the last returned token. */
+       private int fTokenLength;
+       
+       /** The state of the scanner. */
+       private int fState;
+       /** The last significant characters read. */
+       private int fLast;
+       /** The amount of characters already read on first call to nextToken(). */
+       private int fPrefixLength;
+       /** Indicate whether current char is first non-whitespace char on the line*/
+       private boolean fFirstCharOnLine= true;
+       /** An optional (possibly null) comment owner for detecting documentation-comments */
+       private final IDocCommentOwner fOwner;
+       
+       private IDocument fDocument;
+       
+       private final IToken[] fTokens= new IToken[] {
+               new Token(null),
+               new Token(C_SINGLE_LINE_COMMENT),
+               new Token(C_MULTI_LINE_COMMENT),
+               new Token(C_CHARACTER),
+               new Token(C_STRING),
+               new Token(C_STRING),
+               new Token(C_PREPROCESSOR),
+               new Token(C_MULTI_LINE_COMMENT),
+               new Token(C_PREPROCESSOR),
+               new Token(C_SINGLE_LINE_DOC_COMMENT),
+               new Token(C_MULTI_LINE_DOC_COMMENT)
+       };
+       
+       private final StringBuilder fRawStringDelimiter = new StringBuilder(12);
+
+       public FastCPartitionScanner(IDocCommentOwner owner) {
+          fOwner = owner;
+       }
+       
+       public FastCPartitionScanner() {
+           this(null);
+       }
+
+       /*
+        * @see org.eclipse.jface.text.rules.ITokenScanner#nextToken()
+        */
+       public IToken nextToken() {
+
+               fTokenOffset += fTokenLength;
+               fTokenLength= fPrefixLength;
+
+               RawStringState rawStringState = RawStringState.OPEN_DELIMITER;
+               int rawStringDelimiterIdx = 0;
+               
+               while (true) {
+                       final int ch= fScanner.read();
+                       
+                       final boolean isFirstCharOnLine= fFirstCharOnLine;
+                       if (isFirstCharOnLine && ch != ' ' && ch != '\t') {
+                               fFirstCharOnLine= false;
+                       }
+                       // characters
+                       switch (ch) {
+                       case ICharacterScanner.EOF:
+                               fLast= NONE; // ignore last
+                               if (fTokenLength > 0) {
+                                       return preFix(fState, CCODE, NONE, 0);
+
+                               } else {
+                                       fPrefixLength= 0;
+                                       return Token.EOF;
+                               }
+
+                       case '\r':
+                               fFirstCharOnLine= true;
+                               if (fLast == BACKSLASH || fLast == BACKSLASH_BACKSLASH) {
+                                       fLast= BACKSLASH_CR;
+                                       fTokenLength++;
+                                       continue;
+                               } else if (fLast != CARRIAGE_RETURN) {
+                                       fLast= CARRIAGE_RETURN;
+                                       fTokenLength++;
+                                       continue;
+                               } else {
+                                       // fLast == CARRIAGE_RETURN
+                                       switch (fState) {
+                                       case SINGLE_LINE_COMMENT:
+                                       case CHARACTER:
+                                       case STRING:
+                                       case PREPROCESSOR:
+                                               if (fTokenLength > 0) {
+                                                       IToken token= fTokens[fState];
+                                                       fLast= CARRIAGE_RETURN;
+                                                       fPrefixLength= 1;
+
+                                                       fState= CCODE;
+                                                       return token;
+
+                                               } else {
+                                                       consume();
+                                                       continue;
+                                               }
+
+                                       default:
+                                               consume();
+                                               continue;
+                                       }
+                               }
+
+                       case '\\':
+                               switch (fState) {
+                               case CHARACTER:
+                               case STRING:
+                               case PREPROCESSOR_STRING:
+                                       fTokenLength++;
+                                       fLast= fLast == BACKSLASH ? BACKSLASH_BACKSLASH : BACKSLASH;
+                                       continue;
+                               default:
+                                       fTokenLength++;
+                                       fLast= BACKSLASH;
+                                       continue;
+                               }
+
+                       case '\n':
+                               fFirstCharOnLine= true;
+                               switch (fState) {
+                               case SINGLE_LINE_COMMENT:
+                               case CHARACTER:
+                               case STRING:
+                               case PREPROCESSOR:
+                               case PREPROCESSOR_STRING:
+                                       // assert(fTokenLength > 0);
+                                       // if last char was a backslash then we have spliced line
+                                       if (fLast != BACKSLASH && fLast != BACKSLASH_CR && fLast != BACKSLASH_BACKSLASH) {
+                                               return postFix(fState);
+                                       }
+                                       consume();
+                                       continue;
+
+                               default:
+                                       consume();
+                                       continue;
+                               }
+
+                       default:
+                               if (fLast == CARRIAGE_RETURN) {
+                                       switch (fState) {
+                                       case SINGLE_LINE_COMMENT:
+                                       case CHARACTER:
+                                       case STRING:
+                                       case PREPROCESSOR:
+                                       case PREPROCESSOR_STRING:
+
+                                               int last;
+                                               int newState;
+                                               switch (ch) {
+                                               case '/':
+                                                       last= SLASH;
+                                                       newState= CCODE;
+                                                       break;
+
+                                               case '*':
+                                                       last= STAR;
+                                                       newState= CCODE;
+                                                       break;
+
+                                               case '\'':
+                                                       last= NONE;
+                                                       newState= CHARACTER;
+                                                       break;
+
+                                               case '"':
+                                                       last= NONE;
+                                                       newState= STRING;
+                                                       break;
+
+                                               case '\r':
+                                                       last= CARRIAGE_RETURN;
+                                                       newState= CCODE;
+                                                       break;
+
+                                               case '\\':
+                                                       last= BACKSLASH;
+                                                       newState= CCODE;
+                                                       break;
+
+                                               case '#':
+                                                       last= NONE;
+                                                       newState= PREPROCESSOR;
+                                                       break;
+
+                                               default:
+                                                       last= NONE;
+                                                       newState= CCODE;
+                                                       break;
+                                               }
+
+                                               fLast= NONE; // ignore fLast
+                                               return preFix(fState, newState, last, 1);
+
+                                       case CCODE:
+                                               if (ch == '#' && isFirstCharOnLine) {
+                                                       fLast= NONE; // ignore fLast
+                                                       int column= fScanner.getColumn() - 1;
+                                                       fTokenLength -= column;
+                                                       if (fTokenLength > 0) {
+                                                               return preFix(fState, PREPROCESSOR, NONE, column + 1);
+                                                       } else {
+                                                               preFix(fState, PREPROCESSOR, NONE, column + 1);
+                                                               fTokenOffset += fTokenLength;
+                                                               fTokenLength= fPrefixLength;
+                                                               break;
+                                                       }
+                                               }
+                                               break;
+
+                                       default:
+                                               break;
+                                       }
+                               }
+                       }
+
+                       // states
+                       switch (fState) {
+                       case CCODE:
+                               switch (ch) {
+                               case '/':
+                                       if (fLast == SLASH) {
+                                               if (fTokenLength - getLastLength(fLast) > 0) {
+                                                       return preFix(CCODE, SINGLE_LINE_COMMENT, NONE, 2);
+                                               } else {
+                                                       preFix(CCODE, SINGLE_LINE_COMMENT, NONE, 2);
+                                                       fTokenOffset += fTokenLength;
+                                                       fTokenLength= fPrefixLength;
+                                                       break;
+                                               }
+       
+                                       } else {
+                                               fTokenLength++;
+                                               fLast= SLASH;
+                                               break;
+                                       }
+       
+                               case '*':
+                                       if (fLast == SLASH) {
+                                               if (fTokenLength - getLastLength(fLast) > 0) {
+                                                       return preFix(CCODE, MULTI_LINE_COMMENT, SLASH_STAR, 2);
+                                               } else {
+                                                       preFix(CCODE, MULTI_LINE_COMMENT, SLASH_STAR, 2);
+                                                       fTokenOffset += fTokenLength;
+                                                       fTokenLength= fPrefixLength;
+                                                       break;
+                                               }
+
+                                       } else {
+                                               consume();
+                                               break;
+                                       }
+                                       
+                               case '\'':
+                                       fLast= NONE; // ignore fLast
+                                       if (fTokenLength > 0) {
+                                               return preFix(CCODE, CHARACTER, NONE, 1);
+                                       } else {
+                                               preFix(CCODE, CHARACTER, NONE, 1);
+                                               fTokenOffset += fTokenLength;
+                                               fTokenLength= fPrefixLength;
+                                               break;
+                                       }
+
+                               case 'u':
+                               case 'U':
+                               case 'L':
+                                       if (fLast != IDENT) {
+                                               fLast = NONE;
+                                       }
+                                       fTokenLength++;
+                                       continue;
+                                       
+                               case 'R':
+                                       if (fLast == RAW_STRING_R) {
+                                               fLast = IDENT;
+                                       } else if (fLast != IDENT) {
+                                               fLast = RAW_STRING_R;
+                                       }
+                                       fTokenLength++;
+                                       continue;
+
+                               case '"':
+                                       int newState = STRING;
+                                       if (fLast == RAW_STRING_R) {
+                                               newState = RAW_STRING;
+                                               rawStringState = RawStringState.OPEN_DELIMITER;
+                                               fRawStringDelimiter.setLength(0);
+                                       }
+                                       fLast= NONE; // ignore fLast
+                                       if (fTokenLength > 0 ) {
+                                               return preFix(CCODE, newState, NONE, 1);
+                                       } else {
+                                               preFix(CCODE, newState, NONE, 1);
+                                               fTokenOffset += fTokenLength;
+                                               fTokenLength= fPrefixLength;
+                                               break;
+                                       }
+                                       
+                               case '#':
+                                       if (isFirstCharOnLine) {
+                                               int column= fScanner.getColumn() - 1;
+                                               fTokenLength -= column;
+                                               if (fTokenLength > 0) {
+                                                       return preFix(fState, PREPROCESSOR, NONE, column + 1);
+                                               } else {
+                                                       preFix(fState, PREPROCESSOR, NONE, column + 1);
+                                                       fTokenOffset += fTokenLength;
+                                                       fTokenLength= fPrefixLength;
+                                                       break;
+                                               }
+                                       }
+                                       consume();
+                                       break;
+                               default:
+                                       if ('a' <= ch && ch <= 'z' || 'A' <= ch && ch <= 'Z' || ch =='_') {
+                                               fLast = IDENT;
+                                               fTokenOffset++;
+                                       } else if ('0' <= ch && ch <= '9' && fLast == IDENT) {
+                                               fTokenOffset++;
+                                       } else {
+                                               consume();
+                                       }
+                                       break;
+                               }
+                               break;
+
+                       case SINGLE_LINE_COMMENT:
+                               consume();
+                               break;
+
+                       case PREPROCESSOR:
+                               switch (ch) {
+                               case '/':
+                                       if (fLast == SLASH) {
+                                               if (fTokenLength - getLastLength(fLast) > 0) {
+                                                       return preFix(fState, SINGLE_LINE_COMMENT, SLASH, 2);
+                                               } else {
+                                                       preFix(fState, SINGLE_LINE_COMMENT, SLASH, 2);
+                                                       fTokenOffset += fTokenLength;
+                                                       fTokenLength= fPrefixLength;
+                                                       break;
+                                               }
+                                       } else {
+                                               fTokenLength++;
+                                               fLast= SLASH;
+                                       }
+                                       break;
+       
+                               case '*':
+                                       if (fLast == SLASH) {
+                                               if (fTokenLength - getLastLength(fLast) > 0) {
+                                                       return preFix(fState, PREPROCESSOR_MULTI_LINE_COMMENT, SLASH_STAR, 2);
+                                               } else {
+                                                       preFix(fState, PREPROCESSOR_MULTI_LINE_COMMENT, SLASH_STAR, 2);
+                                                       fTokenOffset += fTokenLength;
+                                                       fTokenLength= fPrefixLength;
+                                                       break;
+                                               }
+                                       }
+                                       consume();
+                                       break;
+
+                               case '"':
+                                       if (fLast != BACKSLASH) {
+                                               fState= PREPROCESSOR_STRING;
+                                       }
+                                       consume();
+                                       break;
+                                       
+                               default:
+                                       consume();
+                                       break;
+                               }
+                               break;
+
+                       case PREPROCESSOR_STRING:
+                               switch (ch) {
+                               case '"':
+                                       if (fLast != BACKSLASH) {
+                                               fState= PREPROCESSOR;
+                                       }
+                                       consume();
+                                       break;
+                                       
+                               default:
+                                       consume();
+                                       break;
+                               }
+                               break;
+                               
+                       case PREPROCESSOR_MULTI_LINE_COMMENT:
+                               switch (ch) {
+                               case '*':
+                                       fTokenLength++;
+                                       fLast= STAR;
+                                       break;
+       
+                               case '/':
+                                       if (fLast == STAR) {
+                                               IToken token= postFix(fState);
+                                               fState= PREPROCESSOR;
+                                               return token;
+                                       }
+                                       consume();
+                                       break;
+       
+                               default:
+                                       consume();
+                                       break;
+                               }
+                               break;
+                               
+                       case MULTI_LINE_COMMENT:
+                               switch (ch) {
+                               case '*':
+                                       fTokenLength++;
+                                       fLast= STAR;
+                                       break;
+       
+                               case '/':
+                                       if (fLast == STAR) {
+                                               return postFix(MULTI_LINE_COMMENT);
+                                       } else {
+                                               consume();
+                                               break;
+                                       }
+       
+                               default:
+                                       consume();
+                                       break;
+                               }
+                               break;
+                               
+                       case STRING:
+                               switch (ch) {
+                               case '\"':
+                                       if (fLast != BACKSLASH) {
+                                               return postFix(STRING);
+                                       } else {
+                                               consume();
+                                               break;
+                                       }
+                               
+                               default:
+                                       consume();
+                                       break;
+                               }
+                               break;
+
+                       case RAW_STRING:
+                               switch (rawStringState) {
+                               case OPEN_DELIMITER:
+                                       if (ch == '(') {
+                                               rawStringState = RawStringState.CONTENT;
+                                       } else if (ch == '"') {
+                                               return postFix(RAW_STRING);
+                                       } else if (ch != ' ' && ch != '\\' && ch != ')' && fRawStringDelimiter.length() < 12) {
+                                               fRawStringDelimiter.append((char) ch);
+                                       } else {
+                                               fState = STRING;
+                                       }
+                                       consume();
+                                       break;
+                               case CONTENT:
+                                       if (ch == ')') {
+                                               rawStringState = RawStringState.CLOSE_DELIMITER;
+                                               rawStringDelimiterIdx = 0;
+                                       }
+                                       consume();
+                                       break;
+                               case CLOSE_DELIMITER:
+                                       if (ch == ')') {
+                                               rawStringDelimiterIdx = 0;
+                                       } else if (rawStringDelimiterIdx < fRawStringDelimiter.length()) {
+                                               if (fRawStringDelimiter.charAt(rawStringDelimiterIdx) != ch) {
+                                                       rawStringState = RawStringState.CONTENT;
+                                               } else {
+                                                       ++rawStringDelimiterIdx;
+                                               }
+                                       } else if (ch == '"') {
+                                               return postFix(RAW_STRING);
+                                       } else {
+                                               rawStringState = RawStringState.CONTENT;
+                                       }
+                                       consume();
+                                       break;
+                               }
+                               break;
+
+                       case CHARACTER:
+                               switch (ch) {
+                               case '\'':
+                                       if (fLast != BACKSLASH) {
+                                               return postFix(CHARACTER);
+                                       } else {
+                                               consume();
+                                               break;
+                                       }
+       
+                               default:
+                                       consume();
+                                       break;
+                               }
+                               break;
+                       }
+               }
+       }
+
+       private static final int getLastLength(int last) {
+               switch (last) {
+               default:
+                       return -1;
+
+               case NONE:
+               case IDENT:
+                       return 0;
+                       
+               case CARRIAGE_RETURN:
+               case BACKSLASH:
+               case SLASH:
+               case STAR:
+               case RAW_STRING_R:
+                       return 1;
+
+               case SLASH_STAR:
+               case BACKSLASH_CR:
+               case BACKSLASH_BACKSLASH:
+                       return 2;
+
+               }
+       }
+
+       private final void consume() {
+               fTokenLength++;
+               fLast= NONE;
+       }
+       
+       private final IToken postFix(int state) {
+               return postFix(state, CCODE);
+       }
+       
+       private final IToken postFix(int state, int newState) {
+               fTokenLength++;
+               fLast= NONE;
+               fState= newState;
+               fPrefixLength= 0;
+               return fTokens[interceptTokenState(state)];
+       }
+
+
+       private final IToken preFix(int state, int newState, int last, int prefixLength) {
+               fTokenLength -= getLastLength(fLast);
+               fLast= last;
+               fPrefixLength= prefixLength;
+               fState= newState;
+               return fTokens[interceptTokenState(state)];
+       }
+
+       private static int getState(String contentType) {
+
+               if (contentType == null)
+                       return CCODE;
+
+               else if (contentType.equals(C_SINGLE_LINE_COMMENT))
+                       return SINGLE_LINE_COMMENT;
+
+               else if (contentType.equals(C_MULTI_LINE_COMMENT))
+                       return MULTI_LINE_COMMENT;
+
+               else if (contentType.equals(C_STRING))
+                       return STRING;
+
+               else if (contentType.equals(C_CHARACTER))
+                       return CHARACTER;
+
+               else if (contentType.equals(C_PREPROCESSOR))
+                       return PREPROCESSOR;
+               
+               else if (contentType.equals(C_SINGLE_LINE_DOC_COMMENT))
+                       return SINGLE_LINE_COMMENT; // intentionally non-doc state: the state machine is doc-comment unaware
+
+               else if (contentType.equals(C_MULTI_LINE_DOC_COMMENT))
+                       return MULTI_LINE_COMMENT; // intentionally non-doc state: the state machine is doc-comment unaware
+               
+               else
+                       return CCODE;
+       }
+
+       /*
+        * @see IPartitionTokenScanner#setPartialRange(IDocument, int, int, String, int)
+        */
+       public void setPartialRange(IDocument document, int offset, int length, String contentType, int partitionOffset) {
+               fDocument= document;
+               fScanner.setRange(document, offset, length);
+               fTokenOffset= partitionOffset;
+               fTokenLength= 0;
+               fPrefixLength= offset - partitionOffset;
+               fLast= NONE;
+               
+               fState= getState(contentType);
+               if (fState == STRING) {
+                       // raw string is a special case: need to restart from partition offset
+                       try {
+                               if (partitionOffset > 0 && fDocument.getChar(partitionOffset - 1) == 'R') {
+                                       fState = RAW_STRING;
+                                       int endOffset = offset + length;
+                                       offset = partitionOffset + 1;
+                                       length = endOffset - offset;
+                                       fScanner.setRange(document, offset, length);
+                                       fPrefixLength = offset - partitionOffset;
+                                       fRawStringDelimiter.setLength(0);
+                               }
+                       } catch (BadLocationException exc) {
+                               // cannot happen
+                       }
+               }
+               if (offset == partitionOffset) {
+                       // restart at beginning of partition
+                       fState= CCODE;
+               }
+
+               try {
+                       int column= fScanner.getColumn();
+                       fFirstCharOnLine= column == 0 || document.get(offset-column, column).trim().length() == 0;
+               } catch (BadLocationException exc) {
+                       fFirstCharOnLine= true;
+               }
+       }
+
+       /*
+        * @see ITokenScanner#setRange(IDocument, int, int)
+        */
+       public void setRange(IDocument document, int offset, int length) {
+               fDocument= document;
+               fScanner.setRange(document, offset, length);
+               fTokenOffset= offset;
+               fTokenLength= 0;
+               fPrefixLength= 0;
+               fLast= NONE;
+               fState= CCODE;
+
+               try {
+                       int column= fScanner.getColumn();
+                       fFirstCharOnLine= column == 0 || document.get(offset-column, column).trim().length() == 0;
+               } catch (BadLocationException exc) {
+                       fFirstCharOnLine= true;
+               }
+       }
+
+       /*
+        * @see ITokenScanner#getTokenLength()
+        */
+       public int getTokenLength() {
+               return fTokenLength;
+       }
+
+       /*
+        * @see ITokenScanner#getTokenOffset()
+        */
+       public int getTokenOffset() {
+               return fTokenOffset;
+       }
+
+       private int interceptTokenState(int proposedTokenState) {
+               if(fOwner!=null) {
+                       switch(proposedTokenState) {
+                       case MULTI_LINE_COMMENT:
+                               if(fOwner.getMultilineConfiguration().isDocumentationComment(fDocument, fTokenOffset, fTokenLength))
+                                       return MULTI_LINE_DOC_COMMENT;
+                               break;
+
+                       case SINGLE_LINE_COMMENT:
+                               if(fOwner.getSinglelineConfiguration().isDocumentationComment(fDocument, fTokenOffset, fTokenLength))
+                                       return SINGLE_LINE_DOC_COMMENT;
+                               break;
+
+                       }
+               }
+               return proposedTokenState;
+       }
+       
+       /**
+        * @return the DocCommentOwner associated with this partition scanner, or null
+        * if there is no owner.
+        * @since 5.0
+        */
+       public IDocCommentOwner getDocCommentOwner() {
+               return fOwner;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitioner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/FastCPartitioner.java
new file mode 100644 (file)
index 0000000..6965b4f
--- /dev/null
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *     Andrew Ferguson (Symbian)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.rules.FastPartitioner;
+import org.eclipse.jface.text.rules.IPartitionTokenScanner;
+
+import org.eclipse.cdt.ui.text.ICPartitions;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
+
+/**
+ * A slightly adapted FastPartitioner.
+ */
+public class FastCPartitioner extends FastPartitioner {
+
+       /**
+        * Creates a new partitioner for the given content types.
+        * 
+        * @param scanner
+        * @param legalContentTypes
+        */
+       public FastCPartitioner(IPartitionTokenScanner scanner, String[] legalContentTypes) {
+               super(scanner, legalContentTypes);
+       }
+
+       @Override
+       public ITypedRegion getPartition(int offset, boolean preferOpenPartitions) {
+               if (preferOpenPartitions && offset == fDocument.getLength() && offset > 0) {
+                       ITypedRegion region = super.getPartition(offset - 1, false);
+                       try {
+                               if (ICPartitions.C_MULTI_LINE_COMMENT.equals(region.getType())) {
+                                       if (!fDocument.get(offset - 2, 2).equals("*/")) { //$NON-NLS-1$
+                                               return region;
+                                       }
+                               } else if (ICPartitions.C_SINGLE_LINE_COMMENT.equals(region.getType())) {
+                                       if (fDocument.getChar(offset - 1) != '\n') {
+                                               return region;
+                                       }
+                               } else if (ICPartitions.C_MULTI_LINE_DOC_COMMENT.equals(region.getType())) {
+                                       if (!fDocument.get(offset - 2, 2).equals("*/")) { //$NON-NLS-1$
+                                               return region;
+                                       }
+                               } else if (ICPartitions.C_SINGLE_LINE_DOC_COMMENT.equals(region.getType())) {
+                                       if (fDocument.getChar(offset - 1) != '\n') {
+                                               return region;
+                                       }
+                               } else if (ICPartitions.C_PREPROCESSOR.equals(region.getType())) {
+                                       if (fDocument.getChar(offset - 1) != '\n') {
+                                               return region;
+                                       }
+                               }
+                       } catch (BadLocationException exc) {
+                       }
+               }
+               return super.getPartition(offset, preferOpenPartitions);
+       }
+       
+       /**
+        * @return the DocCommentOwner associated with this partition scanner, or null
+        * if there is no owner.
+        * @since 5.0
+        */
+       public IDocCommentOwner getDocCommentOwner() {
+               if(fScanner instanceof FastCPartitionScanner) {
+                       return ((FastCPartitionScanner)fScanner).getDocCommentOwner();
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLAnnotationHover.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLAnnotationHover.java
new file mode 100644 (file)
index 0000000..c3e5417
--- /dev/null
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.text.source.DefaultAnnotationHover;
+
+import org.eclipse.cdt.internal.ui.CUIMessages;
+
+/**
+ * Determines all annotations for the given line and collects, concatenates, and formats
+ * their messages in HTML.
+ *
+ * @since 4.0
+ */
+public class HTMLAnnotationHover extends DefaultAnnotationHover {
+
+       /*
+        * Formats a message as HTML text.
+        */
+       @Override
+       protected String formatSingleMessage(String message) {
+               StringBuffer buffer= new StringBuffer();
+               HTMLPrinter.addPageProlog(buffer);
+               HTMLPrinter.addParagraph(buffer, HTMLPrinter.convertToHTMLContent(message));
+               HTMLPrinter.addPageEpilog(buffer);
+               return buffer.toString();
+       }
+
+       /*
+        * Formats several message as HTML text.
+        */
+       @SuppressWarnings({ "unchecked", "rawtypes" })
+       @Override
+       protected String formatMultipleMessages(List messages) {
+               StringBuffer buffer= new StringBuffer();
+               HTMLPrinter.addPageProlog(buffer);
+               HTMLPrinter.addParagraph(buffer, HTMLPrinter.convertToHTMLContent(CUIMessages.CAnnotationHover_multipleMarkers)); 
+
+               HTMLPrinter.startBulletList(buffer);
+               Iterator<String> e= messages.iterator();
+               while (e.hasNext())
+                       HTMLPrinter.addBullet(buffer, HTMLPrinter.convertToHTMLContent(e.next()));
+               HTMLPrinter.endBulletList(buffer);
+
+               HTMLPrinter.addPageEpilog(buffer);
+               return buffer.toString();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLPrinter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLPrinter.java
new file mode 100644 (file)
index 0000000..b8aacea
--- /dev/null
@@ -0,0 +1,179 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Intel corp.
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import java.io.IOException;
+import java.io.Reader;
+
+
+/**
+ * Provides a set of convenience methods for creating HTML pages.
+ */
+public class HTMLPrinter {
+
+       private static final String LB = "<"; //$NON-NLS-1$
+       private static final String CB = "</"; //$NON-NLS-1$
+       private static final String RB = ">"; //$NON-NLS-1$
+       
+       
+       private HTMLPrinter() {
+       }
+       
+       private static String replace(String text, char c, String s) {
+                               
+               int previous= 0;
+               int current= text.indexOf(c, previous);
+               
+               if (current == -1)
+                       return text;
+               
+               StringBuilder buffer= new StringBuilder();      
+               while (current > -1) {
+                       buffer.append(text.substring(previous, current));
+                       buffer.append(s);
+                       previous= current + 1;
+                       current= text.indexOf(c, previous);
+               }
+               buffer.append(text.substring(previous));
+               
+               return buffer.toString();
+       }
+       
+       public static String convertToHTMLContent(String content) {
+               content= replace(content, '<', "&lt;"); //$NON-NLS-1$
+               return replace(content, '>', "&gt;"); //$NON-NLS-1$
+       }
+       
+       public static String read(Reader rd) {
+               
+               StringBuilder buffer= new StringBuilder();
+               char[] readBuffer= new char[2048];
+               
+               try {
+                       int n= rd.read(readBuffer);
+                       while (n > 0) {
+                               buffer.append(readBuffer, 0, n);
+                               n= rd.read(readBuffer);
+                       }
+                       return buffer.toString();
+               } catch (IOException x) {
+               }
+               
+               return null;
+       }
+
+       public static void insertPageProlog(StringBuffer buffer, int position) {
+               buffer.insert(position, "<html><body text=\"#000000\" bgcolor=\"#FFFF88\"><font size=-1>"); //$NON-NLS-1$
+       }
+       
+       public static void insertPageProlog(StringBuilder buffer, int position) {
+               buffer.insert(position, "<html><body text=\"#000000\" bgcolor=\"#FFFF88\"><font size=-1>"); //$NON-NLS-1$
+       }
+       
+       public static void addPageProlog(StringBuffer buffer) {
+               insertPageProlog(buffer, buffer.length());
+       }
+       
+       public static void addPageProlog(StringBuilder buffer) {
+               insertPageProlog(buffer, buffer.length());
+       }
+
+       public static void addPageEpilog(StringBuffer buffer) {
+               buffer.append("</font></body></html>"); //$NON-NLS-1$
+       }
+       
+       public static void addPageEpilog(StringBuilder buffer) {
+               buffer.append("</font></body></html>"); //$NON-NLS-1$
+       }
+
+       public static void startBulletList(StringBuffer buffer) {
+               buffer.append("<ul>"); //$NON-NLS-1$
+       }
+       
+       public static void startBulletList(StringBuilder buffer) {
+               buffer.append("<ul>"); //$NON-NLS-1$
+       }
+       
+       public static void endBulletList(StringBuffer buffer) {
+               buffer.append("</ul>"); //$NON-NLS-1$
+       }
+
+       public static void endBulletList(StringBuilder buffer) {
+               buffer.append("</ul>"); //$NON-NLS-1$
+       }
+
+       private static void addTag(StringBuffer buffer, String bullet, String tag) {
+               if (bullet != null && tag != null) {
+                       buffer.append(LB);
+                       buffer.append(tag);
+                       buffer.append(RB);
+                       buffer.append(bullet);
+                       buffer.append(CB);
+                       buffer.append(tag);
+                       buffer.append(RB);
+               }
+       }
+       
+       private static void addTag(StringBuilder buffer, String bullet, String tag) {
+               if (bullet != null && tag != null) {
+                       buffer.append(LB);
+                       buffer.append(tag);
+                       buffer.append(RB);
+                       buffer.append(bullet);
+                       buffer.append(CB);
+                       buffer.append(tag);
+                       buffer.append(RB);
+               }
+       }
+       
+       public static void addBullet(StringBuffer buffer, String bullet) {
+               addTag(buffer, bullet, "li"); //$NON-NLS-1$
+       }
+       
+       public static void addBullet(StringBuilder buffer, String bullet) {
+               addTag(buffer, bullet, "li"); //$NON-NLS-1$
+       }
+
+       public static void addSmallHeader(StringBuffer buffer, String header) {
+               addTag(buffer, header, "h5"); //$NON-NLS-1$
+       }
+       
+       public static void addSmallHeader(StringBuilder buffer, String header) {
+               addTag(buffer, header, "h5"); //$NON-NLS-1$
+       }
+
+       public static void addParagraph(StringBuffer buffer, String paragraph) {
+               if (paragraph != null) {
+                       buffer.append("<p>"); //$NON-NLS-1$
+                       buffer.append(paragraph);
+               }
+       }
+
+       public static void addParagraph(StringBuilder buffer, String paragraph) {
+               if (paragraph != null) {
+                       buffer.append("<p>"); //$NON-NLS-1$
+                       buffer.append(paragraph);
+               }
+       }
+
+       public static void addParagraph(StringBuffer buffer, Reader paragraphReader) {
+               if (paragraphReader != null)
+                       addParagraph(buffer, read(paragraphReader));
+       }
+
+       public static void addParagraph(StringBuilder buffer, Reader paragraphReader) {
+               if (paragraphReader != null)
+                       addParagraph(buffer, read(paragraphReader));
+       }
+
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/ICReconcilingListener.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/ICReconcilingListener.java
new file mode 100644 (file)
index 0000000..dbbdb2b
--- /dev/null
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems) - Adapted for CDT
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+
+
+/**
+ * Interface of an object listening to (AST-) reconciling.
+ * Inspired by JDT.
+ * 
+ * @since 4.0
+ */
+public interface ICReconcilingListener {
+
+       /**
+        * Called before reconciling is started.
+        */
+       void aboutToBeReconciled();
+
+       /**
+        * Called after reconciling has been finished.
+        * 
+        * @param ast
+        *            the translation unit AST or <code>null</code> if the working
+        *            copy was consistent or reconcilation has been cancelled
+        * @param force
+        *            flag indicating whether the reconciler was invoked forcefully
+        * @param progressMonitor
+        *            the progress monitor
+        */
+       void reconciled(IASTTranslationUnit ast, boolean force, IProgressMonitor progressMonitor);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IHtmlTagConstants.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IHtmlTagConstants.java
new file mode 100644 (file)
index 0000000..69732c6
--- /dev/null
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text;
+
+/**
+ * Html tag constants.
+ */
+public interface IHtmlTagConstants {
+       /** Html tag close prefix */
+       public static final String HTML_CLOSE_PREFIX= "</"; //$NON-NLS-1$
+
+       /** Html entity characters */
+       public static final char[] HTML_ENTITY_CHARACTERS= new char[] { '<', '>', ' ', '&', '^', '~', '\"' };
+
+       /**
+        * Html entity start.
+        */
+       public static final char HTML_ENTITY_START= '&';
+       /**
+        * Html entity end.
+        */
+       public static final char HTML_ENTITY_END= ';';
+       
+       /** Html entity codes */
+       public static final String[] HTML_ENTITY_CODES= new String[] { "&lt;", "&gt;", "&nbsp;", "&amp;", "&circ;", "&tilde;", "&quot;" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
+
+       /** Html general tags */
+       public static final String[] HTML_GENERAL_TAGS= new String[] { "a", "b", "blockquote", "br", "code", "dd", "dl", "dt", "em", "hr", "h1", "h2", "h3", "h4", "h5", "h6", "i", "li", "nl", "ol", "p", "pre", "q", "strong", "tbody", "td", "th", "tr", "tt", "ul" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ //$NON-NLS-14$ //$NON-NLS-15$ //$NON-NLS-16$ //$NON-NLS-17$ //$NON-NLS-18$ //$NON-NLS-19$ //$NON-NLS-20$ //$NON-NLS-21$ //$NON-NLS-22$ //$NON-NLS-23$ //$NON-NLS-24$ //$NON-NLS-25$ //$NON-NLS-26$ //$NON-NLS-27$ //$NON-NLS-28$ //$NON-NLS-29$ //$NON-NLS-30$
+
+       /** Html tag postfix */
+       public static final char HTML_TAG_POSTFIX= '>';
+
+       /** Html tag prefix */
+       public static final char HTML_TAG_PREFIX= '<';
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IProblemRequestorExtension.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/IProblemRequestorExtension.java
new file mode 100644 (file)
index 0000000..a27b69f
--- /dev/null
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2006 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * Extension to <code>IProblemRequestor</code>.
+ * IProblemRequestorExtension
+ */
+public interface IProblemRequestorExtension {
+       
+       /**
+        * Sets the progress monitor to this problem requestor.
+        * 
+        * @param monitor the progress monitor to be used
+        */
+       void setProgressMonitor(IProgressMonitor monitor);
+       
+       /**
+        * Sets the active state of this problem requestor.
+        * 
+        * @param isActive the state of this problem requestor
+        */
+       void setIsActive(boolean isActive);
+       
+       /**
+        * Informs the problem requestor that a sequence of reportings is about to start. While
+        * a sequence is active, multiple peering calls of <code>beginReporting</code> and
+        * <code>endReporting</code> can appear.
+        * 
+        * @since 3.0
+        */
+       void beginReportingSequence();
+       
+       /**
+        * Informs the problem requestor that the sequence of reportings has been finished.
+        * 
+        * @since 3.0
+        */
+       void endReportingSequence();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/LineComparator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/LineComparator.java
new file mode 100644 (file)
index 0000000..eba6c92
--- /dev/null
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.compare.rangedifferencer.IRangeComparator;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+
+/**
+ * This implementation of <code>IRangeComparator</code> compares lines of a document.
+ * The lines are compared using a DJB hash function.
+ * 
+ * @since 5.1
+ */
+public class LineComparator implements IRangeComparator {
+       private static final long UNKNOWN_HASH = Long.MIN_VALUE;
+       private final IDocument fDocument;
+       private final long[] fHashes;
+
+    /**
+        * Create a line comparator for the given document.
+        * 
+        * @param document
+        */
+       public LineComparator(IDocument document) {
+               fDocument= document;
+
+               fHashes= new long[fDocument.getNumberOfLines()];
+               for (int i = 0; i < fHashes.length; i++) {
+                       fHashes[i] = UNKNOWN_HASH;
+               }
+    }
+
+       /*
+     * @see org.eclipse.compare.rangedifferencer.IRangeComparator#getRangeCount()
+     */
+    public int getRangeCount() {
+        return fDocument.getNumberOfLines();
+    }
+
+    /*
+     * @see org.eclipse.compare.rangedifferencer.IRangeComparator#rangesEqual(int, org.eclipse.compare.rangedifferencer.IRangeComparator, int)
+     */
+    public boolean rangesEqual(int thisIndex, IRangeComparator other, int otherIndex) {
+               try {
+                       return getHash(thisIndex) == ((LineComparator) other).getHash(otherIndex);
+               } catch (BadLocationException e) {
+                       CUIPlugin.log(e);
+                       return false;
+               }
+    }
+
+       /*
+        * @see org.eclipse.compare.rangedifferencer.IRangeComparator#skipRangeComparison(int, int, org.eclipse.compare.rangedifferencer.IRangeComparator)
+        */
+       public boolean skipRangeComparison(int length, int maxLength, IRangeComparator other) {
+               return false;
+       }
+
+       /**
+        * @param line the number of the line in the document to get the hash for
+        * @return the hash of the line
+        * @throws BadLocationException if the line number is invalid
+        */
+       private int getHash(int line) throws BadLocationException {
+               long hash= fHashes[line];
+               if (hash == UNKNOWN_HASH) {
+                       IRegion lineRegion= fDocument.getLineInformation(line);
+                       String lineContents= fDocument.get(lineRegion.getOffset(), lineRegion.getLength());
+                       hash= computeDJBHash(lineContents);
+                       fHashes[line] = hash;
+               }
+
+               return (int) hash;
+       }
+
+       /**
+        * Compute a hash using the DJB hash algorithm
+        * 
+        * @param string the string for which to compute a hash
+        * @return the DJB hash value of the string
+        */
+       private int computeDJBHash(String string) {
+               int hash= 5381;
+               int len= string.length();
+               for (int i= 0; i < len; i++) {
+                       char ch= string.charAt(i);
+                       hash= (hash << 5) + hash + ch;
+               }
+
+               return hash;
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/NumberRule.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/NumberRule.java
new file mode 100644 (file)
index 0000000..c2344f2
--- /dev/null
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2006 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Wind River Systems, Inc. - bug fixes
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.text.rules.IRule;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.Token;
+
+/**
+ * Recognizes integer and float numbers.
+ *
+ * @author P.Tomaszewski
+ */
+public class NumberRule implements IRule
+{
+    /** Style token. */
+    private IToken token;
+
+    
+    /**
+     * Creates new number rule.
+     * @param token Style token. 
+     */
+    public NumberRule(IToken token)
+    {
+        super();
+        this.token = token;
+    }
+
+    /**
+     * @see org.eclipse.jface.text.rules.IRule#evaluate(org.eclipse.jface.text.rules.ICharacterScanner)
+     */
+    public IToken evaluate(ICharacterScanner scanner)
+    {
+        int startCh = scanner.read();
+        int ch;
+        int unreadCount = 1;
+
+        if (isNumberStart(startCh))
+        {
+               ch = startCh;
+            if (startCh == '-' || startCh == '+') {
+               ch = scanner.read();
+               ++unreadCount;
+            }
+            if (ch == '0') {
+               int xCh = scanner.read();
+               if (xCh == 'x' || xCh == 'X') {
+                       // hexnumber starting with [+-]?0[xX]
+                    do {
+                        ch = scanner.read();
+                    } while (isHexNumberPart((char)ch));
+                    scanner.unread();
+                    return token;
+               }
+               scanner.unread();
+               // assert ch == '0';
+            } else if (ch == '.') {
+                ch = scanner.read();
+                ++unreadCount;
+            }
+            if (Character.isDigit((char)ch)) {
+               // need at least one digit
+                   do {
+                       ch = scanner.read();
+                   } while (Character.isDigit((char)ch));
+                   if (ch == '.' && startCh != '.') {
+                       // fraction
+                       do {
+                           ch = scanner.read();
+                       } while (Character.isDigit((char)ch));
+                   }
+                   if (ch == 'e' || ch == 'E') {
+                       // exponent
+                       ch = scanner.read();
+                       if (ch == '-' || ch == '+' || Character.isDigit((char)ch)) {
+                           do {
+                               ch = scanner.read();
+                           } while (Character.isDigit((char)ch));
+                       }
+                   }
+                   scanner.unread();
+                   return token;
+            }
+        }
+        do {
+               scanner.unread();
+        } while (--unreadCount > 0);
+        return Token.UNDEFINED;
+    }
+
+    /**
+     * Checks if start of number.
+     * @param ch Char to check.
+     * @return <b>true</b> if Number.
+     */
+    private boolean isNumberStart(int ch)
+    {
+        return ch == '-' || ch == '+' || ch == '.' || Character.isDigit((char)ch);
+    }
+    
+    /**
+     * Checks if part of hex number;
+     * @param ch Char to check.
+     * @return <b>true</b>
+     */
+    private boolean isHexNumberPart(int ch)
+    {
+        return Character.isDigit((char)ch) || ch == 'a' || ch == 'b'
+            || ch == 'c' || ch == 'd' || ch == 'e' || ch == 'f' || ch == 'A'
+            || ch == 'B' || ch == 'C' || ch == 'D' || ch == 'E' || ch == 'F';
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/PartitionDamager.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/PartitionDamager.java
new file mode 100644 (file)
index 0000000..a16bf0c
--- /dev/null
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.presentation.IPresentationDamager;
+
+/**
+ * A simple presentation damager always damaging the whole partition.
+ * This is necessary if the partition contains multiline highlight regions.
+ * 
+ * @since 4.0
+ */
+public class PartitionDamager implements IPresentationDamager {
+
+       /*
+        * @see org.eclipse.jface.text.presentation.IPresentationDamager#getDamageRegion(org.eclipse.jface.text.ITypedRegion, org.eclipse.jface.text.DocumentEvent, boolean)
+        */
+       public IRegion getDamageRegion(ITypedRegion partition, DocumentEvent event,
+                       boolean documentPartitioningChanged) {
+               if (!documentPartitioningChanged && event.getOffset() == partition.getOffset() + partition.getLength()) {
+                       IRegion lineRegion;
+                       try {
+                               lineRegion = event.fDocument.getLineInformationOfOffset(event.getOffset());
+                               int start= partition.getOffset();
+                               int end= lineRegion.getOffset() + lineRegion.getLength();
+                               return new Region(start, end - start);
+                       } catch (BadLocationException exc) {
+                               // ignore
+                       }
+               }
+               return partition;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.presentation.IPresentationDamager#setDocument(org.eclipse.jface.text.IDocument)
+        */
+       public void setDocument(IDocument document) {
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/PreprocessorRule.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/PreprocessorRule.java
new file mode 100644 (file)
index 0000000..38fc912
--- /dev/null
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ * Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.IWordDetector;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.jface.text.rules.WordRule;
+
+/**
+ * Implementation of <code>IRule</code> for C/C++ preprocessor scanning.
+ * It is capable of detecting a pattern which begins with 0 or more whitespaces 
+ * at the beginning of the string, then '#' sign, then 0 or more whitespaces
+ * again, and then directive itself.
+ */
+public class PreprocessorRule extends WordRule {
+
+       private StringBuffer fBuffer = new StringBuffer();
+       private IToken fMalformedToken;
+
+       /**
+        * Creates a rule which, with the help of a word detector, will return the token
+        * associated with the detected word. If no token has been associated, the scanner 
+        * will be rolled back and an undefined token will be returned in order to allow 
+        * any subsequent rules to analyze the characters.
+        *
+        * @param detector the word detector to be used by this rule, may not be <code>null</code>
+        *
+        * @see WordRule#addWord
+        */
+       public PreprocessorRule(IWordDetector detector) {
+               this(detector, Token.UNDEFINED);
+       }
+
+       /**
+        * Creates a rule which, with the help of an word detector, will return the token
+        * associated with the detected word. If no token has been associated, the
+        * specified default token will be returned.
+        *
+        * @param detector the word detector to be used by this rule, may not be <code>null</code>
+        * @param defaultToken the default token to be returned on success 
+        *  if nothing else is specified, may not be <code>null</code>
+        *
+        * @see WordRule#addWord
+        */
+       public PreprocessorRule(IWordDetector detector, IToken defaultToken) {
+               super(detector, defaultToken);
+       }
+
+       /**
+        * Creates a rule which, with the help of an word detector, will return the token
+        * associated with the detected word. If no token has been associated, the
+        * specified default token will be returned.
+        *
+        * @param detector the word detector to be used by this rule, may not be <code>null</code>
+        * @param defaultToken the default token to be returned on success 
+        *  if nothing else is specified, may not be <code>null</code>
+        * @param malformedToken  the token to be returned if the directive is malformed
+        * 
+        * @see WordRule#addWord
+        */
+       public PreprocessorRule(IWordDetector detector, IToken defaultToken, IToken malformedToken) {
+               super(detector, defaultToken);
+               fMalformedToken= malformedToken;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.rules.WordRule#addWord(java.lang.String, org.eclipse.jface.text.rules.IToken)
+        */
+       @Override
+       public void addWord(String word, IToken token) {
+               if (word.charAt(0) == '#') {
+                       word= word.substring(1);
+               }
+               super.addWord(word, token);
+       }
+
+       /*
+        * @see IRule#evaluate
+        */
+       @Override
+       public IToken evaluate(ICharacterScanner scanner) {
+               int c;
+               int nCharsToRollback = 0;
+               boolean hashSignDetected = false;
+
+               do {
+                       c = scanner.read();
+                       nCharsToRollback++;
+               } while (c == ' ' || c == '\t');
+               
+               // Di- and trigraph support
+               if (c == '#') {
+                       hashSignDetected = true;
+               } else if (c == '%') {
+                       c = scanner.read();
+                       nCharsToRollback++;
+                       if (c == ':') {
+                               hashSignDetected = true;
+                       }
+               } else if (c == '?') {
+                       c = scanner.read();
+                       nCharsToRollback++;
+                       if (c == '?') {
+                               c = scanner.read();
+                               nCharsToRollback++;
+                               if (c == '=') {
+                                       hashSignDetected = true;
+                               }
+                       }
+               }
+
+               if (hashSignDetected) {
+
+                       fBuffer.setLength(0);
+                       c = scanner.read();
+                       if (c == '#') {
+                               // ## operator
+                               fBuffer.append((char) c);
+                       } else {
+                               while (c == ' ' || c == '\t') {
+                                       c = scanner.read();
+                               }
+                               if (fDetector.isWordStart((char) c)) {
+                                       do {
+                                               fBuffer.append((char) c);
+                                               c = scanner.read();
+                                       } while (fDetector.isWordPart((char) c));
+                               }
+                               scanner.unread();
+                       }
+                       IToken token = (IToken) fWords.get(fBuffer.toString());
+                       if (token != null)
+                               return token;
+                       
+                       if (fMalformedToken != null) {
+                               do {
+                                       c = scanner.read();
+                               } while (c != ICharacterScanner.EOF);
+                               return fMalformedToken;
+                       }
+
+                       return fDefaultToken;
+
+               }
+               // Doesn't start with '#', roll back scanner
+               
+               for (int i = 0; i < nCharsToRollback; i++) {
+                       scanner.unread();
+               }
+
+               return Token.UNDEFINED;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SequenceCharacterIterator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SequenceCharacterIterator.java
new file mode 100644 (file)
index 0000000..27843e3
--- /dev/null
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import java.text.CharacterIterator;
+
+import org.eclipse.core.runtime.Assert;
+
+
+/**
+ * A <code>CharSequence</code> based implementation of <code>CharacterIterator</code>.
+ *
+ * @since 4.0
+ */
+public class SequenceCharacterIterator implements CharacterIterator {
+
+       private int fIndex= -1;
+       private final CharSequence fSequence;
+       private final int fFirst;
+       private final int fLast;
+
+       private void invariant() {
+               Assert.isTrue(fIndex >= fFirst);
+               Assert.isTrue(fIndex <= fLast);
+       }
+
+       /**
+        * Creates an iterator for the entire sequence.
+        *
+        * @param sequence the sequence backing this iterator
+        */
+       public SequenceCharacterIterator(CharSequence sequence) {
+               this(sequence, 0);
+       }
+
+       /**
+        * Creates an iterator.
+        *
+        * @param sequence the sequence backing this iterator
+        * @param first the first character to consider
+        * @throws IllegalArgumentException if the indices are out of bounds
+        */
+       public SequenceCharacterIterator(CharSequence sequence, int first) throws IllegalArgumentException {
+               this(sequence, first, sequence.length());
+       }
+
+       /**
+        * Creates an iterator.
+        *
+        * @param sequence the sequence backing this iterator
+        * @param first the first character to consider
+        * @param last the last character index to consider
+        * @throws IllegalArgumentException if the indices are out of bounds
+        */
+       public SequenceCharacterIterator(CharSequence sequence, int first, int last) throws IllegalArgumentException {
+               if (sequence == null)
+                       throw new NullPointerException();
+               if (first < 0 || first > last)
+                       throw new IllegalArgumentException();
+               if (last > sequence.length())
+                       throw new IllegalArgumentException();
+               fSequence= sequence;
+               fFirst= first;
+               fLast= last;
+               fIndex= first;
+               invariant();
+       }
+
+       /*
+        * @see java.text.CharacterIterator#first()
+        */
+       public char first() {
+               return setIndex(getBeginIndex());
+       }
+
+       /*
+        * @see java.text.CharacterIterator#last()
+        */
+       public char last() {
+               if (fFirst == fLast)
+                       return setIndex(getEndIndex());
+               return setIndex(getEndIndex() - 1);
+       }
+
+       /*
+        * @see java.text.CharacterIterator#current()
+        */
+       public char current() {
+               if (fIndex >= fFirst && fIndex < fLast)
+                       return fSequence.charAt(fIndex);
+               return DONE;
+       }
+
+       /*
+        * @see java.text.CharacterIterator#next()
+        */
+       public char next() {
+               return setIndex(Math.min(fIndex + 1, getEndIndex()));
+       }
+
+       /*
+        * @see java.text.CharacterIterator#previous()
+        */
+       public char previous() {
+               if (fIndex > getBeginIndex()) {
+                       return setIndex(fIndex - 1);
+               }
+               return DONE;
+       }
+
+       /*
+        * @see java.text.CharacterIterator#setIndex(int)
+        */
+       public char setIndex(int position) {
+               if (position >= getBeginIndex() && position <= getEndIndex())
+                       fIndex= position;
+               else
+                       throw new IllegalArgumentException();
+
+               invariant();
+               return current();
+       }
+
+       /*
+        * @see java.text.CharacterIterator#getBeginIndex()
+        */
+       public int getBeginIndex() {
+               return fFirst;
+       }
+
+       /*
+        * @see java.text.CharacterIterator#getEndIndex()
+        */
+       public int getEndIndex() {
+               return fLast;
+       }
+
+       /*
+        * @see java.text.CharacterIterator#getIndex()
+        */
+       public int getIndex() {
+               return fIndex;
+       }
+
+       /*
+        * @see java.text.CharacterIterator#clone()
+        */
+       @Override
+       public Object clone() {
+               try {
+                       return super.clone();
+               } catch (CloneNotSupportedException e) {
+                       throw new InternalError();
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SimpleCSourceViewerConfiguration.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SimpleCSourceViewerConfiguration.java
new file mode 100644 (file)
index 0000000..679ecca
--- /dev/null
@@ -0,0 +1,146 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin, Google
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.IAutoEditStrategy;
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.ITextHover;
+import org.eclipse.jface.text.formatter.IContentFormatter;
+import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
+import org.eclipse.jface.text.information.IInformationPresenter;
+import org.eclipse.jface.text.source.IAnnotationHover;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.ui.text.CSourceViewerConfiguration;
+import org.eclipse.cdt.ui.text.IColorManager;
+
+
+/**
+ * A simple {@linkplain org.eclipse.cdt.ui.text.CSourceViewerConfiguration C source viewer configuration}.
+ * <p>
+ * This simple source viewer configuration basically provides syntax coloring
+ * and disables all other features like code assist, quick outlines, hyperlinking, etc.
+ * </p>
+ */
+public class SimpleCSourceViewerConfiguration extends CSourceViewerConfiguration {
+
+
+       private boolean fConfigureFormatter;
+
+       /**
+        * Creates a new C source viewer configuration for viewers in the given editor
+        * using the given preference store, the color manager and the specified document partitioning.
+        *
+        * @param colorManager the color manager
+        * @param preferenceStore the preference store, can be read-only
+        * @param editor the editor in which the configured viewer(s) will reside, or <code>null</code> if none
+        * @param partitioning the document partitioning for this configuration, or <code>null</code> for the default partitioning
+        * @param configureFormatter <code>true</code> if a content formatter should be configured
+        */
+       public SimpleCSourceViewerConfiguration(IColorManager colorManager, IPreferenceStore preferenceStore, ITextEditor editor, String partitioning, boolean configureFormatter) {
+               super(colorManager, preferenceStore, editor, partitioning);
+               fConfigureFormatter= configureFormatter;
+       }
+       
+       /*
+        * @see SourceViewerConfiguration#getAutoEditStrategies(ISourceViewer, String)
+        */
+       @Override
+       public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) {
+               return null;
+       }
+
+       /*
+        * @see SourceViewerConfiguration#getAnnotationHover(ISourceViewer)
+        */
+       @Override
+       public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
+               return null;
+       }
+
+       /*
+        * @see SourceViewerConfiguration#getOverviewRulerAnnotationHover(ISourceViewer)
+        */
+       @Override
+       public IAnnotationHover getOverviewRulerAnnotationHover(ISourceViewer sourceViewer) {
+               return null;
+       }
+
+       /*
+        * @see SourceViewerConfiguration#getConfiguredTextHoverStateMasks(ISourceViewer, String)
+        */
+       @Override
+       public int[] getConfiguredTextHoverStateMasks(ISourceViewer sourceViewer, String contentType) {
+               return null;
+       }
+
+       /*
+        * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String, int)
+        */
+       @Override
+       public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) {
+               return null;
+       }
+
+       /*
+        * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String)
+        */
+       @Override
+       public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
+               return null;
+       }
+
+       /*
+        * @see SourceViewerConfiguration#getContentFormatter(ISourceViewer)
+        */
+       @Override
+       public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
+               if (fConfigureFormatter)
+                       return super.getContentFormatter(sourceViewer);
+               return null;
+       }
+
+       /*
+        * @see SourceViewerConfiguration#getInformationControlCreator(ISourceViewer)
+        */
+       @Override
+       public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) {
+               return null;
+       }
+
+       /*
+        * @see SourceViewerConfiguration#getInformationPresenter(ISourceViewer)
+        */
+       @Override
+       public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) {
+               return null;
+       }
+
+       /*
+        * @see SourceViewerConfiguration#getHyperlinkDetectors(ISourceViewer)
+        */
+       @Override
+       public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
+               return null;
+       }
+       
+       /*
+        * @see CSourceViewerConfiguration#getOutlinePresenter(ISourceViewer)
+        */
+       @Override
+       public IInformationPresenter getOutlinePresenter(ISourceViewer sourceViewer) {
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleCharReader.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleCharReader.java
new file mode 100644 (file)
index 0000000..f261c92
--- /dev/null
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import java.io.IOException;
+import java.io.Reader;
+
+
+public abstract class SingleCharReader extends Reader {
+       
+       /**
+        * @see Reader#read()
+        */
+       @Override
+       public abstract int read() throws IOException;
+
+
+       /**
+        * @see Reader#read(char[],int,int)
+        */
+       @Override
+       public int read(char cbuf[], int off, int len) throws IOException {
+               int end= off + len;
+               for (int i= off; i < end; i++) {
+                       int ch= read();
+                       if (ch == -1) {
+                               if (i == off) {
+                                       return -1;
+                               }
+                               return i - off;
+                       }
+                       cbuf[i]= (char)ch;
+               }
+               return len;
+       }               
+       
+       /**
+        * @see Reader#ready()
+        */             
+    @Override
+       public boolean ready() throws IOException {
+               return true;
+       }
+       
+       /**
+        * Gets the content as a String
+        */
+       public String getString() throws IOException {
+               StringBuffer buf= new StringBuffer();
+               int ch;
+               while ((ch= read()) != -1) {
+                       buf.append((char)ch);
+               }
+               return buf.toString();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleCharRule.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleCharRule.java
new file mode 100644 (file)
index 0000000..32a6b3b
--- /dev/null
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2005 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.text.rules.IRule;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.Token;
+
+/**
+ * Checks for single char.
+ *
+ * @author P.Tomaszewski
+ */
+public abstract class SingleCharRule implements IRule
+{
+
+    /** Style token. */
+    private IToken token;
+
+    /**
+     * Creates new rule.
+     * @param token Style token.
+     */
+    public SingleCharRule(IToken token)
+    {
+        super();
+        this.token = token;
+    }
+
+    /**
+     * @see org.eclipse.jface.text.rules.IRule#evaluate(org.eclipse.jface.text.rules.ICharacterScanner)
+     */
+    public IToken evaluate(ICharacterScanner scanner)
+    {
+        int ch = scanner.read();
+
+        if (isRuleChar(ch))
+        {
+            return token;
+        }
+        scanner.unread();
+        return Token.UNDEFINED;
+    }
+
+    /**
+     * Checks if char is rule char.
+     * @param ch Char to check.
+     * @return <b>true</b> if rule char.
+     */
+    protected abstract boolean isRuleChar(int ch);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleTokenCScanner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SingleTokenCScanner.java
new file mode 100644 (file)
index 0000000..7d4de27
--- /dev/null
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Andrew Ferguson (Symbian)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.cdt.ui.text.AbstractCScanner;
+import org.eclipse.cdt.ui.text.ITokenStoreFactory;
+
+/**
+ * 
+ */
+public final class SingleTokenCScanner extends AbstractCScanner {
+       
+       public SingleTokenCScanner(ITokenStoreFactory factory, String property) {
+               super(factory.createTokenStore(new String[] {property}), 20);
+               setDefaultReturnToken(getToken(property));
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SubstitutionTextReader.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SubstitutionTextReader.java
new file mode 100644 (file)
index 0000000..9aa2c1e
--- /dev/null
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+
+import java.io.IOException;
+import java.io.Reader;
+
+
+/**
+ * Reads the text contents from a reader and computes for each character
+ * a potential substitution. The substitution may eat more characters than 
+ * only the one passed into the computation routine.
+ */
+public abstract class SubstitutionTextReader extends SingleCharReader {
+       
+       protected static final String LINE_DELIM= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+       
+       private Reader fReader;
+       private boolean fWasWhiteSpace;
+       private int fCharAfterWhiteSpace;
+       
+       private boolean fReadFromBuffer;
+       private StringBuffer fBuffer;
+       private int fIndex;
+
+
+       protected SubstitutionTextReader(Reader reader) {
+               fReader= reader;
+               fBuffer= new StringBuffer();
+               fIndex= 0;
+               fReadFromBuffer= false;
+               fCharAfterWhiteSpace= -1;
+               fWasWhiteSpace= true;
+       }
+       
+       /**
+        * Implement to compute the substitution for the given character and 
+        * if necessary subsequent characters. Use <code>nextChar</code>
+        * to read subsequent characters.
+        */
+       protected abstract String computeSubstitution(int c) throws IOException;
+       
+       /**
+        * Returns the internal reader.
+        */
+       protected Reader getReader() {
+               return fReader;
+       }
+        
+       /**
+        * Returns the next character.
+        */
+       protected int nextChar() throws IOException {
+               fReadFromBuffer= (fBuffer.length() > 0);
+               if (fReadFromBuffer) {
+                       char ch= fBuffer.charAt(fIndex++);
+                       if (fIndex >= fBuffer.length()) {
+                               fBuffer.setLength(0);
+                               fIndex= 0;
+                       }
+                       return ch;
+               }
+               int ch= fCharAfterWhiteSpace;
+               if (ch == -1) {
+                       ch= fReader.read();
+               }
+               if (Character.isWhitespace((char)ch)) {
+                       do {
+                               ch= fReader.read();
+                       } while (Character.isWhitespace((char)ch));
+                       if (ch != -1) {
+                               fCharAfterWhiteSpace= ch;
+                               return ' ';
+                       }
+               } else {
+                       fCharAfterWhiteSpace= -1;
+               }
+               return ch;
+       }
+       
+       /**
+        * @see Reader#read()
+        */
+       @Override
+       public int read() throws IOException {
+               int c;
+               do {
+                       
+                       c= nextChar();
+                       while (!fReadFromBuffer) {
+                               String s= computeSubstitution(c);
+                               if (s == null)
+                                       break;
+                               if (s.length() > 0)
+                                       fBuffer.insert(0, s);
+                               c= nextChar();
+                       }
+                       
+               } while (fWasWhiteSpace && (c == ' '));
+                               
+               fWasWhiteSpace= (c == ' ' || c == '\r' || c == '\n');
+               return c;
+       }
+               
+       /**
+        * @see Reader#ready()
+        */             
+    @Override
+       public boolean ready() throws IOException {
+               return fReader.ready();
+       }
+               
+       /**
+        * @see Reader#close()
+        */             
+       @Override
+       public void close() throws IOException {
+               fReader.close();
+       }
+       
+       /**
+        * @see Reader#reset()
+        */             
+       @Override
+       public void reset() throws IOException {
+               fReader.reset();
+               fWasWhiteSpace= true;
+               fCharAfterWhiteSpace= -1;
+               fBuffer.setLength(0);
+               fIndex= 0;              
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/Symbols.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/Symbols.java
new file mode 100644 (file)
index 0000000..ec2e89e
--- /dev/null
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+/**
+ * Symbols for the heuristic C/C++ scanner.
+ */
+public interface Symbols {
+       int TokenEOF= -1;
+       int TokenLBRACE= 1;
+       int TokenRBRACE= 2;
+       int TokenLBRACKET= 3;
+       int TokenRBRACKET= 4;
+       int TokenLPAREN= 5;
+       int TokenRPAREN= 6;
+       int TokenSEMICOLON= 7;
+       int TokenOTHER= 8;
+       int TokenCOLON= 9;
+       int TokenQUESTIONMARK= 10;
+       int TokenCOMMA= 11;
+       int TokenEQUAL= 12;
+       int TokenLESSTHAN= 13;
+       int TokenGREATERTHAN= 14;
+       int TokenDOT= 15;
+       int TokenMINUS= 16;
+       int TokenTILDE= 17;
+       int TokenSHIFTRIGHT= 18;
+       int TokenARROW= 19;
+       int TokenDOUBLECOLON= 20;
+       int TokenSHIFTLEFT= 21;
+       int TokenPLUS= 22;
+       int TokenIF= 109;
+       int TokenDO= 1010;
+       int TokenFOR= 1011;
+       int TokenTRY= 1012;
+       int TokenCASE= 1013;
+       int TokenELSE= 1014;
+       int TokenBREAK= 1015;
+       int TokenCATCH= 1016;
+       int TokenWHILE= 1017;
+       int TokenRETURN= 1018;
+       int TokenSTATIC= 1019;
+       int TokenSWITCH= 1020;
+       int TokenGOTO= 1021;
+       int TokenDEFAULT= 1022;
+       int TokenPRIVATE= 1023;
+       int TokenPROTECTED= 1024;
+       int TokenPUBLIC= 1025;
+       int TokenNEW= 1026;
+       int TokenDELETE= 1027; 
+       int TokenCLASS= 1028;
+       int TokenSTRUCT= 1029;
+       int TokenUNION= 1030;
+       int TokenENUM= 1031;
+       int TokenVIRTUAL= 1032;
+       int TokenNAMESPACE= 1033;
+       int TokenOPERATOR= 1034;
+       int TokenTHROW= 1035;
+       int TokenCONST= 1036;
+       int TokenEXTERN= 1037;
+       int TokenTYPEDEF= 1038;
+       int TokenUSING= 1039;
+       int TokenTEMPLATE= 1040;
+       int TokenTYPENAME= 1041;
+       int TokenIDENT= 2000;
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TabsToSpacesConverter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TabsToSpacesConverter.java
new file mode 100644 (file)
index 0000000..b516056
--- /dev/null
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DocumentCommand;
+import org.eclipse.jface.text.IAutoEditStrategy;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ILineTracker;
+import org.eclipse.jface.text.IRegion;
+
+/**
+ * Auto edit strategy that converts tabs into spaces.
+ * <p>
+ * This class is derived from the platform version adding a fix for bug 306333.
+ * Can be removed when the bug is fixed.
+ * </p>
+ * @see org.eclipse.jface.text.TabsToSpacesConverter
+ */
+public class TabsToSpacesConverter implements IAutoEditStrategy {
+
+       private int fTabRatio;
+       private ILineTracker fLineTracker;
+
+
+       public void setNumberOfSpacesPerTab(int ratio) {
+               fTabRatio= ratio;
+       }
+
+       public void setLineTracker(ILineTracker lineTracker) {
+               fLineTracker= lineTracker;
+       }
+
+       private int insertTabString(StringBuffer buffer, int offsetInLine) {
+
+               if (fTabRatio == 0)
+                       return 0;
+
+               int remainder= offsetInLine % fTabRatio;
+               remainder= fTabRatio - remainder;
+               for (int i= 0; i < remainder; i++)
+                       buffer.append(' ');
+               return remainder;
+       }
+
+       public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
+               String text= command.text;
+               if (text == null)
+                       return;
+
+               int index= text.indexOf('\t');
+               if (index > -1) {
+
+                       StringBuffer buffer= new StringBuffer();
+
+                       fLineTracker.set(command.text);
+                       int lines= fLineTracker.getNumberOfLines();
+
+                       try {
+
+                               for (int i= 0; i < lines; i++) {
+
+                                       int offset= fLineTracker.getLineOffset(i);
+                                       int endOffset= offset + fLineTracker.getLineLength(i);
+                                       String line= text.substring(offset, endOffset);
+
+                                       int position= 0;
+                                       if (i == 0) {
+                                               IRegion firstLine= document.getLineInformationOfOffset(command.offset);
+                                               position= computeVisualLength(document.get(firstLine.getOffset(), command.offset - firstLine.getOffset()));
+                                       }
+
+                                       int length= line.length();
+                                       for (int j= 0; j < length; j++) {
+                                               char c= line.charAt(j);
+                                               if (c == '\t') {
+                                                       position += insertTabString(buffer, position);
+                                               } else {
+                                                       buffer.append(c);
+                                                       ++ position;
+                                               }
+                                       }
+
+                               }
+
+                               command.text= buffer.toString();
+
+                       } catch (BadLocationException x) {
+                       }
+               }
+       }
+
+       private int computeVisualLength(String text) {
+               int length = text.length();
+               int offset = 0;
+               for (int i=0; i < length; ++i) {
+                       if (text.charAt(i) == '\t') {
+                               if (fTabRatio != 0)
+                                       offset += fTabRatio - offset % fTabRatio;
+                       } else {
+                               ++offset;
+                       }
+               }
+               return offset;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TaskTagRule.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TaskTagRule.java
new file mode 100644 (file)
index 0000000..7382481
--- /dev/null
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2011 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Sergey Prigogin  (Google)
+ *     Andrew Ferguson  (Symbian)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.IWordDetector;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+import org.eclipse.cdt.core.CCorePreferenceConstants;
+import org.eclipse.cdt.ui.IPropertyChangeParticipant;
+
+/**
+ * Which words should be recognized as task tags is specified under {@link CCorePreferenceConstants#TODO_TASK_TAGS} as a
+ * comma delimited list.
+ * 
+ * @see CCorePreferenceConstants#TODO_TASK_TAGS
+ * @since 5.0
+ */
+public final class TaskTagRule extends CombinedWordRule implements IPropertyChangeParticipant {        
+       private static class TaskTagDetector implements IWordDetector {
+               public boolean isWordStart(char c) {
+                       return c == '@' || c == '\\' || Character.isJavaIdentifierStart(c);
+               }
+
+               public boolean isWordPart(char c) {
+                       return c == '.' || Character.isJavaIdentifierPart(c);
+               }
+       }
+
+       private class TaskTagMatcher extends WordMatcher {
+
+               private IToken fToken;
+               /**
+                * Uppercase words
+                */
+               private Map<CharacterBuffer, IToken> fUppercaseWords= new HashMap<CharacterBuffer, IToken>();
+               /**
+                * <code>true</code> if task tag detection is case-sensitive.
+                */
+               private boolean fCaseSensitive= true;
+               /**
+                * Buffer for uppercase word
+                */
+               private CharacterBuffer fBuffer= new CharacterBuffer(16);
+
+               public TaskTagMatcher(IToken token) {
+                       fToken= token;
+               }
+
+               /*
+                * @see org.eclipse.jdt.internal.ui.text.CombinedWordRule.WordMatcher#clearWords()
+                */
+               @Override
+               public synchronized void clearWords() {
+                       super.clearWords();
+                       fUppercaseWords.clear();
+               }
+
+               public synchronized void addTaskTags(String value) {
+                       String[] taskTags= value.split(","); //$NON-NLS-1$
+                       for (String tag : taskTags) {
+                               if (tag.length() > 0) {
+                                       addWord(tag, fToken);
+                               }
+                       }
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.text.CombinedWordRule.WordMatcher#addWord(java.lang.String, org.eclipse.jface.text.rules.IToken)
+                */
+               @Override
+               public synchronized void addWord(String word, IToken token) {
+                       Assert.isNotNull(word);
+                       Assert.isNotNull(token);
+
+                       super.addWord(word, token);
+                       fUppercaseWords.put(new CharacterBuffer(word.toUpperCase()), token);
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.text.CombinedWordRule.WordMatcher#evaluate(org.eclipse.jface.text.rules.ICharacterScanner, org.eclipse.jdt.internal.ui.text.CombinedWordRule.CharacterBuffer)
+                */
+               @Override
+               public synchronized IToken evaluate(ICharacterScanner scanner, CharacterBuffer word) {
+                       if (fCaseSensitive)
+                               return super.evaluate(scanner, word);
+
+                       fBuffer.clear();
+                       for (int i= 0, n= word.length(); i < n; i++)
+                               fBuffer.append(Character.toUpperCase(word.charAt(i)));
+
+                       IToken token= fUppercaseWords.get(fBuffer);
+                       if (token != null)
+                               return token;
+                       return Token.UNDEFINED;
+               }
+
+               /**
+                * Enables/disables the case-sensitivity of the task tag detection.
+                *
+                * @param caseSensitive <code>true</code> iff case-sensitivity should be enabled
+                */
+               public void setCaseSensitive(boolean caseSensitive) {
+                       fCaseSensitive= caseSensitive;
+               }
+       }
+
+       private static final String TODO_TASK_TAGS= CCorePreferenceConstants.TODO_TASK_TAGS;
+       private static final String TODO_TASK_CASE_SENSITIVE= CCorePreferenceConstants.TODO_TASK_CASE_SENSITIVE;
+       private TaskTagMatcher fMatcher;
+
+       /**
+        * Creates a new task tag rule
+        * @param token the token to return for words recognized as task tags
+        * @param defaultToken 
+        * @param preferenceStore
+        * @param corePreferenceStore
+        */
+       public TaskTagRule(IToken token, IToken defaultToken, IPreferenceStore preferenceStore,
+                       IPreferenceStore corePreferenceStore) {
+               super(new TaskTagDetector(), defaultToken);
+               fMatcher = new TaskTagMatcher(token);
+               addWordMatcher(fMatcher);
+               String taskWords= null;
+               if (preferenceStore.contains(TODO_TASK_TAGS)) {
+                       taskWords= preferenceStore.getString(TODO_TASK_TAGS);
+               } else if (corePreferenceStore != null) {
+                       taskWords= corePreferenceStore.getString(TODO_TASK_TAGS);
+               }
+               if (taskWords != null) {
+                       addTaskTags(taskWords);
+               }
+
+               boolean isCaseSensitive= true;
+               if (preferenceStore.contains(TODO_TASK_CASE_SENSITIVE)) {
+                       isCaseSensitive= preferenceStore.getBoolean(TODO_TASK_CASE_SENSITIVE);
+               } else if (corePreferenceStore != null) {
+                       isCaseSensitive= corePreferenceStore.getBoolean(TODO_TASK_CASE_SENSITIVE);
+               }
+               fMatcher.setCaseSensitive(isCaseSensitive);
+       }
+
+       /**
+        * Removes the current list of words that should be
+        * recognized as task tags.
+        */
+       public void clearTaskTags() {
+               fMatcher.clearWords();
+       }
+
+       /**
+        * Adds tags from the specified string as task tags.
+        * @param value a comma delimited list of words to recognize as task tags
+        */
+       public void addTaskTags(String value) {
+               fMatcher.addTaskTags(value);
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.IPropertyChangeParticipant#affectsBehavior(org.eclipse.jface.util.PropertyChangeEvent)
+        */
+       public boolean affectsBehavior(PropertyChangeEvent event) {
+               return event.getProperty().equals(TODO_TASK_TAGS) || event.getProperty().equals(TODO_TASK_CASE_SENSITIVE);
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.IPropertyChangeParticipant#adaptToPreferenceChange(org.eclipse.jface.util.PropertyChangeEvent)
+        */
+       public void adaptToPreferenceChange(PropertyChangeEvent event) {
+               if (event.getProperty().equals(TODO_TASK_TAGS)) {
+                       Object value= event.getNewValue();
+                       if (value instanceof String) {
+                               synchronized (fMatcher) {
+                                       fMatcher.clearWords();
+                                       fMatcher.addTaskTags((String) value);
+                               }
+                       }
+               } else if (event.getProperty().equals(TODO_TASK_CASE_SENSITIVE)) {
+                       Object value= event.getNewValue();
+                       if (value instanceof String)
+                               fMatcher.setCaseSensitive(Boolean.parseBoolean((String) value));
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TokenStore.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/TokenStore.java
new file mode 100644 (file)
index 0000000..0f5996a
--- /dev/null
@@ -0,0 +1,271 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Andrew Ferguson (Symbian) - refactored to TokenStore (previously part of AbstractCScanner)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text;
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.resource.StringConverter;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.IColorManager;
+import org.eclipse.cdt.ui.text.ITokenStore;
+
+
+/**
+ * Maintains a pool of tokens identified by a String ID.
+ * Supports styles per token.
+ * Updates token instances on property changes.
+ */
+
+public class TokenStore implements ITokenStore {
+       private IColorManager fColorManager;
+       private IPreferenceStore fPreferenceStore;
+
+       private Map<String, IToken> fTokenMap= new HashMap<String, IToken>();
+       private String[] fPropertyNamesColor;
+
+       private boolean fNeedsLazyColorLoading;
+       
+       /**
+        * Maintains tokens for a specified set of property keys. Automatically also
+        * copes with bold, italic, strike-through and underlined versions of the key.
+        * @param manager the IColorManager to retrieve token colors from
+        * @param store the {@link IPreferenceStore} to fetch property preferences from
+        */
+       public TokenStore(IColorManager manager, IPreferenceStore store, String[] propertyNamesColor) {
+               fColorManager= manager;
+               fPreferenceStore= store;
+       
+               fPropertyNamesColor= propertyNamesColor;
+
+               fNeedsLazyColorLoading= Display.getCurrent() == null;
+               for (int i= 0; i < fPropertyNamesColor.length; i++) {                   
+                       if(fPropertyNamesColor[i].endsWith(PreferenceConstants.EDITOR_BOLD_SUFFIX)
+                                       || fPropertyNamesColor[i].endsWith(PreferenceConstants.EDITOR_ITALIC_SUFFIX)
+                                       || fPropertyNamesColor[i].endsWith(PreferenceConstants.EDITOR_STRIKETHROUGH_SUFFIX)
+                                       || fPropertyNamesColor[i].endsWith(PreferenceConstants.EDITOR_UNDERLINE_SUFFIX)) {
+                               throw new IllegalArgumentException(); // XXX
+                       }
+                       if (fNeedsLazyColorLoading)
+                               addTokenWithProxyAttribute(fPropertyNamesColor[i]);
+                       else
+                               addToken(fPropertyNamesColor[i]);
+               }
+       }
+       
+       /**
+        * In the case where at the time of IToken construction, the Display was not
+        * ready to construct colors. 
+        */
+       public void ensureTokensInitialised() {
+               if (fNeedsLazyColorLoading && Display.getCurrent() != null) {
+                       for (int i= 0; i < fPropertyNamesColor.length; i++) {
+                               addToken(fPropertyNamesColor[i]);
+                       }
+                       fNeedsLazyColorLoading= false;
+               }
+       }
+
+       private void addTokenWithProxyAttribute(String colorKey) {
+               fTokenMap.put(colorKey, new Token(createTextAttribute(colorKey, true)));
+       }
+
+       private void addToken(String colorKey) {
+               if (fColorManager != null && colorKey != null && fColorManager.getColor(colorKey) == null) {
+                       RGB rgb= PreferenceConverter.getColor(fPreferenceStore, colorKey);
+                       fColorManager.unbindColor(colorKey);
+                       fColorManager.bindColor(colorKey, rgb);
+               }
+
+               if (!fNeedsLazyColorLoading)
+                       fTokenMap.put(colorKey, new Token(createTextAttribute(colorKey, false)));
+               else {
+                       Token token= ((Token)fTokenMap.get(colorKey));
+                       if (token != null)
+                               token.setData(createTextAttribute(colorKey, false));
+               }
+       }
+
+       /**
+        * Create a text attribute based on the given color, bold, italic, strikethrough and underline preference keys.
+        *
+        * @param colorKey the color preference key
+        * @param boldKey the bold preference key
+        * @param italicKey the italic preference key
+        * @param strikethroughKey the strikethrough preference key
+        * @param underlineKey the italic preference key
+        * @return the created text attribute
+        * @since 3.0
+        */
+       private TextAttribute createTextAttribute(String colorKey, boolean isNull) {
+               Color color= null;
+               if (!isNull)
+                       color= fColorManager.getColor(colorKey);
+
+               String boldKey= colorKey + PreferenceConstants.EDITOR_BOLD_SUFFIX;
+               String italicKey= colorKey + PreferenceConstants.EDITOR_ITALIC_SUFFIX;
+               String strikethroughKey= colorKey + PreferenceConstants.EDITOR_STRIKETHROUGH_SUFFIX;
+               String underlineKey= colorKey + PreferenceConstants.EDITOR_UNDERLINE_SUFFIX;
+               
+               int style= fPreferenceStore.getBoolean(boldKey) ? SWT.BOLD : SWT.NORMAL;
+               if (fPreferenceStore.getBoolean(italicKey))
+                       style |= SWT.ITALIC;
+
+               if (fPreferenceStore.getBoolean(strikethroughKey))
+                       style |= TextAttribute.STRIKETHROUGH;
+
+               if (fPreferenceStore.getBoolean(underlineKey))
+                       style |= TextAttribute.UNDERLINE;
+
+               return new TextAttribute(color, null, style);
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.cdt.ui.text.ITokenStore#getToken(java.lang.String)
+        */
+       public IToken getToken(String key) {
+               return getTokenInner(key);
+       }
+       
+       private Token getTokenInner(String key) {
+               ensureTokensInitialised();
+               return (Token) fTokenMap.get(key);
+       }
+
+       private int indexOf(String property) {
+               if (property != null) {
+                       int length= fPropertyNamesColor.length;
+                       for (int i= 0; i < length; i++) {
+                               if (property.startsWith(fPropertyNamesColor[i])) {
+                                       int pLength= property.length();
+                                       if(fPropertyNamesColor[i].length() < pLength) {
+                                               String end= property.substring(fPropertyNamesColor[i].length());
+                                               if (end.equals(PreferenceConstants.EDITOR_BOLD_SUFFIX)
+                                                       || end.equals(PreferenceConstants.EDITOR_ITALIC_SUFFIX)
+                                                       || end.equals(PreferenceConstants.EDITOR_STRIKETHROUGH_SUFFIX)
+                                                       || end.equals(PreferenceConstants.EDITOR_UNDERLINE_SUFFIX)) {
+                                                       return i;                                               
+                                               }
+                                       } else if (fPropertyNamesColor[i].equals(property)) {
+                                               return i;
+                                       }
+                               }
+                       }
+               }
+               return -1;
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.cdt.ui.IPropertyChangeParticipant#affectsBehavior(org.eclipse.jface.util.PropertyChangeEvent)
+        */
+       public boolean affectsBehavior(PropertyChangeEvent event) {
+               return indexOf(event.getProperty()) >= 0;
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.cdt.ui.IPropertyChangeParticipant#adaptToPreferenceChange(org.eclipse.jface.util.PropertyChangeEvent)
+        */
+       public void adaptToPreferenceChange(PropertyChangeEvent event) {
+               String property= event.getProperty();
+               int i= indexOf(property);
+               if (property.startsWith(fPropertyNamesColor[i])) {
+                       Token token= getTokenInner(fPropertyNamesColor[i]);
+                       if(property.length() == fPropertyNamesColor[i].length()) {
+                               adaptToColorChange(token, event);
+                       } else {
+                               String end= property.substring(fPropertyNamesColor[i].length());                                
+                               if (end.equals(PreferenceConstants.EDITOR_BOLD_SUFFIX)) {
+                                       adaptToStyleChange(token, event, SWT.BOLD);
+                               } else if (end.equals(PreferenceConstants.EDITOR_ITALIC_SUFFIX)) {
+                                       adaptToStyleChange(token, event, SWT.ITALIC);
+                               } else if (end.equals(PreferenceConstants.EDITOR_STRIKETHROUGH_SUFFIX)) {
+                                       adaptToStyleChange(token, event, TextAttribute.STRIKETHROUGH);
+                               } else if (end.equals(PreferenceConstants.EDITOR_UNDERLINE_SUFFIX)) {
+                                       adaptToStyleChange(token, event, TextAttribute.UNDERLINE);
+                               }
+                       }
+               }
+       }
+
+       private void adaptToColorChange(Token token, PropertyChangeEvent event) {
+               RGB rgb= null;
+
+               Object value= event.getNewValue();
+               if (value instanceof RGB)
+                       rgb= (RGB) value;
+               else if (value instanceof String)
+                       rgb= StringConverter.asRGB((String) value);
+
+               if (rgb != null) {
+
+                       String property= event.getProperty();
+                       Color color= fColorManager.getColor(property);
+
+                       if ((color == null || !rgb.equals(color.getRGB()))) {
+                               fColorManager.unbindColor(property);
+                               fColorManager.bindColor(property, rgb);
+
+                               color= fColorManager.getColor(property);
+                       }
+
+                       Object data= token.getData();
+                       if (data instanceof TextAttribute) {
+                               TextAttribute oldAttr= (TextAttribute) data;
+                               token.setData(new TextAttribute(color, oldAttr.getBackground(), oldAttr.getStyle()));
+                       }
+               }
+       }
+
+       private void adaptToStyleChange(Token token, PropertyChangeEvent event, int styleAttribute) {
+               boolean eventValue= false;
+               Object value= event.getNewValue();
+               if (value instanceof Boolean)
+                       eventValue= ((Boolean) value).booleanValue();
+               else if (IPreferenceStore.TRUE.equals(value))
+                       eventValue= true;
+
+               Object data= token.getData();
+               if (data instanceof TextAttribute) {
+                       TextAttribute oldAttr= (TextAttribute) data;
+                       boolean activeValue= (oldAttr.getStyle() & styleAttribute) == styleAttribute;
+                       if (activeValue != eventValue)
+                               token.setData(new TextAttribute(oldAttr.getForeground(), oldAttr.getBackground(), eventValue ? oldAttr.getStyle() | styleAttribute : oldAttr.getStyle() & ~styleAttribute));
+               }
+       }
+       
+       /**
+        * Returns the preference store.
+        *
+        * @return the preference store.
+        *
+        * @since 3.0
+        */
+       public IPreferenceStore getPreferenceStore() {
+               return fPreferenceStore;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/asm/AsmPartitionScanner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/asm/AsmPartitionScanner.java
new file mode 100644 (file)
index 0000000..c427f4b
--- /dev/null
@@ -0,0 +1,685 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.asm;
+
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.rules.ICharacterScanner;
+import org.eclipse.jface.text.rules.IPartitionTokenScanner;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.Token;
+
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+import org.eclipse.cdt.internal.ui.text.BufferedDocumentScanner;
+
+
+/**
+ * This scanner recognizes
+ * <ul>
+ * <li>C multi line comments</li>
+ * <li>Assembly line comments</li>
+ * <li>C++ line comments</li>
+ * <li>C string literals</li>
+ * <li>Assembly character literals</li>
+ * <li>C preprocessor directives</li>
+ * </ul>
+ * Default supported line start comment characters are ';', '!', '|' and '@'.
+ * <p>
+ * A simple heuristic is used to detect valid line end comment characters: If a
+ * character known to be a potential line end comment character is used as a
+ * line start comment char, this character is considered a valid line end
+ * comment character, too. If e.g. a '@' is used to introduce a line start
+ * comment it is also recognized as a line end comment introducer afterwards.
+ * </p>
+ */
+public final class AsmPartitionScanner implements IPartitionTokenScanner, ICPartitions {
+
+       /**
+        * Characters not applicable for line start comments.
+        */
+       private static final String NON_LINE_COMMENT_CHARS = "\t #/_$.%()'\"{}"; //$NON-NLS-1$
+       /**
+        * Characters known to be used as line end comments.
+        */
+       private static final String KNOWN_LINE_END_COMMENT_CHARS = "#;@|!"; //$NON-NLS-1$
+       
+       // states
+       private static final int CCODE= 0;
+       private static final int SINGLE_LINE_COMMENT= 1;
+       private static final int MULTI_LINE_COMMENT= 2;
+       private static final int CHARACTER= 3;
+       private static final int STRING= 4;
+       private static final int PREPROCESSOR= 5;
+       private static final int PREPROCESSOR_MULTI_LINE_COMMENT= 6;
+
+       // beginning of prefixes and postfixes
+       private static final int NONE= 0;
+       private static final int BACKSLASH= 1; // postfix for STRING, CHARACTER and SINGLE_LINE_COMMENT
+       private static final int SLASH= 2; // prefix for SINGLE_LINE or MULTI_LINE
+       private static final int SLASH_STAR= 3; // prefix for MULTI_LINE_COMMENT
+       private static final int STAR= 4; // postfix for MULTI_LINE_COMMENT
+       private static final int CARRIAGE_RETURN=5; // postfix for STRING, CHARACTER and SINGLE_LINE_COMMENT
+       private static final int BACKSLASH_CR= 6; // postfix for STRING, CHARACTER and SINGLE_LINE_COMMENT
+       private static final int BACKSLASH_BACKSLASH= 7; // postfix for STRING, CHARACTER
+       
+       /** The scanner. */
+       private final BufferedDocumentScanner fScanner= new BufferedDocumentScanner(1000);
+       
+       /** The offset of the last returned token. */
+       private int fTokenOffset;
+       /** The length of the last returned token. */
+       private int fTokenLength;
+       
+       /** The state of the scanner. */
+       private int fState;
+       /** The last significant character read. */
+       private int fLast;
+       /** The amount of characters already read on first call to nextToken(). */
+       private int fPrefixLength;
+       /** Indicate whether current char is first non-whitespace char on the line*/
+       private boolean fFirstCharOnLine= true;
+
+       private final IToken[] fTokens= new IToken[] {
+               new Token(null),
+               new Token(C_SINGLE_LINE_COMMENT),
+               new Token(C_MULTI_LINE_COMMENT),
+               new Token(C_CHARACTER),
+               new Token(C_STRING),
+               new Token(C_PREPROCESSOR),
+               new Token(C_MULTI_LINE_COMMENT)
+       };
+
+       private String fLineCommentChars= ""; //$NON-NLS-1$
+       private String fLineEndCommentChars= ""; //$NON-NLS-1$
+       private String fLineStartCommentChars= ";!|@"; //$NON-NLS-1$
+       private boolean fDetectPreprocessor= true;
+       
+       public AsmPartitionScanner() {
+       }
+
+       /**
+        * Configure the set of default line comment characters.
+        * <p>
+        * These characters are considered line comment introducers at any position
+        * in the code.
+        * </p>
+        * 
+        * @param chars
+        */
+       public void setLineCommentCharacters(String chars) {
+               fLineCommentChars= chars != null ? chars : ""; //$NON-NLS-1$
+       }
+
+       /**
+        * Configure the set of default line start comment characters.
+        * <p>
+        * These characters are considered line comment introducers only as first
+        * non-whitespace character on the line.
+        * </p>
+        * 
+        * @param chars
+        */
+       public void setLineStartCommentCharacters(String chars) {
+               fLineStartCommentChars= chars != null ? chars : ""; //$NON-NLS-1$
+       }
+
+       /**
+        * Configure the set of default line end comment characters.
+        * <p>
+        * These characters are considered line comment introducers at the end of a
+        * instruction line.
+        * </p>
+        * 
+        * @param chars
+        */
+       public void setLineEndCommentCharacters(String chars) {
+               fLineEndCommentChars= chars != null ? chars : ""; //$NON-NLS-1$
+       }
+
+       /**
+        * Configure whether preprocessor directives should be detected.
+        * 
+        * @param detectPreprocessor
+        */
+       public void setDetectPreprocessorDiretives(boolean detectPreprocessor) {
+               fDetectPreprocessor= detectPreprocessor;
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.rules.ITokenScanner#nextToken()
+        */
+       public IToken nextToken() {
+
+               fTokenOffset += fTokenLength;
+               fTokenLength= fPrefixLength;
+
+               while (true) {
+                       final int ch= fScanner.read();
+                       
+                       final boolean isFirstCharOnLine= fFirstCharOnLine;
+                       if (fFirstCharOnLine && ch != ' ' && ch != '\t') {
+                               fFirstCharOnLine= false;
+                       }
+                       // characters
+                       switch (ch) {
+                       case ICharacterScanner.EOF:
+                               if (fTokenLength > 0) {
+                                       fLast= NONE; // ignore last
+                                       return preFix(fState, CCODE, NONE, 0);
+
+                               } else {
+                                       fLast= NONE;
+                                       fPrefixLength= 0;
+                                       return Token.EOF;
+                               }
+
+                       case '\r':
+                               fFirstCharOnLine= true;
+                               if (fLast == BACKSLASH || fLast == BACKSLASH_BACKSLASH) {
+                                       fLast= BACKSLASH_CR;
+                                       fTokenLength++;
+                                       continue;
+                               } else if (fLast != CARRIAGE_RETURN) {
+                                               fLast= CARRIAGE_RETURN;
+                                               fTokenLength++;
+                                               continue;
+                               } else {
+                                       // fLast == CARRIAGE_RETURN
+                                       switch (fState) {
+                                       case SINGLE_LINE_COMMENT:
+                                       case CHARACTER:
+                                       case STRING:
+                                       case PREPROCESSOR:
+                                               if (fTokenLength > 0) {
+                                                       IToken token= fTokens[fState];
+
+                                                       fLast= CARRIAGE_RETURN;
+                                                       fPrefixLength= 1;
+
+                                                       fState= CCODE;
+                                                       return token;
+
+                                               } else {
+                                                       consume();
+                                                       continue;
+                                               }
+
+                                       default:
+                                               consume();
+                                               continue;
+                                       }
+                               }
+
+                       case '\\':
+                               switch (fState) {
+                               case CHARACTER:
+                               case STRING:
+                                       fTokenLength++;
+                                       fLast= fLast == BACKSLASH ? BACKSLASH_BACKSLASH : BACKSLASH;
+                                       continue;
+                               default:
+                                       fTokenLength++;
+                                       fLast= BACKSLASH;
+                                       continue;
+                               }
+
+                       case '\n':
+                               fFirstCharOnLine= true;
+                               switch (fState) {
+                               case SINGLE_LINE_COMMENT:
+                               case CHARACTER:
+                               case STRING:
+                               case PREPROCESSOR:
+                                       // assert(fTokenLength > 0);
+                                       // if last char was a backslash then we have an escaped line
+                                       if (fLast != BACKSLASH && fLast != BACKSLASH_CR && fLast != BACKSLASH_BACKSLASH) {
+                                               return postFix(fState);
+                                       }
+                                       consume();
+                                       continue;
+                               default:
+                                       consume();
+                                       continue;
+                               }
+
+                       case ' ':
+                       case '\t':
+                               consume();
+                               continue;
+
+                       default:
+                               if (fLast == CARRIAGE_RETURN) {
+                                       switch (fState) {
+                                       case SINGLE_LINE_COMMENT:
+                                       case CHARACTER:
+                                       case STRING:
+                                       case PREPROCESSOR:
+
+                                               int last;
+                                               int newState;
+                                               switch (ch) {
+                                               case '/':
+                                                       last= SLASH;
+                                                       newState= CCODE;
+                                                       break;
+
+                                               case '*':
+                                                       last= STAR;
+                                                       newState= CCODE;
+                                                       break;
+
+                                               case '\'':
+                                                       last= NONE;
+                                                       newState= CHARACTER;
+                                                       break;
+
+                                               case '"':
+                                                       last= NONE;
+                                                       newState= STRING;
+                                                       break;
+
+                                               case '\r':
+                                                       last= CARRIAGE_RETURN;
+                                                       newState= CCODE;
+                                                       break;
+
+                                               case '\\':
+                                                       last= BACKSLASH;
+                                                       newState= CCODE;
+                                                       break;
+
+                                               case '#':
+                                                       last= NONE;
+                                                       newState= PREPROCESSOR;
+                                                       break;
+
+                                               default:
+                                                       last= NONE;
+                                                       newState= CCODE;
+                                                       break;
+                                               }
+
+                                               fLast= NONE; // ignore fLast
+                                               return preFix(fState, newState, last, 1);
+
+                                       case CCODE:
+                                               if (fDetectPreprocessor && ch == '#' && isFirstCharOnLine) {
+                                                       fLast= NONE; // ignore fLast
+                                                       int column= fScanner.getColumn() - 1;
+                                                       fTokenLength -= column;
+                                                       if (fTokenLength > 0) {
+                                                               return preFix(fState, PREPROCESSOR, NONE, column + 1);
+                                                       } else {
+                                                               preFix(fState, PREPROCESSOR, NONE, column + 1);
+                                                               fTokenOffset += fTokenLength;
+                                                               fTokenLength= fPrefixLength;
+                                                               break;
+                                                       }
+                                               }
+                                               break;
+
+                                       default:
+                                               break;
+                                       }
+                               }
+                       }
+
+                       // states
+                       switch (fState) {
+                       case CCODE:
+                               if (fLast == NONE) {
+                                       boolean isLineComment= false;
+                                       if (ch == '#' && fDetectPreprocessor && isFirstCharOnLine) {
+                                               // don't consume as line comment
+                                       } else if (fLineCommentChars.indexOf(ch) >= 0 || (isFirstCharOnLine && fLineStartCommentChars.indexOf(ch) >= 0) || (!isFirstCharOnLine && fLineEndCommentChars.indexOf(ch) >= 0)) {
+                                               isLineComment= true;
+                                       } else if (isFirstCharOnLine && !Character.isLetterOrDigit((char)ch) && NON_LINE_COMMENT_CHARS.indexOf(ch) < 0) {
+                                               fLineStartCommentChars += (char)ch;
+                                               isLineComment= true;
+                                       }
+                                       if (isLineComment) {
+                                               if (isFirstCharOnLine && fLineEndCommentChars.indexOf(ch) < 0 && KNOWN_LINE_END_COMMENT_CHARS.indexOf(ch) >= 0) {
+                                                       fLineEndCommentChars += (char)ch;
+                                               }
+                                               if (fTokenLength - getLastLength(fLast) > 0) {
+                                                       return preFix(CCODE, SINGLE_LINE_COMMENT, NONE, 1);
+                                               } else {
+                                                       preFix(CCODE, SINGLE_LINE_COMMENT, NONE, 1);
+                                                       fTokenOffset += fTokenLength;
+                                                       fTokenLength= fPrefixLength;
+                                               }
+                                               break;
+                                       }
+                               }
+
+                               switch (ch) {
+                               case '/':
+                                       // supported by gnu preprocessor
+                                       if (fLast == SLASH) {
+                                               if (fTokenLength - getLastLength(fLast) > 0) {
+                                                       return preFix(CCODE, SINGLE_LINE_COMMENT, NONE, 2);
+                                               } else {
+                                                       preFix(CCODE, SINGLE_LINE_COMMENT, NONE, 2);
+                                                       fTokenOffset += fTokenLength;
+                                                       fTokenLength= fPrefixLength;
+                                                       break;
+                                               }
+                                       } else {
+                                               fTokenLength++;
+                                               fLast= SLASH;
+                                               break;
+                                       }
+       
+                               case '*':
+                                       if (fLast == SLASH) {
+                                               if (fTokenLength - getLastLength(fLast) > 0) {
+                                                       return preFix(CCODE, MULTI_LINE_COMMENT, SLASH_STAR, 2);
+                                               } else {
+                                                       preFix(CCODE, MULTI_LINE_COMMENT, SLASH_STAR, 2);
+                                                       fTokenOffset += fTokenLength;
+                                                       fTokenLength= fPrefixLength;
+                                                       break;
+                                               }
+                                       } else {
+                                               consume();
+                                               break;
+                                       }
+                                       
+                               case '\'':
+                                       fLast= NONE; // ignore fLast
+                                       if (fTokenLength > 0) {
+                                               return preFix(CCODE, CHARACTER, NONE, 1);
+                                       } else {
+                                               preFix(CCODE, CHARACTER, NONE, 1);
+                                               fTokenOffset += fTokenLength;
+                                               fTokenLength= fPrefixLength;
+                                               break;
+                                       }
+
+                               case '"':
+                                       fLast= NONE; // ignore fLast
+                                       if (fTokenLength > 0 ) {
+                                               return preFix(CCODE, STRING, NONE, 1);
+                                       } else {
+                                               preFix(CCODE, STRING, NONE, 1);
+                                               fTokenOffset += fTokenLength;
+                                               fTokenLength= fPrefixLength;
+                                               break;
+                                       }
+                                       
+                               case '#':
+                                       if (fDetectPreprocessor && isFirstCharOnLine) {
+                                               int column= fScanner.getColumn() - 1;
+                                               fTokenLength -= column;
+                                               if (fTokenLength > 0) {
+                                                       return preFix(fState, PREPROCESSOR, NONE, column + 1);
+                                               } else {
+                                                       preFix(fState, PREPROCESSOR, NONE, column + 1);
+                                                       fTokenOffset += fTokenLength;
+                                                       fTokenLength= fPrefixLength;
+                                                       break;
+                                               }
+                                       }
+                                       consume();
+                                       break;
+                               default:
+                                       consume();
+                                       break;
+                               }
+                               break;
+
+                       case SINGLE_LINE_COMMENT:
+                               consume();
+                               break;
+
+                       case PREPROCESSOR:
+                               switch (ch) {
+                               case '/':
+                                       if (fLast == SLASH) {
+                                               consume();
+                                               break;
+                                       } else {
+                                               fTokenLength++;
+                                               fLast= SLASH;
+                                               break;
+                                       }
+       
+                               case '*':
+                                       if (fLast == SLASH) {
+                                               if (fTokenLength - getLastLength(fLast) > 0) {
+                                                       return preFix(fState, PREPROCESSOR_MULTI_LINE_COMMENT, SLASH_STAR, 2);
+                                               } else {
+                                                       preFix(fState, PREPROCESSOR_MULTI_LINE_COMMENT, SLASH_STAR, 2);
+                                                       fTokenOffset += fTokenLength;
+                                                       fTokenLength= fPrefixLength;
+                                                       break;
+                                               }
+                                       } else {
+                                               consume();
+                                               break;
+                                       }
+                               default:
+                                       consume();
+                                       break;
+                               }
+                               break;
+
+                       case PREPROCESSOR_MULTI_LINE_COMMENT:
+                               switch (ch) {
+                               case '*':
+                                       fTokenLength++;
+                                       fLast= STAR;
+                                       break;
+       
+                               case '/':
+                                       if (fLast == STAR) {
+                                               IToken token= postFix(fState);
+                                               fState= PREPROCESSOR;
+                                               return token;
+                                       }
+                                       consume();
+                                       break;
+       
+                               default:
+                                       consume();
+                                       break;
+                               }
+                               break;
+                               
+                       case MULTI_LINE_COMMENT:
+                               switch (ch) {
+                               case '*':
+                                       fTokenLength++;
+                                       fLast= STAR;
+                                       break;
+       
+                               case '/':
+                                       if (fLast == STAR) {
+                                               return postFix(MULTI_LINE_COMMENT);
+                                       } else {
+                                               consume();
+                                               break;
+                                       }
+       
+                               default:
+                                       consume();
+                                       break;
+                               }
+                               break;
+                               
+                       case STRING:
+                               switch (ch) {
+                               case '\"':
+                                       if (fLast != BACKSLASH) {
+                                               return postFix(STRING);
+
+                                       } else {
+                                               consume();
+                                               break;
+                                       }
+                               
+                               default:
+                                       consume();
+                                       break;
+                               }
+                               break;
+       
+                       case CHARACTER:
+                               switch (ch) {
+                               case '\\':
+                                       fLast= (fLast == BACKSLASH) ? NONE : BACKSLASH;
+                                       fTokenLength++;
+                                       if (fLast != BACKSLASH) {
+                                               return preFix(CHARACTER, CCODE, NONE, 1);
+                                       }
+                                       break;
+       
+                               default:
+                                       return postFix(CHARACTER);
+                               }
+                               break;
+                       }
+               }
+       }
+
+       private static final int getLastLength(int last) {
+               switch (last) {
+               default:
+                       return -1;
+
+               case NONE:
+                       return 0;
+                       
+               case CARRIAGE_RETURN:
+               case BACKSLASH:
+               case SLASH:
+               case STAR:
+                       return 1;
+
+               case SLASH_STAR:
+               case BACKSLASH_CR:
+               case BACKSLASH_BACKSLASH:
+                       return 2;
+
+               }
+       }
+
+       private final void consume() {
+               fTokenLength++;
+               fLast= NONE;
+       }
+       
+       private final IToken postFix(int state) {
+               fTokenLength++;
+               fLast= NONE;
+               fState= CCODE;
+               fPrefixLength= 0;
+               return fTokens[state];
+       }
+
+       private final IToken preFix(int state, int newState, int last, int prefixLength) {
+               fTokenLength -= getLastLength(fLast);
+               fLast= last;
+               fPrefixLength= prefixLength;
+               IToken token= fTokens[state];
+               fState= newState;
+               return token;
+       }
+
+       private static int getState(String contentType) {
+
+               if (contentType == null)
+                       return CCODE;
+
+               else if (contentType.equals(C_SINGLE_LINE_COMMENT))
+                       return SINGLE_LINE_COMMENT;
+
+               else if (contentType.equals(C_MULTI_LINE_COMMENT))
+                       return MULTI_LINE_COMMENT;
+
+               else if (contentType.equals(C_STRING))
+                       return STRING;
+
+               else if (contentType.equals(C_CHARACTER))
+                       return CHARACTER;
+
+               else if (contentType.equals(C_PREPROCESSOR))
+                       return PREPROCESSOR;
+                       
+               else
+                       return CCODE;
+       }
+
+       /*
+        * @see IPartitionTokenScanner#setPartialRange(IDocument, int, int, String, int)
+        */
+       public void setPartialRange(IDocument document, int offset, int length, String contentType, int partitionOffset) {
+
+               fScanner.setRange(document, offset, length);
+               fTokenOffset= partitionOffset;
+               fTokenLength= 0;
+               fPrefixLength= offset - partitionOffset;
+               fLast= NONE;
+               
+               if (offset == partitionOffset) {
+                       // restart at beginning of partition
+                       fState= CCODE;
+               } else {
+                       fState= getState(contentType);
+               }
+
+               try {
+                       int column= fScanner.getColumn();
+                       fFirstCharOnLine= column == 0 || document.get(offset-column, column).trim().length() == 0;
+               } catch (BadLocationException exc) {
+                       fFirstCharOnLine= true;
+               }
+       }
+
+       /*
+        * @see ITokenScanner#setRange(IDocument, int, int)
+        */
+       public void setRange(IDocument document, int offset, int length) {
+
+               fScanner.setRange(document, offset, length);
+               fTokenOffset= offset;
+               fTokenLength= 0;
+               fPrefixLength= 0;
+               fLast= NONE;
+               fState= CCODE;
+
+               try {
+                       int column= fScanner.getColumn();
+                       fFirstCharOnLine= column == 0 || document.get(offset-column, column).trim().length() == 0;
+               } catch (BadLocationException exc) {
+                       fFirstCharOnLine= true;
+               }
+       }
+
+       /*
+        * @see ITokenScanner#getTokenLength()
+        */
+       public int getTokenLength() {
+               return fTokenLength;
+       }
+
+       /*
+        * @see ITokenScanner#getTokenOffset()
+        */
+       public int getTokenOffset() {
+               return fTokenOffset;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AbstractAnnotationHover.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AbstractAnnotationHover.java
new file mode 100644 (file)
index 0000000..33e39b8
--- /dev/null
@@ -0,0 +1,790 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Sergey Prigogin (Google)
+ *     IBM Corporation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.c.hover;
+
+import java.util.Iterator;
+
+import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.core.filebuffers.ITextFileBufferManager;
+import org.eclipse.core.filebuffers.LocationKind;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ToolBarManager;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.AbstractInformationControl;
+import org.eclipse.jface.text.AbstractReusableInformationControlCreator;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IInformationControl;
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.IInformationControlExtension2;
+import org.eclipse.jface.text.IInformationControlExtension4;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.IRewriteTarget;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.ITextViewerExtension;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.ICompletionProposalExtension;
+import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.text.source.IAnnotationModelExtension2;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.ScrollBar;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IStorageEditorInput;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.texteditor.AnnotationPreference;
+import org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess;
+
+import com.ibm.icu.text.MessageFormat;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.editor.CAnnotationIterator;
+
+/**
+ * AbstractAnnotationHover
+ * Abstract super class for annotation hovers.
+ */
+public class AbstractAnnotationHover extends AbstractCEditorTextHover {
+
+       /**
+        * An annotation info contains information about an {@link Annotation}
+        * 
+        * @since 5.0
+        */
+       protected static class AnnotationInfo {
+               public final Annotation annotation;
+               public final Position position;
+               public final ITextViewer viewer;
+
+               public AnnotationInfo(Annotation annotation, Position position, ITextViewer textViewer) {
+                       this.annotation= annotation;
+                       this.position= position;
+                       this.viewer= textViewer;
+               }
+
+               /**
+                * Create completion proposals which can resolve the given annotation at
+                * the given position. Returns an empty array if no such proposals exist.
+                * 
+                * @return the proposals or an empty array
+                */
+               public ICompletionProposal[] getCompletionProposals() {
+                       return new ICompletionProposal[0];
+               }
+
+               /**
+                * Adds actions to the given toolbar.
+                * 
+                * @param manager the toolbar manager to add actions to
+                * @param infoControl the information control
+                */
+               public void fillToolBar(ToolBarManager manager, IInformationControl infoControl) {
+                       ConfigureAnnotationsAction configureAnnotationsAction= new ConfigureAnnotationsAction(annotation, infoControl);
+                       manager.add(configureAnnotationsAction);
+               }
+       }
+
+       /**
+        * The annotation information control shows informations about a given
+        * {@link AbstractAnnotationHover.AnnotationInfo}. It can also show a toolbar
+        * and a list of {@link ICompletionProposal}s.
+        * 
+        * @since 5.0
+        */
+       private static class AnnotationInformationControl extends AbstractInformationControl implements IInformationControlExtension2 {
+               private final DefaultMarkerAnnotationAccess fMarkerAnnotationAccess;
+               private Control fFocusControl;
+               private AnnotationInfo fInput;
+               private Composite fParent;
+
+               public AnnotationInformationControl(Shell parentShell, String statusFieldText) {
+                       super(parentShell, statusFieldText);
+                       
+                       fMarkerAnnotationAccess= new DefaultMarkerAnnotationAccess();
+                       create();
+               }
+
+               public AnnotationInformationControl(Shell parentShell, ToolBarManager toolBarManager) {
+                       super(parentShell, toolBarManager);
+                       
+                       fMarkerAnnotationAccess= new DefaultMarkerAnnotationAccess();
+                       create();
+               }
+               
+               /*
+                * @see org.eclipse.jface.text.IInformationControl#setInformation(java.lang.String)
+                */
+               @Override
+               public void setInformation(String information) {
+                       //replaced by IInformationControlExtension2#setInput
+               }
+
+               /*
+                * @see org.eclipse.jface.text.IInformationControlExtension2#setInput(java.lang.Object)
+                */
+               public void setInput(Object input) {
+                       Assert.isLegal(input instanceof AnnotationInfo);
+                       fInput= (AnnotationInfo)input;
+                       disposeDeferredCreatedContent();
+                       deferredCreateContent();
+               }
+               
+               /*
+                * @see org.eclipse.jface.text.IInformationControlExtension#hasContents()
+                */
+               public boolean hasContents() {
+                       return fInput != null;
+               }
+               
+               private AnnotationInfo getAnnotationInfo() {
+                       return fInput;
+               }
+
+               /*
+                * @see org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover.AbstractInformationControl#setFocus()
+                */
+               @Override
+               public void setFocus() {
+                       super.setFocus();
+                       if (fFocusControl != null && !fFocusControl.isDisposed())
+                               fFocusControl.setFocus();
+               }
+
+               /*
+                * @see org.eclipse.jface.text.AbstractInformationControl#setVisible(boolean)
+                */
+               @Override
+               public final void setVisible(boolean visible) {
+                       if (!visible)
+                               disposeDeferredCreatedContent();
+                       super.setVisible(visible);
+               }
+               
+               protected void disposeDeferredCreatedContent() {
+                       Control[] children= fParent.getChildren();
+                       for (Control element : children) {
+                               element.dispose();
+                       }
+                       ToolBarManager toolBarManager= getToolBarManager();
+                       if (toolBarManager != null)
+                               toolBarManager.removeAll();
+               }
+
+               /*
+                * @see org.eclipse.jface.text.AbstractInformationControl#createContent(org.eclipse.swt.widgets.Composite)
+                */
+               @Override
+               protected void createContent(Composite parent) {
+                       fParent= parent;
+                       GridLayout layout= new GridLayout(1, false);
+                       layout.verticalSpacing= 0;
+                       layout.marginWidth= 0;
+                       layout.marginHeight= 0;
+                       fParent.setLayout(layout);
+               }
+               
+               /*
+                * @see org.eclipse.jface.text.AbstractInformationControl#computeSizeHint()
+                */
+               @Override
+               public Point computeSizeHint() {
+                       Point preferedSize= getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
+
+                       Point constrains= getSizeConstraints();
+                       if (constrains == null)
+                               return preferedSize;
+
+                       Point constrainedSize= getShell().computeSize(constrains.x, SWT.DEFAULT, true);
+                       
+                       int width= Math.min(preferedSize.x, constrainedSize.x);
+                       int height= Math.max(preferedSize.y, constrainedSize.y);
+                       
+                       return new Point(width, height);
+               }
+
+               /**
+                * Fills the toolbar actions, if a toolbar is available. This
+                * is called after the input has been set.
+                */
+               protected void fillToolbar() {
+                       ToolBarManager toolBarManager= getToolBarManager();
+                       if (toolBarManager == null)
+                               return;
+                       fInput.fillToolBar(toolBarManager, this);
+                       toolBarManager.update(true);
+               }
+
+               /**
+                * Create content of the hover. This is called after
+                * the input has been set.
+                */
+               protected void deferredCreateContent() {
+                       fillToolbar();
+                       
+                       createAnnotationInformation(fParent, getAnnotationInfo().annotation);
+                       setColorAndFont(fParent, fParent.getForeground(), fParent.getBackground(), JFaceResources.getDialogFont());
+
+                       ICompletionProposal[] proposals= getAnnotationInfo().getCompletionProposals();
+                       if (proposals.length > 0)
+                               createCompletionProposalsControl(fParent, proposals);
+
+                       fParent.layout(true);
+               }
+
+               private void setColorAndFont(Control control, Color foreground, Color background, Font font) {
+                       control.setForeground(foreground);
+                       control.setBackground(background);
+                       control.setFont(font);
+                       
+                       if (control instanceof Composite) {
+                               Control[] children= ((Composite) control).getChildren();
+                               for (Control element : children) {
+                                       setColorAndFont(element, foreground, background, font);
+                               }
+                       }
+               }
+
+               private void createAnnotationInformation(Composite parent, final Annotation annotation) {
+                       Composite composite= new Composite(parent, SWT.NONE);
+                       composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+                       GridLayout layout= new GridLayout(2, false);
+                       layout.marginHeight= 2;
+                       layout.marginWidth= 2;
+                       layout.horizontalSpacing= 0;
+                       composite.setLayout(layout);
+
+                       final Canvas canvas= new Canvas(composite, SWT.NO_FOCUS);
+                       GridData gridData= new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
+                       gridData.widthHint= 17;
+                       gridData.heightHint= 16;
+                       canvas.setLayoutData(gridData);
+                       canvas.addPaintListener(new PaintListener() {
+                               public void paintControl(PaintEvent e) {
+                                       e.gc.setFont(null);
+                                       fMarkerAnnotationAccess.paint(annotation, e.gc, canvas, new Rectangle(0, 0, 16, 16));
+                               }
+                       });
+
+                       StyledText text= new StyledText(composite, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);
+                       GridData data= new GridData(SWT.FILL, SWT.FILL, true, true);
+                       text.setLayoutData(data);
+                       text.setText(annotation.getText());
+               }
+
+               private void createCompletionProposalsControl(Composite parent, ICompletionProposal[] proposals) {
+                       Composite composite= new Composite(parent, SWT.NONE);
+                       composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+                       GridLayout layout2= new GridLayout(1, false);
+                       layout2.marginHeight= 0;
+                       layout2.marginWidth= 0;
+                       layout2.verticalSpacing= 2;
+                       composite.setLayout(layout2);
+
+                       Label separator= new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
+                       GridData gridData= new GridData(SWT.FILL, SWT.CENTER, true, false);
+                       separator.setLayoutData(gridData);
+
+                       Label quickFixLabel= new Label(composite, SWT.NONE);
+                       GridData layoutData= new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
+                       layoutData.horizontalIndent= 4;
+                       quickFixLabel.setLayoutData(layoutData);
+                       String text;
+                       if (proposals.length == 1) {
+                               text= CHoverMessages.AbstractAnnotationHover_message_singleQuickFix;
+                       } else {
+                               text= MessageFormat.format(CHoverMessages.AbstractAnnotationHover_message_multipleQuickFix, new Object[] {String.valueOf(proposals.length)});
+                       }
+                       quickFixLabel.setText(text);
+
+                       setColorAndFont(composite, parent.getForeground(), parent.getBackground(), JFaceResources.getDialogFont());
+                       createCompletionProposalsList(composite, proposals);
+               }
+
+               private void createCompletionProposalsList(Composite parent, ICompletionProposal[] proposals) {
+                       final ScrolledComposite scrolledComposite= new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
+                       GridData gridData= new GridData(SWT.FILL, SWT.FILL, true, true);
+                       scrolledComposite.setLayoutData(gridData);
+                       scrolledComposite.setExpandVertical(false);
+                       scrolledComposite.setExpandHorizontal(false);
+
+                       Composite composite= new Composite(scrolledComposite, SWT.NONE);
+                       composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+                       GridLayout layout= new GridLayout(3, false);
+                       layout.verticalSpacing= 2;
+                       composite.setLayout(layout);
+
+                       final Link[] links= new Link[proposals.length];
+                       for (int i= 0; i < proposals.length; i++) {
+                               Label indent= new Label(composite, SWT.NONE);
+                               GridData gridData1= new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
+                               gridData1.widthHint= 0;
+                               indent.setLayoutData(gridData1);
+
+                               links[i]= createCompletionProposalLink(composite, proposals[i]);
+                       }
+
+                       scrolledComposite.setContent(composite);
+                       setColorAndFont(scrolledComposite, parent.getForeground(), parent.getBackground(), JFaceResources.getDialogFont());
+                       
+                       Point contentSize= composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+                       composite.setSize(contentSize);
+                       
+                       Point constraints= getSizeConstraints();
+                       if (constraints != null && contentSize.x < constraints.x) {
+                               ScrollBar horizontalBar= scrolledComposite.getHorizontalBar();
+                               
+                               int scrollBarHeight;
+                               if (horizontalBar == null) {
+                                       Point scrollSize= scrolledComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+                                       scrollBarHeight= scrollSize.y - contentSize.y;
+                               } else {
+                                       scrollBarHeight= horizontalBar.getSize().y;
+                               }
+                               gridData.heightHint= contentSize.y - scrollBarHeight;
+                       }
+
+                       fFocusControl= links[0];
+                       for (int i= 0; i < links.length; i++) {
+                               final int index= i;
+                               final Link link= links[index];
+                               link.addKeyListener(new KeyListener() {
+                                       public void keyPressed(KeyEvent e) {
+                                               switch (e.keyCode) {
+                                                       case SWT.ARROW_DOWN:
+                                                               if (index + 1 < links.length) {
+                                                                       links[index + 1].setFocus();
+                                                               }
+                                                               break;
+                                                       case SWT.ARROW_UP:
+                                                               if (index > 0) {
+                                                                       links[index - 1].setFocus();
+                                                               }
+                                                               break;
+                                                       default:
+                                                               break;
+                                               }
+                                       }
+
+                                       public void keyReleased(KeyEvent e) {
+                                       }
+                               });
+
+                               link.addFocusListener(new FocusListener() {
+                                       public void focusGained(FocusEvent e) {
+                                               int currentPosition= scrolledComposite.getOrigin().y;
+                                               int hight= scrolledComposite.getSize().y;
+                                               int linkPosition= link.getLocation().y;
+
+                                               if (linkPosition < currentPosition) {
+                                                       if (linkPosition < 10)
+                                                               linkPosition= 0;
+
+                                                       scrolledComposite.setOrigin(0, linkPosition);
+                                               } else if (linkPosition + 20 > currentPosition + hight) {
+                                                       scrolledComposite.setOrigin(0, linkPosition - hight + link.getSize().y);
+                                               }
+                                       }
+
+                                       public void focusLost(FocusEvent e) {
+                                       }
+                               });
+                       }
+               }
+
+               private Link createCompletionProposalLink(Composite parent, final ICompletionProposal proposal) {
+                       Label proposalImage= new Label(parent, SWT.NONE);
+                       proposalImage.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
+                       Image image= proposal.getImage();
+                       if (image != null) {
+                               proposalImage.setImage(image);
+
+                               proposalImage.addMouseListener(new MouseListener() {
+
+                                       public void mouseDoubleClick(MouseEvent e) {
+                                       }
+
+                                       public void mouseDown(MouseEvent e) {
+                                       }
+
+                                       public void mouseUp(MouseEvent e) {
+                                               if (e.button == 1) {
+                                                       apply(proposal, fInput.viewer, fInput.position.offset);
+                                               }
+                                       }
+
+                               });
+                       }
+
+                       Link proposalLink= new Link(parent, SWT.WRAP);
+                       proposalLink.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
+                       proposalLink.setText("<a>" + proposal.getDisplayString() + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$
+                       proposalLink.addSelectionListener(new SelectionAdapter() {
+                               /*
+                                * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+                                */
+                               @Override
+                               public void widgetSelected(SelectionEvent e) {
+                                       apply(proposal, fInput.viewer, fInput.position.offset);
+                               }
+                       });
+
+                       return proposalLink;
+               }
+
+               private void apply(ICompletionProposal p, ITextViewer viewer, int offset) {
+                       //Focus needs to be in the text viewer, otherwise linked mode does not work
+                       dispose();
+
+                       IRewriteTarget target= null;
+                       try {
+                               IDocument document= viewer.getDocument();
+
+                               if (viewer instanceof ITextViewerExtension) {
+                                       ITextViewerExtension extension= (ITextViewerExtension) viewer;
+                                       target= extension.getRewriteTarget();
+                               }
+
+                               if (target != null)
+                                       target.beginCompoundChange();
+
+                               if (p instanceof ICompletionProposalExtension2) {
+                                       ICompletionProposalExtension2 e= (ICompletionProposalExtension2) p;
+                                       e.apply(viewer, (char) 0, SWT.NONE, offset);
+                               } else if (p instanceof ICompletionProposalExtension) {
+                                       ICompletionProposalExtension e= (ICompletionProposalExtension) p;
+                                       e.apply(document, (char) 0, offset);
+                               } else {
+                                       p.apply(document);
+                               }
+
+                               Point selection= p.getSelection(document);
+                               if (selection != null) {
+                                       viewer.setSelectedRange(selection.x, selection.y);
+                                       viewer.revealRange(selection.x, selection.y);
+                               }
+                       } finally {
+                               if (target != null)
+                                       target.endCompoundChange();
+                       }
+               }
+       }
+
+       /**
+        * Presenter control creator.
+        *
+        * @since 5.0
+        */
+       private static final class PresenterControlCreator extends AbstractReusableInformationControlCreator {
+               /*
+                * @see org.eclipse.jdt.internal.ui.text.java.hover.AbstractReusableInformationControlCreator#doCreateInformationControl(org.eclipse.swt.widgets.Shell)
+                */
+               @Override
+               public IInformationControl doCreateInformationControl(Shell parent) {
+                       return new AnnotationInformationControl(parent, new ToolBarManager(SWT.FLAT));
+               }
+       }
+
+
+       /**
+        * Hover control creator.
+        *
+        * @since 5.0
+        */
+       private static final class HoverControlCreator extends AbstractReusableInformationControlCreator {
+               private final IInformationControlCreator fPresenterControlCreator;
+
+               public HoverControlCreator(IInformationControlCreator presenterControlCreator) {
+                       fPresenterControlCreator= presenterControlCreator;
+               }
+               
+               /*
+                * @see org.eclipse.jdt.internal.ui.text.java.hover.AbstractReusableInformationControlCreator#doCreateInformationControl(org.eclipse.swt.widgets.Shell)
+                */
+               @Override
+               public IInformationControl doCreateInformationControl(Shell parent) {
+                       return new AnnotationInformationControl(parent, EditorsUI.getTooltipAffordanceString()) {
+                               /*
+                                * @see org.eclipse.jface.text.IInformationControlExtension5#getInformationPresenterControlCreator()
+                                */
+                               @Override
+                               public IInformationControlCreator getInformationPresenterControlCreator() {
+                                       return fPresenterControlCreator;
+                               }
+                       };
+               }
+               
+               /*
+                * @see org.eclipse.jdt.internal.ui.text.java.hover.AbstractReusableInformationControlCreator#canReuse(org.eclipse.jface.text.IInformationControl)
+                */
+               @Override
+               public boolean canReuse(IInformationControl control) {
+                       if (!super.canReuse(control))
+                               return false;
+
+                       if (control instanceof IInformationControlExtension4)
+                               ((IInformationControlExtension4) control).setStatusText(EditorsUI.getTooltipAffordanceString());
+
+                       return true;
+               }
+       }
+       
+       /**
+        * Action to configure the annotation preferences.
+        * 
+        * @since 5.0
+        */
+       private static final class ConfigureAnnotationsAction extends Action {
+
+               private final Annotation fAnnotation;
+               private final IInformationControl fInfoControl;
+
+               public ConfigureAnnotationsAction(Annotation annotation, IInformationControl infoControl) {
+                       super();
+                       fAnnotation= annotation;
+                       fInfoControl= infoControl;
+                       setImageDescriptor(CPluginImages.DESC_ELCL_CONFIGURE_ANNOTATIONS);
+                       setDisabledImageDescriptor(CPluginImages.DESC_DLCL_CONFIGURE_ANNOTATIONS);
+                       setToolTipText(CHoverMessages.AbstractAnnotationHover_action_configureAnnotationPreferences);
+               }
+
+               /*
+                * @see org.eclipse.jface.action.Action#run()
+                */
+               @Override
+               public void run() {
+                       Shell shell= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+                       
+                       Object data= null;
+                       AnnotationPreference preference= getAnnotationPreference(fAnnotation);
+                       if (preference != null)
+                               data= preference.getPreferenceLabel();
+                       
+                       fInfoControl.dispose(); //FIXME: should have protocol to hide, rather than dispose
+                       PreferencesUtil.createPreferenceDialogOn(shell, "org.eclipse.ui.editors.preferencePages.Annotations", null, data).open(); //$NON-NLS-1$
+               }
+       }
+
+       private final IPreferenceStore fStore= CUIPlugin.getDefault().getCombinedPreferenceStore();
+       private final DefaultMarkerAnnotationAccess fAnnotationAccess= new DefaultMarkerAnnotationAccess();
+       private final boolean fAllAnnotations;
+
+       /**
+        * The hover control creator.
+        * 
+        * @since 5.0
+        */
+       private IInformationControlCreator fHoverControlCreator;
+       /**
+        * The presentation control creator.
+        * 
+        * @since 5.0
+        */
+       private IInformationControlCreator fPresenterControlCreator;
+       
+       public AbstractAnnotationHover(boolean allAnnotations) {
+               fAllAnnotations= allAnnotations;
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.ITextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
+        */
+       @Override
+       public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.jdt.internal.ui.text.java.hover.AbstractJavaEditorTextHover#getHoverInfo2(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
+        * @since 5.0
+        */
+       @Override
+       public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
+               IPath path;
+               IAnnotationModel model;
+               if (textViewer instanceof ISourceViewer) {
+                       path= null;
+                       model= ((ISourceViewer)textViewer).getAnnotationModel();
+               } else {
+                       // Get annotation model from file buffer manager
+                       path= getEditorInputPath();
+                       model= getAnnotationModel(path);
+               }
+               if (model == null)
+                       return null;
+
+               try {
+                       @SuppressWarnings("rawtypes")
+                       Iterator parent;
+                       if (model instanceof IAnnotationModelExtension2)
+                               parent= ((IAnnotationModelExtension2) model).getAnnotationIterator(hoverRegion.getOffset(), hoverRegion.getLength(), true, true);
+                       else
+                               parent= model.getAnnotationIterator();
+                       @SuppressWarnings("unchecked")
+                       Iterator<Annotation> e= new CAnnotationIterator(parent, fAllAnnotations);
+                       
+                       int layer= -1;
+                       Annotation annotation= null;
+                       Position position= null;
+                       while (e.hasNext()) {
+                               Annotation a= e.next();
+
+                               AnnotationPreference preference= getAnnotationPreference(a);
+                               if (preference == null || !(preference.getTextPreferenceKey() != null && fStore.getBoolean(preference.getTextPreferenceKey()) || (preference.getHighlightPreferenceKey() != null && fStore.getBoolean(preference.getHighlightPreferenceKey()))))
+                                       continue;
+
+                               Position p= model.getPosition(a);
+
+                               int l= fAnnotationAccess.getLayer(a);
+
+                               if (l > layer && p != null && p.overlapsWith(hoverRegion.getOffset(), hoverRegion.getLength())) {
+                                       String msg= a.getText();
+                                       if (msg != null && msg.trim().length() > 0) {
+                                               layer= l;
+                                               annotation= a;
+                                               position= p;
+                                       }
+                               }
+                       }
+                       if (layer > -1)
+                               return createAnnotationInfo(annotation, position, textViewer);
+
+               } finally {
+                       try {
+                               if (path != null) {
+                                       ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
+                                       manager.disconnect(path, LocationKind.NORMALIZE, null);
+                               }
+                       } catch (CoreException e) {
+                               CUIPlugin.log(e.getStatus());
+                       }
+               }
+
+               return null;
+       }
+
+       protected AnnotationInfo createAnnotationInfo(Annotation annotation, Position position, ITextViewer textViewer) {
+               return new AnnotationInfo(annotation, position, textViewer);
+       }
+
+       /*
+        * @see ITextHoverExtension#getHoverControlCreator()
+        * @since 5.0
+        */
+       @Override
+       public IInformationControlCreator getHoverControlCreator() {
+               if (fHoverControlCreator == null)
+                       fHoverControlCreator= new HoverControlCreator(getInformationPresenterControlCreator());
+               return fHoverControlCreator;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.ITextHoverExtension2#getInformationPresenterControlCreator()
+        * @since 5.0
+        */
+       @Override
+       public IInformationControlCreator getInformationPresenterControlCreator() {
+               if (fPresenterControlCreator == null)
+                       fPresenterControlCreator= new PresenterControlCreator();
+               return fPresenterControlCreator;
+       }
+
+       private IPath getEditorInputPath() {
+               if (getEditor() == null)
+                       return null;
+
+               IEditorInput input= getEditor().getEditorInput();
+               if (input instanceof IStorageEditorInput) {
+                       try {
+                               return ((IStorageEditorInput)input).getStorage().getFullPath();
+                       } catch (CoreException e) {
+                               CUIPlugin.log(e.getStatus());
+                       }
+               }
+               return null;
+       }
+
+       private IAnnotationModel getAnnotationModel(IPath path) {
+               if (path == null)
+                       return null;
+
+               ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
+               try {
+                       manager.connect(path, LocationKind.NORMALIZE, null);
+               } catch (CoreException e) {
+                       CUIPlugin.log(e.getStatus());
+                       return null;
+               }
+
+               IAnnotationModel model= null;
+               try {
+                       model= manager.getTextFileBuffer(path, LocationKind.NORMALIZE).getAnnotationModel();
+                       return model;
+               } finally {
+                       if (model == null) {
+                               try {
+                                       manager.disconnect(path, LocationKind.NORMALIZE, null);
+                               } catch (CoreException e) {
+                                       CUIPlugin.log(e.getStatus());
+                               }
+                       }
+               }
+       }
+
+       /**
+        * Returns the annotation preference for the given annotation.
+        *
+        * @param annotation the annotation
+        * @return the annotation preference or <code>null</code> if none
+        */
+       private static AnnotationPreference getAnnotationPreference(Annotation annotation) {
+               if (annotation.isMarkedDeleted())
+                       return null;
+               return EditorsUI.getAnnotationPreferenceLookup().getAnnotationPreference(annotation);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AbstractCEditorTextHover.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AbstractCEditorTextHover.java
new file mode 100644 (file)
index 0000000..6280712
--- /dev/null
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     IBM Corporation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.c.hover;
+
+import org.eclipse.jface.text.DefaultInformationControl;
+import org.eclipse.jface.text.IInformationControl;
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextHoverExtension;
+import org.eclipse.jface.text.ITextHoverExtension2;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.information.IInformationProviderExtension2;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.editors.text.EditorsUI;
+
+import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
+
+import org.eclipse.cdt.internal.ui.text.CWordFinder;
+
+/**
+ * Abstract class for providing hover information for C
+ * elements.
+ * 
+ */
+public abstract class AbstractCEditorTextHover implements ICEditorTextHover, ITextHoverExtension, ITextHoverExtension2, IInformationProviderExtension2 {
+
+       private IEditorPart fEditor;
+
+       /*
+        * @see ICEditorTextHover#setEditor(IEditorPart)
+        */
+       public void setEditor(IEditorPart editor) {
+               fEditor = editor;
+       }
+
+       protected IEditorPart getEditor() {
+               return fEditor;
+       }
+
+       /*
+        * @see ITextHover#getHoverRegion(ITextViewer, int)
+        */
+       public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
+               if (textViewer != null) {
+                       /*
+                        * If the hover offset falls within the selection range return the
+                        * region for the whole selection.
+                        */
+                       Point selectedRange = textViewer.getSelectedRange();
+                       if (selectedRange.x >= 0 && selectedRange.y > 0
+                                       && offset >= selectedRange.x
+                                       && offset <= selectedRange.x + selectedRange.y)
+                               return new Region(selectedRange.x, selectedRange.y);
+                       
+                       return CWordFinder.findWord(textViewer.getDocument(), offset);
+               }
+               return null;
+       }
+
+       /*
+        * @see ITextHover#getHoverInfo(ITextViewer, IRegion)
+        */
+       public abstract String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion);
+
+       /*
+        * @see ITextHoverExtension2#getHoverInfo2(ITextViewer, IRegion)
+        */
+       public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
+               return getHoverInfo(textViewer, hoverRegion);
+       }
+
+       /*
+        * @see ITextHoverExtension#getHoverControlCreator()
+        * @since 3.0
+        */
+       public IInformationControlCreator getHoverControlCreator() {
+               return new IInformationControlCreator() {
+                       public IInformationControl createInformationControl(Shell parent) {
+                               return new DefaultInformationControl(parent, getTooltipAffordanceString());
+                       }
+               };
+       }
+
+       /*
+        * @see org.eclipse.jface.text.ITextHoverExtension2#getInformationPresenterControlCreator()
+        * @since 5.0
+        */
+       public IInformationControlCreator getInformationPresenterControlCreator() {
+               return new IInformationControlCreator() {
+                       public IInformationControl createInformationControl(Shell shell) {
+                               return new DefaultInformationControl(shell, true);
+                       }
+               };
+       }
+
+       /**
+        * Returns the tool tip affordance string.
+        * 
+        * @return the affordance string or <code>null</code> if disabled or no
+        *         key binding is defined
+        * @since 3.0
+        */
+       protected String getTooltipAffordanceString() {
+               return EditorsUI.getTooltipAffordanceString();
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AnnotationHover.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AnnotationHover.java
new file mode 100644 (file)
index 0000000..0760c04
--- /dev/null
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2006 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.c.hover;
+
+/**
+ * AnnotationHover
+ * This annotation hover shows the description of the
+ * selected annotation. 
+ */
+public class AnnotationHover extends AbstractAnnotationHover {
+
+       public AnnotationHover() {
+               super(true);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/BestMatchHover.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/BestMatchHover.java
new file mode 100644 (file)
index 0000000..e272274
--- /dev/null
@@ -0,0 +1,191 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Ericsson             - Fix improper hover order (Bug 294812)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.c.hover;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextHover;
+import org.eclipse.jface.text.ITextHoverExtension;
+import org.eclipse.jface.text.ITextHoverExtension2;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.information.IInformationProviderExtension2;
+import org.eclipse.ui.IEditorPart;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
+
+/**
+ * 'Fake' hover used to choose the best available hover.
+ * This hover is always the first hover used and will delegate the hover
+ * request to the best of the real hovers.  The 'best' hover is the first 
+ * hover that returns some text for the specified parameters.
+ * 
+ * Note that hovers are ordered by plugin dependency, with the most specific
+ * hovers being placed before less specific ones.
+ */
+public class BestMatchHover extends AbstractCEditorTextHover {
+
+       /*
+        * Note that hover ordering is very important to be preserved by this
+        * class. (Bug 294812)
+        */
+       private List<CEditorTextHoverDescriptor> fTextHoverSpecifications;
+       private List<ITextHover> fInstantiatedTextHovers;
+       private ITextHover fBestHover;
+
+       public BestMatchHover() {
+               installTextHovers();
+       }
+
+       public BestMatchHover(IEditorPart editor) {
+               this();
+               setEditor(editor);
+       }
+       
+       /**
+        * Installs all text hovers.
+        */
+       private void installTextHovers() {
+               CEditorTextHoverDescriptor[] hoverDescs= CUIPlugin.getDefault().getCEditorTextHoverDescriptors();
+               
+               // initialize lists - indicates that the initialization happened
+               fTextHoverSpecifications= new ArrayList<CEditorTextHoverDescriptor>(hoverDescs.length-1);
+               fInstantiatedTextHovers= new ArrayList<ITextHover>(hoverDescs.length-1);
+
+               // populate list
+               for (int i= 0; i < hoverDescs.length; i++) {
+                       // ensure that we don't add ourselves to the list
+                       if (!PreferenceConstants.ID_BESTMATCH_HOVER.equals(hoverDescs[i].getId())) {
+                               fTextHoverSpecifications.add(hoverDescs[i]);
+                               // add place-holder for hover instance
+                               fInstantiatedTextHovers.add(null);
+                       }
+               }
+       }
+
+       private void checkTextHovers() {
+               if (fTextHoverSpecifications == null)
+                       return;
+
+               boolean allCreated = true;
+               for (int i= 0; i < fTextHoverSpecifications.size(); ++i) {
+                       CEditorTextHoverDescriptor spec= fTextHoverSpecifications.get(i);
+                       if (spec == null) continue;
+                       
+                       ICEditorTextHover hover= spec.createTextHover();
+                       if (hover != null) {
+                               hover.setEditor(getEditor());
+                               // remember instance and mark as created
+                               fInstantiatedTextHovers.set(i, hover);
+                               fTextHoverSpecifications.set(i, null);
+                       } else {
+                               allCreated = false;
+                       }
+               }
+               
+               if (allCreated) {
+                       fTextHoverSpecifications = null;
+               }
+       }
+
+       /*
+        * @see ITextHover#getHoverInfo(ITextViewer, IRegion)
+        */
+       @SuppressWarnings("deprecation")
+       @Override
+       public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
+
+               checkTextHovers();
+               fBestHover= null;
+
+               if (fInstantiatedTextHovers == null)
+                       return null;
+
+               for (ITextHover hover : fInstantiatedTextHovers) {
+                       if (hover == null) continue;
+
+                       String s= hover.getHoverInfo(textViewer, hoverRegion);
+                       if (s != null && s.trim().length() > 0) {
+                               fBestHover= hover;
+                               return s;
+                       }
+               }
+
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.ITextHoverExtension2#getHoverInfo2(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
+        */
+       @SuppressWarnings("deprecation")
+       @Override
+       public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
+               
+               checkTextHovers();
+               fBestHover= null;
+               
+               if (fInstantiatedTextHovers == null)
+                       return null;
+               
+               for (ITextHover hover : fInstantiatedTextHovers) {
+                       if (hover == null) continue;
+
+                       if (hover instanceof ITextHoverExtension2) {
+                               Object info= ((ITextHoverExtension2) hover).getHoverInfo2(textViewer, hoverRegion);
+                               if (info != null) {
+                                       fBestHover= hover;
+                                       return info;
+                               }
+                       } else {
+                               String s= hover.getHoverInfo(textViewer, hoverRegion);
+                               if (s != null && s.trim().length() > 0) {
+                                       fBestHover= hover;
+                                       return s;
+                               }
+                       }
+               }
+               
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.ITextHoverExtension#getHoverControlCreator()
+        * @since 3.0
+        */
+       @Override
+       public IInformationControlCreator getHoverControlCreator() {
+               if (fBestHover instanceof ITextHoverExtension)
+                       return ((ITextHoverExtension)fBestHover).getHoverControlCreator();
+
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.information.IInformationProviderExtension2#getInformationPresenterControlCreator()
+        * @since 3.0
+        */
+       @Override
+       public IInformationControlCreator getInformationPresenterControlCreator() {
+               // this is wrong, but left here for backwards compatibility
+               if (fBestHover instanceof IInformationProviderExtension2)
+                       return ((IInformationProviderExtension2)fBestHover).getInformationPresenterControlCreator();
+
+               return null;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CDocHover.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CDocHover.java
new file mode 100644 (file)
index 0000000..e912220
--- /dev/null
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.c.hover;
+
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Region;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.ui.IEditorInput;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.IFunctionSummary;
+import org.eclipse.cdt.ui.IRequiredInclude;
+import org.eclipse.cdt.ui.IFunctionSummary.IFunctionPrototypeSummary;
+import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
+import org.eclipse.cdt.ui.text.IHoverHelpInvocationContext;
+
+import org.eclipse.cdt.internal.ui.CHelpProviderManager;
+import org.eclipse.cdt.internal.ui.editor.CEditorMessages;
+import org.eclipse.cdt.internal.ui.text.CWordFinder;
+import org.eclipse.cdt.internal.ui.text.HTMLPrinter;
+
+public class CDocHover extends AbstractCEditorTextHover {
+       
+       /**
+        * Constructor for DefaultCEditorTextHover
+        */
+       public CDocHover() {
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.text.ITextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
+        */
+       @Override
+       public String getHoverInfo(ITextViewer viewer, IRegion region) {
+               String expression = null;
+               
+               if (getEditor() == null) 
+                       return null;
+               try {
+                       expression = viewer.getDocument().get(region.getOffset(), region.getLength());
+                       expression = expression.trim();
+                       if (expression.length() == 0)
+                               return null; 
+
+                       StringBuilder buffer = new StringBuilder();
+                       final IRegion hoverRegion = region;
+
+                       // call the Help to get info
+
+                       ICHelpInvocationContext context = new IHoverHelpInvocationContext() {
+
+                               public IProject getProject() {
+                                       ITranslationUnit unit = getTranslationUnit();
+                                       if (unit != null) {
+                                               return unit.getCProject().getProject();
+                                       }
+                                       return null;
+                               }
+
+                               public ITranslationUnit getTranslationUnit() {
+                                       IEditorInput editorInput= getEditor().getEditorInput();
+                                       return CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput);
+                               }
+
+                               public IRegion getHoverRegion() {
+                                       return hoverRegion; 
+                               }
+                               
+                       };
+
+                       IFunctionSummary fs = CHelpProviderManager.getDefault().getFunctionInfo(context, expression);
+                       if (fs != null) {
+                               buffer.append(CEditorMessages.DefaultCEditorTextHover_html_name); 
+                               buffer.append(HTMLPrinter.convertToHTMLContent(fs.getName()));
+                               final IFunctionPrototypeSummary prototype = fs.getPrototype();
+                               if (prototype != null) {
+                                       buffer.append(CEditorMessages.DefaultCEditorTextHover_html_prototype); 
+                                       buffer.append(HTMLPrinter.convertToHTMLContent(prototype.getPrototypeString(false)));
+                               }
+                               if(fs.getDescription() != null) {
+                                       buffer.append(CEditorMessages.DefaultCEditorTextHover_html_description); 
+                                       //Don't convert this description since it could already be formatted
+                                       buffer.append(fs.getDescription());
+                               }
+                               IRequiredInclude[] incs = fs.getIncludes();
+                               if (incs != null && incs.length > 0) {
+                                       buffer.append(CEditorMessages.DefaultCEditorTextHover_html_includes); 
+                                       int count = 0;
+                                       for (IRequiredInclude inc : incs) {
+                                               buffer.append(inc.getIncludeName());
+                                               buffer.append("<br>");        //$NON-NLS-1$
+                                               if (count++ > 4) {
+                                                       buffer.append("...<br>"); //$NON-NLS-1$
+                                                       break; // too long list: do not display all 
+                                               }
+                                       }
+                               }
+                       } 
+                       if (buffer.length() > 0) {
+                               HTMLPrinter.insertPageProlog(buffer, 0);
+                               HTMLPrinter.addPageEpilog(buffer);
+                               return buffer.toString();
+                       }
+               } catch(Exception ex) {
+                       /* Ignore */
+               }
+               
+               return null;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.text.ITextHover#getHoverRegion(org.eclipse.jface.text.ITextViewer, int)
+        */
+       @Override
+       public IRegion getHoverRegion(ITextViewer viewer, int offset) {
+               if (viewer != null) {
+                       Point selectedRange = viewer.getSelectedRange();
+                       if (selectedRange.x >= 0 && 
+                                       selectedRange.y > 0 &&
+                                       offset >= selectedRange.x &&
+                                       offset <= selectedRange.x + selectedRange.y)
+                               return new Region( selectedRange.x, selectedRange.y );
+                       
+                       return CWordFinder.findWord(viewer.getDocument(), offset);
+               }
+               return null;
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CEditorTextHoverDescriptor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CEditorTextHoverDescriptor.java
new file mode 100644 (file)
index 0000000..0640af7
--- /dev/null
@@ -0,0 +1,300 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.c.hover;
+
+import com.ibm.icu.text.Collator;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.swt.SWT;
+import org.osgi.framework.Bundle;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
+
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+
+/**
+ * CEditorTexHoverDescriptor
+ */
+public class CEditorTextHoverDescriptor implements Comparable<CEditorTextHoverDescriptor> {
+
+       private static final String C_EDITOR_TEXT_HOVER_EXTENSION_POINT= "org.eclipse.cdt.ui.textHovers"; //$NON-NLS-1$
+       private static final String HOVER_TAG= "hover"; //$NON-NLS-1$
+       private static final String ID_ATTRIBUTE= "id"; //$NON-NLS-1$
+       private static final String CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$
+       private static final String LABEL_ATTRIBUTE= "label"; //$NON-NLS-1$
+       private static final String ACTIVATE_PLUG_IN_ATTRIBUTE= "activate"; //$NON-NLS-1$
+       private static final String DESCRIPTION_ATTRIBUTE= "description"; //$NON-NLS-1$
+       private static final String PERSPECTIVE= "perspective"; //$NON-NLS-1$
+
+       public static final String NO_MODIFIER= "0"; //$NON-NLS-1$
+       public static final String DISABLED_TAG= "!"; //$NON-NLS-1$
+       public static final String VALUE_SEPARATOR= ";"; //$NON-NLS-1$
+
+       private int fStateMask;
+       private String fModifierString;
+       private boolean fIsEnabled;
+
+       private IConfigurationElement fElement;
+       
+       
+       /**
+        * Returns all C editor text hovers contributed to the workbench.
+        */
+       public static CEditorTextHoverDescriptor[] getContributedHovers() {
+               IExtensionRegistry registry= Platform.getExtensionRegistry();
+               IConfigurationElement[] elements= registry.getConfigurationElementsFor(C_EDITOR_TEXT_HOVER_EXTENSION_POINT);
+               CEditorTextHoverDescriptor[] hoverDescs= createDescriptors(elements);
+               initializeFromPreferences(hoverDescs);
+               return hoverDescs;
+       } 
+
+       /**
+        * Computes the state mask for the given modifier string.
+        * 
+        * @param modifiers     the string with the modifiers, separated by '+', '-', ';', ',' or '.'
+        * @return the state mask or -1 if the input is invalid
+        */
+       public static int computeStateMask(String modifiers) {
+               if (modifiers == null)
+                       return -1;
+               
+               if (modifiers.length() == 0)
+                       return SWT.NONE;
+
+               int stateMask= 0;
+               StringTokenizer modifierTokenizer= new StringTokenizer(modifiers, ",;.:+-* "); //$NON-NLS-1$
+               while (modifierTokenizer.hasMoreTokens()) {
+                       int modifier= EditorUtility.findLocalizedModifier(modifierTokenizer.nextToken());
+                       if (modifier == 0 || (stateMask & modifier) == modifier)
+                               return -1;
+                       stateMask= stateMask | modifier;
+               }
+               return stateMask;
+       }
+
+       /**
+        * Creates a new C Editor text hover descriptor from the given configuration element.
+        */
+       private CEditorTextHoverDescriptor(IConfigurationElement element) {
+               Assert.isNotNull(element);
+               fElement= element;
+       }
+
+       /**
+        * Creates the C editor text hover.
+        */
+       public ICEditorTextHover createTextHover() {
+               String pluginId = fElement.getDeclaringExtension().getContributor().getName();
+               boolean isHoversPlugInActivated= Platform.getBundle(pluginId).getState() == Bundle.ACTIVE;
+               if (isHoversPlugInActivated || canActivatePlugIn()) {
+                       try {
+                               return (ICEditorTextHover)fElement.createExecutableExtension(CLASS_ATTRIBUTE);
+                       } catch (CoreException x) {
+                               CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), 0, "CEditorTextHover.createTextHover", null)); //$NON-NLS-1$
+                       }
+               }
+               
+               return null;
+       }
+       
+       //---- XML Attribute accessors ---------------------------------------------
+       
+       /**
+        * Returns the hover's id.
+        */
+       public String getId() {
+                       return fElement.getAttribute(ID_ATTRIBUTE);
+       }
+
+       /**
+        * Returns the hover's class name.
+        */
+       public String getHoverClassName() {
+               return fElement.getAttribute(CLASS_ATTRIBUTE);
+       }
+        
+       /**
+        * Returns the hover's label.
+        */
+       public String getLabel() {
+               String label= fElement.getAttribute(LABEL_ATTRIBUTE);
+               if (label != null)
+                       return label;
+                       
+               // Return simple class name
+               label= getHoverClassName();
+               int lastDot= label.lastIndexOf('.');
+               if (lastDot >= 0 && lastDot < label.length() - 1) {
+                       return label.substring(lastDot + 1);
+               }
+               return label;
+       }
+
+       /**
+        * Returns the hover's description.
+        * 
+        * @return the hover's description or <code>null</code> if not provided
+        */
+       public String getDescription() {
+               return fElement.getAttribute(DESCRIPTION_ATTRIBUTE);
+       }
+
+       public String getPerspective() {
+               return fElement.getAttribute(PERSPECTIVE);
+       }
+
+       public boolean canActivatePlugIn() {
+               return Boolean.valueOf(fElement.getAttribute(ACTIVATE_PLUG_IN_ATTRIBUTE)).booleanValue();
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               if (obj == null || !obj.getClass().equals(this.getClass()) || getId() == null)
+                       return false;
+               return getId().equals(((CEditorTextHoverDescriptor)obj).getId());
+       }
+
+       @Override
+       public int hashCode() {
+               return getId().hashCode();
+       }
+       
+       /**
+        * {@inheritDoc}
+        */
+       public int compareTo(CEditorTextHoverDescriptor o) {
+               return Collator.getInstance().compare(getLabel(), o.getLabel());
+       }
+
+       private static CEditorTextHoverDescriptor[] createDescriptors(IConfigurationElement[] elements) {
+               List<CEditorTextHoverDescriptor> result= new ArrayList<CEditorTextHoverDescriptor>(elements.length);
+               for (IConfigurationElement element : elements) {
+                       if (HOVER_TAG.equals(element.getName())) {
+                               CEditorTextHoverDescriptor desc= new CEditorTextHoverDescriptor(element);
+                               result.add(desc);
+                       }
+               }
+               Collections.sort(result);
+               return result.toArray(new CEditorTextHoverDescriptor[result.size()]);
+       }
+
+       private static void initializeFromPreferences(CEditorTextHoverDescriptor[] hovers) {
+               String compiledTextHoverModifiers= CUIPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS);
+               
+               StringTokenizer tokenizer= new StringTokenizer(compiledTextHoverModifiers, VALUE_SEPARATOR);
+               HashMap<String, String> idToModifier= new HashMap<String, String>(tokenizer.countTokens() / 2);
+
+               while (tokenizer.hasMoreTokens()) {
+                       String id= tokenizer.nextToken();
+                       if (tokenizer.hasMoreTokens())
+                               idToModifier.put(id, tokenizer.nextToken());
+               }
+
+               String compiledTextHoverModifierMasks= CUIPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS);
+
+               tokenizer= new StringTokenizer(compiledTextHoverModifierMasks, VALUE_SEPARATOR);
+               HashMap<String, String> idToModifierMask= new HashMap<String, String>(tokenizer.countTokens() / 2);
+
+               while (tokenizer.hasMoreTokens()) {
+                       String id= tokenizer.nextToken();
+                       if (tokenizer.hasMoreTokens())
+                               idToModifierMask.put(id, tokenizer.nextToken());
+               }
+
+               for (int i= 0; i < hovers.length; i++) {
+                       String modifierString= idToModifier.get(hovers[i].getId());
+                       boolean enabled= true;
+                       if (modifierString == null)
+                               modifierString= DISABLED_TAG;
+                       
+                       if (modifierString.startsWith(DISABLED_TAG)) {
+                               enabled= false;
+                               modifierString= modifierString.substring(1);
+                       }
+
+                       if (modifierString.equals(NO_MODIFIER))
+                               modifierString= ""; //$NON-NLS-1$
+
+                       hovers[i].fModifierString= modifierString;
+                       hovers[i].fIsEnabled= enabled;
+                       hovers[i].fStateMask= computeStateMask(modifierString);
+                       if (hovers[i].fStateMask == -1) {
+                               // Fallback: use stored modifier masks
+                               try {
+                                       hovers[i].fStateMask= Integer.parseInt(idToModifierMask.get(hovers[i].getId()));
+                               } catch (NumberFormatException ex) {
+                                       hovers[i].fStateMask= -1;
+                               }
+                               // Fix modifier string
+                               int stateMask= hovers[i].fStateMask;
+                               if (stateMask == -1)
+                                       hovers[i].fModifierString= ""; //$NON-NLS-1$
+                               else
+                                       hovers[i].fModifierString= EditorUtility.getModifierString(stateMask);
+                       }
+               }
+       }
+       
+       /**
+        * Returns the configured modifier getStateMask for this hover.
+        * 
+        * @return the hover modifier stateMask or -1 if no hover is configured
+        */
+       public int getStateMask() {
+               return fStateMask;
+       }
+
+       /**
+        * Returns the modifier String as set in the preference store.
+        * 
+        * @return the modifier string
+        */
+       public String getModifierString() {
+               return fModifierString;
+       }
+
+       /**
+        * Returns whether this hover is enabled or not.
+        * 
+        * @return <code>true</code> if enabled
+        */
+       public boolean isEnabled() {
+               return fIsEnabled;
+       }
+       
+       /**
+        * Returns this hover descriptors configuration element.
+        * 
+        * @return the configuration element
+        */
+       public IConfigurationElement getConfigurationElement() {
+               return fElement;
+       }
+
+       @Override
+       public String toString() {
+               return getId();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CEditorTextHoverProxy.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CEditorTextHoverProxy.java
new file mode 100644 (file)
index 0000000..b766047
--- /dev/null
@@ -0,0 +1,136 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.c.hover;
+
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextHoverExtension;
+import org.eclipse.jface.text.ITextHoverExtension2;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.information.IInformationProviderExtension2;
+import org.eclipse.ui.IEditorPart;
+
+import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
+
+/**
+ * CEditorTexHoverProxy
+ */
+public class CEditorTextHoverProxy extends AbstractCEditorTextHover {
+
+       private CEditorTextHoverDescriptor fHoverDescriptor;
+       private ICEditorTextHover fHover;
+
+       public CEditorTextHoverProxy(CEditorTextHoverDescriptor descriptor, IEditorPart editor) {
+               fHoverDescriptor= descriptor;
+               setEditor(editor);
+       }
+
+       /*
+        * @see ICEditorTextHover#setEditor(IEditorPart)
+        */
+       @Override
+       public void setEditor(IEditorPart editor) {
+               super.setEditor(editor);
+
+               if (fHover != null)
+                       fHover.setEditor(getEditor());
+       }
+
+       public boolean isEnabled() {
+               return true;
+       }
+
+       /*
+        * @see ITextHover#getHoverRegion(ITextViewer, int)
+        */
+       @Override
+       public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
+               if (ensureHoverCreated())
+                       return fHover.getHoverRegion(textViewer, offset);
+
+               return null;
+       }
+       
+       /*
+        * @see ITextHover#getHoverInfo(ITextViewer, IRegion)
+        */
+       @SuppressWarnings("deprecation")
+       @Override
+       public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
+               if (ensureHoverCreated())
+                       return fHover.getHoverInfo(textViewer, hoverRegion);
+
+               return null;
+       }
+
+       
+       /*
+        * @see org.eclipse.jface.text.ITextHoverExtension2#getHoverInfo2(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
+        * @since 5.0
+        */
+       @SuppressWarnings("deprecation")
+       @Override
+       public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
+               if (ensureHoverCreated()) {
+                       if (fHover instanceof ITextHoverExtension2)
+                               return ((ITextHoverExtension2) fHover).getHoverInfo2(textViewer, hoverRegion);
+                       
+                       return fHover.getHoverInfo(textViewer, hoverRegion);
+               }
+
+               return null;
+       }
+
+       private boolean ensureHoverCreated() {
+               if (!isEnabled() || fHoverDescriptor == null)
+                       return false;
+               return isCreated() || createHover();
+       }
+
+       private boolean isCreated() {
+               return fHover != null;
+       }
+
+       private boolean createHover() {
+               fHover= fHoverDescriptor.createTextHover();
+               if (fHover != null)
+                       fHover.setEditor(getEditor());
+               return isCreated();
+       }
+
+       /*
+        * @see org.eclipse.jface.text.ITextHoverExtension#getHoverControlCreator()
+        * @since 3.0
+        */
+       @Override
+       public IInformationControlCreator getHoverControlCreator() {
+               if (ensureHoverCreated() && (fHover instanceof ITextHoverExtension))
+                       return ((ITextHoverExtension)fHover).getHoverControlCreator();
+
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.information.IInformationProviderExtension2#getInformationPresenterControlCreator()
+        */
+       @Override
+       public IInformationControlCreator getInformationPresenterControlCreator() {
+               if (ensureHoverCreated()) {
+                       // this is wrong, but left here for backwards compatibility
+                       if (fHover instanceof IInformationProviderExtension2)
+                               return ((IInformationProviderExtension2) fHover).getInformationPresenterControlCreator();
+               }
+               return null;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CHoverMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CHoverMessages.java
new file mode 100644 (file)
index 0000000..9838be3
--- /dev/null
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.c.hover;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class CHoverMessages extends NLS {
+
+       public static String AbstractAnnotationHover_action_configureAnnotationPreferences;
+       public static String AbstractAnnotationHover_message_singleQuickFix;
+       public static String AbstractAnnotationHover_message_multipleQuickFix;
+
+       public static String CMacroExpansionControl_exploreMacroExpansion;
+       public static String CMacroExpansionControl_statusText;
+
+       public static String CMacroExpansionControl_title_expansion;
+       public static String CMacroExpansionControl_title_fullyExpanded;
+       public static String CMacroExpansionControl_title_macroExpansion;
+       public static String CMacroExpansionControl_title_macroExpansionExploration;
+       public static String CMacroExpansionControl_title_original;
+       
+       public static String CMacroExpansionInput_jobTitle;
+
+       public static String CSourceHover_jobTitle;
+
+       static {
+               NLS.initializeMessages(CHoverMessages.class.getName(), CHoverMessages.class);
+       }
+
+       // Do not instantiate
+       private CHoverMessages() {
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CHoverMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CHoverMessages.properties
new file mode 100644 (file)
index 0000000..cb14e7a
--- /dev/null
@@ -0,0 +1,28 @@
+###############################################################################
+#  Copyright (c) 2000, 2009 IBM Corporation and others.
+#  All rights reserved. This program and the accompanying materials
+#  are made available under the terms of the Eclipse Public License v1.0
+#  which accompanies this distribution, and is available at
+#  http://www.eclipse.org/legal/epl-v10.html
+# 
+#  Contributors:
+#     IBM Corporation - initial API and implementation
+#     Anton Leherbauer (Wind River Systems)
+#     Sergey Prigogin (Google)
+###############################################################################
+
+AbstractAnnotationHover_action_configureAnnotationPreferences= Configure Annotation Preferences
+AbstractAnnotationHover_message_singleQuickFix= 1 quick fix available:
+AbstractAnnotationHover_message_multipleQuickFix= {0} quick fixes available:
+
+CMacroExpansionControl_exploreMacroExpansion=Press "{0}" for macro expansion steps
+CMacroExpansionControl_statusText=Press {0} or {1} to step through macro expansion
+CMacroExpansionControl_title_expansion=Expansion \#{0} of {1}
+CMacroExpansionControl_title_fullyExpanded=Fully Expanded
+CMacroExpansionControl_title_macroExpansion=Macro Expansion
+CMacroExpansionControl_title_macroExpansionExploration=Explore Macro Expansion - {0} step(s)
+CMacroExpansionControl_title_original=Original
+
+CMacroExpansionInput_jobTitle= Computing Macro Expansion
+
+CSourceHover_jobTitle= Computing Source
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CInformationProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CInformationProvider.java
new file mode 100644 (file)
index 0000000..710767d
--- /dev/null
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.c.hover;
+
+import org.eclipse.jface.text.AbstractReusableInformationControlCreator;
+import org.eclipse.jface.text.DefaultInformationControl;
+import org.eclipse.jface.text.IInformationControl;
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.information.IInformationProvider;
+import org.eclipse.jface.text.information.IInformationProviderExtension;
+import org.eclipse.jface.text.information.IInformationProviderExtension2;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IPartListener;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+
+/**
+ * Provides information for the current word under the cursor based on the documentation hover
+ * and spelling correction hover.
+ * 
+ * @see CTypeHover
+ * @since 5.0
+ */
+public class CInformationProvider implements IInformationProvider, IInformationProviderExtension, IInformationProviderExtension2 {
+
+       /**
+        * Default control creator.
+        */
+       private static final class ControlCreator extends AbstractReusableInformationControlCreator {
+               @Override
+               public IInformationControl doCreateInformationControl(Shell parent) {
+                       return new DefaultInformationControl(parent);
+               }
+       }
+       
+
+       /**
+        * Part listener handling editor close.
+        */
+       class EditorWatcher implements IPartListener {
+               public void partOpened(IWorkbenchPart part) {
+               }
+               public void partDeactivated(IWorkbenchPart part) {
+               }
+               public void partClosed(IWorkbenchPart part) {
+                       if (part == fEditor) {
+                               fEditor.getSite().getWorkbenchWindow().getPartService().removePartListener(fPartListener);
+                               fPartListener= null;
+                       }
+               }
+               public void partActivated(IWorkbenchPart part) {
+               }
+               public void partBroughtToTop(IWorkbenchPart part) {
+               }
+       }
+
+       protected IEditorPart fEditor;
+       protected IPartListener fPartListener;
+
+       protected CTypeHover fImplementation;
+
+       /**
+        * The default presentation control creator.
+        */
+       private IInformationControlCreator fPresenterControlCreator;
+       
+       public CInformationProvider(IEditorPart editor) {
+               fEditor= editor;
+
+               if (fEditor != null) {
+                       fPartListener= new EditorWatcher();
+                       IWorkbenchWindow window= fEditor.getSite().getWorkbenchWindow();
+                       window.getPartService().addPartListener(fPartListener);
+                       fImplementation= new CTypeHover();
+                       fImplementation.setEditor(fEditor);
+               }
+       }
+
+       /*
+        * @see IInformationProvider#getSubject(ITextViewer, int)
+        */
+       public IRegion getSubject(ITextViewer textViewer, int offset) {
+               if (textViewer != null && fImplementation != null) {
+                       return fImplementation.getHoverRegion(textViewer, offset);
+               }
+               return null;
+       }
+
+       /*
+        * @see IInformationProvider#getInformation(ITextViewer, IRegion)
+        */
+       public String getInformation(ITextViewer textViewer, IRegion subject) {
+               if (fImplementation != null) {
+                       String s= fImplementation.getHoverInfo(textViewer, subject);
+                       if (s != null && s.trim().length() > 0) {
+                               return s;
+                       }
+               }
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.information.IInformationProviderExtension#getInformation2(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
+        */
+       public Object getInformation2(ITextViewer textViewer, IRegion subject) {
+               if (fImplementation == null)
+                       return null;
+               return fImplementation.getHoverInfo2(textViewer, subject);
+       }
+
+       /*
+        * @see IInformationProviderExtension2#getInformationPresenterControlCreator()
+        */
+       public IInformationControlCreator getInformationPresenterControlCreator() {
+               if (fImplementation != null) {
+                       return ((IInformationProviderExtension2) fImplementation).getInformationPresenterControlCreator();
+               }
+               if (fPresenterControlCreator == null)
+                       fPresenterControlCreator= new ControlCreator();
+               return fPresenterControlCreator;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroCompareViewer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroCompareViewer.java
new file mode 100644 (file)
index 0000000..60b3878
--- /dev/null
@@ -0,0 +1,231 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.c.hover;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.contentmergeviewer.ITokenComparator;
+import org.eclipse.compare.rangedifferencer.IRangeComparator;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.ITextPresentationListener;
+import org.eclipse.jface.text.TextPresentation;
+import org.eclipse.jface.text.TextViewer;
+import org.eclipse.swt.custom.StyleRange;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.text.edits.ReplaceEdit;
+
+import org.eclipse.cdt.core.dom.rewrite.MacroExpansionExplorer.IMacroExpansionStep;
+
+import org.eclipse.cdt.internal.ui.compare.CMergeViewer;
+
+/**
+ * A viewer for comparison of macro expansions.
+ *
+ * @since 5.0
+ */
+class CMacroCompareViewer extends CMergeViewer {
+
+       private static final RGB CHANGE_COLOR= new RGB(212,212,212);
+
+       private class ReplaceEditsHighlighter implements ITextPresentationListener {
+               private boolean fBefore;
+               private int[] fStarts;
+               private int[] fLengths;
+               private Color fBackground;
+
+               public ReplaceEditsHighlighter(Color background, boolean before) {
+                       fBackground= background;
+                       fBefore= before;
+               }
+
+               public void setReplaceEdits(int prefixLength, ReplaceEdit[] edits) {
+                       fStarts= new int[edits.length];
+                       fLengths= new int[edits.length];
+                       int delta= 0;
+                       for (int i= 0; i < edits.length; i++) {
+                               ReplaceEdit edit= edits[i];
+                               fStarts[i]= prefixLength + edit.getOffset() + delta;
+                               fLengths[i]= fBefore ? edit.getLength() : edit.getText().length();
+                               if (!fBefore) {
+                                       delta += edit.getText().length() - edit.getLength();
+                               }
+                       }
+               }
+               
+               /*
+                * @see org.eclipse.jface.text.ITextPresentationListener#applyTextPresentation(org.eclipse.jface.text.TextPresentation)
+                */
+               public void applyTextPresentation(TextPresentation textPresentation) {
+                       for (int i = 0; i < fStarts.length; i++) {
+                               textPresentation.mergeStyleRange(new StyleRange(fStarts[i], fLengths[i], null, fBackground));
+                       }
+               }
+
+       }
+
+       /**
+        * A dummy {@link ITokenComparator}.
+        */
+       private static class NullTokenComparator implements ITokenComparator {
+               public int getTokenLength(int index) {
+                       return 0;
+               }
+               public int getTokenStart(int index) {
+                       return 0;
+               }
+               public int getRangeCount() {
+                       return 0;
+               }
+               public boolean rangesEqual(int thisIndex, IRangeComparator other, int otherIndex) {
+                       return true;
+               }
+               public boolean skipRangeComparison(int length, int maxLength, IRangeComparator other) {
+                       return true;
+               }
+       }
+
+       private final ReplaceEditsHighlighter fLeftHighlighter;
+       private final ReplaceEditsHighlighter fRightHighlighter;
+       private Color fChangeBackground;
+
+       private TextViewer fLeftViewer;
+       private TextViewer fRightViewer;
+       private TextViewer fTopViewer;
+       
+       private int fViewerIndex;
+
+       private CMacroExpansionInput fInput;
+       private int fStepIndex;
+       private int fPrefixLength;
+       
+       public CMacroCompareViewer(Composite parent, int styles, CompareConfiguration mp) {
+               super(parent, styles, mp);
+               fChangeBackground= new Color(parent.getDisplay(), CHANGE_COLOR);
+               fLeftHighlighter= new ReplaceEditsHighlighter(fChangeBackground, true);
+               fRightHighlighter= new ReplaceEditsHighlighter(fChangeBackground, false);
+               fViewerIndex= 0;
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.compare.AbstractMergeViewer#handleDispose(org.eclipse.swt.events.DisposeEvent)
+        */
+       @Override
+       protected void handleDispose(DisposeEvent event) {
+               if (fLeftViewer != null) {
+                       fLeftViewer.removeTextPresentationListener(fLeftHighlighter);
+               }
+               if (fRightViewer != null) {
+                       fRightViewer.removeTextPresentationListener(fRightHighlighter);
+               }
+               fChangeBackground.dispose();
+               super.handleDispose(event);
+       }
+       
+       @Override
+       protected IToolBarManager getToolBarManager(Composite parent) {
+               // no toolbar
+               return null;
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.compare.AbstractMergeViewer#configureTextViewer(org.eclipse.jface.text.TextViewer)
+        */
+       @Override
+       protected void configureTextViewer(TextViewer textViewer) {
+               super.configureTextViewer(textViewer);
+               
+               // hack: gain access to text viewers
+               switch (fViewerIndex++) {
+               case 0:
+                       fTopViewer= textViewer;
+                       fTopViewer.getTextWidget().setFont(JFaceResources.getFont(CMergeViewer.class.getName()));
+                       break;
+               case 1:
+                       fLeftViewer= textViewer;
+                       fLeftViewer.getTextWidget().setFont(JFaceResources.getFont(CMergeViewer.class.getName()));
+                       fLeftViewer.addTextPresentationListener(fLeftHighlighter);
+                       break;
+               case 2:
+                       fRightViewer= textViewer;
+                       fRightViewer.getTextWidget().setFont(JFaceResources.getFont(CMergeViewer.class.getName()));
+                       fRightViewer.addTextPresentationListener(fRightHighlighter);
+               }
+       }
+       
+       /*
+        * @see org.eclipse.compare.contentmergeviewer.TextMergeViewer#createTokenComparator(java.lang.String)
+        */
+       @Override
+       protected ITokenComparator createTokenComparator(String line) {
+               return new NullTokenComparator();
+       }
+
+       /**
+        * Set the macro expansion input.
+        * 
+        * @param input
+        */
+       public void setMacroExpansionInput(CMacroExpansionInput input) {
+               fInput= input;
+               fPrefixLength= 0;
+       }
+
+       /*
+        * @see org.eclipse.jface.viewers.ContentViewer#setInput(java.lang.Object)
+        */
+       @Override
+       public void setInput(Object input) {
+               boolean redraw= true;
+               if (fLeftViewer != null && fRightViewer != null) {
+                       redraw= false;
+                       fLeftViewer.setRedraw(false);
+                       fRightViewer.setRedraw(false);
+               }
+               final ReplaceEdit[] edits;
+               
+               try {
+                       final IMacroExpansionStep step;
+                       if (fStepIndex < fInput.fExplorer.getExpansionStepCount()) {
+                               step= fInput.fExplorer.getExpansionStep(fStepIndex);
+                       } else {
+                               step= fInput.fExplorer.getFullExpansion();
+                       }
+                       edits= step.getReplacements();
+
+                       fLeftHighlighter.setReplaceEdits(fPrefixLength, edits);
+                       fRightHighlighter.setReplaceEdits(fPrefixLength, edits);
+       
+                       super.setInput(input);
+                       
+               } finally {
+                       if (!redraw && fLeftViewer != null && fRightViewer != null) {
+                               fLeftViewer.setRedraw(true);
+                               fRightViewer.setRedraw(true);
+                       }
+               }
+               if (edits.length > 0) {
+                       if (fLeftViewer != null && fRightViewer != null) {
+                               final int firstDiffOffset= fPrefixLength + edits[0].getOffset();
+                               fLeftViewer.revealRange(firstDiffOffset, edits[0].getLength());
+                               fRightViewer.revealRange(firstDiffOffset, edits[0].getText().length());
+                       }
+               }
+       }
+
+       public void setMacroExpansionStep(int index) {
+               fStepIndex= index;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionControl.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionControl.java
new file mode 100644 (file)
index 0000000..1509ae0
--- /dev/null
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.c.hover;
+
+import org.eclipse.jface.text.IInformationControl;
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.keys.IBindingService;
+import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
+
+import org.eclipse.cdt.internal.ui.text.AbstractSourceViewerInformationControl;
+
+/**
+ * Information control for macro expansion.
+ *
+ * @since 5.0
+ */
+public class CMacroExpansionControl extends AbstractSourceViewerInformationControl {
+
+       private CMacroExpansionInput fInput;
+
+       /**
+        * Creates a new control for use as a hover which does not take the focus.
+        * 
+        * @param parent  parent shell
+        * @param statusFieldText  text to be displayed in the status field, may be <code>null</code>
+        */
+       public CMacroExpansionControl(Shell parent, String statusFieldText) {
+               super(parent, statusFieldText);
+               setTitleText(CHoverMessages.CMacroExpansionControl_title_macroExpansion);
+       }
+
+       /**
+        * Creates a new control for use as a hover which optionally takes the focus.
+        * 
+        * @param parent  parent shell
+        * @param isResizable  whether this control should be resizable
+        */
+       public CMacroExpansionControl(Shell parent, boolean isResizable) {
+               super(parent, isResizable);
+               setTitleText(CHoverMessages.CMacroExpansionControl_title_macroExpansion);
+       }
+
+       @Override
+       protected boolean hasHeader() {
+               return true;
+       }
+
+       @Override
+       public void setInput(Object input) {
+               if (input instanceof CMacroExpansionInput) {
+                       CMacroExpansionInput macroExpansionInput= (CMacroExpansionInput) input;
+                       setInformation(macroExpansionInput.fExplorer.getFullExpansion().getCodeAfterStep());
+                       fInput= macroExpansionInput;
+                       updateStatusText();
+               } else {
+                       super.setInput(input);
+               }
+       }
+
+       private void updateStatusText() {
+               if (fInput == null) {
+                       return;
+               }
+               if (fInput.fExplorer.getExpansionStepCount() > 1) {
+                       IBindingService bindingService= (IBindingService)PlatformUI.getWorkbench().getAdapter(IBindingService.class);
+                       if (bindingService != null) {
+                               String keySequence= bindingService.getBestActiveBindingFormattedFor(ITextEditorActionDefinitionIds.SHOW_INFORMATION);
+                               if (keySequence != null) {
+                                       setStatusText(NLS.bind(CHoverMessages.CMacroExpansionControl_exploreMacroExpansion, keySequence));
+                               }
+                       }
+               }
+       }
+
+       @Override
+       public IInformationControlCreator getInformationPresenterControlCreator() {
+               return new IInformationControlCreator() {
+                       public IInformationControl createInformationControl(Shell parent) {
+                               if (fInput != null && fInput.fExplorer.getExpansionStepCount() > 1) {
+                                       return new CMacroExpansionExplorationControl(parent, true);
+                               } else {
+                                       return new CMacroExpansionControl(parent, true);
+                               }
+                       }
+               };
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionExplorationControl.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionExplorationControl.java
new file mode 100644 (file)
index 0000000..608cd2e
--- /dev/null
@@ -0,0 +1,603 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *     IBM Corporation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.c.hover;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.compare.Splitter;
+import org.eclipse.compare.structuremergeviewer.Differencer;
+import org.eclipse.compare.structuremergeviewer.DocumentRangeNode;
+import org.eclipse.compare.structuremergeviewer.ICompareInput;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.action.ToolBarManager;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.AbstractInformationControlManager;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.text.edits.ReplaceEdit;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.contexts.IContextActivation;
+import org.eclipse.ui.contexts.IContextService;
+import org.eclipse.ui.handlers.IHandlerActivation;
+import org.eclipse.ui.handlers.IHandlerService;
+import org.eclipse.ui.keys.IBindingService;
+import org.eclipse.ui.menus.CommandContributionItem;
+import org.eclipse.ui.menus.CommandContributionItemParameter;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IMacroBinding;
+import org.eclipse.cdt.core.dom.rewrite.MacroExpansionExplorer.IMacroExpansionStep;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.editor.CSourceViewer;
+import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
+import org.eclipse.cdt.internal.ui.text.AbstractCompareViewerInformationControl;
+import org.eclipse.cdt.internal.ui.text.CTextTools;
+import org.eclipse.cdt.internal.ui.text.SimpleCSourceViewerConfiguration;
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+
+/**
+ * Information control for macro expansion exploration.
+ *
+ * @since 5.0
+ */
+public class CMacroExpansionExplorationControl extends AbstractCompareViewerInformationControl {
+
+       private static final String COMMAND_ID_EXPANSION_BACK= "org.eclipse.cdt.ui.hover.backwardMacroExpansion"; //$NON-NLS-1$
+       private static final String COMMAND_ID_EXPANSION_FORWARD= "org.eclipse.cdt.ui.hover.forwardMacroExpansion"; //$NON-NLS-1$
+       private static final String CONTEXT_ID_MACRO_EXPANSION_HOVER= "org.eclipse.cdt.ui.macroExpansionHoverScope"; //$NON-NLS-1$
+
+       /** Dialog settings key to persist control bounds. */
+       public static final String KEY_CONTROL_BOUNDS = "org.eclipse.cdt.ui.text.hover.CMacroExpansionExploration"; //$NON-NLS-1$
+
+       private static final String KEY_CONTROL_BOUNDS_INTERNAL = KEY_CONTROL_BOUNDS + ".internal"; //$NON-NLS-1$
+
+       private static final int MIN_WIDTH = 320;
+       private static final int MIN_HEIGHT = 180;
+
+       private static class CDiffNode extends DocumentRangeNode implements ITypedElement {
+               public CDiffNode(DocumentRangeNode parent, int type, String id, IDocument doc, int start, int length) {
+                       super(parent, type, id, doc, start, length);
+               }
+               public CDiffNode(int type, String id, IDocument doc, int start, int length) {
+                       super(type, id, doc, start, length);
+               }
+               public String getName() {
+                       return getId();
+               }
+               public String getType() {
+                       return "c2"; //$NON-NLS-1$
+               }
+               public Image getImage() {
+                       return null;
+               }
+       }
+
+       private IHandlerService fHandlerService;
+       private Collection<IHandlerActivation> fHandlerActivations;
+       private IContextService fContextService;
+       private IContextActivation fContextActivation;
+       private int fIndex;
+       private CMacroExpansionInput fInput;
+       private CMacroCompareViewer fMacroCompareViewer;
+       private ISourceViewer fMacroViewer;
+       private StyledText fMacroText;
+       private boolean fRestoreSize;
+       private Point fDefaultSize;
+       private ScrolledComposite fTextScroller;
+
+       /**
+        * Creates a new control for use as a "quick view" where the control immediately takes the focus.
+        * 
+        * @param parent  parent shell
+        * @param input  the input object, may be <code>null</code>
+        */
+       public CMacroExpansionExplorationControl(Shell parent, CMacroExpansionInput input) {
+               super(parent, new ToolBarManager(SWT.FLAT));
+               setMacroExpansionInput(input);
+               addFocusListener(new FocusListener() {
+                       public void focusGained(FocusEvent e) {
+                               registerCommandHandlers();
+                       }
+                       public void focusLost(FocusEvent e) {
+                               unregisterCommandHandlers();
+                       }
+               });
+               getShell().addListener(SWT.Close, new Listener() {
+                       public void handleEvent(Event event) {
+                               widgetClosed();
+                       }});
+               fillToolBar();
+               setDefaultSize(MIN_WIDTH, MIN_HEIGHT);
+       }
+
+       /**
+        * Creates a new control for use as a "quick view" where the control immediately takes the focus.
+        * 
+        * @param parent  parent shell
+        */
+       public CMacroExpansionExplorationControl(Shell parent) {
+               this(parent, null);
+       }
+
+       /**
+        * Creates a new control for use as a "quick view" where the control immediately takes the focus.
+        * 
+        * @param parent  parent shell
+        * @param restoreSize  whether control size should be restored
+        */
+       public CMacroExpansionExplorationControl(Shell parent, boolean restoreSize) {
+               this(parent, null);
+               fRestoreSize= restoreSize;
+               if (restoreSize) {
+                       restoreSize();
+               }
+       }
+
+       private void restoreSize() {
+               String sectionName= KEY_CONTROL_BOUNDS_INTERNAL;
+               IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings().getSection(sectionName);
+               if (settings == null) {
+                       return;
+               }
+               try {
+                       int width= settings.getInt(AbstractInformationControlManager.STORE_SIZE_WIDTH);
+                       int height= settings.getInt(AbstractInformationControlManager.STORE_SIZE_HEIGHT);
+                       setDefaultSize(width, height);
+               } catch (NumberFormatException exc) {
+                       // Ignore
+               }
+       }
+       
+       private void setDefaultSize(int width, int height) {
+               fDefaultSize= new Point(width, height);
+       }
+
+       private void storeSize() {
+               final Shell shell = getShell();
+               if (shell == null) {
+                       return;
+               }
+               String sectionName= KEY_CONTROL_BOUNDS_INTERNAL;
+               IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings().getSection(sectionName);
+               if (settings == null) {
+                       settings= CUIPlugin.getDefault().getDialogSettings().addNewSection(sectionName);
+               }
+               Point size= shell.getSize();
+               settings.put(AbstractInformationControlManager.STORE_SIZE_WIDTH, size.x);
+               settings.put(AbstractInformationControlManager.STORE_SIZE_HEIGHT, size.y);
+       }
+
+       @Override
+       protected boolean hasHeader() {
+               return true;
+       }
+
+       @Override
+       protected CompareViewerControl createCompareViewerControl(Composite parent, int style, CompareConfiguration compareConfig) {
+               Splitter splitter= new Splitter(parent, SWT.VERTICAL);
+               splitter.setLayoutData(new GridData(GridData.FILL_BOTH));
+               // text viewer to show the macro definition
+               fTextScroller= new ScrolledComposite(splitter, SWT.H_SCROLL | SWT.V_SCROLL);
+               fMacroViewer= createSourceViewer(fTextScroller, style);
+               final StyledText textWidget= fMacroViewer.getTextWidget();
+               fTextScroller.setBackground(textWidget.getBackground());
+               fTextScroller.setContent(textWidget);
+               final Point size= textWidget.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+               textWidget.setSize(size);
+               // compare viewer
+               CompareViewerControl control= super.createCompareViewerControl(splitter, style, compareConfig);
+               splitter.setWeights(new int[] { 20, 80 });
+               return control;
+       }
+
+       @Override
+       protected Viewer createContentViewer(Composite parent, ICompareInput input, CompareConfiguration cc) {
+               fMacroCompareViewer= new CMacroCompareViewer(parent, SWT.NULL, cc);
+               if (fInput != null) {
+                       fMacroCompareViewer.setMacroExpansionInput(fInput);
+                       fMacroCompareViewer.setMacroExpansionStep(fIndex);
+               }
+               return fMacroCompareViewer;
+       }
+
+       protected ISourceViewer createSourceViewer(Composite parent, int style) {
+               IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
+               SourceViewer sourceViewer= new CSourceViewer(parent, null, null, false, style, store);
+               CTextTools tools= CUIPlugin.getDefault().getTextTools();
+               sourceViewer.configure(new SimpleCSourceViewerConfiguration(tools.getColorManager(), store, null, ICPartitions.C_PARTITIONING, false));
+               sourceViewer.setEditable(false);
+
+               fMacroText= sourceViewer.getTextWidget();
+
+               Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
+               fMacroText.setFont(font);
+
+               GridData gd= new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
+               gd.heightHint= fMacroText.getLineHeight() * 2;
+               fMacroText.setLayoutData(gd);
+               fMacroText.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
+               
+               final Document doc= new Document();
+               CUIPlugin.getDefault().getTextTools().setupCDocument(doc);
+               sourceViewer.setDocument(doc);
+               return sourceViewer;
+       }
+
+       protected void unregisterCommandHandlers() {
+               if (fHandlerService != null) {
+                       fHandlerService.deactivateHandlers(fHandlerActivations);
+                       fHandlerActivations.clear();
+                       fHandlerService= null;
+               }
+               if (fContextActivation != null) {
+                       fContextService.deactivateContext(fContextActivation);
+                       fContextActivation= null;
+               }
+       }
+
+       protected void registerCommandHandlers() {
+               if (fContextActivation != null) {
+                       return;
+               }
+        IHandler backwardHandler= new AbstractHandler() {
+            public Object execute(ExecutionEvent event) throws ExecutionException {
+                backward();
+                return null;
+            }
+        };
+        IHandler forwardHandler= new AbstractHandler() {
+            public Object execute(ExecutionEvent event) throws ExecutionException {
+                forward();
+                return null;
+            }
+        };
+        IHandler gotoDefinitionHandler= new AbstractHandler() {
+            public Object execute(ExecutionEvent event) throws ExecutionException {
+                gotoMacroDefinition();
+                return null;
+            }
+        };
+
+        IWorkbench workbench= PlatformUI.getWorkbench();
+        fHandlerService= (IHandlerService) workbench.getService(IHandlerService.class);
+        fContextService= (IContextService) workbench.getService(IContextService.class);
+        fContextActivation= fContextService.activateContext(CONTEXT_ID_MACRO_EXPANSION_HOVER);
+        fHandlerActivations= new ArrayList<IHandlerActivation>();
+        fHandlerActivations.add(fHandlerService.activateHandler(COMMAND_ID_EXPANSION_BACK, backwardHandler));
+        fHandlerActivations.add(fHandlerService.activateHandler(COMMAND_ID_EXPANSION_FORWARD, forwardHandler));
+        fHandlerActivations.add(fHandlerService.activateHandler(ICEditorActionDefinitionIds.OPEN_DECL, gotoDefinitionHandler));
+
+        String infoText= getInfoText();
+        if (infoText != null) {
+            setStatusText(infoText);
+            //bug 234952 - truncation in the info label
+            PixelConverter converter = new PixelConverter(getShell());
+            Point pt = getShell().getSize();
+            int stringLengthInPixel = converter.convertWidthInCharsToPixels(infoText.length()+5);
+            if (pt.x < stringLengthInPixel) {
+               getShell().setSize(new Point(stringLengthInPixel, pt.y));
+            }
+        }
+       }
+
+       private void fillToolBar() {
+               ToolBarManager mgr = getToolBarManager();
+               if (mgr == null) {
+                       return;
+               }
+        IWorkbench workbench= PlatformUI.getWorkbench();
+        CommandContributionItemParameter param= new CommandContributionItemParameter(workbench, null, COMMAND_ID_EXPANSION_BACK, CommandContributionItem.STYLE_PUSH);
+        param.icon= CPluginImages.DESC_ELCL_NAVIGATE_BACKWARD;
+               mgr.add(new CommandContributionItem(param));
+               param = new CommandContributionItemParameter(workbench, null, COMMAND_ID_EXPANSION_FORWARD, CommandContributionItem.STYLE_PUSH);
+        param.icon= CPluginImages.DESC_ELCL_NAVIGATE_FORWARD;
+        mgr.add(new CommandContributionItem(param));
+        param = new CommandContributionItemParameter(workbench, null, ICEditorActionDefinitionIds.OPEN_DECL, CommandContributionItem.STYLE_PUSH);
+        param.icon = CPluginImages.DESC_ELCL_OPEN_DECLARATION;
+        mgr.add(new CommandContributionItem(param));
+        mgr.update(true);
+       }
+
+       protected final void gotoMacroDefinition() {
+               int index= fIndex < getStepCount() ? fIndex : 0;
+               final IMacroExpansionStep step= fInput.fExplorer.getExpansionStep(index);
+               IASTFileLocation fileLocation= step.getLocationOfExpandedMacroDefinition();
+               if (fileLocation != null) {
+                       final IPath path= new Path(fileLocation.getFileName());
+                       final int offset= fileLocation.getNodeOffset();
+                       final int length= fileLocation.getNodeLength();
+                       IEditorPart editor;
+                       try {
+                               editor = EditorUtility.openInEditor(path, null);
+                               if (editor instanceof ITextEditor) {
+                                       ITextEditor textEditor = (ITextEditor)editor;
+                                       textEditor.selectAndReveal(offset, length);
+                               }
+                               dispose();
+                       } catch (PartInitException exc) {
+                               CUIPlugin.log(exc);
+                       }
+               }
+       }
+
+       protected final void forward() {
+               fIndex= fixIndex(fIndex + 1);
+               if (fIndex > getStepCount()) {
+                       fIndex= 0;
+               }
+               showExpansion();
+       }
+
+       protected final void backward() {
+               --fIndex;
+               if (fIndex < 0) {
+                       fIndex= fixIndex(getStepCount());
+               }
+               showExpansion();
+       }
+
+       /**
+        * Returns the text to be shown in the popups's information area.
+        * May return <code>null</code>.
+        *
+        * @return The text to be shown in the popup's information area or <code>null</code>
+        */
+       private String getInfoText() {
+               IWorkbench workbench= PlatformUI.getWorkbench();
+               IBindingService bindingService= (IBindingService) workbench.getService(IBindingService.class);
+               String formattedBindingBack= bindingService.getBestActiveBindingFormattedFor(COMMAND_ID_EXPANSION_BACK);
+               String formattedBindingForward= bindingService.getBestActiveBindingFormattedFor(COMMAND_ID_EXPANSION_FORWARD);
+
+               String infoText= null;
+               if (formattedBindingBack != null && formattedBindingForward != null) {
+                       infoText= NLS.bind(CHoverMessages.CMacroExpansionControl_statusText, formattedBindingBack, formattedBindingForward);
+               }
+               return infoText;
+       }
+
+       @Override
+       public void dispose() {
+               unregisterCommandHandlers();
+               super.dispose();
+       }
+
+       @Override
+       public boolean restoresLocation() {
+               return true;
+       }
+
+       @Override
+       public boolean restoresSize() {
+               return true;
+       }
+
+       @Override
+       public void setSizeConstraints(int maxWidth, int maxHeight) {
+               Point constraints= getSizeConstraints();
+               if (constraints != null) {
+                       super.setSizeConstraints(Math.max(constraints.x, maxWidth), Math.max(constraints.y, maxHeight));
+               } else {
+                       super.setSizeConstraints(maxWidth, maxHeight);
+               }
+       }
+
+       @Override
+       public void setSize(int width, int height) {
+               if (fDefaultSize != null) {
+                       width= Math.max(fDefaultSize.x, width);
+                       height= Math.max(fDefaultSize.y, height);
+                       fDefaultSize= null;
+               }
+               super.setSize(width, height);
+       }
+
+       @Override
+       public void setInput(Object input) {
+               if (input instanceof CMacroExpansionInput) {
+                       setMacroExpansionInput((CMacroExpansionInput) input);
+               } else {
+                       if (fMacroCompareViewer != null) {
+                               fMacroCompareViewer.setMacroExpansionStep(fIndex);
+                       }
+                       super.setInput(input);
+               }
+       }
+
+       private void widgetClosed() {
+               if (fRestoreSize) {
+                       storeSize();
+                       fRestoreSize= false;
+               }
+               unregisterCommandHandlers();
+       }
+
+       @Override
+       public void setVisible(boolean visible) {
+               if (!visible) {
+                       if (fRestoreSize) {
+                               storeSize();
+                               fRestoreSize= false;
+                       }
+               }
+               super.setVisible(visible);
+               if (visible) {
+                       setFocus();
+               }
+       }
+
+       @Override
+       public Rectangle computeTrim() {
+               Rectangle trim= super.computeTrim();
+               addInternalTrim(trim);
+               return trim;
+       }
+
+       /**
+        * Adds the internal trimmings to the given trim of the shell.
+        * 
+        * @param trim the shell's trim, will be updated
+        * @since 5.0
+        */
+       private void addInternalTrim(Rectangle trim) {
+               Rectangle textTrim= fMacroText.computeTrim(0, 0, 0, 0);
+               trim.x+= textTrim.x;
+               trim.y+= textTrim.y;
+               trim.width+= textTrim.width;
+               trim.height+= textTrim.height;
+       }
+
+       /**
+        * Set the input for this information control.
+        * @param input
+        */
+       private void setMacroExpansionInput(CMacroExpansionInput input) {
+               fInput= input;
+               if (fInput != null) {
+                       fIndex= fixIndex(input.fStartWithFullExpansion ? getStepCount() : 0);
+                       showExpansion();
+               }
+       }
+
+       private int fixIndex(int index) {
+               if (getStepCount() == 1 && index == 1) {
+                       return 0;
+               }
+               return index;
+       }
+
+       private int getStepCount() {
+               return fInput.fExplorer.getExpansionStepCount();
+       }
+
+       private void showExpansion() {
+               final int idxLeft= fIndex == getStepCount() ? 0 : fIndex;
+               final int idxRight= fIndex + 1;
+
+               CompareConfiguration config= getCompareConfiguration();
+               config.setLeftLabel(getLabelForIndex(idxLeft));
+               config.setRightLabel(getLabelForIndex(idxRight));
+
+               final ITypedElement left= getContentForIndex(fIndex, true);
+               final ITypedElement right= getContentForIndex(fIndex, false);
+               
+               setTitleText(CHoverMessages.bind(CHoverMessages.CMacroExpansionControl_title_macroExpansionExploration, getStepCount()));
+               fMacroViewer.getDocument().set(getMacroText(fIndex));
+               final StyledText textWidget= fMacroViewer.getTextWidget();
+               final Point size= textWidget.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+               textWidget.setSize(size);
+               setInput(createCompareInput(null, left, right));
+       }
+
+       private String getLabelForIndex(int index) {
+               if (index == 0) {
+                       return CHoverMessages.CMacroExpansionControl_title_original;
+               } else if (index < getStepCount()) {
+                       return NLS.bind(CHoverMessages.CMacroExpansionControl_title_expansion,
+                                       String.valueOf(index), String.valueOf(getStepCount()));
+               } else {
+                       return CHoverMessages.CMacroExpansionControl_title_fullyExpanded;
+               }
+       }
+       private Object createCompareInput(ITypedElement original, ITypedElement left, ITypedElement right) {
+               Differencer d= new Differencer();
+               return d.findDifferences(false, new NullProgressMonitor(), null, original, left, right);
+       }
+
+       private ITypedElement getContentForIndex(int index, boolean before) {
+               final IMacroExpansionStep expansionStep;
+               if (index < getStepCount()) {
+                       expansionStep= fInput.fExplorer.getExpansionStep(index);
+               } else {
+                       expansionStep= fInput.fExplorer.getFullExpansion();
+               }
+               final String text;
+               if (before) {
+                       text= expansionStep.getCodeBeforeStep();
+               } else {
+                       text= expansionStep.getCodeAfterStep();
+               }
+               final Document doc= new Document(text);
+               CUIPlugin.getDefault().getTextTools().setupCDocument(doc);
+               return new CDiffNode(0, String.valueOf(index), doc, 0, text.length());
+       }
+
+       private String getMacroText(int index) {
+               index= index < getStepCount() ? index : 0;
+               final IMacroExpansionStep expansionStep= fInput.fExplorer.getExpansionStep(index);
+               IMacroBinding binding= expansionStep.getExpandedMacro();
+               StringBuffer buffer= new StringBuffer();
+               buffer.append("#define ").append(binding.getName()); //$NON-NLS-1$
+               char[][] params= binding.getParameterList();
+               if (params != null) {
+                       buffer.append('(');
+                       for (int i= 0; i < params.length; i++) {
+                               if (i > 0) {
+                                       buffer.append(',');
+                                       buffer.append(' ');
+                               }
+                               char[] param= params[i];
+                               buffer.append(new String(param));
+                       }
+                       buffer.append(')');
+               }
+               buffer.append(' ');
+               if (!binding.isDynamic()) {
+                       buffer.append(binding.getExpansionImage());
+               }
+               else {
+                       ReplaceEdit[] replacements= expansionStep.getReplacements();
+                       if (replacements.length == 1) {
+                               buffer.append(replacements[0].getText());
+                       }
+               }
+               return buffer.toString();
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionHover.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionHover.java
new file mode 100644 (file)
index 0000000..d51835d
--- /dev/null
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.c.hover;
+
+import org.eclipse.jface.text.IInformationControl;
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.part.IWorkbenchPartOrientation;
+
+/**
+ * A hover to explore macro expansion.
+ *
+ * @since 5.0
+ */
+public class CMacroExpansionHover extends AbstractCEditorTextHover {
+
+       @Override
+       public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
+               Object hoverInfo= getHoverInfo2(textViewer, hoverRegion);
+               return hoverInfo != null ? hoverInfo.toString() : null;
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.c.hover.AbstractCEditorTextHover#getHoverInfo2(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
+        */
+       @Override
+       public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
+               CMacroExpansionInput input= CMacroExpansionInput.create(getEditor(), hoverRegion, false);
+               return input;
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.ITextHoverExtension#getHoverControlCreator()
+        */
+       @Override
+       public IInformationControlCreator getHoverControlCreator() {
+               return new IInformationControlCreator() {
+                       public IInformationControl createInformationControl(Shell parent) {
+                               return new CMacroExpansionControl(parent, getTooltipAffordanceString());
+                       }
+               };
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.c.hover.AbstractCEditorTextHover#getInformationPresenterControlCreator()
+        */
+       @Override
+       public IInformationControlCreator getInformationPresenterControlCreator() {
+               return new IInformationControlCreator() {
+                       public IInformationControl createInformationControl(Shell parent) {
+                               IEditorPart editor= getEditor();
+                               int orientation= SWT.NONE;
+                               if (editor instanceof IWorkbenchPartOrientation)
+                                       orientation= ((IWorkbenchPartOrientation) editor).getOrientation();
+                               return new SourceViewerInformationControl(parent, true, orientation, null);
+                       }
+               };
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionInformationProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionInformationProvider.java
new file mode 100644 (file)
index 0000000..5cc4280
--- /dev/null
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.c.hover;
+
+import org.eclipse.jface.text.IInformationControl;
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.information.IInformationProvider;
+import org.eclipse.jface.text.information.IInformationProviderExtension;
+import org.eclipse.jface.text.information.IInformationProviderExtension2;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+
+/**
+ * Information provider for macro exploration.
+ *
+ * @since 5.0
+ */
+public class CMacroExpansionInformationProvider implements IInformationProvider, IInformationProviderExtension, IInformationProviderExtension2 {
+
+       private final ITextEditor fEditor;
+
+       public CMacroExpansionInformationProvider(ITextEditor editor) {
+               fEditor= editor;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.information.IInformationProvider#getInformation(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
+        */
+       public String getInformation(ITextViewer textViewer, IRegion subject) {
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.information.IInformationProvider#getSubject(org.eclipse.jface.text.ITextViewer, int)
+        */
+       public IRegion getSubject(ITextViewer textViewer, int offset) {
+               Point selection= textViewer.getSelectedRange();
+               return new Region(selection.x, selection.y);
+       }
+
+       /*
+        * @see org.eclipse.jface.text.information.IInformationProviderExtension#getInformation2(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
+        */
+       public Object getInformation2(ITextViewer textViewer, IRegion subject) {
+               return CMacroExpansionInput.create(fEditor, subject, true);
+       }
+
+       /*
+        * @see org.eclipse.jface.text.information.IInformationProviderExtension2#getInformationPresenterControlCreator()
+        */
+       public IInformationControlCreator getInformationPresenterControlCreator() {
+               return new IInformationControlCreator() {
+                       public IInformationControl createInformationControl(Shell parent) {
+                               return new CMacroExpansionExplorationControl(parent);
+                       }
+               };
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionInput.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionInput.java
new file mode 100644 (file)
index 0000000..d112238
--- /dev/null
@@ -0,0 +1,326 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.c.hover;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.Region;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTMacroExpansionLocation;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
+import org.eclipse.cdt.core.dom.ast.IASTNodeSelector;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroExpansion;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IMacroBinding;
+import org.eclipse.cdt.core.dom.rewrite.MacroExpansionExplorer;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.IWorkingCopyManager;
+
+import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
+
+import org.eclipse.cdt.internal.ui.editor.ASTProvider;
+import org.eclipse.cdt.internal.ui.text.CHeuristicScanner;
+
+/**
+ * An input object to the {@link CMacroExpansionExplorationControl}.
+ * 
+ * @since 5.0
+ */
+public class CMacroExpansionInput {
+
+       private static class SingletonRule implements ISchedulingRule {
+               public static final ISchedulingRule INSTANCE = new SingletonRule();
+               public boolean contains(ISchedulingRule rule) {
+                       return rule == this;
+               }
+               public boolean isConflicting(ISchedulingRule rule) {
+                       return rule == this;
+               }
+       }
+
+       /**
+        * Computes the expansion region for a selection.
+        */
+       private static class ExpansionRegionComputer implements ASTRunnable {
+               private final Position fTextRegion;
+               private final boolean fAllowSelection;
+               private IASTNode fEnclosingNode;
+               private List<IASTNode> fExpansionNodes= new ArrayList<IASTNode>();
+               private MacroExpansionExplorer fExplorer;
+               private IRegion fExpansionRegion;
+
+               private ExpansionRegionComputer(ITranslationUnit tUnit, IRegion textRegion, boolean allowSelection) {
+                       fTextRegion= new Position(textRegion.getOffset(), textRegion.getLength());
+                       fAllowSelection= allowSelection;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable#runOnAST(org.eclipse.cdt.core.dom.ast.IASTTranslationUnit)
+                */
+               public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
+                       if (ast != null) {
+                               final IASTNodeSelector nodeSelector = ast.getNodeSelector(ast.getFilePath());
+                               // try exact macro name match first
+                               IASTNode node= nodeSelector.findName(fTextRegion.getOffset(), fTextRegion.getLength());
+                               if (node instanceof IASTName) {
+                                       IASTName macroName= (IASTName) node;
+                                       IBinding binding= macroName.getBinding();
+                                       // skip macro references that belong to a macro definition or an undef directive
+                                       if (binding instanceof IMacroBinding && !macroName.isDefinition() &&
+                                                       macroName.getParent() instanceof IASTPreprocessorMacroExpansion) {
+                                               addExpansionNode(node);
+                                               createMacroExpansionExplorer(ast);
+                                               return Status.OK_STATUS;
+                                       }
+                               }
+                               if (fAllowSelection) {
+                                       // selection
+                                       boolean macroOccurrence= false;
+                                       fEnclosingNode= nodeSelector.findEnclosingNode(fTextRegion.getOffset(), fTextRegion.getLength());
+                                       if (fEnclosingNode == null) {
+                                               // selection beyond last declaration
+                                               fEnclosingNode= ast;
+                                       }
+                                       else if (fEnclosingNode.getParent() instanceof IASTPreprocessorMacroExpansion) {
+                                               // selection enclosed by the name of a macro expansion
+                                               fEnclosingNode= fEnclosingNode.getParent();
+                                       }
+                                       
+                                       if (fEnclosingNode instanceof IASTPreprocessorMacroExpansion) {
+                                               // selection enclosed by a macro expansion
+                                               addExpansionNode(fEnclosingNode);
+                                               macroOccurrence= true;
+                                       }
+                                       else {
+                                               IASTNodeLocation[] locations= fEnclosingNode.getNodeLocations();
+                                               for (int i = 0; i < locations.length; i++) {
+                                                       IASTNodeLocation location= locations[i];
+                                                       if (location instanceof IASTMacroExpansionLocation) {
+                                                               IASTFileLocation fileLocation= location.asFileLocation();
+                                                               if (fileLocation != null && ast.getFilePath().equals(fileLocation.getFileName())) {
+                                                                       if (fTextRegion.overlapsWith(fileLocation.getNodeOffset(), fileLocation.getNodeLength())) {
+                                                                               addExpansionNode(nodeSelector.findEnclosingNode(fileLocation.getNodeOffset(), fileLocation.getNodeLength()));
+                                                                               macroOccurrence= true;
+                                                                       }
+                                                               }
+                                                       }
+                                               }
+                                       }
+                                       if (macroOccurrence) {
+                                               createMacroExpansionExplorer(ast);
+                                               return Status.OK_STATUS;
+                                       }
+                               }
+                       }
+                       return Status.CANCEL_STATUS;
+               }
+
+               private void createMacroExpansionExplorer(IASTTranslationUnit ast) {
+                       IRegion region= getExpansionRegion();
+                       if (region != null) {
+                               fExplorer= MacroExpansionExplorer.create(ast, region);
+                               fExpansionRegion= region;
+                       }
+               }
+
+               private void addExpansionNode(IASTNode node) {
+                       if (node != null) {
+                               fEnclosingNode= computeCommonAncestor(node, fEnclosingNode);
+                               fExpansionNodes.add(node);
+                       }
+               }
+
+               private IASTNode computeCommonAncestor(IASTNode node, IASTNode other) {
+                       if (node == null) {
+                               return null;
+                       }
+                       if (other == null) {
+                               return node;
+                       }
+                       if (node == other) {
+                               return other;
+                       }
+                       List<IASTNode> ancestors= new ArrayList<IASTNode>();
+                       while (node != null) {
+                               node= node.getParent();
+                               ancestors.add(node);
+                       }
+                       while (other != null) {
+                               if (ancestors.contains(other)) {
+                                       return other;
+                               }
+                               other= other.getParent();
+                       }
+                       return null;
+               }
+
+               IRegion getExpansionRegion() {
+                       if (fExpansionRegion != null)
+                               return fExpansionRegion;
+                       if (fEnclosingNode != null) {
+                               int startOffset= Integer.MAX_VALUE;
+                               int endOffset= fTextRegion.getOffset() + fTextRegion.getLength();
+                               for (Iterator<IASTNode> it= fExpansionNodes.iterator(); it.hasNext(); ) {
+                                       IASTNode node= it.next();
+                                       if (node != fEnclosingNode) {
+                                               while (node != null && node.getParent() != fEnclosingNode) {
+                                                       node= node.getParent();
+                                               }
+                                       }
+                                       if (node != null) {
+                                               IASTFileLocation location= node.getFileLocation();
+                                               if (location != null) {
+                                                       startOffset= Math.min(startOffset, location.getNodeOffset());
+                                                       endOffset= Math.max(endOffset, location.getNodeOffset() + location.getNodeLength());
+                                               }
+                                       }
+                               }
+                               if (endOffset > startOffset) {
+                                       startOffset= Math.min(startOffset, fTextRegion.getOffset());
+                                       return new Region(startOffset, endOffset - startOffset);
+                               }
+                       }
+                       return null;
+               }
+               
+               MacroExpansionExplorer getMacroExpansionExplorer() {
+                       return fExplorer;
+               }
+       }
+
+       final MacroExpansionExplorer fExplorer;
+       boolean fStartWithFullExpansion= true;
+
+       private CMacroExpansionInput(MacroExpansionExplorer explorer) {
+               Assert.isNotNull(explorer);
+               fExplorer= explorer;
+       }
+
+       @Override
+       public String toString() {
+               return fExplorer.getFullExpansion().getCodeAfterStep();
+       }
+       
+       /**
+        * Creates an input object for the macro expansion exploration control {@link CMacroExpansionExplorationControl}.
+        * 
+        * @param editor  the active editor
+        * @param textRegion  the text region where to consider macro expansions
+        * @param force  force computation of the input, if <code>true</code> this may trigger a parse
+        * @return an instance of {@link CMacroExpansionInput} or <code>null</code> if no macro was found in the region
+        */
+       public static CMacroExpansionInput create(IEditorPart editor, IRegion textRegion, boolean force) {
+               if (editor == null || !(editor instanceof ITextEditor)) {
+                       return null;
+               }
+               IEditorInput editorInput= editor.getEditorInput();
+               IWorkingCopyManager manager= CUIPlugin.getDefault().getWorkingCopyManager();
+               IWorkingCopy tu = manager.getWorkingCopy(editorInput);
+               try {
+                       if (tu == null || !tu.isConsistent()) {
+                               return null;
+                       }
+               } catch (CModelException exc) {
+                       return null;
+               }
+               
+               ExpansionRegionComputer computer= new ExpansionRegionComputer(tu, textRegion, force);
+               doRunOnAST(computer, tu, force);
+
+               MacroExpansionExplorer explorer= computer.getMacroExpansionExplorer();
+               if (explorer == null) {
+                       return null;
+               }
+
+               CMacroExpansionInput input= new CMacroExpansionInput(explorer);
+
+               return input;
+       }
+
+       private static void doRunOnAST(final ASTRunnable runnable, final ITranslationUnit tu, boolean force) {
+               Job job= new Job(CHoverMessages.CMacroExpansionInput_jobTitle) {
+                       @Override
+                       protected IStatus run(IProgressMonitor monitor) {
+                               return ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_ACTIVE_ONLY, monitor, runnable);
+                       }};
+
+               // If the hover thread is interrupted this might have negative
+               // effects on the index - see http://bugs.eclipse.org/219834
+               // Therefore we schedule a job to decouple the parsing from this thread.
+               job.setPriority(force ? Job.INTERACTIVE : Job.DECORATE);
+               job.setSystem(true);
+               job.setRule(SingletonRule.INSTANCE);
+               job.schedule();
+               try {
+                       job.join();
+               } catch (InterruptedException exc) {
+                       job.cancel();
+               }
+       }
+
+       /**
+        * Expand the given text region to span complete lines of the document and
+        * add a number of lines before and after the region.
+        * 
+        * @param region  the text region
+        * @param document  the underlying text document
+        * @param contextLines  the number of lines to add
+        * @return an extended region
+        */
+       public static final IRegion expandRegion(IRegion region, IDocument document, int contextLines) {
+               try {
+                       int start= document.getLineOfOffset(region.getOffset());
+                       start= Math.max(start - contextLines, 0);
+                       int offset= document.getLineOffset(start);
+                       CHeuristicScanner scanner= new CHeuristicScanner(document);
+                       offset= scanner.findNonWhitespaceForward(offset, region.getOffset() + 1);
+                       
+                       int end= document.getLineOfOffset(region.getOffset() + region.getLength());
+                       end= Math.min(end + contextLines, document.getNumberOfLines() - 1);
+
+                       final int endOffset;
+                       if (document.getNumberOfLines() > end + 1) {
+                               endOffset= document.getLineOffset(end + 1);
+                       } else {
+                               endOffset= document.getLineOffset(end) + document.getLineLength(end);
+                       }
+                       return new Region(offset, endOffset - offset);
+                       
+               } catch (BadLocationException x) {
+                       return region;
+               }
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java
new file mode 100644 (file)
index 0000000..b5d4541
--- /dev/null
@@ -0,0 +1,818 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2011 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    QNX Software Systems - Initial API and implementation
+ *    Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.c.hover;
+
+import java.io.IOException;
+import java.util.Set;
+
+import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.core.filebuffers.ITextFileBuffer;
+import org.eclipse.core.filebuffers.ITextFileBufferManager;
+import org.eclipse.core.filebuffers.LocationKind;
+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.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IInformationControl;
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.part.IWorkbenchPartOrientation;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.IPositionConverter;
+import org.eclipse.cdt.core.dom.IName;
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.ICompositeType;
+import org.eclipse.cdt.core.dom.ast.IEnumeration;
+import org.eclipse.cdt.core.dom.ast.IEnumerator;
+import org.eclipse.cdt.core.dom.ast.IFunction;
+import org.eclipse.cdt.core.dom.ast.IMacroBinding;
+import org.eclipse.cdt.core.dom.ast.IParameter;
+import org.eclipse.cdt.core.dom.ast.IProblemBinding;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.ITypedef;
+import org.eclipse.cdt.core.dom.ast.IVariable;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
+import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.core.parser.KeywordSetKey;
+import org.eclipse.cdt.core.parser.ParserFactory;
+import org.eclipse.cdt.core.parser.ParserLanguage;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.IWorkingCopyManager;
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
+import org.eclipse.cdt.internal.corext.util.Strings;
+
+import org.eclipse.cdt.internal.ui.editor.ASTProvider;
+import org.eclipse.cdt.internal.ui.text.CCodeReader;
+import org.eclipse.cdt.internal.ui.text.CHeuristicScanner;
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+
+/**
+ * A text hover presenting the source of the element under the cursor.
+ */
+public class CSourceHover extends AbstractCEditorTextHover {
+
+       private static final boolean DEBUG = false;
+
+       protected static class SingletonRule implements ISchedulingRule {
+               public static final ISchedulingRule INSTANCE = new SingletonRule();
+               public boolean contains(ISchedulingRule rule) {
+                       return rule == this;
+               }
+               public boolean isConflicting(ISchedulingRule rule) {
+                       return rule == this;
+               }
+       }
+
+       /**
+        * Computes the source location for a given identifier.
+        */
+       protected static class ComputeSourceRunnable implements ASTRunnable {
+
+               private final ITranslationUnit fTU;
+               private final IRegion fTextRegion;
+               private final IProgressMonitor fMonitor;
+               private String fSource;
+
+               /**
+                * @param tUnit
+                * @param textRegion 
+                */
+               public ComputeSourceRunnable(ITranslationUnit tUnit, IRegion textRegion) {
+                       fTU= tUnit;
+                       fTextRegion= textRegion;
+                       fMonitor= new NullProgressMonitor();
+                       fSource= null;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable#runOnAST(org.eclipse.cdt.core.dom.ast.IASTTranslationUnit)
+                */
+               public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
+                       if (ast != null) {
+                               try {
+                                       IASTName name= ast.getNodeSelector(null).findEnclosingName(fTextRegion.getOffset(), fTextRegion.getLength());
+                                       if (name != null) {
+                                               IBinding binding= name.resolveBinding();
+                                               if (binding != null) {
+                                                       
+                                                       // Check for implicit names first, could be an implicit constructor call
+                                                       if(name.getParent() instanceof IASTImplicitNameOwner) {
+                                                               IASTImplicitNameOwner iastImplicitNameOwner = (IASTImplicitNameOwner) name.getParent();
+                                                               IASTName [] implicitNames = iastImplicitNameOwner.getImplicitNames();
+                                                               if(implicitNames.length == 1) {
+                                                                       IBinding implicitNameBinding = implicitNames[0].resolveBinding();
+                                                                       if(implicitNameBinding instanceof ICPPConstructor) {
+                                                                               binding = implicitNameBinding;
+                                                                       }
+                                                               }
+                                                       }
+                                                       
+                                                       if (binding instanceof IProblemBinding) {
+                                                               // report problem as source comment
+                                                               if (DEBUG) {
+                                                                       IProblemBinding problem= (IProblemBinding) binding;
+                                                                       fSource= "/* Indexer Problem!\n" + //$NON-NLS-1$
+                                                                                       " * " + problem.getMessage() +  //$NON-NLS-1$
+                                                                                       "\n */"; //$NON-NLS-1$
+                                                               }
+                                                       } else if (binding instanceof IMacroBinding) {
+                                                               fSource= computeSourceForMacro(ast, name, binding);
+                                                       } else {
+                                                               fSource= computeSourceForBinding(ast, binding);
+                                                       }
+                                                       if (fSource != null) {
+                                                               return Status.OK_STATUS;
+                                                       }
+                                               }
+                                       }
+                               } catch (CoreException exc) {
+                                       return exc.getStatus();
+                               } catch (DOMException exc) {
+                                       return new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, "Internal Error", exc); //$NON-NLS-1$
+                               }
+                       }
+                       return Status.CANCEL_STATUS;
+               }
+
+               /**
+                * Compute the source for a macro. If the source location of the macro definition can be determined,
+                * the source is taken from there, otherwise the source is constructed as a <code>#define</code> directive.
+                * 
+                * @param ast  the AST of the translation unit
+                * @param name  the macro occurrence in the AST
+                * @param binding   the binding of the macro name
+                * @return the source or <code>null</code>
+                * @throws CoreException 
+                */
+               private String computeSourceForMacro(IASTTranslationUnit ast, IASTName name, IBinding binding) throws CoreException {
+                       // Search for the macro definition
+                       IName[] defs = ast.getDefinitions(binding);
+                       for (IName def : defs) {
+                               String source= computeSourceForName(def, binding);
+                               if (source != null) {
+                                       return source;
+                               }
+                       }
+                       return null;
+               }
+
+               /**
+                * Find a definition or declaration for the given binding and returns the source for it.
+                * Definitions are preferred over declarations. In case of multiple definitions or declarations,
+                * and the first name which yields source is taken.
+                * 
+                * @param ast  the AST of the translation unit
+                * @param binding  the binding
+                * @return a source string or <code>null</code>, if no source could be computed
+                * @throws CoreException  if the source file could not be loaded or if there was a
+                *                        problem with the index
+                * @throws DOMException  if there was an internal problem with the DOM
+                */
+               private String computeSourceForBinding(IASTTranslationUnit ast, IBinding binding) throws CoreException, DOMException {
+                       IName[] names = findDefsOrDecls(ast, binding);
+                       
+                       // in case the binding is a non-explicit specialization we need
+                       // to consider the original binding (bug 281396)
+                       while (names.length == 0 && binding instanceof ICPPSpecialization) {
+                               IBinding specializedBinding = ((ICPPSpecialization) binding).getSpecializedBinding();
+                               if (specializedBinding == null || specializedBinding instanceof IProblemBinding) {
+                                       break;
+                               }
+                               
+                               names = findDefsOrDecls(ast, specializedBinding);
+                               binding = specializedBinding;
+                       }
+                       if (names.length > 0) {
+                               for (IName name : names) {
+                                       String source= computeSourceForName(name, binding);
+                                       if (source != null) {
+                                               return source;
+                                       }
+                               }
+                       }
+                       return null;
+               }
+
+               private IName[] findDefsOrDecls(IASTTranslationUnit ast, IBinding binding) throws CoreException {
+                       IName[] names= findDefinitions(ast, binding);
+                       if (names.length == 0) {
+                               names= findDeclarations(ast, binding);
+                       }
+                       return names;
+               }
+
+               /**
+                * Get the source for the given name from the underlying file.
+                * 
+                * @param name  the name to get the source for
+                * @param binding  the binding of the name
+                * @return the source string or <code>null</code>, if the source could not be computed
+                * @throws CoreException  if the file could not be loaded
+                */
+               private String computeSourceForName(IName name, IBinding binding) throws CoreException {
+                       IASTFileLocation fileLocation= name.getFileLocation();
+                       if (fileLocation == null) {
+                               return null;
+                       }
+                       int nodeOffset= fileLocation.getNodeOffset();
+                       int nodeLength= fileLocation.getNodeLength();
+                       
+                       String fileName= fileLocation.getFileName();
+                       if (DEBUG) System.out.println("[CSourceHover] Computing source for " + name + " in " + fileName);  //$NON-NLS-1$//$NON-NLS-2$
+                       IPath location= Path.fromOSString(fileName);
+                       LocationKind locationKind= LocationKind.LOCATION;
+                       if (name instanceof IASTName && !name.isReference()) {
+                               IASTName astName= (IASTName)name;
+                               if (astName.getTranslationUnit().getFilePath().equals(fileName) && fTU.getResource() != null) {
+                                       // reuse editor buffer for names local to the translation unit
+                                       location= fTU.getResource().getFullPath();
+                                       locationKind= LocationKind.IFILE;
+                               }
+                       } else {
+                               // try to resolve path to a resource for proper encoding (bug 221029)
+                               IFile file= EditorUtility.getWorkspaceFileAtLocation(location, fTU);
+                               if (file != null) {
+                                       location= file.getFullPath();
+                                       locationKind= LocationKind.IFILE;
+                                       if (name instanceof IIndexName) {
+                                               // need to adjust index offsets to current offsets
+                                               // in case file has been modified since last index time
+                                               IIndexName indexName= (IIndexName) name;
+                                               long timestamp= indexName.getFile().getTimestamp();
+                                               IPositionConverter converter= CCorePlugin.getPositionTrackerManager().findPositionConverter(file, timestamp);
+                                               if (converter != null) {
+                                                       IRegion currentLocation= converter.historicToActual(new Region(nodeOffset, nodeLength));
+                                                       nodeOffset= currentLocation.getOffset();
+                                                       nodeLength= currentLocation.getLength();
+                                               }
+                                       }
+                               }
+                       }
+                       ITextFileBufferManager mgr= FileBuffers.getTextFileBufferManager();
+                       mgr.connect(location, locationKind, fMonitor);
+                       ITextFileBuffer buffer= mgr.getTextFileBuffer(location, locationKind);
+                       try {
+                               IRegion nameRegion= new Region(nodeOffset, nodeLength);
+                               final int nameOffset= nameRegion.getOffset();
+                               final int sourceStart;
+                               final int sourceEnd;
+                               IDocument doc= buffer.getDocument();
+                               if (nameOffset >= doc.getLength() || nodeLength <= 0) {
+                                       return null;
+                               }
+                               if (binding instanceof IMacroBinding) {
+                                       ITypedRegion partition= TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, nameOffset, false);
+                                       if (ICPartitions.C_PREPROCESSOR.equals(partition.getType())) {
+                                               int directiveStart= partition.getOffset();
+                                               int commentStart= searchCommentBackward(doc, directiveStart, -1);
+                                               if (commentStart >= 0) {
+                                                       sourceStart= commentStart;
+                                               } else {
+                                                       sourceStart= directiveStart;
+                                               }
+                                               sourceEnd= directiveStart + partition.getLength();
+                                       } else {
+                                               return null;
+                                       }
+                               } else {
+                                       // expand source range to include preceding comment, if any
+                                       boolean isKnR= isKnRSource(name);
+                                       sourceStart= computeSourceStart(doc, nameOffset, binding, isKnR);
+                                       if (sourceStart == CHeuristicScanner.NOT_FOUND) {
+                                               return null;
+                                       }
+                                       sourceEnd= computeSourceEnd(doc, nameOffset + nameRegion.getLength(), binding, name.isDefinition(), isKnR);
+                               }
+                               String source= buffer.getDocument().get(sourceStart, sourceEnd - sourceStart);
+                               return source;
+
+                       } catch (BadLocationException exc) {
+                               // ignore - should not happen anyway
+                               if (DEBUG) exc.printStackTrace();
+                       } finally {
+                               mgr.disconnect(location, LocationKind.LOCATION, fMonitor);
+                       }
+                       return null;
+               }
+
+               /**
+                * Determine if the name is part of a KnR function definition.
+                * @param name
+                * @return <code>true</code> if the name is part of a KnR function
+                */
+               private boolean isKnRSource(IName name) {
+                       if (name instanceof IASTName) {
+                               IASTNode node= (IASTNode)name;
+                               while (node.getParent() != null) {
+                                       if (node instanceof ICASTKnRFunctionDeclarator) {
+                                               return node.getParent() instanceof IASTFunctionDefinition;
+                                       }
+                                       node= node.getParent();
+                               }
+                       }
+                       return false;
+               }
+
+               private int computeSourceStart(IDocument doc, int nameOffset, IBinding binding, boolean isKnR) throws BadLocationException {
+                       int sourceStart= nameOffset;
+                       CHeuristicScanner scanner= new CHeuristicScanner(doc);
+                       if (binding instanceof IParameter) {
+                               if (isKnR) {
+                                       sourceStart= scanner.scanBackward(nameOffset, CHeuristicScanner.UNBOUND, new char[] { ')', ';' });
+                               } else {
+                                       sourceStart= scanner.scanBackward(nameOffset, CHeuristicScanner.UNBOUND, new char[] { '>', '(', ',' });
+                                       if (sourceStart > 0 && doc.getChar(sourceStart) == '>') {
+                                               sourceStart= scanner.findOpeningPeer(sourceStart - 1, '<', '>');
+                                               if (sourceStart > 0) {
+                                                       sourceStart= scanner.scanBackward(sourceStart, CHeuristicScanner.UNBOUND, new char[] { '(', ',' });
+                                               }
+                                       }
+                               }
+                               if (sourceStart == CHeuristicScanner.NOT_FOUND) {
+                                       return sourceStart;
+                               }
+                               sourceStart= scanner.findNonWhitespaceForward(sourceStart + 1, nameOffset);
+                               if (sourceStart == CHeuristicScanner.NOT_FOUND) {
+                                       sourceStart = nameOffset;
+                               }
+                       } else if (binding instanceof ICPPTemplateParameter) {
+                               sourceStart= scanner.scanBackward(nameOffset, CHeuristicScanner.UNBOUND, new char[] { '>', '<', ',' });
+                               if (sourceStart > 0 && doc.getChar(sourceStart) == '>') {
+                                       sourceStart= scanner.findOpeningPeer(sourceStart - 1, '<', '>');
+                                       if (sourceStart > 0) {
+                                               sourceStart= scanner.scanBackward(sourceStart, CHeuristicScanner.UNBOUND, new char[] { '<', ',' });
+                                       }
+                               }
+                               if (sourceStart == CHeuristicScanner.NOT_FOUND) {
+                                       return sourceStart;
+                               }
+                               sourceStart= scanner.findNonWhitespaceForward(sourceStart + 1, nameOffset);
+                               if (sourceStart == CHeuristicScanner.NOT_FOUND) {
+                                       sourceStart = nameOffset;
+                               }
+                       } else if (binding instanceof IEnumerator) {
+                               sourceStart= scanner.scanBackward(nameOffset, CHeuristicScanner.UNBOUND, new char[] { '{', ',' });
+                               if (sourceStart == CHeuristicScanner.NOT_FOUND) {
+                                       return sourceStart;
+                               }
+                               sourceStart= scanner.findNonWhitespaceForward(sourceStart + 1, nameOffset);
+                               if (sourceStart == CHeuristicScanner.NOT_FOUND) {
+                                       sourceStart = nameOffset;
+                               }
+                       } else {
+                               final boolean expectClosingBrace;
+                               IType type= null;
+                               if (binding instanceof ITypedef) {
+                                       type= ((ITypedef)binding).getType();
+                               } else if (binding instanceof IVariable) {
+                                       type= ((IVariable)binding).getType();
+                               }
+                               expectClosingBrace= (type instanceof ICompositeType || type instanceof IEnumeration) && !(binding instanceof IVariable);
+                               final int nameLine= doc.getLineOfOffset(nameOffset);
+                               sourceStart= nameOffset;
+                               int commentBound;
+                               if (isKnR) {
+                                       commentBound= scanner.scanBackward(sourceStart, CHeuristicScanner.UNBOUND, new char[] { ')', ';' });
+                               } else {
+                                       commentBound= scanner.scanBackward(sourceStart, CHeuristicScanner.UNBOUND, new char[] { '{', '}', ';' });
+                               }
+                               while (expectClosingBrace && commentBound > 0 && doc.getChar(commentBound) == '}') {
+                                       int openingBrace= scanner.findOpeningPeer(commentBound - 1, '{', '}');
+                                       if (openingBrace != CHeuristicScanner.NOT_FOUND) {
+                                               sourceStart= openingBrace - 1;
+                                       }
+                                       if (isKnR) {
+                                               commentBound= scanner.scanBackward(sourceStart, CHeuristicScanner.UNBOUND, new char[] { ')', ';' });
+                                       } else {
+                                               commentBound= scanner.scanBackward(sourceStart, CHeuristicScanner.UNBOUND, new char[] { '{', '}', ';' });
+                                       }
+                               }
+                               if (commentBound == CHeuristicScanner.NOT_FOUND) {
+                                       commentBound= -1; // unbound
+                               }
+                               sourceStart= Math.min(sourceStart, doc.getLineOffset(nameLine));
+                               int commentStart= searchCommentBackward(doc, sourceStart, commentBound);
+                               if (commentStart >= 0) {
+                                       sourceStart= commentStart;
+                               } else {
+                                       int nextNonWS= scanner.findNonWhitespaceForward(commentBound+1, sourceStart);
+                                       if (nextNonWS != CHeuristicScanner.NOT_FOUND) {
+                                               int nextNonWSLine= doc.getLineOfOffset(nextNonWS);
+                                               int lineOffset= doc.getLineOffset(nextNonWSLine);
+                                               if (doc.get(lineOffset, nextNonWS - lineOffset).trim().length() == 0) {
+                                                       sourceStart= doc.getLineOffset(nextNonWSLine);
+                                               }
+                                       }
+                               }
+                       }
+                       return sourceStart;
+               }
+
+               private int computeSourceEnd(IDocument doc, int start, IBinding binding, boolean isDefinition, boolean isKnR) throws BadLocationException {
+                       int sourceEnd= start;
+                       CHeuristicScanner scanner= new CHeuristicScanner(doc);
+                       // expand forward to the end of the definition/declaration
+                       boolean searchBrace= false;
+                       boolean searchSemi= false;
+                       boolean searchComma= false;
+                       if (binding instanceof ICompositeType && isDefinition || binding instanceof IEnumeration) {
+                               searchBrace= true;
+                       } else if (binding instanceof ICPPTemplateDefinition) {
+                               searchBrace= true;
+                       } else if (binding instanceof IFunction && isDefinition) {
+                               searchBrace= true;
+                       } else if (binding instanceof IParameter) {
+                               if (isKnR) {
+                                       searchSemi= true;
+                               } else {
+                                       searchComma= true;
+                               }
+                       } else if (binding instanceof IEnumerator || binding instanceof ICPPTemplateParameter) {
+                               searchComma= true;
+                       } else if (binding instanceof IVariable || binding instanceof ITypedef) {
+                               searchSemi= true;
+                       } else if (!isDefinition) {
+                               searchSemi= true;
+                       }
+                       if (searchBrace) {
+                               int brace= scanner.scanForward(start, CHeuristicScanner.UNBOUND, '{');
+                               if (brace != CHeuristicScanner.NOT_FOUND) {
+                                       sourceEnd= scanner.findClosingPeer(brace + 1, '{', '}');
+                                       if (sourceEnd == CHeuristicScanner.NOT_FOUND) {
+                                               sourceEnd= doc.getLength();
+                                       }
+                               }
+                               // expand region to include whole line
+                               IRegion lineRegion= doc.getLineInformationOfOffset(sourceEnd);
+                               sourceEnd= lineRegion.getOffset() + lineRegion.getLength();
+                       } else if (searchSemi) {
+                               int semi= scanner.scanForward(start, CHeuristicScanner.UNBOUND, ';');
+                               if (semi != CHeuristicScanner.NOT_FOUND) {
+                                       sourceEnd= semi+1;
+                               }
+                               // expand region to include whole line
+                               IRegion lineRegion= doc.getLineInformationOfOffset(sourceEnd);
+                               sourceEnd= lineRegion.getOffset() + lineRegion.getLength();
+                       } else if (searchComma) {
+                               int bound;
+                               if (binding instanceof IParameter) {
+                                       bound= scanner.findClosingPeer(start, '(', ')');
+                               } else if (binding instanceof ICPPTemplateParameter) {
+                                       bound= scanner.findClosingPeer(start, '<', '>');
+                               } else if (binding instanceof IEnumerator) {
+                                       bound= scanner.findClosingPeer(start, '{', '}');
+                               } else {
+                                       bound = CHeuristicScanner.NOT_FOUND;
+                               }
+                               if (bound == CHeuristicScanner.NOT_FOUND) {
+                                       bound= Math.min(doc.getLength(), start + 100);
+                               }
+                               int comma= scanner.scanForward(start, bound, ',');
+                               if (comma == CHeuristicScanner.NOT_FOUND) {
+                                       // last argument
+                                       sourceEnd= bound;
+                               } else {
+                                       sourceEnd= comma;
+                                       // expand region to include whole line if rest is comment
+                                       IRegion lineRegion= doc.getLineInformationOfOffset(sourceEnd);
+                                       int lineEnd= lineRegion.getOffset() + lineRegion.getLength();
+                                       int nextNonWS= scanner.findNonWhitespaceForwardInAnyPartition(sourceEnd + 1, lineEnd);
+                                       if (nextNonWS != CHeuristicScanner.NOT_FOUND) {
+                                               String contentType= TextUtilities.getContentType(doc, ICPartitions.C_PARTITIONING, nextNonWS, false);
+                                               if (ICPartitions.C_MULTI_LINE_COMMENT.equals(contentType) || ICPartitions.C_SINGLE_LINE_COMMENT.equals(contentType)) {
+                                                       sourceEnd= lineEnd;
+                                               }
+                                       }
+                               }
+                       }
+                       return sourceEnd;
+               }
+
+               /**
+                * Search for definitions for the given binding.
+                * 
+                * @param ast  the AST of the translation unit
+                * @param binding  the binding
+                * @return an array of definitions, never <code>null</code>
+                * @throws CoreException
+                */
+               private IName[] findDefinitions(IASTTranslationUnit ast,
+                               IBinding binding) throws CoreException {
+                       IName[] declNames= ast.getDefinitionsInAST(binding);
+                       if (declNames.length == 0 && ast.getIndex() != null) {
+                               // search definitions in index
+                               declNames = ast.getIndex().findNames(binding, IIndex.FIND_DEFINITIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
+                       }
+                       return declNames;
+               }
+
+               /**
+                * Search for declarations for the given binding.
+                * 
+                * @param ast  the AST of the translation unit
+                * @param binding  the binding
+                * @return an array of declarations, never <code>null</code>
+                * @throws CoreException
+                */
+               private IName[] findDeclarations(IASTTranslationUnit ast,
+                               IBinding binding) throws CoreException {
+                       IName[] declNames= ast.getDeclarationsInAST(binding);
+                       if (declNames.length == 0 && ast.getIndex() != null) {
+                               // search declarations in index
+                               declNames= ast.getIndex().findNames(binding, IIndex.FIND_DECLARATIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
+                       }
+                       return declNames;
+               }
+
+               /**
+                * @return the computed source or <code>null</code>, if no source could be computed
+                */
+               public String getSource() {
+                       return fSource;
+               }
+
+       }
+
+       /**
+        * 
+        */
+       public CSourceHover() {
+               super();
+       }
+
+       /*
+        * @see ITextHover#getHoverInfo(ITextViewer, IRegion)
+        */
+       @Override
+       public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
+               IEditorPart editor = getEditor();
+               if (editor != null) {
+                       IEditorInput input= editor.getEditorInput();
+                       IWorkingCopyManager manager= CUIPlugin.getDefault().getWorkingCopyManager();                            
+                       IWorkingCopy copy = manager.getWorkingCopy(input);
+                       try {
+                               if (copy == null || !copy.isConsistent()) {
+                                       return null;
+                               }
+                       } catch (CModelException exc) {
+                               return null;
+                       }
+                       
+                       String expression;
+                       try {
+                               expression = textViewer.getDocument().get(hoverRegion.getOffset(), hoverRegion.getLength());
+                               expression = expression.trim();
+                               if (expression.length() == 0)
+                                       return null;
+
+                               //Before trying a search lets make sure that the user is not hovering over a keyword 
+                               if (selectionIsKeyword(expression))
+                                       return null;
+
+                               String source= null;
+
+                               // Try with the indexer
+                               source= searchInIndex(copy, hoverRegion);
+
+                               if (source == null || source.trim().length() == 0)
+                                       return null;
+
+                               // we are actually interested in the comments, too.
+//                             source= removeLeadingComments(source);
+
+                               String delim= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
+
+                               String[] sourceLines= Strings.convertIntoLines(source);
+                               String firstLine= sourceLines[0];
+                               if (firstLine.length() > 0 && !Character.isWhitespace(firstLine.charAt(0)))
+                                       sourceLines[0]= ""; //$NON-NLS-1$
+                               Strings.trimIndentation(sourceLines, getTabWidth(), getTabWidth());
+
+                               if (!Character.isWhitespace(firstLine.charAt(0)))
+                                       sourceLines[0]= firstLine;
+
+                               source = Strings.concatenate(sourceLines, delim);
+                               return source;
+
+                       } catch (BadLocationException e) {
+                       }
+               }
+               return null;
+       }
+
+       /**
+        * Searches the start of the comment preceding the given source offset.
+        * Continuous line comments are considered as one comment until a block
+        * comment is reached or a non-comment partition.
+        * 
+        * @param doc  the document
+        * @param start  the start of the backward search
+        * @param bound  search boundary (exclusive)
+        * @return the comment start offset or <code>-1</code>, if no suitable comment was found
+        * @throws BadLocationException 
+        */
+       private static int searchCommentBackward(IDocument doc, int start, int bound) throws BadLocationException {
+               int firstLine= doc.getLineOfOffset(start);
+               if (firstLine == 0) {
+                       return 0;
+               }
+               ITypedRegion partition= TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, start, true);
+               int currentOffset= Math.max(doc.getLineOffset(firstLine - 1), partition.getOffset() - 1);
+               int commentOffset= -1;
+               while (currentOffset > bound) {
+                       partition= TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, currentOffset, true);
+                       currentOffset= partition.getOffset() - 1;
+                       if (ICPartitions.C_MULTI_LINE_COMMENT.equals(partition.getType()) 
+                                       || ICPartitions.C_MULTI_LINE_DOC_COMMENT.equals(partition.getType())) {
+                               final int partitionOffset= partition.getOffset();
+                               final int startLine= doc.getLineOfOffset(partitionOffset);
+                               final int lineOffset= doc.getLineOffset(startLine);
+                               if (partitionOffset == lineOffset || 
+                                               doc.get(lineOffset, partitionOffset - lineOffset).trim().length() == 0) {
+                                       return lineOffset;
+                               }
+                               return commentOffset;
+                       } else if (ICPartitions.C_SINGLE_LINE_COMMENT.equals(partition.getType())
+                                       || ICPartitions.C_SINGLE_LINE_DOC_COMMENT.equals(partition.getType())) {
+                               final int partitionOffset= partition.getOffset();
+                               final int startLine= doc.getLineOfOffset(partitionOffset);
+                               final int lineOffset= doc.getLineOffset(startLine);
+                               if (partitionOffset == lineOffset || 
+                                               doc.get(lineOffset, partitionOffset - lineOffset).trim().length() == 0) {
+                                       commentOffset= lineOffset;
+                                       continue;
+                               }
+                               return commentOffset;
+                       } else if (IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType())) {
+                               if (doc.get(partition.getOffset(), partition.getLength()).trim().length() == 0) {
+                                       continue;
+                               }
+                               if (commentOffset >= 0) {
+                                       break;
+                               }
+                       } else {
+                               break;
+                       }
+               }
+               return commentOffset;
+       }
+
+       private static int getTabWidth() {
+               return 4;
+       }
+
+
+       /**
+        * Strip the leading comment from the given source string.
+        * 
+        * @param source
+        * @return  the source string without leading comments
+        */
+       protected static String removeLeadingComments(String source) {
+               CCodeReader reader= new CCodeReader();
+               IDocument document= new Document(source);
+               int i;
+               try {
+                       reader.configureForwardReader(document, 0, document.getLength(), true, false);
+                       int c= reader.read();
+                       while (c != -1 && (c == '\r' || c == '\n')) {
+                               c= reader.read();
+                       }
+                       i= reader.getOffset();
+                       reader.close();
+               } catch (IOException ex) {
+                       i= 0;
+               } finally {
+                       try {
+                               reader.close();
+                       } catch (IOException ex) {
+                               CUIPlugin.log(ex);
+                       }
+               }
+
+               if (i < 0)
+                       return source;
+               return source.substring(i);
+       }
+
+       protected String searchInIndex(final ITranslationUnit tUnit, IRegion textRegion) {
+               final ComputeSourceRunnable computer= new ComputeSourceRunnable(tUnit, textRegion);
+               Job job= new Job(CHoverMessages.CSourceHover_jobTitle) {
+                       @Override
+                       protected IStatus run(IProgressMonitor monitor) {
+                               try {
+                                       return ASTProvider.getASTProvider().runOnAST(tUnit, ASTProvider.WAIT_ACTIVE_ONLY, monitor, computer);
+                               } catch (Throwable t) {
+                                       CUIPlugin.log(t);
+                               }
+                               return Status.CANCEL_STATUS;
+                       }
+               };
+               // If the hover thread is interrupted this might have negative
+               // effects on the index - see http://bugs.eclipse.org/219834
+               // Therefore we schedule a job to decouple the parsing from this thread.
+               job.setPriority(Job.DECORATE);
+               job.setSystem(true);
+               job.setRule(SingletonRule.INSTANCE);
+               job.schedule();
+               try {
+                       job.join();
+               } catch (InterruptedException exc) {
+                       job.cancel();
+                       return null;
+               }
+               return computer.getSource();
+       }
+
+
+       /**
+        * Test whether the given name is a known keyword.
+        * 
+        * @param name
+        * @return <code>true</code> if the name is a known keyword or <code>false</code> if the
+        *         name is not considered a keyword
+        */
+       private boolean selectionIsKeyword(String name) {
+               Set<String> keywords= ParserFactory.getKeywordSet(KeywordSetKey.KEYWORDS, ParserLanguage.CPP);
+               return keywords.contains(name);
+       }
+
+       /*
+        * @see org.eclipse.jface.text.ITextHoverExtension#getHoverControlCreator()
+        * @since 3.0
+        */
+       @Override
+       public IInformationControlCreator getHoverControlCreator() {
+               return new IInformationControlCreator() {
+                       public IInformationControl createInformationControl(Shell parent) {
+                               IEditorPart editor= getEditor();
+                               int orientation= SWT.NONE;
+                               if (editor instanceof IWorkbenchPartOrientation)
+                                       orientation= ((IWorkbenchPartOrientation) editor).getOrientation();
+                               return new SourceViewerInformationControl(parent, false, orientation, getTooltipAffordanceString());
+                       }
+               };
+       }
+
+       /*
+        * @see IInformationProviderExtension2#getInformationPresenterControlCreator()
+        * @since 3.0
+        */
+       @Override
+       public IInformationControlCreator getInformationPresenterControlCreator() {
+               return new IInformationControlCreator() {
+                       public IInformationControl createInformationControl(Shell parent) {
+                               IEditorPart editor= getEditor();
+                               int orientation= SWT.NONE;
+                               if (editor instanceof IWorkbenchPartOrientation)
+                                       orientation= ((IWorkbenchPartOrientation) editor).getOrientation();
+                               return new SourceViewerInformationControl(parent, true, orientation, null);
+                       }
+               };
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CTypeHover.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CTypeHover.java
new file mode 100644 (file)
index 0000000..461436a
--- /dev/null
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *     Marc-Andre Laperle - bug 282495
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.c.hover;
+
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextHoverExtension;
+import org.eclipse.jface.text.ITextHoverExtension2;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.information.IInformationProviderExtension2;
+import org.eclipse.ui.IEditorPart;
+
+import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
+
+/**
+ * Aggregator of problem and doc hovers.
+ * @since 5.0
+ */
+public class CTypeHover implements ICEditorTextHover, ITextHoverExtension, ITextHoverExtension2, IInformationProviderExtension2 {
+       private AbstractCEditorTextHover fProblemHover;
+       private AbstractCEditorTextHover fCDocHover;
+       private AbstractCEditorTextHover fBestMatchHover;
+
+       private AbstractCEditorTextHover fCurrentHover;
+
+       public CTypeHover() {
+               fProblemHover= new ProblemHover();
+               fCDocHover= new CDocHover();
+               fCurrentHover= null;
+               fBestMatchHover = new BestMatchHover();
+       }
+
+       /*
+        * @see ICEditorTextHover#setEditor(IEditorPart)
+        */
+       public void setEditor(IEditorPart editor) {
+               fProblemHover.setEditor(editor);
+               fCDocHover.setEditor(editor);
+               fBestMatchHover.setEditor(editor);
+               fCurrentHover= null;
+       }
+
+       /*
+        * @see ITextHover#getHoverRegion(ITextViewer, int)
+        */
+       public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
+               return fCDocHover.getHoverRegion(textViewer, offset);
+       }
+
+       /*
+        * @see ITextHover#getHoverInfo(ITextViewer, IRegion)
+        */
+       public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
+               Object info= getHoverInfo2(textViewer, hoverRegion);
+               if (info != null) {
+                       return String.valueOf(info);
+               }
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.ITextHoverExtension2#getHoverInfo2(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
+        */
+       public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
+               Object hoverInfo= fProblemHover.getHoverInfo2(textViewer, hoverRegion);
+               if (hoverInfo != null) {
+                       fCurrentHover= fProblemHover;
+                       return hoverInfo;
+               }
+
+               hoverInfo = fCDocHover.getHoverInfo2(textViewer, hoverRegion);
+               if(hoverInfo != null){
+                       fCurrentHover= fCDocHover;
+               }
+               
+               hoverInfo = fBestMatchHover.getHoverInfo(textViewer, hoverRegion);
+               if(hoverInfo != null){
+                       fCurrentHover = fBestMatchHover;
+               }
+               
+               return hoverInfo;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.ITextHoverExtension#getHoverControlCreator()
+        */
+       public IInformationControlCreator getHoverControlCreator() {
+               return fCurrentHover == null ? null : fCurrentHover.getHoverControlCreator();
+       }
+
+       /*
+        * @see org.eclipse.jface.text.information.IInformationProviderExtension2#getInformationPresenterControlCreator()
+        */
+       public IInformationControlCreator getInformationPresenterControlCreator() {
+               return fCurrentHover == null ? null : fCurrentHover.getInformationPresenterControlCreator();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/ProblemHover.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/ProblemHover.java
new file mode 100644 (file)
index 0000000..5f02f3b
--- /dev/null
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.c.hover;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.texteditor.MarkerAnnotation;
+import org.eclipse.ui.texteditor.spelling.SpellingAnnotation;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.ICCompletionProposal;
+import org.eclipse.cdt.ui.text.IProblemLocation;
+
+import org.eclipse.cdt.internal.ui.editor.ICAnnotation;
+import org.eclipse.cdt.internal.ui.text.contentassist.CCompletionProposalComparator;
+import org.eclipse.cdt.internal.ui.text.correction.CCorrectionProcessor;
+import org.eclipse.cdt.internal.ui.text.correction.CorrectionContext;
+import org.eclipse.cdt.internal.ui.text.correction.ProblemLocation;
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+
+/**
+ * This annotation hover shows the description of the
+ * selected java annotation.
+ *
+ * XXX: Currently this problem hover only works for spelling problems.
+ *             see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=62081
+ *
+ * @since 5.0
+ */
+public class ProblemHover extends AbstractAnnotationHover {
+
+       protected static class ProblemInfo extends AnnotationInfo {
+               private static final ICompletionProposal[] NO_PROPOSALS= new ICompletionProposal[0];
+
+               public ProblemInfo(Annotation annotation, Position position, ITextViewer textViewer) {
+                       super(annotation, position, textViewer);
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.text.java.hover.AbstractAnnotationHover.AnnotationInfo#getCompletionProposals()
+                */
+               @Override
+               public ICompletionProposal[] getCompletionProposals() {
+                       if (annotation instanceof ICAnnotation) {
+                               return getCAnnotationFixes((ICAnnotation) annotation);
+                       } else if (annotation instanceof MarkerAnnotation) {
+                               return getMarkerAnnotationFixes((MarkerAnnotation) annotation);
+                       }
+
+                       return NO_PROPOSALS;
+               }
+
+               private ICompletionProposal[] getCAnnotationFixes(ICAnnotation cAnnotation) {
+                       ProblemLocation location= new ProblemLocation(position.getOffset(), position.getLength(), cAnnotation);
+                       ITranslationUnit tu= cAnnotation.getTranslationUnit();
+
+                       ISourceViewer sourceViewer= null;
+                       if (viewer instanceof ISourceViewer)
+                               sourceViewer= (ISourceViewer) viewer;
+
+                       CorrectionContext context= new CorrectionContext(tu, sourceViewer, location.getOffset(), location.getLength());
+                       if (!SpellingAnnotation.TYPE.equals(cAnnotation.getType()))
+                               return NO_PROPOSALS;
+
+                       List<ICCompletionProposal> proposals= new ArrayList<ICCompletionProposal>();
+                       CCorrectionProcessor.collectCorrections(context, new IProblemLocation[] { location }, proposals);
+                       Collections.sort(proposals, new CCompletionProposalComparator());
+
+                       return proposals.toArray(new ICompletionProposal[proposals.size()]);
+               }
+
+               private ICompletionProposal[] getMarkerAnnotationFixes(MarkerAnnotation markerAnnotation) {
+                       if (markerAnnotation.isQuickFixableStateSet() && !markerAnnotation.isQuickFixable())
+                               return NO_PROPOSALS;
+
+                       IMarker marker= markerAnnotation.getMarker();
+
+                       IEditorInput input = null;
+                       try {
+                               input = EditorUtility.getEditorInput(marker.getResource());
+                       } catch (CModelException e) {
+                       }
+                       if (input == null)
+                               return NO_PROPOSALS;
+
+                       ITranslationUnit tu= getTranslationUnit(input);
+                       if (tu == null)
+                               return NO_PROPOSALS;
+
+                       IAnnotationModel model= CUIPlugin.getDefault().getDocumentProvider().getAnnotationModel(input);
+                       if (model == null)
+                               return NO_PROPOSALS;
+                       
+                       ISourceViewer sourceViewer= null;
+                       if (viewer instanceof ISourceViewer)
+                               sourceViewer= (ISourceViewer) viewer;
+
+                       CorrectionContext context= new CorrectionContext(tu, sourceViewer, position.getOffset(), position.getLength());
+
+                       List<ICCompletionProposal> proposals= new ArrayList<ICCompletionProposal>();
+                       CCorrectionProcessor.collectProposals(context, model, new Annotation[] { markerAnnotation }, true, false, proposals);
+
+                       return proposals.toArray(new ICompletionProposal[proposals.size()]);
+               }
+
+               private static ITranslationUnit getTranslationUnit(IEditorInput input) {
+                       return CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(input);
+               }
+       }
+
+       public ProblemHover() {
+               super(false);
+       }
+
+       @Override
+       protected AnnotationInfo createAnnotationInfo(Annotation annotation, Position position, ITextViewer textViewer) {
+               return new ProblemInfo(annotation, position, textViewer);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/SourceViewerInformationControl.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/SourceViewerInformationControl.java
new file mode 100644 (file)
index 0000000..23d155c
--- /dev/null
@@ -0,0 +1,506 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ * Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.c.hover;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IInformationControl;
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.IInformationControlExtension;
+import org.eclipse.jface.text.IInformationControlExtension3;
+import org.eclipse.jface.text.IInformationControlExtension5;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+import org.eclipse.cdt.internal.ui.editor.CSourceViewer;
+import org.eclipse.cdt.internal.ui.text.CTextTools;
+import org.eclipse.cdt.internal.ui.text.SimpleCSourceViewerConfiguration;
+
+/**
+ * Source viewer based implementation of <code>IInformationControl</code>.
+ * Displays information in a source viewer.
+ *
+ */
+public class SourceViewerInformationControl implements IInformationControl, IInformationControlExtension, IInformationControlExtension3, IInformationControlExtension5, DisposeListener {
+
+       /** The control's shell */
+       private Shell fShell;
+       /** The control's text widget */
+       private StyledText fText;
+       /** The control's source viewer */
+       private SourceViewer fViewer;
+       /** The text font (do not dispose!) */
+       private Font fTextFont;
+       /**
+        * The optional status field.
+        *
+        * @since 3.0
+        */
+       private Label fStatusField;
+       /**
+        * The separator for the optional status field.
+        *
+        * @since 3.0
+        */
+       private Label fSeparator;
+       /**
+        * The font of the optional status text label.
+        *
+        * @since 3.0
+        */
+       private Font fStatusTextFont;
+       /**
+        * The width size constraint.
+        * @since 4.0
+        */
+       private int fMaxWidth= SWT.DEFAULT;
+       /**
+        * The height size constraint.
+        * @since 4.0
+        */
+       private int fMaxHeight= SWT.DEFAULT;
+       /**
+        * The orientation of the shell
+        * @since 3.4
+        */
+       private final int fOrientation;
+
+       private Color fBackgroundColor;
+       private boolean fIsSystemBackgroundColor= true;
+
+       /**
+        * Creates a source viewer information control with the given shell as parent. The given
+        * styles are applied to the created styled text widget. The status field will
+        * contain the given text or be hidden.
+        *
+        * @param parent the parent shell
+        * @param isResizable <code>true</code> if resizable
+        * @param orientation the orientation
+        * @param statusFieldText the text to be used in the optional status field
+        *            or <code>null</code> if the status field should be hidden
+        */
+       public SourceViewerInformationControl(Shell parent, boolean isResizable, int orientation, String statusFieldText) {
+               Assert.isLegal(orientation == SWT.RIGHT_TO_LEFT || orientation == SWT.LEFT_TO_RIGHT || orientation == SWT.NONE);
+               fOrientation= orientation;
+               
+               GridLayout layout;
+               GridData gd;
+
+               int shellStyle= SWT.TOOL | SWT.ON_TOP | orientation | (isResizable ? SWT.RESIZE : 0);
+               int textStyle= isResizable ? SWT.V_SCROLL | SWT.H_SCROLL : SWT.NONE;
+
+               fShell= new Shell(parent, SWT.NO_FOCUS | SWT.ON_TOP | shellStyle);
+               Display display= fShell.getDisplay();
+
+               initializeColors();
+
+               Composite composite= fShell;
+               layout= new GridLayout(1, false);
+               layout.marginHeight= 0;
+               layout.marginWidth= 0;
+               composite.setLayout(layout);
+               gd= new GridData(GridData.FILL_HORIZONTAL);
+               composite.setLayoutData(gd);
+
+               if (statusFieldText != null) {
+                       composite= new Composite(composite, SWT.NONE);
+                       layout= new GridLayout(1, false);
+                       layout.marginHeight= 0;
+                       layout.marginWidth= 0;
+                       layout.verticalSpacing= 1;
+                       composite.setLayout(layout);
+                       gd= new GridData(GridData.FILL_BOTH);
+                       composite.setLayoutData(gd);
+                       composite.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
+                       composite.setBackground(fBackgroundColor);
+               }
+
+               // Source viewer
+               IPreferenceStore store= CUIPlugin.getDefault().getCombinedPreferenceStore();
+               fViewer= new CSourceViewer(composite, null, null, false, textStyle, store);
+               CTextTools tools= CUIPlugin.getDefault().getTextTools();
+               fViewer.configure(new SimpleCSourceViewerConfiguration(tools.getColorManager(), store, null, ICPartitions.C_PARTITIONING, false));
+               fViewer.setEditable(false);
+
+               fText= fViewer.getTextWidget();
+               gd= new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
+               fText.setLayoutData(gd);
+               fText.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
+               fText.setBackground(fBackgroundColor);
+
+               initializeFont();
+
+               fText.addKeyListener(new KeyListener() {
+
+                       public void keyPressed(KeyEvent e)  {
+                               if (e.character == 0x1B) // ESC
+                                       fShell.dispose();
+                       }
+
+                       public void keyReleased(KeyEvent e) {}
+               });
+
+               // Status field
+               if (statusFieldText != null) {
+
+                       // Horizontal separator line
+                       fSeparator= new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.LINE_DOT);
+                       fSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+                       // Status field label
+                       fStatusField= new Label(composite, SWT.RIGHT);
+                       fStatusField.setText(statusFieldText);
+                       Font font= fStatusField.getFont();
+                       FontData[] fontDatas= font.getFontData();
+                       for (int i= 0; i < fontDatas.length; i++)
+                               fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10);
+                       fStatusTextFont= new Font(fStatusField.getDisplay(), fontDatas);
+                       fStatusField.setFont(fStatusTextFont);
+                       GridData gd2= new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
+                       fStatusField.setLayoutData(gd2);
+
+                       // Regarding the color see bug 41128
+                       fStatusField.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
+                       fStatusField.setBackground(fBackgroundColor);
+               }
+
+               addDisposeListener(this);
+       }
+
+       private void initializeColors() {
+               RGB bgRGB= getHoverBackgroundColorRGB();
+               if (bgRGB != null) {
+                       fBackgroundColor= new Color(fShell.getDisplay(), bgRGB);
+                       fIsSystemBackgroundColor= false;
+               } else {
+                       fBackgroundColor= fShell.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND);
+                       fIsSystemBackgroundColor= true;
+               }
+       }
+
+       private RGB getHoverBackgroundColorRGB() {
+               IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+               return store.getBoolean(PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT)
+                       ? null
+                       : PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR);
+       }
+
+       /**
+        * Initialize the font to the editor font.
+        *
+        * @since 4.0
+        */
+       private void initializeFont() {
+               fTextFont= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
+               StyledText styledText= getViewer().getTextWidget();
+               styledText.setFont(fTextFont);
+       }
+
+       /*
+        * @see org.eclipse.jface.text.IInformationControlExtension2#setInput(java.lang.Object)
+        */
+       public void setInput(Object input) {
+               if (input instanceof String)
+                       setInformation((String)input);
+               else
+                       setInformation(null);
+       }
+
+       /*
+        * @see IInformationControl#setInformation(String)
+        */
+       public void setInformation(String content) {
+               if (content == null) {
+                       fViewer.setInput(null);
+                       return;
+               }
+
+               IDocument doc= new Document(content);
+               CUIPlugin.getDefault().getTextTools().setupCDocument(doc);
+               fViewer.setInput(doc);
+       }
+
+       /*
+        * @see IInformationControl#setVisible(boolean)
+        */
+       public void setVisible(boolean visible) {
+               fShell.setVisible(visible);
+       }
+
+       /**
+        * {@inheritDoc}
+        * @since 3.0
+        */
+       public void widgetDisposed(DisposeEvent event) {
+               if (fStatusTextFont != null && !fStatusTextFont.isDisposed())
+                       fStatusTextFont.dispose();
+
+               fStatusTextFont= null;
+               fTextFont= null;
+               fShell= null;
+               fText= null;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public final void dispose() {
+               if (!fIsSystemBackgroundColor)
+                       fBackgroundColor.dispose();
+               if (fShell != null && !fShell.isDisposed())
+                       fShell.dispose();
+               else
+                       widgetDisposed(null);
+       }
+
+       /*
+        * @see IInformationControl#setSize(int, int)
+        */
+       public void setSize(int width, int height) {
+               fShell.setSize(width, height);
+       }
+
+       /*
+        * @see IInformationControl#setLocation(Point)
+        */
+       public void setLocation(Point location) {
+               fShell.setLocation(location);
+       }
+
+       /*
+        * @see IInformationControl#setSizeConstraints(int, int)
+        */
+       public void setSizeConstraints(int maxWidth, int maxHeight) {
+               fMaxWidth= maxWidth;
+               fMaxHeight= maxHeight;
+       }
+
+       /*
+        * @see IInformationControl#computeSizeHint()
+        */
+       public Point computeSizeHint() {
+               // compute the preferred size
+               int x= SWT.DEFAULT;
+               int y= SWT.DEFAULT;
+               Point size= fShell.computeSize(x, y);
+               if (size.x > fMaxWidth)
+                       x= fMaxWidth;
+               if (size.y > fMaxHeight)
+                       y= fMaxHeight;
+
+               // recompute using the constraints if the preferred size is larger than the constraints
+               if (x != SWT.DEFAULT || y != SWT.DEFAULT)
+                       size= fShell.computeSize(x, y, false);
+
+               return size;
+       }
+
+       /*
+        * @see IInformationControl#addDisposeListener(DisposeListener)
+        */
+       public void addDisposeListener(DisposeListener listener) {
+               fShell.addDisposeListener(listener);
+       }
+
+       /*
+        * @see IInformationControl#removeDisposeListener(DisposeListener)
+        */
+       public void removeDisposeListener(DisposeListener listener) {
+               fShell.removeDisposeListener(listener);
+       }
+
+       /*
+        * @see IInformationControl#setForegroundColor(Color)
+        */
+       public void setForegroundColor(Color foreground) {
+               fText.setForeground(foreground);
+       }
+
+       /*
+        * @see IInformationControl#setBackgroundColor(Color)
+        */
+       public void setBackgroundColor(Color background) {
+               fText.setBackground(background);
+       }
+
+       /*
+        * @see IInformationControl#isFocusControl()
+        */
+       public boolean isFocusControl() {
+               return fShell.getDisplay().getActiveShell() == fShell;
+       }
+
+       /*
+        * @see IInformationControl#setFocus()
+        */
+       public void setFocus() {
+               fShell.forceFocus();
+               fText.setFocus();
+       }
+
+       /*
+        * @see IInformationControl#addFocusListener(FocusListener)
+        */
+       public void addFocusListener(FocusListener listener) {
+               fText.addFocusListener(listener);
+       }
+
+       /*
+        * @see IInformationControl#removeFocusListener(FocusListener)
+        */
+       public void removeFocusListener(FocusListener listener) {
+               fText.removeFocusListener(listener);
+       }
+
+       /*
+        * @see IInformationControlExtension#hasContents()
+        */
+       public boolean hasContents() {
+               return fText.getCharCount() > 0;
+       }
+
+       protected ISourceViewer getViewer()  {
+               return fViewer;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.IInformationControlExtension3#computeTrim()
+        * @since 5.0
+        */
+       public Rectangle computeTrim() {
+               Rectangle trim= fShell.computeTrim(0, 0, 0, 0);
+               addInternalTrim(trim);
+               return trim;
+       }
+
+       /**
+        * Adds the internal trimmings to the given trim of the shell.
+        * 
+        * @param trim the shell's trim, will be updated
+        * @since 5.0
+        */
+       private void addInternalTrim(Rectangle trim) {
+               Rectangle textTrim= fText.computeTrim(0, 0, 0, 0);
+               trim.x+= textTrim.x;
+               trim.y+= textTrim.y;
+               trim.width+= textTrim.width;
+               trim.height+= textTrim.height;
+               
+               if (fStatusField != null) {
+                       trim.height+= fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
+                       trim.height+= fStatusField.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
+                       trim.height+= 1; // verticalSpacing
+               }
+       }
+
+       /*
+        * @see org.eclipse.jface.text.IInformationControlExtension3#getBounds()
+        * @since 5.0
+        */
+       public Rectangle getBounds() {
+               return fShell.getBounds();
+       }
+
+       /*
+        * @see org.eclipse.jface.text.IInformationControlExtension3#restoresLocation()
+        * @since 5.0
+        */
+       public boolean restoresLocation() {
+               return false;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.IInformationControlExtension3#restoresSize()
+        * @since 5.0
+        */
+       public boolean restoresSize() {
+               return false;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.IInformationControlExtension5#getInformationPresenterControlCreator()
+        * @since 5.0
+        */
+       public IInformationControlCreator getInformationPresenterControlCreator() {
+               return new IInformationControlCreator() {
+                       public IInformationControl createInformationControl(Shell parent) {
+                               return new SourceViewerInformationControl(parent, true, fOrientation, null);
+                       }
+               };
+       }
+
+       /*
+        * @see org.eclipse.jface.text.IInformationControlExtension5#containsControl(org.eclipse.swt.widgets.Control)
+        * @since 5.0
+        */
+       public boolean containsControl(Control control) {
+               do {
+                       if (control == fShell)
+                               return true;
+                       if (control instanceof Shell)
+                               return false;
+                       control= control.getParent();
+               } while (control != null);
+               return false;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.IInformationControlExtension5#isVisible()
+        * @since 5.0
+        */
+       public boolean isVisible() {
+               return fShell != null && !fShell.isDisposed() && fShell.isVisible();
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.IInformationControlExtension5#computeSizeConstraints(int, int)
+        */
+       public Point computeSizeConstraints(int widthInChars, int heightInChars) {
+               GC gc= new GC(fText);
+               gc.setFont(fTextFont);
+               int width= gc.getFontMetrics().getAverageCharWidth();
+               int height= gc.getFontMetrics().getHeight();
+               gc.dispose();
+
+               return new Point(widthInChars * width, heightInChars * height);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposal.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposal.java
new file mode 100644 (file)
index 0000000..bc18bf5
--- /dev/null
@@ -0,0 +1,693 @@
+/*******************************************************************************
+ *  Copyright (c) 2004, 2011 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Rational Software - Initial API and implementation
+ *     Jens Elmenthaler - http://bugs.eclipse.org/173458 (camel case completion)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.contentassist;
+
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.BadPositionCategoryException;
+import org.eclipse.jface.text.DefaultPositionUpdater;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.IPositionUpdater;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.ITextViewerExtension2;
+import org.eclipse.jface.text.ITextViewerExtension5;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.contentassist.ICompletionProposalExtension;
+import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2;
+import org.eclipse.jface.text.contentassist.ICompletionProposalExtension3;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.link.ILinkedModeListener;
+import org.eclipse.jface.text.link.LinkedModeModel;
+import org.eclipse.jface.text.link.LinkedModeUI;
+import org.eclipse.jface.text.link.LinkedModeUI.ExitFlags;
+import org.eclipse.jface.text.link.LinkedModeUI.IExitPolicy;
+import org.eclipse.jface.text.link.LinkedPosition;
+import org.eclipse.jface.text.link.LinkedPositionGroup;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyleRange;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.ui.texteditor.link.EditorLinkedModeUI;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.ICCompletionProposal;
+
+import org.eclipse.cdt.internal.core.parser.util.ContentAssistMatcherFactory;
+
+import org.eclipse.cdt.internal.ui.text.CTextTools;
+
+
+public class CCompletionProposal implements ICCompletionProposal, ICompletionProposalExtension, ICompletionProposalExtension2, ICompletionProposalExtension3 {
+       
+       private String fDisplayString;
+    private String fIdString;
+       private String fReplacementString;
+       private int fReplacementOffset;
+       private int fReplacementLength;
+       private int fCursorPosition;
+       private Image fImage;
+       private IContextInformation fContextInformation;
+       private int fContextInformationPosition;
+       private String fProposalInfo;
+       private char[] fTriggerCharacters;
+       protected boolean fToggleEating;
+       protected ITextViewer fTextViewer;      
+       
+       private int fRelevance;
+       private StyleRange fRememberedStyleRange;
+
+       /**
+        * Creates a new completion proposal. All fields are initialized based on the provided information.
+        *
+        * @param replacementString the actual string to be inserted into the document
+        * @param replacementOffset the offset of the text to be replaced
+        * @param replacementLength the length of the text to be replaced
+        * @param image the image to display for this proposal
+        * @param displayString the string to be displayed for the proposal
+        * If set to <code>null</code>, the replacement string will be taken as display string.
+        */
+       public CCompletionProposal(String replacementString, int replacementOffset, int replacementLength, Image image, String displayString, int relevance) {
+        this(replacementString, replacementOffset, replacementLength, image, displayString, null, relevance, null);
+       }
+
+    /**
+     * Creates a new completion proposal. All fields are initialized based on the provided information.
+     *
+     * @param replacementString the actual string to be inserted into the document
+     * @param replacementOffset the offset of the text to be replaced
+     * @param replacementLength the length of the text to be replaced
+     * @param image the image to display for this proposal
+     * @param displayString the string to be displayed for the proposal
+     * @param viewer the text viewer for which this proposal is computed, may be <code>null</code>
+     * If set to <code>null</code>, the replacement string will be taken as display string.
+     */
+    public CCompletionProposal(String replacementString, int replacementOffset, int replacementLength, Image image, String displayString, int relevance, ITextViewer viewer) {
+        this(replacementString, replacementOffset, replacementLength, image, displayString, null, relevance, viewer);
+    }
+
+    /**
+     * Creates a new completion proposal. All fields are initialized based on the provided information.
+     *
+     * @param replacementString the actual string to be inserted into the document
+     * @param replacementOffset the offset of the text to be replaced
+     * @param replacementLength the length of the text to be replaced
+     * @param image the image to display for this proposal
+     * @param displayString the string to be displayed for the proposal
+     * @param idString the string to be uniquely identify this proposal
+     * @param viewer the text viewer for which this proposal is computed, may be <code>null</code>
+     * If set to <code>null</code>, the replacement string will be taken as display string.
+     */
+    public CCompletionProposal(String replacementString, int replacementOffset, int replacementLength, Image image, String displayString, String idString, int relevance, ITextViewer viewer) {
+        Assert.isNotNull(replacementString);
+               Assert.isTrue(replacementOffset >= 0);
+               Assert.isTrue(replacementLength >= 0);
+                               
+               fReplacementString = replacementString;
+               fReplacementOffset = replacementOffset;
+               fReplacementLength = replacementLength;
+               fImage = image;
+        fRelevance = relevance;
+        fTextViewer = viewer;
+        
+               fDisplayString = displayString != null ? displayString : replacementString;
+        fIdString = idString != null ? idString : displayString;
+
+               fCursorPosition = replacementString.length();
+       
+               fContextInformation = null;
+               fContextInformationPosition = -1;
+               fTriggerCharacters = null;
+               fProposalInfo = null;
+       }
+       
+       /**
+        * Sets the context information.
+        * @param contextInformation The context information associated with this proposal
+        */
+       public void setContextInformation(IContextInformation contextInformation) {
+               fContextInformation= contextInformation;
+               fContextInformationPosition= (fContextInformation != null ? fCursorPosition : -1);
+       }
+       
+       /**
+        * Sets the trigger characters.
+        * @param triggerCharacters The set of characters which can trigger the application of this completion proposal
+        */
+       public void setTriggerCharacters(char[] triggerCharacters) {
+               fTriggerCharacters= triggerCharacters;
+       }
+       
+       /**
+        * Sets the proposal info.
+        * @param proposalInfo The additional information associated with this proposal or <code>null</code>
+        */
+       public void setAdditionalProposalInfo(String proposalInfo) {
+               fProposalInfo= proposalInfo;
+       }
+       
+       /**
+        * Sets the cursor position relative to the insertion offset. By default this is the length of the completion string
+        * (Cursor positioned after the completion)
+        * @param cursorPosition The cursorPosition to set
+        */
+       public void setCursorPosition(int cursorPosition) {
+               Assert.isTrue(cursorPosition >= 0);
+               fCursorPosition= cursorPosition;
+               fContextInformationPosition= (fContextInformation != null ? fCursorPosition : -1);
+       }
+       
+       /*
+        * @see ICompletionProposalExtension#apply(IDocument, char, int)
+        */
+       public void apply(IDocument document, char trigger, int offset) {
+               try {
+                       // patch replacement length
+                       int delta= offset - (fReplacementOffset + fReplacementLength);
+                       if (delta > 0)
+                               fReplacementLength += delta;
+                       
+                       String string;
+                       if (trigger == (char) 0) {
+                               string= fReplacementString;
+                       } else {
+                               StringBuffer buffer= new StringBuffer(fReplacementString);
+
+                               // fix for PR #5533. Assumes that no eating takes place.
+                               if ((fCursorPosition > 0 && fCursorPosition <= buffer.length() && buffer.charAt(fCursorPosition - 1) != trigger)) {
+                                       buffer.insert(fCursorPosition, trigger);
+                                       ++fCursorPosition;
+                               }
+                               
+                               string= buffer.toString();
+                       }
+
+                       // reference position just at the end of the document change.
+                       int referenceOffset= fReplacementOffset + fReplacementLength;
+                       final ReferenceTracker referenceTracker= new ReferenceTracker();
+                       referenceTracker.preReplace(document, referenceOffset);
+
+                       replace(document, fReplacementOffset, fReplacementLength, string);
+
+                       referenceOffset= referenceTracker.postReplace(document);                        
+                       fReplacementOffset= referenceOffset - (string == null ? 0 : string.length());
+
+                       if (fTextViewer != null && string != null) {
+                               int index= string.indexOf("()"); //$NON-NLS-1$
+                               if (index != -1 && index + 1 == fCursorPosition) {
+                                       int newOffset= fReplacementOffset + fCursorPosition;
+                                       
+                                       LinkedPositionGroup group= new LinkedPositionGroup();
+                                       group.addPosition(new LinkedPosition(document, newOffset, 0, LinkedPositionGroup.NO_STOP));
+                                       
+                                       LinkedModeModel model= new LinkedModeModel();
+                                       model.addGroup(group);
+                                       model.forceInstall();
+                                       
+                                       LinkedModeUI ui= new EditorLinkedModeUI(model, fTextViewer);
+                                       ui.setSimpleMode(true);
+                                       ui.setExitPolicy(new ExitPolicy(')'));
+                                       ui.setExitPosition(fTextViewer, newOffset + 1, 0, Integer.MAX_VALUE);
+                                       ui.setCyclingMode(LinkedModeUI.CYCLE_NEVER);
+                                       ui.enter();
+                               }
+                       }
+
+               } catch (BadLocationException x) {
+                       // ignore
+               }               
+       }
+
+       /**
+        * A class to simplify tracking a reference position in a document. 
+        */
+       private static final class ReferenceTracker {
+
+               /** The reference position category name. */
+               private static final String CATEGORY= "reference_position"; //$NON-NLS-1$
+               /** The position updater of the reference position. */
+               private final IPositionUpdater fPositionUpdater= new DefaultPositionUpdater(CATEGORY);
+               /** The reference position. */
+               private final Position fPosition= new Position(0);
+               
+               /**
+                * Called before document changes occur. It must be followed by a call to postReplace().
+                * 
+                * @param document the document on which to track the reference position.
+                *      
+                */
+               public void preReplace(IDocument document, int offset) throws BadLocationException {
+                       fPosition.setOffset(offset);
+                       try {
+                               document.addPositionCategory(CATEGORY);
+                               document.addPositionUpdater(fPositionUpdater);
+                               document.addPosition(CATEGORY, fPosition);
+
+                       } catch (BadPositionCategoryException e) {
+                               // should not happen
+                               CUIPlugin.log(e);
+                       }
+               }
+       
+               /**
+                * Called after the document changed occured. It must be preceded by a call to preReplace().
+                * 
+                * @param document the document on which to track the reference position.
+                */
+               public int postReplace(IDocument document) {
+                       try {
+                               document.removePosition(CATEGORY, fPosition);
+                               document.removePositionUpdater(fPositionUpdater);
+                               document.removePositionCategory(CATEGORY);
+                                
+                       } catch (BadPositionCategoryException e) {
+                               // should not happen
+                               CUIPlugin.log(e);
+                       }
+                       return fPosition.getOffset();
+               }
+       }       
+       
+       protected static class ExitPolicy implements IExitPolicy {
+               
+               final char fExitCharacter;
+               
+               public ExitPolicy(char exitCharacter) {
+                       fExitCharacter= exitCharacter;
+               }
+
+               /*
+                * @see org.eclipse.jdt.internal.ui.text.link.LinkedPositionUI.ExitPolicy#doExit(org.eclipse.jdt.internal.ui.text.link.LinkedPositionManager, org.eclipse.swt.events.VerifyEvent, int, int)
+                */
+               public ExitFlags doExit(LinkedModeModel environment, VerifyEvent event, int offset, int length) {
+                       
+                       if (event.character == fExitCharacter) {
+                               if (environment.anyPositionContains(offset))
+                                       return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
+                               
+                               return new ExitFlags(ILinkedModeListener.UPDATE_CARET, true);
+                       }       
+                       
+                       switch (event.character) {                      
+                       case ';':
+                               return new ExitFlags(ILinkedModeListener.NONE, true);
+                                                               
+                       default:
+                               return null;
+                       }                                               
+               }
+
+       }       
+       
+       // #6410 - File unchanged but dirtied by code assist
+       private void replace(IDocument document, int offset, int length, String string) throws BadLocationException {
+               if (!document.get(offset, length).equals(string))
+                       document.replace(offset, length, string);
+       }
+
+       /*
+        * @see ICompletionProposal#apply
+        */
+       public void apply(IDocument document) {
+               apply(document, (char) 0, fReplacementOffset + fReplacementLength);
+       }
+       
+       /*
+        * @see ICompletionProposal#getSelection
+        */
+       public Point getSelection(IDocument document) {
+               return new Point(fReplacementOffset + fCursorPosition, 0);
+       }
+
+       /*
+        * @see ICompletionProposal#getContextInformation()
+        */
+       public IContextInformation getContextInformation() {
+               return fContextInformation;
+       }
+
+       /*
+        * @see ICompletionProposal#getImage()
+        */
+       public Image getImage() {
+               return fImage;
+       }
+
+       /*
+        * @see ICompletionProposal#getDisplayString()
+        */
+       public String getDisplayString() {
+               return fDisplayString;
+       }
+
+    /**
+     * This method is used by the comparator to compare proposals. It ignores the return type of a function.
+     * 
+     * @return the string representing the display name without the return type (if any).
+     */
+    public String getIdString() {
+        return fIdString;
+    }
+    
+       /*
+        * @see ICompletionProposal#getAdditionalProposalInfo()
+        */
+       public String getAdditionalProposalInfo() {
+               if (fProposalInfo != null) {
+                       return fProposalInfo;
+               }
+               return null;
+       }
+       
+       /*
+        * @see ICompletionProposalExtension#getTriggerCharacters()
+        */
+       public char[] getTriggerCharacters() {
+               return fTriggerCharacters;
+       }
+
+       /*
+        * @see ICompletionProposalExtension#getContextInformationPosition()
+        */
+       public int getContextInformationPosition() {
+               return fReplacementOffset + fContextInformationPosition;
+       }
+       
+       /**
+        * Gets the replacement offset.
+        * @return Returns a int
+        */
+       public int getReplacementOffset() {
+               return fReplacementOffset;
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension3#getCompletionOffset()
+        */
+       public int getPrefixCompletionStart(IDocument document, int completionOffset) {
+               return getReplacementOffset();
+       }
+
+       /**
+        * Sets the replacement offset.
+        * @param replacementOffset The replacement offset to set
+        */
+       public void setReplacementOffset(int replacementOffset) {
+               Assert.isTrue(replacementOffset >= 0);
+               fReplacementOffset= replacementOffset;
+       }       
+
+       /**
+        * Gets the replacement length.
+        * @return Returns a int
+        */
+       public int getReplacementLength() {
+               return fReplacementLength;
+       }
+
+       /**
+        * Sets the replacement length.
+        * @param replacementLength The replacementLength to set
+        */
+       public void setReplacementLength(int replacementLength) {
+               Assert.isTrue(replacementLength >= 0);
+               fReplacementLength= replacementLength;
+       }
+
+       /**
+        * Gets the replacement string.
+        * @return Returns a String
+        */
+       public String getReplacementString() {
+               return fReplacementString;
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension3#getReplacementText()
+        */
+       public CharSequence getPrefixCompletionText(IDocument document, int completionOffset) {
+               String string= getReplacementString();
+               int pos= string.indexOf('(');
+               if (pos > 0)
+                       return string.subSequence(0, pos);
+               return string;
+       }
+
+       /**
+        * Sets the replacement string.
+        * @param replacementString The replacement string to set
+        */
+       public void setReplacementString(String replacementString) {
+               fReplacementString= replacementString;
+       }
+
+       /**
+        * Sets the image.
+        * @param image The image to set
+        */
+       public void setImage(Image image) {
+               fImage= image;
+       }
+
+       /*
+        * @see ICompletionProposalExtension#isValidFor(IDocument, int)
+        */
+       public boolean isValidFor(IDocument document, int offset) {
+               return validate(document, offset, null);
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#validate(org.eclipse.jface.text.IDocument, int, org.eclipse.jface.text.DocumentEvent)
+        */
+       public boolean validate(IDocument document, int offset, DocumentEvent event) {
+
+               if (offset < fReplacementOffset)
+                       return false;
+                               
+               boolean validated= match(document, offset, fReplacementString); 
+
+               if (validated && event != null) {
+                       // adapt replacement range to document change
+                       int delta= (event.fText == null ? 0 : event.fText.length()) - event.fLength;
+                       fReplacementLength += delta;    
+               }
+
+               return validated;
+       }
+       
+       /**
+        * Gets the proposal's relevance.
+        * @return Returns a int
+        */
+       public int getRelevance() {
+               return fRelevance;
+       }
+
+       /**
+        * Sets the proposal's relevance.
+        * @param relevance The relevance to set
+        */
+       public void setRelevance(int relevance) {
+               fRelevance= relevance;
+       }
+
+       /**
+        * Returns <code>true</code> if a words matches the code completion prefix in the document,
+        * <code>false</code> otherwise.
+        */     
+       protected boolean match(IDocument document, int offset, String word) {
+               if (word == null) 
+                       return false;
+               
+               final int wordLength= word.length();
+               if (offset >  fReplacementOffset + wordLength)
+                       return false;
+               
+               try {
+                       int length= offset - fReplacementOffset;
+                       String pattern= document.get(fReplacementOffset, length);
+                       return ContentAssistMatcherFactory.getInstance().match(pattern.toCharArray(), word.toCharArray());
+               } catch (BadLocationException x) {
+               }
+               
+               return false;   
+       }       
+
+       private static boolean insertCompletion() {
+               IPreferenceStore preference= CUIPlugin.getDefault().getPreferenceStore();
+               return preference.getBoolean(ContentAssistPreference.AUTOINSERT);
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension1#apply(org.eclipse.jface.text.ITextViewer, char, int, int)
+        */
+       public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
+
+               IDocument document= viewer.getDocument();
+
+               // don't eat if not in preferences, XOR with modifier key 1 (Ctrl)
+               // but: if there is a selection, replace it!
+               Point selection= viewer.getSelectedRange();
+               fToggleEating= (stateMask & SWT.MOD1) != 0;
+               if (insertCompletion() ^ fToggleEating)
+                       fReplacementLength= selection.x + selection.y - fReplacementOffset;
+               
+               apply(document, trigger, offset);
+               fToggleEating= false;
+       }
+
+       private static Color getForegroundColor(StyledText text) {
+
+               IPreferenceStore preference= CUIPlugin.getDefault().getPreferenceStore();
+               RGB rgb= PreferenceConverter.getColor(preference, ContentAssistPreference.PROPOSALS_FOREGROUND);
+               CTextTools textTools= CUIPlugin.getDefault().getTextTools();
+               return textTools.getColorManager().getColor(rgb);
+       }
+
+       private static Color getBackgroundColor(StyledText text) {
+
+               IPreferenceStore preference= CUIPlugin.getDefault().getPreferenceStore();
+               RGB rgb= PreferenceConverter.getColor(preference, ContentAssistPreference.PROPOSALS_BACKGROUND);
+               CTextTools textTools= CUIPlugin.getDefault().getTextTools();
+               return textTools.getColorManager().getColor(rgb);
+       }
+       
+       private void repairPresentation(ITextViewer viewer) {
+               if (fRememberedStyleRange != null) {
+                        if (viewer instanceof ITextViewerExtension2) {
+                               // attempts to reduce the redraw area
+                               ITextViewerExtension2 viewer2= (ITextViewerExtension2) viewer;
+                               
+                               if (viewer instanceof ITextViewerExtension5) {
+                                       
+                                       ITextViewerExtension5 extension= (ITextViewerExtension5) viewer;
+                                       IRegion widgetRange= extension.modelRange2WidgetRange(new Region(fRememberedStyleRange.start, fRememberedStyleRange.length));
+                                       if (widgetRange != null)
+                                               viewer2.invalidateTextPresentation(widgetRange.getOffset(), widgetRange.getLength());
+                                               
+                               } else {
+                                       viewer2.invalidateTextPresentation(fRememberedStyleRange.start + viewer.getVisibleRegion().getOffset(), fRememberedStyleRange.length);
+                               }
+                               
+                       } else
+                               viewer.invalidateTextPresentation();
+               }
+       }
+
+       private void updateStyle(ITextViewer viewer) {
+
+               StyledText text= viewer.getTextWidget();
+               if (text == null || text.isDisposed())
+                       return;
+
+               int widgetCaret= text.getCaretOffset();
+               
+               int modelCaret= 0;
+               if (viewer instanceof ITextViewerExtension5) {
+                       ITextViewerExtension5 extension= (ITextViewerExtension5) viewer;
+                       modelCaret= extension.widgetOffset2ModelOffset(widgetCaret);
+               } else {
+                       IRegion visibleRegion= viewer.getVisibleRegion();
+                       modelCaret= widgetCaret + visibleRegion.getOffset();                    
+               }
+               
+               if (modelCaret >= fReplacementOffset + fReplacementLength) {
+                       repairPresentation(viewer);
+                       return;
+               }
+                                       
+               int offset= widgetCaret;
+               int length= fReplacementOffset + fReplacementLength - modelCaret;
+       
+               Color foreground= getForegroundColor(text);
+               Color background= getBackgroundColor(text);
+
+               StyleRange range= text.getStyleRangeAtOffset(offset);
+               int fontStyle= range != null ? range.fontStyle : SWT.NORMAL;
+
+               repairPresentation(viewer);
+               fRememberedStyleRange= new StyleRange(offset, length, foreground, background, fontStyle);
+               
+               // http://dev.eclipse.org/bugs/show_bug.cgi?id=34754
+               try {
+                       text.setStyleRange(fRememberedStyleRange);
+               } catch (IllegalArgumentException x) {
+                       // catching exception as offset + length might be outside of the text widget
+                       fRememberedStyleRange= null;
+               }
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#selected(ITextViewer, boolean)
+        */
+       public void selected(ITextViewer viewer, boolean smartToggle) {
+               if (!insertCompletion() ^ smartToggle)
+                       updateStyle(viewer);
+               else {
+                       repairPresentation(viewer);
+                       fRememberedStyleRange= null;
+               }
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#unselected(ITextViewer)
+        */
+       public void unselected(ITextViewer viewer) {
+               repairPresentation(viewer);
+               fRememberedStyleRange= null;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension3#getInformationControlCreator()
+        */
+       public IInformationControlCreator getInformationControlCreator() {
+               return null;
+       }
+
+       public void updateReplacementOffset(int newOffset) {
+               setReplacementOffset(newOffset);
+       }
+
+       public void updateReplacementLength(int length) {
+               setReplacementLength(length);
+       }
+
+       /*
+        * @see java.lang.Object#hashCode()
+        */
+       @Override
+       public int hashCode() {
+               return fIdString.hashCode();
+       }
+
+       /*
+        * @see java.lang.Object#equals(java.lang.Object)
+        */
+       @Override
+       public boolean equals(Object other) {
+               if(!(other instanceof ICCompletionProposal))
+                       return false;
+               return fIdString.equalsIgnoreCase(((ICCompletionProposal)other).getIdString());
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposalComparator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposalComparator.java
new file mode 100644 (file)
index 0000000..3a9b282
--- /dev/null
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.contentassist;
+
+
+import java.util.Comparator;
+
+import org.eclipse.cdt.ui.text.ICCompletionProposal;
+
+public class CCompletionProposalComparator implements Comparator<ICCompletionProposal> {
+
+       private boolean fOrderAlphabetically;
+
+       /**
+        * Constructor for CompletionProposalComparator.
+        */
+       public CCompletionProposalComparator() {
+               fOrderAlphabetically= false;
+       }
+       
+       public void setOrderAlphabetically(boolean orderAlphabetically) {
+               fOrderAlphabetically= orderAlphabetically;
+       }
+       
+       /*
+        * @see Comparator#compare(Object, Object)
+        */
+       public int compare(ICCompletionProposal c1, ICCompletionProposal c2) {
+               if (!fOrderAlphabetically) {
+                       int relevanceDif= c2.getRelevance() - c1.getRelevance();
+                       if (relevanceDif != 0) {
+                               return relevanceDif;
+                       }
+               }
+        
+        String id1 = c1.getIdString();
+        String id2 = c2.getIdString();
+        
+               return id1.compareTo(id2);
+       }       
+       
+}
+
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistInvocationContext.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistInvocationContext.java
new file mode 100644 (file)
index 0000000..89ec8b8
--- /dev/null
@@ -0,0 +1,292 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Bryan Wilkinson (QNX)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.contentassist;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.ui.IEditorPart;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexManager;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext;
+import org.eclipse.cdt.ui.text.contentassist.ICEditorContentAssistInvocationContext;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.text.CHeuristicScanner;
+import org.eclipse.cdt.internal.ui.text.Symbols;
+
+
+/**
+ * Describes the context of a content assist invocation in a C/C++ editor.
+ * <p>
+ * Clients may use but not subclass this class.
+ * </p>
+ * 
+ * @since 4.0
+ */
+public class CContentAssistInvocationContext extends ContentAssistInvocationContext implements ICEditorContentAssistInvocationContext {
+       
+       private final IEditorPart fEditor;
+       private final boolean fIsCompletion;
+       private final boolean fIsAutoActivated;
+       
+       private ITranslationUnit fTU= null;
+       private boolean fTUComputed= false;
+       private int fParseOffset= -1;
+       private boolean fParseOffsetComputed= false;
+       private IASTCompletionNode fCN= null;
+       private boolean fCNComputed= false;
+       private IIndex fIndex = null;
+       private int fContextInfoPosition;
+       
+       /**
+        * Creates a new context.
+        * 
+        * @param viewer the viewer used by the editor
+        * @param offset the invocation offset
+        * @param editor the editor that content assist is invoked in
+        * @param isAutoActivated indicates whether content assist was auto-activated
+        */
+       public CContentAssistInvocationContext(ITextViewer viewer, int offset, IEditorPart editor, boolean isCompletion, boolean isAutoActivated) {
+               super(viewer, offset);
+               Assert.isNotNull(editor);
+               fEditor= editor;
+               fIsCompletion= isCompletion;
+               fIsAutoActivated= isAutoActivated;
+       }
+       
+       /**
+        * Creates a new context.
+        * 
+        * @param unit the translation unit in <code>document</code>
+        */
+       public CContentAssistInvocationContext(ITranslationUnit unit, boolean isCompletion) {
+               super();
+               fTU= unit;
+               fTUComputed= true;
+               fEditor= null;
+               fIsCompletion= isCompletion;
+               fIsAutoActivated= false;
+       }
+       
+       /**
+        * Returns the translation unit that content assist is invoked in, <code>null</code> if there
+        * is none.
+        * 
+        * @return the translation unit that content assist is invoked in, possibly <code>null</code>
+        */
+       public ITranslationUnit getTranslationUnit() {
+               if (!fTUComputed) {
+                       fTUComputed= true;
+                       fTU= CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(fEditor.getEditorInput());
+               }
+               return fTU;
+       }
+       
+       /**
+        * Returns the project of the translation unit that content assist is invoked in,
+        * <code>null</code> if none.
+        * 
+        * @return the current C project, possibly <code>null</code>
+        */
+       public ICProject getProject() {
+               ITranslationUnit unit= getTranslationUnit();
+               return unit == null ? null : unit.getCProject();
+       }
+               
+       public IASTCompletionNode getCompletionNode() {
+               
+               //for scalability
+               if (fEditor != null && fEditor instanceof CEditor) {
+                       CEditor editor = (CEditor)fEditor;
+                       
+                       // check to make sure we should attempt local parsing completions... for remote projects
+                       // we should not do this
+                       if(!editor.shouldProcessLocalParsingCompletions()) {
+                               return null;
+                       }
+                       if (editor.isEnableScalablilityMode()) {
+                               if (editor.isParserBasedContentAssistDisabled()) {
+                                       return null;
+                               }
+                               if (isAutoActivated() && editor.isContentAssistAutoActivartionDisabled()) {
+                                       return null;
+                               }
+                       }
+               }
+               
+               if (fCNComputed) return fCN;
+               
+               fCNComputed = true;
+
+               int offset = getParseOffset();
+               if (offset < 0) return null;
+               
+               ICProject proj= getProject();
+               if (proj == null) return null;
+               
+               try {
+                       IIndexManager manager= CCorePlugin.getIndexManager();
+                       fIndex = manager.getIndex(proj, IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT);
+
+                       try {
+                               fIndex.acquireReadLock();
+                       } catch (InterruptedException e) {
+                               fIndex = null;
+                       }
+
+                       boolean parseNonIndexed= CUIPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREF_USE_STRUCTURAL_PARSE_MODE);
+                       int flags = parseNonIndexed ? ITranslationUnit.AST_SKIP_INDEXED_HEADERS : ITranslationUnit.AST_SKIP_ALL_HEADERS;
+                       flags |= ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT;
+                       
+                       fCN = fTU.getCompletionNode(fIndex, flags, offset);
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }
+               
+               return fCN;
+       }
+       
+       public int getParseOffset() {
+               if (!fParseOffsetComputed) {
+                       fParseOffsetComputed= true;
+                       fContextInfoPosition= guessContextInformationPosition();
+                       if (fIsCompletion) {
+                               fParseOffset = guessCompletionPosition(getInvocationOffset());
+                       } else if (fContextInfoPosition > 0) {
+                               fParseOffset = guessCompletionPosition(fContextInfoPosition);
+                       } else {
+                               fParseOffset = -1;
+                       }
+               }
+               
+               return fParseOffset;
+       }
+
+       /**
+        * @return the offset where context information (parameter hints) starts.
+        */
+       public int getContextInformationOffset() {
+               getParseOffset();
+               return fContextInfoPosition;
+       }
+       
+       /**
+        * Try to find a sensible completion position backwards in case the given offset
+        * is inside a function call argument list.
+        * 
+        * @param contextPosition  the starting position
+        * @return a sensible completion offset
+        */
+       protected int guessCompletionPosition(int contextPosition) {
+               CHeuristicScanner scanner= new CHeuristicScanner(getDocument());
+               int bound= Math.max(-1, contextPosition - 200);
+               
+               int pos= scanner.findNonWhitespaceBackward(contextPosition - 1, bound);
+               if (pos == CHeuristicScanner.NOT_FOUND) return contextPosition;
+               
+               int token= scanner.previousToken(pos, bound);
+               
+               if (token == Symbols.TokenCOMMA) {
+                       pos= scanner.findOpeningPeer(pos, bound, '(', ')');
+                       if (pos == CHeuristicScanner.NOT_FOUND) return contextPosition;
+                       
+                       token = scanner.previousToken(pos, bound);
+               }
+               
+               if (token == Symbols.TokenLPAREN) {
+                       pos= scanner.findNonWhitespaceBackward(pos - 1, bound);
+                       if (pos == CHeuristicScanner.NOT_FOUND) return contextPosition;
+                       
+                       token= scanner.previousToken(pos, bound);
+                       
+                       if (token == Symbols.TokenGREATERTHAN) {
+                               // skip template arguments
+                               pos= scanner.findOpeningPeer(pos - 1, '<', '>');
+                               if (pos == CHeuristicScanner.NOT_FOUND) return contextPosition;
+                               pos= scanner.findNonWhitespaceBackward(pos - 1, bound);
+                               if (pos == CHeuristicScanner.NOT_FOUND) return contextPosition;
+                               token= scanner.previousToken(pos, bound);
+                       }
+                       
+                       if (token == Symbols.TokenIDENT) {
+                               return pos + 1;
+                       }
+               }
+               
+               return contextPosition;
+       }
+       
+       /**
+        * Try to find the smallest offset inside the opening parenthesis of a function call
+        * argument list.
+        * 
+        * @return the offset of the function call parenthesis plus 1 or -1 if the invocation
+        *     offset is not inside a function call (or similar)
+        */
+       protected int guessContextInformationPosition() {
+               final int contextPosition= getInvocationOffset();
+               
+               CHeuristicScanner scanner= new CHeuristicScanner(getDocument());
+               int bound= Math.max(-1, contextPosition - 200);
+               
+               // try the innermost scope of parentheses that looks like a method call
+               int pos= contextPosition - 1;
+               do {
+                       int paren= scanner.findOpeningPeer(pos, bound, '(', ')');
+                       if (paren == CHeuristicScanner.NOT_FOUND)
+                               break;
+                       int token= scanner.previousToken(paren - 1, bound);
+                       // next token must be a method name (identifier) or the closing angle of a
+                       // constructor call of a template type.
+                       if (token == Symbols.TokenIDENT || token == Symbols.TokenGREATERTHAN) {
+                               return paren + 1;
+                       }
+                       pos= paren - 1;
+               } while (true);
+               
+               return -1;
+       }
+       
+       /**
+        * Get the editor content assist is invoked in.
+        * 
+        * @return the editor, may be <code>null</code>
+        */
+       public IEditorPart getEditor() {
+               return fEditor;
+       }
+
+       public boolean isContextInformationStyle() {
+               return !fIsCompletion || (getParseOffset() != getInvocationOffset());
+       }
+       
+       public boolean isAutoActivated() {
+               return fIsAutoActivated;
+       }
+
+       @Override
+       public void dispose() {
+               if (fIndex != null) {
+                       fIndex.releaseReadLock();
+               }
+               super.dispose();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistProcessor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistProcessor.java
new file mode 100644 (file)
index 0000000..1d6e057
--- /dev/null
@@ -0,0 +1,387 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Bryan Wilkinson (QNX)
+ *     Markus Schorn (Wind River Systems)
+ *     Kirk Beitz (Nokia)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.contentassist;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.InvalidRegistryObjectException;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ContentAssistant;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.contentassist.IContextInformationValidator;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.ui.IEditorPart;
+
+import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IPointerType;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.ICCompletionProposal;
+import org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext;
+import org.eclipse.cdt.ui.text.contentassist.IProposalFilter;
+
+import org.eclipse.cdt.internal.ui.preferences.ProposalFilterPreferencesUtil;
+import org.eclipse.cdt.internal.ui.text.CHeuristicScanner;
+import org.eclipse.cdt.internal.ui.text.CParameterListValidator;
+import org.eclipse.cdt.internal.ui.text.Symbols;
+
+/**
+ * C/C++ content assist processor.
+ */
+public class CContentAssistProcessor extends ContentAssistProcessor {
+
+       private static class ActivationSet {
+               private final String theSet;
+
+               ActivationSet(String s) {
+                       theSet = s;
+               }
+
+               boolean contains(char c) {
+                       return -1 != theSet.indexOf(c);
+               }
+       }
+       
+       /**
+        * A wrapper for {@link ICompetionProposal}s.
+        */
+       private static class CCompletionProposalWrapper implements ICCompletionProposal {
+               private ICompletionProposal fWrappedProposal;
+
+               public CCompletionProposalWrapper(ICompletionProposal proposal) {
+                       fWrappedProposal= proposal;
+               }
+
+               /*
+                * @see org.eclipse.cdt.ui.text.ICCompletionProposal#getIdString()
+                */
+               public String getIdString() {
+                       return fWrappedProposal.getDisplayString();
+               }
+
+               /*
+                * @see org.eclipse.cdt.ui.text.ICCompletionProposal#getRelevance()
+                */
+               public int getRelevance() {
+                       return RelevanceConstants.CASE_MATCH_RELEVANCE + RelevanceConstants.KEYWORD_TYPE_RELEVANCE;
+               }
+
+               /*
+                * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument)
+                */
+               public void apply(IDocument document) {
+                       throw new UnsupportedOperationException();
+               }
+
+               /*
+                * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo()
+                */
+               public String getAdditionalProposalInfo() {
+                       return fWrappedProposal.getAdditionalProposalInfo();
+               }
+
+               /*
+                * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getContextInformation()
+                */
+               public IContextInformation getContextInformation() {
+                       return fWrappedProposal.getContextInformation();
+               }
+
+               /*
+                * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
+                */
+               public String getDisplayString() {
+                       return fWrappedProposal.getDisplayString();
+               }
+
+               /*
+                * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage()
+                */
+               public Image getImage() {
+                       return fWrappedProposal.getImage();
+               }
+
+               /*
+                * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getSelection(org.eclipse.jface.text.IDocument)
+                */
+               public Point getSelection(IDocument document) {
+                       return fWrappedProposal.getSelection(document);
+               }
+
+               /**
+                * @return the original proposal
+                */
+               public ICompletionProposal unwrap() {
+                       return fWrappedProposal;
+               }
+       }
+
+       private ActivationSet fReplacementAutoActivationCharacters;
+       private ActivationSet fCContentAutoActivationCharacters;
+       private IContextInformationValidator fValidator;
+       private final IEditorPart fEditor;
+
+       public CContentAssistProcessor(IEditorPart editor, ContentAssistant assistant, String partition) {
+               super(assistant, partition);
+               fEditor= editor;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationValidator()
+        */
+       @Override
+       public IContextInformationValidator getContextInformationValidator() {
+               if (fValidator == null) {
+                       fValidator= new CParameterListValidator();
+               }
+               return fValidator;
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistProcessor#filterAndSort(List, IProgressMonitor)
+        */
+       @Override
+       protected List<ICompletionProposal> filterAndSortProposals(List<ICompletionProposal> proposals,
+                       IProgressMonitor monitor, ContentAssistInvocationContext context) {
+               IProposalFilter filter = getCompletionFilter();
+               ICCompletionProposal[] proposalsInput= new ICCompletionProposal[proposals.size()];
+               // wrap proposals which are no ICCompletionProposals
+               boolean wrapped= false;
+               int i= 0;
+               for (ICompletionProposal proposal : proposals) {
+                       if (proposal instanceof ICCompletionProposal) {
+                               proposalsInput[i++]= (ICCompletionProposal)proposal;
+                       } else {
+                               wrapped= true;
+                               proposalsInput[i++]= new CCompletionProposalWrapper(proposal);
+                       }
+               }
+               // filter
+               ICCompletionProposal[] proposalsFiltered = filter.filterProposals(proposalsInput);
+
+               // sort
+               boolean sortByAlphabet= CUIPlugin.getDefault().getPreferenceStore().getBoolean(ContentAssistPreference.ORDER_PROPOSALS);
+               if (sortByAlphabet) {
+                       // already sorted alphabetically by DefaultProposalFilter
+                       // in case of custom proposal filter, keep ordering applied by filter
+               } else {
+                       // sort by relevance
+                       CCompletionProposalComparator propsComp= new CCompletionProposalComparator();
+                       propsComp.setOrderAlphabetically(sortByAlphabet);
+                       Arrays.sort(proposalsFiltered, propsComp);
+               }
+               List<ICompletionProposal> filteredList;
+               if (wrapped) {
+                       // unwrap again
+                       filteredList= new ArrayList<ICompletionProposal>(proposalsFiltered.length);
+                       for (ICCompletionProposal proposal : proposalsFiltered) {
+                               if (proposal instanceof CCompletionProposalWrapper) {
+                                       filteredList.add(((CCompletionProposalWrapper)proposal).unwrap());
+                               } else {
+                                       filteredList.add(proposal);
+                               }
+                       }
+               } else {
+                       final ICompletionProposal[] tmp= proposalsFiltered;
+                       filteredList= Arrays.asList(tmp);
+               }
+               return filteredList;
+       }
+
+       private IProposalFilter getCompletionFilter() {
+               IProposalFilter filter = null;
+               try {
+                       IConfigurationElement filterElement = ProposalFilterPreferencesUtil.getPreferredFilterElement();
+                       if (null != filterElement) {
+                               Object contribObject = filterElement.createExecutableExtension("class"); //$NON-NLS-1$
+                               if ((contribObject instanceof IProposalFilter)) {
+                                       filter = (IProposalFilter) contribObject;
+                               }
+                       }
+               } catch (InvalidRegistryObjectException e) {
+                       // No action required since we will be using the fail-safe default filter
+                       CUIPlugin.log(e);
+               } catch (CoreException e) {
+                       // No action required since we will be using the fail-safe default filter
+                       CUIPlugin.log(e);
+               }
+
+               if (filter == null) {
+                       // fail-safe default implementation
+                       filter = new DefaultProposalFilter();
+               }
+               return filter;
+       }
+       
+       @Override
+       protected List<IContextInformation> filterAndSortContextInformation(List<IContextInformation> contexts,
+                       IProgressMonitor monitor) {
+               return contexts;
+       }
+
+       /**
+        * Establishes this processor's set of characters checked after
+        * auto-activation to determine if auto-replacement correction
+        * is to occur.
+        * <p>
+        * This set is a (possibly complete) subset of the set established by
+        * {@link ContentAssistProcessor#setCompletionProposalAutoActivationCharacters},
+        * which is the set of characters used to initially trigger auto-activation
+        * for any content-assist operations, including this.  (<i>And while the
+        * name setCompletionProposalAutoActivationCharacters may now be a bit
+        * misleading, it is part of an API implementation called by jface.</i>)
+        *
+        * @param activationSet the activation set
+        */
+       public void setReplacementAutoActivationCharacters(String activationSet) {
+               fReplacementAutoActivationCharacters= new ActivationSet(activationSet);
+       }
+
+       /**
+        * Establishes this processor's set of characters checked after
+        * auto-activation and any auto-correction to determine if completion
+        * proposal computation is to proceed.
+        * <p>
+        * This set is a (possibly complete) subset of the set established by
+        * {@link ContentAssistProcessor#setCompletionProposalAutoActivationCharacters},
+        * which is the set of characters used to initially trigger auto-activation
+        * for any content-assist operations, including this.  (<i>And while the
+        * name setCompletionProposalAutoActivationCharacters may now be a bit
+        * misleading, it is part of an API implementation called by jface.</i>)
+        *
+        * @param activationSet the activation set
+        */
+       public void setCContentAutoActivationCharacters(String activationSet) {
+               fCContentAutoActivationCharacters= new ActivationSet(activationSet);
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistProcessor#createContext(org.eclipse.jface.text.ITextViewer, int)
+        */
+       @Override
+       protected ContentAssistInvocationContext createContext(ITextViewer viewer, int offset, boolean isCompletion) {
+               char activationChar = getActivationChar(viewer, offset);
+               CContentAssistInvocationContext context =
+                               new CContentAssistInvocationContext(viewer, offset, fEditor, isCompletion, isAutoActivated());
+               if (isCompletion && activationChar == '.' && fReplacementAutoActivationCharacters != null &&
+                               fReplacementAutoActivationCharacters.contains('.')) {
+                       IASTCompletionNode node = context.getCompletionNode();
+                       if (node != null) {
+                               IASTName[] names = node.getNames();
+                               if (names.length > 0 && names[0].getParent() instanceof IASTFieldReference) {
+                                       IASTFieldReference ref = (IASTFieldReference) names[0].getParent();
+                                       IASTExpression ownerExpr = ref.getFieldOwner();
+                                       if (ownerExpr.getExpressionType() instanceof IPointerType) {
+                                               context = replaceDotWithArrow(viewer, offset, isCompletion, context, activationChar);
+                                       }
+                               }
+                       }
+                       if (context != null && isAutoActivated() && !fCContentAutoActivationCharacters.contains(activationChar)) {
+                               // auto-replace, but not auto-content-assist - bug 344387
+                               context.dispose();
+                               context = null;
+                       }
+               }
+
+               return context;
+       }
+
+       private CContentAssistInvocationContext replaceDotWithArrow(ITextViewer viewer, int offset,
+                       boolean isCompletion, CContentAssistInvocationContext context, char activationChar) {
+               IDocument doc = viewer.getDocument();
+               try {
+                       doc.replace(offset - 1, 1, "->"); //$NON-NLS-1$
+                       context.dispose();
+                       context = null;
+                       // if user turned on activation only for replacement characters,
+                       // setting the context to null will skip the proposals popup later
+                       if (!isAutoActivated() || fCContentAutoActivationCharacters.contains(activationChar)) {
+                               context = new CContentAssistInvocationContext(viewer, offset + 1, fEditor,
+                                               isCompletion, isAutoActivated());
+                       }
+               } catch (BadLocationException e) {
+                       // ignore
+               }
+               return context;
+       }
+
+       /**
+        * Get the character preceding the content assist activation offset.
+        * @param viewer 
+        * @param offset
+        * @return the activation character
+        */
+       private char getActivationChar(ITextViewer viewer, int offset) {
+               IDocument doc= viewer.getDocument();
+               if (doc == null) {
+                       return 0;
+               }
+               if (offset <= 0) {
+                       return 0;
+               }
+               try {
+                       return doc.getChar(offset - 1);
+               } catch (BadLocationException e) {
+               }
+               return 0;
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistProcessor#verifyAutoActivation(org.eclipse.jface.text.ITextViewer, int)
+        */
+       @Override
+       protected boolean verifyAutoActivation(ITextViewer viewer, int offset) {
+               IDocument doc= viewer.getDocument();
+               if (doc == null) {
+                       return false;
+               }
+               if (offset <= 0) {
+                       return false;
+               }
+               try {
+                       char activationChar= doc.getChar(--offset);
+                       switch (activationChar) {
+                       case ':':
+                               return offset > 0 && doc.getChar(--offset) == ':';
+                       case '>':
+                               return offset > 0 && doc.getChar(--offset) == '-';
+                       case '.':
+                               // avoid completion of float literals
+                               CHeuristicScanner scanner= new CHeuristicScanner(doc);
+                               int token= scanner.previousToken(--offset, Math.max(0, offset - 200));
+                               // the scanner reports numbers as identifiers
+                               if (token == Symbols.TokenIDENT && !Character.isJavaIdentifierStart(doc.getChar(scanner.getPosition() + 1))) {
+                                       // not a valid identifier
+                                       return false;
+                               }
+                               return true;
+                       }
+               } catch (BadLocationException e) {
+               }
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CProposalContextInformation.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CProposalContextInformation.java
new file mode 100644 (file)
index 0000000..2b6743e
--- /dev/null
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corp. - Rational Software - initial implementation
+ *******************************************************************************/
+/*
+ * Created on May 6, 2004
+ */
+package org.eclipse.cdt.internal.ui.text.contentassist;
+
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.contentassist.IContextInformationExtension;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * @author aniefer
+ */
+public class CProposalContextInformation implements IContextInformation, IContextInformationExtension {
+       /** The name of the context */
+       private String fContextDisplayString;
+       /** The information to be displayed */
+       private String fInformationDisplayString;
+       /** The position to display the information */
+       private int fInformationPosition;
+       /** The image to be displayed */
+       private Image fImage;
+
+       /**
+        * Creates a new context information without an image.
+        *
+        * @param contextDisplayString the string to be used when presenting the context
+        * @param informationDisplayString the string to be displayed when presenting the context information
+        */
+       public CProposalContextInformation(String contextDisplayString, String informationDisplayString) {
+               this(null, contextDisplayString, informationDisplayString);
+       }
+
+       /**
+        * Creates a new context information with an image.
+        *
+        * @param image the image to display when presenting the context information
+        * @param contextDisplayString the string to be used when presenting the context
+        * @param informationDisplayString the string to be displayed when presenting the context information,
+        *              may not be <code>null</code>
+        */
+       public CProposalContextInformation(Image image, String contextDisplayString, String informationDisplayString) {
+               //Assert.isNotNull(informationDisplayString);
+               fImage= image;
+               fContextDisplayString= contextDisplayString;
+               fInformationDisplayString= informationDisplayString;
+       }
+
+       /*
+        * @see IContextInformation#equals(Object)
+        */
+       @Override
+       public boolean equals(Object object) {
+               if (object instanceof IContextInformation) {
+                       IContextInformation contextInformation= (IContextInformation) object;
+                       boolean equals= fInformationDisplayString.equalsIgnoreCase(contextInformation.getInformationDisplayString());
+                       if (fContextDisplayString != null) 
+                               equals= equals && fContextDisplayString.equalsIgnoreCase(contextInformation.getContextDisplayString());
+                       return equals;
+               }
+               return false;
+       }
+       
+       /*
+        * @see IContextInformation#getInformationDisplayString()
+        */
+       public String getInformationDisplayString() {
+               return fInformationDisplayString;
+       }
+       
+       /*
+        * @see IContextInformation#getImage()
+        */
+       public Image getImage() {
+               return fImage;
+       }
+       
+       /*
+        * @see IContextInformation#getContextDisplayString()
+        */
+       public String getContextDisplayString() {
+               if (fContextDisplayString != null)
+                       return fContextDisplayString;
+               return fInformationDisplayString;
+       }
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.text.contentassist.IContextInformationExtension#getContextInformationPosition()
+        */
+       public int getContextInformationPosition() {
+               return fInformationPosition;
+       }
+       
+       public void setContextInformationPosition( int pos ){
+               fInformationPosition = pos;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalCategory.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalCategory.java
new file mode 100644 (file)
index 0000000..81c1cdf
--- /dev/null
@@ -0,0 +1,327 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.contentassist;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.action.LegacyActionTools;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.osgi.framework.Bundle;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext;
+import org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer;
+
+import org.eclipse.cdt.internal.ui.util.Messages;
+
+/**
+ * Describes a category extension to the "completionProposalComputer" extension point.
+ * 
+ * @since 4.0
+ */
+public final class CompletionProposalCategory {
+       /** The extension schema name of the icon attribute. */
+       private static final String ICON= "icon"; //$NON-NLS-1$
+
+       private final String fId;
+       private final String fName;
+       private final IConfigurationElement fElement;
+       /** The image descriptor for this category, or <code>null</code> if none specified. */
+       private final ImageDescriptor fImage;
+       
+       private boolean fIsSeparateCommand= true;
+       private boolean fIsEnabled= true;
+       private boolean fIsIncluded= true;
+       private final CompletionProposalComputerRegistry fRegistry;
+       
+       private int fSortOrder= 0x10000;
+       private String fLastError= null;
+
+       CompletionProposalCategory(IConfigurationElement element, CompletionProposalComputerRegistry registry) throws CoreException {
+               fElement= element;
+               fRegistry= registry;
+               IExtension parent= (IExtension) element.getParent();
+               fId= parent.getUniqueIdentifier();
+               checkNotNull(fId, "id"); //$NON-NLS-1$
+               String name= parent.getLabel();
+               if (name == null)
+                       fName= fId;
+               else
+                       fName= name;
+               
+               String icon= element.getAttribute(ICON);
+               ImageDescriptor img= null;
+               if (icon != null) {
+                       Bundle bundle= getBundle();
+                       if (bundle != null) {
+                               Path path= new Path(icon);
+                               URL url= FileLocator.find(bundle, path, null);
+                               img= ImageDescriptor.createFromURL(url);
+                       }
+               }
+               fImage= img;
+
+       }
+
+       CompletionProposalCategory(String id, String name, CompletionProposalComputerRegistry registry) {
+               fRegistry= registry;
+               fId= id;
+               fName= name;
+               fElement= null;
+               fImage= null;
+       }
+
+       private Bundle getBundle() {
+               String namespace= fElement.getDeclaringExtension().getContributor().getName();
+               Bundle bundle= Platform.getBundle(namespace);
+               return bundle;
+       }
+
+       /**
+        * Checks that the given attribute value is not <code>null</code>.
+        *
+        * @param value the element to be checked
+        * @param attribute the attribute
+        * @throws CoreException if <code>value</code> is <code>null</code>
+        */
+       private void checkNotNull(Object obj, String attribute) throws CoreException {
+               if (obj == null) {
+                       Object[] args= { getId(), fElement.getContributor().getName(), attribute };
+                       String message= Messages.format(ContentAssistMessages.CompletionProposalComputerDescriptor_illegal_attribute_message, args);
+                       IStatus status= new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, message, null);
+                       CUIPlugin.log(status);
+                       throw new CoreException(status);
+               }
+       }
+
+       /**
+        * Returns the identifier of the described extension.
+        *
+        * @return Returns the id
+        */
+       public String getId() {
+               return fId;
+       }
+
+       /**
+        * Returns the name of the described extension.
+        * 
+        * @return Returns the name
+        */
+       public String getName() {
+               return fName;
+       }
+       
+       /**
+        * Returns the name of the described extension
+        * without mnemonic hint in order to be displayed
+        * in a message.
+        * 
+        * @return Returns the name
+        */
+       public String getDisplayName() {
+               return LegacyActionTools.removeMnemonics(fName);
+       }
+       
+       /**
+        * Returns the image descriptor of the described category.
+        * 
+        * @return the image descriptor of the described category
+        */
+       public ImageDescriptor getImageDescriptor() {
+               return fImage;
+       }
+       
+       /**
+        * Sets the separate command state of the category.
+        * 
+        * @param enabled the new enabled state.
+        */
+       public void setSeparateCommand(boolean enabled) {
+               fIsSeparateCommand= enabled;
+       }
+       
+       /**
+        * Returns the enablement state of the category.
+        * 
+        * @return the enablement state of the category
+        */
+       public boolean isSeparateCommand() {
+               return fIsSeparateCommand;
+       }
+       
+       /**
+        * @param included the included
+        */
+       public void setIncluded(boolean included) {
+               fIsIncluded= included;
+       }
+       
+       /**
+        * @return included
+        */
+       public boolean isIncluded() {
+               return fIsIncluded;
+       }
+
+       public boolean isEnabled() {
+               return fIsEnabled;
+       }
+
+       public void setEnabled(boolean isEnabled) {
+               fIsEnabled= isEnabled;
+       }
+
+       /**
+        * Returns <code>true</code> if the category contains any computers, <code>false</code>
+        * otherwise.
+        * 
+        * @return <code>true</code> if the category contains any computers, <code>false</code>
+        *         otherwise
+        */
+       public boolean hasComputers() {
+               List<CompletionProposalComputerDescriptor> descriptors= fRegistry.getProposalComputerDescriptors();
+               for (CompletionProposalComputerDescriptor desc : descriptors) {
+                       if (desc.getCategory() == this)
+                               return true;
+               }
+               return false;
+       }
+       
+       /**
+        * Returns <code>true</code> if the category contains any computers in the given partition, <code>false</code>
+        * otherwise.
+        * 
+        * @param partition the partition
+        * @return <code>true</code> if the category contains any computers, <code>false</code>
+        *         otherwise
+        */
+       public boolean hasComputers(String partition) {
+               List<CompletionProposalComputerDescriptor> descriptors= fRegistry.getProposalComputerDescriptors(partition);
+               for (CompletionProposalComputerDescriptor desc : descriptors) {
+                       if (desc.getCategory() == this)
+                               return true;
+               }
+               return false;
+       }
+       
+       /**
+        * @return sortOrder
+        */
+       public int getSortOrder() {
+               return fSortOrder;
+       }
+       
+       /**
+        * @param sortOrder the sortOrder
+        */
+       public void setSortOrder(int sortOrder) {
+               fSortOrder= sortOrder;
+       }
+
+       /**
+        * Safely computes completion proposals of all computers of this category through their
+        * extension. If an extension is disabled, throws an exception or otherwise does not adhere to
+        * the contract described in {@link ICompletionProposalComputer}, it is disabled.
+        * 
+        * @param context the invocation context passed on to the extension
+        * @param partition the partition type where to invocation occurred
+        * @param monitor the progress monitor passed on to the extension
+        * @return the list of computed completion proposals (element type:
+        *         {@link org.eclipse.jface.text.contentassist.ICompletionProposal})
+        */
+       public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, String partition, SubProgressMonitor monitor) {
+               fLastError= null;
+               List<ICompletionProposal> result= new ArrayList<ICompletionProposal>();
+               List<CompletionProposalComputerDescriptor> descriptors= new ArrayList<CompletionProposalComputerDescriptor>(fRegistry.getProposalComputerDescriptors(partition));
+               for (CompletionProposalComputerDescriptor desc : descriptors) {
+                       if (desc.getCategory() == this)
+                               result.addAll(desc.computeCompletionProposals(context, monitor));
+                       if (fLastError == null)
+                               fLastError= desc.getErrorMessage();
+               }
+               return result;
+       }
+
+       /**
+        * Safely computes context information objects of all computers of this category through their
+        * extension. If an extension is disabled, throws an exception or otherwise does not adhere to
+        * the contract described in {@link ICompletionProposalComputer}, it is disabled.
+        * 
+        * @param context the invocation context passed on to the extension
+        * @param partition the partition type where to invocation occurred
+        * @param monitor the progress monitor passed on to the extension
+        * @return the list of computed context information objects (element type:
+        *         {@link org.eclipse.jface.text.contentassist.IContextInformation})
+        */
+       public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, String partition, SubProgressMonitor monitor) {
+               fLastError= null;
+               List<IContextInformation> result= new ArrayList<IContextInformation>();
+               List<CompletionProposalComputerDescriptor> descriptors= new ArrayList<CompletionProposalComputerDescriptor>(fRegistry.getProposalComputerDescriptors(partition));
+               for (CompletionProposalComputerDescriptor desc : descriptors) {
+                       if (desc.getCategory() == this)
+                               result.addAll(desc.computeContextInformation(context, monitor));
+                       if (fLastError == null)
+                               fLastError= desc.getErrorMessage();
+               }
+               return result;
+       }
+
+       /**
+        * Returns the error message from the computers in this category.
+        * 
+        * @return the error message from the computers in this category
+        */
+       public String getErrorMessage() {
+               return fLastError;
+       }
+
+       /**
+        * Notifies the computers in this category of a proposal computation session start.
+        */
+       public void sessionStarted() {
+               List<CompletionProposalComputerDescriptor> descriptors= new ArrayList<CompletionProposalComputerDescriptor>(fRegistry.getProposalComputerDescriptors());
+               for (CompletionProposalComputerDescriptor desc : descriptors) {
+                       if (desc.getCategory() == this)
+                               desc.sessionStarted();
+                       if (fLastError == null)
+                               fLastError= desc.getErrorMessage();
+               }
+       }
+       
+       /**
+        * Notifies the computers in this category of a proposal computation session end.
+        */
+       public void sessionEnded() {
+               List<CompletionProposalComputerDescriptor> descriptors= new ArrayList<CompletionProposalComputerDescriptor>(fRegistry.getProposalComputerDescriptors());
+               for (CompletionProposalComputerDescriptor desc : descriptors) {
+                       if (desc.getCategory() == this)
+                               desc.sessionEnded();
+                       if (fLastError == null)
+                               fLastError= desc.getErrorMessage();
+               }
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerDescriptor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerDescriptor.java
new file mode 100644 (file)
index 0000000..7bfe8c7
--- /dev/null
@@ -0,0 +1,549 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.contentassist;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IContributor;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.InvalidRegistryObjectException;
+import org.eclipse.core.runtime.PerformanceStats;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.osgi.framework.Bundle;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.ICPartitions;
+import org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext;
+import org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer;
+
+import org.eclipse.cdt.internal.ui.util.Messages;
+
+/**
+ * The description of an extension to the
+ * <code>org.eclipse.cdt.ui.completionProposalComputer</code> extension point. Instances are
+ * immutable. Instances can be obtained from a {@link CompletionProposalComputerRegistry}.
+ * 
+ * @see CompletionProposalComputerRegistry
+ * @since 4.0
+ */
+final class CompletionProposalComputerDescriptor {
+       /** The default category id. */
+       private static final String DEFAULT_CATEGORY_ID= "org.eclipse.cdt.ui.defaultProposalCategory"; //$NON-NLS-1$
+       /** The extension schema name of the category id attribute. */
+       private static final String CATEGORY_ID= "categoryId"; //$NON-NLS-1$
+       /** The extension schema name of the partition type attribute. */
+       private static final String TYPE= "type"; //$NON-NLS-1$
+       /** The extension schema name of the class attribute. */
+       private static final String CLASS= "class"; //$NON-NLS-1$
+       /** The extension schema name of the activate attribute. */
+       private static final String ACTIVATE= "activate"; //$NON-NLS-1$
+       /** The extension schema name of the partition child elements. */
+       private static final String PARTITION= "partition"; //$NON-NLS-1$
+       /** Set of Java partition types. */
+       private static final Set<String> PARTITION_SET;
+       /** The name of the performance event used to trace extensions. */
+       private static final String PERFORMANCE_EVENT= CUIPlugin.getPluginId() + "/perf/content_assist/extensions"; //$NON-NLS-1$
+       /**
+        * If <code>true</code>, execution time of extensions is measured and the data forwarded to
+        * core's {@link PerformanceStats} service.
+        */
+       private static final boolean MEASURE_PERFORMANCE= PerformanceStats.isEnabled(PERFORMANCE_EVENT);
+       /**
+        * Independently of the {@link PerformanceStats} service, any operation that takes longer than
+        * {@value} milliseconds will be flagged as an violation. This timeout does not apply to the
+        * first invocation, as it may take longer due to plug-in initialization etc. See also
+        * {@link #fIsReportingDelay}.
+        */
+       private static final long MAX_DELAY= 5000;
+       
+       /* log constants */
+       private static final String COMPUTE_COMPLETION_PROPOSALS= "computeCompletionProposals()"; //$NON-NLS-1$
+       private static final String COMPUTE_CONTEXT_INFORMATION= "computeContextInformation()"; //$NON-NLS-1$
+       private static final String SESSION_STARTED= "sessionStarted()"; //$NON-NLS-1$
+       private static final String SESSION_ENDED= "sessionEnded()"; //$NON-NLS-1$
+       
+       static {
+               Set<String> partitions= new HashSet<String>();
+               partitions.add(IDocument.DEFAULT_CONTENT_TYPE);
+               partitions.addAll(Arrays.asList(ICPartitions.ALL_CPARTITIONS));
+               
+               PARTITION_SET= Collections.unmodifiableSet(partitions);
+       }
+
+       /** The identifier of the extension. */
+       private final String fId;
+       /** The name of the extension. */
+       private final String fName;
+       /** The class name of the provided <code>IJavaCompletionProposalComputer</code>. */
+       private final String fClass;
+       /** The activate attribute value. */
+       private final boolean fActivate;
+       /** The partition of the extension (element type: {@link String}). */
+       private final Set<String> fPartitions;
+       /** The configuration element of this extension. */
+       private final IConfigurationElement fElement;
+       /** The registry we are registered with. */
+       private final CompletionProposalComputerRegistry fRegistry;
+       /** The computer, if instantiated, <code>null</code> otherwise. */
+       private ICompletionProposalComputer fComputer;
+       /** The ui category. */
+       private final CompletionProposalCategory fCategory;
+       /** The first error message in the most recent operation, or <code>null</code>. */
+       private String fLastError;
+       /**
+        * Tells whether to inform the user when <code>MAX_DELAY</code> has been exceeded.
+        * We start timing execution after the first session because the first may take
+        * longer due to plug-in activation and initialization.
+        */
+       private boolean fIsReportingDelay= false;
+       /** The start of the last operation. */
+       private long fStart;
+
+       /**
+        * Creates a new descriptor.
+        * 
+        * @param element the configuration element to read
+        * @param registry the computer registry creating this descriptor
+        * @param categories the categories
+        * @throws InvalidRegistryObjectException if this extension is no longer valid
+        * @throws CoreException if the configuration element is invalid
+        */
+       CompletionProposalComputerDescriptor(IConfigurationElement element, CompletionProposalComputerRegistry registry, List<CompletionProposalCategory> categories) throws InvalidRegistryObjectException, CoreException {
+               Assert.isNotNull(registry);
+               Assert.isNotNull(element);
+               
+               fRegistry= registry;
+               fElement= element;
+               IExtension extension= element.getDeclaringExtension();
+               fId= extension.getUniqueIdentifier();
+               checkNotNull(fId, "id"); //$NON-NLS-1$
+
+               String name= extension.getLabel();
+               if (name.length() == 0)
+                       fName= fId;
+               else
+                       fName= name;
+               
+               Set<String> partitions= new HashSet<String>();
+               IConfigurationElement[] children= element.getChildren(PARTITION);
+               if (children.length == 0) {
+                       fPartitions= PARTITION_SET; // add to all partition types if no partition is configured
+               } else {
+                       for (IConfigurationElement element2 : children) {
+                               String type= element2.getAttribute(TYPE);
+                               checkNotNull(type, TYPE);
+                               partitions.add(type);
+                       }
+                       fPartitions= Collections.unmodifiableSet(partitions);
+               }
+               
+               String activateAttribute= element.getAttribute(ACTIVATE);
+               fActivate= Boolean.valueOf(activateAttribute).booleanValue();
+
+               fClass= element.getAttribute(CLASS);
+               checkNotNull(fClass, CLASS);
+               
+               String categoryId= element.getAttribute(CATEGORY_ID);
+               if (categoryId == null)
+                       categoryId= DEFAULT_CATEGORY_ID;
+               CompletionProposalCategory category= null;
+               for (CompletionProposalCategory cat : categories) {
+                       if (cat.getId().equals(categoryId)) {
+                               category= cat;
+                               break;
+                       }
+               }
+               if (category == null) {
+                       // create a category if it does not exist
+                       fCategory= new CompletionProposalCategory(categoryId, fName, registry);
+                       categories.add(fCategory);
+               } else {
+                       fCategory= category;
+               }
+       }
+
+       /**
+        * Checks that the given attribute value is not <code>null</code>.
+        *
+        * @param value the element to be checked
+        * @param attribute the attribute
+        * @throws CoreException if <code>value</code> is <code>null</code>
+        */
+       private void checkNotNull(Object obj, String attribute) throws CoreException {
+               if (obj == null) {
+                       Object[] args= { getId(), fElement.getContributor().getName(), attribute };
+                       String message= Messages.format(ContentAssistMessages.CompletionProposalComputerDescriptor_illegal_attribute_message, args);
+                       IStatus status= new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, message, null);
+                       CUIPlugin.log(status);
+                       throw new CoreException(status);
+               }
+       }
+
+       /**
+        * Returns the identifier of the described extension.
+        *
+        * @return Returns the id
+        */
+       public String getId() {
+               return fId;
+       }
+
+       /**
+        * Returns the name of the described extension.
+        * 
+        * @return Returns the name
+        */
+       public String getName() {
+               return fName;
+       }
+       
+       /**
+        * Returns the partition types of the described extension.
+        * 
+        * @return the set of partition types (element type: {@link String})
+        */
+       public Set<String> getPartitions() {
+               return fPartitions;
+       }
+       
+       /**
+        * Returns a cached instance of the computer as described in the
+        * extension's xml. The computer is
+        * {@link #createComputer() created} the first time that this method
+        * is called and then cached.
+        * 
+        * @return a new instance of the completion proposal computer as
+        *         described by this descriptor
+        * @throws CoreException if the creation fails
+        * @throws InvalidRegistryObjectException if the extension is not
+        *         valid any longer (e.g. due to plug-in unloading)
+        */
+       private synchronized ICompletionProposalComputer getComputer() throws CoreException, InvalidRegistryObjectException {
+               if (fComputer == null && (fActivate || isPluginLoaded()))
+                       fComputer= createComputer();
+               return fComputer;
+       }
+
+       private boolean isPluginLoaded() {
+               Bundle bundle= getBundle();
+               return bundle != null && bundle.getState() == Bundle.ACTIVE;
+       }
+
+       private Bundle getBundle() {
+               String namespace= fElement.getDeclaringExtension().getContributor().getName();
+               Bundle bundle= Platform.getBundle(namespace);
+               return bundle;
+       }
+
+       /**
+        * Returns a new instance of the computer as described in the
+        * extension's xml. Note that the safest way to access the computer
+        * is by using the {@linkplain #computeCompletionProposals}
+        * and {@linkplain #computeContextInformation}
+        * methods. These delegate the functionality to the contributed
+        * computer, but handle instance creation and any exceptions thrown.
+        * 
+        * @return a new instance of the completion proposal computer as
+        *         described by this descriptor
+        * @throws CoreException if the creation fails
+        * @throws InvalidRegistryObjectException if the extension is not
+        *         valid any longer (e.g. due to plug-in unloading)
+        */
+       public ICompletionProposalComputer createComputer() throws CoreException, InvalidRegistryObjectException {
+               return (ICompletionProposalComputer) fElement.createExecutableExtension(CLASS);
+       }
+       
+       /**
+        * Safely computes completion proposals through the described extension. If the extension
+        * is disabled, throws an exception or otherwise does not adhere to the contract described in
+        * {@link ICompletionProposalComputer}, an empty list is returned.
+        * 
+        * @param context the invocation context passed on to the extension
+        * @param monitor the progress monitor passed on to the extension
+        * @return the list of computed completion proposals (element type:
+        *         {@link org.eclipse.jface.text.contentassist.ICompletionProposal})
+        */
+       public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+               if (!isEnabled())
+                       return Collections.emptyList();
+
+               IStatus status;
+               try {
+                       ICompletionProposalComputer computer= getComputer();
+                       if (computer == null) // not active yet
+                               return Collections.emptyList();
+                       
+                       try {
+                               PerformanceStats stats= startMeter(context, computer);
+                               List<ICompletionProposal> proposals= computer.computeCompletionProposals(context, monitor);
+                               stopMeter(stats, COMPUTE_COMPLETION_PROPOSALS);
+                               
+                               if (proposals != null) {
+                                       fLastError= computer.getErrorMessage();
+                                       return proposals;
+                               }
+                       } finally {
+                               fIsReportingDelay= true;
+                       }
+                       status= createAPIViolationStatus(COMPUTE_COMPLETION_PROPOSALS);
+               } catch (InvalidRegistryObjectException x) {
+                       status= createExceptionStatus(x);
+               } catch (CoreException x) {
+                       status= createExceptionStatus(x);
+               } catch (RuntimeException x) {
+                       status= createExceptionStatus(x);
+               } finally {
+                       monitor.done();
+               }
+
+               fRegistry.informUser(this, status);
+
+               return Collections.emptyList();
+       }
+
+       /**
+        * Safely computes context information objects through the described extension. If the extension
+        * is disabled, throws an exception or otherwise does not adhere to the contract described in
+        * {@link ICompletionProposalComputer}, an empty list is returned.
+        * 
+        * @param context the invocation context passed on to the extension
+        * @param monitor the progress monitor passed on to the extension
+        * @return the list of computed context information objects (element type:
+        *         {@link org.eclipse.jface.text.contentassist.IContextInformation})
+        */
+       public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+               if (!isEnabled())
+                       return Collections.emptyList();
+               
+               IStatus status;
+               try {
+                       ICompletionProposalComputer computer= getComputer();
+                       if (computer == null) // not active yet
+                               return Collections.emptyList();
+
+                       PerformanceStats stats= startMeter(context, computer);
+                       List<IContextInformation> proposals= computer.computeContextInformation(context, monitor);
+                       stopMeter(stats, COMPUTE_CONTEXT_INFORMATION);
+                       
+                       if (proposals != null) {
+                               fLastError= computer.getErrorMessage();
+                               return proposals;
+                       }
+                       
+                       status= createAPIViolationStatus(COMPUTE_CONTEXT_INFORMATION);
+               } catch (InvalidRegistryObjectException x) {
+                       status= createExceptionStatus(x);
+               } catch (CoreException x) {
+                       status= createExceptionStatus(x);
+               } catch (RuntimeException x) {
+                       status= createExceptionStatus(x);
+               } finally {
+                       monitor.done();
+               }
+               
+               fRegistry.informUser(this, status);
+               
+               return Collections.emptyList();
+       }
+       
+
+       /**
+        * Notifies the described extension of a proposal computation session start.
+        * <p><em>
+        * Note: This method is called every time code assist is invoked and
+        * is <strong>not</strong> filtered by partition type.
+        * </em></p>
+        */
+       public void sessionStarted() {
+               if (!isEnabled())
+                       return;
+               
+               IStatus status;
+               try {
+                       ICompletionProposalComputer computer= getComputer();
+                       if (computer == null) // not active yet
+                               return;
+                       
+                       PerformanceStats stats= startMeter(SESSION_STARTED, computer);
+                       computer.sessionStarted();
+                       stopMeter(stats, SESSION_ENDED);
+                       
+                       return;
+               } catch (InvalidRegistryObjectException x) {
+                       status= createExceptionStatus(x);
+               } catch (CoreException x) {
+                       status= createExceptionStatus(x);
+               } catch (RuntimeException x) {
+                       status= createExceptionStatus(x);
+               }
+               
+               fRegistry.informUser(this, status);
+       }
+
+       /**
+        * Notifies the described extension of a proposal computation session end.
+        * <p><em>
+        * Note: This method is called every time code assist is invoked and
+        * is <strong>not</strong> filtered by partition type.
+        * </em></p>
+        */
+       public void sessionEnded() {
+               if (!isEnabled())
+                       return;
+
+               IStatus status;
+               try {
+                       ICompletionProposalComputer computer= getComputer();
+                       if (computer == null) // not active yet
+                               return;
+
+                       PerformanceStats stats= startMeter(SESSION_ENDED, computer);
+                       computer.sessionEnded();
+                       stopMeter(stats, SESSION_ENDED);
+
+                       return;
+               } catch (InvalidRegistryObjectException x) {
+                       status= createExceptionStatus(x);
+               } catch (CoreException x) {
+                       status= createExceptionStatus(x);
+               } catch (RuntimeException x) {
+                       status= createExceptionStatus(x);
+               }
+
+               fRegistry.informUser(this, status);
+       }
+
+       private PerformanceStats startMeter(Object context, ICompletionProposalComputer computer) {
+               final PerformanceStats stats;
+               if (MEASURE_PERFORMANCE) {
+                       stats= PerformanceStats.getStats(PERFORMANCE_EVENT, computer);
+                       stats.startRun(context.toString());
+               } else {
+                       stats= null;
+               }
+               
+               if (fIsReportingDelay) {
+                       fStart= System.currentTimeMillis();
+               }
+               
+               return stats;
+       }
+
+       private void stopMeter(final PerformanceStats stats, String operation) {
+               if (MEASURE_PERFORMANCE) {
+                       stats.endRun();
+                       if (stats.isFailure()) {
+                               IStatus status= createPerformanceStatus(operation);
+                               fRegistry.informUser(this, status);
+                               return;
+                       }
+               }
+               
+               if (fIsReportingDelay) {
+                       long current= System.currentTimeMillis();
+                       if (current - fStart > MAX_DELAY) {
+                               IStatus status= createPerformanceStatus(operation);
+                               fRegistry.informUser(this, status);
+                       }
+               }
+       }
+
+       private IStatus createExceptionStatus(InvalidRegistryObjectException x) {
+               // extension has become invalid - log & disable
+               String blame= createBlameMessage();
+               String reason= ContentAssistMessages.CompletionProposalComputerDescriptor_reason_invalid;
+               return new Status(IStatus.INFO, CUIPlugin.getPluginId(), IStatus.OK, blame + " " + reason, x); //$NON-NLS-1$
+       }
+
+       private IStatus createExceptionStatus(CoreException x) {
+               // unable to instantiate the extension - log & disable
+               String blame= createBlameMessage();
+               String reason= ContentAssistMessages.CompletionProposalComputerDescriptor_reason_instantiation;
+               return new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK, blame + " " + reason, x); //$NON-NLS-1$
+       }
+       
+       private IStatus createExceptionStatus(RuntimeException x) {
+               // misbehaving extension - log & disable
+               String blame= createBlameMessage();
+               String reason= ContentAssistMessages.CompletionProposalComputerDescriptor_reason_runtime_ex;
+               return new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, blame + " " + reason, x); //$NON-NLS-1$
+       }
+
+       private IStatus createAPIViolationStatus(String operation) {
+               String blame= createBlameMessage();
+               Object[] args= {operation};
+               String reason= Messages.format(ContentAssistMessages.CompletionProposalComputerDescriptor_reason_API, args);
+               return new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, blame + " " + reason, null); //$NON-NLS-1$
+       }
+
+       private IStatus createPerformanceStatus(String operation) {
+               String blame= createBlameMessage();
+               Object[] args= {operation};
+               String reason= Messages.format(ContentAssistMessages.CompletionProposalComputerDescriptor_reason_performance, args);
+               return new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, blame + " " + reason, null); //$NON-NLS-1$
+       }
+
+       private String createBlameMessage() {
+               Object[] args= { getName(), fElement.getDeclaringExtension().getContributor().getName() };
+               String disable= Messages.format(ContentAssistMessages.CompletionProposalComputerDescriptor_blame_message, args);
+               return disable;
+       }
+       
+       /**
+        * Returns the enablement state of the described extension.
+        * 
+        * @return the enablement state of the described extension
+        */
+       private boolean isEnabled() {
+               return fCategory.isEnabled();
+       }
+       
+       CompletionProposalCategory getCategory() {
+               return fCategory;
+       }
+
+       /**
+        * Returns the error message from the described extension.
+        * 
+        * @return the error message from the described extension
+        */
+       public String getErrorMessage() {
+               return fLastError;
+       }
+
+       /**
+        * Returns the contributor of the described extension.
+        * 
+        * @return the contributor of the described extension
+        */
+    IContributor getContributor()  {
+        try {
+               return fElement.getContributor();
+        } catch (InvalidRegistryObjectException e) {
+               return null;
+        }          
+    }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerRegistry.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerRegistry.java
new file mode 100644 (file)
index 0000000..2414437
--- /dev/null
@@ -0,0 +1,396 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.contentassist;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IContributor;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+import org.eclipse.cdt.internal.ui.util.Messages;
+
+/**
+ * A registry for all extensions to the
+ * <code>org.eclipse.cdt.ui.completionProposalComputer</code>
+ * extension point.
+ * 
+ * @since 4.0
+ */
+public final class CompletionProposalComputerRegistry {
+
+       private static final String EXTENSION_POINT= "completionProposalComputer"; //$NON-NLS-1$
+       
+       /** The singleton instance. */
+       private static CompletionProposalComputerRegistry fgSingleton= null;
+       
+       /**
+        * Returns the default computer registry.
+        * <p>
+        * TODO keep this or add some other singleton, e.g. CUIPlugin?
+        * </p>
+        * 
+        * @return the singleton instance
+        */
+       public static synchronized CompletionProposalComputerRegistry getDefault() {
+               if (fgSingleton == null) {
+                       fgSingleton= new CompletionProposalComputerRegistry();
+               }
+               
+               return fgSingleton;
+       }
+       
+       /**
+        * The sets of descriptors, grouped by partition type (key type:
+        * {@link String}, value type:
+        * {@linkplain List List&lt;CompletionProposalComputerDescriptor&gt;}).
+        */
+       private final Map<String, List<CompletionProposalComputerDescriptor>> fDescriptorsByPartition= new HashMap<String, List<CompletionProposalComputerDescriptor>>();
+       /**
+        * Unmodifiable versions of the sets stored in
+        * <code>fDescriptorsByPartition</code> (key type: {@link String},
+        * value type:
+        * {@linkplain List List&lt;CompletionProposalComputerDescriptor&gt;}).
+        */
+       private final Map<String, List<CompletionProposalComputerDescriptor>> fPublicDescriptorsByPartition= new HashMap<String, List<CompletionProposalComputerDescriptor>>();
+       /**
+        * All descriptors (element type:
+        * {@link CompletionProposalComputerDescriptor}).
+        */
+       private final List<CompletionProposalComputerDescriptor> fDescriptors= new ArrayList<CompletionProposalComputerDescriptor>();
+       /**
+        * Unmodifiable view of <code>fDescriptors</code>
+        */
+       private final List<CompletionProposalComputerDescriptor> fPublicDescriptors= Collections.unmodifiableList(fDescriptors);
+       
+       private final List<CompletionProposalCategory> fCategories= new ArrayList<CompletionProposalCategory>();
+       private final List<CompletionProposalCategory> fPublicCategories= Collections.unmodifiableList(fCategories);
+       /**
+        * <code>true</code> if this registry has been loaded.
+        */
+       private boolean fLoaded= false;
+
+       /**
+        * Creates a new instance.
+        */
+       public CompletionProposalComputerRegistry() {
+       }
+
+       /**
+        * Returns the list of {@link CompletionProposalComputerDescriptor}s describing all extensions
+        * to the <code>completionProposalComputer</code> extension point for the given partition
+        * type.
+        * <p>
+        * A valid partition is either one of the constants defined in
+        * {@link org.eclipse.cdt.ui.text.ICPartitions} or
+        * {@link org.eclipse.jface.text.IDocument#DEFAULT_CONTENT_TYPE}. An empty list is returned if
+        * there are no extensions for the given partition.
+        * </p>
+        * <p>
+        * The returned list is read-only and is sorted in the order that the extensions were read in.
+        * There are no duplicate elements in the returned list. The returned list may change if plug-ins
+        * are loaded or unloaded while the application is running or if an extension violates the API
+        * contract of {@link org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer}. When
+        * computing proposals, it is therefore imperative to copy the returned list before iterating
+        * over it.
+        * </p>
+        * 
+        * @param partition
+        *        the partition type for which to retrieve the computer descriptors
+        * @return the list of extensions to the <code>completionProposalComputer</code> extension
+        *         point (element type: {@link CompletionProposalComputerDescriptor})
+        */
+       List<CompletionProposalComputerDescriptor> getProposalComputerDescriptors(String partition) {
+               ensureExtensionPointRead();
+               List<CompletionProposalComputerDescriptor> result= fPublicDescriptorsByPartition.get(partition);
+               if (result == null) 
+                       return Collections.emptyList();
+               return result;
+       }
+
+       /**
+        * Returns the list of {@link CompletionProposalComputerDescriptor}s describing all extensions
+        * to the <code>completionProposalComputer</code> extension point.
+        * <p>
+        * The returned list is read-only and is sorted in the order that the extensions were read in.
+        * There are no duplicate elements in the returned list. The returned list may change if plug-ins
+        * are loaded or unloaded while the application is running or if an extension violates the API
+        * contract of {@link org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer}. When
+        * computing proposals, it is therefore imperative to copy the returned list before iterating
+        * over it.
+        * </p>
+        * 
+        * @return the list of extensions to the <code>completionProposalComputer</code> extension
+        *         point (element type: {@link CompletionProposalComputerDescriptor})
+        */
+       List<CompletionProposalComputerDescriptor> getProposalComputerDescriptors() {
+               ensureExtensionPointRead();
+               return fPublicDescriptors;
+       }
+       
+       /**
+        * Returns the list of proposal categories contributed to the
+        * <code>completionProposalComputer</code> extension point.
+        * <p>
+        * <p>
+        * The returned list is read-only and is sorted in the order that the extensions were read in.
+        * There are no duplicate elements in the returned list. The returned list may change if
+        * plug-ins are loaded or unloaded while the application is running.
+        * </p>
+        * 
+        * @return list of proposal categories contributed to the
+        *         <code>completionProposalComputer</code> extension point (element type:
+        *         {@link CompletionProposalCategory})
+        */
+       public List<CompletionProposalCategory> getProposalCategories() {
+               ensureExtensionPointRead();
+               return fPublicCategories;
+       }
+
+       /**
+        * Ensures that the extensions are read and stored in
+        * <code>fDescriptorsByPartition</code>.
+        */
+       private void ensureExtensionPointRead() {
+               boolean reload;
+               synchronized (this) {
+                       reload= !fLoaded;
+                       fLoaded= true;
+               }
+               if (reload)
+                       reload();
+       }
+
+       /**
+        * Reloads the extensions to the extension point.
+        * <p>
+        * This method can be called more than once in order to reload from
+        * a changed extension registry.
+        * </p>
+        */
+       public void reload() {
+               IExtensionRegistry registry= Platform.getExtensionRegistry();
+               List<IConfigurationElement> elements= new ArrayList<IConfigurationElement>(Arrays.asList(registry.getConfigurationElementsFor(CUIPlugin.getPluginId(), EXTENSION_POINT)));
+               
+               Map<String, List<CompletionProposalComputerDescriptor>> map= new HashMap<String, List<CompletionProposalComputerDescriptor>>();
+               List<CompletionProposalComputerDescriptor> all= new ArrayList<CompletionProposalComputerDescriptor>();
+               
+               List<CompletionProposalCategory> categories= getCategories(elements);
+               for (IConfigurationElement element : elements) {
+                       try {
+                               CompletionProposalComputerDescriptor desc= new CompletionProposalComputerDescriptor(element, this, categories);
+                               Set<String> partitions= desc.getPartitions();
+                               for (Object element2 : partitions) {
+                                       String partition= (String) element2;
+                                       List<CompletionProposalComputerDescriptor> list= map.get(partition);
+                                       if (list == null) {
+                                               list= new ArrayList<CompletionProposalComputerDescriptor>();
+                                               map.put(partition, list);
+                                       }
+                                       list.add(desc);
+                               }
+                               all.add(desc);
+                               
+                       } catch (CoreException x) {
+                               /*
+                                * Element is not valid any longer as the contributing plug-in was unloaded or for
+                                * some other reason. Do not include the extension in the list and inform the user
+                                * about it.
+                                */
+                               Object[] args= {element.toString()};
+                               String message= Messages.format(ContentAssistMessages.CompletionProposalComputerRegistry_invalid_message, args);
+                               IStatus status= new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, message, x);
+                               informUser(status);
+                       }
+               }
+               
+               synchronized (this) {
+                       fCategories.clear();
+                       fCategories.addAll(categories);
+                       
+                       Set<String> partitions= map.keySet();
+                       fDescriptorsByPartition.keySet().retainAll(partitions);
+                       fPublicDescriptorsByPartition.keySet().retainAll(partitions);
+                       for (String partition : partitions) {
+                               List<CompletionProposalComputerDescriptor> old= fDescriptorsByPartition.get(partition);
+                               List<CompletionProposalComputerDescriptor> current= map.get(partition);
+                               if (old != null) {
+                                       old.clear();
+                                       old.addAll(current);
+                               } else {
+                                       fDescriptorsByPartition.put(partition, current);
+                                       fPublicDescriptorsByPartition.put(partition, Collections.unmodifiableList(current));
+                               }
+                       }
+                       
+                       fDescriptors.clear();
+                       fDescriptors.addAll(all);
+               }
+       }
+
+       private List<CompletionProposalCategory> getCategories(List<IConfigurationElement> elements) {
+               IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+               String preference= store.getString(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
+               Set<String> disabled= new HashSet<String>();
+               StringTokenizer tok= new StringTokenizer(preference, "\0");  //$NON-NLS-1$
+               while (tok.hasMoreTokens())
+                       disabled.add(tok.nextToken());
+               Map<String, Integer> ordered= new HashMap<String, Integer>();
+               preference= store.getString(PreferenceConstants.CODEASSIST_CATEGORY_ORDER);
+               tok= new StringTokenizer(preference, "\0"); //$NON-NLS-1$
+               while (tok.hasMoreTokens()) {
+                       StringTokenizer inner= new StringTokenizer(tok.nextToken(), ":"); //$NON-NLS-1$
+                       String id= inner.nextToken();
+                       int rank= Integer.parseInt(inner.nextToken());
+                       ordered.put(id, new Integer(rank));
+               }
+               
+               List<CompletionProposalCategory> categories= new ArrayList<CompletionProposalCategory>();
+               for (Iterator<IConfigurationElement> iter= elements.iterator(); iter.hasNext();) {
+                       IConfigurationElement element= iter.next();
+                       try {
+                               if (element.getName().equals("proposalCategory")) { //$NON-NLS-1$
+                                       iter.remove(); // remove from list to leave only computers
+                                       
+                                       CompletionProposalCategory category= new CompletionProposalCategory(element, this);
+                                       categories.add(category);
+                                       category.setIncluded(!disabled.contains(category.getId()));
+                                       Integer rank= ordered.get(category.getId());
+                                       if (rank != null) {
+                                               int r= rank.intValue();
+                                               boolean separate= r < 0xffff;
+                                               category.setSeparateCommand(separate);
+                                               category.setSortOrder(r);
+                                       }
+                               }
+                       } catch (CoreException x) {
+                               /*
+                                * Element is not valid any longer as the contributing plug-in was unloaded or for
+                                * some other reason. Do not include the extension in the list and inform the user
+                                * about it.
+                                */
+                               Object[] args= {element.toString()};
+                               String message= Messages.format(ContentAssistMessages.CompletionProposalComputerRegistry_invalid_message, args);
+                               IStatus status= new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, message, x);
+                               informUser(status);
+                       }
+               }
+               return categories;
+       }
+
+       /**
+        * Log the status and inform the user about a misbehaving extension.
+        * 
+        * @param descriptor the descriptor of the misbehaving extension
+        * @param status a status object that will be logged
+        */
+       void informUser(CompletionProposalComputerDescriptor descriptor, IStatus status) {
+               CUIPlugin.log(status);
+        String title= ContentAssistMessages.CompletionProposalComputerRegistry_error_dialog_title;
+        CompletionProposalCategory category= descriptor.getCategory();
+        IContributor culprit= descriptor.getContributor();
+        Set<String> affectedPlugins= getAffectedContributors(category, culprit);
+        
+               final String avoidHint;
+               final String culpritName= culprit == null ? null : culprit.getName();
+               if (affectedPlugins.isEmpty()) {
+                       if (CUIPlugin.PLUGIN_ID.equals(culpritName)) {
+                               // don't warn about internal computers
+                               return;
+                       }
+                       avoidHint= Messages.format(ContentAssistMessages.CompletionProposalComputerRegistry_messageAvoidanceHint, new Object[] {culpritName, category.getDisplayName()});
+               } else {
+                       avoidHint= Messages.format(ContentAssistMessages.CompletionProposalComputerRegistry_messageAvoidanceHintWithWarning, new Object[] {culpritName, category.getDisplayName(), toString(affectedPlugins)});
+               }        
+               String message= status.getMessage();
+        // inlined from MessageDialog.openError
+        MessageDialog dialog = new MessageDialog(CUIPlugin.getActiveWorkbenchShell(), title, null /* default image */, message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0) {
+               @Override
+                       protected Control createCustomArea(Composite parent) {
+                       Link link= new Link(parent, SWT.NONE);
+                       link.setText(avoidHint);
+                       link.addSelectionListener(new SelectionAdapter() {
+                               @Override
+                                       public void widgetSelected(SelectionEvent e) {
+                                       PreferencesUtil.createPreferenceDialogOn(getShell(), "org.eclipse.cdt.ui.preferences.CodeAssistPreferenceAdvanced", null, null).open(); //$NON-NLS-1$
+                               }
+                       });
+                       GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
+                       gridData.widthHint= this.getMinimumMessageWidth();
+                               link.setLayoutData(gridData);
+                       return link;
+               }
+        };
+        dialog.open();
+       }
+
+       /**
+        * Returns the names of contributors affected by disabling a category. 
+        * 
+        * @param category the category that would be disabled
+        * @param culprit the culprit plug-in, which is not included in the returned list
+        * @return the names of the contributors other than <code>culprit</code> that contribute to <code>category</code> (element type: {@link String})
+        */
+       private Set<String> getAffectedContributors(CompletionProposalCategory category, IContributor culprit) {
+           Set<String> affectedPlugins= new HashSet<String>();
+        for (CompletionProposalComputerDescriptor desc : getProposalComputerDescriptors()) {
+               CompletionProposalCategory cat= desc.getCategory();
+               if (cat.equals(category)) {
+                       IContributor contributor= desc.getContributor();
+                       if (contributor != null && !culprit.equals(contributor))
+                               affectedPlugins.add(contributor.getName());
+               }
+        }
+           return affectedPlugins;
+    }
+
+    private Object toString(Collection<String> collection) {
+       // strip brackets off AbstractCollection.toString()
+       String string= collection.toString();
+       return string.substring(1, string.length() - 1);
+    }
+
+       private void informUser(IStatus status) {
+               CUIPlugin.log(status);
+               String title= ContentAssistMessages.CompletionProposalComputerRegistry_error_dialog_title;
+               String message= status.getMessage();
+               MessageDialog.openError(CUIPlugin.getActiveWorkbenchShell(), title, message);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistComputerParameter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistComputerParameter.java
new file mode 100644 (file)
index 0000000..61a6190
--- /dev/null
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.contentassist;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.commands.IParameterValues;
+
+/**
+ * Map of parameters for the specific content assist command.
+ * 
+ * @since 4.0
+ */
+public final class ContentAssistComputerParameter implements IParameterValues {
+       /*
+        * @see org.eclipse.core.commands.IParameterValues#getParameterValues()
+        */
+       public Map<String,String> getParameterValues() {
+               Collection<CompletionProposalCategory> descriptors= CompletionProposalComputerRegistry.getDefault().getProposalCategories();
+               Map<String, String> map= new HashMap<String, String>(descriptors.size());
+               for (CompletionProposalCategory category : descriptors) {
+                       map.put(category.getDisplayName(), category.getId());
+               }
+               return map;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistHandler.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistHandler.java
new file mode 100644 (file)
index 0000000..8407387
--- /dev/null
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.contentassist;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.internal.ui.editor.SpecificContentAssistExecutor;
+
+/**
+ * A command handler to invoke a content assist for a specific proposal category.
+ * 
+ * @since 4.0
+ */
+public final class ContentAssistHandler extends AbstractHandler {
+       private final SpecificContentAssistExecutor fExecutor= new SpecificContentAssistExecutor(CompletionProposalComputerRegistry.getDefault());
+       
+       public ContentAssistHandler() {
+       }
+
+       /*
+        * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+        */
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               ITextEditor editor= getActiveEditor();
+               if (editor == null)
+                       return null;
+               
+               String categoryId= event.getParameter("org.eclipse.cdt.ui.specific_content_assist.category_id"); //$NON-NLS-1$
+               if (categoryId == null)
+                       return null;
+               
+               fExecutor.invokeContentAssist(editor, categoryId);
+
+               return null;
+       }
+
+       private ITextEditor getActiveEditor() {
+               IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+               if (window != null) {
+                       IWorkbenchPage page= window.getActivePage();
+                       if (page != null) {
+                               IEditorPart editor= page.getActiveEditor();
+                               if (editor instanceof ITextEditor)
+                                       return (ITextEditor) editor;
+                       }
+               }
+               return null;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistMessages.java
new file mode 100644 (file)
index 0000000..06754c5
--- /dev/null
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.contentassist;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Helper class to get NLSed messages.
+ */
+final class ContentAssistMessages extends NLS {
+
+       private static final String BUNDLE_NAME= ContentAssistMessages.class.getName();
+
+       static {
+               NLS.initializeMessages(BUNDLE_NAME, ContentAssistMessages.class);
+       }
+
+       private ContentAssistMessages() {
+               // Do not instantiate
+       }
+
+       public static String CompletionProposalComputerRegistry_messageAvoidanceHint;
+       public static String CompletionProposalComputerRegistry_messageAvoidanceHintWithWarning;
+       public static String ContentAssistProcessor_all_disabled_message;
+       public static String ContentAssistProcessor_all_disabled_preference_link;
+       public static String ContentAssistProcessor_all_disabled_title;
+       public static String ContentAssistProcessor_no_completions;
+       
+       public static String ContentAssistProcessor_computing_proposals;
+       public static String ContentAssistProcessor_collecting_proposals;
+       public static String ContentAssistProcessor_sorting_proposals;
+       public static String ContentAssistProcessor_computing_contexts;
+       public static String ContentAssistProcessor_collecting_contexts;
+       public static String ContentAssistProcessor_sorting_contexts;
+       public static String CompletionProposalComputerDescriptor_illegal_attribute_message;
+       public static String CompletionProposalComputerDescriptor_reason_invalid;
+       public static String CompletionProposalComputerDescriptor_reason_instantiation;
+       public static String CompletionProposalComputerDescriptor_reason_runtime_ex;
+       public static String CompletionProposalComputerDescriptor_reason_API;
+       public static String CompletionProposalComputerDescriptor_reason_performance;
+       public static String CompletionProposalComputerDescriptor_blame_message;
+       public static String CompletionProposalComputerRegistry_invalid_message;
+       public static String CompletionProposalComputerRegistry_error_dialog_title;
+       public static String ContentAssistProcessor_defaultProposalCategory;
+       public static String ContentAssistProcessor_toggle_affordance_press_gesture;
+       public static String ContentAssistProcessor_toggle_affordance_click_gesture;
+       public static String ContentAssistProcessor_toggle_affordance_update_message;
+       public static String ContentAssistProcessor_empty_message;
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistMessages.properties
new file mode 100644 (file)
index 0000000..dc5ba26
--- /dev/null
@@ -0,0 +1,52 @@
+###############################################################################
+# Copyright (c) 2000, 2008 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+#     Anton Leherbauer (Wind River Systems)
+###############################################################################
+
+CompletionProposalComputerRegistry_error_dialog_title=Problems During Content Assist
+# {0} is the plug-in id of the contributing plug-in, {1} the display name of the proposal category
+CompletionProposalComputerRegistry_messageAvoidanceHint=To avoid this message, disable the ''{0}'' plug-in or disable the ''{1}'' category on the <a>content assist</a> preference page.
+# {0} is the plug-in id of the contributing plug-in, {1} the display name of the proposal category, {2} the comma-separated list of plug-ins other than {0} the contribute to the category
+CompletionProposalComputerRegistry_messageAvoidanceHintWithWarning=To avoid this message, disable the ''{0}'' plug-in or disable the ''{1}'' category on the <a>content assist</a> preference page. Note that disabling the category will also affect completion proposals from the following plug-ins: {2}.
+# {0} is the extension id
+CompletionProposalComputerRegistry_invalid_message=The extension ''{0}'' has become invalid.
+
+CompletionProposalComputerDescriptor_reason_invalid=The extension has become invalid.
+CompletionProposalComputerDescriptor_reason_instantiation=Unable to instantiate the extension.
+CompletionProposalComputerDescriptor_reason_runtime_ex=The extension has thrown a runtime exception.
+# {0} specifies an operation name, e.g. "computeProposals"
+CompletionProposalComputerDescriptor_reason_API=The extension violated the API contract of the ''{0}'' operation.
+CompletionProposalComputerDescriptor_reason_performance=The extension took too long to return from the ''{0}'' operation.
+# {0} is the name of an extension, {1} the contributing plug-in name
+CompletionProposalComputerDescriptor_blame_message= The ''{0}'' proposal computer from the ''{1}'' plug-in did not complete normally.
+# {0} is the identifier of an extension, {1} the contributing plug-in, {2} a required but missing xml attribute
+CompletionProposalComputerDescriptor_illegal_attribute_message= The extension "{0}" from plug-in "{1}" did not specify a value for the required "{2}" attribute. Disabling the extension.
+
+ContentAssistProcessor_computing_proposals=Computing completion proposals
+ContentAssistProcessor_collecting_proposals=Collecting proposals
+ContentAssistProcessor_sorting_proposals=Sorting
+ContentAssistProcessor_computing_contexts=Computing context information
+ContentAssistProcessor_all_disabled_title=No Default Proposal Kinds
+ContentAssistProcessor_all_disabled_message=No proposal kinds are enabled for the 'default' content assist list.
+# {0} will be replaced by the label of the 'restore defaults' button
+# The preference page should match the title of the 'C/C++ > Editor > Content Assist > Advanced' preference page
+ContentAssistProcessor_all_disabled_preference_link=Change the settings on the <a>Advanced Content Assist preference page</a> or click ''{0}'' to restore the default behavior.
+ContentAssistProcessor_collecting_contexts=Collecting context information
+ContentAssistProcessor_sorting_contexts=Sorting
+ContentAssistProcessor_defaultProposalCategory=Default Proposals
+# {0} will be replaced by a keyboard shortcut (accelerator)
+ContentAssistProcessor_toggle_affordance_press_gesture=Press ''{0}''
+ContentAssistProcessor_toggle_affordance_click_gesture=Click
+# {0} will be replaced by a title describing the displayed proposal category, {1} by either the press_gesture or click_gesture message above, {2} by the name of the next proposal category 
+ContentAssistProcessor_toggle_affordance_update_message={1} to show {2}
+# {0} will be replaced by a title describing the displayed proposal category
+ContentAssistProcessor_empty_message= No {0}
+
+ContentAssistProcessor_no_completions=No completions available
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPreference.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPreference.java
new file mode 100644 (file)
index 0000000..2a0f050
--- /dev/null
@@ -0,0 +1,316 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2011 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Kirk Beitz (Nokia)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.contentassist;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.ContentAssistant;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.IColorManager;
+
+import org.eclipse.cdt.internal.core.parser.util.ContentAssistMatcherFactory;
+
+import org.eclipse.cdt.internal.ui.text.CTextTools;
+
+
+
+public class ContentAssistPreference {
+       
+//     /** Preference key for content assist auto activation (unused) */
+//     public final static String AUTOACTIVATION=  "content_assist_autoactivation";
+       /** Preference key for content assist auto activation delay */
+       public final static String AUTOACTIVATION_DELAY=  "content_assist_autoactivation_delay"; //$NON-NLS-1$
+       /** Preference key for content assist timeout delay (unused) */
+       public final static String TIMEOUT_DELAY=  "content_assist_timeout_delay"; //$NON-NLS-1$
+       /** Preference key for content assist proposal color */
+       public final static String PROPOSALS_FOREGROUND=  PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND;
+       /** Preference key for content assist proposal color */
+       public final static String PROPOSALS_BACKGROUND=  PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND;
+       /** Preference key for content assist parameters color */
+       public final static String PARAMETERS_FOREGROUND=  PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND;
+       /** Preference key for content assist parameters color */
+       public final static String PARAMETERS_BACKGROUND=  PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND;
+       /** Preference key for content assist auto insert */
+       public final static String AUTOINSERT=  "content_assist_autoinsert"; //$NON-NLS-1$
+       /** Preference key for content assist to insert the common prefix */
+       public final static String PREFIX_COMPLETION= "content_assist_prefix_completion"; //$NON-NLS-1$
+
+       /** Preference key for C/CPP content assist auto activation triggers */
+       public final static String AUTOACTIVATION_TRIGGERS_DOT= "content_assist_autoactivation_trigger_dot"; //$NON-NLS-1$
+       public final static String AUTOACTIVATION_TRIGGERS_ARROW= "content_assist_autoactivation_trigger_arrow"; //$NON-NLS-1$
+       public final static String AUTOACTIVATION_TRIGGERS_DOUBLECOLON= "content_assist_autoactivation_trigger_doublecolon"; //$NON-NLS-1$
+       public final static String AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW= "content_assist_autoactivation_trigger_replace_dot_with_arrow"; //$NON-NLS-1$
+//     /** Preference key for visibility of proposals (unused) */
+//     public final static String SHOW_DOCUMENTED_PROPOSALS= "content_assist_show_visible_proposals"; //$NON-NLS-1$
+       /** Preference key for alphabetic ordering of proposals */
+       public final static String ORDER_PROPOSALS= "content_assist_order_proposals"; //$NON-NLS-1$
+//     /** Preference key for case sensitivity of propsals */
+//     public final static String CASE_SENSITIVITY= "content_assist_case_sensitivity";
+//     /** Preference key for adding includes on code assist (unused) */
+//     public final static String ADD_INCLUDE= "content_assist_add_import";     //$NON-NLS-1$
+       /** Preference key for completion search scope (unused) */
+       public final static String CURRENT_FILE_SEARCH_SCOPE= "content_assist_current_file_search_scope";        //$NON-NLS-1$
+       /** Preference key for completion search scope (unused) */
+       public final static String PROJECT_SEARCH_SCOPE= "content_assist_project_search_scope";  //$NON-NLS-1$
+       /** Preference key for completion filtering */
+       public final static String PROPOSALS_FILTER= "content_assist_proposal_filter"; //$NON-NLS-1$
+       
+       /** Key for boolean preference telling whether camel case/underscore matches are to be shown by content assist features or not*/
+       public static final String SHOW_CAMEL_CASE_MATCHES = "contentAssist.showCamelCaseMatches"; //$NON-NLS-1$
+
+       private static Color getColor(IPreferenceStore store, String key, IColorManager manager) {
+               RGB rgb= PreferenceConverter.getColor(store, key);
+               return manager.getColor(rgb);
+       }
+       
+       private static Color getColor(IPreferenceStore store, String key) {
+               CTextTools textTools= CUIPlugin.getDefault().getTextTools();
+               return getColor(store, key, textTools.getColorManager());
+       }
+       
+       private static CContentAssistProcessor getCProcessor(ContentAssistant assistant) {
+               IContentAssistProcessor p= assistant.getContentAssistProcessor(IDocument.DEFAULT_CONTENT_TYPE);
+               if (p instanceof CContentAssistProcessor)
+                       return  (CContentAssistProcessor) p;
+               return null;
+       }
+       
+       private static void configureCProcessor(ContentAssistant assistant, IPreferenceStore store) {
+               CContentAssistProcessor ccp= getCProcessor(assistant);
+               if (ccp == null)
+                       return;
+               configureActivationCharacters(store, ccp);
+
+//             boolean enabled;
+//             enabled= store.getBoolean(SHOW_DOCUMENTED_PROPOSALS);
+//             ccp.restrictProposalsToVisibility(enabled);
+//
+//             enabled= store.getBoolean(CASE_SENSITIVITY);
+//             ccp.restrictProposalsToMatchingCases(enabled);
+               
+//             enabled= store.getBoolean(ORDER_PROPOSALS);
+//             ccp.orderProposalsAlphabetically(enabled);
+               
+//             enabled= store.getBoolean(ADD_INCLUDE);
+//             ccp.allowAddingIncludes(enabled);
+       }
+
+       private static void configureActivationCharacters(IPreferenceStore store, CContentAssistProcessor ccp) {
+               String triggers = ""; //$NON-NLS-1$
+               boolean useDotAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_DOT);
+               boolean useArrowAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_ARROW);
+               boolean useDoubleColonAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_DOUBLECOLON);
+
+               if (useDotAsTrigger)
+                       triggers = "."; //$NON-NLS-1$
+               if (useArrowAsTrigger)
+                       triggers += ">"; //$NON-NLS-1$
+               if (useDoubleColonAsTrigger)
+                       triggers += ":"; //$NON-NLS-1$
+               ccp.setCContentAutoActivationCharacters(triggers);
+
+               boolean dotTriggersAutoReplace = store.getBoolean(AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW);
+
+               // quick and dirty, since we only have one thing to replace
+               // if other replacement auto-activate triggers are added,
+               // triggers will have to be cleared and characters that share
+               // such as "." will have to be ||ed together.
+               if (!useDotAsTrigger && dotTriggersAutoReplace)
+                       triggers += "."; //$NON-NLS-1$
+               ccp.setCompletionProposalAutoActivationCharacters(triggers.toCharArray());
+
+               triggers = "";  //$NON-NLS-1$
+               if (dotTriggersAutoReplace)
+                       triggers = "."; //$NON-NLS-1$
+               ccp.setReplacementAutoActivationCharacters(triggers);
+       }
+
+       
+       /**
+        * Configure the given content assistant from the given store.
+        */
+       public static void configure(ContentAssistant assistant, IPreferenceStore store) {
+                       
+               CTextTools textTools= CUIPlugin.getDefault().getTextTools();
+               IColorManager manager= textTools.getColorManager();
+               
+               boolean enabledDot= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOT);
+               boolean enabledArrow= store.getBoolean(AUTOACTIVATION_TRIGGERS_ARROW);
+               boolean enabledDoubleColon= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOUBLECOLON);
+               boolean enabledReplaceDotWithArrow
+                       = store.getBoolean(AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW);
+
+               boolean enabled
+                       =  (enabledDot || enabledArrow || enabledDoubleColon
+                                       || enabledReplaceDotWithArrow);
+               assistant.enableAutoActivation(enabled);
+               
+               int delay= store.getInt(AUTOACTIVATION_DELAY);
+               assistant.setAutoActivationDelay(delay);
+               
+               Color c1= getColor(store, PROPOSALS_FOREGROUND, manager);
+               assistant.setProposalSelectorForeground(c1);
+               
+               Color c2= getColor(store, PROPOSALS_BACKGROUND, manager);
+               assistant.setProposalSelectorBackground(c2);
+               
+               Color c3= getColor(store, PARAMETERS_FOREGROUND, manager);
+               assistant.setContextInformationPopupForeground(c3);
+               assistant.setContextSelectorForeground(c3);
+               
+               Color c4= getColor(store, PARAMETERS_BACKGROUND, manager);
+               assistant.setContextInformationPopupBackground(c4);
+               assistant.setContextSelectorBackground(c4);
+               
+               enabled= store.getBoolean(AUTOINSERT);
+               assistant.enableAutoInsert(enabled);
+
+               enabled = store.getBoolean(PREFIX_COMPLETION);
+               assistant.enablePrefixCompletion(enabled);
+
+               configureCProcessor(assistant, store);
+       }
+       
+       
+       private static void changeCProcessor(ContentAssistant assistant, IPreferenceStore store, String key) {
+               CContentAssistProcessor ccp= getCProcessor(assistant);
+               if (ccp == null)
+                       return;
+                       
+               if ( (AUTOACTIVATION_TRIGGERS_DOT.equals(key))
+                    || (AUTOACTIVATION_TRIGGERS_ARROW.equals(key))
+                        || (AUTOACTIVATION_TRIGGERS_DOUBLECOLON.equals(key)) 
+                        || (AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW.equals(key))){
+                       configureActivationCharacters(store, ccp);
+               }
+//             else if (SHOW_DOCUMENTED_PROPOSALS.equals(key)) {
+//                     boolean enabled= store.getBoolean(SHOW_DOCUMENTED_PROPOSALS);
+//                     ccp.restrictProposalsToVisibility(enabled);
+//             }
+//             else if (CASE_SENSITIVITY.equals(key)) {
+//                     boolean enabled= store.getBoolean(CASE_SENSITIVITY);
+//                     ccp.restrictProposalsToMatchingCases(enabled);
+//             }
+//             else if (ORDER_PROPOSALS.equals(key)) {
+//                     boolean enable= store.getBoolean(ORDER_PROPOSALS);
+//                     ccp.orderProposalsAlphabetically(enable);
+//             } else if (ADD_INCLUDE.equals(key)) {
+//                     boolean enabled= store.getBoolean(ADD_INCLUDE);
+//                     ccp.allowAddingIncludes(enabled);
+//             }
+       }
+       
+       /**
+        * Changes the configuration of the given content assistant according to the given property
+        * change event and the given preference store.
+        */
+       public static void changeConfiguration(ContentAssistant assistant, IPreferenceStore store, PropertyChangeEvent event) {
+               
+               String p= event.getProperty();
+               
+               if ((AUTOACTIVATION_TRIGGERS_DOT.equals(p))
+                       || (AUTOACTIVATION_TRIGGERS_ARROW.equals(p))
+                       || (AUTOACTIVATION_TRIGGERS_DOUBLECOLON.equals(p))
+                       || (AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW.equals(p))){
+                       boolean enabledDot= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOT);
+                       boolean enabledArrow= store.getBoolean(AUTOACTIVATION_TRIGGERS_ARROW);
+                       boolean enabledDoubleColon= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOUBLECOLON);
+                       boolean enabledReplaceDotWithArrow= store.getBoolean(AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW);
+                       boolean enabled =  ((enabledDot) || ( enabledArrow ) || (enabledDoubleColon ) || (enabledReplaceDotWithArrow ));
+                       assistant.enableAutoActivation(enabled);
+
+               } else if (AUTOACTIVATION_DELAY.equals(p)) {
+                       int delay= store.getInt(AUTOACTIVATION_DELAY);
+                       assistant.setAutoActivationDelay(delay);
+               } else if (PROPOSALS_FOREGROUND.equals(p)) {
+                       Color c= getColor(store, PROPOSALS_FOREGROUND);
+                       assistant.setProposalSelectorForeground(c);
+               } else if (PROPOSALS_BACKGROUND.equals(p)) {
+                       Color c= getColor(store, PROPOSALS_BACKGROUND);
+                       assistant.setProposalSelectorBackground(c);
+               } else if (PARAMETERS_FOREGROUND.equals(p)) {
+                       Color c= getColor(store, PARAMETERS_FOREGROUND);
+                       assistant.setContextInformationPopupForeground(c);
+                       assistant.setContextSelectorForeground(c);
+               } else if (PARAMETERS_BACKGROUND.equals(p)) {
+                       Color c= getColor(store, PARAMETERS_BACKGROUND);
+                       assistant.setContextInformationPopupBackground(c);
+                       assistant.setContextSelectorBackground(c);
+               } else if (AUTOINSERT.equals(p)) {
+                       boolean enabled= store.getBoolean(AUTOINSERT);
+                       assistant.enableAutoInsert(enabled);
+               } else if (PREFIX_COMPLETION.equals(p)) {
+                       boolean enabled= store.getBoolean(PREFIX_COMPLETION);
+                       assistant.enablePrefixCompletion(enabled);
+               }
+               
+               changeCProcessor(assistant, store, p);
+       }
+       
+       private static ContentAssistPreference instance = null;
+       
+       private final IPropertyChangeListener propertyListener = new IPropertyChangeListener() {
+                       
+               public void propertyChange(PropertyChangeEvent event) {
+                       String prop = event.getProperty();
+                       if (prop.equals(ContentAssistPreference.SHOW_CAMEL_CASE_MATCHES)) {
+                               updateOnPreferences();
+                       }
+                       
+               }
+       };
+       
+       private ContentAssistPreference() {
+               getPreferences().addPropertyChangeListener(
+                               propertyListener);
+               updateOnPreferences();
+       }
+       
+       public static synchronized ContentAssistPreference getInstance() {
+               if (instance == null) {
+                       instance = new ContentAssistPreference();
+               }
+               
+               return instance;
+       }
+       
+       private static IPreferenceStore getPreferences() {
+               return CUIPlugin.getDefault().getPreferenceStore();
+       }
+       
+       private synchronized void updateOnPreferences() {
+               boolean showCamelCaseMatches = getPreferences().getBoolean(ContentAssistPreference.SHOW_CAMEL_CASE_MATCHES);
+               ContentAssistMatcherFactory.getInstance().setShowCamelCaseMatches(showCamelCaseMatches);
+       }
+       
+       private void shutdownInternal() {
+               getPreferences().removePropertyChangeListener(propertyListener);
+       }
+       
+       /**
+        * @noreference This method is not intended to be referenced by clients.
+        */
+       public static synchronized void shutdown() {
+               if (instance != null) {
+                       instance.shutdownInternal();
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistProcessor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistProcessor.java
new file mode 100644 (file)
index 0000000..57d83b0
--- /dev/null
@@ -0,0 +1,598 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Bryan Wilkinson (QNX)
+ *     Markus Schorn (Wind River Systems)
+ *     Kirk Beitz (Nokia)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.contentassist;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.action.LegacyActionTools;
+import org.eclipse.jface.bindings.TriggerSequence;
+import org.eclipse.jface.bindings.keys.KeySequence;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ContentAssistEvent;
+import org.eclipse.jface.text.contentassist.ContentAssistant;
+import org.eclipse.jface.text.contentassist.ICompletionListener;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.text.contentassist.IContentAssistantExtension2;
+import org.eclipse.jface.text.contentassist.IContentAssistantExtension3;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.contentassist.IContextInformationValidator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.eclipse.ui.keys.IBindingService;
+import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext;
+
+import org.eclipse.cdt.internal.ui.dialogs.OptionalMessageDialog;
+import org.eclipse.cdt.internal.ui.util.Messages;
+
+/**
+ * A content assist processor that aggregates the proposals of the
+ * {@link org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer}s contributed via the
+ * <code>org.eclipse.cdt.ui.completionProposalComputer</code> extension point.
+ * <p>
+ * Subclasses may extend:
+ * <ul>
+ * <li><code>createContext</code> to provide the context object passed to the computers</li>
+ * <li><code>createProgressMonitor</code> to change the way progress is reported</li>
+ * <li><code>filterAndSort</code> to add sorting and filtering</li>
+ * <li><code>getContextInformationValidator</code> to add context validation (needed if any
+ * contexts are provided)</li>
+ * <li><code>getErrorMessage</code> to change error reporting</li>
+ * </ul>
+ * </p>
+ * 
+ * @since 4.0
+ */
+public class ContentAssistProcessor implements IContentAssistProcessor {
+       private static final boolean DEBUG= "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.cdt.ui/debug/ResultCollector"));  //$NON-NLS-1$//$NON-NLS-2$
+
+       /**
+        * Dialog settings key for the "all categories are disabled" warning dialog. See
+        * {@link OptionalMessageDialog}.
+        */
+       private static final String PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY= "EmptyDefaultAssistCategory"; //$NON-NLS-1$
+
+       private static final Comparator<CompletionProposalCategory> ORDER_COMPARATOR= new Comparator<CompletionProposalCategory>() {
+
+               public int compare(CompletionProposalCategory d1, CompletionProposalCategory d2) {
+                       return d1.getSortOrder() - d2.getSortOrder();
+               }
+               
+       };
+
+       private static final ICompletionProposal[] NO_PROPOSALS= {};
+       
+       private final List<CompletionProposalCategory> fCategories;
+       private final String fPartition;
+       private final ContentAssistant fAssistant;
+       
+       private char[] fCompletionAutoActivationCharacters;
+       
+       /* cycling stuff */
+       private int fRepetition= -1;
+       private List<List<CompletionProposalCategory>> fCategoryIteration= null;
+       private String fIterationGesture= null;
+       private int fNumberOfComputedResults= 0;
+       private String fErrorMessage;
+       private boolean fIsAutoActivated;
+
+       public ContentAssistProcessor(ContentAssistant assistant, String partition) {
+               Assert.isNotNull(partition);
+               Assert.isNotNull(assistant);
+               fPartition= partition;
+               fCategories= CompletionProposalComputerRegistry.getDefault().getProposalCategories();
+               fAssistant= assistant;
+               fAssistant.addCompletionListener(new ICompletionListener() {
+                       
+                       /*
+                        * @see org.eclipse.jface.text.contentassist.ICompletionListener#assistSessionStarted(org.eclipse.jface.text.contentassist.ContentAssistEvent)
+                        */
+                       public void assistSessionStarted(ContentAssistEvent event) {
+                               if (event.processor != ContentAssistProcessor.this)
+                                       return;
+
+                               fIsAutoActivated= event.isAutoActivated;
+                               fIterationGesture= getIterationGesture();
+                               KeySequence binding= getIterationBinding();
+
+                               // this may show the warning dialog if all categories are disabled
+                               fCategoryIteration= getCategoryIteration();
+                               for (Object element : fCategories) {
+                                       CompletionProposalCategory cat= (CompletionProposalCategory) element;
+                                       cat.sessionStarted();
+                               }
+                               
+                               fRepetition= 0;
+                               if (event.assistant instanceof IContentAssistantExtension2) {
+                                       IContentAssistantExtension2 extension= (IContentAssistantExtension2) event.assistant;
+
+                                       if (fCategoryIteration.size() == 1) {
+                                               extension.setRepeatedInvocationMode(false);
+                                               extension.setShowEmptyList(false);
+                                       } else {
+                                               extension.setRepeatedInvocationMode(true);
+                                               extension.setStatusLineVisible(true);
+                                               extension.setStatusMessage(createIterationMessage());
+                                               extension.setShowEmptyList(true);
+                                               if (extension instanceof IContentAssistantExtension3) {
+                                                       IContentAssistantExtension3 ext3= (IContentAssistantExtension3) extension;
+                                                       ((ContentAssistant) ext3).setRepeatedInvocationTrigger(binding);
+                                               }
+                                       }
+                               
+                               }
+                       }
+                       
+                       /*
+                        * @see org.eclipse.jface.text.contentassist.ICompletionListener#assistSessionEnded(org.eclipse.jface.text.contentassist.ContentAssistEvent)
+                        */
+                       public void assistSessionEnded(ContentAssistEvent event) {
+                               if (event.processor != ContentAssistProcessor.this)
+                                       return;
+
+                               for (Object element : fCategories) {
+                                       CompletionProposalCategory cat= (CompletionProposalCategory) element;
+                                       cat.sessionEnded();
+                               }
+
+                               fCategoryIteration= null;
+                               fRepetition= -1;
+                               fIterationGesture= null;
+                               if (event.assistant instanceof IContentAssistantExtension2) {
+                                       IContentAssistantExtension2 extension= (IContentAssistantExtension2) event.assistant;
+                                       extension.setShowEmptyList(false);
+                                       extension.setRepeatedInvocationMode(false);
+                                       extension.setStatusLineVisible(false);
+                                       if (extension instanceof IContentAssistantExtension3) {
+                                               IContentAssistantExtension3 ext3= (IContentAssistantExtension3) extension;
+                                               ((ContentAssistant) ext3).setRepeatedInvocationTrigger(null);
+                                       }
+                               }
+                       }
+
+                       /*
+                        * @see org.eclipse.jface.text.contentassist.ICompletionListener#selectionChanged(org.eclipse.jface.text.contentassist.ICompletionProposal, boolean)
+                        */
+                       public void selectionChanged(ICompletionProposal proposal, boolean smartToggle) {}
+                       
+               });
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer, int)
+        */
+       public final ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
+               long start= DEBUG ? System.currentTimeMillis() : 0;
+               
+               if (isAutoActivated() && !verifyAutoActivation(viewer, offset)) {
+                       return NO_PROPOSALS;
+               }
+               
+               clearState();
+               
+               IProgressMonitor monitor= createProgressMonitor();
+               monitor.beginTask(ContentAssistMessages.ContentAssistProcessor_computing_proposals, fCategories.size() + 1);
+
+               ContentAssistInvocationContext context= createContext(viewer, offset, true);
+               if (context == null)
+                       return null;
+
+               try {
+                       long setup= DEBUG ? System.currentTimeMillis() : 0;
+                       
+                       monitor.subTask(ContentAssistMessages.ContentAssistProcessor_collecting_proposals);
+                       List<ICompletionProposal> proposals= collectProposals(viewer, offset, monitor, context);
+                       long collect= DEBUG ? System.currentTimeMillis() : 0;
+
+                       monitor.subTask(ContentAssistMessages.ContentAssistProcessor_sorting_proposals);
+                       List<ICompletionProposal> filtered= filterAndSortProposals(proposals, monitor, context);
+                       fNumberOfComputedResults= filtered.size();
+                       long filter= DEBUG ? System.currentTimeMillis() : 0;
+                       
+                       ICompletionProposal[] result= filtered.toArray(new ICompletionProposal[filtered.size()]);
+                       monitor.done();
+                       
+                       if (DEBUG) {
+                               System.err.println("Code Assist Stats (" + result.length + " proposals)"); //$NON-NLS-1$ //$NON-NLS-2$
+                               System.err.println("Code Assist (setup):\t" + (setup - start) ); //$NON-NLS-1$
+                               System.err.println("Code Assist (collect):\t" + (collect - setup) ); //$NON-NLS-1$
+                               System.err.println("Code Assist (sort):\t" + (filter - collect) ); //$NON-NLS-1$
+                       }
+                       
+                       return result;
+               } finally {
+                       context.dispose();
+               }
+       }
+
+       /**
+        * Verify that auto activation is allowed.
+        * <p>
+        * The default implementation always returns <code>true</code>.
+        * </p>
+        * 
+        * @param viewer  the text viewer
+        * @param offset  the offset where content assist was invoked on
+        * @return <code>true</code> if auto activation is allowed
+        */
+       protected boolean verifyAutoActivation(ITextViewer viewer, int offset) {
+               return true;
+       }
+
+       private void clearState() {
+               fErrorMessage=null;
+               fNumberOfComputedResults= 0;
+       }
+
+       private List<ICompletionProposal> collectProposals(ITextViewer viewer, int offset, IProgressMonitor monitor, ContentAssistInvocationContext context) {
+               List<ICompletionProposal> proposals= new ArrayList<ICompletionProposal>();
+               List<CompletionProposalCategory> providers= getCategories();
+               for (CompletionProposalCategory cat : providers) {
+                       List<ICompletionProposal> computed= cat.computeCompletionProposals(context, fPartition, new SubProgressMonitor(monitor, 1));
+                       proposals.addAll(computed);
+                       if (fErrorMessage == null)
+                               fErrorMessage= cat.getErrorMessage();
+               }
+               
+               return proposals;
+       }
+
+       /**
+        * Filters and sorts the proposals. The passed list may be modified
+        * and returned, or a new list may be created and returned.
+        * 
+        * @param proposals the list of collected proposals (element type:
+        *        {@link ICompletionProposal})
+        * @param monitor a progress monitor
+        * @param context TODO
+        * @return the list of filtered and sorted proposals, ready for
+        *         display (element type: {@link ICompletionProposal})
+        */
+       protected List<ICompletionProposal> filterAndSortProposals(List<ICompletionProposal> proposals, IProgressMonitor monitor, ContentAssistInvocationContext context) {
+               return proposals;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer, int)
+        */
+       public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
+               clearState();
+
+               IProgressMonitor monitor= createProgressMonitor();
+               monitor.beginTask(ContentAssistMessages.ContentAssistProcessor_computing_contexts, fCategories.size() + 1);
+               
+               monitor.subTask(ContentAssistMessages.ContentAssistProcessor_collecting_contexts);
+               List<IContextInformation> proposals= collectContextInformation(viewer, offset, monitor);
+               monitor.subTask(ContentAssistMessages.ContentAssistProcessor_sorting_contexts);
+               List<IContextInformation> filtered= filterAndSortContextInformation(proposals, monitor);
+               fNumberOfComputedResults= filtered.size();
+               
+               IContextInformation[] result= filtered.toArray(new IContextInformation[filtered.size()]);
+               monitor.done();
+               return result;
+       }
+
+       private List<IContextInformation> collectContextInformation(ITextViewer viewer, int offset, IProgressMonitor monitor) {
+               List<IContextInformation> proposals= new ArrayList<IContextInformation>();
+               ContentAssistInvocationContext context= createContext(viewer, offset, false);
+               
+               try {
+                       List<CompletionProposalCategory> providers= getCategories();
+                       for (CompletionProposalCategory cat : providers) {
+                               List<IContextInformation> computed= cat.computeContextInformation(context, fPartition, new SubProgressMonitor(monitor, 1));
+                               proposals.addAll(computed);
+                               if (fErrorMessage == null)
+                                       fErrorMessage= cat.getErrorMessage();
+                       }
+                       
+                       return proposals;
+               } finally {
+                       context.dispose();
+               }
+       }
+
+       /**
+        * Filters and sorts the context information objects. The passed
+        * list may be modified and returned, or a new list may be created
+        * and returned.
+        * 
+        * @param contexts the list of collected proposals (element type:
+        *        {@link IContextInformation})
+        * @param monitor a progress monitor
+        * @return the list of filtered and sorted proposals, ready for
+        *         display (element type: {@link IContextInformation})
+        */
+       protected List<IContextInformation> filterAndSortContextInformation(List<IContextInformation> contexts, IProgressMonitor monitor) {
+               return contexts;
+       }
+
+       /**
+        * Sets this processor's set of characters triggering the activation of the
+        * completion proposal computation (including auto-correction auto-activation)
+        *
+        * @param activationSet the activation set
+        */
+       public void setCompletionProposalAutoActivationCharacters(char[] activationSet) {
+               fCompletionAutoActivationCharacters= activationSet;
+       }
+
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
+        */
+       public char[] getCompletionProposalAutoActivationCharacters() {
+               return fCompletionAutoActivationCharacters;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters()
+        */
+       public char[] getContextInformationAutoActivationCharacters() {
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage()
+        */
+       public String getErrorMessage() {
+               if (fNumberOfComputedResults > 0)
+                       return null;
+               if (fErrorMessage != null)
+                       return fErrorMessage;
+               return ContentAssistMessages.ContentAssistProcessor_no_completions;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationValidator()
+        */
+       public IContextInformationValidator getContextInformationValidator() {
+               return null;
+       }
+
+       /**
+        * Creates a progress monitor.
+        * <p>
+        * The default implementation creates a
+        * <code>NullProgressMonitor</code>.
+        * </p>
+        * 
+        * @return a progress monitor
+        */
+       protected IProgressMonitor createProgressMonitor() {
+               return new NullProgressMonitor();
+       }
+
+       /**
+        * Creates the context that is passed to the completion proposal
+        * computers.
+        * 
+        * @param viewer the viewer that content assist is invoked on
+        * @param offset the content assist offset
+        * @return the context to be passed to the computers
+        *         or <code>null</code> if no completion is possible
+        */
+       protected ContentAssistInvocationContext createContext(ITextViewer viewer, int offset, boolean isCompletion) {
+               return new ContentAssistInvocationContext(viewer, offset);
+       }
+
+       /**
+        * Test whether the current session was auto-activated.
+        * 
+        * @return  <code>true</code> if the current session was auto-activated.
+        */
+       protected boolean isAutoActivated() {
+               return fIsAutoActivated;
+       }
+
+       private List<CompletionProposalCategory> getCategories() {
+               if (fCategoryIteration == null)
+                       return fCategories;
+               
+               int iteration= fRepetition % fCategoryIteration.size();
+               fAssistant.setStatusMessage(createIterationMessage());
+               fAssistant.setEmptyMessage(createEmptyMessage());
+               fRepetition++;
+               
+//             fAssistant.setShowMessage(fRepetition % 2 != 0);
+//             
+               return fCategoryIteration.get(iteration);
+       }
+
+       private List<List<CompletionProposalCategory>> getCategoryIteration() {
+               List<List<CompletionProposalCategory>> sequence= new ArrayList<List<CompletionProposalCategory>>();
+               sequence.add(getDefaultCategories());
+               for (CompletionProposalCategory cat : getSeparateCategories()) {
+                       sequence.add(Collections.singletonList(cat));
+               }
+               return sequence;
+       }
+
+       private List<CompletionProposalCategory> getDefaultCategories() {
+               // default mix - enable all included computers
+               List<CompletionProposalCategory> included= getDefaultCategoriesUnchecked();
+
+               if (IDocument.DEFAULT_CONTENT_TYPE.equals(fPartition) && included.isEmpty() && !fCategories.isEmpty())
+                       if (informUserAboutEmptyDefaultCategory())
+                               // preferences were restored - recompute the default categories
+                               included= getDefaultCategoriesUnchecked();
+
+               return included;
+       }
+
+       private List<CompletionProposalCategory> getDefaultCategoriesUnchecked() {
+               List<CompletionProposalCategory> included= new ArrayList<CompletionProposalCategory>();
+               for (Object element : fCategories) {
+                       CompletionProposalCategory category= (CompletionProposalCategory) element;
+                       if (category.isIncluded() && category.hasComputers(fPartition))
+                               included.add(category);
+               }
+               return included;
+       }
+
+       /**
+        * Informs the user about the fact that there are no enabled categories in the default content
+        * assist set and shows a link to the preferences.
+        */
+       private boolean informUserAboutEmptyDefaultCategory() {
+               if (OptionalMessageDialog.isDialogEnabled(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY)) {
+                       final Shell shell= CUIPlugin.getActiveWorkbenchShell();
+                       String title= ContentAssistMessages.ContentAssistProcessor_all_disabled_title;
+                       String message= ContentAssistMessages.ContentAssistProcessor_all_disabled_message;
+                       // see PreferencePage#createControl for the 'defaults' label
+                       final String restoreButtonLabel= JFaceResources.getString("defaults"); //$NON-NLS-1$
+                       final String linkMessage= Messages.format(ContentAssistMessages.ContentAssistProcessor_all_disabled_preference_link, LegacyActionTools.removeMnemonics(restoreButtonLabel));
+                       final int restoreId= IDialogConstants.CLIENT_ID + 10;
+                       final int settingsId= IDialogConstants.CLIENT_ID + 11;
+                       final OptionalMessageDialog dialog= new OptionalMessageDialog(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY, shell, title, null /* default image */, message, MessageDialog.WARNING, new String[] { restoreButtonLabel, IDialogConstants.CLOSE_LABEL }, 1) {
+                               /*
+                                * @see org.eclipse.cdt.internal.ui.dialogs.OptionalMessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite)
+                                */
+                               @Override
+                               protected Control createCustomArea(Composite composite) {
+                                       // wrap link and checkbox in one composite without space
+                                       Composite parent= new Composite(composite, SWT.NONE);
+                                       GridLayout layout= new GridLayout();
+                                       layout.marginHeight= 0;
+                                       layout.marginWidth= 0;
+                                       layout.verticalSpacing= 0;
+                                       parent.setLayout(layout);
+                                       
+                                       Composite linkComposite= new Composite(parent, SWT.NONE);
+                                       layout= new GridLayout();
+                                       layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
+                                       layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
+                                       layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
+                                       linkComposite.setLayout(layout);
+
+                               Link link= new Link(linkComposite, SWT.NONE);
+                               link.setText(linkMessage);
+                               link.addSelectionListener(new SelectionAdapter() {
+                                       @Override
+                                               public void widgetSelected(SelectionEvent e) {
+                                               setReturnCode(settingsId);
+                                               close();
+                                       }
+                               });
+                               GridData gridData= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
+                               gridData.widthHint= this.getMinimumMessageWidth();
+                                       link.setLayoutData(gridData);
+
+                                       // create checkbox and "don't show this message" prompt
+                                       super.createCustomArea(parent);
+                                       
+                                       return parent;
+                       }
+                               
+                               /*
+                                * @see org.eclipse.jface.dialogs.MessageDialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+                                */
+                               @Override
+                               protected void createButtonsForButtonBar(Composite parent) {
+                               Button[] buttons= new Button[2];
+                                       buttons[0]= createButton(parent, restoreId, restoreButtonLabel, false);
+                               buttons[1]= createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, true);
+                               setButtons(buttons);
+                               }
+               };
+               int returnValue= dialog.open();
+               if (restoreId == returnValue || settingsId == returnValue) {
+                       if (restoreId == returnValue) {
+                               IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+                               store.setToDefault(PreferenceConstants.CODEASSIST_CATEGORY_ORDER);
+                               store.setToDefault(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
+                       }
+                       if (settingsId == returnValue)
+                                       PreferencesUtil.createPreferenceDialogOn(shell, "org.eclipse.cdt.ui.preferences.CodeAssistPreferenceAdvanced", null, null).open(); //$NON-NLS-1$
+                       CompletionProposalComputerRegistry registry= CompletionProposalComputerRegistry.getDefault();
+                       registry.reload();
+                       return true;
+               }
+               }
+               return false;
+       }
+
+       private List<CompletionProposalCategory> getSeparateCategories() {
+               ArrayList<CompletionProposalCategory> sorted= new ArrayList<CompletionProposalCategory>();
+               for (Object element : fCategories) {
+                       CompletionProposalCategory category= (CompletionProposalCategory) element;
+                       if (category.isSeparateCommand() && category.hasComputers(fPartition))
+                               sorted.add(category);
+               }
+               Collections.sort(sorted, ORDER_COMPARATOR);
+               return sorted;
+       }
+       
+       private String createEmptyMessage() {
+               return Messages.format(ContentAssistMessages.ContentAssistProcessor_empty_message, getCategoryLabel(fRepetition));
+       }
+       
+       private String createIterationMessage() {
+               return Messages.format(ContentAssistMessages.ContentAssistProcessor_toggle_affordance_update_message, getCategoryLabel(fRepetition), fIterationGesture, getCategoryLabel(fRepetition + 1));
+       }
+       
+       private String getCategoryLabel(int repetition) {
+               int iteration= repetition % fCategoryIteration.size();
+               if (iteration == 0)
+                       return ContentAssistMessages.ContentAssistProcessor_defaultProposalCategory;
+               return toString(fCategoryIteration.get(iteration).get(0));
+       }
+       
+       private String toString(CompletionProposalCategory category) {
+               return category.getDisplayName();
+       }
+
+       private String getIterationGesture() {
+               TriggerSequence binding= getIterationBinding();
+               return binding != null ? 
+                                 Messages.format(ContentAssistMessages.ContentAssistProcessor_toggle_affordance_press_gesture, new Object[] { binding.format() })
+                               : ContentAssistMessages.ContentAssistProcessor_toggle_affordance_click_gesture;
+       }
+
+       private KeySequence getIterationBinding() {
+           final IBindingService bindingSvc= (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class);
+               TriggerSequence binding= bindingSvc.getBestActiveBindingFor(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
+               if (binding instanceof KeySequence)
+                       return (KeySequence) binding;
+               return null;
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java
new file mode 100644 (file)
index 0000000..969caba
--- /dev/null
@@ -0,0 +1,659 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    QNX - Initial API and implementation
+ *    Markus Schorn (Wind River Systems)
+ *    Anton Leherbauer (Wind River Systems)
+ *    Sergey Prigogin (Google)
+ *    Jens Elmenthaler - http://bugs.eclipse.org/173458 (camel case completion)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.contentassist;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.swt.graphics.Image;
+
+import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTCompletionContext;
+import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionStyleMacroParameter;
+import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorFunctionStyleMacroDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.ICompositeType;
+import org.eclipse.cdt.core.dom.ast.IEnumeration;
+import org.eclipse.cdt.core.dom.ast.IEnumerator;
+import org.eclipse.cdt.core.dom.ast.IField;
+import org.eclipse.cdt.core.dom.ast.IFunction;
+import org.eclipse.cdt.core.dom.ast.IFunctionType;
+import org.eclipse.cdt.core.dom.ast.IParameter;
+import org.eclipse.cdt.core.dom.ast.IScope;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.ITypedef;
+import org.eclipse.cdt.core.dom.ast.IVariable;
+import org.eclipse.cdt.core.dom.ast.c.ICFunctionScope;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
+import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
+import org.eclipse.cdt.core.parser.util.CharArrayUtils;
+import org.eclipse.cdt.core.parser.util.IContentAssistMatcher;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+import org.eclipse.cdt.internal.core.dom.parser.c.CBuiltinParameter;
+import org.eclipse.cdt.internal.core.dom.parser.c.CBuiltinVariable;
+import org.eclipse.cdt.internal.core.dom.parser.c.CImplicitFunction;
+import org.eclipse.cdt.internal.core.dom.parser.c.CImplicitTypedef;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBuiltinParameter;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBuiltinVariable;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPImplicitFunction;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPImplicitMethod;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPImplicitTypedef;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.AccessContext;
+import org.eclipse.cdt.internal.core.parser.util.ContentAssistMatcherFactory;
+
+import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
+
+/**
+ * Searches the DOM (both the AST and the index) for completion proposals.
+ * 
+ * @author Bryan Wilkinson
+ */
+public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer {
+
+       /**
+        * Default constructor is required (executable extension).
+        */
+       public DOMCompletionProposalComputer() {
+       }
+       
+       @Override
+       protected List<ICompletionProposal> computeCompletionProposals(
+                       CContentAssistInvocationContext context,
+                       IASTCompletionNode completionNode, String prefix) {
+
+               List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
+               
+               if (inPreprocessorDirective(context)) {
+                       if (!inPreprocessorKeyword(context)) {
+                               // add only macros
+                               if (prefix.length() == 0) {
+                                       try {
+                                               prefix= context.computeIdentifierPrefix().toString();
+                                       } catch (BadLocationException exc) {
+                                               CUIPlugin.log(exc);
+                                       }
+                               }
+                               addMacroProposals(context, prefix, proposals);
+                       }
+               } else {
+                       boolean handleMacros= false;
+                       IASTName[] names = completionNode.getNames();
+
+                       for (IASTName name : names) {
+                               if (name.getTranslationUnit() == null)
+                                       // The node isn't properly hooked up, must have backtracked out of this node
+                                       continue;
+                               
+                               IASTCompletionContext astContext = name.getCompletionContext();
+                               if (astContext == null) {
+                                       continue;
+                               } else if (astContext instanceof IASTIdExpression
+                                               || astContext instanceof IASTNamedTypeSpecifier) {
+                                       // handle macros only if there is a prefix
+                                       handleMacros = prefix.length() > 0;
+                               }
+                               
+                               IBinding[] bindings = astContext.findBindings(name, !context.isContextInformationStyle());
+                               
+                               if (bindings != null) {
+                                       AccessContext accessibilityContext = new AccessContext(name);
+                                       for (IBinding binding : bindings) {
+                                               if (accessibilityContext.isAccessible(binding))
+                                                       handleBinding(binding, context, prefix, astContext, proposals);
+                                       }
+                               }
+                       }
+
+                       if (handleMacros)
+                               addMacroProposals(context, prefix, proposals);
+               }
+               
+               return proposals;
+       }
+
+       /**
+        * Test whether the invocation offset is inside or before the preprocessor directive keyword.
+        * 
+        * @param context  the invocation context
+        * @return <code>true</code> if the invocation offset is inside or before the directive keyword 
+        */
+       private boolean inPreprocessorKeyword(CContentAssistInvocationContext context) {
+               IDocument doc = context.getDocument();
+               int offset = context.getInvocationOffset();
+               
+               try {
+                       final ITypedRegion partition=
+                                       TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, offset, true);
+                       if (ICPartitions.C_PREPROCESSOR.equals(partition.getType())) {
+                               String ppPrefix= doc.get(partition.getOffset(), offset - partition.getOffset());
+                               if (ppPrefix.matches("\\s*#\\s*\\w*")) { //$NON-NLS-1$
+                                       // we are inside the directive keyword
+                                       return true;
+                               }
+                       }
+                       
+               } catch (BadLocationException exc) {
+               }
+               return false;
+       }
+
+       /**
+        * Check if the invocation offset is inside a preprocessor directive.
+        * 
+        * @param context  the content asist invocation context
+        * @return <code>true</code> if invocation offset is inside a preprocessor directive
+        */
+       private boolean inPreprocessorDirective(CContentAssistInvocationContext context) {
+               IDocument doc = context.getDocument();
+               int offset = context.getInvocationOffset();
+               
+               try {
+                       final ITypedRegion partition=
+                                       TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, offset, true);
+                       if (ICPartitions.C_PREPROCESSOR.equals(partition.getType())) {
+                               return true;
+                       }
+                       
+               } catch (BadLocationException exc) {
+               }
+               return false;
+       }
+
+       private void addMacroProposals(CContentAssistInvocationContext context, String prefix,
+                       List<ICompletionProposal> proposals) {
+               IASTCompletionNode completionNode = context.getCompletionNode();
+               addMacroProposals(context, prefix, proposals, completionNode.getTranslationUnit()
+                               .getMacroDefinitions());
+               addMacroProposals(context, prefix, proposals, completionNode.getTranslationUnit()
+                               .getBuiltinMacroDefinitions());
+       }
+
+       private void addMacroProposals(CContentAssistInvocationContext context, String prefix,
+                       List<ICompletionProposal> proposals, IASTPreprocessorMacroDefinition[] macros) {
+               if (macros != null) {
+                       char[] prefixChars= prefix.toCharArray();
+                       final boolean matchPrefix= !context.isContextInformationStyle();
+                       if (matchPrefix) {
+                               IContentAssistMatcher matcher = ContentAssistMatcherFactory.getInstance().createMatcher(prefixChars);
+                               for (int i = 0; i < macros.length; ++i) {
+                                       final char[] macroName= macros[i].getName().toCharArray();
+                                       if (matcher.match(macroName)) {
+                                               handleMacro(macros[i], context, prefix, proposals);
+                                       }
+                               }
+                       } else {
+                               for (int i = 0; i < macros.length; ++i) {
+                                       final char[] macroName= macros[i].getName().toCharArray();
+                                       if (CharArrayUtils.equals(macroName, 0, macroName.length, prefixChars, true)) {
+                                               handleMacro(macros[i], context, prefix, proposals);
+                                       }
+                               }
+                       }
+               }
+       }
+       
+       private void handleMacro(IASTPreprocessorMacroDefinition macro, CContentAssistInvocationContext context,
+                       String prefix, List<ICompletionProposal> proposals) {
+               final String macroName = macro.getName().toString();
+               final int baseRelevance= computeBaseRelevance(prefix, macroName);
+
+               Image image = getImage(CElementImageProvider.getMacroImageDescriptor());
+               
+               if (macro instanceof IASTPreprocessorFunctionStyleMacroDefinition) {
+                       IASTPreprocessorFunctionStyleMacroDefinition functionMacro =
+                                       (IASTPreprocessorFunctionStyleMacroDefinition) macro;
+                       
+                       StringBuilder repStringBuff = new StringBuilder();
+                       repStringBuff.append(macroName);
+                       repStringBuff.append('(');
+                       
+                       StringBuilder args = new StringBuilder();
+
+                       IASTFunctionStyleMacroParameter[] params = functionMacro.getParameters();
+                       if (params != null) {
+                               for (int i = 0; i < params.length; ++i) {
+                                       if (i > 0)
+                                               args.append(", "); //$NON-NLS-1$
+                                       args.append(params[i].getParameter());
+                               }
+                       }
+                       String argString = args.toString();
+                       
+                       StringBuilder descStringBuff = new StringBuilder(repStringBuff.toString());
+                       descStringBuff.append(argString);
+                       descStringBuff.append(')');
+                       
+                       repStringBuff.append(')');
+                       String repString = repStringBuff.toString();
+                       String descString = descStringBuff.toString();
+                       
+                       CCompletionProposal proposal = createProposal(repString, descString, prefix.length(), image,
+                                       baseRelevance + RelevanceConstants.MACRO_TYPE_RELEVANCE, context);
+                       if (!context.isContextInformationStyle()) {
+                               if (argString.length() > 0) {
+                                       proposal.setCursorPosition(repString.length() - 1);
+                               } else {
+                                       proposal.setCursorPosition(repString.length());
+                               }
+                       }
+                       
+                       if (argString.length() > 0) {
+                               CProposalContextInformation info = new CProposalContextInformation(image, descString, argString);
+                               info.setContextInformationPosition(context.getContextInformationOffset());
+                               proposal.setContextInformation(info);
+                       }
+                       
+                       proposals.add(proposal);
+               } else {
+                       proposals.add(createProposal(macroName, macroName, prefix.length(), image,
+                                       baseRelevance + RelevanceConstants.MACRO_TYPE_RELEVANCE, context));
+               }
+       }
+
+       protected void handleBinding(IBinding binding, CContentAssistInvocationContext cContext, String prefix, 
+                       IASTCompletionContext astContext, List<ICompletionProposal> proposals) {
+               if ((binding instanceof CPPImplicitFunction
+                               || binding instanceof CPPImplicitTypedef
+                               || binding instanceof CPPBuiltinVariable
+                               || binding instanceof CPPBuiltinParameter
+                               || binding instanceof CImplicitFunction
+                               || binding instanceof CImplicitTypedef
+                               || binding instanceof CBuiltinVariable
+                               || binding instanceof CBuiltinParameter)
+                               && !(binding instanceof CPPImplicitMethod)) {
+                       return;
+               }
+
+               if (!isAnonymousBinding(binding)) {
+                       final String name = binding.getName();
+                       final int baseRelevance= computeBaseRelevance(prefix, name);
+                       if (binding instanceof ICPPClassType) {
+                               handleClass((ICPPClassType) binding, astContext, cContext, baseRelevance, proposals);
+                       } else if (binding instanceof IFunction) {
+                               handleFunction((IFunction)binding, cContext, baseRelevance, proposals);
+                       } else if (binding instanceof IVariable) {
+                               handleVariable((IVariable) binding, cContext, baseRelevance, proposals);
+                       } else if (!cContext.isContextInformationStyle()) {
+                               if (binding instanceof ITypedef) {
+                                       proposals.add(createProposal(name, name, getImage(binding),
+                                                       baseRelevance + RelevanceConstants.TYPEDEF_TYPE_RELEVANCE, cContext));
+                               } else if (binding instanceof ICPPNamespace) {
+                                       handleNamespace((ICPPNamespace) binding, astContext, cContext, baseRelevance, proposals);
+                               } else if (binding instanceof IEnumeration) {
+                                       proposals.add(createProposal(name, name, getImage(binding),
+                                                       baseRelevance + RelevanceConstants.ENUMERATION_TYPE_RELEVANCE, cContext));
+                               } else if (binding instanceof IEnumerator) {
+                                       proposals.add(createProposal(name, name, getImage(binding),
+                                                       baseRelevance + RelevanceConstants.ENUMERATOR_TYPE_RELEVANCE, cContext));
+                               } else {
+                                       proposals.add(createProposal(name, name, getImage(binding),
+                                                       baseRelevance + RelevanceConstants.DEFAULT_TYPE_RELEVANCE, cContext));
+                               }
+                       }
+               }
+       }
+       
+       private boolean isAnonymousBinding(IBinding binding) {
+               char[] name= binding.getNameCharArray();
+               return name.length == 0 || name[0] == '{';
+       }
+
+       private void handleClass(ICPPClassType classType, IASTCompletionContext astContext,
+                       CContentAssistInvocationContext context, int baseRelevance, List<ICompletionProposal> proposals) {
+               if (context.isContextInformationStyle()) {
+                       ICPPConstructor[] constructors = classType.getConstructors();
+                       for (ICPPConstructor constructor : constructors) {
+                               handleFunction(constructor, context, baseRelevance, proposals);
+                       }
+               } else {
+                       int relevance= 0;
+                       switch (classType.getKey()) {
+                       case ICPPClassType.k_class:
+                               relevance= RelevanceConstants.CLASS_TYPE_RELEVANCE;
+                               break;
+                       case ICompositeType.k_struct:
+                               relevance= RelevanceConstants.STRUCT_TYPE_RELEVANCE;
+                               break;
+                       case ICompositeType.k_union:
+                               relevance= RelevanceConstants.UNION_TYPE_RELEVANCE;
+                               break;
+                       }
+                       if (astContext instanceof IASTName && !(astContext instanceof ICPPASTQualifiedName)) {
+                               IASTName name= (IASTName)astContext;
+                               if (name.getParent() instanceof IASTDeclarator) {
+                                       proposals.add(createProposal(classType.getName() + "::", classType.getName(), //$NON-NLS-1$
+                                                       getImage(classType), baseRelevance + relevance, context));
+                               }
+                       }
+                       proposals.add(createProposal(classType.getName(), classType.getName(), getImage(classType),
+                                       baseRelevance + RelevanceConstants.CLASS_TYPE_RELEVANCE, context));
+               }
+       }
+       
+       private void handleFunction(IFunction function, CContentAssistInvocationContext context,
+                       int baseRelevance, List<ICompletionProposal> proposals) {       
+               Image image = getImage(function);
+               
+               StringBuilder repStringBuff = new StringBuilder();
+               repStringBuff.append(function.getName());
+               repStringBuff.append('(');
+               
+               StringBuilder dispargs = new StringBuilder(); // for the dispargString
+        StringBuilder idargs = new StringBuilder();   // for the idargString
+               boolean hasArgs = true;
+               String returnTypeStr = null;
+               IParameter[] params = function.getParameters();
+               if (params != null) {
+                       for (int i = 0; i < params.length; ++i) {
+                               IType paramType = params[i].getType();
+                               if (i > 0) {
+                           dispargs.append(',');
+                           idargs.append(',');
+                       }
+
+                               dispargs.append(ASTTypeUtil.getType(paramType, false));
+                       idargs.append(ASTTypeUtil.getType(paramType, false));
+                               String paramName = params[i].getName();
+                               if (paramName != null && paramName.length() > 0) {
+                                       dispargs.append(' ');
+                                       dispargs.append(paramName);
+                               }
+                       }
+               
+                       if (function.takesVarArgs()) {
+                               if (params.length > 0) {
+                                       dispargs.append(',');
+                                       idargs.append(',');
+                               }
+                               dispargs.append("..."); //$NON-NLS-1$
+                               idargs.append("..."); //$NON-NLS-1$
+                       } else if (params.length == 0) { // force the void in
+                               dispargs.append("void"); //$NON-NLS-1$
+                               idargs.append("void"); //$NON-NLS-1$
+                       }
+               }
+               IFunctionType functionType = function.getType();
+               if (functionType != null) {
+                       IType returnType = functionType.getReturnType();
+                       if (returnType != null)
+                               returnTypeStr = ASTTypeUtil.getType(returnType, false);
+               }
+
+               hasArgs = ASTTypeUtil.functionTakesParameters(function);
+        
+        String dispargString = dispargs.toString();
+        String idargString = idargs.toString();
+               String contextDispargString = hasArgs ? dispargString : null;
+        StringBuilder dispStringBuff = new StringBuilder(repStringBuff.toString());
+               dispStringBuff.append(dispargString);
+        dispStringBuff.append(')');
+        if (returnTypeStr != null && returnTypeStr.length() > 0) {
+            dispStringBuff.append(" : "); //$NON-NLS-1$
+            dispStringBuff.append(returnTypeStr);
+        }
+        String dispString = dispStringBuff.toString();
+
+        StringBuilder idStringBuff = new StringBuilder(repStringBuff.toString());
+        idStringBuff.append(idargString);
+        idStringBuff.append(')');
+        String idString = idStringBuff.toString();
+               
+        repStringBuff.append(')');
+        String repString = repStringBuff.toString();
+
+        final int relevance = function instanceof ICPPMethod ?
+                       RelevanceConstants.METHOD_TYPE_RELEVANCE : RelevanceConstants.FUNCTION_TYPE_RELEVANCE;
+               CCompletionProposal proposal = createProposal(repString, dispString, idString,
+                               context.getCompletionNode().getLength(), image, baseRelevance + relevance, context);
+               if (!context.isContextInformationStyle()) {
+                       int cursorPosition = hasArgs ? (repString.length() - 1) : repString.length();
+                       proposal.setCursorPosition(cursorPosition);
+               }
+               
+               if (contextDispargString != null) {
+                       CProposalContextInformation info =
+                                       new CProposalContextInformation(image, dispString, contextDispargString);
+                       info.setContextInformationPosition(context.getContextInformationOffset());
+                       proposal.setContextInformation(info);
+               }
+               
+               proposals.add(proposal);
+       }
+       
+       private void handleVariable(IVariable variable, CContentAssistInvocationContext context,
+                       int baseRelevance, List<ICompletionProposal> proposals) {
+               if (context.isContextInformationStyle()) {
+                       IType t = variable.getType();
+                       t= unwindTypedefs(t);
+                       if (t instanceof ICPPClassType) {
+                               ICPPClassType classType= (ICPPClassType) t;
+                               ICPPConstructor[] constructors = classType.getConstructors();
+                               for (ICPPConstructor constructor : constructors) {
+                                       handleFunction(constructor, context, baseRelevance, proposals);
+                               }
+                       }
+                       return;
+               } 
+
+               StringBuilder repStringBuff = new StringBuilder();
+               repStringBuff.append(variable.getName());
+               
+               String returnTypeStr = "<unknown>"; //$NON-NLS-1$
+               IType varType = variable.getType();
+               if (varType != null)
+                       returnTypeStr = ASTTypeUtil.getType(varType, false);
+        
+        StringBuilder dispStringBuff = new StringBuilder(repStringBuff.toString());
+        if (returnTypeStr != null) {
+            dispStringBuff.append(" : "); //$NON-NLS-1$
+            dispStringBuff.append(returnTypeStr);
+        }
+        String dispString = dispStringBuff.toString();
+
+        StringBuilder idStringBuff = new StringBuilder(repStringBuff.toString());
+        String idString = idStringBuff.toString();
+               
+        String repString = repStringBuff.toString();
+
+               Image image = getImage(variable);
+               final int relevance = isLocalVariable(variable) 
+                       ? RelevanceConstants.LOCAL_VARIABLE_TYPE_RELEVANCE
+                       : isField(variable) 
+                               ? RelevanceConstants.FIELD_TYPE_RELEVANCE
+                               : RelevanceConstants.VARIABLE_TYPE_RELEVANCE;
+               CCompletionProposal proposal = createProposal(repString, dispString, idString,
+                               context.getCompletionNode().getLength(), image, baseRelevance + relevance, context);
+               proposals.add(proposal);
+       }
+       
+       private IType unwindTypedefs(final IType t) {
+               IType r= t;
+               while (r instanceof ITypedef)
+                       r= ((ITypedef) r).getType();
+               return r != null ? r : t;
+       }
+
+       private static boolean isField(IVariable variable) {
+               return variable instanceof IField;
+       }
+
+       private static boolean isLocalVariable(IVariable variable) {
+               try {
+                       return isLocalScope(variable.getScope());
+               } catch (DOMException exc) {
+                       return false;
+               }
+       }
+
+    private static boolean isLocalScope(IScope scope) {
+        while (scope != null) {
+            if (scope instanceof ICPPFunctionScope ||
+                    scope instanceof ICPPBlockScope ||
+                    scope instanceof ICFunctionScope) {
+                return true;
+            }
+            try {
+                scope= scope.getParent();
+            } catch (DOMException e) {
+                scope= null;
+            }
+        }
+        return false;
+    }
+
+       private void handleNamespace(ICPPNamespace namespace,
+                       IASTCompletionContext astContext,
+                       CContentAssistInvocationContext cContext, 
+                       int baseRelevance, 
+                       List<ICompletionProposal> proposals) {
+
+               if (astContext instanceof ICPPASTQualifiedName) {
+                       IASTCompletionContext parent = ((ICPPASTQualifiedName) astContext)
+                                       .getCompletionContext();
+                       handleNamespace(namespace, parent, cContext, baseRelevance, proposals);
+                       return;
+               }
+               
+               StringBuilder repStringBuff = new StringBuilder();
+               repStringBuff.append(namespace.getName());
+               
+               if (!(astContext instanceof ICPPASTUsingDeclaration)
+                               && !(astContext instanceof ICPPASTUsingDirective)) {
+                       repStringBuff.append("::"); //$NON-NLS-1$
+               }
+               
+               String repString = repStringBuff.toString();
+               proposals.add(createProposal(repString, namespace.getName(), getImage(namespace),
+                               baseRelevance + RelevanceConstants.NAMESPACE_TYPE_RELEVANCE, cContext));
+       }
+       
+       private CCompletionProposal createProposal(String repString, String dispString, Image image,
+                       int relevance, CContentAssistInvocationContext context) {
+               return createProposal(repString, dispString, null, context.getCompletionNode().getLength(), image,
+                               relevance, context);
+       }
+       
+       private CCompletionProposal createProposal(String repString, String dispString, int prefixLength,
+                       Image image, int relevance, CContentAssistInvocationContext context) {
+               return createProposal(repString, dispString, null, prefixLength, image, relevance, context);
+       }
+
+       private CCompletionProposal createProposal(String repString, String dispString, String idString,
+                       int prefixLength, Image image, int relevance, CContentAssistInvocationContext context) {
+               int parseOffset = context.getParseOffset();
+               int invocationOffset = context.getInvocationOffset();
+               boolean doReplacement = !context.isContextInformationStyle();
+               
+               int repLength = doReplacement ? prefixLength : 0;
+               int repOffset = doReplacement ? parseOffset - repLength : invocationOffset;
+               repString = doReplacement ? repString : ""; //$NON-NLS-1$
+               
+               return new CCompletionProposal(repString, repOffset, repLength, image, dispString, idString,
+                               relevance, context.getViewer());
+       }
+
+       private Image getImage(ImageDescriptor desc) {
+               return desc != null ? CUIPlugin.getImageDescriptorRegistry().get(desc) : null;
+       }
+       
+       private Image getImage(IBinding binding) {
+               ImageDescriptor imageDescriptor = null;
+               
+               if (binding instanceof ITypedef) {
+                       imageDescriptor = CElementImageProvider.getTypedefImageDescriptor();
+               } else if (binding instanceof ICompositeType) {
+                       if (((ICompositeType)binding).getKey() == ICPPClassType.k_class || binding instanceof ICPPClassTemplate)
+                               imageDescriptor = CElementImageProvider.getClassImageDescriptor();
+                       else if (((ICompositeType)binding).getKey() == ICompositeType.k_struct)
+                               imageDescriptor = CElementImageProvider.getStructImageDescriptor();
+                       else if (((ICompositeType)binding).getKey() == ICompositeType.k_union)
+                               imageDescriptor = CElementImageProvider.getUnionImageDescriptor();
+               } else if (binding instanceof ICPPMethod) {
+                       switch (((ICPPMethod)binding).getVisibility()) {
+                       case ICPPMember.v_private:
+                               imageDescriptor = CElementImageProvider.getMethodImageDescriptor(ASTAccessVisibility.PRIVATE);
+                               break;
+                       case ICPPMember.v_protected:
+                               imageDescriptor = CElementImageProvider.getMethodImageDescriptor(ASTAccessVisibility.PROTECTED);
+                               break;
+                       default:
+                               imageDescriptor = CElementImageProvider.getMethodImageDescriptor(ASTAccessVisibility.PUBLIC);
+                               break;
+                       }
+               } else if (binding instanceof IFunction) {
+                       imageDescriptor = CElementImageProvider.getFunctionImageDescriptor();
+               } else if (binding instanceof ICPPField) {
+                       switch (((ICPPField)binding).getVisibility()) {
+                       case ICPPMember.v_private:
+                               imageDescriptor = CElementImageProvider.getFieldImageDescriptor(ASTAccessVisibility.PRIVATE);
+                               break;
+                       case ICPPMember.v_protected:
+                               imageDescriptor = CElementImageProvider.getFieldImageDescriptor(ASTAccessVisibility.PROTECTED);
+                               break;
+                       default:
+                               imageDescriptor = CElementImageProvider.getFieldImageDescriptor(ASTAccessVisibility.PUBLIC);
+                               break;
+                       }
+               } else if (binding instanceof IField) {
+                       imageDescriptor = CElementImageProvider.getFieldImageDescriptor(ASTAccessVisibility.PUBLIC);
+               } else if (binding instanceof IVariable) {
+                       imageDescriptor = CElementImageProvider.getVariableImageDescriptor();
+               } else if (binding instanceof IEnumeration) {
+                       imageDescriptor = CElementImageProvider.getEnumerationImageDescriptor();
+               } else if (binding instanceof IEnumerator) {
+                   imageDescriptor = CElementImageProvider.getEnumeratorImageDescriptor();
+               } else if (binding instanceof ICPPNamespace) {
+                       imageDescriptor = CElementImageProvider.getNamespaceImageDescriptor();
+               } else if (binding instanceof ICPPFunctionTemplate) {
+                       imageDescriptor = CElementImageProvider.getFunctionImageDescriptor();
+               } else if (binding instanceof ICPPUsingDeclaration) {
+                       IBinding[] delegates = ((ICPPUsingDeclaration) binding).getDelegates();
+                       if (delegates.length > 0)
+                               return getImage(delegates[0]);
+               }
+               
+               return imageDescriptor != null
+                       ? CUIPlugin.getImageDescriptorRegistry().get(imageDescriptor)
+                       : null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DefaultProposalFilter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DefaultProposalFilter.java
new file mode 100644 (file)
index 0000000..0ced0ac
--- /dev/null
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2006 QNX Software Systems
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.contentassist;
+
+import java.util.Arrays;
+
+import org.eclipse.cdt.ui.text.ICCompletionProposal;
+import org.eclipse.cdt.ui.text.contentassist.IProposalFilter;
+
+/**
+ * The default code completion filter: Remove duplicate entries on the basis of
+ * their id string. Use CCompletionProposalComparator for sorting.
+ */
+public class DefaultProposalFilter implements IProposalFilter {
+
+       public ICCompletionProposal[] filterProposals(
+                       ICCompletionProposal[] proposals) {
+
+               CCompletionProposalComparator propsComp = new CCompletionProposalComparator();
+               propsComp.setOrderAlphabetically(true);
+               Arrays.sort(proposals, propsComp);
+
+               // remove duplicates but leave the ones with return types
+
+               int last = 0;
+               int removed = 0;
+               for (int i = 1; i < proposals.length; ++i) {
+                       if (propsComp.compare(proposals[last], proposals[i]) == 0) {
+                               // We want to leave the one that has the return string if any
+                               boolean lastReturn = proposals[last].getIdString() != proposals[last]
+                                               .getDisplayString();
+                               boolean iReturn = proposals[i].getIdString() != proposals[i]
+                                               .getDisplayString();
+
+                               if (!lastReturn && iReturn)
+                                       // flip i down to last
+                                       proposals[last] = proposals[i];
+
+                               // Remove the duplicate
+                               proposals[i] = null;
+                               ++removed;
+                       } else
+                               // update last
+                               last = i;
+               }
+               if (removed > 0) {
+                       // Strip out the null entries
+                       ICCompletionProposal[] newArray = new ICCompletionProposal[proposals.length
+                                       - removed];
+                       int j = 0;
+                       for (int i = 0; i < proposals.length; ++i)
+                               if (proposals[i] != null)
+                                       newArray[j++] = proposals[i];
+                       proposals = newArray;
+               }
+
+               return proposals;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HelpCompletionProposalComputer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HelpCompletionProposalComputer.java
new file mode 100644 (file)
index 0000000..babe0ab
--- /dev/null
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Bryan Wilkinson (QNX) - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.contentassist;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.swt.graphics.Image;
+
+import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
+import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.IFunctionSummary;
+import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
+import org.eclipse.cdt.ui.text.IContentAssistHelpInvocationContext;
+
+import org.eclipse.cdt.internal.ui.CHelpProviderManager;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
+
+public class HelpCompletionProposalComputer extends ParsingBasedProposalComputer {
+
+       @Override
+       protected List<ICompletionProposal> computeCompletionProposals(
+                       CContentAssistInvocationContext cContext,
+                       IASTCompletionNode completionNode, String prefix)
+                       throws CoreException {
+               
+               boolean handleHelp = false;
+               if (completionNode != null) {
+                       IASTName[] names = completionNode.getNames();
+                       for (int i = 0; i < names.length; ++i) {
+                               IASTName name = names[i];
+                               
+                               // ignore if not connected
+                               if (name.getTranslationUnit() == null)
+                                       continue;
+                       
+                               // ignore if this is a member access
+                               if (name.getParent() instanceof IASTFieldReference)
+                                       continue;
+                               
+                               handleHelp = true;
+                               break;
+                       }
+               }
+               
+               if (!handleHelp) {
+                       return Collections.emptyList();
+               }
+               
+               final ITranslationUnit tu = cContext.getTranslationUnit();
+               final IASTCompletionNode cn = completionNode;
+               final int cc = cContext.getInvocationOffset();
+               
+               // Find matching functions
+               ICHelpInvocationContext helpContext = new IContentAssistHelpInvocationContext() {
+
+                       public IProject getProject() {
+                               return tu.getCProject().getProject();
+                       }
+
+                       public ITranslationUnit getTranslationUnit() {
+                               return tu;
+                       }
+                       
+                       public int getInvocationOffset() {
+                               return cc;
+                       }
+                       
+                       public IASTCompletionNode getCompletionNode() {
+                               return cn;
+                       }
+               };
+
+               IFunctionSummary[] summaries = CHelpProviderManager.getDefault()
+                               .getMatchingFunctions(helpContext, prefix);
+               if (summaries == null)
+                       return Collections.emptyList();
+
+               int repOffset = cContext.getInvocationOffset() - prefix.length();
+               int repLength = prefix.length();
+               Image image = CUIPlugin.getImageDescriptorRegistry().get(
+                               CElementImageProvider.getFunctionImageDescriptor());
+
+               List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
+
+               for (IFunctionSummary summary : summaries) {
+                       String fname = summary.getName() + "()"; //$NON-NLS-1$
+                       String fdesc = summary.getDescription();
+                       IFunctionSummary.IFunctionPrototypeSummary fproto = summary
+                                       .getPrototype();
+                       String fargs = fproto.getArguments();
+
+                       int relevance = computeBaseRelevance(prefix, summary.getName()) + RelevanceConstants.HELP_TYPE_RELEVANCE;
+                       CCompletionProposal proposal;
+                       proposal = new CCompletionProposal(
+                                       fname,
+                                       repOffset,
+                                       repLength,
+                                       image,
+                                       fproto.getPrototypeString(true),
+                                       relevance,
+                                       cContext.getViewer());
+
+                       if (fdesc != null) {
+                               proposal.setAdditionalProposalInfo(fdesc);
+                       }
+
+                       if (!cContext.isContextInformationStyle()) {
+                               if (fargs != null && fargs.length() > 0) {
+                                       // set the cursor before the closing bracket
+                                       proposal.setCursorPosition(fname.length() - 1);
+                               } else {
+                                       // set the cursor behind the closing bracked
+                                       proposal.setCursorPosition(fname.length());
+                               }
+                       }
+                       
+                       if (fargs != null && fargs.length() > 0) {
+                               CProposalContextInformation info = new CProposalContextInformation(image, fname, fargs);
+                               info.setContextInformationPosition(cContext.getContextInformationOffset());
+                               proposal.setContextInformation(info);
+
+                       }
+
+                       proposals.add(proposal);
+               }
+
+               return proposals;
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HippieProposalComputer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HippieProposalComputer.java
new file mode 100644 (file)
index 0000000..b3b0e51
--- /dev/null
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.contentassist;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.ui.texteditor.HippieProposalProcessor;
+
+import org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext;
+import org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer;
+
+
+/**
+ * A computer wrapper for the hippie processor.
+ * 
+ * @since 4.0
+ */
+public final class HippieProposalComputer implements ICompletionProposalComputer {
+       /** The wrapped processor. */
+       private final HippieProposalProcessor fProcessor= new HippieProposalProcessor();
+
+       /**
+        * Default ctor to make it instantiatable via the extension mechanism.
+        */
+       public HippieProposalComputer() {
+       }
+       
+       /*
+        * @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#computeCompletionProposals(org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
+        */
+       public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+               return Arrays.asList(fProcessor.computeCompletionProposals(context.getViewer(), context.getInvocationOffset()));
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#computeContextInformation(org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
+        */
+       public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+               return Arrays.asList(fProcessor.computeContextInformation(context.getViewer(), context.getInvocationOffset()));
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalComputer#getErrorMessage()
+        */
+       public String getErrorMessage() {
+               return fProcessor.getErrorMessage();
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#sessionStarted()
+        */
+       public void sessionStarted() {
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#sessionEnded()
+        */
+       public void sessionEnded() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/InclusionProposalComputer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/InclusionProposalComputer.java
new file mode 100644 (file)
index 0000000..da4560c
--- /dev/null
@@ -0,0 +1,380 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *     Jens Elmenthaler - http://bugs.eclipse.org/173458 (camel case completion)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.contentassist;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceProxy;
+import org.eclipse.core.resources.IResourceProxyVisitor;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.swt.graphics.Image;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.IInclude;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.parser.IExtendedScannerInfo;
+import org.eclipse.cdt.core.parser.IScannerInfo;
+import org.eclipse.cdt.core.parser.util.IContentAssistMatcher;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.ICPartitions;
+import org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext;
+import org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer;
+
+import org.eclipse.cdt.internal.core.parser.util.ContentAssistMatcherFactory;
+
+import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
+
+/**
+ * A proposal computer for include directives.
+ *
+ * @since 5.0
+ */
+public class InclusionProposalComputer implements ICompletionProposalComputer {
+
+       private String fErrorMessage;
+
+       public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+               List<ICompletionProposal> proposals= Collections.emptyList();
+               fErrorMessage= null;
+               
+               if (context instanceof CContentAssistInvocationContext) {
+                       CContentAssistInvocationContext cContext= (CContentAssistInvocationContext) context;
+                       if (inIncludeDirective(cContext)) {
+                               // add include file proposals
+                               proposals= new ArrayList<ICompletionProposal>();
+                               try {
+                                       addInclusionProposals(cContext, proposals);
+                               } catch (Exception exc) {
+                                       fErrorMessage= exc.getMessage();
+                                       CUIPlugin.log(exc);
+                               }
+                       }
+               }
+               return proposals;
+       }
+
+       public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+               return null;
+       }
+
+       public String getErrorMessage() {
+               return fErrorMessage;
+       }
+
+       public void sessionEnded() {
+       }
+
+       public void sessionStarted() {
+       }
+
+       /**
+        * Test whether the invocation offset is inside the file name part if an include directive.
+        * 
+        * @param context  the invocation context
+        * @return <code>true</code> if the invocation offset is inside or before the directive keyword
+        */
+       private boolean inIncludeDirective(CContentAssistInvocationContext context) {
+               IDocument doc = context.getDocument();
+               int offset = context.getInvocationOffset();
+               
+               try {
+                       final ITypedRegion partition= TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, offset, true);
+                       if (ICPartitions.C_PREPROCESSOR.equals(partition.getType())) {
+                               String ppPrefix= doc.get(partition.getOffset(), offset - partition.getOffset());
+                               if (ppPrefix.matches("\\s*#\\s*include\\s*[\"<][^\">]*")) { //$NON-NLS-1$
+                                       // we are inside the file name part of the include directive
+                                       return true;
+                               }
+                       }
+                       
+               } catch (BadLocationException exc) {
+               }
+               return false;
+       }
+
+       private void addInclusionProposals(CContentAssistInvocationContext context, List<ICompletionProposal> proposals) throws Exception {
+               if (context.isContextInformationStyle()) {
+                       return;
+               }
+               final ITranslationUnit tu= context.getTranslationUnit();
+               if (tu == null) {
+                       return;
+               }
+               String prefix;
+               boolean angleBrackets= false;
+               prefix = computeIncludePrefix(context);
+               if (prefix.length() > 0) {
+                       angleBrackets= prefix.charAt(0) == '<';
+                       prefix= prefix.substring(1);
+               }
+               IPath prefixPath= new Path(prefix);
+               String[] potentialIncludes= collectIncludeFiles(tu, prefixPath, angleBrackets);
+               if (potentialIncludes.length > 0) {
+                       IInclude[] includes= tu.getIncludes();
+                       Set<String> alreadyIncluded= new HashSet<String>();
+                       for (IInclude includeDirective : includes) {
+                               alreadyIncluded.add(includeDirective.getElementName());
+                       }
+                       Image image = getImage(CElementImageProvider.getIncludeImageDescriptor());
+                       for (String include : potentialIncludes) {
+                               if (alreadyIncluded.add(include)) {
+                                       final char openingBracket= angleBrackets ? '<' : '"';
+                                       final char closingBracket= angleBrackets ? '>' : '"';
+                                       String repString= openingBracket + include;
+                                       final String dispString= repString + closingBracket;
+                                       int repLength = prefix.length() + 1;
+                                       int repOffset= context.getInvocationOffset() - repLength;
+                                       final boolean needClosingBracket= context.getDocument().getChar(repOffset + repLength) != closingBracket;
+                                       if (needClosingBracket) {
+                                               repString += closingBracket;
+                                       }
+                                       final boolean isDir= include.endsWith("/"); //$NON-NLS-1$
+                                       final int relevance= computeRelevance(prefix, include) + (isDir ? 0 : 1);
+                                       final CCompletionProposal proposal= createProposal(repOffset, repLength, repString, dispString, image, relevance, context);
+                                       if (!isDir && !needClosingBracket) {
+                                               // put cursor behind closing bracket
+                                               proposal.setCursorPosition(repString.length() + 1);
+                                       }
+                                       proposals.add(proposal);
+                               }
+                       }
+               }
+       }
+       
+       /**
+        * Collect potential include files for the given translation unit.
+        * 
+        * @param tu  the translation unit to include the file
+        * @param prefixPath  the path part to match the sub-directory and file name
+        * @param angleBrackets  whether angle brackets enclose the include file name
+        * @return an array of incude file names
+        * @throws CoreException
+        */
+       private String[] collectIncludeFiles(final ITranslationUnit tu, IPath prefixPath, boolean angleBrackets) throws CoreException {
+               final List<String> includeFiles= new ArrayList<String>();
+               if (!angleBrackets) {
+                       // search in current directory
+                       IResource resource= tu.getResource();
+                       if (resource != null) {
+                               IContainer parent= resource.getParent();
+                               collectIncludeFilesFromContainer(tu, parent, prefixPath, includeFiles);
+                       } else {
+                               IPath location= tu.getLocation();
+                               if (location != null) {
+                                       collectIncludeFilesFromDirectory(tu, location.removeLastSegments(1), prefixPath, includeFiles);
+                               }
+                       }
+               }
+               IScannerInfo info= tu.getScannerInfo(true);
+               if (info != null) {
+                       collectIncludeFilesFromScannerInfo(tu, info, prefixPath, angleBrackets, includeFiles);
+               }
+               return includeFiles.toArray(new String[includeFiles.size()]);
+       }
+
+       /**
+        * @param tu  the translation unit to include the file
+        * @param info  the scanner info for this translation unit
+        * @param prefixPath  the path part to match the sub-directory and file name
+        * @param angleBrackets  whether angle brackets enclose the include file name
+        * @param includeFiles  the result list
+        */
+       private void collectIncludeFilesFromScannerInfo(ITranslationUnit tu, IScannerInfo info, IPath prefixPath, boolean angleBrackets, List<String> includeFiles) {
+               if (!angleBrackets && info instanceof IExtendedScannerInfo) {
+                       IExtendedScannerInfo extendedInfo= (IExtendedScannerInfo) info;
+                       String[] quoteIncludes= extendedInfo.getLocalIncludePath();
+                       
+                       if (quoteIncludes != null) {
+                               for (String quoteInclude : quoteIncludes) {
+                                       IPath includeDir= new Path(quoteInclude);
+                                       collectIncludeFilesFromDirectory(tu, includeDir, prefixPath, includeFiles);
+                               }
+                       }
+               }
+               
+               String[] allIncludes= info.getIncludePaths();
+               for (String allInclude : allIncludes) {
+                       IPath includeDir= new Path(allInclude);
+                       collectIncludeFilesFromDirectory(tu, includeDir, prefixPath, includeFiles);
+               }
+       }
+
+       /**
+        * Collect include files from the given file system directory.
+        * 
+        * @param tu  the translation unit to include the file
+        * @param directory  the file system path of the directory
+        * @param prefixPath  the path part to match the sub-directory and file name
+        * @param includeFiles  the result list
+        */
+       private void collectIncludeFilesFromDirectory(ITranslationUnit tu, IPath directory, IPath prefixPath, List<String> includeFiles) {
+               final String namePrefix;
+               if (prefixPath.segmentCount() == 0) {
+                       namePrefix= ""; //$NON-NLS-1$
+               } else if (prefixPath.hasTrailingSeparator()) {
+                       namePrefix= ""; //$NON-NLS-1$
+                       prefixPath= prefixPath.removeTrailingSeparator();
+                       directory= directory.append(prefixPath);
+               } else {
+                       namePrefix= prefixPath.lastSegment();
+                       prefixPath= prefixPath.removeLastSegments(1);
+                       if (prefixPath.segmentCount() > 0) {
+                               directory= directory.append(prefixPath);
+                       }
+               }
+               final File fileDir = directory.toFile();
+               if (!fileDir.exists()) {
+                       return;
+               }
+               final int prefixLength = namePrefix.length();
+               final IProject project= tu.getCProject().getProject();
+               File[] files= fileDir.listFiles();
+               IContentAssistMatcher matcher = ContentAssistMatcherFactory.getInstance().createMatcher(namePrefix);
+               for (File file : files) {
+                       final String name= file.getName();
+                       if (name.length() >= prefixLength && matcher.match(name.toCharArray())) {
+                               if (file.isFile()) {
+                                       if (CoreModel.isValidCXXHeaderUnitName(project, name) || CoreModel.isValidCHeaderUnitName(project, name)) {
+                                               includeFiles.add(prefixPath.append(name).toString());
+                                       }
+                               } else if (file.isDirectory()) {
+                                       includeFiles.add(prefixPath.append(name).addTrailingSeparator().toString());
+                               }
+                       }
+               }
+       }
+
+       /**
+        * Collect include files from the given resource container.
+        * 
+        * @param tu  the translation unit to include the file
+        * @param parent  the resource container
+        * @param prefixPath  the path part to match the sub-directory and file name
+        * @param includeFiles  the result list
+        * @throws CoreException
+        */
+       private void collectIncludeFilesFromContainer(final ITranslationUnit tu, IContainer parent, IPath prefixPath, final List<String> includeFiles) throws CoreException {
+               final String namePrefix;
+               if (prefixPath.segmentCount() == 0) {
+                       namePrefix= ""; //$NON-NLS-1$
+               } else if (prefixPath.hasTrailingSeparator()) {
+                       namePrefix= ""; //$NON-NLS-1$
+                       prefixPath= prefixPath.removeTrailingSeparator();
+               } else {
+                       namePrefix= prefixPath.lastSegment();
+                       prefixPath= prefixPath.removeLastSegments(1);
+               }
+               if (prefixPath.segmentCount() > 0) {
+                       IPath parentPath = parent.getFullPath().append(prefixPath);
+                       if (parentPath.segmentCount() > 1) {
+                               parent = parent.getFolder(prefixPath);
+                       } else if (parentPath.segmentCount() == 1) {
+                               parent = ResourcesPlugin.getWorkspace().getRoot().getProject(parentPath.lastSegment());
+                       } else {
+                               return;
+                       }
+               }
+               if (!parent.exists()) {
+                       return;
+               }
+               final IPath cPrefixPath= prefixPath;
+               final int prefixLength = namePrefix.length();
+               final IContentAssistMatcher matcher = ContentAssistMatcherFactory.getInstance().createMatcher(namePrefix);
+               final IProject project= tu.getCProject().getProject();
+               parent.accept(new IResourceProxyVisitor() {
+                       boolean fFirstVisit= true;
+                       public boolean visit(IResourceProxy proxy) throws CoreException {
+                               final int type= proxy.getType();
+                               final String name= proxy.getName();
+                               if (fFirstVisit) {
+                                       fFirstVisit= false;
+                                       return true;
+                               }
+                               if (name.length() >= prefixLength && matcher.match(name.toCharArray())) {
+                                       if (type == IResource.FILE) {
+                                               if (CoreModel.isValidCXXHeaderUnitName(project, name) || CoreModel.isValidCHeaderUnitName(project, name)) {
+                                                       includeFiles.add(cPrefixPath.append(name).toString());
+                                               }
+                                       } else if (type == IResource.FOLDER) {
+                                               includeFiles.add(cPrefixPath.append(name).addTrailingSeparator().toString());
+                                       }
+                               }
+                               return false;
+                       }}, IResource.DEPTH_ONE);
+       }
+
+       /**
+        * Compute the file name portion in an incomplete include directive.
+        * 
+        * @param context
+        * @return the file name portion including the opening bracket or quote
+        * @throws BadLocationException
+        */
+       private String computeIncludePrefix(CContentAssistInvocationContext context) throws BadLocationException {
+               IDocument document= context.getDocument();
+               if (document == null)
+                       return null;
+               int end= context.getInvocationOffset();
+               int start= end;
+               while (--start >= 0) {
+                       final char ch= document.getChar(start);
+                       if (ch == '"' || ch == '<')
+                               break;
+               }
+               return document.get(start, end - start);
+       }
+
+
+       /**
+        * Compute base relevance depending on quality of name / prefix match.
+        * 
+        * @param prefix  the completion pefix
+        * @param match  the matching identifier
+        * @return a relevance value inidicating the quality of the name match
+        */
+       protected int computeRelevance(String prefix, String match) {
+               int baseRelevance= 0;
+               boolean caseMatch= prefix.length() > 0 && match.startsWith(prefix);
+               if (caseMatch) {
+                       baseRelevance += RelevanceConstants.CASE_MATCH_RELEVANCE;
+               }
+               return baseRelevance;
+       }
+
+       private CCompletionProposal createProposal(int repOffset, int repLength, String repString, String dispString, Image image, int relevance, CContentAssistInvocationContext context) {
+               return new CCompletionProposal(repString, repOffset, repLength, image, dispString, dispString, relevance, context.getViewer());
+       }
+
+       private Image getImage(ImageDescriptor desc) {
+               return desc != null ? CUIPlugin.getImageDescriptorRegistry().get(desc) : null;
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/KeywordCompletionProposalComputer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/KeywordCompletionProposalComputer.java
new file mode 100644 (file)
index 0000000..6205757
--- /dev/null
@@ -0,0 +1,193 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Bryan Wilkinson (QNX) - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.contentassist;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.swt.graphics.Image;
+
+import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
+import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.model.ICLanguageKeywords;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
+
+public class KeywordCompletionProposalComputer extends ParsingBasedProposalComputer {
+
+       private static final int MIN_KEYWORD_LENGTH = 5;
+       
+       @Override
+       protected List<ICompletionProposal> computeCompletionProposals(
+                       CContentAssistInvocationContext context,
+                       IASTCompletionNode completionNode, String prefix)
+                       throws CoreException {
+
+               if (prefix.length() == 0) {
+                       try {
+                               prefix= context.computeIdentifierPrefix().toString();
+                       } catch (BadLocationException exc) {
+                               CUIPlugin.log(exc);
+                       }
+               }
+               final int prefixLength = prefix.length();
+               // No prefix, no completions
+        if (prefixLength == 0 || context.isContextInformationStyle())
+            return Collections.emptyList();
+
+        // keywords are matched case-sensitive
+               final int relevance = RelevanceConstants.CASE_MATCH_RELEVANCE + RelevanceConstants.KEYWORD_TYPE_RELEVANCE;
+
+               List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
+
+               ICLanguageKeywords languageKeywords = null;
+               ITranslationUnit tu = context.getTranslationUnit();
+        if(tu != null) {
+               ILanguage language = tu.getLanguage();
+               if(language != null)
+                       languageKeywords = (ICLanguageKeywords) language.getAdapter(ICLanguageKeywords.class);
+        }
+               
+        if(languageKeywords == null)
+               return Collections.emptyList();
+        
+               
+               if (inPreprocessorDirective(context)) {
+                       // TODO split this into a separate proposal computer?
+                       boolean needDirectiveKeyword= inPreprocessorKeyword(context);
+
+                       // add matching preprocessor keyword proposals
+                       ImageDescriptor imagedesc = CElementImageProvider.getKeywordImageDescriptor();
+                       Image image = imagedesc != null ? CUIPlugin.getImageDescriptorRegistry().get(imagedesc) : null;
+                       
+                       for(String keyword : languageKeywords.getPreprocessorKeywords()) {
+                               if (keyword.startsWith(prefix) && keyword.length() > prefixLength) {
+                                       String repString = keyword + ' ';
+                                       int repLength = prefixLength;
+                                       int repOffset = context.getInvocationOffset() - repLength;
+                                       if (prefix.charAt(0) == '#') {
+                                               // strip leading '#' from replacement
+                                               repLength--;
+                                               repOffset++;
+                                               repString= repString.substring(1);
+                                       } else if (needDirectiveKeyword) {
+                                               continue;
+                                       }
+                                       proposals.add(new CCompletionProposal(repString, repOffset,
+                                                       repLength, image, keyword, relevance, context.getViewer()));
+                               }
+                       }
+               } else {
+               if (!isValidContext(completionNode))
+                   return Collections.emptyList();
+               
+                       // add matching keyword proposals
+               ImageDescriptor imagedesc = CElementImageProvider.getKeywordImageDescriptor();
+               Image image = imagedesc != null ? CUIPlugin.getImageDescriptorRegistry().get(imagedesc) : null;
+               
+               for(String keyword : languageKeywords.getKeywords()) {
+                   if (keyword.startsWith(prefix) && keyword.length() > prefixLength && keyword.length() >= MIN_KEYWORD_LENGTH) {
+                       int repLength = prefixLength;
+                       int repOffset = context.getInvocationOffset() - repLength;
+                       proposals.add(new CCompletionProposal(keyword, repOffset,
+                                                       repLength, image, keyword, relevance, context.getViewer()));
+                   }
+               }
+               }
+        
+        return proposals;
+       }
+
+       /**
+        * Checks whether the given invocation context looks valid for template completion.
+        * 
+        * @param context  the content assist invocation context
+        * @return <code>false</code> if the given invocation context looks like a field reference
+        */
+       private boolean isValidContext(IASTCompletionNode completionNode) {
+               IASTName[] names = completionNode.getNames();
+               for (int i = 0; i < names.length; ++i) {
+                       IASTName name = names[i];
+                       
+                       // ignore if not connected
+                       if (name.getTranslationUnit() == null)
+                               continue;
+               
+                       // ignore if this is a member access
+                       if (name.getParent() instanceof IASTFieldReference)
+                               continue;
+                       
+                       return true;
+               }
+               
+               return false;
+       }
+
+       /**
+        * Test whether the invocation offset is inside or before the preprocessor directive keyword.
+        * 
+        * @param context  the invocation context
+        * @return <code>true</code> if the invocation offset is inside or before the directive keyword
+        */
+       private boolean inPreprocessorKeyword(CContentAssistInvocationContext context) {
+               IDocument doc = context.getDocument();
+               int offset = context.getInvocationOffset();
+               
+               try {
+                       final ITypedRegion partition= TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, offset, true);
+                       if (ICPartitions.C_PREPROCESSOR.equals(partition.getType())) {
+                               String ppPrefix= doc.get(partition.getOffset(), offset - partition.getOffset());
+                               if (ppPrefix.matches("\\s*#\\s*\\w*")) { //$NON-NLS-1$
+                                       // we are inside the directive keyword
+                                       return true;
+                               }
+                       }
+                       
+               } catch (BadLocationException exc) {
+               }
+               return false;
+       }
+
+       /**
+        * Check if the invocation offset is inside a preprocessor directive.
+        * 
+        * @param context  the content asist invocation context
+        * @return <code>true</code> if invocation offset is inside a preprocessor directive
+        */
+       private boolean inPreprocessorDirective(CContentAssistInvocationContext context) {
+               IDocument doc = context.getDocument();
+               int offset = context.getInvocationOffset();
+               
+               try {
+                       final ITypedRegion partition= TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, offset, true);
+                       if (ICPartitions.C_PREPROCESSOR.equals(partition.getType())) {
+                               return true;
+                       }
+                       
+               } catch (BadLocationException exc) {
+               }
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParsingBasedProposalComputer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParsingBasedProposalComputer.java
new file mode 100644 (file)
index 0000000..0ecae2a
--- /dev/null
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    QNX - Initial API and implementation
+ *    Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.contentassist;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+
+import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext;
+import org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer;
+
+/**
+ * The base class for any proposal computers that require a completion node in
+ * order to determine its completion proposals.
+ * 
+ * @author Bryan Wilkinson
+ */
+public abstract class ParsingBasedProposalComputer implements ICompletionProposalComputer {
+
+       private String fErrorMessage = null;
+       
+       public List<ICompletionProposal> computeCompletionProposals(
+                       ContentAssistInvocationContext context, IProgressMonitor monitor) {
+               try {
+                       if (context instanceof CContentAssistInvocationContext) {
+                               CContentAssistInvocationContext cContext = (CContentAssistInvocationContext) context;
+                               
+                               IASTCompletionNode completionNode = cContext.getCompletionNode();
+                               if (completionNode == null) 
+                                       return Collections.emptyList();
+                               String prefix = completionNode.getPrefix();
+                               if (prefix == null) {
+                                       prefix = cContext.computeIdentifierPrefix().toString();
+                               }
+
+                               return computeCompletionProposals(cContext, completionNode, prefix);
+                       }
+               } catch (Exception e) {
+                       fErrorMessage = e.toString();
+                       CUIPlugin.log(e);
+               }
+
+               return Collections.emptyList();
+       }
+       
+       protected abstract List<ICompletionProposal> computeCompletionProposals(
+                       CContentAssistInvocationContext context,
+                       IASTCompletionNode completionNode,
+                       String prefix) throws CoreException;
+       
+       public List<IContextInformation> computeContextInformation(
+                       ContentAssistInvocationContext context, IProgressMonitor monitor) {
+               Collection<ICompletionProposal> proposals= computeCompletionProposals(context, monitor);
+               // remove duplicates
+               
+               proposals= (new LinkedHashSet<ICompletionProposal>(proposals));
+               List<IContextInformation> result= new ArrayList<IContextInformation>();
+               for (ICompletionProposal proposal : proposals) {
+                       IContextInformation contextInformation= proposal.getContextInformation();
+                       if (contextInformation != null) {
+                               result.add(contextInformation);
+                       }
+               }
+               
+               return result;
+       }
+
+       public String getErrorMessage() {
+               return fErrorMessage;
+       }
+
+       public void sessionEnded() {
+       }
+
+       public void sessionStarted() {
+               fErrorMessage = null;
+       }
+
+       /**
+        * Compute base relevance depending on quality of name / prefix match.
+        * 
+        * @param prefix  the completion pefix
+        * @param match  the matching identifier
+        * @return a relevance value inidicating the quality of the name match
+        */
+       protected int computeBaseRelevance(String prefix, String match) {
+               boolean caseMatch= prefix.length() > 0 && match.startsWith(prefix);
+               if (caseMatch) {
+                       return RelevanceConstants.CASE_MATCH_RELEVANCE;
+               }
+               boolean exactNameMatch= match.equalsIgnoreCase(prefix);
+               if (exactNameMatch) {
+                       return RelevanceConstants.EXACT_NAME_MATCH_RELEVANCE;
+               }
+               return 0;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/RelevanceConstants.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/RelevanceConstants.java
new file mode 100644 (file)
index 0000000..e31ebc0
--- /dev/null
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Rational Software - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.contentassist;
+
+public interface RelevanceConstants {
+       /** Relevance increment for same case matches */
+       final int CASE_MATCH_RELEVANCE = 1000;
+
+       /** Relevance increment for exact name matches (disregarding case) */
+       final int EXACT_NAME_MATCH_RELEVANCE = 40;
+       
+       /** Relevance constant for proposals contributed by help provider */
+       final int HELP_TYPE_RELEVANCE = 200;
+
+       // parsing-based relevance constants
+       final int LOCAL_VARIABLE_TYPE_RELEVANCE = 140;
+       final int FIELD_TYPE_RELEVANCE = 130;
+       final int METHOD_TYPE_RELEVANCE = 120;
+       final int VARIABLE_TYPE_RELEVANCE = 110;
+       final int FUNCTION_TYPE_RELEVANCE = 100;
+       final int CLASS_TYPE_RELEVANCE = 90;
+       final int STRUCT_TYPE_RELEVANCE = 80;
+       final int UNION_TYPE_RELEVANCE = 70;
+       final int TYPEDEF_TYPE_RELEVANCE = 60;
+       final int NAMESPACE_TYPE_RELEVANCE = 50;
+       final int ENUMERATOR_TYPE_RELEVANCE = 40;
+       final int ENUMERATION_TYPE_RELEVANCE = 30;
+       final int DEFAULT_TYPE_RELEVANCE = 20;
+       final int MACRO_TYPE_RELEVANCE = 15;
+
+       /** Relevance constant for (key-)word proposals */
+       final int KEYWORD_TYPE_RELEVANCE = 10;
+       
+       /** Relevance constant for editor template proposals */
+       final int TEMPLATE_TYPE_RELEVANCE = 5;
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/TemplateCompletionProposalComputer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/TemplateCompletionProposalComputer.java
new file mode 100644 (file)
index 0000000..9638894
--- /dev/null
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.contentassist;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.templates.TemplateContextType;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.ICPartitions;
+import org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext;
+import org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer;
+
+import org.eclipse.cdt.internal.corext.template.c.CContextType;
+import org.eclipse.cdt.internal.corext.template.c.CommentContextType;
+import org.eclipse.cdt.internal.corext.template.c.DocCommentContextType;
+
+import org.eclipse.cdt.internal.ui.text.CHeuristicScanner;
+import org.eclipse.cdt.internal.ui.text.template.TemplateEngine;
+
+/**
+ * A completion proposal computer for templates.
+ *
+ * @since 4.0
+ */
+public class TemplateCompletionProposalComputer implements ICompletionProposalComputer {
+
+       private final TemplateEngine fCTemplateEngine;
+       private final TemplateEngine fCommentTemplateEngine;
+       private final TemplateEngine fDocCommentTemplateEngine;
+
+       /**
+        * Default constructor is required (executable extension).
+        */
+       public TemplateCompletionProposalComputer() {
+               TemplateContextType contextType= CUIPlugin.getDefault().getTemplateContextRegistry().getContextType(CContextType.ID);
+               if (contextType == null) {
+                       contextType= new CContextType();
+                       CUIPlugin.getDefault().getTemplateContextRegistry().addContextType(contextType);
+               }
+               fCTemplateEngine= new TemplateEngine(contextType);
+               contextType= CUIPlugin.getDefault().getTemplateContextRegistry().getContextType(CommentContextType.ID);
+               if (contextType == null) {
+                       contextType= new CommentContextType();
+                       CUIPlugin.getDefault().getTemplateContextRegistry().addContextType(contextType);
+               }
+               fCommentTemplateEngine= new TemplateEngine(contextType);
+               contextType= CUIPlugin.getDefault().getTemplateContextRegistry().getContextType(DocCommentContextType.ID);
+               if (contextType == null) {
+                       contextType= new DocCommentContextType();
+                       CUIPlugin.getDefault().getTemplateContextRegistry().addContextType(contextType);
+               }
+               fDocCommentTemplateEngine= new TemplateEngine(contextType);
+       }
+       
+       /*
+        * @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#computeCompletionProposals(org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
+        */
+       public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+               ITextViewer viewer= context.getViewer();
+               int offset= context.getInvocationOffset();
+               TemplateEngine engine= null;
+               try {
+                       String partition= TextUtilities.getContentType(viewer.getDocument(), ICPartitions.C_PARTITIONING, offset, true);
+                       if (partition.equals(ICPartitions.C_MULTI_LINE_COMMENT) || partition.equals(ICPartitions.C_SINGLE_LINE_COMMENT)) {
+                               engine= fCommentTemplateEngine;
+                       } else if (partition.equals(ICPartitions.C_MULTI_LINE_DOC_COMMENT) || partition.equals(ICPartitions.C_SINGLE_LINE_DOC_COMMENT)) {
+                               engine= fDocCommentTemplateEngine;
+                       } else {
+                               if (isValidContext(context)) {
+                                       engine= fCTemplateEngine;
+                               }
+                       }
+               } catch (BadLocationException x) {
+                       return Collections.emptyList();
+               }
+               
+               if (engine != null && context instanceof CContentAssistInvocationContext) {
+                       CContentAssistInvocationContext cContext= (CContentAssistInvocationContext)context;
+                       ITranslationUnit tUnit = cContext.getTranslationUnit();
+                       if (tUnit == null) {
+                               return Collections.emptyList();
+                       }
+                       engine.reset();
+                       engine.complete(viewer, offset, tUnit);
+
+                       List<ICompletionProposal> result= engine.getResults();
+
+                       return result;
+               }
+               return Collections.emptyList();
+       }
+
+       /**
+        * Checks whether the given invocation context looks valid for template completion.
+        * 
+        * @param context  the content assist invocation context
+        * @return <code>false</code> if the given invocation context looks like a field reference
+        */
+       private boolean isValidContext(ContentAssistInvocationContext context) {
+               CHeuristicScanner scanner= new CHeuristicScanner(context.getDocument());
+               int start= context.getInvocationOffset();
+               return !scanner.looksLikeFieldReferenceBackward(start, Math.max(0, start-100));
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#computeContextInformation(org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
+        */
+       public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+               return Collections.emptyList();
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#getErrorMessage()
+        */
+       public String getErrorMessage() {
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#sessionStarted()
+        */
+       public void sessionStarted() {
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#sessionEnded()
+        */
+       public void sessionEnded() {
+               if (fCommentTemplateEngine != null) {
+                       fCommentTemplateEngine.reset();
+               }
+               if (fCTemplateEngine != null) {
+                       fCTemplateEngine.reset();
+               }
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionAssistant.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionAssistant.java
new file mode 100644 (file)
index 0000000..090d817
--- /dev/null
@@ -0,0 +1,338 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *        Sergey Prigogin (Google)
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.correction;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DefaultInformationControl;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IInformationControl;
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.quickassist.IQuickAssistAssistant;
+import org.eclipse.jface.text.quickassist.QuickAssistAssistant;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPreferenceConstants;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.IColorManager;
+
+import org.eclipse.cdt.internal.core.model.ASTCache;
+
+import org.eclipse.cdt.internal.ui.editor.ASTProvider;
+import org.eclipse.cdt.internal.ui.text.CTextTools;
+
+public class CCorrectionAssistant extends QuickAssistAssistant {
+       private ITextViewer fViewer;
+       private ITextEditor fEditor;
+       private Position fPosition;
+       private Annotation[] fCurrentAnnotations;
+
+       private QuickAssistLightBulbUpdater fLightBulbUpdater;
+
+       /**
+        * Constructor for CCorrectionAssistant.
+        */
+       public CCorrectionAssistant(ITextEditor editor) {
+               super();
+               Assert.isNotNull(editor);
+               fEditor= editor;
+
+               CCorrectionProcessor processor= new CCorrectionProcessor(this);
+
+               setQuickAssistProcessor(processor);
+               enableColoredLabels(PlatformUI.getPreferenceStore().getBoolean(IWorkbenchPreferenceConstants.USE_COLORED_LABELS));
+
+               setInformationControlCreator(getInformationControlCreator());
+
+               CTextTools textTools= CUIPlugin.getDefault().getTextTools();
+               IColorManager manager= textTools.getColorManager();
+
+               IPreferenceStore store=  CUIPlugin.getDefault().getPreferenceStore();
+
+               Color c= getColor(store, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, manager);
+               setProposalSelectorForeground(c);
+
+               c= getColor(store, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, manager);
+               setProposalSelectorBackground(c);
+       }
+
+       public IEditorPart getEditor() {
+               return fEditor;
+       }
+
+
+       private IInformationControlCreator getInformationControlCreator() {
+               return new IInformationControlCreator() {
+                       public IInformationControl createInformationControl(Shell parent) {
+                               return new DefaultInformationControl(parent, false);
+                       }
+               };
+       }
+
+       private static Color getColor(IPreferenceStore store, String key, IColorManager manager) {
+               RGB rgb= PreferenceConverter.getColor(store, key);
+               return manager.getColor(rgb);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.text.contentassist.IContentAssistant#install(org.eclipse.jface.text.ITextViewer)
+        */
+       @Override
+       public void install(ISourceViewer sourceViewer) {
+               super.install(sourceViewer);
+               fViewer= sourceViewer;
+
+               fLightBulbUpdater= new QuickAssistLightBulbUpdater(fEditor, sourceViewer);
+               fLightBulbUpdater.install();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.text.contentassist.ContentAssistant#uninstall()
+        */
+       @Override
+       public void uninstall() {
+               if (fLightBulbUpdater != null) {
+                       fLightBulbUpdater.uninstall();
+                       fLightBulbUpdater= null;
+               }
+               super.uninstall();
+       }
+
+       /**
+        * Show completions at caret position. If current
+        * position does not contain quick fixes look for
+        * next quick fix on same line by moving from left
+        * to right and restarting at end of line if the
+        * beginning of the line is reached.
+        *
+        * @see IQuickAssistAssistant#showPossibleQuickAssists()
+        */
+       @Override
+       public String showPossibleQuickAssists() {
+               fPosition= null;
+               fCurrentAnnotations= null;
+               
+               if (fViewer == null || fViewer.getDocument() == null)
+                       // Let superclass deal with this
+                       return super.showPossibleQuickAssists();
+
+
+               ArrayList<Annotation> resultingAnnotations= new ArrayList<Annotation>(20);
+               try {
+                       Point selectedRange= fViewer.getSelectedRange();
+                       int currOffset= selectedRange.x;
+                       int currLength= selectedRange.y;
+                       boolean goToClosest= (currLength == 0);
+                       
+                       int newOffset= collectQuickFixableAnnotations(fEditor, currOffset, goToClosest, resultingAnnotations);
+                       if (newOffset != currOffset) {
+                               storePosition(currOffset, currLength);
+                               fViewer.setSelectedRange(newOffset, 0);
+                               fViewer.revealRange(newOffset, 0);
+                       }
+               } catch (BadLocationException e) {
+                       CUIPlugin.log(e);
+               }
+               fCurrentAnnotations= resultingAnnotations.toArray(new Annotation[resultingAnnotations.size()]);
+
+               return super.showPossibleQuickAssists();
+       }
+       
+       
+       private static IRegion getRegionOfInterest(ITextEditor editor, int invocationLocation) throws BadLocationException {
+               IDocumentProvider documentProvider= editor.getDocumentProvider();
+               if (documentProvider == null) {
+                       return null;
+               }
+               IDocument document= documentProvider.getDocument(editor.getEditorInput());
+               if (document == null) {
+                       return null;
+               }
+               return document.getLineInformationOfOffset(invocationLocation);
+       }
+       
+       public static int collectQuickFixableAnnotations(ITextEditor editor, int invocationLocation, boolean goToClosest, ArrayList<Annotation> resultingAnnotations) throws BadLocationException {
+               IAnnotationModel model= CUIPlugin.getDefault().getDocumentProvider().getAnnotationModel(editor.getEditorInput());
+               if (model == null) {
+                       return invocationLocation;
+               }
+               
+               ensureUpdatedAnnotations(editor);
+               
+               Iterator<?> iter= model.getAnnotationIterator();
+               if (goToClosest) {
+                       IRegion lineInfo= getRegionOfInterest(editor, invocationLocation);
+                       if (lineInfo == null) {
+                               return invocationLocation;
+                       }
+                       int rangeStart= lineInfo.getOffset();
+                       int rangeEnd= rangeStart + lineInfo.getLength();
+                       
+                       ArrayList<Annotation> allAnnotations= new ArrayList<Annotation>();
+                       ArrayList<Position> allPositions= new ArrayList<Position>();
+                       int bestOffset= Integer.MAX_VALUE;
+                       while (iter.hasNext()) {
+                               Annotation annot= (Annotation) iter.next();
+                               if (CCorrectionProcessor.isQuickFixableType(annot)) {
+                                       Position pos= model.getPosition(annot);
+                                       if (pos != null && isInside(pos.offset, rangeStart, rangeEnd)) { // inside our range?
+                                               allAnnotations.add(annot);
+                                               allPositions.add(pos);
+                                               bestOffset= processAnnotation(annot, pos, invocationLocation, bestOffset);
+                                       }
+                               }
+                       }
+                       if (bestOffset == Integer.MAX_VALUE) {
+                               return invocationLocation;
+                       }
+                       for (int i= 0; i < allPositions.size(); i++) {
+                               Position pos= allPositions.get(i);
+                               if (isInside(bestOffset, pos.offset, pos.offset + pos.length)) {
+                                       resultingAnnotations.add(allAnnotations.get(i));
+                               }
+                       }
+                       return bestOffset;
+               }
+               while (iter.hasNext()) {
+                       Annotation annot= (Annotation) iter.next();
+                       if (CCorrectionProcessor.isQuickFixableType(annot)) {
+                               Position pos= model.getPosition(annot);
+                               if (pos != null && isInside(invocationLocation, pos.offset, pos.offset + pos.length)) {
+                                       resultingAnnotations.add(annot);
+                               }
+                       }
+               }
+               return invocationLocation;
+       }
+
+       private static void ensureUpdatedAnnotations(ITextEditor editor) {
+               Object inputElement= editor.getEditorInput().getAdapter(ICElement.class);
+               if (inputElement instanceof ITranslationUnit) {
+                       final ASTProvider astProvider= CUIPlugin.getDefault().getASTProvider();
+                       astProvider.runOnAST((ITranslationUnit) inputElement, ASTProvider.WAIT_ACTIVE_ONLY, null, new ASTCache.ASTRunnable() {
+                               public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
+                                       return Status.OK_STATUS;
+                               }
+                       });
+               }
+       }
+
+       private static int processAnnotation(Annotation annot, Position pos, int invocationLocation, int bestOffset) {
+               int posBegin= pos.offset;
+               int posEnd= posBegin + pos.length;
+               if (isInside(invocationLocation, posBegin, posEnd)) { // covers invocation location?
+                       return invocationLocation;
+               } else if (bestOffset != invocationLocation) {
+                       int newClosestPosition= computeBestOffset(posBegin, invocationLocation, bestOffset);
+                       if (newClosestPosition != -1) { 
+                               if (newClosestPosition != bestOffset) { // new best
+                                       if (CCorrectionProcessor.hasCorrections(annot)) { // only jump to it if there are proposals
+                                               return newClosestPosition;
+                                       }
+                               }
+                       }
+               }
+               return bestOffset;
+       }
+
+       private static boolean isInside(int offset, int start, int end) {
+               return offset == start || offset == end || (offset > start && offset < end); // make sure to handle 0-length ranges
+       }
+
+       /**
+        * Computes and returns the invocation offset given a new
+        * position, the initial offset and the best invocation offset
+        * found so far.
+        * <p>
+        * The closest offset to the left of the initial offset is the
+        * best. If there is no offset on the left, the closest on the
+        * right is the best.</p>
+        * @return -1 is returned if the given offset is not closer or the new best offset
+        */
+       private static int computeBestOffset(int newOffset, int invocationLocation, int bestOffset) {
+               if (newOffset <= invocationLocation) {
+                       if (bestOffset > invocationLocation) {
+                               return newOffset; // closest was on the right, prefer on the left
+                       } else if (bestOffset <= newOffset) {
+                               return newOffset; // we are closer or equal
+                       }
+                       return -1; // further away
+               }
+
+               if (newOffset <= bestOffset)
+                       return newOffset; // we are closer or equal
+
+               return -1; // further away
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ContentAssistant#possibleCompletionsClosed()
+        */
+       @Override
+       protected void possibleCompletionsClosed() {
+               super.possibleCompletionsClosed();
+               restorePosition();
+       }
+
+       private void storePosition(int currOffset, int currLength) {
+               fPosition= new Position(currOffset, currLength);
+       }
+
+       private void restorePosition() {
+               if (fPosition != null && !fPosition.isDeleted() && fViewer.getDocument() != null) {
+                       fViewer.setSelectedRange(fPosition.offset, fPosition.length);
+                       fViewer.revealRange(fPosition.offset, fPosition.length);
+               }
+               fPosition= null;
+       }
+
+       /**
+        * Returns true if the last invoked completion was called with an updated offset.
+        */
+       public boolean isUpdatedOffset() {
+               return fPosition != null;
+       }
+
+       /**
+        * Returns the annotations at the current offset
+        */
+       public Annotation[] getAnnotationsAtOffset() {
+               return fCurrentAnnotations;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionProcessor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionProcessor.java
new file mode 100644 (file)
index 0000000..77d9cc5
--- /dev/null
@@ -0,0 +1,497 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *        Sergey Prigogin (Google)
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.correction;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.ISafeRunnable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.contentassist.ContentAssistEvent;
+import org.eclipse.jface.text.contentassist.ICompletionListener;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ltk.core.refactoring.NullChange;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IMarkerHelpRegistry;
+import org.eclipse.ui.IMarkerResolution;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.texteditor.SimpleMarkerAnnotation;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.ICCompletionProposal;
+import org.eclipse.cdt.ui.text.IInvocationContext;
+import org.eclipse.cdt.ui.text.IProblemLocation;
+import org.eclipse.cdt.ui.text.IQuickAssistProcessor;
+import org.eclipse.cdt.ui.text.IQuickFixProcessor;
+
+import org.eclipse.cdt.internal.ui.editor.ICAnnotation;
+import org.eclipse.cdt.internal.ui.text.contentassist.CCompletionProposalComparator;
+import org.eclipse.cdt.internal.ui.text.correction.proposals.ChangeCorrectionProposal;
+
+public class CCorrectionProcessor implements org.eclipse.jface.text.quickassist.IQuickAssistProcessor {
+       private static final String QUICKFIX_PROCESSOR_CONTRIBUTION_ID= "quickFixProcessors"; //$NON-NLS-1$
+       private static final String QUICKASSIST_PROCESSOR_CONTRIBUTION_ID= "quickAssistProcessors"; //$NON-NLS-1$
+
+       private static ContributedProcessorDescriptor[] fgContributedAssistProcessors= null;
+       private static ContributedProcessorDescriptor[] fgContributedCorrectionProcessors= null;
+
+       private static ContributedProcessorDescriptor[] getProcessorDescriptors(String contributionId, boolean testMarkerTypes) {
+               IConfigurationElement[] elements= Platform.getExtensionRegistry().getConfigurationElementsFor(CUIPlugin.PLUGIN_ID, contributionId);
+               ArrayList<ContributedProcessorDescriptor> res= new ArrayList<ContributedProcessorDescriptor>(elements.length);
+
+               for (int i= 0; i < elements.length; i++) {
+                       ContributedProcessorDescriptor desc= new ContributedProcessorDescriptor(elements[i], testMarkerTypes);
+                       IStatus status= desc.checkSyntax();
+                       if (status.isOK()) {
+                               res.add(desc);
+                       } else {
+                               CUIPlugin.log(status);
+                       }
+               }
+               return res.toArray(new ContributedProcessorDescriptor[res.size()]);
+       }
+
+       private static ContributedProcessorDescriptor[] getCorrectionProcessors() {
+               if (fgContributedCorrectionProcessors == null) {
+                       fgContributedCorrectionProcessors= getProcessorDescriptors(QUICKFIX_PROCESSOR_CONTRIBUTION_ID, true);
+               }
+               return fgContributedCorrectionProcessors;
+       }
+
+       private static ContributedProcessorDescriptor[] getAssistProcessors() {
+               if (fgContributedAssistProcessors == null) {
+                       fgContributedAssistProcessors= getProcessorDescriptors(QUICKASSIST_PROCESSOR_CONTRIBUTION_ID, false);
+               }
+               return fgContributedAssistProcessors;
+       }
+
+       public static boolean hasCorrections(ITranslationUnit tu, int problemId, String markerType) {
+               ContributedProcessorDescriptor[] processors= getCorrectionProcessors();
+               SafeHasCorrections collector= new SafeHasCorrections(tu, problemId);
+               for (int i= 0; i < processors.length; i++) {
+                       if (processors[i].canHandleMarkerType(markerType)) {
+                               collector.process(processors[i]);
+                               if (collector.hasCorrections()) {
+                                       return true;
+                               }
+                       }
+               }
+               return false;
+       }
+
+       public static boolean isQuickFixableType(Annotation annotation) {
+               return (annotation instanceof ICAnnotation || annotation instanceof SimpleMarkerAnnotation) && !annotation.isMarkedDeleted();
+       }
+
+       public static boolean hasCorrections(Annotation annotation) {
+               if (annotation instanceof ICAnnotation) {
+                       ICAnnotation cAnnotation= (ICAnnotation) annotation;
+                       int problemId= cAnnotation.getId();
+                       if (problemId != -1) {
+                               ITranslationUnit tu= cAnnotation.getTranslationUnit();
+                               if (tu != null) {
+                                       return hasCorrections(tu, problemId, cAnnotation.getMarkerType());
+                               }
+                       }
+               }
+               if (annotation instanceof SimpleMarkerAnnotation) {
+                       return hasCorrections(((SimpleMarkerAnnotation) annotation).getMarker());
+               }
+               return false;
+       }
+
+       private static boolean hasCorrections(IMarker marker) {
+               if (marker == null || !marker.exists())
+                       return false;
+
+               IMarkerHelpRegistry registry= IDE.getMarkerHelpRegistry();
+               return registry != null && registry.hasResolutions(marker);
+       }
+
+       public static boolean hasAssists(CorrectionContext context) {
+               ContributedProcessorDescriptor[] processors= getAssistProcessors();
+               SafeHasAssist collector= new SafeHasAssist(context);
+
+               for (int i= 0; i < processors.length; i++) {
+                       collector.process(processors[i]);
+                       if (collector.hasAssists()) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+       private CCorrectionAssistant fAssistant;
+       private String fErrorMessage;
+
+       /*
+        * Constructor for CCorrectionProcessor.
+        */
+       public CCorrectionProcessor(CCorrectionAssistant assistant) {
+               fAssistant= assistant;
+               fAssistant.addCompletionListener(new ICompletionListener() {
+               
+                       public void assistSessionEnded(ContentAssistEvent event) {
+                               fAssistant.setStatusLineVisible(false);
+                       }
+               
+                       public void assistSessionStarted(ContentAssistEvent event) {
+                               fAssistant.setStatusLineVisible(true);
+                       }
+
+                       public void selectionChanged(ICompletionProposal proposal, boolean smartToggle) {
+                               if (proposal instanceof IStatusLineProposal) {
+                                       IStatusLineProposal statusLineProposal= (IStatusLineProposal)proposal;
+                                       String message= statusLineProposal.getStatusMessage();
+                                       if (message != null) {
+                                               fAssistant.setStatusMessage(message);
+                                       } else {
+                                               fAssistant.setStatusMessage(""); //$NON-NLS-1$
+                                       }
+                               } else {
+                                       fAssistant.setStatusMessage(""); //$NON-NLS-1$
+                               }
+                       }
+               });
+       }
+
+       /*
+        * @see IContentAssistProcessor#computeCompletionProposals(ITextViewer, int)
+        */
+       public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext quickAssistContext) {
+               ISourceViewer viewer= quickAssistContext.getSourceViewer();
+               int documentOffset= quickAssistContext.getOffset();
+               
+               IEditorPart part= fAssistant.getEditor();
+
+               ITranslationUnit tu= CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(part.getEditorInput());
+               IAnnotationModel model= CUIPlugin.getDefault().getDocumentProvider().getAnnotationModel(part.getEditorInput());
+               
+               int length= viewer != null ? viewer.getSelectedRange().y : 0;
+               CorrectionContext context= new CorrectionContext(tu, viewer, documentOffset, length);
+
+               Annotation[] annotations= fAssistant.getAnnotationsAtOffset();
+               
+               fErrorMessage= null;
+               
+               ICCompletionProposal[] res= null;
+               if (model != null && annotations != null) {
+                       ArrayList<ICCompletionProposal> proposals= new ArrayList<ICCompletionProposal>(10);
+                       IStatus status= collectProposals(context, model, annotations, true, !fAssistant.isUpdatedOffset(), proposals);
+                       res= proposals.toArray(new ICCompletionProposal[proposals.size()]);
+                       if (!status.isOK()) {
+                               fErrorMessage= status.getMessage();
+                               CUIPlugin.log(status);
+                       }
+               }
+               
+               if (res == null || res.length == 0) {
+                       return new ICCompletionProposal[]
+                                       { new ChangeCorrectionProposal(CorrectionMessages.NoCorrectionProposal_description, new NullChange(""), 0, null) }; //$NON-NLS-1$
+               }
+               if (res.length > 1) {
+                       Arrays.sort(res, new CCompletionProposalComparator());
+               }
+               return res;
+       }
+
+       public static IStatus collectProposals(CorrectionContext context, IAnnotationModel model, Annotation[] annotations, boolean addQuickFixes, boolean addQuickAssists, Collection<ICCompletionProposal> proposals) {
+               ArrayList<ProblemLocation> problems= new ArrayList<ProblemLocation>();
+               
+               // collect problem locations and corrections from marker annotations
+               for (int i= 0; i < annotations.length; i++) {
+                       Annotation curr= annotations[i];
+                       if (curr instanceof ICAnnotation) {
+                               ProblemLocation problemLocation= getProblemLocation((ICAnnotation) curr, model);
+                               if (problemLocation != null) {
+                                       problems.add(problemLocation);
+                               }
+                       }
+                       if (addQuickFixes && curr instanceof SimpleMarkerAnnotation) {
+                               // collect marker proposals
+                               collectMarkerProposals((SimpleMarkerAnnotation) curr, proposals);
+                       }
+               }
+               MultiStatus resStatus= null;
+               
+               IProblemLocation[] problemLocations= problems.toArray(new IProblemLocation[problems.size()]);
+               if (addQuickFixes) {
+                       IStatus status= collectCorrections(context, problemLocations, proposals);
+                       if (!status.isOK()) {
+                               resStatus= new MultiStatus(CUIPlugin.PLUGIN_ID, IStatus.ERROR, CorrectionMessages.CCorrectionProcessor_error_quickfix_message, null);
+                               resStatus.add(status);
+                       }
+               }
+               if (addQuickAssists) {
+                       IStatus status= collectAssists(context, problemLocations, proposals);
+                       if (!status.isOK()) {
+                               if (resStatus == null) {
+                                       resStatus= new MultiStatus(CUIPlugin.PLUGIN_ID, IStatus.ERROR, CorrectionMessages.CCorrectionProcessor_error_quickassist_message, null);
+                               }
+                               resStatus.add(status);
+                       }
+               }
+               if (resStatus != null) {
+                       return resStatus;
+               }
+               return Status.OK_STATUS;
+       }
+       
+       private static ProblemLocation getProblemLocation(ICAnnotation cAnnotation, IAnnotationModel model) {
+               int problemId= cAnnotation.getId();
+               if (problemId != -1) {
+                       Position pos= model.getPosition((Annotation) cAnnotation);
+                       if (pos != null) {
+                               return new ProblemLocation(pos.getOffset(), pos.getLength(), cAnnotation); // java problems all handled by the quick assist processors
+                       }
+               }
+               return null;
+       }
+
+       private static void collectMarkerProposals(SimpleMarkerAnnotation annotation, Collection<ICCompletionProposal> proposals) {
+               IMarker marker= annotation.getMarker();
+               IMarkerResolution[] res= IDE.getMarkerHelpRegistry().getResolutions(marker);
+               if (res.length > 0) {
+                       for (int i= 0; i < res.length; i++) {
+                               proposals.add(new MarkerResolutionProposal(res[i], marker));
+                       }
+               }
+       }
+
+       private static abstract class SafeCorrectionProcessorAccess implements ISafeRunnable {
+               private MultiStatus fMulti= null;
+               private ContributedProcessorDescriptor fDescriptor;
+
+               public void process(ContributedProcessorDescriptor[] desc) {
+                       for (int i= 0; i < desc.length; i++) {
+                               fDescriptor= desc[i];
+                               SafeRunner.run(this);
+                       }
+               }
+
+               public void process(ContributedProcessorDescriptor desc) {
+                       fDescriptor= desc;
+                       SafeRunner.run(this);
+               }
+
+               public void run() throws Exception {
+                       safeRun(fDescriptor);
+               }
+
+               protected abstract void safeRun(ContributedProcessorDescriptor processor) throws Exception;
+
+               public void handleException(Throwable exception) {
+                       if (fMulti == null) {
+                               fMulti= new MultiStatus(CUIPlugin.PLUGIN_ID, IStatus.OK, CorrectionMessages.CCorrectionProcessor_error_status, null);
+                       }
+                       fMulti.merge(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.ERROR, CorrectionMessages.CCorrectionProcessor_error_status, exception));
+               }
+
+               public IStatus getStatus() {
+                       if (fMulti == null) {
+                               return Status.OK_STATUS;
+                       }
+                       return fMulti;
+               }
+       }
+
+       private static class SafeCorrectionCollector extends SafeCorrectionProcessorAccess {
+               private final CorrectionContext fContext;
+               private final Collection<ICCompletionProposal> fProposals;
+               private IProblemLocation[] fLocations;
+
+               public SafeCorrectionCollector(CorrectionContext context, Collection<ICCompletionProposal> proposals) {
+                       fContext= context;
+                       fProposals= proposals;
+               }
+               
+               public void setProblemLocations(IProblemLocation[] locations) {
+                       fLocations= locations;
+               }
+
+               @Override
+               public void safeRun(ContributedProcessorDescriptor desc) throws Exception {
+                       IQuickFixProcessor curr= (IQuickFixProcessor) desc.getProcessor(fContext.getTranslationUnit());
+                       if (curr != null) {
+                               ICCompletionProposal[] res= curr.getCorrections(fContext, fLocations);
+                               if (res != null) {
+                                       for (int k= 0; k < res.length; k++) {
+                                               fProposals.add(res[k]);
+                                       }
+                               }
+                       }
+               }
+       }
+
+       private static class SafeAssistCollector extends SafeCorrectionProcessorAccess {
+               private final IInvocationContext fContext;
+               private final IProblemLocation[] fLocations;
+               private final Collection<ICCompletionProposal> fProposals;
+
+               public SafeAssistCollector(IInvocationContext context, IProblemLocation[] locations, Collection<ICCompletionProposal> proposals) {
+                       fContext= context;
+                       fLocations= locations;
+                       fProposals= proposals;
+               }
+
+               @Override
+               public void safeRun(ContributedProcessorDescriptor desc) throws Exception {
+                       IQuickAssistProcessor curr= (IQuickAssistProcessor) desc.getProcessor(fContext.getTranslationUnit());
+                       if (curr != null) {
+                               ICCompletionProposal[] res= curr.getAssists(fContext, fLocations);
+                               if (res != null) {
+                                       for (int k= 0; k < res.length; k++) {
+                                               fProposals.add(res[k]);
+                                       }
+                               }
+                       }
+               }
+       }
+
+       private static class SafeHasAssist extends SafeCorrectionProcessorAccess {
+               private final CorrectionContext fContext;
+               private boolean fHasAssists;
+
+               public SafeHasAssist(CorrectionContext context) {
+                       fContext= context;
+                       fHasAssists= false;
+               }
+
+               public boolean hasAssists() {
+                       return fHasAssists;
+               }
+
+               @Override
+               public void safeRun(ContributedProcessorDescriptor desc) throws Exception {
+                       IQuickAssistProcessor processor= (IQuickAssistProcessor) desc.getProcessor(fContext.getTranslationUnit());
+                       if (processor != null && processor.hasAssists(fContext)) {
+                               fHasAssists= true;
+                       }
+               }
+       }
+
+       private static class SafeHasCorrections extends SafeCorrectionProcessorAccess {
+               private final ITranslationUnit fCu;
+               private final int fProblemId;
+               private boolean fHasCorrections;
+
+               public SafeHasCorrections(ITranslationUnit tu, int problemId) {
+                       fCu= tu;
+                       fProblemId= problemId;
+                       fHasCorrections= false;
+               }
+
+               public boolean hasCorrections() {
+                       return fHasCorrections;
+               }
+
+               @Override
+               public void safeRun(ContributedProcessorDescriptor desc) throws Exception {
+                       IQuickFixProcessor processor= (IQuickFixProcessor) desc.getProcessor(fCu);
+                       if (processor != null && processor.hasCorrections(fCu, fProblemId)) {
+                               fHasCorrections= true;
+                       }
+               }
+       }
+
+       public static IStatus collectCorrections(CorrectionContext context, IProblemLocation[] locations, Collection<ICCompletionProposal> proposals) {
+               ContributedProcessorDescriptor[] processors= getCorrectionProcessors();
+               SafeCorrectionCollector collector= new SafeCorrectionCollector(context, proposals);
+               for (int i= 0; i < processors.length; i++) {
+                       ContributedProcessorDescriptor curr= processors[i];
+                       IProblemLocation[] handled= getHandledProblems(locations, curr);
+                       if (handled != null) {
+                               collector.setProblemLocations(handled);
+                               collector.process(curr);
+                       }
+               }
+               return collector.getStatus();
+       }
+
+       private static IProblemLocation[] getHandledProblems(IProblemLocation[] locations, ContributedProcessorDescriptor processor) {
+               // implementation tries to avoid creating a new array
+               boolean allHandled= true;
+               ArrayList<IProblemLocation> res= null;
+               for (int i= 0; i < locations.length; i++) {
+                       IProblemLocation curr= locations[i];
+                       if (processor.canHandleMarkerType(curr.getMarkerType())) {
+                               if (!allHandled) { // first handled problem
+                                       if (res == null) {
+                                               res= new ArrayList<IProblemLocation>(locations.length - i);
+                                       }
+                                       res.add(curr);
+                               }
+                       } else if (allHandled) { 
+                               if (i > 0) { // first non handled problem 
+                                       res= new ArrayList<IProblemLocation>(locations.length - i);
+                                       for (int k= 0; k < i; k++) {
+                                               res.add(locations[k]);
+                                       }
+                               }
+                               allHandled= false;
+                       }
+               }
+               if (allHandled) {
+                       return locations;
+               }
+               if (res == null) {
+                       return null;
+               }
+               return res.toArray(new IProblemLocation[res.size()]);
+       }
+
+       public static IStatus collectAssists(CorrectionContext context, IProblemLocation[] locations, Collection<ICCompletionProposal> proposals) {
+               ContributedProcessorDescriptor[] processors= getAssistProcessors();
+               SafeAssistCollector collector= new SafeAssistCollector(context, locations, proposals);
+               collector.process(processors);
+
+               return collector.getStatus();
+       }
+
+       /*
+        * @see IContentAssistProcessor#getErrorMessage()
+        */
+       public String getErrorMessage() {
+               return fErrorMessage;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.quickassist.IQuickAssistProcessor#canFix(org.eclipse.jface.text.source.Annotation)
+        */
+       public boolean canFix(Annotation annotation) {
+               return hasCorrections(annotation);
+       }
+
+       /*
+        * @see org.eclipse.jface.text.quickassist.IQuickAssistProcessor#canAssist(org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext)
+        */
+       public boolean canAssist(IQuickAssistInvocationContext invocationContext) {
+               if (invocationContext instanceof CorrectionContext)
+                       return hasAssists((CorrectionContext) invocationContext);
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CSelectAnnotationRulerAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CSelectAnnotationRulerAction.java
new file mode 100644 (file)
index 0000000..172ce10
--- /dev/null
@@ -0,0 +1,173 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     David Perryman (IPL Information Processing Limited)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.correction;
+
+import java.util.Iterator;
+import java.util.ResourceBundle;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextOperationTarget;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationAccessExtension;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.IVerticalRulerInfo;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
+import org.eclipse.ui.texteditor.AnnotationPreference;
+import org.eclipse.ui.texteditor.AnnotationPreferenceLookup;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.ITextEditorExtension;
+import org.eclipse.ui.texteditor.SelectMarkerRulerAction;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.editor.OverrideIndicatorManager;
+
+/**
+ * Action which gets triggered when selecting (annotations) in the vertical ruler.
+ * based upon org.eclipse.jdt.internal.ui.javaeditor.JavaSelectMarkerRulerAction
+ */
+public class CSelectAnnotationRulerAction extends SelectMarkerRulerAction {
+
+    private ITextEditor fTextEditor;
+    private Position fPosition;
+    private AnnotationPreferenceLookup fAnnotationPreferenceLookup;
+    private IPreferenceStore fStore;
+    private boolean fHasCorrection;
+    private ResourceBundle fBundle;
+       private Annotation fAnnotation;
+
+    public CSelectAnnotationRulerAction(ResourceBundle bundle, String prefix, ITextEditor editor, IVerticalRulerInfo ruler) {
+        super(bundle, prefix, editor, ruler);
+        fBundle= bundle;
+        fTextEditor= editor;
+
+        fAnnotationPreferenceLookup= EditorsUI.getAnnotationPreferenceLookup();
+        fStore= CUIPlugin.getDefault().getCombinedPreferenceStore();
+    }
+
+    @Override
+       public void run() {
+        // is there an equivalent preference for the C Editor?
+        // if (fStore.getBoolean(PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER))
+        //     return;
+        
+        runWithEvent(null);
+    }
+    
+    /*
+     * @see org.eclipse.jface.action.IAction#runWithEvent(org.eclipse.swt.widgets.Event)
+     */
+    @Override
+       public void runWithEvent(Event event) {
+               if (fAnnotation instanceof OverrideIndicatorManager.OverrideIndicator) {
+                       ((OverrideIndicatorManager.OverrideIndicator)fAnnotation).open();
+                       return;
+               }
+       
+        if (fHasCorrection) {
+            ITextOperationTarget operation= (ITextOperationTarget) fTextEditor.getAdapter(ITextOperationTarget.class);
+            final int opCode= ISourceViewer.QUICK_ASSIST;
+            if (operation != null && operation.canDoOperation(opCode)) {
+                fTextEditor.selectAndReveal(fPosition.getOffset(), fPosition.getLength());
+                operation.doOperation(opCode);
+            }
+            return;
+        }
+
+        super.run();
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.ui.texteditor.SelectMarkerRulerAction#update()
+     */
+    @Override
+       public void update() {
+        findCAnnotation();
+        setEnabled(true); 
+
+               if (fAnnotation instanceof OverrideIndicatorManager.OverrideIndicator) {
+                       initialize(fBundle, "CSelectAnnotationRulerAction.OpenSuperImplementation."); //$NON-NLS-1$
+                       return;
+               }
+        if (fHasCorrection) {
+            initialize(fBundle, "CSelectAnnotationRulerAction.QuickFix."); //$NON-NLS-1$
+            return;
+        }
+
+        initialize(fBundle, "CSelectAnnotationRulerAction.GotoAnnotation."); //$NON-NLS-1$;
+        super.update();
+    }
+
+    private void findCAnnotation() {
+        fPosition= null;
+        fAnnotation = null;
+        fHasCorrection= false;
+
+        AbstractMarkerAnnotationModel model= getAnnotationModel();
+        IAnnotationAccessExtension annotationAccess= getAnnotationAccessExtension();
+
+        IDocument document= getDocument();
+        if (model == null)
+            return ;
+
+        Iterator<?> iter= model.getAnnotationIterator();
+        int layer= Integer.MIN_VALUE;
+
+        while (iter.hasNext()) {
+            Annotation annotation= (Annotation) iter.next();
+            if (annotation.isMarkedDeleted())
+                continue;
+
+            int annotationLayer= layer;
+            if (annotationAccess != null) {
+                annotationLayer= annotationAccess.getLayer(annotation);
+                if (annotationLayer < layer)
+                    continue;
+            }
+
+            Position position= model.getPosition(annotation);
+            if (!includesRulerLine(position, document))
+                continue;
+            
+            boolean isReadOnly = fTextEditor instanceof ITextEditorExtension && ((ITextEditorExtension)fTextEditor).isEditorInputReadOnly();
+
+            if (!isReadOnly && CCorrectionProcessor.hasCorrections(annotation)) {
+                
+                fPosition= position;
+                fAnnotation = annotation;
+                fHasCorrection= true;
+                layer= annotationLayer;
+                continue;
+            }
+                       AnnotationPreference preference= fAnnotationPreferenceLookup.getAnnotationPreference(annotation);
+                       if (preference == null)
+                           continue;
+
+                       String key= preference.getVerticalRulerPreferenceKey();
+                       if (key == null)
+                           continue;
+
+                       if (fStore.getBoolean(key)) {
+                           fPosition= position;
+                           fAnnotation = annotation;
+                           fHasCorrection= false;
+                           layer= annotationLayer;
+                       }
+        }
+    }
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CSelectRulerAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CSelectRulerAction.java
new file mode 100644 (file)
index 0000000..0e12c6f
--- /dev/null
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     David Perryman (IPL Information Processing Limited)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.correction;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.text.source.IVerticalRulerInfo;
+import org.eclipse.ui.texteditor.AbstractRulerActionDelegate;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.internal.ui.editor.ConstructedCEditorMessages;
+
+public class CSelectRulerAction extends AbstractRulerActionDelegate {
+
+    /*
+     * @see AbstractRulerActionDelegate#createAction(ITextEditor, IVerticalRulerInfo)
+     */
+    @Override
+       protected IAction createAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) {
+        return new CSelectAnnotationRulerAction(ConstructedCEditorMessages.getResourceBundle(), "CSelectAnnotationRulerAction.", editor, rulerInfo); //$NON-NLS-1$
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ContributedProcessorDescriptor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ContributedProcessorDescriptor.java
new file mode 100644 (file)
index 0000000..c21975f
--- /dev/null
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *        Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.correction;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.expressions.EvaluationContext;
+import org.eclipse.core.expressions.EvaluationResult;
+import org.eclipse.core.expressions.Expression;
+import org.eclipse.core.expressions.ExpressionConverter;
+import org.eclipse.core.expressions.ExpressionTagNames;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IStatus;
+
+import org.eclipse.cdt.core.model.ICModelMarker;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+
+public final class ContributedProcessorDescriptor {
+       private final IConfigurationElement fConfigurationElement;
+       private Object fProcessorInstance;
+       private Boolean fStatus;
+       private boolean fLastResult;
+       private final Set<String> fHandledMarkerTypes;
+
+       private static final String ID= "id"; //$NON-NLS-1$
+       private static final String CLASS= "class"; //$NON-NLS-1$
+       
+       private static final String HANDLED_MARKER_TYPES= "handledMarkerTypes"; //$NON-NLS-1$
+       private static final String MARKER_TYPE= "markerType"; //$NON-NLS-1$
+       
+       public ContributedProcessorDescriptor(IConfigurationElement element, boolean testMarkerTypes) {
+               fConfigurationElement= element;
+               fProcessorInstance= null;
+               fStatus= null; // undefined
+               if (fConfigurationElement.getChildren(ExpressionTagNames.ENABLEMENT).length == 0) {
+                       fStatus= Boolean.TRUE;
+               }
+               fHandledMarkerTypes= testMarkerTypes ? getHandledMarkerTypes(element) : null;
+       }
+
+       private Set<String> getHandledMarkerTypes(IConfigurationElement element) {
+               HashSet<String> map= new HashSet<String>(7);
+               IConfigurationElement[] children= element.getChildren(HANDLED_MARKER_TYPES);
+               for (IConfigurationElement element2 : children) {
+                       IConfigurationElement[] types= element2.getChildren(MARKER_TYPE);
+                       for (IConfigurationElement type : types) {
+                               String attribute= type.getAttribute(ID);
+                               if (attribute != null) {
+                                       map.add(attribute);
+                               }
+                       }
+               }
+               if (map.isEmpty()) {
+                       map.add(ICModelMarker.TASK_MARKER);
+               }
+               return map;
+       }
+
+       public IStatus checkSyntax() {
+               IConfigurationElement[] children= fConfigurationElement.getChildren(ExpressionTagNames.ENABLEMENT);
+               if (children.length > 1) {
+                       String id= fConfigurationElement.getAttribute(ID);
+                       return new StatusInfo(IStatus.ERROR, "Only one < enablement > element allowed. Disabling " + id); //$NON-NLS-1$
+               }
+               return new StatusInfo(IStatus.OK, "Syntactically correct quick assist/fix processor"); //$NON-NLS-1$
+       }
+
+       private boolean matches(ITranslationUnit cunit) {
+               if (fStatus != null) {
+                       return fStatus.booleanValue();
+               }
+
+               IConfigurationElement[] children= fConfigurationElement.getChildren(ExpressionTagNames.ENABLEMENT);
+               if (children.length == 1) {
+                       try {
+                               ExpressionConverter parser= ExpressionConverter.getDefault();
+                               Expression expression= parser.perform(children[0]);
+                               EvaluationContext evalContext= new EvaluationContext(null, cunit);
+                               evalContext.addVariable("compilationUnit", cunit); //$NON-NLS-1$
+                               ICProject cProject= cunit.getCProject();
+                               String[] natures= cProject.getProject().getDescription().getNatureIds();
+                               evalContext.addVariable("projectNatures", Arrays.asList(natures)); //$NON-NLS-1$
+                               fLastResult= !(expression.evaluate(evalContext) != EvaluationResult.TRUE);
+                               return fLastResult;
+                       } catch (CoreException e) {
+                               CUIPlugin.log(e);
+                       }
+               }
+               fStatus= Boolean.FALSE;
+               return false;
+       }
+       
+       public Object getProcessor(ITranslationUnit cunit) throws CoreException {
+               if (matches(cunit)) {
+                       if (fProcessorInstance == null) {
+                               fProcessorInstance= fConfigurationElement.createExecutableExtension(CLASS);
+                       }
+                       return fProcessorInstance;
+               }
+               return null;
+       }
+       
+       public boolean canHandleMarkerType(String markerType) {
+               return fHandledMarkerTypes == null || fHandledMarkerTypes.contains(markerType);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandHandler.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandHandler.java
new file mode 100644 (file)
index 0000000..3519f1d
--- /dev/null
@@ -0,0 +1,193 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *        Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.correction;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.bindings.TriggerSequence;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.ICompletionProposalExtension;
+import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.keys.IBindingService;
+
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNodeSelector;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.ICCompletionProposal;
+import org.eclipse.cdt.ui.text.IInvocationContext;
+
+import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
+
+import org.eclipse.cdt.internal.ui.actions.ActionUtil;
+import org.eclipse.cdt.internal.ui.editor.ASTProvider;
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.text.correction.proposals.LinkedNamesAssistProposal;
+
+/**
+ * Handler to be used to run a quick fix or assist by keyboard shortcut
+ */
+public class CorrectionCommandHandler extends AbstractHandler {
+       private final CEditor fEditor;
+       private final String fId;
+       private final boolean fIsAssist;
+
+       public CorrectionCommandHandler(CEditor editor, String id, boolean isAssist) {
+               fEditor= editor;
+               fId= id;
+               fIsAssist= isAssist;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+        */
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               doExecute();
+               return null;
+       }
+
+       /**
+        * Try to execute the correction command.
+        * 
+        * @return <code>true</code> iff the correction could be started
+        * @since 5.3
+        */
+       public boolean doExecute() {
+               ISelection selection= fEditor.getSelectionProvider().getSelection();
+               ITranslationUnit tu= CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(fEditor.getEditorInput());
+               IAnnotationModel model= CUIPlugin.getDefault().getDocumentProvider().getAnnotationModel(fEditor.getEditorInput());
+               if (selection instanceof ITextSelection && tu != null && model != null) {
+                       if (!ActionUtil.isEditable(fEditor)) {
+                               return false;
+                       }
+                       ICompletionProposal proposal= findCorrection(fId, fIsAssist, (ITextSelection) selection, tu, model);
+                       if (proposal != null) {
+                               invokeProposal(proposal, ((ITextSelection) selection).getOffset());
+                       }
+               }
+               return false;
+       }
+       
+       private ICompletionProposal findCorrection(String id, boolean isAssist, ITextSelection selection, ITranslationUnit tu, IAnnotationModel model) {
+               CorrectionContext context= new CorrectionContext(tu, selection.getOffset(), selection.getLength());
+               Collection<ICCompletionProposal> proposals= new ArrayList<ICCompletionProposal>(10);
+               if (isAssist) {
+                       if (id.equals(LinkedNamesAssistProposal.ASSIST_ID)) {
+                               return getLocalRenameProposal(context); // shortcut for local rename
+                       }
+                       CCorrectionProcessor.collectAssists(context, new ProblemLocation[0], proposals);
+               } else {
+                       try {
+                               boolean goToClosest= selection.getLength() == 0; 
+                               Annotation[] annotations= getAnnotations(selection.getOffset(), goToClosest);
+                               CCorrectionProcessor.collectProposals(context, model, annotations, true, false, proposals);
+                       } catch (BadLocationException e) {
+                               return null;
+                       }
+               }
+               for (Iterator<ICCompletionProposal> iter= proposals.iterator(); iter.hasNext();) {
+                       Object curr= iter.next();
+                       if (curr instanceof ICommandAccess) {
+                               if (id.equals(((ICommandAccess) curr).getCommandId())) {
+                                       return (ICompletionProposal) curr;
+                               }
+                       }
+               }
+               return null;
+       }
+
+       private Annotation[] getAnnotations(int offset, boolean goToClosest) throws BadLocationException {
+               ArrayList<Annotation> resultingAnnotations= new ArrayList<Annotation>();
+               CCorrectionAssistant.collectQuickFixableAnnotations(fEditor, offset, goToClosest, resultingAnnotations);
+               return resultingAnnotations.toArray(new Annotation[resultingAnnotations.size()]);
+       }
+       
+       private ICompletionProposal getLocalRenameProposal(final IInvocationContext context) {
+               final ICCompletionProposal[] proposals= new ICCompletionProposal[1];
+
+               ASTProvider.getASTProvider().runOnAST(context.getTranslationUnit(), ASTProvider.WAIT_ACTIVE_ONLY,
+                               new NullProgressMonitor(), new ASTRunnable() {
+
+                       public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
+                               IASTNodeSelector selector= astRoot.getNodeSelector(null);
+                               IASTName name= selector.findEnclosingName(context.getSelectionOffset(), context.getSelectionLength());
+
+                               // Activate the proposal only if a simple name is selected.
+                               if (name != null && name == name.getLastName()) {
+                                       IBinding binding= name.resolveBinding();
+                                       if (binding != null) {
+                                               proposals[0]= new LinkedNamesAssistProposal(context.getTranslationUnit());
+                                       }
+                               }
+                               return Status.OK_STATUS;
+                       }
+               });
+               return proposals[0];
+       }
+
+       private IDocument getDocument() {
+               return CUIPlugin.getDefault().getDocumentProvider().getDocument(fEditor.getEditorInput());
+       }
+       
+       private void invokeProposal(ICompletionProposal proposal, int offset) {
+               if (proposal instanceof ICompletionProposalExtension2) {
+                       ITextViewer viewer= fEditor.getViewer();
+                       if (viewer != null) {
+                               ((ICompletionProposalExtension2) proposal).apply(viewer, (char) 0, 0, offset);
+                               return;
+                       }
+               } else if (proposal instanceof ICompletionProposalExtension) {
+                       IDocument document= getDocument();
+                       if (document != null) {
+                               ((ICompletionProposalExtension) proposal).apply(document, (char) 0, offset);
+                               return;
+                       }
+               }
+               IDocument document= getDocument();
+               if (document != null) {
+                       proposal.apply(document);
+               }
+       }
+       
+       public static String getShortCutString(String proposalId) {
+               if (proposalId != null) {
+                       IBindingService bindingService= (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class);
+                       if (bindingService != null) {
+                               TriggerSequence[] activeBindingsFor= bindingService.getActiveBindingsFor(proposalId);
+                               if (activeBindingsFor.length > 0) {
+                                       return activeBindingsFor[0].format();
+                               }
+                       }
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandInstaller.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandInstaller.java
new file mode 100644 (file)
index 0000000..b454b43
--- /dev/null
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *        Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.correction;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.LegacyHandlerSubmissionExpression;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.handlers.IHandlerActivation;
+import org.eclipse.ui.handlers.IHandlerService;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+
+public class CorrectionCommandInstaller {
+       /**
+        * All correction commands must start with the following prefix.
+        */
+       public static final String COMMAND_PREFIX= "org.eclipse.jdt.ui.correction."; //$NON-NLS-1$
+       
+       /**
+        * Commands for quick assist must have the following suffix.
+        */
+       public static final String ASSIST_SUFFIX= ".assist"; //$NON-NLS-1$
+       
+       private List<IHandlerActivation> fCorrectionHandlerActivations;
+       
+       public CorrectionCommandInstaller() {
+               fCorrectionHandlerActivations= null;
+       }
+       
+       public void registerCommands(CEditor editor) {
+               IWorkbench workbench= PlatformUI.getWorkbench();
+               ICommandService commandService= (ICommandService) workbench.getAdapter(ICommandService.class);
+               IHandlerService handlerService= (IHandlerService) workbench.getAdapter(IHandlerService.class);
+               if (commandService == null || handlerService == null) {
+                       return;
+               }
+               
+               if (fCorrectionHandlerActivations != null) {
+                       CUIPlugin.logError("Correction handler activations not released"); //$NON-NLS-1$
+               }
+               fCorrectionHandlerActivations= new ArrayList<IHandlerActivation>();
+               
+               @SuppressWarnings("unchecked")
+               Collection<String> definedCommandIds= commandService.getDefinedCommandIds();
+               for (Object element : definedCommandIds) {
+                       String id= (String) element;
+                       if (id.startsWith(COMMAND_PREFIX)) {
+                               boolean isAssist= id.endsWith(ASSIST_SUFFIX);
+                               CorrectionCommandHandler handler= new CorrectionCommandHandler(editor, id, isAssist);
+                               IHandlerActivation activation= handlerService.activateHandler(id, handler, new LegacyHandlerSubmissionExpression(null, null, editor.getSite()));
+                               fCorrectionHandlerActivations.add(activation);
+                       }
+               }
+       }
+       
+       public void deregisterCommands() {
+               IHandlerService handlerService= (IHandlerService) PlatformUI.getWorkbench().getAdapter(IHandlerService.class);
+               if (handlerService != null && fCorrectionHandlerActivations != null) {
+                       handlerService.deactivateHandlers(fCorrectionHandlerActivations);
+                       fCorrectionHandlerActivations= null;
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionContext.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionContext.java
new file mode 100644 (file)
index 0000000..7a93b2b
--- /dev/null
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *        Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.correction;
+
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.TextInvocationContext;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.text.IInvocationContext;
+
+public class CorrectionContext extends TextInvocationContext implements IInvocationContext {
+       private ITranslationUnit fTranslationUnit;
+
+       /*
+        * Constructor for CorrectionContext.
+        */
+       public CorrectionContext(ITranslationUnit tu, ISourceViewer sourceViewer, int offset, int length) {
+               super(sourceViewer, offset, length);
+               fTranslationUnit= tu;
+       }
+       
+       /*
+        * Constructor for CorrectionContext.
+        */
+       public CorrectionContext(ITranslationUnit tu, int offset, int length) {
+               this(tu, null, offset, length);
+       }
+
+       /**
+        * Returns the translation unit.
+        * @return an <code>ITranslationUnit</code>
+        */
+       public ITranslationUnit getTranslationUnit() {
+               return fTranslationUnit;
+       }
+
+       /**
+        * Returns the length.
+        * @return int
+        */
+       public int getSelectionLength() {
+               return Math.max(getLength(), 0);
+       }
+
+       /**
+        * Returns the offset.
+        * @return int
+        */
+       public int getSelectionOffset() {
+               return getOffset();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionMessages.java
new file mode 100644 (file)
index 0000000..6b2f81c
--- /dev/null
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2008 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *        Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.correction;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Helper class to get NLSed messages.
+ */
+public final class CorrectionMessages extends NLS {
+       static {
+               NLS.initializeMessages(CorrectionMessages.class.getName(), CorrectionMessages.class);
+       }
+
+       private CorrectionMessages() {
+               // Do not instantiate
+       }
+
+       public static String CCorrectionProcessor_error_quickassist_message;
+       public static String CCorrectionProcessor_error_quickfix_message;
+       public static String CCorrectionProcessor_error_status;
+       public static String MarkerResolutionProposal_additionaldesc;
+       public static String NoCorrectionProposal_description;
+       
+       public static String ChangeCorrectionProposal_error_title;
+       public static String ChangeCorrectionProposal_error_message;
+       public static String ChangeCorrectionProposal_name_with_shortcut;
+       public static String TUCorrectionProposal_error_title;
+       public static String TUCorrectionProposal_error_message;
+       public static String LinkedNamesAssistProposal_proposalinfo;
+       public static String LinkedNamesAssistProposal_description;
+       public static String RenameRefactoringProposal_additionalInfo;
+       public static String RenameRefactoringProposal_name;
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionMessages.properties
new file mode 100644 (file)
index 0000000..0c35c4b
--- /dev/null
@@ -0,0 +1,33 @@
+###############################################################################
+#  Copyright (c) 2000, 2008 IBM Corporation and others.
+#  All rights reserved. This program and the accompanying materials
+#  are made available under the terms of the Eclipse Public License v1.0
+#  which accompanies this distribution, and is available at
+#  http://www.eclipse.org/legal/epl-v10.html
+# 
+#  Contributors:
+#     IBM Corporation - initial API and implementation
+#     Sergey Prigogin (Google)
+###############################################################################
+
+CCorrectionProcessor_error_quickassist_message=An error occurred while computing quick assists. Check log for details.
+CCorrectionProcessor_error_quickfix_message=An error occurred while computing quick fixes. Check log for details.
+CCorrectionProcessor_error_status=Exception while processing quick fixes or quick assists
+
+MarkerResolutionProposal_additionaldesc=Problem description: {0}
+NoCorrectionProposal_description=No suggestions available
+
+# ------ CCorrectionProcessor
+
+ChangeCorrectionProposal_error_title=Quick Fix
+ChangeCorrectionProposal_error_message=An exception occurred while applying the quick fix.
+ChangeCorrectionProposal_name_with_shortcut={0} ({1})
+
+TUCorrectionProposal_error_title=Quick Fix
+TUCorrectionProposal_error_message=An exception occurred while applying the quick fix.
+
+LinkedNamesAssistProposal_proposalinfo=Link all references for a local rename (does not change references in other files)
+LinkedNamesAssistProposal_description=Rename in file
+
+RenameRefactoringProposal_additionalInfo=Start the Rename refactoring
+RenameRefactoringProposal_name=Rename in workspace
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ICommandAccess.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ICommandAccess.java
new file mode 100644 (file)
index 0000000..d76f8bb
--- /dev/null
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2008 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *        Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.correction;
+
+/**
+ * Correction proposals implement this interface to by invokable by a command. 
+ * (e.g. keyboard shortcut) 
+ */
+public interface ICommandAccess {
+
+       /**
+        * Returns the id of the command that should invoke this correction proposal
+        * @return the id of the command. This id must start with {@link CorrectionCommandInstaller#COMMAND_PREFIX}
+        * to be recognizes as correction command.
+        */
+       String getCommandId();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/IStatusLineProposal.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/IStatusLineProposal.java
new file mode 100644 (file)
index 0000000..62ef8b3
--- /dev/null
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *        Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.correction;
+
+/**
+ * A proposal which is able to show a message
+ * on the status line of the content assistant
+ * in which this proposal is shown.
+ * 
+ * @see org.eclipse.jface.text.contentassist.IContentAssistantExtension2
+ */
+public interface IStatusLineProposal {
+       /**
+        * The message to show when this proposal is
+        * selected by the user in the content assistant.
+        * 
+        * @return The message to show, or null for no message.
+        */
+       public String getStatusMessage();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/MarkerResolutionProposal.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/MarkerResolutionProposal.java
new file mode 100644 (file)
index 0000000..15099f7
--- /dev/null
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *        Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.correction;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.ui.IMarkerResolution;
+import org.eclipse.ui.IMarkerResolution2;
+
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.ICCompletionProposal;
+
+public class MarkerResolutionProposal implements ICCompletionProposal {
+       private IMarkerResolution fResolution;
+       private IMarker fMarker;
+
+       /**
+        * Constructor for MarkerResolutionProposal.
+        */
+       public MarkerResolutionProposal(IMarkerResolution resolution, IMarker marker) {
+               fResolution= resolution;
+               fMarker= marker;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument)
+        */
+       public void apply(IDocument document) {
+               fResolution.run(fMarker);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo()
+        */
+       public String getAdditionalProposalInfo() {
+               if (fResolution instanceof IMarkerResolution2) {
+                       return ((IMarkerResolution2) fResolution).getDescription();
+               }
+               if (fResolution instanceof ICCompletionProposal) {
+                       return ((ICCompletionProposal) fResolution).getAdditionalProposalInfo();
+               }
+               try {
+                       String problemDesc= (String) fMarker.getAttribute(IMarker.MESSAGE);
+                       return CorrectionMessages.bind(CorrectionMessages.MarkerResolutionProposal_additionaldesc,
+                                       problemDesc);
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }
+               return null;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getContextInformation()
+        */
+       public IContextInformation getContextInformation() {
+               return null;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
+        */
+       public String getDisplayString() {
+               return fResolution.getLabel();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage()
+        */
+       public Image getImage() {
+               if (fResolution instanceof IMarkerResolution2) {
+                       return ((IMarkerResolution2) fResolution).getImage();
+               }
+               if (fResolution instanceof ICCompletionProposal) {
+                       return ((ICCompletionProposal) fResolution).getImage();
+               }
+               return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_CORRECTION_CHANGE);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jdt.internal.ui.text.java.ICCompletionProposal#getRelevance()
+        */
+       public int getRelevance() {
+               if (fResolution instanceof ICCompletionProposal) {
+                       return ((ICCompletionProposal) fResolution).getRelevance();
+               }
+               return 10;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getSelection(org.eclipse.jface.text.IDocument)
+        */
+       public Point getSelection(IDocument document) {
+               if (fResolution instanceof ICCompletionProposal) {
+                       return ((ICCompletionProposal) fResolution).getSelection(document);
+               }
+               return null;
+       }
+
+       public String getIdString() {
+               return getDisplayString();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ProblemLocation.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ProblemLocation.java
new file mode 100644 (file)
index 0000000..f2c9852
--- /dev/null
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *        Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.correction;
+
+import org.eclipse.cdt.core.model.ICModelMarker;
+import org.eclipse.cdt.core.parser.IPersistableProblem;
+import org.eclipse.cdt.core.parser.IProblem;
+import org.eclipse.cdt.ui.text.IProblemLocation;
+
+import org.eclipse.cdt.internal.ui.editor.CMarkerAnnotation;
+import org.eclipse.cdt.internal.ui.editor.ICAnnotation;
+
+public class ProblemLocation implements IProblemLocation {
+       private final int fId;
+       private final String[] fArguments;
+       private final int fOffset;
+       private final int fLength;
+       private final boolean fIsError;
+       private final String fMarkerType;
+
+       public ProblemLocation(int offset, int length, ICAnnotation annotation) {
+               fId= annotation.getId();
+               fArguments= annotation.getArguments();
+               fOffset= offset;
+               fLength= length;
+               fIsError= CMarkerAnnotation.ERROR_ANNOTATION_TYPE.equals(annotation.getType());
+               
+               String markerType= annotation.getMarkerType();
+               fMarkerType= markerType != null ? markerType : ICModelMarker.C_MODEL_PROBLEM_MARKER;
+       }
+
+       public ProblemLocation(int offset, int length, int id, String[] arguments, boolean isError, String markerType) {
+               fId= id;
+               fArguments= arguments;
+               fOffset= offset;
+               fLength= length;
+               fIsError= isError;
+               fMarkerType= markerType;
+       }
+       
+       public ProblemLocation(IProblem problem) {
+               fId= problem.getID();
+               fArguments= problem.getArguments();
+               fOffset= problem.getSourceStart();
+               fLength= problem.getSourceEnd() - fOffset + 1;
+               fIsError= problem.isError();
+               fMarkerType= problem instanceof IPersistableProblem ?
+                               ((IPersistableProblem) problem).getMarkerType() : ICModelMarker.C_MODEL_PROBLEM_MARKER;
+       }
+
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jdt.internal.ui.text.correction.IProblemLocation#getProblemId()
+        */
+       public int getProblemId() {
+               return fId;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jdt.internal.ui.text.correction.IProblemLocation#getProblemArguments()
+        */
+       public String[] getProblemArguments() {
+               return fArguments;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jdt.internal.ui.text.correction.IProblemLocation#getLength()
+        */
+       public int getLength() {
+               return fLength;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jdt.internal.ui.text.correction.IProblemLocation#getOffset()
+        */
+       public int getOffset() {
+               return fOffset;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jdt.ui.text.java.IProblemLocation#isError()
+        */
+       public boolean isError() {
+               return fIsError;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jdt.ui.text.java.IProblemLocation#getMarkerType()
+        */
+       public String getMarkerType() {
+               return fMarkerType;
+       }
+       
+       @Override
+       public String toString() {
+               StringBuffer buf= new StringBuffer();
+               buf.append("Id: ").append(getErrorCode(fId)).append('\n'); //$NON-NLS-1$
+               buf.append('[').append(fOffset).append(", ").append(fLength).append(']').append('\n'); //$NON-NLS-1$
+               String[] arg= fArguments;
+               if (arg != null) {
+                       for (int i= 0; i < arg.length; i++) {
+                               buf.append(arg[i]);
+                               buf.append('\n');                                
+                       }
+               }
+               return buf.toString();
+       }
+
+       private String getErrorCode(int code) {
+               StringBuffer buf= new StringBuffer();
+               if ((code & IProblem.SCANNER_RELATED) != 0) {
+                       buf.append("ScannerRelated + "); //$NON-NLS-1$
+               }
+               if ((code & IProblem.PREPROCESSOR_RELATED) != 0) {
+                       buf.append("PreprocessorRelated + "); //$NON-NLS-1$
+               }
+               if ((code & IProblem.SEMANTICS_RELATED) != 0) {
+                       buf.append("SemanticsRelated + "); //$NON-NLS-1$
+               }
+               if ((code & IProblem.INTERNAL_RELATED) != 0) {
+                       buf.append("Internal + "); //$NON-NLS-1$
+               }
+               if ((code & IProblem.SYNTAX_RELATED) != 0) {
+                       buf.append("Syntax + "); //$NON-NLS-1$
+               }
+               buf.append(code & IProblem.IGNORE_CATEGORIES_MASK);
+
+               return buf.toString();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistLightBulbUpdater.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistLightBulbUpdater.java
new file mode 100644 (file)
index 0000000..607f404
--- /dev/null
@@ -0,0 +1,287 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *        Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.correction;
+
+import java.util.ConcurrentModificationException;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationAccessExtension;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.text.source.IAnnotationPresentation;
+import org.eclipse.jface.text.source.ImageUtilities;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.texteditor.AnnotationPreference;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
+
+import org.eclipse.cdt.internal.ui.editor.ASTProvider;
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+import org.eclipse.cdt.internal.ui.viewsupport.ISelectionListenerWithAST;
+import org.eclipse.cdt.internal.ui.viewsupport.SelectionListenerWithASTManager;
+
+/**
+ *
+ */
+public class QuickAssistLightBulbUpdater {
+
+       public static class AssistAnnotation extends Annotation implements IAnnotationPresentation {
+               //XXX: To be fully correct this should be a non-static field in QuickAssistLightBulbUpdater
+               private static final int LAYER;
+
+               static {
+                       Annotation annotation= new Annotation("org.eclipse.jdt.ui.warning", false, null); //$NON-NLS-1$
+                       AnnotationPreference preference= EditorsUI.getAnnotationPreferenceLookup().getAnnotationPreference(annotation);
+                       if (preference != null)
+                               LAYER= preference.getPresentationLayer() - 1;
+                       else
+                               LAYER= IAnnotationAccessExtension.DEFAULT_LAYER;
+               }
+
+               private Image fImage;
+
+               public AssistAnnotation() {
+               }
+
+               /*
+                * @see org.eclipse.jface.text.source.IAnnotationPresentation#getLayer()
+                */
+               public int getLayer() {
+                       return LAYER;
+               }
+
+               private Image getImage() {
+                       if (fImage == null) {
+                               fImage= CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_QUICK_ASSIST);
+                       }
+                       return fImage;
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.text.source.Annotation#paint(org.eclipse.swt.graphics.GC, org.eclipse.swt.widgets.Canvas, org.eclipse.swt.graphics.Rectangle)
+                */
+               public void paint(GC gc, Canvas canvas, Rectangle r) {
+                       ImageUtilities.drawImage(getImage(), gc, canvas, r, SWT.CENTER, SWT.TOP);
+               }
+       }
+
+       private final Annotation fAnnotation;
+       private boolean fIsAnnotationShown;
+       private ITextEditor fEditor;
+       private ITextViewer fViewer;
+
+       private ISelectionListenerWithAST fListener;
+       private IPropertyChangeListener fPropertyChangeListener;
+
+       public QuickAssistLightBulbUpdater(ITextEditor part, ITextViewer viewer) {
+               fEditor= part;
+               fViewer= viewer;
+               fAnnotation= new AssistAnnotation();
+               fIsAnnotationShown= false;
+               fPropertyChangeListener= null;
+       }
+
+       public boolean isSetInPreferences() {
+               return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_QUICKASSIST_LIGHTBULB);
+       }
+
+       private void installSelectionListener() {
+               fListener= new ISelectionListenerWithAST() {
+                       public void selectionChanged(IEditorPart part,
+                                       ITextSelection selection, IASTTranslationUnit astRoot) {
+                               doSelectionChanged(selection.getOffset(), selection.getLength(), astRoot);
+                       }
+               };
+               SelectionListenerWithASTManager.getDefault().addListener(fEditor, fListener);
+       }
+
+       private void uninstallSelectionListener() {
+               if (fListener != null) {
+                       SelectionListenerWithASTManager.getDefault().removeListener(fEditor, fListener);
+                       fListener= null;
+               }
+               IAnnotationModel model= getAnnotationModel();
+               if (model != null) {
+                       removeLightBulb(model);
+               }
+       }
+
+       public void install() {
+               if (isSetInPreferences()) {
+                       installSelectionListener();
+               }
+               if (fPropertyChangeListener == null) {
+                       fPropertyChangeListener= new IPropertyChangeListener() {
+                               public void propertyChange(PropertyChangeEvent event) {
+                                       doPropertyChanged(event.getProperty());
+                               }
+                       };
+                       PreferenceConstants.getPreferenceStore().addPropertyChangeListener(fPropertyChangeListener);
+               }
+       }
+
+       public void uninstall() {
+               uninstallSelectionListener();
+               if (fPropertyChangeListener != null) {
+                       PreferenceConstants.getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener);
+                       fPropertyChangeListener= null;
+               }
+       }
+
+       protected void doPropertyChanged(String property) {
+               if (property.equals(PreferenceConstants.EDITOR_QUICKASSIST_LIGHTBULB)) {
+                       if (isSetInPreferences()) {
+                               IWorkingCopy workingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(fEditor.getEditorInput());
+                               if (workingCopy != null) {
+                                       installSelectionListener();
+                                       final Point point= fViewer.getSelectedRange();
+                                       ASTProvider.getASTProvider().runOnAST(workingCopy, ASTProvider.WAIT_IF_OPEN, null, new ASTRunnable() {
+                                               public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) {
+                                                       if (astRoot != null) {
+                                                               doSelectionChanged(point.x, point.y, astRoot);
+                                                       }
+                                                       return Status.OK_STATUS;
+                                               }
+                                       });
+                               }
+                       } else {
+                               uninstallSelectionListener();
+                       }
+               }
+       }
+
+       private ITranslationUnit getTranslationUnit() {
+               ICElement elem= EditorUtility.getEditorInputCElement(fEditor);
+               if (elem instanceof ITranslationUnit) {
+                       return (ITranslationUnit) elem;
+               }
+               return null;
+       }
+
+       private IAnnotationModel getAnnotationModel() {
+               return CUIPlugin.getDefault().getDocumentProvider().getAnnotationModel(fEditor.getEditorInput());
+       }
+
+       private IDocument getDocument() {
+               return CUIPlugin.getDefault().getDocumentProvider().getDocument(fEditor.getEditorInput());
+       }
+
+       private void doSelectionChanged(int offset, int length, IASTTranslationUnit astRoot) {
+               final IAnnotationModel model= getAnnotationModel();
+               final ITranslationUnit tu= getTranslationUnit();
+               if (model == null || tu == null) {
+                       return;
+               }
+
+               final CorrectionContext context= new CorrectionContext(tu, offset, length);
+
+               boolean hasQuickFix= hasQuickFixLightBulb(model, context.getSelectionOffset());
+               if (hasQuickFix) {
+                       removeLightBulb(model);
+                       return; // there is already a quick fix light bulb at the new location
+               }
+
+               calculateLightBulb(model, context);
+       }
+
+       /*
+        * Needs to be called synchronized
+        */
+       private void calculateLightBulb(IAnnotationModel model, CorrectionContext context) {
+               boolean needsAnnotation= CCorrectionProcessor.hasAssists(context);
+               if (fIsAnnotationShown) {
+                       model.removeAnnotation(fAnnotation);
+               }
+               if (needsAnnotation) {
+                       model.addAnnotation(fAnnotation, new Position(context.getSelectionOffset(), context.getSelectionLength()));
+               }
+               fIsAnnotationShown= needsAnnotation;
+       }
+
+       private void removeLightBulb(IAnnotationModel model) {
+               synchronized (this) {
+                       if (fIsAnnotationShown) {
+                               model.removeAnnotation(fAnnotation);
+                               fIsAnnotationShown= false;
+                       }
+               }
+       }
+
+       /*
+        * Tests if there is already a quick fix light bulb on the current line
+        */
+       private boolean hasQuickFixLightBulb(IAnnotationModel model, int offset) {
+               try {
+                       IDocument document= getDocument();
+                       if (document == null) {
+                               return false;
+                       }
+
+                       // we access a document and annotation model from within a job
+                       // since these are only read accesses, we won't hurt anyone else if
+                       // this goes boink
+
+                       // may throw an IndexOutOfBoundsException upon concurrent document modification
+                       int currLine= document.getLineOfOffset(offset);
+
+                       // this iterator is not protected, it may throw ConcurrentModificationExceptions
+                       Iterator<?> iter= model.getAnnotationIterator();
+                       while (iter.hasNext()) {
+                               Annotation annot= (Annotation) iter.next();
+                               if (CCorrectionProcessor.isQuickFixableType(annot)) {
+                                       // may throw an IndexOutOfBoundsException upon concurrent annotation model changes
+                                       Position pos= model.getPosition(annot);
+                                       if (pos != null) {
+                                               // may throw an IndexOutOfBoundsException upon concurrent document modification
+                                               int startLine= document.getLineOfOffset(pos.getOffset());
+                                               if (startLine == currLine && CCorrectionProcessor.hasCorrections(annot)) {
+                                                       return true;
+                                               }
+                                       }
+                               }
+                       }
+               } catch (BadLocationException e) {
+                       // ignore
+               } catch (IndexOutOfBoundsException e) {
+                       // concurrent modification - too bad, ignore
+               } catch (ConcurrentModificationException e) {
+                       // concurrent modification - too bad, ignore
+               }
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistProcessor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistProcessor.java
new file mode 100644 (file)
index 0000000..173818f
--- /dev/null
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sebastian Davids <sdavids@gmx.de> - Bug 37432 getInvertEqualsProposal
+ *     Benjamin Muskalla <b.muskalla@gmx.net> - Bug 36350 convertToStringBufferPropsal
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.correction;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.IEditorPart;
+
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNodeSelector;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.ICCompletionProposal;
+import org.eclipse.cdt.ui.text.IInvocationContext;
+import org.eclipse.cdt.ui.text.IProblemLocation;
+import org.eclipse.cdt.ui.text.IQuickAssistProcessor;
+
+import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
+
+import org.eclipse.cdt.internal.ui.editor.ASTProvider;
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.text.correction.proposals.LinkedNamesAssistProposal;
+import org.eclipse.cdt.internal.ui.text.correction.proposals.RenameRefactoringProposal;
+
+/**
+ * see org.eclipse.cdt.ui.text.IQuickAssistProcessor
+ */
+public class QuickAssistProcessor implements IQuickAssistProcessor {
+
+       public QuickAssistProcessor() {
+               super();
+       }
+
+       public boolean hasAssists(final IInvocationContext context) throws CoreException {
+               IStatus status = ASTProvider.getASTProvider().runOnAST(context.getTranslationUnit(),
+                               ASTProvider.WAIT_ACTIVE_ONLY, new NullProgressMonitor(), new ASTRunnable() {
+
+                       public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
+                               IASTNodeSelector selector= astRoot.getNodeSelector(null);
+                               IASTName name= selector.findEnclosingName(context.getSelectionOffset(), context.getSelectionLength());
+
+                               // Activate the proposal only if a simple name is selected.
+                               if (name != null && name == name.getLastName()) {
+                                       IBinding binding= name.resolveBinding();
+                                       if (binding != null) {
+                                               return Status.OK_STATUS;
+                                       }
+                               }
+                               return Status.CANCEL_STATUS;
+                       }
+               });
+               return status.isOK();
+       }
+
+       public ICCompletionProposal[] getAssists(final IInvocationContext context,
+                       final IProblemLocation[] problemLocations) throws CoreException {
+               final ArrayList<ICCompletionProposal> proposals= new ArrayList<ICCompletionProposal>();
+
+               ASTProvider.getASTProvider().runOnAST(context.getTranslationUnit(), ASTProvider.WAIT_ACTIVE_ONLY,
+                               new NullProgressMonitor(),
+                               new ASTRunnable() {
+
+                       public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
+                               IASTNodeSelector selector= astRoot.getNodeSelector(null);
+                               IASTName name= selector.findEnclosingName(context.getSelectionOffset(), context.getSelectionLength());
+
+                               // Activate the proposal only if a simple name is selected.
+                               if (name != null && name == name.getLastName()) {
+                                       IBinding binding= name.resolveBinding();
+                                       if (binding != null) {
+                                               boolean noErrorsAtLocation= noErrorsAtLocation(problemLocations);
+                                               
+                                               // Quick assists that show up also if there is an error/warning
+                                               getRenameLocalProposals(context, problemLocations, noErrorsAtLocation, proposals);
+                                               getRenameRefactoringProposal(context, problemLocations, noErrorsAtLocation, proposals);
+                                       }
+                               }
+                               return Status.OK_STATUS;
+                       }
+               });
+               
+               return proposals.isEmpty() ? null : proposals.toArray(new ICCompletionProposal[proposals.size()]);
+       }
+
+       private boolean noErrorsAtLocation(IProblemLocation[] locations) {
+               if (locations != null) {
+                       for (int i= 0; i < locations.length; i++) {
+                               if (locations[i].isError()) {
+                                       return false;
+                               }
+                       }
+               }
+               return true;
+       }
+       
+       private static void getRenameLocalProposals(IInvocationContext context, IProblemLocation[] locations,
+                       boolean noErrorsAtLocation, Collection<ICCompletionProposal> proposals) {
+               LinkedNamesAssistProposal proposal= new LinkedNamesAssistProposal(context.getTranslationUnit());
+               if (!noErrorsAtLocation) {
+                       proposal.setRelevance(1);
+               }
+               
+               proposals.add(proposal);
+       }
+
+       private static boolean getRenameRefactoringProposal(IInvocationContext context, IProblemLocation[] locations,
+                       boolean noErrorsAtLocation, Collection<ICCompletionProposal> proposals)
+                       throws CoreException {
+               IEditorPart editor= CUIPlugin.getActivePage().getActiveEditor();
+               if (!(editor instanceof CEditor))
+                       return false;
+
+               if (proposals == null) {
+                       return true;
+               }
+               RenameRefactoringProposal proposal= new RenameRefactoringProposal((CEditor) editor);
+               if (!noErrorsAtLocation) {
+                       proposal.setRelevance(1);
+               }
+
+               proposals.add(proposal);
+               return true;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/ASTRewriteCorrectionProposal.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/ASTRewriteCorrectionProposal.java
new file mode 100644 (file)
index 0000000..a92164c
--- /dev/null
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2008 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.correction.proposals;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
+import org.eclipse.ltk.core.refactoring.TextChange;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.text.edits.TextEdit;
+
+import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+import org.eclipse.cdt.internal.ui.CUIStatus;
+
+/**
+ * A proposal for quick fixes and quick assists that works on a AST rewriter.
+ * Either a rewriter is directly passed in the constructor or method {@link #getRewrite()}
+ * is overridden to provide the AST rewriter that is evaluated to the document when the
+ * proposal is applied.
+ * 
+ * @since 5.1
+ */
+public class ASTRewriteCorrectionProposal extends TUCorrectionProposal {
+       private ASTRewrite fRewrite;
+
+       /**
+        * Constructs a AST rewrite correction proposal.
+        * 
+        * @param name the display name of the proposal.
+        * @param tu the translation unit that is modified.
+        * @param rewrite the AST rewrite that is invoked when the proposal is applied or
+        *  <code>null</code> if {@link #getRewrite()} is overridden.
+        * @param relevance The relevance of this proposal.
+        * @param image The image that is displayed for this proposal or <code>null</code> if no
+        * image is desired.
+        */
+       public ASTRewriteCorrectionProposal(String name, ITranslationUnit tu, ASTRewrite rewrite, int relevance, Image image) {
+               super(name, tu, relevance, image);
+               fRewrite= rewrite;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.text.correction.TUCorrectionProposal#addEdits(org.eclipse.jface.text.IDocument)
+        */
+       @Override
+       protected void addEdits(IDocument document, TextEdit editRoot) throws CoreException {
+               super.addEdits(document, editRoot);
+               ASTRewrite rewrite= getRewrite();
+               if (rewrite != null) {
+                       try {
+                               Change change = rewrite.rewriteAST();
+                               addTextEdits(change, editRoot);
+                       } catch (IllegalArgumentException e) {
+                               throw new CoreException(CUIStatus.createError(IStatus.ERROR, e));
+                       }
+               }
+       }
+
+       /**
+        * Adds all text edits from {@code change} to {@code editRoot}.
+        * @param change
+        * @param editRoot
+        */
+       private void addTextEdits(Change change, TextEdit editRoot) {
+               if (change instanceof TextChange) {
+                       editRoot.addChild(((TextChange) change).getEdit());
+               } else if (change instanceof CompositeChange) {
+                       for (Change c : ((CompositeChange) change).getChildren()) {
+                               addTextEdits(c, editRoot);
+                       }
+               }
+       }
+
+       /**
+        * Returns the rewriter that has been passed in the constructor. Implementors can override this
+        * method to create the rewriter lazy. This method will only be called once.
+        * 
+        * @return returns the rewriter to be used.
+        * @throws CoreException an exception is thrown when the rewriter could not be created.
+        */
+       protected ASTRewrite getRewrite() throws CoreException {
+               if (fRewrite == null) {
+                       IStatus status= CUIStatus.createError(IStatus.ERROR, "Rewriter not initialized", null); //$NON-NLS-1$
+                       throw new CoreException(status);
+               }
+               return fRewrite;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/ChangeCorrectionProposal.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/ChangeCorrectionProposal.java
new file mode 100644 (file)
index 0000000..d56e3c0
--- /dev/null
@@ -0,0 +1,311 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.correction.proposals;
+
+import com.ibm.icu.text.MessageFormat;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+
+import org.eclipse.jface.viewers.StyledString;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRewriteTarget;
+import org.eclipse.jface.text.contentassist.ICompletionProposalExtension6;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.link.LinkedModeModel;
+
+import org.eclipse.ui.IEditorPart;
+
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.IUndoManager;
+import org.eclipse.ltk.core.refactoring.NullChange;
+import org.eclipse.ltk.core.refactoring.RefactoringCore;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.ICCompletionProposal;
+
+import org.eclipse.cdt.internal.ui.text.correction.CorrectionCommandHandler;
+import org.eclipse.cdt.internal.ui.text.correction.CorrectionMessages;
+import org.eclipse.cdt.internal.ui.text.correction.ICommandAccess;
+import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
+import org.eclipse.cdt.internal.ui.viewsupport.ColoringLabelProvider;
+
+/**
+ * Implementation of a C completion proposal to be used for quick fix and quick assist
+ * proposals that invoke a {@link Change}. The proposal offers a proposal information but no context
+ * information.
+ * 
+ * @since 5.1
+ */
+public class ChangeCorrectionProposal implements ICCompletionProposal, ICommandAccess, ICompletionProposalExtension6 {
+       private Change fChange;
+       private String fName;
+       private int fRelevance;
+       private Image fImage;
+       private String fCommandId;
+
+       /**
+        * Constructs a change correction proposal.
+        * 
+        * @param name The name that is displayed in the proposal selection dialog.
+        * @param change The change that is executed when the proposal is applied or <code>null</code>
+        * if the change will be created by implementors of {@link #createChange()}.
+        * @param relevance The relevance of this proposal.
+        * @param image The image that is displayed for this proposal or <code>null</code> if no
+        * image is desired.
+        */
+       public ChangeCorrectionProposal(String name, Change change, int relevance, Image image) {
+               if (name == null) {
+                       throw new IllegalArgumentException("Name must not be null"); //$NON-NLS-1$
+               }
+               fName= name;
+               fChange= change;
+               fRelevance= relevance;
+               fImage= image;
+               fCommandId= null;
+       }
+
+       /*
+        * @see ICompletionProposal#apply(IDocument)
+        */
+       public void apply(IDocument document) {
+               try {
+                       performChange(CUIPlugin.getActivePage().getActiveEditor(), document);
+               } catch (CoreException e) {
+                       ExceptionHandler.handle(e, CorrectionMessages.ChangeCorrectionProposal_error_title, CorrectionMessages.ChangeCorrectionProposal_error_message);
+               }
+       }
+
+       /**
+        * Performs the change associated with this proposal.
+        * 
+        * @param activeEditor The editor currently active or <code>null</code> if no
+        * editor is active.
+        * @param document The document of the editor currently active or <code>null</code> if
+        * no editor is visible.
+        * @throws CoreException Thrown when the invocation of the change failed.
+        */
+       protected void performChange(IEditorPart activeEditor, IDocument document) throws CoreException {
+               Change change= null;
+               IRewriteTarget rewriteTarget= null;
+               try {
+                       change= getChange();
+                       if (change != null) {
+                               if (document != null) {
+                                       LinkedModeModel.closeAllModels(document);
+                               }
+                               if (activeEditor != null) {
+                                       rewriteTarget= (IRewriteTarget) activeEditor.getAdapter(IRewriteTarget.class);
+                                       if (rewriteTarget != null) {
+                                               rewriteTarget.beginCompoundChange();
+                                       }
+                               }
+
+                               change.initializeValidationData(new NullProgressMonitor());
+                               RefactoringStatus valid= change.isValid(new NullProgressMonitor());
+                               if (valid.hasFatalError()) {
+                                       IStatus status= new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.ERROR,
+                                               valid.getMessageMatchingSeverity(RefactoringStatus.FATAL), null);
+                                       throw new CoreException(status);
+                               } else {
+                                       IUndoManager manager= RefactoringCore.getUndoManager();
+                                       manager.aboutToPerformChange(change);
+                                       Change undoChange= change.perform(new NullProgressMonitor());
+                                       manager.changePerformed(change, true);
+                                       if (undoChange != null) {
+                                               undoChange.initializeValidationData(new NullProgressMonitor());
+                                               manager.addUndo(getName(), undoChange);
+                                       }
+                               }
+                       }
+               } finally {
+                       if (rewriteTarget != null) {
+                               rewriteTarget.endCompoundChange();
+                       }
+
+                       if (change != null) {
+                               change.dispose();
+                       }
+               }
+       }
+
+       /*
+        * @see ICompletionProposal#getAdditionalProposalInfo()
+        */
+       public String getAdditionalProposalInfo() {
+               StringBuffer buf= new StringBuffer();
+               buf.append("<p>"); //$NON-NLS-1$
+               try {
+                       Change change= getChange();
+                       if (change != null) {
+                               String name= change.getName();
+                               if (name.length() == 0) {
+                                       return null;
+                               }
+                               buf.append(name);
+                       } else {
+                               return null;
+                       }
+               } catch (CoreException e) {
+                       buf.append("Unexpected error when accessing this proposal:<p><pre>"); //$NON-NLS-1$
+                       buf.append(e.getLocalizedMessage());
+                       buf.append("</pre>"); //$NON-NLS-1$
+               }
+               buf.append("</p>"); //$NON-NLS-1$
+               return buf.toString();
+       }
+
+       /*
+        * @see ICompletionProposal#getContextInformation()
+        */
+       public IContextInformation getContextInformation() {
+               return null;
+       }
+
+       /*
+        * @see ICompletionProposal#getDisplayString()
+        */
+       public String getDisplayString() {
+               String shortCutString= CorrectionCommandHandler.getShortCutString(getCommandId());
+               if (shortCutString != null) {
+                       return MessageFormat.format(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut, new Object[] {getName(), shortCutString});
+               }
+               return getName();
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension6#getStyledDisplayString()
+        */
+       public StyledString getStyledDisplayString() {
+               StyledString str= new StyledString(getName());
+               
+               String shortCutString= CorrectionCommandHandler.getShortCutString(getCommandId());
+               if (shortCutString != null) {
+                       String decorated= MessageFormat.format(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut, new Object[] {getName(), shortCutString});
+                       return ColoringLabelProvider.decorateStyledString(str, decorated, StyledString.QUALIFIER_STYLER); 
+               }
+               return str;
+       }
+       
+       /** 
+        * Returns the name of the proposal.
+        * 
+        * @return return the name of the proposal
+        */
+       public String getName() {
+               return fName;
+       }
+       
+       /*
+        * @see ICompletionProposal#getImage()
+        */
+       public Image getImage() {
+               return fImage;
+       }
+
+       /*
+        * @see ICompletionProposal#getSelection(IDocument)
+        */
+       public Point getSelection(IDocument document) {
+               return null;
+       }
+
+       /**
+        * Sets the proposal's image or <code>null</code> if no image is desired.
+        * 
+        * @param image the desired image.
+        */
+       public void setImage(Image image) {
+               fImage= image;
+       }
+
+       /**
+        * Returns the change that will be executed when the proposal is applied.
+        * 
+        * @return returns the change for this proposal.
+        * @throws CoreException thrown when the change could not be created
+        */
+       public final Change getChange() throws CoreException {
+               if (fChange == null) {
+                       fChange= createChange();
+               }
+               return fChange;
+       }
+
+       /**
+        * Creates the text change for this proposal.
+        * This method is only called once and only when no text change has been passed in
+        * {@link #ChangeCorrectionProposal(String, Change, int, Image)}.
+        * 
+        * @return returns the created change.
+        * @throws CoreException thrown if the creation of the change failed.
+        */
+       protected Change createChange() throws CoreException {
+               return new NullChange();
+       }
+       
+       /**
+        * Sets the display name.
+        * 
+        * @param name the name to set
+        */
+       public void setDisplayName(String name) {
+               if (name == null) {
+                       throw new IllegalArgumentException("Name must not be null"); //$NON-NLS-1$
+               }
+               fName= name;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.ui.text.c.ICCompletionProposal#getRelevance()
+        */
+       public int getRelevance() {
+               return fRelevance;
+       }
+
+       /**
+        * Sets the relevance.
+        * @param relevance the relevance to set
+        */
+       public void setRelevance(int relevance) {
+               fRelevance= relevance;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.text.correction.IShortcutProposal#getProposalId()
+        */
+       public String getCommandId() {
+               return fCommandId;
+       }
+       
+       /**
+        * Set the proposal id to allow assigning a shortcut to the correction proposal.
+        * 
+        * @param commandId The proposal id for this proposal or <code>null</code> if no command
+        * should be assigned to this proposal.
+        */
+       public void setCommandId(String commandId) {
+               fCommandId= commandId;
+       }
+
+       public String getIdString() {
+               return fCommandId;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedCorrectionProposal.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedCorrectionProposal.java
new file mode 100644 (file)
index 0000000..ae9f533
--- /dev/null
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2008 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.correction.proposals;
+
+import org.eclipse.swt.graphics.Image;
+
+import org.eclipse.cdt.core.dom.rewrite.ASTRewrite;
+import org.eclipse.cdt.core.dom.rewrite.ITrackedNodePosition;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+
+/**
+ * A proposal for quick fixes and quick assists that works on a AST rewriter and enters the
+ * linked mode when the proposal is set up.
+ * Either a rewriter is directly passed in the constructor or method {@link #getRewrite()} is
+ * overridden to provide the AST rewriter that is evaluated to the document when the proposal
+ * is applied.
+ * @since 5.1
+ */
+public class LinkedCorrectionProposal extends ASTRewriteCorrectionProposal {
+
+       /**
+        * Constructs a linked correction proposal.
+        * @param name The display name of the proposal.
+        * @param tu The translation unit that is modified.
+        * @param rewrite The AST rewrite that is invoked when the proposal is applied
+        *  <code>null</code> can be passed if {@link #getRewrite()} is overridden.
+        * @param relevance The relevance of this proposal.
+        * @param image The image that is displayed for this proposal or <code>null</code> if no
+        * image is desired.
+        */
+       public LinkedCorrectionProposal(String name, ITranslationUnit tu, ASTRewrite rewrite,
+                       int relevance, Image image) {
+               super(name, tu, rewrite, relevance, image);
+       }
+
+       /**
+        * Adds a linked position to be shown when the proposal is applied. All position with the
+        * same group id are linked.
+        * @param position The position to add.
+        * @param isFirst If set, the proposal is jumped to first.
+        * @param groupID The id of the group the proposal belongs to. All proposals in the same group
+        * are linked.
+        */
+       public void addLinkedPosition(ITrackedNodePosition position, boolean isFirst, String groupID) {
+               getLinkedProposalModel().getPositionGroup(groupID, true).addPosition(position, isFirst);
+       }
+
+       /**
+        * Sets the end position of the linked mode to the end of the passed range.
+        * @param position The position that describes the end position of the linked mode.
+        */
+       public void setEndPosition(ITrackedNodePosition position) {
+               getLinkedProposalModel().setEndPosition(position);
+       }
+
+       /**
+        * Adds a linked position proposal to the group with the given id.
+        * @param groupID The id of the group that should present the proposal
+        * @param proposal The string to propose.
+        * @param image The image to show for the position proposal or <code>null</code> if
+        * no image is desired.
+        */
+       public void addLinkedPositionProposal(String groupID, String proposal, Image image) {
+               getLinkedProposalModel().getPositionGroup(groupID, true).addProposal(proposal, image, 10);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedNamesAssistProposal.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/LinkedNamesAssistProposal.java
new file mode 100644 (file)
index 0000000..4a98318
--- /dev/null
@@ -0,0 +1,328 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.correction.proposals;
+
+import java.util.Arrays;
+import java.util.Comparator;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2;
+import org.eclipse.jface.text.contentassist.ICompletionProposalExtension6;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.link.LinkedModeModel;
+import org.eclipse.jface.text.link.LinkedModeUI;
+import org.eclipse.jface.text.link.LinkedModeUI.ExitFlags;
+import org.eclipse.jface.text.link.LinkedModeUI.IExitPolicy;
+import org.eclipse.jface.text.link.LinkedPosition;
+import org.eclipse.jface.text.link.LinkedPositionGroup;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.texteditor.link.EditorLinkedModeUI;
+
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNodeSelector;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.ICCompletionProposal;
+
+import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
+
+import org.eclipse.cdt.internal.ui.editor.ASTProvider;
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.editor.EditorHighlightingSynchronizer;
+import org.eclipse.cdt.internal.ui.search.LinkedNamesFinder;
+import org.eclipse.cdt.internal.ui.text.correction.CorrectionCommandHandler;
+import org.eclipse.cdt.internal.ui.text.correction.CorrectionMessages;
+import org.eclipse.cdt.internal.ui.text.correction.ICommandAccess;
+import org.eclipse.cdt.internal.ui.viewsupport.ColoringLabelProvider;
+
+/**
+ * A proposal.allowing user to edit in place all occurrences of a name.
+ */
+public class LinkedNamesAssistProposal implements ICCompletionProposal, ICompletionProposalExtension2,
+               ICompletionProposalExtension6, ICommandAccess {
+
+       /**
+        * An exit policy that skips Backspace and Delete at the beginning and at the end
+        * of a linked position, respectively.
+        * 
+        * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=183925 .
+        */
+       public static class DeleteBlockingExitPolicy implements IExitPolicy {
+               private IDocument fDocument;
+
+               public DeleteBlockingExitPolicy(IDocument document) {
+                       fDocument= document;
+               }
+
+               public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) {
+                       if (length == 0 && (event.character == SWT.BS || event.character == SWT.DEL)) {
+                               LinkedPosition position= model.findPosition(new LinkedPosition(fDocument, offset, 0, LinkedPositionGroup.NO_STOP));
+                               if (position != null) {
+                                       if (event.character == SWT.BS) {
+                                               if (offset - 1 < position.getOffset()) {
+                                                       //skip backspace at beginning of linked position
+                                                       event.doit= false;
+                                               }
+                                       } else /* event.character == SWT.DEL */ {
+                                               if (offset + 1 > position.getOffset() + position.getLength()) {
+                                                       //skip delete at end of linked position
+                                                       event.doit= false;
+                                               }
+                                       }
+                               }
+                       }
+
+                       return null; // don't change behavior
+               }
+       }
+
+
+       public static final String ASSIST_ID= "org.eclipse.cdt.ui.correction.renameInFile.assist"; //$NON-NLS-1$
+
+       private ITranslationUnit fTranslationUnit;
+       private String fLabel;
+       private String fValueSuggestion;
+       private int fRelevance;
+       private IRegion[] fLocations;
+
+       public LinkedNamesAssistProposal(ITranslationUnit tu) {
+               this(CorrectionMessages.LinkedNamesAssistProposal_description, tu, null);
+               fTranslationUnit= tu;
+               fRelevance= 8;
+       }
+
+       public LinkedNamesAssistProposal(String label, ITranslationUnit tu, String valueSuggestion) {
+               fLabel= label;
+               fTranslationUnit= tu;
+               fValueSuggestion= valueSuggestion;
+               fRelevance= 8;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#apply(org.eclipse.jface.text.ITextViewer, char, int, int)
+        */
+       public void apply(final ITextViewer viewer, char trigger, int stateMask, final int offset) {
+               try {
+                       fLocations = null;
+                       Point selection= viewer.getSelectedRange();
+                       final int secectionOffset = selection.x;
+                       final int selectionLength = selection.y;
+
+                       ASTProvider.getASTProvider().runOnAST(fTranslationUnit, ASTProvider.WAIT_ACTIVE_ONLY,
+                                       new NullProgressMonitor(), new ASTRunnable() {
+
+                               public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException {
+                                       if (astRoot == null)
+                                               return Status.CANCEL_STATUS;
+                                       
+                                       IASTNodeSelector selector= astRoot.getNodeSelector(null);
+                                       IASTName name= selector.findEnclosingName(secectionOffset, selectionLength);
+                                       if (name != null) {
+                                               fLocations = LinkedNamesFinder.findByName(astRoot, name);
+                                       }
+                                       return Status.OK_STATUS;
+                               }
+                       });
+
+                       if (fLocations == null || fLocations.length == 0) {
+                               return;
+                       }
+
+                       // Sort the locations starting with the one @ offset.
+                       Arrays.sort(fLocations, new Comparator<IRegion>() {
+
+                               public int compare(IRegion n1, IRegion n2) {
+                                       return rank(n1) - rank(n2);
+                               }
+
+                               /**
+                                * Returns the absolute rank of a location. Location preceding <code>offset</code>
+                                * are ranked last.
+                                *
+                                * @param location the location to compute the rank for
+                                * @return the rank of the location with respect to the invocation offset
+                                */
+                               private int rank(IRegion location) {
+                                       int relativeRank= location.getOffset() + location.getLength() - offset;
+                                       if (relativeRank < 0)
+                                               return Integer.MAX_VALUE + relativeRank;
+                                       else
+                                               return relativeRank;
+                               }
+                       });
+                       
+                       IDocument document= viewer.getDocument();
+                       LinkedPositionGroup group= new LinkedPositionGroup();
+                       for (int i= 0; i < fLocations.length; i++) {
+                               IRegion item= fLocations[i];
+                               group.addPosition(new LinkedPosition(document, item.getOffset(), item.getLength(), i));
+                       }
+
+                       LinkedModeModel model= new LinkedModeModel();
+                       model.addGroup(group);
+                       model.forceInstall();
+                       CEditor editor= getCEditor();
+                       if (editor != null) {
+                               model.addLinkingListener(new EditorHighlightingSynchronizer(editor));
+                       }
+
+                       LinkedModeUI ui= new EditorLinkedModeUI(model, viewer);
+                       ui.setExitPolicy(new DeleteBlockingExitPolicy(document));
+                       ui.setExitPosition(viewer, offset, 0, LinkedPositionGroup.NO_STOP);
+                       ui.enter();
+
+                       if (fValueSuggestion != null) {
+                               document.replace(fLocations[0].getOffset(), fLocations[0].getLength(), fValueSuggestion);
+                               IRegion selectedRegion= ui.getSelectedRegion();
+                               selection= new Point(selectedRegion.getOffset(), fValueSuggestion.length());
+                       }
+
+                       viewer.setSelectedRange(selection.x, selection.y); // By default full word is selected, restore original selection
+               } catch (BadLocationException e) {
+                       CUIPlugin.log(e);
+               }
+       }
+
+       /**
+        * Returns the currently active C editor, or <code>null</code> if it
+        * cannot be determined.
+        *
+        * @return  the currently active C editor, or <code>null</code>
+        */
+       private CEditor getCEditor() {
+               IEditorPart part= CUIPlugin.getActivePage().getActiveEditor();
+               if (part instanceof CEditor)
+                       return (CEditor) part;
+               else
+                       return null;
+       }
+
+       /*
+        * @see ICompletionProposal#apply(IDocument)
+        */
+       public void apply(IDocument document) {
+               // can't do anything
+       }
+
+       /*
+        * @see ICompletionProposal#getSelection(IDocument)
+        */
+       public Point getSelection(IDocument document) {
+               return null;
+       }
+
+       /*
+        * @see ICompletionProposal#getAdditionalProposalInfo()
+        */
+       public String getAdditionalProposalInfo() {
+               return CorrectionMessages.LinkedNamesAssistProposal_proposalinfo;
+       }
+
+       /*
+        * @see ICompletionProposal#getDisplayString()
+        */
+       public String getDisplayString() {
+               String shortCutString= CorrectionCommandHandler.getShortCutString(getCommandId());
+               if (shortCutString != null) {
+                       return NLS.bind(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut,
+                                       fLabel, shortCutString);
+               }
+               return fLabel;
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension6#getStyledDisplayString()
+        */
+       public StyledString getStyledDisplayString() {
+               StyledString str= new StyledString(fLabel);
+               
+               String shortCutString= CorrectionCommandHandler.getShortCutString(getCommandId());
+               if (shortCutString != null) {
+                       String decorated= NLS.bind(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut,
+                                       fLabel, shortCutString);
+                       return ColoringLabelProvider.decorateStyledString(str, decorated, StyledString.QUALIFIER_STYLER); 
+               }
+               return str;
+       }
+
+       /*
+        * @see ICompletionProposal#getImage()
+        */
+       public Image getImage() {
+               return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_CORRECTION_LINKED_RENAME);
+       }
+
+       /*
+        * @see ICompletionProposal#getContextInformation()
+        */
+       public IContextInformation getContextInformation() {
+               return null;
+       }
+
+       /*
+        * @see ICCompletionProposal#getRelevance()
+        */
+       public int getRelevance() {
+               return fRelevance;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#selected(org.eclipse.jface.text.ITextViewer, boolean)
+        */
+       public void selected(ITextViewer textViewer, boolean smartToggle) {
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#unselected(org.eclipse.jface.text.ITextViewer)
+        */
+       public void unselected(ITextViewer textViewer) {
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#validate(org.eclipse.jface.text.IDocument, int, org.eclipse.jface.text.DocumentEvent)
+        */
+       public boolean validate(IDocument document, int offset, DocumentEvent event) {
+               return false;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.text.correction.ICommandAccess#getCommandId()
+        */
+       public String getCommandId() {
+               return ASSIST_ID;
+       }
+
+       public void setRelevance(int relevance) {
+               fRelevance= relevance;
+       }
+
+       public String getIdString() {
+               return ASSIST_ID;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/RenameRefactoringProposal.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/RenameRefactoringProposal.java
new file mode 100644 (file)
index 0000000..0c540fc
--- /dev/null
@@ -0,0 +1,136 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.correction.proposals;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.ICompletionProposalExtension6;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.viewers.StyledCellLabelProvider;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.refactoring.actions.CRenameAction;
+import org.eclipse.cdt.ui.text.ICCompletionProposal;
+
+import org.eclipse.cdt.internal.corext.util.Messages;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
+import org.eclipse.cdt.internal.ui.text.correction.CorrectionCommandHandler;
+import org.eclipse.cdt.internal.ui.text.correction.CorrectionMessages;
+import org.eclipse.cdt.internal.ui.text.correction.ICommandAccess;
+
+/**
+ * A quick assist proposal that starts the Rename refactoring.
+ */
+public class RenameRefactoringProposal implements ICCompletionProposal, ICompletionProposalExtension6, ICommandAccess {
+       private final CEditor fEditor;
+       private final String fLabel;
+       private int fRelevance;
+
+       public RenameRefactoringProposal(CEditor editor) {
+               fEditor = editor;
+               fLabel= CorrectionMessages.RenameRefactoringProposal_name;
+               fRelevance= 8;
+       }
+
+       /*
+        * @see ICompletionProposal#apply(IDocument)
+        */
+       public void apply(IDocument document) {
+               CRenameAction action= new CRenameAction();
+               action.setEditor(fEditor);
+               action.run();
+       }
+
+       /*
+        * @see ICompletionProposal#getSelection(IDocument)
+        */
+       public Point getSelection(IDocument document) {
+               return null;
+       }
+
+       /*
+        * @see ICompletionProposal#getAdditionalProposalInfo()
+        */
+       public String getAdditionalProposalInfo() {
+               return CorrectionMessages.RenameRefactoringProposal_additionalInfo;
+       }
+
+       /*
+        * @see ICompletionProposal#getDisplayString()
+        */
+       public String getDisplayString() {
+               String shortCutString= CorrectionCommandHandler.getShortCutString(getCommandId());
+               if (shortCutString != null) {
+                       return Messages.format(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut,
+                                       new String[] { fLabel, shortCutString });
+               }
+               return fLabel;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension6#getStyledDisplayString()
+        */
+       public StyledString getStyledDisplayString() {
+               StyledString str= new StyledString(fLabel);
+
+               String shortCutString= CorrectionCommandHandler.getShortCutString(getCommandId());
+               if (shortCutString != null) {
+                       String decorated= Messages.format(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut,
+                                       new String[] { fLabel, shortCutString });
+                       return StyledCellLabelProvider.styleDecoratedString(decorated, StyledString.QUALIFIER_STYLER, str);
+               }
+               return str;
+       }
+
+       /*
+        * @see ICompletionProposal#getImage()
+        */
+       public Image getImage() {
+               return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_CORRECTION_LINKED_RENAME);
+       }
+
+       /*
+        * @see ICompletionProposal#getContextInformation()
+        */
+       public IContextInformation getContextInformation() {
+               return null;
+       }
+
+       /*
+        * @see ICCompletionProposal#getRelevance()
+        */
+       public int getRelevance() {
+               return fRelevance;
+       }
+
+       /*
+        * @see ICCompletionProposal#getIdString()
+        */
+       public String getIdString() {
+               return getCommandId();
+       }
+
+       /*
+        * @see ICommandAccess#getCommandId()
+        */
+       public String getCommandId() {
+               return ICEditorActionDefinitionIds.RENAME_ELEMENT;
+       }
+
+       public void setRelevance(int relevance) {
+               fRelevance= relevance;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/TUCorrectionProposal.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/proposals/TUCorrectionProposal.java
new file mode 100644 (file)
index 0000000..5fe6cc5
--- /dev/null
@@ -0,0 +1,436 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.correction.proposals;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.DocumentChange;
+import org.eclipse.ltk.core.refactoring.TextChange;
+import org.eclipse.ltk.core.refactoring.TextFileChange;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.text.edits.CopyTargetEdit;
+import org.eclipse.text.edits.DeleteEdit;
+import org.eclipse.text.edits.InsertEdit;
+import org.eclipse.text.edits.MoveSourceEdit;
+import org.eclipse.text.edits.MoveTargetEdit;
+import org.eclipse.text.edits.MultiTextEdit;
+import org.eclipse.text.edits.ReplaceEdit;
+import org.eclipse.text.edits.TextEdit;
+import org.eclipse.text.edits.TextEditVisitor;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.refactoring.CTextFileChange;
+
+import org.eclipse.cdt.internal.corext.codemanipulation.StubUtility;
+import org.eclipse.cdt.internal.corext.fix.LinkedProposalModel;
+import org.eclipse.cdt.internal.corext.fix.LinkedProposalPositionGroup;
+import org.eclipse.cdt.internal.corext.util.Resources;
+import org.eclipse.cdt.internal.corext.util.Strings;
+
+import org.eclipse.cdt.internal.ui.CUIStatus;
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.text.correction.CorrectionMessages;
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
+import org.eclipse.cdt.internal.ui.viewsupport.LinkedProposalModelPresenter;
+
+/**
+ * A proposal for quick fixes and quick assist that work on a single compilation unit.
+ * Either a {@link TextChange text change} is directly passed in the constructor or method
+ * {@link #addEdits(IDocument, TextEdit)} is overridden to provide the text edits that are
+ * applied to the document when the proposal is evaluated.
+ * <p>
+ * The proposal takes care of the preview of the changes as proposal information.
+ * </p>
+ * @since 5.1
+ */
+public class TUCorrectionProposal extends ChangeCorrectionProposal  {
+       private ITranslationUnit fTranslationUnit;
+       private LinkedProposalModel fLinkedProposalModel;
+
+       /**
+        * Constructs a correction proposal working on a compilation unit with a given text change
+        *
+        * @param name the name that is displayed in the proposal selection dialog.
+        * @param tu the compilation unit on that the change works.
+        * @param change the change that is executed when the proposal is applied or <code>null</code>
+        * if implementors override {@link #addEdits(IDocument, TextEdit)} to provide
+        * the text edits or {@link #createTextChange()} to provide a text change.
+        * @param relevance the relevance of this proposal.
+        * @param image the image that is displayed for this proposal or <code>null</code> if no
+        * image is desired.
+        */
+       public TUCorrectionProposal(String name, ITranslationUnit tu, TextChange change, int relevance, Image image) {
+               super(name, change, relevance, image);
+               if (tu == null) {
+                       throw new IllegalArgumentException("Translation unit must not be null"); //$NON-NLS-1$
+               }
+               fTranslationUnit= tu;
+               fLinkedProposalModel= null;
+       }
+
+       /**
+        * Constructs a correction proposal working on a compilation unit.
+        * <p>Users have to override {@link #addEdits(IDocument, TextEdit)} to provide
+        * the text edits or {@link #createTextChange()} to provide a text change.
+        * </p>
+        *
+        * @param name The name that is displayed in the proposal selection dialog.
+        * @param tu The compilation unit on that the change works.
+        * @param relevance The relevance of this proposal.
+        * @param image The image that is displayed for this proposal or <code>null</code> if no
+        * image is desired.
+        */
+       protected TUCorrectionProposal(String name, ITranslationUnit tu, int relevance, Image image) {
+               this(name, tu, null, relevance, image);
+       }
+
+       /**
+        * Called when the {@link CTextFileChange} is initialized. Subclasses can override to
+        * add text edits to the root edit of the change. Implementors must not access the proposal,
+        * e.g getting the change.
+        * <p>The default implementation does not add any edits</p>
+        *
+        * @param document content of the underlying compilation unit. To be accessed read only.
+        * @param editRoot The root edit to add all edits to
+        * @throws CoreException can be thrown if adding the edits is failing.
+        */
+       protected void addEdits(IDocument document, TextEdit editRoot) throws CoreException {
+//             if (false) {
+//                     throw new CoreException(CUIStatus.createError(IStatus.ERROR, "Implementors can throw an exception", null)); //$NON-NLS-1$
+//             }
+       }
+
+       protected LinkedProposalModel getLinkedProposalModel() {
+               if (fLinkedProposalModel == null) {
+                       fLinkedProposalModel= new LinkedProposalModel();
+               }
+               return fLinkedProposalModel;
+       }
+
+       public void setLinkedProposalModel(LinkedProposalModel model) {
+               fLinkedProposalModel= model;
+       }
+
+       /*
+        * @see ICompletionProposal#getAdditionalProposalInfo()
+        */
+       @Override
+       public String getAdditionalProposalInfo() {
+               final StringBuffer buf= new StringBuffer();
+
+               try {
+                       final TextChange change= getTextChange();
+
+                       change.setKeepPreviewEdits(true);
+                       final IDocument previewContent= change.getPreviewDocument(new NullProgressMonitor());
+                       final TextEdit rootEdit= change.getPreviewEdit(change.getEdit());
+
+                       class EditAnnotator extends TextEditVisitor {
+                               private int fWrittenToPos = 0;
+
+                               public void unchangedUntil(int pos) {
+                                       if (pos > fWrittenToPos) {
+                                               appendContent(previewContent, fWrittenToPos, pos, buf, true);
+                                               fWrittenToPos = pos;
+                                       }
+                               }
+
+                               @Override
+                               public boolean visit(MoveTargetEdit edit) {
+                                       return true; //rangeAdded(edit);
+                               }
+
+                               @Override
+                               public boolean visit(CopyTargetEdit edit) {
+                                       return true; //return rangeAdded(edit);
+                               }
+
+                               @Override
+                               public boolean visit(InsertEdit edit) {
+                                       return rangeAdded(edit);
+                               }
+
+                               @Override
+                               public boolean visit(ReplaceEdit edit) {
+                                       if (edit.getLength() > 0)
+                                               return rangeAdded(edit);
+                                       return rangeRemoved(edit);
+                               }
+
+                               @Override
+                               public boolean visit(MoveSourceEdit edit) {
+                                       return rangeRemoved(edit);
+                               }
+
+                               @Override
+                               public boolean visit(DeleteEdit edit) {
+                                       return rangeRemoved(edit);
+                               }
+
+                               private boolean rangeRemoved(TextEdit edit) {
+                                       unchangedUntil(edit.getOffset());
+                                       return false;
+                               }
+
+                               private boolean rangeAdded(TextEdit edit) {
+                                       unchangedUntil(edit.getOffset());
+                                       buf.append("<b>"); //$NON-NLS-1$
+                                       appendContent(previewContent, edit.getOffset(), edit.getExclusiveEnd(), buf, false);
+                                       buf.append("</b>"); //$NON-NLS-1$
+                                       fWrittenToPos = edit.getExclusiveEnd();
+                                       return false;
+                               }
+                       }
+                       EditAnnotator ea = new EditAnnotator();
+                       rootEdit.accept(ea);
+
+                       // Final pre-existing region
+                       ea.unchangedUntil(previewContent.getLength());
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }
+               return buf.toString();
+       }
+
+       private final int surroundLines= 1;
+
+       private void appendContent(IDocument text, int startOffset, int endOffset, StringBuffer buf, boolean surroundLinesOnly) {
+               try {
+                       int startLine= text.getLineOfOffset(startOffset);
+                       int endLine= text.getLineOfOffset(endOffset);
+
+                       boolean dotsAdded= false;
+                       if (surroundLinesOnly && startOffset == 0) { // no surround lines for the top no-change range
+                               startLine= Math.max(endLine - surroundLines, 0);
+                               buf.append("...<br>"); //$NON-NLS-1$
+                               dotsAdded= true;
+                       }
+
+                       for (int i= startLine; i <= endLine; i++) {
+                               if (surroundLinesOnly) {
+                                       if ((i - startLine > surroundLines) && (endLine - i > surroundLines)) {
+                                               if (!dotsAdded) {
+                                                       buf.append("...<br>"); //$NON-NLS-1$
+                                                       dotsAdded= true;
+                                               } else if (endOffset == text.getLength()) {
+                                                       return; // no surround lines for the bottom no-change range
+                                               }
+                                               continue;
+                                       }
+                               }
+
+                               IRegion lineInfo= text.getLineInformation(i);
+                               int start= lineInfo.getOffset();
+                               int end= start + lineInfo.getLength();
+
+                               int from= Math.max(start, startOffset);
+                               int to= Math.min(end, endOffset);
+                               String content= text.get(from, to - from);
+                               if (surroundLinesOnly && (from == start) && Strings.containsOnlyWhitespaces(content)) {
+                                       continue; // ignore empty lines except when range started in the middle of a line
+                               }
+                               for (int k= 0; k < content.length(); k++) {
+                                       char ch= content.charAt(k);
+                                       if (ch == '<') {
+                                               buf.append("&lt;"); //$NON-NLS-1$
+                                       } else if (ch == '>') {
+                                               buf.append("&gt;"); //$NON-NLS-1$
+                                       } else {
+                                               buf.append(ch);
+                                       }
+                               }
+                               if (to == end && to != endOffset) { // new line when at the end of the line, and not end of range
+                                       buf.append("<br>"); //$NON-NLS-1$
+                               }
+                       }
+               } catch (BadLocationException e) {
+                       // ignore
+               }
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument)
+        */
+       @Override
+       public void apply(IDocument document) {
+               try {
+                       ITranslationUnit unit= getTranslationUnit();
+                       IEditorPart part= null;
+                       if (unit.getResource().exists()) {
+                               boolean canEdit= performValidateEdit(unit);
+                               if (!canEdit) {
+                                       return;
+                               }
+                               part= EditorUtility.isOpenInEditor(unit);
+                               if (part == null) {
+                                       part= EditorUtility.openInEditor(unit);
+                                       if (part != null) {
+                                               document= CUIPlugin.getDefault().getDocumentProvider().getDocument(part.getEditorInput());
+                                       }
+                               }
+                               IWorkbenchPage page= CUIPlugin.getActivePage();
+                               if (page != null && part != null) {
+                                       page.bringToTop(part);
+                               }
+                               if (part != null) {
+                                       part.setFocus();
+                               }
+                       }
+                       performChange(part, document);
+               } catch (CoreException e) {
+                       ExceptionHandler.handle(e, CorrectionMessages.TUCorrectionProposal_error_title,
+                                       CorrectionMessages.TUCorrectionProposal_error_message);
+               }
+       }
+
+       private boolean performValidateEdit(ITranslationUnit unit) {
+               IStatus status= Resources.makeCommittable(unit.getResource(), CUIPlugin.getActiveWorkbenchShell());
+               if (!status.isOK()) {
+                       String label= CorrectionMessages.TUCorrectionProposal_error_title;
+                       String message= CorrectionMessages.TUCorrectionProposal_error_message;
+                       ErrorDialog.openError(CUIPlugin.getActiveWorkbenchShell(), label, message, status);
+                       return false;
+               }
+               return true;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.text.correction.ChangeCorrectionProposal#performChange(org.eclipse.jface.text.IDocument, org.eclipse.ui.IEditorPart)
+        */
+       @Override
+       protected void performChange(IEditorPart part, IDocument document) throws CoreException {
+               try {
+                       super.performChange(part, document);
+                       if (part == null) {
+                               return;
+                       }
+
+                       if (fLinkedProposalModel != null) {
+                               if (fLinkedProposalModel.hasLinkedPositions() && part instanceof CEditor) {
+                                       // enter linked mode
+                                       ITextViewer viewer= ((CEditor) part).getViewer();
+                                       new LinkedProposalModelPresenter().enterLinkedMode(viewer, part, fLinkedProposalModel);
+                               } else if (part instanceof ITextEditor) {
+                                       LinkedProposalPositionGroup.PositionInformation endPosition= fLinkedProposalModel.getEndPosition();
+                                       if (endPosition != null) {
+                                               // select a result
+                                               int pos= endPosition.getOffset() + endPosition.getLength();
+                                               ((ITextEditor) part).selectAndReveal(pos, 0);
+                                       }
+                               }
+                       }
+               } catch (BadLocationException e) {
+                       throw new CoreException(CUIStatus.createError(IStatus.ERROR, e));
+               }
+       }
+
+       /**
+        * Creates the text change for this proposal.
+        * This method is only called once and only when no text change has been passed in
+        * {@link #TUCorrectionProposal(String, ITranslationUnit, TextChange, int, Image)}.
+        *
+        * @return returns the created text change.
+        * @throws CoreException thrown if the creation of the text change failed.
+        */
+       protected TextChange createTextChange() throws CoreException {
+               ITranslationUnit tu= getTranslationUnit();
+               String name= getName();
+               TextChange change;
+               if (!tu.getResource().exists()) {
+                       String source;
+                       try {
+                               source= tu.getSource();
+                       } catch (CModelException e) {
+                               CUIPlugin.log(e);
+                               source= new String(); // empty
+                       }
+                       Document document= new Document(source);
+                       document.setInitialLineDelimiter(StubUtility.getLineDelimiterUsed(tu));
+                       change= new DocumentChange(name, document);
+               } else {
+                       CTextFileChange tuChange = new CTextFileChange(name, tu);
+                       tuChange.setSaveMode(TextFileChange.LEAVE_DIRTY);
+                       change= tuChange;
+               }
+               TextEdit rootEdit= new MultiTextEdit();
+               change.setEdit(rootEdit);
+
+               // initialize text change
+               IDocument document= change.getCurrentDocument(new NullProgressMonitor());
+               addEdits(document, rootEdit);
+               return change;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.text.correction.ChangeCorrectionProposal#createChange()
+        */
+       @Override
+       protected final Change createChange() throws CoreException {
+               return createTextChange(); // make sure that only text changes are allowed here
+       }
+
+       /**
+        * Gets the text change that is invoked when the change is applied.
+        *
+        * @return returns the text change that is invoked when the change is applied.
+        * @throws CoreException throws an exception if accessing the change failed
+        */
+       public final TextChange getTextChange() throws CoreException {
+               return (TextChange) getChange();
+       }
+
+       /**
+        * The compilation unit on that the change works.
+        *
+        * @return the compilation unit on that the change works.
+        */
+       public final ITranslationUnit getTranslationUnit() {
+               return fTranslationUnit;
+       }
+
+       /**
+        * Creates a preview of the content of the compilation unit after applying the change.
+        *
+        * @return returns the preview of the changed compilation unit.
+        * @throws CoreException thrown if the creation of the change failed.
+        */
+       public String getPreviewContent() throws CoreException {
+               return getTextChange().getPreviewContent(new NullProgressMonitor());
+       }
+
+       /* (non-Javadoc)
+        * @see java.lang.Object#toString()
+        */
+       @Override
+       public String toString() {
+               try {
+                       return getPreviewContent();
+               } catch (CoreException e) {
+               }
+               return super.toString();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/AbstractDocCommentProposalComputer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/AbstractDocCommentProposalComputer.java
new file mode 100644 (file)
index 0000000..04af9f9
--- /dev/null
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.doctools;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.IWorkingCopyManager;
+import org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext;
+import org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration;
+
+
+abstract class AbstractDocCommentProposalComputer implements ICompletionProposalComputer {
+       
+       protected abstract IDocCommentViewerConfiguration getConfiguration(IDocCommentOwner owner);
+       
+       protected final IDocCommentViewerConfiguration getConfiguration() {
+               IResource resource= getResource();
+               IDocCommentOwner owner= DocCommentOwnerManager.getInstance().getCommentOwner(resource);
+               return getConfiguration(owner);
+       }
+       
+       public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+               return getConfiguration().createProposalComputer().computeCompletionProposals(context, monitor);
+       }
+
+       public List<IContextInformation> computeContextInformation(
+                       ContentAssistInvocationContext context, IProgressMonitor monitor) {
+               return getConfiguration().createProposalComputer().computeContextInformation(context, monitor);
+       }
+
+       public String getErrorMessage() {
+               return getConfiguration().createProposalComputer().getErrorMessage();
+       }
+
+       public void sessionEnded() {
+               // XXX
+       }
+
+       public void sessionStarted() {
+               // XXX
+       }
+       
+       
+       private static IResource getResource() {
+               ITranslationUnit tu= getTranslationUnit();
+               return tu.getResource();
+       }
+       
+       private static ITranslationUnit getTranslationUnit() {
+               IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+               if (window == null)
+                       return null;
+
+               IWorkbenchPage page= window.getActivePage();
+               if (page == null)
+                       return null;
+
+               IEditorPart editor= page.getActiveEditor();
+               if (editor == null)
+                       return null;
+
+               IWorkingCopyManager manager= CUIPlugin.getDefault().getWorkingCopyManager();
+               ITranslationUnit unit= manager.getWorkingCopy(editor.getEditorInput());
+               if (unit == null)
+                       return null;
+
+               return unit;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentMultilineProposalComputer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentMultilineProposalComputer.java
new file mode 100644 (file)
index 0000000..fa15ccd
--- /dev/null
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.doctools;
+
+import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration;
+
+public class DocCommentMultilineProposalComputer extends AbstractDocCommentProposalComputer {
+       @Override
+       protected IDocCommentViewerConfiguration getConfiguration(IDocCommentOwner owner) {
+               return owner.getMultilineConfiguration();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentOwner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentOwner.java
new file mode 100644 (file)
index 0000000..1369c23
--- /dev/null
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.doctools;
+
+import org.eclipse.core.runtime.Assert;
+
+import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration;
+
+/**
+ * Internal implementation of IDocCommentOwner
+ */
+public class DocCommentOwner implements IDocCommentOwner {
+       private final String id;
+       private final String name;
+       private final IDocCommentViewerConfiguration multi, single;
+       
+       public DocCommentOwner(String id, String name, IDocCommentViewerConfiguration multi, IDocCommentViewerConfiguration single) {
+               Assert.isNotNull(id); Assert.isNotNull(name); Assert.isNotNull(multi); Assert.isNotNull(single);
+               this.id= id;
+               this.name= name;
+               this.multi= multi;
+               this.single= single;
+       }
+       
+       /*
+        * @see org.eclipse.cdt.ui.text.ICCommentOwner#getID()
+        */
+       public String getID() {
+               return id;
+       }
+       
+       /*
+        * @see org.eclipse.cdt.ui.text.ICCommentOwner#getName()
+        */
+       public String getName() {
+               return name;
+       }
+       
+       /*
+        * @see org.eclipse.cdt.ui.text.ICCommentOwner#getMultilineConfiguration()
+        */
+       public IDocCommentViewerConfiguration getMultilineConfiguration() {
+               return multi;
+       }
+       
+       /*
+        * @see org.eclipse.cdt.ui.text.ICCommentOwner#getSinglelineConfiguration()
+        */
+       public IDocCommentViewerConfiguration getSinglelineConfiguration() {
+               return single;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentOwnerManager.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentOwnerManager.java
new file mode 100644 (file)
index 0000000..286f63a
--- /dev/null
@@ -0,0 +1,267 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Andrew Ferguson (Symbian) - Initial implementation
+ *     IBM Corporation
+ *     Johan Ekberg -  Bug 285932
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.doctools;
+
+import com.ibm.icu.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.osgi.service.prefs.Preferences;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentOwnershipListener;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration;
+
+/**
+ * This class manages which IDocCommentOwner's are available in the run-time, and how they map to
+ * resources in projects.
+ * @since 5.0
+ */
+public class DocCommentOwnerManager {
+       /** Constants for attributes/elements from the DocCommentOwner extension point */
+       private static final String ELEMENT_OWNER = "owner"; //$NON-NLS-1$
+       private static final String ATTRKEY_OWNER_ID = "id"; //$NON-NLS-1$
+       private static final String ATTRKEY_OWNER_NAME = "name"; //$NON-NLS-1$
+       private static final String ATTRKEY_OWNER_SINGLELINE = "singleline"; //$NON-NLS-1$
+       private static final String ATTRKEY_OWNER_MULTILINE = "multiline"; //$NON-NLS-1$
+
+       private static final String QUALIFIER= CCorePlugin.PLUGIN_ID;
+       private static final String WORKSPACE_DOC_TOOL_NODE= "doctool"; //$NON-NLS-1$
+       private static final String PREFKEY_WORKSPACE_DEFAULT= "workspace.default"; //$NON-NLS-1$
+       
+       private static DocCommentOwnerManager singleton;
+
+       public static DocCommentOwnerManager getInstance() {
+               return singleton == null ? singleton= new DocCommentOwnerManager() : singleton;
+       }
+
+       private Map<String, IDocCommentOwner> fOwners;
+       private IDocCommentOwner fWorkspaceOwner;
+       private Map<IProject, ProjectMap> prj2map= new HashMap<IProject, ProjectMap>();
+       private static List<IDocCommentOwnershipListener> fListeners;
+
+       private DocCommentOwnerManager() {
+               fOwners= getCommentOwnerExtensions();
+               fListeners= new ArrayList<IDocCommentOwnershipListener>();
+
+           Preferences defaultPrefs = DefaultScope.INSTANCE.getNode(QUALIFIER).node(WORKSPACE_DOC_TOOL_NODE);
+               Preferences prefs= InstanceScope.INSTANCE.getNode(QUALIFIER).node(WORKSPACE_DOC_TOOL_NODE);
+           String id= prefs.get(PREFKEY_WORKSPACE_DEFAULT, defaultPrefs.get(PREFKEY_WORKSPACE_DEFAULT,
+                       NullDocCommentOwner.INSTANCE.getID()));
+               
+               fWorkspaceOwner= getOwner(id);
+               if (fWorkspaceOwner == null) {
+                       // this could occur if a plug-in is no longer available
+                       fWorkspaceOwner= NullDocCommentOwner.INSTANCE;
+               }
+       }
+
+       /**
+        * @param project a non-null project
+        * @return whether the specified project defines any documentation owner association 
+        */
+       public boolean projectDefinesOwnership(IProject project) {
+               return !getProjectMap(project).isEmpty();
+       }
+
+       /**
+        * @param newOwner the non-null doc-comment owner
+        */
+       public void setWorkspaceCommentOwner(IDocCommentOwner newOwner) {
+               if (newOwner == null)
+                       throw new IllegalArgumentException();
+               
+               if (!fWorkspaceOwner.getID().equals(newOwner.getID())) {
+                       IDocCommentOwner oldOwner= fWorkspaceOwner;
+                       fWorkspaceOwner= newOwner;
+
+                       Preferences prefs= InstanceScope.INSTANCE.getNode(QUALIFIER).node(WORKSPACE_DOC_TOOL_NODE);
+                       prefs.put(PREFKEY_WORKSPACE_DEFAULT, newOwner.getID());
+                       
+                       fireWorkspaceOwnershipChanged(oldOwner, fWorkspaceOwner);
+               }
+       }
+
+       /**
+        * @return the doc comment owner associated with the workspace. If non
+        * is set, the {@link NullDocCommentOwner} is returned.
+        */
+       public IDocCommentOwner getWorkspaceCommentOwner() {
+               return fWorkspaceOwner;
+       }
+
+       /**
+        * 
+        * @param resource May be null.
+        * @return a non-null IDocCommentOwner. If the resource was null, the {@link NullDocCommentOwner} is returned.
+        */
+       public IDocCommentOwner getCommentOwner(IResource resource) {
+               if (resource==null)
+                       return NullDocCommentOwner.INSTANCE;
+
+               if (ResourcesPlugin.getWorkspace().getRoot().equals(resource))
+                       return getWorkspaceCommentOwner();
+
+               ProjectMap pm= getProjectMap(resource);
+               String ownerID= pm.getOwnerID(resource);
+               IDocCommentOwner result= getOwner(ownerID);
+               return result == null ? fWorkspaceOwner : result;
+       }
+
+       /**
+        * @param id
+        * @return the {@link IDocCommentOwner} with the specified id, or null
+        */
+       public IDocCommentOwner getOwner(String id) {
+               if (NullDocCommentOwner.INSTANCE.getID().equals(id)) {
+                       return NullDocCommentOwner.INSTANCE;
+               }
+               return fOwners.get(id);
+       }
+
+       /**
+        * @param resource a non-null resource to map a comment owner to
+        * @param newOwner the new owner to assign, or null to inherit the parent's mapping
+        * @param removeSubMappings if the resource is an {@link IContainer}, then remove any mappings
+        * children have. <em>This is currently unimplemented.</em>
+        */
+       /*
+        * Note - this implementation currently ignores removeSubMappings.
+        */
+       public void setCommentOwner(IResource resource, IDocCommentOwner newOwner, boolean removeSubMappings) {
+               Assert.isNotNull(resource);
+
+               if (ResourcesPlugin.getWorkspace().getRoot().equals(resource)) {
+                       setWorkspaceCommentOwner(newOwner);
+                       return;
+               }
+
+               ProjectMap pm= getProjectMap(resource);
+               IDocCommentOwner oldOwner= getCommentOwner(resource);
+               pm.setCommentOwner(resource, newOwner);
+               
+               IDocCommentOwner newLogicalOwner= getCommentOwner(resource);
+               if (!newLogicalOwner.getID().equals(oldOwner.getID())) { 
+                       fireOwnershipChanged(resource, removeSubMappings, oldOwner, newLogicalOwner);
+               }
+       }
+
+       /**
+        * @return any comment owners registered against the extension point. This does not include
+        * the null comment processor.
+        */
+       public IDocCommentOwner[] getRegisteredOwners() {
+               return fOwners.values().toArray(new IDocCommentOwner[fOwners.values().size()]);
+       }
+
+
+       /**
+        * @param listener registers a listener for doc-comment ownership events
+        */
+       public void addListener(IDocCommentOwnershipListener listener) {
+               if (!fListeners.contains(listener)) {
+                       fListeners.add(listener);
+               }
+       }
+
+       /**
+        * @param listener removes a listener from those registered for doc-comment ownership events
+        */
+       public void removeListener(IDocCommentOwnershipListener listener) {
+               fListeners.remove(listener);
+       }
+
+       /*
+        * Utilities
+        */
+
+       /**
+        * @param resource a non-null resource
+        * @return the cached (or newly obtained) ProjectMap for the resources
+        * associated project.
+        */
+       private ProjectMap getProjectMap(IResource resource) {
+               Assert.isNotNull(resource);
+               IProject project= resource.getProject();
+
+               if (!prj2map.containsKey(project)) {
+                       prj2map.put(project, new ProjectMap(project));
+               }
+
+               return prj2map.get(project);
+       }
+
+       /**
+        * @return a map of ID to {@link IDocCommentOwner} for comment owners registered
+        * via the DocCommentOwner extension point
+        */
+       private static Map<String, IDocCommentOwner> getCommentOwnerExtensions() {
+               Map<String, IDocCommentOwner> result= new HashMap<String, IDocCommentOwner>();
+
+               IExtensionRegistry registry = Platform.getExtensionRegistry();
+               IExtensionPoint indexProviders = registry.getExtensionPoint(CUIPlugin.ID_COMMENT_OWNER);
+               IExtension[] extensions = indexProviders.getExtensions();
+               for (IExtension extension : extensions) {
+                       try {
+                               IConfigurationElement[] ce = extension.getConfigurationElements();
+                               for (IConfigurationElement element : ce) {
+                                       if (element.getName().equals(ELEMENT_OWNER)) { 
+                                               IDocCommentViewerConfiguration multi = (IDocCommentViewerConfiguration) element.createExecutableExtension(ATTRKEY_OWNER_MULTILINE);
+                                               IDocCommentViewerConfiguration single = (IDocCommentViewerConfiguration) element.createExecutableExtension(ATTRKEY_OWNER_SINGLELINE);
+                                               String id= element.getAttribute(ATTRKEY_OWNER_ID);
+                                               String name= element.getAttribute(ATTRKEY_OWNER_NAME);
+                                               if (result.put(id, new DocCommentOwner(id, name, multi, single))!=null) {
+                                                       String msg= MessageFormat.format(Messages.DocCommentOwnerManager_DuplicateMapping0, new Object[] {id});
+                                                       CUIPlugin.log(new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, msg));
+                                               }
+                                       }
+                               }
+                       } catch(CoreException ce) {
+                               CUIPlugin.log(ce);
+                       }
+               }
+
+               return result;
+       }
+
+       private void fireOwnershipChanged(IResource resource, boolean submappingsRemoved, IDocCommentOwner oldOwner, IDocCommentOwner newOwner) {
+               for (IDocCommentOwnershipListener docCommentOwnershipListener : fListeners) {
+                       docCommentOwnershipListener.ownershipChanged(resource, submappingsRemoved, oldOwner, newOwner);
+               }
+       }
+
+       private void fireWorkspaceOwnershipChanged(IDocCommentOwner oldOwner, IDocCommentOwner newOwner) {
+               for (IDocCommentOwnershipListener element : fListeners) {
+                       element.workspaceOwnershipChanged(oldOwner, newOwner);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentSinglelineProposalComputer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentSinglelineProposalComputer.java
new file mode 100644 (file)
index 0000000..a30b69f
--- /dev/null
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.doctools;
+
+import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration;
+
+public class DocCommentSinglelineProposalComputer extends AbstractDocCommentProposalComputer {
+       @Override
+       protected IDocCommentViewerConfiguration getConfiguration(IDocCommentOwner owner) {
+               return owner.getSinglelineConfiguration();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentSpellDictionary.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentSpellDictionary.java
new file mode 100644 (file)
index 0000000..4bef3cb
--- /dev/null
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.doctools;
+
+import java.net.URL;
+
+import org.eclipse.core.runtime.Assert;
+
+import org.eclipse.cdt.ui.text.doctools.IDocCommentSimpleDictionary;
+
+import org.eclipse.cdt.internal.ui.text.spelling.engine.AbstractSpellDictionary;
+import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellDictionary;
+
+/**
+ * Adapter from interim public {@link IDocCommentSimpleDictionary} to internal {@link ISpellDictionary}
+ */
+public class DocCommentSpellDictionary extends AbstractSpellDictionary {
+
+       protected IDocCommentSimpleDictionary fDict;
+       
+       /**
+        * @param dict
+        */
+       public DocCommentSpellDictionary(IDocCommentSimpleDictionary dict) {
+               Assert.isNotNull(dict);
+               fDict= dict;
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.AbstractSpellDictionary#getName()
+        */
+       @Override
+       protected final URL getURL() {
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.spelling.engine.AbstractSpellDictionary#load(java.net.URL)
+        */
+       @Override
+       protected synchronized boolean load(final URL url) {
+               unload();
+
+               String[] words= fDict.getAdditionalWords();
+               for(int i=0; i<words.length; i++)
+                       hashWord(words[i]);
+               
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/EditorReopener.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/EditorReopener.java
new file mode 100644 (file)
index 0000000..c043d38
--- /dev/null
@@ -0,0 +1,181 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.doctools;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.progress.WorkbenchJob;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentOwnershipListener;
+
+import org.eclipse.cdt.internal.ui.editor.ITranslationUnitEditorInput;
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
+
+/**
+ * Listens to change in doc-comment ownership and reinitializes
+ * the editors (or a safe superset of) that need reopening.
+ */
+public class EditorReopener implements IDocCommentOwnershipListener {
+
+       /*
+        * @see org.eclipse.cdt.ui.text.doctools.IDocCommentOwnershipListener#ownershipChanged(org.eclipse.core.resources.IResource, boolean, org.eclipse.cdt.ui.text.doctools.IDocCommentOwner, org.eclipse.cdt.ui.text.doctools.IDocCommentOwner)
+        */
+       public void ownershipChanged(IResource resource, boolean recursive,
+                       IDocCommentOwner old, IDocCommentOwner newOwner) {
+               IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+               if(window!=null) {
+                       try {
+                               IEditorPart[] parts= getEditorsToRepon(window, resource);
+                               if(queryIfNeeded(window.getShell(), parts)) {
+                                       reopenEditors(window, parts);
+                               }
+                       } catch(CoreException ce) {
+                               CUIPlugin.log(ce);
+                       }
+               }
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.doctools.IDocCommentOwnershipListener#workspaceOwnershipChanged(org.eclipse.cdt.ui.text.doctools.IDocCommentOwner, org.eclipse.cdt.ui.text.doctools.IDocCommentOwner)
+        */
+       public void workspaceOwnershipChanged(IDocCommentOwner old, IDocCommentOwner newOwner) {
+               IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+               if(window!=null) {
+                       try {
+                               IEditorPart[] parts= getEditorsToRepon(window, null);
+                               if(queryIfNeeded(window.getShell(), parts)) {
+                                       reopenEditors(window, parts);
+                               }
+                       } catch(CoreException ce) {
+                               CUIPlugin.log(ce);
+                       }
+               }
+       }
+
+       /**
+        * @param window
+        * @param resource may be null to indicate all CDT editors should be reopened
+        * @return an array of {@link IEditorPart} objects that might need to be reinitialized
+        * based on doc-comment ownership of the specified resource changing
+        */
+       /*
+        * This could be smarter in determining smaller sets of editors to re-open
+        */
+       private IEditorPart[] getEditorsToRepon(IWorkbenchWindow window, IResource resource) {
+               List<IEditorPart> needReopening= new ArrayList<IEditorPart>();
+               if(window.getActivePage()!=null) {
+                       IEditorReference[] es= window.getActivePage().getEditorReferences();
+                       for(int i=0; i<es.length; i++) {
+                               IEditorPart part= es[i].getEditor(false);
+                               if(part!=null) {
+                                       IEditorInput iei= part.getEditorInput();
+                                       if(resource!=null) {
+                                               if(iei instanceof IFileEditorInput) {
+                                                       IFile file= ((IFileEditorInput) iei).getFile();
+                                                       IProject project= resource.getProject();
+                                                       if(file.getProject().equals(project) && CoreModel.hasCNature(project)) {
+                                                               needReopening.add(part);
+                                                       }
+                                               }
+                                       } else {
+                                               if(iei instanceof ITranslationUnitEditorInput || iei instanceof IFileEditorInput) {
+                                                       needReopening.add(part);
+                                               }
+                                       }
+                               }
+                       }
+               }
+               return needReopening.toArray(new IEditorPart[needReopening.size()]);
+       }
+
+       private boolean queryIfNeeded(Shell shell, IEditorPart[] editorParts) throws CoreException {
+               boolean anyUnsaved= false;
+               for(int j=0; j<editorParts.length; j++)
+                       if(editorParts[j].isSaveOnCloseNeeded())
+                               anyUnsaved= true;
+
+               boolean saveAndReopen= !anyUnsaved;
+               if(anyUnsaved) {
+                       String title= Messages.EditorReopener_ShouldSave_Title;
+                       String msg= Messages.EditorReopener_ShouldSave_Message; 
+
+                       if (MessageDialog.openQuestion(shell, title, msg))
+                               saveAndReopen= true;
+               }
+               return saveAndReopen;
+       }
+
+       private void reopenEditors(final IWorkbenchWindow window, final IEditorPart[] editorParts) throws CoreException {
+               WorkbenchJob job= new WorkbenchJob(Messages.EditorReopener_ReopenJobStart) {
+                       @Override
+                       public IStatus runInUIThread(IProgressMonitor monitor) {
+                               IEditorPart oldActive= window.getActivePage().getActiveEditor();
+                               IEditorPart newActive= null;
+
+                               for(int j=0; j<editorParts.length; j++) {
+                                       IEditorPart oldPart= editorParts[j];
+                                       if(oldPart.isDirty()) {
+                                               oldPart.doSave(new NullProgressMonitor());
+                                       }
+                                       window.getActivePage().closeEditor(oldPart, false);
+                                       IEditorInput oldInput= oldPart.getEditorInput();
+
+                                       try {
+                                               IEditorPart newPart= null;
+                                               if(oldInput instanceof IFileEditorInput) {
+                                                       newPart= EditorUtility.openInEditor(((IFileEditorInput)oldInput).getFile());
+                                               } else if(oldInput instanceof ExternalEditorInput) {
+                                                       ExternalEditorInput eei= (ExternalEditorInput) oldInput;
+                                                       ICElement element= CoreModel.getDefault().create(eei.getMarkerResource());
+                                                       newPart= EditorUtility.openInEditor(eei.getPath(), element);
+                                               }
+                                               if(oldPart == oldActive)
+                                                       newActive= newPart;
+                                       } catch(PartInitException pie) {
+                                               CUIPlugin.log(pie);
+                                       } catch(CModelException cme) {
+                                               CUIPlugin.log(cme);
+                                       }
+                               }
+
+                               if(newActive != null) {
+                                       window.getActivePage().activate(newActive);
+                               }
+                               return new Status(IStatus.OK, CUIPlugin.PLUGIN_ID, Messages.EditorReopener_ReopenJobComplete);
+                       }
+               };
+               job.schedule();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/Messages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/Messages.java
new file mode 100644 (file)
index 0000000..411de44
--- /dev/null
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.doctools;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+       private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.text.doctools.messages"; //$NON-NLS-1$
+       public static String DocCommentOwnerManager_DuplicateMapping0;
+       public static String EditorReopener_ReopenJobComplete;
+       public static String EditorReopener_ReopenJobStart;
+       public static String EditorReopener_ShouldSave_Message;
+       public static String EditorReopener_ShouldSave_Title;
+       public static String NullDocCommentOwner_Name;
+       static {
+               // initialize resource bundle
+               NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+       }
+
+       private Messages() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/NullDocCommentOwner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/NullDocCommentOwner.java
new file mode 100644 (file)
index 0000000..cf85b5d
--- /dev/null
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.doctools;
+
+import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
+
+public final class NullDocCommentOwner extends DocCommentOwner {
+       private static final String ID = "org.eclipse.cdt.internal.ui.text.doctools.NullDocCommentOwner"; //$NON-NLS-1$
+       public static final IDocCommentOwner INSTANCE= new NullDocCommentOwner();
+       private NullDocCommentOwner() {
+               super(
+                       ID,
+                       Messages.NullDocCommentOwner_Name,
+                       NullDocCommentViewerConfiguration.INSTANCE,
+                       NullDocCommentViewerConfiguration.INSTANCE
+                       );
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/NullDocCommentViewerConfiguration.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/NullDocCommentViewerConfiguration.java
new file mode 100644 (file)
index 0000000..05e0919
--- /dev/null
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.doctools;
+
+import org.eclipse.jface.text.IAutoEditStrategy;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextDoubleClickStrategy;
+
+import org.eclipse.cdt.ui.text.ICTokenScanner;
+import org.eclipse.cdt.ui.text.ITokenStoreFactory;
+import org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentDictionary;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration;
+
+public class NullDocCommentViewerConfiguration implements IDocCommentViewerConfiguration {
+       public static final IDocCommentViewerConfiguration INSTANCE= new NullDocCommentViewerConfiguration();
+       
+       public NullDocCommentViewerConfiguration() {
+       }
+       
+       public IAutoEditStrategy createAutoEditStrategy() {             
+               return null;
+       }
+
+       public ICTokenScanner createCommentScanner(ITokenStoreFactory tokenStoreFactory) {
+               return null;
+       }
+
+       public ITextDoubleClickStrategy createDoubleClickStrategy() {
+               return null;
+       }
+
+       public ICompletionProposalComputer createProposalComputer() {
+               return null;
+       }
+
+       public boolean isDocumentationComment(IDocument doc, int offset, int length) {
+               return false;
+       }
+       
+       public IDocCommentDictionary getSpellingDictionary() {
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/ProjectMap.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/ProjectMap.java
new file mode 100644 (file)
index 0000000..9652b51
--- /dev/null
@@ -0,0 +1,165 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Andrew Ferguson (Symbian) - Initial implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.doctools;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICStorageElement;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
+
+/**
+ * A ProjectMap is an internal abstraction which
+ * <ul>
+ * <li>Maintains mappings from project relative paths to comment-owner ID's
+ * <li>Manages persistence of these mappings to the .cproject file.
+ * </ul>
+ * for a particular {@link IProject}
+ * 
+ * @since 5.0
+ */
+class ProjectMap {
+       /** .cproject xml element/attribute names **/
+       private static final String ATTRVAL_STORAGEID= "org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"; //$NON-NLS-1$
+       private static final String ELEMENT_DOC_COMMENT_OWNER = "doc-comment-owner"; //$NON-NLS-1$
+       private static final String ATTRKEY_DCO_ID = "id"; //$NON-NLS-1$
+       private static final String ELEMENT_PATH = "path"; //$NON-NLS-1$
+       private static final String ATTRKEY_PATH_VALUE = "value"; //$NON-NLS-1$
+       
+       private IProject fProject;
+       private Map<IPath, String> fMap;
+       
+       /**
+        * Loads the project map
+        * @param project
+        */
+       public ProjectMap(IProject project) {
+               try {
+                       fMap= load(project);
+               } catch(CoreException ce) {
+                       CUIPlugin.log(ce);
+                       fMap= new HashMap<IPath, String>();
+               }
+               fProject= project;
+       }
+       
+       /**
+        * Returns the id of the doc comment owner mapped to the resource specified, or null
+        * if no owner is mapped within this project. Ownership is inherited from parents and
+        *  may be overridden. 
+        * @param resource
+        * @return possibly null
+        */
+       public String getOwnerID(IResource resource) {
+               String id= null;
+               if (resource != null) {
+                       for (IPath p= resource.getProjectRelativePath(); ; p= p.removeLastSegments(1)) {
+                               if (fMap.containsKey(p)) {
+                                       id= fMap.get(p);
+                                       break;
+                               }
+                               if (p.isEmpty())
+                                       break;
+                       }
+               }
+               return id;
+       }
+
+       /**
+        * Creates a new (or updates the existing) mapping associating the specified
+        * {@link IDocCommentOwner} with the specified {@link IResource}
+        * @param resource the non-null resource to create an association for
+        * @param owner the owner to associate the resource with, or <code>null</code> to ensure there
+        * is no association.
+        */
+       public void setCommentOwner(IResource resource, IDocCommentOwner owner) {
+               Assert.isNotNull(resource);
+               if (ResourcesPlugin.getWorkspace().getRoot().equals(resource))
+                       throw new IllegalStateException();
+               if (owner != null) {
+                       fMap.put(resource.getProjectRelativePath(), owner.getID());
+               } else {
+                       fMap.remove(resource.getProjectRelativePath());
+               }
+               try {
+                       save();
+               } catch(CoreException ce) {
+                       CUIPlugin.log(ce);
+               }
+       }
+
+       public boolean isEmpty() {
+               return fMap.isEmpty();
+       }
+       
+       private static Map<IPath, String> load(IProject project) throws CoreException {
+               Map<IPath, String> result= new HashMap<IPath, String>();
+               ICProjectDescription pd= CCorePlugin.getDefault().getProjectDescription(project, false);
+               if (pd != null) {
+                       ICStorageElement element = pd.getStorage(ATTRVAL_STORAGEID, false);
+                       if (element != null) {
+                               for (ICStorageElement node : element.getChildrenByName(ELEMENT_DOC_COMMENT_OWNER)) {
+                                       String commentOwnerID = node.getAttribute(ATTRKEY_DCO_ID);
+                                       if (commentOwnerID != null) {
+                                               for (ICStorageElement path : node.getChildrenByName(ELEMENT_PATH)) {
+                                                       String pathValue= path.getAttribute(ATTRKEY_PATH_VALUE);
+                                                       if(pathValue != null) {
+                                                               result.put(Path.fromPortableString(pathValue), commentOwnerID);
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+               return result;
+       }
+
+       /**
+        * Write the map to the .cproject file
+        */
+       public void save() throws CoreException {
+               ICProjectDescription pd= CCorePlugin.getDefault().getProjectDescription(fProject, true);
+
+               // remove current associations
+               ICStorageElement data = pd.getStorage(ATTRVAL_STORAGEID, true);
+               for (ICStorageElement child : data.getChildren())
+                       data.removeChild(child);
+
+               // invert and persist associations
+               for (Iterator<String> i= fMap.values().iterator(); i.hasNext();) {
+                       String cid= i.next();
+                       ICStorageElement commentNode = data.createChild(ELEMENT_DOC_COMMENT_OWNER);
+                       commentNode.setAttribute(ATTRKEY_DCO_ID, cid);
+                       for (Iterator<IPath> j= fMap.keySet().iterator(); j.hasNext(); ) {
+                               IPath path= j.next();
+                               String ccid= fMap.get(path);
+                               if(cid.equals(ccid)) {
+                                       ICStorageElement pathNode = commentNode.createChild(ELEMENT_PATH);
+                                       pathNode.setAttribute(ATTRKEY_PATH_VALUE, path.toPortableString());
+                               }
+                       }
+               }
+               CCorePlugin.getDefault().setProjectDescription(fProject, pd);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/messages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/messages.properties
new file mode 100644 (file)
index 0000000..12623fe
--- /dev/null
@@ -0,0 +1,16 @@
+###############################################################################
+# Copyright (c) 2008 Symbian Ltd. and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     Symbian Ltd. - initial API and implementation
+###############################################################################
+DocCommentOwnerManager_DuplicateMapping0=More than one DocCommentOwner extension is registered for ID {0}
+EditorReopener_ReopenJobComplete=Re-initializing editors complete
+EditorReopener_ReopenJobStart=Re-initializing editors
+EditorReopener_ShouldSave_Message=To react to this change, its necessary to reinitialize some unsaved editors. If you continue they will be saved automatically and reopened. Continue?
+EditorReopener_ShouldSave_Title=Unsaved editors need reopening
+NullDocCommentOwner_Name=None
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/CFoldingStructureProviderDescriptor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/CFoldingStructureProviderDescriptor.java
new file mode 100644 (file)
index 0000000..a20cc24
--- /dev/null
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.folding;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+
+import org.eclipse.cdt.ui.text.folding.ICFoldingPreferenceBlock;
+import org.eclipse.cdt.ui.text.folding.ICFoldingStructureProvider;
+
+/**
+ * Describes a contribution to the folding provider extension point.
+ * 
+ */
+public final class CFoldingStructureProviderDescriptor {
+
+       /* extension point attribute names */
+       
+       private static final String PREFERENCES_CLASS= "preferencesClass"; //$NON-NLS-1$
+       private static final String CLASS= "class"; //$NON-NLS-1$
+       private static final String NAME= "name"; //$NON-NLS-1$
+       private static final String ID= "id"; //$NON-NLS-1$
+       
+       /** The identifier of the extension. */
+       private String fId;
+       /** The name of the extension. */
+       private String fName;
+       /** The class name of the provided <code>ICFoldingStructureProvider</code>. */
+       private String fClass;
+       /**
+        * <code>true</code> if the extension specifies a custom
+        * <code>ICFoldingPreferenceBlock</code>.
+        */
+       private boolean fHasPreferences;
+       /** The configuration element of this extension. */
+       private IConfigurationElement fElement;
+       
+       /**
+        * Creates a new descriptor.
+        * 
+        * @param element the configuration element to read
+        */
+       CFoldingStructureProviderDescriptor(IConfigurationElement element) {
+               fElement= element;
+               fId= element.getAttribute(ID);
+               Assert.isLegal(fId != null);
+               
+               fName= element.getAttribute(NAME);
+               if (fName == null)
+                       fName= fId;
+               
+               fClass= element.getAttribute(CLASS);
+               Assert.isLegal(fClass != null);
+               
+               if (element.getAttribute(PREFERENCES_CLASS) == null)
+                       fHasPreferences= false;
+               else
+                       fHasPreferences= true;
+       }
+       
+       /**
+        * Creates a folding provider as described in the extension's xml.
+        * 
+        * @return a new instance of the folding provider described by this
+        *         descriptor
+        * @throws CoreException if creation fails
+        */
+       public ICFoldingStructureProvider createProvider() throws CoreException {
+               ICFoldingStructureProvider prov= (ICFoldingStructureProvider) fElement.createExecutableExtension(CLASS);
+               return prov;
+       }
+
+       /**
+        * Creates a preferences object as described in the extension's xml.
+        * 
+        * @return a new instance of the reference provider described by this
+        *         descriptor
+        * @throws CoreException if creation fails
+        */
+       public ICFoldingPreferenceBlock createPreferences() throws CoreException {
+               if (fHasPreferences) {
+                       ICFoldingPreferenceBlock prefs= (ICFoldingPreferenceBlock) fElement.createExecutableExtension(PREFERENCES_CLASS);
+                       return prefs;
+               }
+               return new EmptyCFoldingPreferenceBlock();
+       }
+       
+       /**
+        * Returns the identifier of the described extension.
+        * 
+        * @return Returns the id
+        */
+       public String getId() {
+               return fId;
+       }
+       
+       /**
+        * Returns the name of the described extension.
+        * 
+        * @return Returns the name
+        */
+       public String getName() {
+               return fName;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/CFoldingStructureProviderRegistry.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/CFoldingStructureProviderRegistry.java
new file mode 100644 (file)
index 0000000..d94518f
--- /dev/null
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.folding;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.folding.ICFoldingStructureProvider;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+
+public class CFoldingStructureProviderRegistry {
+
+       private static final String EXTENSION_POINT= "foldingStructureProviders"; //$NON-NLS-1$
+       
+       /** The map of descriptors, indexed by their identifiers. */
+       private Map<String, CFoldingStructureProviderDescriptor> fDescriptors;
+
+       /**
+        * Creates a new instance. 
+        */
+       public CFoldingStructureProviderRegistry() {
+       }
+       
+       /**
+        * Returns an array of <code>ICFoldingProviderDescriptor</code> describing
+        * all extension to the <code>foldingProviders</code> extension point.
+        * 
+        * @return the list of extensions to the
+        *         <code>quickDiffReferenceProvider</code> extension point.
+        */
+       public CFoldingStructureProviderDescriptor[] getFoldingProviderDescriptors() {
+               synchronized (this) {
+                       ensureRegistered();
+                       return fDescriptors.values().toArray(new CFoldingStructureProviderDescriptor[fDescriptors.size()]);
+               }
+       }
+       
+       /**
+        * Returns the folding provider with identifier <code>id</code> or
+        * <code>null</code> if no such provider is registered.
+        * 
+        * @param id the identifier for which a provider is wanted
+        * @return the corresponding provider, or <code>null</code> if none can be
+        *         found
+        */
+       public CFoldingStructureProviderDescriptor getFoldingProviderDescriptor(String id) {
+               synchronized (this) {
+                       ensureRegistered();
+                       return fDescriptors.get(id);
+               }
+       }
+       
+       /**
+        * Instantiates and returns the provider that is currently configured in the
+        * preferences.
+        * 
+        * @return the current provider according to the preferences
+        */
+       public ICFoldingStructureProvider getCurrentFoldingProvider() {
+               String id= CUIPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.EDITOR_FOLDING_PROVIDER);
+               CFoldingStructureProviderDescriptor desc= getFoldingProviderDescriptor(id);
+               if (desc != null) {
+                       try {
+                               return desc.createProvider();
+                       } catch (CoreException e) {
+                               CUIPlugin.log(e);
+                       }
+               }
+               return null;
+       }
+       
+       /**
+        * Ensures that the extensions are read and stored in
+        * <code>fDescriptors</code>.
+        */
+       private void ensureRegistered() {
+               if (fDescriptors == null)
+                       reloadExtensions();
+       }
+
+       /**
+        * Reads all extensions.
+        * <p>
+        * This method can be called more than once in
+        * order to reload from a changed extension registry.
+        * </p>
+        */
+       public void reloadExtensions() {
+               IExtensionRegistry registry= Platform.getExtensionRegistry();
+               Map<String, CFoldingStructureProviderDescriptor> map= new HashMap<String, CFoldingStructureProviderDescriptor>();
+
+               IConfigurationElement[] elements= registry.getConfigurationElementsFor(CUIPlugin.getPluginId(), EXTENSION_POINT);
+               for (int i= 0; i < elements.length; i++) {
+                       CFoldingStructureProviderDescriptor desc= new CFoldingStructureProviderDescriptor(elements[i]);
+                       map.put(desc.getId(), desc);
+               }
+               
+               synchronized(this) {
+                       fDescriptors= Collections.unmodifiableMap(map);
+               }
+       }
+
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingPreferenceBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingPreferenceBlock.java
new file mode 100644 (file)
index 0000000..68162b9
--- /dev/null
@@ -0,0 +1,175 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Elazar Leibovich (IDF) - Code folding of compound statements (bug 174597)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.folding;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.folding.ICFoldingPreferenceBlock;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+
+import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore;
+import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey;
+
+/**
+ */
+public class DefaultCFoldingPreferenceBlock implements ICFoldingPreferenceBlock {
+
+       private IPreferenceStore fStore;
+       protected OverlayPreferenceStore fOverlayStore;
+       private OverlayKey[] fKeys;
+       protected Map<Button, String> fCheckBoxes= new HashMap<Button, String>();
+
+       private SelectionListener fCheckBoxListener= new SelectionListener() {
+               public void widgetDefaultSelected(SelectionEvent e) {
+               }
+               public void widgetSelected(SelectionEvent e) {
+                       Button button= (Button) e.widget;
+                       String key= fCheckBoxes.get(button);
+                       fOverlayStore.setValue(key, button.getSelection());
+                       updateEnablement(key);
+               }
+       };
+       private Button fInactiveCodeFoldingCheckBox;
+       
+
+       public DefaultCFoldingPreferenceBlock() {
+               fStore= CUIPlugin.getDefault().getPreferenceStore();
+               fKeys= createKeys();
+               fOverlayStore= new OverlayPreferenceStore(fStore, fKeys);
+       }
+       
+       private OverlayKey[] createKeys() {
+               ArrayList<OverlayKey> overlayKeys= new ArrayList<OverlayKey>();
+
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_MACROS));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_FUNCTIONS));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_METHODS));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_STRUCTURES));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_COMMENTS));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_HEADERS));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_INACTIVE_CODE));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_STATEMENTS));
+               
+               return overlayKeys.toArray(new OverlayKey[overlayKeys.size()]);
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.folding.ICFoldingPreferences#createControl(org.eclipse.swt.widgets.Group)
+        */
+       public Control createControl(Composite composite) {
+               fOverlayStore.load();
+               fOverlayStore.start();
+               
+               Composite inner= new Composite(composite, SWT.NONE);
+               GridLayout layout= new GridLayout(1, true);
+               layout.verticalSpacing= 3;
+               layout.marginWidth= 0;
+               inner.setLayout(layout);
+
+               addCheckBox(inner, FoldingMessages.DefaultCFoldingPreferenceBlock_preprocessor_enabled, PreferenceConstants.EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED, 1);
+               addCheckBox(inner, FoldingMessages.DefaultCFoldingPreferenceBlock_statements_enabled, PreferenceConstants.EDITOR_FOLDING_STATEMENTS, 1);
+               ControlFactory.createEmptySpace(inner);
+
+               Composite group= ControlFactory.createGroup(inner, FoldingMessages.DefaultCFoldingPreferenceBlock_title, 1);
+
+               addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_macros, PreferenceConstants.EDITOR_FOLDING_MACROS, 0); 
+               addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_functions, PreferenceConstants.EDITOR_FOLDING_FUNCTIONS, 0); 
+               addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_methods, PreferenceConstants.EDITOR_FOLDING_METHODS, 0); 
+               addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_structures, PreferenceConstants.EDITOR_FOLDING_STRUCTURES, 0); 
+               addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_comments, PreferenceConstants.EDITOR_FOLDING_COMMENTS, 0); 
+               addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_headers, PreferenceConstants.EDITOR_FOLDING_HEADERS, 0);
+               fInactiveCodeFoldingCheckBox= addCheckBox(group, FoldingMessages.DefaultCFoldingPreferenceBlock_inactive_code, PreferenceConstants.EDITOR_FOLDING_INACTIVE_CODE, 0); 
+               
+               return inner;
+       }
+       
+       private Button addCheckBox(Composite parent, String label, String key, int indentation) {               
+               Button checkBox= new Button(parent, SWT.CHECK);
+               checkBox.setText(label);
+               
+               GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+               gd.horizontalIndent= indentation;
+               gd.horizontalSpan= 1;
+               gd.grabExcessVerticalSpace= false;
+               checkBox.setLayoutData(gd);
+               checkBox.addSelectionListener(fCheckBoxListener);
+               
+               fCheckBoxes.put(checkBox, key);
+               
+               return checkBox;
+       }
+       
+       private void initializeFields() {
+               Iterator<Button> it= fCheckBoxes.keySet().iterator();
+               while (it.hasNext()) {
+                       Button b= it.next();
+                       String key= fCheckBoxes.get(b);
+                       b.setSelection(fOverlayStore.getBoolean(key));
+                       updateEnablement(key);
+               }
+       }
+
+       protected void updateEnablement(String key) {
+               if (PreferenceConstants.EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED.equals(key)) {
+                       fInactiveCodeFoldingCheckBox.setEnabled(fOverlayStore.getBoolean(key));
+               }
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.folding.AbstractCFoldingPreferences#performOk()
+        */
+       public void performOk() {
+               fOverlayStore.propagate();
+       }
+       
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.folding.AbstractCFoldingPreferences#initialize()
+        */
+       public void initialize() {
+               initializeFields();
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.folding.AbstractCFoldingPreferences#performDefaults()
+        */
+       public void performDefaults() {
+               fOverlayStore.loadDefaults();
+               initializeFields();
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.folding.AbstractCFoldingPreferences#dispose()
+        */
+       public void dispose() {
+               fOverlayStore.stop();
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructureProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructureProvider.java
new file mode 100644 (file)
index 0000000..ed4a65c
--- /dev/null
@@ -0,0 +1,1765 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Markus Schorn (Wind River Systems)
+ *     Elazar Leibovich (IDF) - Code folding of compound statements (bug 174597)
+ *     Andrew Ferguson (Symbian)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.folding;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Stack;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.projection.IProjectionListener;
+import org.eclipse.jface.text.source.projection.IProjectionPosition;
+import org.eclipse.jface.text.source.projection.ProjectionAnnotation;
+import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel;
+import org.eclipse.jface.text.source.projection.ProjectionViewer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTBreakStatement;
+import org.eclipse.cdt.core.dom.ast.IASTCaseStatement;
+import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTDefaultStatement;
+import org.eclipse.cdt.core.dom.ast.IASTDoStatement;
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTForStatement;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
+import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorElifStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorElseStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorEndifStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIfStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIfdefStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIfndefStatement;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
+import org.eclipse.cdt.core.dom.ast.IASTProblem;
+import org.eclipse.cdt.core.dom.ast.IASTStatement;
+import org.eclipse.cdt.core.dom.ast.IASTSwitchStatement;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTRangeBasedForStatement;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.IParent;
+import org.eclipse.cdt.core.model.ISourceRange;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.parser.IProblem;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.ICPartitions;
+import org.eclipse.cdt.ui.text.folding.ICFoldingStructureProvider;
+
+import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
+import org.eclipse.cdt.internal.core.model.ASTCache;
+
+import org.eclipse.cdt.internal.ui.editor.ASTProvider;
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.editor.ASTProvider.WAIT_FLAG;
+import org.eclipse.cdt.internal.ui.text.DocumentCharacterIterator;
+import org.eclipse.cdt.internal.ui.text.ICReconcilingListener;
+
+/**
+ * Default implementation of a {@link ICFoldingStructureProvider}.
+ * <p>
+ * Derived from JDT counterpart.
+ * </p>
+ */
+public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvider {
+
+       /**
+        * A visitor to collect compound statement positions.
+        *
+        * @since 5.0
+        */
+       private final class StatementVisitor extends ASTVisitor {
+               {
+                       shouldVisitStatements = true;
+                       shouldVisitDeclarations = true;
+               }
+               private final Stack<StatementRegion> fStatements;
+               int fLevel= 0;
+               String fFunction= ""; //$NON-NLS-1$
+
+               private StatementVisitor(Stack<StatementRegion> statements) {
+                       fStatements = statements;
+               }
+
+               @Override
+               public int visit(IASTStatement statement) {
+                       ++fLevel;
+                       // if it's not part of the displayed - file, we don't need it
+                       if (!statement.isPartOfTranslationUnitFile())
+                               return PROCESS_SKIP;// we neither need its descendants
+                       try {
+                               StatementRegion mr;
+                               IASTFileLocation fl;
+                               if (statement instanceof IASTIfStatement) {
+                                       IASTIfStatement ifstmt = (IASTIfStatement) statement;
+                                       fl = ifstmt.getFileLocation();
+                                       if (fl==null) return PROCESS_CONTINUE;
+                                       int ifOffset= fl.getNodeOffset();
+                                       IASTStatement thenStmt;
+                                       mr = createRegion();
+                                       thenStmt = ifstmt.getThenClause();
+                                       if (thenStmt==null) return PROCESS_CONTINUE;
+                                       fl = thenStmt.getFileLocation();
+                                       mr.setLength(fl.getNodeOffset() + fl.getNodeLength() - ifOffset);
+                                       mr.setOffset(ifOffset);
+                                       mr.inclusive = !(thenStmt instanceof IASTCompoundStatement);
+                                       IASTStatement elseStmt;
+                                       elseStmt = ifstmt.getElseClause();
+                                       if (elseStmt == null) {
+                                               mr.inclusive = true;
+                                               fStatements.push(mr);
+                                               return PROCESS_CONTINUE;
+                                       }
+                                       IASTFileLocation elseStmtLocation = elseStmt.getFileLocation();
+                                       mr.inclusive = mr.inclusive || fl.getEndingLineNumber() < elseStmtLocation.getStartingLineNumber();
+                                       if (elseStmt instanceof IASTIfStatement) {
+                                               fStatements.push(mr);
+                                               return PROCESS_CONTINUE;
+                                       }
+                                       fStatements.push(mr);
+                                       mr = createRegion();
+                                       mr.setLength(elseStmtLocation.getNodeLength());
+                                       mr.setOffset(elseStmtLocation.getNodeOffset());
+                                       mr.inclusive = true;
+                                       fStatements.push(mr);
+                                       return PROCESS_CONTINUE;
+                               }
+                               mr = createRegion();
+                               mr.inclusive = true;
+                               if (statement instanceof IASTDoStatement)
+                                       mr.inclusive = false;
+                               if (statement instanceof IASTSwitchStatement) {
+                                       IASTStatement switchstmt = ((IASTSwitchStatement)statement).getBody();
+                                       if (switchstmt instanceof IASTCompoundStatement) {
+                                               IASTStatement[] stmts = ((IASTCompoundStatement)switchstmt).getStatements();
+                                               boolean pushedMR = false;
+                                               for (IASTStatement tmpstmt : stmts) {
+                                                       StatementRegion tmpmr;
+                                                       if (!(tmpstmt instanceof IASTCaseStatement || tmpstmt instanceof IASTDefaultStatement)) {
+                                                               if (!pushedMR) return PROCESS_SKIP;
+                                                               IASTFileLocation tmpfl = tmpstmt.getFileLocation();
+                                                               tmpmr = fStatements.peek();
+                                                               tmpmr.setLength(tmpfl.getNodeLength()+tmpfl.getNodeOffset()-tmpmr.getOffset());
+                                                               if (tmpstmt instanceof IASTBreakStatement) pushedMR = false;
+                                                               continue;
+                                                       }
+                                                       IASTFileLocation tmpfl;
+                                                       tmpmr = createRegion();
+                                                       tmpmr.level= fLevel+1;
+                                                       tmpmr.inclusive = true;
+                                                       if (tmpstmt instanceof IASTCaseStatement) {
+                                                               IASTCaseStatement casestmt = (IASTCaseStatement) tmpstmt;
+                                                               tmpfl = casestmt.getExpression().getFileLocation();
+                                                               tmpmr.setOffset(tmpfl.getNodeOffset());
+                                                               tmpmr.setLength(tmpfl.getNodeLength());
+                                                       } else if (tmpstmt instanceof IASTDefaultStatement) {
+                                                               IASTDefaultStatement defstmt = (IASTDefaultStatement) tmpstmt;
+                                                               tmpfl = defstmt.getFileLocation();
+                                                               tmpmr.setOffset(tmpfl.getNodeOffset()+tmpfl.getNodeLength());
+                                                               tmpmr.setLength(0);
+                                                       }
+                                                       fStatements.push(tmpmr);
+                                                       pushedMR = true;
+                                               }
+                                       }
+                               }
+                               if (statement instanceof IASTForStatement
+                                               || statement instanceof IASTWhileStatement
+                                               || statement instanceof IASTDoStatement
+                                               || statement instanceof IASTSwitchStatement
+                                               || statement instanceof ICPPASTRangeBasedForStatement) {
+                                       fl = statement.getFileLocation();
+                                       mr.setLength(fl.getNodeLength());
+                                       mr.setOffset(fl.getNodeOffset());
+                                       fStatements.push(mr);
+                               }
+                               return PROCESS_CONTINUE;
+                       } catch (Exception e) {
+                               CUIPlugin.log(e);
+                               return PROCESS_ABORT;
+                       }
+               }
+
+               @Override
+               public int leave(IASTStatement statement) {
+                       --fLevel;
+                       return PROCESS_CONTINUE;
+               }
+
+               @Override
+               public int visit(IASTDeclaration declaration) {
+                       if (!declaration.isPartOfTranslationUnitFile())
+                               return PROCESS_SKIP;// we neither need its descendants
+                       if (declaration instanceof IASTFunctionDefinition) {
+                               final IASTFunctionDeclarator declarator = ((IASTFunctionDefinition)declaration).getDeclarator();
+                               if (declarator != null) {
+                                       fFunction= new String(ASTQueries.findInnermostDeclarator(declarator).getName().toCharArray());
+                                       fLevel= 0;
+                               }
+                       }
+                       return PROCESS_CONTINUE;
+               }
+
+               @Override
+               public int leave(IASTDeclaration declaration) {
+                       if (declaration instanceof IASTFunctionDefinition) {
+                               fFunction= ""; //$NON-NLS-1$
+                       }
+                       return PROCESS_CONTINUE;
+               }
+
+               private StatementRegion createRegion() {
+                       return new StatementRegion(fFunction, fLevel);
+               }
+       }
+
+       /**
+        * Listen to cursor position changes.
+        */
+       private final class SelectionListener implements ISelectionChangedListener {
+               public void selectionChanged(SelectionChangedEvent event) {
+                       ISelection s= event.getSelection();
+                       if (s instanceof ITextSelection) {
+                               ITextSelection selection= (ITextSelection)event.getSelection();
+                               fCursorPosition= selection.getOffset();
+                       }
+               }
+       }
+
+       /**
+        * Update folding positions triggered by reconciler.
+        */
+       private class FoldingStructureReconciler implements ICReconcilingListener {
+               private volatile boolean fReconciling;
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#aboutToBeReconciled()
+                */
+               public void aboutToBeReconciled() {
+                       
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#reconciled(IASTTranslationUnit, boolean, IProgressMonitor)
+                */
+               public void reconciled(IASTTranslationUnit ast, boolean force, IProgressMonitor progressMonitor) {
+                       if (fInput == null || progressMonitor.isCanceled()) {
+                               return;
+                       }
+                       synchronized (this) {
+                               if (fReconciling) {
+                                       return;
+                               }
+                               fReconciling= true;
+                       }
+                       try {
+                               final boolean initialReconcile= fInitialReconcilePending;
+                               fInitialReconcilePending= false;
+                               FoldingStructureComputationContext ctx= createContext(initialReconcile);
+                               if (ctx != null) {
+                                       if (initialReconcile || !hasSyntaxError(ast)) {
+                                               ctx.fAST= ast;
+                                       }
+                                       update(ctx);
+                               }
+                       } finally {
+                               fReconciling= false;
+                       }
+               }
+
+               /**
+                * Test whether the given ast contains one or more syntax errors.
+                * 
+                * @param ast
+                * @return <code>true</code> if the ast contains a syntax error
+                */
+               private boolean hasSyntaxError(IASTTranslationUnit ast) {
+                       if (ast == null) {
+                               return false;
+                       }
+                       IASTProblem[] problems= ast.getPreprocessorProblems();
+                       for (IASTProblem problem : problems) {
+                               if ((problem.getID() & (IProblem.SYNTAX_ERROR | IProblem.SCANNER_RELATED)) != 0) {
+                                       return true;
+                               }
+                       }
+                       problems= CPPVisitor.getProblems(ast);
+                       for (IASTProblem problem : problems) {
+                               if ((problem.getID() & (IProblem.SYNTAX_ERROR | IProblem.SCANNER_RELATED)) != 0) {
+                                       return true;
+                               }
+                       }
+                       return false;
+               }
+
+       }
+
+
+       /**
+        * A context that contains the information needed to compute the folding structure of an
+        * {@link ITranslationUnit}. Computed folding regions are collected via
+        * {@linkplain #addProjectionRange(DefaultCFoldingStructureProvider.CProjectionAnnotation, Position) addProjectionRange}.
+        */
+       protected final class FoldingStructureComputationContext {
+               private final ProjectionAnnotationModel fModel;
+               private final IDocument fDocument;
+               private final boolean fAllowCollapsing;
+
+               private ISourceReference fFirstType;
+               private boolean fHasHeaderComment;
+               private LinkedHashMap<CProjectionAnnotation,Position> fMap= new LinkedHashMap<CProjectionAnnotation,Position>();
+               private IASTTranslationUnit fAST;
+
+               FoldingStructureComputationContext(IDocument document, ProjectionAnnotationModel model, boolean allowCollapsing) {
+                       Assert.isNotNull(document);
+                       Assert.isNotNull(model);
+                       fDocument= document;
+                       fModel= model;
+                       fAllowCollapsing= allowCollapsing;
+               }
+               
+               void setFirstType(ISourceReference reference) {
+                       if (hasFirstType())
+                               throw new IllegalStateException();
+                       fFirstType= reference;
+               }
+               
+               boolean hasFirstType() {
+                       return fFirstType != null;
+               }
+               
+               ISourceReference getFirstType() {
+                       return fFirstType;
+               }
+
+               boolean hasHeaderComment() {
+                       return fHasHeaderComment;
+               }
+
+               void setHasHeaderComment() {
+                       fHasHeaderComment= true;
+               }
+               
+               /**
+                * Returns <code>true</code> if newly created folding regions may be collapsed,
+                * <code>false</code> if not. This is usually <code>false</code> when updating the
+                * folding structure while typing; it may be <code>true</code> when computing or restoring
+                * the initial folding structure.
+                * 
+                * @return <code>true</code> if newly created folding regions may be collapsed,
+                *         <code>false</code> if not
+                */
+               public boolean allowCollapsing() {
+                       return fAllowCollapsing;
+               }
+
+               /**
+                * Returns the document which contains the code being folded.
+                * 
+                * @return the document which contains the code being folded
+                */
+               IDocument getDocument() {
+                       return fDocument;
+               }
+
+               ProjectionAnnotationModel getModel() {
+                       return fModel;
+               }
+               
+               /**
+                * Adds a projection (folding) region to this context. The created annotation / position
+                * pair will be added to the {@link ProjectionAnnotationModel} of the
+                * {@link ProjectionViewer} of the editor.
+                * 
+                * @param annotation the annotation to add
+                * @param position the corresponding position
+                */
+               public void addProjectionRange(CProjectionAnnotation annotation, Position position) {
+                       fMap.put(annotation, position);
+               }
+
+               /**
+                * Returns <code>true</code> if header comments should be collapsed.
+                * 
+                * @return <code>true</code> if header comments should be collapsed
+                */
+               public boolean collapseHeaderComments() {
+                       return fAllowCollapsing && fCollapseHeaderComments;
+               }
+
+               /**
+                * Returns <code>true</code> if comments should be collapsed.
+                * 
+                * @return <code>true</code> if comments should be collapsed
+                */
+               public boolean collapseComments() {
+                       return fAllowCollapsing && fCollapseComments;
+               }
+
+               /**
+                * Returns <code>true</code> if functions should be collapsed.
+                * 
+                * @return <code>true</code> if functions should be collapsed
+                */
+               public boolean collapseFunctions() {
+                       return fAllowCollapsing && fCollapseFunctions;
+               }
+
+               /**
+                * Returns <code>true</code> if macros should be collapsed.
+                * 
+                * @return <code>true</code> if macros should be collapsed
+                */
+               public boolean collapseMacros() {
+                       return fAllowCollapsing && fCollapseMacros;
+               }
+
+               /**
+                * Returns <code>true</code> if methods should be collapsed.
+                * 
+                * @return <code>true</code> if methods should be collapsed
+                */
+               public boolean collapseMethods() {
+                       return fAllowCollapsing && fCollapseMethods;
+               }
+
+               /**
+                * Returns <code>true</code> if structures should be collapsed.
+                * 
+                * @return <code>true</code> if structures should be collapsed
+                */
+               public boolean collapseStructures() {
+                       return fAllowCollapsing && fCollapseStructures;
+               }
+
+               /**
+                * Returns <code>true</code> if inactive code should be collapsed.
+                * 
+                * @return <code>true</code> if inactive code should be collapsed
+                */
+               public boolean collapseInactiveCode() {
+                       return fAllowCollapsing && fCollapseInactiveCode;
+               }
+
+               /**
+                * @return the current AST or <code>null</code>
+                */
+               public IASTTranslationUnit getAST() {
+                       return fAST;
+               }
+       }
+       
+
+       private static class CProjectionAnnotation extends ProjectionAnnotation {
+
+               public final static int CMODEL= 0;
+               public final static int COMMENT= 1;
+               public final static int BRANCH= 2;
+               public final static int STATEMENT= 3;
+               
+               private Object fKey;
+               private int fCategory;
+               
+               public CProjectionAnnotation(boolean isCollapsed, Object key, boolean isComment) {
+                       this(isCollapsed, key, isComment ? COMMENT : 0);
+               }
+               
+               public CProjectionAnnotation(boolean isCollapsed, Object key, int category) {
+                       super(isCollapsed);
+                       fKey= key;
+                       fCategory= category;
+               }
+               
+               public Object getElement() {
+                       return fKey;
+               }
+               
+               public void setElement(Object element) {
+                       fKey= element;
+               }
+               
+               public int getCategory() {
+                       return fCategory;
+               }
+
+//             public void setCategory(int category) {
+//                     fCategory = category;
+//             }
+//
+//             public boolean isComment() {
+//                     return fCategory == COMMENT;
+//             }
+//             
+//             public void setIsComment(boolean isComment) {
+//                     fCategory= isComment ? COMMENT : 0;
+//             }
+               /*
+                * @see java.lang.Object#toString()
+                */
+               @Override
+               public String toString() {
+                       return "CProjectionAnnotation:\n" + //$NON-NLS-1$
+                                       "\tkey: \t"+ fKey + "\n" + //$NON-NLS-1$ //$NON-NLS-2$
+                                       "\tcollapsed: \t" + isCollapsed() + "\n" + //$NON-NLS-1$ //$NON-NLS-2$
+                                       "\tcategory: \t" + getCategory() + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
+               }
+       }
+       
+
+       private static final class Tuple {
+               CProjectionAnnotation annotation;
+               Position position;
+               Tuple(CProjectionAnnotation annotation, Position position) {
+                       this.annotation= annotation;
+                       this.position= position;
+               }
+       }
+
+       private static final class Counter {
+               int fCount;
+       }
+       
+       /**
+        * Projection position that will return two foldable regions: one folding away
+        * the region from after the '/*' to the beginning of the content, the other
+        * from after the first content line until after the comment.
+        */
+       private static final class CommentPosition extends Position implements IProjectionPosition {
+               CommentPosition(int offset, int length) {
+                       super(offset, length);
+               }
+
+               /*
+                * @see org.eclipse.jface.text.source.projection.IProjectionPosition#computeFoldingRegions(org.eclipse.jface.text.IDocument)
+                */
+               public IRegion[] computeProjectionRegions(IDocument document) throws BadLocationException {
+                       DocumentCharacterIterator sequence= new DocumentCharacterIterator(document, offset, offset + length);
+                       int prefixEnd= 0;
+                       int contentStart= findFirstContent(sequence, prefixEnd);
+
+                       int firstLine= document.getLineOfOffset(offset + prefixEnd);
+                       int captionLine= document.getLineOfOffset(offset + contentStart);
+                       int lastLine= document.getLineOfOffset(offset + length);
+
+                       Assert.isTrue(firstLine <= captionLine, "first folded line is greater than the caption line"); //$NON-NLS-1$
+                       Assert.isTrue(captionLine <= lastLine, "caption line is greater than the last folded line"); //$NON-NLS-1$
+
+                       IRegion preRegion;
+                       if (firstLine < captionLine) {
+                               int preOffset= document.getLineOffset(firstLine);
+                               IRegion preEndLineInfo= document.getLineInformation(captionLine);
+                               int preEnd= preEndLineInfo.getOffset();
+                               preRegion= new Region(preOffset, preEnd - preOffset);
+                       } else {
+                               preRegion= null;
+                       }
+
+                       if (captionLine < lastLine) {
+                               int postOffset= document.getLineOffset(captionLine + 1);
+                               IRegion postRegion= new Region(postOffset, offset + length - postOffset);
+
+                               if (preRegion == null)
+                                       return new IRegion[] { postRegion };
+
+                               return new IRegion[] { preRegion, postRegion };
+                       }
+
+                       if (preRegion != null)
+                               return new IRegion[] { preRegion };
+
+                       return null;
+               }
+
+               /**
+                * Finds the offset of the first identifier part within <code>content</code>.
+                * Returns 0 if none is found.
+                *
+                * @param content the content to search
+                * @return the first index of a unicode identifier part, or zero if none can
+                *         be found
+                */
+               private int findFirstContent(final CharSequence content, int prefixEnd) {
+                       int lenght= content.length();
+                       for (int i= prefixEnd; i < lenght; i++) {
+                               if (Character.isUnicodeIdentifierPart(content.charAt(i)))
+                                       return i;
+                       }
+                       return 0;
+               }
+
+               /*
+                * @see org.eclipse.jface.text.source.projection.IProjectionPosition#computeCaptionOffset(org.eclipse.jface.text.IDocument)
+                */
+               public int computeCaptionOffset(IDocument document) {
+                       DocumentCharacterIterator sequence= new DocumentCharacterIterator(document, offset, offset + length);
+                       return findFirstContent(sequence, 0);
+               }
+       }
+
+       /**
+        * Projection position that will return two foldable regions: one folding away
+        * the lines before the one containing the simple name of the C element, one
+        * folding away any lines after the caption.
+        */
+       private static final class CElementPosition extends Position implements IProjectionPosition {
+
+               private ICElement fElement;
+
+               public CElementPosition(int offset, int length, ICElement element) {
+                       super(offset, length);
+                       Assert.isNotNull(element);
+                       fElement= element;
+               }
+               
+               public void setElement(ICElement member) {
+                       Assert.isNotNull(member);
+                       fElement= member;
+               }
+               
+               /*
+                * @see org.eclipse.jface.text.source.projection.IProjectionPosition#computeFoldingRegions(org.eclipse.jface.text.IDocument)
+                */
+               public IRegion[] computeProjectionRegions(IDocument document) throws BadLocationException {
+                       int captionOffset= offset;
+                       try {
+                               /* The member's name range may not be correct. However,
+                                * reconciling would trigger another element delta which would
+                                * lead to reentrant situations. Therefore, we optimistically
+                                * assume that the name range is correct, but double check the
+                                * received lines below. */
+                               if (fElement instanceof ISourceReference) {
+                                       ISourceRange sourceRange= ((ISourceReference) fElement).getSourceRange();
+                                       if (sourceRange != null) {
+                                               // Use end of name range for the caption offset
+                                               // in case a qualified name is split on multiple lines (bug 248613).
+                                               captionOffset= sourceRange.getIdStartPos() + sourceRange.getIdLength() - 1;
+                                       }
+                               }
+                       } catch (CModelException e) {
+                               // ignore and use default
+                       }
+
+                       int firstLine= document.getLineOfOffset(offset);
+                       int captionLine= document.getLineOfOffset(captionOffset);
+                       int lastLine= document.getLineOfOffset(offset + length);
+
+                       /* see comment above - adjust the caption line to be inside the
+                        * entire folded region, and rely on later element deltas to correct
+                        * the name range. */
+                       if (captionLine < firstLine)
+                               captionLine= firstLine;
+                       if (captionLine > lastLine)
+                               captionLine= lastLine;
+
+                       IRegion preRegion;
+                       if (firstLine < captionLine) {
+                               int preOffset= document.getLineOffset(firstLine);
+                               IRegion preEndLineInfo= document.getLineInformation(captionLine);
+                               int preEnd= preEndLineInfo.getOffset();
+                               preRegion= new Region(preOffset, preEnd - preOffset);
+                       } else {
+                               preRegion= null;
+                       }
+
+                       if (captionLine < lastLine) {
+                               int postOffset= document.getLineOffset(captionLine + 1);
+                               IRegion postRegion= new Region(postOffset, offset + length - postOffset);
+
+                               if (preRegion == null)
+                                       return new IRegion[] { postRegion };
+
+                               return new IRegion[] { preRegion, postRegion };
+                       }
+
+                       if (preRegion != null)
+                               return new IRegion[] { preRegion };
+
+                       return null;
+               }
+
+               /*
+                * @see org.eclipse.jface.text.source.projection.IProjectionPosition#computeCaptionOffset(org.eclipse.jface.text.IDocument)
+                */
+               public int computeCaptionOffset(IDocument document) throws BadLocationException {
+                       int captionOffset= offset;
+                       try {
+                               // need a reconcile here?
+                               if (fElement instanceof ISourceReference) {
+                                       ISourceRange sourceRange= ((ISourceReference) fElement).getSourceRange();
+                                       if (sourceRange != null) {
+                                               captionOffset= sourceRange.getIdStartPos() + sourceRange.getIdLength() - 1;
+                                               if (captionOffset < offset) {
+                                                       captionOffset= offset;
+                                               }
+                                       }
+                               }
+                       } catch (CModelException e) {
+                               // ignore and use default
+                       }
+
+                       return captionOffset - offset;
+               }
+
+       }
+       
+       /**
+        * Internal projection listener.
+        */
+       private final class ProjectionListener implements IProjectionListener {
+               private ProjectionViewer fViewer;
+
+               /**
+                * Registers the listener with the viewer.
+                * 
+                * @param viewer the viewer to register a listener with
+                */
+               public ProjectionListener(ProjectionViewer viewer) {
+                       Assert.isLegal(viewer != null);
+                       fViewer= viewer;
+                       fViewer.addProjectionListener(this);
+               }
+               
+               /**
+                * Disposes of this listener and removes the projection listener from the viewer.
+                */
+               public void dispose() {
+                       if (fViewer != null) {
+                               fViewer.removeProjectionListener(this);
+                               fViewer= null;
+                       }
+               }
+               
+               /*
+                * @see org.eclipse.jface.text.source.projection.IProjectionListener#projectionEnabled()
+                */
+               public void projectionEnabled() {
+                       handleProjectionEnabled();
+               }
+
+               /*
+                * @see org.eclipse.jface.text.source.projection.IProjectionListener#projectionDisabled()
+                */
+               public void projectionDisabled() {
+                       handleProjectionDisabled();
+               }
+       }
+
+       /**
+        * Implementation of <code>IRegion</code> that can be reused
+        * by setting the offset and the length.
+        */
+       private static class ModifiableRegion extends Position implements IRegion {
+               ModifiableRegion() {
+                       super();
+               }
+               ModifiableRegion(int offset, int length) {
+                       super(offset, length);
+               }
+       }
+
+       /**
+        * Representation of a preprocessor code branch.
+        */
+       private static class Branch extends ModifiableRegion {
+
+               private final boolean fTaken;
+               public final String fCondition;
+               public boolean fInclusive;
+
+               Branch(int offset, boolean taken, String key) {
+                       this(offset, 0, taken, key);
+               }
+
+               Branch(int offset, int length, boolean taken, String key) {
+                       super(offset, length);
+                       fTaken= taken;
+                       fCondition= key;
+               }
+
+               public void setEndOffset(int endOffset) {
+                       setLength(endOffset - getOffset());
+               }
+
+               public boolean taken() {
+                       return fTaken;
+               }
+
+               public void setInclusive(boolean inclusive) {
+                       fInclusive= inclusive;
+               }
+       }
+
+       private final static boolean DEBUG= "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.cdt.ui/debug/folding"));  //$NON-NLS-1$//$NON-NLS-2$;
+
+       private ITextEditor fEditor;
+       private ProjectionListener fProjectionListener;
+       protected ICElement fInput;
+       
+       private boolean fCollapseHeaderComments= true;
+       private boolean fCollapseComments= false;
+       private boolean fCollapseMacros= false;
+       private boolean fCollapseFunctions= true;
+       private boolean fCollapseStructures= true;
+       private boolean fCollapseMethods= false;
+       private boolean fCollapseInactiveCode= true;
+       
+       private int fMinCommentLines= 1;
+       private boolean fPreprocessorBranchFoldingEnabled= true;
+       private boolean fStatementsFoldingEnabled= false;
+       private boolean fCommentFoldingEnabled= true;
+
+       private ICReconcilingListener fReconilingListener;
+       private volatile boolean fInitialReconcilePending= true;
+
+       private int fCursorPosition;
+
+       private SelectionListener fSelectionListener;
+
+
+       /**
+        * Creates a new folding provider. It must be
+        * {@link #install(ITextEditor, ProjectionViewer) installed} on an editor/viewer pair before it
+        * can be used, and {@link #uninstall() uninstalled} when not used any longer.
+        * <p>
+        * The projection state may be reset by calling {@link #initialize()}.
+        * </p>
+        */
+       public DefaultCFoldingStructureProvider() {
+       }
+       
+       /*
+        * @see org.eclipse.cdt.ui.text.folding.ICFoldingStructureProvider#install(org.eclipse.ui.texteditor.ITextEditor, org.eclipse.jface.text.source.projection.ProjectionViewer)
+        */
+       public void install(ITextEditor editor, ProjectionViewer viewer) {
+               Assert.isLegal(editor != null);
+               Assert.isLegal(viewer != null);
+
+               internalUninstall();
+               
+               if (editor instanceof CEditor) {
+                       fEditor= editor;
+                       fProjectionListener= new ProjectionListener(viewer);
+               }
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.folding.ICFoldingStructureProvider#uninstall()
+        */
+       public void uninstall() {
+               internalUninstall();
+       }
+       
+       /**
+        * Internal implementation of {@link #uninstall()}.
+        */
+       private void internalUninstall() {
+               if (isInstalled()) {
+                       handleProjectionDisabled();
+                       fProjectionListener.dispose();
+                       fProjectionListener= null;
+                       fEditor= null;
+               }
+       }
+
+       /**
+        * Returns <code>true</code> if the provider is installed, <code>false</code> otherwise.
+        * 
+        * @return <code>true</code> if the provider is installed, <code>false</code> otherwise
+        */
+       protected final boolean isInstalled() {
+               return fEditor != null;
+       }
+               
+       /**
+        * Called whenever projection is enabled, for example when the viewer issues a
+        * {@link IProjectionListener#projectionEnabled() projectionEnabled} message. When the provider
+        * is already enabled when this method is called, it is first
+        * {@link #handleProjectionDisabled() disabled}.
+        * <p>
+        * Subclasses may extend.
+        * </p>
+        */
+       protected void handleProjectionEnabled() {
+               if (DEBUG) System.out.println("DefaultCFoldingStructureProvider.handleProjectionEnabled()"); //$NON-NLS-1$
+               // projectionEnabled messages are not always paired with projectionDisabled
+               // i.e. multiple enabled messages may be sent out.
+               // we have to make sure that we disable first when getting an enable
+               // message.
+               handleProjectionDisabled();
+
+               if (fEditor instanceof CEditor) {
+                       initialize();
+                       fReconilingListener= new FoldingStructureReconciler();
+                       ((CEditor)fEditor).addReconcileListener(fReconilingListener);
+                       fSelectionListener= new SelectionListener();
+                       fEditor.getSelectionProvider().addSelectionChangedListener(fSelectionListener);
+               }
+       }
+
+       /**
+        * Called whenever projection is disabled, for example when the provider is
+        * {@link #uninstall() uninstalled}, when the viewer issues a
+        * {@link IProjectionListener#projectionDisabled() projectionDisabled} message and before
+        * {@link #handleProjectionEnabled() enabling} the provider. Implementations must be prepared to
+        * handle multiple calls to this method even if the provider is already disabled.
+        * <p>
+        * Subclasses may extend.
+        * </p>
+        */
+       protected void handleProjectionDisabled() {
+               if (fReconilingListener != null) {
+                       ((CEditor)fEditor).removeReconcileListener(fReconilingListener);
+                       fReconilingListener= null;
+               }
+               if (fSelectionListener != null) {
+                       fEditor.getSelectionProvider().removeSelectionChangedListener(fSelectionListener);
+                       fSelectionListener= null;
+               }
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.folding.ICFoldingStructureProvider#initialize()
+        */
+       public final void initialize() {
+               if (DEBUG) System.out.println("DefaultCFoldingStructureProvider.initialize()"); //$NON-NLS-1$
+               fInitialReconcilePending= true;
+               fCursorPosition= -1;
+               update(createInitialContext());
+       }
+
+       private FoldingStructureComputationContext createInitialContext() {
+               initializePreferences();
+               fInput= getInputElement();
+               if (fInput == null)
+                       return null;
+               
+               return createContext(true);
+       }
+
+       private FoldingStructureComputationContext createContext(boolean allowCollapse) {
+               if (!isInstalled())
+                       return null;
+               ProjectionAnnotationModel model= getModel();
+               if (model == null)
+                       return null;
+               IDocument doc= getDocument();
+               if (doc == null)
+                       return null;
+               
+               return new FoldingStructureComputationContext(doc, model, allowCollapse);
+       }
+       
+       private ICElement getInputElement() {
+               if (fEditor instanceof CEditor) {
+                       return ((CEditor)fEditor).getInputCElement();
+               }
+               return null;
+       }
+
+       private void initializePreferences() {
+               IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+               fCollapseFunctions= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_FUNCTIONS);
+               fCollapseStructures= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_STRUCTURES);
+               fCollapseMacros= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_MACROS);
+               fCollapseMethods= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_METHODS);
+               fCollapseHeaderComments= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_HEADERS);
+               fCollapseComments= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_COMMENTS);
+               fCollapseInactiveCode= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_INACTIVE_CODE);
+               fPreprocessorBranchFoldingEnabled= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED);
+               fStatementsFoldingEnabled= store.getBoolean(PreferenceConstants.EDITOR_FOLDING_STATEMENTS);
+               fCommentFoldingEnabled = true;
+       }
+
+       private void update(FoldingStructureComputationContext ctx) {
+           if (ctx == null || !isConsistent(fInput))
+                       return;
+
+               if (!fInitialReconcilePending && fSelectionListener != null) {
+                       fEditor.getSelectionProvider().removeSelectionChangedListener(fSelectionListener);
+                       fSelectionListener= null;
+               }
+
+               Map<CProjectionAnnotation,Position> additions= new HashMap<CProjectionAnnotation,Position>();
+               List<CProjectionAnnotation> deletions= new ArrayList<CProjectionAnnotation>();
+               List<CProjectionAnnotation> updates= new ArrayList<CProjectionAnnotation>();
+               
+               computeFoldingStructure(ctx);
+               Map<CProjectionAnnotation,Position> updated= ctx.fMap;
+               Map<Object, List<Tuple>> previous= computeCurrentStructure(ctx);
+
+               Iterator<CProjectionAnnotation> e= updated.keySet().iterator();
+               while (e.hasNext()) {
+                       CProjectionAnnotation newAnnotation= e.next();
+                       Object key= newAnnotation.getElement();
+                       Position newPosition= updated.get(newAnnotation);
+
+                       List<Tuple> annotations= previous.get(key);
+                       if (annotations == null) {
+                               if (DEBUG) System.out.println("DefaultCFoldingStructureProvider.update() new annotation " + newAnnotation); //$NON-NLS-1$
+
+                               additions.put(newAnnotation, newPosition);
+
+                       } else {
+                               Iterator<Tuple> x= annotations.iterator();
+                               boolean matched= false;
+                               while (x.hasNext()) {
+                                       Tuple tuple= x.next();
+                                       CProjectionAnnotation existingAnnotation= tuple.annotation;
+                                       Position existingPosition= tuple.position;
+                                       if (newAnnotation.getCategory() == existingAnnotation.getCategory()) {
+                                               final boolean collapseChanged = ctx.allowCollapsing() && existingAnnotation.isCollapsed() != newAnnotation.isCollapsed();
+                                               if (existingPosition != null && (collapseChanged || !newPosition.equals(existingPosition))) {
+                                                       existingPosition.setOffset(newPosition.getOffset());
+                                                       existingPosition.setLength(newPosition.getLength());
+                                                       if (collapseChanged) {
+                                                               if (DEBUG) System.out.println("DefaultCFoldingStructureProvider.update() change annotation " + newAnnotation); //$NON-NLS-1$
+                                                               if (newAnnotation.isCollapsed())
+                                                                       existingAnnotation.markCollapsed();
+                                                               else
+                                                                       existingAnnotation.markExpanded();
+                                                       }
+                                                       updates.add(existingAnnotation);
+                                               }
+                                               matched= true;
+                                               x.remove();
+                                               break;
+                                       }
+                               }
+                               if (!matched) {
+                                       if (DEBUG) System.out.println("DefaultCFoldingStructureProvider.update() new annotation " + newAnnotation); //$NON-NLS-1$
+
+                                       additions.put(newAnnotation, newPosition);
+                               }
+                               if (annotations.isEmpty())
+                                       previous.remove(key);
+                       }
+               }
+
+               Iterator<List<Tuple>> e2= previous.values().iterator();
+               while (e2.hasNext()) {
+                       List<Tuple> list= e2.next();
+                       int size= list.size();
+                       for (int i= 0; i < size; i++) {
+                               CProjectionAnnotation annotation= list.get(i).annotation;
+                               if (DEBUG) System.out.println("DefaultCFoldingStructureProvider.update() deleted annotation " + annotation); //$NON-NLS-1$
+                               deletions.add(annotation);
+                       }
+               }
+
+               match(deletions, additions, updates, ctx);
+
+               Annotation[] removals= new Annotation[deletions.size()];
+               deletions.toArray(removals);
+               Annotation[] changes= new Annotation[updates.size()];
+               updates.toArray(changes);
+               if (DEBUG) System.out.println("DefaultCFoldingStructureProvider.update() "+removals.length+" deleted, "+additions.size()+" added, "+changes.length+" changed"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+               ctx.getModel().modifyAnnotations(removals, additions, changes);
+    }
+
+       /**
+        * Matches deleted annotations to changed or added ones. A deleted
+        * annotation/position tuple that has a matching addition / change
+        * is updated and marked as changed. The matching tuple is not added
+        * (for additions) or marked as deletion instead (for changes). The
+        * result is that more annotations are changed and fewer get
+        * deleted/re-added.
+        */
+       private void match(List<CProjectionAnnotation> deletions, Map<CProjectionAnnotation,Position> additions,
+                       List<CProjectionAnnotation> changes, FoldingStructureComputationContext ctx) {
+               if (deletions.isEmpty() || (additions.isEmpty() && changes.isEmpty()))
+                       return;
+
+               List<CProjectionAnnotation> newDeletions= new ArrayList<CProjectionAnnotation>();
+               List<CProjectionAnnotation> newChanges= new ArrayList<CProjectionAnnotation>();
+
+               Iterator<CProjectionAnnotation> deletionIterator= deletions.iterator();
+               while (deletionIterator.hasNext()) {
+                       CProjectionAnnotation deleted= deletionIterator.next();
+                       Position deletedPosition= ctx.getModel().getPosition(deleted);
+                       if (deletedPosition == null || deletedPosition.length < 5)
+                               continue;
+                       
+                       Tuple deletedTuple= new Tuple(deleted, deletedPosition);
+
+                       Tuple match= findMatch(deletedTuple, changes, null, ctx);
+                       boolean addToDeletions= true; 
+                       if (match == null) {
+                               match= findMatch(deletedTuple, additions.keySet(), additions, ctx);
+                               addToDeletions= false;
+                       }
+                       
+                       if (match != null) {
+                               Object element= match.annotation.getElement();
+                               deleted.setElement(element);
+                               deletedPosition.setLength(match.position.getLength());
+                               if (deletedPosition instanceof CElementPosition && element instanceof ICElement) {
+                                       CElementPosition cep= (CElementPosition) deletedPosition;
+                                       cep.setElement((ICElement) element);
+                               }
+
+                               deletionIterator.remove();
+                               if (DEBUG) System.out.println("DefaultCFoldingStructureProvider.update() changed annotation " + deleted); //$NON-NLS-1$
+                               newChanges.add(deleted);
+
+                               if (addToDeletions) {
+                                       if (DEBUG) System.out.println("DefaultCFoldingStructureProvider.update() deleted annotation " + match.annotation); //$NON-NLS-1$
+                                       newDeletions.add(match.annotation);
+                               }
+                       }
+               }
+
+               deletions.addAll(newDeletions);
+               changes.addAll(newChanges);
+       }
+
+       /**
+        * Finds a match for <code>tuple</code> in a collection of
+        * annotations. The positions for the
+        * <code>CProjectionAnnotation</code> instances in
+        * <code>annotations</code> can be found in the passed
+        * <code>positionMap</code> or in the model if
+        * <code>positionMap</code> is <code>null</code>.
+        * <p>
+        * A tuple is said to match another if their annotations have the
+        * same category and their position offsets are equal.
+        * </p>
+        * <p>
+        * If a match is found, the annotation gets removed from
+        * <code>annotations</code>.
+        * </p>
+        * 
+        * @param tuple the tuple for which we want to find a match
+        * @param annotations collection of
+        *        <code>CProjectionAnnotation</code>
+        * @param positionMap a <code>Map&lt;Annotation, Position&gt;</code>
+        *        or <code>null</code>
+        * @return a matching tuple or <code>null</code> for no match
+        */
+       private Tuple findMatch(Tuple tuple, Collection<CProjectionAnnotation> annotations, Map<CProjectionAnnotation,Position> positionMap, FoldingStructureComputationContext ctx) {
+               Iterator<CProjectionAnnotation> it= annotations.iterator();
+               while (it.hasNext()) {
+                       CProjectionAnnotation annotation= it.next();
+                       if (tuple.annotation.getCategory() == annotation.getCategory()) {
+                               Position position= positionMap == null ? ctx.getModel().getPosition(annotation) : positionMap.get(annotation);
+                               if (position == null)
+                                       continue;
+
+                               if (tuple.position.getOffset() == position.getOffset()) {
+                                       it.remove();
+                                       return new Tuple(annotation, position);
+                               }
+                       }
+               }
+               
+               return null;
+       }
+
+       private Map<Object, List<Tuple>> computeCurrentStructure(FoldingStructureComputationContext ctx) {
+               boolean includeBranches= fPreprocessorBranchFoldingEnabled && ctx.fAST != null;
+               boolean includeStmts= fStatementsFoldingEnabled && ctx.fAST != null;
+               boolean includeCModel= ctx.fAST != null || !(fPreprocessorBranchFoldingEnabled || fStatementsFoldingEnabled);
+               Map<Object, List<Tuple>> map= new HashMap<Object, List<Tuple>>();
+               ProjectionAnnotationModel model= ctx.getModel();
+               Iterator<?> e= model.getAnnotationIterator();
+               while (e.hasNext()) {
+                       Object annotation= e.next();
+                       if (annotation instanceof CProjectionAnnotation) {
+                               CProjectionAnnotation cAnnotation= (CProjectionAnnotation) annotation;
+                               final boolean include;
+                               switch (cAnnotation.getCategory()) {
+                               case CProjectionAnnotation.BRANCH:
+                                       include= includeBranches;
+                                       break;
+                               case CProjectionAnnotation.STATEMENT:
+                                       include= includeStmts;
+                                       break;
+                               case CProjectionAnnotation.CMODEL:
+                                       include= includeCModel;
+                                       break;
+                               default:
+                                       include= true;
+                                       break;
+                               }
+                               Position position= model.getPosition(cAnnotation);
+                               assert position != null;
+                               if (include || position.length < 5) {
+                                       List<Tuple> list= map.get(cAnnotation.getElement());
+                                       if (list == null) {
+                                               list= new ArrayList<Tuple>(2);
+                                               map.put(cAnnotation.getElement(), list);
+                                       }
+                                       list.add(new Tuple(cAnnotation, position));
+                               }
+                       }
+               }
+
+               Comparator<Tuple> comparator= new Comparator<Tuple>() {
+                       public int compare(Tuple t1, Tuple t2) {
+                               return t1.position.getOffset() - t2.position.getOffset();
+                       }
+               };
+               for(List<Tuple> list : map.values()) {
+                       Collections.sort(list, comparator);
+               }
+               return map;
+       }
+       
+
+       private void computeFoldingStructure(final FoldingStructureComputationContext ctx) {
+               if (fCommentFoldingEnabled) {
+                       // compute comment positions from partitioning
+                       try {
+                               IDocument doc= ctx.getDocument();
+                               ITypedRegion[] partitions = TextUtilities.computePartitioning(doc, ICPartitions.C_PARTITIONING, 0, doc.getLength(), false);
+                               computeFoldingStructure(partitions, ctx);
+                       } catch (BadLocationException e) {
+                               // ignore
+                       }
+               }
+               final boolean needAST= fPreprocessorBranchFoldingEnabled || fStatementsFoldingEnabled;
+               if (needAST) {
+                       IASTTranslationUnit ast= ctx.getAST();
+                       if (ast != null) {
+                               computeFoldingStructure(ast, ctx);
+                       } else if (fInitialReconcilePending) {
+                               final WAIT_FLAG waitFlag= ASTProvider.WAIT_ACTIVE_ONLY;
+                               final ASTProvider astProvider= CUIPlugin.getDefault().getASTProvider();
+                               IStatus status= astProvider.runOnAST(getInputElement(), waitFlag, null, new ASTCache.ASTRunnable() {
+                                       public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
+                                               if (ast != null) {
+                                                       ctx.fAST= ast;
+                                                       computeFoldingStructure(ast, ctx);
+                                               }
+                                               return Status.OK_STATUS;
+                                       }
+                               });
+                               if (status.matches(IStatus.ERROR)) {
+                                       CUIPlugin.log(status);
+                               }
+                       }
+               }
+               if (!needAST || ctx.getAST() != null) {
+                       fInitialReconcilePending= false;
+                       IParent parent= (IParent) fInput;
+                       try {
+                               computeFoldingStructure(parent.getChildren(), ctx);
+                       } catch (CModelException x) {
+                       }
+               }
+       }
+
+       static boolean isConsistent(ICElement element) {
+               if (element instanceof ITranslationUnit) {
+                       try {
+                               return ((ITranslationUnit)element).isConsistent();
+                       } catch (CModelException exc) {
+                       }
+               }
+               return false;
+       }
+
+       /**
+        * A modifiable region with extra information about the region it holds.
+        * It tells us whether or not to include the last line of the region
+        */
+       private static class StatementRegion extends ModifiableRegion {
+               public final String function;
+               public int level;
+               public boolean inclusive;
+               public StatementRegion(String function, int level) {
+                       this.function= function; 
+                       this.level= level;
+               }
+       }
+
+       /**
+        * Computes folding structure of statements for the given AST.
+        * 
+        * @param ast
+        * @param ctx
+        */
+       private void computeStatementFoldingStructure(IASTTranslationUnit ast, FoldingStructureComputationContext ctx) {
+               final Stack<StatementRegion> iral= new Stack<StatementRegion>();
+               ast.accept(new StatementVisitor(iral));
+               while (!iral.empty()) {
+                       StatementRegion mr = iral.pop();
+                       IRegion aligned = alignRegion(mr, ctx,mr.inclusive);
+                       if (aligned != null) {
+                               Position alignedPos= new Position(aligned.getOffset(), aligned.getLength());
+                               ctx.addProjectionRange(new CProjectionAnnotation(
+                                               false, mr.function + mr.level + computeKey(mr, ctx), CProjectionAnnotation.STATEMENT), alignedPos);
+                       }
+               }
+       }
+
+       /**
+        * Compute folding structure of things related to the AST tree. Currently it
+        * computes the folding structure for: preprocessor branches for the given
+        * AST. Also, it computes statements folding (if/else do/while for and
+        * switch)
+        * 
+        * @param ast
+        * @param ctx
+        */
+       private void computeFoldingStructure(IASTTranslationUnit ast, FoldingStructureComputationContext ctx) {
+               if (ast == null) {
+                       return;
+               }
+               String fileName = ast.getFilePath();
+               if (fileName == null) {
+                       return;
+               }
+
+               if (fStatementsFoldingEnabled)
+                       computeStatementFoldingStructure(ast, ctx);
+
+               if (fPreprocessorBranchFoldingEnabled)
+                       computePreprocessorFoldingStructure(ast, ctx);
+       }
+
+       /**
+        * Computes folding structure for preprocessor branches for the given AST.
+        * 
+        * @param ast
+        * @param ctx
+        */
+       private void computePreprocessorFoldingStructure(IASTTranslationUnit ast, FoldingStructureComputationContext ctx) {
+               List<Branch> branches = new ArrayList<Branch>();
+               Stack<Branch> branchStack = new Stack<Branch>();
+
+               IASTPreprocessorStatement[] preprocStmts = ast.getAllPreprocessorStatements();
+
+               for (IASTPreprocessorStatement statement : preprocStmts) {
+                       if (!statement.isPartOfTranslationUnitFile()) {
+                               // preprocessor directive is from a different file
+                               continue;
+                       }
+                       IASTNodeLocation stmtLocation= statement.getFileLocation();
+                       if (stmtLocation == null) {
+                               continue;
+                       }
+                       if (statement instanceof IASTPreprocessorIfStatement) {
+                               IASTPreprocessorIfStatement ifStmt = (IASTPreprocessorIfStatement)statement;
+                               branchStack.push(new Branch(stmtLocation.getNodeOffset(), ifStmt.taken(), "#if " + new String(ifStmt.getCondition()))); //$NON-NLS-1$
+                       } else if (statement instanceof IASTPreprocessorIfdefStatement) {
+                               IASTPreprocessorIfdefStatement ifdefStmt = (IASTPreprocessorIfdefStatement)statement;
+                               branchStack.push(new Branch(stmtLocation.getNodeOffset(), ifdefStmt.taken(), "#ifdef " + new String(ifdefStmt.getCondition()))); //$NON-NLS-1$
+                       } else if (statement instanceof IASTPreprocessorIfndefStatement) {
+                               IASTPreprocessorIfndefStatement ifndefStmt = (IASTPreprocessorIfndefStatement)statement;
+                               branchStack.push(new Branch(stmtLocation.getNodeOffset(), ifndefStmt.taken(), "#ifndef " + new String(ifndefStmt.getCondition()))); //$NON-NLS-1$
+                       } else if (statement instanceof IASTPreprocessorElseStatement) {
+                               if (branchStack.isEmpty()) {
+                                       // #else without #if
+                                       continue;
+                               }
+                               Branch branch= branchStack.pop();
+                               IASTPreprocessorElseStatement elseStmt = (IASTPreprocessorElseStatement)statement;
+                               branchStack.push(new Branch(stmtLocation.getNodeOffset(), elseStmt.taken(), branch.fCondition));
+                               branch.setEndOffset(stmtLocation.getNodeOffset());
+                               branches.add(branch);
+                       } else if (statement instanceof IASTPreprocessorElifStatement) {
+                               if (branchStack.isEmpty()) {
+                                       // #elif without #if
+                                       continue;
+                               }
+                               Branch branch= branchStack.pop();
+                               IASTPreprocessorElifStatement elifStmt = (IASTPreprocessorElifStatement) statement;
+                               branchStack.push(new Branch(stmtLocation.getNodeOffset(), elifStmt.taken(), branch.fCondition));
+                               branch.setEndOffset(stmtLocation.getNodeOffset());
+                               branches.add(branch);
+                       } else if (statement instanceof IASTPreprocessorEndifStatement) {
+                               if (branchStack.isEmpty()) {
+                                       // #endif without #if
+                                       continue;
+                               }
+                               Branch branch= branchStack.pop();
+                               branch.setEndOffset(stmtLocation.getNodeOffset() + stmtLocation.getNodeLength());
+                               branch.setInclusive(true);
+                               branches.add(branch);
+                       }
+               }
+
+               if (!branchStack.isEmpty()) {
+                       // unterminated #if
+                       Branch branch= branchStack.pop();
+                       branch.setEndOffset(getDocument().getLength());
+                       branch.setInclusive(true);
+                       branches.add(branch);
+               }
+               
+               Map<String, Counter> keys= new HashMap<String, Counter>(branches.size());
+               for (Branch branch : branches) {
+                       IRegion aligned = alignRegion(branch, ctx, branch.fInclusive);
+                       if (aligned != null) {
+                               Position alignedPos= new Position(aligned.getOffset(), aligned.getLength());
+                               final boolean collapse= !branch.taken() && ctx.collapseInactiveCode() && !alignedPos.includes(fCursorPosition);
+                               // compute a stable key
+                               String key = branch.fCondition;
+                               Counter counter= keys.get(key);
+                               if (counter == null) {
+                                       keys.put(key, new Counter());
+                               } else {
+                                       key= Integer.toString(counter.fCount++) + key;
+                               }
+                               ctx.addProjectionRange(new CProjectionAnnotation(collapse, key, CProjectionAnnotation.BRANCH), alignedPos);
+                       }
+               }
+       }
+
+       /**
+        * Compute a key for recognizing an annotation based on the given position.
+        * 
+        * @param pos
+        * @param ctx
+        * @return a key to recognize an annotation position
+        */
+       private Object computeKey(Position pos, FoldingStructureComputationContext ctx) {
+               try {
+                       final IDocument document= ctx.getDocument();
+                       IRegion line= document.getLineInformationOfOffset(pos.offset);
+                       return document.get(pos.offset, Math.min(32, line.getOffset() + line.getLength() - pos.offset));
+               } catch (BadLocationException exc) {
+                       return exc;
+               }
+       }
+
+       /**
+        * Compute folding structure based on partioning information.
+        * 
+        * @param partitions  array of document partitions
+        * @param ctx  the folding structure context
+        * @throws BadLocationException 
+        */
+       private void computeFoldingStructure(ITypedRegion[] partitions, FoldingStructureComputationContext ctx) throws BadLocationException {
+               boolean collapse = ctx.collapseComments();
+               IDocument doc= ctx.getDocument();
+               int startLine = -1;
+               int endLine = -1;
+               List<Tuple> comments= new ArrayList<Tuple>();
+               ModifiableRegion commentRange = new ModifiableRegion();
+               for (ITypedRegion partition : partitions) {
+                       boolean singleLine= false;
+                       if (ICPartitions.C_MULTI_LINE_COMMENT.equals(partition.getType())
+                               || ICPartitions.C_MULTI_LINE_DOC_COMMENT.equals(partition.getType())) {
+                               Position position= createCommentPosition(alignRegion(partition, ctx, true));
+                               if (position != null) {
+                                       if (startLine >= 0 && endLine - startLine >= fMinCommentLines) {
+                                               Position projection = createCommentPosition(alignRegion(commentRange, ctx, true));
+                                               if (projection != null) {
+                                                       comments.add(new Tuple(new CProjectionAnnotation(collapse, doc.get(projection.offset, Math.min(16, projection.length)), true), projection));
+                                               }
+                                               startLine= -1;
+                                       }
+                                       comments.add(new Tuple(new CProjectionAnnotation(collapse, doc.get(position.offset, Math.min(16, position.length)), true), position));
+                               } else {
+                                       singleLine= true;
+                               }
+                       } else {
+                               singleLine= ICPartitions.C_SINGLE_LINE_COMMENT.equals(partition.getType());
+                       }
+                       if (singleLine) {
+                               // if comment starts at column 0 and spans only one line
+                               // and is adjacent to a previous line comment, add it
+                               // to the commentRange
+                               int lineNr = doc.getLineOfOffset(partition.getOffset());
+                               IRegion lineRegion = doc.getLineInformation(lineNr);
+                               boolean isLineStart = partition.getOffset() == lineRegion.getOffset();
+                               if (!isLineStart) {
+                                       continue;
+                               }
+                               if (!singleLine) {
+                                       singleLine = lineRegion.getOffset() + lineRegion.getLength() >= partition.getOffset() + partition.getLength();
+                                       if (!singleLine) {
+                                               continue;
+                                       }
+                               }
+                               if (startLine < 0 || lineNr - endLine > 1) {
+                                       if (startLine >= 0 && endLine - startLine >= fMinCommentLines) {
+                                               Position projection = createCommentPosition(alignRegion(commentRange, ctx, true));
+                                               if (projection != null) {
+                                                       comments.add(new Tuple(new CProjectionAnnotation(collapse, doc.get(projection.offset, Math.min(16, projection.length)), true), projection));
+                                               }
+                                       }
+                                       startLine = lineNr;
+                                       endLine = lineNr;
+                                       commentRange.offset = lineRegion.getOffset();
+                                       commentRange.length = lineRegion.getLength();
+                               } else {
+                                       endLine = lineNr;
+                                       int delta = lineRegion.getOffset() + lineRegion.getLength() - commentRange.offset - commentRange.length;
+                                       commentRange.length += delta;
+                               }
+                       }
+               }
+               if (startLine >= 0 && endLine - startLine >= fMinCommentLines) {
+                       Position projection = createCommentPosition(alignRegion(commentRange, ctx, true));
+                       if (projection != null) {
+                               comments.add(new Tuple(new CProjectionAnnotation(collapse, doc.get(projection.offset, Math.min(16, projection.length)), true), projection));
+                       }
+               }
+               if (!comments.isEmpty()) {
+                       // first comment starting before line 10 is considered the header comment
+                       Iterator<Tuple> iter = comments.iterator();
+                       Tuple tuple = iter.next();
+                       int lineNr = doc.getLineOfOffset(tuple.position.getOffset());
+                       if (lineNr < 10) {
+                               if (ctx.collapseHeaderComments()) {
+                                       tuple.annotation.markCollapsed();
+                               } else {
+                                       tuple.annotation.markExpanded();
+                               }
+                       }
+                       ctx.addProjectionRange(tuple.annotation, tuple.position);
+                       while (iter.hasNext()) {
+                               tuple = iter.next();
+                               ctx.addProjectionRange(tuple.annotation, tuple.position);
+                       }
+               }
+       }
+
+       private void computeFoldingStructure(ICElement[] elements, FoldingStructureComputationContext ctx) throws CModelException {
+               for (ICElement element : elements) {
+                       computeFoldingStructure(element, ctx);
+
+                       if (element instanceof IParent) {
+                               IParent parent= (IParent) element;
+                               computeFoldingStructure(parent.getChildren(), ctx);
+                       }
+               }
+       }
+
+       /**
+        * Computes the folding structure for a given {@link ICElement C element}. Computed
+        * projection annotations are
+        * {@link DefaultCFoldingStructureProvider.FoldingStructureComputationContext#addProjectionRange(DefaultCFoldingStructureProvider.CProjectionAnnotation, Position) added}
+        * to the computation context.
+        * <p>
+        * Subclasses may extend or replace. The default implementation creates projection annotations
+        * for the following elements:
+        * <ul>
+        * <li>structs, unions, classes</li>
+        * <li>functions</li>
+        * <li>methods</li>
+        * <li>multiline macro definitions</li>
+        * </ul>
+        * </p>
+        * 
+        * @param element the C element to compute the folding structure for
+        * @param ctx the computation context
+        */
+       protected void computeFoldingStructure(ICElement element, FoldingStructureComputationContext ctx) {
+
+               boolean collapse= false;
+               switch (element.getElementType()) {
+
+               case ICElement.C_STRUCT:
+               case ICElement.C_CLASS:
+               case ICElement.C_UNION:
+               case ICElement.C_ENUMERATION:
+               case ICElement.C_TEMPLATE_STRUCT:
+               case ICElement.C_TEMPLATE_CLASS:
+               case ICElement.C_TEMPLATE_UNION:
+                       collapse= ctx.collapseStructures();
+                       break;
+               case ICElement.C_MACRO:
+                       collapse= ctx.collapseMacros();
+                       break;
+               case ICElement.C_FUNCTION:
+               case ICElement.C_TEMPLATE_FUNCTION:
+                       collapse= ctx.collapseFunctions();
+                       break;
+               case ICElement.C_METHOD:
+               case ICElement.C_TEMPLATE_METHOD:
+                       collapse= ctx.collapseMethods();
+                       break;
+               case ICElement.C_NAMESPACE:
+                       break;
+               default:
+                       return;
+               }
+
+               IRegion[] regions= computeProjectionRanges((ISourceReference) element, ctx);
+               if (regions.length > 0) {
+                       IRegion normalized= alignRegion(regions[regions.length - 1], ctx, true);
+                       if (normalized != null) {
+                               Position position= createElementPosition(normalized, element);
+                               if (position != null) {
+                                       collapse= collapse && !position.includes(fCursorPosition);
+                                       ctx.addProjectionRange(new CProjectionAnnotation(collapse, element, false), position);
+                               }
+                       }
+               }
+       }
+
+       /**
+        * Computes the projection ranges for a given <code>ISourceReference</code>. More than one
+        * range or none at all may be returned. If there are no foldable regions, an empty array is
+        * returned.
+        * <p>
+        * The last region in the returned array (if not empty) describes the region for the C
+        * element that implements the source reference. Any preceding regions describe comments
+        * of that element.
+        * </p>
+        * 
+        * @param reference a C element that is a source reference
+        * @param ctx the folding context
+        * @return the regions to be folded
+        */
+       protected final IRegion[] computeProjectionRanges(ISourceReference reference, FoldingStructureComputationContext ctx) {
+               try {
+                       ISourceRange range= reference.getSourceRange();
+                       return new IRegion[] {
+                               new Region(range.getStartPos(), range.getLength())
+                       };
+               } catch (CModelException e) {
+               }
+
+               return new IRegion[0];
+       }
+
+       /**
+        * Creates a comment folding position from an
+        * {@link #alignRegion(IRegion, DefaultCFoldingStructureProvider.FoldingStructureComputationContext, boolean) aligned}
+        * region.
+        * 
+        * @param aligned an aligned region
+        * @return a folding position corresponding to <code>aligned</code>
+        */
+       protected final Position createCommentPosition(IRegion aligned) {
+               if (aligned == null) {
+                       return null;
+               }
+               return new CommentPosition(aligned.getOffset(), aligned.getLength());
+       }
+
+       /**
+        * Creates a folding position that remembers its element from an
+        * {@link #alignRegion(IRegion, DefaultCFoldingStructureProvider.FoldingStructureComputationContext, boolean) aligned}
+        * region.
+        * 
+        * @param aligned an aligned region
+        * @param element the element to remember
+        * @return a folding position corresponding to <code>aligned</code>
+        */
+       protected final Position createElementPosition(IRegion aligned, ICElement element) {
+               return new CElementPosition(aligned.getOffset(), aligned.getLength(), element);
+       }
+
+       /**
+        * Aligns <code>region</code> to start and end at a line offset. The region's start is
+        * decreased to the next line offset, and the end offset increased to the next line start or the
+        * end of the document. <code>null</code> is returned if <code>region</code> is
+        * <code>null</code> itself or does not comprise at least one line delimiter, as a single line
+        * cannot be folded.
+        * 
+        * @param region the region to align, may be <code>null</code>
+        * @param ctx the folding context
+        * @return a region equal or greater than <code>region</code> that is aligned with line
+        *         offsets, <code>null</code> if the region is too small to be foldable (e.g. covers
+        *         only one line)
+        */
+       protected final IRegion alignRegion(IRegion region, FoldingStructureComputationContext ctx) {
+               return alignRegion(region, ctx, true);
+       }
+
+       /**
+        * Aligns <code>region</code> to start and end at a line offset. The region's start is
+        * decreased to the next line offset, and the end offset increased to the next line start or the
+        * end of the document. <code>null</code> is returned if <code>region</code> is
+        * <code>null</code> itself or does not comprise at least one line delimiter, as a single line
+        * cannot be folded.
+        * 
+        * @param region the region to align, may be <code>null</code>
+        * @param ctx the folding context
+        * @param inclusive include line of end offset
+        * @return a region equal or greater than <code>region</code> that is aligned with line
+        *         offsets, <code>null</code> if the region is too small to be foldable (e.g. covers
+        *         only one line)
+        */
+       protected final IRegion alignRegion(IRegion region, FoldingStructureComputationContext ctx, boolean inclusive) {
+               if (region == null)
+                       return null;
+               
+               IDocument document= ctx.getDocument();
+               
+               try {
+                       
+                       int start= document.getLineOfOffset(region.getOffset());
+                       int end= document.getLineOfOffset(region.getOffset() + region.getLength());
+                       if (start >= end)
+                               return null;
+                       
+                       int offset= document.getLineOffset(start);
+                       int endOffset;
+                       if (inclusive) {
+                               if (document.getNumberOfLines() > end + 1)
+                                       endOffset= document.getLineOffset(end + 1);
+                               else
+                                       endOffset= document.getLineOffset(end) + document.getLineLength(end);
+                       } else {
+                               endOffset= document.getLineOffset(end);
+                       }
+                       return new Region(offset, endOffset - offset);
+                       
+               } catch (BadLocationException x) {
+                       // concurrent modification
+                       return null;
+               }
+       }
+       
+       private ProjectionAnnotationModel getModel() {
+               return (ProjectionAnnotationModel) fEditor.getAdapter(ProjectionAnnotationModel.class);
+       }
+
+       private IDocument getDocument() {
+               IDocumentProvider provider= fEditor.getDocumentProvider();
+               return provider.getDocument(fEditor.getEditorInput());
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/EmptyCFoldingPreferenceBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/EmptyCFoldingPreferenceBlock.java
new file mode 100644 (file)
index 0000000..3a0d132
--- /dev/null
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.folding;
+
+import org.eclipse.cdt.ui.text.folding.ICFoldingPreferenceBlock;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+
+/**
+ * Empty preference block for extensions to the
+ * <code>org.eclipse.cdt.ui.foldingStructureProviders</code> extension
+ * point that do not specify their own.
+ * 
+ * @since 3.0
+ */
+public class EmptyCFoldingPreferenceBlock implements ICFoldingPreferenceBlock {
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.folding.ICFoldingPreferences#createControl(org.eclipse.swt.widgets.Group)
+        */
+       public Control createControl(Composite composite) {
+               Composite inner= new Composite(composite, SWT.NONE);
+               inner.setLayout(new GridLayout(3, false));
+
+               Label label= new Label(inner, SWT.CENTER);
+               GridData gd= new GridData(GridData.FILL_BOTH);
+               gd.widthHint= 30;
+               label.setLayoutData(gd);
+               
+               label= new Label(inner, SWT.CENTER);
+               label.setText(FoldingMessages.EmptyCFoldingPreferenceBlock_emptyCaption); 
+               gd= new GridData(GridData.CENTER);
+               label.setLayoutData(gd);
+
+               label= new Label(inner, SWT.CENTER);
+               gd= new GridData(GridData.FILL_BOTH);
+               gd.widthHint= 30;
+               label.setLayoutData(gd);
+               
+               return inner;
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.folding.ICFoldingPreferenceBlock#initialize()
+        */
+       public void initialize() {
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.folding.ICFoldingPreferenceBlock#performOk()
+        */
+       public void performOk() {
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.folding.ICFoldingPreferenceBlock#performDefaults()
+        */
+       public void performDefaults() {
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.folding.ICFoldingPreferenceBlock#dispose()
+        */
+       public void dispose() {
+       }
+
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/FoldingMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/FoldingMessages.java
new file mode 100644 (file)
index 0000000..103c591
--- /dev/null
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Elazar Leibovich (IDF) - Code folding of compound statements (bug 174597)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.folding;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class FoldingMessages extends NLS {
+
+       private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.text.folding.FoldingMessages";//$NON-NLS-1$
+
+       private FoldingMessages() {
+               // Do not instantiate
+       }
+
+       public static String DefaultCFoldingPreferenceBlock_title;
+       public static String DefaultCFoldingPreferenceBlock_macros;
+       public static String DefaultCFoldingPreferenceBlock_functions;
+       public static String DefaultCFoldingPreferenceBlock_methods;
+       public static String DefaultCFoldingPreferenceBlock_structures;
+       public static String DefaultCFoldingPreferenceBlock_comments;
+       public static String DefaultCFoldingPreferenceBlock_headers;
+       public static String DefaultCFoldingPreferenceBlock_inactive_code;
+       public static String DefaultCFoldingPreferenceBlock_preprocessor_enabled;
+       public static String EmptyCFoldingPreferenceBlock_emptyCaption;
+       public static String DefaultCFoldingPreferenceBlock_statements_enabled;
+
+       static {
+               NLS.initializeMessages(BUNDLE_NAME, FoldingMessages.class);
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/FoldingMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/FoldingMessages.properties
new file mode 100644 (file)
index 0000000..3a6a8fd
--- /dev/null
@@ -0,0 +1,26 @@
+###############################################################################
+# Copyright (c) 2000, 2008 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+#     Anton Leherbauer (Wind River Systems)
+#     Elazar Leibovich (IDF) - Code folding of compound statements (bug 174597)
+###############################################################################
+
+
+DefaultCFoldingPreferenceBlock_title= Initially fold these region types:
+DefaultCFoldingPreferenceBlock_macros= &Macros
+DefaultCFoldingPreferenceBlock_functions= &Functions
+DefaultCFoldingPreferenceBlock_methods= M&ethods
+DefaultCFoldingPreferenceBlock_structures= &Structures
+DefaultCFoldingPreferenceBlock_comments= &Comments
+DefaultCFoldingPreferenceBlock_headers= &Header Comments
+DefaultCFoldingPreferenceBlock_inactive_code= &Inactive Preprocessor Branches
+DefaultCFoldingPreferenceBlock_preprocessor_enabled= Enable folding of preprocessor branches (#if/#endif)
+DefaultCFoldingPreferenceBlock_statements_enabled= Enable folding of control flow statements (if/else, do/while, for, switch)
+
+EmptyCFoldingPreferenceBlock_emptyCaption=
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/AddWordProposal.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/AddWordProposal.java
new file mode 100644 (file)
index 0000000..db335dd
--- /dev/null
@@ -0,0 +1,173 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *        Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialogWithToggle;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.eclipse.ui.texteditor.spelling.SpellingProblem;
+
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.ICCompletionProposal;
+import org.eclipse.cdt.ui.text.IInvocationContext;
+
+import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellCheckEngine;
+import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellChecker;
+
+/**
+ * Proposal to add the unknown word to the dictionaries.
+ */
+public class AddWordProposal implements ICCompletionProposal {
+       private static final String PREF_KEY_DO_NOT_ASK= "do_not_ask_to_install_user_dictionary"; //$NON-NLS-1$
+       
+       /** The invocation context */
+       private final IInvocationContext fContext;
+
+       /** The word to add */
+       private final String fWord;
+
+       /**
+        * Creates a new add word proposal
+        *
+        * @param word
+        *                   The word to add
+        * @param context
+        *                   The invocation context
+        */
+       public AddWordProposal(final String word, final IInvocationContext context) {
+               fContext= context;
+               fWord= word;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument)
+        */
+       public final void apply(final IDocument document) {
+               final ISpellCheckEngine engine= SpellCheckEngine.getInstance();
+               final ISpellChecker checker= engine.getSpellChecker();
+
+               if (checker == null)
+                       return;
+               
+               IQuickAssistInvocationContext quickAssistContext= null;
+               if (fContext instanceof IQuickAssistInvocationContext)
+                       quickAssistContext= (IQuickAssistInvocationContext)fContext;
+               
+               if (!checker.acceptsWords()) {
+                       final Shell shell;
+                       if (quickAssistContext != null && quickAssistContext.getSourceViewer() != null)
+                               shell= quickAssistContext.getSourceViewer().getTextWidget().getShell();
+                       else
+                               shell= CUIPlugin.getActiveWorkbenchShell();
+                       
+                       if (!canAskToConfigure() || !askUserToConfigureUserDictionary(shell))
+                               return;
+                       
+                       String[] preferencePageIds= new String[] { "org.eclipse.ui.editors.preferencePages.Spelling" }; //$NON-NLS-1$
+                       PreferencesUtil.createPreferenceDialogOn(shell, preferencePageIds[0], preferencePageIds, null).open();
+               }
+               
+               if (checker.acceptsWords()) {
+                       checker.addWord(fWord);
+                       if (quickAssistContext != null && quickAssistContext.getSourceViewer() != null) {
+                               SpellingProblem.removeAll(quickAssistContext.getSourceViewer(), fWord);
+                       }
+               }
+       }
+
+       /**
+        * Asks the user whether he wants to configure
+        * a user dictionary.
+        * 
+        * @param shell
+        * @return <code>true</code> if the user wants to configure the user dictionary
+        */
+       private boolean askUserToConfigureUserDictionary(Shell shell) {
+               MessageDialogWithToggle toggleDialog= MessageDialogWithToggle.openYesNoQuestion(
+                               shell,
+                               Messages.Spelling_add_askToConfigure_title,
+                               Messages.Spelling_add_askToConfigure_question,
+                               Messages.Spelling_add_askToConfigure_ignoreMessage,
+                               false,
+                               null,
+                               null);
+               
+               PreferenceConstants.getPreferenceStore().setValue(PREF_KEY_DO_NOT_ASK, toggleDialog.getToggleState());
+               
+               return toggleDialog.getReturnCode() == IDialogConstants.YES_ID;
+       }
+
+       /**
+        * Tells whether this proposal can ask to
+        * configure a user dictionary.
+        * 
+        * @return <code>true</code> if it can ask the user
+        */
+       static boolean canAskToConfigure() {
+               return !PreferenceConstants.getPreferenceStore().getBoolean(PREF_KEY_DO_NOT_ASK);
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo()
+        */
+       public String getAdditionalProposalInfo() {
+               return Messages.bind(Messages.Spelling_add_info, WordCorrectionProposal.getHtmlRepresentation(fWord));
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getContextInformation()
+        */
+       public final IContextInformation getContextInformation() {
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
+        */
+       public String getDisplayString() {
+               return Messages.bind(Messages.Spelling_add_label, fWord);
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage()
+        */
+       public Image getImage() {
+               return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_CORRECTION_ADD);
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.java.IJavaCompletionProposal#getRelevance()
+        */
+       public int getRelevance() {
+               return Integer.MIN_VALUE;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getSelection(org.eclipse.jface.text.IDocument)
+        */
+       public final Point getSelection(final IDocument document) {
+               return new Point(fContext.getSelectionOffset(), fContext.getSelectionLength());
+       }
+
+       public String getIdString() {
+               return fWord;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingEngine.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingEngine.java
new file mode 100644 (file)
index 0000000..f598c2f
--- /dev/null
@@ -0,0 +1,209 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *        Sergey Prigogin (Google)
+ *     Andrew Ferguson (Symbian)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentExtension3;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.text.TypedRegion;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.RuleBasedScanner;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector;
+
+import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
+import org.eclipse.cdt.ui.text.ICPartitions;
+import org.eclipse.cdt.ui.text.ITokenStore;
+import org.eclipse.cdt.ui.text.ITokenStoreFactory;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentDictionary;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentSimpleDictionary;
+
+import org.eclipse.cdt.internal.ui.text.CPreprocessorScanner;
+import org.eclipse.cdt.internal.ui.text.FastCPartitioner;
+import org.eclipse.cdt.internal.ui.text.doctools.DocCommentSpellDictionary;
+import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellChecker;
+import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellDictionary;
+import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellEventListener;
+
+/**
+ * C/C++ spelling engine
+ */
+public class CSpellingEngine extends SpellingEngine {
+
+       /**
+        * A dummy token store for use with a token scanner.
+        */
+       private static class SimpleTokenStore implements ITokenStore {
+               public void ensureTokensInitialised() {
+               }
+               public IPreferenceStore getPreferenceStore() {
+                       return null;
+               }
+               public IToken getToken(String property) {
+                       return new Token(property);
+               }
+               public void adaptToPreferenceChange(PropertyChangeEvent event) {
+               }
+               public boolean affectsBehavior(PropertyChangeEvent event) {
+                       return false;
+               }
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.SpellingEngine#check(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IRegion[], org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellChecker, org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector, org.eclipse.core.runtime.IProgressMonitor)
+        */
+       @Override
+       protected void check(IDocument document, IRegion[] regions, ISpellChecker checker, ISpellingProblemCollector collector, IProgressMonitor monitor) {
+               ISpellEventListener listener= new SpellEventListener(collector, document);
+               boolean isIgnoringStringLiterals= SpellingPreferences.isIgnoreStringLiterals();
+               
+               ISpellDictionary toRemove= null;
+               try {
+                       checker.addListener(listener);
+                       
+                       IDocCommentOwner owner= null;
+                       if (document instanceof IDocumentExtension3) {
+                               IDocumentPartitioner partitioner= ((IDocumentExtension3)document).getDocumentPartitioner(ICPartitions.C_PARTITIONING);
+                               if (partitioner instanceof FastCPartitioner) {
+                                       owner= ((FastCPartitioner)partitioner).getDocCommentOwner();
+                               }
+                       }
+                       
+                       try {
+                               for (int i= 0; i < regions.length; i++) {
+                                       IRegion region= regions[i];
+                                       ITypedRegion[] partitions= TextUtilities.computePartitioning(document,
+                                                       ICPartitions.C_PARTITIONING, region.getOffset(), region.getLength(), false);
+                                       for (int index= 0; index < partitions.length; index++) {
+                                               if (monitor != null && monitor.isCanceled())
+                                                       return;
+
+                                               ITypedRegion partition= partitions[index];
+                                               final String type= partition.getType();
+                                               
+                                               if (isIgnoringStringLiterals && type.equals(ICPartitions.C_STRING))
+                                                       continue;
+
+                                               if (owner!=null) {
+                                                       IDocCommentDictionary dict= null;
+                                                       
+                                                       if (type.equals(ICPartitions.C_MULTI_LINE_DOC_COMMENT)) {
+                                                               dict= owner.getMultilineConfiguration().getSpellingDictionary();
+                                                       } else if (type.equals(ICPartitions.C_SINGLE_LINE_DOC_COMMENT)) {
+                                                               dict= owner.getSinglelineConfiguration().getSpellingDictionary();
+                                                       }
+                                                       
+                                                       if (dict instanceof IDocCommentSimpleDictionary) {
+                                                               ISpellDictionary sd= new DocCommentSpellDictionary((IDocCommentSimpleDictionary)dict);
+                                                               checker.addDictionary(sd);
+                                                               toRemove= sd;
+                                                       }
+                                               }
+                                               
+                                               if (type.equals(ICPartitions.C_PREPROCESSOR)) {
+                                                       RuleBasedScanner scanner = new CPreprocessorScanner(new ITokenStoreFactory() {
+                                                               public ITokenStore createTokenStore(String[] propertyColorNames) {
+                                                                       return new SimpleTokenStore();
+                                                               }}, GPPLanguage.getDefault());
+                                                       scanner.setRange(document, partition.getOffset(), partition.getLength());
+                                                       int firstTokenOffset = -1;
+                                                       int firstTokenLength = -1;
+                                                       while (true) {
+                                                               IToken token = scanner.nextToken();
+                                                               if (token.isEOF()) {
+                                                                       break;
+                                                               }
+                                                               if (token.isOther()) {
+                                                                       int offset = scanner.getTokenOffset();
+                                                                       int length = scanner.getTokenLength();
+                                                                       if (firstTokenOffset < 0) {
+                                                                               firstTokenOffset = offset;
+                                                                               firstTokenLength = length;
+                                                                       }
+                                                                       String subregionType = null;
+                                                                       char c = document.getChar(offset);
+                                                                       if (c == '"') {
+                                                                               if (!isIgnoringStringLiterals &&
+                                                                                               !isIncludeDirective(document, firstTokenOffset, firstTokenLength)) {
+                                                                                       subregionType = ICPartitions.C_STRING;
+                                                                               }
+                                                                       } else if (c == '/' && length >= 2) {
+                                                                               c = document.getChar(offset + 1);
+                                                                               if (c == '/') {
+                                                                                       subregionType = ICPartitions.C_SINGLE_LINE_COMMENT;
+                                                                               } else if (c == '*') {
+                                                                                       subregionType = ICPartitions.C_MULTI_LINE_COMMENT;
+                                                                               }
+                                                                       }
+                                                                       if (subregionType != null) {
+                                                                               TypedRegion subregion = new TypedRegion(offset, length, subregionType);
+                                                                               checker.execute(new SpellCheckIterator(document, subregion,
+                                                                                               checker.getLocale()));
+                                                                       }
+                                                               }
+                                                       }
+                                               } else if (!type.equals(IDocument.DEFAULT_CONTENT_TYPE) &&
+                                                               !type.equals(ICPartitions.C_CHARACTER)) {
+                                                       checker.execute(new SpellCheckIterator(document, partition, checker.getLocale()));
+                                               }
+                                               
+                                               if (toRemove != null) {
+                                                       checker.removeDictionary(toRemove);
+                                                       toRemove= null;
+                                               }
+                                       }
+                               }
+                       } catch (BadLocationException x) {
+                               // Ignore BadLocationException since although it does happen from time to time,
+                               // there seems to be not much harm from it.
+//                             CUIPlugin.log(x);
+                       }
+               } finally {
+                       if (toRemove != null)
+                               checker.removeDictionary(toRemove);
+                       checker.removeListener(listener);
+               }
+       }
+
+       /**
+        * Returns <code>true</code> if the token at the given offset and length is an include directive. 
+        * @param document
+        * @param offset
+        * @param length
+        * @return
+        * @throws BadLocationException
+        */
+       private boolean isIncludeDirective(IDocument document, int offset, int length) throws BadLocationException {
+               while (length > 0) {
+                       char c = document.getChar(offset);
+                       if (c == '#' || Character.isWhitespace(c)) {
+                               offset++;
+                               length--;
+                       } else if (c == 'i') {
+                               return document.get(offset, length).startsWith("include"); //$NON-NLS-1$
+                       } else {
+                               break;
+                       }
+               }
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingProblem.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingProblem.java
new file mode 100644 (file)
index 0000000..15a406d
--- /dev/null
@@ -0,0 +1,211 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *        Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.texteditor.spelling.SpellingProblem;
+
+import org.eclipse.cdt.ui.text.ICCompletionProposal;
+
+import org.eclipse.cdt.internal.ui.text.IHtmlTagConstants;
+import org.eclipse.cdt.internal.ui.text.correction.CorrectionContext;
+import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellCheckEngine;
+import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellChecker;
+import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellEvent;
+import org.eclipse.cdt.internal.ui.text.spelling.engine.RankedWordProposal;
+
+/**
+ * A {@link SpellingProblem} that adapts a {@link ISpellEvent}.
+ * <p>
+ * TODO: remove {@link ISpellEvent} notification mechanism
+ * </p>
+ */
+public class CSpellingProblem extends SpellingProblem {
+       /** Spell event */
+       private ISpellEvent fSpellEvent;
+
+       /**
+        * The associated document.
+        */
+       private IDocument fDocument;
+
+       /**
+        * Initialize with the given spell event.
+        * 
+        * @param spellEvent the spell event
+        * @param document the document
+        */
+       public CSpellingProblem(ISpellEvent spellEvent, IDocument document) {
+               Assert.isLegal(document != null);
+               Assert.isLegal(spellEvent != null);
+               fSpellEvent= spellEvent;
+               fDocument= document;
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.spelling.SpellingProblem#getOffset()
+        */
+       @Override
+       public int getOffset() {
+               return fSpellEvent.getBegin();
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.spelling.SpellingProblem#getLength()
+        */
+       @Override
+       public int getLength() {
+               return fSpellEvent.getEnd() - fSpellEvent.getBegin() + 1;
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.spelling.SpellingProblem#getMessage()
+        */
+       @Override
+       public String getMessage() {
+               if (isSentenceStart() && isDictionaryMatch())
+                       return NLS.bind(Messages.Spelling_error_case_label, fSpellEvent.getWord());
+
+               return NLS.bind(Messages.Spelling_error_label, fSpellEvent.getWord());
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.spelling.SpellingProblem#getProposals()
+        */
+       @Override
+       public ICompletionProposal[] getProposals() {
+               String[] arguments= getArguments();
+               if (arguments == null)
+                       return new ICompletionProposal[0];
+               
+               final int threshold= SpellingPreferences.spellingProposalThreshold();
+               int size= 0;
+               List<RankedWordProposal> proposals= null;
+
+               RankedWordProposal proposal= null;
+               ICCompletionProposal[] result= null;
+               int index= 0;
+
+               boolean fixed= false;
+               boolean match= false;
+               boolean sentence= false;
+
+               final ISpellCheckEngine engine= SpellCheckEngine.getInstance();
+               final ISpellChecker checker= engine.getSpellChecker();
+
+               if (checker != null) {
+                       CorrectionContext context= new CorrectionContext(null, getOffset(), getLength());
+
+                       // Hack borrowed from JDT.
+                       fixed= arguments[0].charAt(0) == IHtmlTagConstants.HTML_TAG_PREFIX;
+
+                       if ((sentence && match) && !fixed) {
+                               result= new ICCompletionProposal[] { new ChangeCaseProposal(
+                                               arguments, getOffset(), getLength(), context,
+                                               engine.getLocale()) };
+                   } else {
+                               proposals= new ArrayList<RankedWordProposal>(checker.getProposals(arguments[0],
+                                               sentence));
+                               size= proposals.size();
+
+                               if (threshold > 0 && size > threshold) {
+                                       Collections.sort(proposals);
+                                       proposals= proposals.subList(size - threshold - 1, size - 1);
+                                       size= proposals.size();
+                               }
+
+                               boolean extendable= !fixed ? (checker.acceptsWords() || AddWordProposal.canAskToConfigure()) : false;
+                               result= new ICCompletionProposal[size + (extendable ? 3 : 2)];
+
+                               for (index= 0; index < size; index++) {
+                                       proposal= proposals.get(index);
+                                       result[index]= new WordCorrectionProposal(proposal
+                                                       .getText(), arguments, getOffset(), getLength(),
+                                                       context, proposal.getRank());
+                               }
+
+                               if (extendable)
+                                       result[index++]= new AddWordProposal(arguments[0], context);
+
+                               result[index++]= new WordIgnoreProposal(arguments[0], context);
+                               result[index++]= new DisableSpellCheckingProposal(context);
+                       }
+               }
+
+               return result;
+       }
+       
+       public String[] getArguments() {
+               String prefix= ""; //$NON-NLS-1$
+               String postfix= ""; //$NON-NLS-1$
+               String word;
+               try {
+                       word= fDocument.get(getOffset(), getLength());
+               } catch (BadLocationException e) {
+                       return null;
+               }
+
+               try {
+                       IRegion line= fDocument.getLineInformationOfOffset(getOffset());
+                       int end= getOffset() + getLength();
+                       prefix= fDocument.get(line.getOffset(), getOffset()
+                                       - line.getOffset());
+                       postfix= fDocument.get(end + 1, line.getOffset() + line.getLength()
+                                       - end);
+               } catch (BadLocationException exception) {
+                       // Do nothing
+               }
+
+               return new String[] {
+                               word,
+                               prefix,
+                               postfix,
+                               isSentenceStart() ? Boolean.toString(true) : Boolean
+                                               .toString(false),
+                               isDictionaryMatch() ? Boolean.toString(true) : Boolean
+                                               .toString(false) };
+       }
+
+       /**
+        * Returns <code>true</code> iff the corresponding word was found in the dictionary.
+        * <p>
+        * NOTE: to be removed, see {@link #getProposals()}
+        * </p>
+        *
+        * @return <code>true</code> iff the corresponding word was found in the dictionary
+        */
+       public boolean isDictionaryMatch() {
+               return fSpellEvent.isMatch();
+       }
+
+       /**
+        * Returns <code>true</code> iff the corresponding word starts a sentence.
+        * <p>
+        * NOTE: to be removed, see {@link #getProposals()}
+        * </p>
+        *
+        * @return <code>true</code> iff the corresponding word starts a sentence
+        */
+       public boolean isSentenceStart() {
+               return fSpellEvent.isStart();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingReconcileStrategy.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingReconcileStrategy.java
new file mode 100644 (file)
index 0000000..7b296f4
--- /dev/null
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *        Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector;
+import org.eclipse.ui.texteditor.spelling.SpellingProblem;
+import org.eclipse.ui.texteditor.spelling.SpellingReconcileStrategy;
+import org.eclipse.ui.texteditor.spelling.SpellingService;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.IProblemRequestor;
+import org.eclipse.cdt.core.parser.IProblem;
+
+/**
+ * Reconcile strategy for spell checking comments.
+ */
+public class CSpellingReconcileStrategy extends SpellingReconcileStrategy {
+       /**
+        * Spelling problem collector that forwards {@link SpellingProblem}s as
+        * {@link IProblem}s to the {@link IProblemRequestor}.
+        */
+       private class SpellingProblemCollector implements ISpellingProblemCollector {
+               /*
+                * @see org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector#accept(org.eclipse.ui.texteditor.spelling.SpellingProblem)
+                */
+               public void accept(SpellingProblem problem) {
+                       IProblemRequestor requestor= fRequestor;
+                       if (requestor != null) {
+                               try {
+                                       int line= getDocument().getLineOfOffset(problem.getOffset()) + 1;
+                                       String word= getDocument().get(problem.getOffset(), problem.getLength());
+                                       boolean dictionaryMatch= false;
+                                       boolean sentenceStart= false;
+                                       if (problem instanceof CSpellingProblem) {
+                                               dictionaryMatch= ((CSpellingProblem)problem).isDictionaryMatch();
+                                               sentenceStart= ((CSpellingProblem) problem).isSentenceStart();
+                                       }
+                                       // see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=81514
+                                       IEditorInput editorInput= fEditor.getEditorInput();
+                                       if (editorInput != null) {
+                                               CoreSpellingProblem iProblem= new CoreSpellingProblem(problem.getOffset(), problem.getOffset() + problem.getLength() - 1, line, problem.getMessage(), word, dictionaryMatch, sentenceStart, getDocument(), editorInput.getName());
+                                               requestor.acceptProblem(iProblem);
+                                       }
+                               } catch (BadLocationException x) {
+                                       // drop this SpellingProblem
+                               }
+                       }
+               }
+
+               /*
+                * @see org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector#beginCollecting()
+                */
+               public void beginCollecting() {
+                       if (fRequestor != null)
+                               fRequestor.beginReporting();
+               }
+
+               /*
+                * @see org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector#endCollecting()
+                */
+               public void endCollecting() {
+                       if (fRequestor != null)
+                               fRequestor.endReporting();
+               }
+       }
+
+       
+       /** The id of the problem */
+       public static final int SPELLING_PROBLEM_ID= 0x80000000;
+
+       /** Properties file content type */
+       private static final IContentType CXX_CONTENT_TYPE= Platform.getContentTypeManager().getContentType(CCorePlugin.CONTENT_TYPE_CXXSOURCE);
+
+       /** The text editor to operate on. */
+       private ITextEditor fEditor;
+
+       /** The problem requester. */
+       private IProblemRequestor fRequestor;
+       
+       /**
+        * Creates a new comment reconcile strategy.
+        *
+        * @param viewer the source viewer
+        * @param editor the text editor to operate on
+        */
+       public CSpellingReconcileStrategy(ISourceViewer viewer, ITextEditor editor) {
+               super(viewer, CSpellingService.getInstance());
+               fEditor= editor;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion)
+        */
+       @Override
+       public void reconcile(IRegion region) {
+               if (fRequestor != null && isSpellingEnabled())
+                       super.reconcile(region);
+       }
+       
+       private boolean isSpellingEnabled() {
+               return EditorsUI.getPreferenceStore().getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED);
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.spelling.SpellingReconcileStrategy#createSpellingProblemCollector()
+        */
+       @Override
+       protected ISpellingProblemCollector createSpellingProblemCollector() {
+               return new SpellingProblemCollector();
+       }
+       
+       /*
+        * @see org.eclipse.ui.texteditor.spelling.SpellingReconcileStrategy#getContentType()
+        */
+       @Override
+       protected IContentType getContentType() {
+               return CXX_CONTENT_TYPE;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument)
+        */
+       @Override
+       public void setDocument(IDocument document) {
+               super.setDocument(document);
+               updateProblemRequester();
+       }
+
+       /**
+        * Update the problem requester based on the current editor
+        */
+       private void updateProblemRequester() {
+               IAnnotationModel model= getAnnotationModel();
+               fRequestor= (model instanceof IProblemRequestor) ? (IProblemRequestor) model : null;
+       }
+       
+       /*
+        * @see org.eclipse.ui.texteditor.spelling.SpellingReconcileStrategy#getAnnotationModel()
+        */
+       @Override
+       protected IAnnotationModel getAnnotationModel() {
+               final IDocumentProvider documentProvider= fEditor.getDocumentProvider();
+               if (documentProvider == null)
+                       return null;
+               return documentProvider.getAnnotationModel(fEditor.getEditorInput());
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingService.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingService.java
new file mode 100644 (file)
index 0000000..fa6a001
--- /dev/null
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Google, Inc and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *        Sergey Prigogin (Google) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.spelling;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.ISafeRunnable;
+import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.texteditor.spelling.ISpellingEngine;
+import org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector;
+import org.eclipse.ui.texteditor.spelling.SpellingContext;
+import org.eclipse.ui.texteditor.spelling.SpellingService;
+
+/**
+ * Platform's SpellingService uses a spelling engine that is independent
+ * of the content type (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=185695).
+ * We are providing our own SpellingService to be able to use the C/C++ specific
+ * spelling engine even when it is not selected in
+ * Preferences/General/Editors/Text Editors/Spelling.
+ */
+public class CSpellingService extends SpellingService {
+       private static CSpellingService fInstance;
+       
+       private IPreferenceStore fPreferences;
+       private ISpellingEngine fEngine;
+       
+
+       public static CSpellingService getInstance() {
+               if (fInstance == null) {
+                       fInstance = new CSpellingService(EditorsUI.getPreferenceStore());
+               }
+               return fInstance;
+       }
+
+       @Override
+       public void check(final IDocument document, final IRegion[] regions, final SpellingContext context,
+                       final ISpellingProblemCollector collector, final IProgressMonitor monitor) {
+               try {
+                       collector.beginCollecting();
+                       if (fPreferences.getBoolean(PREFERENCE_SPELLING_ENABLED))
+                               if (fEngine == null) {
+                                       fEngine = new CSpellingEngine();
+                               }
+                               ISafeRunnable runnable= new ISafeRunnable() {
+                                       public void run() throws Exception {
+                                               fEngine.check(document, regions, context, collector, monitor);
+                                       }
+                                       public void handleException(Throwable x) {
+                                       }
+                               };
+                               SafeRunner.run(runnable);
+               } finally {
+                       collector.endCollecting();
+               }
+       }
+       
+       private CSpellingService(IPreferenceStore preferences) {
+               super(preferences);
+               fPreferences = preferences;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/ChangeCaseProposal.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/ChangeCaseProposal.java
new file mode 100644 (file)
index 0000000..17c9257
--- /dev/null
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *        Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling;
+
+import java.util.Locale;
+
+import org.eclipse.cdt.ui.text.IInvocationContext;
+
+/**
+ * Proposal to change the letter case of a word.
+ */
+public class ChangeCaseProposal extends WordCorrectionProposal {
+
+       /**
+        * Creates a new change case proposal.
+        *
+        * @param arguments The problem arguments associated with the spelling problem
+        * @param offset The offset in the document where to apply the proposal
+        * @param length The length in the document to apply the proposal
+        * @param context The invocation context for this proposal
+        * @param locale The locale to use for the case change
+        */
+       public ChangeCaseProposal(final String[] arguments, final int offset, final int length,
+                       final IInvocationContext context, final Locale locale) {
+               super(Character.isLowerCase(arguments[0].charAt(0)) ? Character.toUpperCase(arguments[0].charAt(0)) + arguments[0].substring(1) : arguments[0],
+                               arguments, offset, length, context, Integer.MAX_VALUE);
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
+        */
+       @Override
+       public String getDisplayString() {
+               return Messages.Spelling_case_label;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CoreSpellingProblem.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CoreSpellingProblem.java
new file mode 100644 (file)
index 0000000..1254f4a
--- /dev/null
@@ -0,0 +1,194 @@
+/*******************************************************************************
+ *  Copyright (c) 2005, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *        Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.spelling;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.osgi.util.NLS;
+
+import org.eclipse.cdt.core.parser.AbstractPersistableProblem;
+
+/**
+ * Spelling problem to be accepted by problem requesters.
+ */
+public class CoreSpellingProblem extends AbstractPersistableProblem {
+       // spelling 'marker type' name. Only virtual as spelling problems are never persisted in markers. 
+       // marker type is used in the quickFixProcessor extension point
+       public static final String MARKER_TYPE= "org.eclipse.cdt.internal.spelling"; //$NON-NLS-1$
+       
+       /** The end offset of the problem */
+       private int fSourceEnd= 0;
+
+       /** The line number of the problem */
+       private int fLineNumber= 1;
+
+       /** The start offset of the problem */
+       private int fSourceStart= 0;
+
+       /** The description of the problem */
+       private String fMessage;
+
+       /** The misspelled word */
+       private String fWord;
+
+       /** Was the word found in the dictionary? */
+       private boolean fMatch;
+
+       /** Does the word start a new sentence? */
+       private boolean fSentence;
+
+       /** The associated document */
+       private IDocument fDocument;
+
+       /** The originating file name */
+       private String fOrigin;
+
+       /**
+        * Initialize with the given parameters.
+        *
+        * @param start the start offset
+        * @param end the end offset
+        * @param line the line
+        * @param message the message
+        * @param word the word
+        * @param match <code>true</code> iff the word was found in the dictionary
+        * @param sentence <code>true</code> iff the word starts a sentence
+        * @param document the document
+        * @param origin the originating file name
+        */
+       public CoreSpellingProblem(int start, int end, int line, String message, String word, boolean match, boolean sentence, IDocument document, String origin) {
+               super();
+               fSourceStart= start;
+               fSourceEnd= end;
+               fLineNumber= line;
+               fMessage= message;
+               fWord= word;
+               fMatch= match;
+               fSentence= sentence;
+               fDocument= document;
+               fOrigin= origin;
+       }
+       /*
+        * @see org.eclipse.cdt.core.parser.IProblem#getArguments()
+        */
+       public String[] getArguments() {
+               String prefix= ""; //$NON-NLS-1$
+               String postfix= ""; //$NON-NLS-1$
+
+               try {
+                       IRegion line= fDocument.getLineInformationOfOffset(fSourceStart);
+
+                       prefix= fDocument.get(line.getOffset(), fSourceStart - line.getOffset());
+                       postfix= fDocument.get(fSourceEnd + 1, line.getOffset() + line.getLength() - fSourceEnd);
+               } catch (BadLocationException exception) {
+                       // Do nothing
+               }
+               return new String[] { fWord, prefix, postfix, fSentence ? Boolean.toString(true) : Boolean.toString(false), fMatch ? Boolean.toString(true) : Boolean.toString(false) };
+       }
+
+       /*
+        * @see org.eclipse.cdt.core.parser.IProblem#getID()
+        */
+       public int getID() {
+               return CSpellingReconcileStrategy.SPELLING_PROBLEM_ID;
+       }
+
+       /*
+        * @see org.eclipse.cdt.core.parser.IProblem#getMessage()
+        */
+       public String getMessage() {
+               return fMessage;
+       }
+
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.core.parser.IProblem#getMessageWithLocation()
+        */
+       public String getMessageWithLocation() {
+               return NLS.bind(Messages.Spelling_msgWithLocation, new Object[] {fMessage, fOrigin, fLineNumber});
+       }
+
+       /*
+        * @see org.eclipse.cdt.core.parser.IProblem#getOriginatingFileName()
+        */
+       public char[] getOriginatingFileName() {
+               return fOrigin.toCharArray();
+       }
+
+       /*
+        * @see org.eclipse.cdt.core.parser.IProblem#getSourceEnd()
+        */
+       public int getSourceEnd() {
+               return fSourceEnd;
+       }
+
+       /*
+        * @see org.eclipse.cdt.core.parser.IProblem#getSourceLineNumber()
+        */
+       public int getSourceLineNumber() {
+               return fLineNumber;
+       }
+
+       /*
+        * @see org.eclipse.cdt.core.parser.IProblem#getSourceStart()
+        */
+       public int getSourceStart() {
+               return fSourceStart;
+       }
+
+       /*
+        * @see org.eclipse.cdt.core.parser.IProblem#isError()
+        */
+       public boolean isError() {
+               return false;
+       }
+
+       /*
+        * @see org.eclipse.cdt.core.parser.IProblem#isWarning()
+        */
+       public boolean isWarning() {
+               return true;
+       }
+
+       /*
+        * @see org.eclipse.cdt.core.parser.IProblem#setSourceStart(int)
+        */
+       public void setSourceStart(int sourceStart) {
+               fSourceStart= sourceStart;
+       }
+
+       /*
+        * @see org.eclipse.cdt.core.parser.IProblem#setSourceEnd(int)
+        */
+       public void setSourceEnd(int sourceEnd) {
+               fSourceEnd= sourceEnd;
+       }
+
+       /*
+        * @see org.eclipse.cdt.core.parser.IProblem#setSourceLineNumber(int)
+        */
+       public void setSourceLineNumber(int lineNumber) {
+               fLineNumber= lineNumber;
+       }
+       
+       /*
+        * @see org.eclipse.cdt.core.parser.CategorizedProblem#getMarkerType()
+        */
+       public String getMarkerType() {
+               return MARKER_TYPE;
+       }
+       
+       public boolean checkCategory(int bitmask) {
+               return (getID() & bitmask) != 0;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/DisableSpellCheckingProposal.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/DisableSpellCheckingProposal.java
new file mode 100644 (file)
index 0000000..ca637f0
--- /dev/null
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *        Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.spelling;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.texteditor.spelling.SpellingService;
+
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.text.ICCompletionProposal;
+import org.eclipse.cdt.ui.text.IInvocationContext;
+
+
+/**
+ * Proposal to disable spell checking.
+ */
+public class DisableSpellCheckingProposal implements ICCompletionProposal {
+       private final String ID_DISABLE = "DISABLE"; //$NON-NLS-1$
+       
+       /** The invocation context */
+       private IInvocationContext fContext;
+
+       /**
+        * Creates a new proposal.
+        *
+        * @param context the invocation context
+        */
+       public DisableSpellCheckingProposal(IInvocationContext context) {
+               fContext= context;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument)
+        */
+       public final void apply(final IDocument document) {
+               IPreferenceStore store= EditorsUI.getPreferenceStore();
+               store.setValue(SpellingService.PREFERENCE_SPELLING_ENABLED, false);
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo()
+        */
+       public String getAdditionalProposalInfo() {
+               return Messages.Spelling_disable_info;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getContextInformation()
+        */
+       public final IContextInformation getContextInformation() {
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
+        */
+       public String getDisplayString() {
+               return Messages.Spelling_disable_label;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage()
+        */
+       public Image getImage() {
+               return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_NLS_NEVER_TRANSLATE);
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.java.IJavaCompletionProposal#getRelevance()
+        */
+       public final int getRelevance() {
+               return Integer.MIN_VALUE + 1;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getSelection(org.eclipse.jface.text.IDocument)
+        */
+       public final Point getSelection(final IDocument document) {
+               return new Point(fContext.getSelectionOffset(), fContext.getSelectionLength());
+       }
+       
+       public String getIdString() {
+               return ID_DISABLE;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/HtmlTagDictionary.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/HtmlTagDictionary.java
new file mode 100644 (file)
index 0000000..552e774
--- /dev/null
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling;
+
+import java.net.URL;
+
+import org.eclipse.cdt.internal.ui.text.IHtmlTagConstants;
+import org.eclipse.cdt.internal.ui.text.spelling.engine.AbstractSpellDictionary;
+
+/**
+ * Dictionary for html tags.
+ */
+public class HtmlTagDictionary extends AbstractSpellDictionary {
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.AbstractSpellDictionary#getName()
+        */
+       @Override
+       protected final URL getURL() {
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellDictionary#isCorrect(java.lang.String)
+        */
+       @Override
+       public boolean isCorrect(final String word) {
+               if (word.charAt(0) == IHtmlTagConstants.HTML_TAG_PREFIX)
+                       return super.isCorrect(word);
+
+               return false;
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.spelling.engine.AbstractSpellDictionary#load(java.net.URL)
+        */
+       @Override
+       protected synchronized boolean load(final URL url) {
+               unload();
+
+               for (int index= 0; index < IHtmlTagConstants.HTML_GENERAL_TAGS.length; index++) {
+                       hashWord(IHtmlTagConstants.HTML_TAG_PREFIX + IHtmlTagConstants.HTML_GENERAL_TAGS[index] + IHtmlTagConstants.HTML_TAG_POSTFIX);
+                       hashWord(IHtmlTagConstants.HTML_CLOSE_PREFIX + IHtmlTagConstants.HTML_GENERAL_TAGS[index] + IHtmlTagConstants.HTML_TAG_POSTFIX);
+               }
+               return true;
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.AbstractSpellDictionary#stripNonLetters(java.lang.String)
+        */
+       @Override
+       protected String stripNonLetters(String word) {
+               return word;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/Messages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/Messages.java
new file mode 100644 (file)
index 0000000..d380d96
--- /dev/null
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM - Initial API and implementation
+ *        Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+       private static final String BUNDLE_NAME = Messages.class.getName();
+
+       public static String AbstractSpellingDictionary_encodingError;
+       public static String Spelling_add_askToConfigure_ignoreMessage;
+       public static String Spelling_add_askToConfigure_question;
+       public static String Spelling_add_askToConfigure_title;
+       public static String Spelling_add_info;
+       public static String Spelling_add_label;
+       public static String Spelling_case_label;
+       public static String Spelling_correct_label;
+       public static String Spelling_disable_info;
+       public static String Spelling_disable_label;
+       public static String Spelling_error_case_label;
+       public static String Spelling_error_label;
+       public static String Spelling_ignore_info;
+       public static String Spelling_ignore_label;
+
+       public static String Spelling_msgWithLocation;
+
+       static {
+               // Initialize resource bundle
+               NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+       }
+
+       private Messages() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/Messages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/Messages.properties
new file mode 100644 (file)
index 0000000..0a6d20b
--- /dev/null
@@ -0,0 +1,27 @@
+###############################################################################
+# Copyright (c) 2000, 2008 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+#     Sergey Prigogin (Google)
+###############################################################################
+
+AbstractSpellingDictionary_encodingError=Could not read: ''{0}'', where the bad characters are replaced by ''{1}''. Check the encoding of the spelling dictionary ({2}).
+Spelling_add_askToConfigure_ignoreMessage=&Do not show 'Add word' proposals if user dictionary is missing
+Spelling_add_askToConfigure_question=A user dictionary is needed to add words.\nDo you want to configure it now?\n
+Spelling_add_askToConfigure_title=Missing User Dictionary
+Spelling_add_info=Adds the word ''{0}'' to the dictionary
+Spelling_add_label=Add ''{0}'' to dictionary
+Spelling_case_label=Change to upper case
+Spelling_correct_label=Change to ''{0}''
+Spelling_disable_info=Disables spell checking.
+Spelling_disable_label=Disable spell checking
+Spelling_error_case_label= The word ''{0}'' should have an initial upper case letter
+Spelling_error_label=The word ''{0}'' is not correctly spelled
+Spelling_ignore_info=Ignores ''{0}'' during the current session
+Spelling_ignore_label=Ignore ''{0}'' during the current session
+Spelling_msgWithLocation={0} in file: {1}:{2}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckEngine.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckEngine.java
new file mode 100644 (file)
index 0000000..05e3014
--- /dev/null
@@ -0,0 +1,418 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *        Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.text.spelling.engine.DefaultSpellChecker;
+import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellCheckEngine;
+import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellChecker;
+import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellDictionary;
+import org.eclipse.cdt.internal.ui.text.spelling.engine.LocaleSensitiveSpellDictionary;
+import org.eclipse.cdt.internal.ui.text.spelling.engine.PersistentSpellDictionary;
+
+/**
+ * Spell check engine for C/C++ source spell checking.
+ */
+public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListener {
+       /** The dictionary location */
+       public static final String DICTIONARY_LOCATION= "dictionaries/"; //$NON-NLS-1$
+
+       /** The singleton engine instance */
+       private static ISpellCheckEngine fgEngine= null;
+       
+       /**
+        * Caches the locales of installed dictionaries.
+        */
+       private static Set<Locale> fgLocalesWithInstalledDictionaries;
+
+       /**
+        * Returns the locales for which this
+        * spell check engine has dictionaries.
+        *
+        * @return The available locales for this engine
+        */
+       public static Set<Locale> getLocalesWithInstalledDictionaries() {
+               if (fgLocalesWithInstalledDictionaries != null)
+                       return fgLocalesWithInstalledDictionaries;
+               
+               URL location;
+               try {
+                       location= getDictionaryLocation();
+                       if (location == null)
+                               return fgLocalesWithInstalledDictionaries= Collections.emptySet();
+               } catch (MalformedURLException ex) {
+                       CUIPlugin.log(ex);
+                       return fgLocalesWithInstalledDictionaries= Collections.emptySet();
+               }
+               
+               String[] fileNames;
+               try {
+                       URL url= FileLocator.toFileURL(location);
+                       File file= new File(url.getFile());
+                       if (!file.isDirectory())
+                               return fgLocalesWithInstalledDictionaries= Collections.emptySet();
+                       fileNames= file.list();
+                       if (fileNames == null)
+                               return fgLocalesWithInstalledDictionaries= Collections.emptySet();
+               } catch (IOException ex) {
+                       CUIPlugin.log(ex);
+                       return fgLocalesWithInstalledDictionaries= Collections.emptySet();
+               }
+               
+               fgLocalesWithInstalledDictionaries= new HashSet<Locale>();
+               int fileNameCount= fileNames.length;
+               for (int i= 0; i < fileNameCount; i++) {
+                       String fileName= fileNames[i];
+                       int localeEnd= fileName.indexOf(".dictionary"); //$NON-NLS-1$ 
+                       if (localeEnd > 1) {
+                               String localeName= fileName.substring(0, localeEnd);
+                               int languageEnd=localeName.indexOf('_');
+                               if (languageEnd == -1) {
+                                       fgLocalesWithInstalledDictionaries.add(new Locale(localeName));
+                               } else if (languageEnd == 2 && localeName.length() == 5) {
+                                       fgLocalesWithInstalledDictionaries.add(new Locale(localeName.substring(0, 2), localeName.substring(3)));
+                               } else if (localeName.length() > 6 && localeName.charAt(5) == '_') {
+                                       fgLocalesWithInstalledDictionaries.add(new Locale(localeName.substring(0, 2), localeName.substring(3, 5), localeName.substring(6)));
+                               }
+                       }
+               }
+
+               return fgLocalesWithInstalledDictionaries;
+       }
+
+       /**
+        * Returns the default locale for this engine.
+        *
+        * @return The default locale
+        */
+       public static Locale getDefaultLocale() {
+               return Locale.getDefault();
+       }
+       
+       /**
+        * Returns the dictionary closest to the given locale.
+        *
+        * @param locale the locale
+        * @return the dictionary or <code>null</code> if none is suitable
+        */
+       public ISpellDictionary findDictionary(Locale locale) {
+               ISpellDictionary dictionary= fLocaleDictionaries.get(locale);
+               if (dictionary != null)
+                       return dictionary;
+               
+               // Try same language
+               String language= locale.getLanguage();
+               for (Entry<Locale, ISpellDictionary> entry : fLocaleDictionaries.entrySet()) {
+                       Locale dictLocale= entry.getKey();
+                       if (dictLocale.getLanguage().equals(language))
+                               return entry.getValue();
+               }
+               
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellCheckEngine#findDictionary(java.util.Locale)
+        */
+       public static Locale findClosestLocale(Locale locale) {
+               if (locale == null || locale.toString().length() == 0)
+                       return locale;
+               
+               if (getLocalesWithInstalledDictionaries().contains(locale))
+                       return locale;
+
+               // Try same language
+               String language= locale.getLanguage();
+               for (Locale dictLocale : getLocalesWithInstalledDictionaries()) {
+                       if (dictLocale.getLanguage().equals(language))
+                               return dictLocale;
+               }
+               
+               // Try whether American English is present
+               Locale defaultLocale= Locale.US;
+               if (getLocalesWithInstalledDictionaries().contains(defaultLocale))
+                       return defaultLocale;
+               
+               return null;
+       }
+
+       /**
+        * Returns the URL for the dictionary location where
+        * the Platform dictionaries are located.
+        * <p>
+        * This is in <code>org.eclipse.cdt.ui/dictionaries/</code>
+        * which can also be populated via fragments.
+        * </p>
+        *
+        * @throws MalformedURLException if the URL could not be created
+        * @return The dictionary location, or <code>null</code> iff the location is not known
+        */
+       public static URL getDictionaryLocation() throws MalformedURLException {
+               // Unfortunately, dictionaries used by JDT are not accessible,
+               // so we have to provide our own copies of the same files.
+               final CUIPlugin plugin= CUIPlugin.getDefault();
+               if (plugin != null)
+                       return plugin.getBundle().getEntry("/" + DICTIONARY_LOCATION); //$NON-NLS-1$
+
+               return null;
+       }
+
+       /**
+        * Returns the singleton instance of the spell check engine.
+        *
+        * @return The singleton instance of the spell check engine
+        */
+       public static final synchronized ISpellCheckEngine getInstance() {
+               if (fgEngine == null)
+                       fgEngine= new SpellCheckEngine();
+
+               return fgEngine;
+       }
+       
+       /**
+        * Shuts down the singleton instance of the spell check engine.
+        */
+       public static final synchronized void shutdownInstance() {
+               if (fgEngine != null) {
+                       fgEngine.shutdown();
+                       fgEngine= null;
+               }
+       }
+
+       /** The registered locale insensitive dictionaries */
+       private Set<ISpellDictionary> fGlobalDictionaries= new HashSet<ISpellDictionary>();
+
+       /** The spell checker for fLocale */
+       private ISpellChecker fChecker= null;
+
+       /** The registered locale sensitive dictionaries */
+       private Map<Locale, ISpellDictionary> fLocaleDictionaries= new HashMap<Locale, ISpellDictionary>();
+
+       /** The user dictionary */
+       private ISpellDictionary fUserDictionary= null;
+
+       /**
+        * Creates a new spell check manager.
+        */
+       private SpellCheckEngine() {
+               fGlobalDictionaries.add(new TaskTagDictionary());
+               fGlobalDictionaries.add(new HtmlTagDictionary());
+
+               try {
+                       final URL location= getDictionaryLocation();
+
+                       for (Locale locale : getLocalesWithInstalledDictionaries()) {
+                               fLocaleDictionaries.put(locale, new LocaleSensitiveSpellDictionary(locale, location));
+                       }
+               } catch (MalformedURLException exception) {
+                       // Do nothing
+               }
+               
+               SpellingPreferences.addPropertyChangeListener(this);
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellCheckEngine#getSpellChecker()
+        */
+       public final synchronized ISpellChecker getSpellChecker() throws IllegalStateException {
+               if (fGlobalDictionaries == null)
+                       throw new IllegalStateException("spell checker has been shut down"); //$NON-NLS-1$
+               
+               IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+               Locale locale= getCurrentLocale(store);
+               if (fUserDictionary == null && "".equals(locale.toString())) //$NON-NLS-1$
+                       return null;
+               
+               if (fChecker != null && fChecker.getLocale().equals(locale))
+                       return fChecker;
+               
+               resetSpellChecker();
+               
+               fChecker= new DefaultSpellChecker(store, locale);
+               resetUserDictionary();
+               
+               for (ISpellDictionary dictionary : fGlobalDictionaries) {
+                       fChecker.addDictionary(dictionary);
+               }
+
+               ISpellDictionary dictionary= findDictionary(fChecker.getLocale());
+               if (dictionary != null)
+                       fChecker.addDictionary(dictionary);
+
+               return fChecker;
+       }
+
+       /**
+        * Returns the current locale of the spelling preferences.
+        *
+        * @param store the preference store
+        * @return The current locale of the spelling preferences
+        */
+       private Locale getCurrentLocale(IPreferenceStore store) {
+               return convertToLocale(SpellingPreferences.getSpellingLocale());
+       }
+       
+       public static Locale convertToLocale(String locale) {
+               Locale defaultLocale= SpellCheckEngine.getDefaultLocale();
+               if (locale.equals(defaultLocale.toString()))
+                       return defaultLocale;
+               
+               if (locale.length() >= 5)
+                       return new Locale(locale.substring(0, 2), locale.substring(3, 5));
+               
+               return new Locale(""); //$NON-NLS-1$
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.spelling.engine.ISpellCheckEngine#getLocale()
+        */
+       public synchronized final Locale getLocale() {
+               if (fChecker == null)
+                       return null;
+               
+               return fChecker.getLocale();
+       }
+
+       /*
+        * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+        */
+       public final void propertyChange(final PropertyChangeEvent event) {
+               if (event.getProperty().equals(SpellingPreferences.SPELLING_LOCALE)) {
+                       resetSpellChecker();
+                       return;
+               }
+               
+               if (event.getProperty().equals(SpellingPreferences.SPELLING_USER_DICTIONARY)) {
+                       resetUserDictionary();
+                       return;
+               }
+               
+               if (event.getProperty().equals(SpellingPreferences.SPELLING_USER_DICTIONARY_ENCODING)) {
+                       resetUserDictionary();
+                       return;
+               }
+       }
+
+       /**
+        * Resets the current checker's user dictionary.
+        */
+       private synchronized void resetUserDictionary() {
+               if (fChecker == null)
+                       return;
+               
+               // Update user dictionary
+               if (fUserDictionary != null) {
+                       fChecker.removeDictionary(fUserDictionary);
+                       fUserDictionary.unload();
+                       fUserDictionary= null;
+               }
+
+               final String filePath= SpellingPreferences.getSpellingUserDictionary();
+               if (filePath.length() > 0) {
+                       try {
+                               File file= new File(filePath);
+                               if (!file.exists() && !file.createNewFile())
+                                       return;
+                               
+                               final URL url= new URL("file", null, filePath); //$NON-NLS-1$
+                               InputStream stream= url.openStream();
+                               if (stream != null) {
+                                       try {
+                                               fUserDictionary= new PersistentSpellDictionary(url);
+                                               fChecker.addDictionary(fUserDictionary);
+                                       } finally {
+                                               stream.close();
+                                       }
+                               }
+                       } catch (MalformedURLException exception) {
+                               // Do nothing
+                       } catch (IOException exception) {
+                               // Do nothing
+                       }
+               }
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellCheckEngine#registerDictionary(org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellDictionary)
+        */
+       public synchronized final void registerGlobalDictionary(final ISpellDictionary dictionary) {
+               fGlobalDictionaries.add(dictionary);
+               resetSpellChecker();
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellCheckEngine#registerDictionary(java.util.Locale, org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellDictionary)
+        */
+       public synchronized final void registerDictionary(final Locale locale, final ISpellDictionary dictionary) {
+               fLocaleDictionaries.put(locale, dictionary);
+               resetSpellChecker();
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellCheckEngine#unload()
+        */
+       public synchronized final void shutdown() {
+               SpellingPreferences.removePropertyChangeListener(this);
+
+               for (ISpellDictionary dictionary : fGlobalDictionaries) {
+                       dictionary.unload();
+               }
+               fGlobalDictionaries= null;
+
+               for (ISpellDictionary dictionary : fLocaleDictionaries.values()) {
+                       dictionary.unload();
+               }
+               fLocaleDictionaries= null;
+
+               fUserDictionary= null;
+               fChecker= null;
+       }
+       
+       private synchronized void resetSpellChecker() {
+               if (fChecker != null) {
+                       ISpellDictionary dictionary= fLocaleDictionaries.get(fChecker.getLocale());
+                       if (dictionary != null)
+                               dictionary.unload();
+               }
+               fChecker= null;
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.spelling.engine.ISpellCheckEngine#unregisterDictionary(org.eclipse.cdt.ui.text.spelling.engine.ISpellDictionary)
+        */
+       public synchronized final void unregisterDictionary(final ISpellDictionary dictionary) {
+               fGlobalDictionaries.remove(dictionary);
+               fLocaleDictionaries.values().remove(dictionary);
+               dictionary.unload();
+               resetSpellChecker();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckIterator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckIterator.java
new file mode 100644 (file)
index 0000000..b1b41b8
--- /dev/null
@@ -0,0 +1,364 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.spelling;
+
+import java.util.LinkedList;
+import java.util.Locale;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+
+import com.ibm.icu.text.BreakIterator;
+
+import org.eclipse.cdt.internal.ui.text.IHtmlTagConstants;
+import org.eclipse.cdt.internal.ui.text.spelling.engine.DefaultSpellChecker;
+import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellCheckIterator;
+
+/**
+ * Iterator to spell check multiline comment regions.
+ */
+public class SpellCheckIterator implements ISpellCheckIterator {
+       /** The content of the region */
+       protected final String fContent;
+
+       /** The last token */
+       protected String fLastToken= null;
+
+       /** The next break */
+       protected int fNext= 1;
+
+       /** The offset of the region */
+       protected final int fOffset;
+
+       /** The predecessor break */
+       private int fPredecessor;
+
+       /** The previous break */
+       protected int fPrevious= 0;
+
+       /** The sentence breaks */
+       private final LinkedList<Integer> fSentenceBreaks= new LinkedList<Integer>();
+
+       /** Does the current word start a sentence? */
+       private boolean fStartsSentence= false;
+
+       /** The successor break */
+       protected int fSuccessor;
+
+       /** The word iterator */
+       private final BreakIterator fWordIterator;
+
+       private boolean fIsIgnoringSingleLetters;
+
+       /**
+        * Creates a new spell check iterator.
+        *
+        * @param document the document containing the specified partition
+        * @param region the region to spell check
+        * @param locale the locale to use for spell checking
+        */
+       public SpellCheckIterator(IDocument document, IRegion region, Locale locale) {
+               this(document, region, locale, BreakIterator.getWordInstance(locale));
+       }
+
+       /**
+        * Creates a new spell check iterator.
+        *
+        * @param document the document containing the specified partition
+        * @param region the region to spell check
+        * @param locale the locale to use for spell checking
+        * @param breakIterator the break-iterator
+        */
+       public SpellCheckIterator(IDocument document, IRegion region, Locale locale, BreakIterator breakIterator) {
+               fOffset= region.getOffset();
+               fWordIterator= breakIterator;
+
+               String content;
+               try {
+                       content= document.get(region.getOffset(), region.getLength());
+               } catch (Exception exception) {
+                       content= ""; //$NON-NLS-1$
+               }
+               fContent= content;
+
+               fWordIterator.setText(content);
+               fPredecessor= fWordIterator.first();
+               fSuccessor= fWordIterator.next();
+
+               final BreakIterator iterator= BreakIterator.getSentenceInstance(locale);
+               iterator.setText(content);
+
+               int offset= iterator.current();
+               while (offset != BreakIterator.DONE) {
+                       fSentenceBreaks.add(new Integer(offset));
+                       offset= iterator.next();
+               }
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellCheckIterator#setIgnoreSingleLetters(boolean)
+        */
+       public void setIgnoreSingleLetters(boolean state) {
+               fIsIgnoringSingleLetters= state;
+       }
+
+       /*
+        * @see org.eclipse.spelling.done.ISpellCheckIterator#getBegin()
+        */
+       public final int getBegin() {
+               return fPrevious + fOffset;
+       }
+
+       /*
+        * @see org.eclipse.spelling.done.ISpellCheckIterator#getEnd()
+        */
+       public final int getEnd() {
+               return fNext + fOffset - 1;
+       }
+
+       /*
+        * @see java.util.Iterator#hasNext()
+        */
+       public final boolean hasNext() {
+               return fSuccessor != BreakIterator.DONE;
+       }
+
+       /**
+        * Does the specified token consist of at least one letter and digits
+        * only?
+        *
+        * @param begin the begin index
+        * @param end the end index
+        * @return <code>true</code> iff the token consists of digits and at
+        *         least one letter only, <code>false</code> otherwise
+        */
+       protected final boolean isAlphaNumeric(final int begin, final int end) {
+               char character= 0;
+               boolean letter= false;
+               for (int index= begin; index < end; index++) {
+                       character= fContent.charAt(index);
+                       if (Character.isLetter(character))
+                               letter= true;
+
+                       if (!Character.isLetterOrDigit(character))
+                               return false;
+               }
+               return letter;
+       }
+
+       /**
+        * Checks the last token against the given tags?
+        *
+        * @param tags the tags to check
+        * @return <code>true</code> iff the last token is in the given array
+        */
+       protected final boolean isToken(final String[] tags) {
+               return isToken(fLastToken, tags);
+       }
+       
+       /**
+        * Checks the given  token against the given tags?
+        *
+        * @param token the token to check
+        * @param tags the tags to check
+        * @return <code>true</code> iff the last token is in the given array
+        */
+       protected final boolean isToken(final String token, final String[] tags) {
+               if (token != null) {
+                       for (String tag : tags) {
+                               if (token.equals(tag))
+                                       return true;
+                       }
+               }
+               return false;
+       }
+
+       /**
+        * Is the current token a single letter token surrounded by
+        * non-whitespace characters?
+        *
+        * @param begin the begin index
+        * @return <code>true</code> iff the token is a single letter token,
+        *         <code>false</code> otherwise
+        */
+       protected final boolean isSingleLetter(final int begin) {
+               if (!Character.isLetter(fContent.charAt(begin)))
+                       return false;
+
+               if (begin > 0 && !Character.isWhitespace(fContent.charAt(begin - 1)))
+                       return false;
+
+               if (begin < fContent.length() - 1 && !Character.isWhitespace(fContent.charAt(begin + 1)))
+                       return false;
+               
+               return true;
+       }
+
+       /**
+        * Does the specified token look like an URL?
+        *
+        * @param begin the begin index
+        * @return <code>true</code> iff this token look like an URL,
+        *         <code>false</code> otherwise
+        */
+       protected final boolean isUrlToken(final int begin) {
+               for (String element : DefaultSpellChecker.URL_PREFIXES) {
+                       if (fContent.startsWith(element, begin))
+                               return true;
+               }
+               return false;
+       }
+
+       /**
+        * Does the specified token consist of whitespace only?
+        *
+        * @param begin the begin index
+        * @param end the end index
+        * @return <code>true</code> iff the token consists of whitespace
+        *         only, <code>false</code> otherwise
+        */
+       protected final boolean isWhitespace(final int begin, final int end) {
+               for (int index= begin; index < end; index++) {
+                       if (!Character.isWhitespace(fContent.charAt(index)))
+                               return false;
+               }
+               return true;
+       }
+
+       /*
+        * @see java.util.Iterator#next()
+        */
+       public String next() {
+               String token= nextToken();
+               while (token == null && fSuccessor != BreakIterator.DONE)
+                       token= nextToken();
+
+               fLastToken= token;
+               return token;
+       }
+
+       /**
+        * Advances the end index to the next word break.
+        */
+       protected final void nextBreak() {
+               fNext= fSuccessor;
+               fPredecessor= fSuccessor;
+               fSuccessor= fWordIterator.next();
+       }
+
+       /**
+        * Returns the next sentence break.
+        *
+        * @return the next sentence break
+        */
+       protected final int nextSentence() {
+               return fSentenceBreaks.getFirst().intValue();
+       }
+
+       /**
+        * Determines the next token to be spell checked.
+        *
+        * @return the next token to be spell checked, or <code>null</code>
+        *         iff the next token is not a candidate for spell checking.
+        */
+       protected String nextToken() {
+               String token= null;
+               fPrevious= fPredecessor;
+               fStartsSentence= false;
+               nextBreak();
+
+               boolean update= false;
+               if (fNext - fPrevious > 0) {
+                       if (fSuccessor != BreakIterator.DONE && fContent.charAt(fPrevious) == IHtmlTagConstants.HTML_TAG_PREFIX && (Character.isLetter(fContent.charAt(fNext)) || fContent.charAt(fNext) == '/')) {
+                               if (fContent.startsWith(IHtmlTagConstants.HTML_CLOSE_PREFIX, fPrevious))
+                                       nextBreak();
+
+                               nextBreak();
+
+                               if (fSuccessor != BreakIterator.DONE && fContent.charAt(fNext) == IHtmlTagConstants.HTML_TAG_POSTFIX) {
+                                       nextBreak();
+                                       if (fSuccessor != BreakIterator.DONE) {
+                                               update= true;
+                                               token= fContent.substring(fPrevious, fNext);
+                                       }
+                               }
+                       } else if (fSuccessor != BreakIterator.DONE && fContent.charAt(fPrevious) == IHtmlTagConstants.HTML_ENTITY_START && (Character.isLetter(fContent.charAt(fNext)))) {
+                               nextBreak();
+                               if (fSuccessor != BreakIterator.DONE && fContent.charAt(fNext) == IHtmlTagConstants.HTML_ENTITY_END) {
+                                       nextBreak();
+                                       if (isToken(fContent.substring(fPrevious, fNext), IHtmlTagConstants.HTML_ENTITY_CODES)) {
+                                               skipTokens(fPrevious, IHtmlTagConstants.HTML_ENTITY_END);
+                                               update= true;
+                                       } else {
+                                               token= fContent.substring(fPrevious, fNext);
+                                       }
+                               } else {
+                                       token= fContent.substring(fPrevious, fNext);
+                               }
+                               
+                               update= true;
+                       } else if (!isWhitespace(fPrevious, fNext) && isAlphaNumeric(fPrevious, fNext)) {
+                               if (isUrlToken(fPrevious)) {
+                                       skipTokens(fPrevious, ' ');
+                               } else if (fNext - fPrevious > 1 || isSingleLetter(fPrevious) && !fIsIgnoringSingleLetters) {
+                                       token= fContent.substring(fPrevious, fNext);
+                               }
+                               update= true;
+                       }
+               }
+
+               if (update && fSentenceBreaks.size() > 0) {
+                       if (fPrevious >= nextSentence()) {
+                               while (fSentenceBreaks.size() > 0 && fPrevious >= nextSentence())
+                                       fSentenceBreaks.removeFirst();
+
+                               fStartsSentence= (fLastToken == null) || (token != null);
+                       }
+               }
+               return token;
+       }
+
+       /*
+        * @see java.util.Iterator#remove()
+        */
+       public final void remove() {
+               throw new UnsupportedOperationException();
+       }
+
+       /**
+        * Skip the tokens until the stop character is reached.
+        *
+        * @param begin the begin index
+        * @param stop the stop character
+        */
+       protected final void skipTokens(final int begin, final char stop) {
+               int end= begin;
+
+               while (end < fContent.length() && fContent.charAt(end) != stop)
+                       end++;
+
+               if (end < fContent.length()) {
+                       fNext= end;
+                       fPredecessor= fNext;
+                       fSuccessor= fWordIterator.following(fNext);
+               } else {
+                       fSuccessor= BreakIterator.DONE;
+               }
+       }
+
+       /*
+        * @see org.eclipse.spelling.done.ISpellCheckIterator#startsSentence()
+        */
+       public final boolean startsSentence() {
+               return fStartsSentence;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingEngine.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingEngine.java
new file mode 100644 (file)
index 0000000..66d7420
--- /dev/null
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *        Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.ui.texteditor.spelling.ISpellingEngine;
+import org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector;
+import org.eclipse.ui.texteditor.spelling.SpellingContext;
+
+import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellCheckEngine;
+import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellChecker;
+import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellEvent;
+import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellEventListener;
+
+/**
+ * Internal abstract spelling engine, subclasses provide a content-type specific implementation.
+ */
+public abstract class SpellingEngine implements ISpellingEngine {
+       /**
+        * {@link ISpellEvent}listener that forwards events as
+        * {@link org.eclipse.ui.texteditor.spelling.SpellingProblem}.
+        */
+       protected static class SpellEventListener implements ISpellEventListener {
+               /** Spelling problem collector */
+               private ISpellingProblemCollector fCollector;
+               
+               /**
+                * The document.
+                */
+               private IDocument fDocument;
+
+               /**
+                * Initialize with the given spelling problem collector.
+                *
+                * @param collector the spelling problem collector
+                * @param document the document
+                */
+               public SpellEventListener(ISpellingProblemCollector collector, IDocument document) {
+                       fCollector= collector;
+                       fDocument= document;
+               }
+
+               /*
+                * @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellEventListener#handle(org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellEvent)
+                */
+               public void handle(ISpellEvent event) {
+                       fCollector.accept(new CSpellingProblem(event, fDocument));
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.spelling.ISpellingEngine#check(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IRegion[], org.eclipse.ui.texteditor.spelling.SpellingContext, org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector, org.eclipse.core.runtime.IProgressMonitor)
+        */
+       public void check(IDocument document, IRegion[] regions, SpellingContext context, ISpellingProblemCollector collector, IProgressMonitor monitor) {
+               if (collector != null) {
+                       final ISpellCheckEngine spellingEngine= SpellCheckEngine.getInstance();
+                       ISpellChecker checker= spellingEngine.getSpellChecker();
+                       if (checker != null)
+                               check(document, regions, checker, collector, monitor);
+               }
+       }
+
+       /**
+        * Spell checks the given document regions with the given arguments.
+        *
+        * @param document the document
+        * @param regions the regions
+        * @param checker the spell checker
+        * @param collector the spelling problem collector
+        * @param monitor the progress monitor, can be <code>null</code>
+        */
+       protected abstract void check(IDocument document, IRegion[] regions, ISpellChecker checker, ISpellingProblemCollector collector, IProgressMonitor monitor);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingEngineDispatcher.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingEngineDispatcher.java
new file mode 100644 (file)
index 0000000..bc9111b
--- /dev/null
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *        Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.texteditor.spelling.ISpellingEngine;
+import org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector;
+import org.eclipse.ui.texteditor.spelling.SpellingContext;
+import org.eclipse.ui.texteditor.spelling.SpellingEngineDescriptor;
+
+import org.eclipse.cdt.core.CCorePlugin;
+
+/**
+ * A dispatcher that decides what spelling engine to use depending on content type.
+ * When C/C++ spelling engine is selected in Preferences/General/Editors/Text Editors/Spelling
+ * this class is called to perform spelling check for all text-based content types.
+ * If the content type does not match one of C/C++ content types, the spelling check
+ * is delegated to the default spelling engine, most likely the one provided by JDT.
+ */
+public class SpellingEngineDispatcher implements ISpellingEngine {
+       private static final String C_SPELLING_ENGINE_ID = "org.eclipse.cdt.internal.ui.text.spelling.CSpellingEngine"; //$NON-NLS-1$
+
+       /** C/C++ source content type */
+       private static final IContentType CHEADER_CONTENT_TYPE= Platform.getContentTypeManager().getContentType(CCorePlugin.CONTENT_TYPE_CHEADER);
+       private static final IContentType CSOURCE_CONTENT_TYPE= Platform.getContentTypeManager().getContentType(CCorePlugin.CONTENT_TYPE_CSOURCE);
+       private static final IContentType CXXHEADER_CONTENT_TYPE= Platform.getContentTypeManager().getContentType(CCorePlugin.CONTENT_TYPE_CXXHEADER);
+       private static final IContentType CXXSOURCE_CONTENT_TYPE= Platform.getContentTypeManager().getContentType(CCorePlugin.CONTENT_TYPE_CXXSOURCE);
+
+       /** Available spelling engines by content type */
+       private Map<IContentType, SpellingEngine> fEngines= new HashMap<IContentType, SpellingEngine>();
+       private ISpellingEngine defaultEngine;
+
+       /**
+        * Initialize concrete engines.
+        */
+       public SpellingEngineDispatcher() {
+               SpellingEngine engine = new CSpellingEngine();
+               if (CHEADER_CONTENT_TYPE != null)
+                       fEngines.put(CHEADER_CONTENT_TYPE, engine);
+               if (CSOURCE_CONTENT_TYPE != null)
+                       fEngines.put(CSOURCE_CONTENT_TYPE, engine);
+               if (CXXHEADER_CONTENT_TYPE != null)
+                       fEngines.put(CXXHEADER_CONTENT_TYPE, engine);
+               if (CXXSOURCE_CONTENT_TYPE != null)
+                       fEngines.put(CXXSOURCE_CONTENT_TYPE, engine);
+               try {
+                       SpellingEngineDescriptor descriptor =
+                                       EditorsUI.getSpellingService().getDefaultSpellingEngineDescriptor();
+                       if (!C_SPELLING_ENGINE_ID.equals(descriptor.getId())) {  // Do not delegate to itself.
+                               defaultEngine = descriptor.createEngine();
+                       }
+               } catch (CoreException e) {
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.texteditor.spelling.ISpellingEngine#check(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IRegion[], org.eclipse.ui.texteditor.spelling.SpellingContext, org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector, org.eclipse.core.runtime.IProgressMonitor)
+        */
+       public void check(IDocument document, IRegion[] regions, SpellingContext context, ISpellingProblemCollector collector, IProgressMonitor monitor) {
+               ISpellingEngine engine= getEngine(context.getContentType());
+               if (engine == null)
+                       engine= defaultEngine;
+               if (engine != null)
+                       engine.check(document, regions, context, collector, monitor);
+       }
+
+       /**
+        * Returns a spelling engine for the given content type or
+        * <code>null</code> if none could be found.
+        *
+        * @param contentType the content type
+        * @return a spelling engine for the given content type or
+        *         <code>null</code> if none could be found
+        */
+       private ISpellingEngine getEngine(IContentType contentType) {
+               if (contentType == null)
+                       return null;
+
+               if (fEngines.containsKey(contentType))
+                       return fEngines.get(contentType);
+
+               return getEngine(contentType.getBaseType());
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingPreferences.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingPreferences.java
new file mode 100644 (file)
index 0000000..d238848
--- /dev/null
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Google, Inc and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *        Sergey Prigogin (Google) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.spelling;
+
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+
+/**
+ * This class encapsulates spelling preferences.
+ * If the source of spelling preferences were to move from CDT to the platform,
+ * this class would make refactoring easier.
+ */
+public class SpellingPreferences {
+       private static IPreferenceStore preferenceStore = PreferenceConstants.getPreferenceStore();
+       static final String SPELLING_LOCALE = PreferenceConstants.SPELLING_LOCALE;
+       static final String SPELLING_USER_DICTIONARY = PreferenceConstants.SPELLING_USER_DICTIONARY;
+       static final String SPELLING_USER_DICTIONARY_ENCODING = PreferenceConstants.SPELLING_USER_DICTIONARY_ENCODING;
+       private static final String SPELLING_PROPOSAL_THRESHOLD = PreferenceConstants.SPELLING_PROPOSAL_THRESHOLD;
+       private static final String SPELLING_ENABLE_CONTENTASSIST = PreferenceConstants.SPELLING_ENABLE_CONTENTASSIST;
+       private static final String SPELLING_IGNORE_DIGITS = PreferenceConstants.SPELLING_IGNORE_DIGITS;
+       private static final String SPELLING_IGNORE_MIXED = PreferenceConstants.SPELLING_IGNORE_MIXED;
+       private static final String SPELLING_IGNORE_NON_LETTERS = PreferenceConstants.SPELLING_IGNORE_NON_LETTERS;
+       private static final String SPELLING_IGNORE_SENTENCE = PreferenceConstants.SPELLING_IGNORE_SENTENCE;
+       private static final String SPELLING_IGNORE_SINGLE_LETTERS = PreferenceConstants.SPELLING_IGNORE_SINGLE_LETTERS;
+       private static final String SPELLING_IGNORE_STRING_LITERALS = PreferenceConstants.SPELLING_IGNORE_STRING_LITERALS;
+       private static final String SPELLING_IGNORE_UPPER = PreferenceConstants.SPELLING_IGNORE_UPPER;
+       private static final String SPELLING_IGNORE_URLS = PreferenceConstants.SPELLING_IGNORE_URLS;
+       
+       /**
+        * @see IPreferenceStore#addPropertyChangeListener(IPropertyChangeListener)
+        */
+    public static void addPropertyChangeListener(IPropertyChangeListener listener) {
+               preferenceStore.addPropertyChangeListener(listener); 
+    }
+       
+       /**
+        * @see IPreferenceStore#removePropertyChangeListener(IPropertyChangeListener)
+        */
+    public static void removePropertyChangeListener(IPropertyChangeListener listener) {
+               preferenceStore.removePropertyChangeListener(listener); 
+    }
+
+       /**
+        * The locale used for spell checking.
+        */
+       public static String getSpellingLocale() {
+               return preferenceStore.getString(SPELLING_LOCALE);
+       }
+       
+       /**
+        * The workspace user dictionary.
+        */
+       public static String getSpellingUserDictionary() {
+               return preferenceStore.getString(SPELLING_USER_DICTIONARY);
+       }
+       
+       /**
+        * The encoding of the workspace user dictionary.
+        */
+       public static String getSpellingUserDictionaryEncoding() {
+               return preferenceStore.getString(SPELLING_USER_DICTIONARY_ENCODING);
+       }
+       
+       /**
+        * Returns the number of proposals offered during spell checking.
+        */
+       public static int spellingProposalThreshold() {
+               return preferenceStore.getInt(SPELLING_PROPOSAL_THRESHOLD);
+       }
+
+       /**
+        * Returns <code>true</code> if spelling content assist is enabled.
+        */
+       public static boolean isEnabledSpellingContentAssist() {
+               return preferenceStore.getBoolean(SPELLING_ENABLE_CONTENTASSIST);
+       }
+       
+       /**
+        * Returns <code>true</code> if words containing digits should
+        * be skipped during spell checking.
+        */
+       public static boolean isIgnoreDigits() {
+               return preferenceStore.getBoolean(SPELLING_IGNORE_DIGITS);
+       }
+
+       /**
+        * Returns <code>true</code> if mixed case words should be
+        * skipped during spell checking.
+        */
+       public static boolean isIgnoreMixed() {
+               return preferenceStore.getBoolean(SPELLING_IGNORE_MIXED);
+       }
+       
+       /**
+        * Returns <code>true</code> if non-letters at word boundaries
+        * should be ignored during spell checking.
+        */
+       public static boolean isIgnoreNonLetters() {
+               return preferenceStore.getBoolean(SPELLING_IGNORE_NON_LETTERS);
+       }
+       
+       /**
+        * Returns <code>true</code> if sentence capitalization should
+        * be ignored during spell checking.
+        */
+       public static boolean isIgnoreSentence() {
+               return preferenceStore.getBoolean(SPELLING_IGNORE_SENTENCE);
+       }
+       
+       /**
+        * Returns <code>true</code> if single letters
+        * should be ignored during spell checking.
+        */
+       public static boolean isIgnoreSingleLetters() {
+               return preferenceStore.getBoolean(SPELLING_IGNORE_SINGLE_LETTERS);
+       }
+       
+       /**
+        * Returns <code>true</code> if string literals
+        * should be ignored during spell checking.
+        */
+       public static boolean isIgnoreStringLiterals() {
+               return preferenceStore.getBoolean(SPELLING_IGNORE_STRING_LITERALS);
+       }
+
+       /**
+        * Returns <code>true</code> if upper case words should be
+        * skipped during spell checking.
+        */
+       public static boolean isIgnoreUpper() {
+               return preferenceStore.getBoolean(SPELLING_IGNORE_UPPER);
+       }
+
+       /**
+        * Returns <code>true</code> if URLs should be ignored during
+        * spell checking.
+        */
+       public static boolean isIgnoreUrls() {
+               return preferenceStore.getBoolean(SPELLING_IGNORE_URLS);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/TaskTagDictionary.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/TaskTagDictionary.java
new file mode 100644 (file)
index 0000000..1169b2e
--- /dev/null
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling;
+
+import java.net.URL;
+import java.util.StringTokenizer;
+
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.CCorePreferenceConstants;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.text.spelling.engine.AbstractSpellDictionary;
+
+/**
+ * Dictionary for task tags.
+ */
+public class TaskTagDictionary extends AbstractSpellDictionary implements IPropertyChangeListener {
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.AbstractSpellDictionary#getName()
+        */
+       @Override
+       protected final URL getURL() {
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.spelling.engine.AbstractSpellDictionary#load(java.net.URL)
+        */
+       @Override
+       protected synchronized boolean load(final URL url) {
+               final CUIPlugin plugin= CUIPlugin.getDefault();
+               if (plugin != null) {
+                       plugin.getCorePreferenceStore().addPropertyChangeListener(this);
+                       return updateTaskTags();
+               }
+               return false;
+       }
+
+       /*
+        * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+        */
+       public void propertyChange(PropertyChangeEvent event) {
+               if (CCorePreferenceConstants.TODO_TASK_TAGS.equals(event.getProperty()))
+                       updateTaskTags();
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.spelling.engine.ISpellDictionary#unload()
+        */
+       @Override
+       public synchronized void unload() {
+               final CUIPlugin plugin= CUIPlugin.getDefault();
+               if (plugin != null)
+                       plugin.getCorePreferenceStore().removePropertyChangeListener(this);
+
+               super.unload();
+       }
+
+       /**
+        * Handles the compiler task tags property change event.
+        * 
+        * @return  <code>true</code> if the task tags got updated
+        */
+       protected boolean updateTaskTags() {
+               final String tags= CCorePlugin.getOption(CCorePreferenceConstants.TODO_TASK_TAGS);
+               if (tags != null) {
+                       unload();
+
+                       final StringTokenizer tokenizer= new StringTokenizer(tags, ","); //$NON-NLS-1$
+                       while (tokenizer.hasMoreTokens())
+                               hashWord(tokenizer.nextToken());
+
+                       return true;
+               }
+               return false;
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.AbstractSpellDictionary#stripNonLetters(java.lang.String)
+        */
+       @Override
+       protected String stripNonLetters(String word) {
+               return word;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/TextSpellingEngine.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/TextSpellingEngine.java
new file mode 100644 (file)
index 0000000..d877b8e
--- /dev/null
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *        Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+
+import org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector;
+
+import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellChecker;
+import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellEventListener;
+
+/**
+ * Text spelling engine
+ */
+public class TextSpellingEngine extends SpellingEngine {
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.SpellingEngine#check(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IRegion[], org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellChecker, org.eclipse.ui.texteditor.spelling.ISpellingProblemCollector, org.eclipse.core.runtime.IProgressMonitor)
+        */
+       @Override
+       protected void check(IDocument document, IRegion[] regions, ISpellChecker checker, ISpellingProblemCollector collector, IProgressMonitor monitor) {
+               ISpellEventListener listener= new SpellEventListener(collector, document);
+               try {
+                       checker.addListener(listener);
+                       for (int i= 0; i < regions.length; i++) {
+                               if (monitor != null && monitor.isCanceled())
+                                       return;
+                               checker.execute(new SpellCheckIterator(document, regions[i], checker.getLocale()));
+                       }
+               } finally {
+                       checker.removeListener(listener);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordCompletionProposalComputer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordCompletionProposalComputer.java
new file mode 100644 (file)
index 0000000..7005c95
--- /dev/null
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext;
+import org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer;
+
+import org.eclipse.cdt.internal.ui.text.contentassist.CCompletionProposal;
+import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellCheckEngine;
+import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellChecker;
+import org.eclipse.cdt.internal.ui.text.spelling.engine.RankedWordProposal;
+
+/**
+ * Content assist processor to complete words.
+ * <strong>Note:</strong> This is currently not supported because the spelling engine
+ * cannot return word proposals but only correction proposals.
+ */
+public final class WordCompletionProposalComputer implements ICompletionProposalComputer {
+       /** The prefix rank shift */
+       private static final int PREFIX_RANK_SHIFT= 500;
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalComputer#computeCompletionProposals(org.eclipse.jface.text.contentassist.TextContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
+        */
+       public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+               if (contributes()) {
+                       try {
+                               IDocument document= context.getDocument();
+                               final int offset= context.getInvocationOffset();
+                       
+                               final IRegion region= document.getLineInformationOfOffset(offset);
+                               final String content= document.get(region.getOffset(), region.getLength());
+                       
+                               int index= offset - region.getOffset() - 1;
+                               while (index >= 0 && Character.isLetter(content.charAt(index)))
+                                       index--;
+                       
+                               final int start= region.getOffset() + index + 1;
+                               final String candidate= content.substring(index + 1, offset - region.getOffset());
+                       
+                               if (candidate.length() > 0) {
+                                       final ISpellCheckEngine engine= SpellCheckEngine.getInstance();
+                                       final ISpellChecker checker= engine.getSpellChecker();
+                       
+                                       if (checker != null) {
+                                               final List<RankedWordProposal> proposals= new ArrayList<RankedWordProposal>(checker.getProposals(candidate, Character.isUpperCase(candidate.charAt(0))));
+                                               final List<ICompletionProposal> result= new ArrayList<ICompletionProposal>(proposals.size());
+                       
+                                               for (Object element : proposals) {
+                                                       RankedWordProposal word= (RankedWordProposal) element;
+                                                       String text= word.getText();
+                                                       if (text.startsWith(candidate))
+                                                               word.setRank(word.getRank() + PREFIX_RANK_SHIFT);
+                                                       
+                                                       result.add(new CCompletionProposal(text, start, candidate.length(),
+                                                                       CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_CORRECTION_RENAME), text, word.getRank()) {
+                                                               /*
+                                                                * @see org.eclipse.cdt.internal.ui.text.java.JavaCompletionProposal#validate(org.eclipse.jface.text.IDocument, int, org.eclipse.jface.text.DocumentEvent)
+                                                                */
+                                                               @Override
+                                                               public boolean validate(IDocument doc, int validate_offset, DocumentEvent event) {
+                                                                       return offset == validate_offset;
+                                                               }
+                                                       });
+                                               }
+                                               
+                                               return result;
+                                       }
+                               }
+                       } catch (BadLocationException exception) {
+                               // log & ignore
+                               CUIPlugin.log(exception);
+                       }
+               }
+               return Collections.emptyList();
+       }
+
+       private boolean contributes() {
+               return SpellingPreferences.isEnabledSpellingContentAssist();
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalComputer#computeContextInformation(org.eclipse.jface.text.contentassist.TextContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
+        */
+       public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+               return Collections.emptyList();
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposalComputer#getErrorMessage()
+        */
+       public String getErrorMessage() {
+               return null; // no error message available
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.java.IJavaCompletionProposalComputer#sessionStarted()
+        */
+       public void sessionStarted() {
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.java.IJavaCompletionProposalComputer#sessionEnded()
+        */
+       public void sessionEnded() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordCorrectionProposal.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordCorrectionProposal.java
new file mode 100644 (file)
index 0000000..d1c893c
--- /dev/null
@@ -0,0 +1,172 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.text.ICCompletionProposal;
+import org.eclipse.cdt.ui.text.IInvocationContext;
+
+import org.eclipse.cdt.internal.ui.text.IHtmlTagConstants;
+
+/**
+ * Proposal to correct the incorrectly spelled word.
+ */
+public class WordCorrectionProposal implements ICCompletionProposal {
+       /** The invocation context */
+       private final IInvocationContext fContext;
+
+       /** The length in the document */
+       private final int fLength;
+
+       /** The line where to apply the correction */
+       private final String fLine;
+
+       /** The offset in the document */
+       private final int fOffset;
+
+       /** The relevance of this proposal */
+       private final int fRelevance;
+
+       /** The word to complete */
+       private final String fWord;
+
+       /**
+        * Creates a new word correction proposal.
+        *
+        * @param word the corrected word
+        * @param arguments the problem arguments associated with the spelling problem
+        * @param offset the offset in the document where to apply the proposal
+        * @param length the length in the document to apply the proposal
+        * @param context the invocation context for this proposal
+        * @param relevance the relevance of this proposal
+        */
+       public WordCorrectionProposal(final String word, final String[] arguments, final int offset,
+                       final int length, final IInvocationContext context, final int relevance) {
+               fWord= Character.isUpperCase(arguments[0].charAt(0)) ?
+                               Character.toUpperCase(word.charAt(0)) + word.substring(1) : word;
+
+               fOffset= offset;
+               fLength= length;
+               fContext= context;
+               fRelevance= relevance;
+
+               final StringBuffer buffer= new StringBuffer(80);
+
+               buffer.append("...<br>"); //$NON-NLS-1$
+               buffer.append(getHtmlRepresentation(arguments[1]));
+               buffer.append("<b>"); //$NON-NLS-1$
+               buffer.append(getHtmlRepresentation(fWord));
+               buffer.append("</b>"); //$NON-NLS-1$
+               buffer.append(getHtmlRepresentation(arguments[2]));
+               buffer.append("<br>..."); //$NON-NLS-1$
+
+               fLine= buffer.toString();
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument)
+        */
+       public final void apply(final IDocument document) {
+               try {
+                       document.replace(fOffset, fLength, fWord);
+               } catch (BadLocationException exception) {
+                       // Do nothing
+               }
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo()
+        */
+       public String getAdditionalProposalInfo() {
+               return fLine;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getContextInformation()
+        */
+       public final IContextInformation getContextInformation() {
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
+        */
+       public String getDisplayString() {
+               return Messages.bind(Messages.Spelling_correct_label, fWord);
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage()
+        */
+       public Image getImage() {
+               return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_CORRECTION_RENAME);
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.java.IJavaCompletionProposal#getRelevance()
+        */
+       public final int getRelevance() {
+               return fRelevance;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getSelection(org.eclipse.jface.text.IDocument)
+        */
+       public final Point getSelection(final IDocument document) {
+               int offset= fContext.getSelectionOffset();
+               int length= fContext.getSelectionLength();
+
+               final int delta= fWord.length() - fLength;
+               if (offset <= fOffset && offset + length >= fOffset) {
+                       length += delta;
+               } else if (offset > fOffset && offset + length > fOffset + fLength) {
+                       offset += delta;
+                       length -= delta;
+               } else {
+                       length += delta;
+               }
+
+               return new Point(offset, length);
+       }
+       
+       /**
+        * Returns the html representation of the specified string.
+        *
+        * @param string The string to return the html representation for
+        * @return The html representation for the string
+        */
+       public static String getHtmlRepresentation(final String string) {
+               final int length= string.length();
+               final StringBuffer buffer= new StringBuffer(string);
+
+               for (int offset= length - 1; offset >= 0; offset--) {
+                       for (int index= 0; index < IHtmlTagConstants.HTML_ENTITY_CHARACTERS.length; index++) {
+                               if (string.charAt(offset) == IHtmlTagConstants.HTML_ENTITY_CHARACTERS[index]) {
+                                       buffer.replace(offset, offset + 1, String.valueOf(IHtmlTagConstants.HTML_ENTITY_CODES[index]));
+                                       break;
+                               }
+                       }
+               }
+               return buffer.toString();
+       }
+
+       public String getIdString() {
+               return fWord;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordIgnoreProposal.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordIgnoreProposal.java
new file mode 100644 (file)
index 0000000..9b3b019
--- /dev/null
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.ui.texteditor.spelling.SpellingProblem;
+
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.text.ICCompletionProposal;
+import org.eclipse.cdt.ui.text.IInvocationContext;
+
+import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellCheckEngine;
+import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellChecker;
+
+/**
+ * Proposal to ignore the word during the current editing session.
+ */
+public class WordIgnoreProposal implements ICCompletionProposal {
+       /** The invocation context */
+       private IInvocationContext fContext;
+
+       /** The word to ignore */
+       private String fWord;
+
+       /**
+        * Creates a new spell ignore proposal.
+        *
+        * @param word       The word to ignore
+        * @param context    The invocation context
+        */
+       public WordIgnoreProposal(final String word, final IInvocationContext context) {
+               fWord= word;
+               fContext= context;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument)
+        */
+       public final void apply(final IDocument document) {
+        final ISpellCheckEngine engine= SpellCheckEngine.getInstance();
+        final ISpellChecker checker= engine.getSpellChecker();
+        if (checker != null) {
+            checker.ignoreWord(fWord);
+            if (fContext instanceof IQuickAssistInvocationContext) {
+                ISourceViewer sourceViewer= ((IQuickAssistInvocationContext) fContext).getSourceViewer();
+                if (sourceViewer != null) {
+                    SpellingProblem.removeAll(sourceViewer, fWord);
+                }
+            }
+        }
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo()
+        */
+       public String getAdditionalProposalInfo() {
+               return Messages.bind(Messages.Spelling_ignore_info, WordCorrectionProposal.getHtmlRepresentation(fWord));
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getContextInformation()
+        */
+       public final IContextInformation getContextInformation() {
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
+        */
+       public String getDisplayString() {
+               return Messages.bind(Messages.Spelling_ignore_label, fWord);
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage()
+        */
+       public Image getImage() {
+               return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_NLS_NEVER_TRANSLATE);
+       }
+       /*
+        * @see org.eclipse.cdt.ui.text.java.IJavaCompletionProposal#getRelevance()
+        */
+       public final int getRelevance() {
+               return Integer.MIN_VALUE + 1;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getSelection(org.eclipse.jface.text.IDocument)
+        */
+       public final Point getSelection(final IDocument document) {
+               return new Point(fContext.getSelectionOffset(), fContext.getSelectionLength());
+       }
+
+       public String getIdString() {
+               return fWord;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordQuickFixProcessor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordQuickFixProcessor.java
new file mode 100644 (file)
index 0000000..15b50e5
--- /dev/null
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.text.ICCompletionProposal;
+import org.eclipse.cdt.ui.text.IInvocationContext;
+import org.eclipse.cdt.ui.text.IProblemLocation;
+import org.eclipse.cdt.ui.text.IQuickFixProcessor;
+
+import org.eclipse.cdt.internal.ui.text.IHtmlTagConstants;
+import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellCheckEngine;
+import org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellChecker;
+import org.eclipse.cdt.internal.ui.text.spelling.engine.RankedWordProposal;
+
+/**
+ * Quick fix processor for incorrectly spelled words.
+ */
+public class WordQuickFixProcessor implements IQuickFixProcessor {
+       /**
+        * Creates a new word quick fix processor.
+        */
+       public WordQuickFixProcessor() {
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.java.IQuickFixProcessor#getCorrections(org.eclipse.cdt.ui.text.java.ContentAssistInvocationContext,org.eclipse.cdt.ui.text.java.IProblemLocation[])
+        */
+       public ICCompletionProposal[] getCorrections(IInvocationContext context, IProblemLocation[] locations) throws CoreException {
+               final int threshold= SpellingPreferences.spellingProposalThreshold();
+
+               int size= 0;
+               List<RankedWordProposal> proposals= null;
+               String[] arguments= null;
+
+               IProblemLocation location= null;
+               RankedWordProposal proposal= null;
+               ICCompletionProposal[] result= null;
+
+               boolean fixed= false;
+               boolean match= false;
+               boolean sentence= false;
+
+               final ISpellCheckEngine engine= SpellCheckEngine.getInstance();
+               final ISpellChecker checker= engine.getSpellChecker();
+
+               if (checker != null) {
+                       for (int index= 0; index < locations.length; index++) {
+                               location= locations[index];
+                               if (location.getProblemId() == CSpellingReconcileStrategy.SPELLING_PROBLEM_ID) {
+                                       arguments= location.getProblemArguments();
+                                       if (arguments != null && arguments.length > 4) {
+                                               sentence= Boolean.valueOf(arguments[3]).booleanValue();
+                                               match= Boolean.valueOf(arguments[4]).booleanValue();
+                                               fixed= arguments[0].charAt(0) == IHtmlTagConstants.HTML_TAG_PREFIX;
+
+                                               if ((sentence && match) && !fixed) {
+                                                       result= new ICCompletionProposal[] { new ChangeCaseProposal(arguments, location.getOffset(), location.getLength(), context, engine.getLocale())};
+                                               } else {
+                                                       proposals= new ArrayList<RankedWordProposal>(checker.getProposals(arguments[0], sentence));
+                                                       size= proposals.size();
+
+                                                       if (threshold > 0 && size > threshold) {
+                                                               Collections.sort(proposals);
+                                                               proposals= proposals.subList(size - threshold - 1, size - 1);
+                                                               size= proposals.size();
+                                                       }
+
+                                                       boolean extendable= !fixed ? (checker.acceptsWords() || AddWordProposal.canAskToConfigure()) : false;
+                                                       result= new ICCompletionProposal[size + (extendable ? 3 : 2)];
+
+                                                       for (index= 0; index < size; index++) {
+                                                               proposal= proposals.get(index);
+                                                               result[index]= new WordCorrectionProposal(proposal.getText(), arguments, location.getOffset(), location.getLength(), context, proposal.getRank());
+                                                       }
+
+                                                       if (extendable)
+                                                               result[index++]= new AddWordProposal(arguments[0], context);
+
+                                                       result[index++]= new WordIgnoreProposal(arguments[0], context);
+                                                       result[index++]= new DisableSpellCheckingProposal(context);
+                                               }
+                                               break;
+                                       }
+                               }
+                       }
+               }
+               return result;
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.java.IQuickFixProcessor#hasCorrections(org.eclipse.cdt.core.ICompilationUnit,int)
+        */
+       public final boolean hasCorrections(ITranslationUnit unit, int id) {
+               return id == CSpellingReconcileStrategy.SPELLING_PROBLEM_ID;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/AbstractSpellDictionary.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/AbstractSpellDictionary.java
new file mode 100644 (file)
index 0000000..4b07165
--- /dev/null
@@ -0,0 +1,615 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling.engine;
+
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Serializable;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CodingErrorAction;
+import java.nio.charset.MalformedInputException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.osgi.util.NLS;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.text.spelling.Messages;
+import org.eclipse.cdt.internal.ui.text.spelling.SpellingPreferences;
+
+/**
+ * Partial implementation of a spell dictionary.
+ */
+public abstract class AbstractSpellDictionary implements ISpellDictionary {
+       /** The bucket capacity */
+       protected static final int BUCKET_CAPACITY= 4;
+
+       /** The word buffer capacity */
+       protected static final int BUFFER_CAPACITY= 32;
+
+       /** The distance threshold */
+       protected static final int DISTANCE_THRESHOLD= 160;
+
+       /** The hash capacity */
+       protected static final int HASH_CAPACITY= 22 * 1024;
+
+       /** The phonetic distance algorithm */
+       private IPhoneticDistanceAlgorithm fDistanceAlgorithm= new DefaultPhoneticDistanceAlgorithm();
+
+       /** The mapping from phonetic hashes to word lists */
+       private final Map<String, Serializable> fHashBuckets= new HashMap<String, Serializable>(HASH_CAPACITY);
+
+       /** The phonetic hash provider */
+       private IPhoneticHashProvider fHashProvider= new DefaultPhoneticHashProvider();
+
+       /** Is the dictionary already loaded? */
+       private boolean fLoaded= false;
+       /**
+        * Must the dictionary be loaded?
+        */
+       private boolean fMustLoad= true;
+
+       /**
+        * Tells whether to strip non-letters at word boundaries.
+        */
+       boolean fIsStrippingNonLetters= true;
+
+       /**
+        * Returns all candidates with the same phonetic hash.
+        *
+        * @param hash
+        *                   The hash to retrieve the candidates of
+        * @return Array of candidates for the phonetic hash
+        */
+       protected final Object getCandidates(final String hash) {
+               return fHashBuckets.get(hash);
+       }
+
+       /**
+        * Returns all candidates that have a phonetic hash within a bounded
+        * distance to the specified word.
+        *
+        * @param word
+        *                   The word to find the nearest matches for
+        * @param sentence
+        *                   <code>true</code> iff the proposals start a new sentence,
+        *                   <code>false</code> otherwise
+        * @param hashs
+        *                   Array of close hashes to find the matches
+        * @return Set of ranked words with bounded distance to the specified word
+        */
+       protected final Set<RankedWordProposal> getCandidates(final String word, final boolean sentence, final ArrayList<String> hashs) {
+
+               int distance= 0;
+               String hash= null;
+
+               final StringBuffer buffer= new StringBuffer(BUFFER_CAPACITY);
+               final HashSet<RankedWordProposal> result= new HashSet<RankedWordProposal>(BUCKET_CAPACITY * hashs.size());
+
+               for (int index= 0; index < hashs.size(); index++) {
+
+                       hash= hashs.get(index);
+
+                       final Object candidates= getCandidates(hash);
+                       if (candidates == null)
+                               continue;
+                       else if (candidates instanceof String) {
+                               String candidate= (String)candidates;
+                               distance= fDistanceAlgorithm.getDistance(word, candidate);
+                               if (distance < DISTANCE_THRESHOLD) {
+                                       buffer.setLength(0);
+                                       buffer.append(candidate);
+                                       if (sentence)
+                                               buffer.setCharAt(0, Character.toUpperCase(buffer.charAt(0)));
+                                       result.add(new RankedWordProposal(buffer.toString(), -distance));
+                               }
+                               continue;
+                       }
+
+                       @SuppressWarnings("unchecked")
+                       final ArrayList<String> candidateList= (ArrayList<String>)candidates;
+                       for (int offset= 0; offset < candidateList.size(); offset++) {
+
+                               String candidate= candidateList.get(offset);
+                               distance= fDistanceAlgorithm.getDistance(word, candidate);
+
+                               if (distance < DISTANCE_THRESHOLD) {
+
+                                       buffer.setLength(0);
+                                       buffer.append(candidate);
+
+                                       if (sentence)
+                                               buffer.setCharAt(0, Character.toUpperCase(buffer.charAt(0)));
+
+                                       result.add(new RankedWordProposal(buffer.toString(), -distance));
+                               }
+                       }
+               }
+               return result;
+       }
+
+       /**
+        * Returns all approximations that have a phonetic hash with smallest
+        * possible distance to the specified word.
+        *
+        * @param word
+        *                   The word to find the nearest matches for
+        * @param sentence
+        *                   <code>true</code> iff the proposals start a new sentence,
+        *                   <code>false</code> otherwise
+        * @param result
+        *                   Set of ranked words with smallest possible distance to the
+        *                   specified word
+        */
+       protected final void getCandidates(final String word, final boolean sentence, final Set<RankedWordProposal> result) {
+
+               int distance= 0;
+               int minimum= Integer.MAX_VALUE;
+
+               StringBuffer buffer= new StringBuffer(BUFFER_CAPACITY);
+
+               final Object candidates= getCandidates(fHashProvider.getHash(word));
+               if (candidates == null)
+                       return;
+               else if (candidates instanceof String) {
+                       String candidate= (String)candidates;
+                       distance= fDistanceAlgorithm.getDistance(word, candidate);
+                       buffer.append(candidate);
+                       if (sentence)
+                               buffer.setCharAt(0, Character.toUpperCase(buffer.charAt(0)));
+                       result.add(new RankedWordProposal(buffer.toString(), -distance));
+                       return;
+               }
+
+               @SuppressWarnings("unchecked")
+               final ArrayList<String> candidateList= (ArrayList<String>)candidates;
+               final ArrayList<RankedWordProposal> matches= new ArrayList<RankedWordProposal>(candidateList.size());
+
+               for (int index= 0; index < candidateList.size(); index++) {
+                       String candidate= candidateList.get(index);
+                       distance= fDistanceAlgorithm.getDistance(word, candidate);
+
+                       if (distance <= minimum) {
+                               
+                               if (distance < minimum)
+                                       matches.clear();
+
+                               buffer.setLength(0);
+                               buffer.append(candidate);
+
+                               if (sentence)
+                                       buffer.setCharAt(0, Character.toUpperCase(buffer.charAt(0)));
+
+                               matches.add(new RankedWordProposal(buffer.toString(), -distance));
+                               minimum= distance;
+                       }
+               }
+
+               result.addAll(matches);
+       }
+       
+       /**
+        * Tells whether this dictionary is empty.
+        * 
+        * @return <code>true</code> if this dictionary is empty
+        */
+       protected boolean isEmpty() {
+               return fHashBuckets.size() == 0;
+       }
+
+       /**
+        * Returns the used phonetic distance algorithm.
+        *
+        * @return The phonetic distance algorithm
+        */
+       protected final IPhoneticDistanceAlgorithm getDistanceAlgorithm() {
+               return fDistanceAlgorithm;
+       }
+
+       /**
+        * Returns the used phonetic hash provider.
+        *
+        * @return The phonetic hash provider
+        */
+       protected final IPhoneticHashProvider getHashProvider() {
+               return fHashProvider;
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellDictionary#getProposals(java.lang.String,boolean)
+        */
+       public Set<RankedWordProposal> getProposals(final String word, final boolean sentence) {
+
+               try {
+
+                       if (!fLoaded) {
+                               synchronized (this) {
+                                       fLoaded= load(getURL());
+                                       if (fLoaded)
+                                               compact();
+                               }
+                       }
+
+               } catch (MalformedURLException exception) {
+                       // Do nothing
+               }
+
+               final String hash= fHashProvider.getHash(word);
+               final char[] mutators= fHashProvider.getMutators();
+
+               final ArrayList<String> neighborhood= new ArrayList<String>((word.length() + 1) * (mutators.length + 2));
+               neighborhood.add(hash);
+
+               final Set<RankedWordProposal> candidates= getCandidates(word, sentence, neighborhood);
+               neighborhood.clear();
+
+               char previous= 0;
+               char next= 0;
+
+               char[] characters= word.toCharArray();
+               for (int index= 0; index < word.length() - 1; index++) {
+
+                       next= characters[index];
+                       previous= characters[index + 1];
+
+                       characters[index]= previous;
+                       characters[index + 1]= next;
+
+                       neighborhood.add(fHashProvider.getHash(new String(characters)));
+
+                       characters[index]= next;
+                       characters[index + 1]= previous;
+               }
+
+               final String sentinel= word + " "; //$NON-NLS-1$
+
+               characters= sentinel.toCharArray();
+               int offset= characters.length - 1;
+
+               while (true) {
+
+                       for (char mutator : mutators) {
+
+                               characters[offset]= mutator;
+                               neighborhood.add(fHashProvider.getHash(new String(characters)));
+                       }
+
+                       if (offset == 0)
+                               break;
+
+                       characters[offset]= characters[offset - 1];
+                       --offset;
+               }
+
+               char mutated= 0;
+               characters= word.toCharArray();
+
+               for (int index= 0; index < word.length(); index++) {
+
+                       mutated= characters[index];
+                       for (char mutator2 : mutators) {
+
+                               characters[index]= mutator2;
+                               neighborhood.add(fHashProvider.getHash(new String(characters)));
+                       }
+                       characters[index]= mutated;
+               }
+
+               characters= word.toCharArray();
+               final char[] deleted= new char[characters.length - 1];
+
+               for (int index= 0; index < deleted.length; index++)
+                       deleted[index]= characters[index];
+
+               next= characters[characters.length - 1];
+               offset= deleted.length;
+
+               while (true) {
+
+                       neighborhood.add(fHashProvider.getHash(new String(characters)));
+                       if (offset == 0)
+                               break;
+
+                       previous= next;
+                       next= deleted[offset - 1];
+
+                       deleted[offset - 1]= previous;
+                       --offset;
+               }
+
+               neighborhood.remove(hash);
+               final Set<RankedWordProposal> matches= getCandidates(word, sentence, neighborhood);
+
+               if (matches.size() == 0 && candidates.size() == 0)
+                       getCandidates(word, sentence, candidates);
+
+               candidates.addAll(matches);
+
+               return candidates;
+       }
+
+       /**
+        * Returns the URL of the dictionary word list.
+        *
+        * @throws MalformedURLException
+        *                    if the URL could not be retrieved
+        * @return The URL of the dictionary word list
+        */
+       protected abstract URL getURL() throws MalformedURLException;
+
+       /**
+        * Hashes the word into the dictionary.
+        *
+        * @param word
+        *                   The word to hash in the dictionary
+        */
+       protected final void hashWord(final String word) {
+
+               final String hash= fHashProvider.getHash(word);
+               Object bucket= fHashBuckets.get(hash);
+
+               if (bucket == null) {
+                       fHashBuckets.put(hash, word);
+               } else if (bucket instanceof ArrayList<?>) {
+                       @SuppressWarnings({"unchecked", "rawtypes"})
+                       final ArrayList<Object> bucket2 = (ArrayList)bucket;
+                       bucket2.add(word);
+               } else {
+                       ArrayList<Object> list= new ArrayList<Object>(BUCKET_CAPACITY);
+                       list.add(bucket);
+                       list.add(word);
+                       fHashBuckets.put(hash, list);
+               }
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellDictionary#isCorrect(java.lang.String)
+        */
+       public boolean isCorrect(String word) {
+               word= stripNonLetters(word);
+               try {
+                       
+                       if (!fLoaded) {
+                               synchronized (this) {
+                                       fLoaded= load(getURL());
+                                       if (fLoaded)
+                                               compact();
+                               }
+                       }
+
+               } catch (MalformedURLException exception) {
+                       // Do nothing
+               }
+
+               final Object candidates= getCandidates(fHashProvider.getHash(word));
+               if (candidates == null)
+                       return false;
+               else if (candidates instanceof String) {
+                       String candidate= (String)candidates;
+                       if (candidate.equals(word) || candidate.equals(word.toLowerCase()))
+                               return true;
+                       return false;
+               }
+               @SuppressWarnings({ "unchecked", "rawtypes" })
+               final ArrayList<String> candidateList= (ArrayList)candidates;
+               if (candidateList.contains(word) || candidateList.contains(word.toLowerCase()))
+                       return true;
+
+               return false;
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellDictionary#setStripNonLetters(boolean)
+        */
+       public void setStripNonLetters(boolean state) {
+               fIsStrippingNonLetters= state;
+       }
+       
+       /**
+        * Strips non-letter characters from the given word.
+        * <p>
+        * This will only happen if the corresponding preference is enabled.
+        * </p>
+        * 
+        * @param word the word to strip
+        * @return the stripped word
+        */
+       protected String stripNonLetters(String word) {
+               if (!fIsStrippingNonLetters)
+                       return word;
+               
+               int i= 0;
+               int j= word.length() - 1;
+               while (i <= j && !Character.isLetter(word.charAt(i)))
+                       i++;
+               if (i > j)
+                       return ""; //$NON-NLS-1$
+               
+               while (j > i && !Character.isLetter(word.charAt(j)))
+                       j--;
+               
+               return word.substring(i, j+1);
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.spelling.engine.ISpellDictionary#isLoaded()
+        */
+       public final synchronized boolean isLoaded() {
+               return fLoaded || fHashBuckets.size() > 0;
+       }
+
+       /**
+        * Loads a dictionary word list from disk.
+        *
+        * @param url
+        *                   The URL of the word list to load
+        * @return <code>true</code> iff the word list could be loaded, <code>false</code>
+        *               otherwise
+        */
+       protected synchronized boolean load(final URL url) {
+                if (!fMustLoad)
+                        return fLoaded;
+
+               if (url != null) {
+                       InputStream stream= null;
+                       int line= 0;
+                       try {
+                               stream= url.openStream();
+                               if (stream != null) {
+                                       String word= null;
+                                       
+                                       // Setup a reader with a decoder in order to read over malformed input if needed.
+                                       CharsetDecoder decoder= Charset.forName(getEncoding()).newDecoder();
+                                       decoder.onMalformedInput(CodingErrorAction.REPORT);
+                                       decoder.onUnmappableCharacter(CodingErrorAction.REPORT);
+                                       final BufferedReader reader= new BufferedReader(new InputStreamReader(stream, decoder));
+                                       
+                                       boolean doRead= true;
+                                       while (doRead) {
+                                               try {
+                                                       word= reader.readLine();
+                                               } catch (MalformedInputException ex) {
+                                                       // Tell the decoder to replace malformed input in order to read the line.
+                                                       decoder.onMalformedInput(CodingErrorAction.REPLACE);
+                                                       decoder.reset();
+                                                       word= reader.readLine();
+                                                       decoder.onMalformedInput(CodingErrorAction.REPORT);
+                                                       
+                                                       String message= NLS.bind(Messages.AbstractSpellingDictionary_encodingError,
+                                                                       new String[] { word, decoder.replacement(), url.toString() });
+                                                       IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK, message, ex);
+                                                       CUIPlugin.log(status);
+                                                       
+                                                       doRead= word != null;
+                                                       continue;
+                                               }
+                                               doRead= word != null;
+                                               if (doRead)
+                                                       hashWord(word);
+                                       }
+                                       return true;
+                               }
+                       } catch (FileNotFoundException e) {
+                               String urlString= url.toString();
+                               String lowercaseUrlString= urlString.toLowerCase();
+                               if (urlString.equals(lowercaseUrlString)) {
+                                       CUIPlugin.log(e);
+                               } else {
+                                       try {
+                                               return load(new URL(lowercaseUrlString));
+                                       } catch (MalformedURLException ex) {
+                                               CUIPlugin.log(ex);
+                                       }
+                               }
+                       } catch (IOException exception) {
+                               if (line > 0) {
+                                       String message= NLS.bind(Messages.AbstractSpellingDictionary_encodingError,
+                                                       String.valueOf(line), url.toString());
+                                       IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK, message, exception);
+                                       CUIPlugin.log(status);
+                               } else {
+                                       CUIPlugin.log(exception);
+                               }
+                       } finally {
+                               fMustLoad= false;
+                               try {
+                                       if (stream != null)
+                                               stream.close();
+                               } catch (IOException x) {
+                               }
+                       }
+               }
+               return false;
+       }
+
+       /**
+        * Compacts the dictionary.
+        */
+       private void compact() {
+               Iterator<Serializable> iter= fHashBuckets.values().iterator();
+               while (iter.hasNext()) {
+                       Object element= iter.next();
+                       if (element instanceof ArrayList<?>)
+                               ((ArrayList<?>)element).trimToSize();
+               }
+       }
+
+       /**
+        * Sets the phonetic distance algorithm to use.
+        *
+        * @param algorithm
+        *                   The phonetic distance algorithm
+        */
+       protected final void setDistanceAlgorithm(final IPhoneticDistanceAlgorithm algorithm) {
+               fDistanceAlgorithm= algorithm;
+       }
+
+       /**
+        * Sets the phonetic hash provider to use.
+        *
+        * @param provider
+        *                   The phonetic hash provider
+        */
+       protected final void setHashProvider(final IPhoneticHashProvider provider) {
+               fHashProvider= provider;
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.spelling.engine.ISpellDictionary#unload()
+        */
+       public synchronized void unload() {
+               fLoaded= false;
+               fMustLoad= true;
+               fHashBuckets.clear();
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.spelling.engine.ISpellDictionary#acceptsWords()
+        */
+       public boolean acceptsWords() {
+               return false;
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellDictionary#addWord(java.lang.String)
+        */
+       public void addWord(final String word) {
+               // Do nothing
+       }
+       
+       /**
+        * Returns the encoding of this dictionary.
+        * 
+        * @return the encoding of this dictionary
+        */
+       protected String getEncoding() {
+               String encoding= SpellingPreferences.getSpellingUserDictionaryEncoding();
+               if (encoding == null || encoding.length() == 0)
+                       encoding= ResourcesPlugin.getEncoding();
+               return encoding;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultPhoneticDistanceAlgorithm.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultPhoneticDistanceAlgorithm.java
new file mode 100644 (file)
index 0000000..bbb570b
--- /dev/null
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling.engine;
+
+/**
+ * Default phonetic distance algorithm for English words.
+ * <p>
+ * This algorithm implements the Levenshtein text edit distance.
+ * </p>
+ */
+public final class DefaultPhoneticDistanceAlgorithm implements IPhoneticDistanceAlgorithm {
+
+       /** The change case cost */
+       public static final int COST_CASE= 10;
+
+       /** The insert character cost */
+       public static final int COST_INSERT= 95;
+
+       /** The remove character cost */
+       public static final int COST_REMOVE= 95;
+
+       /** The substitute characters cost */
+       public static final int COST_SUBSTITUTE= 100;
+
+       /** The swap characters cost */
+       public static final int COST_SWAP= 90;
+
+       /*
+        * @see org.eclipse.spelling.done.IPhoneticDistanceAlgorithm#getDistance(java.lang.String,java.lang.String)
+        */
+       public final int getDistance(final String from, final String to) {
+
+               final char[] first= (" " + from).toCharArray(); //$NON-NLS-1$
+               final char[] second= (" " + to).toCharArray(); //$NON-NLS-1$
+
+               final int rows= first.length;
+               final int columns= second.length;
+
+               final int[][] metric= new int[rows][columns];
+               for (int column= 1; column < columns; column++)
+                       metric[0][column]= metric[0][column - 1] + COST_REMOVE;
+
+               for (int row= 1; row < rows; row++)
+                       metric[row][0]= metric[row - 1][0] + COST_INSERT;
+
+               char source, target;
+
+               int swap= Integer.MAX_VALUE;
+               int change= Integer.MAX_VALUE;
+
+               int minimum, diagonal, insert, remove;
+               for (int row= 1; row < rows; row++) {
+
+                       source= first[row];
+                       for (int column= 1; column < columns; column++) {
+
+                               target= second[column];
+                               diagonal= metric[row - 1][column - 1];
+
+                               if (source == target) {
+                                       metric[row][column]= diagonal;
+                                       continue;
+                               }
+
+                               change= Integer.MAX_VALUE;
+                               if (Character.toLowerCase(source) == Character.toLowerCase(target))
+                                       change= COST_CASE + diagonal;
+
+                               swap= Integer.MAX_VALUE;
+                               if (row != 1 && column != 1 && source == second[column - 1] && first[row - 1] == target)
+                                       swap= COST_SWAP + metric[row - 2][column - 2];
+
+                               minimum= COST_SUBSTITUTE + diagonal;
+                               if (swap < minimum)
+                                       minimum= swap;
+
+                               remove= metric[row][column - 1];
+                               if (COST_REMOVE + remove < minimum)
+                                       minimum= COST_REMOVE + remove;
+
+                               insert= metric[row - 1][column];
+                               if (COST_INSERT + insert < minimum)
+                                       minimum= COST_INSERT + insert;
+                               if (change < minimum)
+                                       minimum= change;
+
+                               metric[row][column]= minimum;
+                       }
+               }
+               return metric[rows - 1][columns - 1];
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultPhoneticHashProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultPhoneticHashProvider.java
new file mode 100644 (file)
index 0000000..b3a82a4
--- /dev/null
@@ -0,0 +1,670 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling.engine;
+
+/**
+ * Default phonetic hash provider for english languages.
+ * <p>
+ * This algorithm uses an adapted version double metaphone algorithm by
+ * Lawrence Philips.
+ * <p>
+ */
+public final class DefaultPhoneticHashProvider implements IPhoneticHashProvider {
+       private static final String[] meta01= { "ACH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta02= { "BACHER", "MACHER", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta03= { "CAESAR", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta04= { "CHIA", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta05= { "CH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta06= { "CHAE", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta07= { "HARAC", "HARIS", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta08= { "HOR", "HYM", "HIA", "HEM", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+       private static final String[] meta09= { "CHORE", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta10= { "VAN ", "VON ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta11= { "SCH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta12= { "ORCHES", "ARCHIT", "ORCHID", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+       private static final String[] meta13= { "T", "S", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta14= { "A", "O", "U", "E", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+       private static final String[] meta15= { "L", "R", "N", "M", "B", "H", "F", "V", "W", " ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$
+       private static final String[] meta16= { "MC", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta17= { "CZ", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta18= { "WICZ", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta19= { "CIA", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta20= { "CC", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta21= { "I", "E", "H", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+       private static final String[] meta22= { "HU", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta23= { "UCCEE", "UCCES", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta24= { "CK", "CG", "CQ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+       private static final String[] meta25= { "CI", "CE", "CY", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+       private static final String[] meta26= { "GN", "KN", "PN", "WR", "PS", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+       private static final String[] meta27= { " C", " Q", " G", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+       private static final String[] meta28= { "C", "K", "Q", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+       private static final String[] meta29= { "CE", "CI", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta30= { "DG", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta31= { "I", "E", "Y", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+       private static final String[] meta32= { "DT", "DD", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta33= { "B", "H", "D", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+       private static final String[] meta34= { "B", "H", "D", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+       private static final String[] meta35= { "B", "H", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta36= { "C", "G", "L", "R", "T", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+       private static final String[] meta37= { "EY", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta38= { "LI", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta39= { "ES", "EP", "EB", "EL", "EY", "IB", "IL", "IN", "IE", "EI", "ER", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$
+       private static final String[] meta40= { "ER", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta41= { "DANGER", "RANGER", "MANGER", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+       private static final String[] meta42= { "E", "I", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta43= { "RGY", "OGY", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta44= { "E", "I", "Y", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+       private static final String[] meta45= { "AGGI", "OGGI", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta46= { "VAN ", "VON ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta47= { "SCH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta48= { "ET", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta49= { "C", "X", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta50= { "JOSE", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta51= { "SAN ", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta52= { "SAN ", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta53= { "JOSE", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta54= { "L", "T", "K", "S", "N", "M", "B", "Z", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
+       private static final String[] meta55= { "S", "K", "L", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+       private static final String[] meta56= { "ILLO", "ILLA", "ALLE", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+       private static final String[] meta57= { "AS", "OS", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta58= { "A", "O", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta59= { "ALLE", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta60= { "UMB", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta61= { "ER", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta62= { "P", "B", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta63= { "IE", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta64= { "ME", "MA", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta65= { "ISL", "YSL", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta66= { "SUGAR", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta67= { "SH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta68= { "HEIM", "HOEK", "HOLM", "HOLZ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+       private static final String[] meta69= { "SIO", "SIA", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta70= { "SIAN", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta71= { "M", "N", "L", "W", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+       private static final String[] meta72= { "Z", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta73= { "Z", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta74= { "SC", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta75= { "OO", "ER", "EN", "UY", "ED", "EM", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
+       private static final String[] meta76= { "ER", "EN", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta77= { "I", "E", "Y", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+       private static final String[] meta78= { "AI", "OI", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta79= { "S", "Z", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta80= { "TION", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta81= { "TIA", "TCH", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta82= { "TH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta83= { "TTH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta84= { "OM", "AM", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta85= { "VAN ", "VON ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta86= { "SCH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta87= { "T", "D", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta88= { "WR", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta89= { "WH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta90= { "EWSKI", "EWSKY", "OWSKI", "OWSKY", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+       private static final String[] meta91= { "SCH", "" }; //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String[] meta92= { "WICZ", "WITZ", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta93= { "IAU", "EAU", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta94= { "AU", "OU", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       private static final String[] meta95= { "W", "K", "CZ", "WITZ" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+       /** The mutator characters */
+       private static final char[] MUTATOR_CHARACTERS= { 'A', 'B', 'X', 'S', 'K', 'J', 'T', 'F', 'H', 'L', 'M', 'N', 'P', 'R', '0' };
+
+       /** The vowel characters */
+       private static final char[] VOWEL_CHARACTERS= new char[] { 'A', 'E', 'I', 'O', 'U', 'Y' };
+
+       /**
+        * Test whether the specified string contains one of the candidates in the
+        * list.
+        *
+        * @param candidates
+        *                   Array of candidates to check
+        * @param token
+        *                   The token to check for occurrences of the candidates
+        * @param offset
+        *                   The offset where to begin checking in the string
+        * @param length
+        *                   The length of the range in the string to check
+        * @return <code>true</code> iff the string contains one of the
+        *               candidates, <code>false</code> otherwise.
+        */
+       protected static final boolean hasOneOf(final String[] candidates, final char[] token, final int offset, final int length) {
+               if (offset < 0 || offset >= token.length || candidates.length == 0)
+                       return false;
+
+               final String checkable= new String(token, offset, length);
+               for (String candidate : candidates) {
+
+                       if (candidate.equals(checkable))
+                               return true;
+               }
+               return false;
+       }
+
+       /**
+        * Test whether the specified token contains one of the candidates in the
+        * list.
+        *
+        * @param candidates
+        *                   Array of candidates to check
+        * @param token
+        *                   The token to check for occurrences of the candidates
+        * @return <code>true</code> iff the string contains one of the
+        *               candidates, <code>false</code> otherwise.
+        */
+       protected static final boolean hasOneOf(final String[] candidates, final String token) {
+               for (String candidate : candidates) {
+
+                       if (token.indexOf(candidate) >= 0)
+                               return true;
+               }
+               return false;
+       }
+
+       /**
+        * Tests whether the specified token contains a vowel at the specified
+        * offset.
+        *
+        * @param token
+        *                   The token to check for a vowel
+        * @param offset
+        *                   The offset where to begin checking in the token
+        * @param length
+        *                   The length of the range in the token to check
+        * @return <code>true</code> iff the token contains a vowel, <code>false</code>
+        *               otherwise.
+        */
+       protected static final boolean hasVowel(final char[] token, final int offset, final int length) {
+               if (offset >= 0 && offset < length) {
+                       final char character= token[offset];
+                       for (char element : VOWEL_CHARACTERS) {
+                               if (element == character)
+                                       return true;
+                       }
+               }
+               return false;
+       }
+
+       /*
+        * @see org.eclipse.spelling.done.IPhoneticHasher#getHash(java.lang.String)
+        */
+       public final String getHash(final String word) {
+               final String input= word.toUpperCase() + "     "; //$NON-NLS-1$
+               final char[] hashable= input.toCharArray();
+
+               final boolean has95= hasOneOf(meta95, input);
+               final StringBuffer buffer= new StringBuffer(hashable.length);
+
+               int offset= 0;
+               if (hasOneOf(meta26, hashable, 0, 2))
+                       offset += 1;
+
+               if (hashable[0] == 'X') {
+                       buffer.append('S');
+                       offset += 1;
+               }
+
+               while (offset < hashable.length) {
+                       switch (hashable[offset]) {
+                               case 'A' :
+                               case 'E' :
+                               case 'I' :
+                               case 'O' :
+                               case 'U' :
+                               case 'Y' :
+                                       if (offset == 0)
+                                               buffer.append('A');
+                                       offset += 1;
+                                       break;
+                               case 'B' :
+                                       buffer.append('P');
+                                       if (hashable[offset + 1] == 'B')
+                                               offset += 2;
+                                       else
+                                               offset += 1;
+                                       break;
+                               case 'C' :
+                                       if ((offset > 1) && !hasVowel(hashable, offset - 2, hashable.length) && hasOneOf(meta01, hashable, (offset - 1), 3) && (hashable[offset + 2] != 'I') && (hashable[offset + 2] != 'E') || hasOneOf(meta02, hashable, (offset - 2), 6)) {
+                                               buffer.append('K');
+                                               offset += 2;
+                                               break;
+                                       }
+                                       if ((offset == 0) && hasOneOf(meta03, hashable, offset, 6)) {
+                                               buffer.append('S');
+                                               offset += 2;
+                                               break;
+                                       }
+                                       if (hasOneOf(meta04, hashable, offset, 4)) {
+                                               buffer.append('K');
+                                               offset += 2;
+                                               break;
+                                       }
+                                       if (hasOneOf(meta05, hashable, offset, 2)) {
+                                               if ((offset > 0) && hasOneOf(meta06, hashable, offset, 4)) {
+                                                       buffer.append('K');
+                                                       offset += 2;
+                                                       break;
+                                               }
+                                               if ((offset == 0) && hasOneOf(meta07, hashable, (offset + 1), 5) || hasOneOf(meta08, hashable, offset + 1, 3) && !hasOneOf(meta09, hashable, 0, 5)) {
+                                                       buffer.append('K');
+                                                       offset += 2;
+                                                       break;
+                                               }
+                                               if (hasOneOf(meta10, hashable, 0, 4) || hasOneOf(meta11, hashable, 0, 3) || hasOneOf(meta12, hashable, offset - 2, 6) || hasOneOf(meta13, hashable, offset + 2, 1) || (hasOneOf(meta14, hashable, offset - 1, 1) || (offset == 0)) && hasOneOf(meta15, hashable, offset + 2, 1)) {
+                                                       buffer.append('K');
+                                               } else {
+                                                       if (offset > 0) {
+                                                               if (hasOneOf(meta16, hashable, 0, 2))
+                                                                       buffer.append('K');
+                                                               else
+                                                                       buffer.append('X');
+                                                       } else {
+                                                               buffer.append('X');
+                                                       }
+                                               }
+                                               offset += 2;
+                                               break;
+                                       }
+                                       if (hasOneOf(meta17, hashable, offset, 2) && !hasOneOf(meta18, hashable, offset, 4)) {
+                                               buffer.append('S');
+                                               offset += 2;
+                                               break;
+                                       }
+                                       if (hasOneOf(meta19, hashable, offset, 2)) {
+                                               buffer.append('X');
+                                               offset += 2;
+                                               break;
+                                       }
+                                       if (hasOneOf(meta20, hashable, offset, 2) && !((offset == 1) && hashable[0] == 'M')) {
+                                               if (hasOneOf(meta21, hashable, offset + 2, 1) && !hasOneOf(meta22, hashable, offset + 2, 2)) {
+                                                       if (((offset == 1) && (hashable[offset - 1] == 'A')) || hasOneOf(meta23, hashable, (offset - 1), 5))
+                                                               buffer.append("KS"); //$NON-NLS-1$
+                                                       else
+                                                               buffer.append('X');
+                                                       offset += 3;
+                                               } else {
+                                                       buffer.append('K');
+                                                       offset += 2;
+                                               }
+                                               break;
+                                       }
+                                       if (hasOneOf(meta24, hashable, offset, 2)) {
+                                               buffer.append('K');
+                                               offset += 2;
+                                               break;
+                                       } else if (hasOneOf(meta25, hashable, offset, 2)) {
+                                               buffer.append('S');
+                                               offset += 2;
+                                               break;
+                                       }
+                                       buffer.append('K');
+                                       if (hasOneOf(meta27, hashable, offset + 1, 2))
+                                               offset += 3;
+                                       else if (hasOneOf(meta28, hashable, offset + 1, 1) && !hasOneOf(meta29, hashable, offset + 1, 2))
+                                               offset += 2;
+                                       else
+                                               offset += 1;
+                                       break;
+                               case '\u00C7' :
+                                       buffer.append('S');
+                                       offset += 1;
+                                       break;
+                               case 'D' :
+                                       if (hasOneOf(meta30, hashable, offset, 2)) {
+                                               if (hasOneOf(meta31, hashable, offset + 2, 1)) {
+                                                       buffer.append('J');
+                                                       offset += 3;
+                                               } else {
+                                                       buffer.append("TK"); //$NON-NLS-1$
+                                                       offset += 2;
+                                               }
+                                               break;
+                                       }
+                                       buffer.append('T');
+                                       if (hasOneOf(meta32, hashable, offset, 2)) {
+                                               offset += 2;
+                                       } else {
+                                               offset += 1;
+                                       }
+                                       break;
+                               case 'F' :
+                                       if (hashable[offset + 1] == 'F')
+                                               offset += 2;
+                                       else
+                                               offset += 1;
+                                       buffer.append('F');
+                                       break;
+                               case 'G' :
+                                       if (hashable[offset + 1] == 'H') {
+                                               if ((offset > 0) && !hasVowel(hashable, offset - 1, hashable.length)) {
+                                                       buffer.append('K');
+                                                       offset += 2;
+                                                       break;
+                                               }
+                                               if (offset < 3) {
+                                                       if (offset == 0) {
+                                                               if (hashable[offset + 2] == 'I')
+                                                                       buffer.append('J');
+                                                               else
+                                                                       buffer.append('K');
+                                                               offset += 2;
+                                                               break;
+                                                       }
+                                               }
+                                               if ((offset > 1) && hasOneOf(meta33, hashable, offset - 2, 1) || ((offset > 2) && hasOneOf(meta34, hashable, offset - 3, 1)) || ((offset > 3) && hasOneOf(meta35, hashable, offset - 4, 1))) {
+                                                       offset += 2;
+                                               } else {
+                                                       if ((offset > 2) && (hashable[offset - 1] == 'U') && hasOneOf(meta36, hashable, offset - 3, 1)) {
+                                                               buffer.append('F');
+                                                       } else {
+                                                               if ((offset > 0) && (hashable[offset - 1] != 'I'))
+                                                                       buffer.append('K');
+                                                       }
+                                                       offset += 2;
+                                               }
+                                               break;
+                                       }
+                                       if (hashable[offset + 1] == 'N') {
+                                               if ((offset == 1) && hasVowel(hashable, 0, hashable.length) && !has95) {
+                                                       buffer.append("KN"); //$NON-NLS-1$
+                                               } else {
+                                                       if (!hasOneOf(meta37, hashable, offset + 2, 2) && (hashable[offset + 1] != 'Y') && !has95) {
+                                                               buffer.append("N"); //$NON-NLS-1$
+                                                       } else {
+                                                               buffer.append("KN"); //$NON-NLS-1$
+                                                       }
+                                               }
+                                               offset += 2;
+                                               break;
+                                       }
+                                       if (hasOneOf(meta38, hashable, offset + 1, 2) && !has95) {
+                                               buffer.append("KL"); //$NON-NLS-1$
+                                               offset += 2;
+                                               break;
+                                       }
+                                       if ((offset == 0) && ((hashable[offset + 1] == 'Y') || hasOneOf(meta39, hashable, offset + 1, 2))) {
+                                               buffer.append('K');
+                                               offset += 2;
+                                               break;
+                                       }
+                                       if ((hasOneOf(meta40, hashable, offset + 1, 2) || (hashable[offset + 1] == 'Y')) && !hasOneOf(meta41, hashable, 0, 6) && !hasOneOf(meta42, hashable, offset - 1, 1) && !hasOneOf(meta43, hashable, offset - 1, 3)) {
+                                               buffer.append('K');
+                                               offset += 2;
+                                               break;
+                                       }
+                                       if (hasOneOf(meta44, hashable, offset + 1, 1) || hasOneOf(meta45, hashable, offset - 1, 4)) {
+                                               if (hasOneOf(meta46, hashable, 0, 4) || hasOneOf(meta47, hashable, 0, 3) || hasOneOf(meta48, hashable, offset + 1, 2)) {
+                                                       buffer.append('K');
+                                               } else {
+                                                       buffer.append('J');
+                                               }
+                                               offset += 2;
+                                               break;
+                                       }
+                                       if (hashable[offset + 1] == 'G')
+                                               offset += 2;
+                                       else
+                                               offset += 1;
+                                       buffer.append('K');
+                                       break;
+                               case 'H' :
+                                       if (((offset == 0) || hasVowel(hashable, offset - 1, hashable.length)) && hasVowel(hashable, offset + 1, hashable.length)) {
+                                               buffer.append('H');
+                                               offset += 2;
+                                       } else {
+                                               offset += 1;
+                                       }
+                                       break;
+                               case 'J' :
+                                       if (hasOneOf(meta50, hashable, offset, 4) || hasOneOf(meta51, hashable, 0, 4)) {
+                                               if ((offset == 0) && (hashable[offset + 4] == ' ') || hasOneOf(meta52, hashable, 0, 4)) {
+                                                       buffer.append('H');
+                                               } else {
+                                                       buffer.append('J');
+                                               }
+                                               offset += 1;
+                                               break;
+                                       }
+                                       if ((offset == 0) && !hasOneOf(meta53, hashable, offset, 4)) {
+                                               buffer.append('J');
+                                       } else {
+                                               if (hasVowel(hashable, offset - 1, hashable.length) && !has95 && ((hashable[offset + 1] == 'A') || hashable[offset + 1] == 'O')) {
+                                                       buffer.append('J');
+                                               } else {
+                                                       if (offset == (hashable.length - 1)) {
+                                                               buffer.append('J');
+                                                       } else {
+                                                               if (!hasOneOf(meta54, hashable, offset + 1, 1) && !hasOneOf(meta55, hashable, offset - 1, 1)) {
+                                                                       buffer.append('J');
+                                                               }
+                                                       }
+                                               }
+                                       }
+                                       if (hashable[offset + 1] == 'J')
+                                               offset += 2;
+                                       else
+                                               offset += 1;
+                                       break;
+                               case 'K' :
+                                       if (hashable[offset + 1] == 'K')
+                                               offset += 2;
+                                       else
+                                               offset += 1;
+                                       buffer.append('K');
+                                       break;
+                               case 'L' :
+                                       if (hashable[offset + 1] == 'L') {
+                                               if (((offset == (hashable.length - 3)) && hasOneOf(meta56, hashable, offset - 1, 4)) || ((hasOneOf(meta57, hashable, (hashable.length - 1) - 1, 2) || hasOneOf(meta58, hashable, hashable.length - 1, 1)) && hasOneOf(meta59, hashable, offset - 1, 4))) {
+                                                       buffer.append('L');
+                                                       offset += 2;
+                                                       break;
+                                               }
+                                               offset += 2;
+                                       } else
+                                               offset += 1;
+                                       buffer.append('L');
+                                       break;
+                               case 'M' :
+                                       if ((hasOneOf(meta60, hashable, offset - 1, 3) && (((offset + 1) == (hashable.length - 1)) || hasOneOf(meta61, hashable, offset + 2, 2))) || (hashable[offset + 1] == 'M'))
+                                               offset += 2;
+                                       else
+                                               offset += 1;
+                                       buffer.append('M');
+                                       break;
+                               case 'N' :
+                                       if (hashable[offset + 1] == 'N')
+                                               offset += 2;
+                                       else
+                                               offset += 1;
+                                       buffer.append('N');
+                                       break;
+                               case '\u00D1' :
+                                       offset += 1;
+                                       buffer.append('N');
+                                       break;
+                               case 'P' :
+                                       if (hashable[offset + 1] == 'N') {
+                                               buffer.append('F');
+                                               offset += 2;
+                                               break;
+                                       }
+                                       if (hasOneOf(meta62, hashable, offset + 1, 1))
+                                               offset += 2;
+                                       else
+                                               offset += 1;
+                                       buffer.append('P');
+                                       break;
+                               case 'Q' :
+                                       if (hashable[offset + 1] == 'Q')
+                                               offset += 2;
+                                       else
+                                               offset += 1;
+                                       buffer.append('K');
+                                       break;
+                               case 'R' :
+                                       if (!((offset == (hashable.length - 1)) && !has95 && hasOneOf(meta63, hashable, offset - 2, 2) && !hasOneOf(meta64, hashable, offset - 4, 2)))
+                                               buffer.append('R');
+                                       if (hashable[offset + 1] == 'R')
+                                               offset += 2;
+                                       else
+                                               offset += 1;
+                                       break;
+                               case 'S' :
+                                       if (hasOneOf(meta65, hashable, offset - 1, 3)) {
+                                               offset += 1;
+                                               break;
+                                       }
+                                       if ((offset == 0) && hasOneOf(meta66, hashable, offset, 5)) {
+                                               buffer.append('X');
+                                               offset += 1;
+                                               break;
+                                       }
+                                       if (hasOneOf(meta67, hashable, offset, 2)) {
+                                               if (hasOneOf(meta68, hashable, offset + 1, 4))
+                                                       buffer.append('S');
+                                               else
+                                                       buffer.append('X');
+                                               offset += 2;
+                                               break;
+                                       }
+                                       if (hasOneOf(meta69, hashable, offset, 3) || hasOneOf(meta70, hashable, offset, 4)) {
+                                               buffer.append('S');
+                                               offset += 3;
+                                               break;
+                                       }
+                                       if (((offset == 0) && hasOneOf(meta71, hashable, offset + 1, 1)) || hasOneOf(meta72, hashable, offset + 1, 1)) {
+                                               buffer.append('S');
+                                               if (hasOneOf(meta73, hashable, offset + 1, 1))
+                                                       offset += 2;
+                                               else
+                                                       offset += 1;
+                                               break;
+                                       }
+                                       if (hasOneOf(meta74, hashable, offset, 2)) {
+                                               if (hashable[offset + 2] == 'H') {
+                                                       if (hasOneOf(meta75, hashable, offset + 3, 2)) {
+                                                               if (hasOneOf(meta76, hashable, offset + 3, 2)) {
+                                                                       buffer.append("X"); //$NON-NLS-1$
+                                                               } else {
+                                                                       buffer.append("SK"); //$NON-NLS-1$
+                                                               }
+                                                               offset += 3;
+                                                       } else {
+                                                               buffer.append('X');
+                                                               offset += 3;
+                                                       }
+                                                       break;
+                                               }
+                                               if (hasOneOf(meta77, hashable, offset + 2, 1)) {
+                                                       buffer.append('S');
+                                                       offset += 3;
+                                                       break;
+                                               }
+                                               buffer.append("SK"); //$NON-NLS-1$
+                                               offset += 3;
+                                               break;
+                                       }
+                                       if (!((offset == (hashable.length - 1)) && hasOneOf(meta78, hashable, offset - 2, 2)))
+                                               buffer.append('S');
+                                       if (hasOneOf(meta79, hashable, offset + 1, 1))
+                                               offset += 2;
+                                       else
+                                               offset += 1;
+                                       break;
+                               case 'T' :
+                                       if (hasOneOf(meta80, hashable, offset, 4)) {
+                                               buffer.append('X');
+                                               offset += 3;
+                                               break;
+                                       }
+                                       if (hasOneOf(meta81, hashable, offset, 3)) {
+                                               buffer.append('X');
+                                               offset += 3;
+                                               break;
+                                       }
+                                       if (hasOneOf(meta82, hashable, offset, 2) || hasOneOf(meta83, hashable, offset, 3)) {
+                                               if (hasOneOf(meta84, hashable, (offset + 2), 2) || hasOneOf(meta85, hashable, 0, 4) || hasOneOf(meta86, hashable, 0, 3)) {
+                                                       buffer.append('T');
+                                               } else {
+                                                       buffer.append('0');
+                                               }
+                                               offset += 2;
+                                               break;
+                                       }
+                                       if (hasOneOf(meta87, hashable, offset + 1, 1)) {
+                                               offset += 2;
+                                       } else
+                                               offset += 1;
+                                       buffer.append('T');
+                                       break;
+                               case 'V' :
+                                       if (hashable[offset + 1] == 'V')
+                                               offset += 2;
+                                       else
+                                               offset += 1;
+                                       buffer.append('F');
+                                       break;
+                               case 'W' :
+                                       if (hasOneOf(meta88, hashable, offset, 2)) {
+                                               buffer.append('R');
+                                               offset += 2;
+                                               break;
+                                       }
+                                       if ((offset == 0) && (hasVowel(hashable, offset + 1, hashable.length) || hasOneOf(meta89, hashable, offset, 2))) {
+                                               buffer.append('A');
+                                       }
+                                       if (((offset == (hashable.length - 1)) && hasVowel(hashable, offset - 1, hashable.length)) || hasOneOf(meta90, hashable, offset - 1, 5) || hasOneOf(meta91, hashable, 0, 3)) {
+                                               buffer.append('F');
+                                               offset += 1;
+                                               break;
+                                       }
+                                       if (hasOneOf(meta92, hashable, offset, 4)) {
+                                               buffer.append("TS"); //$NON-NLS-1$
+                                               offset += 4;
+                                               break;
+                                       }
+                                       offset += 1;
+                                       break;
+                               case 'X' :
+                                       if (!((offset == (hashable.length - 1)) && (hasOneOf(meta93, hashable, offset - 3, 3) || hasOneOf(meta94, hashable, offset - 2, 2))))
+                                               buffer.append("KS"); //$NON-NLS-1$
+                                       if (hasOneOf(meta49, hashable, offset + 1, 1))
+                                               offset += 2;
+                                       else
+                                               offset += 1;
+                                       break;
+                               case 'Z' :
+                                       if (hashable[offset + 1] == 'H') {
+                                               buffer.append('J');
+                                               offset += 2;
+                                               break;
+                                       }
+                                       buffer.append('S');
+                                       if (hashable[offset + 1] == 'Z')
+                                               offset += 2;
+                                       else
+                                               offset += 1;
+                                       break;
+                               default :
+                                       offset += 1;
+                       }
+               }
+               return buffer.toString();
+       }
+
+       /*
+        * @see org.eclipse.spelling.done.IPhoneticHasher#getMutators()
+        */
+       public final char[] getMutators() {
+               return MUTATOR_CHARACTERS;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultSpellChecker.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultSpellChecker.java
new file mode 100644 (file)
index 0000000..f199502
--- /dev/null
@@ -0,0 +1,345 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling.engine;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Set;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.preference.IPreferenceStore;
+
+import org.eclipse.cdt.internal.ui.text.spelling.SpellingPreferences;
+
+/**
+ * Default spell checker for standard text.
+ */
+public class DefaultSpellChecker implements ISpellChecker {
+       /** Array of URL prefixes */
+       public static final String[] URL_PREFIXES= new String[] { "http://", "https://", "www.", "ftp://", "ftps://", "news://", "mailto://" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
+
+       /**
+        * Does this word contain digits?
+        *
+        * @param word the word to check
+        * @return <code>true</code> iff this word contains digits, <code>false</code> otherwise
+        */
+       protected static boolean isDigits(final String word) {
+               for (int index= 0; index < word.length(); index++) {
+                       if (Character.isDigit(word.charAt(index)))
+                               return true;
+               }
+               return false;
+       }
+
+       /**
+        * Does this word contain mixed-case letters?
+        *
+        * @param word
+        *                   The word to check
+        * @param sentence
+        *                   <code>true</code> iff the specified word starts a new
+        *                   sentence, <code>false</code> otherwise
+        * @return <code>true</code> iff the contains mixed-case letters, <code>false</code>
+        *               otherwise
+        */
+       protected static boolean isMixedCase(final String word, final boolean sentence) {
+               final int length= word.length();
+               boolean upper= Character.isUpperCase(word.charAt(0));
+
+               if (sentence && upper && (length > 1))
+                       upper= Character.isUpperCase(word.charAt(1));
+
+               if (upper) {
+                       for (int index= length - 1; index > 0; index--) {
+                               if (Character.isLowerCase(word.charAt(index)))
+                                       return true;
+                       }
+               } else {
+                       for (int index= length - 1; index > 0; index--) {
+                               if (Character.isUpperCase(word.charAt(index)))
+                                       return true;
+                       }
+               }
+               return false;
+       }
+
+       /**
+        * Does this word contain upper-case letters only?
+        *
+        * @param word
+        *                   The word to check
+        * @return <code>true</code> iff this word only contains upper-case
+        *               letters, <code>false</code> otherwise
+        */
+       protected static boolean isUpperCase(final String word) {
+               for (int index= word.length() - 1; index >= 0; index--) {
+                       if (Character.isLowerCase(word.charAt(index)))
+                               return false;
+               }
+               return true;
+       }
+
+       /**
+        * Does this word look like an URL?
+        *
+        * @param word
+        *                   The word to check
+        * @return <code>true</code> iff this word looks like an URL, <code>false</code>
+        *               otherwise
+        */
+       protected static boolean isUrl(final String word) {
+               for (String element : URL_PREFIXES) {
+                       if (word.startsWith(element))
+                               return true;
+               }
+               return false;
+       }
+
+       /**
+        * The dictionaries to use for spell checking. Synchronized to avoid
+        * concurrent modifications.
+        */
+       private final Set<ISpellDictionary> fDictionaries= Collections.synchronizedSet(new HashSet<ISpellDictionary>());
+
+       /**
+        * The words to be ignored. Synchronized to avoid concurrent modifications.
+        */
+       private final Set<String> fIgnored= Collections.synchronizedSet(new HashSet<String>());
+
+       /**
+        * The spell event listeners. Synchronized to avoid concurrent
+        * modifications.
+        */
+       private final Set<ISpellEventListener> fListeners= Collections.synchronizedSet(new HashSet<ISpellEventListener>());
+
+       /**
+        * The locale of this checker.
+        */
+       private Locale fLocale;
+
+       /**
+        * Creates a new default spell checker.
+        *
+        * @param store the preference store for this spell checker
+        * @param locale the locale
+        */
+       public DefaultSpellChecker(IPreferenceStore store, Locale locale) {
+               Assert.isLegal(store != null);
+               Assert.isLegal(locale != null);
+               
+               fLocale= locale;
+       }
+
+       /*
+        * @see org.eclipse.spelling.done.ISpellChecker#addDictionary(org.eclipse.spelling.done.ISpellDictionary)
+        */
+       public final void addDictionary(final ISpellDictionary dictionary) {
+               // synchronizing is necessary as this is a write access
+               fDictionaries.add(dictionary);
+       }
+
+       /*
+        * @see org.eclipse.spelling.done.ISpellChecker#addListener(org.eclipse.spelling.done.ISpellEventListener)
+        */
+       public final void addListener(final ISpellEventListener listener) {
+               // synchronizing is necessary as this is a write access
+               fListeners.add(listener);
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.spelling.engine.ISpellChecker#acceptsWords()
+        */
+       public boolean acceptsWords() {
+               // synchronizing might not be needed here since acceptWords is
+               // a read-only access and only called in the same thread as
+               // the modifying methods add/checkWord (?)
+               Set<ISpellDictionary> copy;
+               synchronized (fDictionaries) {
+                       copy= new HashSet<ISpellDictionary>(fDictionaries);
+               }
+
+               ISpellDictionary dictionary= null;
+               for (final Iterator<ISpellDictionary> iterator= copy.iterator(); iterator.hasNext();) {
+                       dictionary= iterator.next();
+                       if (dictionary.acceptsWords())
+                               return true;
+               }
+               return false;
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellChecker#addWord(java.lang.String)
+        */
+       public void addWord(final String word) {
+               // synchronizing is necessary as this is a write access
+               Set<ISpellDictionary> copy;
+               synchronized (fDictionaries) {
+                       copy= new HashSet<ISpellDictionary>(fDictionaries);
+               }
+
+               final String addable= word.toLowerCase();
+               for (ISpellDictionary dictionary : copy) {
+                       if (dictionary.acceptsWords())
+                               dictionary.addWord(addable);
+               }
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.spelling.engine.ISpellChecker#checkWord(java.lang.String)
+        */
+       public final void checkWord(final String word) {
+               // synchronizing is necessary as this is a write access
+               fIgnored.remove(word.toLowerCase());
+       }
+
+       /*
+        * @see org.eclipse.spelling.done.ISpellChecker#execute(org.eclipse.spelling.ISpellCheckTokenizer)
+        */
+       public void execute(final ISpellCheckIterator iterator) {
+               final boolean ignoreDigits= SpellingPreferences.isIgnoreDigits();
+               final boolean ignoreMixed= SpellingPreferences.isIgnoreMixed();
+               final boolean ignoreSentence= SpellingPreferences.isIgnoreSentence();
+               final boolean ignoreUpper= SpellingPreferences.isIgnoreUpper();
+               final boolean ignoreUrls= SpellingPreferences.isIgnoreUrls();
+               final boolean ignoreNonLetters= SpellingPreferences.isIgnoreNonLetters();
+               final boolean ignoreSingleLetters= SpellingPreferences.isIgnoreSingleLetters();
+               
+               iterator.setIgnoreSingleLetters(ignoreSingleLetters);
+               
+               synchronized (fDictionaries) {
+                       Iterator<ISpellDictionary> iter= fDictionaries.iterator();
+                       while (iter.hasNext())
+                               iter.next().setStripNonLetters(ignoreNonLetters);
+               }
+
+               String word= null;
+               boolean starts= false;
+
+               while (iterator.hasNext()) {
+                       word= iterator.next();
+                       if (word != null) {
+                               // synchronizing is necessary as this is called inside the reconciler
+                               if (!fIgnored.contains(word)) {
+                                       starts= iterator.startsSentence();
+                                       if (!isCorrect(word)) {
+                                           boolean isMixed= isMixedCase(word, true);
+                                           boolean isUpper= isUpperCase(word);
+                                           boolean isDigits= isDigits(word);
+                                           boolean isUrl= isUrl(word);
+
+                                           if (!ignoreMixed && isMixed || !ignoreUpper && isUpper || !ignoreDigits && isDigits || !ignoreUrls && isUrl || !(isMixed || isUpper || isDigits || isUrl))
+                                               fireEvent(new SpellEvent(this, word, iterator.getBegin(), iterator.getEnd(), starts, false));
+                                       } else {
+                                               if (!ignoreSentence && starts && Character.isLowerCase(word.charAt(0)))
+                                                       fireEvent(new SpellEvent(this, word, iterator.getBegin(), iterator.getEnd(), true, true));
+                                       }
+                               }
+                       }
+               }
+       }
+
+       /**
+        * Fires the specified event.
+        *
+        * @param event
+        *                   Event to fire
+        */
+       protected final void fireEvent(final ISpellEvent event) {
+               // synchronizing is necessary as this is called from execute
+               Set<ISpellEventListener> copy;
+               synchronized (fListeners) {
+                       copy= new HashSet<ISpellEventListener>(fListeners);
+               }
+               for (ISpellEventListener spellEventListener : copy) {
+                       spellEventListener.handle(event);
+               }
+       }
+
+       /*
+        * @see org.eclipse.spelling.done.ISpellChecker#getProposals(java.lang.String,boolean)
+        */
+       public Set<RankedWordProposal> getProposals(final String word, final boolean sentence) {
+               // synchronizing might not be needed here since getProposals is
+               // a read-only access and only called in the same thread as
+               // the modifying methods add/removeDictionary (?)
+               Set<ISpellDictionary> copy;
+               synchronized (fDictionaries) {
+                       copy= new HashSet<ISpellDictionary>(fDictionaries);
+               }
+
+               ISpellDictionary dictionary= null;
+               final HashSet<RankedWordProposal> proposals= new HashSet<RankedWordProposal>();
+
+               for (final Iterator<ISpellDictionary> iterator= copy.iterator(); iterator.hasNext();) {
+                       dictionary= iterator.next();
+                       proposals.addAll(dictionary.getProposals(word, sentence));
+               }
+               return proposals;
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellChecker#ignoreWord(java.lang.String)
+        */
+       public final void ignoreWord(final String word) {
+               // synchronizing is necessary as this is a write access
+               fIgnored.add(word.toLowerCase());
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellChecker#isCorrect(java.lang.String)
+        */
+       public final boolean isCorrect(final String word) {
+               // synchronizing is necessary as this is called from execute
+               Set<ISpellDictionary> copy;
+               synchronized (fDictionaries) {
+                       copy= new HashSet<ISpellDictionary>(fDictionaries);
+               }
+
+               if (fIgnored.contains(word.toLowerCase()))
+                       return true;
+
+               ISpellDictionary dictionary= null;
+               for (final Iterator<ISpellDictionary> iterator= copy.iterator(); iterator.hasNext();) {
+                       dictionary= iterator.next();
+                       if (dictionary.isCorrect(word))
+                               return true;
+               }
+               return false;
+       }
+
+       /*
+        * @see org.eclipse.spelling.done.ISpellChecker#removeDictionary(org.eclipse.spelling.done.ISpellDictionary)
+        */
+       public final void removeDictionary(final ISpellDictionary dictionary) {
+               // synchronizing is necessary as this is a write access
+               fDictionaries.remove(dictionary);
+       }
+
+       /*
+        * @see org.eclipse.spelling.done.ISpellChecker#removeListener(org.eclipse.spelling.done.ISpellEventListener)
+        */
+       public final void removeListener(final ISpellEventListener listener) {
+               // synchronizing is necessary as this is a write access
+               fListeners.remove(listener);
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellChecker#getLocale()
+        */
+       public Locale getLocale() {
+               return fLocale;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/IPhoneticDistanceAlgorithm.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/IPhoneticDistanceAlgorithm.java
new file mode 100644 (file)
index 0000000..553a7e8
--- /dev/null
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling.engine;
+
+/**
+ * Interface of algorithms to compute the phonetic distance between two words.
+ */
+public interface IPhoneticDistanceAlgorithm {
+
+       /**
+        * Returns the non-negative phonetic distance between two words
+        *
+        * @param from
+        *                  The first word
+        * @param to
+        *                  The second word
+        * @return The non-negative phonetic distance between the words.
+        */
+       public int getDistance(String from, String to);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/IPhoneticHashProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/IPhoneticHashProvider.java
new file mode 100644 (file)
index 0000000..b3c2668
--- /dev/null
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling.engine;
+
+/**
+ * Interface of hashers to compute the phonetic hash for a word.
+ */
+public interface IPhoneticHashProvider {
+
+       /**
+        * Returns the phonetic hash for the word.
+        *
+        * @param word
+        *                  The word to get the phonetic hash for
+        * @return The phonetic hash for the word
+        */
+       public String getHash(String word);
+
+       /**
+        * Returns an array of characters to compute possible mutations.
+        *
+        * @return Array of possible mutator characters
+        */
+       public char[] getMutators();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellCheckEngine.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellCheckEngine.java
new file mode 100644 (file)
index 0000000..60929a9
--- /dev/null
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling.engine;
+
+import java.util.Locale;
+
+import org.eclipse.cdt.internal.ui.text.spelling.SpellingPreferences;
+
+/**
+ * Interface for a spell check engine.
+ * <p>
+ * This engine can be configured with multiple
+ * dictionaries.
+ * </p>
+ */
+public interface ISpellCheckEngine {
+
+       /**
+        * Returns a spell checker configured with the global
+        * dictionaries and the locale dictionary that correspond to the current
+        * {@linkplain SpellingPreferences#getSpellingLocale() locale preference}.
+        * <p>
+        * <strong>Note:</strong> Changes to the spelling engine dictionaries
+        * are not propagated to this spell checker.</p>
+        *
+        * @return a configured instance of the spell checker or <code>null</code> if none
+        * @throws IllegalStateException if called after being shut down
+        */
+       ISpellChecker getSpellChecker() throws IllegalStateException;
+
+       /**
+        * Returns the locale of the current spell check engine.
+        *
+        * @return the locale of the current spell check engine
+        */
+       Locale getLocale();
+
+       /**
+        * Registers a global dictionary.
+        *
+        * @param dictionary the global dictionary to register
+        */
+       void registerGlobalDictionary(ISpellDictionary dictionary);
+
+       /**
+        * Registers a dictionary tuned for the specified locale with this engine.
+        *
+        * @param locale
+        *                   The locale to register the dictionary with
+        * @param dictionary
+        *                   The dictionary to register
+        */
+       void registerDictionary(Locale locale, ISpellDictionary dictionary);
+
+       /**
+        * Shuts down this spell check engine and its associated components.
+        * <p>
+        * Further calls to this engine result in exceptions.
+        * </p>
+        */
+       void shutdown();
+
+       /**
+        * Unregisters a dictionary previously registered either by a call to
+        * <code>registerDictionary(Locale,ISpellDictionary)</code> or <code>registerDictionary(ISpellDictionary)</code>.
+        * <p>
+        * If the dictionary was not registered before, nothing happens.</p>
+        *
+        * @param dictionary the dictionary to unregister
+        */
+       void unregisterDictionary(ISpellDictionary dictionary);
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellCheckIterator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellCheckIterator.java
new file mode 100644 (file)
index 0000000..7f67568
--- /dev/null
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling.engine;
+
+import java.util.Iterator;
+
+/**
+ * Interface for iterators used for spell checking.
+ */
+public interface ISpellCheckIterator extends Iterator<String> {
+       /**
+        * Returns the begin index (inclusive) of the current word.
+        *
+        * @return The begin index of the current word
+        */
+       public int getBegin();
+
+       /**
+        * Returns the end index (exclusive) of the current word.
+        *
+        * @return The end index of the current word
+        */
+       public int getEnd();
+
+       /**
+        * Does the current word start a new sentence?
+        *
+        * @return <code>true<code> iff the current word starts a new sentence, <code>false</code> otherwise
+        */
+       public boolean startsSentence();
+
+       /**
+        * Tells whether to ignore single letters
+        * from being checked.
+        * 
+        * @param state <code>true</code> if single letters should be ignored
+        */
+       public void setIgnoreSingleLetters(boolean state);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellChecker.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellChecker.java
new file mode 100644 (file)
index 0000000..0c33e7a
--- /dev/null
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling.engine;
+
+import java.util.Locale;
+import java.util.Set;
+
+/**
+ * Interface for spell checkers.
+ */
+public interface ISpellChecker {
+
+       /**
+        * Adds a dictionary to the list of active dictionaries.
+        *
+        * @param dictionary The dictionary to add
+        */
+       void addDictionary(ISpellDictionary dictionary);
+
+       /**
+        * Adds a spell event listener to the active listeners.
+        *
+        * @param listener   The listener to add
+        */
+       void addListener(ISpellEventListener listener);
+
+       /**
+        * Returns whether this spell checker accepts word additions.
+        *
+        * @return <code>true</code> if word additions are accepted, <code>false</code> otherwise
+        */
+       boolean acceptsWords();
+
+       /**
+        * Adds the specified word to the set of correct words.
+        *
+        * @param word       The word to add to the set of correct words
+        */
+       void addWord(String word);
+
+       /**
+        * Checks the specified word until calling <code>ignoreWord(String)</code>.
+        *
+        * @param word       The word to check
+        */
+       void checkWord(String word);
+
+       /**
+        * Checks the spelling with the spell check iterator. Implementations must
+        * be thread safe as this may be called inside a reconciler thread.
+        *
+        * @param iterator   The iterator to use for spell checking
+        */
+       void execute(ISpellCheckIterator iterator);
+
+       /**
+        * Returns the ranked proposals for a word.
+        *
+        * @param word       The word to retrieve the proposals for
+        * @param sentence   <code>true</code> iff the proposals should start a
+        *                   sentence, <code>false</code> otherwise
+        * @return Set of ranked proposals for the word
+        */
+       Set<RankedWordProposal> getProposals(String word, boolean sentence);
+
+       /**
+        * Ignores the specified word until calling <code>checkWord(String)</code>.
+        *
+        * @param word The word to ignore
+        */
+       void ignoreWord(String word);
+
+       /**
+        * Is the specified word correctly spelled? Implementations must be thread
+        * safe as this may be called from within a reconciler thread.
+        *
+        * @param word The word to check its spelling
+        * @return <code>true</code> iff the word is correctly spelled, <code>false</code>
+        *               otherwise
+        */
+       boolean isCorrect(String word);
+
+       /**
+        * Remove a dictionary from the list of active dictionaries.
+        *
+        * @param dictionary The dictionary to remove
+        */
+       void removeDictionary(ISpellDictionary dictionary);
+
+       /**
+        * Removes a spell event listener from the active listeners.
+        *
+        * @param listener The listener to remove
+        */
+       void removeListener(ISpellEventListener listener);
+       
+       /**
+        * Returns the current locale of the spell check engine.
+        *
+        * @return The current locale of the engine
+        */
+       Locale getLocale();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellDictionary.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellDictionary.java
new file mode 100644 (file)
index 0000000..4231e27
--- /dev/null
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling.engine;
+
+import java.util.Set;
+
+/**
+ * Interface of dictionaries to use for spell checking.
+ */
+public interface ISpellDictionary {
+       /**
+        * Returns whether this dictionary accepts new words.
+        *
+        * @return <code>true</code> if this dictionary accepts new words, <code>false</code> otherwise
+        */
+       public boolean acceptsWords();
+
+       /**
+        * Externalizes the specified word.
+        *
+        * @param word       The word to externalize in the dictionary
+        */
+       public void addWord(String word);
+
+       /**
+        * Returns the ranked word proposals for an incorrectly spelled word.
+        *
+        * @param word       The word to retrieve the proposals for
+        * @param sentence   <code>true</code> iff the proposals start a new sentence,
+        *                   <code>false</code> otherwise
+        * @return Array of ranked word proposals
+        */
+       public Set<RankedWordProposal> getProposals(String word, boolean sentence);
+
+       /**
+        * Is the specified word correctly spelled?
+        *
+        * @param word the word to spell check
+        * @return <code>true</code> iff this word is correctly spelled, <code>false</code> otherwise
+        */
+       public boolean isCorrect(String word);
+
+       /**
+        * Is the dictionary loaded?
+        *
+        * @return <code>true</code> iff it is loaded, <code>false</code> otherwise
+        */
+       public boolean isLoaded();
+
+       /**
+        * Empties the dictionary.
+        */
+       public void unload();
+
+       /**
+        * Tells whether to strip non-letters from word boundaries.
+        * 
+        * @param state <code>true</code> if non-letters should be stripped
+        */
+       public void setStripNonLetters(boolean state);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellEvent.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellEvent.java
new file mode 100644 (file)
index 0000000..816a959
--- /dev/null
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling.engine;
+
+import java.util.Set;
+
+/**
+ * Event fired by spell checkers.
+ */
+public interface ISpellEvent {
+
+       /**
+        * Returns the begin index of the incorrectly spelled word.
+        *
+        * @return The begin index of the word
+        */
+       public int getBegin();
+
+       /**
+        * Returns the end index of the incorrectly spelled word.
+        *
+        * @return The end index of the word
+        */
+       public int getEnd();
+
+       /**
+        * Returns the proposals for the incorrectly spelled word.
+        *
+        * @return Array of proposals for the word
+        */
+       public Set<RankedWordProposal> getProposals();
+
+       /**
+        * Returns the incorrectly spelled word.
+        *
+        * @return The incorrect word
+        */
+       public String getWord();
+
+       /**
+        * Was the incorrectly spelled word found in the dictionary?
+        *
+        * @return <code>true</code> iff the word was found, <code>false</code> otherwise
+        */
+       public boolean isMatch();
+
+       /**
+        * Does the incorrectly spelled word start a new sentence?
+        *
+        * @return <code>true<code> iff the word starts a new sentence, <code>false</code> otherwise
+        */
+       public boolean isStart();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellEventListener.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellEventListener.java
new file mode 100644 (file)
index 0000000..7e298e5
--- /dev/null
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling.engine;
+
+/**
+ * Interface for spell event listeners.
+ */
+public interface ISpellEventListener {
+       /**
+        * Handles a spell event.
+        *
+        * @param event     Event to handle
+        */
+       public void handle(ISpellEvent event);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/LocaleSensitiveSpellDictionary.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/LocaleSensitiveSpellDictionary.java
new file mode 100644 (file)
index 0000000..996a517
--- /dev/null
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling.engine;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Locale;
+
+/**
+ * Platform wide read-only locale sensitive dictionary for spell checking.
+ */
+public class LocaleSensitiveSpellDictionary extends AbstractSpellDictionary {
+       /** The locale of this dictionary */
+       private final Locale fLocale;
+
+       /** The location of the dictionaries */
+       private final URL fLocation;
+
+       /**
+        * Creates a new locale sensitive spell dictionary.
+        *
+        * @param locale     The locale for this dictionary
+        * @param location   The location of the locale sensitive dictionaries
+        */
+       public LocaleSensitiveSpellDictionary(final Locale locale, final URL location) {
+               fLocation= location;
+               fLocale= locale;
+       }
+
+       /**
+        * Returns the locale of this dictionary.
+        *
+        * @return The locale of this dictionary
+        */
+       public final Locale getLocale() {
+               return fLocale;
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.AbstractSpellDictionary#getURL()
+        */
+       @Override
+       protected final URL getURL() throws MalformedURLException {
+               return new URL(fLocation, fLocale.toString() + ".dictionary");  //$NON-NLS-1$
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/PersistentSpellDictionary.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/PersistentSpellDictionary.java
new file mode 100644 (file)
index 0000000..86fcd28
--- /dev/null
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling.engine;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * Persistent modifiable word-list based dictionary.
+ */
+public class PersistentSpellDictionary extends AbstractSpellDictionary {
+       /** The word list location */
+       private final URL fLocation;
+
+       /**
+        * Creates a new persistent spell dictionary.
+        *
+        * @param url        The URL of the word list for this dictionary
+        */
+       public PersistentSpellDictionary(final URL url) {
+               fLocation= url;
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.spelling.engine.AbstractSpellDictionary#acceptsWords()
+        */
+       @Override
+       public boolean acceptsWords() {
+               return true;
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellDictionary#addWord(java.lang.String)
+        */
+       @Override
+       public void addWord(final String word) {
+               if (isCorrect(word))
+                       return;
+
+               FileOutputStream fileStream= null;
+               try {
+                       Charset charset= Charset.forName(getEncoding());
+                       ByteBuffer byteBuffer= charset.encode(word + "\n"); //$NON-NLS-1$
+                       int size= byteBuffer.limit();
+                       final byte[] byteArray;
+                       if (byteBuffer.hasArray())
+                               byteArray= byteBuffer.array();
+                       else {
+                               byteArray= new byte[size];
+                               byteBuffer.get(byteArray);
+                       }
+                       
+                       fileStream= new FileOutputStream(fLocation.getPath(), true);
+                       
+                       // Encoding UTF-16 charset writes a BOM. In which case we need to cut it away if the file isn't empty
+                       int bomCutSize= 0;
+                       if (!isEmpty() && "UTF-16".equals(charset.name())) //$NON-NLS-1$
+                               bomCutSize= 2;
+                       
+                       fileStream.write(byteArray, bomCutSize, size - bomCutSize);
+               } catch (IOException exception) {
+                       CUIPlugin.log(exception);
+                       return;
+               } finally {
+                       try {
+                               if (fileStream != null)
+                                       fileStream.close();
+                       } catch (IOException e) {
+                       }
+               }
+
+               hashWord(word);
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.AbstractSpellDictionary#getURL()
+        */
+       @Override
+       protected final URL getURL() {
+               return fLocation;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/RankedWordProposal.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/RankedWordProposal.java
new file mode 100644 (file)
index 0000000..fdce635
--- /dev/null
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling.engine;
+
+/**
+ * Ranked word proposal for quick fix and content assist.
+ */
+public class RankedWordProposal implements Comparable<RankedWordProposal> {
+       /** The word rank */
+       private int fRank;
+
+       /** The word text */
+       private final String fText;
+
+       /**
+        * Creates a new ranked word proposal.
+        *
+        * @param text       The text of this proposal
+        * @param rank       The rank of this proposal
+        */
+       public RankedWordProposal(final String text, final int rank) {
+               fText= text;
+               fRank= rank;
+       }
+
+       /*
+        * @see java.lang.Comparable#compareTo(java.lang.Object)
+        */
+       public final int compareTo(RankedWordProposal word) {
+
+               final int rank= word.getRank();
+
+               if (fRank < rank)
+                       return -1;
+
+               if (fRank > rank)
+                       return 1;
+
+               return 0;
+       }
+
+       /*
+        * @see java.lang.Object#equals(java.lang.Object)
+        */
+       @Override
+       public final boolean equals(Object object) {
+               if (object instanceof RankedWordProposal)
+                       return object.hashCode() == hashCode();
+
+               return false;
+       }
+
+       /**
+        * Returns the rank of the word
+        *
+        * @return The rank of the word
+        */
+       public final int getRank() {
+               return fRank;
+       }
+
+       /**
+        * Returns the text of this word.
+        *
+        * @return The text of this word
+        */
+       public final String getText() {
+               return fText;
+       }
+
+       /*
+        * @see java.lang.Object#hashCode()
+        */
+       @Override
+       public final int hashCode() {
+               return fText.hashCode();
+       }
+
+       /**
+        * Sets the rank of the word.
+        *
+        * @param rank       The rank to set
+        */
+       public final void setRank(final int rank) {
+               fRank= rank;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/SpellEvent.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/SpellEvent.java
new file mode 100644 (file)
index 0000000..a3be795
--- /dev/null
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.text.spelling.engine;
+
+import java.util.Set;
+
+/**
+ * Spell event fired for words detected by a spell check iterator.
+ */
+public class SpellEvent implements ISpellEvent {
+       /** The begin index of the word in the spell checkable medium */
+       private final int fBegin;
+
+       /** The spell checker that causes the event */
+       private final ISpellChecker fChecker;
+
+       /** The end index of the word in the spell checkable medium */
+       private final int fEnd;
+
+       /** Was the word found in the dictionary? */
+       private final boolean fMatch;
+
+       /** Does the word start a new sentence? */
+       private final boolean fSentence;
+
+       /** The word that causes the spell event */
+       private final String fWord;
+
+       /**
+        * Creates a new spell event.
+        *
+        * @param checker    The spell checker that causes the event
+        * @param word       The word that causes the event
+        * @param begin      The begin index of the word in the spell checkable medium
+        * @param end        The end index of the word in the spell checkable medium
+        * @param sentence   <code>true</code> iff the word starts a new sentence,
+        *                   <code>false</code> otherwise
+        * @param match      <code>true</code> iff the word was found in the dictionary,
+        *                   <code>false</code> otherwise
+        */
+       protected SpellEvent(final ISpellChecker checker, final String word, final int begin, final int end, final boolean sentence, final boolean match) {
+               fChecker= checker;
+               fEnd= end;
+               fBegin= begin;
+               fWord= word;
+               fSentence= sentence;
+               fMatch= match;
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellEvent#getBegin()
+        */
+       public final int getBegin() {
+               return fBegin;
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellEvent#getEnd()
+        */
+       public final int getEnd() {
+               return fEnd;
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellEvent#getProposals()
+        */
+       public final Set<RankedWordProposal> getProposals() {
+               return fChecker.getProposals(fWord, fSentence);
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellEvent#getWord()
+        */
+       public final String getWord() {
+               return fWord;
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellEvent#isMatch()
+        */
+       public final boolean isMatch() {
+               return fMatch;
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellEvent#isStart()
+        */
+       public final boolean isStart() {
+               return fSentence;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateEngine.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateEngine.java
new file mode 100644 (file)
index 0000000..9f55a72
--- /dev/null
@@ -0,0 +1,222 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.template;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IInformationControl;
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.templates.GlobalTemplateVariables;
+import org.eclipse.jface.text.templates.Template;
+import org.eclipse.jface.text.templates.TemplateContext;
+import org.eclipse.jface.text.templates.TemplateContextType;
+import org.eclipse.jface.text.templates.TemplateProposal;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.ICCompletionProposal;
+
+import org.eclipse.cdt.internal.corext.template.c.TranslationUnitContext;
+import org.eclipse.cdt.internal.corext.template.c.TranslationUnitContextType;
+
+import org.eclipse.cdt.internal.ui.text.c.hover.SourceViewerInformationControl;
+import org.eclipse.cdt.internal.ui.text.contentassist.RelevanceConstants;
+
+public class TemplateEngine {
+
+       private static final String $_LINE_SELECTION= "${" + GlobalTemplateVariables.LineSelection.NAME + '}'; //$NON-NLS-1$
+       private static final String $_WORD_SELECTION= "${" + GlobalTemplateVariables.WordSelection.NAME + '}'; //$NON-NLS-1$
+
+       /** The context type. */
+       private final TemplateContextType fContextType; 
+       /** The result proposals. */
+       private final ArrayList<ICompletionProposal> fProposals= new ArrayList<ICompletionProposal>();
+       /** Positions created on the key documents to remove in reset. */
+       private final Map<IDocument, Position> fPositions= new HashMap<IDocument, Position>();
+       /** Pattern to match the start of a line content */
+       private final Pattern fStartOfLineContentPattern = Pattern.compile("[^ \t]"); //$NON-NLS-1$
+
+       public static class CTemplateProposal extends TemplateProposal implements ICCompletionProposal {
+               
+               @Override
+               public IInformationControlCreator getInformationControlCreator() {
+                       return new IInformationControlCreator() {
+                               public IInformationControl createInformationControl(Shell parent) {
+                                       int orientation = SWT.LEFT_TO_RIGHT;
+                                       return new SourceViewerInformationControl(parent, false, orientation, null);
+                               }
+                       };
+               }
+
+               public CTemplateProposal(Template template, TemplateContext context, IRegion region, Image image) {
+                       super(template, context, region, image, RelevanceConstants.CASE_MATCH_RELEVANCE + RelevanceConstants.TEMPLATE_TYPE_RELEVANCE);
+               }
+
+        public String getIdString() {
+            return getDisplayString();
+        }
+        
+       }
+       /**
+        * Creates the template engine for a particular context type.
+        * See <code>TemplateContext</code> for supported context types.
+        */
+       public TemplateEngine(TemplateContextType contextType) {
+               Assert.isNotNull(contextType);
+               fContextType= contextType;
+       }
+
+       /**
+        * Empties the collector.
+        */
+       public void reset() {
+               fProposals.clear();
+               for (Entry<IDocument, Position> entry2 : fPositions.entrySet()) {
+                       Entry<IDocument, Position> entry= entry2;
+                       IDocument doc= entry.getKey();
+                       Position position= entry.getValue();
+                       doc.removePosition(position);
+               }
+               fPositions.clear();
+       }
+
+       /**
+        * Returns the array of matching templates.
+        */
+       public List<ICompletionProposal> getResults() {
+               return fProposals;
+       }
+
+       /**
+        * Inspects the context of the compilation unit around <code>completionPosition</code>
+        * and feeds the collector with proposals.
+        * @param viewer the text viewer
+        * @param completionPosition the context position in the document of the text viewer
+        * @param translationUnit the translation unit (may be <code>null</code>)
+        */
+       public void complete(ITextViewer viewer, int completionPosition, ITranslationUnit translationUnit) {
+               if (!(fContextType instanceof TranslationUnitContextType))
+                       return;
+
+           IDocument document= viewer.getDocument();
+               Point selection= viewer.getSelectedRange();
+               boolean multipleLinesSelected= areMultipleLinesSelected(viewer);
+               if (multipleLinesSelected) {
+                       // adjust line selection to start at column 1 and end at line delimiter
+                       try {
+                               IRegion startLine = document.getLineInformationOfOffset(selection.x);
+                               IRegion endLine = document.getLineInformationOfOffset(selection.x + selection.y - 1);
+                               completionPosition= selection.x= startLine.getOffset();
+                               selection.y= endLine.getOffset() + endLine.getLength() - startLine.getOffset();
+                       } catch (BadLocationException exc) {
+                       }
+               }
+               Position position= new Position(completionPosition, selection.y);
+
+               // remember selected text
+               String selectedText= null;
+               if (selection.y != 0) {
+                       try {
+                               selectedText= document.get(selection.x, selection.y);
+                               document.addPosition(position);
+                               fPositions.put(document, position);
+                       } catch (BadLocationException e) {}
+               }
+
+               TranslationUnitContext context= ((TranslationUnitContextType) fContextType).createContext(document, position, translationUnit);
+               context.setVariable("selection", selectedText); //$NON-NLS-1$
+               int start= context.getStart();
+               int end= context.getEnd();
+               IRegion region= new Region(start, end - start);
+
+               Template[] templates= CUIPlugin.getDefault().getTemplateStore().getTemplates();
+
+               Image image= CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_TEMPLATE);
+               if (selection.y == 0) {
+                       for (int i= 0; i != templates.length; i++)
+                               if (context.canEvaluate(templates[i]))
+                                       fProposals.add(new CTemplateProposal(templates[i], context, region, image));
+
+               } else {
+
+                       if (multipleLinesSelected || context.getKey().length() == 0)
+                               context.setForceEvaluation(true);
+
+                       for (int i= 0; i != templates.length; i++) {
+                               Template template= templates[i];
+                               if (context.canEvaluate(template) &&
+                                       template.getContextTypeId().equals(context.getContextType().getId()) &&
+                                       (!multipleLinesSelected && template.getPattern().indexOf($_WORD_SELECTION) != -1 || (multipleLinesSelected && template.getPattern().indexOf($_LINE_SELECTION) != -1)))
+                               {
+                                       fProposals.add(new CTemplateProposal(templates[i], context, region, image));
+                               }
+                       }
+               }
+
+       }
+
+       /**
+        * Returns <code>true</code> if one line is completely selected or if multiple lines are selected. Being
+        * completely selected means that all characters are selected except the new line characters and
+        * leading/trailing spaces.
+        * 
+        * @return <code>true</code> if one or multiple lines are selected
+        */
+       private boolean areMultipleLinesSelected(ITextViewer viewer) {
+               if (viewer == null)
+                       return false;
+
+               Point s= viewer.getSelectedRange();
+               if (s.y == 0)
+                       return false;
+
+               try {
+
+                       IDocument document= viewer.getDocument();
+                       int startLine= document.getLineOfOffset(s.x);
+                       IRegion line= document.getLineInformation(startLine);
+                       
+                       String lineContent = document.get(line.getOffset(), line.getLength());
+                       Matcher m = fStartOfLineContentPattern.matcher(lineContent);
+                       int lineContentStart = 0;
+                       if(m.find())
+                               lineContentStart = m.start() + line.getOffset();
+                       int lineContentLength = lineContent.trim().length();
+                       
+                       return s.x <= lineContentStart && s.x + s.y >= lineContentStart + lineContentLength;
+
+               } catch (BadLocationException x) {
+                       return false;
+               }
+       }
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateMessages.java
new file mode 100644 (file)
index 0000000..b2a208c
--- /dev/null
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.template;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class TemplateMessages extends NLS {
+
+       private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.text.template.TemplateMessages";//$NON-NLS-1$
+
+       private TemplateMessages() {
+               // Do not instantiate
+       }
+
+       public static String TemplateVariableProposal_error_title;
+
+       static {
+               NLS.initializeMessages(BUNDLE_NAME, TemplateMessages.class);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateMessages.properties
new file mode 100644 (file)
index 0000000..4c7d64d
--- /dev/null
@@ -0,0 +1,13 @@
+###############################################################################
+# Copyright (c) 2000, 2007 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+#     Anton Leherbauer (Wind River Systems)
+###############################################################################
+
+TemplateVariableProposal_error_title=Error applying template variable proposal
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProcessor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProcessor.java
new file mode 100644 (file)
index 0000000..78e1315
--- /dev/null
@@ -0,0 +1,172 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.template;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.contentassist.IContextInformationValidator;
+import org.eclipse.jface.text.templates.TemplateContextType;
+import org.eclipse.jface.text.templates.TemplateVariableResolver;
+
+
+
+public class TemplateVariableProcessor implements IContentAssistProcessor {
+
+       private static Comparator<TemplateVariableProposal> fgTemplateVariableProposalComparator= new Comparator<TemplateVariableProposal>() {
+               public int compare(TemplateVariableProposal arg0, TemplateVariableProposal arg1) {
+                       return arg0.getDisplayString().compareTo(arg1.getDisplayString());
+               }
+
+               @Override
+               public boolean equals(Object arg0) {
+                       return false;
+               }
+       };
+
+
+       /** the context type */
+       private TemplateContextType fContextType;
+
+       /**
+        * Sets the context type.
+        * 
+        * @param contextType the context type 
+        */
+       public void setContextType(TemplateContextType contextType) {
+               fContextType= contextType;
+       }
+
+       /**
+        * Gets the context type.
+        * 
+        * @return the context type
+        */
+       public TemplateContextType getContextType() {
+               return fContextType;
+       }
+
+       /*
+        * @see IContentAssistProcessor#computeCompletionProposals(ITextViewer, int)
+        */
+       public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer,     int documentOffset) {
+
+               if (fContextType == null)
+                       return null;
+
+               List<TemplateVariableProposal> proposals= new ArrayList<TemplateVariableProposal>();
+
+               String text= viewer.getDocument().get();
+               int start= getStart(text, documentOffset);
+               int end= documentOffset;
+
+               String string= text.substring(start, end);
+               int colon= string.indexOf(':');
+               boolean includeBrace= true;
+               int offset= start;
+               String prefix= string;
+               if (colon != -1) {
+                       includeBrace= false;
+                       offset= start + colon + 1;
+                       prefix= string.substring(colon + 1);
+               } else {
+                       int escape= string.indexOf("${"); //$NON-NLS-1$
+                       if (escape != -1) {
+                               offset= start + escape + 2;
+                               includeBrace= false;
+                               prefix= string.substring(escape + 2);
+                       }
+               }
+               if (prefix.equals("$")) //$NON-NLS-1$
+                       prefix= ""; //$NON-NLS-1$
+
+               int length= end - offset;
+
+               @SuppressWarnings("unchecked")
+               final Iterator<TemplateVariableResolver> resolvers = fContextType.resolvers();
+               while (resolvers.hasNext()) {
+                       TemplateVariableResolver variable= resolvers.next();
+
+                       if (variable.getType().startsWith(prefix))
+                               proposals.add(new TemplateVariableProposal(variable, offset, length, viewer, includeBrace));
+               }
+
+               Collections.sort(proposals, fgTemplateVariableProposalComparator);
+               return proposals.toArray(new ICompletionProposal[proposals.size()]);
+       }
+
+       /* Guesses the start position of the completion */
+       private int getStart(String string, int end) {
+               int start= end;
+
+               if (start >= 1 && string.charAt(start - 1) == '$')
+                       return start - 1;
+
+               while ((start != 0) && Character.isUnicodeIdentifierPart(string.charAt(start - 1)))
+                       start--;
+               
+               if (start >= 1 && string.charAt(start - 1) == ':') {
+                       start--;
+                       while ((start != 0) && Character.isUnicodeIdentifierPart(string.charAt(start - 1)))
+                               start--;
+               }
+
+               if (start >= 2 && string.charAt(start - 1) == '{' && string.charAt(start - 2) == '$')
+                       return start - 2;
+
+               return end;
+       }
+
+       /*
+        * @see IContentAssistProcessor#computeContextInformation(ITextViewer, int)
+        */
+       public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) {
+               return null;
+       }
+
+       /*
+        * @see IContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
+        */
+       public char[] getCompletionProposalAutoActivationCharacters() {
+               return new char[] {'$'};
+       }
+
+       /*
+        * @see IContentAssistProcessor#getContextInformationAutoActivationCharacters()
+        */
+       public char[] getContextInformationAutoActivationCharacters() {
+               return null;
+       }
+
+       /*
+        * @see IContentAssistProcessor#getErrorMessage()
+        */
+       public String getErrorMessage() {
+               return null;
+       }
+
+       /*
+        * @see IContentAssistProcessor#getContextInformationValidator()
+        */
+       public IContextInformationValidator getContextInformationValidator() {
+               return null;
+       }
+
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProposal.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProposal.java
new file mode 100644 (file)
index 0000000..ede4a45
--- /dev/null
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.template;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.templates.TemplateVariableResolver;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * A proposal for insertion of template variables.
+ */
+public class TemplateVariableProposal implements ICompletionProposal {
+
+       private TemplateVariableResolver fResolver;
+       private int fOffset;
+       private int fLength;
+       private ITextViewer fViewer;
+
+       private Point fSelection;
+       private final boolean fIncludeBrace;
+
+       /**
+        * Creates a template variable proposal.
+        *
+        * @param variable the template variable
+        * @param offset the offset to replace
+        * @param length the length to replace
+        * @param viewer the viewer
+        * @param includeBrace whether to also replace the ${ 
+        */
+       public TemplateVariableProposal(TemplateVariableResolver variable, int offset, int length, ITextViewer viewer, boolean includeBrace) {
+               fResolver= variable;
+               fOffset= offset;
+               fLength= length;
+               fViewer= viewer;
+               fIncludeBrace= includeBrace;
+       }
+
+       /*
+        * @see ICompletionProposal#apply(IDocument)
+        */
+       public void apply(IDocument document) {
+
+               try {
+                       String variable;
+                       String type= fResolver.getType();
+                       if (type.equals("dollar")) //$NON-NLS-1$
+                               variable= "$$"; //$NON-NLS-1$
+                       else if (fIncludeBrace)
+                               variable= "${" + type + '}'; //$NON-NLS-1$
+                       else
+                               variable= type;
+                       document.replace(fOffset, fLength, variable);
+                       fSelection= new Point(fOffset + variable.length(), 0);
+
+               } catch (BadLocationException e) {
+                       CUIPlugin.log(e);
+
+                       Shell shell= fViewer.getTextWidget().getShell();
+                       MessageDialog.openError(shell, TemplateMessages.TemplateVariableProposal_error_title, e.getMessage());
+               }
+       }
+
+       /*
+        * @see ICompletionProposal#getSelection(IDocument)
+        */
+       public Point getSelection(IDocument document) {
+               return fSelection;
+       }
+
+       /*
+        * @see ICompletionProposal#getAdditionalProposalInfo()
+        */
+       public String getAdditionalProposalInfo() {
+               return fResolver.getDescription();
+       }
+
+       /*
+        * @see ICompletionProposal#getDisplayString()
+        */
+       public String getDisplayString() {
+               return fResolver.getType();
+       }
+
+       /*
+        * @see ICompletionProposal#getImage()
+        */
+       public Image getImage() {
+               return null;
+       }
+
+       /*
+        * @see ICompletionProposal#getContextInformation()
+        */
+       public IContextInformation getContextInformation() {
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CColorManager.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CColorManager.java
new file mode 100644 (file)
index 0000000..8c96851
--- /dev/null
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.util;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.cdt.ui.text.IColorManager;
+
+
+/**
+ * CDT color manager.
+ */
+public class CColorManager implements IColorManager {
+       
+       protected Map<String, RGB> fKeyTable= new HashMap<String, RGB>(10);
+       protected Map<Display, Map<RGB, Color>> fDisplayTable= new HashMap<Display, Map<RGB, Color>>(2);
+       
+       /**
+        * Flag which tells if the colors are automatically disposed when
+        * the current display gets disposed.
+        */
+       private boolean fAutoDisposeOnDisplayDispose;
+
+       /**
+        * Creates a new CDT color manager which automatically
+        * disposes the allocated colors when the current display
+        * gets disposed.
+        */
+       public CColorManager() {
+               this(true);
+       }
+
+       /**
+        * Creates a new CDT color manager.
+        *
+        * @param autoDisposeOnDisplayDispose   if <code>true</code>  the color manager
+        * automatically disposes all managed colors when the current display gets disposed
+        * and all calls to {@link org.eclipse.jface.text.source.ISharedTextColors#dispose()} are ignored.
+        *
+        * @since 4.0
+        */
+       public CColorManager(boolean autoDisposeOnDisplayDispose) {
+               fAutoDisposeOnDisplayDispose= autoDisposeOnDisplayDispose;
+       }
+
+       protected void dispose(Display display) {               
+               Map<RGB, Color> colorTable= fDisplayTable.get(display);
+               if (colorTable != null) {
+                       Iterator<Color> e= colorTable.values().iterator();
+                       while (e.hasNext())
+                               (e.next()).dispose();
+               }
+       }
+       
+       /*
+        * @see IColorManager#getColor(RGB)
+        */
+       public Color getColor(RGB rgb) {
+               
+               if (rgb == null)
+                       return null;
+               
+               final Display display= Display.getCurrent();
+               Map<RGB, Color> colorTable= fDisplayTable.get(display);
+               if (colorTable == null) {
+                       colorTable= new HashMap<RGB, Color>(10);
+                       fDisplayTable.put(display, colorTable);
+                       if (fAutoDisposeOnDisplayDispose) {
+                               display.disposeExec(new Runnable() {
+                                       public void run() {
+                                               dispose(display);
+                                       }
+                               });
+                       }
+               }
+               
+               Color color= colorTable.get(rgb);
+               if (color == null) {
+                       color= new Color(Display.getCurrent(), rgb);
+                       colorTable.put(rgb, color);
+               }
+               
+               return color;
+       }
+       
+       /*
+        * @see IColorManager#dispose
+        */
+       public void dispose() {
+               if (!fAutoDisposeOnDisplayDispose)
+                       dispose(Display.getCurrent());
+       }
+
+       /*
+        * @see IColorManager#getColor(String)
+        */
+       public Color getColor(String key) {
+               
+               if (key == null)
+                       return null;
+                       
+               RGB rgb= fKeyTable.get(key);
+               return getColor(rgb);
+       }
+       
+       /*
+        * @see IColorManager#bindColor(String, RGB)
+        */
+       public void bindColor(String key, RGB rgb) {
+               Object value= fKeyTable.get(key);
+               if (value != null)
+                       throw new UnsupportedOperationException();
+               
+               fKeyTable.put(key, rgb);
+       }
+
+       /*
+        * @see IColorManager#unbindColor(String)
+        */
+       public void unbindColor(String key) {
+               fKeyTable.remove(key);
+       }
+}
+
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CWhitespaceDetector.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CWhitespaceDetector.java
new file mode 100644 (file)
index 0000000..24e543a
--- /dev/null
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.util;
+
+import org.eclipse.jface.text.rules.IWhitespaceDetector;
+
+
+/**
+ * A simple white space detector.
+ */
+public class CWhitespaceDetector implements IWhitespaceDetector {
+
+       /*
+        * @see IWhitespaceDetector#isWhitespace(char)
+        */
+       public boolean isWhitespace(char c) {
+               switch (c) {
+               case ' ':
+               case '\t':
+               case '\r':
+               case '\n':
+                       return true;
+               default:
+                       return false;
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CWordDetector.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CWordDetector.java
new file mode 100644 (file)
index 0000000..24bf90b
--- /dev/null
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.text.util;
+
+import org.eclipse.jface.text.rules.IWordDetector;
+
+
+/**
+ * A C aware word detector.
+ */
+public class CWordDetector implements IWordDetector {
+
+       /*
+        * @see org.eclipse.jface.text.rules.IWordDetector#isWordStart(char)
+        */
+       public boolean isWordStart(char c) {
+               return Character.isJavaIdentifierStart(c) || c == '@';
+       }
+
+       /*
+        * @see org.eclipse.jface.text.rules.IWordDetector#isWordPart(char)
+        */
+       public boolean isWordPart(char c) {
+               return Character.isJavaIdentifierPart(c);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/ITHModelPresenter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/ITHModelPresenter.java
new file mode 100644 (file)
index 0000000..8cb816b
--- /dev/null
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.typehierarchy;
+
+import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
+
+public interface ITHModelPresenter {
+
+       void setMessage(String msg);
+
+       void onEvent(int event);
+
+       IWorkbenchSiteProgressService getProgressService();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/Messages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/Messages.java
new file mode 100644 (file)
index 0000000..7af2a32
--- /dev/null
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.typehierarchy;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+       private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.typehierarchy.messages"; //$NON-NLS-1$
+       public static String OpenTypeHierarchyAction_label;
+       public static String OpenTypeHierarchyAction_tooltip;
+       public static String OpenTypeInHierarchyAction_errorNoDefinition;
+       public static String OpenTypeInHierarchyAction_errorTitle;
+       public static String OpenTypeInHierarchyAction_message;
+       public static String OpenTypeInHierarchyAction_title;
+       public static String OpenTypeInHierarchyAction_upperListLabel;
+       public static String THHierarchyModel_errorComputingHierarchy;
+       public static String THHierarchyModel_Job_title;
+       public static String THHistoryDropDownAction_ClearHistory;
+       public static String THHistoryDropDownAction_tooltip;
+       public static String THHistoryListAction_HistoryList_label;
+       public static String THHistoryListAction_HistoryList_title;
+       public static String THHistoryListAction_label;
+       public static String THHistoryListAction_Remove;
+       public static String THInformationControl_titleHierarchy;
+       public static String THInformationControl_titleSubHierarchy;
+       public static String THInformationControl_titleSuperHierarchy;
+       public static String THInformationControl_titleMemberInHierarchy;
+       public static String THInformationControl_titleMemberInSubHierarchy;
+       public static String THInformationControl_titleMemberInSuperHierarchy;
+       public static String THInformationControl_toggle_typeHierarchy_label;
+       public static String THInformationControl_toggle_subTypeHierarchy_label;
+       public static String THInformationControl_toggle_superTypeHierarchy_label;
+       public static String THViewPart_AutomaticOrientation;
+       public static String THViewPart_Cancel;
+       public static String THViewPart_Cancel_tooltip;
+       public static String THViewPart_CompleteTypeHierarchy;
+       public static String THViewPart_CompleteTypeHierarchy_tooltip;
+       public static String THViewPart_FocusOn;
+       public static String THViewPart_HideFields_label;
+       public static String THViewPart_HideFields_tooltip;
+       public static String THViewPart_HideNonPublic_label;
+       public static String THViewPart_HideNonPublic_tooltip;
+       public static String THViewPart_HideStatic_label;
+       public static String THViewPart_HideStatic_tooltip;
+       public static String THViewPart_HorizontalOrientation;
+       public static String THViewPart_instruction;
+       public static String THViewPart_LayoutMenu;
+       public static String THViewPart_MethodPane_title;
+       public static String THViewPart_Open;
+       public static String THViewPart_Open_tooltip;
+       public static String THViewPart_CopyTypeHierarchy;
+       public static String THViewPart_Refresh;
+       public static String THViewPart_Refresh_tooltip;
+       public static String THViewPart_ShowFileNames;
+       public static String THViewPart_ShowFileNames_tooltip;
+       public static String THViewPart_ShowInherited_label;
+       public static String THViewPart_ShowInherited_tooltip;
+       public static String THViewPart_SinglePaneOrientation;
+       public static String THViewPart_SubtypeHierarchy;
+       public static String THViewPart_SubtypeHierarchy_tooltip;
+       public static String THViewPart_SupertypeHierarchy;
+       public static String THViewPart_SupertypeHierarchy_tooltip;
+       public static String THViewPart_VerticalOrientation;
+       public static String TypeHierarchyUI_OpenFailure_message;
+       public static String TypeHierarchyUI_OpenTypeHierarchy;
+       static {
+               // initialize resource bundle
+               NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+       }
+
+       private Messages() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/OpenTypeHierarchyAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/OpenTypeHierarchyAction.java
new file mode 100644 (file)
index 0000000..49156b7
--- /dev/null
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.typehierarchy;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.actions.SelectionDispatchAction;
+
+
+
+public class OpenTypeHierarchyAction extends SelectionDispatchAction {
+
+       private ITextEditor fEditor;
+
+       public OpenTypeHierarchyAction(IWorkbenchSite site) {
+               super(site);
+               setText(Messages.OpenTypeHierarchyAction_label);
+               setToolTipText(Messages.OpenTypeHierarchyAction_tooltip);
+       }
+       
+       public OpenTypeHierarchyAction(ITextEditor editor) {
+               this(editor.getSite());
+               fEditor= editor;
+               setEnabled(fEditor != null && CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput()) != null);
+       }
+
+       @Override
+       public void run(ITextSelection sel) {
+               TypeHierarchyUI.open(fEditor, sel);
+       }
+       
+       @Override
+       public void run(IStructuredSelection selection) {
+               if (!selection.isEmpty()) {
+                       Object selectedObject= selection.getFirstElement();
+                       ICElement elem= (ICElement) getAdapter(selectedObject, ICElement.class);
+                       if (elem != null) {
+                               TypeHierarchyUI.open(elem, getSite().getWorkbenchWindow());
+                       }
+               }
+       }
+
+       @Override
+       public void selectionChanged(ITextSelection sel) {
+       }
+                       
+       @Override
+       public void selectionChanged(IStructuredSelection selection) {
+               if (selection.isEmpty()) {
+                       setEnabled(false);
+                       return;
+               }
+               
+               Object selectedObject= selection.getFirstElement();
+               ICElement elem= (ICElement) getAdapter(selectedObject, ICElement.class);
+               if (elem != null) {
+                       setEnabled(TypeHierarchyUI.isValidInput(elem));
+               }
+               else {
+                       setEnabled(false);
+               }
+       }
+
+       @SuppressWarnings("rawtypes")
+       private Object getAdapter(Object object, Class desiredClass) {
+               if (desiredClass.isInstance(object)) {
+                       return object;
+               }
+               if (object instanceof IAdaptable) {
+                       IAdaptable adaptable= (IAdaptable) object;
+                       return adaptable.getAdapter(desiredClass);
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/OpenTypeInHierarchyAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/OpenTypeInHierarchyAction.java
new file mode 100644 (file)
index 0000000..3cb16a3
--- /dev/null
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.typehierarchy;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.browser.ITypeInfo;
+import org.eclipse.cdt.core.browser.ITypeReference;
+import org.eclipse.cdt.core.model.ICElement;
+
+import org.eclipse.cdt.internal.ui.browser.opentype.ElementSelectionDialog;
+
+public class OpenTypeInHierarchyAction implements IWorkbenchWindowActionDelegate {
+
+       private static final int[] VISIBLE_TYPES = { 
+               ICElement.C_CLASS, ICElement.C_STRUCT, ICElement.C_TYPEDEF, ICElement.C_ENUMERATION,
+               ICElement.C_UNION };
+       
+       private IWorkbenchWindow fWorkbenchWindow;
+
+       public OpenTypeInHierarchyAction() {
+       }
+
+       public void run(IAction action) {
+               ElementSelectionDialog dialog = new ElementSelectionDialog(getShell());
+               configureDialog(dialog);
+               int result = dialog.open();
+               if (result != IDialogConstants.OK_ID)
+                       return;
+               
+               ITypeInfo info = (ITypeInfo) dialog.getFirstResult();
+               if (info == null)
+                       return;
+               
+               ICElement[] elements= null;
+               ITypeReference location = info.getResolvedReference();
+               if (location != null) {
+                       elements= location.getCElements();
+               }
+               if (elements == null || elements.length == 0) {
+                       String title = Messages.OpenTypeInHierarchyAction_errorTitle;
+                       String message = NLS.bind(Messages.OpenTypeInHierarchyAction_errorNoDefinition, info.getQualifiedTypeName().toString());
+                       MessageDialog.openError(getShell(), title, message);
+               } 
+               else {
+                       TypeHierarchyUI.open(elements[0], fWorkbenchWindow);
+               }
+       }
+       
+       private void configureDialog(ElementSelectionDialog dialog) {
+               dialog.setDialogSettings(getClass().getName());
+               dialog.setVisibleTypes(VISIBLE_TYPES);
+               dialog.setTitle(Messages.OpenTypeInHierarchyAction_title);
+               dialog.setUpperListLabel(Messages.OpenTypeInHierarchyAction_upperListLabel);
+               dialog.setMessage(Messages.OpenTypeInHierarchyAction_message);
+
+               if (fWorkbenchWindow != null) {
+                       IWorkbenchPage page= fWorkbenchWindow.getActivePage();
+                       if (page != null) {
+                               IWorkbenchPart part= page.getActivePart();
+                               if (part instanceof ITextEditor) {
+                                       ISelection sel= ((ITextEditor) part).getSelectionProvider().getSelection();
+                                       if (sel instanceof ITextSelection) {
+                                               String txt= ((ITextSelection) sel).getText();
+                                               if (txt.length() > 0 && txt.length() < 80) {
+                                                       dialog.setFilter(txt, true);
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+
+       private Shell getShell() {
+               return fWorkbenchWindow.getShell();
+       }
+
+       public void dispose() {
+               fWorkbenchWindow= null;
+       }
+       
+       public void init(IWorkbenchWindow window) {
+               fWorkbenchWindow= window;
+       }
+       
+       public void selectionChanged(IAction action, ISelection selection) {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THContentProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THContentProvider.java
new file mode 100644 (file)
index 0000000..cb53f81
--- /dev/null
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.typehierarchy;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+public class THContentProvider implements ITreeContentProvider {
+       private static final Object[] NO_CHILDREN= new Object[0];
+       private THHierarchyModel fModel; 
+
+       public THContentProvider() {
+       }
+    
+    final public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+       fModel= (THHierarchyModel) newInput;
+    }
+
+    public void dispose() {
+       fModel= null;
+    }
+
+    final public Object[] getElements(Object inputElement) {
+       if (fModel == null) {
+               return NO_CHILDREN;
+       }
+        return fModel.getHierarchyRootElements();
+    }
+
+    final public boolean hasChildren(Object element) {
+       if (element instanceof THNode) {
+               return ((THNode) element).hasChildren();
+       }
+       return false;
+    }
+
+    public Object[] getChildren(Object element) {
+       if (element instanceof THNode) {
+               return ((THNode) element).getChildren();
+       }
+       return NO_CHILDREN;
+    }
+
+       public Object getParent(Object element) {
+       if (element instanceof THNode) {
+               return ((THNode) element).getParent();
+       }
+       return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THDropTargetListener.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THDropTargetListener.java
new file mode 100644 (file)
index 0000000..a9fb76b
--- /dev/null
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.typehierarchy;
+
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.DropTargetListener;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbenchWindow;
+
+import org.eclipse.cdt.core.model.ICElement;
+
+
+public class THDropTargetListener implements DropTargetListener {
+       private ICElement fInput;
+       private boolean fEnabled= true;
+       private IWorkbenchWindow fWindow;
+
+    public THDropTargetListener(THViewPart view) {
+       fWindow= view.getSite().getWorkbenchWindow();
+    }
+    
+    public void setEnabled(boolean val) {
+       fEnabled= val;
+    }
+    
+    public void dragEnter(DropTargetEvent event) {
+       fInput= null;
+        checkOperation(event);
+        if (event.detail != DND.DROP_NONE) {
+                       if (LocalSelectionTransfer.getTransfer().isSupportedType(event.currentDataType)) {
+                               fInput= checkLocalSelection();
+                               if (!TypeHierarchyUI.isValidInput(fInput)) {
+                                       event.detail= DND.DROP_NONE;
+                                       fInput= null;
+                               }
+               }
+        }
+    }
+
+       private ICElement checkLocalSelection() {
+               ISelection sel= LocalSelectionTransfer.getTransfer().getSelection();
+               if (sel instanceof IStructuredSelection) {
+                       for (Iterator<?> iter = ((IStructuredSelection)sel).iterator(); iter.hasNext();) {
+                               Object element = iter.next();
+                               if (element instanceof ICElement) {
+                                       return (ICElement) element;
+                               }
+                               if (element instanceof IAdaptable) {
+                                       ICElement adapter= (ICElement) ((IAdaptable) element).getAdapter(ICElement.class);
+                                       if (adapter != null) {
+                                               return adapter;
+                                       }
+                               }
+                       }
+               }
+               return null;
+       }
+
+    public void dragLeave(DropTargetEvent event) {
+    }
+
+    public void dragOperationChanged(DropTargetEvent event) {
+        checkOperation(event);
+    }
+
+    public void dragOver(DropTargetEvent event) {
+    }
+
+    public void drop(DropTargetEvent event) {
+       if (fInput == null) {
+            Display.getCurrent().beep();
+        }
+        else {
+               TypeHierarchyUI.open(fInput, fWindow);
+        }
+    }
+
+    public void dropAccept(DropTargetEvent event) {
+    }
+    
+    private void checkOperation(DropTargetEvent event) {
+        if (fEnabled && (event.operations & DND.DROP_COPY) != 0) {
+            event.detail= DND.DROP_COPY;
+        }
+        else {
+            event.detail= DND.DROP_NONE;
+        }
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraph.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraph.java
new file mode 100644 (file)
index 0000000..85ee76f
--- /dev/null
@@ -0,0 +1,300 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.typehierarchy;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+import org.eclipse.cdt.core.dom.IName;
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.ICompositeType;
+import org.eclipse.cdt.core.dom.ast.IEnumeration;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.ITypedef;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexBinding;
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.model.ext.ICElementHandle;
+
+import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
+
+class THGraph {
+       private static final ICElement[] NO_MEMBERS = new ICElement[0];
+       private THGraphNode fInputNode= null;
+       private HashSet<THGraphNode> fRootNodes= new HashSet<THGraphNode>();
+       private HashSet<THGraphNode> fLeaveNodes= new HashSet<THGraphNode>();
+       private HashMap<ICElement, THGraphNode> fNodes= new HashMap<ICElement, THGraphNode>();
+       private boolean fFileIsIndexed;
+       
+       public THGraph() {
+       }
+
+       public THGraphNode getInputNode() {
+               return fInputNode;
+       }
+       
+       public THGraphNode getNode(ICElement elem) {
+               return fNodes.get(elem);
+       }
+
+       private THGraphNode addNode(ICElement input) {
+               THGraphNode node= fNodes.get(input); 
+
+               if (node == null) {
+                       node= new THGraphNode(input);
+                       fNodes.put(input, node);
+                       fRootNodes.add(node);
+                       fLeaveNodes.add(node);
+               }
+               return node;
+       }
+       
+       private THGraphEdge addEdge(THGraphNode from, THGraphNode to) {
+               if (createsLoopOrIsDuplicate(from, to)) {
+                       return null;
+               }
+               THGraphEdge edge= new THGraphEdge(from, to);
+               from.startEdge(edge);
+               to.endEdge(edge);
+               fRootNodes.remove(to);
+               fLeaveNodes.remove(from);
+               return edge;
+       }
+
+       private boolean createsLoopOrIsDuplicate(THGraphNode from, THGraphNode to) {
+               if (from == to) {
+                       return true;
+               }
+               if (to.getOutgoing().isEmpty() || from.getIncoming().isEmpty()) {
+                       return false;
+               }
+               
+               HashSet<THGraphNode> checked= new HashSet<THGraphNode>();
+               ArrayList<THGraphNode> stack= new ArrayList<THGraphNode>();
+               stack.add(to);
+               
+               while (!stack.isEmpty()) {
+                       THGraphNode node= stack.remove(stack.size()-1);
+                       List<THGraphEdge> out= node.getOutgoing();
+                       for (THGraphEdge edge : out) {
+                               node= edge.getEndNode();
+                               if (node == from) {
+                                       return true;
+                               }
+                               if (checked.add(node)) {
+                                       stack.add(node);
+                               }
+                       }
+               }
+               // check if edge is already there.
+               List<THGraphEdge> out= from.getOutgoing();
+               for (THGraphEdge edge : out) {
+                       if (edge.getEndNode() == to) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+       public Collection<THGraphNode> getRootNodes() {
+               return fRootNodes;
+       }
+
+       public Collection<THGraphNode> getLeaveNodes() {
+               return fLeaveNodes;
+       }
+
+       public void defineInputNode(IIndex index, ICElement input) {
+               if (input != null) {
+                       try {
+                               if (IndexUI.isIndexed(index, input)) {
+                                       fFileIsIndexed= true;
+                                       input= IndexUI.attemptConvertionToHandle(index, input);
+                                       fInputNode= addNode(input);
+                               }
+                       } catch (CoreException e) {
+                               CUIPlugin.log(e);
+                       }
+               }
+       }
+
+       public void addSuperClasses(IIndex index, IProgressMonitor monitor) {
+               if (fInputNode == null) {
+                       return;
+               }
+               HashSet<ICElement> handled= new HashSet<ICElement>();
+               ArrayList<ICElement> stack= new ArrayList<ICElement>();
+               stack.add(fInputNode.getElement());
+               handled.add(fInputNode.getElement());
+               while (!stack.isEmpty()) {
+                       if (monitor.isCanceled()) {
+                               return;
+                       }
+                       ICElement elem= stack.remove(stack.size()-1);
+                       THGraphNode graphNode= addNode(elem);
+                       try {
+                               IIndexBinding binding = IndexUI.elementToBinding(index, elem);
+                               if (binding != null) {
+                                       addMembers(index, graphNode, binding);
+                               }
+                               if (binding instanceof ICPPClassType) {
+                                       ICPPClassType ct= (ICPPClassType) binding;
+                                       ICPPBase[] bases= ct.getBases();
+                                       for (ICPPBase base : bases) {
+                                               if (monitor.isCanceled()) {
+                                                       return;
+                                               }
+                                               IName name= base.getBaseClassSpecifierName();
+                                               IBinding basecl= name != null ? index.findBinding(name) : base.getBaseClass();
+                                               ICElementHandle[] baseElems= IndexUI.findRepresentative(index, basecl);
+                                               for (ICElementHandle baseElem : baseElems) {
+                                                       THGraphNode baseGraphNode= addNode(baseElem);
+                                                       addMembers(index, baseGraphNode, basecl);                                                       
+                                                       addEdge(graphNode, baseGraphNode);
+                                                       if (handled.add(baseElem)) {
+                                                               stack.add(baseElem);
+                                                       }
+                                               }
+                                       }
+                               }
+                               else if (binding instanceof ITypedef) {
+                                       ITypedef ct= (ITypedef) binding;
+                                       IType type= ct.getType();
+                                       if (type instanceof IBinding) {
+                                               IBinding basecl= (IBinding) type;
+                                               ICElementHandle[] baseElems= IndexUI.findRepresentative(index, basecl);
+                                               if (baseElems.length > 0) {
+                                                       ICElementHandle baseElem= baseElems[0];
+                                                       THGraphNode baseGraphNode= addNode(baseElem);
+                                                       addMembers(index, baseGraphNode, basecl);                                                       
+                                                       addEdge(graphNode, baseGraphNode);
+                                                       if (handled.add(baseElem)) {
+                                                               stack.add(baseElem);
+                                                       }
+                                               }
+                                       }
+                               }
+                       } catch (CoreException e) {
+                               CUIPlugin.log(e);
+                       }
+               }
+       }
+
+       public void addSubClasses(IIndex index, IProgressMonitor monitor) {
+               if (fInputNode == null) {
+                       return;
+               }
+               HashSet<ICElement> handled= new HashSet<ICElement>();
+               ArrayList<ICElement> stack= new ArrayList<ICElement>();
+               ICElement element = fInputNode.getElement();
+               stack.add(element);
+               handled.add(element);
+               while (!stack.isEmpty()) {
+                       if (monitor.isCanceled()) {
+                               return;
+                       }
+                       ICElement elem= stack.remove(stack.size()-1);
+                       THGraphNode graphNode= addNode(elem);
+                       try {
+                               IBinding binding = IndexUI.elementToBinding(index, elem);
+                               if (binding != null) {
+                                       IIndexName[] names= index.findNames(binding, IIndex.FIND_REFERENCES | IIndex.FIND_DEFINITIONS);
+                                       for (IIndexName indexName : names) {
+                                               if (monitor.isCanceled()) {
+                                                       return;
+                                               }
+                                               if (indexName.isBaseSpecifier()) {
+                                                       IIndexName subClassDef= indexName.getEnclosingDefinition();
+                                                       if (subClassDef != null) {
+                                                               IBinding subClass= index.findBinding(subClassDef);
+                                                               ICElementHandle[] subClassElems= IndexUI.findRepresentative(index, subClass);
+                                                               if (subClassElems.length > 0) {
+                                                                       ICElementHandle subClassElem= subClassElems[0];
+                                                                       THGraphNode subGraphNode= addNode(subClassElem);
+                                                                       addMembers(index, subGraphNode, subClass);                                                      
+                                                                       addEdge(subGraphNode, graphNode);
+                                                                       if (handled.add(subClassElem)) {
+                                                                               stack.add(subClassElem);
+                                                                       }
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                       } catch (CoreException e) {
+                               CUIPlugin.log(e);
+                       }
+               }
+       }
+       
+       private void addMembers(IIndex index, THGraphNode graphNode, IBinding binding) throws CoreException {
+               if (graphNode.getMembers(false) == null) {
+                       ArrayList<ICElement> memberList= new ArrayList<ICElement>();
+                       try {
+                               if (binding instanceof ICPPClassType) {
+                                       ICPPClassType ct= (ICPPClassType) binding;
+                                       IBinding[] members= ct.getDeclaredFields();
+                                       addMemberElements(index, members, memberList);
+                                       members= ct.getDeclaredMethods();
+                                       addMemberElements(index, members, memberList);
+                               }
+                               else if (binding instanceof ICompositeType) {
+                                       ICompositeType ct= (ICompositeType) binding;
+                                       IBinding[] members= ct.getFields();
+                                       addMemberElements(index, members, memberList);
+                               }
+                               else if (binding instanceof IEnumeration) {
+                                       IEnumeration ct= (IEnumeration) binding;
+                                       IBinding[] members= ct.getEnumerators();
+                                       addMemberElements(index, members, memberList);
+                               }
+                       } catch (DOMException e) {
+                               // problem bindings should not be reported to the log.
+                       }
+                       if (memberList.isEmpty()) {
+                               graphNode.setMembers(NO_MEMBERS);
+                       }
+                       else {
+                               graphNode.setMembers(memberList.toArray(new ICElement[memberList.size()]));
+                       }
+               }
+       }
+       
+       private void addMemberElements(IIndex index, IBinding[] members, List<ICElement> memberList) 
+                       throws CoreException {
+               for (IBinding binding : members) {
+                       ICElement[] elems= IndexUI.findRepresentative(index, binding);
+                       if (elems.length > 0) {
+                               memberList.add(elems[0]);
+                       }
+               }
+       }
+
+       public boolean isTrivial() {
+               return fNodes.size() < 2;
+       }
+
+       public boolean isFileIndexed() {
+               return fFileIsIndexed;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraphEdge.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraphEdge.java
new file mode 100644 (file)
index 0000000..75f1095
--- /dev/null
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.typehierarchy;
+
+class THGraphEdge {
+       private THGraphNode fFrom;
+       private THGraphNode fTo;
+       
+       THGraphEdge(THGraphNode from, THGraphNode to) {
+               fFrom= from;
+               fTo= to;
+       }
+       
+       THGraphNode getStartNode() {
+               return fFrom;
+       }
+       
+       THGraphNode getEndNode() {
+               return fTo;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraphNode.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THGraphNode.java
new file mode 100644 (file)
index 0000000..825e8cf
--- /dev/null
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.typehierarchy;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.core.model.ICElement;
+
+class THGraphNode {
+       private List<THGraphEdge> fOutgoing= Collections.emptyList();
+       private List<THGraphEdge> fIncoming= Collections.emptyList();
+       private ICElement fElement;
+       private ICElement[] fMembers= null;
+       
+       THGraphNode(ICElement element) {
+               fElement= element;
+       }
+       
+       void startEdge(THGraphEdge outgoing) {
+               fOutgoing= addElement(fOutgoing, outgoing);
+       }
+
+       void endEdge(THGraphEdge incoming) {
+               fIncoming= addElement(fIncoming, incoming);
+       }
+       
+       ICElement getElement() {
+               return fElement;
+       }
+
+       private List<THGraphEdge> addElement(List<THGraphEdge> list, THGraphEdge elem) {
+               switch (list.size()) {
+               case 0:
+                       return Collections.singletonList(elem);
+               case 1:
+                       list= new ArrayList<THGraphEdge>(list);
+                       list.add(elem);
+                       return list;
+               }
+               list.add(elem);
+               return list;
+       }
+
+       List<THGraphEdge> getOutgoing() {
+               return fOutgoing;
+       }
+       
+       List<THGraphEdge> getIncoming() {
+               return fIncoming;
+       }
+
+       public void setMembers(ICElement[] array) {
+               fMembers= array;
+       }
+       
+       public ICElement[] getMembers(boolean addInherited) {
+               if (!addInherited) {
+                       return fMembers;
+               }
+               ArrayList<ICElement> list= new ArrayList<ICElement>();
+               collectMembers(new HashSet<THGraphNode>(), list);
+               return list.toArray(new ICElement[list.size()]);
+       }
+
+       private void collectMembers(HashSet<THGraphNode> visited, List<ICElement> list) {
+               if (visited.add(this)) {
+                       if (fMembers != null) {
+                               list.addAll(Arrays.asList(fMembers));
+                       }
+                       List<THGraphEdge> bases= getOutgoing();
+                       for (Iterator<THGraphEdge> iterator = bases.iterator(); iterator.hasNext();) {
+                               THGraphEdge edge = iterator.next();
+                               edge.getEndNode().collectMembers(visited, list);
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHierarchyModel.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHierarchyModel.java
new file mode 100644 (file)
index 0000000..5efc791
--- /dev/null
@@ -0,0 +1,436 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.typehierarchy;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
+import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
+
+class THHierarchyModel {
+    public class BackgroundJob extends Job {
+               public BackgroundJob() {
+                       super(Messages.THHierarchyModel_Job_title);
+               }
+
+               @Override
+               protected IStatus run(IProgressMonitor monitor) {
+                       return onComputeGraph(this, monitor);
+               }
+       }
+    
+       static final int TYPE_HIERARCHY = 0;
+    static final int SUB_TYPE_HIERARCHY = 1;
+    static final int SUPER_TYPE_HIERARCHY = 2;
+
+       static final int END_OF_COMPUTATION = 0;
+       
+       private static final ISchedulingRule RULE = new THSchedulingRule();
+       private static final Object[] NO_CHILDREN= new Object[0];
+
+       private ICElement fInput;
+       private int fHierarchyKind;
+       private boolean fShowInheritedMembers;
+       
+       private THGraph fGraph;
+       private THNode[] fRootNodes;
+       private THNode fSelectedTypeNode;
+       private ICElement fTypeToSelect;
+       private ICElement fSelectedMember;
+       private String fMemberSignatureToSelect;
+       
+       private Job fJob;
+       private Display fDisplay;
+       private ITHModelPresenter fView;
+       private WorkingSetFilterUI fFilter;
+       private final boolean fHideNonImplementorLeaves;
+       
+       public THHierarchyModel(ITHModelPresenter view, Display display, boolean hideNonImplementors) {
+               fDisplay= display;
+               fView= view;
+               fHideNonImplementorLeaves= hideNonImplementors;
+       }
+       
+       public ICElement getInput() {
+               return fInput;
+       }
+
+       public int getHierarchyKind() {
+               return fHierarchyKind;
+       }
+
+       public void setHierarchyKind(int hierarchyKind) {
+               fHierarchyKind = hierarchyKind;
+               computeNodes();
+       }
+
+       public boolean isShowInheritedMembers() {
+               return fShowInheritedMembers;
+       }
+
+       public void setShowInheritedMembers(boolean showInheritedMembers) {
+               fShowInheritedMembers = showInheritedMembers;
+               updateSelectedMember();
+               updateImplementors();
+       }
+
+       public Object[] getHierarchyRootElements() {
+               if (fRootNodes == null) {
+                       return new Object[] {"..."}; //$NON-NLS-1$
+               }
+               return fRootNodes;
+       }
+
+       public void setWorkingSetFilter(WorkingSetFilterUI filterUI) {
+               fFilter= filterUI;
+               computeNodes();
+       }
+
+       synchronized public void setInput(ICElement input, ICElement member) {
+               stopGraphComputation();
+               fInput= input;
+               fSelectedMember= member;
+               fMemberSignatureToSelect= TypeHierarchyUI.getLocalElementSignature(fSelectedMember);
+               fRootNodes= null;
+               fSelectedTypeNode= null;
+               fTypeToSelect= input;
+       }
+       
+       synchronized public void computeGraph() {
+               if (fJob != null) {
+                       fJob.cancel();
+               }
+               fJob= new BackgroundJob();
+               fJob.setRule(RULE);
+               IWorkbenchSiteProgressService ps= fView.getProgressService();
+               if (ps != null) {
+                       ps.schedule(fJob, 0L, true);
+               }
+               else {
+                       fJob.schedule();
+               }
+       }
+
+       synchronized public void stopGraphComputation() {
+               if (fJob != null) {
+                       fJob.cancel();
+               }
+               fJob= null;
+       }
+
+       protected IStatus onComputeGraph(Job job, IProgressMonitor monitor) {
+               THGraph graph= new THGraph();
+               try {
+                       ICProject[] scope= CoreModel.getDefault().getCModel().getCProjects();
+                       IIndex index= CCorePlugin.getIndexManager().getIndex(scope);
+                       index.acquireReadLock();
+                       try {
+                               if (monitor.isCanceled()) 
+                                       return Status.CANCEL_STATUS;
+                               graph.defineInputNode(index, fInput);
+                               graph.addSuperClasses(index, monitor);
+                               if (monitor.isCanceled()) 
+                                       return Status.CANCEL_STATUS;
+                               graph.addSubClasses(index, monitor);
+                               if (monitor.isCanceled()) 
+                                       return Status.CANCEL_STATUS;
+                       }
+                       finally {
+                               index.releaseReadLock(); 
+                       }
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               } catch (InterruptedException e) {
+                       return Status.CANCEL_STATUS;
+               }
+               finally {
+                       onJobDone(graph, job);
+               }                       
+               return Status.OK_STATUS;
+       }
+       
+       
+       protected void computeNodes() {
+               if (fGraph == null) {
+                       return;
+               }
+               boolean fwd= fHierarchyKind == SUPER_TYPE_HIERARCHY;
+               ArrayList<THNode> stack= new ArrayList<THNode>();
+               ArrayList<THNode> roots= new ArrayList<THNode>();
+               ArrayList<THNode> leafs= new ArrayList<THNode>();
+               
+               THGraphNode inputNode= fGraph.getInputNode();
+               Collection<THGraphNode> groots;
+               
+               if (fHierarchyKind == TYPE_HIERARCHY) {
+                       groots= fGraph.getLeaveNodes();
+               }
+               else {
+                       THGraphNode node= fGraph.getInputNode();
+                       if (node != null) {
+                               groots= Collections.singleton(node);
+                       }
+                       else {
+                               groots= Collections.emptySet();
+                       }
+               }
+               
+               for (THGraphNode gnode : groots) {
+                       THNode node = createNode(null, gnode, inputNode);
+                       roots.add(node);
+                       stack.add(node);
+               }
+               
+               while(!stack.isEmpty()) {
+                       THNode node= stack.remove(stack.size()-1);
+                       THGraphNode gnode= fGraph.getNode(node.getElement());
+                       List<THGraphEdge> edges= fwd ? gnode.getOutgoing() : gnode.getIncoming();
+                       if (edges.isEmpty()) {
+                               leafs.add(node);
+                       }
+                       else {
+                               for (THGraphEdge edge : edges) {
+                                       THGraphNode gchildNode= fwd ? edge.getEndNode() : edge.getStartNode();
+                                       THNode childNode= createNode(node, gchildNode, inputNode);
+                                       node.addChild(childNode);
+                                       stack.add(childNode);
+                               }
+                       }
+               }
+               fRootNodes= roots.toArray(new THNode[roots.size()]);
+               removeFilteredLeafs(fRootNodes);
+               fSelectedTypeNode= findSelection(fRootNodes);
+               if (fSelectedTypeNode != null) {
+                       fTypeToSelect= fSelectedTypeNode.getElement();
+                       updateSelectedMember();
+               }
+               
+               updateImplementors();
+               if (!fwd && fHideNonImplementorLeaves && fSelectedMember != null && fMemberSignatureToSelect != null) 
+                       removeNonImplementorLeaves(fRootNodes);
+       }
+
+       private void removeFilteredLeafs(THNode[] rootNodes) {
+               for (THNode node : rootNodes) {
+                       node.removeFilteredLeafs();
+               }
+       }
+
+       private void removeNonImplementorLeaves(THNode[] rootNodes) {
+               for (THNode node : rootNodes) {
+                       node.removeNonImplementorLeafs();
+               }
+       }
+
+       private THNode findSelection(THNode[] searchme) {
+               THNode[] result= new THNode[2];
+               findSelection(searchme, result);
+               if (result[0] != null) {
+                       return result[0];
+               }
+               return result[1];
+       }
+
+       private void findSelection(THNode[] searchme, THNode[] result) {
+               for (THNode element : searchme) {
+                       findSelection(element, result);
+                       if (result[0] != null) {
+                               break;
+                       }
+               }
+       }
+
+       private void findSelection(THNode node, THNode[] result) {
+               if (node.equals(fSelectedTypeNode)) {
+                       result[0]= node;
+                       return;
+               }
+               else if (result[1] == null) {
+                       if (node.getElement().equals(fTypeToSelect)) {
+                               result[1]= node;
+                       }
+               }
+               THNode[] children= node.getChildren();
+               findSelection(children, result);
+       }
+
+       private void updateSelectedMember() {
+               ICElement oldSelection= fSelectedMember;
+               fSelectedMember= null;
+               if (fSelectedTypeNode != null && fMemberSignatureToSelect != null) {
+                       THGraphNode gnode= fGraph.getNode(fSelectedTypeNode.getElement());
+                       if (gnode != null) {
+                               ICElement[] members= gnode.getMembers(fShowInheritedMembers);
+                               if (members != null) {
+                                       for (ICElement member : members) {
+                                               if (member.equals(oldSelection)) {
+                                                       fSelectedMember= member;
+                                                       return;
+                                               }
+                                       }
+                                       for (ICElement member : members) {
+                                               if (fMemberSignatureToSelect.equals(TypeHierarchyUI.getLocalElementSignature(member))) {
+                                                       fSelectedMember= member;
+                                                       return;
+                                               }
+                                       }
+                               }
+                       }
+               }       
+       }
+
+       private THNode createNode(THNode parent, THGraphNode gnode, THGraphNode inputNode) {
+               ICElement element = gnode.getElement();
+               THNode node= new THNode(parent, element);
+               if (gnode != inputNode && fFilter != null && !fFilter.isPartOfWorkingSet(element)) {
+                       node.setIsFiltered(true);
+               }
+               return node;
+       }
+
+       synchronized private void onJobDone(final THGraph graph, Job job) {
+               if (fJob == job) {
+                       fJob= null;
+                       fDisplay.asyncExec(new Runnable(){
+                               public void run() {
+                                       fGraph= graph;
+                                       THGraphNode inputNode= fGraph.getInputNode();
+                                       if (!fGraph.isFileIndexed()) {
+                                               fView.setMessage(IndexUI.getFileNotIndexedMessage(fInput));
+                                       }
+                                       else if (inputNode == null) {
+                                               fView.setMessage(Messages.THHierarchyModel_errorComputingHierarchy);
+                                       }
+                                       else {
+                                               if (fTypeToSelect == fInput) {
+                                                       fTypeToSelect= inputNode.getElement();
+                                               }
+                                               fInput= inputNode.getElement();
+                                       }
+                                       computeNodes();
+                                       notifyEvent(END_OF_COMPUTATION);
+                               }
+                       });
+               }
+       }
+
+       private void notifyEvent(int event) {
+               fView.onEvent(event);
+       }
+
+       synchronized public void refresh() {
+               computeGraph();
+       }
+
+       public boolean isComputed() {
+               return fRootNodes!=null;
+       }
+
+       public THNode getSelectionInHierarchy() {
+               return fSelectedTypeNode;
+       }
+
+       public void onHierarchySelectionChanged(THNode node) {
+               fSelectedTypeNode= node;
+               if (node != null) {
+                       fTypeToSelect= node.getElement();
+               }
+               updateSelectedMember();
+               updateImplementors();
+       }
+
+       public Object[] getMembers() {
+               if (fSelectedTypeNode != null) {
+                       THGraphNode gnode= fGraph.getNode(fSelectedTypeNode.getElement());
+                       Object[] result= gnode.getMembers(fShowInheritedMembers);
+                       if (result != null) {
+                               return result;
+                       }
+               }
+               return NO_CHILDREN;
+       }
+
+       public void onMemberSelectionChanged(ICElement elem) {
+               fSelectedMember= elem;
+               if (fSelectedMember != null) {
+                       fMemberSignatureToSelect= TypeHierarchyUI.getLocalElementSignature(fSelectedMember);
+               }
+               updateImplementors();
+       }
+
+       private void updateImplementors() {
+               if (fRootNodes != null) {
+                       for (THNode node : fRootNodes) {
+                               updateImplementors(node);
+                       }
+               }
+       }
+
+       private void updateImplementors(THNode node) {
+               node.setIsImplementor(isImplementor(node.getElement()));
+               THNode[] children= node.getChildren();
+               for (THNode child : children) {
+                       updateImplementors(child);
+               }
+       }
+
+       private boolean isImplementor(ICElement element) {
+               if (element == null 
+                               || fSelectedMember == null || fMemberSignatureToSelect == null) {
+                       return false;
+               }
+               THGraphNode gnode= fGraph.getNode(element);
+               if (gnode != null) {
+                       ICElement[] members= gnode.getMembers(false);
+                       if (members != null) {
+                               for (ICElement member : members) {
+                                       if (member == fSelectedMember) {
+                                               return true;
+                                       }
+                                       if (fMemberSignatureToSelect.equals(TypeHierarchyUI.getLocalElementSignature(member))) {
+                                               return true;
+                                       }
+                               }
+                       }
+               }
+               return false;
+       }
+
+       public ICElement getSelectedMember() {
+               return fSelectedMember;
+       }
+
+       public boolean hasTrivialHierarchy() {
+               if (fRootNodes == null || fRootNodes.length == 0) {
+                       return true;
+               }
+               return fRootNodes.length == 1 && !fRootNodes[0].hasChildren();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryAction.java
new file mode 100644 (file)
index 0000000..4c9d0f9
--- /dev/null
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.typehierarchy;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+import org.eclipse.cdt.core.model.ICElement;
+
+import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
+
+
+/**
+ * Action used for the include browser forward / backward buttons
+ */
+public class THHistoryAction extends Action {
+       final static long LABEL_OPTIONS= 
+               CElementLabels.M_PARAMETER_TYPES | 
+               CElementLabels.ALL_FULLY_QUALIFIED |
+               CElementLabels.MF_POST_FILE_QUALIFIED;
+       
+       private THViewPart fViewPart;
+       private ICElement fElement;
+       
+       public THHistoryAction(THViewPart hierarchyView, ICElement element) {
+        super("", AS_RADIO_BUTTON); //$NON-NLS-1$
+               fViewPart= hierarchyView;
+               fElement= element;              
+       
+               String elementName= CElementLabels.getElementLabel(element, LABEL_OPTIONS);
+               setText(elementName);
+               setImageDescriptor(getImageDescriptor(element));
+       }
+       
+       private ImageDescriptor getImageDescriptor(ICElement elem) {
+               CElementImageProvider imageProvider= new CElementImageProvider();
+               ImageDescriptor desc= imageProvider.getBaseImageDescriptor(elem, 0);
+               imageProvider.dispose();
+               return desc;
+       }
+       
+       /*
+        * @see Action#run()
+        */
+       @Override
+       public void run() {
+               fViewPart.setInput(fElement, null);
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryDropDownAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryDropDownAction.java
new file mode 100644 (file)
index 0000000..2927ae4
--- /dev/null
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.typehierarchy;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IMenuCreator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+
+import org.eclipse.cdt.core.model.ICElement;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+
+public class THHistoryDropDownAction extends Action implements IMenuCreator {
+       
+       public static class ClearHistoryAction extends Action {
+
+               private THViewPart fView;
+               
+               public ClearHistoryAction(THViewPart view) {
+                       super(Messages.THHistoryDropDownAction_ClearHistory);
+                       fView= view;
+               }
+                       
+               @Override
+               public void run() {
+                       fView.setHistoryEntries(new ICElement[0]);
+                       fView.setInput(null, null);
+               }
+       }
+
+       public static final int RESULTS_IN_DROP_DOWN= 10;
+
+       private THViewPart fHierarchyView;
+       private Menu fMenu;
+       
+       public THHistoryDropDownAction(THViewPart viewPart) {
+               fHierarchyView= viewPart;
+               fMenu= null;
+               setToolTipText(Messages.THHistoryDropDownAction_tooltip); 
+               CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "history_list.gif"); //$NON-NLS-1$
+               setMenuCreator(this);
+       }
+
+       public void dispose() {
+               // action is reused, can be called several times.
+               if (fMenu != null) {
+                       fMenu.dispose();
+                       fMenu= null;
+               }
+       }
+
+       public Menu getMenu(Menu parent) {
+               return null;
+       }
+
+       public Menu getMenu(Control parent) {
+               if (fMenu != null) {
+                       fMenu.dispose();
+               }
+               fMenu= new Menu(parent);
+               ICElement[] elements= fHierarchyView.getHistoryEntries();
+               addEntries(fMenu, elements);
+               new MenuItem(fMenu, SWT.SEPARATOR);
+               addActionToMenu(fMenu, new THHistoryListAction(fHierarchyView));
+               addActionToMenu(fMenu, new ClearHistoryAction(fHierarchyView));
+               return fMenu;
+       }
+       
+       private boolean addEntries(Menu menu, ICElement[] elements) {
+               boolean checked= false;
+               
+               int min= Math.min(elements.length, RESULTS_IN_DROP_DOWN);
+               for (int i= 0; i < min; i++) {
+                       THHistoryAction action= new THHistoryAction(fHierarchyView, elements[i]);
+                       action.setChecked(elements[i].equals(fHierarchyView.getInput()));
+                       checked= checked || action.isChecked();
+                       addActionToMenu(menu, action);
+               }
+               
+               
+               return checked;
+       }
+       
+
+       protected void addActionToMenu(Menu parent, Action action) {
+               ActionContributionItem item= new ActionContributionItem(action);
+               item.fill(parent, -1);
+       }
+
+       @Override
+       public void run() {
+               (new THHistoryListAction(fHierarchyView)).run();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryListAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryListAction.java
new file mode 100644 (file)
index 0000000..6f92d73
--- /dev/null
@@ -0,0 +1,181 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.typehierarchy;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.StatusDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.cdt.core.model.ICElement;
+
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
+
+public class THHistoryListAction extends Action {
+       
+       private class HistoryListDialog extends StatusDialog {
+               private ListDialogField<ICElement> fHistoryList;
+               private IStatus fHistoryStatus;
+               private ICElement fResult;
+               
+               private HistoryListDialog(Shell shell, ICElement[] historyEntries) {
+                       super(shell);
+                       setHelpAvailable(false);                        
+                       setTitle(Messages.THHistoryListAction_HistoryList_title); 
+                       String[] buttonLabels= new String[] { 
+                               Messages.THHistoryListAction_Remove, 
+                       };
+                                       
+                       IListAdapter<ICElement> adapter= new IListAdapter<ICElement>() {
+                               public void customButtonPressed(ListDialogField<ICElement> field, int index) {
+                                       doCustomButtonPressed();
+                               }
+                               public void selectionChanged(ListDialogField<ICElement> field) {
+                                       doSelectionChanged();
+                               }
+                               
+                               public void doubleClicked(ListDialogField<ICElement> field) {
+                                       doDoubleClicked();
+                               }                               
+                       };
+               
+                       ILabelProvider labelProvider= new CUILabelProvider(THHistoryAction.LABEL_OPTIONS, CElementImageProvider.OVERLAY_ICONS);
+                       
+                       fHistoryList= new ListDialogField<ICElement>(adapter, buttonLabels, labelProvider);
+                       fHistoryList.setLabelText(Messages.THHistoryListAction_HistoryList_label); 
+                       fHistoryList.setElements(Arrays.asList(historyEntries));
+                       
+                       ISelection sel;
+                       if (historyEntries.length > 0) {
+                               sel= new StructuredSelection(historyEntries[0]);
+                       } else {
+                               sel= new StructuredSelection();
+                       }
+                       
+                       fHistoryList.selectElements(sel);
+               }
+                       
+               /*
+                * @see Dialog#createDialogArea(Composite)
+                */
+               @Override
+               protected Control createDialogArea(Composite parent) {
+                       initializeDialogUnits(parent);
+                       
+                       Composite composite= (Composite) super.createDialogArea(parent);
+                       
+                       Composite inner= new Composite(composite, SWT.NONE);
+                       inner.setFont(parent.getFont());
+                       
+                       inner.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+                       LayoutUtil.doDefaultLayout(inner, new DialogField[] { fHistoryList }, true, 0, 0);
+                       LayoutUtil.setHeightHint(fHistoryList.getListControl(null), convertHeightInCharsToPixels(12));
+                       LayoutUtil.setHorizontalGrabbing(fHistoryList.getListControl(null), true);
+
+                       applyDialogFont(composite);             
+                       return composite;
+               }
+
+               /**
+                * Method doCustomButtonPressed.
+                */
+               private void doCustomButtonPressed() {
+                       fHistoryList.removeElements(fHistoryList.getSelectedElements());
+               }
+               
+               private void doDoubleClicked() {
+                       if (fHistoryStatus.isOK()) {
+                               okPressed();
+                       }
+               }
+
+               private void doSelectionChanged() {
+                       StatusInfo status= new StatusInfo();
+                       List<?> selected= fHistoryList.getSelectedElements();
+                       if (selected.size() != 1) {
+                               status.setError(""); //$NON-NLS-1$
+                               fResult= null;
+                       } else {
+                               fResult= (ICElement) selected.get(0);
+                       }
+                       fHistoryList.enableButton(0, fHistoryList.getSize() > selected.size() && selected.size() != 0);                 
+                       fHistoryStatus= status;
+                       updateStatus(status);   
+               }
+                               
+               public ICElement getResult() {
+                       return fResult;
+               }
+               
+               public ICElement[] getRemaining() {
+                       List<?> elems= fHistoryList.getElements();
+                       return elems.toArray(new ICElement[elems.size()]);
+               }       
+               
+               /*
+                * @see org.eclipse.jface.window.Window#configureShell(Shell)
+                */
+               @Override
+               protected void configureShell(Shell newShell) {
+                       super.configureShell(newShell);
+//                     PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, ...);
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.window.Window#create()
+                */
+               @Override
+               public void create() {
+                       setShellStyle(getShellStyle() | SWT.RESIZE);
+                       super.create();
+               }
+       }
+       
+       private THViewPart fView;
+       
+       public THHistoryListAction(THViewPart hierarchyView) {
+               fView= hierarchyView;
+               setText(Messages.THHistoryListAction_label); 
+       }
+               
+       /*
+        * @see IAction#run()
+        */
+       @Override
+       public void run() {
+               ICElement[] historyEntries= fView.getHistoryEntries();
+               HistoryListDialog dialog= new HistoryListDialog(fView.getSite().getShell(), historyEntries);
+               if (dialog.open() == Window.OK) {
+                       fView.setHistoryEntries(dialog.getRemaining());
+                       fView.setInput(dialog.getResult(), null);
+               }
+       }
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THInformationControl.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THInformationControl.java
new file mode 100644 (file)
index 0000000..169b505
--- /dev/null
@@ -0,0 +1,315 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Markus Schorn - initial API and implementation
+ *     Patrick Hofer [bug 325488]
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.typehierarchy;
+
+import java.util.Iterator;
+
+import org.eclipse.jface.bindings.Trigger;
+import org.eclipse.jface.bindings.TriggerSequence;
+import org.eclipse.jface.bindings.keys.KeyStroke;
+import org.eclipse.jface.bindings.keys.SWTKeySupport;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
+
+import com.ibm.icu.text.MessageFormat;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
+import org.eclipse.cdt.internal.ui.text.AbstractInformationControl;
+import org.eclipse.cdt.internal.ui.viewsupport.EditorOpener;
+
+public class THInformationControl extends AbstractInformationControl implements ITHModelPresenter {
+
+       private THHierarchyModel fModel;
+       private THLabelProvider fHierarchyLabelProvider;
+       private TreeViewer fHierarchyTreeViewer;
+       private boolean fDisposed= false;
+       private KeyAdapter fKeyAdapter;
+       
+       public THInformationControl(Shell parent, int shellStyle, int treeStyle) {
+               super(parent, shellStyle, treeStyle, ICEditorActionDefinitionIds.OPEN_QUICK_TYPE_HIERARCHY, true);
+       }
+
+       private KeyAdapter getKeyAdapter() {
+               if (fKeyAdapter == null) {
+                       fKeyAdapter= new KeyAdapter() {
+                               @Override
+                               public void keyPressed(KeyEvent e) {
+                                       int accelerator = SWTKeySupport.convertEventToUnmodifiedAccelerator(e);
+                                       KeyStroke keyStroke = SWTKeySupport.convertAcceleratorToKeyStroke(accelerator);
+                                       Trigger[] triggers = getInvokingCommandTriggerSequence().getTriggers();
+                                       if (triggers == null)
+                                               return;
+
+                                       for (Trigger trigger : triggers) {
+                                               if (trigger.equals(keyStroke)) {
+                                                       e.doit= false;
+                                                       toggleHierarchy();
+                                                       return;
+                                               }
+                                       }
+                               }
+                       };
+               }
+               return fKeyAdapter;
+       }
+
+       @Override
+       protected boolean hasHeader() {
+               return true;
+       }
+
+       @Override
+       protected Text createFilterText(Composite parent) {
+               Text text= super.createFilterText(parent);
+               text.addKeyListener(getKeyAdapter());
+               return text;
+       }
+
+       @Override
+       protected TreeViewer createTreeViewer(Composite parent, int style) {
+               Display display= getShell().getDisplay();
+               fModel= new THHierarchyModel(this, display, true);
+               fHierarchyLabelProvider= new THLabelProvider(display, fModel);
+               fHierarchyLabelProvider.setMarkImplementers(false);
+               fHierarchyTreeViewer = new TreeViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+               fHierarchyTreeViewer.setContentProvider(new THContentProvider());
+               fHierarchyTreeViewer.setLabelProvider(fHierarchyLabelProvider);
+               fHierarchyTreeViewer.setSorter(new ViewerSorter());
+               fHierarchyTreeViewer.setUseHashlookup(true);
+               fHierarchyTreeViewer.getTree().addKeyListener(getKeyAdapter());
+               return fHierarchyTreeViewer;
+       }
+
+       protected void onOpenElement(ISelection selection) {
+               ICElement elem= (ICElement) getSelectedElement();
+               if (elem != null) {
+                       try {
+                               EditorOpener.open(CUIPlugin.getActivePage(), elem);
+                       } catch (CModelException e) {
+                               CUIPlugin.log(e);
+                       }
+               }
+       }
+
+       @Override
+       public void setInput(Object input) {
+               if (input instanceof ICElement[]) {
+                       ICElement[] splitInput= (ICElement[]) input;
+                       if (TypeHierarchyUI.isValidTypeInput(splitInput[0])) {
+                               fModel.setInput(splitInput[0], splitInput[1]);
+                               fHierarchyLabelProvider.setHideNonImplementers(splitInput[1] != null);
+                               fHierarchyTreeViewer.setInput(fModel);
+                               fModel.computeGraph();
+                               updateTitle();
+                       }
+               }
+       }
+
+       protected void updateTitle() {
+               setTitleText(computeTitleText());
+       }
+       
+       private String computeTitleText() {
+               final ICElement input = fModel.getInput();
+               final ICElement member= fModel.getSelectedMember();
+               String elemName= member != null ? member.getElementName() : input.getElementName();
+               return NLS.bind(getFormatString(fModel.getHierarchyKind(), member != null), elemName);
+       }
+       
+       private String getFormatString(int hierarchyKind, boolean forMember) {
+               switch (hierarchyKind) {
+               case THHierarchyModel.SUB_TYPE_HIERARCHY:
+                       return forMember
+                                       ? Messages.THInformationControl_titleMemberInSubHierarchy
+                                       : Messages.THInformationControl_titleSubHierarchy;
+                       
+               case THHierarchyModel.SUPER_TYPE_HIERARCHY:
+                       return forMember 
+                                       ? Messages.THInformationControl_titleMemberInSuperHierarchy
+                                       : Messages.THInformationControl_titleSuperHierarchy;
+                       
+               case THHierarchyModel.TYPE_HIERARCHY:
+               default:
+                       return forMember 
+                                       ? Messages.THInformationControl_titleMemberInHierarchy
+                                       : Messages.THInformationControl_titleHierarchy;
+               }
+       }
+
+       @Override
+       protected String getId() {
+               return "org.eclipse.cdt.internal.ui.typehierarchy.QuickHierarchy"; //$NON-NLS-1$
+       }
+
+       @Override
+       protected Object getSelectedElement() {
+               THNode node= selectionToNode(fHierarchyTreeViewer.getSelection());
+               if (node != null) {
+                       ICElement elem= node.getElement();
+                       if (node.isImplementor()) {
+                               fModel.onHierarchySelectionChanged(node);
+                               ICElement melem= fModel.getSelectedMember();
+                               if (melem != null) {
+                                       return melem;
+                               }
+                       }
+                       return elem;
+               }
+               return null;
+       }
+
+       private THNode selectionToNode(ISelection selection) {
+               if (selection instanceof IStructuredSelection) {
+                       IStructuredSelection ss= (IStructuredSelection) selection;
+                       for (Iterator<?> iter = ss.iterator(); iter.hasNext(); ) {
+                               Object cand= iter.next();
+                               if (cand instanceof THNode) {
+                                       return (THNode) cand;
+                               }
+                       }
+               }
+               return null;
+       }
+
+       @Override
+       public void widgetDisposed(DisposeEvent event) {
+               fDisposed= true;
+               super.widgetDisposed(event);
+       }
+
+       public void onEvent(int event) {
+               if (!fDisposed) {
+                       switch (event) {
+                       case THHierarchyModel.END_OF_COMPUTATION:
+                               if (fModel.hasTrivialHierarchy()) {
+                                       fHierarchyLabelProvider.setHideNonImplementers(false);
+                               }
+                               fHierarchyTreeViewer.refresh();
+                               THNode selection= fModel.getSelectionInHierarchy();
+                               if (selection != null) {
+                                       fHierarchyTreeViewer.setSelection(new StructuredSelection(selection));
+                                       fHierarchyTreeViewer.expandToLevel(selection, 2);
+                               }
+                               break;
+                       }               
+               }
+       }
+
+       public void setMessage(String msg) {
+       }
+
+       public IWorkbenchSiteProgressService getProgressService() {
+               return null;
+       }
+
+       @Override
+       protected String getStatusFieldText() {
+               TriggerSequence sequence = getInvokingCommandTriggerSequence();
+               String keyName= ""; //$NON-NLS-1$
+               if (sequence != null)
+                       keyName= sequence.format();
+
+               String message= ""; //$NON-NLS-1$
+               switch (fModel.getHierarchyKind()) {
+               case THHierarchyModel.TYPE_HIERARCHY:
+                       message = Messages.THInformationControl_toggle_superTypeHierarchy_label;
+                       break;
+
+               case THHierarchyModel.SUB_TYPE_HIERARCHY:
+                       message = Messages.THInformationControl_toggle_typeHierarchy_label;
+                       break;
+
+               case THHierarchyModel.SUPER_TYPE_HIERARCHY:
+                       message = Messages.THInformationControl_toggle_subTypeHierarchy_label;
+                       break;
+
+               default:
+                       break;
+               }
+               return MessageFormat.format(message, new Object[] {keyName} );
+       }
+
+       @Override
+       protected void selectFirstMatch() {
+               Tree tree= fHierarchyTreeViewer.getTree();
+               Object element= findElement(tree.getItems());
+               if (element != null)
+                       fHierarchyTreeViewer.setSelection(new StructuredSelection(element), true);
+               else
+                       fHierarchyTreeViewer.setSelection(StructuredSelection.EMPTY);
+       }
+
+       protected void toggleHierarchy() {
+               fHierarchyTreeViewer.getTree().setRedraw(false);
+               switch (fModel.getHierarchyKind()) {
+               case THHierarchyModel.TYPE_HIERARCHY:
+                       fModel.setHierarchyKind(THHierarchyModel.SUPER_TYPE_HIERARCHY);
+                       break;
+
+               case THHierarchyModel.SUB_TYPE_HIERARCHY:
+                       fModel.setHierarchyKind(THHierarchyModel.TYPE_HIERARCHY);
+                       break;
+
+               case THHierarchyModel.SUPER_TYPE_HIERARCHY:
+                       fModel.setHierarchyKind(THHierarchyModel.SUB_TYPE_HIERARCHY);
+                       break;
+
+               default:
+                       break;
+               }
+               fHierarchyTreeViewer.refresh();
+               fHierarchyTreeViewer.expandAll();
+               fHierarchyTreeViewer.getTree().setRedraw(true);
+               updateStatusFieldText();
+               updateTitle();
+       }
+       
+       private THNode findElement(TreeItem[] items) {
+               for (TreeItem item2 : items) {
+                       Object item= item2.getData();
+                       THNode element= null;
+                       if (item instanceof THNode) {
+                               element= (THNode)item;
+                               if (fStringMatcher == null)
+                                       return element;
+       
+                               String label= fHierarchyLabelProvider.getText(element);
+                               if (fStringMatcher.match(label))
+                                       return element;
+                       }
+                       element= findElement(item2.getItems());
+                       if (element != null)
+                               return element;
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THInformationProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THInformationProvider.java
new file mode 100644 (file)
index 0000000..a255533
--- /dev/null
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.typehierarchy;
+
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.information.IInformationProvider;
+import org.eclipse.jface.text.information.IInformationProviderExtension;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+public class THInformationProvider implements IInformationProviderExtension, IInformationProvider {
+
+       private ITextEditor fEditor;
+
+       public THInformationProvider(ITextEditor editor) {
+               fEditor= editor;
+       }
+
+       public Object getInformation2(ITextViewer textViewer, IRegion subject) {
+               return fEditor == null ? null : TypeHierarchyUI.getInput(fEditor, subject);
+       }
+
+       public String getInformation(ITextViewer textViewer, IRegion subject) {
+               return null;
+       }
+
+       public IRegion getSubject(ITextViewer textViewer, int offset) {
+               return new Region(offset, 0);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THLabelProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THLabelProvider.java
new file mode 100644 (file)
index 0000000..783b271
--- /dev/null
@@ -0,0 +1,170 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.typehierarchy;
+
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ILabelDecorator;
+import org.eclipse.jface.viewers.StyledCellLabelProvider;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
+import org.eclipse.cdt.ui.CElementImageDescriptor;
+
+import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.ImageImageDescriptor;
+
+public class THLabelProvider extends AppearanceAwareLabelProvider {
+
+       private final static long LABEL_OPTIONS_SIMPLE= CElementLabels.ALL_FULLY_QUALIFIED | CElementLabels.M_PARAMETER_TYPES | CElementLabels.M_APP_RETURNTYPE | CElementLabels.F_APP_TYPE_SIGNATURE;
+       private final static long LABEL_OPTIONS_SHOW_FILES= LABEL_OPTIONS_SIMPLE | CElementLabels.MF_POST_FILE_QUALIFIED;
+       
+    private CUILabelProvider fCLabelProvider= new CUILabelProvider(LABEL_OPTIONS_SIMPLE, 0);
+    private THHierarchyModel fModel;
+    private HashMap<String, Image> fCachedImages= new HashMap<String, Image>();
+       private Color fColorInactive;
+       private boolean fMarkImplementers= true;
+       private boolean fHideNonImplementers= false;
+    
+    public THLabelProvider(Display display, THHierarchyModel model) {
+        fColorInactive= display.getSystemColor(SWT.COLOR_DARK_GRAY);
+        fModel= model;
+    }
+    
+    @Override
+       public Image getImage(Object element) {
+       if (element instanceof THNode) {
+            THNode node= (THNode) element;
+            ICElement decl= node.getElement();
+            if (decl != null) {
+               if (node.isFiltered() ||
+                               (fHideNonImplementers && !node.isImplementor())) {
+                       fCLabelProvider.setImageFlags(CElementImageProvider.LIGHT_TYPE_ICONS);
+               }
+               Image image= fCLabelProvider.getImage(decl);
+                       fCLabelProvider.setImageFlags(0);
+                if (image != null) {
+                       return decorateImage(image, node);
+                }
+            }
+        }
+        else if (element instanceof ICElement) {
+               return fCLabelProvider.getImage(element);
+        }
+        return super.getImage(element);
+    }
+
+    @Override
+       public String getText(Object element) {
+        if (element instanceof THNode) {
+            THNode node= (THNode) element;
+            ICElement decl= node.getElement();
+            if (decl != null) {
+               String label= fCLabelProvider.getText(decl);
+               return decorateText(label, element);
+            }
+        }
+        return super.getText(element);
+    }
+    
+    @Override
+       public StyledString getStyledText(Object element) {
+               if (element instanceof THNode) {
+            THNode node= (THNode) element;
+            ICElement decl= node.getElement();
+            if (decl != null) {
+               StyledString label= fCLabelProvider.getStyledText(decl);
+               if (fModel.isShowInheritedMembers()) {
+               }
+               String decorated= decorateText(label.getString(), element);
+                       if (decorated != null) {
+                               return StyledCellLabelProvider.styleDecoratedString(decorated, StyledString.DECORATIONS_STYLER, label);
+                       }
+                       return label;
+            }
+        }
+               return super.getStyledText(element);
+       }
+    
+       @Override
+       public void dispose() {
+        fCLabelProvider.dispose();
+        for (Iterator<Image> iter = fCachedImages.values().iterator(); iter.hasNext();) {
+            Image image = iter.next();
+            image.dispose();
+        }
+        fCachedImages.clear();
+        super.dispose();
+    }
+
+    private Image decorateImage(Image image, THNode node) {
+        int flags= 0;        
+        if (node.hasChildren()) {
+            if (fModel.getHierarchyKind() == THHierarchyModel.SUPER_TYPE_HIERARCHY) {
+               flags |= CElementImageDescriptor.RELATES_TO;
+            }
+            else {
+                flags |= CElementImageDescriptor.REFERENCED_BY;
+            }
+        }
+        if (fMarkImplementers && node.isImplementor()) {
+               flags |= CElementImageDescriptor.DEFINES;
+        }
+
+        String key= image.toString()+String.valueOf(flags);
+        Image result= fCachedImages.get(key);
+        if (result == null) {
+            ImageDescriptor desc= new CElementImageDescriptor(
+                    new ImageImageDescriptor(image), flags, new Point(20,16));
+            result= desc.createImage();
+            fCachedImages.put(key, result);
+        }
+        return result;
+    }
+
+    @Override
+       public Color getForeground(Object element) {
+       if (element instanceof THNode) {
+               THNode node= (THNode) element;
+               if (node.isFiltered()) {
+                       return fColorInactive;
+               }
+       }
+       return null;
+    }
+
+    public void setShowFiles(boolean show) {
+               fCLabelProvider.setTextFlags(show ? LABEL_OPTIONS_SHOW_FILES : LABEL_OPTIONS_SIMPLE);
+    }
+
+       public void setMarkImplementers(boolean val) {
+               fMarkImplementers= val;
+       }
+
+       public void setHideNonImplementers(boolean val) {
+               fHideNonImplementers= val;
+       }
+       
+       @Override
+       public void addLabelDecorator(ILabelDecorator decorator) {
+               super.addLabelDecorator(decorator);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THMemberContentProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THMemberContentProvider.java
new file mode 100644 (file)
index 0000000..8ec56d6
--- /dev/null
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.typehierarchy;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+public class THMemberContentProvider implements IStructuredContentProvider {
+       private static final Object[] NO_CHILDREN= new Object[0];
+       private THHierarchyModel fModel; 
+
+       public THMemberContentProvider() {
+       }
+    
+    final public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+       fModel= (THHierarchyModel) newInput;
+    }
+
+    public void dispose() {
+       fModel= null;
+    }
+
+    final public Object[] getElements(Object inputElement) {
+       if (fModel == null) {
+               return NO_CHILDREN;
+       }
+        return fModel.getMembers();
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THNode.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THNode.java
new file mode 100644 (file)
index 0000000..9b22c8a
--- /dev/null
@@ -0,0 +1,143 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.typehierarchy;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+
+import org.eclipse.cdt.core.model.ICElement;
+
+import org.eclipse.cdt.internal.ui.util.CoreUtility;
+
+public class THNode implements IAdaptable {
+       private THNode fParent;
+       private ICElement fElement;
+       private List<THNode> fChildren= Collections.emptyList();
+    
+    private int fHashCode;
+    private boolean fIsFiltered;
+    private boolean fIsImplementor;
+
+    /**
+     * Creates a new node for the include browser
+     */
+    public THNode(THNode parent, ICElement decl) {
+        fParent= parent;
+        fElement= decl;
+        fHashCode= computeHashCode();
+    }
+    
+       private int computeHashCode() {
+        int hashCode= 0;
+        if (fParent != null) {
+            hashCode= fParent.hashCode() * 31;
+        }
+        if (fElement != null) {
+               hashCode+= fElement.hashCode();
+        }
+        return hashCode;
+    }   
+
+    @Override
+       public int hashCode() {
+        return fHashCode;
+    }
+    
+    @Override
+       public boolean equals(Object o) {
+               if (!(o instanceof THNode)) {
+                       return false;
+               }
+
+               THNode rhs = (THNode) o;
+               if (fHashCode != rhs.fHashCode) {
+                       return false;
+               }
+
+               return CoreUtility.safeEquals(fElement, rhs.fElement);
+    }
+    
+       /**
+     * Returns the parent node or <code>null</code> for the root node.
+     */
+    public THNode getParent() {
+        return fParent;
+    }
+
+
+       public ICElement getElement() {
+               return fElement;
+       }
+       
+       @SuppressWarnings({ "unchecked", "rawtypes" })
+       public Object getAdapter(Class adapter) {
+               if (adapter.isAssignableFrom(ICElement.class)) {
+                       return getElement();
+               }
+               return null;
+       }
+       
+       public boolean isFiltered() {
+               return fIsFiltered;
+       }
+
+       public void setIsFiltered(boolean val) {
+               fIsFiltered= val;
+       }
+
+       public void addChild(THNode childNode) {
+               if (fChildren.isEmpty()) {
+                       fChildren= new ArrayList<THNode>();
+               }                       
+               fChildren.add(childNode);
+       }
+
+       public boolean hasChildren() {
+               return !fChildren.isEmpty();
+       }
+
+       public THNode[] getChildren() {
+               return fChildren.toArray(new THNode[fChildren.size()]);
+       }
+
+       public void setIsImplementor(boolean val) {
+               fIsImplementor= val;
+       }
+
+       public boolean isImplementor() {
+               return fIsImplementor;
+       }
+
+       public void removeFilteredLeafs() {
+               for (Iterator<THNode> iterator = fChildren.iterator(); iterator.hasNext();) {
+                       THNode child = iterator.next();
+                       child.removeFilteredLeafs();
+                       if (child.isFiltered() && !child.hasChildren()) {
+                               iterator.remove();
+                       }
+               }
+       }
+
+       public void removeNonImplementorLeafs() {
+               for (Iterator<THNode> iterator = fChildren.iterator(); iterator.hasNext();) {
+                       THNode child = iterator.next();
+                       child.removeNonImplementorLeafs();
+                       if (!child.isImplementor() && !child.hasChildren()) {
+                               iterator.remove();
+                       }
+               }
+       }
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THSchedulingRule.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THSchedulingRule.java
new file mode 100644 (file)
index 0000000..aaf9000
--- /dev/null
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.typehierarchy;
+
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+
+public class THSchedulingRule implements ISchedulingRule {
+
+       public boolean contains(ISchedulingRule rule) {
+               return rule==this;
+       }
+
+       public boolean isConflicting(ISchedulingRule rule) {
+               return rule==this;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THViewPart.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THViewPart.java
new file mode 100644 (file)
index 0000000..a5294fd
--- /dev/null
@@ -0,0 +1,1133 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *    IBM Corporation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.typehierarchy;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.action.ToolBarManager;
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.IOpenListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.OpenEvent;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.ACC;
+import org.eclipse.swt.accessibility.AccessibleAdapter;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.custom.ViewForm;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DropTarget;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.contexts.IContextActivation;
+import org.eclipse.ui.contexts.IContextService;
+import org.eclipse.ui.navigator.ICommonMenuConstants;
+import org.eclipse.ui.part.PageBook;
+import org.eclipse.ui.part.ViewPart;
+import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
+
+import com.ibm.icu.text.MessageFormat;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IDeclaration;
+import org.eclipse.cdt.core.model.IMember;
+import org.eclipse.cdt.core.model.IMethodDeclaration;
+import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.actions.CdtActionConstants;
+import org.eclipse.cdt.ui.actions.OpenViewActionGroup;
+import org.eclipse.cdt.ui.refactoring.actions.CRefactoringActionGroup;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.IContextMenuConstants;
+import org.eclipse.cdt.internal.ui.actions.CopyTreeAction;
+import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
+import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
+import org.eclipse.cdt.internal.ui.viewsupport.AdaptingSelectionProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
+import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCLabelProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.EditorOpener;
+import org.eclipse.cdt.internal.ui.viewsupport.SelectionProviderMediator;
+import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
+
+/**
+ * The view part for the include browser.
+ */
+public class THViewPart extends ViewPart implements ITHModelPresenter {
+       private static final int MAX_HISTORY_SIZE = 10;
+    private static final String TRUE = String.valueOf(true);
+    private static final String KEY_WORKING_SET_FILTER = "workingSetFilter"; //$NON-NLS-1$
+    private static final String KEY_SHOW_FILES= "showFilesInLabels"; //$NON-NLS-1$
+    private static final String KEY_SHOW_INHERITED_MEMBERS= "showInheritedMembers"; //$NON-NLS-1$
+    private static final String KEY_FILTER_FIELDS= "filterFields"; //$NON-NLS-1$
+    private static final String KEY_FILTER_STATIC= "filterStatic"; //$NON-NLS-1$
+    private static final String KEY_FILTER_NON_PUBLIC= "filterNonPublic"; //$NON-NLS-1$
+    private static final String KEY_MODE= "hierarchyMode"; //$NON-NLS-1$
+    private static final String KEY_ORIENTATION= "viewOrientation"; //$NON-NLS-1$
+       private static final String KEY_SPLITTER_W1 = "splitterWeight1"; //$NON-NLS-1$
+       private static final String KEY_SPLITTER_W2 = "splitterWeight2"; //$NON-NLS-1$
+
+       // constants for view orientation
+       private static final int ORIENTATION_AUTOMATIC = 0;
+       private static final int ORIENTATION_HORIZONTAL = 1;
+       private static final int ORIENTATION_VERTICAL = 2;
+       private static final int ORIENTATION_SINGLE = 3;
+       
+       // options for label provider
+       private static final long MEMBER_LABEL_OPTIONS_SIMPLE = CElementLabels.M_PARAMETER_TYPES | CElementLabels.M_APP_RETURNTYPE | CElementLabels.F_APP_TYPE_SIGNATURE;
+       private static final long MEMBER_LABEL_OPTIONS_QUALIFIED = MEMBER_LABEL_OPTIONS_SIMPLE | CElementLabels.ALL_POST_QUALIFIED;
+       private static final int MEMBER_ICON_OPTIONS = CElementImageProvider.OVERLAY_ICONS;
+    
+       // state information
+    private IMemento fMemento;
+    private boolean fShowsMessage= true;
+       private int fCurrentViewOrientation= -1;
+       private boolean fInComputeOrientation= false;
+       private ArrayList<ICElement> fHistoryEntries= new ArrayList<ICElement>(MAX_HISTORY_SIZE);
+       private int fIgnoreSelectionChanges= 0;
+
+    // widgets
+    private PageBook fPagebook;
+    private Label fInfoText;
+       private SashForm fSplitter;
+       private ViewForm fHierarchyViewForm;
+       private ViewForm fMemberViewForm;
+       private CLabel fMemberLabel;
+
+    // viewers and helpers
+       private THHierarchyModel fModel;
+       private THLabelProvider fHierarchyLabelProvider;
+       private CUILabelProvider fMemberLabelProvider;
+       private TableViewer fMemberViewer;
+       private TreeViewer fHierarchyTreeViewer;
+
+    // filters
+       private WorkingSetFilterUI fWorkingSetFilterUI;
+       private ViewerFilter fFieldFilter;
+       private ViewerFilter fStaticFilter;
+       private ViewerFilter fNonPublicFilter;
+
+    // actions
+       private ToolBarManager fMemberToolbarManager;
+    
+       private Action fShowSuperTypeHierarchyAction;
+    private Action fShowSubTypeHierarchyAction;
+    private Action fShowTypeHierarchyAction;
+    
+    private Action fShowFilesInLabelsAction;
+    private Action fRefreshAction;
+    private Action fCancelAction;
+       private Action fHistoryAction;
+       private Action fOpenElement;
+       private CopyTreeAction fCopyAction;
+
+       private Action fHorizontalOrientation;
+       private Action fVerticalOrientation;
+       private Action fAutomaticOrientation;
+       private Action fSingleOrientation;
+
+    private Action fShowInheritedMembersAction;
+       private Action fFieldFilterAction;
+       private Action fStaticFilterAction;
+       private Action fNonPublicFilterAction;
+
+       // action groups
+       private OpenViewActionGroup fOpenViewActionGroup;
+       private SelectionSearchGroup fSelectionSearchGroup;
+       private CRefactoringActionGroup fRefactoringActionGroup;
+       private IContextActivation fContextActivation;
+    
+    @Override
+       public void setFocus() {
+        fPagebook.setFocus();
+    }
+
+    public void setMessage(String msg) {
+        fInfoText.setText(msg);
+        fPagebook.showPage(fInfoText);
+        fShowsMessage= true;
+        updateDescription();
+        updateActionEnablement();
+    }
+    
+    void setInput(ICElement inputType, ICElement inputMember) {
+       if (inputType == null) {
+            setMessage(Messages.THViewPart_instruction);
+            fHierarchyTreeViewer.setInput(null);
+            fMemberViewer.setInput(null);
+            return;
+       }
+        fShowsMessage= false;
+        fModel.setInput(inputType, inputMember);
+        fHierarchyTreeViewer.setInput(fModel);
+        fMemberViewer.setInput(fModel);
+        fPagebook.showPage(fSplitter);
+        updateDescription();
+       updateHistory(inputType);
+       updateActionEnablement();
+       fModel.computeGraph();
+    }
+
+       @Override
+       public void createPartControl(Composite parent) {
+        fPagebook = new PageBook(parent, SWT.NULL);
+        createInfoPage();
+        createViewerPage();
+                
+        initSelectionProvider();
+
+        initDragAndDrop();
+        createActions();
+        createContextMenu();
+
+        setMessage(Messages.THViewPart_instruction);
+        initializeActionStates();
+        
+       IContextService ctxService = (IContextService) getSite().getService(IContextService.class);
+       if (ctxService != null) {
+               fContextActivation= ctxService.activateContext(CUIPlugin.CVIEWS_SCOPE);
+       }
+
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(fPagebook, ICHelpContextIds.TYPE_HIERARCHY_VIEW);
+       }
+       
+       @Override
+       public void dispose() {
+               if (fContextActivation != null) {
+                       IContextService ctxService = (IContextService)getSite().getService(IContextService.class);
+               if (ctxService != null) {
+                       ctxService.deactivateContext(fContextActivation);
+               }
+               }
+
+               if (fOpenViewActionGroup != null) {
+                       fOpenViewActionGroup.dispose();
+                       fOpenViewActionGroup= null;
+               }
+               if (fSelectionSearchGroup != null) {
+                       fSelectionSearchGroup.dispose();
+                       fSelectionSearchGroup= null;
+               }
+               if (fRefactoringActionGroup != null) {
+                       fRefactoringActionGroup.dispose();
+                       fRefactoringActionGroup= null;
+               }
+               if (fWorkingSetFilterUI != null) {
+                       fWorkingSetFilterUI.dispose();
+                       fWorkingSetFilterUI= null;
+               }
+               super.dispose();
+       }
+       
+       private void initSelectionProvider() {
+               SelectionProviderMediator mediator= new SelectionProviderMediator();
+               mediator.addViewer(fHierarchyTreeViewer);
+               mediator.addViewer(fMemberViewer);
+               getSite().setSelectionProvider(new AdaptingSelectionProvider(ICElement.class, mediator));
+       }
+
+    private void initializeActionStates() {
+        int mode= THHierarchyModel.TYPE_HIERARCHY;
+        int orientation= ORIENTATION_AUTOMATIC;
+        boolean showFiles= false;
+        boolean showInheritedMembers= false;
+        boolean hideFields= false;
+        boolean hideStatic= false;
+        boolean hideNonPublic= false;
+        int[] weights= {35,65};
+        
+        if (fMemento != null) {
+            showFiles= TRUE.equals(fMemento.getString(KEY_SHOW_FILES));
+            showInheritedMembers= TRUE.equals(fMemento.getString(KEY_SHOW_INHERITED_MEMBERS));
+            hideFields= TRUE.equals(fMemento.getString(KEY_FILTER_FIELDS));
+            hideStatic= TRUE.equals(fMemento.getString(KEY_FILTER_STATIC));
+            hideNonPublic= TRUE.equals(fMemento.getString(KEY_FILTER_NON_PUBLIC));
+            Integer intval= fMemento.getInteger(KEY_MODE);
+            if (intval != null) {
+               mode= intval.intValue();
+            }
+            intval= fMemento.getInteger(KEY_ORIENTATION);
+            if (intval != null) {
+               orientation= intval.intValue();
+            }
+            intval= fMemento.getInteger(KEY_SPLITTER_W1);
+            Integer intval2= fMemento.getInteger(KEY_SPLITTER_W2);
+            if (intval != null && intval2 != null) {
+               weights[0]= intval.intValue();
+               weights[1]= intval2.intValue();
+            }
+        }
+        restoreOrientation(orientation);
+        restoreHierarchyKind(mode);
+               fSplitter.setWeights(weights);
+
+               fShowInheritedMembersAction.setChecked(showInheritedMembers);
+               fShowInheritedMembersAction.run();
+               
+               fFieldFilterAction.setChecked(hideFields);
+               fFieldFilterAction.run();
+               fStaticFilterAction.setChecked(hideStatic);
+               fStaticFilterAction.run();
+               fNonPublicFilterAction.setChecked(hideNonPublic);
+               fNonPublicFilterAction.run();
+
+               fHierarchyLabelProvider.setShowFiles(showFiles);
+        fShowFilesInLabelsAction.setChecked(showFiles);
+  
+               fMemberToolbarManager.update(true);
+    }
+
+       @Override
+       public void init(IViewSite site, IMemento memento) throws PartInitException {
+        fMemento= memento;
+        super.init(site, memento);
+    }
+
+
+    @Override
+       public void saveState(IMemento memento) {
+        if (fWorkingSetFilterUI != null) {
+               fWorkingSetFilterUI.saveState(memento, KEY_WORKING_SET_FILTER);
+        }
+       memento.putString(KEY_SHOW_INHERITED_MEMBERS, String.valueOf(fShowInheritedMembersAction.isChecked()));
+        memento.putString(KEY_SHOW_FILES, String.valueOf(fShowFilesInLabelsAction.isChecked()));
+        memento.putString(KEY_FILTER_FIELDS, String.valueOf(fFieldFilterAction.isChecked()));
+        memento.putString(KEY_FILTER_STATIC, String.valueOf(fStaticFilterAction.isChecked()));
+        memento.putString(KEY_FILTER_NON_PUBLIC, String.valueOf(fNonPublicFilterAction.isChecked()));
+               int[] weights= fSplitter.getWeights();
+        memento.putInteger(KEY_SPLITTER_W1, weights[0]);
+        memento.putInteger(KEY_SPLITTER_W2, weights[1]);
+        if (fAutomaticOrientation.isChecked()) {
+               memento.putInteger(KEY_ORIENTATION, ORIENTATION_AUTOMATIC);
+        }
+        else {
+               memento.putInteger(KEY_ORIENTATION, fCurrentViewOrientation);
+        }
+        super.saveState(memento);
+    }
+
+    private void createContextMenu() {
+        IWorkbenchPartSite site = getSite();
+       
+        // hierarchy
+       MenuManager manager = new MenuManager();
+       manager.setRemoveAllWhenShown(true);
+       manager.addMenuListener(new IMenuListener() {
+               public void menuAboutToShow(IMenuManager m) {
+                       onContextMenuAboutToShow(m, true);
+               }
+       });
+       Menu menu = manager.createContextMenu(fHierarchyTreeViewer.getControl());
+       fHierarchyTreeViewer.getControl().setMenu(menu);
+       site.registerContextMenu(CUIPlugin.ID_TYPE_HIERARCHY, manager, fHierarchyTreeViewer); 
+
+       manager = new MenuManager();
+       manager.setRemoveAllWhenShown(true);
+       manager.addMenuListener(new IMenuListener() {
+               public void menuAboutToShow(IMenuManager m) {
+                       onContextMenuAboutToShow(m, false);
+               }
+       });
+       menu = manager.createContextMenu(fMemberViewer.getControl());
+       fMemberViewer.getControl().setMenu(menu);
+       site.registerContextMenu(CUIPlugin.ID_TYPE_HIERARCHY + ".members", manager, fMemberViewer); //$NON-NLS-1$
+    }
+
+       protected void onContextMenuAboutToShow(IMenuManager menu, boolean hierarchyView) {
+               CUIPlugin.createStandardGroups(menu);
+               StructuredViewer viewer= hierarchyView ? (StructuredViewer) fHierarchyTreeViewer : fMemberViewer;
+               final ICElement elem= selectionToElement(viewer.getSelection());
+               if (elem != null) {
+                       menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, fOpenElement);
+                       if (hierarchyView && !elem.equals(fModel.getInput())) {
+                               String label= MessageFormat.format(Messages.THViewPart_FocusOn, 
+                                               new Object[] {
+                                               CElementLabels.getTextLabel(elem, CElementLabels.ALL_FULLY_QUALIFIED | CElementLabels.M_PARAMETER_TYPES)
+                               });
+                               menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, new Action(label) {
+                                       @Override
+                                       public void run() {
+                                               setInput(elem, null);
+                                       }
+                               });
+                       }
+               }
+               
+               // action groups
+               ISelection selection = getSite().getSelectionProvider().getSelection();
+               if (OpenViewActionGroup.canActionBeAdded(selection)) {
+                       fOpenViewActionGroup.fillContextMenu(menu);
+               }
+
+               if (hierarchyView && fCopyAction.canActionBeAdded()) {
+               menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, fCopyAction);
+               }
+
+               if (SelectionSearchGroup.canActionBeAdded(selection)) {
+                       fSelectionSearchGroup.fillContextMenu(menu);
+               }
+               fRefactoringActionGroup.fillContextMenu(menu);
+       }
+
+       private void createViewerPage() {
+               fSplitter= new SashForm(fPagebook, SWT.VERTICAL);
+               fSplitter.setLayoutData(new GridData(GridData.FILL_BOTH));
+               fSplitter.addControlListener(new ControlListener() {
+                       public void controlMoved(ControlEvent e) {
+                       }
+                       public void controlResized(ControlEvent e) {
+                               if (fAutomaticOrientation.isChecked()) {
+                                       setOrientation(ORIENTATION_AUTOMATIC);
+                               }
+                       }
+               });
+
+               fHierarchyViewForm= new ViewForm(fSplitter, SWT.NONE);
+               Control hierarchyControl= createHierarchyControl(fHierarchyViewForm);
+               fHierarchyViewForm.setContent(hierarchyControl);
+                               
+               fMemberViewForm= new ViewForm(fSplitter, SWT.NONE);
+               Control memberControl= createMemberControl(fMemberViewForm);
+               fMemberViewForm.setContent(memberControl);
+               
+               fMemberLabel = new CLabel(fMemberViewForm, SWT.NONE);
+       fMemberLabel.setText(Messages.THViewPart_MethodPane_title); 
+               fMemberViewForm.setTopLeft(fMemberLabel);
+       }
+   
+       private Control createMemberControl(ViewForm parent) {
+               fMemberLabelProvider= new AppearanceAwareLabelProvider(MEMBER_LABEL_OPTIONS_SIMPLE, MEMBER_ICON_OPTIONS);
+               fMemberViewer = new TableViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+               fMemberViewer.setContentProvider(new THMemberContentProvider());
+               fMemberViewer.setLabelProvider(new DecoratingCLabelProvider(fMemberLabelProvider, true));
+               fMemberViewer.addOpenListener(new IOpenListener() {
+                       public void open(OpenEvent event) {
+                               onOpenElement(event.getSelection());
+                       }
+               });
+       fMemberViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+                       public void selectionChanged(final SelectionChangedEvent event) {
+                               onMemberSelectionChanged(event);
+                       }
+       });
+       fMemberViewer.setSorter(new ViewerSorter() {
+               @Override
+                       public int category(Object element) {
+                       if (element instanceof ICElement) {
+                               ICElement celem= (ICElement)element;
+                               switch (celem.getElementType()) {
+                                       case ICElement.C_FIELD: return 1;
+                                       case ICElement.C_METHOD: 
+                                       case ICElement.C_METHOD_DECLARATION:
+                                               IMethodDeclaration md= (IMethodDeclaration) celem;
+                                               try {
+                                                               if (md.isConstructor()) return 2;
+                                                               if (md.isDestructor()) return 3;
+                                                       } catch (CModelException e) {
+                                                               CUIPlugin.log(e);
+                                                       }
+                                               break;
+                               }
+                       }
+                       return 10;
+               }
+       });   
+        
+               final ToolBar memberToolBar= new ToolBar(parent, SWT.FLAT | SWT.WRAP);
+               parent.setTopCenter(memberToolBar);
+               
+               memberToolBar.getAccessible().addAccessibleListener(new AccessibleAdapter() {
+                       @Override
+                       public void getName(AccessibleEvent e) {
+                               if (e.childID != ACC.CHILDID_SELF) {
+                                       ToolItem item = memberToolBar.getItem(e.childID);
+                                       if (item != null) {
+                                               String toolTip = item.getToolTipText();
+                                               if (toolTip != null) {
+                                                       e.result = toolTip;
+                                               }
+                                       }
+                               }
+                       }
+               });
+
+               fMemberToolbarManager= new ToolBarManager(memberToolBar);
+       return fMemberViewer.getControl();
+       }
+
+       protected void onMemberSelectionChanged(SelectionChangedEvent event) {
+               if (fIgnoreSelectionChanges == 0) {
+                       ICElement elem= selectionToElement(event.getSelection());
+                       fModel.onMemberSelectionChanged(elem);
+                       fHierarchyTreeViewer.refresh();
+               }
+       }
+
+       private Control createHierarchyControl(ViewForm parent) {
+               Display display= getSite().getShell().getDisplay();
+               fModel= new THHierarchyModel(this, display, false);
+               fHierarchyLabelProvider= new THLabelProvider(display, fModel);
+       fHierarchyTreeViewer = new TreeViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
+       fHierarchyTreeViewer.setContentProvider(new THContentProvider());
+       fHierarchyTreeViewer.setLabelProvider(new DecoratingCLabelProvider(fHierarchyLabelProvider, true));
+       fHierarchyTreeViewer.setSorter(new ViewerSorter());
+       fHierarchyTreeViewer.setUseHashlookup(true);
+       fHierarchyTreeViewer.addOpenListener(new IOpenListener() {
+                       public void open(OpenEvent event) {
+                               onOpenElement(event.getSelection());
+                       }
+               });
+
+       fHierarchyTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+                       public void selectionChanged(final SelectionChangedEvent event) {
+                               onHierarchySelectionChanged(event);
+                       }
+       });
+                   
+       return fHierarchyTreeViewer.getControl();
+       }       
+
+    protected void onHierarchySelectionChanged(SelectionChangedEvent event) {
+               if (fIgnoreSelectionChanges == 0) {
+                       THNode node= selectionToNode(event.getSelection());
+                       fModel.onHierarchySelectionChanged(node);
+                       updateView();
+               }
+       }
+
+       private void createInfoPage() {
+       fInfoText = new Label(fPagebook, SWT.TOP | SWT.LEFT | SWT.WRAP);
+    }
+
+    private void initDragAndDrop() {
+        THDropTargetListener dropListener= new THDropTargetListener(this);
+        Transfer[] localSelectionTransfer= new Transfer[] {    LocalSelectionTransfer.getTransfer() };
+        DropTarget dropTarget = new DropTarget(fPagebook, DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT);
+        dropTarget.setTransfer(localSelectionTransfer);
+        dropTarget.addDropListener(dropListener);
+    }
+
+    private void createActions() {
+       // action groups
+       fOpenViewActionGroup= new OpenViewActionGroup(this);
+       fOpenViewActionGroup.setSuppressTypeHierarchy(true);
+       fOpenViewActionGroup.setSuppressProperties(true);
+       fOpenViewActionGroup.setEnableIncludeBrowser(true);
+       fSelectionSearchGroup= new SelectionSearchGroup(getSite());
+       fRefactoringActionGroup= new CRefactoringActionGroup(this);
+       
+       fWorkingSetFilterUI= new WorkingSetFilterUI(this, fMemento, KEY_WORKING_SET_FILTER) {
+            @Override
+                       protected void onWorkingSetChange() {
+                updateWorkingSetFilter(this);
+            }
+            @Override
+                       protected void onWorkingSetNameChange() {
+                updateDescription();
+            }
+        };
+
+               fHorizontalOrientation= new Action(Messages.THViewPart_HorizontalOrientation, IAction.AS_RADIO_BUTTON) {
+                       @Override
+                       public void run() {
+                               setOrientation(ORIENTATION_HORIZONTAL);
+                       }
+               };
+               CPluginImages.setImageDescriptors(fHorizontalOrientation, CPluginImages.T_LCL, CPluginImages.IMG_LCL_HORIZONTAL_ORIENTATION);
+
+               fVerticalOrientation= new Action(Messages.THViewPart_VerticalOrientation, IAction.AS_RADIO_BUTTON) {
+                       @Override
+                       public void run() {
+                               setOrientation(ORIENTATION_VERTICAL);
+                       }
+               };
+               CPluginImages.setImageDescriptors(fVerticalOrientation, CPluginImages.T_LCL, CPluginImages.IMG_LCL_VERTICAL_ORIENTATION);
+
+               fAutomaticOrientation= new Action(Messages.THViewPart_AutomaticOrientation, IAction.AS_RADIO_BUTTON) {
+                       @Override
+                       public void run() {
+                               setOrientation(ORIENTATION_AUTOMATIC);
+                       }
+               };
+               CPluginImages.setImageDescriptors(fAutomaticOrientation, CPluginImages.T_LCL, CPluginImages.IMG_LCL_AUTOMATIC_ORIENTATION);
+
+               fSingleOrientation= new Action(Messages.THViewPart_SinglePaneOrientation, IAction.AS_RADIO_BUTTON) {
+                       @Override
+                       public void run() {
+                               setOrientation(ORIENTATION_SINGLE);
+                       }
+               };
+               CPluginImages.setImageDescriptors(fSingleOrientation, CPluginImages.T_LCL, CPluginImages.IMG_LCL_SINGLE_ORIENTATION);
+
+               fShowTypeHierarchyAction= new Action(Messages.THViewPart_CompleteTypeHierarchy, IAction.AS_RADIO_BUTTON) {
+                       @Override
+                       public void run() {
+                               if (isChecked()) {
+                                       onSetHierarchyKind(THHierarchyModel.TYPE_HIERARCHY);
+                               }
+                       }
+        };
+        fShowTypeHierarchyAction.setToolTipText(Messages.THViewPart_CompleteTypeHierarchy_tooltip);
+        CPluginImages.setImageDescriptors(fShowTypeHierarchyAction, CPluginImages.T_LCL, CPluginImages.IMG_LCL_TYPE_HIERARCHY);       
+
+               fShowSubTypeHierarchyAction= new Action(Messages.THViewPart_SubtypeHierarchy, IAction.AS_RADIO_BUTTON) {
+                       @Override
+                       public void run() {
+                               if (isChecked()) {
+                                       onSetHierarchyKind(THHierarchyModel.SUB_TYPE_HIERARCHY);
+                               }
+                       }
+        };
+        fShowSubTypeHierarchyAction.setToolTipText(Messages.THViewPart_SubtypeHierarchy_tooltip);
+        CPluginImages.setImageDescriptors(fShowSubTypeHierarchyAction, CPluginImages.T_LCL, CPluginImages.IMG_LCL_SUB_TYPE_HIERARCHY);       
+
+               fShowSuperTypeHierarchyAction= new Action(Messages.THViewPart_SupertypeHierarchy, IAction.AS_RADIO_BUTTON) {
+                       @Override
+                       public void run() {
+                               if (isChecked()) {
+                                       onSetHierarchyKind(THHierarchyModel.SUPER_TYPE_HIERARCHY);
+                               }
+                       }
+        };
+        fShowSuperTypeHierarchyAction.setToolTipText(Messages.THViewPart_SupertypeHierarchy_tooltip);
+        CPluginImages.setImageDescriptors(fShowSuperTypeHierarchyAction, CPluginImages.T_LCL, CPluginImages.IMG_LCL_SUPER_TYPE_HIERARCHY);       
+
+               fShowInheritedMembersAction= new Action(Messages.THViewPart_ShowInherited_label, IAction.AS_CHECK_BOX) {
+                       @Override
+                       public void run() {
+                               onShowInheritedMembers(isChecked());
+                       }
+        };
+        fShowInheritedMembersAction.setToolTipText(Messages.THViewPart_ShowInherited_tooltip);
+        CPluginImages.setImageDescriptors(fShowInheritedMembersAction, CPluginImages.T_LCL, CPluginImages.IMG_LCL_SHOW_INHERITED_MEMBERS);       
+
+        fFieldFilter= new ViewerFilter() {
+            @Override
+                       public boolean select(Viewer viewer, Object parentElement, Object element) {
+                if (element instanceof ICElement) {
+                       ICElement node= (ICElement) element;
+                       switch (node.getElementType()) {
+                       case ICElement.C_ENUMERATOR:
+                       case ICElement.C_FIELD:
+                       case ICElement.C_TEMPLATE_VARIABLE:
+                       case ICElement.C_VARIABLE:
+                       case ICElement.C_VARIABLE_DECLARATION:
+                       case ICElement.C_VARIABLE_LOCAL:
+                               return false;
+                       }
+                }
+                return true;
+            }
+        };
+        fStaticFilter= new ViewerFilter() {
+            @Override
+                       public boolean select(Viewer viewer, Object parentElement, Object element) {
+                if (element instanceof IDeclaration) {
+                       IDeclaration node= (IDeclaration) element;
+                       try {
+                                               return !node.isStatic();
+                                       } catch (CModelException e) {
+                                               CUIPlugin.log(e);
+                                       }
+                }
+                return true;
+            }
+        };
+        fNonPublicFilter= new ViewerFilter() {
+            @Override
+                       public boolean select(Viewer viewer, Object parentElement, Object element) {
+                if (element instanceof IMember) {
+                       IMember node= (IMember) element;
+                       try {
+                                               return ASTAccessVisibility.PUBLIC.equals(node.getVisibility());
+                                       } catch (CModelException e) {
+                                               CUIPlugin.log(e);
+                                       }
+                }
+                return true;
+            }
+        };
+        fFieldFilterAction= new Action(Messages.THViewPart_HideFields_label, IAction.AS_CHECK_BOX) {
+            @Override
+                       public void run() {
+                if (isChecked()) {
+                    fMemberViewer.addFilter(fFieldFilter);
+                }
+                else {
+                       fMemberViewer.removeFilter(fFieldFilter);
+                }
+            }
+        };
+        fFieldFilterAction.setToolTipText(Messages.THViewPart_HideFields_tooltip);
+        CPluginImages.setImageDescriptors(fFieldFilterAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_FIELDS);       
+
+        fStaticFilterAction= new Action(Messages.THViewPart_HideStatic_label, IAction.AS_CHECK_BOX) {
+            @Override
+                       public void run() {
+                if (isChecked()) {
+                    fMemberViewer.addFilter(fStaticFilter);
+                } else {
+                       fMemberViewer.removeFilter(fStaticFilter);
+                }
+            }
+        };
+        fStaticFilterAction.setToolTipText(Messages.THViewPart_HideStatic_tooltip);
+        CPluginImages.setImageDescriptors(fStaticFilterAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_STATIC);       
+
+        fNonPublicFilterAction= new Action(Messages.THViewPart_HideNonPublic_label, IAction.AS_CHECK_BOX) {
+            @Override
+                       public void run() {
+                if (isChecked()) {
+                    fMemberViewer.addFilter(fNonPublicFilter);
+                } else {
+                       fMemberViewer.removeFilter(fNonPublicFilter);
+                }
+            }
+        };
+        fNonPublicFilterAction.setToolTipText(Messages.THViewPart_HideNonPublic_tooltip);
+        CPluginImages.setImageDescriptors(fNonPublicFilterAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_PUBLIC);       
+
+        fOpenElement= new Action(Messages.THViewPart_Open) {
+               @Override
+                       public void run() {
+                       onOpenElement(getSite().getSelectionProvider().getSelection());
+               }
+        };
+        fOpenElement.setToolTipText(Messages.THViewPart_Open_tooltip);
+        fOpenElement.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_DECL);
+
+        fShowFilesInLabelsAction= new Action(Messages.THViewPart_ShowFileNames, IAction.AS_CHECK_BOX) {
+            @Override
+                       public void run() {
+                onShowFilesInLabels(isChecked());
+            }
+        };
+        fShowFilesInLabelsAction.setToolTipText(Messages.THViewPart_ShowFileNames_tooltip);
+
+        fRefreshAction = new Action(Messages.THViewPart_Refresh) {
+            @Override
+                       public void run() {
+                onRefresh();
+            }
+        };
+        fRefreshAction.setToolTipText(Messages.THViewPart_Refresh_tooltip); 
+        CPluginImages.setImageDescriptors(fRefreshAction, CPluginImages.T_LCL, CPluginImages.IMG_REFRESH);       
+
+        fCancelAction = new Action(Messages.THViewPart_Cancel) {
+            @Override
+                       public void run() {
+                onCancel();
+            }
+        };
+        fCancelAction.setToolTipText(Messages.THViewPart_Cancel_tooltip); 
+        CPluginImages.setImageDescriptors(fCancelAction, CPluginImages.T_LCL, CPluginImages.IMG_LCL_CANCEL);       
+
+        fHistoryAction = new THHistoryDropDownAction(this);
+
+        fCopyAction= new CopyTypeHierarchyAction(this, fHierarchyTreeViewer);
+
+        // setup action bar
+        // global action hooks
+        IActionBars actionBars = getViewSite().getActionBars();
+        fRefactoringActionGroup.fillActionBars(actionBars);
+        fOpenViewActionGroup.fillActionBars(actionBars);
+        fSelectionSearchGroup.fillActionBars(actionBars);
+        
+        actionBars.setGlobalActionHandler(CdtActionConstants.OPEN_DECLARATION, fOpenElement);
+        actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), fRefreshAction);
+        actionBars.updateActionBars();
+        
+        // local toolbar
+        IToolBarManager tm = actionBars.getToolBarManager();
+        tm.add(fShowTypeHierarchyAction);
+        tm.add(fShowSuperTypeHierarchyAction);
+        tm.add(fShowSubTypeHierarchyAction);
+               tm.add(fHistoryAction);
+        tm.add(fRefreshAction);
+        tm.add(fCancelAction);
+
+        // local menu
+        IMenuManager mm = actionBars.getMenuManager();
+
+        fWorkingSetFilterUI.fillActionBars(actionBars);
+        mm.add(new Separator(IContextMenuConstants.GROUP_SHOW));
+        mm.add(fShowTypeHierarchyAction);
+        mm.add(fShowSuperTypeHierarchyAction);
+        mm.add(fShowSubTypeHierarchyAction);
+        mm.add(new Separator(IContextMenuConstants.GROUP_VIEWER_SETUP));
+
+        MenuManager submenu= new MenuManager(Messages.THViewPart_LayoutMenu);
+               submenu.add(fHorizontalOrientation);
+               submenu.add(fVerticalOrientation);
+               submenu.add(fAutomaticOrientation);
+               submenu.add(fSingleOrientation);
+
+               mm.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, submenu);
+        mm.add(new Separator());
+        mm.add(fShowFilesInLabelsAction);
+        
+        // member toolbar
+        fMemberToolbarManager.add(fShowInheritedMembersAction);
+        fMemberToolbarManager.add(new Separator());
+        fMemberToolbarManager.add(fFieldFilterAction);
+        fMemberToolbarManager.add(fStaticFilterAction);
+        fMemberToolbarManager.add(fNonPublicFilterAction);        
+    }
+            
+       protected void onOpenElement(ISelection selection) {
+       ICElement elem= selectionToElement(selection);
+       openElement(elem);
+       }
+
+       private void openElement(ICElement elem) {
+               if (elem != null) {
+                       IWorkbenchPage page= getSite().getPage();
+                       try {
+                               EditorOpener.open(page, elem);
+                       } catch (CModelException e) {
+                               CUIPlugin.log(e);
+                       }
+               }
+       }
+
+    protected void onRefresh() {
+       fModel.refresh();
+       updateActionEnablement();
+    }
+
+    protected void onCancel() {
+       fModel.stopGraphComputation();
+       updateView();
+    }
+
+    protected void onShowFilesInLabels(boolean show) {
+       fHierarchyLabelProvider.setShowFiles(show);
+       fHierarchyTreeViewer.refresh();
+    }
+
+    private void updateHistory(ICElement input) {
+       if (input != null) {
+               fHistoryEntries.remove(input);
+               fHistoryEntries.add(0, input);
+               if (fHistoryEntries.size() > MAX_HISTORY_SIZE) {
+                       fHistoryEntries.remove(MAX_HISTORY_SIZE-1);
+               }
+       }
+       }
+    
+    private void updateDescription() {
+        String message= ""; //$NON-NLS-1$
+        if (!fShowsMessage) {
+               ICElement elem= getInput();
+            if (elem != null) {
+                String label;
+               
+                // label
+                label= CElementLabels.getElementLabel(elem, 0);
+               
+                // scope
+                IWorkingSet workingSet= fWorkingSetFilterUI.getWorkingSet();
+               if (workingSet == null) {       
+                       message= label;
+               } else {
+                       String scope= workingSet.getLabel();
+                       message= MessageFormat.format("{0} - {1}", new Object[] {label, scope}); //$NON-NLS-1$
+               }
+               
+               label= ""; //$NON-NLS-1$
+               Image image= null;
+               THNode node= fModel.getSelectionInHierarchy();
+               if (node != null) {
+                       elem= node.getElement();
+                       if (elem != null) {
+                               label= CElementLabels.getElementLabel(elem, 0);
+                               image= fHierarchyLabelProvider.getImage(elem);
+                       }
+               }
+               fMemberLabel.setText(label);
+               fMemberLabel.setImage(image);
+            }
+        }
+        setContentDescription(message);
+    }
+    
+       private void updateActionEnablement() {
+               fHistoryAction.setEnabled(!fHistoryEntries.isEmpty());
+               fRefreshAction.setEnabled(!fShowsMessage);
+               fCancelAction.setEnabled(!fShowsMessage && !fModel.isComputed());
+               fShowSubTypeHierarchyAction.setEnabled(!fShowsMessage);
+               fShowSuperTypeHierarchyAction.setEnabled(!fShowsMessage);
+               fShowTypeHierarchyAction.setEnabled(!fShowsMessage);
+       }
+
+    private void updateWorkingSetFilter(WorkingSetFilterUI filterUI) {
+       fModel.setWorkingSetFilter(filterUI);
+       updateView();
+    }
+    
+    public void onSetHierarchyKind(int kind) {
+       if (fModel.getHierarchyKind() != kind) {
+               fModel.setHierarchyKind(kind);
+               updateView();
+       }
+    }
+
+    protected void onShowInheritedMembers(boolean show) {
+       if (fModel.isShowInheritedMembers() != show) {
+               fModel.setShowInheritedMembers(show);
+               fMemberLabelProvider.setTextFlags(show ? 
+                               MEMBER_LABEL_OPTIONS_QUALIFIED : MEMBER_LABEL_OPTIONS_SIMPLE);
+               updateViewers();
+       }
+    }
+
+    private void updateViewers() {
+       if (!fShowsMessage) {
+               fIgnoreSelectionChanges++;
+               try {
+                       fHierarchyLabelProvider.setMarkImplementers(!fModel.hasTrivialHierarchy());
+                       fHierarchyTreeViewer.refresh();
+                       fMemberViewer.refresh();
+                       setSelections();
+               } finally {
+                       fIgnoreSelectionChanges--;
+               }
+       }
+       }
+
+    private void updateView() {
+       if (!fShowsMessage) {
+               fIgnoreSelectionChanges++;
+               try {
+                       updateViewers();
+                       updateDescription();
+                       updateActionEnablement();
+               } finally {
+                       fIgnoreSelectionChanges--;
+               }
+       }
+       }
+
+       private void setSelections() {
+               fIgnoreSelectionChanges++;
+               try {
+                       THNode node= fModel.getSelectionInHierarchy();
+                       if (node != null) {
+                               fHierarchyTreeViewer.setSelection(new StructuredSelection(node));
+                               fHierarchyTreeViewer.expandToLevel(node, 1);
+                       }
+                       ICElement elem= fModel.getSelectedMember();
+                       if (elem != null) {
+                               fMemberViewer.setSelection(new StructuredSelection(elem));
+                       }
+               } finally {
+                       fIgnoreSelectionChanges--;
+               }
+       }
+
+       private ICElement selectionToElement(ISelection selection) {
+               if (selection instanceof IStructuredSelection) {
+                       IStructuredSelection ss= (IStructuredSelection) selection;
+                       for (Iterator<?> iter = ss.iterator(); iter.hasNext(); ) {
+                               Object cand= iter.next();
+                               if (cand instanceof ICElement) {
+                                       return (ICElement) cand;
+                               }
+                               if (cand instanceof IAdaptable) {
+                                       ICElement elem= (ICElement) ((IAdaptable) cand).getAdapter(ICElement.class);
+                                       if (elem != null) {
+                                               return elem;
+                                       }
+                               }
+                       }
+               }
+               return null;
+       }
+
+       private THNode selectionToNode(ISelection selection) {
+               if (selection instanceof IStructuredSelection) {
+                       IStructuredSelection ss= (IStructuredSelection) selection;
+                       for (Iterator<?> iter = ss.iterator(); iter.hasNext(); ) {
+                               Object cand= iter.next();
+                               if (cand instanceof THNode) {
+                                       return (THNode) cand;
+                               }
+                       }
+               }
+               return null;
+       }
+
+       public Control getPageBook() {
+               return fPagebook;
+       }
+
+       public ICElement[] getHistoryEntries() {
+               return fHistoryEntries.toArray(new ICElement[fHistoryEntries.size()]);
+       }
+
+       public void setHistoryEntries(ICElement[] remaining) {
+               fHistoryEntries.clear();
+               fHistoryEntries.addAll(Arrays.asList(remaining));
+       }
+
+       ICElement getInput() {
+        Object input= fModel.getInput();
+        if (input instanceof ICElement) {
+               return (ICElement) input;
+        }
+        return null;
+       }
+
+       public TreeViewer getHiearchyViewer() {
+               return fHierarchyTreeViewer;
+       }
+
+       public TableViewer getMemberViewer() {
+               return fMemberViewer;
+       }
+       
+       private void restoreOrientation(int orientation) {
+               switch(orientation) {
+                       case ORIENTATION_HORIZONTAL:
+                               fHorizontalOrientation.setChecked(true);
+                               break;
+                       case ORIENTATION_VERTICAL:
+                               fVerticalOrientation.setChecked(true);
+                               break;
+                       case ORIENTATION_SINGLE:
+                               fSingleOrientation.setChecked(true);
+                               break;
+                       default:
+                               orientation= ORIENTATION_AUTOMATIC;
+                               fAutomaticOrientation.setChecked(true);
+                               break;
+               }
+               setOrientation(orientation);
+       }
+       
+    private void restoreHierarchyKind(int kind) {
+               switch(kind) {
+               case THHierarchyModel.SUB_TYPE_HIERARCHY:
+                       fShowSubTypeHierarchyAction.setChecked(true);
+                       break;
+               case THHierarchyModel.SUPER_TYPE_HIERARCHY:
+                       fShowSuperTypeHierarchyAction.setChecked(true);
+                       break;
+               default:
+                       kind= THHierarchyModel.TYPE_HIERARCHY;
+                       fShowTypeHierarchyAction.setChecked(true);
+                       break;
+               }                       
+               fModel.setHierarchyKind(kind);
+       }
+
+       public void setOrientation(int orientation) {
+               if (fInComputeOrientation) {
+                       return;
+               }
+               fInComputeOrientation= true;
+               try {
+                       if (fCurrentViewOrientation != orientation) {
+                               if (fSplitter != null && !fSplitter.isDisposed()) {
+                                       if (orientation == ORIENTATION_AUTOMATIC) {
+                                               orientation= getBestOrientation();
+                                       }
+                                       if (orientation == ORIENTATION_SINGLE) {
+                                               fMemberViewForm.setVisible(false);
+                                       } else {
+                                               if (fCurrentViewOrientation == ORIENTATION_SINGLE) {
+                                                       fMemberViewForm.setVisible(true);
+                                               }
+                                               boolean horizontal= orientation == ORIENTATION_HORIZONTAL;
+                                               fSplitter.setOrientation(horizontal ? SWT.HORIZONTAL : SWT.VERTICAL);
+                                       }
+                                       fSplitter.layout();
+                               }
+                               fCurrentViewOrientation= orientation;
+                       }
+               } finally {
+                       fInComputeOrientation= false;
+               }
+       }
+
+       private int getBestOrientation() {
+               Point size= fSplitter.getSize();
+               if (size.x != 0 && size.y != 0 && 3 * size.x < 2 * size.y) { 
+                       return ORIENTATION_VERTICAL;
+               }
+               return ORIENTATION_HORIZONTAL;
+       }
+
+       public void onEvent(int event) {
+               switch (event) {
+               case THHierarchyModel.END_OF_COMPUTATION:
+                       updateView();
+                       break;
+               }               
+       }
+
+       public IWorkbenchSiteProgressService getProgressService() {
+               return (IWorkbenchSiteProgressService) getSite().getAdapter(IWorkbenchSiteProgressService.class);       
+       }
+
+       private static class CopyTypeHierarchyAction extends CopyTreeAction {
+               public CopyTypeHierarchyAction(ViewPart view, TreeViewer viewer) {
+                       super(Messages.THViewPart_CopyTypeHierarchy, view, viewer);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/TypeHierarchyUI.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/TypeHierarchyUI.java
new file mode 100644 (file)
index 0000000..d2ff4aa
--- /dev/null
@@ -0,0 +1,334 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.typehierarchy;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.Region;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.ICompositeType;
+import org.eclipse.cdt.core.dom.ast.IEnumeration;
+import org.eclipse.cdt.core.dom.ast.IEnumerator;
+import org.eclipse.cdt.core.dom.ast.IField;
+import org.eclipse.cdt.core.dom.ast.IType;
+import org.eclipse.cdt.core.dom.ast.ITypedef;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexManager;
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IFunctionDeclaration;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
+import org.eclipse.cdt.internal.ui.util.StatusLineHandler;
+import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
+
+public class TypeHierarchyUI {
+       public static THViewPart open(ICElement input, IWorkbenchWindow window) {
+        if (!isValidInput(input)) {
+               return null;
+        }
+        ICElement memberInput= null;
+        if (!isValidTypeInput(input)) {
+               memberInput= input;
+               input= memberInput.getParent();
+               if (!isValidTypeInput(input)) {
+                       ICElement[] inputs= findInput(memberInput);
+                       if (inputs != null) {
+                               input= inputs[0];
+                               memberInput= inputs[1];
+                       }
+               }
+        }
+                       
+        if (isValidTypeInput(input)) {
+               return openInViewPart(window, input, memberInput);
+        }
+        return null;
+    }
+
+    private static THViewPart openInViewPart(IWorkbenchWindow window, ICElement input, ICElement member) {
+        IWorkbenchPage page= window.getActivePage();
+        try {
+            THViewPart result= (THViewPart)page.showView(CUIPlugin.ID_TYPE_HIERARCHY);
+            result.setInput(input, member);
+            return result;
+        } catch (CoreException e) {
+            ExceptionHandler.handle(e, window.getShell(), Messages.TypeHierarchyUI_OpenTypeHierarchy, null); 
+        }
+        return null;        
+    }
+
+       public static ICElement[] getInput(final ITextEditor editor, IRegion region) {
+               if (editor != null) {
+                       final IEditorInput editorInput = editor.getEditorInput();
+                       ICElement inputCElement = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput);
+                       if (inputCElement != null) {
+                               final ICProject project= inputCElement.getCProject();
+                               try {
+                                       return findInput(project, editorInput, region);
+                               } catch (CoreException e) {
+                                       CUIPlugin.log(e);
+                               }
+                       }
+               }
+               return null;
+       }
+
+    public static void open(final ITextEditor editor, final ITextSelection sel) {
+               if (editor != null) {
+                       ICElement inputCElement = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
+                       if (inputCElement != null) {
+                               final ICProject project= inputCElement.getCProject();
+                               final IEditorInput editorInput = editor.getEditorInput();
+                               final Display display= Display.getCurrent();
+
+                               Job job= new Job(Messages.TypeHierarchyUI_OpenTypeHierarchy) {
+                                       @Override
+                                       protected IStatus run(IProgressMonitor monitor) {
+                                               try {
+                                                       StatusLineHandler.clearStatusLine(editor.getSite());
+                                                       IRegion reg= new Region(sel.getOffset(), sel.getLength());
+                                                       final ICElement[] elems= findInput(project, editorInput, reg);
+                                                       if (elems != null && elems.length == 2) {
+                                                               display.asyncExec(new Runnable() {
+                                                                       public void run() {
+                                                                               openInViewPart(editor.getSite().getWorkbenchWindow(), elems[0], elems[1]);
+                                                                       }});
+                                                       } else {
+                                                               StatusLineHandler.showStatusLineMessage(editor.getSite(), 
+                                                                               Messages.TypeHierarchyUI_OpenFailure_message);
+                                                       }
+                                                       return Status.OK_STATUS;
+                                               } 
+                                               catch (CoreException e) {
+                                                       return e.getStatus();
+                                               }
+                                       }
+                               };
+                               job.setUser(true);
+                               job.schedule();
+                       }
+               }
+    }
+    
+       private static ICElement[] findInput(ICProject project, IEditorInput editorInput, IRegion sel) throws CoreException {
+               try {
+                       IIndex index= CCorePlugin.getIndexManager().getIndex(project, IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT);
+
+                       index.acquireReadLock();
+                       try {
+                               IASTName name= IndexUI.getSelectedName(editorInput, sel);
+                               if (name != null) {
+                                       IBinding binding= name.resolveBinding();
+                                       if (!isValidInput(binding)) {
+                                               return null;
+                                       }
+                                       ICElement member= null;
+                                       if (!isValidTypeInput(binding)) {
+                                               member= findDeclaration(project, index, name, binding);
+                                               name= null;
+                                               binding= findTypeBinding(binding);
+                                       }
+                                       if (isValidTypeInput(binding)) {
+                                               ICElement input= findDefinition(project, index, name, binding);
+                                               if (input != null) {
+                                                       return new ICElement[] {input, member};
+                                               }
+                                       }
+                               }
+                       }
+                       finally {
+                               index.releaseReadLock();
+                       }
+               }
+               catch (CoreException e) {
+                       CUIPlugin.log(e);
+               } 
+               catch (InterruptedException e) {
+               }
+               return null;
+       }
+
+       private static ICElement[] findInput(ICElement member)  {
+               ICProject project= member.getCProject();
+               try {
+                       IIndex index= CCorePlugin.getIndexManager().getIndex(project, IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT);
+                       index.acquireReadLock();
+                       try {
+                               IIndexName name= IndexUI.elementToName(index, member);
+                               if (name != null) {
+                                       member= IndexUI.getCElementForName(project, index, name);
+                                       IBinding binding= index.findBinding(name);
+                                       binding= findTypeBinding(binding);
+                                       if (isValidTypeInput(binding)) {
+                                               ICElement input= findDefinition(project, index, null, binding);
+                                               if (input != null) {
+                                                       return new ICElement[] {input, member};
+                                               }
+                                       }
+                               }
+                       }
+                       finally {
+                               index.releaseReadLock();
+                       }
+               }
+               catch (CoreException e) {
+                       CUIPlugin.log(e);
+               } 
+               catch (InterruptedException e) {
+               }
+               return null;
+       }
+
+       private static IBinding findTypeBinding(IBinding memberBinding) {
+               try {
+                       if (memberBinding instanceof IEnumerator) {
+                               IType type= ((IEnumerator) memberBinding).getType();
+                               if (type instanceof IBinding) {
+                                       return (IBinding) type;
+                               }
+                       }
+                       else if (memberBinding instanceof ICPPMember) {
+                               return ((ICPPMember) memberBinding).getClassOwner();
+                       }
+                       else if (memberBinding instanceof IField) {
+                               return ((IField) memberBinding).getCompositeTypeOwner();
+                       }
+               } catch (DOMException e) {
+                       // don't log problem bindings
+               }
+               return null;
+       }
+
+       private static ICElement findDefinition(ICProject project, IIndex index, IASTName name, IBinding binding) 
+                       throws CoreException {
+               if (name != null && name.isDefinition()) {
+                       return IndexUI.getCElementForName(project, index, name);
+               }
+
+               ICElement[] elems= IndexUI.findAllDefinitions(index, binding);
+               if (elems.length > 0) {
+                       return elems[0];
+               }
+               return IndexUI.findAnyDeclaration(index, project, binding);
+       }
+
+       private static ICElement findDeclaration(ICProject project, IIndex index, IASTName name, IBinding binding) 
+                       throws CoreException {
+               if (name != null && name.isDefinition()) {
+                       return IndexUI.getCElementForName(project, index, name);
+               }
+
+               ICElement[] elems= IndexUI.findAllDefinitions(index, binding);
+               if (elems.length > 0) {
+                       return elems[0];
+               }
+               return IndexUI.findAnyDeclaration(index, project, binding);
+       }
+
+       public static boolean isValidInput(IBinding binding) {
+               if (isValidTypeInput(binding)
+                               || binding instanceof ICPPMember
+                               || binding instanceof IEnumerator
+                               || binding instanceof IField) {
+                       return true;
+               }
+               return false;
+       }
+
+       public static boolean isValidTypeInput(IBinding binding) {
+               if (binding instanceof ICompositeType
+                               || binding instanceof IEnumeration 
+                               || binding instanceof ITypedef) {
+                       return true;
+               }
+               return false;
+       }
+
+       public static boolean isValidInput(ICElement elem) {
+               if (elem == null) {
+                       return false;
+               }
+               if (isValidTypeInput(elem)) {
+                       return true;
+               }
+               switch (elem.getElementType()) {
+               case ICElement.C_FIELD:
+               case ICElement.C_METHOD:
+               case ICElement.C_METHOD_DECLARATION:
+               case ICElement.C_TEMPLATE_METHOD:
+               case ICElement.C_TEMPLATE_METHOD_DECLARATION:
+               case ICElement.C_ENUMERATOR:
+                       return true;
+               }
+               return false;
+       }
+
+       public static boolean isValidTypeInput(ICElement elem) {
+               if (elem == null) {
+                       return false;
+               }
+               switch (elem.getElementType()) {
+               case ICElement.C_CLASS:
+               case ICElement.C_STRUCT:
+               case ICElement.C_UNION:
+               case ICElement.C_CLASS_DECLARATION:
+               case ICElement.C_STRUCT_DECLARATION:
+               case ICElement.C_UNION_DECLARATION:
+               case ICElement.C_ENUMERATION:
+               case ICElement.C_TYPEDEF:
+//             case ICElement.C_TEMPLATE_CLASS:
+//             case ICElement.C_TEMPLATE_CLASS_DECLARATION:
+//             case ICElement.C_TEMPLATE_STRUCT:
+//             case ICElement.C_TEMPLATE_STRUCT_DECLARATION:
+//             case ICElement.C_TEMPLATE_UNION:
+//             case ICElement.C_TEMPLATE_UNION_DECLARATION:
+                       return true;
+               }
+               return false;
+       }
+
+       static String getLocalElementSignature(ICElement element) {
+               if (element != null) {
+                       try {
+                               switch (element.getElementType()) {
+                               case ICElement.C_METHOD:
+                               case ICElement.C_METHOD_DECLARATION:
+                                       return ((IFunctionDeclaration) element).getSignature();
+                               case ICElement.C_FIELD:
+                                       return element.getElementName();
+                               }
+                       } catch (CModelException e) {
+                               CUIPlugin.log(e);
+                       }
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/messages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/messages.properties
new file mode 100644 (file)
index 0000000..b8673ad
--- /dev/null
@@ -0,0 +1,67 @@
+###############################################################################
+# Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     Markus Schorn (Wind River Systems)
+###############################################################################
+THHistoryDropDownAction_ClearHistory=Clear History
+THHistoryListAction_HistoryList_title=Type Hierarchy History
+THHistoryListAction_HistoryList_label=Select the input for the Type Hierarchy:
+THViewPart_SupertypeHierarchy_tooltip=Show the Supertype Hierarchy
+THHistoryDropDownAction_tooltip=Show History List
+THViewPart_AutomaticOrientation=Automatic View Orientation
+THHistoryListAction_Remove=Remove
+THHierarchyModel_Job_title=Open Type Hierarchy
+THHierarchyModel_errorComputingHierarchy=The hierarchy could not be computed, see the log for details.
+THViewPart_Refresh_tooltip=Refresh
+THHistoryListAction_label=Open History...
+THViewPart_instruction=To display the type hierarchy, select a type or member and select the 'Open Type Hierarchy' menu option.
+THViewPart_MethodPane_title=Content
+THViewPart_HorizontalOrientation=Horizontal View Orientation
+THViewPart_HideNonPublic_tooltip=Hide Non-Public Members
+THViewPart_VerticalOrientation=Vertical View Orientation
+THViewPart_SinglePaneOrientation=Hierarchy View Only
+THViewPart_CompleteTypeHierarchy=Type Hierarchy
+THViewPart_CompleteTypeHierarchy_tooltip=Show the Type Hierarchy
+THViewPart_SubtypeHierarchy=Subtype Hierarchy
+THViewPart_HideFields_label=Hide Fields
+THViewPart_HideStatic_label=Hide Static Members
+THViewPart_SubtypeHierarchy_tooltip=Show the Subtype Hierarchy
+THViewPart_SupertypeHierarchy=Supertype Hierarchy
+THViewPart_HideFields_tooltip=Hide Fields
+THViewPart_HideStatic_tooltip=Hide Static Fields and Methods
+THViewPart_Open=Open
+THViewPart_Open_tooltip=Open
+THViewPart_CopyTypeHierarchy=Copy E&xpanded Hierarchy
+THViewPart_ShowFileNames=Show File Names
+THViewPart_Cancel_tooltip=Cancel
+THViewPart_ShowFileNames_tooltip=Show File Names
+THViewPart_ShowInherited_label=Show Inherited Members
+THViewPart_HideNonPublic_label=Hide Non-Public Members
+THViewPart_ShowInherited_tooltip=Show All Inherited Members
+THViewPart_Refresh=Refresh
+THViewPart_LayoutMenu=Layout
+THViewPart_FocusOn=Focus On ''{0}''
+THViewPart_Cancel=Cancel
+TypeHierarchyUI_OpenTypeHierarchy=Open Type Hierarchy
+TypeHierarchyUI_OpenFailure_message=Cannot resolve selected text to a defined type
+OpenTypeHierarchyAction_label=Open Type Hierarchy
+OpenTypeHierarchyAction_tooltip=Open Type Hierarchy
+OpenTypeInHierarchyAction_errorTitle=Open Type in Hierarchy
+OpenTypeInHierarchyAction_title=Open Type in Hierarchy
+OpenTypeInHierarchyAction_message=&Choose a type (? = any character, * = any string):
+THInformationControl_titleHierarchy=Type hierarchy of ''{0}''
+THInformationControl_titleSubHierarchy=Subtypes of ''{0}''
+THInformationControl_titleSuperHierarchy=Supertypes of ''{0}''
+THInformationControl_titleMemberInHierarchy=Types declaring ''{0}''
+THInformationControl_titleMemberInSubHierarchy=Subtypes declaring ''{0}''
+THInformationControl_titleMemberInSuperHierarchy=Supertypes declaring ''{0}''
+THInformationControl_toggle_typeHierarchy_label=Press ''{0}'' to see the type hierarchy
+THInformationControl_toggle_subTypeHierarchy_label=Press ''{0}'' to see the subtype hierarchy
+THInformationControl_toggle_superTypeHierarchy_label=Press ''{0}'' to see the supertype hierarchy
+OpenTypeInHierarchyAction_errorNoDefinition=Could not locate definition of type ''{0}''
+OpenTypeInHierarchyAction_upperListLabel=&Matching Types:
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/BusyIndicatorRunnableContext.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/BusyIndicatorRunnableContext.java
new file mode 100644 (file)
index 0000000..e4484e8
--- /dev/null
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.util;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.swt.custom.BusyIndicator;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+
+import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.operation.ModalContext;
+
+/**
+ * A runnable context that shows the busy cursor instead of a progress
+ * monitor. Note, that the UI thread is blocked even if the runnable
+ * is executed in a separate thread by passing <code>fork= true</code>
+ * to the context's run method. Furthermore this context doesn't provide
+ * any UI to cancel the operation.
+ */
+public class BusyIndicatorRunnableContext implements IRunnableContext {
+
+       private static class BusyRunnable implements Runnable {
+               
+               private static class ThreadContext extends Thread {
+                       IRunnableWithProgress fRunnable;
+                       Throwable fThrowable;
+                       
+                       public ThreadContext(IRunnableWithProgress runnable) {
+                               this(runnable, "BusyCursorRunnableContext-Thread"); //$NON-NLS-1$
+                       }                       
+                       protected ThreadContext(IRunnableWithProgress runnable, String name) {
+                               super(name);
+                               fRunnable= runnable;
+                       }
+                       @Override
+                       public void run() {
+                               try {
+                                       fRunnable.run(new NullProgressMonitor());
+                               } catch (InvocationTargetException e) {
+                                       fThrowable= e;
+                               } catch (InterruptedException e) {
+                                       fThrowable= e;
+                               } catch (ThreadDeath e) {
+                                       fThrowable= e;
+                                       throw e;
+                               } catch (RuntimeException e) {
+                                       fThrowable= e;
+                               } catch (Error e) {
+                                       fThrowable= e;
+                               }
+                       }
+                       void sync() {
+                               try {
+                                       join();
+                               } catch (InterruptedException e) {
+                                       // ok to ignore exception
+                               }
+                       }
+               }
+               
+               public Throwable fThrowable;
+               private boolean fFork;
+               private IRunnableWithProgress fRunnable;
+               public BusyRunnable(boolean fork, IRunnableWithProgress runnable) {
+                       fFork= fork;
+                       fRunnable= runnable;
+               }
+               public void run() {
+                       try {
+                               internalRun(fFork, fRunnable);
+                       } catch (InvocationTargetException e) {
+                               fThrowable= e;
+                       } catch (InterruptedException e) {
+                               fThrowable= e;
+                       }
+               }
+               private void internalRun(boolean fork, final IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException {
+                       Thread thread= Thread.currentThread();
+                       // Do not spawn another thread if we are already in a modal context
+                       // thread or inside a busy context thread.
+                       if (thread instanceof ThreadContext || ModalContext.isModalContextThread(thread))
+                               fork= false;
+                               
+                       if (fork) {
+                               final ThreadContext t= new ThreadContext(runnable);
+                               t.start();
+                               t.sync();
+                               // Check if the separate thread was terminated by an exception
+                               Throwable throwable= t.fThrowable;
+                               if (throwable != null) {
+                                       if (throwable instanceof InvocationTargetException) {
+                                               throw (InvocationTargetException) throwable;
+                                       } else if (throwable instanceof InterruptedException) {
+                                               throw (InterruptedException) throwable;
+                                       } else if (throwable instanceof OperationCanceledException) {
+                                               throw new InterruptedException();
+                                       } else {
+                                               throw new InvocationTargetException(throwable);
+                                       }
+                               }
+                       } else {
+                               try {
+                                       runnable.run(new NullProgressMonitor());
+                               } catch (OperationCanceledException e) {
+                                       throw new InterruptedException();
+                               }       
+                       }
+               }
+       }
+
+       /* (non-Javadoc)
+        * Method declared on IRunnableContext.
+        */
+       public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException {
+               BusyRunnable busyRunnable= new BusyRunnable(fork, runnable);
+               BusyIndicator.showWhile(null, busyRunnable);
+               Throwable throwable= busyRunnable.fThrowable;
+               if (throwable instanceof InvocationTargetException) {
+                       throw (InvocationTargetException)throwable;
+               } else if (throwable instanceof InterruptedException) {
+                       throw (InterruptedException)throwable;
+               }
+       }       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CHelpDisplayContext.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CHelpDisplayContext.java
new file mode 100644 (file)
index 0000000..bd77baf
--- /dev/null
@@ -0,0 +1,124 @@
+/**********************************************************************
+ * Copyright (c) 2004, 2008 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *     Intel Corporation - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ **********************************************************************/
+package org.eclipse.cdt.internal.ui.util;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.help.HelpSystem;
+import org.eclipse.help.IContext;
+import org.eclipse.help.IHelpResource;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.ICHelpResourceDescriptor;
+import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
+
+import org.eclipse.cdt.internal.ui.CHelpProviderManager;
+import org.eclipse.cdt.internal.ui.text.CWordFinder;
+
+/**
+ * 
+ * @since 2.1
+ */
+public class CHelpDisplayContext implements IContext {
+       
+       private IHelpResource[] fHelpResources;
+       private String fText;
+       
+       public static void displayHelp(String contextId, ITextEditor editor) throws CoreException {
+               String selected = getSelectedString(editor);
+               IContext context= HelpSystem.getContext(contextId);
+               if (context != null) {
+                       if (selected != null && selected.length() > 0) {
+                               context= new CHelpDisplayContext(context, editor, selected);
+                       }
+                       PlatformUI.getWorkbench().getHelpSystem().displayHelp(context);
+               }
+       }
+       
+       private static String getSelectedString(ITextEditor editor){
+               String expression = null;
+               try{
+                       ITextSelection selection = (ITextSelection)editor.getSite().getSelectionProvider().getSelection();
+                       IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
+                       IRegion region = CWordFinder.findWord(document, selection.getOffset());
+                       expression = document.get(region.getOffset(), region.getLength());
+               }
+               catch(Exception e){
+               }
+               return expression;
+       }
+
+       public CHelpDisplayContext(IContext context, final ITextEditor editor , String selected) throws CoreException {
+
+               List<IHelpResource> helpResources= new ArrayList<IHelpResource>();
+               
+               ICHelpInvocationContext invocationContext = new ICHelpInvocationContext() {
+
+                       public IProject getProject() {
+                               ITranslationUnit unit = getTranslationUnit();
+                               if (unit != null) {
+                                       return unit.getCProject().getProject();
+                               }
+                               return null;
+                       }
+
+                       public ITranslationUnit getTranslationUnit() {
+                               IEditorInput editorInput= editor.getEditorInput();
+                               return CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput);
+                       }       
+               };
+
+               if (context != null) {
+                       IHelpResource[] resources= context.getRelatedTopics();
+                       if (resources != null){
+                               helpResources.addAll(Arrays.asList(resources));
+                       }
+               }
+
+               ICHelpResourceDescriptor providerResources[] = CHelpProviderManager.getDefault().getHelpResources(invocationContext,selected);
+               if(providerResources != null){
+                       for(int i = 0; i < providerResources.length; i++){
+                               helpResources.addAll(Arrays.asList(providerResources[i].getHelpResources()));
+                       }
+               }
+
+               fHelpResources= helpResources.toArray(new IHelpResource[helpResources.size()]);
+               if (fText == null || fText.length() == 0) {
+                       if (context != null) {
+                               fText= context.getText();
+                       }
+               }
+               if (fText != null && fText.length() == 0) {
+                       fText= null; 
+               }
+       }
+
+       public IHelpResource[] getRelatedTopics() {
+               return fHelpResources;
+       }
+
+       public String getText() {
+               return fText;
+       }
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CUIHelp.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CUIHelp.java
new file mode 100644 (file)
index 0000000..ee6f4bc
--- /dev/null
@@ -0,0 +1,130 @@
+/**********************************************************************
+ * Copyright (c) 2004, 2008 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *     Intel Corporation - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ **********************************************************************/
+
+package org.eclipse.cdt.internal.ui.util;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.text.CWordFinder;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.help.HelpSystem;
+import org.eclipse.help.IContext;
+import org.eclipse.help.IContextProvider;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.HelpEvent;
+import org.eclipse.swt.events.HelpListener;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+/**
+ * 
+ * @since 2.1
+ */
+public class CUIHelp {
+
+       public static void setHelp(CEditor editor, StyledText text, String contextId) {
+               CUIHelpListener listener= new CUIHelpListener(editor, contextId);
+               text.addHelpListener(listener);
+       }
+
+       private static class CUIHelpListener implements HelpListener {
+
+               private String fContextId;
+               private CEditor fEditor;
+
+               public CUIHelpListener(CEditor editor, String contextId) {
+                       fContextId= contextId;
+                       fEditor= editor;
+               }
+
+               /*
+               * @see HelpListener#helpRequested(HelpEvent)
+               * 
+               */
+               public void helpRequested(HelpEvent e) {
+                       try {
+                               CHelpDisplayContext.displayHelp(fContextId, fEditor);
+                       } catch (CoreException x) {
+                               CUIPlugin.log(x);
+                       }
+               }
+       }
+
+       /**
+        * A dynamic help context provider.
+        * 
+        * @since 4.0
+        */
+       public static final class CUIHelpContextProvider implements IContextProvider {
+
+               private final ITextEditor fEditor;
+
+               /**
+                * Creates a context provider for the given text editor.
+                * @param editor
+                */
+               public CUIHelpContextProvider(ITextEditor editor) {
+                       fEditor= editor;
+               }
+
+               /*
+                * @see org.eclipse.help.IContextProvider#getContext(java.lang.Object)
+                */
+               public IContext getContext(Object target) {
+                       String selected = getSelectedString(fEditor);
+                       IContext context= HelpSystem.getContext(ICHelpContextIds.CEDITOR_VIEW);
+                       if (context != null) {
+                               if (selected != null && selected.length() > 0) {
+                                       try {
+                                               context= new CHelpDisplayContext(context, fEditor, selected);
+                                       } catch (CoreException exc) {
+                                       }
+                               }
+                       }
+                       return context;
+               }
+       
+               /*
+                * @see org.eclipse.help.IContextProvider#getContextChangeMask()
+                */
+               public int getContextChangeMask() {
+                       return SELECTION;
+               }
+       
+               /*
+                * @see org.eclipse.help.IContextProvider#getSearchExpression(java.lang.Object)
+                */
+               public String getSearchExpression(Object target) {
+                       return getSelectedString(fEditor);
+               }
+       
+               private static String getSelectedString(ITextEditor editor){
+                       String expression = null;
+                       try{
+                               ITextSelection selection = (ITextSelection)editor.getSite().getSelectionProvider().getSelection();
+                               IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
+                               IRegion region = CWordFinder.findWord(document, selection.getOffset());
+                               if (region != null)
+                                       expression = document.get(region.getOffset(), region.getLength());
+                       }
+                       catch(Exception e){
+                       }
+                       return expression;
+               }
+       
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CoreUtility.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/CoreUtility.java
new file mode 100644 (file)
index 0000000..999b4ff
--- /dev/null
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2006 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.util;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.osgi.framework.Bundle;
+
+public class CoreUtility {
+       
+       /**
+        * Creates a folder and all parent folders if not existing.
+        * Project must exist.
+        * <code> org.eclipse.ui.dialogs.ContainerGenerator</code> is too heavy
+        * (creates a runnable)
+        */
+       public static void createFolder(IFolder folder, boolean force, boolean local, IProgressMonitor monitor) throws CoreException {
+               if (!folder.exists()) {
+                       IContainer parent= folder.getParent();
+                       if (parent instanceof IFolder) {
+                               createFolder((IFolder)parent, force, local, null);
+                       }
+                       folder.create(force, local, monitor);
+               }
+       }
+       
+       /**
+        * Creates an extension.  If the extension plugin has not
+        * been loaded a busy cursor will be activated during the duration of
+        * the load.
+        *
+        * @param element the config element defining the extension
+        * @param classAttribute the name of the attribute carrying the class
+        * @return the extension object
+        */
+       public static Object createExtension(final IConfigurationElement element, final String classAttribute) throws CoreException {
+               // If plugin has been loaded create extension.
+               // Otherwise, show busy cursor then create extension.
+               
+               String id= element.getContributor().getName();
+               Bundle bundle = Platform.getBundle(id);
+               if(bundle.getState() == org.osgi.framework.Bundle.ACTIVE) {
+                       return element.createExecutableExtension(classAttribute);
+               }
+               final Object[] ret = new Object[1];
+               final CoreException[] exc = new CoreException[1];
+               BusyIndicator.showWhile(null, new Runnable() {
+                       public void run() {
+                               try {
+                                       ret[0] = element.createExecutableExtension(classAttribute);
+                               } catch (CoreException e) {
+                                       exc[0] = e;
+                               }
+                       }
+               });
+               if (exc[0] != null)
+                       throw exc[0];
+               return ret[0];
+       }
+
+       /**
+        * Calls equals after checking for nulls
+        */
+       public static boolean safeEquals(Object lhs, Object rhs) {
+           if (lhs==rhs) {
+               return true;
+           }
+           if (lhs == null || rhs == null) {
+               return false;
+           }
+           return lhs.equals(rhs);
+       }
+
+       /**
+        * Calls hashCode after checking for null
+        */
+       public static int safeHashcode(Object o) {
+               return o == null ? 0 : o.hashCode();
+       }
+
+       /**
+        * Comparse two integers.
+        */
+       public static int compare(int lhs, int rhs) {
+               if (lhs < rhs) {
+                       return -1;
+               }
+               if (lhs > rhs) {
+                       return 1;
+               }
+               return 0;
+       }
+}      
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/DeleteIProblemMarkerAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/DeleteIProblemMarkerAction.java
new file mode 100644 (file)
index 0000000..91f0032
--- /dev/null
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.util;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.actions.ActionDelegate;
+
+import org.eclipse.cdt.core.model.ICModelMarker;
+
+/**
+ * @author Bogdan Gheorghe
+ */
+public class DeleteIProblemMarkerAction extends ActionDelegate implements IObjectActionDelegate {
+
+    private IStructuredSelection  selection;
+
+       /**
+        * @see ActionDelegate#run(IAction)
+        */
+       @Override
+       public void run(IAction action) {
+
+               if (selection != null) {
+                       if (selection.isEmpty()) {
+                               return;
+                       }
+                       try {
+                               List<?> list = selection.toList();
+                               List<IMarker> listMarkers = new ArrayList<IMarker>();
+                               Iterator<?> iterator = list.iterator();
+                               while (iterator.hasNext()) {
+                                       IMarker marker = (IMarker)iterator.next();
+                                       if (marker.isSubtypeOf(ICModelMarker.INDEXER_MARKER)) {
+                                               listMarkers.add(marker);
+                                       }
+                               }
+                               // Bail out early
+                               if (listMarkers.isEmpty()) {
+                                       return;
+                               }
+                               IMarker[] markers = new IMarker[listMarkers.size()];
+                               listMarkers.toArray(markers);
+                               // be sure to only invoke one workspace operation
+                               ResourcesPlugin.getWorkspace().deleteMarkers(markers);
+                               selection = null;
+                       } catch (CoreException e) {
+                       }
+               }
+       }
+
+       /**
+        * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
+        */
+       public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+       }
+
+       @Override
+       public void selectionChanged(IAction action, ISelection selection) {
+               boolean enable = false;
+               if (selection instanceof IStructuredSelection) {
+                       Object object = ((IStructuredSelection) selection).getFirstElement();
+                       if (object instanceof IMarker) {
+                               try {
+                                       IMarker marker = (IMarker) object;
+                                       if (marker.isSubtypeOf(ICModelMarker.INDEXER_MARKER)) {
+                                                       enable = true;
+                                       }
+                                       this.selection = (IStructuredSelection)selection;
+                                       action.setEnabled(enable);
+                               } catch (CoreException e) {
+                               }
+                       }
+               }
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/DeleteTaskAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/DeleteTaskAction.java
new file mode 100644 (file)
index 0000000..e6d3ed2
--- /dev/null
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.util;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.actions.ActionDelegate;
+
+import org.eclipse.cdt.core.model.ICModelMarker;
+
+public class DeleteTaskAction extends ActionDelegate implements IObjectActionDelegate
+{
+       private IStructuredSelection  selection;
+
+       /**
+        * @see ActionDelegate#run(IAction)
+        */
+       @Override
+       public void run(IAction action) {
+               // Add your code here to perform the action
+               if (selection != null) {
+                       if (selection.isEmpty()) {
+                               return;
+                       }
+                       try {
+                               List<?> list = selection.toList();
+                               List<IMarker> listMarkers = new ArrayList<IMarker>();
+                               Iterator<?> iterator = list.iterator();
+                               while (iterator.hasNext()) {
+                                       IMarker marker = (IMarker)iterator.next();
+                                       if (marker.isSubtypeOf(ICModelMarker.C_MODEL_PROBLEM_MARKER)
+                                               || marker.isSubtypeOf(ICModelMarker.C_MODEL_MARKER_VARIABLE)) {
+                                               listMarkers.add(marker);
+                                       }
+                               }
+                               // Bail out early
+                               if (listMarkers.isEmpty()) {
+                                       return;
+                               }
+                               IMarker[] markers = new IMarker[listMarkers.size()];
+                               listMarkers.toArray(markers);
+                               // be sure to only invoke one workspace operation
+                               ResourcesPlugin.getWorkspace().deleteMarkers(markers);
+                               selection = null;
+                       } catch (CoreException e) {
+                       }
+               }
+       }
+
+       /**
+        * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
+        */
+       public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+       }
+
+       @Override
+       public void selectionChanged(IAction action, ISelection selection) {
+               boolean enable = false;
+               if (selection instanceof IStructuredSelection) {
+                       Object object = ((IStructuredSelection) selection).getFirstElement();
+                       if (object instanceof IMarker) {
+                               try {
+                                       IMarker marker = (IMarker) object;
+                                       if (marker.isSubtypeOf(ICModelMarker.C_MODEL_PROBLEM_MARKER)
+                                               || marker.isSubtypeOf(ICModelMarker.C_MODEL_MARKER_VARIABLE)) {
+                                                       enable = true;
+                                       }
+                                       this.selection = (IStructuredSelection)selection;
+                                       action.setEnabled(enable);
+                               } catch (CoreException e) {
+                               }
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java
new file mode 100644 (file)
index 0000000..2c1f8c9
--- /dev/null
@@ -0,0 +1,1016 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *     Norbert Ploett (Siemens AG)
+ *     Anton Leherbauer (Wind River Systems)
+ *     Ed Swartz (Nokia)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.compare.rangedifferencer.IRangeComparator;
+import org.eclipse.compare.rangedifferencer.RangeDifference;
+import org.eclipse.compare.rangedifferencer.RangeDifferencer;
+import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.core.filebuffers.ITextFileBuffer;
+import org.eclipse.core.filebuffers.ITextFileBufferManager;
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.filesystem.URIUtil;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.ISafeRunnable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.ui.IEditorDescriptor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorRegistry;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.editors.text.TextFileDocumentProvider;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.ide.ResourceUtil;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.part.MultiEditorInput;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import com.ibm.icu.text.MessageFormat;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.IBinary;
+import org.eclipse.cdt.core.model.IBuffer;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IIncludeReference;
+import org.eclipse.cdt.core.model.ISourceRange;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.core.resources.FileStorage;
+import org.eclipse.cdt.ui.CDTUITools;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.utils.UNCPathConverter;
+
+import org.eclipse.cdt.internal.core.resources.ResourceLookup;
+
+import org.eclipse.cdt.internal.ui.ICStatusConstants;
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.editor.CEditorMessages;
+import org.eclipse.cdt.internal.ui.editor.ITranslationUnitEditorInput;
+import org.eclipse.cdt.internal.ui.text.LineComparator;
+
+public class EditorUtility {
+
+       /**
+        * The ID of the default text editor
+        */
+       public static final String DEFAULT_TEXT_EDITOR_ID = EditorsUI.DEFAULT_TEXT_EDITOR_ID;
+
+       private EditorUtility () {
+       }
+
+       /**
+        * Tests if a cu is currently shown in an editor
+        * @return the IEditorPart if shown, null if element is not open in an editor
+        */
+       public static IEditorPart isOpenInEditor(Object inputElement) {
+               IEditorInput input = null;
+
+               try {
+                       input = getEditorInput(inputElement);
+               } catch (CModelException x) {
+                       //CUIPlugin.log(x.getStatus());
+               }
+
+               if (input != null) {
+                       IWorkbenchPage p= CUIPlugin.getActivePage();
+                       if (p != null) {
+                               return p.findEditor(input);
+                       }
+               }
+
+               return null;
+       }
+
+       /**
+        * Opens an editor for an element such as <code>ICElement</code>,
+        * <code>IFile</code>, or <code>IStorage</code>.
+        * The editor is activated by default.
+        * @return the IEditorPart or null if wrong element type or opening failed
+        */
+       public static IEditorPart openInEditor(Object inputElement) throws CModelException, PartInitException {
+               return openInEditor(inputElement, true);
+       }
+
+       /**
+        * Opens an editor for an element (ICElement, IFile, IStorage...)
+        * @return the IEditorPart or null if wrong element type or opening failed
+        */
+       public static IEditorPart openInEditor(Object inputElement, boolean activate)
+                       throws CModelException, PartInitException {
+               if (inputElement instanceof IFile) {
+                       return openInEditor((IFile) inputElement, activate);
+               }
+
+               IEditorInput input = getEditorInput(inputElement);
+
+               if (input != null) {
+                       return openInEditor(input, getEditorID(input, inputElement), activate);
+               }
+
+               return null;
+       }
+
+       /**
+        * Selects a C Element in an editor
+        */
+       public static void revealInEditor(IEditorPart part, ICElement element) {
+               if (element == null) {
+                       return;
+               }
+               if (part instanceof CEditor) {
+                       ((CEditor) part).setSelection(element);
+               } else if (part instanceof ITextEditor) {
+                       if (element instanceof ISourceReference && !(element instanceof ITranslationUnit)) {
+                               ISourceReference reference= (ISourceReference) element;
+                               try {
+                                       ISourceRange range= reference.getSourceRange();
+                                       ((ITextEditor) part).selectAndReveal(range.getIdStartPos(), range.getIdLength());
+                               } catch (CModelException exc) {
+                                       CUIPlugin.log(exc.getStatus());
+                               }
+                       }
+               }
+       }
+
+       private static IEditorPart openInEditor(IFile file, boolean activate) throws PartInitException {
+               if (file == null)
+                       return null;
+               if (!file.getProject().isAccessible()) {
+                       closedProject(file.getProject());
+                       return null;
+               }
+
+               try {
+                       if (!file.isLinked(IResource.CHECK_ANCESTORS)) {
+                               File tempFile = file.getRawLocation().toFile();
+
+                               if (tempFile != null){
+                                       String canonicalPath = null;
+                                       try {
+                                               canonicalPath = tempFile.getCanonicalPath();
+                                       } catch (IOException e) {
+                                       }
+
+                                       if (canonicalPath != null){
+                                               IPath path = new Path(canonicalPath);
+                                               file = CUIPlugin.getWorkspace().getRoot().getFileForLocation(path);
+                                       }
+                               }
+                       }
+
+                       IEditorInput input = getEditorInput(file);
+                       if (input != null) {
+                               return openInEditor(input, getEditorID(input, file), activate);
+                       }
+               } catch (CModelException e) {
+               }
+               return null;
+       }
+
+       /**
+        * @deprecated use IResource.isLinked(IResource.CHECK_ANCESTORS) instead.
+        */
+       @Deprecated
+       public static boolean isLinked(IFile file) {
+               if (file.isLinked())
+                       return true;
+
+               IPath path = file.getLocation();
+
+               while (path.segmentCount() > 0) {
+                       path = path.removeLastSegments(1);
+                       IContainer[] containers = ResourcesPlugin.getWorkspace().getRoot().findContainersForLocation(path);
+
+                       for (IContainer container : containers) {
+                               if (container instanceof IFolder && ((IFolder) container).isLinked()) {
+                                       return true;
+                               }
+                       }
+               }
+
+               return false;
+       }
+
+       /**
+        * Open error dialog about closed project.
+        * @param project
+        */
+       private static void closedProject(IProject project) {
+               MessageBox errorMsg = new MessageBox(CUIPlugin.getActiveWorkbenchShell(), SWT.ICON_ERROR | SWT.OK);
+               errorMsg.setText(CUIPlugin.getResourceString("EditorUtility.closedproject")); //$NON-NLS-1$
+               String desc= CUIPlugin.getResourceString("Editorutility.closedproject.description"); //$NON-NLS-1$
+               errorMsg.setMessage(MessageFormat.format(desc, new Object[]{project.getName()}));
+               errorMsg.open();
+       }
+
+       private static IEditorPart openInEditor(IEditorInput input, String editorID, boolean activate) throws PartInitException {
+               if (input != null) {
+                       IWorkbenchPage p= CUIPlugin.getActivePage();
+                       if (p != null) {
+                               IEditorPart editorPart= p.openEditor(input, editorID, activate);
+                               return editorPart;
+                       }
+               }
+               return null;
+       }
+
+       private static IEditorInput getEditorInput(ICElement element) throws CModelException {
+               while (element != null) {
+                       if (element instanceof ISourceReference) {
+                               ITranslationUnit tu = ((ISourceReference) element).getTranslationUnit();
+                               if (tu != null) {
+                                       element = tu;
+                               }
+                       }
+                       if (element instanceof IWorkingCopy && ((IWorkingCopy) element).isWorkingCopy())
+                               element= ((IWorkingCopy) element).getOriginalElement();
+
+                       if (element instanceof ITranslationUnit) {
+                               ITranslationUnit unit= (ITranslationUnit) element;
+                               IResource resource= unit.getResource();
+                               if (resource instanceof IFile) {
+                                       return new FileEditorInput((IFile) resource);
+                               }
+                               return new ExternalEditorInput(unit);
+                       }
+
+                       if (element instanceof IBinary) {
+                               IResource resource= element.getResource();
+                               if (resource instanceof IFile) {
+                                       return new FileEditorInput((IFile)resource);
+                               }
+                       }
+
+                       element= element.getParent();
+               }
+
+               return null;
+       }
+
+       public static IEditorInput getEditorInput(Object input) throws CModelException {
+               if (input instanceof ICElement) {
+                       return getEditorInput((ICElement) input);
+               }
+               if (input instanceof IFile) {
+                       return new FileEditorInput((IFile) input);
+               }
+               if (input instanceof IStorage) {
+                       final IPath location= ((IStorage)input).getFullPath();
+                       if (location != null) {
+                               return new ExternalEditorInput(location);
+                       }
+               }
+               return null;
+       }
+
+       /**
+        * Utility method to open an editor for the given file system location
+        * using {@link #getEditorInputForLocation(IPath, ICElement)} to create
+        * the editor input.
+        *
+        * @param location  a file system location
+        * @param element  an element related to the target file, may be <code>null</code>
+        * @throws PartInitException
+        */
+       public static IEditorPart openInEditor(IPath location, ICElement element) throws PartInitException {
+               return openInEditor(location, element, true);
+       }
+
+       public static IEditorPart openInEditor(IPath location, ICElement element, boolean activate) throws PartInitException {
+               IEditorInput input= getEditorInputForLocation(location, element);
+               return EditorUtility.openInEditor(input, getEditorID(input, element), activate);
+       }
+       
+       public static IEditorPart openInEditor(URI locationURI, ICElement element) throws PartInitException {
+               IEditorInput input= getEditorInputForLocation(locationURI, element);
+               return EditorUtility.openInEditor(input, getEditorID(input, element), true);
+       }
+
+       /**
+        * Utility method to get an editor input for the given file system location.
+        * If the location denotes a workspace file, a <code>FileEditorInput</code>
+        * is returned, otherwise, the input is an <code>IURIEditorInput</code>
+        * assuming the location points to an existing file in the file system.
+        * The <code>ICElement</code> is used to determine the associated project
+        * in case the location can not be resolved to a workspace <code>IFile</code>.
+        *
+        * @param locationURI  a valid file system location
+        * @param context  an element related to the target file, may be <code>null</code>
+        * @return an editor input
+        */
+       public static IEditorInput getEditorInputForLocation(URI locationURI, ICElement context) {
+               IFile resource= getWorkspaceFileAtLocation(locationURI, context);
+               if (resource != null) {
+                       return new FileEditorInput(resource);
+               }
+
+               if (context == null) {
+                       // try to synthesize a context for a location appearing on a project's
+                       // include paths
+                       try {
+                               ICProject[] projects = CCorePlugin.getDefault().getCoreModel().getCModel().getCProjects();
+                               outerFor: for (int i = 0; i < projects.length; i++) {
+                                       IIncludeReference[] includeReferences = projects[i].getIncludeReferences();
+                                       for (int j = 0; j < includeReferences.length; j++) {
+                                               // crecoskie test
+                                               // TODO FIXME
+                                               // include entries don't handle URIs yet, so fake it out for now
+                                               IPath path = URIUtil.toPath(locationURI);
+                                               if(path == null)
+                                                       path = new Path(locationURI.getPath());
+                                               
+                                               if (includeReferences[j].isOnIncludeEntry(path)) {
+                                                       context = projects[i];
+                                                       break outerFor;
+                                               }
+                                       }
+                               }
+                               if (context == null && projects.length > 0) {
+                                       // last resort: just take any of them
+                                       context= projects[0];
+                               }
+                       } catch (CModelException e) {
+                       }
+               }
+
+               if (context != null) {
+                       // try to get a translation unit from the location and associated element
+                       ICProject cproject= context.getCProject();
+                       if (cproject != null) {
+                               ITranslationUnit unit = CoreModel.getDefault().createTranslationUnitFrom(cproject, locationURI);
+                               if (unit != null) {
+                                       IFileStore fileStore = null;
+                                       try {
+                                               fileStore = EFS.getStore(locationURI);
+                                       } catch (CoreException e) {
+                                               // TODO Auto-generated catch block
+                                               e.printStackTrace();
+                                               return null;
+                                       }
+                                       
+                                       if(fileStore != null)
+                                               return new ExternalEditorInput(unit);
+                               }
+                               // no translation unit - still try to get a sensible marker resource
+                               // from the associated element
+                               IResource markerResource= cproject.getProject();
+                               return new ExternalEditorInput(locationURI, markerResource);
+                       }
+               }
+               return new ExternalEditorInput(locationURI);
+       }
+
+       public static IEditorInput getEditorInputForLocation(IPath location, ICElement context) {
+               IFile resource= getWorkspaceFileAtLocation(location, context);
+               if (resource != null) {
+                       return new FileEditorInput(resource);
+               }
+               if (location.isUNC()) {
+                       return getEditorInputForLocation(UNCPathConverter.getInstance().toURI(location), context);
+               }
+
+               if (context == null) {
+                       // try to synthesize a context for a location appearing on a project's
+                       // include paths
+                       try {
+                               ICProject[] projects = CCorePlugin.getDefault().getCoreModel().getCModel().getCProjects();
+                               outerFor: for (int i = 0; i < projects.length; i++) {
+                                       IIncludeReference[] includeReferences = projects[i].getIncludeReferences();
+                                       for (int j = 0; j < includeReferences.length; j++) {
+                                               if (includeReferences[j].isOnIncludeEntry(location)) {
+                                                       context = projects[i];
+                                                       break outerFor;
+                                               }
+                                       }
+                               }
+                               if (context == null && projects.length > 0) {
+                                       // last resort: just take any of them
+                                       context= projects[0];
+                               }
+                       } catch (CModelException e) {
+                       }
+               }
+
+               if (context != null) {
+                       // try to get a translation unit from the location and associated element
+                       ICProject cproject= context.getCProject();
+                       if (cproject != null) {
+                               ITranslationUnit unit = CoreModel.getDefault().createTranslationUnitFrom(cproject, location);
+                               if (unit != null) {
+                                       return new ExternalEditorInput(unit);
+                               }
+                               // no translation unit - still try to get a sensible marker resource
+                               // from the associated element
+                               IResource markerResource= cproject.getProject();
+                               return new ExternalEditorInput(location, markerResource);
+                       }
+               }
+               return new ExternalEditorInput(location);
+       }
+
+       /**
+        * Utility method to resolve a file system location to a workspace resource.
+        * If a context element is given and there are multiple matches in the workspace,
+        * a resource with the same project of the context element are preferred.
+        *
+        * @param location  a valid file system location
+        * @param context  an element related to the target file, may be <code>null</code>
+        * @return an <code>IFile</code> or <code>null</code>
+        */
+       public static IFile getWorkspaceFileAtLocation(IPath location, ICElement context) {
+               IProject project= null;
+               if (context != null) {
+                       ICProject cProject= context.getCProject();
+                       if (cProject != null) {
+                               project= cProject.getProject();
+                       }
+               }
+               IFile file= ResourceLookup.selectFileForLocation(location, project);
+               if (file != null && file.isAccessible())
+                       return file;
+               
+               IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
+               // workaround http://bugs.eclipse.org/233939
+               file= root.getFileForLocation(location);
+               if (file != null && file.isAccessible()) 
+                       return file;
+
+               // try workspace relative path
+               if (location.segmentCount() >= 2) {
+                       // @see IContainer#getFile for the required number of segments
+                       file= root.getFile(location);
+                       if (file != null && file.isAccessible()) 
+                               return file;
+               }
+               return null;
+       }
+
+       /**
+        * Utility method to resolve a file system location to a workspace resource.
+        * If a context element is given and there are multiple matches in the workspace,
+        * a resource with the same project of the context element are preferred.
+        *
+        * @param locationURI  a valid Eclipse file system URI
+        * @param context  an element related to the target file, may be <code>null</code>
+        * @return an <code>IFile</code> or <code>null</code>
+        */
+       public static IFile getWorkspaceFileAtLocation(URI locationURI, ICElement context) {
+               IProject project= null;
+               if (context != null) {
+                       ICProject cProject= context.getCProject();
+                       if (cProject != null) {
+                               project= cProject.getProject();
+                       }
+               }
+               
+               IFile file= ResourceLookup.selectFileForLocationURI(locationURI, project);
+               if (file != null && file.isAccessible())
+                       return file;
+               
+               return null;
+       }
+       
+       /**
+        * If the current active editor edits a c element return it, else
+        * return null
+        */
+       public static ICElement getActiveEditorCInput() {
+               IWorkbenchPage page= CUIPlugin.getActivePage();
+               if (page != null) {
+                       IEditorPart part= page.getActiveEditor();
+                       if (part != null) {
+                               return getEditorInputCElement(part);
+                       }
+               }
+               return null;
+       }
+
+       public static ICElement getEditorInputCElement(IEditorPart part) {
+               IEditorInput editorInput= part.getEditorInput();
+               if (editorInput == null) {
+                       return null;
+               }
+               return (ICElement) editorInput.getAdapter(ICElement.class);
+       }
+
+       /**
+        * Gets the working copy of an translation unit opened in an editor
+        *
+        * @param tu the original translation unit (or another working copy)
+        * @return the working copy of the translation unit, or null if not found
+       */
+       public static ITranslationUnit getWorkingCopy(ITranslationUnit tu) {
+               if (tu == null)
+                       return null;
+               if (tu.isWorkingCopy())
+                       return tu;
+
+               return CDTUITools.getWorkingCopyManager().findSharedWorkingCopy(tu);
+       }
+
+       /**
+        * Determine the editor id from the given file name using
+        * the workspace-wide content-type definitions.
+        *
+        * @param name  the file name
+        * @return a valid editor id, never <code>null</code>
+        */
+       public static String getEditorID(String name) {
+               try {
+                       IEditorDescriptor descriptor = IDE.getEditorDescriptor(name);
+                       if (descriptor != null) {
+                               return descriptor.getId();
+                       }
+               } catch (PartInitException exc) {
+                       // ignore
+               }
+               return DEFAULT_TEXT_EDITOR_ID;
+       }
+
+       /**
+        * Determine the editor id from the given editor input and optional input object.
+        * When a translation unit can be obtained, the project-specific content-type
+        * mechanism is used to determine the correct editor id.
+        * If that fails, the editor id is determined by file name and extension using
+        * the workspace-wide content-type definitions.
+        *
+        * @param input  the editor input
+        * @param inputObject  the input object (used to create the editor input) or <code>null</code>
+        * @return a valid editor id, never <code>null</code>
+        */
+       public static String getEditorID(IEditorInput input, Object inputObject) {
+               ICElement cElement= null;
+               if (input instanceof IFileEditorInput) {
+                       IFileEditorInput editorInput = (IFileEditorInput)input;
+                       IFile file = editorInput.getFile();
+                       // Try file specific editor.
+                       try {
+                               String editorID = file.getPersistentProperty(IDE.EDITOR_KEY);
+                               if (editorID != null) {
+                                       IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
+                                       IEditorDescriptor desc = registry.findEditor(editorID);
+                                       if (desc != null) {
+                                               return editorID;
+                                       }
+                               }
+                       } catch (CoreException e) {
+                               // do nothing
+                       }
+                       cElement = CoreModel.getDefault().create(file);
+               } else if (input instanceof ITranslationUnitEditorInput) {
+                       ITranslationUnitEditorInput editorInput = (ITranslationUnitEditorInput)input;
+                       cElement = editorInput.getTranslationUnit();
+               } else if (inputObject instanceof ICElement) {
+                       cElement= (ICElement)inputObject;
+               }
+
+               // Choose an editor based on the content type
+               IContentType contentType= null;
+               if (cElement instanceof ITranslationUnit) {
+                       String contentTypeId= ((ITranslationUnit)cElement).getContentTypeId();
+                       if (contentTypeId != null) {
+                               contentType= Platform.getContentTypeManager().getContentType(contentTypeId);
+                       }
+               }
+               if (contentType == null) {
+                       IProject project= null;
+                       if (cElement != null) {
+                               project= cElement.getCProject().getProject();
+                       } else {
+                               IFile file= ResourceUtil.getFile(input);
+                               if (file != null) {
+                                       project= file.getProject();
+                               }
+                       }
+                       contentType= CCorePlugin.getContentType(project, input.getName());
+               }
+               // handle binary files without content-type (e.g. executables without extension)
+               if (contentType == null && cElement != null) {
+                       final int elementType= cElement.getElementType();
+                       if (elementType == ICElement.C_ARCHIVE || elementType == ICElement.C_BINARY) {
+                               contentType= Platform.getContentTypeManager().getContentType(CCorePlugin.CONTENT_TYPE_BINARYFILE);
+                       }
+               }
+               IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
+               IEditorDescriptor desc= registry.getDefaultEditor(input.getName(), contentType);
+               if (desc != null) {
+                       String editorID= desc.getId();
+                       if (input instanceof IFileEditorInput) {
+                               IFile file= ((IFileEditorInput)input).getFile();
+                               IDE.setDefaultEditor(file, editorID);
+                       }
+                       return editorID;
+               }
+
+               return DEFAULT_TEXT_EDITOR_ID;
+       }
+
+       /**
+        * Maps the localized modifier name to a code in the same
+        * manner as #findModifier.
+        *
+        * @return the SWT modifier bit, or <code>0</code> if no match was found
+        */
+       public static int findLocalizedModifier(String token) {
+               if (token == null)
+                       return 0;
+
+               if (token.equalsIgnoreCase(Action.findModifierString(SWT.CTRL)))
+                       return SWT.CTRL;
+               if (token.equalsIgnoreCase(Action.findModifierString(SWT.SHIFT)))
+                       return SWT.SHIFT;
+               if (token.equalsIgnoreCase(Action.findModifierString(SWT.ALT)))
+                       return SWT.ALT;
+               if (token.equalsIgnoreCase(Action.findModifierString(SWT.COMMAND)))
+                       return SWT.COMMAND;
+
+               return 0;
+       }
+
+       /**
+        * Returns the modifier string for the given SWT modifier
+        * modifier bits.
+        *
+        * @param stateMask     the SWT modifier bits
+        * @return the modifier string
+        * @since 2.1.1
+        */
+       public static String getModifierString(int stateMask) {
+               String modifierString= ""; //$NON-NLS-1$
+               if ((stateMask & SWT.CTRL) == SWT.CTRL)
+                       modifierString= appendModifierString(modifierString, SWT.CTRL);
+               if ((stateMask & SWT.ALT) == SWT.ALT)
+                       modifierString= appendModifierString(modifierString, SWT.ALT);
+               if ((stateMask & SWT.SHIFT) == SWT.SHIFT)
+                       modifierString= appendModifierString(modifierString, SWT.SHIFT);
+               if ((stateMask & SWT.COMMAND) == SWT.COMMAND)
+                       modifierString= appendModifierString(modifierString,  SWT.COMMAND);
+
+               return modifierString;
+       }
+
+       /**
+        * Appends to modifier string of the given SWT modifier bit
+        * to the given modifierString.
+        *
+        * @param modifierString        the modifier string
+        * @param modifier                      an int with SWT modifier bit
+        * @return the concatenated modifier string
+        * @since 2.1.1
+        */
+       private static String appendModifierString(String modifierString, int modifier) {
+               if (modifierString == null)
+                       modifierString= ""; //$NON-NLS-1$
+               String newModifierString= Action.findModifierString(modifier);
+               if (modifierString.length() == 0)
+                       return newModifierString;
+               return NLS.bind(CEditorMessages.EditorUtility_concatModifierStrings, new String[] {modifierString, newModifierString}); 
+       }
+
+       public static IStorage getStorage(IBinary bin) {
+               IStorage store = null;
+               try {
+                       IBuffer buffer = bin.getBuffer();
+                       if (buffer != null) {
+                               store = new FileStorage (new ByteArrayInputStream(buffer.getContents().getBytes()), bin.getPath());
+                       }
+               } catch (CModelException e) {
+                       // nothing;
+               }
+               return store;
+       }
+
+       /**
+        * Returns the C project for a given editor input or <code>null</code> if no corresponding
+        * C project exists.
+        *
+        * @param input the editor input
+        * @return the corresponding C project
+        *
+        * @since 5.0
+        */
+       public static ICProject getCProject(IEditorInput input) {
+               ICProject cProject= null;
+               if (input instanceof IFileEditorInput) {
+                       IProject project= ((IFileEditorInput) input).getFile().getProject();
+                       if (project != null) {
+                               cProject= CoreModel.getDefault().create(project);
+                               if (!cProject.exists())
+                                       cProject= null;
+                       }
+               } else if (input instanceof ITranslationUnitEditorInput) {
+                       final ITranslationUnit tu= ((ITranslationUnitEditorInput) input).getTranslationUnit();
+                       if (tu != null) {
+                               cProject= tu.getCProject();
+                       } else if (input instanceof ExternalEditorInput) {
+                               IResource resource= ((ExternalEditorInput) input).getMarkerResource();
+                               if (resource instanceof IProject) {
+                                       cProject= CoreModel.getDefault().create((IProject) resource);
+                               }
+                       }
+               }
+               return cProject;
+       }
+
+       /**
+        * Returns an array of all editors that have an unsaved content. If the identical content is
+        * presented in more than one editor, only one of those editor parts is part of the result.
+        * @param skipNonResourceEditors if <code>true</code>, editors whose inputs do not adapt to {@link IResource}
+        * are not saved
+        *
+        * @return an array of dirty editor parts
+        * @since 5.3
+        */
+       public static IEditorPart[] getDirtyEditors(boolean skipNonResourceEditors) {
+               Set<IEditorInput> inputs= new HashSet<IEditorInput>();
+               List<IEditorPart> result= new ArrayList<IEditorPart>(0);
+               IWorkbench workbench= PlatformUI.getWorkbench();
+               IWorkbenchWindow[] windows= workbench.getWorkbenchWindows();
+               for (IWorkbenchWindow window : windows) {
+                       IWorkbenchPage[] pages= window.getPages();
+                       for (IWorkbenchPage page : pages) {
+                               IEditorPart[] editors= page.getDirtyEditors();
+                               for (IEditorPart ep : editors) {
+                                       IEditorInput input= ep.getEditorInput();
+                                       if (inputs.add(input)) {
+                                               if (!skipNonResourceEditors || isResourceEditorInput(input)) {
+                                                       result.add(ep);
+                                               }
+                                       }
+                               }
+                       }
+               }
+               return result.toArray(new IEditorPart[result.size()]);
+       }
+
+       private static boolean isResourceEditorInput(IEditorInput input) {
+               if (input instanceof MultiEditorInput) {
+                       IEditorInput[] inputs= ((MultiEditorInput) input).getInput();
+                       for (IEditorInput input2 : inputs) {
+                               if (input2.getAdapter(IResource.class) != null) {
+                                       return true;
+                               }
+                       }
+               } else if (input.getAdapter(IResource.class) != null) {
+                       return true;
+               }
+               return false;
+       }
+
+       /**
+        * Returns the editors to save before performing global C-related
+        * operations.
+        *
+        * @param saveUnknownEditors <code>true</code> iff editors with unknown buffer management should also be saved
+        * @return the editors to save
+        * @since 5.3
+        */
+       public static IEditorPart[] getDirtyEditorsToSave(boolean saveUnknownEditors) {
+               Set<IEditorInput> inputs= new HashSet<IEditorInput>();
+               List<IEditorPart> result= new ArrayList<IEditorPart>(0);
+               IWorkbench workbench= PlatformUI.getWorkbench();
+               IWorkbenchWindow[] windows= workbench.getWorkbenchWindows();
+               for (IWorkbenchWindow window : windows) {
+                       IWorkbenchPage[] pages= window.getPages();
+                       for (IWorkbenchPage page : pages) {
+                               IEditorPart[] editors= page.getDirtyEditors();
+                               for (IEditorPart editor : editors) {
+                                       IEditorPart ep= editor;
+                                       IEditorInput input= ep.getEditorInput();
+                                       if (!mustSaveDirtyEditor(ep, input, saveUnknownEditors))
+                                               continue;
+
+                                       if (inputs.add(input))
+                                               result.add(ep);
+                               }
+                       }
+               }
+               return result.toArray(new IEditorPart[result.size()]);
+       }
+
+       private static boolean mustSaveDirtyEditor(IEditorPart ep, IEditorInput input, boolean saveUnknownEditors) {
+               /*
+                * Goal: save all editors that could interfere with refactoring operations.
+                *
+                * Always save all editors for translation units that are not working copies.
+                * (Leaving them dirty would cause problems, since the file buffer could have been
+                * modified but the C model is not reconciled.)
+                *
+                * If <code>saveUnknownEditors</code> is <code>true</code>, save all editors
+                * whose implementation is probably not based on file buffers.
+                */
+               IResource resource= (IResource) input.getAdapter(IResource.class);
+               if (resource == null)
+                       return saveUnknownEditors;
+
+               ICElement element= CCorePlugin.getDefault().getCoreModel().create(resource);
+               if (element instanceof ITranslationUnit) {
+                       ITranslationUnit tu= (ITranslationUnit) element;
+                       if (getWorkingCopy(tu) == null) {
+                               return true;
+                       }
+               }
+
+               if (!(ep instanceof ITextEditor))
+                       return saveUnknownEditors;
+
+               ITextEditor textEditor= (ITextEditor) ep;
+               IDocumentProvider documentProvider= textEditor.getDocumentProvider();
+               if (!(documentProvider instanceof TextFileDocumentProvider))
+                       return saveUnknownEditors;
+
+               return false;
+       }
+
+       /**
+        * Return the regions of all lines which have changed in the given buffer since the
+        * last save occurred. Each region in the result spans over the size of at least one line.
+        * If successive lines have changed a region spans over the size of all successive lines.
+        * The regions include line delimiters.
+        * 
+        * @param buffer the buffer to compare contents from
+        * @param monitor to report progress to
+        * @return the regions of the changed lines
+        * @throws CoreException
+        * @since 5.1
+        */
+       public static IRegion[] calculateChangedLineRegions(final ITextFileBuffer buffer,
+                       final IProgressMonitor monitor) throws CoreException {
+               final IRegion[][] result= new IRegion[1][];
+               final IStatus[] errorStatus= new IStatus[] { Status.OK_STATUS };
+       
+               try {
+                       SafeRunner.run(new ISafeRunnable() {
+                               /*
+                                * @see org.eclipse.core.runtime.ISafeRunnable#handleException(java.lang.Throwable)
+                                */
+                               public void handleException(Throwable exception) {
+                                       CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID,
+                                                       ICStatusConstants.EDITOR_CHANGED_REGION_CALCULATION, exception.getLocalizedMessage(),
+                                                       exception));
+                                       String msg= Messages.EditorUtility_error_calculatingChangedRegions;
+                                       errorStatus[0]= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID,
+                                                       ICStatusConstants.EDITOR_CHANGED_REGION_CALCULATION, msg, exception);
+                                       result[0]= null;
+                               }
+       
+                               /*
+                                * @see org.eclipse.core.runtime.ISafeRunnable#run()
+                                */
+                               public void run() throws Exception {
+                                       monitor.beginTask(Messages.EditorUtility_calculatingChangedRegions_message, 20);
+                                       IFileStore fileStore= buffer.getFileStore();
+       
+                                       ITextFileBufferManager fileBufferManager= FileBuffers.createTextFileBufferManager();
+                                       fileBufferManager.connectFileStore(fileStore, getSubProgressMonitor(monitor, 15));
+                                       try {
+                                               IDocument currentDocument= buffer.getDocument();
+                                               IDocument oldDocument= 
+                                                               ((ITextFileBuffer) fileBufferManager.getFileStoreFileBuffer(fileStore)).getDocument();
+       
+                                               result[0]= getChangedLineRegions(oldDocument, currentDocument);
+                                       } finally {
+                                               fileBufferManager.disconnectFileStore(fileStore, getSubProgressMonitor(monitor, 5));
+                                               monitor.done();
+                                       }
+                               }
+
+                               /**
+                                * Return regions of all lines which differ comparing <code>oldDocument</code>s content
+                                * with <code>currentDocument</code>s content. Successive lines are merged into one region.
+                                * 
+                                * @param oldDocument a document containing the old content
+                                * @param currentDocument a document containing the current content
+                                * @return the changed regions
+                                * @throws BadLocationException
+                                */
+                               private IRegion[] getChangedLineRegions(IDocument oldDocument, IDocument currentDocument) {
+                                       /*
+                                        * Do not change the type of those local variables. We use Object
+                                        * here in order to prevent loading of the Compare plug-in at load
+                                        * time of this class.
+                                        */
+                                       Object leftSide= new LineComparator(oldDocument);
+                                       Object rightSide= new LineComparator(currentDocument);
+
+                                       RangeDifference[] differences= RangeDifferencer.findDifferences((IRangeComparator) leftSide, (IRangeComparator) rightSide);
+
+                                       // It holds that:
+                                       // 1. Ranges are sorted:
+                                       //     forAll r1,r2 element differences: indexOf(r1) < indexOf(r2) -> r1.rightStart() < r2.rightStart();
+                                       // 2. Successive changed lines are merged into on RangeDifference
+                                       //     forAll r1,r2 element differences: r1.rightStart() < r2.rightStart() -> r1.rightEnd() < r2.rightStart
+
+                                       List<IRegion> regions= new ArrayList<IRegion>();
+                                       final int numberOfLines= currentDocument.getNumberOfLines();
+                                       for (RangeDifference curr : differences) {
+                                               if (curr.kind() == RangeDifference.CHANGE) {
+                                                       int startLine= Math.min(curr.rightStart(), numberOfLines - 1);
+                                                       int endLine= curr.rightEnd() - 1;
+
+                                                       IRegion startLineRegion;
+                                                       try {
+                                                               startLineRegion = currentDocument.getLineInformation(startLine);
+                                                               if (startLine >= endLine) {
+                                                                       // startLine > endLine indicates a deletion of one or more lines.
+                                                                       // Deletions are ignored except at the end of the document. 
+                                                                       if (startLine == endLine ||
+                                                                                       startLineRegion.getOffset() + startLineRegion.getLength() == currentDocument.getLength()) {
+                                                                               regions.add(startLineRegion);
+                                                                       }
+                                                               } else {
+                                                                       IRegion endLineRegion= currentDocument.getLineInformation(endLine);
+                                                                       int startOffset= startLineRegion.getOffset();
+                                                                       int endOffset= endLineRegion.getOffset() + endLineRegion.getLength();
+                                                                       regions.add(new Region(startOffset, endOffset - startOffset));
+                                                               }
+                                                       } catch (BadLocationException e) {
+                                                               CUIPlugin.log(e);
+                                                       }
+                                               }
+                                       }
+
+                                       return regions.toArray(new IRegion[regions.size()]);
+                               }
+                       });
+               } finally {
+                       if (!errorStatus[0].isOK())
+                               throw new CoreException(errorStatus[0]);
+               }
+       
+               return result[0];
+       }
+
+       /**
+        * Creates and returns a new sub-progress monitor for
+        * the given parent monitor.
+        *
+        * @param monitor the parent progress monitor
+        * @param ticks the number of work ticks allocated from the parent monitor
+        * @return the new sub-progress monitor
+        */
+       private static IProgressMonitor getSubProgressMonitor(IProgressMonitor monitor, int ticks) {
+               if (monitor != null)
+                       return new SubProgressMonitor(monitor, ticks, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
+
+               return new NullProgressMonitor();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExceptionHandler.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExceptionHandler.java
new file mode 100644 (file)
index 0000000..5bbf74c
--- /dev/null
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Rational Software - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.util;
+
+
+import java.io.StringWriter;
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.internal.ui.CStatusConstants;
+import org.eclipse.cdt.internal.ui.CUIMessages;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+
+/**
+ * The default exception handler shows an error dialog when one of its handle methods
+ * is called. If the passed exception is a <code>CoreException</code> an error dialog
+ * pops up showing the exception's status information. For a <code>InvocationTargetException</code>
+ * a normal message dialog pops up showing the exception's message. Additionally the exception
+ * is written to the platform log.
+ */
+public class ExceptionHandler {
+
+       private static ExceptionHandler fgInstance= new ExceptionHandler();
+       
+       /**
+        * Logs the given exception using the platform's logging mechanism. The exception is
+        * logged as an error with the error code <code>JavaStatusConstants.INTERNAL_ERROR</code>.
+        */
+       public static void log(Throwable t, String message) {
+               CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), 
+                       CStatusConstants.INTERNAL_ERROR, message, t));
+       }
+       
+       /**
+        * Handles the given <code>CoreException</code>. The workbench shell is used as a parent
+        * for the dialog window.
+        * 
+        * @param e the <code>CoreException</code> to be handled
+        * @param title the dialog window's window title
+        * @param message message to be displayed by the dialog window
+        */
+       public static void handle(CoreException e, String title, String message) {
+               handle(e, CUIPlugin.getActiveWorkbenchShell(), title, message);
+       }
+       
+       /**
+        * Handles the given <code>CoreException</code>. 
+        * 
+        * @param e the <code>CoreException</code> to be handled
+        * @param parent the dialog window's parent shell
+        * @param title the dialog window's window title
+        * @param message message to be displayed by the dialog window
+        */
+       public static void handle(CoreException e, Shell parent, String title, String message) {
+               fgInstance.perform(e, parent, title, message);
+       }
+       
+       /**
+        * Handles the given <code>InvocationTargetException</code>. The workbench shell is used 
+        * as a parent for the dialog window.
+        * 
+        * @param e the <code>InvocationTargetException</code> to be handled
+        * @param title the dialog window's window title
+        * @param message message to be displayed by the dialog window
+        */
+       public static void handle(InvocationTargetException e, String title, String message) {
+               handle(e, CUIPlugin.getActiveWorkbenchShell(), title, message);
+       }
+       
+       /**
+        * Handles the given <code>InvocationTargetException</code>. 
+        * 
+        * @param e the <code>InvocationTargetException</code> to be handled
+        * @param parent the dialog window's parent shell
+        * @param title the dialog window's window title
+        * @param message message to be displayed by the dialog window
+        */
+       public static void handle(InvocationTargetException e, Shell parent, String title, String message) {
+               fgInstance.perform(e, parent, title, message);
+       }
+
+       //---- Hooks for subclasses to control exception handling ------------------------------------
+       
+       protected void perform(CoreException e, Shell shell, String title, String message) {
+               CUIPlugin.log(e);
+               IStatus status= e.getStatus();
+               if (status != null) {
+                       ErrorDialog.openError(shell, title, message, status);
+               } else {
+                       displayMessageDialog(e, e.getMessage(), shell, title, message);
+               }
+       }
+
+       protected void perform(InvocationTargetException e, Shell shell, String title, String message) {
+               Throwable target= e.getTargetException();
+               if (target instanceof CoreException) {
+                       perform((CoreException)target, shell, title, message);
+               } else {
+                       CUIPlugin.log(e);
+                       if (e.getMessage() != null && e.getMessage().length() > 0) {
+                               displayMessageDialog(e, e.getMessage(), shell, title, message);
+                       } else {
+                               displayMessageDialog(e, target.getMessage(), shell, title, message);
+                       }
+               }
+       }
+
+       //---- Helper methods -----------------------------------------------------------------------
+       
+       private void displayMessageDialog(Throwable t, String exceptionMessage, Shell shell, String title, String message) {
+               StringWriter msg= new StringWriter();
+               if (message != null) {
+                       msg.write(message);
+                       msg.write("\n\n"); //$NON-NLS-1$
+               }
+               if (exceptionMessage == null || exceptionMessage.length() == 0)
+                       msg.write(CUIMessages.ExceptionDialog_seeErrorLogMessage); 
+               else
+                       msg.write(exceptionMessage);
+               MessageDialog.openError(shell, title, msg.toString());                  
+       }       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExternalEditorInput.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExternalEditorInput.java
new file mode 100644 (file)
index 0000000..5f8733d
--- /dev/null
@@ -0,0 +1,159 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.util;
+
+
+import java.net.URI;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.filesystem.URIUtil;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.ide.FileStoreEditorInput;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.editor.ITranslationUnitEditorInput;
+
+
+/**
+ * An EditorInput for an external (non-workspace) file.
+ */
+public final class ExternalEditorInput extends FileStoreEditorInput implements ITranslationUnitEditorInput {
+           
+       private final IPath location;
+       private final IResource markerResource;
+       private ITranslationUnit unit;
+
+       /**
+        * Create an editor input for an external translation unit.
+        * 
+        * @param unit  the translation unit
+        */
+       public ExternalEditorInput(ITranslationUnit unit) {
+               this(unit.getLocationURI(), unit.getCProject().getProject());
+               Assert.isNotNull(unit);
+               this.unit = unit;
+       }
+
+       /**
+        * Create an editor input for an external file of the local file system.
+        * 
+        * @param location  the file system location
+        */
+       public ExternalEditorInput(IPath location) {
+               this(URIUtil.toURI(location), null);
+       }
+
+       /**
+        * Create an editor input for an external file of the local file system.
+        * 
+        * @param location  the file system location
+        * @param markerResource  the associated marker resource, may be <code>null</code>
+        */
+       public ExternalEditorInput(IPath location, IResource markerResource) {
+               this(URIUtil.toURI(location), markerResource);
+       }
+
+       /**
+        * Create an editor input for a location URI.
+        * 
+        * @param locationURI  the location URI
+        */
+       public ExternalEditorInput(URI locationURI) {
+               this(locationURI, null);
+       }
+
+       /**
+        * Create an editor input for a location URI.
+        * 
+        * @param locationURI  the location URI
+        * @param markerResource  the associated marker resource, may be <code>null</code>
+        */
+       public ExternalEditorInput(URI locationURI, IResource markerResource) {
+               super(getFileStore(locationURI));
+               this.location = URIUtil.toPath(locationURI);
+               this.markerResource = markerResource;
+       }
+
+       private static IFileStore getFileStore(URI locationURI) {
+               try {
+                       return EFS.getStore(locationURI);
+               } catch (CoreException exc) {
+                       CUIPlugin.log(exc);
+               }
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.editor.ITranslationUnitEditorInput#getTranslationUnit()
+        */
+       public ITranslationUnit getTranslationUnit() {
+               return unit;
+       }
+
+       /*
+        * @see org.eclipse.ui.ide.FileStoreEditorInput#getAdapter(java.lang.Class)
+        */
+       @SuppressWarnings({ "unchecked", "rawtypes" })
+       @Override
+       public Object getAdapter(Class adapter) {
+               if (adapter.isAssignableFrom(ITranslationUnit.class) && unit != null) {
+                       return unit;
+               }
+               return super.getAdapter(adapter);
+       }
+
+       /**
+        * Return the resource where markers for this external editor input are stored
+        */
+       public IResource getMarkerResource() {
+               return markerResource;
+       }
+
+       /*
+        * @see org.eclipse.ui.IPersistableElement#getFactoryId()
+        */
+       @Override
+       public String getFactoryId() {
+               if (getPath() != null) {
+                       return ExternalEditorInputFactory.ID;
+               }
+               return super.getFactoryId();
+       }
+
+       /*
+        * @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento)
+        */
+       @Override
+       public void saveState(IMemento memento) {
+               if (getPath() != null) {
+                       ExternalEditorInputFactory.saveState(memento, this);
+               } else {
+                       super.saveState(memento);
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.IPathEditorInput#getPath()
+        * Note: ExternalEditorInput must not implement IPathEditorInput!
+        */
+       public IPath getPath() {
+               return location;
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExternalEditorInputFactory.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ExternalEditorInputFactory.java
new file mode 100644 (file)
index 0000000..ba51f5b
--- /dev/null
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.util;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.ui.IElementFactory;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IPersistableElement;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+/**
+ * The ExternalEditorInputFactory is used to save and recreate an ExternalEditorInput object.
+ * As such, it implements the IPersistableElement interface for storage
+ * and the IElementFactory interface for recreation.
+ *
+ * @see IMemento
+ * @see IPersistableElement
+ * @see IElementFactory
+ *
+ * @since 4.0
+ */
+public class ExternalEditorInputFactory implements IElementFactory {
+
+       public static final String ID = "org.eclipse.cdt.ui.ExternalEditorInputFactory"; //$NON-NLS-1$
+
+    private static final String TAG_PATH = "path";//$NON-NLS-1$
+    private static final String TAG_PROJECT = "project";//$NON-NLS-1$
+
+       /*
+        * @see org.eclipse.ui.IElementFactory#createElement(org.eclipse.ui.IMemento)
+        */
+       public IAdaptable createElement(IMemento memento) {
+        // Get the file name.
+        String fileName = memento.getString(TAG_PATH);
+        if (fileName == null) {
+                       return null;
+               }
+
+        IPath location= new Path(fileName);
+        ICProject cProject= null;
+        
+        String projectName= memento.getString(TAG_PROJECT);
+        if (projectName != null) {
+               IProject project= ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+               if (project.isAccessible() && CoreModel.hasCNature(project)) {
+                       cProject= CoreModel.getDefault().create(project);
+               }
+        }
+               return EditorUtility.getEditorInputForLocation(location, cProject);
+       }
+
+       /**
+        * Save the element state.
+        * 
+        * @param memento  the storage
+        * @param input  the element
+        */
+       static void saveState(IMemento memento, ExternalEditorInput input) {
+               IPath location= input.getPath();
+               if (location != null) {
+                       memento.putString(TAG_PATH, location.toOSString());
+               }
+               IProject project= null;
+               ITranslationUnit unit= input.getTranslationUnit();
+               if (unit != null) {
+                       project= unit.getCProject().getProject();
+               }
+               if (project == null && input.getMarkerResource() instanceof IProject) {
+                       project= (IProject)input.getMarkerResource();
+               }
+               if (project != null) {
+                       memento.putString(TAG_PROJECT, project.getName());
+               }
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/IDebugLogConstants.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/IDebugLogConstants.java
new file mode 100644 (file)
index 0000000..2eef977
--- /dev/null
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.util;
+
+public interface IDebugLogConstants {
+       public class DebugLogConstant {
+               private DebugLogConstant( int value )
+               {
+               }
+       }
+       
+       public static final DebugLogConstant CONTENTASSIST = new DebugLogConstant ( 1 );
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/IProblemChangedListener.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/IProblemChangedListener.java
new file mode 100644 (file)
index 0000000..7c7f261
--- /dev/null
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2000 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.util;
+
+import org.eclipse.core.resources.IResource;
+
+/**
+ * Can be added to a ProblemMarkerManager to get notified about error
+ * marker changes. Used to update error ticks.
+ */
+public interface IProblemChangedListener {
+       
+       /**
+        * @param changedElements  A set of type <code>IPath</code> that
+        * describe the resources that had an error marker change.
+        */
+       void problemsChanged(IResource[] changedResources, boolean markerChanged);
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ImageDescriptorRegistry.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ImageDescriptorRegistry.java
new file mode 100644 (file)
index 0000000..5991804
--- /dev/null
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.util;
+
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.core.runtime.Assert;
+
+/**
+ * A registry that maps <code>ImageDescriptors</code> to <code>Image</code>.
+ */
+public class ImageDescriptorRegistry {
+
+       private HashMap<ImageDescriptor, Image> fRegistry= new HashMap<ImageDescriptor, Image>(10);
+       private Display fDisplay;
+       
+       /**
+        * Creates a new image descriptor registry for the current or default display,
+        * respectively.
+        */
+       public ImageDescriptorRegistry() {
+               this(SWTUtil.getStandardDisplay());
+       }
+       
+       /**
+        * Creates a new image descriptor registry for the given display. All images
+        * managed by this registry will be disposed when the display gets disposed.
+        * 
+        * @param display the display the images managed by this registry are allocated for 
+        */
+       public ImageDescriptorRegistry(Display display) {
+               fDisplay= display;
+               Assert.isNotNull(fDisplay);
+               hookDisplay();
+       }
+       
+       /**
+        * Returns the image assiciated with the given image descriptor.
+        * 
+        * @param descriptor the image descriptor for which the registry manages an image
+        * @return the image associated with the image descriptor or <code>null</code>
+        *  if the image descriptor can't create the requested image.
+        */
+       public Image get(ImageDescriptor descriptor) {
+               if (descriptor == null)
+                       descriptor= ImageDescriptor.getMissingImageDescriptor();
+                       
+               Image result= fRegistry.get(descriptor);
+               if (result != null)
+                       return result;
+       
+               Assert.isTrue(fDisplay == SWTUtil.getStandardDisplay(), "Allocating image for wrong display."); //$NON-NLS-1$
+               result= descriptor.createImage();
+               if (result != null)
+                       fRegistry.put(descriptor, result);
+               return result;
+       }
+
+       /**
+        * Disposes all images managed by this registry.
+        */     
+       public void dispose() {
+               for (Iterator<Image> iter= fRegistry.values().iterator(); iter.hasNext(); ) {
+                       Image image= iter.next();
+                       image.dispose();
+               }
+               fRegistry.clear();
+       }
+       
+       private void hookDisplay() {
+               fDisplay.disposeExec(new Runnable() {
+                       public void run() {
+                               dispose();
+                       }       
+               });
+       }
+}
+
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/Messages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/Messages.java
new file mode 100644 (file)
index 0000000..704f586
--- /dev/null
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *    Sergey Prigogin (Google)
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.util;
+
+import com.ibm.icu.text.MessageFormat;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+       private static final String BUNDLE_NAME= Messages.class.getName();
+
+       public static String EditorUtility_calculatingChangedRegions_message;
+       public static String EditorUtility_error_calculatingChangedRegions;
+
+       public static String OpenExternalProblemAction_CannotReadExternalLocation;
+
+       public static String OpenExternalProblemAction_ErrorOpeningFile;
+
+       public static String format(String pattern, Object... arguments) {
+        return MessageFormat.format(pattern, arguments);
+    }
+    
+       private Messages() {
+               // Do not instantiate
+       }
+
+       static {
+               NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/Messages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/Messages.properties
new file mode 100644 (file)
index 0000000..4fc6559
--- /dev/null
@@ -0,0 +1,15 @@
+###############################################################################
+# Copyright (c) 2009 Google, Inc and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     Sergey Prigogin (Google) - initial API and implementation
+###############################################################################
+
+EditorUtility_calculatingChangedRegions_message=Calculating changed regions
+EditorUtility_error_calculatingChangedRegions=An error occurred while calculating the changed regions. See error log for details.
+OpenExternalProblemAction_CannotReadExternalLocation=Cannot read external location {0}
+OpenExternalProblemAction_ErrorOpeningFile=Error Opening File
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/NameComposer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/NameComposer.java
new file mode 100644 (file)
index 0000000..4492bca
--- /dev/null
@@ -0,0 +1,191 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Google, Inc and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *        Sergey Prigogin (Google) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.ibm.icu.text.BreakIterator;
+
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+import org.eclipse.cdt.internal.ui.text.CBreakIterator;
+
+/**
+ * Composes names according to a particular style. A seed name is split into
+ * words at non-alphanumeric characters and camel case boundaries. The resulting
+ * words are capitalized according to the given capitalization style, joined
+ * using the given delimiter and combined with the given prefix and suffix.
+ */
+public class NameComposer {
+       private static final int CAPITALIZATION_ORIGINAL = PreferenceConstants.NAME_STYLE_CAPITALIZATION_ORIGINAL;
+       private static final int CAPITALIZATION_UPPER_CASE = PreferenceConstants.NAME_STYLE_CAPITALIZATION_UPPER_CASE;
+       private static final int CAPITALIZATION_LOWER_CASE = PreferenceConstants.NAME_STYLE_CAPITALIZATION_LOWER_CASE;
+       private static final int CAPITALIZATION_CAMEL_CASE = PreferenceConstants.NAME_STYLE_CAPITALIZATION_CAMEL_CASE;
+       private static final int CAPITALIZATION_LOWER_CAMEL_CASE = PreferenceConstants.NAME_STYLE_CAPITALIZATION_LOWER_CAMEL_CASE;
+
+       private final int capitalization;
+       private final String wordDelimiter;
+       private final String prefix;
+       private final String suffix;
+
+       /**
+        * Creates a name composer for a given style.
+        * 
+        * @param capitalization capitalization transformation applied to name. Possible values: <ul>
+        * <li>PreferenceConstants.NAME_STYLE_CAPITALIZATION_ORIGINAL,</li>
+        * <li>PreferenceConstants.NAME_STYLE_CAPITALIZATION_UPPER_CASE,</li>
+        * <li>PreferenceConstants.NAME_STYLE_CAPITALIZATION_LOWER_CASE,</li>
+        * <li>PreferenceConstants.NAME_STYLE_CAPITALIZATION_CAMEL_CASE,</li>
+        * <li>PreferenceConstants.NAME_STYLE_CAPITALIZATION_LOWER_CAMEL_CASE.</li>
+        * </ul>
+        * @param wordDelimiter delimiter inserted between words
+        * @param prefix prefix prepended to the name
+        * @param suffix suffix appended to the name
+        */
+       public NameComposer(int capitalization, String wordDelimiter, String prefix, String suffix) {
+               this.capitalization = capitalization;
+               this.wordDelimiter = wordDelimiter;
+               this.prefix = prefix;
+               this.suffix = suffix;
+       }
+
+       /**
+        * Composes a name according to the composer's style based on a seed name.
+        * 
+        * @param seedName the name used as an inspiration
+        * @return the composed name
+        */
+       public String compose(String seedName) {
+               List<CharSequence> words = splitIntoWords(seedName);
+               return compose(words);
+       }
+
+       /**
+        * Composes a name according to the composer's style based on a seed words.
+        * 
+        * @param words the words that that should be combined to form the name
+        * @return the composed name
+        */
+       public String compose(List<CharSequence> words) {
+               StringBuilder buf = new StringBuilder();
+               buf.append(prefix);
+               for (int i = 0; i < words.size(); i++) {
+                       if (i > 0) {
+                               buf.append(wordDelimiter);
+                       }
+                       CharSequence word = words.get(i);
+                       switch (capitalization) {
+                       case CAPITALIZATION_ORIGINAL:
+                               buf.append(word);
+                               break;
+                       case CAPITALIZATION_UPPER_CASE:
+                               appendUpperCase(buf, word);
+                               break;
+                       case CAPITALIZATION_LOWER_CASE:
+                               appendLowerCase(buf, word);
+                               break;
+                       case CAPITALIZATION_CAMEL_CASE:
+                               appendTitleCase(buf, word);
+                               break;
+                       case CAPITALIZATION_LOWER_CAMEL_CASE:
+                               if (i == 0) {
+                                       appendLowerCase(buf, word);
+                               } else {
+                                       appendTitleCase(buf, word);
+                               }
+                               break;
+                       }
+               }
+               buf.append(suffix);
+               return buf.toString();
+       }
+
+       /**
+        * Splits a name into words at non-alphanumeric characters and camel case boundaries.
+        */
+       public List<CharSequence> splitIntoWords(CharSequence name) {
+               List<CharSequence> words = new ArrayList<CharSequence>();
+               CBreakIterator iterator = new CBreakIterator();
+               iterator.setText(name);
+               int end;
+               for (int start = iterator.first(); (end = iterator.next()) != BreakIterator.DONE; start = end) {
+                       if (Character.isLetterOrDigit(name.charAt(start))) {
+                               int pos = end;
+                               while (--pos >= start && !Character.isLetterOrDigit(name.charAt(pos))) {
+                               }
+                               words.add(name.subSequence(start, pos + 1));
+                       }
+               }
+               return words;
+       }
+
+       private void appendUpperCase(StringBuilder buf, CharSequence word) {
+               for (int i = 0; i < word.length(); i++) {
+                       buf.append(Character.toUpperCase(word.charAt(i)));
+               }
+       }
+
+       private void appendLowerCase(StringBuilder buf, CharSequence word) {
+               for (int i = 0; i < word.length(); i++) {
+                       buf.append(Character.toLowerCase(word.charAt(i)));
+               }
+       }
+
+       private void appendTitleCase(StringBuilder buf, CharSequence word) {
+               for (int i = 0; i < word.length(); i++) {
+                       buf.append(i == 0 ?
+                                       Character.toUpperCase(word.charAt(i)) : Character.toLowerCase(word.charAt(i)));
+               }
+       }
+
+       /**
+        * Returns the trimmed field name. Leading and trailing non-alphanumeric characters are trimmed.
+        * If the first word of the name consists of a single letter and the name contains more than
+        * one word, the first word is removed.
+        * 
+        * @param fieldName a field name to trim
+        * @return the trimmed field name
+        */
+       public static String trimFieldName(String fieldName){
+               CBreakIterator iterator = new CBreakIterator();
+               iterator.setText(fieldName);
+               int firstWordStart = -1;
+               int firstWordEnd = -1;
+               int secondWordStart = -1;
+               int lastWordEnd = -1;
+               int end;
+               for (int start = iterator.first(); (end = iterator.next()) != BreakIterator.DONE; start = end) {
+                       if (Character.isLetterOrDigit(fieldName.charAt(start))) {
+                               int pos = end;
+                               while (--pos >= start && !Character.isLetterOrDigit(fieldName.charAt(pos))) {
+                               }
+                               lastWordEnd = pos + 1;
+                               if (firstWordStart < 0) {
+                                       firstWordStart = start;
+                                       firstWordEnd = lastWordEnd;
+                               } else if (secondWordStart < 0) {
+                                       secondWordStart = start;
+                               }
+                       }
+               }
+               // Skip the first word if it consists of a single letter and the name contains more than
+               // one word.
+               if (firstWordStart >= 0 && firstWordStart + 1 == firstWordEnd && secondWordStart >= 0) {
+                       firstWordStart = secondWordStart;
+               }
+               if (firstWordStart < 0) {
+                       return fieldName;
+               } else {
+                       return fieldName.substring(firstWordStart, lastWordEnd);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/OpenExternalProblemAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/OpenExternalProblemAction.java
new file mode 100644 (file)
index 0000000..f69ae0a
--- /dev/null
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Siemens AG and others.
+ * All rights reserved. This content and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Norbert Ploett (Siemens AG)
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.util;
+
+import java.io.File;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.actions.ActionDelegate;
+import org.eclipse.ui.ide.IDE;
+
+import org.eclipse.cdt.core.model.ICModelMarker;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.model.CModelManager;
+
+public class OpenExternalProblemAction extends ActionDelegate implements IObjectActionDelegate {
+       
+       IStructuredSelection selection ;
+
+       public OpenExternalProblemAction() {
+       }
+
+       public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+               
+       }
+
+       @Override
+       public void runWithEvent(IAction action, Event event) {
+               Object object = selection.getFirstElement();
+               if (object instanceof IMarker) {
+                       try {
+                               IMarker marker = (IMarker) object;
+                               Object attributeObject = marker.getAttribute(ICModelMarker.C_MODEL_MARKER_EXTERNAL_LOCATION);
+                               if (attributeObject instanceof String)  {
+                                       String externalLocation = (String) attributeObject;
+                                       IPath externalPath = new Path(externalLocation);
+                                       
+                                       File file = externalPath.toFile() ;
+                                       if (!file.canRead()) {
+                                               MessageBox errorMsg = new MessageBox(CUIPlugin.getActiveWorkbenchShell(), SWT.ICON_ERROR | SWT.OK);
+                                               errorMsg.setText(Messages.OpenExternalProblemAction_ErrorOpeningFile);
+                                               errorMsg.setMessage(NLS.bind(Messages.OpenExternalProblemAction_CannotReadExternalLocation, externalPath));
+                                               errorMsg.open();
+                                               return;
+                                       }
+                                       
+                                       IEditorPart editor = EditorUtility.openInEditor(externalPath, getCProject(marker));
+                                       if (editor != null) {
+                                               IDE.gotoMarker(editor, marker);
+                                       }
+                               }
+                       } catch (CoreException e) {
+                               CUIPlugin.log(e.getStatus());
+                       }
+               }
+       }
+       
+       private ICProject getCProject(IMarker marker)  {
+               ICProject cproject = null ;
+               
+               if (marker.getResource() instanceof IProject) {
+                       IProject project = (IProject) marker.getResource();
+                       cproject = CModelManager.getDefault().create(project);
+               }
+               return cproject ;
+       }
+       
+       @Override
+       public void selectionChanged(IAction action, ISelection selection) {
+               boolean enable = false;
+               if (selection instanceof IStructuredSelection) {
+                       Object object = ((IStructuredSelection) selection).getFirstElement();
+                       if (object instanceof IMarker) {
+                               try {
+                                       IMarker marker = (IMarker) object;
+                                       if ((marker.isSubtypeOf(ICModelMarker.C_MODEL_PROBLEM_MARKER))
+                                                       &&(null!=marker.getAttribute(ICModelMarker.C_MODEL_MARKER_EXTERNAL_LOCATION, null))) {
+                                                       enable = true;
+                                       }
+                                       this.selection = (IStructuredSelection)selection;
+                                       action.setEnabled(enable);
+                               } catch (CoreException e) {
+                               }
+                       }
+               }
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/PendingUpdateAdapter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/PendingUpdateAdapter.java
new file mode 100644 (file)
index 0000000..eb042d7
--- /dev/null
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.util;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+
+/**
+ * The PendingUpdateAdapter is a convenience object that can be used
+ * by a BaseWorkbenchContentProvider that wants to show a pending update.
+ */
+public class PendingUpdateAdapter implements IWorkbenchAdapter, IAdaptable {
+
+    boolean removed = false;
+
+    /**
+     * Return whether or not this has been removed from the tree.
+     * @return boolean
+     */
+    public boolean isRemoved() {
+        return removed;
+    }
+
+    /**
+     * Set whether or not this has been removed from the tree.
+     * @param removedValue boolean
+     */
+    public void setRemoved(boolean removedValue) {
+        this.removed = removedValue;
+    }
+
+    /**
+     * Create a new instance of the receiver.
+     */
+    public PendingUpdateAdapter() {
+        //No initial behavior
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+     */
+    @SuppressWarnings("rawtypes")
+       public Object getAdapter(Class adapter) {
+        if (adapter == IWorkbenchAdapter.class)
+            return this;
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
+     */
+    public Object[] getChildren(Object o) {
+        return new Object[0];
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
+     */
+    public ImageDescriptor getImageDescriptor(Object object) {
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
+     */
+    public String getLabel(Object o) {
+        return "Pending"; //$NON-NLS-1$
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
+     */
+    public Object getParent(Object o) {
+        return null;
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemMarkerManager.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemMarkerManager.java
new file mode 100644 (file)
index 0000000..9dc4f33
--- /dev/null
@@ -0,0 +1,190 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.util;
+
+import java.util.HashSet;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IMarkerDelta;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.jface.text.source.AnnotationModelEvent;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.text.source.IAnnotationModelListener;
+import org.eclipse.jface.text.source.IAnnotationModelListenerExtension;
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.editor.TranslationUnitAnnotationModelEvent;
+
+/**
+ * Listens to resource deltas and filters for marker changes of type
+ * IMarker.PROBLEM Viewers showing error ticks should register as listener to
+ * this type.
+ */
+public class ProblemMarkerManager implements IResourceChangeListener, IAnnotationModelListener, IAnnotationModelListenerExtension {
+
+       /**
+        * Visitors used to filter the element delta changes
+        */
+       private static class ProjectErrorVisitor implements IResourceDeltaVisitor {
+
+               private HashSet<IResource> fChangedElements;
+
+               public ProjectErrorVisitor(HashSet<IResource> changedElements) {
+                       fChangedElements = changedElements;
+               }
+
+               public boolean visit(IResourceDelta delta) throws CoreException {
+                       IResource res = delta.getResource();
+                       if (res instanceof IProject && delta.getKind() == IResourceDelta.CHANGED) {
+                               IProject project = (IProject)res;
+                               if (!project.isAccessible()) {
+                                       // only track open C projects
+                                       return false;
+                               }
+                       }
+                       checkInvalidate(delta, res);
+                       return true;
+               }
+
+               private void checkInvalidate(IResourceDelta delta, IResource resource) {
+                       int kind = delta.getKind();
+                       if (kind == IResourceDelta.REMOVED || kind == IResourceDelta.ADDED
+                                       || (kind == IResourceDelta.CHANGED && isErrorDelta(delta))) {
+                               // invalidate the path and all parent paths
+                               while (resource.getType() != IResource.ROOT && fChangedElements.add(resource)) {
+                                       resource = resource.getParent();
+                               }
+                       }
+               }
+
+               private boolean isErrorDelta(IResourceDelta delta) {
+                       if ( (delta.getFlags() & IResourceDelta.MARKERS) != 0) {
+                               IMarkerDelta[] markerDeltas = delta.getMarkerDeltas();
+                               for (IMarkerDelta markerDelta : markerDeltas) {
+                                       if (markerDelta.isSubtypeOf(IMarker.PROBLEM)) {
+                                               int kind = markerDelta.getKind();
+                                               if (kind == IResourceDelta.ADDED || kind == IResourceDelta.REMOVED)
+                                                       return true;
+                                               int severity = markerDelta.getAttribute(IMarker.SEVERITY, -1);
+                                               int newSeverity = markerDelta.getMarker().getAttribute(IMarker.SEVERITY, -1);
+                                               if (newSeverity != severity)
+                                                       return true;
+                                       }
+                               }
+                       }
+                       return false;
+               }
+       }
+
+       ListenerList fListeners;
+
+       public ProblemMarkerManager() {
+               fListeners = new ListenerList();
+       }
+
+       /*
+        * @see IResourceChangeListener#resourceChanged
+        */
+       public void resourceChanged(IResourceChangeEvent event) {
+               HashSet<IResource> changedElements = new HashSet<IResource>();
+
+               try {
+                       IResourceDelta delta = event.getDelta();
+                       if (delta != null)
+                               delta.accept(new ProjectErrorVisitor(changedElements));
+               } catch (CoreException e) {
+                       CUIPlugin.log(e.getStatus());
+               }
+
+               if (!changedElements.isEmpty()) {
+                       IResource[] changes = changedElements.toArray(new IResource[changedElements.size()]);
+                       fireChanges(changes, true);
+               }
+
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see IAnnotationModelListener#modelChanged(IAnnotationModel)
+        */
+       public void modelChanged(IAnnotationModel model) {
+               // no action
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see IAnnotationModelListenerExtension#modelChanged(AnnotationModelEvent)
+        */
+       public void modelChanged(AnnotationModelEvent event) {
+               if (event instanceof TranslationUnitAnnotationModelEvent) {
+                       TranslationUnitAnnotationModelEvent cuEvent = (TranslationUnitAnnotationModelEvent)event;
+                       if (cuEvent.includesProblemMarkerAnnotationChanges()) {
+                               //IResource[] changes= new IResource[]
+                               // {cuEvent.getUnderlyingResource()};
+                               IResource res = cuEvent.getUnderlyingResource();
+                               if (res != null) {
+                                       fireChanges(new IResource[]{res}, false);
+                               }
+                       }
+               }
+       }
+
+       /**
+        * Adds a listener for problem marker changes.
+        */
+       public void addListener(IProblemChangedListener listener) {
+               if (fListeners.isEmpty()) {
+                       CUIPlugin.getWorkspace().addResourceChangeListener(this);
+                       CUIPlugin.getDefault().getDocumentProvider().addGlobalAnnotationModelListener(this);
+               }
+               fListeners.add(listener);
+       }
+
+       /**
+        * Removes a <code>IProblemChangedListener</code>.
+        */
+       public void removeListener(IProblemChangedListener listener) {
+               fListeners.remove(listener);
+               if (fListeners.isEmpty()) {
+                       CUIPlugin.getWorkspace().removeResourceChangeListener(this);
+                       CUIPlugin.getDefault().getDocumentProvider().removeGlobalAnnotationModelListener(this);
+               }
+       }
+
+       private void fireChanges(final IResource[] changes, final boolean markerChanged) {
+               Display display = SWTUtil.getStandardDisplay();
+               if (display != null && !display.isDisposed()) {
+                       display.asyncExec(new Runnable() {
+
+                               public void run() {
+                                       Object[] listeners = fListeners.getListeners();
+                                       for (Object listener : listeners) {
+                                               IProblemChangedListener curr = (IProblemChangedListener)listener;
+                                               curr.problemsChanged(changes, markerChanged);
+                                       }
+                               }
+                       });
+               }
+       }
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemTableViewer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemTableViewer.java
new file mode 100644 (file)
index 0000000..a10e922
--- /dev/null
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.util;
+
+import java.util.ArrayList;
+
+import org.eclipse.cdt.internal.ui.viewsupport.ProblemsLabelDecorator.ProblemsLabelChangedEvent;
+import org.eclipse.core.resources.IResource;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Item;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Widget;
+
+import org.eclipse.jface.viewers.IBaseLabelProvider;
+import org.eclipse.jface.viewers.LabelProviderChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+
+/**
+ * Extends a  TableViewer to allow more performance when showing error ticks.
+ * A <code>ProblemItemMapper</code> is contained that maps all items in
+ * the tree to underlying resource
+ */
+public class ProblemTableViewer extends TableViewer {
+
+       protected ResourceToItemsMapper fResourceToItemsMapper;
+
+       /**
+        * Constructor for ProblemTableViewer.
+        * @param parent
+        */
+       public ProblemTableViewer(Composite parent) {
+               super(parent);
+               initMapper();
+       }
+
+       /**
+        * Constructor for ProblemTableViewer.
+        * @param parent
+        * @param style
+        */
+       public ProblemTableViewer(Composite parent, int style) {
+               super(parent, style);
+               initMapper();
+       }
+
+       /**
+        * Constructor for ProblemTableViewer.
+        * @param table
+        */
+       public ProblemTableViewer(Table table) {
+               super(table);
+               initMapper();
+       }
+
+       private void initMapper() {
+               fResourceToItemsMapper= new ResourceToItemsMapper(this);
+       }
+       
+       /*
+        * @see StructuredViewer#mapElement(Object, Widget)
+        */
+       @Override
+       protected void mapElement(Object element, Widget item) {
+               super.mapElement(element, item);
+               if (item instanceof Item) {
+                       fResourceToItemsMapper.addToMap(element, (Item) item);
+               }
+       }
+
+       /*
+        * @see StructuredViewer#unmapElement(Object, Widget)
+        */
+       @Override
+       protected void unmapElement(Object element, Widget item) {
+               if (item instanceof Item) {
+                       fResourceToItemsMapper.removeFromMap(element, (Item) item);
+               }               
+               super.unmapElement(element, item);
+       }
+
+       /*
+        * @see StructuredViewer#unmapAllElements()
+        */
+       @Override
+       protected void unmapAllElements() {
+               fResourceToItemsMapper.clearMap();
+               super.unmapAllElements();
+       }
+       
+       /*
+        * @see ContentViewer#handleLabelProviderChanged(LabelProviderChangedEvent)
+        */
+       @Override
+       protected void handleLabelProviderChanged(LabelProviderChangedEvent event) {
+               if (event instanceof ProblemsLabelChangedEvent) {
+                       ProblemsLabelChangedEvent e= (ProblemsLabelChangedEvent) event;
+                       if (!e.isMarkerChange() && canIgnoreChangesFromAnnotionModel()) {
+                               return;
+                       }
+               }
+               
+               Object[] changed= event.getElements();
+               if (changed != null && !fResourceToItemsMapper.isEmpty()) {
+                       ArrayList<Object> others= new ArrayList<Object>(changed.length);
+                       for (int i= 0; i < changed.length; i++) {
+                               Object curr= changed[i];
+                               if (curr instanceof IResource) {
+                                       fResourceToItemsMapper.resourceChanged((IResource) curr);
+                               } else {
+                                       others.add(curr);
+                               }
+                       }
+                       if (others.isEmpty()) {
+                               return;
+                       }
+                       event= new LabelProviderChangedEvent((IBaseLabelProvider) event.getSource(), others.toArray());
+               }
+               super.handleLabelProviderChanged(event);
+       }
+       
+       /**
+        * Answers whether this viewer can ignore label provider changes resulting from
+        * marker changes in annotation models
+        */
+       private boolean canIgnoreChangesFromAnnotionModel() {
+//             Object contentProvider= getContentProvider();
+//             return contentProvider instanceof IWorkingCopyProvider && !((IWorkingCopyProvider)contentProvider).providesWorkingCopies();
+               return true;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemTreeViewer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ProblemTreeViewer.java
new file mode 100644 (file)
index 0000000..7cfa713
--- /dev/null
@@ -0,0 +1,158 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.util;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.viewers.IBaseLabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProviderChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Item;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.Widget;
+
+
+/**
+ * Extends a  TreeViewer to allow more performance when showing error ticks.
+ * A <code>ProblemItemMapper</code> is contained that maps all items in
+ * the tree to underlying resource
+ */
+public class ProblemTreeViewer extends TreeViewer {
+
+       protected ResourceToItemsMapper fResourceToItemsMapper;
+
+       /*
+        * @see TreeViewer#TreeViewer(Composite)
+        */
+       public ProblemTreeViewer(Composite parent) {
+               super(parent);
+               initMapper();
+       }
+
+       /*
+        * @see TreeViewer#TreeViewer(Composite, int)
+        */
+       public ProblemTreeViewer(Composite parent, int style) {
+               super(parent, style);
+               initMapper();
+       }
+
+       /*
+        * @see TreeViewer#TreeViewer(Tree)
+        */
+       public ProblemTreeViewer(Tree tree) {
+               super(tree);
+               initMapper();
+       }
+       
+       private void initMapper() {
+               fResourceToItemsMapper= new ResourceToItemsMapper(this);
+       }
+       
+       
+       protected void doUpdateItem(Item item) {
+               doUpdateItem(item, item.getData(), true);
+       }
+       /*
+        * @see StructuredViewer#mapElement(Object, Widget)
+        */
+       @Override
+       protected void mapElement(Object element, Widget item) {
+               super.mapElement(element, item);
+               if (item instanceof Item) {
+                       fResourceToItemsMapper.addToMap(element, (Item) item);
+               }
+       }
+       
+       /*
+        * @see StructuredViewer#unmapElement(Object, Widget)
+        */
+       @Override
+       protected void unmapElement(Object element, Widget item) {
+               if (item instanceof Item) {
+                       fResourceToItemsMapper.removeFromMap(element, (Item) item);
+               }               
+               super.unmapElement(element);
+       }
+
+       /*
+        * @see StructuredViewer#unmapAllElements()
+        */
+       @Override
+       protected void unmapAllElements() {
+               fResourceToItemsMapper.clearMap();
+               super.unmapAllElements();
+       }
+
+       /*
+        * @see ContentViewer#handleLabelProviderChanged(LabelProviderChangedEvent)
+        */
+       @Override
+       protected void handleLabelProviderChanged(LabelProviderChangedEvent event) {
+               Object source= event.getElement();
+               if (source == null) {
+                       super.handleLabelProviderChanged(event);
+                       return;
+               }
+               Object[] changed= event.getElements();
+               if (changed != null && !fResourceToItemsMapper.isEmpty()) {
+                       ArrayList<Object> others= new ArrayList<Object>(changed.length);
+                       for (int i= 0; i < changed.length; i++) {
+                               Object curr= changed[i];
+                               if (curr instanceof IResource) {
+                                       fResourceToItemsMapper.resourceChanged((IResource) curr);
+                               } else {
+                                       others.add(curr);
+                               }
+                       }
+                       if (others.isEmpty()) {
+                               return;
+                       }
+                       event= new LabelProviderChangedEvent((IBaseLabelProvider) event.getSource(), others.toArray());
+               }               
+               super.handleLabelProviderChanged(event);
+               return;
+       }
+       
+//    /**
+//     * @see org.eclipse.jface.viewers.StructuredViewer#update(java.lang.Object, java.lang.String[])
+//     */
+//    public void update(Object element, String[] properties)
+//    {
+        /* Calling StructuredViewer.update() causes
+         * RunnableLock deadlock with StructuredViewer.doInternalUpdate()
+         * when long h file (with lots of declarations) is edited.
+         * This is only workaround, it only protects against
+         * deadlock but may cause other problems. */
+//    }
+// Yeah, and the problem tree no longer updates after a schecdule decoration job!!!!
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.viewers.AbstractTreeViewer#isExpandable(java.lang.Object)
+        */
+       @Override
+       public boolean isExpandable(Object element) {
+               ITreeContentProvider cp = (ITreeContentProvider) getContentProvider();
+               if (cp == null)
+                       return false;
+               // since AbstractTreeViewer will run filteres here on element children this will cause binary search threads and TU parsering 
+               // to be started for each project/file tested for expandablity, this can be expensive if lots of project exists in workspace 
+               // or lots of TUs exist in one folder so lets skip it....
+               return cp.hasChildren(element);
+       }
+       
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/RemoteTreeContentManager.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/RemoteTreeContentManager.java
new file mode 100644 (file)
index 0000000..748f124
--- /dev/null
@@ -0,0 +1,359 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.progress.IDeferredWorkbenchAdapter;
+import org.eclipse.ui.progress.IElementCollector;
+import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
+import org.eclipse.ui.progress.WorkbenchJob;
+
+/**
+ * A remote content manager that merges content into a tree rather then replacing
+ * its children with a "pending" node, and then the real children when they are available.
+ * This avoids collapsing the viewer when a refresh is performed. This implementation is
+ * currently tied to the <code>RemoteTreeViewer</code>.
+ * 
+ * @since 3.1
+ */
+public class RemoteTreeContentManager {
+    private RemoteTreeViewer fViewer;
+    private IWorkbenchSiteProgressService progressService;
+    
+    /**
+     * Job to fetch children
+     */
+    private Job fFetchJob = new FetchJob();
+    
+    /**
+     * Queue of parents to fetch children for, and
+     * associated element collectors and deferred adapters.
+     */
+    private List<Object> fElementQueue = new ArrayList<Object>();
+    private List<IElementCollector> fCollectors = new ArrayList<IElementCollector>();
+    private List<IDeferredWorkbenchAdapter> fAdapaters = new ArrayList<IDeferredWorkbenchAdapter>();
+    
+    /**
+     * Fetching children is done in a single background job.
+     * This makes fetching single threaded/serial per view.
+     */
+    class FetchJob extends Job {
+       
+        public FetchJob() {
+            super("FetchJob"); //$NON-NLS-1$
+            setSystem(true);
+        }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
+                */
+               @Override
+               protected IStatus run(IProgressMonitor monitor) {
+                       while (!fElementQueue.isEmpty() && !monitor.isCanceled()) {
+                               Object element = null;
+                               IElementCollector collector = null;
+                               IDeferredWorkbenchAdapter adapter = null;
+                               synchronized (fElementQueue) {
+                                       // could have been cancelled after entering the while loop
+                                       if (fElementQueue.isEmpty()) {
+                                               return Status.CANCEL_STATUS;
+                                       }
+                                       element = fElementQueue.remove(0);
+                                       collector = fCollectors.remove(0);
+                                       adapter = fAdapaters.remove(0);
+                               }
+                               adapter.fetchDeferredChildren(element, collector, monitor);
+                       }
+                       if (monitor.isCanceled()) {
+                               return Status.CANCEL_STATUS;
+                       }
+                       return Status.OK_STATUS;
+               }
+       
+    }
+    
+    /**
+     * Element collector
+     */
+    public class Collector implements IElementCollector {            
+        // number of children added to the tree
+        int offset = 0;
+        Object fParent;
+        
+        public Collector(Object parent) {
+               fParent = parent;
+        }
+        /*
+         *  (non-Javadoc)
+         * @see org.eclipse.jface.progress.IElementCollector#add(java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
+         */
+        public void add(Object element, IProgressMonitor monitor) {
+            add(new Object[] { element }, monitor);
+        }
+
+        /*
+         *  (non-Javadoc)
+         * @see org.eclipse.jface.progress.IElementCollector#add(java.lang.Object[], org.eclipse.core.runtime.IProgressMonitor)
+         */
+        public void add(Object[] elements, IProgressMonitor monitor) {
+            Object[] filtered = fViewer.filter(elements);
+            fViewer.getSorter().sort(fViewer, filtered);
+            if (filtered.length > 0) {
+                replaceChildren(fParent, filtered, offset, monitor);
+                offset = offset + filtered.length;
+            }
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see org.eclipse.jface.progress.IElementCollector#done()
+         */
+        public void done() {
+            prune(fParent, offset);
+        }
+    }
+    
+    /**
+     * Contructs a new content manager.
+     * 
+     * @param provider content provider
+     * @param viewer viewer
+     * @param site part site
+     */
+    public RemoteTreeContentManager(ITreeContentProvider provider, RemoteTreeViewer viewer, IWorkbenchPartSite site) {
+        fViewer = viewer;
+        if (site != null) {
+               Object siteService = site.getAdapter(IWorkbenchSiteProgressService.class);
+               if (siteService != null) {
+                       progressService = (IWorkbenchSiteProgressService) siteService;
+               }
+        }
+    }
+    
+    /**
+     * Create the element collector for the receiver.
+     *@param parent
+     *            The parent object being filled in,
+     * @param placeholder
+     *            The adapter that will be used to indicate that results are
+     *            pending, possibly <code>null</code>
+     * @return IElementCollector
+     */
+    protected IElementCollector createElementCollector(Object parent, PendingUpdateAdapter placeholder) {
+        return new Collector(parent);
+    }
+    
+    /**
+     * Returns the child elements of the given element, or in the case of a
+     * deferred element, returns a placeholder. If a deferred element is used, a
+     * job is created to fetch the children in the background.
+     * 
+     * @param parent
+     *            The parent object.
+     * @return Object[] or <code>null</code> if parent is not an instance of
+     *         IDeferredWorkbenchAdapter.
+     */
+    public Object[] getChildren(final Object parent) {
+        IDeferredWorkbenchAdapter element = getAdapter(parent);
+        if (element == null)
+            return null;
+        Object[] currentChildren = fViewer.getCurrentChildren(parent);
+        PendingUpdateAdapter placeholder = null;
+        if (currentChildren == null || currentChildren.length == 0) {
+            placeholder = new PendingUpdateAdapter();
+        }
+        startFetchingDeferredChildren(parent, element, placeholder);
+        if (placeholder == null) {
+            return currentChildren;
+        }
+        return new Object[] { placeholder };
+    }
+    
+    /**
+     * Create a UIJob to replace the children of the parent in the tree viewer.
+     * 
+     * @param parent the parent for which children are to be replaced
+     * @param children the replacement children
+     * @param offset the offset at which to start replacing children
+     * @param monitor progress monitor
+     */
+    protected void replaceChildren(final Object parent, final Object[] children, final int offset, IProgressMonitor monitor) {
+       if (monitor.isCanceled()) {
+               return;
+       }
+        WorkbenchJob updateJob = new WorkbenchJob("IncrementalDeferredTreeContentManager") { //$NON-NLS-1$
+            /*
+             * (non-Javadoc)
+             * 
+             * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
+             */
+            @Override
+                       public IStatus runInUIThread(IProgressMonitor updateMonitor) {
+                //Cancel the job if the tree viewer got closed
+                if (fViewer.getControl().isDisposed())
+                    return Status.CANCEL_STATUS;
+                fViewer.replace(parent, children, offset);
+                return Status.OK_STATUS;
+            }
+        };
+        updateJob.setSystem(true);
+        updateJob.setPriority(Job.INTERACTIVE);
+        updateJob.schedule();
+    } 
+    
+    /**
+     * Create a UIJob to prune the children of the parent in the tree viewer, starting
+     * at the given offset.
+     * 
+     * @param parent the parent for which children should be pruned
+     * @param offset the offset at which children should be pruned. All children at and after
+     *  this index will be removed from the tree. 
+     */
+    protected void prune(final Object parent, final int offset) {
+        WorkbenchJob updateJob = new WorkbenchJob("DeferredTree") { //$NON-NLS-1$
+            /*
+             * (non-Javadoc)
+             * 
+             * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
+             */
+            @Override
+                       public IStatus runInUIThread(IProgressMonitor updateMonitor) {
+                //Cancel the job if the tree viewer got closed
+                if (fViewer.getControl().isDisposed())
+                    return Status.CANCEL_STATUS;
+                fViewer.prune(parent, offset);
+                return Status.OK_STATUS;
+            }
+        };
+        updateJob.setSystem(true);
+        updateJob.setPriority(Job.INTERACTIVE);
+        updateJob.schedule();
+    }     
+    
+    /**
+     * Run a job to clear the placeholder. This is used when the update
+     * for the tree is complete so that the user is aware that no more 
+     * updates are pending.
+     * 
+     * @param placeholder
+     */
+    protected void runClearPlaceholderJob(final PendingUpdateAdapter placeholder) {
+        if (placeholder == null || placeholder.isRemoved() || !PlatformUI.isWorkbenchRunning())
+            return;
+        //Clear the placeholder if it is still there
+        WorkbenchJob clearJob = new WorkbenchJob("DeferredTreeContentManager_ClearJob") { //$NON-NLS-1$
+            /*
+             * (non-Javadoc)
+             * 
+             * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
+             */
+            @Override
+                       public IStatus runInUIThread(IProgressMonitor monitor) {
+                if (!placeholder.isRemoved()) {
+                    Control control = fViewer.getControl();
+                    if (control.isDisposed())
+                        return Status.CANCEL_STATUS;
+                    fViewer.remove(placeholder);
+                    placeholder.setRemoved(true);
+                }
+                return Status.OK_STATUS;
+            }
+        };
+        clearJob.setSystem(true);
+        clearJob.schedule();
+    }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.progress.DeferredTreeContentManager#getFetchJobName(java.lang.Object, org.eclipse.ui.progress.IDeferredWorkbenchAdapter)
+        */
+       protected String getFetchJobName(Object parent, IDeferredWorkbenchAdapter adapter) {
+               return "RemoteTreeContentManager"; //$NON-NLS-1$
+       }
+       
+
+    /**
+     * Return the IDeferredWorkbenchAdapter for element or the element if it is
+     * an instance of IDeferredWorkbenchAdapter. If it does not exist return
+     * null.
+     * 
+     * @param element
+     * @return IDeferredWorkbenchAdapter or <code>null</code>
+     */
+    protected IDeferredWorkbenchAdapter getAdapter(Object element) {
+        if (element instanceof IDeferredWorkbenchAdapter)
+            return (IDeferredWorkbenchAdapter) element;
+        if (!(element instanceof IAdaptable))
+            return null;
+        Object adapter = ((IAdaptable) element)
+                .getAdapter(IDeferredWorkbenchAdapter.class);
+        if (adapter == null)
+            return null;
+        return (IDeferredWorkbenchAdapter) adapter;
+    }
+       
+    protected void startFetchingDeferredChildren(final Object parent, final IDeferredWorkbenchAdapter adapter, PendingUpdateAdapter placeholder) {
+               final IElementCollector collector = createElementCollector(parent, placeholder);
+               synchronized (fElementQueue) {
+                       if (!fElementQueue.contains(parent)) {
+                               fElementQueue.add(parent);
+                               fCollectors.add(collector);
+                               fAdapaters.add(adapter);
+                       }
+               }
+               if (progressService == null)
+                       fFetchJob.schedule();
+               else
+                       progressService.schedule(fFetchJob);
+       }
+
+    /**
+     * Provides an optimized lookup for determining if an element has children.
+     * This is required because elements that are populated lazilly can't
+     * answer <code>getChildren</code> just to determine the potential for
+     * children. Throw an AssertionFailedException if element is null.
+     * 
+     * @param element The Object being tested. This should not be
+     * <code>null</code>.
+     * @return boolean <code>true</code> if there are potentially children.
+     * @throws RuntimeException if the element is null.
+     */
+    public boolean mayHaveChildren(Object element) {
+       //Assert.isNotNull(element, ProgressMessages.DeferredTreeContentManager_NotDeferred); 
+        IDeferredWorkbenchAdapter adapter = getAdapter(element);
+        return adapter != null && adapter.isContainer();
+    }
+
+    /**
+     * Cancels any content this provider is currently fetching.
+     */
+    public void cancel() {
+       synchronized (fElementQueue) {
+               fFetchJob.cancel();
+               fElementQueue.clear();
+               fAdapaters.clear();
+               fCollectors.clear();
+       }
+    }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/RemoteTreeViewer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/RemoteTreeViewer.java
new file mode 100644 (file)
index 0000000..6ab18eb
--- /dev/null
@@ -0,0 +1,436 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.util;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Item;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.swt.widgets.Widget;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.eclipse.ui.progress.UIJob;
+
+public class RemoteTreeViewer extends ProblemTreeViewer {
+    private ExpansionJob fExpansionJob = null;
+    private SelectionJob fSelectionJob = null;
+    
+
+    class ExpansionJob extends UIJob {
+        
+        private Object element;
+        private List<Object> parents = new ArrayList<Object>(); // top down
+        
+        /**
+         * Constucts a job to expand the given element.
+         * 
+         */
+        public ExpansionJob() {
+            super("Expansion"); //$NON-NLS-1$
+            setPriority(Job.INTERACTIVE);
+            setSystem(true);
+        }
+
+        /* (non-Javadoc)
+         * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
+         */
+        @Override
+               public IStatus runInUIThread(IProgressMonitor monitor) {
+            if (getControl().isDisposed() || element == null) {
+                return Status.OK_STATUS;
+            }            
+            synchronized (RemoteTreeViewer.this) {
+                boolean allParentsExpanded = true;
+                Iterator<Object> iterator = parents.iterator();
+                while (iterator.hasNext() && !monitor.isCanceled()) {
+                    Object parent = iterator.next();
+                    Widget item = findItem(parent);
+                    if (item != null) {
+                        expandToLevel(parent, 1);
+                    } else {
+                        allParentsExpanded = false;
+                        break;
+                    }
+                }
+                if (allParentsExpanded) {
+                    Widget item = findItem(element); 
+                    if (item != null) {
+                        if (isExpandable(element)) {
+                           expandToLevel(element, 1);
+                        }
+                        element = null;
+                        parents.clear();
+                        return Status.OK_STATUS;
+                    }
+                }
+                return Status.OK_STATUS;
+            }
+        }
+        
+        public void validate(Object object) {
+            if (element != null) {   
+                if (element.equals(object) || parents.contains(object)) {
+                    cancel();
+                    element = null;
+                }
+            }
+        }
+
+        public void setDeferredExpansion(Object toExpand) {
+            element = toExpand;
+            parents.clear();
+            addAllParents(parents, element);
+        }
+        
+    }
+
+    class SelectionJob extends UIJob {
+        
+        private IStructuredSelection selection;
+        private Object first;
+        private List<Object> parents = new ArrayList<Object>(); // top down
+        
+        /**
+         * Constucts a job to select the given element.
+         * 
+         */
+        public SelectionJob() {
+            super("Selection"); //$NON-NLS-1$
+            setPriority(Job.INTERACTIVE);
+            setSystem(true);
+        }
+
+        /* (non-Javadoc)
+         * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
+         */
+        @Override
+               public IStatus runInUIThread(IProgressMonitor monitor) {
+            if (getControl().isDisposed() || selection == null) {
+                return Status.OK_STATUS;
+            }
+            synchronized (RemoteTreeViewer.this) {
+                boolean allParentsExpanded = true;
+                Iterator<Object> iterator = parents.iterator();
+                while (iterator.hasNext() && !monitor.isCanceled()) {
+                    Object parent = iterator.next();
+                    Widget item = findItem(parent);
+                    if (item != null) {
+                        expandToLevel(parent, 1);
+                    } else {
+                        allParentsExpanded = false;
+                        break;
+                    }
+                }
+                if (allParentsExpanded) {
+                    if (findItem(first) != null) {
+                        setSelection(selection, true);
+                        selection = null;
+                        first = null;
+                        parents.clear();
+                        return Status.OK_STATUS;
+                    }
+                }
+
+                return Status.OK_STATUS;
+            }
+        }
+        
+        public void setDeferredSelection(IStructuredSelection sel) {
+            selection = sel;
+            first = selection.getFirstElement();
+            parents.clear();
+            addAllParents(parents, first);
+        }
+        
+        public void validate(Object object) {
+            if (first != null) {
+                if (first.equals(object) || parents.contains(object)) {
+                    cancel();
+                    selection = null;
+                }
+            }
+        }
+    }
+    
+
+    /**
+     * Constructs a remote tree viewer parented by the given composite.
+     *   
+     * @param parent parent composite
+     */
+    public RemoteTreeViewer(Composite parent) {
+        super(parent);
+        addDisposeListener();
+        fExpansionJob = new ExpansionJob();
+        fSelectionJob = new SelectionJob();
+    }
+
+    /**
+     * Constructs a remote tree viewer parented by the given composite
+     * with the given style.
+     * 
+     * @param parent parent composite
+     * @param style style bits
+     */
+    public RemoteTreeViewer(Composite parent, int style) {
+        super(parent, style);
+        addDisposeListener();
+        fExpansionJob = new ExpansionJob();
+        fSelectionJob = new SelectionJob();
+    }
+
+    /**
+     * Constructs a remote tree viewer with the given tree.
+     * 
+     * @param tree tree widget
+     */
+    public RemoteTreeViewer(Tree tree) {
+        super(tree);
+        addDisposeListener();
+        fExpansionJob = new ExpansionJob();
+        fSelectionJob = new SelectionJob();
+    }
+    
+    private void addDisposeListener() {
+        getControl().addDisposeListener(new DisposeListener() {
+            public void widgetDisposed(DisposeEvent e) {
+                cancelJobs();
+            }
+        });
+    }
+    
+    protected void runDeferredUpdates() {
+        if (fExpansionJob != null) {
+            fExpansionJob.schedule();
+        }
+        if (fSelectionJob != null) {
+            fSelectionJob.schedule();
+        }        
+    }
+    
+    /**
+     * The given element is being removed from the tree. Cancel
+     * any deferred updates for the element.
+     * 
+     * @param element
+     */
+    protected void validateDeferredUpdates(Object element) {
+        if (element != null) {
+               if (fExpansionJob != null) {
+                   fExpansionJob.validate(element);
+               }
+               if (fSelectionJob != null) {
+                   fSelectionJob.validate(element);
+               }
+        }
+    }
+    
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.AbstractTreeViewer#add(java.lang.Object, java.lang.Object)
+     */
+    @Override
+       public synchronized void add(Object parentElement, Object childElement) {
+        super.add(parentElement, childElement);
+        runDeferredUpdates();
+    }
+    
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.viewers.AbstractTreeViewer#add(java.lang.Object, java.lang.Object[])
+     */
+    @Override
+       public synchronized void add(Object parentElement, Object[] childElements) {
+        super.add(parentElement, childElements);
+        runDeferredUpdates();
+    }
+    
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.viewers.AbstractTreeViewer#remove(java.lang.Object)
+        */
+       @Override
+       public synchronized void remove(Object element) {
+           validateDeferredUpdates(element);
+               super.remove(element);
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.viewers.AbstractTreeViewer#remove(java.lang.Object[])
+        */
+       @Override
+       public synchronized void remove(Object[] elements) {
+           for (int i = 0; i < elements.length; i++) {
+            validateDeferredUpdates(elements[i]);
+        }
+               super.remove(elements);
+       }    
+
+    /**
+     * Cancels any deferred updates currently scheduled/running.
+     */
+    public void cancelJobs() {
+        cancel(fSelectionJob);
+        cancel(fExpansionJob);
+    }
+
+    public synchronized void deferExpansion(Object element) {
+        TreeItem treeItem = (TreeItem) findItem(element);
+        if (treeItem == null) {
+            fExpansionJob.setDeferredExpansion(element);
+            fExpansionJob.schedule();
+        } else {
+            if (!getExpanded(treeItem)) {
+                fExpansionJob.setDeferredExpansion(element);
+                fExpansionJob.schedule();
+            }
+        }
+    }
+    
+    public synchronized void deferSelection(IStructuredSelection selection) {
+        if (fSelectionJob == null) {
+            fSelectionJob = new SelectionJob();
+        }
+        
+        fSelectionJob.setDeferredSelection(selection);
+        fSelectionJob.schedule();        
+    }    
+    
+    public IStructuredSelection getDeferredSelection() {
+        if (fSelectionJob != null) {
+            return fSelectionJob.selection;
+        }
+        return null;
+    }
+
+    private void cancel(Job job) {
+        if (job != null) {
+            job.cancel();
+        }          
+    }
+
+    private void addAllParents(List<Object> list, Object element) {
+       if (element instanceof IAdaptable) {
+               IAdaptable adaptable = (IAdaptable) element;
+               IWorkbenchAdapter adapter = (IWorkbenchAdapter) adaptable.getAdapter(IWorkbenchAdapter.class);
+               if (adapter != null) {
+                       Object parent = adapter.getParent(element);
+                       if (parent != null) {
+                               list.add(0, parent);
+                               if (!(parent instanceof ITranslationUnit))
+                                       addAllParents(list, parent);
+                       }
+               }
+       }
+    }
+
+    @Override
+       public Object[] filter(Object[] elements) {
+        return super.filter(elements);
+    }
+    
+    public Object[] getCurrentChildren(Object parent) {
+        Widget widget = findItem(parent);
+        if (widget != null) {
+            Item[] items = getChildren(widget);
+            Object[] children = new Object[items.length];
+            for (int i = 0; i < children.length; i++) {
+                Object data = items[i].getData();
+                if (data == null) {
+                    return null;
+                }
+                children[i] = data;
+               }
+            return children;
+        }
+        return null;
+    }
+
+    public synchronized void prune(final Object parent, final int offset) {
+        Widget widget = findItem(parent);
+        if (widget != null) {
+            final Item[] currentChildren = getChildren(widget);
+            if (offset < currentChildren.length) {
+                preservingSelection(new Runnable() {
+                    public void run() {
+                        for (int i = offset; i < currentChildren.length; i++) {
+                            if (currentChildren[i].getData() != null) {
+                                disassociate(currentChildren[i]);
+                            } 
+                            currentChildren[i].dispose();
+                        }
+                    }
+                });
+            }
+        }
+    }
+
+    public synchronized void replace(final Object parent, final Object[] children, final int offset) {
+        preservingSelection(new Runnable() {
+            public void run() {
+                Widget widget = findItem(parent);
+                if (widget == null) {
+                    add(parent, children);
+                } else {
+                       Item[] currentChildren = getChildren(widget);
+                       int pos = offset;
+                       if (pos >= currentChildren.length) {
+                           // append
+                           add(parent, children);
+                       } else {
+                           // replace
+                           for (int i = 0; i < children.length; i++) {
+                               Object child = children[i];
+                               if (pos < currentChildren.length) {
+                                   // replace
+                                   Item item = currentChildren[pos];
+                                   Object data = item.getData();
+                                   if (!child.equals(data)) {
+                                       // no need to cancel pending updates here, the child may have shifted up/down
+                                       internalRefresh(item, child, true, true);
+                                   } else {
+                                       // If it's the same child, the label/content may still have changed
+                                       doUpdateItem(item, child);
+                                       updatePlus(item, child);
+                                   }
+                               } else {
+                                   // add
+                                       int numLeft = children.length - i;
+                                       if (numLeft > 1) {
+                                               Object[] others = new Object[numLeft];
+                                               System.arraycopy(children, i, others, 0, numLeft);
+                                               add(parent, others);
+                                       } else {
+                                               add(parent, child);
+                                       }
+                                       break;
+                               }
+                               pos++;
+                           }
+                       }
+                }
+                runDeferredUpdates();
+            }
+        });
+    }
+    
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ResourceToItemsMapper.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ResourceToItemsMapper.java
new file mode 100644 (file)
index 0000000..713e09a
--- /dev/null
@@ -0,0 +1,204 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.util;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Stack;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.viewers.ContentViewer;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.IViewerLabelProvider;
+import org.eclipse.jface.viewers.ViewerLabel;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Item;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+/**
+ * Helper class for updating error markers and other decorators that work on resources.
+ * Items are mapped to their element's underlying resource.
+ * Method <code>resourceChanged</code> updates all items that are affected from the changed
+ * elements.
+ */
+public class ResourceToItemsMapper {
+
+       private static final int NUMBER_LIST_REUSE= 10;
+
+       // map from resource to item
+       private HashMap<IResource, Object> fResourceToItem;
+       private Stack<List<Item>> fReuseLists;
+       
+       private ContentViewer fContentViewer;
+
+       public ResourceToItemsMapper(ContentViewer viewer) {
+               fResourceToItem= new HashMap<IResource, Object>();
+               fReuseLists= new Stack<List<Item>>();
+               
+               fContentViewer= viewer;
+       }
+
+       /**
+        * Must be called from the UI thread.
+        */
+       public void resourceChanged(IResource changedResource) {
+               Object obj= fResourceToItem.get(changedResource);
+               if (obj == null) {
+                       // not mapped
+               } else if (obj instanceof Item) {
+                       updateItem((Item) obj);
+               } else { // List of Items
+                       @SuppressWarnings("unchecked")
+                       List<Item> list= (List<Item>) obj;
+                       for (int k= 0; k < list.size(); k++) {
+                               updateItem(list.get(k));
+                       }
+               }
+       }
+               
+       private void updateItem(Item item) {
+               if (!item.isDisposed()) { // defensive code
+                       ILabelProvider lprovider= (ILabelProvider) fContentViewer.getLabelProvider();
+                       
+                       Object data= item.getData();
+                       
+                       // If it is an IItemLabelProvider than short circuit: patch Tod (bug 55012)
+                       if (data != null && lprovider instanceof IViewerLabelProvider) {
+                               IViewerLabelProvider provider= (IViewerLabelProvider) lprovider;
+                               
+                               ViewerLabel updateLabel= new ViewerLabel(item.getText(), item.getImage());
+                               provider.updateLabel(updateLabel, data);
+                               
+                               if (updateLabel.hasNewImage()) {
+                                       item.setImage(updateLabel.getImage());
+                               }
+                               if (updateLabel.hasNewText()) {
+                                       item.setText(updateLabel.getText());
+                               }
+                       } else {
+                               Image oldImage= item.getImage();
+                               Image image= lprovider.getImage(data);
+                               if (image != null && !image.equals(oldImage)) {
+                                       item.setImage(image);
+                               }
+                               String oldText= item.getText();
+                               String text= lprovider.getText(data);
+                               if (text != null && !text.equals(oldText)) {
+                                       item.setText(text);
+                               }
+                       }
+               }
+       }
+
+       /**
+        * Adds a new item to the map.
+        * @param element Element to map
+        * @param item The item used for the element
+        */
+       public void addToMap(Object element, Item item) {
+               IResource resource= getCorrespondingResource(element);
+               if (resource != null) {
+                       Object existingMapping= fResourceToItem.get(resource);
+                       if (existingMapping == null) {
+                               fResourceToItem.put(resource, item);
+                       } else if (existingMapping instanceof Item) {
+                               if (existingMapping != item) {
+                                       List<Item> list= getNewList();
+                                       list.add((Item) existingMapping);
+                                       list.add(item);
+                                       fResourceToItem.put(resource, list);
+                               }
+                       } else { // List                        
+                               @SuppressWarnings("unchecked")
+                               List<Item> list= (List<Item>) existingMapping;
+                               if (!list.contains(item)) {
+                                       list.add(item);
+                               }
+                       }
+               }
+       }
+
+       /**
+        * Removes an element from the map.
+        */     
+       public void removeFromMap(Object element, Item item) {
+               IResource resource= getCorrespondingResource(element);
+               if (resource != null) {
+                       Object existingMapping= fResourceToItem.get(resource);
+                       if (existingMapping == null) {
+                               return;
+                       } else if (existingMapping instanceof Item) {
+                               fResourceToItem.remove(resource);
+                       } else { // List
+                               @SuppressWarnings({ "unchecked", "rawtypes" })
+                               List<Item> list= (List) existingMapping;
+                               list.remove(item);
+                               if (list.isEmpty()) {
+                                       fResourceToItem.remove(list);
+                                       releaseList(list);
+                               }
+                       }
+               }
+       }
+       
+       private List<Item> getNewList() {
+               if (!fReuseLists.isEmpty()) {
+                       return fReuseLists.pop();
+               }
+               return new ArrayList<Item>(2);
+       }
+       
+       private void releaseList(List<Item> list) {
+               if (fReuseLists.size() < NUMBER_LIST_REUSE) {
+                       fReuseLists.push(list);
+               }
+       }
+       
+       /**
+        * Clears the map.
+        */
+       public void clearMap() {
+               fResourceToItem.clear();
+       }
+       
+       /**
+        * Tests if the map is empty
+        */
+       public boolean isEmpty() {
+               return fResourceToItem.isEmpty();
+       }       
+       
+       /**
+        * Method that decides which elements can have error markers
+        * Returns null if an element can not have error markers.
+        */     
+       private static IResource getCorrespondingResource(Object element) {
+               if (element instanceof ICElement) {
+                       ICElement elem= (ICElement) element;
+                       IResource res= elem.getResource();
+                       if (res == null) {
+                               ITranslationUnit cu= (ITranslationUnit) elem.getAncestor(ICElement.C_UNIT);
+                               if (cu != null) {
+                                       // elements in compilation units are mapped to the underlying resource of the original cu
+                                       res= cu.getResource();
+                               }
+                       }
+                       return res; 
+               } else if (element instanceof IResource) {
+                       return (IResource) element;
+               }
+               return null;
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/RowLayouter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/RowLayouter.java
new file mode 100644 (file)
index 0000000..8490132
--- /dev/null
@@ -0,0 +1,184 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.util;
+
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Control;
+
+import org.eclipse.core.runtime.Assert;
+
+/**
+ * Helper class to layout a number of children if the composite uses a <code>GridLayout</code>. 
+ * If the numbers of widgets to be layouted into one row is smaller than the number of columns 
+ * defined for the grid layout the helper class assigns a corresponing value to the <code>
+ * GridData.horizontalSpan</code> field.
+ * 
+ * Additionally a row layouter manages a default <code>GridData</code> object for each column.
+ * If set this grid data is used for the widget if it doesn't manage its own grid data object.
+ * 
+ * Call one of the <code>perform</code> methods to assign the correct grid data objects to
+ * a set of widgets according to the number of columns passed to the layouter's constructor.
+ */
+public class RowLayouter {
+
+       public int spanHorizontalAlignment= -1;
+       public int spanGrabExcessHorizontalSpace= -1;
+       public int spanHorizontalSpan= -1;
+       public int spanHorizontalIndent= -1;
+       public int spanWidthHint= -1;
+               
+       public int spanVerticalAlignment= -1;
+       public int spanGrabExcessVerticalSpace= -1;
+       public int spanVerticalSpan= -1;
+       public int spanHeightHint= -1;
+       
+       private int fNumColumns;
+       private boolean fOrder;
+       private Control fLastControl;
+       private GridData[] fDefaultGridDatas= new GridData[4];
+               
+       public RowLayouter(int numColumns) {
+               this(numColumns, false);
+       }
+
+       public RowLayouter(int numColumns, boolean order) {
+               fNumColumns= numColumns;
+               fOrder= order;
+       }
+       
+       public void setDefaultSpan() {
+               spanHorizontalAlignment= GridData.FILL;
+               spanGrabExcessHorizontalSpace= 1;
+       }
+       
+       public void perform(Control c1) {
+               perform(new Control[] {c1}, 0);
+       }
+       
+       public void perform(Control c1, Control c2, int span) {
+               perform(new Control[] {c1, c2}, span);
+       }
+       
+       public void perform(Control c1, Control c2, Control c3, int span) {
+               perform(new Control[] {c1, c2, c3}, span);
+       }
+       
+       public void perform(Control[] controls, int spanColumn) {
+               int numColumns= numColumns();
+               Assert.isTrue(controls.length <= numColumns);
+               order(controls);
+               int gridIndex= 0;
+               for (int i= 0; i < controls.length; i++) {
+                       Control control= controls[i];
+                       GridData gd= (GridData)control.getLayoutData();
+                       if (gd == null)
+                               gd= getGridData(gridIndex);
+                               
+                       if (i == spanColumn) {
+                               int span= numColumns - (controls.length - 1);
+                               gridIndex+= span;
+                               if (gd == null)
+                                       gd= new GridData();
+                               applyDelta(gd);
+                               gd.horizontalSpan= span;
+                       } else {
+                               gridIndex++;
+                       }
+                       control.setLayoutData(gd);
+               }
+       }
+       
+       private void applyDelta(GridData gd) {
+               if (spanHorizontalAlignment != -1)
+                       gd.horizontalAlignment= spanHorizontalAlignment;
+                       
+               if (spanGrabExcessHorizontalSpace != -1) {
+                       if (spanGrabExcessHorizontalSpace == 0)
+                               gd.grabExcessHorizontalSpace= false;
+                       else
+                               gd.grabExcessHorizontalSpace= true;
+               }               
+                               
+                       
+               if (spanHorizontalSpan != -1)
+                       gd.horizontalSpan= spanHorizontalSpan;
+                       
+               if (spanHorizontalIndent != -1)
+                       gd.horizontalIndent= spanHorizontalIndent;
+               
+               if (spanWidthHint != -1)
+                       gd.widthHint= spanWidthHint;
+                       
+               if (spanVerticalAlignment != -1)
+                       gd.verticalAlignment= spanVerticalAlignment;
+                       
+               if (spanGrabExcessVerticalSpace != -1) {
+                       if (spanGrabExcessVerticalSpace == 0)
+                               gd.grabExcessVerticalSpace= false;
+                       else
+                               gd.grabExcessVerticalSpace= true;
+               }               
+                       
+               if (spanVerticalSpan != -1)
+                       gd.verticalSpan= spanVerticalSpan;
+                       
+               if (spanHeightHint != -1)
+                       gd.heightHint= spanHeightHint;
+       }
+       public void setDefaultGridData(GridData gd, int index) {
+               if (index >= fDefaultGridDatas.length) {
+                       GridData[] newDatas= new GridData[index + 4];
+                       System.arraycopy(fDefaultGridDatas, 0, newDatas, 0, fDefaultGridDatas.length);
+                       fDefaultGridDatas= newDatas;
+               }
+               fDefaultGridDatas[index]= gd;
+       }
+       
+       public GridData getGridData(int index) {
+               if (index > fDefaultGridDatas.length)
+                       return null;
+                       
+               return cloneGridData(fDefaultGridDatas[index]);
+       }
+       
+       public int numColumns() {
+               return fNumColumns;
+       }
+       
+       protected void order(Control[] controls) {
+               if (!fOrder)
+                       return;
+                       
+               for (int i= 0; i < controls.length; i++) {
+                       Control control= controls[i];
+                       control.moveBelow(fLastControl);
+                       fLastControl= control;
+               }
+       }
+       
+       protected GridData cloneGridData(GridData gd) {
+               if (gd == null)
+                       return null;
+                       
+               GridData result= new GridData();
+               result.horizontalAlignment= gd.horizontalAlignment;
+               result.grabExcessHorizontalSpace= gd.grabExcessHorizontalSpace;
+               result.horizontalSpan= gd.horizontalSpan;
+               result.horizontalIndent= gd.horizontalIndent;
+               result.widthHint= gd.widthHint;
+               
+               result.verticalAlignment= gd.verticalAlignment;
+               result.grabExcessVerticalSpace= gd.grabExcessVerticalSpace;
+               result.verticalSpan= gd.verticalSpan;
+               result.heightHint= gd.heightHint;
+               return result;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SWTUtil.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SWTUtil.java
new file mode 100644 (file)
index 0000000..174c9bd
--- /dev/null
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.util;
+
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.DragSource;
+import org.eclipse.swt.dnd.DropTarget;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Caret;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.ScrollBar;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Widget;
+
+/**
+ * Utility class to simplify access to some SWT resources. 
+ */
+public class SWTUtil {
+       
+       /**
+        * Returns the standard display to be used. The method first checks, if
+        * the thread calling this method has an associated disaply. If so, this
+        * display is returned. Otherwise the method returns the default display.
+        */
+       public static Display getStandardDisplay() {
+               Display display;
+               display= Display.getCurrent();
+               if (display == null)
+                       display= Display.getDefault();
+               return display;         
+       }
+       
+       /**
+        * Returns the shell for the given widget. If the widget doesn't represent
+        * a SWT object that manage a shell, <code>null</code> is returned.
+        * 
+        * @return the shell for the given widget
+        */
+       public static Shell getShell(Widget widget) {
+               if (widget instanceof Control)
+                       return ((Control)widget).getShell();
+               if (widget instanceof Caret)
+                       return ((Caret)widget).getParent().getShell();
+               if (widget instanceof DragSource)
+                       return ((DragSource)widget).getControl().getShell();
+               if (widget instanceof DropTarget)
+                       return ((DropTarget)widget).getControl().getShell();
+               if (widget instanceof Menu)
+                       return ((Menu)widget).getParent().getShell();
+               if (widget instanceof ScrollBar)
+                       return ((ScrollBar)widget).getParent().getShell();
+                                                       
+               return null;    
+       }
+
+
+       /**
+        * Returns a width hint for a button control.
+        */
+       public static int getButtonWidthHint(Button button) {
+               if (button.getFont().equals(JFaceResources.getDefaultFont()))
+                       button.setFont(JFaceResources.getDialogFont());
+               PixelConverter converter= new PixelConverter(button);
+               int widthHint= converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
+               return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
+       }
+
+       /**
+        * Returns a height hint for a button control.
+        * @deprecated
+        * @see IDialogConstants#BUTTON_HEIGHT
+        */             
+       @Deprecated
+       public static int getButtonHeigthHint(Button button) {
+               if (button.getFont().equals(JFaceResources.getDefaultFont()))
+                       button.setFont(JFaceResources.getDialogFont());
+               PixelConverter converter= new PixelConverter(button);
+               return converter.convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
+       }       
+
+       
+       /**
+        * Sets width for the button control.
+        * <b>Note:</b> This is a NOP if the button's layout data is not
+        * an instance of <code>GridData</code>.
+        * 
+        * @param button a button for which to set the dimension hint
+        */             
+       public static void setButtonDimensionHint(Button button) {
+               Assert.isNotNull(button);
+               Object gd= button.getLayoutData();
+               if (gd instanceof GridData) {
+                       ((GridData)gd).widthHint= getButtonWidthHint(button);            
+               }
+       }
+       
+       public static int getTableHeightHint(Table table, int rows) {
+               if (table.getFont().equals(JFaceResources.getDefaultFont()))
+                       table.setFont(JFaceResources.getDialogFont());
+               int result= table.getItemHeight() * rows + table.getHeaderHeight();
+               if (table.getLinesVisible())
+                       result+= table.getGridLineWidth() * (rows - 1);
+               return result;          
+       }
+       
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SelectionUtil.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/SelectionUtil.java
new file mode 100644 (file)
index 0000000..95efd6c
--- /dev/null
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.util;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+public class SelectionUtil {
+       /**
+        * Returns the selected element if the selection consists of a single element only.
+        *
+        * @param s the selection
+        * @return the selected first element or null
+        */
+       public static Object getSingleElement(ISelection s) {
+               if (!(s instanceof IStructuredSelection))
+                       return null;
+               IStructuredSelection selection= (IStructuredSelection) s;
+               if (selection.size() != 1)
+                       return null;
+
+               return selection.getFirstElement();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/StatusLineHandler.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/StatusLineHandler.java
new file mode 100644 (file)
index 0000000..b5a3e11
--- /dev/null
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corp. - Rational Software - initial implementation
+ *     Markus Schorn (Wind River Systems)
+ *     Ed Swartz (Nokia)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.util;
+
+import org.eclipse.jface.action.IStatusLineManager;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchSite;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * Utilities for clearing and setting status line.  Client should
+ * invoke {@link #clearStatusLine(IWorkbenchSite)} before an operation
+ * and invoke {@link #showStatusLineMessage(IWorkbenchSite, String)} on
+ * error.
+ * @author eswartz
+ *
+ */
+public abstract class StatusLineHandler {
+       public static void showStatusLineMessage(final IWorkbenchSite site, final String message) {
+               // run the code to update the status line on the Display thread
+               // this way any other thread can invoke operationNotAvailable(String)
+               CUIPlugin.getStandardDisplay().asyncExec(new Runnable(){
+                       /* (non-Javadoc)
+                        * @see java.lang.Runnable#run()
+                        */
+                       public void run() {
+                               IStatusLineManager statusManager = null;
+                                if (site instanceof IViewSite){
+                                       statusManager = ((IViewSite) site).getActionBars().getStatusLineManager();
+                                }
+                                else if (site instanceof IEditorSite){
+                                       statusManager = ((IEditorSite) site).getActionBars().getStatusLineManager();
+                                }      
+                                if( statusManager != null )
+                                       statusManager.setErrorMessage(message);
+                       }
+               });
+       }
+       public static void clearStatusLine(final IWorkbenchSite site) {
+               // run the code to update the status line on the Display thread
+               // this way any other thread can invoke clearStatusLine()
+               CUIPlugin.getStandardDisplay().asyncExec(new Runnable(){
+                       /* (non-Javadoc)
+                        * @see java.lang.Runnable#run()
+                        */
+                       public void run() {
+                               IStatusLineManager statusManager = null;
+                                if (site instanceof IViewSite){
+                                       statusManager = ((IViewSite) site).getActionBars().getStatusLineManager();
+                                }
+                                else if (site instanceof IEditorSite){
+                                       statusManager = ((IEditorSite) site).getActionBars().getStatusLineManager();
+                                }      
+                                if( statusManager != null )
+                                       statusManager.setErrorMessage( "" ); //$NON-NLS-1$
+                       }
+               });
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/StringMatcher.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/StringMatcher.java
new file mode 100644 (file)
index 0000000..7ccdd88
--- /dev/null
@@ -0,0 +1,390 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.util;
+
+import java.util.Vector;
+
+public class StringMatcher {
+       protected String fPattern;
+       protected int fLength; // pattern length
+       protected boolean fIgnoreWildCards;
+       protected boolean fIgnoreCase;
+       protected boolean fHasLeadingStar;
+       protected boolean fHasTrailingStar;
+       protected String fSegments[]; //the given pattern is split into * separated segments
+
+       /* boundary value beyond which we don't need to search in the text */
+       protected int fBound= 0;
+
+       protected static final char fSingleWildCard= '\u0000';
+
+       public static class Position {
+               int start; //inclusive
+               int end; //exclusive
+               public Position(int start, int end) {
+                       this.start= start;
+                       this.end= end;
+               }
+               public int getStart() {
+                       return start;
+               }
+               public int getEnd() {
+                       return end;
+               }
+       }
+
+       /**
+        * Find the first occurrence of the pattern between <code>start</code)(inclusive) 
+        * and <code>end</code>(exclusive).  
+        * @param text the String object to search in 
+        * @param start the starting index of the search range, inclusive
+        * @param end the ending index of the search range, exclusive
+        * @return an <code>StringMatcher.Position</code> object that keeps the starting 
+        * (inclusive) and ending positions (exclusive) of the first occurrence of the 
+        * pattern in the specified range of the text; return null if not found or subtext
+        * is empty (start==end). A pair of zeros is returned if pattern is empty string
+        * Note that for pattern like "*abc*" with leading and trailing stars, position of "abc"
+        * is returned. For a pattern like"*??*" in text "abcdf", (1,3) is returned
+        */
+
+       public StringMatcher.Position find(String text, int start, int end) {
+               if (fPattern == null || text == null)
+                       throw new IllegalArgumentException();
+
+               int tlen= text.length();
+               if (start < 0)
+                       start= 0;
+               if (end > tlen)
+                       end= tlen;
+               if (end < 0 || start >= end)
+                       return null;
+               if (fLength == 0)
+                       return new Position(start, start);
+               if (fIgnoreWildCards) {
+                       int x= posIn(text, start, end);
+                       if (x < 0)
+                               return null;
+                       return new Position(x, x + fLength);
+               }
+
+               int segCount= fSegments.length;
+               if (segCount == 0) //pattern contains only '*'(s)
+                       return new Position(start, end);
+
+               int curPos= start;
+               int matchStart= -1;
+               for (int i= 0; i < segCount && curPos < end; ++i) {
+                       String current= fSegments[i];
+                       int nextMatch= regExpPosIn(text, curPos, end, current);
+                       if (nextMatch < 0)
+                               return null;
+                       if (i == 0)
+                               matchStart= nextMatch;
+                       curPos= nextMatch + current.length();
+               }
+               return new Position(matchStart, curPos);
+       }
+       /**
+        * StringMatcher constructor takes in a String object that is a simple 
+        * pattern which may contain  \18\19 for 0 and many characters and
+        *  \18\19 for exactly one character. Also takes as parameter a boolean object
+        * specifying if case should be ignored
+        * @deprecated Use StringMatcher(pattern, ignoreCase, ignoreWildCards).
+        */
+       @Deprecated
+       public StringMatcher(String aPattern, boolean ignoreCase) {
+               this(aPattern, ignoreCase, false);
+       }
+       /**
+        * StringMatcher constructor takes in a String object that is a simple 
+        * pattern which may contain  \18\19 for 0 and many characters and
+        *  \18\19 for exactly one character.  
+        *
+        * Literal '*' and '?' characters must be escaped in the pattern 
+        * e.g., "\*" means literal "*", etc.
+        *
+        * Escaping any other character (including the escape character itself), 
+        * just results in that character in the pattern.
+        * e.g., "\a" means "a" and "\\" means "\"
+        *
+        * If invoking the StringMatcher with string literals in Java, don't forget
+        * escape characters are represented by "\\".
+        *
+        * @param aPattern the pattern to match text against
+        * @param ignoreCase if true, case is ignored
+        * @param ignoreWildCards if true, wild cards and their escape sequences are ignored
+        *                (everything is taken literally).
+        */
+       public StringMatcher(String aPattern, boolean ignoreCase, boolean ignoreWildCards) {
+               fIgnoreCase= ignoreCase;
+               fIgnoreWildCards= ignoreWildCards;
+               fLength= aPattern.length();
+
+               /* convert case */
+               if (fIgnoreCase) {
+                       char[] chars= aPattern.toCharArray();
+                       for (int i = 0; i < chars.length; i++) {
+                               chars[i]= Character.toUpperCase(chars[i]);
+                       }
+                       fPattern= new String(chars);
+               } else {
+                       fPattern= aPattern;
+               }
+
+               if (fIgnoreWildCards) {
+                       parseNoWildCards();
+               } else {
+                       parseWildCards();
+               }
+       }
+       /**
+        * Given the starting (inclusive) and the ending (exclusive) poisitions in the   
+        * <code>text</code>, determine if the given substring matches with aPattern  
+        * @return true if the specified portion of the text matches the pattern
+        * @param text  a String object that contains the substring to match 
+        * @param start marks the starting position (inclusive) of the substring
+        * @param end marks the ending index (exclusive) of the substring 
+        */
+       public boolean match(String text, int start, int end) {
+               if (null == fPattern || null == text)
+                       throw new IllegalArgumentException();
+
+               if (start > end)
+                       return false;
+
+               if (fIgnoreWildCards)
+                       return fPattern.regionMatches(fIgnoreCase, 0, text, start, fLength);
+               int segCount= fSegments.length;
+               if (segCount == 0) //pattern contains only '*'(s) or empty pattern
+                       return true;
+               if (start == end)
+                       return fLength == 0;
+               if (fLength == 0)
+                       return start == end;
+
+               int tlen= text.length();
+               if (start < 0)
+                       start= 0;
+               if (end > tlen)
+                       end= tlen;
+
+               int tCurPos= start;
+               int bound= end - fBound;
+               if (bound < 0)
+                       return false;
+               int i= 0;
+               String current= fSegments[i];
+               int segLength= current.length();
+
+               /* process first segment */
+               if (!fHasLeadingStar) {
+                       if (!regExpRegionMatches(text, start, current, 0, segLength)) {
+                               return false;
+                       }
+                       ++i;
+                       tCurPos= tCurPos + segLength;
+               }
+
+               /* process middle segments */
+               for (; i < segCount && tCurPos <= bound; ++i) {
+                       current= fSegments[i];
+                       int currentMatch;
+                       int k= current.indexOf(fSingleWildCard);
+                       if (k < 0) {
+                               currentMatch= textPosIn(text, tCurPos, end, current);
+                               if (currentMatch < 0)
+                                       return false;
+                       } else {
+                               currentMatch= regExpPosIn(text, tCurPos, end, current);
+                               if (currentMatch < 0)
+                                       return false;
+                       }
+                       tCurPos= currentMatch + current.length();
+               }
+
+               /* process final segment */
+               if (!fHasTrailingStar && tCurPos != end) {
+                       int clen= current.length();
+                       return regExpRegionMatches(text, end - clen, current, 0, clen);
+               }
+               return i == segCount;
+       }
+       /**
+        * match the given <code>text</code> with the pattern 
+        * @return true if matched eitherwise false
+        * @param text a String object 
+        */
+       public boolean match(String text) {
+               return match(text, 0, text.length());
+       }
+       /**
+        * This method parses the given pattern into segments seperated by wildcard '*' characters.
+        * Since wildcards are not being used in this case, the pattern consists of a single segment.
+        */
+       private void parseNoWildCards() {
+               fSegments= new String[1];
+               fSegments[0]= fPattern;
+               fBound= fLength;
+       }
+       /**
+        *  This method parses the given pattern into segments seperated by wildcard '*' characters.
+        */
+       private void parseWildCards() {
+               if (fPattern.startsWith("*")) //$NON-NLS-1$
+                       fHasLeadingStar= true;
+               if (fPattern.endsWith("*")) { //$NON-NLS-1$
+                       /* make sure it's not an escaped wildcard */
+                       if (fLength > 1 && fPattern.charAt(fLength - 2) != '\\') {
+                               fHasTrailingStar= true;
+                       }
+               }
+
+               Vector<String> temp= new Vector<String>();
+
+               int pos= 0;
+               StringBuffer buf= new StringBuffer();
+               while (pos < fLength) {
+                       char c= fPattern.charAt(pos++);
+                       switch (c) {
+                               case '\\' :
+                                       if (pos >= fLength) {
+                                               buf.append(c);
+                                       } else {
+                                               char next= fPattern.charAt(pos++);
+                                               /* if it's an escape sequence */
+                                               if (next == '*' || next == '?' || next == '\\') {
+                                                       buf.append(next);
+                                               } else {
+                                                       /* not an escape sequence, just insert literally */
+                                                       buf.append(c);
+                                                       buf.append(next);
+                                               }
+                                       }
+                                       break;
+                               case '*' :
+                                       if (buf.length() > 0) {
+                                               /* new segment */
+                                               temp.addElement(buf.toString());
+                                               fBound += buf.length();
+                                               buf.setLength(0);
+                                       }
+                                       break;
+                               case '?' :
+                                       /* append special character representing single match wildcard */
+                                       buf.append(fSingleWildCard);
+                                       break;
+                               default :
+                                       buf.append(c);
+                       }
+               }
+
+               /* add last buffer to segment list */
+               if (buf.length() > 0) {
+                       temp.addElement(buf.toString());
+                       fBound += buf.length();
+               }
+
+               fSegments= new String[temp.size()];
+               temp.copyInto(fSegments);
+       }
+       /** 
+        * @param text a string which contains no wildcard
+        * @param start the starting index in the text for search, inclusive
+        * @param end the stopping point of search, exclusive
+        * @return the starting index in the text of the pattern , or -1 if not found 
+        */
+       protected int posIn(String text, int start, int end) { //no wild card in pattern
+               int max= end - fLength;
+
+               if (!fIgnoreCase) {
+                       int i= text.indexOf(fPattern, start);
+                       if (i == -1 || i > max)
+                               return -1;
+                       return i;
+               }
+
+               for (int i= start; i <= max; ++i) {
+                       if (text.regionMatches(true, i, fPattern, 0, fLength))
+                               return i;
+               }
+
+               return -1;
+       }
+       /** 
+        * @param text a simple regular expression that may only contain '?'(s)
+        * @param start the starting index in the text for search, inclusive
+        * @param end the stopping point of search, exclusive
+        * @param p a simple regular expression that may contains '?'
+        * @return the starting index in the text of the pattern , or -1 if not found 
+        */
+       protected int regExpPosIn(String text, int start, int end, String p) {
+               int plen= p.length();
+
+               int max= end - plen;
+               for (int i= start; i <= max; ++i) {
+                       if (regExpRegionMatches(text, i, p, 0, plen))
+                               return i;
+               }
+               return -1;
+       }
+
+       protected boolean regExpRegionMatches(String text, int tStart, String p, int pStart, int plen) {
+               while (plen-- > 0) {
+                       char tchar= text.charAt(tStart++);
+                       char pchar= p.charAt(pStart++);
+
+                       /* process wild cards */
+                       if (!fIgnoreWildCards) {
+                               /* skip single wild cards */
+                               if (pchar == fSingleWildCard) {
+                                       continue;
+                               }
+                       }
+                       if (pchar == tchar)
+                               continue;
+                       if (fIgnoreCase) {
+                               char tc= Character.toUpperCase(tchar);
+                               if (tc == pchar)
+                                       continue;
+                       }
+                       return false;
+               }
+               return true;
+       }
+       /** 
+        * @param text the string to match
+        * @param start the starting index in the text for search, inclusive
+        * @param end the stopping point of search, exclusive
+        * @param p a string that has no wildcard
+        * @return the starting index in the text of the pattern , or -1 if not found 
+        */
+       protected int textPosIn(String text, int start, int end, String p) {
+
+               int plen= p.length();
+               int max= end - plen;
+
+               if (!fIgnoreCase) {
+                       int i= text.indexOf(p, start);
+                       if (i == -1 || i > max)
+                               return -1;
+                       return i;
+               }
+
+               for (int i= 0; i <= max; ++i) {
+                       if (text.regionMatches(true, i, p, 0, plen))
+                               return i;
+               }
+
+               return -1;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/TableLayoutComposite.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/TableLayoutComposite.java
new file mode 100644 (file)
index 0000000..8d22100
--- /dev/null
@@ -0,0 +1,172 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Rational Software - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnPixelData;
+import org.eclipse.jface.viewers.ColumnWeightData;
+
+/**
+ * A special composite to layout columns inside a table. The composite is needed since we have
+ * to layout the columns "before" the actual table gets layouted. Hence we can't use a normal
+ * layout manager.
+ */
+public class TableLayoutComposite extends Composite {
+
+       private List<ColumnLayoutData> columns= new ArrayList<ColumnLayoutData>();
+
+       /**
+        * Creates a new <code>TableLayoutComposite</code>.
+        */
+       public TableLayoutComposite(Composite parent, int style) {
+               super(parent, style);
+               addControlListener(new ControlAdapter() {
+                       @Override
+                       public void controlResized(ControlEvent e) {
+                               Rectangle area= getClientArea();
+                               Table table= (Table)getChildren()[0];
+                               Point preferredSize= computeTableSize(table);
+                               int width= area.width - 2 * table.getBorderWidth();
+                               if (preferredSize.y > area.height) {
+                                       // Subtract the scrollbar width from the total column width
+                                       // if a vertical scrollbar will be required
+                                       Point vBarSize = table.getVerticalBar().getSize();
+                                       width -= vBarSize.x;
+                               }
+                               layoutTable(table, width, area, table.getSize().x < area.width);
+                       }
+               });
+       }
+       
+       /**
+        * Adds a new column of data to this table layout.
+        *
+        * @param data the column layout data
+        */
+       public void addColumnData(ColumnLayoutData data) {
+               columns.add(data);
+       }
+       
+       //---- Helpers -------------------------------------------------------------------------------------
+       
+       Point computeTableSize(Table table) {
+               Point result= table.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+               
+               int width= 0;
+               int size= columns.size();
+               for (int i= 0; i < size; ++i) {
+                       ColumnLayoutData layoutData= columns.get(i);
+                       if (layoutData instanceof ColumnPixelData) {
+                               ColumnPixelData col= (ColumnPixelData) layoutData;
+                               width += col.width;
+                       } else if (layoutData instanceof ColumnWeightData) {
+                               ColumnWeightData col= (ColumnWeightData) layoutData;
+                               width += col.minimumWidth;
+                       } else {
+                               Assert.isTrue(false, "Unknown column layout data"); //$NON-NLS-1$
+                       }
+               }
+               if (width > result.x)
+                       result.x= width;
+               return result;
+       }
+       
+       void layoutTable(Table table, int width, Rectangle area, boolean increase) {
+               // XXX: Layout is being called with an invalid value the first time
+               // it is being called on Linux. This method resets the
+               // Layout to null so we make sure we run it only when
+               // the value is OK.
+               if (width <= 1)
+                       return;
+
+               TableColumn[] tableColumns= table.getColumns();
+               int size= Math.min(columns.size(), tableColumns.length);
+               int[] widths= new int[size];
+               int fixedWidth= 0;
+               int numberOfWeightColumns= 0;
+               int totalWeight= 0;
+
+               // First calc space occupied by fixed columns
+               for (int i= 0; i < size; i++) {
+                       ColumnLayoutData col= columns.get(i);
+                       if (col instanceof ColumnPixelData) {
+                               int pixels= ((ColumnPixelData) col).width;
+                               widths[i]= pixels;
+                               fixedWidth += pixels;
+                       } else if (col instanceof ColumnWeightData) {
+                               ColumnWeightData cw= (ColumnWeightData) col;
+                               numberOfWeightColumns++;
+                               // first time, use the weight specified by the column data, otherwise use the actual width as the weight
+                               // int weight = firstTime ? cw.weight : tableColumns[i].getWidth();
+                               int weight= cw.weight;
+                               totalWeight += weight;
+                       } else {
+                               Assert.isTrue(false, "Unknown column layout data"); //$NON-NLS-1$
+                       }
+               }
+
+               // Do we have columns that have a weight
+               if (numberOfWeightColumns > 0) {
+                       // Now distribute the rest to the columns with weight.
+                       int rest= width - fixedWidth;
+                       int totalDistributed= 0;
+                       for (int i= 0; i < size; ++i) {
+                               ColumnLayoutData col= columns.get(i);
+                               if (col instanceof ColumnWeightData) {
+                                       ColumnWeightData cw= (ColumnWeightData) col;
+                                       // calculate weight as above
+                                       // int weight = firstTime ? cw.weight : tableColumns[i].getWidth();
+                                       int weight= cw.weight;
+                                       int pixels= totalWeight == 0 ? 0 : weight * rest / totalWeight;
+                                       if (pixels < cw.minimumWidth)
+                                               pixels= cw.minimumWidth;
+                                       totalDistributed += pixels;
+                                       widths[i]= pixels;
+                               }
+                       }
+
+                       // Distribute any remaining pixels to columns with weight.
+                       int diff= rest - totalDistributed;
+                       for (int i= 0; diff > 0; ++i) {
+                               if (i == size)
+                                       i= 0;
+                               ColumnLayoutData col= columns.get(i);
+                               if (col instanceof ColumnWeightData) {
+                                       ++widths[i];
+                                       --diff;
+                               }
+                       }
+               }
+               
+               if (increase) {
+                       table.setSize(area.width, area.height);
+               }
+               for (int i= 0; i < size; i++) {
+                       tableColumns[i].setWidth(widths[i]);
+               }
+               if (!increase) {
+                       table.setSize(area.width, area.height);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/TwoArrayQuickSort.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/TwoArrayQuickSort.java
new file mode 100644 (file)
index 0000000..43330ff
--- /dev/null
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.util;
+
+import org.eclipse.core.runtime.Assert;
+
+
+/**
+ * Quick sort to sort two arrays in parallel.
+ */
+public class TwoArrayQuickSort {
+
+       private static void internalSort(String[] keys, Object[] values, int left, int right, boolean ignoreCase) { 
+       
+               int original_left= left;
+               int original_right= right;
+               
+               String mid= keys[(left + right) / 2]; 
+               do { 
+                       while (smaller(keys[left], mid, ignoreCase)) { 
+                               left++; 
+                       } 
+                       while (smaller(mid, keys[right], ignoreCase)) { 
+                               right--; 
+                       } 
+                       if (left <= right) { 
+                               String tmp= keys[left]; 
+                               keys[left]= keys[right]; 
+                               keys[right]= tmp;
+                               
+                               Object tmp2= values[left]; 
+                               values[left]= values[right]; 
+                               values[right]= tmp2;
+                               
+                               left++; 
+                               right--; 
+                       } 
+               } while (left <= right);
+               
+               if (original_left < right) {
+                       internalSort(keys , values, original_left, right, ignoreCase); 
+               }       
+               if (left < original_right) {
+                        internalSort(keys, values, left, original_right, ignoreCase); 
+               } 
+       }
+       private static boolean smaller(String left, String right, boolean ignoreCase) {
+               if (ignoreCase)
+                       return left.compareToIgnoreCase(right) < 0;
+               return left.compareTo(right) < 0;       
+       }
+       /**
+        * Sorts keys and values in parallel.
+        */
+       public static void sort(String[] keys, Object[] values, boolean ignoreCase) { 
+               if (keys != null && values != null) {
+                       Assert.isTrue(keys.length == values.length);
+                       if (keys.length > 1)
+                               internalSort(keys, values, 0, keys.length - 1, ignoreCase);     
+               } else {
+                       if (keys != null || values != null)
+                               Assert.isTrue(false, "Either keys or values in null"); //$NON-NLS-1$
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/Util.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/Util.java
new file mode 100644 (file)
index 0000000..53fa9ba
--- /dev/null
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.util;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+public class Util implements IDebugLogConstants{
+       public static boolean VERBOSE_CONTENTASSIST = false;
+       private Util() {
+       }
+       /*
+        * Add a log entry
+        */
+       
+       public static void debugLog(String message, DebugLogConstant client) {
+               if( CUIPlugin.getDefault() == null ) return;
+               if ( CUIPlugin.getDefault().isDebugging() && isActive(client)) {
+                       while (message.length() > 100) {        
+                               String partial = message.substring(0, 100);
+                               message = message.substring(100);
+                               System.out.println(partial + "\\"); //$NON-NLS-1$
+                       }
+                       if (message.endsWith("\n")) { //$NON-NLS-1$
+                               System.err.print(message);
+                       } else {
+                               System.out.println(message);
+                       }
+               }
+       }
+       
+       public static boolean isActive(DebugLogConstant client) {
+               if (client.equals(IDebugLogConstants.CONTENTASSIST)){
+                       return VERBOSE_CONTENTASSIST;
+               }
+               return false;
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ViewerPane.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/ViewerPane.java
new file mode 100644 (file)
index 0000000..c7ded19
--- /dev/null
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.util;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.custom.ViewForm;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.ToolBar;
+
+import org.eclipse.jface.action.ToolBarManager;
+
+/**
+ * A <code>ViewerPane</code> is a convenience class which installs a
+ * <code>CLabel</code> and a <code>Toolbar</code> in a <code>ViewForm</code>.
+ * <P>
+ */
+public class ViewerPane extends ViewForm {
+       
+       private ToolBarManager fToolBarManager;
+
+       public ViewerPane(Composite parent, int style) {
+               super(parent, style);
+               
+               marginWidth= 0;
+               marginHeight= 0;
+               
+               CLabel label= new CLabel(this, SWT.NONE);
+               setTopLeft(label);
+               
+               ToolBar tb= new ToolBar(this, SWT.FLAT);
+               setTopCenter(tb);
+               fToolBarManager= new ToolBarManager(tb);
+       }
+       
+       /**
+        * Sets the receiver's title text.
+        */
+       public void setText(String label) {
+               CLabel cl= (CLabel) getTopLeft();
+               cl.setText(label);              
+       }
+       
+       public String getText() {
+               CLabel cl= (CLabel) getTopLeft();
+               return cl.getText();
+       }
+       
+       /**
+        * Sets the receiver's title image.
+        */
+       public void setImage(Image image) {
+               CLabel cl= (CLabel) getTopLeft();
+               cl.setImage(image);
+       }
+       
+       public Image getImage() {
+               CLabel cl= (CLabel) getTopLeft();
+               return cl.getImage();
+       }
+       
+       public ToolBarManager getToolBarManager() {
+               return fToolBarManager;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AdaptingSelectionProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AdaptingSelectionProvider.java
new file mode 100644 (file)
index 0000000..c569ec8
--- /dev/null
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+
+/**
+ * A selection provider that adapts the elements of structured selections
+ * to a requested type. 
+ * @author markus.schorn@windriver.com
+ */
+public class AdaptingSelectionProvider implements ISelectionProvider, ISelectionChangedListener {
+
+       private Class<?> fTargetType;
+       private ListenerList fListenerList;
+       private ISelectionProvider fProvider;
+
+       public AdaptingSelectionProvider(Class<?> targetType, ISelectionProvider provider) {
+               fProvider= provider;
+               fTargetType= targetType;
+               fListenerList= new ListenerList();
+       }
+       
+       private ISelection convertSelection(ISelection selection) {
+               if (selection != null) {
+                       if (selection instanceof IStructuredSelection) {
+                               IStructuredSelection ss= (IStructuredSelection) selection;
+                               ArrayList<Object> adapted= new ArrayList<Object>();
+                               for (Iterator<?> iter = ss.iterator(); iter.hasNext(); ) {
+                                       Object elem= adaptElem(iter.next());
+                                       if (elem != null) {
+                                               adapted.add(elem);
+                                       }
+                               }
+                               return new StructuredSelection(adapted);
+                       }
+               }
+               return selection;
+       }
+
+       private Object adaptElem(Object elem) {
+               if (fTargetType.isInstance(elem)) {
+                       return elem;
+               }
+               if (elem instanceof IAdaptable) {
+                       return ((IAdaptable) elem).getAdapter(fTargetType);
+               }
+               return null;
+       }
+
+       public void addSelectionChangedListener(ISelectionChangedListener listener) {
+               if (fListenerList.isEmpty()) {
+                       fProvider.addSelectionChangedListener(this);
+               }
+               fListenerList.add(listener);
+       }
+
+       public ISelection getSelection() {
+               return convertSelection(fProvider.getSelection());
+       }
+
+       public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+               fListenerList.remove(listener);
+               if (fListenerList.isEmpty()) {
+                       fProvider.removeSelectionChangedListener(this);
+               }
+       }
+
+       public void setSelection(ISelection selection) {
+               throw new UnsupportedOperationException();
+       }
+
+       public void selectionChanged(SelectionChangedEvent event) {
+               SelectionChangedEvent event2= new SelectionChangedEvent(this, convertSelection(event.getSelection()));
+               Object[] listeners= fListenerList.getListeners();
+               for (Object listener : listeners) {
+                       ISelectionChangedListener l= (ISelectionChangedListener) listener;
+                       l.selectionChanged(event2);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AppearanceAwareLabelProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AppearanceAwareLabelProvider.java
new file mode 100644 (file)
index 0000000..7c0c665
--- /dev/null
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
+
+/**
+ * CUILabelProvider that respects settings from the Appearance preference page.
+ * Triggers a viewer update when a preference changes (currently none).
+ */
+public class AppearanceAwareLabelProvider extends CUILabelProvider implements IPropertyChangeListener {
+
+       public final static long DEFAULT_TEXTFLAGS= CElementLabels.M_PARAMETER_TYPES | CElementLabels.PROJECT_POST_QUALIFIED | CElementLabels.F_APP_TYPE_SIGNATURE | CElementLabels.M_APP_RETURNTYPE;
+       public final static int DEFAULT_IMAGEFLAGS= CElementImageProvider.OVERLAY_ICONS;
+
+       /**
+        * Constructor for AppearanceAwareLabelProvider.
+        */
+       public AppearanceAwareLabelProvider(long textFlags, int imageFlags) {
+               super(textFlags, imageFlags);
+       }
+
+       /**
+        * Creates a labelProvider with DEFAULT_TEXTFLAGS and DEFAULT_IMAGEFLAGS
+        */     
+       public AppearanceAwareLabelProvider() {
+               this(DEFAULT_TEXTFLAGS, DEFAULT_IMAGEFLAGS);
+       }
+       
+       /*
+        * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
+        */
+       public void propertyChange(PropertyChangeEvent event) {
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AsyncTreeContentProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AsyncTreeContentProvider.java
new file mode 100644 (file)
index 0000000..359d0a3
--- /dev/null
@@ -0,0 +1,357 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWTException;
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.cdt.internal.ui.CUIMessages;
+
+/**
+ * A TreeContentProvider that supports asyncronous computation of child nodes.
+ * <p>
+ * While a computation for children is in progress an object of type {@link AsyncTreeWorkInProgressNode}
+ * is returned as a child. On completion of the computation the viewer will be refreshed with the actual
+ * children.
+ */
+public abstract class AsyncTreeContentProvider implements ITreeContentProvider {
+    private static final int PRIORITY_LOW = 0;
+    private static final int PRIORITY_HIGH = 10;
+    protected static final Object[] NO_CHILDREN = new Object[0];
+    
+    private Object fInput;
+    private HashMap<Object, Object[]> fChildNodes= new HashMap<Object, Object[]>();
+    private HashSet<Object> fHighPriorityTasks= new HashSet<Object>();
+    private HashSet<Object> fLowPriorityTasks= new HashSet<Object>();
+    private HashMap<Object, Object[]> fViewUpdates= new HashMap<Object, Object[]>();
+    private int fViewUpdateDelta;
+    private Job fJob;
+    private Display fDisplay;
+    private TreeViewer fTreeViewer= null;
+    private Runnable fScheduledViewupdate= null;
+    private HashSet<Object> fAutoexpand;
+    private Object fAutoSelect;
+
+    public AsyncTreeContentProvider(Display disp) {
+        fDisplay= disp;
+        fJob= new Job(CUIMessages.AsyncTreeContentProvider_JobName) { 
+            @Override
+                       protected IStatus run(final IProgressMonitor monitor) {
+                return runJob(monitor);
+            }
+        };
+        fJob.setSystem(true);
+    }
+    /**
+     * {@inheritDoc}
+     * <p> 
+     * This implementation returns the parent for nodes indicating asyncronous computation.
+     * It returns <code>null</code> for all other elements. It should be overridden and
+     * called by derived classes.
+     */
+    public Object getParent(Object element) {
+        if (element instanceof AsyncTreeWorkInProgressNode) {
+            AsyncTreeWorkInProgressNode wipNode = (AsyncTreeWorkInProgressNode) element;
+            return wipNode.getParent();
+        }
+        return null;
+    }
+    
+    /**
+     * Returns the child elements of the given parent element, or <code>null</code>.
+     * <p>
+     * The method is called within the UI-thread and shall therefore return null in case
+     * the computation of the children may take longer. 
+     * </p>
+     * The result is neither modified by the content provider nor the viewer.
+     *
+     * @param parentElement the parent element
+     * @return an array of child elements, or <code>null</code>
+     */
+    protected Object[] syncronouslyComputeChildren(Object parentElement) {
+        return null;
+    }
+
+    /**
+     * Returns the child elements of the given parent element.
+     * <p>
+     * The method is called outside the UI-thread. There is no need to report progress, the monitor
+     * is supplied such that implementations can check for cancel requests. 
+     * </p>
+     * The result is neither modified by the content provider nor the viewer.
+     *
+     * @param parentElement the parent element
+     * @param monitor the monitor that can be checked for a cancel event.
+     * @return an array of child elements.
+     */
+    protected Object[] asyncronouslyComputeChildren(Object parentElement, IProgressMonitor monitor) {
+        return NO_CHILDREN;
+    }
+
+    /**
+     * Clears all caches and stops asyncronous computations. As a consequence 
+     * child nodes requested by the viewer have to be computed from scratch.
+     * <p>
+     * Derived classes may override this method but must call <code>super.clearCaches()</code>.
+     */
+    protected void clear() {
+        fChildNodes.clear();       
+        synchronized (fHighPriorityTasks) {
+            fScheduledViewupdate= null;
+            fHighPriorityTasks.clear();
+            fLowPriorityTasks.clear();
+            fViewUpdates.clear();   
+        }
+    }
+    
+    /**
+     * Recomputes all of the nodes, trying to keep the expanded state even with async
+     * computations.
+     */
+    public void recompute() {
+       if (getInput() != null) {
+               fAutoexpand= new HashSet<Object>();
+               fAutoexpand.addAll(Arrays.asList(fTreeViewer.getVisibleExpandedElements()));
+               fAutoSelect= null;
+               fAutoSelect= ((IStructuredSelection) fTreeViewer.getSelection()).getFirstElement();
+               clear();
+               refreshViewer();
+       }
+    }
+    
+    /**
+     * Refreshes the viewer
+     */
+    private void refreshViewer() {
+        if (fTreeViewer != null) {
+            fTreeViewer.refresh();
+        }
+    }
+    
+    final public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+        if (newInput != oldInput) {
+            clear();
+            fInput= newInput;
+        }
+        if (viewer instanceof TreeViewer) {
+            fTreeViewer= (TreeViewer) viewer;
+        }
+        else {
+            fTreeViewer= null;
+        }
+    }
+
+    final public Object getInput() {
+        return fInput;
+    }
+    
+    final public Object[] getElements(Object inputElement) {
+        return getChildren(inputElement);
+    }
+
+    final public Object[] getChildren(Object parentElement) {
+        Object[] children = internalGetChildren(parentElement);
+        if (children == null) {
+            scheduleQuery(parentElement, PRIORITY_HIGH);
+            return new Object[] {new AsyncTreeWorkInProgressNode(parentElement)};
+        }
+        return children;
+    }
+
+    final public boolean hasChildren(Object element) {
+        assert Display.getCurrent() != null;
+
+        Object[] children= internalGetChildren(element);
+        if (children == null) {
+            scheduleQuery(element, PRIORITY_LOW);
+            return true;
+        }
+        return children.length > 0;
+    }
+
+    public void dispose() {
+        fTreeViewer= null;
+        clear();
+    }
+
+    private void scheduleQuery(Object element, int priority) {
+        synchronized(fHighPriorityTasks) {
+            if (priority == PRIORITY_HIGH) {
+                if (!fHighPriorityTasks.contains(element)) {
+                    fHighPriorityTasks.add(element);
+                    fLowPriorityTasks.remove(element);
+                }
+            }
+            else {
+                if (!fHighPriorityTasks.contains(element) &&
+                        !fLowPriorityTasks.contains(element)) {
+                    fLowPriorityTasks.add(element);
+                }
+            }
+            fJob.schedule();
+        }
+    }
+    
+    private IStatus runJob(final IProgressMonitor monitor) {
+        monitor.beginTask(CUIMessages.AsyncTreeContentProvider_TaskName, IProgressMonitor.UNKNOWN); 
+        try {
+            Object parent= getParentForNextTask();
+            while (parent != null) {
+                Object[] children= asyncronouslyComputeChildren(parent, monitor);
+                synchronized (fHighPriorityTasks) {
+                    if (fHighPriorityTasks.remove(parent) || fLowPriorityTasks.remove(parent)) {
+                        fViewUpdates.put(parent, children);
+                        scheduleViewerUpdate();
+                    }
+                }
+                parent= getParentForNextTask();
+            }
+            return Status.OK_STATUS;
+        }
+        finally {
+            monitor.done();
+        }
+    }
+    
+    private void scheduleViewerUpdate() {
+        Runnable runme= null;
+        synchronized(fHighPriorityTasks) {
+            if (fScheduledViewupdate != null) {
+                return;
+            }
+            runme= fScheduledViewupdate= new Runnable(){
+                public void run() {
+                    HashMap<Object, Object[]> updates= null;
+                    synchronized(fHighPriorityTasks) {
+                        if (fViewUpdates.isEmpty()) {
+                            fScheduledViewupdate= null;
+                            return;
+                        }
+                        if (fScheduledViewupdate != this) {
+                            return;
+                        }
+                        updates= fViewUpdates;
+                        fViewUpdates= new HashMap<Object, Object[]>();
+                    }
+                    fChildNodes.putAll(updates);
+                    if (fTreeViewer instanceof ExtendedTreeViewer) {
+                        ((ExtendedTreeViewer) fTreeViewer).refresh(updates.keySet().toArray());
+                    }
+                    else if (fTreeViewer != null) {
+                        for (Iterator<Object> iter = updates.keySet().iterator(); iter.hasNext();) {
+                            fTreeViewer.refresh(iter.next());
+                        }
+                    }
+                    for (Iterator<Object[]> iter = updates.values().iterator(); iter.hasNext();) {
+                        checkForAutoExpand(iter.next());
+                    }
+                    fViewUpdateDelta= Math.min(1000, fViewUpdateDelta*2);
+                    fDisplay.timerExec(fViewUpdateDelta, this);
+                }
+            };
+        }
+        try {
+            fViewUpdateDelta= 32;
+            fDisplay.asyncExec(runme); 
+        }
+        catch (SWTException e) {
+            // display may have been disposed.
+        }
+    }
+
+    private void checkForAutoExpand(Object[] objects) {
+        if (fTreeViewer == null) {
+            return;
+        }
+        if (fAutoexpand != null && !fAutoexpand.isEmpty()) {
+            for (int i = 0; i < objects.length; i++) {
+                Object object = objects[i];
+                if (fAutoexpand.remove(object)) {
+                    fTreeViewer.setExpandedState(object, true);
+                }
+                if (object.equals(fAutoSelect)) {
+                    if (fTreeViewer.getSelection().isEmpty()) {
+                        fTreeViewer.setSelection(new StructuredSelection(object));
+                    }
+                    fAutoSelect= null;
+                }
+            }
+        }
+        if (fAutoSelect != null) {
+            if (fTreeViewer.getSelection().isEmpty()) {
+                for (int i = 0; i < objects.length; i++) {
+                    Object object = objects[i];
+                    if (object.equals(fAutoSelect)) {
+                        fTreeViewer.setSelection(new StructuredSelection(object));
+                        fAutoSelect= null;
+                    }
+                }
+            }
+            else {
+                fAutoSelect= null;
+            }
+        }
+    }
+
+    private final Object getParentForNextTask() {
+        synchronized(fHighPriorityTasks) {
+            Object parent= null;
+            if (!fHighPriorityTasks.isEmpty()) {
+                parent= fHighPriorityTasks.iterator().next();
+            }
+            else if (!fLowPriorityTasks.isEmpty()) {
+                parent= fLowPriorityTasks.iterator().next();
+            }
+            return parent;
+        }
+    }
+
+
+    private Object[] internalGetChildren(Object parentElement) {
+        assert Display.getCurrent() != null;
+
+        if (parentElement instanceof AsyncTreeWorkInProgressNode) {
+            return NO_CHILDREN;
+        }
+        Object[] children= fChildNodes.get(parentElement);
+        if (children == null) {
+            children= syncronouslyComputeChildren(parentElement);
+            if (children != null) {
+                final Object[] finalChildren= children;
+                fChildNodes.put(parentElement, children);
+                fDisplay.asyncExec(new Runnable() {
+                    public void run() {
+                        checkForAutoExpand(finalChildren);
+                    }});
+            }
+        }
+        return children;
+    }
+    
+    final protected Display getDisplay() {
+       return fDisplay;
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AsyncTreeWorkInProgressNode.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/AsyncTreeWorkInProgressNode.java
new file mode 100644 (file)
index 0000000..0b2d82e
--- /dev/null
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+public class AsyncTreeWorkInProgressNode {
+
+    private Object fParent;
+
+    public AsyncTreeWorkInProgressNode(Object parentElement) {
+        fParent= parentElement;
+    }
+    public Object getParent() {
+        return fParent;
+    }
+    @Override
+       public String toString() {
+        return "..."; //$NON-NLS-1$
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/BasicElementLabels.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/BasicElementLabels.java
new file mode 100644 (file)
index 0000000..2499c85
--- /dev/null
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import java.io.File;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.osgi.util.TextProcessor;
+import org.eclipse.ui.IWorkingSet;
+
+import org.eclipse.cdt.internal.corext.util.Strings;
+
+/**
+ * A label provider for basic elements like paths. The label provider will make sure that the labels are correctly
+ * shown in RTL environments.
+ */
+public class BasicElementLabels {
+       // TextProcessor delimiters
+       private static final String CODE_DELIMITERS= TextProcessor.getDefaultDelimiters() + "<>()?,{}+-*!%=^|&;[]~"; //$NON-NLS-1$
+       private static final String FILE_PATTERN_DELIMITERS= TextProcessor.getDefaultDelimiters() + "*.?"; //$NON-NLS-1$
+       private static final String URL_DELIMITERS= TextProcessor.getDefaultDelimiters() + ":@?-"; //$NON-NLS-1$
+       
+       /**
+        * Returns the label of a path.
+        *
+        * @param path the path
+        * @param isOSPath if <code>true</code>, the path represents an OS path, if <code>false</code> it is a workspace path.
+        * @return the label of the path to be used in the UI.
+        */
+       public static String getPathLabel(IPath path, boolean isOSPath) {
+               String label;
+               if (isOSPath) {
+                       label= path.toOSString();
+               } else {
+                       label= path.makeRelative().toString();
+               }
+               return Strings.markLTR(label);
+       }
+
+       /**
+        * Returns the label of the path of a file.
+        *
+        * @param file the file
+        * @return the label of the file path to be used in the UI.
+        */
+       public static String getPathLabel(File file) {
+               return Strings.markLTR(file.getAbsolutePath());
+       }
+
+       /**
+        * Returns the label for a file pattern like '*.java'
+        *
+        * @param name the pattern
+        * @return the label of the pattern.
+        */
+       public static String getFilePattern(String name) {
+               return Strings.markLTR(name, FILE_PATTERN_DELIMITERS);
+       }
+
+       /**
+        * Returns the label for a URL, URI or URL part. Example is 'http://www.x.xom/s.html#1'
+        *
+        * @param name the URL string
+        * @return the label of the URL.
+        */
+       public static String getURLPart(String name) {
+               return Strings.markLTR(name, URL_DELIMITERS);
+       }
+
+       /**
+        * Returns a label for a resource name.
+        *
+        * @param resource the resource
+        * @return the label of the resource name.
+        */
+       public static String getResourceName(IResource resource) {
+               return Strings.markLTR(resource.getName());
+       }
+
+       /**
+        * Returns a label for a resource name.
+        *
+        * @param resourceName the resource name
+        * @return the label of the resource name.
+        */
+       public static String getResourceName(String resourceName) {
+               return Strings.markLTR(resourceName);
+       }
+
+       /**
+        * Returns a label for C element name. Example is 'new Test<? extends List>() { ...}'.
+        * This method should only be used for simple element names. Use
+        * {@link CElementLabels} to create a label from a C element.
+        *
+        * @param name the C element name.
+        * @return the label for the C element
+        */
+       public static String getCElementName(String name) {
+               return Strings.markCElementLabelLTR(name);
+       }
+
+       /**
+        * Returns a label for C code snippet used in a label. Example is 'Test test= new Test<? extends List>() { ...}'.
+        *
+        * @param string the C code snippet
+        * @return the label for the C code snippet
+        */
+       public static String getCCodeString(String string) {
+               return Strings.markLTR(string, CODE_DELIMITERS);
+       }
+
+       /**
+        * Returns a label for a version name. Example is '1.4.1'
+        *
+        * @param name the version string
+        * @return the version label
+        */
+       public static String getVersionName(String name) {
+               return Strings.markLTR(name);
+       }
+
+       /**
+        * Returns a label for a working set
+        *
+        * @param set the working set
+        * @return the label of the working set
+        */
+       public static String getWorkingSetLabel(IWorkingSet set) {
+               return Strings.markLTR(set.getLabel());
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CDTContextActivator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CDTContextActivator.java
new file mode 100644 (file)
index 0000000..b1788ab
--- /dev/null
@@ -0,0 +1,245 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.ui.IPartListener2;
+import org.eclipse.ui.IWindowListener;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartReference;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.contexts.IContextActivation;
+import org.eclipse.ui.contexts.IContextService;
+import org.eclipse.ui.navigator.CommonNavigator;
+import org.eclipse.ui.part.IPage;
+import org.eclipse.ui.views.contentoutline.ContentOutline;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.editor.CContentOutlinePage;
+
+/**
+ * Once registered as windows listener, observes all part activations. Whenever the
+ * CDT outline view is brought to the front, the CDT context is set.
+ */
+public class CDTContextActivator implements IWindowListener, IPartListener2 {
+       private static CDTContextActivator sInstance= new CDTContextActivator();
+       
+       private Map<ContentOutline, IContextActivation> fActivationPerOutline = new HashMap<ContentOutline, IContextActivation>();
+       private Map<CommonNavigator, SelectionListener> fActivationPerNavigator= new HashMap<CommonNavigator, SelectionListener>();
+       private Collection<IWorkbenchWindow> fWindows= new HashSet<IWorkbenchWindow>();
+
+       
+       private CDTContextActivator() {
+       }
+       
+       public static CDTContextActivator getInstance() {
+               return sInstance;
+       }
+       
+       public void install() {
+               IWorkbench workbench = PlatformUI.getWorkbench();
+               if (workbench != null) {
+                       // listen for new windows
+                       workbench.addWindowListener(this);
+                       IWorkbenchWindow[] wnds= workbench.getWorkbenchWindows();
+                       for (int i = 0; i < wnds.length; i++) {
+                               IWorkbenchWindow window = wnds[i];
+                               register(window);
+                       }
+                       // register open windows
+                       IWorkbenchWindow ww= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+                       if (ww != null) {
+                               IWorkbenchPage activePage = ww.getActivePage();
+                               if (activePage != null) {
+                                       IWorkbenchPartReference part= activePage.getActivePartReference();
+                                       if (part != null) {
+                                               partActivated(part);
+                                       }
+                               }
+                       }
+               }
+       }
+
+       public void uninstall() {
+               for (Iterator<IWorkbenchWindow> iterator = fWindows.iterator(); iterator.hasNext();) {
+                       IWorkbenchWindow window = iterator.next();
+                       unregister(window);
+               }
+               for (Iterator<SelectionListener> iterator = fActivationPerNavigator.values().iterator(); iterator.hasNext();) {
+                       SelectionListener l= iterator.next();
+                       l.uninstall();
+               }
+       }
+
+       private void register(IWorkbenchWindow wnd) {
+               wnd.getPartService().addPartListener(this);
+               fWindows.add(wnd);
+       }
+       
+       private void unregister(IWorkbenchWindow wnd) {
+               wnd.getPartService().removePartListener(this);
+               fWindows.remove(wnd);
+       }
+
+       public void windowOpened(IWorkbenchWindow window) {
+               register(window);
+       }
+
+       public void windowClosed(IWorkbenchWindow window) {
+               unregister(window);
+       }
+
+       public void windowActivated(IWorkbenchWindow window) {
+       }
+       
+       public void windowDeactivated(IWorkbenchWindow window) {
+       }
+
+       private void onContentOutlineClosed(ContentOutline outline) {
+               fActivationPerOutline.remove(outline);
+       }
+       
+       private void onContentOutlineActivated(ContentOutline outline) {
+               IPage page = outline.getCurrentPage();
+               if (page instanceof CContentOutlinePage) {
+                       if (!fActivationPerOutline.containsKey(outline)){
+                               // cdt outline activated for the first time
+                               IContextService ctxtService = (IContextService)outline.getViewSite().getService(IContextService.class);
+                               IContextActivation activateContext = ctxtService.activateContext(CUIPlugin.CVIEWS_SCOPE);
+                               fActivationPerOutline.put(outline,activateContext);
+                       }
+               } 
+               else {
+                       IContextActivation activation = fActivationPerOutline.remove(outline); 
+                       if (activation != null) {
+                               // other outline page brought to front
+                               IContextService ctxtService = (IContextService)outline.getViewSite().getService(IContextService.class);
+                               ctxtService.deactivateContext(activation);
+                       }
+               }
+       }
+
+       private static class SelectionListener implements ISelectionChangedListener {
+               private IWorkbenchPartSite fSite;
+               private IContextService fCtxService;
+               private IContextActivation fActivation;
+
+               public SelectionListener(IWorkbenchPartSite site) {
+                       fSite= site;
+                       fCtxService= (IContextService)fSite.getService(IContextService.class);
+                       ISelectionProvider sp= site.getSelectionProvider();
+                       
+                       if (sp != null && fCtxService != null) {
+                               sp.addSelectionChangedListener(this);
+                               onNewSelection(sp.getSelection());
+                       }
+               }
+
+               public void uninstall() {
+                       ISelectionProvider sp= fSite.getSelectionProvider();
+                       if (sp != null && fCtxService != null) {
+                               onNewSelection(null);
+                               sp.removeSelectionChangedListener(this);
+                       }
+               }
+               
+               public void selectionChanged(SelectionChangedEvent event) {
+                       onNewSelection(event.getSelection());
+               }
+
+               private void onNewSelection(ISelection selection) {
+                       boolean isRelevant= false;
+                       if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
+                               if (((IStructuredSelection) selection).getFirstElement() instanceof ICElement) {
+                                       isRelevant = true;
+                               }
+                       }
+                       if (isRelevant) {
+                               if (fActivation == null) {
+                                       fActivation= fCtxService.activateContext(CUIPlugin.CVIEWS_SCOPE);
+                               }
+                       }
+                       else {
+                               if (fActivation != null) {
+                                       fCtxService.deactivateContext(fActivation);
+                                       fActivation= null;
+                               }
+                       }
+               }
+       }
+
+       private void onCommonNavigatorActivated(CommonNavigator part) {
+               SelectionListener l= fActivationPerNavigator.get(part);
+               if (l == null) {
+                       l= new SelectionListener(part.getSite());
+                       fActivationPerNavigator.put(part, l);
+               }
+       }
+
+       private void onCommonNavigatorClosed(CommonNavigator part) {
+               fActivationPerNavigator.remove(part);
+       }
+
+       public void partActivated(IWorkbenchPartReference partRef) {
+               IWorkbenchPart part= partRef.getPart(false);
+               if (part instanceof ContentOutline) {
+                       onContentOutlineActivated((ContentOutline) part);
+               }
+               else if (part instanceof CommonNavigator) {
+                       onCommonNavigatorActivated((CommonNavigator) part);
+               }
+       }
+
+       public void partClosed(IWorkbenchPartReference partRef) {
+               IWorkbenchPart part= partRef.getPart(false);
+               if (part instanceof ContentOutline) {
+                       onContentOutlineClosed((ContentOutline)part);
+               }
+               else if (part instanceof CommonNavigator) {
+                       onCommonNavigatorClosed((CommonNavigator) part);
+               }
+       }
+
+       public void partBroughtToTop(IWorkbenchPartReference partRef) {
+       }
+
+       public void partDeactivated(IWorkbenchPartReference partRef) {
+       }
+
+       public void partOpened(IWorkbenchPartReference partRef) {
+       }
+
+       public void partHidden(IWorkbenchPartReference partRef) {
+       }
+
+       public void partVisible(IWorkbenchPartReference partRef) {
+       }
+
+       public void partInputChanged(IWorkbenchPartReference partRef) {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java
new file mode 100644 (file)
index 0000000..fef2ccf
--- /dev/null
@@ -0,0 +1,648 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Markus Schorn (Wind River Systems)
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.IArchiveContainer;
+import org.eclipse.cdt.core.model.IBinary;
+import org.eclipse.cdt.core.model.IBinaryContainer;
+import org.eclipse.cdt.core.model.IBinaryModule;
+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.IContributedCElement;
+import org.eclipse.cdt.core.model.IDeclaration;
+import org.eclipse.cdt.core.model.IField;
+import org.eclipse.cdt.core.model.IInclude;
+import org.eclipse.cdt.core.model.IIncludeReference;
+import org.eclipse.cdt.core.model.ILibraryReference;
+import org.eclipse.cdt.core.model.IMethodDeclaration;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.core.model.ISourceRoot;
+import org.eclipse.cdt.core.model.ITemplate;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CElementImageDescriptor;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.model.CModelManager;
+
+
+/**
+ * Default strategy of the C plugin for the construction of C element icons.
+ */
+public class CElementImageProvider {
+       
+       /**
+        * Flags for the CElementImageProvider:
+        * Generate images with overlays.
+        */
+       public final static int OVERLAY_ICONS= 0x1;
+
+       /**
+        * Generate small sized images.
+        */
+       public final static int SMALL_ICONS= 0x2;
+
+       /**
+        * Use the 'light' style for rendering types.
+        */     
+       public final static int LIGHT_TYPE_ICONS= 0x4;
+       
+       /**
+        * Show error overlay. 
+        */     
+       public final static int OVERLAY_ERROR= 0x8;
+
+       /**
+        * Show warning overlay
+        */     
+       public final static int OVERLAY_WARNING= 0x10;
+       
+       /**
+        * Show override overlay. 
+        */     
+       public final static int OVERLAY_OVERRIDE= 0x20;
+
+       /**
+        * Show implements overlay. 
+        */     
+       public final static int OVERLAY_IMPLEMENTS= 0x40;
+       
+       /**
+        * Show external file overlay.
+        */
+       public final static int OVERLAY_EXTERNAL= 0x80;
+       
+       public static final Point SMALL_SIZE= new Point(16, 16);
+       public static final Point BIG_SIZE= new Point(22, 16);
+
+       private static ImageDescriptor DESC_OBJ_PROJECT_CLOSED; 
+       private static ImageDescriptor DESC_OBJ_PROJECT;        
+       //private static ImageDescriptor DESC_OBJ_FOLDER;
+       {
+               ISharedImages images= CUIPlugin.getDefault().getWorkbench().getSharedImages(); 
+               DESC_OBJ_PROJECT_CLOSED= images.getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED);
+               DESC_OBJ_PROJECT=                images.getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT);
+               //DESC_OBJ_FOLDER=               images.getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER);
+       }
+       
+       public CElementImageProvider() {
+       }       
+               
+       /**
+        * Returns the icon for a given element. The icon depends on the element type
+        * and element properties. If configured, overlay icons are constructed for
+        * <code>ISourceReference</code>s.
+        * @param flags Flags as defined by the CElementImageProvider
+        */
+       public Image getImageLabel(Object element, int flags) {
+               ImageDescriptor descriptor= null;
+               if (element instanceof ICElement) {
+                       if (!CCorePlugin.showSourceRootsAtTopOfProject() &&
+                               element instanceof ICContainer && isParentOfSourceRoot(element)) {
+                               
+                               descriptor = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_SOURCE2_ROOT);
+                       } else {
+                               descriptor= getCImageDescriptor((ICElement) element, flags);
+                       }
+               } else if (element instanceof IFile) {
+                       // Check for Non Translation Unit.
+                       IFile file = (IFile)element;
+                       String name = file.getName();
+                       if (CoreModel.isValidTranslationUnitName(file.getProject(), name) ||
+                                       CoreModel.isValidTranslationUnitName(null, name)) {
+                               if (CoreModel.isValidCHeaderUnitName(null, name) ||
+                                       CoreModel.isValidCXXHeaderUnitName(null, name))
+                                       descriptor = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT_RESOURCE_H);
+                               else if (CoreModel.isValidASMSourceUnitName(null, name))
+                                       descriptor = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT_RESOURCE_A);
+                               else
+                                       descriptor = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT_RESOURCE);
+                               
+                               Point size= useSmallSize(flags) ? SMALL_SIZE : BIG_SIZE;
+                               descriptor = new CElementImageDescriptor(descriptor, 0, size);
+                       }
+               } else if (!CCorePlugin.showSourceRootsAtTopOfProject() &&
+                               element instanceof IFolder && isParentOfSourceRoot(element)) {
+                       descriptor = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_SOURCE2_ROOT);
+               }
+               if (descriptor == null && element instanceof IAdaptable) {
+                       descriptor= getWorkbenchImageDescriptor((IAdaptable) element, flags);
+               }
+               if (descriptor != null) {
+                       return CUIPlugin.getImageDescriptorRegistry().get(descriptor);
+               }
+               return null;
+       }
+
+       private boolean isParentOfSourceRoot(Object element) {
+               // we want to return true for parents of source roots which are not themselves source roots
+               // so we can distinguish the two and return the source root icon or the parent of source root icon
+               IFolder folder = null;
+               if (element instanceof ICContainer && !(element instanceof ISourceRoot))
+                       folder = (IFolder) ((ICContainer) element).getResource();
+               else if (element instanceof IFolder)
+                       folder = (IFolder) element;
+               if (folder == null)
+                       return false;
+               
+               ICProject cproject = CModelManager.getDefault().getCModel().findCProject(folder.getProject());
+               if (cproject != null) {
+                       try {
+                               IPath folderPath = folder.getFullPath();
+                               for (ICElement sourceRoot : cproject.getSourceRoots()) {
+                                       IPath sourceRootPath = sourceRoot.getPath();
+                                       if (folderPath.isPrefixOf(sourceRootPath)) {
+                                               return true;
+                                       }
+                               }
+                       } catch (CModelException e) {
+                       }
+               }
+               
+               return false;
+       }
+
+       public static ImageDescriptor getImageDescriptor(int type) {
+               switch (type) {
+                       case ICElement.C_VCONTAINER:
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CONTAINER);
+
+                       case ICElement.C_BINARY:
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_BINARY);
+       
+                       case ICElement.C_ARCHIVE:
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ARCHIVE);
+
+                       case ICElement.C_UNIT:
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT);
+                               
+                       case ICElement.C_CCONTAINER:
+                               //return DESC_OBJ_FOLDER;
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CFOLDER);
+                       
+                       case ICElement.C_PROJECT:
+                               return DESC_OBJ_PROJECT;
+                                       
+                       case ICElement.C_STRUCT:
+                       case ICElement.C_TEMPLATE_STRUCT:
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_STRUCT);
+                               
+                       case ICElement.C_CLASS:
+                       case ICElement.C_TEMPLATE_CLASS:
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CLASS);
+
+                       case ICElement.C_UNION:
+                       case ICElement.C_TEMPLATE_UNION:
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_UNION);
+
+                       case ICElement.C_TYPEDEF:
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TYPEDEF);
+
+                       case ICElement.C_ENUMERATION:
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ENUMERATION);
+
+                       case ICElement.C_ENUMERATOR:
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ENUMERATOR);
+
+                       case ICElement.C_FIELD:
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_PUBLIC_FIELD);
+                       
+                       case ICElement.C_VARIABLE:
+                       case ICElement.C_TEMPLATE_VARIABLE:
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_VARIABLE);
+
+                       case ICElement.C_METHOD:  
+                       case ICElement.C_METHOD_DECLARATION:
+                       case ICElement.C_TEMPLATE_METHOD:
+                       case ICElement.C_TEMPLATE_METHOD_DECLARATION:
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_PUBLIC_METHOD);
+                               
+                       case ICElement.C_FUNCTION:
+                       case ICElement.C_TEMPLATE_FUNCTION:
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_FUNCTION);
+
+                       case ICElement.C_STRUCT_DECLARATION:
+                       case ICElement.C_CLASS_DECLARATION:
+                       case ICElement.C_UNION_DECLARATION:
+                       case ICElement.C_VARIABLE_DECLARATION:
+                       case ICElement.C_TEMPLATE_CLASS_DECLARATION:
+                       case ICElement.C_TEMPLATE_STRUCT_DECLARATION:
+                       case ICElement.C_TEMPLATE_UNION_DECLARATION:
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_VAR_DECLARATION);
+                       
+                       case ICElement.C_FUNCTION_DECLARATION:
+                       case ICElement.C_TEMPLATE_FUNCTION_DECLARATION:
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_DECLARATION);
+
+                       case ICElement.C_INCLUDE:
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_INCLUDE);
+
+                       case ICElement.C_MACRO:
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_MACRO);
+                               
+                       case ICElement.C_NAMESPACE:
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_NAMESPACE);
+
+                       case ICElement.C_USING:
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_USING);
+
+                       case ICElement.ASM_LABEL:
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_LABEL);
+}
+               return null;
+       }
+
+       private boolean showOverlayIcons(int flags) {
+               return (flags & OVERLAY_ICONS) != 0;
+       }
+       
+//     private boolean useLightIcons(int flags) {
+//             return (flags & LIGHT_TYPE_ICONS) != 0;
+//     }
+       
+       private boolean useSmallSize(int flags) {
+               return (flags & SMALL_ICONS) != 0;
+       }
+       
+       /**
+        * Returns an image descriptor for a C element. The descriptor includes overlays, if specified.
+        */
+       public ImageDescriptor getCImageDescriptor(ICElement element, int flags) {
+               int adornmentFlags= computeCAdornmentFlags(element, flags);
+               Point size= useSmallSize(flags) ? SMALL_SIZE : BIG_SIZE;
+               ImageDescriptor desc = getBaseImageDescriptor(element, flags);
+               if(desc != null) {
+                       return new CElementImageDescriptor(desc, adornmentFlags, size);
+               }
+               return null;
+       }
+
+       /**
+        * Returns an image descriptor for a IAdaptable. The descriptor includes overlays, if specified (only error ticks apply).
+        * Returns <code>null</code> if no image could be found.
+        */     
+       public ImageDescriptor getWorkbenchImageDescriptor(IAdaptable adaptable, int flags) {
+               IWorkbenchAdapter wbAdapter= (IWorkbenchAdapter) adaptable.getAdapter(IWorkbenchAdapter.class);
+               if (wbAdapter == null) {
+                       return null;
+               }
+               ImageDescriptor descriptor= wbAdapter.getImageDescriptor(adaptable);
+               if (descriptor == null) {
+                       return null;
+               }
+               int adornmentFlags= computeBasicAdornmentFlags(adaptable, flags);
+               Point size= useSmallSize(flags) ? SMALL_SIZE : BIG_SIZE;
+               return new CElementImageDescriptor(descriptor, adornmentFlags, size);
+       }
+       
+       // ---- Computation of base image key -------------------------------------------------
+       
+       /**
+        * Returns an image descriptor for a C element. This is the base image, no overlays.
+        */
+       public ImageDescriptor getBaseImageDescriptor(ICElement celement, int renderFlags) {
+               // Allow contributed languages to provide icons for their extensions to the ICElement hierarchy
+               if (celement instanceof IContributedCElement)
+                   return (ImageDescriptor)((IContributedCElement)celement).getAdapter(ImageDescriptor.class);
+               
+               int type = celement.getElementType();
+               switch (type) {
+                       case ICElement.C_VCONTAINER:
+                               if (celement instanceof IBinaryModule) {
+                                       return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_BINARY);
+                               } else if (celement instanceof ILibraryReference) {
+                                       return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_UNKNOWN);
+                               } else if (celement instanceof IIncludeReference) {
+                                       return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER);
+                               } else if (celement instanceof IArchiveContainer) {
+                                       return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ARCHIVES_CONTAINER);
+                               } else if (celement instanceof IBinaryContainer) {
+                                       return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_BINARIES_CONTAINER);
+                               }
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CONTAINER);
+
+                       case ICElement.C_BINARY: {
+                               IBinary bin = (IBinary)celement;
+                               if (bin.isExecutable()) {
+                                       if (bin.hasDebug())
+                                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CEXEC_DEBUG);
+                                       return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CEXEC);
+                               } else if (bin.isSharedLib()) {
+                                       return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_SHLIB);
+                               } else if (bin.isCore()) {
+                                       return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CORE);
+                               }
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_BINARY);
+                       }
+       
+                       case ICElement.C_ARCHIVE:
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ARCHIVE);
+
+                       case ICElement.C_UNIT: {
+                               ITranslationUnit unit = (ITranslationUnit)celement;
+                               if (unit.isHeaderUnit()) {
+                                       return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT_HEADER);
+                               } else if (unit.isSourceUnit()) {
+                                       if (unit.isASMLanguage()) {
+                                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT_ASM);
+                                       }
+                               }
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT);
+                       }
+                               
+                       case ICElement.C_CCONTAINER:
+                               if (celement instanceof ISourceRoot) {
+                                       return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_SOURCE_ROOT);
+                               }
+                               //return DESC_OBJ_FOLDER;
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CFOLDER);
+                       
+                       case ICElement.C_PROJECT:
+                               ICProject cp= (ICProject)celement;
+                               if (cp.getProject().isOpen()) {
+                                       IProject project= cp.getProject();
+                                       IWorkbenchAdapter adapter= (IWorkbenchAdapter)project.getAdapter(IWorkbenchAdapter.class);
+                                       if (adapter != null) {
+                                               ImageDescriptor result= adapter.getImageDescriptor(project);
+                                               if (result != null)
+                                                       return result;
+                                       }
+                                       return DESC_OBJ_PROJECT;
+                               }
+                               return DESC_OBJ_PROJECT_CLOSED;
+
+                       case ICElement.C_STRUCT:
+                       case ICElement.C_TEMPLATE_STRUCT:
+                               return getStructImageDescriptor((renderFlags & LIGHT_TYPE_ICONS) != 0);
+                               
+                       case ICElement.C_CLASS:
+                       case ICElement.C_TEMPLATE_CLASS:
+                               return getClassImageDescriptor((renderFlags & LIGHT_TYPE_ICONS) != 0);
+                               
+                       case ICElement.C_UNION:
+                       case ICElement.C_TEMPLATE_UNION:
+                               return getUnionImageDescriptor((renderFlags & LIGHT_TYPE_ICONS) != 0);
+
+                       case ICElement.C_TYPEDEF:
+                               return getTypedefImageDescriptor((renderFlags & LIGHT_TYPE_ICONS) != 0);
+
+                       case ICElement.C_ENUMERATION:
+                               return getEnumerationImageDescriptor((renderFlags & LIGHT_TYPE_ICONS) != 0);
+
+                       case ICElement.C_ENUMERATOR:
+                               return getEnumeratorImageDescriptor();
+
+                       case ICElement.C_FIELD:
+                               try {
+                                       IField  field = (IField)celement;
+                                       ASTAccessVisibility visibility = field.getVisibility();
+                                       return getFieldImageDescriptor(visibility);
+                               } catch (CModelException e) {
+                                       return null;
+                               }
+                       
+                       case ICElement.C_METHOD:  
+                       case ICElement.C_METHOD_DECLARATION:
+                       case ICElement.C_TEMPLATE_METHOD:
+                       case ICElement.C_TEMPLATE_METHOD_DECLARATION:
+                               try {
+                                       IMethodDeclaration  md= (IMethodDeclaration)celement;
+                                       ASTAccessVisibility visibility =md.getVisibility();
+                                       return getMethodImageDescriptor(visibility); 
+                               } catch (CModelException e) {
+                                       return null;
+                               }
+                       case ICElement.C_VARIABLE:
+                       case ICElement.C_TEMPLATE_VARIABLE:
+                               return getVariableImageDescriptor();
+                               
+                       case ICElement.C_FUNCTION:
+                       case ICElement.C_TEMPLATE_FUNCTION:
+                               return getFunctionImageDescriptor();
+
+                       case ICElement.C_STRUCT_DECLARATION:
+                       case ICElement.C_CLASS_DECLARATION:
+                       case ICElement.C_UNION_DECLARATION:
+                       case ICElement.C_VARIABLE_DECLARATION:
+                       case ICElement.C_TEMPLATE_CLASS_DECLARATION:
+                       case ICElement.C_TEMPLATE_UNION_DECLARATION:
+                       case ICElement.C_TEMPLATE_STRUCT_DECLARATION:
+                               return getVariableDeclarationImageDescriptor();
+                       
+                       case ICElement.C_FUNCTION_DECLARATION:
+                       case ICElement.C_TEMPLATE_FUNCTION_DECLARATION:
+                               return getFunctionDeclarationImageDescriptor();
+
+                       case ICElement.C_INCLUDE:
+                               return getIncludeImageDescriptor();
+
+                       case ICElement.C_MACRO:
+                               return getMacroImageDescriptor();
+                               
+                       case ICElement.C_NAMESPACE:
+                               return getNamespaceImageDescriptor();
+
+                       case ICElement.C_USING:
+                               return getUsingImageDescriptor();
+
+                       default:
+                               return getImageDescriptor(type);
+               }
+       }       
+
+
+       // ---- Methods to compute the adornments flags ---------------------------------
+       
+       private int computeCAdornmentFlags(ICElement element, int renderFlags) {
+               
+               int flags= computeBasicAdornmentFlags(element, renderFlags);
+               if (showOverlayIcons(renderFlags)) {
+                       try {
+                               if (element instanceof IDeclaration) {
+                                       IDeclaration decl = (IDeclaration) element;
+                                       if(decl.isStatic()){
+                                               flags |= CElementImageDescriptor.STATIC;
+                                       }
+                                       if(decl.isConst()){
+                                               flags |= CElementImageDescriptor.CONSTANT;
+                                       }
+                                       if(decl.isVolatile()){
+                                               flags |= CElementImageDescriptor.VOLATILE;
+                                       }
+                                       if(element instanceof ITemplate){
+                                               flags |= CElementImageDescriptor.TEMPLATE;
+                                       }
+                               } 
+                               if (element instanceof ISourceReference) {
+                                       ISourceReference sref= (ISourceReference) element;
+                                       if (!sref.isActive()) {
+                                               flags |= CElementImageDescriptor.INACTIVE;
+                                       } else {
+                                               if (element instanceof IInclude) {
+                                                       IInclude include= (IInclude) element;
+                                                       if (!include.isResolved()) {
+                                                               flags |= CElementImageDescriptor.WARNING;
+                                                       }
+                                               }
+                                       }
+                               }
+                       } catch (CModelException e) {
+                       }
+               }
+               return flags;
+       }
+       
+       private int computeBasicAdornmentFlags(Object element, int renderFlags) {
+               int flags= 0;
+               if ((renderFlags & OVERLAY_ERROR) !=0) {
+                       flags |= CElementImageDescriptor.ERROR;
+               }
+               if ((renderFlags & OVERLAY_WARNING) !=0) {
+                       flags |= CElementImageDescriptor.WARNING;
+               }
+//             if ((renderFlags & OVERLAY_OVERRIDE) !=0) {
+//                     flags |= CElementImageDescriptor.OVERRIDES;
+//             }
+//             if ((renderFlags & OVERLAY_IMPLEMENTS) !=0) {
+//                     flags |= CElementImageDescriptor.IMPLEMENTS;
+//             }
+               if ((renderFlags & OVERLAY_EXTERNAL) != 0) {
+                       flags |= CElementImageDescriptor.EXTERNAL_FILE;
+               }
+               return flags;                   
+       }       
+       
+       public void dispose() {
+       }
+
+       public static ImageDescriptor getStructImageDescriptor(){
+               return getStructImageDescriptor(false);
+       }
+
+       public static ImageDescriptor getStructImageDescriptor(boolean alt){
+               return alt ? CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_STRUCT_ALT) : CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_STRUCT);     
+       }
+       
+       public static ImageDescriptor getClassImageDescriptor(){
+               return getClassImageDescriptor(false);
+       }
+
+       public static ImageDescriptor getClassImageDescriptor(boolean alt){
+               return alt ? CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CLASS_ALT) : CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CLASS);       
+       }
+
+       public static ImageDescriptor getUnionImageDescriptor(){
+               return getUnionImageDescriptor(false);
+       }
+
+       public static ImageDescriptor getUnionImageDescriptor(boolean alt){
+               return alt ? CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_UNION_ALT) : CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_UNION);       
+       }
+
+       public static ImageDescriptor getTypedefImageDescriptor(){
+               return getTypedefImageDescriptor(false);
+       }
+
+       public static ImageDescriptor getTypedefImageDescriptor(boolean alt){
+               return alt ? CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TYPEDEF_ALT) : CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TYPEDEF);   
+       }
+       
+       public static ImageDescriptor getEnumerationImageDescriptor(){
+               return getEnumerationImageDescriptor(false);
+       }
+
+       public static ImageDescriptor getEnumerationImageDescriptor(boolean alt){
+               return alt ? CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ENUMERATION_ALT) : CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ENUMERATION);   
+       }
+       
+       public static ImageDescriptor getEnumeratorImageDescriptor(){
+               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ENUMERATOR); 
+       }
+
+       public static ImageDescriptor getFieldImageDescriptor(ASTAccessVisibility visibility) {
+               if (visibility == ASTAccessVisibility.PUBLIC)
+                       return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_PUBLIC_FIELD);
+               if( visibility == ASTAccessVisibility.PROTECTED)
+                       return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_PROTECTED_FIELD);
+               
+               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_PRIVATE_FIELD);                      
+       }
+
+       public static ImageDescriptor getMethodImageDescriptor(ASTAccessVisibility visibility) {
+               if( visibility == ASTAccessVisibility.PUBLIC)
+                       return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_PUBLIC_METHOD);
+               if( visibility == ASTAccessVisibility.PROTECTED)
+                       return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_PROTECTED_METHOD);
+               
+               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_PRIVATE_METHOD);                             
+       }
+
+       public static ImageDescriptor getVariableImageDescriptor(){
+               return getImageDescriptor(ICElement.C_VARIABLE);
+       }
+
+       public static ImageDescriptor getLocalVariableImageDescriptor(){
+               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_LOCAL_VARIABLE);     
+       }
+       
+       public static ImageDescriptor getFunctionImageDescriptor(){
+               return getImageDescriptor(ICElement.C_FUNCTION);
+       }
+
+       public static ImageDescriptor getVariableDeclarationImageDescriptor(){
+               return getImageDescriptor(ICElement.C_VARIABLE_DECLARATION);
+       }
+
+       public static ImageDescriptor getFunctionDeclarationImageDescriptor(){
+               return getImageDescriptor(ICElement.C_FUNCTION_DECLARATION);
+       }
+
+       public static ImageDescriptor getIncludeImageDescriptor(){
+               return getImageDescriptor(ICElement.C_INCLUDE);
+       }
+
+       public static ImageDescriptor getMacroImageDescriptor(){
+               return getImageDescriptor(ICElement.C_MACRO);
+       }
+
+       public static ImageDescriptor getNamespaceImageDescriptor(){
+               return getImageDescriptor(ICElement.C_NAMESPACE);
+       }
+
+       public static ImageDescriptor getUsingImageDescriptor(){
+               return getImageDescriptor(ICElement.C_USING);
+       }
+
+       public static ImageDescriptor getKeywordImageDescriptor(){
+               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_KEYWORD);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabelComposer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabelComposer.java
new file mode 100644 (file)
index 0000000..27608bc
--- /dev/null
@@ -0,0 +1,979 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corp. - Rational Software - initial implementation
+ *     Markus Schorn (Wind River Systems)
+ *     Gerhard Schaber (Wind River Systems)
+ *     Patrick Hofer [bug 325799]
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.jface.viewers.StyledString.Styler;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.IBinary;
+import org.eclipse.cdt.core.model.ICContainer;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IEnumerator;
+import org.eclipse.cdt.core.model.IField;
+import org.eclipse.cdt.core.model.IFunctionDeclaration;
+import org.eclipse.cdt.core.model.IInheritance;
+import org.eclipse.cdt.core.model.IMacro;
+import org.eclipse.cdt.core.model.IMethodDeclaration;
+import org.eclipse.cdt.core.model.ISourceRoot;
+import org.eclipse.cdt.core.model.ITemplate;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.ITypeDef;
+import org.eclipse.cdt.core.model.IVariableDeclaration;
+import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.model.CoreModelMessages;
+
+
+// Most parts of this file were previously located in CElementLabels.
+// FlexibleBuffer and sub-types are taken from JDTs JavaElementLabelComposer.
+
+/**
+ * Creates labels for ICElement objects.
+ */
+public class CElementLabelComposer {
+
+       /**
+        * An adapter for buffer supported by the label composer.
+        */
+       public static abstract class FlexibleBuffer {
+
+               /**
+                * Appends the string representation of the given character to the buffer.
+                *
+                * @param ch the character to append
+                * @return a reference to this object
+                */
+               public abstract FlexibleBuffer append(char ch);
+
+               /**
+                * Appends the given string to the buffer.
+                *
+                * @param string the string to append
+                * @return a reference to this object
+                */
+               public abstract FlexibleBuffer append(String string);
+
+               /**
+                * Returns the length of the the buffer.
+                *
+                * @return the length of the current string
+                */
+               public abstract int length();
+
+               /**
+                * Sets a styler to use for the given source range. The range must be subrange of actual
+                * string of this buffer. Stylers previously set for that range will be overwritten.
+                *
+                * @param offset the start offset of the range
+                * @param length the length of the range
+                * @param styler the styler to set
+                *
+                * @throws StringIndexOutOfBoundsException if <code>start</code> is less than zero, or if
+                *             offset plus length is greater than the length of this object.
+                */
+               public abstract void setStyle(int offset, int length, Styler styler);
+       }
+
+       public static class FlexibleStringBuffer extends FlexibleBuffer {
+               private final StringBuffer fStringBuffer;
+
+               public FlexibleStringBuffer(StringBuffer stringBuffer) {
+                       fStringBuffer= stringBuffer;
+               }
+
+               @Override
+               public FlexibleBuffer append(char ch) {
+                       fStringBuffer.append(ch);
+                       return this;
+               }
+
+               @Override
+               public FlexibleBuffer append(String string) {
+                       fStringBuffer.append(string);
+                       return this;
+               }
+
+               @Override
+               public int length() {
+                       return fStringBuffer.length();
+               }
+
+               @Override
+               public void setStyle(int offset, int length, Styler styler) {
+                       // no style
+               }
+
+               @Override
+               public String toString() {
+                       return fStringBuffer.toString();
+               }
+       }
+
+       public static class FlexibleStyledString extends FlexibleBuffer {
+               private final StyledString fStyledString;
+
+               public FlexibleStyledString(StyledString stringBuffer) {
+                       fStyledString= stringBuffer;
+               }
+
+               @Override
+               public FlexibleBuffer append(char ch) {
+                       fStyledString.append(ch);
+                       return this;
+               }
+
+               @Override
+               public FlexibleBuffer append(String string) {
+                       fStyledString.append(string);
+                       return this;
+               }
+
+               @Override
+               public int length() {
+                       return fStyledString.length();
+               }
+
+               @Override
+               public void setStyle(int offset, int length, Styler styler) {
+                       fStyledString.setStyle(offset, length, styler);
+               }
+
+               @Override
+               public String toString() {
+                       return fStyledString.toString();
+               }
+       }
+       
+       
+       private static final Styler QUALIFIER_STYLE= StyledString.QUALIFIER_STYLER;
+       //private static final Styler COUNTER_STYLE= StyledString.COUNTER_STYLER;
+       private static final Styler DECORATIONS_STYLE= StyledString.DECORATIONS_STYLER;
+
+       
+       private final FlexibleBuffer fBuffer;
+
+       /**
+        * Creates a new java element composer based on the given buffer.
+        *
+        * @param buffer the buffer
+        */
+       public CElementLabelComposer(FlexibleBuffer buffer) {
+               fBuffer= buffer;
+       }
+
+       /**
+        * Creates a new java element composer based on the given buffer.
+        *
+        * @param buffer the buffer
+        */
+       public CElementLabelComposer(StyledString buffer) {
+               this(new FlexibleStyledString(buffer));
+       }
+
+       /**
+        * Creates a new java element composer based on the given buffer.
+        *
+        * @param buffer the buffer
+        */
+       public CElementLabelComposer(StringBuffer buffer) {
+               this(new FlexibleStringBuffer(buffer));
+       }
+       
+       
+       /**
+        * Appends the label for an element to a StringBuffer.
+        * @param element any element (IMethodDeclaration, IField, ITypeDef, IVariableDeclaration, etc.)
+        * @param flags any of the flags (M_*, F_*, ROOT_*, etc.) defined in this class
+        */
+       public void appendElementLabel(ICElement element, long flags) {
+               int type= element.getElementType();
+               ISourceRoot root= null;
+               
+               if (type != ICElement.C_MODEL && type != ICElement.C_PROJECT && !(type == ICElement.C_CCONTAINER && element instanceof ISourceRoot))
+                       root= getSourceRoot(element);
+               if (root != null && getFlag(flags, CElementLabels.PREPEND_ROOT_PATH)) {
+                       getSourceRootLabel(root, CElementLabels.ROOT_QUALIFIED);
+                       fBuffer.append(CElementLabels.CONCAT_STRING);
+               }               
+               switch (type) {
+                       case ICElement.C_MACRO:
+                               appendMacroLabel((IMacro) element, flags);
+                               break;
+                       case ICElement.C_METHOD : 
+                       case ICElement.C_METHOD_DECLARATION:
+                       case ICElement.C_TEMPLATE_METHOD:
+                       case ICElement.C_TEMPLATE_METHOD_DECLARATION:
+                               appendMethodLabel( (IMethodDeclaration) element, flags);
+                               break;
+                       case ICElement.C_FUNCTION:
+                       case ICElement.C_FUNCTION_DECLARATION:
+                       case ICElement.C_TEMPLATE_FUNCTION:
+                       case ICElement.C_TEMPLATE_FUNCTION_DECLARATION:
+                               appendFunctionLabel( (IFunctionDeclaration) element, flags);
+                               break;
+                       case ICElement.C_FIELD : 
+                               appendFieldLabel( (IField) element, flags);
+                               break;
+                       case ICElement.C_VARIABLE:
+                       case ICElement.C_VARIABLE_DECLARATION:
+                               appendVariableLabel( (IVariableDeclaration) element, flags);
+                               break;
+                       case ICElement.C_ENUMERATOR:
+                               appendEnumeratorLabel((IEnumerator) element, flags);
+                               break;
+                       case ICElement.C_CLASS:
+                       case ICElement.C_STRUCT:
+                       case ICElement.C_UNION:
+                       case ICElement.C_ENUMERATION:
+                       case ICElement.C_TEMPLATE_CLASS:
+                       case ICElement.C_TEMPLATE_STRUCT:
+                       case ICElement.C_TEMPLATE_UNION:
+                       case ICElement.C_TEMPLATE_CLASS_DECLARATION:
+                       case ICElement.C_TEMPLATE_STRUCT_DECLARATION:
+                       case ICElement.C_TEMPLATE_UNION_DECLARATION:
+                       case ICElement.C_NAMESPACE:
+                               appendTypeLabel( element, flags);
+                               break;
+                       case ICElement.C_TYPEDEF:
+                               appendTypeDefLabel((ITypeDef)element, flags);
+                               break;
+                       case ICElement.C_UNIT: 
+                               appendTranslationUnitLabel((ITranslationUnit) element, flags);
+                               break;  
+                       case ICElement.C_CCONTAINER:
+                               ICContainer container = (ICContainer) element;
+                               if (container instanceof ISourceRoot)
+                                       getSourceRootLabel((ISourceRoot) container, flags);
+                               else
+                                       appendContainerLabel(container, flags);
+                               break;
+                       case ICElement.C_PROJECT:
+                       case ICElement.C_MODEL:
+                               fBuffer.append(element.getElementName());
+                               break;
+                       default:
+                               fBuffer.append(element.getElementName());
+               }
+               
+               if (root != null && getFlag(flags, CElementLabels.APPEND_ROOT_PATH)) {
+                       int offset= fBuffer.length();
+                       fBuffer.append(CElementLabels.CONCAT_STRING);
+                       getSourceRootLabel(root, CElementLabels.ROOT_QUALIFIED);
+                       if (getFlag(flags, CElementLabels.COLORIZE)) {
+                               fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE);
+                       }
+               }
+               
+               if (element instanceof IBinary) {
+                       IBinary bin = (IBinary)element;
+                       fBuffer.append(" - [" + bin.getCPU() + "/" + (bin.isLittleEndian() ? "le" : "be") + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+               }
+       }
+       
+       
+       /**
+        * Appends the label for a macro definition to a StringBuffer.
+        * @param macro a macro definition
+        * @param flags {@link CElementLabels#MF_POST_FILE_QUALIFIED}, or 0.
+        */
+       public void appendMacroLabel(IMacro macro, long flags) {
+               fBuffer.append(macro.getElementName());
+               if( getFlag( flags, CElementLabels.M_PARAMETER_TYPES ) ) {
+                       if (macro.isFunctionStyle()) {
+                               fBuffer.append("()"); //$NON-NLS-1$
+                       }
+               }
+               
+               if( getFlag(flags, CElementLabels.MF_POST_FILE_QUALIFIED)) {
+                       IPath path= macro.getPath();
+                       if (path != null) {
+                               int offset= fBuffer.length();
+                               fBuffer.append( CElementLabels.CONCAT_STRING );
+                               fBuffer.append(path.toString());
+                               if (getFlag(flags, CElementLabels.COLORIZE)) {
+                                       fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE);
+                               }
+                       }
+               }
+       }
+
+       /**
+        * Appends the label for a method declaration to a StringBuffer.
+        * @param method a method declaration
+        * @param flags any of the M_* flags, and {@link CElementLabels#MF_POST_FILE_QUALIFIED}
+        */
+       public void appendMethodLabel( IMethodDeclaration method, long flags ) {
+               try {
+               //return type
+               if( getFlag( flags, CElementLabels.M_PRE_RETURNTYPE ) && method.exists() && !method.isConstructor() ) {
+                       fBuffer.append( method.getReturnType() );
+                       fBuffer.append( ' ' );
+               }
+               
+               //qualification
+               if( getFlag( flags, CElementLabels.M_FULLY_QUALIFIED ) ){
+                       ICElement parent = method.getParent();
+                       if (parent != null && parent.exists() && !(parent instanceof ITranslationUnit)) {
+                               appendTypeLabel( parent, CElementLabels.T_FULLY_QUALIFIED | (flags & CElementLabels.TEMPLATE_ARGUMENTS));
+                               fBuffer.append( "::" ); //$NON-NLS-1$
+                       }
+               }
+               
+               if (getFlag(flags, CElementLabels.M_SIMPLE_NAME)) {
+                       fBuffer.append(getSimpleName(method.getElementName()));
+               } else {
+                       fBuffer.append(method.getElementName());
+               }
+               
+               //template parameters
+               if (method instanceof ITemplate) {
+                       appendTemplateParameters((ITemplate)method, flags);
+               }
+
+               //parameters
+               if( getFlag( flags, CElementLabels.M_PARAMETER_TYPES ) ) {
+                       fBuffer.append('(');
+
+                       String[] types = method.getParameterTypes();
+                       
+                       if (types != null) {
+                               for (int i= 0; i < types.length; i++) {
+                                       if (i > 0) {
+                                               fBuffer.append( CElementLabels.COMMA_STRING );
+                                       }
+                                       fBuffer.append( types[i] );
+                               }
+                       }
+                       fBuffer.append(')');
+               }
+               
+               //exceptions
+               if( getFlag( flags, CElementLabels.M_EXCEPTIONS ) && method.exists() ){
+                       String [] types = method.getExceptions();
+                       if (types.length > 0) {
+                               fBuffer.append(" throw( "); //$NON-NLS-1$
+                               for (int i= 0; i < types.length; i++) {
+                                       if (i > 0) {
+                                               fBuffer.append(CElementLabels.COMMA_STRING);
+                                       }
+                                       fBuffer.append( types[i] );
+                               }
+                               fBuffer.append( " )" ); //$NON-NLS-1$
+                       }
+               }
+               
+               if( getFlag( flags, CElementLabels.M_APP_RETURNTYPE ) && method.exists() && !method.isConstructor() && !method.isDestructor()) {
+                       final String typeName= method.getReturnType();
+                       if (typeName != null && typeName.length() > 0) {
+                               int offset= fBuffer.length();
+                               fBuffer.append( CElementLabels.DECL_STRING );
+                               fBuffer.append(typeName);
+                               if (getFlag(flags, CElementLabels.COLORIZE)) {
+                                       fBuffer.setStyle(offset, fBuffer.length() - offset, DECORATIONS_STYLE);
+                               }
+                       }
+               }                       
+               
+               // post qualification
+               if( getFlag(flags, CElementLabels.M_POST_QUALIFIED)) {
+                       int offset= fBuffer.length();
+                       fBuffer.append( CElementLabels.CONCAT_STRING );
+                       appendTypeLabel( method.getParent(), CElementLabels.T_FULLY_QUALIFIED | (flags & CElementLabels.TEMPLATE_ARGUMENTS));
+                       if (getFlag(flags, CElementLabels.COLORIZE)) {
+                               fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE);
+                       }
+               }
+               if( getFlag(flags, CElementLabels.MF_POST_FILE_QUALIFIED)) {
+                       
+                       IPath path= method.getPath();
+                       if (path != null) {
+                               int offset= fBuffer.length();
+                               fBuffer.append( CElementLabels.CONCAT_STRING );
+                               fBuffer.append(path.toString());
+                               if (getFlag(flags, CElementLabels.COLORIZE)) {
+                                       fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE);
+                               }
+                       }
+                       
+               }
+               } catch (CModelException e) {
+                       CUIPlugin.log(e);
+               }
+       }
+
+       /**
+        * Strip any qualifier from the given name.
+        * 
+        * @param elementName
+        * @return a "simple" name
+        */
+       private static String getSimpleName(String elementName) {
+               int idx = elementName.lastIndexOf("::"); //$NON-NLS-1$
+               if (idx >= 0) {
+                       return elementName.substring(idx+2);
+               }
+               return elementName;
+       }
+
+       private void appendTemplateParameters(ITemplate template, long flags) {
+               String[] args= null;
+               if (getFlag(flags, CElementLabels.TEMPLATE_ARGUMENTS)) {
+                       args = template.getTemplateArguments();
+               } else if (getFlag(flags, CElementLabels.TEMPLATE_PARAMETERS)) {
+                       args= template.getTemplateParameterTypes();
+               } else {
+                       return;
+               }
+               
+               fBuffer.append('<');
+               if (args != null) {
+                       for (int i= 0; i < args.length; i++) {
+                               if (i > 0) {
+                                       fBuffer.append( ',' );
+                               }
+                               fBuffer.append( args[i] );
+                       }
+               }
+               fBuffer.append('>');
+       }
+
+       /**
+        * Appends the label for a field to a StringBuffer.
+        * @param field a field
+        * @param flags any of the F_* flags, and {@link CElementLabels#MF_POST_FILE_QUALIFIED}
+        */
+       public void appendFieldLabel(IField field, long flags ) {
+               try {
+               //return type
+               if( getFlag( flags, CElementLabels.F_PRE_TYPE_SIGNATURE ) && field.exists()) {
+                       fBuffer.append( field.getTypeName() );
+                       fBuffer.append( ' ' );
+               }
+               
+               //qualification
+               if( getFlag( flags, CElementLabels.F_FULLY_QUALIFIED ) ){
+                       ICElement parent = field.getParent();
+                       if (parent != null && parent.exists()) {
+                               appendTypeLabel( parent, CElementLabels.T_FULLY_QUALIFIED | (flags & CElementLabels.TEMPLATE_PARAMETERS));
+                               fBuffer.append( "::" ); //$NON-NLS-1$
+                       }
+               }
+               
+               if (getFlag(flags, CElementLabels.F_SIMPLE_NAME)) {
+                       fBuffer.append(getSimpleName(field.getElementName()));
+               } else {
+                       fBuffer.append(field.getElementName());
+               }
+                       
+               if( getFlag( flags, CElementLabels.F_APP_TYPE_SIGNATURE ) && field.exists()) {
+                       int offset= fBuffer.length();
+                       fBuffer.append( CElementLabels.DECL_STRING );
+                       fBuffer.append( field.getTypeName() );  
+                       if (getFlag(flags, CElementLabels.COLORIZE)) {
+                               fBuffer.setStyle(offset, fBuffer.length() - offset, DECORATIONS_STYLE);
+                       }
+               }       
+               
+               // post qualification
+               if( getFlag(flags, CElementLabels.F_POST_QUALIFIED)) {
+                       int offset= fBuffer.length();
+                       fBuffer.append( CElementLabels.CONCAT_STRING );
+                       appendTypeLabel( field.getParent(), CElementLabels.T_FULLY_QUALIFIED | (flags & CElementLabels.TEMPLATE_PARAMETERS));
+                       if (getFlag(flags, CElementLabels.COLORIZE)) {
+                               fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE);
+                       }
+               }
+               if( getFlag(flags, CElementLabels.MF_POST_FILE_QUALIFIED)) {
+                       IPath path= field.getPath();
+                       if (path != null) {
+                               int offset= fBuffer.length();
+                               fBuffer.append( CElementLabels.CONCAT_STRING );
+                               fBuffer.append(path.toString());
+                               if (getFlag(flags, CElementLabels.COLORIZE)) {
+                                       fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE);
+                               }
+                       }
+
+               }
+               } catch (CModelException e) {
+                       CUIPlugin.log(e);
+               }
+       }
+
+       /**
+        * Appends the label for a variable declaration to a StringBuffer.
+        * @param var a variable declaration
+        * @param flags any of the F_* flags, and {@link CElementLabels#MF_POST_FILE_QUALIFIED}
+        */
+       public void appendVariableLabel(IVariableDeclaration var, long flags ) {
+               try {
+               //return type
+               if( getFlag( flags, CElementLabels.F_PRE_TYPE_SIGNATURE ) && var.exists()) {
+                       fBuffer.append( var.getTypeName() );
+                       fBuffer.append( ' ' );
+               }
+               
+               //qualification
+               if( getFlag( flags, CElementLabels.F_FULLY_QUALIFIED ) ){
+                       ICElement parent = var.getParent();
+                       if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) {
+                               appendTypeLabel( parent, CElementLabels.T_FULLY_QUALIFIED);
+                               fBuffer.append( "::" ); //$NON-NLS-1$
+                       }
+               }
+               
+               fBuffer.append( var.getElementName() );
+               
+               if( getFlag( flags, CElementLabels.F_APP_TYPE_SIGNATURE ) && var.exists()) {
+                       int offset= fBuffer.length();
+                       fBuffer.append( CElementLabels.DECL_STRING );
+                       fBuffer.append( var.getTypeName() );    
+                       if (getFlag(flags, CElementLabels.COLORIZE)) {
+                               fBuffer.setStyle(offset, fBuffer.length() - offset, DECORATIONS_STYLE);
+                       }
+               }                       
+               
+               // post qualification
+               if( getFlag(flags, CElementLabels.F_POST_QUALIFIED)) {
+                       ICElement parent = var.getParent();
+                       if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) {
+                               int offset= fBuffer.length();
+                               fBuffer.append( CElementLabels.CONCAT_STRING );
+                               appendTypeLabel( var.getParent(), CElementLabels.T_FULLY_QUALIFIED);
+                               if (getFlag(flags, CElementLabels.COLORIZE)) {
+                                       fBuffer.setStyle(offset, fBuffer.length() - offset, DECORATIONS_STYLE);
+                               }
+                       }
+               }
+               if( getFlag(flags, CElementLabels.MF_POST_FILE_QUALIFIED)) {
+                       int offset= fBuffer.length();
+                       IPath path= var.getPath();
+                       if (path != null) {
+                               fBuffer.append( CElementLabels.CONCAT_STRING );
+                               fBuffer.append(path.toString());
+                       }
+                       if (getFlag(flags, CElementLabels.COLORIZE)) {
+                               fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE);
+                       }
+               }
+               } catch (CModelException e) {
+                       CUIPlugin.log(e);
+               }
+       }
+
+       /**
+        * Appends the label for an enumerator to a StringBuffer.
+        * @param var an enumerator
+        * @param flags any of the F_* flags, and {@link CElementLabels#MF_POST_FILE_QUALIFIED}
+        */
+       public void appendEnumeratorLabel(IEnumerator var, long flags ) {
+               //qualification
+               if( getFlag( flags, CElementLabels.F_FULLY_QUALIFIED ) ){
+                       ICElement parent = var.getParent();
+                       if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) {
+                               appendTypeLabel( parent, CElementLabels.T_FULLY_QUALIFIED);
+                               fBuffer.append( "::" ); //$NON-NLS-1$
+                       }
+               }
+               
+               fBuffer.append( var.getElementName() );
+                                               
+               // post qualification
+               if( getFlag(flags, CElementLabels.F_POST_QUALIFIED)) {
+                       ICElement parent = var.getParent();
+                       if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) {
+                               fBuffer.append( CElementLabels.CONCAT_STRING );
+                               appendTypeLabel( var.getParent(), CElementLabels.T_FULLY_QUALIFIED);
+                       }
+               }
+               if( getFlag(flags, CElementLabels.MF_POST_FILE_QUALIFIED)) {
+                       int offset= fBuffer.length();
+                       IPath path= var.getPath();
+                       if (path != null) {
+                               fBuffer.append( CElementLabels.CONCAT_STRING );
+                               fBuffer.append(path.toString());
+                       }
+                       if (getFlag(flags, CElementLabels.COLORIZE)) {
+                               fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE);
+                       }
+               }
+       }
+
+       /**
+        * Appends the label for a function declaration to a StringBuffer.
+        * @param func a function declaration
+        * @param flags any of the M_* flags, and {@link CElementLabels#MF_POST_FILE_QUALIFIED}
+        */
+       public void appendFunctionLabel(IFunctionDeclaration func, long flags) {
+               //return type
+               if( getFlag( flags, CElementLabels.M_PRE_RETURNTYPE ) && func.exists()) {
+                       fBuffer.append( func.getReturnType() );
+                       fBuffer.append( ' ' );
+               }
+               
+               //qualification
+               if( getFlag( flags, CElementLabels.M_FULLY_QUALIFIED ) ){
+                       ICElement parent = func.getParent();
+                       if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) {
+                               appendTypeLabel( parent, CElementLabels.T_FULLY_QUALIFIED);
+                               fBuffer.append( "::" ); //$NON-NLS-1$
+                       }
+               }
+               
+               fBuffer.append( func.getElementName() );
+
+               //template parameters
+               if (func instanceof ITemplate) {
+                       appendTemplateParameters((ITemplate)func, flags);
+               }
+
+               //parameters
+               if( getFlag( flags, CElementLabels.M_PARAMETER_TYPES ) ) {
+                       fBuffer.append('(');
+
+                       String[] types = func.getParameterTypes();
+                       
+                       if (types != null) {
+                               for (int i= 0; i < types.length; i++) {
+                                       if (i > 0) {
+                                               fBuffer.append( CElementLabels.COMMA_STRING );
+                                       }
+                                       fBuffer.append( types[i] );
+                               }
+                       }
+                       fBuffer.append(')');
+               }
+               
+               //exceptions
+               if( getFlag( flags, CElementLabels.M_EXCEPTIONS ) && func.exists() ){
+                       String [] types = func.getExceptions();
+                       if (types.length > 0) {
+                               fBuffer.append(" throw( "); //$NON-NLS-1$
+                               for (int i= 0; i < types.length; i++) {
+                                       if (i > 0) {
+                                               fBuffer.append(CElementLabels.COMMA_STRING);
+                                       }
+                                       fBuffer.append( types[i] );
+                               }
+                               fBuffer.append( " )" ); //$NON-NLS-1$
+                       }
+               }
+               
+               if( getFlag( flags, CElementLabels.M_APP_RETURNTYPE ) && func.exists()) {
+                       final String typeName= func.getReturnType();
+                       if (typeName != null && typeName.length() > 0) {
+                               int offset= fBuffer.length();
+                               fBuffer.append( CElementLabels.DECL_STRING );
+                               fBuffer.append(typeName);
+                               if (getFlag(flags, CElementLabels.COLORIZE)) {
+                                       fBuffer.setStyle(offset, fBuffer.length() - offset, DECORATIONS_STYLE);
+                               }
+                       }
+               }                       
+               
+               // post qualification
+               if( getFlag(flags, CElementLabels.M_POST_QUALIFIED)) {
+                       ICElement parent = func.getParent();
+                       if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) {
+                               fBuffer.append( CElementLabels.CONCAT_STRING );
+                               appendTypeLabel( func.getParent(), CElementLabels.T_FULLY_QUALIFIED);
+                       }
+               }
+               if( getFlag(flags, CElementLabels.MF_POST_FILE_QUALIFIED)) {
+                       IPath path= func.getPath();
+                       if (path != null) {
+                               int offset= fBuffer.length();
+                               fBuffer.append( CElementLabels.CONCAT_STRING );
+                               fBuffer.append(path.toString());
+                               if (getFlag(flags, CElementLabels.COLORIZE)) {
+                                       fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE);
+                               }
+                       }
+               }
+       }
+
+       /**
+        * Appends the label for a type definition to a StringBuffer.
+        * @param typedef a type definition
+        * @param flags any of the F_* flags, and CElementLabels.MF_POST_FILE_QUALIFIED
+        */
+       public void appendTypeDefLabel(ITypeDef typedef, long flags ) {
+               // type
+               if( getFlag( flags, CElementLabels.F_PRE_TYPE_SIGNATURE ) && typedef.exists()) {
+                       fBuffer.append( typedef.getTypeName() );
+                       fBuffer.append( ' ' );
+               }
+               
+               //qualification
+               if( getFlag( flags, CElementLabels.F_FULLY_QUALIFIED ) ){
+                       ICElement parent = typedef.getParent();
+                       if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) {
+                               appendTypeLabel( parent, CElementLabels.T_FULLY_QUALIFIED);
+                               fBuffer.append( "::" ); //$NON-NLS-1$
+                       }
+               }
+               
+               fBuffer.append( typedef.getElementName() );
+                               
+               if( getFlag( flags, CElementLabels.F_APP_TYPE_SIGNATURE ) && typedef.exists()) {
+                       String typeName= typedef.getTypeName();
+                       if (typeName != null && typeName.length() > 0) {
+                               int offset= fBuffer.length();
+                               fBuffer.append( CElementLabels.DECL_STRING );
+                               fBuffer.append(typeName);
+                               if (getFlag(flags, CElementLabels.COLORIZE)) {
+                                       fBuffer.setStyle(offset, fBuffer.length() - offset, DECORATIONS_STYLE);
+                               }
+                       }
+               }                       
+               
+               // post qualification
+               if( getFlag(flags, CElementLabels.F_POST_QUALIFIED)) {
+                       ICElement parent = typedef.getParent();
+                       if (parent != null && parent.exists() && parent.getElementType() == ICElement.C_NAMESPACE) {
+                               fBuffer.append( CElementLabels.CONCAT_STRING );
+                               appendTypeLabel( typedef.getParent(), CElementLabels.T_FULLY_QUALIFIED);
+                       }
+               }
+               if( getFlag(flags, CElementLabels.MF_POST_FILE_QUALIFIED)) {
+                       IPath path= typedef.getPath();
+                       if (path != null) {
+                               int offset= fBuffer.length();
+                               fBuffer.append( CElementLabels.CONCAT_STRING );
+                               fBuffer.append(path.toString());
+                               if (getFlag(flags, CElementLabels.COLORIZE)) {
+                                       fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE);
+                               }
+                       }
+               }
+       }
+
+       /**
+        * Appends the label for a source root to a StringBuffer.
+        * @param root a source root
+        * @param flags any of the ROOT_* flags, and PROJECT_POST_QUALIFIED
+        */
+       public void getSourceRootLabel(ISourceRoot root, long flags) {
+               appendFolderLabel(root, flags);
+       }
+       
+       /**
+        * Appends the label for a container to a StringBuffer.
+        * @param container a container
+        * @param flags any of the ROOT_* flags, and PROJECT_POST_QUALIFIED
+        */
+       public void appendContainerLabel(ICContainer container, long flags) {
+               appendFolderLabel(container, flags);
+       }
+
+       private void appendFolderLabel(ICContainer container, long flags) {
+               IResource resource= container.getResource();
+               boolean rootQualified= getFlag(flags, CElementLabels.ROOT_QUALIFIED);
+               if (rootQualified) {
+                       fBuffer.append(container.getPath().makeRelative().toString());
+               } else {
+                       if (CCorePlugin.showSourceRootsAtTopOfProject()) {
+                               fBuffer.append(container.getElementName());
+                       }
+                       else {
+                               String elementName = container.getElementName();
+                               IPath path = new Path(elementName);
+                               fBuffer.append(path.lastSegment());
+                       }
+                       if (getFlag(flags, CElementLabels.ROOT_QUALIFIED)) {
+                               if (resource != null && container instanceof ISourceRoot && isReferenced((ISourceRoot)container)) {
+                                       fBuffer.append(CElementLabels.CONCAT_STRING);
+                                       fBuffer.append(resource.getProject().getName());
+                               } else {
+                                       fBuffer.append(CElementLabels.CONCAT_STRING);
+                                       fBuffer.append(container.getParent().getElementName());
+                               }
+                       }
+               }
+       }
+
+       /**
+        * Appends the label for a translation unit to a StringBuffer.
+        * @param tu a translation unit
+        * @param flags any of the TU_* flags
+        */
+       public  void appendTranslationUnitLabel(ITranslationUnit tu, long flags) {
+               IResource r= tu.getResource();
+               IPath path;
+               if (r != null) {
+                       path= r.getFullPath().makeRelative();
+               }
+               else {
+                       path= tu.getPath();
+               }
+               
+               if (path == null) {
+                       fBuffer.append(tu.getElementName());
+               }
+               else {
+                       if (getFlag(flags, CElementLabels.TU_QUALIFIED)) {
+                               fBuffer.append(path.toString());
+                       }
+                       else if (getFlag(flags, CElementLabels.TU_POST_QUALIFIED)) {
+                               fBuffer.append(path.lastSegment());
+                               fBuffer.append(CElementLabels.CONCAT_STRING);
+                               fBuffer.append(path.removeLastSegments(1).toString());
+                       }
+                       else {
+                               fBuffer.append(path.lastSegment());
+                       }
+               }
+       }
+
+       /**
+        * Appends the label for a type to a StringBuffer.
+        * @param elem a type
+        * @param flags any of the T_* flags, and {@link CElementLabels#MF_POST_FILE_QUALIFIED}
+        */
+       private void appendTypeLabel(ICElement elem, long flags) {
+               if (getFlag(flags, CElementLabels.T_FULLY_QUALIFIED)) {
+                       ICElement parent= elem.getParent();
+                       boolean isQualifier= true;
+                       if (parent != null) {
+                               switch (parent.getElementType()) {
+                               case ICElement.C_ARCHIVE:
+                               case ICElement.C_BINARY:
+                               case ICElement.C_CCONTAINER:
+                               case ICElement.C_MODEL:
+                               case ICElement.C_PROJECT:
+                               case ICElement.C_UNIT:
+                               case ICElement.C_VCONTAINER:
+                                       isQualifier= false;
+                                       break;
+                               }
+                       }
+                       // types cannot be qualified in plain c
+                       if (isQualifier && !isCLanguage(parent)) {
+                               long qflags= flags & ~CElementLabels.MF_POST_FILE_QUALIFIED;
+                               appendTypeLabel(parent, qflags);
+                               fBuffer.append("::"); //$NON-NLS-1$
+                       }
+               }
+               
+               String typeName= elem.getElementName();
+               if (typeName.length() == 0) { // anonymous
+                   typeName = CoreModelMessages.getString("CElementLabels.anonymous"); //$NON-NLS-1$
+               }
+               fBuffer.append(typeName);
+
+               if (getFlag(flags, CElementLabels.T_INHERITANCE) && elem instanceof IInheritance) {
+                       IInheritance inheritance= (IInheritance)elem;
+                       String[] superclassNames= inheritance.getSuperClassesNames();
+                       if (superclassNames != null && superclassNames.length > 0) {
+                               fBuffer.append(CElementLabels.DECL_STRING);
+                               for (int i = 0; i < superclassNames.length; i++) {
+                                       if (i> 0) {
+                                               fBuffer.append(CElementLabels.COMMA_STRING);
+                                       }
+                                       String superclass = superclassNames[i];
+                                       String visibility = getVisibility(inheritance.getSuperClassAccess(superclass));
+                                       fBuffer.append(visibility).append(' ').append(superclass);
+                               }
+                       }
+               }
+
+               //template parameters
+               if (elem instanceof ITemplate) {
+                       appendTemplateParameters((ITemplate)elem, flags);
+               }
+               
+               if( getFlag(flags, CElementLabels.MF_POST_FILE_QUALIFIED)) {
+                       IPath path= elem.getPath();
+                       if (path != null) {
+                               int offset= fBuffer.length();
+                               fBuffer.append( CElementLabels.CONCAT_STRING );
+                               fBuffer.append(path.toString());
+                               if (getFlag(flags, CElementLabels.COLORIZE)) {
+                                       fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE);
+                               }
+                       }
+               }
+       }
+       
+       private static boolean isCLanguage(ICElement elem) {
+               while (elem != null) {
+                       elem= elem.getParent();
+                       if (elem instanceof ITranslationUnit) {
+                                return ((ITranslationUnit) elem).isCLanguage();
+                       }
+               }
+               return false;
+       }
+
+       /**
+        * Convert an <code>ASTAccessVisibility</code> into its string representation.
+        * 
+        * @param access
+        * @return "public", "protected" or "private"
+        */
+       private static String getVisibility(ASTAccessVisibility access) {
+               if (access == ASTAccessVisibility.PUBLIC) {
+                       return "public"; //$NON-NLS-1$
+               }
+               if (access == ASTAccessVisibility.PROTECTED) {
+                       return "protected"; //$NON-NLS-1$
+               }
+               return "private"; //$NON-NLS-1$
+       }
+
+       private static boolean getFlag(long flags, long flag) {
+               return (flags & flag) != 0;
+       }
+
+
+       /**
+        * Returns the source root of <code>ICElement</code>. If the given
+        * element is already a source root, the element itself is returned.
+        */
+       public static ISourceRoot getSourceRoot(ICElement element) {
+               ICElement root = element;
+               while (root != null) {
+                       if (root instanceof ISourceRoot)
+                               return (ISourceRoot)root;
+                       ICElement parent = root.getAncestor(ICElement.C_CCONTAINER);
+                       if (parent == root)
+                               return null;
+                       root = parent;
+               }
+               return null;
+       }
+       
+       /**
+        * Returns <code>true</code> if the given source root is
+        * referenced. This means it is own by a different project but is referenced
+        * by the root's parent. Returns <code>false</code> if the given root
+        * doesn't have an underlying resource.
+        */
+       public static boolean isReferenced(ISourceRoot root) {
+               IResource resource= root.getResource();
+               if (resource != null) {
+                       IProject project= resource.getProject();
+                       IProject container= root.getCProject().getProject();
+                       return !container.equals(project);
+               }
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabels.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabels.java
new file mode 100644 (file)
index 0000000..13655c3
--- /dev/null
@@ -0,0 +1,515 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corp. - Rational Software - initial implementation
+ *     Markus Schorn (Wind River Systems)
+ *     Patrick Hofer [bug 325799]
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.osgi.util.TextProcessor;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IEnumerator;
+import org.eclipse.cdt.core.model.IField;
+import org.eclipse.cdt.core.model.IFunctionDeclaration;
+import org.eclipse.cdt.core.model.IMacro;
+import org.eclipse.cdt.core.model.IMethodDeclaration;
+import org.eclipse.cdt.core.model.ITypeDef;
+import org.eclipse.cdt.core.model.IVariableDeclaration;
+
+import org.eclipse.cdt.internal.core.model.CElement;
+import org.eclipse.cdt.internal.core.model.CoreModelMessages;
+import org.eclipse.cdt.internal.corext.util.Strings;
+
+/*
+ * This class is basically a clone of org.eclipse.cdt.core.model.util.CElementLabels 
+ * (refer to bug 325799 for the reasoning)
+ */
+
+/**
+ * Computes labels for objects of type {@link CElement}.
+ */
+public class CElementLabels {
+       /**
+        * Method names contain parameter types.
+        * e.g. <code>foo(int)</code>
+        */
+       public final static long M_PARAMETER_TYPES= 1L << 0;
+
+       /**
+        * Method definition names without qualifier.
+        * e.g. <code>foo(int)</code>
+        */
+       public final static long M_SIMPLE_NAME= 1L << 1;
+
+       /**
+        * Method names contain thrown exceptions.
+        * e.g. <code>foo throw( IOException )</code>
+        */
+       public final static long M_EXCEPTIONS= 1L << 2;
+       
+       /**
+        * Method names contain return type (appended)
+        * e.g. <code>foo : int</code>
+        */
+       public final static long M_APP_RETURNTYPE= 1L << 3;
+
+       /**
+        * Method names contain return type (appended)
+        * e.g. <code>int foo</code>
+        */
+       public final static long M_PRE_RETURNTYPE= 1L << 4;     
+
+       /**
+        * Method names are fully qualified.
+        * e.g. <code>ClassName::size</code>
+        */
+       public final static long M_FULLY_QUALIFIED= 1L << 5;
+
+       /**
+        * Method names are post qualified.
+        * e.g. <code>size - ClassName</code>
+        */
+       public final static long M_POST_QUALIFIED= 1L << 6;
+
+       /**
+        * Templates are qualified with template parameters.
+        * e.g. <code>ClassName<T></code>
+        */
+       public final static long TEMPLATE_PARAMETERS= 1L << 7;
+
+       /**
+        * Static field names without qualifier.
+        * e.g. <code>fHello</code>
+        */
+       public final static long F_SIMPLE_NAME= 1L << 8;
+
+       /**
+        * Field names contain the declared type (appended)
+        * e.g. <code>fHello: int</code>
+        */
+       public final static long F_APP_TYPE_SIGNATURE= 1L << 9;
+
+       /**
+        * Field names contain the declared type (prepended)
+        * e.g. <code>int fHello</code>
+        */
+       public final static long F_PRE_TYPE_SIGNATURE= 1L << 10;        
+
+       /**
+        * Fields names are fully qualified.
+        * e.g. <code>ClassName::fField</code>
+        */
+       public final static long F_FULLY_QUALIFIED= 1L << 11;
+
+       /**
+        * Fields names are post qualified.
+        * e.g. <code>fField - ClassName</code>
+        */
+       public final static long F_POST_QUALIFIED= 1L << 12;    
+
+       /**
+        * Type names are fully qualified.
+        * e.g. <code>namespace::ClassName</code>
+        */
+       public final static long T_FULLY_QUALIFIED= 1L << 13;
+
+       /**
+        * Instances and specializations are qualified with arguments, templates with template parameter names.
+        * The flag overrides {@link #TEMPLATE_PARAMETERS}.
+        */
+       public final static long TEMPLATE_ARGUMENTS= 1L << 14;
+
+       /**
+        * Append base class specifications to type names.
+        * e.g. <code>MyClass : public BaseClass</code>
+        */
+       public final static long T_INHERITANCE= 1L << 16;
+
+       /**
+        * Translation unit names contain the full path.
+        * e.g. <code>/MyProject/src/ClassName.cpp</code>
+        */     
+       public final static long TU_QUALIFIED= 1L << 20;
+
+       /**
+        * Translation unit names are post qualified with their path.
+        * e.g. <code>ClassName.cpp - /MyProject/src</code>
+        */     
+       public final static long TU_POST_QUALIFIED= 1L << 21;
+
+       /**
+        * Source roots contain the project name (prepended).
+        * e.g. <code>MyProject/src</code>
+        */
+       public final static long ROOT_QUALIFIED= 1L << 25;
+
+       /**
+        * Source roots contain the project name (appended).
+        * e.g. <code>src - MyProject</code>
+        */
+       public final static long ROOT_POST_QUALIFIED= 1L << 26; 
+
+       /**
+        * Add source root path.
+        * e.g. <code>func() - MyProject/src</code>
+        * Option only applies to getElementLabel
+        */
+       public final static long APPEND_ROOT_PATH= 1L << 27;
+
+       /**
+        * Prepend source root path.
+        * e.g. <code>MyProject/src - func()</code>
+        * Option only applies to getElementLabel
+        */
+       public final static long PREPEND_ROOT_PATH= 1L << 28;
+
+       /**
+        * Post qualify container project. For example
+        * <code>folder - MyProject</code> if the folder is in project MyProject.
+        */
+       public final static long PROJECT_POST_QUALIFIED= 1L << 30; 
+
+       /**
+        * Post qualify symbols with file. 
+        * e.g. <code>func() - /proj/folder/file.cpp</code> 
+        */
+       public final static long MF_POST_FILE_QUALIFIED= 1L << 31;
+
+       /**
+        * Specifies to apply color styles to labels. This flag only applies to methods taking or returning a {@link StyledString}.
+        */
+       public final static long COLORIZE= 1L << 32;
+       
+       /**
+        * Qualify all elements
+        */
+       public final static long ALL_FULLY_QUALIFIED= F_FULLY_QUALIFIED | M_FULLY_QUALIFIED | T_FULLY_QUALIFIED | TU_QUALIFIED | ROOT_QUALIFIED;
+
+       /**
+        * Post qualify all elements
+        */
+       public final static long ALL_POST_QUALIFIED= F_POST_QUALIFIED | M_POST_QUALIFIED  | TU_POST_QUALIFIED | ROOT_POST_QUALIFIED;
+
+       /**
+        *  Default options (M_PARAMETER_TYPES enabled)
+        */
+       public final static long ALL_DEFAULT= M_PARAMETER_TYPES;
+
+       /**
+        *  Default qualify options (All except Root)
+        */
+       public final static long DEFAULT_QUALIFIED= F_FULLY_QUALIFIED | M_FULLY_QUALIFIED | T_FULLY_QUALIFIED | TU_QUALIFIED;
+
+       /**
+        *  Default post qualify options (All except Root)
+        */
+       public final static long DEFAULT_POST_QUALIFIED= F_POST_QUALIFIED | M_POST_QUALIFIED | TU_POST_QUALIFIED;
+
+       /**
+        * Separator for appending qualifiers
+        */
+       public final static String CONCAT_STRING= CoreModelMessages.getString("CElementLabels.concat_string"); // " - "; //$NON-NLS-1$
+       
+       /**
+        * Separator for parameters, base classes, exceptions, etc.
+        */
+       public final static String COMMA_STRING = CoreModelMessages.getString("CElementLabels.comma_string"); // ", "; //$NON-NLS-1$
+       
+       /**
+        * Separator for appending (return) type
+        */
+       public final static String DECL_STRING  = CoreModelMessages.getString("CElementLabels.declseparator_string"); // "  "; // use for return type //$NON-NLS-1$
+
+       
+       
+       //====================
+       
+       
+       private CElementLabels() {
+       }
+
+       /**
+        * Returns the label of the given object. The object must be of type {@link ICElement} or adapt to {@link IWorkbenchAdapter}.
+        * If the element type is not known, the empty string is returned.
+        * The returned label is BiDi-processed with {@link TextProcessor#process(String, String)}.
+        *
+        * @param obj object to get the label for
+        * @param flags the rendering flags
+        * @return the label or the empty string if the object type is not supported
+        */
+       public static String getTextLabel(Object obj, long flags) {
+               if (obj instanceof ICElement) {
+                       return getElementLabel((ICElement) obj, flags);
+
+               } else if (obj instanceof IResource) {
+                       return BasicElementLabels.getResourceName((IResource) obj);
+
+               } else if (obj instanceof IStorage) {
+                       return BasicElementLabels.getResourceName(((IStorage) obj).getName());
+
+               } else if (obj instanceof IAdaptable) {
+                       IWorkbenchAdapter wbadapter= (IWorkbenchAdapter) ((IAdaptable)obj).getAdapter(IWorkbenchAdapter.class);
+                       if (wbadapter != null) {
+                               return Strings.markLTR(wbadapter.getLabel(obj));
+                       }
+               }
+               return ""; //$NON-NLS-1$
+       }
+
+       /**
+        * Returns the styled label of the given object. The object must be of type {@link ICElement} or adapt to {@link IWorkbenchAdapter}.
+        * If the element type is not known, the empty string is returned.
+        * The returned label is BiDi-processed with {@link TextProcessor#process(String, String)}.
+        *
+        * @param obj object to get the label for
+        * @param flags the rendering flags
+        * @return the label or the empty string if the object type is not supported
+        */
+       public static StyledString getStyledTextLabel(Object obj, long flags) {
+               if (obj instanceof ICElement) {
+                       return getStyledElementLabel((ICElement) obj, flags);
+
+               } else if (obj instanceof IResource) {
+                       return getStyledResourceLabel((IResource) obj);
+
+               } else if (obj instanceof IStorage) {
+                       return getStyledStorageLabel((IStorage) obj);
+
+               } else if (obj instanceof IAdaptable) {
+                       IWorkbenchAdapter wbadapter= (IWorkbenchAdapter) ((IAdaptable)obj).getAdapter(IWorkbenchAdapter.class);
+                       if (wbadapter != null) {
+                               return Strings.markLTR(new StyledString(wbadapter.getLabel(obj)));
+                       }
+               }
+               return new StyledString();
+       }
+
+       /**
+        * Returns the styled string for the given resource.
+        * The returned label is BiDi-processed with {@link TextProcessor#process(String, String)}.
+        *
+        * @param resource the resource
+        * @return the styled string
+        */
+       private static StyledString getStyledResourceLabel(IResource resource) {
+               StyledString result= new StyledString(resource.getName());
+               return Strings.markLTR(result);
+       }
+
+       /**
+        * Returns the styled string for the given storage.
+        * The returned label is BiDi-processed with {@link TextProcessor#process(String, String)}.
+        *
+        * @param storage the storage
+        * @return the styled string
+        */
+       private static StyledString getStyledStorageLabel(IStorage storage) {
+               StyledString result= new StyledString(storage.getName());
+               return Strings.markLTR(result);
+       }
+
+
+       /**
+        * Returns the label for a Java element with the flags as defined by this class.
+        *
+        * @param element the element to render
+        * @param flags the rendering flags
+        * @return the label of the Java element
+        */
+       public static String getElementLabel(ICElement element, long flags) {
+               StringBuffer result= new StringBuffer();
+               getElementLabel(element, flags, result);
+               return Strings.markCElementLabelLTR(result.toString());
+       }
+
+       /**
+        * Returns the styled label for a Java element with the flags as defined by this class.
+        *
+        * @param element the element to render
+        * @param flags the rendering flags
+        * @return the label of the Java element
+        *
+        */
+       public static StyledString getStyledElementLabel(ICElement element, long flags) {
+               StyledString result= new StyledString();
+               getElementLabel(element, flags, result);
+               return Strings.markCElementLabelLTR(result);
+       }
+
+       /**
+        * Returns the label for a Java element with the flags as defined by this class.
+        *
+        * @param element the element to render
+        * @param flags the rendering flags
+        * @param buf the buffer to append the resulting label to
+        */
+       public static void getElementLabel(ICElement element, long flags, StringBuffer buf) {
+               new CElementLabelComposer(buf).appendElementLabel(element, flags);
+       }
+
+       /**
+        * Returns the styled label for a Java element with the flags as defined by this class.
+        *
+        * @param element the element to render
+        * @param flags the rendering flags
+        * @param result the buffer to append the resulting label to
+        */
+       public static void getElementLabel(ICElement element, long flags, StyledString result) {
+               new CElementLabelComposer(result).appendElementLabel(element, flags);
+       }
+       
+       /**
+        * Appends the label for a macro definition to a StringBuffer.
+        * @param macro a macro definition
+        * @param flags {@link #MF_POST_FILE_QUALIFIED}, or 0.
+        * @param buf the buffer to append the label to.
+        */
+       public static void getMacroLabel(IMacro macro, int flags, StringBuffer buf) {
+               new CElementLabelComposer(buf).appendMacroLabel(macro, flags);
+       }
+
+       /**
+        * Appends the label for a macro to a {@link StyledString}. Considers the M_* flags.
+        *
+        * @param macro the element to render
+        * @param flags the rendering flags. Flags with names starting with 'M_' are considered.
+        * @param result the buffer to append the resulting label to
+        */
+       public static void getMethodLabel(IMacro macro, long flags, StyledString result) {
+               new CElementLabelComposer(result).appendMacroLabel(macro, flags);
+       }
+       
+       /**
+        * Appends the label for a method declaration to a StringBuffer.
+        * @param method a method declaration
+        * @param flags any of the M_* flags, and MF_POST_FILE_QUALIFIED
+        * @param buf the buffer to append the label
+        */
+       public static void getMethodLabel( IMethodDeclaration method, int flags, StringBuffer buf ) {
+               new CElementLabelComposer(buf).appendMethodLabel(method, flags);
+       }
+
+       /**
+        * Appends the label for a macro to a {@link StyledString}. Considers the M_* flags.
+        *
+        * @param method the element to render
+        * @param flags the rendering flags. Flags with names starting with 'M_' are considered.
+        * @param result the buffer to append the resulting label to
+        */
+       public static void getMethodLabel(IMethodDeclaration method, long flags, StyledString result) {
+               new CElementLabelComposer(result).appendMethodLabel(method, flags);
+       }
+       
+       /**
+        * Appends the label for a field to a StringBuffer.
+        * @param field a field
+        * @param flags any of the F_* flags, and MF_POST_FILE_QUALIFIED
+        * @param buf the buffer to append the label
+        */
+       public static void getFieldLabel(IField field, int flags, StringBuffer buf ) {
+               new CElementLabelComposer(buf).appendFieldLabel(field, flags);  
+       }
+
+       /**
+        * Appends the label for a field to a {@link StyledString}.
+        * @param field a field
+        * @param flags any of the F_* flags, and MF_POST_FILE_QUALIFIED
+        * @param result the buffer to append the label
+        */
+       public static void getFieldLabel(IField field, int flags, StyledString result ) {
+               new CElementLabelComposer(result).appendFieldLabel(field, flags);       
+       }
+
+       /**
+        * Appends the label for a variable declaration to a StringBuffer.
+        * @param var a variable declaration
+        * @param flags any of the F_* flags, and MF_POST_FILE_QUALIFIED
+        * @param buf the buffer to append the label
+        */
+       public static void getVariableLabel(IVariableDeclaration var, int flags, StringBuffer buf ) {
+               new CElementLabelComposer(buf).appendVariableLabel(var, flags); 
+       }
+
+       /**
+        * Appends the label for a variable declaration to a {@link StyledString}.
+        * @param var a variable declaration
+        * @param flags any of the F_* flags, and MF_POST_FILE_QUALIFIED
+        * @param result the buffer to append the label
+        */
+       public static void getVariableLabel(IVariableDeclaration var, int flags, StyledString result ) {
+               new CElementLabelComposer(result).appendVariableLabel(var, flags);      
+       }
+
+       /**
+        * Appends the label for an enumerator to a StringBuffer.
+        * @param var an enumerator
+        * @param flags any of the F_* flags, and MF_POST_FILE_QUALIFIED
+        * @param buf the buffer to append the label
+        */
+       public static void getEnumeratorLabel(IEnumerator var, int flags, StringBuffer buf ) {
+               new CElementLabelComposer(buf).appendEnumeratorLabel(var, flags);       
+       }
+
+       /**
+        * Appends the label for an enumerator to a {@link StyledString}.
+        * @param var an enumerator
+        * @param flags any of the F_* flags, and MF_POST_FILE_QUALIFIED
+        * @param result the buffer to append the label
+        */
+       public static void getEnumeratorLabel(IEnumerator var, int flags, StyledString result ) {
+               new CElementLabelComposer(result).appendEnumeratorLabel(var, flags);    
+       }
+
+       /**
+        * Appends the label for a function declaration to a StringBuffer.
+        * @param func a function declaration
+        * @param flags any of the M_* flags, and MF_POST_FILE_QUALIFIED
+        * @param buf the buffer to append the label
+        */
+       public static void getFunctionLabel(IFunctionDeclaration func, int flags, StringBuffer buf) {
+               new CElementLabelComposer(buf).appendFunctionLabel(func, flags);        
+       }
+
+       /**
+        * Appends the label for a function declaration to a {@link StyledString}.
+        * @param func a function declaration
+        * @param flags any of the M_* flags, and MF_POST_FILE_QUALIFIED
+        * @param result the buffer to append the label
+        */
+       public static void getFunctionLabel(IFunctionDeclaration func, int flags, StyledString result) {
+               new CElementLabelComposer(result).appendFunctionLabel(func, flags);     
+       }
+
+       /**
+        * Appends the label for a type definition to a StringBuffer.
+        * @param typedef a type definition
+        * @param flags any of the F_* flags, and MF_POST_FILE_QUALIFIED
+        * @param buf the buffer to append the label
+        */
+       public static void getTypeDefLabel(ITypeDef typedef, int flags, StringBuffer buf ) {
+               new CElementLabelComposer(buf).appendTypeDefLabel(typedef, flags);              
+       }
+
+       /**
+        * Appends the label for a type definition to a {@link StyledString}.
+        * @param typedef a type definition
+        * @param flags any of the F_* flags, and MF_POST_FILE_QUALIFIED
+        * @param result the buffer to append the label
+        */
+       public static void getTypeDefLabel(ITypeDef typedef, int flags, StyledString result ) {
+               new CElementLabelComposer(result).appendTypeDefLabel(typedef, flags);           
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CUILabelProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CUILabelProvider.java
new file mode 100644 (file)
index 0000000..bb751ac
--- /dev/null
@@ -0,0 +1,278 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Patrick Hofer [bug 325799]
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.jface.viewers.IColorProvider;
+import org.eclipse.jface.viewers.ILabelDecorator;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StyledCellLabelProvider;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+public class CUILabelProvider extends LabelProvider implements IColorProvider, IStyledLabelProvider {
+       
+       protected CElementImageProvider fImageLabelProvider;
+       protected StorageLabelProvider fStorageLabelProvider;
+       
+       private ArrayList<ILabelDecorator> fLabelDecorators;
+
+       private int fImageFlags;
+       private long fTextFlags;
+       private Color fInactiveColor;
+       private Color fDefaultColor;
+
+       /**
+        * Creates a new label provider with default flags.
+        */
+       public CUILabelProvider() {
+               this(CElementLabels.M_PARAMETER_TYPES, CElementImageProvider.OVERLAY_ICONS);
+       }
+
+       /**
+        * @param textFlags Flags defined in <code>CElementLabels</code>.
+        * @param imageFlags Flags defined in <code>CElementImageProvider</code>.
+        */
+       public CUILabelProvider(long textFlags, int imageFlags) {
+               fImageLabelProvider= new CElementImageProvider();
+               fLabelDecorators= null;
+
+               fStorageLabelProvider= new StorageLabelProvider();
+               fImageFlags= imageFlags;
+               fTextFlags= textFlags;
+       }
+       
+       /**
+        * Adds a decorator to the label provider
+        * @param decorator the decorator to add
+        */
+       public void addLabelDecorator(ILabelDecorator decorator) {
+               if (fLabelDecorators == null) {
+                       fLabelDecorators= new ArrayList<ILabelDecorator>(2);
+               }
+               fLabelDecorators.add(decorator);
+       }
+       
+       /**
+        * Sets the textFlags.
+        * @param textFlags The textFlags to set
+        */
+       public final void setTextFlags(long textFlags) {
+               fTextFlags= textFlags;
+       }
+
+       /**
+        * Sets the imageFlags
+        * @param imageFlags The imageFlags to set
+        */
+       public final void setImageFlags(int imageFlags) {
+               fImageFlags= imageFlags;
+       }
+       
+       /**
+        * Gets the image flags.
+        * Can be overwritten by super classes.
+        * @return Returns a int
+        */
+       public final int getImageFlags() {
+               return fImageFlags;
+       }
+
+       /**
+        * Gets the text flags.
+        * @return Returns a int
+        */
+       public final long getTextFlags() {
+               return fTextFlags;
+       }
+       
+       /**
+        * Evaluates the image flags for a element.
+        * Can be overwritten by super classes.
+        * @param element the element to compute the image flags for
+        * @return Returns a int
+        */
+       protected int evaluateImageFlags(Object element) {
+               return getImageFlags();
+       }
+
+       /**
+        * Evaluates the text flags for a element. Can be overwritten by super classes.
+        * @param element the element to compute the text flags for
+        * @return Returns a int
+        */
+       protected long evaluateTextFlags(Object element) {
+               return getTextFlags();
+       }
+
+       protected Image decorateImage(Image image, Object element) {
+               if (fLabelDecorators != null && image != null) {
+                       for (int i= 0; i < fLabelDecorators.size(); i++) {
+                               ILabelDecorator decorator= fLabelDecorators.get(i);
+                               image= decorator.decorateImage(image, element);
+                       }
+               }
+               return image;
+       }
+
+       /* (non-Javadoc)
+        * @see ILabelProvider#getImage
+        */
+       @Override
+       public Image getImage(Object element) {
+               Image result= fImageLabelProvider.getImageLabel(element, evaluateImageFlags(element));
+               if (result == null && (element instanceof IStorage)) {
+                       result= fStorageLabelProvider.getImage(element);
+               }
+               
+               return decorateImage(result, element);
+       }
+
+       protected String decorateText(String text, Object element) {
+               if (fLabelDecorators != null && text.length() > 0) {
+                       for (int i= 0; i < fLabelDecorators.size(); i++) {
+                               ILabelDecorator decorator= fLabelDecorators.get(i);
+                               text= decorator.decorateText(text, element);
+                       }
+               }       
+               return text;
+       }
+
+
+       /* (non-Javadoc)
+        * @see ILabelProvider#getText
+        */
+       @Override
+       public String getText(Object element) {
+               String result= CElementLabels.getTextLabel(element, evaluateTextFlags(element));
+               if (result.length() == 0 && (element instanceof IStorage)) {
+                       result= fStorageLabelProvider.getText(element);
+               }
+               
+               return decorateText(result, element);
+       }
+
+       public StyledString getStyledText(Object element) {
+               StyledString string= CElementLabels.getStyledTextLabel(element, (evaluateTextFlags(element) | CElementLabels.COLORIZE));
+               if (string.length() == 0 && (element instanceof IStorage)) {
+                       string= new StyledString(fStorageLabelProvider.getText(element));
+               }
+               String decorated= decorateText(string.getString(), element);
+               if (decorated != null) {
+                       return StyledCellLabelProvider.styleDecoratedString(decorated, StyledString.DECORATIONS_STYLER, string);
+               }
+               return string;
+       }
+       
+
+       /* (non-Javadoc)
+        * @see IBaseLabelProvider#dispose
+        */
+       @Override
+       public void dispose() {
+               if (fLabelDecorators != null) {
+                       for (int i= 0; i < fLabelDecorators.size(); i++) {
+                               ILabelDecorator decorator= fLabelDecorators.get(i);
+                               decorator.dispose();
+                       }
+                       fLabelDecorators= null;
+               }
+               fStorageLabelProvider.dispose();
+               fImageLabelProvider.dispose();
+       }
+       
+       /* (non-Javadoc)
+        * @see IBaseLabelProvider#addListener(ILabelProviderListener)
+        */
+       @Override
+       public void addListener(ILabelProviderListener listener) {
+               if (fLabelDecorators != null) {
+                       for (int i= 0; i < fLabelDecorators.size(); i++) {
+                               ILabelDecorator decorator= fLabelDecorators.get(i);
+                               decorator.addListener(listener);
+                       }
+               }
+               super.addListener(listener);    
+       }
+
+       /* (non-Javadoc)
+        * @see IBaseLabelProvider#isLabelProperty(Object, String)
+        */
+       @Override
+       public boolean isLabelProperty(Object element, String property) {
+               return true;    
+       }
+
+       /* (non-Javadoc)
+        * @see IBaseLabelProvider#removeListener(ILabelProviderListener)
+        */
+       @Override
+       public void removeListener(ILabelProviderListener listener) {
+               if (fLabelDecorators != null) {
+                       for (int i= 0; i < fLabelDecorators.size(); i++) {
+                               ILabelDecorator decorator= fLabelDecorators.get(i);
+                               decorator.removeListener(listener);
+                       }
+               }
+               super.removeListener(listener); 
+       }
+       
+       public static ILabelDecorator[] getDecorators(boolean errortick, ILabelDecorator extra) {
+               if (errortick) {
+                       if (extra == null) {
+                               return new ILabelDecorator[] {};
+                       }
+                       return new ILabelDecorator[] { extra };
+               }
+               if (extra != null) {
+                       return new ILabelDecorator[] { extra };
+               }
+               return null;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
+        */
+       public Color getForeground(Object element) {
+               if (element instanceof ISourceReference) {
+                       ISourceReference sref= (ISourceReference)element;
+                       if (!sref.isActive()) {
+                               if (fInactiveColor == null && Display.getCurrent() != null) {
+                                       fInactiveColor= CUIPlugin.getStandardDisplay().getSystemColor(SWT.COLOR_DARK_GRAY);
+                                       fDefaultColor= CUIPlugin.getStandardDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND);
+                               }
+                               return fInactiveColor;
+                       }
+               }
+               return fDefaultColor;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
+        */
+       public Color getBackground(Object element) {
+               return null;
+       }       
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ColoredViewersManager.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ColoredViewersManager.java
new file mode 100644 (file)
index 0000000..b1d5207
--- /dev/null
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.swt.widgets.Display;
+
+import org.eclipse.jface.preference.JFacePreferences;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+import org.eclipse.ui.IWorkbenchPreferenceConstants;
+import org.eclipse.ui.PlatformUI;
+
+
+public class ColoredViewersManager implements IPropertyChangeListener {
+       public static final String INHERITED_COLOR_NAME= "org.eclipse.cdt.ui.ColoredLabels.inherited"; //$NON-NLS-1$
+       
+       public static final String HIGHLIGHT_BG_COLOR_NAME= "org.eclipse.cdt.ui.ColoredLabels.match_highlight"; //$NON-NLS-1$
+       public static final String HIGHLIGHT_WRITE_BG_COLOR_NAME= "org.eclipse.cdt.ui.ColoredLabels.writeaccess_highlight"; //$NON-NLS-1$
+       
+       private static ColoredViewersManager fgInstance= new ColoredViewersManager();
+       
+       private Set<ColoringLabelProvider> fManagedLabelProviders;
+               
+       public ColoredViewersManager() {
+               fManagedLabelProviders= new HashSet<ColoringLabelProvider>();
+       }
+       
+       public void installColoredLabels(ColoringLabelProvider labelProvider) {
+               if (fManagedLabelProviders.contains(labelProvider))
+                       return;
+               
+               if (fManagedLabelProviders.isEmpty()) {
+                       // first lp installed
+                       PlatformUI.getPreferenceStore().addPropertyChangeListener(this);
+                       JFaceResources.getColorRegistry().addListener(this);
+               }
+               fManagedLabelProviders.add(labelProvider);
+       }
+       
+       public void uninstallColoredLabels(ColoringLabelProvider labelProvider) {
+               if (!fManagedLabelProviders.remove(labelProvider))
+                       return; // not installed
+               
+               if (fManagedLabelProviders.isEmpty()) {
+                       PlatformUI.getPreferenceStore().removePropertyChangeListener(this);
+                       JFaceResources.getColorRegistry().removeListener(this);
+                       // last viewer uninstalled
+               }
+       }
+                               
+       public void propertyChange(PropertyChangeEvent event) {
+               String property= event.getProperty();
+               if (property.equals(JFacePreferences.QUALIFIER_COLOR) || property.equals(JFacePreferences.COUNTER_COLOR) || property.equals(JFacePreferences.DECORATIONS_COLOR)
+                               || property.equals(HIGHLIGHT_BG_COLOR_NAME) || property.equals(IWorkbenchPreferenceConstants.USE_COLORED_LABELS) || property.equals(HIGHLIGHT_WRITE_BG_COLOR_NAME)) {
+                       Display.getDefault().asyncExec(new Runnable() {
+                               public void run() {
+                                       refreshAllViewers();
+                               }
+                       });
+               }
+       }
+       
+       protected final void refreshAllViewers() {
+               for (ColoringLabelProvider provider : fManagedLabelProviders) {
+                       provider.refresh();
+               }
+       }
+               
+       public static boolean showColoredLabels() {
+               return PlatformUI.getPreferenceStore().getBoolean(IWorkbenchPreferenceConstants.USE_COLORED_LABELS);
+       }
+       
+       public static void install(ColoringLabelProvider labelProvider) {
+               fgInstance.installColoredLabels(labelProvider);
+       }
+       
+       public static void uninstall(ColoringLabelProvider labelProvider) {
+               fgInstance.uninstallColoredLabels(labelProvider);
+       }       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ColoringLabelProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ColoringLabelProvider.java
new file mode 100644 (file)
index 0000000..aa59113
--- /dev/null
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyleRange;
+
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider;
+import org.eclipse.jface.viewers.IDecorationContext;
+import org.eclipse.jface.viewers.ILabelDecorator;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.jface.viewers.ViewerColumn;
+import org.eclipse.jface.viewers.StyledString.Styler;
+
+public class ColoringLabelProvider extends DecoratingStyledCellLabelProvider implements ILabelProvider {
+       public static final Styler HIGHLIGHT_STYLE= StyledString.createColorRegistryStyler(null, ColoredViewersManager.HIGHLIGHT_BG_COLOR_NAME);
+       public static final Styler HIGHLIGHT_WRITE_STYLE= StyledString.createColorRegistryStyler(null, ColoredViewersManager.HIGHLIGHT_WRITE_BG_COLOR_NAME);
+       
+       public ColoringLabelProvider(IStyledLabelProvider labelProvider) {
+               this(labelProvider, null, null);
+       }
+       
+       public ColoringLabelProvider(IStyledLabelProvider labelProvider, ILabelDecorator decorator, IDecorationContext decorationContext) {
+               super(labelProvider, decorator, decorationContext);
+       }
+
+       @Override
+       public void initialize(ColumnViewer viewer, ViewerColumn column) {
+               ColoredViewersManager.install(this);
+               setOwnerDrawEnabled(ColoredViewersManager.showColoredLabels());
+               
+               super.initialize(viewer, column);
+       }
+               
+       @Override
+       public void dispose() {
+               super.dispose();
+               ColoredViewersManager.uninstall(this);
+       }
+       
+       public void refresh() {
+               ColumnViewer viewer= getViewer();
+               
+               if (viewer == null) {
+                       return;
+               }
+               boolean showColoredLabels= ColoredViewersManager.showColoredLabels();
+               if (showColoredLabels != isOwnerDrawEnabled()) {
+                       setOwnerDrawEnabled(showColoredLabels);
+                       viewer.refresh();
+               } else if (showColoredLabels) {
+                       viewer.refresh();
+               }
+       }
+       
+       @Override
+       protected StyleRange prepareStyleRange(StyleRange styleRange, boolean applyColors) {
+               if (!applyColors && styleRange.background != null) {
+                       styleRange= super.prepareStyleRange(styleRange, applyColors);
+                       styleRange.borderStyle= SWT.BORDER_DOT;
+                       return styleRange;
+               }
+               return super.prepareStyleRange(styleRange, applyColors);
+       }
+       
+       public String getText(Object element) {
+               return getStyledText(element).getString();
+       }
+
+       public static StyledString decorateStyledString(StyledString string, String decorated, Styler color) {
+               String label= string.getString();
+               int originalStart= decorated.indexOf(label);
+               if (originalStart == -1) {
+                       return new StyledString(decorated); // the decorator did something wild
+               }
+               if (originalStart > 0) {
+                       StyledString newString= new StyledString(decorated.substring(0, originalStart), color);
+                       newString.append(string);
+                       string= newString;
+               }
+               if (decorated.length() > originalStart + label.length()) { // decorator appended something
+                       return string.append(decorated.substring(originalStart + label.length()), color);
+               }
+               return string; // no change
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/DecoratingCLabelProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/DecoratingCLabelProvider.java
new file mode 100644 (file)
index 0000000..1684202
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Patrick Hofer [bug 325799]
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import org.eclipse.jface.viewers.DecorationContext;
+import org.eclipse.ui.PlatformUI;
+
+public class DecoratingCLabelProvider extends ColoringLabelProvider {
+       
+       /**
+        * Decorating label provider for C/C++. Combines a CUILabelProvider
+        * with problem and override indicator with the workbench decorator (label
+        * decorator extension point).
+        * @param labelProvider the label provider to decorate
+        */
+       public DecoratingCLabelProvider(CUILabelProvider labelProvider) {
+               this(labelProvider, true);
+       }
+
+       /**
+        * Decorating label provider for C/C++. Combines a CUILabelProvider
+        * (if enabled with problem indicator) with the workbench
+        * decorator (label decorator extension point).
+        * @param labelProvider the label provider to decorate
+        * @param errorTick show error ticks
+        */
+       public DecoratingCLabelProvider(CUILabelProvider labelProvider, boolean errorTick) {
+               super(labelProvider, PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(), DecorationContext.DEFAULT_CONTEXT);
+               if (errorTick) {
+                       labelProvider.addLabelDecorator(new ProblemsLabelDecorator(null));
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/EditorOpener.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/EditorOpener.java
new file mode 100644 (file)
index 0000000..8109b18
--- /dev/null
@@ -0,0 +1,179 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import java.net.URI;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.IPositionConverter;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ISourceRange;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.model.ext.ICElementHandle;
+
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+import org.eclipse.cdt.internal.ui.util.StatusLineHandler;
+
+/**
+ * An utility to open editors for references or elements.
+ */
+public class EditorOpener {
+       
+       /**
+        * Opens the editor selecting the given region.
+        */
+       public static void open(IWorkbenchPage page, IFile file, IRegion region, long timestamp) {
+               if (file.getLocationURI() != null) {
+                       IEditorPart editor= null;
+                       if (timestamp == 0) {
+                               timestamp= file.getLocalTimeStamp();
+                       }
+                       try {
+                               // Bug 328321: Linked resources of closed projects report wrong location.
+                               if (!file.exists()) {
+                                       final IWorkbenchPartSite site = page.getActivePart().getSite();
+                                       showStatus(site, 3000,
+                                                       NLS.bind(Messages.EditorOpener_fileDoesNotExist, file.getName()));
+                                       return;
+                               }
+                               editor= IDE.openEditor(page, file, false);
+                       } catch (PartInitException e) {
+                               CUIPlugin.log(e);
+                       }
+                       selectRegion(file.getFullPath(), region, timestamp, editor);
+               }
+       }
+
+       private static void showStatus(final IWorkbenchPartSite site, int duration, String msg) {
+               StatusLineHandler.showStatusLineMessage(site, msg);
+                Display.getCurrent().timerExec(duration, new Runnable() {
+                       public void run() {
+                               StatusLineHandler.clearStatusLine(site);
+                       }
+               });
+       }
+
+       private static void selectRegion(IPath filebufferKey, IRegion region, long timestamp, IEditorPart editor) {
+               if (editor instanceof ITextEditor) {
+            ITextEditor te= (ITextEditor) editor;
+            IPositionConverter pc= CCorePlugin.getPositionTrackerManager().findPositionConverter(filebufferKey, timestamp);
+            if (pc != null) {
+               region= pc.historicToActual(region);
+            }
+            te.selectAndReveal(region.getOffset(), region.getLength());
+        }
+       }
+       
+       private static void selectRegion(URI locationURI, IRegion region, long timestamp, IEditorPart editor) {
+               if (editor instanceof ITextEditor) {
+            ITextEditor te= (ITextEditor) editor;
+            IPositionConverter pc= CCorePlugin.getPositionTrackerManager().findPositionConverter(locationURI, timestamp);
+            if (pc != null) {
+               region= pc.historicToActual(region);
+            }
+            te.selectAndReveal(region.getOffset(), region.getLength());
+        }
+       }
+
+       /**
+        * Opens the editor for an external location, selecting the given region.
+        */
+       public static void openExternalFile(IWorkbenchPage page, IPath location, IRegion region, long timestamp) {
+               IEditorPart editor= null;
+               try {
+                       editor= EditorUtility.openInEditor(location, null);
+               if (timestamp == 0) {
+                       timestamp= location.toFile().lastModified();
+               }
+               selectRegion(location, region, timestamp, editor);
+               } catch (PartInitException e) {
+                       CUIPlugin.log(e);
+               }
+       }
+       
+       /**
+        * Opens the editor for an external EFS location, selecting the given region.
+        */
+       public static void openExternalFile(IWorkbenchPage page, URI locationURI, IRegion region, long timestamp, ICElement context) {
+               IEditorPart editor= null;
+               try {
+                       editor= EditorUtility.openInEditor(locationURI, context);
+               if (timestamp == 0) {
+                       try {
+                                       timestamp= EFS.getStore(locationURI).fetchInfo().getLastModified();
+                               } catch (CoreException e) {
+                                       CUIPlugin.log(e);
+                               }
+               }
+               selectRegion(locationURI, region, timestamp, editor);
+               } catch (PartInitException e) {
+                       CUIPlugin.log(e);
+               }
+       }
+
+       /**
+        * Opens the editor for an ICElement, selecting the id.
+        * @throws CModelException 
+        */
+       public static void open(IWorkbenchPage page, ICElement element) throws CModelException {
+               if (element instanceof ISourceReference) {
+                       ISourceReference sr= (ISourceReference) element;
+                       ITranslationUnit tu= sr.getTranslationUnit();
+                       ISourceRange range= sr.getSourceRange();
+                       long timestamp= 0; // last modified of file.
+                       if (tu.isWorkingCopy() || element instanceof ICElementHandle) {
+                               timestamp= -1; 
+                       }
+                       open(page, tu, new Region(range.getIdStartPos(), range.getIdLength()), timestamp);
+               }
+       }
+
+       /**
+        * Opens the editor for an ICElement, selecting the given region.
+        */
+       public static void open(IWorkbenchPage page, ITranslationUnit tu, Region region, long timestamp) {
+               if (tu != null) {
+                       IResource r= tu.getResource();
+                       if (r instanceof IFile) {
+                               if (r.getLocationURI() != null) {
+                                       EditorOpener.open(page, (IFile) r, region, timestamp);
+                               }
+                       }
+                       else {
+                               IPath location= tu.getPath();
+                               if (location != null) {
+                                       EditorOpener.openExternalFile(page, location, region, timestamp);
+                               }
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ExcludedFileDecorator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ExcludedFileDecorator.java
new file mode 100644 (file)
index 0000000..a8faf92
--- /dev/null
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Atmel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Torkild U. Resheim (Atmel Corporation) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.preference.JFacePreferences;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ILightweightLabelDecorator;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
+import org.eclipse.cdt.core.settings.model.ICSourceEntry;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+
+/**
+ * Determines if a file is excluded from a CDT build and if that is the case decorates the file's icon and
+ * renders the label using the qualifier (gray) color.
+ */
+public class ExcludedFileDecorator implements ILightweightLabelDecorator {
+
+       public void decorate(Object element, IDecoration decoration) {
+               if (element instanceof IFile) {
+                       IFile resource = (IFile) element;
+                       ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
+                       ICProjectDescription desc = mngr.getProjectDescription(resource.getProject(), false);
+                       if (desc == null)
+                               return;
+                       ICConfigurationDescription conf = desc.getDefaultSettingConfiguration();
+                       ICSourceEntry[] entries = conf.getSourceEntries();
+                       boolean isSource = false;
+                       for (ICSourceEntry icSourceEntry : entries) {
+                               if (icSourceEntry.getFullPath().isPrefixOf(resource.getFullPath())) {
+                                       isSource = true;
+                                       break;
+                               }
+                       }
+                       // Only bother to mark items that would be included otherwise
+                       if (isSource && CDataUtil.isExcluded(resource.getFullPath(), entries)) {
+                               decoration.addOverlay(CPluginImages.DESC_OVR_INACTIVE);
+                               decoration.setForegroundColor(JFaceResources.getColorRegistry().get(
+                                               JFacePreferences.QUALIFIER_COLOR));
+                       }
+               }
+       }
+
+       public void addListener(ILabelProviderListener listener) {
+               // We don't track state changes
+       }
+
+       public void dispose() {
+       }
+
+       public boolean isLabelProperty(Object element, String property) {
+               return false;
+       }
+
+       public void removeListener(ILabelProviderListener listener) {
+               // We don't track state changes
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ExtendedTreeViewer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ExtendedTreeViewer.java
new file mode 100644 (file)
index 0000000..b6d9e2c
--- /dev/null
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.widgets.Composite;
+
+public class ExtendedTreeViewer extends TreeViewer {
+
+    private boolean fPreservingSelection= false;
+
+    public ExtendedTreeViewer(Composite parent) {
+        super(parent);
+    }
+
+    public ExtendedTreeViewer(Composite parent, int style) {
+        super(parent, style);
+    }
+
+    public void refresh(final Object[] elements) {
+        preservingSelection(new Runnable() {
+            public void run() {
+                for (int i = 0; i < elements.length; i++) {
+                    refresh(elements[i]);
+                }
+            }
+        });
+    }
+
+    @Override
+       protected void preservingSelection(Runnable updateCode) {
+        if (fPreservingSelection) {
+            updateCode.run();
+        } else {
+            fPreservingSelection= true;
+            try {
+                super.preservingSelection(updateCode);
+            } finally {
+                fPreservingSelection= false;
+            }
+        }
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ISelectionListenerWithAST.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ISelectionListenerWithAST.java
new file mode 100644 (file)
index 0000000..bc0f874
--- /dev/null
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.ui.IEditorPart;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+
+/**
+ * Listener to be informed on text selection changes in an editor (post selection), including the corresponding AST.
+ * The AST is shared and must not be modified.
+ * Listeners can be registered in a <code>SelectionListenerWithASTManager</code>.
+ */
+public interface ISelectionListenerWithAST {
+       
+       /**
+        * Called when a selection has changed. The method is called in a post selection event in an background
+        * thread.
+        * 
+        * @param part The editor part in which the selection change has occurred.
+        * @param selection The new text selection
+        * @param astRoot The AST tree corresponding to the editor's input. This AST is shared and must
+        * not be modified.
+        */
+       void selectionChanged(IEditorPart part, ITextSelection selection, IASTTranslationUnit astRoot);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IViewPartInputProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IViewPartInputProvider.java
new file mode 100644 (file)
index 0000000..3f794a7
--- /dev/null
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+/**
+ * Interface common to all view parts that provide an input.
+ */
+public interface IViewPartInputProvider {
+       
+       /**
+        * Returns the input.
+        *
+        * @return the input object
+        */
+       public Object getViewPartInput();
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ImageImageDescriptor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ImageImageDescriptor.java
new file mode 100644 (file)
index 0000000..e4d0a30
--- /dev/null
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+
+/**
+  */
+public class ImageImageDescriptor extends ImageDescriptor {
+
+       private Image fImage;
+
+       /**
+        * Constructor for ImagImageDescriptor.
+        */
+       public ImageImageDescriptor(Image image) {
+               super();
+               fImage= image;
+       }
+
+       /* (non-Javadoc)
+        * @see ImageDescriptor#getImageData()
+        */
+       @Override
+       public ImageData getImageData() {
+               return fImage.getImageData();
+       }
+
+       /* (non-Javadoc)
+        * @see Object#equals(Object)
+        */
+       @Override
+       public boolean equals(Object obj) {
+               return (obj != null) && getClass().equals(obj.getClass()) && fImage.equals(((ImageImageDescriptor)obj).fImage);
+       }
+
+       /* (non-Javadoc)
+        * @see Object#hashCode()
+        */
+       @Override
+       public int hashCode() {
+               return fImage.hashCode();
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java
new file mode 100644 (file)
index 0000000..c11a424
--- /dev/null
@@ -0,0 +1,529 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Markus Schorn - initial API and implementation
+ *     Ed Swartz (Nokia)
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Properties;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.Region;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.IEditorInput;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.IPositionConverter;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTExpression;
+import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
+import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTNodeSelector;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroExpansion;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.ICompositeType;
+import org.eclipse.cdt.core.dom.ast.IEnumeration;
+import org.eclipse.cdt.core.dom.ast.IEnumerator;
+import org.eclipse.cdt.core.dom.ast.IField;
+import org.eclipse.cdt.core.dom.ast.ITypedef;
+import org.eclipse.cdt.core.dom.ast.IVariable;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexBinding;
+import org.eclipse.cdt.core.index.IIndexFile;
+import org.eclipse.cdt.core.index.IIndexFileLocation;
+import org.eclipse.cdt.core.index.IIndexInclude;
+import org.eclipse.cdt.core.index.IIndexMacro;
+import org.eclipse.cdt.core.index.IIndexName;
+import org.eclipse.cdt.core.index.IndexFilter;
+import org.eclipse.cdt.core.index.IndexLocationFactory;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModelUtil;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IInclude;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.ISourceRange;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
+import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInstanceCache;
+import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
+import org.eclipse.cdt.internal.core.model.ext.CElementHandleFactory;
+import org.eclipse.cdt.internal.core.model.ext.ICElementHandle;
+import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
+
+import org.eclipse.cdt.internal.ui.editor.ASTProvider;
+
+public class IndexUI {
+       private static final ICElementHandle[] EMPTY_ELEMENTS = new ICElementHandle[0];
+
+       public static IIndexBinding elementToBinding(IIndex index, ICElement element) throws CoreException {
+               return elementToBinding(index, element, -1);
+       }
+
+       public static IIndexBinding elementToBinding(IIndex index, ICElement element, int linkageID) throws CoreException {
+               if (element instanceof ISourceReference) {
+                       ISourceReference sf = ((ISourceReference)element);
+                       ISourceRange range= sf.getSourceRange();
+                       if (range.getIdLength() != 0) {
+                               IIndexName name= elementToName(index, element, linkageID);
+                               if (name != null) {
+                                       return index.findBinding(name);
+                               }
+                       } else {
+                               String name= element.getElementName();
+                               name= name.substring(name.lastIndexOf(':')+1);
+                               IIndexBinding[] bindings= index.findBindings(name.toCharArray(), IndexFilter.ALL, new NullProgressMonitor());
+                               for (IIndexBinding binding : bindings) {
+                                       if (checkBinding(binding, element)) {
+                                               return binding;
+                                       }
+                               }
+                       }
+               }
+               return null;
+       }
+
+       private static boolean checkBinding(IIndexBinding binding, ICElement element) {
+               switch(element.getElementType()) {
+               case ICElement.C_ENUMERATION:
+                       return binding instanceof IEnumeration;
+               case ICElement.C_NAMESPACE:
+                       return binding instanceof ICPPNamespace;
+               case ICElement.C_STRUCT_DECLARATION:
+               case ICElement.C_STRUCT:
+                       return binding instanceof ICompositeType && 
+                               ((ICompositeType) binding).getKey() == ICompositeType.k_struct;
+               case ICElement.C_CLASS:
+               case ICElement.C_CLASS_DECLARATION:
+                       return binding instanceof ICPPClassType && 
+                               ((ICompositeType) binding).getKey() == ICPPClassType.k_class;
+               case ICElement.C_UNION:
+               case ICElement.C_UNION_DECLARATION:
+                       return binding instanceof ICompositeType && 
+                               ((ICompositeType) binding).getKey() == ICompositeType.k_union;
+               case ICElement.C_TYPEDEF:
+                       return binding instanceof ITypedef;
+               case ICElement.C_METHOD:        
+               case ICElement.C_METHOD_DECLARATION:
+                       return binding instanceof ICPPMethod;
+               case ICElement.C_FIELD:
+                       return binding instanceof IField;
+               case ICElement.C_FUNCTION:      
+               case ICElement.C_FUNCTION_DECLARATION:
+                       return binding instanceof ICPPFunction && !(binding instanceof ICPPMethod);
+               case ICElement.C_VARIABLE:
+               case ICElement.C_VARIABLE_DECLARATION:
+                       return binding instanceof IVariable;
+               case ICElement.C_ENUMERATOR:
+                       return binding instanceof IEnumerator;
+               case ICElement.C_TEMPLATE_CLASS:
+               case ICElement.C_TEMPLATE_CLASS_DECLARATION:
+               case ICElement.C_TEMPLATE_STRUCT:
+               case ICElement.C_TEMPLATE_STRUCT_DECLARATION:
+               case ICElement.C_TEMPLATE_UNION:
+               case ICElement.C_TEMPLATE_UNION_DECLARATION:
+                       return binding instanceof ICPPClassTemplate;
+               case ICElement.C_TEMPLATE_FUNCTION:
+               case ICElement.C_TEMPLATE_FUNCTION_DECLARATION:
+                       return binding instanceof ICPPFunctionTemplate && !(binding instanceof ICPPMethod);
+               case ICElement.C_TEMPLATE_METHOD_DECLARATION:
+               case ICElement.C_TEMPLATE_METHOD:
+                       return binding instanceof ICPPFunctionTemplate && binding instanceof ICPPMethod;
+               case ICElement.C_TEMPLATE_VARIABLE:
+                       return binding instanceof ICPPTemplateParameter;
+               }
+               return false;
+       }
+
+       public static IIndexName elementToName(IIndex index, ICElement element) throws CoreException {
+               return elementToName(index, element, -1);
+       }
+       
+       public static IIndexName elementToName(IIndex index, ICElement element, int linkageID) throws CoreException {
+               if (element instanceof ISourceReference) {
+                       ISourceReference sf = ((ISourceReference)element);
+                       ITranslationUnit tu= sf.getTranslationUnit();
+                       if (tu != null) {
+                               IIndexFileLocation location= IndexLocationFactory.getIFL(tu);
+                               if (location != null) {
+                                       IIndexFile[] files= index.getFiles(location);
+                                       for (IIndexFile file : files) {
+                                               if (linkageID == -1 || file.getLinkageID() == linkageID) {
+                                                       String elementName= element.getElementName();
+                                                       int idx= elementName.lastIndexOf(":") + 1; //$NON-NLS-1$
+                                                       ISourceRange pos= sf.getSourceRange();
+                                                       IRegion region = getConvertedRegion(tu, file, pos.getIdStartPos() + idx, pos.getIdLength() - idx);
+                                                       IIndexName[] names= file.findNames(region.getOffset(), region.getLength());
+                                                       for (IIndexName name2 : names) {
+                                                               IIndexName name = name2;
+                                                               if (!name.isReference() && elementName.endsWith(new String(name.getSimpleID()))) {
+                                                                       return name;
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+               return null;
+       }
+
+       public static boolean isIndexed(IIndex index, ICElement element) throws CoreException {
+               if (element instanceof ISourceReference) {
+                       ISourceReference sf = ((ISourceReference)element);
+                       ITranslationUnit tu= sf.getTranslationUnit();
+                       if (tu != null) {
+                               IIndexFileLocation location= IndexLocationFactory.getIFL(tu);
+                               if (location != null) {
+                                       IIndexFile[] files= index.getFiles(location);
+                                       return files.length > 0;
+                               }
+                       }
+               }
+               return false;
+       }
+       
+       private static IRegion getConvertedRegion(ITranslationUnit tu, IIndexFile file, int pos,
+                       int length) throws CoreException {
+               IRegion region= new Region(pos, length);
+               IPositionConverter converter=
+                               CCorePlugin.getPositionTrackerManager().findPositionConverter(tu, file.getTimestamp());
+               if (converter != null) {
+                       region= converter.actualToHistoric(region);
+               }
+               return region;
+       }
+       
+       public static IIndexInclude elementToInclude(IIndex index, IInclude include) throws CoreException {
+               if (include != null) {
+                       ITranslationUnit tu= include.getTranslationUnit();
+                       if (tu != null) {
+                               IIndexFileLocation location= IndexLocationFactory.getIFL(tu);
+                               if (location != null) {
+                                       IIndexFile[] files= index.getFiles(location);
+                                       for (IIndexFile file : files) {
+                                               String elementName= include.getElementName();
+                                               ISourceRange pos= include.getSourceRange();
+                                               IRegion region= getConvertedRegion(tu, file, pos.getIdStartPos(), pos.getIdLength());
+
+                                               IIndexInclude[] includes= index.findIncludes(file);
+                                               int bestDiff= Integer.MAX_VALUE;
+                                               IIndexInclude best= null;
+                                               for (IIndexInclude candidate : includes) {
+                                                       int diff= Math.abs(candidate.getNameOffset() - region.getOffset());
+                                                       if (diff > bestDiff) {
+                                                               break;
+                                                       }
+                                                       if (candidate.getFullName().endsWith(elementName)) {
+                                                               bestDiff= diff;
+                                                               best= candidate;
+                                                       }
+                                               }
+                                               if (best != null)
+                                                       return best;
+                                       }
+                               }
+                       }
+               }
+               return null;
+       }
+
+
+       public static ICElementHandle[] findRepresentative(IIndex index, IBinding binding) throws CoreException {
+               ICElementHandle[] defs = IndexUI.findAllDefinitions(index, binding);
+               if (defs.length == 0) {
+                       ICElementHandle elem = IndexUI.findAnyDeclaration(index, null, binding);
+                       if (elem != null) {
+                               defs = new ICElementHandle[] { elem };
+                       }
+               }
+               return defs;
+       }
+
+       public static ICElementHandle[] findAllDefinitions(IIndex index, IBinding binding) throws CoreException {
+               if (binding != null) {
+                       IIndexName[] defs= index.findNames(binding, IIndex.FIND_DEFINITIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
+
+                       ArrayList<ICElementHandle> result= new ArrayList<ICElementHandle>();
+                       for (IIndexName in : defs) {
+                               ICElementHandle definition= getCElementForName((ICProject) null, index, in);
+                               if (definition != null) {
+                                       result.add(definition);
+                               }
+                       }
+                       return result.toArray(new ICElementHandle[result.size()]);
+               }
+               return EMPTY_ELEMENTS;
+       }
+
+       /**
+        * Creates CElementHandles for definitions or declarations when you expect to find those
+        * in the index.
+        * @param preferProject
+        * @param index
+        * @param declName
+        * @return the ICElementHandle or <code>null</code>.
+        */
+       public static ICElementHandle getCElementForName(ICProject preferProject, IIndex index, IASTName declName) 
+                       throws CoreException {
+               assert !declName.isReference();
+               IBinding binding= declName.resolveBinding();
+               if (binding != null) {
+                       ITranslationUnit tu= getTranslationUnit(preferProject, declName);
+                       if (tu != null) {
+                               IFile file= (IFile) tu.getResource();
+                               long timestamp= file != null ? file.getLocalTimeStamp() : 0;
+                               IASTFileLocation loc= declName.getFileLocation();
+                               IRegion region= new Region(loc.getNodeOffset(), loc.getNodeLength());
+                               IPositionConverter converter= CCorePlugin.getPositionTrackerManager().findPositionConverter(tu, timestamp);
+                               if (converter != null) {
+                                       region= converter.actualToHistoric(region);
+                               }
+                               return CElementHandleFactory.create(tu, binding, declName.isDefinition(), region, timestamp);
+                       }
+               }
+               return null;
+       }
+       
+       public static ITranslationUnit getTranslationUnit(ICProject cproject, IASTName name) {
+               return getTranslationUnit(cproject, name.getFileLocation());
+       }
+
+       public static ITranslationUnit getTranslationUnit(ICProject cproject, IIndexName name) {
+               try {
+                       return CoreModelUtil.findTranslationUnitForLocation(name.getFile().getLocation(), cproject);
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }
+               return null;
+       }
+
+       private static ITranslationUnit getTranslationUnit(ICProject cproject, final IASTFileLocation fileLocation) {
+               if (fileLocation != null) {
+                       IPath path= Path.fromOSString(fileLocation.getFileName());
+                       try {
+                               return CoreModelUtil.findTranslationUnitForLocation(path, cproject);
+                       } catch (CModelException e) {
+                               CUIPlugin.log(e);
+                       }
+               }
+               return null;
+       }
+
+       public static ICElementHandle getCElementForName(ICProject preferProject, IIndex index, IIndexName declName) 
+                       throws CoreException {
+               assert !declName.isReference();
+               ITranslationUnit tu= getTranslationUnit(preferProject, declName);
+               if (tu != null) {
+                       return getCElementForName(tu, index, declName);
+               }
+               return null;
+       }
+
+       public static ICElementHandle getCElementForName(ITranslationUnit tu, IIndex index, IIndexName declName) 
+                       throws CoreException {
+               IRegion region= new Region(declName.getNodeOffset(), declName.getNodeLength());
+               long timestamp= declName.getFile().getTimestamp();
+               return CElementHandleFactory.create(tu, index.findBinding(declName), declName.isDefinition(), region, timestamp);
+       }
+
+       public static ICElementHandle getCElementForMacro(ICProject preferProject, IIndex index, IIndexMacro macro) 
+                       throws CoreException {
+               ITranslationUnit tu= getTranslationUnit(preferProject, macro.getFileLocation());
+               if (tu != null) {
+                       IIndexName name= macro.getDefinition();
+                       if (name != null) {
+                               IRegion region= new Region(name.getNodeOffset(), name.getNodeLength());
+                               long timestamp= macro.getFile().getTimestamp();
+                               return CElementHandleFactory.create(tu, macro, region, timestamp);
+                       }
+               }
+               return null;
+       }
+
+       public static ICElementHandle findAnyDeclaration(IIndex index, ICProject preferProject, IBinding binding) 
+                       throws CoreException {
+               if (binding != null) {
+                       IIndexName[] names= index.findNames(binding, IIndex.FIND_DECLARATIONS);
+                       for (IIndexName name : names) {
+                               ICElementHandle elem= getCElementForName(preferProject, index, name);
+                               if (elem != null) {
+                                       return elem;
+                               }
+                       }
+               }
+               return null;
+       }
+
+       public static IASTName getSelectedName(IEditorInput editorInput, ITextSelection selection) throws CoreException {
+               return getSelectedName(editorInput, selection.getOffset(), selection.getLength());
+       }
+
+       public static IASTName getSelectedName(IEditorInput editorInput, IRegion selection) throws CoreException {
+               return getSelectedName(editorInput, selection.getOffset(), selection.getLength());
+       }
+
+       private static IASTName getSelectedName(IEditorInput editorInput, final int offset, final int length) {
+               IWorkingCopy workingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput);
+               if (workingCopy == null)
+                       return null;
+               
+               final IASTName[] result= {null};
+               ASTProvider.getASTProvider().runOnAST(workingCopy, ASTProvider.WAIT_ACTIVE_ONLY, null, new ASTRunnable() {
+                       public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
+                               if (ast != null) {
+                                       final IASTNodeSelector nodeSelector = ast.getNodeSelector(null);
+                                       IASTName name= nodeSelector.findEnclosingName(offset, length);
+                                       if (name == null) {
+                                               name= nodeSelector.findImplicitName(offset, length);
+                                       }
+                                       if (name != null && name.getParent() instanceof IASTPreprocessorMacroExpansion) {
+                                               IASTFileLocation floc= name.getParent().getFileLocation();
+                                               IASTNode node= nodeSelector.findEnclosingNodeInExpansion(floc.getNodeOffset(), floc.getNodeLength());
+                                               if (node instanceof IASTName) {
+                                                       name= (IASTName) node;
+                                               } else if (node instanceof IASTFunctionCallExpression){
+                                                       IASTExpression expr= ((IASTFunctionCallExpression) node).getFunctionNameExpression();
+                                                       if (expr instanceof IASTIdExpression) {
+                                                               name= ((IASTIdExpression) expr).getName();
+                                                       }
+                                               } else {
+                                                       if (node instanceof IASTSimpleDeclaration) {
+                                                               IASTNode[] dtors= ((IASTSimpleDeclaration) node).getDeclarators();
+                                                               if (dtors != null && dtors.length > 0) {
+                                                                       node= dtors[0];
+                                                               }
+                                                       } else if (node instanceof IASTFunctionDefinition) {
+                                                               node= ((IASTFunctionDefinition) node).getDeclarator();
+                                                       }
+                                                       if (node instanceof IASTDeclarator) {
+                                                               IASTDeclarator dtor= ASTQueries.findTypeRelevantDeclarator((IASTDeclarator) node);
+                                                               name= dtor.getName();
+                                                       }
+                                               }
+                                       }
+                                       result[0]= name;
+                               }
+                               return Status.OK_STATUS;
+                       }
+               });
+               return result[0];
+       }
+
+       public static String getFileNotIndexedMessage(ICElement input) {
+               ITranslationUnit tu= null;
+               if (input instanceof ISourceReference) {
+                       ISourceReference ref= (ISourceReference) input;
+                       tu= ref.getTranslationUnit();
+               }
+               if (tu == null) {
+                       return NLS.bind(Messages.IndexUI_infoNotInSource, input.getElementName());
+               } 
+               
+               String msg= NLS.bind(Messages.IndexUI_infoNotInIndex, tu.getElementName());
+               
+               IResource res= tu.getResource();
+               if (res != null) {
+                       Properties props= IndexerPreferences.getProperties(res.getProject());
+                       if (props == null || !"true".equals(props.get(IndexerPreferences.KEY_INDEX_ALL_FILES)) || //$NON-NLS-1$
+                                       (!"true".equals(props.get(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG)) && //$NON-NLS-1$
+                                        !"true".equals(props.get(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_ALTERNATE_LANG)))) { //$NON-NLS-1$
+                               msg= msg + " " + Messages.IndexUI_infoSelectIndexAllFiles; //$NON-NLS-1$
+                       } 
+               }
+               return msg;
+       }
+
+       public static ICElement attemptConvertionToHandle(IIndex index, ICElement input) throws CoreException {
+               if (input instanceof ICElementHandle) {
+                       return input;
+               }
+               IIndexName name= IndexUI.elementToName(index, input);
+               if (name != null) {
+                       ICElement handle= getCElementForName(input.getCProject(), index, name);
+                       if (handle != null) {
+                               return handle;
+                       }
+               } 
+               return input;
+       }
+       
+       /**
+        * Searches for all specializations that depend on the definition of the given binding.
+        */
+       public static List<? extends IBinding> findSpecializations(IBinding binding) throws CoreException {
+               List<IBinding> result= null;
+
+               IBinding owner = binding.getOwner();
+               if (owner != null) {
+                       List<? extends IBinding> specializedOwners= findSpecializations(owner);
+                       if (!specializedOwners.isEmpty()) {
+                               result= new ArrayList<IBinding>(specializedOwners.size());
+
+                               for (IBinding specOwner : specializedOwners) {
+                                       if (specOwner instanceof ICPPClassSpecialization) {
+                                               result.add(((ICPPClassSpecialization) specOwner).specializeMember(binding));
+                                       }
+                               }
+                       }
+               }
+               
+               if (binding instanceof ICPPInstanceCache) {
+                       final List<ICPPTemplateInstance> instances= Arrays.asList(((ICPPInstanceCache) binding).getAllInstances());
+                       if (!instances.isEmpty()) {
+                               if (result == null)
+                                       result= new ArrayList<IBinding>(instances.size());
+
+                               for (ICPPTemplateInstance inst : instances) {
+                                       if (!ASTInternal.hasDeclaration(inst)) {
+                                               result.add(inst);
+                                       }
+                               }
+                       }
+               }
+               
+               if (result != null) {
+                       return result;
+               }
+               return Collections.emptyList();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesCache.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesCache.java
new file mode 100644 (file)
index 0000000..c44c97d
--- /dev/null
@@ -0,0 +1,276 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.LabelProviderChangedEvent;
+import org.eclipse.swt.SWTException;
+import org.eclipse.ui.IDecoratorManager;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IIndexChangeEvent;
+import org.eclipse.cdt.core.index.IIndexChangeListener;
+import org.eclipse.cdt.core.index.IIndexFile;
+import org.eclipse.cdt.core.index.IIndexFileLocation;
+import org.eclipse.cdt.core.index.IIndexManager;
+import org.eclipse.cdt.core.index.IIndexerStateEvent;
+import org.eclipse.cdt.core.index.IIndexerStateListener;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICProject;
+
+class IndexedFilesCache implements IIndexChangeListener, IIndexerStateListener, ILabelProviderListener {
+       private static final String DECORATOR_ID = "org.eclipse.cdt.ui.indexedFiles"; //$NON-NLS-1$
+       private static final IndexedFilesCache INSTANCE = new IndexedFilesCache();
+       private static final ISchedulingRule RULE = new ISchedulingRule() {
+               public boolean contains(ISchedulingRule rule) {
+                       return rule == this;
+               }
+               public boolean isConflicting(ISchedulingRule rule) {
+                       return rule == this;
+               }
+       };
+
+       public static IndexedFilesCache getInstance() {
+               return INSTANCE;
+       }
+
+       private final HashMap<String, Set<Integer>> fIndexedFiles= new HashMap<String, Set<Integer>>();
+       private boolean fIsDirty= false;
+       private boolean fActive= false;
+
+       private void scheduleInitialize() {
+               Job j= new Job(Messages.IndexedFilesCache_jobName) {
+                       @Override
+                       protected IStatus run(IProgressMonitor monitor) {
+                               try {
+                                       ICProject[] prj= CoreModel.getDefault().getCModel().getCProjects();
+                                       for (ICProject project : prj) {
+                                               initialize(project);
+                                       }
+                               } catch (CoreException e) {
+                                       return e.getStatus();
+                               } catch (InterruptedException e) {
+                                       Thread.currentThread().interrupt();
+                                       return Status.CANCEL_STATUS;
+                               }
+                               checkTriggerDecorator(1);
+                               return Status.OK_STATUS;
+                       }
+                       @Override
+                       public boolean belongsTo(Object family) {
+                               return family == IndexedFilesCache.this;
+                       }
+                       
+               };
+               j.setSystem(true);
+               j.setRule(RULE);
+               j.schedule();           
+       }
+
+       private void scheduleInitialize(final ICProject project) {
+               Job j= new Job(Messages.IndexedFilesCache_jobName) {
+                       @Override
+                       protected IStatus run(IProgressMonitor monitor) {
+                               try {
+                                       initialize(project);
+                               } catch (CoreException e) {
+                                       return e.getStatus();
+                               } catch (InterruptedException e) {
+                                       Thread.currentThread().interrupt();
+                                       return Status.CANCEL_STATUS;
+                               }
+                               checkTriggerDecorator(1);
+                               return Status.OK_STATUS;
+                       }
+                       @Override
+                       public boolean belongsTo(Object family) {
+                               return family == IndexedFilesCache.this;
+                       }
+               };
+               j.setSystem(true);
+               j.setRule(RULE);
+               j.schedule();           
+       }
+
+       final protected void initialize(ICProject prj) throws CoreException, InterruptedException {
+               IIndex index= CCorePlugin.getIndexManager().getIndex(prj, 0);
+               List<IIndexFileLocation> list= new ArrayList<IIndexFileLocation>();
+               index.acquireReadLock();
+               try {
+                       IIndexFile[] files= index.getAllFiles();
+                       for (IIndexFile ifile : files) {
+                               if (ifile.getTimestamp() >= 0) {
+                                       list.add(ifile.getLocation());
+                               }
+                       }
+                       if (!list.isEmpty()) {
+                               final String prjName= prj.getElementName();
+                               synchronized(fIndexedFiles) {
+                                       Set<Integer> cache= fIndexedFiles.get(prjName);
+                                       if (cache == null) {
+                                               cache= new HashSet<Integer>();
+                                               fIndexedFiles.put(prjName, cache);
+                                       }
+                                       else {
+                                               if (!cache.isEmpty()) {
+                                                       cache.clear();
+                                                       fIsDirty= true;
+                                               }
+                                       }
+                                       for (IIndexFileLocation ifl: list) { 
+                                               final int h= computeHash(ifl);
+                                               if (cache.add(h)) {
+                                                       fIsDirty= true;
+                                               }
+                                       }
+                               }
+                       }
+               }
+               finally {
+                       index.releaseReadLock();
+               }
+       }
+
+       public void indexChanged(IIndexChangeEvent e) {
+               // the index manager has reported a change to an index
+               ICProject cproject= e.getAffectedProject();
+               if (cproject == null) {
+                       return;
+               }
+               synchronized (fIndexedFiles) {
+                       if (!fActive) {
+                               return;
+                       }
+                       if (e.isReloaded()) {
+                               scheduleInitialize(cproject);
+                       }
+                       else {
+                               final String prjName = cproject.getElementName();
+                               if (e.isCleared()) {
+                                       if (fIndexedFiles.remove(prjName) != null) {
+                                               fIsDirty= true;
+                                       }
+                               } 
+                               final Set<IIndexFileLocation> filesCleared = e.getFilesCleared();
+                               final Set<IIndexFileLocation> filesWritten = e.getFilesWritten();
+                               if (!(filesCleared.isEmpty() && filesWritten.isEmpty())) {
+                                       Set<Integer> cache= fIndexedFiles.get(prjName);
+                                       if (cache == null) {
+                                               cache= new HashSet<Integer>();
+                                               fIndexedFiles.put(prjName, cache);
+                                       }
+                                       for (IIndexFileLocation ifl: filesCleared) { 
+                                               final int h= computeHash(ifl);
+                                               if (cache.remove(h)) {
+                                                       fIsDirty= true;
+                                               }
+                                       }
+                                       for (IIndexFileLocation ifl: filesWritten) { 
+                                               final int h= computeHash(ifl);
+                                               if (cache.add(h)) {
+                                                       fIsDirty= true;
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+
+       public void indexChanged(IIndexerStateEvent event) {
+               if (event.indexerIsIdle()) {
+                       checkTriggerDecorator(0);
+               }
+       }
+
+       private void activate() {
+               synchronized (fIndexedFiles) {
+                       fActive= true;
+                       PlatformUI.getWorkbench().getDecoratorManager().addListener(this);
+                       final IIndexManager indexManager = CCorePlugin.getIndexManager();
+                       indexManager.addIndexChangeListener(IndexedFilesCache.this);
+                       indexManager.addIndexerStateListener(IndexedFilesCache.this);
+                       scheduleInitialize();
+               }
+       }
+
+       private void deactivate() {
+               synchronized (fIndexedFiles) {
+                       fActive= false;
+                       fIndexedFiles.clear();
+                       final IIndexManager indexManager = CCorePlugin.getIndexManager();
+                       indexManager.removeIndexChangeListener(IndexedFilesCache.this);
+                       indexManager.removeIndexerStateListener(IndexedFilesCache.this);
+                       PlatformUI.getWorkbench().getDecoratorManager().removeListener(this);
+               }
+       }
+
+
+       final protected void checkTriggerDecorator(int jobCount) {
+               if (fIsDirty && CCorePlugin.getIndexManager().isIndexerIdle() && 
+                               Job.getJobManager().find(this).length == jobCount) {
+                       fIsDirty= false;
+                       final IWorkbench workbench= PlatformUI.getWorkbench();
+                       try {
+                               workbench.getDisplay().asyncExec(new Runnable(){
+                                       public void run() {
+                                               workbench.getDecoratorManager().update(DECORATOR_ID);                   
+                                       }
+                               });
+                       }
+                       catch (SWTException e) {
+                               // in case the display is no longer valid
+                       }
+               }
+       }
+       
+       public boolean isIndexed(IProject project, IIndexFileLocation ifl) {
+               // request from a label provider
+               synchronized(fIndexedFiles) {
+                       if (!fActive) {
+                               activate();
+                       }
+                       Set<Integer> cache= fIndexedFiles.get(project.getName());
+                       return cache != null && cache.contains(computeHash(ifl));
+               }
+       }
+
+       private int computeHash(IIndexFileLocation ifl) {
+               final String fp= ifl.getFullPath();
+               final int h1= fp == null ? 0 : fp.hashCode() * 43;
+               return h1 + ifl.getURI().hashCode();
+       }
+
+       public void labelProviderChanged(LabelProviderChangedEvent event) {
+               final Object src= event.getSource();
+               if (src instanceof IDecoratorManager) {
+                       IDecoratorManager mng= (IDecoratorManager) src;
+                       if (!mng.getEnabled(DECORATOR_ID)) {
+                               deactivate();
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesLabelProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexedFilesLabelProvider.java
new file mode 100644 (file)
index 0000000..8318442
--- /dev/null
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ILightweightLabelDecorator;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+import org.eclipse.cdt.core.index.IIndexFileLocation;
+import org.eclipse.cdt.core.index.IndexLocationFactory;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * A label provider that marks all translation units that are currently part of the index.
+ */
+public class IndexedFilesLabelProvider implements ILightweightLabelDecorator {
+       private static final ImageDescriptor INDEXED= 
+       AbstractUIPlugin.imageDescriptorFromPlugin(CUIPlugin.PLUGIN_ID, "$nl$/icons/ovr16/indexedFile.gif"); //$NON-NLS-1$
+    
+    public IndexedFilesLabelProvider() {
+    }
+
+    public void addListener(ILabelProviderListener listener) {
+    }
+
+    public void dispose() {
+    }
+
+    public boolean isLabelProperty(Object element, String property) {
+        return false;
+    }
+
+    public void removeListener(ILabelProviderListener listener) {
+    }
+
+    /**
+     * Adds the linked resource overlay if the given element is a linked
+     * resource.
+     * 
+     * @param element element to decorate
+     * @param decoration  The decoration we are adding to
+     * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(Object, IDecoration)
+     */
+    public void decorate(Object element, IDecoration decoration) {
+       IIndexFileLocation ifl= null;
+       IProject project= null;
+        if (element instanceof IFile) {
+               final IFile file = (IFile) element;
+                       ifl= IndexLocationFactory.getWorkspaceIFL(file);
+                       project= file.getProject();
+        }
+        else if (element instanceof ITranslationUnit) {
+               final ITranslationUnit tu = (ITranslationUnit) element;
+                       ifl= IndexLocationFactory.getIFL(tu);
+               project= tu.getCProject().getProject();
+        }
+        if (isIndexed(project, ifl)) {
+               decoration.addOverlay(INDEXED, IDecoration.TOP_LEFT);
+        }
+    }
+
+       private boolean isIndexed(IProject project, IIndexFileLocation ifl) {
+               if (project == null || ifl == null) {
+                       return false;
+               }
+               
+               return IndexedFilesCache.getInstance().isIndexed(project, ifl);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/LinkedProposalModelPresenter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/LinkedProposalModelPresenter.java
new file mode 100644 (file)
index 0000000..5aed7f9
--- /dev/null
@@ -0,0 +1,239 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.link.ILinkedModeListener;
+import org.eclipse.jface.text.link.LinkedModeModel;
+import org.eclipse.jface.text.link.LinkedModeUI;
+import org.eclipse.jface.text.link.LinkedPosition;
+import org.eclipse.jface.text.link.LinkedPositionGroup;
+import org.eclipse.jface.text.link.ProposalPosition;
+import org.eclipse.jface.text.link.LinkedModeUI.ExitFlags;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.text.edits.MalformedTreeException;
+import org.eclipse.text.edits.TextEdit;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.texteditor.link.EditorLinkedModeUI;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.ICCompletionProposal;
+
+import org.eclipse.cdt.internal.corext.fix.LinkedProposalModel;
+import org.eclipse.cdt.internal.corext.fix.LinkedProposalPositionGroup;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.editor.EditorHighlightingSynchronizer;
+
+/**
+ * Does the setup of the linked mode from a {@link LinkedProposalModel}
+ */
+public class LinkedProposalModelPresenter {
+       
+       public LinkedProposalModelPresenter() {
+       }
+       
+       public void enterLinkedMode(ITextViewer viewer, IEditorPart editor, LinkedProposalModel linkedProposalModel) throws BadLocationException {
+               IDocument document= viewer.getDocument();
+
+               LinkedModeModel model= new LinkedModeModel();
+               boolean added= false;
+
+               Iterator<LinkedProposalPositionGroup> iterator= linkedProposalModel.getPositionGroupIterator();
+               while (iterator.hasNext()) {
+                       LinkedProposalPositionGroup curr= iterator.next();
+
+                       LinkedPositionGroup group= new LinkedPositionGroup();
+
+                       LinkedProposalPositionGroup.PositionInformation[] positions= curr.getPositions();
+                       if (positions.length > 0) {
+                               LinkedProposalPositionGroup.Proposal[] linkedModeProposals= curr.getProposals();
+                               if (linkedModeProposals.length <= 1) {
+                                       for (int i= 0; i < positions.length; i++) {
+                                               LinkedProposalPositionGroup.PositionInformation pos= positions[i];
+                                               if (pos.getOffset() != -1) {
+                                                       group.addPosition(new LinkedPosition(document, pos.getOffset(), pos.getLength(), pos.getSequenceRank()));
+                                               }
+                                       }
+                               } else {
+                                       LinkedPositionProposalImpl[] proposalImpls= new LinkedPositionProposalImpl[linkedModeProposals.length];
+                                       for (int i= 0; i < linkedModeProposals.length; i++) {
+                                               proposalImpls[i]= new LinkedPositionProposalImpl(linkedModeProposals[i], model);
+                                       }
+
+                                       for (int i= 0; i < positions.length; i++) {
+                                               LinkedProposalPositionGroup.PositionInformation pos= positions[i];
+                                               if (pos.getOffset() != -1) {
+                                                       group.addPosition(new ProposalPosition(document, pos.getOffset(), pos.getLength(), pos.getSequenceRank(), proposalImpls));
+                                               }
+                                       }
+                               }
+                               model.addGroup(group);
+                               added= true;
+                       }
+               }
+
+               model.forceInstall();
+
+               if (editor instanceof CEditor) {
+                       model.addLinkingListener(new EditorHighlightingSynchronizer((CEditor) editor));
+               }
+
+               if (added) { // only set up UI if there are any positions set
+                       LinkedModeUI ui= new EditorLinkedModeUI(model, viewer);
+                       LinkedProposalPositionGroup.PositionInformation endPosition= linkedProposalModel.getEndPosition();
+                       if (endPosition != null && endPosition.getOffset() != -1) {
+                               ui.setExitPosition(viewer, endPosition.getOffset() + endPosition.getLength(), 0, Integer.MAX_VALUE);
+                       } else {
+                               int cursorPosition= viewer.getSelectedRange().x;
+                               if (cursorPosition != 0) {
+                                       ui.setExitPosition(viewer, cursorPosition, 0, Integer.MAX_VALUE);
+                               }
+                       }
+                       ui.setExitPolicy(new LinkedModeExitPolicy());
+                       ui.enter();
+
+                       IRegion region= ui.getSelectedRegion();
+                       viewer.setSelectedRange(region.getOffset(), region.getLength());
+                       viewer.revealRange(region.getOffset(), region.getLength());
+               }
+       }
+
+       private static class LinkedPositionProposalImpl implements ICompletionProposalExtension2, ICCompletionProposal {
+               private final LinkedProposalPositionGroup.Proposal fProposal;
+               private final LinkedModeModel fLinkedPositionModel;
+
+               public LinkedPositionProposalImpl(LinkedProposalPositionGroup.Proposal proposal, LinkedModeModel model) {
+                       fProposal= proposal;
+                       fLinkedPositionModel= model;
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#apply(org.eclipse.jface.text.ITextViewer, char, int, int)
+                */
+               public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
+                       IDocument doc= viewer.getDocument();
+                       LinkedPosition position= fLinkedPositionModel.findPosition(new LinkedPosition(doc, offset, 0));
+                       if (position != null) {
+                               try {
+                                       try {
+                                               TextEdit edit= fProposal.computeEdits(offset, position, trigger, stateMask, fLinkedPositionModel);
+                                               if (edit != null) {
+                                                       edit.apply(position.getDocument(), 0);
+                                               }
+                                       } catch (MalformedTreeException e) {
+                                               throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.ERROR, "Unexpected exception applying edit", e)); //$NON-NLS-1$
+                                       } catch (BadLocationException e) {
+                                               throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.ERROR, "Unexpected exception applying edit", e)); //$NON-NLS-1$
+                                       }
+                               } catch (CoreException e) {
+                                       CUIPlugin.log(e);
+                               }
+                       }
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
+                */
+               public String getDisplayString() {
+                       return fProposal.getDisplayString();
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage()
+                */
+               public Image getImage() {
+                       return fProposal.getImage();
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.cdt.ui.text.ICCompletionProposal#getRelevance()
+                */
+               public int getRelevance() {
+                       return fProposal.getRelevance();
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument)
+                */
+               public void apply(IDocument document) {
+                       // not called
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo()
+                */
+               public String getAdditionalProposalInfo() {
+                       return fProposal.getAdditionalProposalInfo();
+               }
+
+               public Point getSelection(IDocument document) { return null; }
+               public IContextInformation getContextInformation() { return null; }
+               public void selected(ITextViewer viewer, boolean smartToggle) {}
+               public void unselected(ITextViewer viewer) {}
+
+               /*
+                * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#validate(org.eclipse.jface.text.IDocument, int, org.eclipse.jface.text.DocumentEvent)
+                */
+               public boolean validate(IDocument document, int offset, DocumentEvent event) {
+                       // ignore event
+                       String insert= getDisplayString();
+
+                       int off;
+                       LinkedPosition pos= fLinkedPositionModel.findPosition(new LinkedPosition(document, offset, 0));
+                       if (pos != null) {
+                               off= pos.getOffset();
+                       } else {
+                               off= Math.max(0, offset - insert.length());
+                       }
+                       int length= offset - off;
+
+                       if (offset <= document.getLength()) {
+                               try {
+                                       String content= document.get(off, length);
+                                       if (insert.startsWith(content))
+                                               return true;
+                               } catch (BadLocationException e) {
+                                       CUIPlugin.log(e);
+                                       // and ignore and return false
+                               }
+                       }
+                       return false;
+               }
+
+               public String getIdString() {
+                       return getDisplayString();
+               }
+       }
+       
+       private static class LinkedModeExitPolicy implements LinkedModeUI.IExitPolicy {
+               public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) {
+                       if (event.character  == '=') {
+                               return new ExitFlags(ILinkedModeListener.EXIT_ALL, true);
+                       }
+                       return null;
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ListContentProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ListContentProvider.java
new file mode 100644 (file)
index 0000000..a26ea3e
--- /dev/null
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ *  Copyright (c) 2004, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *  IBM Rational Software - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+/** 
+ * A specialized content provider to show a list of editor parts.
+ */ 
+public class ListContentProvider implements IStructuredContentProvider {
+       List<?> fContents;      
+
+       public ListContentProvider() {
+       }
+       
+       public Object[] getElements(Object input) {
+               if (fContents != null && fContents == input)
+                       return fContents.toArray();
+               return new Object[0];
+       }
+
+       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+               if (newInput instanceof List<?>) 
+                       fContents= (List<?>)newInput;
+               else
+                       fContents= null;
+               // we use a fixed set.
+       }
+
+       public void dispose() {
+       }
+       
+       public boolean isDeleted(Object o) {
+               return fContents != null && !fContents.contains(o);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilter.java
new file mode 100644 (file)
index 0000000..8bfb373
--- /dev/null
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Rational Software - initial implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.IDeclaration;
+import org.eclipse.cdt.core.model.IField;
+import org.eclipse.cdt.core.model.IMember;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
+
+
+/**
+ * Filter for the methods viewer.
+ * Changing a filter property does not trigger a refiltering of the viewer
+ */
+
+public class MemberFilter extends ViewerFilter{
+
+       public static final int FILTER_NONPUBLIC= 1;
+       public static final int FILTER_STATIC= 2;
+       public static final int FILTER_FIELDS= 4;
+       public static final int FILTER_INACTIVE= 0x10;
+       
+       /** @deprecated Unsupported filter constant */
+       @Deprecated
+       public static final int FILTER_LOCALTYPES= 8;
+       
+       private int fFilterProperties;
+
+       /**
+        * Modifies filter and add a property to filter for
+        */
+       public final void addFilter(int filter) {
+               fFilterProperties |= filter;
+       }
+       /**
+        * Modifies filter and remove a property to filter for
+        */     
+       public final void removeFilter(int filter) {
+               fFilterProperties &= (-1 ^ filter);
+       }
+       /**
+        * Tests if a property is filtered
+        */             
+       public final boolean hasFilter(int filter) {
+               return (fFilterProperties & filter) != 0;
+       }
+       
+       /*
+        * @see ViewerFilter@isFilterProperty
+        */
+       public boolean isFilterProperty(Object element, Object property) {
+               return false;
+       }
+       /*
+        * @see ViewerFilter@select
+        */             
+       @Override
+       public boolean select(Viewer viewer, Object parentElement, Object element) {
+               if(element instanceof IDeclaration){
+                       try {
+                               IDeclaration declaration = (IDeclaration) element;
+                               if (hasFilter(FILTER_STATIC) && (declaration.isStatic()) ) {
+                                       return false;
+                               }
+                               if (element instanceof IMember) {
+                                       IMember member= (IMember)element;
+                                       if (hasFilter(FILTER_NONPUBLIC) && (member.getVisibility() != ASTAccessVisibility.PUBLIC)) {
+                                               return false;
+                                       }
+                                       
+                                       if (hasFilter(FILTER_FIELDS) && element instanceof IField) {
+                                               return false;
+                                       }                                       
+                               }
+                       } catch (CModelException e) {
+                               // ignore
+                       }
+               }
+               if (hasFilter(FILTER_INACTIVE)) {
+                       if (element instanceof ISourceReference && !((ISourceReference) element).isActive()) {
+                               return false;
+                       }
+               }
+               return true;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilterAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/MemberFilterAction.java
new file mode 100644 (file)
index 0000000..24c91fc
--- /dev/null
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Rational Software - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.ui.actions.MemberFilterActionGroup;
+
+/**
+ * Action used to enable / disable method filter properties
+ */
+
+public class MemberFilterAction extends Action {
+
+       private int fFilterProperty;
+       private MemberFilterActionGroup fFilterActionGroup;
+       
+       public MemberFilterAction(MemberFilterActionGroup actionGroup, String title, int property, String contextHelpId, boolean initValue) {
+               super(title);
+               fFilterActionGroup= actionGroup;
+               fFilterProperty= property;
+               
+               if (contextHelpId != null) {
+                       PlatformUI.getWorkbench().getHelpSystem().setHelp(this, contextHelpId);
+               }
+               setChecked(initValue);
+       }
+       
+       /**
+        * Returns this action's filter property.
+        */
+       public int getFilterProperty() {
+               return fFilterProperty;
+       }
+       
+       /*
+        * @see Action#actionPerformed
+        */
+       @Override
+       public void run() {     
+               fFilterActionGroup.setMemberFilter(fFilterProperty, isChecked());
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/Messages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/Messages.java
new file mode 100644 (file)
index 0000000..13eecf1
--- /dev/null
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+       private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.viewsupport.messages"; //$NON-NLS-1$
+       public static String EditorOpener_fileDoesNotExist;
+       public static String IndexedFilesCache_jobName;
+       public static String IndexUI_infoNotInIndex;
+       public static String IndexUI_infoNotInSource;
+       public static String IndexUI_infoSelectIndexAllFiles;
+       public static String SelectionListenerWithASTManager_jobName;
+       static {
+               // initialize resource bundle
+               NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+       }
+
+       private Messages() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProblemsLabelDecorator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProblemsLabelDecorator.java
new file mode 100644 (file)
index 0000000..17232c4
--- /dev/null
@@ -0,0 +1,396 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceStatus;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IBaseLabelProvider;
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.jface.viewers.ILabelDecorator;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ILightweightLabelDecorator;
+import org.eclipse.jface.viewers.LabelProviderChangedEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.ui.texteditor.MarkerUtilities;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ISourceRange;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.ui.CElementImageDescriptor;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.util.IProblemChangedListener;
+import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;
+
+/**
+ * LabelDecorator that decorates an element's image with error and warning overlays that 
+ * represent the severity of markers attached to the element's underlying resource. To see 
+ * a problem decoration for a marker, the marker needs to be a subtype of <code>IMarker.PROBLEM</code>.
+ * <p>
+ * Note: Only images for elements in Java projects are currently updated on marker changes.
+ * </p>
+ * 
+ * @since 2.0
+ */
+public class ProblemsLabelDecorator implements ILabelDecorator, ILightweightLabelDecorator {
+       
+       /**
+        * This is a special <code>LabelProviderChangedEvent</code> carring additional 
+        * information whether the event orgins from a maker change.
+        * <p>
+        * <code>ProblemsLabelChangedEvent</code>s are only generated by <code>
+        * ProblemsLabelDecorator</code>s.
+        * </p>
+        */
+       public static class ProblemsLabelChangedEvent extends LabelProviderChangedEvent {
+
+               private boolean fMarkerChange;
+
+               /**
+                * Note: This constructor is for internal use only. Clients should not call this constructor.
+                */
+               public ProblemsLabelChangedEvent(IBaseLabelProvider source, IResource[] changedResource, boolean isMarkerChange) {
+                       super(source, changedResource);
+                       fMarkerChange= isMarkerChange;
+               }
+               
+               /**
+                * Returns whether this event origins from marker changes. If <code>false</code> an annotation 
+                * model change is the origin. In this case viewers not displaying working copies can ignore these 
+                * events.
+                * 
+                * @return if this event origins from a marker change.
+                */
+               public boolean isMarkerChange() {
+                       return fMarkerChange;
+               }
+
+       }
+
+       private static final int ERRORTICK_WARNING= CElementImageDescriptor.WARNING;
+       private static final int ERRORTICK_ERROR= CElementImageDescriptor.ERROR;        
+       private static final int TICK_CONFIGURATION = CElementImageDescriptor.SETTINGS; 
+       
+       private ImageDescriptorRegistry fRegistry;
+       private boolean fUseNewRegistry= false;
+       private IProblemChangedListener fProblemChangedListener;
+       
+       private ListenerList fListeners;
+
+       /**
+        * Creates a new <code>ProblemsLabelDecorator</code>.
+        */
+       public ProblemsLabelDecorator() {
+               this(null);
+               fUseNewRegistry= true;
+       }
+       
+       /*
+        * Creates decorator with a shared image registry.
+        * 
+        * @param registry The registry to use or <code>null</code> to use the Java plugin's
+        * image registry.
+        */
+       /**
+        * Note: This constructor is for internal use only. Clients should not call this constructor.
+        */
+       public ProblemsLabelDecorator(ImageDescriptorRegistry registry) {
+               fRegistry= registry;
+               fProblemChangedListener= null;
+       }
+       
+       private ImageDescriptorRegistry getRegistry() {
+               if (fRegistry == null) {
+                       fRegistry= fUseNewRegistry ? new ImageDescriptorRegistry() : CUIPlugin.getImageDescriptorRegistry();
+               }
+               return fRegistry;
+       }
+       
+
+       /* (non-Javadoc)
+        * @see ILabelDecorator#decorateText(String, Object)
+        */
+       public String decorateText(String text, Object element) {
+               return text;
+       }       
+
+       /* (non-Javadoc)
+        * @see ILabelDecorator#decorateImage(Image, Object)
+        */
+       public Image decorateImage(Image image, Object obj) {
+               int adornmentFlags= computeAdornmentFlags(obj);
+               if (adornmentFlags != 0) {
+                       ImageDescriptor baseImage= new ImageImageDescriptor(image);
+                       Rectangle bounds= image.getBounds();
+                       return getRegistry().get(new CElementImageDescriptor(baseImage, adornmentFlags, new Point(bounds.width, bounds.height)));
+               }
+               return image;
+       }
+
+       /**
+        * Note: This method is for internal use only. Clients should not call this method.
+        */
+       protected int computeAdornmentFlags(Object obj) {
+               try {
+                       if (obj instanceof ICElement) {
+                               ICElement element= (ICElement) obj;
+                               int type= element.getElementType();
+                               switch (type) {
+                                       case ICElement.C_PROJECT:
+                                       case ICElement.C_CCONTAINER:
+                                               return getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_INFINITE, null) | getTicks(element.getResource());
+                                       case ICElement.C_UNIT:
+                                               return getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_ONE, null) | getTicks(element.getResource());
+                                       case ICElement.C_FUNCTION:
+                                       case ICElement.C_CLASS:
+                                       case ICElement.C_UNION:
+                                       case ICElement.C_STRUCT:
+                                       case ICElement.C_VARIABLE:
+                                       case ICElement.C_METHOD:
+                                               ITranslationUnit tu= ((ISourceReference)element).getTranslationUnit();
+                                               if (tu != null && tu.exists()) {
+                                                       return getErrorTicksFromMarkers(tu.getResource(), IResource.DEPTH_ONE, (ISourceReference)element);
+                                               }
+                                               break;
+                               }
+                       } else if (obj instanceof IResource) {
+                               return getErrorTicksFromMarkers((IResource) obj, IResource.DEPTH_INFINITE, null) | getTicks((IResource)obj);
+                       }
+               } catch (CoreException e) {
+                       if (e instanceof CModelException) {
+//                             if (((CModelException) e).isDoesNotExist()) {
+//                                     return 0;
+//                             }
+                       }
+                       if (e.getStatus().getCode() == IResourceStatus.MARKER_NOT_FOUND) {
+                               return 0;
+                       }
+                       
+                       CUIPlugin.log(e);
+               }
+               return 0;
+       }
+
+       private int getErrorTicksFromMarkers(IResource res, int depth, ISourceReference sourceElement) throws CoreException {
+               if (res == null || !res.isAccessible()) {
+                       return 0;
+               }
+               int info= 0;
+               
+               IMarker[] markers= res.findMarkers(IMarker.PROBLEM, true, depth);
+               if (markers != null) {
+                       for (int i= 0; i < markers.length && (info != ERRORTICK_ERROR); i++) {
+                               IMarker curr= markers[i];
+                               if (sourceElement == null || isMarkerInRange(curr, sourceElement)) {
+                                       int priority= curr.getAttribute(IMarker.SEVERITY, -1);
+                                       if (priority == IMarker.SEVERITY_WARNING) {
+                                               info= ERRORTICK_WARNING;
+                                       } else if (priority == IMarker.SEVERITY_ERROR) {
+                                               info= ERRORTICK_ERROR;
+                                       }
+                               }
+                       }                       
+               }
+               return info;
+       }
+
+       private boolean isMarkerInRange(IMarker marker, ISourceReference sourceElement) throws CoreException {
+               if (marker.isSubtypeOf(IMarker.TEXT)) {
+                       int pos= marker.getAttribute(IMarker.CHAR_START, -1);
+                       if (pos == -1) {
+                               int line= MarkerUtilities.getLineNumber(marker);
+                               if (line >= 0) {
+                                       return isInside( -1, line, sourceElement);
+                               }
+                       }
+                       return isInside(pos, -1, sourceElement);
+                       
+               }
+               return false;
+       }
+       
+       
+//     private int getErrorTicksFromWorkingCopy(ITranslationUnit original, ISourceReference sourceElement) throws CoreException {
+//             int info= 0;
+//             FileEditorInput editorInput= new FileEditorInput((IFile) original.getResource());
+//             IAnnotationModel model= CUIPlugin.getDefault().getTranslationUnitDocumentProvider().getAnnotationModel(editorInput);
+//             if (model != null) {
+//                     Iterator iter= model.getAnnotationIterator();
+//                     while ((info != ERRORTICK_ERROR) && iter.hasNext()) {
+//                             Annotation curr= (Annotation) iter.next();
+//                             IMarker marker= isAnnotationInRange(model, curr, sourceElement);
+//                             if (marker != null) {
+//                                     int priority= marker.getAttribute(IMarker.SEVERITY, -1);
+//                                     if (priority == IMarker.SEVERITY_WARNING) {
+//                                             info= ERRORTICK_WARNING;
+//                                     } else if (priority == IMarker.SEVERITY_ERROR) {
+//                                             info= ERRORTICK_ERROR;
+//                                     }
+//                             }
+//                     }
+//             }
+//             return info;
+//     }
+                       
+//     private IMarker isAnnotationInRange(IAnnotationModel model, Annotation annot, ISourceReference sourceElement) throws CoreException {
+//             if (annot instanceof MarkerAnnotation) {
+//                     IMarker marker= ((MarkerAnnotation) annot).getMarker();
+//                     if (marker.exists() && marker.isSubtypeOf(IMarker.PROBLEM)) {
+//                             Position pos= model.getPosition(annot);
+//                             if (pos != null && (sourceElement == null || isInside(pos.getOffset(), -1, sourceElement))) {
+//                                     return marker;
+//                             }
+//                     }
+//             }
+//             return null;
+//     }
+       
+       /**
+        * Tests if a position is inside the source range of an element. Usually this is done
+        * by looking at the offset. In case the offset equals <code>-1</code>, the line is 
+        * tested.
+        * @param offSet offset to be tested
+        * @param line line to be tested
+        * @param sourceElement Source element (must be a ICElement)
+        * @return boolean Return <code>true</code> if position is located inside the source element.
+        * @throws CoreException Exception thrown if element range could not be accessed.
+        * 
+        * @since 2.1
+        */
+       protected boolean isInside(int offSet, int line, ISourceReference sourceElement) throws CoreException {
+               ISourceRange range= sourceElement.getSourceRange();
+               if (range != null) {
+                       if (offSet ==-1) {
+                               return (line >= range.getStartLine() && line <= range.getEndLine());
+                       }
+                       int rangeOffset= range.getStartPos();
+                       return (rangeOffset <= offSet && rangeOffset + range.getLength() > offSet);                     
+               }
+               return false;
+       }       
+       
+       /* (non-Javadoc)
+        * @see IBaseLabelProvider#dispose()
+        */
+       public void dispose() {
+               if (fProblemChangedListener != null) {
+                       CUIPlugin.getDefault().getProblemMarkerManager().removeListener(fProblemChangedListener);
+                       fProblemChangedListener= null;
+               }
+               if (fRegistry != null && fUseNewRegistry) {
+                       fRegistry.dispose();
+               }
+       }
+
+       /* (non-Javadoc)
+        * @see IBaseLabelProvider#isLabelProperty(Object, String)
+        */
+       public boolean isLabelProperty(Object element, String property) {
+               return true;
+       }
+       
+       /* (non-Javadoc)
+        * @see IBaseLabelProvider#addListener(ILabelProviderListener)
+        */
+       public void addListener(ILabelProviderListener listener) {
+               if (fListeners == null) {
+                       fListeners= new ListenerList();
+               }
+               fListeners.add(listener);
+               if (fProblemChangedListener == null) {
+                       fProblemChangedListener= new IProblemChangedListener() {
+                               public void problemsChanged(IResource[] changedResources, boolean isMarkerChange) {
+                                       fireProblemsChanged(changedResources, isMarkerChange);
+                               }
+                       };
+                       CUIPlugin.getDefault().getProblemMarkerManager().addListener(fProblemChangedListener);
+               }
+       }       
+
+       /* (non-Javadoc)
+        * @see IBaseLabelProvider#removeListener(ILabelProviderListener)
+        */
+       public void removeListener(ILabelProviderListener listener) {
+               if (fListeners != null) {
+                       fListeners.remove(listener);
+                       if (fListeners.isEmpty() && fProblemChangedListener != null) {
+                               CUIPlugin.getDefault().getProblemMarkerManager().removeListener(fProblemChangedListener);
+                               fProblemChangedListener= null;
+                       }
+               }
+       }
+       
+       protected void fireProblemsChanged(IResource[] changedResources, boolean isMarkerChange) {
+               if (fListeners != null && !fListeners.isEmpty()) {
+                       LabelProviderChangedEvent event= new ProblemsLabelChangedEvent(this, changedResources, isMarkerChange);
+                       Object[] listeners= fListeners.getListeners();
+                       for (Object listener : listeners) {
+                               ((ILabelProviderListener) listener).labelProviderChanged(event);
+                       }
+               }
+       }
+               
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object, org.eclipse.jface.viewers.IDecoration)
+        */
+       public void decorate(Object element, IDecoration decoration) { 
+               int adornmentFlags= computeAdornmentFlags(element);
+
+               if ((adornmentFlags & TICK_CONFIGURATION) != 0) {
+                       decoration.addOverlay(CPluginImages.DESC_OVR_SETTING);
+                       adornmentFlags &= ~TICK_CONFIGURATION;
+               }
+               
+               if (adornmentFlags == ERRORTICK_ERROR) {
+                       decoration.addOverlay(CPluginImages.DESC_OVR_ERROR);
+               } else if (adornmentFlags == ERRORTICK_WARNING) {
+                       decoration.addOverlay(CPluginImages.DESC_OVR_WARNING);
+               }  
+       }
+
+       /**
+        * @param rc - resource to check
+        * @return flags {@link TICK_CONFIGURATION} if the resource has custom settings and possibly needs
+        * to be adorned or 0 otherwise.
+        */
+       private int getTicks (IResource rc) {
+               if (rc == null || rc instanceof IProject)
+                       return 0;
+
+               int result = 0;
+               ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(rc.getProject(), false);
+               if (prjDescription != null) {
+                       ICConfigurationDescription cfgDescription = prjDescription.getDefaultSettingConfiguration();
+                       if (cfgDescription != null) {
+                               IPath path = rc.getProjectRelativePath();
+                               ICResourceDescription rcDescription = cfgDescription.getResourceDescription(path, true);
+                               if (rcDescription != null)
+                                       result |= TICK_CONFIGURATION;
+                       }
+               }
+               return result;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProjectTemplateStore.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/ProjectTemplateStore.java
new file mode 100644 (file)
index 0000000..393fd8c
--- /dev/null
@@ -0,0 +1,199 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.text.templates.Template;
+import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData;
+import org.eclipse.jface.text.templates.persistence.TemplateReaderWriter;
+import org.eclipse.jface.text.templates.persistence.TemplateStore;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * @since 5.0
+ */
+public final class ProjectTemplateStore {
+       
+       private static final String KEY= "org.eclipse.cdt.ui.text.custom_code_templates"; //$NON-NLS-1$
+
+       private final TemplateStore fInstanceStore;
+       private final TemplateStore fProjectStore;
+       
+       public ProjectTemplateStore(IProject project) {
+               fInstanceStore= CUIPlugin.getDefault().getCodeTemplateStore();
+               if (project == null) {
+                       fProjectStore= null;
+               } else {
+                       final ScopedPreferenceStore projectSettings= new ScopedPreferenceStore(new ProjectScope(project), CUIPlugin.PLUGIN_ID);
+                       fProjectStore= new TemplateStore(projectSettings, KEY) {
+                               /*
+                                * Make sure we keep the id of added code templates - add removes
+                                * it in the usual add() method
+                                */
+                               @Override
+                               public void add(TemplatePersistenceData data) {
+                                       if (data.isUserAdded()) {
+                                               super.add(data);
+                                       } else {
+                                               internalAdd(data);
+                                       }
+                               }
+                               
+                               @Override
+                               public void save() throws IOException {
+                                       
+                                       StringWriter output= new StringWriter();
+                                       TemplateReaderWriter writer= new TemplateReaderWriter();
+                                       writer.save(getTemplateData(false), output);
+                                       
+                                       projectSettings.setValue(KEY, output.toString());
+                                       projectSettings.save();
+                               }
+                       };
+               }
+       }
+       
+       public static boolean hasProjectSpecificTempates(IProject project) {
+               String pref= new ProjectScope(project).getNode(CUIPlugin.PLUGIN_ID).get(KEY, null);
+               if (pref != null && pref.trim().length() > 0) {
+                       Reader input= new StringReader(pref);
+                       TemplateReaderWriter reader= new TemplateReaderWriter();
+                       TemplatePersistenceData[] datas;
+                       try {
+                               datas= reader.read(input);
+                               return datas.length > 0;
+                       } catch (IOException e) {
+                               // ignore
+                       }
+               }
+               return false;
+       }
+       
+       
+       public TemplatePersistenceData[] getTemplateData() {
+               if (fProjectStore != null) {
+                       return fProjectStore.getTemplateData(true);
+               }
+               return fInstanceStore.getTemplateData(true);
+       }
+       
+       public Template findTemplateById(String id) {
+               Template template= null;
+               if (fProjectStore != null)
+                       template= fProjectStore.findTemplateById(id);
+               if (template == null)
+                       template= fInstanceStore.findTemplateById(id);
+               
+               return template;
+       }
+       
+       public void load() throws IOException {
+               if (fProjectStore != null) {
+                       fProjectStore.load();
+                       
+                       Set<String> datas= new HashSet<String>();
+                       TemplatePersistenceData[] data= fProjectStore.getTemplateData(false);
+                       for (TemplatePersistenceData element : data) {
+                               String id= element.getId();
+                               if (id == null) {
+                                       id= element.getTemplate().getName();
+                               }
+                               datas.add(id);
+                       }
+                       
+                       data= fInstanceStore.getTemplateData(false);
+                       for (TemplatePersistenceData orig : data) {
+                               String origId= orig.getId();
+                               if (origId == null) {
+                                       origId= orig.getTemplate().getName();
+                               }
+                               if (!datas.contains(orig.getId())) {
+                                       TemplatePersistenceData copy= new TemplatePersistenceData(new Template(orig.getTemplate()), orig.isEnabled(), orig.getId());
+                                       fProjectStore.add(copy);
+                                       copy.setDeleted(true);
+                               }
+                       }
+               }
+       }
+       
+       public boolean isProjectSpecific(String id) {
+               if (id == null) {
+                       return false;
+               }
+               
+               if (fProjectStore == null)
+                       return false;
+               
+               return fProjectStore.findTemplateById(id) != null;
+       }
+       
+       
+       public void setProjectSpecific(String id, boolean projectSpecific) {
+               Assert.isNotNull(fProjectStore);
+               
+               TemplatePersistenceData data= fProjectStore.getTemplateData(id);
+               if (data == null) {
+                       return; // does not exist
+               }
+               data.setDeleted(!projectSpecific);
+       }
+
+       public void restoreDefaults() {
+               if (fProjectStore == null) {
+                       fInstanceStore.restoreDefaults();
+               } else {
+                       fProjectStore.restoreDefaults();
+               }
+       }
+       
+       public void save() throws IOException {
+               if (fProjectStore == null) {
+                       fInstanceStore.save();
+               } else {
+                       fProjectStore.save();
+               }
+       }
+       
+       public void revertChanges() throws IOException {
+               if (fProjectStore != null) {
+                       // nothing to do
+               } else {
+                       fInstanceStore.load();
+               }
+       }
+
+       public void addTemplateData(TemplatePersistenceData data) {
+               if (fProjectStore != null) {
+                       fProjectStore.add(data);
+               } else {
+                       fInstanceStore.add(data);
+               }
+       }
+
+       public void delete(TemplatePersistenceData data) {
+               if (fProjectStore != null) {
+                       fProjectStore.delete(data);
+               } else {
+                       fInstanceStore.delete(data);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionListenerWithASTManager.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionListenerWithASTManager.java
new file mode 100644 (file)
index 0000000..033c1ed
--- /dev/null
@@ -0,0 +1,233 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.ILock;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.text.ISelectionValidator;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
+
+import org.eclipse.cdt.internal.ui.editor.ASTProvider;
+
+/**
+ * Infrastructure to share an AST for editor post selection listeners.
+ */
+public class SelectionListenerWithASTManager {
+       private static SelectionListenerWithASTManager fgDefault;
+       
+       /**
+        * @return Returns the default manager instance.
+        */
+       public static SelectionListenerWithASTManager getDefault() {
+               if (fgDefault == null) {
+                       fgDefault= new SelectionListenerWithASTManager();
+               }
+               return fgDefault;
+       }
+       
+       private final static class PartListenerGroup {
+               private ITextEditor fPart;
+               private ISelectionListener fPostSelectionListener;
+               private ISelectionChangedListener fSelectionListener;
+               private Job fCurrentJob;
+               private ListenerList fAstListeners;
+               /** Rule to make sure only one job is running at a time */
+               private final ILock fJobLock= Job.getJobManager().newLock();
+               private ISelectionValidator fValidator;
+               
+               public PartListenerGroup(ITextEditor editorPart) {
+                       fPart= editorPart;
+                       fCurrentJob= null;
+                       fAstListeners= new ListenerList(ListenerList.IDENTITY);
+                       
+                       fSelectionListener= new ISelectionChangedListener() {
+                               public void selectionChanged(SelectionChangedEvent event) {
+                                       ISelection selection= event.getSelection();
+                                       if (selection instanceof ITextSelection) {
+                                               fireSelectionChanged((ITextSelection) selection);
+                                       }
+                               }
+                       };
+                       
+                       fPostSelectionListener= new ISelectionListener() {
+                               public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+                                       if (part == fPart && selection instanceof ITextSelection)
+                                               firePostSelectionChanged((ITextSelection) selection);
+                               }
+                       };
+               }
+
+               public boolean isEmpty() {
+                       return fAstListeners.isEmpty();
+               }
+
+               public void install(ISelectionListenerWithAST listener) {
+                       if (isEmpty()) {
+                               fPart.getEditorSite().getPage().addPostSelectionListener(fPostSelectionListener);
+                               ISelectionProvider selectionProvider= fPart.getSelectionProvider();
+                               if (selectionProvider != null) {
+                                       selectionProvider.addSelectionChangedListener(fSelectionListener);
+                                       if (selectionProvider instanceof ISelectionValidator) {
+                                               fValidator= (ISelectionValidator) selectionProvider;
+                                       }
+                               }
+                       }
+                       fAstListeners.add(listener);
+               }
+               
+               public void uninstall(ISelectionListenerWithAST listener) {
+                       fAstListeners.remove(listener);
+                       if (isEmpty()) {
+                               fPart.getEditorSite().getPage().removePostSelectionListener(fPostSelectionListener);
+                               ISelectionProvider selectionProvider= fPart.getSelectionProvider();
+                               if (selectionProvider != null) {
+                                       selectionProvider.removeSelectionChangedListener(fSelectionListener);
+                               }
+                               fValidator= null;
+                       }
+               }
+               
+               public void fireSelectionChanged(final ITextSelection selection) {
+                       if (fCurrentJob != null) {
+                               fCurrentJob.cancel();
+                       }
+               }
+               
+               public void firePostSelectionChanged(final ITextSelection selection) {
+                       if (fCurrentJob != null) {
+                               fCurrentJob.cancel();
+                       }
+                       
+                       final IWorkingCopy workingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(fPart.getEditorInput());
+                       if (workingCopy == null)
+                               return;
+                       
+                       fCurrentJob= new Job(Messages.SelectionListenerWithASTManager_jobName) { 
+                               @Override
+                               public IStatus run(IProgressMonitor monitor) {
+                                       try {
+                                               // Try to acquire the lock
+                                               while (!monitor.isCanceled() && !fJobLock.acquire(10)) {}
+                                               if (!monitor.isCanceled() && isSelectionValid(selection)) {
+                                                       return calculateASTandInform(workingCopy, selection, monitor);
+                                               }
+                                       } catch (InterruptedException e) {
+                                       } finally {
+                                               if (fJobLock.getDepth() != 0)
+                                                       fJobLock.release();
+                                       }
+                                       return Status.OK_STATUS;
+                               }
+                       };
+                       fCurrentJob.setPriority(Job.DECORATE);
+                       fCurrentJob.setSystem(true);
+                       fCurrentJob.schedule();
+               }
+
+               /**
+                * Verify that selection is still valid.
+                * 
+                * @param selection
+                * @return <code>true</code> if selection is valid
+                */
+               protected boolean isSelectionValid(ITextSelection selection) {
+                       return fValidator == null || fValidator.isValid(selection);
+               }
+
+               protected IStatus calculateASTandInform(final IWorkingCopy workingCopy, final ITextSelection selection, final IProgressMonitor monitor) {
+                       return ASTProvider.getASTProvider().runOnAST(workingCopy, ASTProvider.WAIT_ACTIVE_ONLY, monitor, new ASTRunnable() {
+                               public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) {
+                                       if (astRoot != null && !monitor.isCanceled() && isSelectionValid(selection)) {
+                                               Object[] listeners;
+                                               synchronized (PartListenerGroup.this) {
+                                                       listeners= fAstListeners.getListeners();
+                                               }
+                                               for (int i= 0; i < listeners.length; i++) {
+                                                       final Object l = listeners[i];
+                                                       try {
+                                                               ((ISelectionListenerWithAST) l).selectionChanged(fPart, selection, astRoot);
+                                                       } catch (RuntimeException e) {
+                                                               CUIPlugin.log(e);
+                                                               fAstListeners.remove(l);
+                                                       } catch (OutOfMemoryError e) {
+                                                               CUIPlugin.log(e);
+                                                               fAstListeners.remove(l);
+                                                       }
+                                               }
+                                               return Status.OK_STATUS;
+                                       }
+                                       return Status.CANCEL_STATUS;
+                               }
+                       });
+               }
+       }
+       
+       private Map<ITextEditor, PartListenerGroup> fListenerGroups;
+       
+       private SelectionListenerWithASTManager() {
+               fListenerGroups= new HashMap<ITextEditor, PartListenerGroup>();
+       }
+       
+       /**
+        * Registers a selection listener for the given editor part.
+        * @param part The editor part to listen to.
+        * @param listener The listener to register.
+        */
+       public void addListener(ITextEditor part, ISelectionListenerWithAST listener) {
+               synchronized (this) {
+                       PartListenerGroup partListener= fListenerGroups.get(part);
+                       if (partListener == null) {
+                               partListener= new PartListenerGroup(part);
+                               fListenerGroups.put(part, partListener);
+                       }
+                       partListener.install(listener);
+               }
+       }
+
+       /**
+        * Unregisters a selection listener.
+        * @param part The editor part the listener was registered.
+        * @param listener The listener to unregister.
+        */
+       public void removeListener(ITextEditor part, ISelectionListenerWithAST listener) {
+               synchronized (this) {
+                       PartListenerGroup partListener= fListenerGroups.get(part);
+                       if (partListener != null) {
+                               partListener.uninstall(listener);
+                               if (partListener.isEmpty()) {
+                                       fListenerGroups.remove(part);
+                               }
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionProviderMediator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/SelectionProviderMediator.java
new file mode 100644 (file)
index 0000000..d2a70a9
--- /dev/null
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.widgets.Control;
+
+public class SelectionProviderMediator implements ISelectionProvider {
+       private Map<Control, ISelectionProvider> fProviders= new HashMap<Control, ISelectionProvider>();
+       private ISelectionProvider fActiveProvider = null;
+       private ISelectionChangedListener fSelectionChangedListener;
+       private FocusListener fFocusListener;
+
+    private ListenerList fListenerList= new ListenerList();
+
+       public SelectionProviderMediator() {
+               fSelectionChangedListener= new ISelectionChangedListener() {
+                       public void selectionChanged(SelectionChangedEvent event) {
+                               onSelectionChanged(event);
+                       }
+               };
+               fFocusListener = new FocusListener() {
+                       public void focusGained(FocusEvent e) {
+                               onFocusGained(e);
+                       }
+                       public void focusLost(FocusEvent e) {
+                       }
+               };
+       }
+
+    final public void addSelectionChangedListener(ISelectionChangedListener listener) {
+       fListenerList.add(listener);
+    }
+
+    final public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+       fListenerList.remove(listener);
+    }
+
+       final protected void fireSelectionChanged() {
+               Object[] listeners= fListenerList.getListeners();
+               if (listeners.length > 0) {
+                       SelectionChangedEvent event= new SelectionChangedEvent(this, getSelection());
+                       
+                       for (int i = 0; i < listeners.length; i++) {
+                               ISelectionChangedListener listener= (ISelectionChangedListener) listeners[i];
+                               listener.selectionChanged(event);
+                       }
+               }
+       }
+           
+       public void addViewer(Viewer viewer) {
+               addSelectionProvider(viewer.getControl(), viewer);
+       }
+
+       public void addSelectionProvider(Control ctrl, ISelectionProvider sp) {
+               fProviders.put(ctrl, sp);
+               sp.addSelectionChangedListener(fSelectionChangedListener);
+               ctrl.addFocusListener(fFocusListener);
+       }
+
+       // overrider
+       public ISelection getSelection() {
+               if (fActiveProvider != null) {
+                       return fActiveProvider.getSelection();
+               }
+               return StructuredSelection.EMPTY;
+       }
+       // overrider
+       public void setSelection(ISelection selection) {
+               if (fActiveProvider != null) {
+                       fActiveProvider.setSelection(selection);
+               }
+       }
+
+       protected void onFocusGained(FocusEvent e) {
+               ISelectionProvider provider= fProviders.get(e.widget);
+               if (provider != null) {
+                       fActiveProvider= provider;
+                       fireSelectionChanged();
+               }
+       }
+
+       protected void onSelectionChanged(SelectionChangedEvent event) {
+               if (event.getSelectionProvider() == fActiveProvider) {
+                       fireSelectionChanged();
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StandardCElementLabelProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StandardCElementLabelProvider.java
new file mode 100644 (file)
index 0000000..aa7745a
--- /dev/null
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+import org.eclipse.cdt.ui.CElementLabelProvider;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+
+/**
+ * CElementLabelProvider that respects settings from the Appearance preference page.
+ * Triggers a viewer update when a preference changes.
+ * 
+ * @deprecated Use {@link AppearanceAwareLabelProvider} instead.
+ */
+@Deprecated
+public class StandardCElementLabelProvider extends AppearanceAwareLabelProvider {
+
+       /**
+        * Constructor for StandardCElementLabelProvider.
+        * @see CElementLabelProvider#CElementLabelProvider()
+        */
+       public StandardCElementLabelProvider(int textFlags, int imageFlags) {
+               super(textFlags, imageFlags);
+               initMasks();
+               CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
+       }
+
+       /**
+        * Creates a StandardCElementLabelProvider with DEFAULT_TEXTFLAGS, DEFAULT_IMAGEFLAGS
+        * and the ErrorTickAdornmentProvider.
+        */     
+       public StandardCElementLabelProvider() {
+               super();
+       }
+       
+       private void initMasks() {
+               // turn on or off the flags depending on property/preference changes.
+       }
+
+       /*
+        * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
+        */
+       @Override
+       public void propertyChange(PropertyChangeEvent event) {
+               //String property= event.getProperty();
+               /* if (property.equals(AppearancePreferencePage.PREF_METHOD_RETURNTYPE)
+                               || property.equals(AppearancePreferencePage.PREF_OVERRIDE_INDICATOR)
+                               || property.equals(AppearancePreferencePage.PREF_PKG_NAME_PATTERN_FOR_PKG_VIEW)) {
+                       initMasks();
+                       LabelProviderChangedEvent lpEvent= new LabelProviderChangedEvent(this, null); // refresh all
+                       fireLabelProviderChanged(lpEvent);
+               }       */      
+       }
+
+       /*
+        * @see IBaseLabelProvider#dispose()
+        */
+       @Override
+       public void dispose() {
+               CUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
+               super.dispose();
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StatusBarUpdater.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StatusBarUpdater.java
new file mode 100644 (file)
index 0000000..7a1060d
--- /dev/null
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
+
+import org.eclipse.cdt.internal.ui.CUIMessages;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.action.IStatusLineManager;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Add the <code>StatusBarUpdater</code> to your ViewPart to have the statusbar
+ * describing the selected elements.
+ */
+public class StatusBarUpdater implements ISelectionChangedListener {
+       
+       private final long LABEL_FLAGS= CElementLabels.DEFAULT_QUALIFIED | CElementLabels.ROOT_POST_QUALIFIED | CElementLabels.APPEND_ROOT_PATH |
+                       CElementLabels.M_PARAMETER_TYPES | CElementLabels.M_APP_RETURNTYPE | CElementLabels.M_EXCEPTIONS | 
+                       CElementLabels.F_APP_TYPE_SIGNATURE;
+
+       private IStatusLineManager fStatusLineManager;
+       
+       public StatusBarUpdater(IStatusLineManager statusLineManager) {
+               fStatusLineManager= statusLineManager;
+       }
+               
+       /*
+        * @see ISelectionChangedListener#selectionChanged
+        */
+       public void selectionChanged(SelectionChangedEvent event) {
+               String statusBarMessage= formatMessage(event.getSelection());
+               fStatusLineManager.setMessage(statusBarMessage);
+       }
+       
+       
+       protected String formatMessage(ISelection sel) {
+               if (sel instanceof IStructuredSelection && !sel.isEmpty()) {
+                       IStructuredSelection selection= (IStructuredSelection) sel;
+                       
+                       int nElements= selection.size();
+                       if (nElements > 1) {
+                               return NLS.bind(CUIMessages.StatusBarUpdater_num_elements_selected, String.valueOf(nElements)); 
+                       } 
+                       Object elem= selection.getFirstElement();
+                       if (elem instanceof ICElement) {
+                               return formatCElementMessage((ICElement) elem);
+                       } else if (elem instanceof IResource) {
+                               return formatResourceMessage((IResource) elem);
+                       }
+               }
+               return "";  //$NON-NLS-1$
+       }
+               
+       private String formatCElementMessage(ICElement element) {
+               return CElementLabels.getElementLabel(element, LABEL_FLAGS);
+       }
+               
+       private String formatResourceMessage(IResource element) {
+               IContainer parent= element.getParent();
+               if (parent != null && parent.getType() != IResource.ROOT)
+                       return element.getName() + CElementLabels.CONCAT_STRING + parent.getFullPath().makeRelative().toString();
+               return element.getName();
+       }       
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StorageLabelProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/StorageLabelProvider.java
new file mode 100644 (file)
index 0000000..4a6f7df
--- /dev/null
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.IPath;
+
+import org.eclipse.swt.graphics.Image;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.LabelProvider;
+
+import org.eclipse.ui.IEditorRegistry;
+import org.eclipse.ui.IFileEditorMapping;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Standard label provider for IStorage objects.
+ * Use this class when you want to present IStorage objects in a viewer.
+ */
+public class StorageLabelProvider extends LabelProvider {
+       
+       private IEditorRegistry fEditorRegistry= PlatformUI.getWorkbench().getEditorRegistry();
+       private Map<String, Image> fJarImageMap= new HashMap<String, Image>(10);
+       private Image fDefaultImage;
+
+       /* (non-Javadoc)
+        * @see ILabelProvider#getImage
+        */
+       @Override
+       public Image getImage(Object element) {
+               if (element instanceof IStorage) 
+                       return getImageForJarEntry((IStorage)element);
+
+               return super.getImage(element);
+       }
+
+       /* (non-Javadoc)
+        * @see ILabelProvider#getText
+        */
+       @Override
+       public String getText(Object element) {
+               if (element instanceof IStorage)
+                       return ((IStorage)element).getName();
+
+               return super.getText(element);
+       }
+
+       /* (non-Javadoc)
+        * 
+        * @see IBaseLabelProvider#dispose
+        */
+       @Override
+       public void dispose() {
+               if (fJarImageMap != null) {
+                       Iterator<Image> each= fJarImageMap.values().iterator();
+                       while (each.hasNext()) {
+                               Image image= each.next();
+                               image.dispose();
+                       }
+                       fJarImageMap= null;
+               }
+               if (fDefaultImage != null)
+                       fDefaultImage.dispose();
+               fDefaultImage= null;
+       }
+       
+       /*
+        * Gets and caches an image for a JarEntryFile.
+        * The image for a JarEntryFile is retrieved from the EditorRegistry.
+        */ 
+       private Image getImageForJarEntry(IStorage element) {
+               if (fJarImageMap == null)
+                       return getDefaultImage();
+
+               if (element == null || element.getName() == null)
+                       return getDefaultImage();
+
+               // Try to find icon for full name
+               String name= element.getName();
+               Image image= fJarImageMap.get(name);
+               if (image != null) 
+                       return image;
+               IFileEditorMapping[] mappings= fEditorRegistry.getFileEditorMappings();
+               int i= 0;
+               while (i < mappings.length) {
+                       if (mappings[i].getLabel().equals(name))
+                               break;
+                       i++;
+               }
+               String key= name;
+               if (i == mappings.length) {
+                       // Try to find icon for extension
+                       IPath path= element.getFullPath();
+                       if (path == null)
+                               return getDefaultImage();
+                       key= path.getFileExtension();
+                       if (key == null)
+                               return getDefaultImage();
+                       image= fJarImageMap.get(key);
+                       if (image != null) 
+                               return image;
+               }
+
+               // Get the image from the editor registry       
+               ImageDescriptor desc= fEditorRegistry.getImageDescriptor(name);
+               image= desc.createImage();
+
+               fJarImageMap.put(key, image);
+
+               return image;
+       }
+       
+       private Image getDefaultImage() {
+               if (fDefaultImage == null)
+                       fDefaultImage= fEditorRegistry.getImageDescriptor((String)null).createImage();
+               return fDefaultImage;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/TreeNavigator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/TreeNavigator.java
new file mode 100644 (file)
index 0000000..19210a1
--- /dev/null
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+/**
+ * Utility to perform next/previous navigation on a tree.
+ * @author markus.schorn@windriver.com
+ */
+public class TreeNavigator {
+       private Tree fTree;
+       private Class<?> fDataClass;
+
+       /**
+        * Creates a tree navigator for the given tree. It allows for finding tree items.
+        * In case you supply a dataClass only nodes with data of this class are considered.
+        * @param tree the tree to operate on
+        * @param dataClass the required class for the data of the tree nodes, or <code>null</code>.
+        */
+       public TreeNavigator(Tree tree, Class<?> dataClass) {
+               fTree= tree;
+               fDataClass= dataClass;
+       }
+
+       /**
+        * Find the first valid item of the selection. 
+        * @return the first valid item in the selection or <code>null</code>
+        */     
+       public TreeItem getSelectedItem() {
+        return getItemOfClass(fTree.getSelection(), true);
+       }
+       
+       private TreeItem getItemOfClass(TreeItem[] items, boolean fwd) {
+        for (int i = 0; i < items.length; i++) {
+            TreeItem item = items[fwd ? i : items.length-1-i];
+            if (fDataClass==null || fDataClass.isInstance(item.getData())) {
+                return item;
+            }
+        }
+        return null;
+       }
+
+       /**
+        * Find the first valid item on the given level. All parents have to be valid also. 
+        * @param level the level to search, use <code>0</code> for the root nodes of the tree.
+        * @param fwd if set to false the tree is searched reverse from the buttom.
+        * @return the first item on the given level, or <code>null</code>
+        */
+       public TreeItem getFirstItemOnLevel(int level, boolean fwd) {
+               return getFirstOnLevel(fTree.getItems(), level, fwd);
+       }
+       private TreeItem getFirstOnLevel(TreeItem[] items, int level, boolean fwd) {
+               TreeItem item= getItemOfClass(items, fwd);
+               if (level <= 0 || item == null) {
+                       return item;
+               }
+               return getFirstOnLevel(item.getItems(), level-1, fwd);
+       }
+
+       /** 
+        * Combines the methods {@link TreeNavigator#getSelectedItem()} and
+        * {@link TreeNavigator#getFirstItemOnLevel(int, boolean)}.
+        * @param level the level to search, use <code>0</code> for the root nodes of the tree.
+        * @param fwd if set to false the tree is searched reverse from the buttom.
+        * @return the first valid item of the selection or the first item on the given level, or <code>null</code>
+        */
+       public TreeItem getSelectedItemOrFirstOnLevel(int level, boolean fwd) {
+               TreeItem result= getSelectedItem();
+               if (result == null) {
+                       result= getFirstItemOnLevel(level, fwd);
+               }
+               return result;
+       }
+       
+       /**
+        * Searches for the next valid sibbling of the given item.
+        * @param current a tree item to start the search
+        * @param forward if false the previous sibbling is returned
+        * @return the next sibbling after the given one, or <code>null</code>
+        */
+       public TreeItem getNextSibbling(TreeItem current, boolean forward) {
+        TreeItem parentItem= current.getParentItem();
+        if (parentItem == null) {
+               Tree tree= current.getParent();
+            int itemCount = tree.getItemCount();
+            if (itemCount > 0) {
+                int index= tree.indexOf(current);
+                index = (index + (forward ? 1 : itemCount-1)) % itemCount;
+                return tree.getItem(index);
+            }
+        }
+        else {
+               int itemCount = parentItem.getItemCount();
+               if (itemCount > 0) {
+                       int index= parentItem.indexOf(current);
+                       index = (index + (forward ? 1 : itemCount-1)) % itemCount;
+                       return parentItem.getItem(index);
+               }
+        }
+        return null;
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/WorkingSetFilter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/WorkingSetFilter.java
new file mode 100644 (file)
index 0000000..955ce99
--- /dev/null
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import java.util.HashMap;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.ui.IWorkingSet;
+
+public class WorkingSetFilter {
+
+    private static final Object ACCEPT = new Object();
+    private static final Object REJECT = new Object();
+
+    private HashMap<IPath, Object> fResourceFilter= null;
+
+    public synchronized boolean isPartOfWorkingSet(ICElement elem) {
+        if (fResourceFilter == null) {
+            return true;
+        }
+        if (elem == null) {
+               return false;
+        }
+        IPath path= elem.getPath();
+        if (path == null) {
+            return false;
+        }
+        Object check= fResourceFilter.get(path);
+        if (check == null) {
+            check= checkWorkingSet(path);
+            fResourceFilter.put(path, check);
+        }
+        return check == ACCEPT;
+    }
+
+    public synchronized boolean isPartOfWorkingSet(IPath resourceOrExternalPath) {
+        if (fResourceFilter == null) {
+            return true;
+        }
+        if (resourceOrExternalPath == null) {
+            return false;
+        }
+        Object check= fResourceFilter.get(resourceOrExternalPath);
+        if (check == null) {
+            check= checkWorkingSet(resourceOrExternalPath);
+            fResourceFilter.put(resourceOrExternalPath, check);
+        }
+        return check == ACCEPT;
+    }
+
+    private synchronized Object checkWorkingSet(IPath path) {
+        if (path.segmentCount() == 0) {
+            return REJECT;
+        }
+
+        Object result= fResourceFilter.get(path);
+        if (result == null) {
+            result= checkWorkingSet(path.removeLastSegments(1));
+            fResourceFilter.put(path, result);
+        }
+        return result;
+    }
+
+    public synchronized void setWorkingSet(IWorkingSet workingSetFilter) {
+        if (workingSetFilter == null) {
+            fResourceFilter= null;
+        }
+        else {
+            IAdaptable[] input = workingSetFilter.getElements();
+            fResourceFilter = new HashMap<IPath, Object>();
+            for (int i = 0; i < input.length; i++) {
+                IAdaptable adaptable = input[i];
+                IResource res = (IResource) adaptable.getAdapter(IResource.class);
+                if (res != null) {
+                    fResourceFilter.put(res.getFullPath(), ACCEPT);
+                }
+            }
+        }
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/WorkingSetFilterUI.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/WorkingSetFilterUI.java
new file mode 100644 (file)
index 0000000..48f8999
--- /dev/null
@@ -0,0 +1,184 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.viewsupport;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetManager;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.WorkingSetFilterActionGroup;
+
+import org.eclipse.cdt.core.model.ICElement;
+
+/**
+ * Wraps {@link WorkingSetFilterActionGroup} and handles the property changed
+ * events 
+ */
+public abstract class WorkingSetFilterUI {
+    private IPropertyChangeListener fWorkingSetListener;
+    private IWorkingSet fWorkingSet;
+    WorkingSetFilterActionGroup fWorkingSetFilterGroup;
+    private IViewPart fViewPart;
+    private WorkingSetFilter fWorkingSetFilter= null;
+    private IWorkingSetManager fWSManager;
+    
+    public WorkingSetFilterUI(IViewPart viewPart, IMemento memento, String key) {
+        fWSManager= PlatformUI.getWorkbench().getWorkingSetManager();
+        fViewPart= viewPart;
+        
+        if (memento != null) {
+            memento= memento.getChild(key);
+            if (memento != null) {
+                IWorkingSet ws= fWSManager.createWorkingSet(memento);
+                if (ws != null) {
+                    fWorkingSet= fWSManager.getWorkingSet(ws.getName());
+                    if (fWorkingSet == null) {
+                        fWorkingSet= ws;
+                        fWSManager.addWorkingSet(ws);
+                    }
+                }
+            }
+        }
+        fWorkingSetListener = new IPropertyChangeListener() {
+            public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event) {
+                onWorkingSetPropertyChange(event);
+            }
+        }; 
+        fWSManager.addPropertyChangeListener(fWorkingSetListener);
+        IPropertyChangeListener workingSetUpdater = new IPropertyChangeListener() {
+            public void propertyChange(PropertyChangeEvent event) {
+                onWorkingSetFilterUpdate(event);
+            }
+        };
+
+        fWorkingSetFilterGroup= new WorkingSetFilterActionGroup(fViewPart.getSite().getShell(), workingSetUpdater);
+        fWorkingSetFilterGroup.setWorkingSet(fWorkingSet);
+    }
+
+    public void dispose() {
+        fWSManager.removePropertyChangeListener(fWorkingSetListener);
+        fWorkingSetFilterGroup.dispose();
+    }
+
+    private void applyWorkingSetFilter() {
+        if (fWorkingSet == null) {
+            fWorkingSetFilter = null;
+        }
+        else {
+            fWorkingSetFilter = new WorkingSetFilter();
+            fWorkingSetFilter.setWorkingSet(fWorkingSet);
+        }
+    }
+
+    protected void onWorkingSetPropertyChange(PropertyChangeEvent evt) {
+        if (fWorkingSet == null) {
+            return;
+        }
+        boolean doRefresh = false;
+        String propertyName = evt.getProperty();
+        Object newValue = evt.getNewValue();
+        Object oldValue = evt.getOldValue();
+        
+        if (propertyName.equals(IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE)) {
+            if (fWorkingSet == newValue) { // weired, but this is how it works
+                doRefresh = true;
+            }
+        }
+        else if (propertyName.equals(IWorkingSetManager.CHANGE_WORKING_SET_NAME_CHANGE)) {
+            if (fWorkingSet == newValue) { 
+                onWorkingSetNameChange();
+            }
+        }
+        else if (propertyName.equals(IWorkingSetManager.CHANGE_WORKING_SET_REMOVE)) {
+            if (fWorkingSet == oldValue) {
+                fWorkingSet = null;
+                doRefresh = true;
+            }
+        }
+        if (doRefresh) {
+            applyWorkingSetFilter();
+            onWorkingSetChange();
+        }
+    }
+    
+    protected void onWorkingSetFilterUpdate(PropertyChangeEvent event) {
+        String property = event.getProperty();
+        if (WorkingSetFilterActionGroup.CHANGE_WORKING_SET.equals(property)) {
+            Object newValue = event.getNewValue();
+            
+            if (newValue instanceof IWorkingSet) {  
+                fWorkingSet = (IWorkingSet) newValue;
+                fWSManager.addRecentWorkingSet(fWorkingSet);
+            }
+            else {
+                fWorkingSet = null;
+            }
+            applyWorkingSetFilter();
+            onWorkingSetChange();
+            onWorkingSetNameChange();
+        }
+    }
+
+    protected abstract void onWorkingSetChange();
+    protected abstract void onWorkingSetNameChange();
+
+    public void fillActionBars(IActionBars actionBars) {
+        fWorkingSetFilterGroup.fillActionBars(actionBars);
+    }
+    
+    public boolean isPartOfWorkingSet(ICElement element) {
+        if (fWorkingSetFilter == null) {
+            return true;
+        }
+        return fWorkingSetFilter.isPartOfWorkingSet(element);
+    }
+
+    public boolean isPartOfWorkingSet(IPath resourceOrExternalPath) {
+        if (fWorkingSetFilter == null) {
+            return true;
+        }
+        return fWorkingSetFilter.isPartOfWorkingSet(resourceOrExternalPath);
+    }
+
+    public IWorkingSet getWorkingSet() {
+        return fWorkingSet;
+    }
+    
+    public void setWorkingSet(IWorkingSet workingSet) {
+        fWorkingSet= workingSet;
+        fWorkingSetFilterGroup.setWorkingSet(fWorkingSet);
+    }
+    
+    public List<String> getRecent() {
+        IWorkingSet[] workingSets= fWSManager.getRecentWorkingSets();
+        ArrayList<String> result= new ArrayList<String>(workingSets.length);
+        for (int i = 0; i < workingSets.length; i++) {
+            result.add(workingSets[i].getName());
+        }
+        return result;
+    }
+
+    public void saveState(IMemento memento, String key) {
+        if (fWorkingSet != null) {
+            fWorkingSet.saveState(memento.createChild(key));
+        }
+    }
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/messages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/messages.properties
new file mode 100644 (file)
index 0000000..74bd740
--- /dev/null
@@ -0,0 +1,16 @@
+################################################################################
+#  Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+#  All rights reserved. This program and the accompanying materials
+#  are made available under the terms of the Eclipse Public License v1.0
+#  which accompanies this distribution, and is available at
+#  http://www.eclipse.org/legal/epl-v10.html
+# 
+#  Contributors:
+#     Markus Schorn - initial API and implementation
+################################################################################
+EditorOpener_fileDoesNotExist=File ''{0}'' no longer exists
+IndexedFilesCache_jobName=Initialize C/C++ Index Label Provider
+IndexUI_infoNotInSource=The element ''{0}'' does not belong to a source file.
+IndexUI_infoNotInIndex=The file ''{0}'' is currently not part of the index. 
+IndexUI_infoSelectIndexAllFiles=For headers that are never included, or sources that are not part of the build, consider selecting the preference 'Index all files'.
+SelectionListenerWithASTManager_jobName=Notifying selection listeners
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/AbstractOpenWizardAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/AbstractOpenWizardAction.java
new file mode 100644 (file)
index 0000000..a916b8f
--- /dev/null
@@ -0,0 +1,226 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Rational Software - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards;
+
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.layout.PixelConverter;
+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;
+import org.eclipse.ui.actions.NewProjectAction;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
+
+public abstract class AbstractOpenWizardAction extends Action implements IWorkbenchWindowActionDelegate {
+
+       private Class<?>[] fActivatedOnTypes;
+       private boolean fAcceptEmptySelection;
+       
+       /**
+        * Creates a AbstractOpenWizardAction.
+        * @param label The label of the action
+        * @param acceptEmptySelection Specifies if the action allows an empty selection
+        */
+       public AbstractOpenWizardAction(String label, boolean acceptEmptySelection) {
+               this(label, null, acceptEmptySelection);
+       }
+
+       /**
+        * Creates a AbstractOpenWizardAction.
+        * @param label The label of the action
+        * @param activatedOnTypes The action is only enabled when all objects in the selection
+        *                         are of the given types. <code>null</code> will allow all types.
+        * @param acceptEmptySelection Specifies if the action allows an empty selection
+        */     
+       public AbstractOpenWizardAction(String label, Class<?>[] activatedOnTypes, boolean acceptEmptySelection) {
+               super(label);
+               fActivatedOnTypes= activatedOnTypes;
+               fAcceptEmptySelection= acceptEmptySelection;
+       }
+
+       /**
+        * Creates a AbstractOpenWizardAction with no restrictions on types, and does allow
+        * an empty selection.
+        */
+       protected AbstractOpenWizardAction() {
+               fActivatedOnTypes= null;
+               fAcceptEmptySelection= true;
+       }
+       
+       protected IWorkbench getWorkbench() {
+               return CUIPlugin.getDefault().getWorkbench();
+       }
+       
+       private boolean isOfAcceptedType(Object obj) {
+               if (fActivatedOnTypes != null) {
+                       for (Class<?> activatedOnType : fActivatedOnTypes) {
+                               if (activatedOnType.isInstance(obj)) {
+                                       return true;
+                               }
+                       }
+                       return false;
+               }
+               return true;
+       }
+       
+       
+       private boolean isEnabled(IStructuredSelection selection) {
+               Iterator<?> iter= selection.iterator();
+               while (iter.hasNext()) {
+                       Object obj= iter.next();
+                       if (!isOfAcceptedType(obj) || !shouldAcceptElement(obj)) {
+                               return false;
+                       }
+               }
+               return true;
+       }
+       
+       /**
+        * Can be overridden to add more checks.
+        * obj is guaranteed to be instance of one of the accepted types
+        */
+       protected boolean shouldAcceptElement(Object obj) {
+               return true;
+       }               
+               
+       /**
+        * Creates the specific wizard.
+        * (to be implemented by a subclass)
+        */
+       abstract protected Wizard createWizard() throws CoreException;
+
+
+       protected IStructuredSelection getCurrentSelection() {
+               IWorkbenchWindow window= CUIPlugin.getActiveWorkbenchWindow();
+               if (window != null) {
+                       ISelection selection= window.getSelectionService().getSelection();
+                       if (selection instanceof IStructuredSelection) {
+                               return (IStructuredSelection) selection;
+                       }
+                       // 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 StructuredSelection.EMPTY;
+       }
+
+       /**
+        * The user has invoked this action.
+        */
+       @Override
+       public void run() {
+/*             if (!fNoChecking && !canActionBeAdded()) {
+                       return;
+               }
+               if (!checkWorkspaceNotEmpty()) {
+                       return;
+               }
+*/             Shell shell= CUIPlugin.getActiveWorkbenchShell();
+               try {
+                       Wizard wizard= createWizard();
+                       if (wizard instanceof IWorkbenchWizard) {
+                               ((IWorkbenchWizard)wizard).init(getWorkbench(), getCurrentSelection());
+                       }
+                       
+                       WizardDialog dialog= new WizardDialog(shell, wizard);
+                       PixelConverter converter= new PixelConverter(CUIPlugin.getActiveWorkbenchShell());
+                       
+                       dialog.setMinimumPageSize(converter.convertWidthInCharsToPixels(70), converter.convertHeightInCharsToPixels(20));
+                       dialog.create();
+                       dialog.open();
+               } catch (CoreException e) {
+                       String title= NewWizardMessages.AbstractOpenWizardAction_createerror_title; 
+                       String message= NewWizardMessages.AbstractOpenWizardAction_createerror_message; 
+                       ExceptionHandler.handle(e, shell, title, message);
+               }
+       }
+       
+       /**
+        * Tests if the action can be run on the current selection.
+        */
+       public boolean canActionBeAdded() {
+               IStructuredSelection selection= getCurrentSelection();
+               if (selection == null || selection.isEmpty()) {
+                       return fAcceptEmptySelection;
+               }
+               return isEnabled(selection);
+       }
+
+       /*
+        * @see IActionDelegate#run(IAction)
+        */
+       public void run(IAction action) {
+               run();
+       }
+
+       /*
+        * @see IWorkbenchWindowActionDelegate#dispose()
+        */
+       public void dispose() {
+       }
+
+       /*
+        * @see IWorkbenchWindowActionDelegate#init(IWorkbenchWindow)
+        */
+       public void init(IWorkbenchWindow window) {
+       }
+
+       /*
+        * @see IActionDelegate#selectionChanged(IAction, ISelection)
+        */
+       public void selectionChanged(IAction action, ISelection selection) {
+               // selection taken from selectionprovider
+       }
+       
+       protected boolean checkWorkspaceNotEmpty() {
+               IWorkspace workspace= ResourcesPlugin.getWorkspace();
+               if (workspace.getRoot().getProjects().length == 0) {
+                       Shell shell= CUIPlugin.getActiveWorkbenchShell();
+                       String title= NewWizardMessages.AbstractOpenWizardAction_noproject_title; 
+                       String message= NewWizardMessages.AbstractOpenWizardAction_noproject_message; 
+                       if (MessageDialog.openQuestion(shell, title, message)) {
+                               IWorkbenchWindow window= CUIPlugin.getActiveWorkbenchWindow();
+                               (new NewProjectAction(window)).run();
+                               return workspace.getRoot().getProjects().length != 0;
+                       }
+                       return false;
+               }
+               return true;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/AbstractWizardDropDownAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/AbstractWizardDropDownAction.java
new file mode 100644 (file)
index 0000000..821bf7e
--- /dev/null
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards;
+
+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;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuCreator;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
+
+public abstract class AbstractWizardDropDownAction extends Action implements IMenuCreator, IWorkbenchWindowPulldownDelegate2 {
+
+       protected final static IAction[] NO_ACTIONS = new IAction[0];
+       private Menu fMenu;
+       private IAction[] fActions;
+       private IRegistryChangeListener fListener;
+       private Object fLock = new Object();
+       
+       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
+               Menu oldMenu = null;
+               synchronized(fLock) {
+                       oldMenu = fMenu;
+               fActions = null;
+               fMenu = null;
+               }
+               if (oldMenu != null)
+                       oldMenu.dispose();
+       }
+
+       public void dispose() {
+               if (fListener != null) {
+                       Platform.getExtensionRegistry().removeRegistryChangeListener(fListener);
+                       fListener= null;
+               }
+               refreshActions();
+       }
+
+       public Menu getMenu(Menu parent) {
+               return null;
+       }
+
+       public Menu getMenu(Control parent) {
+               synchronized(fLock) {
+                       fMenu= new Menu(parent);
+                       IAction[] actions= getActions();
+                       for (int i= 0; i < actions.length; i++) {
+                               ActionContributionItem item= new ActionContributionItem(actions[i]);
+                               item.fill(fMenu, -1);
+                       }
+                       return fMenu;
+               }
+       }
+       
+       @Override
+       public void run() {
+           // 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 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() {
+               synchronized(fLock) {
+               fActions = getWizardActions();
+                   if (fActions == null)
+                       fActions = NO_ACTIONS;
+
+                   //TODO provide a way to sort the actions
+
+                   return fActions;
+               }
+       }
+       
+       protected abstract IAction[] getWizardActions();
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
+        */
+       public void init(IWorkbenchWindow window) {
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+        */
+       public void run(IAction action) {
+               run();
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+        */
+       public void selectionChanged(IAction action, ISelection selection) {
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/CWizardRegistry.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/CWizardRegistry.java
new file mode 100644 (file)
index 0000000..0446749
--- /dev/null
@@ -0,0 +1,434 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     IBM Corporation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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.IPluginContribution;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.activities.WorkbenchActivityHelper;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * 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_CFOLDER = "cfolder";//$NON-NLS-1$
+       private final static String ATT_CPROJECT = "cproject";//$NON-NLS-1$
+       private final static String ATT_CCPROJECT = "ccproject";//$NON-NLS-1$
+    private final static String TAG_CLASS = "class"; //$NON-NLS-1$
+    private final static String TAG_ID = "id"; //$NON-NLS-1$
+    private final static String PL_NEW = "newWizards"; //$NON-NLS-1$
+
+       
+       
+       
+       /**
+        * Checks if wizard supports C projects.
+        * 
+        * @param element the wizard element
+        * 
+        * @return <code>true</code> 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 <code>true</code> 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.
+        *     <wizard
+        *         name="My C Wizard"
+        *         icon="icons/cwiz.gif"
+        *         category="org.eclipse.cdt.ui.newCWizards"
+        *         id="xx.MyCWizard"
+        *         class="org.xx.MyCWizard"
+        *         project="true">
+        *         <description>
+        *             My C Wizard
+        *         </description>
+        *      </wizard>
+        *
+        * 
+        * @return an array of IConfigurationElement
+        */
+       public static IConfigurationElement[] getProjectWizardElements() {
+               List<IConfigurationElement> elemList = new ArrayList<IConfigurationElement>();
+           IConfigurationElement[] elements = getAllWizardElements();
+           for (int i = 0; i < elements.length; ++i) {
+                       IConfigurationElement element = elements[i];
+                       if (isProjectWizard(element)) {
+                           elemList.add(element);
+            }
+           }
+               return 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(TAG_CLASS);
+               if (classElements.length > 0) {
+                       for (IConfigurationElement classElement : classElements) {
+                               IConfigurationElement[] paramElements = classElement.getChildren(TAG_PARAMETER);
+                               for (IConfigurationElement curr : paramElements) {
+                                       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;
+               }
+               // fall back, if no <class> 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.
+        *     <wizard
+        *         name="My C Wizard"
+        *         icon="icons/cwiz.gif"
+        *         category="org.eclipse.cdt.ui.newCWizards"
+        *         id="xx.MyCWizard">
+        *         <class class="org.xx.MyCWizard">
+        *             <parameter name="ctype" value="true" />
+        *         </class> 
+        *         <description>
+        *             My C Wizard
+        *         </description>
+        *      </wizard>
+        * 
+        * @return an array of IConfigurationElement
+        */
+       public static IConfigurationElement[] getTypeWizardElements() {
+               List<IConfigurationElement> elemList = new ArrayList<IConfigurationElement>();
+           IConfigurationElement[] elements = getAllWizardElements();
+           for (int i = 0; i < elements.length; ++i) {
+                       IConfigurationElement element = elements[i];
+                       if (isTypeWizard(element)) {
+                           elemList.add(element);
+            }
+           }
+               return elemList.toArray(new IConfigurationElement[elemList.size()]);
+       }
+       
+    private static boolean isTypeWizard(IConfigurationElement element) {
+               IConfigurationElement[] classElements = element.getChildren(TAG_CLASS);
+               if (classElements.length > 0) {
+                       for (IConfigurationElement classElement : classElements) {
+                               IConfigurationElement[] paramElements = classElement.getChildren(TAG_PARAMETER);
+                               for (IConfigurationElement curr : paramElements) {
+                                       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.
+        *     <wizard
+        *         name="My C File Wizard"
+        *         icon="icons/cwiz.gif"
+        *         category="org.eclipse.cdt.ui.newCWizards"
+        *         id="xx.MyCWizard">
+        *         <class class="org.xx.MyCFileWizard">
+        *             <parameter name="cfile" value="true" />
+        *         </class> 
+        *         <description>
+        *             My C File Wizard
+        *         </description>
+        *      </wizard>
+        * 
+        * @return an array of IConfigurationElement
+        */
+       public static IConfigurationElement[] getFileWizardElements() {
+               List<IConfigurationElement> elemList = new ArrayList<IConfigurationElement>();
+           IConfigurationElement[] elements = getAllWizardElements();
+           for (int i = 0; i < elements.length; ++i) {
+                       IConfigurationElement element = elements[i];
+                       if (isFileWizard(element)) {
+                           elemList.add(element);
+            }
+           }
+               return elemList.toArray(new IConfigurationElement[elemList.size()]);
+       }
+       
+    private static boolean isFileWizard(IConfigurationElement element) {
+               IConfigurationElement[] classElements = element.getChildren(TAG_CLASS);
+               if (classElements.length > 0) {
+                       for (IConfigurationElement classElement : classElements) {
+                               IConfigurationElement[] paramElements = classElement.getChildren(TAG_PARAMETER);
+                               for (IConfigurationElement curr : paramElements) {
+                                       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[] getFolderWizardActions() {
+           return createActions(getFolderWizardElements());
+    }
+
+       /**
+        * Returns IDs of all C/C++ folder wizards contributed to the workbench.
+        * 
+        * @return an array of wizard ids
+        */
+       public static String[] getFolderWizardIDs() {
+               return getWizardIDs(getFolderWizardElements());
+       }
+
+       /**
+        * Returns extension data for all the C/C++ folder wizards contributed to the workbench.
+        *     <wizard
+        *         name="My C Folder Wizard"
+        *         icon="icons/cwiz.gif"
+        *         category="org.eclipse.cdt.ui.newCWizards"
+        *         id="xx.MyCWizard">
+        *         <class class="org.xx.MyCFolderWizard">
+        *             <parameter name="cfolder" value="true" />
+        *         </class> 
+        *         <description>
+        *             My C Folder Wizard
+        *         </description>
+        *      </wizard>
+        * 
+        * @return an array of IConfigurationElement
+        */
+       public static IConfigurationElement[] getFolderWizardElements() {
+               List<IConfigurationElement> elemList = new ArrayList<IConfigurationElement>();
+           IConfigurationElement[] elements = getAllWizardElements();
+           for (int i = 0; i < elements.length; ++i) {
+                       IConfigurationElement element = elements[i];
+                       if (isFolderWizard(element)) {
+                           elemList.add(element);
+            }
+           }
+               return elemList.toArray(new IConfigurationElement[elemList.size()]);
+       }
+       
+    private static boolean isFolderWizard(IConfigurationElement element) {
+               IConfigurationElement[] classElements = element.getChildren(TAG_CLASS);
+               if (classElements.length > 0) {
+                       for (IConfigurationElement classElement : classElements) {
+                               IConfigurationElement[] paramElements = classElement.getChildren(TAG_PARAMETER);
+                               for (IConfigurationElement curr : paramElements) {
+                                       String name = curr.getAttribute(TAG_NAME);
+                                       if (name != null && name.equals(ATT_CFOLDER)) {
+                                           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<String> idList = new ArrayList<String>();
+
+           // add C wizards first
+           for (int i = 0; i < elements.length; ++i) {
+                       IConfigurationElement element= elements[i];
+                       if (isCProjectWizard(element)) {
+                   String id = element.getAttribute(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(TAG_ID);
+                   if (id != null && !idList.contains(id)) {
+                       idList.add(id);
+                   }
+                       }
+           }
+           
+               return idList.toArray(new String[idList.size()]);
+       }
+    
+    private static IAction[] createActions(IConfigurationElement[] elements) {
+           List<String> idList = new ArrayList<String>();
+           List<IAction> actionList = new ArrayList<IAction>();
+
+           // add C wizards first
+           for (int i = 0; i < elements.length; ++i) {
+                       IConfigurationElement element = elements[i];
+                       if (isCProjectWizard(element)) {
+                   String id = element.getAttribute(TAG_ID);
+                   if (id != null && !idList.contains(id)) {
+                       idList.add(id);
+                       IAction action = new OpenNewWizardAction(element);
+                       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(TAG_ID);
+                   if (id != null && !idList.contains(id)) {
+                       idList.add(id);
+                       IAction action = new OpenNewWizardAction(element);
+                       actionList.add(action);
+                   }
+                       }
+           }
+           
+               return actionList.toArray(new IAction[actionList.size()]);
+    }
+    
+    private static class WizardConfig implements IPluginContribution {
+       
+               private IConfigurationElement fElement;
+               
+       public WizardConfig(IConfigurationElement element) {
+                       fElement = element;
+               }
+       
+               public String getLocalId() {
+                       return fElement.getAttribute("id"); //$NON-NLS-1$
+               }
+
+               public String getPluginId() {
+                       return fElement.getContributor().getName();
+               }
+       
+    }
+    
+
+    /**
+        * Returns extension data for all the C/C++ wizards contributed to the workbench.
+        *     <wizard
+        *         name="My C Wizard"
+        *         icon="icons/cwiz.gif"
+        *         category="org.eclipse.cdt.ui.newCWizards"
+        *         id="xx.MyCWizard">
+        *         <description>
+        *             My C Wizard
+        *         </description>
+        *      </wizard>
+        * 
+        * @return an array of IConfigurationElement
+        */
+       public static IConfigurationElement[] getAllWizardElements() {
+               List<IConfigurationElement> elemList = new ArrayList<IConfigurationElement>();
+               IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(PlatformUI.PLUGIN_ID, PL_NEW);
+               if (extensionPoint != null) {
+                       IConfigurationElement[] elements = extensionPoint.getConfigurationElements();
+                       for (IConfigurationElement element : elements) {
+                               if (element.getName().equals(TAG_WIZARD)) {                                     
+                                       if (!WorkbenchActivityHelper.filterItem(new WizardConfig(element))) {                                                                                           
+                                           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 elemList.toArray(new IConfigurationElement[elemList.size()]);
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/ICDTCommonProjectWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/ICDTCommonProjectWizard.java
new file mode 100644 (file)
index 0000000..29df360
--- /dev/null
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards;
+
+
+import java.net.URI;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
+
+/**
+ * @since 5.1
+ */
+public interface ICDTCommonProjectWizard extends IWizard {
+       /**
+        * First stage of creating the project but no progress displayed. Identical to 
+        * calling createIProject(name, location, new NullProgressMonitor())
+        * 
+        * @param name name of the project
+        * @param location location URI for the project
+        * @return the project
+        * @throws CoreException if project creation fails for any reason
+        */
+       public IProject createIProject(final String name, final URI location) throws CoreException;
+
+       /**
+        * First stage of creating the project. Only used internally.
+        * 
+        * @param name name of the project
+        * @param location location URI for the project
+        * @param monitor progress monitor
+        * @return the project
+        * @throws CoreException if project creation fails for any reason
+        */
+       public IProject createIProject(final String name, final URI location, IProgressMonitor monitor) throws CoreException;
+       
+       /**
+        * Get the file content types supported by this project
+        * 
+        * @return array of file content types
+        */
+       public String[] getContentTypeIDs();
+
+       /**
+        * Get the file extension specifications for each content type.
+        * 
+        * @return array of file extension specifications
+        */
+       public String[] getExtensions();
+
+       /**
+        * Get the languages supported by each content type
+        * 
+        * @return array of languages
+        */
+       public String[] getLanguageIDs();
+               
+       /**
+        * Return the last project created by the call to getProject().
+        * 
+        * @return the last project created
+        */
+       public IProject getLastProject();
+
+       /**
+        * Get the project natures provided by this project.
+        * 
+        * @return array of project natures
+        */
+       public String[] getNatures();
+       
+       /**
+        * Create and return the project specified by the wizard. Identical to calling
+        * getProject(defaults, true)
+        * 
+        * @param defaults true if called from the first wizard page
+        * @return the newly created project
+        */
+       public IProject getProject(boolean defaults);
+       
+       /**
+        * Create and return the project specified by the wizard.
+        * 
+        * @param defaults true if called from the first wizard page
+        * @param onFinish true if the method is called when finish is pressed, false
+        * otherwise. If onFinish is false, the project is temporary and can be removed
+        * if cancel is pressed. 
+        * @return the newly created project
+        */
+       public IProject getProject(boolean defaults, boolean onFinish);
+       
+       /**
+        * Can be used to pass a configuration element to update the perspective based 
+        * on the current settings in the Workbench/Perspectives preference page via
+        * {@link BasicNewProjectResourceWizard#updatePerspective(IConfigurationElement)}
+        * 
+        * @param config the configuration element
+        * @param propertyName not used
+        * @param data not used
+        * @throws CoreException
+        */
+       public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException;
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewClassCreationWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewClassCreationWizard.java
new file mode 100644 (file)
index 0000000..0c23903
--- /dev/null
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.wizards.classwizard.NewClassWizardMessages;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.wizards.NewClassCreationWizardPage;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+public class NewClassCreationWizard extends NewElementWizard {
+    
+    private NewClassCreationWizardPage fPage;
+    
+    public NewClassCreationWizard() {
+        super();
+        setDefaultPageImageDescriptor(CPluginImages.DESC_WIZBAN_NEWCLASS);
+        setDialogSettings(CUIPlugin.getDefault().getDialogSettings());
+        setWindowTitle(NewClassWizardMessages.NewClassCreationWizard_title); 
+    }
+    
+    /*
+     * @see Wizard#createPages
+     */
+    @Override
+       public void addPages() {
+        super.addPages();
+        fPage = new NewClassCreationWizardPage();
+        addPage(fPage);
+        fPage.init(getSelection());
+    }
+    
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.cdt.internal.ui.wizards.NewElementWizard#canRunForked()
+     */
+    @Override
+       protected boolean canRunForked() {
+        return !fPage.isNamespaceSelected();
+    }
+    
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.cdt.internal.ui.wizards.NewElementWizard#finishPage(org.eclipse.core.runtime.IProgressMonitor)
+     */
+    @Override
+       protected void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException {
+        fPage.createClass(monitor); // use the full progress monitor
+    }
+    
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.jface.wizard.IWizard#performFinish()
+     */
+    @Override
+       public boolean performFinish() {
+        boolean finished = super.performFinish();
+        if (finished) {
+            if (fPage.openClassInEditor()) {
+                IFile source = fPage.getCreatedSourceFile();
+                if (source != null) {
+                    selectAndReveal(source);
+                    openResource(source);
+                }
+                IFile header = fPage.getCreatedHeaderFile();
+                if (header != null) {
+                    selectAndReveal(header);
+                    openResource(header);
+                }
+            }
+        }
+        return finished;
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewElementWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewElementWizard.java
new file mode 100644 (file)
index 0000000..7698e49
--- /dev/null
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.cdt.internal.ui.actions.WorkbenchRunnableAdapter;
+import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
+
+public abstract class NewElementWizard extends Wizard implements INewWizard {
+
+       private IWorkbench fWorkbench;
+       private IStructuredSelection fSelection;
+
+       public NewElementWizard() {
+               setNeedsProgressMonitor(true);
+       }
+                       
+       protected void openResource(final IFile resource) {
+               final IWorkbenchPage activePage= CUIPlugin.getActivePage();
+               if (activePage != null) {
+                       final Display display= getShell().getDisplay();
+                       if (display != null) {
+                               display.asyncExec(new Runnable() {
+                                       public void run() {
+                                               try {
+                                                       IDE.openEditor(activePage, resource, true);
+                                               } catch (PartInitException e) {
+                                                       CUIPlugin.log(e);
+                                               }
+                                       }
+                               });
+                       }
+               }
+       }
+       
+       /**
+        * Subclasses should override to perform the actions of the wizard.
+        * This method is run in the wizard container's context as a workspace runnable.
+        * @param monitor
+        * @throws InterruptedException
+        * @throws CoreException
+        */
+       protected abstract void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException;
+       
+       /**
+        * Returns the scheduling rule for creating the element.
+        */
+       protected ISchedulingRule getSchedulingRule() {
+               return ResourcesPlugin.getWorkspace().getRoot(); // look all by default
+       }
+       
+       
+       protected boolean canRunForked() {
+               return true;
+       }
+       
+       
+       protected void handleFinishException(Shell shell, InvocationTargetException e) {
+               String title= NewWizardMessages.NewElementWizard_op_error_title; 
+               String message= NewWizardMessages.NewElementWizard_op_error_message; 
+               ExceptionHandler.handle(e, shell, title, message);
+       }
+       
+       /*
+        * @see Wizard#performFinish
+        */             
+       @Override
+       public boolean performFinish() {
+               IWorkspaceRunnable op= new IWorkspaceRunnable() {
+                       public void run(IProgressMonitor monitor) throws CoreException, OperationCanceledException {
+                               try {
+                                       finishPage(monitor);
+                               } catch (InterruptedException e) {
+                                       throw new OperationCanceledException(e.getMessage());
+                               }
+                       }
+               };
+               try {
+                       getContainer().run(canRunForked(), true, new WorkbenchRunnableAdapter(op, getSchedulingRule()));
+               } catch (InvocationTargetException e) {
+                       handleFinishException(getShell(), e);
+                       return false;
+               } catch  (InterruptedException e) {
+                       return false;
+               }
+               return true;
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+        */
+       public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
+               fWorkbench= workbench;
+               fSelection= currentSelection;
+       }
+       
+       public IStructuredSelection getSelection() {
+               return fSelection;
+       }
+
+       public IWorkbench getWorkbench() {
+               return fWorkbench;
+       }
+
+       protected void selectAndReveal(IResource newResource) {
+               BasicNewResourceWizard.selectAndReveal(newResource, fWorkbench.getActiveWorkbenchWindow());
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewElementWizardPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewElementWizardPage.java
new file mode 100644 (file)
index 0000000..8680abe
--- /dev/null
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards;
+
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.wizard.WizardPage;
+
+/**
+ * Base class for wizard page responsible to create C elements. The class
+ * provides API to update the wizard's status line and OK button according to
+ * the value of a <code>IStatus</code> object.
+ */
+public abstract class NewElementWizardPage extends WizardPage {
+
+       private IStatus fCurrStatus;
+       
+       private boolean fPageVisible;
+
+       /**
+        * Creates a <code>NewElementWizardPage</code>.
+        * 
+        * @param name the wizard page's name
+        */     
+       public NewElementWizardPage(String name) {
+               super(name);
+               fPageVisible = false;
+               fCurrStatus =  new StatusInfo();
+       }
+               
+       // ---- WizardPage ----------------
+       
+       /*
+        * @see WizardPage#becomesVisible
+        */
+       @Override
+       public void setVisible(boolean visible) {
+               super.setVisible(visible);
+               fPageVisible = visible;
+               // policy: wizards are not allowed to come up with an error message
+               if (visible && fCurrStatus.matches(IStatus.ERROR)) {
+                       StatusInfo status = new StatusInfo();
+                       status.setError("");  //$NON-NLS-1$
+                       fCurrStatus = status;
+               } 
+               updateStatus(fCurrStatus);
+       }       
+
+       /**
+        * Updates the status line and the ok button according to the given status
+        * 
+        * @param status status to apply
+        */
+       protected void updateStatus(IStatus status) {
+               fCurrStatus = status;
+               setPageComplete(!status.matches(IStatus.ERROR));
+               if (fPageVisible) {
+                       StatusUtil.applyToStatusLine(this, status);
+               }
+       }
+       
+       /**
+        * Updates the status line and the ok button according to the status evaluate from
+        * an array of status. The most severe error is taken.  In case that two status with 
+        * the same severity exists, the status with lower index is taken.
+        * 
+        * @param status the array of status
+        */
+       protected void updateStatus(IStatus[] status) {
+               updateStatus(StatusUtil.getMostSevere(status));
+       }       
+                       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewFileDropDownAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewFileDropDownAction.java
new file mode 100644 (file)
index 0000000..e7e919f
--- /dev/null
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     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);
+       }
+
+       @Override
+       protected IAction[] getWizardActions() {
+               return CWizardRegistry.getFileWizardActions();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewFolderDropDownAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewFolderDropDownAction.java
new file mode 100644 (file)
index 0000000..86d797f
--- /dev/null
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards;
+
+import org.eclipse.jface.action.IAction;
+
+public class NewFolderDropDownAction extends AbstractWizardDropDownAction {
+
+       public NewFolderDropDownAction() {
+           super();
+//             WorkbenchHelp.setHelp(this, ICHelpContextIds.OPEN_FOLDER_WIZARD_ACTION);
+       }
+
+       @Override
+       protected IAction[] getWizardActions() {
+               return CWizardRegistry.getFolderWizardActions();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewProjectDropDownAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewProjectDropDownAction.java
new file mode 100644 (file)
index 0000000..5d8d791
--- /dev/null
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.ui.PlatformUI;
+
+public class NewProjectDropDownAction extends AbstractWizardDropDownAction {
+
+       public NewProjectDropDownAction() {
+           super();
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.OPEN_PROJECT_WIZARD_ACTION);
+       }
+       
+       @Override
+       protected IAction[] getWizardActions() {
+               return CWizardRegistry.getProjectWizardActions();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewTypeDropDownAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewTypeDropDownAction.java
new file mode 100644 (file)
index 0000000..871acbc
--- /dev/null
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.ui.PlatformUI;
+
+public class NewTypeDropDownAction extends AbstractWizardDropDownAction {
+
+       public NewTypeDropDownAction() {
+           super();
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.OPEN_CLASS_WIZARD_ACTION);
+       }
+
+       @Override
+       protected IAction[] getWizardActions() {
+               return CWizardRegistry.getTypeWizardActions();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewWizardMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewWizardMessages.java
new file mode 100644 (file)
index 0000000..c8d3962
--- /dev/null
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Rational Software - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class NewWizardMessages extends NLS {
+
+       private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.wizards.NewWizardMessages";//$NON-NLS-1$
+
+       private NewWizardMessages() {
+               // Do not instantiate
+       }
+
+       public static String AbstractOpenWizardAction_noproject_title;
+       public static String AbstractOpenWizardAction_noproject_message;
+       public static String AbstractOpenWizardAction_createerror_title;
+       public static String AbstractOpenWizardAction_createerror_message;
+       public static String NewElementWizard_op_error_title;
+       public static String NewElementWizard_op_error_message;
+       public static String NewClassWizardPage_files_linkFileButton;
+       public static String CreateLinkedResourceGroup_resolvedPathLabel;
+       public static String CreateLinkedResourceGroup_browseButton;
+       public static String CreateLinkedResourceGroup_open;
+       public static String CreateLinkedResourceGroup_targetSelectionLabel;
+       public static String CreateLinkedResourceGroup_linkTargetNotFile;
+       public static String CreateLinkedResourceGroup_linkTargetNotFolder;
+       public static String CreateLinkedResourceGroup_linkTargetNonExistent;
+       public static String SourceFolderSelectionDialog_title;
+       public static String SourceFolderSelectionDialog_description;
+
+       static {
+               NLS.initializeMessages(BUNDLE_NAME, NewWizardMessages.class);
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewWizardMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewWizardMessages.properties
new file mode 100644 (file)
index 0000000..c187562
--- /dev/null
@@ -0,0 +1,40 @@
+###############################################################################
+# Copyright (c) 2000, 2008 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+#     Anton Leherbauer (Wind River Systems)
+###############################################################################
+
+# ------- AbstractOpenWizardAction -------
+
+AbstractOpenWizardAction_noproject_title=New
+AbstractOpenWizardAction_noproject_message=A project needs to be created first.\nOpen the 'New Project' wizard'?
+
+AbstractOpenWizardAction_createerror_title=Open Wizard
+AbstractOpenWizardAction_createerror_message=The wizard could not be opened. See log for details.
+
+# ------- NewElementWizard -------
+
+NewElementWizard_op_error_title=New
+NewElementWizard_op_error_message=Creation of element failed.
+
+# -----------NewClassWizardPage -------------
+NewClassWizardPage_files_linkFileButton=Link to file
+
+# ----- LinkToFileGroup -----
+CreateLinkedResourceGroup_resolvedPathLabel=Resolved Location:
+CreateLinkedResourceGroup_browseButton=Browse...
+CreateLinkedResourceGroup_open=Open
+CreateLinkedResourceGroup_targetSelectionLabel= Select the link target.
+CreateLinkedResourceGroup_linkTargetNotFile= Link target must be a file
+CreateLinkedResourceGroup_linkTargetNotFolder= Link target must be a folder
+CreateLinkedResourceGroup_linkTargetNonExistent= Link target does not exist
+
+# ----------- SourceFolderSelectionDialog -------------
+SourceFolderSelectionDialog_title= Folder Selection
+SourceFolderSelectionDialog_description= &Choose a source folder:
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/OpenNewWizardAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/OpenNewWizardAction.java
new file mode 100644 (file)
index 0000000..82a13a8
--- /dev/null
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.cdt.internal.ui.util.CoreUtility;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.Wizard;
+
+
+public class OpenNewWizardAction extends AbstractOpenWizardAction {
+
+       private static final String TAG_DESCRIPTION = "description";    //$NON-NLS-1$
+       private final static String ATT_NAME = "name";//$NON-NLS-1$
+       private final static String ATT_CLASS = "class";//$NON-NLS-1$
+       private final static String ATT_ICON = "icon";//$NON-NLS-1$
+       
+       private IConfigurationElement fConfigurationElement;
+
+       public OpenNewWizardAction(IConfigurationElement element) {
+               fConfigurationElement= element;
+               setText(element.getAttribute(ATT_NAME));
+               
+               String description= getDescriptionFromConfig(fConfigurationElement);
+               setDescription(description);
+               setToolTipText(description);
+               setImageDescriptor(getIconFromConfig(fConfigurationElement));
+       }
+       
+       private String getDescriptionFromConfig(IConfigurationElement config) {
+               IConfigurationElement [] children = config.getChildren(TAG_DESCRIPTION);
+               if (children.length>=1) {
+                       return children[0].getValue();
+               }
+               return ""; //$NON-NLS-1$
+       }
+
+       private ImageDescriptor getIconFromConfig(IConfigurationElement config) {
+               try {
+                       String iconName = config.getAttribute(ATT_ICON);
+                       if (iconName != null) {
+                               URL pluginInstallUrl = Platform.getBundle(config.getDeclaringExtension().getContributor().getName()).getEntry("/"); //$NON-NLS-1$                       
+                               return ImageDescriptor.createFromURL(new URL(pluginInstallUrl, iconName));
+                       }
+                       return null;
+               } catch (MalformedURLException exception) {
+                       CUIPlugin.logError("Unable to load wizard icon"); //$NON-NLS-1$
+               }
+               return ImageDescriptor.getMissingImageDescriptor();
+               
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jdt.internal.ui.wizards.AbstractOpenWizardAction#createWizard()
+        */
+       @Override
+       protected Wizard createWizard() throws CoreException {
+               return (Wizard) CoreUtility.createExtension(fConfigurationElement, ATT_CLASS);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/SourceFolderSelectionDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/SourceFolderSelectionDialog.java
new file mode 100644 (file)
index 0000000..612afef
--- /dev/null
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+
+import org.eclipse.cdt.core.model.ICContainer;
+import org.eclipse.cdt.core.model.ICModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.ui.CElementContentProvider;
+import org.eclipse.cdt.ui.CElementLabelProvider;
+import org.eclipse.cdt.ui.CElementSorter;
+
+import org.eclipse.cdt.internal.ui.dialogs.TypedElementSelectionValidator;
+import org.eclipse.cdt.internal.ui.dialogs.TypedViewerFilter;
+
+public class SourceFolderSelectionDialog extends ElementTreeSelectionDialog {
+    
+    private static final Class<?>[] VALIDATOR_CLASSES = new Class<?>[] { ICContainer.class, ICProject.class };
+    private static final TypedElementSelectionValidator fValidator = new TypedElementSelectionValidator(VALIDATOR_CLASSES, false);
+    
+    private static final Class<?>[] FILTER_CLASSES = new Class<?>[] { ICModel.class, ICContainer.class, ICProject.class };
+    private static final ViewerFilter fFilter = new TypedViewerFilter(FILTER_CLASSES);
+    
+    private static final ViewerSorter fSorter = new CElementSorter();
+    
+    public SourceFolderSelectionDialog(Shell parent) {
+        super(parent, createLabelProvider(), createContentProvider());
+        setValidator(fValidator);
+        setComparator(fSorter);
+        addFilter(fFilter);
+        setTitle(NewWizardMessages.SourceFolderSelectionDialog_title); 
+        setMessage(NewWizardMessages.SourceFolderSelectionDialog_description); 
+    }
+
+       private static ITreeContentProvider createContentProvider() {
+               return new CElementContentProvider();
+       }
+
+       private static ILabelProvider createLabelProvider() {
+               return new CElementLabelProvider(CElementLabelProvider.SHOW_DEFAULT);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/AbstractMethodStub.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/AbstractMethodStub.java
new file mode 100644 (file)
index 0000000..08cc40a
--- /dev/null
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.classwizard;
+
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
+
+public abstract class AbstractMethodStub implements IMethodStub {
+    protected String fName;
+    protected String fDescription;
+    protected ASTAccessVisibility fAccess;
+    protected boolean fIsVirtual;
+    protected boolean fIsInline;
+    
+    public AbstractMethodStub(String name, ASTAccessVisibility access, boolean isVirtual, boolean isInline) {
+        fName = name;
+        fAccess = access;
+        fIsVirtual = isVirtual;
+        fIsInline = isInline;
+    }
+    
+    public String getName() {
+        return fName;
+    }
+
+    public String getDescription() {
+        return fDescription;
+    }
+
+    public ASTAccessVisibility getAccess() {
+        return fAccess;
+    }
+
+    public void setAccess(ASTAccessVisibility access) {
+        fAccess = access;
+    }
+
+    public boolean isVirtual() {
+        return fIsVirtual;
+    }
+    
+    public void setVirtual(boolean isVirtual) {
+        fIsVirtual = isVirtual;
+    }
+
+    public boolean isInline() {
+        return fIsInline;
+    }
+
+    public void setInline(boolean isInline) {
+        fIsInline = isInline;
+    }
+    
+    public boolean canModifyAccess() {
+        return true;
+    }
+
+    public boolean canModifyVirtual() {
+        return true;
+    }
+
+    public boolean canModifyInline() {
+        return true;
+    }
+
+    public boolean isConstructor() {
+        return false;
+    }
+
+    public boolean isDestructor() {
+        return false;
+    }
+       
+    public abstract String createMethodDeclaration(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses, String lineDelimiter) throws CoreException;
+    
+    public abstract String createMethodImplementation(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses, String lineDelimiter) throws CoreException;
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassInfo.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassInfo.java
new file mode 100644 (file)
index 0000000..5f611e1
--- /dev/null
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.classwizard;
+
+import org.eclipse.cdt.core.browser.ITypeInfo;
+import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
+
+
+public class BaseClassInfo implements IBaseClassInfo {
+    
+    private ITypeInfo fType;
+    private ASTAccessVisibility fAccess;
+    private boolean fIsVirtual;
+    
+    public BaseClassInfo(ITypeInfo type, ASTAccessVisibility access, boolean isVirtual) {
+        fType = type;
+        fAccess = access;
+        fIsVirtual = isVirtual;
+    }
+
+    public ITypeInfo getType() {
+        return fType;
+    }
+    
+    public ASTAccessVisibility getAccess() {
+        return fAccess;
+    }
+    
+       public boolean isVirtual() {
+           return fIsVirtual;
+       }
+
+    public void setAccess(ASTAccessVisibility access) {
+        fAccess = access;
+    }
+
+    public void setVirtual(boolean isVirtual) {
+        fIsVirtual = isVirtual;
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesLabelProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesLabelProvider.java
new file mode 100644 (file)
index 0000000..a893875
--- /dev/null
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.classwizard;
+
+import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
+import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoLabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+
+public final class BaseClassesLabelProvider implements ITableLabelProvider {
+
+       private static final String YES_VALUE = NewClassWizardMessages.BaseClassesLabelProvider_boolean_yes_label; 
+       private static final String NO_VALUE = NewClassWizardMessages.BaseClassesLabelProvider_boolean_no_label; 
+       private static final String ACCESS_PUBLIC = NewClassWizardMessages.BaseClassesLabelProvider_access_public_label; 
+       private static final String ACCESS_PROTECTED = NewClassWizardMessages.BaseClassesLabelProvider_access_protected_label; 
+       private static final String ACCESS_PRIVATE = NewClassWizardMessages.BaseClassesLabelProvider_access_private_label; 
+
+    public static final String getYesNoText(boolean value) {
+       return value ? YES_VALUE : NO_VALUE;
+    }
+
+    public static final String getAccessText(ASTAccessVisibility access) {
+        if (access == ASTAccessVisibility.PRIVATE)
+            return ACCESS_PRIVATE;
+        if (access == ASTAccessVisibility.PROTECTED)
+            return ACCESS_PROTECTED;
+           return ACCESS_PUBLIC;
+    }
+
+    private static TypeInfoLabelProvider fTypeInfoLabelProvider = new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_FULLY_QUALIFIED);
+    
+       /*
+        * @see ITableLabelProvider#getColumnImage(Object, int)
+        */
+       public Image getColumnImage(Object element, int columnIndex) {
+               if (columnIndex != 0)
+                       return null;
+               
+           IBaseClassInfo info = (IBaseClassInfo) element;
+               return fTypeInfoLabelProvider.getImage(info.getType());
+       }
+
+       /*
+        * @see ITableLabelProvider#getColumnText(Object, int)
+        */
+       public String getColumnText(Object element, int columnIndex) {
+           IBaseClassInfo info = (IBaseClassInfo) element;
+               
+               switch (columnIndex) {
+                       case 0:
+                           return fTypeInfoLabelProvider.getText(info.getType());
+                       case 1:
+                           return getAccessText(info.getAccess());
+                       case 2:
+                               return getYesNoText(info.isVirtual());
+                       default:
+                               return null;
+               }
+       }
+
+       /*
+        * @see IBaseLabelProvider#addListener(ILabelProviderListener)
+        */
+       public void addListener(ILabelProviderListener listener) {
+       }
+
+       /*
+        * @see IBaseLabelProvider#dispose()
+        */
+       public void dispose() {
+       }
+
+       /*
+        * @see IBaseLabelProvider#isLabelProperty(Object, String)
+        */
+       public boolean isLabelProperty(Object element, String property) {
+               return false;
+       }
+
+       /*
+        * @see IBaseLabelProvider#removeListener(ILabelProviderListener)
+        */
+       public void removeListener(ILabelProviderListener listener) {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesListDialogField.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/BaseClassesListDialogField.java
new file mode 100644 (file)
index 0000000..5c8f0ac
--- /dev/null
@@ -0,0 +1,182 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     IBM Corporation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.classwizard;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.ComboBoxCellEditor;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleAdapter;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Item;
+import org.eclipse.swt.widgets.Table;
+
+import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
+
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
+
+public class BaseClassesListDialogField extends ListDialogField<IBaseClassInfo> {
+    
+    // column properties
+    private static final String CP_NAME = "name"; //$NON-NLS-1$
+    private static final String CP_ACCESS = "access"; //$NON-NLS-1$
+    private static final String CP_VIRTUAL = "virtual"; //$NON-NLS-1$
+    static final Integer INDEX_YES = new Integer(0);
+    static final Integer INDEX_NO = new Integer(1);
+    static final Integer INDEX_PUBLIC = new Integer(0);
+    static final Integer INDEX_PROTECTED = new Integer(1);
+    static final Integer INDEX_PRIVATE = new Integer(2);
+    
+    private final class CellHandler implements ICellModifier {
+        public boolean canModify(Object element, String property) {
+            return (element instanceof IBaseClassInfo)
+               && (property.equals(CP_ACCESS) || property.equals(CP_VIRTUAL));
+        }
+        
+        public Object getValue(Object element, String property) {
+            if (!(element instanceof IBaseClassInfo))
+                return null;
+            
+            IBaseClassInfo baseClass = (IBaseClassInfo) element;
+            if (property.equals(CP_ACCESS)) {
+                if (baseClass.getAccess() == ASTAccessVisibility.PRIVATE) {
+                    return INDEX_PRIVATE;
+                } else if (baseClass.getAccess() == ASTAccessVisibility.PROTECTED) {
+                    return INDEX_PROTECTED;
+                } else {
+                    return INDEX_PUBLIC;
+                }
+            } else if (property.equals(CP_VIRTUAL)) {
+               if (baseClass.isVirtual())
+                       return INDEX_YES;
+               return INDEX_NO;
+            }
+            return null;
+        }
+        
+        public void modify(Object element, String property, Object value) {
+            IBaseClassInfo baseClass = null;
+            if (element instanceof IBaseClassInfo) {
+                baseClass = (IBaseClassInfo) element;
+            } else if (element instanceof Item) {
+                Object data = ((Item)element).getData();
+                if (data instanceof IBaseClassInfo)
+                    baseClass = (IBaseClassInfo) data;
+            }
+            if (baseClass != null) {
+                if (property.equals(CP_ACCESS) && value instanceof Integer) {
+                    Integer access = (Integer)value;
+                    if (access.equals(INDEX_PRIVATE)) {
+                        baseClass.setAccess(ASTAccessVisibility.PRIVATE);
+                    } else if (access.equals(INDEX_PROTECTED)) {
+                        baseClass.setAccess(ASTAccessVisibility.PROTECTED);
+                    } else {
+                        baseClass.setAccess(ASTAccessVisibility.PUBLIC);
+                    }
+                    refresh();
+                } else if (property.equals(CP_VIRTUAL) && value instanceof Integer) {
+                    Integer yesno = (Integer)value;
+                    baseClass.setVirtual(yesno.equals(INDEX_YES));
+                    refresh();
+                }
+            }
+        }
+    }
+    
+    public BaseClassesListDialogField(String title, IListAdapter<IBaseClassInfo> listAdapter) {
+        super(listAdapter,
+               new String[] {
+                NewClassWizardMessages.BaseClassesListDialogField_buttons_add, 
+                NewClassWizardMessages.BaseClassesListDialogField_buttons_remove, 
+                NewClassWizardMessages.BaseClassesListDialogField_buttons_up, 
+                NewClassWizardMessages.BaseClassesListDialogField_buttons_down
+               }, new BaseClassesLabelProvider());
+        setRemoveButtonIndex(1);
+        setUpButtonIndex(2);
+        setDownButtonIndex(3);
+        setLabelText(title);
+        
+        String[] headers = new String[] {
+               NewClassWizardMessages.BaseClassesListDialogField_headings_name, 
+               NewClassWizardMessages.BaseClassesListDialogField_headings_access, 
+               NewClassWizardMessages.BaseClassesListDialogField_headings_virtual
+        };
+        ColumnLayoutData[] columns = new ColumnLayoutData[] {
+               new ColumnWeightData(70, 30),
+               new ColumnWeightData(30, 30),
+               new ColumnWeightData(25, 25),
+        };
+        setTableColumns(new ListDialogField.ColumnsDescription(columns, headers, true));
+    }
+    
+    @Override
+       protected boolean managedButtonPressed(int index) {
+        super.managedButtonPressed(index);
+        return false;
+    }
+    
+    @Override
+       protected TableViewer createTableViewer(Composite parent) {
+        TableViewer viewer = super.createTableViewer(parent);
+        Table table = viewer.getTable();
+        table.getAccessible().addAccessibleListener(
+            new AccessibleAdapter() {                       
+                @Override
+                               public void getName(AccessibleEvent e) {
+                        e.result = NewClassWizardMessages.NewClassCreationWizardPage_baseClasses_label; 
+                }
+            }
+        );
+        
+        CellEditor virtualCellEditor = new ComboBoxCellEditor(table,
+               new String[] {
+                /* INDEX_YES */BaseClassesLabelProvider.getYesNoText(true),
+                /* INDEX_NO */BaseClassesLabelProvider.getYesNoText(false)
+               }, SWT.READ_ONLY);
+
+        CellEditor accessCellEditor = new ComboBoxCellEditor(table,
+               new String[] {
+                /* INDEX_PUBLIC */BaseClassesLabelProvider.getAccessText(ASTAccessVisibility.PUBLIC),
+                /* INDEX_PROTECTED */BaseClassesLabelProvider.getAccessText(ASTAccessVisibility.PROTECTED),
+                /* INDEX_PRIVATE */BaseClassesLabelProvider.getAccessText(ASTAccessVisibility.PRIVATE)
+            }, SWT.READ_ONLY);
+        
+        viewer.setCellEditors(new CellEditor[] {
+            null,
+            accessCellEditor,
+            virtualCellEditor
+               });
+        viewer.setColumnProperties(new String[] {
+            CP_NAME,
+            CP_ACCESS,
+            CP_VIRTUAL
+        });
+        viewer.setCellModifier(new CellHandler());
+        return viewer;
+    }
+    
+    public void addBaseClass(IBaseClassInfo baseClass) {
+        addElement(baseClass);
+    }
+    
+    public IBaseClassInfo[] getBaseClasses() {
+           List<IBaseClassInfo> baseClasses = getElements();
+           return baseClasses.toArray(new IBaseClassInfo[baseClasses.size()]);
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/ConstructorMethodStub.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/ConstructorMethodStub.java
new file mode 100644 (file)
index 0000000..da082b2
--- /dev/null
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.classwizard;
+
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
+import org.eclipse.cdt.ui.CodeGeneration;
+
+
+public final class ConstructorMethodStub extends AbstractMethodStub {
+    private static String NAME = NewClassWizardMessages.NewClassCodeGeneration_stub_constructor_name; 
+    
+    public ConstructorMethodStub() {
+        this(ASTAccessVisibility.PUBLIC, false);
+    }
+
+    public ConstructorMethodStub(ASTAccessVisibility access, boolean isInline) {
+        super(NAME, access, false, isInline);
+    }
+
+    @Override
+       public String createMethodDeclaration(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses, String lineDelimiter) throws CoreException {
+        StringBuffer buf = new StringBuffer();
+        buf.append(className);
+        buf.append("()"); //$NON-NLS-1$
+       if (fIsInline) {
+            buf.append('{');
+            buf.append(lineDelimiter);
+               String body= CodeGeneration.getConstructorBodyContent(tu, className, null, lineDelimiter);
+               if (body != null) {
+                       buf.append(body);
+                buf.append(lineDelimiter);
+               }
+            buf.append('}');
+       } else {
+           buf.append(";"); //$NON-NLS-1$
+       }
+        return buf.toString();
+    }
+
+    @Override
+       public String createMethodImplementation(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses, String lineDelimiter) throws CoreException {
+        if (fIsInline) {
+            return ""; //$NON-NLS-1$
+        }
+        StringBuffer buf = new StringBuffer();
+        buf.append(className);
+        buf.append("::"); //$NON-NLS-1$
+        buf.append(className);
+        buf.append("()"); //$NON-NLS-1$
+        buf.append(lineDelimiter);
+        buf.append('{');
+        buf.append(lineDelimiter);
+       String body= CodeGeneration.getConstructorBodyContent(tu, className, null, lineDelimiter);
+       if (body != null) {
+               buf.append(body);
+            buf.append(lineDelimiter);
+       }
+        buf.append('}');
+        return buf.toString();
+    }
+
+    @Override
+       public boolean isConstructor() {
+        return true;
+    }
+
+    @Override
+       public boolean canModifyVirtual() {
+        return false;
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/DestructorMethodStub.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/DestructorMethodStub.java
new file mode 100644 (file)
index 0000000..f2e75bc
--- /dev/null
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.classwizard;
+
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
+import org.eclipse.cdt.ui.CodeGeneration;
+
+
+public final class DestructorMethodStub extends AbstractMethodStub {
+    
+    private static String NAME = NewClassWizardMessages.NewClassCodeGeneration_stub_destructor_name; 
+    
+    public DestructorMethodStub() {
+        this(ASTAccessVisibility.PUBLIC, true, false);
+    }
+
+    public DestructorMethodStub(ASTAccessVisibility access, boolean isVirtual, boolean isInline) {
+        super(NAME, access, isVirtual, isInline);
+    }
+
+    @Override
+       public String createMethodDeclaration(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses, String lineDelimiter) throws CoreException {
+        StringBuffer buf = new StringBuffer();
+       if (fIsVirtual){
+           buf.append("virtual "); //$NON-NLS-1$
+       }
+       buf.append("~"); //$NON-NLS-1$
+       buf.append(className);
+       buf.append("()"); //$NON-NLS-1$
+       if (fIsInline) {
+            buf.append('{');
+            buf.append(lineDelimiter);
+               String body= CodeGeneration.getDestructorBodyContent(tu, className, null, lineDelimiter);
+               if (body != null) {
+                       buf.append(body);
+                buf.append(lineDelimiter);
+               }
+            buf.append('}');
+       } else {
+           buf.append(";"); //$NON-NLS-1$
+       }
+        return buf.toString();
+    }
+
+    @Override
+       public String createMethodImplementation(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses, String lineDelimiter) throws CoreException {
+       if (fIsInline) {
+               return ""; //$NON-NLS-1$
+       }
+       StringBuffer buf = new StringBuffer();
+       buf.append(className);
+       buf.append("::~"); //$NON-NLS-1$
+       buf.append(className);
+       buf.append("()"); //$NON-NLS-1$
+       buf.append(lineDelimiter);
+        buf.append('{');
+        buf.append(lineDelimiter);
+       String body= CodeGeneration.getDestructorBodyContent(tu, className, null, lineDelimiter);
+       if (body != null) {
+               buf.append(body);
+            buf.append(lineDelimiter);
+       }
+        buf.append('}');
+       return buf.toString();
+    }
+
+    @Override
+       public boolean isDestructor() {
+        return true;
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/EnclosingClassSelectionDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/EnclosingClassSelectionDialog.java
new file mode 100644 (file)
index 0000000..c6bc74d
--- /dev/null
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.classwizard;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog;
+import org.eclipse.swt.widgets.Shell;
+
+public class EnclosingClassSelectionDialog extends TypeSelectionDialog {
+    
+    private static final String DIALOG_SETTINGS = EnclosingClassSelectionDialog.class.getName();
+    private static final int[] VISIBLE_TYPES = { ICElement.C_CLASS };
+    
+    public EnclosingClassSelectionDialog(Shell parent) {
+        super(parent);
+        setTitle(NewClassWizardMessages.EnclosingClassSelectionDialog_title); 
+        setMessage(NewClassWizardMessages.EnclosingClassSelectionDialog_message); 
+        setDialogSettings(DIALOG_SETTINGS);
+        setVisibleTypes(VISIBLE_TYPES);
+        setFilter("*", true); //$NON-NLS-1$
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/IBaseClassInfo.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/IBaseClassInfo.java
new file mode 100644 (file)
index 0000000..b92c907
--- /dev/null
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.classwizard;
+
+import org.eclipse.cdt.core.browser.ITypeInfo;
+import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
+
+
+public interface IBaseClassInfo {
+       public ITypeInfo getType();
+    public ASTAccessVisibility getAccess();
+    public boolean isVirtual();
+    
+    public void setAccess(ASTAccessVisibility access);
+    public void setVirtual(boolean isVirtual);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/IMethodStub.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/IMethodStub.java
new file mode 100644 (file)
index 0000000..1d0e380
--- /dev/null
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.classwizard;
+
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
+
+
+public interface IMethodStub {
+    public String getName();
+    public String getDescription();
+
+    public ASTAccessVisibility getAccess();
+    public boolean canModifyAccess();
+    public void setAccess(ASTAccessVisibility access);
+
+    public boolean isVirtual();
+    public boolean canModifyVirtual();
+    public void setVirtual(boolean isVirtual);
+
+    public boolean isInline();
+    public boolean canModifyInline();
+    public void setInline(boolean isVirtual);
+    
+    public boolean isConstructor();
+    public boolean isDestructor();
+    
+    public String createMethodDeclaration(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses, String lineDelimiter) throws CoreException;
+    public String createMethodImplementation(ITranslationUnit tu, String className, IBaseClassInfo[] baseClasses, String lineDelimiter) throws CoreException;
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsLabelProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsLabelProvider.java
new file mode 100644 (file)
index 0000000..d4b26e4
--- /dev/null
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.classwizard;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
+
+
+public final class MethodStubsLabelProvider implements ITableLabelProvider {
+
+       /*
+        * @see ITableLabelProvider#getColumnImage(Object, int)
+        */
+       public Image getColumnImage(Object element, int columnIndex) {
+               if (columnIndex != 0)
+                       return null;
+               
+           IMethodStub stub = (IMethodStub) element;
+               ImageDescriptor descriptor = CElementImageProvider.getMethodImageDescriptor(stub.getAccess());
+               if (descriptor != null) {
+                       return CUIPlugin.getImageDescriptorRegistry().get(descriptor);
+               }
+               return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_PUBLIC_METHOD);
+       }
+
+       /*
+        * @see ITableLabelProvider#getColumnText(Object, int)
+        */
+       public String getColumnText(Object element, int columnIndex) {
+           IMethodStub stub = (IMethodStub) element;
+               
+               switch (columnIndex) {
+                       case 0:
+                               return stub.getName();
+                       case 1:
+                               return BaseClassesLabelProvider.getAccessText(stub.getAccess());
+                       case 2:
+                               return BaseClassesLabelProvider.getYesNoText(stub.isVirtual());
+                       case 3:
+                               return BaseClassesLabelProvider.getYesNoText(stub.isInline());
+                       default:
+                               return null;
+               }
+       }
+
+       /*
+        * @see IBaseLabelProvider#addListener(ILabelProviderListener)
+        */
+       public void addListener(ILabelProviderListener listener) {
+       }
+
+       /*
+        * @see IBaseLabelProvider#dispose()
+        */
+       public void dispose() {
+       }
+
+       /*
+        * @see IBaseLabelProvider#isLabelProperty(Object, String)
+        */
+       public boolean isLabelProperty(Object element, String property) {
+               return false;
+       }
+
+       /*
+        * @see IBaseLabelProvider#removeListener(ILabelProviderListener)
+        */
+       public void removeListener(ILabelProviderListener listener) {
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsListDialogField.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/MethodStubsListDialogField.java
new file mode 100644 (file)
index 0000000..f078806
--- /dev/null
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     IBM Corporation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.classwizard;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.ComboBoxCellEditor;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleAdapter;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Item;
+import org.eclipse.swt.widgets.Table;
+
+import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
+
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.CheckedListDialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
+
+public class MethodStubsListDialogField extends CheckedListDialogField<IMethodStub> {
+    
+    // column properties
+    private static final String CP_NAME = "name"; //$NON-NLS-1$
+    private static final String CP_ACCESS = "access"; //$NON-NLS-1$
+    private static final String CP_VIRTUAL = "virtual"; //$NON-NLS-1$
+    private static final String CP_INLINE = "inline"; //$NON-NLS-1$
+    static final Integer INDEX_YES = new Integer(0);
+    static final Integer INDEX_NO = new Integer(1);
+    static final Integer INDEX_PUBLIC = new Integer(0);
+    static final Integer INDEX_PROTECTED = new Integer(1);
+    static final Integer INDEX_PRIVATE = new Integer(2);
+    
+    private final class CellHandler implements ICellModifier {
+        public boolean canModify(Object element, String property) {
+            if (element instanceof IMethodStub) {
+                IMethodStub stub = (IMethodStub) element;
+                if (property.equals(CP_ACCESS)) {
+                    return stub.canModifyAccess();
+                } else if (property.equals(CP_VIRTUAL)) {
+                    return stub.canModifyVirtual();
+                } else if (property.equals(CP_INLINE)) {
+                    return stub.canModifyInline();
+                }
+            }
+            return false;
+        }
+        
+        public Object getValue(Object element, String property) {
+            if (!(element instanceof IMethodStub))
+                return null;
+            
+            IMethodStub stub = (IMethodStub) element;
+            if (property.equals(CP_ACCESS)) {
+                if (stub.getAccess() == ASTAccessVisibility.PRIVATE) {
+                    return INDEX_PRIVATE;
+                } else if (stub.getAccess() == ASTAccessVisibility.PROTECTED) {
+                    return INDEX_PROTECTED;
+                } else {
+                    return INDEX_PUBLIC;
+                }
+            } else if (property.equals(CP_VIRTUAL)) {
+               if (stub.isVirtual())
+                       return INDEX_YES;
+               return INDEX_NO;
+               } else if (property.equals(CP_INLINE)) {
+                       if (stub.isInline())
+                               return INDEX_YES;
+                       return INDEX_NO;
+               }
+            return null;
+        }
+        
+        public void modify(Object element, String property, Object value) {
+            IMethodStub stub = null;
+            if (element instanceof IMethodStub) {
+                stub = (IMethodStub)element;
+            } else if (element instanceof Item) {
+                Object data = ((Item)element).getData();
+                if (data instanceof IMethodStub)
+                    stub = (IMethodStub)data;
+            }
+            if (stub != null) {
+                if (property.equals(CP_ACCESS) && value instanceof Integer) {
+                    Integer access = (Integer) value;
+                    if (access.equals(INDEX_PRIVATE)) {
+                        stub.setAccess(ASTAccessVisibility.PRIVATE);
+                    } else if (access.equals(INDEX_PROTECTED)) {
+                        stub.setAccess(ASTAccessVisibility.PROTECTED);
+                    } else {
+                        stub.setAccess(ASTAccessVisibility.PUBLIC);
+                    }
+                    refresh();
+                } else if (property.equals(CP_VIRTUAL) && value instanceof Integer) {
+                    Integer yesno = (Integer) value;
+                    stub.setVirtual(yesno.equals(INDEX_YES));
+                    refresh();
+                } else if (property.equals(CP_INLINE) && value instanceof Integer) {
+                    Integer yesno = (Integer) value;
+                    stub.setInline(yesno.equals(INDEX_YES));
+                    refresh();
+                }
+            }
+        }
+    }
+    
+    public MethodStubsListDialogField(String title, IListAdapter<IMethodStub> listAdapter) {
+        super(listAdapter, null, new MethodStubsLabelProvider());
+        setLabelText(title);
+        
+        String[] headers = new String[] {
+               NewClassWizardMessages.MethodStubsDialogField_headings_name, 
+               NewClassWizardMessages.MethodStubsDialogField_headings_access, 
+               NewClassWizardMessages.MethodStubsDialogField_headings_virtual, 
+               NewClassWizardMessages.MethodStubsDialogField_headings_inline
+        };
+        ColumnLayoutData[] columns = new ColumnLayoutData[] {
+               new ColumnWeightData(70, 30),
+               new ColumnWeightData(40, 30),
+               new ColumnWeightData(30, 25),
+               new ColumnWeightData(30, 25),
+        };
+        setTableColumns(new ListDialogField.ColumnsDescription(columns, headers, true));
+    }
+    
+    @Override
+       protected boolean managedButtonPressed(int index) {
+        super.managedButtonPressed(index);
+        return false;
+    }
+    
+    @Override
+       protected TableViewer createTableViewer(Composite parent) {
+        TableViewer viewer = super.createTableViewer(parent);
+        Table table = viewer.getTable();
+        table.getAccessible().addAccessibleListener(
+            new AccessibleAdapter() {                       
+                @Override
+                               public void getName(AccessibleEvent e) {
+                        e.result = NewClassWizardMessages.NewClassCreationWizardPage_methodStubs_label; 
+                }
+            }
+        );
+        
+        CellEditor virtualCellEditor = new ComboBoxCellEditor(table,
+               new String[] {
+                /* INDEX_YES */BaseClassesLabelProvider.getYesNoText(true),
+                /* INDEX_NO */BaseClassesLabelProvider.getYesNoText(false)
+               }, SWT.READ_ONLY);
+
+        CellEditor accessCellEditor = new ComboBoxCellEditor(table,
+               new String[] {
+                /* INDEX_PUBLIC */BaseClassesLabelProvider.getAccessText(ASTAccessVisibility.PUBLIC),
+                /* INDEX_PROTECTED */BaseClassesLabelProvider.getAccessText(ASTAccessVisibility.PROTECTED),
+                /* INDEX_PRIVATE */BaseClassesLabelProvider.getAccessText(ASTAccessVisibility.PRIVATE)
+            }, SWT.READ_ONLY);
+        
+        viewer.setCellEditors(new CellEditor[] {
+            null,
+            accessCellEditor,
+            virtualCellEditor,
+            virtualCellEditor
+               });
+        viewer.setColumnProperties(new String[] {
+            CP_NAME,
+            CP_ACCESS,
+            CP_VIRTUAL,
+            CP_INLINE
+        });
+        viewer.setCellModifier(new CellHandler());
+        return viewer;
+    }
+    
+    public void addMethodStub(IMethodStub methodStub, boolean checked) {
+               addElement(methodStub);
+               setChecked(methodStub, checked);
+    }
+
+    public IMethodStub[] getMethodStubs() {
+           List<IMethodStub> allStubs = getElements();
+           return allStubs.toArray(new IMethodStub[allStubs.size()]);
+    }
+
+    public IMethodStub[] getCheckedMethodStubs() {
+           List<IMethodStub> checkedStubs = getCheckedElements();
+           return checkedStubs.toArray(new IMethodStub[checkedStubs.size()]);
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NamespaceSelectionDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NamespaceSelectionDialog.java
new file mode 100644 (file)
index 0000000..a3358bd
--- /dev/null
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.classwizard;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog;
+import org.eclipse.swt.widgets.Shell;
+
+public class NamespaceSelectionDialog extends TypeSelectionDialog {
+    private static final String DIALOG_SETTINGS = NamespaceSelectionDialog.class.getName();
+    private static final int[] VISIBLE_TYPES = { ICElement.C_NAMESPACE };
+    
+    public NamespaceSelectionDialog(Shell parent) {
+        super(parent);
+        setTitle(NewClassWizardMessages.NamespaceSelectionDialog_title); 
+        setMessage(NewClassWizardMessages.NamespaceSelectionDialog_message); 
+        setDialogSettings(DIALOG_SETTINGS);
+        setVisibleTypes(VISIBLE_TYPES);
+        setFilter("*", true); //$NON-NLS-1$
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewBaseClassSelectionDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewBaseClassSelectionDialog.java
new file mode 100644 (file)
index 0000000..d605c0d
--- /dev/null
@@ -0,0 +1,179 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2011 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.classwizard;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.core.browser.ITypeInfo;
+import org.eclipse.cdt.core.model.ICElement;
+
+import org.eclipse.cdt.internal.ui.browser.opentype.ElementSelectionDialog;
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.progress.IProgressService;
+
+public class NewBaseClassSelectionDialog extends ElementSelectionDialog {
+    private static final String DIALOG_SETTINGS = NewBaseClassSelectionDialog.class.getName();
+    private static final int[] VISIBLE_TYPES = { ICElement.C_CLASS, ICElement.C_STRUCT };
+    private static final int ADD_ID = IDialogConstants.CLIENT_ID + 1;
+       private List<ITypeInfo> fTypeList;
+       private List<ITypeSelectionListener> fTypeListeners;
+
+       public interface ITypeSelectionListener {
+           void typeAdded(ITypeInfo baseClass);
+       }
+
+    public NewBaseClassSelectionDialog(Shell parent) {
+        super(parent);
+        setTitle(NewClassWizardMessages.NewBaseClassSelectionDialog_title); 
+        setMessage(NewClassWizardMessages.NewBaseClassSelectionDialog_message); 
+        setDialogSettings(DIALOG_SETTINGS);
+        setVisibleTypes(VISIBLE_TYPES);
+               setStatusLineAboveButtons(true);
+               fTypeList = new ArrayList<ITypeInfo>();
+               fTypeListeners = new ArrayList<ITypeSelectionListener>();
+    }
+
+    public void addListener(ITypeSelectionListener listener) {
+        if (!fTypeListeners.contains(listener))
+            fTypeListeners.add(listener);
+    }
+
+    public void removeListener(ITypeSelectionListener listener) {
+        fTypeListeners.remove(listener);
+    }
+
+    private void notifyTypeAddedListeners(ITypeInfo type) {
+        // first copy listeners in case one calls removeListener
+        List<ITypeSelectionListener> list = new ArrayList<ITypeSelectionListener>(fTypeListeners);
+        for (Iterator<ITypeSelectionListener> i = list.iterator(); i.hasNext(); ) {
+            ITypeSelectionListener listener = i.next();
+            listener.typeAdded(type);
+        }
+    }
+
+    public ITypeInfo[] getAddedTypes() {
+        return fTypeList.toArray(new ITypeInfo[fTypeList.size()]);
+    }
+
+    /*
+        * @see Dialog#createButtonsForButtonBar
+        */
+       @Override
+       protected void createButtonsForButtonBar(Composite parent) {
+               createButton(parent, ADD_ID, NewClassWizardMessages.NewBaseClassSelectionDialog_addButton_label, true); 
+               super.createButtonsForButtonBar(parent);
+       }
+
+       /*
+        * @see Dialog#buttonPressed
+        */
+       @Override
+       protected void buttonPressed(int buttonId) {
+               if (buttonId == ADD_ID){
+                       addType(getLowerSelectedElement());
+               }
+               super.buttonPressed(buttonId);  
+       }
+
+       /*
+        * @see Dialog#okPressed
+        */
+       @Override
+       protected void okPressed() {
+           addType(getLowerSelectedElement());
+               super.okPressed();
+       }
+
+       private void addType(Object elem) {
+               if (elem instanceof ITypeInfo) {
+                   ITypeInfo type = (ITypeInfo)elem;
+                   if (fTypeList.contains(type)) {
+                String qualifiedName = type.getQualifiedTypeName().getFullyQualifiedName();
+                String message = NLS.bind(NewClassWizardMessages.NewBaseClassSelectionDialog_classalreadyadded_info, qualifiedName); 
+                updateStatus(new StatusInfo(IStatus.INFO, message));
+            } else {
+                               String qualifiedName = type.getQualifiedTypeName().getFullyQualifiedName();
+                               String message = NLS.bind(NewClassWizardMessages.NewBaseClassSelectionDialog_addingclass_info, qualifiedName); 
+                               updateStatus(new StatusInfo(IStatus.INFO, message));
+
+                boolean canAdd = true;
+                if (verifyBaseClasses()) {
+                    IProgressService service = PlatformUI.getWorkbench().getProgressService();
+                    NewClassWizardUtil.resolveClassLocation(type, service);
+                    canAdd = (type.getResolvedReference() != null);
+                }
+
+//                             // Resolve location of base class
+//                             if (type.getResolvedReference() == null) {
+//                                     final ITypeInfo[] typesToResolve = new ITypeInfo[] { type };
+//                                     IRunnableWithProgress runnable = new IRunnableWithProgress() {
+//                                             public void run(IProgressMonitor progressMonitor) throws InvocationTargetException, InterruptedException {
+//                                                     AllTypesCache.resolveTypeLocation(typesToResolve[0], progressMonitor);
+//                                                     if (progressMonitor.isCanceled()) {
+//                                                             throw new InterruptedException();
+//                                                     }
+//                                             }
+//                                     };
+//
+//                                     IProgressService service = PlatformUI.getWorkbench().getProgressService();
+//                                     try {
+//                                             service.busyCursorWhile(runnable);
+//                                     } catch (InvocationTargetException e) {
+//                                             String title= NewClassWizardMessages.getString("NewBaseClassSelectionDialog.getClasses.exception.title"); //$NON-NLS-1$
+//                                             String errorMessage= NewClassWizardMessages.getString("NewBaseClassSelectionDialog.getClasses.exception.message"); //$NON-NLS-1$
+//                                             ExceptionHandler.handle(e, title, errorMessage);
+//                                     } catch (InterruptedException e) {
+//                                             // Cancelled by user
+//                                     }
+//                             }
+
+                if (canAdd) {
+                                       fTypeList.add(type);
+
+                                       message = NLS.bind(NewClassWizardMessages.NewBaseClassSelectionDialog_classadded_info, qualifiedName); 
+                                       updateStatus(new StatusInfo(IStatus.INFO, message));
+
+                                       notifyTypeAddedListeners(type);
+                               } else {
+                                       message = NLS.bind(NewClassWizardMessages.NewBaseClassSelectionDialog_error_classnotadded, qualifiedName); 
+                                       updateStatus(new StatusInfo(IStatus.ERROR, message));
+                               }
+                   }
+               }
+       }
+
+    /**
+     * Checks if the base classes need to be verified (i.e. they must exist in the project)
+     * 
+     * @return <code>true</code> if the base classes should be verified
+     */
+    public boolean verifyBaseClasses() {
+        return NewClassWizardPrefs.verifyBaseClasses();
+    }
+
+       /*
+        * @see AbstractElementListSelectionDialog#handleDefaultSelected()
+        */
+       @Override
+       protected void handleDefaultSelected() {
+               if (validateCurrentSelection())
+                       buttonPressed(ADD_ID);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassCodeGenerator.java
new file mode 100644 (file)
index 0000000..9de3a40
--- /dev/null
@@ -0,0 +1,1229 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2011 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     IBM Corporation
+ *     Warren Paul (Nokia) - 173555
+ *     Anton Leherbauer (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.classwizard;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+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.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.text.edits.DeleteEdit;
+import org.eclipse.text.edits.MalformedTreeException;
+import org.eclipse.text.edits.MultiTextEdit;
+import org.eclipse.text.edits.TextEdit;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.browser.IQualifiedTypeName;
+import org.eclipse.cdt.core.browser.ITypeReference;
+import org.eclipse.cdt.core.browser.QualifiedTypeName;
+import org.eclipse.cdt.core.formatter.CodeFormatter;
+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.IIncludeEntry;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+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.ui.CUIPlugin;
+import org.eclipse.cdt.ui.CodeGeneration;
+import org.eclipse.cdt.utils.PathUtil;
+
+import org.eclipse.cdt.internal.corext.codemanipulation.StubUtility;
+import org.eclipse.cdt.internal.corext.util.CModelUtil;
+import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
+import org.eclipse.cdt.internal.corext.util.Strings;
+import org.eclipse.cdt.internal.formatter.scanner.Scanner;
+import org.eclipse.cdt.internal.formatter.scanner.Token;
+
+import org.eclipse.cdt.internal.ui.wizards.filewizard.NewSourceFileGenerator;
+
+public class NewClassCodeGenerator {
+    private final IPath fHeaderPath;
+    private final IPath fSourcePath;
+    private final IPath fTestPath;
+    private String fClassName;
+    private IQualifiedTypeName fNamespace;
+    private final IBaseClassInfo[] fBaseClasses;
+    private final IMethodStub[] fMethodStubs;
+    private ITranslationUnit fCreatedHeaderTU;
+    private ITranslationUnit fCreatedSourceTU;
+    private ITranslationUnit fCreatedTestTU;
+    private ICElement fCreatedClass;
+       private String fFullyQualifiedClassName;
+       private boolean fForceSourceFileCreation;
+    
+       /**
+        * When set to <code>true</code>, the source file is created, even if no stubs have
+        * been selected.
+        */
+       public void setForceSourceFileCreation(boolean force) {
+               fForceSourceFileCreation = force;
+       }
+
+       public static class CodeGeneratorException extends CoreException {
+        /**
+                * Comment for <code>serialVersionUID</code>
+                */
+               private static final long serialVersionUID = 1L;
+               
+        public CodeGeneratorException(String message) {
+            super(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK, message, null));
+        }
+        
+        public CodeGeneratorException(Throwable e) {
+            super(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK, e.getMessage(), e));
+        }
+       }
+
+       /**
+        * @param headerPath the header file path
+        * @param sourcePath the source file path
+        * @param testPath the test file path, can be {@code null}
+        * @param className the class name
+        * @param namespace the namespace name
+        * @param baseClasses the base classes
+        * @param methodStubs the method stubs
+        */
+    public NewClassCodeGenerator(IPath headerPath, IPath sourcePath, IPath testPath,
+               String className, String namespace, IBaseClassInfo[] baseClasses, IMethodStub[] methodStubs) {
+        fHeaderPath = headerPath;
+        fSourcePath = sourcePath;
+        fTestPath = testPath;
+        if (className != null && className.length() > 0) {
+            fClassName = className;
+        }
+        if (namespace != null && namespace.length() > 0) {
+            fNamespace = new QualifiedTypeName(namespace);
+        }
+        if (fNamespace != null) {
+               fFullyQualifiedClassName= fNamespace.append(fClassName).getFullyQualifiedName();
+        } else {
+               fFullyQualifiedClassName= fClassName;
+        }
+        fBaseClasses = baseClasses;
+        fMethodStubs = methodStubs;
+    }
+
+    public ICElement getCreatedClass() {
+        return fCreatedClass;
+    }
+
+    public ITranslationUnit getCreatedHeaderTU() {
+        return fCreatedHeaderTU;
+    }
+    
+    public IFile getCreatedHeaderFile() {
+        if (fCreatedHeaderTU != null) {
+            return (IFile) fCreatedHeaderTU.getResource();
+        }
+        return null;
+    }
+
+    public ITranslationUnit getCreatedSourceTU() {
+        return fCreatedSourceTU;
+    }
+
+    public IFile getCreatedSourceFile() {
+        if (fCreatedSourceTU != null) {
+            return (IFile) fCreatedSourceTU.getResource();
+        }
+        return null;
+    }
+
+    public IFile getCreatedTestFile() {
+        if (fCreatedTestTU != null) {
+            return (IFile) fCreatedTestTU.getResource();
+        }
+        return null;
+    }
+
+    /**
+     * Creates the new class.
+     * 
+     * @param monitor
+     *            a progress monitor to report progress.
+     * @throws CoreException
+     *             Thrown when the creation failed.
+     * @throws InterruptedException
+     *             Thrown when the operation was cancelled.
+     */
+    public ICElement createClass(IProgressMonitor monitor)
+               throws CodeGeneratorException, CoreException, InterruptedException {
+        if (monitor == null)
+            monitor = new NullProgressMonitor();
+
+        monitor.beginTask(NewClassWizardMessages.NewClassCodeGeneration_createType_mainTask, 400); 
+
+           ITranslationUnit headerTU = null;
+        ITranslationUnit sourceTU = null;
+        ITranslationUnit testTU = null;
+        ICElement createdClass = null;
+
+        IWorkingCopy headerWorkingCopy = null;
+        IWorkingCopy sourceWorkingCopy = null;
+        IWorkingCopy testWorkingCopy = null;
+        try {
+            if (fHeaderPath != null) {
+                // Get method stubs
+                List<IMethodStub> publicMethods = getStubs(ASTAccessVisibility.PUBLIC, false);
+                List<IMethodStub> protectedMethods = getStubs(ASTAccessVisibility.PROTECTED, false);
+                List<IMethodStub> privateMethods = getStubs(ASTAccessVisibility.PRIVATE, false);
+                
+                   IFile headerFile = NewSourceFileGenerator.createHeaderFile(fHeaderPath, true,
+                               new SubProgressMonitor(monitor, 50));
+                   if (headerFile != null) {
+                       headerTU = (ITranslationUnit) CoreModel.getDefault().create(headerFile);
+       
+                       // Create a working copy with a new owner
+                       headerWorkingCopy = headerTU.getWorkingCopy();
+                       // headerWorkingCopy = headerTU.getSharedWorkingCopy(null, CUIPlugin.getDefault().getBufferFactory());
+
+                       String headerContent = constructHeaderFileContent(headerTU, publicMethods,
+                                       protectedMethods, privateMethods, headerWorkingCopy.getBuffer().getContents(),
+                                       new SubProgressMonitor(monitor, 100));
+                       if (headerContent != null) {
+                               headerContent= formatSource(headerContent, headerTU);   
+                       } else {
+                               headerContent = ""; //$NON-NLS-1$
+                       }
+                       headerWorkingCopy.getBuffer().setContents(headerContent);
+
+                       if (monitor.isCanceled()) {
+                               throw new InterruptedException();
+                       }
+
+                       headerWorkingCopy.reconcile();
+                       headerWorkingCopy.commit(true, monitor);
+                       monitor.worked(50);
+
+                       createdClass = headerWorkingCopy.getElement(fFullyQualifiedClassName);
+                   }
+                   fCreatedClass = createdClass;
+                   fCreatedHeaderTU = headerTU;
+            }
+
+            if (fSourcePath != null) {
+                // Get method stubs
+                List<IMethodStub> publicMethods = getStubs(ASTAccessVisibility.PUBLIC, true);
+                List<IMethodStub> protectedMethods = getStubs(ASTAccessVisibility.PROTECTED, true);
+                List<IMethodStub> privateMethods = getStubs(ASTAccessVisibility.PRIVATE, true);
+                
+                if (!fForceSourceFileCreation && publicMethods.isEmpty() &&
+                               protectedMethods.isEmpty() && privateMethods.isEmpty()) {
+                    monitor.worked(100);
+                } else {
+                           IFile sourceFile = NewSourceFileGenerator.createSourceFile(fSourcePath, true,
+                                       new SubProgressMonitor(monitor, 50));
+                           if (sourceFile != null) {
+                               sourceTU = (ITranslationUnit) CoreModel.getDefault().create(sourceFile);
+                               monitor.worked(50);
+
+                               // Create a working copy with a new owner
+                               sourceWorkingCopy = sourceTU.getWorkingCopy();
+
+                               String sourceContent = constructSourceFileContent(sourceTU, headerTU,
+                                               publicMethods, protectedMethods, privateMethods,
+                                               sourceWorkingCopy.getBuffer().getContents(), new SubProgressMonitor(monitor, 100));
+                               if (sourceContent != null) {
+                                       sourceContent = formatSource(sourceContent, sourceTU);  
+                               } else {
+                                       sourceContent = ""; //$NON-NLS-1$
+                               }
+                               sourceWorkingCopy.getBuffer().setContents(sourceContent);
+
+                               if (monitor.isCanceled()) {
+                                       throw new InterruptedException();
+                               }
+
+                               sourceWorkingCopy.reconcile();
+                               sourceWorkingCopy.commit(true, monitor);
+                               monitor.worked(50);
+                           }
+               
+                           fCreatedSourceTU = sourceTU;
+                }
+            }
+
+            if (fTestPath != null) {
+                   IFile testFile = NewSourceFileGenerator.createTestFile(fTestPath, true,
+                               new SubProgressMonitor(monitor, 50));
+                   if (testFile != null) {
+                       testTU = (ITranslationUnit) CoreModel.getDefault().create(testFile);
+                       monitor.worked(50);
+
+                       // Create a working copy with a new owner
+                       testWorkingCopy = testTU.getWorkingCopy();
+
+                       String testContent = constructTestFileContent(testTU, headerTU,
+                                       testWorkingCopy.getBuffer().getContents(), new SubProgressMonitor(monitor, 100));
+                       testContent= formatSource(testContent, testTU);
+                       testWorkingCopy.getBuffer().setContents(testContent);
+
+                       if (monitor.isCanceled()) {
+                               throw new InterruptedException();
+                       }
+
+                       testWorkingCopy.reconcile();
+                       testWorkingCopy.commit(true, monitor);
+                       monitor.worked(50);
+                   }
+       
+                   fCreatedTestTU = testTU;
+            }
+        } finally {
+            if (headerWorkingCopy != null) {
+                headerWorkingCopy.destroy();
+            }
+            if (sourceWorkingCopy != null) {
+                sourceWorkingCopy.destroy();
+            }
+            if (testWorkingCopy != null) {
+                testWorkingCopy.destroy();
+            }
+            monitor.done();
+        }
+
+        return fCreatedClass;
+    }
+
+    /**
+     * Format given source content according to the project's code style options.
+     * 
+        * @param content  the source content
+        * @param tu  the translation unit
+        * @return the formatted source text or the original if the text could not be formatted successfully
+     * @throws CModelException 
+        */
+       private String formatSource(String content, ITranslationUnit tu) throws CModelException {
+        String lineDelimiter= StubUtility.getLineDelimiterUsed(tu);
+        TextEdit edit= CodeFormatterUtil.format(CodeFormatter.K_TRANSLATION_UNIT, content, 0, lineDelimiter,
+                       tu.getCProject().getOptions(true));
+        if (edit != null) {
+               IDocument doc= new Document(content);
+               try {
+                               edit.apply(doc);
+               content= doc.get();
+                       } catch (MalformedTreeException exc) {
+                               CUIPlugin.log(exc);
+                       } catch (BadLocationException exc) {
+                               CUIPlugin.log(exc);
+                       }
+        }
+        return content;
+       }
+
+       public String constructHeaderFileContent(ITranslationUnit headerTU, List<IMethodStub> publicMethods,
+                       List<IMethodStub> protectedMethods, List<IMethodStub> privateMethods, String oldContents,
+                       IProgressMonitor monitor) throws CoreException {
+        monitor.beginTask(NewClassWizardMessages.NewClassCodeGeneration_createType_task_header, 100); 
+        
+        String lineDelimiter= StubUtility.getLineDelimiterUsed(headerTU);
+
+       String namespaceBegin = fNamespace == null ?
+                       null : constructNamespaceBegin(headerTU, lineDelimiter);
+       String namespaceEnd = fNamespace == null ?
+                       null : constructNamespaceEnd(headerTU, lineDelimiter);
+       String classDefinition = constructClassDefinition(headerTU, publicMethods, protectedMethods,
+                       privateMethods, lineDelimiter);
+
+        String includes = null;
+        if (fBaseClasses != null && fBaseClasses.length > 0) {
+            includes = constructBaseClassIncludes(headerTU, lineDelimiter,
+                       new SubProgressMonitor(monitor, 50));
+        }
+
+        if (oldContents != null) {
+               if (oldContents.length() == 0) {
+                       oldContents = null;
+               } else if (!oldContents.endsWith(lineDelimiter)) {
+                       oldContents += lineDelimiter;
+               }
+        }
+
+        String fileContent;
+        if (oldContents != null) {
+            int appendFirstCharPos = -1;
+            StringBuilder text = new StringBuilder();
+               int insertionPos = getClassDefInsertionPos(oldContents);
+               if (insertionPos == -1) {
+                       text.append(oldContents);
+               } else {
+                   // Skip over whitespace
+                   int prependLastCharPos = insertionPos - 1;
+                   while (prependLastCharPos >= 0 && Character.isWhitespace(oldContents.charAt(prependLastCharPos))) {
+                       --prependLastCharPos;
+                   }
+                   if (prependLastCharPos >= 0) {
+                       text.append(oldContents.substring(0, prependLastCharPos + 1));
+                   }
+                   appendFirstCharPos = prependLastCharPos + 1;
+               }
+            text.append(lineDelimiter);
+            
+            // Insert a blank line before class definition
+            text.append(lineDelimiter);
+            if (namespaceBegin != null) {
+               text.append(namespaceBegin);
+               text.append(lineDelimiter);
+               text.append(lineDelimiter);
+            }
+            text.append(classDefinition);
+            if (namespaceEnd != null) {
+               if (!classDefinition.endsWith(lineDelimiter))
+                       text.append(lineDelimiter);
+               text.append(lineDelimiter);
+               text.append(namespaceEnd);
+            }
+            if (appendFirstCharPos != -1) {
+                // Insert a blank line after class definition
+                text.append(lineDelimiter);
+                
+                // Skip over any extra whitespace
+                int len = oldContents.length();
+                while (appendFirstCharPos < len &&
+                               Character.isWhitespace(oldContents.charAt(appendFirstCharPos))) {
+                    ++appendFirstCharPos;
+                }
+                if (appendFirstCharPos < len) {
+                    text.append(oldContents.substring(appendFirstCharPos));
+                }
+            }
+            if (Strings.endsWith(text, lineDelimiter))
+               text.append(lineDelimiter);
+            fileContent= text.toString();
+        } else {
+               String namespaceName = fNamespace == null ?
+                               null : fNamespace.getFullyQualifiedName();
+               String classComment = getClassComment(headerTU, lineDelimiter);
+               fileContent= CodeGeneration.getHeaderFileContent(headerTU, includes, namespaceBegin,
+                               namespaceEnd, namespaceName, classComment, classDefinition, fClassName,
+                               lineDelimiter);
+        }
+
+        monitor.done();
+        return fileContent;
+    }
+
+       public String constructNamespaceBegin(ITranslationUnit tu, String lineDelimiter) throws CoreException {
+               StringBuilder text = new StringBuilder();
+               for (int i = 0; i < fNamespace.segmentCount(); i++) {
+                   String namespaceName = fNamespace.segment(i);
+                   if (i > 0) {
+                       text.append(lineDelimiter);
+                   }
+                   text.append(CodeGeneration.getNamespaceBeginContent(tu, namespaceName, lineDelimiter));
+               }
+               return text.toString();
+       }
+
+       public String constructNamespaceEnd(ITranslationUnit tu, String lineDelimiter) throws CoreException {
+               StringBuilder text = new StringBuilder();
+               for (int i = fNamespace.segmentCount(); --i >= 0;) {
+                   String namespaceName = fNamespace.segment(i);
+                   text.append(CodeGeneration.getNamespaceEndContent(tu, namespaceName, lineDelimiter));
+                   if (i > 0) {
+                       text.append(lineDelimiter);
+                   }
+               }
+               return text.toString();
+       }
+
+       public String constructClassDefinition(ITranslationUnit tu, List<IMethodStub> publicMethods,
+                       List<IMethodStub> protectedMethods,     List<IMethodStub> privateMethods,
+                       String lineDelimiter) throws CoreException {
+        StringBuilder code = new StringBuilder();
+        String comment = getClassComment(tu, lineDelimiter);
+        if (comment != null) {
+               code.append(comment);
+               code.append(lineDelimiter);
+        }
+        code.append("class "); //$NON-NLS-1$
+        code.append(fClassName);
+        code.append(constructBaseClassInheritance());
+        code.append(" {"); //$NON-NLS-1$
+       code.append(lineDelimiter);
+               String body = constructMethodDeclarations(tu, publicMethods, protectedMethods,
+                               privateMethods, lineDelimiter);
+        body = CodeGeneration.getClassBodyContent(tu, fClassName, body, lineDelimiter);
+        if (body != null) {
+               code.append(body);
+               if (!body.endsWith(lineDelimiter)) {
+                       code.append(lineDelimiter);
+               }
+        }
+        code.append("};"); //$NON-NLS-1$
+        return removeRedundantVisibilityLabels(code.toString());
+       }
+
+    private String removeRedundantVisibilityLabels(String code) {
+               Scanner scanner = new Scanner();
+               scanner.setSource(code.toCharArray());
+               scanner.resetTo(0, code.length());
+               IDocument doc = new Document(code);
+               try {
+                       MultiTextEdit edit = new MultiTextEdit();
+                       int sectionType = Token.tBADCHAR;
+                       int previousTokenType = Token.tBADCHAR;
+                       int previousTokenOffset = -1;
+                       Token token;
+                       while ((token = scanner.nextToken()) != null) {
+                               if (token.type == Token.tCOLON) {
+                                       switch (previousTokenType) {
+                                       case Token.t_public:
+                                       case Token.t_protected:
+                                       case Token.t_private:
+                                               if (previousTokenType == sectionType) {
+                                                       IRegion region1 = doc.getLineInformationOfOffset(previousTokenOffset);
+                                                       IRegion region2 = doc.getLineInformationOfOffset(token.offset);
+                                                       edit.addChild(new DeleteEdit(region1.getOffset(), region2.getOffset() + region2.getLength() - region1.getOffset()));
+                                               }
+                                               sectionType = previousTokenType;
+                                       }
+                               }
+                               previousTokenType = token.type;
+                               previousTokenOffset = token.offset;
+                       }
+                       edit.apply(doc, 0);
+               } catch (MalformedTreeException e) {
+                       CUIPlugin.log(e);
+               } catch (BadLocationException e) {
+                       CUIPlugin.log(e);
+               }
+               return doc.get();
+       }
+
+       private int getClassDefInsertionPos(String contents) {
+        if (contents.length() == 0) {
+            return -1;
+        }
+        //TODO temporary hack
+        int insertPos = contents.lastIndexOf("#endif"); //$NON-NLS-1$
+        if (insertPos != -1) {
+            // check if any code follows the #endif
+            if ((contents.indexOf('}', insertPos) != -1)
+                    || (contents.indexOf(';', insertPos) != -1)) {
+                return -1;
+            }
+        }
+        return insertPos;
+    }
+    
+       /**
+        * Retrieve the class comment. Returns the content of the 'type comment' template.
+        * 
+        * @param tu the translation unit
+        * @param lineDelimiter the line delimiter to use
+        * @return the type comment or <code>null</code> if a type comment 
+        * is not desired
+     *
+     * @since 5.0
+        */             
+       private String getClassComment(ITranslationUnit tu, String lineDelimiter) {
+               if (isAddComments(tu)) {
+                       try {
+                               String fqName= fFullyQualifiedClassName;
+                               String comment= CodeGeneration.getClassComment(tu, fqName, lineDelimiter);
+                               if (comment != null && isValidComment(comment)) {
+                                       return comment;
+                               }
+                       } catch (CoreException e) {
+                               CUIPlugin.log(e);
+                       }
+               }
+               return null;
+       }
+
+       private boolean isValidComment(String template) {
+               // TODO verify comment
+               return true;
+       }
+       
+       /**
+        * Returns if comments are added. The settings as specified in the preferences is used.
+        * 
+        * @param tu
+        * @return Returns <code>true</code> if comments can be added
+        * @since 5.0
+        */
+       public boolean isAddComments(ITranslationUnit tu) {
+               return StubUtility.doAddComments(tu.getCProject()); 
+       }
+                       
+    private String constructMethodDeclarations(ITranslationUnit tu, List<IMethodStub> publicMethods,
+               List<IMethodStub> protectedMethods, List<IMethodStub> privateMethods, String lineDelimiter)
+               throws CoreException {
+       StringBuilder text = new StringBuilder();
+        if (!publicMethods.isEmpty()) {
+            text.append("public:"); //$NON-NLS-1$
+            text.append(lineDelimiter);
+            for (IMethodStub stub : publicMethods) {
+                String code = stub.createMethodDeclaration(tu, fClassName, fBaseClasses, lineDelimiter);
+                text.append('\t');
+                text.append(code);
+                text.append(lineDelimiter);
+            }
+        }
+
+        if (!protectedMethods.isEmpty()) {
+               if (text.length() > 0) {
+                text.append(lineDelimiter);
+               }
+            text.append("protected:"); //$NON-NLS-1$
+            text.append(lineDelimiter);
+            for (IMethodStub stub : protectedMethods) {
+                String code = stub.createMethodDeclaration(tu, fClassName, fBaseClasses, lineDelimiter);
+                text.append('\t');
+                text.append(code);
+                text.append(lineDelimiter);
+            }
+        }
+
+        if (!privateMethods.isEmpty()) {
+               if (text.length() > 0) {
+                text.append(lineDelimiter);
+               }
+            text.append("private:"); //$NON-NLS-1$
+            text.append(lineDelimiter);
+            for (IMethodStub stub : privateMethods) {
+                String code = stub.createMethodDeclaration(tu, fClassName, fBaseClasses, lineDelimiter);
+                text.append('\t');
+                text.append(code);
+                text.append(lineDelimiter);
+            }
+        }
+
+        return text.toString();
+    }
+
+    private List<IMethodStub> getStubs(ASTAccessVisibility access, boolean skipInline) {
+        List<IMethodStub> list = new ArrayList<IMethodStub>();
+        if (fMethodStubs != null) {
+            for (int i = 0; i < fMethodStubs.length; ++i) {
+                IMethodStub stub = fMethodStubs[i];
+                if (stub.getAccess() == access && (!skipInline || !stub.isInline())) {
+                    list.add(stub);
+                }
+            }
+        }
+        return list;
+    }
+
+    private String constructBaseClassInheritance() {
+        if (fBaseClasses == null || fBaseClasses.length == 0) {
+               return ""; //$NON-NLS-1$
+        }
+       StringBuilder text = new StringBuilder();
+        text.append(" : "); //$NON-NLS-1$
+        for (int i = 0; i < fBaseClasses.length; ++i) {
+            IBaseClassInfo baseClass = fBaseClasses[i];
+            String baseClassName = baseClass.getType().getQualifiedTypeName().getFullyQualifiedName();
+            if (i > 0)
+                text.append(", "); //$NON-NLS-1$
+            if (baseClass.getAccess() == ASTAccessVisibility.PRIVATE)
+                text.append("private"); //$NON-NLS-1$
+            else if (baseClass.getAccess() == ASTAccessVisibility.PROTECTED)
+                text.append("private"); //$NON-NLS-1$
+            else
+                text.append("public"); //$NON-NLS-1$
+            text.append(' ');
+
+            if (baseClass.isVirtual())
+                text.append("virtual "); //$NON-NLS-1$
+
+            text.append(baseClassName);
+        }
+        return text.toString();
+    }
+
+    private String constructBaseClassIncludes(ITranslationUnit headerTU, String lineDelimiter,
+               IProgressMonitor monitor) throws CodeGeneratorException {
+        monitor.beginTask(NewClassWizardMessages.NewClassCodeGeneration_createType_task_header_includePaths, 100); 
+        
+        ICProject cProject = headerTU.getCProject();
+        IProject project = cProject.getProject();
+        IPath projectLocation = new Path(project.getLocationURI().getPath());
+        IPath headerLocation = new Path(headerTU.getResource().getLocationURI().getPath());
+        
+        List<IPath> includePaths = getIncludePaths(headerTU);
+        List<IPath> baseClassPaths = getBaseClassPaths(verifyBaseClasses());
+        
+           // Add the missing include paths to the project
+        if (createIncludePaths()) {
+               List<IPath> newIncludePaths = getMissingIncludePaths(projectLocation, includePaths, baseClassPaths);
+               if (!newIncludePaths.isEmpty()) {
+                           addIncludePaths(cProject, newIncludePaths, monitor);
+               }
+        }
+
+        List<IPath> systemIncludes = new ArrayList<IPath>();
+        List<IPath> localIncludes = new ArrayList<IPath>();
+        
+        // Sort the include paths into system and local
+        for (IPath baseClassLocation : baseClassPaths) {
+            boolean isSystemIncludePath = false;
+
+            IPath includePath = PathUtil.makeRelativePathToProjectIncludes(baseClassLocation, project);
+            if (includePath != null && !projectLocation.isPrefixOf(baseClassLocation)) {
+                isSystemIncludePath = true;
+            } else if (projectLocation.isPrefixOf(baseClassLocation)
+                    && projectLocation.isPrefixOf(headerLocation)) {
+                includePath = PathUtil.makeRelativePath(baseClassLocation, headerLocation.removeLastSegments(1));
+            }
+            if (includePath == null)
+                includePath = baseClassLocation;
+            
+            // Make the new #include path in the source file only point to a relative file
+            // (i.e. now that the path has been included above in the project)
+            includePath = includePath.removeFirstSegments(includePath.segmentCount() - 1).setDevice(null);
+            
+            if (isSystemIncludePath)
+                systemIncludes.add(includePath);
+            else
+                localIncludes.add(includePath);
+        }
+        
+       StringBuilder text = new StringBuilder();
+        // Write the system include paths, e.g. #include <header.h>
+        for (IPath includePath : systemIncludes) {
+            if (!(headerTU.getElementName().equals(includePath.toString()))) {
+                           String include = getIncludeString(includePath.toString(), true);
+                           text.append(include);
+                           text.append(lineDelimiter);
+                       }
+        }
+        
+        // Write the local include paths, e.g. #include "header.h"
+        for (IPath includePath : localIncludes) {
+            if (!(headerTU.getElementName().equals(includePath.toString()))) {
+                           String include = getIncludeString(includePath.toString(), false);
+                           text.append(include);
+                           text.append(lineDelimiter);
+                       }
+        }
+        
+        monitor.done();
+        return text.toString();
+    }
+    
+    /**
+     * Checks if the base classes need to be verified (ie they must exist in the project)
+     * 
+     * @return <code>true</code> if the base classes should be verified
+     */
+    private boolean verifyBaseClasses() {
+        return NewClassWizardPrefs.verifyBaseClasses();
+    }
+
+    /**
+     * Checks if include paths can be added to the project as needed.
+     *
+     * @return <code>true</code> if the include paths should be added
+     */
+    private boolean createIncludePaths() {
+        return NewClassWizardPrefs.createIncludePaths();
+    }
+
+    private void addIncludePaths(ICProject cProject, List<IPath> newIncludePaths, IProgressMonitor monitor) throws CodeGeneratorException {
+        monitor.beginTask(NewClassWizardMessages.NewClassCodeGeneration_createType_task_header_addIncludePaths, 100); 
+
+        //TODO prefs option whether to add to project or parent source folder?
+        IPath addToResourcePath = cProject.getPath();
+        try {
+            List<IPathEntry> pathEntryList = new ArrayList<IPathEntry>();
+            List<IPathEntry> checkEntryList = new ArrayList<IPathEntry>();
+            
+            IPathEntry[] checkEntries = cProject.getResolvedPathEntries();
+            IPathEntry[] pathEntries = cProject.getRawPathEntries();
+            if (pathEntries != null) {
+                for (int i = 0; i < pathEntries.length; ++i) {
+                       pathEntryList.add(pathEntries[i]);
+                }
+            }
+            for (IPathEntry checkEntrie : checkEntries) {
+               if (checkEntrie instanceof IIncludeEntry)
+                       checkEntryList.add(checkEntrie);
+            }
+            
+            for (IPath folderToAdd : newIncludePaths) {
+                // do not add any #includes that are local to the project
+                if (cProject.getPath().segment(0).equals(folderToAdd.segment(0)))
+                       continue;
+                
+                ICProject includeProject = toCProject(PathUtil.getEnclosingProject(folderToAdd));
+                if (includeProject != null) {
+                    // Make sure that the include is made the same way that build properties for
+                       // projects makes them, so .contains below is a valid check
+                    IIncludeEntry entry = CoreModel.newIncludeEntry(addToResourcePath, null, new Path(includeProject.getProject().getLocationURI().getPath()), true);
+                    
+                    if (!checkEntryList.contains(entry)) // if the path already exists in the #includes then don't add it
+                       pathEntryList.add(entry);
+                }
+            }
+            pathEntries = pathEntryList.toArray(new IPathEntry[pathEntryList.size()]);
+            cProject.setRawPathEntries(pathEntries, new SubProgressMonitor(monitor, 80));
+        } catch (CModelException e) {
+            throw new CodeGeneratorException(e);
+        }
+        monitor.done();
+    }
+
+       private ICProject toCProject(IProject enclosingProject) {
+               if (enclosingProject != null)
+                       return CoreModel.getDefault().create(enclosingProject);
+               return null;
+       }
+
+       private List<IPath> getMissingIncludePaths(IPath projectLocation, List<IPath> includePaths, List<IPath> baseClassPaths) {
+        // check for missing include paths
+        List<IPath> newIncludePaths = new ArrayList<IPath>();
+        for (IPath baseClassLocation : baseClassPaths) {
+            // skip any paths inside the same project
+            //TODO possibly a preferences option?
+            if (projectLocation.isPrefixOf(baseClassLocation)) {
+                continue;
+            }
+
+            IPath folderToAdd = baseClassLocation.removeLastSegments(1);
+            IPath canonPath = PathUtil.getCanonicalPath(folderToAdd);
+            if (canonPath != null)
+                folderToAdd = canonPath;
+
+            // see if folder or its parent hasn't already been added
+            for (IPath newFolder : newIncludePaths) {
+                if (newFolder.isPrefixOf(folderToAdd)) {
+                       folderToAdd = null;
+                       break;
+                   }
+            }
+
+            if (folderToAdd != null) {
+                   // search include paths
+                boolean foundPath = false;
+                   for (IPath includePath : includePaths) {
+                       if (includePath.isPrefixOf(folderToAdd) || includePath.equals(folderToAdd)) {
+                               foundPath = true;
+                               break;
+                           }
+                   }
+                   if (!foundPath) {
+                    // remove any children of this folder
+                    for (Iterator<IPath> newIter = newIncludePaths.iterator(); newIter.hasNext(); ) {
+                        IPath newFolder = newIter.next();
+                           if (folderToAdd.isPrefixOf(newFolder)) {
+                               newIter.remove();
+                           }
+                    }
+                    if (!newIncludePaths.contains(folderToAdd)) {
+                        newIncludePaths.add(folderToAdd);
+                    }
+                   }
+            }
+        }
+        return newIncludePaths;
+    }
+
+    private List<IPath> getIncludePaths(ITranslationUnit headerTU) throws CodeGeneratorException {
+        IProject project = headerTU.getCProject().getProject();
+        // get the parent source folder
+        ICContainer sourceFolder = CModelUtil.getSourceFolder(headerTU);
+        if (sourceFolder == null) {
+            throw new CodeGeneratorException("Could not find source folder"); //$NON-NLS-1$
+        }
+
+        // get the include paths
+        IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project);
+        if (provider != null) {
+            IScannerInfo info = provider.getScannerInformation(sourceFolder.getResource());
+            if (info != null) {
+                String[] includePaths = info.getIncludePaths();
+                if (includePaths != null) {
+                    List<IPath> list = new ArrayList<IPath>();
+                    for (int i = 0; i < includePaths.length; ++i) {
+                        //TODO do we need to canonicalize these paths first?
+                        IPath path = new Path(includePaths[i]);
+                        if (!list.contains(path)) {
+                            list.add(path);
+                        }
+                    }
+                    return list;
+                }
+            }
+        }
+        return null;
+    }
+    
+    private List<IPath> getBaseClassPaths(boolean verifyLocation) throws CodeGeneratorException {
+        List<IPath> list = new ArrayList<IPath>();
+           for (int i = 0; i < fBaseClasses.length; ++i) {
+               IBaseClassInfo baseClass = fBaseClasses[i];
+               ITypeReference ref = baseClass.getType().getResolvedReference();
+               IPath baseClassLocation = null;
+               if (ref != null) {
+                   baseClassLocation = ref.getLocation();
+            }
+            
+               if (baseClassLocation == null) {
+                if (verifyLocation) {
+                    throw new CodeGeneratorException("Could not find base class " + baseClass.toString()); //$NON-NLS-1$
+                }
+               } else if (!list.contains(baseClassLocation)) {
+                list.add(baseClassLocation);
+            }
+           }
+           return list;
+    }
+    
+    public String constructSourceFileContent(ITranslationUnit sourceTU, ITranslationUnit headerTU,
+               List<IMethodStub> publicMethods, List<IMethodStub> protectedMethods,
+               List<IMethodStub> privateMethods, String oldContents, IProgressMonitor monitor) throws CoreException {
+        monitor.beginTask(NewClassWizardMessages.NewClassCodeGeneration_createType_task_source, 150); 
+        
+        String lineDelimiter= StubUtility.getLineDelimiterUsed(sourceTU);
+        String includeString = null;
+        if (headerTU != null) {
+            includeString = getHeaderIncludeString(sourceTU, headerTU, new SubProgressMonitor(monitor, 50));
+               if (includeString != null) {
+                   // Check if file already has the include.
+                   if (oldContents != null && hasInclude(oldContents, includeString)) {
+                       // Don't bother to add it.
+                       includeString = null;
+                   }
+               }
+        }
+
+        String methodBodies = null;
+        if (!publicMethods.isEmpty() || !protectedMethods.isEmpty() || !privateMethods.isEmpty()) {
+            // TODO sort methods (e.g. constructor always first?)
+            methodBodies = constructMethodBodies(sourceTU, publicMethods, protectedMethods,
+                       privateMethods, lineDelimiter, new SubProgressMonitor(monitor, 50));
+        }
+
+       String namespaceBegin = fNamespace == null ?
+                       null : constructNamespaceBegin(sourceTU, lineDelimiter);
+       String namespaceEnd = fNamespace == null ?
+                       null : constructNamespaceEnd(sourceTU, lineDelimiter);
+
+        if (oldContents != null) {
+               if (oldContents.length() == 0) {
+                       oldContents = null;
+               } else if (!oldContents.endsWith(lineDelimiter)) {
+                       oldContents += lineDelimiter;
+               }
+        }
+
+       String fileContent;
+        if (oldContents != null) {
+            StringBuilder text = new StringBuilder();
+
+               if (includeString != null) {
+               int insertionPos = getIncludeInsertionPos(oldContents);
+               if (insertionPos == -1) {
+                       text.append(oldContents);
+                    text.append(lineDelimiter);
+                    text.append(includeString);
+                    text.append(lineDelimiter);
+               } else {
+                   text.append(oldContents.substring(0, insertionPos));
+                    text.append(includeString);
+                    text.append(lineDelimiter);
+                    text.append(oldContents.substring(insertionPos));
+               }
+               } else {
+                       text.append(oldContents);
+               }
+            // Add a blank line
+            text.append(lineDelimiter);
+
+            if (methodBodies != null) {
+                   if (namespaceBegin != null) {
+                       text.append(namespaceBegin);
+                       text.append(lineDelimiter);
+                       text.append(lineDelimiter);
+                   }
+                   text.append(methodBodies);
+                   if (namespaceEnd != null) {
+                       if (!methodBodies.endsWith(lineDelimiter))
+                               text.append(lineDelimiter);
+                       text.append(lineDelimiter);
+                       text.append(namespaceEnd);
+                   }
+            }
+            
+            if (Strings.endsWith(text, lineDelimiter))
+               text.append(lineDelimiter);
+               fileContent = text.toString();
+        } else {
+               String namespaceName = fNamespace == null ?
+                               null : fNamespace.getFullyQualifiedName();
+               fileContent= CodeGeneration.getBodyFileContent(sourceTU, includeString, namespaceBegin,
+                               namespaceEnd, namespaceName, null, methodBodies, fClassName, lineDelimiter);
+        }
+        monitor.done();
+        return fileContent;
+    }
+    
+    public String constructTestFileContent(ITranslationUnit testTU, ITranslationUnit headerTU,
+               String oldContents, IProgressMonitor monitor) throws CoreException {
+        monitor.beginTask(NewClassWizardMessages.NewClassCodeGeneration_createType_task_source, 150); 
+        
+        String lineDelimiter= StubUtility.getLineDelimiterUsed(testTU);
+
+        String includeString = null;
+        if (headerTU != null) {
+            includeString = getHeaderIncludeString(testTU, headerTU, new SubProgressMonitor(monitor, 50));
+               if (includeString != null) {
+                   // Check if file already has the include.
+                   if (oldContents != null && hasInclude(oldContents, includeString)) {
+                       // Don't bother to add it.
+                       includeString = null;
+                   }
+               }
+        }
+        
+        if (oldContents != null) {
+               if (oldContents.length() == 0) {
+                       oldContents = null;
+               } else if (!oldContents.endsWith(lineDelimiter)) {
+                       oldContents += lineDelimiter;
+               }
+        }
+
+        String fileContent;
+        if (oldContents != null) {
+            StringBuilder text = new StringBuilder();
+
+               if (includeString != null) {
+               int insertionPos = getIncludeInsertionPos(oldContents);
+               if (insertionPos == -1) {
+                       text.append(oldContents);
+                    text.append(lineDelimiter);
+                    text.append(includeString);
+                    text.append(lineDelimiter);
+               } else {
+                   text.append(oldContents.substring(0, insertionPos));
+                    text.append(includeString);
+                    text.append(lineDelimiter);
+                    text.append(oldContents.substring(insertionPos));
+               }
+               } else {
+                       text.append(oldContents);
+               }
+
+               if (Strings.endsWith(text, lineDelimiter))
+               text.append(lineDelimiter);
+               fileContent = text.toString();
+        } else {
+               String namespaceBegin = fNamespace == null ?
+                               null : constructNamespaceBegin(testTU, lineDelimiter);
+               String namespaceEnd = fNamespace == null ?
+                               null : constructNamespaceEnd(testTU, lineDelimiter);
+               String namespaceName = fNamespace == null ?
+                               null : fNamespace.getFullyQualifiedName();
+               fileContent= CodeGeneration.getTestFileContent(testTU, includeString, namespaceBegin,
+                               namespaceEnd, namespaceName, null, fClassName, lineDelimiter);
+        }
+        monitor.done();
+        return fileContent;
+    }
+    
+    private String getHeaderIncludeString(ITranslationUnit sourceTU, ITranslationUnit headerTU,
+               IProgressMonitor monitor) {
+        IProject project = headerTU.getCProject().getProject();
+        IPath projectLocation = new Path(project.getLocationURI().getPath());
+        IPath headerLocation = new Path(headerTU.getResource().getLocationURI().getPath());
+        IPath sourceLocation = new Path(sourceTU.getResource().getLocationURI().getPath());
+
+        IPath includePath = PathUtil.makeRelativePathToProjectIncludes(headerLocation, project);
+        boolean isSystemIncludePath = false;
+        if (headerTU.getResource() == null && includePath != null
+                       && !projectLocation.isPrefixOf(headerLocation)) {
+            isSystemIncludePath = true;
+        } else if (projectLocation.isPrefixOf(headerLocation)
+                       && projectLocation.isPrefixOf(sourceLocation)) {
+            includePath = PathUtil.makeRelativePath(headerLocation, sourceLocation.removeLastSegments(1));
+        }
+        if (includePath == null)
+            includePath = headerLocation;
+
+        return getIncludeString(includePath.toString(), isSystemIncludePath);
+    }
+
+    private boolean hasInclude(String contents, String include) {
+        int maxStartPos = contents.length() - include.length() - 1;
+        if (maxStartPos < 0) {
+            return false;
+        }
+        int startPos = 0;
+        while (startPos <= maxStartPos) {
+               int includePos = contents.indexOf(include, startPos);
+               if (includePos == -1) {
+                   return false;
+               }
+               if (includePos == startPos) {
+                       return true;
+               }
+               
+               // TODO detect if it's commented out
+               
+               // make sure it's on a line by itself
+               int linePos = findFirstLineChar(contents, includePos);
+               if (linePos == -1 || linePos == includePos) {
+                       return true;
+               }
+               boolean badLine = false;
+               for (int pos = linePos; pos < includePos; ++pos) {
+                       char c = contents.charAt(pos);
+                       if (!Character.isWhitespace(c)) {
+                               badLine = true;
+                               break;
+                       }
+               }
+               if (!badLine) {
+                       return true;
+               }
+               
+               // keep searching
+               startPos = includePos + include.length();
+        }
+        return false;
+    }
+
+    private int getIncludeInsertionPos(String contents) {
+        if (contents.length() == 0) {
+            return -1;
+        }
+        //TODO temporary hack
+        int includePos = contents.lastIndexOf("#include "); //$NON-NLS-1$
+        if (includePos != -1) {
+            // Find the end of line
+            int startPos = includePos + "#include ".length(); //$NON-NLS-1$
+            int eolPos = findLastLineChar(contents, startPos);
+            if (eolPos != -1) {
+                int insertPos = eolPos + 1;
+                if (insertPos < (contents.length() - 1)) {
+                    return insertPos;
+                }
+            }
+        }
+        return -1;
+    }
+
+    private String constructMethodBodies(ITranslationUnit tu, List<IMethodStub> publicMethods,
+               List<IMethodStub> protectedMethods, List<IMethodStub> privateMethods, String lineDelimiter,
+               IProgressMonitor monitor) throws CoreException {
+       StringBuilder text = new StringBuilder();
+        if (!publicMethods.isEmpty()) {
+            for (Iterator<IMethodStub> i = publicMethods.iterator(); i.hasNext();) {
+                IMethodStub stub = i.next();
+                String code = stub.createMethodImplementation(tu, fClassName, fBaseClasses, lineDelimiter);
+                text.append(code);
+                text.append(lineDelimiter);
+                if (i.hasNext())
+                    text.append(lineDelimiter);
+            }
+        }
+
+        if (!protectedMethods.isEmpty()) {
+            for (Iterator<IMethodStub> i = protectedMethods.iterator(); i.hasNext();) {
+                IMethodStub stub = i.next();
+                String code = stub.createMethodImplementation(tu, fClassName, fBaseClasses, lineDelimiter);
+                text.append(code);
+                text.append(lineDelimiter);
+                if (i.hasNext())
+                    text.append(lineDelimiter);
+            }
+        }
+
+        if (!privateMethods.isEmpty()) {
+            for (Iterator<IMethodStub> i = privateMethods.iterator(); i.hasNext();) {
+                IMethodStub stub = i.next();
+                String code = stub.createMethodImplementation(tu, fClassName, fBaseClasses, lineDelimiter);
+                text.append(code);
+                text.append(lineDelimiter);
+                if (i.hasNext())
+                    text.append(lineDelimiter);
+            }
+        }
+        return text.toString();
+    }
+
+    private String getIncludeString(String fileName, boolean isSystemInclude) {
+        StringBuilder buf = new StringBuilder();
+        buf.append("#include "); //$NON-NLS-1$
+        if (isSystemInclude)
+            buf.append('<'); 
+        else
+            buf.append('\"'); 
+        buf.append(fileName);
+        if (isSystemInclude)
+            buf.append('>'); 
+        else
+            buf.append('\"'); 
+        return buf.toString();
+    }
+    
+    private int findLastLineChar(String contents, int startPos) {
+        int endPos = contents.length() - 1;
+        int linePos = startPos;
+        while (linePos <= endPos) {
+            char c = contents.charAt(linePos);
+            if (c == '\r') {
+                // could be '\r\n' as one delimiter
+                if (linePos < endPos && contents.charAt(linePos + 1) == '\n') {
+                    return linePos + 1;
+                }
+                return linePos;
+            } else if (c == '\n') {
+                return linePos;
+            }
+            ++linePos;
+        }
+        return -1;
+    }
+    
+    private int findFirstLineChar(String contents, int startPos) {
+        int linePos = startPos;
+        while (linePos >= 0) {
+            char c = contents.charAt(linePos);
+            if (c == '\n' || c == '\r') {
+                if (linePos + 1 < startPos) {
+                    return linePos + 1;
+                }
+                return -1;
+            }
+            --linePos;
+        }
+        return -1;
+    }
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.java
new file mode 100644 (file)
index 0000000..b2cd29b
--- /dev/null
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2011 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.classwizard;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class NewClassWizardMessages extends NLS {
+       public static String NewClassCreationWizard_title;
+       public static String NewClassCreationWizardPage_title;
+       public static String NewClassCreationWizardPage_description;
+       public static String NewClassCreationWizardPage_getTypes_noNamespaces_title;
+       public static String NewClassCreationWizardPage_getTypes_noNamespaces_message;
+       public static String NewClassCreationWizardPage_sourceFolder_label;
+       public static String NewClassCreationWizardPage_sourceFolder_button;
+       public static String NewClassCreationWizardPage_error_EnterSourceFolderName;
+       public static String NewClassCreationWizardPage_error_NotAFolder;
+       public static String NewClassCreationWizardPage_error_NotASourceFolder;
+       public static String NewClassCreationWizardPage_warning_NotACProject;
+       public static String NewClassCreationWizardPage_warning_NotInACProject;
+       public static String NewClassCreationWizardPage_namespace_label;
+       public static String NewClassCreationWizardPage_namespace_button;
+       public static String NewClassCreationWizardPage_error_EnterNamespace;
+       public static String NewClassCreationWizardPage_error_EnclosingNamespaceNotExists;
+       public static String NewClassCreationWizardPage_error_NamespaceExistsDifferentCase;
+       public static String NewClassCreationWizardPage_error_TypeMatchingNamespaceExists;
+       public static String NewClassCreationWizardPage_error_TypeMatchingNamespaceExistsDifferentCase;
+       public static String NewClassCreationWizardPage_warning_NamespaceNotExists;
+       public static String NewClassCreationWizardPage_error_InvalidNamespace;
+       public static String NewClassCreationWizardPage_warning_NamespaceDiscouraged;
+       public static String NewClassCreationWizardPage_className_label;
+       public static String NewClassCreationWizardPage_error_EnterClassName;
+       public static String NewClassCreationWizardPage_error_ClassNameExists;
+       public static String NewClassCreationWizardPage_error_ClassNameExistsDifferentCase;
+       public static String NewClassCreationWizardPage_error_TypeMatchingClassExists;
+       public static String NewClassCreationWizardPage_error_TypeMatchingClassExistsDifferentCase;
+       public static String NewClassCreationWizardPage_error_InvalidClassName;
+       public static String NewClassCreationWizardPage_error_QualifiedClassName;
+       public static String NewClassCreationWizardPage_warning_ClassNameDiscouraged;
+       public static String NewClassCreationWizardPage_baseClasses_label;
+       public static String NewClassCreationWizardPage_error_BaseClassNotExistsInProject;
+       public static String NewClassCreationWizardPage_methodStubs_label;
+       public static String NewClassCreationWizardPage_error_NotAFile;
+       public static String NewClassCreationWizardPage_error_FolderDoesNotExist;
+       public static String NewClassCreationWizardPage_error_LocationUnknown;
+       public static String NewClassCreationWizardPage_headerFile_label;
+       public static String NewClassCreationWizardPage_headerFile_button;
+       public static String NewClassCreationWizardPage_ChooseHeaderFileDialog_title;
+       public static String NewClassCreationWizardPage_error_EnterHeaderFileName;
+       public static String NewClassCreationWizardPage_error_HeaderFileNotInSourceFolder;
+       public static String NewClassCreationWizardPage_warning_HeaderFileNameDiscouraged;
+       public static String NewClassCreationWizardPage_warning_HeaderFileExists;
+       public static String NewClassCreationWizardPage_error_InvalidHeaderFileName;
+       public static String NewClassCreationWizardPage_sourceFile_button;
+       public static String NewClassCreationWizardPage_sourceFile_label;
+       public static String NewClassCreationWizardPage_ChooseSourceFileDialog_title;
+       public static String NewClassCreationWizardPage_error_EnterSourceFileName;
+       public static String NewClassCreationWizardPage_error_SourceFileNotInSourceFolder;
+       public static String NewClassCreationWizardPage_warning_SourceFileNameDiscouraged;
+       public static String NewClassCreationWizardPage_warning_SourceFileExists;
+       public static String NewClassCreationWizardPage_error_InvalidSourceFileName;
+       public static String NewClassCreationWizardPage_testFile_label;
+       public static String NewClassCreationWizardPage_testFile_button;
+       public static String NewClassCreationWizardPage_ChooseTestFileDialog_title;
+       public static String NewClassCreationWizardPage_error_EnterTestFileName;
+       public static String NewClassCreationWizardPage_error_TestFileNotInSourceFolder;
+       public static String NewClassCreationWizardPage_warning_TestFileNameDiscouraged;
+       public static String NewClassCreationWizardPage_warning_TestFileExists;
+       public static String NewClassCreationWizardPage_error_InvalidTestFileName;
+       public static String BaseClassesListDialogField_buttons_add;
+       public static String BaseClassesListDialogField_buttons_remove;
+       public static String BaseClassesListDialogField_buttons_up;
+       public static String BaseClassesListDialogField_buttons_down;
+       public static String BaseClassesListDialogField_headings_name;
+       public static String BaseClassesListDialogField_headings_access;
+       public static String BaseClassesListDialogField_headings_virtual;
+       public static String BaseClassesLabelProvider_boolean_yes_label;
+       public static String BaseClassesLabelProvider_boolean_no_label;
+       public static String BaseClassesLabelProvider_access_public_label;
+       public static String BaseClassesLabelProvider_access_protected_label;
+       public static String BaseClassesLabelProvider_access_private_label;
+       public static String MethodStubsDialogField_headings_name;
+       public static String MethodStubsDialogField_headings_access;
+       public static String MethodStubsDialogField_headings_virtual;
+       public static String MethodStubsDialogField_headings_inline;
+       public static String NamespaceSelectionDialog_title;
+       public static String NamespaceSelectionDialog_message;
+       public static String EnclosingClassSelectionDialog_title;
+       public static String EnclosingClassSelectionDialog_message;
+       public static String NewBaseClassSelectionDialog_title;
+       public static String NewBaseClassSelectionDialog_message;
+       public static String NewBaseClassSelectionDialog_addButton_label;
+       public static String NewBaseClassSelectionDialog_classadded_info;
+       public static String NewBaseClassSelectionDialog_classalreadyadded_info;
+       public static String NewBaseClassSelectionDialog_addingclass_info;
+       public static String NewBaseClassSelectionDialog_error_classnotadded;
+       public static String SourceFileSelectionDialog_folderName_label;
+       public static String SourceFileSelectionDialog_fileName_label;
+       public static String SourceFileSelectionDialog_error_EnterFolderName;
+       public static String SourceFileSelectionDialog_error_FolderDoesNotExist;
+       public static String SourceFileSelectionDialog_error_NotAFolder;
+       public static String SourceFileSelectionDialog_error_NotASourceFolder;
+       public static String SourceFileSelectionDialog_warning_NotACProject;
+       public static String SourceFileSelectionDialog_warning_NotInACProject;
+       public static String SourceFileSelectionDialog_error_EnterFileName;
+       public static String SourceFileSelectionDialog_error_NotAFile;
+       public static String SourceFileSelectionDialog_error_NotASourceFile;
+       public static String SourceFileSelectionDialog_warning_SourceFileExists;
+       public static String NewClassCodeGeneration_createType_mainTask;
+       public static String NewClassCodeGeneration_createType_task_header;
+       public static String NewClassCodeGeneration_createType_task_header_includePaths;
+       public static String NewClassCodeGeneration_createType_task_header_addIncludePaths;
+       public static String NewClassCodeGeneration_createType_task_source;
+       public static String NewClassCodeGeneration_stub_constructor_name;
+       public static String NewClassCodeGeneration_stub_destructor_name;
+
+       static {
+               NLS.initializeMessages(NewClassWizardMessages.class.getName(), NewClassWizardMessages.class);
+       }
+
+       // Do not instantiate
+       private NewClassWizardMessages() {
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardMessages.properties
new file mode 100644 (file)
index 0000000..ff35ba9
--- /dev/null
@@ -0,0 +1,151 @@
+###############################################################################
+# Copyright (c) 2004, 2011 QNX Software Systems and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     QNX Software Systems - Initial API and implementation
+#          IBM Corporation
+#     Anton Leherbauer (Wind River Systems)
+#     Sergey Prigogin (Google)
+###############################################################################
+
+# ------- NewClassCreationWizard -------
+NewClassCreationWizard_title=New C++ Class
+
+# -----------NewClassCreationWizardPage -------------
+NewClassCreationWizardPage_title=C++ Class
+NewClassCreationWizardPage_description=Create a new C++ class.
+
+NewClassCreationWizardPage_getTypes_noNamespaces_title=Namespace Selection
+NewClassCreationWizardPage_getTypes_noNamespaces_message=No namespaces available.
+
+NewClassCreationWizardPage_sourceFolder_label=&Source folder:
+NewClassCreationWizardPage_sourceFolder_button=Br&owse...
+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.
+NewClassCreationWizardPage_warning_NotACProject=Folder is not a C/C++ project.
+NewClassCreationWizardPage_warning_NotInACProject=Folder is not in a C/C++ project.
+
+NewClassCreationWizardPage_namespace_label=&Namespace:
+NewClassCreationWizardPage_namespace_button=Bro&wse...
+
+NewClassCreationWizardPage_error_EnterNamespace=Namespace is empty.
+NewClassCreationWizardPage_error_EnclosingNamespaceNotExists=Enclosing namespace does not exist.
+NewClassCreationWizardPage_error_NamespaceExistsDifferentCase=Namespace with the same name exists in a different scope.
+NewClassCreationWizardPage_error_TypeMatchingNamespaceExists=Another type with the same name as specified namespace exists.
+NewClassCreationWizardPage_error_TypeMatchingNamespaceExistsDifferentCase=Another type with the same name as specified namespace exists in a different scope.
+NewClassCreationWizardPage_warning_NamespaceNotExists=Namespace does not exist. A new namespace will be created.
+NewClassCreationWizardPage_error_InvalidNamespace=Namespace is not valid. {0}.
+NewClassCreationWizardPage_warning_NamespaceDiscouraged=Namespace is discouraged. {0}.
+
+NewClassCreationWizardPage_className_label=&Class name:
+NewClassCreationWizardPage_error_EnterClassName=Class name is empty.
+NewClassCreationWizardPage_error_ClassNameExists=Class already exists.
+NewClassCreationWizardPage_error_ClassNameExistsDifferentCase=Class with same name exists in a different scope.
+NewClassCreationWizardPage_error_TypeMatchingClassExists=Another type with the same name exists.
+NewClassCreationWizardPage_error_TypeMatchingClassExistsDifferentCase=Another type with the same name exists in a different scope.
+NewClassCreationWizardPage_error_InvalidClassName=Class name is not valid. {0}.
+NewClassCreationWizardPage_error_QualifiedClassName=Class name must not be qualified.
+NewClassCreationWizardPage_warning_ClassNameDiscouraged=Class name is discouraged. {0}.
+
+NewClassCreationWizardPage_baseClasses_label=&Base classes:
+NewClassCreationWizardPage_error_BaseClassNotExistsInProject=Base class ''{0}'' not in include paths for current project.
+
+NewClassCreationWizardPage_methodStubs_label=&Method stubs:
+
+NewClassCreationWizardPage_error_NotAFile=''{0}'' is not a file.
+NewClassCreationWizardPage_error_FolderDoesNotExist=Folder ''{0}'' does not exist.
+NewClassCreationWizardPage_error_LocationUnknown=Cannot locate resource. {0}
+
+NewClassCreationWizardPage_headerFile_label=&Header:
+NewClassCreationWizardPage_headerFile_button=Browse...
+NewClassCreationWizardPage_ChooseHeaderFileDialog_title=Header File Selection
+NewClassCreationWizardPage_error_EnterHeaderFileName=Header file name is empty.
+NewClassCreationWizardPage_error_HeaderFileNotInSourceFolder=Header file must be inside source folder.
+NewClassCreationWizardPage_warning_HeaderFileNameDiscouraged=Header file name is discouraged. {0}.
+NewClassCreationWizardPage_warning_HeaderFileExists=Header file already exists. Contents will be appended.
+NewClassCreationWizardPage_error_InvalidHeaderFileName=Header file name is not valid. {0}.
+
+NewClassCreationWizardPage_sourceFile_label=Sourc&e:
+NewClassCreationWizardPage_sourceFile_button=Browse...
+NewClassCreationWizardPage_ChooseSourceFileDialog_title=Source File Selection
+NewClassCreationWizardPage_error_EnterSourceFileName=Source file name is empty.
+NewClassCreationWizardPage_error_SourceFileNotInSourceFolder=Source file must be inside source folder.
+NewClassCreationWizardPage_warning_SourceFileNameDiscouraged=Source file name is discouraged. {0}
+NewClassCreationWizardPage_warning_SourceFileExists=Source file already exists. Contents will be appended.
+NewClassCreationWizardPage_error_InvalidSourceFileName=Source file name is not valid. {0}
+
+NewClassCreationWizardPage_testFile_label=Unit &Test:
+NewClassCreationWizardPage_testFile_button=Browse...
+NewClassCreationWizardPage_ChooseTestFileDialog_title=Test File Selection
+NewClassCreationWizardPage_error_EnterTestFileName=Test file name is empty.
+NewClassCreationWizardPage_error_TestFileNotInSourceFolder=Test file must be inside source folder.
+NewClassCreationWizardPage_warning_TestFileNameDiscouraged=Test file name is discouraged. {0}
+NewClassCreationWizardPage_warning_TestFileExists=Test file already exists. Contents will be appended.
+NewClassCreationWizardPage_error_InvalidTestFileName=Test file name is not valid. {0}
+
+# -----------BaseClassesListDialogField -------------
+BaseClassesListDialogField_buttons_add=&Add...
+BaseClassesListDialogField_buttons_remove=&Remove
+BaseClassesListDialogField_buttons_up=U&p
+BaseClassesListDialogField_buttons_down=&Down
+BaseClassesListDialogField_headings_name=Name
+BaseClassesListDialogField_headings_access=Access
+BaseClassesListDialogField_headings_virtual=Virtual
+
+# -----------BaseClassesLabelProvider -------------
+BaseClassesLabelProvider_boolean_yes_label=yes
+BaseClassesLabelProvider_boolean_no_label=no
+BaseClassesLabelProvider_access_public_label=public
+BaseClassesLabelProvider_access_protected_label=protected
+BaseClassesLabelProvider_access_private_label=private
+
+# -----------MethodStubsDialogField -------------
+MethodStubsDialogField_headings_name=Name
+MethodStubsDialogField_headings_access=Access
+MethodStubsDialogField_headings_virtual=Virtual
+MethodStubsDialogField_headings_inline=Inline
+
+# ------- NamespaceSelectionDialog -----
+NamespaceSelectionDialog_title=Choose Namespace
+NamespaceSelectionDialog_message=&Choose a namespace (? = any character, * = any string):
+
+# ------- EnclosingClassSelectionDialog -----
+EnclosingClassSelectionDialog_title=Choose Enclosing Class
+EnclosingClassSelectionDialog_message=&Choose a class (? = any character, * = any string):
+
+# ------- NewBaseClassSelectionDialog -----
+NewBaseClassSelectionDialog_title=Choose Base Class
+NewBaseClassSelectionDialog_message=&Choose a class (? = any character, * = any string):
+NewBaseClassSelectionDialog_addButton_label=&Add
+NewBaseClassSelectionDialog_classadded_info=''{0}'' added.
+NewBaseClassSelectionDialog_classalreadyadded_info=''{0}'' already added.
+NewBaseClassSelectionDialog_addingclass_info=Adding ''{0}''...
+NewBaseClassSelectionDialog_error_classnotadded=''{0}'' could not be added.
+
+# ------- SourceFileSelectionDialog -----
+SourceFileSelectionDialog_folderName_label=Folder Name:
+SourceFileSelectionDialog_fileName_label=File Name:
+SourceFileSelectionDialog_error_EnterFolderName=Folder name is empty.
+SourceFileSelectionDialog_error_FolderDoesNotExist=Folder ''{0}'' does not exist.
+SourceFileSelectionDialog_error_NotAFolder=''{0}'' must be a project or folder.
+SourceFileSelectionDialog_error_NotASourceFolder=Folder ''{0}'' is not a valid source folder.
+SourceFileSelectionDialog_warning_NotACProject=Folder is not a C/C++ project.
+SourceFileSelectionDialog_warning_NotInACProject=Folder is not in a C/C++ project.
+SourceFileSelectionDialog_error_EnterFileName=File name is empty.
+SourceFileSelectionDialog_error_NotAFile=''{0}'' is not a source file.
+SourceFileSelectionDialog_error_NotASourceFile=''{0}'' is not a valid source file.
+SourceFileSelectionDialog_warning_SourceFileExists=New class contents will be appended to existing file ''{0}''.
+
+# -----------NewClassCodeGeneration -------------
+NewClassCodeGeneration_createType_mainTask=Creating type....
+NewClassCodeGeneration_createType_task_header=Creating header file....
+NewClassCodeGeneration_createType_task_header_includePaths=Adding include paths....
+NewClassCodeGeneration_createType_task_header_addIncludePaths=Adding new include paths to project....
+NewClassCodeGeneration_createType_task_source=Creating source file....
+NewClassCodeGeneration_stub_constructor_name=Constructor
+NewClassCodeGeneration_stub_destructor_name=Destructor
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardPrefs.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardPrefs.java
new file mode 100644 (file)
index 0000000..afc6e8f
--- /dev/null
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2005 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.classwizard;
+
+public class NewClassWizardPrefs {
+
+    /**
+     * Checks if the base classes need to be verified (ie they must exist in the project)
+     * 
+     * @return <code>true</code> if the base classes should be verified
+     */
+    public static boolean verifyBaseClasses() {
+        //TODO this should be a prefs option
+        return true;
+    }
+    
+    /**
+     * Checks if include paths can be added to the project as needed.
+     * 
+     * @return <code>true</code> if the include paths should be added
+     */
+    public static boolean createIncludePaths() {
+        //TODO this should be a prefs option
+        return true;
+    }
+
+    /**
+     * Returns whether the generated header and source files should be
+     * opened in editors after the finish button is pressed.
+     * 
+     * @return <code>true</code> if the header and source file should be
+     * displayed
+     */
+    public static boolean openClassInEditor() {
+        //TODO this should be a prefs option
+        return true;
+    }
+    
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/NewClassWizardUtil.java
new file mode 100644 (file)
index 0000000..a479240
--- /dev/null
@@ -0,0 +1,420 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     IBM Corporation
+ *     Markus Schorn (Wind River Systems)
+ *     Warren Paul (Nokia) - 174238
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.classwizard;
+
+import org.eclipse.core.resources.IFile;
+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.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.views.contentoutline.ContentOutline;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.browser.IQualifiedTypeName;
+import org.eclipse.cdt.core.browser.ITypeInfo;
+import org.eclipse.cdt.core.browser.ITypeReference;
+import org.eclipse.cdt.core.dom.ILinkage;
+import org.eclipse.cdt.core.dom.ast.DOMException;
+import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.IEnumeration;
+import org.eclipse.cdt.core.dom.ast.ITypedef;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
+import org.eclipse.cdt.core.index.IIndex;
+import org.eclipse.cdt.core.index.IndexFilter;
+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.parser.Keywords;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.viewsupport.IViewPartInputProvider;
+
+public class NewClassWizardUtil {
+    /**
+     * Returns the parent source folder of the given element. If the given
+     * element is already a source folder, the element itself is returned.
+     * 
+     * @param element the C Element
+     * @return the source folder
+     */
+    public static ICContainer getSourceFolder(ICElement element) {
+        ICContainer folder = null;
+        boolean foundSourceRoot = false;
+        ICElement curr = element;
+        while (curr != null && !foundSourceRoot) {
+            if (curr instanceof ICContainer && folder == null) {
+                folder = (ICContainer)curr;
+            }
+            foundSourceRoot = (curr instanceof ISourceRoot);
+            curr = curr.getParent();
+        }
+        if (folder == null) {
+            ICProject cproject = element.getCProject();
+            folder = cproject.findSourceRoot(cproject.getProject());
+        }
+        return folder;
+    }
+    
+    /**
+     * Returns the parent source folder for the given path. If the given
+     * path is already a source folder, the corresponding C element is returned.
+     * 
+     * @param path the path
+     * @return the source folder
+     */
+    public static ICContainer getSourceFolder(IPath path) {
+        if (path == null)
+            return null;
+        while (path.segmentCount() > 0) {
+            IResource res = getWorkspaceRoot().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());
+                    if (elem != null) {
+                        ICContainer sourceFolder = getSourceFolder(elem);
+                        if (sourceFolder != null)
+                            return sourceFolder;
+                        if (resType == IResource.PROJECT) {
+                               if (elem instanceof ICContainer) {
+                                return (ICContainer)elem;
+                               }
+                        }
+                    }
+                }
+            }
+            path = path.removeLastSegments(1);
+        }
+        return null;
+    }
+    
+    /**
+     * Returns the parent source folder for the given resource. If the given
+     * resource is already a source folder, the corresponding C element is returned.
+     * 
+     * @param resource the resource
+     * @return the source folder
+     */
+    public static ICContainer getSourceFolder(IResource resource) {
+        if (resource != null && resource.exists()) {
+            int resType = resource.getType();
+            if (resType == IResource.PROJECT || resType == IResource.FOLDER) {
+                ICElement elem = CoreModel.getDefault().create(resource.getFullPath());
+                if (elem != null) {
+                    ICContainer sourceFolder = getSourceFolder(elem);
+                    if (sourceFolder != null)
+                        return sourceFolder;
+                }
+            } else {
+                return getSourceFolder(resource.getParent());
+            }
+        }
+        return null;
+    }
+    
+    /**
+     * Returns the first source root in the given project. If the project has
+     * no source roots as children, the project itself is returned.
+     * 
+     * @param cproject
+     * @return the source root
+     */
+    public static ISourceRoot getFirstSourceRoot(ICProject cproject) {
+        ISourceRoot folder = null;
+        try {
+            if (cproject.exists()) {
+                ISourceRoot[] roots = cproject.getSourceRoots();
+                if (roots != null && roots.length > 0)
+                    folder = roots[0];
+            }
+        } catch (CModelException e) {
+            CUIPlugin.log(e);
+        }
+        if (folder == null) {
+            folder = cproject.findSourceRoot(cproject.getResource());
+        }
+        return folder;
+    }
+
+    /**
+     * Returns the C Element which corresponds to the given selection.
+     * 
+     * @param selection the selection to be inspected
+     * @return a C element matching the selection, or <code>null</code>
+     * if no C element exists in the given selection
+     */
+    public static ICElement getCElementFromSelection(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) {
+                            celem = (ICElement) resource.getAdapter(ICElement.class);
+                            resource = resource.getParent();
+                        }
+                        if (celem == null) {
+                            celem = CoreModel.getDefault().create(resource); // c project
+                        }
+                    }
+                }
+            }
+        }
+        return celem;
+    }
+    
+    /**
+     * Returns the C Element which corresponds to the active editor.
+     * 
+     * @return a C element matching the active editor, or <code>null</code>
+     * if no C element can be found
+     */
+    public static ICElement getCElementFromEditor() {
+        ICElement 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);
+                }
+            }
+        }
+        return celem;
+    }
+    
+    /**
+     * Returns the parent namespace for the given element. If the given element is
+     * already a namespace, the element itself is returned.
+     *
+     * @param element the given C Element
+     * @return the C Element for the namespace, or <code>null</code> if not found
+     */
+    public static ICElement getNamespace(ICElement element) {
+        ICElement curr = element;
+        while (curr != null) {
+            int type = curr.getElementType();
+            if (type == ICElement.C_UNIT) {
+                break;
+            }
+            if (type == ICElement.C_NAMESPACE) {
+                return curr;
+            }
+            curr = curr.getParent();
+        }
+        return null;
+    }
+    
+    /**
+     * Returns the workspace root.
+     * 
+     * @return the workspace root
+     */ 
+    public static IWorkspaceRoot getWorkspaceRoot() {
+        return ResourcesPlugin.getWorkspace().getRoot();
+    }
+    
+    /**
+     * Resolves the location of the given class.
+     * 
+     * @param type the class to resolve
+     * @param context the runnable context
+     * @return the class location, or <code>null</code> if not found
+     */
+    public static ITypeReference resolveClassLocation(ITypeInfo type, IRunnableContext context) {
+        return type.getResolvedReference();
+    }
+
+    /**
+     * Checks whether the given type can be found in the given project or the
+     * given include paths.
+     * 
+     * @param type the type
+     * @param project the project
+     * @param includePaths the include paths
+     * @return <code>true</code> if the given type is found
+     */
+    public static boolean isTypeReachable(ITypeInfo type, ICProject project, String[] includePaths) {
+        ICProject baseProject = type.getEnclosingProject();
+        if (baseProject != null && baseProject.equals(project)) {
+            return true;
+        }
+        
+        // check the include paths
+        ITypeReference ref = type.getResolvedReference();
+        IPath location = ref == null ? null : ref.getLocation();
+        boolean isTypeLocation= true;
+        if (location == null) {
+               isTypeLocation= false;
+               
+               if (baseProject != null) {
+                location = baseProject.getProject().getLocation();
+               }
+            if (location == null)
+               return false;
+        }
+    
+        for (int i = 0; i < includePaths.length; ++i) {
+            IPath includePath = new Path(includePaths[i]);
+            if (isTypeLocation) {
+                               if (includePath.isPrefixOf(location))
+                    return true;
+            } else {
+                // we don't have the real location, so just check the project path
+                               if (location.isPrefixOf(includePath))
+                    return true;
+            }
+        }
+        
+        return false;
+    }
+
+       public static final int SEARCH_MATCH_ERROR = -1;  // some error, search failed
+       public static final int SEARCH_MATCH_NOTFOUND = 0;  // no match found
+       public static final int SEARCH_MATCH_FOUND_EXACT = 1;   // exact match
+       public static final int SEARCH_MATCH_FOUND_EXACT_ANOTHER_TYPE = 2; // same name found, by different type
+       public static final int SEARCH_MATCH_FOUND_ANOTHER_NAMESPACE = 3; // same type name exits in different scope
+       public static final int SEARCH_MATCH_FOUND_ANOTHER_TYPE = 4; // same name used by another type in different scope
+
+       /**
+        * Search for the given qualified name of the give
+        * @param typeName  qualified name of the type to search
+        * @param project  
+        * @param queryType Class of interface type to search for (e.g. ICPPClassType.class)
+        * @return one of {@link #SEARCH_MATCH_ERROR}, 
+        * {@link #SEARCH_MATCH_FOUND_ANOTHER_NAMESPACE},
+        * {@link #SEARCH_MATCH_FOUND_ANOTHER_TYPE}, 
+        * {@link #SEARCH_MATCH_FOUND_EXACT_ANOTHER_TYPE},
+        * {@link #SEARCH_MATCH_FOUND_EXACT} or
+        * {@link #SEARCH_MATCH_NOTFOUND}.       
+        */
+       public static int searchForCppType(IQualifiedTypeName typeName, ICProject project, Class<?> queryType) {
+               IIndex index= null;
+               try {
+                       if (project != null) {
+                               index = CCorePlugin.getIndexManager().getIndex(project);
+                               index.acquireReadLock();
+                       }
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+                       return SEARCH_MATCH_ERROR;
+               } catch (InterruptedException e) {
+                       Thread.currentThread().interrupt();
+                       return SEARCH_MATCH_NOTFOUND;
+               }
+               if (index == null) {
+                       return SEARCH_MATCH_ERROR;
+               }
+               try {
+                       String fullyQualifiedTypeName = typeName.getFullyQualifiedName();
+                       try {
+                               IndexFilter filter= IndexFilter.getDeclaredBindingFilter(ILinkage.CPP_LINKAGE_ID, true);
+                               //bug 165636: findBindings(char[][]...) does not find nested nodes (classes)
+                               //therefore switching back to findBindings(Pattern...)
+                               IBinding[] bindings = index.findBindings(typeName.getName().toCharArray(), false, filter, new NullProgressMonitor());
+                               boolean sameTypeNameExists = false; 
+                               boolean sameNameDifferentTypeExists = false;
+
+                               for (int i = 0; i < bindings.length; ++i) {
+                                       ICPPBinding binding = (ICPPBinding) bindings[i];
+
+                                       //get the fully qualified name of this binding
+                                       String bindingFullName = renderQualifiedName(binding.getQualifiedName());
+                                       Class<? extends ICPPBinding> currentNodeType = binding.getClass();
+                                       // full binding                         
+                                       if (queryType.isAssignableFrom(currentNodeType)) {                                              
+                                               if (bindingFullName.equals(fullyQualifiedTypeName)) {
+                                                       //bug 165636: there is a match only if there is a definition for the binding
+                                                       //otherwise, users can create a new class definition for this binding
+                                                       if (index.findDefinitions(binding).length > 0)  {
+                                                               return SEARCH_MATCH_FOUND_EXACT;
+                                                       }                                                       
+                                               } else {
+                                                       // same type , same name , but different name space
+                                                       // see if there is an exact match;
+                                                       sameTypeNameExists = true;
+                                               }
+                                       } else if(ICPPClassType.class.isAssignableFrom(currentNodeType) || 
+                                                       IEnumeration.class.isAssignableFrom(currentNodeType) || // TODO - this should maybe be ICPPEnumeration
+                                                       ICPPNamespace.class.isAssignableFrom(currentNodeType) ||
+                                                       ITypedef.class.isAssignableFrom(currentNodeType) ||
+                                                       ICPPBasicType.class.isAssignableFrom(currentNodeType)) {                                                
+                                               if (bindingFullName.equals(fullyQualifiedTypeName))     {
+                                                       return SEARCH_MATCH_FOUND_EXACT_ANOTHER_TYPE;
+                                               }
+                                               // different type , same name , but different name space
+                                               sameNameDifferentTypeExists = true;
+                                       }
+                               }
+                               if(sameTypeNameExists){
+                                       return SEARCH_MATCH_FOUND_ANOTHER_NAMESPACE;
+                               }
+
+                               if(sameNameDifferentTypeExists){
+                                       return SEARCH_MATCH_FOUND_ANOTHER_TYPE;
+                               }
+                       } catch (CoreException e) {
+                               return SEARCH_MATCH_ERROR;
+                       } catch (DOMException e) {
+                               return SEARCH_MATCH_ERROR;
+                       }
+                       return SEARCH_MATCH_NOTFOUND;
+               } finally {
+                       index.releaseReadLock();
+               }
+       }
+
+       private static String renderQualifiedName(String[] qn) {
+               StringBuilder result = new StringBuilder();
+               boolean needSep= false;
+               for (String element : qn) {
+                       if (needSep)
+                               result.append(Keywords.cpCOLONCOLON);
+                       result.append(element);  
+                       needSep= true;
+               }
+               return result.toString();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/SourceFileSelectionDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/classwizard/SourceFileSelectionDialog.java
new file mode 100644 (file)
index 0000000..03ece11
--- /dev/null
@@ -0,0 +1,565 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2011 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.classwizard;
+
+import java.util.ArrayList;
+
+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.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.dialogs.SelectionStatusDialog;
+
+import org.eclipse.cdt.utils.PathUtil;
+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.ICElementVisitor;
+import org.eclipse.cdt.core.model.ICModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CElementContentProvider;
+import org.eclipse.cdt.ui.CElementLabelProvider;
+import org.eclipse.cdt.ui.CElementSorter;
+
+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.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;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringDialogField;
+
+public class SourceFileSelectionDialog extends SelectionStatusDialog {
+    
+    TreeViewer fViewer;
+    private final ITreeContentProvider fContentProvider = new CElementContentProvider();
+    private final ILabelProvider fLabelProvider = new CElementLabelProvider(CElementLabelProvider.SHOW_DEFAULT);
+    IStatus fCurrStatus = new StatusInfo();
+    IStatus fFolderNameStatus = new StatusInfo();
+    IStatus fFileNameStatus = new StatusInfo();
+    ICElement fInput;
+    private int fWidth = 60;
+    private int fHeight = 18;
+    StringDialogField fFolderNameDialogField;
+    StringDialogField fFileNameDialogField;
+    private IWorkspaceRoot fWorkspaceRoot;
+    private final FieldsAdapter fFieldsAdapter = new FieldsAdapter();
+    
+       private ICElement fCurrentFolder = null;
+       private String fCurrentFileString = null;
+    String fInitialFolderName = null;
+    String fInitialFileName = null;
+    
+    private final class FieldsAdapter extends SelectionAdapter
+       implements ISelectionChangedListener, IDoubleClickListener, IDialogFieldListener {
+        
+        // -- SelectionAdapter --
+        @Override
+               public void widgetDefaultSelected(SelectionEvent e) {
+            doStatusUpdate();
+            if (fCurrStatus.isOK())
+                buttonPressed(IDialogConstants.OK_ID);
+        }
+        
+        // -- ISelectionChangedListener --
+        public void selectionChanged(SelectionChangedEvent event) {
+            setResult(((IStructuredSelection) event.getSelection()).toList());
+            ISelection sel = event.getSelection();
+            if (sel instanceof IStructuredSelection) {
+                Object obj = ((IStructuredSelection) sel).getFirstElement();
+                if (obj instanceof ICElement) {
+                    ICElement elem = (ICElement) obj;
+                    IPath path = elem.getPath();
+                    String fileName = fFileNameDialogField.getText();
+                    String folderName = fFolderNameDialogField.getText();
+                    if (elem instanceof ICContainer || elem instanceof ICProject) {
+                        folderName = path.toString();
+                    } else {
+                        folderName = path.removeLastSegments(1).toString();
+                        fileName = path.lastSegment();
+                    }
+                    setPathFields(folderName, fileName);
+                }
+            }
+            doStatusUpdate();
+        }
+        
+        // -- IDoubleClickListener --
+        public void doubleClick(DoubleClickEvent event) {
+            doStatusUpdate();
+            
+            ISelection selection = event.getSelection();
+            if (selection instanceof IStructuredSelection) {
+                Object item = ((IStructuredSelection)selection).getFirstElement();
+                   if (fCurrStatus.getSeverity() != IStatus.ERROR) {
+                    if (item instanceof ITranslationUnit) {
+                        setResult(((IStructuredSelection)selection).toList());
+                        close();
+                        return;
+                    }
+                   }
+                if (fViewer.getExpandedState(item))
+                    fViewer.collapseToLevel(item, 1);
+                else
+                    fViewer.expandToLevel(item, 1);
+            }
+        }
+
+        // -- IDialogFieldListener --
+        public void dialogFieldChanged(DialogField field) {
+            if (field == fFolderNameDialogField) {
+                       fFolderNameStatus = folderNameChanged();
+                       fFileNameStatus = fileNameChanged();
+            } else if (field == fFileNameDialogField) {
+                       fFileNameStatus = fileNameChanged();
+            }
+            doStatusUpdate();
+        }
+    }
+    
+    static final Class<?>[] FILTER_TYPES = new Class[] {
+            ICModel.class,
+            ICProject.class,
+            ICContainer.class,
+            ITranslationUnit.class
+        };
+
+    private final class Filter extends TypedViewerFilter {
+        
+        private Filter() {
+            super(FILTER_TYPES);
+        }
+        
+        @Override
+               public boolean select(Viewer viewer, Object parent, Object obj) {
+            if (obj instanceof ICElement) {
+                ICElement elem = (ICElement)obj;
+                if (!(fInput instanceof ICModel)) {
+                    return elem.getCProject().equals(fInput.getCProject());
+                }
+                return true;
+            }
+            return super.select(viewer, parent, obj);
+        }
+    }
+    
+    /**
+     * Constructs an instance of <code>ElementTreeSelectionDialog</code>.
+     * 
+     * @param parent
+     *            The parent shell for the dialog
+     */
+    public SourceFileSelectionDialog(Shell parent) {
+        super(parent);
+        
+        fWorkspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+        fInput = CoreModel.create(fWorkspaceRoot);
+        
+        fFolderNameDialogField = new StringDialogField();
+        fFolderNameDialogField.setDialogFieldListener(fFieldsAdapter);
+        fFolderNameDialogField.setLabelText(NewClassWizardMessages.SourceFileSelectionDialog_folderName_label); 
+        
+        fFileNameDialogField = new StringDialogField();
+        fFileNameDialogField.setDialogFieldListener(fFieldsAdapter);
+        fFileNameDialogField.setLabelText(NewClassWizardMessages.SourceFileSelectionDialog_fileName_label); 
+        
+               setResult(new ArrayList<Object>(0));
+        setStatusLineAboveButtons(true);
+        
+        int shellStyle = getShellStyle();
+        setShellStyle(shellStyle | SWT.MAX | SWT.RESIZE);
+    }
+    
+    /**
+     * Sets the tree input.
+     * 
+     * @param input
+     *            the tree input.
+     */
+    public void setInput(ICElement input) {
+        fInput = input;
+    }
+    
+       protected void doStatusUpdate() {
+               // status of all used components
+               IStatus[] status = new IStatus[] {
+                       fFolderNameStatus,
+                       fFileNameStatus
+               };
+               
+               // the mode severe status will be displayed and the ok button enabled/disabled.
+               updateStatus(status);
+       }
+    
+       /**
+        * Updates the status line and the ok button according to the given status
+        * 
+        * @param status status to apply
+        */
+       @Override
+       protected void updateStatus(IStatus status) {
+               fCurrStatus = status;
+           super.updateStatus(status);
+       }
+       
+       /**
+        * Updates the status line and the ok button according to the status evaluate from
+        * an array of status. The most severe error is taken.  In case that two status with 
+        * the same severity exists, the status with lower index is taken.
+        * 
+        * @param status the array of status
+        */
+       protected void updateStatus(IStatus[] status) {
+               updateStatus(StatusUtil.getMostSevere(status));
+       }
+       
+       IStatus folderNameChanged() {
+        StatusInfo status = new StatusInfo();
+        
+               fCurrentFolder = null;
+        String str = fFolderNameDialogField.getText();
+               if (str.length() == 0) {
+                       status.setError(NewClassWizardMessages.SourceFileSelectionDialog_error_EnterFolderName); 
+                       return status;
+               }
+
+               IPath path = new Path(str);
+               IResource res = fWorkspaceRoot.findMember(path);
+               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(NLS.bind(NewClassWizardMessages.SourceFileSelectionDialog_error_NotAFolder, str)); 
+                                       return status;
+                               }
+                           ICElement e = CoreModel.getDefault().create(res.getFullPath());
+                           fCurrentFolder = CModelUtil.getSourceFolder(e);
+                               if (fCurrentFolder == null) {
+                                       status.setError(NLS.bind(NewClassWizardMessages.SourceFileSelectionDialog_error_NotASourceFolder, str)); 
+                                       return status;
+                               }
+                           if (!CoreModel.hasCCNature(proj) && !CoreModel.hasCNature(proj)) {
+                                       if (resType == IResource.PROJECT) {
+                                               status.setError(NewClassWizardMessages.SourceFileSelectionDialog_warning_NotACProject); 
+                                               return status;
+                                       }
+                                       status.setWarning(NewClassWizardMessages.SourceFileSelectionDialog_warning_NotInACProject); 
+                               }
+                       } else {
+                               status.setError(NLS.bind(NewClassWizardMessages.SourceFileSelectionDialog_error_NotAFolder, str)); 
+                               return status;
+                       }
+               } else {
+                       status.setError(NLS.bind(NewClassWizardMessages.SourceFileSelectionDialog_error_FolderDoesNotExist, str)); 
+                       return status;
+               }
+        return status;
+       }
+
+       IStatus fileNameChanged() {
+        StatusInfo status = new StatusInfo();
+        
+        fCurrentFileString = null;
+               ICElement existingFile = null;
+        String str = fFileNameDialogField.getText();
+               if (str.length() == 0) {
+                       status.setError(NewClassWizardMessages.SourceFileSelectionDialog_error_EnterFileName); 
+                       return status;
+               }
+
+               if (fCurrentFolder != null) {
+                       IPath folderPath = fCurrentFolder.getPath();
+                       IPath path = new Path(str);
+                       IResource res = fWorkspaceRoot.findMember(folderPath.append(path));
+                       if (res == null)
+                               res = fWorkspaceRoot.findMember(path);
+                       if (res != null && res.exists()) {
+                               int resType = res.getType();
+                               if (resType == IResource.FILE) {
+                                       IProject proj = res.getProject();
+                                       if (!proj.isOpen()) {
+                                               status.setError(NLS.bind(NewClassWizardMessages.SourceFileSelectionDialog_error_NotAFile, str)); 
+                                               return status;
+                                       }
+                                   ICElement e = CoreModel.getDefault().create(res.getFullPath());
+                                   if (e instanceof ITranslationUnit) {
+                                       existingFile = e;
+                                   }
+                                       if (existingFile == null) {
+                                               status.setError(NLS.bind(NewClassWizardMessages.SourceFileSelectionDialog_error_NotASourceFile, str)); 
+                                               return status;
+                                       }
+                                   if (!CoreModel.hasCCNature(proj) && !CoreModel.hasCNature(proj)) {
+                                               status.setWarning(NewClassWizardMessages.SourceFileSelectionDialog_warning_NotInACProject); 
+                                       }
+                               } else {
+                                       status.setError(NLS.bind(NewClassWizardMessages.SourceFileSelectionDialog_error_NotAFile, str)); 
+                                       return status;
+                               }
+                       }
+               }
+               if (existingFile != null) {
+                       status.setWarning(NLS.bind(NewClassWizardMessages.SourceFileSelectionDialog_warning_SourceFileExists, str)); 
+               }
+               fCurrentFileString = str;
+        return status;
+       }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.jface.window.Window#open()
+     */
+    @Override
+       public int open() {
+        super.open();
+        return getReturnCode();
+    }
+    
+    /**
+     * Handles cancel button pressed event.
+     */
+    @Override
+       protected void cancelPressed() {
+        setResult(null);
+        super.cancelPressed();
+    }
+    
+    /*
+     * @see SelectionStatusDialog#computeResult()
+     */
+    @Override
+       protected void computeResult() {
+        setResult(((IStructuredSelection) fViewer.getSelection()).toList());
+    }
+    
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.jface.window.Window#create()
+     */
+    @Override
+       public void create() {
+        BusyIndicator.showWhile(null, new Runnable() {
+            public void run() {
+                superCreate();
+                fViewer.setSelection(new StructuredSelection(getInitialElementSelections()), true);
+                setPathFields(fInitialFolderName, fInitialFileName);
+                fFileNameDialogField.setFocus();
+                doStatusUpdate();
+            }
+        });
+    }
+    void superCreate() {
+        super.create();
+    }
+    
+    /*
+     * @see Dialog#createDialogArea(Composite)
+     */
+    @Override
+       protected Control createDialogArea(Composite parent) {
+        Composite composite = (Composite) super.createDialogArea(parent);
+        // Label messageLabel = createMessageArea(composite);
+        int nColumns = 4;
+        fFolderNameDialogField.doFillIntoGrid(composite, nColumns - 1);
+        DialogField.createEmptySpace(composite);
+        LayoutUtil.setWidthHint(fFolderNameDialogField.getTextControl(null), getMaxFieldWidth());
+        
+        TreeViewer treeViewer = createTreeViewer(composite);
+        
+        GridData data = new GridData(GridData.FILL_BOTH);
+        data.widthHint = convertWidthInCharsToPixels(fWidth);
+        data.heightHint = convertHeightInCharsToPixels(fHeight);
+        
+        Tree treeWidget = treeViewer.getTree();
+        treeWidget.setLayoutData(data);
+        treeWidget.setFont(parent.getFont());
+        
+        fFileNameDialogField.doFillIntoGrid(composite, nColumns - 1);
+        DialogField.createEmptySpace(composite);
+        LayoutUtil.setWidthHint(fFileNameDialogField.getTextControl(null), getMaxFieldWidth());
+        
+        return composite;
+    }
+    
+    /**
+     * 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(60);
+    }
+    
+    /**
+     * Creates the tree viewer.
+     * 
+     * @param parent
+     *            the parent composite
+     * @return the tree viewer
+     */
+    protected TreeViewer createTreeViewer(Composite parent) {
+        int style = (SWT.BORDER | SWT.SINGLE);
+        
+        fViewer = new TreeViewer(new Tree(parent, style));
+        fViewer.setContentProvider(fContentProvider);
+        fViewer.setLabelProvider(fLabelProvider);
+        fViewer.addSelectionChangedListener(fFieldsAdapter);
+        
+        fViewer.setSorter(new CElementSorter());
+        fViewer.addFilter(new Filter());
+        
+        Tree tree = fViewer.getTree();
+        tree.addSelectionListener(fFieldsAdapter);
+        fViewer.addDoubleClickListener(fFieldsAdapter);
+        
+        fViewer.setInput(fInput.getCModel());
+        
+        return fViewer;
+    }
+    
+    /**
+     * Returns the tree viewer.
+     * 
+     * @return the tree viewer
+     */
+    protected TreeViewer getTreeViewer() {
+        return fViewer;
+    }
+    
+    /**
+     * @see org.eclipse.jface.window.Window#handleShellCloseEvent()
+     */
+    @Override
+       protected void handleShellCloseEvent() {
+        super.handleShellCloseEvent();
+        
+        //Handle the closing of the shell by selecting the close icon
+        if (getReturnCode() == CANCEL)
+            setResult(null);
+    }
+    
+    public String getFolderName() {
+        if (fCurrentFolder != null) {
+            return fCurrentFolder.getPath().toString();
+        }
+        return null;
+    }
+    
+    public String getFileName() {
+        return fCurrentFileString;
+    }
+    
+    public IPath getFilePath() {
+        IPath path = null;
+        if (fCurrentFolder != null) {
+            path = fCurrentFolder.getPath();
+            if (fCurrentFileString != null)
+                path = path.append(fCurrentFileString);
+        } else if (fCurrentFileString != null) {
+            path = new Path(fCurrentFileString);
+        }
+        return path;
+    }
+
+    void setPathFields(String folderName, String fileName) {
+           fFolderNameDialogField.setTextWithoutUpdate(folderName != null ? folderName : ""); //$NON-NLS-1$
+           fFileNameDialogField.setTextWithoutUpdate(fileName != null ? fileName : ""); //$NON-NLS-1$
+               fFolderNameStatus = folderNameChanged();
+               fFileNameStatus = fileNameChanged();
+    }
+    
+    /**
+     * Sets the initial selection. Convenience method.
+     */
+    public void setInitialSelection(String folderName, String fileName) {
+        fInitialFileName = (fileName != null && fileName.length() > 0) ? fileName : null;
+        fInitialFolderName = null;
+        if (folderName != null && folderName.length() > 0) {
+               // find a folder that actually exists
+            IPath initialFolderPath = new Path(folderName);
+            final IPath folderPath = PathUtil.getValidEnclosingFolder(initialFolderPath);
+            if (folderPath != null) {
+                fInitialFolderName = folderPath.toString();
+                               if (fInput != null) {
+                           final ICElement[] foundElem = {/*base_folder*/ null, /*exact_folder*/ null, /*exact_file*/ null};
+                           try {
+                                   fInput.accept(new ICElementVisitor() {
+                                       public boolean visit(ICElement elem) {
+                                           IPath path = elem.getPath();
+                                           if (path.isPrefixOf(folderPath)) {
+                                               if (foundElem[0] == null || path.segmentCount() > foundElem[0].getPath().segmentCount()) {
+                                                   foundElem[0] = elem; /*base_folder*/
+                                               }
+                                           if (path.equals(folderPath)) {
+                                               foundElem[1] = elem; /*exact_folder*/
+                                                   if (fInitialFileName == null)
+                                                       return false; // no need to search children
+                                           } else if (fInitialFileName != null && elem.getElementName().equals(fInitialFileName)) {
+                                               foundElem[2] = elem; /*exact_file*/
+                                               return false; // no need to search children
+                                           }
+                                           return true;
+                                           }
+                                           return false;
+                                       }
+                                   });
+               
+                                   ICElement selectedElement = foundElem[2]; /*exact_file*/
+                                   if (selectedElement == null)
+                                       selectedElement = foundElem[1]; /*exact_folder*/
+                                   if (selectedElement == null)
+                                       selectedElement = foundElem[0]; /*base_folder*/
+               
+                                   if (selectedElement != null) {
+                                       setInitialSelections(new Object[] { selectedElement });
+                                   }
+                               } catch (CoreException e) {
+                               }
+                       }
+               }
+        }
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/CheckedListDialogField.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/CheckedListDialogField.java
new file mode 100644 (file)
index 0000000..bd3ccf0
--- /dev/null
@@ -0,0 +1,237 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.dialogfields;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.IBaseLabelProvider;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Table;
+
+/**
+ * A list with check boxes and a button bar. Typical buttons are 'Check All' and 'Uncheck All'.
+ * List model is independent of widget creation.
+ * DialogFields controls are: Label, List and Composite containing buttons.
+ */
+public class CheckedListDialogField<T> extends ListDialogField<T> {
+       private int fCheckAllButtonIndex;
+       private int fUncheckAllButtonIndex;
+       
+       private List<T> fCheckElements;
+
+       public CheckedListDialogField(IListAdapter<T> adapter, String[] customButtonLabels, IBaseLabelProvider lprovider) {
+               super(adapter, customButtonLabels, lprovider);
+               fCheckElements= new ArrayList<T>();
+               
+               fCheckAllButtonIndex= -1;
+               fUncheckAllButtonIndex= -1;
+       }
+
+       /**
+        * Sets the index of the 'check' button in the button label array passed in the constructor.
+        * The behaviour of the button marked as the check button will then be handled internally.
+        * (enable state, button invocation behaviour)
+        */     
+       public void setCheckAllButtonIndex(int checkButtonIndex) {
+               Assert.isTrue(checkButtonIndex < fButtonLabels.length);
+               fCheckAllButtonIndex= checkButtonIndex;
+       }
+
+       /**
+        * Sets the index of the 'uncheck' button in the button label array passed in the constructor.
+        * The behaviour of the button marked as the uncheck button will then be handled internally.
+        * (enable state, button invocation behaviour)
+        */     
+       public void setUncheckAllButtonIndex(int uncheckButtonIndex) {
+               Assert.isTrue(uncheckButtonIndex < fButtonLabels.length);
+               fUncheckAllButtonIndex= uncheckButtonIndex;
+       }
+       
+
+       /*
+        * @see ListDialogField#createTableViewer
+        */
+       @Override
+       protected TableViewer createTableViewer(Composite parent) {
+               Table table= new Table(parent, SWT.CHECK + getListStyle());
+               CheckboxTableViewer tableViewer= new CheckboxTableViewer(table);
+               tableViewer.addCheckStateListener(new ICheckStateListener() {
+                       public void checkStateChanged(CheckStateChangedEvent e) {
+                               doCheckStateChanged(e);
+                       }
+               });
+               return tableViewer;
+       }               
+       
+       
+       /*
+        * @see ListDialogField#getListControl
+        */
+       @Override
+       public Control getListControl(Composite parent) {
+               Control control= super.getListControl(parent);
+               if (parent != null) {
+                       ((CheckboxTableViewer)fTable).setCheckedElements(fCheckElements.toArray());
+               }
+               return control;
+       }       
+       
+       /*
+        * @see DialogField#dialogFieldChanged
+        * Hooks in to get element changes to update check model.
+        */
+       @Override
+       public void dialogFieldChanged() {
+               for (int i= fCheckElements.size() -1; i >= 0; i--) {
+                       if (!fElements.contains(fCheckElements.get(i))) {
+                               fCheckElements.remove(i);
+                       }
+               }
+               super.dialogFieldChanged();
+       }       
+       
+       private void checkStateChanged() {
+               //call super and do not update check model
+               super.dialogFieldChanged();
+       }               
+
+       /**
+        * Gets the checked elements.
+        */
+       public List<T> getCheckedElements() {
+               return new ArrayList<T>(fCheckElements);
+       }
+       
+       /**
+        * Returns the number of checked elements.
+        */
+       public int getCheckedSize() {
+               return fCheckElements.size();
+       }
+       
+       /**
+        * Returns true if the element is checked.
+        */
+       public boolean isChecked(Object obj) {
+               return fCheckElements.contains(obj);
+       }       
+       
+       /**
+        * Sets the checked elements.
+        */     
+       public void setCheckedElements(Collection<T> list) {
+               fCheckElements= new ArrayList<T>(list);
+               if (fTable != null) {
+                       ((CheckboxTableViewer)fTable).setCheckedElements(list.toArray());
+               }
+               checkStateChanged();
+       }
+
+       /**
+        * Sets the checked state of an element.
+        */             
+       public void setChecked(T object, boolean state) {
+               setCheckedWithoutUpdate(object, state);
+               checkStateChanged();
+       }
+       
+       /**
+        * Sets the checked state of an element. No dialog changed listener is informed.
+        */             
+       public void setCheckedWithoutUpdate(T object, boolean state) {
+               if (state) {
+                       if (!fCheckElements.contains(object)) {
+                               fCheckElements.add(object);
+                       }
+               } else {
+                       fCheckElements.remove(object);
+               }
+               if (fTable != null) {
+                       ((CheckboxTableViewer)fTable).setChecked(object, state);
+               }
+       }
+
+       /**
+        * Sets the check state of all elements
+        */     
+       public void checkAll(boolean state) {
+               if (state) {
+                       fCheckElements= getElements();
+               } else {
+                       fCheckElements.clear();
+               }
+               if (fTable != null) {
+                       ((CheckboxTableViewer) fTable).setAllChecked(state);
+               }
+               checkStateChanged();
+       }
+                       
+       void doCheckStateChanged(CheckStateChangedEvent e) {
+               if (e.getChecked()) {
+                       @SuppressWarnings("unchecked")
+                       T elem= (T) e.getElement();
+                       fCheckElements.add(elem);
+               } else {
+                       fCheckElements.remove(e.getElement());
+               }               
+               checkStateChanged();
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField#replaceElement(java.lang.Object, java.lang.Object)
+        */
+       @Override
+       public void replaceElement(T oldElement, T newElement) throws IllegalArgumentException {
+               boolean wasChecked= isChecked(oldElement);
+               super.replaceElement(oldElement, newElement);
+               setChecked(newElement, wasChecked);
+       }
+       
+       // ------ enable / disable management
+       
+       /*
+        * @see ListDialogField#getManagedButtonState
+        */
+       @Override
+       protected boolean getManagedButtonState(ISelection sel, int index) {
+               if (index == fCheckAllButtonIndex) {
+                       return !fElements.isEmpty();
+               } else if (index == fUncheckAllButtonIndex) {
+                       return !fElements.isEmpty();
+               }
+               return super.getManagedButtonState(sel, index);
+       }       
+
+       /*
+        * @see ListDialogField#extraButtonPressed
+        */     
+       @Override
+       protected boolean managedButtonPressed(int index) {
+               if (index == fCheckAllButtonIndex) {
+                       checkAll(true);
+               } else if (index == fUncheckAllButtonIndex) {
+                       checkAll(false);
+               } else {
+                       return super.managedButtonPressed(index);
+               }
+               return true;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ComboDialogField.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ComboDialogField.java
new file mode 100644 (file)
index 0000000..73eef52
--- /dev/null
@@ -0,0 +1,229 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.dialogfields;
+
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+
+/**
+ * Dialog field containing a label and a combo control.
+ */
+public class ComboDialogField extends DialogField {
+               
+       private String fText;
+       private int fSelectionIndex;
+       private String[] fItems;
+       private Combo fComboControl;
+       private ModifyListener fModifyListener;
+       private int fFlags;
+       
+       public ComboDialogField(int flags) {
+               super();
+               fText= ""; //$NON-NLS-1$
+               fItems= new String[0];
+               fFlags= flags;
+               fSelectionIndex= -1;
+       }
+                       
+       // ------- layout helpers
+               
+       /*
+        * @see DialogField#doFillIntoGrid
+        */
+       @Override
+       public Control[] doFillIntoGrid(Composite parent, int nColumns) {
+               assertEnoughColumns(nColumns);
+               
+               Label label= getLabelControl(parent);
+               label.setLayoutData(gridDataForLabel(1));
+               Combo combo= getComboControl(parent);
+               combo.setLayoutData(gridDataForCombo(nColumns - 1));
+               
+               return new Control[] { label, combo };
+       } 
+
+       /*
+        * @see DialogField#getNumberOfControls
+        */
+       @Override
+       public int getNumberOfControls() {
+               return 2;       
+       }
+       
+       protected static GridData gridDataForCombo(int span) {
+               GridData gd= new GridData();
+               gd.horizontalAlignment= GridData.FILL;
+               gd.grabExcessHorizontalSpace= false;
+               gd.horizontalSpan= span;
+               return gd;
+       }       
+       
+       // ------- focus methods
+       
+       /*
+        * @see DialogField#setFocus
+        */
+       @Override
+       public boolean setFocus() {
+               if (isOkToUse(fComboControl)) {
+                       fComboControl.setFocus();
+               }
+               return true;
+       }
+               
+       // ------- ui creation                  
+
+       /**
+        * Creates or returns the created combo control.
+        * @param parent The parent composite or <code>null</code> when the widget has
+        * already been created.
+        */             
+       public Combo getComboControl(Composite parent) {
+               if (fComboControl == null) {
+                       assertCompositeNotNull(parent);
+                       fModifyListener= new ModifyListener() {
+                               public void modifyText(ModifyEvent e) {
+                                       doModifyText(e);
+                               }
+                       };
+                       SelectionListener selectionListener= new SelectionListener() {
+                               public void widgetSelected(SelectionEvent e) {
+                                       doSelectionChanged(e);
+                               }
+                               
+                               public void widgetDefaultSelected(SelectionEvent e) {   }
+                       };
+                       
+                       fComboControl= new Combo(parent, fFlags);
+                       // moved up due to 1GEUNW2
+                       fComboControl.setItems(fItems);
+                       if (fSelectionIndex != -1) {
+                               fComboControl.select(fSelectionIndex);
+                       } else {
+                               fComboControl.setText(fText);
+                       }
+                       fComboControl.setFont(parent.getFont());
+                       fComboControl.addModifyListener(fModifyListener);
+                       fComboControl.addSelectionListener(selectionListener);
+                       fComboControl.setEnabled(isEnabled());
+               }
+               return fComboControl;
+       }       
+       
+       protected void doModifyText(ModifyEvent e) {
+               if (isOkToUse(fComboControl)) {
+                       fText= fComboControl.getText();
+                       fSelectionIndex= fComboControl.getSelectionIndex();
+               }
+               dialogFieldChanged();
+       }
+       
+       protected void doSelectionChanged(SelectionEvent e) {
+               if (isOkToUse(fComboControl)) {
+                       fItems= fComboControl.getItems();
+                       fText= fComboControl.getText();
+                       fSelectionIndex= fComboControl.getSelectionIndex();
+               }
+               dialogFieldChanged();   
+       }
+       
+       // ------ enable / disable management
+       
+       /*
+        * @see DialogField#updateEnableState
+        */             
+       @Override
+       protected void updateEnableState() {
+               super.updateEnableState();              
+               if (isOkToUse(fComboControl)) {
+                       fComboControl.setEnabled(isEnabled());
+               }       
+       }               
+               
+       // ------ text access 
+       
+       /**
+        * Gets the combo items.
+        */     
+       public String[] getItems() {
+               return fItems;
+       }
+       
+       /**
+        * Sets the combo items. Triggers a dialog-changed event.
+        */
+       public void setItems(String[] items) {
+               fItems= items;
+               if (isOkToUse(fComboControl)) {
+                       fComboControl.setItems(items);
+               }
+               dialogFieldChanged();
+       }
+       
+       /**
+        * Gets the text.
+        */     
+       public String getText() {
+               return fText;
+       }
+       
+       /**
+        * Sets the text. Triggers a dialog-changed event.
+        */
+       public void setText(String text) {
+               fText= text;
+               if (isOkToUse(fComboControl)) {
+                       fComboControl.setText(text);
+               } else {
+                       dialogFieldChanged();
+               }       
+       }
+
+       /**
+        * Selects an item.
+        */     
+       public void selectItem(int index) {
+               if (isOkToUse(fComboControl)) {
+                       fComboControl.select(index);
+               } else {
+                       if (index >= 0 && index < fItems.length) {
+                               fText= fItems[index];
+                               fSelectionIndex= index; 
+                       }
+               }
+               dialogFieldChanged();
+       }
+       
+       public int getSelectionIndex() {
+               return fSelectionIndex;
+       }
+       
+
+       /**
+        * Sets the text without triggering a dialog-changed event.
+        */
+       public void setTextWithoutUpdate(String text) {
+               fText= text;
+               if (isOkToUse(fComboControl)) {
+                       fComboControl.removeModifyListener(fModifyListener);
+                       fComboControl.setText(text);
+                       fComboControl.addModifyListener(fModifyListener);
+               }
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/DialogField.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/DialogField.java
new file mode 100644 (file)
index 0000000..1196178
--- /dev/null
@@ -0,0 +1,218 @@
+/*******************************************************************************
+ *  Copyright (c) 2005, 2008 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.dialogfields;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+
+public class DialogField {
+
+       private Label fLabel;
+       protected String fLabelText;
+       
+       private IDialogFieldListener fDialogFieldListener;
+       
+       private boolean fEnabled;
+
+       public DialogField() {
+               fEnabled= true;
+               fLabel= null;
+               fLabelText= ""; //$NON-NLS-1$
+       }
+       
+       /**
+        * Sets the label of the dialog field.
+        */
+       public void setLabelText(String labeltext) {
+               fLabelText= labeltext;
+       }
+               
+       // ------ change listener
+       
+       /**
+        * Defines the listener for this dialog field.
+        */     
+       public final void setDialogFieldListener(IDialogFieldListener listener) {
+               fDialogFieldListener= listener;
+       }
+
+       /**
+        * Programmatical invocation of a dialog field change.
+        */             
+       public void dialogFieldChanged() {
+               if (fDialogFieldListener != null) {
+                       fDialogFieldListener.dialogFieldChanged(this);
+               }
+       }       
+       
+       // ------- focus management
+       
+       /**
+        * Tries to set the focus to the dialog field.
+        * Returns <code>true</code> if the dialog field can take focus.
+        *      To be reimplemented by dialog field implementors.
+        */
+       public boolean setFocus() {
+               return false;
+       }
+
+       /**
+        * Posts <code>setFocus</code> to the display event queue.
+        */     
+       public void postSetFocusOnDialogField(Display display) {
+               if (display != null) {
+                       display.asyncExec(
+                               new Runnable() {
+                                       public void run() {
+                                               setFocus();
+                                       }
+                               }
+                       );
+               }
+       }               
+       
+       // ------- layout helpers
+       
+       /**
+        * Creates all controls of the dialog field and fills it to a composite.
+        * The composite is assumed to have <code>MGridLayout</code> as
+        * layout.
+        * The dialog field will adjust its controls' spans to the number of columns given.
+        *      To be reimplemented by dialog field implementors.
+        */
+       public Control[] doFillIntoGrid(Composite parent, int nColumns) {
+               assertEnoughColumns(nColumns);
+               
+               Label label= getLabelControl(parent);
+               label.setLayoutData(gridDataForLabel(nColumns));
+               
+               return new Control[] { label };
+       }
+       
+       /**
+        * Returns the number of columns of the dialog field.
+        *      To be reimplemented by dialog field implementors.
+        */
+       public int getNumberOfControls() {
+               return 1;       
+       }       
+       
+       protected static GridData gridDataForLabel(int span) {
+               GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               gd.horizontalSpan= span;
+               return gd;
+       }
+       
+       // ------- ui creation
+
+       /**
+        * Creates or returns the created label widget.
+        * @param parent The parent composite or <code>null</code> if the widget has
+        * already been created.
+        */                     
+       public Label getLabelControl(Composite parent) {
+               if (fLabel == null) {
+                       assertCompositeNotNull(parent);
+                       
+                       fLabel= new Label(parent, SWT.LEFT);
+                       fLabel.setFont(parent.getFont());
+                       fLabel.setEnabled(fEnabled);            
+                       if (fLabelText != null && !"".equals(fLabelText)) { //$NON-NLS-1$
+                               fLabel.setText(fLabelText);
+                       } else {
+                               // XXX: to avoid a 16 pixel wide empty label - revisit
+                               fLabel.setText("."); //$NON-NLS-1$
+                               fLabel.setVisible(false);
+                       }                       
+               }
+               return fLabel;
+       }
+
+       /**
+        * Creates a spacer control.
+        * @param parent The parent composite
+        */             
+       public static Control createEmptySpace(Composite parent) {
+               return createEmptySpace(parent, 1);
+       }
+
+       /**
+        * Creates a spacer control with the given span.
+        * The composite is assumed to have <code>MGridLayout</code> as
+        * layout.
+        * @param parent The parent composite
+        */                     
+       public static Control createEmptySpace(Composite parent, int span) {
+               Label label= new Label(parent, SWT.LEFT);
+               GridData gd= new GridData();
+               gd.horizontalAlignment= GridData.BEGINNING;
+               gd.grabExcessHorizontalSpace= false;
+               gd.horizontalSpan= span;
+               gd.horizontalIndent= 0;
+               gd.widthHint= 0;
+               gd.heightHint= 0;
+               label.setLayoutData(gd);
+               return label;
+       }
+       
+       /**
+        * Tests is the control is not <code>null</code> and not disposed.
+       */
+       protected final boolean isOkToUse(Control control) {
+               return (control != null) && !(control.isDisposed());
+       }
+       
+       // --------- enable / disable management
+       
+       /**
+        * Sets the enable state of the dialog field.
+        */
+       public final void setEnabled(boolean enabled) {
+               if (enabled != fEnabled) {
+                       fEnabled= enabled;
+                       updateEnableState();
+               }
+       }
+       
+       /**
+        * Called when the enable state changed.
+        * To be extended by dialog field implementors.
+        */
+       protected void updateEnableState() {
+               if (fLabel != null) {
+                       fLabel.setEnabled(fEnabled);
+               }
+       }
+
+       /**
+        * Gets the enable state of the dialog field.
+        */     
+       public final boolean isEnabled() {
+               return fEnabled;
+       }
+
+       protected final void assertCompositeNotNull(Composite comp) {
+               Assert.isNotNull(comp, "uncreated control requested with composite null"); //$NON-NLS-1$
+       }
+       
+       protected final void assertEnoughColumns(int nColumns) {
+               Assert.isTrue(nColumns >= getNumberOfControls(), "given number of columns is too small"); //$NON-NLS-1$
+       }
+       
+       
+
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IDialogFieldListener.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IDialogFieldListener.java
new file mode 100644 (file)
index 0000000..520a04a
--- /dev/null
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2000 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.dialogfields;
+
+public interface IDialogFieldListener {
+       
+       void dialogFieldChanged(DialogField field);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IListAdapter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IListAdapter.java
new file mode 100644 (file)
index 0000000..a1351e1
--- /dev/null
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Rational Software - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.dialogfields;
+
+/**
+ * Change listener used by <code>ListDialogField</code> and <code>CheckedListDialogField</code>
+ */
+public interface IListAdapter<T> {
+       
+       /**
+        * A button from the button bar has been pressed.
+        */
+       void customButtonPressed(ListDialogField<T> field, int index);
+       
+       /**
+        * The selection of the list has changed.
+        */     
+       void selectionChanged(ListDialogField<T> field);
+       
+       /**
+        * En entry in the list has been double clicked
+        */
+       void doubleClicked(ListDialogField<T> field);   
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IStringButtonAdapter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IStringButtonAdapter.java
new file mode 100644 (file)
index 0000000..651e38d
--- /dev/null
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2000 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.dialogfields;
+
+public interface IStringButtonAdapter {
+       
+       void changeControlPressed(DialogField field);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ITreeListAdapter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ITreeListAdapter.java
new file mode 100644 (file)
index 0000000..a749914
--- /dev/null
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.dialogfields;
+
+import org.eclipse.swt.events.KeyEvent;
+
+/**
+ * Change listener used by <code>TreeListDialogField</code>
+ */
+public interface ITreeListAdapter<T> {
+       
+       /**
+        * A button from the button bar has been pressed.
+        */
+       void customButtonPressed(TreeListDialogField<T> field, int index);
+       
+       /**
+        * The selection of the list has changed.
+        */     
+       void selectionChanged(TreeListDialogField<T> field);
+
+       /**
+        * The list has been double clicked
+        */
+       void doubleClicked(TreeListDialogField<T> field);
+
+       /**
+        * A key has been pressed
+        */
+       void keyPressed(TreeListDialogField<T> field, KeyEvent event);
+
+       Object[] getChildren(TreeListDialogField<T> field, Object element);
+
+       Object getParent(TreeListDialogField<T> field, Object element);
+
+       boolean hasChildren(TreeListDialogField<T> field, Object element);
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LayoutUtil.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LayoutUtil.java
new file mode 100644 (file)
index 0000000..f9da1a3
--- /dev/null
@@ -0,0 +1,180 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Rational Software - initial implementation
+ *     Markus Schorn (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.dialogfields;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Layout;
+
+public class LayoutUtil {
+       /**
+        * Calculates the number of columns needed by field editors
+        */
+       public static int getNumberOfColumns(DialogField[] editors) {
+               int nColumns= 0;
+               for (int i= 0; i < editors.length; i++) {
+                       nColumns= Math.max(editors[i].getNumberOfControls(), nColumns);
+               }
+               return nColumns;
+       }
+
+       /**
+        * Returns the number of columns in the layout of a composite,
+        * or 1 if the composite doesn't have a grid layout.
+        */
+       public static int getNumberOfColumns(Composite composite) {
+               Layout layout = composite.getLayout();
+               return layout instanceof GridLayout ? ((GridLayout) layout).numColumns : 1;
+       }
+       
+       /**
+        * Creates a composite and fills in the given editors.
+        * @param labelOnTop Defines if the label of all fields should be on top of the fields
+        */     
+       public static void doDefaultLayout(Composite parent, DialogField[] editors, boolean labelOnTop) {
+               doDefaultLayout(parent, editors, labelOnTop, 0, 0, 0, 0);
+       }
+
+       /**
+        * Creates a composite and fills in the given editors.
+        * @param labelOnTop Defines if the label of all fields should be on top of the fields
+        * @param minWidth The minimal width of the composite
+        * @param minHeight The minimal height of the composite 
+        */
+       public static void doDefaultLayout(Composite parent, DialogField[] editors, boolean labelOnTop,
+                       int minWidth, int minHeight) {
+               doDefaultLayout(parent, editors, labelOnTop, minWidth, minHeight, 0, 0);
+       }
+
+       /**
+        * Creates a composite and fills in the given editors.
+        * @param labelOnTop Defines if the label of all fields should be on top of the fields
+        * @param minWidth The minimal width of the composite
+        * @param minHeight The minimal height of the composite
+        * @param marginWidth The margin width to be used by the composite
+        * @param marginHeight The margin height to be used by the composite
+        */     
+       private static void doDefaultLayout(Composite parent, DialogField[] editors, boolean labelOnTop,
+                       int minWidth, int minHeight, int marginWidth, int marginHeight) {
+               int nCulumns= getNumberOfColumns(editors);
+               Control[][] controls= new Control[editors.length][];
+               for (int i= 0; i < editors.length; i++) {
+                       controls[i]= editors[i].doFillIntoGrid(parent, nCulumns);
+               }
+               if (labelOnTop) {
+                       nCulumns--;
+                       modifyLabelSpans(controls, nCulumns);
+               }
+               GridLayout layout= new GridLayout();
+               if (marginWidth != SWT.DEFAULT) {
+                       layout.marginWidth= marginWidth;
+               }
+               if (marginHeight != SWT.DEFAULT) {
+                       layout.marginHeight= marginHeight;
+               }
+               layout.numColumns= nCulumns;            
+               parent.setLayout(layout);
+       }
+       
+       private static void modifyLabelSpans(Control[][] controls, int nCulumns) {
+               for (int i= 0; i < controls.length; i++) {
+                       setHorizontalSpan(controls[i][0], nCulumns);
+               }
+       }
+       
+       /**
+        * Sets the span of a control. Assumes that GridData is used.
+        */
+       public static void setHorizontalSpan(Control control, int span) {
+               Object ld= control.getLayoutData();
+               if (ld instanceof GridData) {
+                       ((GridData) ld).horizontalSpan= span;
+               } else if (span != 1) {
+                       GridData gd= new GridData();
+                       gd.horizontalSpan= span;
+                       control.setLayoutData(gd);
+               }
+       }       
+
+       /**
+        * Sets the width hint of a control. Assumes that GridData is used.
+        */
+       public static void setWidthHint(Control control, int widthHint) {
+               Object ld= control.getLayoutData();
+               if (ld instanceof GridData) {
+                       ((GridData) ld).widthHint= widthHint;
+               }
+       }
+       
+       /**
+        * Sets the heigthHint hint of a control. Assumes that GridData is used.
+        */
+       public static void setHeightHint(Control control, int heigthHint) {
+               Object ld= control.getLayoutData();
+               if (ld instanceof GridData) {
+                       ((GridData) ld).heightHint= heigthHint;
+               }
+       }       
+       
+       /**
+        * Sets the horizontal indent of a control. Assumes that GridData is used.
+        */
+       public static void setHorizontalIndent(Control control, int horizontalIndent) {
+               Object ld= control.getLayoutData();
+               if (ld instanceof GridData) {
+                       ((GridData) ld).horizontalIndent= horizontalIndent;
+               }
+       }
+       
+       /**
+        * Sets the horizontal alignment of a control. Assumes that GridData is used.
+        */
+       public static void setHorizontalAlignment(Control control, int horizontalAlignment) {
+               Object ld= control.getLayoutData();
+               if (ld instanceof GridData) {
+                       ((GridData) ld).horizontalAlignment= horizontalAlignment;
+               }
+       }               
+
+       /**
+        * Makes a control grab all available horizontal space. Assumes that GridData is used.
+        */
+       public static void setHorizontalGrabbing(Control control) {
+               setHorizontalGrabbing(control, true);
+       }
+
+       /**
+        * Makes a control grab all available horizontal space. Assumes that GridData is used.
+        * @param value <code>true</code> to grab, <code>false</code> not to grab
+        */
+       public static void setHorizontalGrabbing(Control control, boolean value) {
+               Object ld= control.getLayoutData();
+               if (ld instanceof GridData) {
+                       ((GridData) ld).grabExcessHorizontalSpace= value;
+               }
+       }
+
+       /**
+        * Makes a control grab all available horizontal space. Assumes that GridData is used.
+        * @param value <code>true</code> to grab, <code>false</code> not to grab
+        */
+       public static void setVerticalGrabbing(Control control, boolean value) {
+               Object ld= control.getLayoutData();
+               if (ld instanceof GridData) {
+                       ((GridData) ld).grabExcessVerticalSpace= value;
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LinkToFileGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/LinkToFileGroup.java
new file mode 100644 (file)
index 0000000..30885fa
--- /dev/null
@@ -0,0 +1,365 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Rational Software - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.dialogfields;
+
+import java.io.File;
+
+import org.eclipse.cdt.internal.ui.wizards.NewWizardMessages;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.core.resources.IPathVariableManager;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * This class is part of the NewClassWizard.
+ * It handles the Link to file part. 
+ */
+public class LinkToFileGroup extends StringButtonDialogField {
+       protected Listener listener;
+       private String initialLinkTarget;
+       private int type;
+       protected boolean createLink = false;
+
+       // used to compute layout sizes
+       //private FontMetrics fontMetrics;
+
+       // widgets
+       //private Composite groupComposite;
+       protected Text linkTargetField;
+       protected Button linkButton;
+       protected Button browseButton;
+       private Label resolvedPathLabelText;
+       private Label resolvedPathLabelData;
+       boolean preventDialogFieldChanged = false;
+       
+       public LinkToFileGroup(IStringButtonAdapter adapter, Listener listener) {
+               super(adapter);
+               this.listener = listener;
+               this.type = IResource.FILE;
+       }
+       
+       @Override
+       public Control[] doFillIntoGrid(Composite parent, int nColumns) {
+               assertEnoughColumns(nColumns);
+               //initializeDialogUnits(parent);
+               
+               Label label= getLabelControl(parent);
+               label.setLayoutData(gridDataForLabel(1));
+                       
+               getLinkCheckButtonControl(parent);              
+
+               Text text= getTextControl(parent);
+               text.setLayoutData(gridDataForText(2));
+
+               Button browseButton = getBrowseButtonControl(parent);           
+               browseButton.setLayoutData(gridDataForButton(browseButton, 1));
+               
+               DialogField.createEmptySpace(parent);
+
+               resolvedPathLabelText = new Label(parent, SWT.SINGLE);
+               resolvedPathLabelText.setText(NewWizardMessages.CreateLinkedResourceGroup_resolvedPathLabel); 
+               resolvedPathLabelText.setVisible(true);         
+               
+               resolvedPathLabelData = new Label(parent, SWT.SINGLE);
+               GridData data = new GridData(GridData.FILL_HORIZONTAL);
+               data.horizontalSpan = 3;
+               resolvedPathLabelData.setLayoutData(data);
+               resolvedPathLabelData.setVisible(true);
+               
+               return null;
+       }
+       
+       /*
+        * @see DialogField#getNumberOfControls
+        */             
+       @Override
+       public int getNumberOfControls() {
+               return 4;       
+       }
+       
+       public Button getLinkCheckButtonControl(Composite parent){
+               if (linkButton == null){
+                       linkButton = new Button(parent, SWT.CHECK);
+                       linkButton.setText(NewWizardMessages.NewClassWizardPage_files_linkFileButton); 
+                       linkButton.setSelection(createLink);
+                       linkButton.setFont(parent.getFont());
+                       SelectionListener selectionListener = new SelectionAdapter() {
+                               @Override
+                               public void widgetSelected(SelectionEvent e) {
+                                       createLink = linkButton.getSelection();
+                                       browseButton.setEnabled(createLink);
+                                       linkTargetField.setEnabled(createLink);
+                                       resolveVariable();
+                                       if (listener != null)
+                                               listener.handleEvent(new Event());
+                                       if (!preventDialogFieldChanged)
+                                               dialogFieldChanged();
+                               }
+                       };
+                       linkButton.addSelectionListener(selectionListener);
+               }
+               return linkButton;
+       }
+       
+       @Override
+       public String getText() {
+               return linkTargetField.getText();
+       }
+       
+       @Override
+       public void setText(String text) {
+               if (isOkToUse(linkTargetField)) {
+                       preventDialogFieldChanged = true;
+                       linkTargetField.setText(text);
+                       preventDialogFieldChanged = false;
+               }
+//             dialogFieldChanged();
+       }
+       
+       @Override
+       public Text getTextControl(Composite parent){
+               if (linkTargetField == null){
+                       assertCompositeNotNull(parent);
+                       linkTargetField = new Text(parent, SWT.BORDER);
+                       linkTargetField.setFont(parent.getFont());
+                       linkTargetField.setEnabled(createLink);
+                       linkTargetField.addModifyListener(new ModifyListener() {
+                               public void modifyText(ModifyEvent e) {
+                                       resolveVariable();
+                                       if (listener != null)
+                                               listener.handleEvent(new Event());
+                                       if (!preventDialogFieldChanged)
+                                               dialogFieldChanged();
+                               }
+                       });
+                       if (initialLinkTarget != null)
+                               linkTargetField.setText(initialLinkTarget);
+               }
+               return  linkTargetField;
+       }
+       
+       public static GridData gridDataForText(int span){
+               GridData data = new GridData();
+               data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
+               data.horizontalAlignment= GridData.FILL;
+               data.grabExcessHorizontalSpace= false;
+               data.horizontalSpan= span;              
+               return data;
+       }
+       
+       public Button getBrowseButtonControl(Composite parent){
+               // browse button
+               if (browseButton == null){
+                       assertCompositeNotNull(parent);
+                       browseButton = new Button(parent, SWT.PUSH);
+                       //setButtonLayoutData(browseButton);
+                       browseButton.setFont(parent.getFont());
+                       browseButton.setText(NewWizardMessages.CreateLinkedResourceGroup_browseButton); 
+                       browseButton.addSelectionListener(new SelectionAdapter() {
+                               @Override
+                               public void widgetSelected(SelectionEvent event) {
+                                       handleLinkTargetBrowseButtonPressed();
+                               }
+                       });
+                       browseButton.setEnabled(createLink);
+               }
+               return browseButton;
+       }
+
+       /**
+        * Returns a new status object with the given severity and message.
+        * 
+        * @return a new status object with the given severity and message.
+        */
+       private IStatus createStatus(int severity, String message) {
+               return new Status(
+                       severity,
+                       CUIPlugin.getPluginId(),
+                       severity,
+                       message,        
+                       null);
+       }       
+       /**
+        * Returns the link target location entered by the user. 
+        *
+        * @return the link target location entered by the user. null if the user
+        *      chose not to create a link.
+        */
+       public String getLinkTarget() {
+               if (createLink && linkTargetField != null && linkTargetField.isDisposed() == false)
+                       return linkTargetField.getText();
+
+               return null;
+       }
+
+       public String getResolvedPath() {
+               if (createLink && resolvedPathLabelData != null && resolvedPathLabelData.isDisposed() == false)
+                       return resolvedPathLabelData.getText();
+
+               return null;
+       }
+
+       /**
+        * Opens a file or directory browser depending on the link type.
+        */
+       protected void handleLinkTargetBrowseButtonPressed() {
+               String linkTargetName = linkTargetField.getText();
+               File file = null;
+               String selection = null;
+       
+               if ("".equals(linkTargetName) == false) {       //$NON-NLS-1$
+                       file = new File(linkTargetName);
+                       if (file.exists() == false)
+                               file = null;
+               }
+               if (type == IResource.FILE) {
+                       FileDialog dialog = new FileDialog(linkTargetField.getShell());
+                       dialog.setText(NewWizardMessages.CreateLinkedResourceGroup_open); 
+                       if (file != null) {
+                               if (file.isFile())
+                                       dialog.setFileName(linkTargetName);
+                               else
+                                       dialog.setFilterPath(linkTargetName);
+                       }
+                       selection = dialog.open();              
+               }
+               else {
+                       DirectoryDialog dialog = new DirectoryDialog(linkTargetField.getShell());
+                       dialog.setText(NewWizardMessages.CreateLinkedResourceGroup_open); 
+                       if (file != null) {
+                               if (file.isFile())
+                                       linkTargetName = file.getParent();
+                               if (linkTargetName != null)
+                                       dialog.setFilterPath(linkTargetName);
+                       }
+                       dialog.setMessage(NewWizardMessages.CreateLinkedResourceGroup_targetSelectionLabel); 
+                       selection = dialog.open();
+               }                                       
+               if (selection != null) {
+                       linkTargetField.setText(selection);
+                       if (!preventDialogFieldChanged)
+                               dialogFieldChanged();
+               }
+       }
+       /**
+        * Tries to resolve the value entered in the link target field as 
+        * a variable, if the value is a relative path.
+        * Displays the resolved value if the entered value is a variable.
+        */
+       protected void resolveVariable() {
+               if (!linkTargetField.isEnabled()) {
+                       resolvedPathLabelData.setText(""); //$NON-NLS-1$
+                       return;
+               }
+                       
+               IPathVariableManager pathVariableManager = ResourcesPlugin.getWorkspace().getPathVariableManager();
+               IPath path = new Path(linkTargetField.getText());
+               IPath resolvedPath = pathVariableManager.resolvePath(path);
+       
+               resolvedPathLabelData.setText(resolvedPath.toOSString());
+       }
+       /**
+        * Sets the value of the link target field
+        * 
+        * @param target the value of the link target field
+        */
+       public void setLinkTarget(String target) {
+               initialLinkTarget = target;
+               if (linkTargetField != null && linkTargetField.isDisposed() == false) {
+                       linkTargetField.setText(target);
+                       if (!preventDialogFieldChanged)
+                               dialogFieldChanged();
+               }
+       }
+       /**
+        * Validates the type of the given file against the link type specified
+        * in the constructor.
+        * 
+        * @param linkTargetFile file to validate
+        * @return IStatus indicating the validation result. IStatus.OK if the 
+        *      given file is valid.
+        */
+       private IStatus validateFileType(File linkTargetFile) {
+               if (type == IResource.FILE && linkTargetFile.isFile() == false) {
+                       return createStatus(
+                               IStatus.ERROR,
+                               NewWizardMessages.CreateLinkedResourceGroup_linkTargetNotFile); 
+               } else if (type == IResource.FOLDER && linkTargetFile.isDirectory() == false) {
+                       return createStatus(
+                               IStatus.ERROR,
+                               NewWizardMessages.CreateLinkedResourceGroup_linkTargetNotFolder);       
+               }
+               return createStatus(IStatus.OK, ""); //$NON-NLS-1$
+       }
+       /**
+        * Validates this page's controls.
+        *
+        * @return IStatus indicating the validation result. IStatus.OK if the 
+        *      specified link target is valid given the linkHandle.
+        */
+       public IStatus validateLinkLocation(IResource linkHandle) {
+               if (linkTargetField == null || linkTargetField.isDisposed())
+                       return createStatus(IStatus.OK, "");    //$NON-NLS-1$
+       
+               IWorkspace workspace = ResourcesPlugin.getWorkspace();
+               String linkTargetName = linkTargetField.getText();
+               IPath path = new Path(linkTargetName);
+       
+               if (createLink == false)
+                       return createStatus(IStatus.OK, ""); //$NON-NLS-1$
+
+               IStatus locationStatus = workspace.validateLinkLocation(linkHandle,     path);
+               if (locationStatus.getSeverity() == IStatus.ERROR)
+                       return locationStatus;
+
+               // use the resolved link target name
+               linkTargetName = resolvedPathLabelData.getText();
+               path = new Path(linkTargetName);
+               File linkTargetFile = new Path(linkTargetName).toFile();
+               if (linkTargetFile.exists()) {
+                       IStatus fileTypeStatus = validateFileType(linkTargetFile);
+                       if (fileTypeStatus.isOK() == false)
+                               return fileTypeStatus;
+               } else if (locationStatus.getSeverity() == IStatus.OK) {
+                       // locationStatus takes precedence over missing location warning.
+                       return createStatus(
+                               IStatus.WARNING,
+                               NewWizardMessages.CreateLinkedResourceGroup_linkTargetNonExistent);     
+               }
+               return locationStatus;
+       }
+       
+       public boolean linkCreated (){
+               return createLink;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField.java
new file mode 100644 (file)
index 0000000..cbc8300
--- /dev/null
@@ -0,0 +1,884 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Rational Software - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.dialogfields;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IBaseLabelProvider;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+import org.eclipse.cdt.internal.ui.util.SWTUtil;
+import org.eclipse.cdt.internal.ui.util.TableLayoutComposite;
+
+/**
+ * A list with a button bar.
+ * Typical buttons are 'Add', 'Remove', 'Up' and 'Down'.
+ * List model is independent of widget creation.
+ * DialogFields controls are: Label, List and Composite containing buttons.
+ */
+public class ListDialogField<T> extends DialogField {
+       
+       public static class ColumnsDescription {
+               protected ColumnLayoutData[] columns;
+               protected String[] headers;
+               protected boolean drawLines;
+               
+               public ColumnsDescription(ColumnLayoutData[] columns, String[] headers, boolean drawLines) {
+                       this.columns= columns;
+                       this.headers= headers;
+                       this.drawLines= drawLines;
+               }
+               
+               public ColumnsDescription(String[] headers, boolean drawLines) {
+                       this(createColumnWeightData(headers.length), headers, drawLines);
+               }
+               
+               public ColumnsDescription(int nColumns, boolean drawLines) {
+                       this(createColumnWeightData(nColumns), null, drawLines);
+               }
+               
+               private static ColumnLayoutData[] createColumnWeightData(int nColumns) {
+                       ColumnLayoutData[] data= new ColumnLayoutData[nColumns];
+                       for (int i= 0; i < nColumns; i++) {
+                               data[i]= new ColumnWeightData(1);
+                       }                       
+                       return data;
+               }
+       }
+       
+       protected TableViewer fTable;
+       protected IBaseLabelProvider fLabelProvider;
+       protected ListViewerAdapter fListViewerAdapter;
+       protected List<T> fElements;
+       protected ViewerComparator fViewerComparator;
+
+       protected String[] fButtonLabels;
+       private Button[] fButtonControls;
+       
+       private boolean[] fButtonsEnabled;
+       
+       private int fRemoveButtonIndex;
+       private int fUpButtonIndex;
+       private int fDownButtonIndex;
+       
+       private Label fLastSeparator;
+       
+       protected Control fTableControl;
+       private Composite fButtonsControl;
+       private ISelection fSelectionWhenEnabled;
+       
+       private IListAdapter<T> fListAdapter;
+       
+       private Object fParentElement;
+       
+       protected ColumnsDescription fTableColumns;
+       
+
+       /**
+        * Creates the <code>ListDialogField</code>.
+        * @param adapter A listener for button invocation, selection changes. Can
+        * be <code>null</code>.
+        * @param buttonLabels The labels of all buttons: <code>null</code> is a valid array entry and
+        * marks a separator.
+        * @param lprovider The label provider to render the table entries
+        */     
+       public ListDialogField(IListAdapter<T> adapter, String[] buttonLabels, IBaseLabelProvider lprovider) {
+               super();
+               fListAdapter= adapter;
+
+               fLabelProvider= lprovider;
+               fListViewerAdapter= new ListViewerAdapter();
+               fParentElement= this;
+
+               fElements= new ArrayList<T>(10);
+                                       
+               fButtonLabels= buttonLabels;
+               if (fButtonLabels != null) {
+                       int nButtons= fButtonLabels.length;
+                       fButtonsEnabled= new boolean[nButtons];
+                       for (int i= 0; i < nButtons; i++) {
+                               fButtonsEnabled[i]= true;
+                       }
+               }       
+                               
+               fTable= null;
+               fTableControl= null;
+               fButtonsControl= null;
+               fTableColumns= null;
+               
+               fRemoveButtonIndex= -1;
+               fUpButtonIndex= -1;
+               fDownButtonIndex= -1;
+       }
+               
+       /**
+        * Sets the index of the 'remove' button in the button label array passed in the constructor.
+        * The behaviour of the button marked as the 'remove' button will then be handled internally.
+        * (enable state, button invocation behaviour)
+        */     
+       public void setRemoveButtonIndex(int removeButtonIndex) {
+               Assert.isTrue(removeButtonIndex < fButtonLabels.length);
+               fRemoveButtonIndex= removeButtonIndex;
+       }
+
+       /**
+        * Sets the index of the 'up' button in the button label array passed in the constructor.
+        * The behaviour of the button marked as the 'up' button will then be handled internally.
+        * (enable state, button invocation behaviour)
+        */     
+       public void setUpButtonIndex(int upButtonIndex) {
+               Assert.isTrue(upButtonIndex < fButtonLabels.length);
+               fUpButtonIndex= upButtonIndex;
+       }
+
+       /**
+        * Sets the index of the 'down' button in the button label array passed in the constructor.
+        * The behaviour of the button marked as the 'down' button will then be handled internally.
+        * (enable state, button invocation behaviour)
+        */     
+       public void setDownButtonIndex(int downButtonIndex) {
+               Assert.isTrue(downButtonIndex < fButtonLabels.length);
+               fDownButtonIndex= downButtonIndex;
+       }
+       
+       /**
+        * Sets the viewerComparator.
+        * @param viewerComparator The viewerComparator to set
+        */
+       public void setViewerComparator(ViewerComparator viewerComparator) {
+               fViewerComparator= viewerComparator;
+       }
+       
+       public void setTableColumns(ColumnsDescription column) {
+               fTableColumns= column;
+       }
+       
+       
+       // ------ adapter communication
+       
+       private void buttonPressed(int index) {
+               if (!managedButtonPressed(index) && fListAdapter != null) {
+                       fListAdapter.customButtonPressed(this, index);
+               }
+       }
+       
+       /**
+        * Checks if the button pressed is handled internally
+        * @return Returns true if button has been handled.
+        */
+       protected boolean managedButtonPressed(int index) {
+               if (index == fRemoveButtonIndex) {
+                       remove();
+               } else if (index == fUpButtonIndex) {
+                       up();
+               } else if (index == fDownButtonIndex) {
+                       down();
+               } else {
+                       return false;
+               }
+               return true;
+       }
+       
+
+       // ------ layout helpers
+       
+       /*
+        * @see DialogField#doFillIntoGrid
+        */
+       @Override
+       public Control[] doFillIntoGrid(Composite parent, int nColumns) {
+               PixelConverter converter= new PixelConverter(parent);
+               
+               assertEnoughColumns(nColumns);
+               
+               Label label= getLabelControl(parent);
+               GridData gd= gridDataForLabel(1);
+               gd.verticalAlignment= GridData.BEGINNING;
+               label.setLayoutData(gd);
+               
+               Control list= getListControl(parent);
+               gd= new GridData();
+               gd.horizontalAlignment= GridData.FILL;
+               gd.grabExcessHorizontalSpace= true;
+               gd.verticalAlignment= GridData.FILL;
+               gd.grabExcessVerticalSpace= true;
+               gd.horizontalSpan= nColumns - 2;
+               gd.widthHint= converter.convertWidthInCharsToPixels(50);
+               gd.heightHint= converter.convertHeightInCharsToPixels(6);
+
+               list.setLayoutData(gd);
+               
+               Composite buttons= getButtonBox(parent);
+               gd= new GridData();
+               gd.horizontalAlignment= GridData.FILL;
+               gd.grabExcessHorizontalSpace= false;
+               gd.verticalAlignment= GridData.FILL;
+               gd.grabExcessVerticalSpace= true;
+               gd.horizontalSpan= 1;
+               buttons.setLayoutData(gd);
+               
+               return new Control[] { label, list, buttons };
+       }
+
+       /*
+        * @see DialogField#getNumberOfControls
+        */     
+       @Override
+       public int getNumberOfControls() {
+               return 3;       
+       }
+
+       /**
+        * Sets the minimal width of the buttons. Must be called after widget creation.
+        */             
+       public void setButtonsMinWidth(int minWidth) {
+               if (fLastSeparator != null) {
+                       ((GridData)fLastSeparator.getLayoutData()).widthHint= minWidth;
+               }
+       }
+       
+       
+       // ------ ui creation
+       
+       /**
+        * Returns the list control. When called the first time, the control will be created.
+        * @param parent the parent composite when called the first time, or <code>null</code>
+        * after.
+        */
+       public Control getListControl(Composite parent) {
+               if (fTableControl == null) {
+                       assertCompositeNotNull(parent);
+                       
+                       if (fTableColumns == null) {
+                               fTable= createTableViewer(parent);
+                               Table tableControl= fTable.getTable();
+                               
+                               fTableControl= tableControl;
+                               tableControl.setLayout(new TableLayout());
+                       } else {
+                               TableLayoutComposite composite= new TableLayoutComposite(parent, SWT.NONE);
+                               fTableControl= composite;
+                               
+                               fTable= createTableViewer(composite);
+                               Table tableControl= fTable.getTable();
+                                                               
+                               tableControl.setHeaderVisible(fTableColumns.headers != null);
+                               tableControl.setLinesVisible(fTableColumns.drawLines);
+                               ColumnLayoutData[] columns= fTableColumns.columns;
+                               for (int i= 0; i < columns.length; i++) {
+                                       composite.addColumnData(columns[i]);
+                                       TableColumn column= new TableColumn(tableControl, SWT.NONE);
+                                       //tableLayout.addColumnData(columns[i]);
+                                       if (fTableColumns.headers != null) {
+                                               column.setText(fTableColumns.headers[i]);
+                                       }
+                               }
+                       }
+
+                       fTable.getTable().addKeyListener(new KeyAdapter() {
+                               @Override
+                               public void keyPressed(KeyEvent e) {
+                                       handleKeyPressed(e);
+                               }
+                       });
+                       
+                       //fTableControl.setLayout(tableLayout);                                         
+                       
+                       fTable.setContentProvider(fListViewerAdapter);
+                       fTable.setLabelProvider(fLabelProvider);
+                       fTable.addSelectionChangedListener(fListViewerAdapter);
+                       fTable.addDoubleClickListener(fListViewerAdapter);
+                       
+                       fTable.setInput(fParentElement);
+                       
+                       if (fViewerComparator != null) {
+                               fTable.setComparator(fViewerComparator);
+                       }
+                       
+                       fTableControl.setEnabled(isEnabled());
+                       if (fSelectionWhenEnabled != null) {
+                               postSetSelection(fSelectionWhenEnabled);
+                       }
+               }
+               return fTableControl;
+       }
+
+       /**
+        * Returns the internally used table viewer.
+        */             
+       public TableViewer getTableViewer() {
+               return fTable;
+       }
+       
+       /* 
+        * Subclasses may override to specify a different style.
+        */
+       protected int getListStyle(){
+               int style=  SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL ;
+               if (fTableColumns != null) {
+                       style |= SWT.FULL_SELECTION;
+               }
+               return style;           
+       }
+       
+       protected TableViewer createTableViewer(Composite parent) {
+               Table table= new Table(parent, getListStyle());
+               return new TableViewer(table);
+       }       
+       
+       protected Button createButton(Composite parent, String label, SelectionListener listener) {
+               Button button= new Button(parent, SWT.PUSH);
+               button.setText(label);
+               button.addSelectionListener(listener);
+               GridData gd= new GridData();
+               gd.horizontalAlignment= GridData.FILL;
+               gd.grabExcessHorizontalSpace= true;
+               gd.verticalAlignment= GridData.BEGINNING;
+               gd.widthHint = SWTUtil.getButtonWidthHint(button);
+       
+               button.setLayoutData(gd);
+               return button;
+       }
+       
+       private Label createSeparator(Composite parent) {
+               Label separator= new Label(parent, SWT.NONE);
+               separator.setVisible(false);
+               GridData gd= new GridData();
+               gd.horizontalAlignment= GridData.FILL;
+               gd.verticalAlignment= GridData.BEGINNING;
+               gd.heightHint= 4;
+               separator.setLayoutData(gd);
+               return separator;
+       }                       
+
+       /**
+        * Returns the composite containing the buttons. When called the first time, the control
+        * will be created.
+        * @param parent the parent composite when called the first time, or <code>null</code>
+        * after.
+        */     
+       public Composite getButtonBox(Composite parent) {
+               if (fButtonsControl == null) {
+                       assertCompositeNotNull(parent);
+                       
+                       SelectionListener listener= new SelectionListener() {
+                               public void widgetDefaultSelected(SelectionEvent e) {
+                                       doButtonSelected(e);
+                               }
+                               public void widgetSelected(SelectionEvent e) {
+                                       doButtonSelected(e);
+                               }
+                       };
+                       
+                       Composite contents= new Composite(parent, SWT.NULL);
+                       GridLayout layout= new GridLayout();
+                       layout.marginWidth= 0;
+                       layout.marginHeight= 0;
+                       contents.setLayout(layout);
+                       
+                       if (fButtonLabels != null) {
+                               fButtonControls= new Button[fButtonLabels.length];
+                               for (int i= 0; i < fButtonLabels.length; i++) {
+                                       String currLabel= fButtonLabels[i];
+                                       if (currLabel != null) {
+                                               fButtonControls[i]= createButton(contents, currLabel, listener);
+                                               fButtonControls[i].setEnabled(isEnabled() && fButtonsEnabled[i]);
+                                       } else {
+                                               fButtonControls[i]= null;
+                                               createSeparator(contents);
+                                       }
+                               }
+                       }
+                                               
+                       fLastSeparator= createSeparator(contents);      
+       
+                       updateButtonState();
+                       fButtonsControl= contents;
+               }
+               
+               return fButtonsControl;
+       }
+       
+       protected void doButtonSelected(SelectionEvent e) {
+               if (fButtonControls != null) {
+                       for (int i= 0; i < fButtonControls.length; i++) {
+                               if (e.widget == fButtonControls[i]) {
+                                       buttonPressed(i);
+                                       return;
+                               }
+                       }
+               }
+       }
+       
+       /**
+        * Handles key events in the table viewer. Specifically
+        * when the delete key is pressed.
+        */
+       protected void handleKeyPressed(KeyEvent event) {
+               if (event.character == SWT.DEL && event.stateMask == 0) {
+                       if (fRemoveButtonIndex != -1 && isButtonEnabled(fTable.getSelection(), fRemoveButtonIndex)) {
+                               managedButtonPressed(fRemoveButtonIndex);
+                       }
+               } 
+       }       
+       
+       // ------ enable / disable management
+
+       /*
+        * @see DialogField#dialogFieldChanged
+        */     
+       @Override
+       public void dialogFieldChanged() {
+               super.dialogFieldChanged();
+               updateButtonState();
+       }
+       
+       /*
+        * Updates the enable state of the all buttons
+        */ 
+       protected void updateButtonState() {
+               if (fButtonControls != null) {
+                       ISelection sel= fTable.getSelection();
+                       for (int i= 0; i < fButtonControls.length; i++) {
+                               Button button= fButtonControls[i];
+                               if (isOkToUse(button)) {
+                                       button.setEnabled(isButtonEnabled(sel, i));
+                               }                               
+                       }
+               }
+       }
+       
+       protected boolean getManagedButtonState(ISelection sel, int index) {
+               if (index == fRemoveButtonIndex) {
+                       return !sel.isEmpty();
+               } else if (index == fUpButtonIndex) {
+                       return !sel.isEmpty() && canMoveUp();
+               } else if (index == fDownButtonIndex) {
+                       return !sel.isEmpty() && canMoveDown();
+               }
+               return true;
+       }               
+
+       /*
+        * @see DialogField#updateEnableState
+        */     
+       @Override
+       protected void updateEnableState() {
+               super.updateEnableState();
+               
+               boolean enabled= isEnabled();
+               if (isOkToUse(fTableControl)) {
+                       if (!enabled) {
+                               fSelectionWhenEnabled= fTable.getSelection();
+                               selectElements(null);
+                       } else {
+                               selectElements(fSelectionWhenEnabled);
+                               fSelectionWhenEnabled= null;
+                       }
+                       fTableControl.setEnabled(enabled);
+               }
+               updateButtonState();
+       }
+
+       /**
+        * Sets a button enabled or disabled.
+        */     
+       public void enableButton(int index, boolean enable) {
+               if (fButtonsEnabled != null && index < fButtonsEnabled.length) {
+                       fButtonsEnabled[index]= enable;
+                       updateButtonState();
+               }
+       }
+       
+       private boolean isButtonEnabled(ISelection sel, int index) {
+               boolean extraState= getManagedButtonState(sel, index);
+               return isEnabled() && extraState && fButtonsEnabled[index];
+       }               
+       
+
+       // ------ model access
+       
+       /**
+        * Sets the elements shown in the list.
+        */
+       public void setElements(List<? extends T> elements) {
+               fElements= new ArrayList<T>(elements);
+               if (fTable != null) {
+                       fTable.refresh();
+               }
+               dialogFieldChanged();
+       }
+
+       /**
+        * Gets the elements shown in the list.
+        * The list returned is a copy, so it can be modified by the user.
+        */     
+       public List<T> getElements() {
+               return new ArrayList<T>(fElements);
+       }
+
+       /**
+        * Gets the elements shown at the given index.
+        */             
+       public T getElement(int index) {
+               return fElements.get(index);
+       }
+       
+       /**
+       * Gets the index of an element in the list or -1 if element is not in list.
+       */
+       public int getIndexOfElement(Object elem) {
+               return fElements.indexOf(elem);
+       }       
+
+       /**
+        * Replace an element.
+        */             
+       public void replaceElement(T oldElement, T newElement) throws IllegalArgumentException { 
+               int idx= fElements.indexOf(oldElement);
+               if (idx != -1) {
+                       fElements.set(idx, newElement);
+                       if (fTable != null) {
+                               List<T> selected= getSelectedElements();
+                               if (selected.remove(oldElement)) {
+                                       selected.add(newElement);
+                               }
+                               fTable.refresh();
+                               selectElements(new StructuredSelection(selected));
+                       }
+                       dialogFieldChanged();
+               } else {
+                       throw new IllegalArgumentException();
+               }
+       }       
+
+       /**
+        * Adds an element at the end of the list.
+        */             
+       public void addElement(T element) {             
+               if (fElements.contains(element)) {
+                       return;
+               }
+               fElements.add(element);
+               if (fTable != null) {
+                       fTable.add(element);
+               }
+               dialogFieldChanged();
+       }
+
+       /**
+        * Adds elements at the end of the list.
+        */     
+       public void addElements(List<? extends T> elements) {
+               int nElements= elements.size();
+               
+               if (nElements > 0) {
+                       // filter duplicated
+                       ArrayList<T> elementsToAdd= new ArrayList<T>(nElements);
+                       
+                       for (int i= 0; i < nElements; i++) {
+                               T elem= elements.get(i);
+                               if (!fElements.contains(elem)) {
+                                       elementsToAdd.add(elem);
+                               }       
+                       }
+                       fElements.addAll(elementsToAdd);
+                       if (fTable != null) {
+                               fTable.add(elementsToAdd.toArray());
+                       }
+                       dialogFieldChanged();
+               }
+       }       
+
+       /**
+        * Adds an element at a position.
+        */             
+       public void insertElementAt(T element, int index) {
+               if (fElements.contains(element)) {
+                       return;
+               }
+               fElements.add(index, element);
+               if (fTable != null) {
+                       fTable.add(element);
+               }
+               
+               dialogFieldChanged();
+       }       
+
+       /**
+        * Adds an element at a position.
+        */     
+       public void removeAllElements() {
+               if (fElements.size() > 0) {
+                       fElements.clear();
+                       if (fTable != null) {
+                               fTable.refresh();
+                       }
+                       dialogFieldChanged();
+               }
+       }
+               
+       /**
+        * Removes an element from the list.
+        */             
+       public void removeElement(Object element) throws IllegalArgumentException {
+               if (fElements.remove(element)) {
+                       if (fTable != null) {
+                               fTable.remove(element);
+                       }
+                       dialogFieldChanged();
+               } else {
+                       throw new IllegalArgumentException();
+               }
+       }
+
+       /**
+        * Removes elements from the list.
+        */             
+       public void removeElements(List<?> elements) {
+               if (elements.size() > 0) {
+                       fElements.removeAll(elements);
+                       if (fTable != null) {
+                               fTable.remove(elements.toArray());
+                       }
+                       dialogFieldChanged();
+               }
+       }
+
+       /**
+        * Gets the number of elements
+        */             
+       public int getSize() {
+               return fElements.size();
+       }
+
+       public void selectElements(ISelection selection) {
+               fSelectionWhenEnabled= selection;
+               if (fTable != null) {
+                       fTable.setSelection(selection, true);
+               }
+       }
+       
+       public void selectFirstElement() {
+               Object element= null;
+               if (fViewerComparator != null) {
+                       Object[] arr= fElements.toArray(); 
+                       fViewerComparator.sort(fTable, arr);
+                       if (arr.length > 0) {
+                               element= arr[0];
+                       }
+               } else {
+                       if (fElements.size() > 0) {
+                               element= fElements.get(0);
+                       }
+               }
+               if (element != null) {
+                       selectElements(new StructuredSelection(element));
+               }
+       }
+               
+       public void postSetSelection(final ISelection selection) {
+               if (isOkToUse(fTableControl)) {
+                       Display d= fTableControl.getDisplay();
+                       d.asyncExec(new Runnable() {
+                               public void run() {
+                                       if (isOkToUse(fTableControl)) {
+                                               selectElements(selection);
+                                       }
+                               }
+                       });
+               }
+       }
+       
+       /**
+        * Refreshes the table.
+        */
+       public void refresh() {
+               if (fTable != null) {
+                       fTable.refresh();
+               }
+       }
+       
+       // ------- list maintenance
+       
+       private List<T> moveUp(List<? extends T> elements, List<? extends T> move) {
+               int nElements= elements.size();
+               List<T> res= new ArrayList<T>(nElements);
+               T floating= null;
+               for (int i= 0; i < nElements; i++) {
+                       T curr= elements.get(i);
+                       if (move.contains(curr)) {
+                               res.add(curr);
+                       } else {
+                               if (floating != null) {
+                                       res.add(floating);
+                               }
+                               floating= curr;
+                       }
+               }
+               if (floating != null) {
+                       res.add(floating);
+               }
+               return res;
+       }       
+       
+       private void moveUp(List<? extends T> toMoveUp) {
+               if (toMoveUp.size() > 0) {
+                       setElements(moveUp(fElements, toMoveUp));
+                       fTable.reveal(toMoveUp.get(0));
+               }
+       }
+       
+       private void moveDown(List<? extends T> toMoveDown) {
+               if (toMoveDown.size() > 0) {
+                       setElements(reverse(moveUp(reverse(fElements), toMoveDown)));
+                       fTable.reveal(toMoveDown.get(toMoveDown.size() - 1));
+               }
+       }
+       
+       private List<T> reverse(List<? extends T> p) {
+               List<T> reverse= new ArrayList<T>(p.size());
+               for (int i= p.size()-1; i >= 0; i--) {
+                       reverse.add(p.get(i));
+               }
+               return reverse;
+       }
+       
+       private void remove() {
+               removeElements(getSelectedElements());
+       }
+       
+       private void up() {
+               moveUp(getSelectedElements());
+       }
+       
+       private void down() {
+               moveDown(getSelectedElements());
+       }
+       
+       private boolean canMoveUp() {
+               if (isOkToUse(fTableControl)) {
+                       int[] indc= fTable.getTable().getSelectionIndices();
+                       for (int i= 0; i < indc.length; i++) {
+                               if (indc[i] != i) {
+                                       return true;
+                               }
+                       }
+               }
+               return false;
+       }
+       
+       private boolean canMoveDown() {
+               if (isOkToUse(fTableControl)) {
+                       int[] indc= fTable.getTable().getSelectionIndices();
+                       int k= fElements.size() - 1;
+                       for (int i= indc.length - 1; i >= 0 ; i--, k--) {
+                               if (indc[i] != k) {
+                                       return true;
+                               }
+                       }
+               }
+               return false;
+       }       
+
+       /**
+        * Returns the selected elements.
+        */
+       public List<T> getSelectedElements() {
+               List<T> result= new ArrayList<T>();
+               if (fTable != null) {
+                       ISelection selection= fTable.getSelection();
+                       if (selection instanceof IStructuredSelection) {
+                               @SuppressWarnings("unchecked")
+                               Iterator<T> iter= ((IStructuredSelection)selection).iterator();
+                               while (iter.hasNext()) {
+                                       result.add(iter.next());
+                               }
+                       }
+               }
+               return result;
+       }
+       
+       // ------- ListViewerAdapter
+       
+       private class ListViewerAdapter implements IStructuredContentProvider, ISelectionChangedListener, IDoubleClickListener {
+
+               // ------- ITableContentProvider Interface ------------
+       
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+                       // will never happen
+               }
+                       
+               public void dispose() {
+               }
+               
+               public Object[] getElements(Object obj) {
+                       return fElements.toArray();
+               }
+       
+               // ------- ISelectionChangedListener Interface ------------
+               
+               public void selectionChanged(SelectionChangedEvent event) {
+                       doListSelected(event);
+               }
+               
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
+                */
+               public void doubleClick(DoubleClickEvent event) {
+                       doDoubleClick(event);
+               }
+       }
+       
+       protected void doListSelected(SelectionChangedEvent event) {
+               updateButtonState();
+               if (fListAdapter != null) {
+                       fListAdapter.selectionChanged(this);
+               }
+       }
+       
+       protected void doDoubleClick(DoubleClickEvent event) {
+               if (fListAdapter != null) {
+                       fListAdapter.doubleClicked(this);
+               }
+       }       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogField.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogField.java
new file mode 100644 (file)
index 0000000..5a1547c
--- /dev/null
@@ -0,0 +1,194 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.dialogfields;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+import org.eclipse.cdt.internal.ui.util.SWTUtil;
+
+/**
+ * Dialog Field containing a single button such as a radio or checkbox button.
+ */
+public class SelectionButtonDialogField extends DialogField {
+       
+       private Button fButton;
+       private boolean fIsSelected;
+       private DialogField[] fAttachedDialogFields;
+       private int fButtonStyle;
+
+       /**
+        * Creates a selection button.
+        * Allowed button styles: SWT.RADIO, SWT.CHECK, SWT.TOGGLE, SWT.PUSH
+        */
+       public SelectionButtonDialogField(int buttonStyle) {
+               super();
+               fIsSelected= false;
+               fAttachedDialogFields= null;
+               fButtonStyle= buttonStyle;
+       }
+       
+       /**
+        * Attaches a field to the selection state of the selection button.
+        * The attached field will be disabled if the selection button is not selected.
+        */
+       public void attachDialogField(DialogField dialogField) {
+               attachDialogFields(new DialogField[] { dialogField });
+       }
+
+       /**
+        * Attaches fields to the selection state of the selection button.
+        * The attached fields will be disabled if the selection button is not selected.
+        */     
+       public void attachDialogFields(DialogField[] dialogFields) {
+               fAttachedDialogFields= dialogFields;
+               for (int i= 0; i < dialogFields.length; i++) {
+                       dialogFields[i].setEnabled(fIsSelected);
+               }
+       }       
+       
+       /**
+        * Returns <code>true</code> is  teh gived field is attached to the selection button.
+        */
+       public boolean isAttached(DialogField editor) {
+               if (fAttachedDialogFields != null) {
+                       for (int i=0; i < fAttachedDialogFields.length; i++) {
+                               if (fAttachedDialogFields[i] == editor) {
+                                       return true;
+                               }
+                       }
+               }
+               return false;
+       }
+       
+       // ------- layout helpers
+       
+       /*
+        * @see DialogField#doFillIntoGrid
+        */
+       @Override
+       public Control[] doFillIntoGrid(Composite parent, int nColumns) {
+               assertEnoughColumns(nColumns);
+               
+               Button button= getSelectionButton(parent);
+               GridData gd= new GridData();
+               gd.horizontalSpan= nColumns;
+               gd.horizontalAlignment= GridData.FILL;
+               if (fButtonStyle == SWT.PUSH) {
+                       gd.widthHint = SWTUtil.getButtonWidthHint(button);
+               }                       
+               
+               button.setLayoutData(gd);
+               
+               return new Control[] { button };
+       }       
+
+       /*
+        * @see DialogField#getNumberOfControls
+        */     
+       @Override
+       public int getNumberOfControls() {
+               return 1;       
+       }       
+       
+       // ------- ui creation                  
+
+       /**
+        * Returns the selection button widget. When called the first time, the widget will be created.
+        * @param group the parent composite when called the first time, or <code>null</code>
+        * after.
+        */             
+       public Button getSelectionButton(Composite group) {
+               if (fButton == null) {
+                       assertCompositeNotNull(group);
+                       
+                       fButton= new Button(group, fButtonStyle);
+                       fButton.setFont(group.getFont());                       
+                       fButton.setText(fLabelText);
+                       fButton.setEnabled(isEnabled());
+                       fButton.setSelection(fIsSelected);
+                       fButton.addSelectionListener(new SelectionListener() {
+                               public void widgetDefaultSelected(SelectionEvent e) {
+                                       doWidgetSelected(e);
+                               }
+                               public void widgetSelected(SelectionEvent e) {
+                                       doWidgetSelected(e);
+                               }
+                       });                             
+               }
+               return fButton;
+       }
+       
+       protected void doWidgetSelected(SelectionEvent e) {
+               if (isOkToUse(fButton)) {
+                       changeValue(fButton.getSelection());
+               }
+       }       
+       
+       private void changeValue(boolean newState) {
+               if (fIsSelected != newState) {
+                       fIsSelected= newState;                  
+                       if (fAttachedDialogFields != null) {
+                               boolean focusSet= false;
+                               for (int i= 0; i < fAttachedDialogFields.length; i++) {         
+                                       fAttachedDialogFields[i].setEnabled(fIsSelected);
+                                       if (fIsSelected && !focusSet) {
+                                               focusSet= fAttachedDialogFields[i].setFocus();
+                                       }
+                               }
+                       }
+                       dialogFieldChanged();
+               } else if (fButtonStyle == SWT.PUSH) {
+                       dialogFieldChanged();
+               }
+       }               
+
+       // ------ model access  
+       
+       /**
+        * Returns the selection state of the button.
+        */
+       public boolean isSelected() {
+               return fIsSelected;
+       }
+
+       /**
+        * Sets the selection state of the button.
+        */     
+       public void setSelection(boolean selected) {
+               changeValue(selected);
+               if (isOkToUse(fButton)) {
+                       fButton.setSelection(selected);
+               }
+       }
+
+       // ------ enable / disable management
+
+       /*
+        * @see DialogField#updateEnableState
+        */     
+       @Override
+       protected void updateEnableState() {
+               super.updateEnableState();
+               if (isOkToUse(fButton)) {
+                       fButton.setEnabled(isEnabled());
+               }               
+       }
+       
+       
+       
+               
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogFieldGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/SelectionButtonDialogFieldGroup.java
new file mode 100644 (file)
index 0000000..206d0ab
--- /dev/null
@@ -0,0 +1,258 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Rational Software - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.dialogfields;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+
+import org.eclipse.core.runtime.Assert;
+
+/**
+ * Dialog field describing a group with buttons (Checkboxes, radio buttons..)
+ */
+public class SelectionButtonDialogFieldGroup extends DialogField {
+       
+       private Composite fButtonComposite;
+       
+       private Button[] fButtons;
+       private String[] fButtonNames;
+       private boolean[] fButtonsSelected;
+       private boolean[] fButtonsEnabled;
+       
+       private int fGroupBorderStyle;
+       private int fGroupNumberOfColumns;
+       private int fButtonsStyle;      
+               
+       /**
+        * Creates a group without border.
+        */
+       public SelectionButtonDialogFieldGroup(int buttonsStyle, String[] buttonNames, int nColumns) {
+               this(buttonsStyle, buttonNames, nColumns, SWT.NONE);            
+       }       
+       
+       
+       /**
+        * Creates a group with border (label in border).
+        * Accepted button styles are: SWT.RADIO, SWT.CHECK, SWT.TOGGLE
+        * For border styles see <code>Group</code>
+        */     
+       public SelectionButtonDialogFieldGroup(int buttonsStyle, String[] buttonNames, int nColumns, int borderStyle) {
+               super();
+               
+               Assert.isTrue(buttonsStyle == SWT.RADIO || buttonsStyle == SWT.CHECK || buttonsStyle == SWT.TOGGLE);
+               fButtonNames= buttonNames;
+               
+               int nButtons= buttonNames.length;
+               fButtonsSelected= new boolean[nButtons];
+               fButtonsEnabled= new boolean[nButtons];
+               for (int i= 0; i < nButtons; i++) {
+                       fButtonsSelected[i]= false;
+                       fButtonsEnabled[i]= true;
+               }
+               if (fButtonsStyle == SWT.RADIO) {
+                       fButtonsSelected[0]= true;
+               }
+               
+               fGroupBorderStyle= borderStyle;
+               fGroupNumberOfColumns= (nColumns <= 0) ? nButtons : nColumns;
+               
+               fButtonsStyle= buttonsStyle;
+               
+       }
+       
+       // ------- layout helpers
+               
+       /*
+        * @see DialogField#doFillIntoGrid
+        */
+       @Override
+       public Control[] doFillIntoGrid(Composite parent, int nColumns) {
+               assertEnoughColumns(nColumns);
+                               
+               if (fGroupBorderStyle == SWT.NONE) {
+                       Label label= getLabelControl(parent);
+                       label.setLayoutData(gridDataForLabel(1));
+               
+                       Composite buttonsgroup= getSelectionButtonsGroup(parent);
+                       GridData gd= new GridData();
+                       gd.horizontalSpan= nColumns - 1;
+                       buttonsgroup.setLayoutData(gd);
+                       
+                       return new Control[] { label, buttonsgroup };
+               }
+               Composite buttonsgroup= getSelectionButtonsGroup(parent);
+               GridData gd= new GridData();
+               gd.horizontalSpan= nColumns;
+               buttonsgroup.setLayoutData(gd);
+               
+               return new Control[] { buttonsgroup };
+       }       
+
+       /*
+        * @see DialogField#doFillIntoGrid
+        */     
+       @Override
+       public int getNumberOfControls() {
+               return (fGroupBorderStyle == SWT.NONE) ? 2 : 1;
+       }
+       
+       // ------- ui creation
+       
+       private Button createSelectionButton(int index, Composite group, SelectionListener listener) {
+               Button button= new Button(group, fButtonsStyle | SWT.LEFT);
+               button.setFont(group.getFont());                        
+               button.setText(fButtonNames[index]);
+               button.setEnabled(isEnabled() && fButtonsEnabled[index]);
+               button.setSelection(fButtonsSelected[index]);
+               button.addSelectionListener(listener);
+               button.setLayoutData(new GridData());
+               return button;
+       }
+
+       /**
+        * Returns the group widget. When called the first time, the widget will be created.
+        * @param parent the parent composite when called the first time, or <code>null</code>
+        * after.
+        */
+       public Composite getSelectionButtonsGroup(Composite parent) {
+               if (fButtonComposite == null) {
+                       assertCompositeNotNull(parent);
+                       
+                       GridLayout layout= new GridLayout();
+                       layout.makeColumnsEqualWidth= true;
+                       layout.numColumns= fGroupNumberOfColumns;                       
+                       
+                       if (fGroupBorderStyle != SWT.NONE) {
+                               Group group= new Group(parent, fGroupBorderStyle);
+                               if (fLabelText != null && fLabelText.length() > 0) {
+                                       group.setText(fLabelText);
+                               }
+                               fButtonComposite= group;
+                       } else {
+                               fButtonComposite= new Composite(parent, SWT.NULL);
+                               layout.marginHeight= 0;
+                               layout.marginWidth= 0;
+                       }
+
+                       fButtonComposite.setLayout(layout);
+                       
+                       SelectionListener listener= new SelectionListener() {
+                               public void widgetDefaultSelected(SelectionEvent e) {
+                                       doWidgetSelected(e);
+                               }
+                               public void widgetSelected(SelectionEvent e) {
+                                       doWidgetSelected(e);
+                               }
+                       };      
+                       int nButtons= fButtonNames.length;
+                       fButtons= new Button[nButtons]; 
+                       for (int i= 0; i < nButtons; i++) {
+                               fButtons[i]= createSelectionButton(i, fButtonComposite, listener);
+                       }
+                       int nRows= nButtons / fGroupNumberOfColumns;
+                       int nFillElements= nRows * fGroupNumberOfColumns - nButtons;
+                       for (int i= 0; i < nFillElements; i++) {
+                               createEmptySpace(fButtonComposite);
+                       }
+               }
+               return fButtonComposite;
+       }
+
+       /**
+        * Returns a button from the group or <code>null</code> if not yet created.
+        */     
+       public Button getSelectionButton(int index) {
+               if (index >= 0 && index < fButtons.length) {
+                       return fButtons[index];
+               }
+               return null;
+       }
+       
+       protected void doWidgetSelected(SelectionEvent e) {
+               Button button= (Button)e.widget;
+               for (int i= 0; i < fButtons.length; i++) {
+                       if (fButtons[i] == button) {
+                               fButtonsSelected[i]= button.getSelection();
+                               dialogFieldChanged();
+                               return;
+                       }
+               }
+       }       
+       
+       // ------ model access  
+
+       /**
+        * Returns the selection state of a button contained in the group.
+        * @param index the index of the button
+        */
+       public boolean isSelected(int index) {
+               if (index >= 0 && index < fButtonsSelected.length) {
+                       return fButtonsSelected[index];
+               }
+               return false;
+       }
+       
+       /**
+        * Sets the selection state of a button contained in the group.
+        */
+       public void setSelection(int index, boolean selected) {
+               if (index >= 0 && index < fButtonsSelected.length) {
+                       if (fButtonsSelected[index] != selected) {
+                               fButtonsSelected[index]= selected;
+                               if (fButtons != null) {
+                                       Button button= fButtons[index];
+                                       if (isOkToUse(button)) {
+                                               button.setSelection(selected);
+                                       }
+                               }
+                       }
+               }
+       }
+
+       // ------ enable / disable management
+       
+       @Override
+       protected void updateEnableState() {
+               super.updateEnableState();
+               if (fButtons != null) {
+                       boolean enabled= isEnabled();
+                       for (int i= 0; i < fButtons.length; i++) {
+                               Button button= fButtons[i];
+                               if (isOkToUse(button)) {
+                                       button.setEnabled(enabled && fButtonsEnabled[i]);
+                               }
+                       }
+               }
+       }
+       
+       /**
+        * Sets the enable state of a button contained in the group.
+        */     
+       public void enableSelectionButton(int index, boolean enable) {
+               if (index >= 0 && index < fButtonsEnabled.length) {
+                       fButtonsEnabled[index]= enable;
+                       if (fButtons != null) {
+                               Button button= fButtons[index];
+                               if (isOkToUse(button)) {
+                                       button.setEnabled(isEnabled() && enable);
+                               }
+                       }
+               }
+       }       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/Separator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/Separator.java
new file mode 100644 (file)
index 0000000..278df0e
--- /dev/null
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Rational Software - initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.dialogfields;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+
+import org.eclipse.swt.layout.GridData;
+
+/**
+ * Dialog field describing a separator.
+ */
+public class Separator extends DialogField {
+       
+       private Label fSeparator;
+       private int fStyle;
+       
+       public Separator() {
+               this(SWT.NONE);
+       }       
+       
+       /**
+        * @param style of the separator. See <code>Label</code> for possible
+        * styles.
+        */
+       public Separator(int style) {
+               super();
+               fStyle= style;
+       }
+                       
+       // ------- layout helpers
+
+       /**
+        * Creates the separator and fills it in a MGridLayout.
+        * @param height The heigth of the separator
+        */             
+       public Control[] doFillIntoGrid(Composite parent, int nColumns, int height) {
+               assertEnoughColumns(nColumns);
+               
+               Control separator= getSeparator(parent);
+               separator.setLayoutData(gridDataForSeperator(nColumns, height));
+               
+               return new Control[] { separator };
+       }
+
+       /*
+        * @see DialogField#doFillIntoGrid
+        */     
+       @Override
+       public Control[] doFillIntoGrid(Composite parent, int nColumns) {
+               return doFillIntoGrid(parent, nColumns, 4);
+       }
+
+       /*
+        * @see DialogField#getNumberOfControls
+        */     
+       @Override
+       public int getNumberOfControls() {
+               return 1;       
+       }
+       
+       protected static GridData gridDataForSeperator(int span, int height) {
+               GridData gd= new GridData();
+               gd.horizontalAlignment= GridData.FILL;
+               gd.verticalAlignment= GridData.BEGINNING;
+               gd.heightHint= height;          
+               gd.horizontalSpan= span;
+               return gd;
+       }
+       
+       // ------- ui creation  
+
+       /**
+        * Creates or returns the created separator.
+        * @param parent The parent composite or <code>null</code> if the widget has
+        * already been created.
+        */     
+       public Control getSeparator(Composite parent) {
+               if (fSeparator == null) {
+                       assertCompositeNotNull(parent);
+                       fSeparator= new Label(parent, fStyle);
+               }       
+               return fSeparator;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringButtonDialogField.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringButtonDialogField.java
new file mode 100644 (file)
index 0000000..b4b780c
--- /dev/null
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.dialogfields;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.internal.ui.util.SWTUtil;
+
+/**
+ * Dialog field containing a label, text control and a button control.
+ */
+public class StringButtonDialogField extends StringDialogField {
+               
+       private Button fBrowseButton;
+       private String fBrowseButtonLabel;
+       private IStringButtonAdapter fStringButtonAdapter;
+       
+       private boolean fButtonEnabled;
+       
+       public StringButtonDialogField(IStringButtonAdapter adapter) {
+               super();
+               fStringButtonAdapter= adapter;
+               fBrowseButtonLabel= "!Browse...!"; //$NON-NLS-1$
+               fButtonEnabled= true;
+       }
+
+       /**
+        * Sets the label of the button.
+        */
+       public void setButtonLabel(String label) {
+               fBrowseButtonLabel= label;
+       }
+       
+       // ------ adapter communication
+
+       /**
+        * Programmatical pressing of the button
+        */     
+       public void changeControlPressed() {
+               fStringButtonAdapter.changeControlPressed(this);
+       }
+       
+       // ------- layout helpers
+
+       /*
+        * @see DialogField#doFillIntoGrid
+        */             
+       @Override
+       public Control[] doFillIntoGrid(Composite parent, int nColumns) {
+               assertEnoughColumns(nColumns);
+               
+               Label label= getLabelControl(parent);
+               label.setLayoutData(gridDataForLabel(1));
+               Text text= getTextControl(parent);
+               text.setLayoutData(gridDataForText(nColumns - 2));
+               Button button= getChangeControl(parent);
+               button.setLayoutData(gridDataForButton(button, 1));
+       
+               return new Control[] { label, text, button };
+       }       
+
+       /*
+        * @see DialogField#getNumberOfControls
+        */             
+       @Override
+       public int getNumberOfControls() {
+               return 3;       
+       }
+       
+       protected static GridData gridDataForButton(Button button, int span) {
+               GridData gd= new GridData();
+               gd.horizontalAlignment= GridData.FILL;
+               gd.grabExcessHorizontalSpace= false;
+               gd.horizontalSpan= span;
+               gd.widthHint = SWTUtil.getButtonWidthHint(button);              
+               return gd;
+       }               
+       
+       // ------- ui creation  
+
+       /**
+        * Creates or returns the created buttom widget.
+        * @param parent The parent composite or <code>null</code> if the widget has
+        * already been created.
+        */             
+       public Button getChangeControl(Composite parent) {
+               if (fBrowseButton == null) {
+                       assertCompositeNotNull(parent);
+                       
+                       fBrowseButton= new Button(parent, SWT.PUSH);
+                       fBrowseButton.setText(fBrowseButtonLabel);
+                       fBrowseButton.setEnabled(isEnabled() && fButtonEnabled);
+                       fBrowseButton.addSelectionListener(new SelectionListener() {
+                               public void widgetDefaultSelected(SelectionEvent e) {
+                                       changeControlPressed();
+                               }
+                               public void widgetSelected(SelectionEvent e) {
+                                       changeControlPressed();
+                               }
+                       });     
+                       
+               }
+               return fBrowseButton;
+       }
+       
+       // ------ enable / disable management
+       
+       /**
+        * Sets the enable state of the button.
+        */
+       public void enableButton(boolean enable) {
+               if (isOkToUse(fBrowseButton)) {
+                       fBrowseButton.setEnabled(isEnabled() && enable);
+               }
+               fButtonEnabled= enable;
+       }
+
+       /*
+        * @see DialogField#updateEnableState
+        */     
+       @Override
+       protected void updateEnableState() {
+               super.updateEnableState();
+               if (isOkToUse(fBrowseButton)) {
+                       fBrowseButton.setEnabled(isEnabled() && fButtonEnabled);
+               }
+       }               
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringDialogField.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/StringDialogField.java
new file mode 100644 (file)
index 0000000..2cc7711
--- /dev/null
@@ -0,0 +1,167 @@
+/*******************************************************************************
+ * Copyright (c) 2000 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.dialogfields;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+
+public class StringDialogField extends DialogField {
+               
+       private String fText;
+       private Text fTextControl;
+       private ModifyListener fModifyListener;
+       
+       public StringDialogField() {
+               super();
+               fText= ""; //$NON-NLS-1$
+       }
+                       
+       // ------- layout helpers
+               
+       /*
+        * @see DialogField#doFillIntoGrid
+        */
+       @Override
+       public Control[] doFillIntoGrid(Composite parent, int nColumns) {
+               assertEnoughColumns(nColumns);
+               
+               Label label= getLabelControl(parent);
+               label.setLayoutData(gridDataForLabel(1));
+               Text text= getTextControl(parent);
+               text.setLayoutData(gridDataForText(nColumns - 1));
+               
+               return new Control[] { label, text };
+       } 
+
+       /*
+        * @see DialogField#getNumberOfControls
+        */
+       @Override
+       public int getNumberOfControls() {
+               return 2;       
+       }
+       
+       protected static GridData gridDataForText(int span) {
+               GridData gd= new GridData();
+               gd.horizontalAlignment= GridData.FILL;
+               gd.grabExcessHorizontalSpace= true;
+               gd.horizontalSpan= span;
+               return gd;
+       }       
+       
+       // ------- focus methods
+       
+       /*
+        * @see DialogField#setFocus
+        */
+       @Override
+       public boolean setFocus() {
+               if (isOkToUse(fTextControl)) {
+                       fTextControl.setFocus();
+                       fTextControl.setSelection(0, fTextControl.getText().length());
+               }
+               return true;
+       }
+               
+       // ------- ui creation                  
+
+       /**
+        * Creates or returns the created text control.
+        * @param parent The parent composite or <code>null</code> when the widget has
+        * already been created.
+        */             
+       public Text getTextControl(Composite parent) {
+               if (fTextControl == null) {
+                       assertCompositeNotNull(parent);
+                       fModifyListener= new ModifyListener() {
+                               public void modifyText(ModifyEvent e) {
+                                       doModifyText(e);
+                               }
+                       };
+                       
+                       fTextControl= new Text(parent, SWT.SINGLE | SWT.BORDER);
+                       // moved up due to 1GEUNW2
+                       fTextControl.setText(fText);
+                       fTextControl.setFont(parent.getFont());
+                       fTextControl.addModifyListener(fModifyListener);
+                       
+                       fTextControl.setEnabled(isEnabled());
+               }
+               return fTextControl;
+       }
+       
+       protected void doModifyText(ModifyEvent e) {
+               if (isOkToUse(fTextControl)) {
+                       fText= fTextControl.getText();
+               }
+               dialogFieldChanged();
+       }               
+       
+       // ------ enable / disable management
+       
+       /*
+        * @see DialogField#updateEnableState
+        */             
+       @Override
+       protected void updateEnableState() {
+               super.updateEnableState();              
+               if (isOkToUse(fTextControl)) {
+                       fTextControl.setEnabled(isEnabled());
+               }       
+       }               
+               
+       // ------ text access 
+       
+       /**
+        * Gets the text. Can not be <code>null</code>
+        */     
+       public String getText() {
+               return fText;
+       }
+       
+       /**
+        * Sets the text. Triggers a dialog-changed event.
+        */
+       public void setText(String text) {
+               fText= text;
+               if (isOkToUse(fTextControl)) {
+                       fTextControl.setText(text);
+               } else {
+                       dialogFieldChanged();
+               }       
+       }
+
+       /**
+        * Sets the text without triggering a dialog-changed event.
+        */
+       public void setTextWithoutUpdate(String text) {
+               fText= text;
+               if (isOkToUse(fTextControl)) {
+                       fTextControl.removeModifyListener(fModifyListener);
+                       fTextControl.setText(text);
+                       fTextControl.addModifyListener(fModifyListener);
+               }
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/TreeListDialogField.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/TreeListDialogField.java
new file mode 100644 (file)
index 0000000..57a045e
--- /dev/null
@@ -0,0 +1,908 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.dialogfields;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Tree;
+
+import org.eclipse.cdt.internal.ui.util.SWTUtil;
+
+/**
+ * A list with a button bar. Typical buttons are 'Add', 'Remove', 'Up' and
+ * 'Down'. List model is independent of widget creation. DialogFields controls
+ * are: Label, List and Composite containing buttons.
+ */
+public class TreeListDialogField<T> extends DialogField {
+       protected TreeViewer fTree;
+       protected ILabelProvider fLabelProvider;
+       protected TreeViewerAdapter fTreeViewerAdapter;
+       protected List<T> fElements;
+       protected ViewerComparator fViewerComparator;
+
+       protected String[] fButtonLabels;
+       private Button[] fButtonControls;
+
+       private boolean[] fButtonsEnabled;
+
+       private int fRemoveButtonIndex;
+       private int fUpButtonIndex;
+       private int fDownButtonIndex;
+
+       private Label fLastSeparator;
+
+       Tree fTreeControl;
+       private Composite fButtonsControl;
+       private ISelection fSelectionWhenEnabled;
+
+       ITreeListAdapter<T> fTreeAdapter;
+
+       Object fParentElement;
+       private int fTreeExpandLevel;
+
+       /**
+        * @param adapter Can be <code>null</code>.
+        */
+       public TreeListDialogField(ITreeListAdapter<T> adapter, String[] buttonLabels, ILabelProvider lprovider) {
+               super();
+               fTreeAdapter = adapter;
+
+               fLabelProvider = lprovider;
+               fTreeViewerAdapter = new TreeViewerAdapter();
+               fParentElement = this;
+
+               fElements = new ArrayList<T>(10);
+
+               fButtonLabels = buttonLabels;
+               if (fButtonLabels != null) {
+                       int nButtons = fButtonLabels.length;
+                       fButtonsEnabled = new boolean[nButtons];
+                       for (int i = 0; i < nButtons; i++) {
+                               fButtonsEnabled[i] = true;
+                       }
+               }
+
+               fTree = null;
+               fTreeControl = null;
+               fButtonsControl = null;
+
+               fRemoveButtonIndex = -1;
+               fUpButtonIndex = -1;
+               fDownButtonIndex = -1;
+
+               fTreeExpandLevel = 0;
+       }
+
+       /**
+        * Sets the index of the 'remove' button in the button label array passed in
+        * the constructor. The behavior of the button marked as the 'remove'
+        * button will then be handled internally. (enable state, button invocation
+        * behavior)
+        */
+       public void setRemoveButtonIndex(int removeButtonIndex) {
+               Assert.isTrue(removeButtonIndex < fButtonLabels.length);
+               fRemoveButtonIndex = removeButtonIndex;
+       }
+
+       /**
+        * Sets the index of the 'up' button in the button label array passed in the
+        * constructor. The behavior of the button marked as the 'up' button will
+        * then be handled internally. (enable state, button invocation behavior)
+        */
+       public void setUpButtonIndex(int upButtonIndex) {
+               Assert.isTrue(upButtonIndex < fButtonLabels.length);
+               fUpButtonIndex = upButtonIndex;
+       }
+
+       /**
+        * Sets the index of the 'down' button in the button label array passed in
+        * the constructor. The behavior of the button marked as the 'down' button
+        * will then be handled internally. (enable state, button invocation
+        * behavior)
+        */
+       public void setDownButtonIndex(int downButtonIndex) {
+               Assert.isTrue(downButtonIndex < fButtonLabels.length);
+               fDownButtonIndex = downButtonIndex;
+       }
+
+       /**
+        * Sets the viewerSorter.
+        * 
+        * @param viewerSorter
+        *        The viewerSorter to set
+        *        
+        * @deprecated Use {@link #setViewerComparator(ViewerComparator)} instead.
+        */
+       @Deprecated
+       public void setViewerSorter(ViewerSorter viewerSorter) {
+               setViewerComparator(viewerSorter);
+       }
+
+       /**
+        * Sets the viewerComparator.
+        * 
+        * @param viewerComparator
+        *        The viewerComparator to set
+        */
+       public void setViewerComparator(ViewerComparator viewerComparator) {
+               fViewerComparator = viewerComparator;
+       }
+
+       public void setTreeExpansionLevel(int level) {
+               fTreeExpandLevel = level;
+               if (fTree != null) {
+                       fTree.expandToLevel(level);
+               }
+       }
+
+       // ------ adapter communication
+
+       private void buttonPressed(int index) {
+               if (!managedButtonPressed(index) && fTreeAdapter != null) {
+                       fTreeAdapter.customButtonPressed(this, index);
+               }
+       }
+
+       /**
+        * Checks if the button pressed is handled internally
+        * 
+        * @return Returns true if button has been handled.
+        */
+       protected boolean managedButtonPressed(int index) {
+               if (index == fRemoveButtonIndex) {
+                       remove();
+               } else if (index == fUpButtonIndex) {
+                       up();
+               } else if (index == fDownButtonIndex) {
+                       down();
+               } else {
+                       return false;
+               }
+               return true;
+       }
+
+       // ------ layout helpers
+
+       /*
+        * @see DialogField#doFillIntoGrid
+        */
+       @Override
+       public Control[] doFillIntoGrid(Composite parent, int nColumns) {
+               PixelConverter converter = new PixelConverter(parent);
+
+               assertEnoughColumns(nColumns);
+
+               Label label = getLabelControl(parent);
+               GridData gd = gridDataForLabel(1);
+               gd.verticalAlignment = GridData.BEGINNING;
+               label.setLayoutData(gd);
+
+               Control list = getTreeControl(parent);
+               gd = new GridData();
+               gd.horizontalAlignment = GridData.FILL;
+               gd.grabExcessHorizontalSpace = false;
+               gd.verticalAlignment = GridData.FILL;
+               gd.grabExcessVerticalSpace = true;
+               gd.horizontalSpan = nColumns - 2;
+               gd.widthHint = converter.convertWidthInCharsToPixels(50);
+               gd.heightHint = converter.convertHeightInCharsToPixels(6);
+
+               list.setLayoutData(gd);
+
+               Composite buttons = getButtonBox(parent);
+               gd = new GridData();
+               gd.horizontalAlignment = GridData.FILL;
+               gd.grabExcessHorizontalSpace = false;
+               gd.verticalAlignment = GridData.FILL;
+               gd.grabExcessVerticalSpace = true;
+               gd.horizontalSpan = 1;
+               buttons.setLayoutData(gd);
+
+               return new Control[] { label, list, buttons};
+       }
+
+       /*
+        * @see DialogField#getNumberOfControls
+        */
+       @Override
+       public int getNumberOfControls() {
+               return 3;
+       }
+
+       /**
+        * Sets the minimal width of the buttons. Must be called after widget
+        * creation.
+        */
+       public void setButtonsMinWidth(int minWidth) {
+               if (fLastSeparator != null) {
+                       ((GridData) fLastSeparator.getLayoutData()).widthHint = minWidth;
+               }
+       }
+
+       // ------ ui creation
+
+       /**
+        * Returns the tree control. When called the first time, the control will be
+        * created.
+        * 
+        * @param parent 
+        *        parent composite when called the first time, or <code>null</code>
+        *        after.
+        */
+       public Control getTreeControl(Composite parent) {
+               if (fTreeControl == null) {
+                       assertCompositeNotNull(parent);
+
+                       fTree = createTreeViewer(parent);
+
+                       fTreeControl = (Tree) fTree.getControl();
+                       fTreeControl.addKeyListener(new KeyAdapter() {
+
+                               @Override
+                               public void keyPressed(KeyEvent e) {
+                                       handleKeyPressed(e);
+                               }
+                       });
+                       fTree.setContentProvider(fTreeViewerAdapter);
+                       fTree.setLabelProvider(fLabelProvider);
+                       fTree.addSelectionChangedListener(fTreeViewerAdapter);
+                       fTree.addDoubleClickListener(fTreeViewerAdapter);
+
+                       fTree.setInput(fParentElement);
+                       fTree.expandToLevel(fTreeExpandLevel);
+
+                       if (fViewerComparator != null) {
+                               fTree.setComparator(fViewerComparator);
+                       }
+
+                       fTreeControl.setEnabled(isEnabled());
+                       if (fSelectionWhenEnabled != null) {
+                               postSetSelection(fSelectionWhenEnabled);
+                       }
+               }
+               return fTreeControl;
+       }
+
+       /**
+        * Returns the internally used table viewer.
+        */
+       public TreeViewer getTreeViewer() {
+               return fTree;
+       }
+
+       /*
+        * Subclasses may override to specify a different style.
+        */
+       protected int getTreeStyle() {
+               int style = SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL;
+               return style;
+       }
+
+       protected TreeViewer createTreeViewer(Composite parent) {
+               Tree tree = new Tree(parent, getTreeStyle());
+               return new TreeViewer(tree);
+       }
+
+       protected Button createButton(Composite parent, String label, SelectionListener listener) {
+               Button button = new Button(parent, SWT.PUSH);
+               button.setText(label);
+               button.addSelectionListener(listener);
+               GridData gd = new GridData();
+               gd.horizontalAlignment = GridData.FILL;
+               gd.grabExcessHorizontalSpace = true;
+               gd.verticalAlignment = GridData.BEGINNING;
+               gd.widthHint = SWTUtil.getButtonWidthHint(button);
+
+               button.setLayoutData(gd);
+               return button;
+       }
+
+       private Label createSeparator(Composite parent) {
+               Label separator = new Label(parent, SWT.NONE);
+               separator.setVisible(false);
+               GridData gd = new GridData();
+               gd.horizontalAlignment = GridData.FILL;
+               gd.verticalAlignment = GridData.BEGINNING;
+               gd.heightHint = 4;
+               separator.setLayoutData(gd);
+               return separator;
+       }
+
+       /**
+        * Returns the composite containing the buttons. When called the first time,
+        * the control will be created.
+        * 
+        * @param parent
+        *        parent composite when called the first time, or <code>null</code>
+        *        after.
+        */
+       public Composite getButtonBox(Composite parent) {
+               if (fButtonsControl == null) {
+                       assertCompositeNotNull(parent);
+
+                       SelectionListener listener = new SelectionListener() {
+
+                               public void widgetDefaultSelected(SelectionEvent e) {
+                                       doButtonSelected(e);
+                               }
+
+                               public void widgetSelected(SelectionEvent e) {
+                                       doButtonSelected(e);
+                               }
+                       };
+
+                       Composite contents = new Composite(parent, SWT.NULL);
+                       GridLayout layout = new GridLayout();
+                       layout.marginWidth = 0;
+                       layout.marginHeight = 0;
+                       contents.setLayout(layout);
+
+                       if (fButtonLabels != null) {
+                               fButtonControls = new Button[fButtonLabels.length];
+                               for (int i = 0; i < fButtonLabels.length; i++) {
+                                       String currLabel = fButtonLabels[i];
+                                       if (currLabel != null) {
+                                               fButtonControls[i] = createButton(contents, currLabel, listener);
+                                               fButtonControls[i].setEnabled(isEnabled() && fButtonsEnabled[i]);
+                                       } else {
+                                               fButtonControls[i] = null;
+                                               createSeparator(contents);
+                                       }
+                               }
+                       }
+
+                       fLastSeparator = createSeparator(contents);
+
+                       updateButtonState();
+                       fButtonsControl = contents;
+               }
+
+               return fButtonsControl;
+       }
+
+       void doButtonSelected(SelectionEvent e) {
+               if (fButtonControls != null) {
+                       for (int i = 0; i < fButtonControls.length; i++) {
+                               if (e.widget == fButtonControls[i]) {
+                                       buttonPressed(i);
+                                       return;
+                               }
+                       }
+               }
+       }
+
+       /**
+        * Handles key events in the table viewer. Specifically when the delete key
+        * is pressed.
+        */
+       protected void handleKeyPressed(KeyEvent event) {
+               if (event.character == SWT.DEL && event.stateMask == 0) {
+                       if (fRemoveButtonIndex != -1 && isButtonEnabled(fTree.getSelection(), fRemoveButtonIndex)) {
+                               managedButtonPressed(fRemoveButtonIndex);
+                               return;
+                       }
+               }
+               fTreeAdapter.keyPressed(this, event);
+       }
+
+       // ------ enable / disable management
+
+       /*
+        * @see DialogField#dialogFieldChanged
+        */
+       @Override
+       public void dialogFieldChanged() {
+               super.dialogFieldChanged();
+               updateButtonState();
+       }
+
+       /*
+        * Updates the enable state of the all buttons
+        */
+       protected void updateButtonState() {
+               if (fButtonControls != null) {
+                       ISelection sel = fTree.getSelection();
+                       for (int i = 0; i < fButtonControls.length; i++) {
+                               Button button = fButtonControls[i];
+                               if (isOkToUse(button)) {
+                                       button.setEnabled(isButtonEnabled(sel, i));
+                               }
+                       }
+               }
+       }
+
+       protected boolean containsAttributes(List<Object> selected) {
+               for (int i = 0; i < selected.size(); i++) {
+                       if (!fElements.contains(selected.get(i))) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+       protected boolean getManagedButtonState(ISelection sel, int index) {
+               List<Object> selected = getSelectedElements();
+               boolean hasAttributes = containsAttributes(selected);
+               if (index == fRemoveButtonIndex) {
+                       return !selected.isEmpty() && !hasAttributes;
+               } else if (index == fUpButtonIndex) {
+                       return !sel.isEmpty() && !hasAttributes && canMoveUp(selected);
+               } else if (index == fDownButtonIndex) {
+                       return !sel.isEmpty() && !hasAttributes && canMoveDown(selected);
+               }
+               return true;
+       }
+
+       /*
+        * @see DialogField#updateEnableState
+        */
+       @Override
+       protected void updateEnableState() {
+               super.updateEnableState();
+
+               boolean enabled = isEnabled();
+               if (isOkToUse(fTreeControl)) {
+                       if (!enabled) {
+                               fSelectionWhenEnabled = fTree.getSelection();
+                               selectElements(null);
+                       } else {
+                               selectElements(fSelectionWhenEnabled);
+                               fSelectionWhenEnabled = null;
+                       }
+                       fTreeControl.setEnabled(enabled);
+               }
+               updateButtonState();
+       }
+
+       /**
+        * Sets a button enabled or disabled.
+        */
+       public void enableButton(int index, boolean enable) {
+               if (fButtonsEnabled != null && index < fButtonsEnabled.length) {
+                       fButtonsEnabled[index] = enable;
+                       updateButtonState();
+               }
+       }
+
+       private boolean isButtonEnabled(ISelection sel, int index) {
+               boolean extraState = getManagedButtonState(sel, index);
+               return isEnabled() && extraState && fButtonsEnabled[index];
+       }
+
+       // ------ model access
+
+       /**
+        * Sets the elements shown in the list.
+        */
+       public void setElements(List<T> elements) {
+               fElements = new ArrayList<T>(elements);
+               refresh();
+               if (fTree != null) {
+                       fTree.expandToLevel(fTreeExpandLevel);
+               }
+               dialogFieldChanged();
+       }
+
+       /**
+        * Gets the elements shown in the list. The list returned is a copy, so it
+        * can be modified by the user.
+        */
+       public List<T> getElements() {
+               return new ArrayList<T>(fElements);
+       }
+
+       /**
+        * Gets the element shown at the given index.
+        */
+       public Object getElement(int index) {
+               return fElements.get(index);
+       }
+
+       /**
+        * Gets the index of an element in the list or -1 if element is not in list.
+        */
+       public int getIndexOfElement(Object elem) {
+               return fElements.indexOf(elem);
+       }
+
+       /**
+        * Replace an element.
+        */
+       public void replaceElement(T oldElement, T newElement) throws IllegalArgumentException {
+               int idx = fElements.indexOf(oldElement);
+               if (idx != -1) {
+                       fElements.set(idx, newElement);
+                       if (fTree != null) {
+                               List<Object> selected = getSelectedElements();
+                               if (selected.remove(oldElement)) {
+                                       selected.add(newElement);
+                               }
+                               boolean isExpanded = fTree.getExpandedState(oldElement);
+                               fTree.remove(oldElement);
+                               fTree.add(fParentElement, newElement);
+                               if (isExpanded) {
+                                       fTree.expandToLevel(newElement, fTreeExpandLevel);
+                               }
+                               selectElements(new StructuredSelection(selected));
+                       }
+                       dialogFieldChanged();
+               } else {
+                       throw new IllegalArgumentException();
+               }
+       }
+
+       /**
+        * Adds an element at the end of the tree list.
+        */
+       public void addElement(T element) {
+               if (fElements.contains(element)) {
+                       return;
+               }
+               fElements.add(element);
+               if (fTree != null) {
+                       fTree.add(fParentElement, element);
+                       fTree.expandToLevel(element, fTreeExpandLevel);
+               }
+               dialogFieldChanged();
+       }
+
+       /**
+        * Adds elements at the end of the tree list.
+        */
+       public void addElements(List<T> elements) {
+               int nElements = elements.size();
+
+               if (nElements > 0) {
+                       // filter duplicated
+                       ArrayList<T> elementsToAdd = new ArrayList<T>(nElements);
+
+                       for (int i = 0; i < nElements; i++) {
+                               T elem = elements.get(i);
+                               if (!fElements.contains(elem)) {
+                                       elementsToAdd.add(elem);
+                               }
+                       }
+                       fElements.addAll(elementsToAdd);
+                       if (fTree != null) {
+                               fTree.add(fParentElement, elementsToAdd.toArray());
+                               for (int i = 0; i < elementsToAdd.size(); i++) {
+                                       fTree.expandToLevel(elementsToAdd.get(i), fTreeExpandLevel);
+                               }
+                       }
+                       dialogFieldChanged();
+               }
+       }
+
+       /**
+        * Adds an element at a position.
+        */
+       public void insertElementAt(T element, int index) {
+               if (fElements.contains(element)) {
+                       return;
+               }
+               fElements.add(index, element);
+               if (fTree != null) {
+                       fTree.add(fParentElement, element);
+                       if (fTreeExpandLevel != -1) {
+                               fTree.expandToLevel(element, fTreeExpandLevel);
+                       }
+               }
+
+               dialogFieldChanged();
+       }
+
+       /**
+        * Adds an element at a position.
+        */
+       public void removeAllElements() {
+               if (fElements.size() > 0) {
+                       fElements.clear();
+                       refresh();
+                       dialogFieldChanged();
+               }
+       }
+
+       /**
+        * Removes an element from the list.
+        */
+       public void removeElement(Object element) throws IllegalArgumentException {
+               if (fElements.remove(element)) {
+                       if (fTree != null) {
+                               fTree.remove(element);
+                       }
+                       dialogFieldChanged();
+               } else {
+                       throw new IllegalArgumentException();
+               }
+       }
+
+       /**
+        * Removes elements from the list.
+        */
+       public void removeElements(List<?> elements) {
+               if (elements.size() > 0) {
+                       fElements.removeAll(elements);
+                       if (fTree != null) {
+                               fTree.remove(elements.toArray());
+                       }
+                       dialogFieldChanged();
+               }
+       }
+
+       /**
+        * Gets the number of elements
+        */
+       public int getSize() {
+               return fElements.size();
+       }
+
+       public void selectElements(ISelection selection) {
+               fSelectionWhenEnabled = selection;
+               if (fTree != null) {
+                       fTree.setSelection(selection, true);
+               }
+       }
+
+       public void selectFirstElement() {
+               Object element = null;
+               if (fViewerComparator != null) {
+                       Object[] arr = fElements.toArray();
+                       fViewerComparator.sort(fTree, arr);
+                       if (arr.length > 0) {
+                               element = arr[0];
+                       }
+               } else {
+                       if (fElements.size() > 0) {
+                               element = fElements.get(0);
+                       }
+               }
+               if (element != null) {
+                       selectElements(new StructuredSelection(element));
+               }
+       }
+
+       public void postSetSelection(final ISelection selection) {
+               if (isOkToUse(fTreeControl)) {
+                       Display d = fTreeControl.getDisplay();
+                       d.asyncExec(new Runnable() {
+                               public void run() {
+                                       if (isOkToUse(fTreeControl)) {
+                                               selectElements(selection);
+                                       }
+                               }
+                       });
+               }
+       }
+
+       /**
+        * Refreshes the tree.
+        */
+       public void refresh() {
+               if (fTree != null) {
+                       fTree.refresh();
+               }
+       }
+
+       /**
+        * Refreshes the tree.
+        */
+       public void refresh(Object element) {
+               if (fTree != null) {
+                       fTree.refresh(element);
+               }
+       }
+
+       // ------- list maintenance
+
+       private List<T> moveUp(List<T> elements, List<?> move) {
+               int nElements = elements.size();
+               List<T> res = new ArrayList<T>(nElements);
+               T floating = null;
+               for (int i = 0; i < nElements; i++) {
+                       T curr = elements.get(i);
+                       if (move.contains(curr)) {
+                               res.add(curr);
+                       } else {
+                               if (floating != null) {
+                                       res.add(floating);
+                               }
+                               floating = curr;
+                       }
+               }
+               if (floating != null) {
+                       res.add(floating);
+               }
+               return res;
+       }
+
+       private void moveUp(List<?> toMoveUp) {
+               if (toMoveUp.size() > 0) {
+                       setElements(moveUp(fElements, toMoveUp));
+                       fTree.reveal(toMoveUp.get(0));
+               }
+       }
+
+       private void moveDown(List<?> toMoveDown) {
+               if (toMoveDown.size() > 0) {
+                       setElements(reverse(moveUp(reverse(fElements), toMoveDown)));
+                       fTree.reveal(toMoveDown.get(toMoveDown.size() - 1));
+               }
+       }
+
+       private List<T> reverse(List<T> p) {
+               List<T> reverse = new ArrayList<T>(p.size());
+               for (int i = p.size() - 1; i >= 0; i--) {
+                       reverse.add(p.get(i));
+               }
+               return reverse;
+       }
+
+       private void remove() {
+               removeElements(getSelectedElements());
+       }
+
+       private void up() {
+               moveUp(getSelectedElements());
+       }
+
+       private void down() {
+               moveDown(getSelectedElements());
+       }
+
+       private boolean canMoveUp(List<Object> selectedElements) {
+               if (isOkToUse(fTreeControl)) {
+                       int nSelected = selectedElements.size();
+                       int nElements = fElements.size();
+                       for (int i = 0; i < nElements && nSelected > 0; i++) {
+                               if (!selectedElements.contains(fElements.get(i))) {
+                                       return true;
+                               }
+                               nSelected--;
+                       }
+               }
+               return false;
+       }
+
+       private boolean canMoveDown(List<Object> selectedElements) {
+               if (isOkToUse(fTreeControl)) {
+                       int nSelected = selectedElements.size();
+                       for (int i = fElements.size() - 1; i >= 0 && nSelected > 0; i--) {
+                               if (!selectedElements.contains(fElements.get(i))) {
+                                       return true;
+                               }
+                               nSelected--;
+                       }
+               }
+               return false;
+       }
+
+       /**
+        * Returns the selected elements.
+        */
+       public List<Object> getSelectedElements() {
+               ArrayList<Object> result = new ArrayList<Object>();
+               if (fTree != null) {
+                       ISelection selection = fTree.getSelection();
+                       if (selection instanceof IStructuredSelection) {
+                               @SuppressWarnings("unchecked")
+                               Iterator<Object> iter = ((IStructuredSelection) selection).iterator();
+                               while (iter.hasNext()) {
+                                       result.add(iter.next());
+                               }
+                       }
+               }
+               return result;
+       }
+
+       public void expandElement(Object element, int level) {
+               if (fTree != null) {
+                       fTree.expandToLevel(element, level);
+               }
+       }
+
+       // ------- TreeViewerAdapter
+
+       private class TreeViewerAdapter implements ITreeContentProvider, ISelectionChangedListener, IDoubleClickListener {
+               private final Object[] NO_ELEMENTS = new Object[0];
+
+               // ------- ITreeContentProvider Interface ------------
+
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+                       // will never happen
+               }
+
+               public void dispose() {
+               }
+
+               public Object[] getElements(Object obj) {
+                       return fElements.toArray();
+               }
+
+               public Object[] getChildren(Object element) {
+                       if (fTreeAdapter != null) {
+                               return fTreeAdapter.getChildren(TreeListDialogField.this, element);
+                       }
+                       return NO_ELEMENTS;
+               }
+
+               public Object getParent(Object element) {
+                       if (!fElements.contains(element) && fTreeAdapter != null) {
+                               return fTreeAdapter.getParent(TreeListDialogField.this, element);
+                       }
+                       return fParentElement;
+               }
+
+               public boolean hasChildren(Object element) {
+                       if (fTreeAdapter != null) {
+                               return fTreeAdapter.hasChildren(TreeListDialogField.this, element);
+                       }
+                       return false;
+               }
+
+               // ------- ISelectionChangedListener Interface ------------
+
+               public void selectionChanged(SelectionChangedEvent event) {
+                       doListSelected(event);
+               }
+
+               /*
+                * (non-Javadoc)
+                * 
+                * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
+                */
+               public void doubleClick(DoubleClickEvent event) {
+                       doDoubleClick(event);
+               }
+       }
+
+       protected void doListSelected(SelectionChangedEvent event) {
+               updateButtonState();
+               if (fTreeAdapter != null) {
+                       fTreeAdapter.selectionChanged(this);
+               }
+       }
+
+       protected void doDoubleClick(DoubleClickEvent event) {
+               if (fTreeAdapter != null) {
+                       fTreeAdapter.doubleClicked(this);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizard.java
new file mode 100644 (file)
index 0000000..256a920
--- /dev/null
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+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.AbstractFileCreationWizard_title); 
+    }
+    
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.cdt.internal.ui.wizards.NewElementWizard#canRunForked()
+     */
+    @Override
+       protected boolean canRunForked() {
+       return true;
+    }
+    
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.eclipse.cdt.internal.ui.wizards.NewElementWizard#finishPage(org.eclipse.core.runtime.IProgressMonitor)
+     */
+    @Override
+       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()
+     */
+    @Override
+       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/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizardPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/AbstractFileCreationWizardPage.java
new file mode 100644 (file)
index 0000000..fdc4137
--- /dev/null
@@ -0,0 +1,730 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     IBM Corporation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.filewizard;
+
+import java.util.HashMap;
+import java.util.Map;
+
+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.preference.PreferenceDialog;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.templates.Template;
+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.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+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.dialogs.PreferencesUtil;
+import org.eclipse.ui.views.contentoutline.ContentOutline;
+
+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.ui.CUIPlugin;
+import org.eclipse.cdt.utils.PathUtil;
+
+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.preferences.CodeTemplatePreferencePage;
+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.ComboDialogField;
+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;
+
+public abstract class AbstractFileCreationWizardPage extends NewElementWizardPage {
+
+       private static final int MAX_FIELD_CHARS = 50;
+       private static final String NO_TEMPLATE = ""; //$NON-NLS-1$
+       
+       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;
+       int fLastFocusedField = 0;
+       private StringButtonDialogField fSourceFolderDialogField;
+       private IStatus fSourceFolderStatus;
+       private IStatus fNewFileStatus;
+       private final IStatus STATUS_OK = new StatusInfo();
+       
+       /**
+     * This flag isFirstTime is used to keep a note
+     * that the file creation wizard has just been 
+     * created.
+     */
+    private boolean isFirstTime = true;
+
+       private Template[] fTemplates;
+
+       private ComboDialogField fTemplateDialogField;
+       
+       public AbstractFileCreationWizardPage(String name) {
+               super(name);
+
+               setDescription(NewFileWizardMessages.AbstractFileCreationWizardPage_description); 
+               
+               fWorkspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+               
+               SourceFolderFieldAdapter sourceFolderAdapter = new SourceFolderFieldAdapter();
+               fSourceFolderDialogField = new StringButtonDialogField(sourceFolderAdapter);
+               fSourceFolderDialogField.setDialogFieldListener(sourceFolderAdapter);
+               fSourceFolderDialogField.setLabelText(NewFileWizardMessages.AbstractFileCreationWizardPage_sourceFolder_label); 
+               fSourceFolderDialogField.setButtonLabel(NewFileWizardMessages.AbstractFileCreationWizardPage_sourceFolder_button); 
+
+               fTemplates= getApplicableTemplates();
+               if (fTemplates != null && fTemplates.length > 0) {
+                       fTemplateDialogField= new ComboDialogField(SWT.READ_ONLY);
+                       fTemplateDialogField.setLabelText(NewFileWizardMessages.AbstractFileCreationWizardPage_template_label);
+               }
+
+               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 - 1);
+        // Placeholder for the right column.
+        (new Composite(composite, SWT.NO_FOCUS)).setLayoutData(new GridData(1, 1));
+
+        createTemplateControls(composite, nColumns);
+
+               composite.layout();
+
+               setErrorMessage(null);
+               setMessage(null);
+               setControl(composite);
+    }
+       
+       /**
+        * Creates a separator line. Expects a <code>GridLayout</code> 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 <code>GridLayout</code> 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 <code>GridLayout</code> with at 
+        * least 2 columns.
+        * 
+        * @param parent the parent composite
+        * @param nColumns number of columns to span
+        */             
+       protected abstract void createFileControls(Composite parent, int nColumns);
+
+       /**
+        * Creates the controls for the file template field. Expects a <code>GridLayout</code> with at 
+        * least 3 columns.
+        * 
+        * @param parent the parent composite
+        * @param columns number of columns to span
+        */             
+       protected void createTemplateControls(Composite parent, int columns) {
+               if (fTemplateDialogField != null) {
+                       fTemplateDialogField.doFillIntoGrid(parent, columns - 1);
+                       Button configureButton= new Button(parent, SWT.PUSH);
+                       configureButton.setText(NewFileWizardMessages.AbstractFileCreationWizardPage_configure_label);
+                       configureButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+                       configureButton.addSelectionListener(new SelectionAdapter() {
+                               @Override
+                               public void widgetSelected(SelectionEvent e) {
+                                       editTemplates();
+                               }
+                       });
+                       Combo comboControl= fTemplateDialogField.getComboControl(null);
+                       LayoutUtil.setWidthHint(comboControl, getMaxFieldWidth());
+               }
+       }
+
+       protected void editTemplates() {
+               String prefPageId= CodeTemplatePreferencePage.PREF_ID;
+               Map<String, String> data= null;
+               String templateName= null;
+               Template template= getSelectedTemplate();
+               if (template != null) {
+                       templateName= template.getName();
+               }
+               if (templateName != null) {
+                       data= new HashMap<String, String>();
+                       data.put(CodeTemplatePreferencePage.DATA_SELECT_TEMPLATE, templateName);
+               }
+               PreferenceDialog dialog= PreferencesUtil.createPreferenceDialogOn(getShell(), prefPageId, new String[] { prefPageId }, data);
+               if (dialog.open() == Window.OK) {
+                       updateTemplates();
+               }
+       }
+
+       protected void updateTemplates() {
+               if (fTemplateDialogField != null) {
+                       Template selected= getSelectedTemplate();
+                       String name = selected != null ?
+                                       selected.getName() :
+                                       getDefaultTemplateName();
+                       fTemplates= getApplicableTemplates();
+                       int idx= NO_TEMPLATE.equals(name) ? 0 : 1;
+                       String[] names= new String[fTemplates.length + 1];
+                       for (int i = 0; i < fTemplates.length; i++) {
+                               names[i + 1]= fTemplates[i].getName();
+                               if (name != null && name.equals(names[i + 1])) {
+                                       idx= i + 1;
+                               }
+                       }
+                       names[0]= NewFileWizardMessages.AbstractFileCreationWizardPage_noTemplate;
+                       fTemplateDialogField.setItems(names);
+                       fTemplateDialogField.selectItem(idx);
+               }
+       }
+
+       /**
+     * Configure the set of templates to select from.
+        * @return the set of templates
+        */
+       protected abstract Template[] getApplicableTemplates();
+
+       /**
+        * Returns the selected template and saves its name for future use.
+        *  
+        * @return the selected template or <code>null</code> if none.
+        */
+       protected Template getTemplate() {
+               Template template = getSelectedTemplate();
+               saveLastUsedTemplateName(template != null ? template.getName() : NO_TEMPLATE);
+               return template;
+       }
+
+       private Template getSelectedTemplate() {
+               if (fTemplateDialogField != null) {
+                       int index= fTemplateDialogField.getSelectionIndex() - 1;
+                       if (index >= 0 && index < fTemplates.length) {
+                               return fTemplates[index];
+                       }
+               }
+               return null;
+       }
+       
+    /**
+     * 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 <code>null</code>,
+     * 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) {
+                                               celem = (ICElement) resource.getAdapter(ICElement.class);
+                                               resource = resource.getParent();
+                                       }
+                                       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.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 <code>
+     * null</code> if no selection was available
+     */
+    protected void initFields(ICElement elem) {
+           initSourceFolder(elem);
+           updateTemplates();
+       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.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. <code>null</code> 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 <code>null</code>.
+     *
+     * @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;
+            if (isFirstTime) {
+               isFirstTime = false;
+               return;
+            }
+               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) {
+                               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.AbstractFileCreationWizardPage_error_EnterSourceFolderName); 
+                       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(NLS.bind(NewFileWizardMessages.AbstractFileCreationWizardPage_error_NotAFolder, folderPath)); 
+                                       return status;
+                               }
+                           if (!CoreModel.hasCCNature(proj) && !CoreModel.hasCNature(proj)) {
+                                       if (resType == IResource.PROJECT) {
+                                               status.setError(NewFileWizardMessages.AbstractFileCreationWizardPage_warning_NotACProject); 
+                                               return status;
+                                       }
+                                       status.setWarning(NewFileWizardMessages.AbstractFileCreationWizardPage_warning_NotInACProject); 
+                               }
+                           ICElement e = CoreModel.getDefault().create(res.getFullPath());
+                           if (CModelUtil.getSourceFolder(e) == null) {
+                                       status.setError(NLS.bind(NewFileWizardMessages.AbstractFileCreationWizardPage_error_NotASourceFolder, folderPath)); 
+                                       return status;
+                               }
+                       } else {
+                               status.setError(NLS.bind(NewFileWizardMessages.AbstractFileCreationWizardPage_error_NotAFolder, folderPath)); 
+                               return status;
+                       }
+               } else {
+                       status.setError(NLS.bind(NewFileWizardMessages.AbstractFileCreationWizardPage_error_FolderDoesNotExist, folderPath)); 
+                       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
+        */
+       @Override
+       public void setVisible(boolean visible) {
+               super.setVisible(visible);
+               if (visible) {
+                       setFocus();
+               }
+       }
+
+       /**
+        * Sets the focus on the starting input field.
+        */             
+       protected abstract void setFocus();
+                               
+       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.segmentCount() > 0) {
+                   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.
+        */
+       public abstract void createFile(IProgressMonitor monitor) throws CoreException;
+       
+       /**
+        * Returns the created file. The method only returns a valid translation unit 
+        * after <code>createFile</code> has been called.
+        * 
+        * @return the created translation unit
+        * @see #createFile(IProgressMonitor)
+        */                     
+       public abstract ITranslationUnit getCreatedFileTU();
+       
+       /**
+        * @return the name of the template used in the previous dialog invocation, or
+        * the name of the default template.
+        */
+       public abstract String getDefaultTemplateName();
+       
+       /**
+        * Saves the name of the last used template.
+        * 
+        * @param name the name of a template, or an empty string for no template.
+        */
+       public abstract void saveLastUsedTemplateName(String name);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileFromTemplateWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileFromTemplateWizard.java
new file mode 100644 (file)
index 0000000..2aa2508
--- /dev/null
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.filewizard;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+
+/**
+ * A generic new file wizard with support for file templates.
+ * Based on {@link org.eclipse.ui.wizards.newresource.BasicNewFileResourceWizard BasicNewFileResourceWizard}.
+ *
+ * @since 5.0
+ */
+public class NewFileFromTemplateWizard extends BasicNewResourceWizard {
+    private WizardNewFileCreationPage mainPage;
+
+    /**
+     * Creates a wizard for creating a new file resource in the workspace.
+     */
+    public NewFileFromTemplateWizard() {
+        super();
+    }
+
+    /*
+     * Method declared on IWizard.
+     */
+    @Override
+       public void addPages() {
+        super.addPages();
+        mainPage = new WizardNewFileFromTemplateCreationPage("newFilePage1", getSelection());//$NON-NLS-1$
+        mainPage.setTitle(NewFileWizardMessages.NewFileFromTemplateWizard_pageTitle);
+        mainPage.setDescription(NewFileWizardMessages.NewFileFromTemplateWizard_description); 
+        addPage(mainPage);
+    }
+
+    /*
+     * Method declared on IWorkbenchWizard.
+     */
+    @Override
+       public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
+        super.init(workbench, currentSelection);
+        setWindowTitle(NewFileWizardMessages.NewFileFromTemplateWizard_shellTitle);
+        setNeedsProgressMonitor(true);
+    }
+
+    /*
+     * Method declared on BasicNewResourceWizard.
+     */
+    @Override
+       protected void initializeDefaultPageImageDescriptor() {
+       ImageDescriptor desc = CPluginImages.DESC_WIZBAN_NEW_FILE;
+          setDefaultPageImageDescriptor(desc);
+    }
+
+    /*
+     * Method declared on IWizard.
+     */
+    @Override
+       public boolean performFinish() {
+        IFile file = mainPage.createNewFile();
+        if (file == null) {
+                       return false;
+               }
+
+        selectAndReveal(file);
+
+        // Open editor on new file.
+        IWorkbenchWindow dw = getWorkbench().getActiveWorkbenchWindow();
+        try {
+            if (dw != null) {
+                IWorkbenchPage page = dw.getActivePage();
+                if (page != null) {
+                    IDE.openEditor(page, file, true);
+                }
+            }
+        } catch (PartInitException e) {
+            openError(getShell(), NewFileWizardMessages.NewFileFromTemplateWizard_errorMessage, e.getMessage(), e);
+        }
+
+        return true;
+    }
+
+    /**
+     * Open an error style dialog for PartInitException by
+     * including any extra information from the nested
+     * CoreException if present.
+     */
+    public static void openError(Shell parent, String title, String message,
+            PartInitException exception) {
+        // Check for a nested CoreException
+        CoreException nestedException = null;
+        IStatus status = exception.getStatus();
+        if (status != null && status.getException() instanceof CoreException) {
+                       nestedException = (CoreException) status.getException();
+               }
+
+        if (nestedException != null) {
+            // Open an error dialog and include the extra
+            // status information from the nested CoreException
+            ErrorDialog.openError(parent, title, message, nestedException
+                    .getStatus());
+        } else {
+            // Open a regular error dialog since there is no
+            // extra information to display
+            MessageDialog.openError(parent, title, message);
+        }
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileWizardMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileWizardMessages.java
new file mode 100644 (file)
index 0000000..b7a0ca9
--- /dev/null
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.filewizard;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class NewFileWizardMessages extends NLS {
+
+       private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.wizards.filewizard.NewFileWizardMessages";//$NON-NLS-1$
+
+       private NewFileWizardMessages() {
+               // Do not instantiate
+       }
+
+       public static String AbstractFileCreationWizard_title;
+       public static String AbstractFileCreationWizardPage_description;
+       public static String AbstractFileCreationWizardPage_sourceFolder_label;
+       public static String AbstractFileCreationWizardPage_sourceFolder_button;
+       public static String AbstractFileCreationWizardPage_error_EnterSourceFolderName;
+       public static String AbstractFileCreationWizardPage_error_NotAFolder;
+       public static String AbstractFileCreationWizardPage_error_NotASourceFolder;
+       public static String AbstractFileCreationWizardPage_error_FolderDoesNotExist;
+       public static String AbstractFileCreationWizardPage_template_label;
+       public static String AbstractFileCreationWizardPage_configure_label;
+       public static String AbstractFileCreationWizardPage_noTemplate;
+       public static String AbstractFileCreationWizardPage_warning_NotACProject;
+       public static String AbstractFileCreationWizardPage_warning_NotInACProject;
+       public static String NewHeaderFileCreationWizard_title;
+       public static String NewSourceFileCreationWizard_title;
+       public static String NewHeaderFileCreationWizardPage_title;
+       public static String NewHeaderFileCreationWizardPage_description;
+       public static String NewHeaderFileCreationWizardPage_headerFile_label;
+       public static String NewHeaderFileCreationWizardPage_error_EnterFileName;
+       public static String NewHeaderFileCreationWizardPage_error_FileNotInSourceFolder;
+       public static String NewHeaderFileCreationWizardPage_error_FileExists;
+       public static String NewHeaderFileCreationWizardPage_error_MatchingFolderExists;
+       public static String NewHeaderFileCreationWizardPage_error_MatchingResourceExists;
+       public static String NewHeaderFileCreationWizardPage_error_FolderDoesNotExist;
+       public static String NewHeaderFileCreationWizardPage_warning_FileNameDiscouraged;
+       public static String NewHeaderFileCreationWizardPage_error_InvalidFileName;
+       public static String NewSourceFileCreationWizardPage_title;
+       public static String NewSourceFileCreationWizardPage_description;
+       public static String NewSourceFileCreationWizardPage_sourceFile_label;
+       public static String NewSourceFileCreationWizardPage_error_EnterFileName;
+       public static String NewSourceFileCreationWizardPage_error_FileNotInSourceFolder;
+       public static String NewSourceFileCreationWizardPage_error_FileExists;
+       public static String NewSourceFileCreationWizardPage_error_MatchingFolderExists;
+       public static String NewSourceFileCreationWizardPage_error_MatchingResourceExists;
+       public static String NewSourceFileCreationWizardPage_error_FolderDoesNotExist;
+       public static String NewSourceFileCreationWizardPage_warning_FileNameDiscouraged;
+       public static String NewSourceFileCreationWizardPage_error_InvalidFileName;
+       public static String NewSourceFileGenerator_createFile_task;
+       public static String NewFileFromTemplateWizard_pageTitle;
+       public static String NewFileFromTemplateWizard_description;
+       public static String NewFileFromTemplateWizard_shellTitle;
+       public static String NewFileFromTemplateWizard_errorMessage;
+       public static String WizardNewFileFromTemplateCreationPage_configure_label;
+       public static String WizardNewFileFromTemplateCreationPage_noTemplate_name;
+       public static String WizardNewFileFromTemplateCreationPage_useTemplate_label;
+
+       static {
+               NLS.initializeMessages(BUNDLE_NAME, NewFileWizardMessages.class);
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileWizardMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewFileWizardMessages.properties
new file mode 100644 (file)
index 0000000..2a15865
--- /dev/null
@@ -0,0 +1,73 @@
+###############################################################################
+# Copyright (c) 2004, 2009 QNX Software Systems and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     QNX Software Systems - Initial API and implementation
+#     Anton Leherbauer (Wind River Systems)
+###############################################################################
+
+# ------- AbstractFileCreationWizard -------
+AbstractFileCreationWizard_title= New File
+
+# ----------- AbstractFileCreationWizardPage -------------
+AbstractFileCreationWizardPage_description=Creates a new file
+AbstractFileCreationWizardPage_sourceFolder_label=Source fol&der:
+AbstractFileCreationWizardPage_sourceFolder_button=&Browse...
+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_FolderDoesNotExist=Folder ''{0}'' does not exist.
+AbstractFileCreationWizardPage_template_label=&Template:
+AbstractFileCreationWizardPage_configure_label=Configure...
+AbstractFileCreationWizardPage_noTemplate=<None>
+AbstractFileCreationWizardPage_warning_NotACProject=Folder is not a C/C++ project.
+AbstractFileCreationWizardPage_warning_NotInACProject=Folder is not in a C/C++ project.
+
+# ------- NewHeaderFileCreationWizard -------
+NewHeaderFileCreationWizard_title= New Header File
+
+# ------- NewSourceFileCreationWizard -------
+NewSourceFileCreationWizard_title= New Source File
+
+# ----------- NewHeaderFileCreationWizardPage -------------
+NewHeaderFileCreationWizardPage_title= Header File
+NewHeaderFileCreationWizardPage_description= Create a new header file.
+NewHeaderFileCreationWizardPage_headerFile_label= Header fil&e:
+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_error_FolderDoesNotExist=Folder ''{0}'' does not exist.
+NewHeaderFileCreationWizardPage_warning_FileNameDiscouraged=File name is discouraged. {0}.
+NewHeaderFileCreationWizardPage_error_InvalidFileName=File name is not valid. {0}.
+
+# ----------- NewSourceFileCreationWizardPage -------------
+NewSourceFileCreationWizardPage_title= Source File
+NewSourceFileCreationWizardPage_description= Create a new source file.
+NewSourceFileCreationWizardPage_sourceFile_label= Source fil&e:
+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_error_FolderDoesNotExist=Folder ''{0}'' does not exist.
+NewSourceFileCreationWizardPage_warning_FileNameDiscouraged=File name is discouraged. {0}.
+NewSourceFileCreationWizardPage_error_InvalidFileName=File name is not valid. {0}.
+
+# ----------- NewSourceFileGenerator -------------
+NewSourceFileGenerator_createFile_task= Creating
+
+# ----- NewFileFromTemplateWizard ------
+NewFileFromTemplateWizard_pageTitle= File
+NewFileFromTemplateWizard_description=Create a new file resource from a template.
+NewFileFromTemplateWizard_shellTitle= New File
+NewFileFromTemplateWizard_errorMessage= Problems Opening Editor
+
+WizardNewFileFromTemplateCreationPage_configure_label=Configure...
+WizardNewFileFromTemplateCreationPage_noTemplate_name=<None>
+WizardNewFileFromTemplateCreationPage_useTemplate_label=Use template:
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewHeaderFileCreationWizardPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewHeaderFileCreationWizardPage.java
new file mode 100644 (file)
index 0000000..4830890
--- /dev/null
@@ -0,0 +1,220 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Sergey Prigogin (Google)
+******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.filewizard;
+
+import org.eclipse.cdt.core.CConventions;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CodeGeneration;
+
+import org.eclipse.cdt.internal.core.model.CProject;
+import org.eclipse.cdt.internal.corext.codemanipulation.StubUtility;
+
+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.resources.IProject;
+import org.eclipse.core.resources.IResource;
+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.jface.text.templates.Template;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+public class NewHeaderFileCreationWizardPage extends AbstractFileCreationWizardPage {
+       private final String KEY_LAST_USED_TEMPLATE = "LastUsedHeaderTemplate"; //$NON-NLS-1$
+
+       private ITranslationUnit fNewFileTU = null;
+       private StringDialogField fNewFileDialogField;
+       
+       public NewHeaderFileCreationWizardPage() {
+               super(NewFileWizardMessages.NewHeaderFileCreationWizard_title);
+               setTitle(NewFileWizardMessages.NewHeaderFileCreationWizardPage_title);
+               setDescription(NewFileWizardMessages.NewHeaderFileCreationWizardPage_description); 
+
+               fNewFileDialogField = new StringDialogField();
+               fNewFileDialogField.setDialogFieldListener(new IDialogFieldListener() {
+                       public void dialogFieldChanged(DialogField field) {
+                               handleFieldChanged(NEW_FILE_ID);
+                       }
+               });
+               fNewFileDialogField.setLabelText(NewFileWizardMessages.NewHeaderFileCreationWizardPage_headerFile_label); 
+       }
+       
+       /**
+        * Sets the focus on the starting input field.
+        */             
+       @Override
+       protected void setFocus() {
+               fNewFileDialogField.setFocus();
+       }
+
+       /**
+        * Creates the controls for the file name field. Expects a <code>GridLayout</code> with at 
+        * least 2 columns.
+        * 
+        * @param parent the parent composite
+        * @param nColumns number of columns to span
+        */             
+       @Override
+       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));
+       }
+       
+       @Override
+       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;
+       }
+
+       @Override
+       protected IStatus fileNameChanged() {
+               StatusInfo status = new StatusInfo();
+               
+               IPath filePath = getFileFullPath();
+               if (filePath == null) {
+                       status.setError(NewFileWizardMessages.NewHeaderFileCreationWizardPage_error_EnterFileName); 
+                       return status;
+               }
+
+               IPath sourceFolderPath = getSourceFolderFullPath();
+               if (sourceFolderPath == null || !sourceFolderPath.isPrefixOf(filePath)) {
+                       status.setError(NewFileWizardMessages.NewHeaderFileCreationWizardPage_error_FileNotInSourceFolder); 
+                       return status;
+               }
+               
+               // check if file already exists
+               IResource file = getWorkspaceRoot().findMember(filePath);
+               if (file != null && file.exists()) {
+               if (file.getType() == IResource.FILE) {
+                       status.setError(NewFileWizardMessages.NewHeaderFileCreationWizardPage_error_FileExists); 
+               } else if (file.getType() == IResource.FOLDER) {
+                       status.setError(NewFileWizardMessages.NewHeaderFileCreationWizardPage_error_MatchingFolderExists); 
+               } else {
+                       status.setError(NewFileWizardMessages.NewHeaderFileCreationWizardPage_error_MatchingResourceExists); 
+               }
+                       return status;
+               }
+               
+               // check if folder exists
+               IPath folderPath = filePath.removeLastSegments(1).makeRelative();
+               IResource folder = getWorkspaceRoot().findMember(folderPath);
+               if (folder == null || !folder.exists() || (folder.getType() != IResource.PROJECT && folder.getType() != IResource.FOLDER)) {
+                   status.setError(NLS.bind(NewFileWizardMessages.NewHeaderFileCreationWizardPage_error_FolderDoesNotExist, folderPath)); 
+                       return status;
+               }
+
+               IStatus convStatus = CConventions.validateHeaderFileName(getCurrentProject(), filePath.lastSegment());
+               if (convStatus.getSeverity() == IStatus.ERROR) {
+                       status.setError(NLS.bind(NewFileWizardMessages.NewHeaderFileCreationWizardPage_error_InvalidFileName, convStatus.getMessage())); 
+                       return status;
+               } else if (convStatus.getSeverity() == IStatus.WARNING) {
+                       status.setWarning(NLS.bind(NewFileWizardMessages.NewHeaderFileCreationWizardPage_warning_FileNameDiscouraged, convStatus.getMessage())); 
+               }
+               return status;
+       }
+       
+       @Override
+       public void createFile(IProgressMonitor monitor) throws CoreException {
+        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);
+                       if (fNewFileTU != null) {
+                               String lineDelimiter= StubUtility.getLineDelimiterUsed(fNewFileTU);
+                                               String content= CodeGeneration.getHeaderFileContent(getTemplate(),
+                                                               fNewFileTU, lineDelimiter);
+                                               if (content != null) {
+                                                       fNewFileTU.getBuffer().setContents(content.toCharArray());
+                                                       fNewFileTU.save(monitor, true);
+                                               }
+                       }
+                   }
+               } finally {
+                   monitor.done();
+               }
+        }
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.wizards.filewizard.AbstractFileCreationWizardPage#getCreatedFileTU()
+        */
+       @Override
+       public ITranslationUnit getCreatedFileTU() {
+               return fNewFileTU;
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.wizards.filewizard.AbstractFileCreationWizardPage#getApplicableTemplates()
+        */
+       @Override
+       protected Template[] getApplicableTemplates() {
+               return StubUtility.getFileTemplatesForContentTypes(
+                               new String[] { CCorePlugin.CONTENT_TYPE_CXXHEADER, CCorePlugin.CONTENT_TYPE_CHEADER }, null);
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.wizards.filewizard.AbstractFileCreationWizardPage#getDefaultTemplateName()
+        */
+       @Override
+       public String getDefaultTemplateName() {
+               String name = getDialogSettings().get(KEY_LAST_USED_TEMPLATE);
+               if (name == null) {
+                       IProject project = getCurrentProject();
+                       if (project != null) {
+                               String contentType = CProject.hasCCNature(project) ?
+                                               CCorePlugin.CONTENT_TYPE_CXXHEADER : CCorePlugin.CONTENT_TYPE_CHEADER;
+                               Template[] templates =
+                                               StubUtility.getFileTemplatesForContentTypes(new String[] { contentType }, null);
+                               if (templates.length != 0) {
+                                       name = templates[0].getName();
+                               }
+                       }
+               }
+               return name;
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.wizards.filewizard.AbstractFileCreationWizardPage#savePreferredTemplateName(String)
+        */
+       @Override
+       public void saveLastUsedTemplateName(String name) {
+               getDialogSettings().put(KEY_LAST_USED_TEMPLATE, name);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileCreationWizardPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileCreationWizardPage.java
new file mode 100644 (file)
index 0000000..2e78e6a
--- /dev/null
@@ -0,0 +1,224 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *     IBM Corporation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.filewizard;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+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.jface.text.templates.Template;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.core.CConventions;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CodeGeneration;
+
+import org.eclipse.cdt.internal.core.model.CProject;
+import org.eclipse.cdt.internal.corext.codemanipulation.StubUtility;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+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;
+
+public class NewSourceFileCreationWizardPage extends AbstractFileCreationWizardPage {
+       private final String KEY_LAST_USED_TEMPLATE = "LastUsedSourceTemplate"; //$NON-NLS-1$
+
+       private ITranslationUnit fNewFileTU = null;
+       private StringDialogField fNewFileDialogField;
+       
+       public NewSourceFileCreationWizardPage() {
+               super(NewFileWizardMessages.NewSourceFileCreationWizard_title);
+               setTitle(NewFileWizardMessages.NewSourceFileCreationWizardPage_title);
+               setDescription(NewFileWizardMessages.NewSourceFileCreationWizardPage_description); 
+
+               fNewFileDialogField = new StringDialogField();
+               fNewFileDialogField.setDialogFieldListener(new IDialogFieldListener() {
+                       public void dialogFieldChanged(DialogField field) {
+                               handleFieldChanged(NEW_FILE_ID);
+                       }
+               });
+               fNewFileDialogField.setLabelText(NewFileWizardMessages.NewSourceFileCreationWizardPage_sourceFile_label); 
+       }
+       
+       /**
+        * Sets the focus on the starting input field.
+        */
+       @Override
+       protected void setFocus() {
+               fNewFileDialogField.setFocus();
+       }
+
+       /**
+        * Creates the controls for the file name field. Expects a <code>GridLayout</code> with at 
+        * least 2 columns.
+        * 
+        * @param parent the parent composite
+        * @param nColumns number of columns to span
+        */             
+       @Override
+       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));
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(parent.getParent(), ICHelpContextIds.NEW_C_FILE_WIZARD_PAGE);
+       }
+       
+       @Override
+       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;
+       }
+       
+       @Override
+       protected IStatus fileNameChanged() {
+               StatusInfo status = new StatusInfo();
+               
+               IPath filePath = getFileFullPath();
+               if (filePath == null) {
+                       status.setError(NewFileWizardMessages.NewSourceFileCreationWizardPage_error_EnterFileName); 
+                       return status;
+               }
+
+               IPath sourceFolderPath = getSourceFolderFullPath();
+               if (sourceFolderPath == null || !sourceFolderPath.isPrefixOf(filePath)) {
+                       status.setError(NewFileWizardMessages.NewSourceFileCreationWizardPage_error_FileNotInSourceFolder); 
+                       return status;
+               }
+               
+               // check if file already exists
+               IResource file = getWorkspaceRoot().findMember(filePath);
+               if (file != null && file.exists()) {
+               if (file.getType() == IResource.FILE) {
+                       status.setError(NewFileWizardMessages.NewSourceFileCreationWizardPage_error_FileExists); 
+               } else if (file.getType() == IResource.FOLDER) {
+                       status.setError(NewFileWizardMessages.NewSourceFileCreationWizardPage_error_MatchingFolderExists); 
+               } else {
+                       status.setError(NewFileWizardMessages.NewSourceFileCreationWizardPage_error_MatchingResourceExists); 
+               }
+                       return status;
+               }
+               
+               // check if folder exists
+               IPath folderPath = filePath.removeLastSegments(1).makeRelative();
+               IResource folder = getWorkspaceRoot().findMember(folderPath);
+               if (folder == null || !folder.exists() || (folder.getType() != IResource.PROJECT && folder.getType() != IResource.FOLDER)) {
+                   status.setError(NLS.bind(NewFileWizardMessages.NewSourceFileCreationWizardPage_error_FolderDoesNotExist, folderPath)); 
+                       return status;
+               }
+
+               IStatus convStatus = CConventions.validateSourceFileName(getCurrentProject(), filePath.lastSegment());
+               if (convStatus.getSeverity() == IStatus.ERROR) {
+                       status.setError(NLS.bind(NewFileWizardMessages.NewSourceFileCreationWizardPage_error_InvalidFileName, convStatus.getMessage())); 
+                       return status;
+               } else if (convStatus.getSeverity() == IStatus.WARNING) {
+                       status.setWarning(NLS.bind(NewFileWizardMessages.NewSourceFileCreationWizardPage_warning_FileNameDiscouraged, convStatus.getMessage())); 
+               }
+               return status;
+       }
+       
+       @Override
+       public void createFile(IProgressMonitor monitor) throws CoreException {
+        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);
+                       if (fNewFileTU != null) {
+                               String lineDelimiter= StubUtility.getLineDelimiterUsed(fNewFileTU);
+                                               String content= CodeGeneration.getBodyFileContent(getTemplate(), fNewFileTU, null, null, lineDelimiter);
+                                               if (content != null) {
+                                                       fNewFileTU.getBuffer().setContents(content.toCharArray());
+                                                       fNewFileTU.save(monitor, true);
+                                               }
+                       }
+                   }
+               } finally {
+                   monitor.done();
+               }
+        }
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.wizards.filewizard.AbstractFileCreationWizardPage#getCreatedFileTU()
+        */
+       @Override
+       public ITranslationUnit getCreatedFileTU() {
+               return fNewFileTU;
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.wizards.filewizard.AbstractFileCreationWizardPage#getApplicableTemplates()
+        */
+       @Override
+       protected Template[] getApplicableTemplates() {
+               return StubUtility.getFileTemplatesForContentTypes(
+                               new String[] { CCorePlugin.CONTENT_TYPE_CXXSOURCE, CCorePlugin.CONTENT_TYPE_CSOURCE }, null);
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.wizards.filewizard.AbstractFileCreationWizardPage#getDefaultTemplateName()
+        */
+       @Override
+       public String getDefaultTemplateName() {
+               String name = getDialogSettings().get(KEY_LAST_USED_TEMPLATE);
+               if (name == null) {
+                       IProject project = getCurrentProject();
+                       if (project != null) {
+                               String contentType = CProject.hasCCNature(project) ?
+                                               CCorePlugin.CONTENT_TYPE_CXXSOURCE : CCorePlugin.CONTENT_TYPE_CSOURCE;
+                               Template[] templates =
+                                               StubUtility.getFileTemplatesForContentTypes(new String[] { contentType }, null);
+                               if (templates.length != 0) {
+                                       name = templates[0].getName();
+                               }
+                       }
+               }
+               return name;
+       }
+       
+       /*
+        * @see org.eclipse.cdt.internal.ui.wizards.filewizard.AbstractFileCreationWizardPage#savePreferredTemplateName(String)
+        */
+       @Override
+       public void saveLastUsedTemplateName(String name) {
+               getDialogSettings().put(KEY_LAST_USED_TEMPLATE, name);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileGenerator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/NewSourceFileGenerator.java
new file mode 100644 (file)
index 0000000..5e9c6a3
--- /dev/null
@@ -0,0 +1,174 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2011 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.filewizard;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+import org.eclipse.cdt.internal.ui.util.NameComposer;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceStatus;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.runtime.preferences.IPreferencesService;
+import org.eclipse.ui.dialogs.ContainerGenerator;
+
+public class NewSourceFileGenerator {
+    /**
+     * Creates a header file name from the given class name. This is the file name
+     * to be used when the class is created. eg. "MyClass" -> "MyClass.h"
+     * 
+     * @param className the class name
+     * @return the header file name for the given class
+     */
+    public static String generateHeaderFileNameFromClass(String className) {
+       IPreferencesService preferences = Platform.getPreferencesService();
+       int capitalization = preferences.getInt(CUIPlugin.PLUGIN_ID,
+                       PreferenceConstants.NAME_STYLE_CPP_HEADER_CAPITALIZATION,
+                       PreferenceConstants.NAME_STYLE_CAPITALIZATION_ORIGINAL, null);
+       String wordDelimiter = preferences.getString(CUIPlugin.PLUGIN_ID,
+                       PreferenceConstants.NAME_STYLE_CPP_HEADER_WORD_DELIMITER, "", null); //$NON-NLS-1$
+       String prefix = preferences.getString(CUIPlugin.PLUGIN_ID,
+                       PreferenceConstants.NAME_STYLE_CPP_HEADER_PREFIX, "", null); //$NON-NLS-1$
+       String suffix = preferences.getString(CUIPlugin.PLUGIN_ID,
+                       PreferenceConstants.NAME_STYLE_CPP_HEADER_SUFFIX, ".h", null); //$NON-NLS-1$
+       NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
+       return composer.compose(className);
+    }
+
+    /**
+     * Creates a source file name from the given class name. This is the file name
+     * to be used when the class is created. e.g. "MyClass" -> "MyClass.cpp"
+     * 
+     * @param className the class name
+     * @return the source file name for the given class
+     */
+    public static String generateSourceFileNameFromClass(String className) {
+       IPreferencesService preferences = Platform.getPreferencesService();
+       int capitalization = preferences.getInt(CUIPlugin.PLUGIN_ID,
+                       PreferenceConstants.NAME_STYLE_CPP_SOURCE_CAPITALIZATION,
+                       PreferenceConstants.NAME_STYLE_CAPITALIZATION_ORIGINAL, null);
+       String wordDelimiter = preferences.getString(CUIPlugin.PLUGIN_ID,
+                       PreferenceConstants.NAME_STYLE_CPP_SOURCE_WORD_DELIMITER, "", null); //$NON-NLS-1$
+       String prefix = preferences.getString(CUIPlugin.PLUGIN_ID,
+                       PreferenceConstants.NAME_STYLE_CPP_SOURCE_PREFIX, "", null); //$NON-NLS-1$
+       String suffix = preferences.getString(CUIPlugin.PLUGIN_ID,
+                       PreferenceConstants.NAME_STYLE_CPP_SOURCE_SUFFIX, ".cpp", null); //$NON-NLS-1$
+       NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
+       return composer.compose(className);
+    }
+
+    /**
+     * Creates a file name for the unit test from the given class name. This is the file name
+     * to be used when the test is created. e.g. "MyClass" -> "MyClass_test.cpp"
+     * 
+     * @param className the class name
+     * @return the test file name for the given class
+     */
+    public static String generateTestFileNameFromClass(String className) {
+       IPreferencesService preferences = Platform.getPreferencesService();
+       int capitalization = preferences.getInt(CUIPlugin.PLUGIN_ID,
+                       PreferenceConstants.NAME_STYLE_CPP_TEST_CAPITALIZATION,
+                       PreferenceConstants.NAME_STYLE_CAPITALIZATION_ORIGINAL, null);
+       String wordDelimiter = preferences.getString(CUIPlugin.PLUGIN_ID,
+                       PreferenceConstants.NAME_STYLE_CPP_TEST_WORD_DELIMITER, "", null); //$NON-NLS-1$
+       String prefix = preferences.getString(CUIPlugin.PLUGIN_ID,
+                       PreferenceConstants.NAME_STYLE_CPP_TEST_PREFIX, "", null); //$NON-NLS-1$
+       String suffix = preferences.getString(CUIPlugin.PLUGIN_ID,
+                       PreferenceConstants.NAME_STYLE_CPP_TEST_SUFFIX, "_test.cpp", null); //$NON-NLS-1$
+       NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix);
+       return composer.compose(className);
+    }
+
+    public static IFile createHeaderFile(IPath filePath, boolean force, IProgressMonitor monitor)
+               throws CoreException {
+               return createEmptyFile(filePath, force, monitor);
+    }
+    
+    public static IFile createSourceFile(IPath filePath, boolean force, IProgressMonitor monitor)
+               throws CoreException {
+               return createEmptyFile(filePath, force, monitor);
+    }
+
+    public static IFile createTestFile(IPath filePath, boolean force, IProgressMonitor monitor)
+               throws CoreException {
+               return createEmptyFile(filePath, force, monitor);
+    }
+
+    public static IFile createEmptyFile(IPath filePath, boolean force, IProgressMonitor monitor)
+               throws CoreException {
+        ByteArrayInputStream stream = new ByteArrayInputStream(new byte[0]);
+               return createNewFile(filePath, stream, force, monitor);
+    }
+
+    private static IFile createNewFile(IPath newFilePath, InputStream contents, boolean force,
+               IProgressMonitor monitor) throws CoreException {
+        int totalWork = 100;
+        int createFileWork = totalWork;
+
+        monitor.beginTask(NewFileWizardMessages.NewSourceFileGenerator_createFile_task, totalWork); 
+
+        IWorkspaceRoot root = CUIPlugin.getWorkspace().getRoot();
+        IFile newFile = root.getFileForLocation(newFilePath);
+        if (newFile == null)
+            newFile = root.getFile(newFilePath);
+        if (newFile.exists()) {
+            monitor.done();
+            return newFile;
+        }
+
+        if (newFilePath.segmentCount() > 1) {
+               IPath containerPath = newFilePath.removeLastSegments(1);
+               if (root.getContainerForLocation(containerPath) == null) {
+                   int containerWork = totalWork / 2;
+                   createFileWork = totalWork / 2;
+                   ContainerGenerator generator = new ContainerGenerator(containerPath);
+                   generator.generateContainer(new SubProgressMonitor(monitor, containerWork));
+               }
+        }
+
+        createFile(newFile, contents, force, new SubProgressMonitor(monitor, createFileWork));
+        monitor.done();
+
+        return newFile;
+    }
+
+    private static void createFile(IFile fileHandle, InputStream contents, boolean force,
+               IProgressMonitor monitor) throws CoreException {
+        if (contents == null)
+            contents = new ByteArrayInputStream(new byte[0]);
+
+        try {
+            fileHandle.create(contents, force, monitor);
+        } catch (CoreException e) {
+            // If the file already existed locally, just refresh to get contents
+            if (e.getStatus().getCode() == IResourceStatus.PATH_OCCUPIED)
+                fileHandle.refreshLocal(IResource.DEPTH_ZERO, null);
+            else
+                throw e;
+        }
+
+        if (monitor.isCanceled())
+            throw new OperationCanceledException();
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/WizardNewFileFromTemplateCreationPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/filewizard/WizardNewFileFromTemplateCreationPage.java
new file mode 100644 (file)
index 0000000..9e7d17e
--- /dev/null
@@ -0,0 +1,277 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.wizards.filewizard;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.core.runtime.content.IContentTypeManager;
+import org.eclipse.core.runtime.content.IContentTypeMatcher;
+import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.jface.text.templates.Template;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+
+import org.eclipse.cdt.internal.corext.codemanipulation.StubUtility;
+import org.eclipse.cdt.internal.corext.template.c.FileTemplateContextType;
+
+import org.eclipse.cdt.internal.ui.preferences.CodeTemplatePreferencePage;
+
+/**
+ * A new file creation wizard page with support for templates.
+ *
+ * @since 5.0
+ */
+public class WizardNewFileFromTemplateCreationPage extends WizardNewFileCreationPage {
+
+       private Combo fTemplatesCombo;
+       private Template[] fTemplates;
+       protected boolean fUseTemplate= true;
+
+       /**
+        * Create a new 'file from template' page.
+        * 
+        * @param pageName
+        * @param selection
+        */
+       public WizardNewFileFromTemplateCreationPage(String pageName, IStructuredSelection selection) {
+               super(pageName, selection);
+       }
+
+       /*
+        * @see org.eclipse.ui.dialogs.WizardNewFileCreationPage#createAdvancedControls(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected void createAdvancedControls(Composite parent) {
+               Composite groupComposite= new Composite(parent,SWT.NONE);
+               groupComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+               GridLayout layout= new GridLayout();
+               layout.numColumns= 3;
+               groupComposite.setLayout(layout);
+
+               final Button useTemplateButton= new Button(groupComposite, SWT.CHECK);
+
+               useTemplateButton.setText(NewFileWizardMessages.WizardNewFileFromTemplateCreationPage_useTemplate_label);
+               useTemplateButton.setSelection(fUseTemplate);
+               SelectionListener useTemplateListener= new SelectionAdapter() {
+                               @Override
+                               public void widgetSelected(SelectionEvent e) {
+                                       fUseTemplate= useTemplateButton.getSelection();
+                                       fTemplatesCombo.setEnabled(fUseTemplate);
+                               }
+                       };
+               useTemplateButton.addSelectionListener(useTemplateListener);
+
+               fTemplatesCombo= new Combo(groupComposite, SWT.READ_ONLY);
+               fTemplatesCombo.setEnabled(fUseTemplate);
+               fTemplatesCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               
+               final Button configureButton= new Button(groupComposite, SWT.PUSH);
+               configureButton.setText(NewFileWizardMessages.WizardNewFileFromTemplateCreationPage_configure_label);
+
+               SelectionListener changeTemplateListener= new SelectionAdapter() {
+                               @Override
+                               public void widgetSelected(SelectionEvent e) {
+                                       editTemplates();
+                               }
+                       };
+               configureButton.addSelectionListener(changeTemplateListener);
+               updateTemplates();
+
+               super.createAdvancedControls(parent);
+       }
+
+       protected void editTemplates() {
+               String prefPageId= CodeTemplatePreferencePage.PREF_ID;
+               Map<String, String> data= null;
+               String templateName= null;
+               Template template= getSelectedTemplate();
+               if (template != null) {
+                       templateName= template.getName();
+               }
+               if (templateName != null) {
+                       data= new HashMap<String, String>();
+                       data.put(CodeTemplatePreferencePage.DATA_SELECT_TEMPLATE, templateName);
+               }
+               PreferenceDialog dialog= PreferencesUtil.createPreferenceDialogOn(getShell(), prefPageId, new String[] { prefPageId }, data);
+               if (dialog.open() == Window.OK) {
+                       updateTemplates();
+               }
+       }
+
+       /*
+        * @see org.eclipse.ui.dialogs.WizardNewFileCreationPage#getInitialContents()
+        */
+       @Override
+       protected InputStream getInitialContents() {
+               Template template= getSelectedTemplate();
+               if (fUseTemplate && template != null) {
+                       IFile fileHandle= createFileHandle(getContainerFullPath().append(getResourceName()));
+                       String lineDelimiter= StubUtility.getLineDelimiterPreference(getContainterProject());
+                       try {
+                               String content= StubUtility.getFileContent(template, fileHandle, lineDelimiter);
+                               if (content != null) {
+                                       try {
+                                               String charset= fileHandle.getParent().getDefaultCharset();
+                                               return new ByteArrayInputStream(content.getBytes(charset));
+                                       } catch (UnsupportedEncodingException exc) {
+                                               return new ByteArrayInputStream(content.getBytes());
+                                       }
+                               }
+                       } catch (CoreException exc) {
+                       }
+               }
+               return super.getInitialContents();
+       }
+
+       /*
+        * @see org.eclipse.ui.dialogs.WizardNewFileCreationPage#handleEvent(org.eclipse.swt.widgets.Event)
+        */
+       @Override
+       public void handleEvent(Event event) {
+               updateTemplates();
+               super.handleEvent(event);
+       }
+
+       protected void updateTemplates() {
+               Template selected= getSelectedTemplate();
+               boolean isDefaultSelected= (selected != null && fTemplates.length == 1) || (fTemplatesCombo != null && fTemplatesCombo.getSelectionIndex() == 0);
+               fTemplates= getApplicableTemplates();
+               int idx= 0;
+               String[] names= new String[fTemplates.length];
+               for (int i = 0; i < names.length; i++) {
+                       names[i]= fTemplates[i].getName();
+                       if (!isDefaultSelected && selected != null && selected.getName().equals(names[i])) {
+                               idx= i;
+                       }
+               }
+               if (fTemplatesCombo != null) {
+                       if (names.length == 0) {
+                               names= new String[] { NewFileWizardMessages.WizardNewFileFromTemplateCreationPage_noTemplate_name };
+                       }
+                       fTemplatesCombo.setItems(names);
+                       fTemplatesCombo.select(idx);
+               }
+       }
+
+       /**
+        * @return the selected template or <code>null</code> if none
+        */
+       protected Template getSelectedTemplate() {
+               if (fTemplates != null) {
+                       int index= 0;
+                       if (fTemplatesCombo != null) {
+                               index= fTemplatesCombo.getSelectionIndex();
+                               if (index < 0) {
+                                       index= 0;
+                               }
+                       }
+                       if (index < fTemplates.length) {
+                               return fTemplates[index];
+                       }
+               }
+               return null;
+       }
+
+       private String getResourceName() {
+               String fileName= getFileName();
+               String fileExtension= getFileExtension();
+               if (fileExtension != null && fileExtension.length() > 0 && !fileName.endsWith('.' + fileExtension)) {
+                       fileName += '.';
+                       fileName += fileExtension;
+               }
+               return fileName;
+       }
+
+       private IProject getContainterProject() {
+               IPath containerPath= getContainerFullPath();
+               if (containerPath != null) {
+                       return ResourcesPlugin.getWorkspace().getRoot().getProject(containerPath.segment(0));
+               }
+               return null;
+       }
+
+       /**
+     * Configure the set of selectable templates.
+        * @return the set of templates
+        */
+       protected Template[] getApplicableTemplates() {
+               IProject project= getContainterProject();
+               String fileName= getResourceName();
+               String[] contentTypes= getAllContentTypeIdsForFileName(project, fileName);
+               return StubUtility.getFileTemplatesForContentTypes(contentTypes, project);
+       }
+
+       private static String[] getAllContentTypeIdsForFileName(IProject project, String fileName) {
+               IContentTypeMatcher matcher;
+               if (project == null || !project.isAccessible()) {
+                       IContentTypeManager contentTypeMgr= Platform.getContentTypeManager();
+                       matcher= contentTypeMgr;
+               } else {
+                       try {
+                               matcher= project.getContentTypeMatcher();
+                       } catch (CoreException exc) {
+                               IContentTypeManager contentTypeMgr= Platform.getContentTypeManager();
+                               matcher= contentTypeMgr;
+                       }
+               }
+               IContentType[] contentTypes= matcher.findContentTypesFor(fileName);
+               List<String> result= new ArrayList<String>(contentTypes.length * 2);
+               for (int i = 0; i < contentTypes.length; i++) {
+                       IContentType contentType = contentTypes[i];
+                       String id= contentType.getId();
+                       result.add(id);
+               }
+               // add base types
+               for (int i = 0; i < contentTypes.length; i++) {
+                       IContentType contentType = contentTypes[i].getBaseType();
+                       while (contentType != null) {
+                               String id= contentType.getId();
+                               if (result.contains(id)) {
+                                       break;
+                               }
+                               result.add(id);
+                               contentType= contentType.getBaseType();
+                       }
+               }
+               if (result.isEmpty()) {
+                       result.add(FileTemplateContextType.CONTENTTYPE_TEXT);
+               }
+               return result.toArray(new String[result.size()]);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewFolderWizardMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewFolderWizardMessages.java
new file mode 100644 (file)
index 0000000..24ef3e2
--- /dev/null
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.folderwizard;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class NewFolderWizardMessages extends NLS {
+
+       private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.wizards.folderwizard.NewFolderWizardMessages";//$NON-NLS-1$
+
+       private NewFolderWizardMessages() {
+               // Do not instantiate
+       }
+
+       public static String NewSourceFolderCreationWizard_title;
+       public static String NewSourceFolderWizardPage_title;
+       public static String NewSourceFolderWizardPage_description;
+       public static String NewSourceFolderWizardPage_root_label;
+       public static String NewSourceFolderWizardPage_root_button;
+       public static String NewSourceFolderWizardPage_project_label;
+       public static String NewSourceFolderWizardPage_project_button;
+       public static String NewSourceFolderWizardPage_operation;
+       public static String NewSourceFolderWizardPage_exclude_label;
+       public static String NewSourceFolderWizardPage_ChooseExistingRootDialog_title;
+       public static String NewSourceFolderWizardPage_ChooseExistingRootDialog_description;
+       public static String NewSourceFolderWizardPage_ChooseProjectDialog_title;
+       public static String NewSourceFolderWizardPage_ChooseProjectDialog_description;
+       public static String NewSourceFolderWizardPage_error_EnterRootName;
+       public static String NewSourceFolderWizardPage_error_InvalidRootName;
+       public static String NewSourceFolderWizardPage_error_NotAFolder;
+       public static String NewSourceFolderWizardPage_error_AlreadyExisting;
+       public static String NewSourceFolderWizardPage_error_EnterProjectName;
+       public static String NewSourceFolderWizardPage_error_InvalidProjectPath;
+       public static String NewSourceFolderWizardPage_error_NotACProject;
+       public static String NewSourceFolderWizardPage_error_ProjectNotExists;
+       public static String NewSourceFolderWizardPage_warning_ReplaceSF;
+       public static String NewSourceFolderWizardPage_warning_AddedExclusions;
+
+       static {
+               NLS.initializeMessages(BUNDLE_NAME, NewFolderWizardMessages.class);
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewFolderWizardMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewFolderWizardMessages.properties
new file mode 100644 (file)
index 0000000..484da43
--- /dev/null
@@ -0,0 +1,47 @@
+###############################################################################
+# Copyright (c) 2004, 2008 QNX Software Systems and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     QNX Software Systems - Initial API and implementation
+#     Anton Leherbauer (Wind River Systems)
+###############################################################################
+
+# ------- NewSourceFolderWizardPage-------
+
+NewSourceFolderCreationWizard_title=New Source Folder
+
+NewSourceFolderWizardPage_title=Source folder
+NewSourceFolderWizardPage_description=Add a new source folder
+
+NewSourceFolderWizardPage_root_label=Fol&der name:
+NewSourceFolderWizardPage_root_button=Br&owse...
+
+NewSourceFolderWizardPage_project_label=Project &name:
+NewSourceFolderWizardPage_project_button=Bro&wse...
+
+NewSourceFolderWizardPage_operation=Creating new source folder...
+
+NewSourceFolderWizardPage_exclude_label=&Update exclusion filters in other source folders to solve nesting.
+
+NewSourceFolderWizardPage_ChooseExistingRootDialog_title=Existing Folder Selection
+NewSourceFolderWizardPage_ChooseExistingRootDialog_description=&Choose folder as source folder:
+
+NewSourceFolderWizardPage_ChooseProjectDialog_title=Project Selection
+NewSourceFolderWizardPage_ChooseProjectDialog_description=&Choose project for the new source folder:
+
+NewSourceFolderWizardPage_error_EnterRootName=Root name must be entered.
+NewSourceFolderWizardPage_error_InvalidRootName=Invalid folder name. {0}
+NewSourceFolderWizardPage_error_NotAFolder=Not a folder.
+NewSourceFolderWizardPage_error_AlreadyExisting=The folder is already a source folder.
+
+NewSourceFolderWizardPage_error_EnterProjectName=Project name must be entered.
+NewSourceFolderWizardPage_error_InvalidProjectPath=Invalid project path.
+NewSourceFolderWizardPage_error_NotACProject=Project is not a C project.
+NewSourceFolderWizardPage_error_ProjectNotExists=Project does not exist.
+
+NewSourceFolderWizardPage_warning_ReplaceSF=To avoid overlapping, the existing project source folder entry will be replaced.
+NewSourceFolderWizardPage_warning_AddedExclusions=Exclusion patterns of {0} source folder(s) updated to solve nesting.
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewSourceFolderWizardPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewSourceFolderWizardPage.java
new file mode 100644 (file)
index 0000000..4d21e9e
--- /dev/null
@@ -0,0 +1,523 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.folderwizard;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFolder;
+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.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.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.eclipse.ui.views.navigator.ResourceComparator;
+
+import org.eclipse.cdt.core.CCProjectNature;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.CProjectNature;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.CoreModelUtil;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICModelStatus;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.cdt.core.model.ISourceEntry;
+import org.eclipse.cdt.core.model.ISourceRoot;
+import org.eclipse.cdt.core.settings.model.CSourceEntry;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICSourceEntry;
+import org.eclipse.cdt.core.settings.model.WriteAccessException;
+import org.eclipse.cdt.ui.CElementLabelProvider;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.model.PathEntryManager;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.dialogs.TypedElementSelectionValidator;
+import org.eclipse.cdt.internal.ui.dialogs.TypedViewerFilter;
+import org.eclipse.cdt.internal.ui.util.CoreUtility;
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+import org.eclipse.cdt.internal.ui.wizards.NewElementWizardPage;
+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.SelectionButtonDialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
+
+public class NewSourceFolderWizardPage extends NewElementWizardPage {
+       private static final String PAGE_NAME= "NewSourceFolderWizardPage"; //$NON-NLS-1$
+
+       private StringButtonDialogField fProjectField;
+       private StatusInfo fProjectStatus;
+       
+       private StringButtonDialogField fRootDialogField;
+       private StatusInfo fRootStatus;
+       
+       private SelectionButtonDialogField fExcludeInOthersFields;
+       
+       private IWorkspaceRoot fWorkspaceRoot;
+       
+       private ICProject fCurrCProject;
+       private IPathEntry[] fEntries;
+       
+       private IPathEntry[] fNewEntries;
+       
+       private boolean fIsProjectAsSourceFolder;
+       
+       private ISourceRoot fCreatedRoot;
+       
+       public NewSourceFolderWizardPage() {
+               super(PAGE_NAME);
+               
+               setTitle(NewFolderWizardMessages.NewSourceFolderWizardPage_title); 
+               setDescription(NewFolderWizardMessages.NewSourceFolderWizardPage_description);           
+               
+               fWorkspaceRoot= ResourcesPlugin.getWorkspace().getRoot();
+               
+               RootFieldAdapter adapter= new RootFieldAdapter();
+               
+               fProjectField= new StringButtonDialogField(adapter);
+               fProjectField.setDialogFieldListener(adapter);
+               fProjectField.setLabelText(NewFolderWizardMessages.NewSourceFolderWizardPage_project_label); 
+               fProjectField.setButtonLabel(NewFolderWizardMessages.NewSourceFolderWizardPage_project_button);  
+               
+               fRootDialogField= new StringButtonDialogField(adapter);
+               fRootDialogField.setDialogFieldListener(adapter);
+               fRootDialogField.setLabelText(NewFolderWizardMessages.NewSourceFolderWizardPage_root_label); 
+               fRootDialogField.setButtonLabel(NewFolderWizardMessages.NewSourceFolderWizardPage_root_button); 
+               
+               fExcludeInOthersFields= new SelectionButtonDialogField(SWT.CHECK);
+               fExcludeInOthersFields.setDialogFieldListener(adapter);
+               fExcludeInOthersFields.setLabelText(NewFolderWizardMessages.NewSourceFolderWizardPage_exclude_label); 
+               
+               fRootStatus= new StatusInfo();
+               fProjectStatus= new StatusInfo();
+       }
+                       
+       // -------- Initialization ---------
+               
+       public void init(IStructuredSelection selection) {
+               if (selection == null || selection.isEmpty()) {
+                       setDefaultAttributes();
+                       return;
+               }
+               
+               Object selectedElement= selection.getFirstElement();
+               if (selectedElement == null) {
+                       selectedElement= EditorUtility.getActiveEditorCInput();
+               }                               
+               
+               String projPath= null;
+               
+               if (selectedElement instanceof IResource) {
+                       IProject proj= ((IResource)selectedElement).getProject();
+                       if (proj != null) {
+                               projPath= proj.getFullPath().makeRelative().toString();
+                       }       
+               } else if (selectedElement instanceof ICElement) {
+                       ICProject jproject= ((ICElement)selectedElement).getCProject();
+                       if (jproject != null) {
+                               projPath= jproject.getProject().getFullPath().makeRelative().toString();
+                       }
+               }       
+               
+               if (projPath != null) {
+                       fProjectField.setText(projPath);
+                       fRootDialogField.setText(""); //$NON-NLS-1$
+               } else {
+                       setDefaultAttributes();
+               }
+       }
+       
+       private void setDefaultAttributes() {
+               String projPath= ""; //$NON-NLS-1$
+               
+               try {
+                       // find the first C project
+                       IProject[] projects= fWorkspaceRoot.getProjects();
+                       for (IProject proj : projects) {
+                               if (proj.hasNature(CProjectNature.C_NATURE_ID) || proj.hasNature(CCProjectNature.CC_NATURE_ID)) {
+                                       projPath= proj.getFullPath().makeRelative().toString();
+                                       break;
+                               }
+                       }                                       
+               } catch (CoreException e) {
+                       // ignore here
+               }
+               fProjectField.setText(projPath);
+               fRootDialogField.setText("");            //$NON-NLS-1$
+       }
+
+       // -------- UI Creation ---------
+
+       /*
+        * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+        */
+       public void createControl(Composite parent) {
+               initializeDialogUnits(parent);
+               
+               Composite composite= new Composite(parent, SWT.NONE);
+                       
+               GridLayout layout= new GridLayout();
+               layout.marginWidth= 0;
+               layout.marginHeight= 0; 
+               layout.numColumns= 3;
+               composite.setLayout(layout);
+                               
+               fProjectField.doFillIntoGrid(composite, 3);     
+               fRootDialogField.doFillIntoGrid(composite, 3);
+               fExcludeInOthersFields.doFillIntoGrid(composite, 3);
+               
+               int maxFieldWidth= convertWidthInCharsToPixels(40);
+               LayoutUtil.setWidthHint(fProjectField.getTextControl(null), maxFieldWidth);
+               LayoutUtil.setHorizontalGrabbing(fProjectField.getTextControl(null), true);     
+               LayoutUtil.setWidthHint(fRootDialogField.getTextControl(null), maxFieldWidth);  
+                       
+               // Bug #220003 : consistency between New Source Folder dialog and Source Location Property tab.
+               fExcludeInOthersFields.setSelection(true);
+               
+               setControl(composite);
+               Dialog.applyDialogFont(composite);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.NEW_SRCFLDER_WIZARD_PAGE);                
+       }
+       
+       /*
+        * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
+        */
+       @Override
+       public void setVisible(boolean visible) {
+               super.setVisible(visible);
+               if (visible) {
+                       fRootDialogField.setFocus();
+               }
+       }       
+               
+       // -------- ContainerFieldAdapter --------
+
+       private class RootFieldAdapter implements IStringButtonAdapter, IDialogFieldListener {
+
+               // -------- IStringButtonAdapter
+               public void changeControlPressed(DialogField field) {
+                       packRootChangeControlPressed(field);
+               }
+               
+               // -------- IDialogFieldListener
+               public void dialogFieldChanged(DialogField field) {
+                       packRootDialogFieldChanged(field);
+               }
+       }
+
+       protected void packRootChangeControlPressed(DialogField field) {
+               if (field == fRootDialogField) {
+                       IPath initialPath= new Path(fRootDialogField.getText());
+                       String title= NewFolderWizardMessages.NewSourceFolderWizardPage_ChooseExistingRootDialog_title; 
+                       String message= NewFolderWizardMessages.NewSourceFolderWizardPage_ChooseExistingRootDialog_description; 
+                       IFolder folder= chooseFolder(title, message, initialPath);
+                       if (folder != null) {
+                               IPath path= folder.getFullPath().removeFirstSegments(1);
+                               fRootDialogField.setText(path.toString());
+                       }
+               } else if (field == fProjectField) {
+                       ICProject jproject= chooseProject();
+                       if (jproject != null) {
+                               IPath path= jproject.getProject().getFullPath().makeRelative();
+                               fProjectField.setText(path.toString());
+                       }
+               } 
+       }       
+       
+       protected void packRootDialogFieldChanged(DialogField field) {
+               if (field == fRootDialogField) {
+                       updateRootStatus();
+               } else if (field == fProjectField) {
+                       updateProjectStatus();
+                       updateRootStatus();
+               } else if (field == fExcludeInOthersFields) {
+                       updateRootStatus();
+               }
+               updateStatus(new IStatus[] { fProjectStatus, fRootStatus });
+       }
+
+       private void updateProjectStatus() {
+               fCurrCProject= null;
+               fIsProjectAsSourceFolder= false;
+               
+               String str= fProjectField.getText();
+               if (str.length() == 0) {
+                       fProjectStatus.setError(NewFolderWizardMessages.NewSourceFolderWizardPage_error_EnterProjectName); 
+                       return;
+               }
+               IPath path= new Path(str);
+               if (path.segmentCount() != 1) {
+                       fProjectStatus.setError(NewFolderWizardMessages.NewSourceFolderWizardPage_error_InvalidProjectPath); 
+                       return;
+               }
+               IProject project= fWorkspaceRoot.getProject(path.toString());
+               if (!project.exists()) {
+                       fProjectStatus.setError(NewFolderWizardMessages.NewSourceFolderWizardPage_error_ProjectNotExists); 
+                       return;
+               }
+               try {
+                       if (project.hasNature(CProjectNature.C_NATURE_ID) || project.hasNature(CCProjectNature.CC_NATURE_ID)) {
+                               fCurrCProject= CoreModel.getDefault().create(project);
+                               fEntries= fCurrCProject.getRawPathEntries();
+                               fProjectStatus.setOK();
+                               return;
+                       }
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+                       fCurrCProject= null;
+               }       
+               fProjectStatus.setError(NewFolderWizardMessages.NewSourceFolderWizardPage_error_NotACProject); 
+       }
+
+       private void updateRootStatus() {
+               fRootDialogField.enableButton(fCurrCProject != null);
+               fIsProjectAsSourceFolder= false;
+               if (fCurrCProject == null) {
+                       return;
+               }
+               fRootStatus.setOK();
+               
+               IPath projPath= fCurrCProject.getProject().getFullPath();
+               String str= fRootDialogField.getText();
+               if (str.length() == 0) {
+                       fRootStatus.setError(NLS.bind(NewFolderWizardMessages.NewSourceFolderWizardPage_error_EnterRootName, fCurrCProject.getProject().getFullPath().toString())); 
+               } else {
+                       IPath path= projPath.append(str);
+                       IStatus validate= fWorkspaceRoot.getWorkspace().validatePath(path.toString(), IResource.FOLDER);
+                       if (validate.matches(IStatus.ERROR)) {
+                               fRootStatus.setError(NLS.bind(NewFolderWizardMessages.NewSourceFolderWizardPage_error_InvalidRootName, validate.getMessage())); 
+                       } else {
+                               IResource res= fWorkspaceRoot.findMember(path);
+                               if (res != null) {
+                                       if (res.getType() != IResource.FOLDER) {
+                                               fRootStatus.setError(NewFolderWizardMessages.NewSourceFolderWizardPage_error_NotAFolder); 
+                                               return;
+                                       }
+                               }
+                               ArrayList<IPathEntry> newEntries= new ArrayList<IPathEntry>(fEntries.length + 1);
+                               int projectEntryIndex= -1;
+                               
+                               for (int i= 0; i < fEntries.length; i++) {
+                                       IPathEntry curr= fEntries[i];
+                                       if (curr.getEntryKind() == IPathEntry.CDT_SOURCE) {
+                                               if (path.equals(curr.getPath())) {
+                                                       fRootStatus.setError(NewFolderWizardMessages.NewSourceFolderWizardPage_error_AlreadyExisting); 
+                                                       return;
+                                               }
+                                               if (projPath.equals(curr.getPath())) {
+                                                       projectEntryIndex= i;
+                                               }       
+                                       }
+                                       newEntries.add(curr);
+                               }
+                               
+                               IPathEntry newEntry= CoreModel.newSourceEntry(path);
+                               
+                               Set<IPathEntry> modified= new HashSet<IPathEntry>();                            
+                               if (fExcludeInOthersFields.isSelected()) {
+                                       addExclusionPatterns(newEntry, newEntries, modified);
+                                       newEntries.add(CoreModel.newSourceEntry(path));
+                               } else {
+                                       if (projectEntryIndex != -1) {
+                                               fIsProjectAsSourceFolder= true;
+                                               newEntries.set(projectEntryIndex, newEntry);
+                                       } else {
+                                               newEntries.add(CoreModel.newSourceEntry(path));
+                                       }
+                               }
+                                       
+                               fNewEntries= newEntries.toArray(new IPathEntry[newEntries.size()]);
+
+                               ICModelStatus status= PathEntryManager.getDefault().validatePathEntry(fCurrCProject, fNewEntries);
+                               if (!status.isOK()) {
+                                       IStatus status2= PathEntryManager.getDefault().validatePathEntry(fCurrCProject, fNewEntries);
+                                       if (status2.isOK()) {
+                                               return;
+                                       }
+                                       fRootStatus.setError(status.getMessage());
+                                       return;
+                               } else if (fIsProjectAsSourceFolder) {
+                                       fRootStatus.setInfo(NewFolderWizardMessages.NewSourceFolderWizardPage_warning_ReplaceSF); 
+                                       return;
+                               }
+                               if (!modified.isEmpty()) {
+                                       fRootStatus.setInfo(NLS.bind(NewFolderWizardMessages.NewSourceFolderWizardPage_warning_AddedExclusions, String.valueOf(modified.size()))); 
+                                       return;
+                               }
+                       }
+               }
+       }
+       
+       private void addExclusionPatterns(IPathEntry newEntry, List<IPathEntry> existing, Set<IPathEntry> modifiedEntries) {
+               IPath entryPath= newEntry.getPath();
+               for (int i= 0; i < existing.size(); i++) {
+                       IPathEntry curr= existing.get(i);
+                       IPath currPath= curr.getPath();
+                       if (curr.getEntryKind() == IPathEntry.CDT_SOURCE && currPath.isPrefixOf(entryPath)) {
+                               IPath[] exclusionFilters= ((ISourceEntry)curr).getExclusionPatterns();
+                               if (!CoreModelUtil.isExcludedPath(entryPath, exclusionFilters)) {
+                                       IPath pathToExclude= entryPath.removeFirstSegments(currPath.segmentCount()).addTrailingSeparator();
+                                       IPath[] newExclusionFilters= new IPath[exclusionFilters.length + 1];
+                                       System.arraycopy(exclusionFilters, 0, newExclusionFilters, 0, exclusionFilters.length);
+                                       newExclusionFilters[exclusionFilters.length]= pathToExclude;
+                                       
+                                       IPathEntry updated= CoreModel.newSourceEntry(currPath, newExclusionFilters);
+                                       existing.set(i, updated);
+                                       modifiedEntries.add(updated);
+                               }
+                       }
+               }
+       }       
+       
+       // ---- creation ----------------
+       
+       public ISourceRoot getNewSourceRoot() {
+               return fCreatedRoot;
+       }
+       
+       public IResource getCorrespondingResource() {
+               return fCurrCProject.getProject().getFolder(fRootDialogField.getText());
+       }
+       
+       public void createSourceRoot(IProgressMonitor monitor) throws CoreException, InterruptedException {
+               if (monitor == null) {
+                       monitor= new NullProgressMonitor();
+               }
+               monitor.beginTask(NewFolderWizardMessages.NewSourceFolderWizardPage_operation, 3); 
+               try {
+//                     IPath projPath= fCurrCProject.getProject().getFullPath();
+                       String relPath= fRootDialogField.getText();
+                               
+                       IFolder folder= fCurrCProject.getProject().getFolder(relPath);
+                       if (!folder.exists()) {
+                               CoreUtility.createFolder(folder, true, true, new SubProgressMonitor(monitor, 1));                       
+                       }
+                       if (monitor.isCanceled()) {
+                               throw new InterruptedException();
+                       }
+                       
+                       if(CCorePlugin.getDefault().isNewStyleProject(fCurrCProject.getProject())){
+                               ICSourceEntry newEntry = new CSourceEntry(folder, null, 0); 
+                               ICProjectDescription des = CCorePlugin.getDefault().getProjectDescription(fCurrCProject.getProject(), true);
+                               addEntryToAllCfgs(des, newEntry, fIsProjectAsSourceFolder);
+                               CCorePlugin.getDefault().setProjectDescription(fCurrCProject.getProject(), des, false, new SubProgressMonitor(monitor, 2));
+                       } else {
+                               fCurrCProject.setRawPathEntries(fNewEntries, new SubProgressMonitor(monitor, 2));
+                       }
+       
+                       fCreatedRoot= fCurrCProject.findSourceRoot(folder);
+               } finally {
+                       monitor.done();
+               }
+       }
+       
+       private void addEntryToAllCfgs(ICProjectDescription des, ICSourceEntry entry, boolean removeProj) throws WriteAccessException, CoreException{
+               ICConfigurationDescription cfgs[] = des.getConfigurations();
+               for(ICConfigurationDescription cfg : cfgs){
+                       ICSourceEntry[] entries = cfg.getSourceEntries();
+                       entries = addEntry(entries, entry, removeProj);
+                       cfg.setSourceEntries(entries);
+               }
+       }
+       
+       private ICSourceEntry[] addEntry(ICSourceEntry[] entries, ICSourceEntry entry, boolean removeProj){
+               Set<ICSourceEntry> set = new HashSet<ICSourceEntry>();
+               for(ICSourceEntry se : entries){
+                       if(removeProj && new Path(se.getValue()).segmentCount() == 1)
+                               continue;
+                       set.add(se);
+               }
+               set.add(entry);
+               return set.toArray(new ICSourceEntry[set.size()]);
+       }
+       
+       // ------------- choose dialogs
+       
+       private IFolder chooseFolder(String title, String message, IPath initialPath) { 
+               Class<?>[] acceptedClasses= new Class<?>[] { IFolder.class };
+               ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, false);
+               ViewerFilter filter= new TypedViewerFilter(acceptedClasses, null);      
+               
+               ILabelProvider lp= new WorkbenchLabelProvider();
+               ITreeContentProvider cp= new WorkbenchContentProvider();
+
+               IProject currProject= fCurrCProject.getProject();
+
+               ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), lp, cp);
+               dialog.setValidator(validator);
+               dialog.setTitle(title);
+               dialog.setMessage(message);
+               dialog.addFilter(filter);
+               dialog.setInput(currProject);
+               dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
+               IResource res= currProject.findMember(initialPath);
+               if (res != null) {
+                       dialog.setInitialSelection(res);
+               }
+
+               if (dialog.open() == Window.OK) {
+                       return (IFolder) dialog.getFirstResult();
+               }                       
+               return null;            
+       }
+       
+       private ICProject chooseProject() {
+               ICProject[] projects;
+               try {
+                       projects= CoreModel.create(fWorkspaceRoot).getCProjects();
+               } catch (CModelException e) {
+                       CUIPlugin.log(e);
+                       projects= new ICProject[0];
+               }
+               
+               ILabelProvider labelProvider= new CElementLabelProvider(CElementLabelProvider.SHOW_DEFAULT);
+               ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), labelProvider);
+               dialog.setTitle(NewFolderWizardMessages.NewSourceFolderWizardPage_ChooseProjectDialog_title); 
+               dialog.setMessage(NewFolderWizardMessages.NewSourceFolderWizardPage_ChooseProjectDialog_description); 
+               dialog.setElements(projects);
+               dialog.setInitialSelections(new Object[] { fCurrCProject });
+               if (dialog.open() == Window.OK) {                       
+                       return (ICProject) dialog.getFirstResult();
+               }                       
+               return null;            
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/Messages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/Messages.java
new file mode 100644 (file)
index 0000000..725f1bc
--- /dev/null
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.wizards.indexwizards;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+       private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.wizards.indexwizards.messages"; //$NON-NLS-1$
+       public static String StringVariableSelectionDialog_columnArgument;
+       public static String StringVariableSelectionDialog_columnDescription;
+       public static String StringVariableSelectionDialog_message;
+       public static String StringVariableSelectionDialog_title;
+       public static String TeamProjectIndexExportWizard_title;
+       public static String TeamProjectIndexExportWizardPage_description;
+       public static String TeamProjectIndexExportWizardPage_deselectAll;
+       public static String TeamProjectIndexExportWizardPage_destinationLabel;
+       public static String TeamProjectIndexExportWizardPage_destinationMessage;
+       public static String TeamProjectIndexExportWizardPage_errorDlgTitle;
+       public static String TeamProjectIndexExportWizardPage_errorExporting;
+       public static String TeamProjectIndexExportWizardPage_errorInOperation;
+       public static String TeamProjectIndexExportWizardPage_labelProjectTable;
+       public static String TeamProjectIndexExportWizardPage_noProjectError;
+       public static String TeamProjectIndexExportWizardPage_resourceSnapshotButton;
+       public static String TeamProjectIndexExportWizardPage_selectAll;
+       public static String TeamProjectIndexExportWizardPage_title;
+       public static String TeamProjectIndexExportWizardPage_variableButton;
+       static {
+               // initialize resource bundle
+               NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+       }
+
+       private Messages() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/StringVariableLabelProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/StringVariableLabelProvider.java
new file mode 100644 (file)
index 0000000..3371522
--- /dev/null
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.wizards.indexwizards;
+
+import org.eclipse.core.variables.IStringVariable;
+import org.eclipse.jface.viewers.LabelProvider;
+
+/**
+ * Copied from org.eclipse.debug.ui
+ * @since 4.0
+ */
+public class StringVariableLabelProvider extends LabelProvider {
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
+        */
+       @Override
+       public String getText(Object element) {
+               if (element instanceof IStringVariable) {
+                       IStringVariable variable = (IStringVariable)element;
+                       return variable.getName();
+               }
+               return super.getText(element);
+       }
+
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/StringVariableSelectionDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/StringVariableSelectionDialog.java
new file mode 100644 (file)
index 0000000..024a36a
--- /dev/null
@@ -0,0 +1,210 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *    IBM Corporation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.wizards.indexwizards;
+
+import org.eclipse.core.variables.IDynamicVariable;
+import org.eclipse.core.variables.IStringVariable;
+import org.eclipse.core.variables.VariablesPlugin;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleAdapter;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * Copied from org.eclipse.debug.ui
+ * @since 4.0
+ */
+public class StringVariableSelectionDialog extends ElementListSelectionDialog {
+       
+       // variable description
+       private Text fDescriptionText;
+       // the argument value
+       private Text fArgumentText;
+       private String fArgumentValue;
+
+       /**
+        * Constructs a new string substitution variable selection dialog.
+        *  
+        * @param parent parent shell
+        */
+       public StringVariableSelectionDialog(Shell parent) {
+               super(parent, new StringVariableLabelProvider());
+               setShellStyle(getShellStyle() | SWT.RESIZE);
+               setTitle(Messages.StringVariableSelectionDialog_title); 
+               setMessage(Messages.StringVariableSelectionDialog_message); 
+               setMultipleSelection(false);
+               setElements(VariablesPlugin.getDefault().getStringVariableManager().getVariables());
+       }
+       
+       /**
+        * Returns the variable expression the user generated from this
+        * dialog, or <code>null</code> if none.
+        *  
+        * @return variable expression the user generated from this
+        * dialog, or <code>null</code> if none
+        */
+       public String getVariableExpression() {
+               Object[] selected = getResult();
+               if (selected != null && selected.length == 1) {
+                       IStringVariable variable = (IStringVariable)selected[0];
+                       StringBuffer buffer = new StringBuffer();
+                       buffer.append("${"); //$NON-NLS-1$
+                       buffer.append(variable.getName());
+                       if (fArgumentValue != null && fArgumentValue.length() > 0) {
+                               buffer.append(":"); //$NON-NLS-1$
+                               buffer.append(fArgumentValue);
+                       }
+                       buffer.append("}"); //$NON-NLS-1$
+                       return buffer.toString();
+               }
+               return null;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected Control createDialogArea(Composite parent) {
+               Control control = super.createDialogArea(parent);
+               createArgumentArea((Composite)control);
+               return control;
+       }
+
+       /**
+        * Creates an area to display a description of the selected variable
+        * and a button to configure the variable's argument.
+        * 
+        * @param parent parent widget
+        */
+       private void createArgumentArea(Composite parent) {
+               Composite container = new Composite(parent, SWT.NONE);
+               GridLayout layout = new GridLayout();
+               layout.numColumns = 2;
+               layout.makeColumnsEqualWidth = false;
+               layout.marginHeight = 0;
+               layout.marginWidth = 0;
+               container.setLayout(layout);
+               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+               container.setLayoutData(gd);
+               container.setFont(parent.getFont());
+                               
+               Label desc = new Label(container, SWT.NONE);
+               desc.setFont(parent.getFont());
+               desc.setText(Messages.StringVariableSelectionDialog_columnArgument); 
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = 2;
+               desc.setLayoutData(gd);         
+               
+               Composite args = new Composite(container, SWT.NONE);
+               layout = new GridLayout(2, false);
+               layout.marginHeight = 0;
+               layout.marginWidth = 0;
+               args.setLayout(layout);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = 2;
+               args.setLayoutData(gd);
+               args.setFont(container.getFont());
+               
+               fArgumentText = new Text(args, SWT.BORDER);
+               fArgumentText.setFont(container.getFont());
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               fArgumentText.setLayoutData(gd);                
+               fArgumentText.getAccessible().addAccessibleListener(new AccessibleAdapter() {                       
+            @Override
+                       public void getName(AccessibleEvent e) {
+                    e.result = Messages.StringVariableSelectionDialog_columnArgument;
+            }
+               });
+               
+               desc = new Label(container, SWT.NONE);
+               desc.setFont(parent.getFont());
+               desc.setText(Messages.StringVariableSelectionDialog_columnDescription); 
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = 2;
+               desc.setLayoutData(gd);
+               
+               fDescriptionText = new Text(container, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
+               fDescriptionText.setFont(container.getFont());
+               fDescriptionText.setEditable(false);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = 2;
+               gd.heightHint = 50;
+               fDescriptionText.setLayoutData(gd);
+       }
+
+       /**
+        * Update variable description and argument button enablement.
+        * 
+        * @see org.eclipse.ui.dialogs.AbstractElementListSelectionDialog#handleSelectionChanged()
+        */
+       @Override
+       protected void handleSelectionChanged() {
+               super.handleSelectionChanged();
+               Object[] objects = getSelectedElements();
+               boolean argEnabled = false;
+               String text = null;
+               if (objects.length == 1) {
+                       IStringVariable variable = (IStringVariable)objects[0];
+                        if (variable instanceof IDynamicVariable) {
+                               argEnabled = ((IDynamicVariable)variable).supportsArgument();
+                        }
+                        text = variable.getDescription();
+               }
+               if (text == null) {
+                       text = ""; //$NON-NLS-1$
+               }
+               fArgumentText.setEnabled(argEnabled);
+               fDescriptionText.setText(text);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+        */
+       @Override
+       protected void okPressed() {
+               fArgumentValue = fArgumentText.getText().trim();
+               super.okPressed();
+       }
+
+       /**
+        * Returns the name of the section that this dialog stores its settings in
+        * 
+        * @return String
+        */
+       private String getDialogSettingsSectionName() {
+               return CUIPlugin.PLUGIN_ID + ".STRING_VARIABLE_SELECTION_DIALOG_SECTION"; //$NON-NLS-1$
+       }
+       
+        /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.Dialog#getDialogBoundsSettings()
+     */
+    @Override
+       protected IDialogSettings getDialogBoundsSettings() {
+        IDialogSettings settings = CUIPlugin.getDefault().getDialogSettings();
+         IDialogSettings section = settings.getSection(getDialogSettingsSectionName());
+         if (section == null) {
+             section = settings.addNewSection(getDialogSettingsSectionName());
+         } 
+         return section;
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectIndexExportWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectIndexExportWizard.java
new file mode 100644 (file)
index 0000000..4c2f7c6
--- /dev/null
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.internal.ui.wizards.indexwizards;
+
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IExportWizard;
+import org.eclipse.ui.IWorkbench;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+
+public class TeamProjectIndexExportWizard extends Wizard implements IExportWizard {
+       private static final String DIALOG_SETTINGS_SECTION = "TeamProjectIndexExportWizard"; //$NON-NLS-1$
+       private TeamProjectIndexExportWizardPage fMainPage;
+       private IStructuredSelection fSelection;
+
+       public TeamProjectIndexExportWizard() {
+        IDialogSettings workbenchSettings = CUIPlugin.getDefault().getDialogSettings();
+        IDialogSettings section = workbenchSettings.getSection(DIALOG_SETTINGS_SECTION);
+        if (section == null) {
+                       section = workbenchSettings.addNewSection(DIALOG_SETTINGS_SECTION);
+               }
+        setDialogSettings(section);
+       }
+
+    @Override
+       public void addPages() {
+        super.addPages();
+        fMainPage = new TeamProjectIndexExportWizardPage(fSelection);
+        addPage(fMainPage);
+    }
+
+       @Override
+       public boolean performFinish() {
+        return fMainPage.finish();
+    }
+
+       public void init(IWorkbench workbench, IStructuredSelection selection) {
+        fSelection= selection;
+        setWindowTitle(Messages.TeamProjectIndexExportWizard_title);
+        setDefaultPageImageDescriptor(CPluginImages.DESC_WIZBAN_EXPORTINDEX);
+        setNeedsProgressMonitor(true);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectIndexExportWizardPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectIndexExportWizardPage.java
new file mode 100644 (file)
index 0000000..d0b8b57
--- /dev/null
@@ -0,0 +1,480 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.internal.ui.wizards.indexwizards;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.ui.CElementLabelProvider;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.pdom.TeamPDOMExportOperation;
+import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
+
+import org.eclipse.cdt.internal.ui.viewsupport.ListContentProvider;
+public class TeamProjectIndexExportWizardPage extends WizardPage implements Listener {
+    private static final int SIZING_TEXT_FIELD_WIDTH = 250;
+
+    private IStructuredSelection fInitialSelection;
+       private CheckboxTableViewer fProjectViewer;
+    private Text fDestinationField;
+    private Button fResourceSnapshotButton;
+
+    /**
+     * Create an instance of this class
+     */
+    protected TeamProjectIndexExportWizardPage(String name, IStructuredSelection selection) {
+        super(name);
+        fInitialSelection= selection;
+    }
+
+    /**
+     * Create an instance of this class.
+     *
+     * @param selection the selection
+     */
+    public TeamProjectIndexExportWizardPage(IStructuredSelection selection) {
+        this("indexExportPage", selection); //$NON-NLS-1$
+        setTitle(Messages.TeamProjectIndexExportWizardPage_title); 
+        setDescription(Messages.TeamProjectIndexExportWizardPage_description); 
+    }
+
+    public void createControl(Composite parent) {
+        initializeDialogUnits(parent);
+
+        Composite composite = new Composite(parent, SWT.NULL);
+        composite.setLayout(new GridLayout());
+        composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL
+                | GridData.HORIZONTAL_ALIGN_FILL));
+        composite.setFont(parent.getFont());
+
+        createResourcesGroup(composite);
+        createDestinationGroup(composite);
+
+        restoreWidgetValues(); 
+        if (fInitialSelection != null) {
+                       setupBasedOnInitialSelections();
+               }
+        setupDestination();
+
+        updateWidgetEnablements();
+        setPageComplete(determinePageCompletion());
+        setErrorMessage(null); // should not initially have error message
+        
+        setControl(composite);
+        giveFocusToDestination();
+    }
+
+       /**
+     * Creates the checkbox tree and list for selecting resources.
+     *
+     * @param parent the parent control
+     */
+    private final void createResourcesGroup(Composite parent) {
+        Composite resourcesGroup = new Composite(parent, SWT.NONE);
+        resourcesGroup.setLayout(new GridLayout());
+        resourcesGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
+        resourcesGroup.setFont(parent.getFont());
+
+        new Label(resourcesGroup, SWT.NONE).setText(Messages.TeamProjectIndexExportWizardPage_labelProjectTable);       
+        Table table= new Table(resourcesGroup, SWT.CHECK | SWT.BORDER);
+        table.setLayoutData(new GridData(GridData.FILL_BOTH));
+               fProjectViewer= new CheckboxTableViewer(table);
+               fProjectViewer.setContentProvider(new ListContentProvider());
+               fProjectViewer.setLabelProvider(new CElementLabelProvider());        
+        ICheckStateListener checkListener = new ICheckStateListener() {
+            public void checkStateChanged(CheckStateChangedEvent event) {
+                updateWidgetEnablements();
+            }
+        };
+        fProjectViewer.addCheckStateListener(checkListener);
+               
+
+        // top level group
+        Composite buttonComposite = new Composite(resourcesGroup, SWT.NONE);
+        buttonComposite.setFont(parent.getFont());
+
+        GridLayout layout = new GridLayout(2, true);
+        layout.marginHeight= layout.marginWidth= 0;
+        buttonComposite.setLayout(layout);
+        buttonComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL
+                | GridData.HORIZONTAL_ALIGN_FILL));
+
+
+        Button selectButton = createButton(buttonComposite,
+                IDialogConstants.SELECT_ALL_ID, Messages.TeamProjectIndexExportWizardPage_selectAll, false);
+
+        SelectionAdapter listener = new SelectionAdapter() {
+            @Override
+                       public void widgetSelected(SelectionEvent e) {
+                fProjectViewer.setAllChecked(true);
+                updateWidgetEnablements();
+            }
+        };
+        selectButton.addSelectionListener(listener);
+
+        Button deselectButton = createButton(buttonComposite,
+                IDialogConstants.DESELECT_ALL_ID, Messages.TeamProjectIndexExportWizardPage_deselectAll, false);
+
+        listener = new SelectionAdapter() {
+            @Override
+                       public void widgetSelected(SelectionEvent e) {
+               fProjectViewer.setAllChecked(false);
+                updateWidgetEnablements();
+            }
+        };
+        deselectButton.addSelectionListener(listener);
+
+        initProjects();
+    }
+
+    private Button createButton(Composite parent, int id, String label,
+            boolean defaultButton) {
+        Button button = new Button(parent, SWT.PUSH);
+
+        GridData buttonData = new GridData(GridData.FILL_HORIZONTAL);
+        button.setLayoutData(buttonData);
+
+        button.setData(new Integer(id));
+        button.setText(label);
+        button.setFont(parent.getFont());
+
+        if (defaultButton) {
+            Shell shell = parent.getShell();
+            if (shell != null) {
+                shell.setDefaultButton(button);
+            }
+            button.setFocus();
+        }
+        button.setFont(parent.getFont());
+        setButtonLayoutData(button);
+        return button;
+    }
+
+    private void initProjects() {
+        ArrayList<ICProject> input = new ArrayList<ICProject>();
+        ICProject[] projects;
+               try {
+                       projects = CoreModel.getDefault().getCModel().getCProjects();
+               for (ICProject project : projects) {
+                   if (project.getProject().isOpen()) {
+                                       input.add(project);
+                               }
+               }
+               } catch (CModelException e) {
+                       CUIPlugin.log(e);
+               }
+               fProjectViewer.setInput(input);
+       }
+
+    private void setupBasedOnInitialSelections() {
+       HashSet<String> names= new HashSet<String>();
+        Iterator<?> it = fInitialSelection.iterator();
+        while (it.hasNext()) {
+            IProject project = (IProject) it.next();
+            names.add(project.getName());
+        }
+        
+        Collection<?> prjs= (Collection<?>) fProjectViewer.getInput();
+        for (Object element : prjs) {
+                       ICProject prj = (ICProject) element;
+                       if (names.contains(prj.getElementName())) {
+                   fProjectViewer.setChecked(prj, true);
+                       }
+               }
+    }
+    
+    private void setupDestination() {
+       String dest;
+       ICProject[] prjs= getCheckedElements();
+       if (prjs.length > 0) {
+               dest= IndexerPreferences.getIndexImportLocation(prjs[0].getProject());
+       }
+       else {
+               dest= IndexerPreferences.getIndexImportLocation(null);
+       }
+       fDestinationField.setText(dest);
+    }
+       
+    
+    private void createDestinationGroup(Composite parent) {
+       GridData gd;
+        Font font = parent.getFont();
+        // destination specification group
+        Composite destinationSelectionGroup = new Composite(parent, SWT.NONE);
+        destinationSelectionGroup.setLayout(new GridLayout(2, false));
+        destinationSelectionGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+        destinationSelectionGroup.setFont(font);
+
+        Label destinationLabel = new Label(destinationSelectionGroup, SWT.NONE);
+        destinationLabel.setText(Messages.TeamProjectIndexExportWizardPage_destinationLabel); 
+        destinationLabel.setFont(font);
+        destinationLabel.setLayoutData(gd= new GridData());
+        gd.horizontalSpan= 2;
+        
+        // destination name entry field
+        fDestinationField = new Text(destinationSelectionGroup, SWT.BORDER);
+        fDestinationField.addListener(SWT.Modify, this);
+        fDestinationField.addListener(SWT.Selection, this);
+        fDestinationField.setFont(font);
+        fDestinationField.setLayoutData(gd= new GridData());
+        gd.grabExcessHorizontalSpace= true;
+        gd.horizontalAlignment= GridData.FILL;
+        gd.widthHint = SIZING_TEXT_FIELD_WIDTH;
+
+        Button button= createButton(destinationSelectionGroup, IDialogConstants.CLIENT_ID, Messages.TeamProjectIndexExportWizardPage_variableButton, false);
+        SelectionAdapter listener = new SelectionAdapter() {
+            @Override
+                       public void widgetSelected(SelectionEvent e) {
+                onInsertVariable();
+            }
+        };
+        button.addSelectionListener(listener);
+
+        // resource snapshot destination group
+        Composite resourceSnapshotDestinationGroup = new Composite(parent, SWT.NONE);
+        resourceSnapshotDestinationGroup.setLayout(new GridLayout(1, false));
+        resourceSnapshotDestinationGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
+        resourceSnapshotDestinationGroup.setFont(font);
+        
+        fResourceSnapshotButton = new Button(resourceSnapshotDestinationGroup, SWT.CHECK);
+        fResourceSnapshotButton.setText(Messages.TeamProjectIndexExportWizardPage_resourceSnapshotButton);
+        fResourceSnapshotButton.setFont(font);
+        fResourceSnapshotButton.setLayoutData(gd= new GridData());
+        gd.grabExcessHorizontalSpace= true;
+        gd.horizontalAlignment= GridData.FILL;
+    }
+
+       protected void onInsertVariable() {
+               StringVariableSelectionDialog dlg= new StringVariableSelectionDialog(getShell());
+               if (dlg.open() == Window.OK) {
+                       String var= dlg.getVariableExpression();
+                       fDestinationField.insert(var);
+               }
+       }
+
+       public boolean finish() {
+        ICProject[] projectsToExport= getCheckedElements();
+
+        // about to invoke the operation so save our state
+        saveWidgetValues();
+        return executeExportOperation(projectsToExport);
+    }
+
+       private void saveWidgetValues() {
+       }
+
+       private void restoreWidgetValues() {
+       }
+
+
+       private ICProject[] getCheckedElements() {
+               Object[] obj= fProjectViewer.getCheckedElements();
+               ICProject[] prjs= new ICProject[obj.length];
+               System.arraycopy(obj, 0, prjs, 0, obj.length);
+               return prjs;
+       }
+
+    private boolean executeExportOperation(final ICProject[] projects) {
+       final String dest= getDestinationValue();
+       final MultiStatus status= new MultiStatus(CUIPlugin.PLUGIN_ID, 
+                       0, Messages.TeamProjectIndexExportWizardPage_errorExporting, null); 
+       final boolean exportResourceSnapshot = fResourceSnapshotButton.getSelection();
+
+       IRunnableWithProgress op= new IRunnableWithProgress() {
+                       public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+                               monitor.beginTask("", projects.length); //$NON-NLS-1$
+                               for (ICProject project : projects) {
+                                       TeamPDOMExportOperation op= new TeamPDOMExportOperation(project);
+                                       op.setTargetLocation(dest);
+                                       if (exportResourceSnapshot) {
+                                               op.setOptions(TeamPDOMExportOperation.EXPORT_OPTION_RESOURCE_SNAPSHOT);
+                                       }
+                                       try {
+                                               op.run(new SubProgressMonitor(monitor, 1));
+                                       } catch (CoreException e) {
+                                               status.merge(e.getStatus());
+                                       }
+                               }
+                       }
+       };
+        try {
+            getContainer().run(true, true, op);
+        } catch (InterruptedException e) {
+            return false;
+        } catch (InvocationTargetException e) {
+            CUIPlugin.log(Messages.TeamProjectIndexExportWizardPage_errorExporting,
+                       e.getTargetException());
+            displayErrorDialog(e.getTargetException());
+            return false;
+        }
+
+        if (!status.isOK()) {
+               CUIPlugin.log(status);
+            ErrorDialog.openError(getContainer().getShell(),
+                    getErrorDialogTitle(),
+                    null, // no special message
+                    status);
+            return false;
+        }
+
+        return true;
+    }
+
+    private String getDestinationValue() {
+        return fDestinationField.getText().trim();
+    }
+
+    private void giveFocusToDestination() {
+       fDestinationField.setFocus();
+    }
+
+    /**
+     * Answer a boolean indicating whether the receivers destination specification
+     * widgets currently all contain valid values.
+     */
+       protected boolean validateDestinationGroup() {
+        String destinationValue = getDestinationValue();
+        if (destinationValue.length() == 0) {
+            setMessage(Messages.TeamProjectIndexExportWizardPage_destinationMessage); 
+            return false;
+        }
+
+        setErrorMessage(null);
+        return true;
+    }
+
+       protected boolean validateSourceGroup() {
+       // there must be some resources selected for Export
+       boolean isValid = true;
+        Object[] projectsToExport = getCheckedElements();
+       if (projectsToExport.length == 0){
+               setErrorMessage(Messages.TeamProjectIndexExportWizardPage_noProjectError); 
+            isValid =  false;
+       } else {
+                       setErrorMessage(null);
+               }
+               return isValid;
+       }
+
+       protected void updateWidgetEnablements() {
+        boolean pageComplete = determinePageCompletion();
+        setPageComplete(pageComplete);
+        if (pageComplete) {
+                       setMessage(null);
+               }
+    }
+    
+
+       public void handleEvent(Event event) {
+               updateWidgetEnablements();
+       }
+       
+       protected String getErrorDialogTitle() {
+        return Messages.TeamProjectIndexExportWizardPage_errorDlgTitle; 
+    }
+
+    /**
+     * Returns whether this page is complete. This determination is made based upon
+     * the current contents of this page's controls.  Subclasses wishing to include
+     * their controls in this determination should override the hook methods 
+     * <code>validateSourceGroup</code> and/or <code>validateOptionsGroup</code>.
+     *
+     * @return <code>true</code> if this page is complete, and <code>false</code> if
+     *   incomplete
+     * @see #validateSourceGroup
+     * @see #validateDestinationGroup
+     */
+    private boolean determinePageCompletion() {
+        boolean complete = validateSourceGroup() && validateDestinationGroup();
+
+        // Avoid draw flicker by not clearing the error
+        // message unless all is valid.
+        if (complete) {
+                       setErrorMessage(null);
+               }
+
+        return complete;
+    }
+
+    /**
+     * Determine if the page is complete and update the page appropriately. 
+     */
+    protected void updatePageCompletion() {
+        boolean pageComplete = determinePageCompletion();
+        setPageComplete(pageComplete);
+        if (pageComplete) {
+            setErrorMessage(null);
+        }
+    }
+
+    /**
+     * Display an error dialog with the specified message.
+     *
+     * @param message the error message
+     */
+    private void displayErrorDialog(String message) {
+        MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(),
+                getErrorDialogTitle(), message, SWT.SHEET);
+    }
+
+    /**
+     * Display an error dislog with the information from the
+     * supplied exception.
+     * @param exception Throwable
+     */
+    private void displayErrorDialog(Throwable exception) {
+        String message = exception.getMessage();
+        //Some system exceptions have no message
+        if (message == null) {
+                       message = NLS.bind(Messages.TeamProjectIndexExportWizardPage_errorInOperation, exception);
+               }
+        displayErrorDialog(message);
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/messages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/messages.properties
new file mode 100644 (file)
index 0000000..15c1c58
--- /dev/null
@@ -0,0 +1,28 @@
+###############################################################################
+# Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     Markus Schorn (Wind River Systems)
+###############################################################################
+TeamProjectIndexExportWizard_title=Export
+TeamProjectIndexExportWizardPage_title=Export Team Shared Index
+TeamProjectIndexExportWizardPage_description=Export C/C++ index for use in other workspaces.
+TeamProjectIndexExportWizardPage_labelProjectTable=Select &project indexes to export:
+TeamProjectIndexExportWizardPage_selectAll=&Select All
+TeamProjectIndexExportWizardPage_deselectAll=&Deselect All
+TeamProjectIndexExportWizardPage_destinationLabel=&Export destination:
+TeamProjectIndexExportWizardPage_variableButton=Insert &Variable...
+TeamProjectIndexExportWizardPage_errorExporting=Errors occurred while exporting index
+TeamProjectIndexExportWizardPage_destinationMessage=Enter a destination archive file.
+TeamProjectIndexExportWizardPage_noProjectError=At least one project must be selected.
+TeamProjectIndexExportWizardPage_errorDlgTitle=Export C/C++ Index
+TeamProjectIndexExportWizardPage_errorInOperation=Error occurred during operation: {0}
+TeamProjectIndexExportWizardPage_resourceSnapshotButton=Export resource snapshot
+StringVariableSelectionDialog_title=Select Variable
+StringVariableSelectionDialog_message=&Choose a variable (? = any character, * = any string):
+StringVariableSelectionDialog_columnArgument=&Argument:
+StringVariableSelectionDialog_columnDescription=&Variable Description:
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IProjectSettingsWizardPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IProjectSettingsWizardPage.java
new file mode 100644 (file)
index 0000000..1e87db4
--- /dev/null
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ *  Copyright (c) 2008 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *      IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.settingswizards;
+
+import java.util.List;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+
+/**
+ * Defines the methods that the strategies can call on the 
+ * wizard page.
+ * 
+ * This interface exists mainly so that it can be implemented by a 
+ * mock object, which makes testing the strategies easy.
+ * 
+ * @author Mike Kucera
+ * @since 5.1
+ */
+public interface IProjectSettingsWizardPage {
+
+       static final String FILENAME_EXTENSION = "xml"; //$NON-NLS-1$
+       
+
+       /**
+        * Sets the input list for the displayed list of settings processors.
+        */
+       void setDisplayedSettingsProcessors(List<ISettingsProcessor> processors);
+       
+       /**
+        * Returns a list of all the available settings processors.
+        */
+       List<ISettingsProcessor> getSettingsProcessors();
+       
+       /**
+        * Returns a list of the settings processors that were selected by the user.
+        */
+       List<ISettingsProcessor> getSelectedSettingsProcessors();
+       
+       /**
+        * Returns the contents of the file path text box.
+        */
+       String getDestinationFilePath();
+
+       /**
+        * Returns the configuration that was selected by the user.
+        * 
+        * The selected project can be determined by calling 
+        * ICCOnfigurationDescription.getProjectDescription().getProject();
+        */
+       ICConfigurationDescription getSelectedConfiguration();
+       
+       /**
+        * Causes an error dialog to be shown to the user.
+        */
+       void showErrorDialog(String dialogTitle, String message);
+
+       /**
+        * Displays a message at the top of the wizard page.
+        * @param flag a constant from the IMessageProvider interface
+        */
+       void setMessage(String message, int flag);
+
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IProjectSettingsWizardPageStrategy.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IProjectSettingsWizardPageStrategy.java
new file mode 100644 (file)
index 0000000..4868b97
--- /dev/null
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.settingswizards;
+
+/**
+ * The wizard page is very similar for importing and exporting,
+ * the wizard page delegates to a strategy object which defines
+ * the behavior that is specific to import and export.
+ * 
+ * @author Mike Kucera
+ * @since 5.1
+ */
+public interface IProjectSettingsWizardPageStrategy {
+       
+       enum MessageType { TITLE, MESSAGE, SETTINGS, CHECKBOX, FILE }
+       
+       
+       /**
+        * Some of the strings displayed on the wizard page are
+        * different, this method returns the correct string
+        * to display depending on the strategy.
+        */
+       String getMessage(MessageType messageType);
+
+       
+       /**
+        * Event sent to strategy object when the
+        * page has been created (at the end of createControl())
+        */
+       void pageCreated(IProjectSettingsWizardPage page);
+       
+       
+       /**
+        * Event sent to strategy object when the user selects
+        * a file name.
+        */
+       void fileSelected(IProjectSettingsWizardPage page);
+       
+       
+       /**
+        * Event sent to strategy object when the user clicks
+        * finish on the wizard page.
+        */
+       boolean finish(IProjectSettingsWizardPage page);
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ISettingsProcessor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ISettingsProcessor.java
new file mode 100644 (file)
index 0000000..31d6ebf
--- /dev/null
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.settingswizards;
+
+
+import org.eclipse.swt.graphics.Image;
+import org.w3c.dom.Element;
+import org.xml.sax.ContentHandler;
+
+import org.eclipse.cdt.core.settings.model.ICFolderDescription;
+
+
+/**
+ * The exported XML file is divided into 'section' elements, each
+ * ISettingsProcessor is responsible for reading and writing
+ * a particular section.
+ * 
+ * A section can contain anything, for example include paths or macros.
+ * No schema is defined for the XML file, that way additional settings
+ * processors can be easily added. In the future there may be an extension
+ * point for adding settings processors.
+ *  
+ * 
+ * @author Mike Kucera
+ * @since 5.1
+ */
+public interface ISettingsProcessor {
+
+       /**
+        * Return the string that will appear in the selection list
+        * on the wizard page.
+        */
+       String getDisplayName();
+       
+       
+       /**
+        * Return the image that will appear in the selection list
+        * on the wizard page.
+        */
+       Image getIcon();
+       
+       
+       /**
+        * The name of the section in the XML file.
+        * 
+        * This String should be unique, so prefix it with the package
+        * name or something.
+        */
+       String getSectionName();
+
+       
+       /**
+        * Outputs a section of the XML file using the given SAX ContentHandler.
+        * 
+        * @param projectRoot The folder description for the selected project and configuration
+        * @throws SettingsImportExportException if the section could not be written
+        */
+       void writeSectionXML(ICFolderDescription projectRoot, ContentHandler content) throws SettingsImportExportException;
+       
+       
+       /**
+        * Passed part of the DOM tree that represents the section 
+        * that is processed by this importer.
+        * 
+        * @param projectRoot The folder description for the selected project and configuration
+        * @throws SettingsImportExportException if the section could not be read and imported
+        */
+       void readSectionXML(ICFolderDescription projectRoot, Element section) throws SettingsImportExportException;
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IncludePathsSettingsProcessor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/IncludePathsSettingsProcessor.java
new file mode 100644 (file)
index 0000000..ba522f8
--- /dev/null
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.settingswizards;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.graphics.Image;
+import org.w3c.dom.Element;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+
+/**
+ * A settings processor that imports and exports include paths.
+ * 
+ * @author Mike Kucera
+ * @since 5.1
+ * 
+ */
+public class IncludePathsSettingsProcessor extends SettingsProcessor { 
+
+       private static final String SECTION_NAME = "org.eclipse.cdt.internal.ui.wizards.settingswizards.IncludePaths"; //$NON-NLS-1$
+       private static final String INCLUDE_PATH_ELEMENT = "includepath"; //$NON-NLS-1$
+       private static final String WORKSPACE_PATH_ATTR = "workspace_path"; //$NON-NLS-1$
+       
+       
+       public Image getIcon() {
+               return CUIPlugin.getImageDescriptorRegistry().get(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER));
+       }
+
+       public String getDisplayName() {
+               return Messages.ProjectSettingsWizardPage_Processor_Includes;
+       }
+       
+       public String getSectionName() {
+               return SECTION_NAME;
+       }
+
+       @Override
+       protected int getSettingsType() {
+               return ICSettingEntry.INCLUDE_PATH;
+       }
+       
+       @Override
+       protected void writeSettings(ContentHandler content, ICLanguageSettingEntry setting) throws SettingsImportExportException {
+               char[] value = setting.getValue().toCharArray();
+               
+               try {
+                       AttributesImpl attrib = null;
+                       if( (setting.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) > 0 ) {
+                               attrib = new AttributesImpl();
+                               attrib.addAttribute(NONE, NONE, WORKSPACE_PATH_ATTR, NONE, Boolean.TRUE.toString());
+                       }
+                       content.startElement(NONE, NONE, INCLUDE_PATH_ELEMENT, attrib);
+                       content.characters(value, 0, value.length);
+                       content.endElement(NONE, NONE, INCLUDE_PATH_ELEMENT);
+                       newline(content);
+                       
+               } catch (SAXException e) {
+                       throw new SettingsImportExportException(e);
+               }
+       }
+
+       
+       @Override
+       protected void readSettings(ICLanguageSetting setting, Element language) throws SettingsImportExportException {
+               List<ICLanguageSettingEntry> includes = new ArrayList<ICLanguageSettingEntry>();
+               
+               List<Element> includeNodes = XMLUtils.extractChildElements(language, INCLUDE_PATH_ELEMENT);
+               for(Element includeElement : includeNodes) {
+                       String include = includeElement.getTextContent();
+                       int flags = 0;
+                       if(include != null && include.length() > 0) {
+                               if( includeElement.getAttribute(WORKSPACE_PATH_ATTR).equalsIgnoreCase(Boolean.TRUE.toString()) )
+                                       flags |= ICSettingEntry.VALUE_WORKSPACE_PATH;
+                               includes.add(new CIncludePathEntry(include, flags));
+                       }
+               }
+
+               if(includes.isEmpty())
+                       return;
+               
+               // need to do this or existing settings will disappear
+               includes.addAll(setting.getSettingEntriesList(ICLanguageSettingEntry.INCLUDE_PATH));
+               setting.setSettingEntries(ICSettingEntry.INCLUDE_PATH, includes);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/MacroSettingsProcessor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/MacroSettingsProcessor.java
new file mode 100644 (file)
index 0000000..ce74795
--- /dev/null
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.settingswizards;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.graphics.Image;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+import org.eclipse.cdt.core.settings.model.CMacroEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * A settings processor that imports and exports symbols.
+ * 
+ * @author Mike Kucera
+ * @since 5.1
+ * 
+ */
+public class MacroSettingsProcessor extends SettingsProcessor {
+
+       public static final String SECTION_NAME = "org.eclipse.cdt.internal.ui.wizards.settingswizards.Macros"; //$NON-NLS-1$
+       
+       private static final String MACRO_ELEMENT = "macro"; //$NON-NLS-1$
+       private static final String NAME_ELEMENT = "name";   //$NON-NLS-1$
+       private static final String VALUE_ELEMENT = "value"; //$NON-NLS-1$
+       
+       
+       public Image getIcon() {
+               return CUIPlugin.getImageDescriptorRegistry().get(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_MACRO));
+       }
+
+       public String getDisplayName() {
+               return Messages.ProjectSettingsWizardPage_Processor_Macros;
+       }
+
+       public String getSectionName() {
+               return SECTION_NAME;
+       }
+
+       @Override
+       protected int getSettingsType() {
+               return ICSettingEntry.MACRO;
+       }
+       
+       @Override
+       protected void writeSettings(ContentHandler content, ICLanguageSettingEntry setting) throws SettingsImportExportException {
+               char[] name = setting.getName().toCharArray();
+               char[] value = setting.getValue().toCharArray();
+               
+               try {
+                       content.startElement(NONE, NONE, MACRO_ELEMENT, null);
+                       newline(content);
+                       
+                       content.startElement(NONE, NONE, NAME_ELEMENT, null);
+                       content.characters(name, 0, name.length);
+                       content.endElement(NONE, NONE, NAME_ELEMENT);
+                       
+                       content.startElement(NONE, NONE, VALUE_ELEMENT, null);
+                       content.characters(value, 0, value.length);
+                       content.endElement(NONE, NONE, VALUE_ELEMENT);
+                       newline(content);
+                       
+                       content.endElement(NONE, NONE, MACRO_ELEMENT);
+                       newline(content);
+                       
+               } catch(SAXException e) {
+                       throw new SettingsImportExportException(e);
+               }
+       }
+       
+       
+       @Override
+       protected void readSettings(ICLanguageSetting setting, Element language) throws SettingsImportExportException {
+               List<ICLanguageSettingEntry> macros = new ArrayList<ICLanguageSettingEntry>();
+               
+               List<Element> macrosNodes = XMLUtils.extractChildElements(language, MACRO_ELEMENT);
+               
+               for(Element macroElement : macrosNodes) {
+                       String name = null;
+                       String value = null;
+                       
+                       NodeList nodeList = macroElement.getChildNodes();
+                       for(int i = 0; i < nodeList.getLength(); i++) {
+                               Node node = nodeList.item(i);
+                               switch(node.getNodeType()) {
+                               case Node.TEXT_NODE:
+                                       Text text = (Text)node;
+                                       if(XMLUtils.isWhitespace(text.getData()))
+                                               break;
+                                       throw new SettingsImportExportException("Unknown text: '" + text.getData() + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+                               case Node.ELEMENT_NODE:
+                                       Element element = (Element)node;
+                                       String tagName = element.getTagName();
+                                       if(name == null && tagName.equals(NAME_ELEMENT))
+                                               name = element.getTextContent();
+                                       else if(value == null && tagName.equals(VALUE_ELEMENT))
+                                               value = element.getTextContent();
+                                       else
+                                               throw new SettingsImportExportException("Unknown or extra tag: " + tagName); //$NON-NLS-1$
+                                       break;
+                               default:
+                                       throw new SettingsImportExportException("Unknown node: " + node.getNodeName()); //$NON-NLS-1$
+                               }
+                       }
+                       
+                       if(name == null)
+                               throw new SettingsImportExportException("There must be one <name> element"); //$NON-NLS-1$
+                       if(value == null)
+                               throw new SettingsImportExportException("There must be one <value> element"); //$NON-NLS-1$
+                       
+                       macros.add(new CMacroEntry(name, value, 0));
+               }
+               
+               if(macros.isEmpty())
+                       return;
+               
+               // need to do this or existing settings will disappear
+               macros.addAll(setting.getSettingEntriesList(ICLanguageSettingEntry.MACRO));
+               setting.setSettingEntries(ICSettingEntry.MACRO, macros);
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/Messages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/Messages.java
new file mode 100644 (file)
index 0000000..974fecd
--- /dev/null
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.settingswizards;
+
+import org.eclipse.osgi.util.NLS;
+
+
+class Messages extends NLS {
+       
+       private static final String BUNDLE_NAME = 
+               "org.eclipse.cdt.internal.ui.wizards.settingswizards.messages"; //$NON-NLS-1$
+
+       static {
+               initializeMessages(BUNDLE_NAME, Messages.class);
+       }
+       
+       private Messages() { }
+       
+       
+       // messages specific to the import page
+       public static String 
+               ProjectSettingsWizardPage_Import_title,
+               ProjectSettingsWizardPage_Import_message,
+               ProjectSettingsWizardPage_Import_selectSettings,
+               ProjectSettingsWizardPage_Import_checkBox,
+               ProjectSettingsWizardPage_Import_file,
+               ProjectSettingsWizardPage_Import_parseError,
+               ProjectSettingsWizardPage_Import_openError;
+               
+       // messages specific to the export page
+       public static String
+               ProjectSettingsWizardPage_Export_title,
+               ProjectSettingsWizardPage_Export_message,
+               ProjectSettingsWizardPage_Export_selectSettings,
+               ProjectSettingsWizardPage_Export_checkBox,
+               ProjectSettingsWizardPage_Export_file;
+       
+       // messages common to both
+       public static String
+               ProjectSettingsWizardPage_selectAll,
+               ProjectSettingsWizardPage_deselectAll,
+               ProjectSettingsWizardPage_selectProject,
+               ProjectSettingsWizardPage_browse,
+               ProjectSettingsWizardPage_noOpenProjects,
+               ProjectSettingsWizardPage_selectConfiguration,
+               ProjectSettingsWizardPage_active;
+       
+       // messages for settings processors
+       public static String
+               ProjectSettingsWizardPage_Processor_Includes,
+               ProjectSettingsWizardPage_Processor_Macros;
+       
+       // error messages during export
+       public static String 
+               ProjectSettingsExportStrategy_couldNotOpen,
+               ProjectSettingsExportStrategy_exportError,
+               ProjectSettingsExportStrategy_exportFailed,
+               ProjectSettingsExportStrategy_fileOpenError,
+               ProjectSettingsExportStrategy_xmlError;
+       
+       // error messages during import
+       public static String 
+               ProjectSettingsImportStrategy_couldNotImport,
+               ProjectSettingsImportStrategy_couldNotOpen,
+               ProjectSettingsImportStrategy_fileOpenError,
+               ProjectSettingsImportStrategy_importError,
+               ProjectSettingsImportStrategy_saveError;
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsExportStrategy.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsExportStrategy.java
new file mode 100644 (file)
index 0000000..51e02da
--- /dev/null
@@ -0,0 +1,187 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.settingswizards;
+
+
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.net.URI;
+import java.util.List;
+
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.sax.SAXTransformerFactory;
+import javax.xml.transform.sax.TransformerHandler;
+import javax.xml.transform.stream.StreamResult;
+
+import org.eclipse.core.filesystem.URIUtil;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+import org.eclipse.cdt.core.resources.ResourcesUtil;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICFolderDescription;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+
+/**
+ * Custom behavior for the Export wizard.
+ * 
+ * @author Mike Kucera
+ * @since 5.1
+ *
+ */
+public class ProjectSettingsExportStrategy implements IProjectSettingsWizardPageStrategy {
+
+       public static final String ROOT_ELEMENT = "cdtprojectproperties"; //$NON-NLS-1$
+       public static final String SECTION_ELEMENT = "section"; //$NON-NLS-1$
+       public static final String SECTION_NAME_ATTRIBUTE = "name"; //$NON-NLS-1$
+       
+       
+       
+       private static final String NONE = ""; //$NON-NLS-1$
+       private static final String CDATA = "CDATA"; //$NON-NLS-1$
+       
+       
+       
+       public String getMessage(MessageType type) {
+               switch(type) {
+               case TITLE:    return Messages.ProjectSettingsWizardPage_Export_title;
+               case MESSAGE:  return Messages.ProjectSettingsWizardPage_Export_message;
+               case CHECKBOX: return Messages.ProjectSettingsWizardPage_Export_checkBox;
+               case FILE:     return Messages.ProjectSettingsWizardPage_Export_file;
+               case SETTINGS: return Messages.ProjectSettingsWizardPage_Export_selectSettings;
+               default:       return null;
+               }
+       }
+       
+
+       public void pageCreated(IProjectSettingsWizardPage page) {
+               // do nothing
+       }
+
+       
+       public void fileSelected(IProjectSettingsWizardPage page) {
+               // do nothing
+       }
+
+       
+       private Writer getWriter(IProjectSettingsWizardPage page) throws IOException {
+               IPath path = new Path(page.getDestinationFilePath());
+               if(!IProjectSettingsWizardPage.FILENAME_EXTENSION.equals(path.getFileExtension()))
+                       path.addFileExtension(IProjectSettingsWizardPage.FILENAME_EXTENSION);
+               
+               return new FileWriter(path.toFile());
+       }
+       
+
+       /**
+        * Exports the selected project settings to an XML file.
+        */
+       public boolean finish(IProjectSettingsWizardPage page) {
+               SAXTransformerFactory factory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
+               TransformerHandler handler = null;
+               try {
+                       handler = factory.newTransformerHandler();
+               } catch (TransformerConfigurationException e) {
+                       CUIPlugin.log(e);
+                       page.showErrorDialog(Messages.ProjectSettingsExportStrategy_exportError, 
+                                                    Messages.ProjectSettingsExportStrategy_exportFailed);
+                       return false;
+               }
+               
+               // gets a writer for the file that was selected by the user
+               Writer writer;
+               try {
+                       writer = getWriter(page);
+               } catch(IOException e) {
+                       page.showErrorDialog(Messages.ProjectSettingsExportStrategy_fileOpenError, 
+                                                    Messages.ProjectSettingsExportStrategy_couldNotOpen);
+                       return false;
+               }
+               
+               // stream the results to the writer as text
+               handler.setResult(new StreamResult(writer));
+               
+               // write out the XML header
+               Transformer transformer = handler.getTransformer();
+               transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1"); //$NON-NLS-1$
+               transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
+               
+               List<ISettingsProcessor> exporters = page.getSelectedSettingsProcessors();
+               
+               ICConfigurationDescription config = page.getSelectedConfiguration();
+               ICFolderDescription projectRoot = config.getRootFolderDescription();
+               
+               boolean result = false;
+               try {
+                       AttributesImpl attributes = new AttributesImpl();
+                       
+                       handler.startDocument();
+                       newline(handler);
+                       handler.startElement(NONE, NONE, ROOT_ELEMENT, null);
+                       newline(handler);
+                       
+                       for(ISettingsProcessor exporter : exporters) {
+                               attributes.clear();
+                               attributes.addAttribute(NONE, NONE, SECTION_NAME_ATTRIBUTE, CDATA, exporter.getSectionName());
+                               handler.startElement(NONE, NONE, SECTION_ELEMENT, attributes);
+                               newline(handler);
+                               
+                               // each exporter is responsible for writing out its own section of the file
+                               exporter.writeSectionXML(projectRoot, handler);
+                               
+                               handler.endElement(NONE, NONE, SECTION_ELEMENT);
+                               newline(handler);
+                       }
+                       
+                       handler.endElement(NONE, NONE, ROOT_ELEMENT);
+                       newline(handler);
+                       handler.endDocument();
+                       newline(handler);
+                       
+                       result = true;
+               } catch (SAXException e) {
+                       CUIPlugin.log(e);
+                       page.showErrorDialog(Messages.ProjectSettingsExportStrategy_exportError, 
+                                                    Messages.ProjectSettingsExportStrategy_xmlError);
+                       result = false;
+               } catch(SettingsImportExportException e) {
+                       CUIPlugin.log(e);
+                       page.showErrorDialog(Messages.ProjectSettingsExportStrategy_fileOpenError, 
+                                                    Messages.ProjectSettingsExportStrategy_couldNotOpen);
+                       result = false;
+               }
+               
+               URI uri = URIUtil.toURI(page.getDestinationFilePath());
+               ResourcesUtil.refreshWorkspaceFiles(uri);
+               
+               return result;
+       }
+       
+       
+       
+       
+       
+       
+       /**
+        * Outputs a newline (\n) to the given ContentHandler.
+        */
+       private static void newline(ContentHandler handler) throws SAXException {
+               handler.ignorableWhitespace("\n".toCharArray(), 0, 1); //$NON-NLS-1$
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsExportWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsExportWizard.java
new file mode 100644 (file)
index 0000000..86173b8
--- /dev/null
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.settingswizards;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IExportWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * @since 5.1
+ */
+public class ProjectSettingsExportWizard extends ProjectSettingsWizard implements IExportWizard {
+
+
+       @Override
+       public void init(IWorkbench workbench, IStructuredSelection selection) {
+               super.init(workbench, selection);
+               setWindowTitle(Messages.ProjectSettingsWizardPage_Export_title); 
+       }
+
+       @Override
+       public ProjectSettingsWizardPage getPage() {
+               return ProjectSettingsWizardPage.createExportWizardPage();
+       }
+       
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsImportStrategy.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsImportStrategy.java
new file mode 100644 (file)
index 0000000..2d02b40
--- /dev/null
@@ -0,0 +1,240 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.settingswizards;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICFolderDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * Custom behavior for the Import wizard.
+ * 
+ * @author Mike Kucera
+ * @since 5.1
+ *
+ */
+public class ProjectSettingsImportStrategy implements IProjectSettingsWizardPageStrategy {
+
+
+       public String getMessage(MessageType type) {
+               switch(type) {
+               case TITLE:    return Messages.ProjectSettingsWizardPage_Import_title;
+               case MESSAGE:  return Messages.ProjectSettingsWizardPage_Import_message;
+               case CHECKBOX: return Messages.ProjectSettingsWizardPage_Import_checkBox;
+               case FILE:     return Messages.ProjectSettingsWizardPage_Import_file;
+               case SETTINGS: return Messages.ProjectSettingsWizardPage_Import_selectSettings;
+               default:       return null;
+               }
+       }
+       
+
+       /*
+        * Start with an empty list of processors.
+        */
+       public void pageCreated(IProjectSettingsWizardPage page) {
+               page.setDisplayedSettingsProcessors(Collections.<ISettingsProcessor>emptyList());
+       }
+       
+       
+       /*
+        * Collects the importers that can be applied to the file and displays 
+        * them to the user.
+        */
+       public void fileSelected(IProjectSettingsWizardPage page) {
+               List<ImporterSectionPair> pairs = Collections.emptyList();
+               try {
+                       pairs = extractSectionsFromFile(page);
+                       page.setMessage(getMessage(MessageType.MESSAGE), IMessageProvider.NONE); // its all good
+               } catch (FileNotFoundException e) {
+                       page.setMessage(Messages.ProjectSettingsWizardPage_Import_openError, IMessageProvider.ERROR);
+               } catch (SettingsImportExportException e) {
+                       page.setMessage(Messages.ProjectSettingsWizardPage_Import_parseError, IMessageProvider.ERROR);
+               }
+               
+               List<ISettingsProcessor> importersToDisplay = new ArrayList<ISettingsProcessor>();
+               for(ImporterSectionPair pair : pairs) {
+                       importersToDisplay.add(pair.importer);
+               }
+               
+               // if there was an error then importersToDisplay will be empty and this will clear the list
+               page.setDisplayedSettingsProcessors(importersToDisplay);
+       }
+       
+       
+       /*
+        * Parse the file again and this time actually do the import.
+        */
+       public boolean finish(IProjectSettingsWizardPage page) {
+               // get the selected project and configuration
+               ICConfigurationDescription config = page.getSelectedConfiguration();
+               IProject project = config.getProjectDescription().getProject();
+               
+               // get a writable copy of the project description so that we can make changes to it
+               ICProjectDescription writableDescription = CoreModel.getDefault().getProjectDescription(project, true);
+               ICConfigurationDescription writableConfig = writableDescription.getConfigurationById(config.getId());
+               ICFolderDescription writableProjectRoot = writableConfig.getRootFolderDescription();
+               
+               List<ISettingsProcessor> selectedImporters = page.getSelectedSettingsProcessors();
+               
+               try {
+                       List<ImporterSectionPair> pairs = extractSectionsFromFile(page);
+                       
+                       for(ImporterSectionPair pair : pairs) {
+                               if(selectedImporters.contains(pair.importer))
+                                       pair.importer.readSectionXML(writableProjectRoot, pair.section);
+                       }
+                       
+               } catch (FileNotFoundException e) {
+                       CUIPlugin.log(e);
+                       page.showErrorDialog(Messages.ProjectSettingsImportStrategy_fileOpenError, 
+                                                    Messages.ProjectSettingsImportStrategy_couldNotOpen);
+                       return false;
+               } catch (SettingsImportExportException e) { // error during parsing or importing
+                       CUIPlugin.log(e);
+                       page.showErrorDialog(Messages.ProjectSettingsImportStrategy_importError, 
+                                                    Messages.ProjectSettingsImportStrategy_couldNotImport);
+                       return false;
+               }
+               
+               // only if all the importing was successful do we actually write out to the .cproject file
+               try {
+                       CoreModel.getDefault().setProjectDescription(project, writableDescription);
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+                       page.showErrorDialog(Messages.ProjectSettingsImportStrategy_importError, 
+                                                    Messages.ProjectSettingsImportStrategy_saveError);
+                       return false;
+               }
+               
+               return true;
+       }
+       
+
+       private static class ImporterSectionPair {
+               Element section;
+               ISettingsProcessor importer;
+               ImporterSectionPair(ISettingsProcessor importer, Element section) {
+                       this.importer = importer;
+                       this.section = section;
+               }
+       }
+       
+       /*
+        * Attempts to parse the file the user selected.
+        */
+       private List<ImporterSectionPair> extractSectionsFromFile(IProjectSettingsWizardPage page) throws FileNotFoundException, SettingsImportExportException {
+               // get the file path that the user input
+               String filePath = page.getDestinationFilePath();
+               
+               // get all the importers
+               Map<String,ISettingsProcessor> importers = new HashMap<String,ISettingsProcessor>();
+               for(ISettingsProcessor processor : page.getSettingsProcessors()) {
+                       importers.put(processor.getSectionName(), processor);
+               }
+               
+               FileInputStream in = new FileInputStream(filePath); // throws FileNotFoundException
+               
+               // try to parse the file as generic XML with no schema
+               Document document = parse(in);
+               
+               // now try to get a list of <section> elements
+               Element root = document.getDocumentElement();
+               List<Element> sections = XMLUtils.extractChildElements(root, ProjectSettingsExportStrategy.SECTION_ELEMENT);
+               
+               List<ImporterSectionPair> pairs = new ArrayList<ImporterSectionPair>();
+               
+               // associate an importer with each section
+               for(Element section : sections) {
+                       String sectionName = section.getAttribute(ProjectSettingsExportStrategy.SECTION_NAME_ATTRIBUTE);
+                       if(sectionName != null) {
+                               ISettingsProcessor importer = importers.get(sectionName);
+                               
+                               // if there is an importer available for the section then delegate to it
+                               if(importer != null)
+                                       pairs.add(new ImporterSectionPair(importer, section));
+                       }
+               }
+               
+               return pairs;
+       }
+       
+       
+       /**
+        * An error handler that aborts the XML parse at the first sign
+        * of any kind of problem.
+        */
+       private static ErrorHandler ABORTING_ERROR_HANDER = new ErrorHandler() {
+               public void error(SAXParseException e) throws SAXException {
+                       throw e;
+               }
+               public void fatalError(SAXParseException e) throws SAXException {
+                       throw e;
+               }
+               public void warning(SAXParseException e) throws SAXException {
+                       throw e;
+               }
+       };
+       
+       
+       /*
+        * Uses JAXP to parse the file. Returns null if the file could
+        * not be parsed as XML.
+        * 
+        * Not validating because I want to make it easy to add new settings processors.
+     * Eventually there could be an extension point for adding settings processors
+        * so I'm coding everything with the assumption that each settings processor
+        * will do its own validation programatically.
+        */
+       private static Document parse(InputStream in) throws SettingsImportExportException {
+               DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+               factory.setValidating(false);
+               factory.setNamespaceAware(false);
+               factory.setIgnoringComments(true);
+               
+               try {
+                       DocumentBuilder parser = factory.newDocumentBuilder();
+                       parser.setErrorHandler(ABORTING_ERROR_HANDER); // causes SAXException to be thrown on any parse error
+                       InputSource input = new InputSource(in); // TODO should I be using an InputSource?
+                       Document doc = parser.parse(input);
+                       return doc;
+                       
+               } catch (Exception e) {
+                       throw new SettingsImportExportException(e);
+               }
+       }
+       
+       
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsImportWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsImportWizard.java
new file mode 100644 (file)
index 0000000..11900a1
--- /dev/null
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.settingswizards;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IImportWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * @since 5.1
+ */
+public class ProjectSettingsImportWizard extends ProjectSettingsWizard implements IImportWizard {
+
+
+       @Override
+       public void init(IWorkbench workbench, IStructuredSelection selection) {
+               super.init(workbench, selection);
+               setWindowTitle(Messages.ProjectSettingsWizardPage_Import_title);
+       }
+
+       @Override
+       public ProjectSettingsWizardPage getPage() {
+               return ProjectSettingsWizardPage.createImportWizardPage();
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsWizard.java
new file mode 100644 (file)
index 0000000..5b8efe1
--- /dev/null
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.settingswizards;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * @since 5.1
+ */
+public abstract class ProjectSettingsWizard extends Wizard {
+
+       private ProjectSettingsWizardPage mainPage;
+       private IStructuredSelection selection;
+       
+       public abstract ProjectSettingsWizardPage getPage(); 
+
+       private boolean finishedPressed;
+       
+       
+       @Override
+       public void addPages() {
+               super.addPages();
+               mainPage = getPage();
+               
+               // happens if the user invoked the wizard by right clicking on a project element
+               if(selection != null) {
+                       IProject project = (IProject)selection.getFirstElement();
+                       mainPage.setInitialProject(project);
+               }
+               
+               addPage(mainPage);
+       }
+
+       @Override
+       public boolean performFinish() {
+               finishedPressed = true;
+               return mainPage.finish();
+       }
+       
+       public boolean isFinishedPressed() {
+               return finishedPressed;
+       }
+       
+
+       public void init(IWorkbench workbench, IStructuredSelection selection) {
+               this.selection = selection;
+               setNeedsProgressMonitor(true);
+       }
+       
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsWizardPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/ProjectSettingsWizardPage.java
new file mode 100644 (file)
index 0000000..7bda2ec
--- /dev/null
@@ -0,0 +1,453 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.settingswizards;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CElementLabelProvider;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.viewsupport.ListContentProvider;
+import org.eclipse.cdt.internal.ui.wizards.settingswizards.IProjectSettingsWizardPageStrategy.MessageType;
+
+/**
+ * @since 5.1
+ */
+abstract public class ProjectSettingsWizardPage extends WizardPage implements IProjectSettingsWizardPage {
+
+       public static final String FILENAME_EXTENSION = "xml"; //$NON-NLS-1$
+       
+       
+       private final IProjectSettingsWizardPageStrategy strategy;
+       private final List<ISettingsProcessor> processors;
+       
+       private ICProject selectedProject;
+       private ICConfigurationDescription selectedConfiguration;
+       
+       private Text filePathText;
+       private CheckboxTableViewer settingsViewer;
+       
+       private IProject initialProject;
+       
+       /**
+        * 
+        * @param strategy
+        * @param initialProject the initial project to be selected, may be null
+        */
+       private ProjectSettingsWizardPage(IProjectSettingsWizardPageStrategy strategy) {
+               super(""); //$NON-NLS-1$
+               this.strategy = strategy;
+               
+               // This could be replaced with an extension point
+               this.processors = Arrays.<ISettingsProcessor>asList(
+                       new IncludePathsSettingsProcessor(),
+                       new MacroSettingsProcessor()
+               );
+               
+       }
+       
+       
+       
+       
+       protected abstract void layoutPage(Composite parent);
+       
+       
+       public static ProjectSettingsWizardPage createExportWizardPage() {
+               return new ProjectSettingsWizardPage(new ProjectSettingsExportStrategy()) {
+                       @Override
+                       public void layoutPage(Composite parent) {
+                           createProjectSelectionGroup(parent);
+                           createSettingsSelectionGroup(parent);
+                           //createCheckboxSelectionGroup(parent);
+                           createFileSelectionGroup(parent);
+                       }
+               };
+       }
+       
+       
+       public static ProjectSettingsWizardPage createImportWizardPage() {
+               return new ProjectSettingsWizardPage(new ProjectSettingsImportStrategy()) {
+                       @Override
+                       public void layoutPage(Composite parent) {
+                               createFileSelectionGroup(parent);
+                           createProjectSelectionGroup(parent);
+                           createSettingsSelectionGroup(parent);
+                           //createCheckboxSelectionGroup(parent);
+                       }
+               };
+       }
+       
+       
+       public boolean finish() {
+               return strategy.finish(this);
+       }
+       
+       
+       public void setInitialProject(IProject project) {
+               this.initialProject = project;
+       }
+       
+       
+       public List<ISettingsProcessor> getSettingsProcessors() {
+               return Collections.unmodifiableList(processors);
+       }
+       
+       
+       public List<ISettingsProcessor> getSelectedSettingsProcessors() {
+               List<ISettingsProcessor> selected = new ArrayList<ISettingsProcessor>();
+               for(Object element : settingsViewer.getCheckedElements()) {
+                       selected.add((ISettingsProcessor)element);
+               }
+               return selected;
+       }
+       
+       public String getDestinationFilePath() {
+               return filePathText.getText();
+       }
+       
+       
+       public ICProject getSelectedProject() {
+               return selectedProject;
+       }
+       
+       
+       public ICConfigurationDescription getSelectedConfiguration() {
+               return selectedConfiguration;
+       }
+       
+       public void setDisplayedSettingsProcessors(List<ISettingsProcessor> processors) {
+               settingsViewer.setInput(processors);
+               settingsViewer.refresh();
+               settingsViewer.setAllChecked(true);
+               updateWidgetEnablements();
+       }
+       
+       
+       public void showErrorDialog(String dialogTitle, String message) {
+               Shell shell = Display.getCurrent().getActiveShell();
+               Status status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, message, null);
+               ErrorDialog.openError(shell, dialogTitle, null, status);
+       }
+       
+       
+       public void createControl(Composite parent) {
+               setTitle(strategy.getMessage(MessageType.TITLE));
+               setMessage(strategy.getMessage(MessageType.MESSAGE));
+                   
+               Composite composite = new Composite(parent, SWT.NULL);
+               composite.setLayout(new GridLayout());
+               composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL));
+           composite.setFont(parent.getFont());
+           
+           layoutPage(composite);
+           
+               setControl(composite);
+               
+               strategy.pageCreated(this);
+               
+               updateWidgetEnablements();
+       }
+       
+       
+       private void updateWidgetEnablements() {
+               boolean enableFinishButton = selectedProject != null 
+                                         && selectedConfiguration != null
+                                         && settingsViewer.getCheckedElements().length > 0 
+                                         && filePathText.getText().length() > 0;
+               
+               // since this wizard has only one page we can toggle the finish button using the setPageComplete() method
+               setPageComplete(enableFinishButton);
+       }
+       
+       
+       
+       protected void createProjectSelectionGroup(Composite parent) {
+               Composite projectSelectionGroup = new Composite(parent, SWT.NONE);
+               projectSelectionGroup.setLayout(new GridLayout(2, true));
+               projectSelectionGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
+               projectSelectionGroup.setFont(parent.getFont());
+               
+               Label projectLabel = new Label(projectSelectionGroup, SWT.NONE);
+               projectLabel.setText(Messages.ProjectSettingsWizardPage_selectProject);
+               projectLabel.setLayoutData(new GridData());
+               
+               Label configLabel = new Label(projectSelectionGroup, SWT.NONE);
+               configLabel.setText(Messages.ProjectSettingsWizardPage_selectConfiguration);
+               configLabel.setLayoutData(new GridData());
+
+               final Table projectTable = new Table(projectSelectionGroup, SWT.SINGLE | SWT.BORDER);
+               projectTable.setLayoutData(new GridData(GridData.FILL_BOTH));
+               
+               TableViewer projectViewer = new TableViewer(projectTable);
+               projectViewer.setContentProvider(new ListContentProvider());
+               projectViewer.setLabelProvider(new CElementLabelProvider());
+               List<ICProject> openProjects = getAllOpenCProjects();
+               Collections.sort(openProjects, new Comparator<ICProject>() {
+                       public int compare(ICProject o1, ICProject o2) {
+                               return o1.getProject().getName().compareTo(o2.getProject().getName());
+                       }
+               });
+               projectViewer.setInput(openProjects);
+               
+               final Table configTable = new Table(projectSelectionGroup, SWT.SINGLE | SWT.BORDER);
+               configTable.setLayoutData(new GridData(GridData.FILL_BOTH));
+               
+               final TableViewer configViewer = new TableViewer(configTable);
+               configViewer.setContentProvider(new ListContentProvider());
+               configViewer.setLabelProvider(new LabelProvider() { 
+                       @Override public Image getImage(Object element) {
+                               return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_CONFIG);
+                       }
+                       @Override public String getText(Object element) {
+                               ICConfigurationDescription config = (ICConfigurationDescription)element;
+                               String label = config.getName();
+                               if(config.isActive())
+                                       label += " (" + Messages.ProjectSettingsWizardPage_active + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+                               return label;
+                       }
+               });
+               
+               
+               // TODO what if nothing is selected?
+               projectTable.addSelectionListener(new SelectionAdapter() {
+                       @Override public void widgetSelected(SelectionEvent e) {
+                               TableItem[] items = projectTable.getSelection();
+                               selectedProject = (ICProject)items[0].getData(); // its a single select so this is ok
+                               configViewer.setInput(getConfigurations(selectedProject));
+                               configViewer.refresh();
+                               configTable.select(0);
+                               configTable.notifyListeners(SWT.Selection, new Event());
+                       }
+               });
+               
+               
+               configTable.addSelectionListener(new SelectionAdapter() {
+                       @Override public void widgetSelected(SelectionEvent e) {
+                               TableItem[] items = configTable.getSelection();
+                               selectedConfiguration = (ICConfigurationDescription)items[0].getData();
+                               updateWidgetEnablements();
+                       }
+               });
+               
+               if(openProjects.isEmpty()) {
+                       setErrorMessage(Messages.ProjectSettingsWizardPage_noOpenProjects);
+               }
+               
+               
+               if((initialProject == null || !initialProject.isOpen()) && !openProjects.isEmpty()) {
+                       initialProject = openProjects.get(0).getProject();
+               }
+                       
+               if(initialProject != null) {
+                       String initialProjectName = initialProject.getName();
+                       for(int i = 0; i < openProjects.size(); i++) {
+                               ICProject tableProject = openProjects.get(i);
+                               if(tableProject.getElementName().equals(initialProjectName)) {
+                                       projectTable.select(i);
+                                       configViewer.setInput(getConfigurations(tableProject));
+                                       configViewer.refresh();
+                                       configTable.select(0);
+                                       selectedProject = tableProject;
+                                       selectedConfiguration = (ICConfigurationDescription)configTable.getSelection()[0].getData();
+                                       break;
+                               }
+                       }
+               }
+       }
+       
+       
+       private static List<ICConfigurationDescription> getConfigurations(ICProject project) {
+               // get a read-only project description, no need to waste memory
+               ICProjectDescription description = CCorePlugin.getDefault().getProjectDescription(project.getProject(), false);
+               return Arrays.asList(description.getConfigurations());
+       }
+       
+       
+       private static List<ICProject> getAllOpenCProjects() {
+        List<ICProject> projects = new ArrayList<ICProject>();
+               try {
+               for(ICProject project : CoreModel.getDefault().getCModel().getCProjects()) {
+                   if(project.getProject().isOpen()) {
+                       projects.add(project);
+                               }
+               }
+               } catch(CModelException e) {
+                       CUIPlugin.log(e);
+               }
+               return projects;
+       }
+       
+       
+       protected void createSettingsSelectionGroup(Composite parent) {
+               Composite settingsSelectionGroup = new Composite(parent, SWT.NONE);
+               settingsSelectionGroup.setLayout(new GridLayout());
+               settingsSelectionGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
+               settingsSelectionGroup.setFont(parent.getFont());
+       
+               Label label = new Label(settingsSelectionGroup, SWT.NONE);
+               label.setText(strategy.getMessage(MessageType.SETTINGS));
+               
+               Table table = new Table(settingsSelectionGroup, SWT.CHECK | SWT.BORDER);
+               table.setLayoutData(new GridData(GridData.FILL_BOTH));
+               
+               
+               settingsViewer = new CheckboxTableViewer(table);
+               settingsViewer.setContentProvider(new ListContentProvider());
+               
+               settingsViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+                       public void selectionChanged(SelectionChangedEvent event) {
+                               updateWidgetEnablements();
+                       }
+               });
+               
+               LabelProvider settingsProcessorLabelProvider = new LabelProvider() {
+                       @Override public Image getImage(Object element) {
+                               return ((ISettingsProcessor)element).getIcon();
+                       }
+                       @Override public String getText(Object element) {
+                               return ((ISettingsProcessor)element).getDisplayName();
+                       }
+               };
+               
+               settingsViewer.setLabelProvider(settingsProcessorLabelProvider); 
+               settingsViewer.setInput(processors);
+               settingsViewer.setAllChecked(true);
+               
+               
+               Composite buttonComposite = new Composite(settingsSelectionGroup, SWT.NONE);
+               GridLayout layout = new GridLayout(2, true);
+        layout.marginHeight= layout.marginWidth= 0;
+        buttonComposite.setLayout(layout);
+        buttonComposite.setLayoutData(new GridData());
+        
+               Button selectButton = new Button(buttonComposite, SWT.PUSH);
+               selectButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               selectButton.setText(Messages.ProjectSettingsWizardPage_selectAll);
+               
+               selectButton.addSelectionListener(new SelectionAdapter() {
+                       @Override public void widgetSelected(SelectionEvent e) {
+                               settingsViewer.setAllChecked(true);
+                               updateWidgetEnablements();
+                       }
+               });
+               
+               Button deselectButton = new Button(buttonComposite, SWT.PUSH);
+               deselectButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               deselectButton.setText(Messages.ProjectSettingsWizardPage_deselectAll);
+               
+               deselectButton.addSelectionListener(new SelectionAdapter() {
+                       @Override public void widgetSelected(SelectionEvent e) {
+                               settingsViewer.setAllChecked(false);
+                               updateWidgetEnablements();
+                       }
+               });
+       }
+       
+       
+       protected void createFileSelectionGroup(Composite parent) {
+               Composite fileSelectionGroup = new Composite(parent, SWT.NONE);
+               fileSelectionGroup.setLayout(new GridLayout(2, false));
+               fileSelectionGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               fileSelectionGroup.setFont(parent.getFont());
+               
+               Label label = new Label(fileSelectionGroup, SWT.NONE);
+               label.setText(strategy.getMessage(MessageType.FILE));
+               GridData gridData = new GridData();
+               gridData.horizontalSpan = 2;
+               label.setLayoutData(gridData);
+               
+               filePathText = new Text(fileSelectionGroup, SWT.SINGLE | SWT.BORDER);
+               filePathText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               filePathText.addModifyListener(new ModifyListener() {
+                       public void modifyText(ModifyEvent e) {
+                               updateWidgetEnablements();
+                               strategy.fileSelected(ProjectSettingsWizardPage.this);
+                       } 
+               });
+               
+               Button browseButton = new Button(fileSelectionGroup, SWT.PUSH);
+               browseButton.setText(Messages.ProjectSettingsWizardPage_browse);
+               browseButton.setLayoutData(new GridData());
+               browseButton.addSelectionListener(new SelectionAdapter() {
+                       @Override public void widgetSelected(SelectionEvent e) {
+                               int type = (strategy instanceof ProjectSettingsImportStrategy) ? SWT.OPEN : SWT.SAVE;
+                               FileDialog fileDialog = new FileDialog(getShell(), type);
+                               fileDialog.setFilterExtensions(new String[] {"*." + FILENAME_EXTENSION}); //$NON-NLS-1$
+                               String filePath = fileDialog.open();
+                               if(filePath != null)
+                                       filePathText.setText(filePath);
+                       }
+               });
+       }
+
+       
+
+
+//     protected void createCheckboxSelectionGroup(Composite parent) {
+//             Composite checkboxSelectGroup = new Composite(parent, SWT.NONE);
+//             checkboxSelectGroup.setLayout(new GridLayout());
+//             checkboxSelectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+//             checkboxSelectGroup.setFont(parent.getFont());
+//             
+//             final Button checkBox = new Button(checkboxSelectGroup, SWT.CHECK);
+//             checkBox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+//             checkBox.setText(strategy.getMessage(CHECKBOX));
+//             
+//             checkBox.addSelectionListener(new SelectionAdapter() {
+//                     @Override public void widgetSelected(SelectionEvent e) {
+//                             strategy.handleCheckboxClick(ProjectSettingsWizardPage.this, checkBox.getSelection());
+//                     }
+//             });
+//     }
+       
+
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/SettingsImportExportException.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/SettingsImportExportException.java
new file mode 100644 (file)
index 0000000..561f463
--- /dev/null
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.settingswizards;
+
+/**
+ * An exception that represents a problem with importing or exporting
+ * settings.
+ * 
+ * @since 5.1
+ */
+public class SettingsImportExportException extends Exception {
+
+       public SettingsImportExportException() {
+       }
+
+       public SettingsImportExportException(String message) {
+               super(message);
+       }
+
+       public SettingsImportExportException(Throwable t) {
+               super(t);
+       }
+
+       public SettingsImportExportException(String message, Throwable t) {
+               super(message, t);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/SettingsProcessor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/SettingsProcessor.java
new file mode 100644 (file)
index 0000000..7f150d4
--- /dev/null
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.settingswizards;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.w3c.dom.Element;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+import org.eclipse.cdt.core.settings.model.ICFolderDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+
+/**
+ * Base class implementing standard import and export functionality
+ * for a section of the file.
+ * 
+ * @author Mike Kucera
+ * @since 5.1
+ */
+public abstract class SettingsProcessor implements ISettingsProcessor {
+
+       protected static final String NONE = ""; //$NON-NLS-1$
+       protected static final String CDATA = "CDATA"; //$NON-NLS-1$
+       
+       protected static final String NAME_ATTRIBUTE = "name"; //$NON-NLS-1$
+       protected static final String LANGUAGE_ELEMENT = "language"; //$NON-NLS-1$
+       
+       
+       /**
+        * Returns a constant from the ICSettingEntry interface.
+        */
+       protected abstract int getSettingsType();
+       
+       
+       protected abstract void writeSettings(ContentHandler content, ICLanguageSettingEntry setting)
+               throws SettingsImportExportException;
+       
+       
+       protected abstract void readSettings(ICLanguageSetting setting, Element language) 
+               throws SettingsImportExportException;
+       
+       
+       /**
+        * Outputs a newline (\n) to the given ContentHandler.
+        */
+       protected static void newline(ContentHandler handler) throws SAXException {
+               handler.ignorableWhitespace("\n".toCharArray(), 0, 1); //$NON-NLS-1$
+       }
+       
+       
+
+       public void writeSectionXML(ICFolderDescription projectRoot, ContentHandler content) throws SettingsImportExportException {
+               ICLanguageSetting[] languages = projectRoot.getLanguageSettings();
+               AttributesImpl attributes = new AttributesImpl();
+               
+               try {
+                       for(ICLanguageSetting language : languages) {
+                               //TODO for some reason language.getLanguageId() is returning null
+                               String languageName = language.getName();
+                               attributes.clear();
+                               attributes.addAttribute(NONE, NONE, NAME_ATTRIBUTE, CDATA, languageName);
+                               content.startElement(NONE, NONE, LANGUAGE_ELEMENT, attributes);
+                               newline(content);
+                               
+                               ICLanguageSettingEntry[] settings = language.getSettingEntries(getSettingsType());
+                               
+                               for(ICLanguageSettingEntry setting : settings) {
+                                       if(!setting.isBuiltIn()) {
+                                               writeSettings(content, setting);
+                                       }
+                               }
+                               
+                               newline(content);
+                               content.endElement(NONE, NONE, LANGUAGE_ELEMENT);
+                               newline(content);
+                       }
+               
+               } catch(SAXException e) {
+                       throw new SettingsImportExportException(e);
+               }
+       }
+       
+       
+       
+       public void readSectionXML(ICFolderDescription projectRoot, Element section) throws SettingsImportExportException {
+               ICLanguageSetting[] languageSettings = projectRoot.getLanguageSettings();
+               
+               Map<String,ICLanguageSetting> languageMap = new HashMap<String,ICLanguageSetting>();
+               for(ICLanguageSetting language : languageSettings) {
+                       languageMap.put(language.getName(), language);
+               }
+       
+               List<Element> elements = XMLUtils.extractChildElements(section, LANGUAGE_ELEMENT); // throws SettingsImportExportException
+               for(Element languageElement : elements) {
+                       String languageName = languageElement.getAttribute(NAME_ATTRIBUTE);
+                       ICLanguageSetting setting = languageMap.get(languageName);
+                       if(setting != null)
+                               readSettings(setting, languageElement);
+               }
+       }
+
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/XMLUtils.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/XMLUtils.java
new file mode 100644 (file)
index 0000000..404e94f
--- /dev/null
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.wizards.settingswizards;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+public class XMLUtils {
+
+       private XMLUtils() {}
+       
+       
+       public static List<Element> extractChildElements(Element node, String childElementName) throws SettingsImportExportException {
+               List<Element> extracted = new ArrayList<Element>();
+               
+               NodeList children = node.getChildNodes();
+               for(int i = 0; i < children.getLength(); i++) {
+                       Node child = children.item(i);
+                       switch(child.getNodeType()) {
+                       case Node.ELEMENT_NODE:
+                               Element element = (Element)child;
+                               if(element.getTagName().equals(childElementName)) {
+                                       extracted.add(element);
+                               }
+                               else
+                                       throw new SettingsImportExportException("Unknown tag: " + element.getTagName()); //$NON-NLS-1$
+                               break;
+                       case Node.TEXT_NODE:
+                               Text text = (Text)child;
+                               if(isWhitespace(text.getData()))
+                                       break;
+                               throw new SettingsImportExportException("Unknown text: '" + text.getData() + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+                       default:
+                               throw new SettingsImportExportException("Unknown node: " + child.getNodeName()); //$NON-NLS-1$
+                       }
+               }
+               
+               return extracted;
+       }
+       
+       
+       public static boolean isWhitespace(String s) {
+               if(s == null)
+                       return false;
+               
+               for(char c : s.toCharArray()) {
+                       if(!Character.isWhitespace(c)) {
+                               return false;
+                       }
+               }
+               
+               return true;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/messages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/messages.properties
new file mode 100644 (file)
index 0000000..cf92dd7
--- /dev/null
@@ -0,0 +1,46 @@
+##################################################################################
+# Copyright (c) 2008, 2009 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+##################################################################################
+ProjectSettingsExportStrategy_couldNotOpen=Could not open specified file
+ProjectSettingsExportStrategy_exportError=Export Error
+ProjectSettingsExportStrategy_exportFailed=Export failed
+ProjectSettingsExportStrategy_fileOpenError=File Open Error
+ProjectSettingsExportStrategy_xmlError=Export failure, error writing XML file
+
+ProjectSettingsImportStrategy_couldNotImport=File could not be imported
+ProjectSettingsImportStrategy_couldNotOpen=Could not open the specified file
+ProjectSettingsImportStrategy_fileOpenError=File Open Error
+ProjectSettingsImportStrategy_importError=Import Error
+ProjectSettingsImportStrategy_saveError=Could not save imported data
+
+ProjectSettingsWizardPage_Import_title=Import
+ProjectSettingsWizardPage_Import_message=Import C/C++ project settings
+ProjectSettingsWizardPage_Import_selectSettings=Select settings to import
+ProjectSettingsWizardPage_Import_checkBox=Import folder and file specific settings
+ProjectSettingsWizardPage_Import_file=Settings file
+ProjectSettingsWizardPage_Import_parseError=File could not be parsed
+ProjectSettingsWizardPage_Import_openError=File could not be opened
+
+ProjectSettingsWizardPage_Export_title=Export
+ProjectSettingsWizardPage_Export_message=Export C/C++ project settings for use in another workspace
+ProjectSettingsWizardPage_Export_selectSettings=Select settings to export
+ProjectSettingsWizardPage_Export_checkBox=Export folder and file specific settings
+ProjectSettingsWizardPage_Export_file=Export to file
+
+ProjectSettingsWizardPage_selectAll=Select All
+ProjectSettingsWizardPage_deselectAll=Deselect All
+ProjectSettingsWizardPage_selectProject=Select Project
+ProjectSettingsWizardPage_selectConfiguration=Select Configuration
+ProjectSettingsWizardPage_browse=Browse...
+ProjectSettingsWizardPage_noOpenProjects=There are no open projects
+ProjectSettingsWizardPage_active=Active
+
+ProjectSettingsWizardPage_Processor_Macros=Symbols
+ProjectSettingsWizardPage_Processor_Includes=Include Paths
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/AbstractWorkingSetConfigsContribution.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/AbstractWorkingSetConfigsContribution.java
new file mode 100644 (file)
index 0000000..bb4a174
--- /dev/null
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.actions.CompoundContributionItem;
+
+import com.ibm.icu.text.Collator;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * Common API of dynamic contribution of items to manipulate configurations of a working set.
+ * 
+ * @author Christian W. Damus (cdamus)
+ * 
+ * @since 6.0
+ */
+abstract class AbstractWorkingSetConfigsContribution extends CompoundContributionItem {
+
+       private IWorkingSetProxy workingSet;
+
+       private Comparator<IWorkingSetConfiguration> configOrdering = new Comparator<IWorkingSetConfiguration>() {
+               private Collator collator = Collator.getInstance();
+
+               public int compare(IWorkingSetConfiguration o1, IWorkingSetConfiguration o2) {
+                       return collator.compare(o1.getName(), o2.getName());
+               }
+       };
+
+       /**
+        * Initializes me without a working set. I figure it out, later. This is only appropriate usage for
+        * context-menu contribution, where the workbench selection is obvious.
+        */
+       public AbstractWorkingSetConfigsContribution() {
+               super();
+       }
+
+       /**
+        * Initializes me with my working set.
+        * 
+        * @param workingSet
+        *            my working set
+        */
+       AbstractWorkingSetConfigsContribution(IWorkingSetProxy workingSet) {
+               super();
+
+               this.workingSet = workingSet;
+       }
+
+       @Override
+       protected IContributionItem[] getContributionItems() {
+               if (getWorkingSet() == null) {
+                       return new IContributionItem[0];
+               }
+
+               // sort the configurations by name
+               List<IWorkingSetConfiguration> configs = new java.util.ArrayList<IWorkingSetConfiguration>(
+                               getWorkingSet().getConfigurations());
+               Collections.sort(configs, configOrdering);
+
+               IContributionItem[] result = new IContributionItem[configs.size()];
+               int i = 0;
+               for (IWorkingSetConfiguration next : configs) {
+                       result[i] = createContribution(next, i);
+                       i++;
+               }
+
+               return result;
+       }
+
+       /**
+        * Creates a contribution item for a specific configuration of my working set.
+        * 
+        * @param config
+        *            a configuration of my working set
+        * @param index
+        *            the index of the contribution in the composite
+        *            
+        * @return the contribution
+        */
+       protected abstract IContributionItem createContribution(IWorkingSetConfiguration config, int index);
+
+       /**
+        * Obtains my working set. It may be lazily determined from the current workbench selection.
+        * 
+        * @return my working set
+        */
+       protected IWorkingSetProxy getWorkingSet() {
+               if (workingSet == null) {
+                       ISelection sel = CUIPlugin.getActivePage().getSelection();
+                       if (sel instanceof IStructuredSelection) {
+                               IStructuredSelection ssel = (IStructuredSelection) sel;
+
+                               if (!ssel.isEmpty()) {
+                                       Object first = ssel.getFirstElement();
+                                       if (first instanceof IWorkingSet) {
+                                               workingSet = WorkingSetConfigurationManager.getDefault().getWorkingSet(
+                                                               ((IWorkingSet) first).getName());
+                                       }
+                               }
+                       }
+               }
+
+               return workingSet;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/AbstractWorkingSetsContribution.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/AbstractWorkingSetsContribution.java
new file mode 100644 (file)
index 0000000..5c091cd
--- /dev/null
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetManager;
+import org.eclipse.ui.actions.CompoundContributionItem;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * A dynamic contribution of sub-menus for working set configuration actions, with further sub-menus showing
+ * the configurations to choose from.
+ * 
+ * @author Christian W. Damus (cdamus)
+ * 
+ * @since 6.0
+ */
+abstract class AbstractWorkingSetsContribution extends CompoundContributionItem {
+
+       private IWorkingSetManager workingSetManager;
+
+       /**
+        * Initializes me without an identifier.
+        */
+       public AbstractWorkingSetsContribution() {
+               super();
+       }
+
+       /**
+        * Initializes me with my identifier.
+        * 
+        * @param id
+        *            my identifier
+        */
+       public AbstractWorkingSetsContribution(String id) {
+               super(id);
+       }
+
+       @Override
+       protected IContributionItem[] getContributionItems() {
+               // at most 5 recent working sets
+               List<IContributionItem> result = new java.util.ArrayList<IContributionItem>(5);
+
+               int i = 0;
+               for (IWorkingSet recent : getWorkingsetManager().getRecentWorkingSets()) {
+                       IWorkingSetProxy proxy = WorkingSetConfigurationManager.getDefault().getWorkingSet(
+                                       recent.getName());
+
+                       if (proxy != null) {
+                               IContributionItem item = createMenu(proxy, i++);
+                               if (item != null) {
+                                       result.add(item);
+                               }
+                       }
+               }
+
+               return result.toArray(new IContributionItem[result.size()]);
+       }
+
+       private IWorkingSetManager getWorkingsetManager() {
+               if (workingSetManager == null) {
+                       workingSetManager = CUIPlugin.getDefault().getWorkbench().getWorkingSetManager();
+               }
+
+               return workingSetManager;
+       }
+
+       private IContributionItem createMenu(IWorkingSetProxy workingSet, int index) {
+               IContributionItem result = null;
+               IWorkingSet ws = workingSet.resolve();
+               String label = NLS.bind(WorkingSetMessages.WorkingSetMenus_enumPattern, index + 1, ws.getLabel());
+               Collection<IWorkingSetConfiguration> configs = workingSet.getConfigurations();
+
+               if (!configs.isEmpty()) {
+                       MenuManager submenu = new MenuManager(label, ws.getName());
+                       result = submenu;
+
+                       submenu.add(createContribution(workingSet));
+               }
+
+               return result;
+       }
+
+       /**
+        * Creates a contribution item for a working set.
+        * 
+        * @param workingSet
+        *            a working set
+        * @return the contribution
+        */
+       protected abstract IContributionItem createContribution(IWorkingSetProxy workingSet);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ActivateWorkingSetConfigsContribution.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ActivateWorkingSetConfigsContribution.java
new file mode 100644 (file)
index 0000000..6684375
--- /dev/null
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * A dynamic contribution of items to activate configurations of a working set.
+ * 
+ * @author Christian W. Damus (cdamus)
+ * 
+ * @since 6.0
+ */
+public class ActivateWorkingSetConfigsContribution extends AbstractWorkingSetConfigsContribution {
+
+       /**
+        * Initializes me without a working set. I figure it out, later. This is only appropriate usage for
+        * context-menu contribution, where the workbench selection is obvious.
+        */
+       public ActivateWorkingSetConfigsContribution() {
+               super();
+       }
+
+       /**
+        * Initializes me with my working set.
+        * 
+        * @param workingSet
+        *            my working set
+        */
+       ActivateWorkingSetConfigsContribution(IWorkingSetProxy workingSet) {
+               super(workingSet);
+       }
+
+       @Override
+       protected IContributionItem createContribution(IWorkingSetConfiguration config, int index) {
+               return new ActionContributionItem(new ActivateConfigAction(config, index + 1));
+       }
+
+       //
+       // Nested classes
+       //
+
+       private static class ActivateConfigAction extends Action {
+               private IWorkingSetConfiguration workingSetConfig;
+
+               ActivateConfigAction(IWorkingSetConfiguration workingSetConfig, int ordinal) {
+                       super(NLS.bind(WorkingSetMessages.WorkingSetMenus_enumPattern, ordinal, workingSetConfig
+                                       .getName()));
+
+                       this.workingSetConfig = workingSetConfig;
+               }
+
+               @Override
+               public void run() {
+                       workingSetConfig.activate();
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ActivateWorkingSetsContribution.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ActivateWorkingSetsContribution.java
new file mode 100644 (file)
index 0000000..542404d
--- /dev/null
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import org.eclipse.jface.action.IContributionItem;
+
+/**
+ * A dynamic contribution of sub-menus to activate working sets, with further sub-menus showing the
+ * configurations to choose from.
+ * 
+ * @author Christian W. Damus (cdamus)
+ * 
+ * @since 6.0
+ */
+public class ActivateWorkingSetsContribution extends AbstractWorkingSetsContribution {
+
+       /**
+        * Initializes me.
+        */
+       public ActivateWorkingSetsContribution() {
+               super();
+       }
+
+       @Override
+       protected IContributionItem createContribution(IWorkingSetProxy workingSet) {
+               return new ActivateWorkingSetConfigsContribution(workingSet);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/BuildJob.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/BuildJob.java
new file mode 100644 (file)
index 0000000..4fdb5d5
--- /dev/null
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Intel Corporation, QNX Software Systems, and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *     QNX Software Systems - [272416] Rework the working set configurations
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import java.util.Collection;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * A job that builds a bunch of workspace projects or a working set configuration.
+ */
+public final class BuildJob extends Job {
+       private Collection<IProject> projects;
+       private IWorkingSetConfiguration workingSetConfig;
+
+       /**
+        * Initializes me with a bunch projects to build in their active configurations.
+        * 
+        * @param projects
+        *            the projects to build
+        */
+       public BuildJob(Collection<IProject> projects) {
+               super(Messages.WorkingSetConfigAction_21); 
+               this.projects = new java.util.ArrayList<IProject>(projects);
+       }
+
+       /**
+        * Initializes me with a working set configuration to build.
+        * 
+        * @param workingSetConfig
+        *            the working set configuration to build
+        */
+       public BuildJob(IWorkingSetConfiguration workingSetConfig) {
+               super(Messages.WorkingSetConfigAction_21); 
+               this.workingSetConfig = workingSetConfig;
+       }
+
+       @Override
+       protected IStatus run(IProgressMonitor monitor) {
+               if (projects != null) {
+                       return buildProjects(monitor);
+               } else {
+                       return buildWorkingSetConfig(monitor);
+               }
+       }
+
+       private IStatus buildProjects(IProgressMonitor monitor) {
+               try {
+                       for (IProject p : projects) {
+                               try {
+                                       setName(Messages.WorkingSetConfigAction_21 + p.getName()); 
+                                       p.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
+                               } catch (CoreException e) {
+                                       return new MultiStatus(CUIPlugin.PLUGIN_ID, 0, new IStatus[] { e.getStatus() },
+                                                       Messages.WorkingSetConfigAction_22, 
+                                                       null);
+                               }
+                               if (monitor.isCanceled()) {
+                                       return Status.CANCEL_STATUS;
+                               }
+                       }
+               } finally {
+                       monitor.done();
+               }
+               return Status.OK_STATUS;
+       }
+
+       private IStatus buildWorkingSetConfig(IProgressMonitor monitor) {
+               try {
+                       return workingSetConfig.build(monitor);
+               } finally {
+                       monitor.done();
+               }
+       }
+
+       @Override
+       public boolean belongsTo(Object family) {
+               return ResourcesPlugin.FAMILY_MANUAL_BUILD == family;
+       }
+
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/BuildWorkingSetConfigsContribution.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/BuildWorkingSetConfigsContribution.java
new file mode 100644 (file)
index 0000000..b6b5250
--- /dev/null
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * A dynamic contribution of items to build configurations of a working set.
+ * 
+ * @author Christian W. Damus (cdamus)
+ * 
+ * @since 6.0
+ */
+public class BuildWorkingSetConfigsContribution extends AbstractWorkingSetConfigsContribution {
+
+       /**
+        * Initializes me without a working set. I figure it out, later. This is only appropriate usage for
+        * context-menu contribution, where the workbench selection is obvious.
+        */
+       public BuildWorkingSetConfigsContribution() {
+               super();
+       }
+
+       /**
+        * Initializes me with my working set.
+        * 
+        * @param workingSet
+        *            my working set
+        */
+       BuildWorkingSetConfigsContribution(IWorkingSetProxy workingSet) {
+               super(workingSet);
+       }
+
+       @Override
+       protected IContributionItem createContribution(IWorkingSetConfiguration config, int index) {
+               return new ActionContributionItem(new BuildConfigAction(config, index + 1));
+       }
+
+       //
+       // Nested classes
+       //
+
+       private static class BuildConfigAction extends Action {
+               private IWorkingSetConfiguration workingSetConfig;
+
+               BuildConfigAction(IWorkingSetConfiguration workingSetConfig, int ordinal) {
+                       super(NLS.bind(WorkingSetMessages.WorkingSetMenus_enumPattern, ordinal, workingSetConfig
+                                       .getName()));
+
+                       this.workingSetConfig = workingSetConfig;
+               }
+
+               @Override
+               public void run() {
+                       new BuildJob(workingSetConfig).schedule();
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/BuildWorkingSetsContribution.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/BuildWorkingSetsContribution.java
new file mode 100644 (file)
index 0000000..c0707a7
--- /dev/null
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import org.eclipse.jface.action.IContributionItem;
+
+/**
+ * A dynamic contribution of sub-menus to build working sets, with further sub-menus showing the
+ * configurations to choose from.
+ * 
+ * @author Christian W. Damus (cdamus)
+ * 
+ * @since 6.0
+ */
+public class BuildWorkingSetsContribution extends AbstractWorkingSetsContribution {
+
+       /**
+        * Initializes me.
+        */
+       public BuildWorkingSetsContribution() {
+               super();
+       }
+
+       @Override
+       protected IContributionItem createContribution(IWorkingSetProxy workingSet) {
+               return new BuildWorkingSetConfigsContribution(workingSet);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetPage.java
new file mode 100644 (file)
index 0000000..76f16b6
--- /dev/null
@@ -0,0 +1,455 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.ITreeViewerListener;
+import org.eclipse.jface.viewers.TreeExpansionEvent;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetManager;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.IWorkingSetPage;
+
+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.ICModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.ui.CElementGrouping;
+import org.eclipse.cdt.ui.CElementSorter;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
+import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCLabelProvider;
+
+/**
+ * The C element working set page allows the user to create 
+ * and edit a C element working set.
+ * <p>
+ * Working set elements are presented as a C element tree.
+ * </p>
+ * 
+ */
+public class CElementWorkingSetPage extends WizardPage implements IWorkingSetPage {
+
+       final private static String PAGE_TITLE= WorkingSetMessages.CElementWorkingSetPage_title; 
+       final private static String PAGE_ID= "CElementWorkingSetPage"; //$NON-NLS-1$
+
+       private final static int SIZING_SELECTION_WIDGET_WIDTH = 50;
+       private final static int SIZING_SELECTION_WIDGET_HEIGHT = 200;
+
+       private Text fWorkingSetName;
+       private CheckboxTreeViewer fTree;
+       private IWorkingSet fWorkingSet;
+       private boolean fFirstCheck;            // set to true if selection is set in setSelection
+       private ITreeContentProvider fTreeContentProvider;
+
+       /**
+        * Creates a new instance of the receiver.
+        */
+       public CElementWorkingSetPage() {
+               super(PAGE_ID, PAGE_TITLE, CPluginImages.DESC_WIZABAN_C_APP);
+               setDescription(WorkingSetMessages.CElementWorkingSetPage_description); 
+               fFirstCheck= true;
+       }
+
+       /*
+        * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+        */
+       public void createControl(Composite parent) {
+               initializeDialogUnits(parent);
+
+               Composite composite= new Composite(parent, SWT.NULL);
+               composite.setLayout(new GridLayout());
+               composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+               setControl(composite);
+
+               Label label = new Label(composite, SWT.WRAP);
+               label.setText(WorkingSetMessages.CElementWorkingSetPage_name); 
+               GridData gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
+               label.setLayoutData(gd);
+
+               fWorkingSetName = new Text(composite, SWT.SINGLE | SWT.BORDER);
+               fWorkingSetName.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
+               fWorkingSetName.addModifyListener(
+                       new ModifyListener() {
+                               public void modifyText(ModifyEvent e) {
+                                       validateInput();
+                               }
+                       }
+               );
+               fWorkingSetName.setFocus();
+               
+               label = new Label(composite, SWT.WRAP);
+               label.setText(WorkingSetMessages.CElementWorkingSetPage_content); 
+               gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
+               label.setLayoutData(gd);
+
+               fTree = new CheckboxTreeViewer(composite);
+               gd = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL);
+               gd.heightHint = SIZING_SELECTION_WIDGET_HEIGHT;
+               gd.widthHint = SIZING_SELECTION_WIDGET_WIDTH;
+               fTree.getControl().setLayoutData(gd);
+
+               fTreeContentProvider= new CElementWorkingSetPageContentProvider();
+               fTree.setContentProvider(fTreeContentProvider);
+
+               AppearanceAwareLabelProvider cElementLabelProvider= 
+                       new AppearanceAwareLabelProvider(
+                               AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS,
+                               AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS | CElementImageProvider.SMALL_ICONS
+                       );
+               
+               fTree.setLabelProvider(new DecoratingCLabelProvider(cElementLabelProvider));
+               fTree.setSorter(new CElementSorter());
+               fTree.setUseHashlookup(true);
+
+               fTree.setInput(CoreModel.create(CUIPlugin.getWorkspace().getRoot()));
+
+               fTree.addCheckStateListener(new ICheckStateListener() {
+                       public void checkStateChanged(CheckStateChangedEvent event) {
+                               handleCheckStateChange(event);
+                       }
+               });
+
+               fTree.addTreeListener(new ITreeViewerListener() {
+                       public void treeCollapsed(TreeExpansionEvent event) {
+                       }
+                       public void treeExpanded(TreeExpansionEvent event) {
+                               final Object element = event.getElement();
+                               if (fTree.getGrayed(element) == false)
+                                       BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
+                                               public void run() {
+                                                       setSubtreeChecked(element, fTree.getChecked(element), false);
+                                               }
+                                       });
+                       }
+               });
+
+               if (fWorkingSet != null) {
+                       fWorkingSetName.setText(fWorkingSet.getName());
+               }
+               initializeCheckedState();
+               validateInput();
+
+               Dialog.applyDialogFont(composite);
+               // TODO Set help for the page 
+//             CUIHelp.setHelp(fTree, ICHelpContextIds.C_WORKING_SET_PAGE);
+       }
+
+       /*
+        * @see org.eclipse.ui.dialogs.IWorkingSetPage#finish()
+        */
+       public void finish() {
+               String workingSetName= fWorkingSetName.getText();
+               ArrayList<Object> elements= new ArrayList<Object>(10);
+               findCheckedElements(elements, fTree.getInput());
+               if (fWorkingSet == null) {
+                       IWorkingSetManager workingSetManager= PlatformUI.getWorkbench().getWorkingSetManager();
+                       fWorkingSet= workingSetManager.createWorkingSet(workingSetName, elements.toArray(new IAdaptable[elements.size()]));
+               } else {
+                       // Add inaccessible resources
+                       IAdaptable[] oldItems= fWorkingSet.getElements();
+                       HashSet<IProject> closedWithChildren= new HashSet<IProject>(elements.size());
+                       for (IAdaptable oldItem : oldItems) {
+                               IResource oldResource= null;
+                               if (oldItem instanceof IResource) {
+                                       oldResource= (IResource)oldItem;
+                               } else {
+                                       oldResource= (IResource)oldItem.getAdapter(IResource.class);
+                               }
+                               if (oldResource != null && oldResource.isAccessible() == false) {
+                                       IProject project= oldResource.getProject();
+                                       if (closedWithChildren.contains(project) || elements.contains(project)) {
+                                               elements.add(oldItem);
+                                               elements.remove(project);
+                                               closedWithChildren.add(project);
+                                       }
+                               }
+                       }
+                       fWorkingSet.setName(workingSetName);
+                       fWorkingSet.setElements(elements.toArray(new IAdaptable[elements.size()]));
+               }
+       }       
+
+       /*
+        * @see org.eclipse.ui.dialogs.IWorkingSetPage#getSelection()
+        */
+       public IWorkingSet getSelection() {
+               return fWorkingSet;
+       }
+
+       /**
+        * Called when the checked state of a tree item changes.
+        * 
+        * @param event the checked state change event.
+        */
+       void handleCheckStateChange(final CheckStateChangedEvent event) {
+               BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
+                       public void run() {
+                               IAdaptable element= (IAdaptable) event.getElement();
+                               boolean state = event.getChecked();
+                               
+                               fTree.setGrayed(element, false);
+                               if (isExpandable(element)) {
+                                       setSubtreeChecked(element, state, true);
+                               }
+                               updateParentState(element, state);
+                               validateInput();
+                       }
+               });
+       }
+       
+       private boolean isExpandable(Object element) {
+               return (element instanceof ICProject || element instanceof ICContainer
+                               || element instanceof CElementGrouping
+                               || element instanceof ICModel || element instanceof IContainer);
+       }
+
+       private void updateParentState(Object child, boolean baseChildState) {
+               if (child == null)
+                       return;
+               if (child instanceof IAdaptable) {
+                       IResource resource= (IResource)((IAdaptable)child).getAdapter(IResource.class);
+                       if (resource != null && !resource.isAccessible())
+                               return;
+               }
+               Object parent= fTreeContentProvider.getParent(child);
+               if (parent == null)
+                       return;
+               
+               updateObjectState(parent, baseChildState);
+       }
+
+       private void updateObjectState(Object element, boolean baseChildState) {                
+
+               boolean allSameState= true;
+               Object[] children= fTreeContentProvider.getChildren(element);
+
+               for (int i= children.length -1; i >= 0; i--) {
+                       if (fTree.getChecked(children[i]) != baseChildState || fTree.getGrayed(children[i])) {
+                               allSameState= false;
+                               break;
+                       }
+               }
+       
+               fTree.setGrayed(element, !allSameState);
+               fTree.setChecked(element, !allSameState || baseChildState);
+               
+               updateParentState(element, baseChildState);
+       }
+
+       /**
+        * Sets the checked state of tree items based on the initial 
+        * working set, if any.
+        */
+       private void initializeCheckedState() {
+               BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
+                       public void run() {
+                               Object[] elements;
+                               if (fWorkingSet == null) {
+                                       // Use current part's selection for initialization
+                                       IWorkbenchPage page= CUIPlugin.getActivePage();
+                                       if (page == null)
+                                               return;
+                                       
+                                       IWorkbenchPart part= CUIPlugin.getActivePage().getActivePart();
+                                       if (part == null)
+                                               return;
+                                       
+                                       try {
+                                               elements= SelectionConverter.getStructuredSelection(part).toArray();
+                                               for (int i= 0; i < elements.length; i++) {
+                                                       if (elements[i] instanceof IResource) {
+                                                               ICElement ce= (ICElement)((IResource)elements[i]).getAdapter(ICElement.class);
+                                                               if (ce != null && ce.exists() &&  ce.getCProject().isOnSourceRoot((IResource)elements[i]))
+                                                                       elements[i]= ce;
+                                                       }
+                                               }
+                                       } catch (CModelException e) {
+                                               return;
+                                       }
+                               }
+                               else
+                                       elements= fWorkingSet.getElements();
+
+                               for (int i = 0; i < elements.length; i++) {
+                                       Object element = elements[i];
+                                       if (element instanceof IResource) {
+                                               IProject project= ((IResource)element).getProject();
+                                               if (!project.isAccessible()) {
+                                                       elements[i]= project;
+                                               } else {
+                                                       // for backwards compatibility: adapt to ICElement if possible
+                                                       if(CoreModel.hasCNature(project)) {
+                                                               ICElement cElement= CoreModel.getDefault().create((IResource)element);
+                                                               if (cElement != null) {
+                                                                       elements[i]= cElement;
+                                                               }
+                                                       }
+                                               }
+                                       } else if (element instanceof ICElement) {
+                                               ICProject cProject= ((ICElement)element).getCProject();
+                                               if (cProject != null && !cProject.getProject().isAccessible()) 
+                                                       elements[i]= cProject.getProject();
+                                       }
+                               }
+                               fTree.setCheckedElements(elements);
+                               HashSet<Object> parents = new HashSet<Object>();
+                               for (Object element : elements) {
+                                       if (isExpandable(element))
+                                               setSubtreeChecked(element, true, true);
+                                               
+                                       if (element instanceof IAdaptable) {
+                                               IResource resource= (IResource) ((IAdaptable)element).getAdapter(IResource.class);
+                                               if (resource != null && !resource.isAccessible())
+                                                       continue;
+                                       }
+                                       Object parent= fTreeContentProvider.getParent(element);
+                                       if (parent != null)
+                                               parents.add(parent);
+                               }
+                               
+                               for (Object object : parents)
+                                       updateObjectState(object, true);
+                       }
+               });
+       }
+
+       /*
+        * @see org.eclipse.ui.dialogs.IWorkingSetPage#setSelection(org.eclipse.ui.IWorkingSet)
+        */
+       public void setSelection(IWorkingSet workingSet) {
+               if (workingSet == null) {
+                       throw new IllegalArgumentException("Working set must not be null"); //$NON-NLS-1$
+               }
+               fWorkingSet = workingSet;
+               if (getContainer() != null && fWorkingSetName != null) {
+                       fFirstCheck = false;
+                       fWorkingSetName.setText(workingSet.getName());
+                       initializeCheckedState();
+                       validateInput();
+               }
+       }       
+       /**
+        * Sets the checked state of the container's members.
+        * 
+        * @param parent the parent whose children should be checked/unchecked
+        * @param state true=check all members in the container. false=uncheck all 
+        *      members in the container.
+        * @param checkExpandedState true=recurse into sub-containers and set the 
+        *      checked state. false=only set checked state of members of this container
+        */
+       private void setSubtreeChecked(Object parent, boolean state, boolean checkExpandedState) {
+               if (!(parent instanceof IAdaptable))
+                       return;
+               IContainer container= (IContainer)((IAdaptable)parent).getAdapter(IContainer.class);
+               if ((!fTree.getExpandedState(parent) && checkExpandedState) || (container != null && !container.isAccessible()))
+                       return;
+               
+               Object[] children= fTreeContentProvider.getChildren(parent);
+               for (int i= children.length - 1; i >= 0; i--) {
+                       Object element= children[i];
+                       if (state) {
+                               fTree.setChecked(element, true);
+                               fTree.setGrayed(element, false);
+                       }
+                       else
+                               fTree.setGrayChecked(element, false);
+                       if (isExpandable(element))
+                               setSubtreeChecked(element, state, true);
+               }
+       }
+
+       /**
+        * Validates the working set name and the checked state of the 
+        * resource tree.
+        */
+       void validateInput() {
+               String errorMessage = null;
+               String newText = fWorkingSetName.getText();
+
+               if (newText.equals(newText.trim()) == false) {
+                       errorMessage = WorkingSetMessages.CElementWorkingSetPage_warning_nameMustNotBeEmpty; 
+               }
+               if (newText.equals("")) { //$NON-NLS-1$
+                       if (fFirstCheck) {
+                               setPageComplete(false);
+                               fFirstCheck= false;
+                               return;
+                       }
+                       errorMessage = WorkingSetMessages.CElementWorkingSetPage_warning_nameMustNotBeEmpty; 
+               }
+
+               fFirstCheck= false;
+
+               if (errorMessage == null && (fWorkingSet == null || newText.equals(fWorkingSet.getName()) == false)) {
+                       IWorkingSet[] workingSets = PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSets();
+                       for (IWorkingSet workingSet : workingSets) {
+                               if (newText.equals(workingSet.getName())) {
+                                       errorMessage = WorkingSetMessages.CElementWorkingSetPage_warning_workingSetExists; 
+                               }
+                       }
+               }
+               
+               if (errorMessage == null && fTree.getCheckedElements().length == 0) {
+                       String infoMessage = WorkingSetMessages.CElementWorkingSetPage_warning_resourceMustBeChecked; 
+                       setMessage(infoMessage, INFORMATION);
+               }
+               setErrorMessage(errorMessage);
+               setPageComplete(errorMessage == null);
+       }
+
+       /**
+        * Collects all checked elements of the given parent.
+        * 
+        * @param checkedElements the output, list of checked elements
+        * @param parent the parent to collect checked elements in
+        */
+       private void findCheckedElements(List<Object> checkedElements, Object parent) {
+               Object[] children= fTreeContentProvider.getChildren(parent);
+               for (Object element : children) {
+                       if (fTree.getGrayed(element))
+                               findCheckedElements(checkedElements, element);
+                       else if (fTree.getChecked(element))
+                               checkedElements.add(element);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetPageContentProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetPageContentProvider.java
new file mode 100644 (file)
index 0000000..101f296
--- /dev/null
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICProject;
+
+import org.eclipse.cdt.internal.ui.BaseCElementContentProvider;
+
+class CElementWorkingSetPageContentProvider extends BaseCElementContentProvider {
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.BaseCElementContentProvider#getChildren(java.lang.Object)
+        */
+       @Override
+       public Object[] getChildren(Object element) {
+               if (element instanceof IWorkspaceRoot) {
+                       IWorkspaceRoot root = (IWorkspaceRoot)element;
+                       IProject[] projects = root.getProjects();
+                       List<ICProject> list = new ArrayList<ICProject>(projects.length);
+                       for (int i = 0; i < projects.length; i++) {
+                               if (CoreModel.hasCNature(projects[i])) {
+                                       list.add(CoreModel.getDefault().create(projects[i]));
+                               }
+                       }
+                       return list.toArray();
+               }
+               return super.getChildren(element);
+       }
+}      
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetUpdater.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/CElementWorkingSetUpdater.java
new file mode 100644 (file)
index 0000000..5ee4d6b
--- /dev/null
@@ -0,0 +1,305 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.IJobChangeEvent;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetUpdater;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ElementChangedEvent;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICElementDelta;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IElementChangedListener;
+
+
+public class CElementWorkingSetUpdater implements IWorkingSetUpdater, IElementChangedListener {
+
+       private static class SingletonRule implements ISchedulingRule {
+               public static final ISchedulingRule INSTANCE = new SingletonRule();
+               public boolean contains(ISchedulingRule rule) {
+                       return rule == this;
+               }
+               public boolean isConflicting(ISchedulingRule rule) {
+                       return rule == this;
+               }
+       }
+
+       private static class WorkingSetCheck extends Job {
+               private final IWorkingSet fWorkingSet;
+               WorkingSetCheck(final IWorkingSet workingSet) {
+                       super("Check WorkingSet"); //$NON-NLS-1$
+                       fWorkingSet= workingSet;
+               }
+               /*
+                * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
+                */
+               @Override
+               protected IStatus run(IProgressMonitor monitor) {
+                       synchronized (fWorkingSet) {
+                               checkElementExistence(fWorkingSet);
+                       }
+                       return Status.OK_STATUS;
+               }
+       }
+
+       public static final String ID= "org.eclipse.cdt.ui.CElementWorkingSetPage"; //$NON-NLS-1$
+       
+       private List<IWorkingSet> fWorkingSets;
+       
+       private static class WorkingSetDelta {
+               private IWorkingSet fWorkingSet;
+               private List<Object> fElements;
+               private boolean fChanged;
+               public WorkingSetDelta(IWorkingSet workingSet) {
+                       fWorkingSet= workingSet;
+                       synchronized (fWorkingSet) {
+                               fElements= new ArrayList<Object>(Arrays.asList(fWorkingSet.getElements()));
+                       }
+               }
+               public int indexOf(Object element) {
+                       return fElements.indexOf(element);
+               }
+               public void set(int index, Object element) {
+                       if (element == null) {
+                               remove(index);
+                       } else {
+                               fElements.set(index, element);
+                               fChanged= true;
+                       }
+               }
+               public void remove(int index) {
+                       if (fElements.remove(index) != null) {
+                               fChanged= true;
+                       }
+               }
+               public void process() {
+                       if (fChanged) {
+                               fWorkingSet.setElements(fElements.toArray(new IAdaptable[fElements.size()]));
+                       }
+               }
+       }
+       
+       public CElementWorkingSetUpdater() {
+               fWorkingSets= new ArrayList<IWorkingSet>();
+               CoreModel.getDefault().addElementChangedListener(this);
+       }
+       
+       /**
+        * {@inheritDoc}
+        */
+       public void add(final IWorkingSet workingSet) {
+               // delay the check for existence - this may be called very early in the bootstrap
+               // otherwise it is causing all kinds of weird exceptions
+               Job check= new WorkingSetCheck(workingSet);
+               check.setUser(false);
+               check.setPriority(Job.SHORT);
+               // make jobs run sequential
+               check.setRule(SingletonRule.INSTANCE);
+               check.schedule(2000 + fWorkingSets.size() * 100);
+               check.addJobChangeListener(new JobChangeAdapter() {
+                       @Override
+                       public void done(IJobChangeEvent event) {
+                               synchronized (fWorkingSets) {
+                                       fWorkingSets.add(workingSet);
+                               }
+                       }});
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public boolean remove(IWorkingSet workingSet) {
+               boolean result;
+               synchronized(fWorkingSets) {
+                       result= fWorkingSets.remove(workingSet);
+               }
+               return result;
+       }
+       
+       /**
+        * {@inheritDoc}
+        */
+       public boolean contains(IWorkingSet workingSet) {
+               synchronized(fWorkingSets) {
+                       return fWorkingSets.contains(workingSet);
+               }
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void dispose() {
+               synchronized(fWorkingSets) {
+                       fWorkingSets.clear();
+               }
+               CoreModel.getDefault().removeElementChangedListener(this);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public void elementChanged(ElementChangedEvent event) {
+               IWorkingSet[] workingSets;
+               synchronized(fWorkingSets) {
+                       workingSets= fWorkingSets.toArray(new IWorkingSet[fWorkingSets.size()]);
+               }
+               for (int w= 0; w < workingSets.length; w++) {
+                       WorkingSetDelta workingSetDelta= new WorkingSetDelta(workingSets[w]);
+                       processCElementDelta(workingSetDelta, event.getDelta());
+                       IResourceDelta[] resourceDeltas= event.getDelta().getResourceDeltas();
+                       if (resourceDeltas != null) {
+                               for (int r= 0; r < resourceDeltas.length; r++) {
+                                       processResourceDelta(workingSetDelta, resourceDeltas[r]);
+                               }
+                       }
+                       workingSetDelta.process();
+               }
+       }
+
+       private void processCElementDelta(WorkingSetDelta result, ICElementDelta delta) {
+               ICElement cElement= delta.getElement();
+               int index= result.indexOf(cElement);
+               int type= cElement.getElementType();
+               int kind= delta.getKind();
+               int flags= delta.getFlags();
+               if (type == ICElement.C_PROJECT && kind == ICElementDelta.CHANGED) {
+                       if (index != -1 && (flags & ICElementDelta.F_CLOSED) != 0) {
+                               result.set(index, ((ICProject)cElement).getProject());
+                       } else if ((flags & ICElementDelta.F_OPENED) != 0) {
+                               index= result.indexOf(((ICProject)cElement).getProject());
+                               if (index != -1)
+                                       result.set(index, cElement);
+                       }
+               } else if (type == ICElement.C_PROJECT && kind == ICElementDelta.REMOVED) {
+                       if (index != -1)
+                               result.set(index, ((ICProject)cElement).getProject());
+               } else if (type == ICElement.C_PROJECT && kind == ICElementDelta.ADDED) {
+                       index= result.indexOf(((ICProject)cElement).getProject());
+                       if (index != -1)
+                               result.set(index, cElement);
+               } else if (index != -1) {
+                       if (kind == ICElementDelta.REMOVED) {
+                               if ((flags & ICElementDelta.F_MOVED_TO) != 0) {
+                                       result.set(index, delta.getMovedToElement());
+                               } else {
+                                       result.remove(index);
+                               }
+                       }
+               }
+               IResourceDelta[] resourceDeltas= delta.getResourceDeltas();
+               if (resourceDeltas != null) {
+                       for (int i= 0; i < resourceDeltas.length; i++) {
+                               processResourceDelta(result, resourceDeltas[i]);
+                       }
+               }
+               ICElementDelta[] children= delta.getAffectedChildren();
+               for (int i= 0; i < children.length; i++) {
+                       processCElementDelta(result, children[i]);
+               }
+       }
+       
+       private void processResourceDelta(WorkingSetDelta result, IResourceDelta delta) {
+               IResource resource= delta.getResource();
+               int type= resource.getType();
+               int index= result.indexOf(resource);
+               int kind= delta.getKind();
+               int flags= delta.getFlags();
+               if (kind == IResourceDelta.CHANGED && type == IResource.PROJECT && index != -1) {
+                       if ((flags & IResourceDelta.OPEN) != 0) {
+                               result.set(index, resource);
+                       }
+               }
+               if (index != -1 && kind == IResourceDelta.REMOVED) {
+                       if ((flags & IResourceDelta.MOVED_TO) != 0) {
+                               result.set(index, 
+                                       ResourcesPlugin.getWorkspace().getRoot().findMember(delta.getMovedToPath()));
+                       } else {
+                               result.remove(index);
+                       }
+               }
+               
+               // Don't dive into closed or opened projects
+               if (projectGotClosedOrOpened(resource, kind, flags))
+                       return;
+               
+               IResourceDelta[] children= delta.getAffectedChildren();
+               for (int i= 0; i < children.length; i++) {
+                       processResourceDelta(result, children[i]);
+               }
+       }
+
+       private boolean projectGotClosedOrOpened(IResource resource, int kind, int flags) {
+               return resource.getType() == IResource.PROJECT 
+                       && kind == IResourceDelta.CHANGED 
+                       && (flags & IResourceDelta.OPEN) != 0;
+       }
+       
+       private static void checkElementExistence(IWorkingSet workingSet) {
+               List<IAdaptable> elements= new ArrayList<IAdaptable>(Arrays.asList(workingSet.getElements()));
+               boolean changed= false;
+               for (Iterator<IAdaptable> iter= elements.iterator(); iter.hasNext();) {
+                       IAdaptable element= iter.next();
+                       boolean remove= false;
+                       if (element instanceof ICElement) {
+                               ICElement cElement= (ICElement)element;
+                               // If we have directly a project then remove it when it
+                               // doesn't exist anymore. However if we have a sub element
+                               // under a project only remove the element if the parent
+                               // project is open. Otherwise we would remove all elements
+                               // in closed projects.
+                               if (cElement instanceof ICProject) {
+                                       remove= !cElement.exists();
+                               } else {
+                                       IProject project= cElement.getCProject().getProject();
+                                       remove= project.isOpen() && !cElement.exists();
+                               }
+                       } else if (element instanceof IResource) {
+                               IResource resource= (IResource)element;
+                               // See comments above
+                               if (resource instanceof IProject) {
+                                       remove= !resource.exists();
+                               } else {
+                                       IProject project= resource.getProject();
+                                       remove= (project != null ? project.isOpen() : true) && !resource.exists();
+                               }
+                       } else if (element == null) {
+                               // should not happen anyway, but who knows?
+                               remove= true;
+                       }
+                       if (remove) {
+                               iter.remove();
+                               changed= true;
+                       }
+               }
+               if (changed) {
+                       workingSet.setElements(elements.toArray(new IAdaptable[elements.size()]));
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetConfiguration.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetConfiguration.java
new file mode 100644 (file)
index 0000000..a57d734
--- /dev/null
@@ -0,0 +1,181 @@
+/*******************************************************************************
+ * Copyright (c) 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import java.util.Collection;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+
+/**
+ * <p>
+ * The protocol for working set configurations. A working set configuration specifies, at a minimum, a
+ * {@linkplain ICConfigurationDescription build configuration} for each C/C++ project in the working set.
+ * {@linkplain #activate() activating} the configuration applies these build configurations to the respective
+ * projects as their active build configurations.
+ * </p>
+ * <p>
+ * Implementations of this interface may choose to manage more configuration settings than are captured by the
+ * active build configuration. They are, then, responsible for persistence, editing, and application of these
+ * settings.
+ * </p>
+ * <p>
+ * A working set configuration is considered to be {@linkplain #isActive() active} if all of the projects in
+ * the working set are configured to build according to the configuration specified by the working set
+ * configuration. It is an implementation detail (i.e., unspecified) what it means for a working set that has
+ * recorded settings for projects that are not currently {@linkplain IResource#isAccessible() accessible} in
+ * the workspace. However, for projects that are accessible and are included in the working set, but for which
+ * the working set configuration has no settings, such projects are implicitly in the working set
+ * configuration and it specifies their current configuration settings. Thus, in the extreme case, a
+ * working-set configuration that includes none of the projects that currently are members of the working set,
+ * is active.
+ * </p>
+ * 
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
+ * 
+ * @author Christian W. Damus (cdamus)
+ * 
+ * @since 6.0
+ */
+public interface IWorkingSetConfiguration extends IWorkingSetConfigurationElement {
+       /**
+        * Obtains the working set element that contains me.
+        * 
+        * @return my working set
+        */
+       IWorkingSetProxy getWorkingSet();
+
+       /**
+        * Queries my name.
+        * 
+        * @return my name
+        */
+       String getName();
+
+       /**
+        * Obtains the project configuration element for the specified project.
+        * 
+        * @param projectName
+        *            a project name
+        * 
+        * @return that project's configuration element
+        * 
+        * @throws IllegalArgumentException
+        *             if the specified project is not a member of my working set
+        * 
+        * @see #getProjectConfigurations()
+        */
+       IWorkingSetProjectConfiguration getProjectConfiguration(String projectName);
+
+       /**
+        * Obtains the configuration elements for all of the projects in my working set. These include any
+        * projects that were not in my working set when I was last updated, and does not include any projects
+        * that were in my working set when I was last updated but that no longer are.
+        * 
+        * @return my project configuration elements
+        */
+       Collection<IWorkingSetProjectConfiguration> getProjectConfigurations();
+
+       /**
+        * Queries whether I am currently active in the workspace. I am active if and only if for every the
+        * projects in my working set, its active configuration is the one that I specify for it. As a special
+        * case, the configurations of an empty working set can never be active.
+        * 
+        * @return whether I am currently active in the workspace
+        * 
+        * @see #activate()
+        */
+       boolean isActive();
+
+       /**
+        * Updates the workspace to set, for each project in my working set, the active configuration that I
+        * specify for it. This method has no effect if I am already active.
+        * 
+        * @see #isActive()
+        */
+       void activate();
+
+       /**
+        * Builds my project configurations in the workspace.
+        * 
+        * @param monitor
+        *            for reporting progress of the working-set build
+        * @return the aggregate status of the individual
+        *         {@linkplain IWorkingSetProjectConfiguration#build(IProgressMonitor) project builds}
+        */
+       IStatus build(IProgressMonitor monitor);
+
+       /**
+        * Creates a <i>snapshot</i> (also known as a "working copy") of myself, providing a mutable view suitable
+        * for editing.
+        * 
+        * @param workingSet
+        *            my parent working set snapshot
+        * @param workspace
+        *            a workspace snapshot that captures the baseline state of the workspace and the working set
+        *            configurations that are to be edited
+        * 
+        * @return a working-copy snapshot of myself
+        */
+       ISnapshot createSnapshot(IWorkingSetProxy.ISnapshot workingSet, WorkspaceSnapshot workspace);
+
+       //
+       // Nested types
+       //
+
+       /**
+        * The snapshot ("working copy") view of a working set configuration. It defines additional API for the
+        * manipulation of working set configurations.
+        * 
+        * @noimplement This interface is not intended to be implemented by clients.
+        * @noextend This interface is not intended to be extended by clients.
+        * 
+        * @author Christian W. Damus (cdamus)
+        * 
+        * @since 6.0
+        */
+       interface ISnapshot extends IWorkingSetConfiguration, IWorkingSetConfigurationElement.ISnapshot {
+               IWorkingSetProxy.ISnapshot getWorkingSet();
+
+               /**
+                * <p>
+                * Queries whether I am read-only. Read-only working set configurations are used for the special case
+                * of showing what is the active configuration of the projects in a working set when none of the named
+                * working set configurations is active. Thus, a working set that has no user-defined named
+                * configurations does, at least, have its read-only active configuration.
+                * </p>
+                * <p>
+                * A working set only ever has at most one read-only configuration, though it may have multiple active
+                * configurations if some of its configurations are equivalent.
+                * </p>
+                * 
+                * @return whether I am the read-only active configuration of my working set
+                */
+               boolean isReadOnly();
+
+               /**
+                * Sets my name, which must be unique amongst the configurations in my working set.
+                * 
+                * @param name
+                *            my new, unique name
+                * 
+                * @throws IllegalArgumentException
+                *             if the new name is <code>null</code> or empty, or if it is already used by another
+                *             configuration of the same working set
+                */
+               void setName(String name);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetConfigurationElement.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetConfigurationElement.java
new file mode 100644 (file)
index 0000000..b060014
--- /dev/null
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IPersistable;
+
+/**
+ * The protocol for elements of the working-set configuration model, which can be persisted via
+ * {@linkplain IMemento mementos}.
+ * 
+ * @author Christian W. Damus (cdamus)
+ * 
+ * @since 6.0
+ * 
+ */
+public interface IWorkingSetConfigurationElement extends IPersistable {
+       /**
+        * Loads me from the specified memento.
+        * 
+        * @param memento
+        *            a memento in which I am persisted
+        */
+       void loadState(IMemento memento);
+
+       //
+       // Nested types
+       //
+
+       /**
+        * The protocol for mutable working-copies ("snapshots") of working set configuration model elements.
+        * 
+        * @author Christian W. Damus (cdamus)
+        * 
+        * @since 6.0
+        * 
+        * @see WorkspaceSnapshot
+        */
+       interface ISnapshot {
+               /**
+                * Obtains the workspace snapshot that describes the baseline state of the working-set configuration
+                * editing session of which I am a part.
+                * 
+                * @return my base workspace snapshot
+                */
+               WorkspaceSnapshot getWorkspaceSnapshot();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfiguration.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfiguration.java
new file mode 100644 (file)
index 0000000..3454e95
--- /dev/null
@@ -0,0 +1,170 @@
+/*******************************************************************************
+ * Copyright (c) 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import java.util.Collection;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+
+/**
+ * <p>
+ * The protocol for project configurations in a working set configuration. At a minimum, the project
+ * configuration specifies which build configuration is {@linkplain #getSelectedConfigurationID() selected} to
+ * be set as the project's active configuration. Implementations are free to add more configuration
+ * information than the selected build configuration.
+ * </p>
+ * <p>
+ * Note that project configurations are owned by working set configurations. Thus, different configurations of
+ * the same (or different) working set may specify different settings for the same project.
+ * </p>
+ * 
+ * @author Christian W. Damus (cdamus)
+ * 
+ * @since 6.0
+ */
+public interface IWorkingSetProjectConfiguration extends IWorkingSetConfigurationElement {
+       /**
+        * Obtains the working set configuration element that owns me.
+        * 
+        * @return my working set configuration
+        */
+       IWorkingSetConfiguration getWorkingSetConfiguration();
+
+       /**
+        * Queries the name of the project that I configure.
+        * 
+        * @return my project name
+        */
+       String getProjectName();
+
+       /**
+        * Resolves my project name to the actual project resource in the workspace.
+        * 
+        * @return my referenced project, or <code>null</code> if the project is not
+        *         {@linkplain IResource#isAccessible() accessible} in the workspace
+        */
+       IProject resolveProject();
+
+       /**
+        * Queries the ID of the build configuration that is currently selected for my project.
+        * 
+        * @return my selected build configuration ID
+        */
+       String getSelectedConfigurationID();
+
+       /**
+        * <p>
+        * Resolves my selected configuration reference to the C model's description handle for it.
+        * </p>
+        * <p>
+        * <b>Note</b> that, in the general case, it is possible for the configuration to resolve to a different
+        * object from one call to the next, but always representing the same configuration. However, in the case
+        * of a working-copy {@linkplain IWorkingSetProjectConfiguration.ISnapshot snapshot} of me, the result
+        * will always be the same object.
+        * </p>
+        * 
+        * @return the C model representation of my selected build configuration
+        * 
+        * @see #resolveConfigurations()
+        */
+       ICConfigurationDescription resolveSelectedConfiguration();
+
+       /**
+        * <p>
+        * Resolves the set of available configurations of my project.
+        * </p>
+        * <p>
+        * <b>Note</b> that, in the general case, it is possible for these configurations to resolve to different
+        * objects from one call to the next, but always representing the same configurations. However, in the
+        * case of a working-copy {@linkplain IWorkingSetProjectConfiguration.ISnapshot snapshot} of me, the
+        * results will always be the same objects.
+        * </p>
+        * 
+        * @return the C model representation of my selected available build configurations
+        * 
+        * @see #resolveSelectedConfiguration()
+        */
+       Collection<ICConfigurationDescription> resolveConfigurations();
+
+       /**
+        * Queries whether my project currently has my selected configuration active in the workspace.
+        * 
+        * @return whether I am my project's active configuration
+        * 
+        * @see #getSelectedConfigurationID()
+        * @see #activate()
+        */
+       boolean isActive();
+
+       /**
+        * Activates my selected configuration in the workspace, for my project.
+        * 
+        * @see #getSelectedConfigurationID()
+        * @see ISnapshot#setSelectedConfigurationID(String)
+        * @see #isActive()
+        */
+       void activate();
+
+       /**
+        * Builds my selected configuration in the workspace, for my project. If building the configuration
+        * actually requires activating it, and it was not already active, then it would be a good idea to return
+        * a warning status indicating that the active configuration had to be changed in order to effect the
+        * build.
+        * 
+        * @param monitor
+        *            a progress monitor to report build progress
+        * @return a status indicating any error or warning conditions in the invocation of the build
+        */
+       IStatus build(IProgressMonitor monitor);
+
+       /**
+        * Creates a <i>snapshot</i> (also known as a "working copy") of myself, providing a mutable view suitable
+        * for editing.
+        * 
+        * @param workingSetConfig
+        *            my parent working set configuration snapshot
+        * @param workspace
+        *            a workspace snapshot that captures the baseline state of the workspace and the working set
+        *            configurations that are to be edited
+        * 
+        * @return a working-copy snapshot of myself
+        */
+       ISnapshot createSnapshot(IWorkingSetConfiguration.ISnapshot workingSetConfig, WorkspaceSnapshot workspace);
+
+       //
+       // Nested types
+       //
+
+       /**
+        * The snapshot ("working copy") view of a working set project configuration.
+        * 
+        * @author Christian W. Damus (cdamus)
+        * 
+        * @since 6.0
+        */
+       interface ISnapshot extends IWorkingSetProjectConfiguration, IWorkingSetConfigurationElement.ISnapshot {
+               IWorkingSetConfiguration.ISnapshot getWorkingSetConfiguration();
+
+               /**
+                * Sets the ID of the build configuration that is currently selected for my project.
+                * 
+                * @param id
+                *            my selected build configuration ID
+                */
+               void setSelectedConfigurationID(String id);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfigurationController.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfigurationController.java
new file mode 100644 (file)
index 0000000..bfb1c82
--- /dev/null
@@ -0,0 +1,176 @@
+/*******************************************************************************
+ * Copyright (c) 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import org.eclipse.jface.viewers.IBaseLabelProvider;
+import org.eclipse.jface.viewers.IColorProvider;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.IFontProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+/**
+ * Protocol for the view controller for the project configurations pane of the working set configurations
+ * dialog. It takes care of coordinating the user gestures in that pane with the working-set configuration
+ * model and vice-versa.
+ * 
+ * @author Christian W. Damus (cdamus)
+ * 
+ * @since 6.0
+ * 
+ */
+public interface IWorkingSetProjectConfigurationController {
+       /**
+        * Queries the project configuration in the Working Set Configurations pane that I control.
+        * 
+        * @return the new working set configuration selection. May be <code>null</code> if there is no selection
+        */
+       IWorkingSetProjectConfiguration.ISnapshot getProjectConfiguration();
+
+       /**
+        * Notifies me that the check state of some element that I control in the sub-tree of my
+        * {@linkplain #getProjectConfiguration() project configuration} has changed its check-state. The
+        * controller context can be used to pass back reactions such as to veto the check-state change or to
+        * signal that some level of UI refresh is required.
+        * 
+        * @param element
+        *            an element that has been checked or unchecked
+        * @param checked
+        *            whether the <tt>element</tt> is now checked
+        * @param context
+        *            the controller context, used to communicate vetos, refreshes, etc.
+        */
+       void checkStateChanged(Object element, boolean checked, IControllerContext context);
+
+       /**
+        * Computes the initial check-box settings for my tree according to the current state of my
+        * {@linkplain #getProjectConfiguration() project configuration}.
+        * 
+        * @param context
+        *            context in which I can set initial check-states of my elements
+        */
+       void updateCheckState(IControllerContext context);
+
+       /**
+        * Obtains a content provider for the structure rooted at my {@linkplain #getProjectConfiguration()
+        * project configuration}. Note that this method will only be called once, and that the caller takes
+        * responsibility for {@linkplain IContentProvider#dispose() disposing} the content provider.
+        * 
+        * @return my content provider
+        */
+       ITreeContentProvider getContentProvider();
+
+       /**
+        * <p>
+        * Obtains a label provider for the structure rooted at my {@linkplain #getProjectConfiguration() project
+        * configuration}. Note that this method will only be called once, and that the caller takes
+        * responsibility for {@linkplain IBaseLabelProvider#dispose() disposing} the label provider.
+        * </p>
+        * <p>
+        * The viewer argument is useful to obtain information about default font and colors, for label providers
+        * that implement the optional {@link IFontProvider} and/or {@link IColorProvider} interfaces.
+        * </p>
+        * 
+        * @param viewer
+        *            the viewer for which I will provide labels
+        * 
+        * @return my label provider
+        */
+       ILabelProvider getLabelProvider(Viewer viewer);
+
+       //
+       // Nested types
+       //
+
+       /**
+        * An interface provided by the Manage Working Set Configurations dialog infrastructure to
+        * {@link IWorkingSetProjectConfigurationController}s for communication of state changes back to the UI.
+        * 
+        * @noimplement This interface is not intended to be implemented by clients.
+        * @noextend This interface is not intended to be extended by clients.
+        * 
+        * @author Christian W. Damus (damus)
+        * 
+        * @since 6.0
+        */
+       interface IControllerContext {
+               /**
+                * Queries whether the current working set configuration context is a read-only one. In such cases, I
+                * should probably disallow check-state changes and other editing.
+                * 
+                * @return whether the current working set configuration is read-only
+                * 
+                * @see IWorkingSetConfiguration.ISnapshot#isReadOnly()
+                */
+               boolean isReadOnly();
+
+               /**
+                * Sets the check state of an element in the Project Configurations pane under the authority of the
+                * controller. This is particularly useful for setting the
+                * {@linkplain IWorkingSetProjectConfigurationController#updateCheckState(IControllerContext) initial
+                * check state} of a controller and for
+                * {@linkplain IWorkingSetProjectConfigurationController#checkStateChanged(Object, boolean, IControllerContext)
+                * vetoing check state changes}.
+                * 
+                * @param element
+                *            the element to update checked
+                * @param checked
+                *            whether the element should be checked
+                * 
+                * @see IWorkingSetProjectConfigurationController#checkStateChanged(Object, boolean,
+                *      IControllerContext)
+                * @see IWorkingSetProjectConfigurationController#updateCheckState(IControllerContext)
+                * @see #setGrayed(Object, boolean)
+                */
+               void setChecked(Object element, boolean checked);
+
+               /**
+                * Sets the gray state of an element in the Project Configurations pane under the authority of the
+                * controller. This is particularly useful for setting the
+                * {@linkplain IWorkingSetProjectConfigurationController#updateCheckState(IControllerContext) initial
+                * check state} of a controller and for
+                * {@linkplain IWorkingSetProjectConfigurationController#checkStateChanged(Object, boolean, IControllerContext)
+                * responding to check state changes}.
+                * 
+                * @param element
+                *            the element to update checked
+                * @param checked
+                *            whether the element should be checked
+                * 
+                * @see IWorkingSetProjectConfigurationController#checkStateChanged(Object, boolean,
+                *      IControllerContext)
+                * @see IWorkingSetProjectConfigurationController#updateCheckState(IControllerContext)
+                * @see #setChecked(Object, boolean)
+                */
+               void setGrayed(Object element, boolean grayed);
+
+               /**
+                * Requests an update of the visual appearance of the specified element. The element may be any
+                * element under my control, or even the {@link IWorkingSetConfiguration} or {@link IWorkingSetProxy}
+                * that owns my project configuration.
+                * 
+                * @param element
+                *            an element to update
+                */
+               void update(Object element);
+
+               /**
+                * Notifies that the specified project configuration's activation state has changed. That is, that it
+                * is now activated when previously it was not, or vice-versa.
+                * 
+                * @param project
+                *            configuration the project configuration that changed
+                */
+               void activationStateChanged(IWorkingSetProjectConfiguration projectConfiguration);
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfigurationFactory.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProjectConfigurationFactory.java
new file mode 100644 (file)
index 0000000..87358cb
--- /dev/null
@@ -0,0 +1,394 @@
+/*******************************************************************************
+ * Copyright (c) 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectNatureDescriptor;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.osgi.util.NLS;
+
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.workingsets.WorkspaceSnapshot.ProjectState;
+
+/**
+ * Protocol for a factory of {@link IWorkingSetProjectConfiguration}s. Factories are {@linkplain Registry
+ * registered} against project natures.
+ * 
+ * @author Christian W. Damus (cdamus)
+ * 
+ * @since 6.0
+ */
+public interface IWorkingSetProjectConfigurationFactory {
+       /**
+        * Queries my factory ID. The ID is persisted in the working set configuration data so that the same
+        * factory can be used to reconstruct project configurations when loading the working set configurations.
+        * 
+        * @return my unique identifier
+        */
+       String getID();
+
+       /**
+        * Creates a new project configuration element.
+        * 
+        * @param parent
+        *            the working set configuration that owns the new project configuration
+        * @param project
+        *            the workspace project for which to create the configuration
+        * 
+        * @return the new project configuration
+        */
+       IWorkingSetProjectConfiguration createProjectConfiguration(IWorkingSetConfiguration parent,
+                       IProject project);
+
+       /**
+        * Creates a UI controller to support editing the specified project configuration snapshot, which should
+        * have been obtained from a configuration that I previously
+        * {@linkplain #createProjectConfiguration(org.eclipse.cdt.internal.ui.workingsets.IWorkingSetConfiguration, IProject)
+        * created}, myself.
+        * 
+        * @param config
+        *            a project configuration snapshot that I created
+        * 
+        * @return a suitable controller for it. Must not be <code>null</code>
+        */
+       IWorkingSetProjectConfigurationController createProjectConfigurationController(
+                       IWorkingSetProjectConfiguration.ISnapshot config);
+
+       /**
+        * Creates a snapshot of the configuration state of a project in the workspace. This may capture
+        * additional build meta-data beyond just the "active configuration."
+        * 
+        * @param project
+        *            a project to capture in a {@link WorkspaceSnapshot}
+        * @param desc
+        *            the project description, from which to capture the initial configuration data
+        * 
+        * @return the project state capture. Must not be <code>null</code>
+        */
+       WorkspaceSnapshot.ProjectState createProjectState(IProject project, ICProjectDescription desc);
+
+       //
+       // Nested types
+       //
+
+       /**
+        * A registry of {@linkplain IWorkingSetProjectConfigurationFactory project configuration factories}
+        * contributed on the <tt>org.eclipse.cdt.ui.workingSetConfigurations</tt> extension point.
+        * 
+        * @author Christian W. Damus (cdamus)
+        * 
+        * @since 6.0
+        */
+       class Registry {
+               private static final String EXT_PT_ID = "workingSetConfigurations"; //$NON-NLS-1$
+               private static final String E_FACTORY = "projectConfigurationFactory"; //$NON-NLS-1$
+               private static final String E_NATURE = "projectNature"; //$NON-NLS-1$
+               private static final String A_ID = "id"; //$NON-NLS-1$
+               private static final String A_CLASS = "class"; //$NON-NLS-1$
+
+               /**
+                * The shared project configuration factory registry.
+                */
+               public static Registry INSTANCE = new Registry();
+
+               private final IWorkingSetProjectConfigurationFactory defaultFactory = new Default();
+               private final Map<String, IWorkingSetProjectConfigurationFactory> factoriesByID = new java.util.HashMap<String, IWorkingSetProjectConfigurationFactory>();
+               private final Map<String, IWorkingSetProjectConfigurationFactory> factoriesByNature = new java.util.HashMap<String, IWorkingSetProjectConfigurationFactory>();
+
+               private Map<String, Set<String>> projectNaturePartOrdering;
+
+               private Registry() {
+                       super();
+
+                       projectNaturePartOrdering = computeProjectNaturePartOrdering();
+
+                       loadExtensions();
+               }
+
+               public IWorkingSetProjectConfigurationFactory getFactory(String id) {
+                       IWorkingSetProjectConfigurationFactory result = get(factoriesByID, id);
+
+                       if (result == null) {
+                               result = defaultFactory;
+                       }
+
+                       return result;
+               }
+
+               public IWorkingSetProjectConfigurationFactory getFactory(IProject project) {
+                       IWorkingSetProjectConfigurationFactory result = null;
+
+                       for (String nature : getPartOrderedNatureIDs(project)) {
+                               result = get(factoriesByNature, nature);
+
+                               if (result != null) {
+                                       break;
+                               }
+                       }
+
+                       return result;
+               }
+
+               private IWorkingSetProjectConfigurationFactory get(
+                               Map<?, IWorkingSetProjectConfigurationFactory> map, Object key) {
+                       return map.get(key);
+               }
+
+               private String[] getPartOrderedNatureIDs(IProject project) {
+                       String[] result;
+
+                       try {
+                               result = project.getDescription().getNatureIds();
+                       } catch (CoreException e) {
+                               CUIPlugin.log(e.getStatus());
+                               result = new String[0];
+                       }
+
+                       if (result.length > 0) {
+                               Arrays.sort(result, new Comparator<String>() {
+                                       public int compare(String nature1, String nature2) {
+                                               Set<String> required1 = projectNaturePartOrdering.get(nature1);
+                                               Set<String> required2 = projectNaturePartOrdering.get(nature2);
+
+                                               if (required1.contains(nature2)) {
+                                                       return -1; // required1 precedes required2
+                                               } else if (required2.contains(nature1)) {
+                                                       return +1; // required2 precedes required1
+                                               } else if (nature1.startsWith("org.eclipse.cdt.") //$NON-NLS-1$
+                                                               && !nature2.startsWith("org.eclipse.cdt.")) { //$NON-NLS-1$
+                                                       return +1; // lower priority to CDT natures
+                                               } else if (nature2.startsWith("org.eclipse.cdt.") //$NON-NLS-1$
+                                                               && !nature1.startsWith("org.eclipse.cdt.")) { //$NON-NLS-1$
+                                                       return -1; // lower priority to CDT natures
+                                               }
+
+                                               return 0; // not partially comparable
+                                       }
+                               });
+                       }
+
+                       return result;
+               }
+
+               private Map<String, Set<String>> computeProjectNaturePartOrdering() {
+                       Map<String, Set<String>> result = new java.util.HashMap<String, Set<String>>();
+
+                       // first pass to populate the map with immediate requireds
+                       IWorkspace ws = ResourcesPlugin.getWorkspace();
+                       for (IProjectNatureDescriptor next : ws.getNatureDescriptors()) {
+                               result.put(next.getNatureId(), new java.util.HashSet<String>(Arrays.asList(next
+                                               .getRequiredNatureIds())));
+                       }
+
+                       // now, iterate to add transitive requireds
+                       boolean loopAgain;
+                       do {
+                               loopAgain = false;
+
+                               for (Map.Entry<String, Set<String>> next : result.entrySet()) {
+                                       Set<String> requireds = next.getValue();
+                                       Set<String> newRequireds = new java.util.HashSet<String>(requireds);
+
+                                       boolean changed = false;
+
+                                       for (String required : requireds) {
+                                               changed |= newRequireds.addAll(result.get(required));
+                                       }
+
+                                       if (changed) {
+                                               loopAgain = true;
+                                               next.setValue(newRequireds);
+                                       }
+                               }
+                       } while (loopAgain);
+
+                       return result;
+               }
+
+               private void loadExtensions() {
+                       IExtensionRegistry registry = Platform.getExtensionRegistry();
+                       for (IExtension ext : registry.getExtensionPoint(CUIPlugin.PLUGIN_ID, EXT_PT_ID).getExtensions()) {
+                               for (IConfigurationElement element : ext.getConfigurationElements()) {
+                                       if (E_FACTORY.equals(element.getName())) {
+                                               try {
+                                                       Descriptor desc = new Descriptor(element);
+
+                                                       synchronized (factoriesByID) {
+                                                               factoriesByID.put(desc.getID(), desc);
+                                                       }
+
+                                                       synchronized (factoriesByNature) {
+                                                               for (IConfigurationElement nature : element.getChildren(E_NATURE)) {
+                                                                       String natureID = nature.getAttribute(A_ID);
+
+                                                                       if (natureID != null) {
+                                                                               factoriesByNature.put(natureID, desc);
+                                                                       } else {
+                                                                               CUIPlugin.log(NLS.bind(
+                                                                                               WorkingSetMessages.WSProjConfigFactory_noNatureID, ext
+                                                                                                               .getContributor().getName()), null);
+                                                                       }
+                                                               }
+                                                       }
+                                               } catch (CoreException e) {
+                                                       CUIPlugin.log(e.getStatus());
+                                               }
+                                       }
+                               }
+                       }
+               }
+
+               //
+               // Nested classes
+               //
+
+               /**
+                * A self-resolving descriptor for lazy instantiation of a factory.
+                */
+               private class Descriptor implements IWorkingSetProjectConfigurationFactory {
+                       private final IConfigurationElement extension;
+                       private final String id;
+
+                       Descriptor(IConfigurationElement extension) throws CoreException {
+                               this.extension = extension;
+                               id = extension.getAttribute(A_ID);
+
+                               if (id == null) {
+                                       throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, NLS.bind(
+                                                       WorkingSetMessages.WSProjConfigFactory_noFactoryID, extension.getContributor()
+                                                                       .getName())));
+                               }
+                       }
+
+                       public String getID() {
+                               return id;
+                       }
+
+                       public IWorkingSetProjectConfiguration createProjectConfiguration(
+                                       IWorkingSetConfiguration parent, IProject project) {
+                               return resolve().createProjectConfiguration(parent, project);
+                       }
+
+                       public IWorkingSetProjectConfigurationController createProjectConfigurationController(
+                                       IWorkingSetProjectConfiguration.ISnapshot config) {
+
+                               return resolve().createProjectConfigurationController(config);
+                       }
+
+                       public ProjectState createProjectState(IProject project, ICProjectDescription desc) {
+                               return resolve().createProjectState(project, desc);
+                       }
+
+                       private IWorkingSetProjectConfigurationFactory resolve() {
+                               IWorkingSetProjectConfigurationFactory result = null;
+
+                               try {
+                                       result = (IWorkingSetProjectConfigurationFactory) extension
+                                                       .createExecutableExtension(A_CLASS);
+                               } catch (ClassCastException e) {
+                                       CUIPlugin.log(NLS.bind(WorkingSetMessages.WSProjConfigFactory_badFactory, extension
+                                                       .getContributor().getName()), e);
+                               } catch (CoreException e) {
+                                       CUIPlugin.log(new MultiStatus(CUIPlugin.PLUGIN_ID, 0, new IStatus[] { e.getStatus() },
+                                                       WorkingSetMessages.WSProjConfigFactory_factoryFailed, null));
+                               }
+
+                               if (result == null) {
+                                       result = defaultFactory;
+                               }
+
+                               // replace the descriptor in the maps
+                               synchronized (factoriesByID) {
+                                       factoriesByID.put(getID(), result);
+                               }
+                               synchronized (factoriesByNature) {
+                                       for (Map.Entry<String, IWorkingSetProjectConfigurationFactory> next : factoriesByNature
+                                                       .entrySet()) {
+                                               if (next.getValue().getID().equals(getID())) {
+                                                       next.setValue(result);
+                                               }
+                                       }
+                               }
+
+                               return result;
+                       }
+               }
+
+               /**
+                * The default project configuration factory. Clients may extend this class to implement custom
+                * factories for their project natures.
+                * 
+                * @author Christian W. Damus (cdamus)
+                * 
+                * @since 6.0
+                */
+               public static class Default implements IWorkingSetProjectConfigurationFactory, IExecutableExtension {
+
+                       private String id;
+
+                       public Default() {
+                               super();
+                       }
+
+                       public IWorkingSetProjectConfiguration createProjectConfiguration(
+                                       IWorkingSetConfiguration parent, IProject project) {
+
+                               WorkingSetProjectConfiguration result = createProjectConfiguration(parent);
+                               result.setProjectName(project.getName());
+                               return result;
+                       }
+
+                       protected WorkingSetProjectConfiguration createProjectConfiguration(
+                                       IWorkingSetConfiguration parent) {
+                               return new WorkingSetProjectConfiguration(parent);
+                       }
+
+                       public IWorkingSetProjectConfigurationController createProjectConfigurationController(
+                                       IWorkingSetProjectConfiguration.ISnapshot config) {
+
+                               return new ProjectConfigurationController(config);
+                       }
+
+                       public ProjectState createProjectState(IProject project, ICProjectDescription desc) {
+                               return new WorkspaceSnapshot.ProjectState(project, desc);
+                       }
+
+                       public String getID() {
+                               return id;
+                       }
+
+                       public void setInitializationData(IConfigurationElement config, String propertyName, Object data)
+                                       throws CoreException {
+
+                               this.id = config.getAttribute(A_ID);
+                       }
+
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProxy.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/IWorkingSetProxy.java
new file mode 100644 (file)
index 0000000..30c84de
--- /dev/null
@@ -0,0 +1,161 @@
+/*******************************************************************************
+ * Copyright (c) 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import java.util.Collection;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.ui.IWorkingSet;
+
+/**
+ * The protocol for elements representing working sets, providing proxies for the workbench's actual
+ * {@link IWorkingSet}s. A working set may have zero or more {@linkplain IWorkingSetConfiguration
+ * configurations} that aggregate configuration settings for the C/C++ projects in the working set.
+ * 
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
+ * 
+ * @author Christian W. Damus (cdamus)
+ * 
+ * @since 6.0
+ * 
+ */
+public interface IWorkingSetProxy extends IWorkingSetConfigurationElement {
+       /**
+        * Queries my name. This is the {@link IWorkingSet#getName() name} of my referenced working set, not its
+        * {@link IWorkingSet#getLabel() label}. As my referenced working set's name changes, so does my name.
+        * 
+        * @return my working set's name
+        */
+       String getName();
+
+       /**
+        * Resolves me to the actual working set as maintained by the workbench.
+        * 
+        * @return my referenced working set, or <code>null</code> if it no longer exists
+        */
+       IWorkingSet resolve();
+
+       /**
+        * Resolves the actual existing projects in my working set, that are currently
+        * {@linkplain IResource#isAccessible() accessible} in the workspace.
+        * 
+        * @return my projects
+        */
+       Collection<IProject> resolveProjects();
+
+       /**
+        * Queries whether I am a valid working set proxy, to be displayed to and manipulated by the user. This
+        * should at least check that the proxy {@linkplain #resolve() resolves} to an existing working set and
+        * that it includes at least one {@linkplain #resolveProjects() project}.
+        * 
+        * @return whether I am a valid working set proxy
+        */
+       boolean isValid();
+
+       /**
+        * Obtains the named configuration of my working set.
+        * 
+        * @param name
+        *            a configuration name
+        * 
+        * @return the matching configuration, or <code>null</code> if there is none such
+        */
+       IWorkingSetConfiguration getConfiguration(String name);
+
+       /**
+        * Obtains all of the configurations currently defined for my working set. If I am a working-copy
+        * {@linkplain IWorkingSetProxy.ISnapshot snapshot}, then these may include a special
+        * {@linkplain IWorkingSetConfiguration.ISnapshot#isReadOnly() read-only} configuration indicating the
+        * active configurations of my projects, if none of my named configurations is
+        * {@linkplain IWorkingSetConfiguration#isActive() active}.
+        * 
+        * @return my configurations
+        */
+       Collection<IWorkingSetConfiguration> getConfigurations();
+
+       /**
+        * Creates a <i>snapshot</i> (also known as a "working copy") of myself, providing a mutable view suitable
+        * for editing.
+        * 
+        * @param workspace
+        *            a workspace snapshot that captures the baseline state of the workspace and the working set
+        *            configurations that are to be edited
+        * 
+        * @return a working-copy snapshot of myself
+        */
+       ISnapshot createSnapshot(WorkspaceSnapshot workspace);
+
+       //
+       // Nested types
+       //
+
+       /**
+        * The snapshot ("working copy") view of a working set proxy. It has additional API for modifying
+        * configurations, which can then be {@linkplain WorkspaceSnapshot#save() saved} for posterity.
+        * 
+        * @noimplement This interface is not intended to be implemented by clients.
+        * @noextend This interface is not intended to be extended by clients.
+        * 
+        * @author Christian W. Damus (cdamus)
+        * 
+        * @since 6.0
+        */
+       interface ISnapshot extends IWorkingSetProxy, IWorkingSetConfigurationElement.ISnapshot {
+               /**
+                * Creates a new configuration with the specified name.
+                * 
+                * @param name
+                *            a new configuration name
+                * 
+                * @return the new configuration
+                * 
+                * @throws IllegalArgumentException
+                *             if the new name is <code>null</code> or empty, or if it is already used by another
+                *             configuration of the same working set
+                */
+               IWorkingSetConfiguration.ISnapshot createConfiguration(String name);
+
+               /**
+                * Removes the specified configuration from me.
+                * 
+                * @param config
+                *            a configuration to remove
+                * 
+                * @throws IllegalArgumentException
+                *             if the configuration to be removed is
+                *             {@linkplain IWorkingSetConfiguration.ISnapshot#isReadOnly() read-only}
+                */
+               void removeConfiguration(IWorkingSetConfiguration config);
+
+               /**
+                * <p>
+                * Updates me according to the (assumed to have changed) activation state of my configurations. If any
+                * named configurations are active and I currently have a "fake"
+                * {@linkplain IWorkingSetConfiguration.ISnapshot#isReadOnly() read-only} configuration, then it is
+                * removed and I signal a "major change."
+                * </p>
+                * <p>
+                * If I have no named configurations that are active, and currently have not got a read-only
+                * configuration to show the active configuration, then I create it and signal a "major change."
+                * </p>
+                * <p>
+                * It is assumed that the UI will refresh the tree structure rooted in me when I signal a major
+                * change.
+                * </p>
+                * 
+                * @return whether this update results in a "major change" to my child configuration structure
+                */
+               boolean updateActiveConfigurations();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ProjectConfigsController.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ProjectConfigsController.java
new file mode 100644 (file)
index 0000000..2623a95
--- /dev/null
@@ -0,0 +1,386 @@
+/*******************************************************************************
+ * Copyright (c) 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import java.util.Map;
+
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.IColorProvider;
+import org.eclipse.jface.viewers.IFontProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * View controller for the project configurations pane of the working set configurations dialog. It takes care
+ * of coordinating the user gestures in that pane with the working-set configuration model and vice-versa.
+ * 
+ * @author Christian W. Damus (cdamus)
+ * 
+ * @since 6.0
+ * 
+ */
+class ProjectConfigsController implements ICheckStateListener, DisposeListener {
+       private CheckboxTreeViewer tree;
+
+       private IWorkingSetConfiguration.ISnapshot workingSet;
+       private WorkingSetConfigsController workingSetController;
+
+       private ControllerContext controllerContext;
+
+       private ILabelProvider labelProvider = new DelegatingLabelProvider();
+       private ITreeContentProvider contentProvider = new DelegatingContentProvider();
+
+       /**
+        * Initializes me.
+        */
+       ProjectConfigsController() {
+               super();
+       }
+
+       /**
+        * Assigns the tree viewer that I control.
+        * 
+        * @param tree
+        *            my tree viewer
+        */
+       void setTreeViewer(CheckboxTreeViewer tree) {
+               if (this.tree != null) {
+                       this.tree.getTree().removeDisposeListener(this);
+                       this.tree.removeCheckStateListener(this);
+                       this.tree.setLabelProvider(null);
+                       this.tree.setContentProvider(null);
+               }
+
+               this.tree = tree;
+
+               if (this.tree != null) {
+                       this.tree.setUseHashlookup(true);
+                       this.tree.setContentProvider(contentProvider);
+                       this.tree.setLabelProvider(labelProvider);
+                       this.tree.addCheckStateListener(this);
+                       this.tree.getTree().addDisposeListener(this);
+               }
+       }
+
+       /**
+        * Injects the current selection of a working set from the Working Set Configurations pane. This changes
+        * the project configurations that I show in my own tree.
+        * 
+        * @param config
+        *            the new working set configuration selection. May be <code>null</code> if there is no
+        *            selection
+        */
+       void setWorkingSetConfiguration(IWorkingSetConfiguration.ISnapshot config) {
+               if ((tree != null) && (config != workingSet)) {
+                       this.workingSet = config;
+
+                       tree.setSelection(new StructuredSelection());
+
+                       if (config != null) {
+                               controllerContext = new ControllerContext(tree);
+                               tree.setInput(config);
+                               tree.getTree().setEnabled(true);
+                               updateCheckState(config);
+                               tree.expandToLevel(2);
+                       } else {
+                               tree.getTree().setEnabled(false);
+                               tree.setInput(config);
+                               controllerContext.dispose();
+                               controllerContext = null;
+                       }
+               }
+       }
+
+       /**
+        * Queries the current working set configuration that I show in my tree.
+        * 
+        * @return the working set configuration, or <code>null</code> if none
+        */
+       IWorkingSetConfiguration.ISnapshot getWorkingSetConfiguration() {
+               return workingSet;
+       }
+
+       public void checkStateChanged(CheckStateChangedEvent event) {
+               Object element = event.getElement();
+               IWorkingSetProjectConfigurationController controller = controllerContext
+                               .controllerForElement(element);
+
+               if (controller != null) {
+                       controller.checkStateChanged(element, event.getChecked(), controllerContext);
+
+               } else {
+                       // controller unknown? Cannot change the check-state
+                       tree.setChecked(element, !event.getChecked());
+               }
+       }
+
+       public void widgetDisposed(DisposeEvent e) {
+               dispose();
+       }
+
+       /**
+        * Computes the initial check-box settings for my tree according to the current state of the specified
+        * working set configuration.
+        * 
+        * @param config
+        *            a working set configuration that I am now showing
+        */
+       private void updateCheckState(IWorkingSetConfiguration.ISnapshot config) {
+               for (IWorkingSetProjectConfiguration project : config.getProjectConfigurations()) {
+                       IWorkingSetProjectConfigurationController controller = controllerContext
+                                       .controllerForElement(project);
+
+                       if (controller != null) {
+                               controller.updateCheckState(controllerContext);
+                       }
+               }
+       }
+
+       void update() {
+               if (tree != null) {
+                       tree.refresh(true);
+               }
+       }
+
+       /**
+        * Connects me to the controller of the working set configurations pane.
+        * 
+        * @param controller
+        *            the working-set configs controller
+        */
+       void setWorkingSetConfigurationsController(WorkingSetConfigsController controller) {
+               workingSetController = controller;
+       }
+
+       void dispose() {
+               if (controllerContext != null) {
+                       controllerContext.dispose();
+                       controllerContext = null;
+               }
+       }
+
+       //
+       // Nested classes
+       //
+
+       private class ControllerContext implements IWorkingSetProjectConfigurationController.IControllerContext {
+
+               private Map<Object, IWorkingSetProjectConfigurationController> elementToControllerMap;
+
+               private Map<IWorkingSetProjectConfigurationController, ITreeContentProvider> contentProviders;
+               private Map<IWorkingSetProjectConfigurationController, ILabelProvider> labelProviders;
+
+               ControllerContext(Viewer viewer) {
+                       elementToControllerMap = new java.util.IdentityHashMap<Object, IWorkingSetProjectConfigurationController>();
+                       contentProviders = new java.util.HashMap<IWorkingSetProjectConfigurationController, ITreeContentProvider>();
+                       labelProviders = new java.util.HashMap<IWorkingSetProjectConfigurationController, ILabelProvider>();
+
+                       for (IWorkingSetProjectConfiguration next : getWorkingSetConfiguration()
+                                       .getProjectConfigurations()) {
+
+                               IWorkingSetProjectConfiguration.ISnapshot project = (IWorkingSetProjectConfiguration.ISnapshot) next;
+
+                               IWorkingSetProjectConfigurationController controller = IWorkingSetProjectConfigurationFactory.Registry.INSTANCE
+                                               .getFactory(project.resolveProject()).createProjectConfigurationController(project);
+
+                               if (controller == null) {
+                                       // can only supply the default behaviour, then
+                                       controller = new ProjectConfigurationController(project);
+                               }
+
+                               elementToControllerMap.put(project, controller);
+                               contentProviders.put(controller, controller.getContentProvider());
+                               labelProviders.put(controller, controller.getLabelProvider(viewer));
+
+                               discoverElements(controller, project, contentProviders.get(controller));
+                       }
+               }
+
+               private void discoverElements(IWorkingSetProjectConfigurationController controller, Object element,
+                               ITreeContentProvider provider) {
+                       Object[] children = provider.getChildren(element);
+
+                       for (Object next : children) {
+                               elementToControllerMap.put(next, controller);
+                               discoverElements(controller, next, provider);
+                       }
+               }
+
+               IWorkingSetProjectConfigurationController controllerForElement(Object element) {
+                       return elementToControllerMap.get(element);
+               }
+
+               ITreeContentProvider contentProviderForElement(Object element) {
+                       return contentProviders.get(elementToControllerMap.get(element));
+               }
+
+               ILabelProvider labelProviderForElement(Object element) {
+                       return labelProviders.get(elementToControllerMap.get(element));
+               }
+
+               public void activationStateChanged(IWorkingSetProjectConfiguration projectConfiguration) {
+                       workingSetController.projectSelectionsChanged(projectConfiguration);
+               }
+
+               public boolean isReadOnly() {
+                       return getWorkingSetConfiguration().isReadOnly();
+               }
+
+               public void setChecked(Object element, boolean checked) {
+                       tree.setChecked(element, checked);
+               }
+
+               public void setGrayed(Object element, boolean grayed) {
+                       tree.setGrayChecked(element, grayed);
+               }
+
+               public void update(Object element) {
+                       if ((element instanceof IWorkingSetConfiguration) || (element instanceof IWorkingSetProxy)) {
+                               // TODO: Talk to the WS controller
+                       } else if (controllerForElement(element) != null) {
+                               // only need to update if we have actually accessed this
+                               // element, yet, in order to display it
+                               tree.update(element, null);
+                       }
+               }
+
+               public void dispose() {
+                       elementToControllerMap = null;
+
+                       if (contentProviders != null) {
+                               for (ITreeContentProvider next : contentProviders.values()) {
+                                       next.dispose();
+                               }
+                               contentProviders = null;
+                       }
+
+                       if (labelProviders != null) {
+                               for (ILabelProvider next : labelProviders.values()) {
+                                       next.dispose();
+                               }
+                               labelProviders = null;
+                       }
+               }
+       }
+
+       private class DelegatingLabelProvider extends LabelProvider implements IFontProvider, IColorProvider {
+               private final NullLabelProvider defaultLabels = new NullLabelProvider();
+
+               @Override
+               public String getText(Object element) {
+                       return delegateFor(element, ILabelProvider.class).getText(element);
+               }
+
+               @Override
+               public Image getImage(Object element) {
+                       return delegateFor(element, ILabelProvider.class).getImage(element);
+               }
+
+               public Font getFont(Object element) {
+                       return delegateFor(element, IFontProvider.class).getFont(element);
+               }
+
+               public Color getBackground(Object element) {
+                       return delegateFor(element, IColorProvider.class).getBackground(element);
+               }
+
+               public Color getForeground(Object element) {
+                       return delegateFor(element, IColorProvider.class).getForeground(element);
+               }
+
+               @SuppressWarnings("unchecked")
+               private <T> T delegateFor(Object element, Class<T> expectedType) {
+                       if (controllerContext == null) {
+                               return (T) defaultLabels;
+                       } else {
+                               T result = (T) controllerContext.labelProviderForElement(element);
+
+                               if (!expectedType.isInstance(result)) {
+                                       return (T) defaultLabels;
+                               }
+
+                               return result;
+                       }
+               }
+       }
+
+       private class DelegatingContentProvider implements ITreeContentProvider {
+               private final Object[] NO_OBJECTS = new Object[0];
+
+               public Object[] getChildren(Object parentElement) {
+                       ITreeContentProvider delegate = delegateFor(parentElement);
+
+                       return (delegate != null) ? delegate.getChildren(parentElement) : NO_OBJECTS;
+               }
+
+               public Object getParent(Object element) {
+                       ITreeContentProvider delegate = delegateFor(element);
+
+                       return (delegate != null) ? delegate.getParent(element) : null;
+               }
+
+               public boolean hasChildren(Object element) {
+                       ITreeContentProvider delegate = delegateFor(element);
+
+                       return (delegate != null) && delegate.hasChildren(element);
+               }
+
+               public Object[] getElements(Object inputElement) {
+                       return getWorkingSetConfiguration().getProjectConfigurations().toArray();
+               }
+
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+                       // nothing to do
+               }
+
+               public void dispose() {
+                       // nothing of my own to dispose
+               }
+
+               private ITreeContentProvider delegateFor(Object element) {
+                       return (controllerContext == null) ? null : controllerContext.contentProviderForElement(element);
+               }
+       }
+
+       /**
+        * A useful empty implementation of the extended label-provider protocol.
+        * 
+        * @author Christian W. Damus (cdamus)
+        * 
+        * @since 6.0
+        */
+       private static class NullLabelProvider extends LabelProvider implements IFontProvider, IColorProvider {
+
+               public Font getFont(Object element) {
+                       return null;
+               }
+
+               public Color getBackground(Object element) {
+                       return null;
+               }
+
+               public Color getForeground(Object element) {
+                       return null;
+               }
+
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ProjectConfigurationController.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/ProjectConfigurationController.java
new file mode 100644 (file)
index 0000000..26cdff9
--- /dev/null
@@ -0,0 +1,220 @@
+/*******************************************************************************
+ * Copyright (c) 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import java.util.Set;
+
+import org.eclipse.jface.resource.FontDescriptor;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.resource.LocalResourceManager;
+import org.eclipse.jface.resource.ResourceManager;
+import org.eclipse.jface.viewers.IFontProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.ui.CDTSharedImages;
+
+import org.eclipse.cdt.internal.ui.workingsets.IWorkingSetProjectConfiguration.ISnapshot;
+
+/**
+ * Default implementation of the working set project configuration controller protocol.
+ * 
+ * @author Christian W. Damus (cdamus)
+ * 
+ * @since 6.0
+ * 
+ */
+public class ProjectConfigurationController implements IWorkingSetProjectConfigurationController {
+
+       private IWorkingSetProjectConfiguration.ISnapshot config;
+
+       /**
+        * Initializes me with my project configuration.
+        * 
+        * @param config
+        *            my project configuration
+        */
+       public ProjectConfigurationController(IWorkingSetProjectConfiguration.ISnapshot config) {
+               this.config = config;
+       }
+
+       public ISnapshot getProjectConfiguration() {
+               return config;
+       }
+
+       public void checkStateChanged(Object element, boolean checked, IControllerContext context) {
+               if (!context.isReadOnly() && (element instanceof ICConfigurationDescription)) {
+
+                       ICConfigurationDescription newSel = (ICConfigurationDescription) element;
+                       ICConfigurationDescription oldSel = getProjectConfiguration().resolveSelectedConfiguration();
+
+                       boolean oldActive = getProjectConfiguration().isActive();
+
+                       if (checked) {
+                               if (newSel != oldSel) {
+                                       getProjectConfiguration().setSelectedConfigurationID(newSel.getId());
+
+                                       if (oldSel != null) {
+                                               context.setChecked(oldSel, false);
+                                       }
+                               }
+                       } else if (newSel == oldSel) {
+                               // cannot just uncheck the current selection
+                               context.setChecked(oldSel, true);
+                       }
+
+                       boolean newActive = getProjectConfiguration().isActive();
+                       if (oldActive != newActive) {
+                               context.activationStateChanged(getProjectConfiguration());
+                       }
+               } else {
+                       // cannot change the check-state of these nodes
+                       context.setChecked(element, !checked);
+               }
+       }
+
+       public void updateCheckState(IControllerContext context) {
+               ICConfigurationDescription sel = getProjectConfiguration().resolveSelectedConfiguration();
+
+               if (sel != null) {
+                       context.setChecked(sel, true);
+               }
+
+               // gray the project node
+               context.setGrayed(getProjectConfiguration(), true);
+       }
+
+       public ITreeContentProvider getContentProvider() {
+               return new ContentProvider(getProjectConfiguration());
+       }
+
+       public ILabelProvider getLabelProvider(Viewer viewer) {
+               return new LabelProvider(viewer, getProjectConfiguration());
+       }
+
+       //
+       // Nested classes
+       //
+
+       private static class ContentProvider implements ITreeContentProvider {
+               private static final Object[] NO_OBJECTS = new Object[0];
+
+               private IWorkingSetProjectConfiguration project;
+               private Set<ICConfigurationDescription> configs;
+
+               ContentProvider(IWorkingSetProjectConfiguration project) {
+                       this.project = project;
+                       this.configs = new java.util.HashSet<ICConfigurationDescription>(project.resolveConfigurations());
+               }
+
+               public Object[] getChildren(Object parentElement) {
+                       return (parentElement == project) ? project.resolveConfigurations().toArray() : NO_OBJECTS;
+               }
+
+               public Object getParent(Object element) {
+                       return (element == project) ? null : configs.contains(element) ? project : null;
+               }
+
+               public boolean hasChildren(Object element) {
+                       return element == project;
+               }
+
+               public Object[] getElements(Object inputElement) {
+                       return new Object[] { project };
+               }
+
+               public void dispose() {
+                       // nothing to dispose
+               }
+
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+                       // nothing to do
+               }
+
+       }
+
+       private static class LabelProvider extends org.eclipse.jface.viewers.LabelProvider implements
+                       IFontProvider {
+
+               private IWorkingSetProjectConfiguration.ISnapshot projectConfig;
+               private WorkbenchLabelProvider wbLabels = new WorkbenchLabelProvider();
+               private Image configImage = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_CONFIG);
+
+               private Font defaultFont;
+               private ResourceManager fonts = new LocalResourceManager(JFaceResources.getResources());
+
+               LabelProvider(Viewer viewer, IWorkingSetProjectConfiguration.ISnapshot projectConfig) {
+                       this.projectConfig = projectConfig;
+                       this.defaultFont = viewer.getControl().getFont();
+               }
+
+               @Override
+               public String getText(Object element) {
+                       if (element instanceof ICConfigurationDescription) {
+                               ICConfigurationDescription config = (ICConfigurationDescription) element;
+
+                               return isActiveInWorkspace(config) ? NLS.bind(
+                                               WorkingSetMessages.ProjConfigController_activeConfig, config.getName()) : config
+                                               .getName();
+                       } else if (element instanceof IWorkingSetProjectConfiguration) {
+                               return wbLabels.getText(((IWorkingSetProjectConfiguration) element).resolveProject());
+                       }
+
+                       return wbLabels.getText(element);
+               }
+
+               @Override
+               public Image getImage(Object element) {
+                       if (element instanceof ICConfigurationDescription) {
+                               return configImage;
+                       } else if (element instanceof IWorkingSetProjectConfiguration) {
+                               return wbLabels.getImage(((IWorkingSetProjectConfiguration) element).resolveProject());
+                       }
+
+                       return wbLabels.getImage(element);
+               }
+
+               public Font getFont(Object element) {
+                       if (element instanceof ICConfigurationDescription) {
+                               ICConfigurationDescription config = (ICConfigurationDescription) element;
+
+                               if (isActiveInWorkspace(config)) {
+                                       FontDescriptor desc = FontDescriptor.createFrom(defaultFont);
+                                       return (Font) fonts.get(desc.withStyle(SWT.BOLD));
+                               }
+                       }
+
+                       return wbLabels.getFont(element);
+               }
+
+               private boolean isActiveInWorkspace(ICConfigurationDescription config) {
+                       WorkspaceSnapshot workspace = projectConfig.getWorkspaceSnapshot();
+
+                       return workspace.getState(projectConfig.resolveProject()).isActive(config.getId());
+               }
+
+               @Override
+               public void dispose() {
+                       wbLabels.dispose();
+                       fonts.dispose();
+                       super.dispose();
+               }
+       }
+
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigsController.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigsController.java
new file mode 100644 (file)
index 0000000..314e33d
--- /dev/null
@@ -0,0 +1,460 @@
+/*******************************************************************************
+ * Copyright (c) 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.ui.IWorkingSet;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * The view controller for the working set configurations pane in the dialog. It takes care of coordinating
+ * the user gestures in the pane with the working set configuration model, and vice-versa. It also implements
+ * the handling of the action buttons.
+ * 
+ * @author Christian W. Damus (cdamus)
+ * 
+ * @since 6.0
+ * 
+ */
+class WorkingSetConfigsController implements SelectionListener, ISelectionChangedListener {
+
+       private TreeViewer tree;
+       private Button addButton;
+       private Button removeButton;
+       private Button renameButton;
+       private Button activateButton;
+       private Button buildButton;
+
+       private IWorkingSetProxy.ISnapshot initialWorkingSet;
+       private IWorkingSetProxy.ISnapshot currentWorkingSet;
+       private IWorkingSetConfiguration.ISnapshot currentConfig;
+
+       private final WorkspaceSnapshot workspace;
+
+       private ProjectConfigsController projectsController;
+
+       /**
+        * Initializes me we an initial working set to select.
+        */
+       WorkingSetConfigsController(WorkspaceSnapshot workspace, IWorkingSetProxy.ISnapshot initialWorkingSet) {
+               this.workspace = workspace;
+
+               if (initialWorkingSet != null) {
+                       this.initialWorkingSet = initialWorkingSet;
+               } else {
+                       IWorkingSet[] recent = WorkingSetConfigurationManager.WS_MGR.getRecentWorkingSets();
+                       if ((recent != null) && (recent.length > 0)) {
+                               this.initialWorkingSet = workspace.getWorkingSet(recent[0].getName());
+                       }
+               }
+       }
+
+       /**
+        * Initializes me.
+        */
+       WorkingSetConfigsController(WorkspaceSnapshot workspace) {
+               this(workspace, null);
+       }
+
+       /**
+        * Assigns the tree viewer that I control.
+        * 
+        * @param tree
+        *            my tree viewer
+        */
+       void setTreeViewer(final TreeViewer tree) {
+               if (this.tree != null) {
+                       this.tree.removeSelectionChangedListener(this);
+               }
+
+               this.tree = tree;
+
+               if (this.tree != null) {
+                       this.tree.addSelectionChangedListener(this);
+
+                       this.tree.setInput(workspace.getWorkingSets());
+
+                       if (!workspace.getWorkingSets().isEmpty()) {
+                               tree.getTree().getDisplay().asyncExec(new Runnable() {
+
+                                       public void run() {
+                                               Object initialSelection;
+
+                                               ITreeContentProvider content = (ITreeContentProvider) tree.getContentProvider();
+
+                                               if ((initialWorkingSet != null)
+                                                               && Arrays.asList(content.getElements(tree.getInput())).contains(
+                                                                               initialWorkingSet)) {
+                                                       initialSelection = initialWorkingSet;
+                                               } else {
+                                                       // we have a most-recently-used working set. Just
+                                                       // take the first in tree order
+                                                       initialSelection = tree.getTree().getItem(0).getData();
+                                               }
+
+                                               Object[] children = content.getChildren(initialSelection);
+                                               IStructuredSelection sel;
+
+                                               if ((children == null) || (children.length == 0)) {
+                                                       // Shouldn't happen: there should at least be the
+                                                       // read-only config.
+                                                       // Can only select the initial working set
+                                                       sel = new StructuredSelection(initialSelection);
+                                               } else {
+                                                       Object[] toSort = new Object[children.length];
+                                                       System.arraycopy(children, 0, toSort, 0, children.length);
+                                                       tree.getComparator().sort(tree, toSort);
+                                                       sel = new StructuredSelection(toSort[0]);
+                                               }
+
+                                               // make the selection
+                                               tree.setSelection(sel, true);
+                                       }
+                               });
+                       }
+               }
+       }
+
+       private Button updateButton(Button oldButton, Button newButton) {
+               if (oldButton != null) {
+                       oldButton.removeSelectionListener(this);
+               }
+
+               if (newButton != null) {
+                       newButton.addSelectionListener(this);
+               }
+
+               return newButton;
+       }
+
+       /**
+        * Assigns me my "Add..." button.
+        * 
+        * @param addButton
+        *            my add button
+        */
+       void setAddButton(Button addButton) {
+               this.addButton = updateButton(this.addButton, addButton);
+       }
+
+       /**
+        * Assigns me my "Remove" button.
+        * 
+        * @param removeButton
+        *            my remove button
+        */
+       void setRemoveButton(Button removeButton) {
+               this.removeButton = updateButton(this.removeButton, removeButton);
+       }
+
+       /**
+        * Assigns me my "Rename..." button.
+        * 
+        * @param renameButton
+        *            my rename button
+        */
+       void setRenameButton(Button renameButton) {
+               this.renameButton = updateButton(this.renameButton, renameButton);
+       }
+
+       /**
+        * Assigns me my "Activate" button.
+        * 
+        * @param activateButton
+        *            my activate button
+        */
+       void setActivateButton(Button activateButton) {
+               this.activateButton = updateButton(this.activateButton, activateButton);
+       }
+
+       /**
+        * Assigns me my "Build" button.
+        * 
+        * @param buildButton
+        *            my build button
+        */
+       void setBuildButton(Button buildButton) {
+               this.buildButton = updateButton(this.buildButton, buildButton);
+       }
+
+       /**
+        * Connects me to the controller for the project configurations pane, into which I inject the currently
+        * selected working set configuration.
+        * 
+        * @param controller
+        *            my project configurations controller
+        */
+       void setProjectConfigsController(ProjectConfigsController controller) {
+               this.projectsController = controller;
+
+               if (controller != null) {
+                       controller.setWorkingSetConfiguration(currentConfig);
+               }
+       }
+
+       public void widgetDefaultSelected(SelectionEvent e) {
+               // not interesting
+       }
+
+       /**
+        * Handles button presses in the working set configurations pane.
+        */
+       public void widgetSelected(SelectionEvent e) {
+               // handle button press
+               if (e.widget == addButton) {
+                       addConfig();
+               } else if (e.widget == removeButton) {
+                       removeConfig();
+               } else if (e.widget == renameButton) {
+                       renameConfig();
+               } else if (e.widget == activateButton) {
+                       activateConfig();
+               } else if (e.widget == buildButton) {
+                       buildConfig();
+               }
+       }
+
+       /**
+        * Handles selection of working sets and their configurations. Among potentially other actions, this
+        * injects the working-set configuration selection into the project configurations controller and updates
+        * the enablement of the buttons.
+        */
+       public void selectionChanged(SelectionChangedEvent event) {
+               currentConfig = null;
+               currentWorkingSet = null;
+
+               if (event.getSelection() instanceof IStructuredSelection) {
+                       IStructuredSelection sel = (IStructuredSelection) event.getSelection();
+
+                       if (!sel.isEmpty()) {
+                               Object first = sel.getFirstElement();
+
+                               if (first instanceof IWorkingSetConfiguration) {
+                                       currentConfig = (IWorkingSetConfiguration.ISnapshot) first;
+                                       currentWorkingSet = currentConfig.getWorkingSet();
+                               } else if (first instanceof IWorkingSetProxy) {
+                                       currentWorkingSet = (IWorkingSetProxy.ISnapshot) first;
+                               }
+                       }
+               }
+
+               if (projectsController != null) {
+                       // tell the project controller
+                       projectsController.setWorkingSetConfiguration(currentConfig);
+               }
+
+               updateButtons();
+       }
+
+       /**
+        * Handler for the "Add..." button.
+        */
+       private void addConfig() {
+               InputDialog dlg = new InputDialog(tree.getTree().getShell(),
+                               WorkingSetMessages.WSConfigsController_addDlg_title,
+                               WorkingSetMessages.WSConfigsController_addDlg_msg,
+                               WorkingSetMessages.WSConfigsController_addDlg_defaultName, new IInputValidator() {
+
+                                       public String isValid(String newText) {
+                                               if (currentWorkingSet.getConfiguration(newText) != null) {
+                                                       return WorkingSetMessages.WSConfigsController_addDlg_nameExists;
+                                               }
+                                               if (newText.length() == 0) {
+                                                       return WorkingSetMessages.WSConfigsController_addDlg_emptyName;
+                                               }
+                                               return null;
+                                       }
+                               });
+
+               if (dlg.open() == IDialogConstants.OK_ID) {
+                       IWorkingSetConfiguration.ISnapshot newConfig = currentWorkingSet.createConfiguration(dlg
+                                       .getValue());
+                       tree.refresh(currentWorkingSet);
+                       tree.setSelection(new StructuredSelection(newConfig), true);
+                       currentConfig = newConfig;
+                       currentWorkingSet = currentConfig.getWorkingSet();
+
+                       // this is a "recently used" working set
+                       IWorkingSet ws = currentWorkingSet.resolve();
+                       if (ws != null) {
+                               WorkingSetConfigurationManager.WS_MGR.addRecentWorkingSet(ws);
+                       }
+               }
+       }
+
+       /**
+        * Handler for the "Remove" button.
+        */
+       private void removeConfig() {
+               currentWorkingSet.removeConfiguration(currentConfig);
+               tree.refresh(currentWorkingSet);
+       }
+
+       /**
+        * Handler for the "Rename..." button.
+        */
+       private void renameConfig() {
+               InputDialog dlg = new InputDialog(tree.getTree().getShell(),
+                               WorkingSetMessages.WSConfigsController_renameDlg_title,
+                               WorkingSetMessages.WSConfigsController_renameDlg_msg, currentConfig.getName(),
+                               new IInputValidator() {
+
+                                       public String isValid(String newText) {
+                                               if (newText.equals(currentConfig.getName())) {
+                                                       return ""; //$NON-NLS-1$
+                                               }
+                                               if (currentWorkingSet.getConfiguration(newText) != null) {
+                                                       return WorkingSetMessages.WSConfigsController_addDlg_nameExists;
+                                               }
+                                               if (newText.length() == 0) {
+                                                       return WorkingSetMessages.WSConfigsController_addDlg_emptyName;
+                                               }
+                                               return null;
+                                       }
+                               });
+
+               if (dlg.open() == IDialogConstants.OK_ID) {
+                       currentConfig.setName(dlg.getValue());
+                       tree.refresh(currentWorkingSet);
+               }
+       }
+
+       /**
+        * Handler for the "Activate" button.
+        */
+       private void activateConfig() {
+               currentConfig.activate();
+               projectsController.update();
+               updateForActivation();
+       }
+
+       /**
+        * Updates the display to reflect potential changes in project activation and the resulting changes in
+        * working-set config activation, if any.
+        */
+       private void updateForActivation() {
+               // update all working-set configs that intersect this config
+               Collection<IWorkingSetProxy.ISnapshot> unaffectedWorkingSets = new java.util.HashSet<IWorkingSetProxy.ISnapshot>(
+                               workspace.getWorkingSets());
+
+               for (IProject project : currentConfig.getWorkingSet().resolveProjects()) {
+                       for (Iterator<IWorkingSetProxy.ISnapshot> iter = unaffectedWorkingSets.iterator(); iter.hasNext();) {
+                               IWorkingSetProxy.ISnapshot next = iter.next();
+
+                               if (next.resolveProjects().contains(project)) {
+                                       iter.remove();
+
+                                       if (next.updateActiveConfigurations()) {
+                                               // major change. Refresh it altogether
+                                               tree.refresh(next);
+                                       } else {
+                                               // lighter-weight updates of its configs
+                                               for (IWorkingSetConfiguration config : next.getConfigurations()) {
+                                                       tree.update(config, null);
+                                               }
+                                       }
+                               }
+                       }
+               }
+
+               updateButtons();
+       }
+
+       /**
+        * Handler for the "Build" button.
+        */
+       private void buildConfig() {
+               final IStatus[] problem = new IStatus[1];
+
+               try {
+                       ProgressMonitorDialog dlg = new ProgressMonitorDialog(tree.getControl().getShell());
+                       dlg.run(true, true, new IRunnableWithProgress() {
+
+                               public void run(IProgressMonitor monitor) {
+                                       IStatus status = currentConfig.build(monitor);
+                                       if (status.matches(IStatus.WARNING | IStatus.ERROR)) {
+                                               problem[0] = status;
+                                       }
+                               }
+                       });
+               } catch (Exception e) {
+                       CUIPlugin.log(WorkingSetMessages.WSConfigsController_buildFailedLog, e);
+               }
+
+               // it is possible that some project configurations had to applied in
+               // order to effect a build. Refresh to handle that case
+               updateForActivation();
+
+               if (problem[0] != null) {
+                       // show the problem
+                       ErrorDialog.openError(tree.getControl().getShell(),
+                                       WorkingSetMessages.WSConfigsController_buildFailedDlgTitle,
+                                       WorkingSetMessages.WSConfigsController_buildFailedDlgMsg, problem[0]);
+               }
+       }
+
+       /**
+        * Updates the enablement state of the action buttons according to the current selection.
+        */
+       private void updateButtons() {
+               if (addButton != null) {
+                       addButton.setEnabled(currentWorkingSet != null);
+               }
+               if (removeButton != null) {
+                       removeButton.setEnabled((currentConfig != null) && !currentConfig.isReadOnly());
+               }
+               if (renameButton != null) {
+                       renameButton.setEnabled((currentConfig != null) && !currentConfig.isReadOnly());
+               }
+               if (activateButton != null) {
+                       activateButton.setEnabled((currentConfig != null) && !currentConfig.isActive());
+               }
+               if (buildButton != null) {
+                       buildButton.setEnabled(currentConfig != null);
+               }
+       }
+
+       /**
+        * Notification that the selection of configuration(s) in some project in the current working set
+        * configuration has changed. I accordingly update the visuals of the working-set configuration to
+        * indicate whether it is active or not.
+        * 
+        * @param project
+        *            the project configuration whose active configuration selections have changed
+        */
+       void projectSelectionsChanged(IWorkingSetProjectConfiguration project) {
+               tree.update(currentConfig, null);
+               updateButtons(); // depends on whether the ws config is active
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfiguration.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfiguration.java
new file mode 100644 (file)
index 0000000..eb9adb3
--- /dev/null
@@ -0,0 +1,384 @@
+/*******************************************************************************
+ * Copyright (c) 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import static org.eclipse.cdt.internal.ui.workingsets.WorkingSetConfigurationManager.ATTR_NAME;
+import static org.eclipse.cdt.internal.ui.workingsets.WorkingSetConfigurationManager.KEY_PROJECT;
+
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IWorkingSet;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * Default implementation of the {@link IWorkingSetConfiguration} interface.
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ * 
+ * @author Christian W. Damus (cdamus)
+ * 
+ * @since 6.0
+ * 
+ */
+public class WorkingSetConfiguration implements IWorkingSetConfiguration {
+       private final IWorkingSetProxy workingSet;
+       private String name;
+
+       private Map<String, IWorkingSetProjectConfiguration> projects;
+
+       /**
+        * Initializes me with my parent working set.
+        * 
+        * @param workingSet
+        *            my parent working set
+        */
+       protected WorkingSetConfiguration(IWorkingSetProxy workingSet) {
+               this.workingSet = workingSet;
+       }
+
+       /**
+        * Obtains my parent working set.
+        * 
+        * @return my parent
+        */
+       public IWorkingSetProxy getWorkingSet() {
+               return workingSet;
+       }
+
+       /**
+        * Obtains my name.
+        * 
+        * @return my name
+        */
+       public String getName() {
+               return name;
+       }
+
+       /**
+        * Sets my name.
+        * 
+        * @param name
+        *            my new name
+        * 
+        * @throws IllegalArgumentException
+        *             if the specified name is <code>null</code> or empty, or if it is already used by another
+        *             configuration in my warking set
+        */
+       void setName(String name) {
+               if ((name == null) || (name.length() == 0)) {
+                       throw new IllegalArgumentException("name is empty"); //$NON-NLS-1$
+               }
+
+               if (!name.equals(getName())) {
+                       if (getWorkingSet().getConfiguration(name) != null) {
+                               throw new IllegalArgumentException("name is already in use"); //$NON-NLS-1$
+                       }
+
+                       basicSetName(name);
+               }
+       }
+
+       /**
+        * Provides simple access to the name for setting it.
+        * 
+        * @param name
+        *            my new name
+        */
+       protected void basicSetName(String name) {
+               this.name = name;
+       }
+
+       private Map<String, IWorkingSetProjectConfiguration> getProjects() {
+               if (projects == null) {
+                       projects = new java.util.HashMap<String, IWorkingSetProjectConfiguration>();
+
+                       for (IProject next : workingSet.resolveProjects()) {
+                               IWorkingSetProjectConfiguration child = createProjectConfiguration(next);
+
+                               // the project may not be a C/C++ project
+                               if (child != null) {
+                                       basicAddProjectConfiguration(child);
+                               }
+                       }
+               }
+
+               return projects;
+       }
+
+       protected void basicAddProjectConfiguration(IWorkingSetProjectConfiguration projectConfig) {
+               if (projects == null) {
+                       projects = new java.util.HashMap<String, IWorkingSetProjectConfiguration>();
+               }
+
+               projects.put(projectConfig.getProjectName(), projectConfig);
+       }
+
+       public IWorkingSetProjectConfiguration getProjectConfiguration(String projectName) {
+               return getProjects().get(projectName);
+       }
+
+       public java.util.Collection<IWorkingSetProjectConfiguration> getProjectConfigurations() {
+               return getProjects().values();
+       }
+
+       public boolean isActive() {
+               boolean result = !getProjects().isEmpty();
+
+               if (result) {
+                       for (IWorkingSetProjectConfiguration next : getProjectConfigurations()) {
+                               if (!next.isActive()) {
+                                       result = false;
+                                       break;
+                               }
+                       }
+               }
+
+               return result;
+       }
+
+       public void activate() {
+               if (!isActive()) {
+                       for (IWorkingSetProjectConfiguration next : getProjectConfigurations()) {
+                               next.activate();
+                       }
+               }
+
+               // this is a "recently used" working set
+               IWorkingSet ws = getWorkingSet().resolve();
+               if (ws != null) {
+                       WorkingSetConfigurationManager.WS_MGR.addRecentWorkingSet(ws);
+               }
+       }
+
+       public IStatus build(IProgressMonitor monitor) {
+               MultiStatus result = new MultiStatus(CUIPlugin.PLUGIN_ID, 0,
+                               WorkingSetMessages.WSConfig_build_problems, null);
+
+               List<IWorkingSetProjectConfiguration> toBuild = new java.util.ArrayList<IWorkingSetProjectConfiguration>(
+                               getProjectConfigurations().size());
+               for (IWorkingSetProjectConfiguration next : getProjectConfigurations()) {
+                       IProject project = next.resolveProject();
+
+                       if ((project != null) && (project.isAccessible())) {
+                               toBuild.add(next);
+                       }
+               }
+
+               SubMonitor progress = SubMonitor.convert(monitor, NLS.bind(WorkingSetMessages.WSConfig_build_task,
+                               getWorkingSet().getName()), toBuild.size());
+
+               try {
+                       for (IWorkingSetProjectConfiguration next : toBuild) {
+                               if (progress.isCanceled()) {
+                                       result.add(Status.CANCEL_STATUS);
+                                       break;
+                               }
+
+                               IStatus status = next.build(progress.newChild(1));
+
+                               if ((status != null && !status.isOK())) {
+                                       result.add(status);
+                               }
+                       }
+               } finally {
+                       if (monitor != null) {
+                               monitor.done();
+                       }
+               }
+
+               return result.isOK() ? Status.OK_STATUS : result;
+       }
+
+       public void saveState(IMemento memento) {
+               memento.putString(ATTR_NAME, getName());
+
+               for (IWorkingSetProjectConfiguration next : getProjectConfigurations()) {
+                       next.saveState(memento.createChild(KEY_PROJECT));
+               }
+       }
+
+       public void loadState(IMemento memento) {
+               setName(memento.getString(ATTR_NAME));
+
+               Map<String, IMemento> projectMementos = new java.util.HashMap<String, IMemento>();
+               for (IMemento next : memento.getChildren(KEY_PROJECT)) {
+                       projectMementos.put(next.getString(ATTR_NAME), next);
+               }
+
+               for (IWorkingSetProjectConfiguration next : getProjectConfigurations()) {
+                       IMemento state = projectMementos.get(next.getProjectName());
+                       if (state != null) {
+                               next.loadState(state);
+                       }
+               }
+       }
+
+       /**
+        * Creates a new project configuration for the specified project. May be overridden by subclasses to
+        * create a different implementation.
+        * 
+        * @param project
+        *            a workspace project
+        * @return a new project configuration element for it
+        */
+       protected IWorkingSetProjectConfiguration createProjectConfiguration(IProject project) {
+               IWorkingSetProjectConfiguration result = null;
+
+               IWorkingSetProjectConfigurationFactory factory = IWorkingSetProjectConfigurationFactory.Registry.INSTANCE
+                               .getFactory(project);
+               if (factory != null) {
+                       result = factory.createProjectConfiguration(this, project);
+               }
+
+               return result;
+       }
+
+       public ISnapshot createSnapshot(IWorkingSetProxy.ISnapshot workingSet, WorkspaceSnapshot workspace) {
+
+               return new Snapshot(workingSet, this, workspace);
+       }
+
+       /**
+        * Utility method to query whether the specified configuration is a read-only snapshot.
+        * 
+        * @param config
+        *            a working set configuration
+        * @return whether it is a read-only snapshot
+        * 
+        * @see IWorkingSetConfiguration.ISnapshot#isReadOnly()
+        */
+       static boolean isReadOnly(IWorkingSetConfiguration config) {
+               return (config instanceof WorkingSetConfiguration.Snapshot)
+                               && ((WorkingSetConfiguration.Snapshot) config).isReadOnly();
+       }
+
+       //
+       // Nested classes
+       //
+
+       /**
+        * Default implementation of the mutable working set configuration snapshot.
+        * 
+        * @author Christian W. Damus (cdamus)
+        * 
+        * @noextend This class is not intended to be subclassed by clients.
+        * 
+        * @since 6.0
+        */
+       public static class Snapshot extends WorkingSetConfiguration implements
+                       IWorkingSetConfiguration.ISnapshot {
+
+               private final boolean readOnly;
+               private final WorkspaceSnapshot workspace;
+
+               /**
+                * Initializes me with the current workspace snapshot.
+                * 
+                * @param workingSet
+                *            my parent working set
+                * @param workspace
+                *            the current workspace snapshot
+                */
+               protected Snapshot(IWorkingSetProxy workingSet, WorkspaceSnapshot workspace) {
+                       this(workingSet, workspace, false);
+               }
+
+               /**
+                * Initializes me as a special read-only configuration that shows what is the current active
+                * configuration of the projects in a working set when none of its named configurations is active.
+                * 
+                * @param workingSet
+                *            my parent working set
+                * @param workspace
+                *            the current workspace snapshot
+                * @param readOnly
+                *            whether I am read-only. A read-only configuration cannot be modified in the dialog
+                */
+               protected Snapshot(IWorkingSetProxy workingSet, WorkspaceSnapshot workspace, boolean readOnly) {
+                       super(workingSet);
+
+                       this.readOnly = readOnly;
+                       this.workspace = workspace;
+               }
+
+               /**
+                * Initializes me with the current workspace snapshot.
+                * 
+                * @param workingSet
+                *            my parent working set
+                * @param config
+                *            the working set configuration that I copy
+                * @param workspace
+                *            the current workspace snapshot
+                */
+               protected Snapshot(IWorkingSetProxy workingSet, IWorkingSetConfiguration config,
+                               WorkspaceSnapshot workspace) {
+                       this(workingSet, workspace);
+
+                       setName(config.getName());
+
+                       for (IWorkingSetProjectConfiguration next : config.getProjectConfigurations()) {
+                               basicAddProjectConfiguration(next.createSnapshot(this, workspace));
+                       }
+               }
+
+               @Override
+               public final IWorkingSetProxy.ISnapshot getWorkingSet() {
+                       return (IWorkingSetProxy.ISnapshot) super.getWorkingSet();
+               }
+
+               public final WorkspaceSnapshot getWorkspaceSnapshot() {
+                       return workspace;
+               }
+
+               /**
+                * Queries whether I am a read-only view of the current active configurations of my working set's
+                * projects.
+                * 
+                * @return whether I am read-only
+                */
+               public final boolean isReadOnly() {
+                       return readOnly;
+               }
+
+               @Override
+               public void setName(String name) {
+                       super.setName(name);
+               }
+
+               /**
+                * I create project configurations that are mutable, as I am.
+                */
+               @Override
+               protected IWorkingSetProjectConfiguration createProjectConfiguration(IProject project) {
+                       IWorkingSetProjectConfiguration result = null;
+
+                       IWorkingSetProjectConfigurationFactory factory = IWorkingSetProjectConfigurationFactory.Registry.INSTANCE
+                                       .getFactory(project);
+                       if (factory != null) {
+                               result = factory.createProjectConfiguration(this, project).createSnapshot(this, workspace);
+                       }
+
+                       return result;
+               }
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationBlock.java
new file mode 100644 (file)
index 0000000..65b4695
--- /dev/null
@@ -0,0 +1,451 @@
+/*******************************************************************************
+ * Copyright (c) 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import java.util.Collection;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.resource.FontDescriptor;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.resource.LocalResourceManager;
+import org.eclipse.jface.resource.ResourceManager;
+import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.IFilter;
+import org.eclipse.jface.viewers.IFontProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleAdapter;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+
+import org.eclipse.cdt.ui.CDTSharedImages;
+
+import org.eclipse.cdt.internal.ui.dialogs.OptionalMessageDialog;
+
+/**
+ * A block of UI controls for management of working set configurations. These collect the selection of project
+ * configurations for the member projects of the working sets into named presets.
+ * 
+ * @author Christian W. Damus (cdamus)
+ * 
+ * @since 6.0
+ */
+public class WorkingSetConfigurationBlock {
+
+       private static final String BUILD_PROMPT_DIALOG_ID = "workingsets.build.prompt"; //$NON-NLS-1$
+       private static final int BUILD_PROMPT_DIALOG_NO = 0;
+       private static final int BUILD_PROMPT_DIALOG_CANCEL = 1;
+       private static final int BUILD_PROMPT_DIALOG_YES = 2;
+
+       private WorkspaceSnapshot workspace;
+       private WorkingSetConfigsController controller;
+
+       private IWorkingSetProxy.ISnapshot initialSelection;
+       private IFilter workingSetFilter;
+
+       private Control contents;
+
+       /**
+        * Initializes me. I take the most recently used working set as my initial selection.
+        * 
+        * @param workspace
+        *            the workspace snapshot to edit
+        */
+       public WorkingSetConfigurationBlock(WorkspaceSnapshot workspace) {
+               this(workspace, null);
+       }
+
+       /**
+        * Initializes me with my initial selection.
+        * 
+        * @param workspace
+        *            the workspace snapshot to edit
+        * @param initialSelection
+        *            my initial selection
+        */
+       public WorkingSetConfigurationBlock(WorkspaceSnapshot workspace,
+                       IWorkingSetProxy.ISnapshot initialSelection) {
+               
+               this.workspace = workspace;
+               this.initialSelection = initialSelection;
+       }
+
+       /**
+        * Queries the working set filter, if any, that restricts the display of working sets.
+        * 
+        * @return my working-set filter
+        */
+       public IFilter getWorkingSetFilter() {
+               return workingSetFilter;
+       }
+
+       /**
+        * Assigns a filter to restrict the working sets that are shown.
+        * 
+        * @param filter
+        *            a working-set filter
+        */
+       public void setWorkingSetFilter(IFilter filter) {
+               this.workingSetFilter = filter;
+       }
+
+       /**
+        * Creates the contents of the working set configuration management control block.
+        * 
+        * @param parent
+        *            the parent composite in which to create my controls
+        * 
+        * @return my controls
+        */
+       public Control createContents(Composite parent) {
+               SashForm sashForm = new SashForm(parent, SWT.VERTICAL | SWT.SMOOTH);
+
+               GridLayoutFactory layoutFactory = GridLayoutFactory.fillDefaults();
+               createWorkingSetConfigsArea(sashForm, layoutFactory.extendedMargins(0, 0, 0, 15));
+               createProjectConfigsArea(sashForm, layoutFactory.extendedMargins(0, 0, 15, 0));
+
+               sashForm.setWeights(new int[] { 1, 1 });
+
+               contents = sashForm;
+
+               return sashForm;
+       }
+
+       /**
+        * Creates the "working set configurations" pane in the upper part of the sash form.
+        * 
+        * @param parent
+        *            the parent composite
+        * @param layoutFactory
+        *            a layout-factory to use to lay out the composite in a grid, possibly pre-configured. Its use
+        *            is optional
+        * 
+        * @return the working set configurations pane
+        */
+       protected Composite createWorkingSetConfigsArea(Composite parent, GridLayoutFactory layoutFactory) {
+               Composite result = new Composite(parent, SWT.NONE);
+               layoutFactory.numColumns(2).applyTo(result);
+
+               GridDataFactory layoutDataFactory = GridDataFactory.fillDefaults();
+
+               Label label = new Label(result, SWT.NONE);
+               label.setText(WorkingSetMessages.WSConfigDialog_wsTree_label);
+               layoutDataFactory.span(2, 1).applyTo(label);
+
+               controller = new WorkingSetConfigsController(workspace, initialSelection);
+
+               TreeViewer tree = new TreeViewer(result);
+               layoutDataFactory.span(1, 1).align(SWT.FILL, SWT.FILL).grab(true, true).hint(250, SWT.DEFAULT)
+                               .applyTo(tree.getControl());
+
+               tree.setContentProvider(new WSConfigsContentProvider());
+               tree.setLabelProvider(new WSConfigsLabelProvider(tree));
+               controller.setTreeViewer(tree);
+
+               tree.setComparator(new ViewerComparator() {
+                       @Override
+                       public int category(Object element) {
+                               if (element instanceof IWorkingSetConfiguration.ISnapshot) {
+                                       IWorkingSetConfiguration.ISnapshot config = (IWorkingSetConfiguration.ISnapshot) element;
+                                       if (config.isReadOnly()) {
+                                               return 0;
+                                       }
+                               }
+                               return 1;
+                       }
+               });
+
+               tree.getTree().getAccessible().addAccessibleListener(new AccessibleAdapter() {
+                       @Override
+                       public void getName(AccessibleEvent e) {
+                               e.result = WorkingSetMessages.WSConfigDialog_wsTree_accessible_name;
+                       }
+               });
+
+               Composite buttons = new Composite(result, SWT.NONE);
+               layoutDataFactory.grab(false, false).hint(SWT.DEFAULT, SWT.DEFAULT).applyTo(buttons);
+               layoutFactory.numColumns(1).extendedMargins(0, 0, 0, 0).applyTo(buttons);
+
+               Button button = new Button(buttons, SWT.PUSH);
+               layoutDataFactory.align(SWT.FILL, SWT.BEGINNING).applyTo(button);
+               button.setText(WorkingSetMessages.WSConfigDialog_add_label);
+               controller.setAddButton(button);
+
+               button = new Button(buttons, SWT.PUSH);
+               layoutDataFactory.applyTo(button);
+               button.setText(WorkingSetMessages.WSConfigDialog_remove_label);
+               controller.setRemoveButton(button);
+
+               button = new Button(buttons, SWT.PUSH);
+               layoutDataFactory.applyTo(button);
+               button.setText(WorkingSetMessages.WSConfigDialog_rename_label);
+               controller.setRenameButton(button);
+
+               button = new Button(buttons, SWT.PUSH);
+               layoutDataFactory.applyTo(button);
+               button.setText(WorkingSetMessages.WSConfigDialog_activate_label);
+               controller.setActivateButton(button);
+
+               button = new Button(buttons, SWT.PUSH);
+               layoutDataFactory.applyTo(button);
+               button.setText(WorkingSetMessages.WSConfigDialog_build_label);
+               controller.setBuildButton(button);
+
+               return result;
+       }
+
+       /**
+        * Creates the "project configurations" pane in the lower part of the sash form.
+        * 
+        * @param parent
+        *            the parent composite
+        * @param layoutFactory
+        *            a layout-factory to use to lay out the composite in a grid, possibly pre-configured. Its use
+        *            is optional
+        * 
+        * @return the project configurations pane
+        */
+       protected Composite createProjectConfigsArea(Composite parent, GridLayoutFactory layoutFactory) {
+               Composite result = new Composite(parent, SWT.NONE);
+               layoutFactory.numColumns(1).applyTo(result);
+
+               GridDataFactory layoutDataFactory = GridDataFactory.fillDefaults();
+
+               Label label = new Label(result, SWT.NONE);
+               label.setText(WorkingSetMessages.WSConfigDialog_projTree_label);
+               layoutDataFactory.applyTo(label);
+
+               ProjectConfigsController projectsController = new ProjectConfigsController();
+               CheckboxTreeViewer tree = new CheckboxTreeViewer(result);
+               layoutDataFactory.span(1, 1).align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(tree.getControl());
+
+               controller.setProjectConfigsController(projectsController);
+               projectsController.setWorkingSetConfigurationsController(controller);
+
+               projectsController.setTreeViewer(tree);
+
+               tree.setComparator(new ViewerComparator());
+
+               tree.getTree().getAccessible().addAccessibleListener(new AccessibleAdapter() {
+                       @Override
+                       public void getName(AccessibleEvent e) {
+                               e.result = WorkingSetMessages.WSConfigDialog_projTree_accessible_name;
+                       }
+               });
+
+               return result;
+       }
+
+       /**
+        * Saves the working set configurations to storage.
+        */
+       public void save() {
+               workspace.save();
+       }
+
+       /**
+        * Builds the projects that were reconfigured by the dialog, if any. The user is prompted (if prompting is
+        * not disabled via the preference) before building. The user has the options to build, not build, or
+        * cancel. The result indicates cancellation.
+        * 
+        * @return <code>true</code> if the user opted to save changes and exit the dialog (with or without
+        *         build); <code>false</code> if the user cancelled and the dialog should remain open and unsaved
+        */
+       public boolean build() {
+               boolean result = true;
+               Collection<IProject> projects = workspace.getProjectsToBuild();
+
+               if (!projects.isEmpty()) {
+                       int defaultButton = OptionalMessageDialog.getDialogDetail(BUILD_PROMPT_DIALOG_ID);
+                       if (defaultButton == OptionalMessageDialog.NO_DETAIL) {
+                               defaultButton = BUILD_PROMPT_DIALOG_YES; // yes button is the default-default
+                       }
+
+                       int button = OptionalMessageDialog.open(BUILD_PROMPT_DIALOG_ID, contents.getShell(),
+                                       WorkingSetMessages.WSConfigDialog_buildPrompt_title, null,
+                                       WorkingSetMessages.WSConfigDialog_buildPrompt_message, MessageDialog.QUESTION,
+                                       new String[] { IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL,
+                                                       IDialogConstants.YES_LABEL }, defaultButton);
+
+                       if (button == OptionalMessageDialog.NOT_SHOWN) {
+                               // handle the case where the dialog was suppressed. Get the current default
+                               button = defaultButton;
+                       } else if (button != BUILD_PROMPT_DIALOG_CANCEL) {
+                               // store non-cancel selection as the new default answer
+                               OptionalMessageDialog.setDialogDetail(BUILD_PROMPT_DIALOG_ID, button);
+                       }
+
+                       switch (button) {
+                       case BUILD_PROMPT_DIALOG_YES:
+                               // do the build
+                               new BuildJob(projects).schedule();
+                               break;
+                       case BUILD_PROMPT_DIALOG_NO:
+                               // just don't build
+                               break;
+                       default: // BUILD_PROMPT_DIALOG_CANCEL
+                               result = false;
+                               break;
+                       }
+               }
+
+               return result;
+       }
+
+       //
+       // Nested classes
+       //
+
+       /**
+        * Simple content provider for the working set configurations tree.
+        * 
+        * @author Christian W. Damus (cdamus)
+        */
+       private class WSConfigsContentProvider implements ITreeContentProvider {
+               private Collection<IWorkingSetProxy> workingSets;
+
+               public Object[] getChildren(Object parentElement) {
+                       if (parentElement == workingSets) {
+                               Collection<IWorkingSetProxy> filtered = filterWorkingSets(workingSets);
+                               return filtered.toArray();
+                       } else if (parentElement instanceof IWorkingSetProxy) {
+                               return ((IWorkingSetProxy) parentElement).getConfigurations().toArray();
+                       } else {
+                               return new Object[0];
+                       }
+               }
+
+               private Collection<IWorkingSetProxy> filterWorkingSets(Collection<IWorkingSetProxy> workingSets) {
+                       if (workingSetFilter == null) {
+                               return workingSets;
+                       }
+
+                       Collection<IWorkingSetProxy> result = new java.util.ArrayList<IWorkingSetProxy>();
+
+                       for (IWorkingSetProxy next : workingSets) {
+                               if (workingSetFilter.select(next)) {
+                                       result.add(next);
+                               }
+                       }
+
+                       return result;
+               }
+
+               public Object getParent(Object element) {
+                       return (element instanceof IWorkingSetConfiguration) ? ((IWorkingSetConfiguration) element)
+                                       .getWorkingSet() : null;
+               }
+
+               public boolean hasChildren(Object element) {
+                       return (element != null) && !(element instanceof IWorkingSetConfiguration);
+               }
+
+               public Object[] getElements(Object inputElement) {
+                       return getChildren(inputElement);
+               }
+
+               public void dispose() {
+                       // nothing to dispose
+               }
+
+               @SuppressWarnings("unchecked")
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+                       workingSets = (Collection<IWorkingSetProxy>) newInput;
+               }
+
+       }
+
+       /**
+        * Label provider for working sets and their configurations. The active configuration is highlighted in
+        * bold and affixed with an "(active)" decoration. The special read-only configuration is further
+        * differentiated with an italic font.
+        * 
+        * @author Christian W. Damus (cdamus)
+        */
+       private class WSConfigsLabelProvider extends LabelProvider implements IFontProvider {
+               private WorkbenchLabelProvider wbLabels = new WorkbenchLabelProvider();
+               private Image configImage = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_CONFIG);
+               private Font defaultFont;
+               private ResourceManager fonts = new LocalResourceManager(JFaceResources.getResources());
+
+               WSConfigsLabelProvider(Viewer viewer) {
+                       defaultFont = viewer.getControl().getFont();
+               }
+
+               @Override
+               public String getText(Object element) {
+                       if (element instanceof IWorkingSetConfiguration) {
+                               IWorkingSetConfiguration config = (IWorkingSetConfiguration) element;
+
+                               if (config.isActive()) {
+                                       return WorkingSetConfiguration.isReadOnly(config)
+                                                       ? WorkingSetMessages.WSConfigDialog_implicit_config : NLS.bind(
+                                                                       WorkingSetMessages.WSConfigDialog_active_config, config.getName());
+                               }
+                               return config.getName();
+                       } else if (element instanceof IWorkingSetProxy) {
+                               return ((IWorkingSetProxy) element).resolve().getLabel();
+                       }
+
+                       return wbLabels.getText(element);
+               }
+
+               @Override
+               public Image getImage(Object element) {
+                       if (element instanceof IWorkingSetConfiguration) {
+                               return configImage;
+                       } else if (element instanceof IWorkingSetProxy) {
+                               return wbLabels.getImage(((IWorkingSetProxy) element).resolve());
+                       }
+
+                       return wbLabels.getImage(element);
+               }
+
+               @Override
+               public void dispose() {
+                       wbLabels.dispose();
+                       fonts.dispose();
+                       super.dispose();
+               }
+
+               public Font getFont(Object element) {
+                       if (element instanceof IWorkingSetConfiguration) {
+                               IWorkingSetConfiguration config = (IWorkingSetConfiguration) element;
+                               if (config.isActive()) {
+                                       FontDescriptor desc = FontDescriptor.createFrom(defaultFont);
+
+                                       desc = WorkingSetConfiguration.isReadOnly(config) ? desc.withStyle(SWT.BOLD | SWT.ITALIC)
+                                                       : desc.withStyle(SWT.BOLD);
+                                       return (Font) fonts.get(desc);
+                               }
+                       }
+
+                       return wbLabels.getFont(element);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationDialog.java
new file mode 100644 (file)
index 0000000..2413066
--- /dev/null
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.TrayDialog;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * A dialog for management of working set configurations. These collect the selection of project
+ * configurations for the member projects of the working sets into named presets.
+ * 
+ * @author Christian W. Damus (cdamus)
+ * 
+ * @since 6.0
+ */
+public class WorkingSetConfigurationDialog extends TrayDialog {
+
+       private WorkingSetConfigurationBlock block;
+
+       /**
+        * Initializes me with my shell.
+        * 
+        * @param shell
+        */
+       public WorkingSetConfigurationDialog(Shell shell) {
+               super(shell);
+       }
+
+       /**
+        * Initializes me with my shell provider.
+        * 
+        * @param parentShell
+        */
+       public WorkingSetConfigurationDialog(IShellProvider parentShell) {
+               super(parentShell);
+       }
+
+       @Override
+       protected boolean isResizable() {
+               return true;
+       }
+
+       @Override
+       protected void configureShell(Shell newShell) {
+               setHelpAvailable(false);
+
+               super.configureShell(newShell);
+
+               newShell.setText(WorkingSetMessages.WSConfigDialog_title);
+       }
+
+       @Override
+       protected Control createDialogArea(Composite parent) {
+               Composite result = (Composite) super.createDialogArea(parent);
+
+               block = new WorkingSetConfigurationBlock(WorkingSetConfigurationManager.getDefault()
+                               .createWorkspaceSnapshot());
+               Control contents = block.createContents(result);
+               contents.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+               return result;
+       }
+
+       @Override
+       protected void buttonPressed(int buttonId) {
+               if (buttonId == IDialogConstants.OK_ID) {
+                       if (!block.build()) {
+                               // user cancelled: don't save, and don't close the dialog
+                               return;
+                       }
+
+                       block.save();
+               }
+
+               super.buttonPressed(buttonId);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationManager.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationManager.java
new file mode 100644 (file)
index 0000000..4094044
--- /dev/null
@@ -0,0 +1,415 @@
+/*******************************************************************************
+ * Copyright (c) 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetManager;
+import org.eclipse.ui.XMLMemento;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.newui.CDTPrefUtil;
+
+/**
+ * The purveyor of working set configurations. It provides a current view of the {@linkplain IWorkingSetProxy
+ * working set configurations} defined in the workspace, as well as a working-copy
+ * {@linkplain WorkspaceSnapshot snapshot} of the same for making modifications.
+ * 
+ * @author Christian W. Damus (cdamus)
+ * 
+ * @since 6.0
+ * 
+ */
+public class WorkingSetConfigurationManager {
+
+       static final String TYPE_WORKING_SET_CONFIGS = "org.eclipse.cdt.ui.workingSetConfigurations"; //$NON-NLS-1$
+       static final String KEY_WORKING_SET = "workingSet"; //$NON-NLS-1$
+       static final String ATTR_NAME = "name"; //$NON-NLS-1$
+       static final String KEY_CONFIG = "config"; //$NON-NLS-1$
+       static final String KEY_PROJECT = "project"; //$NON-NLS-1$
+       static final String ATTR_CONFIG = "config"; //$NON-NLS-1$
+       static final String ATTR_FACTORY = "factory"; //$NON-NLS-1$
+
+       static IWorkingSetManager WS_MGR = CUIPlugin.getDefault().getWorkbench().getWorkingSetManager();
+
+       private static final WorkingSetConfigurationManager INSTANCE = new WorkingSetConfigurationManager();
+
+       private Map<String, IWorkingSetProxy> workingSets;
+
+       private final Object storeLock = new Object();
+       private IMemento store;
+
+       private final ISchedulingRule saveRule = new ISchedulingRule() {
+
+               public boolean isConflicting(ISchedulingRule rule) {
+                       return rule == this;
+               }
+
+               public boolean contains(ISchedulingRule rule) {
+                       return rule == this;
+               }
+       };
+
+       /**
+        * Not instantiable by clients.
+        */
+       private WorkingSetConfigurationManager() {
+               store = loadMemento();
+               new WorkingSetChangeTracker();
+       }
+
+       /**
+        * Obtains the default working set configuration manager.
+        * 
+        * @return the working set configuration manager
+        */
+       public static WorkingSetConfigurationManager getDefault() {
+               return INSTANCE;
+       }
+
+       private Map<String, IWorkingSetProxy> getWorkingSetMap() {
+               Map<String, IWorkingSetProxy> result;
+
+               synchronized (storeLock) {
+                       if (workingSets == null) {
+                               load();
+                       }
+                       result = workingSets;
+               }
+
+               return result;
+       }
+
+       /**
+        * Obtains the current immutable view of the specified working set's configurations. These configurations
+        * may be {@linkplain IWorkingSetConfiguration#activate() activated} to apply their settings to the
+        * workspace, but they cannot be modified.
+        * 
+        * @param name
+        *            the name of the working set to retrieve
+        * @return the named working set, or <code>null</code> if there is none available by that name
+        */
+       public IWorkingSetProxy getWorkingSet(String name) {
+               return getWorkingSetMap().get(name);
+       }
+
+       /**
+        * Obtains the current immutable view of all available working set configurations. These configurations
+        * may be {@linkplain IWorkingSetConfiguration#activate() activated} to apply their settings to the
+        * workspace, but they cannot be modified.
+        * 
+        * @return the working set configurations
+        */
+       public Collection<IWorkingSetProxy> getWorkingSets() {
+               return getWorkingSetMap().values();
+       }
+
+       /**
+        * Creates a new mutable snapshot of the current working set configurations. This snapshot accepts
+        * modifications and can be {@linkplain WorkspaceSnapshot#save() saved} to persist the changes.
+        * 
+        * @return a working-copy of the working set configurations
+        */
+       public WorkspaceSnapshot createWorkspaceSnapshot() {
+               return new WorkspaceSnapshot().initialize(getWorkingSetMap());
+       }
+
+       /**
+        * <p>
+        * Loads the working set configurations from storage.
+        * </p>
+        * <p>
+        * <b>Note</b> that this method must only be called within the <tt>storeLock</tt> monitor.
+        * </p>
+        */
+       private void load() {
+               workingSets = new java.util.HashMap<String, IWorkingSetProxy>();
+
+               for (IMemento next : store.getChildren(KEY_WORKING_SET)) {
+                       WorkingSetProxy ws = new WorkingSetProxy();
+
+                       ws.loadState(next);
+
+                       if (ws.isValid()) {
+                               workingSets.put(ws.getName(), ws);
+                       }
+               }
+       }
+
+       /**
+        * <p>
+        * Forgets the current view of the working set configurations.
+        * </p>
+        * <p>
+        * <b>Note</b> that this method must only be called within the <tt>storeLock</tt> monitor.
+        * </p>
+        */
+       private void clear() {
+               workingSets = null;
+       }
+
+       /**
+        * Saves the working set configurations to storage.
+        * 
+        * @param snapshot
+        *            the snapshot to save
+        */
+       void save(WorkspaceSnapshot snapshot) {
+               final XMLMemento memento = XMLMemento.createWriteRoot(TYPE_WORKING_SET_CONFIGS);
+
+               for (IWorkingSetConfigurationElement next : snapshot.getWorkingSets()) {
+                       next.saveState(memento.createChild(KEY_WORKING_SET));
+               }
+
+               save(memento);
+       }
+
+       /**
+        * Records the specified memento as our new store and asynchronously saves it in a job.
+        * 
+        * @param memento
+        *            the new store
+        */
+       private void save(final XMLMemento memento) {
+               synchronized (storeLock) {
+                       store = memento;
+                       clear();
+               }
+
+               new Job(WorkingSetMessages.WSConfigManager_save_job) {
+                       {
+                               setRule(saveRule);
+                               setSystem(true);
+                       }
+
+                       @Override
+                       protected IStatus run(IProgressMonitor monitor) {
+
+                               File file = getStorage();
+                               FileWriter writer = null;
+                               try {
+                                       writer = new FileWriter(file);
+                                       memento.save(writer);
+                                       writer.close();
+                               } catch (IOException e) {
+                                       if (writer != null) {
+                                               try {
+                                                       writer.close();
+                                               } catch (IOException e2) {
+                                                       // no recovery
+                                                       CUIPlugin.log(WorkingSetMessages.WSConfigManager_closeFailed, e);
+                                               }
+                                       }
+
+                                       file.delete(); // it is corrupt; we won't be able to load it, later
+
+                                       CUIPlugin.log(WorkingSetMessages.WSConfigManager_saveFailed, e);
+                               }
+                               return Status.OK_STATUS;
+                       }
+               }.schedule();
+       }
+
+       /**
+        * Gets the file in which we persist the working set configurations.
+        * 
+        * @return the file store
+        */
+       private File getStorage() {
+               IPath path = CUIPlugin.getDefault().getStateLocation().append("workingSetConfigs.xml"); //$NON-NLS-1$
+               return path.toFile();
+       }
+
+       /**
+        * Loads the working set configurations from storage. For compatibility, if the XML file is not available,
+        * we load from the old preference setting format.
+        * 
+        * @return the working set configuration store
+        */
+       private IMemento loadMemento() {
+               IMemento result = null;
+
+               File file = getStorage();
+
+               if (file.exists()) {
+                       FileReader reader = null;
+                       try {
+                               reader = new FileReader(file);
+                               result = XMLMemento.createReadRoot(reader);
+                               reader.close();
+                       } catch (Exception e) {
+                               result = null;
+
+                               if (reader != null) {
+                                       try {
+                                               reader.close();
+                                       } catch (IOException e2) {
+                                               // no recovery
+                                               CUIPlugin.log(WorkingSetMessages.WSConfigManager_closeFailed, e);
+                                       }
+                               }
+
+                               CUIPlugin.log(WorkingSetMessages.WSConfigManager_loadFailed, e);
+                       }
+               }
+
+               if (result == null) {
+                       // fake one from the old preference storage format. This also
+                       // handles the case of no working set configurations ever being made
+                       @SuppressWarnings("deprecation")
+                       List<String> configSetStrings = CDTPrefUtil.readConfigSets();
+                       result = XMLMemento.createWriteRoot(TYPE_WORKING_SET_CONFIGS);
+
+                       // collect the unordered entries by working set
+                       Map<String, IMemento> configMap = new HashMap<String, IMemento>();
+                       for (String next : configSetStrings) {
+                               String[] bits = next.split(" "); //$NON-NLS-1$
+
+                               if (bits.length >= 2) {
+                                       String configName = bits[0];
+                                       String wsName = bits[1];
+
+                                       IMemento workingSet = configMap.get(wsName);
+                                       if (workingSet == null) {
+                                               workingSet = result.createChild(KEY_WORKING_SET);
+                                               configMap.put(wsName, workingSet);
+                                       }
+
+                                       workingSet.putString(ATTR_NAME, wsName);
+
+                                       IMemento config = workingSet.createChild(KEY_CONFIG);
+                                       config.putString(ATTR_NAME, configName);
+
+                                       int limit = bits.length - (bits.length % 2);
+                                       for (int i = 2; i < limit; i += 2) {
+                                               IMemento project = config.createChild(KEY_PROJECT);
+                                               project.putString(ATTR_NAME, bits[i]);
+                                               project.putString(ATTR_CONFIG, bits[i + 1]);
+                                       }
+                               }
+                       }
+               }
+
+               return result;
+       }
+
+       //
+       // Nested classes
+       //
+
+       /**
+        * A working set manager listener that tracks name changes and removals of working sets to keep our
+        * configurations in synch as much as possible. It updates the memento store directly in response to
+        * changes in the working sets.
+        * 
+        * @author Christian W. Damus (cdamus)
+        * 
+        * @since 6.0
+        */
+       private class WorkingSetChangeTracker extends java.util.IdentityHashMap<IWorkingSet, String> implements
+                       IPropertyChangeListener {
+
+               WorkingSetChangeTracker() {
+                       for (IWorkingSet next : WS_MGR.getWorkingSets()) {
+                               put(next, next.getName());
+                       }
+
+                       WS_MGR.addPropertyChangeListener(this);
+               }
+
+               public void propertyChange(PropertyChangeEvent event) {
+                       String property = event.getProperty();
+
+                       if (IWorkingSetManager.CHANGE_WORKING_SET_NAME_CHANGE.equals(property)) {
+                               handleNameChange((IWorkingSet) event.getNewValue());
+                       } else if (IWorkingSetManager.CHANGE_WORKING_SET_REMOVE.equals(property)) {
+                               handleRemove((IWorkingSet) event.getOldValue());
+                       } else if (IWorkingSetManager.CHANGE_WORKING_SET_ADD.equals(property)) {
+                               handleAdd((IWorkingSet) event.getNewValue());
+                       }
+               }
+
+               private void handleNameChange(IWorkingSet workingSet) {
+                       synchronized (storeLock) {
+                               String oldName = get(workingSet);
+                               IMemento wsMemento = null;
+                               if (oldName != null) {
+                                       for (IMemento next : store.getChildren(KEY_WORKING_SET)) {
+                                               if (oldName.equals(next.getString(ATTR_NAME))) {
+                                                       wsMemento = next;
+                                                       break;
+                                               }
+                                       }
+                               }
+
+                               if (wsMemento != null) {
+                                       // update the memento with the new name
+                                       wsMemento.putString(ATTR_NAME, workingSet.getName());
+
+                                       // clone it
+                                       XMLMemento newStore = XMLMemento.createWriteRoot(TYPE_WORKING_SET_CONFIGS);
+                                       newStore.putMemento(store);
+
+                                       // save it asynchronously
+                                       save(newStore);
+                               }
+
+                               // and update our mapping
+                               put(workingSet, workingSet.getName());
+                       }
+               }
+
+               private void handleRemove(IWorkingSet workingSet) {
+                       synchronized (storeLock) {
+                               String name = get(workingSet);
+                               if (name != null) {
+                                       // remove the memento from the store
+                                       XMLMemento newStore = XMLMemento.createWriteRoot(TYPE_WORKING_SET_CONFIGS);
+                                       for (IMemento next : store.getChildren(KEY_WORKING_SET)) {
+                                               if (!name.equals(next.getString(ATTR_NAME))) {
+                                                       newStore.createChild(KEY_WORKING_SET).putMemento(next);
+                                               }
+                                       }
+
+                                       // save asynchronously
+                                       save(newStore);
+                               }
+
+                               // and update our mapping
+                               remove(workingSet);
+                       }
+               }
+
+               private void handleAdd(IWorkingSet workingSet) {
+                       synchronized (storeLock) {
+                               put(workingSet, workingSet.getName());
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationsPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetConfigurationsPage.java
new file mode 100644 (file)
index 0000000..dbbf15a
--- /dev/null
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.viewers.IFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+/**
+ * Property page for the configurations of a working set.
+ * 
+ * @author Christian W. Damus (cdamus)
+ * 
+ * @since 6.0
+ */
+public class WorkingSetConfigurationsPage extends PropertyPage {
+
+       private WorkingSetConfigurationBlock block;
+
+       /**
+        * Initializes me.
+        */
+       public WorkingSetConfigurationsPage() {
+               super();
+               
+               noDefaultAndApplyButton();
+       }
+
+       @Override
+       protected Control createContents(Composite parent) {
+               Composite result = new Composite(parent, SWT.NONE);
+               GridLayoutFactory.fillDefaults().margins(5, 5).applyTo(result);
+
+               final WorkspaceSnapshot workspace = WorkingSetConfigurationManager.getDefault()
+                               .createWorkspaceSnapshot();
+               final IWorkingSetProxy.ISnapshot workingSet = getWorkingSet(workspace);
+
+               if (workingSet == null) {
+                       new Label(result, SWT.NONE).setText(WorkingSetMessages.WSetConfigsPage_noProjects);
+               } else {
+                       block = new WorkingSetConfigurationBlock(workspace, workingSet);
+                       block.setWorkingSetFilter(new IFilter() {
+
+                               public boolean select(Object toTest) {
+                                       return toTest == workingSet;
+                               }
+                       });
+
+                       Control contents = block.createContents(result);
+                       contents.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               }
+
+               return result;
+       }
+
+       private IWorkingSetProxy.ISnapshot getWorkingSet(WorkspaceSnapshot workspace) {
+               IWorkingSetProxy.ISnapshot result = null;
+               IWorkingSet realWorkingSet = (IWorkingSet) getElement().getAdapter(IWorkingSet.class);
+
+               if (realWorkingSet != null) {
+                       result = workspace.getWorkingSet(realWorkingSet.getName());
+                       if ((result != null) && result.resolveProjects().isEmpty()) {
+                               // no C/C++ projects to configure
+                               result = null;
+                       }
+               }
+
+               return result;
+       }
+       
+       @Override
+       public boolean performOk() {
+               if (!block.build()) {
+                       // user cancelled: don't save, and don't close the property page
+                       return false;
+               }
+
+               block.save();
+               return true;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetMessages.java
new file mode 100644 (file)
index 0000000..238152e
--- /dev/null
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 IBM Corporation, QNX Software Systems, and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software Systems - [272416] Rework the working set configurations
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class WorkingSetMessages extends NLS {
+
+       private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.workingsets.WorkingSetMessages";//$NON-NLS-1$
+
+       private WorkingSetMessages() {
+               // Do not instantiate
+       }
+
+       public static String CElementWorkingSetPage_title;
+       public static String CElementWorkingSetPage_name;
+       public static String CElementWorkingSetPage_description;
+       public static String CElementWorkingSetPage_content;
+       public static String CElementWorkingSetPage_warning_nameMustNotBeEmpty;
+       public static String CElementWorkingSetPage_warning_workingSetExists;
+       public static String CElementWorkingSetPage_warning_resourceMustBeChecked;
+       
+       public static String ProjConfigController_activeConfig;
+
+       public static String WorkingSetMenus_enumPattern;
+       public static String WorkspaceSnapshot_buildNoProj;
+       
+       public static String WSConfig_build_problems;
+       public static String WSConfig_build_task;
+       
+       public static String WSConfigDialog_activate_label;
+       public static String WSConfigDialog_active_config;
+       public static String WSConfigDialog_add_label;
+       public static String WSConfigDialog_build_label;
+       public static String WSConfigDialog_buildPrompt_message;
+       public static String WSConfigDialog_buildPrompt_title;
+       public static String WSConfigDialog_implicit_config;
+       public static String WSConfigDialog_projTree_accessible_name;
+       public static String WSConfigDialog_projTree_label;
+       public static String WSConfigDialog_remove_label;
+       public static String WSConfigDialog_rename_label;
+       public static String WSConfigDialog_title;
+       public static String WSConfigDialog_wsTree_accessible_name;
+       public static String WSConfigDialog_wsTree_label;
+
+       public static String WSConfigManager_closeFailed;
+       public static String WSConfigManager_loadFailed;
+       public static String WSConfigManager_save_job;
+       public static String WSConfigManager_saveFailed;
+       
+       public static String WSConfigsController_addDlg_defaultName;
+       public static String WSConfigsController_addDlg_emptyName;
+       public static String WSConfigsController_addDlg_msg;
+       public static String WSConfigsController_addDlg_nameExists;
+       public static String WSConfigsController_addDlg_title;
+       public static String WSConfigsController_buildFailedDlgMsg;
+       public static String WSConfigsController_buildFailedDlgTitle;
+       public static String WSConfigsController_buildFailedLog;
+       public static String WSConfigsController_renameDlg_msg;
+       public static String WSConfigsController_renameDlg_title;
+       
+       public static String WSetConfigsPage_noProjects;
+       
+       public static String WSProjConfig_activatedWarning;
+       public static String WSProjConfig_buildProblem;
+       public static String WSProjConfig_noConfig;
+       
+       public static String WSProjConfigFactory_badFactory;
+       public static String WSProjConfigFactory_factoryFailed;
+       public static String WSProjConfigFactory_noFactoryID;
+       public static String WSProjConfigFactory_noNatureID;
+
+       static {
+               NLS.initializeMessages(BUNDLE_NAME, WorkingSetMessages.class);
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetMessages.properties
new file mode 100644 (file)
index 0000000..d22113a
--- /dev/null
@@ -0,0 +1,71 @@
+###############################################################################
+# Copyright (c) 2000, 2009 IBM Corporation, QNX Software Systems, and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+#     Anton Leherbauer (Wind River Systems)
+#     QNX Software Systems - [272416] Rework the working set configurations
+###############################################################################
+
+CElementWorkingSetPage_title= C/C++ Working Set
+CElementWorkingSetPage_name= &Working set name:
+CElementWorkingSetPage_description= Enter a working set name and select the working set elements.
+
+CElementWorkingSetPage_content= Working set &content:
+CElementWorkingSetPage_warning_nameMustNotBeEmpty= The name must not be empty.
+CElementWorkingSetPage_warning_workingSetExists= A working set with that name already exists.
+CElementWorkingSetPage_warning_resourceMustBeChecked= At least one resource must be checked.
+
+ProjConfigController_activeConfig={0} (active)
+
+WorkingSetMenus_enumPattern=&{0} {1}
+WorkspaceSnapshot_buildNoProj=Attempt to build project that does not exist: {0}
+
+WSConfig_build_problems=Problems occurred in building the working set.
+WSConfig_build_task=Building working set "{0}"
+
+WSConfigDialog_activate_label=&Set Active
+WSConfigDialog_active_config={0} (active)
+WSConfigDialog_add_label=&Add...
+WSConfigDialog_build_label=&Build
+WSConfigDialog_buildPrompt_message=Some projects have had their active configurations changed, and need to be re-built.  Build them now?
+WSConfigDialog_buildPrompt_title=Build New Configuration
+WSConfigDialog_implicit_config=(active)
+WSConfigDialog_projTree_accessible_name=Project configuration selection tree
+WSConfigDialog_projTree_label=Project configurations:
+WSConfigDialog_remove_label=&Remove
+WSConfigDialog_rename_label=Re&name...
+WSConfigDialog_title=Manage Working Set Configurations
+WSConfigDialog_wsTree_accessible_name=Working sets and configurations tree
+WSConfigDialog_wsTree_label=Working set configurations:
+
+WSConfigManager_closeFailed=Failed to close working set configurations file.
+WSConfigManager_loadFailed=Failed to load working set configurations.
+WSConfigManager_save_job=Saving working set configurations
+WSConfigManager_saveFailed=Failed to save working set configurations.
+
+WSConfigsController_addDlg_defaultName=NewConfiguration
+WSConfigsController_addDlg_emptyName=The name must not be empty.
+WSConfigsController_addDlg_msg=Enter a name for the new configuration.
+WSConfigsController_addDlg_nameExists=A configuration with that name already exists.
+WSConfigsController_addDlg_title=Add Working Set Configuration
+WSConfigsController_buildFailedDlgMsg=Problems occurred during the build.
+WSConfigsController_buildFailedDlgTitle=Build Problems
+WSConfigsController_buildFailedLog=Exception occurred in working-set build.
+WSConfigsController_renameDlg_msg=Enter a new name for the configuration.
+WSConfigsController_renameDlg_title=Rename Working Set Configuration
+
+WSetConfigsPage_noProjects=Working set does not include any C/C++ projects.
+
+WSProjConfig_activatedWarning=Set configuration "{0}" active in project "{1}".
+WSProjConfig_buildProblem=Problems occurred in building project "{0}".
+WSProjConfig_noConfig=No configuration selected for project "{0}".
+
+WSProjConfigFactory_badFactory=Invalid project configuration factory in plug-in {0}.  Expected an IWorkingSetProjectConfigurationFactory.
+WSProjConfigFactory_factoryFailed=Failed to create project configuration factory.
+WSProjConfigFactory_noFactoryID=Missing ID in project configuration factory extension in plug-in {0}
+WSProjConfigFactory_noNatureID=Missing nature ID in project configuration factory in plug-in {0}.
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetProjectConfiguration.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetProjectConfiguration.java
new file mode 100644 (file)
index 0000000..b0fec6f
--- /dev/null
@@ -0,0 +1,298 @@
+/*******************************************************************************
+ * Copyright (c) 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import static org.eclipse.cdt.internal.ui.workingsets.WorkingSetConfigurationManager.ATTR_CONFIG;
+import static org.eclipse.cdt.internal.ui.workingsets.WorkingSetConfigurationManager.ATTR_NAME;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.IMemento;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * Default implementation of the {@link IWorkingSetProjectConfiguration} interface. Clients may extend this
+ * class to implement additional project configuration settings.
+ * 
+ * @author Christian W. Damus (cdamus)
+ * 
+ * @since 6.0
+ * 
+ */
+public class WorkingSetProjectConfiguration implements IWorkingSetProjectConfiguration {
+       private final IWorkingSetConfiguration workingSetConfig;
+       private String projectName;
+       private String selectedConfiguration;
+
+       /**
+        * Initializes me with my parent working set configuration.
+        * 
+        * @param parent
+        *            my parent working set configuration
+        */
+       protected WorkingSetProjectConfiguration(IWorkingSetConfiguration parent) {
+               this.workingSetConfig = parent;
+       }
+
+       public IWorkingSetConfiguration getWorkingSetConfiguration() {
+               return workingSetConfig;
+       }
+
+       public String getProjectName() {
+               return projectName;
+       }
+
+       /**
+        * Sets my project name. Note that this <b>does not</b> change the name of the project that I represent.
+        * Rather, it changes <i>which</i> project I represent.
+        * 
+        * @param projectName
+        *            my new project name
+        */
+       protected void setProjectName(String projectName) {
+               this.projectName = projectName;
+       }
+
+       public IProject resolveProject() {
+               IProject result = ResourcesPlugin.getWorkspace().getRoot().getProject(getProjectName());
+
+               if ((result != null) && !result.isAccessible()) {
+                       result = null;
+               }
+
+               return result;
+       }
+
+       public String getSelectedConfigurationID() {
+               return selectedConfiguration;
+       }
+
+       protected void setSelectedConfigurationID(String id) {
+               this.selectedConfiguration = id;
+       }
+
+       public ICConfigurationDescription resolveSelectedConfiguration() {
+               ICConfigurationDescription result = null;
+
+               IProject project = resolveProject();
+               if (project != null) {
+                       ICProjectDescription desc = CoreModel.getDefault().getProjectDescription(project);
+
+                       if (desc != null) {
+                               result = desc.getConfigurationById(getSelectedConfigurationID());
+                       }
+               }
+
+               return result;
+       }
+
+       public Collection<ICConfigurationDescription> resolveConfigurations() {
+               ICConfigurationDescription[] result = null;
+
+               IProject project = resolveProject();
+               if (project != null) {
+                       ICProjectDescription desc = CoreModel.getDefault().getProjectDescription(project);
+
+                       if (desc != null) {
+                               result = desc.getConfigurations();
+                       }
+               }
+
+               return (result == null) ? Collections.<ICConfigurationDescription> emptyList() : Arrays
+                               .asList(result);
+       }
+
+       public boolean isActive() {
+               ICConfigurationDescription desc = resolveSelectedConfiguration();
+
+               return (desc != null) && desc.isActive();
+       }
+
+       public void activate() {
+               ICConfigurationDescription config = resolveSelectedConfiguration();
+
+               if (config != null) {
+                       ICProjectDescription desc = config.getProjectDescription();
+
+                       if (desc.getActiveConfiguration() != config) {
+                               try {
+                                       IProject project = desc.getProject();
+                                       desc.setActiveConfiguration(config);
+                                       CoreModel.getDefault().setProjectDescription(project, desc);
+                               } catch (CoreException e) {
+                                       CUIPlugin.log(e);
+                               }
+                       }
+               }
+       }
+
+       public IStatus build(IProgressMonitor monitor) {
+               IStatus result = Status.OK_STATUS;
+
+               ICConfigurationDescription config = resolveSelectedConfiguration();
+
+               if (config == null) {
+                       result = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, NLS.bind(
+                                       WorkingSetMessages.WSProjConfig_noConfig, getProjectName()));
+               } else {
+                       if (!isActive()) {
+                               activate();
+                               result = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, NLS.bind(
+                                               WorkingSetMessages.WSProjConfig_activatedWarning, config.getName(), getProjectName()));
+                       }
+
+                       monitor = SubMonitor.convert(monitor);
+
+                       try {
+                               resolveProject().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
+                       } catch (CoreException e) {
+                               if (result.isOK()) {
+                                       result = e.getStatus();
+                               } else {
+                                       result = new MultiStatus(CUIPlugin.PLUGIN_ID, 0, new IStatus[] { result, e.getStatus() },
+                                                       NLS.bind(WorkingSetMessages.WSProjConfig_buildProblem, getProjectName()), null);
+                               }
+                       }
+               }
+
+               return result;
+       }
+
+       public void saveState(IMemento memento) {
+               memento.putString(ATTR_NAME, getProjectName());
+
+               if (getSelectedConfigurationID() != null) {
+                       memento.putString(ATTR_CONFIG, getSelectedConfigurationID());
+               }
+       }
+
+       public void loadState(IMemento memento) {
+               projectName = memento.getString(ATTR_NAME);
+               selectedConfiguration = memento.getString(ATTR_CONFIG);
+       }
+
+       public ISnapshot createSnapshot(IWorkingSetConfiguration.ISnapshot workingSetConfig,
+                       WorkspaceSnapshot workspace) {
+
+               return new Snapshot(workingSetConfig, this, workspace);
+       }
+
+       //
+       // Nested classes
+       //
+
+       /**
+        * Default implementation of the mutable project configuration snapshot.
+        * 
+        * @author Christian W. Damus (cdamus)
+        * 
+        * @since 6.0
+        */
+       public static class Snapshot extends WorkingSetProjectConfiguration implements
+                       IWorkingSetProjectConfiguration.ISnapshot {
+
+               private final IProject project;
+               private final WorkspaceSnapshot workspace;
+
+               /**
+                * Initializes me with the project that I represent and the workspace snapshot. I discover the
+                * currently defined configurations for my project and initially select the one that is currently
+                * active, or the first available if none is active (which would be odd).
+                * 
+                * @param parent
+                *            my parent working set configuration
+                * @param projectConfig
+                *            the project configuration to copy
+                * @param workspace
+                *            the current workspace snapshot
+                */
+               protected Snapshot(IWorkingSetConfiguration parent, IWorkingSetProjectConfiguration projectConfig,
+                               WorkspaceSnapshot workspace) {
+
+                       super(parent);
+
+                       this.project = projectConfig.resolveProject();
+                       this.workspace = workspace;
+
+                       String selected = projectConfig.getSelectedConfigurationID();
+                       if (selected == null) {
+                               selected = workspace.getActiveConfigurationID(project);
+                       }
+                       setSelectedConfigurationID(selected);
+               }
+
+               @Override
+               public IWorkingSetConfiguration.ISnapshot getWorkingSetConfiguration() {
+                       return (IWorkingSetConfiguration.ISnapshot) super.getWorkingSetConfiguration();
+               }
+
+               public final WorkspaceSnapshot getWorkspaceSnapshot() {
+                       return workspace;
+               }
+
+               @Override
+               public final IProject resolveProject() {
+                       return project;
+               }
+
+               @Override
+               public final String getProjectName() {
+                       return resolveProject().getName();
+               }
+
+               @Override
+               public void setSelectedConfigurationID(String id) {
+                       super.setSelectedConfigurationID(id);
+               }
+
+               @Override
+               public boolean isActive() {
+                       return workspace.isActive(this);
+               }
+
+               @Override
+               public void activate() {
+                       workspace.activate(resolveProject(), getSelectedConfigurationID());
+               }
+
+               @Override
+               public IStatus build(IProgressMonitor monitor) {
+                       return workspace.build(resolveProject(), getSelectedConfigurationID(), monitor);
+               }
+
+               @Override
+               public Collection<ICConfigurationDescription> resolveConfigurations() {
+                       return workspace.getConfigurations(resolveProject());
+               }
+
+               @Override
+               public ICConfigurationDescription resolveSelectedConfiguration() {
+                       return workspace.getConfiguration(resolveProject(), getSelectedConfigurationID());
+               }
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetPropertyTester.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetPropertyTester.java
new file mode 100644 (file)
index 0000000..0d9cb66
--- /dev/null
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.ui.IWorkingSet;
+
+import org.eclipse.cdt.core.model.CoreModel;
+
+/**
+ * Property tester for working sets that CDT can manipulate in cool ways, such
+ * as managing build configurations.
+ *
+ * @author Christian W. Damus (cdamus)
+ * 
+ * @since 6.0
+ *
+ */
+public class WorkingSetPropertyTester extends PropertyTester {
+
+       private static final String P_HAS_C_PROJECTS = "hasCProjects"; //$NON-NLS-1$
+       
+       /**
+        * Initializes me.
+        */
+       public WorkingSetPropertyTester() {
+               super();
+       }
+
+       public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+               if (P_HAS_C_PROJECTS.equals(property)) {
+                       return hasCProjects(getWorkingSet(receiver));
+               }
+               
+               return false;
+       }
+
+       private IWorkingSet getWorkingSet(Object object) {
+               IWorkingSet result = null;
+               
+               if (object instanceof IWorkingSet) {
+                       result = (IWorkingSet) object;
+               } else if (object instanceof IAdaptable) {
+                       result = (IWorkingSet) ((IAdaptable) object).getAdapter(IWorkingSet.class);
+               }
+               
+               return result;
+       }
+       
+       private boolean hasCProjects(IWorkingSet workingSet) {
+               boolean result = false;
+               
+               if (workingSet != null) {
+                       IAdaptable[] members = workingSet.getElements();
+                       
+                       for (IAdaptable next : members) {
+                               IProject project = (IProject) next.getAdapter(IProject.class);
+                               
+                               if ((project != null) && CoreModel.hasCNature(project)) {
+                                       result = true;
+                                       break;
+                               }
+                       }
+               }
+               
+               return result;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetProxy.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkingSetProxy.java
new file mode 100644 (file)
index 0000000..0545e28
--- /dev/null
@@ -0,0 +1,328 @@
+/*******************************************************************************
+ * Copyright (c) 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import static org.eclipse.cdt.internal.ui.workingsets.WorkingSetConfigurationManager.ATTR_NAME;
+import static org.eclipse.cdt.internal.ui.workingsets.WorkingSetConfigurationManager.KEY_CONFIG;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IWorkingSet;
+
+import com.ibm.icu.text.UCharacterIterator;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+
+/**
+ * Default implementation of the {@link IWorkingSetProxy} interface.
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ * 
+ * @author Christian W. Damus (cdamus)
+ * 
+ * @since 6.0
+ */
+public class WorkingSetProxy implements IWorkingSetProxy {
+       private String name;
+       private Map<String, IWorkingSetConfiguration> configurations;
+
+       /**
+        * Initializes me.
+        */
+       public WorkingSetProxy() {
+               super();
+       }
+
+       public String getName() {
+               return name;
+       }
+
+       /**
+        * Sets my name. This <b>does not</b> change the name of the working set that I represent. Rather, it
+        * changes <i>which</i> working set I represent.
+        * 
+        * @param name
+        *            my new name
+        */
+       void setName(String name) {
+               this.name = name;
+       }
+
+       public IWorkingSet resolve() {
+               return WorkingSetConfigurationManager.WS_MGR.getWorkingSet(name);
+       }
+
+       public Collection<IProject> resolveProjects() {
+               Set<IProject> result = new java.util.HashSet<IProject>();
+
+               IWorkingSet resolvedWS = resolve();
+               if (resolvedWS != null) {
+                       for (IAdaptable next : resolvedWS.getElements()) {
+                               IProject proj = (IProject) next.getAdapter(IProject.class);
+
+                               if (proj != null) {
+                                       result.add(proj);
+                               }
+                       }
+               }
+
+               return result;
+       }
+
+       public boolean isValid() {
+               return !resolveProjects().isEmpty();
+       }
+
+       private Map<String, IWorkingSetConfiguration> getConfigurationsMap() {
+               if (configurations == null) {
+                       configurations = new java.util.HashMap<String, IWorkingSetConfiguration>();
+               }
+
+               return configurations;
+       }
+
+       public IWorkingSetConfiguration getConfiguration(String name) {
+               return getConfigurationsMap().get(name);
+       }
+
+       public Collection<IWorkingSetConfiguration> getConfigurations() {
+               return getConfigurationsMap().values();
+       }
+
+       public void saveState(IMemento memento) {
+               memento.putString(ATTR_NAME, getName());
+
+               for (IWorkingSetConfiguration next : getConfigurations()) {
+                       if (!isTransient(next)) {
+                               next.saveState(memento.createChild(KEY_CONFIG));
+                       }
+               }
+       }
+
+       /**
+        * Queries whether the specified configuration is transient, meaning that it should not be persisted in
+        * the working set configuration store. The default implementation just returns <code>false</code>;
+        * subclasses may redefine as required.
+        * 
+        * @param config
+        *            a working set configuration
+        * @return whether it should be omitted from persistence
+        */
+       protected boolean isTransient(IWorkingSetConfiguration config) {
+               return false;
+       }
+
+       public void loadState(IMemento memento) {
+               setName(memento.getString(ATTR_NAME));
+
+               for (IMemento next : memento.getChildren(KEY_CONFIG)) {
+                       IWorkingSetConfiguration config = createWorkingSetConfiguration();
+                       config.loadState(next);
+                       getConfigurationsMap().put(config.getName(), config);
+               }
+       }
+
+       /**
+        * Creates a new child working set configuration element. Subclasses may override to create custom
+        * implementations.
+        * 
+        * @return the new working set configuration
+        */
+       protected IWorkingSetConfiguration createWorkingSetConfiguration() {
+               return new WorkingSetConfiguration(this);
+       }
+
+       /**
+        * Provides simple access to the child configurations, to remove the specified configuration.
+        * 
+        * @param config
+        *            a configuration to remove
+        */
+       protected void basicRemoveConfiguration(IWorkingSetConfiguration config) {
+               getConfigurationsMap().remove(config.getName());
+       }
+
+       /**
+        * Provides simple access to the child configurations, to add the specified configuration.
+        * 
+        * @param config
+        *            a configuration to add
+        */
+       protected void basicAddConfiguration(IWorkingSetConfiguration config) {
+               getConfigurationsMap().put(config.getName(), config);
+       }
+
+       public ISnapshot createSnapshot(WorkspaceSnapshot workspace) {
+               Snapshot result = new Snapshot(this, workspace);
+
+               result.updateActiveConfigurations();
+
+               return result;
+       }
+
+       //
+       // Nested classes
+       //
+
+       /**
+        * The default implementation of a mutable working set snapshot.
+        * 
+        * @noextend This class is not intended to be subclassed by clients.
+        * 
+        * @author Christian W. Damus (cdamus)
+        * 
+        * @since 6.0
+        */
+       public static class Snapshot extends WorkingSetProxy implements IWorkingSetProxy.ISnapshot {
+               private final WorkspaceSnapshot workspace;
+               private IWorkingSetConfiguration.ISnapshot readOnlyConfig;
+
+               /**
+                * Initializes me with the current workspace snapshot.
+                * 
+                * @param workingSet
+                *            the original working set element to copy
+                * @param workspace
+                *            the workspace snapshot
+                */
+               protected Snapshot(IWorkingSetProxy workingSet, WorkspaceSnapshot workspace) {
+                       super();
+
+                       this.workspace = workspace;
+
+                       setName(workingSet.getName());
+
+                       for (IWorkingSetConfiguration next : workingSet.getConfigurations()) {
+                               basicAddConfiguration(next.createSnapshot(this, workspace));
+                       }
+               }
+
+               public final WorkspaceSnapshot getWorkspaceSnapshot() {
+                       return workspace;
+               }
+
+               public IWorkingSetConfiguration.ISnapshot createConfiguration(String name) {
+                       if ((name == null) || (name.length() == 0)) {
+                               throw new IllegalArgumentException("name is empty"); //$NON-NLS-1$
+                       }
+                       if (getConfiguration(name) != null) {
+                               throw new IllegalArgumentException("name is already in use"); //$NON-NLS-1$
+                       }
+
+                       IWorkingSetConfiguration.ISnapshot result = createWorkingSetConfiguration();
+                       result.setName(name);
+
+                       heuristicSelectProjectConfigurations(result);
+
+                       basicAddConfiguration(result);
+                       updateActiveConfigurations();
+
+                       return result;
+               }
+
+               /**
+                * Heuristically attempts to select reasonable default project configurations for a new working-set
+                * configuration. This implementation does a best-effort match of project configuration names against
+                * the working set configuration name.
+                * 
+                * @param newConfig
+                *            the new working set configuration
+                */
+               protected void heuristicSelectProjectConfigurations(IWorkingSetConfiguration.ISnapshot newConfig) {
+                       String nameToSearch = getSearchKey(newConfig.getName());
+
+                       for (IWorkingSetProjectConfiguration next : newConfig.getProjectConfigurations()) {
+                               IWorkingSetProjectConfiguration.ISnapshot project = (IWorkingSetProjectConfiguration.ISnapshot) next;
+
+                               for (ICConfigurationDescription config : project.resolveConfigurations()) {
+                                       if (nameToSearch.equalsIgnoreCase(getSearchKey(config.getName()))) {
+                                               // a match! Select this config
+                                               project.setSelectedConfigurationID(config.getId());
+                                               break;
+                                       }
+                               }
+                       }
+
+               }
+
+               private String getSearchKey(String configurationName) {
+                       StringBuilder result = new StringBuilder(configurationName.length());
+
+                       UCharacterIterator iter = UCharacterIterator.getInstance(configurationName);
+                       for (int cp = iter.nextCodePoint(); cp != UCharacterIterator.DONE; cp = iter.nextCodePoint()) {
+                               if (Character.isLetterOrDigit(cp)) {
+                                       result.appendCodePoint(cp);
+                               }
+                       }
+
+                       return result.toString();
+               }
+
+               /**
+                * I create working-set configuration snapshots that are mutable, as I am.
+                */
+               @Override
+               protected IWorkingSetConfiguration.ISnapshot createWorkingSetConfiguration() {
+                       return new WorkingSetConfiguration.Snapshot(this, workspace);
+               }
+
+               public void removeConfiguration(IWorkingSetConfiguration config) {
+                       if (WorkingSetConfiguration.isReadOnly(config)) {
+                               throw new IllegalArgumentException("config is read-only"); //$NON-NLS-1$
+                       }
+
+                       basicRemoveConfiguration(config);
+               }
+
+               public boolean updateActiveConfigurations() {
+                       boolean result = getConfigurations().isEmpty();
+
+                       boolean hasActiveConfig = false;
+                       for (IWorkingSetConfiguration next : getConfigurations()) {
+                               if (next.isActive() && !WorkingSetConfiguration.isReadOnly(next)) {
+                                       hasActiveConfig = true;
+                                       break;
+                               }
+                       }
+
+                       if (hasActiveConfig) {
+                               if (readOnlyConfig != null) {
+                                       basicRemoveConfiguration(readOnlyConfig);
+                                       result = true;
+                               }
+                               readOnlyConfig = null;
+                       } else {
+                               WorkingSetConfiguration.Snapshot ro = new WorkingSetConfiguration.Snapshot(this, workspace,
+                                               true);
+                               ro.basicSetName(""); // don't want to validate this name //$NON-NLS-1$
+                               readOnlyConfig = ro;
+                               basicAddConfiguration(readOnlyConfig);
+                               result = true;
+                       }
+
+                       return result;
+               }
+
+               /**
+                * Read-only working set configuration snapshots are transient.
+                */
+               @Override
+               protected boolean isTransient(IWorkingSetConfiguration config) {
+                       return WorkingSetConfiguration.isReadOnly(config);
+               }
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkspaceSnapshot.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/workingsets/WorkspaceSnapshot.java
new file mode 100644 (file)
index 0000000..64f2270
--- /dev/null
@@ -0,0 +1,525 @@
+/*******************************************************************************
+ * Copyright (c) 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.internal.ui.workingsets;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.IWorkingSet;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * <p>
+ * A snapshot of the working set configurations and project configurations across the workspace at the time
+ * when it was created. The snapshot maintains a delta from that original state to the current state, for such
+ * comparison operations as determining which projects need to be re-built because their active configurations
+ * have changed. The snapshot provides mutable working-copy views of the working set configurations at the
+ * time of snapshot creation.
+ * </p>
+ * <p>
+ * To make changes to working set configurations, first
+ * {@linkplain WorkingSetConfigurationManager#createWorkspaceSnapshot() obtain a snapshot} from the
+ * {@link WorkingSetConfigurationManager}. Then make edits to the various snapshots of the configuration
+ * elements and {@linkplain #save() save} the snapshot
+ * </p>
+ * 
+ * @author Christian W. Damus (cdamus)
+ * 
+ * @since 6.0
+ * 
+ */
+public class WorkspaceSnapshot {
+       private Map<String, IWorkingSetProxy.ISnapshot> workingSets = new java.util.HashMap<String, IWorkingSetProxy.ISnapshot>();
+       private Map<IProject, ProjectState> projectStates = new java.util.HashMap<IProject, ProjectState>();
+
+       /**
+        * Initializes me. I capture the current C/C++ active configuration state of the projects in the
+        * workspace.
+        */
+       WorkspaceSnapshot() {
+               IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+
+               for (IProject next : root.getProjects()) {
+                       ICProjectDescription desc = CoreModel.getDefault().getProjectDescription(next);
+
+                       if (desc != null) {
+                               projectStates.put(next, createProjectState(next, desc));
+                       }
+               }
+       }
+
+       /**
+        * Creates a project state using the registered factory, if possible.
+        * 
+        * @param project
+        *            a workspace project
+        * @param desc
+        *            its CDT project description
+        * 
+        * @return its state capture (will never be <code>null</code>)
+        */
+       private static ProjectState createProjectState(IProject project, ICProjectDescription desc) {
+               ProjectState result = null;
+               IWorkingSetProjectConfigurationFactory factory = IWorkingSetProjectConfigurationFactory.Registry.INSTANCE
+                               .getFactory(project);
+
+               if (factory != null) {
+                       result = factory.createProjectState(project, desc);
+               }
+
+               if (result == null) {
+                       // the default-default
+                       result = new ProjectState(project, desc);
+               }
+
+               return result;
+       }
+
+       /**
+        * Initializes me with the specified working sets to copy for editing.
+        * 
+        * @param workingSets
+        *            the working sets to copy
+        * @return myself
+        */
+       WorkspaceSnapshot initialize(Map<String, IWorkingSetProxy> workingSets) {
+               for (IWorkingSet next : WorkingSetConfigurationManager.WS_MGR.getWorkingSets()) {
+                       IWorkingSetProxy workingSet = workingSets.get(next.getName());
+
+                       if (workingSet == null) {
+                               workingSet = new WorkingSetProxy();
+                               ((WorkingSetProxy) workingSet).setName(next.getName());
+                       }
+
+                       if (workingSet.isValid()) {
+                               this.workingSets.put(workingSet.getName(), workingSet.createSnapshot(this));
+                       }
+               }
+
+               return this;
+       }
+
+       /**
+        * Obtains a mutable snapshot of the named working set.
+        * 
+        * @param name
+        *            the working set to retrieve
+        * 
+        * @return the working set snapshot, or <code>null</code> if there is no working set by this name
+        * 
+        * @see #getWorkingSets()
+        */
+       public IWorkingSetProxy.ISnapshot getWorkingSet(String name) {
+               return workingSets.get(name);
+       }
+
+       /**
+        * Obtains snapshots of all of the working sets currently defined by the workbench.
+        * 
+        * @return the working set snapshots
+        * 
+        * @see #getWorkingSet(String)
+        */
+       public Collection<IWorkingSetProxy.ISnapshot> getWorkingSets() {
+               return workingSets.values();
+       }
+
+       /**
+        * Obtains the project state recording the initial configuration of the specified <tt>project</tt> at the
+        * time that this snapshot was taken.
+        * 
+        * @param project
+        *            a project
+        * @return its snapshot/delta state
+        */
+       public ProjectState getState(IProject project) {
+               return projectStates.get(project);
+       }
+
+       /**
+        * Queries the ID of the configuration of the specified project that was active when the workspace
+        * snapshot was taken.
+        * 
+        * @param project
+        *            a project
+        * @return its active configuration ID at the time of the snapshot
+        */
+       String getBaselineConfigurationID(IProject project) {
+               String result = null;
+               ProjectState state = getState(project);
+
+               if (state != null) {
+                       result = state.getBaselineConfigurationID();
+               }
+
+               return result;
+       }
+
+       /**
+        * Queries the ID of the currently active configuration of the specified project.
+        * 
+        * @param project
+        *            a project
+        * 
+        * @return the current active configuration ID
+        */
+       String getActiveConfigurationID(IProject project) {
+               String result = null;
+               ProjectState state = getState(project);
+
+               if (state != null) {
+                       result = state.getActiveConfigurationID();
+               }
+
+               return result;
+       }
+
+       /**
+        * Queries whether the configuration selected by the given project in a working set configuration is
+        * currently active in the workspace.
+        * 
+        * @param project
+        *            a project configuration element in a working set configuration
+        * 
+        * @return whether the project's selected configuration is active
+        * 
+        * @see #activate(IProject, String)
+        */
+       boolean isActive(IWorkingSetProjectConfiguration project) {
+               boolean result = false;
+               ProjectState state = getState(project.resolveProject());
+
+               if (state != null) {
+                       result = state.isActive(project.getSelectedConfigurationID());
+               }
+
+               return result;
+       }
+
+       /**
+        * Activates, in the workspace, the specified configuration of a project. This method has no effect if the
+        * given configuration is already active.
+        * 
+        * @param project
+        *            the project for which to set the active configuration
+        * @param configID
+        *            the ID of the configuration to activate
+        * 
+        * @see #isActive(IWorkingSetProjectConfiguration)
+        */
+       void activate(IProject project, String configID) {
+               ProjectState state = getState(project);
+
+               if (state != null) {
+                       state.activate(configID);
+               }
+       }
+
+       IStatus build(IProject project, String configID, IProgressMonitor monitor) {
+               ProjectState state = getState(project);
+
+               if (state != null) {
+                       return state.build(configID, monitor);
+               }
+
+               return new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, NLS.bind(
+                               WorkingSetMessages.WorkspaceSnapshot_buildNoProj, project.getName()));
+       }
+
+       /**
+        * Obtains the configurations of the specified project, as known at the time that this snapshot was taken.
+        * 
+        * @param project
+        *            a project
+        * 
+        * @return its configurations, which may be an empty collection if the project is not a C/C++ project
+        */
+       public Collection<ICConfigurationDescription> getConfigurations(IProject project) {
+               Collection<ICConfigurationDescription> result;
+               ProjectState state = getState(project);
+
+               if (state == null) {
+                       result = Collections.emptyList();
+               } else {
+                       result = state.getConfigurations();
+               }
+
+               return result;
+       }
+
+       /**
+        * Obtains the specified configuration of a project, as known at the time that this snapshot was taken.
+        * 
+        * @param project
+        *            a project
+        * @param id
+        *            the ID of a configuration
+        * 
+        * @return the configuration, or <code>null</code> if there is none such by this ID
+        */
+       public ICConfigurationDescription getConfiguration(IProject project, String id) {
+               ProjectState state = getState(project);
+               return (state == null) ? null : state.getConfiguration(id);
+       }
+
+       /**
+        * Queries the projects that need to be built because their active configurations have been changed since
+        * this snapshot was taken.
+        * 
+        * @return the projects needing to be re-built
+        */
+       public Collection<IProject> getProjectsToBuild() {
+               Collection<IProject> result = new java.util.ArrayList<IProject>();
+
+               for (ProjectState next : projectStates.values()) {
+                       if (next.needsBuild()) {
+                               result.add(next.getProject());
+                       }
+               }
+
+               return result;
+       }
+
+       /**
+        * Saves my working set configuration settings.
+        */
+       public void save() {
+               WorkingSetConfigurationManager.getDefault().save(this);
+       }
+
+       //
+       // Nested classes
+       //
+
+       /**
+        * Capture of the current state of a project at the time when a {@linkplain WorkspaceSnapshot workspace
+        * snapshot} was taken, and its delta from that original state. This tracks at least the C/C++ project
+        * description (if any) and the original active configuration. Subclasses may track additional
+        * configuration details.
+        * 
+        * @author Christian W. Damus (cdamus)
+        * 
+        * @since 6.0
+        */
+       public static class ProjectState {
+               private final IProject project;
+               private final ICProjectDescription projectDescription;
+               private final String baselineConfigID;
+               private String currentConfigID;
+               private String lastBuiltConfigID;
+
+               /**
+                * Initializes me with a project and its description.
+                * 
+                * @param project
+                *            the project whose state I track
+                * @param desc
+                *            the project's description, from which I capture the initial state snapshot
+                */
+               protected ProjectState(IProject project, ICProjectDescription desc) {
+                       this.project = project;
+                       this.projectDescription = desc;
+
+                       if (desc != null) {
+                               ICConfigurationDescription config = desc.getActiveConfiguration();
+                               this.baselineConfigID = (config == null) ? "" : config.getId(); //$NON-NLS-1$
+                       } else {
+                               this.baselineConfigID = ""; //$NON-NLS-1$
+                       }
+
+                       this.currentConfigID = this.baselineConfigID;
+               }
+
+               /**
+                * Obtains the project that I track.
+                * 
+                * @return my project
+                */
+               public final IProject getProject() {
+                       return project;
+               }
+
+               /**
+                * Obtains the project description that was current when the snapshot was taken.
+                * 
+                * @return my project description
+                */
+               protected final ICProjectDescription getProjectDescription() {
+                       return projectDescription;
+               }
+
+               /**
+                * Queries whether my project needs to be re-built because its active configuration has been changed
+                * since the snapshot was taken, and it hasn't been built already.
+                * 
+                * @return whether I need to be re-built
+                */
+               public boolean needsBuild() {
+                       return !currentConfigID.equals(baselineConfigID) && !currentConfigID.equals(lastBuiltConfigID);
+               }
+
+               /**
+                * Queries whether the specified configuration is currently active in the workspace for my project.
+                * 
+                * @param configID
+                *            the ID of a project build configuration
+                * @return whether it is my project's active configuration
+                */
+               public boolean isActive(String configID) {
+                       return currentConfigID.equals(configID);
+               }
+
+               /**
+                * Queries the ID of the currently active configuration.
+                * 
+                * @return the current active configuration ID
+                */
+               protected String getActiveConfigurationID() {
+                       return currentConfigID;
+               }
+
+               /**
+                * Queries the ID of the configuration of my project that was active when the workspace snapshot was
+                * taken.
+                * 
+                * @return its active configuration ID at the time of the snapshot
+                */
+               protected String getBaselineConfigurationID() {
+                       return baselineConfigID;
+               }
+
+               /**
+                * Sets my project's active configuration to the specified configuration. This method has no effect if
+                * this configuration is already active.
+                * 
+                * @param configID
+                *            the ID of the configuration to activate
+                */
+               protected void activate(String configID) {
+                       if (!currentConfigID.equals(configID) && (projectDescription != null)) {
+                               try {
+                                       ICConfigurationDescription realConfig = projectDescription.getConfigurationById(configID);
+                                       realConfig.setActive();
+                                       CoreModel.getDefault().setProjectDescription(project, projectDescription);
+                                       currentConfigID = configID;
+                               } catch (CoreException e) {
+                                       CUIPlugin.log(e);
+                               }
+                       }
+               }
+
+               /**
+                * Builds the specified configuration of my project. I update myself to record a new build baseline if
+                * the build succeeds.
+                * 
+                * @param configID
+                *            the configuration to build
+                * @param monitor
+                *            a monitor to report build progress
+                * 
+                * @return the status of the build
+                */
+               protected IStatus build(String configID, IProgressMonitor monitor) {
+                       IStatus result = Status.OK_STATUS;
+
+                       ICConfigurationDescription config = getConfiguration(configID);
+
+                       if (config == null) {
+                               result = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, NLS.bind(
+                                               WorkingSetMessages.WSProjConfig_noConfig, getProject().getName()));
+                       } else {
+                               if (!isActive(configID)) {
+                                       activate(configID);
+                                       result = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, NLS.bind(
+                                                       WorkingSetMessages.WSProjConfig_activatedWarning, config.getName(), getProject()
+                                                                       .getName()));
+                               }
+
+                               monitor = SubMonitor.convert(monitor);
+
+                               try {
+                                       getProject().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
+
+                                       // update the build baseline to this config, which is now active
+                                       built(configID);
+                               } catch (CoreException e) {
+                                       if (result.isOK()) {
+                                               result = e.getStatus();
+                                       } else {
+                                               result = new MultiStatus(CUIPlugin.PLUGIN_ID, 0, new IStatus[] { result,
+                                                               e.getStatus() }, NLS.bind(WorkingSetMessages.WSProjConfig_buildProblem,
+                                                               getProject().getName()), null);
+                                       }
+                               }
+                       }
+
+                       return result;
+               }
+
+               /**
+                * Records that we built the specified configuration ID. I will not {@linkplain #needsBuild() need a
+                * build} if the last build configuration is my active configuration.
+                * 
+                * @param configID
+                *            the configuration that was built (not <code>null</code>)
+                */
+               protected void built(String configID) {
+                       lastBuiltConfigID = configID;
+               }
+
+               /**
+                * Obtains the configurations of my project that were defined at the time that the snapshot was taken.
+                * 
+                * @return my project's configurations, which may be empty if it is not a C/C++ project
+                */
+               protected Collection<ICConfigurationDescription> getConfigurations() {
+                       Collection<ICConfigurationDescription> result;
+
+                       if (projectDescription == null) {
+                               result = Collections.emptyList();
+                       } else {
+                               result = Arrays.asList(projectDescription.getConfigurations());
+                       }
+
+                       return result;
+               }
+
+               /**
+                * Obtains the specified configuration of my project as it was defined at the time that the snapshot
+                * was taken.
+                * 
+                * @param id
+                *            a configuration ID
+                * @return the matching configuration, or <code>null</code> if it did not exist
+                */
+               protected ICConfigurationDescription getConfiguration(String id) {
+                       return (projectDescription == null) ? null : projectDescription.getConfigurationById(id);
+               }
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTSharedImages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTSharedImages.java
new file mode 100644 (file)
index 0000000..73cbf49
--- /dev/null
@@ -0,0 +1,385 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Andrew Gvozdev and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Andrew Gvozdev (Quoin Inc.) - initial API and implementation
+ *    Patrick Chuong (Texas Instruments) - Add support for icon overlay in the debug view (Bug 334566)
+ *******************************************************************************/
+package org.eclipse.cdt.ui;
+
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.jface.viewers.DecorationOverlayIcon;
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * A repository for common images used by the CDT which may be useful to other plug-ins.
+ * <p>
+ * This class provides {@link Image} and {@link ImageDescriptor}
+ * for each named image in the interface.  All {@code Image} objects provided
+ * by this class are managed by this class and must never be disposed
+ * by other clients.
+ * </p>
+ * <p>
+ * For common platform images see {@link org.eclipse.ui.ISharedImages}
+ * ({@code org.eclipse.ui.PlatformUI.getWorkbench().getSharedImages()})
+ * <br>
+ * and {@link org.eclipse.ui.ide.IDE.SharedImages}.
+ * </p>
+ * <p>
+ * Note that org.eclipse.cdt.ui.tests.misc.CDTSharedImagesTests will verify
+ * existence of the images defined here.
+ * </p>
+ *
+ * @noextend This class is not intended to be subclassed by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ * 
+ * @since 5.3
+ */
+public class CDTSharedImages {
+       private static final char OVERLAY_SEPARATOR = '.';
+       private static ImageRegistry imageRegistry = new ImageRegistry(CUIPlugin.getStandardDisplay());
+       private static Map<String, URL> urlMap = new HashMap<String, URL>();
+
+       public static final String IMG_OBJS_TEMPLATE = "icons/obj16/template_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_VARIABLE = "icons/obj16/variable_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_LOCAL_VARIABLE = "icons/obj16/variable_local_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_CLASS = "icons/obj16/class_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_CLASS_ALT = "icons/obj16/classfo_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_NAMESPACE = "icons/obj16/namespace_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_USING = "icons/obj16/using_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_STRUCT = "icons/obj16/struct_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_STRUCT_ALT = "icons/obj16/structfo_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_UNION = "icons/obj16/union_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_UNION_ALT = "icons/obj16/unionfo_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_TYPEDEF = "icons/obj16/typedef_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_TYPEDEF_ALT = "icons/obj16/typedeffo_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_ENUMERATION = "icons/obj16/enum_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_ENUMERATION_ALT = "icons/obj16/enumfo_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_UNKNOWN_TYPE = "icons/obj16/unknown_type_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_ENUMERATOR = "icons/obj16/enumerator_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_FUNCTION = "icons/obj16/function_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_PUBLIC_METHOD = "icons/obj16/method_public_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_PROTECTED_METHOD = "icons/obj16/method_protected_obj.gif"; //$NON-NLS-1$
+
+       public static final String IMG_OBJS_PRIVATE_METHOD = "icons/obj16/method_private_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_PUBLIC_FIELD = "icons/obj16/field_public_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_PROTECTED_FIELD = "icons/obj16/field_protected_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_PRIVATE_FIELD = "icons/obj16/field_private_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_KEYWORD = "icons/obj16/keyword_obj.gif"; //$NON-NLS-1$
+
+       public static final String IMG_OBJS_DECLARATION = "icons/obj16/cdeclaration_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_VAR_DECLARATION = "icons/obj16/var_declaration_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_INCLUDE = "icons/obj16/include_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_MACRO = "icons/obj16/define_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_LABEL = "icons/obj16/label_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_TUNIT = "icons/obj16/c_file_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_TUNIT_HEADER = "icons/obj16/h_file_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_TUNIT_ASM = "icons/obj16/s_file_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_TUNIT_RESOURCE = "icons/obj16/c_resource_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_TUNIT_RESOURCE_H = "icons/obj16/ch_resource_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_TUNIT_RESOURCE_A = "icons/obj16/asm_resource_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_SOURCE_ROOT = "icons/obj16/sroot_obj.gif"; // $NON-NLS-1$  //$NON-NLS-1$
+       public static final String IMG_OBJS_SOURCE2_ROOT = "icons/obj16/sroot2_obj.gif"; // $NON-NLS-1$  //$NON-NLS-1$
+       public static final String IMG_OBJS_FOLDER = "icons/obj16/fldr_obj.gif"; // $NON-NLS-1$  //$NON-NLS-1$
+       public static final String IMG_OBJS_CFOLDER = "icons/obj16/cfolder_obj.gif"; // $NON-NLS-1$  //$NON-NLS-1$
+       public static final String IMG_OBJS_CONFIG = "icons/obj16/config.gif"; // $NON-NLS-1$  //$NON-NLS-1$
+       public static final String IMG_OBJS_ARCHIVE = "icons/obj16/ar_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_BINARY = "icons/obj16/bin_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_SHLIB = "icons/obj16/shlib_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_CEXEC = "icons/obj16/exec_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_CEXEC_DEBUG = "icons/obj16/exec_dbg_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_CORE = "icons/obj16/core_obj.gif"; //$NON-NLS-1$
+
+       public static final String IMG_OBJS_CONTAINER = "icons/obj16/container_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_ARCHIVES_CONTAINER = "icons/obj16/archives_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_BINARIES_CONTAINER = "icons/obj16/binaries_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_OUTPUT_FOLDER = "icons/obj16/output_folder_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_LIBRARY = "icons/obj16/lib_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_INCLUDES_CONTAINER = "icons/obj16/includes_container.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_INCLUDES_FOLDER = "icons/obj16/hfolder_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_INCLUDES_FOLDER_PROJECT = "icons/obj16/hfolder_prj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_INCLUDES_FOLDER_WORKSPACE = "icons/obj16/wsp_includefolder.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_QUOTE_INCLUDES_FOLDER = "icons/obj16/hfolder_quote_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_INCLUDES_FOLDER_SYSTEM = "icons/obj16/fldr_sys_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_MACROS_FILE= "icons/obj16/macros_file.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_LIBRARY_FOLDER=  "icons/obj16/fldr_lib_obj.gif"; // $NON-NLS-1$  //$NON-NLS-1$
+       public static final String IMG_OBJS_ORDER = "icons/obj16/cp_order_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_EXCLUSION_FILTER_ATTRIB = "icons/obj16/exclusion_filter_attrib.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_SOURCE_ATTACH_ATTRIB = "icons/obj16/source_attach_attrib.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_IMPORT_SETTINGS = "icons/obj16/import_settings_wiz.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_EXPORT_SETTINGS = "icons/obj16/export_settings_wiz.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_INCCONT = "icons/obj16/incc_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_EXTENSION = "icons/obj16/extension_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_USER = "icons/obj16/person-me.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_CDT_TESTING = "icons/obj16/flask.png"; //$NON-NLS-1$
+
+       public static final String IMG_OBJS_NLS_NEVER_TRANSLATE = "icons/obj16/never_translate.gif"; //$NON-NLS-1$
+
+       // Breakpoint images
+       public static final String IMG_OBJS_BREAKPOINT = "icons/obj16/breakpoint.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_BREAKPOINT_DISABLED = "icons/obj16/breakpoint_disabled.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_BREAKPOINT_ACTIVE = "icons/obj16/breakpoint_active.gif"; //$NON-NLS-1$
+
+       public static final String IMG_OBJS_FIXABLE_PROBLEM = "icons/obj16/quickfix_warning_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_FIXABLE_ERROR = "icons/obj16/quickfix_error_obj.gif"; //$NON-NLS-1$
+
+       // unknown type
+       public static final String IMG_OBJS_UNKNOWN = "icons/obj16/unknown_obj.gif"; //$NON-NLS-1$
+
+       // For the build image
+       public static final String IMG_OBJS_BUILD = "icons/obj16/build_menu.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_FILESYSTEM = "icons/obj16/filesyst.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_WORKSPACE = "icons/obj16/workspace.gif"; //$NON-NLS-1$
+
+       //for search
+       public static final String IMG_OBJS_SEARCH_REF = "icons/obj16/search_ref_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_SEARCH_DECL = "icons/obj16/search_decl_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_SEARCH_LINE = "icons/obj16/searchm_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_CSEARCH = "icons/obj16/csearch_obj.gif"; //$NON-NLS-1$
+
+       public static final String IMG_OBJS_SEARCHFOLDER = "icons/obj16/fldr_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_SEARCHPROJECT = "icons/obj16/cprojects.gif"; //$NON-NLS-1$
+
+       // refactoring
+       public static final String IMG_OBJS_REFACTORING_FATAL = "icons/obj16/fatalerror_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_REFACTORING_ERROR = "icons/obj16/error_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_REFACTORING_WARNING = "icons/obj16/warning_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_REFACTORING_INFO = "icons/obj16/info_obj.gif"; //$NON-NLS-1$
+
+       public static final String IMG_OBJS_PREFERRED = "icons/obj16/tc_preferred.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_EMPTY = "icons/obj16/tc_empty.gif"; //$NON-NLS-1$
+
+       public static final String IMG_OBJS_QUICK_ASSIST = "icons/obj16/quickassist_obj.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_CORRECTION_ADD = "icons/obj16/correction_add.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_CORRECTION_CHANGE = "icons/obj16/correction_change.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_CORRECTION_RENAME = "icons/obj16/correction_rename.gif"; //$NON-NLS-1$
+       public static final String IMG_OBJS_CORRECTION_LINKED_RENAME = "icons/obj16/correction_linked_rename.gif"; //$NON-NLS-1$
+
+       public static final String IMG_VIEW_BUILD_CONSOLE = "icons/view16/buildconsole.gif"; //$NON-NLS-1$
+
+       // Images for file list control
+       public static final String IMG_FILELIST_ADD = "icons/elcl16/list-add.gif"; //$NON-NLS-1$
+       public static final String IMG_FILELIST_DEL = "icons/elcl16/list-delete.gif"; //$NON-NLS-1$
+       public static final String IMG_FILELIST_EDIT = "icons/elcl16/list-edit.gif"; //$NON-NLS-1$
+       public static final String IMG_FILELIST_MOVEUP = "icons/elcl16/list-moveup.gif"; //$NON-NLS-1$
+       public static final String IMG_FILELIST_MOVEDOWN = "icons/elcl16/list-movedown.gif"; //$NON-NLS-1$
+
+       // overlays
+       public static final String IMG_OVR_WARNING = "icons/ovr16/warning_co.gif"; //$NON-NLS-1$
+       public static final String IMG_OVR_ERROR = "icons/ovr16/error_co.gif"; //$NON-NLS-1$
+       public static final String IMG_OVR_SETTING = "icons/ovr16/setting_nav.gif"; //$NON-NLS-1$
+       public static final String IMG_OVR_INACTIVE = "icons/ovr16/inactive_co.gif"; //$NON-NLS-1$
+       
+       // Pin & Clone
+    public static final String IMG_THREAD_SUSPENDED_R_PINNED = "icons/obj16/threads_obj_r.gif"; //$NON-NLS-1$
+    public static final String IMG_THREAD_SUSPENDED_G_PINNED = "icons/obj16/threads_obj_g.gif"; //$NON-NLS-1$
+    public static final String IMG_THREAD_SUSPENDED_B_PINNED = "icons/obj16/threads_obj_b.gif"; //$NON-NLS-1$
+    
+    public static final String IMG_THREAD_RUNNING_R_PINNED = "icons/obj16/thread_obj_r.gif"; //$NON-NLS-1$
+    public static final String IMG_THREAD_RUNNING_G_PINNED = "icons/obj16/thread_obj_g.gif"; //$NON-NLS-1$
+    public static final String IMG_THREAD_RUNNING_B_PINNED = "icons/obj16/thread_obj_b.gif"; //$NON-NLS-1$    
+    
+    public static final String IMG_CONTAINER_SUSPENDED_R_PINNED = "icons/obj16/debugts_obj_r.gif"; //$NON-NLS-1$
+    public static final String IMG_CONTAINER_SUSPENDED_G_PINNED = "icons/obj16/debugts_obj_g.gif"; //$NON-NLS-1$
+    public static final String IMG_CONTAINER_SUSPENDED_B_PINNED = "icons/obj16/debugts_obj_b.gif"; //$NON-NLS-1$
+    
+    public static final String IMG_CONTAINER_RUNNING_R_PINNED = "icons/obj16/debugt_obj_r.gif"; //$NON-NLS-1$    
+    public static final String IMG_CONTAINER_RUNNING_G_PINNED = "icons/obj16/debugt_obj_g.gif"; //$NON-NLS-1$
+    public static final String IMG_CONTAINER_RUNNING_B_PINNED = "icons/obj16/debugt_obj_b.gif"; //$NON-NLS-1$
+
+    public static final String IMG_VIEW_PIN_ACTION = "icons/obj16/toolbar_pinned.gif"; //$NON-NLS-1$
+    public static final String IMG_VIEW_PIN_ACTION_R = "icons/obj16/toolbar_pinned_r.gif"; //$NON-NLS-1$
+    public static final String IMG_VIEW_PIN_ACTION_G = "icons/obj16/toolbar_pinned_g.gif"; //$NON-NLS-1$
+    public static final String IMG_VIEW_PIN_ACTION_B = "icons/obj16/toolbar_pinned_b.gif"; //$NON-NLS-1$
+    public static final String IMG_VIEW_PIN_ACTION_MULTI = "icons/obj16/toolbar_pinned_multi.gif"; //$NON-NLS-1$
+
+       /**
+        * The method finds URL of the image corresponding to the key which could be project-relative path
+        * of the image in org.eclipse.cdt.ui plugin or a (previously registered) string representation of URL
+        * in a bundle.
+        * For project-relative paths a check on existence and variables expansion (such as "$NL$")
+        * is done using {@link FileLocator}.
+        *
+        * @param key - the key which could be project-relative path of the image in org.eclipse.cdt.ui plugin
+        *     or a previously registered string representation of URL in a bundle.
+        * @return the URL or {@code null} if image was not found.
+        */
+       private static URL getUrl(String key) {
+               // Note that the map can keep null URL in order not to search again
+               if (urlMap.containsKey(key))
+                       return urlMap.get(key);
+
+               IPath projectRelativePath = new Path(key);
+               URL url = FileLocator.find(CUIPlugin.getDefault().getBundle(), projectRelativePath, null);
+               if (url==null) {
+                       Exception e = new Exception(NLS.bind(Messages.CDTSharedImages_MissingImage, key, CUIPlugin.PLUGIN_ID));
+                       CUIPlugin.log(e.getMessage(), e);
+               }
+               urlMap.put(key, url);
+               return url;
+       }
+
+       /**
+        * Internal method. It lets register image URL from a bundle directly to the map.
+        * It is user responsibility to ensure that a valid URL is passed.
+        *
+        * @param url - URL of the image pointing to its location in a bundle (bundle entry).
+        *
+        * @noreference This is internal method which is not intended to be referenced by clients.
+        */
+       public static void register(URL url) {
+               urlMap.put(url.toString(), url);
+       }
+
+       /**
+        * The method retrieves an image from the internal repository according to the given key.
+        * The image is managed by image registry and the caller must not dispose it.
+        *
+        * @param key - one of {@code CDTSharedImages.IMG_} constants.
+        * <p>
+        * Reserved for internal usage: the key could be a string representation of URL pointing to location
+        * of the image in the bundle. Such URL key must be registered first with {@code register(URL url)}.
+        * </p>
+        * @return the image from the repository or the default image for missing image descriptor.
+        */
+       public static Image getImage(String key) {
+               URL url = getUrl(key);
+               String registryKey = url!=null ? url.toString() : null;
+               Image image = imageRegistry.get(registryKey);
+               if (image==null) {
+                       ImageDescriptor descriptor= ImageDescriptor.createFromURL(url);
+                       imageRegistry.put(registryKey, descriptor);
+                       image = imageRegistry.get(registryKey);
+               }
+
+               return image;
+       }
+
+       /**
+        * The method retrieves an image descriptor from the internal repository according to the given key.
+        * See also {@link #getImage(String)}.
+        *
+        * @param key - one of {@code CDTSharedImages.IMG_} constants.
+        * @return the image from the repository or {@link ImageDescriptor#getMissingImageDescriptor()}.
+        */
+       public static ImageDescriptor getImageDescriptor(String key) {
+               URL url = getUrl(key);
+               String registryKey = url!=null ? url.toString() : null;
+               ImageDescriptor descriptor = imageRegistry.getDescriptor(registryKey);
+               if (descriptor==null) {
+                       descriptor = ImageDescriptor.createFromURL(url);
+                       imageRegistry.put(registryKey, descriptor);
+               }
+               return descriptor;
+       }
+
+       /**
+        * Retrieves an overlaid image from the internal repository of images.
+        * If there is no image one will be created.
+        *
+       * The decoration overlay for the base image will use the array of
+        * provided overlays. The indices of the array correspond to the values
+        * of the 5 overlay constants defined on {@link IDecoration}, i.e.
+        * {@link IDecoration#TOP_LEFT},
+        * {@link IDecoration#TOP_RIGHT},
+        * {@link IDecoration#BOTTOM_LEFT},
+        * {@link IDecoration#BOTTOM_RIGHT} or
+        * {@link IDecoration#UNDERLAY}.
+        *
+        * @param baseKey the base image key.
+        * @param overlayKeys the keys for the overlay images. Must be
+        *    String[5], i.e. string array of 5 elements. Put {@code null} as
+        *    an element to the array if no overlay should be added in given quadrant.
+        */
+       public static Image getImageOverlaid(String baseKey, String[] overlayKeys) {
+               Assert.isTrue(overlayKeys.length==5);
+
+               String suffix=""; //$NON-NLS-1$
+               for (int i=0;i<5;i++) {
+                       String overlayKey=""; //$NON-NLS-1$
+                       if (i<overlayKeys.length && overlayKeys[i]!=null) {
+                               overlayKey=overlayKeys[i];
+                       }
+                       suffix=suffix+OVERLAY_SEPARATOR+overlayKey;
+               }
+               if (suffix.length()==5) {
+                       // No overlays added
+                       Image result = getImage(baseKey);
+                       return result;
+               }
+               String compositeKey=baseKey+suffix;
+
+               Image result = imageRegistry.get(compositeKey);
+               if (result!=null)
+                       return result;
+
+               Image baseImage = getImage(baseKey);
+               ImageDescriptor[] overlayDescriptors = new ImageDescriptor[5];
+               for (int i=0;i<5;i++) {
+                       String overlayKey = overlayKeys[i];
+                       if (overlayKey!=null) {
+                               overlayDescriptors[i] = getImageDescriptor(overlayKey);
+                       }
+               }
+               ImageDescriptor compositeDescriptor = new DecorationOverlayIcon(baseImage, overlayDescriptors);
+               imageRegistry.put(compositeKey, compositeDescriptor);
+               result = imageRegistry.get(compositeKey);
+               return result;
+       }
+
+       /**
+        * Retrieves an overlaid image descriptor from the repository of images.
+        * If there is no image one will be created.
+        *
+        * @param baseKey - key of the base image. Expected to be in repository.
+        * @param overlayKey - key of overlay image. Expected to be in repository as well.
+        * @param quadrant - location of overlay, one of those:
+        *        {@link IDecoration#TOP_LEFT},
+        *        {@link IDecoration#TOP_RIGHT},
+        *        {@link IDecoration#BOTTOM_LEFT},
+        *        {@link IDecoration#BOTTOM_RIGHT}
+        *
+        * @return image overlaid with smaller image in the specified quadrant.
+        */
+       public static Image getImageOverlaid(String baseKey, String overlayKey, int quadrant) {
+               String[] overlayKeys = new String[5];
+               overlayKeys[quadrant]=overlayKey;
+               return getImageOverlaid(baseKey, overlayKeys);
+       }
+
+       /**
+        * Helper method to return an image with warning overlay.
+        *
+        * @param baseKey - key of the base image. Expected to be in repository.
+        * @return an image with warning overlay.
+        */
+       public static Image getImageWithWarning(String baseKey) {
+               return CDTSharedImages.getImageOverlaid(baseKey, CDTSharedImages.IMG_OVR_WARNING, IDecoration.BOTTOM_LEFT);
+       }
+
+       /**
+        * Helper method to return an image with error overlay.
+        *
+        * @param baseKey - key of the base image. Expected to be in repository.
+        * @return an image with error overlay.
+        */
+       public static Image getImageWithError(String baseKey) {
+               return CDTSharedImages.getImageOverlaid(baseKey, CDTSharedImages.IMG_OVR_ERROR, IDecoration.BOTTOM_LEFT);
+       }
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTUIImages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTUIImages.java
new file mode 100644 (file)
index 0000000..fddc23d
--- /dev/null
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2008 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui;
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+
+
+/**
+ * Images for {@link org.eclipse.cdt.utils.ui.controls.FileListControl}.
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ * 
+ * @deprecated as of CDT 8.0. Use {@link CDTSharedImages}.
+ */
+@Deprecated
+public class CDTUIImages {
+       private static final String ICONS= "icons/"; //$NON-NLS-1$
+       /** Converter from CPluginImages key to CDTSharedImages key */
+       private static Map<String, String> fPathMap = new HashMap<String, String>();
+
+       private static final String NAME_PREFIX= CUIPlugin.PLUGIN_ID + '.';
+       private static final int NAME_PREFIX_LENGTH= NAME_PREFIX.length();
+       public static final String T_LIST= "elcl16/"; //$NON-NLS-1$
+       
+       // Image for file list control
+       public static final String IMG_FILELIST_ADD = NAME_PREFIX + "list-add.gif"; //$NON-NLS-1$
+       public static final ImageDescriptor DESC_FILELIST_ADD = createManaged(T_LIST, IMG_FILELIST_ADD);
+       public static final String IMG_FILELIST_DEL = NAME_PREFIX + "list-delete.gif"; //$NON-NLS-1$
+       public static final ImageDescriptor DESC_FILELIST_DEL = createManaged(T_LIST, IMG_FILELIST_DEL);
+       public static final String IMG_FILELIST_EDIT = NAME_PREFIX + "list-edit.gif"; //$NON-NLS-1$
+       public static final ImageDescriptor DESC_FILELIST_EDIT = createManaged(T_LIST, IMG_FILELIST_EDIT);
+       public static final String IMG_FILELIST_MOVEUP = NAME_PREFIX + "list-moveup.gif"; //$NON-NLS-1$
+       public static final ImageDescriptor DESC_FILELIST_MOVEUP = createManaged(T_LIST, IMG_FILELIST_MOVEUP);
+       public static final String IMG_FILELIST_MOVEDOWN = NAME_PREFIX + "list-movedown.gif"; //$NON-NLS-1$
+       public static final ImageDescriptor DESC_FILELIST_MOVEDOWN = createManaged(T_LIST, IMG_FILELIST_MOVEDOWN);
+       
+       /**
+        * Creates an image descriptor which is managed by internal registry in CDTSharedImages.
+        * {@code name} is assumed to start with "org.eclipse.cdt.ui."
+        */
+       private static ImageDescriptor createManaged(String prefix, String name) {
+               try {
+                       String convertedKey = ICONS + prefix + name.substring(NAME_PREFIX_LENGTH);
+                       fPathMap.put(name, convertedKey);
+                       return CDTSharedImages.getImageDescriptor(convertedKey);
+               } catch (Throwable e) {
+                       CUIPlugin.log(e);
+               }
+               return ImageDescriptor.getMissingImageDescriptor();
+       }
+       
+       /**
+        * Get an image from internal image registry. The image is managed by the registry and
+        * must not be disposed by the caller.
+        * 
+        * @param key - one of {@code CDTUIImages.IMG_} constants.
+        * @return the image corresponding the given key.
+        * 
+        * @deprecated as of CDT 8.0. Use {@link CDTSharedImages#getImage(String)}.
+        */
+       @Deprecated
+       public static Image get(String key) {
+               String pathKey = fPathMap.get(key);
+               return CDTSharedImages.getImage(pathKey);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTUITools.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CDTUITools.java
new file mode 100644 (file)
index 0000000..2b8ffa2
--- /dev/null
@@ -0,0 +1,210 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui;
+
+import java.net.URI;
+
+import org.eclipse.core.filebuffers.LocationKind;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentExtension3;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.jface.text.rules.FastPartitioner;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.text.ICPartitions;
+import org.eclipse.cdt.ui.text.IColorManager;
+import org.eclipse.cdt.internal.ui.editor.ITranslationUnitEditorInput;
+import org.eclipse.cdt.internal.ui.text.asm.AsmPartitionScanner;
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+
+/**
+ * This class provides utilities for clients of the CDT UI plug-in.
+ * This class provides static methods for:
+ * <ul>
+ *  <li>opening an editor on a C model element.</li>
+ *  <li>accessing working copy manager and document provider used with C model elements.</li>
+ *  <li>accessing color manager used for syntax coloring of C/C++ files.</li>
+ * </ul>
+ *
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ * @since 5.1
+ */
+public final class CDTUITools {
+
+       private CDTUITools() {
+               // prevent instantiation
+       }
+       
+       /**
+        * Returns the color manager which is used to manage
+        * colors needed for syntax highlighting.
+        *
+        * @return the color manager to be used for C/C++ text viewers
+        */
+       public static IColorManager getColorManager() {
+               return CUIPlugin.getDefault().getTextTools().getColorManager();
+       }
+
+       /**
+        * Opens an editor on the given C model element in the active page. Valid are elements that are {@link ISourceReference}.
+        *
+        * @param element the input element
+        * @return returns the editor part of the opened editor or <code>null</code> if the element is not a {@link ISourceReference} or the
+        * file was opened in an external editor.
+        * @exception PartInitException if the editor could not be initialized or no workbench page is active
+        * @exception CModelException if this element does not exist or if an exception occurs while accessing its underlying resource
+        */
+       public static IEditorPart openInEditor(ICElement element) throws CModelException, PartInitException {
+               return openInEditor(element, true, true);
+       }
+
+       /**
+        * Opens an editor on the given C model element in the active page. Valid are elements that are {@link ISourceReference}.
+        *
+        * @param element the input element
+        * @return returns the editor part of the opened editor or <code>null</code> if the element is not a {@link ISourceReference} or the
+        * file was opened in an external editor.
+        * @exception PartInitException if the editor could not be initialized or no workbench page is active
+        * @exception CModelException if this element does not exist or if an exception occurs while accessing its underlying resource
+        */
+       public static IEditorPart openInEditor(ICElement element, boolean activate, boolean reveal) throws CModelException, PartInitException {
+               if (!(element instanceof ISourceReference)) {
+                       return null;
+               }
+               IEditorPart part= EditorUtility.openInEditor(element, activate);
+               if (reveal && part != null) {
+                       EditorUtility.revealInEditor(part, element);
+               }
+               return part;
+       }
+
+       /**
+        * Reveals the given C model element  in the given editor.. 
+        *
+        * @param part the editor displaying a translation unit
+        * @param element the element to be revealed
+        */
+       public static void revealInEditor(IEditorPart part, ICElement element) {
+               EditorUtility.revealInEditor(part, element);
+       }
+
+       /**
+        * Returns the working copy manager for the CDT UI plug-in.
+        *
+        * @return the working copy manager for the CDT UI plug-in
+        */
+       public static IWorkingCopyManager getWorkingCopyManager() {
+               return CUIPlugin.getDefault().getWorkingCopyManager();
+       }
+
+       /**
+        * Returns the document provider used for C/C++ files.
+        *
+        * @return the document provider for C/C++ files.
+        *
+        * @see IDocumentProvider
+        */
+       public static IDocumentProvider getDocumentProvider() {
+               return CUIPlugin.getDefault().getDocumentProvider();
+       }
+
+       /**
+        * Returns the <code>ICElement</code> element wrapped by the given editor input.
+        *
+        * @param editorInput the editor input
+        * @return the ICElement wrapped by <code>editorInput</code> or <code>null</code> if none
+        */
+       public static ICElement getEditorInputCElement(IEditorInput editorInput) {
+               if (editorInput instanceof ITranslationUnitEditorInput) {
+                       return ((ITranslationUnitEditorInput) editorInput).getTranslationUnit();
+               }
+               IWorkingCopy tu= CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput);
+               if (tu != null)
+                       return tu;
+
+               return (ICElement)editorInput.getAdapter(ICElement.class);
+       }
+
+       /**
+        * Utility method to get an editor input for the given file system location.
+        * If the location denotes a workspace file, a <code>FileEditorInput</code>
+        * is returned, otherwise, the input is an <code>IURIEditorInput</code>
+        * assuming the location points to an existing file in an Eclipse file system.
+        * The <code>ICElement</code> is used to determine the associated project
+        * in case the location can not be resolved to a workspace <code>IFile</code>.
+        *
+        * @param locationURI  a valid Eclipse file system URI
+        * @param context  an element related to the target file, may be <code>null</code>
+        * @return an editor input
+        */
+       public static IEditorInput getEditorInputForLocation(URI locationURI, ICElement context) {
+               return EditorUtility.getEditorInputForLocation(locationURI, context);
+       }
+
+       /**
+        * Utility method to get an editor input for the given file system location.
+        * If the location denotes a workspace file, a <code>FileEditorInput</code>
+        * is returned, otherwise, the input is an <code>IURIEditorInput</code>
+        * assuming the location points to an existing file in the file system.
+        * The <code>ICElement</code> is used to determine the associated project
+        * in case the location can not be resolved to a workspace <code>IFile</code>.
+        *
+        * @param location  a valid file system location
+        * @param context  an element related to the target file, may be <code>null</code>
+        * @return an editor input
+        */
+       public static IEditorInput getEditorInputForLocation(IPath location, ICElement context) {
+               return EditorUtility.getEditorInputForLocation(location, context);
+       }
+
+       /**
+        * Sets up the given document for the default C/C++ partitioning.
+        * 
+        * @param document the document to be set up
+        * @param location the path of the resource backing the document. May be null.
+        * @param locationKind the type of path specified above. May be null.
+        */
+       public static void setupCDocument(IDocument document, IPath location, LocationKind locationKind) {
+               CUIPlugin.getDefault().getTextTools().setupCDocument(document, location, locationKind);
+       }
+
+       /**
+        * Create a document partitioner suitable for Assembly source.
+        */
+       public static IDocumentPartitioner createAsmDocumentPartitioner() {
+               return new FastPartitioner(new AsmPartitionScanner(), ICPartitions.ALL_ASM_PARTITIONS);
+       }
+
+       /**
+        * Sets up the given document for the default Assembly partitioning.
+        * 
+        * @param document the document to be set up
+        */
+       public static void setupAsmDocument(IDocument document) {
+               IDocumentPartitioner partitioner= createAsmDocumentPartitioner();
+               if (document instanceof IDocumentExtension3) {
+                       IDocumentExtension3 extension3= (IDocumentExtension3) document;
+                       extension3.setDocumentPartitioner(ICPartitions.C_PARTITIONING, partitioner);
+               } else {
+                       document.setDocumentPartitioner(partitioner);
+               }
+               partitioner.connect(document);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementContentProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementContentProvider.java
new file mode 100644 (file)
index 0000000..6ea8e6a
--- /dev/null
@@ -0,0 +1,494 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.ui;
+
+
+
+import java.util.HashSet;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.information.IInformationProvider;
+import org.eclipse.jface.text.information.IInformationProviderExtension;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ElementChangedEvent;
+import org.eclipse.cdt.core.model.IArchive;
+import org.eclipse.cdt.core.model.IBinary;
+import org.eclipse.cdt.core.model.ICContainer;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICElementDelta;
+import org.eclipse.cdt.core.model.ICModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IElementChangedListener;
+import org.eclipse.cdt.core.model.IParent;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+
+import org.eclipse.cdt.internal.core.model.ArchiveContainer;
+import org.eclipse.cdt.internal.core.model.BinaryContainer;
+
+import org.eclipse.cdt.internal.ui.BaseCElementContentProvider;
+import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
+import org.eclipse.cdt.internal.ui.text.CWordFinder;
+
+/**
+ * A content provider for C elements.
+ * <p>
+ * The following C element hierarchy is surfaced by this content provider:
+ * <p>
+ * <pre>
+C model (<code>ICModel</code>)<br>
+   C project (<code>ICProject</code>)<br>
+      Virtual binaries  container(<code>IBinaryContainery</code>)
+      Virtual archives  container(<code>IArchiveContainery</code>)
+      Source root (<code>ISourceRoot</code>)<br>
+          C Container(folders) (<code>ICContainer</code>)<br>
+          Translation unit (<code>ITranslationUnit</code>)<br>
+          Binary file (<code>IBinary</code>)<br>
+          Archive file (<code>IArchive</code>)<br>
+      Non C Resource file (<code>Object</code>)<br>
+
+ * </pre>
+ */
+public class CElementContentProvider extends BaseCElementContentProvider implements IElementChangedListener, IInformationProvider, IInformationProviderExtension{
+
+       /** Editor. */
+    protected ITextEditor fEditor;
+    protected StructuredViewer fViewer;
+       protected Object fInput;
+       
+       /** Remember what refreshes we already have pending so we don't post them again. */
+       protected HashSet<IRefreshable> pendingRefreshes = new HashSet<IRefreshable>();
+
+    /**
+     * Creates a new content provider for C elements.
+     */
+    public CElementContentProvider()
+    {
+        // Empty.
+    }
+    
+       /**
+        * Creates a new content provider for C elements.
+     * @param editor Editor.
+        */
+       public CElementContentProvider(ITextEditor editor)
+    {
+        fEditor = editor;
+       }
+    
+       /**
+        * Creates a new content provider for C elements.
+        */
+       public CElementContentProvider(boolean provideMembers, boolean provideWorkingCopy) {
+               super(provideMembers, provideWorkingCopy);
+       }
+
+    /**
+     * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+     */
+    @Override
+       public void dispose() {
+        super.dispose();
+        CoreModel.getDefault().removeElementChangedListener(this);
+    }
+
+    /**
+     * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+     */
+    @Override
+       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+
+        super.inputChanged(viewer, oldInput, newInput);
+
+        fViewer = (StructuredViewer) viewer;
+
+        if (oldInput == null && newInput != null) {
+            CoreModel.getDefault().addElementChangedListener(this);
+        } else if (oldInput != null && newInput == null) {
+            CoreModel.getDefault().removeElementChangedListener(this);
+        }
+        fInput= newInput;
+    }
+
+       /**
+     * @see org.eclipse.cdt.core.model.IElementChangedListener#elementChanged(org.eclipse.cdt.core.model.ElementChangedEvent)
+        */
+    public void elementChanged(final ElementChangedEvent event) {
+               try {
+                       processDelta(event.getDelta());
+               } catch(CModelException e) {
+                       CUIPlugin.log(e);
+                       e.printStackTrace();
+               }
+       }
+
+       protected boolean isPathEntryChange(ICElementDelta delta) {
+               int flags= delta.getFlags();
+               return (delta.getKind() == ICElementDelta.CHANGED &&
+                               ((flags & ICElementDelta.F_BINARY_PARSER_CHANGED) != 0 ||
+                               (flags & ICElementDelta.F_ADDED_PATHENTRY_LIBRARY) != 0 ||
+                               (flags & ICElementDelta.F_ADDED_PATHENTRY_SOURCE) != 0 ||
+                               (flags & ICElementDelta.F_REMOVED_PATHENTRY_LIBRARY) != 0 ||
+                               (flags & ICElementDelta.F_PATHENTRY_REORDER) != 0 ||
+                               (flags & ICElementDelta.F_REMOVED_PATHENTRY_SOURCE) != 0 ||
+                               (flags & ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE) != 0));
+       }
+
+       /**
+        * Processes a delta recursively. When more than two children are affected the
+        * tree is fully refreshed starting at this node. The delta is processed in the
+        * current thread but the viewer updates are posted to the UI thread.
+        */
+       protected void processDelta(ICElementDelta delta) throws CModelException {
+               int kind= delta.getKind();
+               int flags= delta.getFlags();
+               ICElement element= delta.getElement();
+
+               //System.out.println("Processing " + element);
+
+               // handle open and closing of a project
+               if (((flags & ICElementDelta.F_CLOSED) != 0) || ((flags & ICElementDelta.F_OPENED) != 0)) {
+                       postRefresh(element);
+                       return;
+               }
+
+               // We do not care about changes in Working copies
+               // well, we do see bug 147694
+               if (element instanceof ITranslationUnit) {
+                       ITranslationUnit unit = (ITranslationUnit) element;
+                       if (unit.isWorkingCopy()) {
+                               if (!getProvideWorkingCopy() || kind == ICElementDelta.REMOVED || kind == ICElementDelta.ADDED) {
+                                       return;
+                               }
+                       }
+                       if (!getProvideMembers() && kind == ICElementDelta.CHANGED) {
+                               return;
+                       }
+               }
+
+               if (kind == ICElementDelta.REMOVED) {
+                       postRemove(element);
+                       updateContainer(element);
+                       return;
+               }
+
+               if (kind == ICElementDelta.ADDED) {
+                       Object parent= internalGetParent(element);
+                       postAdd(parent, element);
+                       updateContainer(element);
+               }
+
+               if (isPathEntryChange(delta)) {
+                       postRefresh(element.getCProject());
+                       return;
+               }
+
+               if (kind == ICElementDelta.CHANGED) {
+                       // Binary/Archive changes is done differently since they
+                       // are at two places, they are in the {Binary,Archive}Container
+                       // and in the Tree hierarchy
+                       if (updateContainer(element)) {
+                               Object parent = getParent(element);
+                               postRefresh(parent);
+                               return;
+                       } else if (element instanceof ITranslationUnit) {
+                               postRefresh(element);
+                               return;
+                       } else if (element instanceof ICContainer) {
+                               // if element itself has changed, not its children
+                               if ((flags&~(ICElementDelta.F_CHILDREN|ICElementDelta.F_FINE_GRAINED))!=0) {
+                                       postRefresh(element);
+                               }
+                       } else if (element instanceof ArchiveContainer || element instanceof BinaryContainer) {
+                               postContainerRefresh((IParent) element, element.getCProject());
+                       }
+
+               }
+
+               if (processResourceDeltas(delta.getResourceDeltas(), element))
+                       return;
+       
+               ICElementDelta[] affectedChildren= delta.getAffectedChildren();
+               for (ICElementDelta element2 : affectedChildren) {
+                       processDelta(element2);
+               }
+       }
+
+       /**
+        * Process resource deltas.
+        *
+        * @return true if the parent got refreshed
+        */
+       private boolean processResourceDeltas(IResourceDelta[] deltas, Object parent) {
+               if (deltas == null)
+                       return false;
+               
+               if (deltas.length > 1 && !(parent instanceof ICModel)) {
+                       // more than one child changed, refresh from here downwards
+                       // but not if the parent is ICModel
+                       // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=202085
+                       postRefresh(parent);
+                       return true;
+               }
+
+               for (IResourceDelta delta : deltas) {
+                       if (processResourceDelta(delta, parent))
+                               return true;
+               }
+
+               return false;
+       }
+
+       /**
+        * Process a resource delta.
+        * 
+        * @return true if the parent got refreshed
+        */
+       private boolean processResourceDelta(IResourceDelta delta, Object parent) {
+               int status= delta.getKind();
+               IResource resource= delta.getResource();
+               // filter out changes affecting the output folder
+               if (resource == null) {
+                       return false;
+               }
+                        
+               // this could be optimized by handling all the added children in the parent
+               if ((status & IResourceDelta.REMOVED) != 0) {
+                       postRemove(resource);
+               }
+               if ((status & IResourceDelta.ADDED) != 0) {
+                       postAdd(parent, resource);
+               }
+
+               int flags= delta.getFlags();
+               // open/close state change of a project
+               if ((flags & IResourceDelta.OPEN) != 0) {
+                       postProjectStateChanged(parent);
+                       return true;
+               }
+
+               processResourceDeltas(delta.getAffectedChildren(), resource);
+               return false;
+       }
+
+       private boolean updateContainer(ICElement cfile) throws CModelException {
+               IParent container = null;
+               ICProject cproject = null;
+               if (cfile instanceof IBinary) {
+                       IBinary bin = (IBinary)cfile;
+                       if (bin.showInBinaryContainer()) {
+                               cproject = bin.getCProject();
+                               container = cproject.getBinaryContainer();
+                       }
+               } else if (cfile instanceof IArchive) {
+                       cproject = cfile.getCProject();
+                       container = cproject.getArchiveContainer();
+               }
+               if (container != null) {
+                       postContainerRefresh(container, cproject);
+                       return true;
+               }
+               return false;
+       }
+       
+       // Tree refresh system
+       // We keep track of what we're going to refresh and avoid posting multiple refresh
+       // messages for the same elements. This avoids major performance issues where
+       // we update tree views hundreds or thousands of times.
+       protected interface IRefreshable {
+           public void refresh();
+       }
+       protected final class RefreshContainer implements IRefreshable {
+               private IParent container;
+               private Object project;
+               public RefreshContainer(IParent container, Object project) {
+                       this.container = container;
+                       this.project = project;
+               }
+           public void refresh() {
+                       if (container.hasChildren()) {
+                               if (fViewer.testFindItem(container) != null) {
+                                       fViewer.refresh(container);
+                               } else {
+                                       fViewer.refresh(project);
+                               }
+                       } else {
+                               fViewer.refresh(project);
+                       }
+           }
+           @Override
+               public boolean equals(Object o) {
+               if (o instanceof RefreshContainer) {
+                       RefreshContainer c = (RefreshContainer)o;
+                       return c.container.equals(container) && c.project.equals(project);
+               }
+               return false;
+           }
+           @Override
+               public int hashCode() {
+               return container.hashCode()*10903143 + 31181;
+           }
+       }
+       protected final class RefreshElement implements IRefreshable {
+               private Object element;
+               public RefreshElement(Object element) {
+                       this.element = element;
+               }
+               public void refresh() {
+                       if (element instanceof IWorkingCopy){
+                               if (fViewer.testFindItem(element) != null){
+                                       fViewer.refresh(element);
+                               } else {
+                                       fViewer.refresh(((IWorkingCopy)element).getOriginalElement());
+                               }
+                       } else if (element instanceof IBinary) {
+                               fViewer.refresh(element, true);
+                       } else {
+                               fViewer.refresh(element);
+                       }
+               }
+           @Override
+               public boolean equals(Object o) {
+               if (o instanceof RefreshElement) {
+                       RefreshElement c = (RefreshElement)o;
+                       return c.element.equals(element);
+               }
+               return false;
+           }
+           @Override
+               public int hashCode() {
+               return element.hashCode()*7 + 490487;
+           }
+       }
+
+       protected final class RefreshProjectState implements IRefreshable {
+               private Object element;
+               public RefreshProjectState(Object element) {
+                       this.element = element;
+               }
+               public void refresh() {
+                       fViewer.refresh(element, true);
+                       // trigger a syntetic selection change so that action refresh their
+                       // enable state.
+                       fViewer.setSelection(fViewer.getSelection());
+               }
+           @Override
+               public boolean equals(Object o) {
+               if (o instanceof RefreshElement) {
+                       RefreshElement c = (RefreshElement)o;
+                       return c.element.equals(element);
+               }
+               return false;
+           }
+           @Override
+               public int hashCode() {
+               return element.hashCode()*11 + 490487;
+           }
+       }
+
+       protected void postContainerRefresh(final IParent container, final ICProject cproject) {
+               //System.out.println("UI Container:" + cproject + " " + container);
+               postRefreshable(new RefreshContainer(container, cproject));
+       }
+
+       protected void postRefresh(final Object element) {
+               //System.out.println("UI refresh:" + element);
+               postRefreshable(new RefreshElement(element));
+       }
+
+       protected void postAdd(final Object parent, final Object element) {
+               //System.out.println("UI add:" + parent + " " + element);
+               postRefreshable(new RefreshElement(parent));
+       }
+
+       protected void postRemove(final Object element) {
+               //System.out.println("UI remove:" + element);
+               postRefreshable(new RefreshElement(internalGetParent(element)));
+       }
+
+       protected void postProjectStateChanged(final Object root) {
+               postRefreshable(new RefreshProjectState(root));
+       }
+
+       protected final void postRefreshable(final IRefreshable r) {
+               Control ctrl= fViewer.getControl();
+               if (ctrl != null && !ctrl.isDisposed()) {
+                       if (pendingRefreshes.contains(r))
+                               return;
+                       pendingRefreshes.add(r);
+                       ctrl.getDisplay().asyncExec(new Runnable() {
+                               public void run() {
+                                       pendingRefreshes.remove(r);
+                                       Control ctrl= fViewer.getControl();
+                                       if (ctrl != null && !ctrl.isDisposed()) {
+                                               r.refresh();
+                                       }
+                               }
+                       });
+               }
+       }
+
+    /*
+     * @see org.eclipse.jface.text.information.IInformationProvider#getSubject(org.eclipse.jface.text.ITextViewer, int)
+     */
+    public IRegion getSubject(ITextViewer textViewer, int offset) {
+               if (textViewer != null && fEditor != null) {
+                       IRegion region = CWordFinder.findWord(textViewer.getDocument(),
+                                       offset);
+                       if (region != null) {
+                               return region;
+                       }
+                       return new Region(offset, 0);
+               }
+               return null;
+       }
+
+    /*
+        * @see org.eclipse.jface.text.information.IInformationProvider#getInformation(org.eclipse.jface.text.ITextViewer,
+        *      org.eclipse.jface.text.IRegion)
+        */
+    public String getInformation(ITextViewer textViewer, IRegion subject) {
+       // deprecated API - not used anymore
+        Object info = getInformation2(textViewer, subject);
+        if (info != null) {
+               return info.toString();
+        }
+        return null;
+    }
+
+    /*
+     * @see org.eclipse.jface.text.information.IInformationProviderExtension#getInformation2(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
+     */
+    public Object getInformation2(ITextViewer textViewer, IRegion subject) {
+               if (fEditor == null)
+                       return null;
+               try {
+                       ICElement element = SelectionConverter.getElementAtOffset(fEditor);
+                       if (element != null) {
+                               return element;
+                       }
+                       return SelectionConverter.getInput(fEditor);
+               } catch (CModelException e) {
+                       return null;
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementGrouping.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementGrouping.java
new file mode 100644 (file)
index 0000000..133f7ad
--- /dev/null
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     IBM Corporation
+ *******************************************************************************/
+package org.eclipse.cdt.ui;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.eclipse.ui.model.WorkbenchAdapter;
+
+/**
+ */
+public abstract class CElementGrouping extends WorkbenchAdapter implements IAdaptable {
+
+       public final static int INCLUDES_GROUPING = 0x00001;
+       
+       /**
+        * @since 5.2
+        */
+       public final static int MACROS_GROUPING = 0x00011;
+       
+       public final static int NAMESPACE_GROUPING = 0x00010;
+       public final static int CLASS_GROUPING = 0x00100;
+       public final static int LIBRARY_REF_CONTAINER = 0x01000;
+       public final static int INCLUDE_REF_CONTAINER = 0x10000;
+       
+       int type;
+       
+       public CElementGrouping(int type) {
+               this.type = type;
+       }
+
+       public int getType() {
+               return type;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
+        */
+       @Override
+       public String getLabel(Object object) {
+               switch (type) {
+                       case INCLUDES_GROUPING:
+                               return Messages.CElementGrouping_includeGroupingLabel; 
+                       case MACROS_GROUPING:
+                               return Messages.CElementGrouping_macroGroupingLabel;
+               }
+               return super.getLabel(object);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
+        */
+       @Override
+       public ImageDescriptor getImageDescriptor(Object object) {
+               switch (type) {
+                       case INCLUDES_GROUPING:
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_INCCONT);
+                       case NAMESPACE_GROUPING:
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_NAMESPACE);
+                       case CLASS_GROUPING:
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CLASS);
+                       case MACROS_GROUPING:
+                               return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_MACRO);
+               }
+               return super.getImageDescriptor(object);
+       }
+
+       /*
+        * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
+        */
+       @SuppressWarnings("rawtypes")
+       public Object getAdapter(Class clas) {
+               if (clas == IWorkbenchAdapter.class)
+                       return this;
+               return null;
+       }
+
+       /*
+        * @see java.lang.Object#toString()
+        */
+       @Override
+       public String toString() {
+               return getLabel(null);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementImageDescriptor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementImageDescriptor.java
new file mode 100644 (file)
index 0000000..2b94f32
--- /dev/null
@@ -0,0 +1,338 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Markus Schorn (Wind River Systems)
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.ui;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.resource.CompositeImageDescriptor;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.Point;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+
+
+/**
+ * A CImageDescriptor consists of a base image and several adornments. The adornments
+ * are computed according to the flags either passed during creation or set via the method
+ * <code>setAdornments</code>. 
+ * </p>
+ * It is guaranteed that objects that conform to this interface are also instances of type
+ * <code>ImageDescriptor</code>
+ * </p>
+ * <b>Note:</b> This class/interface is part of an interim API that is still under development 
+ * and expected to change before reaching stability.
+ * </p>
+ * 
+ * @since 2.0 
+ */
+public class CElementImageDescriptor extends CompositeImageDescriptor {
+       
+       /** Flag to render the abstract adornment */
+       public final static int TEMPLATE=               0x001;
+       
+       /** Flag to render the const adornment */
+       public final static int CONSTANT=               0x002;
+       
+       /** Flag to render the volatile adornment */
+       public final static int VOLATILE=               0x004;
+       
+       /** Flag to render the static adornment */
+       public final static int STATIC=                 0x008;
+       
+       /**  
+        * @deprecated flag never had an effect
+        */
+       @Deprecated
+       public final static int RUNNABLE=               0x010;
+       
+       /** Flag to render the warning adornment */
+       public final static int WARNING=                0x020;
+       
+       /** Flag to render the error adornment */
+       public final static int ERROR=                  0x040;
+       
+       /**  
+        * @deprecated flag never had an effect 
+        */
+       @Deprecated
+       public final static int OVERRIDES=              0x080;
+       
+       /**  
+        * @deprecated flag never had an effect 
+        */
+       @Deprecated
+       public final static int IMPLEMENTS=     0x100;          
+
+    /** Flag to render the 'relates to' adornment (for trees, an arrow down) */
+    public final static int RELATES_TO=     0x200;      
+
+    /** Flag to render the 'relates to' adornment (for trees, two arrows down) */
+    public final static int RELATES_TO_MULTIPLE= 0x400;      
+
+    /** Flag to render the 'referenced by' adornment (for trees, an arrow up) */
+    public final static int REFERENCED_BY=  0x800;      
+
+    /** Flag to render the 'recursive relation' adornment (for trees, an arrow pointing back) */
+    public final static int RECURSIVE_RELATION= 0x1000;
+    
+    /** Flag to render the 'system include' adornment */
+    public final static int SYSTEM_INCLUDE= 0x2000;      
+
+    /** Flag to render the 'defines' adornment in the type hierarchy*/
+    public final static int DEFINES= 0x4000;      
+
+    /** Flag to render the 'inactive' adornment for include directives */
+    public final static int INACTIVE= 0x8000;      
+
+    /** Flag to render the 'read access' adornment for references to variables or fields */
+       public static final int READ_ACCESS = 0x10000;      
+
+    /** Flag to render the 'read access' adornment for references to variables or fields */
+       public static final int WRITE_ACCESS = 0x20000;      
+
+    /** Flag to render the 'external file' adornment for translation units */
+       public static final int EXTERNAL_FILE = 0x40000;
+
+    /** Flag to render the 'custom settings' adornment 
+     * @since 5.2 */
+    public final static int SETTINGS= 0x80000;
+
+       private ImageDescriptor fBaseImage;
+       private int fFlags;
+       private Point fSize;
+
+       /**
+        * Create a new CElementImageDescriptor.
+        * 
+        * @param baseImage an image descriptor used as the base image
+        * @param flags flags indicating which adornments are to be rendered. See <code>setAdornments</code>
+        *      for valid values.
+        * @param size the size of the resulting image
+        * @see #setAdornments(int)
+        */
+       public CElementImageDescriptor(ImageDescriptor baseImage, int flags, Point size) {
+               fBaseImage= baseImage;
+               Assert.isNotNull(fBaseImage);
+               fFlags= flags;
+               Assert.isTrue(fFlags >= 0);
+               fSize= size;
+               Assert.isNotNull(fSize);
+       }
+       
+       /**
+        * Sets the descriptors adornments. Valid values are: <code>ABSTRACT</code>, <code>FINAL</code>,
+        * </code>STATIC<code>, </code>WARNING<code>, 
+        * </code>ERROR<code>, or any combination of those.
+        * 
+        * @param adornments the image descritpors adornments
+        */
+       public void setAdornments(int adornments) {
+               Assert.isTrue(adornments >= 0);
+               fFlags= adornments;
+       }
+
+       /**
+        * Returns the current adornments.
+        * 
+        * @return the current adornments
+        */
+       public int getAdronments() {
+               return fFlags;
+       }
+
+       /**
+        * Sets the size of the image created by calling <code>createImage()</code>.
+        * 
+        * @param size the size of the image returned from calling <code>createImage()</code>
+        */
+       public void setImageSize(Point size) {
+               Assert.isNotNull(size);
+               Assert.isTrue(size.x >= 0 && size.y >= 0);
+               fSize= size;
+       }
+       
+       /**
+        * Returns the size of the image created by calling <code>createImage()</code>.
+        * 
+        * @return the size of the image created by calling <code>createImage</code>
+        */
+       public Point getImageSize() {
+               return new Point(fSize.x, fSize.y);
+       }
+       
+       /* (non-Javadoc)
+        * Method declared in CompositeImageDescriptor
+        */
+       @Override
+       protected Point getSize() {
+               return fSize;
+       }
+       
+       /* (non-Javadoc)
+        * Method declared on Object.
+        */
+       @Override
+       public boolean equals(Object object) {
+               if (!CElementImageDescriptor.class.equals(object.getClass()))
+                       return false;
+                       
+               CElementImageDescriptor other= (CElementImageDescriptor)object;
+               return (fBaseImage.equals(other.fBaseImage) && fFlags == other.fFlags && fSize.equals(other.fSize));
+       }
+       
+       /* (non-Javadoc)
+        * Method declared on Object.
+        */
+       @Override
+       public int hashCode() {
+               return fBaseImage.hashCode() | fFlags | fSize.hashCode();
+       }
+       
+       /* (non-Javadoc)
+        * Method declared in CompositeImageDescriptor
+        */
+       @Override
+       protected void drawCompositeImage(int width, int height) {
+               ImageData bg;
+               if ((bg= fBaseImage.getImageData()) == null)
+                       bg= DEFAULT_IMAGE_DATA;
+                       
+               drawImage(bg, 0, 0);
+               drawTopRight();
+               drawBottomRight();
+               drawBottomLeft();
+               drawTopLeft();
+       }       
+       
+       private void drawTopRight() {           
+               int x= getSize().x;
+               ImageData data= null;
+               if ((fFlags & VOLATILE) != 0) {
+                       data= CPluginImages.DESC_OVR_VOLATILE.getImageData();
+                       x-= data.width;
+                       drawImage(data, x, 0);
+               }
+               if ((fFlags & CONSTANT) != 0) {
+                       data= CPluginImages.DESC_OVR_CONSTANT.getImageData();
+                       x-= data.width;
+                       drawImage(data, x, 0);
+               }
+               if ((fFlags & STATIC) != 0) {
+                       data= CPluginImages.DESC_OVR_STATIC.getImageData();
+                       x-= data.width;
+                       drawImage(data, x, 0);
+               } 
+               if ((fFlags & TEMPLATE) != 0) {
+                       data= CPluginImages.DESC_OVR_TEMPLATE.getImageData();
+                       x-= data.width;
+                       drawImage(data, x, 0);
+               }
+               if ((fFlags & SYSTEM_INCLUDE) != 0) {
+                       data = CPluginImages.DESC_OVR_SYSTEM_INCLUDE.getImageData();
+                       x -= data.width;
+                       drawImage(data, x, 0);
+               }
+               if ((fFlags & SETTINGS) != 0) {
+                       data = CPluginImages.DESC_OVR_SETTING.getImageData();
+                       x -= data.width;
+                       drawImage(data, x, 0);
+               }
+       }               
+       
+       private void drawBottomRight() {
+               Point size= getSize();
+               int x= size.x;
+               ImageData data= null;
+        if ((fFlags & RECURSIVE_RELATION) != 0) {
+            data= CPluginImages.DESC_OVR_REC_RELATESTO.getImageData();
+            x-= data.width;
+            drawImage(data, x, size.y-data.height);
+        }
+        else if ((fFlags & RELATES_TO) != 0) {
+            data= CPluginImages.DESC_OVR_RELATESTO.getImageData();
+            x-= data.width;
+            drawImage(data, x, size.y-data.height);
+        }
+        else if ((fFlags & RELATES_TO_MULTIPLE) != 0) {
+               data= CPluginImages.DESC_OVR_RELATESTOMULTIPLE.getImageData();
+               x-= data.width;
+               drawImage(data, x, size.y-data.height);
+        }
+        else if ((fFlags & REFERENCED_BY) != 0) {
+            data= CPluginImages.DESC_OVR_REFERENCEDBY.getImageData();
+            x-= data.width;
+            drawImage(data, x, size.y-data.height);
+        }
+//             if ((fFlags & OVERRIDES) != 0) {
+//                     data= CPluginImages.DESC_OVR_OVERRIDES.getImageData();
+//                     x-= data.width;
+//                     drawImage(data, x, size.y - data.height);
+//             }
+//             if ((fFlags & IMPLEMENTS) != 0) {
+//                     data= CPluginImages.DESC_OVR_IMPLEMENTS.getImageData();
+//                     x-= data.width;
+//                     drawImage(data, x, size.y - data.height);
+//             }               
+       }               
+       
+       private void drawTopLeft() {
+               ImageData data= null;
+               if ((fFlags & DEFINES) != 0) {
+                       data= CPluginImages.DESC_OVR_DEFINES.getImageData();
+                       drawImage(data, 0, 0);
+               }
+               if ((fFlags & INACTIVE) != 0) {
+                       data= CPluginImages.DESC_OVR_INACTIVE.getImageData();
+                       drawImage(data, 0, 0);
+               } 
+               
+               final boolean isReadAccess= (fFlags & READ_ACCESS) != 0;
+               final boolean isWriteAccess= (fFlags & WRITE_ACCESS) != 0;
+               if (isReadAccess) {
+                       if (isWriteAccess) {
+                               data= CPluginImages.DESC_OVR_READ_WRITE_ACCESS.getImageData();
+                       }
+                       else {
+                               data= CPluginImages.DESC_OVR_READ_ACCESS.getImageData();
+                       }
+                       drawImage(data, 0, 0);
+               }
+               else if (isWriteAccess) {
+                       data= CPluginImages.DESC_OVR_WRITE_ACCESS.getImageData();
+                       drawImage(data, 0, 0);
+               }
+               
+               if ((fFlags & EXTERNAL_FILE) != 0) {
+                       data= CPluginImages.DESC_OVR_EXTERNAL_FILE.getImageData();
+                       drawImage(data, 0, 0);
+               }
+       }
+
+       private void drawBottomLeft() {
+               Point size= getSize();
+               int x= 0;
+               ImageData data= null;
+               if ((fFlags & ERROR) != 0) {
+                       data= CPluginImages.DESC_OVR_ERROR.getImageData();
+                       drawImage(data, x, size.y - data.height);
+                       x+= data.width;
+               }
+               if ((fFlags & WARNING) != 0) {
+                       data= CPluginImages.DESC_OVR_WARNING.getImageData();
+                       drawImage(data, x, size.y - data.height);
+                       x+= data.width;
+               }
+       }               
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementLabelProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementLabelProvider.java
new file mode 100644 (file)
index 0000000..52ae3e4
--- /dev/null
@@ -0,0 +1,189 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.ui;
+
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
+
+import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider;
+
+/**
+ * The label provider for the c model elements.
+ */
+public class CElementLabelProvider extends LabelProvider {
+
+       /**
+        * Flag (bit mask) indicating that methods labels include the method return type. (appended)
+        */
+       public final static int SHOW_RETURN_TYPE = 0x001;
+
+       /**
+        * Flag (bit mask) indicating that method label include method parameter types.
+        */
+       public final static int SHOW_PARAMETERS = 0x002;
+
+       /**
+        * Flag (bit mask) indicating that method label include thrown exception.
+        */
+       public final static int SHOW_EXCEPTION = 0x004;
+
+       /**
+        * Flag (bit mask) indicating that the label should show the icons with no space
+        * reserved for overlays.
+        */
+       public final static int SHOW_SMALL_ICONS = 0x100;
+
+       /**
+        * Flag (bit mask) indicating that the label should include overlay icons
+        * for element type and modifiers.
+        */
+       public final static int SHOW_OVERLAY_ICONS = 0x010;
+
+       /**
+        * Flag (bit mask) indicating that Complation Units, Class Files, Types, Declarations and Members
+        * should be rendered qualified.
+        * Examples: java.lang.String, java.util.Vector.size()
+        * 
+        * @since 2.0
+        */
+       public final static int SHOW_QUALIFIED=                         0x400;
+
+       /**
+        * Flag (bit mask) indicating that Compilation Units, Class Files, Types, Declarations and Members
+        * should be rendered qualified. The qualification is appended
+        * Examples: String - java.lang, size() - java.util.Vector
+        * 
+        * @since 2.0
+        */
+       public final static int SHOW_POST_QUALIFIED=    0x800;  
+       
+       
+       /**
+        * Constant (value <code>0</code>) indicating that the label should show 
+        * the basic images only.
+        */
+       public final static int SHOW_BASICS= 0x000;
+       
+       
+       public final static int SHOW_DEFAULT= new Integer(SHOW_PARAMETERS | SHOW_OVERLAY_ICONS).intValue();
+       
+       private volatile WorkbenchLabelProvider fWorkbenchLabelProvider;
+       protected CElementImageProvider fImageLabelProvider;
+       private CUILabelProvider fCElementLabelProvider;
+
+       private int fFlags;
+       private int fImageFlags;
+       private int fTextFlags;
+
+       public CElementLabelProvider() {
+               this(SHOW_DEFAULT);
+       }
+
+       public CElementLabelProvider(int flags) {
+               // WorkbenchLabelProvider may only be initialized on the UI thread
+               // http://bugs.eclipse.org/247274
+               if (Display.getCurrent() != null) {
+                       fWorkbenchLabelProvider= new WorkbenchLabelProvider();
+               } else {
+                       // Delay initialization
+                       CUIPlugin.getStandardDisplay().asyncExec(new Runnable() {
+                               public void run() {
+                                       if (fCElementLabelProvider != null) {
+                                               fWorkbenchLabelProvider= new WorkbenchLabelProvider();
+                                       }
+                               }});
+               }
+               fImageLabelProvider= new CElementImageProvider();
+
+               fFlags = flags;
+               fCElementLabelProvider= new CUILabelProvider(getTextFlags() | CElementLabels.TEMPLATE_PARAMETERS, getImageFlags());
+       }
+
+       @Override
+       public String getText(Object element) {
+               if (element instanceof ICElement) {
+                       return fCElementLabelProvider.getText(element);
+               }
+               if (fWorkbenchLabelProvider != null) {
+                       return fWorkbenchLabelProvider.getText(element);
+               }
+               return super.getText(element);
+       }
+
+       @Override
+       public Image getImage(Object element) {
+               return fImageLabelProvider.getImageLabel(element, getImageFlags());
+       }
+       
+       @Override
+       public void dispose() {
+               if (fCElementLabelProvider != null) {
+                       fCElementLabelProvider.dispose();
+                       fCElementLabelProvider= null;
+               }
+               if (fWorkbenchLabelProvider != null) {
+                       fWorkbenchLabelProvider.dispose();
+                       fWorkbenchLabelProvider= null;
+               }
+               if(fImageLabelProvider != null) {
+                       fImageLabelProvider.dispose();
+               }
+       }
+
+       private boolean getFlag(int flag) {
+               return (fFlags & flag) != 0;
+       }
+
+       /**
+        * Gets the image flags.
+        * Can be overwritten by super classes.
+        * @return Returns a int
+        */
+       public int getImageFlags() {
+               fImageFlags = 0;
+               if (getFlag(SHOW_OVERLAY_ICONS)) {
+                       fImageFlags |= CElementImageProvider.OVERLAY_ICONS;
+               }
+               if (getFlag(SHOW_SMALL_ICONS)) {
+                       fImageFlags |= CElementImageProvider.SMALL_ICONS;
+               }
+               return fImageFlags;
+       }
+
+       /**
+        * Gets the text flags. Can be overwritten by super classes.
+        * @return Returns a int
+        */
+       public int getTextFlags() {
+               fTextFlags = 0;
+               if (getFlag(SHOW_RETURN_TYPE)) {
+                       fTextFlags |= CElementLabels.M_APP_RETURNTYPE;
+               }
+               if (getFlag(SHOW_PARAMETERS)) {
+                       fTextFlags |= CElementLabels.M_PARAMETER_TYPES;
+               }
+               if (getFlag(SHOW_EXCEPTION)) {
+                       fTextFlags |= CElementLabels.M_EXCEPTIONS;
+               }
+               if (getFlag(SHOW_POST_QUALIFIED)) {
+                       fTextFlags |= CElementLabels.M_POST_QUALIFIED;
+               }
+               return fTextFlags;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementSorter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementSorter.java
new file mode 100644 (file)
index 0000000..58485bb
--- /dev/null
@@ -0,0 +1,442 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.ui;
+
+import java.util.Comparator;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.ContentViewer;
+import org.eclipse.jface.viewers.IBaseLabelProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.IArchiveContainer;
+import org.eclipse.cdt.core.model.IBinaryContainer;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IIncludeReference;
+import org.eclipse.cdt.core.model.ILibraryReference;
+import org.eclipse.cdt.core.model.IMember;
+import org.eclipse.cdt.core.model.IMethodDeclaration;
+import org.eclipse.cdt.core.model.ISourceRoot;
+
+/**
+ *     A sorter to sort the file and the folders in the C viewer in the following order:
+ *     1 Project
+ *     2 BinaryContainer
+ *  3 ArchiveContainer
+ *  4 LibraryContainer
+ *  5 IncludeContainer
+ *  6 Source roots
+ *  5 C Elements
+ *  6 non C Elements
+ *  
+ *  @noextend This class is not intended to be subclassed by clients.
+ */
+public class CElementSorter extends ViewerSorter { 
+
+    protected static final int CMODEL = 0;
+       protected static final int PROJECTS = 10;
+       protected static final int BINARYCONTAINER = 12;
+       protected static final int ARCHIVECONTAINER = 13;
+       protected static final int INCLUDEREFCONTAINER = 14;
+       protected static final int LIBRARYREFCONTAINER = 15;
+       protected static final int SOURCEROOTS = 16;
+       protected static final int CCONTAINERS = 17;
+       protected static final int LIBRARYREFERENCES = 18;
+       protected static final int INCLUDEREFERENCES = 19;
+       protected static final int TRANSLATIONUNIT_HEADERS = 20;
+       protected static final int TRANSLATIONUNIT_SOURCE = 21;
+       protected static final int TRANSLATIONUNITS = 22;
+       protected static final int BINARIES = 23;
+       protected static final int ARCHIVES = 24;
+       
+       protected static final int INCLUDES = 28;
+       protected static final int MACROS = 29;
+       protected static final int USINGS = 30;
+       protected static final int NAMESPACES = 32;
+       protected static final int NAMESPACES_RESERVED = 33;
+       protected static final int NAMESPACES_SYSTEM = 34;
+       /**
+        * @since 5.1
+        */
+       protected static final int TYPES = 35;
+
+       @Deprecated
+       protected static final int VARIABLEDECLARATIONS = 36;
+       @Deprecated
+       protected static final int FUNCTIONDECLARATIONS = 37;
+       protected static final int VARIABLES = 38;
+       protected static final int VARIABLES_RESERVED = 39;
+       protected static final int VARIABLES_SYSTEM = 40;
+       protected static final int FUNCTIONS = 41;
+       protected static final int FUNCTIONS_RESERVED = 42;
+       protected static final int FUNCTIONS_SYSTEM = 43;
+       @Deprecated
+       protected static final int METHODDECLARATIONS = 44;
+
+       protected static final int CELEMENTS = 100;
+       protected static final int CELEMENTS_RESERVED = 101;
+       protected static final int CELEMENTS_SYSTEM = 102;
+
+       protected static final int RESOURCEFOLDERS= 200;
+       protected static final int RESOURCES= 201;
+       protected static final int STORAGE= 202;
+       protected static final int OTHERS= 500;
+
+
+       /*
+        * Constants added for names starting with '_' or '__'
+        */
+       private static final int NORMAL = 0;
+       private static final int RESERVED = 1;
+       private static final int SYSTEM = 2;
+
+       /*
+        * Constants for ordering different member kinds.
+        */
+       private static final int STATIC_MEMBER = 0;
+       private static final int CONSTRUCTOR = 1;
+       private static final int DESTRUCTOR = 2;
+       private static final int MEMBER = 3;
+
+       /**
+        * Flag indicating whether header files and source files should be separated.
+        * If <code>true</code>, header files will be sorted before source files,
+        * otherwise header and source files will be sorted by name.
+        */
+       private boolean fSeparateHeaderAndSource;
+       
+       private boolean fKeepSortOrderOfExcludedFiles;
+
+       /**
+        * Default constructor for use as executable extension.
+        */
+       public CElementSorter() {
+               final IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+               fSeparateHeaderAndSource= store.getBoolean(PreferenceConstants.CVIEW_SEPARATE_HEADER_AND_SOURCE);
+               fKeepSortOrderOfExcludedFiles= store.getBoolean(PreferenceConstants.SORT_ORDER_OF_EXCLUDED_FILES);
+       }
+       
+       @Override
+       public int category (Object element) {
+               if (element instanceof ICElement) {
+                       ICElement cElement = (ICElement) element;
+                       switch (cElement.getElementType()) {
+                       case ICElement.C_MODEL:
+                               return CMODEL;
+                       case ICElement.C_PROJECT:
+                               return PROJECTS;
+                       case ICElement.C_CCONTAINER:
+                               if (element instanceof ISourceRoot) {
+                                       return SOURCEROOTS;
+                               }
+                               return CCONTAINERS;
+                       case ICElement.C_VCONTAINER:
+                               if (element instanceof IBinaryContainer) {
+                                       return BINARYCONTAINER;
+                               } else if (element instanceof IArchiveContainer) {
+                                       return ARCHIVECONTAINER;
+                               } else if (element instanceof ILibraryReference) {
+                                       return LIBRARYREFERENCES;
+                               } else if (element instanceof IIncludeReference) {
+                                       return INCLUDEREFERENCES;
+                               }
+                               return CCONTAINERS;
+                       case ICElement.C_UNIT:
+                               return getTranslationUnitCategory(cElement.getCProject().getProject(), cElement.getElementName());
+                       case ICElement.C_INCLUDE:
+                               return INCLUDES;
+                       case ICElement.C_MACRO:
+                               return MACROS;
+                       case ICElement.C_NAMESPACE:
+                               return NAMESPACES + getNameKind(cElement.getElementName());
+                       case ICElement.C_USING:
+                               return USINGS;
+                       case ICElement.C_TYPEDEF:
+                       case ICElement.C_CLASS: 
+                       case ICElement.C_CLASS_DECLARATION:
+                       case ICElement.C_TEMPLATE_CLASS:
+                       case ICElement.C_TEMPLATE_CLASS_DECLARATION:
+                       case ICElement.C_STRUCT:
+                       case ICElement.C_STRUCT_DECLARATION:
+                       case ICElement.C_TEMPLATE_STRUCT:
+                       case ICElement.C_TEMPLATE_STRUCT_DECLARATION:
+                       case ICElement.C_UNION:
+                       case ICElement.C_UNION_DECLARATION:
+                       case ICElement.C_TEMPLATE_UNION:
+                       case ICElement.C_TEMPLATE_UNION_DECLARATION:
+                       case ICElement.C_ENUMERATION:
+                               return TYPES;
+                       case ICElement.C_VARIABLE_DECLARATION:
+                       case ICElement.C_VARIABLE:
+                       case ICElement.C_TEMPLATE_VARIABLE:
+                       case ICElement.C_FIELD:
+                               return VARIABLES + getNameKind(cElement.getElementName());
+                       case ICElement.C_FUNCTION_DECLARATION:
+                       case ICElement.C_FUNCTION:
+                       case ICElement.C_TEMPLATE_FUNCTION_DECLARATION:
+                       case ICElement.C_TEMPLATE_FUNCTION:
+                       case ICElement.C_METHOD_DECLARATION:
+                       case ICElement.C_METHOD:
+                       case ICElement.C_TEMPLATE_METHOD_DECLARATION:
+                       case ICElement.C_TEMPLATE_METHOD:
+                               return FUNCTIONS + getNameKind(cElement.getElementName());
+                       case ICElement.C_ARCHIVE:
+                               return ARCHIVES;
+                       case ICElement.C_BINARY:
+                               return BINARIES;
+                       default:
+                               return CELEMENTS + getNameKind(cElement.getElementName());
+                       }
+               } else if (element instanceof IResource) {
+                       IResource resource = (IResource) element;
+                       switch (resource.getType()) {
+                       case IResource.PROJECT:
+                               return PROJECTS;
+                       case IResource.FOLDER:
+                               return RESOURCEFOLDERS;
+                       default: // translation unit that was excluded from the build
+                               if(fKeepSortOrderOfExcludedFiles &&
+                                               CoreModel.isValidTranslationUnitName(resource.getProject(), resource.getName())) {
+                                       return getTranslationUnitCategory(resource.getProject(), resource.getName());
+                               } 
+                               return RESOURCES;
+                       }
+               } else if (element instanceof IStorage) {
+                       return STORAGE;
+               } else if (element instanceof CElementGrouping) {
+                       int type = ((CElementGrouping)element).getType();
+                       switch (type) {
+                       case CElementGrouping.INCLUDES_GROUPING:
+                               return INCLUDES;
+                       case CElementGrouping.MACROS_GROUPING:
+                               return MACROS;
+                       case CElementGrouping.CLASS_GROUPING:
+                               return TYPES;
+                       case CElementGrouping.NAMESPACE_GROUPING:
+                               return NAMESPACES;
+                       case CElementGrouping.LIBRARY_REF_CONTAINER:
+                               return LIBRARYREFCONTAINER;
+                       case CElementGrouping.INCLUDE_REF_CONTAINER:
+                               return INCLUDEREFCONTAINER;
+                       }
+               }
+               return OTHERS;
+       }
+
+       private int getNameKind(String name) {
+               int length = name.length();
+               if (length > 0 && name.charAt(0) == '_') {
+                       if (length > 1 && name.charAt(1) == '_') {
+                               return SYSTEM;
+                       }
+                       return RESERVED;
+               }
+               return NORMAL;
+       }
+       
+       private int getTranslationUnitCategory(IProject project, String name) {
+               if (fSeparateHeaderAndSource) {
+                       if (CoreModel.isValidHeaderUnitName(project, name)) {
+                               return TRANSLATIONUNIT_HEADERS;
+                       }
+                       if (CoreModel.isValidSourceUnitName(project, name)) {
+                               return TRANSLATIONUNIT_SOURCE;
+                       }
+               }
+               return TRANSLATIONUNITS;
+       } 
+
+       @Override
+       public int compare(Viewer viewer, Object e1, Object e2) {
+               int cat1 = category(e1);
+               int cat2 = category(e2);
+
+               if (cat1 != cat2)
+                       return cat1 - cat2;
+
+               // cat1 == cat2
+
+               @SuppressWarnings("unchecked")
+               final Comparator<Object> comparator = getComparator();
+               if (cat1 == PROJECTS) {
+                       IWorkbenchAdapter a1= (IWorkbenchAdapter)((IAdaptable)e1).getAdapter(IWorkbenchAdapter.class);
+                       IWorkbenchAdapter a2= (IWorkbenchAdapter)((IAdaptable)e2).getAdapter(IWorkbenchAdapter.class);
+                       return comparator.compare(a1.getLabel(e1), a2.getLabel(e2));
+               }
+
+               if (cat1 == SOURCEROOTS) {
+                       ISourceRoot root1= getSourceRoot(e1);
+                       ISourceRoot root2= getSourceRoot(e2);
+                       if (root1 == null) {
+                               if (root2 == null) {
+                                       return 0;
+                               }
+                               return 1;
+                       } else if (root2 == null) {
+                               return -1;
+                       }                       
+                       if (!root1.getPath().equals(root2.getPath())) {
+                               int p1= getPathEntryIndex(root1);
+                               int p2= getPathEntryIndex(root2);
+                               if (p1 != p2) {
+                                       return p1 - p2;
+                               }
+                       }
+               }
+
+               // non - c resources are sorted using the label from the viewers label provider
+               if (cat1 == RESOURCES || cat1 == RESOURCEFOLDERS || cat1 == STORAGE || cat1 == OTHERS) {
+                       return compareWithLabelProvider(viewer, e1, e2);
+               }
+               
+               String ns1 = ""; //$NON-NLS-1$
+               String ns2 = ns1;
+               
+               String name1;
+               String name2;
+
+               if (e1 instanceof ICElement) {
+                       name1 = ((ICElement)e1).getElementName();
+                       int idx = name1.lastIndexOf("::"); //$NON-NLS-1$
+                       if (idx >= 0) {
+                               ns1 = name1.substring(0, idx);
+                               name1 = name1.substring(idx + 2);
+                       }
+                   if (name1.length() > 0 && name1.charAt(0) == '~') {
+                       name1 = name1.substring(1);
+                   }
+               } else if (e1 instanceof IResource) {
+                   name1 = ((IResource)e1).getName(); 
+               } else {
+                       name1 = e1.toString();
+               }
+               if (e2 instanceof ICElement) {
+                       name2 = ((ICElement)e2).getElementName();
+                       int idx = name2.lastIndexOf("::"); //$NON-NLS-1$
+                       if (idx >= 0) {
+                               ns2 = name2.substring(0, idx);
+                               name2 = name2.substring(idx + 2);
+                       }
+                   if (name2.length() > 0 && name2.charAt(0) == '~') {
+                       name2 = name2.substring(1);
+                   }
+               } else if(e2 instanceof IResource) {
+                   name2 = ((IResource)e2).getName(); 
+               } else {
+                       name2 = e2.toString();
+               }
+               
+               // compare namespace
+               int result = comparator.compare(ns1, ns2);
+               if (result != 0) {
+                       return result;
+               }
+               
+               // compare method/member kind
+               if (e1 instanceof IMethodDeclaration && e2 instanceof IMethodDeclaration) {
+                       result = getMethodKind((IMethodDeclaration) e1) - getMethodKind((IMethodDeclaration) e2);
+               } else if (e1 instanceof IMember && e2 instanceof IMember) {
+                       result = getMemberKind((IMember) e1) - getMemberKind((IMember) e2);
+               }
+               if (result != 0) {
+                       return result;
+               }
+
+               // compare simple name
+               result = comparator.compare(name1, name2);
+               if (result != 0) {
+                       return result;
+               }
+               return result;
+       }
+
+       private int getMethodKind(IMethodDeclaration method) {
+               try {
+                       if (method.isStatic()) {
+                               return STATIC_MEMBER;
+                       }
+                       if (method.isConstructor()) {
+                               return CONSTRUCTOR;
+                       }
+                       if (method.isDestructor()) {
+                               return DESTRUCTOR;
+                       }
+               } catch (CModelException exc) {
+                       // ignore
+               }
+               return MEMBER;
+       }
+
+       private int getMemberKind(IMember member) {
+               try {
+                       if (member.isStatic()) {
+                               return STATIC_MEMBER;
+                       }
+               } catch (CModelException exc) {
+                       // ignore
+               }
+               return MEMBER;
+       }
+
+       private ISourceRoot getSourceRoot(Object element) {
+               ICElement celement = (ICElement)element;
+               while (! (celement instanceof ISourceRoot) && celement != null) {
+                       celement = celement.getParent();
+               }
+               return (ISourceRoot)celement;
+       }
+
+       private int compareWithLabelProvider(Viewer viewer, Object e1, Object e2) {
+               if (viewer instanceof ContentViewer) {
+                       IBaseLabelProvider prov = ((ContentViewer) viewer).getLabelProvider();
+                       if (prov instanceof ILabelProvider) {
+                               ILabelProvider lprov= (ILabelProvider) prov;
+                               String name1 = lprov.getText(e1);
+                               String name2 = lprov.getText(e2);
+                               if (name1 != null && name2 != null) {
+                                       @SuppressWarnings("unchecked")
+                                       final Comparator<Object> comparator = getComparator();
+                                       return comparator.compare(name1, name2);
+                               }
+                       }
+               }
+               return 0; // can't compare
+       }
+
+       private int getPathEntryIndex(ISourceRoot root) {
+               try {
+                       IPath rootPath= root.getPath();
+                       ISourceRoot[] roots= root.getCProject().getSourceRoots();
+                       for (int i= 0; i < roots.length; i++) {
+                               if (roots[i].getPath().equals(rootPath)) {
+                                       return i;
+                               }
+                       }
+               } catch (CModelException e) {
+               }
+
+               return Integer.MAX_VALUE;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java
new file mode 100644 (file)
index 0000000..f8e2cdc
--- /dev/null
@@ -0,0 +1,1041 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     IBM Corp. - Rational Software
+ *     Markus Schorn (Wind River Systems)
+ *     Anton Leherbauer (Wind River Systems)
+ *     Jeff Johnston (Red Hat Inc.)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.ui;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+import java.util.Set;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdapterManager;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.source.ISharedTextColors;
+import org.eclipse.jface.text.templates.ContextTypeRegistry;
+import org.eclipse.jface.text.templates.persistence.TemplateStore;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.editors.text.templates.ContributionContextTypeRegistry;
+import org.eclipse.ui.editors.text.templates.ContributionTemplateStore;
+import org.eclipse.ui.navigator.ICommonMenuConstants;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
+import org.eclipse.ui.texteditor.ChainedPreferenceStore;
+import org.eclipse.ui.texteditor.ConfigurationElementSorter;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+
+import com.ibm.icu.text.MessageFormat;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.core.model.IWorkingCopyProvider;
+
+import org.eclipse.cdt.internal.core.dom.rewrite.ASTRewriteAnalyzer;
+import org.eclipse.cdt.internal.core.model.IBufferFactory;
+import org.eclipse.cdt.internal.corext.template.c.CContextType;
+import org.eclipse.cdt.internal.corext.template.c.CodeTemplateContextType;
+import org.eclipse.cdt.internal.corext.template.c.CommentContextType;
+import org.eclipse.cdt.internal.corext.template.c.DocCommentContextType;
+import org.eclipse.cdt.internal.corext.template.c.FileTemplateContextType;
+
+import org.eclipse.cdt.internal.ui.CElementAdapterFactory;
+import org.eclipse.cdt.internal.ui.ICStatusConstants;
+import org.eclipse.cdt.internal.ui.IContextMenuConstants;
+import org.eclipse.cdt.internal.ui.ResourceAdapterFactory;
+import org.eclipse.cdt.internal.ui.buildconsole.BuildConsoleManager;
+import org.eclipse.cdt.internal.ui.buildconsole.GlobalBuildConsoleManager;
+import org.eclipse.cdt.internal.ui.editor.ASTProvider;
+import org.eclipse.cdt.internal.ui.editor.CDocumentProvider;
+import org.eclipse.cdt.internal.ui.editor.WorkingCopyManager;
+import org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage;
+import org.eclipse.cdt.internal.ui.refactoring.CTextFileChangeFactory;
+import org.eclipse.cdt.internal.ui.text.CTextTools;
+import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverDescriptor;
+import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
+import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
+import org.eclipse.cdt.internal.ui.text.doctools.EditorReopener;
+import org.eclipse.cdt.internal.ui.text.folding.CFoldingStructureProviderRegistry;
+import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;
+import org.eclipse.cdt.internal.ui.util.ProblemMarkerManager;
+import org.eclipse.cdt.internal.ui.util.Util;
+import org.eclipse.cdt.internal.ui.viewsupport.CDTContextActivator;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ */
+public class CUIPlugin extends AbstractUIPlugin {
+       public static final String PLUGIN_ID = "org.eclipse.cdt.ui"; //$NON-NLS-1$
+       public static final String PLUGIN_CORE_ID = "org.eclipse.cdt.core"; //$NON-NLS-1$
+       public static final String EDITOR_ID = PLUGIN_ID + ".editor.CEditor"; //$NON-NLS-1$
+       public static final String CVIEW_ID = PLUGIN_ID + ".CView"; //$NON-NLS-1$
+       public static final String C_PROBLEMMARKER = PLUGIN_CORE_ID + ".problem"; //$NON-NLS-1$
+
+       public static final String ID_COMMENT_OWNER= PLUGIN_ID+".DocCommentOwner"; //$NON-NLS-1$
+       
+    public static final String ID_INCLUDE_BROWSER= PLUGIN_ID + ".includeBrowser"; //$NON-NLS-1$
+    public static final String ID_CALL_HIERARCHY= PLUGIN_ID + ".callHierarchy"; //$NON-NLS-1$
+       public static final String ID_TYPE_HIERARCHY = PLUGIN_ID + ".typeHierarchy"; //$NON-NLS-1$
+    
+       public static final String C_PROJECT_WIZARD_ID = PLUGIN_ID + ".wizards.StdCWizard"; //$NON-NLS-1$
+       public static final String CPP_PROJECT_WIZARD_ID = PLUGIN_ID + ".wizards.StdCCWizard"; //$NON-NLS-1$
+
+       public final static String CWIZARD_CATEGORY_ID = "org.eclipse.cdt.ui.newCWizards"; //$NON-NLS-1$
+       /** @deprecated This wizard category has been merged with the {@link #CWIZARD_CATEGORY_ID c wizard category} */
+       @Deprecated
+       public final static String CCWIZARD_CATEGORY_ID = "org.eclipse.cdt.ui.newCCWizards"; //$NON-NLS-1$
+       
+       public static final String SEARCH_ACTION_SET_ID = PLUGIN_ID + ".SearchActionSet"; //$NON-NLS-1$
+       public static final String BUILDER_ID = PLUGIN_CORE_ID + ".cbuilder"; //$NON-NLS-1$
+
+       private static CUIPlugin fgCPlugin;
+       private static ResourceBundle fgResourceBundle;
+
+       private static final String CONTENTASSIST = CUIPlugin.PLUGIN_ID + "/debug/contentassist" ; //$NON-NLS-1$
+
+       /**
+        * The id of the C perspective
+        * (value <code>"org.eclipse.cdt.ui.CPerspective"</code>).
+        */     
+       public static final String ID_CPERSPECTIVE = PLUGIN_ID + ".CPerspective"; //$NON-NLS-1$
+
+       /**
+        * The id of the C hierarchy perspective
+        * (value <code>"org.eclipse.cdt.ui.CHierarchyPerspective"</code>).
+        * 
+        * @deprecated This perspective no longer exists.
+        */     
+       @Deprecated
+       public static final String ID_CHIERARCHY_PERSPECTIVE = PLUGIN_ID + ".CHierarchyPerspective"; //$NON-NLS-1$
+
+       /**
+        * The id of the C Browsing Perspective
+        * (value <code>"org.eclipse.cdt.ui.CBrowsingPerspective"</code>).
+        * 
+        * @since 2.0
+        * @deprecated This perspective no longer exists.
+        */
+       @Deprecated
+       public static final String ID_CBROWSING_PERSPECTIVE = PLUGIN_ID + ".CBrowsingPerspective"; //$NON-NLS-1$
+
+       /**
+        * The view part id of the C Browsing Projects view
+        * (value <code>"org.eclipse.cdt.ui.ProjectsView"</code>).
+        * 
+        * @since 2.0
+        * @deprecated This view no longer exists.
+        * @noreference This field is not intended to be referenced by clients.
+        */
+       @Deprecated
+       public static String ID_PROJECTS_VIEW = PLUGIN_ID + ".ProjectsView"; //$NON-NLS-1$
+
+       /**
+        * The view part id of the C Browsing Namespaces view
+        * (value <code>"org.eclipse.cdt.ui.NamespacesView"</code>).
+        * 
+        * @since 2.0
+        * @deprecated This view no longer exists.
+        * @noreference This field is not intended to be referenced by clients.
+        */
+       @Deprecated
+       public static String ID_NAMESPACES_VIEW = PLUGIN_ID + ".NamespacesView"; //$NON-NLS-1$
+
+       /**
+        * The view part id of the C Browsing Types view
+        * (value <code>"org.eclipse.cdt.ui.TypesView"</code>).
+        * 
+        * @since 2.0
+        * @deprecated This view no longer exists.
+        * @noreference This field is not intended to be referenced by clients.
+        */
+       @Deprecated
+       public static String ID_TYPES_VIEW = PLUGIN_ID + ".TypesView"; //$NON-NLS-1$
+
+       /**
+        * The view part id of the C Browsing Members view
+        * (value <code>"org.eclipse.cdt.ui.MembersView"</code>).
+        * 
+        * @since 2.0
+        * @deprecated This view no longer exists.
+        * @noreference This field is not intended to be referenced by clients.
+        */
+       @Deprecated
+       public static String ID_MEMBERS_VIEW = PLUGIN_ID + ".MembersView"; //$NON-NLS-1$
+
+       /**
+        * The key to store customized templates. 
+        * @since 3.0
+        */
+       private static final String CUSTOM_TEMPLATES_KEY= "org.eclipse.cdt.ui.text.templates.custom"; //$NON-NLS-1$
+
+       /**
+        * The id of the C Element Creation action set
+        * (value <code>"org.eclipse.cdt.ui.CElementCreationActionSet"</code>).
+        * 
+        * @since 2.0
+        */
+       public static final String ID_CELEMENT_CREATION_ACTION_SET= "org.eclipse.cdt.ui.CElementCreationActionSet"; //$NON-NLS-1$
+       
+       /**
+        * The id of the scope used by all the CDT views
+        * (value <code>"org.eclipse.cdt.ui.scope"</code>).
+        * @since 4.0
+        */
+       public static final String CVIEWS_SCOPE = "org.eclipse.cdt.ui.cViewScope"; //$NON-NLS-1$
+       
+       /**
+        * The key to store customized code templates. 
+        * @since 5.0
+        */
+       private static final String CODE_TEMPLATES_KEY= "org.eclipse.cdt.ui.text.custom_code_templates"; //$NON-NLS-1$
+
+       // -------- static methods --------
+
+       static {
+               try {
+                       fgResourceBundle = ResourceBundle.getBundle("org.eclipse.cdt.internal.ui.CPluginResources"); //$NON-NLS-1$
+               } catch (MissingResourceException x) {
+                       fgResourceBundle = null;
+               }
+       }
+
+       /**
+        * @noreference This method is not intended to be referenced by clients.
+        * @deprecated use {@link CDTUITools#getWorkingCopyManager()}, instead.
+        */
+       @Deprecated
+       public synchronized IBufferFactory getBufferFactory() {
+               return ((WorkingCopyManager) getWorkingCopyManager()).getBufferFactory();
+       }
+       
+       public static IWorkingCopy[] getSharedWorkingCopies() {
+               return getDefault().getWorkingCopyManager().getSharedWorkingCopies();
+       }
+       
+       public static String getResourceString(String key) {
+               try {
+                       return fgResourceBundle.getString(key);
+               } catch (MissingResourceException e) {
+                       return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$
+               } catch (NullPointerException e) {
+                       return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$
+               }
+       }
+
+       public static IWorkspace getWorkspace() {
+               return ResourcesPlugin.getWorkspace();
+       }
+       
+       public static String getFormattedString(String key, String arg) {
+               return MessageFormat.format(getResourceString(key), new Object[] {arg});
+       }
+
+       public static String getFormattedString(String key, String[] args) {
+               return MessageFormat.format(getResourceString(key), (Object[]) args);
+       }
+
+       public static ResourceBundle getResourceBundle() {
+               return fgResourceBundle;
+       }
+       
+       public static IWorkbenchWindow getActiveWorkbenchWindow() {
+               return getDefault().getWorkbench().getActiveWorkbenchWindow();
+       }
+
+       public static IWorkbenchPage getActivePage() {
+               IWorkbenchWindow window = getActiveWorkbenchWindow();
+               if (window != null) {
+                       return window.getActivePage();
+               }
+               return null;
+       }
+
+       public static Shell getActiveWorkbenchShell() {
+                IWorkbenchWindow window= getActiveWorkbenchWindow();
+                if (window != null) {
+                       return window.getShell();
+                }
+                return null;
+       }
+
+       public static CUIPlugin getDefault() {
+               return fgCPlugin;
+       }
+
+       public static void log(Throwable e) {
+               log("Error", e); //$NON-NLS-1$
+       }
+
+       public static void log(String message, Throwable e) {
+               log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, message, e));
+       }
+
+       public static void log(IStatus status) {
+               getDefault().getLog().log(status);
+       }
+       
+       /**
+        * @noreference This method is not intended to be referenced by clients.
+        */
+       public static void logError(String message) {
+               log(message, null);
+       }
+
+       /**
+        * @deprecated Use {@link #logError(String)}
+        */
+       @Deprecated
+       public void logErrorMessage(String message) {
+               log(new Status(IStatus.ERROR, PLUGIN_ID, ICStatusConstants.INTERNAL_ERROR, message, null));
+       }
+
+       /**
+       * Utility method with conventions
+       * @param logError TODO
+       */
+       public static void errorDialog(Shell shell, String title, String message, IStatus s, boolean logError) {
+               if (logError)
+                   log(s);
+               
+               // if the 'message' resource string and the IStatus' message are the same,
+               // don't show both in the dialog
+               if (s != null && message.equals(s.getMessage())) {
+                       message = null;
+               }
+               ErrorDialog.openError(shell, title, message, s);
+       }
+
+       /**
+       * Utility method with conventions
+       * @param logError TODO
+       */
+       public static void errorDialog(Shell shell, String title, String message, Throwable t, boolean logError) {
+               if (logError)
+                       log(message, t);
+               
+               IStatus status;
+               if (t instanceof CoreException) {
+                       status = ((CoreException) t).getStatus();
+                       // if the 'message' resource string and the IStatus' message are the same,
+                       // don't show both in the dialog
+                       if (status != null && message.equals(status.getMessage())) {
+                               message = null;
+                       }
+               } else {
+                       status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, -1, "Internal Error: ", t); //$NON-NLS-1$       
+               }
+               ErrorDialog.openError(shell, title, message, status);
+       }
+
+       // ------ CUIPlugin
+
+       private ImageDescriptorRegistry fImageDescriptorRegistry;
+       private CEditorTextHoverDescriptor[] fCEditorTextHoverDescriptors;
+
+       /**
+        * The extension point registry for the <code>org.eclipse.cdt.ui.foldingStructureProviders</code>
+        * extension point.
+        */
+       private CFoldingStructureProviderRegistry fFoldingStructureProviderRegistry;
+
+       /**
+        * The combined preference store.
+        * @since 3.0
+        */
+       private IPreferenceStore fCombinedPreferenceStore;
+
+       /**
+        * The core preference store.
+        * @since 5.3
+        */
+       private IPreferenceStore fCorePreferenceStore;
+
+       private CoreModel fCoreModel;
+       private CDocumentProvider fDocumentProvider;
+       private WorkingCopyManager fWorkingCopyManager;
+       private CTextTools fTextTools;
+       private ProblemMarkerManager fProblemMarkerManager;
+       private Map<String, BuildConsoleManager> fBuildConsoleManagers;
+       private ResourceAdapterFactory fResourceAdapterFactory;
+       private CElementAdapterFactory fCElementAdapterFactory;
+
+       /** 
+        * The template context type registry for the C editor. 
+        * @since 3.0
+        */
+       private ContributionContextTypeRegistry fContextTypeRegistry;
+
+       /**
+        * The template store for the C editor. 
+        * @since 3.0
+        */
+       private TemplateStore fTemplateStore;
+
+       /**
+        * The AST provider.
+        * @since 4.0
+        */
+       private ASTProvider fASTProvider;
+
+       /** 
+        * The code template context type registry for the C editor. 
+        * @since 5.0
+        */
+       private ContextTypeRegistry fCodeTemplateContextTypeRegistry;
+       
+       /**
+        * The code template store for the C editor. 
+        * @since 5.0
+        */
+       private TemplateStore fCodeTemplateStore;
+
+       public CUIPlugin() {
+               fgCPlugin = this;
+               fDocumentProvider = null;
+               fTextTools = null;              
+               fBuildConsoleManagers = new HashMap<String, BuildConsoleManager>();
+       }
+               
+       /**
+        * Returns the used document provider.
+        * 
+        * @noreference This method is not intended to be referenced by clients.
+        */
+       public synchronized CDocumentProvider getDocumentProvider() {
+               if (fDocumentProvider == null) {
+                       fDocumentProvider = new CDocumentProvider();
+               }
+               return fDocumentProvider;
+       }
+       
+       /**
+        * Returns the working copy manager
+        * @return IWorkingCopyManager
+        */
+       public synchronized IWorkingCopyManager getWorkingCopyManager() {
+               if (fWorkingCopyManager == null) {
+                       CDocumentProvider provider = getDocumentProvider();
+                       fWorkingCopyManager = new WorkingCopyManager(provider);
+               }
+               return fWorkingCopyManager;
+       }
+
+       /**
+        * Returns the shared C/C++ text tools.
+        * @noreference This method is not intended to be referenced by clients.
+        */
+       public CTextTools getTextTools() {
+               if (fTextTools == null)
+                       fTextTools = new CTextTools();
+               return fTextTools;
+       }
+
+       /**
+        * Return the default console manager.
+        * @return IBuildConsoleManager
+        */
+       public IBuildConsoleManager getConsoleManager() {
+               return getConsoleManager(getResourceString("BuildConsole.name"), BuildConsoleManager.DEFAULT_CONTEXT_MENU_ID); //$NON-NLS-1$
+       }
+
+       /**
+        * Obtain a console manager with the given id. If a manager has not been created yet,
+        * it is created and its console created and activated.
+        * 
+        * @param name - console name.
+        * @param contextId - console id matching context id in the Console view dropdown.
+        * @return console manager.
+        * 
+        * Note that this method is rather internal and should not be referenced by clients.
+        * To create a build console, use {@link CCorePlugin#getBuildConsole(String, String, URL)}
+        */
+       public IBuildConsoleManager getConsoleManager(String name, String contextId) {
+               return getConsoleManager(name, contextId, null);
+       }
+
+       /**
+        * Obtain a console manager with the given id. If a manager has not been created yet,
+        * it is created and its console created and activated with the given attributes.
+        * 
+        * @param name - console name.
+        * @param contextId - console id matching context id in the Console view dropdown.
+        *    Can't be {@code null}.
+        * @param iconUrl - a {@link URL} of the icon for the context menu of the Console
+        *    view. The url is expected to point to an image in eclipse OSGi bundle.
+        *    {@code iconUrl} can be <b>null</b>, in that case the default image is used.
+        * @return console manager.
+        * 
+        * @noreference This method is not intended to be referenced by clients.
+        */
+       public IBuildConsoleManager getConsoleManager(String name, String contextId, URL iconUrl) {
+               Assert.isNotNull(contextId);
+
+               BuildConsoleManager manager = fBuildConsoleManagers.get(contextId);
+               if (manager == null ) {
+                       manager = new BuildConsoleManager();
+                       fBuildConsoleManagers.put(contextId, manager);
+                       manager.startup(name, contextId, iconUrl);
+               }
+               return manager;
+       }
+
+       /**
+        * @since 5.3
+        */
+       public void startGlobalConsole() {
+               GlobalBuildConsoleManager.startGlobalConsole();
+       }
+       /*
+        * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+        */
+       @Override
+       public void start(BundleContext context) throws Exception {
+               super.start(context);
+
+               //Set debug tracing options
+               configurePluginDebugOptions();
+               
+               registerAdapters();
+               IWorkingCopyProvider workingCopyProvider = new IWorkingCopyProvider() {
+                       public IWorkingCopy[] getWorkingCopies() {
+                               return CUIPlugin.getSharedWorkingCopies();
+                       }
+               };
+               CCorePlugin.getDefault().getDOM().setWorkingCopyProvider(workingCopyProvider);
+               
+               // init ast provider
+               getASTProvider();
+               CDTContextActivator.getInstance().install();
+               
+               DocCommentOwnerManager.getInstance().addListener(new EditorReopener());
+               ASTRewriteAnalyzer.setCTextFileChangeFactory(new CTextFileChangeFactory());
+               
+               // A workaround for black console bug 320723.
+               BuildConsolePreferencePage.initDefaults(getPreferenceStore());
+               //initialize ContentAssistMatcherPreference
+               ContentAssistPreference.getInstance();
+
+               // start make-ui plugin, such that it can check for project conversions.
+               Job job= new Job(Messages.CUIPlugin_jobStartMakeUI) {
+                       @Override
+                       protected IStatus run(IProgressMonitor monitor) {
+                               Bundle bundle= Platform.getBundle("org.eclipse.cdt.make.ui"); //$NON-NLS-1$
+                               try {
+                                       if (bundle != null) {
+                                               switch (bundle.getState()) {
+                                               case Bundle.RESOLVED:
+                                               case Bundle.STARTING:  // because make.ui uses lazy activation, we need to start it.
+                                                       bundle.start(Bundle.START_TRANSIENT);
+                                                       break;
+                                               }
+                                       }
+                               } catch (BundleException e) {
+                                       return new Status(IStatus.WARNING, PLUGIN_ID, e.getMessage(), e);
+                               }
+                               return Status.OK_STATUS;
+                       }
+               };
+               job.setSystem(true);
+               job.schedule();
+       }
+
+       /* (non-Javadoc)
+        * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+        */
+       @Override
+       public void stop(BundleContext context) throws Exception {
+               CDTContextActivator.getInstance().uninstall();
+               if (fASTProvider != null) {
+                       fASTProvider.dispose();
+                       fASTProvider= null;
+               }
+               if (fTextTools != null) {
+                       fTextTools.dispose();
+                       fTextTools= null;
+               }
+               if (fImageDescriptorRegistry != null) {
+                       fImageDescriptorRegistry.dispose();
+                       fImageDescriptorRegistry= null;
+               }
+               if (fBuildConsoleManagers != null ) {
+                       Object[] bcm = fBuildConsoleManagers.values().toArray();
+                       for (int i = 0; i < bcm.length; ++i) {
+                               BuildConsoleManager m = (BuildConsoleManager)bcm[i];
+                               if (m != null)
+                                       m.shutdown();
+                       }
+                       fBuildConsoleManagers.clear();
+               }
+               
+               GlobalBuildConsoleManager.stop();
+
+               unregisterAdapters();
+
+               if (fWorkingCopyManager != null) {
+                       fWorkingCopyManager.shutdown();
+                       fWorkingCopyManager= null;
+               }
+                
+               if (fDocumentProvider != null) {
+                       fDocumentProvider.shutdown();
+                       fDocumentProvider= null;
+               }
+               
+               ContentAssistPreference.shutdown();
+
+               // Do this last.
+               super.stop(context);
+       }
+
+       public CoreModel getCoreModel() {
+               return fCoreModel;
+       }
+
+       public static String getPluginId() {
+               return PLUGIN_ID;
+       }
+
+       /**
+        * @noreference This method is not intended to be referenced by clients.
+        */
+       public static ImageDescriptorRegistry getImageDescriptorRegistry() {
+               return getDefault().internalGetImageDescriptorRegistry();
+       }
+
+       private ImageDescriptorRegistry internalGetImageDescriptorRegistry() {
+               if (fImageDescriptorRegistry == null)
+                       fImageDescriptorRegistry = new ImageDescriptorRegistry();
+               return fImageDescriptorRegistry;
+       }
+
+       /**
+        * Returns the problem marker manager.
+        * 
+        * @noreference This method is not intended to be referenced by clients.
+        */
+       public ProblemMarkerManager getProblemMarkerManager() {
+               if (fProblemMarkerManager == null)
+                       fProblemMarkerManager = new ProblemMarkerManager();
+               return fProblemMarkerManager;
+       }
+
+       protected void registerAdapters() {
+               fResourceAdapterFactory = new ResourceAdapterFactory();
+               fCElementAdapterFactory = new CElementAdapterFactory();
+
+               IAdapterManager manager = Platform.getAdapterManager();
+               manager.registerAdapters(fResourceAdapterFactory, IResource.class);
+               manager.registerAdapters(fCElementAdapterFactory, ICElement.class);
+       }
+        
+       private void unregisterAdapters() {
+               IAdapterManager manager = Platform.getAdapterManager();
+               manager.unregisterAdapters(fResourceAdapterFactory);
+               manager.unregisterAdapters(fCElementAdapterFactory);
+       }
+
+       /** 
+        * @deprecated Use {@link EditorsUI#getSharedTextColors()} instead.
+        * @noreference This method is not intended to be referenced by clients.
+        */
+       @Deprecated
+       public ISharedTextColors getSharedTextColors() {
+               return EditorsUI.getSharedTextColors();
+       }
+       
+       public void configurePluginDebugOptions() {
+               if (isDebugging()) {
+                       String option = Platform.getDebugOption(CONTENTASSIST);
+                       if (option != null)
+                               Util.VERBOSE_CONTENTASSIST = option.equalsIgnoreCase("true") ; //$NON-NLS-1$
+               }
+       }
+
+       /**
+        * Returns a combined preference store, this store is read-only.
+        * 
+        * @return the combined preference store
+        * 
+        * @since 3.0
+        */
+       public IPreferenceStore getCombinedPreferenceStore() {
+               if (fCombinedPreferenceStore == null) {
+                       fCombinedPreferenceStore= new ChainedPreferenceStore(new IPreferenceStore[] { 
+                                       getPreferenceStore(), 
+                                       getCorePreferenceStore(), 
+                                       EditorsUI.getPreferenceStore() 
+                       });
+               }
+               return fCombinedPreferenceStore;
+       }
+
+       /**
+        * Returns a preference store for org.eclipse.cdt.core preferences
+        * @return the preference store
+        * @since 5.3
+        */
+       public IPreferenceStore getCorePreferenceStore() {
+               if (fCorePreferenceStore == null) {
+                       fCorePreferenceStore= new ScopedPreferenceStore(InstanceScope.INSTANCE, PLUGIN_CORE_ID);
+               }
+               return fCorePreferenceStore;
+       }
+
+       /**
+        * Returns a section in the C UI plugin's dialog settings. If the section doesn't exist yet, it is created.
+        *
+        * @param name the name of the section
+        * @return the section of the given name
+        * @since 5.3
+        */
+       public IDialogSettings getDialogSettingsSection(String name) {
+               IDialogSettings dialogSettings= getDialogSettings();
+               IDialogSettings section= dialogSettings.getSection(name);
+               if (section == null) {
+                       section= dialogSettings.addNewSection(name);
+               }
+               return section;
+       }
+
+       /**
+        * Returns an array of all editors that have an unsaved content. If the identical content is 
+        * presented in more than one editor, only one of those editor parts is part of the result.
+        * 
+        * @return an array of all dirty editor parts.
+        */     
+       public static IEditorPart[] getDirtyEditors() {
+               Set<IEditorInput> inputs= new HashSet<IEditorInput>();
+               List<IEditorPart> result= new ArrayList<IEditorPart>(0);
+               IWorkbench workbench= getDefault().getWorkbench();
+               IWorkbenchWindow[] windows= workbench.getWorkbenchWindows();
+               for (IWorkbenchWindow window : windows) {
+                       IWorkbenchPage[] pages= window.getPages();
+                       for (IWorkbenchPage page : pages) {
+                               IEditorPart[] editors= page.getDirtyEditors();
+                               for (IEditorPart ep : editors) {
+                                       IEditorInput input= ep.getEditorInput();
+                                       if (!inputs.contains(input)) {
+                                               inputs.add(input);
+                                               result.add(ep);
+                                       }
+                               }
+                       }
+               }
+               return result.toArray(new IEditorPart[result.size()]);
+       }
+       /**
+        * Returns an array of all instanciated editors. 
+        */
+       public static IEditorPart[] getInstanciatedEditors() {
+               List<IEditorPart> result= new ArrayList<IEditorPart>(0);
+               IWorkbench workbench= getDefault().getWorkbench();
+               IWorkbenchWindow[] windows= workbench.getWorkbenchWindows();
+               for (IWorkbenchWindow window : windows) {
+                       IWorkbenchPage[] pages= window.getPages();
+                       for (IWorkbenchPage page : pages) {
+                               IEditorReference[] references= page.getEditorReferences();
+                               for (IEditorReference reference : references) {
+                                       IEditorPart editor= reference.getEditor(false);
+                                       if (editor != null)
+                                               result.add(editor);
+                               }
+                       }
+               }
+               return result.toArray(new IEditorPart[result.size()]);
+       }
+
+       /**
+        * Returns the standard display to be used. The method first checks, if
+        * the thread calling this method has an associated display. If so, this
+        * display is returned. Otherwise the method returns the default display.
+        */
+       public static Display getStandardDisplay() {
+               Display display= Display.getCurrent();
+               if (display == null) {
+                       display= Display.getDefault();
+               }
+               return display;         
+       }       
+
+       /**
+        * Creates the CUIplugin standard groups in a context menu.
+        */
+       public static void createStandardGroups(IMenuManager menu) {
+               if (!menu.isEmpty())
+                       return;
+
+               menu.add(new Separator(IContextMenuConstants.GROUP_NEW));
+               menu.add(new GroupMarker(IContextMenuConstants.GROUP_GOTO));
+               menu.add(new Separator(IContextMenuConstants.GROUP_OPEN));
+               menu.add(new GroupMarker(IContextMenuConstants.GROUP_SHOW));
+               menu.add(new Separator(ICommonMenuConstants.GROUP_EDIT));
+               menu.add(new Separator(IContextMenuConstants.GROUP_REORGANIZE));
+               menu.add(new Separator(IContextMenuConstants.GROUP_GENERATE));
+               menu.add(new Separator(IContextMenuConstants.GROUP_SEARCH));
+               menu.add(new Separator(IContextMenuConstants.GROUP_BUILD));
+               menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
+               menu.add(new Separator(IContextMenuConstants.GROUP_VIEWER_SETUP));
+               menu.add(new Separator(IContextMenuConstants.GROUP_PROPERTIES));
+       }
+
+       /**
+        * Returns all C editor text hovers contributed to the workbench.
+        * 
+        * @return an array of CEditorTextHoverDescriptor
+        * 
+        * @noreference This method is not intended to be referenced by clients.
+        */
+       public CEditorTextHoverDescriptor[] getCEditorTextHoverDescriptors() {
+               if (fCEditorTextHoverDescriptors == null) {
+                       fCEditorTextHoverDescriptors= CEditorTextHoverDescriptor.getContributedHovers();
+                       ConfigurationElementSorter sorter= new ConfigurationElementSorter() {
+                               /**
+                                * {@inheritDoc}
+                                */
+                               @Override
+                               public IConfigurationElement getConfigurationElement(Object object) {
+                                       return ((CEditorTextHoverDescriptor)object).getConfigurationElement();
+                               }
+                       };
+                       sorter.sort(fCEditorTextHoverDescriptors);
+               
+                       // The Problem hover has to be the first and the Annotation hover has to be the last one in the CDT UI's hover list
+                       int length= fCEditorTextHoverDescriptors.length;
+                       int first= -1;
+                       int last= length - 1;
+                       int problemHoverIndex= -1;
+                       int annotationHoverIndex= -1;
+                       for (int i= 0; i < length; i++) {
+                               if (!fCEditorTextHoverDescriptors[i].getId().startsWith(PLUGIN_ID)) {
+                                       if (problemHoverIndex == -1 || annotationHoverIndex == -1) {
+                                               continue;
+                                       }
+                                       last= i - 1;
+                                       break;
+                               }
+                               if (first == -1)
+                                       first= i;
+                               
+                               if (fCEditorTextHoverDescriptors[i].getId().equals("org.eclipse.cdt.ui.AnnotationHover")) { //$NON-NLS-1$
+                                       annotationHoverIndex= i;
+                                       continue;
+                               }
+                               if (fCEditorTextHoverDescriptors[i].getId().equals("org.eclipse.cdt.ui.ProblemHover")) { //$NON-NLS-1$
+                                       problemHoverIndex= i;
+                                       continue;
+                               }
+                       }
+       
+                       CEditorTextHoverDescriptor hoverDescriptor= null;
+                       
+                       if (first > -1 && problemHoverIndex > -1 && problemHoverIndex > first) {
+                               // move problem hover to beginning
+                               hoverDescriptor= fCEditorTextHoverDescriptors[problemHoverIndex];
+                               System.arraycopy(fCEditorTextHoverDescriptors, first, fCEditorTextHoverDescriptors, first+1, problemHoverIndex - first);
+                               fCEditorTextHoverDescriptors[first]= hoverDescriptor;
+
+                               // update annotation hover index if needed
+                               if (annotationHoverIndex >= first && annotationHoverIndex < problemHoverIndex)
+                                       annotationHoverIndex++;
+                       }
+                       
+                       if (annotationHoverIndex > -1 && annotationHoverIndex < last) {
+                               // move annotation hover to end
+                               hoverDescriptor= fCEditorTextHoverDescriptors[annotationHoverIndex];
+                               System.arraycopy(fCEditorTextHoverDescriptors, annotationHoverIndex+1, fCEditorTextHoverDescriptors, annotationHoverIndex, last - annotationHoverIndex);
+                               fCEditorTextHoverDescriptors[last]= hoverDescriptor;
+                       }
+
+                       // Move Best Match hover to front
+                       for (int i= 0; i < length; i++) {
+                               if (PreferenceConstants.ID_BESTMATCH_HOVER.equals(fCEditorTextHoverDescriptors[i].getId())) {
+                                       if (i > 0) {
+                                               // move to top
+                                               CEditorTextHoverDescriptor bestMatchHover= fCEditorTextHoverDescriptors[i];
+                                               System.arraycopy(fCEditorTextHoverDescriptors, 0, fCEditorTextHoverDescriptors, 1, i);
+                                               fCEditorTextHoverDescriptors[0]= bestMatchHover;
+                                       }
+                                       break;
+                               }
+                               
+                       }
+               }
+               return fCEditorTextHoverDescriptors;
+       } 
+
+       /**
+        * Resets the C editor text hovers contributed to the workbench.
+        * <p>
+        * This will force a rebuild of the descriptors the next time
+        * a client asks for them.
+        * </p>
+        * 
+        */
+       public void resetCEditorTextHoverDescriptors() {
+               fCEditorTextHoverDescriptors= null;
+       }
+
+       /**
+        * Returns the registry of the extensions to the <code>org.eclipse.cdt.ui.foldingStructureProviders</code>
+        * extension point.
+        * 
+        * @return the registry of contributed <code>ICFoldingStructureProvider</code>
+        * 
+        * @noreference This method is not intended to be referenced by clients.
+        * @since 3.0
+        */
+       public synchronized CFoldingStructureProviderRegistry getFoldingStructureProviderRegistry() {
+               if (fFoldingStructureProviderRegistry == null)
+                       fFoldingStructureProviderRegistry= new CFoldingStructureProviderRegistry();
+               return fFoldingStructureProviderRegistry;
+       }
+
+       /**
+        * Returns the template context type registry for the C plugin.
+        * 
+        * @return the template context type registry for the C plugin
+        * @since 3.0
+        */
+       public ContextTypeRegistry getTemplateContextRegistry() {
+               if (fContextTypeRegistry == null) {
+                       fContextTypeRegistry= new ContributionContextTypeRegistry(EDITOR_ID);
+                       fContextTypeRegistry.addContextType(CContextType.ID);
+                       fContextTypeRegistry.addContextType(CommentContextType.ID);
+                       fContextTypeRegistry.addContextType(DocCommentContextType.ID);
+               }
+               return fContextTypeRegistry;
+       }
+
+       /**
+        * Returns the template store for the C editor templates.
+        * 
+        * @return the template store for the C editor templates
+        * @since 3.0
+        */
+       public TemplateStore getTemplateStore() {
+               if (fTemplateStore == null) {
+                       fTemplateStore = new ContributionTemplateStore(getTemplateContextRegistry(), getPreferenceStore(), CUSTOM_TEMPLATES_KEY);
+                       try {
+                               fTemplateStore.load();
+                       } catch (IOException e) {
+                               log(e);
+                       }
+               }
+               return fTemplateStore;
+       }
+
+       /**
+        * Returns the template context type registry for the code generation
+        * templates.
+        * 
+        * @return the template context type registry for the code generation
+        *         templates
+        * @since 5.0
+        */
+       public ContextTypeRegistry getCodeTemplateContextRegistry() {
+               if (fCodeTemplateContextTypeRegistry == null) {
+                       fCodeTemplateContextTypeRegistry= new ContributionContextTypeRegistry("org.eclipse.cdt.ui.codeTemplates"); //$NON-NLS-1$
+                       
+                       CodeTemplateContextType.registerContextTypes(fCodeTemplateContextTypeRegistry);
+                       FileTemplateContextType.registerContextTypes(fCodeTemplateContextTypeRegistry);
+               }
+
+               return fCodeTemplateContextTypeRegistry;
+       }
+       
+       /**
+        * Returns the template store for the code generation templates.
+        * 
+        * @return the template store for the code generation templates
+        * @since 5.0
+        */
+       public TemplateStore getCodeTemplateStore() {
+               if (fCodeTemplateStore == null) {
+                       IPreferenceStore store= getPreferenceStore();
+                       fCodeTemplateStore= new ContributionTemplateStore(getCodeTemplateContextRegistry(), store, CODE_TEMPLATES_KEY);
+
+                       try {
+                               fCodeTemplateStore.load();
+                       } catch (IOException e) {
+                               log(e);
+                       }
+                       
+                       fCodeTemplateStore.startListeningForPreferenceChanges();
+               }
+               
+               return fCodeTemplateStore;
+       }
+       
+       /**
+        * Returns the AST provider.
+        * 
+        * @return the AST provider
+        * 
+        * @noreference This method is not intended to be referenced by clients.
+        * @since 4.0
+        */
+       public synchronized ASTProvider getASTProvider() {
+               if (fASTProvider == null)
+                       fASTProvider= new ASTProvider();
+               
+               return fASTProvider;
+       }
+               
+       /**
+        * Answers the <code>Shell</code> associated with the active workbench, or 
+        * one of the windows associated with the workbench.
+        */
+       public Shell getShell() {
+               if (getActiveWorkbenchShell() != null) {
+                       return getActiveWorkbenchShell();
+               }
+               IWorkbenchWindow[] windows = getDefault().getWorkbench().getWorkbenchWindows();
+               return windows[0].getShell();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPreferenceInitializer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPreferenceInitializer.java
new file mode 100644 (file)
index 0000000..60d6458
--- /dev/null
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ *  Copyright (c) 2003, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     QNX Software Systems - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui;
+
+import org.eclipse.cdt.internal.ui.cview.CView;
+import org.eclipse.cdt.internal.ui.editor.SemanticHighlightings;
+import org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage;
+import org.eclipse.cdt.internal.ui.preferences.CEditorPreferencePage;
+import org.eclipse.cdt.internal.ui.preferences.CPluginPreferencePage;
+import org.eclipse.cdt.internal.ui.preferences.CodeAssistPreferencePage;
+import org.eclipse.cdt.internal.ui.preferences.WorkInProgressPreferencePage;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
+import org.eclipse.ui.texteditor.AbstractTextEditor;
+
+/**
+ * This class implements the setting of the CUI initial preference store settings.
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class CUIPreferenceInitializer extends AbstractPreferenceInitializer {
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
+        */
+       @Override
+       public void initializeDefaultPreferences() {
+               final IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore();
+
+        PreferenceConstants.initializeDefaultValues(store);
+               CPluginPreferencePage.initDefaults(store);
+               BuildConsolePreferencePage.initDefaults(store);
+               CView.initDefaults(store);
+               CEditorPreferencePage.initDefaults(store);
+               CodeAssistPreferencePage.initDefaults(store);
+               SemanticHighlightings.initDefaults(store);
+               WorkInProgressPreferencePage.initDefaults(store);
+               
+               // We need to do this remove any keys that might have been
+               // in the CUIPlugin store prior to the move of the CEditor setting
+               // All of those settings are now in the workbench "All TextEditor" preference Page.
+               // Later we should remove this calls, after CDT-3.0
+               EditorsUI.useAnnotationsPreferencePage(store);
+        EditorsUI.useQuickDiffPreferencePage(store);
+               useTextEditorPreferencePage(store);
+       }
+
+       /*
+        * Reset to default, those constants that are no longer maintained in CUIPlugin store.
+        */
+       public static void useTextEditorPreferencePage(IPreferenceStore store) {
+               store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE);
+               store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR);
+
+               store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER);    
+               store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR);
+               store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER);
+
+               store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
+
+               store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN);
+               store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR);
+               store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN);
+               
+               store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_USE_CUSTOM_CARETS);
+               store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WIDE_CARET);
+               
+               store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR);
+               store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR);
+               store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR);
+               store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR);
+               store.setToDefault(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND);
+               store.setToDefault(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
+               store.setToDefault(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT);
+               store.setToDefault(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT);
+
+               store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE);
+               store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SMART_HOME_END);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CodeGeneration.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CodeGeneration.java
new file mode 100644 (file)
index 0000000..10bdb30
--- /dev/null
@@ -0,0 +1,483 @@
+/*******************************************************************************
+ *  Copyright (c) 2001, 2011 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     Rational Software - initial implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.ui;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.templates.Template;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+import org.eclipse.cdt.internal.corext.codemanipulation.StubUtility;
+
+/**
+ * Class that offers access to the templates contained in the 'Code Templates' preference page.
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ * @since 2.1
+ */
+public class CodeGeneration {
+
+       private CodeGeneration() {
+       }
+
+       /**
+        * Returns the content for a new header file using the default 'header file' code template.
+        * @param tu The translation unit to create the source for. The translation unit does not need
+        *              to exist.
+        * @param lineDelimiter The line delimiter to be used.
+        * @return Returns the new content or <code>null</code> if the template is undefined or empty.
+        * @throws CoreException
+        * @since 5.3
+        */
+       public static String getHeaderFileContent(Template template, ITranslationUnit tu,
+                       String lineDelimiter) throws CoreException {    
+               return getHeaderFileContent(template, tu, null, null, null, null, null, null, null,
+                               lineDelimiter);
+       }
+
+       /**
+        * Returns the content for a new header file using the default 'header file' code template.
+        * @param tu The translation unit to create the source for. The translation unit does not need
+        *              to exist.
+        * @param typeComment The comment for the type to created. Used when the code template contains
+        *              a ${typecomment} variable. Can be <code>null</code> if no comment should be added.
+        * @param typeContent The code of the type, including type declaration and body.
+        * @param lineDelimiter The line delimiter to be used.
+        * @return Returns the new content or <code>null</code> if the template is undefined or empty.
+        * @throws CoreException
+        */
+       public static String getHeaderFileContent(ITranslationUnit tu, String typeComment,
+                       String typeContent, String lineDelimiter) throws CoreException {        
+               return getHeaderFileContent(tu, null, null, null, null, typeComment, typeContent, null,
+                               lineDelimiter);
+       }
+
+       /**
+        * Returns the content for a new header file using the default 'header file' code template.
+        * @param template  The file template to use or <code>null</code> for the default template
+        * @param tu The translation unit to create the source for. The translation unit does not need
+        *              to exist.
+        * @param typeComment The comment for the type to created. Used when the code template contains
+        *              a ${typecomment} variable. Can be <code>null</code> if no comment should be added.
+        * @param typeContent The code of the type, including type declaration and body.
+        * @param lineDelimiter The line delimiter to be used.
+        * @return Returns the new content or <code>null</code> if the template is undefined or empty.
+        * @throws CoreException
+        */
+       public static String getHeaderFileContent(Template template, ITranslationUnit tu,
+                       String typeComment, String typeContent, String lineDelimiter) throws CoreException {    
+               return getHeaderFileContent(template, tu, null, null, null, null, typeComment, typeContent,
+                               null, lineDelimiter);
+       }
+
+       /**
+        * Returns the content for a new header file using the default 'header file' code template.
+        * @param tu The translation unit to create the source for. The translation unit does not need
+        *              to exist.
+        * @param includes Include statements, or {@code null} if there are no includes.
+        * @param namespaceBegin Beginning of namespace declarations, or {@code null} if there is no
+        *              namespace.
+        * @param namespaceEnd End of namespace declarations, or {@code null} if there is no
+        *              namespace.
+        * @param namespaceName Fully qualified namespace name, or {@code null} if there is no
+        *              namespace.
+        * @param typeComment The comment for the type to created. Used when the code template contains
+        *              a ${typecomment} variable. Can be <code>null</code> if no comment should be added.
+        * @param typeContent The code of the type, including type declaration and body.
+        * @param typeName The name of the type.
+        * @param lineDelimiter The line delimiter to be used.
+        * @return Returns the new content or <code>null</code> if the template is undefined or empty.
+        * @throws CoreException
+        * @since 5.3
+        */
+       public static String getHeaderFileContent(ITranslationUnit tu, String includes,
+                       String namespaceBegin, String namespaceEnd, String namespaceName, String typeComment,
+                       String typeContent, String typeName, String lineDelimiter) throws CoreException {       
+               return StubUtility.getHeaderFileContent(tu, typeContent,
+                               getFileComment(tu, lineDelimiter), includes, namespaceBegin, namespaceEnd,
+                               namespaceName, typeComment, typeName, lineDelimiter);
+       }
+
+       /**
+        * Returns the content for a new header file using the default 'header file' code template.
+        * @param template  The file template to use or <code>null</code> for the default template
+        * @param tu The translation unit to create the source for. The translation unit does not need
+        *              to exist.
+        * @param includes Include statements, or {@code null} if there are no includes.
+        * @param namespaceBegin Beginning of namespace declarations, or {@code null} if there is no
+        *              namespace.
+        * @param namespaceEnd End of namespace declarations, or {@code null} if there is no
+        *              namespace.
+        * @param namespaceName Fully qualified namespace name, or {@code null} if there is no
+        *              namespace.
+        * @param typeComment The comment for the type to created. Used when the code template contains
+        *              a ${typecomment} variable. Can be <code>null</code> if no comment should be added.
+        * @param typeContent The code of the type, including type declaration and body.
+        * @param typeName The name of the type.
+        * @param lineDelimiter The line delimiter to be used.
+        * @return Returns the new content or <code>null</code> if the template is undefined or empty.
+        * @throws CoreException
+        * @since 5.3
+        */
+       public static String getHeaderFileContent(Template template, ITranslationUnit tu,
+                       String includes, String namespaceBegin, String namespaceEnd, String namespaceName,
+                       String typeComment, String typeContent, String typeName, String lineDelimiter)
+                       throws CoreException {  
+               return StubUtility.getHeaderFileContent(template, tu, typeContent,
+                               getFileComment(tu, lineDelimiter), includes, namespaceBegin, namespaceEnd,
+                               namespaceName, typeComment, typeName, lineDelimiter);
+       }
+
+       /**
+        * Returns the content for a new translation unit using the 'source file' code template.
+        * @param tu The translation unit to create the source for. The translation unit does not need
+        *              to exist.
+        * @param typeComment The comment for the type to created. Used when the code template contains
+        *              a ${typecomment} variable. Can be <code>null</code> if no comment should be added.
+        * @param typeContent The code of the type, including type declaration and body.
+        * @param lineDelimiter The line delimiter to be used.
+        * @return Returns the new content or <code>null</code> if the template is undefined or empty.
+        * @throws CoreException
+        */
+       public static String getBodyFileContent(ITranslationUnit tu, String typeComment,
+                       String typeContent, String lineDelimiter) throws CoreException {        
+               return getBodyFileContent(tu, typeContent, null, null, null, null, typeComment, null,
+                               lineDelimiter);
+       }
+
+       /**
+        * Returns the content for a new translation unit using the 'source file' code template.
+        * @param template  The file template to use or <code>null</code> for the default template
+        * @param tu The translation unit to create the source for. The translation unit does not need
+        *              to exist.
+        * @param typeComment The comment for the type to created. Used when the code template contains
+        *              a ${typecomment} variable. Can be <code>null</code> if no comment should be added.
+        * @param typeContent The code of the type, including type declaration and body.
+        * @param lineDelimiter The line delimiter to be used.
+        * @return Returns the new content or <code>null</code> if the template is undefined or empty.
+        * @throws CoreException
+        */
+       public static String getBodyFileContent(Template template, ITranslationUnit tu,
+                       String typeComment, String typeContent, String lineDelimiter) throws CoreException {    
+               return getBodyFileContent(template, tu, typeContent, null, null, null, null, typeComment,
+                               null, lineDelimiter);
+       }
+
+       /**
+        * Returns the content for a new source file using the default 'source file' code template.
+        * @param tu The translation unit to create the source for. The translation unit does not need
+        *              to exist.
+        * @param includes Include statements, or {@code null} if there are no includes.
+        * @param namespaceBegin Beginning of namespace declarations, or {@code null} if there is no
+        *              namespace.
+        * @param namespaceEnd End of namespace declarations, or {@code null} if there is no
+        *              namespace.
+        * @param namespaceName Fully qualified namespace name, or {@code null} if there is no
+        *              namespace.
+        * @param typeComment The comment for the type to created. Used when the code template contains
+        *              a ${typecomment} variable. Can be <code>null</code> if no comment should be added.
+        * @param typeContent The code of the type, including type declaration and body.
+        * @param typeName The name of the type.
+        * @param lineDelimiter The line delimiter to be used.
+        * @return Returns the new content or <code>null</code> if the template is undefined or empty.
+        * @throws CoreException
+        * @since 5.3
+        */
+       public static String getBodyFileContent(ITranslationUnit tu,
+                       String includes, String namespaceBegin, String namespaceEnd, String namespaceName,
+                       String typeComment, String typeContent, String typeName, String lineDelimiter)
+                       throws CoreException {  
+               return StubUtility.getBodyFileContent(tu, typeContent, getFileComment(tu, lineDelimiter),
+                               includes, namespaceBegin, namespaceEnd, namespaceName, typeComment, typeName,
+                               lineDelimiter);
+       }
+
+       /**
+        * Returns the content for a new source file using the default 'source file' code template.
+        * @param template  The file template to use or <code>null</code> for the default template
+        * @param tu The translation unit to create the source for. The translation unit does not need
+        *              to exist.
+        * @param includes Include statements, or {@code null} if there are no includes.
+        * @param namespaceBegin Beginning of namespace declarations, or {@code null} if there is no
+        *              namespace.
+        * @param namespaceEnd End of namespace declarations, or {@code null} if there is no
+        *              namespace.
+        * @param namespaceName Fully qualified namespace name, or {@code null} if there is no
+        *              namespace.
+        * @param typeComment The comment for the type to created. Used when the code template contains
+        *              a ${typecomment} variable. Can be <code>null</code> if no comment should be added.
+        * @param typeContent The code of the type, including type declaration and body.
+        * @param typeName The name of the type.
+        * @param lineDelimiter The line delimiter to be used.
+        * @return Returns the new content or <code>null</code> if the template is undefined or empty.
+        * @throws CoreException
+        * @since 5.3
+        */
+       public static String getBodyFileContent(Template template, ITranslationUnit tu,
+                       String includes, String namespaceBegin, String namespaceEnd, String namespaceName,
+                       String typeComment, String typeContent, String typeName, String lineDelimiter)
+                       throws CoreException {  
+               return StubUtility.getBodyFileContent(template, tu, typeContent,
+                               getFileComment(tu, lineDelimiter), includes, namespaceBegin, namespaceEnd,
+                               namespaceName, typeComment, typeName, lineDelimiter);
+       }
+
+       /**
+        * Returns the content for a new translation unit using the 'test file' code template.
+        * @param tu The translation unit to create the source for. The translation unit does not need
+        *              to exist.
+        * @param includes Include statements, or {@code null} if there are no includes.
+        * @param namespaceBegin Beginning of namespace declarations, or {@code null} if there is no
+        *              namespace.
+        * @param namespaceEnd End of namespace declarations, or {@code null} if there is no
+        *              namespace.
+        * @param namespaceName Fully qualified namespace name, or {@code null} if there is no
+        *              namespace.
+        * @param testCases The test cases code.
+        * @param typeName The name of the type.
+        * @param lineDelimiter The line delimiter to be used.
+        * @return Returns the new content or <code>null</code> if the template is undefined or empty.
+        * @throws CoreException
+        * @since 5.3
+        */
+       public static String getTestFileContent(ITranslationUnit tu,
+                       String includes, String namespaceBegin, String namespaceEnd, String namespaceName,
+                       String testCases, String typeName, String lineDelimiter) throws CoreException { 
+               return StubUtility.getTestFileContent(tu, testCases, getFileComment(tu, lineDelimiter),
+                               includes, namespaceBegin, namespaceEnd, namespaceName, typeName, lineDelimiter);
+       }
+
+       /**
+        * Returns the content of the body for a method using the method body template.
+        * <code>null</code> is returned if the template is empty.
+        * <p>The returned string is unformatted and not indented.
+        * 
+        * @param tu The translation unit to which the method belongs. The translation unit does not need to exist.
+        * @param typeName Name of the type to which the method belongs.
+        * @param methodName Name of the method.
+        * @param bodyStatement The code to be entered at the place of the variable ${body_statement}. 
+        * @param lineDelimiter The line delimiter to be used.
+        * @return Returns the constructed body content or <code>null</code> if
+        * the comment code template is empty. The returned string is unformatted and and has no indent (formatting required).
+        * @throws CoreException Thrown when the evaluation of the code template fails.
+        */     
+       public static String getMethodBodyContent(ITranslationUnit tu, String typeName,
+                       String methodName, String bodyStatement, String lineDelimiter) throws CoreException {
+               return StubUtility.getMethodBodyContent(tu.getCProject(), typeName, methodName,
+                               bodyStatement, lineDelimiter);
+       }
+
+       /**
+        * Returns the content of the body for a constructor using the constructor body template.
+        * <code>null</code> is returned if the template is empty.
+        * <p>The returned string is unformatted and not indented.
+        * 
+        * @param tu The translation unit to which the method belongs. The translation unit
+        *              does not need to exist.
+        * @param typeName Name of the type to which the constructor belongs.
+        * @param bodyStatement The code to be entered at the place of the variable ${body_statement}. 
+        * @param lineDelimiter The line delimiter to be used.
+        * @return Returns the constructed body content or <code>null</code> if the comment code
+        *              template is empty. The returned string is unformatted and and has no indent
+        *              (formatting required).
+        * @throws CoreException Thrown when the evaluation of the code template fails.
+        */     
+       public static String getConstructorBodyContent(ITranslationUnit tu, String typeName,
+                       String bodyStatement, String lineDelimiter) throws CoreException {
+               return StubUtility.getConstructorBodyContent(tu.getCProject(), typeName, bodyStatement,
+                               lineDelimiter);
+       }
+
+       /**
+        * Returns the content of the body for a destructor using the destructor body template.
+        * <code>null</code> is returned if the template is empty.
+        * <p>The returned string is unformatted and not indented.
+        * 
+        * @param tu The translation unit to which the method belongs. The translation unit
+        *              does not need to exist.
+        * @param typeName Name of the type to which the constructor belongs.
+        * @param bodyStatement The code to be entered at the place of the variable ${body_statement}. 
+        * @param lineDelimiter The line delimiter to be used.
+        * @return Returns the constructed body content or <code>null</code> if the comment code
+        *              template is empty. The returned string is unformatted and and has no indent
+        *              (formatting required).
+        * @throws CoreException Thrown when the evaluation of the code template fails.
+        */     
+       public static String getDestructorBodyContent(ITranslationUnit tu, String typeName,
+                       String bodyStatement, String lineDelimiter) throws CoreException {
+               return StubUtility.getDestructorBodyContent(tu.getCProject(), typeName, bodyStatement,
+                               lineDelimiter);
+       }
+
+       /**
+        * Returns the content of the class definition body using the class body template.
+        * <code>null</code> is returned if the template is empty.
+        * <p>The returned string is unformatted and not indented.
+        * 
+        * @param tu The translation unit to which the method belongs. The translation unit
+        *              does not need to exist.
+        * @param className The name of the class.
+        * @param classMemberDeclarations The code to be entered at the place of the variable
+        *              ${declarations}. 
+        * @param lineDelimiter The line delimiter to be used.
+        * @return Returns the constructed class body content or <code>null</code> if
+        *              the class body code template is empty. The returned string is unformatted and
+        *              has no indent (formatting required).
+        * @throws CoreException Thrown when the evaluation of the code template fails.
+        * @since 5.3
+        */     
+       public static String getClassBodyContent(ITranslationUnit tu, String className,
+                       String classMemberDeclarations, String lineDelimiter)
+                       throws CoreException {
+               return StubUtility.getClassBodyContent(tu.getCProject(), className, classMemberDeclarations,
+                               lineDelimiter);
+       }
+
+       /**
+        * Returns the content of the beginning of a namespace declaration using the corresponding
+        * template. <code>null</code> is returned if the template is empty.
+        * <p>The returned string is unformatted and not indented.
+        * 
+        * @param tu The translation unit to which the method belongs. The translation unit
+        *              does not need to exist.
+        * @param namespaceName The name of the namespace.
+        * @param lineDelimiter The line delimiter to be used.
+        * @return Returns the constructed beginning of a namespace declaration,or <code>null</code> if
+        *              the namespace code template is empty. The returned string is unformatted and has no
+        *              indent (formatting required).
+        * @throws CoreException Thrown when the evaluation of the code template fails.
+        * @since 5.3
+        */     
+       public static String getNamespaceBeginContent(ITranslationUnit tu, String namespaceName,
+                       String lineDelimiter) throws CoreException {
+               return StubUtility.getNamespaceBeginContent(tu.getCProject(), namespaceName, lineDelimiter);
+       }
+
+       /**
+        * Returns the content of the end of a namespace declaration using the corresponding
+        * template. <code>null</code> is returned if the template is empty.
+        * <p>The returned string is unformatted and not indented.
+        * 
+        * @param tu The translation unit to which the method belongs. The translation unit
+        *              does not need to exist.
+        * @param namespaceName The name of the namespace.
+        * @param lineDelimiter The line delimiter to be used.
+        * @return Returns the constructed end of a namespace declaration,or <code>null</code> if
+        *              the namespace code template is empty. The returned string is unformatted and has no
+        *              indent (formatting required).
+        * @throws CoreException Thrown when the evaluation of the code template fails.
+        * @since 5.3
+        */     
+       public static String getNamespaceEndContent(ITranslationUnit tu, String namespaceName,
+                       String lineDelimiter) throws CoreException {
+               return StubUtility.getNamespaceEndContent(tu.getCProject(), namespaceName, lineDelimiter);
+       }
+
+       /**
+        * Returns the content for a new file comment using the 'file comment' code template.
+        * The returned content is unformatted and is not indented.
+        * @param tu The translation unit to add the comment to. The translation unit does not need
+        *              to exist.
+        * @param lineDelimiter The line delimiter to be used.
+        * @return Returns the new content or <code>null</code> if the code template is undefined
+        *              or empty. The returned content is unformatted and is not indented.
+        * @throws CoreException Thrown when the evaluation of the code template fails.
+        * @since 5.0
+        */     
+       public static String getFileComment(ITranslationUnit tu, String lineDelimiter)
+                       throws CoreException {
+               return StubUtility.getFileComment(tu, lineDelimiter);
+       }
+       
+       /**
+        * Returns the content for a new type comment using the 'typecomment' code template.
+        * The returned content is unformatted and is not indented.
+        * @param tu The translation unit where the type is contained. The translation unit
+        *              does not need to exist.
+        * @param typeQualifiedName The name of the type to which the comment is added. For inner types
+        *              the name must be qualified and include the outer types names (dot separated). 
+        * @param lineDelimiter The line delimiter to be used.
+        * @return Returns the new content or <code>null</code> if the code template is undefined
+        *              or empty. The returned content is unformatted and is not indented.
+        * @throws CoreException
+        */     
+       public static String getClassComment(ITranslationUnit tu, String typeQualifiedName,
+                       String lineDelimiter) throws CoreException {
+               return StubUtility.getClassComment(tu, typeQualifiedName, lineDelimiter);
+       }
+
+       /**
+        * Returns the comment for a method using the method comment code template.
+        * <code>null</code> is returned if the template is empty.
+        * <p>The returned string is unformatted and not indented.
+        * 
+        * @param tu The translation unit to which the method belongs. The translation unit
+        *              does not need to exist.
+        * @param declaringTypeName Name of the type to which the method belongs.
+        * @param methodName Name of the method.
+        * @param paramNames Names of the parameters for the method.
+        * @param excTypeSig Thrown exceptions.
+        * @param retTypeSig Return type.
+        * @param lineDelimiter The line delimiter to be used.
+        * @return Returns the constructed comment or <code>null</code> if the comment code template
+        *              is empty. The returned content is unformatted and not indented (formatting required).
+        * @throws CoreException Thrown when the evaluation of the code template fails.
+        */
+       public static String getMethodComment(ITranslationUnit tu, String declaringTypeName,
+                       String methodName, String[] paramNames, String[] excTypeSig, String retTypeSig,
+                       String lineDelimiter) throws CoreException {
+               return StubUtility.getMethodComment(tu, declaringTypeName, methodName, paramNames,
+                               excTypeSig, retTypeSig, lineDelimiter);
+       }
+
+       /**
+        * Returns the comment for a constructor using the constructor comment code template.
+        * <code>null</code> is returned if the template is empty.
+        * <p>The returned string is unformatted and not indented.
+        * 
+        * @param tu The translation unit to which the method belongs. The translation unit
+        *              does not need to exist.
+        * @param declaringTypeName Name of the type to which the method belongs.
+        * @param paramNames Names of the parameters for the method.
+        * @param excTypeSig Thrown exceptions.
+        * @param lineDelimiter The line delimiter to be used.
+        * @return Returns the constructed comment or <code>null</code> if the comment code template
+        *              is empty. The returned content is unformatted and not indented (formatting required).
+        * @throws CoreException Thrown when the evaluation of the code template fails.
+        */
+       public static String getConstructorComment(ITranslationUnit tu, String declaringTypeName,
+                       String[] paramNames, String[] excTypeSig, String lineDelimiter) throws CoreException {
+               return StubUtility.getConstructorComment(tu, declaringTypeName, paramNames, excTypeSig,
+                               lineDelimiter);
+       }
+
+       /**
+        * Returns the comment for a destructor using the destructor comment code template.
+        * <code>null</code> is returned if the template is empty.
+        * <p>The returned string is unformatted and not indented.
+        * 
+        * @param tu The translation unit to which the method belongs. The translation unit
+        *              does not need to exist.
+        * @param declaringTypeName Name of the type to which the method belongs.
+        * @param excTypeSig Thrown exceptions.
+        * @param lineDelimiter The line delimiter to be used.
+        * @return Returns the constructed comment or <code>null</code> if the comment code template
+        *              is empty. The returned content is unformatted and not indented (formatting required).
+        * @throws CoreException Thrown when the evaluation of the code template fails.
+        */
+       public static String getDestructorComment(ITranslationUnit tu, String declaringTypeName,
+                       String[] excTypeSig, String lineDelimiter) throws CoreException {
+               return StubUtility.getDestructorComment(tu, declaringTypeName, excTypeSig, lineDelimiter);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/FunctionPrototypeSummary.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/FunctionPrototypeSummary.java
new file mode 100644 (file)
index 0000000..1a7d40c
--- /dev/null
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui;
+
+/**
+ * This class is a helper class which takes care of implementing some of the 
+ * function prototype parsing and stripping.
+ */
+public class FunctionPrototypeSummary implements IFunctionSummary.IFunctionPrototypeSummary {
+       String fname;
+       String freturn;
+       String farguments;
+               
+       /**
+        * Create a function prototype summary based on a prototype string.
+        * @param proto The string describing the prototype which is properly 
+        * formed with following format -- returntype function(arguments)
+        * The following formats will be converted as follows:
+        * function(arguments) --> function(arguments) //constructors!
+        * returntype function --> returntype function()
+        * function            --> void function() 
+        */
+       public FunctionPrototypeSummary(String proto) {
+               int leftbracket = proto.indexOf('(');
+               int rightbracket = proto.lastIndexOf(')');
+               
+               //If there are brackets missing, then assume void parameters
+               if(leftbracket == -1 || rightbracket == -1) {
+                       if(leftbracket != -1) {
+                               proto = proto.substring(leftbracket) + ")"; //$NON-NLS-1$
+                       } else if(rightbracket != -1) {
+                               proto = proto.substring(rightbracket - 1) + "()";                                //$NON-NLS-1$
+                       } else {
+                               proto = proto + "()"; //$NON-NLS-1$
+                       }
+               
+                       leftbracket = proto.indexOf('(');
+                       rightbracket = proto.lastIndexOf(')');
+               } 
+               
+               farguments = proto.substring(leftbracket + 1, rightbracket);
+                       
+               // fix for bug #44359
+               if(farguments.equals("void")) //$NON-NLS-1$
+                       farguments = ""; //$NON-NLS-1$
+               
+               int nameend = leftbracket - 1;
+               while(proto.charAt(nameend) == ' ') {
+                       nameend--;
+               }
+
+               int namestart = nameend;
+               while(namestart > 0 && proto.charAt(namestart) != ' ') {
+                       namestart--;
+               }
+
+               fname = proto.substring(namestart, nameend + 1).trim();
+                       
+               if(namestart == 0) {
+                       //Constructors are like this, don't stick a type on them.
+                       freturn = ""; //$NON-NLS-1$
+               } else {
+                       freturn = proto.substring(0, namestart).trim();
+               }
+       }
+
+       public String getName() {
+               return fname;
+       }
+
+       public String getReturnType() {
+               return freturn;
+       }
+               
+       public String getArguments() {
+               return farguments;
+       }
+               
+       public String getPrototypeString(boolean namefirst) {
+               return getPrototypeString(namefirst, true);
+       }
+       
+       public String getPrototypeString(boolean namefirst, boolean appendReturnType) {
+               StringBuilder buffer = new StringBuilder();
+               if((!namefirst) && (appendReturnType)) {
+                       buffer.append(getReturnType());
+                       buffer.append(" "); //$NON-NLS-1$
+               }
+               buffer.append(getName());
+               buffer.append("("); //$NON-NLS-1$
+               if(getArguments() != null) {
+                       buffer.append(getArguments());
+               }
+               buffer.append(")"); //$NON-NLS-1$
+               if((namefirst) && (appendReturnType) && getReturnType().length() > 0 ) {
+                       buffer.append(" "); //$NON-NLS-1$
+                       buffer.append(getReturnType());
+               }
+               buffer.append(";"); //$NON-NLS-1$
+               return buffer.toString();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IBuildConsoleEvent.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IBuildConsoleEvent.java
new file mode 100644 (file)
index 0000000..de74ee5
--- /dev/null
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui;
+
+import org.eclipse.core.resources.IProject;
+
+/**
+ * A build console event.
+ * 
+ * @see IBuildConsoleListener
+ * 
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface IBuildConsoleEvent {
+       final static int CONSOLE_START = 1;
+       final static int CONSOLE_CLOSE = 2;
+       
+       IProject getProject();
+       int getType();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IBuildConsoleListener.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IBuildConsoleListener.java
new file mode 100644 (file)
index 0000000..d9ddfdf
--- /dev/null
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui;
+
+/**
+ * A listener to build console events.
+ * <p>
+ * Clients may implement this interface.
+ * </p>
+ * 
+ * @see IBuildConsoleEvent
+ */
+public interface IBuildConsoleListener {
+       void consoleChange(IBuildConsoleEvent event);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IBuildConsoleManager.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IBuildConsoleManager.java
new file mode 100644 (file)
index 0000000..d9f4fcc
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ * Alex Collins (Broadcom Corp.) - Global console
+ *******************************************************************************/
+package org.eclipse.cdt.ui;
+
+import org.eclipse.cdt.core.resources.IConsole;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.text.IDocument;
+
+/**
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface IBuildConsoleManager {
+       /**
+        * @return the console to which build output should be printed.
+        *         This may be backed by two console documents: one for the Project
+        *         and one Global
+        */
+       IConsole getConsole(IProject project);
+       /**
+        * @return the console associated with the specified project
+        * @since 5.3
+        */
+       IConsole getProjectConsole(IProject project);
+       /**
+        * @param project
+        * @return IDocument backing the console for the given project
+        */
+       IDocument getConsoleDocument(IProject project);
+       IProject getLastBuiltProject();
+       void addConsoleListener(IBuildConsoleListener listener);
+       void removeConsoleListener(IBuildConsoleListener listener);
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICDTConstants.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICDTConstants.java
new file mode 100644 (file)
index 0000000..2460dfc
--- /dev/null
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui;
+
+
+/**
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface ICDTConstants 
+{
+       // CDT Extension Points
+       public static final String EP_TEXT_HOVERS = "textHovers"; //$NON-NLS-1$
+
+       // Persistance tags.
+       public static final String TAG_TEXT_HOVER = "textHover"; //$NON-NLS-1$
+
+       // Atributes
+       public static final String ATT_CLASS = "class"; //$NON-NLS-1$
+       public static final String ATT_ID = "id"; //$NON-NLS-1$
+       public static final String ATT_NAME = "name"; //$NON-NLS-1$
+       public static final String ATT_PERSPECTIVE = "perspective"; //$NON-NLS-1$
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpBook.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpBook.java
new file mode 100644 (file)
index 0000000..2fcb4a0
--- /dev/null
@@ -0,0 +1,39 @@
+/**********************************************************************
+ * Copyright (c) 2004, 2008 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *     Intel Corporation - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.cdt.ui;
+
+/**
+ * Represents the help book, that is a set of articles on some topic.
+ * Such as "C functions", "Qt library", etc., provided by help provider.
+ * <p>
+ * Clients may implement this interface.
+ * </p>
+ * @see ICHelpProvider
+ * @since 2.1
+ */
+public interface ICHelpBook {
+       public static final int HELP_TYPE_C = 1;
+       public static final int HELP_TYPE_CPP = 2;
+       public static final int HELP_TYPE_ASM = 3;
+
+       /**
+        * returns the tytle of the Help Book
+        * @return String representing the HelpBook tytle
+        */
+       String getTitle();
+       
+       /**
+        * gets the type of Help provided with this book that might be ine of ICHelpBook.HELP_TYPE_XXX
+        * @return one of ICHelpBook.HELP_TYPE_XXX representing the type of Provided help
+        */
+       int getCHelpType();
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpProvider.java
new file mode 100644 (file)
index 0000000..65ea9e2
--- /dev/null
@@ -0,0 +1,62 @@
+/**********************************************************************
+ * Copyright (c) 2004, 2009 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *     Intel Corporation - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.cdt.ui;
+
+import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
+
+/**
+ * Represents a C/C++ help provider. This interface need to be implemented by
+ * contributors to extension point "org.eclipse.cdt.ui.CHelpProvider".
+ * <p>
+ * Clients may implement this interface.
+ * </p>
+ * 
+ * @since 2.1
+ */
+public interface ICHelpProvider {
+
+       /**
+        * Initialize the completion contributor class
+        */
+       void initialize();
+
+       /**
+        * Get available help books
+        * @return The <code>ICHelpBook[]</code> array of available help books
+        */
+       ICHelpBook[] getCHelpBooks();
+       
+       /**
+        * get the matching function of a given name
+        * 
+        * @param helpBooks the array of help books to be searched for help
+        * @param name the function name for which help is needed
+        * @return the IFunctionSummary interface
+        */
+       IFunctionSummary getFunctionInfo(ICHelpInvocationContext context, ICHelpBook[] helpBooks, String name);
+       
+       /**
+        * Get array of matching functions starting with this prefix
+        * 
+        * @param helpBooks the array of help books to be searched for help
+        * @param prefix the function name prefix
+        * @return the IFunctionSummary[] array
+        */
+       IFunctionSummary[] getMatchingFunctions(ICHelpInvocationContext context, ICHelpBook[] helpBooks, String prefix);
+
+       /**
+        * 
+        * @param helpBooks the array of help books to be searched for help
+        * @param name the C/C++ element name for which help is needed
+        * @return the ICHelpResourceDescriptor[] array representing found help resources
+        */
+       ICHelpResourceDescriptor[] getHelpResources(ICHelpInvocationContext context, ICHelpBook[] helpBooks, String name);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpResourceDescriptor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ICHelpResourceDescriptor.java
new file mode 100644 (file)
index 0000000..69169e3
--- /dev/null
@@ -0,0 +1,39 @@
+/**********************************************************************
+ * Copyright (c) 2004, 2008 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *     Intel Corporation - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.cdt.ui;
+
+import org.eclipse.help.IHelpResource;
+
+/**
+ * This interface represents Help Resources found in the certain Help Book 
+ * provided by certain CHelpProvider
+ * <p>
+ * Clients may implement this interface.
+ * </p>
+ * @see ICHelpProvider
+ * @since 2.1
+ */
+public interface ICHelpResourceDescriptor {
+       /**
+        * represents the Help Book, where help resources represented by getHelpResources()
+        * method were found
+        * @return ICHelpBook interface representing the help book where help was found 
+        */
+       ICHelpBook getCHelpBook();
+       
+       /**
+        * gets the array of help resources found in the HelpBook represented
+        * by getCHelpBook() method
+        * @return the IHelpResource[] array
+        */
+       IHelpResource[] getHelpResources();
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IEditorInputDelegate.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IEditorInputDelegate.java
new file mode 100644 (file)
index 0000000..bcbc068
--- /dev/null
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui;
+
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.ui.IEditorInput;
+
+/**
+ * This interface allows to create flexible editor inputs.
+ * 
+ * @since May 21, 2003
+ * @deprecated Not supported anymore.
+ */
+@Deprecated
+public interface IEditorInputDelegate extends IEditorInput {
+       /**
+        * Returns the editor input delegate for this editor input.
+        * 
+        * @return editor input delegate
+        */
+       IEditorInput getDelegate();
+
+       /**
+        * Returns the storage associated with this editor input.
+        * 
+        * @return stirage associated with this editor input
+        * @throws CoreException on failure. Reasons include:
+        */
+       IStorage getStorage() throws CoreException;
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IFunctionSummary.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IFunctionSummary.java
new file mode 100644 (file)
index 0000000..5fcb40d
--- /dev/null
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui;
+
+
+/**
+ * A function summary provided by an {@link ICHelpProvider}.
+ * <p>
+ * Clients may implement this interface.
+ * </p>
+ * @see ICHelpProvider
+ */
+public interface IFunctionSummary {
+       
+       /**
+        * <p>
+        * Clients may implement this interface.
+        * </p>
+        */
+       public interface IFunctionPrototypeSummary {
+               /**
+                * Get the name of the function.  This should be the
+                * same as for IFunctionSummary.
+                * ie "int main(int argc, char **argv)" --> "main"
+                * @return The name of the function without any additional
+                * information.
+                */
+               public String getName();
+                               
+               /**
+                * Get the return type of the function.
+                * ie "int main(int argc, char **argv)" --> "int"
+                * @return A string containing the return type of the 
+                * function.
+                */             
+               public String getReturnType();
+               
+               /**
+                * Get the arguments of the function.
+                * ie "int main(int argc, char **argv)" --> "int argc, char **argv"
+                * @return A string containing the arguments of the 
+                * function, or null if the function has no arguments.
+                */
+               public String getArguments();
+
+               /**
+                * Get a nice user defined string.  The format of
+                * which depends on the variable namefirst
+                * namefirst == true: main(int argc, char **argv) int
+                * namefirst == false: int main(int argc, char **argv);
+                */
+               public String getPrototypeString(boolean namefirst);
+       }
+       
+       /**
+        * Gets the name of the function.  This is the simple
+        * name without any additional return or argument information.
+        * The function "int main(int argc, char **argv)" would 
+        * return "main"
+        * @return The name of the function without any additional
+        * information
+        */
+       public String getName();
+
+       /**
+        * Get the full namespace qualifier for this function 
+        * (generally C++ only)
+        * @return The string of the fully qualified namespace for
+        * this function, or null if the namespace is not known.
+        */
+       public String getNamespace();
+
+       /**
+        * Gets the description of the function.  This string can be
+        * either text or HTML coded and is displayed as part of the
+        * hover help and as the context proposal information.
+        * @return A description for this function, or null if no 
+        * description is available.
+        */
+       public String getDescription();
+       
+       /**
+        * Gets the prototype description for this function. 
+        * @return The IFunctionPrototypeSummary describing the 
+        * prototype for this function 
+        */
+       public IFunctionPrototypeSummary getPrototype();
+               
+       /**
+        * Get headers required by this function
+        * @return A list of IRequiredInclude definitions, or null if no
+        * include definitions are available.
+        */
+       public IRequiredInclude[] getIncludes();
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ILanguageUI.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/ILanguageUI.java
new file mode 100644 (file)
index 0000000..12dcade
--- /dev/null
@@ -0,0 +1,33 @@
+/**********************************************************************
+ * Copyright (c) 2006, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *     Doug Schaefer (QNX Software Systems) - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.ui;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.text.rules.RuleBasedScanner;
+
+/**
+ * Adapter interface to {@link org.eclipse.cdt.core.model.ILanguage ILanguage} for language extensions to
+ * provide a custom code scanner implementation.
+ * <p>
+ * Clients may implement this interface.
+ * </p>
+ */
+public interface ILanguageUI extends IAdaptable {
+
+       /**
+        * Get the code scanner that drives coloring in the editor.
+        * 
+        * @return code scanner for this language
+        */
+       RuleBasedScanner getCodeScanner();
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IPropertyChangeParticipant.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IPropertyChangeParticipant.java
new file mode 100644 (file)
index 0000000..71134ba
--- /dev/null
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial Implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui;
+
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+/**
+ * Implemented by classes which can optionally participate in property
+ * change events, and report whether an event would affect them without
+ * adapting to it.
+ * <p>
+ * Clients may implement this interface.
+ * </p>
+ * 
+ * @since 5.0
+ */
+public interface IPropertyChangeParticipant {
+       /**
+        * @param event
+        * @return true if the specified event will affect the participant's
+        * behaviour in a way it determines potential clients could act upon.
+        */
+       public boolean affectsBehavior(PropertyChangeEvent event);
+       
+       /**
+        * Performs any necessary to adapt the participant to the specified event.
+        * @param event
+        */
+       public void adaptToPreferenceChange(PropertyChangeEvent event);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IRequiredInclude.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IRequiredInclude.java
new file mode 100644 (file)
index 0000000..6b8e246
--- /dev/null
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui;
+
+
+/**
+ * Interface related to {@link IFunctionSummary} denoting an include required for a function.
+ * <p>
+ * Clients may implement this interface.
+ * </p>
+ * @see IFunctionSummary
+ */
+public interface IRequiredInclude {
+
+       /**
+        * Get the include name.
+        */
+       String getIncludeName();
+
+       /**
+        * Returns whether the include is to search on "standard places" like /usr/include first .
+        * An include is standard if it starts with <code>"&lt;"</code>.
+        */
+       boolean isStandard();
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IWorkingCopyManager.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IWorkingCopyManager.java
new file mode 100644 (file)
index 0000000..95a3f74
--- /dev/null
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *      IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.ui.IEditorInput;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.IProblemRequestor;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+
+/**
+ * Interface for accessing working copies of <code>ITranslationUnit</code>
+ * objects. The original translation unit is only given indirectly by means
+ * of an <code>IEditorInput</code>. The life cycle is as follows:
+ * <ul>
+ * <li> <code>connect</code> creates and remembers a working copy of the 
+ *   translation unit which is encoded in the given editor input</li>
+ * <li> <code>getWorkingCopy</code> returns the working copy remembered on 
+ *   <code>connect</code></li>
+ * <li> <code>disconnect</code> destroys the working copy remembered on 
+ *   <code>connect</code></li>
+ * </ul>
+ * <p>
+ * This interface is not intended to be implemented by clients.
+ * </p>
+ * @noimplement This interface is not intended to be implemented by clients.
+ * 
+ * @see CDTUITools#getWorkingCopyManager
+ */
+public interface IWorkingCopyManager {
+       
+       /**
+        * Connects the given editor input to this manager. After calling
+        * this method, a working copy will be available for the translation unit encoded
+        * in the given editor input (does nothing if there is no encoded translation unit).
+        *
+        * @param input the editor input
+        * @exception CoreException if the working copy cannot be created for the 
+        *   translation unit
+        */
+       void connect(IEditorInput input) throws CoreException;
+       
+       /**
+        * Disconnects the given editor input from this manager. After calling
+        * this method, a working copy for the translation unit encoded
+        * in the given editor input will no longer be available. Does nothing if there
+        * is no encoded translation unit, or if there is no remembered working copy for
+        * the translation unit.
+        * 
+        * @param input the editor input
+        */
+       void disconnect(IEditorInput input);
+       
+       /**
+        * Returns the working copy remembered for the translation unit encoded in
+        * the given editor input.
+        *
+        * @param input the editor input
+        * @return the working copy of the translation unit, or <code>null</code> if the
+        *   input does not encode an editor input, or if there is no remembered working
+        *   copy for this translation unit
+        */
+       IWorkingCopy getWorkingCopy(IEditorInput input);
+       
+       /**
+        * Shuts down this working copy manager. All working copies still remembered
+        * by this manager is destroyed.
+        */
+       void shutdown();
+
+       /**
+        * Returns a shared working copy for the given translation unit. If necessary, a new 
+        * working copy will be created.
+        * @param tu a translation unit
+        * @param requestor call back interface for reporting problems, may be <code>null</code>.
+        * @param monitor a monitor to report progress 
+        * @since 5.2
+        */
+       IWorkingCopy getSharedWorkingCopy(ITranslationUnit tu, IProblemRequestor requestor, IProgressMonitor monitor) throws CModelException;
+
+       /**
+        * Returns all shared working copies, currently available.
+        * @since 5.2
+        */
+       IWorkingCopy[] getSharedWorkingCopies();
+
+       /**
+        * Returns the shared working copy for the given translation unit, if it exists, or <code>null</code>, otherwise.
+        * @since 5.2
+        */
+       IWorkingCopy findSharedWorkingCopy(ITranslationUnit tu);
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IWorkingCopyManagerExtension.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IWorkingCopyManagerExtension.java
new file mode 100644 (file)
index 0000000..9a9946e
--- /dev/null
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2008 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui;
+
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.ui.IEditorInput;
+
+/**
+ * Extension interface for <code>IWorkingCopyManager</code>.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @since 2.1
+ */
+public interface IWorkingCopyManagerExtension {
+       
+       /**
+        * Sets the given working copy for the given editor input. If the given editor input
+        * is not connected to this working copy manager, this call has no effect. <p>
+        * This working copy manager does not assume the ownership of this working copy, i.e.,
+        * the given working copy is not automatically be freed when this manager is shut down.
+        * 
+        * @param input the editor input
+        * @param workingCopy the working copy
+        */
+       void setWorkingCopy(IEditorInput input, IWorkingCopy workingCopy);
+       
+       /**
+        * Removes the working copy set for the given editor input. If there is no
+        * working copy set for this input or this input is not connected to this
+        * working copy manager, this call has no effect.
+        * 
+        * @param input the editor input
+        */
+       void removeWorkingCopy(IEditorInput input);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IncludesGrouping.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IncludesGrouping.java
new file mode 100644 (file)
index 0000000..584a053
--- /dev/null
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+
+/**
+ * IncludesGrouping
+ */
+public class IncludesGrouping extends CElementGrouping {
+       ITranslationUnit tu;
+
+       public IncludesGrouping(ITranslationUnit unit) {
+               super(CElementGrouping.INCLUDES_GROUPING);
+               tu = unit;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
+        */
+       @Override
+       public Object[] getChildren(Object object) {
+               try {
+                       return tu.getChildrenOfType(ICElement.C_INCLUDE).toArray();
+               } catch (CModelException e) {
+               }
+               return super.getChildren(object);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
+        */
+       @Override
+       public Object getParent(Object object) {
+               return tu;
+       }
+
+       /* (non-Javadoc)
+        * @see java.lang.Object#equals(java.lang.Object)
+        */
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj) {
+                       return true;
+               }
+               if (obj instanceof IncludesGrouping) {
+                       return tu.equals(((IncludesGrouping)obj).tu) ;
+               }
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/Messages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/Messages.java
new file mode 100644 (file)
index 0000000..e8932fb
--- /dev/null
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM - Initial API and implementation
+ *    Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+       /** @since 5.3 */
+       public static String CDTSharedImages_MissingImage;
+
+       public static String CElementGrouping_includeGroupingLabel;
+       
+       /** @since 5.2 */
+       public static String CElementGrouping_macroGroupingLabel;
+       
+       public static String CUIPlugin_jobStartMakeUI;
+
+       static {
+               // Initialize resource bundle
+               NLS.initializeMessages(Messages.class.getName(), Messages.class);
+       }
+
+       private Messages() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/Messages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/Messages.properties
new file mode 100644 (file)
index 0000000..e37f514
--- /dev/null
@@ -0,0 +1,18 @@
+###############################################################################
+# Copyright (c) 2007, 2010 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#    IBM - Initial API and implementation
+#    Markus Schorn (Wind River Systems)
+###############################################################################
+
+#Note to translators: "include" is a code word and should not be translated.  Thanks.
+
+CDTSharedImages_MissingImage=Image {0} is missing in plugin {1}
+CElementGrouping_includeGroupingLabel=include directives
+CUIPlugin_jobStartMakeUI=Starting plugin org.eclipse.cdt.make.ui
+CElementGrouping_macroGroupingLabel=macro definitions
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/NamespacesGrouping.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/NamespacesGrouping.java
new file mode 100644 (file)
index 0000000..cb51ede
--- /dev/null
@@ -0,0 +1,181 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IMember;
+import org.eclipse.cdt.core.model.INamespace;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+import org.eclipse.cdt.internal.ui.MembersGrouping;
+
+/**
+ * NamespacesGrouping
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class NamespacesGrouping extends CElementGrouping {
+
+       protected ITranslationUnit fUnit;
+       protected String fName;
+       private final boolean fMemberGrouping;
+       
+       public NamespacesGrouping(ITranslationUnit unit, INamespace namespace) {
+               this(unit, namespace, false);
+       }
+
+       /**
+        * Create new namespace grouping and optional member grouping.
+        * 
+        * @param unit  the parent translation unit
+        * @param namespace  the namespace
+        * @param memberGrouping  whether member grouping is enabled
+        * @since 5.1
+        */
+       public NamespacesGrouping(ITranslationUnit unit, INamespace namespace, boolean memberGrouping) {
+               super(CElementGrouping.NAMESPACE_GROUPING);
+               fUnit = unit;
+               fName = namespace.getElementName();
+               fMemberGrouping = memberGrouping;
+       }
+
+       @Override
+       public String getLabel(Object object) {
+               return fName;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
+        */
+       @Override
+       public Object[] getChildren(Object object) {
+               Set<Object> list = new LinkedHashSet<Object>();
+               try {
+                       INamespace[] namespaces = getNamespaces();
+                       for (INamespace iNamespace : namespaces) {
+                               list.addAll(getNamespaceChildren(iNamespace));
+                       }
+               } catch (CModelException exc) {
+                       // ignore at this point
+               }
+
+               return list.toArray();
+       }
+
+
+       /**
+        * @since 5.1
+        */
+       public INamespace[] getNamespaces() {
+               List<INamespace> list = new ArrayList<INamespace>();
+               try {
+                       List<ICElement> namespaces = fUnit.getChildrenOfType(ICElement.C_NAMESPACE);
+                       for (ICElement icElement : namespaces) {
+                               if (fName.equals(icElement.getElementName())) {
+                                       INamespace nspace = (INamespace) icElement;
+                                       list.add(nspace);
+                               }
+                       }
+               } catch (CModelException exc) {
+                       // ignore at this point
+               }
+
+               return list.toArray(new INamespace[list.size()]);
+       }
+
+       private Collection<Object> getNamespaceChildren(INamespace nspace) throws CModelException {
+               Object[] children = nspace.getChildren();
+               if (!fMemberGrouping) {
+                       return Arrays.asList(children);
+               }
+               List<Object> list = new ArrayList<Object>(children.length);
+               // check if there is another member with the same namespace for the same parent
+               Map<String, MembersGrouping> map = new HashMap<String, MembersGrouping>();
+               for (int i = 0; i < children.length; ++i) {
+                       if (children[i] instanceof IMember) {
+                               final ICElement member = (ICElement)children[i];
+                               String name = member.getElementName();
+                               int idx = name.lastIndexOf("::"); //$NON-NLS-1$
+                               if (idx < 0) {
+                                       continue;
+                               }
+                               String namespace = name.substring(0, idx);
+                               MembersGrouping memberGrouping = map.get(namespace);
+                               if (memberGrouping == null) {
+                                       memberGrouping = new MembersGrouping(this, namespace);
+                                       map.put(namespace, memberGrouping);
+                                       list.add(memberGrouping);
+                               }
+                       } else {
+                               list.add(children[i]);
+                       }
+               }
+               return list;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
+        */
+       @Override
+       public Object getParent(Object object) {
+               return fUnit;
+       }
+
+       /**
+        * @param nspace
+        * @deprecated
+        */
+       @Deprecated
+       public void addNamespace(INamespace nspace) {
+       }
+
+       /* (non-Javadoc)
+        * @see java.lang.Object#equals(java.lang.Object)
+        */
+       @Override
+       public boolean equals(Object obj) {
+               if (this == obj) {
+                       return true;
+               }
+               if (obj instanceof NamespacesGrouping) {
+                       NamespacesGrouping other = (NamespacesGrouping)obj;
+                       return fUnit.equals(other.fUnit) && fName.equals(other.fName);
+               }
+               return false;
+       }
+
+       /*
+        * @see java.lang.Object#hashCode()
+        */
+       @Override
+       public int hashCode() {
+               return fUnit.hashCode() * 17 + fName.hashCode();
+       }
+       
+       /*
+        * @see org.eclipse.cdt.ui.CElementGrouping#toString()
+        */
+       @Override
+       public String toString() {
+               return fName;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java
new file mode 100644 (file)
index 0000000..be6aaa1
--- /dev/null
@@ -0,0 +1,2175 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *        Sergey Prigogin (Google)
+ *     Elazar Leibovich (IDF) - Code folding of compound statements (bug 174597)
+ *     Jens Elmenthaler (Verigy) - http://bugs.eclipse.org/235586
+ *******************************************************************************/
+package org.eclipse.cdt.ui;
+
+import java.util.Locale;
+
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.resource.ColorRegistry;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
+
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.ui.text.ICColorConstants;
+
+import org.eclipse.cdt.internal.ui.ICThemeConstants;
+import org.eclipse.cdt.internal.ui.preferences.formatter.FormatterProfileManager;
+import org.eclipse.cdt.internal.ui.text.spelling.SpellCheckEngine;
+
+/**
+ * Preference constants used in the CDT-UI preference store. Clients should only read the
+ * CDT-UI preference store using these values. Clients are not allowed to modify the
+ * preference store programmatically.
+ * 
+ * The preferences defined in this file are exported in the plugin's 
+ * "preferenceTransfer" extension. If adding a new preference please 
+ * also add it to one of the two if applicable:
+ * <ol>
+ * <li>"Editor Appearance" - Any preference related to how the editor presents 
+ *                                                     the edited code to the user.</li>
+ * <li>"Editor Behavior" - Any preference related to how the editor process the 
+ *                                               edited code.</li>
+ * </ol>
+ * @noextend This class is not intended to be subclassed by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ * @since 2.0
+ */
+public class PreferenceConstants {
+
+       private PreferenceConstants() {
+       }
+
+       /**
+        * Preference key suffix for bold text style preference keys.
+        *
+        * @since 4.0
+        */
+       public static final String EDITOR_BOLD_SUFFIX= "_bold"; //$NON-NLS-1$
+
+       /**
+        * Preference key suffix for italic text style preference keys.
+        *
+        * @since 4.0
+        */
+       public static final String EDITOR_ITALIC_SUFFIX= "_italic"; //$NON-NLS-1$
+
+       /**
+        * Preference key suffix for strikethrough text style preference keys.
+        *
+        * @since 4.0
+        */
+       public static final String EDITOR_STRIKETHROUGH_SUFFIX= "_strikethrough"; //$NON-NLS-1$
+
+       /**
+        * Preference key suffix for underline text style preference keys.
+        *
+        * @since 4.0
+        */
+       public static final String EDITOR_UNDERLINE_SUFFIX= "_underline"; //$NON-NLS-1$
+
+       /**
+        * A named preference that holds the color used to render multi-line comments.
+        * <p>
+        * Value is of type <code>String</code>. A RGB color value encoded as a string
+        * using class <code>PreferenceConverter</code>
+        * </p>
+        *
+        * @see org.eclipse.jface.resource.StringConverter
+        * @see org.eclipse.jface.preference.PreferenceConverter
+        * @since 4.0
+        */
+       public final static String EDITOR_MULTI_LINE_COMMENT_COLOR= ICColorConstants.C_MULTI_LINE_COMMENT;
+
+       /**
+        * A named preference that controls whether multi-line comments are rendered in bold.
+        * <p>
+        * Value is of type <code>Boolean</code>. If <code>true</code> multi-line comments are rendered
+        * in bold. If <code>false</code> the are rendered using no font style attribute.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public final static String EDITOR_MULTI_LINE_COMMENT_BOLD= ICColorConstants.C_MULTI_LINE_COMMENT + EDITOR_BOLD_SUFFIX;
+
+       /**
+        * A named preference that controls whether multi-line comments are rendered in italic.
+        * <p>
+        * Value is of type <code>Boolean</code>. If <code>true</code> multi-line comments are rendered
+        * in italic. If <code>false</code> the are rendered using no italic font style attribute.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public final static String EDITOR_MULTI_LINE_COMMENT_ITALIC= ICColorConstants.C_MULTI_LINE_COMMENT + EDITOR_ITALIC_SUFFIX;
+
+       /**
+        * A named preference that holds the color used to render single line comments.
+        * <p>
+        * Value is of type <code>String</code>. A RGB color value encoded as a string
+        * using class <code>PreferenceConverter</code>
+        * </p>
+        *
+        * @see org.eclipse.jface.resource.StringConverter
+        * @see org.eclipse.jface.preference.PreferenceConverter
+        * @since 4.0
+        */
+       public final static String EDITOR_SINGLE_LINE_COMMENT_COLOR= ICColorConstants.C_SINGLE_LINE_COMMENT;
+
+       /**
+        * A named preference that controls whether single line comments are rendered in bold.
+        * <p>
+        * Value is of type <code>Boolean</code>. If <code>true</code> single line comments are rendered
+        * in bold. If <code>false</code> the are rendered using no font style attribute.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public final static String EDITOR_SINGLE_LINE_COMMENT_BOLD= ICColorConstants.C_SINGLE_LINE_COMMENT + EDITOR_BOLD_SUFFIX;
+
+       /**
+        * A named preference that controls whether single line comments are rendered in italic.
+        * <p>
+        * Value is of type <code>Boolean</code>. If <code>true</code> single line comments are rendered
+        * in italic. If <code>false</code> the are rendered using no italic font style attribute.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public final static String EDITOR_SINGLE_LINE_COMMENT_ITALIC= ICColorConstants.C_SINGLE_LINE_COMMENT + EDITOR_ITALIC_SUFFIX;
+
+       /**
+        * A named preference that holds the color used to render C/C++ keywords.
+        * <p>
+        * Value is of type <code>String</code>. A RGB color value encoded as a string
+        * using class <code>PreferenceConverter</code>
+        * </p>
+        *
+        * @see org.eclipse.jface.resource.StringConverter
+        * @see org.eclipse.jface.preference.PreferenceConverter
+        * @since 4.0
+        */
+       public final static String EDITOR_C_KEYWORD_COLOR= ICColorConstants.C_KEYWORD;
+
+       /**
+        * A named preference that controls whether keywords are rendered in bold.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public final static String EDITOR_C_KEYWORD_BOLD= ICColorConstants.C_KEYWORD + EDITOR_BOLD_SUFFIX;
+
+       /**
+        * A named preference that controls whether keywords are rendered in italic.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public final static String EDITOR_C_KEYWORD_ITALIC= ICColorConstants.C_KEYWORD + EDITOR_ITALIC_SUFFIX;
+
+       /**
+        * A named preference that holds the color used to render preprocessor directives.
+        * <p>
+        * Value is of type <code>String</code>. A RGB color value encoded as a string
+        * using class <code>PreferenceConverter</code>
+        * </p>
+        *
+        * @see org.eclipse.jface.resource.StringConverter
+        * @see org.eclipse.jface.preference.PreferenceConverter
+        * @since 4.0
+        */
+       public final static String EDITOR_PP_DIRECTIVE_COLOR= ICColorConstants.PP_DIRECTIVE;
+
+       /**
+        * A named preference that controls whether preprocessor directives are rendered in bold.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public final static String EDITOR_PP_DIRECTIVE_BOLD= ICColorConstants.PP_DIRECTIVE + EDITOR_BOLD_SUFFIX;
+
+       /**
+        * A named preference that controls whether preprocessor directives are rendered in italic.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public final static String EDITOR_PP_DIRECTIVE_ITALIC= ICColorConstants.PP_DIRECTIVE + EDITOR_ITALIC_SUFFIX;
+
+       /**
+        * A named preference that holds the color used to render headers.
+        * <p>
+        * Value is of type <code>String</code>. A RGB color value encoded as a string
+        * using class <code>PreferenceConverter</code>
+        * </p>
+        *
+        * @see org.eclipse.jface.resource.StringConverter
+        * @see org.eclipse.jface.preference.PreferenceConverter
+        * @since 4.0
+        */
+       public final static String EDITOR_PP_HEADER_COLOR= ICColorConstants.PP_HEADER;
+
+       /**
+        * A named preference that controls whether headers are rendered in bold.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public final static String EDITOR_PP_HEADER_BOLD= ICColorConstants.PP_HEADER + EDITOR_BOLD_SUFFIX;
+
+       /**
+        * A named preference that controls whether number are rendered in italic.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public final static String EDITOR_PP_HEADER_ITALIC= ICColorConstants.PP_HEADER + EDITOR_ITALIC_SUFFIX;
+
+       /**
+        * A named preference that holds the color used to render preprocessor text.
+        * <p>
+        * Value is of type <code>String</code>. A RGB color value encoded as a string
+        * using class <code>PreferenceConverter</code>
+        * </p>
+        *
+        * @see org.eclipse.jface.resource.StringConverter
+        * @see org.eclipse.jface.preference.PreferenceConverter
+        * @since 4.0
+        */
+       public final static String EDITOR_PP_DEFAULT_COLOR= ICColorConstants.PP_DEFAULT;
+
+       /**
+        * A named preference that controls whether preprocessor text is rendered in bold.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public final static String EDITOR_PP_DEFAULT_BOLD= ICColorConstants.PP_DEFAULT + EDITOR_BOLD_SUFFIX;
+
+       /**
+        * A named preference that controls whether preprocessor text is rendered in italic.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public final static String EDITOR_PP_DEFAULT_ITALIC= ICColorConstants.PP_DEFAULT + EDITOR_ITALIC_SUFFIX;
+
+       /**
+        * A named preference that holds the color used to render builtin types.
+        * <p>
+        * Value is of type <code>String</code>. A RGB color value encoded as a string
+        * using class <code>PreferenceConverter</code>
+        * </p>
+        *
+        * @see org.eclipse.jface.resource.StringConverter
+        * @see org.eclipse.jface.preference.PreferenceConverter
+        * @since 4.0
+        */
+       public final static String EDITOR_C_BUILTIN_TYPE_COLOR= ICColorConstants.C_TYPE;
+
+       /**
+        * A named preference that controls whether builtin types are rendered in bold.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public final static String EDITOR_C_BUILTIN_TYPE_BOLD= ICColorConstants.C_TYPE + EDITOR_BOLD_SUFFIX;
+
+       /**
+        * A named preference that controls whether builtin types are rendered in italic.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public final static String EDITOR_C_BUILTIN_TYPE_ITALIC= ICColorConstants.C_TYPE + EDITOR_ITALIC_SUFFIX;
+
+       /**
+        * A named preference that holds the color used to render string constants.
+        * <p>
+        * Value is of type <code>String</code>. A RGB color value encoded as a string
+        * using class <code>PreferenceConverter</code>
+        * </p>
+        *
+        * @see org.eclipse.jface.resource.StringConverter
+        * @see org.eclipse.jface.preference.PreferenceConverter
+        * @since 4.0
+        */
+       public final static String EDITOR_C_STRING_COLOR= ICColorConstants.C_STRING;
+
+       /**
+        * A named preference that controls whether string constants are rendered in bold.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public final static String EDITOR_C_STRING_BOLD= ICColorConstants.C_STRING + EDITOR_BOLD_SUFFIX;
+
+       /**
+        * A named preference that controls whether string constants are rendered in italic.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public final static String EDITOR_C_STRING_ITALIC= ICColorConstants.C_STRING + EDITOR_ITALIC_SUFFIX;
+
+       /**
+        * A named preference that holds the color used to render operators.
+        * <p>
+        * Value is of type <code>String</code>. A RGB color value encoded as a string
+        * using class <code>PreferenceConverter</code>
+        * </p>
+        *
+        * @see org.eclipse.jface.resource.StringConverter
+        * @see org.eclipse.jface.preference.PreferenceConverter
+        * @since 4.0
+        */
+       public final static String EDITOR_C_OPERATOR_COLOR= ICColorConstants.C_OPERATOR;
+
+       /**
+        * A named preference that controls whether operators are rendered in bold.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public final static String EDITOR_C_OPERATOR_BOLD= ICColorConstants.C_OPERATOR + EDITOR_BOLD_SUFFIX;
+
+       /**
+        * A named preference that controls whether operators are rendered in italic.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public final static String EDITOR_C_OPERATOR_ITALIC= ICColorConstants.C_OPERATOR + EDITOR_ITALIC_SUFFIX;
+
+       /**
+        * A named preference that holds the color used to render numbers.
+        * <p>
+        * Value is of type <code>String</code>. A RGB color value encoded as a string
+        * using class <code>PreferenceConverter</code>
+        * </p>
+        *
+        * @see org.eclipse.jface.resource.StringConverter
+        * @see org.eclipse.jface.preference.PreferenceConverter
+        * @since 4.0
+        */
+       public final static String EDITOR_C_NUMBER_COLOR= ICColorConstants.C_NUMBER;
+
+       /**
+        * A named preference that controls whether number are rendered in bold.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public final static String EDITOR_C_NUMBER_BOLD= ICColorConstants.C_NUMBER + EDITOR_BOLD_SUFFIX;
+
+       /**
+        * A named preference that controls whether number are rendered in italic.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public final static String EDITOR_C_NUMBER_ITALIC= ICColorConstants.C_NUMBER + EDITOR_ITALIC_SUFFIX;
+
+       /**
+        * A named preference that holds the color used to render braces.
+        * <p>
+        * Value is of type <code>String</code>. A RGB color value encoded as a string
+        * using class <code>PreferenceConverter</code>
+        * </p>
+        *
+        * @see org.eclipse.jface.resource.StringConverter
+        * @see org.eclipse.jface.preference.PreferenceConverter
+        * @since 4.0
+        */
+       public final static String EDITOR_C_BRACES_COLOR= ICColorConstants.C_BRACES;
+
+       /**
+        * A named preference that controls whether braces are rendered in bold.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public final static String EDITOR_C_BRACES_BOLD= ICColorConstants.C_BRACES + EDITOR_BOLD_SUFFIX;
+
+       /**
+        * A named preference that controls whether braces are rendered in italic.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public final static String EDITOR_C_BRACES_ITALIC= ICColorConstants.C_BRACES + EDITOR_ITALIC_SUFFIX;
+
+       /**
+        * A named preference that holds the color used to render C/C++ default text.
+        * <p>
+        * Value is of type <code>String</code>. A RGB color value encoded as a string
+        * using class <code>PreferenceConverter</code>
+        * </p>
+        *
+        * @see org.eclipse.jface.resource.StringConverter
+        * @see org.eclipse.jface.preference.PreferenceConverter
+        * @since 4.0
+        */
+       public final static String EDITOR_C_DEFAULT_COLOR= ICColorConstants.C_DEFAULT;
+
+       /**
+        * A named preference that controls whether C/C++ default text is rendered in bold.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public final static String EDITOR_C_DEFAULT_BOLD= ICColorConstants.C_DEFAULT + EDITOR_BOLD_SUFFIX;
+
+       /**
+        * A named preference that controls whether C/C++ default text is rendered in italic.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public final static String EDITOR_C_DEFAULT_ITALIC= ICColorConstants.C_DEFAULT + EDITOR_ITALIC_SUFFIX;
+
+       /**
+        * A named preference that holds the color used to render assembly labels.
+        * <p>
+        * Value is of type <code>String</code>. A RGB color value encoded as a string
+        * using class <code>PreferenceConverter</code>
+        * </p>
+        *
+        * @see org.eclipse.jface.resource.StringConverter
+        * @see org.eclipse.jface.preference.PreferenceConverter
+        * @since 5.0
+        */
+       public final static String EDITOR_ASM_LABEL_COLOR= ICColorConstants.ASM_LABEL;
+
+       /**
+        * A named preference that controls whether assembly labels are rendered in bold.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public final static String EDITOR_ASM_LABEL_BOLD= ICColorConstants.ASM_LABEL + EDITOR_BOLD_SUFFIX;
+
+       /**
+        * A named preference that controls whether assembly labels are rendered in italic.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public final static String EDITOR_ASM_LABEL_ITALIC= ICColorConstants.ASM_LABEL + EDITOR_ITALIC_SUFFIX;
+
+       /**
+        * A named preference that holds the color used to render assembly directives.
+        * <p>
+        * Value is of type <code>String</code>. A RGB color value encoded as a string
+        * using class <code>PreferenceConverter</code>
+        * </p>
+        *
+        * @see org.eclipse.jface.resource.StringConverter
+        * @see org.eclipse.jface.preference.PreferenceConverter
+        * @since 5.0
+        */
+       public final static String EDITOR_ASM_DIRECTIVE_COLOR= ICColorConstants.ASM_DIRECTIVE;
+
+       /**
+        * A named preference that controls whether assembly directives are rendered in bold.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public final static String EDITOR_ASM_DIRECTIVE_BOLD= ICColorConstants.ASM_DIRECTIVE + EDITOR_BOLD_SUFFIX;
+
+       /**
+        * A named preference that controls whether assembly directives are rendered in italic.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public final static String EDITOR_ASM_DIRECTIVE_ITALIC= ICColorConstants.ASM_DIRECTIVE + EDITOR_ITALIC_SUFFIX;
+
+       /**
+        * The symbolic font name for the C/C++ editor text font
+        * (value <code>"org.eclipse.cdt.ui.editors.textfont"</code>).
+        *
+        * @since 4.0
+        */
+       public final static String EDITOR_TEXT_FONT= "org.eclipse.cdt.ui.editors.textfont"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether the cview's selection is linked to the active editor.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        */
+       public static final String PREF_LINK_TO_EDITOR= "org.eclipse.cdt.ui.editor.linkToEditor"; //$NON-NLS-1$
+
+       /**
+        * A named preference that speficies whether children of a translation unit are shown in the CView.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        */
+       public static final String PREF_SHOW_CU_CHILDREN= "org.eclipse.cdt.ui.editor.CUChildren"; //$NON-NLS-1$
+
+       /**
+        * A named preference that speficies whether to use the parser's structural mode to build the CModel.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        */
+       public static final String PREF_USE_STRUCTURAL_PARSE_MODE= "org.eclipse.cdt.ui.editor.UseStructuralMode"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls if segmented view (show selected element only) is turned on or off.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        */
+       public static final String EDITOR_SHOW_SEGMENTS= "org.eclipse.cdt.ui.editor.showSegments"; //$NON-NLS-1$
+
+    /**
+     * A named preference that holds the color used to render task tags.
+     * <p>
+     * Value is of type <code>String</code>. A RGB color value encoded as a string
+     * using class <code>PreferenceConverter</code>
+     * </p>
+     *
+     * @see org.eclipse.jface.resource.StringConverter
+     * @see org.eclipse.jface.preference.PreferenceConverter
+     */
+    public final static String EDITOR_TASK_TAG_COLOR= ICColorConstants.TASK_TAG;
+
+    /**
+     * A named preference that controls whether task tags are rendered in bold.
+     * <p>
+     * Value is of type <code>Boolean</code>.
+     * </p>
+     */
+    public final static String EDITOR_TASK_TAG_BOLD= ICColorConstants.TASK_TAG + EDITOR_BOLD_SUFFIX;
+
+    /**
+     * A named preference that controls whether task tags are rendered in italic.
+     * <p>
+     * Value is of type <code>Boolean</code>.
+     * </p>
+     */
+    public final static String EDITOR_TASK_TAG_ITALIC= ICColorConstants.TASK_TAG + EDITOR_ITALIC_SUFFIX;
+
+    /**
+        * A named preference that controls if correction indicators are shown in the UI.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        */
+       public final static String EDITOR_CORRECTION_INDICATION= "CEditor.ShowTemporaryProblem"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls if temporary problems are evaluated and shown in the UI.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        */
+       public final static String EDITOR_EVALUATE_TEMPORARY_PROBLEMS= "handleTemporaryProblems"; //$NON-NLS-1$
+
+       /**
+        * A named preference that defines the key for the hover modifiers.
+        *
+        */
+       public static final String EDITOR_TEXT_HOVER_MODIFIERS= "hoverModifiers"; //$NON-NLS-1$
+
+       /**
+        * A named preference that defines the key for the hover modifier state masks.
+        * The value is only used if the value of <code>EDITOR_TEXT_HOVER_MODIFIERS</code>
+        * cannot be resolved to valid SWT modifier bits.
+        *
+        * @see #EDITOR_TEXT_HOVER_MODIFIERS
+        */
+       public static final String EDITOR_TEXT_HOVER_MODIFIER_MASKS= "hoverModifierMasks"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether the 'close strings' feature
+        *  is   enabled.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        */
+       public final static String EDITOR_CLOSE_STRINGS= "closeStrings"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether the 'wrap strings' feature is
+        * enabled.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        */
+       public final static String EDITOR_WRAP_STRINGS= "wrapStrings"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether the 'escape strings' feature is
+        * enabled.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        */
+       public final static String EDITOR_ESCAPE_STRINGS= "escapeStrings"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether the 'close brackets' feature is
+        * enabled.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        */
+       public final static String EDITOR_CLOSE_BRACKETS= "closeBrackets"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether the 'close angular brackets' feature is
+        * enabled.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        */
+       public final static String EDITOR_CLOSE_ANGULAR_BRACKETS= "closeAngularBrackets"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether the 'close braces' feature is
+        * enabled.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        */
+       public final static String EDITOR_CLOSE_BRACES= "closeBraces"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether the 'smart paste' feature is
+        * enabled.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        */
+       public final static String EDITOR_SMART_PASTE= "smartPaste"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls the smart tab behavior.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        */
+       public static final String EDITOR_SMART_TAB= "smart_tab"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether the 'auto indent' feature is
+        * enabled.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        */
+       public final static String EDITOR_AUTO_INDENT= "autoIndent"; //$NON-NLS-1$
+
+       /**
+        * The id of the best match hover contributed for extension point
+        * <code>org.eclipse.cdt.ui.textHovers</code>.
+        *
+        * @since 2.1
+        */
+       public static final String ID_BESTMATCH_HOVER= "org.eclipse.cdt.ui.BestMatchHover"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether the Outline view should group include directives.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        */
+       public static final String OUTLINE_GROUP_INCLUDES= "org.eclipse.cdt.ui.outline.groupincludes"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether the Outline view should group namespaces.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        */
+       public static final String OUTLINE_GROUP_NAMESPACES= "org.eclipse.cdt.ui.outline.groupnamespaces"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether the Outline view should group member definitions.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        * @since 5.1
+        */
+       public static final String OUTLINE_GROUP_MEMBERS= "org.eclipse.cdt.ui.outline.groupmembers"; //$NON-NLS-1$
+       
+       /**
+        * A named preference that controls whether the Outline view should group macro definitions.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        * @since 5.2
+        */
+       public static final String OUTLINE_GROUP_MACROS= "org.eclipse.cdt.ui.outline.groupmacros"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether the Outline view
+        * selection should stay in sync with with the element at the current cursor position.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        */
+       public static final String OUTLINE_LINK_TO_EDITOR = "org.eclipse.cdt.ui.outline.linktoeditor"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether include directives should be grouped in the
+        * C/C++ Projects view and the Project Explorer view.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        */
+       public static final String CVIEW_GROUP_INCLUDES= "org.eclipse.cdt.ui.cview.groupincludes"; //$NON-NLS-1$
+       
+       /**
+        * A named preference that controls whether macro defintions should be grouped in the
+        * C/C++ Projects view and the Project Explorer view.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        * @since 5.2
+        */
+       public static final String CVIEW_GROUP_MACROS= "org.eclipse.cdt.ui.cview.groupmacros"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether header and source files should be separated in the
+        * C/C++ Projects view and the Project Explorer view.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        * 
+        * @since 5.0
+        */
+       public static final String CVIEW_SEPARATE_HEADER_AND_SOURCE= "org.eclipse.cdt.ui.cview.separateheaderandsource"; //$NON-NLS-1$
+               
+       /**
+        * A named preference that controls whether the sorting order of source files should be changed 
+        * in the C/C++ Projects view and the Project Explorer view when they are excluded from build.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        * 
+        * @since 5.3
+        */
+       public static final String SORT_ORDER_OF_EXCLUDED_FILES= "org.eclipse.cdt.ui.cview.sortorderofexcludedfiles"; //$NON-NLS-1$
+       
+       /**
+        * A named preference that controls which completion proposal categories
+        * have been excluded from the default proposal list.
+        * <p>
+        * Value is of type <code>String</code>, a "\0"-separated list of identifiers.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public static final String CODEASSIST_EXCLUDED_CATEGORIES= "content_assist_disabled_computers"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls the order of the specific code assist commands.
+        * <p>
+        * Value is of type <code>String</code>, a "\0"-separated list of identifiers.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public static final String CODEASSIST_CATEGORY_ORDER= "content_assist_category_order"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether folding is enabled in the C editor.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        */
+       public static final String EDITOR_FOLDING_ENABLED= "editor_folding_enabled"; //$NON-NLS-1$
+
+       /**
+        * A named preference that stores the configured folding provider.
+        * <p>
+        * Value is of type <code>String</code>.
+        * </p>
+        *
+        */
+       public static final String EDITOR_FOLDING_PROVIDER= "editor_folding_provider"; //$NON-NLS-1$
+
+       /**
+        * A named preference that stores the value for Structure folding for the default folding provider.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 3.0
+        */
+       public static final String EDITOR_FOLDING_STRUCTURES= "editor_folding_default_structures"; //$NON-NLS-1$
+
+       /**
+        * A named preference that stores the value for statements folding (if/else, do/while, for, switch statements)
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        */
+       public static final String EDITOR_FOLDING_STATEMENTS = "editor_folding_statements"; //$NON-NLS-1$
+       
+       /**
+        * A named preference that stores the value for functions folding for the default folding provider.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 3.0
+        */
+       public static final String EDITOR_FOLDING_FUNCTIONS= "editor_folding_default_functions"; //$NON-NLS-1$
+
+       /**
+        * A named preference that stores the value for method folding for the default folding provider.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 3.0
+        */
+       public static final String EDITOR_FOLDING_METHODS= "editor_folding_default_methods"; //$NON-NLS-1$
+
+       /**
+        * A named preference that stores the value for macros folding for the default folding provider.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 3.0
+        */
+       public static final String EDITOR_FOLDING_MACROS= "editor_folding_default_macros"; //$NON-NLS-1$
+
+       /**
+        * A named preference that stores the value for comment folding for the default folding provider.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public static final String EDITOR_FOLDING_COMMENTS= "editor_folding_default_comments"; //$NON-NLS-1$
+
+       /**
+        * A named preference that stores the value for header comment folding for the default folding provider.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public static final String EDITOR_FOLDING_HEADERS= "editor_folding_default_headers"; //$NON-NLS-1$
+
+       /**
+        * A named preference that stores the value for inactive code folding for the default folding provider.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public static final String EDITOR_FOLDING_INACTIVE_CODE= "editor_folding_default_inactive"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether folding of preprocessor branches is enabled.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public static final String EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED= "editor_folding_preprocessor_enabled"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls if templates are formatted when applied.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 2.1
+        */
+       public static final String TEMPLATES_USE_CODEFORMATTER= "org.eclipse.cdt.ui.text.templates.format"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls which profile is used by the code formatter.
+        * <p>
+        * Value is of type <code>String</code>.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public static final String FORMATTER_PROFILE = "formatter_profile"; //$NON-NLS-1$
+
+       /**
+        * Preference key for whether to ensure a newline at the end of files when saving.
+        *
+        * @since 4.0
+        */
+       public final static String ENSURE_NEWLINE_AT_EOF = "ensureNewlineAtEOF"; //$NON-NLS-1$
+
+       /**
+        * Preference key for whether to remove trailing whitespace when saving.
+        *
+        * @since 5.0
+        */
+       public final static String REMOVE_TRAILING_WHITESPACE = "removeTrailingWhitespace"; //$NON-NLS-1$
+       
+       /**
+        * Preference key controlling how REMOVE_TRAILING_WHITESPACE option is applied.
+        * If REMOVE_TRAILING_WHITESPACE is enabled, this option limits the scope of
+        * the removal to edited lines only. This option has no effect if
+        * REMOVE_TRAILING_WHITESPACE is disabled.
+        *
+        * @since 5.1
+        */
+       public final static String REMOVE_TRAILING_WHITESPACE_LIMIT_TO_EDITED_LINES = "removeTrailingWhitespaceEditedLines"; //$NON-NLS-1$
+
+       /**
+        * A named preference that defines whether the hint to make hover sticky should be shown.
+        *
+        * @since 3.1.1
+        * @deprecated As of 4.0, replaced by {@link AbstractDecoratedTextEditorPreferenceConstants#EDITOR_SHOW_TEXT_HOVER_AFFORDANCE}
+        */
+       @Deprecated
+       public static final String EDITOR_SHOW_TEXT_HOVER_AFFORDANCE= AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE;
+
+       /**
+        * A named preference prefix for semantic highlighting preferences.
+        *
+        * @since 4.0
+        */
+       public static final String EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX="semanticHighlighting."; //$NON-NLS-1$
+
+       /**
+        * A named preference suffix that controls a semantic highlighting's color.
+        * <p>
+        * Value is of type <code>String</code>. A RGB color value encoded as a string
+        * using class <code>PreferenceConverter</code>
+        * </p>
+        *
+        * @see org.eclipse.jface.resource.StringConverter
+        * @see org.eclipse.jface.preference.PreferenceConverter
+        * @since 4.0
+        */
+       public static final String EDITOR_SEMANTIC_HIGHLIGHTING_COLOR_SUFFIX=".color"; //$NON-NLS-1$
+
+       /**
+        * A named preference suffix that controls if semantic highlighting has the text attribute bold.
+        * <p>
+        * Value is of type <code>Boolean</code>: <code>true</code> if bold.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public static final String EDITOR_SEMANTIC_HIGHLIGHTING_BOLD_SUFFIX=".bold"; //$NON-NLS-1$
+
+       /**
+        * A named preference suffix that controls if semantic highlighting has the text attribute italic.
+        * <p>
+        * Value is of type <code>Boolean</code>: <code>true</code> if italic.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public static final String EDITOR_SEMANTIC_HIGHLIGHTING_ITALIC_SUFFIX=".italic"; //$NON-NLS-1$
+
+       /**
+        * A named preference suffix that controls if semantic highlighting has the text attribute strikethrough.
+        * <p>
+        * Value is of type <code>Boolean</code>: <code>true</code> if strikethrough.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public static final String EDITOR_SEMANTIC_HIGHLIGHTING_STRIKETHROUGH_SUFFIX=".strikethrough"; //$NON-NLS-1$
+
+       /**
+        * A named preference suffix that controls if semantic highlighting has the text attribute underline.
+        * <p>
+        * Value is of type <code>Boolean</code>: <code>true</code> if underline.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public static final String EDITOR_SEMANTIC_HIGHLIGHTING_UNDERLINE_SUFFIX=".underline"; //$NON-NLS-1$
+
+       /**
+        * A named preference suffix that controls if semantic highlighting is enabled.
+        * <p>
+        * Value is of type <code>Boolean</code>: <code>true</code> if enabled.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public static final String EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED_SUFFIX=".enabled"; //$NON-NLS-1$
+
+       /**
+        * A named preference key that controls if semantic highlighting is enabled.
+        * <p>
+        * Value is of type <code>Boolean</code>: <code>true</code> if enabled.
+        * </p>
+        *
+        * @since 4.0
+        */
+       public static final String EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED= "semanticHighlighting.enabled"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls if quick assist light bulbs are shown.
+        * <p>
+        * Value is of type <code>Boolean</code>: if <code>true</code> light bulbs are shown
+        * for quick assists.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public static final String EDITOR_QUICKASSIST_LIGHTBULB="org.eclipse.cdt.quickassist.lightbulb"; //$NON-NLS-1$
+
+       /**
+        * A named preference that holds the background color used in the code assist selection dialog.
+        * <p>
+        * Value is of type <code>String</code>. A RGB color value encoded as a string
+        * using class <code>PreferenceConverter</code>
+        * </p>
+        *
+        * @see org.eclipse.jface.resource.StringConverter
+        * @see org.eclipse.jface.preference.PreferenceConverter
+        *
+        * @since 5.0
+        */
+       public final static String CODEASSIST_PROPOSALS_BACKGROUND= "content_assist_proposals_background"; //$NON-NLS-1$
+       /**
+        * A named preference that holds the foreground color used in the code assist selection dialog.
+        * <p>
+        * Value is of type <code>String</code>. A RGB color value encoded as a string
+        * using class <code>PreferenceConverter</code>
+        * </p>
+        *
+        * @see org.eclipse.jface.resource.StringConverter
+        * @see org.eclipse.jface.preference.PreferenceConverter
+        *
+        * @since 5.0
+        */
+       public final static String CODEASSIST_PROPOSALS_FOREGROUND= "content_assist_proposals_foreground"; //$NON-NLS-1$
+       
+       /**
+        * A named preference that holds the background color used for parameter hints.
+        * <p>
+        * Value is of type <code>String</code>. A RGB color value encoded as a string
+        * using class <code>PreferenceConverter</code>
+        * </p>
+        * 
+        * @see org.eclipse.jface.resource.StringConverter
+        * @see org.eclipse.jface.preference.PreferenceConverter
+        *
+        * @since 5.0
+        */
+       public final static String CODEASSIST_PARAMETERS_BACKGROUND= "content_assist_parameters_background"; //$NON-NLS-1$
+
+       /**
+        * A named preference that holds the foreground color used in the code assist selection dialog.
+        * <p>
+        * Value is of type <code>String</code>. A RGB color value encoded as a string
+        * using class <code>PreferenceConverter</code>
+        * </p>
+        * 
+        * @see org.eclipse.jface.resource.StringConverter
+        * @see org.eclipse.jface.preference.PreferenceConverter
+        *
+        * @since 5.0
+        */
+       public final static String CODEASSIST_PARAMETERS_FOREGROUND= "content_assist_parameters_foreground"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether all dirty editors are automatically saved before a refactoring is
+        * executed.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        * @since 5.3
+        */
+       public static final String REFACTOR_SAVE_ALL_EDITORS= "Refactoring.savealleditors"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether certain refactorings use a lightweight UI when
+        * started from a C/C++ editor.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        * @since 5.3
+        */
+       public static final String REFACTOR_LIGHTWEIGHT= "Refactor.lightweight"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether words containing digits should
+        * be skipped during spell checking.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public final static String SPELLING_IGNORE_DIGITS= "spelling_ignore_digits"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether mixed case words should be
+        * skipped during spell checking.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public final static String SPELLING_IGNORE_MIXED= "spelling_ignore_mixed"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether sentence capitalization should
+        * be ignored during spell checking.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public final static String SPELLING_IGNORE_SENTENCE= "spelling_ignore_sentence"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether upper case words should be
+        * skipped during spell checking.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public final static String SPELLING_IGNORE_UPPER= "spelling_ignore_upper"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether URLs should be ignored during
+        * spell checking.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public final static String SPELLING_IGNORE_URLS= "spelling_ignore_urls"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether single letters
+        * should be ignored during spell checking.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public final static String SPELLING_IGNORE_SINGLE_LETTERS= "spelling_ignore_single_letters"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether string literals
+        * should be ignored during spell checking.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public final static String SPELLING_IGNORE_STRING_LITERALS= "spelling_ignore_string_literals"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether non-letters at word boundaries
+        * should be ignored during spell checking.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public final static String SPELLING_IGNORE_NON_LETTERS= "spelling_ignore_non_letters"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls the locale used for spell checking.
+        * <p>
+        * Value is of type <code>String</code>.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public final static String SPELLING_LOCALE= "spelling_locale"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls the number of proposals offered during
+        * spell checking.
+        * <p>
+        * Value is of type <code>Integer</code>.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public final static String SPELLING_PROPOSAL_THRESHOLD= "spelling_proposal_threshold"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls the maximum number of problems reported
+        * during spell checking.
+        * <p>
+        * Value is of type <code>Integer</code>.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public final static String SPELLING_PROBLEMS_THRESHOLD= "spelling_problems_threshold"; //$NON-NLS-1$
+
+       /**
+        * A named preference that specifies the workspace user dictionary.
+        * <p>
+        * Value is of type <code>Integer</code>.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public final static String SPELLING_USER_DICTIONARY= "spelling_user_dictionary"; //$NON-NLS-1$
+
+       /**
+        * A named preference that specifies encoding of the workspace user dictionary.
+        * <p>
+        * Value is of type <code>String</code>.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public final static String SPELLING_USER_DICTIONARY_ENCODING= "spelling_user_dictionary_encoding"; //$NON-NLS-1$
+
+       /**
+        * A named preference that specifies whether spelling dictionaries are available to content assist.
+        *
+        * <strong>Note:</strong> This is currently not supported because the spelling engine
+        * cannot return word proposals but only correction proposals.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public final static String SPELLING_ENABLE_CONTENTASSIST= "spelling_enable_contentassist"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls if documentation comment stubs will be added
+        * automatically to newly created types and methods.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        * @since 5.0
+        */
+       public static final String CODEGEN_ADD_COMMENTS= "org.eclipse.cdt.ui.add_comments"; //$NON-NLS-1$
+
+       /**
+        * A named preference that holds the source hover background color.
+        * <p>
+        * Value is of type <code>String</code>. A RGB color value encoded as a string
+        * using class <code>PreferenceConverter</code>
+        * </p>
+        *
+        * @see org.eclipse.jface.resource.StringConverter
+        * @see org.eclipse.jface.preference.PreferenceConverter
+        * @since 5.0
+        */
+       public final static String EDITOR_SOURCE_HOVER_BACKGROUND_COLOR= "sourceHoverBackgroundColor"; //$NON-NLS-1$
+
+       /**
+        * A named preference that tells whether to use the system
+        * default color ({@link SWT#COLOR_INFO_BACKGROUND}) for
+        * the source hover background color.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @see org.eclipse.jface.resource.StringConverter
+        * @see org.eclipse.jface.preference.PreferenceConverter
+        * @since 5.0
+        */
+       public final static String EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT= "sourceHoverBackgroundColor.SystemDefault"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether occurrences are marked in the editor.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public static final String EDITOR_MARK_OCCURRENCES= "markOccurrences"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether occurrences are sticky in the editor.
+        * Only valid if {@link #EDITOR_MARK_OCCURRENCES} is <code>true</code>.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public static final String EDITOR_STICKY_OCCURRENCES= "stickyOccurrences"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether occurrences of overloaded operators are marked in the editor.
+        * Only valid if {@link #EDITOR_MARK_OCCURRENCES} is <code>true</code>.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        * 
+        * @since 5.3
+        */
+       public static final String EDITOR_MARK_OVERLOADED_OPERATOR_OCCURRENCES= "markOverloadedOperatorsOccurrences"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether all scalability mode options should be turned on.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public static final String SCALABILITY_ENABLE_ALL = "scalability.enableAll"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether the editor's reconciler is disabled.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public static final String SCALABILITY_RECONCILER = "scalability.reconciler"; //$NON-NLS-1$
+       
+       /**
+        * A named preference that controls whether syntax coloring is disabled.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public static final String SCALABILITY_SYNTAX_COLOR = "scalability.syntaxColor"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether parser-based content assist proposals are disabled.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public static final String SCALABILITY_PARSER_BASED_CONTENT_ASSIST = "scalability.parserBasedContentAssist"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls whether users should be notified if scalability mode should be turned on.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public static final String SCALABILITY_ALERT = "scalability.detect"; //$NON-NLS-1$
+       
+       /**
+        * The size of the file that will trigger scalability mode
+        * <p>
+        * Value is of type <code>int</code>.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public static final String SCALABILITY_NUMBER_OF_LINES = "scalability.numberOfLines"; //$NON-NLS-1$
+       
+       /**
+        * A named preference that controls whether syntax coloring is disabled.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public static final String SCALABILITY_SEMANTIC_HIGHLIGHT = "scalability.semanticHighlight"; //$NON-NLS-1$
+       
+       /**
+        * A named preference that controls whether the content assist auto activation is disabled in scalability mode.
+        * <p>
+        * Value is of type <code>Boolean</code>.
+        * </p>
+        *
+        * @since 5.0
+        */
+       public static final String SCALABILITY_CONTENT_ASSIST_AUTO_ACTIVATION = "scalability.contentAssistAutoActivation"; //$NON-NLS-1$
+       
+       /**
+        * A named preference that controls how an include guard symbol is created.
+        * <p>
+        * Value is of type <code>Integer</code>.
+        * </p>
+        *
+        * @since 5.1
+        */
+       public static final String CODE_TEMPLATES_INCLUDE_GUARD_SCHEME = "codetemplates.includeGuardGenerationScheme"; //$NON-NLS-1$
+
+       /**
+        * The value of <code>CODE_TEMPLATES_INCLUDE_GUARD_GENERATION_SCHEME</code>
+        * specifying that the include guard symbol is to be derived from
+        * the include file's name.
+        * 
+        * @since 5.1
+        */
+       public static final int CODE_TEMPLATES_INCLUDE_GUARD_SCHEME_FILE_NAME = 0;
+       
+       /**
+        * The value of <code>CODE_TEMPLATES_INCLUDE_GUARD_GENERATION_SCHEME</code>
+        * specifying that the include guard symbol is to be derived from a UUID.
+        * 
+        * @since 5.1
+        */
+       public static final int CODE_TEMPLATES_INCLUDE_GUARD_SCHEME_UUID = 1;
+       
+       /**
+        * The value of <code>CODE_TEMPLATES_INCLUDE_GUARD_GENERATION_SCHEME</code>
+        * specifying that the include guard symbol is to be derived from
+        * the include file's path relative to the source folder.
+        * 
+        * @since 5.2
+        */
+       public static final int CODE_TEMPLATES_INCLUDE_GUARD_SCHEME_FILE_PATH = 2;
+
+       /**
+        * A named preference that controls how capitalization of a constant name.
+        * <p>
+        * Value is of type <code>Integer</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_CONSTANT_CAPITALIZATION = "nameStyle.constant.capitalization"; //$NON-NLS-1$
+       /**
+        * A named preference that controls prefix of a constant name.
+        * <p>
+        * Value is of type <code>String</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_CONSTANT_PREFIX = "nameStyle.constant.prefix"; //$NON-NLS-1$
+       /**
+        * A named preference that controls suffix of a constant name.
+        * <p>
+        * Value is of type <code>String</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_CONSTANT_SUFFIX = "nameStyle.constant.suffix"; //$NON-NLS-1$
+       /**
+        * A named preference that controls delimiter that is inserted between words
+        * of a constant name.
+        * <p>
+        * Value is of type <code>String</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_CONSTANT_WORD_DELIMITER = "nameStyle.constant.wordDelimiter"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls how capitalization of a variable name.
+        * <p>
+        * Value is of type <code>Integer</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_VARIABLE_CAPITALIZATION = "nameStyle.variable.capitalization"; //$NON-NLS-1$
+       /**
+        * A named preference that controls prefix of a variable name.
+        * <p>
+        * Value is of type <code>String</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_VARIABLE_PREFIX = "nameStyle.variable.prefix"; //$NON-NLS-1$
+       /**
+        * A named preference that controls suffix of a variable name.
+        * <p>
+        * Value is of type <code>String</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_VARIABLE_SUFFIX = "nameStyle.variable.suffix"; //$NON-NLS-1$
+       /**
+        * A named preference that controls delimiter that is inserted between words
+        * of a variable name.
+        * <p>
+        * Value is of type <code>String</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_VARIABLE_WORD_DELIMITER = "nameStyle.variable.wordDelimiter"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls how capitalization of a field name.
+        * <p>
+        * Value is of type <code>Integer</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_FIELD_CAPITALIZATION = "nameStyle.field.capitalization"; //$NON-NLS-1$
+       /**
+        * A named preference that controls prefix of a field name.
+        * <p>
+        * Value is of type <code>String</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_FIELD_PREFIX = "nameStyle.field.prefix"; //$NON-NLS-1$
+       /**
+        * A named preference that controls suffix of a field name.
+        * <p>
+        * Value is of type <code>String</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_FIELD_SUFFIX = "nameStyle.field.suffix"; //$NON-NLS-1$
+       /**
+        * A named preference that controls delimiter that is inserted between words
+        * of a field name.
+        * <p>
+        * Value is of type <code>String</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_FIELD_WORD_DELIMITER = "nameStyle.field.wordDelimiter"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls how capitalization of the getter name
+        * depends on capitalization of the field name.
+        * <p>
+        * Value is of type <code>Integer</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_GETTER_CAPITALIZATION = "nameStyle.getter.capitalization"; //$NON-NLS-1$
+       /**
+        * A named preference that controls prefix of the getter name.
+        * <p>
+        * Value is of type <code>String</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_GETTER_PREFIX = "nameStyle.getter.prefix"; //$NON-NLS-1$
+       /**
+        * A named preference that controls prefix of the getter name for a boolean field.
+        * <p>
+        * Value is of type <code>String</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_GETTER_PREFIX_FOR_BOOLEAN = "nameStyle.getter.prefixForBoolean"; //$NON-NLS-1$
+       /**
+        * A named preference that controls suffix of the getter name.
+        * <p>
+        * Value is of type <code>String</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_GETTER_SUFFIX = "nameStyle.getter.suffix"; //$NON-NLS-1$
+       /**
+        * A named preference that controls delimiter that is inserted between words
+        * when composing the getter name from the field name.
+        * <p>
+        * Value is of type <code>String</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_GETTER_WORD_DELIMITER = "nameStyle.getter.wordDelimiter"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls how capitalization of the setter name
+        * depends on capitalization of the field name.
+        * <p>
+        * Value is of type <code>Integer</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_SETTER_CAPITALIZATION = "nameStyle.setter.capitalization"; //$NON-NLS-1$
+       /**
+        * A named preference that controls prefix of the setter name.
+        * <p>
+        * Value is of type <code>String</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_SETTER_PREFIX = "nameStyle.setter.prefix"; //$NON-NLS-1$
+       /**
+        * A named preference that controls suffix of the setter name.
+        * <p>
+        * Value is of type <code>String</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_SETTER_SUFFIX = "nameStyle.setter.suffix"; //$NON-NLS-1$
+       /**
+        * A named preference that controls delimiter that is inserted between words
+        * when composing the setter name from the field name.
+        * <p>
+        * Value is of type <code>String</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_SETTER_WORD_DELIMITER = "nameStyle.setter.wordDelimiter"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls how capitalization of the C++ source file name
+        * depends on capitalization of the class name.
+        * <p>
+        * Value is of type <code>Integer</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_CPP_SOURCE_CAPITALIZATION = "nameStyle.cpp.source.capitalization"; //$NON-NLS-1$
+       /**
+        * A named preference that controls prefix of the C++ source file name.
+        * <p>
+        * Value is of type <code>String</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_CPP_SOURCE_PREFIX = "nameStyle.cpp.source.prefix"; //$NON-NLS-1$
+       /**
+        * A named preference that controls suffix of the C++ source file name.
+        * <p>
+        * Value is of type <code>String</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_CPP_SOURCE_SUFFIX = "nameStyle.cpp.source.suffix"; //$NON-NLS-1$
+       /**
+        * A named preference that controls delimiter that is inserted between words
+        * when composing the C++ source file name from the class name.
+        * <p>
+        * Value is of type <code>String</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_CPP_SOURCE_WORD_DELIMITER = "nameStyle.cpp.source.wordDelimiter"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls how capitalization of the C++ header file name
+        * depends on capitalization of the class name.
+        * <p>
+        * Value is of type <code>Integer</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_CPP_HEADER_CAPITALIZATION = "nameStyle.cpp.header.capitalization"; //$NON-NLS-1$
+       /**
+        * A named preference that controls prefix of the C++ header file name.
+        * <p>
+        * Value is of type <code>String</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_CPP_HEADER_PREFIX = "nameStyle.cpp.header.prefix"; //$NON-NLS-1$
+       /**
+        * A named preference that controls suffix of the C++ header file name.
+        * <p>
+        * Value is of type <code>String</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_CPP_HEADER_SUFFIX = "nameStyle.cpp.header.suffix"; //$NON-NLS-1$
+       /**
+        * A named preference that controls delimiter that is inserted between words
+        * when composing the C++ header file name from the class name.
+        * <p>
+        * Value is of type <code>String</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_CPP_HEADER_WORD_DELIMITER = "nameStyle.cpp.header.wordDelimiter"; //$NON-NLS-1$
+
+       /**
+        * A named preference that controls how capitalization of the C++ test file name
+        * depends on capitalization of the class name.
+        * <p>
+        * Value is of type <code>Integer</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_CPP_TEST_CAPITALIZATION = "nameStyle.cpp.test.capitalization"; //$NON-NLS-1$
+       /**
+        * A named preference that controls prefix of the C++ test file name.
+        * <p>
+        * Value is of type <code>String</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_CPP_TEST_PREFIX = "nameStyle.cpp.test.prefix"; //$NON-NLS-1$
+       /**
+        * A named preference that controls suffix of the C++ test file name.
+        * <p>
+        * Value is of type <code>String</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_CPP_TEST_SUFFIX = "nameStyle.cpp.test.suffix"; //$NON-NLS-1$
+       /**
+        * A named preference that controls delimiter that is inserted between words
+        * when composing the C++ test file name from the class name.
+        * <p>
+        * Value is of type <code>String</code>.
+        * 
+        * @since 5.3
+        */
+       public static final String NAME_STYLE_CPP_TEST_WORD_DELIMITER = "nameStyle.cpp.test.wordDelimiter"; //$NON-NLS-1$
+
+       /**
+        * The value of <code>NAME_STYLE_*_CAPITALIZATION</code> specifying that the name
+        * is to be derived from the class or the variable name without changing
+        * capitalization.
+        * 
+        * @since 5.3
+        */
+       public static final int NAME_STYLE_CAPITALIZATION_ORIGINAL = 0;
+       /**
+        * The value of <code>NAME_STYLE_*_CAPITALIZATION</code> specifying that the name
+        * is to be derived from the class or the variable name by converting it to upper
+        * case.
+        * 
+        * @since 5.3
+        */
+       public static final int NAME_STYLE_CAPITALIZATION_UPPER_CASE = 1;
+       /**
+        * The value of <code>NAME_STYLE_*_CAPITALIZATION</code> specifying that the name
+        * is to be derived from the class or the variable name by converting it to lower
+        * case.
+        * 
+        * @since 5.3
+        */
+       public static final int NAME_STYLE_CAPITALIZATION_LOWER_CASE = 2;
+       /**
+        * The value of <code>NAME_STYLE_*_CAPITALIZATION</code> specifying that the name
+        * is to be derived from the class or the variable name by capitalizing first
+        * letter of every word.
+        * 
+        * @since 5.3
+        */
+       public static final int NAME_STYLE_CAPITALIZATION_CAMEL_CASE = 3;
+       /**
+        * The value of <code>NAME_STYLE_*_CAPITALIZATION</code> specifying that the name
+        * is to be derived from the class or the variable name by capitalizing first
+        * letter of every word except the first one.
+        * 
+        * @since 5.3
+        */
+       public static final int NAME_STYLE_CAPITALIZATION_LOWER_CAMEL_CASE = 4;
+       
+       /**
+        * Returns the CDT-UI preference store.
+        *
+        * @return the CDT-UI preference store
+        */
+       public static IPreferenceStore getPreferenceStore() {
+               return CUIPlugin.getDefault().getPreferenceStore();
+       }
+
+    /**
+     * Initializes the given preference store with the default values.
+     *
+     * @param store the preference store to be initialized
+     */
+    public static void initializeDefaultValues(IPreferenceStore store) {
+               ColorRegistry registry= PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry();
+
+               store.setDefault(PreferenceConstants.EDITOR_CORRECTION_INDICATION, false);
+               store.setDefault(PreferenceConstants.EDITOR_SHOW_SEGMENTS, false);
+               store.setDefault(PreferenceConstants.PREF_SHOW_CU_CHILDREN, true);
+
+               // This option has to be turned on for the spelling checker too work.
+               store.setDefault(PreferenceConstants.EDITOR_EVALUATE_TEMPORARY_PROBLEMS, true);
+
+               int sourceHoverModifier= SWT.MOD2;
+               String sourceHoverModifierName= Action.findModifierString(sourceHoverModifier); // Shift
+               store.setDefault(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS, "org.eclipse.cdt.ui.BestMatchHover;0;org.eclipse.cdt.ui.CSourceHover;" + sourceHoverModifierName); //$NON-NLS-1$
+               store.setDefault(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS, "org.eclipse.cdt.ui.BestMatchHover;0;org.eclipse.cdt.ui.CSourceHover;" + sourceHoverModifier); //$NON-NLS-1$
+
+               store.setDefault(EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT, true);
+
+               // Coloring
+               PreferenceConverter.setDefault(store, EDITOR_MULTI_LINE_COMMENT_COLOR, new RGB(63, 127, 95));
+               store.setDefault(EDITOR_MULTI_LINE_COMMENT_BOLD, false);
+               store.setDefault(EDITOR_MULTI_LINE_COMMENT_ITALIC, false);
+
+               PreferenceConverter.setDefault(store, EDITOR_SINGLE_LINE_COMMENT_COLOR, new RGB(63, 127, 95));
+               store.setDefault(EDITOR_SINGLE_LINE_COMMENT_BOLD, false);
+               store.setDefault(EDITOR_SINGLE_LINE_COMMENT_ITALIC, false);
+
+        PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_TASK_TAG_COLOR, new RGB(127, 159, 191));
+        store.setDefault(PreferenceConstants.EDITOR_TASK_TAG_BOLD, true);
+        store.setDefault(PreferenceConstants.EDITOR_TASK_TAG_ITALIC, false);
+
+        PreferenceConverter.setDefault(store, EDITOR_C_KEYWORD_COLOR, new RGB(127, 0, 85));
+               store.setDefault(EDITOR_C_KEYWORD_BOLD, true);
+               store.setDefault(EDITOR_C_KEYWORD_ITALIC, false);
+
+               PreferenceConverter.setDefault(store, EDITOR_C_BUILTIN_TYPE_COLOR, new RGB(127, 0, 85));
+               store.setDefault(EDITOR_C_BUILTIN_TYPE_BOLD, true);
+               store.setDefault(EDITOR_C_BUILTIN_TYPE_ITALIC, false);
+
+               PreferenceConverter.setDefault(store, EDITOR_C_STRING_COLOR, new RGB(42, 0, 255));
+               store.setDefault(EDITOR_C_STRING_BOLD, false);
+               store.setDefault(EDITOR_C_STRING_ITALIC, false);
+
+               PreferenceConverter.setDefault(store, EDITOR_C_DEFAULT_COLOR, new RGB(0, 0, 0));
+               store.setDefault(EDITOR_C_DEFAULT_BOLD, false);
+               store.setDefault(EDITOR_C_DEFAULT_ITALIC, false);
+
+        PreferenceConverter.setDefault(store, EDITOR_C_OPERATOR_COLOR, new RGB(0, 0, 0));
+        store.setDefault(EDITOR_C_OPERATOR_BOLD, false);
+        store.setDefault(EDITOR_C_OPERATOR_ITALIC, false);
+
+        PreferenceConverter.setDefault(store, EDITOR_C_BRACES_COLOR, new RGB(0, 0, 0));
+        store.setDefault(EDITOR_C_BRACES_BOLD, false);
+        store.setDefault(EDITOR_C_BRACES_ITALIC, false);
+
+        PreferenceConverter.setDefault(store, EDITOR_C_NUMBER_COLOR, new RGB(0, 0, 0));
+        store.setDefault(EDITOR_C_NUMBER_BOLD, false);
+        store.setDefault(EDITOR_C_NUMBER_ITALIC, false);
+
+        PreferenceConverter.setDefault(store, EDITOR_PP_DIRECTIVE_COLOR, new RGB(127, 0, 85));
+               store.setDefault(EDITOR_PP_DIRECTIVE_BOLD, true);
+               store.setDefault(EDITOR_PP_DIRECTIVE_ITALIC, false);
+
+        PreferenceConverter.setDefault(store, EDITOR_PP_HEADER_COLOR, new RGB(42, 0, 255));
+        store.setDefault(EDITOR_PP_HEADER_BOLD, false);
+        store.setDefault(EDITOR_PP_HEADER_ITALIC, false);
+
+        PreferenceConverter.setDefault(store, EDITOR_PP_DEFAULT_COLOR, new RGB(0, 0, 0));
+        store.setDefault(EDITOR_PP_DEFAULT_BOLD, false);
+        store.setDefault(EDITOR_PP_DEFAULT_ITALIC, false);
+
+        PreferenceConverter.setDefault(store, EDITOR_ASM_LABEL_COLOR, new RGB(127, 0, 85));
+               store.setDefault(EDITOR_ASM_LABEL_BOLD, true);
+               store.setDefault(EDITOR_ASM_LABEL_ITALIC, false);
+
+        PreferenceConverter.setDefault(store, EDITOR_ASM_DIRECTIVE_COLOR, new RGB(127, 0, 85));
+               store.setDefault(EDITOR_ASM_DIRECTIVE_BOLD, true);
+               store.setDefault(EDITOR_ASM_DIRECTIVE_ITALIC, false);
+
+               // Folding
+               store.setDefault(PreferenceConstants.EDITOR_FOLDING_ENABLED, false);
+               store.setDefault(PreferenceConstants.EDITOR_FOLDING_PROVIDER, "org.eclipse.cdt.ui.text.defaultFoldingProvider"); //$NON-NLS-1$
+               store.setDefault(PreferenceConstants.EDITOR_FOLDING_FUNCTIONS, false);
+               store.setDefault(PreferenceConstants.EDITOR_FOLDING_STRUCTURES, true);
+               store.setDefault(PreferenceConstants.EDITOR_FOLDING_METHODS, false);
+               store.setDefault(PreferenceConstants.EDITOR_FOLDING_MACROS, true);
+               store.setDefault(PreferenceConstants.EDITOR_FOLDING_COMMENTS, false);
+               store.setDefault(PreferenceConstants.EDITOR_FOLDING_HEADERS, true);
+               store.setDefault(PreferenceConstants.EDITOR_FOLDING_INACTIVE_CODE, true);
+               store.setDefault(PreferenceConstants.EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED, false);
+
+               // Smart edit
+               store.setDefault(PreferenceConstants.EDITOR_CLOSE_STRINGS, true);
+               store.setDefault(PreferenceConstants.EDITOR_CLOSE_BRACKETS, true);
+               store.setDefault(PreferenceConstants.EDITOR_CLOSE_ANGULAR_BRACKETS, true);
+               store.setDefault(PreferenceConstants.EDITOR_CLOSE_BRACES, true);
+               store.setDefault(PreferenceConstants.EDITOR_SMART_PASTE, true);
+               store.setDefault(PreferenceConstants.EDITOR_SMART_TAB, true);
+               store.setDefault(PreferenceConstants.EDITOR_WRAP_STRINGS, true);
+               store.setDefault(PreferenceConstants.EDITOR_ESCAPE_STRINGS, false);
+               store.setDefault(PreferenceConstants.EDITOR_AUTO_INDENT, true);
+
+               store.setDefault(PreferenceConstants.REMOVE_TRAILING_WHITESPACE, true);
+               store.setDefault(PreferenceConstants.REMOVE_TRAILING_WHITESPACE_LIMIT_TO_EDITED_LINES, true);
+               store.setDefault(PreferenceConstants.ENSURE_NEWLINE_AT_EOF, true);
+
+               // Formatter profile
+               store.setDefault(PreferenceConstants.FORMATTER_PROFILE, FormatterProfileManager.DEFAULT_PROFILE);
+               
+               // Content assist
+               store.setDefault(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES, "org.eclipse.cdt.ui.textProposalCategory\0"); //$NON-NLS-1$
+               store.setDefault(PreferenceConstants.CODEASSIST_CATEGORY_ORDER, "org.eclipse.cdt.ui.parserProposalCategory:65539\0org.eclipse.cdt.ui.textProposalCategory:65541\0org.eclipse.cdt.ui.templateProposalCategory:2\0org.eclipse.cdt.ui.helpProposalCategory:5\0"); //$NON-NLS-1$
+
+               setDefaultAndFireEvent(
+                               store,
+                               PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND,
+                               findRGB(registry, ICThemeConstants.CODEASSIST_PROPOSALS_BACKGROUND, new RGB(255, 255, 255)));
+               setDefaultAndFireEvent(
+                               store,
+                               PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND,
+                               findRGB(registry, ICThemeConstants.CODEASSIST_PROPOSALS_FOREGROUND, new RGB(0, 0, 0)));
+               setDefaultAndFireEvent(
+                               store,
+                               PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND,
+                               findRGB(registry, ICThemeConstants.CODEASSIST_PARAMETERS_BACKGROUND, new RGB(255, 255, 255)));
+               setDefaultAndFireEvent(
+                               store,
+                               PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND,
+                               findRGB(registry, ICThemeConstants.CODEASSIST_PARAMETERS_FOREGROUND, new RGB(0, 0, 0)));
+
+               // Refactoring.
+               store.setDefault(PreferenceConstants.REFACTOR_SAVE_ALL_EDITORS, false);
+               store.setDefault(PreferenceConstants.REFACTOR_LIGHTWEIGHT, true);
+
+               // Spell checking
+               store.setDefault(PreferenceConstants.SPELLING_LOCALE, "en_US"); //$NON-NLS-1$
+               String isInitializedKey= "spelling_locale_initialized"; //$NON-NLS-1$
+               if (!store.getBoolean(isInitializedKey)) {
+                       store.setValue(isInitializedKey, true);
+                       Locale locale= SpellCheckEngine.getDefaultLocale();
+                       locale= SpellCheckEngine.findClosestLocale(locale);
+                       if (locale != null)
+                               store.setValue(PreferenceConstants.SPELLING_LOCALE, locale.toString());
+               }
+               store.setDefault(PreferenceConstants.SPELLING_IGNORE_DIGITS, true);
+               store.setDefault(PreferenceConstants.SPELLING_IGNORE_MIXED, true);
+               store.setDefault(PreferenceConstants.SPELLING_IGNORE_SENTENCE, true);
+               store.setDefault(PreferenceConstants.SPELLING_IGNORE_UPPER, true);
+               store.setDefault(PreferenceConstants.SPELLING_IGNORE_URLS, true);
+               store.setDefault(PreferenceConstants.SPELLING_IGNORE_SINGLE_LETTERS, true);
+               store.setDefault(PreferenceConstants.SPELLING_IGNORE_STRING_LITERALS, false);
+               store.setDefault(PreferenceConstants.SPELLING_IGNORE_NON_LETTERS, true);
+               store.setDefault(PreferenceConstants.SPELLING_USER_DICTIONARY, ""); //$NON-NLS-1$
+
+               // Note: For backwards compatibility we must use the property and not the workspace default
+               store.setDefault(PreferenceConstants.SPELLING_USER_DICTIONARY_ENCODING,
+                               System.getProperty("file.encoding")); //$NON-NLS-1$
+
+               store.setDefault(PreferenceConstants.SPELLING_PROPOSAL_THRESHOLD, 20);
+               store.setDefault(PreferenceConstants.SPELLING_PROBLEMS_THRESHOLD, 100);
+               /*
+                * TODO: This is currently disabled because the spelling engine
+                * cannot return word proposals but only correction proposals.
+                */
+               store.setToDefault(PreferenceConstants.SPELLING_ENABLE_CONTENTASSIST);
+
+               // codegen
+               store.setDefault(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);
+               
+               // mark occurrences
+               store.setDefault(PreferenceConstants.EDITOR_MARK_OCCURRENCES, true);
+               store.setDefault(PreferenceConstants.EDITOR_MARK_OVERLOADED_OPERATOR_OCCURRENCES, false);
+               store.setDefault(PreferenceConstants.EDITOR_STICKY_OCCURRENCES, true);
+               
+               // Scalability
+               store.setDefault(PreferenceConstants.SCALABILITY_ALERT, true);
+               store.setDefault(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES, 5000);
+               store.setDefault(PreferenceConstants.SCALABILITY_ENABLE_ALL, false);
+               store.setDefault(PreferenceConstants.SCALABILITY_RECONCILER, true);
+               store.setDefault(PreferenceConstants.SCALABILITY_SYNTAX_COLOR, false);
+               store.setDefault(PreferenceConstants.SCALABILITY_SEMANTIC_HIGHLIGHT, false);
+               store.setDefault(PreferenceConstants.SCALABILITY_PARSER_BASED_CONTENT_ASSIST, false);
+               store.setDefault(PreferenceConstants.SCALABILITY_CONTENT_ASSIST_AUTO_ACTIVATION, false);
+               
+               // Code Templates
+               store.setDefault(PreferenceConstants.CODE_TEMPLATES_INCLUDE_GUARD_SCHEME,
+                               CODE_TEMPLATES_INCLUDE_GUARD_SCHEME_FILE_NAME);
+
+               // Name Style
+               store.setDefault(NAME_STYLE_CONSTANT_CAPITALIZATION, NAME_STYLE_CAPITALIZATION_UPPER_CASE);
+               store.setDefault(NAME_STYLE_CONSTANT_PREFIX, ""); //$NON-NLS-1$
+               store.setDefault(NAME_STYLE_CONSTANT_SUFFIX, ""); //$NON-NLS-1$
+               store.setDefault(NAME_STYLE_CONSTANT_WORD_DELIMITER, "_"); //$NON-NLS-1$
+               store.setDefault(NAME_STYLE_VARIABLE_CAPITALIZATION, NAME_STYLE_CAPITALIZATION_LOWER_CAMEL_CASE);
+               store.setDefault(NAME_STYLE_VARIABLE_PREFIX, ""); //$NON-NLS-1$
+               store.setDefault(NAME_STYLE_VARIABLE_SUFFIX, ""); //$NON-NLS-1$
+               store.setDefault(NAME_STYLE_VARIABLE_WORD_DELIMITER, ""); //$NON-NLS-1$
+               store.setDefault(NAME_STYLE_FIELD_CAPITALIZATION, NAME_STYLE_CAPITALIZATION_LOWER_CAMEL_CASE);
+               store.setDefault(NAME_STYLE_FIELD_PREFIX, ""); //$NON-NLS-1$
+               store.setDefault(NAME_STYLE_FIELD_SUFFIX, ""); //$NON-NLS-1$
+               store.setDefault(NAME_STYLE_FIELD_WORD_DELIMITER, ""); //$NON-NLS-1$
+               store.setDefault(NAME_STYLE_GETTER_CAPITALIZATION, NAME_STYLE_CAPITALIZATION_CAMEL_CASE);
+               store.setDefault(NAME_STYLE_GETTER_PREFIX, "get"); //$NON-NLS-1$
+               store.setDefault(NAME_STYLE_GETTER_PREFIX_FOR_BOOLEAN, "is"); //$NON-NLS-1$
+               store.setDefault(NAME_STYLE_GETTER_SUFFIX, ""); //$NON-NLS-1$
+               store.setDefault(NAME_STYLE_GETTER_WORD_DELIMITER, ""); //$NON-NLS-1$
+               store.setDefault(NAME_STYLE_SETTER_CAPITALIZATION, NAME_STYLE_CAPITALIZATION_CAMEL_CASE);
+               store.setDefault(NAME_STYLE_SETTER_PREFIX, "set"); //$NON-NLS-1$
+               store.setDefault(NAME_STYLE_SETTER_SUFFIX, ""); //$NON-NLS-1$
+               store.setDefault(NAME_STYLE_SETTER_WORD_DELIMITER, ""); //$NON-NLS-1$
+               store.setDefault(NAME_STYLE_CPP_HEADER_CAPITALIZATION, NAME_STYLE_CAPITALIZATION_ORIGINAL);
+               store.setDefault(NAME_STYLE_CPP_HEADER_PREFIX, ""); //$NON-NLS-1$
+               store.setDefault(NAME_STYLE_CPP_HEADER_SUFFIX, ".h"); //$NON-NLS-1$
+               store.setDefault(NAME_STYLE_CPP_HEADER_WORD_DELIMITER, ""); //$NON-NLS-1$
+               store.setDefault(NAME_STYLE_CPP_SOURCE_CAPITALIZATION, NAME_STYLE_CAPITALIZATION_ORIGINAL);
+               store.setDefault(NAME_STYLE_CPP_SOURCE_PREFIX, ""); //$NON-NLS-1$
+               store.setDefault(NAME_STYLE_CPP_SOURCE_SUFFIX, ".cpp"); //$NON-NLS-1$
+               store.setDefault(NAME_STYLE_CPP_SOURCE_WORD_DELIMITER, ""); //$NON-NLS-1$
+               store.setDefault(NAME_STYLE_CPP_TEST_CAPITALIZATION, NAME_STYLE_CAPITALIZATION_ORIGINAL);
+               store.setDefault(NAME_STYLE_CPP_TEST_PREFIX, ""); //$NON-NLS-1$
+               store.setDefault(NAME_STYLE_CPP_TEST_SUFFIX, "_test.cpp"); //$NON-NLS-1$
+               store.setDefault(NAME_STYLE_CPP_TEST_WORD_DELIMITER, ""); //$NON-NLS-1$
+    }
+
+    /**
+     * Returns the node in the preference in the given context.
+     * @param key The preference key.
+     * @param project The current context or <code>null</code> if no context is available and the
+        * workspace setting should be taken. Note that passing <code>null</code> should
+        * be avoided.
+     * @return Returns the node matching the given context.
+     */
+       private static IEclipsePreferences getPreferenceNode(String key, ICProject project) {
+               IEclipsePreferences node = null;
+               
+               if (project != null) {
+                       node = new ProjectScope(project.getProject()).getNode(CUIPlugin.PLUGIN_ID);
+                       if (node.get(key, null) != null) {
+                               return node;
+                       }
+               }
+               node = InstanceScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID);
+               if (node.get(key, null) != null) {
+                       return node;
+               }
+               
+               return DefaultScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID);
+       }
+
+       /**
+        * Returns the string value for the given key in the given context.
+        * @param key The preference key
+        * @param project The current context or <code>null</code> if no context is available and the
+        * workspace setting should be taken. Note that passing <code>null</code> should
+        * be avoided.
+        * @return Returns the current value for the string.
+        * @since 5.0
+        */
+       public static String getPreference(String key, ICProject project) {
+               return getPreferenceNode(key, project).get(key, null);
+       }
+
+       /**
+        * Returns the integer value for the given key in the given context.
+        * @param key The preference key
+        * @param project The current context or <code>null</code> if no context is available and the
+        * workspace setting should be taken. Note that passing <code>null</code> should
+        * be avoided.
+        * @param defaultValue The default value if not specified in the preferences.
+        * @return Returns the current value for the string.
+        * @since 5.1
+        */
+       public static int getPreference(String key, ICProject project, int defaultValue) {
+               return getPreferenceNode(key, project).getInt(key, defaultValue);
+       }
+
+       /**
+        * Returns the boolean value for the given key in the given context.
+        * @param key The preference key
+        * @param project The current context or <code>null</code> if no context is available and the
+        * workspace setting should be taken. Note that passing <code>null</code> should
+        * be avoided.
+        * @param defaultValue The default value if not specified in the preferences.
+        * @return Returns the current value for the string.
+        * @since 5.1
+        */
+       public static boolean getPreference(String key, ICProject project, boolean defaultValue) {
+               return getPreferenceNode(key, project).getBoolean(key, defaultValue);
+       }
+
+       /**
+        * Sets the default value and fires a property
+        * change event if necessary.
+        *
+        * @param store the preference store
+        * @param key the preference key
+        * @param newValue the new value
+        * @since 5.0
+        */
+       private static void setDefaultAndFireEvent(IPreferenceStore store, String key, RGB newValue) {
+               RGB oldValue= null;
+               if (store.isDefault(key))
+                       oldValue= PreferenceConverter.getDefaultColor(store, key);
+
+               PreferenceConverter.setDefault(store, key, newValue);
+
+               if (oldValue != null && !oldValue.equals(newValue))
+                       store.firePropertyChangeEvent(key, oldValue, newValue);
+       }
+
+       /**
+        * Returns the RGB for the given key in the given color registry.
+        *
+        * @param registry the color registry
+        * @param key the key for the constant in the registry
+        * @param defaultRGB the default RGB if no entry is found
+        * @return RGB the RGB
+        * @since 5.0
+        */
+       private static RGB findRGB(ColorRegistry registry, String key, RGB defaultRGB) {
+               RGB rgb= registry.getRGB(key);
+               if (rgb != null)
+                       return rgb;
+               return defaultRGB;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/BuildActiveConfigMenuAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/BuildActiveConfigMenuAction.java
new file mode 100644 (file)
index 0000000..15a2c6d
--- /dev/null
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Nokia and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Nokia - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.actions;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.events.MenuAdapter;
+import org.eclipse.swt.events.MenuEvent;
+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.actions.BuildAction;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener;
+import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
+
+import org.eclipse.cdt.internal.ui.actions.ActionMessages;
+import org.eclipse.cdt.internal.ui.cview.BuildGroup;
+
+/**
+ * Implements a toolbar button that builds the active configuration
+ * of selected projects. Also includes a menu that builds any of the
+ * other configurations.
+ */
+public class BuildActiveConfigMenuAction extends ChangeBuildConfigActionBase
+               implements IWorkbenchWindowPulldownDelegate2, ICProjectDescriptionListener {
+
+       private BuildAction buildaction;
+       private IAction actionMenuCache; // cache the menu action so we can update the tool tip when the configuration changes
+
+       /**
+        * @see org.eclipse.ui.IWorkbenchWindowPulldownDelegate2#getMenu(org.eclipse.swt.widgets.Menu)
+        */
+       public Menu getMenu(Menu parent) {
+               Menu menu = new Menu(parent);
+               addMenuListener(menu);
+               return menu;
+       }
+
+       /**
+        * @see org.eclipse.ui.IWorkbenchWindowPulldownDelegate#getMenu(org.eclipse.swt.widgets.Control)
+        */
+       public Menu getMenu(Control parent) {
+               Menu menu = new Menu(parent);
+               addMenuListener(menu);
+               return menu;
+       }
+
+       /**
+        * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
+        */
+       public void dispose() {
+               ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
+               mngr.removeCProjectDescriptionListener(this);
+       }
+
+       /**
+        * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
+        */
+       public void init(IWorkbenchWindow window) {
+               buildaction = new BuildGroup.CDTBuildAction(window, IncrementalProjectBuilder.INCREMENTAL_BUILD);
+               ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
+               mngr.addCProjectDescriptionListener(this, CProjectDescriptionEvent.APPLIED);
+       }
+
+       /**
+        * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+        */
+       public void run(IAction action) {
+               buildaction.selectionChanged(new StructuredSelection(fProjects.toArray()));
+               buildaction.run();
+       }
+
+       /**
+        * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+        */
+       public void selectionChanged(IAction action, ISelection selection) {
+               if (actionMenuCache == null){
+                       actionMenuCache = action;
+               }
+               onSelectionChanged(action, selection);
+               updateBuildConfigMenuToolTip(action);
+       }
+       
+       /**
+        * Adds a listener to the given menu to re-populate it each time is is shown
+        * @param menu The menu to add listener to
+        */
+       private void addMenuListener(Menu menu) {
+               menu.addMenuListener(new MenuAdapter() {
+                       @Override
+                       public void menuShown(MenuEvent e) {
+                               fillMenu((Menu)e.widget);
+                       }
+               });
+       }
+
+       @Override
+       protected IAction makeAction(String sName, StringBuffer builder, int accel) {
+               return new BuildConfigAction(fProjects, sName, builder.toString(), accel + 1, buildaction);
+       }
+       
+       /**
+        * Update the tool tip based on the currently selected project and active configuration.
+        * @param action - The build configuration menu to change the tool tip on
+        */
+       public void updateBuildConfigMenuToolTip(IAction action){
+               String toolTipText = ""; //$NON-NLS-1$
+               if (fProjects.size() <= 5) {
+                       StringBuilder sb = new StringBuilder();
+                       for (IProject prj : fProjects) {
+                               if (prj != null){
+                                       ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(prj, false);
+                                       if (prjd != null) {
+                                               sb.append(NLS.bind(ActionMessages.BuildActiveConfigMenuAction_buildConfigTooltip,
+                                                               prjd.getActiveConfiguration().getName(), prj.getName())).append(System.getProperty("line.separator")); //$NON-NLS-1$
+                                       }
+                               }
+                       }
+                       toolTipText = sb.toString().trim();
+               }
+               if (toolTipText.length() == 0)
+                       toolTipText = ActionMessages.BuildActiveConfigMenuAction_defaultTooltip;
+               action.setToolTipText(toolTipText);
+       }
+
+       public void handleEvent(CProjectDescriptionEvent event) {
+               if (actionMenuCache != null){
+                       updateBuildConfigMenuToolTip(actionMenuCache);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/BuildConfigAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/BuildConfigAction.java
new file mode 100644 (file)
index 0000000..d24da23
--- /dev/null
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Nokia and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Nokia - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.actions;
+
+import java.util.HashSet;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.actions.BuildAction;
+
+/**
+ * Action which builds the active configurations of the selected projects.
+ */
+public class BuildConfigAction extends ChangeConfigAction {
+       
+       private BuildAction buildAction;
+
+       /**
+        * Constructs the action.
+        * @param projects List of selected managed-built projects 
+        * @param configName Build configuration name
+        * @param accel Number to be used as accelerator
+        */
+       public BuildConfigAction(HashSet<IProject> projects, String configName, String displayName, int accel, BuildAction buildAction) {
+               super(projects, configName, displayName, accel);
+               this.buildAction = buildAction;
+       }
+       
+       /**
+        * @see org.eclipse.jface.action.IAction#run()
+        */
+       @Override
+       public void run() {
+               super.run();
+               buildAction.selectionChanged(new StructuredSelection(fProjects.toArray()));
+               buildAction.run();              
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/CdtActionConstants.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/CdtActionConstants.java
new file mode 100644 (file)
index 0000000..3bc790a
--- /dev/null
@@ -0,0 +1,481 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.actions;
+
+/**
+ * Action ids for standard actions, for groups in the menu bar, and
+ * for actions in context menus of CDT views.
+ * 
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ * @since 2.0
+ */
+public class CdtActionConstants {
+
+       // Navigate menu
+       
+       /**
+        * Navigate menu: name of standard Goto Type global action
+        * (value <code>"org.eclipse.cdt.ui.actions.GoToType"</code>).
+        */
+       public static final String GOTO_TYPE= "org.eclipse.cdt.ui.actions.GoToType"; //$NON-NLS-1$
+       
+       /**
+        * Navigate menu: name of standard Open Super Implementation global action
+        * (value <code>"org.eclipse.cdt.ui.actions.OpenSuperImplementation"</code>).
+        */
+       public static final String OPEN_SUPER_IMPLEMENTATION= "org.eclipse.cdt.ui.actions.OpenSuperImplementation"; //$NON-NLS-1$
+       
+    /**
+     * Navigate menu: name of standard Open Declaration global action
+     * (value <code>"org.eclipse.cdt.ui.actions.OpenDeclaration"</code>).
+     * @since 5.0
+     */
+    public static final String OPEN_DECLARATION= "org.eclipse.cdt.ui.actions.OpenDeclaration"; //$NON-NLS-1$
+
+       /**
+        * Navigate menu: name of standard Open Type Hierarchy global action
+        * (value <code>"org.eclipse.cdt.ui.actions.OpenTypeHierarchy"</code>).
+        */
+       public static final String OPEN_TYPE_HIERARCHY= "org.eclipse.cdt.ui.actions.OpenTypeHierarchy"; //$NON-NLS-1$
+
+    /**
+     * Navigate menu: name of standard Open Call Hierarchy global action
+     * (value <code>"org.eclipse.cdt.ui.actions.OpenCallHierarchy"</code>).
+     * @since 3.0
+     */
+    public static final String OPEN_CALL_HIERARCHY= "org.eclipse.cdt.ui.actions.OpenCallHierarchy"; //$NON-NLS-1$
+
+    /**
+     * Navigate menu: name of standard Open Include Browser global action
+     * (value <code>"org.eclipse.cdt.ui.actions.OpenIncludeBrowser"</code>).
+     * @since 4.0
+     */
+    public static final String OPEN_INCLUDE_BROWSER= "org.eclipse.cdt.ui.actions.OpenIncludeBrowser"; //$NON-NLS-1$
+
+       // Edit menu
+
+       /**
+        * Edit menu: name of standard Code Assist global action
+        * (value <code>"org.eclipse.cdt.ui.actions.ContentAssist"</code>).
+        */
+       public static final String CONTENT_ASSIST= "org.eclipse.cdt.ui.actions.ContentAssist"; //$NON-NLS-1$
+
+       // Source menu  
+       
+       /**
+        * Source menu: name of standard Comment global action
+        * (value <code>"org.eclipse.cdt.ui.actions.Comment"</code>).
+        */
+       public static final String COMMENT= "org.eclipse.cdt.ui.actions.Comment"; //$NON-NLS-1$
+       
+       /**
+        * Source menu: name of standard Uncomment global action
+        * (value <code>"org.eclipse.cdt.ui.actions.Uncomment"</code>).
+        */
+       public static final String UNCOMMENT= "org.eclipse.cdt.ui.actions.Uncomment"; //$NON-NLS-1$
+       
+       /**
+        * Source menu: name of standard ToggleComment global action
+        * (value <code>"org.eclipse.cdt.ui.actions.ToggleComment"</code>).
+        * @since 3.0
+        */
+       public static final String TOGGLE_COMMENT= "org.eclipse.cdt.ui.actions.ToggleComment"; //$NON-NLS-1$
+       
+       /**
+        * Source menu: name of standard Block Comment global action
+        * (value <code>"org.eclipse.cdt.ui.actions.AddBlockComment"</code>).
+        * 
+        * @since 3.0
+        */
+       public static final String ADD_BLOCK_COMMENT= "org.eclipse.cdt.ui.actions.AddBlockComment"; //$NON-NLS-1$
+       
+       /**
+        * Source menu: name of standard Block Uncomment global action
+        * (value <code>"org.eclipse.cdt.ui.actions.RemoveBlockComment"</code>).
+        * 
+        * @since 3.0
+        */
+       public static final String REMOVE_BLOCK_COMMENT= "org.eclipse.cdt.ui.actions.RemoveBlockComment"; //$NON-NLS-1$
+       
+       /**
+        * Source menu: name of standard Indent global action
+        * (value <code>"org.eclipse.cdt.ui.actions.Indent"</code>).
+        */
+       public static final String INDENT= "org.eclipse.cdt.ui.actions.Indent"; //$NON-NLS-1$
+       
+       /**
+        * Source menu: name of standard Shift Right action
+        * (value <code>"org.eclipse.cdt.ui.actions.ShiftRight"</code>).
+        */
+       public static final String SHIFT_RIGHT= "org.eclipse.cdt.ui.actions.ShiftRight"; //$NON-NLS-1$
+       
+       /**
+        * Source menu: name of standard Shift Left global action
+        * (value <code>"org.eclipse.cdt.ui.actions.ShiftLeft"</code>).
+        */
+       public static final String SHIFT_LEFT= "org.eclipse.cdt.ui.actions.ShiftLeft"; //$NON-NLS-1$
+       
+       /**
+        * Source menu: name of standard Format global action
+        * (value <code>"org.eclipse.cdt.ui.actions.Format"</code>).
+        */
+       public static final String FORMAT= "org.eclipse.cdt.ui.actions.Format"; //$NON-NLS-1$
+
+       /**
+        * Source menu: name of standard Add Include global action
+        * (value <code>"org.eclipse.cdt.ui.actions.AddInclude"</code>).
+        */
+       public static final String ADD_INCLUDE= "org.eclipse.cdt.ui.actions.AddInclude"; //$NON-NLS-1$
+
+       /**
+        * Source menu: name of standard Sort Lines global action
+        * (value <code>"org.eclipse.cdt.ui.actions.SortLines"</code>).
+        * @since 5.2
+        */
+       public static final String SORT_LINES= "org.eclipse.cdt.ui.actions.SortLines"; //$NON-NLS-1$
+
+       /**
+        * Source menu: name of standard Sort Members global action (value
+        * <code>"org.eclipse.cdt.ui.actions.SortMembers"</code>).
+        */
+       public static final String SORT_MEMBERS= "org.eclipse.cdt.ui.actions.SortMembers"; //$NON-NLS-1$
+
+       /**
+        * Source menu: name of standard Surround with try/catch block global action
+        * (value <code>"org.eclipse.cdt.ui.actions.SurroundWithTryCatch"</code>).
+        */
+       public static final String SURROUND_WITH_TRY_CATCH= "org.eclipse.cdt.ui.actions.SurroundWithTryCatch"; //$NON-NLS-1$
+       
+       /**
+        * Source menu: name of standard Override Methods global action
+        * (value <code>"org.eclipse.cdt.ui.actions.OverrideMethods"</code>).
+        */
+       public static final String OVERRIDE_METHODS= "org.eclipse.cdt.ui.actions.OverrideMethods"; //$NON-NLS-1$
+       
+       /**
+        * Source menu: name of standard Generate Getter and Setter global action
+        * (value <code>"org.eclipse.cdt.ui.actions.GenerateGetterSetter"</code>).
+        */
+       public static final String GENERATE_GETTER_SETTER= "org.eclipse.cdt.ui.actions.GenerateGetterSetter"; //$NON-NLS-1$
+
+       /**
+        * Source menu: name of standard delegate methods global action (value
+        * <code>"org.eclipse.cdt.ui.actions.GenerateDelegateMethods"</code>).
+        */
+       public static final String GENERATE_DELEGATE_METHODS= "org.eclipse.cdt.ui.actions.GenerateDelegateMethods"; //$NON-NLS-1$
+
+       /**
+        * Source menu: name of standard Add Constructor From Superclass global action
+        * (value <code>"org.eclipse.cdt.ui.actions.AddConstructorFromSuperclass"</code>).
+        */
+       public static final String ADD_CONSTRUCTOR_FROM_SUPERCLASS= "org.eclipse.cdt.ui.actions.AddConstructorFromSuperclass"; //$NON-NLS-1$
+       
+       /**
+        * Source menu: name of standard Generate Constructor using Fields global action
+        * (value <code>"org.eclipse.cdt.ui.actions.GenerateConstructorUsingFields"</code>).
+        */
+       public static final String GENERATE_CONSTRUCTOR_USING_FIELDS= "org.eclipse.cdt.ui.actions.GenerateConstructorUsingFields"; //$NON-NLS-1$
+       
+       /**
+        * Source menu: name of standard Add Cppdoc Comment global action
+        * (value <code>"org.eclipse.cdt.ui.actions.AddCppDocComment"</code>).
+        */
+       public static final String ADD_CPP_DOC_COMMENT= "org.eclipse.cdt.ui.actions.AddCppDocComment"; //$NON-NLS-1$
+
+       /**
+        * Source menu: name of standard Find Strings to Externalize global action
+        * (value <code>"org.eclipse.cdt.ui.actions.FindStringsToExternalize"</code>).
+        */
+       public static final String FIND_STRINGS_TO_EXTERNALIZE= "org.eclipse.cdt.ui.actions.FindStringsToExternalize"; //$NON-NLS-1$
+       
+       /**
+        * Source menu: name of standard Externalize Strings global action
+        * (value <code>"org.eclipse.cdt.ui.actions.ExternalizeStrings"</code>).
+        */
+       public static final String EXTERNALIZE_STRINGS= "org.eclipse.cdt.ui.actions.ExternalizeStrings"; //$NON-NLS-1$
+       
+       // Refactor menu
+       
+       /**
+        * Refactor menu: name of standard Self Encapsulate Field global action
+        * (value <code>"org.eclipse.cdt.ui.actions.SelfEncapsulateField"</code>).
+        */
+       public static final String SELF_ENCAPSULATE_FIELD= "org.eclipse.cdt.ui.actions.SelfEncapsulateField"; //$NON-NLS-1$
+       
+       /**
+        * Refactor menu: name of standard Modify Parameters global action
+        * (value <code>"org.eclipse.cdt.ui.actions.ModifyParameters"</code>).
+        */
+       public static final String MODIFY_PARAMETERS= "org.eclipse.cdt.ui.actions.ModifyParameters"; //$NON-NLS-1$
+       
+       /**
+        * Refactor menu: name of standard Pull Up global action
+        * (value <code>"org.eclipse.cdt.ui.actions.PullUp"</code>).
+        */
+       public static final String PULL_UP= "org.eclipse.cdt.ui.actions.PullUp"; //$NON-NLS-1$
+
+       /**
+        * Refactor menu: name of standard Push Down global action
+        * (value <code>"org.eclipse.cdt.ui.actions.PushDown"</code>).
+        */
+       public static final String PUSH_DOWN= "org.eclipse.cdt.ui.actions.PushDown"; //$NON-NLS-1$
+       
+       /**
+        * Refactor menu: name of standard Move Element global action
+        * (value <code>"org.eclipse.cdt.ui.actions.Move"</code>).
+        */
+       public static final String MOVE= "org.eclipse.cdt.ui.actions.Move"; //$NON-NLS-1$
+       
+       /**
+        * Refactor menu: name of standard Rename Element global action
+        * (value <code>"org.eclipse.cdt.ui.actions.Rename"</code>).
+        */
+       public static final String RENAME= "org.eclipse.cdt.ui.actions.Rename"; //$NON-NLS-1$
+       
+       /**
+        * Refactor menu: name of standard Extract Temp global action
+        * (value <code>"org.eclipse.cdt.ui.actions.ExtractTemp"</code>).
+        */
+       public static final String EXTRACT_TEMP= "org.eclipse.cdt.ui.actions.ExtractTemp"; //$NON-NLS-1$
+
+       /**
+        * Refactor menu: name of standard Extract Constant global action
+        * (value <code>"org.eclipse.cdt.ui.actions.ExtractConstant"</code>).
+        */
+       public static final String EXTRACT_CONSTANT= "org.eclipse.cdt.ui.actions.ExtractConstant"; //$NON-NLS-1$
+
+       /**
+        * Refactor menu: name of standard Extract Local Variable global action
+        * (value <code>"org.eclipse.cdt.ui.actions.ExtractLocalVariable"</code>).
+     * @since 5.1
+        */
+       public static final String EXTRACT_LOCAL_VARIABLE= "org.eclipse.cdt.ui.actions.ExtractLocalVariable"; //$NON-NLS-1$
+       
+       /**
+        * Refactor menu: name of standard Hide Method global action
+        * (value <code>"org.eclipse.cdt.ui.actions.HideMethod"</code>).
+        */
+       public static final String HIDE_METHOD= "org.eclipse.cdt.ui.actions.HideMethod"; //$NON-NLS-1$
+
+       /**
+        * Refactor menu: name of standard Extract Constant global action
+        * (value <code>"org.eclipse.cdt.ui.actions.ImplementMethod"</code>).
+        */
+       public static final String IMPLEMENT_METHOD= "org.eclipse.cdt.ui.actions.ImplementMethod"; //$NON-NLS-1$
+
+       /**
+        * Refactor menu: name of standard Generate Getters and Setters global action
+        * (value <code>"org.eclipse.cdt.ui.actions.GettersAndSetters"</code>).
+        */
+       public static final String GETTERS_AND_SETTERS= "org.eclipse.cdt.ui.actions.GettersAndSetters"; //$NON-NLS-1$
+       
+       /**
+        * Refactor menu: name of standard Introduce Parameter global action
+        * (value <code>"org.eclipse.cdt.ui.actions.IntroduceParameter"</code>).
+        */
+       public static final String INTRODUCE_PARAMETER= "org.eclipse.cdt.ui.actions.IntroduceParameter"; //$NON-NLS-1$
+
+       /**
+        * Refactor menu: name of standard Introduce Factory global action
+        * (value <code>"org.eclipse.cdt.ui.actions.IntroduceFactory"</code>).
+        */
+       public static final String INTRODUCE_FACTORY= "org.eclipse.cdt.ui.actions.IntroduceFactory"; //$NON-NLS-1$
+
+       /**
+        * Refactor menu: name of standard Extract Method global action
+        * (value <code>"org.eclipse.cdt.ui.actions.ExtractMethod"</code>).
+        */
+       public static final String EXTRACT_METHOD= "org.eclipse.cdt.ui.actions.ExtractMethod"; //$NON-NLS-1$
+
+       /**
+        * Refactor menu: name of standard Toggle Function global action (value
+        * <code>"org.eclipse.cdt.ui.actions.ExtractMethod"</code>).
+        * 
+        * @since 5.3
+        */
+       public static final String TOGGLE_FUNCTION = "org.eclipse.cdt.ui.actions.ToggleFunction"; //$NON-NLS-1$
+
+       /**
+        * Refactor menu: name of standard Inline global action 
+        * (value <code>"org.eclipse.cdt.ui.actions.Inline"</code>).
+        */
+       public static final String INLINE= "org.eclipse.cdt.ui.actions.Inline"; //$NON-NLS-1$
+
+       /**
+        * Refactor menu: name of standard Extract Interface global action
+        * (value <code>"org.eclipse.cdt.ui.actions.ExtractInterface"</code>).
+        */
+       public static final String EXTRACT_INTERFACE= "org.eclipse.cdt.ui.actions.ExtractInterface"; //$NON-NLS-1$
+
+       /**
+        * Refactor menu: name of standard Generalize Type global action
+        * (value <code>"org.eclipse.cdt.ui.actions.ChangeType"</code>).
+        */
+       public static final String CHANGE_TYPE= "org.eclipse.cdt.ui.actions.ChangeType"; //$NON-NLS-1$
+
+       /**
+        * Refactor menu: name of standard global action to convert a nested type to a top level type
+        * (value <code>"org.eclipse.cdt.ui.actions.MoveInnerToTop"</code>).
+        */
+       public static final String CONVERT_NESTED_TO_TOP= "org.eclipse.cdt.ui.actions.ConvertNestedToTop"; //$NON-NLS-1$
+       
+       /**
+        * Refactor menu: name of standard Use Supertype global action
+        * (value <code>"org.eclipse.cdt.ui.actions.UseSupertype"</code>).
+        */
+       public static final String USE_SUPERTYPE= "org.eclipse.cdt.ui.actions.UseSupertype"; //$NON-NLS-1$
+
+       /**
+        * Refactor menu: name of standard global action to convert a local
+        * variable to a field (value <code>"org.eclipse.cdt.ui.actions.ConvertLocalToField"</code>).
+        */
+       public static final String CONVERT_LOCAL_TO_FIELD= "org.eclipse.cdt.ui.actions.ConvertLocalToField"; //$NON-NLS-1$
+
+       /**
+        * Refactor menu: name of standard Covert Anonymous to Nested global action
+        * (value <code>"org.eclipse.cdt.ui.actions.ConvertAnonymousToNested"</code>).
+        */
+       public static final String CONVERT_ANONYMOUS_TO_NESTED= "org.eclipse.cdt.ui.actions.ConvertAnonymousToNested"; //$NON-NLS-1$
+       
+       // Search Menu
+       
+       /**
+        * Search menu: name of standard Find References in Workspace global action
+        * (value <code>"org.eclipse.cdt.ui.actions.ReferencesInWorkspace"</code>).
+        */
+       public static final String FIND_REFERENCES_IN_WORKSPACE= "org.eclipse.cdt.ui.actions.ReferencesInWorkspace"; //$NON-NLS-1$
+
+       /**
+        * Search menu: name of standard Find References in Project global action
+        * (value <code>"org.eclipse.cdt.ui.actions.ReferencesInProject"</code>).
+        */
+       public static final String FIND_REFERENCES_IN_PROJECT= "org.eclipse.cdt.ui.actions.ReferencesInProject"; //$NON-NLS-1$
+
+       /**
+        * Search menu: name of standard Find References in Hierarchy global action
+        * (value <code>"org.eclipse.cdt.ui.actions.ReferencesInHierarchy"</code>).
+        */
+       public static final String FIND_REFERENCES_IN_HIERARCHY= "org.eclipse.cdt.ui.actions.ReferencesInHierarchy"; //$NON-NLS-1$
+       
+       /**
+        * Search menu: name of standard Find References in Working Set global action
+        * (value <code>"org.eclipse.cdt.ui.actions.ReferencesInWorkingSet"</code>).
+        */
+       public static final String FIND_REFERENCES_IN_WORKING_SET= "org.eclipse.cdt.ui.actions.ReferencesInWorkingSet"; //$NON-NLS-1$
+
+
+
+       /**
+        * Search menu: name of standard Find Declarations in Workspace global action
+        * (value <code>"org.eclipse.cdt.ui.actions.DeclarationsInWorkspace"</code>).
+        */
+       public static final String FIND_DECLARATIONS_IN_WORKSPACE= "org.eclipse.cdt.ui.actions.DeclarationsInWorkspace"; //$NON-NLS-1$
+
+       /**
+        * Search menu: name of standard Find Declarations in Project global action
+        * (value <code>"org.eclipse.cdt.ui.actions.DeclarationsInProject"</code>).
+        */
+       public static final String FIND_DECLARATIONS_IN_PROJECT= "org.eclipse.cdt.ui.actions.DeclarationsInProject"; //$NON-NLS-1$
+
+       /**
+        * Search menu: name of standard Find Declarations in Hierarchy global action
+        * (value <code>"org.eclipse.cdt.ui.actions.DeclarationsInHierarchy"</code>).
+        */
+       public static final String FIND_DECLARATIONS_IN_HIERARCHY= "org.eclipse.cdt.ui.actions.DeclarationsInHierarchy"; //$NON-NLS-1$
+       
+       /**
+        * Search menu: name of standard Find Declarations in Working Set global action
+        * (value <code>"org.eclipse.cdt.ui.actions.DeclarationsInWorkingSet"</code>).
+        */
+       public static final String FIND_DECLARATIONS_IN_WORKING_SET= "org.eclipse.cdt.ui.actions.DeclarationsInWorkingSet"; //$NON-NLS-1$
+
+       /**
+        * Search menu: name of standard Find Implementors in Workspace global action
+        * (value <code>"org.eclipse.cdt.ui.actions.ImplementorsInWorkspace"</code>).
+        */
+       public static final String FIND_IMPLEMENTORS_IN_WORKSPACE= "org.eclipse.cdt.ui.actions.ImplementorsInWorkspace"; //$NON-NLS-1$
+
+       /**
+        * Search menu: name of standard Find Implementors in Project global action
+        * (value <code>"org.eclipse.cdt.ui.actions.ImplementorsInProject"</code>).
+        */
+       public static final String FIND_IMPLEMENTORS_IN_PROJECT= "org.eclipse.cdt.ui.actions.ImplementorsInProject"; //$NON-NLS-1$
+
+       /**
+        * Search menu: name of standard Find Implementors in Working Set global action
+        * (value <code>"org.eclipse.cdt.ui.actions.ImplementorsInWorkingSet"</code>).
+        */
+       public static final String FIND_IMPLEMENTORS_IN_WORKING_SET= "org.eclipse.cdt.ui.actions.ImplementorsInWorkingSet"; //$NON-NLS-1$
+
+       /**
+        * Search menu: name of standard Find Read Access in Workspace global action
+        * (value <code>"org.eclipse.cdt.ui.actions.ReadAccessInWorkspace"</code>).
+        */
+       public static final String FIND_READ_ACCESS_IN_WORKSPACE= "org.eclipse.cdt.ui.actions.ReadAccessInWorkspace"; //$NON-NLS-1$
+
+       /**
+        * Search menu: name of standard Find Read Access in Project global action
+        * (value <code>"org.eclipse.cdt.ui.actions.ReadAccessInProject"</code>).
+        */
+       public static final String FIND_READ_ACCESS_IN_PROJECT= "org.eclipse.cdt.ui.actions.ReadAccessInProject"; //$NON-NLS-1$
+
+       /**
+        * Search menu: name of standard Find Read Access in Hierarchy global action
+        * (value <code>"org.eclipse.cdt.ui.actions.ReadAccessInHierarchy"</code>).
+        */
+       public static final String FIND_READ_ACCESS_IN_HIERARCHY= "org.eclipse.cdt.ui.actions.ReadAccessInHierarchy"; //$NON-NLS-1$
+       
+       /**
+        * Search menu: name of standard Find Read Access in Working Set global action
+        * (value <code>"org.eclipse.cdt.ui.actions.ReadAccessInWorkingSet"</code>).
+        */
+       public static final String FIND_READ_ACCESS_IN_WORKING_SET= "org.eclipse.cdt.ui.actions.ReadAccessInWorkingSet"; //$NON-NLS-1$
+
+       /**
+        * Search menu: name of standard Find Write Access in Workspace global action
+        * (value <code>"org.eclipse.cdt.ui.actions.WriteAccessInWorkspace"</code>).
+        */
+       public static final String FIND_WRITE_ACCESS_IN_WORKSPACE= "org.eclipse.cdt.ui.actions.WriteAccessInWorkspace"; //$NON-NLS-1$
+
+       /**
+        * Search menu: name of standard Find Write Access in Project global action
+        * (value <code>"org.eclipse.cdt.ui.actions.WriteAccessInProject"</code>).
+        */
+       public static final String FIND_WRITE_ACCESS_IN_PROJECT= "org.eclipse.cdt.ui.actions.WriteAccessInProject"; //$NON-NLS-1$
+
+       /**
+        * Search menu: name of standard Find Read Access in Hierarchy global action
+        * (value <code>"org.eclipse.cdt.ui.actions.WriteAccessInHierarchy"</code>).
+        */
+       public static final String FIND_WRITE_ACCESS_IN_HIERARCHY= "org.eclipse.cdt.ui.actions.WriteAccessInHierarchy"; //$NON-NLS-1$
+       
+       /**
+        * Search menu: name of standard Find Read Access in Working Set global action
+        * (value <code>"org.eclipse.cdt.ui.actions.WriteAccessInWorkingSet"</code>).
+        */
+       public static final String FIND_WRITE_ACCESS_IN_WORKING_SET= "org.eclipse.cdt.ui.actions.WriteAccessInWorkingSet"; //$NON-NLS-1$
+       
+       /**
+        * Search menu: name of standard Occurrences in File global action (value
+        * <code>"org.eclipse.cdt.ui.actions.OccurrencesInFile"</code>).
+        */
+       public static final String FIND_OCCURRENCES_IN_FILE= "org.eclipse.cdt.ui.actions.OccurrencesInFile"; //$NON-NLS-1$
+       
+       /**
+        * Search menu: name of standard Find exception occurrences global action (value
+        * <code>"org.eclipse.cdt.ui.actions.ExceptionOccurrences"</code>).
+        */
+       public static final String FIND_EXCEPTION_OCCURRENCES= "org.eclipse.cdt.ui.actions.ExceptionOccurrences"; //$NON-NLS-1$         
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigActionBase.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigActionBase.java
new file mode 100644 (file)
index 0000000..5701861
--- /dev/null
@@ -0,0 +1,292 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *     Warren Paul (Nokia) - bug 200420.
+ *******************************************************************************/
+package org.eclipse.cdt.ui.actions;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.cview.IncludeRefContainer;
+import org.eclipse.cdt.internal.ui.cview.IncludeReferenceProxy;
+
+/**
+ * Base class for build configuration actions. 
+ */
+public class ChangeBuildConfigActionBase {
+       
+       /**
+        * List of selected managed-built projects
+        */
+       protected HashSet<IProject> fProjects = new HashSet<IProject>();
+       
+       /**
+        * Fills the menu with build configurations which are common for all selected projects
+        * @param menu The menu to fill
+        */
+       protected void fillMenu(Menu menu)      {
+               // This should not happen 
+               if (menu == null) return;
+
+               MenuItem[] items = menu.getItems();
+               for (MenuItem item2 : items)
+                       item2.dispose();
+               
+               SortedSet<String> configNames = new TreeSet<String>();
+               String sCurrentConfig = null;
+               boolean bCurrentConfig = true;
+               for (IProject prj : fProjects) {
+                       ICConfigurationDescription[] cfgDescs = getCfgs(prj);
+
+                       String sActiveConfig = null;
+                       // Store names and detect active configuration
+                       for (ICConfigurationDescription cfgDesc : cfgDescs) {
+                               String s = cfgDesc.getName();
+                               if (!configNames.contains(s)) 
+                                       configNames.add(s);
+                               if (cfgDesc.isActive()) 
+                                       sActiveConfig = s;
+                       }
+
+                       // Check whether all projects have the same active configuration
+                       if (bCurrentConfig) {
+                               if (sCurrentConfig == null)
+                                       sCurrentConfig = sActiveConfig;
+                               else {
+                                       if (!sCurrentConfig.equals(sActiveConfig)) 
+                                               bCurrentConfig = false;
+                               }
+                       }
+               }
+               
+               int accel = 0;
+               for (String sName : configNames) {
+                       String sDesc = null;
+                       boolean commonName = true;
+                       boolean commonDesc = true;
+                       boolean firstProj = true;
+                       for (IProject prj : fProjects) {
+                               ICConfigurationDescription[] cfgDescs = getCfgs(prj);
+                               int i = 0;
+                               for (; i < cfgDescs.length; i++) {
+                                       if (cfgDescs[i].getName().equals(sName)) {
+                                               String sNewDesc = cfgDescs[i].getDescription();
+                                               if (sNewDesc != null && sNewDesc.length() == 0) {
+                                                       sNewDesc = null;
+                                               }
+                                               if (commonDesc) {
+                                                       if (firstProj) {
+                                                               sDesc = sNewDesc;
+                                                               firstProj = false;
+                                                       } else if (sNewDesc == null && sDesc != null || sNewDesc != null && !sNewDesc.equals(sDesc)) {
+                                                               commonDesc = false;     
+                                                       }
+                                               }
+                                               break;
+                                       }
+                               }
+                               if (i == cfgDescs.length) {
+                                       commonName = false;
+                                       break;
+                               }
+                       }
+                       if (commonName) {
+                               StringBuffer builder = new StringBuffer(sName);
+                               if (commonDesc) {
+                                       if (sDesc != null) {
+                                               builder.append(" (");   //$NON-NLS-1$
+                                               builder.append(sDesc);
+                                               builder.append(")");    //$NON-NLS-1$
+                                       }
+                               } else {
+                                       builder.append(" (...)");       //$NON-NLS-1$
+                               }
+                                       
+                               IAction action = makeAction(sName ,builder, accel);
+                               if (bCurrentConfig && sCurrentConfig != null && sCurrentConfig.equals(sName)) {
+                                       action.setChecked(true);
+                               }
+                               ActionContributionItem item = new ActionContributionItem(action);
+                               item.fill(menu, -1);
+                               accel++;
+                       }
+               }
+       }
+
+       protected IAction makeAction(String sName, StringBuffer builder, int accel) {
+               return new ChangeConfigAction(fProjects, sName, builder.toString(), accel + 1);
+       }
+
+       /**
+        * selectionChanged() event handler. Fills the list of managed-built projects 
+        * based on the selection. If some non-managed-built projects are selected,
+        * disables the action. 
+        * @param action The action
+        * @param selection The selection
+        */
+       protected void onSelectionChanged(IAction action, ISelection selection) {
+               fProjects.clear();
+
+               boolean badObject = false;
+               
+               if (selection != null )
+               {
+                       if (selection instanceof IStructuredSelection) {
+                               if (selection.isEmpty()) {
+                                       // could be a form editor or something.  try to get the project from the active part
+                                       IWorkbenchPage page = CUIPlugin.getActivePage();
+                                       if (page != null) {
+                                               IWorkbenchPart part = page.getActivePart();
+                                               if (part != null) {
+                                                       Object o = part.getAdapter(IResource.class);
+                                                       if (o != null && o instanceof IResource) {
+                                                               fProjects.add(((IResource)o).getProject());
+                                                       }
+                                               }
+                                       }
+                               }
+                               Iterator<?> iter = ((IStructuredSelection)selection).iterator();
+                               while (iter.hasNext()) {
+                                       Object selItem = iter.next();
+                                       IProject project = null;
+                                       if (selItem instanceof ICElement) {
+                                               ICProject cproject = ((ICElement)selItem).getCProject();
+                                               if (cproject != null) project = cproject.getProject();
+                                       }
+                                       else if (selItem instanceof IResource) {
+                                               project = ((IResource)selItem).getProject();
+                                       } else if (selItem instanceof IncludeRefContainer) {
+                                               ICProject fCProject = ((IncludeRefContainer)selItem).getCProject();
+                                               if (fCProject != null)
+                                                       project = fCProject.getProject();
+                                       } else if (selItem instanceof IncludeReferenceProxy) {
+                                               IncludeRefContainer irc = ((IncludeReferenceProxy)selItem).getIncludeRefContainer();
+                                               if (irc != null) {
+                                                       ICProject fCProject = irc.getCProject();
+                                                       if (fCProject != null)
+                                                               project = fCProject.getProject();
+                                               }
+                                       } else if (selItem instanceof IAdaptable) {
+                                               Object adapter = ((IAdaptable)selItem).getAdapter(IProject.class);
+                                               if (adapter != null && adapter instanceof IProject) {
+                                                       project = (IProject)adapter;
+                                               }
+                                       }
+                                       // Check whether the project is CDT project
+                                       if (project != null) {
+                                               if (!CoreModel.getDefault().isNewStyleProject(project))
+                                                       project = null;
+                                               else {
+                                                       ICConfigurationDescription[] tmp = getCfgs(project);
+                                                       if (tmp == null || tmp.length == 0)     project = null;
+                                               }
+                                       }
+                                       if (project != null) {
+                                               fProjects.add(project);
+                                       } else {
+                                               badObject = true;
+                                               break;
+                                       }
+                               }
+                       }
+                       else
+                       if (selection instanceof ITextSelection) {
+                               // If a text selection check the selected part to see if we can find
+                               // an editor part that we can adapt to a resource and then
+                               // back to a project.
+                               IWorkbenchWindow window = CUIPlugin.getActiveWorkbenchWindow();
+                               if (window != null) {
+                                       IWorkbenchPage page = window.getActivePage();
+                                       if (page != null) {
+                                               IWorkbenchPart part = page.getActivePart();
+                                               if (part instanceof IEditorPart) {
+                                                       IEditorPart epart = (IEditorPart) part;
+                                                       IResource resource = (IResource) epart.getEditorInput().getAdapter(IResource.class);
+                                                       if (resource != null)
+                                                       {
+                                                               IProject project = resource.getProject();
+                                                               badObject = !(project != null && CoreModel.getDefault().isNewStyleProject(project));
+
+                                                               if (!badObject) {
+                                                                       fProjects.add(project);
+                                                               }                                                                       
+                                                       }
+                                               }
+                                       }
+                               }
+
+                       }
+               }
+               
+               
+               boolean enable = false;
+               if (!badObject && !fProjects.isEmpty()) {
+                       Iterator<IProject> iter = fProjects.iterator();
+                       ICConfigurationDescription[] firstConfigs = getCfgs(iter.next());
+                       if (firstConfigs!=null) {
+                               for (ICConfigurationDescription firstConfig : firstConfigs) {
+                                       boolean common = true;
+                                       Iterator<IProject> iter2 = fProjects.iterator();
+                                       while (iter2.hasNext()) {
+                                               ICConfigurationDescription[] currentConfigs = getCfgs(iter2.next());
+                                               int j = 0;
+                                               for (; j < currentConfigs.length; j++) {
+                                                       if (firstConfig.getName().equals(currentConfigs[j].getName())) 
+                                                               break;
+                                               }
+                                               if (j == currentConfigs.length) {
+                                                       common = false;
+                                                       break;
+                                               }
+                                       }
+                                       if (common) {
+                                               enable = true;
+                                               break;
+                                       }
+                               }
+                       }
+               }
+               action.setEnabled(enable);
+       }
+       
+       private ICConfigurationDescription[] getCfgs(IProject prj) {
+               ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(prj, false);
+               if (prjd == null) return null;
+               ICConfigurationDescription[] tmp = prjd.getConfigurations();
+               if (tmp == null) return null;
+               return prjd.getConfigurations(); 
+       }
+       
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigContextAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigContextAction.java
new file mode 100644 (file)
index 0000000..5556997
--- /dev/null
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.actions;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuCreator;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.events.MenuAdapter;
+import org.eclipse.swt.events.MenuEvent;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * This context menu action is used to change active build configuration for the project
+ */
+public class ChangeBuildConfigContextAction extends ChangeBuildConfigActionBase implements 
+       IMenuCreator, IObjectActionDelegate     {
+
+       /** 
+        * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
+        */
+       public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+               // do nothing
+       }
+
+       /**
+        * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+        */
+       public void run(IAction action) {
+               // do nothing
+       }
+
+       /**
+        * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+        */
+       public void selectionChanged(IAction action, ISelection selection) {
+               onSelectionChanged(action, selection);
+               action.setMenuCreator(this);
+       }
+
+       /**
+        * @see org.eclipse.jface.action.IMenuCreator#dispose()
+        */
+       public void dispose() {
+               // do nothing
+       }
+
+       /**
+        * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Control)
+        */
+       public Menu getMenu(Control parent) {
+               // this method is never called
+               return null;
+       }
+
+       /**
+        * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Menu)
+        */
+       public Menu getMenu(Menu parent) {
+               Menu menu = new Menu(parent);
+               menu.addMenuListener(new MenuAdapter() {
+                       @Override
+                       public void menuShown(MenuEvent e) {
+                               fillMenu((Menu)e.widget);
+                       }
+               });
+               return menu;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigMenuAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeBuildConfigMenuAction.java
new file mode 100644 (file)
index 0000000..ddef08d
--- /dev/null
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2010 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.actions;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.events.MenuAdapter;
+import org.eclipse.swt.events.MenuEvent;
+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.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.newui.IConfigManager;
+import org.eclipse.cdt.ui.newui.ManageConfigSelector;
+
+import org.eclipse.cdt.internal.ui.actions.ActionMessages;
+
+/**
+ * Action which changes active build configuration of the current project 
+ */
+public class ChangeBuildConfigMenuAction extends ChangeBuildConfigActionBase implements
+               IWorkbenchWindowPulldownDelegate2 {
+
+       /**
+        * @see org.eclipse.ui.IWorkbenchWindowPulldownDelegate2#getMenu(org.eclipse.swt.widgets.Menu)
+        */
+       public Menu getMenu(Menu parent) {
+               Menu menu = new Menu(parent);
+               addMenuListener(menu);
+               return menu;
+       }
+
+       /**
+        * @see org.eclipse.ui.IWorkbenchWindowPulldownDelegate#getMenu(org.eclipse.swt.widgets.Control)
+        */
+       public Menu getMenu(Control parent) {
+               Menu menu = new Menu(parent);
+               addMenuListener(menu);
+               return menu;
+       }
+
+       /**
+        * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
+        */
+       public void dispose() {
+               // do nothing
+       }
+
+       /**
+        * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
+        */
+       public void init(IWorkbenchWindow window) {
+               // do nothing
+       }
+
+       /**
+        * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+        */
+       public void run(IAction action) {
+               IProject[] obs = fProjects.toArray(new IProject[fProjects.size()]);
+               IConfigManager cm = ManageConfigSelector.getManager(obs);
+               if (cm != null) {
+                       cm.manage(obs, true);
+               } else {
+                       MessageDialog.openInformation(CUIPlugin.getActiveWorkbenchShell(),
+                                       ActionMessages.ChangeBuildConfigMenuAction_title,
+                                       ActionMessages.ChangeBuildConfigMenuAction_text);
+               }
+       }
+
+       /**
+        * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+        */
+       public void selectionChanged(IAction action, ISelection selection) {
+               onSelectionChanged(action, selection);
+       }
+       
+       /**
+        * Adds a listener to the given menu to repopulate it each time is is shown
+        * @param menu The menu to add listener to
+        */
+       private void addMenuListener(Menu menu) {
+               menu.addMenuListener(new MenuAdapter() {
+                       @Override
+                       public void menuShown(MenuEvent e) {
+                               fillMenu((Menu)e.widget);
+                       }
+               });
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeConfigAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ChangeConfigAction.java
new file mode 100644 (file)
index 0000000..421510e
--- /dev/null
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.actions;
+
+import java.util.HashSet;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.action.Action;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.ui.newui.AbstractPage;
+import org.eclipse.cdt.ui.newui.CDTPropertyManager;
+
+/**
+ * Action which changes active build configuration of the current project to 
+ * the given one.
+ */
+public class ChangeConfigAction extends Action {
+
+       private String fConfigName = null;
+       protected HashSet<IProject> fProjects = null;
+       
+       /**
+        * Constructs the action.
+        * @param projects List of selected managed-built projects 
+        * @param configName Build configuration name
+        * @param accel Number to be used as accelerator
+        */
+       public ChangeConfigAction(HashSet<IProject> projects, String configName, String displayName, int accel) {
+               super("&" + accel + " " + displayName); //$NON-NLS-1$ //$NON-NLS-2$
+               fProjects = projects;
+               fConfigName = configName;
+       }
+       
+       /**
+        * @see org.eclipse.jface.action.IAction#run()
+        */
+       @Override
+       public void run() {
+               Iterator<IProject> iter = fProjects.iterator();
+               while (iter.hasNext()) {
+                       IProject prj = iter.next();
+                       ICProjectDescription prjd = CDTPropertyManager.getProjectDescription(prj);
+                       boolean changed = false;
+                       ICConfigurationDescription[] configs = prjd.getConfigurations(); 
+                       if (configs != null && configs.length > 0) {
+                               for (ICConfigurationDescription config : configs) {
+                                       if (config.getName().equals(fConfigName)) {
+                                               config.setActive();
+                                               CDTPropertyManager.performOk(null);
+                                               AbstractPage.updateViews(prj);
+                                               changed = true;
+                                               break;
+                                       }
+                               }
+                       }
+                       
+                       if(!changed)
+                               CDTPropertyManager.performCancel(null);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/CustomFiltersActionGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/CustomFiltersActionGroup.java
new file mode 100644 (file)
index 0000000..a5dcd31
--- /dev/null
@@ -0,0 +1,734 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.actions;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.Stack;
+import java.util.StringTokenizer;
+import java.util.TreeSet;
+import java.util.Map.Entry;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ContributionItem;
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.actions.ActionGroup;
+
+import org.eclipse.cdt.core.model.ICModel;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.filters.CustomFiltersDialog;
+import org.eclipse.cdt.internal.ui.filters.FilterDescriptor;
+import org.eclipse.cdt.internal.ui.filters.FilterMessages;
+import org.eclipse.cdt.internal.ui.filters.NamePatternFilter;
+
+/**
+ * Action group to add the filter action to a view part's tool bar
+ * menu.
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ * @since 2.0
+ */
+public class CustomFiltersActionGroup extends ActionGroup {
+
+       class ShowFilterDialogAction extends Action {
+               ShowFilterDialogAction() {
+                       setText(FilterMessages.OpenCustomFiltersDialogAction_text);
+                       //setImageDescriptor(CPluginImages.DESC_CLCL_FILTER);
+               }
+               
+               @Override
+               public void run() {
+                       openDialog();
+               }
+       }
+
+       /**
+        * Menu contribution item which shows and lets check and uncheck filters.
+        * 
+        * @since 3.0
+        */
+       class FilterActionMenuContributionItem extends ContributionItem {
+
+               private int fItemNumber;
+               boolean fState;
+               String fFilterId;
+               private String fFilterName;
+               CustomFiltersActionGroup fActionGroup;
+
+               /**
+                * Constructor for FilterActionMenuContributionItem.
+                * 
+                * @param actionGroup   the action group
+                * @param filterId              the id of the filter
+                * @param filterName    the name of the filter
+                * @param state                 the initial state of the filter
+                * @param itemNumber    the menu item index
+                */
+               public FilterActionMenuContributionItem(CustomFiltersActionGroup actionGroup, String filterId, String filterName, boolean state, int itemNumber) {
+                       super(filterId);
+                       Assert.isNotNull(actionGroup);
+                       Assert.isNotNull(filterId);
+                       Assert.isNotNull(filterName);
+                       fActionGroup= actionGroup;
+                       fFilterId= filterId;
+                       fFilterName= filterName;
+                       fState= state;
+                       fItemNumber= itemNumber;
+               }
+
+               /*
+                * Overrides method from ContributionItem.
+                */
+               @Override
+               public void fill(Menu menu, int index) {
+                       MenuItem mi= new MenuItem(menu, SWT.CHECK, index);
+                       mi.setText("&" + fItemNumber + " " + fFilterName);  //$NON-NLS-1$  //$NON-NLS-2$
+                       /*
+                        * XXX: Don't set the image - would look bad because other menu items don't provide image
+                        * XXX: Get working set specific image name from XML - would need to cache icons
+                        */
+//                     mi.setImage(JavaPluginImages.get(JavaPluginImages.IMG_OBJS_JAVA_WORKING_SET));
+                       mi.setSelection(fState);
+                       mi.addSelectionListener(new SelectionAdapter() {
+                               @Override
+                               public void widgetSelected(SelectionEvent e) {
+                                       fState= !fState;
+                                       fActionGroup.setFilter(fFilterId, fState);
+                               }
+                       });
+               }
+       
+               /*
+                * @see org.eclipse.jface.action.IContributionItem#isDynamic()
+                */
+               @Override
+               public boolean isDynamic() {
+                       return true;
+               }
+       }
+
+       private static final String TAG_CUSTOM_FILTERS = "customFilters"; //$NON-NLS-1$
+       private static final String TAG_USER_DEFINED_PATTERNS_ENABLED= "userDefinedPatternsEnabled"; //$NON-NLS-1$
+       private static final String TAG_USER_DEFINED_PATTERNS= "userDefinedPatterns"; //$NON-NLS-1$
+       private static final String TAG_XML_DEFINED_FILTERS= "xmlDefinedFilters"; //$NON-NLS-1$
+       private static final String TAG_LRU_FILTERS = "lastRecentlyUsedFilters"; //$NON-NLS-1$
+
+       private static final String TAG_CHILD= "child"; //$NON-NLS-1$
+       private static final String TAG_PATTERN= "pattern"; //$NON-NLS-1$
+       private static final String TAG_FILTER_ID= "filterId"; //$NON-NLS-1$
+       private static final String TAG_IS_ENABLED= "isEnabled"; //$NON-NLS-1$
+
+       private static final String SEPARATOR= ",";  //$NON-NLS-1$
+
+       private static final int MAX_FILTER_MENU_ENTRIES= 3;
+       private static final String RECENT_FILTERS_GROUP_NAME= "recentFiltersGroup"; //$NON-NLS-1$
+
+       private StructuredViewer fViewer;
+
+       private NamePatternFilter fPatternFilter;
+       private Map<String, ViewerFilter> fInstalledBuiltInFilters;
+       
+       private Map<String, Boolean> fEnabledFilterIds;
+       private boolean fUserDefinedPatternsEnabled;
+       private String[] fUserDefinedPatterns;
+       /**
+        * Recently changed filter Ids stack with oldest on top (i.e. at the end).
+        *
+        * @since 3.0
+        */
+       private Stack<String> fLRUFilterIdsStack; 
+       /**
+        * Handle to menu manager to dynamically update
+        * the last recently used filters.
+        * 
+        * @since 3.0
+        */
+       private IMenuManager fMenuManager;
+       /**
+        * The menu listener which dynamically updates
+        * the last recently used filters.
+        * 
+        * @since 3.0
+        */
+       private IMenuListener fMenuListener;
+       /**
+        * Filter Ids used in the last view menu invocation.
+        * 
+        * @since 3.0
+        */
+       private String[] fFilterIdsUsedInLastViewMenu;
+       private HashMap<String, FilterDescriptor> fFilterDescriptorMap;
+       private String fTargetId;
+       
+       /**
+        * Creates a new <code>CustomFiltersActionGroup</code>.
+        * 
+        * @param part          the view part that owns this action group
+        * @param viewer        the viewer to be filtered
+        */
+       public CustomFiltersActionGroup(IViewPart part, StructuredViewer viewer) {
+               this(part.getViewSite().getId(), viewer);
+       }
+
+       /**
+        * Creates a new <code>CustomFiltersActionGroup</code>.
+        * 
+        * @param ownerId       the id of this action group's owner
+        * @param viewer        the viewer to be filtered
+        */
+       public CustomFiltersActionGroup(String ownerId, StructuredViewer viewer) {
+               Assert.isNotNull(ownerId);
+               Assert.isNotNull(viewer);
+               fTargetId= ownerId;
+               fViewer= viewer;
+
+               fLRUFilterIdsStack= new Stack<String>();
+
+               initializeWithPluginContributions();
+               initializeWithViewDefaults();
+               
+               installFilters();
+       }
+       
+       /*
+        * Method declared on ActionGroup.
+        */
+       @Override
+       public void fillActionBars(IActionBars actionBars) {
+               fillToolBar(actionBars.getToolBarManager());
+               fillViewMenu(actionBars.getMenuManager());
+       }
+
+       public String[] removeFiltersFor(Object parent, Object element, IContentProvider contentProvider) {
+           String[] enabledFilters= getEnabledFilterIds();
+           Set<String> newFilters= new HashSet<String>();
+           for (String filterName : enabledFilters) {
+            ViewerFilter filter= fInstalledBuiltInFilters.get(filterName);
+            if (filter == null)
+                newFilters.add(filterName);
+           else if (isSelected(parent, element, contentProvider, filter)) 
+                newFilters.add(filterName);
+        }
+           if (newFilters.size() == enabledFilters.length)
+               return new String[0];
+           return newFilters.toArray(new String[newFilters.size()]);
+       }
+       
+       public void setFilters(String[] newFilters) {
+           setEnabledFilterIds(newFilters);
+           updateViewerFilters(true);
+       }
+       
+       private boolean isSelected(Object parent, Object element, IContentProvider contentProvider, ViewerFilter filter) {
+           if (contentProvider instanceof ITreeContentProvider) {
+               // the element and all its parents have to be selected
+               ITreeContentProvider provider = (ITreeContentProvider) contentProvider;
+               while (element != null && !(element instanceof ICModel)) {
+                   if (!filter.select(fViewer, parent, element)) 
+                       return false;
+                   element= provider.getParent( element);
+               }
+               return true;
+           } 
+           return filter.select(fViewer, parent, element);
+       }
+
+    /**
+        * Sets the enable state of the given filter.
+        * 
+        * @param filterId the id of the filter
+        * @param state the filter state
+        */
+       void setFilter(String filterId, boolean state) {
+               // Renew filter id in LRU stack
+               fLRUFilterIdsStack.remove(filterId);
+               fLRUFilterIdsStack.add(0, filterId);
+               
+               fEnabledFilterIds.put(filterId, new Boolean(state));
+               storeViewDefaults();
+               
+               updateViewerFilters(true);
+       }
+       
+       private String[] getEnabledFilterIds() {
+               Set<String> enabledFilterIds= new HashSet<String>(fEnabledFilterIds.size());
+               Iterator<Map.Entry<String,Boolean>> iter= fEnabledFilterIds.entrySet().iterator();
+               while (iter.hasNext()) {
+                       Map.Entry<String,Boolean> entry= iter.next();
+                       String id= entry.getKey();
+                       boolean isEnabled= (entry.getValue()).booleanValue();
+                       if (isEnabled)
+                               enabledFilterIds.add(id);
+               }
+               return enabledFilterIds.toArray(new String[enabledFilterIds.size()]);
+       }
+
+       
+       private void setEnabledFilterIds(String[] enabledIds) {
+               Iterator<String> iter= fEnabledFilterIds.keySet().iterator();
+               while (iter.hasNext()) {
+                       String id= iter.next();
+                       fEnabledFilterIds.put(id, Boolean.FALSE);
+               }
+               for (String enabledId : enabledIds)
+                       fEnabledFilterIds.put(enabledId, Boolean.TRUE);
+       }
+
+       private void setUserDefinedPatterns(String[] patterns) {
+               fUserDefinedPatterns= patterns;
+               cleanUpPatternDuplicates();
+       }
+
+       /**
+        * Sets the recently changed filters.
+        * 
+        * @param changeHistory the change history
+        * @since 3.0
+        */
+       private void setRecentlyChangedFilters(Stack<FilterDescriptor> changeHistory) {
+               Stack<String> oldestFirstStack= new Stack<String>();
+               
+               int length= Math.min(changeHistory.size(), MAX_FILTER_MENU_ENTRIES);
+               for (int i= 0; i < length; i++)
+                       oldestFirstStack.push((changeHistory.pop()).getId());
+               
+               length= Math.min(fLRUFilterIdsStack.size(), MAX_FILTER_MENU_ENTRIES - oldestFirstStack.size());
+               int NEWEST= 0;
+               for (int i= 0; i < length; i++) {
+                       String filter= fLRUFilterIdsStack.remove(NEWEST);
+                       if (!oldestFirstStack.contains(filter))
+                               oldestFirstStack.push(filter);
+               }
+               fLRUFilterIdsStack= oldestFirstStack;
+       }
+       
+       private boolean areUserDefinedPatternsEnabled() {
+               return fUserDefinedPatternsEnabled;
+       }
+
+       private void setUserDefinedPatternsEnabled(boolean state) {
+               fUserDefinedPatternsEnabled= state;
+       }
+
+       private void fillToolBar(IToolBarManager tooBar) {
+       }
+
+       public void fillViewMenu(IMenuManager viewMenu) {
+               /*
+                * Don't change the separator group name.
+                * Using this name ensures that other filters
+                * get contributed to the same group.
+                */
+               viewMenu.add(new Separator("filters")); //$NON-NLS-1$
+               viewMenu.add(new GroupMarker(RECENT_FILTERS_GROUP_NAME));
+               viewMenu.add(new ShowFilterDialogAction());
+
+               fMenuManager= viewMenu;
+               fMenuListener= new IMenuListener() {
+                       public void menuAboutToShow(IMenuManager manager) {
+                               removePreviousLRUFilterActions(manager);
+                               addLRUFilterActions(manager);
+                       }
+               };
+               fMenuManager.addMenuListener(fMenuListener);
+       }
+
+       void removePreviousLRUFilterActions(IMenuManager mm) {
+               if (fFilterIdsUsedInLastViewMenu == null)
+                       return;
+               
+               for (String element : fFilterIdsUsedInLastViewMenu)
+                       mm.remove(element);
+       }
+
+       void addLRUFilterActions(IMenuManager mm) {
+               if (fLRUFilterIdsStack.isEmpty()) {
+                       fFilterIdsUsedInLastViewMenu= null;
+                       return;
+               }
+               
+               SortedSet<Object> sortedFilters= new TreeSet<Object>(fLRUFilterIdsStack);
+               String[] recentlyChangedFilterIds= sortedFilters.toArray(new String[sortedFilters.size()]);
+               
+               fFilterIdsUsedInLastViewMenu= new String[recentlyChangedFilterIds.length];
+               for (int i= 0; i < recentlyChangedFilterIds.length; i++) {
+                       String id= recentlyChangedFilterIds[i];
+                       fFilterIdsUsedInLastViewMenu[i]= id;
+                       boolean state= fEnabledFilterIds.containsKey(id) && fEnabledFilterIds.get(id).booleanValue();
+                       FilterDescriptor filterDesc= fFilterDescriptorMap.get(id);
+                       if (filterDesc != null) {
+                               IContributionItem item= new FilterActionMenuContributionItem(this, id, filterDesc.getName(), state, i+1);
+                               mm.insertBefore(RECENT_FILTERS_GROUP_NAME, item);
+                       }
+               }
+       }
+
+       /*
+        * Method declared on ActionGroup.
+        */
+       @Override
+       public void dispose() {
+               if (fMenuManager != null)
+                       fMenuManager.removeMenuListener(fMenuListener);
+               super.dispose();
+       }
+       
+       private void initializeWithPluginContributions() {
+               fUserDefinedPatterns= new String[0];
+               fUserDefinedPatternsEnabled= false;
+
+               FilterDescriptor[] filterDescs= FilterDescriptor.getFilterDescriptors(fTargetId);
+               fFilterDescriptorMap= new HashMap<String, FilterDescriptor>(filterDescs.length);
+               fEnabledFilterIds= new HashMap<String, Boolean>(filterDescs.length);
+               for (FilterDescriptor filterDesc : filterDescs) {
+                       String id= filterDesc.getId();
+                       Boolean isEnabled= new Boolean(filterDesc.isEnabled());
+                       //if (fEnabledFilterIds.containsKey(id))
+                       //      CUIPlugin.log(new Status("WARNING: Duplicate id for extension-point \"org.eclipse.jdt.ui.CElementFilters\"")); //$NON-NLS-1$
+                       fEnabledFilterIds.put(id, isEnabled);
+                       fFilterDescriptorMap.put(id, filterDesc);
+               }
+       }
+
+       // ---------- viewer filter handling ----------
+       
+       private void installFilters() {
+               fInstalledBuiltInFilters= new HashMap<String, ViewerFilter>(fEnabledFilterIds.size());
+               fPatternFilter= new NamePatternFilter();
+               fPatternFilter.setPatterns(getUserAndBuiltInPatterns());
+               fViewer.addFilter(fPatternFilter);
+               updateBuiltInFilters();
+       }
+
+       private void updateViewerFilters(boolean refresh) {
+               String[] patterns= getUserAndBuiltInPatterns();
+               fPatternFilter.setPatterns(patterns);
+               fViewer.getControl().setRedraw(false);
+               updateBuiltInFilters();
+               if (refresh)
+                       fViewer.refresh();
+               fViewer.getControl().setRedraw(true);
+       }
+       
+       private void updateBuiltInFilters() {
+               Set<String> installedFilters= fInstalledBuiltInFilters.keySet();
+               Set<String> filtersToAdd= new HashSet<String>(fEnabledFilterIds.size());
+               Set<String> filtersToRemove= new HashSet<String>(fEnabledFilterIds.size());
+               Iterator<Map.Entry<String,Boolean>> iter= fEnabledFilterIds.entrySet().iterator();
+               while (iter.hasNext()) {
+                       Map.Entry<String, Boolean> entry= iter.next();
+                       String id= entry.getKey();
+                       boolean isEnabled= (entry.getValue()).booleanValue();
+                       if (isEnabled && !installedFilters.contains(id))
+                               filtersToAdd.add(id);
+                       else if (!isEnabled && installedFilters.contains(id))
+                               filtersToRemove.add(id);
+               }
+               
+               // Install the filters
+               FilterDescriptor[] filterDescs= FilterDescriptor.getFilterDescriptors(fTargetId);
+               for (FilterDescriptor filterDesc : filterDescs) {
+                       String id= filterDesc.getId();
+                       // just to double check - id should denote a custom filter anyway
+                       boolean isCustomFilter= filterDesc.isCustomFilter();
+                       if (isCustomFilter) {
+                               if (filtersToAdd.contains(id)) {
+                                       ViewerFilter filter= filterDesc.createViewerFilter();
+                                       if (filter != null) {
+                                               fViewer.addFilter(filter);
+                                               fInstalledBuiltInFilters.put(id, filter);
+                                       }
+                               }
+                               if (filtersToRemove.contains(id)) {
+                                       fViewer.removeFilter(fInstalledBuiltInFilters.get(id));
+                                       fInstalledBuiltInFilters.remove(id);
+                               }
+                       }
+               }
+       }
+
+       private String[] getUserAndBuiltInPatterns() {
+               List<String> patterns= new ArrayList<String>(fUserDefinedPatterns.length);
+               if (areUserDefinedPatternsEnabled())
+                       patterns.addAll(Arrays.asList(fUserDefinedPatterns));
+               FilterDescriptor[] filterDescs= FilterDescriptor.getFilterDescriptors(fTargetId);
+               for (FilterDescriptor filterDesc : filterDescs) {
+                       String id= filterDesc.getId();
+                       boolean isPatternFilter= filterDesc.isPatternFilter();
+                       Object isEnabled= fEnabledFilterIds.get(id);
+                       if (isEnabled != null && isPatternFilter && ((Boolean)isEnabled).booleanValue())
+                               patterns.add(filterDesc.getPattern());
+               }
+               return patterns.toArray(new String[patterns.size()]);
+       }
+
+       // ---------- view kind/defaults persistency ----------
+               
+       private void initializeWithViewDefaults() {
+               // get default values for view
+               IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+
+               // XXX: can be removed once bug 22533 is fixed.
+               if (!store.contains(getPreferenceKey("TAG_DUMMY_TO_TEST_EXISTENCE")))//$NON-NLS-1$
+                       return;
+
+               // XXX: Uncomment once bug 22533 is fixed.
+//             if (!store.contains(getPreferenceKey(TAG_USER_DEFINED_PATTERNS_ENABLED)))
+//                     return;
+               
+               fUserDefinedPatternsEnabled= store.getBoolean(getPreferenceKey(TAG_USER_DEFINED_PATTERNS_ENABLED));
+               setUserDefinedPatterns(CustomFiltersDialog.convertFromString(store.getString(getPreferenceKey(TAG_USER_DEFINED_PATTERNS)), SEPARATOR));
+
+               Iterator<String> iter= fEnabledFilterIds.keySet().iterator();
+               while (iter.hasNext()) {
+                       String id= iter.next();
+                       Boolean isEnabled= new Boolean(store.getBoolean(id));
+                       fEnabledFilterIds.put(id, isEnabled);
+               }
+               
+               fLRUFilterIdsStack.clear();
+               String lruFilterIds= store.getString(TAG_LRU_FILTERS);
+               StringTokenizer tokenizer= new StringTokenizer(lruFilterIds, SEPARATOR);
+               while (tokenizer.hasMoreTokens()) {
+                       String id= tokenizer.nextToken();
+                       if (fFilterDescriptorMap.containsKey(id) && !fLRUFilterIdsStack.contains(id))
+                               fLRUFilterIdsStack.push(id);
+               }
+       }
+
+       private void storeViewDefaults() {
+               // get default values for view
+               IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+
+               // XXX: can be removed once bug 22533 is fixed.
+               store.setValue(getPreferenceKey("TAG_DUMMY_TO_TEST_EXISTENCE"), "storedViewPreferences");//$NON-NLS-1$//$NON-NLS-2$
+               
+               store.setValue(getPreferenceKey(TAG_USER_DEFINED_PATTERNS_ENABLED), fUserDefinedPatternsEnabled);
+               store.setValue(getPreferenceKey(TAG_USER_DEFINED_PATTERNS), CustomFiltersDialog.convertToString(fUserDefinedPatterns ,SEPARATOR));
+
+               Iterator<Entry<String, Boolean>> iter= fEnabledFilterIds.entrySet().iterator();
+               while (iter.hasNext()) {
+                       Map.Entry<String,Boolean> entry= iter.next();
+                       String id= entry.getKey();
+                       boolean isEnabled= (entry.getValue()).booleanValue();
+                       store.setValue(id, isEnabled);
+               }
+
+               StringBuffer buf= new StringBuffer(fLRUFilterIdsStack.size() * 20);
+               Iterator<String> iterIds= fLRUFilterIdsStack.iterator();
+               while (iterIds.hasNext()) {
+                       buf.append(iterIds.next());
+                       buf.append(SEPARATOR);
+               }
+               store.setValue(TAG_LRU_FILTERS, buf.toString());
+       }
+       
+       private String getPreferenceKey(String tag) {
+               return "CustomFiltersActionGroup." + fTargetId + '.' + tag; //$NON-NLS-1$
+       }
+
+       // ---------- view instance persistency ----------
+
+       /**
+        * Saves the state of the custom filters in a memento.
+        * 
+        * @param memento the memento into which the state is saved
+        */
+       public void saveState(IMemento memento) {
+               IMemento customFilters= memento.createChild(TAG_CUSTOM_FILTERS);
+               customFilters.putString(TAG_USER_DEFINED_PATTERNS_ENABLED, new Boolean(fUserDefinedPatternsEnabled).toString());
+               saveUserDefinedPatterns(customFilters);
+               saveXmlDefinedFilters(customFilters);
+               saveLRUFilters(customFilters);
+       }
+
+       private void saveXmlDefinedFilters(IMemento memento) {
+               if(fEnabledFilterIds != null && !fEnabledFilterIds.isEmpty()) {
+                       IMemento xmlDefinedFilters= memento.createChild(TAG_XML_DEFINED_FILTERS);
+                       Iterator<Map.Entry<String,Boolean>> iter= fEnabledFilterIds.entrySet().iterator();
+                       while (iter.hasNext()) {
+                               Map.Entry<String,Boolean> entry= iter.next();
+                               String id= entry.getKey();
+                               Boolean isEnabled= entry.getValue();
+                               IMemento child= xmlDefinedFilters.createChild(TAG_CHILD);
+                               child.putString(TAG_FILTER_ID, id);
+                               child.putString(TAG_IS_ENABLED, isEnabled.toString());
+                       }
+               }
+       }
+       /**
+        * Stores the last recently used filter Ids into
+        * the given memento
+        * 
+        * @param memento the memento into which to store the LRU filter Ids
+        * @since 3.0
+        */
+       private void saveLRUFilters(IMemento memento) {
+               if(fLRUFilterIdsStack != null && !fLRUFilterIdsStack.isEmpty()) {
+                       IMemento lruFilters= memento.createChild(TAG_LRU_FILTERS);
+                       Iterator<String> iter= fLRUFilterIdsStack.iterator();
+                       while (iter.hasNext()) {
+                               String id= iter.next();
+                               IMemento child= lruFilters.createChild(TAG_CHILD);
+                               child.putString(TAG_FILTER_ID, id);
+                       }
+               }
+       }
+
+       private void saveUserDefinedPatterns(IMemento memento) {
+               if(fUserDefinedPatterns != null && fUserDefinedPatterns.length > 0) {
+                       IMemento userDefinedPatterns= memento.createChild(TAG_USER_DEFINED_PATTERNS);
+                       for (String userDefinedPattern : fUserDefinedPatterns) {
+                               IMemento child= userDefinedPatterns.createChild(TAG_CHILD);
+                               child.putString(TAG_PATTERN, userDefinedPattern);
+                       }
+               }
+       }
+
+       /**
+        * Restores the state of the filter actions from a memento.
+        * <p>
+        * Note: This method does not refresh the viewer.
+        * </p>
+        * 
+        * @param memento the memento from which the state is restored
+        */     
+       public void restoreState(IMemento memento) {
+               if (memento == null)
+                       return;
+               IMemento customFilters= memento.getChild(TAG_CUSTOM_FILTERS);
+               if (customFilters == null)
+                       return;
+               String userDefinedPatternsEnabled= customFilters.getString(TAG_USER_DEFINED_PATTERNS_ENABLED);
+               if (userDefinedPatternsEnabled == null)
+                       return;
+
+               fUserDefinedPatternsEnabled= Boolean.valueOf(userDefinedPatternsEnabled).booleanValue();
+               restoreUserDefinedPatterns(customFilters);
+               restoreXmlDefinedFilters(customFilters);
+               restoreLRUFilters(customFilters);
+               
+               updateViewerFilters(false);
+       }
+
+       private void restoreUserDefinedPatterns(IMemento memento) {
+               IMemento userDefinedPatterns= memento.getChild(TAG_USER_DEFINED_PATTERNS);
+               if(userDefinedPatterns != null) {       
+                       IMemento children[]= userDefinedPatterns.getChildren(TAG_CHILD);
+                       String[] patterns= new String[children.length];
+                       for (int i = 0; i < children.length; i++)
+                               patterns[i]= children[i].getString(TAG_PATTERN);
+
+                       setUserDefinedPatterns(patterns);
+               } else
+                       setUserDefinedPatterns(new String[0]);
+       }
+
+       private void restoreXmlDefinedFilters(IMemento memento) {
+               IMemento xmlDefinedFilters= memento.getChild(TAG_XML_DEFINED_FILTERS);
+               if(xmlDefinedFilters != null) {
+                       IMemento[] children= xmlDefinedFilters.getChildren(TAG_CHILD);
+                       for (IMemento element : children) {
+                               String id= element.getString(TAG_FILTER_ID);
+                               Boolean isEnabled= new Boolean(element.getString(TAG_IS_ENABLED));
+                               fEnabledFilterIds.put(id, isEnabled);
+                       }
+               }
+       }
+
+       private void restoreLRUFilters(IMemento memento) {
+               IMemento lruFilters= memento.getChild(TAG_LRU_FILTERS);
+               fLRUFilterIdsStack.clear();
+               if(lruFilters != null) {
+                       IMemento[] children= lruFilters.getChildren(TAG_CHILD);
+                       for (IMemento element : children) {
+                               String id= element.getString(TAG_FILTER_ID);
+                               if (fFilterDescriptorMap.containsKey(id) && !fLRUFilterIdsStack.contains(id))
+                                       fLRUFilterIdsStack.push(id);
+                       }
+               }
+       }
+
+       private void cleanUpPatternDuplicates() {
+               if (!areUserDefinedPatternsEnabled())
+                       return;
+               List<String> userDefinedPatterns= new ArrayList<String>(Arrays.asList(fUserDefinedPatterns));
+               FilterDescriptor[] filters= FilterDescriptor.getFilterDescriptors(fTargetId);
+
+               for (FilterDescriptor filter : filters) {
+                       if (filter.isPatternFilter()) {
+                               String pattern= filter.getPattern();
+                               if (userDefinedPatterns.contains(pattern)) {
+                                       fEnabledFilterIds.put(filter.getId(), Boolean.TRUE);
+                                       boolean hasMore= true;
+                                       while (hasMore)
+                                               hasMore= userDefinedPatterns.remove(pattern);
+                               }
+                       }
+               }
+               fUserDefinedPatterns= userDefinedPatterns.toArray(new String[userDefinedPatterns.size()]);
+               setUserDefinedPatternsEnabled(fUserDefinedPatternsEnabled && fUserDefinedPatterns.length > 0);
+       }
+       
+       // ---------- dialog related code ----------
+
+       void openDialog() {
+               CustomFiltersDialog dialog= new CustomFiltersDialog(
+                       fViewer.getControl().getShell(),
+                       fTargetId,
+                       areUserDefinedPatternsEnabled(),
+                       fUserDefinedPatterns,
+                       getEnabledFilterIds());
+               
+               if (dialog.open() == Window.OK) {
+                       setEnabledFilterIds(dialog.getEnabledFilterIds());
+                       setUserDefinedPatternsEnabled(dialog.areUserDefinedPatternsEnabled());
+                       setUserDefinedPatterns(dialog.getUserDefinedPatterns());
+                       setRecentlyChangedFilters(dialog.getFilterDescriptorChangeHistory());
+
+                       storeViewDefaults();
+
+                       updateViewerFilters(true);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/DeleteResConfigsAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/DeleteResConfigsAction.java
new file mode 100644 (file)
index 0000000..eff1fc5
--- /dev/null
@@ -0,0 +1,204 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.actions;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
+import org.eclipse.ui.dialogs.ListSelectionDialog;
+
+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.ITranslationUnit;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.newui.AbstractPage;
+
+import org.eclipse.cdt.internal.ui.actions.ActionMessages;
+import org.eclipse.cdt.internal.ui.actions.DeleteResConfigsHandler;
+
+/**
+ * Action which deletes resource description. (If resource description is missing
+ * one from parent is normally used)
+ * @deprecated as of CDT 8.0 now using {@link DeleteResConfigsHandler} 
+ */
+@Deprecated
+public class DeleteResConfigsAction 
+implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
+
+       protected ArrayList<IResource> objects = null;
+       private   ArrayList<ResCfgData> outData = null;         
+
+       public void selectionChanged(IAction action, ISelection selection) {
+               objects = null;
+               outData = null;
+               
+               if (!selection.isEmpty()) {
+                       // case for context menu
+                       if (selection instanceof IStructuredSelection) {
+                               Object[] obs = ((IStructuredSelection)selection).toArray();
+                               if (obs.length > 0) {
+                                       for (int i=0; i<obs.length; i++) {
+                                               IResource res = null;
+                                               // only folders and files may be affected by this action
+                                               if (obs[i] instanceof ICContainer || obs[i] instanceof ITranslationUnit)
+                                                       res = ((ICElement)obs[i]).getResource();
+                                               // project's configuration cannot be deleted
+                                               else if (obs[i] instanceof IResource && !(obs[i] instanceof IProject))
+                                                       res = (IResource)obs[i];
+                                               if (res != null) {
+                                                       IProject p = res.getProject();
+                                                       if (!p.isOpen()) continue;
+                                                       
+                                                       if (!CoreModel.getDefault().isNewStyleProject(p))
+                                                               continue;
+
+                                                       IPath path = res.getProjectRelativePath();
+                                                       // getting description in read-only mode
+                                                       ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false);
+                                                       if (prjd == null) continue;
+                                                       ICConfigurationDescription[] cfgds = prjd.getConfigurations();
+                                                       if (cfgds == null || cfgds.length == 0) continue;
+                                                       for (ICConfigurationDescription cfgd : cfgds) {
+                                                               ICResourceDescription rd = cfgd.getResourceDescription(path, true);
+                                                               if (rd != null) {
+                                                                       if (objects == null) objects = new ArrayList<IResource>();
+                                                                       objects.add(res);
+                                                                       break; // stop configurations scanning
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               } 
+               action.setEnabled(objects != null);
+       }
+       
+       public void run(IAction action) {
+               openDialog();
+       }
+       
+       
+       private void openDialog() {
+               if (objects == null || objects.size() == 0) return; 
+               // create list of configurations to delete
+               
+               ListSelectionDialog dialog = new ListSelectionDialog(
+                               CUIPlugin.getActiveWorkbenchShell(), 
+                               objects, 
+                               createSelectionDialogContentProvider(), 
+                               new LabelProvider() {}, ActionMessages.DeleteResConfigsAction_0);
+               dialog.setTitle(ActionMessages.DeleteResConfigsAction_1);
+               if (dialog.open() == Window.OK) {
+                       Object[] selected = dialog.getResult();
+                       if (selected != null && selected.length > 0) {
+                               for (Object element : selected) {
+                                       ((ResCfgData)element).delete();
+                                       AbstractPage.updateViews(((ResCfgData)element).res);
+                               }
+                       }
+               }
+       }
+
+       // Stores data for resource description with its "parents".
+       class ResCfgData {
+               IResource res;
+               ICProjectDescription prjd;
+               ICConfigurationDescription cfgd;
+               ICResourceDescription rdesc;
+               
+               public ResCfgData(IResource res2, ICProjectDescription prjd2,
+                               ICConfigurationDescription cfgd2, ICResourceDescription rdesc2) {
+                       res = res2; prjd = prjd2; cfgd = cfgd2; rdesc = rdesc2;
+               }
+               
+               // performs deletion
+               public void delete() {
+                       try {
+                               cfgd.removeResourceDescription(rdesc);
+                               CoreModel.getDefault().setProjectDescription(res.getProject(), prjd);
+                       } catch (CoreException e) {}
+               }
+               @Override
+               public String toString() {
+                       return "[" + cfgd.getName() + "] for " + res.getName();   //$NON-NLS-1$ //$NON-NLS-2$
+               }
+       }
+       
+       
+       private IStructuredContentProvider createSelectionDialogContentProvider() {
+               return new IStructuredContentProvider() {
+
+                       public Object[] getElements(Object inputElement) {
+                               if (outData != null) return outData.toArray();
+                               
+                               outData = new ArrayList<ResCfgData>();
+                               List<?> ls = (List<?>)inputElement;
+                               Iterator<?> it = ls.iterator();
+                               IProject proj = null;
+                               ICProjectDescription prjd = null;
+                               ICConfigurationDescription[] cfgds = null;
+
+                               // creating list of all res descs for all objects
+                               while (it.hasNext()) {
+                                       IResource res = (IResource)it.next();
+                                       IPath path = res.getProjectRelativePath();
+                                       if (res.getProject() != proj) {
+                                               proj = res.getProject();
+                                               prjd = CoreModel.getDefault().getProjectDescription(proj);
+                                               cfgds = prjd.getConfigurations();
+                                       }
+                                       if (cfgds != null) {
+                                               for (ICConfigurationDescription cfgd : cfgds) {
+                                                       ICResourceDescription rd = cfgd.getResourceDescription(path, true);
+                                                       if (rd != null) 
+                                                               outData.add(new ResCfgData(res, prjd, cfgd, rd));
+                                               }
+                                       }
+                               }
+                               return outData.toArray();
+                       }
+                       public void dispose() {}
+                       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+               };
+       }
+       
+       public void dispose() { objects = null; }
+       
+       // doing nothing
+       public void init(IWorkbenchWindow window) { }
+       public Menu getMenu(Menu parent) { return null; }
+       public Menu getMenu(Control parent) { return null; }
+       public void setActivePart(IAction action, IWorkbenchPart targetPart) {}
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ExcludeFromBuildAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ExcludeFromBuildAction.java
new file mode 100644 (file)
index 0000000..d9aeb99
--- /dev/null
@@ -0,0 +1,228 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.actions;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
+import org.eclipse.ui.dialogs.ListSelectionDialog;
+
+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.ITranslationUnit;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICSourceEntry;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.newui.AbstractPage;
+
+import org.eclipse.cdt.internal.ui.actions.ActionMessages;
+import org.eclipse.cdt.internal.ui.actions.ExcludeFromBuildHandler;
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * Action which excludes resources from build.
+ * @deprecated as of CDT 8.0 now using {@link ExcludeFromBuildHandler}
+ */
+@Deprecated
+public class ExcludeFromBuildAction 
+implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
+
+       protected ArrayList<IResource> objects = null;
+       protected ArrayList<String> cfgNames = null;
+
+       public void selectionChanged(IAction action, ISelection selection) {
+               objects = null;
+               cfgNames = null;
+               boolean cfgsOK = true;
+               
+               if (!selection.isEmpty()) {
+                       // case for context menu
+                       if (selection instanceof IStructuredSelection) {
+                               Object[] obs = ((IStructuredSelection)selection).toArray();
+                               if (obs.length > 0) {
+                                       for (int i=0; i<obs.length && cfgsOK; i++) {
+                                               // if project selected, don't do anything
+                                               if ((obs[i] instanceof IProject) || (obs[i] instanceof ICProject)) {
+                                                       cfgsOK=false; 
+                                                       break;
+                                               }
+                                               IResource res = null;
+                                               // only folders and files may be affected by this action
+                                               if (obs[i] instanceof ICContainer || obs[i] instanceof ITranslationUnit) {
+                                                       res = ((ICElement) obs[i]).getResource();
+                                               } else if (obs[i] instanceof IResource) {
+                                                       // project's configuration cannot be deleted
+                                                       res = (IResource) obs[i];
+                                               }
+                                               if (res != null) {
+                                                       ICConfigurationDescription[] cfgds = getCfgsRead(res);
+                                                       if (cfgds == null || cfgds.length == 0) continue;
+                                                       
+                                                       if (objects == null) objects = new ArrayList<IResource>();
+                                                       objects.add(res);
+                                                       if (cfgNames == null) {
+                                                               cfgNames = new ArrayList<String>(cfgds.length);
+                                                               for (int j=0; j<cfgds.length; j++) { 
+                                                                       if (!canExclude(res, cfgds[j])) {
+                                                                               cfgNames = null;
+                                                                               cfgsOK = false;
+                                                                               break;
+                                                                       }
+                                                                       cfgNames.add(cfgds[j].getName());
+                                                               }
+                                                       } else {
+                                                               if (cfgNames.size() != cfgds.length) {
+                                                                       cfgsOK = false;
+                                                               } else {
+                                                                       for (int j=0; j<cfgds.length; j++) {
+                                                                               if (! canExclude(res, cfgds[j]) ||
+                                                                                       ! cfgNames.contains(cfgds[j].getName())) {
+                                                                                       cfgsOK = false;
+                                                                                       break;
+                                                                               }
+                                                                       }
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               } 
+               action.setEnabled(cfgsOK && objects != null );
+       }
+
+       private boolean canExclude(IResource res, ICConfigurationDescription cfg) {
+               IPath p = res.getFullPath();
+               ICSourceEntry[] ent = cfg.getSourceEntries();
+               boolean state = CDataUtil.isExcluded(p, ent);
+               return CDataUtil.canExclude(p, (res instanceof IFolder), !state, ent);
+       }
+
+       private void setExclude(IResource res, ICConfigurationDescription cfg, boolean exclude) {
+               try {
+                       ICSourceEntry[] newEntries = CDataUtil.setExcluded(res.getFullPath(), (res instanceof IFolder), exclude, cfg.getSourceEntries());
+                       cfg.setSourceEntries(newEntries);
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }                                       
+       }
+       
+       public void run(IAction action) {
+               openDialog();
+       }
+       
+       private ICConfigurationDescription[] getCfgsRead(IResource res) {
+               IProject p = res.getProject();
+               if (!p.isOpen()) return null;
+               if (!CoreModel.getDefault().isNewStyleProject(p)) return null;
+               ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false);
+               if (prjd == null) return null;
+               return prjd.getConfigurations();
+       }
+       
+       private void openDialog() {
+               if (objects == null || objects.size() == 0) return; 
+               // create list of configurations to delete
+               
+               ListSelectionDialog dialog = new ListSelectionDialog(
+                               CUIPlugin.getActiveWorkbenchShell(), 
+                               cfgNames, 
+                               createSelectionDialogContentProvider(), 
+                               new LabelProvider() {}, 
+                               ActionMessages.ExcludeFromBuildAction_0);
+               dialog.setTitle(ActionMessages.ExcludeFromBuildAction_1);
+               
+               boolean[] status = new boolean[cfgNames.size()];
+               Iterator<IResource> it = objects.iterator();
+               while (it.hasNext()) {
+                       IResource res = it.next();
+                       ICConfigurationDescription[] cfgds = getCfgsRead(res);
+                       IPath p = res.getFullPath();
+                       for (int i=0; i<cfgds.length; i++) {
+                               boolean b = CDataUtil.isExcluded(p, cfgds[i].getSourceEntries());
+                               if (b) status[i] = true;
+                       }
+               }
+               ArrayList<String> lst = new ArrayList<String>();
+               for (int i=0; i<status.length; i++) 
+                       if (status[i]) lst.add(cfgNames.get(i));
+               if (lst.size() > 0)
+                       dialog.setInitialElementSelections(lst);
+               
+               if (dialog.open() == Window.OK) {
+                       Object[] selected = dialog.getResult(); // may be empty
+                       Iterator<IResource> it2 = objects.iterator();
+                       while (it2.hasNext()) {
+                               IResource res = it2.next();
+                               IProject p = res.getProject();
+                               if (!p.isOpen()) continue;
+                               // get writable description
+                               ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, true);
+                               if (prjd == null) continue;
+                               ICConfigurationDescription[] cfgds = prjd.getConfigurations();
+                               for (int i=0; i<cfgds.length; i++) {
+                                       boolean exclude = false;
+                                       for (int j=0; j<selected.length; j++) {
+                                               if (cfgds[i].getName().equals(selected[j])) {
+                                                       exclude = true;
+                                                       break;
+                                               }
+                                       }
+                                       setExclude(res, cfgds[i], exclude);
+                               }
+                               try {
+                                       CoreModel.getDefault().setProjectDescription(p, prjd);
+                               } catch (CoreException e) {
+                                       CUIPlugin.logError(Messages.AbstractPage_11 + e.getLocalizedMessage()); 
+                               }
+                               AbstractPage.updateViews(res);
+                       }
+               }
+       }
+
+       private IStructuredContentProvider createSelectionDialogContentProvider() {
+               return new IStructuredContentProvider() {
+                       public Object[] getElements(Object inputElement) { return cfgNames.toArray(); }
+                       public void dispose() {}
+                       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+               };
+       }
+       
+       public void dispose() { objects = null; }
+       
+       // doing nothing
+       public void init(IWorkbenchWindow window) { }
+       public Menu getMenu(Menu parent) { return null; }
+       public Menu getMenu(Control parent) { return null; }
+       public void setActivePart(IAction action, IWorkbenchPart targetPart) {}
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/FormatAllAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/FormatAllAction.java
new file mode 100644 (file)
index 0000000..3b37dfd
--- /dev/null
@@ -0,0 +1,418 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.actions;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+
+import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.core.filebuffers.ITextFileBuffer;
+import org.eclipse.core.filebuffers.ITextFileBufferManager;
+import org.eclipse.core.filebuffers.LocationKind;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+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.MultiStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.text.DocumentRewriteSession;
+import org.eclipse.jface.text.DocumentRewriteSessionType;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentExtension;
+import org.eclipse.jface.text.IDocumentExtension4;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.formatter.FormattingContext;
+import org.eclipse.jface.text.formatter.FormattingContextProperties;
+import org.eclipse.jface.text.formatter.IFormattingContext;
+import org.eclipse.jface.text.formatter.MultiPassContentFormatter;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
+import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
+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.ILanguage;
+import org.eclipse.cdt.core.model.ISourceRoot;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CDTUITools;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+import org.eclipse.cdt.internal.corext.util.Resources;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.actions.ActionMessages;
+import org.eclipse.cdt.internal.ui.actions.WorkbenchRunnableAdapter;
+import org.eclipse.cdt.internal.ui.dialogs.OptionalMessageDialog;
+import org.eclipse.cdt.internal.ui.text.CFormattingStrategy;
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
+
+/**
+ * Formats the code of the translation units contained in the selection.
+ * <p>
+ * The action is applicable to selections containing elements of
+ * type <code>ITranslationUnit</code>, <code>ICContainer</code>
+ * and <code>ICProject</code>.
+ * </p>
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ *
+ * @since 5.3
+ *
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class FormatAllAction extends SelectionDispatchAction {
+
+       /*
+        * Class implements IObjectActionDelegate
+        */
+       public static class ObjectDelegate implements IObjectActionDelegate {
+               private FormatAllAction fAction;
+               public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+                       fAction= new FormatAllAction(targetPart.getSite());
+               }
+               public void run(IAction action) {
+                       fAction.run();
+               }
+               public void selectionChanged(IAction action, ISelection selection) {
+                       if (fAction == null)
+                               action.setEnabled(false);
+               }
+       }
+
+       private DocumentRewriteSession fRewriteSession;
+
+       /**
+        * Creates a new <code>FormatAllAction</code>. The action requires
+        * that the selection provided by the site's selection provider is of type <code>
+        * org.eclipse.jface.viewers.IStructuredSelection</code>.
+        *
+        * @param site the site providing context information for this action
+        */
+       public FormatAllAction(IWorkbenchSite site) {
+               super(site);
+               setText(ActionMessages.FormatAllAction_label);
+               setToolTipText(ActionMessages.FormatAllAction_tooltip);
+               setDescription(ActionMessages.FormatAllAction_description);
+               
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.FORMAT_ALL);                                   
+       }
+
+
+       @Override
+       public void selectionChanged(ITextSelection selection) {
+               // do nothing
+       }
+
+       @Override
+       public void selectionChanged(IStructuredSelection selection) {
+               setEnabled(isEnabled(selection));
+       }
+
+       private ITranslationUnit[] getTranslationUnits(IStructuredSelection selection) {
+               HashSet<ICElement> result= new HashSet<ICElement>();
+               Object[] selected= selection.toArray();
+               for (int i= 0; i < selected.length; i++) {
+                       try {
+                               if (selected[i] instanceof ICElement) {
+                                       ICElement elem= (ICElement) selected[i];
+                                       if (elem.exists()) {
+                                               switch (elem.getElementType()) {
+                                                       case ICElement.C_UNIT:
+                                                               result.add(elem);
+                                                               break;          
+                                                       case ICElement.C_CCONTAINER:
+                                                               collectTranslationUnits((ICContainer) elem, result);
+                                                               break;
+                                                       case ICElement.C_PROJECT:
+                                                               collectTranslationUnits((ICProject) elem, result);
+                                                               break;
+                                               }
+                                       }
+                               } else if (selected[i] instanceof IProject) {
+                                       final IProject project = (IProject) selected[i];
+                                       if (CoreModel.hasCNature(project)) {
+                                               collectTranslationUnits(CoreModel.getDefault().create(project), result);
+                                       }
+                               }
+                       } catch (CModelException e) {
+                               CUIPlugin.log(e);
+                       }
+               }
+               return result.toArray(new ITranslationUnit[result.size()]);
+       }
+       
+       private void collectTranslationUnits(ICProject project, Collection<ICElement> result) throws CModelException {
+               ISourceRoot[] roots = project.getSourceRoots();
+               for (ISourceRoot root : roots) {
+                       collectTranslationUnits(root, result);
+               }
+       }
+
+       private void collectTranslationUnits(ICContainer container, Collection<ICElement> result) throws CModelException {
+               ICElement[] children= container.getChildren();
+               for (int i= 0; i < children.length; i++) {
+                       ICElement elem= children[i];
+                       if (elem.exists()) {
+                               switch (elem.getElementType()) {
+                               case ICElement.C_UNIT:
+                                       result.add(elem);
+                                       break;
+                               case ICElement.C_CCONTAINER:
+                                       collectTranslationUnits((ICContainer) elem, result);
+                                       break;
+                               }
+                       }
+               }
+       }       
+
+       private boolean isEnabled(IStructuredSelection selection) {
+               Object[] selected= selection.toArray();
+               for (int i= 0; i < selected.length; i++) {
+                       if (selected[i] instanceof ICElement) {
+                               ICElement elem= (ICElement) selected[i];
+                               if (elem.exists()) {
+                                       switch (elem.getElementType()) {
+                                               case ICElement.C_UNIT:
+                                               case ICElement.C_CCONTAINER:
+                                               case ICElement.C_PROJECT:
+                                                       return true;
+                                       }
+                               }
+                       } else if (selected[i] instanceof IProject) {
+                               if (CoreModel.hasCNature((IProject) selected[i])) {
+                                       return true;
+                               }
+                       }
+               }
+               return false;
+       }
+       
+       @Override
+       public void run(ITextSelection selection) {
+       }
+
+       @Override
+       public void run(IStructuredSelection selection) {
+               ITranslationUnit[] tus= getTranslationUnits(selection);
+               if (tus.length == 0)
+                       return;
+               if (tus.length > 1) {
+                       int returnCode= OptionalMessageDialog.open("FormatAll",  //$NON-NLS-1$
+                                       getShell(), 
+                                       ActionMessages.FormatAllAction_noundo_title, 
+                                       null,
+                                       ActionMessages.FormatAllAction_noundo_message,  
+                                       MessageDialog.WARNING,          
+                                       new String[] {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL}, 
+                                       0);
+                       if (returnCode != OptionalMessageDialog.NOT_SHOWN && 
+                                       returnCode != Window.OK ) return;
+               }
+                               
+               IStatus status= Resources.makeCommittable(getResources(tus), getShell());
+               if (!status.isOK()) {
+                       ErrorDialog.openError(getShell(), ActionMessages.FormatAllAction_failedvalidateedit_title, ActionMessages.FormatAllAction_failedvalidateedit_message, status); 
+                       return;
+               }
+               
+               runOnMultiple(tus);
+       }
+
+       private IResource[] getResources(ITranslationUnit[] tus) {
+               IResource[] res= new IResource[tus.length];
+               for (int i= 0; i < res.length; i++) {
+                       res[i]= tus[i].getResource();
+               }
+               return res;
+       }
+
+       /**
+        * Perform format all on the given translation units.
+        * @param tus The translation units to format.
+        */
+       public void runOnMultiple(final ITranslationUnit[] tus) {
+               try {
+                       String message= ActionMessages.FormatAllAction_status_description; 
+                       final MultiStatus status= new MultiStatus(CUIPlugin.PLUGIN_ID, IStatus.OK, message, null);
+                       
+                       if (tus.length == 1) {
+                               EditorUtility.openInEditor(tus[0]);
+                       }
+                       
+                       PlatformUI.getWorkbench().getProgressService().run(true, true, new WorkbenchRunnableAdapter(new IWorkspaceRunnable() {
+                               public void run(IProgressMonitor monitor) {
+                                       doRunOnMultiple(tus, status, monitor);
+                               }
+                       })); // workspace lock
+                       if (!status.isOK()) {
+                               String title= ActionMessages.FormatAllAction_multi_status_title; 
+                               ErrorDialog.openError(getShell(), title, null, status);
+                       }
+               } catch (InvocationTargetException e) {
+                       ExceptionHandler.handle(e, getShell(), ActionMessages.FormatAllAction_error_title, ActionMessages.FormatAllAction_error_message); 
+               } catch (InterruptedException e) {
+                       // Canceled by user
+               } catch (CoreException e) {
+                       ExceptionHandler.handle(e, getShell(), ActionMessages.FormatAllAction_error_title, ActionMessages.FormatAllAction_error_message); 
+               }
+       }
+
+       private static Map<String, Object> getFomatterSettings(ICProject project) {
+               return new HashMap<String, Object>(project.getOptions(true));
+       }
+       
+       private void doFormat(IDocument document, Map<String, Object> options) {
+               final IFormattingContext context = new FormattingContext();
+               try {
+                       context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, options);
+                       context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.valueOf(true));
+
+                       final MultiPassContentFormatter formatter= new MultiPassContentFormatter(ICPartitions.C_PARTITIONING, IDocument.DEFAULT_CONTENT_TYPE);
+                       formatter.setMasterStrategy(new CFormattingStrategy());
+
+                       try {
+                               startSequentialRewriteMode(document);
+                               formatter.format(document, context);
+                       } finally {
+                               stopSequentialRewriteMode(document);
+                       }
+               } finally {
+                   context.dispose();
+               }
+    }
+
+       @SuppressWarnings("deprecation")
+       private void startSequentialRewriteMode(IDocument document) {
+               if (document instanceof IDocumentExtension4) {
+                       IDocumentExtension4 extension= (IDocumentExtension4) document;
+                       fRewriteSession= extension.startRewriteSession(DocumentRewriteSessionType.SEQUENTIAL);
+               } else if (document instanceof IDocumentExtension) {
+                       IDocumentExtension extension= (IDocumentExtension) document;
+                       extension.startSequentialRewrite(false);
+               }
+       }
+       
+       @SuppressWarnings("deprecation")
+       private void stopSequentialRewriteMode(IDocument document) {
+               if (document instanceof IDocumentExtension4) {
+                       IDocumentExtension4 extension= (IDocumentExtension4) document;
+                       extension.stopRewriteSession(fRewriteSession);
+               } else if (document instanceof IDocumentExtension) {
+                       IDocumentExtension extension= (IDocumentExtension)document;
+                       extension.stopSequentialRewrite();
+               }
+       }
+       
+       private void doRunOnMultiple(ITranslationUnit[] tus, MultiStatus status, IProgressMonitor monitor) throws OperationCanceledException {
+               if (monitor == null) {
+                       monitor= new NullProgressMonitor();
+               }       
+               monitor.setTaskName(ActionMessages.FormatAllAction_operation_description); 
+       
+               monitor.beginTask("", tus.length * 4); //$NON-NLS-1$
+               try {
+                       Map<String, Object> lastOptions= null;
+                       ICProject lastProject= null;
+                       
+                       for (int i= 0; i < tus.length; i++) {
+                               ITranslationUnit tu= tus[i];
+                               IPath path= tu.getPath();
+                               if (lastProject == null || lastOptions == null|| !lastProject.equals(tu.getCProject())) {
+                                       lastProject= tu.getCProject();
+                                       lastOptions= getFomatterSettings(lastProject);
+                               }
+                               
+                               ILanguage language= null;
+                               try {
+                                       language= tu.getLanguage();
+                               } catch (CoreException exc) {
+                                       // use fallback CPP
+                                       language= GPPLanguage.getDefault();
+                               }
+                               
+                               // use working copy if available
+                               ITranslationUnit wc = CDTUITools.getWorkingCopyManager().findSharedWorkingCopy(tu);
+                               if (wc != null) {
+                                       tu = wc;
+                               }
+                               lastOptions.put(DefaultCodeFormatterConstants.FORMATTER_TRANSLATION_UNIT, tu);
+                               lastOptions.put(DefaultCodeFormatterConstants.FORMATTER_LANGUAGE, language);
+                               lastOptions.put(DefaultCodeFormatterConstants.FORMATTER_CURRENT_FILE, tu.getResource());
+
+                               if (monitor.isCanceled()) {
+                                       throw new OperationCanceledException();
+                               }
+                               
+                               ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
+                               try {
+                                       try {
+                                               manager.connect(path, LocationKind.IFILE, new SubProgressMonitor(monitor, 1));
+               
+                                               monitor.subTask(path.makeRelative().toString());
+                                               ITextFileBuffer fileBuffer= manager.getTextFileBuffer(path, LocationKind.IFILE);
+                                               boolean wasDirty = fileBuffer.isDirty();
+                                               
+                                               formatTranslationUnit(fileBuffer, lastOptions);
+                                               
+                                               if (fileBuffer.isDirty() && !wasDirty) {
+                                                       fileBuffer.commit(new SubProgressMonitor(monitor, 2), false);
+                                               } else {
+                                                       monitor.worked(2);
+                                               }
+                                       } finally {
+                                               manager.disconnect(path, LocationKind.IFILE, new SubProgressMonitor(monitor, 1));
+                                       }
+                               } catch (CoreException e) {
+                                       status.add(e.getStatus());
+                               }
+                       }
+               } finally {
+                       monitor.done();
+               }
+       }
+       
+       private void formatTranslationUnit(final ITextFileBuffer fileBuffer, final Map<String, Object> options) {
+               if (fileBuffer.isShared()) {
+                       getShell().getDisplay().syncExec(new Runnable() {
+                               public void run() {
+                                       doFormat(fileBuffer.getDocument(), options);
+                               }
+                       });
+               } else {
+                       doFormat(fileBuffer.getDocument(), options); // run in context thread
+               }
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/GenerateActionGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/GenerateActionGroup.java
new file mode 100644 (file)
index 0000000..60f8dde
--- /dev/null
@@ -0,0 +1,559 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2010 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems) - Adapted for CDT
+ *******************************************************************************/
+package org.eclipse.cdt.ui.actions;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchCommandConstants;
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.actions.AddBookmarkAction;
+import org.eclipse.ui.actions.AddTaskAction;
+import org.eclipse.ui.handlers.IHandlerActivation;
+import org.eclipse.ui.handlers.IHandlerService;
+import org.eclipse.ui.ide.IDEActionFactory;
+import org.eclipse.ui.part.Page;
+import org.eclipse.ui.texteditor.ITextEditorActionConstants;
+import org.eclipse.ui.texteditor.IUpdate;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.ui.refactoring.actions.GettersAndSettersAction;
+import org.eclipse.cdt.ui.refactoring.actions.ImplementMethodAction;
+import org.eclipse.cdt.ui.refactoring.actions.RefactoringAction;
+
+import org.eclipse.cdt.internal.ui.IContextMenuConstants;
+import org.eclipse.cdt.internal.ui.actions.ActionMessages;
+import org.eclipse.cdt.internal.ui.actions.CDTQuickMenuCreator;
+import org.eclipse.cdt.internal.ui.editor.AddIncludeOnSelectionAction;
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
+import org.eclipse.cdt.internal.ui.editor.SortLinesAction;
+
+/**
+ * Action group that adds the source and generate actions to a part's context
+ * menu and installs handlers for the corresponding global menu actions.
+ * 
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ * @since 4.0
+ */
+public class GenerateActionGroup extends ActionGroup implements ISelectionChangedListener {
+       
+       /**
+        * Pop-up menu: id of the source sub menu (value <code>org.eclipse.cdt.ui.source.menu</code>).
+        */
+       public static final String MENU_ID= "org.eclipse.cdt.ui.source.menu"; //$NON-NLS-1$
+       
+       /**
+        * Pop-up menu: id of the organize group of the source sub menu (value
+        * <code>organizeGroup</code>).
+        */
+       public static final String GROUP_ORGANIZE= "organizeGroup";  //$NON-NLS-1$
+       
+       /**
+        * Pop-up menu: id of the generate group of the source sub menu (value
+        * <code>generateGroup</code>).
+        */
+       public static final String GROUP_GENERATE= "generateGroup";  //$NON-NLS-1$
+
+       /**
+        * Pop-up menu: id of the code group of the source sub menu (value
+        * <code>codeGroup</code>).
+        */
+       public static final String GROUP_CODE= "codeGroup";  //$NON-NLS-1$
+
+       /**
+        * Pop-up menu: id of the externalize group of the source sub menu (value
+        * <code>externalizeGroup</code>).
+        */
+       private static final String GROUP_EXTERNALIZE= "externalizeGroup"; //$NON-NLS-1$
+
+       /**
+        * Pop-up menu: id of the comment group of the source sub menu (value
+        * <code>commentGroup</code>).
+        */
+       private static final String GROUP_COMMENT= "commentGroup"; //$NON-NLS-1$
+
+       /**
+        * Pop-up menu: id of the edit group of the source sub menu (value
+        * <code>editGroup</code>).
+        */
+       private static final String GROUP_EDIT= "editGroup"; //$NON-NLS-1$
+       
+       private CEditor fEditor;
+       private IWorkbenchSite fSite;
+       private String fGroupName= IContextMenuConstants.GROUP_REORGANIZE;
+       private List<ISelectionChangedListener> fRegisteredSelectionListeners;
+       private List<RefactoringAction> fRefactorActions= new ArrayList<RefactoringAction>();
+       
+       private AddIncludeOnSelectionAction fAddInclude;
+//     private OverrideMethodsAction fOverrideMethods;
+//     private GenerateHashCodeEqualsAction fHashCodeEquals;
+       private GettersAndSettersAction fAddGetterSetter;
+       private ImplementMethodAction fImplementMethod;
+//     private AddDelegateMethodsAction fAddDelegateMethods;
+//     private AddUnimplementedConstructorsAction fAddUnimplementedConstructors;
+//     private GenerateNewConstructorUsingFieldsAction fGenerateConstructorUsingFields;
+//     private AddJavaDocStubAction fAddCppDocStub;
+       private AddBookmarkAction fAddBookmark;
+       private AddTaskAction fAddTaskAction;
+//     private ExternalizeStringsAction fExternalizeStrings;
+//     private CleanUpAction fCleanUp; 
+//     
+//     private OrganizeIncludesAction fOrganizeIncludes;
+//     private SortMembersAction fSortMembers;
+       private SortLinesAction fSortLines;
+       private FormatAllAction fFormatAll;
+//     private CopyQualifiedNameAction fCopyQualifiedNameAction;
+//     
+       private static final String QUICK_MENU_ID= "org.eclipse.cdt.ui.edit.text.c.source.quickMenu"; //$NON-NLS-1$
+
+       private IHandlerActivation fQuickAccessHandlerActivation;
+       private IHandlerService fHandlerService;
+
+
+       /**
+        * Note: This constructor is for internal use only. Clients should not call this constructor.
+        * @param editor the C editor
+        * @param groupName the group name to add the action to
+        * 
+        * @noreference This constructor is not intended to be referenced by clients.
+        */
+       public GenerateActionGroup(CEditor editor, String groupName) {
+               fSite= editor.getSite();
+               fEditor= editor;
+               fGroupName= groupName;
+               
+               fAddInclude= new AddIncludeOnSelectionAction(editor);
+               fAddInclude.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_INCLUDE);
+               editor.setAction("AddIncludeOnSelection", fAddInclude); //$NON-NLS-1$
+               
+//             fOrganizeIncludes= new OrganizeIncludesAction(editor);
+//             fOrganizeIncludes.setActionDefinitionId(ICEditorActionDefinitionIds.ORGANIZE_INCLUDES);
+//             editor.setAction("OrganizeIncludes", fOrganizeIncludes); //$NON-NLS-1$
+//
+//             fSortMembers= new SortMembersAction(editor);
+//             fSortMembers.setActionDefinitionId(ICEditorActionDefinitionIds.SORT_MEMBERS);
+//             editor.setAction("SortMembers", fSortMembers); //$NON-NLS-1$
+
+               fSortLines= new SortLinesAction(editor);
+               fSortLines.setActionDefinitionId(ICEditorActionDefinitionIds.SORT_LINES);
+               editor.setAction("SortLines", fSortLines); //$NON-NLS-1$
+               
+//             IAction pastAction= editor.getAction(ITextEditorActionConstants.PASTE);//IWorkbenchActionDefinitionIds.PASTE);
+//             fCopyQualifiedNameAction= new CopyQualifiedNameAction(editor, null, pastAction);
+//             fCopyQualifiedNameAction.setActionDefinitionId(CopyQualifiedNameAction.JAVA_EDITOR_ACTION_DEFINITIONS_ID);
+//             editor.setAction("CopyQualifiedName", fCopyQualifiedNameAction); //$NON-NLS-1$
+//
+//             fOverrideMethods= new OverrideMethodsAction(editor);
+//             fOverrideMethods.setActionDefinitionId(ICEditorActionDefinitionIds.OVERRIDE_METHODS);
+//             editor.setAction("OverrideMethods", fOverrideMethods); //$NON-NLS-1$
+//             
+               fAddGetterSetter= new GettersAndSettersAction(editor);
+               fAddGetterSetter.setActionDefinitionId(ICEditorActionDefinitionIds.GETTERS_AND_SETTERS);
+               editor.setAction("org.eclipse.cdt.ui.refactor.getters.and.setters", fAddGetterSetter); //$NON-NLS-1$
+               
+               fImplementMethod = new ImplementMethodAction(editor);
+               fImplementMethod.setActionDefinitionId(ICEditorActionDefinitionIds.IMPLEMENT_METHOD);
+               editor.setAction("org.eclipse.cdt.ui.refactor.implement.method", fImplementMethod); //$NON-NLS-1$
+//
+//             fAddDelegateMethods= new AddDelegateMethodsAction(editor);
+//             fAddDelegateMethods.setActionDefinitionId(ICEditorActionDefinitionIds.CREATE_DELEGATE_METHODS);
+//             editor.setAction("AddDelegateMethods", fAddDelegateMethods); //$NON-NLS-1$
+//                     
+//             fAddUnimplementedConstructors= new AddUnimplementedConstructorsAction(editor);
+//             fAddUnimplementedConstructors.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_UNIMPLEMENTED_CONTRUCTORS);
+//             editor.setAction("AddUnimplementedConstructors", fAddUnimplementedConstructors); //$NON-NLS-1$          
+//
+//             fGenerateConstructorUsingFields= new GenerateNewConstructorUsingFieldsAction(editor);
+//             fGenerateConstructorUsingFields.setActionDefinitionId(ICEditorActionDefinitionIds.GENERATE_CONSTRUCTOR_USING_FIELDS);
+//             editor.setAction("GenerateConstructorUsingFields", fGenerateConstructorUsingFields); //$NON-NLS-1$              
+//
+//             fHashCodeEquals= new GenerateHashCodeEqualsAction(editor);
+//             fHashCodeEquals.setActionDefinitionId(ICEditorActionDefinitionIds.GENERATE_HASHCODE_EQUALS);
+//             editor.setAction("GenerateHashCodeEquals", fHashCodeEquals); //$NON-NLS-1$
+//
+//             fAddCppDocStub= new AddJavaDocStubAction(editor);
+//             fAddCppDocStub.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_JAVADOC_COMMENT);
+//             editor.setAction("AddJavadocComment", fAddCppDocStub); //$NON-NLS-1$
+//             
+//             fCleanUp= new CleanUpAction(editor);
+//             fCleanUp.setActionDefinitionId(ICEditorActionDefinitionIds.CLEAN_UP);
+//             editor.setAction("CleanUp", fCleanUp); //$NON-NLS-1$
+//             
+//             fExternalizeStrings= new ExternalizeStringsAction(editor);
+//             fExternalizeStrings.setActionDefinitionId(ICEditorActionDefinitionIds.EXTERNALIZE_STRINGS);
+//             editor.setAction("ExternalizeStrings", fExternalizeStrings); //$NON-NLS-1$      
+//                             
+               installQuickAccessAction();
+       }
+       
+       /**
+        * Creates a new <code>GenerateActionGroup</code>. The group 
+        * requires that the selection provided by the page's selection provider 
+        * is of type <code>org.eclipse.jface.viewers.IStructuredSelection</code>.
+        * 
+        * @param page the page that owns this action group
+        */
+       public GenerateActionGroup(Page page) {
+               this(page.getSite());
+       }
+
+       /**
+        * Creates a new <code>GenerateActionGroup</code>. The group 
+        * requires that the selection provided by the part's selection provider 
+        * is of type <code>org.eclipse.jface.viewers.IStructuredSelection</code>.
+        * 
+        * @param part the view part that owns this action group
+        */
+       public GenerateActionGroup(IViewPart part) {
+               this(part.getSite());
+       }
+       
+       private GenerateActionGroup(IWorkbenchSite site) {
+               fSite= site;
+               ISelectionProvider provider= fSite.getSelectionProvider();
+               ISelection selection= provider.getSelection();
+               
+//             fOverrideMethods= new OverrideMethodsAction(site);
+//             fOverrideMethods.setActionDefinitionId(ICEditorActionDefinitionIds.OVERRIDE_METHODS);
+//             
+               fAddGetterSetter = new GettersAndSettersAction();
+               fAddGetterSetter.setActionDefinitionId(ICEditorActionDefinitionIds.GETTERS_AND_SETTERS);
+               fAddGetterSetter.setSite(fSite);
+               fRefactorActions.add(fAddGetterSetter);
+
+               fImplementMethod = new ImplementMethodAction();
+               fImplementMethod.setActionDefinitionId(ICEditorActionDefinitionIds.IMPLEMENT_METHOD);
+               fImplementMethod.setSite(fSite);
+               fRefactorActions.add(fImplementMethod);
+
+//             fAddDelegateMethods= new AddDelegateMethodsAction(site);
+//             fAddDelegateMethods.setActionDefinitionId(ICEditorActionDefinitionIds.CREATE_DELEGATE_METHODS);
+//             
+//             fAddUnimplementedConstructors= new AddUnimplementedConstructorsAction(site);
+//             fAddUnimplementedConstructors.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_UNIMPLEMENTED_CONTRUCTORS);
+//             
+//             fGenerateConstructorUsingFields= new GenerateNewConstructorUsingFieldsAction(site);
+//             fGenerateConstructorUsingFields.setActionDefinitionId(ICEditorActionDefinitionIds.GENERATE_CONSTRUCTOR_USING_FIELDS);
+//
+//             fHashCodeEquals= new GenerateHashCodeEqualsAction(site);
+//             fHashCodeEquals.setActionDefinitionId(ICEditorActionDefinitionIds.GENERATE_HASHCODE_EQUALS);
+//
+//             fAddCppDocStub= new AddJavaDocStubAction(site);
+//             fAddCppDocStub.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_JAVADOC_COMMENT);
+               
+               fAddBookmark= new AddBookmarkAction(site, true);
+               fAddBookmark.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_ADD_BOOKMARK);
+               
+               fAddTaskAction= new AddTaskAction(site);
+               fAddTaskAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_ADD_TASK);
+               
+//             fExternalizeStrings= new ExternalizeStringsAction(site);
+//             fExternalizeStrings.setActionDefinitionId(ICEditorActionDefinitionIds.EXTERNALIZE_STRINGS);
+//             
+//             fOrganizeIncludes= new OrganizeIncludesAction(site);
+//             fOrganizeIncludes.setActionDefinitionId(ICEditorActionDefinitionIds.ORGANIZE_INCLUDES);
+//             
+//             fSortMembers= new SortMembersAction(site);
+//             fSortMembers.setActionDefinitionId(ICEditorActionDefinitionIds.SORT_MEMBERS);
+//             
+               fFormatAll= new FormatAllAction(site);
+               fFormatAll.setActionDefinitionId(ICEditorActionDefinitionIds.FORMAT);
+//             
+//             fCleanUp= new CleanUpAction(site);
+//             fCleanUp.setActionDefinitionId(ICEditorActionDefinitionIds.CLEAN_UP);
+
+               
+//             fOverrideMethods.update(selection);
+//             fAddDelegateMethods.update(selection);
+//             fAddUnimplementedConstructors.update(selection);        
+//             fGenerateConstructorUsingFields.update(selection);
+//             fHashCodeEquals.update(selection);
+//             fAddCppDocStub.update(selection);
+//             fExternalizeStrings.update(selection);
+//             fFindNLSProblems.update(selection);
+//             fCleanUp.update(selection);
+//             fOrganizeIncludes.update(selection);
+//             fSortMembers.update(selection);
+               fFormatAll.update(selection);
+               if (selection instanceof IStructuredSelection) {
+                       IStructuredSelection ss= (IStructuredSelection)selection;
+                       fAddBookmark.selectionChanged(ss);
+                       fAddTaskAction.selectionChanged(ss);
+               } else {
+                       fAddBookmark.setEnabled(false);
+                       fAddTaskAction.setEnabled(false);
+               }
+               
+//             registerSelectionListener(provider, fOverrideMethods);
+//             registerSelectionListener(provider, fAddDelegateMethods);
+//             registerSelectionListener(provider, fAddUnimplementedConstructors);
+//             registerSelectionListener(provider, fGenerateConstructorUsingFields);
+//             registerSelectionListener(provider, fHashCodeEquals);
+//             registerSelectionListener(provider, fAddCppDocStub);
+               registerSelectionListener(provider, fAddBookmark);
+//             registerSelectionListener(provider, fExternalizeStrings);
+//             registerSelectionListener(provider, fFindNLSProblems);
+//             registerSelectionListener(provider, fOrganizeIncludes);
+               registerSelectionListener(provider, fFormatAll);
+//             registerSelectionListener(provider, fSortMembers);
+               registerSelectionListener(provider, fAddTaskAction);
+//             registerSelectionListener(provider, fCleanUp);
+               
+               selectionChanged(new SelectionChangedEvent(provider, selection));
+               registerSelectionListener(provider, this);
+               
+               installQuickAccessAction();
+       }
+       
+       private void installQuickAccessAction() {
+               fHandlerService= (IHandlerService)fSite.getService(IHandlerService.class);
+               if (fHandlerService != null) {
+                       IHandler handler= new CDTQuickMenuCreator(fEditor) {
+                               @Override
+                               protected void fillMenu(IMenuManager menu) {
+                                       fillQuickMenu(menu);
+                               }
+                       }.createHandler();
+                       fQuickAccessHandlerActivation= fHandlerService.activateHandler(QUICK_MENU_ID, handler);
+               }
+       }
+
+       private void registerSelectionListener(ISelectionProvider provider, ISelectionChangedListener listener) {
+               if (fRegisteredSelectionListeners == null)
+                       fRegisteredSelectionListeners= new ArrayList<ISelectionChangedListener>(10);
+               provider.addSelectionChangedListener(listener);
+               fRegisteredSelectionListeners.add(listener);
+       }
+       
+       /*
+        * The state of the editor owning this action group has changed. 
+        * This method does nothing if the group's owner isn't an
+        * editor.
+        */
+       /**
+        * Note: This method is for internal use only. Clients should not call this method.
+        */
+       public void editorStateChanged() {
+               Assert.isTrue(isEditorOwner());
+       }
+
+       /* 
+        * Method declared in ActionGroup
+        */
+       @Override
+       public void fillActionBars(IActionBars actionBar) {
+               super.fillActionBars(actionBar);
+               setGlobalActionHandlers(actionBar);
+       }
+       
+       /* 
+        * Method declared in ActionGroup
+        */
+       @Override
+       public void fillContextMenu(IMenuManager menu) {
+               super.fillContextMenu(menu);
+               MenuManager subMenu= new MenuManager(ActionMessages.SourceMenu_label, MENU_ID);
+               subMenu.setActionDefinitionId(QUICK_MENU_ID);
+               int added= 0;
+               if (isEditorOwner()) {
+                       added= fillEditorSubMenu(subMenu);
+               } else {
+                       added= fillViewSubMenu(subMenu);
+               }
+               if (added > 0)
+                       menu.appendToGroup(fGroupName, subMenu);
+       }
+
+       private void fillQuickMenu(IMenuManager menu) {
+               if (isEditorOwner()) {
+                       fillEditorSubMenu(menu);
+               } else {
+                       fillViewSubMenu(menu);
+               }
+       }
+       
+       private int fillEditorSubMenu(IMenuManager source) {
+               int added= 0;
+               source.add(new Separator(GROUP_COMMENT));
+               added+= addEditorAction(source, "ToggleComment"); //$NON-NLS-1$
+               added+= addEditorAction(source, "AddBlockComment"); //$NON-NLS-1$
+               added+= addEditorAction(source, "RemoveBlockComment"); //$NON-NLS-1$
+//             added+= addAction(source, fAddCppDocStub);
+               source.add(new Separator(GROUP_EDIT));
+               added+= addEditorAction(source, ITextEditorActionConstants.SHIFT_RIGHT);
+               added+= addEditorAction(source, ITextEditorActionConstants.SHIFT_LEFT);
+               added+= addEditorAction(source, "Indent"); //$NON-NLS-1$
+               added+= addEditorAction(source, "Format"); //$NON-NLS-1$
+               source.add(new Separator(GROUP_ORGANIZE));
+               added+= addAction(source, fAddInclude);
+//             added+= addAction(source, fOrganizeIncludes);
+//             added+= addAction(source, fSortMembers);
+               added+= addAction(source, fSortLines);
+//             added+= addAction(source, fCleanUp);
+               source.add(new Separator(GROUP_GENERATE));
+//             added+= addAction(source, fOverrideMethods);
+               added+= addAction(source, fAddGetterSetter);
+               added+= addAction(source, fImplementMethod);
+//             added+= addAction(source, fAddDelegateMethods);
+//             added+= addAction(source, fHashCodeEquals);
+//             added+= addAction(source, fGenerateConstructorUsingFields);
+//             added+= addAction(source, fAddUnimplementedConstructors);
+               source.add(new Separator(GROUP_CODE));
+               source.add(new Separator(GROUP_EXTERNALIZE));
+//             added+= addAction(source, fExternalizeStrings);
+               return added;
+       }
+
+       private int fillViewSubMenu(IMenuManager source) {
+               int added= 0;
+               source.add(new Separator(GROUP_COMMENT));
+//             added+= addAction(source, fAddCppDocStub);
+               source.add(new Separator(GROUP_EDIT));
+               added+= addAction(source, fFormatAll);
+               source.add(new Separator(GROUP_ORGANIZE));
+               added+= addAction(source, fAddInclude);
+//             added+= addAction(source, fOrganizeIncludes);
+//             added+= addAction(source, fSortMembers);
+//             added+= addAction(source, fCleanUp);
+               source.add(new Separator(GROUP_GENERATE));
+//             added+= addAction(source, fOverrideMethods);
+               added+= addAction(source, fAddGetterSetter);
+               added+= addAction(source, fImplementMethod);
+//             added+= addAction(source, fAddDelegateMethods);
+//             added+= addAction(source, fHashCodeEquals);
+//             added+= addAction(source, fGenerateConstructorUsingFields);
+//             added+= addAction(source, fAddUnimplementedConstructors);
+               source.add(new Separator(GROUP_CODE));
+               source.add(new Separator(GROUP_EXTERNALIZE));
+//             added+= addAction(source, fExternalizeStrings);
+//             added+= addAction(source, fFindNLSProblems);
+               return added;
+       }
+
+       /* 
+        * Method declared in ActionGroup
+        */
+       @Override
+       public void dispose() {
+               if (fRegisteredSelectionListeners != null) {
+                       ISelectionProvider provider= fSite.getSelectionProvider();
+                       for (Iterator<ISelectionChangedListener> iter= fRegisteredSelectionListeners.iterator(); iter.hasNext();) {
+                               ISelectionChangedListener listener= iter.next();
+                               provider.removeSelectionChangedListener(listener);
+                       }
+               }
+               if (fQuickAccessHandlerActivation != null && fHandlerService != null) {
+                       fHandlerService.deactivateHandler(fQuickAccessHandlerActivation);
+               }
+               fEditor= null;
+               super.dispose();
+       }
+       
+       private void setGlobalActionHandlers(IActionBars actionBar) {
+               actionBar.setGlobalActionHandler(CdtActionConstants.ADD_INCLUDE, fAddInclude);
+//             actionBar.setGlobalActionHandler(CdtActionConstants.OVERRIDE_METHODS, fOverrideMethods);
+               actionBar.setGlobalActionHandler(CdtActionConstants.GETTERS_AND_SETTERS, fAddGetterSetter);
+               actionBar.setGlobalActionHandler(CdtActionConstants.IMPLEMENT_METHOD, fImplementMethod);
+//             actionBar.setGlobalActionHandler(CdtActionConstants.GENERATE_DELEGATE_METHODS, fAddDelegateMethods);
+//             actionBar.setGlobalActionHandler(CdtActionConstants.ADD_CONSTRUCTOR_FROM_SUPERCLASS, fAddUnimplementedConstructors);            
+//             actionBar.setGlobalActionHandler(CdtActionConstants.GENERATE_CONSTRUCTOR_USING_FIELDS, fGenerateConstructorUsingFields);
+//             actionBar.setGlobalActionHandler(CdtActionConstants.GENERATE_HASHCODE_EQUALS, fHashCodeEquals);
+//             actionBar.setGlobalActionHandler(CdtActionConstants.ADD_CPP_DOC_COMMENT, fAddCppDocStub);
+//             actionBar.setGlobalActionHandler(CdtActionConstants.EXTERNALIZE_STRINGS, fExternalizeStrings);
+//             actionBar.setGlobalActionHandler(CdtActionConstants.CLEAN_UP, fCleanUp);
+//             actionBar.setGlobalActionHandler(CdtActionConstants.ORGANIZE_INCLUDES, fOrganizeIncludes);
+//             actionBar.setGlobalActionHandler(CdtActionConstants.SORT_MEMBERS, fSortMembers);
+               if (!isEditorOwner()) {
+                       // editor provides its own implementation of these actions.
+                       actionBar.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), fAddBookmark);
+                       actionBar.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), fAddTaskAction);
+                       actionBar.setGlobalActionHandler(CdtActionConstants.FORMAT, fFormatAll);
+               } else {
+//                     actionBar.setGlobalActionHandler(CopyQualifiedNameAction.ACTION_HANDLER_ID, fCopyQualifiedNameAction);
+               }
+       }
+       
+       private int addAction(IMenuManager menu, IAction action) {
+               if (action instanceof IUpdate)
+                       ((IUpdate)action).update();
+               if (action != null && action.isEnabled()) {
+                       menu.add(action);
+                       return 1;
+               }
+               return 0;
+       }       
+       
+       private int addEditorAction(IMenuManager menu, String actionID) {
+               if (fEditor == null)
+                       return 0;
+               IAction action= fEditor.getAction(actionID);
+               if (action == null)
+                       return 0;
+               if (action instanceof IUpdate)
+                       ((IUpdate)action).update();
+               if (action.isEnabled()) {
+                       menu.add(action);
+                       return 1;
+               }
+               return 0;
+       }
+       
+       private boolean isEditorOwner() {
+               return fEditor != null;
+       }
+       
+       private ICElement getCElement(ISelection selection) {
+               if (selection instanceof IStructuredSelection) {
+                       IStructuredSelection ss = (IStructuredSelection) selection;
+                       if (ss.size() == 1) {
+                               Object o = ss.getFirstElement();
+                               if (o instanceof ICElement && o instanceof ISourceReference) {
+                                       return (ICElement) o;
+                               }
+                       }
+               }
+               return null;
+       }
+
+       /**
+        * {@inheritDoc}
+        * @since 5.2
+        * @noreference This method is not intended to be referenced by clients.
+        */
+       public void selectionChanged(SelectionChangedEvent event) {
+               ICElement celem = getCElement(event.getSelection());
+               for (RefactoringAction action : fRefactorActions) {
+                       action.updateSelection(celem);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ManageConfigsAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ManageConfigsAction.java
new file mode 100644 (file)
index 0000000..09c7ca0
--- /dev/null
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.actions;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
+
+import org.eclipse.cdt.ui.newui.IConfigManager;
+import org.eclipse.cdt.ui.newui.ManageConfigSelector;
+
+/**
+ * Action which lets to manage (add/remove etc.) build configurations of the project.
+ */
+public class ManageConfigsAction 
+implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate {
+       IProject[] obs = null; 
+       
+       public void selectionChanged(IAction action, ISelection selection) {
+               if (!selection.isEmpty()) {
+                       // case for context menu
+                       if (selection instanceof StructuredSelection) {
+                               obs = ManageConfigSelector.getProjects(((StructuredSelection)selection).toArray());
+                               action.setEnabled(ManageConfigSelector.getManager(obs) != null);
+                               return;
+                       }
+               }
+               action.setEnabled(false);
+       }
+       
+       public void run(IAction action) {
+               IConfigManager cm = ManageConfigSelector.getManager(obs);
+               if (cm != null && obs != null)
+                       cm.manage(obs, true);
+       }
+       
+       public void dispose() { obs = null; }
+       
+       // doing nothing
+       public void init(IWorkbenchWindow window) { }
+       public Menu getMenu(Menu parent) { return null; }
+       public Menu getMenu(Control parent) { return null; }
+       public void setActivePart(IAction action, IWorkbenchPart targetPart) {}
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/MemberFilterActionGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/MemberFilterActionGroup.java
new file mode 100644 (file)
index 0000000..69312e5
--- /dev/null
@@ -0,0 +1,412 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Rational Software - initial implementation
+ *     Markus Schorn (Wind River Systems)
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.actions;
+
+/**
+ * Action Group that contributes filter buttons for a view parts showing 
+ * methods and fields. Contributed filters are: hide fields, hide static
+ * members and hide non-public members.
+ * <p>
+ * The action group installs a filter on a structured viewer. The filter is connected 
+ * to the actions installed in the view part's toolbar menu and is updated when the 
+ * state of the buttons changes.
+ * <p>
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.actions.ActionGroup;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.actions.ActionMessages;
+import org.eclipse.cdt.internal.ui.viewsupport.MemberFilter;
+import org.eclipse.cdt.internal.ui.viewsupport.MemberFilterAction;
+
+public class MemberFilterActionGroup extends ActionGroup {
+       public static final int FILTER_NONPUBLIC= MemberFilter.FILTER_NONPUBLIC;
+       public static final int FILTER_STATIC= MemberFilter.FILTER_STATIC;
+       public static final int FILTER_FIELDS= MemberFilter.FILTER_FIELDS;
+       /**
+        * @since 5.1
+        */
+       public static final int FILTER_INACTIVE= MemberFilter.FILTER_INACTIVE;
+       
+       /** @deprecated Unsupported filter constant */
+       @Deprecated
+       public static final int FILTER_LOCALTYPES= MemberFilter.FILTER_LOCALTYPES;
+       
+       /**
+        * @deprecated we may choose to add more filters in future versions.
+        */
+       @Deprecated
+       public static final int ALL_FILTERS= FILTER_NONPUBLIC | FILTER_FIELDS | FILTER_STATIC;
+       
+       private static final String TAG_HIDEFIELDS= "hidefields"; //$NON-NLS-1$
+       private static final String TAG_HIDESTATIC= "hidestatic"; //$NON-NLS-1$
+       private static final String TAG_HIDENONPUBLIC= "hidenonpublic"; //$NON-NLS-1$
+       private static final String TAG_HIDEINACTIVE= "hideinactive"; //$NON-NLS-1$
+       
+       private MemberFilterAction[] fFilterActions;
+       private MemberFilter fFilter;
+       
+       StructuredViewer fViewer;
+       private String fViewerId;
+       private boolean fInViewMenu;
+       
+       
+       /**
+        * Creates a new <code>MemberFilterActionGroup</code>.
+        * 
+        * @param viewer the viewer to be filtered
+        * @param viewerId a unique id of the viewer. Used as a key to to store 
+        * the last used filter settings in the preference store
+        */
+       public MemberFilterActionGroup(StructuredViewer viewer, String viewerId) {
+               this(viewer, viewerId, false);
+       }
+       
+       /**
+        * Creates a new <code>MemberFilterActionGroup</code>.
+        * 
+        * @param viewer the viewer to be filtered
+        * @param viewerId a unique id of the viewer. Used as a key to to store 
+        * the last used filter settings in the preference store
+        * @param inViewMenu if <code>true</code> the actions are added to the view
+        * menu. If <code>false</code> they are added to the toobar.
+        * 
+        * @since 2.1
+        */
+       public MemberFilterActionGroup(StructuredViewer viewer, String viewerId, boolean inViewMenu) {
+               fViewer= viewer;
+               fViewerId= viewerId;
+               fInViewMenu= inViewMenu;
+               
+               // get initial values
+               IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+               boolean doHideFields= store.getBoolean(getPreferenceKey(FILTER_FIELDS));
+               boolean doHideStatic= store.getBoolean(getPreferenceKey(FILTER_STATIC));
+               boolean doHidePublic= store.getBoolean(getPreferenceKey(FILTER_NONPUBLIC));
+               boolean doHideInactive= store.getBoolean(getPreferenceKey(FILTER_INACTIVE));
+
+               fFilter= new MemberFilter();
+               if (doHideFields)
+                       fFilter.addFilter(FILTER_FIELDS);
+               if (doHideStatic)
+                       fFilter.addFilter(FILTER_STATIC);                       
+               if (doHidePublic)
+                       fFilter.addFilter(FILTER_NONPUBLIC);    
+               if (doHideInactive)
+                       fFilter.addFilter(FILTER_INACTIVE);
+       
+               // fields
+               String title= ActionMessages.MemberFilterActionGroup_hide_fields_label;
+               String helpContext= ICHelpContextIds.FILTER_FIELDS_ACTION;
+               MemberFilterAction hideFields= new MemberFilterAction(this, title, FILTER_FIELDS, helpContext, doHideFields);
+               hideFields.setDescription(ActionMessages.MemberFilterActionGroup_hide_fields_description);
+               hideFields.setToolTipText(ActionMessages.MemberFilterActionGroup_hide_fields_tooltip);
+               CPluginImages.setImageDescriptors(hideFields, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_FIELDS); 
+               
+               // static
+               title= ActionMessages.MemberFilterActionGroup_hide_static_label;
+               helpContext= ICHelpContextIds.FILTER_STATIC_ACTION;
+               MemberFilterAction hideStatic= new MemberFilterAction(this, title, FILTER_STATIC, helpContext, doHideStatic);
+               hideStatic.setDescription(ActionMessages.MemberFilterActionGroup_hide_static_description);
+               hideStatic.setToolTipText(ActionMessages.MemberFilterActionGroup_hide_static_tooltip);
+               CPluginImages.setImageDescriptors(hideStatic, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_STATIC); 
+               
+               // non-public
+               title= ActionMessages.MemberFilterActionGroup_hide_nonpublic_label;
+               helpContext= ICHelpContextIds.FILTER_PUBLIC_ACTION;
+               MemberFilterAction hideNonPublic= new MemberFilterAction(this, title, FILTER_NONPUBLIC, helpContext, doHidePublic);
+               hideNonPublic.setDescription(ActionMessages.MemberFilterActionGroup_hide_nonpublic_description);
+               hideNonPublic.setToolTipText(ActionMessages.MemberFilterActionGroup_hide_nonpublic_tooltip);
+               CPluginImages.setImageDescriptors(hideNonPublic, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_PUBLIC); 
+
+               // inactive
+               title= ActionMessages.MemberFilterActionGroup_hide_inactive_label;
+               MemberFilterAction hideInactive= new MemberFilterAction(this, title, FILTER_INACTIVE, null, doHideInactive);
+               hideInactive.setDescription(ActionMessages.MemberFilterActionGroup_hide_inactive_description);
+               hideInactive.setToolTipText(ActionMessages.MemberFilterActionGroup_hide_inactive_tooltip);
+               CPluginImages.setImageDescriptors(hideInactive, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_INACTIVE); 
+
+               // order corresponds to order in toolbar
+               fFilterActions= new MemberFilterAction[] { hideFields, hideStatic, hideNonPublic, hideInactive };
+               
+               fViewer.addFilter(fFilter);
+       }
+       
+       /**
+        * Creates a new <code>MemberFilterActionGroup</code>.
+        * 
+        * @param viewer the viewer to be filtered
+        * @param viewerId a unique id of the viewer. Used as a key to to store 
+        * the last used filter settings in the preference store
+        * @param inViewMenu if <code>true</code> the actions are added to the view
+        * menu. If <code>false</code> they are added to the toobar.
+        * @param availableFilters Specifies which filter action should be contained. {@link #FILTER_NONPUBLIC},
+        * {@link #FILTER_STATIC}, {@link #FILTER_FIELDS}, {@link #FILTER_INACTIVE}
+        * or a combination of these constants are possible values. 
+        */
+       public MemberFilterActionGroup(StructuredViewer viewer, String viewerId, boolean inViewMenu, int availableFilters) {    
+                               
+               fViewer= viewer;
+               fViewerId= viewerId;
+               fInViewMenu= inViewMenu;
+               
+               IPreferenceStore store= PreferenceConstants.getPreferenceStore();
+               fFilter= new MemberFilter();
+               
+               String title, helpContext;
+               ArrayList<MemberFilterAction> actions= new ArrayList<MemberFilterAction>(4);
+               
+               // fields
+               int filterProperty= FILTER_FIELDS;
+               if (isSet(filterProperty, availableFilters)) {
+                       boolean filterEnabled= store.getBoolean(getPreferenceKey(filterProperty));
+                       if (filterEnabled) {
+                               fFilter.addFilter(filterProperty);
+                       }
+                       title= ActionMessages.MemberFilterActionGroup_hide_fields_label;
+                       helpContext= ICHelpContextIds.FILTER_FIELDS_ACTION;
+                       MemberFilterAction hideFields= new MemberFilterAction(this, title, filterProperty, helpContext, filterEnabled);
+                       hideFields.setDescription(ActionMessages.MemberFilterActionGroup_hide_fields_description);
+                       hideFields.setToolTipText(ActionMessages.MemberFilterActionGroup_hide_fields_tooltip);
+                       CPluginImages.setImageDescriptors(hideFields, CPluginImages.T_LCL, "fields_co.gif"); //$NON-NLS-1$
+                       actions.add(hideFields);
+               }
+                       
+               // static
+               filterProperty= FILTER_STATIC;
+               if (isSet(filterProperty, availableFilters)) {
+                       boolean filterEnabled= store.getBoolean(getPreferenceKey(filterProperty));
+                       if (filterEnabled) {
+                               fFilter.addFilter(filterProperty);
+                       }
+                       title= ActionMessages.MemberFilterActionGroup_hide_static_label;
+                       helpContext= ICHelpContextIds.FILTER_STATIC_ACTION;
+                       MemberFilterAction hideStatic= new MemberFilterAction(this, title, FILTER_STATIC, helpContext, filterEnabled);
+                       hideStatic.setDescription(ActionMessages.MemberFilterActionGroup_hide_static_description);
+                       hideStatic.setToolTipText(ActionMessages.MemberFilterActionGroup_hide_static_tooltip);
+                       CPluginImages.setImageDescriptors(hideStatic, CPluginImages.T_LCL, "static_co.gif"); //$NON-NLS-1$
+                       actions.add(hideStatic);
+               }
+               
+               // non-public
+               filterProperty= FILTER_NONPUBLIC;
+               if (isSet(filterProperty, availableFilters)) {
+                       boolean filterEnabled= store.getBoolean(getPreferenceKey(filterProperty));
+                       if (filterEnabled) {
+                               fFilter.addFilter(filterProperty);
+                       }
+                       title= ActionMessages.MemberFilterActionGroup_hide_nonpublic_label;
+                       helpContext= ICHelpContextIds.FILTER_PUBLIC_ACTION;
+                       MemberFilterAction hideNonPublic= new MemberFilterAction(this, title, filterProperty, helpContext, filterEnabled);
+                       hideNonPublic.setDescription(ActionMessages.MemberFilterActionGroup_hide_nonpublic_description);
+                       hideNonPublic.setToolTipText(ActionMessages.MemberFilterActionGroup_hide_nonpublic_tooltip);
+                       CPluginImages.setImageDescriptors(hideNonPublic, CPluginImages.T_LCL, "public_co.gif"); //$NON-NLS-1$
+                       actions.add(hideNonPublic);
+               }
+
+               // non-public
+               filterProperty= FILTER_INACTIVE;
+               if (isSet(filterProperty, availableFilters)) {
+                       boolean filterEnabled= store.getBoolean(getPreferenceKey(filterProperty));
+                       if (filterEnabled) {
+                               fFilter.addFilter(filterProperty);
+                       }
+                       title= ActionMessages.MemberFilterActionGroup_hide_inactive_label;
+                       MemberFilterAction hideInactive= new MemberFilterAction(this, title, filterProperty, null, filterEnabled);
+                       hideInactive.setDescription(ActionMessages.MemberFilterActionGroup_hide_inactive_description);
+                       hideInactive.setToolTipText(ActionMessages.MemberFilterActionGroup_hide_inactive_tooltip);
+                       CPluginImages.setImageDescriptors(hideInactive, CPluginImages.T_LCL, "filterInactive.gif"); //$NON-NLS-1$
+                       actions.add(hideInactive);
+               }
+
+               // order corresponds to order in toolbar
+               fFilterActions= actions.toArray(new MemberFilterAction[actions.size()]);
+               
+               fViewer.addFilter(fFilter);
+       }
+
+       private boolean isSet(int flag, int set) {
+               return (flag & set) != 0;
+       }
+
+       private String getPreferenceKey(int filterProperty) {
+               return "MemberFilterActionGroup." + fViewerId + '.' + String.valueOf(filterProperty); //$NON-NLS-1$
+       }
+       
+       /**
+        * Sets the member filters.
+        * 
+        * @param filterProperty the filter to be manipulated. Valid values are <code>FILTER_FIELDS</code>, 
+        * <code>FILTER_PUBLIC</code>, <code>FILTER_PRIVATE</code> and <code>FILTER_INACTIVE</code> as defined by this action 
+        * group
+        * @param set if <code>true</code> the given filter is installed. If <code>false</code> the
+        * given filter is removed
+        * .
+        */     
+       public void setMemberFilter(int filterProperty, boolean set) {
+               setMemberFilters(new int[] {filterProperty}, new boolean[] {set}, true);
+       }
+
+       private void setMemberFilters(int[] propertyKeys, boolean[] propertyValues, boolean refresh) {
+               if (propertyKeys.length == 0)
+                       return;
+               Assert.isTrue(propertyKeys.length == propertyValues.length);
+               
+               for (int i= 0; i < propertyKeys.length; i++) {
+                       int filterProperty= propertyKeys[i];
+                       boolean set= propertyValues[i];
+                       if (set) {
+                               fFilter.addFilter(filterProperty);
+                       } else {
+                               fFilter.removeFilter(filterProperty);
+                       }
+                       IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+                       
+                       for (int j= 0; j < fFilterActions.length; j++) {
+                               int currProperty= fFilterActions[j].getFilterProperty();
+                               if (currProperty == filterProperty) {
+                                       fFilterActions[j].setChecked(set);
+                               }
+                               store.setValue(getPreferenceKey(currProperty), hasMemberFilter(currProperty));
+                       }
+               }
+               if (refresh) {
+                       fViewer.getControl().setRedraw(false);
+                       BusyIndicator.showWhile(fViewer.getControl().getDisplay(), new Runnable() {
+                               public void run() {
+                                       fViewer.refresh();
+                               }
+                       });
+                       fViewer.getControl().setRedraw(true);
+               }
+       }
+
+       /**
+        * Returns <code>true</code> if the given filter is installed.
+        * 
+        * @param filterProperty the filter to be tested. Valid values are <code>FILTER_FIELDS</code>, 
+        * <code>FILTER_PUBLIC</code>, <code>FILTER_PRIVATE</code> and <code>FILTER_INACTIVE</code> 
+        * as defined by this action group
+        */     
+       public boolean hasMemberFilter(int filterProperty) {
+               return fFilter.hasFilter(filterProperty);
+       }
+       
+       /**
+        * Saves the state of the filter actions in a memento.
+        * 
+        * @param memento the memento to which the state is saved
+        */
+       public void saveState(IMemento memento) {
+               memento.putString(TAG_HIDEFIELDS, String.valueOf(hasMemberFilter(FILTER_FIELDS)));
+               memento.putString(TAG_HIDESTATIC, String.valueOf(hasMemberFilter(FILTER_STATIC)));
+               memento.putString(TAG_HIDENONPUBLIC, String.valueOf(hasMemberFilter(FILTER_NONPUBLIC)));
+               memento.putString(TAG_HIDEINACTIVE, String.valueOf(hasMemberFilter(FILTER_INACTIVE)));
+       }
+       
+       /**
+        * Restores the state of the filter actions from a memento.
+        * <p>
+        * Note: This method does not refresh the viewer.
+        * </p>
+        * @param memento the memento from which the state is restored
+        */     
+       public void restoreState(IMemento memento) {
+               setMemberFilters(
+                       new int[] {FILTER_FIELDS, FILTER_STATIC, FILTER_NONPUBLIC, FILTER_INACTIVE},
+                       new boolean[] {
+                               Boolean.valueOf(memento.getString(TAG_HIDEFIELDS)).booleanValue(),
+                               Boolean.valueOf(memento.getString(TAG_HIDESTATIC)).booleanValue(),
+                               Boolean.valueOf(memento.getString(TAG_HIDENONPUBLIC)).booleanValue(),
+                               Boolean.valueOf(memento.getString(TAG_HIDEINACTIVE)).booleanValue()
+                       }, false);
+       }
+       
+       /* (non-Javadoc)
+        * @see ActionGroup#fillActionBars(IActionBars)
+        */
+       @Override
+       public void fillActionBars(IActionBars actionBars) {
+               contributeToToolBar(actionBars.getToolBarManager());
+       }
+       
+       /**
+        * Adds the filter actions to the given tool bar
+        * 
+        * @param tbm the tool bar to which the actions are added
+        */
+       public void contributeToToolBar(IToolBarManager tbm) {
+               if (fInViewMenu)
+                       return;
+               tbm.add(fFilterActions[0]); // fields
+               tbm.add(fFilterActions[1]); // static
+               tbm.add(fFilterActions[2]); // public
+               tbm.add(fFilterActions[3]); // inactive
+       }
+       
+       /**
+        * Adds the filter actions to the given menu manager.
+        * 
+        * @param menu the menu manager to which the actions are added
+        * @since 2.1
+        */
+       public void contributeToViewMenu(IMenuManager menu) {
+               if (!fInViewMenu)
+                       return;
+               final String filters= "filters"; //$NON-NLS-1$
+               if (menu.find(filters) != null) {
+                       menu.prependToGroup(filters, fFilterActions[0]); // fields
+                       menu.prependToGroup(filters, fFilterActions[1]); // static
+                       menu.prependToGroup(filters, fFilterActions[2]); // public
+                       menu.prependToGroup(filters, fFilterActions[3]); // inactive
+               } else {
+                       menu.add(fFilterActions[0]); // fields
+                       menu.add(fFilterActions[1]); // static
+                       menu.add(fFilterActions[2]); // public
+                       menu.add(fFilterActions[3]); // inactive
+               }
+       }
+       
+       /* (non-Javadoc)
+        * @see ActionGroup#dispose()
+        */
+       @Override
+       public void dispose() {
+               fFilterActions= null;
+               fFilter= null;
+               fViewer= null;
+               
+               super.dispose();
+       }
+
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/OpenAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/OpenAction.java
new file mode 100644 (file)
index 0000000..e20dc34
--- /dev/null
@@ -0,0 +1,207 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.actions;
+
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.util.OpenStrategy;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.texteditor.IEditorStatusLine;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.ICStatusConstants;
+import org.eclipse.cdt.internal.ui.actions.ActionMessages;
+import org.eclipse.cdt.internal.ui.actions.ActionUtil;
+import org.eclipse.cdt.internal.ui.actions.OpenActionUtil;
+import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
+
+/**
+ * This action opens a Java editor on a Java element or file.
+ * <p>
+ * The action is applicable to selections containing elements of
+ * type <code>ICompilationUnit</code>, <code>IMember</code>
+ * or <code>IFile</code>.
+ * 
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p> 
+ * 
+ * @since 2.0
+ */
+public class OpenAction extends SelectionDispatchAction {
+       private CEditor fEditor;
+       
+       /**
+        * Creates a new <code>OpenAction</code>. The action requires
+        * that the selection provided by the site's selection provider is of type <code>
+        * org.eclipse.jface.viewers.IStructuredSelection</code>.
+        * 
+        * @param site the site providing context information for this action
+        */
+       public OpenAction(IWorkbenchSite site) {
+               super(site);
+               setText(ActionMessages.OpenAction_label);
+               setToolTipText(ActionMessages.OpenAction_tooltip);
+               setDescription(ActionMessages.OpenAction_description);          
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.OPEN_ACTION);
+       }
+       
+       /**
+        * Note: This constructor is for internal use only. Clients should not call this constructor.
+        * 
+        * @noreference This constructor is not intended to be referenced by clients.
+        */
+       public OpenAction(CEditor editor) {
+               this(editor.getEditorSite());
+               fEditor= editor;
+               setText(ActionMessages.OpenAction_declaration_label);
+               setEnabled(SelectionConverter.canOperateOn(fEditor));
+       }
+       
+       /* (non-Javadoc)
+        * Method declared on SelectionDispatchAction.
+        */
+       @Override
+       public void selectionChanged(ITextSelection selection) {
+       }
+
+       /* (non-Javadoc)
+        * Method declared on SelectionDispatchAction.
+        */
+       @Override
+       public void selectionChanged(IStructuredSelection selection) {
+               setEnabled(checkEnabled(selection));
+       }
+       
+       private boolean checkEnabled(IStructuredSelection selection) {
+               if (selection.isEmpty())
+                       return false;
+               for (Iterator<?> iter= selection.iterator(); iter.hasNext();) {
+                       Object element= iter.next();
+                       if (element instanceof ISourceReference)
+                               continue;
+                       if (element instanceof IFile)
+                               continue;
+                       if (element instanceof IStorage)
+                               continue;
+                       return false;
+               }
+               return true;
+       }
+       
+       /* (non-Javadoc)
+        * Method declared on SelectionDispatchAction.
+        */
+       @Override
+       public void run(ITextSelection selection) {
+               if (!ActionUtil.isProcessable(fEditor))
+                       return;
+               try {
+                       ICElement element= SelectionConverter.codeResolve(fEditor, getShell(), getDialogTitle(), 
+                               ActionMessages.OpenAction_select_element);
+                       if (element == null) {
+                               IEditorStatusLine statusLine= (IEditorStatusLine) fEditor.getAdapter(IEditorStatusLine.class);
+                               if (statusLine != null)
+                                       statusLine.setMessage(true, ActionMessages.OpenAction_error_messageBadSelection, null);
+                               getShell().getDisplay().beep();
+                               return;
+                       }
+                       ICElement input= SelectionConverter.getInput(fEditor);
+                       int type= element.getElementType();
+                       if (type == ICElement.C_PROJECT || type == ICElement.C_CCONTAINER)
+                               element= input;
+                       run(new Object[] {element} );
+               } catch (CModelException e) {
+                       showError(e);
+               }
+       }
+       
+       /* (non-Javadoc)
+        * Method declared on SelectionDispatchAction.
+        */
+       @Override
+       public void run(IStructuredSelection selection) {
+               if (!checkEnabled(selection))
+                       return;
+               run(selection.toArray());
+       }
+       
+       /**
+        * Note: this method is for internal use only. Clients should not call this method.
+        */
+       public void run(Object[] elements) {
+               if (elements == null)
+                       return;
+               for (Object element : elements) {
+                       try {
+                               element= getElementToOpen(element);
+                               boolean activateOnOpen= fEditor != null ? true : OpenStrategy.activateOnOpen();
+                               OpenActionUtil.open(element, activateOnOpen);
+                       } catch (CModelException e) {
+                               CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(),
+                                               ICStatusConstants.INTERNAL_ERROR, ActionMessages.OpenAction_error_message, e));
+                               ErrorDialog.openError(getShell(), getDialogTitle(),
+                                               ActionMessages.OpenAction_error_messageProblems, e.getStatus());
+                       } catch (PartInitException x) {
+                               String name= null;
+                               
+                               if (element instanceof ICElement) {
+                                       name= ((ICElement) element).getElementName();
+                               } else if (element instanceof IStorage) {
+                                       name= ((IStorage) element).getName();
+                               } else if (element instanceof IResource) {
+                                       name= ((IResource) element).getName();
+                               }
+                               
+                               if (name != null) {
+                                       MessageDialog.openError(getShell(),
+                                               ActionMessages.OpenAction_error_messageProblems,
+                                               NLS.bind(ActionMessages.OpenAction_error_messageArgs, name, x.getMessage()));                   
+                               }
+                       }               
+               }
+       }
+       
+       /**
+        * Note: this method is for internal use only. Clients should not call this method.
+        */
+       public Object getElementToOpen(Object object) throws CModelException {
+               return object;
+       }       
+       
+       private String getDialogTitle() {
+               return ActionMessages.OpenAction_error_title;
+       }
+       
+       private void showError(CoreException e) {
+               ExceptionHandler.handle(e, getShell(), getDialogTitle(), ActionMessages.OpenAction_error_message);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/OpenViewActionGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/OpenViewActionGroup.java
new file mode 100644 (file)
index 0000000..f54bd10
--- /dev/null
@@ -0,0 +1,316 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.actions;
+
+import java.util.List;
+
+import org.eclipse.jface.action.IMenuManager;
+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.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.dialogs.PropertyDialogAction;
+import org.eclipse.ui.part.Page;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IInclude;
+
+import org.eclipse.cdt.internal.ui.IContextMenuConstants;
+import org.eclipse.cdt.internal.ui.callhierarchy.OpenCallHierarchyAction;
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
+import org.eclipse.cdt.internal.ui.includebrowser.OpenIncludeBrowserAction;
+import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction;
+import org.eclipse.cdt.internal.ui.typehierarchy.OpenTypeHierarchyAction;
+
+/**
+ * Action group that adds actions to open a new CDT view part or an external 
+ * viewer to a context menu and the global menu bar.
+ * 
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ * 
+ * @since 2.0
+ */
+public class OpenViewActionGroup extends ActionGroup {
+
+    private boolean fEditorIsOwner;
+       private boolean fSuppressTypeHierarchy;
+       private boolean fSuppressCallHierarchy;
+       private boolean fSuppressProperties;
+       private boolean fEnableIncludeBrowser;
+       
+       private IWorkbenchSite fSite;
+       private String fGroupName= IContextMenuConstants.GROUP_OPEN;
+       
+//     private OpenSuperImplementationAction fOpenSuperImplementation;
+//     private OpenExternalJavadocAction fOpenExternalJavadoc;
+       private OpenTypeHierarchyAction fOpenTypeHierarchy;
+       private PropertyDialogAction fOpenPropertiesDialog;
+       private OpenCallHierarchyAction fOpenCallHierarchy;
+       private OpenIncludeBrowserAction fOpenIncludeBrowser;
+       private OpenDeclarationsAction fOpenDeclaration;
+
+       /**
+        * Creates a new <code>OpenActionGroup</code>. The group requires
+        * that the selection provided by the page's selection provider is of type <code>
+        * org.eclipse.jface.viewers.IStructuredSelection</code>.
+        * 
+        * @param page the page that owns this action group
+        */
+       public OpenViewActionGroup(Page page) {
+               createSiteActions(page.getSite(), null);
+       }
+
+       /**
+        * Creates a new <code>OpenActionGroup</code>. The group requires
+        * that the selection provided by the page's selection provider is of type <code>
+        * org.eclipse.jface.viewers.IStructuredSelection</code>.
+        * 
+        * @param page the page that owns this action group
+        * 
+        * @noreference This constructor is not intended to be referenced by clients.
+        */
+       public OpenViewActionGroup(Page page, CEditor editor) {
+               createSiteActions(page.getSite(), editor);
+       }
+
+       /**
+        * Creates a new <code>OpenActionGroup</code>. The group requires
+        * that the selection provided by the part's selection provider is of type <code>
+        * org.eclipse.jface.viewers.IStructuredSelection</code>.
+        * 
+        * @param part the view part that owns this action group
+        */
+       public OpenViewActionGroup(IWorkbenchPart part) {
+               createSiteActions(part.getSite(), null);
+       }
+       
+       /**
+        * Note: This constructor is for internal use only. Clients should not call this constructor.
+        */
+       public OpenViewActionGroup(ITextEditor part) {
+               fEditorIsOwner= true;
+
+//             fOpenSuperImplementation= new OpenSuperImplementationAction(part);
+//             fOpenSuperImplementation.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_SUPER_IMPLEMENTATION);
+//             part.setAction("OpenSuperImplementation", fOpenSuperImplementation); //$NON-NLS-1$
+
+//             fOpenExternalJavadoc= new OpenExternalJavadocAction(part);
+//             fOpenExternalJavadoc.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_EXTERNAL_JAVADOC);
+//             part.setAction("OpenExternalJavadoc", fOpenExternalJavadoc); //$NON-NLS-1$
+
+               fOpenTypeHierarchy= new OpenTypeHierarchyAction(part);
+               fOpenTypeHierarchy.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_TYPE_HIERARCHY);
+               part.setAction("OpenTypeHierarchy", fOpenTypeHierarchy); //$NON-NLS-1$
+               
+        fOpenCallHierarchy= new OpenCallHierarchyAction(part);
+        fOpenCallHierarchy.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_CALL_HIERARCHY);
+        part.setAction("OpenCallHierarchy", fOpenCallHierarchy); //$NON-NLS-1$
+
+        fOpenIncludeBrowser= new OpenIncludeBrowserAction(part);
+        fOpenIncludeBrowser.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_INCLUDE_BROWSER);
+        part.setAction("OpenIncludeBrowser", fOpenIncludeBrowser); //$NON-NLS-1$
+        
+        if (part instanceof CEditor) {
+               fOpenDeclaration= new OpenDeclarationsAction((CEditor) part);
+               fOpenDeclaration.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_DECL);
+               part.setAction("OpenDeclarations", fOpenDeclaration); //$NON-NLS-1$
+        }
+
+               initialize(part.getEditorSite());
+       }
+
+       private void createSiteActions(IWorkbenchSite site, CEditor editor) {
+//             fOpenSuperImplementation= new OpenSuperImplementationAction(site);
+//             fOpenSuperImplementation.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_SUPER_IMPLEMENTATION);
+//
+//             fOpenExternalJavadoc= new OpenExternalJavadocAction(site);
+//             fOpenExternalJavadoc.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_EXTERNAL_JAVADOC);
+
+               fOpenTypeHierarchy= new OpenTypeHierarchyAction(site);
+               fOpenTypeHierarchy.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_TYPE_HIERARCHY);
+               
+               fOpenCallHierarchy= new OpenCallHierarchyAction(site);
+        fOpenCallHierarchy.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_CALL_HIERARCHY);
+
+               fOpenIncludeBrowser= new OpenIncludeBrowserAction(site);
+               fOpenIncludeBrowser.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_INCLUDE_BROWSER);
+
+        if (editor != null) {
+               fOpenDeclaration= new OpenDeclarationsAction(editor);
+               fOpenDeclaration.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_DECL);
+        }
+
+        fOpenPropertiesDialog= new PropertyDialogAction(site, site.getSelectionProvider());
+        fOpenPropertiesDialog.setActionDefinitionId("org.eclipse.ui.file.properties"); //$NON-NLS-1$
+               
+        initialize(site);
+       }
+       
+       private void initialize(IWorkbenchSite site) {
+               fSite= site;
+               ISelectionProvider provider= fSite.getSelectionProvider();
+               ISelection selection= provider.getSelection();
+//             fOpenSuperImplementation.update(selection);
+//             fOpenExternalJavadoc.update(selection);
+               fOpenTypeHierarchy.update(selection);
+               fOpenCallHierarchy.update(selection);
+               fOpenIncludeBrowser.update(selection);
+               if (!fEditorIsOwner) {
+                       if (selection instanceof IStructuredSelection) {
+                               IStructuredSelection ss= (IStructuredSelection)selection;
+                               fOpenPropertiesDialog.selectionChanged(ss);
+                       } else {
+                               fOpenPropertiesDialog.selectionChanged(selection);
+                       }
+//                     provider.addSelectionChangedListener(fOpenSuperImplementation);
+//                     provider.addSelectionChangedListener(fOpenExternalJavadoc);
+                       provider.addSelectionChangedListener(fOpenTypeHierarchy);
+                       provider.addSelectionChangedListener(fOpenCallHierarchy);
+                       provider.addSelectionChangedListener(fOpenIncludeBrowser);
+                       // no need to register the open properties dialog action since it registers itself
+               }
+       }
+
+       /* (non-Javadoc)
+        * Method declared in ActionGroup
+        */
+       @Override
+       public void fillActionBars(IActionBars actionBar) {
+               super.fillActionBars(actionBar);
+               setGlobalActionHandlers(actionBar);
+       }
+       
+       /* (non-Javadoc)
+        * Method declared in ActionGroup
+        */
+       @Override
+       public void fillContextMenu(IMenuManager menu) {
+               super.fillContextMenu(menu);
+               IStructuredSelection selection= getStructuredSelection();
+               if (!fEditorIsOwner) {
+                       if (fOpenDeclaration != null && fOpenDeclaration.isEnabled()) {
+                               if (selection != null) {
+                                       Object elem= selection.getFirstElement();
+                                       if (elem instanceof ICElement && elem instanceof IInclude == false) {
+                                               menu.appendToGroup(fGroupName, fOpenDeclaration);
+                                       }
+                               }
+                       }
+                       if (!fSuppressTypeHierarchy && fOpenTypeHierarchy.isEnabled()) {
+                               menu.appendToGroup(fGroupName, fOpenTypeHierarchy);
+                       }
+                       if (!fSuppressCallHierarchy && fOpenCallHierarchy.isEnabled()) {
+                               menu.appendToGroup(fGroupName, fOpenCallHierarchy);
+                       }
+                       if (fEnableIncludeBrowser && fOpenIncludeBrowser.isEnabled()) {
+                               menu.appendToGroup(fGroupName, fOpenIncludeBrowser);
+                       }
+               }
+//             appendToGroup(menu, fOpenSuperImplementation);
+               if (!fSuppressProperties) {
+                       if (fOpenPropertiesDialog != null && fOpenPropertiesDialog.isEnabled() && selection != null &&fOpenPropertiesDialog.isApplicableForSelection(selection)) {
+                               menu.appendToGroup(IContextMenuConstants.GROUP_PROPERTIES, fOpenPropertiesDialog);
+                       }
+               }
+       }
+
+       /*
+        * @see ActionGroup#dispose()
+        */
+       @Override
+       public void dispose() {
+               ISelectionProvider provider= fSite.getSelectionProvider();
+//             provider.removeSelectionChangedListener(fOpenSuperImplementation);
+//             provider.removeSelectionChangedListener(fOpenExternalJavadoc);
+               provider.removeSelectionChangedListener(fOpenTypeHierarchy);
+               provider.removeSelectionChangedListener(fOpenCallHierarchy);
+               provider.removeSelectionChangedListener(fOpenIncludeBrowser);
+               if (fOpenPropertiesDialog != null) {
+                       fOpenPropertiesDialog.dispose();
+               }
+               super.dispose();
+       }
+       
+       private void setGlobalActionHandlers(IActionBars actionBars) {
+//             actionBars.setGlobalActionHandler(JdtActionConstants.OPEN_SUPER_IMPLEMENTATION, fOpenSuperImplementation);
+//             actionBars.setGlobalActionHandler(JdtActionConstants.OPEN_EXTERNAL_JAVA_DOC, fOpenExternalJavadoc);
+               actionBars.setGlobalActionHandler(CdtActionConstants.OPEN_TYPE_HIERARCHY, fOpenTypeHierarchy);
+        actionBars.setGlobalActionHandler(CdtActionConstants.OPEN_CALL_HIERARCHY, fOpenCallHierarchy);
+        actionBars.setGlobalActionHandler(CdtActionConstants.OPEN_INCLUDE_BROWSER, fOpenIncludeBrowser);
+        if (fOpenDeclaration != null) {
+               actionBars.setGlobalActionHandler(CdtActionConstants.OPEN_DECLARATION, fOpenDeclaration);
+        }
+        if (fOpenPropertiesDialog != null) {
+               actionBars.setGlobalActionHandler(ActionFactory.PROPERTIES.getId(), fOpenPropertiesDialog);
+        }
+       }
+       
+       private IStructuredSelection getStructuredSelection() {
+               if (fSite != null) {
+                       ISelection selection= fSite.getSelectionProvider().getSelection();
+                       if (selection instanceof IStructuredSelection) {
+                               return (IStructuredSelection)selection;
+                       }
+               }
+               return null;
+       }
+
+       public static boolean canActionBeAdded(ISelection selection) {
+               if (selection instanceof ITextSelection) {
+                       return true;
+               }
+               return getElement(selection) != null;
+       }
+       
+       private static ICElement getElement(ISelection sel) {
+               if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
+                       List<?> list= ((IStructuredSelection)sel).toList();
+                       if (list.size() == 1) {
+                               Object element= list.get(0);
+                               if (element instanceof ICElement) {
+                                       return (ICElement)element;
+                               }
+                       }
+               }
+               return null;
+       }
+       
+
+       public void setAppendToGroup(String groupName) {
+               fGroupName= groupName;
+       }
+
+       public void setSuppressTypeHierarchy(boolean suppressTypeHierarchy) {
+               fSuppressTypeHierarchy = suppressTypeHierarchy;
+       }
+
+       public void setSuppressCallHierarchy(boolean suppressCallHierarchy) {
+               fSuppressCallHierarchy = suppressCallHierarchy;
+       }
+
+       public void setSuppressProperties(boolean suppressProperties) {
+               fSuppressProperties = suppressProperties;
+       }
+       
+       public void setEnableIncludeBrowser(boolean enableIncludeBrowser) {
+               fEnableIncludeBrowser= enableIncludeBrowser;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/SelectionDispatchAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/SelectionDispatchAction.java
new file mode 100644 (file)
index 0000000..8b3e33a
--- /dev/null
@@ -0,0 +1,203 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.actions;
+
+
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+
+import org.eclipse.ui.IWorkbenchSite;
+
+/**
+ * Action that dispatches the <code>IAction#run()</code> and the 
+ * <code>ISelectionChangedListener#selectionChanged</code> 
+ * according to the type of the selection. 
+ * 
+ * <ul>
+ *     <li>if selection is of type <code>ITextSelection</code> then
+ *     <code>run(ITextSelection)</code> and <code>selectionChanged(ITextSelection)</code>
+ *     is called.</li> 
+ *     <li>if selection is of type <code>IStructuredSelection</code> then
+ *     <code>run(IStructuredSelection)</code> and <code>
+ *     selectionChanged(IStructuredSelection)</code> is called.</li>
+ *     <li>default is to call <code>run(ISelection)</code> and <code>
+ *     selectionChanged(ISelection)</code>.</li>
+ * </ul>
+ * 
+ * <p>
+ * Note: This class is not intended to be subclassed outside the CDT UI plugin.
+ * </p>
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ * @since 2.0
+ */
+public abstract class SelectionDispatchAction extends Action implements ISelectionChangedListener {
+       
+       private IWorkbenchSite fSite;
+       
+       /**
+        * Creates a new action with no text and no image.
+        * <p>
+        * Configure the action later using the set methods.
+        * </p>
+        * 
+        * @param site the site this action is working on
+        */
+       protected SelectionDispatchAction(IWorkbenchSite site) {
+               Assert.isNotNull(site);
+               fSite= site;
+       }
+
+       /**
+        * Returns the site owning this action.
+        * 
+        * @return the site owning this action
+        */
+       public IWorkbenchSite getSite() {
+               return fSite;
+       }
+
+       /**
+        * Returns the selection provided by the site owning this action.
+        * 
+        * @return the site's selection
+        */     
+       public ISelection getSelection() {
+               if (getSelectionProvider() != null)
+                       return getSelectionProvider().getSelection();
+               return null;
+       }
+
+       /**
+        * Returns the shell provided by the site owning this action.
+        * 
+        * @return the site's shell     
+        */
+       public  Shell getShell() {
+               return fSite.getShell();
+       }
+       
+       /**
+        * Returns the selection provider managed by the site owning this action.
+        * 
+        * @return the site's selection provider        
+        */
+       public ISelectionProvider getSelectionProvider() {
+               return fSite.getSelectionProvider();
+       }
+
+       /**
+        * Updates the action's enablement state according to the given selection. This
+        * default implementation calls one of the <code>selectionChanged</code>
+        * methods depending on the type of the passed selection.
+        * 
+        * @param selection the selection this action is working on
+        */
+       public void update(ISelection selection) {
+               dispatchSelectionChanged(selection);
+       }
+
+       /**
+        * Notifies this action that the given structured selection has changed. This default
+        * implementation calls <code>selectionChanged(ISelection selection)</code>.
+        * 
+        * @param selection the new selection
+        */
+       public void selectionChanged(IStructuredSelection selection) {
+               selectionChanged((ISelection)selection);
+       }
+
+       /**
+        * Executes this actions with the given structured selection. This default implementation
+        * calls <code>run(ISelection selection)</code>.
+        */
+       public void run(IStructuredSelection selection) {
+               run((ISelection)selection);
+       }
+                       
+       /**
+        * Notifies this action that the given text selection has changed.  This default
+        * implementation calls <code>selectionChanged(ISelection selection)</code>.
+        * 
+        * @param selection the new selection
+        */
+       public void selectionChanged(ITextSelection selection) {
+               selectionChanged((ISelection)selection);
+       }
+       
+       /**
+        * Executes this actions with the given text selection. This default implementation
+        * calls <code>run(ISelection selection)</code>.
+        */
+       public void run(ITextSelection selection) {
+               run((ISelection)selection);
+       }
+       
+       /**
+        * Notifies this action that the given selection has changed.  This default
+        * implementation sets the action's enablement state to <code>false</code>.
+        * 
+        * @param selection the new selection
+        */
+       public void selectionChanged(ISelection selection) {
+               setEnabled(false);
+       }
+       
+       /**
+        * Executes this actions with the given selection. This default implementation
+        * does nothing.
+        */
+       public void run(ISelection selection) {
+       }
+
+       /* (non-Javadoc)
+        * Method declared on IAction.
+        */
+       @Override
+       public void run() {
+               dispatchRun(getSelection());
+       }
+       
+       /* (non-Javadoc)
+        * Method declared on ISelectionChangedListener.
+        */
+       public void selectionChanged(SelectionChangedEvent event) {
+               dispatchSelectionChanged(event.getSelection());
+       }
+
+       private void dispatchSelectionChanged(ISelection selection) {
+               if (selection instanceof IStructuredSelection) {
+                       selectionChanged((IStructuredSelection)selection);
+               } else if (selection instanceof ITextSelection) {
+                       selectionChanged((ITextSelection)selection);
+               } else {
+                       selectionChanged(selection);
+               }
+       }
+
+       private void dispatchRun(ISelection selection) {
+               if (selection instanceof IStructuredSelection) {
+                       run((IStructuredSelection)selection);
+               } else if (selection instanceof ITextSelection) {
+                       run((ITextSelection)selection);
+               } else {
+                       run(selection);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ShowInCViewAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/ShowInCViewAction.java
new file mode 100644 (file)
index 0000000..afdc056
--- /dev/null
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui.actions;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
+import org.eclipse.cdt.internal.ui.editor.CEditorMessages;
+import org.eclipse.cdt.ui.CUIPlugin;
+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.viewers.StructuredSelection;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.actions.SelectionProviderAction;
+import org.eclipse.ui.part.ISetSelectionTarget;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+/**
+ * This class will open the C/C++ Projects view and highlight the
+ * selected resource matching the current resouce being edited in
+ * the C/C++ Editor.  It uses the IShowInSource/IShowInTarget to 
+ * accomplish this task so as to provide some additional portability
+ * and future proofing.
+ * 
+ * @deprecated Use generic IShowInTarget support instead.
+ */
+@Deprecated
+public class ShowInCViewAction extends SelectionProviderAction {
+
+       private IWorkbenchPage page;
+       private ITextEditor fEditor;
+
+       public ShowInCViewAction(IWorkbenchSite site) {
+               this(site.getPage(), site.getSelectionProvider());
+       }
+
+       public ShowInCViewAction(ITextEditor editor) {  
+               this(editor.getEditorSite().getWorkbenchWindow().getActivePage(), editor.getSelectionProvider());
+               fEditor = editor;
+       }
+
+       public ShowInCViewAction(IWorkbenchPage page, ISelectionProvider viewer) {
+               super(viewer, CEditorMessages.ShowInCView_label); 
+               setToolTipText(CEditorMessages.ShowInCView_tooltip); 
+               setDescription(CEditorMessages.ShowInCView_description); 
+               this.page = page;
+               setDescription(CEditorMessages.ShowInCView_tooltip); 
+               //WorkbenchHelp.setHelp(this, ICHelpContextIds.SHOW_IN_CVIEW_ACTION);
+       }
+
+       @Override
+       public void run() {
+               ISelection selection = getSelection();
+               if (selection instanceof ITextSelection) {
+                       run(fEditor);
+               } else if (selection instanceof IStructuredSelection) {
+                       run((IStructuredSelection)selection);
+               }
+
+       }
+
+       public void run(IStructuredSelection selection) {
+               if (page == null) {
+                       page = CUIPlugin.getActivePage();
+                       if (page == null) {
+                               return;
+                       }
+               }
+
+               //Locate a source and a target for us to use
+               try {
+                       IWorkbenchPart part = page.showView(CUIPlugin.CVIEW_ID);
+                       if (part instanceof ISetSelectionTarget) {
+                               ((ISetSelectionTarget) part).selectReveal(selection);
+                       }
+               } catch(PartInitException ex) {
+               }
+       }
+
+       public void run(ITextEditor editor) {
+               if (editor != null) {
+                       try {
+                               ICElement celement = SelectionConverter.getElementAtOffset(editor);
+                               if (celement != null) {
+                                       run(new StructuredSelection(celement));
+                               }
+                       } catch (CModelException e) {
+                       }
+               }
+       }
+
+       /*
+        * (non-Javadoc)
+        * Method declared on SelectionProviderAction.
+        */
+       @Override
+       public void selectionChanged(IStructuredSelection selection) {
+               setEnabled(!getSelection().isEmpty());
+       }
+
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/WorkingSetConfigAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/WorkingSetConfigAction.java
new file mode 100644 (file)
index 0000000..f3368ae
--- /dev/null
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Intel Corporation, QNX Software Systems, and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *     QNX Software Systems - [272416] Rework the config sets dialog 
+ *******************************************************************************/
+package org.eclipse.cdt.ui.actions;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetManager;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.workingsets.WorkingSetConfigurationDialog;
+
+/**
+ */
+public class WorkingSetConfigAction implements IWorkbenchWindowActionDelegate, IPropertyChangeListener {
+       private static final IWorkingSetManager wsm = CUIPlugin.getDefault().getWorkbench().getWorkingSetManager();  
+       private boolean enabled = true;
+       
+       private IWorkbenchWindow window;
+       
+       public void run(IAction action) {
+               new WorkingSetConfigurationDialog(window.getShell()).open();
+       }
+       
+       public void selectionChanged(IAction action, ISelection selection) {
+               checkWS();
+               if (action.isEnabled() != enabled)
+                       action.setEnabled(enabled);
+       }
+       public void dispose() {
+               wsm.removePropertyChangeListener(this);
+               
+       }
+       public void init(IWorkbenchWindow window) {
+               this.window = window;
+               wsm.addPropertyChangeListener(this);
+               checkWS();
+       }
+       
+       private IWorkingSet[] checkWS() {
+               IWorkingSet[] w = wsm.getWorkingSets();
+               if (w == null)
+                       w = new IWorkingSet[0]; 
+               enabled = w.length > 0;
+               return w;
+       }
+
+       public void propertyChange(PropertyChangeEvent event) {
+               checkWS();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoLabelProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoLabelProvider.java
new file mode 100644 (file)
index 0000000..45dc538
--- /dev/null
@@ -0,0 +1,245 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software Systems - adapted for use in CDT
+ *     Andrew Ferguson (Symbian)
+ *     Anton Leherbauer (Wind River Systems)
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.browser.typeinfo;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+import org.eclipse.cdt.core.browser.IFunctionInfo;
+import org.eclipse.cdt.core.browser.IQualifiedTypeName;
+import org.eclipse.cdt.core.browser.ITypeInfo;
+import org.eclipse.cdt.core.browser.ITypeReference;
+import org.eclipse.cdt.core.browser.IndexTypeInfo;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IVariableDeclaration;
+import org.eclipse.cdt.ui.CDTSharedImages;
+
+import org.eclipse.cdt.internal.core.model.FunctionDeclaration;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class TypeInfoLabelProvider extends LabelProvider {
+
+       public static final int SHOW_NAME_ONLY= 0x01;
+       public static final int SHOW_ENCLOSING_TYPE_ONLY= 0x02;
+       public static final int SHOW_FULLY_QUALIFIED= 0x04;
+       public static final int SHOW_PATH= 0x08;
+       public static final int SHOW_PARAMETERS= 0x10;
+       public static final int SHOW_RETURN_TYPE= 0x20;
+
+       private static final Image HEADER_ICON= CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_TUNIT_HEADER);
+       private static final Image SOURCE_ICON= CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_TUNIT);
+       private static final Image NAMESPACE_ICON= CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_NAMESPACE);
+       private static final Image TEMPLATE_ICON= CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_TEMPLATE);
+       private static final Image CLASS_ICON= CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_CLASS);
+       private static final Image STRUCT_ICON= CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_STRUCT);
+       private static final Image TYPEDEF_ICON= CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_TYPEDEF);
+       private static final Image UNION_ICON= CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_UNION);
+       private static final Image ENUM_ICON= CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_ENUMERATION);
+       private static final Image FUNCTION_ICON= CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_FUNCTION);
+       private static final Image VARIABLE_ICON= CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_VARIABLE);
+       private static final Image VARIABLE_LOCAL_ICON= CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_LOCAL_VARIABLE);
+       private static final Image ENUMERATOR_ICON= CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_ENUMERATOR);
+       private static final Image MACRO_ICON= CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_MACRO);
+       private static final Image UNKNOWN_TYPE_ICON= CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_UNKNOWN_TYPE);
+
+       private int fFlags;
+       
+       public TypeInfoLabelProvider(int flags) {
+               fFlags= flags;
+       }       
+       
+       private boolean isSet(int flag) {
+               return (fFlags & flag) != 0;
+       }
+
+       /* non java-doc
+        * @see ILabelProvider#getText
+        */
+       @Override
+       public String getText(Object element) {
+               if (! (element instanceof ITypeInfo)) 
+                       return super.getText(element);
+               
+               ITypeInfo typeInfo= (ITypeInfo) element;
+               IQualifiedTypeName qualifiedName = typeInfo.getQualifiedTypeName();
+               
+               StringBuffer buf= new StringBuffer();
+               if (isSet(SHOW_NAME_ONLY)) {
+                       String name= typeInfo.getName();
+                       if (name != null && name.length() > 0)
+                               buf.append(name);
+               } else if (isSet(SHOW_ENCLOSING_TYPE_ONLY)) {
+                       IQualifiedTypeName parentName= qualifiedName.getEnclosingTypeName();
+                       if (parentName != null) {
+                               buf.append(parentName.getFullyQualifiedName());
+                       } else {
+                               buf.append(TypeInfoMessages.TypeInfoLabelProvider_globalScope); 
+                       }
+               } else if (isSet(SHOW_FULLY_QUALIFIED)) {
+                       final int elemType = typeInfo.getCElementType();
+                       if (elemType != ICElement.C_VARIABLE_LOCAL && qualifiedName.isGlobal()) {
+                               if ((elemType != ICElement.C_FUNCTION && elemType != ICElement.C_VARIABLE) ||
+                                               !(typeInfo instanceof IndexTypeInfo && ((IndexTypeInfo) typeInfo).isFileLocal())) {
+                                       buf.append(TypeInfoMessages.TypeInfoLabelProvider_globalScope);
+                                       buf.append(' ');
+                               }
+                       }
+                       buf.append(qualifiedName.getFullyQualifiedName());
+               }
+               if (isSet(SHOW_PARAMETERS)) {
+                       final int elementType = typeInfo.getCElementType();
+                       if (elementType == ICElement.C_FUNCTION || elementType == ICElement.C_MACRO) {
+                               if (typeInfo instanceof IFunctionInfo) {
+                                       IFunctionInfo functionInfo= (IFunctionInfo)typeInfo;
+                                       String[] params= functionInfo.getParameters();
+                                       if (params != null) {
+                                               buf.append(FunctionDeclaration.getParameterClause(params));
+                                       }
+                               }
+                       }
+               }
+               if (isSet(SHOW_RETURN_TYPE)) {
+                       switch(typeInfo.getCElementType()) {
+                       case ICElement.C_FUNCTION:
+                               if (typeInfo instanceof IFunctionInfo) {
+                                       IFunctionInfo functionInfo= (IFunctionInfo)typeInfo;
+                                       String returnType= functionInfo.getReturnType();
+                                       if (returnType != null && returnType.length() > 0) {
+                                               buf.append(TypeInfoMessages.TypeInfoLabelProvider_colon);
+                                               buf.append(returnType);
+                                       }
+                               }
+                               break;
+                       case ICElement.C_VARIABLE:
+                               ITypeReference ref= typeInfo.getResolvedReference();
+                               if (ref != null) {
+                                       ICElement[] cElements= ref.getCElements();
+                                       if (cElements != null && cElements.length > 0) {
+                                               String returnType= null;
+                                               if (cElements[0] instanceof IVariableDeclaration) {
+                                                       try {
+                                                               returnType= ((IVariableDeclaration)cElements[0]).getTypeName();
+                                                       } catch (CModelException exc) {
+                                                       }
+                                               }
+                                               if (returnType != null && returnType.length() > 0) {
+                                                       buf.append(TypeInfoMessages.TypeInfoLabelProvider_colon);
+                                                       buf.append(returnType);
+                                               }
+                                       }
+                               }
+                               break;
+                       }
+               }
+               if (isSet(SHOW_PATH)) {
+                       IPath path = null;
+                       ITypeReference ref = typeInfo.getResolvedReference();
+                       if (ref != null) {
+                               path = ref.getPath();
+                       } else {
+                               ICProject project = typeInfo.getEnclosingProject();
+                               if (project != null) {
+                                       path = project.getProject().getFullPath();
+                               }
+                       }
+                       if (path != null) {
+                               buf.append(TypeInfoMessages.TypeInfoLabelProvider_dash);
+                               buf.append(path.toString());
+                       }
+               }
+               return buf.toString();                          
+       }
+       
+       /* non java-doc
+        * @see ILabelProvider#getImage
+        */     
+       @Override
+       public Image getImage(Object element) {
+               if (!(element instanceof ITypeInfo)) 
+                       return super.getImage(element); 
+
+               ITypeInfo typeRef= (ITypeInfo) element;
+               if (isSet(SHOW_ENCLOSING_TYPE_ONLY)) {
+                       IPath path = null;
+                       ITypeReference ref = typeRef.getResolvedReference();
+                       if (ref != null) {
+                               path = ref.getPath();
+                               
+                               // IndexTypeInfo may not have an enclosing project 
+                               ICProject cproject = typeRef.getEnclosingProject();
+                               IProject project = cproject==null ? null : cproject.getProject();
+                               
+                               if (CoreModel.isValidHeaderUnitName(project, path.lastSegment())) {
+                                       return HEADER_ICON;
+                               }
+                       }
+                       return SOURCE_ICON;
+               }
+
+               return getTypeIcon(typeRef.getCElementType());
+       }
+
+       public static Image getTypeIcon(int type)
+       {
+               switch (type)
+               {
+               case ICElement.C_NAMESPACE:
+                       return NAMESPACE_ICON;
+                       
+               case ICElement.C_TEMPLATE_CLASS:
+                       return TEMPLATE_ICON;
+
+               case ICElement.C_CLASS:
+                       return CLASS_ICON;
+
+               case ICElement.C_STRUCT:
+                       return STRUCT_ICON;
+
+               case ICElement.C_UNION:
+                       return UNION_ICON;
+
+               case ICElement.C_ENUMERATION:
+                       return ENUM_ICON;
+
+               case ICElement.C_TYPEDEF:
+                       return TYPEDEF_ICON;
+
+               case ICElement.C_FUNCTION:
+                       return FUNCTION_ICON;
+
+               case ICElement.C_VARIABLE:
+                       return VARIABLE_ICON;
+               
+               case ICElement.C_ENUMERATOR:
+                       return ENUMERATOR_ICON;
+                       
+               case ICElement.C_MACRO:
+                       return MACRO_ICON;
+                       
+               case ICElement.C_VARIABLE_LOCAL:
+                       return VARIABLE_LOCAL_ICON;
+
+               default:
+                       return UNKNOWN_TYPE_ICON;
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoMessages.java
new file mode 100644 (file)
index 0000000..4f0a595
--- /dev/null
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.browser.typeinfo;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ */
+public final class TypeInfoMessages extends NLS {
+
+       private static final String BUNDLE_NAME = "org.eclipse.cdt.ui.browser.typeinfo.TypeInfoMessages";//$NON-NLS-1$
+
+       private TypeInfoMessages() {
+               // Do not instantiate
+       }
+
+       public static String TypeSelectionDialog_lowerLabel;
+       public static String TypeSelectionDialog_upperLabel;
+       public static String TypeSelectionDialog_filterLabel;
+       public static String TypeSelectionDialog_filterNamespaces;
+       public static String TypeSelectionDialog_filterClasses;
+       public static String TypeSelectionDialog_filterStructs;
+       public static String TypeSelectionDialog_filterTypedefs;
+       public static String TypeSelectionDialog_filterEnums;
+       public static String TypeSelectionDialog_filterUnions;
+       public static String TypeSelectionDialog_filterFunctions;
+       public static String TypeSelectionDialog_filterVariables;
+       /** @since 5.3 */
+       public static String TypeSelectionDialog_filterEnumerators;
+       public static String TypeSelectionDialog_filterMacros;
+       public static String TypeSelectionDialog_filterLowLevelTypes;
+       public static String TypeInfoLabelProvider_globalScope;
+       public static String TypeInfoLabelProvider_dash;
+       public static String TypeInfoLabelProvider_colon;
+
+       static {
+               NLS.initializeMessages(BUNDLE_NAME, TypeInfoMessages.class);
+       }
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoMessages.properties
new file mode 100644 (file)
index 0000000..7a42f62
--- /dev/null
@@ -0,0 +1,36 @@
+###############################################################################
+# Copyright (c) 2000, 2010 QNX Software Systems and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     QNX Software Systems - Initial API and implementation
+#     Anton Leherbauer (Wind River Systems)
+#     IBM Corporation
+#     Markus Schorn (Wind River Systems)
+###############################################################################
+
+TypeSelectionDialog_lowerLabel=&Qualified name and location:
+TypeSelectionDialog_upperLabel=&Matching elements:
+TypeSelectionDialog_filterLabel=Visible element types:
+
+# START NON-TRANSLATABLE
+TypeSelectionDialog_filterNamespaces=&Namespace
+TypeSelectionDialog_filterClasses=C&lass
+TypeSelectionDialog_filterStructs=&Struct
+TypeSelectionDialog_filterTypedefs=&Typedef
+# END NON-TRANSLATABLE
+TypeSelectionDialog_filterEnums=&Enumeration
+TypeSelectionDialog_filterUnions=&Union
+TypeSelectionDialog_filterFunctions=&Function
+TypeSelectionDialog_filterVariables=&Variable
+TypeSelectionDialog_filterEnumerators=Enume&rator
+TypeSelectionDialog_filterMacros=M&acro
+
+TypeSelectionDialog_filterLowLevelTypes=Show &low-level elements (names beginning with '_')
+
+TypeInfoLabelProvider_globalScope=(global)
+TypeInfoLabelProvider_dash=\ -\ 
+TypeInfoLabelProvider_colon=:\ 
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java
new file mode 100644 (file)
index 0000000..d52441a
--- /dev/null
@@ -0,0 +1,697 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software Systems - adapted for use in CDT
+ *     Markus Schorn (Wind River Systems)
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.browser.typeinfo;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleAdapter;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.FilteredList;
+import org.eclipse.ui.dialogs.TwoPaneElementSelector;
+
+import org.eclipse.cdt.core.browser.IQualifiedTypeName;
+import org.eclipse.cdt.core.browser.ITypeInfo;
+import org.eclipse.cdt.core.browser.ITypeReference;
+import org.eclipse.cdt.core.browser.IndexTypeInfo;
+import org.eclipse.cdt.core.browser.QualifiedTypeName;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.util.StringMatcher;
+
+/**
+ * A dialog to select a type from a list of types.
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class TypeSelectionDialog extends TwoPaneElementSelector {
+
+       private static class TypeFilterMatcher implements FilteredList.FilterMatcher {
+
+               private static final char END_SYMBOL = '<';
+               private static final char ANY_STRING = '*';
+               
+               private StringMatcher fNameMatcher = null;
+               private StringMatcher[] fSegmentMatchers = null;
+               private boolean fMatchGlobalNamespace = false;
+               private Collection<Integer> fVisibleTypes = new HashSet<Integer>();
+               private boolean fShowLowLevelTypes = false;
+               
+               /*
+                * @see FilteredList.FilterMatcher#setFilter(String, boolean)
+                */
+               public void setFilter(String pattern, boolean ignoreCase, boolean ignoreWildCards) {
+                       // parse pattern into segments
+                       QualifiedTypeName qualifiedName = new QualifiedTypeName(pattern);
+                       String[] segments = qualifiedName.segments();
+                       int length = segments.length;
+
+                       // append wildcard to innermost segment
+                       segments[length-1] = adjustPattern(segments[length-1]);
+                       
+                       fMatchGlobalNamespace = false;
+                       fSegmentMatchers = new StringMatcher[length];
+                       int count = 0;
+                       for (int i = 0; i < length; ++i) {
+                               if (segments[i].length() > 0) {
+                                       // create StringMatcher for this segment
+                                       fSegmentMatchers[count++] = new StringMatcher(segments[i], ignoreCase, ignoreWildCards);
+                               } else if (i == 0) {
+                                       // allow outermost segment to be blank (e.g. "::foo*")
+                                       fMatchGlobalNamespace = true;
+                               } else {
+                                       // skip over blank segments (e.g. treat "foo::::b*" as "foo::b*")
+                               }
+                       }
+                       if (count != length) {
+                               if (count > 0) {
+                                       // resize array
+                                       StringMatcher[] newMatchers = new StringMatcher[count];
+                                       System.arraycopy(fSegmentMatchers, 0, newMatchers, 0, count);
+                                       fSegmentMatchers = newMatchers;
+                               } else {
+                                       // fallback to wildcard (should never get here)
+                                       fSegmentMatchers = new StringMatcher[1];
+                                       fSegmentMatchers[0] = new StringMatcher(String.valueOf(ANY_STRING), ignoreCase, ignoreWildCards);
+                               }
+                       }
+                       // match simple name with innermost segment
+                       fNameMatcher = fSegmentMatchers[fSegmentMatchers.length-1];
+               }
+               
+               public Collection<Integer> getVisibleTypes() {
+                       return fVisibleTypes;
+               }
+               
+               public void setShowLowLevelTypes(boolean show) {
+                       fShowLowLevelTypes = show;
+               }
+
+               public boolean getShowLowLevelTypes() {
+                       return fShowLowLevelTypes;
+               }
+
+               /*
+                * @see FilteredList.FilterMatcher#match(Object)
+                */
+               public boolean match(Object element) {
+                       if (!(element instanceof ITypeInfo))
+                               return false;
+
+                       ITypeInfo info = (ITypeInfo) element;
+                       IQualifiedTypeName qualifiedName = info.getQualifiedTypeName();
+                       
+                       if (fVisibleTypes != null && !fVisibleTypes.contains(new Integer(info.getCElementType())))
+                               return false;
+
+                       if (!fShowLowLevelTypes && qualifiedName.isLowLevel())
+                               return false;
+                       
+                       if (fSegmentMatchers.length == 1 && !fMatchGlobalNamespace)
+                               return fNameMatcher.match(qualifiedName.getName());
+                       
+                       return matchQualifiedName(info);
+               }
+
+               private boolean matchQualifiedName(ITypeInfo info) {
+                       IQualifiedTypeName qualifiedName = info.getQualifiedTypeName();
+                       if (fSegmentMatchers.length != qualifiedName.segmentCount())
+                               return false;
+                       
+                       if (fMatchGlobalNamespace) {
+                               // must match global namespace (eg ::foo)
+                               if (qualifiedName.segment(0).length() > 0)
+                                       return false;
+                       }
+                       
+                       boolean matchFound = true;
+                       int max = Math.min(fSegmentMatchers.length, qualifiedName.segmentCount());
+                       for (int i = 0; i < max; ++i) {
+                               StringMatcher matcher = fSegmentMatchers[i];
+                               String name = qualifiedName.segment(i);
+                               if (name == null || !matcher.match(name)) {
+                                       matchFound = false;
+                                       break;
+                               }
+                       }
+                       return matchFound;
+               }
+
+               private static String adjustPattern(String pattern) {
+                       int length = pattern.length();
+                       if (length > 0) {
+                               switch (pattern.charAt(length - 1)) {
+                                       case END_SYMBOL:
+                                               return pattern.substring(0, length - 1);
+                                       case ANY_STRING:
+                                               return pattern;
+                               }
+                       }
+                       return pattern + ANY_STRING;
+               }
+       }
+       
+       private static class StringComparator implements Comparator<String> {
+           public int compare(String left, String right) {
+               int result = left.compareToIgnoreCase(right);                   
+                       if (result == 0)
+                               result = left.compareTo(right);
+
+                       return result;
+           }
+       }
+
+       private static final String DIALOG_SETTINGS = TypeSelectionDialog.class.getName();
+       private static final String SETTINGS_X_POS = "x"; //$NON-NLS-1$
+       private static final String SETTINGS_Y_POS = "y"; //$NON-NLS-1$
+       private static final String SETTINGS_WIDTH = "width"; //$NON-NLS-1$
+       private static final String SETTINGS_HEIGHT = "height"; //$NON-NLS-1$
+       private static final String SETTINGS_SHOW_NAMESPACES = "show_namespaces"; //$NON-NLS-1$
+       private static final String SETTINGS_SHOW_CLASSES = "show_classes"; //$NON-NLS-1$
+       private static final String SETTINGS_SHOW_STRUCTS = "show_structs"; //$NON-NLS-1$
+       private static final String SETTINGS_SHOW_TYPEDEFS = "show_typedefs"; //$NON-NLS-1$
+       private static final String SETTINGS_SHOW_ENUMS = "show_enums"; //$NON-NLS-1$
+       private static final String SETTINGS_SHOW_UNIONS = "show_unions"; //$NON-NLS-1$
+       private static final String SETTINGS_SHOW_FUNCTIONS = "show_functions"; //$NON-NLS-1$
+       private static final String SETTINGS_SHOW_VARIABLES = "show_variables"; //$NON-NLS-1$
+       private static final String SETTINGS_SHOW_ENUMERATORS = "show_enumerators"; //$NON-NLS-1$
+       private static final String SETTINGS_SHOW_MACROS = "show_macros"; //$NON-NLS-1$
+       private static final String SETTINGS_SHOW_LOWLEVEL = "show_lowlevel"; //$NON-NLS-1$
+
+       private static final TypeInfoLabelProvider fElementRenderer = new TypeInfoLabelProvider(
+                       TypeInfoLabelProvider.SHOW_NAME_ONLY | TypeInfoLabelProvider.SHOW_PARAMETERS);
+       private static final TypeInfoLabelProvider fQualifierRenderer = new TypeInfoLabelProvider(
+                       TypeInfoLabelProvider.SHOW_FULLY_QUALIFIED |
+                       TypeInfoLabelProvider.SHOW_PARAMETERS |
+                       TypeInfoLabelProvider.SHOW_PATH);
+       
+       private static final StringComparator fStringComparator = new StringComparator();
+
+       private static final int[] ALL_TYPES = { ICElement.C_NAMESPACE, ICElement.C_CLASS,
+                       ICElement.C_STRUCT, ICElement.C_TYPEDEF, ICElement.C_ENUMERATION,
+                       ICElement.C_UNION, ICElement.C_FUNCTION, ICElement.C_VARIABLE, 
+                       ICElement.C_ENUMERATOR, ICElement.C_MACRO };
+
+       // the filter matcher contains state information, must not be static
+       private final TypeFilterMatcher fFilterMatcher = new TypeFilterMatcher();
+       private Set<Integer> fKnownTypes = new HashSet<Integer>(ALL_TYPES.length);
+       private Text fTextWidget;
+       private boolean fSelectFilterText = false;
+       private FilteredList fNewFilteredList;
+       private String fDialogSection;
+       private Point fLocation;
+       private Point fSize;
+       /**
+        * Constructs a type selection dialog.
+        * @param parent  the parent shell.
+        */
+       public TypeSelectionDialog(Shell parent) {
+               super(parent, fElementRenderer, fQualifierRenderer);
+               setMatchEmptyString(false);
+               setUpperListLabel(TypeInfoMessages.TypeSelectionDialog_upperLabel); 
+               setLowerListLabel(TypeInfoMessages.TypeSelectionDialog_lowerLabel); 
+               setVisibleTypes(ALL_TYPES);
+               setDialogSettings(DIALOG_SETTINGS);
+       }
+       
+       /**
+        * Sets the filter pattern.
+        * @param filter the filter pattern.
+        * @param selectText <code>true</code> if filter text should be initially selected
+        * @see org.eclipse.ui.dialogs.AbstractElementListSelectionDialog#setFilter(java.lang.String)
+        */
+       public void setFilter(String filter, boolean selectText) {
+               super.setFilter(filter);
+               fSelectFilterText = selectText;
+       }
+
+       /**
+        * Sets which CElement types are visible in the dialog.
+        * 
+        * @param types Array of CElement types.
+        */
+       public void setVisibleTypes(int[] types) {
+               fKnownTypes.clear();
+               for (int i = 0; i < types.length; ++i) {
+                       fKnownTypes.add(types[i]);
+               }
+       }
+       
+       /**
+        * Answer whether the given type is visible in the dialog.
+        * 
+        * @param type the type constant, see {@link ICElement}
+        * @return <code>true</code> if the given type is visible,
+        *         <code>false</code> otherwise
+        */
+       protected boolean isVisibleType(int type) {
+               return fKnownTypes.contains(type);
+       }
+
+       /**
+        * Sets section name to use when storing the dialog settings.
+        * 
+        * @param section Name of section.
+        */
+       public void setDialogSettings(String section) {
+               fDialogSection = section + "Settings"; //$NON-NLS-1$
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.dialogs.AbstractElementListSelectionDialog#createFilterText(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected Text createFilterText(Composite parent) {
+               fTextWidget = super.createFilterText(parent);
+
+               // create type checkboxes below filter text
+               createTypeFilterArea(parent);
+               
+               return fTextWidget;
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.dialogs.AbstractElementListSelectionDialog#createFilteredList(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected FilteredList createFilteredList(Composite parent) {
+               fNewFilteredList = super.createFilteredList(parent);
+               fNewFilteredList.setFilterMatcher(fFilterMatcher);
+               fNewFilteredList.setComparator(fStringComparator);
+               //bug 189330 - adding label to element list for accessiblity
+               if (fNewFilteredList != null) {
+                       fNewFilteredList.getAccessible().addAccessibleListener(
+                   new AccessibleAdapter() {                       
+                       @Override
+                                       public void getName(AccessibleEvent e) {
+                               e.result = TypeInfoMessages.TypeSelectionDialog_upperLabel;
+                       }
+                   }
+               );
+               }
+               return fNewFilteredList;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.window.Window#create()
+        */
+       @Override
+       public void create() {
+               super.create();
+               if (fSelectFilterText)
+                       fTextWidget.selectAll();
+       }
+
+       /*
+        * @see Window#close()
+        */
+       @Override
+       public boolean close() {
+               writeSettings(getDialogSettings());
+               return super.close();
+       }
+
+       /*
+        * @see org.eclipse.jface.window.Window#createContents(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected Control createContents(Composite parent) {
+               readSettings(getDialogSettings());
+               return super.createContents(parent);
+       }
+
+       /**
+        * Creates a type filter checkbox.
+        */
+       private void createTypeCheckbox(Composite parent, Integer typeObject) {
+               String name;
+               int type = typeObject.intValue();
+               switch (type) {
+                       case ICElement.C_NAMESPACE:
+                               name = TypeInfoMessages.TypeSelectionDialog_filterNamespaces; 
+                       break;
+                       case ICElement.C_CLASS:
+                               name = TypeInfoMessages.TypeSelectionDialog_filterClasses; 
+                       break;
+                       case ICElement.C_STRUCT:
+                               name = TypeInfoMessages.TypeSelectionDialog_filterStructs; 
+                       break;
+                       case ICElement.C_TYPEDEF:
+                               name = TypeInfoMessages.TypeSelectionDialog_filterTypedefs; 
+                       break;
+                       case ICElement.C_ENUMERATION:
+                               name = TypeInfoMessages.TypeSelectionDialog_filterEnums; 
+                       break;
+                       case ICElement.C_UNION:
+                               name = TypeInfoMessages.TypeSelectionDialog_filterUnions; 
+                       break;
+                       case ICElement.C_FUNCTION:
+                               name = TypeInfoMessages.TypeSelectionDialog_filterFunctions; 
+                       break;
+                       case ICElement.C_VARIABLE:
+                               name = TypeInfoMessages.TypeSelectionDialog_filterVariables; 
+                       break;
+                       case ICElement.C_ENUMERATOR:
+                               name = TypeInfoMessages.TypeSelectionDialog_filterEnumerators; 
+                       break;
+                       case ICElement.C_MACRO:
+                               name = TypeInfoMessages.TypeSelectionDialog_filterMacros; 
+                       break;
+                       default:
+                               return;
+               }
+               Image icon = TypeInfoLabelProvider.getTypeIcon(type);
+
+               Composite composite = new Composite(parent, SWT.NONE);
+               GridLayout layout= new GridLayout(2, false);
+               layout.marginHeight = 0;
+               composite.setLayout(layout);
+               
+               final Integer fTypeObject = typeObject;
+               Button checkbox = new Button(composite, SWT.CHECK);
+               checkbox.setFont(composite.getFont());
+               checkbox.setImage(icon);
+               checkbox.setSelection(fFilterMatcher.getVisibleTypes().contains(fTypeObject));
+               checkbox.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               if (e.widget instanceof Button) {
+                                       Button checkbox = (Button) e.widget;
+                                       if (checkbox.getSelection())
+                                               fFilterMatcher.getVisibleTypes().add(fTypeObject);
+                                       else
+                                               fFilterMatcher.getVisibleTypes().remove(fTypeObject);
+                                       updateElements();
+                               }
+                       }
+               });
+               checkbox.setText(name);
+       }
+
+       /**
+        * Creates an area to filter types.
+        * 
+        * @param parent area to create controls in
+        */
+       private void createTypeFilterArea(Composite parent) {
+               createLabel(parent, TypeInfoMessages.TypeSelectionDialog_filterLabel); 
+               
+               Composite upperRow = new Composite(parent, SWT.NONE);
+               int columns= fKnownTypes.size() > 6 ? 4 : 3;
+               GridLayout upperLayout = new GridLayout(columns, true);
+               upperLayout.verticalSpacing = 2;
+               upperLayout.marginHeight = 0;
+               upperLayout.marginWidth = 0;
+               upperRow.setLayout(upperLayout);
+
+               // The 'for' loop is here to guarantee that we always create the checkboxes in the same order.
+               for (int i = 0; i < ALL_TYPES.length; ++i) {
+                       Integer typeObject = new Integer(ALL_TYPES[i]);
+                       if (fKnownTypes.contains(typeObject))
+                               createTypeCheckbox(upperRow, typeObject);
+               }
+
+               if (showLowLevelFilter()) {
+                       Composite lowerRow = new Composite(parent, SWT.NONE);
+                       GridLayout lowerLayout = new GridLayout(1, true);
+                       lowerLayout.verticalSpacing = 2;
+                       lowerLayout.marginHeight = 0;
+                       upperLayout.marginWidth = 0;
+                       lowerRow.setLayout(lowerLayout);
+
+                       Composite composite = new Composite(lowerRow, SWT.NONE);
+                       GridLayout layout= new GridLayout(2, false);
+                       layout.marginHeight = 0;
+                       layout.marginWidth = 0;
+                       composite.setLayout(layout);
+
+                       String name = TypeInfoMessages.TypeSelectionDialog_filterLowLevelTypes; 
+                       Button checkbox = new Button(composite, SWT.CHECK);
+                       checkbox.setFont(composite.getFont());
+                       checkbox.setText(name);
+                       checkbox.setSelection(fFilterMatcher.getShowLowLevelTypes());
+                       checkbox.addSelectionListener(new SelectionAdapter() {
+                               @Override
+                               public void widgetSelected(SelectionEvent e) {
+                                       if (e.widget instanceof Button) {
+                                               Button button = (Button) e.widget;
+                                               fFilterMatcher.setShowLowLevelTypes(button.getSelection());
+                                               updateElements();
+                                       }
+                               }
+                       });
+               }
+       }
+       
+       /**
+        * Forces redraw of elements list.
+        */
+       void updateElements() {
+               fNewFilteredList.setFilter(fTextWidget.getText());
+               handleSelectionChanged();
+       }
+       
+       /**
+        * Returns the dialog settings object used to save state
+        * for this dialog.
+        *
+        * @return the dialog settings to be used
+        */
+       protected IDialogSettings getDialogSettings() {
+               IDialogSettings allSettings = CUIPlugin.getDefault().getDialogSettings();
+               IDialogSettings section = allSettings.getSection(fDialogSection);               
+               if (section == null) {
+                       section = allSettings.addNewSection(fDialogSection);
+                       writeDefaultSettings(section);
+               }
+               return section;
+       }
+       
+       /**
+        * Stores current configuration in the dialog store.
+        */
+       protected void writeSettings(IDialogSettings section) {
+               Point location = getShell().getLocation();
+               section.put(SETTINGS_X_POS, location.x);
+               section.put(SETTINGS_Y_POS, location.y);
+
+               if (getTray() == null) {
+                       // only save size if help tray is not shown
+                       Point size = getShell().getSize();
+                       section.put(SETTINGS_WIDTH, size.x);
+                       section.put(SETTINGS_HEIGHT, size.y);
+               }
+               section.put(SETTINGS_SHOW_NAMESPACES, fFilterMatcher.getVisibleTypes().contains(new Integer(ICElement.C_NAMESPACE)));
+               section.put(SETTINGS_SHOW_CLASSES, fFilterMatcher.getVisibleTypes().contains(new Integer(ICElement.C_CLASS)));
+               section.put(SETTINGS_SHOW_STRUCTS, fFilterMatcher.getVisibleTypes().contains(new Integer(ICElement.C_STRUCT)));
+               section.put(SETTINGS_SHOW_TYPEDEFS, fFilterMatcher.getVisibleTypes().contains(new Integer(ICElement.C_TYPEDEF)));
+               section.put(SETTINGS_SHOW_ENUMS, fFilterMatcher.getVisibleTypes().contains(new Integer(ICElement.C_ENUMERATION)));
+               section.put(SETTINGS_SHOW_UNIONS, fFilterMatcher.getVisibleTypes().contains(new Integer(ICElement.C_UNION)));
+               section.put(SETTINGS_SHOW_FUNCTIONS, fFilterMatcher.getVisibleTypes().contains(new Integer(ICElement.C_FUNCTION)));
+               section.put(SETTINGS_SHOW_VARIABLES, fFilterMatcher.getVisibleTypes().contains(new Integer(ICElement.C_VARIABLE)));
+               section.put(SETTINGS_SHOW_ENUMERATORS, fFilterMatcher.getVisibleTypes().contains(new Integer(ICElement.C_ENUMERATOR)));
+               section.put(SETTINGS_SHOW_MACROS, fFilterMatcher.getVisibleTypes().contains(new Integer(ICElement.C_MACRO)));
+               section.put(SETTINGS_SHOW_LOWLEVEL, fFilterMatcher.getShowLowLevelTypes());
+       }
+
+       /**
+        * Stores default dialog settings.
+        */
+       protected void writeDefaultSettings(IDialogSettings section) {
+               section.put(SETTINGS_SHOW_NAMESPACES, true); 
+               section.put(SETTINGS_SHOW_CLASSES, true);
+               section.put(SETTINGS_SHOW_STRUCTS, true);
+               section.put(SETTINGS_SHOW_TYPEDEFS, true);
+               section.put(SETTINGS_SHOW_ENUMS, true);
+               section.put(SETTINGS_SHOW_UNIONS, true);
+               section.put(SETTINGS_SHOW_FUNCTIONS, true);
+               section.put(SETTINGS_SHOW_VARIABLES, true);
+               section.put(SETTINGS_SHOW_ENUMERATORS, true);
+               section.put(SETTINGS_SHOW_MACROS, true);
+               section.put(SETTINGS_SHOW_LOWLEVEL, false);
+       }
+
+       /**
+        * Initializes itself from the dialog settings with the same state
+        * as at the previous invocation.
+        */
+       protected void readSettings(IDialogSettings section) {
+               try {
+                       int x = section.getInt(SETTINGS_X_POS);
+                       int y = section.getInt(SETTINGS_Y_POS);
+                       fLocation = new Point(x, y);
+                       int width = section.getInt(SETTINGS_WIDTH);
+                       int height = section.getInt(SETTINGS_HEIGHT);
+                       fSize = new Point(width, height);
+               } catch (NumberFormatException e) {
+                       fLocation = null;
+                       fSize = null;
+               }
+
+               if (section.getBoolean(SETTINGS_SHOW_NAMESPACES)) {
+                       Integer typeObject = new Integer(ICElement.C_NAMESPACE);
+                       if (fKnownTypes.contains(typeObject))
+                               fFilterMatcher.getVisibleTypes().add(typeObject);
+               }
+               if (section.getBoolean(SETTINGS_SHOW_CLASSES)) {
+                       Integer typeObject = new Integer(ICElement.C_CLASS);
+                       if (fKnownTypes.contains(typeObject))
+                               fFilterMatcher.getVisibleTypes().add(typeObject);
+               }
+               if (section.getBoolean(SETTINGS_SHOW_STRUCTS)) {
+                       Integer typeObject = new Integer(ICElement.C_STRUCT);
+                       if (fKnownTypes.contains(typeObject))
+                               fFilterMatcher.getVisibleTypes().add(typeObject);
+               }
+               if (section.getBoolean(SETTINGS_SHOW_TYPEDEFS)) {
+                       Integer typeObject = new Integer(ICElement.C_TYPEDEF);
+                       if (fKnownTypes.contains(typeObject))
+                               fFilterMatcher.getVisibleTypes().add(typeObject);
+               }
+               if (section.getBoolean(SETTINGS_SHOW_ENUMS)) {
+                       Integer typeObject = new Integer(ICElement.C_ENUMERATION);
+                       if (fKnownTypes.contains(typeObject))
+                               fFilterMatcher.getVisibleTypes().add(typeObject);
+               }
+               if (section.getBoolean(SETTINGS_SHOW_UNIONS)) {
+                       Integer typeObject = new Integer(ICElement.C_UNION);
+                       if (fKnownTypes.contains(typeObject))
+                               fFilterMatcher.getVisibleTypes().add(typeObject);
+               }
+               if (section.getBoolean(SETTINGS_SHOW_FUNCTIONS)) {
+                       Integer typeObject = new Integer(ICElement.C_FUNCTION);
+                       if (fKnownTypes.contains(typeObject))
+                               fFilterMatcher.getVisibleTypes().add(typeObject);
+               }
+               if (section.getBoolean(SETTINGS_SHOW_VARIABLES)) {
+                       Integer typeObject = new Integer(ICElement.C_VARIABLE);
+                       if (fKnownTypes.contains(typeObject))
+                               fFilterMatcher.getVisibleTypes().add(typeObject);
+               }
+               if (section.getBoolean(SETTINGS_SHOW_ENUMERATORS)) {
+                       Integer typeObject = new Integer(ICElement.C_ENUMERATOR);
+                       if (fKnownTypes.contains(typeObject))
+                               fFilterMatcher.getVisibleTypes().add(typeObject);
+               }
+               if (section.getBoolean(SETTINGS_SHOW_MACROS)) {
+                       Integer typeObject = new Integer(ICElement.C_MACRO);
+                       if (fKnownTypes.contains(typeObject))
+                               fFilterMatcher.getVisibleTypes().add(typeObject);
+               }
+               if (showLowLevelFilter()) {
+                       fFilterMatcher.setShowLowLevelTypes(section.getBoolean(SETTINGS_SHOW_LOWLEVEL));
+               } else {
+                       fFilterMatcher.setShowLowLevelTypes(true);
+               }
+       }
+       
+       /**
+        * @return whether the low level filter checkbox should be shown
+        */
+       protected boolean showLowLevelFilter() {
+               return true;
+       }
+
+       /* (non-Cdoc)
+        * @see org.eclipse.jface.window.Window#getInitialSize()
+        */
+       @Override
+       protected Point getInitialSize() {
+               Point result = super.getInitialSize();
+               if (fSize != null) {
+                       result.x = Math.max(result.x, fSize.x);
+                       result.y = Math.max(result.y, fSize.y);
+                       Rectangle display = getShell().getDisplay().getClientArea();
+                       result.x = Math.min(result.x, display.width);
+                       result.y = Math.min(result.y, display.height);
+               }
+               return result;
+       }
+       
+       /* (non-Cdoc)
+        * @see org.eclipse.jface.window.Window#getInitialLocation(org.eclipse.swt.graphics.Point)
+        */
+       @Override
+       protected Point getInitialLocation(Point initialSize) {
+               Point result = super.getInitialLocation(initialSize);
+               if (fLocation != null) {
+                       result.x = fLocation.x;
+                       result.y = fLocation.y;
+                       Rectangle display = getShell().getDisplay().getClientArea();
+                       int xe = result.x + initialSize.x;
+                       if (xe > display.width) {
+                               result.x -= xe - display.width; 
+                       }
+                       int ye = result.y + initialSize.y;
+                       if (ye > display.height) {
+                               result.y -= ye - display.height; 
+                       }
+               }
+               return result;
+       }       
+       
+       /*
+        * @see org.eclipse.ui.dialogs.SelectionStatusDialog#computeResult()
+        */
+       @Override
+       protected void computeResult() {
+               ITypeInfo selection = (ITypeInfo) getLowerSelectedElement();
+               if (selection == null)
+                       return;
+                       
+               List<ITypeInfo> result = new ArrayList<ITypeInfo>(1);
+               result.add(selection);
+               setResult(result);
+       }
+       
+    @Override
+       public Object[] getFoldedElements(int index) {
+       ArrayList<IndexTypeInfo> result= new ArrayList<IndexTypeInfo>();
+       Object[] typeInfos= super.getFoldedElements(index);
+       if (typeInfos != null) {
+               for (Object typeInfo : typeInfos) {
+                       if (typeInfo instanceof IndexTypeInfo) {
+                               addFoldedElements((IndexTypeInfo) typeInfo, result);
+                       }
+               }
+       }
+       return result.toArray();
+    }
+
+       private void addFoldedElements(IndexTypeInfo typeInfo, ArrayList<IndexTypeInfo> result) {
+               ITypeReference[] refs= typeInfo.getReferences();
+               for (ITypeReference ref : refs) {
+                       result.add(IndexTypeInfo.create(typeInfo, ref));
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractBinaryParserPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractBinaryParserPage.java
new file mode 100644 (file)
index 0000000..655cd12
--- /dev/null
@@ -0,0 +1,169 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui.dialogs;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.utils.ui.controls.TabFolderLayout;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @deprecated as of CDT 4.0. This class used in property pages
+ * for 3.X style projects.
+ */
+@Deprecated
+public abstract class AbstractBinaryParserPage extends AbstractCOptionPage {
+
+       protected ICOptionPage fCurrentBinaryParserPage;
+       protected Map<String, BinaryParserPageConfiguration> fParserPageMap = null;
+
+       // Composite parent provided by the block.
+       protected Composite fCompositeParent;
+       private ICOptionPage fCurrentPage;
+
+       protected class BinaryParserPageConfiguration {
+
+               ICOptionPage page;
+               IConfigurationElement fElement;
+
+               public BinaryParserPageConfiguration(IConfigurationElement element) {
+                       fElement = element;
+               }
+
+               public ICOptionPage getPage() throws CoreException {
+                       if (page == null) {
+                               page = (ICOptionPage) fElement.createExecutableExtension("class"); //$NON-NLS-1$
+                       }
+                       return page;
+               }
+       }
+
+       protected AbstractBinaryParserPage(String title) {
+               super(title);
+               initializeParserPageMap();
+
+       }
+
+       protected AbstractBinaryParserPage(String title, ImageDescriptor image) {
+               super(title, image);
+               initializeParserPageMap();
+       }
+
+       private void initializeParserPageMap() {
+               fParserPageMap = new HashMap<String, BinaryParserPageConfiguration>(5);
+
+               IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID, "BinaryParserPage"); //$NON-NLS-1$
+               IConfigurationElement[] infos = extensionPoint.getConfigurationElements();
+               for (int i = 0; i < infos.length; i++) {
+                       if (infos[i].getName().equals("parserPage")) { //$NON-NLS-1$
+                               String id = infos[i].getAttribute("parserID"); //$NON-NLS-1$
+                               fParserPageMap.put(id, new BinaryParserPageConfiguration(infos[i]));
+                       }
+               }
+       }
+
+       protected Composite getCompositeParent() {
+               return fCompositeParent;
+       }
+
+       protected void setCompositeParent(Composite parent) {
+               fCompositeParent = parent;
+               fCompositeParent.setLayout(new TabFolderLayout());
+       }
+
+       @Override
+       public void setVisible(boolean visible) {
+               super.setVisible(visible);
+               handleBinaryParserChanged();
+       }
+       /**
+        * Notification that the user changed the selection of the Binary Parser.
+        */
+       protected void handleBinaryParserChanged() {
+               if (getCompositeParent() == null) {
+                       return;
+               }
+               String[] enabled = getBinaryParserIDs();
+               ICOptionPage page;
+               for (int i = 0; i < enabled.length; i++) { // create all enabled pages
+                       page = getBinaryParserPage(enabled[i]);
+                       if (page != null) {
+                               if (page.getControl() == null) {
+                                       Composite parent = getCompositeParent();
+                                       page.setContainer(getContainer());
+                                       page.createControl(parent);
+                                       parent.layout(true);
+                               } else {
+                                       page.setVisible(false);
+                               }
+                       }
+               }
+               // Retrieve the dynamic UI for the current parser
+               String parserID = getCurrentBinaryParserID();
+               page = getBinaryParserPage(parserID);
+               if (page != null) {
+                       page.setVisible(true);
+               }
+               setCurrentPage(page);
+       }
+
+       protected ICOptionPage getCurrentPage() {
+               return fCurrentPage;
+       }
+
+       protected void setCurrentPage(ICOptionPage page) {
+               fCurrentPage = page;
+       }
+
+       protected ICOptionPage getBinaryParserPage(String parserID) {
+               BinaryParserPageConfiguration configElement = fParserPageMap.get(parserID);
+               if (configElement != null) {
+                       try {
+                               return configElement.getPage();
+                       } catch (CoreException e) {
+                       }
+               }
+               return null;
+       }
+
+       abstract protected String getCurrentBinaryParserID();
+
+       abstract protected String[] getBinaryParserIDs();
+
+       @Override
+       abstract public void createControl(Composite parent);
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
+        */
+       @Override
+       abstract public void performApply(IProgressMonitor monitor) throws CoreException;
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
+        */
+       @Override
+       abstract public void performDefaults();
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractCOptionPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractCOptionPage.java
new file mode 100644 (file)
index 0000000..d6dbf9f
--- /dev/null
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.dialogs;
+
+import org.eclipse.cdt.internal.ui.util.SWTUtil;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+
+public abstract class AbstractCOptionPage extends DialogPage implements ICOptionPage {
+
+       private boolean bIsValid = true;
+       private ICOptionContainer fContainer;
+       
+
+       protected Button createPushButton(Composite parent, String label, Image image) {
+               Button button = new Button(parent, SWT.PUSH);
+               button.setFont(parent.getFont());
+               if (image != null) {
+                       button.setImage(image);
+               }
+               if (label != null) {
+                       button.setText(label);
+               }
+               GridData gd = new GridData();
+               button.setLayoutData(gd);
+               SWTUtil.setButtonDimensionHint(button);
+               return button;
+       }
+
+       protected Button createRadioButton(Composite parent, String label) {
+               Button button = new Button(parent, SWT.RADIO);
+               button.setFont(parent.getFont());
+               if (label != null) {
+                       button.setText(label);
+               }
+               GridData gd = new GridData();
+               button.setLayoutData(gd);
+               SWTUtil.setButtonDimensionHint(button);
+               return button;
+       }
+
+       protected AbstractCOptionPage() {
+               super();
+       }
+
+       protected AbstractCOptionPage(String title) {
+               super(title);
+       }
+
+       protected AbstractCOptionPage(String title, ImageDescriptor image) {
+               super(title, image);
+       }
+
+       public void setContainer(ICOptionContainer container) {
+               fContainer = container;
+       }
+       
+       protected ICOptionContainer getContainer() {
+               return fContainer;
+       }
+
+       protected void setValid(boolean isValid) {
+               bIsValid = isValid;
+       }
+       
+       public boolean isValid() {
+               return bIsValid;
+       }
+
+       public abstract void performApply(IProgressMonitor monitor) throws CoreException;
+
+       public abstract void performDefaults();
+       
+       public abstract void createControl(Composite parent);
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractErrorParserBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractErrorParserBlock.java
new file mode 100644 (file)
index 0000000..1b63765
--- /dev/null
@@ -0,0 +1,322 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.dialogs;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.ErrorParserManager;
+import org.eclipse.cdt.internal.ui.CUIMessages;
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.CheckedListDialogField;
+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.ui.CUIPlugin;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.PlatformUI;
+
+public abstract class AbstractErrorParserBlock extends AbstractCOptionPage {
+       private static final String PREFIX = "ErrorParserBlock"; //$NON-NLS-1$
+       private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
+       private static final String DESC = PREFIX + ".desc"; //$NON-NLS-1$
+
+       private static String[] EMPTY = new String[0];
+       private Preferences fPrefs;
+       protected HashMap<String, String> mapParsers = new HashMap<String, String>();
+       private CheckedListDialogField<String> fErrorParserList;
+       protected boolean listDirty = false;
+
+       class FieldListenerAdapter implements IDialogFieldListener {
+
+               /*
+                * (non-Javadoc)
+                * 
+                * @see org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener#dialogFieldChanged(org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField)
+                */
+               public void dialogFieldChanged(DialogField field) {
+                       listDirty = true;
+               }
+
+       }
+
+       /**
+        * @deprecated - use AbstractErrorParserBlock(), preferences setting should
+        *             now be handled by extending classes, use
+        *             setErrorParserIDs(boolean)/saveErrorParserIDs() to handle
+        *             getting/setting of values.
+        * 
+        * @param prefs
+        */
+       @Deprecated
+       public AbstractErrorParserBlock(Preferences prefs) {
+               this();
+//             usingDeprecatedContructor = true;
+               fPrefs = prefs;
+       }
+
+       public AbstractErrorParserBlock() {
+               super(CUIPlugin.getResourceString(LABEL));
+               setDescription(CUIPlugin.getResourceString(DESC));
+       }
+
+       @Override
+       public Image getImage() {
+               return null;
+       }
+
+       public void updateValues() {
+               fErrorParserList.removeAllElements();
+               setValues();
+       }
+
+       /**
+        * Returns a label provider for the error parsers
+        * 
+        * @return the content provider
+        */
+       protected ILabelProvider getLabelProvider() {
+               return new LabelProvider() {
+
+                       /*
+                        * (non-Javadoc)
+                        * 
+                        * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
+                        */
+                       @Override
+                       public String getText(Object element) {
+                               String name = mapParsers.get(element.toString());
+                               return name != null ? name : element.toString(); 
+                       }
+               };
+       }
+
+       protected FieldListenerAdapter getFieldListenerAdapter() {
+               return new FieldListenerAdapter();
+       }
+
+       protected String[] getErrorParserIDs(boolean defaults) {
+               String parserIDs = null;
+               if (fPrefs != null) {
+                       if (defaults == true) {
+                               parserIDs = fPrefs.getDefaultString(ErrorParserManager.PREF_ERROR_PARSER);
+                       } else {
+                               parserIDs = fPrefs.getString(ErrorParserManager.PREF_ERROR_PARSER);
+                       }
+               } else {
+                       return getErrorParserIDs();
+               }
+               String[] empty = new String[0];
+               if (parserIDs != null && parserIDs.length() > 0) {
+                       StringTokenizer tok = new StringTokenizer(parserIDs, ";"); //$NON-NLS-1$
+                       List<String> list = new ArrayList<String>(tok.countTokens());
+                       while (tok.hasMoreElements()) {
+                               list.add(tok.nextToken());
+                       }
+                       return list.toArray(empty);
+               }
+               return empty;
+       }
+
+       /**
+        * To be implemented, abstract method.
+        * 
+        * @param project
+        * @return String[]
+        */
+       protected abstract String[] getErrorParserIDs(IProject project);
+
+       /**
+        * To be overloaded by subclasses with another method of getting the error
+        * parsers. For example, the managed builder new project wizard uses the
+        * selected Target.
+        *  @deprecated - use getErrorParserIDs(boolean defaults)
+        * @return String[]
+        */
+       @Deprecated
+       protected String[] getErrorParserIDs() {
+               return new String[0];
+       }
+
+       /**
+        * To be implemented. abstract method.
+        */
+       protected abstract void saveErrorParsers(IProject project, String[] parserIDs) throws CoreException;
+
+       /**
+        * @deprecated - use saveErrorParser(String[])
+        * @param prefs
+        * @param parserIDs
+        */
+
+       @Deprecated
+       protected void saveErrorParsers(Preferences prefs, String[] parserIDs) {
+               StringBuffer buf = new StringBuffer();
+               for (int i = 0; i < parserIDs.length; i++) {
+                       buf.append(parserIDs[i]).append(';');
+               }
+               prefs.setValue(ErrorParserManager.PREF_ERROR_PARSER, buf.toString());
+       }
+
+       protected void saveErrorParsers(String[] parserIDs) throws CoreException {
+               saveErrorParsers(fPrefs, parserIDs);
+       }
+
+       protected void initMapParsers() {
+               mapParsers.clear();
+               IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID,
+                               CCorePlugin.ERROR_PARSER_SIMPLE_ID);
+               if (point != null) {
+                       IExtension[] exts = point.getExtensions();
+                       for (int i = 0; i < exts.length; i++) {
+                               if (exts[i].getConfigurationElements().length > 0) {
+                                       mapParsers.put(exts[i].getUniqueIdentifier(), exts[i].getLabel());
+                               }
+                       }
+               }
+       }
+
+       protected void initializeValues() {
+               initMapParsers();
+               setValues();
+       }
+
+       protected void setDefaults() {
+               String[] parserIDs;
+               IProject project = getContainer().getProject();
+               if (project == null) {
+                       // From a Preference.
+                       parserIDs = getErrorParserIDs(true);
+               } else {
+                       parserIDs = getErrorParserIDs(false);
+               }
+               updateListControl(parserIDs);
+       }
+
+       protected void setValues() {
+               String[] parserIDs;
+               IProject project = getContainer().getProject();
+               if (project == null) {
+                       parserIDs = getErrorParserIDs(false);
+               } else {
+                       // From the Project.
+                       parserIDs = getErrorParserIDs(project);
+               }
+               updateListControl(parserIDs);
+       }
+
+       protected void updateListControl(String[] parserIDs) {
+               List<String> checkedList = Arrays.asList(parserIDs);
+               fErrorParserList.setElements(checkedList);
+               fErrorParserList.setCheckedElements(checkedList);
+               if (checkedList.size() > 0) {
+                       fErrorParserList.getTableViewer().setSelection(new StructuredSelection(checkedList.get(0)), true);
+               }
+               Iterator<String> items = mapParsers.keySet().iterator();
+               while (items.hasNext()) {
+                       String item = items.next();
+                       boolean found = false;
+                       for (int i = 0; i < parserIDs.length; i++) {
+                               if (item.equals(parserIDs[i])) {
+                                       found = true;
+                                       break;
+                               }
+                       }
+                       if (!found) {
+                               fErrorParserList.addElement(item);
+                       }
+               }
+       }
+
+       @Override
+       public void createControl(Composite parent) {
+               Composite composite = new Composite(parent, SWT.NONE);
+               setControl(composite);
+
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.ERROR_PARSERS_PAGE);
+
+               String[] buttonLabels = new String[]{
+               CUIMessages.AbstractErrorParserBlock_label_up, 
+                               CUIMessages.AbstractErrorParserBlock_label_down, 
+                               /* 2 */
+                               null,
+                               CUIMessages.AbstractErrorParserBlock_label_selectAll, 
+                               CUIMessages.AbstractErrorParserBlock_label_unselectAll
+               };
+
+               fErrorParserList = new CheckedListDialogField<String>(null, buttonLabels, getLabelProvider());
+               fErrorParserList.setDialogFieldListener(getFieldListenerAdapter());
+               fErrorParserList.setLabelText(CUIMessages.AbstractErrorParserBlock_label_errorParsers); 
+               fErrorParserList.setUpButtonIndex(0);
+               fErrorParserList.setDownButtonIndex(1);
+               fErrorParserList.setCheckAllButtonIndex(3);
+               fErrorParserList.setUncheckAllButtonIndex(4);
+
+               LayoutUtil.doDefaultLayout(composite, new DialogField[]{fErrorParserList}, true);
+               LayoutUtil.setHorizontalGrabbing(fErrorParserList.getListControl(null), true);
+
+               initializeValues();
+       }
+
+       @Override
+       public void performApply(IProgressMonitor monitor) throws CoreException {
+               if (listDirty) {
+                       IProject project = getContainer().getProject();
+                       if (monitor == null) {
+                               monitor = new NullProgressMonitor();
+                       }
+                       monitor.beginTask(CUIMessages.AbstractErrorParserBlock_task_setErrorParser, 1); 
+                       List<String> elements = fErrorParserList.getElements();
+                       int count = elements.size();
+                       List<Object> list = new ArrayList<Object>(count);
+                       for (int i = 0; i < count; i++) {
+                               Object obj = elements.get(i);
+                               if (fErrorParserList.isChecked(obj)) {
+                                       list.add(obj);
+                               }
+                       }
+
+                       String[] parserIDs = list.toArray(EMPTY);
+
+                       if (project == null) {
+                               //  Save to preferences
+                               saveErrorParsers(parserIDs);
+                       } else {
+                               saveErrorParsers(project, parserIDs);
+                       }
+                       monitor.worked(1);
+                       monitor.done();
+               }
+       }
+
+       @Override
+       public void performDefaults() {
+               setDefaults();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractGNUBinaryParserPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractGNUBinaryParserPage.java
new file mode 100644 (file)
index 0000000..cead283
--- /dev/null
@@ -0,0 +1,280 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui.dialogs;
+
+import java.io.File;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+
+import org.eclipse.cdt.internal.ui.CUIMessages;
+
+/**
+ * Abstract base binary parser page for GNU binutils based binary parsers
+ */
+public abstract class AbstractGNUBinaryParserPage extends AbstractCOptionPage {
+
+       public final static String PREF_ADDR2LINE_PATH = CUIPlugin.PLUGIN_ID + ".addr2line"; //$NON-NLS-1$
+       public final static String PREF_CPPFILT_PATH = CUIPlugin.PLUGIN_ID + ".cppfilt"; //$NON-NLS-1$
+
+       protected Text fAddr2LineCommandText;
+       protected Text fCPPFiltCommandText;
+       private String parserID = null;
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
+        */
+       @Override
+       public void performApply(IProgressMonitor monitor) throws CoreException {
+               if (monitor == null) {
+                       monitor = new NullProgressMonitor();
+               }
+
+               String addr2line = fAddr2LineCommandText.getText().trim();
+               String cppfilt = fCPPFiltCommandText.getText().trim();
+
+               monitor.beginTask(CUIMessages.BinaryParserPage_task_savingAttributes, 1); 
+               IProject proj = getContainer().getProject();
+               if (proj != null) {
+                       ICConfigExtensionReference[] cext = null;
+                       ICProjectDescription desc = CCorePlugin.getDefault().getProjectDescription(proj, true);
+                       if (desc != null) {
+                               ICConfigurationDescription cfgDesc = desc.getDefaultSettingConfiguration();
+                               if (cfgDesc != null) {
+                                       cext = cfgDesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID);
+                               }
+                       }
+                       if (cext != null && cext.length > 0) {
+                               initializeParserId();
+                               for (int i = 0; i < cext.length; i++) {
+                                       if (cext[i].getID().equals(parserID)) {
+                                               String orig = cext[i].getExtensionData("addr2line"); //$NON-NLS-1$
+                                               if (orig == null || !orig.equals(addr2line)) {
+                                                       cext[i].setExtensionData("addr2line", addr2line); //$NON-NLS-1$
+                                               }
+                                               orig = cext[i].getExtensionData("c++filt"); //$NON-NLS-1$
+                                               if (orig == null || !orig.equals(cppfilt)) {
+                                                       cext[i].setExtensionData("c++filt", cppfilt); //$NON-NLS-1$
+                                               }
+                                       }
+                               }
+                               CCorePlugin.getDefault().setProjectDescription(proj, desc);
+                       }
+               } else {
+                       Preferences store = getContainer().getPreferences();
+                       if (store != null) {
+                               store.setValue(PREF_ADDR2LINE_PATH, addr2line);
+                               store.setValue(PREF_CPPFILT_PATH, cppfilt);
+                       }
+               }
+       }
+
+       private void initializeParserId() {
+               if (parserID == null) {
+                       IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID, "BinaryParserPage"); //$NON-NLS-1$
+                       IConfigurationElement[] infos = point.getConfigurationElements();
+                       for (int i = 0; i < infos.length; i++) {
+                               String id = infos[i].getAttribute("parserID"); //$NON-NLS-1$
+                               String clazz = infos[i].getAttribute("class"); //$NON-NLS-1$
+                               String ego = getRealBinaryParserPage().getClass().getName();
+                               if (clazz != null && clazz.equals(ego)) {
+                                       parserID = id;
+                                       return;
+                               }
+                       }
+                       parserID = "";  //$NON-NLS-1$
+               }
+       }
+
+       /**
+        * If this class is inherited from then this method MUST be implemented
+        * in the derived class.
+        */
+       abstract protected AbstractGNUBinaryParserPage getRealBinaryParserPage();
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
+        */
+       @Override
+       public void performDefaults() {
+               String addr2line = null;
+               String cppfilt = null;
+               IProject proj = getContainer().getProject();
+               Preferences store = getContainer().getPreferences();
+               if (store != null) {
+                       if (proj != null) {
+                               addr2line = store.getString(PREF_ADDR2LINE_PATH);
+                               cppfilt = store.getString(PREF_CPPFILT_PATH);
+                       } else {
+                               addr2line = store.getDefaultString(PREF_ADDR2LINE_PATH);
+                               cppfilt = store.getDefaultString(PREF_CPPFILT_PATH);
+                       }
+                       fAddr2LineCommandText.setText((addr2line == null || addr2line.length() == 0) ? "addr2line" : addr2line); //$NON-NLS-1$
+                       fCPPFiltCommandText.setText((cppfilt == null || cppfilt.length() == 0) ? "c++filt" : cppfilt); //$NON-NLS-1$
+               }
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       public void createControl(Composite parent) {
+               Group comp = new Group(parent, SWT.SHADOW_ETCHED_IN);
+               comp.setText(CUIMessages.BinaryParserBlock_binaryParserOptions); 
+               comp.setLayout(new GridLayout(2, true));
+               comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               ((GridLayout) comp.getLayout()).makeColumnsEqualWidth = false;
+               
+               Label label = ControlFactory.createLabel(comp, CUIMessages.BinaryParserPage_label_addr2lineCommand); 
+               GridData gd = new GridData();
+               gd.horizontalSpan = 2;
+               label.setLayoutData(gd);
+
+               fAddr2LineCommandText = ControlFactory.createTextField(comp, SWT.SINGLE | SWT.BORDER);
+               fAddr2LineCommandText.addModifyListener(new ModifyListener() {
+
+                       public void modifyText(ModifyEvent evt) {
+                               //updateLaunchConfigurationDialog();
+                       }
+               });
+
+               Button button = ControlFactory.createPushButton(comp, CUIMessages.BinaryParserPage_label_browse); 
+               button.addSelectionListener(new SelectionAdapter() {
+
+                       @Override
+                       public void widgetSelected(SelectionEvent evt) {
+                               handleAddr2LineButtonSelected();
+                               //updateLaunchConfigurationDialog();
+                       }
+
+                       private void handleAddr2LineButtonSelected() {
+                               FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
+                               dialog.setText(CUIMessages.BinaryParserPage_label_addr2lineCommand); 
+                               String command = fAddr2LineCommandText.getText().trim();
+                               int lastSeparatorIndex = command.lastIndexOf(File.separator);
+                               if (lastSeparatorIndex != -1) {
+                                       dialog.setFilterPath(command.substring(0, lastSeparatorIndex));
+                               }
+                               String res = dialog.open();
+                               if (res == null) {
+                                       return;
+                               }
+                               fAddr2LineCommandText.setText(res);
+                       }
+               });
+
+               label = ControlFactory.createLabel(comp, CUIMessages.BinaryParserPage_label_cppfiltCommand); 
+               gd = new GridData();
+               gd.horizontalSpan = 2;
+               label.setLayoutData(gd);
+
+               fCPPFiltCommandText = ControlFactory.createTextField(comp, SWT.SINGLE | SWT.BORDER);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               fCPPFiltCommandText.setLayoutData(gd);
+               fCPPFiltCommandText.addModifyListener(new ModifyListener() {
+
+                       public void modifyText(ModifyEvent evt) {
+                               //updateLaunchConfigurationDialog();
+                       }
+               });
+               button = ControlFactory.createPushButton(comp, CUIMessages.BinaryParserPage_label_browse1); 
+               button.addSelectionListener(new SelectionAdapter() {
+
+                       @Override
+                       public void widgetSelected(SelectionEvent evt) {
+                               handleCPPFiltButtonSelected();
+                               //updateLaunchConfigurationDialog();
+                       }
+
+                       private void handleCPPFiltButtonSelected() {
+                               FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
+                               dialog.setText(CUIMessages.BinaryParserPage_label_cppfiltCommand); 
+                               String command = fCPPFiltCommandText.getText().trim();
+                               int lastSeparatorIndex = command.lastIndexOf(File.separator);
+                               if (lastSeparatorIndex != -1) {
+                                       dialog.setFilterPath(command.substring(0, lastSeparatorIndex));
+                               }
+                               String res = dialog.open();
+                               if (res == null) {
+                                       return;
+                               }
+                               fCPPFiltCommandText.setText(res);
+                       }
+               });
+
+               setControl(comp);
+               initialziedValues();
+       }
+       
+       private void initialziedValues() {
+               String addr2line = null;
+               String cppfilt = null;
+               IProject proj = getContainer().getProject();
+               if (proj != null) {
+                       try {
+                               ICConfigExtensionReference[] cext = CCorePlugin.getDefault().getDefaultBinaryParserExtensions(proj);
+                               if (cext.length > 0) {
+                                       initializeParserId();
+                                       for (int i = 0; i < cext.length; i++) {
+                                               if (cext[i].getID().equals(parserID)) {
+                                                       addr2line = cext[0].getExtensionData("addr2line"); //$NON-NLS-1$
+                                                       cppfilt = cext[0].getExtensionData("c++filt"); //$NON-NLS-1$
+                                                       break;
+                                               }
+                                       }
+                               }
+                       } catch (CoreException e) {
+                       }
+               } else {
+                       Preferences store = getContainer().getPreferences();
+                       if (store != null) {
+                               addr2line = store.getString(PREF_ADDR2LINE_PATH);
+                               cppfilt = store.getString(PREF_CPPFILT_PATH);
+                       }
+               }
+               fAddr2LineCommandText.setText((addr2line == null || addr2line.length() == 0) ? "addr2line" : addr2line); //$NON-NLS-1$
+               fCPPFiltCommandText.setText((cppfilt == null || cppfilt.length() == 0) ? "c++filt" : cppfilt); //$NON-NLS-1$
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractIndexerPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractIndexerPage.java
new file mode 100644 (file)
index 0000000..37e9e1f
--- /dev/null
@@ -0,0 +1,364 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Bogdan Gheorghe (IBM) - Initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.dialogs;
+
+import java.util.Properties;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.jface.preference.IntegerFieldEditor;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+
+import org.eclipse.cdt.internal.core.model.CProject;
+import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
+
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
+
+/**
+ * Configuration for indexer.
+ */
+public abstract class AbstractIndexerPage extends AbstractCOptionPage {
+       protected static final String INDEX_ALL_FILES = DialogsMessages.AbstractIndexerPage_indexAllFiles;
+       protected static final String TRUE = String.valueOf(true);
+
+       private Button fAllSources;
+       private Button fAllHeadersDefault;
+       private Button fAllHeadersAlt;
+       private Button fIndexOnOpen;
+       private Button fIncludeHeuristics;
+       private IntegerFieldEditor fFileSizeLimit;
+       private Text fFilesToParseUpFront;
+       private Button fSkipReferences;
+       private Button fSkipImplicitReferences;
+       private Button fSkipMacroAndTypeReferences;
+
+    private IPropertyChangeListener validityChangeListener = new IPropertyChangeListener() {
+        public void propertyChange(PropertyChangeEvent event) {
+            if (event.getProperty().equals(FieldEditor.IS_VALID)) {
+                               updateValidState();
+                       }
+        }
+    };
+       /** @since 5.3 */
+       protected PixelConverter pixelConverter;
+
+       protected AbstractIndexerPage() {
+               super();
+       }
+
+       final public IProject getCurrentProject() {
+               ICOptionContainer container = getContainer();
+               if (container != null) {
+                       return container.getProject();
+               }
+               return null;
+       }
+
+       @Override
+       public void createControl(Composite parent) {
+       pixelConverter = new PixelConverter(parent);
+               GridLayout gl;
+               Composite page = new Composite(parent, SWT.NULL);
+               page.setFont(parent.getFont());
+               page.setLayout(gl= new GridLayout(1, true));
+               gl.marginHeight = 0;
+               gl.marginWidth = 0;
+               page.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               Composite group= new Composite(page, SWT.NONE);
+               
+               fAllSources= createAllFilesButton(group);
+               IProject prj= getCurrentProject();
+               if (prj == null || !CProject.hasCCNature(prj)) {
+                       fAllHeadersDefault= createAllHeadersButton(group);
+               } else {
+                       fAllHeadersDefault= createAllCppHeadersButton(group);
+                       fAllHeadersAlt= createAllCHeadersButton(group);
+               }
+               fIndexOnOpen= createIndexOnOpenButton(group);
+
+               fIncludeHeuristics= createIncludeHeuristicsButton(group);
+               fFileSizeLimit= createFileSizeLimit(group);
+
+               group.setLayout(gl= new GridLayout(3, false));
+               gl.marginHeight = 0;
+               gl.marginWidth= 0;
+               group.setLayoutData(new GridData());
+
+               group= new Composite(page, SWT.NONE);
+               group.setLayout(gl= new GridLayout(1, false));
+               gl.marginHeight = 0;
+               gl.marginWidth= 0;
+               group.setLayoutData(new GridData());
+               fSkipReferences= createSkipReferencesButton(group);
+               fSkipImplicitReferences= createSkipImplicitReferencesButton(group);
+               fSkipMacroAndTypeReferences= createSkipMacroAndTypeReferencesButton(group);
+               
+               fFilesToParseUpFront= createParseUpFrontTextField(page);
+               
+               final SelectionAdapter selectionListener = new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               updateEnablement();
+                       }
+               };
+               fSkipReferences.addSelectionListener(selectionListener);
+               fAllSources.addSelectionListener(selectionListener);
+               setControl(page);
+       }
+
+       /**
+        * Use the properties to initialize the controls of the page. Fill in defaults 
+        * for properties that are missing.
+        * @since 4.0
+        */
+       public void setProperties(Properties properties) {
+               if (fAllSources != null) {
+                       boolean indexAllFiles= TRUE.equals(properties.get(IndexerPreferences.KEY_INDEX_ALL_FILES));
+                       fAllSources.setSelection(indexAllFiles);
+               }
+               if (fAllHeadersDefault != null) {
+                       boolean indexAllFiles= TRUE.equals(properties.get(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG));
+                       fAllHeadersDefault.setSelection(indexAllFiles);
+               }
+               if (fAllHeadersAlt != null) {
+                       boolean indexAllFiles= TRUE.equals(properties.get(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_ALTERNATE_LANG));
+                       fAllHeadersAlt.setSelection(indexAllFiles);
+               }
+               if (fIndexOnOpen != null) {
+                       boolean indexOnOpen= TRUE.equals(properties.get(IndexerPreferences.KEY_INDEX_ON_OPEN));
+                       fIndexOnOpen.setSelection(indexOnOpen);
+               }
+               if (fIncludeHeuristics != null) {
+                       Object prop= properties.get(IndexerPreferences.KEY_INCLUDE_HEURISTICS);
+                       boolean use= prop == null || TRUE.equals(prop);
+                       fIncludeHeuristics.setSelection(use);
+               }
+               if (fFileSizeLimit != null) {
+                       Object prop= properties.get(IndexerPreferences.KEY_SKIP_FILES_LARGER_THAN_MB);
+                       int size= 0;
+                       if (prop != null) {
+                               try {
+                                       size= Integer.parseInt(prop.toString());
+                               } catch (NumberFormatException e) {
+                               }
+                       }
+                       if (size <= 0) {
+                               size= IndexerPreferences.DEFAULT_FILE_SIZE_LIMIT;
+                       }
+                       fFileSizeLimit.setStringValue(String.valueOf(size));
+               }
+               if (fSkipReferences != null) {
+                       boolean skipReferences= TRUE.equals(properties.get(IndexerPreferences.KEY_SKIP_ALL_REFERENCES));
+                       fSkipReferences.setSelection(skipReferences);
+               }
+               if (fSkipImplicitReferences != null) {
+                       boolean skipImplicitReferences= TRUE.equals(properties.get(IndexerPreferences.KEY_SKIP_IMPLICIT_REFERENCES));
+                       fSkipImplicitReferences.setSelection(skipImplicitReferences);
+               }               
+               if (fSkipMacroAndTypeReferences != null) {
+                       boolean skipTypeReferences= TRUE.equals(properties.get(IndexerPreferences.KEY_SKIP_TYPE_REFERENCES));
+                       boolean skipMacroReferences= TRUE.equals(properties.get(IndexerPreferences.KEY_SKIP_MACRO_REFERENCES));
+                       fSkipMacroAndTypeReferences.setSelection(skipTypeReferences && skipMacroReferences);
+               }               
+               if (fFilesToParseUpFront != null) {
+                       String files = getNotNull(properties, IndexerPreferences.KEY_FILES_TO_PARSE_UP_FRONT);
+                       fFilesToParseUpFront.setText(files);
+               }
+               updateEnablement();
+       }
+
+       /**
+        * Return the properties according to the selections on the page.
+        * @since 4.0
+        */
+       public Properties getProperties(){
+               Properties props= new Properties();
+               if (fAllSources != null) {
+                       props.put(IndexerPreferences.KEY_INDEX_ALL_FILES, String.valueOf(fAllSources.getSelection()));
+               }
+               if (fAllHeadersDefault != null) {
+                       props.put(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_DEFAULT_LANG, String.valueOf(fAllHeadersDefault.getSelection()));
+               }
+               if (fAllHeadersAlt != null) {
+                       props.put(IndexerPreferences.KEY_INDEX_UNUSED_HEADERS_WITH_ALTERNATE_LANG, String.valueOf(fAllHeadersAlt.getSelection()));
+               }
+               if (fIndexOnOpen != null) {
+                       props.put(IndexerPreferences.KEY_INDEX_ON_OPEN, String.valueOf(fIndexOnOpen.getSelection()));
+               }
+               if (fIncludeHeuristics != null) {
+                       props.put(IndexerPreferences.KEY_INCLUDE_HEURISTICS, String.valueOf(fIncludeHeuristics.getSelection()));
+               }
+               if (fFileSizeLimit != null) {
+                       props.put(IndexerPreferences.KEY_SKIP_FILES_LARGER_THAN_MB, String.valueOf(fFileSizeLimit.getIntValue()));
+               }
+               if (fFilesToParseUpFront != null) {
+                       props.put(IndexerPreferences.KEY_FILES_TO_PARSE_UP_FRONT, fFilesToParseUpFront.getText());
+               }
+               if (fSkipReferences != null) {
+                       props.put(IndexerPreferences.KEY_SKIP_ALL_REFERENCES, String.valueOf(fSkipReferences.getSelection()));
+               }
+               if (fSkipImplicitReferences != null) {
+                       props.put(IndexerPreferences.KEY_SKIP_IMPLICIT_REFERENCES, String.valueOf(fSkipImplicitReferences.getSelection()));
+               }
+               if (fSkipMacroAndTypeReferences != null) {
+                       final String value = String.valueOf(fSkipMacroAndTypeReferences.getSelection());
+                       props.put(IndexerPreferences.KEY_SKIP_TYPE_REFERENCES, value);
+                       props.put(IndexerPreferences.KEY_SKIP_MACRO_REFERENCES, value);
+               }
+               return props;
+       }
+
+       /**
+        * {@link #getProperties()} will be called instead.
+        */
+       @Override
+       final public void performApply(IProgressMonitor monitor) {
+               throw new UnsupportedOperationException();
+       }
+
+       /**
+        * {@link #setProperties(Properties)} will be called instead.
+        */
+       @Override
+       final public void performDefaults() {
+               throw new UnsupportedOperationException();
+       }
+
+       public void updateEnablement() {
+               if (fSkipReferences != null) {
+                       final boolean skipReferences = fSkipReferences.getSelection();
+                       if (fSkipImplicitReferences != null) {
+                               fSkipImplicitReferences.setEnabled(!skipReferences);
+                       }
+                       if (fSkipMacroAndTypeReferences != null) {
+                               fSkipMacroAndTypeReferences.setEnabled(!skipReferences);
+                       }
+               }
+       }
+       
+    private void updateValidState() {
+       if (!fFileSizeLimit.isValid()) {
+               setErrorMessage(fFileSizeLimit.getErrorMessage());
+               setValid(false);
+               } else {
+               setValid(true);
+       }
+        final ICOptionContainer container = getContainer();
+        if (container != null) {
+               container.updateContainer();
+        }
+    }
+    
+       private String getNotNull(Properties properties, String key) {
+               String files= (String) properties.get(key);
+               if (files == null) {
+                       files= ""; //$NON-NLS-1$
+               }
+               return files;
+       }
+
+       private Text createParseUpFrontTextField(Composite page) {
+               Label l= ControlFactory.createLabel(page, DialogsMessages.AbstractIndexerPage_indexUpFront);
+               ((GridData) l.getLayoutData()).verticalIndent= 5;
+               return ControlFactory.createTextField(page);
+       } 
+
+       private Button createAllFilesButton(Composite page) {
+               Button result= ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_indexAllFiles);
+               ((GridData) result.getLayoutData()).horizontalSpan= 3;
+               return result;
+       }
+
+       private Button createAllHeadersButton(Composite page) {
+               Button result= ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_indexAllHeaders);
+               ((GridData) result.getLayoutData()).horizontalSpan= 3;
+               return result;
+       }
+
+       private Button createAllCHeadersButton(Composite page) {
+               Button result= ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_indexAllHeadersC);
+               ((GridData) result.getLayoutData()).horizontalSpan= 3;
+               return result;
+       }
+
+       private Button createAllCppHeadersButton(Composite page) {
+               Button result= ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_indexAllHeadersCpp);
+               ((GridData) result.getLayoutData()).horizontalSpan= 3;
+               return result;
+       }
+
+       private Button createIndexOnOpenButton(Composite page) {
+               Button result= ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_indexOpenedFiles);
+               ((GridData) result.getLayoutData()).horizontalSpan= 3;
+               return result;
+       }
+
+       private Button createIncludeHeuristicsButton(Composite page) {
+               Button result= ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_heuristicIncludes);
+               ((GridData) result.getLayoutData()).horizontalSpan= 3;
+               return result;
+       }
+       
+       private IntegerFieldEditor createFileSizeLimit(Composite group) {
+               IntegerFieldEditor result= new IntegerFieldEditor(IndexerPreferences.KEY_SKIP_FILES_LARGER_THAN_MB, DialogsMessages.AbstractIndexerPage_fileSizeLimit, group, 5);
+               result.setValidRange(1, 100000);
+               ControlFactory.createLabel(group, DialogsMessages.CacheSizeBlock_MB); 
+               Text control = result.getTextControl(group);
+               LayoutUtil.setWidthHint(control, pixelConverter.convertWidthInCharsToPixels(10));
+               LayoutUtil.setHorizontalGrabbing(control, false); 
+
+               result.setPropertyChangeListener(validityChangeListener);
+               return result;
+       }
+
+       private Button createSkipReferencesButton(Composite page) {
+               return ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_skipAllReferences);
+       }
+
+       private Button createSkipImplicitReferencesButton(Composite page) {
+               return ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_skipImplicitReferences);
+       }
+
+       private Button createSkipMacroAndTypeReferencesButton(Composite page) {
+               return ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_skipTypeAndMacroReferences);
+       }
+       
+       /**
+        * Enable or disable support for parsing files up front. Essentially the according widget will be 
+        * enabled or disabled.
+        * There will be no effect by calling this function before the IndexerPage is created 
+        * (by {@link #createControl(Composite)}). 
+        * <p> By default, support for parsing files up front is enabled.
+        * 
+        * @since 5.3
+        */
+       protected void setSupportForFilesParsedUpFront(boolean enable){
+               if(fFilesToParseUpFront!=null){
+                       fFilesToParseUpFront.setEnabled(enable);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/BinaryParserBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/BinaryParserBlock.java
new file mode 100644 (file)
index 0000000..2914de9
--- /dev/null
@@ -0,0 +1,410 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.dialogs;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.ICDescriptor;
+import org.eclipse.cdt.core.ICDescriptorOperation;
+import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+
+import org.eclipse.cdt.internal.ui.CUIMessages;
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.CheckedListDialogField;
+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.IListAdapter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
+
+/**
+ * @deprecated as of CDT 4.0. This tab was used to set preferences/properties
+ * for 3.X style projects.
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+@Deprecated
+public class BinaryParserBlock extends AbstractBinaryParserPage {
+       private static final int DEFAULT_HEIGHT = 160;
+       private static final String PREFIX = "BinaryParserBlock"; //$NON-NLS-1$
+       private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
+       private static final String DESC = PREFIX + ".desc"; //$NON-NLS-1$
+
+       private static final String ATTR_FILTER = "filter"; //$NON-NLS-1$
+       private static final String ATTR_NAME = "name"; //$NON-NLS-1$
+       private static final String ATTR_NAME_VISIBILITY = "visibility"; //$NON-NLS-1$
+       private static final String ATTR_VALUE = "value"; //$NON-NLS-1$
+       private static final String ATTR_VALUE_PRIVATE = "private"; //$NON-NLS-1$
+
+       protected CheckedListDialogField<BinaryParserConfiguration> binaryList;
+       protected Map<String, BinaryParserConfiguration> configMap;
+       protected List<BinaryParserConfiguration> initialSelected;
+
+       protected class BinaryParserConfiguration {
+               IExtension fExtension;
+
+               public BinaryParserConfiguration(IExtension extension) {
+                       fExtension = extension;
+               }
+
+               public String getID() {
+                       return fExtension.getUniqueIdentifier();
+               }
+
+               public String getName() {
+                       return fExtension.getLabel();
+               }
+
+               @Override
+               public String toString() {
+                       return fExtension.getUniqueIdentifier();
+               }
+
+               @Override
+               public boolean equals(Object obj) {
+                       if (obj instanceof BinaryParserConfiguration) {
+                               return this.getID().equals(((BinaryParserConfiguration) obj).getID());
+                       }
+                       return super.equals(obj);
+               }
+       }
+
+       protected class BinaryParserLabelProvider extends LabelProvider {
+               @Override
+               public String getText(Object element) {
+                       return ((BinaryParserConfiguration) element).getName();
+               }
+       }
+
+       public BinaryParserBlock() {
+               super(CUIPlugin.getResourceString(LABEL));
+               setDescription(CUIPlugin.getResourceString(DESC));
+               String[] buttonLabels = new String[]{
+               CUIMessages.BinaryParserBlock_button_up, 
+                               CUIMessages.BinaryParserBlock_button_down}; 
+
+               IListAdapter<BinaryParserConfiguration> listAdapter = new IListAdapter<BinaryParserConfiguration>() {
+
+                       public void customButtonPressed(ListDialogField<BinaryParserConfiguration> field, int index) {
+                       }
+
+                       public void selectionChanged(ListDialogField<BinaryParserConfiguration> field) {
+                               handleBinaryParserChanged();
+                       }
+
+                       public void doubleClicked(ListDialogField<BinaryParserConfiguration> field) {
+                       }
+               };
+
+               binaryList = new CheckedListDialogField<BinaryParserConfiguration>(listAdapter, buttonLabels, new BinaryParserLabelProvider()) {
+
+                       @Override
+                       protected int getListStyle() {
+                               int style = super.getListStyle();
+                               return style & ~SWT.MULTI;
+                       }
+               };
+               binaryList.setDialogFieldListener(new IDialogFieldListener() {
+
+                       public void dialogFieldChanged(DialogField field) {
+                               if (getContainer() != null) {
+                                       getContainer().updateContainer();
+                                       handleBinaryParserChanged();
+                               }
+                       }
+               });
+               binaryList.setLabelText(CUIMessages.BinaryParserBlock_binaryParser); 
+               binaryList.setUpButtonIndex(0);
+               binaryList.setDownButtonIndex(1);
+               initializeParserList();
+       }
+
+       private void initializeParserList() {
+               IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, CCorePlugin.BINARY_PARSER_SIMPLE_ID);
+               if (point != null) {
+                       IExtension[] exts = point.getExtensions();
+                       configMap = new HashMap<String, BinaryParserConfiguration>(exts.length);
+                       for (IExtension ext : exts) {
+                               if (isExtensionVisible(ext)) {
+                                       configMap.put(ext.getUniqueIdentifier(), new BinaryParserConfiguration(ext));
+                               }
+                       }
+               }
+       }
+
+       private boolean isExtensionVisible(IExtension ext) {
+               IConfigurationElement[] elements = ext.getConfigurationElements();
+               for (IConfigurationElement element : elements) {
+                       IConfigurationElement[] children = element.getChildren(ATTR_FILTER);
+                       for (IConfigurationElement element2 : children) {
+                               String name = element2.getAttribute(ATTR_NAME);
+                               if (name != null && name.equals(ATTR_NAME_VISIBILITY)) {
+                                       String value = element2.getAttribute(ATTR_VALUE);
+                                       if (value != null && value.equals(ATTR_VALUE_PRIVATE)) {
+                                               return false;
+                                       }
+                               }
+                       }
+                       return true;
+               }
+               return false; // invalid extension definition (must have at least cextension elements)
+       }
+
+       @Override
+       public void createControl(Composite parent) {
+               PixelConverter converter = new PixelConverter(parent);
+
+               Composite composite = ControlFactory.createComposite(parent, 1);
+               ((GridData) (composite.getLayoutData())).horizontalAlignment = GridData.FILL_HORIZONTAL;
+               setControl(composite);
+
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.BINARY_PARSER_PAGE);
+
+               Composite listComposite = ControlFactory.createComposite(composite, 1);
+               LayoutUtil.doDefaultLayout(listComposite, new DialogField[]{binaryList}, true);
+               LayoutUtil.setHorizontalGrabbing(binaryList.getListControl(null), true);
+
+               int buttonBarWidth = converter.convertWidthInCharsToPixels(15);
+               binaryList.setButtonsMinWidth(buttonBarWidth);
+
+               // Add the Parser UI contribution.
+               
+               Composite parserGroup = new Composite(composite, SWT.NULL);
+               
+               GridData gd = new GridData();
+               gd.heightHint = converter.convertHorizontalDLUsToPixels(DEFAULT_HEIGHT);
+               gd.horizontalAlignment = GridData.FILL;
+               gd.grabExcessHorizontalSpace = true;
+               gd.grabExcessVerticalSpace = true;
+               parserGroup.setLayoutData(gd);
+               // Must set the composite parent to super class.
+               setCompositeParent(parserGroup);
+               // fire a change event, to quick start.
+               handleBinaryParserChanged();
+               parent.layout(true);
+       }
+
+       @Override
+       public void performApply(IProgressMonitor monitor) throws CoreException {
+               if (monitor == null) {
+                       monitor = new NullProgressMonitor();
+               }
+               monitor.beginTask(CUIMessages.BinaryParserBlock_settingBinaryParser, 2); 
+               List<BinaryParserConfiguration> parsers = binaryList.getElements();
+               final List<BinaryParserConfiguration> selected = new ArrayList<BinaryParserConfiguration>(); // must do this to get proper order.
+               for (int i = 0; i < parsers.size(); i++) {
+                       if (binaryList.isChecked(parsers.get(i))) {
+                               selected.add(parsers.get(i));
+                       }
+               }
+               if (getContainer().getProject() != null) {
+                       ICDescriptorOperation op = new ICDescriptorOperation() {
+
+                               public void execute(ICDescriptor descriptor, IProgressMonitor monitor) throws CoreException {
+                                       if (initialSelected == null || !selected.equals(initialSelected)) {
+                                               descriptor.remove(CCorePlugin.BINARY_PARSER_UNIQ_ID);
+                                               for (int i = 0; i < selected.size(); i++) {
+                                                       descriptor.create(CCorePlugin.BINARY_PARSER_UNIQ_ID,
+                                                                       selected.get(i).getID());
+                                               }
+                                       }
+                                       monitor.worked(1);
+                                       // Give a chance to the contributions to save.
+                                       // We have to do it last to make sure the parser id
+                                       // is save
+                                       // in .cdtproject
+                                       for (int i = 0; i < selected.size(); i++) {
+                                               ICOptionPage page = getBinaryParserPage(selected.get(i).getID());
+                                               if (page != null && page.getControl() != null) {
+                                                       page.performApply(new SubProgressMonitor(monitor, 1));
+                                               }
+                                       }
+                               }
+                       };
+                       CCorePlugin.getDefault().getCDescriptorManager().runDescriptorOperation(getContainer().getProject(), op, monitor);
+               } else {
+                       if (initialSelected == null || !selected.equals(initialSelected)) {
+                               Preferences store = getContainer().getPreferences();
+                               if (store != null) {
+                                       store.setValue(CCorePlugin.PREF_BINARY_PARSER, arrayToString(selected.toArray()));
+                               }
+                       }
+                       monitor.worked(1);
+                       // Give a chance to the contributions to save.
+                       for (int i = 0; i < selected.size(); i++) {
+                               ICOptionPage page = getBinaryParserPage(selected.get(i).getID());
+                               if (page != null && page.getControl() != null) {
+                                       page.performApply(new SubProgressMonitor(monitor, 1));
+                               }
+                       }
+               }
+               initialSelected = selected;
+               monitor.done();
+       }
+
+       @Override
+       public void setContainer(ICOptionContainer container) {
+               super.setContainer(container);
+
+               List<BinaryParserConfiguration> elements = new ArrayList<BinaryParserConfiguration>();
+
+               if (getContainer().getProject() != null) {
+                       try {
+                               ICConfigExtensionReference[] ref = CCorePlugin.getDefault().getDefaultBinaryParserExtensions(getContainer().getProject()); 
+                               initialSelected = new ArrayList<BinaryParserConfiguration>(ref.length);
+                               for (ICConfigExtensionReference element : ref) {
+                                       if (configMap.get(element.getID()) != null) {
+                                               initialSelected.add(configMap.get(element.getID()));
+                                               elements.add(configMap.get(element.getID()));
+                                       }
+                               }
+                       } catch (CoreException e) {
+                       }
+                       for (Entry<String, BinaryParserConfiguration> entry: configMap.entrySet()) {
+                               if (!elements.contains(entry.getValue())) {
+                                       elements.add(entry.getValue());
+                               }
+                       }
+                       binaryList.setElements(elements);
+                       if (initialSelected != null)
+                               binaryList.setCheckedElements(initialSelected);
+               }
+               if (initialSelected == null) {
+                       Preferences store = getContainer().getPreferences();
+                       String id = null;
+                       if (store != null) {
+                               id = store.getString(CCorePlugin.PREF_BINARY_PARSER);
+                       }
+
+                       if (id != null && id.length() > 0) {
+                               String[] ids = parseStringToArray(id);
+                               initialSelected = new ArrayList<BinaryParserConfiguration>(ids.length);
+                               for (String id2 : ids) {
+                                       if (configMap.get(id2) != null) {
+                                               initialSelected.add(configMap.get(id2));
+                                               elements.add(configMap.get(id2));
+                                       }
+                               }
+                       }
+                       for (Entry<String, BinaryParserConfiguration> entry: configMap.entrySet()) {
+                               if (!elements.contains(entry.getValue())) {
+                                       elements.add(entry.getValue());
+                               }
+                       }
+                       binaryList.setElements(elements);
+                       if (initialSelected != null)
+                               binaryList.setCheckedElements(initialSelected);
+                       // reset this since we only want to prevent applying non-changed selections on the project
+                       // and project creation we always want to apply selection.
+                       initialSelected = null;
+               }
+       }
+       private String arrayToString(Object[] array) {
+               StringBuffer buf = new StringBuffer();
+               for (Object element : array) {
+                       buf.append(element.toString()).append(';');
+               }
+               return buf.toString();
+       }
+
+       private String[] parseStringToArray(String syms) {
+               if (syms != null && syms.length() > 0) {
+                       StringTokenizer tok = new StringTokenizer(syms, ";"); //$NON-NLS-1$
+                       ArrayList<String> list = new ArrayList<String>(tok.countTokens());
+                       while (tok.hasMoreElements()) {
+                               list.add(tok.nextToken());
+                       }
+                       return list.toArray(new String[list.size()]);
+               }
+               return new String[0];
+       }
+
+       @Override
+       public void performDefaults() {
+               String id = null;
+
+               // default current pages.
+               List<BinaryParserConfiguration> selected = binaryList.getCheckedElements();
+               for (int i = 0; i < selected.size(); i++) {
+                       ICOptionPage page = getBinaryParserPage(selected.get(i).getID());
+                       if (page != null) {
+                               page.performDefaults();
+                       }
+               }
+               Preferences store = getContainer().getPreferences();
+               if (store != null) {
+                       if (getContainer().getProject() != null) {
+                               id = store.getString(CCorePlugin.PREF_BINARY_PARSER);
+                       } else {
+                               id = store.getDefaultString(CCorePlugin.PREF_BINARY_PARSER);
+                       }
+               }
+               //default selection
+               selected.clear();
+               if (id != null) {
+                       String[] ids = parseStringToArray(id);
+                       for (String id2 : ids) {
+                               if (configMap.get(id2) != null) {
+                                       selected.add(configMap.get(id2));
+                               }
+                       }
+               }
+               binaryList.setCheckedElements(selected);
+               binaryList.getTableViewer().setSelection(new StructuredSelection(selected.get(0)), true);
+               // Give a change to the UI contributors to react.
+               // But do it last after the comboBox is set.
+               handleBinaryParserChanged();
+               getContainer().updateContainer();
+       }
+
+       @Override
+       protected String getCurrentBinaryParserID() {
+               List<BinaryParserConfiguration> list = binaryList.getSelectedElements();
+               if (list.size() > 0) {
+                       BinaryParserConfiguration selected = list.get(0);
+                       //if (binaryList.isChecked(selected)) {
+                       //      return selected.getID();
+                       //}
+                       return selected.getID();
+               }
+               return null;
+       }
+
+       @Override
+       protected String[] getBinaryParserIDs() {
+               return configMap.keySet().toArray(new String[configMap.keySet().size()]);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CHelpConfigurationPropertyPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CHelpConfigurationPropertyPage.java
new file mode 100644 (file)
index 0000000..31d214c
--- /dev/null
@@ -0,0 +1,191 @@
+/**********************************************************************
+ * Copyright (c) 2004, 2010 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *     Intel Corporation - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ **********************************************************************/
+package org.eclipse.cdt.ui.dialogs;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
+
+import org.eclipse.cdt.internal.ui.CHelpProviderManager;
+import org.eclipse.cdt.internal.ui.CUIMessages;
+import org.eclipse.cdt.internal.ui.text.CHelpBookDescriptor;
+import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.CheckedListDialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
+
+/**
+ * This class defines a project property page 
+ * for C/C++ project help settings configuration
+ * @since 2.1
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class CHelpConfigurationPropertyPage extends PropertyPage implements
+               IWorkbenchPreferencePage {
+       private CHelpSettingsDisplay fCHelpSettingsDisplay;
+       
+       private class CHelpBookListLabelProvider extends LabelProvider {
+               private ImageDescriptor fHelpProviderIcon;
+               private ImageDescriptorRegistry fRegistry;
+               
+               public CHelpBookListLabelProvider() {
+                       fRegistry= CUIPlugin.getImageDescriptorRegistry();
+                       fHelpProviderIcon= CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_LIBRARY);
+               }
+               
+               @Override
+               public String getText(Object element) {
+                       if (element instanceof CHelpBookDescriptor) {
+                               return ((CHelpBookDescriptor)element).getCHelpBook().getTitle();
+                       }
+                       return super.getText(element);
+               }
+
+               @Override
+               public Image getImage(Object element) {
+                       if (element instanceof CHelpBookDescriptor) {
+                               return fRegistry.get(fHelpProviderIcon);
+                       } 
+                       return null;
+               }
+       }
+       
+       private class CHelpSettingsDisplay {
+               private CheckedListDialogField<CHelpBookDescriptor> fCHelpBookList;
+               private IProject fProject;
+               private CHelpBookDescriptor fCHelpBookDescriptors[];
+               
+               public CHelpSettingsDisplay() {
+               
+                       String[] buttonLabels= new String[] {
+                               /* 0 */ CUIMessages.CHelpConfigurationPropertyPage_buttonLabels_CheckAll,
+                               /* 1 */ CUIMessages.CHelpConfigurationPropertyPage_buttonLabels_UncheckAll
+                       };
+               
+                       fCHelpBookList= new CheckedListDialogField<CHelpBookDescriptor>(null, buttonLabels, new CHelpBookListLabelProvider());
+                       fCHelpBookList.setLabelText(CUIMessages.CHelpConfigurationPropertyPage_HelpBooks); 
+                       fCHelpBookList.setCheckAllButtonIndex(0);
+                       fCHelpBookList.setUncheckAllButtonIndex(1);
+               }
+               
+               public Control createControl(Composite parent){
+                       PixelConverter converter= new PixelConverter(parent);
+                       
+                       Composite composite= new Composite(parent, SWT.NONE);
+                       
+                       LayoutUtil.doDefaultLayout(composite, new DialogField[] { fCHelpBookList }, true);
+                       LayoutUtil.setHorizontalGrabbing(fCHelpBookList.getListControl(null), true);
+
+                       int buttonBarWidth= converter.convertWidthInCharsToPixels(24);
+                       fCHelpBookList.setButtonsMinWidth(buttonBarWidth);
+                       
+                       return composite;
+               }
+               
+               public void init(final IResource resource) {
+                       if(!(resource instanceof IProject))
+                               return;
+                       fProject = (IProject)resource;
+                       fCHelpBookDescriptors = CHelpProviderManager.getDefault().getCHelpBookDescriptors(new ICHelpInvocationContext(){
+                               public IProject getProject(){return (IProject)resource;}
+                               public ITranslationUnit getTranslationUnit(){return null;}
+                               }
+                       );
+
+                       List<CHelpBookDescriptor> allTopicsList= Arrays.asList(fCHelpBookDescriptors);
+                       List<CHelpBookDescriptor> enabledTopicsList= getEnabledEntries(allTopicsList);
+                       
+                       fCHelpBookList.setElements(allTopicsList);
+                       fCHelpBookList.setCheckedElements(enabledTopicsList);
+               }
+
+               private List<CHelpBookDescriptor> getEnabledEntries(List<CHelpBookDescriptor> list) {
+                       int size = list.size();
+                       List<CHelpBookDescriptor> desList= new ArrayList<CHelpBookDescriptor>();
+
+                       for (int i= 0; i < size; i++) {
+                               CHelpBookDescriptor el = list.get(i);
+                               if(el.isEnabled())
+                                       desList.add(el);
+                       }
+                       return desList;
+               }
+               
+               public void performOk(){
+                       List<CHelpBookDescriptor> list = fCHelpBookList.getElements();
+                       final IProject project = fProject;
+                       
+                       for(int i = 0; i < list.size(); i++){
+                               Object obj = list.get(i);
+                               if(obj != null && obj instanceof CHelpBookDescriptor){
+                                       ((CHelpBookDescriptor)obj).enable(fCHelpBookList.isChecked(obj));
+                               }
+                       }
+                       CHelpProviderManager.getDefault().serialize(new ICHelpInvocationContext(){
+                               public IProject getProject(){return project;}
+                               public ITranslationUnit getTranslationUnit(){return null;}
+                               });
+               }
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected Control createContents(Composite parent) {
+               fCHelpSettingsDisplay= new CHelpSettingsDisplay();
+               fCHelpSettingsDisplay.init(getResource());
+               return fCHelpSettingsDisplay.createControl(parent);
+       }
+
+       private IResource getResource() {
+               IAdaptable element= getElement();
+               if (element instanceof IResource) {
+                       return (IResource)element;
+               }
+               return (IResource)element.getAdapter(IResource.class);
+       }
+
+       @Override
+       public boolean performOk() {
+               fCHelpSettingsDisplay.performOk();
+               super.performOk();
+               return true;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+        */
+       public void init(IWorkbench workbench) {
+               // TODO Auto-generated method stub
+
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CacheSizeBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CacheSizeBlock.java
new file mode 100644 (file)
index 0000000..b0424b6
--- /dev/null
@@ -0,0 +1,191 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Markus Schorn - initial API and implementation
+ *     IBM Corporation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/ 
+package org.eclipse.cdt.ui.dialogs;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.jface.preference.IntegerFieldEditor;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.CCorePreferenceConstants;
+import org.eclipse.cdt.core.dom.CDOM;
+import org.eclipse.cdt.core.parser.CodeReaderCache;
+import org.eclipse.cdt.core.parser.ICodeReaderCache;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
+
+/**
+ * This OptionPage is used in the IndexerPreference page to allow for adjusting
+ * various parsing related caches.
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class CacheSizeBlock extends AbstractCOptionPage {
+       private IntegerFieldEditor fDBLimitPct;
+       private IntegerFieldEditor fDBAbsoluteLimit;
+       private IntegerFieldEditor fCodeReaderLimit;
+       
+    private IPropertyChangeListener validityChangeListener = new IPropertyChangeListener() {
+        public void propertyChange(PropertyChangeEvent event) {
+            if (event.getProperty().equals(FieldEditor.IS_VALID)) {
+                               updateValidState();
+                       }
+        }
+    };
+
+    public CacheSizeBlock(ICOptionContainer container){
+       setContainer(container);
+    }
+
+    @Override
+       public void createControl(Composite parent) {
+       PixelConverter pixelConverter =  new PixelConverter(parent);
+       GridData gd;
+       GridLayout gl;
+        Composite composite = ControlFactory.createComposite(parent, 1);
+               gl=  (GridLayout)composite.getLayout();
+               gl.marginWidth= 0;
+               
+               gd= (GridData) composite.getLayoutData();
+               gd.grabExcessHorizontalSpace= false;
+               gd.horizontalAlignment= GridData.FILL;
+
+               setControl(composite);
+      
+               Group group= ControlFactory.createGroup(composite, DialogsMessages.CacheSizeBlock_cacheLimitGroup, 1);
+               gd= (GridData) group.getLayoutData();
+               gd.grabExcessHorizontalSpace= true;
+               gd.horizontalAlignment= GridData.FILL;
+               
+               Composite cacheComp= ControlFactory.createComposite(group, 3);
+
+               Label dbCacheLabel= ControlFactory.createLabel(cacheComp, DialogsMessages.CacheSizeBlock_indexDatabaseCache);
+               fDBLimitPct= new IntegerFieldEditor(CCorePreferenceConstants.INDEX_DB_CACHE_SIZE_PCT, DialogsMessages.CacheSizeBlock_limitRelativeToMaxHeapSize, cacheComp, 3);
+               fDBLimitPct.setValidRange(1, 75);
+               Text control = fDBLimitPct.getTextControl(cacheComp);
+               LayoutUtil.setWidthHint(control, pixelConverter.convertWidthInCharsToPixels(10));
+               LayoutUtil.setHorizontalGrabbing(control, false); 
+               ControlFactory.createLabel(cacheComp, "%"); //$NON-NLS-1$
+
+               fDBAbsoluteLimit= new IntegerFieldEditor(CCorePreferenceConstants.MAX_INDEX_DB_CACHE_SIZE_MB, DialogsMessages.CacheSizeBlock_absoluteLimit, cacheComp, 4);
+               fDBAbsoluteLimit.setValidRange(1, 10000);
+               control = fDBAbsoluteLimit.getTextControl(cacheComp);
+               LayoutUtil.setWidthHint(control, pixelConverter.convertWidthInCharsToPixels(10));
+               LayoutUtil.setHorizontalGrabbing(control, false); 
+               ControlFactory.createLabel(cacheComp, DialogsMessages.CacheSizeBlock_MB);
+               
+               Label codeReaderLabel= ControlFactory.createLabel(cacheComp, DialogsMessages.CacheSizeBlock_headerFileCache);
+               fCodeReaderLimit= new IntegerFieldEditor(CodeReaderCache.CODE_READER_BUFFER, DialogsMessages.CacheSizeBlock_absoluteLimit, cacheComp, 4);
+               fCodeReaderLimit.setValidRange(1, 10000);
+               control = fCodeReaderLimit.getTextControl(cacheComp);
+               LayoutUtil.setWidthHint(control, pixelConverter.convertWidthInCharsToPixels(10));
+               LayoutUtil.setHorizontalGrabbing(control, false); 
+               ControlFactory.createLabel(cacheComp, DialogsMessages.CacheSizeBlock_MB);
+               
+               gl= (GridLayout) cacheComp.getLayout();
+               gl.numColumns= 3;
+               gl.makeColumnsEqualWidth= false;
+               gl.marginLeft= 0;
+               gl.verticalSpacing= 2;
+
+               gd= (GridData) dbCacheLabel.getLayoutData();
+               gd.horizontalSpan= 3;
+
+               int vindent= pixelConverter.convertHeightInCharsToPixels(1) / 2;
+               gd= (GridData) codeReaderLabel.getLayoutData();
+               gd.verticalIndent= vindent;
+               gd.horizontalSpan= 3;
+
+               int hindent= pixelConverter.convertWidthInCharsToPixels(2);
+               gd= new GridData();
+               gd.horizontalAlignment= GridData.FILL;
+               gd.horizontalIndent= hindent;
+               fDBLimitPct.getLabelControl(cacheComp).setLayoutData(gd);
+
+               gd= new GridData();
+               gd.horizontalAlignment= GridData.FILL;
+               gd.horizontalIndent= hindent;
+               fDBAbsoluteLimit.getLabelControl(cacheComp).setLayoutData(gd);
+
+               gd= new GridData();
+               gd.horizontalAlignment= GridData.FILL;
+               gd.horizontalIndent= hindent;
+               fCodeReaderLimit.getLabelControl(cacheComp).setLayoutData(gd);
+
+               initializeValues();
+    }
+
+    private void initializeValues() {
+       ScopedPreferenceStore prefStore= new ScopedPreferenceStore(InstanceScope.INSTANCE, CCorePlugin.PLUGIN_ID);
+
+       fDBLimitPct.setPreferenceStore(prefStore);
+       fDBLimitPct.setPropertyChangeListener(validityChangeListener);
+       fDBAbsoluteLimit.setPreferenceStore(prefStore);
+       fDBAbsoluteLimit.setPropertyChangeListener(validityChangeListener);
+       fCodeReaderLimit.setPreferenceStore(prefStore);
+       fCodeReaderLimit.setPropertyChangeListener(validityChangeListener);
+
+               fDBLimitPct.load();
+               fDBAbsoluteLimit.load();
+               fCodeReaderLimit.load();
+       }
+
+       @Override
+       public void performApply(IProgressMonitor monitor) throws CoreException {
+               fDBLimitPct.store();
+               fDBAbsoluteLimit.store();
+               fCodeReaderLimit.store();
+               
+               // code reader cache does not listen for pref-changes, help out:
+               ICodeReaderCache cache = CDOM.getInstance().getCodeReaderFactory(CDOM.PARSE_SAVED_RESOURCES).getCodeReaderCache();
+               if (cache instanceof CodeReaderCache) {
+                       ((CodeReaderCache) cache).setCacheSize(fCodeReaderLimit.getIntValue());
+               }
+    }
+
+    @Override
+       public void performDefaults() {
+       fDBLimitPct.loadDefault();
+               fDBAbsoluteLimit.loadDefault();
+               fCodeReaderLimit.loadDefault();
+    }
+
+    private void updateValidState() {
+       if (!fDBLimitPct.isValid()) {
+               setErrorMessage(fDBLimitPct.getErrorMessage());
+               setValid(false);
+       } else if (!fDBAbsoluteLimit.isValid()) {
+               setErrorMessage(fDBAbsoluteLimit.getErrorMessage());
+               setValid(false);
+       } else if (!fCodeReaderLimit.isValid()) {
+               setErrorMessage(fCodeReaderLimit.getErrorMessage());
+               setValid(false);
+       } else {
+               setValid(true);
+       }
+        getContainer().updateContainer();
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CygwinPEBinaryParserPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/CygwinPEBinaryParserPage.java
new file mode 100644 (file)
index 0000000..c950f5a
--- /dev/null
@@ -0,0 +1,372 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui.dialogs;
+
+import java.io.File;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+
+import org.eclipse.cdt.internal.ui.CUIMessages;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class CygwinPEBinaryParserPage extends AbstractCOptionPage {
+
+       public final static String PREF_ADDR2LINE_PATH = CUIPlugin.PLUGIN_ID + ".addr2line"; //$NON-NLS-1$
+       public final static String PREF_CPPFILT_PATH = CUIPlugin.PLUGIN_ID + ".cppfilt"; //$NON-NLS-1$
+       public final static String PREF_CYGPATH_PATH = CUIPlugin.PLUGIN_ID + ".cygpath"; //$NON-NLS-1$
+       public final static String PREF_NM_PATH = CUIPlugin.PLUGIN_ID + ".nm"; //$NON-NLS-1$
+
+       protected Text fAddr2LineCommandText;
+       protected Text fCPPFiltCommandText;
+       protected Text fCygPathCommandText;
+       protected Text fNMCommandText;
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
+        */
+       @Override
+       public void performApply(IProgressMonitor monitor) throws CoreException {
+               if (monitor == null) {
+                       monitor = new NullProgressMonitor();
+               }
+
+               String addr2line = fAddr2LineCommandText.getText().trim();
+               String cppfilt = fCPPFiltCommandText.getText().trim();
+               String cygpath = fCygPathCommandText.getText().trim();
+               String nm = fNMCommandText.getText().trim();
+
+               monitor.beginTask(CUIMessages.BinaryParserPage_task_savingAttributes, 1); 
+               IProject proj = getContainer().getProject();
+               if (proj != null) {
+                       String parserID = ""; //$NON-NLS-1$
+                       ICConfigExtensionReference[] cext = null;
+                       ICProjectDescription desc = CCorePlugin.getDefault().getProjectDescription(proj, true);
+                       if (desc != null) {
+                               ICConfigurationDescription cfgDesc = desc.getDefaultSettingConfiguration();
+                               if (cfgDesc != null) {
+                                       cext = cfgDesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID);
+                               }
+                       }
+                       if (cext != null && cext.length > 0) {
+                               IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID, "BinaryParserPage"); //$NON-NLS-1$
+                               IConfigurationElement[] infos = point.getConfigurationElements();
+                               for (int i = 0; i < infos.length; i++) {
+                                       String id = infos[i].getAttribute("parserID"); //$NON-NLS-1$
+                                       String clazz = infos[i].getAttribute("class"); //$NON-NLS-1$
+                                       String ego = getClass().getName();
+                                       if (clazz != null && clazz.equals(ego)) {
+                                               parserID = id;
+                                               break;
+                                       }
+                               }
+                               for (int i = 0; i < cext.length; i++) {
+                                       if (cext[i].getID().equals(parserID)) {
+                                               String orig = cext[i].getExtensionData("addr2line"); //$NON-NLS-1$
+                                               if (orig == null || !orig.equals(addr2line)) {
+                                                       cext[i].setExtensionData("addr2line", addr2line); //$NON-NLS-1$
+                                               }
+                                               orig = cext[i].getExtensionData("c++filt"); //$NON-NLS-1$
+                                               if (orig == null || !orig.equals(cppfilt)) {
+                                                       cext[i].setExtensionData("c++filt", cppfilt); //$NON-NLS-1$
+                                               }
+                                               orig = cext[i].getExtensionData("cygpath"); //$NON-NLS-1$
+                                               if (orig == null || !orig.equals(cygpath)) {
+                                                       cext[i].setExtensionData("cygpath", cygpath); //$NON-NLS-1$
+                                               }
+                                               orig = cext[i].getExtensionData("nm"); //$NON-NLS-1$
+                                               if (orig == null || !orig.equals(nm)) {
+                                                       cext[i].setExtensionData("nm", nm); //$NON-NLS-1$
+                                               }
+                                       }
+                               }
+                               CCorePlugin.getDefault().setProjectDescription(proj, desc);
+                       }
+               } else {
+                       Preferences store = getContainer().getPreferences();
+                       if (store != null) {
+                               store.setValue(PREF_ADDR2LINE_PATH, addr2line);
+                               store.setValue(PREF_CPPFILT_PATH, cppfilt);
+                               store.setValue(PREF_CYGPATH_PATH, cygpath);
+                               store.setValue(PREF_NM_PATH, nm);
+                       }
+               }
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
+        */
+       @Override
+       public void performDefaults() {
+               String addr2line = null;
+               String cppfilt = null;
+               String cygpath = null;
+               String nm = null;
+               IProject proj = getContainer().getProject();
+               Preferences store = getContainer().getPreferences();
+               if (store != null) {
+                       if (proj != null) {
+                               addr2line = store.getString(PREF_ADDR2LINE_PATH);
+                               cppfilt = store.getString(PREF_CPPFILT_PATH);
+                               cygpath = store.getString(PREF_CYGPATH_PATH);
+                               nm = store.getString(PREF_NM_PATH);
+                       } else {
+                               addr2line = store.getDefaultString(PREF_ADDR2LINE_PATH);
+                               cppfilt = store.getDefaultString(PREF_CPPFILT_PATH);
+                               cygpath = store.getDefaultString(PREF_CYGPATH_PATH);
+                               nm = store.getDefaultString(PREF_NM_PATH);
+                       }
+                       fAddr2LineCommandText.setText((addr2line == null || addr2line.length() == 0) ? "addr2line" : addr2line); //$NON-NLS-1$;
+                       fCPPFiltCommandText.setText((cppfilt == null || cppfilt.length() == 0) ? "c++filt" : cppfilt); //$NON-NLS-1$;
+                       fCygPathCommandText.setText((cygpath == null || cygpath.length() == 0) ? "cygpath" : cygpath); //$NON-NLS-1$;
+                       fNMCommandText.setText((nm == null || nm.length() == 0) ? "nm" : nm); //$NON-NLS-1$;
+               }
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       public void createControl(Composite composite) {
+               Group comp = new Group(composite, SWT.SHADOW_ETCHED_IN);
+               comp.setText(CUIMessages.BinaryParserBlock_binaryParserOptions); 
+               
+               comp.setLayout(new GridLayout(2, true));
+               comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               ((GridLayout) comp.getLayout()).makeColumnsEqualWidth = false;
+
+               Label label = ControlFactory.createLabel(comp, CUIMessages.BinaryParserPage_label_addr2lineCommand); 
+               GridData gd = new GridData();
+               gd.horizontalSpan = 2;
+               label.setLayoutData(gd);
+
+               fAddr2LineCommandText = ControlFactory.createTextField(comp, SWT.SINGLE | SWT.BORDER);
+               fAddr2LineCommandText.addModifyListener(new ModifyListener() {
+
+                       public void modifyText(ModifyEvent evt) {
+                               //updateLaunchConfigurationDialog();
+                       }
+               });
+
+               Button button = ControlFactory.createPushButton(comp, CUIMessages.BinaryParserPage_label_browse); 
+               button.addSelectionListener(new SelectionAdapter() {
+
+                       @Override
+                       public void widgetSelected(SelectionEvent evt) {
+                               handleAddr2LineButtonSelected();
+                               //updateLaunchConfigurationDialog();
+                       }
+
+                       private void handleAddr2LineButtonSelected() {
+                               FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
+                               dialog.setText(CUIMessages.BinaryParserPage_label_addr2lineCommand); 
+                               String command = fAddr2LineCommandText.getText().trim();
+                               int lastSeparatorIndex = command.lastIndexOf(File.separator);
+                               if (lastSeparatorIndex != -1) {
+                                       dialog.setFilterPath(command.substring(0, lastSeparatorIndex));
+                               }
+                               String res = dialog.open();
+                               if (res == null) {
+                                       return;
+                               }
+                               fAddr2LineCommandText.setText(res);
+                       }
+               });
+
+               label = ControlFactory.createLabel(comp, CUIMessages.BinaryParserPage_label_cppfiltCommand); 
+               gd = new GridData();
+               gd.horizontalSpan = 2;
+               label.setLayoutData(gd);
+
+               fCPPFiltCommandText = ControlFactory.createTextField(comp, SWT.SINGLE | SWT.BORDER);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               fCPPFiltCommandText.setLayoutData(gd);
+               fCPPFiltCommandText.addModifyListener(new ModifyListener() {
+
+                       public void modifyText(ModifyEvent evt) {
+                               //updateLaunchConfigurationDialog();
+                       }
+               });
+               button = ControlFactory.createPushButton(comp, CUIMessages.BinaryParserPage_label_browse1); 
+               button.addSelectionListener(new SelectionAdapter() {
+
+                       @Override
+                       public void widgetSelected(SelectionEvent evt) {
+                               handleCPPFiltButtonSelected();
+                               //updateLaunchConfigurationDialog();
+                       }
+
+                       private void handleCPPFiltButtonSelected() {
+                               FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
+                               dialog.setText(CUIMessages.BinaryParserPage_label_cppfiltCommand); 
+                               String command = fCPPFiltCommandText.getText().trim();
+                               int lastSeparatorIndex = command.lastIndexOf(File.separator);
+                               if (lastSeparatorIndex != -1) {
+                                       dialog.setFilterPath(command.substring(0, lastSeparatorIndex));
+                               }
+                               String res = dialog.open();
+                               if (res == null) {
+                                       return;
+                               }
+                               fCPPFiltCommandText.setText(res);
+                       }
+               });
+
+               label = ControlFactory.createLabel(comp, CUIMessages.BinaryParserPage_label_cygpathCommand); 
+               gd = new GridData();
+               gd.horizontalSpan = 2;
+               label.setLayoutData(gd);
+
+               fCygPathCommandText = ControlFactory.createTextField(comp, SWT.SINGLE | SWT.BORDER);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               fCygPathCommandText.setLayoutData(gd);
+               fCygPathCommandText.addModifyListener(new ModifyListener() {
+
+                       public void modifyText(ModifyEvent evt) {
+                               //updateLaunchConfigurationDialog();
+                       }
+               });
+               button = ControlFactory.createPushButton(comp, CUIMessages.BinaryParserPage_label_browse2); 
+               button.addSelectionListener(new SelectionAdapter() {
+
+                       @Override
+                       public void widgetSelected(SelectionEvent evt) {
+                               handleCygPathButtonSelected();
+                               //updateLaunchConfigurationDialog();
+                       }
+
+                       private void handleCygPathButtonSelected() {
+                               FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
+                               dialog.setText(CUIMessages.BinaryParserPage_label_cygpathCommand); 
+                               String command = fCygPathCommandText.getText().trim();
+                               int lastSeparatorIndex = command.lastIndexOf(File.separator);
+                               if (lastSeparatorIndex != -1) {
+                                       dialog.setFilterPath(command.substring(0, lastSeparatorIndex));
+                               }
+                               String res = dialog.open();
+                               if (res == null) {
+                                       return;
+                               }
+                               fCygPathCommandText.setText(res);
+                       }
+               });
+
+
+               label = ControlFactory.createLabel(comp, CUIMessages.BinaryParserPage_label_nmCommand); 
+               gd = new GridData();
+               gd.horizontalSpan = 2;
+               label.setLayoutData(gd);
+
+               fNMCommandText = ControlFactory.createTextField(comp, SWT.SINGLE | SWT.BORDER);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               fNMCommandText.setLayoutData(gd);
+               fNMCommandText.addModifyListener(new ModifyListener() {
+
+                       public void modifyText(ModifyEvent evt) {
+                               //updateLaunchConfigurationDialog();
+                       }
+               });
+               button = ControlFactory.createPushButton(comp, CUIMessages.BinaryParserPage_label_browse2); 
+               button.addSelectionListener(new SelectionAdapter() {
+
+                       @Override
+                       public void widgetSelected(SelectionEvent evt) {
+                               handleCygPathButtonSelected();
+                               //updateLaunchConfigurationDialog();
+                       }
+
+                       private void handleCygPathButtonSelected() {
+                               FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
+                               dialog.setText(CUIMessages.BinaryParserPage_label_nmCommand); 
+                               String command = fNMCommandText.getText().trim();
+                               int lastSeparatorIndex = command.lastIndexOf(File.separator);
+                               if (lastSeparatorIndex != -1) {
+                                       dialog.setFilterPath(command.substring(0, lastSeparatorIndex));
+                               }
+                               String res = dialog.open();
+                               if (res == null) {
+                                       return;
+                               }
+                               fNMCommandText.setText(res);
+                       }
+               });
+
+               setControl(comp);
+               initializeValues();
+       }
+
+       private void initializeValues() {
+               String addr2line = null;
+               String cppfilt = null;
+               String cygpath = null;
+               String nm = null;
+               IProject proj = getContainer().getProject();
+               if (proj != null) {
+                       try {
+                               ICConfigExtensionReference[] cext = CCorePlugin.getDefault().getDefaultBinaryParserExtensions(proj);
+                               if (cext.length > 0) {
+                                       addr2line = cext[0].getExtensionData("addr2line"); //$NON-NLS-1$;
+                                       cppfilt = cext[0].getExtensionData("c++filt"); //$NON-NLS-1$;
+                                       cygpath = cext[0].getExtensionData("cygpath"); //$NON-NLS-1$;
+                                       nm = cext[0].getExtensionData("nm"); //$NON-NLS-1$;
+                               }
+                       } catch (CoreException e) {
+                       }
+               } else {
+                       Preferences store = getContainer().getPreferences();
+                       if (store != null) {
+                               addr2line = store.getString(PREF_ADDR2LINE_PATH);
+                               cppfilt = store.getString(PREF_CPPFILT_PATH);
+                               cygpath = store.getString(PREF_CYGPATH_PATH);
+                               nm = store.getString(PREF_NM_PATH);
+                       }
+               }
+               fAddr2LineCommandText.setText((addr2line == null || addr2line.length() == 0) ? "addr2line" : addr2line); //$NON-NLS-1$;
+               fCPPFiltCommandText.setText((cppfilt == null || cppfilt.length() == 0) ? "c++filt" : cppfilt); //$NON-NLS-1$;
+               fCygPathCommandText.setText((cygpath == null || cygpath.length() == 0) ? "cygpath" : cygpath); //$NON-NLS-1$;
+               fNMCommandText.setText((nm == null || nm.length() == 0) ? "nm" : nm); //$NON-NLS-1$;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DOMSourceIndexerBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DOMSourceIndexerBlock.java
new file mode 100644 (file)
index 0000000..5a1acef
--- /dev/null
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corp. - Rational Software - initial implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui.dialogs;
+
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class DOMSourceIndexerBlock extends AbstractIndexerPage {
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.java
new file mode 100644 (file)
index 0000000..a40485f
--- /dev/null
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *      Markus Schorn - initial API and implementation
+ *      IBM Corporation
+ *      Andrew Ferguson (Symbian)
+ *      Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.dialogs;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ */
+public class DialogsMessages extends NLS {
+       private static final String BUNDLE_NAME = "org.eclipse.cdt.ui.dialogs.DialogsMessages"; //$NON-NLS-1$
+       /** @since 5.2 */
+       public static String AbstractIndexerPage_fileSizeLimit;
+       /** @since 5.1 */
+       public static String AbstractIndexerPage_heuristicIncludes;
+       public static String AbstractIndexerPage_indexAllFiles;
+       /** @since 5.1 */
+       public static String AbstractIndexerPage_indexAllHeaders;
+       /** @since 5.1 */
+       public static String AbstractIndexerPage_indexAllHeadersC;
+       /** @since 5.1 */
+       public static String AbstractIndexerPage_indexAllHeadersCpp;
+       /** @since 5.3 */
+       public static String AbstractIndexerPage_indexOpenedFiles;
+       public static String AbstractIndexerPage_indexUpFront;
+       public static String AbstractIndexerPage_skipAllReferences;
+       /** @since 5.1 */
+       public static String AbstractIndexerPage_skipImplicitReferences;
+       /** @since 5.2 */
+       public static String AbstractIndexerPage_skipTypeAndMacroReferences;
+       public static String AbstractIndexerPage_skipTypeReferences;
+       public static String AbstractIndexerPage_skipMacroReferences;
+       public static String CacheSizeBlock_MB;
+       public static String IndexerBlock_fixedBuildConfig;
+       /** @since 5.3 */
+       public static String IndexerBlock_indexerOptions;
+       public static String IndexerStrategyBlock_activeBuildConfig;
+       public static String IndexerStrategyBlock_autoUpdate;
+       public static String IndexerStrategyBlock_buildConfigGroup;
+       public static String IndexerStrategyBlock_immediateUpdate;
+       public static String IndexerStrategyBlock_specificBuildConfig;
+       public static String IndexerStrategyBlock_strategyGroup;
+       public static String PreferenceScopeBlock_enableProjectSettings;
+       public static String PreferenceScopeBlock_preferenceLink;
+       public static String PreferenceScopeBlock_storeWithProject;
+       public static String CacheSizeBlock_absoluteLimit;
+       public static String CacheSizeBlock_cacheLimitGroup;
+       public static String CacheSizeBlock_headerFileCache;
+       public static String CacheSizeBlock_indexDatabaseCache;
+       public static String CacheSizeBlock_limitRelativeToMaxHeapSize;
+       
+       public static String DocCommentOwnerBlock_DocToolLabel;
+       public static String DocCommentOwnerBlock_EnableProjectSpecificSettings;
+       public static String DocCommentOwnerBlock_SelectDocToolDescription;
+       public static String DocCommentOwnerCombo_None;
+       public static String DocCommentOwnerComposite_DocumentationToolGroupTitle;
+       /** @since 5.2 */
+       public static String RegexErrorParserOptionPage_ConsumeNo;
+       /** @since 5.2 */
+       public static String RegexErrorParserOptionPage_ConsumeYes;
+       /** @since 5.2 */
+       public static String RegexErrorParserOptionPage_DescriptionColumn;
+       /** @since 5.2 */
+       public static String RegexErrorParserOptionPage_EatColumn;
+       /** @since 5.2 */
+       public static String RegexErrorParserOptionPage_FileColumn;
+       /** @since 5.2 */
+       public static String RegexErrorParserOptionPage_LineColumn;
+       /** @since 5.2 */
+       public static String RegexErrorParserOptionPage_LinkToPreferencesMessage;
+       /** @since 5.2 */
+       public static String RegexErrorParserOptionPage_Pattern_Column;
+       /** @since 5.2 */
+       public static String RegexErrorParserOptionPage_SeverityColumn;
+       /** @since 5.2 */
+       public static String RegexErrorParserOptionPage_SeverityError;
+       /** @since 5.2 */
+       public static String RegexErrorParserOptionPage_SeverityIgnore;
+       /** @since 5.2 */
+       public static String RegexErrorParserOptionPage_SeverityInfo;
+       /** @since 5.2 */
+       public static String RegexErrorParserOptionPage_SeverityWarning;
+       /** @since 5.2 */
+       public static String RegexErrorParserOptionPage_Title;
+       /** @since 5.2 */
+       public static String RegexErrorParserOptionPage_TooltipConsume;
+       /** @since 5.2 */
+       public static String RegexErrorParserOptionPage_TooltipDescription;
+       /** @since 5.2 */
+       public static String RegexErrorParserOptionPage_TooltipFile;
+       /** @since 5.2 */
+       public static String RegexErrorParserOptionPage_TooltipLine;
+       /** @since 5.2 */
+       public static String RegexErrorParserOptionPage_TooltipPattern;
+       /** @since 5.2 */
+       public static String RegexErrorParserOptionPage_TooltipSeverity;
+       /** @since 5.2 */
+       public static String RegularExpression_EmptyPattern;
+       /** @since 5.2 */
+       public static String RegularExpression_Validate;
+       /** @since 5.2 */
+       public static String RegularExpression_Enter;
+
+       static {
+               // initialize resource bundle
+               NLS.initializeMessages(BUNDLE_NAME, DialogsMessages.class);
+       }
+
+       private DialogsMessages() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.properties
new file mode 100644 (file)
index 0000000..5255e98
--- /dev/null
@@ -0,0 +1,71 @@
+###############################################################################
+# Copyright (c) 2007, 2011 Wind River Systems, Inc. and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     Markus Schorn (Wind River Systems)
+#        IBM Corporation
+#     Andrew Ferguson (Symbian)
+#        Sergey Prigogin (Google)
+###############################################################################
+PreferenceScopeBlock_enableProjectSettings=Enable project specific settings
+PreferenceScopeBlock_storeWithProject=Store settings with project
+PreferenceScopeBlock_preferenceLink=<a>Configure Workspace Settings...</a>
+AbstractIndexerPage_fileSizeLimit=Skip files larger than:
+AbstractIndexerPage_heuristicIncludes=Allow heuristic resolution of includes
+AbstractIndexerPage_indexAllFiles=Index source files not included in the build
+AbstractIndexerPage_indexAllHeaders=Index unused headers
+AbstractIndexerPage_indexAllHeadersC=Index unused headers as C files
+AbstractIndexerPage_indexAllHeadersCpp=Index unused headers as C++ files
+AbstractIndexerPage_indexOpenedFiles=Index source and header files opened in editor
+AbstractIndexerPage_indexUpFront=Files to index up-front:
+AbstractIndexerPage_skipAllReferences=Skip all references (Call Hierarchy and Search will not work)
+AbstractIndexerPage_skipImplicitReferences=Skip implicit references (e.g. overloaded operators)
+AbstractIndexerPage_skipTypeAndMacroReferences=Skip type and macro references (Search for these references will not work)
+AbstractIndexerPage_skipTypeReferences=Skip type references (Search for type references will not work)
+AbstractIndexerPage_skipMacroReferences=Skip macro references (Search for macro references will not work)
+CacheSizeBlock_cacheLimitGroup=Cache limits
+CacheSizeBlock_indexDatabaseCache=Index database cache:
+CacheSizeBlock_limitRelativeToMaxHeapSize=Limit relative to the maximum heap size:
+CacheSizeBlock_absoluteLimit=Absolute Limit:
+CacheSizeBlock_MB=MB
+CacheSizeBlock_headerFileCache=Header file cache (used by refactoring):
+DocCommentOwnerBlock_DocToolLabel=Documentation tool:
+DocCommentOwnerBlock_EnableProjectSpecificSettings=Enable project specific settings
+DocCommentOwnerBlock_SelectDocToolDescription=Select the documentation tool to be used to determine editor behaviors in this project
+DocCommentOwnerCombo_None=None
+DocCommentOwnerComposite_DocumentationToolGroupTitle=Documentation tool comments
+IndexerBlock_fixedBuildConfig=Use a fixed build configuration
+IndexerBlock_indexerOptions=Indexer options
+IndexerStrategyBlock_strategyGroup=Indexing strategy
+IndexerStrategyBlock_autoUpdate=Automatically update the index
+IndexerStrategyBlock_immediateUpdate=Update index immediately after every file-save
+IndexerStrategyBlock_buildConfigGroup=Build configuration for the indexer
+IndexerStrategyBlock_activeBuildConfig=Use active build configuration
+IndexerStrategyBlock_specificBuildConfig=Use the build configuration specified in the project's indexer settings
+RegexErrorParserOptionPage_ConsumeNo=No
+RegexErrorParserOptionPage_ConsumeYes=
+RegexErrorParserOptionPage_DescriptionColumn=Description
+RegexErrorParserOptionPage_EatColumn=Consume
+RegexErrorParserOptionPage_FileColumn=File
+RegexErrorParserOptionPage_LineColumn=Line
+RegexErrorParserOptionPage_LinkToPreferencesMessage=These options are workspace-wide and can be changed in <a href="workspace">Workspace Settings</a>.
+RegexErrorParserOptionPage_Pattern_Column=Pattern
+RegexErrorParserOptionPage_SeverityColumn=Severity
+RegexErrorParserOptionPage_SeverityError=Error
+RegexErrorParserOptionPage_SeverityIgnore=Ignore
+RegexErrorParserOptionPage_SeverityInfo=Info
+RegexErrorParserOptionPage_SeverityWarning=Warning
+RegexErrorParserOptionPage_Title=Error Parser Options
+RegexErrorParserOptionPage_TooltipConsume=Use ''{0}'' to allow to re-process matching input line by other patterns
+RegexErrorParserOptionPage_TooltipDescription=Description as replacement expression (i.e. $3)
+RegexErrorParserOptionPage_TooltipFile=File as replacement expression (i.e. $1)
+RegexErrorParserOptionPage_TooltipLine=Line as replacement expression (i.e. $2)
+RegexErrorParserOptionPage_TooltipPattern=Java regular expression specifying capturing groups for 'File', 'Line' and 'Description'
+RegexErrorParserOptionPage_TooltipSeverity=Severity of marker
+RegularExpression_EmptyPattern=Empty pattern
+RegularExpression_Validate=Validate Regular Expression
+RegularExpression_Enter=Enter regular expression (use Ctrl+Space for content assist):
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerBlock.java
new file mode 100644 (file)
index 0000000..bb42492
--- /dev/null
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.dialogs;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+
+import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
+
+/**
+ * Project property page for setting documentation comment owner.
+ * <em>This class is not intended for use outside of CDT</em>
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ */
+public class DocCommentOwnerBlock extends AbstractCOptionPage {
+       private static String EDITOR_PREF_PAGE_ID= "org.eclipse.cdt.ui.preferences.CEditorPreferencePage"; //$NON-NLS-1$
+       
+       protected DocCommentOwnerComposite fDocComboComposite;
+       protected DocCommentOwnerManager fManager;
+       
+       protected Button fCheckbox;
+       protected Link fLink;
+       
+       public DocCommentOwnerBlock() {
+               fManager= DocCommentOwnerManager.getInstance();
+       }
+       
+       void handleCheckBox() {
+               fDocComboComposite.setEnabled(fCheckbox.getSelection());
+               fLink.setVisible(!fCheckbox.getSelection());
+       }
+       
+       @Override
+       public void createControl(final Composite parent) {
+               Composite pane= new Composite(parent, SWT.NONE);
+               pane.setLayout(new GridLayout(2, true));
+               pane.setLayoutData(GridDataFactory.fillDefaults().grab(true,false).span(2, 1).create());
+               
+               setControl(pane);
+               
+               fCheckbox= ControlFactory.createCheckBox(pane, DialogsMessages.DocCommentOwnerBlock_EnableProjectSpecificSettings);
+               fCheckbox.setLayoutData(GridDataFactory.fillDefaults().grab(true,false).create());
+               fCheckbox.addSelectionListener(new SelectionAdapter(){
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               handleCheckBox();
+                       }
+               });
+               
+               fLink= new Link(pane, SWT.NONE);
+               fLink.setText(DialogsMessages.PreferenceScopeBlock_preferenceLink);
+               fLink.setLayoutData(GridDataFactory.fillDefaults().align(GridData.CENTER, GridData.BEGINNING).grab(true,false).create());
+               fLink.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               PreferencesUtil.createPreferenceDialogOn(parent.getShell(), EDITOR_PREF_PAGE_ID, null, null).open();
+                       }
+               });
+               
+               String dsc= DialogsMessages.DocCommentOwnerBlock_SelectDocToolDescription;
+               String msg= DialogsMessages.DocCommentOwnerBlock_DocToolLabel;
+               
+               IDocCommentOwner prjOwner= DocCommentOwnerManager.getInstance().getCommentOwner(getProject());
+               fDocComboComposite= new DocCommentOwnerComposite(pane, prjOwner, dsc, msg);
+               fDocComboComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true,false).span(2, 1).create());
+               
+               fCheckbox.setSelection(fManager.projectDefinesOwnership(getProject()));
+               handleCheckBox();
+       }
+       
+       @Override
+       public void performApply(IProgressMonitor monitor) throws CoreException {
+               if(!fCheckbox.getSelection())
+                       fManager.setCommentOwner(getProject(), null, true);
+               else {
+                       IDocCommentOwner newOwner= fDocComboComposite.getSelectedDocCommentOwner();
+                       IProject p= getProject();
+                       fManager.setCommentOwner(p, newOwner, true);
+               }
+       }
+
+       public IProject getProject() {
+               ICOptionContainer container = getContainer();
+               if (container != null){
+                       if (container instanceof ICOptionContainerExtension) {
+                               try {
+                                       return ((ICOptionContainerExtension) container).getProjectHandle();
+                               }
+                               catch (Exception e) {
+                                       return null;
+                               }
+                       }
+                       return container.getProject();
+               }
+               return null;
+       }
+
+       @Override
+       public void performDefaults() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerCombo.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerCombo.java
new file mode 100644 (file)
index 0000000..bd0ae50
--- /dev/null
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.dialogs;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+
+import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+
+import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
+import org.eclipse.cdt.internal.ui.text.doctools.NullDocCommentOwner;
+
+/**
+ * Manages the population and selection of the doc-comment {@link Combo} box
+ * <em>This class is not intended for use outside of CDT</em>
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ */
+public class DocCommentOwnerCombo extends Composite {
+       protected Combo fCombo;
+       protected IDocCommentOwner fOwners[], fInitialOwner;
+
+       public DocCommentOwnerCombo(Composite parent, int style, IDocCommentOwner initialOwner) {
+               super(parent, style);
+               setLayout(new GridLayout());
+               fInitialOwner= initialOwner;
+               fOwners= getNontestOwners();
+               createControl(this);
+       }
+
+       public IDocCommentOwner getSelectedDocCommentOwner() {
+               int index= fCombo.getSelectionIndex();
+               return index == 0 ? NullDocCommentOwner.INSTANCE : fOwners[index-1];
+       }
+       
+       /**
+        * @return the list of registered doc-comment owners, filtering out those from the
+        * test plug-in.
+        */
+       private static IDocCommentOwner[] getNontestOwners() {
+               List<IDocCommentOwner> result= new ArrayList<IDocCommentOwner>();
+               for(IDocCommentOwner owner : DocCommentOwnerManager.getInstance().getRegisteredOwners()) {
+                       if(owner.getID().indexOf(".test.")==-1) //$NON-NLS-1$
+                               result.add(owner);
+               }
+               return result.toArray(new IDocCommentOwner[result.size()]);
+       }
+       
+       public void createControl(Composite parent) {
+               String[] items= new String[fOwners.length+1];
+               items[0]= DialogsMessages.DocCommentOwnerCombo_None;
+               for(int i=0; i<fOwners.length; i++) {
+                       items[i+1]= fOwners[i].getName();
+               }
+               fCombo = ControlFactory.createSelectCombo(parent, items, DialogsMessages.DocCommentOwnerCombo_None);
+               selectInCombo(fInitialOwner);
+       }
+
+       public void selectInCombo(IDocCommentOwner owner) {
+               for(int i=0; i<fOwners.length; i++) {
+                       if(fOwners[i].getID().equals(owner.getID())) {
+                               fCombo.select(i+1);
+                               return;
+                       }
+               }
+               fCombo.select(0);
+       }
+       
+       @Override
+       public void setEnabled(boolean enabled) {
+               fCombo.setEnabled(enabled);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerComposite.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DocCommentOwnerComposite.java
new file mode 100644 (file)
index 0000000..abd54bb
--- /dev/null
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.dialogs;
+
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+
+import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+
+/**
+ * <em>This class is not intended for use outside of CDT</em>
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ */
+public class DocCommentOwnerComposite extends Composite {
+       protected DocCommentOwnerCombo fDocCombo;
+       protected Label desc, comboLabel;
+       protected Group group;
+       
+       public DocCommentOwnerComposite(Composite parent, IDocCommentOwner initialOwner, String description, String label) {
+               super(parent, SWT.NONE);
+               GridLayout gl= new GridLayout();
+               gl.marginHeight= gl.marginWidth= 0;
+               setLayout(gl);
+               
+               group = ControlFactory.createGroup(this, DialogsMessages.DocCommentOwnerComposite_DocumentationToolGroupTitle, 2);
+               group.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
+               
+               desc= new Label(group, SWT.WRAP);
+               GridData gd = GridDataFactory.fillDefaults().grab(false, false).span(2, 1).create();
+               gd.widthHint= 150;
+               desc.setText(description);
+               desc.setLayoutData(gd);
+               
+               comboLabel= new Label(group, SWT.NONE);
+               comboLabel.setText(label);
+               
+               fDocCombo= new DocCommentOwnerCombo(group, SWT.NONE, initialOwner) {};
+               gd = GridDataFactory.fillDefaults().grab(true, false).create();
+               fDocCombo.setLayoutData(gd);
+       }
+       
+       public IDocCommentOwner getSelectedDocCommentOwner() {
+               return fDocCombo.getSelectedDocCommentOwner();
+       }
+       
+       @Override
+       public void setEnabled(boolean enabled) {
+               desc.setEnabled(enabled);
+               comboLabel.setEnabled(enabled);
+               fDocCombo.setEnabled(enabled);
+               group.setEnabled(enabled);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/FastIndexerBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/FastIndexerBlock.java
new file mode 100644 (file)
index 0000000..781f04c
--- /dev/null
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.ui.dialogs;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class FastIndexerBlock extends AbstractIndexerPage {
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/GNUElfBinaryParserPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/GNUElfBinaryParserPage.java
new file mode 100644 (file)
index 0000000..a2bb1e0
--- /dev/null
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ *  Copyright (c) 2004, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *  IBM - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.dialogs;
+
+/**
+ * Reusing AbstractGNUBinaryParserPage.
+ * New class is required for the algorithm in method performApply.
+ * Must implement getRealBinaryParserPage method. 
+ * 
+ * @author vhirsl
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class GNUElfBinaryParserPage extends AbstractGNUBinaryParserPage {
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.ui.dialogs.AbstractGNUBinaryParserPage#getRealBinaryParserPage()
+        */
+       @Override
+       protected AbstractGNUBinaryParserPage getRealBinaryParserPage() {
+               return this;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/GNUSomBinaryParserPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/GNUSomBinaryParserPage.java
new file mode 100644 (file)
index 0000000..1bf7487
--- /dev/null
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ *  Copyright (c) 2004, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *  IBM - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.dialogs;
+
+/**
+ * Reusing AbstractGNUBinaryParserPage.
+ * New class is required for the algorithm in method performApply.
+ * Must implement getRealBinaryParserPage method. 
+ * 
+ * @author vhirsl
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class GNUSomBinaryParserPage extends AbstractGNUBinaryParserPage {
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.ui.dialogs.AbstractGNUBinaryParserPage#getRealBinaryParserPage()
+        */
+       @Override
+       protected AbstractGNUBinaryParserPage getRealBinaryParserPage() {
+               return this;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/GNUXCoffBinaryParserPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/GNUXCoffBinaryParserPage.java
new file mode 100644 (file)
index 0000000..c4ad32e
--- /dev/null
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.dialogs;
+
+/**
+ * Reusing AbstractGNUBinaryParserPage.
+ * New class is required for the algorithm in method performApply.
+ * Must implement getRealBinaryParserPage method. 
+ * 
+ * @author vhirsl
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class GNUXCoffBinaryParserPage extends AbstractGNUBinaryParserPage {
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.ui.dialogs.GNUElfBinaryParserPage#getRealBinaryParserPage()
+        */
+       @Override
+       protected AbstractGNUBinaryParserPage getRealBinaryParserPage() {
+               return this;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ICOptionContainer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ICOptionContainer.java
new file mode 100644 (file)
index 0000000..bee0087
--- /dev/null
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.dialogs;
+
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.Preferences;
+
+public interface ICOptionContainer {
+
+       void updateContainer();
+
+       IProject getProject();
+
+       /**
+        * Returns the preference store.
+        *
+        * @return the preference store, or <code>null</code> if none
+        */
+       public Preferences getPreferences();
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ICOptionContainerExtension.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ICOptionContainerExtension.java
new file mode 100644 (file)
index 0000000..146070e
--- /dev/null
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.ui.dialogs;
+
+import org.eclipse.core.resources.IProject;
+
+/**
+ * Extension for the ICOptionContainer to be used with new project wizards.
+ * This allows children to access the the project handle.
+ * @since 4.0
+ */
+public interface ICOptionContainerExtension extends ICOptionContainer {
+       /**
+        * Returns the project to be created.
+        * @since 4.0
+        */
+       IProject getProjectHandle();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ICOptionPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ICOptionPage.java
new file mode 100644 (file)
index 0000000..26e8a35
--- /dev/null
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.dialogs;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.IDialogPage;
+
+public interface ICOptionPage extends IDialogPage {
+
+       public void setContainer(ICOptionContainer container);
+               
+       public boolean isValid();
+       
+       public void performApply(IProgressMonitor monitor) throws CoreException;
+
+       public void performDefaults();
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IInputStatusValidator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IInputStatusValidator.java
new file mode 100644 (file)
index 0000000..c3009f1
--- /dev/null
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 Andrew Gvozdev and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Andrew Gvozdev - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.dialogs;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+/**
+ * The IInputStatusValidator is the interface for IStatus validators. 
+ * @since 5.2
+ */
+public interface IInputStatusValidator {
+       /**
+        * Validates the given string. Returns the status with an error/warning/info message to display if the new
+        * text fails validation.
+        * 
+        * @param newText
+        *            the text to check for validity
+        * 
+        * @return {@link IStatus} object. For the purpose of validation severity and message are considered.
+        *         <li/>{@link Status#OK_STATUS} or any {@link IStatus#OK} to indicate no error.
+        *         <li/>{@link IStatus#ERROR} indicates an error.
+        *         <li/>{@link IStatus#WARNING} indicates a warning.
+        *         <li/>{@link IStatus#INFO} indicates an informational message.
+        */
+       public IStatus isValid(String newText);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerBlock.java
new file mode 100644 (file)
index 0000000..2ff71b1
--- /dev/null
@@ -0,0 +1,609 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM - Initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.dialogs;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.dialogs.ControlEnableState;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.ui.IPluginContribution;
+import org.eclipse.ui.activities.WorkbenchActivityHelper;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+import com.ibm.icu.text.Collator;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.IPDOMManager;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
+import org.eclipse.cdt.core.settings.model.ICProjectDescriptionPreferences;
+import org.eclipse.cdt.core.settings.model.ICProjectDescriptionWorkspacePreferences;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+import org.eclipse.cdt.utils.ui.controls.TabFolderLayout;
+
+import org.eclipse.cdt.internal.core.CCoreInternals;
+import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
+
+import org.eclipse.cdt.internal.ui.preferences.IndexerPreferencePage;
+
+/**
+ * This <code>IndexerBlock</code> is used in the <code>MakeProjectWizardOptionPage</code> and
+ * the <code>NewManagedProjectOptionPage</code> to display the indexer options during the creation of
+ * a new project.
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class IndexerBlock extends AbstractCOptionPage {
+       private static final String NODE_INDEXERUI = "indexerUI"; //$NON-NLS-1$
+    private static final String ATTRIB_CLASS = "class"; //$NON-NLS-1$
+       private static final String ATTRIB_NAME = "name"; //$NON-NLS-1$
+       private static final String ATTRIB_INDEXERID = "indexerID"; //$NON-NLS-1$
+       private static final String ATTRIB_ID = "id"; //$NON-NLS-1$
+
+       private static final String PREF_PAGE_ID = "org.eclipse.cdt.ui.preferences.IndexerPreferencePage"; //$NON-NLS-1$
+
+       private static final String INDEXER_LABEL = CUIPlugin.getResourceString("BaseIndexerBlock.label" ); //$NON-NLS-1$
+       private static final String INDEXER_DESCRIPTION = CUIPlugin.getResourceString("BaseIndexerBlock.desc"); //$NON-NLS-1$
+       
+       private PreferenceScopeBlock    fPrefScopeBlock;
+       private Button                                  fEnableIndexer;
+    private Combo                                      fIndexersComboBox;
+    private HashMap<String, IndexerConfig> fIndexerConfigMap;
+    private String                                     fTheOneIndexerID;
+       private Composite                               fIndexerPageComposite;
+    private AbstractIndexerPage        fCurrentPage;
+    private Properties                         fCurrentProperties;
+       private Composite                               fPreferenceContent;
+       private Composite                               fParent;
+       private Button                                  fUseActiveBuildButton;
+       private Button                                  fUseFixedBuildConfig;
+       private Combo                                   fBuildConfigComboBox;
+       private ControlEnableState              fEnableState;
+       private Group fBuildConfigGroup;
+    
+    public IndexerBlock(){
+               super(INDEXER_LABEL);
+               setDescription(INDEXER_DESCRIPTION);
+               initializeIndexerConfigMap();
+    }
+    
+       @Override
+       public boolean isValid() {
+               return super.isValid() && (fCurrentPage == null || fCurrentPage.isValid());
+       }
+       
+       @Override
+       public String getErrorMessage() {
+               String msg = super.getErrorMessage();
+               if (msg == null && fCurrentPage != null) {
+                       msg= fCurrentPage.getErrorMessage();
+               }
+               return msg;
+       }
+
+       /**
+     * Create a profile page only on request
+     */
+    private static class IndexerConfig implements IPluginContribution {
+               private static final String NULL = "null"; //$NON-NLS-1$
+               private AbstractIndexerPage fPage;
+        private IConfigurationElement fElement;
+
+        public IndexerConfig(NullIndexerBlock fixed) {
+               fPage= fixed;
+        }
+
+        public IndexerConfig(IConfigurationElement element) {
+               fElement= element;
+        }
+
+        public AbstractIndexerPage getPage() throws CoreException {
+            if (fPage == null) {
+               try {
+                       fPage= (AbstractIndexerPage) fElement.createExecutableExtension(ATTRIB_CLASS);
+               } catch (Exception e) {
+                       CUIPlugin.log(e);
+               }
+               if (fPage == null) {
+                       fPage= new NullIndexerBlock();
+               }
+            }
+            return fPage;
+        }
+        
+        public String getName() {
+               if (fElement == null)
+                       return NULL; 
+            return fElement.getAttribute(ATTRIB_NAME); 
+        }
+        
+               public String getLocalId() {
+               if (fElement == null)
+                       return NULL; 
+                       return fElement.getAttribute(ATTRIB_ID);
+               }
+
+               public String getPluginId() {
+               if (fElement == null)
+                       return NULL; 
+                       return fElement.getContributor().getName();
+               }
+    }
+
+    @Override
+       public void createControl(Composite parent) {
+               fParent= parent;
+
+        Composite composite = ControlFactory.createComposite(parent, 1);
+               GridLayout layout=  ((GridLayout)composite.getLayout());
+               layout.marginWidth= 0;
+               
+               GridData gd= (GridData) composite.getLayoutData();
+               gd.grabExcessHorizontalSpace= true;
+               setControl(composite);
+      
+               if (getProject() != null || getContainer() instanceof ICOptionContainerExtension) {
+                       fPrefScopeBlock= new PreferenceScopeBlock(PREF_PAGE_ID) {
+                               @Override
+                               protected void onPreferenceScopeChange() {
+                                       IndexerBlock.this.onPreferenceScopeChange();
+                               }
+                       };
+                       fPrefScopeBlock.createControl(composite);
+               }               
+
+               fPreferenceContent= ControlFactory.createComposite(composite, 1);
+               layout=  (GridLayout)fPreferenceContent.getLayout();
+               layout.marginHeight= 0;
+               layout.marginWidth= 0;
+               gd= (GridData) fPreferenceContent.getLayoutData();
+               gd.horizontalIndent= 0; 
+
+               // add option to enable indexer
+               final SelectionAdapter indexerChangeListener = new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               onIndexerChange();
+                       }
+               };
+               fEnableIndexer= ControlFactory.createCheckBox(fPreferenceContent, CUIPlugin.getResourceString("IndexerBlock.enable")); //$NON-NLS-1$
+               fEnableIndexer.addSelectionListener(indexerChangeListener);
+
+               // Add a group for indexer options.
+               Group group= ControlFactory.createGroup(fPreferenceContent, DialogsMessages.IndexerBlock_indexerOptions, 1);
+               gd= (GridData) group.getLayoutData();
+               gd.grabExcessHorizontalSpace= true;
+
+               if (fIndexerConfigMap.size() > 2) {
+                       fIndexersComboBox = ControlFactory.createSelectCombo(group, "", ""); //$NON-NLS-1$ //$NON-NLS-2$
+                       fIndexersComboBox.addSelectionListener(indexerChangeListener);
+               }
+
+               // add composite for pages
+        fIndexerPageComposite= ControlFactory.createComposite(group, 1);
+        fIndexerPageComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 2, 1));
+        fIndexerPageComposite.setLayout(new TabFolderLayout());
+
+        if (needBuildConfigOptions()) {
+               fBuildConfigGroup= group= ControlFactory.createGroup(composite, DialogsMessages.IndexerStrategyBlock_buildConfigGroup, 1);
+               gd= (GridData) group.getLayoutData();
+               gd.grabExcessHorizontalSpace= true;
+               fUseActiveBuildButton= ControlFactory.createRadioButton(group, DialogsMessages.IndexerStrategyBlock_activeBuildConfig, null, null);
+               fUseFixedBuildConfig= ControlFactory.createRadioButton(group, DialogsMessages.IndexerBlock_fixedBuildConfig, null, null);
+               fBuildConfigComboBox= ControlFactory.createSelectCombo(group, "", ""); //$NON-NLS-1$ //$NON-NLS-2$
+               final SelectionAdapter listener = new SelectionAdapter() {
+                       @Override
+                               public void widgetSelected(SelectionEvent e) {
+                               setUseActiveBuildConfig(fUseActiveBuildButton.getSelection());
+                       }
+               };
+                       fUseActiveBuildButton.addSelectionListener(listener);
+                       fUseFixedBuildConfig.addSelectionListener(listener);
+        }
+        
+        initializeScope();
+               initializeIndexerCombo();
+               initializeBuildConfigs();
+               onPreferenceScopeChange();
+        fParent.layout(true);
+    }
+
+       protected boolean needBuildConfigOptions() {
+               if (fPrefScopeBlock == null || !(getContainer() instanceof PropertyPage)) {
+                       return false;
+               }
+               IProject prj= getProject();
+               if (prj != null) {
+                       if (IndexerPreferencePage.showBuildConfiguration()) {
+                               ICProjectDescriptionManager prjDescMgr= CCorePlugin.getDefault().getProjectDescriptionManager();
+                               if (prjDescMgr.isNewStyleProject(prj)) 
+                                       return true;
+                       }
+               }
+               return false;
+       }
+       
+       private void updateBuildConfigForScope(int scope) {
+               if (fBuildConfigComboBox != null) {
+                       if (scope == IndexerPreferences.SCOPE_INSTANCE) {
+                       ICProjectDescriptionManager prjDescMgr= CCorePlugin.getDefault().getProjectDescriptionManager();
+                       ICProjectDescriptionWorkspacePreferences prefs= prjDescMgr.getProjectDescriptionWorkspacePreferences(false);
+                       boolean useActive= prefs.getConfigurationRelations() == ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE;
+                               fUseActiveBuildButton.setSelection(useActive);
+                               fUseFixedBuildConfig.setSelection(!useActive);
+                       }
+                       updateBuildConfigEnablement(scope);
+               }
+       }               
+       
+       void updateBuildConfigEnablement(int scope) {
+               if (fBuildConfigGroup == null)
+                       return;
+               
+               if (!fEnableIndexer.getSelection()) {
+                       ControlEnableState.disable(fBuildConfigGroup);
+               } else {
+                       final boolean notDerived = scope != IndexerPreferences.SCOPE_INSTANCE;
+                       final boolean fixed = fUseFixedBuildConfig.getSelection();
+                       // independent of scope
+                       fBuildConfigComboBox.setEnabled(fixed);
+                       fUseActiveBuildButton.setEnabled(notDerived);
+                       fUseFixedBuildConfig.setEnabled(notDerived);
+                       fBuildConfigGroup.setEnabled(notDerived || fixed);
+               }
+       }
+       
+       protected void setUseActiveBuildConfig(boolean useActive) {
+               if (fBuildConfigComboBox != null) {
+                       if (useActive) {
+                       ICProjectDescriptionManager prjDescMgr= CCorePlugin.getDefault().getProjectDescriptionManager();
+                       ICProjectDescription prefs= prjDescMgr.getProjectDescription(getProject(), false);
+                       selectBuildConfigInCombo(prefs.getActiveConfiguration().getName());
+                               fBuildConfigComboBox.setEnabled(false);
+                       } else {
+                               // independent of the scope
+                               fBuildConfigComboBox.setEnabled(true);
+                       }
+                       fUseActiveBuildButton.setSelection(useActive);
+                       fUseFixedBuildConfig.setSelection(!useActive);
+               }
+       }
+
+       private void enablePreferenceContent(boolean enable) {
+               if (fEnableState != null) {
+                       fEnableState.restore();
+               }
+               if (enable) {
+                       fEnableState= null;
+               } else {
+                       fEnableState= ControlEnableState.disable(fPreferenceContent);
+               }
+       }
+
+       private void initializeScope() {
+       IProject proj= getProject();
+       if (fPrefScopeBlock == null) {
+               return;
+       }
+       
+       int scope= proj == null ? IndexerPreferences.SCOPE_INSTANCE : IndexerPreferences.getScope(proj);
+       switch(scope) {
+       case IndexerPreferences.SCOPE_PROJECT_PRIVATE:
+               fPrefScopeBlock.setProjectLocalScope();
+               break;
+       case IndexerPreferences.SCOPE_PROJECT_SHARED:
+               fPrefScopeBlock.setProjectScope();
+               break;
+       default:
+               fPrefScopeBlock.setInstanceScope();
+               break;
+       }
+       }
+
+       private void initializeIndexerCombo() {
+               if (fIndexersComboBox != null) {
+                       String[] names= new String[fIndexerConfigMap.size()-1];
+                       int j= 0;
+                       for (String id : fIndexerConfigMap.keySet()) {
+                               if (!IPDOMManager.ID_NO_INDEXER.equals(id)) {
+                                       names[j++]= fIndexerConfigMap.get(id).getName();
+                               }
+                       }
+                       final Comparator<Object> collator = Collator.getInstance();
+                       Arrays.sort(names, collator);
+                       fIndexersComboBox.setItems(names);
+               } else {
+                       fTheOneIndexerID= IPDOMManager.ID_NO_INDEXER;
+                       for (String id : fIndexerConfigMap.keySet()) {
+                               if (!IPDOMManager.ID_NO_INDEXER.equals(id)) {
+                                       fTheOneIndexerID= id;
+                                       break;
+                               }
+                       }
+               }
+       }
+
+       private void initializeBuildConfigs() {
+               if (fBuildConfigComboBox != null) {
+               ICProjectDescriptionManager prjDescMgr= CCorePlugin.getDefault().getProjectDescriptionManager();
+               ICProjectDescription prefs= prjDescMgr.getProjectDescription(getProject(), false);
+               setUseActiveBuildConfig(prefs.getConfigurationRelations() == ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE);
+               ICConfigurationDescription[] configs= prefs.getConfigurations();
+               String[] names= new String[configs.length];
+               for (int i = 0; i < configs.length; i++) {
+                               ICConfigurationDescription config = configs[i];
+                               names[i]= config.getName();
+                       }
+                       final Comparator<Object> collator = Collator.getInstance();
+                       Arrays.sort(names, collator);
+                       fBuildConfigComboBox.setItems(names);
+               selectBuildConfigInCombo(prefs.getDefaultSettingConfiguration().getName());
+               }
+       }
+
+       private void selectBuildConfigInCombo(String useName) {
+               String[] names= fBuildConfigComboBox.getItems();
+               int selectedIndex = 0;
+               for (int i = 0; i < names.length; i++){
+                       if (names[i].equals(useName))
+                               selectedIndex = i;
+               }
+               fBuildConfigComboBox.select(selectedIndex);
+       }
+       
+    protected void onPreferenceScopeChange() {
+       int scope= computeScope();
+       if (fCurrentProperties == null || scope != IndexerPreferences.SCOPE_PROJECT_PRIVATE) {
+               Properties props= IndexerPreferences.getProperties(getProject(), scope);
+
+               String indexerId= props.getProperty(IndexerPreferences.KEY_INDEXER_ID);
+               if (getIndexerName(indexerId) == null) {
+                       if (fCurrentProperties != null) {
+                               props= fCurrentProperties;
+                       } else {
+                               props= IndexerPreferences.getProperties(getProject(), IndexerPreferences.SCOPE_INSTANCE);
+                       }
+               }
+               fCurrentProperties= props;
+               }
+               updateForNewProperties(scope);
+       updateBuildConfigForScope(scope);
+       }
+
+       private void updateForNewProperties(int scope) {
+               String indexerId= fCurrentProperties.getProperty(IndexerPreferences.KEY_INDEXER_ID);
+               if (indexerId.equals(IPDOMManager.ID_NO_INDEXER)) {
+                       fEnableIndexer.setSelection(false);
+               } else {
+                       fEnableIndexer.setSelection(true);
+                       if (fIndexersComboBox != null) {
+                               String indexerName = getIndexerName(indexerId);
+                               String[] indexerList = fIndexersComboBox.getItems();
+                               int selectedIndex = 0;
+                               for (int i = 0; i < indexerList.length; i++){
+                                       if (indexerList[i].equals(indexerName))
+                                               selectedIndex = i;
+                               }
+                               fIndexersComboBox.select(selectedIndex);
+                       }
+               }
+        setPage();
+        if (fPrefScopeBlock != null) {
+               enablePreferenceContent(scope != IndexerPreferences.SCOPE_INSTANCE);
+        }
+       }
+
+       protected void onIndexerChange() {
+       if (fCurrentPage != null) {
+               Properties props= fCurrentPage.getProperties();
+               if (props != null) {
+                       fCurrentProperties.putAll(props);
+               }
+       }
+       setPage();
+       updateBuildConfigEnablement(computeScope());
+    }
+
+       private int computeScope() {
+               if (fPrefScopeBlock != null) {
+                       if (fPrefScopeBlock.isProjectLocalScope()) {
+                               return IndexerPreferences.SCOPE_PROJECT_PRIVATE;
+                       }
+                       if (fPrefScopeBlock.isProjectScope()) {
+                               return IndexerPreferences.SCOPE_PROJECT_SHARED;
+                       }
+               }
+               return IndexerPreferences.SCOPE_INSTANCE;
+       }
+       
+    private void setPage() {
+        String indexerID= getSelectedIndexerID();
+        AbstractIndexerPage page = getIndexerPage(indexerID);
+        if (page != null) {
+            if (page.getControl() == null) {
+                page.setContainer(getContainer());
+                page.createControl(fIndexerPageComposite);
+                fIndexerPageComposite.layout(true);
+                fParent.layout(true);
+            }
+        }
+        
+        if (fCurrentPage != null){
+               fCurrentPage.setVisible(false);
+        }
+            
+        if (page != null) {
+               page.setProperties(fCurrentProperties);
+               page.setVisible(true);
+        }
+        
+        fCurrentPage= page;
+       }
+
+       /**
+     * Adds all the contributed Indexer Pages to a map
+     */
+    private void initializeIndexerConfigMap() {
+        fIndexerConfigMap = new HashMap<String, IndexerConfig>(5);        
+        IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.getPluginId(), "IndexerPage"); //$NON-NLS-1$
+        IConfigurationElement[] infos = extensionPoint.getConfigurationElements();
+        for (final IConfigurationElement info : infos) {
+               if (info.getName().equals(NODE_INDEXERUI)) { 
+               final String id = info.getAttribute(ATTRIB_INDEXERID);
+               if (id != null) {
+                       IndexerConfig config= new IndexerConfig(info);
+                       if (config.getName() != null && !WorkbenchActivityHelper.filterItem(config)) {
+                               fIndexerConfigMap.put(id, config);
+                       }
+                }
+            }
+        }
+        fIndexerConfigMap.put(IPDOMManager.ID_NO_INDEXER, new IndexerConfig(new NullIndexerBlock()));
+    }
+  
+    private String getIndexerName(String indexerID) {
+        IndexerConfig configElement= fIndexerConfigMap.get(indexerID);
+        if (configElement != null) {
+            return configElement.getName();
+        }
+        return null;
+    }
+
+    private AbstractIndexerPage getIndexerPage(String indexerID) {
+        IndexerConfig configElement= fIndexerConfigMap.get(indexerID);
+        if (configElement != null) {
+            try {
+                return configElement.getPage();
+            } catch (CoreException e) {
+               CUIPlugin.log(e);
+            }
+        }
+        return null;
+    }
+    
+    @Override
+       public void performApply(IProgressMonitor monitor) throws CoreException {
+       int scope= computeScope();
+       IProject project= getProject();
+       String indexerID = getSelectedIndexerID();
+       if (indexerID == null) {
+               return;
+       }
+
+       if (scope != IndexerPreferences.SCOPE_INSTANCE || project == null) {
+               Properties props= new Properties();
+               props.setProperty(IndexerPreferences.KEY_INDEXER_ID, indexerID);
+               if (fCurrentPage != null) {
+                       Properties p1= fCurrentPage.getProperties();
+                       if (p1 != null) {
+                               props.putAll(p1);
+                       }
+               }
+               IndexerPreferences.setProperties(project, scope, props);
+       }
+       
+       if (project != null) {
+               IndexerPreferences.setScope(project, scope);
+       }
+       
+       if (fBuildConfigComboBox != null) {
+               boolean useActive= fUseActiveBuildButton.getSelection();
+               ICProjectDescriptionManager prjDescMgr= CCorePlugin.getDefault().getProjectDescriptionManager();
+               ICProjectDescription prefs= prjDescMgr.getProjectDescription(getProject(), true);
+               if (scope == IndexerPreferences.SCOPE_INSTANCE) {
+                       prefs.useDefaultConfigurationRelations();
+               } else {
+                       prefs.setConfigurationRelations(useActive ?
+                                       ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE :
+                                       ICProjectDescriptionPreferences.CONFIGS_INDEPENDENT);
+               }
+               if (!useActive) {
+                       final ICConfigurationDescription config= prefs.getConfigurationByName(fBuildConfigComboBox.getText());
+                       if (config != null) {
+                               prefs.setDefaultSettingConfiguration(config);
+                       }
+               }
+               prjDescMgr.setProjectDescription(getProject(), prefs);
+       }
+       CCoreInternals.savePreferences(project, scope == IndexerPreferences.SCOPE_PROJECT_SHARED);
+    }
+
+    @Override
+       public void performDefaults() {
+       fCurrentProperties= null;
+       if (fPrefScopeBlock != null) {
+               fPrefScopeBlock.setInstanceScope();
+               onPreferenceScopeChange();
+       } else {
+               fCurrentProperties= IndexerPreferences.getDefaultIndexerProperties();
+               updateForNewProperties(IndexerPreferences.SCOPE_INSTANCE);
+       }
+    }
+
+    /**
+     * @deprecated always returns false
+     */
+       @Deprecated
+       public boolean isIndexEnabled() {
+               return false;
+       }
+
+       private String getSelectedIndexerID(){
+               if (fEnableIndexer.getSelection()) {
+                       if (fIndexersComboBox == null)
+                               return fTheOneIndexerID;
+
+                       final String indexerName = fIndexersComboBox.getText();
+                       for (Map.Entry<String, IndexerConfig> entry : fIndexerConfigMap.entrySet()) {
+                               if (indexerName.equals(entry.getValue().getName())) {
+                                       return entry.getKey();
+                               }
+                       }
+                       return null;
+               }
+               return IPDOMManager.ID_NO_INDEXER;
+       }
+       
+       public IProject getProject() {
+               ICOptionContainer container = getContainer();
+               if (container != null){
+                       if (container instanceof ICOptionContainerExtension) {
+                               try {
+                                       return ((ICOptionContainerExtension) container).getProjectHandle();
+                               } catch (Exception e) {
+                                       return null;
+                               }
+                       }
+                       return container.getProject();
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerOptionPropertyPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/IndexerOptionPropertyPage.java
new file mode 100644 (file)
index 0000000..7b34bbb
--- /dev/null
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corp. - Rational Software - initial implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.dialogs;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class IndexerOptionPropertyPage extends PropertyPage implements ICOptionContainer {
+
+       private IndexerBlock optionPage;
+
+       public IndexerOptionPropertyPage(){
+               super();
+               optionPage = new IndexerBlock();
+               optionPage.setContainer(this);
+       }
+
+       @Override
+       protected Control createContents(Composite parent) {
+               Composite composite = new Composite(parent, SWT.NONE);
+               composite.setLayout(new GridLayout());
+
+               optionPage.createControl(composite);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.PROJECT_INDEXER_PROPERTIES);      
+               
+               return composite;
+       }
+
+       @Override
+       protected void performDefaults() {
+               optionPage.performDefaults();
+       }
+               
+       @Override
+       public boolean performOk() {
+               try {
+                       optionPage.performApply(new NullProgressMonitor());
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }
+               return true;
+       }
+       
+       public IProject getProject(){
+               IProject project= null;
+               IAdaptable elem = getElement();
+               if (elem instanceof IProject) {
+                       project= (IProject) elem;
+               } else if (elem != null) {
+                       project= (IProject) elem.getAdapter(IProject.class);
+               }
+               return project;
+       }
+
+       public void updateContainer() {
+       }
+       
+       /**
+        * @deprecated
+        */
+       @Deprecated
+       public org.eclipse.core.runtime.Preferences getPreferences() {
+               throw new UnsupportedOperationException();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/InputStatusDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/InputStatusDialog.java
new file mode 100644 (file)
index 0000000..142fab9
--- /dev/null
@@ -0,0 +1,214 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 Andrew Gvozdev and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Andrew Gvozdev - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.dialogs;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.StatusDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * An input dialog for soliciting an input string from the user.
+ * The string can be validated. In case of problem error/warning/info message
+ * is shown in status line and decorated with appropriate status icon.
+ * <p>
+ * This concrete dialog class can be instantiated as is, or further subclassed as required.
+ * </p>
+ * @since 5.2
+ */
+public class InputStatusDialog extends StatusDialog {
+       /**
+        * The title of the dialog.
+        */
+       private String title;
+
+       /**
+        * The message to display, or <code>null</code> if none.
+        */
+       private String message;
+
+       /**
+        * The input value; the empty string by default.
+        */
+       private String value = "";//$NON-NLS-1$
+
+       /**
+        * The input validator, or <code>null</code> if none.
+        */
+       private IInputStatusValidator validator;
+
+       /**
+        * Input text widget.
+        */
+       private Text text;
+
+    /**
+     * Creates an input dialog with OK and Cancel buttons. Note that the dialog
+     * will have no visual representation (no widgets) until it is told to open.
+     * <p>
+     * Note that the <code>open</code> method blocks for input dialogs.
+     * </p>
+     * 
+     * @param parentShell
+     *            the parent shell, or <code>null</code> to create a top-level
+     *            shell
+     * @param dialogTitle
+     *            the dialog title, or <code>null</code> if none
+     * @param dialogMessage
+     *            the dialog message, or <code>null</code> if none
+     * @param initialValue
+     *            the initial input value, or <code>null</code> if none
+     *            (equivalent to the empty string)
+     * @param validator
+     *            an input validator, or <code>null</code> if none
+     *            For a validator, following return statuses are recognized:
+     *            <li/>{@link Status#OK_STATUS} or any {@link IStatus#OK} to indicate no error.
+     *            <li/>{@link IStatus#ERROR} indicates an error.
+     *            <li/>{@link IStatus#WARNING} indicates a warning.
+     *            <li/>{@link IStatus#INFO} indicates an informational message
+     */
+       public InputStatusDialog(Shell parentShell, String dialogTitle, String dialogMessage,
+                       String initialValue, IInputStatusValidator validator) {
+               super(parentShell);
+               this.title = dialogTitle;
+               if (dialogMessage == null) {
+                       this.message = ""; //$NON-NLS-1$
+               } else {
+                       this.message = dialogMessage;
+               }
+               if (initialValue == null) {
+                       this.value = ""; //$NON-NLS-1$
+               } else {
+                       this.value = initialValue;
+               }
+               this.validator = validator;
+       }
+
+       /*
+        * (non-Javadoc) Method declared on Dialog.
+        */
+       @Override
+       protected void buttonPressed(int buttonId) {
+               if (buttonId == IDialogConstants.OK_ID) {
+                       value = text.getText();
+               } else {
+                       value = null;
+               }
+               super.buttonPressed(buttonId);
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+        */
+       @Override
+       protected void configureShell(Shell shell) {
+               super.configureShell(shell);
+               if (title != null) {
+                       shell.setText(title);
+               }
+       }
+
+       @Override
+       protected Control createDialogArea(Composite parent) {
+               Composite composite = (Composite) super.createDialogArea(parent);
+
+               Label label = new Label(composite, SWT.WRAP);
+               label.setText(message);
+               GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL
+                               | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
+               data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
+               label.setLayoutData(data);
+               label.setFont(parent.getFont());
+
+               text = new Text(composite, getInputTextStyle());
+               text.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
+               text.addModifyListener(new ModifyListener() {
+                       public void modifyText(ModifyEvent e) {
+                               validateInput();
+                       }
+               });
+               text.setFocus();
+               if (value != null) {
+                       text.setText(value);
+                       text.selectAll();
+               }
+
+               applyDialogFont(composite);
+
+               return composite;
+       }
+
+       /**
+        * Returns the text area.
+        * 
+        * @return the text area
+        */
+       protected Text getText() {
+               return text;
+       }
+
+       /**
+        * Returns the validator.
+        * 
+        * @return the validator
+        */
+       protected IInputStatusValidator getValidator() {
+               return validator;
+       }
+
+       /**
+        * Returns the string typed into this input dialog.
+        * 
+        * @return the input string
+        */
+       public String getValue() {
+               return value;
+       }
+
+       /**
+        * Validates the input.
+        * <p>
+        * The default implementation of this framework method delegates the request to the supplied input
+        * validator object; if it finds the input invalid, the error message is displayed in the dialog's message
+        * line. This hook method is called whenever the text changes in the input field.
+        * </p>
+        */
+       protected void validateInput() {
+               IStatus status = Status.OK_STATUS;
+               if (validator != null) {
+                       status = validator.isValid(text.getText());
+               }
+               updateStatus(status);
+       }
+
+       /**
+        * Returns the style bits that should be used for the input text field. Defaults to a single line entry.
+        * Subclasses may override.
+        * 
+        * @return the integer style bits that should be used when creating the input text
+        * 
+        */
+       protected int getInputTextStyle() {
+               return SWT.SINGLE | SWT.BORDER;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/MachOBinaryParserPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/MachOBinaryParserPage.java
new file mode 100644 (file)
index 0000000..31e2dcd
--- /dev/null
@@ -0,0 +1,216 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui.dialogs;
+
+import java.io.File;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+
+import org.eclipse.cdt.internal.ui.CUIMessages;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class MachOBinaryParserPage extends AbstractCOptionPage {
+
+       public final static String PREF_CPPFILT_PATH = CUIPlugin.PLUGIN_ID + ".cppfilt"; //$NON-NLS-1$
+
+       protected Text fCPPFiltCommandText;
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
+        */
+       @Override
+       public void performApply(IProgressMonitor monitor) throws CoreException {
+               if (monitor == null) {
+                       monitor = new NullProgressMonitor();
+               }
+
+               String cppfilt = fCPPFiltCommandText.getText().trim();
+
+               monitor.beginTask(CUIMessages.BinaryParserPage_task_savingAttributes, 1); 
+               IProject proj = getContainer().getProject();
+               if (proj != null) {
+                       String parserID = ""; //$NON-NLS-1$
+                       ICConfigExtensionReference[] cext = null;
+                       ICProjectDescription desc = CCorePlugin.getDefault().getProjectDescription(proj, true);
+                       if (desc != null) {
+                               ICConfigurationDescription cfgDesc = desc.getDefaultSettingConfiguration();
+                               if (cfgDesc != null) {
+                                       cext = cfgDesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID);
+                               }
+                       }
+                       if (cext != null && cext.length > 0) {
+                               IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID, "BinaryParserPage"); //$NON-NLS-1$
+                               IConfigurationElement[] infos = point.getConfigurationElements();
+                               for (int i = 0; i < infos.length; i++) {
+                                       String id = infos[i].getAttribute("parserID"); //$NON-NLS-1$
+                                       String clazz = infos[i].getAttribute("class"); //$NON-NLS-1$
+                                       String ego = getRealBinaryParserPage().getClass().getName();
+                                       if (clazz != null && clazz.equals(ego)) {
+                                               parserID = id;
+                                               break;
+                                       }
+                               }
+                               for (int i = 0; i < cext.length; i++) {
+                                       if (cext[i].getID().equals(parserID)) {
+
+                                               String orig = cext[i].getExtensionData("c++filt"); //$NON-NLS-1$
+                                               if (orig == null || !orig.equals(cppfilt)) {
+                                                       cext[i].setExtensionData("c++filt", cppfilt); //$NON-NLS-1$
+                                               }
+                                       }
+                               }
+                               CCorePlugin.getDefault().setProjectDescription(proj, desc);
+                       }
+               } else {
+                       Preferences store = getContainer().getPreferences();
+                       if (store != null) {
+                               store.setValue(PREF_CPPFILT_PATH, cppfilt);
+                       }
+               }
+       }
+
+       /**
+        * If this class is inherited from then this method MUST be implemented
+        * in the derived class.
+        */
+       protected Object getRealBinaryParserPage() {
+               return this;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
+        */
+       @Override
+       public void performDefaults() {
+               String cppfilt = null;
+               IProject proj = getContainer().getProject();
+               Preferences store = getContainer().getPreferences();
+               if (store != null) {
+                       if (proj != null) {
+                               cppfilt = store.getString(PREF_CPPFILT_PATH);
+                       } else {
+                               cppfilt = store.getDefaultString(PREF_CPPFILT_PATH);
+                       }
+                       fCPPFiltCommandText.setText((cppfilt == null || cppfilt.length() == 0) ? "c++filt" : cppfilt); //$NON-NLS-1$
+               }
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       public void createControl(Composite parent) {
+               Group comp = new Group(parent, SWT.SHADOW_ETCHED_IN);
+               comp.setText(CUIMessages.BinaryParserBlock_binaryParserOptions); 
+               comp.setLayout(new GridLayout(2, true));
+               comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               ((GridLayout) comp.getLayout()).makeColumnsEqualWidth = false;
+               
+               Label label = ControlFactory.createLabel(comp, CUIMessages.BinaryParserPage_label_cppfiltCommand); 
+               GridData gd = new GridData();
+               gd.horizontalSpan = 2;
+               label.setLayoutData(gd);
+
+               fCPPFiltCommandText = ControlFactory.createTextField(comp, SWT.SINGLE | SWT.BORDER);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               fCPPFiltCommandText.setLayoutData(gd);
+               fCPPFiltCommandText.addModifyListener(new ModifyListener() {
+
+                       public void modifyText(ModifyEvent evt) {
+                               //updateLaunchConfigurationDialog();
+                       }
+               });
+               Button button = ControlFactory.createPushButton(comp, CUIMessages.BinaryParserPage_label_browse); 
+               button.addSelectionListener(new SelectionAdapter() {
+
+                       @Override
+                       public void widgetSelected(SelectionEvent evt) {
+                               handleCPPFiltButtonSelected();
+                               //updateLaunchConfigurationDialog();
+                       }
+
+                       private void handleCPPFiltButtonSelected() {
+                               FileDialog dialog = new FileDialog(getShell(), SWT.NONE);
+                               dialog.setText(CUIMessages.BinaryParserPage_label_cppfiltCommand); 
+                               String command = fCPPFiltCommandText.getText().trim();
+                               int lastSeparatorIndex = command.lastIndexOf(File.separator);
+                               if (lastSeparatorIndex != -1) {
+                                       dialog.setFilterPath(command.substring(0, lastSeparatorIndex));
+                               }
+                               String res = dialog.open();
+                               if (res == null) {
+                                       return;
+                               }
+                               fCPPFiltCommandText.setText(res);
+                       }
+               });
+
+               setControl(comp);
+               initialziedValues();
+       }
+       
+       private void initialziedValues() {
+               String cppfilt = null;
+               IProject proj = getContainer().getProject();
+               if (proj != null) {
+                       try {
+                               ICConfigExtensionReference[] cext = CCorePlugin.getDefault().getDefaultBinaryParserExtensions(proj);
+                               if (cext.length > 0) {
+                                       cppfilt = cext[0].getExtensionData("c++filt"); //$NON-NLS-1$
+                               }
+                       } catch (CoreException e) {
+                       }
+               } else {
+                       Preferences store = getContainer().getPreferences();
+                       if (store != null) {
+                               cppfilt = store.getString(PREF_CPPFILT_PATH);
+                       }
+               }
+               fCPPFiltCommandText.setText((cppfilt == null || cppfilt.length() == 0) ? "c++filt" : cppfilt); //$NON-NLS-1$
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/NullIndexerBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/NullIndexerBlock.java
new file mode 100644 (file)
index 0000000..0de1ddf
--- /dev/null
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.dialogs;
+
+import java.util.Properties;
+
+import org.eclipse.jface.dialogs.ControlEnableState;
+import org.eclipse.swt.widgets.Composite;
+
+
+/**
+ * @author Bogdan Gheorghe
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class NullIndexerBlock extends AbstractIndexerPage {
+
+       @Override
+       public void createControl(Composite parent) {
+               super.createControl(parent);
+               ControlEnableState.disable(getControl());
+       }
+
+       @Override
+       public Properties getProperties() {
+               return new Properties();
+       }
+
+       @Override
+       public void setProperties(Properties properties) {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/PreferenceScopeBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/PreferenceScopeBlock.java
new file mode 100644 (file)
index 0000000..c028cf8
--- /dev/null
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+
+package org.eclipse.cdt.ui.dialogs;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+import org.eclipse.cdt.utils.ui.controls.TabFolderLayout;
+
+abstract public class PreferenceScopeBlock {
+       private Button fUseProjectSettings;
+       private Button fStoreWithProject;
+       private String fPrefPageID;
+       private Link fLink;
+       
+       public PreferenceScopeBlock(String linkedPrefPageID) {
+               fPrefPageID= linkedPrefPageID;
+       }
+       
+       public void createControl(final Composite parent) {
+               Composite group= ControlFactory.createComposite(parent,2);
+               GridLayout layout = (GridLayout)group.getLayout();
+               layout.marginHeight= 0;
+               layout.marginWidth= 0;
+               GridData gd = (GridData) group.getLayoutData();
+               gd.horizontalIndent= 0; 
+
+               fUseProjectSettings= ControlFactory.createCheckBox(group, DialogsMessages.PreferenceScopeBlock_enableProjectSettings);
+               
+               Composite two= ControlFactory.createComposite(group, 1);
+               two.setLayout(new TabFolderLayout());
+               fStoreWithProject= ControlFactory.createCheckBox(two, DialogsMessages.PreferenceScopeBlock_storeWithProject);
+               
+               SelectionListener sl= new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               updateEnablement();
+                               onPreferenceScopeChange();
+                       }
+               };
+               fUseProjectSettings.addSelectionListener(sl);
+               fStoreWithProject.addSelectionListener(sl);
+               
+               fLink= new Link(two, SWT.NONE);
+               fLink.setText(DialogsMessages.PreferenceScopeBlock_preferenceLink);
+               fLink.setLayoutData(new GridData());
+               sl= new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               PreferencesUtil.createPreferenceDialogOn(parent.getShell(), fPrefPageID, null, null).open();
+                               onPreferenceScopeChange();
+                       }
+               };
+               fLink.addSelectionListener(sl);
+               
+               Label horizontalLine= new Label(group, SWT.SEPARATOR | SWT.HORIZONTAL);
+               horizontalLine.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
+               horizontalLine.setFont(group.getFont());
+       }
+
+       abstract protected void onPreferenceScopeChange();
+
+       private void updateEnablement() {
+               if (fUseProjectSettings.getSelection()) {
+                       fLink.setVisible(false);
+                       fStoreWithProject.setVisible(true);
+               }
+               else {
+                       fStoreWithProject.setVisible(false);
+                       fLink.setVisible(true);
+               }
+               fUseProjectSettings.getParent().layout(true);
+       }
+
+       public void setProjectLocalScope() {
+               fUseProjectSettings.setSelection(true);
+               fStoreWithProject.setSelection(false);
+               updateEnablement();
+       }
+
+       public void setProjectScope() {
+               fUseProjectSettings.setSelection(true);
+               fStoreWithProject.setSelection(true);
+               updateEnablement();
+       }
+
+       public void setInstanceScope() {
+               fUseProjectSettings.setSelection(false);
+               fStoreWithProject.setSelection(false);
+               updateEnablement();
+       }
+
+       public boolean isProjectLocalScope() {
+               return fUseProjectSettings.getSelection() && !fStoreWithProject.getSelection();
+       }
+
+       public boolean isProjectScope() {
+               return fUseProjectSettings.getSelection() && fStoreWithProject.getSelection();
+       }
+       
+       public boolean isInstanceScope() {
+               return !fUseProjectSettings.getSelection();
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ReferenceBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ReferenceBlock.java
new file mode 100644 (file)
index 0000000..f5c5bb0
--- /dev/null
@@ -0,0 +1,191 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.dialogs;
+
+import java.util.ArrayList;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.internal.ui.CUIMessages;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+
+/**
+ * @deprecated as of CDT 4.0. This Block was used for New Project Wizard
+ * for 3.X style projects.
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+@Deprecated
+public class ReferenceBlock extends AbstractCOptionPage {
+
+       private static final String PREFIX = "ReferenceBlock"; // $NON-NLS-1$ //$NON-NLS-1$
+       private static final String LABEL = PREFIX + ".label"; // $NON-NLS-1$ //$NON-NLS-1$
+       private static final String DESC = PREFIX + ".desc"; // $NON-NLS-1$ //$NON-NLS-1$
+
+       private CheckboxTableViewer referenceProjectsViewer;
+
+       private static final int PROJECT_LIST_MULTIPLIER = 10;
+       
+       public ReferenceBlock() {
+               super(CUIPlugin.getResourceString(LABEL));
+               setDescription(CUIPlugin.getResourceString(DESC));
+       }
+
+       @Override
+       public Image getImage() {
+               return PlatformUI.getWorkbench().getSharedImages().getImage(IDE.SharedImages.IMG_OBJ_PROJECT);
+       }
+
+       /**
+        * Returns a content provider for the reference project
+        * viewer. It will return all projects in the workspace.
+        *
+        * @return the content provider
+        */
+       protected IStructuredContentProvider getContentProvider() {
+               return new WorkbenchContentProvider() {
+                       @Override
+                       public Object[] getChildren(Object element) {
+                               if (!(element instanceof IWorkspace))
+                                       return new Object[0];
+                               ArrayList<IProject> aList = new ArrayList<IProject>(15);
+                               final IProject[] projects = ((IWorkspace)element).getRoot().getProjects();
+                               for (int i = 0; i < projects.length; i++) {
+                                       if (CoreModel.hasCNature(projects[i])) {
+                                               // Do not show the actual project being look at
+                                               if ((getContainer().getProject() != null) && getContainer().getProject().equals(projects[i])) {
+                                                       continue;
+                                               }
+                                               aList.add(projects[i]);
+                                       }
+                               }
+                               return aList.toArray();
+                       }
+               };
+       }
+
+       protected void initializeValues () {
+               if (getContainer().getProject() != null) {
+                       try {
+                               IProject[] referenced = getContainer().getProject().getReferencedProjects();
+                               referenceProjectsViewer.setCheckedElements(referenced);
+                       } catch (CoreException e) {
+                       }
+               }
+       }
+
+       /**
+        * Returns the referenced projects selected by the user.
+        *
+        * @return the referenced projects
+        */
+       public IProject[] getReferencedProjects() {
+               Object[] elements = referenceProjectsViewer.getCheckedElements();
+               IProject[] projects = new IProject[elements.length];
+               System.arraycopy(elements, 0, projects, 0, elements.length);
+               return projects;        
+       }
+
+       @Override
+       public void createControl(Composite parent) {
+               Composite composite = new Composite(parent, SWT.NONE);
+               composite.setLayout(new GridLayout());
+               composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+               Label label = new Label(composite, SWT.LEFT);
+               label.setText(CUIPlugin.getResourceString(DESC));
+               GridData lbldata = new GridData(GridData.FILL_HORIZONTAL);
+               lbldata.horizontalSpan = 1;
+               label.setLayoutData(lbldata);
+
+
+               referenceProjectsViewer =
+                       CheckboxTableViewer.newCheckList(composite, SWT.TOP | SWT.BORDER);
+               GridData data = new GridData(GridData.FILL_BOTH);
+               data.grabExcessHorizontalSpace = true;
+               data.heightHint =
+                       getDefaultFontHeight(
+                               referenceProjectsViewer.getTable(),
+                               PROJECT_LIST_MULTIPLIER);
+
+               //Only set a height hint if it will not result in a cut off dialog
+               referenceProjectsViewer.getTable().setLayoutData(data);
+
+               referenceProjectsViewer.setLabelProvider(new WorkbenchLabelProvider());
+               referenceProjectsViewer.setContentProvider(getContentProvider());
+               referenceProjectsViewer.setInput(ResourcesPlugin.getWorkspace());
+
+               initializeValues();
+               setControl(composite);
+       }
+
+       /**
+        * Get the defualt widget height for the supplied control.
+        * @return int
+        * @param control - the control being queried about fonts
+        * @param lines - the number of lines to be shown on the table.
+        */
+       private static int getDefaultFontHeight(Control control, int lines) {
+               FontData[] viewerFontData = control.getFont().getFontData();
+               int fontHeight = 10;
+
+               //If we have no font data use our guess
+               if (viewerFontData.length > 0)
+                       fontHeight = viewerFontData[0].getHeight();
+               return lines * fontHeight;
+
+       }
+
+       @Override
+       public void performApply(IProgressMonitor monitor) throws CoreException {
+               IProject[] refProjects = getReferencedProjects();
+               if (refProjects != null) {
+                       IProject project = getContainer().getProject();
+                       if (monitor == null) {
+                               monitor = new NullProgressMonitor();
+                       }
+                       monitor.beginTask(CUIMessages.ReferenceBlock_task_ReferenceProjects, 1); 
+                       try {
+                               IProjectDescription description = project.getDescription();
+                               description.setReferencedProjects(refProjects);
+                               project.setDescription(description, new SubProgressMonitor(monitor, 1));
+                       } catch (CoreException e) {
+                       }
+               }
+               
+       }
+
+       @Override
+       public void performDefaults() {
+               initializeValues();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/RegexErrorParserOptionPage.java
new file mode 100644 (file)
index 0000000..3b0cb51
--- /dev/null
@@ -0,0 +1,777 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 Andrew Gvozdev and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Andrew Gvozdev - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui.dialogs;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.text.FindReplaceDocumentAdapterContentProposalProvider;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.ComboBoxCellEditor;
+import org.eclipse.jface.viewers.EditingSupport;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.eclipse.ui.fieldassist.ContentAssistCommandAdapter;
+
+import com.ibm.icu.text.MessageFormat;
+
+import org.eclipse.cdt.core.ErrorParserManager;
+import org.eclipse.cdt.core.IErrorParserNamed;
+import org.eclipse.cdt.core.IMarkerGenerator;
+import org.eclipse.cdt.core.errorparsers.RegexErrorParser;
+import org.eclipse.cdt.core.errorparsers.RegexErrorPattern;
+import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
+
+import org.eclipse.cdt.internal.ui.util.SWTUtil;
+import org.eclipse.cdt.internal.ui.util.TableLayoutComposite;
+
+/**
+ * Options page for RegexErrorParser in Error Parsers Tab of properties/preferences.
+ *
+ * @since 5.2
+ */
+public final class RegexErrorParserOptionPage extends AbstractCOptionPage {
+
+       private static final String WORKSPACE_PREFERENCE_PAGE = "org.eclipse.cdt.ui.preferences.BuildSettingProperties"; //$NON-NLS-1$
+
+       private static final int BUTTON_ADD = 0;
+       private static final int BUTTON_DELETE = 1;
+       private static final int BUTTON_MOVEUP = 2;
+       private static final int BUTTON_MOVEDOWN = 3;
+
+       private static final String[] BUTTONS = new String[] {
+                       AbstractCPropertyTab.ADD_STR,
+                       AbstractCPropertyTab.DEL_STR,
+                       AbstractCPropertyTab.MOVEUP_STR,
+                       AbstractCPropertyTab.MOVEDOWN_STR,
+               };
+
+       private static final String OOPS = "OOPS"; //$NON-NLS-1$
+
+       private Table fTable;
+       private TableViewer fTableViewer;
+       private Button[] fButtons = null;
+
+       private RegexErrorParser fErrorParser;
+       private boolean fEditable;
+
+       private List<Listener> fListeners = new ArrayList<Listener>();
+
+       /**
+        * Provides generic implementation for overridden methods.
+        * One purpose is to make it easier for subclasses to operate with {@link RegexErrorPattern},
+        * another is to provide content assist.
+        *
+        */
+       private abstract class RegexPatternEditingSupport extends EditingSupport {
+               private final TableViewer tableViewer;
+
+               /**
+                * Constructor.
+                *
+                * @param viewer - table viewer where to provide editing support.
+                * @param isFindStyle - if "find" or "replace" style for potential content assist,
+                *     see {@link FindReplaceDocumentAdapterContentProposalProvider}.
+                */
+               public RegexPatternEditingSupport(TableViewer viewer, boolean isFindStyle) {
+                       super(viewer);
+                       tableViewer = viewer;
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.viewers.EditingSupport#canEdit(java.lang.Object)
+                */
+               @Override
+               protected boolean canEdit(Object element) {
+                       return fEditable;
+               }
+
+               /**
+                * The intention of RegexPatternEditingSupport is to provide Regex content assist
+                * during in-table editing. However having problems with mouse selection and
+                * {@link ContentAssistCommandAdapter} using {@link FindReplaceDocumentAdapterContentProposalProvider}
+                * is removed for time being. See bug 288982 for more details.
+                *
+                * @see org.eclipse.jface.viewers.EditingSupport#getCellEditor(java.lang.Object)
+                */
+               @Override
+               protected CellEditor getCellEditor(Object element) {
+                       CellEditor editor = new TextCellEditor(tableViewer.getTable());
+                       return editor;
+               }
+
+               /**
+                * Get value from {@link RegexErrorPattern}. This is column-specific value.
+                *
+                * @param regexErrorPattern - pattern to query.
+                * @return retrieved value
+                */
+               abstract protected Object getFromPattern(RegexErrorPattern regexErrorPattern);
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.viewers.EditingSupport#getValue(java.lang.Object)
+                */
+               @Override
+               protected Object getValue(Object element) {
+                       if (element instanceof RegexErrorPattern) {
+                               RegexErrorPattern regexErrorPattern = (RegexErrorPattern) element;
+                               return getFromPattern(regexErrorPattern);
+                       }
+                       return OOPS;
+               }
+
+               /**
+                * Set value into one of the pattern's field. Which field - it's column-specific.
+                *
+                * @param regexErrorPattern - pattern to set the field
+                * @param value - value to set
+                */
+               abstract protected void setToPattern(RegexErrorPattern regexErrorPattern, String value);
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.viewers.EditingSupport#setValue(java.lang.Object, java.lang.Object)
+                */
+               @Override
+               protected void setValue(Object element, Object value) {
+                       if (element instanceof RegexErrorPattern && (value instanceof String)) {
+                               String stringValue = (String) value;
+                               RegexErrorPattern errorPattern = (RegexErrorPattern) element;
+                               setToPattern(errorPattern, stringValue);
+                               tableViewer.update(element, null);
+                       }
+               }
+       }
+
+       /**
+        * Constructor.
+        *
+        * @param errorparser - regex error parser for which to display options.
+        * @param editable - if error parser is editable and allowed to change its patterns
+        */
+       public RegexErrorParserOptionPage(RegexErrorParser errorparser, boolean editable) {
+               fErrorParser = errorparser;
+               fEditable = editable;
+       }
+
+       /*
+        * (non-Javadoc)
+        *
+        * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       public void createControl(Composite parent) {
+               Group group = new Group(parent, SWT.SHADOW_ETCHED_IN);
+               group.setText(DialogsMessages.RegexErrorParserOptionPage_Title);
+
+               GridLayout gridLayout = new GridLayout(2, true);
+               gridLayout.makeColumnsEqualWidth = false;
+               gridLayout.marginRight = -10;
+               gridLayout.marginLeft = -4;
+               group.setLayout(gridLayout);
+               group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+               Composite composite = new Composite(group, SWT.NONE);
+               GridLayout layout = new GridLayout();
+               layout.numColumns = 2;
+               layout.marginWidth = 1;
+               layout.marginHeight = 1;
+               layout.marginRight = 1;
+               composite.setLayout(layout);
+               composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+               Dialog.applyDialogFont(composite);
+
+               if (!fEditable)
+                       createLinkToPreferences(composite);
+
+               createPatternsTable(group, composite);
+
+               if (fEditable) {
+                       createButtons(composite);
+               }
+
+               setControl(group);
+               group.update();
+       }
+
+       private void createLinkToPreferences(final Composite parent) {
+                // must not be editable as error parser gets desynchronized with ErrorParsTab
+               Assert.isTrue(!fEditable);
+
+               Link link = new Link(parent, SWT.NONE);
+               link.setText(DialogsMessages.RegexErrorParserOptionPage_LinkToPreferencesMessage);
+
+               link.addListener(SWT.Selection, new Listener() {
+                       public void handleEvent(Event event) {
+                               // Use event.text to tell which link was used
+                               PreferencesUtil.createPreferenceDialogOn(parent.getShell(), WORKSPACE_PREFERENCE_PAGE, null, null).open();
+
+                               IErrorParserNamed errorParser = ErrorParserManager.getErrorParserCopy(fErrorParser.getId());
+                               if (errorParser instanceof RegexErrorParser)
+                                       fErrorParser = (RegexErrorParser) errorParser;
+                               else
+                                       fErrorParser = null;
+
+                               initializeTable();
+                               fireEvent();
+                       }
+               });
+
+               GridData gridData = new GridData(SWT.FILL, SWT.BOTTOM, true, false);
+               gridData.horizontalSpan = 2;
+               link.setLayoutData(gridData);
+       }
+
+       private static RegexErrorPattern newDummyPattern() {
+               return new RegexErrorPattern(null, null, null, null, null, IMarker.SEVERITY_ERROR, true);
+       }
+
+       private static String severityToString(int severity) {
+               switch (severity) {
+               case IMarkerGenerator.SEVERITY_INFO:
+                       return DialogsMessages.RegexErrorParserOptionPage_SeverityInfo;
+               case IMarkerGenerator.SEVERITY_WARNING:
+                       return DialogsMessages.RegexErrorParserOptionPage_SeverityWarning;
+               case IMarkerGenerator.SEVERITY_ERROR_BUILD:
+               case IMarkerGenerator.SEVERITY_ERROR_RESOURCE:
+                       return DialogsMessages.RegexErrorParserOptionPage_SeverityError;
+               }
+               return DialogsMessages.RegexErrorParserOptionPage_SeverityIgnore;
+       }
+
+       private void initializeTable() {
+               RegexErrorPattern[] errorParserPatterns = fErrorParser!=null
+                       ? errorParserPatterns = fErrorParser.getPatterns()
+                       : new RegexErrorPattern[0];
+
+               int len = errorParserPatterns.length;
+               int newLen = len;
+
+               RegexErrorPattern[] tablePatterns = new RegexErrorPattern[newLen];
+               System.arraycopy(errorParserPatterns, 0, tablePatterns, 0, len);
+
+               fTableViewer.setInput(tablePatterns);
+               fTableViewer.refresh();
+       }
+
+       private void createPatternsTable(Group group, Composite parent) {
+               TableLayoutComposite tableLayouter = new TableLayoutComposite(parent, SWT.NONE);
+               tableLayouter.addColumnData(new ColumnWeightData(10, true)); // severity
+               tableLayouter.addColumnData(new ColumnWeightData(40, true)); // pattern
+               tableLayouter.addColumnData(new ColumnWeightData(10, true)); // file
+               tableLayouter.addColumnData(new ColumnWeightData(10, true)); // line
+               tableLayouter.addColumnData(new ColumnWeightData(15, true)); // description
+               tableLayouter.addColumnData(new ColumnWeightData(10, true)); // eat line
+
+               int style= SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER;
+               if (fEditable) {
+                       style = style | SWT.FULL_SELECTION;
+               }
+               fTable = new Table(tableLayouter, style);
+               fTable.setHeaderVisible(true);
+               fTable.setLinesVisible(true);
+               fTable.setEnabled(fEditable);
+
+               GridData gridData = new GridData(GridData.FILL_BOTH);
+               gridData.heightHint = SWTUtil.getTableHeightHint(fTable, 10);
+               gridData.widthHint = new PixelConverter(group).convertWidthInCharsToPixels(100);
+               tableLayouter.setLayoutData(gridData);
+               fTable.setLayout(new TableLayout());
+
+               fTable.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               updateButtons();
+                       }
+               });
+
+               fTableViewer = new TableViewer(fTable);
+               fTableViewer.setUseHashlookup(true);
+               fTableViewer.setContentProvider(new ArrayContentProvider());
+
+               createSeverityColumn();
+               createPatternColumn();
+               createFileColumn();
+               createLineColumn();
+               createDescriptionColumn();
+               createEatLineColumn();
+
+               initializeTable();
+       }
+
+       private void createSeverityColumn() {
+               TableViewerColumn columnViewer = new TableViewerColumn(fTableViewer, SWT.NONE);
+               columnViewer.getColumn().setText(DialogsMessages.RegexErrorParserOptionPage_SeverityColumn);
+               columnViewer.getColumn().setResizable(true);
+               columnViewer.getColumn().setToolTipText(DialogsMessages.RegexErrorParserOptionPage_TooltipSeverity);
+               columnViewer.setLabelProvider(new ColumnLabelProvider() {
+                       final ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
+
+                       @Override
+                       public Image getImage(Object element) {
+                               if (element instanceof RegexErrorPattern) {
+                                       RegexErrorPattern regexErrorPattern = (RegexErrorPattern) element;
+                                       switch (regexErrorPattern.getSeverity()) {
+                                       case IMarkerGenerator.SEVERITY_INFO:
+                                               return images.getImage(ISharedImages.IMG_OBJS_INFO_TSK);
+                                       case IMarkerGenerator.SEVERITY_WARNING:
+                                               return images.getImage(ISharedImages.IMG_OBJS_WARN_TSK);
+                                       case IMarkerGenerator.SEVERITY_ERROR_BUILD:
+                                       case IMarkerGenerator.SEVERITY_ERROR_RESOURCE:
+                                               return images.getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
+                                       case RegexErrorPattern.SEVERITY_SKIP:
+                                                       return images.getImage(ISharedImages.IMG_ELCL_REMOVE_DISABLED);
+                                       }
+                               }
+                               return null;
+                       }
+
+                       @Override
+                       public String getText(Object element) {
+                               if (element instanceof RegexErrorPattern) {
+                                       RegexErrorPattern regex = (RegexErrorPattern) element;
+                                       return severityToString(regex.getSeverity());
+                               }
+                               return severityToString(RegexErrorPattern.SEVERITY_SKIP);
+                       }
+               });
+               columnViewer.setEditingSupport(new EditingSupport(fTableViewer) {
+                       final String[] severityComboBoxArray = new String[] {
+                                       severityToString(IMarkerGenerator.SEVERITY_ERROR_RESOURCE),
+                                       severityToString(IMarkerGenerator.SEVERITY_WARNING),
+                                       severityToString(IMarkerGenerator.SEVERITY_INFO),
+                                       severityToString(RegexErrorPattern.SEVERITY_SKIP),
+                               };
+
+                       private int severityToIndex(int severity) {
+                               String strSeverity = severityToString(severity);
+                               for (int i = 0; i < severityComboBoxArray.length; i++) {
+                                       if (strSeverity.equals(severityComboBoxArray[i]))
+                                               return i;
+                               }
+                               return 0;
+                       }
+
+                       private int indexToSeverity(int index) {
+                               String strCombo = severityComboBoxArray[index];
+                               for (int i = 0; i < severityComboBoxArray.length; i++) {
+                                       if (severityToString(i).equals(strCombo))
+                                               return i;
+                               }
+                               return RegexErrorPattern.SEVERITY_SKIP;
+                       }
+
+                       @Override
+                       protected boolean canEdit(Object element) {
+                               return (element instanceof RegexErrorPattern) && fEditable;
+                       }
+
+                       @Override
+                       protected CellEditor getCellEditor(Object element) {
+                               return new ComboBoxCellEditor(fTableViewer.getTable(), severityComboBoxArray, SWT.READ_ONLY);
+                       }
+
+                       @Override
+                       protected Object getValue(Object element) {
+                               if (element instanceof RegexErrorPattern)
+                                       return severityToIndex(((RegexErrorPattern) element).getSeverity());
+                               return RegexErrorPattern.SEVERITY_SKIP;
+                       }
+
+                       @Override
+                       protected void setValue(Object element, Object value) {
+                               if (element instanceof RegexErrorPattern && (value instanceof Integer)) {
+                                       ((RegexErrorPattern) element).setSeverity(indexToSeverity(((Integer) value).intValue()));
+                                       fTableViewer.update(element, null);
+                               }
+                       }
+
+               });
+       }
+
+       private void createPatternColumn() {
+               TableViewerColumn columnViewer = new TableViewerColumn(fTableViewer, SWT.NONE);
+               columnViewer.getColumn().setText(DialogsMessages.RegexErrorParserOptionPage_Pattern_Column);
+               columnViewer.getColumn().setResizable(true);
+               columnViewer.getColumn().setToolTipText(DialogsMessages.RegexErrorParserOptionPage_TooltipPattern);
+               columnViewer.setLabelProvider(new ColumnLabelProvider() {
+
+                       @Override
+                       public String getText(Object element) {
+                               if (element instanceof RegexErrorPattern) {
+                                       RegexErrorPattern regex = (RegexErrorPattern) element;
+                                       String pattern = regex.getPattern();
+                                       return pattern;
+                               }
+                               return OOPS;
+                       }
+               });
+
+               columnViewer.setEditingSupport(new RegexPatternEditingSupport(fTableViewer, true) {
+                       @Override
+                       protected Object getFromPattern(RegexErrorPattern regexErrorPattern) {
+                               return regexErrorPattern.getPattern();
+                       }
+
+                       @Override
+                       protected void setToPattern(RegexErrorPattern regexErrorPattern, String value) {
+                               if (!fEditable)
+                                       return;
+                               try{
+                                       regexErrorPattern.setPattern(value);
+                               } catch (Exception e) {
+                                       // to avoid recursive edits. the dialog is needed to ensure valid pattern on losing focus.
+                                       // this looks ugly and likely incorrect
+                                       fEditable = false;
+                                       RegularExpressionStatusDialog dialog= new RegularExpressionStatusDialog(getShell(), value);
+                                       if (dialog.open() == Window.OK) {
+                                               regexErrorPattern.setPattern(dialog.getValue());
+                                       }
+                                       fEditable = true;
+                               }
+                       }
+               });
+       }
+
+       private void createFileColumn() {
+               TableViewerColumn columnViewer = new TableViewerColumn(fTableViewer, SWT.NONE);
+               columnViewer.getColumn().setText(DialogsMessages.RegexErrorParserOptionPage_FileColumn);
+               columnViewer.getColumn().setToolTipText(DialogsMessages.RegexErrorParserOptionPage_TooltipFile);
+               columnViewer.getColumn().setResizable(true);
+               columnViewer.setLabelProvider(new ColumnLabelProvider() {
+
+                       @Override
+                       public String getText(Object element) {
+                               if (element instanceof RegexErrorPattern) {
+                                       RegexErrorPattern regex = (RegexErrorPattern) element;
+                                       return regex.getFileExpression();
+                               }
+                               return OOPS;
+                       }
+               });
+               columnViewer.setEditingSupport(new RegexPatternEditingSupport(fTableViewer, false) {
+                       @Override
+                       protected Object getFromPattern(RegexErrorPattern regexErrorPattern) {
+                               return regexErrorPattern.getFileExpression();
+                       }
+
+                       @Override
+                       protected void setToPattern(RegexErrorPattern regexErrorPattern, String value) {
+                               regexErrorPattern.setFileExpression(value);
+                       }
+               });
+       }
+
+       private void createLineColumn() {
+               TableViewerColumn columnViewer = new TableViewerColumn(fTableViewer, SWT.NONE);
+               columnViewer.getColumn().setText(DialogsMessages.RegexErrorParserOptionPage_LineColumn);
+               columnViewer.getColumn().setResizable(true);
+               columnViewer.getColumn().setToolTipText(DialogsMessages.RegexErrorParserOptionPage_TooltipLine);
+               columnViewer.setLabelProvider(new ColumnLabelProvider() {
+
+                       @Override
+                       public String getText(Object element) {
+                               if (element instanceof RegexErrorPattern) {
+                                       RegexErrorPattern regex = (RegexErrorPattern) element;
+                                       return regex.getLineExpression();
+                               }
+                               return OOPS;
+                       }
+               });
+               columnViewer.setEditingSupport(new RegexPatternEditingSupport(fTableViewer, false) {
+                       @Override
+                       protected Object getFromPattern(RegexErrorPattern regexErrorPattern) {
+                               return regexErrorPattern.getLineExpression();
+                       }
+
+                       @Override
+                       protected void setToPattern(RegexErrorPattern regexErrorPattern, String value) {
+                               regexErrorPattern.setLineExpression(value);
+                       }
+               });
+       }
+
+       private void createDescriptionColumn() {
+               TableViewerColumn columnViewer = new TableViewerColumn(fTableViewer, SWT.NONE);
+               columnViewer.getColumn().setText(DialogsMessages.RegexErrorParserOptionPage_DescriptionColumn);
+               columnViewer.getColumn().setResizable(true);
+               columnViewer.getColumn().setToolTipText(DialogsMessages.RegexErrorParserOptionPage_TooltipDescription);
+               columnViewer.setLabelProvider(new ColumnLabelProvider() {
+
+                       @Override
+                       public String getText(Object element) {
+                               if (element instanceof RegexErrorPattern) {
+                                       RegexErrorPattern regex = (RegexErrorPattern) element;
+                                       return regex.getDescriptionExpression();
+                               }
+                               return OOPS;
+                       }
+               });
+               columnViewer.setEditingSupport(new RegexPatternEditingSupport(fTableViewer, false) {
+                       @Override
+                       protected Object getFromPattern(RegexErrorPattern regexErrorPattern) {
+                               return regexErrorPattern.getDescriptionExpression();
+                       }
+
+                       @Override
+                       protected void setToPattern(RegexErrorPattern regexErrorPattern, String value) {
+                               regexErrorPattern.setDescriptionExpression(value);
+                       }
+               });
+       }
+
+       private void createEatLineColumn() {
+               final String EAT_NO = DialogsMessages.RegexErrorParserOptionPage_ConsumeNo;
+               final String EAT_YES = DialogsMessages.RegexErrorParserOptionPage_ConsumeYes;
+
+               final String[] eatLineComboBoxArray = new String[] { EAT_YES, EAT_NO, };
+               final int EAT_YES_INDEX = 0;
+               final int EAT_NO_INDEX = 1;
+
+               TableViewerColumn columnViewer = new TableViewerColumn(fTableViewer, SWT.NONE);
+               columnViewer.getColumn().setText(DialogsMessages.RegexErrorParserOptionPage_EatColumn);
+               columnViewer.getColumn().setResizable(true);
+
+               String message = MessageFormat.format(DialogsMessages.RegexErrorParserOptionPage_TooltipConsume, new Object[] { EAT_NO });
+               columnViewer.getColumn().setToolTipText(message);
+               columnViewer.setLabelProvider(new ColumnLabelProvider() {
+
+                       @Override
+                       public String getText(Object element) {
+                               if (element instanceof RegexErrorPattern) {
+                                       RegexErrorPattern regex = (RegexErrorPattern) element;
+                                       if (!regex.isEatProcessedLine())
+                                               return EAT_NO;
+                               }
+                               return EAT_YES;
+                       }
+               });
+               columnViewer.setEditingSupport(new EditingSupport(fTableViewer) {
+                       @Override
+                       protected boolean canEdit(Object element) {
+                               return (element instanceof RegexErrorPattern) && fEditable;
+                       }
+
+                       @Override
+                       protected CellEditor getCellEditor(Object element) {
+                               return new ComboBoxCellEditor(fTableViewer.getTable(), eatLineComboBoxArray, SWT.READ_ONLY);
+                       }
+
+                       @Override
+                       protected Object getValue(Object element) {
+                               if (element instanceof RegexErrorPattern)
+                                       if (!((RegexErrorPattern) element).isEatProcessedLine())
+                                               return EAT_NO_INDEX;
+                               return EAT_YES_INDEX;
+                       }
+
+                       @Override
+                       protected void setValue(Object element, Object value) {
+                               if ((element instanceof RegexErrorPattern) && (value instanceof Integer)) {
+                                       ((RegexErrorPattern) element).setEatProcessedLine((Integer) value != EAT_NO_INDEX);
+                                       fTableViewer.update(element, null);
+                               }
+                       }
+
+               });
+       }
+
+       private void createButtons(Composite parent) {
+               Composite composite = new Composite(parent, SWT.NONE);
+               composite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
+               composite.setLayout(new GridLayout(1, false));
+
+               fButtons = new Button[BUTTONS.length];
+               for (int i = 0; i < BUTTONS.length; i++) {
+                       fButtons[i] = new Button(composite, SWT.PUSH);
+                       GridData gridData = new GridData(SWT.FILL, SWT.CENTER, false, false);
+                       gridData.minimumWidth = 80;
+
+                       if (BUTTONS[i] != null) {
+                               fButtons[i].setText(BUTTONS[i]);
+                               fButtons[i].setEnabled(false);
+                       } else {
+                               // no button, but placeholder
+                               fButtons[i].setVisible(false);
+                               fButtons[i].setEnabled(false);
+                               gridData.heightHint = 10;
+                       }
+
+                       fButtons[i].setLayoutData(gridData);
+                       fButtons[i].addSelectionListener(new SelectionAdapter() {
+                               @Override
+                               public void widgetSelected(SelectionEvent event) {
+                                       for (int i=0; i<fButtons.length; i++) {
+                                               if (fButtons[i].equals(event.widget)) {
+                                                       buttonPressed(i);
+                                                       return;
+                                               }
+                                       }
+                               }
+                       });
+               }
+               updateButtons();
+       }
+
+       private void updateButtons() {
+               if (fButtons!=null) {
+                       int pos = fTable.getSelectionIndex();
+                       int count = fTable.getItemCount();
+                       int last = count-1;
+                       boolean selected = pos>=0 && pos<=last;
+
+                       fButtons[BUTTON_ADD].setEnabled(true);
+                       fButtons[BUTTON_DELETE].setEnabled(selected);
+                       fButtons[BUTTON_MOVEUP].setEnabled(selected && pos != 0);
+                       fButtons[BUTTON_MOVEDOWN].setEnabled(selected && pos != last);
+               }
+       }
+
+       private void buttonPressed (int button) {
+               switch (button) {
+               case BUTTON_ADD:
+                       addErrorPattern();
+                       break;
+               case BUTTON_DELETE:
+                       deleteErrorPattern();
+                       break;
+               case BUTTON_MOVEUP:
+                       moveItem(true);
+                       break;
+               case BUTTON_MOVEDOWN:
+                       moveItem(false);
+                       break;
+               default:
+                       return;
+               }
+               applyPatterns();
+               updateButtons();
+               fireEvent();
+       }
+
+       private void addErrorPattern() {
+               int pos = fTable.getSelectionIndex();
+               int last = fTable.getItemCount()-1;
+               if (pos<0 || pos>last)
+                       pos = last;
+
+               int newPos = pos + 1;
+               fTableViewer.insert(newDummyPattern(), newPos);
+               fTable.setSelection(newPos);
+       }
+
+       private void deleteErrorPattern() {
+               int pos = fTable.getSelectionIndex();
+               int last = fTable.getItemCount()-1;
+
+               if (pos>=0 && pos<=last) {
+                       fTableViewer.remove(fTableViewer.getElementAt(pos));
+                       fTable.setSelection(pos);
+               }
+       }
+
+       private void moveItem(boolean up) {
+               int pos = fTable.getSelectionIndex();
+               int count = fTable.getItemCount();
+               int last = count-1;
+               boolean selected = pos>=0 && pos<=last;
+
+               if (!selected || (up && pos==0) || (!up && pos==last))
+                       return;
+
+               Object item = fTableViewer.getElementAt(pos);
+               fTableViewer.remove(item);
+               int newPos = up ? pos-1 : pos+1;
+               fTableViewer.insert(item, newPos);
+               fTable.setSelection(newPos);
+       }
+       
+       private void applyPatterns() {
+               if (fErrorParser!=null && fEditable) {
+                       fErrorParser.clearPatterns();
+                       for (TableItem tableItem : fTable.getItems()) {
+                               Object item = tableItem.getData();
+                               if (item instanceof RegexErrorPattern) {
+                                       fErrorParser.addPattern((RegexErrorPattern)item);
+                               }
+                       }
+               }
+       }
+
+       /*
+        * (non-Javadoc)
+        *
+        * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
+        */
+       @Override
+       public void performApply(IProgressMonitor monitor) throws CoreException {
+               applyPatterns();
+       }
+
+       /*
+        * (non-Javadoc)
+        *
+        * @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
+        */
+       @Override
+       public void performDefaults() {
+               // ErrorParsTas.performDefaults() will do all the work
+       }
+
+       /**
+        * @since 5.3
+        */
+       public void addListener(Listener listener){
+               fListeners.add(listener);
+       }
+
+       /**
+        * @since 5.3
+        */
+       public void removeListener(Listener listener){
+               fListeners.remove(listener);
+       }
+       
+       private void fireEvent() {
+               for (Listener listener : fListeners) {
+                       listener.handleEvent(new Event());
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/RegularExpressionStatusDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/RegularExpressionStatusDialog.java
new file mode 100644 (file)
index 0000000..3d67b9f
--- /dev/null
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 Andrew Gvozdev and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Andrew Gvozdev - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui.dialogs;
+
+import java.util.regex.Pattern;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.fieldassist.TextContentAdapter;
+import org.eclipse.jface.text.FindReplaceDocumentAdapterContentProposalProvider;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.fieldassist.ContentAssistCommandAdapter;
+
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+
+/**
+ * Input Dialog for validating regular expression syntax.
+ * 
+ * @since 5.2
+ */
+public class RegularExpressionStatusDialog extends InputStatusDialog {
+       private static final IInputStatusValidator fValidator = new IInputStatusValidator() {
+               public IStatus isValid(String newText) {
+                       StatusInfo status = new StatusInfo();
+                       if (newText.length() == 0) {
+                               status.setWarning(DialogsMessages.RegularExpression_EmptyPattern);
+                       } else {
+                               try {
+                                       Pattern.compile(newText);
+                               } catch (Exception e) {
+                                       // only first line of PatternSyntaxException is really descriptive
+                                       status.setError(e.getMessage().split("[\n\r]", 2)[0]); //$NON-NLS-1$
+                               }
+                       }
+                       return status;
+               }
+       };
+
+       /**
+        * Constructor
+        *
+        * @param shell - the parent shell, or <code>null</code> to create a top-level shell
+        * @param initialValue the initial input value, or <code>null</code> if none
+        *            (equivalent to the empty string)
+        */
+       public RegularExpressionStatusDialog(Shell shell, String initialValue) {
+               super(shell, DialogsMessages.RegularExpression_Validate,
+                               DialogsMessages.RegularExpression_Enter,
+                               initialValue, fValidator);
+       }
+
+       /**
+        * Constructor
+        *
+        * @param shell - the parent shell, or <code>null</code> to create a top-level shell
+        * @param dialogTitle - the dialog title, or <code>null</code> if none
+        * @param dialogMessage - the dialog message, or <code>null</code> if none
+        * @param initialValue the initial input value, or <code>null</code> if none
+        *            (equivalent to the empty string)
+        */
+       public RegularExpressionStatusDialog(Shell shell, String dialogTitle, String dialogMessage, String initialValue) {
+               super(shell, dialogTitle, dialogMessage, initialValue, fValidator);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.internal.ui.dialogs.InputStatusDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected Control createDialogArea(Composite parent) {
+               Control control = super.createDialogArea(parent);
+
+               new ContentAssistCommandAdapter(
+                               getText(),
+                               new TextContentAdapter(),
+                               new FindReplaceDocumentAdapterContentProposalProvider(true),
+                               null,
+                               null,
+                               true);
+
+
+               setHelpAvailable(false);
+               return control;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.StatusDialog#create()
+        */
+       @Override
+       public void create() {
+               super.create();
+               if (getValue().length()>0)
+                       validateInput();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/TabFolderOptionBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/TabFolderOptionBlock.java
new file mode 100644 (file)
index 0000000..05428c7
--- /dev/null
@@ -0,0 +1,252 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.dialogs;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.internal.ui.CUIMessages;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.utils.ui.controls.TabFolderLayout;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+
+/**
+ * @deprecated as of CDT 4.0. This abstract block was used for New Project Wizards
+ * and property pages for 3.X style projects.
+ */
+@Deprecated
+public abstract class TabFolderOptionBlock {
+
+       protected boolean initializingTabs = true;
+       private Composite composite;
+       private boolean bShowMessageArea;
+       private String fErrorMessage;
+       private boolean bIsValid = true;
+
+       private Label messageLabel;
+       private ArrayList<ICOptionPage> pages = new ArrayList<ICOptionPage>();
+       protected ICOptionContainer fParent;
+       private ICOptionPage fCurrentPage;
+
+       private TabFolder fFolder;
+
+       public TabFolderOptionBlock(boolean showMessageArea) {
+               bShowMessageArea = showMessageArea;
+       }
+
+       public TabFolderOptionBlock(ICOptionContainer parent, boolean showMessageArea) {
+               bShowMessageArea = showMessageArea;
+               setOptionContainer(parent);
+       }
+
+       /**
+        * @param parent
+        */
+       public void setOptionContainer(ICOptionContainer parent) {
+               fParent = parent;
+       }
+
+       public TabFolderOptionBlock(ICOptionContainer parent) {
+               this(parent, true);
+       }
+
+       protected void addOptionPage(ICOptionPage page) {
+               if (!pages.contains(page)) {
+                       pages.add(page);
+               }
+       }
+
+       protected List<ICOptionPage> getOptionPages() {
+               return pages;
+       }
+
+       public Control createContents(Composite parent) {
+
+               composite = new Composite(parent, SWT.NONE);
+               composite.setLayout(new GridLayout(1, false));
+
+               if (bShowMessageArea) {
+                       messageLabel = new Label(composite, SWT.LEFT);
+                       messageLabel.setFont(composite.getFont());
+                       messageLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+                       Label separator = new Label(composite, SWT.HORIZONTAL);
+                       separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               }
+
+               createFolder(composite);
+
+               addTabs();
+               setCurrentPage(pages.get(0));
+               initializingTabs = false;
+               String desc = pages.get(0).getDescription();
+               if (messageLabel != null && desc != null) {
+                       messageLabel.setText(desc);
+               }
+               return composite;
+       }
+
+       protected ICOptionPage getStartPage() {
+               return pages.get(0);
+       }
+
+       public int getPageIndex() {
+               return pages.indexOf(getCurrentPage());
+       }
+
+       protected void createFolder(Composite parent) {
+               fFolder = new TabFolder(parent, SWT.NONE);
+               fFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
+               fFolder.setLayout(new TabFolderLayout());
+
+               fFolder.addSelectionListener(new SelectionAdapter() {
+
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               if (!initializingTabs) {
+                                       setCurrentPage((ICOptionPage) ((TabItem)e.item).getData());
+                                       fParent.updateContainer();
+                               }
+                       }
+               });
+       }
+
+       protected void addTab(ICOptionPage tab) {
+               TabItem item = new TabItem(fFolder, SWT.NONE);
+               item.setText(tab.getTitle());
+               Image img = tab.getImage();
+               if (img != null)
+                       item.setImage(img);
+               item.setData(tab);
+               tab.setContainer(fParent);
+               tab.createControl(item.getParent());
+               item.setControl(tab.getControl());
+               addOptionPage(tab);
+       }
+
+       abstract protected void addTabs();
+
+       public boolean performApply(IProgressMonitor monitor) {
+               if (initializingTabs)
+                       return false;
+               if (monitor == null) {
+                       monitor = new NullProgressMonitor();
+               }
+               monitor.beginTask("", pages.size()); //$NON-NLS-1$
+               try {
+                       Iterator<ICOptionPage> iter = pages.iterator();
+                       while (iter.hasNext()) {
+                               ICOptionPage tab = iter.next();
+                               try {
+                                       tab.performApply(new SubProgressMonitor(monitor, 1));
+                               } catch (CoreException e) {
+                                       CUIPlugin.errorDialog(
+                                                       composite.getShell(),
+                                                       CUIMessages.TabFolderOptionBlock_error, CUIMessages.TabFolderOptionBlock_error_settingOptions, e, true); 
+                                       return false;
+                               }
+                       }
+               } finally {
+                       monitor.done();
+               }
+               return true;
+       }
+
+       public void setVisible(boolean visible) {
+               if (initializingTabs)
+                       return;
+               if (fCurrentPage != null) {
+                       fCurrentPage.setVisible(visible);
+               }
+               update();
+       }
+
+       public void update() {
+               if (initializingTabs)
+                       return;
+               boolean ok = true;
+               Iterator<ICOptionPage> iter = pages.iterator();
+               while (iter.hasNext()) {
+                       ICOptionPage tab = iter.next();
+                       ok = tab.isValid();
+                       if (!ok) {
+                String errorMessage = tab.getErrorMessage();
+                if (!tab.getControl().isVisible()) {
+                    setErrorMessage(NLS.bind(
+                            CUIMessages.TabFolderOptionBlock_error_message, tab.getTitle()));
+                } else {
+                    setErrorMessage(errorMessage);
+                }
+                               break;
+                       }
+               }
+               if (ok) {
+                       setErrorMessage(null);
+                       ICOptionPage tab = getCurrentPage();
+                       if (messageLabel != null) {
+                               messageLabel.setText(tab.getDescription() != null ? tab.getDescription() : ""); //$NON-NLS-1$
+                       }
+               }
+               setValid(ok);
+       }
+
+       private void setValid(boolean ok) {
+               bIsValid = ok;
+       }
+
+       private void setErrorMessage(String message) {
+               fErrorMessage = message;
+       }
+
+       public String getErrorMessage() {
+               return fErrorMessage;
+       }
+
+       public boolean isValid() {
+               return bIsValid;
+       }
+
+       public void performDefaults() {
+               if (initializingTabs)
+                       return;
+               getCurrentPage().performDefaults();
+       }
+
+       public ICOptionPage getCurrentPage() {
+               return fCurrentPage;
+       }
+
+       public void setCurrentPage(ICOptionPage page) {
+               //Make the new page visible
+               ICOptionPage oldPage = fCurrentPage;
+               fCurrentPage = page;
+               fCurrentPage.setVisible(true);
+               if (oldPage != null)
+                       oldPage.setVisible(false);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/internal/templateengine/wizard/TemplateCNewWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/internal/templateengine/wizard/TemplateCNewWizard.java
new file mode 100644 (file)
index 0000000..df09102
--- /dev/null
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.internal.templateengine.wizard;
+
+import java.util.ArrayList;
+
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.swt.widgets.Composite;
+
+import org.eclipse.cdt.core.templateengine.TemplateInfo;
+import org.eclipse.cdt.ui.templateengine.Template;
+import org.eclipse.cdt.ui.templateengine.TemplateEngineUI;
+import org.eclipse.cdt.ui.wizards.EntryDescriptor;
+import org.eclipse.cdt.ui.wizards.CNewWizard;
+import org.eclipse.cdt.ui.wizards.IWizardItemsListListener;
+
+/**
+ *
+ */
+public class TemplateCNewWizard extends CNewWizard {
+       /**
+        * Creates and returns an array of items to be displayed 
+        */
+       @Override
+       public EntryDescriptor[] createItems(boolean supportedOnly, IWizard wizard) {
+               Template[] templates = TemplateEngineUI.getDefault().getTemplates();
+               ArrayList<EntryDescriptor> items = new ArrayList<EntryDescriptor>();
+               
+               for (int k=0; k < templates.length; k++) {
+                       TemplateInfo templateInfo = templates[k].getTemplateInfo();
+
+                       items.add(new EntryDescriptor(templates[k].getTemplateId(),
+                                               templateInfo.getProjectType(),
+                                               templates[k].getLabel(),
+                                               templateInfo.isCategory(),
+                                               null,
+                                               null));
+               }
+               return items.toArray(new EntryDescriptor[items.size()]);
+       }
+
+       @Override
+       public void setDependentControl(Composite parent,
+                       IWizardItemsListListener page) {
+               //nothing to do?
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractCPropertyTab.java
new file mode 100644 (file)
index 0000000..2ff7b9c
--- /dev/null
@@ -0,0 +1,739 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *     James Blackburn (Broadcom Corp.)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.lang.reflect.Method;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.FontMetrics;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.eclipse.ui.part.PageBook;
+import org.eclipse.ui.views.navigator.ResourceComparator;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+
+import org.eclipse.cdt.internal.core.resources.ResourceLookup;
+
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * It is a parent for all standard property tabs 
+ * in new CDT model.
+ * 
+ * Although it's enough for new tabs to implement
+ * ICPropertyTab interface only, it would be better 
+ * to extend them from this class.
+ *
+ * In this case, we'll able to use:
+ * - a lot of utility methods via "provider" link.
+ *   In particular, it allows to get current project,
+ *   configuration etc. See ICPropertyProvider interface. 
+ * - a standard way to create buttons (ins/edit/del etc)
+ *   and to handle their events (see buttonPressed(int))
+ * - several utility methods to create widgets in the
+ *   uniform manner (setupLabel(), setupText() etc). 
+ * - means to handle control messages which are the main
+ *   communication way for new CDT model pages and tabs.   
+ */
+public abstract class AbstractCPropertyTab implements ICPropertyTab {
+       
+       public static final Method GRAY_METHOD = getGrayEnabled();
+       public static final int BUTTON_WIDTH = 120; // used as hint for all push buttons
+
+       // commonly used button names
+       public static final String EMPTY_STR = ""; //$NON-NLS-1$
+       public static final String ADD_STR = Messages.FileListControl_add; 
+       public static final String DEL_STR = Messages.FileListControl_delete; 
+       public static final String EDIT_STR = Messages.FileListControl_edit; 
+       public static final String MOVEUP_STR = Messages.FileListControl_moveup; 
+       public static final String MOVEDOWN_STR = Messages.FileListControl_movedown; 
+       public static final String WORKSPACEBUTTON_NAME = Messages.FileListControl_button_workspace; 
+       public static final String FILESYSTEMBUTTON_NAME = Messages.FileListControl_button_fs; 
+       public static final String VARIABLESBUTTON_NAME = Messages.AbstractCPropertyTab_1; 
+       public static final String FILESYSTEM_DIR_DIALOG_MSG = Messages.BrowseEntryDialog_fs_dir_dlg_msg;       
+       public static final String FILESYSTEM_FILE_DIALOG_TITLE = EMPTY_STR;    
+       public static final String WORKSPACE_DIR_DIALOG_TITLE = Messages.BrowseEntryDialog_wsp_dir_dlg_title;   
+       public static final String WORKSPACE_FILE_DIALOG_TITLE = Messages.BrowseEntryDialog_wsp_file_dlg_title; 
+       public static final String WORKSPACE_DIR_DIALOG_MSG = Messages.BrowseEntryDialog_wsp_dir_dlg_msg;       
+       public static final String WORKSPACE_FILE_DIALOG_MSG = Messages.BrowseEntryDialog_wsp_file_dlg_msg;     
+       public static final String WORKSPACE_FILE_DIALOG_ERR = Messages.BrowseEntryDialog_wsp_file_dlg_err;     
+       public static final String WORKSPACE_DIR_DIALOG_ERR = Messages.BrowseEntryDialog_wsp_dir_dlg_err;       
+       public static final String BACKGROUND_TEXT_DEFAULT = Messages.AbstractCPropertyTab_2; 
+       public static final Color BACKGROUND_FOR_USER_VAR = new Color(Display.getDefault(), 255, 255, 200); // light yellow
+
+       private static final String PREFIX = "org.eclipse.cdt.ui."; //$NON-NLS-1$
+       
+       public static final int TRI_UNKNOWN = 2;
+       public static final int TRI_YES = 1;
+       public static final int TRI_NO = 0;
+
+       protected static final String ENUM = "enum"; //$NON-NLS-1$
+       protected static final String SSET = "set";  //$NON-NLS-1$
+       
+       private PageBook pageBook; // to select between background and usercomp.
+       private CLabel  background;
+       private Composite userdata;
+       
+       protected Composite usercomp; // space where user can create widgets 
+       protected Composite buttoncomp; // space for buttons on the right
+       private Button[] buttons;     // buttons in buttoncomp
+       public ICPropertyProvider page;
+       protected Image icon = null; 
+       private String helpId = EMPTY_STR; 
+       
+       protected boolean visible;
+
+       public void createControls(Composite _parent, ICPropertyProvider _provider) {
+               page = _provider;
+               createControls(_parent);
+       }
+
+       /**
+        * Creates basic widgets for property tab.
+        * Descendants should, normally, override
+        * this method but call super.createControls(). 
+        * 
+        * @param parent
+        */
+       protected void createControls(Composite parent) {
+               parent.setLayout(new FillLayout());
+        pageBook = new PageBook(parent, SWT.NULL);
+
+               background = new CLabel(pageBook, SWT.CENTER | SWT.SHADOW_NONE);
+               background.setText(EMPTY_STR);
+
+        GridData gd;
+               userdata= new Composite(pageBook, SWT.NONE);
+               userdata.setLayout(new GridLayout(2, false));
+               
+               usercomp = new Composite(userdata, SWT.NONE);
+               usercomp.setLayoutData(gd= new GridData(GridData.FILL_BOTH));
+               gd.widthHint= 150;
+               
+               buttoncomp = new Composite(userdata, SWT.NONE);
+               buttoncomp.setLayoutData(gd= new GridData(GridData.END));
+               // width hint must be set to one, otherwise subclasses that do not have buttons
+               // don't look pretty, bug 242408
+               gd.widthHint= 1;
+               
+               pageBook.showPage(userdata);
+               
+           PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, helpId);
+       }
+       
+       /**
+        * The common way to create buttons cluster
+        * on the right of tab workspace.
+        * @param names : array of button names
+        * null instead of name means "skip place" 
+        */
+       protected void  initButtons(String[] names) {
+               initButtons(buttoncomp, names, 80);
+       }
+       protected void  initButtons(String[] names, int width) {
+               initButtons(buttoncomp, names, width);
+       }
+       
+       /**
+        * Ability to create standard button on any composite.
+        * @param c
+        * @param names
+        */
+       protected void initButtons(Composite c, String[] names) {
+               initButtons(c, names, 80);
+       }
+       protected void initButtons(Composite c, String[] names, int width) {
+               if (names == null || names.length == 0) return;
+               c.setLayoutData(new GridData(GridData.FILL_VERTICAL));
+           c.setLayout(new GridLayout(1, false));
+               buttons = new Button[names.length];
+               for (int i=0; i<names.length; i++) {
+                       buttons[i] = new Button(c, SWT.PUSH);
+                       GridData gdb = new GridData(GridData.VERTICAL_ALIGN_CENTER);
+                       gdb.grabExcessHorizontalSpace = false;
+                       gdb.horizontalAlignment = SWT.FILL;
+                       gdb.minimumWidth = width;
+                       
+                       if (names[i] != null)
+                               buttons[i].setText(names[i]);
+                       else { // no button, but placeholder ! 
+                               buttons[i].setVisible(false);
+                               buttons[i].setEnabled(false);
+                               gdb.heightHint = 10;
+                       }
+                       
+                       buttons[i].setLayoutData(gdb);
+                       buttons[i].addSelectionListener(new SelectionAdapter() {
+                       @Override
+                               public void widgetSelected(SelectionEvent event) {
+                               buttonPressed(event);
+                       }});
+               }
+       }
+       
+       /**
+        * Called when user changes 
+        * @param cfg - selected configuration
+        */
+       private void configChanged(ICResourceDescription cfg) {
+               if (visible) updateData(cfg);
+       }
+       
+    /**
+     * Disposes the SWT resources allocated by this
+     * dialog page.
+     */
+    public void dispose() {}
+
+    /**
+     * Sets the visibility of this property tab.
+     *
+     * @param _visible <code>true</code> to make this tab visible,
+     *  and <code>false</code> to hide it
+     */
+    public void setVisible(boolean _visible) {
+       visible = _visible;
+       if (visible) updateData(page.getResDesc());
+    }
+       
+    /**
+     * Descendant tabs should implement this method so 
+     * that it copies it's data from one description 
+     * to another. Only data affected by given tab
+     * should be copied.
+     * 
+     * @param src
+     * @param dst
+     */
+       protected abstract void performApply(ICResourceDescription src, ICResourceDescription dst);
+       protected abstract void performDefaults();
+       protected abstract void updateData(ICResourceDescription cfg);
+       protected abstract void updateButtons();
+       protected void performCancel() {}
+       protected void performOK() {}
+
+       /**
+        * 
+        * @param e - event to be handled
+        */
+       private void buttonPressed(SelectionEvent e) {
+               for (int i=0; i<buttons.length; i++) {
+                       if (buttons[i].equals(e.widget)) {
+                               buttonPressed(i);
+                               return;
+                       }
+               }
+       }
+       
+       /**
+        * Method should be rewritten to handle button presses 
+        * @param i : number of button pressed
+        * 
+        * Does nothing by default. 
+        * May (but not must) be overridden.
+        */
+       protected void buttonPressed(int i) {}
+       
+       /**
+        * Checks state of existing button.
+        * 
+        * @param i - button index
+        * @return - true if button exists and enabled 
+        */
+       protected boolean buttonIsEnabled(int i) {
+               if (buttons == null || buttons.length <= i ) 
+                       return false;
+               return buttons[i].isEnabled();
+       }
+       
+       /**
+        * Changes state of existing button.
+        * Does nothing if index is invalid
+        * 
+        * @param i - button index
+        * @param state - required state
+        */
+       protected void buttonSetEnabled(int i, boolean state) {
+               if (buttons == null || buttons.length <= i ) return;
+               buttons[i].setEnabled(state);
+       }
+       
+       /**
+        * Changes text of existing button
+        * Does nothing if index is invalid
+        * 
+        * @param i - button index
+        * @param text - text to display
+        */
+       protected void buttonSetText(int i, String text) {
+               if (buttons == null || buttons.length <= i ) return;
+               buttons[i].setText(text);
+               Composite c = buttons[i].getParent();
+               if (c != null) {
+                       c.pack();
+                       c = c.getParent();
+                       if (c != null)
+                               c.layout(true);
+               }
+       }
+
+       /**********************************************
+        * Utility methods for unified widget creation
+        **********************************************/
+       protected Label setupLabel(Composite c, String name, int span, int mode) {
+               Label l = new Label(c, SWT.NONE);
+               l.setText(name);
+               setupControl(l, span, mode);
+               return l;
+       }
+
+       protected Button setupButton(Composite c, String name, int span, int mode) {
+               Button b = new Button(c, SWT.PUSH);
+               b.setText(name);
+               setupControl(b, span, mode);
+               GridData g = (GridData)b.getLayoutData();
+               g.minimumWidth = BUTTON_WIDTH;
+               g.horizontalAlignment = SWT.RIGHT;
+               b.setLayoutData(g);
+               return b;
+       }
+       
+       protected Text setupText(Composite c, int span, int mode) {
+               Text t = new Text(c, SWT.SINGLE | SWT.BORDER);
+               setupControl(t, span, mode);
+               return t;
+       }
+       
+       protected Group setupGroup(Composite c, String name, int cols, int mode) {
+               Group g = new Group(c, SWT.NONE);
+               g.setText(name);
+               g.setLayout(new GridLayout(cols, false));
+               setupControl(g, 1, mode);
+               return g;
+       }
+       
+       protected Button setupCheck(Composite c, String name, int span, int mode) {
+                Button b = new Button(c, SWT.CHECK);
+                b.setText(name);
+                setupControl(b, span, mode);
+                b.addSelectionListener(new SelectionAdapter() {
+                   @Override
+                       public void widgetSelected(SelectionEvent event) {
+                       setGrayed((Button)event.widget, false);
+                       checkPressed(event);
+                }});
+                return b;
+       }
+
+       /**
+        * Selection handler for checkbox created 
+        * by methods "setupCheck()" or "setupTri()" 
+        * Descendants should override this method 
+        * if they use "setupCheck".  
+        * Usually the method body will look like:
+        * { 
+        *              Control b = (Control)e.widget;
+        *      if (b.equals(myFirstCheckbox) { ... } 
+        *      else if (b.equals(mySecondCheckbox) { ... }
+        *   ... } 
+        */
+    protected void checkPressed(SelectionEvent e) {}
+    
+       protected void setupControl(Control c, int span, int mode) {
+               // although we use GridLayout usually,
+               // exceptions can occur: do nothing. 
+               if (c != null) {
+                       if (span != 0) {
+                               GridData gd = new GridData(mode);
+                               gd.horizontalSpan = span;
+                               c.setLayoutData(gd);
+                       }
+                       Composite p = c.getParent();
+                       c.setFont(p.getFont());
+               }
+       }
+       
+       /*
+        * A set of methods providing selection dialogs for files or dirs. 
+        */
+       
+       public static String getFileSystemDirDialog(Shell shell, String text) {
+               DirectoryDialog dialog = new DirectoryDialog(shell,     SWT.OPEN|SWT.APPLICATION_MODAL);
+               if(text != null && text.trim().length() != 0) dialog.setFilterPath(text);
+               dialog.setMessage(FILESYSTEM_DIR_DIALOG_MSG);
+               return dialog.open();
+       }
+
+       public static String getFileSystemFileDialog(Shell shell, String text) {
+               FileDialog dialog = new FileDialog(shell);
+               if(text != null && text.trim().length() != 0) dialog.setFilterPath(text);
+               dialog.setText(FILESYSTEM_FILE_DIALOG_TITLE);
+               return dialog.open();
+       }
+
+       /**
+        * @since 5.3
+        */
+       public static String getFileSystemFileDialog(Shell shell, String text, String[] filter) {
+               FileDialog dialog = new FileDialog(shell);
+               if(text != null && text.trim().length() != 0) dialog.setFilterPath(text);
+               dialog.setFilterExtensions(filter);
+               dialog.setText(FILESYSTEM_FILE_DIALOG_TITLE);
+               return dialog.open();
+       }
+       
+       public static String getVariableDialog(Shell shell, ICConfigurationDescription cfgd) {
+               
+               ICdtVariableManager vm = CCorePlugin.getDefault().getCdtVariableManager();
+               BuildVarListDialog dialog = new BuildVarListDialog(shell, vm.getVariables(cfgd));
+               dialog.setTitle(Messages.AbstractCPropertyTab_0); 
+               if (dialog.open() == Window.OK) {
+                       Object[] selected = dialog.getResult();
+                       if (selected.length > 0) {
+                               String s = ((ICdtVariable)selected[0]).getName();
+                               return  "${"+s.trim()+"}";  //$NON-NLS-1$//$NON-NLS-2$
+                       }
+               }
+               return null;
+       }
+
+       public static String getWorkspaceDirDialog(Shell shell, String text) {
+               return getWorkspaceDialog(shell, text, true, null);
+       }
+       public static String getWorkspaceFileDialog(Shell shell, String text) {
+               return getWorkspaceDialog(shell, text, false, null);
+       }
+       
+       private static String getWorkspaceDialog(Shell shell, String text, boolean dir, IProject prj) {
+               String currentPathText;
+               IPath path;
+               currentPathText = text;
+               /* Remove double quotes */
+               currentPathText = currentPathText.replaceAll("\"", ""); //$NON-NLS-1$ //$NON-NLS-2$
+               path = new Path(currentPathText);
+               
+               ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell,
+                               new WorkbenchLabelProvider(), new WorkbenchContentProvider());
+
+               if (prj == null)
+                       dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
+               else
+                       dialog.setInput(prj);
+               dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
+       
+               if (dir)        {
+                       IResource container = null;
+                       if(path.isAbsolute()){
+                               IContainer cs[] = ResourcesPlugin.getWorkspace().getRoot().findContainersForLocation(path);
+                               if(cs != null && cs.length > 0)
+                                       container = cs[0];
+                       }
+                       dialog.setInitialSelection(container);
+                       dialog.setValidator(new ISelectionStatusValidator() {
+                           public IStatus validate(Object[] selection) {
+                               if (selection != null)
+                                       if (selection.length > 0)
+                                               if ((selection[0] instanceof IFile))
+                                                       return new StatusInfo(IStatus.ERROR, WORKSPACE_DIR_DIALOG_ERR);
+                               return new StatusInfo();
+                           }
+                       });
+                       dialog.setTitle(WORKSPACE_DIR_DIALOG_TITLE); 
+            dialog.setMessage(WORKSPACE_DIR_DIALOG_MSG); 
+               } else {
+                       IResource resource = null;
+                       if(path.isAbsolute()){
+                               resource= ResourceLookup.selectFileForLocation(path, prj);
+                       }
+                       dialog.setInitialSelection(resource);
+                       dialog.setValidator(new ISelectionStatusValidator() {
+                           public IStatus validate(Object[] selection) {
+                               if (selection != null)
+                                       if (selection.length > 0)
+                                               if (!(selection[0] instanceof IFile))
+                                                       return new StatusInfo(IStatus.ERROR, WORKSPACE_FILE_DIALOG_ERR);
+                               return new StatusInfo();
+                           }
+                       });
+                       dialog.setTitle(WORKSPACE_FILE_DIALOG_TITLE); 
+            dialog.setMessage(WORKSPACE_FILE_DIALOG_MSG); 
+               }
+               if (dialog.open() == Window.OK) {
+                       IResource resource = (IResource) dialog.getFirstResult();
+                       if (resource != null) { 
+                               StringBuffer buf = new StringBuffer();
+                               return buf.append("${").append("workspace_loc:").append(resource.getFullPath()).append("}").toString(); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
+                       }
+               }
+               return null;
+       }
+       
+       // shortcut to frequently-used method
+       public ICResourceDescription getResDesc() {
+               return page.getResDesc();
+       }
+
+       /**
+        * Common event handler: called by parent for each tab
+        */
+       public void handleTabEvent (int kind, Object data) {
+               switch(kind) {
+               case ICPropertyTab.OK:
+                       if (canBeVisible()) performOK();
+                       break;
+               case ICPropertyTab.APPLY:
+                       if (canBeVisible()) performApply(getResDesc(), (ICResourceDescription)data);
+                       break;
+               case ICPropertyTab.CANCEL:
+                       if (canBeVisible()) performCancel();
+                       break;
+               case ICPropertyTab.DEFAULTS:
+                       if (canBeVisible() /*&& getResDesc() != null*/) {
+                               updateData(getResDesc());
+                               performDefaults();
+                       }
+                       break;
+               case ICPropertyTab.UPDATE:
+                       if (canBeVisible()) configChanged((ICResourceDescription)data);
+                       break;
+               case ICPropertyTab.DISPOSE:
+                       dispose();
+                       break;
+               case ICPropertyTab.VISIBLE:
+                       if (canBeVisible()) 
+                               setVisible(data != null);
+                       else 
+                               setVisible(false);
+                       break;
+               case ICPropertyTab.SET_ICON:
+                       icon = (Image)data; 
+                       break;
+               default:
+                       break;
+               }
+       }
+       
+    // By default, returns true (no visibility restriction)
+    // But several pages should rewrite this functionality.
+       public boolean canBeVisible() {
+               return true;
+       }
+
+       /**
+        * Added to avoid usage PixelConverter class.
+        * @param control
+        * @return FontMetrics
+        */
+       public static FontMetrics getFontMetrics(Control control) {
+               GC gc = new GC(control);
+               gc.setFont(control.getFont());
+               FontMetrics fFontMetrics= gc.getFontMetrics();
+               gc.dispose();
+               return fFontMetrics;
+       }
+
+       /**
+        * Sets checkbox to appropriate state: 
+        *        unchecked or checked
+        * @param b - checkbox to set
+        * @param state  
+        */
+       public static void setTriSelection(Button b, boolean state) {
+               setTriSelection(b, state ? TRI_YES : TRI_NO);
+       }
+       
+       /**
+        * Sets checkbox to appropriate state: 
+        *        unchecked, checked or unknown (grayed)
+        * @param b - checkbox to set
+        * @param state 
+        */
+       public static void setTriSelection(Button b, int state) {
+               switch (state) {
+               case TRI_NO:
+                       setGrayed(b, false);
+                       b.setSelection(false);
+                       break;
+               case TRI_YES:
+                       setGrayed(b, false);
+                       b.setSelection(true);
+                       break;
+               case TRI_UNKNOWN:
+                       b.setSelection(true);
+                       setGrayed(b, true);
+                       break;
+               }
+       }
+
+       /**
+        * This method will be simplified after M5 release,
+        * when Button.setGrayed() method will be accessible.
+        * In this case, reflection will not be required.
+        * 
+        * @param b
+        * @param value
+        * @deprecated call {@link Button#setGrayed(boolean)} instead
+        */
+       @Deprecated
+       public static void setGrayed(Button b, boolean value) {
+               b.setGrayed(value);
+       }
+
+       /**
+        * This method will be removed after M5 release,
+        * when Button.setGrayed() will be officially accessible.
+        * 
+        * @return reference to Button.setGrayed() method
+        */
+       private static Method getGrayEnabled() {
+               try {
+                       Class<?> cl = Class.forName("org.eclipse.swt.widgets.Button"); //$NON-NLS-1$
+                       return cl.getMethod("setGrayed", new Class[] { boolean.class }); //$NON-NLS-1$
+               } catch (ClassNotFoundException e) {
+                       return null;
+               } catch (NoSuchMethodException e) {
+                       return null;
+               }
+       }
+
+       /**
+        * Utility method to show/hide working panes
+        * When panes are hidden, message becomes visible 
+        * 
+        * @param visible - true or false
+        * @param msg - text to be shown instead of panes
+        */
+       protected void setAllVisible(boolean visible, String msg) {
+               if (!visible) {
+                       setBackgroundText(msg);
+                       pageBook.showPage(background);
+               } else {
+                       pageBook.showPage(userdata);
+               }
+               if (page != null) {
+                       Button b = page.getAButton();
+                       if (b != null)
+                               b.setVisible(visible);
+                       b = page.getDButton();
+                       if (b != null)
+                               b.setVisible(visible);
+               }
+       }
+       
+       /**
+        * Allows changing message on background pane,
+        * which becomes visible after usercomp hidden
+        * 
+        * @param s - text to display or null for default  
+        */
+       protected void setBackgroundText(String s) {
+               background.setText(s == null ? BACKGROUND_TEXT_DEFAULT : s);
+       }
+       
+       /**
+        * Used to display double-clickable buttons for multiple configurations
+        * string list mode (see Multiple Configurations Edit Preference page).
+        * 
+        * @deprecated as of CDT 8.0. This functionality is presented as links
+        *    to the preference page, see {@link AbstractLangsListTab#updateStringListModeControl()}
+        */
+       @Deprecated
+       protected void updateLbs(Label lb1, Label lb2) {
+               if (page.isMultiCfg()) {
+                       if (lb1 != null) {
+                               lb1.setText(CDTPrefUtil.getDMode());
+                               lb1.setVisible(true);
+                       }
+                       if (lb2 != null) {
+                               lb2.setText(CDTPrefUtil.getWMode());
+                               lb2.setVisible(true);
+                       }
+               } else {
+                       if (lb1 != null)
+                               lb1.setVisible(false);
+                       if (lb2 != null)
+                               lb2.setVisible(false);
+               }
+       }
+
+       /**
+        * The writing mode for multiple configurations edits (configuration drop-down list
+        * in project properties). This mode applies to lists of entries.
+        * See preference Multiple Configurations Edit, String List Write Mode.
+        * 
+        * @return
+        *    {@code true} if each list should be replaced as a whole with the
+        *       list user is currently working with in UI<br/>
+        *    {@code false} if changes apply only to individual entries and unaffected
+        *       entries are preserved.
+        */
+       protected boolean isWModifyMode() {
+               int wmode = CDTPrefUtil.getMultiCfgStringListWriteMode();
+               return (wmode == CDTPrefUtil.WMODE_MODIFY);
+       }
+
+       public String getHelpContextId() {
+               return helpId;
+       }
+       
+       public void setHelpContextId(String id) {
+               helpId = PREFIX + id;
+       }
+
+       /** 
+        * Allows subclasses to inform the container about changes relevant to the indexer.
+        * The tab will be asked before the apply is performed. As a consequence of returning
+        * <code>true</code> the user will be asked whether she wants to rebuild the index.
+        * @since 5.2
+        */
+       protected boolean isIndexerAffected() {
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractExportTab.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractExportTab.java
new file mode 100644 (file)
index 0000000..219fa16
--- /dev/null
@@ -0,0 +1,473 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *     James Blackburn (Broadcom Corp.)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.core.runtime.content.IContentTypeManager;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.IFontProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.LanguageManager;
+import org.eclipse.cdt.core.model.util.CDTListComparator;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICExternalSetting;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+public abstract class AbstractExportTab extends AbstractCPropertyTab {
+       protected Table table;
+       protected TableViewer tv;
+       protected ICConfigurationDescription cfg;
+       protected static final LanguageManager lm = LanguageManager.getInstance();
+       protected static final IContentTypeManager ctm = Platform.getContentTypeManager();
+
+//     protected boolean showBI = false;
+//     boolean  savedShowBI  = false;
+//     List incs;
+       
+       public static final Image IMG_FS = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_FILESYSTEM); 
+       public static final Image IMG_WS = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_WORKSPACE); 
+       public static final Image IMG_MK = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_MACRO);
+       private static final String ALL = Messages.AbstractExportTab_0; 
+       private static final String LIST = Messages.AbstractExportTab_1; 
+       private static Map<String, String> names_l = new HashMap<String, String>();
+       private static Map<String, String> names_t = new HashMap<String, String>();
+       private static String[] names_ls;       
+       private static String[] names_ts;
+       private List<String> namesList;
+
+       static {
+               ILanguage[] ls = lm.getRegisteredLanguages();
+               names_ls = new String[ls.length];
+               for (int i=0; i<ls.length; i++) {
+                       names_l.put(ls[i].getName(), ls[i].getId());
+                       names_ls[i] = ls[i].getName();
+               }
+               String[] ids = lm.getRegisteredContentTypeIds();
+               names_ts = new String[ids.length];
+               for (int i=0; i<ids.length; i++) {
+                       IContentType ct = ctm.getContentType(ids[i]);
+                       names_t.put(ct.getName(), ct.getId());
+                       names_ts[i] = ct.getName();
+               }
+               
+       }
+       
+       @Override
+       public void createControls(Composite parent) {
+               super.createControls(parent);
+               usercomp.setLayout(new GridLayout(2, false));
+           table = new Table(usercomp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.FULL_SELECTION);
+           GridData gd = new GridData(GridData.FILL_BOTH);
+           gd.minimumWidth = 255;
+           table.setLayoutData(gd);
+           table.setHeaderVisible(true);
+           table.setLinesVisible(true);
+
+           tv = new TableViewer(table);
+
+               tv.setContentProvider(new IStructuredContentProvider() {
+                       public Object[] getElements(Object inputElement) {
+                               return (Object[])inputElement;
+                       }
+                       public void dispose() {}
+                       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+               });
+           
+           tv.setLabelProvider(new RichLabelProvider());
+           
+           table.addSelectionListener(new SelectionAdapter() {
+               @Override
+                       public void widgetSelected(SelectionEvent e) {
+                       updateButtons();
+               }
+               @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                       if (buttonIsEnabled(1) && table.getSelectionIndex() != -1)
+                               buttonPressed(1);
+               }
+           });
+           TableColumn c = new TableColumn(table, SWT.NONE);
+           c.setWidth(hasValues() ? 100 : 200);
+           c.setText(Messages.EnvDialog_0); 
+           c = new TableColumn(table, SWT.NONE);
+           c.setWidth(hasValues() ? 100 : 0);
+           c.setText(Messages.EnvDialog_1); 
+           c = new TableColumn(table, SWT.NONE);
+           c.setWidth(100);
+           c.setText(Messages.LanguagesTab_1); 
+           c = new TableColumn(table, SWT.NONE);
+           c.setWidth(100);
+           c.setText(Messages.LanguagesTab_0); 
+           
+           initButtons(new String[] {ADD_STR, EDIT_STR, DEL_STR});
+           updateData(getResDesc());
+       }
+       
+       
+    /**
+     * Updates state of add/edit/delete buttons
+     * Called when table selection changes.
+     */
+    @Override
+       protected void updateButtons() {
+       int i = table.getSelectionIndex();
+               boolean x = i != -1;
+               boolean y = x;
+               if (x) {
+                       ICSettingEntry ent = ((ExtData)(table.getItem(i).getData())).entry;
+                       if (ent.isReadOnly()) x = false;
+                       if (ent.isBuiltIn() || ent.isReadOnly()) y = false;
+               }
+       buttonSetEnabled(1, x);
+       buttonSetEnabled(2, y);
+    }
+       
+       /*
+        * Methods to be implemented in descendants 
+        */
+       public abstract int getKind();
+       public abstract ICLanguageSettingEntry doAdd(String s1, String s2, boolean isWsp);
+       public abstract ICLanguageSettingEntry doEdit(String s1, String s2, boolean isWsp);
+       public abstract boolean hasValues();
+       
+       /**
+        * Called when item added/edited/removed or Tab is changed.
+        * Refreshes whole table contents
+        */
+       protected void update() {
+               int x = table.getSelectionIndex();
+               if (x == -1) x = 0;
+               
+               namesList = new ArrayList<String>();
+               ArrayList<ExtData> lst = new ArrayList<ExtData>();
+               ICExternalSetting[] vals = cfg.getExternalSettings();
+               if (vals == null || vals.length == 0) {
+                       tv.setInput(null);
+                       updateButtons();
+                       return;
+               }
+               for (ICExternalSetting v : vals) {
+                       ICSettingEntry[] ents = v.getEntries(getKind());
+                       if (ents == null || ents.length == 0) continue;
+                       for (ICSettingEntry se : ents) {
+                               lst.add(new ExtData(v, se));
+                               namesList.add(se.getName());
+                       }
+               }
+               Collections.sort(lst, CDTListComparator.getInstance());
+               tv.setInput(lst.toArray(new Object[lst.size()]));
+               if (table.getItemCount() > x) table.select(x);
+               else if (table.getItemCount() > 0) table.select(0);
+               updateButtons();
+       }
+
+       /**
+        * Called when configuration changed
+        * Refreshes languages list and calls table refresh.
+        */
+       @Override
+       public void updateData(ICResourceDescription rcfg) {
+               if (rcfg == null) return;
+               if (page.isMultiCfg()) {
+                       setAllVisible(false, null);
+               } else {
+                       if (!usercomp.isVisible())
+                               setAllVisible(true, null);
+                       cfg = rcfg.getConfiguration();
+                       update();
+               }
+       }
+       /**
+        * Unified "Add/Edit/Delete" buttons handler
+        */
+       @Override
+       public void buttonPressed(int i) {
+               ICLanguageSettingEntry[] ent = new ICLanguageSettingEntry[1];
+               ExtData old;
+               ExpDialog dlg;
+               int n = table.getSelectionIndex();
+
+               switch (i) {
+               case 0: // add
+                       dlg = new ExpDialog(usercomp.getShell(), true,
+                                       Messages.AbstractExportTab_2, EMPTY_STR, EMPTY_STR, cfg, 
+                                       null, null, getKind(), names_ls, names_ts, namesList, false); 
+                       if (dlg.open()) {
+                               ent[0] = doAdd(dlg.text1.trim(), dlg.text2.trim(), dlg.check2);
+                               if (ent[0] != null)
+                                       if (dlg.check1) { // apply to all ?
+                                               ICConfigurationDescription[] cfgs = page.getCfgsEditable();
+                                               for (ICConfigurationDescription cfg2 : cfgs)
+                                                       cfg2.createExternalSetting(name2id(dlg.sel_langs, names_l), 
+                                                                       name2id(dlg.sel_types, names_t), null, ent);
+                                       } else {
+                                               cfg.createExternalSetting(name2id(dlg.sel_langs, names_l), 
+                                                       name2id(dlg.sel_types, names_t), null, ent);
+                                       }
+                               update();
+                       }
+                       break;
+               case 1: // edit
+                       if (n == -1) return;
+                       old = (ExtData)(table.getItem(n).getData());
+                       if (old.entry.isReadOnly()) return;
+                       String s1, s2;
+                       if (getKind() == ICSettingEntry.MACRO) {
+                               s1 = old.getName();
+                               s2 = old.getValue();
+                       } else 
+                               s1 = s2 = old.getName();
+                       boolean isWsp = (old.entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0;
+                       dlg = new ExpDialog(usercomp.getShell(), false,
+                                       Messages.AbstractExportTab_3, s1, s2, cfg, 
+                                       id2name(old.setting.getCompatibleLanguageIds(), names_l),
+                                       id2name(old.setting.getCompatibleContentTypeIds(), names_t),
+                                       getKind(), names_ls, names_ts, null, isWsp); 
+                       if (dlg.open()) {
+                               ent[0] = doEdit(dlg.text1.trim(), dlg.text2.trim(), dlg.check2);
+                               ICSettingEntry[] ls = old.setting.getEntries();
+                               ICSettingEntry[] ls2 = new ICLanguageSettingEntry[ls.length];
+                               for (int x=0; x<ls.length; x++) 
+                                       if (ls[x].equals(old.entry)) ls2[x] = ent[0];
+                                       else ls2[x] = ls[x];
+                               cfg.removeExternalSetting(old.setting);
+                               cfg.createExternalSetting(name2id(dlg.sel_langs, names_l), name2id(dlg.sel_types, names_t), null, ls2);
+                               update();
+                       }
+                       break;
+               case 2: // delete
+                       if (n == -1) return;
+                       TableItem[] its = table.getSelection();
+                       boolean checked[] = new boolean[its.length];
+                       for (int t=0; t<its.length; t++) {
+                               if (checked[t] || its[t] == null) continue;
+                               old = (ExtData)(its[t].getData());
+                               if (old.entry.isReadOnly() || old.entry.isBuiltIn()) continue;
+                               ICSettingEntry[] ls = old.setting.getEntries(getKind());
+                               ArrayList<ICSettingEntry> lst = new ArrayList<ICSettingEntry>();
+outer:                         
+                               for (ICSettingEntry se : ls) { 
+                                       for (int y=t; y<its.length; y++) {
+                                               if (its[y] == null) break;
+                                               Object ob = its[y].getData();
+                                               if (ob != null && (ob instanceof ExtData)) {  
+                                                       ExtData ex = (ExtData)ob;
+                                                       if (se.equals(ex.entry)) {
+                                                               checked[y] = true;
+                                                               continue outer;
+                                                       }
+                                               }
+                                       }
+                                       lst.add(se);
+                               }
+                               // Ensure we don't lose external settings we know nothing about
+                               for (ICSettingEntry e : old.setting.getEntries())
+                                       if (e.getKind() != getKind())
+                                               lst.add(e);
+                               // Remove and re-add the particular setting entry
+                               cfg.removeExternalSetting(old.setting);
+                               cfg.createExternalSetting(old.setting.getCompatibleLanguageIds(), 
+                                               old.setting.getCompatibleContentTypeIds(),
+                                               old.setting.getCompatibleExtensions(), 
+                                               lst.toArray(new ICSettingEntry[lst.size()])); 
+                       }
+                       update();
+                       break;
+
+               default:
+                       break;
+               }
+       }
+
+       public static String[] name2id(String[] ein, Map<String, String> names) {
+               if (ein != null)
+                       for (int k=0; k<ein.length; k++) ein[k] = names.get(ein[k]);
+               return ein;
+       }
+
+       public static String[] id2name(String[] ein, Map<String, String> names) {
+               if (ein != null)
+                       for (int i=0; i<ein.length; i++) {
+                               Iterator<String> it = names.keySet().iterator();
+                               while (it.hasNext()) {
+                                       String s = it.next();
+                                       if (ein[i].equals(names.get(s))) {
+                                               ein[i] = s;
+                                               break;
+                                       }
+                               }
+                       }
+               return ein;
+       }
+       
+       @Override
+       protected void performApply(ICResourceDescription src, ICResourceDescription dst) {
+               ICConfigurationDescription c1 = src.getConfiguration();
+               ICConfigurationDescription c2 = dst.getConfiguration();
+               c2.removeExternalSettings();
+               ICExternalSetting[] v = c1.getExternalSettings();
+               for (ICExternalSetting element : v)
+                       c2.createExternalSetting(element.getCompatibleLanguageIds(), 
+                               element.getCompatibleContentTypeIds(),
+                               element.getCompatibleExtensions(), element.getEntries()); 
+       }
+
+       @Override
+       protected void performDefaults() {
+               cfg.removeExternalSettings();
+               // Bug 295602 Add any resources which are exported by 'default' in this configuration
+               // There's no hook on the Build system to do this, but 
+               //            setSourceEntries -> ... -> Configuration#setSourceEntries(...) -> Configuration#exportArtifactInfo()
+               try {
+                       cfg.setSourceEntries(cfg.getSourceEntries());
+               } catch (CoreException e) {CUIPlugin.log(e);}
+               updateData(this.getResDesc());
+       }
+
+       // Extended label provider
+       private class RichLabelProvider extends LabelProvider implements IFontProvider, ITableLabelProvider /*, IColorProvider*/{
+               public RichLabelProvider(){}
+               @Override
+               public Image getImage(Object element) {
+                       return getColumnImage(element, 0);
+               }
+               public Image getColumnImage(Object element, int columnIndex) {
+                       if (columnIndex > 0) return null;
+                       ExtData data = (ExtData)element;
+                       if (data.entry.getKind() == ICSettingEntry.MACRO)
+                               return IMG_MK;                          
+                       if ((data.entry.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0)
+                               return IMG_WS;
+                       return IMG_FS;
+               }
+               @Override
+               public String getText(Object element) {
+                       return getColumnText(element, 0);
+               }
+               public String getColumnText(Object element, int columnIndex) {
+                       ExtData data = (ExtData)element;
+                       switch (columnIndex) {
+                       case 0:
+                               return data.getName();
+                       case 1:
+                               return data.getValue();
+                       case 2:
+                               return data.getLangStr();
+                       case 3:
+                               return data.getTypeStr();
+                       default:
+                               return EMPTY_STR;
+                       }
+               }
+               
+               public Font getFont(Object element) {
+                       ExtData data = (ExtData)element;
+                       if (data.entry.isBuiltIn()) return null;    // built in
+                       if (data.entry.isReadOnly())                // read only
+                               return JFaceResources.getFontRegistry().getItalic(JFaceResources.DIALOG_FONT);
+                       return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
+               }
+       }
+
+       @Override
+       public boolean canBeVisible() {
+               if (! page.isForProject() ) 
+                       return false;
+               return true;
+       }
+
+       /**
+        *
+        */
+       static class ExtData {
+               ICExternalSetting setting;
+               ICSettingEntry entry;
+               
+               ExtData(ICExternalSetting _s, ICSettingEntry _e) {
+                       setting = _s;
+                       entry = _e;
+               }
+               protected String getName() { 
+                       return entry.getName(); 
+               }
+               protected String getValue() {
+                       if (entry.getKind() == ICSettingEntry.MACRO) 
+                               return entry.getValue();
+                       return EMPTY_STR;
+               } 
+               protected String getLangStr() { 
+                       return getLabel(setting.getCompatibleLanguageIds(), names_l);
+               }
+               protected String getTypeStr() {
+                       return getLabel(setting.getCompatibleContentTypeIds(), names_t);
+               }
+               @Override
+               public String toString() {
+                       return getName();
+               }
+       }
+       
+       static protected String getLabel(String[] lst, Map<String, String> names) {
+               if (lst == null || lst.length == 0) return ALL;
+               if (lst.length > 1) return LIST;
+               Iterator<String> it = names.keySet().iterator();
+               while (it.hasNext()) {
+                       String s = it.next();
+                       if (names.get(s).equals(lst[0]))
+                               return s;
+               }
+               return lst[0];
+       }
+       static protected String getList(String[] lst) {
+               String s = EMPTY_STR;
+               for (String element : lst)
+                       s = s + element + '\n';
+               return s;
+       }
+       static public Image getWspImage(boolean isWsp) {
+               return isWsp ? AbstractExportTab.IMG_WS : AbstractExportTab.IMG_FS;
+       }
+       
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractLangsListTab.java
new file mode 100644 (file)
index 0000000..7528b6f
--- /dev/null
@@ -0,0 +1,855 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *     IBM Corporation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.IFontProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.events.PaintEvent;
+import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
+
+import org.eclipse.cdt.core.model.ILanguageDescriptor;
+import org.eclipse.cdt.core.model.LanguageManager;
+import org.eclipse.cdt.core.model.util.CDTListComparator;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICExternalSetting;
+import org.eclipse.cdt.core.settings.model.ICFileDescription;
+import org.eclipse.cdt.core.settings.model.ICFolderDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICMultiFolderDescription;
+import org.eclipse.cdt.core.settings.model.ICMultiItemsHolder;
+import org.eclipse.cdt.core.settings.model.ICMultiResourceDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+import org.eclipse.cdt.core.settings.model.MultiLanguageSetting;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+import org.eclipse.cdt.ui.CDTSharedImages;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+public abstract class AbstractLangsListTab extends AbstractCPropertyTab {
+       protected Table table;
+       protected TableViewer tv;
+       protected Tree langTree;
+       protected TreeColumn langCol;
+       protected Button showBIButton;
+       protected boolean toAllCfgs = false;
+       protected boolean toAllLang = false;
+       /** @deprecated as of CDT 8.0. {@code linkStringListMode} is used instead. */
+       @Deprecated
+       protected Label lb1, lb2;
+
+       protected TableColumn columnToFit = null;
+
+       protected ICLanguageSetting lang;
+       protected LinkedList<ICLanguageSettingEntry> shownEntries;
+       /** A set of resolved exported entries */
+       protected ArrayList<ICSettingEntry> exported;
+       protected SashForm sashForm;
+       protected ICLanguageSetting [] ls; // all languages known
+       private boolean fHadSomeModification;
+
+       private StringListModeControl stringListModeControl;
+
+       private static final int BUTTON_ADD = 0;
+       private static final int BUTTON_EDIT = 1;
+       private static final int BUTTON_DELETE = 2;
+       private static final int BUTTON_EXPORT_UNEXPORT = 3;
+       // there is a separator instead of button #4
+       private static final int BUTTON_MOVE_UP = 5;
+       private static final int BUTTON_MOVE_DOWN = 6;
+
+       protected final static String[] BUTTONS = {
+                       ADD_STR,
+                       EDIT_STR,
+                       DEL_STR,
+                       Messages.AbstractLangsListTab_Export,
+                       null,
+                       MOVEUP_STR,
+                       MOVEDOWN_STR
+               };
+       protected final static String[] BUTTSYM = {
+                       ADD_STR,
+                       EDIT_STR,
+                       DEL_STR,
+                       Messages.AbstractLangsListTab_Export
+               };
+
+       private static final Comparator<Object> comp = CDTListComparator.getInstance();
+
+       private final static Image IMG_FOLDER = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_FOLDER);
+       private final static Image IMG_INCLUDES_FOLDER = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER);
+       private final static Image IMG_BUILTIN_FOLDER = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER_SYSTEM);
+       private final static Image IMG_WORKSPACE = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_WORKSPACE);
+       private final static Image IMG_INCLUDES_FOLDER_WORKSPACE = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER_WORKSPACE);
+       private final static Image IMG_MACRO = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_MACRO);
+       private static final int[] DEFAULT_SASH_WEIGHTS = new int[] { 10, 30 };
+
+       @Override
+       public void createControls(Composite parent) {
+               super.createControls(parent);
+               usercomp.setLayout(new GridLayout(2, false));
+               GridData gd = (GridData) usercomp.getLayoutData();
+               // Discourage settings entry table from trying to show all its items at once, see bug 264330
+               gd.heightHint =1;
+
+               // Create the sash form
+               sashForm = new SashForm(usercomp, SWT.NONE);
+               sashForm.setOrientation(SWT.HORIZONTAL);
+               gd = new GridData(GridData.FILL_BOTH);
+               gd.horizontalSpan = 2;
+               sashForm.setLayoutData(gd);
+
+               GridLayout layout = new GridLayout();
+               layout.numColumns = 2;
+               layout.marginHeight = 5;
+               sashForm.setLayout(layout);
+
+               addTree(sashForm).setLayoutData(new GridData(GridData.FILL_VERTICAL));
+               table = new Table(sashForm, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.FULL_SELECTION);
+               gd = new GridData(GridData.FILL_BOTH);
+               gd.widthHint = 150;
+               table.setLayoutData(gd);
+               table.setHeaderVisible(isHeaderVisible());
+               table.setLinesVisible(true);
+
+               sashForm.setWeights(DEFAULT_SASH_WEIGHTS);
+
+               sashForm.addListener(SWT.Selection, new Listener() {
+                       public void handleEvent(Event event) {
+                               if (event.detail == SWT.DRAG)
+                                       return;
+
+                               int shift = event.x - sashForm.getBounds().x;
+                               GridData data = (GridData) langTree.getLayoutData();
+                               if ((data.widthHint + shift) < 20)
+                                       return;
+
+                               sashForm.layout(true);
+                       }
+               });
+
+               tv = new TableViewer(table);
+
+               tv.setContentProvider(new IStructuredContentProvider() {
+                       public Object[] getElements(Object inputElement) {
+                               return (Object[])inputElement;
+                       }
+                       public void dispose() {}
+                       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+               });
+
+               tv.setLabelProvider(new RichLabelProvider());
+
+               table.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               updateButtons();
+                       }
+
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               if (buttonIsEnabled(BUTTON_EDIT) && table.getSelectionIndex() != -1)
+                                       buttonPressed(BUTTON_EDIT);
+                       }
+               });
+
+               table.addControlListener(new ControlListener() {
+                       public void controlMoved(ControlEvent e) {
+                               setColumnToFit();
+                       }
+                       public void controlResized(ControlEvent e) {
+                               setColumnToFit();
+                       }});
+
+               showBIButton = setupCheck(usercomp, Messages.AbstractLangsListTab_ShowBuiltin, 1, GridData.GRAB_HORIZONTAL);
+               gd = (GridData) showBIButton.getLayoutData();
+               showBIButton.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               update();
+                       }
+               });
+
+               stringListModeControl = new StringListModeControl(page, usercomp, 1);
+               stringListModeControl.addListener(SWT.Selection, new Listener() {
+                       public void handleEvent(Event event) {
+                               update();
+                       }
+               });
+
+               additionalTableSet();
+               initButtons((getKind() == ICSettingEntry.MACRO) ? BUTTSYM : BUTTONS);
+               updateData(getResDesc());
+       }
+
+       /**
+        * Used to display UI control for multiple configurations string list mode
+        * (see Multiple Configurations Edit Preference page).
+        *
+        * @since 5.3
+        */
+       protected void updateStringListModeControl() {
+               stringListModeControl.updateStringListModeControl();
+       }
+
+       /**
+        * Updates state for all buttons
+        * Called when table selection changes.
+        */
+       @Override
+       protected void updateButtons() {
+               int index = table.getSelectionIndex();
+               int[] ids = table.getSelectionIndices();
+               boolean canAdd = langTree.getItemCount() > 0;
+               boolean canExport = index != -1;
+               boolean canEdit = canExport && ids.length == 1;
+               boolean canDelete = canExport;
+               ICLanguageSettingEntry ent = null;
+               if (canExport) {
+                       ent = (ICLanguageSettingEntry)(table.getItem(index).getData());
+                       if (ent.isReadOnly()) canEdit = false;
+                       if (ent.isReadOnly()) canDelete = false;
+                       if (exported.contains(resolve(ent)))
+                               buttonSetText(BUTTON_EXPORT_UNEXPORT, Messages.AbstractLangsListTab_Unexport);
+                       else
+                               buttonSetText(BUTTON_EXPORT_UNEXPORT, Messages.AbstractLangsListTab_Export);
+               } else {
+                       buttonSetText(BUTTON_EXPORT_UNEXPORT, Messages.AbstractLangsListTab_Export);
+               }
+               boolean canMoveUp = false;
+               boolean canMoveDown = false;
+               if (ent != null) {
+                       canMoveUp = canEdit && index > 0 && !ent.isBuiltIn();
+                       canMoveDown = canEdit && (index < table.getItemCount() - 1) && !ent.isBuiltIn();
+               }
+               if (canMoveDown && showBIButton.getSelection()) {
+                       ent = (ICLanguageSettingEntry)(table.getItem(index+1).getData());
+                       if (ent.isBuiltIn()) canMoveDown = false; // cannot exchange with built in
+               }
+               buttonSetEnabled(BUTTON_ADD, canAdd);
+               buttonSetEnabled(BUTTON_EDIT, canEdit);
+               buttonSetEnabled(BUTTON_DELETE, canDelete);
+               buttonSetEnabled(BUTTON_EXPORT_UNEXPORT, canExport && !page.isMultiCfg());
+               buttonSetEnabled(BUTTON_MOVE_UP, canMoveUp && !page.isMultiCfg());
+               buttonSetEnabled(BUTTON_MOVE_DOWN, canMoveDown && !page.isMultiCfg());
+       }
+
+       private Tree addTree(Composite comp) {
+               langTree = new Tree(comp, SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL);
+               langTree.setLayoutData(new GridData(GridData.FILL_VERTICAL));
+               langTree.setHeaderVisible(true);
+
+               langTree.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               TreeItem[] items = langTree.getSelection();
+                               if (items.length > 0) {
+                                       ICLanguageSetting langSetting = (ICLanguageSetting) items[0].getData();
+                                       if (langSetting != null) {
+                                               lang = langSetting;
+                                               update();
+                                       }
+                               }
+                       }
+               });
+               langTree.addPaintListener(new PaintListener() {
+                       public void paintControl(PaintEvent e) {
+                               int x = langTree.getBounds().width - 5;
+                               if (langCol.getWidth() != x)
+                                       langCol.setWidth(x);
+                       }
+               });
+
+               langCol = new TreeColumn(langTree, SWT.NONE);
+               langCol.setText(Messages.AbstractLangsListTab_Languages);
+               langCol.setWidth(200);
+               langCol.setResizable(false);
+               langCol.setToolTipText(Messages.AbstractLangsListTab_Languages);
+
+               return langTree;
+       }
+
+       /*
+        * Methods to be implemented in descendants
+        */
+       public abstract int getKind();
+       public abstract ICLanguageSettingEntry doAdd();
+       public abstract ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent);
+       public void additionalTableSet() {} // may be not overwritten
+
+       /**
+        * Called when language changed or item added/edited/removed.
+        * Refreshes whole table contwnts
+        *
+        * Note, this method is rewritten in Symbols tab.
+        */
+       public void update() { update(0); }
+
+       public void update(int shift) {
+               if (lang != null) {
+                       int x = table.getSelectionIndex();
+                       if (x == -1) x = 0;
+                       else x += shift; // used only for UP/DOWN
+
+                       shownEntries = getIncs();
+                       tv.setInput(shownEntries.toArray(new Object[shownEntries.size()]));
+                       if (table.getItemCount() > x) table.setSelection(x);
+                       else if (table.getItemCount() > 0) table.setSelection(0);
+               }
+
+               updateStringListModeControl();
+               updateButtons();
+       }
+
+       protected LinkedList<ICLanguageSettingEntry> getIncs() {
+               LinkedList<ICLanguageSettingEntry> l = new LinkedList<ICLanguageSettingEntry>();
+               List<ICLanguageSettingEntry> lst = getSettingEntriesList(getKind());
+               if (lst != null) {
+                       for (ICLanguageSettingEntry ent : lst) {
+                               if (!ent.isBuiltIn())
+                                       l.add(ent);
+                       }
+                       if (showBIButton.getSelection()) {
+                               for (ICLanguageSettingEntry ent : lst)
+                                       if (ent.isBuiltIn())
+                                               l.add(ent);
+                       }
+               }
+               return l;
+       }
+
+
+       /**
+        * Called when configuration changed
+        * Refreshes languages list and calls table refresh.
+        */
+       @Override
+       public void updateData(ICResourceDescription rcDes) {
+               if (rcDes == null || !canBeVisible()) return;
+               updateExport();
+               langTree.removeAll();
+               TreeItem firstItem = null;
+               ls = getLangSetting(rcDes);
+               if (ls != null) {
+                       Arrays.sort(ls, CDTListComparator.getInstance());
+                       for (ICLanguageSetting langSetting : ls) {
+                               if ((langSetting.getSupportedEntryKinds() & getKind()) != 0) {
+                                       TreeItem t = new TreeItem(langTree, SWT.NONE);
+                                       String langId = langSetting.getLanguageId();
+                                       if (langId != null && !langId.equals(EMPTY_STR)) {
+                                               // Bug #178033: get language name via LangManager.
+                                               ILanguageDescriptor langDes = LanguageManager.getInstance().getLanguageDescriptor(langId);
+                                               if (langDes == null)
+                                                       langId = null;
+                                               else
+                                                       langId = langDes.getName();
+                                       }
+                                       if (langId == null || langId.equals(EMPTY_STR))
+                                               langId = langSetting.getName();
+                                       t.setText(0, langId);
+                                       t.setData(langSetting);
+                                       if (firstItem == null) {
+                                               firstItem = t;
+                                               lang = langSetting;
+                                       }
+                               }
+                       }
+
+                       if (firstItem != null && table != null) {
+                               langTree.setSelection(firstItem);
+                       }
+               }
+               update();
+       }
+
+       private void updateExport() {
+               exported = new ArrayList<ICSettingEntry>();
+               ICExternalSetting[] extSettings = getResDesc().getConfiguration().getExternalSettings();
+               if (!(extSettings == null || extSettings.length == 0)) {
+                       for (ICExternalSetting extSetting : extSettings) {
+                               ICSettingEntry[] entries = extSetting.getEntries(getKind());
+                               if (entries == null || entries.length == 0) continue;
+                               for (ICSettingEntry entry : entries)
+                                       exported.add(entry);
+                       }
+               }
+       }
+
+       private void performAdd(ICLanguageSettingEntry entry) {
+               if (entry != null) {
+                       fHadSomeModification= true;
+                       if ((toAllCfgs || toAllLang) && ! (getResDesc() instanceof ICMultiResourceDescription)) {
+                               addToAll(entry);
+                       } else {
+                               if (isWModifyMode() && (lang instanceof MultiLanguageSetting)) {
+                                       performMulti(entry, null);
+                               } else {
+                                       changeIt(entry, null);
+                               }
+                       }
+                       update();
+               }
+       }
+
+       private void changeIt(ICLanguageSettingEntry add, ICLanguageSettingEntry[] del) {
+               List<ICLanguageSettingEntry> lsEntries = getSettingEntriesList(getKind());
+               if (del != null) {
+                       for (ICLanguageSettingEntry d : del) {
+                               for (ICLanguageSettingEntry entry : lsEntries) {
+                                       if (d.getName().equals(entry.getName())) {
+                                               lsEntries.remove(entry);
+                                               break;
+                                       }
+                               }
+                       }
+               }
+               if (add != null)
+                       lsEntries.add(add);
+               setSettingEntries(getKind(), lsEntries, toAllLang);
+       }
+
+       /**
+        * Add and/or delete entries in the case of multi-configuration selection in the drop-down box.<br/>
+        * Hint: {@code lang} keeps the selected language for each one of the selected configurations.
+        *
+        * @param ent - entry to add
+        * @param del - entry to delete
+        */
+       private void performMulti(ICLanguageSettingEntry ent, ICLanguageSettingEntry del) {
+               MultiLanguageSetting ms = (MultiLanguageSetting)lang;
+               ICLanguageSetting[] langSettings = (ICLanguageSetting[])ms.getItems();
+               ICLanguageSettingEntry[][] es = ms.getSettingEntriesM(getKind());
+               for (int i=0; i<langSettings.length; i++) {
+                       List<ICLanguageSettingEntry> entries =
+                               new ArrayList<ICLanguageSettingEntry>(Arrays.asList(es[i]));
+                       if (del != null) {
+                               for (ICLanguageSettingEntry entry : entries) {
+                                       if (entry.getName().equals(del.getName())) {
+                                               entries.remove(entry);
+                                               break;
+                                       }
+                               }
+                       }
+                       if (ent != null)
+                               entries.add(ent);
+                       langSettings[i].setSettingEntries(getKind(), entries);
+               }
+       }
+
+       private void performEdit(int n) {
+               if (n == -1) return;
+               ICLanguageSettingEntry old = (ICLanguageSettingEntry)(table.getItem(n).getData());
+               if (old.isReadOnly()) return;
+               ICLanguageSettingEntry ent = doEdit(old);
+               toAllLang = false;
+               if (ent != null) {
+                       fHadSomeModification= true;
+                       if (isWModifyMode() && (lang instanceof MultiLanguageSetting)) {
+                               performMulti(ent, old);
+                       } else {
+                               ICLanguageSettingEntry[] del = null;
+                               if (!ent.getName().equals(old.getName()) || ent.getFlags() != old.getFlags()) {
+                                       del = new ICLanguageSettingEntry[] { old };
+                               }
+                               changeIt(ent, del);
+                       }
+                       update();
+               }
+       }
+
+       private void performDelete(int n) {
+               if (n == -1) return;
+               fHadSomeModification= true;
+               int[] ids = table.getSelectionIndices();
+               if (isWModifyMode() && (lang instanceof MultiLanguageSetting)) {
+                       for (int x=ids.length-1; x>=0; x--) {
+                               ICLanguageSettingEntry old = (ICLanguageSettingEntry)(table.getItem(ids[x]).getData());
+                                       performMulti(null, old);
+                       }
+               } else {
+                       ICLanguageSettingEntry[] del = new ICLanguageSettingEntry[ids.length];
+                       for (int x=ids.length-1; x>=0; x--) {
+                               ICLanguageSettingEntry old = (ICLanguageSettingEntry)(table.getItem(ids[x]).getData());
+//                             if (old.isReadOnly()) continue;
+                               del[x] = old;
+                       }
+                       changeIt(null, del);
+               }
+               update();
+
+       }
+       /**
+        * Unified buttons handler
+        */
+       @Override
+       public void buttonPressed(int buttonIndex) {
+               ICLanguageSettingEntry old;
+               int n = table.getSelectionIndex();
+               int ids[] = table.getSelectionIndices();
+
+               switch (buttonIndex) {
+               case BUTTON_ADD:
+                       toAllCfgs = false;
+                       toAllLang = false;
+                       performAdd(doAdd());
+                       break;
+               case BUTTON_EDIT:
+                       performEdit(n);
+                       break;
+               case BUTTON_DELETE:
+                       performDelete(n);
+                       break;
+               case BUTTON_EXPORT_UNEXPORT:
+                       if (n == -1) return;
+                       for (int x=ids.length-1; x>=0; x--) {
+                               old = resolve((ICLanguageSettingEntry)(table.getItem(ids[x]).getData()));
+                               if (exported.contains(old)) {
+                                       deleteExportSetting(old);
+                               } else {
+                                       page.getResDesc().getConfiguration().createExternalSetting(null, null, null, new ICLanguageSettingEntry[] {old});
+                               }
+                       }
+                       updateExport();
+                       update();
+                       break;
+               case BUTTON_MOVE_UP:
+               case BUTTON_MOVE_DOWN:
+                       old = (ICLanguageSettingEntry)(table.getItem(n).getData());
+                       int x = shownEntries.indexOf(old);
+                       if (x < 0) break;
+                       if (buttonIndex == BUTTON_MOVE_DOWN) x++; // "down" simply means "up underlying item"
+                       old = shownEntries.get(x);
+                       ICLanguageSettingEntry old2 = shownEntries.get(x - 1);
+                       shownEntries.remove(x);
+                       shownEntries.remove(x - 1);
+                       shownEntries.add(x - 1, old);
+                       shownEntries.add(x, old2);
+
+                       setSettingEntries(getKind(), shownEntries, false);
+                       update(buttonIndex == BUTTON_MOVE_UP ? -1 : 1);
+                       break;
+               default:
+                       break;
+               }
+               table.setFocus();
+       }
+
+       /**
+        * @return resolved ICLanguageSettingEntry
+        */
+       private ICLanguageSettingEntry resolve(ICLanguageSettingEntry entry) {
+               ICLanguageSettingEntry[] entries = CDataUtil.resolveEntries(new ICLanguageSettingEntry[] {entry}, getResDesc().getConfiguration());
+               if (entries.length > 0)
+                       return entries[0];
+               return entry;
+       }
+
+       private void deleteExportSetting(ICSettingEntry ent) {
+//             if (ent.isReadOnly() || ent.isBuiltIn()) continue;
+               ICConfigurationDescription cfg = getResDesc().getConfiguration();
+               ICExternalSetting[] extSettings = cfg.getExternalSettings();
+               if (!(extSettings == null || extSettings.length == 0)) {
+                       for (ICExternalSetting extSetting : extSettings) {
+                               ICSettingEntry[] entries = extSetting.getEntries(getKind());
+                               if (entries == null || entries.length == 0) continue;
+                               for (int j=0; j<entries.length; j++) {
+                                       if (entries[j].equalsByName(ent)) {
+                                               ICSettingEntry[] arr = new ICSettingEntry[entries.length - 1];
+                                               int index = 0;
+                                               for (int k=0; k<entries.length; k++)
+                                                       if (k != j) arr[index++] = entries[k];
+                                               cfg.removeExternalSetting(extSetting);
+                                               cfg.createExternalSetting(extSetting.getCompatibleLanguageIds(),
+                                                               extSetting.getCompatibleContentTypeIds(),
+                                                               extSetting.getCompatibleExtensions(),
+                                                               arr);
+                                               return;
+                                       }
+                               }
+                       }
+               }
+       }
+
+
+       /**
+        * Adds entry to all configurations
+        * @param ent - entry to add
+        */
+       private void addToAll(ICLanguageSettingEntry ent) {
+               ICResourceDescription curRcDes = page.getResDesc();
+               String id = lang.getName(); // getLanguageId() sometimes returns null.
+               for (ICConfigurationDescription cfgDes : page.getCfgsEditable()) {
+                       ICResourceDescription rcDes = page.getResDesc(cfgDes);
+                       if (rcDes == null)
+                               continue;
+                       if (!toAllCfgs && !(curRcDes.equals(rcDes)))
+                               continue;
+                       for (ICLanguageSetting l : getLangSetting(rcDes)) {
+                               if (toAllLang || id == l.getName() || (id != null && id.equals(l.getName()))) {
+                                       List<ICLanguageSettingEntry> lst = l.getSettingEntriesList(getKind());
+                                       lst.add(ent);
+                                       l.setSettingEntries(getKind(), lst);
+                               }
+                       }
+               }
+       }
+
+       @Override
+       protected void performApply(ICResourceDescription src, ICResourceDescription dst) {
+               fHadSomeModification= false;
+               if (page.isMultiCfg()) {
+                       ICLanguageSetting [] sr = ls;
+                       if (dst instanceof ICMultiItemsHolder) {
+                               for (Object item : ((ICMultiItemsHolder)dst).getItems()) {
+                                       if (item instanceof ICResourceDescription) {
+                                               ICLanguageSetting [] ds = getLangSetting((ICResourceDescription)item);
+                                               if (ds == null || sr.length != ds.length) return;
+                                               for (int i=0; i<sr.length; i++) {
+                                                       ICLanguageSettingEntry[] ents = null;
+                                                       ents = sr[i].getSettingEntries(getKind());
+                                                       ds[i].setSettingEntries(getKind(), ents);
+                                               }
+                                       }
+                               }
+                       }
+               } else {
+                       ICLanguageSetting [] sr = getLangSetting(src);
+                       ICLanguageSetting [] ds = getLangSetting(dst);
+                       if (sr == null || ds == null || sr.length != ds.length) return;
+                       for (int i=0; i<sr.length; i++) {
+                               ICLanguageSettingEntry[] ents = null;
+                               ents = sr[i].getSettingEntries(getKind());
+                               ds[i].setSettingEntries(getKind(), ents);
+                       }
+               }
+       }
+
+       @Override
+       protected void performDefaults() {
+               fHadSomeModification= true;
+               TreeItem[] tis = langTree.getItems();
+               for (TreeItem ti : tis) {
+                       Object ob = ti.getData();
+                       if (ob != null && ob instanceof ICLanguageSetting) {
+                               ((ICLanguageSetting)ob).setSettingEntries(getKind(), (List<ICLanguageSettingEntry>)null);
+                       }
+               }
+               updateData(this.getResDesc());
+       }
+
+       // Extended label provider
+       private class RichLabelProvider extends LabelProvider implements IFontProvider, ITableLabelProvider /*, IColorProvider*/{
+               public RichLabelProvider(){}
+               @Override
+               public Image getImage(Object element) {
+                       return getColumnImage(element, 0);
+               }
+               public Image getColumnImage(Object element, int columnIndex) {
+                       if (columnIndex > 0) return null;
+                       if (! (element instanceof ICLanguageSettingEntry)) return null;
+
+                       ICLanguageSettingEntry le = (ICLanguageSettingEntry) element;
+                       if (le.getKind() == ICSettingEntry.MACRO)
+                               return IMG_MACRO;
+                       if ((le.getFlags() & ICSettingEntry.BUILTIN) != 0)
+                               return IMG_BUILTIN_FOLDER;
+
+                       boolean isWorkspacePath = (le.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH) != 0;
+                       if (le.getKind() == ICSettingEntry.INCLUDE_PATH || le.getKind() == ICSettingEntry.INCLUDE_FILE) {
+                               if (isWorkspacePath)
+                                       return IMG_INCLUDES_FOLDER_WORKSPACE;
+                               else
+                                       return IMG_INCLUDES_FOLDER;
+                       } else {
+                               if (isWorkspacePath)
+                                       return IMG_WORKSPACE;
+                               else
+                                       return IMG_FOLDER;
+                       }
+               }
+               @Override
+               public String getText(Object element) {
+                       return getColumnText(element, 0);
+               }
+               public String getColumnText(Object element, int columnIndex) {
+                       if (! (element instanceof ICLanguageSettingEntry)) {
+                               return (columnIndex == 0) ? element.toString() : EMPTY_STR;
+                       }
+                       ICLanguageSettingEntry le = (ICLanguageSettingEntry) element;
+                       if (columnIndex == 0) {
+                               String s = le.getName();
+                               if (exported.contains(resolve(le)))
+                                       s = s + Messages.AbstractLangsListTab_ExportIndicator;
+                               return s;
+                       }
+                       if (le.getKind() == ICSettingEntry.MACRO) {
+                               switch (columnIndex) {
+                                       case 1: return le.getValue();
+                               }
+                       }
+                       return EMPTY_STR;
+               }
+
+               public Font getFont(Object element) {
+                       if (! (element instanceof ICLanguageSettingEntry)) return null;
+                       ICLanguageSettingEntry le = (ICLanguageSettingEntry) element;
+                       if (le.isBuiltIn()) return null;    // built in
+                       if (le.isReadOnly())                // read only
+                               return JFaceResources.getFontRegistry().getItalic(JFaceResources.DIALOG_FONT);
+                       // normal
+                       return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
+               }
+       }
+
+       public ICLanguageSetting[] getLangSetting(ICResourceDescription rcDes) {
+               switch (rcDes.getType()) {
+               case ICSettingBase.SETTING_PROJECT:
+               case ICSettingBase.SETTING_CONFIGURATION:
+               case ICSettingBase.SETTING_FOLDER:
+                       ICFolderDescription foDes = (ICFolderDescription)rcDes;
+                       if (foDes instanceof ICMultiFolderDescription) {
+                               return getLS((ICMultiFolderDescription)foDes);
+                       }
+                       return foDes.getLanguageSettings();
+               case ICSettingBase.SETTING_FILE:
+                       ICFileDescription fiDes = (ICFileDescription)rcDes;
+                       ICLanguageSetting langSetting = fiDes.getLanguageSetting();
+                       return (langSetting != null) ? new ICLanguageSetting[] { langSetting } : null;
+               }
+               return null;
+       }
+
+       private ICLanguageSetting[] getLS(ICMultiFolderDescription foDes) {
+               ICLanguageSetting[] lsets;
+
+               ICLanguageSetting[][] lsArray2D = foDes.getLanguageSettingsM(comp);
+               ICLanguageSetting[] fs = conv2LS(CDTPrefUtil.getListForDisplay(lsArray2D, comp));
+               lsets = new ICLanguageSetting[fs.length];
+               for (int i=0; i<fs.length; i++) {
+                       ArrayList<ICLanguageSetting> list = new ArrayList<ICLanguageSetting>(lsArray2D.length);
+                       for (ICLanguageSetting[] lsArray : lsArray2D) {
+                               int x = Arrays.binarySearch(lsArray, fs[i], comp);
+                               if (x >= 0)
+                                       list.add(lsArray[x]);
+                       }
+                       if (list.size() == 1)
+                               lsets[i] = list.get(0);
+                       else if (list.size() > 1)
+                               lsets[i] = new MultiLanguageSetting(list, foDes.getConfiguration());
+               }
+               return lsets;
+       }
+
+
+       @Override
+       public boolean canBeVisible() {
+               if (getResDesc() == null) return true;
+               ICLanguageSetting [] langSettings = getLangSetting(getResDesc());
+               if (langSettings == null) return false;
+               for (ICLanguageSetting element : langSettings) {
+                       if ((element.getSupportedEntryKinds() & getKind()) != 0)
+                               return true;
+               }
+               return false;
+       }
+
+       private void setSettingEntries(int kind, List<ICLanguageSettingEntry> incs, boolean toAll) {
+               if (page.isMultiCfg()) {
+                       ((ICMultiResourceDescription)getResDesc()).setSettingEntries(lang, kind, incs, toAll);
+               } else
+                       lang.setSettingEntries(kind, incs);
+       }
+       private List<ICLanguageSettingEntry> getSettingEntriesList(int kind) {
+               if (page.isMultiCfg() && lang instanceof MultiLanguageSetting) {
+                       ICLanguageSettingEntry[][] lses = ((MultiLanguageSetting)lang).getSettingEntriesM(kind);
+                       Object[] res = CDTPrefUtil.getListForDisplay(lses, comp);
+                       ICLanguageSettingEntry[] out = new ICLanguageSettingEntry[res.length];
+                       System.arraycopy(res, 0, out, 0, res.length);
+                       return Arrays.asList(out);
+               }
+               return lang.getSettingEntriesList(kind);
+       }
+
+       private ICLanguageSetting[] conv2LS(Object[] ob) {
+               ICLanguageSetting[] se = new ICLanguageSetting[ob.length];
+               System.arraycopy(ob, 0, se, 0, ob.length);
+               return se;
+       }
+
+       protected boolean isHeaderVisible() {
+               return true;
+       }
+
+       protected void setColumnToFit() {
+               if (columnToFit != null)
+                       columnToFit.setWidth(table.getClientArea().width);
+       }
+
+       /**
+        * Returns whether the tab was modified by the user in any way. The flag is
+        * cleared after pressing apply or ok.
+        * @since 5.1
+        */
+       protected final boolean hadSomeModification() {
+               return fHadSomeModification;
+       }
+
+       @Override
+       protected final boolean isIndexerAffected() {
+               switch(getKind()) {
+               case ICSettingEntry.INCLUDE_PATH:
+               case ICSettingEntry.MACRO:
+               case ICSettingEntry.INCLUDE_FILE:
+               case ICSettingEntry.MACRO_FILE:
+                       if (hadSomeModification()) {
+                               return true;
+                       }
+                       break;
+               }
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPage.java
new file mode 100644 (file)
index 0000000..24d1a6a
--- /dev/null
@@ -0,0 +1,1319 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Intel Corporation, QNX Software Systems, and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *     Andrew Gvozdev
+ *     QNX Software Systems - [271628] NPE in configs for project that failed to convert
+ *     James Blackburn (Broadcom Corp.)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.help.HelpSystem;
+import org.eclipse.help.IContext;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.preference.IPreferencePageContainer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartReference;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.util.CDTListComparator;
+import org.eclipse.cdt.core.settings.model.CConfigurationStatus;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICFolderDescription;
+import org.eclipse.cdt.core.settings.model.ICMultiItemsHolder;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.core.settings.model.MultiItemsHolder;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+
+import org.eclipse.cdt.internal.ui.dialogs.OptionalMessageDialog;
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * It is a parent for all standard CDT property pages
+ * in new CDT model. 
+ * 
+ * Although it is enough for new page to implement
+ * "IWorkbenchPropertyPage" interface, it would be
+ * better to extend it from "AbstractPage".
+ * 
+ * In this case, we'll able to use:
+ * - dynamic tabs support via cPropertyTab extension point
+ * - a lot of utility methods: see ICPropertyProvider interface
+ * - mechanism of messages sent to all pages and all tabs in them
+ * 
+ * In fact, descendants of AbstractPage have to implement
+ * the only method:
+ *             protected boolean isSingle(); 
+ * It it returns false, current page can contain multiple tabs
+ * (obtained through "cPropertyTab" extension point).
+ * If it returns true, only one content tab is possible. If
+ * more than 1 tabs refer to this pas as a parent, only 1st
+ * one would be taken into account, others will be ignored. 
+ */
+public abstract class AbstractPage extends PropertyPage 
+implements
+               IPreferencePageContainer, // dynamic pages
+               ICPropertyProvider // utility methods for tabs
+{
+       private static ICResourceDescription resd = null;
+       private static ICConfigurationDescription[] cfgDescs = null;
+       private static ICConfigurationDescription lastSelectedCfg = null;
+       private static ICConfigurationDescription[] multiCfgs = null; // selected multi cfg
+       // tabs
+       private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.ui.cPropertyTab"; //$NON-NLS-1$
+       private static final String ELEMENT_NAME = "tab"; //$NON-NLS-1$
+       private static final String CLASS_NAME = "class"; //$NON-NLS-1$
+       private static final String PARENT_NAME = "parent"; //$NON-NLS-1$
+       private static final String IMAGE_NAME = "icon"; //$NON-NLS-1$
+       private static final String TIP_NAME = "tooltip"; //$NON-NLS-1$
+       private static final String TEXT_NAME = "name"; //$NON-NLS-1$
+       private static final String WEIGHT_NAME = "weight"; //$NON-NLS-1$
+       private static final String HELPID_NAME = "helpId"; //$NON-NLS-1$
+
+       private static final Object NOT_NULL = new Object();
+       public static final String EMPTY_STR = "";  //$NON-NLS-1$
+       
+       private static final int SAVE_MODE_OK = 1;
+       private static final int SAVE_MODE_APPLY = 2;
+       private static final int SAVE_MODE_APPLYOK = 3;
+       
+       private static final String PREF_ASK_REINDEX = "askReindex"; //$NON-NLS-1$
+       
+       private Map<URL, Image> loadedIcons = new HashMap<URL, Image>();
+
+       private final Image IMG_WARN = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_REFACTORING_WARNING);
+       /*
+        * Dialog widgets
+        */
+       private Combo configSelector;
+       private Button manageButton;
+       private Button excludeFromBuildCheck;
+       private Label errIcon;
+       private Text errMessage;
+       private Composite errPane;
+       private Composite parentComposite;
+       /*
+        * Bookeeping variables
+        */
+       protected boolean noContentOnPage = false;
+       protected boolean displayedConfig = false;
+       protected IResource internalElement = null;
+       protected boolean isProject = false;
+       protected boolean isFolder  = false;
+       protected boolean isFile    = false;
+       
+       // tabs
+       protected TabFolder folder;
+       protected ArrayList<InternalTab> itabs = new ArrayList<InternalTab>();
+       protected ICPropertyTab currentTab;
+
+       private static boolean isNewOpening = true;
+       
+       protected class InternalTab {
+               Composite comp;
+               String text;
+               String tip;
+               Image image;
+               ICPropertyTab tab;
+               
+               InternalTab(Composite _comp, String _text, Image _image, ICPropertyTab _tab, String _tip) {
+                       comp  = _comp;
+                       text  = _text;
+                       image = _image;
+                       tab   = _tab;
+                       tip   = _tip;
+               }
+
+               public TabItem createOn(TabFolder f) {
+                       if (tab.canBeVisible()) {
+                               TabItem ti = new TabItem(f, SWT.NONE);
+                               ti.setText(text);
+                               if (tip != null) ti.setToolTipText(tip);
+                               if (image != null) ti.setImage(image);
+                               ti.setControl(comp);
+                               ti.setData(tab);
+                               return ti;
+                       }
+                       return null;
+               }
+       }
+       
+       /**
+        * Default constructor
+        */
+       public AbstractPage() {
+               if (CDTPropertyManager.getPagesCount() == 0) {
+                       cfgDescs = null;
+                       lastSelectedCfg = null;
+                       multiCfgs = null;
+               }
+       }
+       
+       @Override
+       protected Control createContents(Composite parent) {
+               //      Create the container we return to the property page editor
+               Composite composite = new Composite(parent, SWT.NULL);
+               composite.setFont(parent.getFont());
+               GridLayout compositeLayout = new GridLayout();
+               compositeLayout.numColumns = 1;
+               compositeLayout.marginHeight = 0;
+               compositeLayout.marginWidth = 0;
+               composite.setLayout( compositeLayout );
+
+               String s = null;
+               if (!checkElement()) {
+                       s = Messages.AbstractPage_0; 
+               } else if (!isApplicable()) {
+                       return null;
+               } else if (!isCDTProject(getProject())) {
+                       s = Messages.AbstractPage_2; 
+               }
+               
+           if (s == null) {
+               contentForCDT(composite);
+               return composite;
+           }
+               
+               // no contents
+               Label label = new Label(composite, SWT.LEFT);
+               label.setText(s);
+               label.setFont(composite.getFont());
+               noContentOnPage = true;
+               noDefaultAndApplyButton();
+               return composite;
+       }
+       
+       protected void contentForCDT(Composite composite) {
+               GridData gd;
+
+               if (showsConfig()) {
+                       // Add a config selection area
+                       Group configGroup = ControlFactory.createGroup(composite, EMPTY_STR, 1);
+                       gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+                       gd.grabExcessHorizontalSpace = true;
+                       gd.widthHint= 150;
+                       configGroup.setLayoutData(gd);
+                       configGroup.setLayout(new GridLayout(3, false));
+
+                       Label configLabel = new Label(configGroup, SWT.NONE);
+                       configLabel.setText(Messages.AbstractPage_6); 
+                       configLabel.setLayoutData(new GridData(GridData.BEGINNING));
+
+                       configSelector = new Combo(configGroup, SWT.READ_ONLY | SWT.DROP_DOWN);
+                       configSelector.addListener(SWT.Selection, new Listener() {
+                               public void handleEvent(Event e) {
+                                       handleConfigSelection();
+                               }
+                       });
+                       gd = new GridData(GridData.FILL_BOTH);
+                       configSelector.setLayoutData(gd);
+
+                       if (!CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOMNG)) {
+                               manageButton = new Button(configGroup, SWT.PUSH);
+                               manageButton.setText(Messages.AbstractPage_12); 
+                               gd = new GridData(GridData.END);
+                               gd.minimumWidth = 150;
+                               manageButton.setLayoutData(gd);
+                               manageButton.addSelectionListener(new SelectionAdapter() {
+                                       @Override
+                                       public void widgetSelected(SelectionEvent e) {
+                                               IProject[] obs = new IProject[] { getProject() };
+                                               IConfigManager cm = ManageConfigSelector.getManager(obs);
+                                               if (cm != null && cm.manage(obs, false)) {
+                                                       cfgDescs = null;
+                                                       populateConfigurations();                                       
+                                               }
+                                       }
+                               });
+                       } else { // dummy object to avoid breaking layout
+                               new Label(configGroup, SWT.NONE).setLayoutData(new GridData(GridData.END));
+                       }
+
+                       errPane = new Composite(configGroup, SWT.NONE);
+                       gd = new GridData(GridData.FILL_HORIZONTAL);
+                       gd.horizontalSpan = 3;
+                       errPane.setLayoutData(gd);
+                       GridLayout gl = new GridLayout(2, false);
+                       gl.marginHeight = 0;
+                       gl.marginWidth = 0;
+                       gl.verticalSpacing = 0;
+                       gl.horizontalSpacing = 0;
+                       errPane.setLayout(gl);
+
+                       errIcon = new Label(errPane, SWT.LEFT);
+                       errIcon.setLayoutData(new GridData(GridData.BEGINNING));
+                       errIcon.setImage(IMG_WARN);
+
+                       errMessage = new Text(errPane, SWT.LEFT | SWT.READ_ONLY);
+                       errMessage.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+                       if (isForFolder() || isForFile()) {
+                               excludeFromBuildCheck = new Button(configGroup, SWT.CHECK);
+                               excludeFromBuildCheck.setText(Messages.AbstractPage_7); 
+                               gd = new GridData(GridData.FILL_HORIZONTAL);
+                               gd.horizontalSpan = 3;
+                               excludeFromBuildCheck.setLayoutData(gd);
+                               excludeFromBuildCheck.addSelectionListener(new SelectionAdapter() {
+                                       @Override
+                                       public void widgetSelected(SelectionEvent e) {
+                                               ICResourceDescription rcDescription = getResDesc();
+                                               rcDescription.setExcluded(excludeFromBuildCheck.getSelection());
+                                               if (currentTab instanceof AbstractCPropertyTab) {
+                                                       ((AbstractCPropertyTab)currentTab).updateData(rcDescription);
+                                               }
+                                       }
+                               });
+                       }
+               }
+
+               //      Update the contents of the configuration widget
+               populateConfigurations();
+               if (excludeFromBuildCheck != null) {
+                       excludeFromBuildCheck.setSelection(getResDesc().isExcluded());
+               }
+               //      Create the Specific objects for each page
+               createWidgets(composite);
+       }
+
+       public void createWidgets(Composite c) {
+               GridData gd;
+               parentComposite = new Composite(c, SWT.NONE);
+               parentComposite.setLayoutData(gd= new GridData(GridData.FILL_BOTH));
+               gd.widthHint= 800;
+               itabs.clear(); 
+               if (!isSingle()) {
+                       parentComposite.setLayout(new FillLayout());
+                       folder = new TabFolder(parentComposite, SWT.NONE);
+//                     folder.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
+               }
+               loadExtensionsSynchronized(parentComposite);
+               
+               // Set listener after data load, to avoid firing
+               // selection event on not-initialized tab items 
+               if (folder != null) {
+                   folder.addSelectionListener(new SelectionAdapter() {
+                             @Override
+                               public void widgetSelected(org.eclipse.swt.events.SelectionEvent event) {
+                                 if (folder.getSelection().length > 0 ) {
+                                         ICPropertyTab newTab = (ICPropertyTab)folder.getSelection()[0].getData();
+                                         if (newTab != null && currentTab != newTab) {
+                                                 if (currentTab != null) currentTab.handleTabEvent(ICPropertyTab.VISIBLE, null);                                                 
+                                                 currentTab = newTab;
+                                                 currentTab.handleTabEvent(ICPropertyTab.VISIBLE, NOT_NULL);
+                                         }
+                                 }
+                             }
+                           });
+                   if (folder.getItemCount() > 0) folder.setSelection(0);
+               }
+       }
+       /**
+        * 
+        */
+       public IProject getProject() {
+               Object element = getElement();
+               if (element != null) { 
+                       if (element instanceof IFile ||
+                               element instanceof IProject ||
+                               element instanceof IFolder)
+                               {
+                       IResource f = (IResource) element;
+                       return f.getProject();
+                               }
+                       else if (element instanceof ICProject)
+                               return ((ICProject)element).getProject();
+               }
+               return null;
+       }
+
+       /*
+        * Event Handlers
+        */
+       private void handleConfigSelection() {
+               // If there is nothing in config selection widget just bail
+               if (configSelector.getItemCount() == 0) return;
+               int selectionIndex = configSelector.getSelectionIndex();
+               if (selectionIndex == -1) return;
+               if (cfgDescs == null || cfgDescs.length == 0) return;
+
+               // Check if the user has selected the "all / multiple" configuration
+               if (selectionIndex >= cfgDescs.length) {
+                       if (selectionIndex == cfgDescs.length) {  // all
+                               multiCfgs = cfgDescs;
+                       } else { // multiple
+                               // Check previous state of variables figuring out if need to pop up selection dialog
+                               // areCfgsStillThere() covers deletions by a user in Manage Configurations dialog
+                               boolean enterMultiCfgsDialog = (multiCfgs == null)
+                                               || (multiCfgs == cfgDescs) || !areCfgsStillThere(multiCfgs);
+                               if (enterMultiCfgsDialog) {
+                                       ICConfigurationDescription[] mcfgs = ConfigMultiSelectionDialog.select(cfgDescs, parentComposite.getShell());
+                                       if (mcfgs == null || mcfgs.length == 0) {
+                                               // return back to previous selection
+                                               int cfgIndex = -1;
+                                               if (multiCfgs == cfgDescs) { // return to choice "All"
+                                                       cfgIndex = cfgDescs.length;
+                                               } else {
+                                                       cfgIndex = getCfgIndex(lastSelectedCfg);
+                                               }
+                                               configSelector.select(cfgIndex);
+                                               return;
+                                       }
+                                       multiCfgs = mcfgs;
+                               }
+                                       
+                       }
+                       lastSelectedCfg = null;
+
+                       cfgChanged(MultiItemsHolder.createCDescription(multiCfgs));
+                       return;
+               }
+               multiCfgs = null;
+               
+               String id1 = getResDesc() == null ? null : getResDesc().getId();
+               lastSelectedCfg = cfgDescs[selectionIndex];
+               String id2 = lastSelectedCfg.getId();
+               if (id2 != null && !id2.equals(id1)) {
+                       cfgChanged(lastSelectedCfg);
+               }
+       }
+
+       /**
+        * Find index of configuration description in the internal array of
+        * configuration descriptions.
+        * 
+        * @param cfgd
+        * @return index of found configuration description or index of active
+        *         configuration.
+        */
+       private static int getCfgIndex(ICConfigurationDescription cfgd) {
+               int index = 0;
+               for (int i = 0; i < cfgDescs.length; ++i) {
+                       if (cfgd != null) {
+                               if (cfgd.getId().equals(cfgDescs[i].getId())) {
+                                       return i;
+                               }
+                       } else if (cfgDescs[i].isActive()) {
+                               index = i;
+                       }
+               }
+               return index;
+       }
+
+       /**
+        * Find index of active configuration description in the internal array of
+        * configuration descriptions.
+        * 
+        * @return index of active configuration description.
+        */
+       private static int getActiveCfgIndex() {
+               return getCfgIndex(null);
+       }
+       
+       /**
+        * Check if all configuration descriptions are present in the internal array of
+        * configuration descriptions.
+        * @param cfgs
+        * @return true if all present, false otherwise
+        */
+       private static boolean areCfgsStillThere(ICConfigurationDescription[] cfgs) {
+               if (cfgs==null || cfgDescs==null) return false;
+               
+               for (ICConfigurationDescription multiCfg : cfgs) {
+                       boolean foundOne = false;
+                       for (ICConfigurationDescription cfgDesc : cfgDescs) {
+                               if (multiCfg.getId().equals(cfgDesc.getId())) {
+                                       foundOne = true;
+                                       break;
+                               }
+                       }
+                       if (!foundOne) {
+                               return false;
+                       }
+               }
+               return true;
+       }
+       
+    @Override
+       public boolean performCancel() {
+               if (! noContentOnPage && displayedConfig) forEach(ICPropertyTab.CANCEL);
+               
+               CDTPropertyManager.performCancel(this);
+               
+        return true;
+    }
+       @Override
+       public void performDefaults() {
+               if (! noContentOnPage && displayedConfig) forEach(ICPropertyTab.DEFAULTS);
+       }
+    @Override
+       public void performApply() { performSave(SAVE_MODE_APPLY); }
+    
+    /**
+     * There are 2 ways to perform OK for CDT property pages.
+     * 1st (default): 
+     *   All pages use the same editable copy of ICProjectDescription.
+     *   When OK occurs, this object is simply set.
+     *   
+     * 2nd:  
+     *   When OK occurs, each page must copy its data to new instance
+     *   of ICProjectDescription, like it occurs during Apply event.
+     *   It allows to avoid collisions with other property pages, 
+     *   which do not share ICProjectDescription instance.
+     *   But some changes may be saved wrong if they are affected
+     *   by data from another property pages (Discovery options etc).
+
+     *   To enable 2nd mode, just create the following file:
+     *   <workspace>/.metadata/.plugins/org.eclipse.cdt.ui/apply_mode
+     */
+    
+    @Override
+       public boolean performOk() {
+       File f = CUIPlugin.getDefault().getStateLocation().append("apply_mode").toFile(); //$NON-NLS-1$
+       if (f.exists()) 
+               return performSave(SAVE_MODE_APPLYOK);
+               return performSave(SAVE_MODE_OK); 
+               
+    }
+
+    /**
+     * Searches in the prj for the config description with the same ID as for given cfg.
+     * If there's no such cfgd, it will be created.
+     *  
+     *  @param prj - project description where we'll search (or create) config description
+     *  @param cfg - config description belonging to another project description, 
+     *               it is a sample for search and base for possile creation
+     *               of resulting configuration description.
+     *                  
+     *  @return the configuration description (found or created) or null in case of error
+     */
+    private ICConfigurationDescription findCfg(ICProjectDescription prj, ICConfigurationDescription cfg) {
+       String id = cfg.getId();
+       // find config with the same ID as original one
+               ICConfigurationDescription c = prj.getConfigurationById(id);
+               // if there's no cfg found, try to create it
+               if (c == null) {
+                       try {
+                               c = prj.createConfiguration(id, cfg.getName(), cfg);
+                               c.setDescription(cfg.getDescription());
+                       } catch (CoreException e) { 
+                               /* do nothing: c is already null */ 
+                       }
+               }
+               // if creation failed, report an error and return null
+               if (c == null) {
+                       MessageBox mb = new MessageBox(getShell());
+                       mb.setMessage(Messages.AbstractPage_3); 
+                       mb.open();
+               }
+       return c;
+    }
+    
+    /**
+     * The same code used to perform OK and Apply 
+     */
+    private boolean performSave(int mode)      {
+       final int finalMode = mode;
+               if (noContentOnPage || !displayedConfig) return true;
+               if ((mode == SAVE_MODE_OK || mode == SAVE_MODE_APPLYOK) && CDTPropertyManager.isSaveDone()) return true; // do not duplicate
+               
+               final boolean needs = (mode != SAVE_MODE_OK);
+               final ICProjectDescription local_prjd = needs ? CoreModel.getDefault().getProjectDescription(getProject()) : null;
+               
+               ICResourceDescription lc = null;
+               
+               if (needs) { 
+                       if (isMultiCfg()) {
+                               ICResourceDescription[] rds = (ICResourceDescription[])((ICMultiItemsHolder)resd).getItems();
+                               for (int i=0; i<rds.length; i++) {
+                                       ICConfigurationDescription c = local_prjd.getConfigurationById(rds[i].getConfiguration().getId());
+                                       rds[i] = getResDesc(c);
+                               }
+                               lc = MultiItemsHolder.createRDescription(rds);
+                       } else {
+                               ICConfigurationDescription c = findCfg(local_prjd, resd.getConfiguration());
+                               if (c == null) 
+                                       return false; // cannot save: no cfg found
+                               lc = getResDesc(c);
+                       }
+               }
+               final ICResourceDescription local_cfgd = lc;
+               
+               final boolean rebuildIndex= isIndexerAffected();
+               IRunnableWithProgress runnable = new IRunnableWithProgress() {
+                       
+                       private void sendOK() {
+                               for (int j=0; j<CDTPropertyManager.getPagesCount(); j++) {
+                                       Object p = CDTPropertyManager.getPage(j);
+                                       if (p != null && p instanceof AbstractPage) { 
+                                               AbstractPage ap = (AbstractPage)p;
+                                               if (ap.displayedConfig) ap.forEach(ICPropertyTab.OK, null);
+                                       }
+                               }
+                       }
+                       
+                       public void run(IProgressMonitor monitor) {
+                               // ask all tabs to store changes in cfg
+                               switch (finalMode) {
+                               case SAVE_MODE_APPLYOK:
+                                       sendOK();
+                                       ICConfigurationDescription[] olds = CDTPropertyManager.getProjectDescription(AbstractPage.this, getProject()).getConfigurations();
+                                       for (ICConfigurationDescription old : olds) {
+                                                       resd = getResDesc(old);
+                                                       ICResourceDescription r = getResDesc(local_prjd.getConfigurationById(old.getId()));
+                                                       for (int j=0; j<CDTPropertyManager.getPagesCount(); j++) {
+                                                               Object p = CDTPropertyManager.getPage(j);
+                                                               if (p != null && p instanceof AbstractPage) { 
+                                                                       AbstractPage ap = (AbstractPage)p;
+                                                                       if (ap.displayedConfig) {
+                                                                               ap.forEach(ICPropertyTab.UPDATE, resd);
+                                                                               ap.forEach(ICPropertyTab.APPLY, r);
+                                                                       }
+                                                               }
+                                                       }
+                                               }
+                                       break;
+                               case SAVE_MODE_APPLY:
+                                       forEach(ICPropertyTab.APPLY, local_cfgd);
+                                       break;
+                               case SAVE_MODE_OK:
+                                       sendOK();
+                                       break;
+                               } // end switch
+                               try {
+                                       if (needs) // 
+                                               CoreModel.getDefault().setProjectDescription(getProject(), local_prjd);
+                                       else
+                                               CDTPropertyManager.performOk(AbstractPage.this);
+                               } catch (CoreException e) {
+                                       CUIPlugin.logError(Messages.AbstractPage_11 + e.getLocalizedMessage()); 
+                               }
+                               updateViews(internalElement);
+                       }
+               };
+               IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable);
+               try {
+                       PlatformUI.getWorkbench().getProgressService().runInUI(new ProgressMonitorDialog(getShell()), op, ResourcesPlugin.getWorkspace().getRoot());
+               } catch (InvocationTargetException e) {
+                       Throwable e1 = e.getTargetException();
+                       CUIPlugin.errorDialog(getShell(), 
+                                       Messages.AbstractPage_8,  
+                                       Messages.AbstractPage_9, e1, true); 
+                       return false;
+               } catch (InterruptedException e) {
+                       // IProgressService.runInUI(...) misuses this exception to signal that the operation was canceled.
+                       return false;
+               }
+               
+               if (rebuildIndex)
+                       rebuildIndex();
+               return true;
+       }
+
+       private boolean isIndexerAffected() {
+               ICProjectDescription desc= CoreModel.getDefault().getProjectDescription(getProject(), false);
+               if (desc == null || desc.isCdtProjectCreating())
+                       return false;
+
+               Iterator<InternalTab> it = itabs.iterator();
+               while(it.hasNext()) {
+                       InternalTab tab = it.next();
+                       if (tab != null) {
+                               ICPropertyTab tabtab = tab.tab;
+                               if (tabtab instanceof AbstractCPropertyTab && ((AbstractCPropertyTab)tabtab).isIndexerAffected()) {
+                                       return true;
+                               }
+                       }
+               }
+               return false;
+       }
+
+       private void rebuildIndex() {
+               final Shell shell= getShell();
+               final String title= getTitle();
+               final String msg= Messages.AbstractPage_rebuildIndex_question; 
+               int result= OptionalMessageDialog.open(PREF_ASK_REINDEX,
+                               shell, title, null /* default image */, msg, MessageDialog.QUESTION, 
+                               new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL}, 0);
+               if (result == OptionalMessageDialog.NOT_SHOWN) {
+                       result= OptionalMessageDialog.getDialogDetail(PREF_ASK_REINDEX);
+               } else if (result != SWT.DEFAULT) {
+                       OptionalMessageDialog.setDialogDetail(PREF_ASK_REINDEX, result);
+               }
+               if (result == 0) { // first button
+                       final IProject project = getProject();
+                       CCorePlugin.getIndexManager().reindex(CoreModel.getDefault().create(project));
+               }
+       }
+
+       private void populateConfigurations() {
+               IProject prj = getProject();
+               // Do nothing in case of Preferences page.
+               if (prj == null)
+                       return;
+
+               // Do not re-read if list already created by another page
+               if (cfgDescs == null) {
+                       ICProjectDescription pDesc = CDTPropertyManager.getProjectDescription(this, prj);
+                       cfgDescs = (pDesc == null)? null : pDesc.getConfigurations();
+                       if (cfgDescs == null || cfgDescs.length == 0) return;
+                       Arrays.sort(cfgDescs, CDTListComparator.getInstance());
+                       
+               } else {
+                       if (cfgDescs.length == 0) return;
+                       // just register in CDTPropertyManager;
+                       CDTPropertyManager.getProjectDescription(this, prj);
+               }
+               
+               // Do nothing if widget not created yet.
+               if (configSelector == null)     {
+                       lastSelectedCfg = cfgDescs[getActiveCfgIndex()];
+                       cfgChanged(lastSelectedCfg); 
+                       return;
+               }
+
+               // Clear and replace the contents of the selector widget
+               configSelector.removeAll();
+               for (int i = 0; i < cfgDescs.length; ++i) {
+                       String name = cfgDescs[i].getName();
+                       if (cfgDescs[i].isActive()) {
+                               name = name + "  " + Messages.AbstractPage_16; //$NON-NLS-1$ 
+                       }
+                       configSelector.add(name);
+               }
+
+               // Ensure that the last selected config is selected by default
+               int cfgIndex = getCfgIndex(lastSelectedCfg);
+
+               // "All cfgs" - shown if at least 2 cfgs available
+               if (cfgDescs.length > 1) {
+                       configSelector.add(Messages.AbstractPage_4); 
+                       if (multiCfgs == cfgDescs) {
+                               cfgIndex = cfgDescs.length;
+                       }
+               }
+               // "Multi cfgs" - shown if at least 3 cfgs available
+               if (cfgDescs.length > 2) {
+                       configSelector.add(Messages.AbstractPage_5); 
+                       if (multiCfgs != null && multiCfgs != cfgDescs) {
+                               cfgIndex = cfgDescs.length + 1;
+                       }
+               }
+
+               if (cfgIndex<0) {
+                       cfgIndex = getActiveCfgIndex();
+               }
+
+               configSelector.select(cfgIndex);
+               handleConfigSelection();
+       }
+
+       public void updateButtons() {}
+       public void updateMessage() { }
+       public void updateTitle() {     }
+       public void updateContainer() { }
+
+       @Override
+       public boolean isValid() {
+               updateContainer();
+               return super.isValid();
+       }
+       
+       @Override
+       public void setVisible(boolean visible) {
+               super.setVisible(visible);
+               if (visible) {
+                       handleResize(true);
+                       displayedConfig = true;
+                       if (excludeFromBuildCheck != null && resd != null)
+                               excludeFromBuildCheck.setSelection(resd.isExcluded());
+                       populateConfigurations();
+               }
+
+               if (itabs.size() < 1) return;
+               
+               if (currentTab == null && folder.getItemCount() > 0)    {
+                       Object ob = folder.getItem(0).getData();
+                       currentTab = (ICPropertyTab)ob;
+               }
+               if (currentTab != null)
+                       currentTab.handleTabEvent(ICPropertyTab.VISIBLE, visible ? NOT_NULL : null);
+       }
+       
+       protected void handleResize(boolean visible) {
+               if (visible && !isNewOpening) return; // do not duplicate
+               if (visible) 
+                       isNewOpening = false;
+               
+               int saveMode = CDTPrefUtil.getInt(CDTPrefUtil.KEY_POSSAVE);
+               if (saveMode == CDTPrefUtil.POSITION_SAVE_NONE) return;
+               
+               if (internalElement == null && !checkElement()) 
+                       return; // not initialized. Do not process
+               IProject prj = getProject();
+               if (prj == null) 
+                       return; // preferences. Do not process. 
+               QualifiedName WIDTH  = new QualifiedName(prj.getName(),".property.page.width"); //$NON-NLS-1$
+               QualifiedName HEIGHT = new QualifiedName(prj.getName(),".property.page.height"); //$NON-NLS-1$
+               QualifiedName XKEY = new QualifiedName(prj.getName(),".property.page.x"); //$NON-NLS-1$
+               QualifiedName YKEY = new QualifiedName(prj.getName(),".property.page.y"); //$NON-NLS-1$
+               Rectangle r = getShell().getBounds();
+               try {
+                       if (visible) {
+                               String w = prj.getPersistentProperty(WIDTH);
+                               String h = prj.getPersistentProperty(HEIGHT);
+                               if (w != null) r.width  = Integer.parseInt(w);
+                               if (h != null) r.height = Integer.parseInt(h);
+                               if (saveMode == CDTPrefUtil.POSITION_SAVE_BOTH) {
+                                       String x = prj.getPersistentProperty(XKEY);
+                                       String y = prj.getPersistentProperty(YKEY);
+                                       if (x != null) r.x = Integer.parseInt(x);
+                                       if (y != null) r.y = Integer.parseInt(y);
+                               }
+                               getShell().setBounds(r);
+                       } else {
+                               prj.setPersistentProperty(WIDTH,  String.valueOf(r.width));
+                               prj.setPersistentProperty(HEIGHT, String.valueOf(r.height));
+                               prj.setPersistentProperty(XKEY, String.valueOf(r.x));
+                               prj.setPersistentProperty(YKEY, String.valueOf(r.y));
+                       }
+               } catch (CoreException e) {}
+       }
+
+       @Override
+       public IPreferenceStore getPreferenceStore() {
+               return CUIPlugin.getDefault().getPreferenceStore();
+       }
+
+       /**
+        * @deprecated, use {@link #getPreferenceStore()}, instead.
+        */
+       @Deprecated
+       public org.eclipse.core.runtime.Preferences getPreferences()    {
+               return CUIPlugin.getDefault().getPluginPreferences();
+       }
+       
+       public void enableConfigSelection (boolean enable) {
+               if (configSelector != null) configSelector.setEnabled(enable);
+               if (manageButton != null) manageButton.setEnabled(enable);
+       }
+       
+       /**
+        * Returns configuration descriptions for given project
+        */
+       public ICConfigurationDescription[] getCfgsReadOnly(IProject p) {
+               ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false); 
+               if (prjd != null) 
+                       return prjd.getConfigurations();
+               return null;
+       }
+
+       /**
+        * Returns loaded configuration descriptions for current project
+        */
+       public ICConfigurationDescription[] getCfgsEditable() {
+               return cfgDescs;
+       }
+       
+       /** Checks whether project is new CDT project
+        * 
+        * @param p - project to check
+        * @returns true if it's new-style project. 
+        */ 
+       public static boolean isCDTPrj(IProject p) {
+               ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false); 
+               if (prjd == null) return false; 
+               ICConfigurationDescription[] cfgs = prjd.getConfigurations();
+               return (cfgs != null && cfgs.length > 0);
+       }
+       
+       public boolean isCDTProject(IProject p) {
+               return isCDTPrj(p);
+       }
+       
+       public ICResourceDescription getResDesc() {
+               if (resd == null) {
+                       if (cfgDescs == null) {
+                               populateConfigurations();
+                       }
+                       if (lastSelectedCfg!=null) {
+                               resd = getResDesc(lastSelectedCfg);
+                       }
+               }
+               return resd;
+       }
+
+       public ICResourceDescription getResDesc(ICConfigurationDescription cf) {
+               IAdaptable ad = getElement();
+               
+               if (isForProject()) 
+                       return cf.getRootFolderDescription();
+               ICResourceDescription out = null;
+               IResource res = (IResource)ad; 
+               IPath p = res.getProjectRelativePath();
+               if (isForFolder() || isForFile()) {
+                       if (cf instanceof ICMultiItemsHolder) {
+                               out = cf.getResourceDescription(p, isForFolder()); // sic ! 
+                       } else {
+                               out = cf.getResourceDescription(p, false);
+                               if (! p.equals(out.getPath()) ) {
+                                       try {
+                                               if (isForFolder())
+                                                       out = cf.createFolderDescription(p, (ICFolderDescription)out);
+                                               else
+                                                       out = cf.createFileDescription(p, out);
+                                       } catch (CoreException e) {
+                                               System.out.println(Messages.AbstractPage_10 + 
+                                                               p.toOSString() + "\n" + e.getLocalizedMessage()); //$NON-NLS-1$
+                                       }
+                               }
+                       }
+               }
+               return out;
+       }
+       
+       protected void cfgChanged(ICConfigurationDescription _cfgd) {
+               
+               CConfigurationStatus st = _cfgd.getConfigurationStatus();
+               if (errPane != null && errMessage != null) {
+                       if (st.isOK()) {
+                               errPane.setVisible(false);
+                       } else {
+                               errMessage.setText(st.getMessage());
+                               errPane.setVisible(true);
+                       }
+               }
+
+               resd = getResDesc(_cfgd);
+               
+               if (excludeFromBuildCheck != null) {
+                       excludeFromBuildCheck.setEnabled(resd.canExclude(!resd.isExcluded()));
+                       excludeFromBuildCheck.setSelection(resd.isExcluded());
+               }
+               int x = CDTPropertyManager.getPagesCount();
+               for (int i=0; i<x; i++) {
+                       Object p = CDTPropertyManager.getPage(i);
+                       if (p == null || !(p instanceof AbstractPage))
+                               continue;
+                       AbstractPage ap = (AbstractPage)p;
+                       if (ap.displayedConfig)
+                               ap.forEach(ICPropertyTab.UPDATE,getResDesc());
+               }
+       }
+
+       @Override
+       public void dispose() {
+               // Dispose the tabs
+               if (displayedConfig)
+                       forEach(ICPropertyTab.DISPOSE);
+               // Dispose any loaded images
+               for (Image img : loadedIcons.values())
+                       img.dispose();
+               loadedIcons.clear();
+
+               if (!isNewOpening)
+                       handleResize(false); // save page size 
+               isNewOpening = true;
+               // Remove this page from the property manager
+               CDTPropertyManager.remove(this);
+               // clear static variables
+               if (CDTPropertyManager.getPagesCount() == 0) {
+                       resd = null;
+                       cfgDescs = null;
+               }
+       }
+
+       /**
+        * The only method to be redefined in descendants
+        * @return 
+        *              true if single page is required
+        *              false if multiple pages are possible
+        */
+       abstract protected boolean isSingle(); 
+       
+       /**
+        * Defines whether the configurations control is shown or not.
+        * Subclasses may override this.
+        * @return true, if the configurations control should be shown (default); false otherwise
+        */
+       protected boolean showsConfig() { return true;  }
+
+       /**
+        * Apply specified method to all tabs
+        */
+       protected void forEach(int m) { forEach(m, null); }
+       protected void forEach(int m, Object pars) {
+               Iterator<InternalTab> it = itabs.iterator();
+               while(it.hasNext()) {
+                       InternalTab tab = it.next();
+                       if (tab != null) tab.tab.handleTabEvent(m, pars);
+               }
+       }
+       
+       // redefine page width
+       /*
+       public Point computeSize() {
+               Point p = super.computeSize();
+               if (p.x > MAX_WIDTH) p.x = MAX_WIDTH;
+               return p;
+       }
+       */
+       
+       public static String getWeight(IConfigurationElement e) {
+               String s = e.getAttribute(WEIGHT_NAME);
+               return (s == null) ? EMPTY_STR : s;
+       }
+       
+       private synchronized void loadExtensionsSynchronized(Composite parent) {
+               // Get the extensions
+               IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
+                               .getExtensionPoint(EXTENSION_POINT_ID);
+               if (extensionPoint == null) return;
+               IExtension[] extensions = extensionPoint.getExtensions();
+               if (extensions == null) return;
+
+               List<IConfigurationElement> elements = new ArrayList<IConfigurationElement>();
+               for (IExtension ext : extensions)
+                       elements.addAll(Arrays.asList(ext.getConfigurationElements()));
+               Collections.sort(elements, CDTUIListComparator.getInstance());
+
+               for (IConfigurationElement element : elements) {
+                       if (element.getName().equals(ELEMENT_NAME)) {
+                               if (loadTab(element, parent)) return;
+                       } else {
+                               System.out.println(Messages.AbstractPage_13 + element.getName()); 
+                       }
+               }
+       }
+
+       /**
+        * 
+        * @param element
+        * @param parent
+        * @return true if we should exit (no more loadings)
+        *         false if we should continue extensions scan.  
+        * @throws BuildException
+        */
+       private boolean loadTab(IConfigurationElement element, Composite parent) {
+               //      MBSCustomPageData currentPageData;
+               // Check whether it's our tab
+               if (!this.getClass().getName().equals(element.getAttribute(PARENT_NAME))) return false;
+               
+               ICPropertyTab page = null;
+               try {
+                       page = (ICPropertyTab) element.createExecutableExtension(CLASS_NAME);
+               } catch (CoreException e) {
+                       System.out.println(Messages.AbstractPage_14 +  
+                                       e.getLocalizedMessage());
+                       return false; 
+               }
+               if (page == null) return false;
+               
+               String helpId = element.getAttribute(HELPID_NAME);
+               if (helpId != null && helpId.length() > 0 
+                   // TODO: in next version: refer to ICPropertyTab instead of AbstractCPropertyTab
+                       && page instanceof AbstractCPropertyTab) {
+                       ((AbstractCPropertyTab)page).setHelpContextId(helpId);
+               }
+               
+               Image _img = getIcon(element);
+               if (_img != null) page.handleTabEvent(ICPropertyTab.SET_ICON, _img);
+               
+               if (isSingle()) {
+                       // note that name, image and tooltip
+                       // are ignored for single page.
+                       page.createControls(parent, this);
+                       InternalTab itab = new InternalTab(parent, EMPTY_STR, null, page, null);
+                       itabs.add(itab);
+                       currentTab = page;
+                       return true; // don't load other tabs
+               }
+               String _name   = element.getAttribute(TEXT_NAME);
+               String _tip = element.getAttribute(TIP_NAME);
+
+               Composite _comp = new Composite(folder, SWT.NONE);
+               page.createControls(_comp, this);           
+               InternalTab itab = new InternalTab(_comp, _name, _img, page, _tip);
+               itab.createOn(folder);
+               itabs.add(itab);
+               return false;
+       }
+
+       private Image getIcon(IConfigurationElement config) {
+               ImageDescriptor idesc = null;
+               URL url = null;
+               try {
+                       String iconName = config.getAttribute(IMAGE_NAME);
+                       if (iconName != null) {
+                               URL pluginInstallUrl = Platform.getBundle(config.getDeclaringExtension().getContributor().getName()).getEntry("/"); //$NON-NLS-1$
+                               url = new URL(pluginInstallUrl, iconName);
+                               if (loadedIcons.containsKey(url))
+                                       return loadedIcons.get(url);
+                               idesc = ImageDescriptor.createFromURL(url);
+                       }
+               } catch (MalformedURLException exception) {}
+               if (idesc == null)
+                       return null;
+               Image img = idesc.createImage();
+               loadedIcons.put(url, img);
+               return img;
+       }
+
+       public void informAll(int code, Object data) {
+               for (int i=0; i<CDTPropertyManager.getPagesCount(); i++) {
+                       Object p = CDTPropertyManager.getPage(i);
+                       if (p == null || !(p instanceof AbstractPage))
+                               continue;
+                       AbstractPage ap = (AbstractPage)p;
+                       ap.forEach(code, data);
+               }
+       }
+
+       public void informPages(int code, Object data) {
+               for (int i=0; i<CDTPropertyManager.getPagesCount(); i++) {
+                       Object p = CDTPropertyManager.getPage(i);
+                       if (p == null || !(p instanceof AbstractPage))
+                               continue;
+                       AbstractPage ap = (AbstractPage)p;
+                       ap.handleMessage(code, data);
+               }
+       }
+
+       public void handleMessage(int code, Object data) {
+               switch (code) {
+                       // First re-check visibility of all tabs.
+                   // While tab deletion can be made on the fly,
+                   // tabs adding will be made by re-creation
+                   // of all elements, to preserve their order 
+                       case ICPropertyTab.MANAGEDBUILDSTATE:
+                               if (folder == null) {
+                                       if (itabs == null || itabs.size() == 0) 
+                                               return;
+                                       ICPropertyTab t = itabs.get(0).tab;
+                                       if (! t.canBeVisible())
+                                               t.handleTabEvent(ICPropertyTab.VISIBLE, null);
+                                       return;
+                               }
+                               boolean willAdd = false;
+                               TabItem[] ts = folder.getItems();
+                               int x = folder.getSelectionIndex();
+                               String currHeader = (x == -1) ? null : ts[x].getText();
+                               for (int i=0; i<itabs.size(); i++) {
+                                       InternalTab itab = itabs.get(i);
+                                       TabItem ti = null;
+                                       for (TabItem element2 : ts) {
+                                               if (element2.isDisposed()) continue;
+                                               if (element2.getData() == itab.tab) {
+                                                       ti = element2;
+                                                       break;
+                                               }
+                                       }
+                                       if (itab.tab.canBeVisible()) {
+                                               if (ti == null) {
+                                                       willAdd = true;
+                                                       break;
+                                               }
+                                       } else {
+                                               if (ti != null) ti.dispose();
+                                       }
+                               }
+                               // in case of new tab added, 
+                               // we have to dispose and re-create all tabs
+                               if (willAdd) {
+                                       for (int j=0; j<ts.length; j++) 
+                                               if (ts[j] != null && !ts[j].isDisposed())
+                                                       ts[j].dispose();
+                                       TabItem ti = null;
+                                       for (int i=0; i<itabs.size(); i++) {
+                                               InternalTab itab = itabs.get(i);
+                                               if (itab.tab.canBeVisible()) {
+                                                       TabItem currTI = itab.createOn(folder);
+                                                       if (currHeader != null && currHeader.equals(itab.text))
+                                                               ti = currTI;
+                                               }
+                                       }
+                                       if (ti != null) folder.setSelection(ti);
+                               }
+                               break;
+               }
+       }
+       
+       /**
+        * Performs conversion of incoming element to internal representation.
+        */
+       protected boolean checkElement() {
+               IAdaptable el = super.getElement();
+               if (el instanceof ICElement) 
+                       internalElement = ((ICElement)el).getResource();
+               else if (el instanceof IResource) 
+                       internalElement = (IResource)el;
+               else
+                   internalElement = (IResource) el.getAdapter(IResource.class);
+               if (internalElement == null) return false;
+               isProject = internalElement instanceof IProject;
+               isFolder  = internalElement instanceof IFolder;
+               isFile    = internalElement instanceof IFile;
+               return true;
+       }
+       
+       // override parent's method to use proper class
+       @Override
+       public IAdaptable getElement() {
+               if (internalElement == null && !checkElement()) 
+                       throw (new NullPointerException(Messages.AbstractPage_15)); 
+               return internalElement; 
+       }
+       
+       public boolean isForProject()  { return isProject; }
+       public boolean isForFolder()   { return isFolder; }
+       public boolean isForFile()     { return isFile; }
+       public boolean isForPrefs()    { return false; }
+       public boolean isMultiCfg()    { return resd instanceof ICMultiItemsHolder; }
+       
+       /**
+        * Checks whether CDT property pages can be open for given object.
+        * In particular, header files and text files are not allowed.
+        * 
+        * Note, that org.eclipse.cdt.ui.plugin.xml contains appropriate
+        * filters to avoid displaying CDT pages for unwanted objects. 
+        * So this check is only backup, it would prevent from NullPointer
+        * exceptions in case when xml filters were modified somehow.  
+        * 
+        * @return - true if element is applicable to CDT pages.
+        */
+       public boolean isApplicable() {
+               if (internalElement == null && !checkElement())
+                       return false; // unknown element
+               if (isForFile()) // only source files are applicable
+                       return true; //CoreModel.isValidSourceUnitName(getProject(), internalElement.getName());
+               return true; // Projects and folders are always applicable
+       }
+
+       /**
+        * update views (in particular, display resource configurations)
+        */
+       public static void updateViews(IResource res) {
+               if (res == null) return;  
+               IWorkbenchPartReference refs[] = CUIPlugin.getActiveWorkbenchWindow().getActivePage().getViewReferences();
+               for (IWorkbenchPartReference ref : refs) {
+                       IWorkbenchPart part = ref.getPart(false);
+                       if (part != null && part instanceof IPropertyChangeListener)
+                               ((IPropertyChangeListener)part).propertyChange(new PropertyChangeEvent(res, PreferenceConstants.PREF_SHOW_CU_CHILDREN, null, null));
+               }
+       }
+
+       /**
+        * Adjusts form size according to contents dimensions
+        */
+       public void resize() {
+               Shell sh = parentComposite.getShell();
+               Point p0 = sh.getLocation();
+               Point p1 = sh.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
+               Rectangle r = sh.getDisplay().getClientArea();
+               p1.x = Math.min(p1.x, (r.width - p0.x));
+               p1.y = Math.min(p1.y, (r.height - p0.y));
+               sh.setSize(p1);
+       }
+
+       /**
+        * Returns Apply button widget
+        * Allows public access to it.
+        */
+       public Button getAButton() {
+               return getApplyButton();
+       }
+       
+       /**
+        * Returns Default button widget.
+        * Allows public access to it.
+        */
+       public Button getDButton() {
+               return getDefaultsButton();
+       }
+
+       @Override
+       public void performHelp() {
+           // TODO: in next version: refer to ICPropertyTab instead of AbstractCPropertyTab
+               if (currentTab != null && currentTab instanceof AbstractCPropertyTab) {
+                       String s = ((AbstractCPropertyTab)currentTab).getHelpContextId();
+                       if (s != null && s.length() > 0) {
+                               IContext context= HelpSystem.getContext(s);
+                               if (context != null)
+                                       PlatformUI.getWorkbench().getHelpSystem().displayHelp(context);
+                               else
+                                       PlatformUI.getWorkbench().getHelpSystem().displayDynamicHelp();
+                       }
+               }
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPrefPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPrefPage.java
new file mode 100644 (file)
index 0000000..0a7883d
--- /dev/null
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+
+/**
+ * Abstract page to be used as base for preference pages
+ */
+public abstract class AbstractPrefPage extends AbstractPage 
+                               implements IWorkbenchPreferencePage {
+
+       public Label titleLabel;
+       
+       @Override
+       protected Control createContents(Composite parent) {
+               //      Create the container we return to the property page editor
+               Composite composite = new Composite(parent, SWT.NULL);
+               composite.setFont(parent.getFont());
+               GridLayout compositeLayout = new GridLayout();
+               compositeLayout.numColumns = 1;
+               compositeLayout.marginHeight = 0;
+               compositeLayout.marginWidth = 0;
+               composite.setLayout( compositeLayout );
+               
+               String s = getHeader();
+               if (s != null) {
+                       Group configGroup = ControlFactory.createGroup(composite, EMPTY_STR, 1);
+                       GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+                       gd.grabExcessHorizontalSpace = true;
+                       configGroup.setLayoutData(gd);
+                       titleLabel = ControlFactory.createLabel(configGroup, s); 
+               }
+               createWidgets(composite);
+       return composite;
+       }
+
+       @Override
+       protected boolean checkElement() { return true; } 
+       @Override
+       public boolean isForPrefs()    { return true; }
+       public void init(IWorkbench workbench) {}
+       @Override
+       public ICResourceDescription getResDesc() { return null; }
+       @Override
+       public void performApply() { performOk(); }
+       @Override
+       public boolean performOk() { 
+               forEach(ICPropertyTab.OK, null);
+               return true; 
+       }
+       abstract protected String getHeader(); 
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPropertyDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractPropertyDialog.java
new file mode 100644 (file)
index 0000000..9f79c43
--- /dev/null
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+//import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Dialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public abstract class AbstractPropertyDialog extends Dialog {
+       private final static String WSP_BEG = "${workspace_loc:";  //$NON-NLS-1$
+       private final static String WSP_END = "}"; //$NON-NLS-1$
+       protected final static String EMPTY_STR = ""; //$NON-NLS-1$
+       
+       protected Shell shell;
+       public boolean result = false;
+       
+       public Object data = null;
+       public boolean check1 = false;
+       public boolean check2 = false;
+       public boolean check3 = false;
+       public String text1;
+       public String text2;
+       private Shell parent;
+       
+       public AbstractPropertyDialog(Shell _parent, String title) {
+               super(_parent, 0);
+               this.getStyle();
+               
+               parent = _parent;
+               this.setText(title);
+       }
+
+       abstract public void buttonPressed(SelectionEvent e);
+       abstract protected Control createDialogArea(Composite c);
+       
+       protected Button setupButton(Composite c, String text) {
+               Button b = new Button(c, SWT.PUSH);
+               b.setText(text);
+               b.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               b.addSelectionListener(new SelectionAdapter() {
+               @Override
+                       public void widgetSelected(SelectionEvent event) {
+                       buttonPressed(event);
+           }});
+               return b;
+       }
+       
+       public boolean open () {
+                       shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL | SWT.RESIZE);
+                       shell.setText(getText());
+                       createDialogArea(shell);
+                       
+                       // center window
+                       Rectangle r1 = parent.getBounds();
+                       Rectangle r2 = shell.getBounds();
+                       int x = r1.x + (r1.width - r2.width) / 2;
+                       int y = r1.y + (r1.height - r2.height) / 2;
+                       shell.setBounds(x, y, r2.width, r2.height);
+                       
+                       shell.open();
+                       Display display = parent.getDisplay();
+                       while (!shell.isDisposed()) {
+                               if (!display.readAndDispatch()) display.sleep();
+                       }
+                       return result;
+       }
+       protected static String strip_wsp(String s) {
+               s = s.trim();
+               if (s.startsWith(WSP_BEG) && s.endsWith(WSP_END)) {
+                       int x = s.length() - WSP_END.length(); 
+                       s = s.substring(WSP_BEG.length(), x);
+               }
+               return s;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractSinglePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/AbstractSinglePage.java
new file mode 100644 (file)
index 0000000..8e58ae7
--- /dev/null
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.swt.widgets.Composite;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+
+/**
+ * Bug #183341 : Single property page which does not  
+ * require separate cPropertyTab to display data.
+ *
+ */
+public abstract class AbstractSinglePage extends AbstractPage {
+
+       /**
+        * Implement this method to create your own widgets
+        */
+       @Override
+       public abstract void createWidgets(Composite c);
+       
+       /**
+        * Implement this method to perform apply:
+        * copy all data affected by this page 
+        * from src resource description to dst
+        * @param src
+        * @param dst
+        */
+       protected abstract void performApply(ICResourceDescription src, ICResourceDescription dst);
+
+    /**
+     * Rewrite this method to handle configuration change
+     * Do not forget to call super.cfgChanged(_cfgd); 
+     */
+       @Override
+       protected void cfgChanged(ICConfigurationDescription _cfgd) {
+               super.cfgChanged(_cfgd);
+       //      if (displayedConfig) {
+                       // update widgets according to getResDesc() values   
+       //      }
+       }
+
+       /**
+        * Usually, this method needs not to be rewritten
+        */
+    @Override
+       public boolean performCancel() {
+       //      if (! noContentOnPage && displayedConfig) {
+                       // do nothing in most cases
+       //      }
+        return true;
+    }
+    
+    /**
+     * Rewrite this method to restore default 
+     * values in current ResourceDescription
+     */
+       @Override
+       public void performDefaults() {
+       //      if (! noContentOnPage && displayedConfig) {
+                       // do something with getResDesc() fields
+       //      }
+       }
+    
+       /**
+        * Usually, this method needs not to be rewritten
+        */
+    @Override
+       public boolean performOk() {
+               if (! noContentOnPage && displayedConfig) {
+                       // do nothing in most cases
+               }
+       return super.performOk();
+    }
+
+       /**
+        * 
+        */
+       @Override
+       public void setVisible(boolean visible) {
+               super.setVisible(visible);
+               if (visible) {
+                       cfgChanged(getResDesc().getConfiguration());
+               }
+       }
+
+       /**
+        * No need to rewrite
+        */
+       @Override
+       protected boolean isSingle() { return true; }
+       
+       /**
+        * Call to "foreach" does not really matter, since we have not tabs
+        * But we intercept this call to perform other operations (apply). 
+        */
+       @Override
+       protected void forEach(int m, Object data) {
+               if (m == ICPropertyTab.APPLY)
+                       performApply(getResDesc(), (ICResourceDescription)data);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/BinaryParsTab.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/BinaryParsTab.java
new file mode 100644 (file)
index 0000000..69c18a7
--- /dev/null
@@ -0,0 +1,424 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.CoreModelUtil;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICMultiResourceDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.core.settings.model.ICTargetPlatformSetting;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.dialogs.ICOptionPage;
+import org.eclipse.cdt.utils.ui.controls.TabFolderLayout;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class BinaryParsTab extends AbstractCPropertyTab {
+       
+       /* Settings from binary parser pages are NOT saved by prior CDT version.
+        * So existing binary parsers _always_ use default values.
+        * Moreover, obsolete interface is used while attempting to save. 
+        * 
+        * We have to affect both parsers and pages 
+        * to teach them to save data really.
+        * 
+        * It will be done in next versions. Currently pages are disabled.
+        */
+       
+       private static final int DEFAULT_HEIGHT = 160;
+       private static final String ATTR_FILTER = "filter"; //$NON-NLS-1$
+       private static final String ATTR_NAME = "name"; //$NON-NLS-1$
+       private static final String ATTR_NAME_VISIBILITY = "visibility"; //$NON-NLS-1$
+       private static final String ATTR_VALUE = "value"; //$NON-NLS-1$
+       private static final String ATTR_VALUE_PRIVATE = "private"; //$NON-NLS-1$
+
+       protected Map<String, BinaryParserConfiguration> configMap;
+       protected Map<String, BinaryParserPageConfiguration> fParserPageMap = null;
+       protected Table table;
+       protected CheckboxTableViewer tv;
+       protected Composite parserGroup;
+       protected SashForm sashForm;
+
+       private ICTargetPlatformSetting tps;
+       
+       protected class BinaryParserConfiguration {
+               IExtension fExtension;
+               public BinaryParserConfiguration(IExtension extension) { fExtension = extension; }
+               public String getID() { return fExtension.getUniqueIdentifier();}
+               public String getName() { return fExtension.getLabel(); }
+               @Override
+               public String toString() { return fExtension.getUniqueIdentifier();     }
+               @Override
+               public boolean equals(Object obj) {
+                       if (obj instanceof BinaryParserConfiguration) {
+                               return this.getID().equals(((BinaryParserConfiguration) obj).getID());
+                       }
+                       return super.equals(obj);
+               }
+       }
+       
+       protected class BinaryParserPageConfiguration {
+               ICOptionPage dynamicPage;
+               IConfigurationElement fElement;
+               public BinaryParserPageConfiguration(IConfigurationElement element) {
+                       fElement = element;
+               }
+               public ICOptionPage getPage() throws CoreException {
+                       if (dynamicPage == null) {
+                               dynamicPage = (ICOptionPage) fElement.createExecutableExtension("class"); //$NON-NLS-1$
+                       }
+                       return dynamicPage;
+               }
+       }
+       
+       protected String getParserId() {
+               return CCorePlugin.BINARY_PARSER_SIMPLE_ID;
+       }
+
+       @Override
+       public void createControls(Composite parent) {
+               super.createControls(parent);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(usercomp, ICHelpContextIds.BINARY_PARSER_PAGE);
+
+               usercomp.setLayout(new GridLayout(1, false));
+               
+               sashForm = new SashForm(usercomp, SWT.NONE);
+               sashForm.setBackground(sashForm.getDisplay().getSystemColor(SWT.COLOR_GRAY));
+               sashForm.setOrientation(SWT.VERTICAL);
+               sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
+               
+               GridLayout layout = new GridLayout(2, false);
+               layout.marginHeight = 5;
+               sashForm.setLayout(layout);
+
+               Composite c1 = new Composite(sashForm, SWT.NONE);
+               c1.setLayout(new GridLayout(2, false));
+               setupLabel(c1, Messages.BinaryParsTab_0, 2, GridData.FILL_HORIZONTAL); 
+               table = new Table(c1, SWT.BORDER | SWT.CHECK | SWT.SINGLE);
+               table.setLayoutData(new GridData(GridData.FILL_BOTH));
+               table.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               handleBinaryParserChanged();
+                               updateButtons();
+               }});
+               tv = new CheckboxTableViewer(table);
+               tv.setContentProvider(new IStructuredContentProvider() {
+                       public Object[] getElements(Object inputElement) {
+                               return (Object[])inputElement;
+                       }
+                       public void dispose() {}
+                       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+               });
+               tv.setLabelProvider(new LabelProvider() {
+                       @Override
+                       public String getText(Object element) {
+                               String txt = (element != null) ? element.toString() : EMPTY_STR;
+                               if (element instanceof BinaryParserConfiguration)
+                                       txt = ((BinaryParserConfiguration)element).getName();
+                               return txt;
+                       }
+               });
+
+               tv.addCheckStateListener(new ICheckStateListener() {
+                       public void checkStateChanged(CheckStateChangedEvent e) {
+                               saveChecked();
+                       }});
+               
+               // get "standard" buttons on my own place
+               Composite c = new Composite(c1, SWT.NONE);
+               c.setLayoutData(new GridData(GridData.END));
+               initButtons(c, new String[] {MOVEUP_STR, MOVEDOWN_STR});
+
+               parserGroup = new Composite(sashForm, SWT.NULL);
+               GridData gd = new GridData();
+               parserGroup.setLayout(new TabFolderLayout());
+               
+               PixelConverter converter = new PixelConverter(parent);
+               gd.heightHint = converter.convertHorizontalDLUsToPixels(DEFAULT_HEIGHT);
+
+               gd.horizontalAlignment = GridData.FILL;
+               gd.grabExcessHorizontalSpace = true;
+               gd.grabExcessVerticalSpace = true;
+               gd.horizontalSpan = 2;
+               parserGroup.setLayoutData(gd);
+               
+           sashForm.setWeights(new int[] {100, 100});
+               initializeParserList();
+               initializeParserPageMap();
+               handleBinaryParserChanged();
+       }
+
+    @Override
+       public void setVisible(boolean _visible) {
+       super.setVisible(_visible);
+       page.enableConfigSelection(!_visible);
+    }
+
+       @Override
+       public void updateData(ICResourceDescription cfgd) {
+               String[] ids = null;
+               if (page.isForPrefs()) { // prefs
+                       if (cfgd != null &&     cfgd.getConfiguration() != null) {
+                               tps = cfgd.getConfiguration().getTargetPlatformSetting();
+                               if (tps != null)
+                                       ids = tps.getBinaryParserIds();
+                       }
+                       if (ids == null)        
+                               ids = new String[0]; // no selection
+               } else { // project
+                       ICConfigurationDescription[] cfgs = page.getCfgsEditable();
+                       ids = CoreModelUtil.getBinaryParserIds(cfgs);
+               }
+               Object[] data = new Object[configMap.size()];
+               HashMap<String, BinaryParserConfiguration> clone = new HashMap<String, BinaryParserConfiguration>(configMap);
+               // add checked elements
+               int i;
+               for (i=0; i<ids.length; i++) {
+                       data[i] = clone.get(ids[i]);
+                       clone.remove(ids[i]);
+               }
+               // add remaining parsers (unchecked)
+               Iterator<String> it = clone.keySet().iterator();
+//             i = 0;
+               while (it.hasNext()) {
+                       String s = it.next();
+                       data[i++] = clone.get(s);
+               }
+               tv.setInput(data);
+               tv.setAllChecked(false);
+               // set check marks
+               for (i=0; i<ids.length; i++) {
+                       if (configMap.containsKey(ids[i])) {
+                               tv.setChecked(configMap.get(ids[i]), true);
+                       }
+               }
+               updateButtons();
+       }
+       
+       private void initializeParserList() {
+               IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, CCorePlugin.BINARY_PARSER_SIMPLE_ID);
+               if (point != null) {
+                       IExtension[] exts = point.getExtensions();
+                       configMap = new HashMap<String, BinaryParserConfiguration>(exts.length);
+                       for (IExtension ext : exts) {
+                               if (isExtensionVisible(ext)) {
+                                       configMap.put(ext.getUniqueIdentifier(), new BinaryParserConfiguration(ext));
+                               }
+                       }
+               }
+       }
+
+       private void initializeParserPageMap() {
+               fParserPageMap = new HashMap<String, BinaryParserPageConfiguration>(5);
+
+               IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID, "BinaryParserPage"); //$NON-NLS-1$
+               IConfigurationElement[] infos = extensionPoint.getConfigurationElements();
+               for (IConfigurationElement info : infos) {
+                       if (info.getName().equals("parserPage")) { //$NON-NLS-1$
+                               String id = info.getAttribute("parserID"); //$NON-NLS-1$
+                               fParserPageMap.put(id, new BinaryParserPageConfiguration(info));
+                       }
+               }
+       }
+
+       private boolean isExtensionVisible(IExtension ext) {
+               IConfigurationElement[] elements = ext.getConfigurationElements();
+               for (IConfigurationElement element : elements) {
+                       IConfigurationElement[] children = element.getChildren(ATTR_FILTER);
+                       for (IConfigurationElement element2 : children) {
+                               String name = element2.getAttribute(ATTR_NAME);
+                               if (name != null && name.equals(ATTR_NAME_VISIBILITY)) {
+                                       String value = element2.getAttribute(ATTR_VALUE);
+                                       if (value != null && value.equals(ATTR_VALUE_PRIVATE)) {
+                                               return false;
+                                       }
+                               }
+                       }
+                       return true;
+               }
+               return false; // invalid extension definition (must have at least cextension elements)
+       }
+       
+       @Override
+       public void updateButtons() {
+               int cnt = table.getItemCount();
+               int pos = table.getSelectionIndex();
+               buttonSetEnabled(0, pos > 0);
+               buttonSetEnabled(1, pos != -1 && pos < (cnt - 1));
+       }
+       protected void handleBinaryParserChanged() {
+               String[] enabled = getBinaryParserIDs();
+               ICOptionPage dynamicPage;
+               for (String element : enabled) { // create all enabled pages
+                       dynamicPage = getBinaryParserPage(element);
+                       
+                       if (dynamicPage != null) {
+                               if (dynamicPage.getControl() == null) {
+                                       dynamicPage.setContainer(page);
+                                       dynamicPage.createControl(parserGroup);
+                               } 
+                               dynamicPage.setVisible(false);
+                       }
+               }
+               // Retrieve the dynamic UI for the current parser
+               String parserID = getCurrentBinaryParserID();
+               dynamicPage = getBinaryParserPage(parserID);
+               if (dynamicPage != null) { dynamicPage.setVisible(true); }
+       }
+       
+       protected String[] getBinaryParserIDs() {
+               return configMap.keySet().toArray(new String[configMap.keySet().size()]);
+       }
+
+       protected ICOptionPage getBinaryParserPage(String parserID) {
+               BinaryParserPageConfiguration configElement = fParserPageMap.get(parserID);
+               if (configElement != null) {
+                       try {
+                               return configElement.getPage();
+                       } catch (CoreException e) {}
+               }
+               return null;
+       }
+
+       protected String getCurrentBinaryParserID() {
+               int x = table.getSelectionIndex();
+               if (x < 0) return null;
+               return ((BinaryParserConfiguration)table.getItem(x).getData()).getID();
+       }
+
+       @Override
+       protected void performApply(ICResourceDescription src, ICResourceDescription dst) {
+               if (page.isMultiCfg()) {
+                       src = ((ICResourceDescription[])((ICMultiResourceDescription)src).getItems())[0];
+                       dst = ((ICResourceDescription[])((ICMultiResourceDescription)dst).getItems())[0];
+               } 
+               ICTargetPlatformSetting tps1 = src.getConfiguration().getTargetPlatformSetting();
+               ICTargetPlatformSetting tps2 = dst.getConfiguration().getTargetPlatformSetting();
+               if (tps1 != null && tps2 != null) { 
+                       tps2.setBinaryParserIds(tps1.getBinaryParserIds());
+               }
+       }
+       
+       @Override
+       protected void performDefaults() {
+               if (page.isForProject())
+                       CoreModelUtil.setBinaryParserIds(page.getCfgsEditable(), null);
+               else
+                       if (tps != null) 
+                               tps.setBinaryParserIds(null);
+               informPages(false); 
+               updateData(getResDesc());
+       }       
+       
+       private void informPages(boolean apply) {       
+               IProgressMonitor mon = new NullProgressMonitor();
+               Iterator<BinaryParserPageConfiguration> it = fParserPageMap.values().iterator();
+               
+               while (it.hasNext()) {
+                       try {
+                               ICOptionPage dynamicPage = (it.next()).getPage();
+                               if (dynamicPage.isValid() && dynamicPage.getControl() != null) {
+                                       if (apply)  
+                                               dynamicPage.performApply(mon);
+                                       else
+                                               dynamicPage.performDefaults();
+                               }
+                       } catch (CoreException e) {}
+               }
+       }
+       
+       @Override
+       public void buttonPressed(int i) {
+               switch (i) {
+               case 0:
+                       moveItem(true);
+                       break;
+               case 1:
+                       moveItem(false);
+                       break;
+               default:
+                       break;
+               }
+       }
+
+       // Move item up / down
+       private void moveItem(boolean up) {
+               int n = table.getSelectionIndex();
+               if (n < 0 || 
+                               (up && n == 0) || 
+                               (!up && n+1 == table.getItemCount()))
+                       return;
+               Object d = tv.getElementAt(n);
+               boolean checked = tv.getChecked(d);
+               tv.remove(d);
+               n = up ? n - 1 : n + 1;
+               tv.insert(d, n);
+               tv.setChecked(d, checked);
+               table.setSelection(n);
+               saveChecked();
+               updateButtons();
+       }
+       
+       private void saveChecked() {
+               Object[] objs = tv.getCheckedElements();
+               String[] ids = null;
+               if (objs != null) {
+                       ids = new String[objs.length];
+                       for (int i=0; i<objs.length; i++) {
+                               ids[i] = ((BinaryParserConfiguration)objs[i]).getID();
+                       }
+               }
+               if (page.isForPrefs()) {
+                       if (tps != null) tps.setBinaryParserIds(ids);
+               } else {
+                       CoreModelUtil.setBinaryParserIds(page.getCfgsEditable(), ids);
+               }
+       }
+       // This page can be displayed for project only
+       @Override
+       public boolean canBeVisible() {
+               return page.isForProject() || page.isForPrefs();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/BuildVarListDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/BuildVarListDialog.java
new file mode 100644 (file)
index 0000000..382cef8
--- /dev/null
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *     IBM Corporation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.core.variables.IStringVariable;
+import org.eclipse.core.variables.VariablesPlugin;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleAdapter;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * Displays CDT variables dialog with ability to filter.
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class BuildVarListDialog extends ElementListSelectionDialog {
+
+       private static final String TYPE = Messages.BuildVarListDialog_0; 
+    private IStringVariable[] sysVars = VariablesPlugin.getDefault().getStringVariableManager().getVariables();
+
+       private Text text;
+       private Label type;
+       private static final String LIST_DESCRIPTION = Messages.BuildVarListDialog_11; 
+       
+       public BuildVarListDialog(Shell parent, Object[] input) {
+               super(parent, new LabelProvider () {
+                       @Override
+                       public String getText(Object element) {
+                                       if (element instanceof ICdtVariable) 
+                                               return ((ICdtVariable)element).getName();
+                                       return super.getText(element);
+                       }});
+               setShellStyle(getShellStyle() | SWT.RESIZE);
+               setMessage(Messages.StringVariableSelectionDialog_message);
+               setMultipleSelection(false);
+               setElements(input);
+       }
+       
+       @Override
+       protected Control createDialogArea(Composite container) {
+               Composite c = (Composite) super.createDialogArea(container);
+
+               type = new Label(c, SWT.NONE);
+               type.setFont(container.getFont());
+               type.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+                       
+               Label desc = new Label(c, SWT.NONE);
+               desc.setFont(c.getFont());
+               desc.setText(Messages.StringVariableSelectionDialog_columnDescription);
+               desc.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               
+               text = new Text(c, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
+               text.setFont(container.getFont());
+               text.setEditable(false);
+               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.heightHint = 50;
+               text.setLayoutData(gd);
+               
+               //bug 189413 - adding label to build variable list for accessiblity
+               if (fFilteredList != null) {
+                       fFilteredList.getAccessible().addAccessibleListener(
+                   new AccessibleAdapter() {                       
+                       @Override
+                                       public void getName(AccessibleEvent e) {
+                               e.result = LIST_DESCRIPTION;
+                       }
+                   }
+               );
+               }
+               
+               return c;
+       }
+       
+       @Override
+       protected void handleSelectionChanged() {
+               super.handleSelectionChanged();
+               Object[] objects = getSelectedElements();
+               String descr = null;
+               if (objects.length == 1) {
+                       ICdtVariable v = (ICdtVariable)objects[0];
+                       // update type name
+                       type.setText(TYPE + " " + typeIntToString(v.getValueType())); //$NON-NLS-1$
+                       // search in system variables list
+                       for (int i = 0; i < sysVars.length; i++) {
+                               if (v.getName() == sysVars[i].getName()) {
+                                   descr = sysVars[i].getDescription();
+                                   break;
+                               }
+                       }
+               }
+               if (descr == null) 
+                       descr = Messages.BuildVarListDialog_10; 
+               text.setText(descr);
+       }
+
+       public static String typeIntToString(int type){
+               String stringType;
+               switch(type){
+               case ICdtVariable.VALUE_TEXT_LIST:
+                       stringType = Messages.BuildVarListDialog_1; 
+                       break;
+               case ICdtVariable.VALUE_PATH_FILE:
+                       stringType = Messages.BuildVarListDialog_2; 
+                       break;
+               case ICdtVariable.VALUE_PATH_FILE_LIST:
+                       stringType = Messages.BuildVarListDialog_3; 
+                       break;
+               case ICdtVariable.VALUE_PATH_DIR:
+                       stringType = Messages.BuildVarListDialog_4; 
+                       break;
+               case ICdtVariable.VALUE_PATH_DIR_LIST:
+                       stringType = Messages.BuildVarListDialog_5; 
+                       break;
+               case ICdtVariable.VALUE_PATH_ANY:
+                       stringType = Messages.BuildVarListDialog_6; 
+                       break;
+               case ICdtVariable.VALUE_PATH_ANY_LIST:
+                       stringType = Messages.BuildVarListDialog_7; 
+                       break;
+               case ICdtVariable.VALUE_TEXT:
+               default:
+                       stringType = Messages.BuildVarListDialog_8; 
+                       break;
+               }
+               return stringType;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTHelpContextIds.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTHelpContextIds.java
new file mode 100644 (file)
index 0000000..cf72825
--- /dev/null
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDTHelpContextIds {
+       public static final String PREFIX= CUIPlugin.PLUGIN_ID + "."; //$NON-NLS-1$
+
+       // Wizard pages
+       public static final String MAN_PROJ_PLATFORM_HELP = PREFIX + "new_proj_wiz_m_target"; //$NON-NLS-1$
+       public static final String MAN_PROJ_WIZ_NAME_PAGE = PREFIX + "new_proj_wiz_m_name"; //$NON-NLS-1$
+       public static final String MAN_PROJ_WIZ_PROJECTS_TAB = PREFIX + "new_proj_wiz_m_proj"; //$NON-NLS-1$
+       public static final String MAN_PROJ_WIZ_ERRORPARSERS_TAB = PREFIX + "new_proj_wiz_m_errorp"; //$NON-NLS-1$
+       public static final String MAN_PROJ_WIZ_INDEXER_TAB = PREFIX + "new_proj_wiz_m_cindexer"; //$NON-NLS-1$
+       public static final String MAN_PROJ_WIZ_BINARYPARSER_TAB = PREFIX + "new_proj_wiz_s_binary"; //$NON-NLS-1$
+       
+       public static final String MAN_PROJ_BUILD_PROP = PREFIX + "man_prop_build"; //$NON-NLS-1$
+       public static final String MAN_PROJ_ERROR_PARSER = PREFIX + "man_prop_error"; //$NON-NLS-1$
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTPrefUtil.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTPrefUtil.java
new file mode 100644 (file)
index 0000000..4422ba2
--- /dev/null
@@ -0,0 +1,332 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *     QNX Software Systems - [272416] Rework the working set configurations
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.TreeSet;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+import org.eclipse.cdt.internal.ui.workingsets.WorkingSetConfigurationManager;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ */
+public class CDTPrefUtil {
+       // boolean keys (KEY_NO-s are to be inverted !)
+       public static final String KEY_NOSUPP  = "wizard.show.unsupported.disable";  //$NON-NLS-1$
+       public static final String KEY_OTHERS  = "wizard.group.others.enable";  //$NON-NLS-1$
+       public static final String KEY_NOMNG   = "properties.manage.config.disable"; //$NON-NLS-1$
+       public static final String KEY_DTREE   = "properties.data.hierarchy.enable"; //$NON-NLS-1$
+       public static final String KEY_NOTOOLM   = "properties.toolchain.modification.disable"; //$NON-NLS-1$
+       public static final String KEY_EXPORT   = "properties.export.page.enable"; //$NON-NLS-1$
+       /** @since 5.2 Show the "Include Files" settings entry tab */
+       public static final String KEY_SHOW_INC_FILES = "properties.includefiles.page.enable"; //$NON-NLS-1$
+       /** @since 5.2 */
+       public static final String KEY_TIPBOX   = "properties.option.tipbox.enable"; //$NON-NLS-1$
+       // string keys
+       public static final String KEY_PREFTC  = "wizard.preferred.toolchains";  //$NON-NLS-1$
+       public static final String KEY_CONFSET = "workingsets.selected.configs";  //$NON-NLS-1$
+       // integer keys
+       public static final String KEY_POSSAVE  = "properties.save.position"; //$NON-NLS-1$
+               public static final int POSITION_SAVE_SIZE = 0;
+           public static final int POSITION_SAVE_NONE = 2;
+           public static final int POSITION_SAVE_BOTH = 3;
+       
+       public static final String KEY_DISC_NAMES  = "properties.discovery.naming"; //$NON-NLS-1$
+               public static final int DISC_NAMING_UNIQUE_OR_BOTH = 0;
+               public static final int DISC_NAMING_UNIQUE_OR_IDS = 1;
+               public static final int DISC_NAMING_ALWAYS_BOTH = 2;
+               public static final int DISC_NAMING_ALWAYS_IDS = 3;
+               public static final int DISC_NAMING_DEFAULT = DISC_NAMING_UNIQUE_OR_BOTH;
+       
+       /** Property key used for string list display mode for multi-configuration edits (conjunction/disjunction) */
+       public static final String KEY_DMODE = "properties.multi.displ.mode"; //$NON-NLS-1$
+               /** Conjunction implies showing only common elements (intersection) */
+               public static final int DMODE_CONJUNCTION = 1;
+               /** Disjunction implies showing all elements (union) */
+               public static final int DMODE_DISJUNCTION = 2;
+               
+       /** Property key used for string list write mode for multi-configuration edits (modify/replace) */
+       public static final String KEY_WMODE = "properties.multi.write.mode"; //$NON-NLS-1$
+               /** Modify implies changing only given elements and not changing any others */
+               public static final int WMODE_MODIFY  = 4;
+               /** Replace implies replacing the whole list with the given one, overwriting old entries */
+               public static final int WMODE_REPLACE = 8;
+               
+       public static final String NULL = "NULL"; //$NON-NLS-1$
+       private static final IPreferenceStore pref = CUIPlugin.getDefault().getPreferenceStore();
+       private static final String DELIMITER = " "; //$NON-NLS-1$
+       public static final String CONFSETDEL = "\f"; //$NON-NLS-1$
+       private static LinkedList<String> preferredTCs = null;
+       
+       public static final Object[] EMPTY_ARRAY = new Object[0];
+
+       // low-level methods
+       public static boolean getBool(String key) { return pref.getBoolean(key); }
+       public static void setBool(String key, boolean val) { pref.setValue(key, val); }
+       public static int getInt(String key) { return pref.getInt(key); }
+       public static void setInt(String key, int val) { pref.setValue(key, val); }
+       public static String getStr(String key) { return pref.getString(key); }
+       public static void setStr(String key, String val) {     pref.setValue(key, val); }
+
+       // up-level methods
+       public static void readPreferredTCs() {
+               preferredTCs = new LinkedList<String>(Arrays.asList(getStr(KEY_PREFTC).split(DELIMITER)));
+       }
+       public static List<String> getPreferredTCs() {
+               if (preferredTCs == null) readPreferredTCs(); 
+               return preferredTCs; 
+       }
+       public static void delPreferredTC(String s) { 
+               if (preferredTCs == null) readPreferredTCs(); 
+               preferredTCs.remove(s); 
+       }
+       public static void addPreferredTC(String s) {
+               if (preferredTCs == null) readPreferredTCs(); 
+               if (!preferredTCs.contains(s)) preferredTCs.add(s); 
+       }
+       public static void cleanPreferredTCs() {
+               setStr(KEY_PREFTC, IPreferenceStore.STRING_DEFAULT_DEFAULT);
+               readPreferredTCs(); 
+       }
+       public static void savePreferredTCs() {
+               if (preferredTCs == null) return; 
+               Iterator<String> it = preferredTCs.iterator();
+               StringBuilder b = new StringBuilder(); 
+               while (it.hasNext()) {
+                       String s = it.next();
+                       if (s == null) continue; 
+                       b.append(s);
+                       b.append(DELIMITER);
+               }
+               setStr(KEY_PREFTC, b.toString().trim());
+       }
+       
+       /**
+        * Returns string list display mode for multi-configuration edits (conjunction/disjunction).
+        * 
+        * @return the mode which can be either {@link CDTPrefUtil#DMODE_CONJUNCTION} (default value)
+        *    or else {@link CDTPrefUtil#DMODE_DISJUNCTION}.
+        * 
+        * @since 5.3
+        */
+       public static int getMultiCfgStringListDisplayMode() {
+               int mode = getInt(KEY_DMODE);
+               if (mode!=DMODE_CONJUNCTION && mode!=DMODE_DISJUNCTION) {
+                       mode = DMODE_CONJUNCTION;
+               }
+               return mode;
+       }
+       
+       /**
+        * Sets string list display mode for multi-configuration edits (conjunction/disjunction).
+        * 
+        * @param mode must be either {@link CDTPrefUtil#DMODE_CONJUNCTION}
+        *    or {@link CDTPrefUtil#DMODE_DISJUNCTION}.
+        * 
+        * @since 5.3
+        */
+       public static void setMultiCfgStringListDisplayMode(int mode) {
+               setInt(KEY_DMODE, mode);
+       }
+       
+       /**
+        * Returns string list write mode for multi-configuration edits (modify/replace).
+        * 
+        * @return the mode which can be either {@link CDTPrefUtil#WMODE_MODIFY} (default value)
+        *    or else {@link CDTPrefUtil#WMODE_REPLACE}.
+        * 
+        * @since 5.3
+        */
+       public static int getMultiCfgStringListWriteMode() {
+               int mode = getInt(KEY_WMODE);
+               if (mode!=WMODE_MODIFY && mode!=WMODE_REPLACE) {
+                       mode = WMODE_MODIFY;
+               }
+               return mode;
+       }
+       
+       /**
+        * Sets string list write mode for multi-configuration edits (modify/replace).
+        * 
+        * @param mode must be either {@link CDTPrefUtil#WMODE_MODIFY}
+        *    or {@link CDTPrefUtil#WMODE_REPLACE}.
+        * 
+        * @since 5.3
+        */
+       public static void setMultiCfgStringListWriteMode(int mode) {
+               setInt(KEY_WMODE, mode);
+       }
+       
+       /**
+        * @deprecated as of CDT 8.0. Use {@link StringListModeControl} to display string list modes.
+        */
+       @Deprecated
+       public static String getDMode() {
+               String s = null;
+               switch(getMultiCfgStringListDisplayMode()) {
+               case DMODE_CONJUNCTION:
+                       s = Messages.EnvironmentTab_17;  
+                       break;
+               case DMODE_DISJUNCTION:
+                       s = Messages.EnvironmentTab_18;  
+                       break;
+               }
+               return Messages.EnvironmentTab_19 + s;  
+       }
+       
+       /**
+        * @deprecated as of CDT 8.0. Use {@link StringListModeControl} to display string list modes.
+        */
+       @Deprecated
+       public static String getWMode() {
+               String s = null;
+               switch(getMultiCfgStringListWriteMode()) {
+               case WMODE_MODIFY:
+                       s = Messages.EnvironmentTab_24;  
+                       break;
+               case WMODE_REPLACE:
+                       s = Messages.EnvironmentTab_21;  
+                       break;
+               }
+               return Messages.EnvironmentTab_22 + s;  
+       }
+       
+       /**
+        * Toggle string list display mode: conjunction <-> disjunction.
+        */
+       public static void spinDMode() {
+               int mode = getMultiCfgStringListDisplayMode();
+               if (mode==DMODE_CONJUNCTION) {
+                       mode = DMODE_DISJUNCTION;
+               } else {
+                       mode = DMODE_CONJUNCTION;
+               }
+               setMultiCfgStringListDisplayMode(mode);
+       }
+
+       /**
+        * Toggle string list display mode: modify <-> replace.
+        */
+       public static void spinWMode() {
+               int mode = getMultiCfgStringListWriteMode();
+               if (mode==WMODE_MODIFY) {
+                       mode = WMODE_REPLACE;
+               } else {
+                       mode = WMODE_MODIFY;
+               }
+               setMultiCfgStringListWriteMode(mode);
+       }
+
+       public static final String[] getStrListForDisplay(String[][] input) {
+               return getStrListForDisplay(input, getMultiCfgStringListDisplayMode());
+       }
+       
+       private static final String[] getStrListForDisplay(String[][] input, int mode) {
+               Object[] ob = getListForDisplay(input, getMultiCfgStringListDisplayMode(), null);
+               String[] ss = new String[ob.length];
+               System.arraycopy(ob, 0, ss, 0, ob.length);
+               return ss;
+       }
+       
+       public static final Object[] getListForDisplay(Object[][] input, Comparator<Object> cmp) {
+               return getListForDisplay(input, getMultiCfgStringListDisplayMode(), cmp);
+       }
+       /**
+        * Utility method forms string list
+        * according to current list display mode
+        * 
+        * @param input - array of string arrays
+        * @return
+        */
+       private static final Object[] getListForDisplay(Object[][] input, int mode, Comparator<Object> cmp) {
+               if (input == null || input.length == 0)
+                       return EMPTY_ARRAY;
+               if (input.length == 1) {
+                       return (input[0] == null) ?
+                                       EMPTY_ARRAY :
+                                       input[0];
+               }
+
+               Object[] s1 = input[0];
+               if (s1 == null || 
+                       s1.length == 0)
+                       return EMPTY_ARRAY;
+               if (getMultiCfgStringListDisplayMode() == DMODE_CONJUNCTION) 
+               { 
+                       ArrayList<Object> lst = new ArrayList<Object>();
+                       for (int i=0; i<s1.length; i++) {
+                               if (s1[i] == null)
+                                       continue;
+                               boolean found = true;
+                               for (int k = 1; k<input.length; k++) {
+                                       Object[] s2 = input[k];
+                                       if (s2 == null || s2.length == 0)
+                                               return EMPTY_ARRAY;
+                                       if (i == 0)
+                                               Arrays.sort(s2, cmp);
+                                       if (Arrays.binarySearch(s2, s1[i], cmp) < 0) {
+                                               found = false;
+                                               break;
+                                       }
+                               }
+                               if (found) {
+                                       lst.add(s1[i]);
+                               }
+                       }
+                       return lst.toArray();
+               }
+               TreeSet<Object> lst = new TreeSet<Object>(cmp); // set, to avoid doubles
+               for (Object[] element : input) {
+                       if (element == null ||
+                               element.length == 0)
+                               continue;
+                       for (Object element2 : element)
+                               lst.add(element2);
+               }
+               s1 = lst.toArray();
+               Arrays.sort(s1, cmp);
+               return s1;
+       }
+       
+       /**
+        * @deprecated Use the {@link WorkingSetConfigurationManager} class, instead.
+        */
+       @Deprecated
+       public static List<String> readConfigSets() {
+               return new LinkedList<String>(Arrays.asList(getStr(KEY_CONFSET).split(CONFSETDEL)));
+       }
+       
+       /**
+        * @deprecated Use the {@link WorkingSetConfigurationManager} class, instead.
+        */
+       @Deprecated
+       public static void saveConfigSets(List<String> out) {
+               StringBuilder b = new StringBuilder(); 
+               for (String s : out) {
+                       if (s == null) continue; 
+                       b.append(s);
+                       b.append(CONFSETDEL);
+               }
+               setStr(KEY_CONFSET, b.toString());
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTPropertyManager.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTPropertyManager.java
new file mode 100644 (file)
index 0000000..2a3deb3
--- /dev/null
@@ -0,0 +1,188 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.widgets.Widget;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * This class is intended to handle  
+ * 
+ * When new propertypage is created, it should request 
+ * project description by method 
+ * getProjectDescription()
+ * This method, in addition, registers page in list.
+ * 
+ * While page is active, it can change this description
+ * but should not set it, to avoid inconsistency.
+ * 
+ * When page's "performOK" called, it should call
+ * manager's  method
+ * performOk()
+ *
+ * Registered pages can call {@link CDTPropertyManager#remove(Object)}
+ * to explicitly remove themselves from this manager.
+ *
+ * In addition, there are utility methods for pages: 
+ * getPagesCount()
+ * getPage()
+ * isSaveDone()
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class CDTPropertyManager {
+
+       private static ArrayList<Object> pages = new ArrayList<Object>();
+       private static ICProjectDescription prjd = null;
+       private static boolean saveDone  = false;
+       private static IProject project = null;
+       private static DListener dListener = new DListener();
+       
+       
+       public static ICProjectDescription getProjectDescription(PropertyPage p, IProject prj) {
+               return get(p, prj);
+       }       
+       public static ICProjectDescription getProjectDescription(Widget w, IProject prj) {
+               return get(w, prj);
+       }       
+       public static ICProjectDescription getProjectDescription(IProject prj) {
+               return get(null, prj);
+       }       
+       
+       private static ICProjectDescription get(Object p, IProject prj) {
+               // New session - clean static variables
+               if (pages.size() == 0) {
+                       project = null;
+                       prjd = null;
+                       saveDone = false;
+               }
+               // Register new client
+               if (p != null && !pages.contains(p)) {
+                       pages.add(p);
+                       if (p instanceof PropertyPage) {
+                               if (((PropertyPage)p).getControl() != null) 
+                                       ((PropertyPage)p).getControl().addDisposeListener(dListener);
+                       } else if (p instanceof Widget) {
+                               ((Widget)p).addDisposeListener(dListener);
+                       }
+               }
+               // Check that we are working with the same project 
+               if (project == null || !project.equals(prj)) {
+                       project = prj;
+                       prjd = null;
+               }
+               // obtain description if it's needed.
+               if (prjd == null) {
+                       prjd = CoreModel.getDefault().getProjectDescription(prj);
+               }
+               return prjd;
+       }
+
+       /**
+        * Performs optimized (single-time) saving
+        * @param p - widget which calls this functionality
+        */
+       public static void performOk(Object p) {
+               if (saveDone) return;
+
+               performOkForced(p);
+               
+               if (pages.size() == 0) {
+                       project = null;
+                       prjd = null;
+                       saveDone = false;
+               }
+       }
+       
+       public static void performCancel(Object p) {
+               saveDone = true;
+               
+               if (pages.size() == 0) {
+                       project = null;
+                       prjd = null;
+                       saveDone = false;
+               }
+       }
+
+       /**
+        * Explicitly remove the page from this CDTPropertyManager
+        * @param p
+        * @since 5.1
+        */
+       public static void remove(Object p) {
+               DListener.dispose(p);
+       }
+
+       /**
+        * Performs mandatory saving 
+        * @param p
+        */
+       public static void performOkForced(Object p) {
+               saveDone = true;
+               try {
+                       CoreModel.getDefault().setProjectDescription(project, prjd);
+               } catch (CoreException e) {
+                       CUIPlugin.logError(Messages.AbstractPage_11 + e.getLocalizedMessage()); 
+               }
+               
+               if (pages.size() == 0) {
+                       project = null;
+                       prjd = null;
+                       saveDone = false;
+               }
+       }
+       
+       // pages utilities
+       public static boolean isSaveDone() { return saveDone; } 
+       public static int getPagesCount() {     return pages.size(); }
+       public static Object getPage(int index) { return pages.get(index); }
+
+       // Removes disposed items from list
+       static class DListener implements DisposeListener {
+               public static void dispose (Object w) {
+                       if (pages.contains(w)) { // Widget ?    
+                               pages.remove(w); 
+                       } else {                 // Property Page ?
+                               for (Object ob : pages) {
+                                       if (ob != null && ob instanceof PropertyPage) {
+                                               if (((PropertyPage)ob).getControl().equals(w)) {
+                                                       pages.remove(ob);
+                                                       break;
+                                               }
+                                       }
+                               }
+                       }
+
+                       if (pages.isEmpty()) {
+                               saveDone = true;
+                               project = null;
+                               prjd = null;
+                               saveDone = false;
+                       }
+               }
+               public void widgetDisposed(DisposeEvent e) {
+                       dispose(e.widget);
+               }
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTStatusInfo.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTStatusInfo.java
new file mode 100644 (file)
index 0000000..1809da3
--- /dev/null
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 Intel Corporation and others
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * Simple IStatus implementation to avoid using internal classes.
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class CDTStatusInfo implements IStatus {
+       private String text;
+       private int code;
+
+       public CDTStatusInfo() {this(OK, null); }
+       public CDTStatusInfo(int _code, String _text) {
+               text= _text;
+               code= _code;
+       }               
+       public IStatus[] getChildren() { return new IStatus[0];} 
+       public int getCode() { return code; } 
+       public Throwable getException() { return null; }
+       public String getMessage() { return text; }
+       public String getPlugin() { return CUIPlugin.PLUGIN_ID; }
+       public int getSeverity() { return code; }
+       public boolean isMultiStatus() { return false; }
+       public boolean isOK() { return (code == OK); }
+       public boolean matches(int mask) { return (code & mask) != 0; }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTUIListComparator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CDTUIListComparator.java
new file mode 100644 (file)
index 0000000..cb0b691
--- /dev/null
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 Intel Corporation and others
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.util.Comparator;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+
+import org.eclipse.cdt.core.model.util.CDTListComparator;
+import org.eclipse.cdt.ui.newui.AbstractExportTab.ExtData;
+import org.eclipse.cdt.ui.wizards.EntryDescriptor;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class CDTUIListComparator extends CDTListComparator {
+       private static Comparator<Object> comparator = null;
+
+       public static Comparator<Object> getInstance() {
+               if (comparator == null)
+                       comparator = new CDTUIListComparator();
+               return comparator;
+       }
+       @Override
+       public int compare(Object a, Object b) {
+               if (a == null || b == null) 
+                       return 0;
+               if (a instanceof ExtData) {
+                       ExtData c1 = (ExtData)a;
+                       ExtData c2 = (ExtData)b;
+                       return c1.getName().compareToIgnoreCase(c2.getName());
+               } 
+               if (a instanceof IConfigurationElement) {
+                       IConfigurationElement e1 = (IConfigurationElement)a;
+                       IConfigurationElement e2 = (IConfigurationElement)b;
+                       return AbstractPage.getWeight(e1).compareTo(AbstractPage.getWeight(e2)); 
+               }
+               if (a instanceof EntryDescriptor) {
+                       EntryDescriptor c1 = (EntryDescriptor) a;
+                       EntryDescriptor c2 = (EntryDescriptor) b;
+                       return c1.getName().compareToIgnoreCase(c2.getName());
+               }
+               return super.compare(a, b);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationOutputTab.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationOutputTab.java
new file mode 100644 (file)
index 0000000..e551e86
--- /dev/null
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.swt.widgets.Composite;
+
+import org.eclipse.cdt.core.settings.model.COutputEntry;
+import org.eclipse.cdt.core.settings.model.ICExclusionPatternPathEntry;
+import org.eclipse.cdt.core.settings.model.ICOutputEntry;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class CLocationOutputTab extends CLocationTab {
+
+       @Override
+       public void createControls(Composite parent) {
+               super.createControls(parent);
+               label.setText(Messages.CLocationOutputTab_0); 
+       }
+
+       @Override
+       public ICExclusionPatternPathEntry[] getEntries(ICResourceDescription cfgd) {
+               return cfgd.getConfiguration().getBuildSetting().getOutputDirectories();
+       }
+       @Override
+       public void setEntries(ICResourceDescription cfgd, ICExclusionPatternPathEntry[] data) {
+               ICOutputEntry[] out = null;
+               if (data != null) {
+                       out = new ICOutputEntry[data.length];
+                       for (int i=0; i<out.length; i++) out[i] = (ICOutputEntry)data[i];
+               }
+               cfgd.getConfiguration().getBuildSetting().setOutputDirectories(out);
+       }
+       @Override
+       public ICExclusionPatternPathEntry newEntry(IPath p, IPath[] ex, boolean isWorkspacePath) {
+               return new COutputEntry(p, ex, isWorkspacePath ? ICSettingEntry.VALUE_WORKSPACE_PATH : 0);
+       }
+       @Override
+       public ICExclusionPatternPathEntry newEntry(IFolder f, IPath[] ex, boolean isWorkspacePath) {
+               return new COutputEntry(f, ex, isWorkspacePath ? ICSettingEntry.VALUE_WORKSPACE_PATH : 0);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationSourceTab.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationSourceTab.java
new file mode 100644 (file)
index 0000000..94a59ea
--- /dev/null
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.swt.widgets.Composite;
+
+import org.eclipse.cdt.core.settings.model.CSourceEntry;
+import org.eclipse.cdt.core.settings.model.ICExclusionPatternPathEntry;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICSourceEntry;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class CLocationSourceTab extends CLocationTab {
+       
+       @Override
+       public void createControls(Composite parent) {
+               super.createControls(parent);
+               label.setText(Messages.CLocationSourceTab_0);  
+       }
+       
+       @Override
+       public ICExclusionPatternPathEntry newEntry(IPath p, IPath[] ex, boolean isWorkspacePath) {
+               return new CSourceEntry(p, ex, isWorkspacePath ? ICSettingEntry.VALUE_WORKSPACE_PATH : 0);
+       }
+       @Override
+       public ICExclusionPatternPathEntry newEntry(IFolder f, IPath[] ex, boolean isWorkspacePath) {
+               return new CSourceEntry(f, ex, isWorkspacePath ? ICSettingEntry.VALUE_WORKSPACE_PATH : 0);
+       }
+       @Override
+       public ICExclusionPatternPathEntry[] getEntries(ICResourceDescription cfgd) {
+               return cfgd.getConfiguration().getSourceEntries();
+       }
+       @Override
+       public void setEntries(ICResourceDescription cfgd, ICExclusionPatternPathEntry[] data) {
+               ICSourceEntry[] out = null;
+               if (data != null) {
+                       out = new ICSourceEntry[data.length];
+                       for (int i=0; i<out.length; i++) out[i] = (ICSourceEntry)data[i];
+               }
+               try {
+                       cfgd.getConfiguration().setSourceEntries(out);
+               } catch (CoreException e) {}
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationTab.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/CLocationTab.java
new file mode 100644 (file)
index 0000000..6ba3867
--- /dev/null
@@ -0,0 +1,510 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.NewFolderDialog;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICExclusionPatternPathEntry;
+import org.eclipse.cdt.core.settings.model.ICMultiItemsHolder;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.ui.CDTSharedImages;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * CLocationTab implements common features for "Source Location" and "Output Location"
+ * tabs in project preferences.
+ *
+ */
+public abstract class CLocationTab extends AbstractCPropertyTab {
+
+       private final Image IMG_EN = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_CFOLDER);
+       private final Image IMG_FI = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_EXCLUSION_FILTER_ATTRIB);
+       
+       Label label;
+       TreeViewer tree;
+       ArrayList<_Entry> src;
+       ICResourceDescription cfgd;
+       ICProject cprj;
+       
+       class _Filter {
+               _Entry entry; 
+               _Filter(_Entry _entry) { entry = _entry; }
+               
+               public IPath[] getExtPaths() {
+                       IPath[] p = null;
+                       p = entry.ent.getExclusionPatterns();
+                       return p;
+               }
+               
+               public String[] getExts() {
+                       IPath[] p = getExtPaths();
+                       if (p == null || p.length == 0) 
+                               return new String[0];
+                       String[] s = new String[p.length];
+                       for (int i=0; i<p.length; i++) 
+                               s[i] = p[i].toOSString();
+                       return s;
+               }
+               
+               @Override
+               public String toString() {
+                       String[] s = getExts();
+                       if (s.length == 0) 
+                               return Messages.CLocationTab_0; 
+                       String x = Messages.CLocationTab_1; 
+                       for (String element : s)
+                               x = x + element + Messages.CLocationTab_2; 
+                       x = x.substring(0, x.length() - 2) + Messages.CLocationTab_3; 
+                       return x;
+               } 
+       }
+       
+       class _Entry {
+               ICExclusionPatternPathEntry ent;
+               _Filter[] f = new _Filter[1];
+               _Entry(ICExclusionPatternPathEntry _ent) { 
+                       ent = _ent;
+                       f[0] = new _Filter(this);
+               }
+               @Override
+               public String toString() { 
+                       return getPath() == null ? 
+                                       EMPTY_STR : 
+                                       getPath().toString();
+               } 
+
+               public IPath getPath() { 
+                       return ent.isValueWorkspacePath() ? 
+                                       ent.getFullPath() : 
+                                       ent.getLocation(); 
+               } 
+       }
+       
+       @Override
+       public void createControls(Composite parent) {
+               super.createControls(parent);
+               usercomp.setLayout(new GridLayout(1, false));
+               label = new Label(usercomp, SWT.NONE);
+               label.setLayoutData(new GridData(GridData.BEGINNING));
+               tree = new TreeViewer(usercomp);
+               tree.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
+               tree.getTree().addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               updateButtons();
+                       }});
+               
+               initButtons(new String[] {Messages.CLocationTab_4, Messages.CLocationTab_5, Messages.CLocationTab_6, Messages.CLocationTab_7}, 150); 
+               tree.setContentProvider(new ITreeContentProvider() {
+                       public Object[] getChildren(Object parentElement) {
+                               if (parentElement instanceof _Entry)
+                                       return ((_Entry)parentElement).f;
+                               return null;
+                       }
+                       public Object getParent(Object element) {
+                               if (element instanceof _Filter)
+                                       return ((_Filter)element).entry;
+                               return null;
+                       }
+                       public boolean hasChildren(Object element) {
+                               return (element instanceof _Entry);
+                       }
+                       public Object[] getElements(Object inputElement) {
+                               return src.toArray(new _Entry[src.size()]);
+                       }
+                       public void dispose() {}
+                       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+                       }});
+
+               tree.setLabelProvider(new LabelProvider() {
+                       @Override
+                       public Image getImage(Object element) {
+                               if (element instanceof _Entry)
+                                       return IMG_EN;
+                               else if (element instanceof _Filter)
+                                       return IMG_FI;
+                               else 
+                                       return null;
+                       }
+               });
+       }
+
+       /**
+        * Add, Create/Link: always enabled
+        * Edit: enabled if 1 element selected (entry or filter)
+        * Delete: enabled if selected element is entry
+        */
+       @Override
+       protected void updateButtons() {
+               TreeItem[] sel = tree.getTree().getSelection();
+       buttonSetEnabled(2, sel.length == 1);
+       buttonSetEnabled(3, sel.length > 0 && sel[0].getData() instanceof _Entry);
+       }
+       
+       @Override
+       public void buttonPressed(int x) {
+               Shell shell = usercomp.getShell();
+               TreeItem[] sel = tree.getTree().getSelection();
+               switch (x) {
+               // add
+               case 0:
+                       String[] ss = getProjectDialog(shell);
+                       if (ss != null) {
+                               for (String element : ss)
+                                       src.add(new _Entry(newEntry(new Path(element), new IPath[0], true)));
+                               saveData();
+                       }
+                       break;
+               // create / link        
+               case 1:
+                       NewFolderDialog  d = new NewFolderDialog(shell, page.getProject()) {
+                               @Override
+                               public void create() {
+                                       super.create();
+                                       handleAdvancedButtonSelect();
+                               }
+                       };
+                       if (d.open() == Window.OK) {
+                               IFolder f = (IFolder)d.getFirstResult();
+                               src.add(new _Entry(newEntry(f, new IPath[0], !f.isLinked())));
+                               saveData();
+                       }
+                       break;
+               // edit filter  
+               case 2:
+                       if (sel.length == 0) return;
+                       Object data = sel[0].getData();
+                       _Entry entry = null;
+                       if (data instanceof _Entry) 
+                               entry = (_Entry)data;
+                       else if (data instanceof _Filter) 
+                               entry = ((_Filter)data).entry;
+                       else return;
+                       ExPatternDialog dialog = new ExPatternDialog(usercomp.getShell(), entry.ent.getExclusionPatterns(), entry.getPath(), page.getProject());
+                       if (dialog.open() == Window.OK) {
+                               IPath[] ps = dialog.getExclusionPattern();
+                               IPath path = entry.getPath();
+                               boolean isWsp = entry.ent.isValueWorkspacePath();
+                               entry.ent = newEntry(path, ps, isWsp);
+                               saveData();
+                       }
+                       break;
+               case 3:
+                       if (sel.length == 0) return;
+                       for (TreeItem element : sel) {
+                                       if (element.getData() instanceof _Entry) src.remove(element.getData());
+                               }
+                       saveData();
+                       break;
+               default:
+                       break;
+               }
+       }
+       
+       private void saveData() {
+               ICExclusionPatternPathEntry[] p = new ICExclusionPatternPathEntry[src.size()];
+               Iterator<_Entry> it = src.iterator();
+               int i=0;
+               while(it.hasNext()) { p[i++] = (it.next()).ent; }
+               setEntries(cfgd, p);
+               tree.setInput(cfgd);
+               updateData(cfgd);
+               if (page instanceof AbstractPage) {
+                       ICConfigurationDescription cfgDescription = cfgd.getConfiguration();
+                       ((AbstractPage)page).cfgChanged(cfgDescription);
+               }
+       }
+       
+       @Override
+       public void updateData(ICResourceDescription _cfgd) {
+               if (page.isMultiCfg()) {
+                       setAllVisible(false, ""); //$NON-NLS-1$
+                       return;
+               }
+               
+               cfgd = _cfgd;
+               IAdaptable ad = page.getElement();
+               if (ad instanceof ICProject) {
+                       cprj = (ICProject)ad;
+               }
+               IResource rc = (IResource)ad;
+               
+               setAllVisible(true, null);
+               
+               src = new ArrayList<_Entry>();
+               _Entry selectedSourcePath = null;
+               for (ICExclusionPatternPathEntry e : getEntries(cfgd)) {
+                       _Entry entry = new _Entry(e);
+                       if (entry.ent.isValueWorkspacePath() && entry.ent.getFullPath().equals(rc.getFullPath())) {
+                               selectedSourcePath = entry;
+                       }
+                       src.add(entry);
+               }
+               tree.setInput(src);
+               if (selectedSourcePath!=null) {
+                       ISelection selection = new StructuredSelection(new Object[] {selectedSourcePath});
+                       tree.setSelection(selection);
+               }
+               
+               updateButtons();
+       }
+
+       protected abstract ICExclusionPatternPathEntry[] getEntries(ICResourceDescription cfgd);
+       protected abstract void setEntries (ICResourceDescription cfgd, ICExclusionPatternPathEntry[] data);
+       protected abstract ICExclusionPatternPathEntry newEntry(IPath p, IPath[] ex, boolean workspacePath);
+       protected abstract ICExclusionPatternPathEntry newEntry(IFolder f, IPath[] ex, boolean workspacePath);
+       
+       @Override
+       protected void performApply(ICResourceDescription src, ICResourceDescription dst) {
+               setEntries(dst, getEntries(src));
+       }
+
+       @Override
+       protected void performDefaults() {
+                       setEntries(cfgd, null);
+                       updateData(cfgd);
+               }
+
+       
+       // This page can be displayed either for project or for folder
+       @Override
+       public boolean canBeVisible() {
+               if (page.getResDesc() instanceof ICMultiItemsHolder)
+                       return false; // cannot work with multi cfg
+               
+               return page.isForProject() || page.isForFolder();
+       }
+       
+       private String[] getProjectDialog(Shell shell) {
+               Set<IPath> set = new HashSet<IPath>(src.size());
+               for (_Entry e : src)
+                       set.add(e.getPath());
+               
+               LocDialog dialog = new LocDialog(shell, set);
+               dialog.setInput(page.getProject());
+               
+               dialog.setTitle(WORKSPACE_DIR_DIALOG_TITLE);
+               dialog.setMessage(WORKSPACE_DIR_DIALOG_MSG);
+               if (dialog.open() == Window.OK) {
+                       Object[] resources = dialog.getResult();
+                       if (resources != null) {
+                               String[] ss = new String[resources.length];
+                               for (int i=0; i<resources.length; i++)
+                                       ss[i] = ((Holder)resources[i]).getPath().toString();
+                               return ss;
+                       }
+               }
+               return null;
+       }
+
+       /**
+        * This class should hold elements for source location tree 
+        */
+       class Holder implements IAdaptable {
+               private IFolder  f = null;
+               private boolean isRoot = false;
+               private IPath p = null;
+               
+               Holder(IProject _p) {
+                       f = _p.getFolder(_p.getName());
+                       isRoot = true;
+                       p = _p.getFullPath();
+               }
+               
+               Holder(IFolder _f) {
+                       f = _f;
+                       isRoot = false;
+                       p = _f.getFullPath();
+               }
+               
+               @SuppressWarnings("rawtypes")
+               public Object getAdapter(Class adapter) {
+                       return f.getAdapter(adapter);
+               }
+               public boolean isRoot() {
+                       return isRoot;
+               }
+               public IFolder getFolder() {
+                       return f;
+               }
+               public IPath getPath() {
+                       return p;
+               }
+
+               private CLocationTab getOuterType() {
+                       return CLocationTab.this;
+               }
+       
+               @Override
+               public int hashCode() {
+                       final int prime = 31;
+                       int result = 1;
+                       result = prime * result + getOuterType().hashCode();
+                       result = prime * result + ((p == null) ? 0 : p.hashCode());
+                       result = prime * result + (isRoot ? 1231 : 1237);
+                       return result;
+               }
+
+               @Override
+               public boolean equals(Object obj) {
+                       if (this == obj)
+                               return true;
+                       if (obj == null)
+                               return false;
+                       if (getClass() != obj.getClass())
+                               return false;
+                       Holder other = (Holder) obj;
+                       if (!getOuterType().equals(other.getOuterType()))
+                               return false;
+                       if (isRoot != other.isRoot)
+                               return false;
+                       if (p == null) {
+                               if (other.p != null)
+                                       return false;
+                       } else if (!p.equals(other.p))
+                               return false;
+                       return true;
+               }
+               
+               /**
+                * For debugging purpose only
+                * @see java.lang.Object#toString()
+                */
+               @SuppressWarnings("nls")
+               @Override
+               public String toString() {
+                       return "[Holder] " + p;
+               }
+       }
+       
+       class LocDialog extends  ElementTreeSelectionDialog {
+               Set <IPath> existing;
+               
+               public LocDialog(Shell parent, Set <IPath> ex) {
+                       super(parent,
+                                       
+                       new WorkbenchLabelProvider() {
+                           @Override
+                               protected String decorateText(String input, Object element) {
+                               if (element instanceof Holder &&
+                                   ((Holder)element).isRoot())
+                                               return Messages.CLocationTab_8; 
+                               return super.decorateText(input, element);
+                           }
+                       },
+                       
+                       new WorkbenchContentProvider() {
+                               @Override
+                               public Object[] getChildren(Object element) {
+                                       if (element instanceof IProject) {
+                                               Object[] ob1 = super.getChildren(element);
+                                               Object[] ob2 = new Object[ob1.length + 1];
+                                               int cnt = 0;
+                                               ob2[cnt++] = new Holder((IProject)element);
+                                               for (Object ob: ob1) {
+                                                       if (ob instanceof IFolder)
+                                                               ob2[cnt++] = new Holder((IFolder)ob);
+                                               }
+                                               ob1 = new Object[cnt];
+                                               System.arraycopy(ob2, 0, ob1, 0, cnt);
+                                               return ob1;
+                                       } else if (element instanceof Holder) {
+                                               Holder h = (Holder)element;
+                                               if (h.isRoot())
+                                                       return new Object[0];
+                                               Object[] ob1 = super.getChildren(h.getFolder());
+                                               Object[] ob2 = new Object[ob1.length];
+                                               int cnt = 0;
+                                               for (Object ob: ob1) {
+                                                       if (ob instanceof IFolder)
+                                                               ob2[cnt++] = new Holder((IFolder)ob);
+                                               }
+                                               ob1 = new Object[cnt];
+                                               System.arraycopy(ob2, 0, ob1, 0, cnt);
+                                               return ob1;
+                                       } else 
+                                               return super.getChildren(element);
+                               }
+                       });
+                       
+                       addFilter(new ViewerFilter () {
+                               @Override
+                               public boolean select(Viewer viewer, Object parentElement, Object element) {
+                                       if (! (element instanceof Holder))
+                                               return false;
+                                       if (existing == null || existing.size() == 0)
+                                               return true;
+                                       Holder h = (Holder)element;
+                                       return (! existing.contains(h.getPath()));
+                               }});
+                       
+                       existing = ex;
+               }
+               
+               @Override
+               protected TreeViewer createTreeViewer(Composite parent) {
+                       TreeViewer treeViewer = super.createTreeViewer(parent);
+                       
+                       // Expand the tree and select current resource
+                       if (page.getElement() instanceof IFolder) {
+                               IFolder folder = (IFolder)page.getElement();
+                               
+                               List<Holder> list = new ArrayList<Holder>();
+                               list.add(new Holder(folder));
+                               for (IContainer parentFolder = folder.getParent();parentFolder instanceof IFolder;parentFolder=parentFolder.getParent()) {
+                                       list.add(0,new Holder((IFolder) parentFolder));
+                               }
+                               treeViewer.expandToLevel(new TreePath(list.toArray()), 0);
+                               setInitialSelection(new Holder(folder));
+                       }
+                       return treeViewer;
+               }
+       }       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ConfigMultiSelectionDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ConfigMultiSelectionDialog.java
new file mode 100644 (file)
index 0000000..7fcb799
--- /dev/null
@@ -0,0 +1,159 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class ConfigMultiSelectionDialog extends Dialog {
+       static private ICConfigurationDescription[] cfgds;
+       private Table table;
+       private CheckboxTableViewer tv;
+       private Button b_ok;
+       private Label message;
+       private static ICConfigurationDescription[] result = null;
+       
+       /**
+        * @since 5.2
+        */
+       public static ICConfigurationDescription[] select(ICConfigurationDescription[] _cfgds, Shell parentShell) {
+               cfgds = _cfgds;
+               ConfigMultiSelectionDialog d = new ConfigMultiSelectionDialog(parentShell);
+               if (d.open() == OK)     
+                       return result;
+               return null;
+       }
+       
+       public ConfigMultiSelectionDialog(Shell parentShell) { super(parentShell); }
+
+       @Override
+       protected void configureShell(Shell shell) {
+               super.configureShell(shell);
+               shell.setText(Messages.ConfigMultiSelectionDialog_0); 
+       }
+       
+       /**
+        * Method is overridden to disable "OK" button at start
+        */
+       @Override
+       protected Control createContents(Composite parent) {
+               Control out = super.createContents(parent);
+               b_ok = getButton(IDialogConstants.OK_ID);
+               b_ok.setEnabled(false);
+               return out;
+       }       
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected Control createDialogArea(Composite parent) {
+               Composite composite = new Composite(parent, SWT.NULL);
+               composite.setFont(parent.getFont());
+               composite.setLayout(new GridLayout(1, true));
+               composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+       
+               // Create the current config table
+               table = new Table(composite, SWT.CHECK | SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
+               table.setLayoutData(new GridData(GridData.FILL));
+               table.setHeaderVisible(true);
+               table.setLinesVisible(true);
+               
+               message = new Label(composite, SWT.NONE);
+               message.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               message.setText(Messages.ConfigMultiSelectionDialog_1); 
+               message.setForeground(composite.getDisplay().getSystemColor(SWT.COLOR_RED));
+               
+               TableColumn col = new TableColumn(table, SWT.NONE);
+               col.setText(Messages.ManageConfigDialog_1); 
+               col.setWidth(100);
+               col = new TableColumn(table, SWT.NONE);
+               col.setText(Messages.ManageConfigDialog_2); 
+               col.setWidth(120);
+               
+               tv = new CheckboxTableViewer(table);
+               tv.setContentProvider(new IStructuredContentProvider() {
+                       public Object[] getElements(Object inputElement) { return cfgds; }
+                       public void dispose() {}
+                       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+               });
+               tv.addCheckStateListener(new ICheckStateListener() {
+                       public void checkStateChanged(CheckStateChangedEvent e) {
+                               boolean enabled = (tv.getCheckedElements().length > 1); 
+                               if (b_ok != null) b_ok.setEnabled(enabled);
+                               message.setVisible(!enabled);
+                               if (enabled) {
+                                       Object[] ob = tv.getCheckedElements();
+                                       result = new ICConfigurationDescription[ob.length];
+                                       System.arraycopy(ob, 0, result, 0, ob.length);
+                               } else
+                                       result = null;
+                       }});
+               tv.setLabelProvider(new ITableLabelProvider() {
+                       public Image getColumnImage(Object element, int columnIndex) { return null; }
+                       public void addListener(ILabelProviderListener listener) {}
+                       public void dispose() {}
+                       public boolean isLabelProperty(Object element, String property) { return false;}
+                       public void removeListener(ILabelProviderListener listener) {}
+
+                       public String getColumnText(Object element, int index) {
+                               ICConfigurationDescription cfg = (ICConfigurationDescription)element;
+                               if (index == 0) return cfg.getName();
+                               if (index == 1) return cfg.getDescription();
+                               return AbstractPage.EMPTY_STR;
+                       }});
+               tv.setInput(cfgds);
+               table.setFocus();
+               return composite;
+       }
+
+       /**
+        * @deprecated (in org.eclipse.cdt.ui 5.2.0)
+        * 
+        * This call is deprecated in plugin org.eclipse.cdt.ui 5.2.0 and intended to be removed
+        * on occasion when the plugin increases major version (Bug 285033).
+        * Use {@link #select(ICConfigurationDescription[], Shell)} to properly set focus.
+        */
+       @Deprecated
+       public static ICConfigurationDescription[] select(ICConfigurationDescription[] _cfgds) {
+               cfgds = _cfgds;
+               ConfigMultiSelectionDialog d = new ConfigMultiSelectionDialog(CUIPlugin.getActiveWorkbenchShell());
+               if (d.open() == OK)     
+                       return result;
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvDialog.java
new file mode 100644 (file)
index 0000000..e9d9c14
--- /dev/null
@@ -0,0 +1,161 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class EnvDialog extends Dialog {
+       IEnvironmentVariable var;
+       Button b_add2all;
+       private Text text1;
+       private Text text2;
+       private boolean newAction;
+       private boolean multiCfg;
+       private ICConfigurationDescription cfgd;
+       public String t1 = AbstractCPropertyTab.EMPTY_STR;
+       public String t2 = AbstractCPropertyTab.EMPTY_STR;
+       public boolean toAll = false;
+       private String title;
+
+       public EnvDialog(Shell parent, 
+                       IEnvironmentVariable _var, 
+                       String _title, 
+                       boolean _newAction,
+                       boolean _multiCfg,
+                       ICConfigurationDescription _cfgd) {
+               super(parent);
+               var = _var;
+               newAction = _newAction;
+               multiCfg = _multiCfg;
+               cfgd = _cfgd;
+               title = _title;
+       }
+
+       /**
+        * Method is overridden to disable "OK" button at start
+        */
+       @Override
+       protected Control createContents(Composite parent) {
+               Control out = super.createContents(parent);
+               setButtons();
+               return out;
+       }       
+       
+       @Override
+       protected void configureShell(Shell newShell) {
+               super.configureShell(newShell);
+               newShell.setText(title);
+       }
+       
+       @Override
+       protected Control createDialogArea(Composite c) {
+               c.setLayout(new GridLayout(3, false));
+               GridData gd;
+               
+               Label l1 = new Label(c, SWT.NONE);
+               l1.setText(Messages.EnvDialog_0); 
+               l1.setLayoutData(new GridData(GridData.BEGINNING));
+               
+               text1 = new Text(c, SWT.SINGLE | SWT.BORDER);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = 2;
+               gd.widthHint = 400;
+               text1.setLayoutData(gd);
+               text1.addModifyListener(new ModifyListener () {
+                       public void modifyText(ModifyEvent e) { setButtons(); }});
+               
+               Label l2 = new Label(c, SWT.NONE);
+               l2.setText(Messages.EnvDialog_1); 
+               l2.setLayoutData(new GridData(GridData.BEGINNING));
+               
+               text2 = new Text(c, SWT.SINGLE | SWT.BORDER);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.widthHint = 250;
+               text2.setLayoutData(gd);
+               text2.addModifyListener(new ModifyListener () {
+                       public void modifyText(ModifyEvent e) { setButtons(); }});
+
+               final Button b = new Button(c, SWT.PUSH);
+               b.setText(Messages.EnvDialog_2); 
+               b.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               String x = AbstractCPropertyTab.getVariableDialog(b.getShell(), cfgd);
+                               if (x != null) {
+                                       text2.insert(x);
+                                       setButtons();
+                               }
+                       }});
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.widthHint = AbstractCPropertyTab.BUTTON_WIDTH;
+               b.setLayoutData(gd);
+               
+               b_add2all = new Button(c, SWT.CHECK);
+               b_add2all.setText(Messages.EnvDialog_3); 
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               if (cfgd == null)
+                       b_add2all.setVisible(false);
+               else
+                       b_add2all.addSelectionListener(new SelectionAdapter() {
+                               @Override
+                               public void widgetSelected(SelectionEvent e) {
+                                       toAll = b_add2all.getSelection();
+                               }});
+               
+               if (multiCfg)
+                       b_add2all.setVisible(false);
+                       
+               if (!newAction) {
+                       gd.heightHint = 1;
+                       b_add2all.setVisible(false);
+
+                       text1.setText(var.getName());
+                       text1.setEnabled(false); // don't change name
+                       String s = var.getValue();
+                       text2.setText(s == null ? AbstractCPropertyTab.EMPTY_STR : s); 
+               }
+               
+               gd.horizontalSpan = 3;
+               b_add2all.setLayoutData(gd);
+               setButtons();
+               return c;
+       }
+       
+       private void setButtons() {
+               t1 = text1.getText(); 
+               t2 = text2.getText();
+               Button b = getButton(IDialogConstants.OK_ID);
+               if (b != null)
+                       b.setEnabled(t1.trim().length() > 0);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvironmentTab.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvironmentTab.java
new file mode 100644 (file)
index 0000000..cdc6303
--- /dev/null
@@ -0,0 +1,601 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *     IBM Corporation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.IColorProvider;
+import org.eclipse.jface.viewers.IFontProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableFontProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.osgi.util.TextProcessor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.ui.dialogs.ListSelectionDialog;
+
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.core.model.util.CDTListComparator;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.utils.envvar.StorableEnvironment;
+import org.eclipse.cdt.utils.spawner.EnvironmentReader;
+
+import org.eclipse.cdt.internal.core.envvar.EnvVarDescriptor;
+import org.eclipse.cdt.internal.core.envvar.EnvironmentVariableManager;
+import org.eclipse.cdt.internal.core.envvar.UserDefinedEnvironmentSupplier;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class EnvironmentTab extends AbstractCPropertyTab {
+       private static final String SEPARATOR = System.getProperty("path.separator", ";"); //$NON-NLS-1$ //$NON-NLS-2$
+       private static final String LBR = " ["; //$NON-NLS-1$
+       private static final String RBR = "]"; //$NON-NLS-1$
+       private static final UserDefinedEnvironmentSupplier fUserSupplier = EnvironmentVariableManager.fUserSupplier;
+       
+       private final MultiCfgContributedEnvironment ce = new MultiCfgContributedEnvironment();
+
+       private Table table;
+       private TableViewer tv;
+       private ArrayList<TabData> data = new ArrayList<TabData>();
+       private Button b1, b2;
+       private StringListModeControl stringListModeControl;
+
+       private ICConfigurationDescription cfgd = null;
+       private StorableEnvironment vars = null;
+
+       private class TabData implements Comparable<TabData> {
+               IEnvironmentVariable var;
+               TabData(IEnvironmentVariable _var) {
+                       var = _var;
+               }
+               public int compareTo(TabData a) {
+                       String s = var.getName();
+                       if (a != null && s != null && a.var != null)
+                                       return (s.compareTo(a.var.getName())); 
+                       return 0;
+               }
+       }
+       
+       private class EnvironmentLabelProvider extends LabelProvider implements ITableLabelProvider, IFontProvider , ITableFontProvider, IColorProvider{
+               public EnvironmentLabelProvider(boolean user){
+               }
+               @Override
+               public Image getImage(Object element) {
+                       return null; // JavaPluginImages.get(JavaPluginImages.IMG_OBJS_REFACTORING_INFO);
+               }
+               @Override
+               public String getText(Object element) {
+                       return getColumnText(element, 0);
+               }
+               public Image getColumnImage(Object element, int columnIndex) {
+                       return null;
+               }
+               public String getColumnText(Object element, int columnIndex) {
+                       TabData td = (TabData)element;
+                       switch(columnIndex){
+                       case 0:
+                               return td.var.getName();
+                       case 1:
+                               if(td.var.getOperation() == IEnvironmentVariable.ENVVAR_REMOVE)
+                                       return Messages.EnvironmentTab_20; 
+                               return td.var.getValue();
+                       case 2:
+                               return ce.getOrigin(td.var);
+                       }
+                       return EMPTY_STR;
+               }
+
+               public Font getFont(Object element) {
+                       return getFont(element, 0);
+               }
+
+               public Font getFont(Object element, int columnIndex) {
+                       TabData td = (TabData)element;
+                       switch(columnIndex){
+                       case 0:
+                               if (isUsers(td.var))
+                                       return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
+                               break;
+                       default:
+                               break;
+                       }
+                       return null;
+               }
+               
+           public Color getForeground(Object element){
+                       return null;
+           }
+
+           public Color getBackground(Object element){
+                       TabData td = (TabData)element;
+                       if (isUsers(td.var))
+                               return BACKGROUND_FOR_USER_VAR;
+                       return null; 
+           }
+       }
+       
+       @Override
+       public void createControls(Composite parent) {
+               super.createControls(parent);
+               usercomp.setLayout(new GridLayout(3, true));
+               Label l1 = new Label(usercomp, SWT.LEFT);
+               l1.setText(Messages.EnvironmentTab_0);
+               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = 3;
+               l1.setLayoutData(gd);
+               table = new Table(usercomp, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.H_SCROLL | SWT.FULL_SELECTION);
+               table.setHeaderVisible(true);
+               table.setLinesVisible(true);
+               table.addSelectionListener(new SelectionListener() {
+                       public void widgetSelected(SelectionEvent e) {
+                               updateButtons();
+                       }
+
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               if (buttonIsEnabled(2) && table.getSelectionIndex() != -1)
+                                       buttonPressed(2);
+                       }
+               });
+
+               tv = new TableViewer(table);
+               tv.setContentProvider(new IStructuredContentProvider() {
+
+                       public Object[] getElements(Object inputElement) {
+                               if (inputElement != null && inputElement instanceof ArrayList<?>) {
+                                       @SuppressWarnings("unchecked")
+                                       ArrayList<TabData> ar = (ArrayList<TabData>) inputElement;
+                                       return ar.toArray(new TabData[0]);
+                               }
+                               return null;
+                       }
+
+                       public void dispose() {
+                       }
+
+                       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+                       }
+               });
+               tv.setLabelProvider(new EnvironmentLabelProvider(true));
+               // add headers
+               TableColumn tc = new TableColumn(table, SWT.LEFT);
+               tc.setText(Messages.EnvironmentTab_1);
+               tc.setWidth(150);
+               tc = new TableColumn(table, SWT.LEFT);
+               tc.setText(Messages.EnvironmentTab_2);
+               tc.setWidth(150);
+               if (this.getResDesc() != null) {
+                       tc = new TableColumn(table, SWT.LEFT);
+                       tc.setText(Messages.EnvironmentTab_16);
+                       tc.setWidth(100);
+               }
+
+               gd = new GridData(GridData.FILL_BOTH);
+               gd.horizontalSpan = 3;
+               table.setLayoutData(gd);
+
+               b1 = new Button(usercomp, SWT.RADIO);
+               b1.setText(Messages.EnvironmentTab_3);
+               b1.setToolTipText(Messages.EnvironmentTab_3);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               if (page.isForProject())
+                       gd.horizontalSpan = 2;
+               else
+                       gd.horizontalSpan = 3;
+               b1.setLayoutData(gd);
+               b1.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               if (cfgd != null)
+                                       ce.setAppendEnvironment(true, cfgd);
+                               else
+                                       vars.setAppendContributedEnvironment(true);
+                               updateData();
+                       }
+               });
+
+               if (page.isForProject()) {
+                       stringListModeControl = new StringListModeControl(page, usercomp, 1);
+                       stringListModeControl.addListener(SWT.Selection, new Listener() {
+                               public void handleEvent(Event event) {
+                                       updateData();
+                               }
+                       });
+               }
+
+               b2 = new Button(usercomp, SWT.RADIO);
+               b2.setText(Messages.EnvironmentTab_4);
+               b2.setToolTipText(Messages.EnvironmentTab_4);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = 3;
+               b2.setLayoutData(gd);
+               b2.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               if (cfgd != null)
+                                       ce.setAppendEnvironment(false, cfgd);
+                               else
+                                       vars.setAppendContributedEnvironment(false);
+                               updateData();
+                       }
+               });
+
+               initButtons(new String[] {
+                               Messages.EnvironmentTab_5,
+                               Messages.EnvironmentTab_6,
+                               Messages.EnvironmentTab_7,
+                               Messages.EnvironmentTab_8,
+                               Messages.EnvironmentTab_9 
+                       });
+       }
+       
+       @Override
+       public void buttonPressed(int i) {
+               switch (i) {
+               case 0:
+                       handleEnvAddButtonSelected();
+                       break;
+               case 1: // select
+                       handleEnvSelectButtonSelected();
+                       break;
+               case 2: // edit
+                       handleEnvEditButtonSelected(table.getSelectionIndex());
+                       break;
+               case 3: // remove
+                       handleEnvDelButtonSelected(table.getSelectionIndex());
+                       break;
+               case 4: // Undefine
+                       handleEnvUndefButtonSelected(table.getSelectionIndex());
+                       break;
+               }
+               table.setFocus();
+       }
+       
+       @Override
+       protected void updateButtons() {
+               if (table == null || table.isDisposed()) return;
+               
+               boolean canEdit = table.getSelectionCount() == 1;
+               boolean canDel  = false;
+               boolean canUndef = table.getSelectionCount() >= 1;
+               if (canUndef) {
+                       for (int i : table.getSelectionIndices()) {
+                               IEnvironmentVariable var = ((TabData)tv.getElementAt(i)).var;
+                               if (isUsers(var)) {
+                               //      if (cfgd == null || !wse.getVariable(var.))
+                                       canDel = true;
+                                       break;
+                               }
+                       }
+               }
+               buttonSetEnabled(2, canEdit); // edit
+               buttonSetEnabled(3, canDel); // delete
+               buttonSetEnabled(4, canUndef); // undefine
+       }
+
+       @Override
+       protected void updateData(ICResourceDescription _cfgd) {
+               // null means preference configuration 
+               cfgd = (_cfgd != null) ? _cfgd.getConfiguration() : null;
+               if (cfgd == null && vars == null)
+                       vars = fUserSupplier.getWorkspaceEnvironmentCopy();
+               else
+                       ce.setMulti(page.isMultiCfg());
+               updateData();
+       }
+
+       private void updateData() {
+               IEnvironmentVariable[] _vars = null;
+               if (cfgd != null) {
+                       b1.setSelection(ce.appendEnvironment(cfgd));
+                       b2.setSelection(!ce.appendEnvironment(cfgd));
+                        _vars = ce.getVariables(cfgd);
+               } else {
+                       if (vars == null)
+                               vars = fUserSupplier.getWorkspaceEnvironmentCopy();
+                       b1.setSelection(vars.appendContributedEnvironment());
+                       b2.setSelection(!vars.appendContributedEnvironment());
+                       _vars = vars.getVariables() ;
+               }
+               
+               data.clear();
+               if (_vars != null) {
+                       for (IEnvironmentVariable _var : _vars) {
+                               data.add(new TabData(_var));
+                       }
+               }
+               Collections.sort(data);
+               tv.setInput(data);
+               
+               if (stringListModeControl!=null) {
+                       stringListModeControl.updateStringListModeControl();
+               }
+               updateButtons();
+       }
+
+       @Override
+       protected void performApply(ICResourceDescription _src, ICResourceDescription _dst) {
+               ICConfigurationDescription src = _src.getConfiguration();
+               ICConfigurationDescription dst = _dst.getConfiguration();
+               
+               ce.setAppendEnvironment(ce.appendEnvironment(src), dst);
+               IEnvironmentVariable[] v = ce.getVariables(dst);
+               for (IEnvironmentVariable element : v)
+                       ce.removeVariable(element.getName(), dst);
+               v = ce.getVariables(src);
+               for (IEnvironmentVariable element : v) {
+                       if (ce.isUserVariable(src, element))
+                                       ce.addVariable(element.getName(), element.getValue(), 
+                                                       element.getOperation(), element.getDelimiter(), dst);
+               }
+       }
+
+       /**
+        * 
+        */
+       private class MyListSelectionDialog extends ListSelectionDialog {
+               public boolean toAll = false;
+           public MyListSelectionDialog(Shell parentShell, Object input, IStructuredContentProvider contentProvider) {
+               super(parentShell, input, contentProvider, new LabelProvider() {}, Messages.EnvironmentTab_12); 
+           }
+           @Override
+               protected Control createDialogArea(Composite parent) {
+               Composite composite = (Composite) super.createDialogArea(parent);
+               Button b = new Button(composite, SWT.CHECK);
+               b.setText(Messages.EnvironmentTab_13); 
+               b.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               if (cfgd == null)
+                       b.setVisible(false);
+               else
+                       b.addSelectionListener(new SelectionAdapter() {
+                               @Override
+                                       public void widgetSelected(SelectionEvent e) {
+                                       toAll = ((Button)e.widget).getSelection();
+                               }});
+               return composite;
+           }
+       }
+       
+       private void handleEnvEditButtonSelected(int n) {
+               if (n == -1)
+                       return;
+               IEnvironmentVariable var = ((TabData)tv.getElementAt(n)).var;
+               EnvDialog dlg = new EnvDialog(usercomp.getShell(), 
+                               var, 
+                               Messages.EnvironmentTab_11,  
+                               false,
+                               page.isMultiCfg(),
+                               cfgd);
+               if (dlg.open() == Window.OK) {
+                       if (cfgd != null)
+                               ce.addVariable( var.getName(), dlg.t2.trim(), 
+                                               IEnvironmentVariable.ENVVAR_REPLACE, 
+                                               var.getDelimiter(), cfgd);
+                       else
+                               vars.createVariable(dlg.t1.trim(), dlg.t2.trim(),
+                                               IEnvironmentVariable.ENVVAR_REPLACE, var.getDelimiter());
+                       updateData();
+                       table.setSelection(n);
+                       updateButtons();
+               }
+       }
+       
+       private void handleEnvUndefButtonSelected(int n) {
+               if (n == -1) 
+                       return;
+               for (int i : table.getSelectionIndices()) {
+                       IEnvironmentVariable var = ((TabData)tv.getElementAt(i)).var;
+                       if (cfgd == null)
+                               vars.createVariable(
+                                               var.getName(), 
+                                               null, 
+                                               IEnvironmentVariable.ENVVAR_REMOVE, 
+                                               var.getDelimiter());
+                       else 
+                               ce.addVariable(
+                                               var.getName(), 
+                                               null, 
+                                               IEnvironmentVariable.ENVVAR_REMOVE, 
+                                               var.getDelimiter(), cfgd);
+               }
+               updateData();
+               table.setSelection(n);
+               updateButtons();
+       }
+       
+       private void handleEnvDelButtonSelected(int n) {
+               if (n == -1) 
+                       return;
+               for (int i : table.getSelectionIndices()) {
+                       IEnvironmentVariable var = ((TabData)tv.getElementAt(i)).var;
+                       if (cfgd == null) 
+                               vars.deleteVariable(var.getName());
+                       else
+                               ce.removeVariable(var.getName(), cfgd);
+               }
+               updateData();
+               int x = table.getItemCount() - 1;
+               if (x >= 0) {
+                       table.setSelection(Math.min(x, n));
+                       updateButtons();
+               }
+       }
+       
+       private void handleEnvAddButtonSelected() {
+               IEnvironmentVariable var = null;
+               EnvDialog dlg = new EnvDialog(usercomp.getShell(), 
+                               var, 
+                               Messages.EnvironmentTab_10, 
+                               true,
+                               page.isMultiCfg(),
+                               cfgd);
+               if (dlg.open() == Window.OK) {
+                       String name = dlg.t1.trim();
+                       if (name.length() > 0) {
+                               ICConfigurationDescription[] cfgs;
+                               if (dlg.toAll)
+                                       cfgs = page.getCfgsEditable();
+                               else 
+                                       cfgs = new ICConfigurationDescription[] {cfgd};
+                               if (cfgd == null)
+                                       vars.createVariable(name, dlg.t2.trim(), 
+                                                       IEnvironmentVariable.ENVVAR_APPEND, SEPARATOR);
+                               else
+                                       for (ICConfigurationDescription cfg : cfgs) { 
+                                               ce.addVariable(name, dlg.t2.trim(), 
+                                                               IEnvironmentVariable.ENVVAR_APPEND, 
+                                                               SEPARATOR, cfg);
+                                       }
+                               updateData();
+                               setPos(name);
+                       }
+               }
+       }
+
+       private void setPos(String name) {
+               if (name == null || name.length() == 0)
+                       return;
+               for (int i=0; i<table.getItemCount(); i++) {
+                       if (name.equals(table.getItem(i).getText())) {
+                               table.setSelection(i);
+                               updateButtons();
+                               break;
+                       }
+               }
+       }
+       
+       private void handleEnvSelectButtonSelected() {
+               // get Environment Variables from the OS
+               Map<?,?> v = EnvironmentReader.getEnvVars();
+               MyListSelectionDialog dialog = new MyListSelectionDialog(usercomp.getShell(), v, createSelectionDialogContentProvider());
+               
+               dialog.setTitle(Messages.EnvironmentTab_14); 
+               if (dialog.open() == Window.OK) {
+                       Object[] selected = dialog.getResult();
+                       ICConfigurationDescription[] cfgs;
+                       if (dialog.toAll)
+                               cfgs = page.getCfgsEditable();
+                       else 
+                               cfgs = new ICConfigurationDescription[] {cfgd};
+                       
+                       String name = null;
+                       for (Object element : selected) {
+                               name = (String)element;
+                               String value = EMPTY_STR;
+                               int x = name.indexOf(LBR);
+                               if (x >= 0) {
+                                       value = name.substring(x + 2, name.length() - 1);
+                                       name = name.substring(0, x);
+                               }
+                               
+                               if (cfgd == null) 
+                                       vars.createVariable(name, value);
+                               else
+                                       for (ICConfigurationDescription cfg : cfgs) { 
+                                               ce.addVariable(
+                                                               name, value, 
+                                                               IEnvironmentVariable.ENVVAR_APPEND, 
+                                                               SEPARATOR, cfg);
+                               }
+                       }
+                       updateData();
+                       setPos(name);
+               }
+       }
+       
+       private IStructuredContentProvider createSelectionDialogContentProvider() {
+               return new IStructuredContentProvider() {
+
+                       public Object[] getElements(Object inputElement) {
+                               String[] els = null;
+                               if (inputElement instanceof Map<?, ?>) {
+                                       @SuppressWarnings("unchecked")
+                                       Map<String, String> m = (Map<String, String>)inputElement;
+                                       els = new String[m.size()];  
+                                       int index = 0;
+                                       for (Iterator<String> iterator = m.keySet().iterator(); iterator.hasNext(); index++) {
+                                               String k = iterator.next();
+                                               els[index] = TextProcessor.process(k + LBR + m.get(k) + RBR);  
+                                       }
+                               }
+                               Arrays.sort(els, CDTListComparator.getInstance());
+                               return els;
+                       }
+                       public void dispose() {}
+                       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+               };
+       }
+       // This page can be displayed for project only
+       @Override
+       public boolean canBeVisible() {
+               return page.isForProject() || page.isForPrefs();
+       }
+
+       @Override
+       protected void performOK() {
+               if (vars != null) {
+                       if (fUserSupplier.setWorkspaceEnvironment(vars))
+                               if (page instanceof PrefPage_Abstract)
+                                       PrefPage_Abstract.isChanged = true;
+               }
+               vars = null;
+               super.performOK();
+       }
+       
+       @Override
+       protected void performCancel() {
+               vars = null;
+               super.performCancel();
+       }
+       
+       @Override
+       protected void performDefaults() {
+               ce.restoreDefaults(cfgd); // both for proj & prefs
+               vars = null;
+               updateData();
+       }
+       
+       private boolean isUsers(IEnvironmentVariable var) {
+               return cfgd == null || 
+                     (ce.isUserVariable(cfgd, var) &&
+                         ((EnvVarDescriptor)var).getContextInfo().getContext() != null);
+
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ErrorParsTab.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ErrorParsTab.java
new file mode 100644 (file)
index 0000000..3a71d77
--- /dev/null
@@ -0,0 +1,654 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Intel Corporation - Initial API and implementation
+ * Andrew Gvozdev (Quoin Inc.) - Regular expression error parsers
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.layout.PixelConverter;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.PlatformUI;
+import org.osgi.service.prefs.BackingStoreException;
+
+import com.ibm.icu.text.MessageFormat;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.ErrorParserManager;
+import org.eclipse.cdt.core.IErrorParserNamed;
+import org.eclipse.cdt.core.errorparsers.RegexErrorParser;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICMultiConfigDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.dialogs.ICOptionPage;
+import org.eclipse.cdt.ui.dialogs.IInputStatusValidator;
+import org.eclipse.cdt.ui.dialogs.InputStatusDialog;
+import org.eclipse.cdt.ui.dialogs.RegexErrorParserOptionPage;
+import org.eclipse.cdt.utils.ui.controls.TabFolderLayout;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+
+/**
+ * This class represents Error Parser Tab in Project Properties or workspace Preferences
+ *
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class ErrorParsTab extends AbstractCPropertyTab {
+       private static final int DEFAULT_HEIGHT = 130;
+       private static final int BUTTON_ADD = 0;
+       private static final int BUTTON_EDIT = 1;
+       private static final int BUTTON_DELETE = 2;
+       // there is a separator instead of button = 3
+       private static final int BUTTON_MOVEUP = 4;
+       private static final int BUTTON_MOVEDOWN = 5;
+
+       private static final String[] BUTTONS = new String[] {
+               ADD_STR,
+               EDIT_STR,
+               DEL_STR,
+               null,
+               MOVEUP_STR,
+               MOVEDOWN_STR,
+       };
+       private static final String RESET_STR = Messages.ErrorParsTab_Reset;
+
+       private static final String OOPS = "OOPS"; //$NON-NLS-1$
+
+       private Table fTable;
+       private CheckboxTableViewer fTableViewer;
+       private ICConfigurationDescription fCfgDesc;
+
+       private static Map<String, IErrorParserNamed> fExtensionErrorParsers = null;
+
+       private final Map<String, IErrorParserNamed> fAvailableErrorParsers = new LinkedHashMap<String, IErrorParserNamed>();
+       private final Map<String, ICOptionPage> fOptionsPageMap = new HashMap<String, ICOptionPage>();
+       private ICOptionPage fCurrentOptionsPage = null;
+
+       private Composite fCompositeForOptionsPage;
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.ui.newui.AbstractCPropertyTab#createControls(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       public void createControls(Composite parent) {
+
+               super.createControls(parent);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(usercomp, ICHelpContextIds.ERROR_PARSERS_PAGE);
+
+               usercomp.setLayout(new GridLayout(1, false));
+
+               // SashForm
+               SashForm sashForm = new SashForm(usercomp, SWT.NONE);
+               sashForm.setBackground(sashForm.getDisplay().getSystemColor(SWT.COLOR_GRAY));
+               sashForm.setOrientation(SWT.VERTICAL);
+               sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+               GridLayout layout = new GridLayout(2, false);
+               layout.marginHeight = 5;
+               sashForm.setLayout(layout);
+
+               // table
+               Composite compositeSashForm = new Composite(sashForm, SWT.NONE);
+               compositeSashForm.setLayout(new GridLayout(2, false));
+               fTable = new Table(compositeSashForm, SWT.BORDER | SWT.CHECK | SWT.SINGLE);
+               fTable.setLayoutData(new GridData(GridData.FILL_BOTH));
+               fTable.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               displaySelectedOptionPage();
+                               updateButtons();
+               }});
+               fTableViewer = new CheckboxTableViewer(fTable);
+               fTableViewer.setContentProvider(new IStructuredContentProvider() {
+                       public Object[] getElements(Object inputElement) {
+                               return (Object[])inputElement;
+                       }
+                       public void dispose() {}
+                       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
+               });
+               fTableViewer.setLabelProvider(new LabelProvider() {
+                       @Override
+                       public String getText(Object element) {
+                               if (element instanceof String) {
+                                       String id = (String)element;
+                                       IErrorParserNamed errorParser = fAvailableErrorParsers.get(id);
+                                       if (errorParser!=null) {
+                                               String name = errorParser.getName();
+                                               if (name!=null && name.length()>0) {
+                                                       return name;
+                                               }
+                                       }
+                                       return NLS.bind(Messages.ErrorParsTab_error_NonAccessibleID, id); 
+                               }
+                               return OOPS;
+                       }
+                       
+                       @Override
+                       public Image getImage(Object element) {
+                               final String TEST_PLUGIN_ID = "org.eclipse.cdt.core.tests"; //$NON-NLS-1$
+                               final String DEPRECATED = CCorePlugin.getResourceString("CCorePlugin.Deprecated"); //$NON-NLS-1$
+                               if (element instanceof String) {
+                                       String id = (String) element;
+                                       String[] extIds = ErrorParserManager.getErrorParserExtensionIds();
+                                       if (Arrays.asList(extIds).contains(id)) {
+                                               String imageKey = CDTSharedImages.IMG_OBJS_EXTENSION;
+                                               if (id.startsWith(TEST_PLUGIN_ID))
+                                                       imageKey = CDTSharedImages.IMG_OBJS_CDT_TESTING;
+
+                                               String[] overlayKeys = new String[5];
+                                               IErrorParserNamed errorParser = fAvailableErrorParsers.get(id);
+                                               IErrorParserNamed errorParserExt = fExtensionErrorParsers.get(id);
+                                               if (!errorParser.equals(errorParserExt)) {
+                                                       overlayKeys[IDecoration.TOP_RIGHT] = CDTSharedImages.IMG_OVR_SETTING;
+                                               } else if (errorParser.getName().contains(DEPRECATED)) {
+                                                       overlayKeys[IDecoration.TOP_RIGHT] = CDTSharedImages.IMG_OVR_INACTIVE;
+                                               }
+                                               return CDTSharedImages.getImageOverlaid(imageKey, overlayKeys);
+                                       }
+                                       return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_USER);
+                               }
+                               return null;
+                       }
+
+               });
+
+               fTableViewer.addCheckStateListener(new ICheckStateListener() {
+                       public void checkStateChanged(CheckStateChangedEvent e) {
+                               saveChecked();
+                       }});
+
+               // Buttons
+               Composite compositeButtons = new Composite(compositeSashForm, SWT.NONE);
+               compositeButtons.setLayoutData(new GridData(GridData.END));
+               initButtons(compositeButtons, BUTTONS);
+
+               fCompositeForOptionsPage = new Composite(sashForm, SWT.NULL);
+               GridData gd = new GridData();
+               fCompositeForOptionsPage.setLayout(new TabFolderLayout());
+
+               PixelConverter converter = new PixelConverter(parent);
+               gd.heightHint = converter.convertHorizontalDLUsToPixels(DEFAULT_HEIGHT);
+
+               gd.horizontalAlignment = GridData.FILL;
+               gd.grabExcessHorizontalSpace = true;
+               gd.grabExcessVerticalSpace = true;
+               gd.horizontalSpan = 2;
+               fCompositeForOptionsPage.setLayoutData(gd);
+
+               sashForm.setWeights(new int[] {50, 50});
+
+               // init data
+               ICResourceDescription resDecs = getResDesc();
+               fCfgDesc = resDecs!=null ? resDecs.getConfiguration() : null;
+               initMapParsers();
+               updateData(getResDesc());
+       }
+
+       private void initMapParsers() {
+               if (fExtensionErrorParsers==null) {
+                       fExtensionErrorParsers = new LinkedHashMap<String, IErrorParserNamed>();
+                       String[] idsExt = ErrorParserManager.getErrorParserExtensionIds();
+                       for (String idExt : idsExt) {
+                               IErrorParserNamed errorParserExt = ErrorParserManager.getErrorParserExtensionCopy(idExt);
+                               fExtensionErrorParsers.put(idExt, errorParserExt);
+                       }
+               }
+               fAvailableErrorParsers.clear();
+               fOptionsPageMap.clear();
+               for (String id : ErrorParserManager.getErrorParserAvailableIds()) {
+                       IErrorParserNamed errorParser = ErrorParserManager.getErrorParserCopy(id);
+                       fAvailableErrorParsers.put(id, errorParser);
+                       initializeOptionsPage(id);
+               }
+
+               String ids[];
+               if (fCfgDesc!=null) {
+                       ICConfigurationDescription srcCfgDesc = fCfgDesc.getConfiguration();
+                       if (srcCfgDesc instanceof ICMultiConfigDescription) {
+                               String[][] ss = ((ICMultiConfigDescription)srcCfgDesc).getErrorParserIDs();
+                               ids = CDTPrefUtil.getStrListForDisplay(ss);
+                       } else {
+                               ids = srcCfgDesc.getBuildSetting().getErrorParserIDs();
+                       }
+                       Set<String> setIds = new LinkedHashSet<String>(Arrays.asList(ids));
+                       setIds.addAll(fAvailableErrorParsers.keySet());
+                       fTableViewer.setInput(setIds.toArray(new String[0]));
+               } else {
+                       fTableViewer.setInput(fAvailableErrorParsers.keySet().toArray(new String[0]));
+                       ids = ErrorParserManager.getDefaultErrorParserIds();
+               }
+               fTableViewer.setCheckedElements(ids);
+
+               displaySelectedOptionPage();
+       }
+
+       private void initializeOptionsPage(final String id) {
+               IErrorParserNamed errorParser = fAvailableErrorParsers.get(id);
+               if (errorParser!=null) {
+                       String name = errorParser.getName();
+                       if (name!=null && name.length()>0) {
+                               // RegexErrorParser has an Options page
+                               if (errorParser instanceof RegexErrorParser) {
+                                       // allow to edit only for Build Settings Preference Page (where cfgd==null)
+                                       RegexErrorParserOptionPage optionsPage = new RegexErrorParserOptionPage((RegexErrorParser) errorParser, isErrorParsersEditable());
+                                       optionsPage.addListener(new Listener() {
+                                               public void handleEvent(Event event) {
+                                                       fTableViewer.refresh(id);
+                                                       updateButtons();
+                                               }
+                                       });
+                                       fOptionsPageMap.put(id, optionsPage);
+                                       optionsPage.setContainer(page);
+                                       optionsPage.createControl(fCompositeForOptionsPage);
+                                       optionsPage.setVisible(false);
+                                       fCompositeForOptionsPage.layout(true);
+                               }
+                       }
+               }
+       }
+
+       private void displaySelectedOptionPage() {
+               if (fCurrentOptionsPage != null)
+                       fCurrentOptionsPage.setVisible(false);
+
+               int pos = fTable.getSelectionIndex();
+               if (pos<0)
+                       return;
+
+               String parserId = (String)fTable.getItem(pos).getData();
+               ICOptionPage optionsPage = fOptionsPageMap.get(parserId);
+               if (optionsPage != null) {
+                       optionsPage.setVisible(true);
+               }
+               fCurrentOptionsPage = optionsPage;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.ui.newui.AbstractCPropertyTab#buttonPressed(int)
+        */
+       @Override
+       public void buttonPressed (int n) {
+               switch (n) {
+               case BUTTON_ADD:
+                       addErrorParser();
+                       break;
+               case BUTTON_EDIT:
+                       editErrorParser();
+                       break;
+               case BUTTON_DELETE:
+                       deleteErrorParser();
+                       break;
+               case BUTTON_MOVEUP:
+                       moveItem(true);
+                       break;
+               case BUTTON_MOVEDOWN:
+                       moveItem(false);
+                       break;
+               default:
+                       break;
+               }
+               updateButtons();
+       }
+
+       // Move item up / down
+       private void moveItem(boolean up) {
+               int n = fTable.getSelectionIndex();
+               if (n < 0 || (up && n == 0) || (!up && n+1 == fTable.getItemCount()))
+                       return;
+
+               String id = (String)fTableViewer.getElementAt(n);
+               boolean checked = fTableViewer.getChecked(id);
+               fTableViewer.remove(id);
+               n = up ? n-1 : n+1;
+               fTableViewer.insert(id, n);
+               fTableViewer.setChecked(id, checked);
+               fTable.setSelection(n);
+
+               saveChecked();
+       }
+
+       private String makeId(String name) {
+               return CUIPlugin.PLUGIN_ID+'.'+name;
+       }
+
+       private void addErrorParser() {
+               IInputStatusValidator inputValidator = new IInputStatusValidator() {
+                       public IStatus isValid(String newText) {
+                               StatusInfo status = new StatusInfo();
+                               if (newText.trim().length() == 0) {
+                                       status.setError(Messages.ErrorParsTab_error_NonEmptyName); 
+                               } else if (newText.indexOf(ErrorParserManager.ERROR_PARSER_DELIMITER)>=0) {
+                                       String message = MessageFormat.format( Messages.ErrorParsTab_error_IllegalCharacter, 
+                                                       new Object[] { ErrorParserManager.ERROR_PARSER_DELIMITER });
+                                       status.setError(message);
+                               } else if (fAvailableErrorParsers.containsKey(makeId(newText))) {
+                                       status.setError(Messages.ErrorParsTab_error_NonUniqueID); 
+                               }
+                               return status;
+                       }
+
+               };
+               InputStatusDialog addDialog = new InputStatusDialog(usercomp.getShell(),
+                               Messages.ErrorParsTab_title_Add, 
+                               Messages.ErrorParsTab_label_EnterName, 
+                               Messages.ErrorParsTab_label_DefaultRegexErrorParserName, 
+                               inputValidator);
+               addDialog.setHelpAvailable(false);
+
+               if (addDialog.open() == Window.OK) {
+                       String newName = addDialog.getValue();
+                       String newId = makeId(newName);
+                       IErrorParserNamed errorParser = new RegexErrorParser(newId, newName);
+                       fAvailableErrorParsers.put(newId, errorParser);
+
+                       fTableViewer.add(newId);
+                       fTableViewer.setChecked(newId, true);
+                       fTable.setSelection(fTable.getItemCount()-1);
+
+                       initializeOptionsPage(newId);
+                       displaySelectedOptionPage();
+                       updateButtons();
+               }
+       }
+
+       private void editErrorParser() {
+               int n = fTable.getSelectionIndex();
+               Assert.isTrue(n>=0);
+
+               String id = (String)fTableViewer.getElementAt(n);
+               IErrorParserNamed errorParser = fAvailableErrorParsers.get(id);
+
+               IInputStatusValidator inputValidator = new IInputStatusValidator() {
+                       public IStatus isValid(String newText) {
+                               StatusInfo status = new StatusInfo();
+                               if (newText.trim().length() == 0) {
+                                       status.setError(Messages.ErrorParsTab_error_NonEmptyName); 
+                               } else if (newText.indexOf(ErrorParserManager.ERROR_PARSER_DELIMITER)>=0) {
+                                       String message = MessageFormat.format( Messages.ErrorParsTab_error_IllegalCharacter, 
+                                                       new Object[] { ErrorParserManager.ERROR_PARSER_DELIMITER });
+                                       status.setError(message);
+                               }
+                               return status;
+                       }
+
+               };
+               InputStatusDialog addDialog = new InputStatusDialog(usercomp.getShell(),
+                               Messages.ErrorParsTab_title_Edit, 
+                               Messages.ErrorParsTab_label_EnterName, 
+                               errorParser.getName(),
+                               inputValidator);
+               addDialog.setHelpAvailable(false);
+
+               if (addDialog.open() == Window.OK) {
+                       errorParser.setName(addDialog.getValue());
+                       fTableViewer.refresh(id);
+               }
+       }
+
+       private void deleteErrorParser() {
+               int n = fTable.getSelectionIndex();
+               if (n < 0)
+                       return;
+
+               String id = (String)fTableViewer.getElementAt(n);
+               if (fExtensionErrorParsers.containsKey(id)) {
+                       // Reset
+                       fAvailableErrorParsers.put(id, ErrorParserManager.getErrorParserExtensionCopy(id));
+                       fTableViewer.refresh(id);
+                       initializeOptionsPage(id);
+                       displaySelectedOptionPage();
+               } else {
+                       // Delete
+                       fTableViewer.remove(id);
+                       
+                       int last = fTable.getItemCount() - 1;
+                       if (n>last)
+                               n = last;
+                       if (n>=0)
+                               fTable.setSelection(n);
+
+                       saveChecked();
+               }
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.ui.newui.AbstractCPropertyTab#updateData(org.eclipse.cdt.core.settings.model.ICResourceDescription)
+        */
+       @Override
+       public void updateData(ICResourceDescription resDecs) {
+               ICConfigurationDescription oldCfgDesc = fCfgDesc;
+               fCfgDesc = resDecs!=null ? resDecs.getConfiguration() : null;
+               if (oldCfgDesc!=fCfgDesc) {
+                       initMapParsers();
+               }
+               displaySelectedOptionPage();
+               updateButtons();
+       }
+
+       private static boolean isExtensionId(String id) {
+               for (String extId : ErrorParserManager.getErrorParserExtensionIds()) {
+                       if (extId.equals(id)) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+       /**
+        * Check if error parser with this id shown to user differs from error parser defined as extension.
+        */
+       private boolean isModified(String id) {
+               IErrorParserNamed errorParser = fAvailableErrorParsers.get(id);
+               IErrorParserNamed errorParserExt = fExtensionErrorParsers.get(id);
+               return ! errorParser.equals(errorParserExt);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.ui.newui.AbstractCPropertyTab#updateButtons()
+        */
+       @Override
+       public void updateButtons() {
+               int pos = fTable.getSelectionIndex();
+               int count = fTable.getItemCount();
+               int last = count - 1;
+               boolean selected = pos >= 0 && pos <= last;
+               String id = (String)fTableViewer.getElementAt(pos);
+
+               boolean isExtensionId = isExtensionId(id);
+               boolean canDelete = !isExtensionId && isErrorParsersEditable();
+               boolean canReset = isExtensionId && isErrorParsersEditable() && isModified(id);
+               
+               buttonSetText(BUTTON_DELETE, isExtensionId ? RESET_STR : DEL_STR);
+               
+               buttonSetEnabled(BUTTON_ADD, isErrorParsersEditable());
+               buttonSetEnabled(BUTTON_EDIT, isErrorParsersEditable() && selected);
+               buttonSetEnabled(BUTTON_DELETE, (canDelete || canReset) && selected);
+               buttonSetEnabled(BUTTON_MOVEUP, selected && pos!=0);
+               buttonSetEnabled(BUTTON_MOVEDOWN, selected && pos!=last);
+       }
+
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.ui.newui.AbstractCPropertyTab#performApply(org.eclipse.cdt.core.settings.model.ICResourceDescription, org.eclipse.cdt.core.settings.model.ICResourceDescription)
+        */
+       @Override
+       protected void performApply(ICResourceDescription src, ICResourceDescription dst) {
+               performOK();
+
+               if (!page.isForPrefs()) {
+                       ICConfigurationDescription sd = src.getConfiguration();
+                       ICConfigurationDescription dd = dst.getConfiguration();
+                       String[] s = null;
+                       if (sd instanceof ICMultiConfigDescription) {
+                               String[][] ss = ((ICMultiConfigDescription)sd).getErrorParserIDs();
+                               s = CDTPrefUtil.getStrListForDisplay(ss);
+                       } else {
+                               s = sd.getBuildSetting().getErrorParserIDs();
+                       }
+                       if (dd instanceof ICMultiConfigDescription)
+                               ((ICMultiConfigDescription)dd).setErrorParserIDs(s);
+                       else
+                               dd.getBuildSetting().setErrorParserIDs(s);
+                       initMapParsers();
+               }
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.ui.newui.AbstractCPropertyTab#performOK()
+        */
+       @Override
+       protected void performOK() {
+               informPages(true);
+
+               if (page.isForPrefs()) {
+                       if (fCfgDesc==null) {
+                               // Build Settings page
+                               try {
+                                       List<IErrorParserNamed> errorParsersList = new ArrayList<IErrorParserNamed>(fTable.getItemCount());
+                                       for (TableItem item : fTable.getItems()) {
+                                               if (item.getData() instanceof String) {
+                                                       String id = (String) item.getData();
+                                                       if (isModified(id)) {
+                                                               errorParsersList.add(fAvailableErrorParsers.get(id));
+                                                       }
+                                               }
+                                       }
+       
+                                       Object[] checkedElements = fTableViewer.getCheckedElements();
+                                       String[] checkedErrorParserIds = new String[checkedElements.length];
+                                       System.arraycopy(checkedElements, 0, checkedErrorParserIds, 0, checkedElements.length);
+       
+                                       ErrorParserManager.setDefaultErrorParserIds(checkedErrorParserIds);
+                                       ErrorParserManager.setUserDefinedErrorParsers(errorParsersList.toArray(new IErrorParserNamed[errorParsersList.size()]));
+                               } catch (BackingStoreException e) {
+                                       CUIPlugin.log(Messages.ErrorParsTab_error_OnApplyingSettings, e); 
+                               } catch (CoreException e) {
+                                       CUIPlugin.log(Messages.ErrorParsTab_error_OnApplyingSettings, e); 
+                               }
+                       }
+                       initMapParsers();
+               }
+       }
+
+       private void saveChecked() {
+               if (fCfgDesc!=null) {
+                       Object[] objs = fTableViewer.getCheckedElements();
+                       String[] ids = new String[objs.length];
+                       System.arraycopy(objs, 0, ids, 0, objs.length);
+
+                       if (fCfgDesc instanceof ICMultiConfigDescription)
+                               ((ICMultiConfigDescription)fCfgDesc).setErrorParserIDs(ids);
+                       else
+                               fCfgDesc.getBuildSetting().setErrorParserIDs(ids);
+               }
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.ui.newui.AbstractCPropertyTab#canBeVisible()
+        */
+       @Override
+       public boolean canBeVisible() {
+               return page.isForProject() || page.isForPrefs();
+       }
+
+       /**
+        * @return {@code true} if the error parsers are allowed to be editable,
+        *     i.e. Add/Edit/Delete buttons are enabled and Options page edits enabled.
+        *     This will evaluate to {@code true} for Preference Build Settings page but
+        *     not for Preference New CDT Project Wizard/Makefile Project.
+        */
+       private boolean isErrorParsersEditable() {
+               return fCfgDesc==null;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.ui.newui.AbstractCPropertyTab#performDefaults()
+        */
+       @Override
+       protected void performDefaults() {
+               if (isErrorParsersEditable()) {
+                       // Must be Build Settings Preference Page
+                       if (MessageDialog.openQuestion(usercomp.getShell(),
+                                       Messages.ErrorParsTab_title_ConfirmReset, 
+                                       Messages.ErrorParsTab_message_ConfirmReset)) { 
+
+                               try {
+                                       ErrorParserManager.setUserDefinedErrorParsers(null);
+                                       ErrorParserManager.setDefaultErrorParserIds(null);
+                               } catch (BackingStoreException e) {
+                                       CUIPlugin.log(Messages.ErrorParsTab_error_OnRestoring, e); 
+                               } catch (CoreException e) {
+                                       CUIPlugin.log(Messages.ErrorParsTab_error_OnRestoring, e); 
+                               }
+                       }
+               } else {
+                       if (fCfgDesc instanceof ICMultiConfigDescription)
+                               ((ICMultiConfigDescription) fCfgDesc).setErrorParserIDs(null);
+                       else
+                               fCfgDesc.getBuildSetting().setErrorParserIDs(null);
+               }
+               initMapParsers();
+               updateButtons();
+       }
+
+       private void informPages(boolean apply) {
+               Collection<ICOptionPage> pages = fOptionsPageMap.values();
+               for (ICOptionPage dynamicPage : pages) {
+                       if (dynamicPage!=null && dynamicPage.isValid() && dynamicPage.getControl() != null) {
+                               try {
+                                       if (apply)
+                                               dynamicPage.performApply(new NullProgressMonitor());
+                                       else
+                                               dynamicPage.performDefaults();
+                               } catch (CoreException e) {
+                                       CUIPlugin.log(Messages.ErrorParsTab_error_OnApplyingSettings, e); 
+                               }
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternDialog.java
new file mode 100644 (file)
index 0000000..323eea7
--- /dev/null
@@ -0,0 +1,274 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.StatusDialog;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.eclipse.ui.views.navigator.ResourceComparator;
+
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.dialogs.TypedElementSelectionValidator;
+import org.eclipse.cdt.internal.ui.dialogs.TypedViewerFilter;
+import org.eclipse.cdt.internal.ui.dialogs.cpaths.CPathEntryMessages;
+import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;
+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.IListAdapter;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class ExPatternDialog extends StatusDialog {
+       
+       private ListDialogField<String> fExclusionPatternList;
+       private IProject fCurrProject;
+       private IPath[] pattern;
+       private IPath path;     
+       private IContainer fCurrSourceFolder;
+       
+       private static final int IDX_ADD= 0;
+       private static final int IDX_ADD_MULTIPLE= 1;
+       private static final int IDX_EDIT= 2;
+       private static final int IDX_REMOVE= 4;
+               
+       public ExPatternDialog(Shell parent, IPath[] _data, IPath _path, IProject proj) {
+               super(parent);
+               fCurrProject = proj;
+               pattern = _data;
+               path = _path;
+               setTitle(CPathEntryMessages.ExclusionPatternDialog_title); 
+
+               String label= NLS.bind(CPathEntryMessages.ExclusionPatternDialog_pattern_label,
+                               path.makeRelative().toString()); 
+               
+               String[] buttonLabels= new String[] {
+                       CPathEntryMessages.ExclusionPatternDialog_pattern_add, 
+                       CPathEntryMessages.ExclusionPatternDialog_pattern_add_multiple, 
+                       CPathEntryMessages.ExclusionPatternDialog_pattern_edit, 
+                       null,
+                       CPathEntryMessages.ExclusionPatternDialog_pattern_remove
+               };
+
+               ExclusionPatternAdapter adapter= new ExclusionPatternAdapter();
+
+               fExclusionPatternList= new ListDialogField<String>(adapter, buttonLabels, new ExPatternLabelProvider());
+               fExclusionPatternList.setDialogFieldListener(adapter);
+               fExclusionPatternList.setLabelText(label);
+               fExclusionPatternList.setRemoveButtonIndex(IDX_REMOVE);
+               fExclusionPatternList.enableButton(IDX_EDIT, false);
+       
+               IWorkspaceRoot root= fCurrProject.getWorkspace().getRoot();
+               IResource res= root.findMember(path);
+               if (res instanceof IContainer) {
+                       fCurrSourceFolder= (IContainer) res;
+               }                               
+               
+               ArrayList<String> elements= new ArrayList<String>(pattern.length);
+               for (IPath p : pattern) 
+                       elements.add(p.toString());
+               fExclusionPatternList.setElements(elements);
+               fExclusionPatternList.selectFirstElement();
+               fExclusionPatternList.enableButton(IDX_ADD_MULTIPLE, fCurrSourceFolder != null);
+
+               setHelpAvailable(false);
+       }
+
+       @Override
+       protected Control createDialogArea(Composite parent) {
+               Composite composite= (Composite) super.createDialogArea(parent);
+
+               Composite inner= new Composite(composite, SWT.NONE);
+               inner.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               GridLayout layout= new GridLayout(2, false);
+               layout.marginHeight= 0;
+               layout.marginWidth= 0;
+               inner.setLayout(layout);
+               
+               fExclusionPatternList.doFillIntoGrid(inner, 3);
+               LayoutUtil.setHorizontalSpan(fExclusionPatternList.getLabelControl(null), 2);
+               
+               applyDialogFont(composite);             
+               return composite;
+       }
+       
+       protected void doCustomButtonPressed(ListDialogField<String> field, int index) {
+               if (index == IDX_ADD) {
+                       addEntry();
+               } else if (index == IDX_EDIT) {
+                       editEntry();
+               } else if (index == IDX_ADD_MULTIPLE) {
+                       addMultipleEntries();
+               }
+       }
+       
+       protected void doDoubleClicked(ListDialogField<String> field) {
+               editEntry();
+       }
+       
+       protected void doSelectionChanged(ListDialogField<String> field) {
+               List<String> selected= field.getSelectedElements();
+               fExclusionPatternList.enableButton(IDX_EDIT, canEdit(selected));
+       }
+       
+       private boolean canEdit(List<?> selected) {
+               return selected.size() == 1;
+       }
+       
+       private void editEntry() {
+               
+               List<String> selElements= fExclusionPatternList.getSelectedElements();
+               if (selElements.size() != 1) {
+                       return;
+               }
+               List<String> existing= fExclusionPatternList.getElements();
+               String entry= selElements.get(0);
+               ExPatternEntryDialog dialog= new ExPatternEntryDialog(getShell(), entry, existing, fCurrProject, path);
+               if (dialog.open() == Window.OK) {
+                       fExclusionPatternList.replaceElement(entry, dialog.getExclusionPattern());
+               }
+       }
+       
+       private void addEntry() {
+               List<String> existing= fExclusionPatternList.getElements();
+               ExPatternEntryDialog dialog= new ExPatternEntryDialog(getShell(), null, existing, fCurrProject, path);
+               if (dialog.open() == Window.OK) {
+                       fExclusionPatternList.addElement(dialog.getExclusionPattern());
+               }
+       }       
+               
+       protected void doStatusLineUpdate() {
+       }               
+       
+       protected void checkIfPatternValid() {
+       }
+               
+       public IPath[] getExclusionPattern() {
+               IPath[] res= new IPath[fExclusionPatternList.getSize()];
+               for (int i= 0; i < res.length; i++) {
+                       String entry= fExclusionPatternList.getElement(i);
+                       res[i]= new Path(entry);
+               }
+               return res;
+       }
+               
+       /*
+        * @see org.eclipse.jface.window.Window#configureShell(Shell)
+        */
+       @Override
+       protected void configureShell(Shell newShell) {
+               super.configureShell(newShell);
+//             WorkbenchHelp.setHelp(newShell, ICHelpContextIds.EXCLUSION_PATTERN_DIALOG);
+       }
+
+    @Override
+       protected boolean isResizable() {
+       return true;
+    }
+
+       private void addMultipleEntries() {
+               Class<?>[] acceptedClasses= new Class<?>[] { IFolder.class, IFile.class };
+               ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, true);
+               ViewerFilter filter= new TypedViewerFilter(acceptedClasses);
+
+               ILabelProvider lp= new WorkbenchLabelProvider();
+               ITreeContentProvider cp= new WorkbenchContentProvider();
+               
+               IResource initialElement= null; 
+
+               ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), lp, cp);
+               dialog.setTitle(CPathEntryMessages.ExclusionPatternDialog_ChooseExclusionPattern_title); 
+               dialog.setValidator(validator);
+               dialog.setMessage(CPathEntryMessages.ExclusionPatternDialog_ChooseExclusionPattern_description); 
+               dialog.addFilter(filter);
+               dialog.setInput(fCurrSourceFolder);
+               dialog.setInitialSelection(initialElement);
+               dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
+
+               if (dialog.open() == Window.OK) {
+                       Object[] objects= dialog.getResult();
+                       int existingSegments= fCurrSourceFolder.getFullPath().segmentCount();
+                       
+                       for (Object object : objects) {
+                               IResource curr= (IResource) object;
+                               IPath path= curr.getFullPath().removeFirstSegments(existingSegments).makeRelative();
+                               String res;
+                               if (curr instanceof IContainer) {
+                                       res= path.addTrailingSeparator().toString();
+                               } else {
+                                       res= path.toString();
+                               }
+                               fExclusionPatternList.addElement(res);
+                       }
+               }
+       }       
+       
+       private static class ExPatternLabelProvider extends LabelProvider {
+               
+               @Override
+               public Image getImage(Object element) {
+                       ImageDescriptorRegistry registry= CUIPlugin.getImageDescriptorRegistry();
+                       return registry.get(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_EXCLUSION_FILTER_ATTRIB));
+               }
+
+               @Override
+               public String getText(Object element) {
+                       return (String) element;
+               }
+       }
+       
+       private class ExclusionPatternAdapter implements IListAdapter<String>, IDialogFieldListener {
+               public void customButtonPressed(ListDialogField<String> field, int index) {
+                       doCustomButtonPressed(field, index);
+               }
+
+               public void selectionChanged(ListDialogField<String> field) {
+                       doSelectionChanged(field);
+               }
+
+               public void doubleClicked(ListDialogField<String> field) {
+                       doDoubleClicked(field);
+               }
+
+               public void dialogFieldChanged(DialogField field) {
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternEntryDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExPatternEntryDialog.java
new file mode 100644 (file)
index 0000000..243d479
--- /dev/null
@@ -0,0 +1,239 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.StatusDialog;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.eclipse.ui.views.navigator.ResourceComparator;
+
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.dialogs.TypedElementSelectionValidator;
+import org.eclipse.cdt.internal.ui.dialogs.TypedViewerFilter;
+import org.eclipse.cdt.internal.ui.dialogs.cpaths.CPathEntryMessages;
+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.StringButtonDialogField;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class ExPatternEntryDialog extends StatusDialog {
+       private StringButtonDialogField fExclusionPatternDialog;
+       private StatusInfo fExclusionPatternStatus;
+
+       private IContainer fCurrSourceFolder;
+       private String fExclusionPattern;
+       private List<String> fExistingPatterns;
+
+       public ExPatternEntryDialog(Shell parent, String patternToEdit, List<String> existingPatterns, IProject proj, IPath path) {
+               super(parent);
+               fExistingPatterns = existingPatterns;
+               if (patternToEdit == null) {
+                       setTitle(CPathEntryMessages.ExclusionPatternEntryDialog_add_title); 
+               } else {
+                       setTitle(CPathEntryMessages.ExclusionPatternEntryDialog_edit_title); 
+                       fExistingPatterns.remove(patternToEdit);
+               }
+
+               IWorkspaceRoot root = proj.getWorkspace().getRoot();
+               IResource res = root.findMember(path);
+               if (res instanceof IContainer) {
+                       fCurrSourceFolder = (IContainer) res;
+               }
+
+               fExclusionPatternStatus = new StatusInfo();
+
+               String label = NLS.bind(CPathEntryMessages.ExclusionPatternEntryDialog_pattern_label, 
+                               path.makeRelative().toString());
+
+               ExPatternAdapter adapter = new ExPatternAdapter();
+               fExclusionPatternDialog = new StringButtonDialogField(adapter);
+               fExclusionPatternDialog.setLabelText(label);
+               fExclusionPatternDialog.setButtonLabel(CPathEntryMessages.ExclusionPatternEntryDialog_pattern_button); 
+               fExclusionPatternDialog.setDialogFieldListener(adapter);
+               fExclusionPatternDialog.enableButton(fCurrSourceFolder != null);
+
+               if (patternToEdit == null) {
+                       fExclusionPatternDialog.setText(""); //$NON-NLS-1$
+               } else {
+                       fExclusionPatternDialog.setText(patternToEdit.toString());
+               }
+
+               setHelpAvailable(false);
+       }
+
+       @Override
+       protected Control createDialogArea(Composite parent) {
+               Composite composite = (Composite) super.createDialogArea(parent);
+
+               int widthHint = convertWidthInCharsToPixels(60);
+
+               Composite inner = new Composite(composite, SWT.NONE);
+               GridLayout layout = new GridLayout();
+               layout.marginHeight = 0;
+               layout.marginWidth = 0;
+               layout.numColumns = 2;
+               inner.setLayout(layout);
+
+               Label description = new Label(inner, SWT.WRAP);
+               description.setText(CPathEntryMessages.ExclusionPatternEntryDialog_description); 
+               GridData gd = new GridData();
+               gd.horizontalSpan = 2;
+               gd.widthHint = convertWidthInCharsToPixels(80);
+               description.setLayoutData(gd);
+
+               fExclusionPatternDialog.doFillIntoGrid(inner, 3);
+
+               LayoutUtil.setWidthHint(fExclusionPatternDialog.getLabelControl(null), widthHint);
+               LayoutUtil.setHorizontalSpan(fExclusionPatternDialog.getLabelControl(null), 2);
+
+               LayoutUtil.setWidthHint(fExclusionPatternDialog.getTextControl(null), widthHint);
+               LayoutUtil.setHorizontalGrabbing(fExclusionPatternDialog.getTextControl(null), true);
+
+               fExclusionPatternDialog.postSetFocusOnDialogField(parent.getDisplay());
+               applyDialogFont(composite);
+               return composite;
+       }
+
+       // -------- ExclusionPatternAdapter --------
+
+       private class ExPatternAdapter implements IDialogFieldListener, IStringButtonAdapter {
+
+               // -------- IDialogFieldListener
+
+               public void dialogFieldChanged(DialogField field) {
+                       doStatusLineUpdate();
+               }
+
+               public void changeControlPressed(DialogField field) {
+                       doChangeControlPressed();
+               }
+       }
+
+       protected void doChangeControlPressed() {
+               IPath pattern = chooseExclusionPattern();
+               if (pattern != null) {
+                       fExclusionPatternDialog.setText(pattern.toString());
+               }
+       }
+
+       protected void doStatusLineUpdate() {
+               checkIfPatternValid();
+               updateStatus(fExclusionPatternStatus);
+       }
+
+       protected void checkIfPatternValid() {
+               String pattern = fExclusionPatternDialog.getText().trim();
+               if (pattern.length() == 0) {
+                       fExclusionPatternStatus.setError(CPathEntryMessages.ExclusionPatternEntryDialog_error_empty); 
+                       return;
+               }
+               IPath path = new Path(pattern);
+               if (path.isAbsolute() || path.getDevice() != null) {
+                       fExclusionPatternStatus.setError(CPathEntryMessages.ExclusionPatternEntryDialog_error_notrelative); 
+                       return;
+               }
+               if (fExistingPatterns.contains(pattern)) {
+                       fExclusionPatternStatus.setError(CPathEntryMessages.ExclusionPatternEntryDialog_error_exists); 
+                       return;
+               }
+
+               fExclusionPattern = pattern;
+               fExclusionPatternStatus.setOK();
+       }
+
+       public String getExclusionPattern() {
+               return fExclusionPattern;
+       }
+
+       /*
+        * @see org.eclipse.jface.window.Window#configureShell(Shell)
+        */
+       @Override
+       protected void configureShell(Shell newShell) {
+               super.configureShell(newShell);
+               //              WorkbenchHelp.setHelp(newShell,
+               // ICHelpContextIds.EXCLUSION_PATTERN_DIALOG);
+       }
+
+       // ---------- util method ------------
+
+       private IPath chooseExclusionPattern() {
+               Class<?>[] acceptedClasses = new Class<?>[] { IFolder.class, IFile.class};
+               ISelectionStatusValidator validator = new TypedElementSelectionValidator(acceptedClasses, false);
+               ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
+
+               ILabelProvider lp = new WorkbenchLabelProvider();
+               ITreeContentProvider cp = new WorkbenchContentProvider();
+
+               IPath initialPath = new Path(fExclusionPatternDialog.getText());
+               IResource initialElement = null;
+               IContainer curr = fCurrSourceFolder;
+               int nSegments = initialPath.segmentCount();
+               for (int i = 0; i < nSegments; i++) {
+                       IResource elem = curr.findMember(initialPath.segment(i));
+                       if (elem != null) {
+                               initialElement = elem;
+                       }
+                       if (elem instanceof IContainer) {
+                               curr = (IContainer) elem;
+                       } else {
+                               break;
+                       }
+               }
+
+               ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), lp, cp);
+               dialog.setTitle(CPathEntryMessages.ExclusionPatternEntryDialog_ChooseExclusionPattern_title); 
+               dialog.setValidator(validator);
+               dialog.setMessage(CPathEntryMessages.ExclusionPatternEntryDialog_ChooseExclusionPattern_description); 
+               dialog.addFilter(filter);
+               dialog.setInput(fCurrSourceFolder);
+               dialog.setInitialSelection(initialElement);
+               dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
+
+               if (dialog.open() == Window.OK) {
+                       IResource res = (IResource) dialog.getFirstResult();
+                       IPath path = res.getFullPath().removeFirstSegments(fCurrSourceFolder.getFullPath().segmentCount()).makeRelative();
+                       if (res instanceof IContainer) {
+                               return path.addTrailingSeparator();
+                       }
+                       return path;
+               }
+               return null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpDialog.java
new file mode 100644 (file)
index 0000000..45d01e9
--- /dev/null
@@ -0,0 +1,328 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+//import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class ExpDialog extends AbstractPropertyDialog {
+       
+       protected static final String TO_ALL = Messages.ExpDialog_5; 
+       protected static final String EMPTY_NAME = Messages.ExpDialog_8; 
+       protected static final String EMPTY_VALUE = Messages.ExpDialog_10; 
+       
+       public String[] sel_types = null;
+       public String[] sel_langs = null; 
+       private Text txt1;
+       private Text txt2;
+       private List langs;
+       private List types;
+       private Label message;
+       private Button c_langs;
+       private Button c_types;
+       private Button c_all;
+       private Button c_wsp;
+       
+       private Button b_vars;
+       private Button b_work;
+       private Button b_file;
+       private Button b_ok;
+       private Button b_ko;
+       private boolean newAction, isWsp;
+       private int kind;
+       private ICConfigurationDescription cfgd;
+       private String[] names_l, names_t;
+       private java.util.List<String> existing;
+
+       public ExpDialog(Shell parent, boolean _newAction,
+               String title, String _data1, String _data2,
+               ICConfigurationDescription _cfgd,
+               String[] _langs, String[] _types,
+               int _kind, String[] _names_l, String[] _names_t, 
+               java.util.List<String> _existing, boolean _isWsp) {
+               super(parent, title);
+               super.text1 = (_data1 == null) ? EMPTY_STR : _data1;
+               super.text2 = (_data2 == null) ? EMPTY_STR : _data2;
+               newAction = _newAction;
+               cfgd = _cfgd;
+               sel_langs = _langs;
+               sel_types = _types;
+               kind = _kind;
+               names_l = _names_l;
+               names_t = _names_t;
+               existing = _existing;
+               isWsp = _isWsp;
+       }
+
+       @Override
+       protected Control createDialogArea(Composite c) {
+               GridData gd;
+               if (c.getLayoutData() instanceof GridData) {
+                       gd = (GridData)c.getLayoutData();
+                       gd.horizontalIndent = 10;
+                       c.setLayoutData(gd);
+               }
+               c.setLayout(new GridLayout(4, true));
+               
+               Label l1 = new Label(c, SWT.NONE);
+               l1.setText(Messages.ExpDialog_6);  
+               l1.setLayoutData(new GridData(GridData.BEGINNING));
+               
+               txt1 = new Text(c, SWT.SINGLE | SWT.BORDER);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = 3;
+               gd.widthHint = 300;
+               txt1.setLayoutData(gd);
+               txt1.addModifyListener(new ModifyListener() {
+                       public void modifyText(ModifyEvent e) {
+                               setButtons(false);
+                       }});
+                               
+               Label l2 = new Label(c, SWT.NONE);
+               l2.setText(Messages.ExpDialog_7);  
+               l2.setLayoutData(new GridData(GridData.BEGINNING));
+               
+               txt2 = new Text(c, SWT.SINGLE | SWT.BORDER);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = 2;
+               gd.widthHint = 300;
+               txt2.setLayoutData(gd);
+               txt2.addModifyListener(new ModifyListener() {
+                       public void modifyText(ModifyEvent e) {
+                               setButtons(false);
+                       }});
+               
+               if (kind != ICSettingEntry.MACRO) {
+                       l1.setVisible(false);
+                       txt1.setVisible(false);
+                       txt2.setText(super.text1); // note that name edited by 2nd text widget
+               } else {
+                       txt1.setText(super.text1);
+                       txt2.setText(super.text1);
+                       if (!newAction) txt1.setEnabled(false); // macro name
+               }
+               
+               b_vars = setupButton(c, AbstractCPropertyTab.VARIABLESBUTTON_NAME);
+
+               c_all = new Button(c, SWT.CHECK);
+               c_all.setText(Messages.ExpDialog_0); 
+               gd = new GridData(GridData.BEGINNING);
+               gd.horizontalSpan = 2;
+               c_all.setLayoutData(gd);
+               c_all.setVisible(newAction);
+               
+               b_work = setupButton(c, AbstractCPropertyTab.WORKSPACEBUTTON_NAME);
+               b_file = setupButton(c, AbstractCPropertyTab.FILESYSTEMBUTTON_NAME);
+
+               c_wsp = new Button(c, SWT.CHECK);
+               c_wsp.setText(Messages.ExpDialog_4); 
+               gd = new GridData(GridData.BEGINNING);
+               gd.horizontalSpan = 3;
+               c_wsp.setLayoutData(gd);
+               c_wsp.setSelection(isWsp);
+               c_wsp.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               c_wsp.setImage(AbstractExportTab.getWspImage(c_wsp.getSelection()));
+                       }});
+
+               c_wsp.setImage(AbstractExportTab.getWspImage(isWsp));
+               
+               if (kind == ICSettingEntry.MACRO) {
+                       b_work.setVisible(false);
+                       b_file.setVisible(false);
+                       c_wsp.setVisible(false); 
+               }
+               
+               Group dest = new Group(c, SWT.NONE);
+               dest.setText(Messages.ExpDialog_1); 
+               dest.setLayout(new GridLayout(2, true));
+               gd = new GridData(GridData.FILL_BOTH);
+               gd.horizontalSpan = 4;
+               dest.setLayoutData(gd);
+               
+               Label l = new Label(dest, SWT.NONE);
+               l.setText(Messages.ExpDialog_2); 
+               l.setLayoutData(new GridData(GridData.BEGINNING));
+
+               l = new Label(dest, SWT.NONE);
+               l.setText(Messages.ExpDialog_3); 
+               l.setLayoutData(new GridData(GridData.BEGINNING));
+               
+               c_langs = new Button(dest, SWT.CHECK);
+               c_langs.setText(TO_ALL);
+               c_langs.setLayoutData(new GridData(GridData.BEGINNING));
+               c_langs.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               langs.setEnabled(!c_langs.getSelection());
+                       }});
+               
+               c_types = new Button(dest, SWT.CHECK);
+               c_types.setText(TO_ALL);
+               c_types.setLayoutData(new GridData(GridData.BEGINNING));
+               c_types.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               types.setEnabled(!c_types.getSelection());
+                       }});
+               
+               langs = new List(dest, SWT.BORDER | SWT.MULTI);
+               langs.setLayoutData(new GridData(GridData.FILL_BOTH));
+               langs.setItems(names_l);
+               setSelections(sel_langs, langs, c_langs);
+               
+               types = new List(dest, SWT.BORDER | SWT.MULTI);
+               types.setLayoutData(new GridData(GridData.FILL_BOTH));
+               types.setItems(names_t);
+               setSelections(sel_types, types, c_types);
+               
+               message = new Label(c, SWT.NONE);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = 4;
+               message.setLayoutData(gd);
+           message.setForeground(c.getDisplay().getSystemColor(SWT.COLOR_RED));
+               
+               // DUMMY PLACEHOLDER
+               new Label(c, 0).setLayoutData(new GridData(GridData.BEGINNING));
+               b_ok = setupButton(c, IDialogConstants.OK_LABEL);
+               b_ko = setupButton(c, IDialogConstants.CANCEL_LABEL);
+
+               c.getShell().setDefaultButton(b_ok);
+               c.pack();
+               setButtons(true);
+               return c;
+       }       
+       
+       private void setButtons(boolean anew) {
+               if (b_ok == null) return; // while init only
+               message.setText(EMPTY_STR);
+               String name;
+               boolean enabled = true;
+               if (kind == ICSettingEntry.MACRO)
+                       name  = txt1.getText().trim();
+               else 
+                       name = txt2.getText().trim();
+               if (name.length() == 0) {
+                       enabled = false;
+                       if (!anew) {
+                               if (kind == ICSettingEntry.MACRO) 
+                                       message.setText(EMPTY_NAME);
+                               else    
+                                       message.setText(EMPTY_VALUE);
+                       }
+               }
+               if (enabled && existing != null && existing.contains(name)) {
+                       message.setText(Messages.ExpDialog_9); 
+                       enabled = false;
+               }
+               b_ok.setEnabled(enabled);
+       }
+       
+       @Override
+       public void buttonPressed(SelectionEvent e) {
+               String s;
+               if (e.widget.equals(b_ok)) { 
+                       if (kind == ICSettingEntry.MACRO)
+                               super.text1 = txt1.getText();
+                       super.text2 = txt2.getText();
+                       super.check1 = c_all.getSelection();
+                       super.check2 = c_wsp.getSelection();
+                       sel_langs = (c_langs.getSelection()) ? null : langs.getSelection();
+                       sel_types = (c_types.getSelection()) ? null : types.getSelection();
+                       result = true;
+                       shell.dispose(); 
+               } else if (e.widget.equals(b_ko)) {
+                       shell.dispose();
+               } else if (e.widget.equals(b_vars)) {
+                       s = AbstractCPropertyTab.getVariableDialog(shell, cfgd);
+                       if (s != null) txt2.insert(s);
+               }  else if (e.widget.equals(b_work)) {
+                       if (kind == ICSettingEntry.INCLUDE_PATH ||
+                               kind == ICSettingEntry.LIBRARY_PATH)
+                               s = AbstractCPropertyTab.getWorkspaceDirDialog(shell, txt2.getText());
+                       else 
+                               s = AbstractCPropertyTab.getWorkspaceFileDialog(shell, txt2.getText());
+                       if (s != null) {
+                               s = strip_wsp(s);
+                               txt2.setText(s);
+                               c_wsp.setSelection(true);
+                               c_wsp.setImage(AbstractExportTab.getWspImage(c_wsp.getSelection()));
+                       }
+               } else if (e.widget.equals(b_file)) {
+                       if (kind == ICSettingEntry.INCLUDE_PATH ||
+                               kind == ICSettingEntry.LIBRARY_PATH) {
+                               s = AbstractCPropertyTab.getFileSystemDirDialog(shell, txt2.getText());
+                       } else if (kind==ICSettingEntry.INCLUDE_FILE) {
+                               s = AbstractCPropertyTab.getFileSystemFileDialog(shell, txt2.getText(), IncludeDialog.FILTER_INCLUDE_FILE);
+                       } else if (kind==ICSettingEntry.LIBRARY_FILE) {
+                               s = AbstractCPropertyTab.getFileSystemFileDialog(shell, txt2.getText(), IncludeDialog.FILTER_LIBRARY_FILE);
+                       } else {
+                               s = AbstractCPropertyTab.getFileSystemFileDialog(shell, txt2.getText());
+                       }
+                       if (s != null) {
+                               txt2.setText(s);
+                               c_wsp.setSelection(false);
+                               c_wsp.setImage(AbstractExportTab.getWspImage(c_wsp.getSelection()));
+                       }
+               }
+       }
+       
+       protected void setSelections(String[] sel, List lst, Button check) {
+               if (sel == null) {
+                       lst.setEnabled(false);
+                       check.setSelection(true);
+               } else {
+                       lst.setEnabled(true);
+                       check.setSelection(false);
+                       if (sel.length == 0) return;
+                       int cnt = 0;
+                       String[] items = lst.getItems();
+
+                       int[] indices = new int[items.length];
+                       for (int i=0; i<indices.length; i++) indices[i] = -1;
+                       
+                       for (int i=0; i<items.length; i++) {
+                               for (String element : sel) {
+                                       if (items[i].equals(element)) {
+                                               indices[cnt++] = i;
+                                               break;
+                                       }
+                               }
+                       }
+                       lst.setSelection(indices);
+               }
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpIncludeFileTab.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpIncludeFileTab.java
new file mode 100644 (file)
index 0000000..c1e07d3
--- /dev/null
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *     Broadcom Corporation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.cdt.core.settings.model.CIncludeFileEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ * @since 5.2
+ */
+public class ExpIncludeFileTab extends AbstractExportTab {
+
+       @Override
+       public ICLanguageSettingEntry doAdd(String s1, String s2, boolean isWsp) {
+               int flags = isWsp ? ICSettingEntry.VALUE_WORKSPACE_PATH : 0;
+               return new CIncludeFileEntry(s2, flags);
+       }
+
+       @Override
+       public ICLanguageSettingEntry doEdit(String s1, String s2, boolean isWsp) {
+               return doAdd(s1, s2, isWsp);
+       }
+
+       @Override
+       public int getKind() {
+               return ICSettingEntry.INCLUDE_FILE;
+       }
+
+       @Override
+       public boolean canBeVisible() {
+               if (!CDTPrefUtil.getBool(CDTPrefUtil.KEY_SHOW_INC_FILES))
+                       return false;
+               return super.canBeVisible();
+       }
+
+       @Override
+       public boolean hasValues() {
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpIncludeTab.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpIncludeTab.java
new file mode 100644 (file)
index 0000000..3482a3e
--- /dev/null
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class ExpIncludeTab extends AbstractExportTab {
+       
+       @Override
+       public ICLanguageSettingEntry doAdd(String s1, String s2, boolean isWsp) {
+               int flags = isWsp ? ICSettingEntry.VALUE_WORKSPACE_PATH : 0;
+               return new CIncludePathEntry(s2, flags);
+       }
+
+       @Override
+       public ICLanguageSettingEntry doEdit(String s1, String s2, boolean isWsp) {
+               return doAdd(s1, s2, isWsp);
+       }
+       
+       @Override
+       public int getKind() { return ICSettingEntry.INCLUDE_PATH; }
+       @Override
+       public boolean hasValues() { return false; }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpLibraryPathTab.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpLibraryPathTab.java
new file mode 100644 (file)
index 0000000..fe17550
--- /dev/null
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.cdt.core.resources.IPathEntryStoreListener;
+import org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent;
+import org.eclipse.cdt.core.settings.model.CLibraryPathEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class ExpLibraryPathTab extends AbstractExportTab implements IPathEntryStoreListener {
+
+       public void pathEntryStoreChanged(PathEntryStoreChangedEvent event) {
+               updateData(getResDesc());
+       }
+
+       @Override
+       public ICLanguageSettingEntry doAdd(String s1, String s2, boolean isWsp) {
+               int flags = isWsp ? ICSettingEntry.VALUE_WORKSPACE_PATH : 0;
+               return new CLibraryPathEntry(s2, flags);
+       }
+
+       @Override
+       public ICLanguageSettingEntry doEdit(String s1, String s2, boolean isWsp) {
+               return doAdd(s1, s2, isWsp);
+       }
+
+       @Override
+       public int getKind() {
+               return ICSettingEntry.LIBRARY_PATH;
+       }
+
+       @Override
+       public boolean hasValues() {
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpLibraryTab.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpLibraryTab.java
new file mode 100644 (file)
index 0000000..97792f0
--- /dev/null
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.cdt.core.resources.IPathEntryStoreListener;
+import org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent;
+import org.eclipse.cdt.core.settings.model.CLibraryFileEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class ExpLibraryTab extends AbstractExportTab implements IPathEntryStoreListener {
+
+       public void pathEntryStoreChanged(PathEntryStoreChangedEvent event) {
+               updateData(getResDesc());
+       }
+
+       @Override
+       public ICLanguageSettingEntry doAdd(String s1, String s2, boolean isWsp) {
+               int flags = isWsp ? ICSettingEntry.VALUE_WORKSPACE_PATH : 0;
+               return new CLibraryFileEntry(s2, flags);
+       }
+
+       @Override
+       public ICLanguageSettingEntry doEdit(String s1, String s2, boolean isWsp) {
+               return doAdd(s1, s2, isWsp);
+       }
+       
+       @Override
+       public int getKind() {
+               return ICSettingEntry.LIBRARY_FILE;
+       }
+
+       @Override
+       public boolean hasValues() {
+               return false;
+       }
+}
+
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpSymbolTab.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ExpSymbolTab.java
new file mode 100644 (file)
index 0000000..a4bdbdd
--- /dev/null
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.cdt.core.settings.model.CMacroEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class ExpSymbolTab extends AbstractExportTab {
+
+       // isWsp is ignored for symbols
+       @Override
+       public ICLanguageSettingEntry doAdd(String s1, String s2, boolean isWsp) {
+               return new CMacroEntry(s1, s2, 0);
+       }
+
+       @Override
+       public ICLanguageSettingEntry doEdit(String s1, String s2, boolean isWsp) {
+               return doAdd(s1, s2, isWsp);
+       }
+       
+       @Override
+       public int getKind() { return ICSettingEntry.MACRO; }
+       @Override
+       public boolean hasValues() { return true; }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyProvider.java
new file mode 100644 (file)
index 0000000..85d31b7
--- /dev/null
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.swt.widgets.Button;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
+
+/**
+ * Interface provides a set of utility methods
+ * provided by new CDT model property page.
+ * Property tabs associated to this page receive
+ * link to this interface and, so, can access
+ * required data, such as project, config etc.
+ * 
+ * In addition, some methods allow to send 
+ * control messages to other pages / tabs.
+ * 
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+
+public interface ICPropertyProvider extends ICOptionContainer {
+       
+       // new list of config descriptions for given project
+       ICConfigurationDescription[] getCfgsReadOnly(IProject p);
+       // list of loaded config descriptions for current project 
+       ICConfigurationDescription[] getCfgsEditable();
+       // Resource description for given object in current cfg
+       ICResourceDescription getResDesc();
+       // Resource description for given object, in given cfg
+       ICResourceDescription getResDesc(ICConfigurationDescription cfgd);
+       // get Affected object (project, folder, file) 
+       IAdaptable getElement();
+       // ask page to enable or disable config selection
+       void enableConfigSelection (boolean enable);
+       
+       //
+       // set of methods intended to handle messages
+       //
+       // 1. send message to all tabs in all pages
+       void informAll(int code, Object data);
+       // 2. send message to all pages. 
+       void informPages(int code, Object data);
+       // 3. send message only to current page
+       void handleMessage(int code, Object data);
+       
+       //
+       // set of methods for object kind check
+       //
+       boolean isForProject();
+       boolean isForFolder();
+       boolean isForFile();
+       boolean isForPrefs();
+       
+       // Checks whether a project is new CDT model-style
+       boolean isCDTProject(IProject p);
+       boolean isMultiCfg();
+       // Gives access to buttons
+       Button getAButton();
+       Button getDButton();
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyTab.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ICPropertyTab.java
new file mode 100644 (file)
index 0000000..3979e43
--- /dev/null
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Interface for tabs in new CDT model.
+ * All tabs available via extension point
+ * "org.eclipse.cdt.managedbuilder.ui.cPropertyTab"
+ * should implement this interface.
+ */
+public interface ICPropertyTab {
+
+       // kinds of message to be sent (and appropriate data class)
+       public static final int OK = 0;    // perform OK (null)
+       public static final int APPLY = 1; // apply changes (IResourceDescription)
+       public static final int CANCEL = 2; // cancel changes (null)
+       public static final int DEFAULTS = 3; // set defaults (null)
+       public static final int UPDATE = 4;  // re-read cfg (IConfiguration)
+       public static final int VISIBLE = 5; // set visible (not-null means true)
+       public static final int DISPOSE = 6; // dispose (null)    
+       public static final int SET_ICON = 7; // inform tab about its icon (Image)    
+       
+       public static final int MAXCOMMON = 100; // values below are common
+                                                // values above are private
+       // Informs other tabs about changes in managed build settings.
+       // It may result in hiding/showing some tabs or changing their 
+       // contents. Data field is not used (null). 
+       public static final int MANAGEDBUILDSTATE  = MAXCOMMON + 1; 
+
+       /**
+        * Creation of all visible elements
+        * @param parent   - composite where widgets should be created
+        * @param provider - underlying page 
+        */
+       public void createControls(Composite parent, ICPropertyProvider provider);
+       
+       /**
+        * Handle events sent by another tabs or pages 
+        * Most of them are processed in <link>AbstractCPropertyTab</link>
+        * but this functionality can be overridden partially or fully.
+        * @param kind - message ID (see <link>AbstractCPropertyTab</link>)
+        * @param data - additional info, depanding of message kind.
+        */
+       public void handleTabEvent (int kind, Object data);
+       
+       /**
+        * Returns true (by default) if page's contents is correct
+        * Returns false if page cannot be shown because it does
+        * not fit to other settings (for example, managed build
+        * settings are not possible when managed build is off).
+        */
+       public boolean canBeVisible();
+       
+       //*********************************
+       // TODO: in next version, add :
+       //*********************************
+       /**
+        * @return Help Context Id
+        */
+       // public String getHelpContextId();
+       /**
+        * set Help Context Id for the tab
+        */
+       // public void setHelpContextId(String id);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IConfigManager.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IConfigManager.java
new file mode 100644 (file)
index 0000000..2119ca8
--- /dev/null
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.core.resources.IProject;
+
+/*
+ * Implementors are intended to 
+ * override "Manage Configurations" dialog
+ * 
+ * @see ConfigManager extension point.
+ */
+public interface IConfigManager {
+       /**
+        * Checks whether objects are applicable to the manager
+        * 
+        * @param obs - selected projects 
+        * @return true if Configuration Management 
+        *         is possible for these objects
+        */
+       public boolean canManage(IProject[] obs);
+       
+       /**
+        * Displays "Manage Configurations" dialog
+        * 
+        * @param obs - selected projects
+        * @param doOk - whether data saving is required
+        * @return true if user pressed OK in dialog 
+        */
+       public boolean manage(IProject[] obs, boolean doOk);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/INewCfgDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/INewCfgDialog.java
new file mode 100644 (file)
index 0000000..5f506f1
--- /dev/null
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+
+/**
+ * Represents class which is able to display
+ * "New configuration" dialog instead of standard one
+ * and, if user pressed OK, create new configuration
+ * on a basis of its internal data
+ * 
+ * used by extension point:
+ * "org.eclipse.cdt.ui.newCfgDialog" 
+ */
+public interface INewCfgDialog {
+       // Project to work with (set before open() !)
+       void setProject(ICProjectDescription prj);
+       // Title of dialog box (set before open() !)
+       void setTitle(String title);
+       // Shell to create dialog (set before open() !)
+       void setShell(Shell shell);
+       // Opens dialog and (after user presses OK)
+       // creates new configuration. 
+       // Returns Windows.OK on success. 
+       int open();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ImportExportWizardButtons.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ImportExportWizardButtons.java
new file mode 100644 (file)
index 0000000..a5146e2
--- /dev/null
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Corporation - Initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.ui.CDTSharedImages;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+import org.eclipse.cdt.internal.ui.wizards.settingswizards.ProjectSettingsExportWizard;
+import org.eclipse.cdt.internal.ui.wizards.settingswizards.ProjectSettingsImportWizard;
+import org.eclipse.cdt.internal.ui.wizards.settingswizards.ProjectSettingsWizard;
+
+/**
+ * Utility class that adds buttons for "Import Settings..." and "Export Settings..."
+ * to the bottom of the Includes and Symbols tabs.
+ * 
+ * @since 5.2
+ */
+public class ImportExportWizardButtons {
+       
+       private ImportExportWizardButtons() {}
+       
+
+       public static void addWizardLaunchButtons(final Composite parent, final IAdaptable selection) {
+               Composite comp = new Composite(parent, SWT.NONE);
+               GridLayout layout = new GridLayout(2, true);
+               layout.marginHeight = layout.marginWidth = 0;
+               comp.setLayout(layout);
+               GridData data = new GridData();
+               data.horizontalSpan = 2;
+               comp.setLayoutData(data);
+               
+               Button importButton = new Button(comp, SWT.NONE);
+               importButton.setText(Messages.IncludeTab_import); 
+               importButton.setImage(CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_IMPORT_SETTINGS));
+               importButton.addSelectionListener(new SelectionAdapter() {
+                       @Override public void widgetSelected(SelectionEvent e) {
+                               boolean finishedPressed = launchWizard(parent.getShell(), selection, false);
+                               // There is no way to get the contents of the property page to update
+                               // other than to close the whole dialog and then reopen it.
+                               if(finishedPressed)
+                                       parent.getShell().close();
+                       }
+               });
+               
+               Button exportButton = new Button(comp, SWT.NONE);
+               exportButton.setText(Messages.IncludeTab_export); 
+               exportButton.setImage(CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_EXPORT_SETTINGS));
+               exportButton.addSelectionListener(new SelectionAdapter() {
+                       @Override public void widgetSelected(SelectionEvent e) {
+                               launchWizard(parent.getShell(), selection, true);
+                       }
+               });
+               
+       }
+       
+       
+       private static boolean launchWizard(Shell shell, IAdaptable selection, boolean export) {
+               ProjectSettingsWizard wizard;
+               if(export)
+                       wizard = new ProjectSettingsExportWizard();
+               else
+                       wizard = new ProjectSettingsImportWizard();
+               
+               wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(selection));
+               WizardDialog dialog = new WizardDialog(shell, wizard);
+               dialog.create();
+               dialog.open();
+               
+               return wizard.isFinishedPressed();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeDialog.java
new file mode 100644 (file)
index 0000000..e97b308
--- /dev/null
@@ -0,0 +1,241 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICMultiConfigDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+import org.eclipse.cdt.ui.CDTSharedImages;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * A combined dialog which allows selecting file or folder from workspace or filesystem
+ * and some more features. The dialog is used on "Paths and Symbols" properties page.
+ * Note that currently it is used not only for include files/folders but for library
+ * files/folders as well.
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class IncludeDialog extends AbstractPropertyDialog {
+       static final String[] FILTER_INCLUDE_FILE = new String[] {"*.h;*.hpp", "*"}; //$NON-NLS-1$ //$NON-NLS-2$
+       static final String[] FILTER_LIBRARY_FILE = new String[] {"*.a;*.so;*.dll;*.lib", "*"}; //$NON-NLS-1$ //$NON-NLS-2$
+       public String sdata;
+       private Button b_add2confs;
+       private Button b_add2langs;
+       public Text text;
+       private Button b_work;
+       private Button b_file;
+       private Button b_vars;
+       private Button b_ok;
+       private Button b_ko;
+       private int mode;
+       private Button c_wsp;
+       private ICConfigurationDescription cfgd;
+       private boolean isWsp = false;
+       private int kind = 0;
+       
+       static final int NEW_FILE = 0;
+       static final int NEW_DIR  = 1;
+       static final int OLD_FILE = 2;
+       static final int OLD_DIR  = 3;
+       
+       static final int DIR_MASK = 1;  
+       static final int OLD_MASK = 2;  
+       
+       /**
+        * @since 5.3
+        */
+       public IncludeDialog(Shell parent, int mode, String title, String data,
+                       ICConfigurationDescription cfgd, int flags, int kind) {
+
+               super(parent, title);
+               this.mode = mode;
+               this.sdata = data;
+               this.cfgd = cfgd;
+               this.isWsp = (flags == ICSettingEntry.VALUE_WORKSPACE_PATH);
+               this.kind = kind;
+       }
+
+       public IncludeDialog(Shell parent, int mode, String title, String data,
+                       ICConfigurationDescription cfgd, int flags) {
+
+               this(parent, mode, title, data, cfgd, flags, 0);
+       }
+
+       @Override
+       protected Control createDialogArea(Composite c) {
+               c.setLayout(new GridLayout(2, false));
+               GridData gd;
+               
+               Label l1 = new Label(c, SWT.NONE);
+               if ((mode & DIR_MASK) == DIR_MASK)
+                       l1.setText(Messages.IncludeDialog_0); 
+               else
+                       l1.setText(Messages.IncludeDialog_1); 
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = 2;
+               l1.setLayoutData(gd);
+               
+               text = new Text(c, SWT.SINGLE | SWT.BORDER);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = 2;
+               gd.widthHint = 300;
+               text.setLayoutData(gd);
+               if ((mode & OLD_MASK) == OLD_MASK) { text.setText(sdata); }
+               text.addModifyListener(new ModifyListener() {
+                       public void modifyText(ModifyEvent e) {
+                               setButtons();
+                       }});
+               
+// Checkboxes
+               Composite c1 = new Composite (c, SWT.NONE); 
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.verticalAlignment = SWT.TOP;
+               c1.setLayoutData(gd);
+               c1.setLayout(new GridLayout(1, false));
+               
+               b_add2confs = new Button(c1, SWT.CHECK);
+               b_add2confs.setText(Messages.IncludeDialog_2); 
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               if (((mode & OLD_MASK) == OLD_MASK) ||
+                               (cfgd instanceof ICMultiConfigDescription)) {
+                       gd.heightHint = 1;
+                       b_add2confs.setVisible(false);
+               }
+               b_add2confs.setLayoutData(gd);
+
+               b_add2langs = new Button(c1, SWT.CHECK);
+               b_add2langs.setText(Messages.IncludeDialog_3); 
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               if ((mode & OLD_MASK) == OLD_MASK) {
+                       gd.heightHint = 1;
+                       b_add2langs.setVisible(false);
+               }
+               b_add2langs.setLayoutData(gd);
+
+               c_wsp = new Button(c1, SWT.CHECK);
+               c_wsp.setText(Messages.ExpDialog_4); 
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               c_wsp.setLayoutData(gd);
+               c_wsp.setSelection(isWsp);
+               c_wsp.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               c_wsp.setImage(getWspImage(c_wsp.getSelection()));
+                       }});
+               c_wsp.setImage(getWspImage(isWsp));
+
+// Buttons             
+               Composite c2 = new Composite (c, SWT.NONE); 
+               gd = new GridData(GridData.END);
+               c2.setLayoutData(gd);
+               c2.setLayout(new GridLayout(2, true));
+               
+               new Label(c2, 0).setLayoutData(new GridData()); // placeholder
+               b_vars = setupButton(c2, AbstractCPropertyTab.VARIABLESBUTTON_NAME);
+
+               new Label(c2, 0).setLayoutData(new GridData()); // placeholder
+               b_work = setupButton(c2, AbstractCPropertyTab.WORKSPACEBUTTON_NAME);
+
+               new Label(c2, 0).setLayoutData(new GridData()); // placeholder
+               b_file = setupButton(c2, AbstractCPropertyTab.FILESYSTEMBUTTON_NAME);
+
+               b_ok = setupButton(c2, IDialogConstants.OK_LABEL);
+               b_ko = setupButton(c2, IDialogConstants.CANCEL_LABEL);
+               
+               c.getShell().setDefaultButton(b_ok);
+               c.pack();
+               
+               // resize (bug #189333)
+               int x = b_ko.getBounds().width * 3 + 10;
+               int y = c.getBounds().width - 10; 
+               if (x > y) {
+                       ((GridData)(text.getLayoutData())).widthHint = x;
+                       c.pack();
+               }
+               
+               setButtons();
+               return c;
+       }       
+       
+       private void setButtons() {
+               b_ok.setEnabled(text.getText().trim().length() > 0);
+       }
+       
+       @Override
+       public void buttonPressed(SelectionEvent e) {
+               String s;
+               if (e.widget.equals(b_ok)) { 
+                       text1 = text.getText();
+                       check1 = b_add2confs.getSelection();
+                       check2 = c_wsp.getSelection();
+                       check3 = b_add2langs.getSelection();
+                       result = true;
+                       shell.dispose(); 
+               } else if (e.widget.equals(b_ko)) {
+                       shell.dispose();
+               } else if (e.widget.equals(b_work)) {
+                       if ((mode & DIR_MASK)== DIR_MASK)
+                               s = AbstractCPropertyTab.getWorkspaceDirDialog(shell, text.getText());
+                       else 
+                               s = AbstractCPropertyTab.getWorkspaceFileDialog(shell, text.getText());
+                       if (s != null) {
+                               s = strip_wsp(s);
+                               text.setText(s);
+                               c_wsp.setSelection(true);
+                               c_wsp.setImage(getWspImage(c_wsp.getSelection()));
+                       }
+               } else if (e.widget.equals(b_file)) {
+                       if ((mode & DIR_MASK)== DIR_MASK) {
+                               s = AbstractCPropertyTab.getFileSystemDirDialog(shell, text.getText());
+                       } else {
+                               if (kind==ICSettingEntry.INCLUDE_FILE)
+                                       s = AbstractCPropertyTab.getFileSystemFileDialog(shell, text.getText(), FILTER_INCLUDE_FILE);
+                               else if (kind==ICSettingEntry.LIBRARY_FILE)
+                                       s = AbstractCPropertyTab.getFileSystemFileDialog(shell, text.getText(), FILTER_LIBRARY_FILE);
+                               else
+                                       s = AbstractCPropertyTab.getFileSystemFileDialog(shell, text.getText());
+                       }
+                       if (s != null) {
+                               text.setText(s);
+                               c_wsp.setSelection(false);
+                               c_wsp.setImage(getWspImage(c_wsp.getSelection()));
+                       }
+               } else if (e.widget.equals(b_vars)) {
+                       s = AbstractCPropertyTab.getVariableDialog(shell, cfgd);
+                       if (s != null) text.insert(s);
+               }
+       }
+       
+       static private Image getWspImage(boolean isWsp) {
+               final Image IMG_WORKSPACE = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_WORKSPACE); 
+               final Image IMG_FILESYSTEM = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_FOLDER); 
+               return isWsp ? IMG_WORKSPACE : IMG_FILESYSTEM;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeFileTab.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeFileTab.java
new file mode 100644 (file)
index 0000000..a494da5
--- /dev/null
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *     IBM Corporation
+ *     Broadcom Corporation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleAdapter;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.TableColumn;
+
+import org.eclipse.cdt.core.settings.model.CIncludeFileEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * This class provides UI for the {@link ICSettingEntry#INCLUDE_FILE}
+ * option type.
+ *<p>
+ * This tab is hidden by default and can be shown under: <br/>
+ *             Window > Preferences > C/C++ > Property Page Settings > Show "Include Files" Tab
+ *
+ * @noextend This class is not intended to be subclassed by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ * @since 5.2
+ */
+public class IncludeFileTab extends AbstractLangsListTab {
+
+       @Override
+       public void additionalTableSet() {
+               columnToFit = new TableColumn(table, SWT.NONE);
+               columnToFit.setText(Messages.IncludeFileTab_0); 
+               columnToFit.setToolTipText(Messages.IncludeFileTab_0); 
+               showBIButton.setSelection(true);
+               table.getAccessible().addAccessibleListener(new AccessibleAdapter() {
+                       @Override
+                       public void getName(AccessibleEvent e) {
+                               e.result = Messages.IncludeFileTab_0; 
+                       }
+               });
+       }
+
+       @Override
+       public ICLanguageSettingEntry doAdd() {
+               IncludeDialog dlg = new IncludeDialog(
+                               usercomp.getShell(),
+                               IncludeDialog.NEW_FILE,
+                               Messages.IncludeFileTab_1,
+                               EMPTY_STR,
+                               getResDesc().getConfiguration(),
+                               0,
+                               ICSettingEntry.INCLUDE_FILE);
+               if (dlg.open() && dlg.text1.trim().length() > 0) {
+                       toAllCfgs = dlg.check1;
+                       toAllLang = dlg.check3;
+                       int flags = 0;
+                       if (dlg.check2) { // isWsp
+                               flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
+                       }
+                       return new CIncludeFileEntry(dlg.text1, flags);
+               }
+               return null;
+       }
+
+       @Override
+       public ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent) {
+               IncludeDialog dlg = new IncludeDialog(
+                               usercomp.getShell(),
+                               IncludeDialog.OLD_FILE,
+                               Messages.IncludeFileTab_2, 
+                               ent.getValue(),
+                               getResDesc().getConfiguration(),
+                               ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH,
+                               ICSettingEntry.INCLUDE_FILE);
+               if (dlg.open()) {
+                       int flags = 0;
+                       if (dlg.check2)
+                               flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
+                       return new CIncludeFileEntry(dlg.text1, flags);
+               }
+               return null;
+       }
+
+       @Override
+       public int getKind() {
+               return ICSettingEntry.INCLUDE_FILE;
+       }
+
+       @Override
+       public boolean canBeVisible() {
+               if (!CDTPrefUtil.getBool(CDTPrefUtil.KEY_SHOW_INC_FILES))
+                       return false;
+               return super.canBeVisible();
+       }
+
+       @Override
+       public void createControls(final Composite parent) {
+               super.createControls(parent);
+               ImportExportWizardButtons.addWizardLaunchButtons(usercomp, page.getElement());
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeTab.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeTab.java
new file mode 100644 (file)
index 0000000..40ada52
--- /dev/null
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *     IBM Corporation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleAdapter;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.TableColumn;
+
+import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class IncludeTab extends AbstractLangsListTab {
+       
+   @Override
+public void additionalTableSet() {
+          columnToFit = new TableColumn(table, SWT.NONE);
+          columnToFit.setText(Messages.IncludeTab_0); 
+          columnToFit.setToolTipText(Messages.IncludeTab_0); 
+          showBIButton.setSelection(true);
+          table.getAccessible().addAccessibleListener(
+                               new AccessibleAdapter() {                       
+                  @Override
+                                       public void getName(AccessibleEvent e) {
+                          e.result = Messages.IncludeTab_0; 
+                  }
+              }
+                 );
+   }
+       
+       @Override
+       public ICLanguageSettingEntry doAdd() {
+               IncludeDialog dlg = new IncludeDialog(
+                               usercomp.getShell(), IncludeDialog.NEW_DIR,
+                               Messages.IncludeTab_1,  
+                               EMPTY_STR, getResDesc().getConfiguration(), 0);
+               if (dlg.open() && dlg.text1.trim().length() > 0 ) {
+                       toAllCfgs = dlg.check1;
+                       toAllLang = dlg.check3;
+                       int flags = 0;
+                       if (dlg.check2) { // isWsp
+                               flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
+                       }
+                       return new CIncludePathEntry(dlg.text1, flags);
+               }
+               return null;
+       }
+
+       @Override
+       public ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent) {
+               IncludeDialog dlg = new IncludeDialog(
+                               usercomp.getShell(), IncludeDialog.OLD_DIR,
+                               Messages.IncludeTab_2,  
+                               ent.getValue(), getResDesc().getConfiguration(),
+                               (ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH));
+               if (dlg.open()) {
+                       int flags = 0;
+                       if (dlg.check2) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
+                       return new CIncludePathEntry(dlg.text1, flags);
+               }
+               return null;
+       }
+       
+       @Override
+       public int getKind() { return ICSettingEntry.INCLUDE_PATH; }
+       
+       
+       @Override
+       public void createControls(final Composite parent) {
+               super.createControls(parent);
+               ImportExportWizardButtons.addWizardLaunchButtons(usercomp, page.getElement());
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryPathTab.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryPathTab.java
new file mode 100644 (file)
index 0000000..e318962
--- /dev/null
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *     IBM Corporation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.TableColumn;
+
+import org.eclipse.cdt.core.resources.IPathEntryStoreListener;
+import org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent;
+import org.eclipse.cdt.core.settings.model.CLibraryPathEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class LibraryPathTab extends AbstractLangsListTab implements IPathEntryStoreListener {
+       private static final int[] PRIVATE_SASH_WEIGHTS = new int[] { 0, 30 };
+
+       @Override
+       public void additionalTableSet() {
+               columnToFit = new TableColumn(table, SWT.NONE);
+       }
+
+       @Override
+       public void createControls(Composite parent) {
+               super.createControls(parent);
+               sashForm.setWeights(PRIVATE_SASH_WEIGHTS);
+               langTree.setVisible(false);
+       }
+       
+       public void pathEntryStoreChanged(PathEntryStoreChangedEvent event) {
+               updateData(getResDesc());
+       }
+
+       @Override
+       public ICLanguageSettingEntry doAdd() {
+               IncludeDialog dlg = new IncludeDialog(
+                               usercomp.getShell(), IncludeDialog.NEW_DIR,
+                               Messages.LibraryPathTab_1,  
+                               EMPTY_STR, getResDesc().getConfiguration(), 0);
+               if (dlg.open() && dlg.text1.trim().length() > 0 ) {
+                       toAllCfgs = dlg.check1;
+                       toAllLang = dlg.check3;
+                       int flags = 0;
+                       if (dlg.check2) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
+                       return new CLibraryPathEntry(dlg.text1, flags);
+               }
+               return null;
+       }
+
+       @Override
+       public ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent) {
+               IncludeDialog dlg = new IncludeDialog(
+                               usercomp.getShell(), IncludeDialog.OLD_DIR,
+                               Messages.LibraryPathTab_2,  
+                               ent.getValue(), getResDesc().getConfiguration(),
+                               (ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH));
+               if (dlg.open() && dlg.text1.trim().length() > 0 ) {
+                       int flags = 0;
+                       if (dlg.check2) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
+                       return new CLibraryPathEntry(dlg.text1, flags);
+               }
+               return null;
+       }
+       
+       @Override
+       public int getKind() { 
+               return ICSettingEntry.LIBRARY_PATH; 
+       }
+       
+       @Override
+       protected boolean isHeaderVisible() {
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryTab.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/LibraryTab.java
new file mode 100644 (file)
index 0000000..9292bfe
--- /dev/null
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.TableColumn;
+
+import org.eclipse.cdt.core.resources.IPathEntryStoreListener;
+import org.eclipse.cdt.core.resources.PathEntryStoreChangedEvent;
+import org.eclipse.cdt.core.settings.model.CLibraryFileEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class LibraryTab extends AbstractLangsListTab implements IPathEntryStoreListener {
+       private static final int[] PRIVATE_SASH_WEIGHTS = new int[] { 0, 30 };
+
+       @Override
+       public void additionalTableSet() {
+               columnToFit = new TableColumn(table, SWT.NONE);
+       }
+
+       @Override
+       public void createControls(Composite parent) {
+               super.createControls(parent);
+       sashForm.setWeights(PRIVATE_SASH_WEIGHTS);
+               langTree.setVisible(false);
+       }
+
+       public void pathEntryStoreChanged(PathEntryStoreChangedEvent event) {
+               updateData(getResDesc());
+       }
+
+       @Override
+       public ICLanguageSettingEntry doAdd() {
+               IncludeDialog dlg = new IncludeDialog(
+                               usercomp.getShell(), IncludeDialog.NEW_FILE,
+                               Messages.LibraryTab_1,
+                               EMPTY_STR,
+                               getResDesc().getConfiguration(),
+                               0,
+                               ICSettingEntry.LIBRARY_FILE);
+               if (dlg.open() && dlg.text1.trim().length() > 0 ) {
+                       toAllCfgs = dlg.check1;
+                       toAllLang = dlg.check3;
+                       int flags = 0;
+                       if (dlg.check2) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
+                       return new CLibraryFileEntry(dlg.text1, flags);
+               }
+               return null;
+       }
+
+       @Override
+       public ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent) {
+               IncludeDialog dlg = new IncludeDialog(
+                               usercomp.getShell(), IncludeDialog.OLD_FILE,
+                               Messages.LibraryTab_2,
+                               ent.getValue(),
+                               getResDesc().getConfiguration(),
+                               ent.getFlags() & ICSettingEntry.VALUE_WORKSPACE_PATH,
+                               ICSettingEntry.LIBRARY_FILE);
+               if (dlg.open() && dlg.text1.trim().length() > 0 ) {
+                       int flags = 0;
+                       if (dlg.check2) flags = ICSettingEntry.VALUE_WORKSPACE_PATH;
+                       return new CLibraryFileEntry(dlg.text1, flags);
+               }
+               return null;
+       }
+       
+       @Override
+       public int getKind() { 
+               return ICSettingEntry.LIBRARY_FILE; 
+       }
+       
+       @Override
+       protected boolean isHeaderVisible() {
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigDialog.java
new file mode 100644 (file)
index 0000000..8ed8a84
--- /dev/null
@@ -0,0 +1,291 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.util.Arrays;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+
+import org.eclipse.cdt.core.model.util.CDTListComparator;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class ManageConfigDialog extends Dialog {
+       private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.ui.newCfgDialog"; //$NON-NLS-1$
+       public static final String ELEMENT_NAME = "dialog"; //$NON-NLS-1$
+       public static final String CLASS_NAME = "class"; //$NON-NLS-1$
+       public static final String TITLE_NAME = "title"; //$NON-NLS-1$
+       public static final String ID_NAME = "mbs_id"; //$NON-NLS-1$
+
+       // The list of configurations to delete
+       private ICProjectDescription des;
+       private IProject prj;
+       private String title;
+       private String mbs_id;
+       protected Table table;
+       
+       protected Button actBtn;
+       protected Button newBtn;
+       protected Button renBtn;
+       protected Button delBtn;
+
+       /**
+        * @param parentShell
+        */
+       ManageConfigDialog(Shell parentShell, String _title, IProject _prj) {
+               super(parentShell);
+               setShellStyle(getShellStyle() | SWT.RESIZE);
+               title = _title;
+               prj = _prj;
+       }
+
+       @Override
+       protected void configureShell(Shell shell) {
+               super.configureShell(shell);
+               if (title != null) shell.setText(title);
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected Control createDialogArea(Composite parent) {
+               Composite composite = new Composite(parent, SWT.NULL);
+               composite.setFont(parent.getFont());
+               composite.setLayout(new GridLayout(4, true));
+               composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+       
+               // Create the current config table
+               table = new Table(composite, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
+               GridData gd = new GridData(GridData.FILL_BOTH);
+               gd.horizontalSpan = 4;
+               table.setLayoutData(gd);
+               table.setHeaderVisible(true);
+               table.setLinesVisible(true);
+               
+               table.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               updateButtons();
+                       }});
+               
+               TableColumn col = new TableColumn(table, SWT.NONE);
+               col.setText(Messages.ManageConfigDialog_1); 
+               col.setWidth(100);
+               col = new TableColumn(table, SWT.NONE);
+               col.setText(Messages.ManageConfigDialog_2); 
+               col.setWidth(120);
+               col = new TableColumn(table, SWT.NONE);
+               col.setText(Messages.ManageConfigDialog_3); 
+               col.setWidth(80);
+
+               actBtn = new Button(composite, SWT.PUSH);
+               actBtn.setText(Messages.ManageConfigDialog_4); 
+               actBtn.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               actBtn.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               TableItem[] tis = table.getSelection();
+                               if (tis == null || tis.length != 1) return;
+                               ICConfigurationDescription cfgd = (ICConfigurationDescription)tis[0].getData();
+//                             cfgd.setActive();
+                               des.setActiveConfiguration(cfgd);
+                               updateData();
+                       }} ); 
+
+               newBtn = new Button(composite, SWT.PUSH);
+               newBtn.setText(Messages.BuildPropertyCommon_label_new);
+               newBtn.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               newBtn.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               handleNewPressed();
+                       }} ); 
+
+               delBtn = new Button(composite, SWT.PUSH);
+               delBtn.setText(Messages.BuildPropertyCommon_label_remove);
+               delBtn.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               delBtn.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               handleRemovePressed();
+                       }} ); 
+
+               renBtn = new Button(composite, SWT.PUSH);
+               renBtn.setText(Messages.ManageConfig_label_rename);
+               renBtn.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               renBtn.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               handleRenamePressed();
+                       }} ); 
+
+               des = CDTPropertyManager.getProjectDescription(composite, prj);
+//             comp = composite;
+               
+               updateData();
+       return composite;
+       }
+       /*
+        * Event handler for the add button
+        */
+       protected void handleNewPressed() {
+               INewCfgDialog dialog = handleSpecificMBS(mbs_id);
+               if (dialog == null) { // default (core) implementation.
+                       dialog = new NewConfigurationDialog(getShell());
+                       dialog.setTitle(Messages.ManageConfig_label_new_config_dialog);
+               }
+               dialog.setProject(des); 
+               if (dialog.open() == OK) updateData();
+       }
+       
+       /**
+        * Tries to load MBS-specific creation dialog a
+        * @return false if there's no such feature 
+        */
+       protected INewCfgDialog handleSpecificMBS(String id) {
+               IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
+                               .getExtensionPoint(EXTENSION_POINT_ID);
+               if (extensionPoint == null) return null;
+               IExtension[] extensions = extensionPoint.getExtensions();
+               if (extensions == null) return null;
+               for (int i = 0; i < extensions.length; ++i)     {
+                       IConfigurationElement[] elements = extensions[i].getConfigurationElements();
+                       for (int k = 0; k < elements.length; k++) {
+                               if (elements[k].getName().equals(ELEMENT_NAME)) {
+                                       if (! id.equals(elements[k].getAttribute(ID_NAME)))
+                                               continue;
+                                       INewCfgDialog dialog = null;
+                                       try {
+                                               dialog = (INewCfgDialog) elements[k].createExecutableExtension(CLASS_NAME);
+                                               dialog.setTitle(elements[k].getAttribute(TITLE_NAME));
+                                               dialog.setShell(getShell());
+                                               return dialog;
+                                       } catch (CoreException e) {
+                                               System.out.println("Cannot create dialog: " + e.getLocalizedMessage()); //$NON-NLS-1$
+                                               return null; 
+                                       }
+                               }                                       
+                       }
+               }
+               return null;
+       }
+       
+       /*
+        * (non-javadoc) Event handler for the rename button
+        */
+       protected void handleRenamePressed() {
+               int sel = table.getSelectionIndex();
+               if (sel != -1) {
+                       ICConfigurationDescription cfgd = (ICConfigurationDescription) table.getItem(sel).getData();
+                       RenameConfigurationDialog dialog = new RenameConfigurationDialog(
+                                       getShell(), cfgd, des.getConfigurations(),
+                                       Messages.ManageConfig_label_rename_config_dialog);
+                       if (dialog.open() == OK) {
+                               cfgd.setName(dialog.getNewName());
+                               cfgd.setDescription(dialog.getNewDescription());
+                               updateData();
+                       }
+               }
+       }
+
+       /*
+        * (non-javadoc) Event handler for the remove button
+        */
+       protected void handleRemovePressed() {
+               TableItem[] tis = table.getSelection();
+               if (tis == null || tis.length < 1) return;
+               String[] names = new String[tis.length];
+               for (int i=0; i<tis.length; i++) 
+                       names[i] = tis[i].getText(0);
+               // Get the confirmation from user before deleting the configuration
+               Shell shell = CUIPlugin.getActiveWorkbenchShell();
+               boolean shouldDelete = MessageDialog.openQuestion(shell,
+                       Messages.ManageConfig_deletedialog_title,
+                       NLS.bind(Messages.ManageConfig_deletedialog_message, names));
+               if (shouldDelete) {
+                       boolean wasActive = false;
+                       for (int j=0; j<tis.length; j++) {
+                               ICConfigurationDescription cfgd = (ICConfigurationDescription)tis[j].getData();
+                               if (cfgd.isActive()) wasActive = true; 
+                               des.removeConfiguration(cfgd);
+                               
+                       }
+                       ICConfigurationDescription[] cfgds = des.getConfigurations(); 
+                       if (wasActive && cfgds.length > 0) {
+                               cfgds[0].setActive();
+                               des.setActiveConfiguration(cfgds[0]);
+                       }
+                       updateData();
+               }
+       }
+
+       private void updateButtons() {
+               int sel = table.getSelectionCount();
+               delBtn.setEnabled(sel > 0 & sel < table.getItemCount());
+               renBtn.setEnabled(sel == 1);
+               if (sel == 1) {
+                       ICConfigurationDescription c = (ICConfigurationDescription)table.getSelection()[0].getData();
+                       actBtn.setEnabled(c != null && !c.isActive());
+               } else
+                       actBtn.setEnabled(false);
+       }
+
+       /**
+        * refresh configs table after changes
+        */
+       private void updateData() {
+               table.removeAll();
+               ICConfigurationDescription[] cfgds = des.getConfigurations();
+               mbs_id = cfgds[0].getBuildSystemId();
+               Arrays.sort(cfgds, CDTListComparator.getInstance());
+               for (int i=0; i<cfgds.length; i++ ) {
+                       TableItem t = new TableItem(table, 0);
+                       t.setText(0, cfgds[i].getName());
+                       t.setText(1, cfgds[i].getDescription());
+                       t.setText(2, cfgds[i].isActive() ? Messages.ManageConfigDialog_5 : ""); //$NON-NLS-1$ 
+                       t.setData(cfgds[i]);
+               }
+               if (table.getItemCount() > 0) table.select(0);
+               table.setFocus();
+               updateButtons();
+       }
+       
+       ICProjectDescription getProjectDescription(){
+               return des;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigRunner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigRunner.java
new file mode 100644 (file)
index 0000000..3f546e5
--- /dev/null
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui.newui;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class ManageConfigRunner implements IConfigManager {
+       private static final String MANAGE_TITLE = Messages.ManageConfigDialog_0;  
+
+       protected static ManageConfigRunner instance = null;
+       
+       private ICProjectDescription des = null;
+       private IProject prj = null;
+       
+       public static ManageConfigRunner getDefault() {
+               if (instance == null)
+                       instance = new ManageConfigRunner();
+               return instance;
+       }
+       
+       public boolean canManage(IProject[] obs) {
+               // Only one project can be accepted
+               return (obs != null && obs.length == 1);
+       }
+
+       public boolean manage(IProject[] obs, boolean doOk) {
+               if (!canManage(obs))
+                       return false;
+               
+               ManageConfigDialog d = new ManageConfigDialog(Display.getDefault().getActiveShell(),
+                               obs[0].getName()+ ": " + MANAGE_TITLE, obs[0]); //$NON-NLS-1$
+               boolean result = false;
+               if (d.open() == Window.OK) {
+                       if (doOk) {
+                               des = d.getProjectDescription();
+                               prj = obs[0];
+                               if(des != null) 
+                                       try {
+                                               PlatformUI.getWorkbench().getProgressService().run(false, false, getRunnable());
+                                       } catch (InvocationTargetException e) {}
+                                         catch (InterruptedException e) {}
+                       }
+                       AbstractPage.updateViews(obs[0]);
+                       result = true;
+               } else if (doOk) {
+                       CDTPropertyManager.performCancel(d.getShell());
+               }
+               return result;
+       }
+       
+       public IRunnableWithProgress getRunnable() {
+               return new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() {
+                       public void run(IProgressMonitor imonitor) throws InvocationTargetException, InterruptedException {
+                               CUIPlugin.getDefault().getShell().getDisplay().syncExec(new Runnable() {
+                                       public void run() {
+                                               try {
+                                                       CoreModel.getDefault().setProjectDescription(prj, des);
+                                               } catch (CoreException e) {
+                                                       e.printStackTrace();
+                                               }
+                                       }
+                               });
+                       }
+               });
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigSelector.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ManageConfigSelector.java
new file mode 100644 (file)
index 0000000..8295c4e
--- /dev/null
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui.newui;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+
+import org.eclipse.cdt.internal.ui.cview.IncludeRefContainer;
+import org.eclipse.cdt.internal.ui.cview.IncludeReferenceProxy;
+
+/**
+ * This class provides static methods to work with multiple
+ * implementors of "ConfigManager" extension point.
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ */
+public class ManageConfigSelector {
+       private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.ui.ConfigManager"; //$NON-NLS-1$
+       public static final String ELEMENT_NAME = "manager"; //$NON-NLS-1$
+       public static final String CLASS_NAME = "class"; //$NON-NLS-1$
+       private static IConfigManager[] mgrs = null;
+
+       /**
+        * Searches for IConfigManager which
+        * can process given projects.
+        * 
+        * @param obs - list of projects to handle
+        * @return first matching ConfigManager
+        */
+       public static IConfigManager getManager(IProject[] obs) {
+               readMgrs();
+               if (mgrs == null)
+                       return null;
+               for (int i=0; i<mgrs.length; i++) {
+                       if (mgrs[i].canManage(obs))
+                               return mgrs[i];
+               }
+               return null;
+       }
+       
+       /**
+        * Searches for IConfigManager which
+        * can process given objects.
+        * 
+        * @param obs - "raw" array of objects
+        * @return first matching ConfigManager
+        */
+       public static IConfigManager getManagerFor(Object[] obs) {
+               return getManager(getProjects(obs));
+       }               
+       
+       /**
+        * Filters "raw" objects array
+        * 
+        * @param obs - objects to filter
+        * @return array with only new-style projects included
+        */
+       public static IProject[] getProjects(Object[] obs) {
+               ArrayList<IProject> lst = new ArrayList<IProject>();
+               if (obs != null) {
+                       for (Object ob : obs) {
+                               IProject prj = null;
+                               // Extract project from selection 
+                               if (ob instanceof ICElement) { // for C/C++ view
+                                       prj = ((ICElement)ob).getCProject().getProject();
+                               } else if (ob instanceof IResource) { // for other views
+                                       prj = ((IResource)ob).getProject();
+                               /* get project from Include folder elements */
+                               } else if (ob instanceof IncludeRefContainer) {
+                                       ICProject fCProject = ((IncludeRefContainer)ob).getCProject();
+                                       if (fCProject != null)
+                                               prj = fCProject.getProject();
+                               } else if (ob instanceof IncludeReferenceProxy) {
+                                       IncludeRefContainer irc = ((IncludeReferenceProxy)ob).getIncludeRefContainer();
+                                       if (irc != null) {
+                                               ICProject fCProject = irc.getCProject();
+                                               if (fCProject != null)
+                                                       prj = fCProject.getProject();
+                                       }
+                               } 
+
+                               if (prj == null || lst.contains(prj) ||
+                                       !CoreModel.getDefault().isNewStyleProject(prj))
+                                               continue;
+                               lst.add(prj);
+                       }
+               }
+               return lst.toArray(new IProject[lst.size()]);
+       }
+
+       private static void readMgrs() {
+               if (mgrs != null)
+                       return;
+
+               IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_ID);
+               if (extensionPoint == null) 
+                       return;
+
+               IExtension[] extensions = extensionPoint.getExtensions();
+               if (extensions == null) 
+                       return;
+
+               ArrayList<IConfigManager> list = new ArrayList<IConfigManager>();
+               for (int i = 0; i < extensions.length; ++i)     {
+                       IConfigurationElement[] elements = extensions[i].getConfigurationElements();
+                       for (int k = 0; k < elements.length; k++) {
+                               if (elements[k].getName().equals(ELEMENT_NAME)) {
+                                       IConfigManager cm = null;
+                                       try {
+                                               cm = (IConfigManager) elements[k].createExecutableExtension(CLASS_NAME);
+                                       } catch (CoreException e) {
+                                       }
+                                       if (cm != null)
+                                               list.add(cm);
+                               }
+                       }
+               }
+               list.add(ManageConfigRunner.getDefault()); // Default manager
+               mgrs = list.toArray(new IConfigManager[list.size()]);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/MultiCfgContributedEnvironment.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/MultiCfgContributedEnvironment.java
new file mode 100644 (file)
index 0000000..3615006
--- /dev/null
@@ -0,0 +1,197 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *     IBM Corporation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.util.Comparator;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.envvar.IContributedEnvironment;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICMultiConfigDescription;
+import org.eclipse.cdt.core.settings.model.MultiItemsHolder;
+
+import org.eclipse.cdt.internal.core.envvar.ContributedEnvironment;
+
+/**
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class MultiCfgContributedEnvironment implements IContributedEnvironment {
+       private static final IContributedEnvironment ice = CCorePlugin.getDefault().getBuildEnvironmentManager().getContributedEnvironment();
+       private boolean isMulti = false;
+       private ICConfigurationDescription[] mono = new ICConfigurationDescription[1];
+       private static final EnvCmp comparator = new EnvCmp(); 
+       
+       private static class EnvCmp implements Comparator<Object> {
+               
+               public int compare(Object a0, Object a1) {
+                       if (a0 == null || a1 == null)
+                               return 0;
+                       if (a0 instanceof IEnvironmentVariable &&
+                               a1 instanceof IEnvironmentVariable) {
+                               IEnvironmentVariable x0 = (IEnvironmentVariable)a0;
+                               IEnvironmentVariable x1 = (IEnvironmentVariable)a1;
+                               String s0 = x0.getName();
+                               if (s0 == null)
+                                       s0 = AbstractPage.EMPTY_STR;
+                               String s1 = x1.getName();
+                               if (s1 == null)
+                                       s1 = AbstractPage.EMPTY_STR;
+                               return(s0.compareTo(s1));
+                       }
+                       return 0;
+               }
+       }
+       
+       public void setMulti(boolean val) {
+               isMulti = val;
+       }
+       
+       public IEnvironmentVariable addVariable(String name, String value,
+                       int op, String delimiter, ICConfigurationDescription des) {
+               IEnvironmentVariable v = null;
+               for (ICConfigurationDescription c : getCfs(des))
+                       v = ice.addVariable(name, value, op, delimiter, c);
+               doReplace(des);
+               return v;
+       }
+
+       private void doReplace(ICConfigurationDescription des) {
+               if (isMulti && ! isModifyMode()) { 
+                       IEnvironmentVariable[] vars = getVariables(des);
+                       for (int i=0; i<vars.length; i++)
+                               if (! ice.isUserVariable(des, vars[i]))
+                                       vars[i] = null;
+                       for (ICConfigurationDescription c : getCfs(des)) {
+                               ice.restoreDefaults(c);
+                               for (IEnvironmentVariable v : vars)
+                                       if (v != null)
+                                               ice.addVariable(v, c);
+                       }
+               }
+       }
+       
+       public boolean appendEnvironment(ICConfigurationDescription des) {
+               for (ICConfigurationDescription c : getCfs(des))
+                       if (! ice.appendEnvironment(c))
+                               return false;
+               return true;
+       }
+
+       public IEnvironmentVariable getVariable(String name,
+                       ICConfigurationDescription des) {
+               if (!isMulti)
+                       return ice.getVariable(name, des);
+               // should we show ANY vars, even if they exist not in all cfgs ? 
+               boolean any = (getDispMode(des) == CDTPrefUtil.DMODE_DISJUNCTION);      
+               ICConfigurationDescription[] cfs = getCfs(des);
+               IEnvironmentVariable v = ice.getVariable(name, cfs[0]);
+               // if ((any && v != null) || (! any && v == null))
+               if (any ^ (v == null))
+                       return v;
+               for (int i=1; i<cfs.length; i++) {
+                       IEnvironmentVariable w = ice.getVariable(name, cfs[i]);
+                       if (any && (w != null))
+                               return w;
+                       // if (! any  &&  ! v==w)
+                       if (! (any || (v==null && w==null) || (v != null && v.equals(w))))
+                               return null;
+               }
+               return v;
+       }
+
+       public IEnvironmentVariable[] getVariables(
+                       ICConfigurationDescription des) {
+               if (!isMulti)
+                       return ice.getVariables(des);
+               ICConfigurationDescription[] cfs = getCfs(des);
+               IEnvironmentVariable[][] evs = new IEnvironmentVariable[cfs.length][];
+               int i = 0;
+               for (ICConfigurationDescription c : cfs)
+                        evs[i++] = ice.getVariables(c);
+               
+               Object[] obs = CDTPrefUtil.getListForDisplay(evs, comparator); 
+               IEnvironmentVariable[] ev = new IEnvironmentVariable[obs.length];
+               System.arraycopy(obs, 0, ev, 0, obs.length);
+               return ev;
+                          
+       }
+
+       public boolean isUserVariable(ICConfigurationDescription des,
+                       IEnvironmentVariable var) {
+               for (ICConfigurationDescription c : getCfs(des))
+                       if (! ice.isUserVariable(c, var))
+                               return false;
+               return true; // only if for each cfg
+       }
+
+       public IEnvironmentVariable removeVariable(String name,
+                       ICConfigurationDescription des) {
+               IEnvironmentVariable res = null;
+               for (ICConfigurationDescription c : getCfs(des))
+                       res = ice.removeVariable(name, c);
+               doReplace(des);
+               return res;
+       }
+
+       public void restoreDefaults(ICConfigurationDescription des) {
+               for (ICConfigurationDescription c : getCfs(des))
+                       ice.restoreDefaults(c);
+       }
+
+       public void setAppendEnvironment(boolean append,ICConfigurationDescription des) {
+               for (ICConfigurationDescription c : getCfs(des))
+                       ice.setAppendEnvironment(append, c);
+       }
+       
+       private ICConfigurationDescription[] getCfs(ICConfigurationDescription des) {
+               if (isMulti && des instanceof ICMultiConfigDescription) {
+                       return (ICConfigurationDescription[])((ICMultiConfigDescription)des).getItems();
+               }
+               mono[0] = des;
+               return mono;
+       }
+       
+       private int getDispMode(ICConfigurationDescription des) {
+               if (isMulti && des instanceof MultiItemsHolder)
+                       return CDTPrefUtil.getMultiCfgStringListDisplayMode();
+               return 0;       
+       }
+       
+       private boolean isModifyMode() {
+               int wmode = CDTPrefUtil.getMultiCfgStringListWriteMode();
+               return (wmode == CDTPrefUtil.WMODE_MODIFY);
+       }
+
+       public IEnvironmentVariable addVariable(IEnvironmentVariable var,
+                       ICConfigurationDescription des) {
+               IEnvironmentVariable v = null;
+               for (ICConfigurationDescription c : getCfs(des))
+                       v = ice.addVariable(var, c);
+               doReplace(des);
+               return v;
+       }
+
+       public void addVariables(IEnvironmentVariable[] vars,
+                       ICConfigurationDescription des) {
+               for (ICConfigurationDescription c : getCfs(des))
+                       ice.addVariables(vars, c);
+               doReplace(des);
+       }
+       
+       public String getOrigin(IEnvironmentVariable var) {
+               if (ice instanceof ContributedEnvironment)
+                       return ((ContributedEnvironment)ice).getOrigin(var);
+               return AbstractPage.EMPTY_STR;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/MultiLineTextFieldEditor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/MultiLineTextFieldEditor.java
new file mode 100644 (file)
index 0000000..1604fc8
--- /dev/null
@@ -0,0 +1,559 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 BitMethods Inc and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BitMethods Inc - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ *     MultiLineTextFieldEditor.
+ *     Field editor that is same as string field editor but 
+ *     will have the multi line text field for user input.
+ *
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class MultiLineTextFieldEditor extends FieldEditor {
+       
+       /**
+        * Validation strategy constant (value <code>0</code>) indicating that
+        * the editor should perform validation after every key stroke.
+        *
+        * @see #setValidateStrategy
+        */
+       public static final int VALIDATE_ON_KEY_STROKE = 0;
+
+       /**
+        * Validation strategy constant (value <code>1</code>) indicating that
+        * the editor should perform validation only when the text widget 
+        * loses focus.
+        *
+        * @see #setValidateStrategy
+        */
+       public static final int VALIDATE_ON_FOCUS_LOST = 1;
+
+       /**
+        * Text limit constant (value <code>-1</code>) indicating unlimited
+        * text limit and width.
+        */
+       public static int UNLIMITED = -1;
+
+       /**
+        * Cached valid state.
+        */
+       private boolean isValid;
+
+       /**
+        * Old text value.
+        */
+       private String oldValue;
+       private String compTitle;
+       private Label title;
+
+       /**
+        * The text field, or <code>null</code> if none.
+        */
+       private Text textField;
+
+       /**
+        * Text limit of text field in characters; initially unlimited.
+        */
+       private int textLimit = UNLIMITED;
+
+       /**
+        * The error message, or <code>null</code> if none.
+        */
+       private String errorMessage;
+
+       /**
+        * Indicates whether the empty string is legal;
+        * <code>true</code> by default.
+        */
+       private boolean emptyStringAllowed = true;
+
+       /**
+        * The validation strategy; 
+        * <code>VALIDATE_ON_KEY_STROKE</code> by default.
+        */
+       private int validateStrategy = VALIDATE_ON_KEY_STROKE;
+       /**
+        * Creates a new string field editor 
+        */
+       protected MultiLineTextFieldEditor() {
+       }
+       /**
+        * Creates a string field editor.
+        * Use the method <code>setTextLimit</code> to limit the text.
+        * 
+        * @param name the name of the preference this field editor works on
+        * @param labelText the label text of the field editor
+        * @param width the width of the text input field in characters,
+        *  or <code>UNLIMITED</code> for no limit
+        * @param strategy either <code>VALIDATE_ON_KEY_STROKE</code> to perform
+        *  on the fly checking (the default), or <code>VALIDATE_ON_FOCUS_LOST</code> to
+        *  perform validation only after the text has been typed in
+        * @param parent the parent of the field editor's control
+        * @since 2.0
+        */
+       public MultiLineTextFieldEditor(
+               String name,
+               String labelText,
+               int width,
+               int strategy,
+               Composite parent) {
+               init(name, labelText);
+               setValidateStrategy(strategy);
+               isValid = false;
+               errorMessage = Messages.Multiline_error_message;
+               createControl(parent);
+       }
+       
+       /**
+        * Creates a string field editor.
+        * Use the method <code>setTextLimit</code> to limit the text.
+        * 
+        * @param name the name of the preference this field editor works on
+        * @param labelText the label text of the field editor
+        * @param width the width of the text input field in characters,
+        *  or <code>UNLIMITED</code> for no limit
+        * @param parent the parent of the field editor's control
+        */
+       public MultiLineTextFieldEditor(String name, String labelText, int width, Composite parent) {
+               this(name, labelText, width, VALIDATE_ON_KEY_STROKE, parent);
+               this.compTitle = labelText;
+       }
+       /**
+        * Creates a string field editor of unlimited width.
+        * Use the method <code>setTextLimit</code> to limit the text.
+        * 
+        * @param name the name of the preference this field editor works on
+        * @param labelText the label text of the field editor
+        * @param parent the parent of the field editor's control
+        */
+       public MultiLineTextFieldEditor(String name, String labelText, Composite parent) {              
+               this(name, labelText, UNLIMITED, parent);
+       }
+
+       /**
+        * Adjusts the horizontal span of this field editor's basic controls 
+        * <p>
+        * Subclasses must implement this method to adjust the horizontal span
+        * of controls so they appear correct in the given number of columns.
+        * </p>
+        * <p>
+        * The number of columns will always be equal to or greater than the
+        * value returned by this editor's <code>getNumberOfControls</code> method.
+        * 
+        * @param numColumns the number of columns
+        */
+       @Override
+       protected void adjustForNumColumns(int numColumns) {
+               GridData gd = (GridData) textField.getLayoutData();
+               gd.horizontalSpan = numColumns - 1;
+               // We only grab excess space if we have to
+               // If another field editor has more columns then
+               // we assume it is setting the width.
+               gd.grabExcessHorizontalSpace = gd.horizontalSpan == 1;
+       }
+       /**
+        * Checks whether the text input field contains a valid value or not.
+        *
+        * @return <code>true</code> if the field value is valid,
+        *   and <code>false</code> if invalid
+        */
+       protected boolean checkState() {
+               boolean result = false;
+               if (emptyStringAllowed)
+                       result = true;
+
+               if (textField == null)
+                       result = false;
+
+               String txt = textField.getText();
+
+               if (txt == null) {
+                       result = false;
+               }
+               else {
+                       result = (txt.trim().length() > 0) || emptyStringAllowed;
+               }
+
+               // call hook for subclasses
+               result = result && doCheckState();
+
+               if (result)
+                       clearErrorMessage();
+               else
+                       showErrorMessage(errorMessage);
+
+               return result;
+       }
+       /**
+        * Hook for subclasses to do specific state checks.
+        * <p>
+        * The default implementation of this framework method does
+        * nothing and returns <code>true</code>.  Subclasses should 
+        * override this method to specific state checks.
+        * </p>
+        *
+        * @return <code>true</code> if the field value is valid,
+        *   and <code>false</code> if invalid
+        */
+       protected boolean doCheckState() {
+               return true;
+       }
+       /**
+        * Fills this field editor's basic controls into the given parent.
+        * <p>
+        * The string field implementation of this <code>FieldEditor</code>
+        * framework method contributes the text field. Subclasses may override
+        * but must call <code>super.doFillIntoGrid</code>.
+        * </p>
+        */
+       @Override
+       protected void doFillIntoGrid(Composite parent, int numColumns) {
+
+               title = new Label(parent, SWT.UP);
+               title.setFont(parent.getFont());
+               this.compTitle = getLabelText();
+               title.setText(this.compTitle);
+               title.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+
+               textField = getTextControl(parent);
+               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.widthHint = 100;
+               gd.heightHint = 70;
+               textField.setLayoutData(gd);
+
+       }
+       
+       /**
+        * Initializes this field editor with the preference value from
+        * the preference store.
+        * <p>
+        * Subclasses must implement this method to properly initialize
+        * the field editor.
+        * </p>
+        */
+       @Override
+       protected void doLoad() {
+               if (textField != null) {
+                       String value = getPreferenceStore().getString(getPreferenceName());
+                       textField.setText(value);
+                       oldValue = value;
+               }
+       }
+       
+       /**
+        * Initializes this field editor with the default preference value from
+        * the preference store.
+        * <p>
+        * Subclasses must implement this method to properly initialize
+        * the field editor.
+        * </p>
+        */
+       @Override
+       protected void doLoadDefault() {
+               if (textField != null) {
+                       String value =
+                               getPreferenceStore().getDefaultString(getPreferenceName());
+                       textField.setText(value);
+               }
+               valueChanged();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.preference.FieldEditor#doStore()
+        */
+       @Override
+       protected void doStore() {
+               getPreferenceStore().setValue(getPreferenceName(), textField.getText());
+       }
+       
+       /**
+        * Returns the error message that will be displayed when and if 
+        * an error occurs.
+        *
+        * @return the error message, or <code>null</code> if none
+        */
+       public String getErrorMessage() {
+               return errorMessage;
+       }
+       /**
+               * Returns the number of basic controls this field editor consists of.
+               *
+               * @return the number of controls
+               */
+       @Override
+       public int getNumberOfControls() {
+               return 2;
+       }
+       /**
+        * Returns the field editor's value.
+        *
+        * @return the current value
+        */
+       public String getStringValue() {
+               if (textField != null)
+                       return textField.getText();
+               return getPreferenceStore().getString(getPreferenceName());
+       }
+       
+       /**
+        * Returns this field editor's text control.
+        * @return the text control, or <code>null</code> if no
+        * text field is created yet
+        */
+       protected Text getTextControl() {
+               return textField;
+       }
+       
+       /**
+        * Returns this field editor's text control.
+        * <p>
+        * The control is created if it does not yet exist
+        * </p>
+        *
+        * @param parent the parent
+        * @return the text control
+        */
+       public Text getTextControl(Composite parent) {
+               if (textField == null) {
+                       textField =
+                               new Text(
+                                       parent,
+                                       SWT.MULTI | SWT.V_SCROLL | SWT.BORDER | SWT.WRAP);
+                       textField.setFont(parent.getFont());
+                       switch (validateStrategy) {
+                               case VALIDATE_ON_KEY_STROKE :
+                                       textField.addKeyListener(new KeyAdapter() {
+                                               @Override
+                                               public void keyPressed(KeyEvent e) {
+                                                       valueChanged();
+                                               }
+                                       });
+
+                                       textField.addFocusListener(new FocusAdapter() {
+                                               @Override
+                                               public void focusGained(FocusEvent e) {
+                                                       refreshValidState();
+                                               }
+                                               @Override
+                                               public void focusLost(FocusEvent e) {
+                                                       clearErrorMessage();
+                                               }
+                                       });
+                                       break;
+                               case VALIDATE_ON_FOCUS_LOST :
+                                       textField.addKeyListener(new KeyAdapter() {
+                                               @Override
+                                               public void keyPressed(KeyEvent e) {
+                                                       clearErrorMessage();
+                                               }
+                                       });
+                                       textField.addFocusListener(new FocusAdapter() {
+                                               @Override
+                                               public void focusGained(FocusEvent e) {
+                                                       refreshValidState();
+                                               }
+                                               @Override
+                                               public void focusLost(FocusEvent e) {
+                                                       valueChanged();
+                                                       clearErrorMessage();
+                                               }
+                                       });
+                                       break;
+                               default :
+                       }
+                       textField.addDisposeListener(new DisposeListener() {
+                               public void widgetDisposed(DisposeEvent event) {
+                                       textField = null;
+                               }
+                       });
+                       if (textLimit > 0) { //Only set limits above 0 - see SWT spec
+                               textField.setTextLimit(textLimit);
+                       }
+               } else {
+                       checkParent(textField, parent);
+               }
+               return textField;
+       }
+       
+       /**
+        * Returns whether an empty string is a valid value.
+        *
+        * @return <code>true</code> if an empty string is a valid value, and
+        *  <code>false</code> if an empty string is invalid
+        * @see #setEmptyStringAllowed
+        */
+       public boolean isEmptyStringAllowed() {
+               return emptyStringAllowed;
+       }
+       
+       /**
+        * Returns whether this field editor contains a valid value.
+        * <p>
+        * The default implementation of this framework method
+        * returns <code>true</code>. Subclasses wishing to perform
+        * validation should override both this method and
+        * <code>refreshValidState</code>.
+        * </p>
+        * 
+        * @return <code>true</code> if the field value is valid,
+        * and <code>false</code> if invalid
+        * @see #refreshValidState
+        */
+       @Override
+       public boolean isValid() {
+               return isValid;
+       }
+       
+       /**
+        * Refreshes this field editor's valid state after a value change
+        * and fires an <code>IS_VALID</code> property change event if
+        * warranted.
+        * <p>
+        * The default implementation of this framework method does
+        * nothing. Subclasses wishing to perform validation should override
+        * both this method and <code>isValid</code>.
+        * </p>
+        */
+       @Override
+       protected void refreshValidState() {
+               isValid = checkState();
+       }
+       
+       /**
+        * Sets whether the empty string is a valid value or not.
+        *
+        * @param b <code>true</code> if the empty string is allowed,
+        *  and <code>false</code> if it is considered invalid
+        */
+       public void setEmptyStringAllowed(boolean b) {
+               emptyStringAllowed = b;
+       }
+       
+       /**
+        * Sets the error message that will be displayed when and if 
+        * an error occurs.
+        *
+        * @param message the error message
+        */
+       public void setErrorMessage(String message) {
+               errorMessage = message;
+       }
+       
+       /**
+        * Sets the focus to this field editor.
+        * <p>
+        * The default implementation of this framework method
+        * does nothing. Subclasses may reimplement.
+        * </p>
+       */
+       @Override
+       public void setFocus() {
+               if (textField != null) {
+                       textField.setFocus();
+               }
+       }
+       
+       /**
+        * Sets this field editor's value.
+        *
+        * @param value the new value, or <code>null</code> meaning the empty string
+        */
+       public void setStringValue(String value) {
+               if (textField != null) {
+                       if (value == null)
+                               value = ""; //$NON-NLS-1$
+                       oldValue = textField.getText();
+                       if (!oldValue.equals(value)) {
+                               textField.setText(value);
+                               valueChanged();
+                       }
+               }
+       }
+       
+       /**
+        * Sets this text field's text limit.
+        *
+        * @param limit the limit on the number of character in the text
+        *  input field, or <code>UNLIMITED</code> for no limit
+        */
+       public void setTextLimit(int limit) {
+               textLimit = limit;
+               if (textField != null)
+                       textField.setTextLimit(limit);
+       }
+       
+       /**
+        * Sets the strategy for validating the text.
+        * <p>
+        * Calling this method has no effect after <code>createPartControl</code>
+        * is called. Thus this method is really only useful for subclasses to call
+        * in their constructor. However, it has public visibility for backward 
+        * compatibility.
+        * </p>
+        *
+        * @param value either <code>VALIDATE_ON_KEY_STROKE</code> to perform
+        *  on the fly checking (the default), or <code>VALIDATE_ON_FOCUS_LOST</code> to
+        *  perform validation only after the text has been typed in
+        */
+       public void setValidateStrategy(int value) {
+               Assert.isTrue(
+                       value == VALIDATE_ON_FOCUS_LOST || value == VALIDATE_ON_KEY_STROKE);
+               validateStrategy = value;
+       }
+       
+       /**
+        * Shows the error message set via <code>setErrorMessage</code>.
+        */
+       public void showErrorMessage() {
+               showErrorMessage(errorMessage);
+       }
+       
+       /**
+        * Informs this field editor's listener, if it has one, about a change
+        * to the value (<code>VALUE</code> property) provided that the old and
+        * new values are different.
+        * <p>
+        * This hook is <em>not</em> called when the text is initialized 
+        * (or reset to the default value) from the preference store.
+        * </p>
+        */
+       protected void valueChanged() {
+               setPresentsDefaultValue(false);
+               boolean oldState = isValid;
+               refreshValidState();
+
+               if (isValid != oldState)
+                       fireStateChanged(IS_VALID, oldState, isValid);
+
+               String newValue = textField.getText();
+               if (!newValue.equals(oldValue)) {
+                       fireValueChanged(VALUE, oldValue, newValue);
+                       oldValue = newValue;
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/NewConfigurationDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/NewConfigurationDialog.java
new file mode 100644 (file)
index 0000000..2dbe75a
--- /dev/null
@@ -0,0 +1,377 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.preference.JFacePreferences;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class NewConfigurationDialog extends Dialog implements INewCfgDialog {
+       // Widgets
+       private Text configName;
+       private Text configDescription;
+       private Combo cloneConfigSelector;
+       private Label statusLabel;
+
+       /** Default configurations defined in the toolchain description */
+       private ICProjectDescription des;
+       private ICConfigurationDescription[] cfgds;
+       private ICConfigurationDescription parentConfig; 
+       private String newName;
+       private String newDescription;
+       private String title;
+
+       
+       /**
+        */
+       protected NewConfigurationDialog(Shell parentShell) {
+               super(parentShell);
+               setShellStyle(getShellStyle()|SWT.RESIZE);
+               newName = new String();
+               newDescription = new String();
+       }
+       
+       public void setProject(ICProjectDescription prj) {
+               des = prj;
+               cfgds = des.getConfigurations();
+       }
+
+       public void setTitle(String _title) {
+               title = _title;
+       }
+       
+       /* (non-Javadoc)
+        * Method declared on Dialog. Cache the name and base config selections.
+        * We don't have to worry that the index or name is wrong because we 
+        * enable the OK button IFF those conditions are met.
+        */
+       @Override
+       protected void buttonPressed(int buttonId) {
+               if (buttonId == IDialogConstants.OK_ID) {
+                       String description = new String();
+                       String nameAndDescription = new String();
+                       String baseConfigNameAndDescription = new String();
+                       
+                       newName = configName.getText().trim();
+                       newDescription = configDescription.getText().trim();
+                       
+                       baseConfigNameAndDescription = cloneConfigSelector.getItem(cloneConfigSelector.getSelectionIndex());                            
+                       for (int i = 0; i < cfgds.length; i++) {
+                               description = cfgds[i].getDescription();
+                                       
+                               if( (description == null) || (description.equals("")) ){        //$NON-NLS-1$
+                                       nameAndDescription = cfgds[i].getName();
+                               } else {
+                                       nameAndDescription = cfgds[i].getName() + "( " + description + " )";    //$NON-NLS-1$   //$NON-NLS-2$
+                               }
+                               if (nameAndDescription.equals(baseConfigNameAndDescription)) {
+                                       parentConfig = cfgds[i];
+                                       break;                          
+                               }
+                       }
+                       newConfiguration();
+               } else {
+                       newName = null;
+                       newDescription = null;
+                       parentConfig = null;
+               }
+               super.buttonPressed(buttonId);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+        */
+       @Override
+       protected void configureShell(Shell shell) {
+               super.configureShell(shell);
+               if (title != null)
+                       shell.setText(title);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected void createButtonsForButtonBar(Composite parent) {
+               super.createButtonsForButtonBar(parent);
+               configName.setFocus();
+               if (configName != null) {
+                       configName.setText(newName);
+               }
+               validateState();
+       }
+
+       @Override
+       protected Control createDialogArea(Composite parent) {
+               Composite composite = new Composite(parent, SWT.NULL);
+               composite.setFont(parent.getFont());
+               composite.setLayout(new GridLayout(3, false));
+               composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+               // Create a group for the name & description
+
+               final Group group1 = new Group(composite, SWT.NONE);
+               group1.setFont(composite.getFont());
+               GridLayout layout1 = new GridLayout(3, false);
+               group1.setLayout(layout1);
+               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = 3;
+               group1.setLayoutData(gd);
+
+               // bug 187634: Add a label to warn user that configuration name will be used directly
+               // as a directory name in the filesystem.
+               Label warningLabel = new Label(group1, SWT.BEGINNING | SWT.WRAP);
+               warningLabel.setFont(parent.getFont());
+               warningLabel.setText(Messages.NewConfiguration_label_warning); 
+               gd = new GridData(SWT.FILL, SWT.BEGINNING, true, false, 3, 1);
+               gd.widthHint = 300;
+               warningLabel.setLayoutData(gd);
+               
+               // Add a label and a text widget for Configuration's name
+               final Label nameLabel = new Label(group1, SWT.LEFT);
+               nameLabel.setFont(parent.getFont());
+               nameLabel.setText(Messages.NewConfiguration_label_name);
+                               
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = 1;
+               gd.grabExcessHorizontalSpace = false;
+               nameLabel.setLayoutData(gd);
+
+               configName = new Text(group1, SWT.SINGLE | SWT.BORDER);
+               configName.setFont(group1.getFont());
+               configName.setText(getNewName());
+               configName.setFocus();
+               gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+               gd.horizontalSpan = 2;
+               gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
+               configName.setLayoutData(gd);
+               configName.addModifyListener(new ModifyListener() {
+                       public void modifyText(ModifyEvent e) {
+                               validateState();
+                       }
+               });
+               
+//              Add a label and a text widget for Configuration's description
+        final Label descriptionLabel = new Label(group1, SWT.LEFT);
+        descriptionLabel.setFont(parent.getFont());
+        descriptionLabel.setText(Messages.NewConfiguration_label_description);
+
+        gd = new GridData(GridData.FILL_HORIZONTAL);
+        gd.horizontalSpan = 1;
+               gd.grabExcessHorizontalSpace = false;
+        descriptionLabel.setLayoutData(gd);
+        configDescription = new Text(group1, SWT.SINGLE | SWT.BORDER);
+        configDescription.setFont(group1.getFont());
+               configDescription.setText(getNewDescription());
+               configDescription.setFocus();
+               
+        gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+        gd.horizontalSpan = 2;
+        gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
+        configDescription.setLayoutData(gd);
+               
+               final Group group = new Group(composite, SWT.NONE);
+               group.setFont(composite.getFont());
+               group.setText(Messages.NewConfiguration_label_group);
+               GridLayout layout = new GridLayout(1, false);
+               group.setLayout(layout);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = 3;
+               group.setLayoutData(gd);
+
+               cloneConfigSelector = new Combo(group, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
+               cloneConfigSelector.setFont(group.getFont());
+               cloneConfigSelector.setItems(getDefinedConfigNamesAndDescriptions());
+               int index = cloneConfigSelector.indexOf(newName);
+               cloneConfigSelector.select(index < 0 ? 0 : index);
+               gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+               cloneConfigSelector.setLayoutData(gd);
+               cloneConfigSelector.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               validateState();                
+                       }
+               });     
+
+               statusLabel = new Label(composite, SWT.CENTER);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = 3;
+               statusLabel.setLayoutData(gd);
+               statusLabel.setFont(composite.getFont());
+               statusLabel.setForeground(JFaceResources.getColorRegistry().get(JFacePreferences.ERROR_COLOR));
+
+               return composite;
+       }
+
+
+       /*
+        * Returns the array of configuration names defined for this managed project.
+        * This list will be used to populate the list of configurations to 
+        * clone.
+        */
+       private String [] getDefinedConfigNamesAndDescriptions() {
+               String [] namesAndDescriptions = new String[cfgds.length];
+               for (int i = 0; i < cfgds.length; ++i) {
+                       if ( (cfgds[i].getDescription() == null) || cfgds[i].getDescription().equals(""))       //$NON-NLS-1$
+                               namesAndDescriptions[i] = cfgds[i].getName();
+                       else
+                               namesAndDescriptions[i] = cfgds[i].getName() + "( " + cfgds[i].getDescription() +" )";  //$NON-NLS-1$   //$NON-NLS-2$
+               }
+               return namesAndDescriptions; 
+       }
+
+       /**
+        * @return <code>String</code> containing the name chosen by the user for the
+        * new configuration.
+        */
+       public String getNewName() {
+               return newName;
+       }
+       
+       protected boolean isDuplicateName(String newName) {
+               for (int i = 0; i < cfgds.length; i++) {
+                       if (cfgds[i].getName().equals(newName)) 
+                               return true;
+               }
+               return false;
+       }
+
+       protected boolean isSimilarName(String newName) {
+               for (int i = 0; i < cfgds.length; i++) {
+                       if (cfgds[i].getName().equalsIgnoreCase(newName))
+                               return true;
+               }
+               return false;
+       }
+
+       /* (non-Javadoc)
+        * Checks the argument for leading whitespaces and invalid directory name characters. 
+        * @param name
+        * @return <I>true</i> is the name is a valid directory name with no whitespaces
+        */
+       private boolean validateName(String name) {
+               // Names must be at least one character in length
+               if (name.trim().length() == 0)
+                       return false;
+               
+               // Iterate over the name checking for bad characters
+               char[] chars = name.toCharArray();
+               // No whitespaces at the start of a name
+               if (Character.isWhitespace(chars[0])) {
+                       return false;
+               }
+               for (int index = 0; index < chars.length; ++index) {
+                       // Config name must be a valid dir name too, so we ban "\ / : * ? " < >" in the names
+                       if (!Character.isLetterOrDigit(chars[index])) {
+                               switch (chars[index]) {
+                               case '/':
+                               case '\\':
+                               case ':':
+                               case '*':
+                               case '?':
+                               case '\"':
+                               case '<':
+                               case '>':
+                                       return false;
+                               default:
+                                       break;
+                               }
+                       }
+               }
+               return true;
+       }
+       /* (non-Javadoc)
+        * Update the status message and button state based on the input selected
+        * by the user
+        * 
+        */
+       private void validateState() {
+               String s = null;
+               String currentName = configName.getText(); 
+               // Trim trailing whitespace
+               while (currentName.length() > 0 && Character.isWhitespace(currentName.charAt(currentName.length()-1))) {
+                       currentName = currentName.substring(0, currentName.length()-1);
+               }
+               // Make sure that the name is at least one character in length
+               if (currentName.length() == 0) {
+                       // No error message, but cannot select OK
+                       s = ""; //$NON-NLS-1$
+               } else if (cfgds.length == 0) {
+                       s = ""; //$NON-NLS-1$
+                       // Make sure the name is not a duplicate
+               } else if (isDuplicateName(currentName)) {
+                       s = NLS.bind(Messages.NewConfiguration_error_duplicateName, currentName);
+               } else if (isSimilarName(currentName)) {
+                       s = NLS.bind(Messages.NewConfiguration_error_caseName, currentName);
+               } else if (!validateName(currentName)) {
+                       // TODO Create a decent I18N string to describe this problem
+                       s = NLS.bind(Messages.NewConfiguration_error_invalidName, currentName);
+               } 
+               if (statusLabel == null) return;
+               Button b = getButton(IDialogConstants.OK_ID);
+               if (s != null) {
+                       statusLabel.setText(s);
+                       statusLabel.setVisible(true);
+                       if (b != null) b.setEnabled(false);
+               } else {
+                       statusLabel.setVisible(false);
+                       if (b != null) b.setEnabled(true);
+               }
+               return;
+       }
+        public String getNewDescription() {
+        return newDescription;
+    }
+
+       /**
+        * Create a new configuration, using the values currently set in 
+        * the dialog.
+        */
+       private void newConfiguration() {
+               String id = CDataUtil.genId(parentConfig.getId());              
+               try {
+                       ICConfigurationDescription newcfg = des.createConfiguration(id, newName, parentConfig);
+                       newcfg.setDescription(newDescription);
+               } catch (CoreException e) {
+                       System.out.println("Cannot create config\n"+ e.getLocalizedMessage()); //$NON-NLS-1$
+               }
+       }
+       
+       // useless in our case
+       public void setShell(Shell shell) {}
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PageLayout.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PageLayout.java
new file mode 100644 (file)
index 0000000..78b95d5
--- /dev/null
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Layout;
+
+
+/**
+ * Layout for the page container.
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class PageLayout extends Layout {
+       
+       /**
+        * The minimum page size; 200 by 200 by default.
+        *
+        * @see #setMinimumPageSize
+        */
+       private Point minimumPageSize = new Point(200, 200);
+
+       @Override
+       public void layout(Composite composite, boolean force) {
+               Rectangle rect = composite.getClientArea();
+               Control[] children = composite.getChildren();
+               for (int i = 0; i < children.length; i++) {
+                       children[i].setSize(rect.width, rect.height);
+               }
+       }
+       @Override
+       public Point computeSize(Composite composite, int wHint, int hHint,     boolean force) {
+               if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) {
+                       return new Point(wHint, hHint);
+               }
+               int x = minimumPageSize.x;
+               int y = minimumPageSize.y;
+
+               Control[] children = composite.getChildren();
+               for (int i = 0; i < children.length; i++) {
+                       Point size = children[i].computeSize(SWT.DEFAULT, SWT.DEFAULT, force);
+                       x = Math.max(x, size.x);
+                       y = Math.max(y, size.y);
+               }
+               if (wHint != SWT.DEFAULT) {
+                       x = wHint;
+               }
+               if (hHint != SWT.DEFAULT) {
+                       y = hHint;
+               }
+               return new Point(x, y);
+       }
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_head_general.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/Page_head_general.java
new file mode 100644 (file)
index 0000000..183a343
--- /dev/null
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 Intel Corporation and others
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *     Andrew Ferguson (Symbian)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.dialogs.PropertyPage;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.dialogs.DocCommentOwnerBlock;
+import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class Page_head_general extends PropertyPage implements ICOptionContainer {
+       private DocCommentOwnerBlock fDocBlock;
+       private boolean isProjectLevel;
+       
+       @Override
+       protected Control createContents(Composite parent) {
+               isProjectLevel= getProject() != null;
+               if(isProjectLevel) {
+                       fDocBlock= new DocCommentOwnerBlock();
+                       fDocBlock.setContainer(this);
+                       fDocBlock.createControl(parent);
+               }
+               noDefaultAndApplyButton();
+               return parent;
+       }
+       
+       @Override
+       protected void performDefaults() {
+               if(isProjectLevel) {
+                       fDocBlock.performDefaults();
+               }
+               super.performDefaults();
+       }
+       
+       @Override
+       public boolean performOk() {
+               if(isProjectLevel) {
+                       try {
+                               fDocBlock.performApply(new NullProgressMonitor());
+                       } catch(CoreException ce) {
+                               CUIPlugin.log(ce);
+                       }
+               }
+               return true;
+       }
+
+       public IProject getProject(){
+               IProject project= null;
+               IAdaptable elem = getElement();
+               if (elem instanceof IProject) {
+                       project= (IProject) elem;
+               } else if (elem != null) {
+                       project= (IProject) elem.getAdapter(IProject.class);
+               }
+               return project;
+       }
+
+       public Preferences getPreferences() {
+               throw new UnsupportedOperationException();
+       }
+
+       public void updateContainer() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PrefPage_Abstract.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PrefPage_Abstract.java
new file mode 100644 (file)
index 0000000..05dd5dc
--- /dev/null
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+import org.eclipse.cdt.core.model.CoreModel;
+
+/* This class is a base for preference pages 
+ * which store data in preferences 
+ * It means: 
+ *  - changes are saved by tabs, not by page
+ *  - if changes are made, all projects are
+ *    to be updated
+ */
+public class PrefPage_Abstract extends AbstractPrefPage {
+       
+       static public boolean isChanged;
+       
+       public PrefPage_Abstract() {
+               super();
+               isChanged = false;
+       }
+       
+       protected void doSave(IProgressMonitor monitor) throws CoreException {
+               if (isChanged) {
+                       CoreModel.getDefault().updateProjectDescriptions(null, monitor);
+               }
+       }
+
+       @Override
+       protected String getHeader() { return null;     }
+       @Override
+       protected boolean isSingle() { return true; }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ProjectContentsArea.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ProjectContentsArea.java
new file mode 100644 (file)
index 0000000..4415248
--- /dev/null
@@ -0,0 +1,366 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Intel corporation - cloned to CDT UI, to avoid discouraged access  
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.eclipse.core.filesystem.URIUtil;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.osgi.util.TextProcessor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class ProjectContentsArea {
+       private static final String ERROR_INVALID_PATH = Messages.ProjectContentsArea_3; 
+       private static final String ERROR_PATH_EMPTY = Messages.ProjectContentsArea_4; 
+       private static final String ERROR_NOT_ABSOLUTE = Messages.ProjectContentsArea_6; 
+       private static final String ERROR_NOT_VALID = Messages.ProjectContentsArea_7;  
+       private static final String ERROR_CANNOT_CREATE = Messages.ProjectContentsArea_8;  
+       private static final String ERROR_FILE_EXISTS = Messages.ProjectContentsArea_9; 
+       
+       private static final String BROWSE_LABEL = Messages.ProjectContentsArea_0; 
+       private static final int SIZING_TEXT_FIELD_WIDTH = 250;
+       private static final String FILE_SCHEME = "file"; //$NON-NLS-1$
+       private Label locationLabel;
+       private Text locationPathField;
+       private Button browseButton;
+       private IErrorMessageReporter errorReporter;
+       private String projectName = AbstractPage.EMPTY_STR;
+       private String userPath = AbstractPage.EMPTY_STR;
+       private Button useDefaultsButton;
+       private IProject existingProject;
+
+       /**
+        * Create a new instance of a ProjectContentsLocationArea.
+        * 
+        * @param composite
+        */
+       public ProjectContentsArea(IErrorMessageReporter er, Composite composite) {
+               errorReporter = er;
+               createContents(composite, true);
+       }
+
+       /**
+        * Create the contents of the receiver.
+        * 
+        * @param composite
+        * @param defaultEnabled
+        */
+       private void createContents(Composite composite, boolean defaultEnabled) {
+               // project specification group
+               Composite projectGroup = new Composite(composite, SWT.NONE);
+               GridLayout layout = new GridLayout();
+               layout.numColumns = 4;
+               projectGroup.setLayout(layout);
+               projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+               useDefaultsButton = new Button(projectGroup, SWT.CHECK | SWT.RIGHT);
+               useDefaultsButton.setText(Messages.ProjectContentsArea_1); 
+               useDefaultsButton.setSelection(defaultEnabled);
+               GridData buttonData = new GridData();
+               buttonData.horizontalSpan = 4;
+               useDefaultsButton.setLayoutData(buttonData);
+
+               createUserEntryArea(projectGroup, defaultEnabled);
+
+               useDefaultsButton.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               boolean useDefaults = useDefaultsButton.getSelection();
+
+                               if (useDefaults) {
+                                       userPath = locationPathField.getText();
+                                       locationPathField.setText(TextProcessor
+                                                       .process(getDefaultPathDisplayString()));
+                               } else {
+                                       locationPathField.setText(TextProcessor.process(userPath));
+                               }
+                               setUserAreaEnabled(!useDefaults);
+                       }
+               });
+               setUserAreaEnabled(!defaultEnabled);
+       }
+
+       /**
+        * Return whether or not we are currently showing the default location for
+        * the project.
+        * 
+        * @return boolean
+        */
+       public boolean isDefault() {
+               return useDefaultsButton.getSelection();
+       }
+
+       /**
+        * Create the area for user entry.
+        * 
+        * @param composite
+        * @param defaultEnabled
+        */
+       private void createUserEntryArea(Composite composite, boolean defaultEnabled) {
+               // location label
+               locationLabel = new Label(composite, SWT.NONE);
+               locationLabel.setText(Messages.ProjectContentsArea_2); 
+
+               // project location entry field
+               locationPathField = new Text(composite, SWT.BORDER);
+               GridData data = new GridData(GridData.FILL_HORIZONTAL);
+               data.widthHint = SIZING_TEXT_FIELD_WIDTH;
+               data.horizontalSpan = 2;
+               locationPathField.setLayoutData(data);
+
+               // browse button
+               browseButton = new Button(composite, SWT.PUSH);
+               browseButton.setText(BROWSE_LABEL);
+               browseButton.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent event) {
+                               handleLocationBrowseButtonPressed();
+                       }
+               });
+
+               if (defaultEnabled) {
+                       locationPathField.setText(TextProcessor
+                                       .process(getDefaultPathDisplayString()));
+               } else {
+                       if (existingProject == null) {
+                               locationPathField.setText(AbstractPage.EMPTY_STR);
+                       } else {
+                               locationPathField.setText(TextProcessor.process(existingProject
+                                               .getLocation().toString()));
+                       }
+               }
+
+               locationPathField.addModifyListener(new ModifyListener() {
+                       public void modifyText(ModifyEvent e) {
+                               errorReporter.reportError(checkValidLocation());
+                       }
+               });
+       }
+
+       /**
+        * Return the path we are going to display. If it is a file URI then remove
+        * the file prefix.
+        * 
+        * @return String
+        */
+       private String getDefaultPathDisplayString() {
+
+               URI defaultURI = null;
+               if (existingProject != null) {
+                       defaultURI = existingProject.getLocationURI();
+               }
+
+               // Handle files specially. Assume a file if there is no project to query
+               if (defaultURI == null || defaultURI.getScheme().equals(FILE_SCHEME)) {
+                       return Platform.getLocation().append(projectName).toString();
+               }
+               return defaultURI.toString();
+
+       }
+
+       /**
+        * Set the enablement state of the receiver.
+        * 
+        * @param enabled
+        */
+       private void setUserAreaEnabled(boolean enabled) {
+               locationLabel.setEnabled(enabled);
+               locationPathField.setEnabled(enabled);
+               browseButton.setEnabled(enabled);
+       }
+
+       /**
+        * Return the browse button. Usually referenced in order to set the layout
+        * data for a dialog.
+        * 
+        * @return Button
+        */
+       public Button getBrowseButton() {
+               return browseButton;
+       }
+
+       /**
+        * Open an appropriate directory browser
+        */
+       private void handleLocationBrowseButtonPressed() {
+
+               String selectedDirectory = null;
+               String dirName = getPathFromLocationField();
+
+               if (!dirName.equals(AbstractPage.EMPTY_STR)) {
+                       File f = new Path(dirName).toFile();
+                       if (!f.exists()) dirName = AbstractPage.EMPTY_STR;
+               }
+
+               DirectoryDialog dialog = new DirectoryDialog(locationPathField.getShell());
+               dialog.setMessage(Messages.ProjectContentsArea_5); 
+               dialog.setFilterPath(dirName);
+               selectedDirectory = dialog.open();
+
+               if (selectedDirectory != null)
+                       updateLocationField(selectedDirectory);
+       }
+
+       /**
+        * Update the location field based on the selected path.
+        * 
+        * @param selectedPath
+        */
+       private void updateLocationField(String selectedPath) {
+               locationPathField.setText(TextProcessor.process(selectedPath));
+       }
+
+       /**
+        * Return the path on the location field.
+        * 
+        * @return String
+        */
+       private String getPathFromLocationField() {
+               URI fieldURI;
+               try {
+                       fieldURI = new URI(locationPathField.getText());
+               } catch (URISyntaxException e) {
+                       return locationPathField.getText();
+               }
+               return fieldURI.getPath();
+       }
+
+       /**
+        * Check if the entry in the widget location is valid. If it is valid return
+        * null. Otherwise return a string that indicates the problem.
+        * 
+        * @return String
+        */
+       private String checkValidLocation() {
+               
+               if (isDefault()) return null;
+               
+               String locationFieldContents = locationPathField.getText();
+               
+               if (locationFieldContents.length() == 0)
+                       return ERROR_PATH_EMPTY;
+               
+               URI newPath = getProjectLocationURI();
+
+               if (newPath == null)
+                       return ERROR_INVALID_PATH;
+
+               if (!Path.EMPTY.isValidPath(locationFieldContents))
+                       return ERROR_NOT_VALID;
+
+               Path p = new Path(locationFieldContents);
+               
+               if (!p.isAbsolute())
+                       return ERROR_NOT_ABSOLUTE;
+               
+               // try to create dummy file
+               File f = p.toFile();
+               if (!f.exists()) {
+                       boolean result = false;
+                       try {
+                               result = f.createNewFile();
+                       } catch (IOException e) {}
+                       
+                       if (result)
+                               f.delete();
+                       else
+                               return ERROR_CANNOT_CREATE;
+               } else {
+                       if (f.isFile()) 
+                               return ERROR_FILE_EXISTS;
+               }
+               
+               //create a dummy project for the purpose of validation if necessary
+               IProject project = existingProject;
+               if (project == null) {
+                       String name = new Path(locationFieldContents).lastSegment();
+                       if (name != null && Path.EMPTY.isValidSegment(name))
+                               project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
+                       else 
+                               return ERROR_INVALID_PATH; 
+               }
+               IStatus locationStatus = project.getWorkspace().validateProjectLocationURI(project, newPath);
+
+               if (!locationStatus.isOK()) {
+                       return locationStatus.getMessage();
+               }
+               if (existingProject != null) {
+                       URI projectPath = existingProject.getLocationURI();
+                       if (projectPath != null && URIUtil.equals(projectPath, newPath))
+                               return ERROR_INVALID_PATH;
+               }
+
+               return null;
+       }
+
+       /**
+        * Get the URI for the location field if possible.
+        * @return URI or <code>null</code> if it is not valid.
+        */
+       public URI getProjectLocationURI() { 
+               return URIUtil.toURI(locationPathField.getText());
+       }
+
+       /**
+        * Set the text to the default or clear it if not using the defaults.
+        * @param newName
+        *            the name of the project to use. If <code>null</code> use the
+        *            existing project name.
+        */
+       public void updateProjectName(String newName) {
+               projectName = newName;
+               if (isDefault())
+                       locationPathField.setText(TextProcessor.process(getDefaultPathDisplayString()));
+       }
+
+       /**
+        * Return the location for the project. If we are using defaults then return
+        * the workspace root so that core creates it with default values.
+        * 
+        * @return String
+        */
+       public String getProjectLocation() {
+               return isDefault() ? 
+                       Platform.getLocation().toString(): 
+                       locationPathField.getText();
+       }
+
+       /**
+        * IErrorMessageReporter is an interface for type that allow message
+        * reporting. Null means "clear error messages area".
+        */
+       public interface IErrorMessageReporter {
+               public void reportError(String errorMessage);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PropertyTester.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PropertyTester.java
new file mode 100644 (file)
index 0000000..a140e86
--- /dev/null
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.core.resources.IFile;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+/**
+ * Checks whether given object is a source file.
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class PropertyTester extends org.eclipse.core.expressions.PropertyTester {
+       private static final String KEY_SRC  = "isSource"; //$NON-NLS-1$
+       private static final String KEY_PAGE = "pageEnabled"; //$NON-NLS-1$
+       private static final String VAL_EXP  = "export"; //$NON-NLS-1$
+       private static final String VAL_TOOL = "toolEdit"; //$NON-NLS-1$
+       
+       public boolean test(Object receiver, String property, Object[] args,
+                       Object expectedValue) {
+               if (KEY_SRC.equals(property)) {
+                       if (receiver instanceof ITranslationUnit) {
+                               return ((ITranslationUnit)receiver).isSourceUnit();
+                       }
+                       else if (receiver instanceof IFile) {
+                               IFile file = (IFile)receiver;
+                               return CoreModel.isValidSourceUnitName(file.getProject(), file.getName());
+                       }
+               } else if (KEY_PAGE.equals(property) 
+                               && expectedValue instanceof String) {
+                       String s = (String) expectedValue;
+                       if (VAL_EXP.equalsIgnoreCase(s))
+                               return CDTPrefUtil.getBool(CDTPrefUtil.KEY_EXPORT);
+                       if (VAL_TOOL.equalsIgnoreCase(s))
+                               return !CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOTOOLM);
+               }
+               return false;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RefsTab.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RefsTab.java
new file mode 100644 (file)
index 0000000..4558fe5
--- /dev/null
@@ -0,0 +1,396 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *     IBM Corporation
+ *     James Blackburn (Broadcom Corp.)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleAdapter;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.TreeEvent;
+import org.eclipse.swt.events.TreeListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class RefsTab extends AbstractCPropertyTab {
+
+       /** gray colour for 'disabled' items */
+       private final Color GRAY_COLOR = new Color(Display.getDefault(), 100, 100, 100);
+       public Composite comp;
+       private Tree tree;
+
+       static private final String ACTIVE = "[" + Messages.RefsTab_Active + "]"; //$NON-NLS-1$ //$NON-NLS-2$
+
+       private static final int EXPAND_ALL_BUTTON = 0;
+       private static final int COLLAPSE_ALL_BUTTON = 1;
+       private static final int MOVEUP_BUTTON = 3;
+       private static final int MOVEDOWN_BUTTON = 4;
+
+       @Override
+       public void createControls(Composite parent) {
+               super.createControls(parent);
+               initButtons(new String[] {
+                               Messages.RefsTab_ExpandAll,
+                               Messages.RefsTab_CollapseAll,
+                               null,
+                               MOVEUP_STR,
+                               MOVEDOWN_STR}, 120);
+               usercomp.setLayout(new GridLayout(1, false));
+
+               tree = new Tree(usercomp, SWT.SINGLE | SWT.CHECK | SWT.BORDER);
+               tree.setLayoutData(new GridData(GridData.FILL_BOTH));
+               tree.getAccessible().addAccessibleListener(
+            new AccessibleAdapter() {
+                @Override
+                               public void getName(AccessibleEvent e) {
+                       e.result = Messages.RefsTab_ProjectsList;
+                }
+            }
+        );
+
+               // Populate the tree
+               initData();
+               tree.addSelectionListener(new SelectionAdapter() {
+
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               if ((e.detail & SWT.CHECK) == SWT.CHECK && e.item != null && (e.item instanceof TreeItem)) {
+                                       TreeItem sel = (TreeItem)e.item;
+                                       Object data = sel.getData();
+
+                                       // If data is not a configuration ID, then the user isn't allowed to select this...
+                                       if (data == null) {
+                                               sel.setChecked(false);
+                                               return;
+                                       }
+
+                                       boolean checked = sel.getChecked();
+                                       TreeItem parent = sel.getParentItem();
+
+                                       if (parent == null) {
+                                               // Project -- top-level item -- selected
+                                               if (checked)
+                                                       sel.setExpanded(true);
+                                               for (TreeItem child : sel.getItems()) {
+                                                       if (checked) {
+                                                               // Don't select a non-allowed configuration
+                                                               if (child.getData() != null) {
+                                                                       child.setChecked(true);
+                                                                       break;
+                                                               }
+                                                       } else
+                                                               child.setChecked(false);
+                                               }
+                                       } else {
+                                               // Configuration selected (it has a parent)
+                                       if (parent.getChecked()) {
+                                               // Deselect other configs already selected
+                                               for (TreeItem obj : parent.getItems())
+                                                       obj.setChecked(false);
+                                               sel.setChecked(checked);
+                                       }
+                                       parent.setChecked(checked);
+                                       }
+
+                                       // Save the checked configurations
+                                       saveChecked();
+                           }
+                               updateButtons();
+                       }
+               });
+
+               tree.addTreeListener(new TreeListener() {
+                       public void treeCollapsed(TreeEvent e) {
+                               updateExpandButtons(e, false, true);
+                       }
+                       public void treeExpanded(TreeEvent e) {
+                               updateExpandButtons(e, true, false);
+                       }});
+
+       }
+
+    @Override
+       public void buttonPressed(int n) {
+       switch (n)
+       {
+       case COLLAPSE_ALL_BUTTON:
+       case EXPAND_ALL_BUTTON:
+                       for (TreeItem item : tree.getItems())
+                               item.setExpanded(n==EXPAND_ALL_BUTTON);
+                       updateButtons();
+                       break;
+       case MOVEUP_BUTTON:
+       case MOVEDOWN_BUTTON:
+               // TODO cache this...
+               Map<String, String> oldMapping = getResDesc().getConfiguration().getReferenceInfo();
+               TreeItem ti = tree.getSelection()[0];
+               String projectName = ti.getText();
+               List<String> projNames = new ArrayList<String>(oldMapping.keySet());
+               int index = projNames.indexOf(projectName);
+               if (n == MOVEUP_BUTTON) {
+                       if (index > 0) {
+                               projNames.set(index, projNames.get(index - 1));
+                               projNames.set(index - 1, projectName);
+                       }
+               } else {
+                       if (index < projNames.size() - 1) {
+                               projNames.set(index, projNames.get(index + 1));
+                               projNames.set(index + 1, projectName);
+                       }
+               }
+               Map<String, String> newMapping = new LinkedHashMap<String, String>(oldMapping.size());
+               for (String name : projNames)
+                       newMapping.put(name, oldMapping.get(name));
+               getResDesc().getConfiguration().setReferenceInfo(newMapping);
+               initData();
+               break;
+       }
+    }
+
+       @Override
+       protected void updateData(ICResourceDescription cfgd) {
+               if (page.isMultiCfg()) {
+                       setAllVisible(false, null);
+               } else {
+                       if (!usercomp.isVisible())
+                               setAllVisible(true, null);
+                       initData();
+               }
+       }
+
+       /**
+        * Persist the checked configurations
+        */
+       private void saveChecked() {
+               Map<String, String> refs = new LinkedHashMap<String, String>();
+               for (TreeItem project : tree.getItems()) {
+                       if (project.getChecked()) {
+                               if (project.getData() instanceof String) {
+                                       assert(project.getData() != null);
+                                       // Project is missing from the workspace, maintain references
+                                       refs.put(project.getText(), (String)project.getData());
+                               } else {
+                                       for (TreeItem config : project.getItems()) {
+                                               if (config.getChecked()) {
+                                                       assert(config.getData() != null);
+                                                       refs.put(project.getText(), (String)config.getData());
+                                                       break; // only one configuration can be selected a time in a project
+                                               }
+                                       }
+                               }
+                       }
+               }
+               getResDesc().getConfiguration().setReferenceInfo(refs);
+       }
+
+       /**
+        * Initialises the tree.
+        *
+        * TreeItems are either
+        * TI:       Text            ,     Data
+        *   {IProject.getName()}    , {IProject}
+        *       {cfgName}           , {String cfgId}
+        *       {cfgName}           , {null}  // config is not allowed to be selected
+        *
+        * If the projects doesn't exist in the workspace:
+        *   {IProject.getName()}    , {String cfgId}
+        *
+        */
+    private void initData() {
+       // Persist the current select / expand state to restore...
+       String currentSelection = tree.getSelectionCount() == 1 ? tree.getSelection()[0].getText() : null;
+       Set<String> currentExpanded = new HashSet<String>();
+       for (TreeItem ti : tree.getItems())
+               if (ti.getExpanded())
+                       currentExpanded.add(ti.getText());
+
+               tree.removeAll();
+               IProject p = page.getProject();
+               if (p == null)
+                       return;
+
+               // Get all the CDT references
+               Map<String,String> refs = getResDesc().getConfiguration().getReferenceInfo();
+
+               // Preserve project order. All linked to projects occur before others
+               Set<String> projects = new LinkedHashSet<String>(refs.keySet());
+               for (IProject prj : p.getWorkspace().getRoot().getProjects())
+                       projects.add(prj.getName());
+
+               for (String pname : projects) {
+                       // The referenced configuration ID
+                       String ref = refs.get(pname);
+                       IProject prj;
+                       ICConfigurationDescription[] cfgs;
+                       try {
+                               prj = p.getWorkspace().getRoot().getProject(pname);
+                               cfgs = page.getCfgsReadOnly(prj);
+                       } catch (Exception e) {
+                               CUIPlugin.log(Messages.RefsTab_ConfigurationsAccessError+pname, e);
+                               continue;
+                       }
+                       if (cfgs == null || cfgs.length == 0) {
+                               // If the project is referenced, then make sure the user knows about it!
+                               if (ref != null) {
+                                       TreeItem ti = new TreeItem(tree, SWT.NONE);
+                                       ti.setChecked(true);
+                                       ti.setText(pname);
+                                       ti.setData(refs.get(pname));
+                                       ti.setForeground(GRAY_COLOR);
+                               }
+                               continue;
+                       }
+
+                       // Only show the current project if it's got more than 1 configuration
+                       if (page.getProject().equals(prj) && cfgs.length < 2)
+                               continue;
+
+                       // Add the project
+                       TreeItem ti = new TreeItem(tree, SWT.NONE);
+                       ti.setText(pname);
+                       ti.setData(prj);
+                       if (ref != null)
+                               ti.setChecked(true);
+
+                       // Add the configurations
+                       TreeItem ti1;
+                       if (!prj.equals(p)) {
+                               // [ Active ] config in the tree
+                               ti1 = new TreeItem(ti, SWT.NONE);
+                               ti1.setText(ACTIVE);
+                               ti1.setData(EMPTY_STR);
+                               if (EMPTY_STR.equals(ref)) {
+                                       ti1.setChecked(true);
+                                       ti1.setData(ref);
+                               }
+                       }
+                       // Name configurations in the tree
+                       for (ICConfigurationDescription cfg : cfgs) {
+                               // Don't include self configuration
+                               ti1 = new TreeItem(ti, SWT.NONE);
+                               ti1.setText(cfg.getName());
+                               if (prj.equals(p) && cfg.getId().equals(page.getResDesc().getConfiguration().getId())) {
+                                       // users may *only* reference other configuration in the project
+                                       // this data is deliberately null as it may not be selected...
+                                       ti1.setForeground(GRAY_COLOR);
+                                       continue;
+                               } else if (cfg.getId().equals(ref))
+                                       ti1.setChecked(true);
+                               ti1.setData(cfg.getId());
+                       }
+               }
+
+               // Reselect / Re-expand previously selected & expanded items
+               if (currentSelection != null)
+                       for (TreeItem ti : tree.getItems())
+                               if (ti.getText().equals(currentSelection)) {
+                                       tree.setSelection(ti);
+                                       break;
+                               }
+               for (TreeItem ti : tree.getItems())
+                       if (currentExpanded.contains(ti.getText()))
+                               ti.setExpanded(true);
+
+               updateButtons();
+       }
+
+       @Override
+       protected void performApply(ICResourceDescription src, ICResourceDescription dst) {
+               dst.getConfiguration().setReferenceInfo(src.getConfiguration().getReferenceInfo());
+       }
+
+       // This page can be displayed for project only
+       @Override
+       public boolean canBeVisible() {
+               return page.isForProject();
+       }
+
+       @Override
+       protected void performDefaults() {
+               if (!usercomp.isVisible())
+                       return;
+               getResDesc().getConfiguration().setReferenceInfo(new HashMap<String, String>());
+               initData();
+       }
+
+       @Override
+       protected void updateButtons() {
+               updateExpandButtons(null, false, false);
+               updateMoveButtons();
+       }
+
+       @Override
+       public void dispose() {
+               super.dispose();
+               GRAY_COLOR.dispose();
+       }
+
+       private void updateExpandButtons(TreeEvent e, boolean stateE, boolean stateC) {
+               boolean cntE = stateE;
+               boolean cntC = stateC;
+               for (TreeItem item : tree.getItems()) {
+                       if (e != null && e.widget.equals(item))
+                               continue;
+                       if (item.getExpanded())
+                               cntE = true;
+                       else
+                               cntC = true;
+               }
+               buttonSetEnabled(EXPAND_ALL_BUTTON, cntC); // Expand All
+               buttonSetEnabled(COLLAPSE_ALL_BUTTON, cntE); // Collapse all
+       }
+
+       /**
+        * Make the move buttons enabled when a project is selected
+        */
+       private void updateMoveButtons() {
+               if (tree.getSelectionCount() == 1) {
+                       TreeItem ti = tree.getSelection()[0];
+                       // Is a project selected?
+                       if (ti.getParentItem() == null && ti.getChecked()) {
+                               int index = tree.indexOf(ti);
+                               buttonSetEnabled(MOVEUP_BUTTON, index > 0);
+                               buttonSetEnabled(MOVEDOWN_BUTTON, index < tree.getItemCount() - 1);
+                               return;
+                       }
+               }
+               buttonSetEnabled(MOVEUP_BUTTON, false);
+               buttonSetEnabled(MOVEDOWN_BUTTON, false);
+       }
+
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RenameConfigurationDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/RenameConfigurationDialog.java
new file mode 100644 (file)
index 0000000..0b59899
--- /dev/null
@@ -0,0 +1,269 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Intel Corporation - Initial API and implementation
+ * IBM Corporation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.preference.JFacePreferences;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class RenameConfigurationDialog extends Dialog {
+       // Widgets
+       
+       private Text configName;
+       private Text configDescription;
+               
+       private ICConfigurationDescription[] cfgds;
+       private ICConfigurationDescription renameConfig;
+       private String newName;
+       private String newDescription;
+       private Label statusLabel;
+       
+       private String originalName;
+       final private String title;
+       /**
+        */
+       protected RenameConfigurationDialog(Shell parentShell, 
+                       ICConfigurationDescription _renameConfig,
+                       ICConfigurationDescription[] _cfgds,
+                       String _title) {
+               super(parentShell);
+               title = _title;
+               renameConfig = _renameConfig;
+               cfgds = _cfgds;
+               
+               setShellStyle(getShellStyle()|SWT.RESIZE);
+               newName = renameConfig.getName();
+               newDescription = renameConfig.getDescription();
+               if(newDescription == null) newDescription = new String();
+               originalName = renameConfig.getName();
+       }
+       
+       /* (non-Javadoc)
+        * Method declared on Dialog. Cache the name and base config selections.
+        * We don't have to worry that the index or name is wrong because we 
+        * enable the OK button IFF those conditions are met.
+        */
+       @Override
+       protected void buttonPressed(int buttonId) {
+               if (buttonId == IDialogConstants.OK_ID) {
+                       newName = configName.getText().trim();
+                       newDescription = configDescription.getText().trim();
+               } 
+               super.buttonPressed(buttonId);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+        */
+       @Override
+       protected void configureShell(Shell shell) {
+               super.configureShell(shell);
+               if (title != null) shell.setText(title);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected void createButtonsForButtonBar(Composite parent) {
+               super.createButtonsForButtonBar(parent);
+               configName.setFocus();
+               if (configName != null) {
+                       configName.setText(newName);
+               }
+               validateState();
+       }
+
+       @Override
+       protected Control createDialogArea(Composite parent) {
+               
+               Composite composite = new Composite(parent, SWT.NULL);
+               composite.setFont(parent.getFont());
+               composite.setLayout(new GridLayout(3, false));
+               composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               
+               // Create a group for the name & description
+
+               final Group group1 = new Group(composite, SWT.NONE);
+               group1.setFont(composite.getFont());
+               GridLayout layout1 = new GridLayout(3, false);
+               group1.setLayout(layout1);
+               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = 3;
+               group1.setLayoutData(gd);
+
+               // bug 187634: Add a label to warn user that configuration name will be used directly
+               // as a directory name in the filesystem.
+               Label warningLabel = new Label(group1, SWT.BEGINNING | SWT.WRAP);
+               warningLabel.setFont(parent.getFont());
+               warningLabel.setText(Messages.RenameConfiguration_label_warning); 
+               gd = new GridData(SWT.FILL, SWT.BEGINNING, true, false, 3, 1);
+               gd.widthHint = 300;
+               warningLabel.setLayoutData(gd);
+
+               // Add a label and a text widget for Configuration's name
+               final Label nameLabel = new Label(group1, SWT.LEFT);
+               nameLabel.setFont(parent.getFont());
+               nameLabel.setText(Messages.RenameConfiguration_label_name);
+                               
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = 1;
+               gd.grabExcessHorizontalSpace = false;
+               nameLabel.setLayoutData(gd);
+
+               configName = new Text(group1, SWT.SINGLE | SWT.BORDER);
+               configName.setFont(group1.getFont());
+               configName.setText(getNewName());
+               configName.setFocus();
+               gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+               gd.horizontalSpan = 2;
+               gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
+               configName.setLayoutData(gd);
+               configName.addModifyListener(new ModifyListener() {
+                       public void modifyText(ModifyEvent e) {
+                               validateState();
+                       }
+               });
+               
+//              Add a label and a text widget for Configuration's description
+        final Label descriptionLabel = new Label(group1, SWT.LEFT);
+        descriptionLabel.setFont(parent.getFont());
+        descriptionLabel.setText(Messages.RenameConfiguration_label_description);
+
+        gd = new GridData(GridData.FILL_HORIZONTAL);
+        gd.horizontalSpan = 1;
+               gd.grabExcessHorizontalSpace = false;
+        descriptionLabel.setLayoutData(gd);
+        configDescription = new Text(group1, SWT.SINGLE | SWT.BORDER);
+        configDescription.setFont(group1.getFont());
+               configDescription.setText(getNewDescription());
+               configDescription.setFocus();
+               
+        gd = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+        gd.horizontalSpan = 2;
+        gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
+        configDescription.setLayoutData(gd);
+        
+        statusLabel = new Label(parent, SWT.CENTER);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = 3;
+               statusLabel.setLayoutData(gd);
+               statusLabel.setFont(composite.getFont());
+               statusLabel.setForeground(JFaceResources.getColorRegistry().get(JFacePreferences.ERROR_COLOR));
+               return composite;
+       }
+
+       protected boolean isDuplicateName(String newName) {
+               if(newName.equals(originalName)) return false;
+               // Return true if there is already a config of that name defined
+               for (int i = 0; i < cfgds.length; i++) {
+                       if (cfgds[i].getName().equals(newName)) return true;
+               }
+               return false;
+       }
+       
+       protected boolean isSimilarName(String newName) {
+               if(newName.equalsIgnoreCase(originalName))      return false;
+               // Return true if there is already a config of that name defined on the target
+               for (int i = 0; i < cfgds.length; i++) {
+                       if (cfgds[i].getName().equalsIgnoreCase(newName)) return true;
+               }
+               return false;
+       }
+
+       /* (non-Javadoc)
+        * Checks the argument for leading whitespaces and invalid directory name characters. 
+        * @param name
+        * @return <I>true</i> is the name is a valid directory name with no whitespaces
+        */
+       private boolean validateName(String name) {
+               // Iterate over the name checking for bad characters
+               char[] chars = name.toCharArray();
+               // No whitespaces at the start of a name
+               if (Character.isWhitespace(chars[0])) {
+                       return false;
+               }
+               for (int index = 0; index < chars.length; ++index) {
+                       // Config name must be a valid dir name too, so we ban "\ / : * ? " < >" in the names
+                       if (!Character.isLetterOrDigit(chars[index])) {
+                               switch (chars[index]) {
+                               case '/':
+                               case '\\':
+                               case ':':
+                               case '*':
+                               case '?':
+                               case '\"':
+                               case '<':
+                               case '>':
+                                       return false;
+                               default:
+                                       break;
+                               }
+                       }
+               }
+               return true;
+       }
+       /* (non-Javadoc)
+        * Update the status message and button state based on the input selected
+        * by the user
+        * 
+        */
+       private void validateState() {
+               String s = null;
+               String currentName = configName.getText().trim();
+               // Make sure that the name is at least one character in length
+               if (currentName.length() == 0) {
+                       s = ""; //$NON-NLS-1$
+                       // Make sure the name is not a duplicate
+               } else if (isDuplicateName(currentName)) {
+                       s = NLS.bind(Messages.RenameConfiguration_error_duplicateName, currentName);
+               } else if (isSimilarName(currentName)) {
+                       s = NLS.bind(Messages.RenameConfiguration_error_caseName, currentName);
+               } else if (!validateName(currentName)) {
+                       s = NLS.bind(Messages.RenameConfiguration_error_invalidName, currentName);      
+               }
+               Button b = getButton(IDialogConstants.OK_ID);
+               if (s != null) {
+                       statusLabel.setText(s);
+                       statusLabel.setVisible(true);
+                       if (b != null) b.setEnabled(false);
+               } else {
+                       statusLabel.setVisible(false);
+                       if (b != null) b.setEnabled(true);
+               }
+               return;
+       }
+       
+       public String getNewName() { return newName; }
+       public String getNewDescription() { return newDescription; }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/StringListModeControl.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/StringListModeControl.java
new file mode 100644 (file)
index 0000000..3b65521
--- /dev/null
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 2010 Andrew Gvozdev (Quoin Inc.) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Andrew Gvozdev (Quoin Inc.) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui.newui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * Local UI control for multiple configurations string list mode redirecting to
+ * Preference page "Multiple Configurations Edit".
+ *
+ * @since 5.3
+ */
+public class StringListModeControl {
+       private static final String STRING_LIST_MODE_PREFERENCE_PAGE = "org.eclipse.cdt.managedbuilder.ui.preferences.PrefPage_MultiConfig"; //$NON-NLS-1$
+       private ICPropertyProvider page;
+       private Link linkStringListMode;
+       private List<Listener> listeners = new ArrayList<Listener>();
+
+       /**
+        * Constructor.
+        *
+        * @param page - preference page.
+        * @param parent - parent {@code Composite} control.
+        * @param span - horizontal span for the control
+        */
+       public StringListModeControl(ICPropertyProvider page, final Composite parent, int span) {
+               this.page = page;
+               linkStringListMode = new Link(parent, SWT.NONE);
+               updateStringListModeLink(linkStringListMode);
+               linkStringListMode.setToolTipText(Messages.AbstractLangsListTab_MultiConfigStringListModeLinkHint);
+
+               linkStringListMode.addListener(SWT.Selection, new Listener() {
+                       public void handleEvent(Event event) {
+                               // Use event.text to tell which link was used
+                               int result = PreferencesUtil.createPreferenceDialogOn(parent.getShell(), STRING_LIST_MODE_PREFERENCE_PAGE, null, null).open();
+                               if (result!=Window.CANCEL) {
+                                       updateStringListModeControl();
+                                       for (Listener listener : listeners) {
+                                               listener.handleEvent(event);
+                                       }
+                               }
+                       }
+               });
+
+               GridData gridData = new GridData(SWT.RIGHT, SWT.NONE, true, false);
+               gridData.horizontalSpan = span;
+               linkStringListMode.setLayoutData(gridData);
+       }
+
+       /**
+        * Add a listener suitable for {@link org.eclipse.swt.widgets.Widget#addListener(int, Listener)}.
+        *
+        * @param eventType - the type of event to listen for, currently not used.
+        * @param listener - the listener which should be notified when the event occurs.
+        */
+       public void addListener(int eventType, final Listener listener) {
+               listeners.add(listener);
+       }
+
+       /**
+        * Removes the listener from the collection of listeners.
+        *
+        * @param eventType the type of event to listen for, currently not used.
+        * @param listener the listener which should no longer be notified.
+        */
+       protected void removeListener (int eventType, Listener listener) {
+               listeners.remove(listener);
+       }
+
+       /**
+        * Use to update the control when one of the string list modes gets modified .
+        */
+       public void updateStringListModeControl() {
+               updateStringListModeLink(linkStringListMode);
+       }
+
+       /**
+        * Updates the message of the link presented to the user.
+        *
+        * @param link - {@code Link} object to update.
+        */
+       private void updateStringListModeLink(Link link) {
+               boolean isMultiCfg = page.isMultiCfg();
+               linkStringListMode.setVisible(isMultiCfg);
+               if (isMultiCfg) {
+                       String modeUnknown = Messages.AbstractLangsListTab_UnknownMode;
+                       String modeDisplay = modeUnknown;
+                       switch (CDTPrefUtil.getMultiCfgStringListDisplayMode()) {
+                       case CDTPrefUtil.DMODE_CONJUNCTION:
+                               modeDisplay = Messages.AbstractLangsListTab_Conjunction;
+                               break;
+                       case CDTPrefUtil.DMODE_DISJUNCTION:
+                               modeDisplay = Messages.AbstractLangsListTab_Disjunction;
+                               break;
+                       }
+
+                       String modeWrite = modeUnknown;
+                       switch (CDTPrefUtil.getMultiCfgStringListWriteMode()) {
+                       case CDTPrefUtil.WMODE_MODIFY:
+                               modeWrite = Messages.AbstractLangsListTab_Modify;
+                               break;
+                       case CDTPrefUtil.WMODE_REPLACE:
+                               modeWrite = Messages.AbstractLangsListTab_Replace;
+                               break;
+                       }
+
+                       linkStringListMode.setText(Messages.AbstractLangsListTab_StringListMode +
+                                       " <a href=\"workspace-settings\">"+modeDisplay+"</a> + <a href=\"workspace-settings\">"+modeWrite+"</a>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+               }
+               linkStringListMode.getParent().layout();
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/StructureTreeTab.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/StructureTreeTab.java
new file mode 100644 (file)
index 0000000..21f9c91
--- /dev/null
@@ -0,0 +1,802 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.net.URI;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectNatureDescriptor;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceDescription;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourceAttributes;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Spinner;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
+
+import org.eclipse.cdt.core.settings.model.ICBuildSetting;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
+import org.eclipse.cdt.core.settings.model.ICExclusionPatternPathEntry;
+import org.eclipse.cdt.core.settings.model.ICExternalSetting;
+import org.eclipse.cdt.core.settings.model.ICFileDescription;
+import org.eclipse.cdt.core.settings.model.ICFolderDescription;
+import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+import org.eclipse.cdt.core.settings.model.ICSettingContainer;
+import org.eclipse.cdt.core.settings.model.ICSettingObject;
+import org.eclipse.cdt.core.settings.model.ICTargetPlatformSetting;
+import org.eclipse.cdt.core.settings.model.extension.CBuildData;
+import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
+import org.eclipse.cdt.core.settings.model.extension.CFolderData;
+import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
+import org.eclipse.cdt.core.settings.model.extension.CResourceData;
+import org.eclipse.cdt.core.settings.model.extension.CTargetPlatformData;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * This tab is intended to browse 
+ * contents of whole class such as ResourceDescription, 
+ * ConfigurationDescription or ProjectDescription
+ * 
+ * Notes:
+ * 
+ * 1. Many strings in the file remain unlocalized
+ *    since they represent method names.
+ * 2. It is experimental functionality. Work is in progress.  
+ * 3. Tree depth is limited by 16. Deeper branches are truncated.
+ *    But it seems to be very rare situation.
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class StructureTreeTab  extends AbstractCPropertyTab {
+
+       protected class LevelDialog extends Dialog {
+               protected LevelDialog() {
+                       super(CUIPlugin.getActiveWorkbenchShell());
+               }
+               @Override
+               protected Control createDialogArea(Composite parent) {
+                       Composite c = new Composite(parent, 0);
+                       c.setLayoutData(new GridData(GridData.FILL_BOTH));
+                       c.setLayout(new GridLayout(2, false));
+                       Label l = new Label(c, 0);
+                       l.setText(Messages.StructureTreeTab_0);  
+                       c.setLayoutData(new GridData(GridData.BEGINNING));
+                       Spinner sp = new Spinner(c, SWT.BORDER);
+                       sp.setMaximum(NESTING_MAX);
+                       sp.setMinimum(0);
+                       sp.setSelection(currentLevel);
+                       sp.addSelectionListener(new SelectionAdapter () {
+                               @Override
+                               public void widgetSelected(SelectionEvent e) {
+                                       currentLevel = ((Spinner)e.widget).getSelection();
+                               }
+                       });
+                       return c;
+               }
+       }
+       private static final String BL = "["; //$NON-NLS-1$
+       private static final String BR = "]"; //$NON-NLS-1$
+       private static final Image IMG = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_REFACTORING_ERROR);
+       private static final int NESTING_CFG = 5;
+       private static final int NESTING_MAX = 16;
+       private static final String NULL = "<NULL>"; //$NON-NLS-1$
+       private int currentLevel = 4; // default depth
+       private Combo combo;
+       private Tree tree;
+       private ICResourceDescription cfg;
+
+       /*
+        * Common check for each tree item:
+        * - corresponding objects are not null.
+        * - tree item nesting is no too deep.
+        */
+       private boolean check(TreeItem ti, Object obj) {
+               if (obj == null || ti == null) return false;
+               // data not used now
+               // ti.setData(obj);
+               int cnt = NESTING_MAX;
+               TreeItem tiSaved = ti;
+               while (--cnt > 0) {
+                       ti = ti.getParentItem();
+                       if (ti == null) return true;
+               }
+               tiSaved.setText(2, Messages.StructureTreeTab_1); 
+               tiSaved.setImage(IMG);
+               return false;
+       }
+       
+       private TreeItem create(TreeItem ti0, String text, boolean val) {
+               TreeItem t = create(ti0, text, String.valueOf(val));
+               t.setText(2, EMPTY_STR);
+               return t;
+       }
+       
+       private TreeItem create(TreeItem ti0, String text, int val) {
+               TreeItem t = create(ti0, text, String.valueOf(val));
+               t.setText(2, EMPTY_STR);
+               return t;
+       }
+       private TreeItem create(TreeItem ti0, String text, long val) {
+               TreeItem t = create(ti0, text, String.valueOf(val));
+               t.setText(2, Messages.StructureTreeTab_2); 
+               return t;
+       }
+
+       private TreeItem create(TreeItem ti0, String text, String val) {
+               TreeItem ti =  ti0 == null ? new TreeItem(tree, 0) : new TreeItem(ti0, 0);
+               ti.setText(0, text == null ? NULL : text);
+               ti.setText(1, val  == null ? NULL : val );
+               ti.setText(2, Messages.StructureTreeTab_3); 
+               return ti;
+       }
+       
+       @Override
+       public void createControls(Composite parent) {
+               super.createControls(parent);
+               usercomp.setLayout(new GridLayout(5, false));
+               
+               Label lb = new Label(usercomp, 0);
+               lb.setText(Messages.StructureTreeTab_4); 
+               lb.setLayoutData(new GridData(GridData.BEGINNING));
+               
+               combo = new Combo(usercomp, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.BORDER);
+               combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               combo.add(Messages.ConfigDescriptionTab_0); 
+               combo.add(Messages.ConfigDescriptionTab_1); 
+               if (page.isForFolder() || page.isForFile()) {
+                       combo.add(Messages.ConfigDescriptionTab_2); 
+                       combo.select(2); // ResourceDescription
+               } else
+                       combo.select(1); // ConfigurationDescription
+               combo.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               updateData(cfg);
+                       }});
+
+               Button b1 = new Button(usercomp, SWT.PUSH);
+               GridData gd = new GridData(GridData.END);
+               gd.minimumWidth = BUTTON_WIDTH;
+               b1.setLayoutData(gd);
+               b1.setText(Messages.StructureTreeTab_5); 
+               b1.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               tree.setRedraw(false);
+                               expandAll(tree.getItem(0), true, -1);
+                               tree.setRedraw(true);
+                       }});
+
+               Button b2 = new Button(usercomp, SWT.PUSH);
+               gd = new GridData(GridData.END);
+               gd.minimumWidth = BUTTON_WIDTH;
+               b2.setLayoutData(gd);
+               b2.setText(Messages.StructureTreeTab_6); 
+               b2.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               LevelDialog ld = new LevelDialog();
+                               if (ld.open() == Window.OK) {
+                                       tree.setRedraw(false);
+                                       expandAll(tree.getItem(0), true, 0);
+                                       tree.setRedraw(true);
+                               }
+                       }});            
+
+               Button b3 = new Button(usercomp, SWT.PUSH);
+               gd = new GridData(GridData.END);
+               gd.minimumWidth = BUTTON_WIDTH;
+               b3.setLayoutData(gd);
+               b3.setText(Messages.StructureTreeTab_7); 
+               b3.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               tree.setRedraw(false);
+                               expandAll(tree.getItem(0), false, -1);
+                               tree.setRedraw(true);
+                       }});            
+
+               tree = new Tree(usercomp, SWT.BORDER);
+               gd = new GridData(GridData.FILL_BOTH);
+               gd.horizontalSpan = 5;
+               tree.setLayoutData(gd);
+               
+               TreeColumn tc = new TreeColumn(tree, 0);
+               tc.setText(Messages.StructureTreeTab_8); 
+               tc.setWidth(300);
+               tc = new TreeColumn(tree, 0);
+               tc.setText(Messages.StructureTreeTab_9); 
+               tc.setWidth(100);
+               tc = new TreeColumn(tree, 0);
+               tc.setText(Messages.StructureTreeTab_10); 
+               tc.setWidth(200);
+               
+               tree.setHeaderVisible(true);
+               tree.setLinesVisible(true);
+               
+               tree.addSelectionListener(new SelectionListener() {
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                       }
+                       public void widgetSelected(SelectionEvent e) {
+                       }});
+       }
+       
+       private TreeItem createObj(TreeItem ti0, String text, String name, Object obj) {
+               TreeItem t = create(ti0, text, BL+name+BR);
+               if (obj != null) t.setText(2, obj.getClass().getName());
+               return t;
+       }
+
+       /**
+        * Adds conents of array to tree. 
+        */
+       private void expand(TreeItem ti0, String text, Object[] obs) {
+               TreeItem ti = create(ti0, text, obs == null ? 0 : obs.length);
+               if (obs == null || !check(ti, obs)) 
+                       return;
+               for (int i=0; i<obs.length; i++) {
+                       String s = BL+i+BR;
+                       if (obs[i] instanceof String) create(ti, s, (String)obs[i]);
+                       else if (obs[i] instanceof CLanguageData) update(ti, s, (CLanguageData)obs[i]);
+                       else if (obs[i] instanceof CResourceData) update(ti, s, (CResourceData)obs[i]);
+                       else if (obs[i] instanceof ICExclusionPatternPathEntry) update(ti, s, (ICExclusionPatternPathEntry)obs[i]);
+                       else if (obs[i] instanceof ICExternalSetting) update(ti, s, (ICExternalSetting)obs[i]);
+                       else if (obs[i] instanceof ICLanguageSettingEntry) update(ti, s, (ICLanguageSettingEntry)obs[i]);
+                       else if (obs[i] instanceof ICResourceDescription) update(ti, s, (ICResourceDescription)obs[i]);
+                       else if (obs[i] instanceof ICSettingObject) update(ti, s, (ICSettingObject)obs[i]);
+                       else if (obs[i] instanceof IPath) update(ti, s, (IPath)obs[i]);
+                       else if (obs[i] instanceof IResource) update(ti, s, (IResource)obs[i]);
+                       else if (obs[i] instanceof IProjectNatureDescriptor) update(ti, s, (IProjectNatureDescriptor)obs[i]);
+                       else update(ti, s, obs[i]);
+               }
+       }
+
+       private void expandAll(TreeItem ti, boolean b, int level) {
+               if (level == -1) ti.setExpanded(b);
+               else ti.setExpanded(level++ < currentLevel);
+
+               TreeItem[] tis = ti.getItems();
+               if (tis == null) return;
+               for (TreeItem ti2 : tis)
+                       expandAll(ti2, b, level);
+       }
+       // used for languages kinds display
+       private int[] flagsToArray(int flags){
+               int arr[] = new int[32];
+               int num = 0;
+               for(int i = 1; i != 0; i = i << 1){
+                       if((flags & i) != 0)
+                               arr[num++] = i;
+               }
+               if(num == arr.length) return arr;
+               else if(num == 0) return new int[0];
+               int result[] = new int[num];
+               System.arraycopy(arr, 0, result, 0, num);
+               return result;
+       }
+       private int getDepth(TreeItem ti) {
+               int x = 0;
+               while (ti != null) {
+                       ti = ti.getParentItem();
+                       x++;
+               }
+               return x;
+       }
+
+       @Override
+       protected void performApply(ICResourceDescription src,ICResourceDescription dst) {}
+
+       @Override
+       protected void performDefaults() {}
+       
+       private void update(ICProjectDescription prj) {
+               TreeItem ti = new TreeItem(tree, 0);
+               if (!check(ti, prj)) return;
+               ti.setText(0, "ICProjectDescription");  //$NON-NLS-1$
+               update(ti, "getActiveConfiguration()", prj.getActiveConfiguration()); //$NON-NLS-1$
+               expand(ti, "getConfigurations()", prj.getConfigurations()); //$NON-NLS-1$
+               create(ti,"getId()",prj.getId()); //$NON-NLS-1$
+               create(ti,"getName()",prj.getName()); //$NON-NLS-1$
+               update(ti, "getParent()", prj.getParent()); //$NON-NLS-1$
+               update(ti, "getProject()", prj.getProject()); //$NON-NLS-1$
+               create(ti,"getType()",prj.getType()); //$NON-NLS-1$
+               create(ti,"isModified()",prj.isModified()); //$NON-NLS-1$
+               create(ti,"isReadOnly()",prj.isReadOnly()); //$NON-NLS-1$
+               create(ti,"isValid()",prj.isValid()); //$NON-NLS-1$
+       }
+
+       private TreeItem update(TreeItem ti0, String text, CBuildData bd) {
+               TreeItem ti = createObj(ti0, text, bd  == null ? NULL : bd.getName(), bd);
+               if (bd == null || !check(ti, bd)) return ti;
+               // ALMOST THE SAME AS ICBuildSetting
+               update(ti, "getBuilderCWD()", bd.getBuilderCWD()); //$NON-NLS-1$
+               createObj(ti, "getBuildEnvironmentContributor()", EMPTY_STR, bd.getBuildEnvironmentContributor()); //$NON-NLS-1$
+               expand(ti, "getErrorParserIDs()", bd.getErrorParserIDs()); //$NON-NLS-1$
+               create(ti, "getId()", bd.getId()); //$NON-NLS-1$
+               create(ti, "getName()", bd.getName()); //$NON-NLS-1$
+               expand(ti, "getOutputDirectories()", bd.getOutputDirectories()); //$NON-NLS-1$
+               create(ti, "getType()", bd.getType()); //$NON-NLS-1$
+               create(ti, "isValid()",bd.isValid()); //$NON-NLS-1$
+               return ti;
+       }
+       
+       private TreeItem update(TreeItem ti0, String text, CConfigurationData cd) {
+               TreeItem ti = createObj(ti0, text, cd == null ? NULL : cd.getName(), cd);
+               if (cd == null || !check(ti, cd)) return ti;
+               update(ti, "getBuildData()", cd.getBuildData()); //$NON-NLS-1$
+               createObj(ti, "getBuildVariablesContributor()", EMPTY_STR, cd.getBuildVariablesContributor()); //$NON-NLS-1$
+               create(ti, "getDescription()", cd.getDescription()); //$NON-NLS-1$
+               create(ti, "getId()", cd.getId()); //$NON-NLS-1$
+               create(ti, "getName()", cd.getName()); //$NON-NLS-1$
+               expand(ti, "getResourceDatas()", cd.getResourceDatas()); //$NON-NLS-1$
+               update(ti, "getRootFolderData()", cd.getRootFolderData()); //$NON-NLS-1$
+//             expand(ti, "getSourcePaths()", cd.getSourcePaths()); //$NON-NLS-1$
+               update(ti, "getTargetPlatformData()", cd.getTargetPlatformData()); //$NON-NLS-1$
+               create(ti,"getType()",cd.getType()); //$NON-NLS-1$
+               create(ti,"isValid()",cd.isValid()); //$NON-NLS-1$
+               return ti;
+       }
+
+       private TreeItem update(TreeItem ti0, String text, CLanguageData ls) {
+               TreeItem ti = createObj(ti0, text, ls == null ? NULL : ls.getName(), ls);
+               if (ls == null || !check(ti, ls)) return ti;
+               create(ti, "getId()", ls.getId()); //$NON-NLS-1$
+               create(ti, "getLanguageId()", ls.getLanguageId()); //$NON-NLS-1$
+               create(ti, "getName()", ls.getName()); //$NON-NLS-1$
+               expand(ti, "getSourceContentTypeIds()", ls.getSourceContentTypeIds()); //$NON-NLS-1$
+               expand(ti, "getSourceExtensions()", ls.getSourceExtensions()); //$NON-NLS-1$
+               create(ti,"getType()",ls.getType()); //$NON-NLS-1$
+               int k = ls.getSupportedEntryKinds(); 
+               TreeItem ti1 = create(ti, "getSupportedEntryKinds()", k); //$NON-NLS-1$
+               int[] kind = flagsToArray(k);
+               for (int element : kind) {
+                       TreeItem ti2 = create(ti1, "Kind", element); //$NON-NLS-1$
+                       expand(ti2, "getEntries",ls.getEntries(element)); //$NON-NLS-1$
+               }
+               create(ti,"isValid()",ls.isValid()); //$NON-NLS-1$
+               return ti;
+       }
+               
+       private TreeItem update(TreeItem ti0, String text, CResourceData bd) {
+               TreeItem ti = createObj(ti0, text, bd == null ? NULL : bd.getName(), bd);
+               if (bd == null || !check(ti, bd)) return ti;
+               create(ti, "getId()", bd.getId()); //$NON-NLS-1$
+               if (bd instanceof CFolderData) 
+                   expand(ti, "getLanguageDatas()", ((CFolderData)bd).getLanguageDatas()); //$NON-NLS-1$
+               create(ti, "getName()", bd.getName()); //$NON-NLS-1$
+               update(ti,"getPath()",bd.getPath()); //$NON-NLS-1$ 
+               create(ti,"getType()",bd.getType()); //$NON-NLS-1$
+//             create(ti,"isExcluded()",bd.isExcluded()); //$NON-NLS-1$
+               create(ti,"isValid()",bd.isValid()); //$NON-NLS-1$
+               return ti;
+       }
+
+       private TreeItem update(TreeItem ti0, String text, CTargetPlatformData bd) {
+               TreeItem ti = createObj(ti0, text, bd == null ? NULL : bd.getName(), bd);
+               if (bd == null || !check(ti, bd)) return ti;
+               expand(ti, "getBinaryParserIds()", bd.getBinaryParserIds()); //$NON-NLS-1$
+               create(ti, "getId()", bd.getId()); //$NON-NLS-1$
+               create(ti, "getName()", bd.getName()); //$NON-NLS-1$
+               create(ti, "getType()",bd.getType()); //$NON-NLS-1$
+               create(ti, "isValid()",bd.isValid()); //$NON-NLS-1$
+               return ti;
+       }
+       private TreeItem update(TreeItem ti0, String text, ICBuildSetting obj) {
+               TreeItem ti = createObj(ti0, text, obj == null ? NULL : obj.getName(), obj);
+               if (obj == null || !check(ti, obj)) return ti;
+               // ALMOST THE SAME AS CBuildData
+               update(ti, "getBuilderCWD()", obj.getBuilderCWD()); //$NON-NLS-1$
+               createObj(ti, "getBuildEnvironmentContributor()", EMPTY_STR, obj.getBuildEnvironmentContributor()); //$NON-NLS-1$
+               ICConfigurationDescription cd = obj.getConfiguration();
+               createObj(ti, "getConfiguration()", cd == null ? NULL : cd.getName(), cd); //$NON-NLS-1$
+               expand(ti, "getErrorParserIDs()", obj.getErrorParserIDs()); //$NON-NLS-1$
+               create(ti, "getId()", obj.getId()); //$NON-NLS-1$
+               create(ti, "getName()", obj.getName()); //$NON-NLS-1$
+               expand(ti, "getOutputDirectories()", obj.getOutputDirectories()); //$NON-NLS-1$
+               update(ti, "getParent()", obj.getParent()); //$NON-NLS-1$
+               create(ti, "getType()", obj.getType()); //$NON-NLS-1$
+               create(ti, "isReadOnly()", obj.isReadOnly()); //$NON-NLS-1$
+               create(ti, "isValid()",obj.isValid()); //$NON-NLS-1$
+               return ti;
+       }
+       private TreeItem update(TreeItem ti0, String text, ICConfigurationDescription cfg) {
+               TreeItem ti = createObj(ti0, text, cfg == null ? NULL : cfg.getName(), cfg);
+               if (cfg == null || !check(ti, cfg)) return ti;
+               if (getDepth(ti) > NESTING_CFG) return ti;
+               
+               update(ti, "getBuildSetting()", cfg.getBuildSetting()); //$NON-NLS-1$
+               create(ti, "getBuildSystemId()", cfg.getBuildSystemId()); //$NON-NLS-1$
+               createObj(ti, "getBuildVariablesContributor()", EMPTY_STR, cfg.getBuildVariablesContributor()); //$NON-NLS-1$
+               update(ti, "getConfigurationData()", cfg.getConfigurationData()); //$NON-NLS-1$
+               create(ti, "getDescription()", cfg.getDescription()); //$NON-NLS-1$
+               expand(ti, "getExternalSettings()", cfg.getExternalSettings()); //$NON-NLS-1$
+               expand(ti, "getFileDescriptions()", cfg.getFileDescriptions()); //$NON-NLS-1$
+               expand(ti, "getFolderDescriptions()", cfg.getFolderDescriptions()); //$NON-NLS-1$
+               create(ti, "getId()", cfg.getId()); //$NON-NLS-1$
+               create(ti, "getName()", cfg.getName()); //$NON-NLS-1$
+               update(ti, "getParent()", cfg.getParent()); //$NON-NLS-1$
+               update(ti, "getReferenceInfo()", cfg.getReferenceInfo()); //$NON-NLS-1$
+               expand(ti, "getResourceDescriptions()", cfg.getResourceDescriptions()); //$NON-NLS-1$
+               update(ti, "getRootFolderDescription()", cfg.getRootFolderDescription()); //$NON-NLS-1$
+               expand(ti, "getSourceEntries()", cfg.getSourceEntries()); //$NON-NLS-1$
+               update(ti, "getTargetPlatformSetting()", cfg.getTargetPlatformSetting()); //$NON-NLS-1$
+               create(ti,"getType()",cfg.getType()); //$NON-NLS-1$
+               create(ti,"isActive()",cfg.isActive()); //$NON-NLS-1$
+               create(ti,"isModified()",cfg.isModified()); //$NON-NLS-1$
+               create(ti,"isPreferenceConfiguration()",cfg.isPreferenceConfiguration()); //$NON-NLS-1$
+               create(ti,"isReadOnly()",cfg.isReadOnly()); //$NON-NLS-1$
+               create(ti,"isValid()",cfg.isValid()); //$NON-NLS-1$
+               return ti;
+       }
+
+       private TreeItem update(TreeItem ti0, String text, ICExclusionPatternPathEntry s) {
+               TreeItem ti = createObj(ti0, text, s.getName(), s);
+               if (!check(ti, s)) return ti;
+               char[][] chrs = s.fullExclusionPatternChars();
+               TreeItem ti1 = create(ti, "fullExclusionPatternChars()", chrs.length); //$NON-NLS-1$
+               for (int j=0; j<chrs.length; j++) 
+                       create(ti1, BL+j+BR, new String(chrs[j]));
+               expand(ti, "getExclusionPatterns()", s.getExclusionPatterns()); //$NON-NLS-1$
+               create(ti,"getFlags()", s.getFlags()); //$NON-NLS-1$
+               update(ti, "getFullPath()", s.getFullPath()); //$NON-NLS-1$
+               create(ti,"getKind()", s.getKind()); //$NON-NLS-1$
+               update(ti, "getLocation()", s.getLocation()); //$NON-NLS-1$
+               create(ti, "getName()", s.getName()); //$NON-NLS-1$
+               create(ti, "getValue()", s.getValue()); //$NON-NLS-1$
+               create(ti, "isBuiltIn()", s.isBuiltIn()); //$NON-NLS-1$ 
+               create(ti, "isReadOnly()", s.isReadOnly()); //$NON-NLS-1$
+               create(ti, "isResolved()", s.isResolved()); //$NON-NLS-1$
+               create(ti, "isValueWorkspacePath()", s.isValueWorkspacePath()); //$NON-NLS-1$
+               return ti;
+       }
+
+       private TreeItem update(TreeItem ti0, String text, ICExternalSetting es) {
+               TreeItem ti = createObj(ti0, text, EMPTY_STR, es);
+               if (!check(ti, es)) return ti;
+               expand(ti, "getCompatibleContentTypeIds()", es.getCompatibleContentTypeIds()); //$NON-NLS-1$
+               expand(ti, "getCompatibleExtensions()", es.getCompatibleExtensions()); //$NON-NLS-1$
+               expand(ti, "getCompatibleLanguageIds()", es.getCompatibleLanguageIds()); //$NON-NLS-1$
+               expand(ti, "getEntries()", es.getEntries()); //$NON-NLS-1$
+               return ti;
+       }
+       private TreeItem update(TreeItem ti0, String text, ICResourceDescription rcfg) {
+               TreeItem ti = createObj(ti0, text, rcfg == null ? NULL : rcfg.getName(), rcfg);
+               if (rcfg == null || !check(ti, rcfg)) return ti;
+               update(ti, "getConfiguration()", rcfg.getConfiguration()); //$NON-NLS-1$
+               create(ti, "getId()", rcfg.getId()); //$NON-NLS-1$
+               create(ti, "getName()", rcfg.getName()); //$NON-NLS-1$
+               if (rcfg instanceof ICFileDescription)
+                       update(ti, "getLanguageSettings()", ((ICFileDescription)rcfg).getLanguageSetting()); //$NON-NLS-1$
+               else if (rcfg instanceof ICFolderDescription) {
+                       expand(ti, "getLanguageSettings()", ((ICFolderDescription)rcfg).getLanguageSettings()); //$NON-NLS-1$
+                       ICResourceDescription[] rds = ((ICFolderDescription)rcfg).getNestedResourceDescriptions();
+                       if (getDepth(ti) > NESTING_CFG) 
+                               create(ti, "getNestedResourceDescriptions()", rds.length); //$NON-NLS-1$
+                       else
+                               expand(ti, "getNestedResourceDescriptions()", rds); //$NON-NLS-1$
+               }
+               update(ti, "getParent()", rcfg.getParent()); //$NON-NLS-1$
+               update(ti, "getParentFolderDescription()", rcfg.getParentFolderDescription()); //$NON-NLS-1$
+               update(ti, "getPath()", rcfg.getPath()); //$NON-NLS-1$
+               create(ti, "getType()", rcfg.getType()); //$NON-NLS-1$
+               create(ti,"isExcluded()", rcfg.isExcluded()); //$NON-NLS-1$
+               create(ti,"isReadOnly()", rcfg.isReadOnly()); //$NON-NLS-1$
+               if (rcfg instanceof ICFolderDescription)
+                       create(ti,"isRoot()",((ICFolderDescription)rcfg).isRoot()); //$NON-NLS-1$
+               create(ti,"isValid()",rcfg.isValid()); //$NON-NLS-1$
+               return ti;
+       }       
+       private TreeItem update(TreeItem ti0, String text, ICLanguageSetting ls) {
+               TreeItem ti = createObj(ti0, text, ls == null ? NULL : ls.getName(), ls);
+               if (ls == null || !check(ti, ls)) return ti;
+               update(ti, "getConfiguration()", ls.getConfiguration()); //$NON-NLS-1$
+               create(ti, "getId()", ls.getId()); //$NON-NLS-1$
+               create(ti, "getLanguageId()", ls.getLanguageId()); //$NON-NLS-1$
+               create(ti, "getName()", ls.getName()); //$NON-NLS-1$
+               update(ti, "getParent()", ls.getParent()); //$NON-NLS-1$
+               expand(ti, "getSourceContentTypeIds()", ls.getSourceContentTypeIds()); //$NON-NLS-1$
+               expand(ti, "getSourceExtensions()", ls.getSourceExtensions()); //$NON-NLS-1$
+               create(ti,"getType()",ls.getType()); //$NON-NLS-1$
+               int k = ls.getSupportedEntryKinds();
+               TreeItem ti1 = create(ti, "getSupportedEntryKinds()", k); //$NON-NLS-1$
+               int[] kind = flagsToArray(k);
+               for (int element : kind) {
+                       TreeItem ti2 = create(ti1, "Kind", element); //$NON-NLS-1$
+                       expand(ti2, "getResolvedSettingEntries",ls.getResolvedSettingEntries(element)); //$NON-NLS-1$
+                       expand(ti2, "getSettingEntries", ls.getSettingEntries(element)); //$NON-NLS-1$
+               }
+               create(ti,"isReadOnly()",ls.isReadOnly()); //$NON-NLS-1$
+               create(ti,"isValid()",ls.isValid()); //$NON-NLS-1$
+               return ti;
+       }
+
+       private TreeItem update(TreeItem ti0, String text, ICLanguageSettingEntry ent) {
+               TreeItem ti = createObj(ti0, text, ent == null ? NULL : ent.getName(), ent);
+               if (ent == null || !check(ti, ent)) return ti;
+               create(ti, "getFlags()", ent.getFlags()); //$NON-NLS-1$
+               create(ti, "getKind()", ent.getKind()); //$NON-NLS-1$
+               create(ti, "getName()", ent.getName()); //$NON-NLS-1$
+               create(ti, "getValue()", ent.getValue()); //$NON-NLS-1$
+               create(ti, "isBuiltIn()", ent.isBuiltIn()); //$NON-NLS-1$
+               create(ti, "isReadOnly()", ent.isReadOnly()); //$NON-NLS-1$
+               create(ti, "isResolved()", ent.isResolved()); //$NON-NLS-1$
+               return ti;
+       }
+
+       private TreeItem update(TreeItem ti0, String text, ICSettingContainer c) {
+               TreeItem ti = createObj(ti0, text, EMPTY_STR, c);
+               if (!check(ti, c)) return ti;
+               if (getDepth(ti) > NESTING_CFG) return ti;
+               expand(ti, "getChildSettings()", c.getChildSettings()); //$NON-NLS-1$
+               return ti;
+       }       
+       
+       private TreeItem update(TreeItem ti0, String text, ICSettingObject obj) {
+               TreeItem ti = createObj(ti0, text, obj == null ? NULL : obj.getName(), obj);
+               if (obj == null || !check(ti, obj)) return ti;
+               if (obj instanceof ICTargetPlatformSetting)
+                       expand(ti, "getBinaryParserIds()", ((ICTargetPlatformSetting)obj).getBinaryParserIds()); //$NON-NLS-1$
+               update(ti, "getConfiguration()", obj.getConfiguration()); //$NON-NLS-1$
+               create(ti, "getId()", obj.getId()); //$NON-NLS-1$
+               create(ti, "getName()", obj.getName()); //$NON-NLS-1$
+               createObj(ti, "getParent()", EMPTY_STR, obj.getParent()); //$NON-NLS-1$
+               create(ti, "getType()", obj.getType()); //$NON-NLS-1$
+               create(ti,"isReadOnly()", obj.isReadOnly()); //$NON-NLS-1$
+               create(ti,"isValid()",obj.isValid()); //$NON-NLS-1$
+               return ti;
+       }
+
+       private TreeItem update(TreeItem ti0, String text, ICTargetPlatformSetting obj) {
+               TreeItem ti = createObj(ti0, text, obj == null ? NULL : obj.getName(), obj);
+               if (obj == null || !check(ti, obj)) return ti;
+               update(ti, "getConfiguration()", obj.getConfiguration()); //$NON-NLS-1$
+               create(ti, "getId()", obj.getId()); //$NON-NLS-1$
+               create(ti, "getName()", obj.getName()); //$NON-NLS-1$
+               update(ti, "getParent()", obj.getParent()); //$NON-NLS-1$
+               create(ti, "getType()", obj.getType()); //$NON-NLS-1$
+               create(ti,"isReadOnly()", obj.isReadOnly()); //$NON-NLS-1$
+               create(ti,"isValid()",obj.isValid()); //$NON-NLS-1$
+               return ti;
+       }
+
+       private TreeItem update(TreeItem ti0, String text, IPath p) {
+               TreeItem ti = createObj(ti0, text, p == null ? NULL : p.toString(), p);
+               if (p == null || !check(ti, p)) return ti;
+               create(ti, "getDevice()", p.getDevice()); //$NON-NLS-1$ 
+               create(ti, "getFileExtension()", p.getFileExtension()); //$NON-NLS-1$
+               create(ti, "hasTrailingSeparator()", p.hasTrailingSeparator()); //$NON-NLS-1$
+               create(ti, "isAbsolute()", p.isAbsolute()); //$NON-NLS-1$
+               create(ti, "isEmpty()", p.isEmpty()); //$NON-NLS-1$
+               create(ti, "isRoot()", p.isRoot()); //$NON-NLS-1$
+               create(ti, "isUNC()", p.isUNC()); //$NON-NLS-1$
+               TreeItem ti1 = create(ti, "segmentCount()", p.segmentCount()); //$NON-NLS-1$
+               for (int i=0; i<p.segmentCount(); i++) 
+                       create(ti1, "segment("+i+")", p.segment(i)); //$NON-NLS-1$  //$NON-NLS-2$ 
+               create(ti, "toOSString()", p.toOSString()); //$NON-NLS-1$
+               create(ti, "toPortableString()", p.toPortableString()); //$NON-NLS-1$
+               return ti;
+       }
+       private TreeItem update(TreeItem ti0, String text, IProject prj) {
+               TreeItem ti = createObj(ti0, text, prj == null ? NULL : prj.getName(), prj);
+               if (prj == null || !check(ti, prj)) return ti;
+               create(ti, "exists()", prj.exists()); //$NON-NLS-1$
+               try {
+                       create(ti, "getDefaultCharset()", prj.getDefaultCharset()); //$NON-NLS-1$
+                       prj.getDescription();
+               } catch (CoreException e) {}
+               update(ti, "getFullPath()", prj.getFullPath()); //$NON-NLS-1$
+               create(ti, "getName()", prj.getName()); //$NON-NLS-1$
+               update(ti, "getParent()", prj.getParent()); //$NON-NLS-1$
+               try {
+                       IProject[] ps = prj.getReferencedProjects();
+                       TreeItem ti1 = create(ti, "getReferencedProjects()", ps == null ? 0 : ps.length); //$NON-NLS-1$
+                       if (ps != null)
+                               for (int i=0; i<ps.length; i++) update(ti1, BL+i+BR, ps[i]);
+               } catch (CoreException e) {}                    
+               prj.getResourceAttributes();
+               create(ti, "getType()", prj.getType()); //$NON-NLS-1$
+               update(ti, "getWorkspace()", prj.getWorkspace()); //$NON-NLS-1$
+               return ti;
+       }
+       
+       private TreeItem update(TreeItem ti0, String text, IProjectNatureDescriptor nd) {
+               TreeItem ti = createObj(ti0, text, nd == null ? NULL : nd.getLabel(), nd);
+               if (nd == null || !check(ti, nd)) return ti;
+               create(ti, "getLabel()", nd.getLabel()); //$NON-NLS-1$
+               create(ti, "getNatureId()", nd.getNatureId()); //$NON-NLS-1$
+               expand(ti, "getNatureSetIds()", nd.getNatureSetIds()); //$NON-NLS-1$
+               expand(ti, "getRequiredNatureIds()", nd.getRequiredNatureIds()); //$NON-NLS-1$
+               create(ti, "isLinkingAllowed()", nd.isLinkingAllowed()); //$NON-NLS-1$
+               return ti;
+       }
+
+       private TreeItem update(TreeItem ti0, String text, IResource c) {
+               TreeItem ti = createObj(ti0, text, c == null ? NULL : c.getName(), c);
+               if (c == null || !check(ti, c)) return ti;
+               if (getDepth(ti) > NESTING_CFG) return ti;
+               
+               if (c instanceof IContainer)
+                       try {
+                               create(ti, "getDefaultCharset()", ((IContainer)c).getDefaultCharset()); //$NON-NLS-1$
+                       } catch (CoreException e) {}
+               create(ti, "getFileExtension()", c.getFileExtension()); //$NON-NLS-1$
+               update(ti, "getFullPath()", c.getFullPath()); //$NON-NLS-1$
+// TODO:               
+//             c.getLocalTimeStamp());
+               update(ti, "getLocation()", c.getLocation()); //$NON-NLS-1$
+               update(ti, "getLocationURI()", c.getLocationURI()); //$NON-NLS-1$
+//             c.getModificationStamp());
+               create(ti, "getName()", c.getName()); //$NON-NLS-1$
+               update(ti, "getParent()", c.getParent()); //$NON-NLS-1$
+               update(ti, "getProject()", c.getProject()); //$NON-NLS-1$
+               if (c instanceof IWorkspaceRoot)
+                       expand(ti, "getProjects()", ((IWorkspaceRoot)c).getProjects()); //$NON-NLS-1$
+               update(ti, "getProjectRelativePath()", c.getProjectRelativePath()); //$NON-NLS-1$
+               update(ti, "getRawLocation()", c.getRawLocation()); //$NON-NLS-1$
+               update(ti, "getRawLocationURI()", c.getRawLocationURI()); //$NON-NLS-1$
+               update(ti, "getResourceAttributes()", c.getResourceAttributes()); //$NON-NLS-1$
+               create(ti, "getType()", c.getType()); //$NON-NLS-1$
+               createObj(ti, "getWorkspace()", EMPTY_STR, c.getWorkspace()); //$NON-NLS-1$
+               create(ti, "isAccessible()", c.isAccessible()); //$NON-NLS-1$
+               create(ti, "isDerived()", c.isDerived()); //$NON-NLS-1$
+               create(ti, "isLinked()", c.isLinked()); //$NON-NLS-1$
+       //      create(ti, "isLocal(ZERO)", c.isLocal(0)); //$NON-NLS-1$
+       //      create(ti, "isLocal(INIFINITE)", c.isLocal(2)); //$NON-NLS-1$
+               create(ti, "isPhantom()", c.isPhantom()); //$NON-NLS-1$
+       //      create(ti, "isReadOnly()", c.isReadOnly()); //$NON-NLS-1$
+               create(ti, "isSynchronized(ZERO)", c.isSynchronized(0)); //$NON-NLS-1$
+               create(ti, "isSynchronized(INFINITE)", c.isSynchronized(2)); //$NON-NLS-1$
+               create(ti, "isTeamPrivateMember()", c.isTeamPrivateMember()); //$NON-NLS-1$
+               if (c instanceof IContainer)
+                       try {
+                               expand(ti, "members()", ((IContainer)c).members()); //$NON-NLS-1$
+                       } catch (CoreException e) {}
+               return ti;
+       }
+
+       private TreeItem update(TreeItem ti0, String text, IWorkspace w) {
+               TreeItem ti = createObj(ti0, text, EMPTY_STR, w);
+               if (!check(ti, w)) return ti;
+               update(ti, "getDescription()", w.getDescription()); //$NON-NLS-1$
+               expand(ti, "getNatureDescriptors()", w.getNatureDescriptors()); //$NON-NLS-1$
+               createObj(ti, "getPathVariableManager()", EMPTY_STR, w.getPathVariableManager()); //$NON-NLS-1$
+               update(ti, "getRoot()", w.getRoot()); //$NON-NLS-1$
+               createObj(ti, "getSynchronizer()", EMPTY_STR, w.getSynchronizer()); //$NON-NLS-1$
+               create(ti, "isAutoBuilding()", w.isAutoBuilding()); //$NON-NLS-1$
+               create(ti, "isTreeLocked()", w.isTreeLocked()); //$NON-NLS-1$
+               return ti;
+       }
+
+       private TreeItem update(TreeItem ti0, String text, IWorkspaceDescription w) {
+               TreeItem ti = createObj(ti0, text, EMPTY_STR, w);
+               if (!check(ti, w)) return ti;
+               expand(ti, "getBuildOrder()", w.getBuildOrder()); //$NON-NLS-1$
+               create(ti, "getFileStateLongevity()", w.getFileStateLongevity()); //$NON-NLS-1$
+               create(ti, "getMaxBuildIterations()", w.getMaxBuildIterations()); //$NON-NLS-1$
+               create(ti, "getMaxFileStates()", w.getMaxFileStates()); //$NON-NLS-1$
+               create(ti, "getMaxFileStateSize()", w.getMaxFileStateSize()); //$NON-NLS-1$
+               create(ti, "getSnapshotInterval()", w.getSnapshotInterval()); //$NON-NLS-1$
+               create(ti, "isAutoBuilding()", w.isAutoBuilding()); //$NON-NLS-1$
+               return ti;
+       }
+
+       /*
+        * Default method to display unknown classes
+        */
+       private TreeItem update(TreeItem ti0, String text, Object ob) {
+               TreeItem ti = createObj(ti0, BL+text+BR, "???", ob); //$NON-NLS-1$
+               check(ti, ob);
+               return ti;
+       }
+       
+       private TreeItem update(TreeItem ti0, String text, Map<String,String> m) {
+               String s = (m == null) ? NULL : String.valueOf(m.size());
+               TreeItem ti = createObj(ti0, text, s, m);
+               if (m == null || !check(ti, m)) return ti;
+               Iterator<String> it = m.keySet().iterator();
+               while (it.hasNext()) {
+                       s = it.next();
+                       create(ti, s + " =", m.get(s)); //$NON-NLS-1$
+               }
+               return ti;
+       }
+       
+       private TreeItem update(TreeItem ti0, String text, ResourceAttributes ra) {
+               TreeItem ti = createObj(ti0, text, EMPTY_STR, ra);
+               if (!check(ti, ra)) return ti;
+               create(ti, "isArchive()", ra.isArchive()); //$NON-NLS-1$
+               create(ti, "isExecutable()", ra.isExecutable()); //$NON-NLS-1$
+               create(ti, "isHidden()", ra.isHidden()); //$NON-NLS-1$
+               create(ti, "isReadOnly()", ra.isReadOnly()); //$NON-NLS-1$
+               return ti;
+       }
+
+       private TreeItem update(TreeItem ti0, String text, URI uri) {
+               TreeItem ti = createObj(ti0, text, uri == null ? NULL : uri.toString(), uri);
+               if (uri == null || !check(ti, uri)) return ti;
+               create(ti, "getAuthority()", uri.getAuthority()); //$NON-NLS-1$
+               create(ti, "getFragment()", uri.getFragment()); //$NON-NLS-1$
+               create(ti, "getHost()", uri.getHost()); //$NON-NLS-1$
+               create(ti, "getPath()", uri.getPath()); //$NON-NLS-1$
+               create(ti, "getPort()", uri.getPort()); //$NON-NLS-1$
+               create(ti, "getQuery()", uri.getQuery()); //$NON-NLS-1$
+               create(ti, "isAbsolute()", uri.isAbsolute()); //$NON-NLS-1$
+               create(ti, "isOpaque()", uri.isOpaque()); //$NON-NLS-1$
+               create(ti, "toASCIIString()", uri.toASCIIString()); //$NON-NLS-1$
+               return ti;
+       }
+       
+       @Override
+       public void updateData(ICResourceDescription rcfg) {
+               cfg = rcfg;
+               tree.getDisplay().asyncExec(new Runnable() {
+                       public void run() {
+                               try {
+                                       tree.removeAll();
+                                       TreeItem ti = new TreeItem(tree, 0);
+                                       ti.setText(0, Messages.StructureTreeTab_11); 
+                                       tree.update();
+                                       tree.setRedraw(false);
+                                       tree.removeAll();
+                                       switch (combo.getSelectionIndex()) {
+                                       case 0:
+                                               update(cfg.getConfiguration().getProjectDescription());
+                                               break;
+                                       case 1: 
+                                               update(null, "ICConfigurationDescription", cfg.getConfiguration()); //$NON-NLS-1$
+                                               break;
+                                       case 2: 
+                                               update(null, "ICResourceDescription", cfg); //$NON-NLS-1$
+                                               break;
+                                       }
+                               } finally {
+                                       tree.setRedraw(true);
+                               }
+                       }
+               });
+       }
+       
+       // This page can be displayed if it's permitted in prefs
+       @Override
+       public boolean canBeVisible() {
+               return CDTPrefUtil.getBool(CDTPrefUtil.KEY_DTREE);
+       }
+
+       @Override
+       protected void updateButtons() {} // Do nothing. No buttons to update.
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolDialog.java
new file mode 100644 (file)
index 0000000..e7d4c9f
--- /dev/null
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+//import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.core.settings.model.ICResourceDescription;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class SymbolDialog extends AbstractPropertyDialog {
+       private String  data1;
+       private String  data2;
+       private Button b_add2conf;
+       private Button b_add2lang;
+       private Text txt1;
+       private Text txt2;
+       private Button b_vars;
+       private Button b_ok;
+       private Button b_ko;
+       private boolean newAction;
+       private ICResourceDescription cfgd;
+
+       public SymbolDialog(Shell parent, boolean _newAction,
+               String title, String _data1, String _data2,
+               ICResourceDescription _cfgd) {
+               super(parent, title);
+               data1 = _data1;
+               data2 = _data2;
+               newAction = _newAction;
+               cfgd = _cfgd;
+       }
+
+       @Override
+       protected Control createDialogArea(Composite c) {
+               c.setLayout(new GridLayout(4, true));
+               GridData gd;
+               
+               Label l1 = new Label(c, SWT.NONE);
+               l1.setText(Messages.SymbolDialog_0); 
+               l1.setLayoutData(new GridData(GridData.BEGINNING));
+               
+               txt1 = new Text(c, SWT.SINGLE | SWT.BORDER);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = 3;
+               gd.widthHint = 300;
+               txt1.setLayoutData(gd);
+               txt1.addModifyListener(new ModifyListener() {
+                       public void modifyText(ModifyEvent e) {
+                               setButtons();
+                       }}); 
+               
+               Label l2 = new Label(c, SWT.NONE);
+               l2.setText(Messages.SymbolDialog_1); 
+               l2.setLayoutData(new GridData(GridData.BEGINNING));
+               
+               txt2 = new Text(c, SWT.SINGLE | SWT.BORDER);
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = 2;
+               gd.widthHint = 200;
+               txt2.setLayoutData(gd);
+               txt2.addModifyListener(new ModifyListener() {
+                       public void modifyText(ModifyEvent e) {
+                               setButtons();
+                       }}); 
+
+               b_vars = setupButton(c, AbstractCPropertyTab.VARIABLESBUTTON_NAME);
+                       
+               b_add2conf = new Button(c, SWT.CHECK);
+               b_add2conf.setText(Messages.IncludeDialog_2); 
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = 4;
+               b_add2conf.setLayoutData(gd);
+               if (!newAction) {
+                       b_add2conf.setVisible(false);
+                       txt1.setEnabled(false); // don't change name
+               }
+
+               b_add2lang = new Button(c, SWT.CHECK);
+               b_add2lang.setText(Messages.IncludeDialog_3); 
+               gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = 4;
+               b_add2lang.setLayoutData(gd);
+               if (!newAction) {
+                       b_add2lang.setVisible(false);
+                       txt1.setEnabled(false); // don't change name
+               }
+               
+               // add 2 placeholders
+               new Label(c, 0).setLayoutData(new GridData());
+               new Label(c, 0).setLayoutData(new GridData());
+               b_ok = setupButton(c, IDialogConstants.OK_LABEL);
+               b_ko = setupButton(c, IDialogConstants.CANCEL_LABEL);
+               
+               c.getShell().setDefaultButton(b_ok);
+               c.pack();
+
+               // moved here to avoid accessing b_ok before it created.
+               txt1.setText(data1);
+               txt2.setText(data2); 
+               
+               setButtons();
+               return c;
+       }       
+       
+       private void setButtons() {
+               b_ok.setEnabled(txt1.getText().trim().length() > 0);
+       }
+       
+       @Override
+       public void buttonPressed(SelectionEvent e) {
+               if (e.widget.equals(b_ok)) { 
+                       super.text1 = txt1.getText();
+                       super.text2 = txt2.getText();
+                       check1 = b_add2conf.getSelection(); 
+                       check3 = b_add2lang.getSelection(); 
+                       result = true;
+                       shell.dispose(); 
+               } else if (e.widget.equals(b_ko)) {
+                       shell.dispose();
+               } else if (e.widget.equals(b_vars)) {
+                       String s = AbstractCPropertyTab.getVariableDialog(shell, cfgd.getConfiguration());
+                       if (s != null) txt2.insert(s);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolTab.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolTab.java
new file mode 100644 (file)
index 0000000..08de5be
--- /dev/null
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *     IBM Corporation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import java.util.Collections;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleAdapter;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.TableColumn;
+
+import org.eclipse.cdt.core.model.util.CDTListComparator;
+import org.eclipse.cdt.core.settings.model.CMacroEntry;
+import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
+import org.eclipse.cdt.core.settings.model.ICSettingEntry;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class SymbolTab extends AbstractLangsListTab {
+    @Override
+       public void additionalTableSet() {
+       TableColumn tc = new TableColumn(table, SWT.LEFT);
+       tc.setText(Messages.SymbolTab_0); 
+       tc.setWidth(80);
+       tc.setToolTipText(Messages.SymbolTab_0); 
+       tc = new TableColumn(table, SWT.LEFT);
+       tc.setText(Messages.SymbolTab_1); 
+       tc.setWidth(130);
+       tc.setToolTipText(Messages.SymbolTab_1); 
+       table.getAccessible().addAccessibleListener(
+                               new AccessibleAdapter() {                       
+                    @Override
+                                       public void getName(AccessibleEvent e) {
+                            e.result = Messages.SymbolTab_0; 
+                    }
+                }
+                 );
+    }
+
+       @Override
+       public ICLanguageSettingEntry doAdd() {
+               SymbolDialog dlg = new SymbolDialog(
+                               usercomp.getShell(), true,
+                               Messages.SymbolTab_2, EMPTY_STR, EMPTY_STR, getResDesc()); 
+               if (dlg.open() && dlg.text1.trim().length() > 0 ) {
+                       toAllCfgs = dlg.check1;
+                       toAllLang = dlg.check3;
+                       return new CMacroEntry(dlg.text1, dlg.text2, 0);
+               }
+               return null;
+       }
+
+       @Override
+       public ICLanguageSettingEntry doEdit(ICLanguageSettingEntry ent) {
+               SymbolDialog dlg = new SymbolDialog(
+                               usercomp.getShell(), false,
+                               Messages.SymbolTab_3, ent.getName(),  
+                               ent.getValue(), getResDesc());
+               if (dlg.open())
+                       return new CMacroEntry(dlg.text1, dlg.text2, 0);
+               return null;
+       }
+       
+       @Override
+       public int getKind() { 
+               return ICSettingEntry.MACRO; 
+       }
+
+       // Specific version of "update()" for Symbols tab only
+       @Override
+       public void update() {
+               if (lang != null) {
+                       int x = table.getSelectionIndex();
+                       if (x == -1) 
+                               x = 0;
+                       shownEntries = getIncs();
+                       Collections.sort(shownEntries, CDTListComparator.getInstance());
+                       tv.setInput(shownEntries.toArray(new Object[shownEntries.size()]));
+                       if (table.getItemCount() > x)
+                               table.setSelection(x);
+                       else if (table.getItemCount() > 0) 
+                               table.setSelection(0);
+               }               
+               updateStringListModeControl();
+               updateButtons();
+       }
+       
+       
+       @Override
+       public void createControls(final Composite parent) {
+               super.createControls(parent);
+               showBIButton.setSelection(true);
+               ImportExportWizardButtons.addWizardLaunchButtons(usercomp, page.getElement());
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/TypedCDTViewerFilter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/TypedCDTViewerFilter.java
new file mode 100644 (file)
index 0000000..64c9b94
--- /dev/null
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+/**
+ * see org.eclipse.cdt.internal.ui.dialogs.TypedViewerFilter
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class TypedCDTViewerFilter extends ViewerFilter {
+
+       private Class<?>[] types;
+
+       public TypedCDTViewerFilter(Class<?>[] _types) { types= _types; }
+       /**
+        * @see ViewerFilter#select
+        */
+       @Override
+       public boolean select(Viewer viewer, Object parent, Object element) {
+               for (Class<?> type : types) {
+                       if (type.isInstance(element)) return true;
+               }
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/UIMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/UIMessages.java
new file mode 100644 (file)
index 0000000..c5554d4
--- /dev/null
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ *  Copyright (c) 2004, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *  IBM - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.newui;
+
+import com.ibm.icu.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * @since 2.0
+ * @noextend This class is not intended to be subclassed by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ * @deprecated As of CDT 8.0. For internalization {@link org.eclipse.cdt.internal.ui.newui.Messages} is used.
+ */
+@Deprecated
+public class UIMessages {
+       // Bundle ID
+       private static final String BUNDLE_ID = "org.eclipse.cdt.internal.ui.newui.Messages"; //$NON-NLS-1$
+       //Resource bundle.
+       private static ResourceBundle resourceBundle;
+
+       static {
+               try {
+                       resourceBundle = ResourceBundle.getBundle(BUNDLE_ID);
+               } catch (MissingResourceException x) {
+                       resourceBundle = null;
+               }
+       }
+
+       private static String toNlsFormatKey(String key) {
+               return key.replace('.', '_');
+       }
+       public static String getFormattedString(String key, String arg) {
+               key = toNlsFormatKey(key);
+               return MessageFormat.format(getString(key), new String[] { arg });
+       }
+
+       public static String getFormattedString(String key, String[] args) {
+               key = toNlsFormatKey(key);
+               return MessageFormat.format(getString(key), args);
+       }
+
+       public static String getString(String key) {
+               key = toNlsFormatKey(key);
+               try {
+                       return resourceBundle.getString(key);
+               } catch (MissingResourceException e) {
+                       return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$
+               } catch (NullPointerException e) {
+                       return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$
+               }
+       }
+
+       private UIMessages() {
+               // No constructor
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/CTextFileChange.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/CTextFileChange.java
new file mode 100644 (file)
index 0000000..8c339a7
--- /dev/null
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 Wind River Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Markus Schorn (Wind River Systems) - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.refactoring;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.ContentStamp;
+import org.eclipse.ltk.core.refactoring.TextFileChange;
+import org.eclipse.text.edits.UndoEdit;
+
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+
+import org.eclipse.cdt.internal.core.model.TranslationUnit;
+
+import org.eclipse.cdt.internal.ui.refactoring.DocumentAdapter;
+import org.eclipse.cdt.internal.ui.refactoring.UndoCTextFileChange;
+
+
+/**
+ * A TextFileChange that uses a working copy in order to generate CModel events.
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class CTextFileChange extends TextFileChange {
+    // "c2" is the extension which the CContentViewerCreator is registered
+    // with the extension point "org.eclipse.compare.contentMergeViewers"
+    private static final String TEXT_TYPE = "c2"; //$NON-NLS-1$
+       private ITranslationUnit fTranslationUnit;
+    private IWorkingCopy fWorkingCopy;
+    private int fAquireCount;
+    
+    public CTextFileChange(String name, IFile file) {
+        super(name, file);
+        ICElement element = CoreModel.getDefault().create(file);
+        if (element instanceof ITranslationUnit) {
+            fTranslationUnit = (ITranslationUnit) element;
+            setTextType(TEXT_TYPE);
+        }
+    }
+    
+    /**
+        * @since 5.1
+        */
+    public CTextFileChange(String name, ITranslationUnit tu) {
+        super(name, getFile(tu));
+        fTranslationUnit = tu;
+        setTextType(TEXT_TYPE);
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.ltk.core.refactoring.TextFileChange#acquireDocument(org.eclipse.core.runtime.IProgressMonitor)
+     */
+    @Override
+       protected IDocument acquireDocument(IProgressMonitor pm) throws CoreException {
+        IDocument doc= super.acquireDocument(pm);
+        if (++fAquireCount == 1) {
+            if (fTranslationUnit instanceof TranslationUnit && fWorkingCopy == null) {
+                fWorkingCopy= ((TranslationUnit) fTranslationUnit).getWorkingCopy(null, DocumentAdapter.FACTORY);
+                if (!fTranslationUnit.isOpen()) {
+                    fTranslationUnit.open(null);
+                }
+            }
+        }
+        return doc;
+    }
+       
+    @Override
+       protected void commit(final IDocument document, final IProgressMonitor pm) throws CoreException {
+        if (fWorkingCopy == null) {
+               super.commit(document, pm);
+        }
+        else if (needsSaving()) {
+               fWorkingCopy.commit(false, pm);
+        }
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.ltk.core.refactoring.TextFileChange#releaseDocument(org.eclipse.jface.text.IDocument, org.eclipse.core.runtime.IProgressMonitor)
+     */
+    @Override
+       protected void releaseDocument(IDocument document, IProgressMonitor pm) throws CoreException {
+        super.releaseDocument(document, pm);
+        if (--fAquireCount == 0) {
+            if (fWorkingCopy != null) {
+                fWorkingCopy.destroy();
+                fWorkingCopy= null;
+            }
+        }
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.ltk.core.refactoring.TextFileChange#createUndoChange(org.eclipse.text.edits.UndoEdit, org.eclipse.ltk.core.refactoring.ContentStamp)
+     */
+    @Override
+       protected Change createUndoChange(UndoEdit edit, ContentStamp stampToRestore) {
+        return new UndoCTextFileChange(getName(), getFile(), edit, stampToRestore, getSaveMode());
+    }
+
+       private static IFile getFile(ITranslationUnit tu) {
+               return (IFile) tu.getResource();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/CRefactoringActionGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/CRefactoringActionGroup.java
new file mode 100644 (file)
index 0000000..9ade7e6
--- /dev/null
@@ -0,0 +1,296 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    IBM Rational Software - Initial API and implementation
+ *    Markus Schorn, Wind River Systems Inc. - ported for rename refactoring impl. 
+ *******************************************************************************/
+package org.eclipse.cdt.ui.refactoring.actions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.part.Page;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.ui.actions.CdtActionConstants;
+
+import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
+
+/**
+ * Action group that adds refactoring actions (for example Rename..., Move..., etc)
+ * to a context menu and the global menu bar.
+ * 
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ * 
+ * @since 2.0
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class CRefactoringActionGroup extends ActionGroup implements ISelectionChangedListener {
+    /**
+     * Pop-up menu: id of the refactor sub menu (value <code>org.eclipse.cdt.ui.refactoring.menu</code>).
+     * 
+     * @since 2.1
+     */
+    public static final String MENU_ID = "org.eclipse.cdt.ui.refactoring.menu"; //$NON-NLS-1$
+
+    /**
+     * Pop-up menu: id of the reorg group of the refactor sub menu (value
+     * <code>reorgGroup</code>).
+     * 
+     * @since 2.1
+     */
+    public static final String GROUP_REORG = "reorgGroup"; //$NON-NLS-1$
+
+    /**
+     * Pop-up menu: id of the type group of the refactor sub menu (value
+     * <code>typeGroup</code>).
+     * 
+     * @since 2.1
+     */
+    public static final String GROUP_TYPE = "typeGroup"; //$NON-NLS-1$
+
+    /**
+     * Pop-up menu: id of the coding group of the refactor sub menu (value
+     * <code>codingGroup</code>).
+     * 
+     * @since 2.1
+     */
+    public static final String GROUP_CODING = "codingGroup"; //$NON-NLS-1$
+       
+       /**
+        * Pop-up menu: id of the coding group 2 of the refactor sub menu (value
+        * <code>codingGroup2</code>).
+        * 
+        * @since 5.0
+        */
+       public static final String GROUP_CODING2= "codingGroup2"; //$NON-NLS-1$
+
+       /**
+        * Pop-up menu: id of the reorg group 2 of the refactor sub menu (value
+        * <code>reorgGroup2</code>).
+        * 
+        * @since 5.0
+        */
+       public static final String GROUP_REORG2= "reorgGroup2"; //$NON-NLS-1$
+       
+       /**
+        * Pop-up menu: id of the type group 2 of the refactor sub menu (value
+        * <code>typeGroup2</code>).
+        * 
+        * @since 5.0
+        */
+       public static final String GROUP_TYPE2= "typeGroup2"; //$NON-NLS-1$
+       
+       /**
+        * Pop-up menu: id of the type group 2 of the refactor sub menu (value
+        * <code>typeGroup3</code>).
+        * 
+        * @since 5.0
+        */
+       public static final String GROUP_TYPE3= "typeGroup3"; //$NON-NLS-1$
+
+    private String fGroupName= IWorkbenchActionConstants.GROUP_REORGANIZE;
+    private CRenameAction fRenameAction;
+    private RefactoringAction fExtractConstantAction;
+    private RefactoringAction fExtractLocalVariableAction;
+    private RefactoringAction fExtractFunctionAction;
+       private RefactoringAction fToggleFunctionAction;
+    private RefactoringAction fHideMethodAction;
+       private IWorkbenchSite fSite;
+       private List<RefactoringAction> fAllActions= new ArrayList<RefactoringAction>();
+
+    public CRefactoringActionGroup(IWorkbenchPart part) {
+       this(part, null);
+    }
+
+    public CRefactoringActionGroup(Page page) {
+        createActions(false);
+        setWorkbenchSite(page.getSite());
+    }
+
+    public CRefactoringActionGroup(IWorkbenchPart part, String groupName) {
+        if (groupName != null && groupName.length() > 0) {
+            fGroupName= groupName;
+        }
+        createActions(part instanceof ITextEditor);
+
+        if (part instanceof ITextEditor) {
+               setEditor((ITextEditor) part);
+        }
+        else {
+               setWorkbenchSite(part.getSite());
+        }
+    }
+
+       private void createActions(boolean forEditor) {
+               fRenameAction = new CRenameAction();
+        fRenameAction.setActionDefinitionId(ICEditorActionDefinitionIds.RENAME_ELEMENT);
+        fAllActions.add(fRenameAction);
+        
+        if (forEditor) {
+               fExtractConstantAction= new ExtractConstantAction();
+               fExtractConstantAction.setActionDefinitionId(ICEditorActionDefinitionIds.EXTRACT_CONSTANT);
+               fAllActions.add(fExtractConstantAction);
+               
+               fExtractLocalVariableAction= new ExtractLocalVariableAction();
+               fExtractLocalVariableAction.setActionDefinitionId(ICEditorActionDefinitionIds.EXTRACT_LOCAL_VARIABLE);
+               fAllActions.add(fExtractLocalVariableAction);
+
+               fExtractFunctionAction = new ExtractFunctionAction();
+                       fExtractFunctionAction.setActionDefinitionId(ICEditorActionDefinitionIds.EXTRACT_FUNCTION);
+                       fAllActions.add(fExtractFunctionAction);
+
+                       fToggleFunctionAction = new ToggleFunctionAction();
+                       fToggleFunctionAction.setActionDefinitionId(ICEditorActionDefinitionIds.TOGGLE_FUNCTION);
+                       fAllActions.add(fToggleFunctionAction);
+        }
+
+        fHideMethodAction = new HideMethodAction();
+        fHideMethodAction.setActionDefinitionId(ICEditorActionDefinitionIds.HIDE_METHOD);
+        fAllActions.add(fHideMethodAction);
+
+       }
+
+    public void setWorkbenchSite(IWorkbenchSite site) {
+               unregisterSite();
+        fSite= site;
+        
+        for (RefactoringAction action : fAllActions) {
+                       action.setSite(site);
+               }        
+       final ISelectionProvider sp = fSite.getSelectionProvider();
+        sp.addSelectionChangedListener(this);
+        updateActions(sp.getSelection());
+    }
+
+       private void unregisterSite() {
+               if (fSite != null) {
+               fSite.getSelectionProvider().removeSelectionChangedListener(this);
+               fSite= null;
+       }
+       }
+    
+       public void setEditor(ITextEditor textEditor) {
+               unregisterSite();
+               
+        for (RefactoringAction action : fAllActions) {
+                       action.setEditor(textEditor);
+               }        
+    }
+
+
+       @Override
+       public void fillActionBars(IActionBars actionBar) {
+               super.fillActionBars(actionBar);
+               setActionHandler(actionBar, CdtActionConstants.RENAME, fRenameAction);
+               setActionHandler(actionBar, CdtActionConstants.EXTRACT_CONSTANT, fExtractConstantAction);
+               setActionHandler(actionBar, CdtActionConstants.EXTRACT_LOCAL_VARIABLE, fExtractLocalVariableAction);
+               setActionHandler(actionBar, CdtActionConstants.EXTRACT_METHOD, fExtractFunctionAction);
+               setActionHandler(actionBar, CdtActionConstants.TOGGLE_FUNCTION, fToggleFunctionAction);
+               setActionHandler(actionBar, CdtActionConstants.HIDE_METHOD, fHideMethodAction);         
+       }
+
+       private void setActionHandler(IActionBars actionBar, String id, RefactoringAction action) {
+               if (action != null)
+                       actionBar.setGlobalActionHandler(id, action);
+       }
+
+    /* (non-Javadoc)
+     * Method declared in ActionGroup
+     */
+    @Override
+       public void fillContextMenu(IMenuManager menu) {
+       updateActionBars();
+       
+       boolean needMenu= false;
+        for (RefactoringAction action : fAllActions) {
+                       if (action.isEnabled()) {
+                               needMenu= true;
+                               break;
+                       }
+               }        
+
+               if (needMenu) {
+                       IMenuManager refactorSubmenu = new MenuManager(Messages.CRefactoringActionGroup_menu, MENU_ID); 
+                       refactorSubmenu.add(new Separator(GROUP_REORG));
+                       addAction(refactorSubmenu, fRenameAction);
+                       refactorSubmenu.add(new Separator(GROUP_CODING));
+                       addAction(refactorSubmenu, fExtractConstantAction);
+                       addAction(refactorSubmenu, fExtractLocalVariableAction);
+                       addAction(refactorSubmenu, fExtractFunctionAction);
+                       addAction(refactorSubmenu, fToggleFunctionAction);
+                       addAction(refactorSubmenu, fHideMethodAction);
+                       refactorSubmenu.add(new Separator(GROUP_REORG2));
+                       refactorSubmenu.add(new Separator(GROUP_TYPE));
+                       refactorSubmenu.add(new Separator(GROUP_TYPE2));
+                       refactorSubmenu.add(new Separator(GROUP_CODING2));
+                       refactorSubmenu.add(new Separator(GROUP_TYPE3));
+        
+                       menu.appendToGroup(fGroupName, refactorSubmenu);
+               }
+    }
+
+       private void addAction(IMenuManager refactorSubmenu, RefactoringAction action) {
+               if (action != null && action.isEnabled()) {
+                       refactorSubmenu.add(action);
+               }
+       }
+
+       private ICElement getCElement(ISelection selection) {
+               if (selection instanceof IStructuredSelection) {
+                       IStructuredSelection ss= (IStructuredSelection) selection;
+                       if (ss.size() == 1) {
+                               Object o= ss.getFirstElement();
+                               if (o instanceof ICElement && o instanceof ISourceReference) {
+                                       return (ICElement) o;
+                               }
+                       }
+               }
+               return null;
+       }
+
+       private void updateActions(ISelection selection) {
+               ICElement celem= getCElement(selection);
+               for (RefactoringAction action : fAllActions) {
+                       action.updateSelection(celem);
+               }
+    }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.actions.ActionGroup#dispose()
+        */
+       @Override
+       public void dispose() {
+               unregisterSite();
+               fSite= null;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+        */
+       public void selectionChanged(SelectionChangedEvent event) {
+               updateActions(event.getSelection());
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/CRenameAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/CRenameAction.java
new file mode 100644 (file)
index 0000000..a32edc6
--- /dev/null
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2010 Wind River Systems, Inc. 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Markus Schorn - initial API and implementation
+ *     Sergey Prigogin (Google) 
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui.refactoring.actions;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.window.IShellProvider;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IInclude;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+import org.eclipse.cdt.internal.ui.actions.ActionUtil;
+import org.eclipse.cdt.internal.ui.refactoring.rename.CRefactory;
+import org.eclipse.cdt.internal.ui.refactoring.rename.RenameLinkedMode;
+
+/**
+ * Launches a rename refactoring.
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ */          
+public class CRenameAction extends RefactoringAction {
+    
+    public CRenameAction() {
+        super(Messages.CRenameAction_label);
+        setSaveRequired(false);
+    }
+    
+       @Override
+       public void run(IShellProvider shellProvider, ICElement elem) {
+               if (!ActionUtil.isEditable(fEditor, shellProvider.getShell(), elem))
+                       return;
+               CRefactory.getInstance().rename(shellProvider.getShell(), elem);
+       }
+
+       @Override
+       public void run(IShellProvider shellProvider, IWorkingCopy workingCopy, ITextSelection selection) {
+               if (!ActionUtil.isEditable(fEditor))
+                       return;
+               IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
+               boolean lightweight= store.getBoolean(PreferenceConstants.REFACTOR_LIGHTWEIGHT);
+               if (lightweight) {
+                       new RenameLinkedMode(fEditor).start();
+               } else {
+                       CRefactory.getInstance().rename(shellProvider.getShell(), workingCopy, selection);
+               }
+       }
+
+    @Override
+       public void updateSelection(ICElement elem) {
+       super.updateSelection(elem);
+       if (elem == null || elem instanceof IInclude || elem instanceof ITranslationUnit) {
+               setEnabled(false);
+       } else {
+               setEnabled(true);
+       }
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractConstantAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractConstantAction.java
new file mode 100644 (file)
index 0000000..659e43c
--- /dev/null
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 Wind River Systems, Inc. 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Markus Schorn - initial API and implementation 
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui.refactoring.actions;
+
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.window.IShellProvider;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+
+import org.eclipse.cdt.internal.ui.refactoring.extractconstant.ExtractConstantRefactoringRunner;
+
+/**
+ * Launches a extract constant refactoring.
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ */          
+public class ExtractConstantAction extends RefactoringAction {
+    
+    public ExtractConstantAction() {
+        super(Messages.ExtractConstantAction_label);
+    }
+    
+       @Override
+       public void run(IShellProvider shellProvider, ICElement elem) {
+       }
+
+       @Override
+       public void run(IShellProvider shellProvider, IWorkingCopy wc, ITextSelection selection) {
+               IResource res= wc.getResource();
+               if (res instanceof IFile) {
+                       new ExtractConstantRefactoringRunner((IFile) res, selection, shellProvider, wc.getCProject()).run();
+               }
+       }
+
+    @Override
+       public void updateSelection(ICElement elem) {
+       super.updateSelection(elem);
+       setEnabled(false);
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractFunctionAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractFunctionAction.java
new file mode 100644 (file)
index 0000000..2d7d38e
--- /dev/null
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ * Institute for Software (IFS)- initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.ui.refactoring.actions;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.window.IShellProvider;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+
+import org.eclipse.cdt.internal.ui.refactoring.extractfunction.ExtractFunctionRefactoringRunner;
+
+/**
+ *
+ * @since 5.0
+ * @author Emanuel Graf IFS
+ *
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class ExtractFunctionAction extends RefactoringAction {
+
+       public ExtractFunctionAction() {
+               super(Messages.ExtractFunctionAction_label);
+       }
+
+       @Override
+       public void run(IShellProvider shellProvider, ICElement elem) {
+       }
+
+       @Override
+       public void run(IShellProvider shellProvider, IWorkingCopy wc,
+                       ITextSelection s) {
+               IResource res = wc.getResource();
+               if (res instanceof IFile) {
+                       final ISelection selection = fEditor.getSelectionProvider().getSelection();
+                       new ExtractFunctionRefactoringRunner((IFile) res, selection, fEditor.getSite(), wc.getCProject()).run();
+               }
+       }
+
+    @Override
+       public void updateSelection(ICElement elem) {
+               super.updateSelection(elem);
+               setEnabled(false);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractLocalVariableAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ExtractLocalVariableAction.java
new file mode 100644 (file)
index 0000000..b269b35
--- /dev/null
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 Wind River Systems, Inc. 
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Markus Schorn - initial API and implementation 
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui.refactoring.actions;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.window.IShellProvider;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+
+import org.eclipse.cdt.internal.ui.refactoring.extractlocalvariable.ExtractLocalVariableRefactoringRunner;
+
+/**
+ * Launches a extract local variable refactoring.
+ * @since 5.1
+ * @noextend This class is not intended to be subclassed by clients.
+ */          
+public class ExtractLocalVariableAction extends RefactoringAction {
+    
+    public ExtractLocalVariableAction() {
+        super(Messages.ExtractLocalVariableAction_label);
+    }
+    
+       @Override
+       public void run(IShellProvider shellProvider, ICElement elem) {
+       }
+
+       @Override
+       public void run(IShellProvider shellProvider, IWorkingCopy wc, ITextSelection selection) {
+               IResource res= wc.getResource();
+               if (res instanceof IFile) {
+                       new ExtractLocalVariableRefactoringRunner((IFile) res, selection, shellProvider, wc.getCProject()).run();
+               }
+       }
+
+    @Override
+       public void updateSelection(ICElement elem) {
+       super.updateSelection(elem);
+       setEnabled(false);
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/GettersAndSettersAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/GettersAndSettersAction.java
new file mode 100644 (file)
index 0000000..2e07fdd
--- /dev/null
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *
+ * Contributors: 
+ *        Institute for Software - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.refactoring.actions;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.ui.IEditorPart;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IField;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+
+import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.GenerateGettersAndSettersRefactoringRunner;
+
+/**
+ * Launches a getter and setter source code generation.
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ */          
+public class GettersAndSettersAction extends RefactoringAction {
+
+    public GettersAndSettersAction() {
+        super(Messages.GettersAndSetters_label);
+        setSaveRequired(false);
+    }
+
+       /**
+        * @since 5.1
+        */
+       public GettersAndSettersAction(IEditorPart editor) {
+               this();
+               setEditor(editor);
+       }
+
+       @Override
+       public void run(IShellProvider shellProvider, ICElement elem) {
+               new GenerateGettersAndSettersRefactoringRunner(elem, null, shellProvider, elem.getCProject()).run();
+       }
+
+       @Override
+       public void run(IShellProvider shellProvider, IWorkingCopy wc, ITextSelection s) {
+               IResource res= wc.getResource();
+               if (res instanceof IFile) {
+                       new GenerateGettersAndSettersRefactoringRunner(wc, s, shellProvider, wc.getCProject()).run();
+               }
+       }
+
+    @Override
+       public void updateSelection(ICElement elem) {
+       super.updateSelection(elem);
+       if (!(elem instanceof IField) || !(elem instanceof ISourceReference) ||
+                       !(((ISourceReference) elem).getTranslationUnit().getResource() instanceof IFile)) {
+               setEnabled(false);
+       }
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/HideMethodAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/HideMethodAction.java
new file mode 100644 (file)
index 0000000..537c3f5
--- /dev/null
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.refactoring.actions;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.window.IShellProvider;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IMethodDeclaration;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+
+import org.eclipse.cdt.internal.ui.refactoring.hidemethod.HideMethodRefactoringRunner;
+
+/**
+ * Launches a HideMethod refacoring
+ * @author Guido Zgraggen IFS
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class HideMethodAction extends RefactoringAction {
+    
+    public HideMethodAction() {
+        super(Messages.HideMethodAction_label); 
+    }
+    
+       @Override
+       public void run(IShellProvider shellProvider, ICElement elem) {
+               if (elem instanceof ISourceReference) {
+                       new HideMethodRefactoringRunner(null, null, elem, shellProvider, elem.getCProject()).run();
+               }
+       }
+
+       @Override
+       public void run(IShellProvider shellProvider, IWorkingCopy wc, ITextSelection s) {
+               IResource res= wc.getResource();
+               if (res instanceof IFile) {
+                       new HideMethodRefactoringRunner((IFile) res, 
+                                       fEditor.getSelectionProvider().getSelection(), null, 
+                                       fEditor.getSite().getWorkbenchWindow(), wc.getCProject()).run();
+               }
+       }
+
+    @Override
+       public void updateSelection(ICElement elem) {
+       super.updateSelection(elem);
+       if (elem instanceof IMethodDeclaration == false 
+                       || elem instanceof ISourceReference == false
+                       || ((ISourceReference) elem).getTranslationUnit().getResource() instanceof IFile == false) {
+               setEnabled(false);
+       }
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ImplementMethodAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ImplementMethodAction.java
new file mode 100644 (file)
index 0000000..db66437
--- /dev/null
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ *  
+ * Contributors: 
+ * Institute for Software - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui.refactoring.actions;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.ui.IEditorPart;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IMethod;
+import org.eclipse.cdt.core.model.IMethodDeclaration;
+import org.eclipse.cdt.core.model.ISourceReference;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+
+import org.eclipse.cdt.internal.ui.refactoring.implementmethod.ImplementMethodRefactoringRunner;
+
+/**
+ * Launches the implement method source generator (refactoring).
+ * 
+ * @author Lukas Felber
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class ImplementMethodAction extends RefactoringAction {
+
+       public ImplementMethodAction() {
+               super(Messages.ImplementMethodAction_label);
+       }
+
+       /**
+        * @since 5.1
+        */
+       public ImplementMethodAction(IEditorPart editor) {
+               super(Messages.ImplementMethodAction_label);
+               setEditor(editor);
+       }
+
+       @Override
+       public void run(IShellProvider shellProvider, ICElement elem) {
+               new ImplementMethodRefactoringRunner(elem, null, shellProvider, elem.getCProject()).run();
+       }
+
+       @Override
+       public void run(IShellProvider shellProvider, IWorkingCopy wc, ITextSelection selection) {
+               IResource res = wc.getResource();
+               if (res instanceof IFile) {
+                       new ImplementMethodRefactoringRunner(wc, selection, shellProvider, wc.getCProject()).run();
+               }
+       }
+
+       @Override
+       public void updateSelection(ICElement elem) {
+       super.updateSelection(elem);
+       if (elem instanceof IMethod || elem instanceof IMethodDeclaration == false 
+                       || elem instanceof ISourceReference == false
+                       || ((ISourceReference) elem).getTranslationUnit().getResource() instanceof IFile == false) {
+               setEnabled(false);
+       }
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/Messages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/Messages.java
new file mode 100644 (file)
index 0000000..fb089c8
--- /dev/null
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.refactoring.actions;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ */
+public class Messages extends NLS {
+       private static final String BUNDLE_NAME = "org.eclipse.cdt.ui.refactoring.actions.messages"; //$NON-NLS-1$
+
+       public static String CRefactoringActionGroup_menu;
+       public static String CRenameAction_label;
+       public static String ExtractConstantAction_label;
+       /**
+        * @since 5.1
+        */
+       public static String ExtractLocalVariableAction_label;
+       public static String ExtractFunctionAction_label;
+       public static String HideMethodAction_label;
+       public static String ImplementMethodAction_label;
+       public static String GettersAndSetters_label;
+       /**
+        * @since 5.3
+        */
+       public static String ToggleFunctionAction_label;
+
+       static {
+               // initialize resource bundle
+               NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+       }
+
+       private Messages() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/RefactoringAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/RefactoringAction.java
new file mode 100644 (file)
index 0000000..be59b66
--- /dev/null
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Markus Schorn - initial API and implementation
+ *******************************************************************************/ 
+package org.eclipse.cdt.ui.refactoring.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchSite;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.refactoring.utils.EclipseObjects;
+
+/**
+ * Common base class for refactoring actions
+ * @since 5.0
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public abstract class RefactoringAction extends Action {
+    protected CEditor fEditor;
+    private IWorkbenchSite fSite;
+       private ICElement fElement;
+       private boolean saveRequired;
+
+       public RefactoringAction(String label) {
+               super(label);
+               saveRequired = true;
+       }
+
+       /**
+        * Sets behavior with respect to saving dirty editors.
+        * @param saveRequired if <code>true</code>, dirty editors will be saved before refactoring.
+        * @since 5.3
+        */
+       public void setSaveRequired(boolean saveRequired) {
+               this.saveRequired = saveRequired;
+       }
+
+    public void setEditor(IEditorPart editor) {
+        fEditor= null;
+        fSite= null;
+        if (editor instanceof CEditor) {
+            fEditor= (CEditor) editor;
+        }
+        setEnabled(fEditor != null);
+    }
+
+       public void setSite(IWorkbenchSite site) {
+        fEditor= null;
+        fSite= site;
+       }
+       
+    @Override
+       public final void run() {
+       if (saveRequired) {
+               EclipseObjects.getActivePage().saveAllEditors(true);
+               if (EclipseObjects.getActivePage().getDirtyEditors().length != 0) {
+                       return;
+               }
+       }
+       if (fEditor != null) {
+            ISelectionProvider provider= fEditor.getSelectionProvider();
+            if (provider != null) {
+                ISelection s= provider.getSelection();
+                if (s instanceof ITextSelection) {
+                       IWorkingCopy wc= CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(fEditor.getEditorInput());
+                       if (wc != null)
+                               run(fEditor.getSite(), wc, (ITextSelection) s);
+                }
+            }
+        } else if (fSite != null) {
+            if (fElement != null) {
+               run(fSite, fElement);
+            }                        
+        }            
+    }
+
+       public void updateSelection(ICElement elem) {
+               fElement= elem;
+               setEnabled(elem != null);
+       }
+
+    public abstract void run(IShellProvider shellProvider, IWorkingCopy wc, ITextSelection s);
+    public abstract void run(IShellProvider shellProvider, ICElement elem);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ToggleFunctionAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/ToggleFunctionAction.java
new file mode 100644 (file)
index 0000000..5d98d27
--- /dev/null
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Institute for Software, HSR Hochschule fuer Technik  
+ * Rapperswil, University of applied sciences and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution, and is available at 
+ * http://www.eclipse.org/legal/epl-v10.html  
+ * 
+ * Contributors: 
+ * Institute for Software (IFS)- initial API and implementation 
+ ******************************************************************************/
+package org.eclipse.cdt.ui.refactoring.actions;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.refactoring.togglefunction.ToggleRefactoringRunner;
+
+/**
+ * 
+ * @since 5.3
+ * @author Emanuel Graf IFS
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class ToggleFunctionAction extends RefactoringAction {
+       private ICProject project;
+       private IFile file;
+
+       public ToggleFunctionAction() {
+               super(Messages.ToggleFunctionAction_label);
+       }
+
+       @Override
+       public void run(IShellProvider shellProvider, ICElement elem) {
+       }
+
+       @Override
+       public void run(IShellProvider shellProvider, IWorkingCopy wc,
+                       ITextSelection s) {
+               IResource res = wc.getResource();
+               if (isWorkbenchReady(wc) && res instanceof IFile) {
+                       new ToggleRefactoringRunner(file, s, project, shellProvider, project).run();
+               }
+       }
+
+       private boolean isWorkbenchReady(IWorkingCopy wc) {
+               try {
+                       IWorkbenchPage activePage = CUIPlugin.getActivePage();
+                       if (activePage == null)
+                               return false;
+                       IEditorPart editor = activePage.getActiveEditor();
+                       if (editor == null || editor.getEditorInput() == null)
+                               return false;
+                       if (wc == null)
+                               return false;
+                       project = wc.getCProject();
+                       file = (IFile) wc.getResource();
+                       return project != null && file != null;
+               } catch (ClassCastException e) {
+                       return false;
+               }
+       }
+
+    @Override
+       public void updateSelection(ICElement elem) {
+               super.updateSelection(elem);
+               setEnabled(false);
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/messages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/refactoring/actions/messages.properties
new file mode 100644 (file)
index 0000000..251ae6c
--- /dev/null
@@ -0,0 +1,19 @@
+###############################################################################
+# Copyright (c) 2008 Wind River Systems, Inc. and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     Markus Schorn (Wind River Systems)
+###############################################################################
+CRefactoringActionGroup_menu=Refactor
+CRenameAction_label=Rename...
+ExtractConstantAction_label=Extract Constant...
+ExtractLocalVariableAction_label=Extract Local Variable...
+GettersAndSetters_label=Generate Getters and Setters... 
+ImplementMethodAction_label=Implement Method...
+HideMethodAction_label=Hide Method...
+ExtractFunctionAction_label=Extract Function...
+ToggleFunctionAction_label=Toggle Function Definition
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/resources/Messages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/resources/Messages.java
new file mode 100644 (file)
index 0000000..57e36f2
--- /dev/null
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui.resources;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @since 5.3
+ */
+public class Messages extends NLS {
+       private static final String BUNDLE_NAME = "org.eclipse.cdt.ui.resources.messages"; //$NON-NLS-1$
+       public static String RefreshPolicyExceptionDialog_exceptionTypeResources;
+       public static String RefreshPolicyExceptionDialog_addButtonLabel;
+       public static String RefreshPolicyExceptionDialog_SelectResourceDialogMessage;
+       public static String RefreshPolicyExceptionDialog_SelectResourceDialogTitle;
+       public static String RefreshPolicyExceptionDialog_deleteButtonLabel;
+       
+       static {
+               // initialize resource bundle
+               NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+       }
+
+       private Messages() {
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/resources/RefreshExclusionContributionManager.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/resources/RefreshExclusionContributionManager.java
new file mode 100644 (file)
index 0000000..e0ad161
--- /dev/null
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ *  Copyright (c) 2011 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.resources;
+
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as part of a work in progress. There
+ * is no guarantee that this API will work or that it will remain the same. Please do not use this API without
+ * consulting with the CDT team.
+ * 
+ * @author crecoskie
+ * @since 5.3
+ * 
+ */
+public class RefreshExclusionContributionManager {
+
+       public static final String EXCLUSION_CONTRIBUTOR = "exclusionContributor"; //$NON-NLS-1$
+       public static final String EXTENSION_ID = "RefreshExclusionContributor"; //$NON-NLS-1$
+       private static RefreshExclusionContributionManager fInstance;
+
+       public static synchronized RefreshExclusionContributionManager getInstance() {
+               if (fInstance == null) {
+                       fInstance = new RefreshExclusionContributionManager();
+               }
+
+               return fInstance;
+       }
+
+       private LinkedHashMap<String, RefreshExclusionContributor> fIDtoContributorsMap;
+
+       private RefreshExclusionContributionManager() {
+               fIDtoContributorsMap = new LinkedHashMap<String, RefreshExclusionContributor>();
+               loadExtensions();
+       }
+
+       public RefreshExclusionContributor getContributor(String id) {
+               return fIDtoContributorsMap.get(id);
+       }
+
+       public List<RefreshExclusionContributor> getContributors() {
+               return getContributors(false);
+       }
+
+       public List<RefreshExclusionContributor> getContributors(boolean returnTestContributors) {
+               List<RefreshExclusionContributor> retVal = new LinkedList<RefreshExclusionContributor>();
+
+               if (!returnTestContributors) {
+                       for (RefreshExclusionContributor contributor : fIDtoContributorsMap.values()) {
+                               if (!contributor.isTest()) {
+                                       retVal.add(contributor);
+                               }
+                       }
+
+                       return retVal;
+               }
+
+               else {
+                       return new LinkedList<RefreshExclusionContributor>(fIDtoContributorsMap.values());
+               }
+       }
+
+       public synchronized void loadExtensions() {
+               IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID,
+                               EXTENSION_ID);
+               if (extension != null) {
+                       IExtension[] extensions = extension.getExtensions();
+                       for (IExtension extension2 : extensions) {
+                               IConfigurationElement[] configElements = extension2.getConfigurationElements();
+                               for (IConfigurationElement configElement : configElements) {
+
+                                       if (configElement.getName().equals(EXCLUSION_CONTRIBUTOR)) {
+
+                                               String id = configElement.getAttribute("id"); //$NON-NLS-1$
+                                               String name = configElement.getAttribute("name"); //$NON-NLS-1$
+                                               String contributorClassName = configElement.getAttribute("class"); //$NON-NLS-1$
+                                               boolean isTest = false;
+                                               String isTestString = configElement.getAttribute("isTest"); //$NON-NLS-1$
+                                               if (isTestString != null) {
+                                                       isTest = Boolean.getBoolean(isTestString);
+                                               }
+
+                                               if (contributorClassName != null) {
+                                                       try {
+                                                               Object execExt = configElement.createExecutableExtension("class"); //$NON-NLS-1$
+                                                               if ((execExt instanceof RefreshExclusionContributor) && id != null) {
+                                                                       RefreshExclusionContributor exclusionContributor = (RefreshExclusionContributor) execExt;
+                                                                       exclusionContributor.setID(id);
+                                                                       exclusionContributor.setName(name);
+                                                                       exclusionContributor.setIsTest(isTest);
+                                                                       fIDtoContributorsMap.put(id, exclusionContributor);
+
+                                                               }
+                                                       } catch (CoreException e) {
+                                                               CUIPlugin.log(e);
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/resources/RefreshExclusionContributor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/resources/RefreshExclusionContributor.java
new file mode 100644 (file)
index 0000000..5ae521c
--- /dev/null
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ *  Copyright (c) 2011 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.resources;
+
+import org.eclipse.swt.widgets.Composite;
+
+import org.eclipse.cdt.core.resources.RefreshExclusion;
+
+/**
+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as part of a work in progress. There
+ * is no guarantee that this API will work or that it will remain the same. Please do not use this API without
+ * consulting with the CDT team.
+ * 
+ * @author crecoskie
+ * @since 5.3
+ * 
+ */
+public abstract class RefreshExclusionContributor {
+
+       protected String fID;
+       protected boolean fIsTest;
+       protected String fName;
+
+       abstract public RefreshExclusion createExclusion();
+
+       /**
+        * Creates the UI that allows user to modify the given RefreshExclusion
+        * 
+        * @param parent
+        *            - the parent composite to contain the UI
+        * @param exclusion
+        *            - the RefreshExclusion to be modified
+        */
+       abstract public void createProperiesUI(Composite parent, RefreshExclusion exclusion);
+
+       public String getID() {
+               return fID;
+       }
+
+       /**
+        * Returns the human-readable name of this exclusion type.
+        * 
+        * @return String.
+        */
+       public String getName() {
+               return fName;
+       }
+
+       public boolean isTest() {
+               return fIsTest;
+       }
+
+       public void setID(String id) {
+               fID = id;
+       }
+
+       public void setIsTest(boolean isTest) {
+               fIsTest = isTest;
+       }
+
+       public void setName(String name) {
+               fName = name;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/resources/messages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/resources/messages.properties
new file mode 100644 (file)
index 0000000..1ae9593
--- /dev/null
@@ -0,0 +1,16 @@
+###############################################################################
+# Copyright (c) 2011 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1_0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - Initial API and implementation
+###############################################################################
+
+RefreshPolicyExceptionDialog_exceptionTypeResources=Resources
+RefreshPolicyExceptionDialog_addButtonLabel=Add...
+RefreshPolicyExceptionDialog_deleteButtonLabel=Delete
+RefreshPolicyExceptionDialog_SelectResourceDialogTitle=Select resource for exception
+RefreshPolicyExceptionDialog_SelectResourceDialogMessage=Select resource:
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/AbstractWizardDataPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/AbstractWizardDataPage.java
new file mode 100644 (file)
index 0000000..a3ce92d
--- /dev/null
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+
+/**
+ * Implementation of standard behaviours intended to be subclassed by clients.
+ * @since 4.0.2
+ */
+public abstract class AbstractWizardDataPage extends WizardPage implements IWizardDataPage {
+       protected IWizardPage next;
+       
+        /**
+     * Creates a new wizard page with the given name, and
+     * with no title or image.
+     *
+     * @param pageName the name of the page
+     */
+       public AbstractWizardDataPage(String pageName) {
+               super(pageName);
+       }
+       
+    /**
+     * Creates a new wizard page with the given name, title, and image.
+     *
+     * @param pageName the name of the page
+     * @param title the title for this wizard page,
+     *   or <code>null</code> if none
+     * @param imageDescriptor the image descriptor for the title of this wizard page,
+     *   or <code>null</code> if none
+     */
+       public AbstractWizardDataPage(String pageName, String title, ImageDescriptor imageDescriptor) {
+               super(pageName, title, imageDescriptor);
+       }
+       
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.cdt.ui.templateengine.IWizardDataPage#setNextPage(org.eclipse.jface.wizard.IWizardPage)
+        */
+       public void setNextPage(IWizardPage next) {
+               this.next= next;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.jface.wizard.WizardPage#getNextPage()
+        */
+       @Override
+       public IWizardPage getNextPage() {
+               if(next != null) {
+                       return next;
+               }
+               return super.getNextPage();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/FormBrowser.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/FormBrowser.java
new file mode 100644 (file)
index 0000000..f9415e0
--- /dev/null
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.forms.widgets.FormText;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledFormText;
+
+/**
+ * FormBrowser. 
+ */
+class FormBrowser {
+       private FormToolkit toolkit;
+       private Composite container;
+       private ScrolledFormText formText;
+       private String text;
+
+       public void createControl(Composite parent) {
+               toolkit = new FormToolkit(parent.getDisplay());
+               int borderStyle = toolkit.getBorderStyle() == SWT.BORDER ? SWT.NULL : SWT.BORDER;
+               container = new Composite(parent, borderStyle);
+               FillLayout flayout = new FillLayout();
+               flayout.marginWidth = 1;
+               flayout.marginHeight = 1;
+               container.setLayout(flayout);
+               formText = new ScrolledFormText(container, SWT.V_SCROLL | SWT.H_SCROLL, false);
+               if (borderStyle == SWT.NULL) {
+                       formText.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER);
+                       toolkit.paintBordersFor(container);
+               }
+               FormText ftext = toolkit.createFormText(formText, false);
+               formText.setFormText(ftext);
+               formText.setExpandHorizontal(true);
+               formText.setExpandVertical(true);
+               formText.setBackground(toolkit.getColors().getBackground());
+               formText.setForeground(toolkit.getColors().getForeground());
+               ftext.marginWidth = 2;
+               ftext.marginHeight = 2;
+               ftext.setHyperlinkSettings(toolkit.getHyperlinkGroup());
+               formText.addDisposeListener(new DisposeListener() {
+                       public void widgetDisposed(DisposeEvent e) {
+                               if (toolkit != null) {
+                                       toolkit.dispose();
+                                       toolkit = null;
+                               }
+                       }
+               });
+               if (text != null) {
+                       formText.setText(text);
+               }
+       }
+
+       public Control getControl() {
+               return container;
+       }
+
+       /**
+        * @param text  the text to set
+        */
+       public void setText(String text) {
+               this.text = text;
+               if (formText != null) {
+                       formText.setText(text);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/IPagesAfterTemplateSelectionProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/IPagesAfterTemplateSelectionProvider.java
new file mode 100644 (file)
index 0000000..59ef801
--- /dev/null
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWizard;
+
+
+/**
+ * Interface for extensions that provide additional custom pages as part of
+ * project configuration.
+ * @since 4.0
+ */
+public interface IPagesAfterTemplateSelectionProvider {
+    /**
+     * Creates pages that will be appended to the pages returned from
+     * TemplatesChoiceWizard.getPagesAfterTemplateSelection()
+     * Parameters are those used to initialise the wizard.
+     * </p>
+     * @param wizard the wizard requesting the pages
+     * @param workbench the current workbench
+     * @param selection the current object selection, or null if no context is available
+     * 
+     * @since 4.0
+     */
+       IWizardDataPage[] createAdditionalPages(IWorkbenchWizard wizard, IWorkbench workbench, IStructuredSelection selection);
+       
+    /**
+     * Gets the previously created pages
+     * @param wizard the wizard that requested creation of the pages
+     * 
+     * @since 4.0
+     */
+       IWizardDataPage[] getCreatedPages(IWorkbenchWizard wizard);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/ITemplatesListProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/ITemplatesListProvider.java
new file mode 100644 (file)
index 0000000..8628d92
--- /dev/null
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+
+/**
+ * ITemplatesListProvider
+ * 
+ * @since 4.0
+ */
+public interface ITemplatesListProvider extends ITreeContentProvider {
+       
+       Template[] getTemplates();
+       
+       String getDescription(Object object);
+
+       boolean showTemplatesInTreeView();
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/IWizardDataPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/IWizardDataPage.java
new file mode 100644 (file)
index 0000000..5a08277
--- /dev/null
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine;
+
+import java.util.Map;
+
+import org.eclipse.jface.wizard.IWizardPage;
+
+/**
+ * IWizardDataPage is a page which can participate in a custom project template
+ * wizard sequence.
+ * 
+ * @since 4.0
+ */
+public interface IWizardDataPage extends IWizardPage {
+       /**
+        * @return a map of (key,value) pairs that should be added to the
+        * associated project template's value store.
+        */
+       Map<String, String> getPageData();
+       
+       /**
+        * Set the page that follows this one. Implementations must ensure
+        * {@link IWizardPage#getNextPage()} returns the specified value
+        * @param next
+        */
+       public void setNextPage(IWizardPage next);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/Messages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/Messages.java
new file mode 100644 (file)
index 0000000..f79224e
--- /dev/null
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages {
+       private static final String BUNDLE_NAME = "org.eclipse.cdt.ui.templateengine.messages"; //$NON-NLS-1$
+
+       private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
+                       .getBundle(BUNDLE_NAME);
+
+       private Messages() {
+       }
+
+       public static String getString(String key) {
+               try {
+                       return RESOURCE_BUNDLE.getString(key);
+               } catch (MissingResourceException e) {
+                       return '!' + key + '!';
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/ProjectSelectionPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/ProjectSelectionPage.java
new file mode 100644 (file)
index 0000000..a35c382
--- /dev/null
@@ -0,0 +1,353 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine;
+
+import java.util.HashMap;
+import java.util.Map;
+
+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.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+
+import org.eclipse.cdt.core.CCProjectNature;
+import org.eclipse.cdt.core.CProjectNature;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.ui.CElementLabelProvider;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+
+public class ProjectSelectionPage extends WizardPage implements IWizardDataPage {
+               
+       private static final String PAGE_NAME= "NewProjectSelectionWizardPage"; //$NON-NLS-1$
+       private static final String PAGE_TITLE = Messages.getString("ProjectSelectionPage.0"); //$NON-NLS-1$
+       private static final String PAGE_DESCRIPTION = Messages.getString("ProjectSelectionPage.1"); //$NON-NLS-1$
+
+       private Label projectNameLabel;
+       private Button projectBrowseButton;
+       private Text projectNameText;
+       private String projectName = ""; //$NON-NLS-1$
+
+       private IWorkspaceRoot workspaceRoot;
+       private ICProject currentCProject;
+       private IWizardPage next;
+       
+       public ProjectSelectionPage() {
+               super(PAGE_NAME);
+               setTitle(PAGE_TITLE);
+               setDescription(PAGE_DESCRIPTION);
+               
+               workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+               
+               setPageComplete(false);
+       }
+                       
+       public void init(IStructuredSelection selection) {
+               if (selection == null || selection.isEmpty()) {
+                       setDefaultAttributes();
+                       return;
+               }
+               
+               Object selectedElement= selection.getFirstElement();
+               if (selectedElement == null) {
+                       selectedElement= getActiveEditorCInput();
+               }                               
+               
+               String projPath= null;
+               
+               if (selectedElement instanceof IResource) {
+                       IProject project= ((IResource)selectedElement).getProject();
+                       if (project != null) {
+                               projPath= project.getFullPath().makeRelative().toString();
+                       }       
+               } else if (selectedElement instanceof ICElement) {
+                       ICProject cProject= ((ICElement)selectedElement).getCProject();
+                       if (cProject != null) {
+                               projPath= cProject.getProject().getFullPath().makeRelative().toString();
+                       }
+               }       
+               
+               if (projPath != null) {
+                       projectName = projPath;
+               } else {
+                       setDefaultAttributes();
+               }
+       }
+
+       /**
+        * If the current active editor edits a c element return it, else
+        * return null
+        */
+       private ICElement getActiveEditorCInput() {
+               IWorkbenchPage page= CUIPlugin.getActivePage();
+               if (page != null) {
+                       IEditorPart part= page.getActiveEditor();
+                       if (part != null) {
+                               IEditorInput editorInput= part.getEditorInput();
+                               if (editorInput != null) {
+                                       return (ICElement)editorInput.getAdapter(ICElement.class);
+                               }
+                       }
+               }
+               return null;    
+       }
+        
+       private void setDefaultAttributes() {
+               
+               try {
+                       // find the first C project
+                       IProject[] projects= workspaceRoot.getProjects();
+                       for (int i= 0; i < projects.length; i++) {
+                               IProject project= projects[i];
+                               if (project.hasNature(CProjectNature.C_NATURE_ID) || project.hasNature(CCProjectNature.CC_NATURE_ID)) {
+                                       projectName = project.getFullPath().makeRelative().toString();
+                                       break;
+                               }
+                       }                                       
+               } catch (CoreException e) {
+                       // ignore here
+               }
+       }
+       
+       private Map<String, String> data = new HashMap<String, String>(2);
+       
+       public Map<String, String> getPageData() {
+               String cPojectName = currentCProject.getResource().getName().trim();
+               data.put("projectName", cPojectName); //$NON-NLS-1$
+               data.put("baseName", getBaseName(cPojectName)); //$NON-NLS-1$
+               return data;
+       }
+
+       private String getBaseName(String name) {
+               String baseName = name;
+               int dot = baseName.lastIndexOf('.');
+               if (dot != -1) {
+                       baseName = baseName.substring(dot + 1);
+               }
+               dot = baseName.indexOf(' ');
+               if (dot != -1) {
+                       baseName = baseName.substring(0, dot);
+               }
+               return baseName;
+       }
+       
+       public void createControl(Composite parent) {
+               initializeDialogUnits(parent);
+               
+               Composite composite= new Composite(parent, SWT.NONE);
+                       
+               GridLayout layout= new GridLayout();
+               layout.marginWidth= 0;
+               layout.marginHeight= 0; 
+               layout.numColumns= 3;
+               composite.setLayout(layout);
+               
+               createProjectFiled(composite);
+               
+               setControl(composite);
+               Dialog.applyDialogFont(composite);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.NEW_SRCFLDER_WIZARD_PAGE);                
+       
+               projectNameText.setFocus();
+               projectNameText.setSelection(0, projectNameText.getText().length());
+               
+               setPageComplete(validatePage());
+       }
+       
+       private void createProjectFiled(Composite parent) {
+               getLabelControl(parent);
+               GridData gdLabel = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               gdLabel.horizontalSpan= 1;
+               projectNameLabel.setLayoutData(gdLabel);
+               
+               
+               getTextControl(parent);
+               GridData gdText = new GridData();
+               gdText.horizontalAlignment= GridData.FILL;
+               gdText.grabExcessHorizontalSpace= true;
+               gdText.horizontalSpan= 1;
+               gdText.widthHint = convertWidthInCharsToPixels(40);
+               projectNameText.setLayoutData(gdText);
+               
+               getButtonControl(parent);
+               GridData gdButton = new GridData();
+               gdButton.horizontalAlignment= GridData.FILL;
+               gdButton.grabExcessHorizontalSpace= false;
+               gdButton.horizontalSpan= 1;
+               projectBrowseButton.setLayoutData(gdButton);
+       }
+
+       /**
+        * Creates or returns the created Label control.
+        * @param parent The parent composite
+        */             
+       private void getLabelControl(Composite parent) {
+               projectNameLabel = new Label(parent, SWT.LEFT | SWT.WRAP);
+               projectNameLabel.setText(Messages.getString("ProjectSelectionPage.4")); //$NON-NLS-1$
+               projectNameLabel.setFont(parent.getFont());
+               projectNameLabel.setEnabled(true);              
+       }
+
+       /**
+        * Creates or returns the created text control.
+        * @param parent The parent composite
+        */             
+       private void getTextControl(Composite parent) {
+               projectNameText = new Text(parent, SWT.SINGLE | SWT.BORDER);
+               projectNameText.setText(projectName);
+               projectNameText.setFont(parent.getFont());
+               projectNameText.setEnabled(true);
+               projectNameText.addModifyListener(new ModifyListener() {
+                       public void modifyText(ModifyEvent e) {
+                               setPageComplete(validatePage());
+                       }
+               });
+       }
+
+       /**
+        * Creates or returns the created buttom widget.
+        * @param parent The parent composite
+        */             
+       private void getButtonControl(Composite parent) {
+               projectBrowseButton = new Button(parent, SWT.PUSH);
+               projectBrowseButton.setText(Messages.getString("ProjectSelectionPage.5")); //$NON-NLS-1$
+               projectBrowseButton.setFont(parent.getFont());
+               projectBrowseButton.setEnabled(true);
+               projectBrowseButton.addSelectionListener(new SelectionListener() {
+                       public void widgetDefaultSelected(SelectionEvent e) {
+                               packRootChangeControlPressed();
+                       }
+                       public void widgetSelected(SelectionEvent e) {
+                               packRootChangeControlPressed();
+                       }
+               });     
+       }
+       
+       @Override
+       public void setVisible(boolean visible) {
+               super.setVisible(visible);
+       }       
+               
+       protected void packRootChangeControlPressed() {
+               ICProject cProject= chooseProject();
+               if (cProject != null) {
+                       IPath path= cProject.getProject().getFullPath().makeRelative();
+                       projectName = path.toOSString();
+                       projectNameText.setText(projectName);
+               }
+       }       
+       
+    private boolean validatePage() {
+               currentCProject= null;
+               
+               String projectName = projectNameText.getText();
+               if (projectName.length() == 0) {
+            setErrorMessage(Messages.getString("ProjectSelectionPage.6")); //$NON-NLS-1$
+                       return false;
+               }
+               
+               IPath path= new Path(projectName);
+               if (path.segmentCount() != 1) {
+            setErrorMessage(Messages.getString("ProjectSelectionPage.7")); //$NON-NLS-1$
+                       return false;
+               }
+               
+               IProject project= workspaceRoot.getProject(path.toString());
+               if (!project.exists()) {
+            setErrorMessage(Messages.getString("ProjectSelectionPage.8")); //$NON-NLS-1$
+                       return false;
+               }
+               
+               try {
+                       if (project.hasNature(CProjectNature.C_NATURE_ID) || project.hasNature(CCProjectNature.CC_NATURE_ID)) {
+                               currentCProject= CoreModel.getDefault().create(project);
+                       setErrorMessage(null);
+                               return true;
+                       }
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+                       currentCProject= null;
+               }
+               
+        setErrorMessage(Messages.getString("ProjectSelectionPage.9")); //$NON-NLS-1$
+               return false;
+    }
+    
+       private ICProject chooseProject() {
+               ICProject[] projects;
+               try {
+                       projects= CoreModel.create(workspaceRoot).getCProjects();
+               } catch (CModelException e) {
+                       CUIPlugin.log(e);
+                       projects= new ICProject[0];
+               }
+               
+               ILabelProvider labelProvider= new CElementLabelProvider(CElementLabelProvider.SHOW_DEFAULT);
+               ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), labelProvider);
+               dialog.setTitle(Messages.getString("ProjectSelectionPage.10")); //$NON-NLS-1$
+               dialog.setMessage(Messages.getString("ProjectSelectionPage.11")); //$NON-NLS-1$
+               dialog.setElements(projects);
+               dialog.setInitialSelections(new Object[] { currentCProject });
+               if (dialog.open() == Window.OK) {                       
+                       return (ICProject) dialog.getFirstResult();
+               }                       
+               return null;            
+       }
+       
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.cdt.ui.templateengine.IWizardDataPage#setNextPage(org.eclipse.jface.wizard.IWizardPage)
+        */
+       public void setNextPage(IWizardPage next) {
+               this.next= next;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.jface.wizard.WizardPage#getNextPage()
+        */
+       @Override
+       public IWizardPage getNextPage() {
+               if(next != null) {
+                       return next;
+               }
+               return super.getNextPage();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/SimpleElementException.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/SimpleElementException.java
new file mode 100644 (file)
index 0000000..a6ba166
--- /dev/null
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine;
+
+
+
+/**
+ * This Exception is thrown when, we execute getNextChild, addToChildList and
+ * getChildCount on an InputUIElement.
+ * 
+ * @since 4.0
+ */
+
+public class SimpleElementException extends Exception {
+
+       private static final long serialVersionUID = 0000000000L;
+
+       /**
+        * The description of the exception.
+        */
+       String expDefinition;
+
+       private static final String EXCEPTION_STRING = Messages.getString("SimpleElementException.0"); //$NON-NLS-1$
+
+       /**
+        * Constructor receives description of this instance of event as parameter.
+        * The same is assigned to iExpDefinition.
+        */
+       public SimpleElementException() {
+               super(EXCEPTION_STRING);
+               expDefinition = EXCEPTION_STRING;
+       }
+
+       /**
+        * Constructor receives description of this instance of event as parameter.
+        * The same is assigned to iExpDefinition.
+        * 
+        * @param def
+        */
+       public SimpleElementException(String def) {
+               super(def);
+               expDefinition = def;
+       }
+
+       /**
+        * The description of the SimpleElementException is returned.
+        * 
+        * @return String
+        */
+       @Override
+       public String toString() {
+               return expDefinition;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/Template.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/Template.java
new file mode 100644 (file)
index 0000000..23eda69
--- /dev/null
@@ -0,0 +1,209 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWizard;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.w3c.dom.Element;
+
+import org.eclipse.cdt.core.templateengine.TemplateCore;
+import org.eclipse.cdt.core.templateengine.TemplateDescriptor;
+import org.eclipse.cdt.core.templateengine.TemplateEngine;
+import org.eclipse.cdt.core.templateengine.TemplateInfo;
+import org.eclipse.cdt.core.templateengine.TemplateInitializationException;
+import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.templateengine.pages.UIPagesProvider;
+import org.eclipse.cdt.ui.templateengine.pages.UIWizardPage;
+import org.eclipse.cdt.ui.templateengine.uitree.UIElementTreeBuilderHelper;
+import org.eclipse.cdt.ui.templateengine.uitree.UIElementTreeBuilderManager;
+
+/**
+ * Template class is responsible for initiating GUI construction. Collecting data from GUI and 
+ * initiating process part of Template Engine. This is created per TemplateDescriptor basis. 
+ * Once The Template is created it creates a TemplateDescriptor for the XML file name given.
+ * 
+ * @since 4.0
+ */
+
+public class Template extends TemplateCore {
+       
+       private TemplateDescriptor templateDescriptor;
+       private UIElementTreeBuilderManager uiElementTreeBuilderManager;
+       private UIPagesProvider uiPagesProvider;
+       private Map<String, UIWizardPage> pageMap;
+       
+       public Template(TemplateInfo templateInfo) throws TemplateInitializationException {
+               super(templateInfo);
+               templateDescriptor = getTemplateDescriptor();
+               uiElementTreeBuilderManager = new UIElementTreeBuilderManager(new UIElementTreeBuilderHelper(templateDescriptor, templateInfo));
+               uiPagesProvider = new UIPagesProvider();
+       }
+
+       /**
+        * 1. get PropertyGroupList. 
+        * 2. clear UIPage's display order Vector. 
+        * 3. for each PropertyGroup create the UIElementTree. 
+        * 4. Request the UIPagesProvider to generate UIPages for the Tree. 
+        * 5. return the HashMap of UIPages.
+        */
+       public Map<String, UIWizardPage> getUIPages() {
+               if (pageMap == null) {
+                       pageMap = new HashMap<String, UIWizardPage>();
+                       List<Element> rootPropertyGrouplist = templateDescriptor.getPropertyGroupList();
+                       
+                       uiPagesProvider.clearOrderVector();
+       
+                       for (int i = 0; i < rootPropertyGrouplist.size(); i++) {
+                               // since the tree is constructed for a list of PropertyGroup's tree
+                               // root is set to null
+                               // before invoking createUIElementTree(...).
+                               uiElementTreeBuilderManager.setUIElementTreeRootNull();
+                               uiElementTreeBuilderManager.createUIElementTree(null, rootPropertyGrouplist.get(i));
+                               pageMap.putAll(uiPagesProvider.getWizardUIPages(uiElementTreeBuilderManager.getUIElementTreeRoot(), getValueStore()));
+                       }
+               }
+
+               return pageMap;
+       }
+       
+       
+       public IWizardPage[] getTemplateWizardPages(IWizardPage predatingPage, IWizardPage followingPage, IWizard wizard) {
+               List<IWizardDataPage> pages= new ArrayList<IWizardDataPage>();
+//             if (predatingPage != null) { 
+//                     pages.add(predatingPage);
+//             }
+               
+               Map<String, UIWizardPage> templatePages = getUIPages();
+               List<String> templatePagesOrderVector = getPagesOrderVector();
+               if (templatePagesOrderVector.size() != 0) {
+                       IWizardPage prevPage = predatingPage;
+
+                       for (int i=0; i < templatePagesOrderVector.size(); i++) {
+                               UIWizardPage page = templatePages.get(templatePagesOrderVector.get(i));
+                               pages.add(page);
+                               page.setPreviousPage(prevPage);
+                               if (i+1 < templatePagesOrderVector.size()) {
+                                       page.setNextPage(templatePages.get(templatePagesOrderVector.get(i+1)));
+                               } else {
+                                       page.setNextPage(followingPage);
+                               }
+                               page.setWizard(wizard);
+                               prevPage = page;
+                       }
+
+                       predatingPage= prevPage;
+               }
+               
+               try {
+                       IWizardPage prevPage = predatingPage;
+                       IWizardDataPage[] extraPages = getExtraCreatedPages((IWorkbenchWizard)wizard, PlatformUI.getWorkbench(), null);
+                       for (IWizardDataPage page : extraPages) {
+                               pages.add(page);
+                               page.setPreviousPage(prevPage);
+                               
+                               if(prevPage instanceof IWizardDataPage) {
+                                       ((IWizardDataPage)prevPage).setNextPage(page);                                  
+                               }
+
+                               page.setWizard(wizard);
+                               prevPage = page;
+                       }
+                       
+                       if(prevPage instanceof IWizardDataPage) {
+                               ((IWizardDataPage)prevPage).setNextPage(followingPage);                                 
+                       }
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+               
+               followingPage.setPreviousPage(predatingPage);   
+               
+               return pages.toArray(new IWizardPage[pages.size()]);
+       }
+       
+       IWizardDataPage[] getExtraCreatedPages(IWorkbenchWizard wizard, IWorkbench workbench, IStructuredSelection selection) {
+               TemplateInfo templateInfo = getTemplateInfo();
+               IPagesAfterTemplateSelectionProvider extraPagesProvider = (IPagesAfterTemplateSelectionProvider) templateInfo.getExtraPagesProvider();
+               if (extraPagesProvider != null) {
+                       return extraPagesProvider.createAdditionalPages(wizard, null, null);
+               }
+               return new IWizardDataPage[0];          
+       }
+       
+       
+       /**
+        * 
+        * @return List,which contains Page display order
+        */
+
+       public List<String> getPagesOrderVector() {
+               return uiPagesProvider.getOrderVector();
+       }
+
+       /**
+        * this method is for JUnit Test case excecution. return the
+        * UIElementTreeBuilderManager instance used by this Template.
+        * 
+        * @return UIElementTreeBuilderManager
+        */
+       public UIElementTreeBuilderManager getUIElementTreeBuilderManager() {
+               return uiElementTreeBuilderManager;
+       }
+       
+       /**
+        * initializeProcessBlockList() will create the ProcessBlockList,
+        * processPorcessBlockList() will invoke each process execution by assigning
+        * resources to each process (Ref. ProcessResourceManager).
+        * @param monitor 
+        */
+       @Override
+       public IStatus[] executeTemplateProcesses(IProgressMonitor monitor, final boolean showError) {
+               setDirty();
+               TemplateEngine.getDefault().updateSharedDefaults(this);
+               final IStatus[][] result = new IStatus[1][];
+               WorkspaceModifyOperation wmo = new WorkspaceModifyOperation() {
+                       @Override
+                       protected void execute(IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException ,java.lang.reflect.InvocationTargetException ,InterruptedException {
+                               try {
+                                       result[0] = getProcessHandler().processAll(monitor);
+                               } catch (ProcessFailureException e) {
+                                       if (showError) {
+                                               TemplateEngineUIUtil.showError(e.getMessage(), e.getCause());
+                                       }
+                                       result[0] = new IStatus[] {new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.ERROR, e.getMessage(), e)};
+                               }
+                       }
+               };
+               try {
+                       wmo.run(monitor);
+               } catch(InterruptedException ie) {
+                       throw new RuntimeException(ie);
+               } catch(InvocationTargetException ite) {
+                       throw new RuntimeException(ite.getTargetException());
+               }
+               return result[0];
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/TemplateClassWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/TemplateClassWizard.java
new file mode 100644 (file)
index 0000000..a014299
--- /dev/null
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Symbian - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine;
+
+import java.util.Arrays;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
+
+import org.eclipse.cdt.core.templateengine.TemplateCore;
+
+public class TemplateClassWizard extends TemplatesChoiceWizard implements INewWizard, IExecutableExtension {
+
+       public static final String WIZARD_ID = TemplateClassWizard.class.getName();
+
+       private IWizardDataPage[] pagesBeforeTemplatePages;
+       private IWizardDataPage[] pagesAfterTemplatePages;
+       private IWizardDataPage[] pagesAfterTemplateSelection;
+
+       private ProjectSelectionPage projectSelectionPage;
+
+       private IConfigurationElement configElement;
+
+       public TemplateClassWizard() {
+               super();
+               setWindowTitle(Messages.getString("TemplateClassWizard.0")); //$NON-NLS-1$
+               //TODO: Fix the imagedescriptor later.
+               //setDefaultPageImageDescriptor(TemplateEnginePlugin.imageDescriptorFromPlugin(TemplateEnginePlugin.getDefault().getWizardIconPluginID(), TemplateEnginePlugin.getDefault().getWizardIconFile()));
+       }
+
+       @Override
+       public String getListSelectionTitle()
+       {
+               return Messages.getString("TemplateClassWizard.1"); //$NON-NLS-1$
+       }
+
+       @Override
+       public String getListSelectionDescription()
+       {
+               return Messages.getString("TemplateClassWizard.2"); //$NON-NLS-1$
+       }
+
+       @Override
+       public String getListSelectionLabel()
+       {
+               return Messages.getString("TemplateClassWizard.3"); //$NON-NLS-1$
+       }
+
+       @Override
+       protected IWizardDataPage[] getPagesBeforeTemplatePages() {
+               if (pagesBeforeTemplatePages == null) {
+                       projectSelectionPage = new ProjectSelectionPage();
+                       projectSelectionPage.setTitle(Messages.getString("TemplateClassWizard.4")); //$NON-NLS-1$
+                       projectSelectionPage.setDescription(Messages.getString("TemplateClassWizard.5")); //$NON-NLS-1$
+                       projectSelectionPage.init(selection);
+                       pagesBeforeTemplatePages = new IWizardDataPage[] {projectSelectionPage};
+               }
+               return pagesBeforeTemplatePages;
+       }
+
+       @Override
+       protected IWizardDataPage[] getPagesAfterTemplatePages() {
+               if (pagesAfterTemplatePages == null) {
+                       pagesAfterTemplatePages = new IWizardDataPage[] {};
+               }
+               return pagesAfterTemplatePages;
+       }
+
+       public Template[] getTemplates() {
+               SortedSet<TemplateCore> templateList = new TreeSet<TemplateCore>(Template.TEMPLATE_ID_CASE_INSENSITIVE_COMPARATOR);
+               templateList.addAll(Arrays.asList(TemplateEngineUI.getDefault().getTemplates()));
+               return templateList.toArray(new Template[templateList.size()]);
+       }
+
+       public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
+               configElement = config;
+       }
+
+       @Override
+       public boolean performFinish() {
+               boolean retVal = super.performFinish();
+               BasicNewProjectResourceWizard.updatePerspective(configElement);
+               return retVal;
+       }
+
+       @Override
+       protected IWizardDataPage[] getPagesAfterTemplateSelection() {
+               if (pagesAfterTemplateSelection == null) {
+                       pagesAfterTemplateSelection = new IWizardDataPage[] {};
+               }
+               return pagesAfterTemplateSelection;
+       }
+
+       public String getDescription(Object object) {
+               if (object instanceof Template)
+               {
+                       return ((Template)object).getDescription();
+               }
+               return ""; //$NON-NLS-1$
+       }
+
+       public boolean showTemplatesInTreeView() {
+               return false;
+       }
+
+       public Object[] getChildren(Object parentElement) {
+               return null;
+       }
+
+       public Object getParent(Object element) {
+               return null;
+       }
+
+       public boolean hasChildren(Object element) {
+               return false;
+       }
+
+       public Object[] getElements(Object inputElement) {
+               return getTemplates();
+       }
+
+       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/TemplateDrivenWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/TemplateDrivenWizard.java
new file mode 100644 (file)
index 0000000..5d700b1
--- /dev/null
@@ -0,0 +1,190 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui.templateengine;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
+
+import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.templateengine.pages.UIWizardPage;
+
+
+/**
+ * Any wizard intending to use template (@see org.eclipse.cdt.core.templateenginee.Template) based pages
+ * can extend this wizard and use it. Alternatively, a wizard intending to show a choice of templates 
+ * should use TemplatesChoiceWizard (@see org.eclipse.cdt.core.templateenginee.ui.TemplatesChoiceWizard)
+ *  
+ */
+public abstract class TemplateDrivenWizard extends Wizard {
+       protected List<IWizardPage> pagesBeforeTemplatePages = new ArrayList<IWizardPage>();
+       protected List<IWizardPage> pagesAfterTemplatePages = new ArrayList<IWizardPage>();
+       
+       protected Template template;
+       protected int pageIndex;
+       protected Map<String, UIWizardPage> templatePages;
+       protected Composite pageContainer;
+       protected List<String> templatePagesOrderVector;
+       
+       @Override
+       public final void addPage(IWizardPage page) {
+        page.setWizard(this);
+       }
+
+       @Override
+       public final void addPages() {
+               IWizardPage[] pages = getPagesBeforeTemplatePages();
+               for (IWizardPage page : pages) {
+                       addPageBeforeTemplatePages(page);
+               }
+               
+               pages = getPagesAfterTemplatePages();
+               for (IWizardPage page : pages) {
+                       addPageAfterTemplatePages(page);
+               }
+       }
+
+       private void addPageBeforeTemplatePages(IWizardPage page) {
+               addPage(page);
+               pagesBeforeTemplatePages.add(page);
+       }
+
+       private void addPageAfterTemplatePages(IWizardPage page) {
+               addPage(page);
+               pagesAfterTemplatePages.add(page);
+       }
+
+       protected abstract IWizardPage[] getPagesBeforeTemplatePages();
+
+       protected abstract IWizardPage[] getPagesAfterTemplatePages();
+       
+       /**
+        * @return  the template
+        */
+       protected abstract Template getTemplate();
+
+       @Override
+       public IWizardPage getPreviousPage(IWizardPage page) {
+               if (pageIndex > pagesBeforeTemplatePages.size() + templatePagesOrderVector.size()) {//current is some page after template pages other than the first post-template page
+                       pageIndex--;
+                       return pagesAfterTemplatePages.get(pageIndex - pagesBeforeTemplatePages.size() - templatePagesOrderVector.size());
+               } else if (pageIndex > pagesBeforeTemplatePages.size()) {//current is some template page other than the first
+                       pageIndex--;
+               return templatePages.get(templatePagesOrderVector.get(pageIndex - pagesBeforeTemplatePages.size()));
+               } else if (pageIndex > 0) {
+                       pageIndex--;
+                       return pagesBeforeTemplatePages.get(pageIndex);
+               }
+               return null;
+       }
+
+       @Override
+       public IWizardPage getNextPage(IWizardPage page) {
+               if (pageIndex < pagesBeforeTemplatePages.size() - 1) {//current is a page before template pages that is not the final one
+                       pageIndex++;
+                       return pagesBeforeTemplatePages.get(pageIndex);
+               } else if (pageIndex < pagesBeforeTemplatePages.size() + templatePagesOrderVector.size() - 1) {
+                       if(pageIndex == pagesBeforeTemplatePages.size() - 1) {//current is final page before template pages
+                               Template template = getTemplate();
+                               if (this.template != null && !this.template.equals(template)) {//template changed
+                                       this.template = template;
+                                       //TODO: dispose old template pages
+                                       templatePages = template.getUIPages();
+                                       templatePagesOrderVector = template.getPagesOrderVector();
+                               }
+                       }//else current is some template page other than the final one
+                       pageIndex++;
+                       IWizardPage nextPage = templatePages.get(templatePagesOrderVector.get(pageIndex - pagesBeforeTemplatePages.size()));
+               nextPage.setWizard(this);
+               if (nextPage.getControl() == null) {
+                       nextPage.createControl(pageContainer);
+               }
+               return nextPage;
+               } else if (pageIndex < pagesBeforeTemplatePages.size() + templatePagesOrderVector.size() + pagesAfterTemplatePages.size() - 1) {//current is final template page or a page after the final template page
+                       pageIndex++;
+                       return pagesAfterTemplatePages.get(pageIndex - pagesBeforeTemplatePages.size() - templatePagesOrderVector.size());
+               }
+               return null;
+       }
+
+       @Override
+       public final boolean canFinish() {
+               for (IWizardPage wizardPage : pagesBeforeTemplatePages) {
+                       IWizardPage page = wizardPage;
+            if (!page.isPageComplete()) {
+                return false;
+            }
+        }
+        if (templatePages == null) {
+               return false;
+        }
+        for (Object element : templatePages.values()) {
+               IWizardPage page = (IWizardPage) element;
+               if (!page.isPageComplete()) {
+                return false;
+            }
+        }
+        for (Object element : pagesAfterTemplatePages) {
+                       IWizardPage page = (IWizardPage) element;
+            if (!page.isPageComplete()) {
+                return false;
+            }
+        }
+        return true;
+       }
+
+       @Override
+       public boolean performFinish() {
+               IRunnableWithProgress op= new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() {
+                       public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+                               finishPage(monitor);
+                       }
+               });
+
+               try {
+                       getContainer().run(true, false, op);
+               } catch (InvocationTargetException e) {
+                       return false;
+               } catch  (InterruptedException e) {
+                       return false;
+               }
+               return true;
+       }
+
+       private boolean finishPage(IProgressMonitor monitor) {
+           IStatus[] statuses = template.executeTemplateProcesses(monitor, false);
+           if (statuses.length == 1 && statuses[0].getException() instanceof ProcessFailureException) {
+               TemplateEngineUIUtil.showError(statuses[0].getMessage(), statuses[0].getException());
+                   return false;
+           }
+               String msg = Messages.getString("TemplateDrivenWizard.0"); //$NON-NLS-1$
+               TemplateEngineUIUtil.showStatusDialog(msg, new MultiStatus(CUIPlugin.getPluginId(), IStatus.OK, statuses, msg, null));
+               return true;
+       }
+       
+       @Override
+       public final void createPageControls(Composite pageContainer) {
+               super.createPageControls(pageContainer);
+               this.pageContainer = pageContainer;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/TemplateEngineUI.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/TemplateEngineUI.java
new file mode 100644 (file)
index 0000000..81248d3
--- /dev/null
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.core.templateengine.TemplateEngine;
+import org.eclipse.cdt.core.templateengine.TemplateInfo;
+import org.eclipse.cdt.core.templateengine.TemplateInitializationException;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+/**
+ * TemplateEngine is implemented as a Singleton. TemplateEngine is responsible for 
+ * creating SharedDefaults and initializing the SharedDefaults. Template instances
+ * are obtained from TemplateEngine.
+ * 
+ * @since 4.0
+ */
+public class TemplateEngineUI {
+
+       /**
+        * static reference to the Singleton TemplateEngine instance.
+        */
+       private static final TemplateEngineUI TEMPLATE_ENGINE_UI = new TemplateEngineUI();
+
+       private TemplateEngineUI() {
+       }
+
+       public static TemplateEngineUI getDefault() {
+               return TEMPLATE_ENGINE_UI;
+       }
+
+       public Template[] getTemplates(String projectType, String toolChain, String usageFilter) {
+               TemplateInfo[] templateInfoArray = TemplateEngine.getDefault().getTemplateInfos(projectType, toolChain, usageFilter);
+               List<Template> templatesList = new ArrayList<Template>();
+               for (int i=0; i<templateInfoArray.length; i++) {
+                       TemplateInfo info = templateInfoArray[i];
+                       try {
+                               templatesList.add(new Template(info));
+                       } catch (TemplateInitializationException tie) {
+                               CUIPlugin.log(tie);
+                       }
+               }
+               return templatesList.toArray(new Template[templatesList.size()]);
+       }
+
+       public Template[] getTemplates(String projectType, String toolChain) {
+               return getTemplates(projectType, toolChain, null);
+       }
+
+       public Template[] getTemplates(String projectType) {
+               return getTemplates(projectType, null, null);
+       }
+
+       /**
+        * Returns all the templates, no filtering is done.
+        */
+       public Template[] getTemplates() {
+               TemplateInfo[] templateInfoArray = TemplateEngine.getDefault().getTemplateInfos();
+               List<Template> templatesList = new ArrayList<Template>();
+               for (int i=0; i<templateInfoArray.length; i++) {
+                       try {
+                               templatesList.add(new Template(templateInfoArray[i]));
+                       } catch (TemplateInitializationException tie) {
+                               CUIPlugin.log(tie);
+                       }
+               }
+               return templatesList.toArray(new Template[templatesList.size()]);
+       }
+
+       public Template getTemplateById(String templateId) {
+               Template[] templates = getTemplates();
+
+               for(int i=0; i<templates.length; i++) {
+                       Template template = templates[i];
+                       if (template.getTemplateId().equalsIgnoreCase(templateId)) {
+                               return template;
+                       }
+               }
+               return null;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/TemplateEngineUIUtil.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/TemplateEngineUIUtil.java
new file mode 100644 (file)
index 0000000..345b53d
--- /dev/null
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.core.templateengine.TemplateEngineMessages;
+import org.eclipse.cdt.core.templateengine.TemplateEngineUtil;
+import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+public class TemplateEngineUIUtil {
+       /**
+        * Shows the error message in a Dialog Box.
+        * @param message
+        * @param t
+     * 
+     * @since 4.0
+        */
+       public static void showError(String message, Throwable t) {
+               TemplateEngineUtil.log(t);
+               IStatus status;
+               if (t != null) {
+                       if (t instanceof ProcessFailureException) {
+                               List<IStatus> statuses = ((ProcessFailureException) t).getStatuses();
+                               if (statuses == null || statuses.isEmpty()) {
+                                       Throwable p = t;
+                                       do {
+                                               p = p.getCause();
+                                               if (p != null) {
+                                                       statuses = ((ProcessFailureException) p).getStatuses();
+                                               }
+                                       } while ((statuses == null || statuses.isEmpty()) && p != null && p instanceof ProcessFailureException);
+                                       if (statuses == null || statuses.isEmpty()) {
+                                               status = new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.ERROR, t.getMessage(), t);
+                                       } else {
+                                               status = new MultiStatus(CUIPlugin.getPluginId(), IStatus.ERROR, statuses.toArray(new IStatus[statuses.size()]), t.getMessage(), t);
+                                       }
+                               } else {
+                                       status = new MultiStatus(CUIPlugin.getPluginId(), IStatus.ERROR, statuses.toArray(new IStatus[statuses.size()]), t.getMessage(), t);
+                               }
+                       } else if (t instanceof CoreException) {
+                               status = ((CoreException) t).getStatus();
+                               if (status != null && message.equals(status.getMessage())) {
+                                       message = null;
+                               }
+                       } else {
+                               status = new Status(IStatus.ERROR, CUIPlugin.getPluginId(), -1, TemplateEngineMessages.getString("TemplateEngine.internalError") + message, t);  //$NON-NLS-1$
+                       }
+               } else {
+                       status = new Status(IStatus.ERROR, CUIPlugin.getPluginId(), -1, TemplateEngineMessages.getString("TemplateEngine.internalError") + message, null);       //$NON-NLS-1$
+               }
+               IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+               if(window == null){
+                       IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows();
+                       window = windows[0];
+               }
+               ErrorDialog.openError(window.getShell(), TemplateEngineMessages.getString("TemplateEngine.templateEngine"), message, status); //$NON-NLS-1$
+       }
+       
+       /**
+        * Shows the Status message in Dialog Box.
+        * @param message
+        * @param status
+     * 
+     * @since 4.0
+        */
+       public static void showStatusDialog(String message, IStatus status) {
+               IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+               if(window == null){
+                       IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows();
+                       window = windows[0];
+               }
+               ErrorDialog.openError(window.getShell(), TemplateEngineMessages.getString("TemplateEngine.templateEngine"), message, status); //$NON-NLS-1$
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/TemplateListSelectionPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/TemplateListSelectionPage.java
new file mode 100644 (file)
index 0000000..7cc7c99
--- /dev/null
@@ -0,0 +1,273 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.IWizardNode;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardSelectionPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+
+
+/**
+ *  TemplateListSelectionPage 
+ */
+class TemplateListSelectionPage extends WizardSelectionPage implements ISelectionChangedListener {
+
+       private String labelText;
+       private FormBrowser descriptionBrowser;
+       private TreeViewer wizardSelectionTreeViewer = null;
+       private TableViewer wizardSelectionTableViewer = null;
+       private StructuredViewer wizardSelectionViewer = null;
+       private TemplatesChoiceWizard parentWizard;
+       private Template[] templates;
+
+       public TemplateListSelectionPage(TemplatesChoiceWizard parentWizard) {
+               super("Template Selection"); //$NON-NLS-1$
+               setTitle(parentWizard.getListSelectionTitle());
+               setDescription(parentWizard.getListSelectionDescription());
+               this.labelText = parentWizard.getListSelectionLabel();
+               descriptionBrowser = new FormBrowser();
+               descriptionBrowser.setText(""); //$NON-NLS-1$
+               this.parentWizard = parentWizard;
+       }
+
+       public void createDescriptionIn(Composite composite) {
+               descriptionBrowser.createControl(composite);
+               Control c = descriptionBrowser.getControl();
+               GridData gd = new GridData(GridData.FILL_BOTH);
+               gd.widthHint = 200;
+               c.setLayoutData(gd);
+       }
+
+       public String getLabel() {
+               return labelText;
+       }
+       
+       public void setDescriptionText(String text) {
+               descriptionBrowser.setText(text);
+       }
+       
+       public void setDescriptionEnabled(boolean enabled) {
+               Control control = descriptionBrowser.getControl();
+               if (control != null) {
+                       control.setEnabled(enabled);
+               }
+       }
+
+       public void moveToNextPage() {
+               getContainer().showPage(getNextPage());
+       }
+
+       public void createControl(Composite parent) {
+               Composite container = new Composite(parent, SWT.NONE);
+               GridLayout layout = new GridLayout();
+               layout.verticalSpacing = 10;
+               container.setLayout(layout);
+               container.setLayoutData(new GridData(GridData.FILL_BOTH));
+               
+               Label label = new Label(container, SWT.NONE);
+               label.setText(getLabel());
+               GridData gd = new GridData();
+               label.setLayoutData(gd);
+               
+               SashForm sashForm = new SashForm(container, SWT.VERTICAL);
+               gd = new GridData(GridData.FILL_BOTH);
+               gd.widthHint = 300;
+               gd.minimumHeight = 230;
+               sashForm.setLayoutData(gd);
+               
+               boolean useTree = parentWizard.showTemplatesInTreeView();
+
+               if (useTree)
+               {
+                       wizardSelectionTreeViewer = new TreeViewer(sashForm, SWT.BORDER);
+                       wizardSelectionTreeViewer.setContentProvider(parentWizard);
+                       wizardSelectionTreeViewer.addDoubleClickListener(new IDoubleClickListener() {
+                               public void doubleClick(DoubleClickEvent event) {
+                                       selectionChanged(new SelectionChangedEvent(wizardSelectionTreeViewer, wizardSelectionTreeViewer.getSelection()));
+                                       moveToNextPage();
+                               }
+                       });
+                       wizardSelectionTreeViewer.setInput(templates);
+                       wizardSelectionTreeViewer.addSelectionChangedListener(this);
+                       wizardSelectionTreeViewer.getTree().setData("name", "templates"); //$NON-NLS-1$ //$NON-NLS-2$
+                       wizardSelectionViewer = wizardSelectionTreeViewer;
+                       
+               }
+               else
+               {
+                       wizardSelectionTableViewer = new TableViewer(sashForm, SWT.BORDER);
+                       wizardSelectionTableViewer.setContentProvider(parentWizard);
+                       wizardSelectionTableViewer.addDoubleClickListener(new IDoubleClickListener() {
+                               public void doubleClick(DoubleClickEvent event) {
+                                       selectionChanged(new SelectionChangedEvent(wizardSelectionTableViewer, wizardSelectionTableViewer.getSelection()));
+                                       moveToNextPage();
+                               }
+                       });
+                       wizardSelectionTableViewer.setInput(templates);
+                       wizardSelectionTableViewer.addSelectionChangedListener(this);
+                       wizardSelectionTableViewer.getTable().setData("name", "templates"); //$NON-NLS-1$ //$NON-NLS-2$
+                       wizardSelectionViewer = wizardSelectionTableViewer;
+                       
+               }
+               wizardSelectionViewer.getControl().setData(".uid", "wizardSelectionViewer"); //$NON-NLS-1$ //$NON-NLS-2$
+
+               createDescriptionIn(sashForm);
+               sashForm.setWeights(new int[] {75, 25});
+
+               Dialog.applyDialogFont(container);
+               setControl(container);
+       }
+       
+       public void selectionChanged(SelectionChangedEvent event) {
+               setErrorMessage(null);
+               IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+               Template currentWizardSelection = null;
+               Object selectedObject = null;
+               Iterator<?> iter = selection.iterator();
+               if (iter.hasNext()) {
+                       selectedObject = iter.next();
+                       if (selectedObject instanceof Template)
+                               currentWizardSelection = (Template) selectedObject;
+               }
+               if (currentWizardSelection == null) {
+                       setDescriptionText(parentWizard.getDescription(selectedObject));
+                       setSelectedNode(null);
+                       return;
+               }
+               final Template finalSelection = currentWizardSelection;
+               setSelectedNode(new WizardNode(this, finalSelection));
+               setDescriptionText(parentWizard.getDescription(finalSelection));
+               getContainer().updateButtons();
+       }
+       
+       public Template getTemplate() {
+               IWizardNode selectedNode = getSelectedNode();
+               if (selectedNode != null) {
+                       return ((WizardNode)selectedNode).getTemplate();
+               }
+               return null;
+       }
+       
+       public IWizardPage getNextPage(boolean shouldCreate) {
+               if (!shouldCreate) {
+                       return super.getNextPage();
+               }
+               IWizardNode selectedNode = getSelectedNode();
+               selectedNode.dispose();
+               IWizard wizard = selectedNode.getWizard();
+               if (wizard == null) {
+                       super.setSelectedNode(null);
+                       return null;
+               }
+               if (shouldCreate) {
+                       wizard.addPages();
+               }
+               
+               return wizard.getStartingPage();
+       }
+       
+       @Override
+       public boolean canFlipToNextPage() {
+               IStructuredSelection ssel = (IStructuredSelection)wizardSelectionViewer.getSelection();
+               return ssel != null && !ssel.isEmpty() && (ssel.getFirstElement() instanceof Template);
+       }
+
+       @Override
+       public void setVisible(boolean visible) {
+               if (visible) {
+                       Template[] templates = parentWizard.getTemplates();
+                       if (templatesHaveChanged(templates)) {
+                               this.templates = templates;
+                               wizardSelectionViewer.setInput(templates);
+                               wizardSelectionViewer.refresh();
+                               if (wizardSelectionTreeViewer != null) {
+                                       wizardSelectionTreeViewer.expandAll();
+                               }
+                               
+                               // select the first element by default
+                               if (wizardSelectionTableViewer != null) {
+                                       wizardSelectionTableViewer.setSelection(new StructuredSelection(wizardSelectionTableViewer.getElementAt(0)), true);
+                               }
+                               if (wizardSelectionTreeViewer != null) {
+                                       wizardSelectionTreeViewer.setSelection(new StructuredSelection(wizardSelectionTreeViewer.getTree().getItem(0).getData()), true);
+                               }
+                       }
+               }
+               super.setVisible(visible);
+               if (visible) {
+                       if (wizardSelectionTreeViewer != null) {
+                               wizardSelectionTreeViewer.getTree().setFocus();
+                       }                       
+                       if (wizardSelectionTableViewer != null) {
+                               wizardSelectionTableViewer.getTable().setFocus();
+                       }
+               }
+       }
+       
+       private boolean templatesHaveChanged(Template[] newTemplates) {
+               // doing this rather than an array compare because even when
+               // the templates are the same the objects are not.  we really
+               // just need to compare the template info.
+               boolean changed = false;
+               if (newTemplates != null && templates != null && newTemplates.length == templates.length) {
+                       for (int i=0; i<templates.length; i++) {
+                               if (!newTemplates[i].getTemplateInfo().equals(templates[i].getTemplateInfo())) {
+                                       changed = true;
+                                       break;
+                               }
+                       }
+               } else {
+                       changed = true;
+               }
+               
+               return changed;
+       }
+
+       Map<String, String> getDataInPreviousPages() {
+               return parentWizard.getAllDataInNonTemplatePages();
+       }
+
+       public IWizardDataPage[] getPagesAfterTemplatePages()
+       {
+               return parentWizard.getPagesAfterTemplatePages();
+       }
+       
+       public IWizardDataPage[] getPagesAfterTemplateSelection() throws InstantiationException, IllegalAccessException, ClassNotFoundException
+       {
+               return parentWizard.getPagesAfterTemplateSelectionWithExtraPages(getTemplate());                
+       }
+
+       public void adjustTemplateValues(Template template) {
+               parentWizard.adjustTemplateValues(template);            
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/TemplatesChoiceWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/TemplatesChoiceWizard.java
new file mode 100644 (file)
index 0000000..e384f45
--- /dev/null
@@ -0,0 +1,197 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWizard;
+import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
+
+import org.eclipse.cdt.core.templateengine.TemplateInfo;
+import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+
+/**
+ * A wizard intending to show a choice of templates (@see org.eclipse.cdt.core.templateenginee.Template) 
+ * before switching to the pages driven by the chosen template should extend from TemplatesChoiceWizard.
+ * Alternatively, when a choice of templates needn't be shown, TemplateDrivenWizard is a better fit.
+ * (@see org.eclipse.cdt.ui.templateengine.TemplateDrivenWizard)
+ *  
+ */
+public abstract class TemplatesChoiceWizard extends Wizard implements ITemplatesListProvider, IWorkbenchWizard {
+       private static final boolean DEBUG = false;
+       private TemplateListSelectionPage templateListSelectionPage;
+       protected IWorkbench workbench;
+       protected IStructuredSelection selection;
+
+       @Override
+       public final void addPages() {          
+               IWizardPage[] pages = getPagesBeforeTemplatePages();
+               for (IWizardPage page : pages) {
+                       addPage(page);
+               }
+
+               templateListSelectionPage = new TemplateListSelectionPage(this);
+               addPage(templateListSelectionPage);
+
+               pages = getPagesAfterTemplatePages();
+               for (IWizardPage page : pages) {
+                       addPage(page);
+               }
+       }
+
+       public String getListSelectionTitle()
+       {
+               return Messages.getString("TemplatesChoiceWizard.0"); //$NON-NLS-1$
+       }
+
+       public String getListSelectionDescription()
+       {
+               return Messages.getString("TemplatesChoiceWizard.1"); //$NON-NLS-1$
+       }
+
+       public String getListSelectionLabel()
+       {
+               return Messages.getString("TemplatesChoiceWizard.2"); //$NON-NLS-1$
+       }
+
+       protected abstract IWizardDataPage[] getPagesBeforeTemplatePages();
+
+       protected abstract IWizardDataPage[] getPagesAfterTemplatePages();
+
+       protected abstract IWizardDataPage[] getPagesAfterTemplateSelection();
+
+       IWizardDataPage[] getPagesAfterTemplateSelectionWithExtraPages(Template template) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
+               IWizardDataPage[] pages = getPagesAfterTemplateSelection();
+               TemplateInfo templateInfo = template.getTemplateInfo();
+               IPagesAfterTemplateSelectionProvider extraPagesProvider = (IPagesAfterTemplateSelectionProvider) templateInfo.getExtraPagesProvider();
+               if (extraPagesProvider != null) {
+                       List<IWizardDataPage> pageList = new ArrayList<IWizardDataPage>(Arrays.asList(pages));
+                       IWizardDataPage[] extraPages = extraPagesProvider.createAdditionalPages(this, workbench, selection);
+                       pageList.addAll(Arrays.asList(extraPages));
+                       pages = pageList.toArray(new IWizardDataPage[pageList.size()]);
+               }
+               return pages;           
+       }
+
+       IWizardDataPage[] getExtraCreatedPages(Template template) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
+               TemplateInfo templateInfo = template.getTemplateInfo();
+               IPagesAfterTemplateSelectionProvider extraPagesProvider = (IPagesAfterTemplateSelectionProvider) templateInfo.getExtraPagesProvider();
+               if (extraPagesProvider != null) {
+                       List<IWizardDataPage> pageList = new ArrayList<IWizardDataPage>();
+                       IWizardDataPage[] extraPages = extraPagesProvider.getCreatedPages(this);
+                       pageList.addAll(Arrays.asList(extraPages));
+                       return pageList.toArray(new IWizardDataPage[pageList.size()]);
+               }
+               return new IWizardDataPage[0];          
+       }
+
+       @Override
+       public boolean performFinish() {
+               IRunnableWithProgress op= new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() {
+                       public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+                               finishPage(monitor);
+                       }
+               });
+
+               try {
+                       getContainer().run(true, false, op);
+               } catch (InvocationTargetException e) {
+                       return false;
+               } catch  (InterruptedException e) {
+                       return false;
+               }
+               return true;
+
+       }
+
+       private boolean finishPage(IProgressMonitor monitor) {
+               IStatus[] statuses = templateListSelectionPage.getTemplate().executeTemplateProcesses(monitor, false);
+               if (statuses.length == 1 && statuses[0].getException() instanceof ProcessFailureException) {
+                       TemplateEngineUIUtil.showError(statuses[0].getMessage(), statuses[0].getException());
+                       return false;
+               }
+               if (DEBUG) {
+                       String msg = Messages.getString("TemplatesChoiceWizard.3"); //$NON-NLS-1$
+                       TemplateEngineUIUtil.showStatusDialog(msg, new MultiStatus(CUIPlugin.getPluginId(), IStatus.OK, statuses, msg, null));
+               }
+               return true;
+       }
+
+       /**
+        * Returns the Data in Non-Template Pages.
+        * @return Map,
+        */
+       public Map<String, String> getAllDataInNonTemplatePages() {
+               Map<String, String> map = new HashMap<String, String>();
+
+               IWizardDataPage[] pages = getPagesBeforeTemplatePages();
+               for (IWizardDataPage page : pages) {
+                       map.putAll(page.getPageData());
+               }
+
+               pages = getPagesAfterTemplateSelection();
+               for (IWizardDataPage page : pages) {
+                       map.putAll(page.getPageData());
+               }
+
+               try {
+                       pages = getExtraCreatedPages(getSelectedTemplate());
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+               for (IWizardDataPage page : pages) {
+                       map.putAll(page.getPageData());
+               }
+
+               pages = getPagesAfterTemplatePages();
+               for (IWizardDataPage page : pages) {
+                       map.putAll(page.getPageData());
+               }
+
+               return map;
+       }
+
+       /**
+        * initializes the workbench
+        */
+       public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
+               this.workbench = workbench;
+               this.selection = currentSelection;
+               initializeDefaultPageImageDescriptor();
+       }
+
+       protected void initializeDefaultPageImageDescriptor() {
+               // setDefaultPageImageDescriptor(descriptor);
+       }
+
+       public Template getSelectedTemplate() {
+               return templateListSelectionPage.getTemplate();
+       }
+
+       public void adjustTemplateValues(Template template) {
+               // Give the wizard a chance to adjust template values before they go into the page controls.
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/WizardNode.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/WizardNode.java
new file mode 100644 (file)
index 0000000..8c0b696
--- /dev/null
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine;
+
+import java.util.Map;
+
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.IWizardNode;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+
+import org.eclipse.cdt.ui.templateengine.pages.UIWizardPage;
+
+
+/**
+ * Wizard Node 
+ */
+class WizardNode implements IWizardNode {
+       private IWizard wizard;
+       private Template template;
+       private TemplateListSelectionPage parentPage;
+
+       /**
+        * Constructor.
+        * @param parentPage
+        * @param template
+        */
+       public WizardNode(TemplateListSelectionPage parentPage, Template template) {
+               this.parentPage = parentPage;
+               this.template = template;
+       }
+       
+       public void dispose() {
+               if (wizard != null) {
+                       wizard.dispose();
+                       wizard = null;
+               }
+       }
+       
+       /**
+        * Returns the Template
+        */
+       public Template getTemplate() {
+               return template;
+       }
+
+       public Point getExtent() {
+               return new Point(-1, -1);
+       }
+       
+       /**
+        * Returns the Wizard.
+        */
+       public IWizard getWizard() {
+               if (wizard != null) {
+                       return wizard;
+               }
+               wizard = new Wizard() {
+                       {
+                               setWindowTitle(template.getLabel());
+                       }
+                       
+                       private boolean finishPressed;
+                       
+                       @Override
+                       public void addPages() {
+                               IWizardPage[] wpages = null;
+                               try {
+                                       wpages = parentPage.getPagesAfterTemplateSelection();
+                                       for (IWizardPage wpage : wpages) {
+                                               addPage(wpage);
+                                       }
+                               } catch (Exception e) {
+                               }
+                               
+                               Map<String, UIWizardPage> pages = template.getUIPages();
+                               for (Object element : template.getPagesOrderVector()) {
+                                       String id = (String) element;
+                                       addPage(pages.get(id));
+                               }
+
+                               wpages = parentPage.getPagesAfterTemplatePages();
+                               for (IWizardPage wpage : wpages) {
+                                       addPage(wpage);
+                               }
+                       }
+                       
+                       @Override
+                       public boolean performFinish() {
+                               Map<String, String> valueStore = template.getValueStore();
+                               finishPressed = true;
+                               getContainer().updateButtons();
+                               IWizardPage[] wpages = getPages();
+                               for (IWizardPage page : wpages) {
+                                       if (page instanceof UIWizardPage)
+                                               valueStore.putAll(((UIWizardPage) page).getPageData());
+                               }
+                               template.getValueStore().putAll(parentPage.getDataInPreviousPages());
+                               return true;
+                       }
+                       
+                       @Override
+                       public boolean canFinish(){
+                               return !finishPressed && super.canFinish();
+                       }
+
+                       @Override
+                       public void createPageControls(Composite pageContainer) {
+                               super.createPageControls(pageContainer);
+                               parentPage.adjustTemplateValues(template);
+                               IWizardPage[] wpages = getPages();
+                               for (IWizardPage page : wpages) {
+                                       if (page instanceof UIWizardPage)
+                                       ((UIWizardPage) page).getComposite().getUIElement().setValues(template.getValueStore());
+                               }
+                       }
+
+                       @Override
+                       public Image getDefaultPageImage() {
+                               return parentPage.getImage();
+                       }
+               };
+               return wizard;
+       }
+
+       public boolean isContentCreated() {
+               return wizard != null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/event/PatternEvent.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/event/PatternEvent.java
new file mode 100644 (file)
index 0000000..d81f0a7
--- /dev/null
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.event;
+
+import java.util.EventObject;
+
+/**
+ * 
+ * PatternEvent class instances are created, when there is an unexpected input
+ * in the InputUIElement. Which results in a mismatch to the pattern of input
+ * data expected. This has to be updated in the UIPage. To do this,
+ * PatternEvent is fired. For which, the UIPage will be the registered listener.
+ * Here UIPage stands for WizardPage.
+ * 
+ * @since 4.0
+ */
+
+public class PatternEvent extends EventObject {
+
+       private static final long serialVersionUID = 0000000000L;
+
+       /**
+        * The description of this Event instance.
+        */
+       String eventMessage;
+
+       /**
+        * true indicates whether the user input is valid(according to pattern). This is useful, to update the UIPage with error messages. false otherwise.
+        */
+       private boolean valid;
+
+       /**
+        * The PatternEvent gets the Object source of this event, the same is passed
+        * to the EventObject.
+        * 
+        * @param source
+        */
+       private PatternEvent(Object source) {
+               super(source);
+       }
+
+       /**
+        * Overloaded constructor, the Object source of this event and the String
+        * message is paramete. Object source is passed as parameter to EventObject,
+        * the event description is initialized to eventMessage.
+        * 
+        * @param source
+        * @param eventMessage
+        */
+       public PatternEvent(Object source, String eventMessage, boolean valid) {
+               this(source);
+               this.eventMessage = eventMessage;
+               this.valid = valid;
+       }
+
+       /**
+        * return the String description of this Event instance.
+        * 
+        * @return String
+        */
+       @Override
+       public String toString() {
+               return eventMessage;
+       }
+
+       /**
+        * returns the valid flag.
+        * 
+        * @return boolean
+        */
+       public boolean getValid() {
+               return valid;
+       }
+
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/event/PatternEventListener.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/event/PatternEventListener.java
new file mode 100644 (file)
index 0000000..98a726a
--- /dev/null
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.event;
+
+import java.util.EventListener;
+
+/**
+ * PatternEventListener will be implemented by UIPage. When PatternEvent is
+ * fired by InputUIElement due to a mismatch of input entered by the user and
+ * the expected pattern of input.
+ * 
+ * @since 4.0
+ */
+
+public interface PatternEventListener extends EventListener {
+
+       /**
+        * This methods is implemented by calsses handling PatternEvent.
+        * PatternEvent instance is the parameter to this method.
+        * 
+        * @param aPet
+     * 
+     * @since 4.0
+        */
+       public void patternPerformed(PatternEvent aPet);
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/messages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/messages.properties
new file mode 100644 (file)
index 0000000..865733a
--- /dev/null
@@ -0,0 +1,46 @@
+###############################################################################
+# Copyright (c) 2007, 2009 Symbian Software Limited and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Symbian - Initial API and implementation
+# IBM Corporation
+###############################################################################
+
+TemplateDrivenWizard.0=Successful
+TemplateClassWizard.0=Templates Based Class Wizard
+TemplateClassWizard.1=Managed CDT projects class templates
+TemplateClassWizard.2=Select the type of class you would like to create.
+TemplateClassWizard.3=Select a class:
+TemplateClassWizard.4=Managed CDT Projects Class Wizard
+TemplateClassWizard.5=Add a new class to your existing project.
+TemplatesChoiceWizard.0=Template Selection
+TemplatesChoiceWizard.1=Select a template based upon the type of program you are creating.
+TemplatesChoiceWizard.2=Select a template:
+TemplatesChoiceWizard.3=Successful
+TemplateProjectWizard.1=New Managed CDT Project Wizard
+TemplateProjectWizard.2=New Managed CDT Project Wizard
+TemplateProjectWizard.3=Managed CDT Project
+TemplateProjectWizard.4=Managed CDT Project
+TemplateProjectWizard.5=Create a new managed CDT project.
+ProjectSelectionPage.0=Select a Managed CDT project
+ProjectSelectionPage.1=Select a Managed CDT project:
+ProjectSelectionPage.4=Project Name:
+ProjectSelectionPage.5=Browse...
+ProjectSelectionPage.6=Please enter a project name
+ProjectSelectionPage.7=Invalid Project Path
+ProjectSelectionPage.8=The project does not exist
+ProjectSelectionPage.9=Please select a CDT project
+ProjectSelectionPage.10=Project Selection
+ProjectSelectionPage.11=Choose a Project
+UIElementTreeBuilderHelper.InvalidEmptyLabel=Invalid item element in <property id="{0}">: attributes "label" and "value" must be present.
+UIElementTreeBuilderHelper.InvalidNonUniqueValue=Duplicate item value="{0}" in combo box <property id="{1}">.
+UIElementTreeBuilderHelper.UnknownWidgetType0=Unknown widget type: {0}
+UISelectWidget_ErrorNoneSelected0=Please choose a value for {0}
+UITextWidget.0=\ Project already exists in workspace.
+SimpleElementException.0=This Operation not supported on InputUIElement
+TemplateEngineMessage.Error=CDT New Project Wizard Template Engine Error
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/pages/Messages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/pages/Messages.java
new file mode 100644 (file)
index 0000000..0b53ce4
--- /dev/null
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.pages;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages {
+       private static final String BUNDLE_NAME = "org.eclipse.cdt.ui.templateengine.pages.messages"; //$NON-NLS-1$
+
+       private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
+                       .getBundle(BUNDLE_NAME);
+
+       private Messages() {
+       }
+
+       public static String getString(String key) {
+               try {
+                       return RESOURCE_BUNDLE.getString(key);
+               } catch (MissingResourceException e) {
+                       return '!' + key + '!';
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/pages/NewProjectCreationPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/pages/NewProjectCreationPage.java
new file mode 100644 (file)
index 0000000..7c5f74e
--- /dev/null
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Symbian - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.pages;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.templateengine.IWizardDataPage;
+
+/**
+ * The first page in a NewProjectWizard. This is the wizard page that
+ * asks the user for the name and location of the new project.
+ */
+public class NewProjectCreationPage extends WizardNewProjectCreationPage implements IWizardDataPage {  
+       private static final String ERROR_SUFFIX = Messages.getString("NewProjectCreationPage.0"); //$NON-NLS-1$
+       private static final String ERROR_SUFFIX_TOO_LONG = Messages.getString("NewProjectCreationPage.1"); //$NON-NLS-1$
+       private static final Status OK_STATUS = new Status(IStatus.OK, CUIPlugin.getPluginId(), 0, "", null); //$NON-NLS-1$
+
+       private Map<String, String> data;
+       private IWizardPage next;
+       
+       public NewProjectCreationPage(String name) {
+               super(name);
+               data= new HashMap<String, String>();
+               this.setDescription(Messages.getString("NewProjectCreationPage.3"));     //$NON-NLS-1$
+       }
+
+       public Map<String, String> getPageData() {
+               String projName = super.getProjectName().trim();
+               data.put("projectName", projName); //$NON-NLS-1$
+               data.put("baseName", getBaseName(projName)); //$NON-NLS-1$
+               data.put("baseNameUpper", getBaseName(projName).toUpperCase() ); //$NON-NLS-1$
+               data.put("baseNameLower", getBaseName(projName).toLowerCase() ); //$NON-NLS-1$
+               data.put("location", super.getLocationPath().toPortableString()); //$NON-NLS-1$
+               return data;
+       }
+
+       private String getBaseName(String projName) {
+               String baseName = projName;
+               int dot = baseName.lastIndexOf('.');
+               if (dot != -1) {
+                       baseName = baseName.substring(dot + 1);
+               }
+               dot = baseName.indexOf(' ');
+               if (dot != -1) {
+                       baseName = baseName.substring(0, dot);
+               }
+               return baseName;
+       }
+       
+       @Override
+       protected boolean validatePage() {
+               if (super.validatePage() == true) {
+                       IStatus validName = isValidName(getProjectName());
+                       if (!validName.isOK()) {
+                               setErrorMessage(validName.getMessage());
+                               return false;
+                       }
+                       return true;
+               }
+               return false;
+       }
+       
+       /**
+        * Projects names should only be alphanumeric and can contain ' ' and '_' chars. 
+        * Names are limited to 31 chars. Names cannot end in a '.' char.  Note that '.'
+        * characters currently not allowed as many of the command line generators get
+        * the name wrong for generated files.  e.g. my.foo project name results in
+        * foo.rsc, foo.rsg, etc.. rather than the expected my.foo.rsc.
+        * @param projectName - The unmodified project name from the project wizard. 
+        * @return an IStatus message on error.
+        * 
+        * Note: Platform may have a different project name constraints. Please subclass this
+        * to add your own versions of validnames for template projects.
+        */
+       private IStatus isValidName(String projectName) {
+               //String baseName = getBaseName(projectName);
+               String baseName = projectName;
+               
+               if (!Character.isLetter(baseName.charAt(0))) {
+                       return new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.ERROR, projectName + ERROR_SUFFIX, null);
+               }
+               
+               if (baseName.length() > 31) {
+                       return new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.ERROR, projectName + ERROR_SUFFIX_TOO_LONG, null);
+               }
+               
+               for (int i = 1, l = baseName.length(); i < l; i++) {
+                       char c = baseName.charAt(i);
+                       if (!Character.isLetterOrDigit(c) && c != '_' && c != ' ') {
+                               return new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.ERROR, projectName + ERROR_SUFFIX, null);
+                       }
+               }
+               
+               return OK_STATUS;
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.cdt.ui.templateengine.IWizardDataPage#setNextPage(org.eclipse.jface.wizard.IWizardPage)
+        */
+       public void setNextPage(IWizardPage next) {
+               this.next= next;
+       }
+       
+       /*
+        * (non-Javadoc)
+        * @see org.eclipse.jface.wizard.WizardPage#getNextPage()
+        */
+       @Override
+       public IWizardPage getNextPage() {
+               if(next != null) {
+                       return next;
+               }
+               return super.getNextPage();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/pages/TemplateInputDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/pages/TemplateInputDialog.java
new file mode 100644 (file)
index 0000000..d7d442a
--- /dev/null
@@ -0,0 +1,330 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.pages;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.core.templateengine.TemplateEngineUtil;
+
+
+/**
+ * Creates a JFace Dialog for the user to get name-value pair to perform
+ * SharedDefaults settings. The class takes care of user input validation.
+ */
+
+public class TemplateInputDialog extends Dialog {
+
+       /**
+        * Controls settings in the GUI
+        */
+       private static final String NAME = Messages.getString("TemplateInputDialog.0");// To be externalised //$NON-NLS-1$
+       private static final String VALUE = Messages.getString("TemplateInputDialog.1");// To be externalised //$NON-NLS-1$
+
+       /**
+        * Shell display messages for ADD and EDIT functionality
+        */
+
+       private static final String ADD_SHELL_MESSAGE = Messages.getString("TemplateInputDialog.2"); //$NON-NLS-1$
+       private static final String EDIT_SHELL_MESSAGE = Messages.getString("TemplateInputDialog.3"); //$NON-NLS-1$
+
+       /**
+        * Label Error Message
+        */
+       private Label errMessageLabel;
+       private String labelMessage = Messages.getString("TemplateInputDialog.4"); //$NON-NLS-1$
+
+       /**
+        * Text fields properties
+        */
+       private static final int TEXT_LIMIT = 100;
+
+       /**
+        * Dialog creation instances for display
+        */
+       private TemplatePreferencePage templatePreferencePage;
+       private TemplateInputDialog sharedDialog;
+       private Shell shell;
+       private Display display;
+
+       /**
+        * Dialog control instances
+        */
+       private Label valueLabel;
+       private Label nameLabel;
+       private Text valueText;
+       private Text nameText;
+       private Button oKButton;
+
+       /**
+        * Indentifies ADD/EDIT function
+        */
+       private int option;
+
+       /**
+        * Parent composite
+        */
+       private Composite parent;
+
+       /**
+        * JFace Dialog Constructor, constructs controls of the super class
+        * 
+        * @param parentShell
+        */
+
+       protected TemplateInputDialog(Shell parentShell) {
+               super(parentShell);
+               setShellStyle(getShellStyle() | SWT.RESIZE);
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+        */
+
+       @Override
+       protected void configureShell(Shell shell) {
+               super.configureShell(shell);
+               this.shell = shell;
+               display = shell.getDisplay();
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+        */
+
+       @Override
+       protected Control createDialogArea(Composite parent) {
+
+               this.parent = parent;
+               Composite composite = (Composite) super.createDialogArea(parent);
+               GridLayout gridLayout = new GridLayout(2, false);
+               composite.setLayout(gridLayout);
+               createControls(composite);
+               return composite;
+       }
+
+       /**
+        * Opens the Dialog to accept user input for shared values.
+        * 
+        * @param myDialog
+        * @param dataOption
+        */
+
+       public void open(TemplateInputDialog myDialog, int dataOption) {
+               this.option = dataOption;
+               sharedDialog = myDialog;
+               sharedDialog.create();
+               Button oK = getButton(IDialogConstants.OK_ID);
+               oK.setEnabled(false);
+               if (option == TemplatePreferencePage.OPTION_ADD) {
+
+                       shell.setText(ADD_SHELL_MESSAGE);
+               } else if (option == TemplatePreferencePage.OPTION_EDIT) {
+
+                       shell.setText(EDIT_SHELL_MESSAGE);
+               }
+
+               sharedDialog.open();
+       }
+
+       /**
+        * Creates control under the parent composite
+        * 
+        * @param composite
+        */
+
+       private void createControls(Composite composite) {
+
+               // Name Label
+               nameLabel = new Label(composite, SWT.NONE);
+               nameLabel.setText(NAME);
+
+               // Name Text Field
+               nameText = new Text(composite, SWT.BORDER | SWT.SINGLE);
+               nameText.setTextLimit(TEXT_LIMIT);
+               GridData textData = new GridData(GridData.FILL_HORIZONTAL);
+               textData.horizontalSpan = GridData.BEGINNING;
+               nameText.setLayoutData(textData);
+               addTextListener(nameText);
+
+               // Value Label
+               valueLabel = new Label(composite, SWT.NONE);
+               valueLabel.setText(VALUE);
+
+               // Value Text Field
+               valueText = new Text(composite, SWT.BORDER | SWT.SINGLE);
+               valueText.setTextLimit(TEXT_LIMIT);
+               GridData valueData = new GridData(GridData.FILL_HORIZONTAL);
+               valueData.horizontalSpan = GridData.BEGINNING;
+               valueData.verticalSpan = 5;
+               valueText.setLayoutData(valueData);
+               addTextListener(valueText);
+
+               // Label for Error Message
+               Color color = display.getSystemColor(SWT.COLOR_RED); // Get a red Color
+               Composite labelComposite = new Composite(parent, SWT.NONE);
+               labelComposite.setLayout(new GridLayout());
+               labelComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               errMessageLabel = new Label(labelComposite, SWT.COLOR_DARK_RED);
+               errMessageLabel.setForeground(color);
+               errMessageLabel.setText(labelMessage);
+               errMessageLabel.setVisible(false);
+
+               if (option == TemplatePreferencePage.OPTION_EDIT) {
+                       nameLabel.setEnabled(false);
+                       nameText.setEnabled(false);
+
+                       String name = TemplatePreferencePage.getSelectedItemNameFromTable();
+                       if (name != null) {
+                               nameText.setText(name);
+                       }
+               }
+       }
+
+       /**
+        * Adds Modify listeners to the Text fields
+        * 
+        * @param aText
+        */
+       public void addTextListener(final Text aText) {
+
+               ModifyListener mListener = new ModifyListener() {
+                       public void modifyText(ModifyEvent e) {
+                               String nameField = aText.getText();
+                               textChanged(nameField);
+                       }
+               };
+
+               aText.addModifyListener(mListener);
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.dialogs.Dialog#okPressed() This method is
+        *      overridden to perform custom events on OK button.
+        */
+
+       @Override
+       protected void okPressed() {
+               if (option == TemplatePreferencePage.OPTION_ADD) {
+                       String name = nameText.getText();
+                       String value = valueText.getText();
+
+                       if (name != TemplatePreferencePage.Blank && value != TemplatePreferencePage.Blank) {
+                               templatePreferencePage = new TemplatePreferencePage(name, value);
+                               templatePreferencePage.addNewDataIntoTable();
+
+                               if (TemplatePreferencePage.isDup) {
+                                       nameText.setText(TemplatePreferencePage.Blank);
+                                       nameText.setFocus();
+                                       TemplatePreferencePage.isDup = false;
+                               } else if (!TemplatePreferencePage.isDup) {
+                                       nameText.setFocus();
+                                       sharedDialog.close();
+                               }
+                       }
+               }
+
+               if (option == TemplatePreferencePage.OPTION_EDIT) {
+                       String name = nameText.getText();
+                       String value = valueText.getText();
+
+                       if (!value.equals(TemplatePreferencePage.Blank)) {
+                               templatePreferencePage = new TemplatePreferencePage(name, value);
+                               templatePreferencePage.updateDataInTheTable();
+                       }
+                       sharedDialog.close();
+               }
+       }
+
+       /**
+        * Pops up Message dialog if duplicate entry is found and returns
+        * confirmation.
+        * 
+        * @return result
+        */
+
+       public int popDuplicate() {
+
+               MessageBox mBox = new MessageBox(new Shell(), SWT.ICON_INFORMATION);
+               mBox.setText(TemplatePreferencePage.Message);
+               mBox.setMessage(TemplatePreferencePage.DuplicateEntry);
+               int result = mBox.open();
+               return result;
+
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.jface.dialogs.Dialog#cancelPressed()
+        */
+       @Override
+       protected void cancelPressed() {
+
+               sharedDialog.close();
+       }
+
+       /**
+        * 
+        * Implements the modify listener for the text field Name and Value fields.
+        * 
+        * @param textField
+        */
+
+       private void textChanged(String textField) {
+
+               errMessageLabel.setVisible(false);
+               try {
+
+                       // Diable OK button if special characters are entererd.
+                       if (textField.matches(TemplatePreferencePage.Blank)) {
+
+                               oKButton = getButton(IDialogConstants.OK_ID);
+                               errMessageLabel.setText(labelMessage);
+                               errMessageLabel.setVisible(true);
+                               oKButton.setEnabled(false);
+
+                       }
+
+                       // Enable OK button if and only if data is entered.
+                       else if (!nameText.getText().equals(TemplatePreferencePage.Blank)
+                                       && !valueText.getText().equals(TemplatePreferencePage.Blank)) {
+
+                               oKButton = getButton(IDialogConstants.OK_ID);
+                               oKButton.setEnabled(true);
+                       }
+
+               } catch (Exception exp) {
+                       TemplateEngineUtil.log(exp);
+               }
+
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/pages/TemplatePreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/pages/TemplatePreferencePage.java
new file mode 100644 (file)
index 0000000..2ee976e
--- /dev/null
@@ -0,0 +1,591 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ * IBM Corporation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.pages;
+
+import java.util.List;
+
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.viewers.ColumnLayoutData;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.PlatformUI;
+import org.w3c.dom.Element;
+
+import org.eclipse.cdt.core.templateengine.SharedDefaults;
+import org.eclipse.cdt.core.templateengine.TemplateEngine;
+import org.eclipse.cdt.core.templateengine.TemplateEngineHelper;
+import org.eclipse.cdt.core.templateengine.TemplateEngineUtil;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+
+/**
+ * This class represents a preference page that is contributed to the
+ * Preferences dialog. By Provided GUI for SharedDefaults settings for the
+ * Templates present in the Template Engine
+ */
+
+public class TemplatePreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+
+       /**
+        * Preference Page buttons
+        */
+
+       private static final String EditButton = Messages.getString("TemplatePreferencePage.8"); //$NON-NLS-1$
+       private static final String DeleteButton = Messages.getString("TemplatePreferencePage.9"); //$NON-NLS-1$
+       private static final String PageDescription = Messages.getString("TemplatePreferencePage.0");//$NON-NLS-1$
+       public static final String Blank = "";//$NON-NLS-1$
+
+       /**
+        * Validation Messages
+        */
+       public static final String Message = Messages.getString("TemplatePreferencePage.1");//$NON-NLS-1$
+       protected static final String DuplicateEntry = Messages.getString("TemplatePreferencePage.2");//$NON-NLS-1$
+       private static final String DeleteValidator = Messages.getString("TemplatePreferencePage.3");//$NON-NLS-1$
+       private static final String DeleteShellMessage = Messages.getString("TemplatePreferencePage.4");//$NON-NLS-1$
+
+       /**
+        * Button ToolTips
+        */
+       private static final String TableToolTip = Messages.getString("TemplatePreferencePage.5");//$NON-NLS-1$
+       private static final String EditToolTip = Messages.getString("TemplatePreferencePage.6");//$NON-NLS-1$
+       private static final String DeleteToolTip = Messages.getString("TemplatePreferencePage.7");//$NON-NLS-1$
+
+       /**
+        * Class instances
+        */
+       private static TemplateInputDialog inputDialog;
+       private static SharedDefaults sharedDefaults = SharedDefaults.getInstance();
+
+       /**
+        * Table Attributes
+        */
+       private int columnWidth = 100;
+       private int columnWeight = 50;
+       private String columnNames[];
+       private static List<Element> sharedElementList;
+       private int attrListSize;
+
+       private ColumnLayoutData columnLayouts[] = { new ColumnWeightData(columnWeight, columnWidth),
+                       new ColumnWeightData(columnWeight, columnWidth) };
+
+       /**
+        * InfoHelp for SharedDefault
+        */
+       private String pageID;
+       private String SharedContextHelpID = "shared_defaults_help";//$NON-NLS-1$
+
+       /**
+        * Button instance for ADD/EDIT/DELETE
+        */
+
+       private Button editButton;
+       private Button deleteButton;
+
+       /**
+        * Checks for row(s) deletion
+        */
+       private static boolean isDeleted;
+
+       /**
+        * Checks for redundant data
+        */
+       private boolean isRedundant;
+
+       /**
+        * Takes isRedundant reference to get reflected in different class scope See
+        * TemplateInputDialog class
+        */
+       public static boolean isDup;
+       private static String delItemNames[] = null;
+       private static Table table;
+
+       /**
+        * Add/Edit option values
+        */
+       protected static final int OPTION_ADD = 0;
+       protected static final int OPTION_EDIT = 1;
+
+       /**
+        * Dialog input values arriving from TemplateInputDialog class
+        */
+       private String name;
+       private String value;
+
+       /**
+        * Constructor to initialize defaults
+        */
+
+       public TemplatePreferencePage() {
+
+               noDefaultAndApplyButton();
+               initializeDefaults();
+       }
+
+       /**
+        * Sets the values of the Message Dialog
+        * 
+        * @param aName
+        * @param aValue
+        */
+       public TemplatePreferencePage(String aName, String aValue) {
+               this.name = aName;
+               this.value = aValue;
+       }
+
+       /**
+        * Sets default settings and gathers attributes from the XML for Table
+        * properties
+        */
+
+       private void initializeDefaults() {
+               columnNames = new String[] { Messages.getString("TemplatePreferencePage.10"), Messages.getString("TemplatePreferencePage.11") };  //$NON-NLS-1$//$NON-NLS-2$
+               // Setting InfoPop help (plugin-id+ContextID).
+               pageID = CUIPlugin.getPluginId() + "." + //$NON-NLS-1$
+                               SharedContextHelpID;
+
+               setTableAttributes();
+
+       }
+
+       /**
+        * Creates controls on the Preference Page Adds the created Table and Button
+        * composite to the parent composite.
+        * 
+        * @param parent
+        * @return subComposite
+        */
+
+       @Override
+       protected Control createContents(Composite parent) {
+
+               Composite composite = new Composite(parent, SWT.NONE);
+               GridLayout layout = new GridLayout();
+               layout.marginHeight = 0;
+               layout.marginWidth = 0;
+               composite.setLayout(layout);
+
+               Label pageLabel = new Label(composite, SWT.NONE);
+               pageLabel.setText(PageDescription);
+
+               Composite subComposite = new Composite(parent, SWT.NONE);
+               GridLayout subLayout = new GridLayout(2, false);
+               GridData gridData = new GridData(GridData.FILL_BOTH);
+               subComposite.setLayout(subLayout);
+               subComposite.setLayoutData(gridData);
+
+               addFirstSection(subComposite);
+               addSecondSection(subComposite);
+
+               // Info help for SharedDefault is displayed when Functional Key (F1) is
+               // triggered.
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(super.getControl(), pageID);
+               return subComposite;
+
+       }
+
+       /**
+        * Adds table into the first composite present under parent Updates the
+        * Table with backend persistence data.
+        * 
+        * @param parent
+        */
+
+       private void addFirstSection(Composite parent) {
+               createTable(parent);
+               setTableAttributes();
+               addXMLDataIntoTable();
+       }
+
+       /**
+        * Creates second composite for buttons present under the parent
+        * 
+        * @param parent
+        */
+
+       private void addSecondSection(Composite parent) {
+               Composite composite = createDefaultComposite(parent);
+               addButtonControls(composite);
+       }
+
+       /**
+        * Creates default composite area for the Buttons
+        * 
+        * @param parent
+        * @return composite
+        */
+
+       private Composite createDefaultComposite(Composite parent) {
+
+               Composite composite = new Composite(parent, SWT.NULL);
+               FillLayout layout = new FillLayout(SWT.VERTICAL);
+               layout.spacing = 5;
+               layout.marginWidth = 0;
+               layout.marginHeight = 0;
+               composite.setLayout(layout);
+
+               GridData gridData = new GridData();
+               gridData.verticalAlignment = GridData.BEGINNING;
+               composite.setLayoutData(gridData);
+
+               return composite;
+
+       }
+
+       /**
+        * Creates Table with XML properties as its settings
+        * 
+        * @param composite
+        */
+
+       private void createTable(Composite composite) {
+
+               table = new Table(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER
+                               | SWT.NO_REDRAW_RESIZE);
+
+               GridData gridData = new GridData(GridData.FILL_BOTH);
+               gridData.heightHint = convertHeightInCharsToPixels(10);
+               gridData.widthHint = convertWidthInCharsToPixels(10);
+
+               table.setLayoutData(gridData);
+               TableLayout layout = new TableLayout();
+               table.setLayout(layout);
+               table.setLinesVisible(true);
+               table.setHeaderVisible(true);
+               table.setToolTipText(TableToolTip);
+
+               // The attribute size becomes zero when no data
+               // remains in the table. To avoid fault creation of
+               // the table the attribute size to required columns
+               // in the table.
+               if (attrListSize == 0) {
+                       attrListSize = 2;
+               }
+
+               for (int nCols = 0; nCols < attrListSize; nCols++) {
+                       layout.addColumnData(columnLayouts[nCols]);
+                       TableColumn tColumn = new TableColumn(table, SWT.LEFT, nCols);
+                       tColumn.setWidth(columnWidth);
+                       tColumn.setText(columnNames[nCols]);
+               }
+
+               addTableListener();
+       }
+
+       /**
+        * Table listener added to enable EDIT/DELETE functionality only when table
+        * listenes to an event.
+        */
+       private void addTableListener() {
+
+               SelectionListener sListener = new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               boolean isSelected = table.isSelected(table.getSelectionIndex());
+                               int selectionCount = table.getSelectionCount();
+
+                               // Enable EDIT/DELETE button when row(s) get selected
+                               if (isSelected) {
+                                       editButton.setEnabled(true);
+                                       deleteButton.setEnabled(true);
+                               }
+
+                               // disable EDIT button if more than one row is selected
+                               if (selectionCount > 1)
+                                       editButton.setEnabled(false);
+                       }
+               };
+               table.addSelectionListener(sListener);
+       }
+
+       /**
+        * Adds XML backend data into the table Supports for pesistency.
+        */
+
+       private void addXMLDataIntoTable() {
+               for (int i = 0, l = sharedElementList.size(); i < l; i++) {
+                       Element xmlElement = sharedElementList.get(i);
+                       String name = xmlElement.getAttribute(TemplateEngineHelper.ID);
+                       String value = xmlElement.getAttribute(TemplateEngineHelper.VALUE);
+
+                       if (name.equals(Blank) && value.equals(Blank))
+                               return;
+
+                       String backEndData[] = new String[] { name, value };
+                       TableItem backEndItem = new TableItem(table, SWT.NONE);
+
+                       for (int data = 0; data < backEndData.length; data++) {
+                               if (backEndData[data] != null)
+                                       backEndItem.setText(data, backEndData[data]);
+                       }
+               }
+       }
+
+       /**
+        * Creates button controls on the first composite present under parent
+        * composite. Its aligned at rightmost end of Table and top of the second
+        * composite.
+        * 
+        * @param composite
+        */
+
+       private void addButtonControls(Composite composite) {
+
+               editButton = new Button(composite, SWT.PUSH);
+               editButton.setText(EditButton);
+               editButton.setEnabled(false);
+               editButton.setToolTipText(EditToolTip);
+               addButtonListener(editButton);
+
+               deleteButton = new Button(composite, SWT.PUSH);
+               deleteButton.setText(DeleteButton);
+               deleteButton.setEnabled(false);
+               deleteButton.setToolTipText(DeleteToolTip);
+               addButtonListener(deleteButton);
+
+       }
+
+       /**
+        * Constructs button listeners to trigger specific functionality
+        * 
+        * @param button
+        */
+       public void addButtonListener(final Button button) {
+
+               inputDialog = new TemplateInputDialog(getShell());
+               SelectionListener listener = new SelectionAdapter() {
+
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               if (e.getSource().equals(editButton)) {
+                                       String editItemString = getSelectedItemNameFromTable();
+                                       if (editItemString != null) {
+                                               if (editItemString != Blank) {
+                                                       inputDialog.open(inputDialog, OPTION_EDIT);
+                                               }
+                                       }
+                               }
+
+                               if (e.getSource().equals(deleteButton)) {
+                                       deleteRow();
+                                       editButton.setEnabled(false);
+                                       deleteButton.setEnabled(false);
+                               }
+                       }
+               };
+               button.addSelectionListener(listener);
+       }
+
+       /**
+        * Adding new data into the table and adds the same data to the backend XML
+        * Checks for duplicate entries and null values
+        */
+
+       public void addNewDataIntoTable() {
+
+               String addData[] = new String[] { name, value };
+               if (!isDeleted) {
+                       TableItem duplicateItems[] = table.getItems();
+                       TableItem duplicateItem = null;
+
+                       for (TableItem duplicateItem2 : duplicateItems) {
+                               duplicateItem = duplicateItem2;
+                               String duplicateString = duplicateItem.getText();
+
+                               if (duplicateString.equals(name)) {
+                                       int result = inputDialog.popDuplicate();
+                                       if (result == SWT.OK) {
+                                               isRedundant = true;
+                                               isDup = isRedundant;
+                                               break;
+                                       }
+                               }
+                       }
+
+                       // Check if not redundant
+                       if (!isRedundant) {
+                               TableItem tableItem = new TableItem(table, SWT.NONE);
+
+                               for (int data = 0; data < addData.length; data++) {
+                                       tableItem.setText(data, addData[data]);
+                               }
+
+                               isRedundant = false;
+                       }
+               }
+
+               sharedDefaults.addToBackEndStorage(name, value);
+       }
+
+       /**
+        * Gets the size of the Attributes of an Element of XML file
+        * 
+        * @param sharedElementList
+        * @return attrListSize
+        */
+       private int getAttributeSize() {
+               try {
+                       int listSize = sharedElementList.size();
+                       int i = 0;
+                       while (i < listSize) {
+                               Element xmlElement = sharedElementList.get(i++);
+                               attrListSize = xmlElement.getAttributes().getLength();
+                       }
+               } catch (Exception exp) {
+                       TemplateEngineUtil.log(exp);
+               }
+               return attrListSize;
+       }
+
+       /**
+        * Setting the table attributes with the XML properties Sets XML-document
+        * Element List as the number of table rows and XML-document Attribute List
+        * as the number of table columns
+        */
+
+       private void setTableAttributes() {
+
+               try {
+                       SharedDefaults sharedTemp = new SharedDefaults();
+                       sharedElementList = TemplateEngine.getChildrenOfElement(sharedTemp.document.getDocumentElement());
+                       attrListSize = getAttributeSize();
+                       sharedDefaults.putAll(sharedTemp.getSharedDefaultsMap());
+
+               } catch (Exception exp) {
+                       TemplateEngineUtil.log(exp);
+               }
+       }
+
+       public void init(IWorkbench workbench) {
+
+       }
+
+       /**
+        * Updating data with the changed value for a given ID in the table.
+        */
+
+       public void updateDataInTheTable() {
+
+               try {
+                       int selectedItemIndex = table.getSelectionIndex();
+                       TableItem selectedItem = table.getItem(selectedItemIndex);
+                       String updateString[] = new String[] { name, value };
+                       selectedItem.setText(updateString);
+                       sharedDefaults.updateToBackEndStorage(name, value);
+               } catch (Exception exp) {
+                       TemplateEngineUtil.log(exp);
+               }
+       }
+
+       /**
+        * Gives the item for the selected row in the table
+        * 
+        * @return selectedItemName
+        */
+
+       public static String getSelectedItemNameFromTable() {
+
+               String selectedItemName = null;
+               int selectedItemIndex = 0;
+
+               try {
+                       selectedItemIndex = table.getSelectionIndex();
+               }
+
+               catch (Exception exp) {
+                       TemplateEngineUtil.log(exp);
+               }
+
+               TableItem selectedItem = table.getItem(selectedItemIndex);
+               selectedItemName = selectedItem.getText();
+               return selectedItemName;
+
+       }
+
+       /**
+        * Deletes the data for the specified row Data also gets deleted at the
+        * backend with Key-name as an identifier.
+        */
+       private void deleteRow() {
+
+               int result = 0;
+               String nonEmptyItemString = getSelectedItemNameFromTable();
+
+               if (nonEmptyItemString != null)
+                       result = confirmdeleteContents(nonEmptyItemString);
+
+               if (result == SWT.OK) {
+                       int itemSelected[] = table.getSelectionIndices();
+                       table.remove(itemSelected);
+                       
+                       if (delItemNames != null) {
+                               sharedDefaults.deleteBackEndStorage(delItemNames);
+                       }
+               }
+
+               else if (result == SWT.CANCEL)
+                       isDeleted = false;
+       }
+
+       /**
+        * Sets confirmation for the data deletion at the fronend and backend
+        * 
+        * @param selectedItems
+        * @return result
+        */
+
+       private int confirmdeleteContents(String selectedItems) {
+
+               int result = 0;
+               TableItem deleteItems[] = null;
+
+               if (selectedItems != Blank) {
+
+                       deleteItems = table.getSelection();
+                       delItemNames = new String[deleteItems.length];
+
+                       for (int nDel = 0; nDel < deleteItems.length; nDel++) {
+
+                               TableItem item = deleteItems[nDel];
+                               delItemNames[nDel] = item.getText();
+
+                       }
+
+                       MessageBox mBox = new MessageBox(getShell(), SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
+                       mBox.setText(DeleteShellMessage);
+                       mBox.setMessage(DeleteValidator);
+                       result = mBox.open();
+
+               }
+
+               return result;
+
+       }
+
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/pages/UIPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/pages/UIPage.java
new file mode 100644 (file)
index 0000000..b2f91b3
--- /dev/null
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.pages;
+
+import java.net.URL;
+import java.util.Map;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.widgets.Control;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.templateengine.TemplateEngineUtil;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.templateengine.uitree.UIElement;
+import org.eclipse.cdt.ui.templateengine.uitree.uiwidgets.UIComposite;
+
+/**
+ * 
+ * The UIPage extends DialogPage, it implements the createControl() abstract
+ * method. The UIPage is the base class for UIWizardPage. The UIPage contains a
+ * UIComposite, which extends a SWT composite. The SWT widgets are added to
+ * UIComposite.
+ */
+public abstract class UIPage extends DialogPage {
+       /**
+        * The Composite belonging to this page. The SWT widgets are added to this Composite. UIComposite instance is the top level control of this page. This top level control is initialized in createControl method.
+        */
+       protected UIComposite uiComposite;
+
+       /**
+        * resources ID which will be displayed as F1 help in Title area.
+        */
+       protected static String RESOURCES_ID = CCorePlugin.PLUGIN_ID + ".resources"; //$NON-NLS-1$
+
+       /**
+        * The UIElement (group), to which this page corresponds. Every UIElement group corresponds to a UIPage. The children of this goup are UIElement's (SWT widgets). Which are added to the UIComposite.
+        */
+       protected final UIElement uiElement;
+
+       /**
+        * ValueStore for this instance of Template.
+        */
+       protected final Map<String, String> valueStore;
+
+       /**
+        * Title set for this WizardPage.
+        */
+       protected String title;
+
+       /**
+        * Property Group Id corresponding this page
+        */
+       protected String pageId;
+
+       private ImageDescriptor imageDescriptor;
+
+       /**
+        * 
+        * @param name
+        *            Name of this UIPage.
+        * @param element
+        *            The group UIElement.
+        */
+       protected UIPage(String name, UIElement element, Map<String, String> valueStore) {
+               super(name);
+               setTitle(name);
+               setDescription(element.getAttributes().get(UIElement.DESCRIPTION));
+               try {
+                       String imageLoc = element.getAttributes().get(UIElement.IMAGELOCATION);
+                       if (imageLoc != null) {
+                               URL url = FileLocator.toFileURL(FileLocator.find(CCorePlugin.getDefault().getBundle(), new Path(imageLoc), null));
+                               imageDescriptor = ImageDescriptor.createFromURL(url);
+                       }
+               } catch (Exception e) {
+                       TemplateEngineUtil.log(e);
+               }
+
+               super.setImageDescriptor(imageDescriptor);
+               //TODO: Fix the imagedescriptor later.
+               //setImageDescriptor(TemplateEnginePlugin.imageDescriptorFromPlugin(TemplateEnginePlugin.getDefault().getWizardIconPluginID(), TemplateEnginePlugin.getDefault().getWizardIconFile()));
+
+               title = name;
+               uiElement = element;
+               uiElement.setValues(valueStore);
+               this.valueStore = valueStore;
+               //TODO: Check the from which plugin the PLUGIN_ID comes from i.e. from CCorePlugin or CUIPlugin
+               pageId = CUIPlugin.getPluginId() + "." + (uiElement.getAttributes()).get(UIElement.ID); //$NON-NLS-1$
+       }
+
+       /**
+        * The data contained in the Input elements (SWT widgets), on this page is
+        * extracted and put into an HashMap. The same is returned.
+        * 
+        * @return HashMap. The data contained in the widgets on this page.
+        */
+       public Map<String, String> getPageData() {
+               return uiElement.getValues();
+       }
+
+       /**
+        * This is an overridden definition for the same method in DialogPage. The
+        * top level control is returned.
+        * 
+        * @return Control.
+        */
+       @Override
+       public Control getControl() {
+               return uiComposite;
+       }
+
+       /**
+        * 
+        * This returns UICompostie as UIComposite instance. Unlike the getControl.
+        * 
+        * @return UIComposite, used in this page.
+        */
+       public UIComposite getComposite() {
+               return uiComposite;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/pages/UIPagesProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/pages/UIPagesProvider.java
new file mode 100644 (file)
index 0000000..1031479
--- /dev/null
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.pages;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.core.templateengine.TemplateEngineUtil;
+import org.eclipse.cdt.ui.templateengine.SimpleElementException;
+import org.eclipse.cdt.ui.templateengine.uitree.InputUIElement;
+import org.eclipse.cdt.ui.templateengine.uitree.SimpleUIElementGroup;
+import org.eclipse.cdt.ui.templateengine.uitree.UIElement;
+
+
+/**
+ * The UIPagesProvider creates a Map of UIPages. The Map will have ID as key,
+ * UIPage as value. The sequence of call to get Map of UIPages. 1.
+ * clearOrderVector() for all PropertyGroup Elements. 2. getUIPages(...)
+ * 
+ */
+public class UIPagesProvider {
+
+       /**
+        * maintains the Page display order.
+        */
+       private List<String> orderVector;
+
+
+       public UIPagesProvider() {
+               orderVector = new ArrayList<String>();
+       }
+       
+       /**
+        * after getting this clear the Vector.
+        * 
+        * @return Vector
+        */
+       public List<String> getOrderVector() {
+               return orderVector;
+       }
+
+       /**
+        * re-initialize the Vector.
+        */
+       public void clearOrderVector() {
+               orderVector = new ArrayList<String>();
+       }
+
+       /**
+        * This class has methods to return an HashMap of UIPages. The UIPages will
+        * correspond to UIElement group passed as parameter to this method. For a
+        * group UIElement, the children count is taken. An array of UIPage for the
+        * count is created. The same is initialized with UIPages.
+        * 
+        * @param uiElement
+        *            UIElement group root element. Which can be converted to a
+        *            UIPage.
+        * @param valueStore
+        * @return HashMap, UIPages corresponding to param aUIElement.
+        */
+       public Map<String, UIWizardPage> getWizardUIPages(UIElement uiElement, Map<String, String> valueStore) {
+               int childCount = 0;
+
+               try {
+                       childCount = uiElement.getChildCount();
+               } catch (SimpleElementException e) {
+                       TemplateEngineUtil.log(e);
+               }
+
+               // HashMap of UIPages
+               HashMap<String, UIWizardPage> pageMap = new HashMap<String, UIWizardPage>();
+
+               // If uiElement contains other group elements as children.
+               if (hasChildUIGroupElement(uiElement)) {
+
+                       for (int i = 0; i < childCount; i++) {
+                               try {
+                                       pageMap.putAll(getWizardUIPages(uiElement.getChild(i), valueStore)); // recursion
+                               } catch (SimpleElementException e) {
+                                       TemplateEngineUtil.log(e);
+                               }
+                       }
+               }
+               else {
+                       if ((hasChildUIElement(uiElement))) {
+                               String label = uiElement.getAttributes().get(UIElement.TITLE);
+                               String description = (uiElement.getAttributes()).get(UIElement.DESCRIPTION);
+                               UIWizardPage uiPage = new UIWizardPage(label, description, uiElement, valueStore);
+
+                               pageMap.put((uiElement.getAttributes()).get(UIElement.ID), uiPage);
+                               addToOrderVector((uiElement.getAttributes()).get(UIElement.ID));
+                       }
+               }
+               return pageMap;
+       }
+
+       /**
+        * whether the given (node in UIElementTree) UIElement contains children of
+        * group type.
+        * 
+        * @param parent
+        * @return boolean, true if it does, false otherwise.
+        */
+       public boolean hasChildUIGroupElement(UIElement parent) {
+               boolean retVal = false;
+               try {
+                       if (parent.getChildCount() > 0) {
+                               for (int i = 0; i < parent.getChildCount(); i++) {
+                                       if (parent.getChild(i) instanceof SimpleUIElementGroup) {
+                                               retVal = true;
+                                               break;
+                                       }
+                               }
+                       }
+               } catch (SimpleElementException see) {
+                       retVal = false;
+               }
+               return retVal;
+       }
+
+       /**
+        * whether the given (node in UIElementTree) UIElement contains children of
+        * UIElement type.
+        * 
+        * @param parent
+        * @return boolean, true if it does, false otherwise.
+        */
+       public boolean hasChildUIElement(UIElement parent) {
+               boolean retVal = false;
+               try {
+                       if (parent.getChildCount() > 0) {
+                               for (int i = 0; i < parent.getChildCount(); i++) {
+                                       if (parent.getChild(i) instanceof InputUIElement) {
+                                               retVal = true;
+                                               break;
+                                       }
+                               }
+                       }
+               } catch (SimpleElementException see) {
+                       retVal = false;
+               }
+               return retVal;
+       }
+
+       /**
+        * If the order vector contains the page id return, do not add it to order
+        * vector. HashMap will not allow duplicate keys.
+        * 
+        * @param pageId
+        */
+       private void addToOrderVector(String pageId) {
+               for(String id : orderVector) {
+                       if (id.equalsIgnoreCase(pageId))
+                               return;
+               }
+               orderVector.add(pageId);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/pages/UIWizardPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/pages/UIWizardPage.java
new file mode 100644 (file)
index 0000000..d2bb071
--- /dev/null
@@ -0,0 +1,333 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.pages;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.IWizardContainer;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.ui.templateengine.IWizardDataPage;
+import org.eclipse.cdt.ui.templateengine.event.PatternEvent;
+import org.eclipse.cdt.ui.templateengine.event.PatternEventListener;
+import org.eclipse.cdt.ui.templateengine.uitree.UIElement;
+import org.eclipse.cdt.ui.templateengine.uitree.uiwidgets.UIComposite;
+
+
+/**
+ * UIWizardPage provides implementation IWizardPage. UIWizardPage is a
+ * WizardPage.
+ */
+
+public class UIWizardPage extends UIPage implements IWizardDataPage, PatternEventListener {
+
+       /**
+        * This map will contain reference to the source widgets, which has generated the 
+        * SWT events. If this map contains an event source, the error message will not be cleared.
+        */
+       HashMap<Object, String> validInvalid;
+
+       /**
+        * Page Name
+        */
+       private String name;
+
+       /**
+        * The Wizard to which the Page belongs. null, If this page is yet to be added to a Wizard.
+        */
+       private IWizard wizard = null;
+
+       /**
+        * Indicates whether this page is complete.
+        */
+       private boolean isPageComplete;
+
+       /**
+        * That page that was shown right before this page became visible. null if none.
+        */
+       private IWizardPage previousPage = null;
+
+       private IWizardPage nextPage = null;
+       
+       /**
+        * Title of the page, Page Name and UIElement group are the parameters.
+        * 
+        * @param title
+        *            Title of this page
+        * @param pageName
+        *            Name of this page
+        * @param uiElement
+        *            The UIElement group.
+        */
+       public UIWizardPage(String title, String pageName, UIElement uiElement, Map<String, String> valueStore) {
+               super(title, uiElement, valueStore);
+               name = pageName;
+               validInvalid = new HashMap<Object, String>();
+               isPageComplete = uiElement.isValid();
+       }
+
+       /**
+        * returns true if the page is complete, and there is a next page to flip.
+        * 
+        * @return boolean. true if can flip to next page, otherwise false.
+        */
+       public boolean canFlipToNextPage() {
+               boolean retVal = false;
+
+               if (isPageComplete() && (getNextPage() != null))
+                       retVal = true;
+
+               return retVal;
+       }
+
+       /**
+        * Returns the wizard container for this wizard page. null, if wizard page
+        * is yet to be adedd to a wizard, or the wizard is yet to be added to a
+        * container.
+        */
+       protected IWizardContainer getContainer() {
+               if (wizard == null)
+                       return null;
+
+               return wizard.getContainer();
+       }
+
+       /**
+        * Returns the dialog setting for this wizard page. null, if none exists.
+        * 
+        * @return IDialogSettings, if Wizard is not set null.
+        */
+
+       protected IDialogSettings getDialogSettings() {
+               if (wizard == null)
+                       return null;
+
+               return wizard.getDialogSettings();
+       }
+
+       /**
+        * Overloaded from DialogPage get the Image from the super class,
+        * DialogPage. if not defined, then the default page Image is returned.
+        * 
+        * @return Image.
+        */
+
+       @Override
+       public Image getImage() {
+               Image result = super.getImage();
+
+               if (result == null && wizard != null)
+                       return wizard.getDefaultPageImage();
+
+               return result;
+       }
+
+       /**
+        * @return String, page Name.
+        */
+       public String getName() {
+               return name;
+       }
+
+       /**
+        * gets the Nextpage to be displayed, if set.
+        * 
+        * @return IWizardPage.
+        */
+       public IWizardPage getNextPage() {
+               if (nextPage != null)
+                       return nextPage;
+               
+               if (wizard == null)
+                       return null;
+
+               return wizard.getNextPage(this);
+       }
+       
+       public void setNextPage(IWizardPage page) {
+               nextPage  = page;
+       }
+
+       /**
+        * returns the PreviousPage, if Previous page is not initialized. Wizard is
+        * checked for previous page. if wizard for this page is not set null is
+        * returned.
+        * 
+        * @return IWizardPage
+        */
+       public IWizardPage getPreviousPage() {
+               if (previousPage != null)
+                       return previousPage;
+
+               if (wizard == null)
+                       return null;
+
+               return wizard.getPreviousPage(this);
+
+       }
+
+       /**
+        * Overloaded from DialogPage
+        */
+       @Override
+       public Shell getShell() {
+               IWizardContainer container = getContainer();
+
+               if (container == null)
+                       return null;
+
+               return container.getShell();
+       }
+
+       /**
+        * returns the Wizard instance to which this page is added.
+        * 
+        * @return IWizard.
+        */
+       public IWizard getWizard() {
+               return wizard;
+       }
+
+       /**
+        * is this is the current page being displayed.
+        * 
+        * @return boolean, true if this is the current page. otherwise false.
+        */
+       protected boolean isCurrentPage() {
+               boolean retVal = false;
+               if ((getContainer() != null) && (this == getContainer().getCurrentPage()))
+                       retVal = true;
+
+               return retVal;
+       }
+
+       /**
+        * @return boolean, true if this page is complete, otherwise false.
+        */
+       public boolean isPageComplete() {
+               return isPageComplete;
+       }
+
+       /**
+        * Methods from IDialOogPage
+        */
+
+       public void setPageComplete(boolean complete) {
+               isPageComplete = complete;
+
+               if (isCurrentPage())
+                       getContainer().updateButtons();
+       }
+
+       /**
+        * Method from IWizardPage
+        * 
+        */
+       public void setPreviousPage(IWizardPage page) {
+               previousPage = page;
+       }
+
+       /**
+        * set the Wizard for this page, the wizard will contain this page. In the
+        * list of pages which will be displayed as part of this Wizard.
+        * 
+        */
+       public void setWizard(IWizard newWizard) {
+               wizard = newWizard;
+       }
+
+       /**
+        * @return String, Page name of this page.
+        */
+       @Override
+       public String toString() {
+               return name;
+       }
+
+       /**
+        * Creates the top level control for this dialog page under the given parent
+        * composite.
+        * 
+        * @param parent
+        *            the parent composite
+        */
+       public void createControl(Composite parent) {
+               initializeDialogUnits(parent);
+               uiComposite = new UIComposite(parent, uiElement, valueStore);
+               uiComposite.addPatternListener(this);
+               uiElement.createWidgets(uiComposite);
+               
+               // set the focus so that InfoPop is displayed when F1 is Pressed.
+               uiComposite.setFocus();
+               
+               setControl(uiComposite);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), pageId);
+               
+               setPageComplete(uiComposite.isValid());
+       }
+
+       /**
+        * This method is implemented to handle the PatternEvent's generated by SWT
+        * widgets contained in this page. When the user enters data violating the
+        * pattern of data expected by this SWT widgets, a PatternEvent is fired to
+        * the Container. Which has to reflect the same as an ErrorMeesage. Get the
+        * source of the PatternEvent, and the error String causing the
+        * PatternEvent. Store this pair in validInvalid HashMap.
+        * 
+        */
+       public void patternPerformed(PatternEvent patternEvent) {
+               if (!patternEvent.getValid()) {
+                       
+                       validInvalid.put(patternEvent.getSource(), patternEvent.toString());
+                       setErrorMessage(getErrorString());
+                       setPageComplete(validInvalid.isEmpty() && uiComposite.isValid());
+
+               } else {
+                       
+                       validInvalid.remove(patternEvent.getSource());
+                       setPageComplete(validInvalid.isEmpty() && uiComposite.isValid());
+                       if (validInvalid.isEmpty()) {
+                               setErrorMessage(null);
+                       } else {
+                               setErrorMessage(getErrorString());
+                       }
+               }
+
+               getContainer().updateMessage();
+       }
+
+       /**
+        * Iterate through the validInvalid HashMap, formulate the error string
+        * return the same. This will ensure that the proper error string is
+        * updated.
+        * 
+        * @return
+        */
+       private String getErrorString() {
+               Iterator<Object> iterator = validInvalid.keySet().iterator();
+               String message = ""; //$NON-NLS-1$
+               
+               // only display one error message at a time
+               if (iterator.hasNext()) {
+                       message = validInvalid.get(iterator.next());
+               }
+               return message;
+       }
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/pages/messages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/pages/messages.properties
new file mode 100644 (file)
index 0000000..d2d0434
--- /dev/null
@@ -0,0 +1,32 @@
+###############################################################################
+# Copyright (c) 2007 Symbian Software Limited and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Symbian - Initial API and implementation
+# IBM Corporation
+###############################################################################
+
+NewProjectCreationPage.0=\ is an invalid name on this platform.
+NewProjectCreationPage.1=\ is too long. Project names must be less than 32 chars.
+NewProjectCreationPage.3=Enter a name and location for the new CDT project.
+TemplateInputDialog.0=Name :
+TemplateInputDialog.1=Value :
+TemplateInputDialog.2=Add a shared default value
+TemplateInputDialog.3=Edit a shared default value
+TemplateInputDialog.4=Template data must not be empty
+TemplatePreferencePage.0=Default input values for all templates:
+TemplatePreferencePage.1=Message from Dialog Validator
+TemplatePreferencePage.2=Duplicate Entry\!
+TemplatePreferencePage.3=Are you sure want to delete ?
+TemplatePreferencePage.4=Delete a shared default value
+TemplatePreferencePage.5=Templates Global Values Table
+TemplatePreferencePage.6=Updates changed key-value pair
+TemplatePreferencePage.7=Deletes key-value pair
+TemplatePreferencePage.8=Edit...
+TemplatePreferencePage.9=Remove
+TemplatePreferencePage.10=ID
+TemplatePreferencePage.11=Value
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/processes/Messages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/processes/Messages.java
new file mode 100644 (file)
index 0000000..d6b6256
--- /dev/null
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Marc-Andre Laperle and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc-Andre Laperle - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.processes;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @since 5.2
+ */
+public class Messages {
+       private static final String BUNDLE_NAME = "org.eclipse.cdt.ui.templateengine.processes.messages"; //$NON-NLS-1$
+
+       private Messages() {
+       }
+       
+       public static String OpenFiles_CannotOpen_error;
+       public static String OpenFiles_FileNotExist_error;
+
+       static {
+               NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/processes/OpenFiles.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/processes/OpenFiles.java
new file mode 100644 (file)
index 0000000..4bd1379
--- /dev/null
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Marc-Andre Laperle and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc-Andre Laperle - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.processes;
+
+import org.eclipse.cdt.core.templateengine.TemplateCore;
+import org.eclipse.cdt.core.templateengine.process.ProcessArgument;
+import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
+import org.eclipse.cdt.core.templateengine.process.ProcessRunner;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+
+/**
+ * This process opens files in the editor
+ * 
+ * @since 5.2
+ */
+public class OpenFiles extends ProcessRunner {
+
+       /**
+        * This method opens a list of files in the editor
+        */
+       @Override
+       public void process(TemplateCore template, ProcessArgument[] args, String processId,
+                       IProgressMonitor monitor) throws ProcessFailureException {
+               ProcessArgument[][] files = args[1].getComplexArrayValue();
+               for (ProcessArgument[] file : files) {
+                       String fileTargetPath = file[0].getSimpleValue();
+                       String projectName = args[0].getSimpleValue();
+                       IProject projectHandle = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+                       IFile iFile = projectHandle.getFile(fileTargetPath);
+                       if (iFile.exists()) {
+                               try {
+                                       IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(),
+                                                       iFile);
+                               } catch (PartInitException e) {
+                                       throw new ProcessFailureException(Messages.OpenFiles_CannotOpen_error + fileTargetPath);
+                               }
+                       }
+                       else {
+                               throw new ProcessFailureException(Messages.OpenFiles_FileNotExist_error + fileTargetPath);
+                       }
+               }
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/processes/messages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/processes/messages.properties
new file mode 100644 (file)
index 0000000..2db85c8
--- /dev/null
@@ -0,0 +1,13 @@
+###############################################################################
+# Copyright (c) 2010 Marc-Andre Laperle and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#    Marc-Andre Laperle - Initial API and implementation
+###############################################################################
+
+OpenFiles_CannotOpen_error=Open file failure: Cannot open file: 
+OpenFiles_FileNotExist_error=Open file failure: No such file exists: 
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/GenericUIElementGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/GenericUIElementGroup.java
new file mode 100644 (file)
index 0000000..ec36c62
--- /dev/null
@@ -0,0 +1,180 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.uitree;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.ui.templateengine.uitree.uiwidgets.UIComposite;
+
+/**
+ * The GenericUIElementGroup extends UIElement, implements the default behavior
+ * expected from UIElementGroup. This gives behavior expected for PAGES-ONLY
+ * type. Any other type of UIElement groups can override the definitions given
+ * to methods in this class.
+ * 
+ * @since 4.0
+ */
+public class GenericUIElementGroup extends UIElement {
+       /**
+        * @deprecated use {@value UIGroupTypeEnum#PAGES_ONLY}
+        */
+       @Deprecated
+       public static String PAGES_ONLY = UIGroupTypeEnum.PAGES_ONLY.getId();
+       /**
+        * @deprecated use {@value UIGroupTypeEnum#PAGES_ONLY}
+        */
+       @Deprecated
+       public static String PAGES_TAB = UIGroupTypeEnum.PAGES_TAB.getId();
+       /**
+        * @deprecated
+        */
+       @Deprecated
+       public static String LOGTYPE = "UIElement"; //$NON-NLS-1$
+
+       UIGroupTypeEnum type = null;
+
+       /**
+        * child list for this UIElement
+        */
+       private List<UIElement> childList;
+
+       /**
+        * Call UIElement constructor by passing Attributes as parameter.
+        * 
+        * @param attributes
+        */
+       public GenericUIElementGroup(UIGroupTypeEnum type, UIAttributes attributes) {
+               super(attributes);
+               this.type = type;
+               this.childList = new ArrayList<UIElement>();
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.templateengine.uitree.UIElement#setValues(java.util.Map)
+        */
+       @Override
+       public void setValues(Map<String,String> valueMap) {
+               int childCount = getChildCount();
+
+               for (int i = 0; i < childCount; i++) {
+                       getChild(i).setValues(valueMap);
+               }
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.templateengine.uitree.UIElement#getValues()
+        */
+       @Override
+       public Map<String, String> getValues() {
+               HashMap<String, String> valueMap = new HashMap<String, String>();
+               int childCount = getChildCount();
+
+               for (int i = 0; i < childCount; i++) {
+                       valueMap.putAll(getChild(i).getValues());
+               }
+
+               return valueMap;
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.templateengine.uitree.UIElement#createWidgets(org.eclipse.cdt.ui.templateengine.uitree.uiwidgets.UIComposite)
+        */
+       @Override
+       public void createWidgets(UIComposite uiComposite) {
+               int childCount = getChildCount();
+
+               // call createWidgets on all the contained
+               // UI widgets.
+               if (uiComposite != null) {
+                       for (int i = 0; i < childCount; i++) {
+                               getChild(i).createWidgets(uiComposite);
+                       }
+                       uiComposite.setData(".uid", getAttributes().get(UIElement.ID)); //$NON-NLS-1$
+               }
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.templateengine.uitree.UIElement#disposeWidget()
+        */
+       @Override
+       public void disposeWidget() {
+               int childCount = getChildCount();
+
+               for (int i = 0; i < childCount; i++)
+                       getChild(i).disposeWidget();
+       }
+
+       /**
+        * getThe child UIElement at the given index. This method throws
+        * SimpleElementException, if invoked on a InputUIElement.
+        * 
+        * @see UIElement
+        * @param index
+        * @return child uiElement
+        */
+       @Override
+       public UIElement getChild(int index) {
+               return childList.get(index);
+       }
+
+       /**
+        * add the given UIElement to the childList. This method throws
+        * SimpleElementException, if invoked on a InputUIElement.
+        * 
+        * @see UIElement
+        * @param aUIElement
+        */
+       @Override
+       public void addToChildList(UIElement aUIElement) {
+               childList.add(aUIElement);
+       }
+
+       /**
+        * returns the child count of UIElement. This method throws
+        * SimpleElementException, if invoked on a InputUIElement.
+        * 
+        * @see UIElement
+        * @return the child count of UIElement
+        */
+       @Override
+       public int getChildCount() {
+               return childList.size();
+       }
+
+       /**
+        * gets the type of this group. This is not used as of now. but can be used
+        * during UIPage construction.
+        */
+       public UIGroupTypeEnum getType() {
+               return type;
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.templateengine.uitree.UIElement#isValid()
+        */
+       @Override
+       public boolean isValid() {
+               boolean retVal = true;
+
+               int childCount = getChildCount();
+               for (int i = 0; i < childCount; i++) {
+                       if (!getChild(i).isValid()) {
+                               retVal = false;
+                               break;
+                       }
+               }
+
+               return retVal;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/IPageTypeConstants.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/IPageTypeConstants.java
new file mode 100644 (file)
index 0000000..5cea830
--- /dev/null
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Symbian Ltd. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Symbian Ltd. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.uitree;
+
+public interface IPageTypeConstants {
+       /**
+        * Type of UIElement group. The possible values are PAGES_ONLY, PAGES_TAB,
+        * PAGES_TREE, PAGES_TREE_TREE, PAGES_TAB_TREE.
+        */
+
+       public static String LOGTYPE = "UIElement"; //$NON-NLS-1$
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/IPatternMatchingTable.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/IPatternMatchingTable.java
new file mode 100644 (file)
index 0000000..479d701
--- /dev/null
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.uitree;
+
+/**
+ * This class contains the patter strings for a text widget 
+ * 
+ * @since 4.0
+ */
+public class IPatternMatchingTable {
+
+       public static final String TEXT = new String("Text"); //$NON-NLS-1$
+       public static final String FREETEXT = new String("FreeText"); //$NON-NLS-1$
+       public static final String FILENAME = new String("FileName"); //$NON-NLS-1$
+       public static final String TEXTPATTERNVALUE = "[A-Za-z0-9\\!\\?\\.: ]*"; //$NON-NLS-1$
+       public static final String FREETEXTPATTERNVALUE = "[A-Za-z0-9() \\.\\s]*"; //$NON-NLS-1$
+       public static final String FILEPATTERNVALUE = "([A-Za-z][:])?[[\\|\\\\|/]?[_!@#\\$%\\^()\\-+{}\\[\\]=;',A-Za-z0-9\\. ]*]*"; //$NON-NLS-1$
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/IUIElementTreeBuilderHelper.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/IUIElementTreeBuilderHelper.java
new file mode 100644 (file)
index 0000000..cac37ec
--- /dev/null
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.uitree;
+
+import org.w3c.dom.Element;
+
+/**
+ * This interface has methods which returns a UIElement, given an Element.
+ * Method to return a List of Elements, given an Element.
+ * 
+ * @since 4.0
+ */
+
+public interface IUIElementTreeBuilderHelper {
+       /**
+        * Returns the UIElement.
+        * @param element
+        * @return UIElement
+     * 
+     * @since 4.0
+        */
+       public UIElement getUIElement(Element element);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/IUIElementTreeBuilderManager.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/IUIElementTreeBuilderManager.java
new file mode 100644 (file)
index 0000000..80917cd
--- /dev/null
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.uitree;
+
+import org.w3c.dom.Element;
+
+/**
+ * This interface provides methods, which will be implemented by Tree builder
+ * class.
+ * 
+ * @since 4.0
+ */
+
+public interface IUIElementTreeBuilderManager {
+       /**
+        * Creates the UIElement Tree
+        * @param ui
+        * @param parent
+     * 
+     * @since 4.0
+        */
+       public void createUIElementTree(UIElement ui, Element parent);
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/InputUIElement.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/InputUIElement.java
new file mode 100644 (file)
index 0000000..31c0735
--- /dev/null
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.uitree;
+
+import org.eclipse.cdt.ui.templateengine.SimpleElementException;
+
+/**
+ * InputUIElement, an abstract class extends UIElement. Provides implementation
+ * to some of the methods. It provides definitions to those methods which
+ * doesn't apply to InuputUIElement's. SimpleElementException is thrown from
+ * these methods.
+ * 
+ */
+public abstract class InputUIElement extends UIElement {
+       public static final String INPUTTYPE= "input"; //$NON-NLS-1$
+       public static final String MULTILINETYPE= "multiline"; //$NON-NLS-1$
+       public static final String SELECTTYPE= "select"; //$NON-NLS-1$
+       public static final String BOOLEANTYPE= "boolean"; //$NON-NLS-1$
+       public static final String BROWSETYPE= "browse"; //$NON-NLS-1$
+       public static final String BROWSEDIRTYPE= "browsedir"; //$NON-NLS-1$
+       public static final String STRINGLISTTYPE= "stringlist"; //$NON-NLS-1$
+       public static final String SPECIALLISTTYPE= "speciallist"; //$NON-NLS-1$
+       public static final String MANDATORY= "mandatory"; //$NON-NLS-1$
+       public static final String INPUTPATTERN="pattern"; //$NON-NLS-1$
+       public static final String DEFAULT= "default"; //$NON-NLS-1$
+       public static final String WIDGETLABEL= "label"; //$NON-NLS-1$
+       public static final String BROWSELABEL= "    Browse..   "; //$NON-NLS-1$
+       public static final String CONTENTS= " contents"; //$NON-NLS-1$
+       public static final String ISINVALID= " is Invalid. "; //$NON-NLS-1$
+       public static final String CHECKPROJECT= "checkproject"; //$NON-NLS-1$
+       public static final String NULL= "null"; //$NON-NLS-1$
+       public static final String SIZE= "size"; //$NON-NLS-1$
+       public static final String HIDDEN= "hidden"; //$NON-NLS-1$
+       
+       /**
+        * The string appearing in the Combo box
+        */
+       public static final String COMBOITEM_LABEL= "label"; //$NON-NLS-1$
+       
+       /**
+        * Alternative attribute name for the value stored when the corresponding Combo item is selected.
+        * See <a href="https://bugs.eclipse.org/222954">Bugzilla 222954</a>.
+        */
+       public static final String COMBOITEM_NAME= "name"; //$NON-NLS-1$
+       
+       /**
+        * Preferred attribute name for the value stored when the corresponding Combo item is selected.
+        */
+       public static final String COMBOITEM_VALUE= "value"; //$NON-NLS-1$
+
+       protected InputUIElement(UIAttributes uiAttribute) {
+               super(uiAttribute);
+       }
+
+       /**
+        * Overloaded from UIElement, It does not apply to InputUIElement
+        * 
+        * @see UIElement
+        * @param uiElement
+        * @throws SimpleElementException
+        */
+       @Override
+       public void addToChildList(UIElement uiElement) throws SimpleElementException {
+               throw new SimpleElementException();
+       }
+
+       /**
+        * Overloaded from UIElement, It does not apply to InputUIElement
+        * 
+        * @see UIElement
+        */
+       @Override
+       public int getChildCount() throws SimpleElementException {
+               throw new SimpleElementException();
+       }
+
+       /**
+        * Overloaded from UIElement, It does not apply to InputUIElement
+        * 
+        * @see UIElement
+        */
+       @Override
+       public UIElement getChild(int index) throws SimpleElementException {
+               throw new SimpleElementException();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/SimpleUIElementGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/SimpleUIElementGroup.java
new file mode 100644 (file)
index 0000000..829b4e0
--- /dev/null
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.uitree;
+
+import java.util.Map;
+
+import org.eclipse.cdt.ui.templateengine.uitree.uiwidgets.UIComposite;
+
+
+/**
+ * This is a PAGES_ONLY implementation for UIElement group. It uses the method
+ * implementation for UIElement provided by GenericUIElementGroup.
+ */
+
+public class SimpleUIElementGroup extends GenericUIElementGroup {
+
+       public SimpleUIElementGroup(UIAttributes attribute) {
+               super(UIGroupTypeEnum.PAGES_ONLY, attribute);
+       }
+
+       /**
+        * @see UIElement
+        */
+       @Override
+       public void setValues(Map<String, String> valueMap) {
+               super.setValues(valueMap);
+       }
+
+       /**
+        * @see UIElement
+        */
+       @Override
+       public Map<String, String> getValues() {
+               return super.getValues();
+       }
+
+       /**
+        * @see UIElement
+        */
+       @Override
+       public void createWidgets(UIComposite uiComposite) {
+               super.createWidgets(uiComposite);
+       }
+
+       /**
+        * dispose the Widget, releasing any resources occupied by this widget. The
+        * same is called on the child list.
+        * 
+        * @see UIElement
+        */
+       @Override
+       public void disposeWidget() {
+               super.disposeWidget();
+       }
+
+       // @see UIElement
+       @Override
+       public boolean isValid() {
+               return super.isValid();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/UIAttributes.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/UIAttributes.java
new file mode 100644 (file)
index 0000000..d2a805e
--- /dev/null
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.uitree;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.cdt.core.templateengine.TemplateEngineHelper;
+import org.eclipse.cdt.core.templateengine.TemplateInfo;
+
+/**
+ * Every UIElement will be associated with attributes. This class extends
+ * HashMap. It just provides a convenient way to store Key , value pairs. This
+ * class is for clarity in usage. We need not use HashMap for attributes,
+ * instead we can use UIAttributes for attributes.
+ */
+public class UIAttributes extends HashMap<String, String> {
+       private static final long serialVersionUID = 0000000000L;
+       private TemplateInfo templateInfo;
+       
+       UIAttributes(TemplateInfo templateInfo) {
+               this.templateInfo = templateInfo;
+       }
+       
+       @Override
+       public String put(String key, String value) {
+               value = TemplateEngineHelper.externalizeTemplateString(templateInfo, value);
+               return super.put(key, value);
+       }
+
+       @Override
+       public void putAll(Map<? extends String, ? extends String> map) {
+               for(String key : map.keySet()) {
+                       String value = map.get(key);
+                       value = TemplateEngineHelper.externalizeTemplateString(templateInfo, value);
+                       super.put(key, value);
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/UIElement.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/UIElement.java
new file mode 100644 (file)
index 0000000..e109e7b
--- /dev/null
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.uitree;
+
+import java.util.Map;
+
+import org.eclipse.cdt.ui.templateengine.SimpleElementException;
+import org.eclipse.cdt.ui.templateengine.uitree.uiwidgets.UIComposite;
+
+
+/**
+ * UIElement describes the abstract behavior expected from GenericUIElementGroup and 
+ * InputUIElement. Some of the methods are meaningful to group Element. They will throw
+ * SimpleElementException when invoked on InputUIElement.
+ */
+public abstract class UIElement {
+       public static final String ID = "id"; //$NON-NLS-1$
+       public static final String TYPE = "type"; //$NON-NLS-1$
+       public static final String DESCRIPTION = "description"; //$NON-NLS-1$
+       public static final String TITLE = "label"; //$NON-NLS-1$
+       public static final String IMAGELOCATION = "image"; //$NON-NLS-1$
+
+       /**
+        * Parent of this UIElement
+        */
+       private UIElement parent;
+
+       /**
+        * Attributes of this UIElement
+        */
+       protected UIAttributes uiAttributes;
+       
+       public UIElement(UIAttributes uiAttributes) {
+               this.uiAttributes = uiAttributes;
+       }
+
+       /**
+        * set the Parent of this UIElement
+        */
+       public void setParent(UIElement parent) {
+               this.parent = parent;
+       }
+
+       /**
+        * get the Parent of this UIElement
+        */
+       public UIElement getParent() {
+               return parent;
+       }
+
+       /**
+        * get the attributes of this UIElement
+        */
+       public UIAttributes getAttributes() {
+               return uiAttributes;
+       }
+
+       /**
+        * set the Values of UIElements from the given HashMap. This method is called recursively on all the children, if the UIElement instance on which this mehtod called is a GenericUIElementGroup. return void.
+        */
+       public abstract void setValues(Map<String, String> valueMap);
+
+       /**
+        * get The values as a HashMap. This method is called recursively on all the children, if the UIElement instance on which this mehtod called is a GenericUIElementGroup.
+        * @return  HashMap.
+        */
+       public abstract Map<String, String> getValues();
+
+       /**
+        * This method adds UIWidets to UIComposite. This method is called
+        * recursively on all the children, if the UIElement instance on which this
+        * method called is a GenericUIElementGroup.
+        * 
+        * @param uiComposite
+        */
+       public abstract void createWidgets(UIComposite uiComposite);
+
+       /**
+        * disposes the widget. This method is called recursively on all the
+        * children, if the UIElement instance on which this method is called, is a
+        * GenericUIElementGroup.
+        * 
+        */
+       public abstract void disposeWidget();
+
+       /**
+        * getThe child UIElement at the given index. This method throws
+        * SimpleElementException, if invoked on a InputUIElement.
+        * 
+        * @param index
+        * @return The child UIElement
+        * @throws SimpleElementException
+        */
+       public abstract UIElement getChild(int index) throws SimpleElementException;
+
+       /**
+        * add the given UIElement to the childList. This method throws
+        * SimpleElementException, if invoked on a InputUIElement.
+        * 
+        * @param uiElement
+        * @throws SimpleElementException
+        */
+       public abstract void addToChildList(UIElement uiElement) throws SimpleElementException;
+
+       /**
+        * returns the child count of UIElement. This method throws
+        * SimpleElementException, if invoked on a InputUIElement.
+        * 
+        * @return the child count of UIElement
+        * @throws SimpleElementException
+        */
+       public abstract int getChildCount() throws SimpleElementException;
+
+       /**
+        * The return value depends on the state of the UIElement. This information
+        * is used by UIPage to enable or disable the UIPage.
+        * 
+        * @return boolean.
+        */
+       public abstract boolean isValid();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/UIElementTreeBuilderHelper.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/UIElementTreeBuilderHelper.java
new file mode 100644 (file)
index 0000000..b36915b
--- /dev/null
@@ -0,0 +1,163 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ * IBM Corporation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.uitree;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+import com.ibm.icu.text.MessageFormat;
+
+import org.eclipse.cdt.core.templateengine.TemplateDescriptor;
+import org.eclipse.cdt.core.templateengine.TemplateEngine;
+import org.eclipse.cdt.core.templateengine.TemplateInfo;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.templateengine.Messages;
+import org.eclipse.cdt.ui.templateengine.uitree.uiwidgets.UIBooleanWidget;
+import org.eclipse.cdt.ui.templateengine.uitree.uiwidgets.UIBrowseWidget;
+import org.eclipse.cdt.ui.templateengine.uitree.uiwidgets.UISelectWidget;
+import org.eclipse.cdt.ui.templateengine.uitree.uiwidgets.UISpecialListWidget;
+import org.eclipse.cdt.ui.templateengine.uitree.uiwidgets.UIStringListWidget;
+import org.eclipse.cdt.ui.templateengine.uitree.uiwidgets.UITextWidget;
+
+/**
+ * UIElementTreeBuilderHelper provides methods to convert an Element (XML) into
+ * UIElement. The UIElement can be a simple UI Widget or a group.
+ */
+public class UIElementTreeBuilderHelper implements IUIElementTreeBuilderHelper {
+       private static final String TEMPLATE_ENGINE_ERROR = Messages.getString("TemplateEngineMessage.Error"); //$NON-NLS-1$
+       /**
+        * TemplateDescriptor representing the TemplaeDescriptor XML.
+        */
+       private TemplateDescriptor templateDescriptor = null;
+       private TemplateInfo templateInfo;
+
+       /**
+        * Constructor, takes an TemplateDescriptor instance as parameter.
+        * 
+        * @param templateDescriptor
+        */
+       public UIElementTreeBuilderHelper(TemplateDescriptor templateDescriptor, TemplateInfo templateInfo) {
+               this.templateDescriptor = templateDescriptor;
+               this.templateInfo = templateInfo;
+       }
+
+       /**
+        * 
+        * @return List of child Elements for the given
+        */
+       public List<Element> getPropertyGroupList() {
+               return templateDescriptor.getPropertyGroupList();
+       }
+
+       /**
+        * Given an XML Element, representing a PropertyElement. A UIElement for the
+        * same is returned. The Type attribute is verified, based on Type
+        * appropriate UIWidget is instantiated. This class the getUIWidget private
+        * method.
+        * 
+        * @param element
+        * @return UIElement.
+        */
+       public UIElement getUIElement(Element element) {
+               UIAttributes uiAttributes = new UIAttributes(templateInfo);
+
+               NamedNodeMap list = element.getAttributes();
+               for (int i=0; i<list.getLength(); i++) {
+                       Node attribute = list.item(i);
+                       uiAttributes.put(attribute.getNodeName(), attribute.getNodeValue());
+               }
+               
+               return getUIWidget(element, uiAttributes);
+       }
+
+       /**
+        * Given an XML Element, representing a PropertyElement. A UIElement for the
+        * same is returned. The Type attribute is verified, based on Type
+        * appropriate UIWidget is instantiated.
+        * 
+        * @param uiAttributes
+        * @return UIElement.
+        */
+       private UIElement getUIWidget(Element element, UIAttributes uiAttributes) {
+               UIElement widgetElement= null;
+               String id= uiAttributes.get(UIElement.ID);
+               String type= uiAttributes.get(UIElement.TYPE);
+               
+               if (type == null || type.length()==0 ) {
+                       return null;
+               }
+               
+               if (new Boolean(uiAttributes.get(InputUIElement.HIDDEN)).booleanValue()) {
+                       return null;    
+               }
+               
+               if (type.equalsIgnoreCase(InputUIElement.INPUTTYPE)) {
+                       widgetElement = new UITextWidget(uiAttributes);
+               } else if (type.equalsIgnoreCase(InputUIElement.MULTILINETYPE)) {
+                       widgetElement = new UITextWidget(uiAttributes);
+               } else if (type.equalsIgnoreCase(InputUIElement.SELECTTYPE)) {
+                       String defaultValue= element.getAttribute(InputUIElement.DEFAULT);
+                       
+                       Map<String,String> value2name= new LinkedHashMap<String,String>();
+                       for(Element item : TemplateEngine.getChildrenOfElement(element)) {
+                               String label= item.getAttribute(InputUIElement.COMBOITEM_LABEL); // item displayed in Combo
+                               String value= item.getAttribute(InputUIElement.COMBOITEM_NAME); // value stored when its selected
+                               if(value.length() == 0) {
+                                       value= item.getAttribute(InputUIElement.COMBOITEM_VALUE);
+                               }
+                               if(label==null || value==null) {
+                                       String msg = MessageFormat.format(Messages.getString("UIElementTreeBuilderHelper.InvalidEmptyLabel"), //$NON-NLS-1$
+                                                       new Object[] {id});
+                                       CUIPlugin.log(TEMPLATE_ENGINE_ERROR, new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, msg)));
+                               } else {
+                                       if(value2name.put(value, label)!=null) {
+                                               String msg = MessageFormat.format(Messages.getString("UIElementTreeBuilderHelper.InvalidNonUniqueValue"), //$NON-NLS-1$
+                                                               new Object[] {value, id});
+                                               CUIPlugin.log(TEMPLATE_ENGINE_ERROR, new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, msg)));
+                                       }
+                               }
+                       }
+                       
+                       widgetElement = new UISelectWidget(uiAttributes, value2name, defaultValue);
+               } else if (type.equalsIgnoreCase(InputUIElement.BOOLEANTYPE)) {
+                       String defaultValue= element.getAttribute(InputUIElement.DEFAULT);
+                       boolean b= Boolean.parseBoolean(defaultValue);
+                       widgetElement = new UIBooleanWidget(uiAttributes, b);
+               } else if (type.equalsIgnoreCase(InputUIElement.BROWSETYPE)) {
+                       widgetElement = new UIBrowseWidget(uiAttributes, false);
+               } else if (type.equalsIgnoreCase(InputUIElement.BROWSEDIRTYPE)) {
+                       widgetElement = new UIBrowseWidget(uiAttributes, true);
+               } else if (type.equalsIgnoreCase(InputUIElement.STRINGLISTTYPE)) {
+                       widgetElement = new UIStringListWidget(uiAttributes);
+               } else if (type.equalsIgnoreCase(InputUIElement.SPECIALLISTTYPE)) {
+                       widgetElement = new UISpecialListWidget(uiAttributes);
+               } else if (type.equalsIgnoreCase(UIGroupTypeEnum.PAGES_ONLY.getId())) {
+                       widgetElement = new SimpleUIElementGroup(uiAttributes);
+               } else if (type.equalsIgnoreCase(UIGroupTypeEnum.PAGES_TAB.getId())) {
+                       // Note: This is not implemented now as we haven't found a use case
+                       // for generating UI pages as TABS in a single page. 
+               } else {
+                       String msg= MessageFormat.format(Messages.getString("UIElementTreeBuilderHelper.UnknownWidgetType0"), new Object[] {type}); //$NON-NLS-1$
+                       CUIPlugin.log(TEMPLATE_ENGINE_ERROR, new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, msg)));
+               }
+
+               return widgetElement;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/UIElementTreeBuilderManager.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/UIElementTreeBuilderManager.java
new file mode 100644 (file)
index 0000000..37796d4
--- /dev/null
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.uitree;
+
+import java.util.List;
+
+import org.w3c.dom.Element;
+
+import org.eclipse.cdt.core.templateengine.TemplateEngine;
+import org.eclipse.cdt.core.templateengine.TemplateEngineUtil;
+import org.eclipse.cdt.ui.templateengine.SimpleElementException;
+
+
+/**
+ * 
+ * call setgetUIElementTreeRootNull(), before createUIElementTree(...).
+ * UIElementTreeBuilderManager builds a UIElementTree.
+ * 
+ * --------------UITree creation algorithm----------------------------
+ * createUIElementTree(UITreeRoot, RootPropertyGroupElement) UITreeRoot is
+ * initially null. createUIElementTree(UIElement parent, XML_Element element)
+ * Step 1. if( parent == null ) parent =
+ * UIElementTreeBuilderHelper.getUIElement(element).
+ * Step 2. else { 
+ *             Step 3. List
+ *             childList = getChildList(element); 
+ *             Step 4. Iterator I =
+ *             getIterator(childList); 
+ *             Step 5. for every element belonging to childList
+ *             { 
+ *                     Step 6. uiElement = getUIElement (element from childList); advance I to next
+ *                     Element. uiElement .setParent(parent); parent.put(uiElement );
+ *             createUIElementTree(uiElement, element from childList); 
+ *     }
+ * }
+ * ---------------------------------------------------------------------
+ * 
+ */
+
+public class UIElementTreeBuilderManager implements IUIElementTreeBuilderManager {
+       /**
+        * reference to iUIElementTreeBuilderHelper, which returns UIElement for Element.
+        */
+       private UIElementTreeBuilderHelper uiElementTreeBuilderHelper;
+
+       /**
+        * The root of the UIElementTree.
+        */
+       private UIElement uiTreeRoot = null;
+
+       /**
+        * 
+        * @param uiElementTreeBuilderHelper
+        */
+       public UIElementTreeBuilderManager(UIElementTreeBuilderHelper uiElementTreeBuilderHelper) {
+               this.uiElementTreeBuilderHelper = uiElementTreeBuilderHelper;
+       }
+
+       /**
+        * This method create the UIElementTree, by following the algorithm given
+        * above.
+        */
+       public void createUIElementTree(UIElement uiParent, Element element) {
+               if (uiParent == null) {
+                       uiTreeRoot = uiElementTreeBuilderHelper.getUIElement(element);
+                       uiParent = uiTreeRoot;
+               }
+
+               if ((uiParent != null) && (uiParent instanceof GenericUIElementGroup)) {
+                       List<Element> childList = TemplateEngine.getChildrenOfElement(element);
+                       for (int listIndex = 0, l = childList.size(); listIndex < l; listIndex++) {
+                               UIElement uiElement = uiElementTreeBuilderHelper.getUIElement(childList.get(listIndex));
+                               if (uiElement != null) {
+                                       uiElement.setParent(uiParent);
+                               } else {
+                                       continue;
+                               }
+                               try {
+                                       uiParent.addToChildList(uiElement);
+                               } catch (SimpleElementException exp) {
+                                       TemplateEngineUtil.log(exp);
+                               }
+                               createUIElementTree(uiElement, childList.get(listIndex));
+                       }
+               }
+       }
+
+       /**
+        * 
+        * @return UIElement, root UIElement.
+        */
+       public UIElement getUIElementTreeRoot() {
+               return uiTreeRoot;
+       }
+
+       /**
+        * sets the UIElementTree root element to null. This method is invoked
+        * before creating UIElementTree.
+        */
+       public void setUIElementTreeRootNull() {
+               uiTreeRoot = null;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/UIGroupTypeEnum.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/UIGroupTypeEnum.java
new file mode 100644 (file)
index 0000000..589f83b
--- /dev/null
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.uitree;
+
+/**
+ * This class defines various types of UIElement groups.
+ */
+public class UIGroupTypeEnum {
+       public static final UIGroupTypeEnum PAGES_ONLY = new UIGroupTypeEnum("PAGES-ONLY"); //$NON-NLS-1$
+       public static final UIGroupTypeEnum PAGES_TAB = new UIGroupTypeEnum("PAGES-TAB"); //$NON-NLS-1$
+       
+       private String id;
+       
+       private UIGroupTypeEnum(String id) {
+               this.id = id;
+       }
+       
+       @Override
+       public boolean equals(Object other) {
+               if(other instanceof UIGroupTypeEnum) {
+                       return id.equals(((UIGroupTypeEnum)other).id);
+               }
+               return false;
+       }
+       
+       @Override
+       public int hashCode() {
+               return id.hashCode();
+       }
+       
+       public String getId() {
+               return id;
+       }
+       
+       @Override
+       public String toString() {
+               return id;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UIBooleanWidget.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UIBooleanWidget.java
new file mode 100644 (file)
index 0000000..c3a019a
--- /dev/null
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.uitree.uiwidgets;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+import org.eclipse.cdt.ui.templateengine.uitree.InputUIElement;
+import org.eclipse.cdt.ui.templateengine.uitree.UIAttributes;
+import org.eclipse.cdt.ui.templateengine.uitree.UIElement;
+
+
+/**
+ * This gives a Label and Boolean widget.
+ */
+public class UIBooleanWidget extends InputUIElement {
+       /**
+        * Boolean widget.
+        */
+       protected Button button;
+
+       /**
+        * Label of this widget.
+        */
+       protected Label label;
+
+       /**
+        * Composite to which this widget control is added.
+        */
+       protected UIComposite uiComposite;
+       
+       private boolean booleanValue;
+
+       /**
+        * Constructor.
+        * 
+        * @param uiAttributes
+        *            attribute associated with this widget.
+        */
+       public UIBooleanWidget(UIAttributes uiAttributes, boolean defaultValue) {
+               super(uiAttributes);
+               this.booleanValue= defaultValue;
+       }
+
+       /**
+        * @return HashMap which contains the values in the Boolean Widget.
+        */
+       @Override
+       public Map<String, String> getValues() {
+               Map<String, String> values = new HashMap<String, String>();
+               values.put(uiAttributes.get(InputUIElement.ID), Boolean.toString(booleanValue));
+               return values;
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.templateengine.uitree.UIElement#setValues(java.util.Map)
+        */
+       @Override
+       public void setValues(Map<String, String> valueMap) {
+               booleanValue = new Boolean(valueMap.get(uiAttributes.get(InputUIElement.ID))).booleanValue();
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.templateengine.uitree.UIElement#createWidgets(org.eclipse.cdt.ui.templateengine.uitree.uiwidgets.UIComposite)
+        */
+       @Override
+       public void createWidgets(UIComposite uiComposite) {
+               GridData gridData = null;
+               this.uiComposite = uiComposite;
+
+               label = new Label(uiComposite, SWT.LEFT);
+               label.setText(uiAttributes.get(InputUIElement.WIDGETLABEL));
+
+               if (uiAttributes.get(InputUIElement.DESCRIPTION) != null){
+                       String tipText = uiAttributes.get(UIElement.DESCRIPTION);
+                       tipText = tipText.replaceAll("\\\\r\\\\n", "\r\n"); //$NON-NLS-1$ //$NON-NLS-2$
+                       label.setToolTipText(tipText);
+               }
+               gridData = new GridData();
+               gridData.horizontalAlignment = GridData.FILL;
+               gridData.grabExcessHorizontalSpace = true;
+               Composite booleanContainer = new Composite(uiComposite, SWT.NONE);
+               GridData gridcData = new GridData(GridData.FILL_HORIZONTAL);
+               booleanContainer.setLayout(new GridLayout());
+               booleanContainer.setLayoutData(gridcData);
+               button = new Button(booleanContainer, SWT.CHECK);
+               button.setData(".uid", uiAttributes.get(UIElement.ID)); //$NON-NLS-1$
+               button.setSelection(new Boolean(booleanValue).booleanValue());
+               button.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               booleanValue = button.getSelection();
+                       }
+               });
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.templateengine.uitree.UIElement#isValid()
+        */
+       @Override
+       public boolean isValid() {
+               boolean retVal= true;
+               String mandatory= uiAttributes.get(InputUIElement.MANDATORY);
+               if (!booleanValue && Boolean.parseBoolean(mandatory)) {
+                       retVal= false;
+               }
+               return retVal;
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.templateengine.uitree.UIElement#disposeWidget()
+        */
+       @Override
+       public void disposeWidget() {
+               label.dispose();
+               button.dispose();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UIBrowseWidget.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UIBrowseWidget.java
new file mode 100644 (file)
index 0000000..07ce7cf
--- /dev/null
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.uitree.uiwidgets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.ui.templateengine.uitree.InputUIElement;
+import org.eclipse.cdt.ui.templateengine.uitree.UIAttributes;
+import org.eclipse.cdt.ui.templateengine.uitree.UIElement;
+
+
+/**
+ * This gives a Label and Browse widget.
+ */
+
+public class UIBrowseWidget extends UITextWidget {
+
+       /**
+        * Browse Button of this widget.
+        */
+       protected  Button button;
+
+       /**
+        * If set to true, open a DirectoryDialog otherwise FileDialog
+        */
+       protected boolean isDirectoryBrowser;
+       
+       /**
+        * Constructor.
+        * 
+        * @param uiAttribute
+        *            attribute associated with this widget.
+        */
+       public UIBrowseWidget(UIAttributes uiAttribute, boolean isDirectoryBrowser) {
+               super(uiAttribute);
+               this.textValue = uiAttribute.get(InputUIElement.DEFAULT);
+               this.isDirectoryBrowser= isDirectoryBrowser;
+       }
+
+       /**
+        * create a Label and Browse widget, add it to UIComposite. set Layout for
+        * the widgets to be added to UIComposite. set required parameters to the
+        * Widgets.
+        * 
+        * @param composite
+        */
+       @Override
+       public void createWidgets(UIComposite composite) {
+               uiComposite = composite;
+
+               label = new Label(uiComposite, SWT.NONE | SWT.LEFT);
+               label.setText(uiAttributes.get(InputUIElement.WIDGETLABEL));
+
+               // set the tool tip text
+               if (uiAttributes.get(UIElement.DESCRIPTION) != null){
+                       String tipText = uiAttributes.get(UIElement.DESCRIPTION);
+                       tipText = tipText.replaceAll("\\\\r\\\\n", "\r\n"); //$NON-NLS-1$, //$NON-NLS-2$
+                       label.setToolTipText(tipText);
+               }
+               GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+               gridData.widthHint = 70;
+
+               Composite textConatiner = new Composite(uiComposite, SWT.NONE);
+               textConatiner.setLayout(new GridLayout(2, false));
+
+               textConatiner.setLayoutData(gridData);
+
+               text = new Text(textConatiner, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
+               text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               text.addModifyListener(this);
+               text.setText(textValue);
+
+               button = new Button(textConatiner, SWT.PUSH | SWT.LEFT);
+               button.setText(InputUIElement.BROWSELABEL);
+
+               button.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent event) {
+                               onBrowsePushed();
+                       }
+               });
+       }
+
+       protected void onBrowsePushed() {
+               String fileName;
+               if(isDirectoryBrowser) {
+                       fileName= new DirectoryDialog(uiComposite.getShell()).open();
+               } else {
+                       fileName= new FileDialog(uiComposite.getShell()).open();
+               }
+               if (fileName != null) {
+                       textValue = fileName.toString();
+                       text.setText(textValue);
+               }
+       }
+       
+       /**
+        * call the dispose method on the widgets. This is to ensure that the
+        * widgets are properly disposed.
+        */
+       @Override
+       public void disposeWidget() {
+               label.dispose();
+               text.dispose();
+               button.dispose();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UIComposite.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UIComposite.java
new file mode 100644 (file)
index 0000000..2f9a5fa
--- /dev/null
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.uitree.uiwidgets;
+
+import java.util.Map;
+import java.util.Vector;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+
+import org.eclipse.cdt.ui.templateengine.event.PatternEvent;
+import org.eclipse.cdt.ui.templateengine.event.PatternEventListener;
+import org.eclipse.cdt.ui.templateengine.uitree.UIElement;
+
+
+/**
+ * By extending Composite we can create our own Container. UIComposite can act
+ * as the bridge between the UIPage and the UIWidgets contained in that page.
+ * The PatternEvents generated by the UIWidgets will be fired to the UIPage
+ * which is a PatternEventListener.
+ */
+
+public class UIComposite extends Composite {
+
+       /**
+        * The group UIElement corresponding to this UIPage.
+        */
+       private UIElement uiElement;
+
+       /**
+        * The list of PatternEventListeners.
+        */
+       private Vector<PatternEventListener> vector;
+
+       /**
+        * parent Composite, and The UIElement corresponding to this page.
+        * 
+        * @param parent
+        * @param uiElement
+        */
+       public UIComposite(Composite parent, UIElement uiElement, Map<String, String> valueStore) {
+               super(parent, SWT.NONE);
+
+               vector = new Vector<PatternEventListener>();
+               GridLayout layout = new GridLayout(2, false);
+               layout.marginWidth = 10;
+               layout.marginHeight = 5;
+               this.setLayout(layout);
+               this.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+               this.uiElement = uiElement;
+       }
+
+       /**
+        * add a PatternListener to the list.
+        * 
+        * @param patternListener
+        */
+       public void addPatternListener(PatternEventListener patternListener) {
+               vector.add(patternListener);
+       }
+
+       /**
+        * remove the PatternListener from the list.
+        * 
+        * @param patternListener
+        */
+       public void removePatternListener(PatternEventListener patternListener) {
+               vector.remove(patternListener);
+       }
+
+       /**
+        * On occurrence of PatternEvent this method is called to invoke
+        * patternPerformed on all the registered listeners. In our application, we
+        * will have just one registered listener.
+        */
+
+       public void firePatternEvent(PatternEvent patternEvent) {
+               for (int i = 0; i < vector.size(); i++) {
+                       vector.get(i).patternPerformed(patternEvent);
+               }
+       }
+
+       /**
+        * This method will invoke the getValues on UIElement (group Element), which
+        * in turn will invoke the getValues on the UIElement (widgets). This
+        * returns an HashMap of Values.
+        */
+       public Map<String, String> getPageData() {
+               return uiElement.getValues();
+       }
+
+       /**
+        * return the UIElement(group UI Element) represented by this UIComposite.
+        * 
+        * @return UIElement.
+        */
+       public UIElement getUIElement() {
+               return uiElement;
+       }
+
+       /**
+        * This information is used by UIPages to enable or disable the next button.
+        */
+       public boolean isValid() {
+               return uiElement.isValid();
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UISelectWidget.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UISelectWidget.java
new file mode 100644 (file)
index 0000000..5d28de9
--- /dev/null
@@ -0,0 +1,170 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.uitree.uiwidgets;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+import com.ibm.icu.text.MessageFormat;
+
+import org.eclipse.cdt.ui.templateengine.Messages;
+import org.eclipse.cdt.ui.templateengine.event.PatternEvent;
+import org.eclipse.cdt.ui.templateengine.uitree.InputUIElement;
+import org.eclipse.cdt.ui.templateengine.uitree.UIAttributes;
+import org.eclipse.cdt.ui.templateengine.uitree.UIElement;
+
+/**
+ * This gives a Label and Combo widget.
+ */
+public class UISelectWidget extends InputUIElement {
+       protected Label label;
+       protected Combo combo;
+
+       /**
+        * Mapping from values stored by this combo, to their associated names in UI
+        */
+       protected Map<String, String> value2name;
+
+       /**
+        * The default name to select
+        */
+       protected String defaultValue;
+
+       /**
+        * The currently selected name. May be null.
+        */
+       protected String currentValue;
+
+       /**
+        * Constructor for Select Widget.
+        * 
+        * @param attribute
+        *            attribute associated with this widget.
+        */
+       public UISelectWidget(UIAttributes attribute, Map<String, String> value2name, String defaultValue) {
+               super(attribute);
+               this.value2name= value2name;
+               this.defaultValue= defaultValue;
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.templateengine.uitree.UIElement#getValues()
+        */
+       @Override
+       public Map<String, String> getValues() {
+               Map<String, String> values = new HashMap<String, String>();
+               if(currentValue != null) {
+                       values.put(uiAttributes.get(InputUIElement.ID), currentValue);
+               }
+               return values;
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.templateengine.uitree.UIElement#setValues(java.util.Map)
+        */
+       @Override
+       public void setValues(Map<String, String> valueMap) {
+               defaultValue= valueMap.get(uiAttributes.get(InputUIElement.ID));
+               if (combo != null) {
+                       String[] items= combo.getItems();
+                       for (int i=0; i < items.length; i++) {
+                               if (items[i].equals(defaultValue)) {
+                                       combo.select(i);
+                                       break;
+                               }
+                       }
+               }
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.templateengine.uitree.UIElement#createWidgets(org.eclipse.cdt.ui.templateengine.uitree.uiwidgets.UIComposite)
+        */
+       @Override
+       public void createWidgets(final UIComposite uiComposite) {
+               label= new Label(uiComposite, SWT.LEFT);
+               label.setText(uiAttributes.get(InputUIElement.WIDGETLABEL));
+
+               Composite comboComposite = new Composite(uiComposite, SWT.NONE);
+               comboComposite.setLayout(GridLayoutFactory.swtDefaults().create());
+               comboComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
+
+               combo= new Combo(comboComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
+               combo.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());         
+               combo.setData(".uid", uiAttributes.get(UIElement.ID)); //$NON-NLS-1$
+
+               // populate combo
+               int index= 0, defaultIndex= 0;
+               for(String value : value2name.keySet()) {                       
+                       combo.add(value2name.get(value));
+                       if(value.equals(defaultValue)) {
+                               defaultIndex= index;
+                       }
+                       index++;
+
+               }
+               combo.select(defaultIndex);
+               combo.addSelectionListener(new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent e) {
+                               currentValue= getValue(combo.getItem(combo.getSelectionIndex()));
+                               uiComposite.firePatternEvent(createPatternEvent());
+                       }
+               });
+               uiComposite.firePatternEvent(createPatternEvent());
+       }
+
+       private PatternEvent createPatternEvent() {
+               String msg= MessageFormat.format(Messages.getString("UISelectWidget_ErrorNoneSelected0"), new String[] {label.getText()}); //$NON-NLS-1$
+               return new PatternEvent(this, msg, isValid());
+       }
+
+       /**
+        * @return whether this widget has been set to a valid state. For this 
+        * widget type that means whether the user has selected a non-empty string name.
+        */
+       @Override
+       public boolean isValid() {
+               boolean retVal = true;
+               if(Boolean.parseBoolean(uiAttributes.get(InputUIElement.MANDATORY))
+                               && ! InputUIElement.SELECTTYPE.equals(uiAttributes.get(InputUIElement.TYPE)) ) {
+                       retVal= currentValue!= null && currentValue.trim().length()>0;
+               }
+               return retVal;
+       }
+
+       private String getValue(String name) {
+               for(String value : value2name.keySet()) {
+                       if(value2name.get(value).equals(name)) {
+                               return value;
+                       }
+               }
+               throw new IllegalStateException();
+       }
+       
+       
+       /*
+        * @see org.eclipse.cdt.ui.templateengine.uitree.UIElement#disposeWidget()
+        */
+       @Override
+       public void disposeWidget() {
+               label.dispose();
+               combo.dispose();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UISpecialListWidget.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UISpecialListWidget.java
new file mode 100644 (file)
index 0000000..a2b6ffd
--- /dev/null
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.uitree.uiwidgets;
+
+import java.util.Arrays;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+import org.eclipse.cdt.ui.templateengine.uitree.InputUIElement;
+import org.eclipse.cdt.ui.templateengine.uitree.UIAttributes;
+import org.eclipse.cdt.ui.templateengine.uitree.UIElement;
+import org.eclipse.cdt.utils.ui.controls.FileListControl;
+import org.eclipse.cdt.utils.ui.controls.IFileListChangeListener;
+
+
+/**
+ * This gives a Label and UISpecialList Widget.
+ * 
+ */
+public class UISpecialListWidget extends UIStringListWidget {
+       /**
+        * Constructor.
+        * 
+        * @param attribute
+        *            attribute associated with this widget.
+        */
+       public UISpecialListWidget(UIAttributes attribute) {
+               super(attribute);
+       }
+
+       /**
+        * create a Label and Text widget, add it to UIComposite. set Layout for the
+        * widgets to be added to UIComposite. set required parameters to the
+        * Widgets.
+        * 
+        * @param uiComposite
+        */
+       @Override
+       public void createWidgets(final UIComposite uiComposite) {
+               GridData gridData = null;
+
+               label = new Label(uiComposite, SWT.LEFT);
+               label.setText(uiAttributes.get(InputUIElement.WIDGETLABEL));
+
+               GridData gd = new GridData();
+               gd.verticalAlignment = SWT.BEGINNING;
+               gd.verticalIndent = 5;
+               label.setLayoutData(gd);
+
+               if (uiAttributes.get(InputUIElement.DESCRIPTION) != null){
+                       String tipText = uiAttributes.get(UIElement.DESCRIPTION);
+                       tipText = tipText.replaceAll("\\\\r\\\\n", "\r\n"); //$NON-NLS-1$, //$NON-NLS-2$
+                       label.setToolTipText(tipText);
+               }
+               Composite flcComposite = new Composite(uiComposite, SWT.NONE);
+               gridData = new GridData(GridData.FILL_HORIZONTAL);
+               flcComposite.setLayout(new GridLayout());
+               flcComposite.setLayoutData(gridData);
+
+               fileListControl = new FileListControl(flcComposite, uiAttributes.get(InputUIElement.WIDGETLABEL), 1);
+               fileListControl.setList(itemsList.toArray(new String[itemsList.size()]));
+               fileListControl.setSelection(0);
+               fileListControl.addChangeListener(new IFileListChangeListener(){
+                       public void fileListChanged(FileListControl fileList, String oldValue[], String newValue[]) {
+                               itemsList.clear();
+                               itemsList.addAll(Arrays.asList(newValue));
+                               uiComposite.firePatternEvent(createPatternEvent());
+                       }
+               });
+               uiComposite.firePatternEvent(createPatternEvent());
+       }
+
+       /**
+        * call the dispose method on the widgets. This is to ensure that the
+        * widgets are properly disposed.
+        */
+       @Override
+       public void disposeWidget() {
+               label.dispose();
+               fileListControl = null;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UIStringListWidget.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UIStringListWidget.java
new file mode 100644 (file)
index 0000000..e4f623b
--- /dev/null
@@ -0,0 +1,176 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Symbian Software Limited - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui.templateengine.uitree.uiwidgets;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+import com.ibm.icu.text.MessageFormat;
+
+import org.eclipse.cdt.core.templateengine.TemplateEngineHelper;
+import org.eclipse.cdt.ui.templateengine.event.PatternEvent;
+import org.eclipse.cdt.ui.templateengine.uitree.InputUIElement;
+import org.eclipse.cdt.ui.templateengine.uitree.UIAttributes;
+import org.eclipse.cdt.ui.templateengine.uitree.UIElement;
+import org.eclipse.cdt.utils.ui.controls.FileListControl;
+import org.eclipse.cdt.utils.ui.controls.IFileListChangeListener;
+
+
+/**
+ * This gives a Label and StringList Widget.
+ * 
+ */
+public class UIStringListWidget extends InputUIElement {
+       /**
+        * StringList widget.
+        */
+       protected FileListControl fileListControl;
+
+       /**
+        * Label of this widget.
+        */
+       protected Label label;
+
+       protected List<String> itemsList;
+
+       /**
+        * Constructor.
+        * 
+        * @param attribute
+        *            attribute associated with this widget.
+        */
+       public UIStringListWidget(UIAttributes attribute) {
+               super(attribute);
+               itemsList = new ArrayList<String>();
+       }
+
+       /**
+        * @return String_List value contained in the String_List Widget.
+        */
+       @Override
+       public Map<String, String> getValues() {
+               Map<String, String> retMap = new HashMap<String, String>();
+               String itemString = new String();
+               for (int i = 0; i < itemsList.size(); i++) {
+                       itemString = itemString + itemsList.get(i) + "|"; //$NON-NLS-1$
+               }
+               retMap.put(uiAttributes.get(UIElement.ID), itemString);
+
+               return retMap;
+       }
+
+       /**
+        * Set the Text widget with new value.
+        * 
+        * @param valueMap
+        */
+       @Override
+       public void setValues(Map<String, String> valueMap) {
+               String items = valueMap.get(uiAttributes.get(UIElement.ID));
+
+               if (items != null) {
+                       items = items.trim();
+                       StringTokenizer st = new StringTokenizer(items, "|"); //$NON-NLS-1$
+                       while (st.hasMoreTokens()) {
+                               itemsList.add(st.nextToken());
+                       }
+               }
+       }
+
+       /**
+        * create a Label and StringList widget, add it to UIComposite. set Layout
+        * for the widgets to be added to UIComposite. set required parameters to
+        * the Widgets.
+        * 
+        * @param uiComposite
+        */
+       @Override
+       public void createWidgets(final UIComposite uiComposite) {
+               GridData gridData = null;
+
+               label = new Label(uiComposite, SWT.LEFT);
+               label.setText(uiAttributes.get(InputUIElement.WIDGETLABEL));
+
+               GridData gd = new GridData();
+               gd.verticalAlignment = SWT.BEGINNING;
+               gd.verticalIndent = 5;
+               label.setLayoutData(gd);
+
+               if (uiAttributes.get(UIElement.DESCRIPTION) != null){
+                       String tipText = uiAttributes.get(UIElement.DESCRIPTION);
+                       tipText = tipText.replaceAll("\\\\r\\\\n", "\r\n"); //$NON-NLS-1$ //$NON-NLS-2$, $NON-NLS-2$
+                       label.setToolTipText(tipText);
+               }
+               Composite flcComposite = new Composite(uiComposite, SWT.NONE);
+               gridData = new GridData(GridData.FILL_HORIZONTAL);
+               flcComposite.setLayout(new GridLayout());
+               flcComposite.setLayoutData(gridData);
+
+               fileListControl = new FileListControl(flcComposite, uiAttributes.get(InputUIElement.WIDGETLABEL), 0);
+               fileListControl.setList(itemsList.toArray(new String[itemsList.size()]));
+               fileListControl.setSelection(0);
+               fileListControl.addChangeListener(new IFileListChangeListener(){
+                       public void fileListChanged(FileListControl fileList, String oldValue[], String newValue[]) {
+                               itemsList.clear();
+                               itemsList.addAll(Arrays.asList(newValue));
+                               uiComposite.firePatternEvent(createPatternEvent());
+                       }
+               });
+               
+               uiComposite.firePatternEvent(createPatternEvent());
+       }
+       
+       protected PatternEvent createPatternEvent() {
+               String msg= MessageFormat.format("Please add an item to {0}", new String[] {label.getText()}); //$NON-NLS-1$
+               return new PatternEvent(this, msg, isValid());
+       }
+
+       /**
+        * Based on the stage of this Widget return true or false. This return value
+        * will be used by the UIPage to update its(UIPage) state. Return value
+        * depends on the value contained in String List Widget. If value contained
+        * is null and Mandatory value from attributes.
+        * 
+        * @return boolean.
+        */
+       @Override
+       public boolean isValid() {
+               boolean retVal = true;
+               String mandatory = uiAttributes.get(InputUIElement.MANDATORY);
+
+               if ((itemsList == null || itemsList.size() == 0) && (mandatory.equalsIgnoreCase(TemplateEngineHelper.BOOLTRUE))) {
+                       retVal = false;
+               }
+               return retVal;
+       }
+
+       /**
+        * call the dispose method on the widgets. This is to ensure that the
+        * widgets are properly disposed.
+        */
+       @Override
+       public void disposeWidget() {
+               label.dispose();
+               fileListControl = null;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UITextWidget.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/templateengine/uitree/uiwidgets/UITextWidget.java
new file mode 100644 (file)
index 0000000..23ac1c7
--- /dev/null
@@ -0,0 +1,320 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Symbian Software Limited and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bala Torati (Symbian) - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.templateengine.uitree.uiwidgets;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.cdt.core.templateengine.TemplateEngineHelper;
+import org.eclipse.cdt.ui.templateengine.Messages;
+import org.eclipse.cdt.ui.templateengine.event.PatternEvent;
+import org.eclipse.cdt.ui.templateengine.uitree.IPatternMatchingTable;
+import org.eclipse.cdt.ui.templateengine.uitree.InputUIElement;
+import org.eclipse.cdt.ui.templateengine.uitree.UIAttributes;
+import org.eclipse.cdt.ui.templateengine.uitree.UIElement;
+
+
+/**
+ * This gives a Label and Text widget. The Text widget can be SINGLE type of
+ * MULTI type. This depends on the input type in TemplateDescriptor. The data
+ * entered by the user is verified against an expected pattern. If the user
+ * entered data doesn't confirms to the expected pattern, a PatternEvent is
+ * fired to UIComposite.
+ * 
+ * The UI***Widget classes which needs to handle patterns, can inherit the same
+ * from this class. The inheriting class need not cache UIComposite instance
+ * but should set the same for UITextWidget(super).
+ */
+public class UITextWidget extends InputUIElement implements ModifyListener {
+
+       /**
+        * Text widget.
+        */
+       protected Text text;
+
+       /**
+        * Label of this widget.
+        */
+       protected Label label;
+       private String patternValue;
+
+       /**
+        * Composite to which this widget control is added. Classes extending this class, should make sure that they initialize this from the respective class createWidgets method.
+        */
+       protected UIComposite uiComposite;
+       
+       protected String textValue;
+
+       /**
+        * Constructor.
+        * 
+        * @param uiAttribute
+        *            attribute associated with this widget.
+        */
+       public UITextWidget(UIAttributes uiAttribute) {
+               super(uiAttribute);
+               this.textValue = new String();
+       }
+
+       /**
+        * @return String, value contained in the Text Widget.
+        */
+       @Override
+       public Map<String, String> getValues() {
+               Map<String, String> retMap = new HashMap<String, String>();
+               retMap.put(uiAttributes.get(InputUIElement.ID), textValue);
+
+               return retMap;
+       }
+
+       /**
+        * Set the Text widget with new value.
+        * 
+        * @param valueMap
+        */
+       @Override
+       public void setValues(Map<String, String> valueMap) {
+               String val = valueMap.get(uiAttributes.get(InputUIElement.ID));
+               String key = null;
+               String subString = null;
+               if (val != null) {
+                       if (val.indexOf(TemplateEngineHelper.OPEN_MARKER) != -1) {
+                               key = TemplateEngineHelper.getFirstMarkerID(val);
+                               subString = val.substring(key.length() + 3, val.length());
+                               if (valueMap.get(key) != null)
+                                       val = valueMap.get(key) + subString;
+                               else
+                                       val = subString;
+                       }
+                       val = val.trim();
+                       textValue = val;
+               }
+       }
+
+       /**
+        * create a Label and Text widget, add it to UIComposite. set Layout for the
+        * widgets to be added to UIComposite. set required parameters to the
+        * Widgets.
+        * 
+        * @param uiComposite
+        */
+       @Override
+       public void createWidgets(UIComposite uiComposite) {
+
+               GridData gd = new GridData();
+               this.uiComposite = uiComposite;
+               label = new Label(uiComposite, SWT.LEFT);
+
+               label.setText(uiAttributes.get(InputUIElement.WIDGETLABEL));
+               if ((uiAttributes.get(UIElement.TYPE)).equalsIgnoreCase(InputUIElement.MULTILINETYPE)) {
+                       gd = new GridData();
+                       gd.verticalAlignment = SWT.BEGINNING;
+                       gd.verticalIndent = 5;
+                       label.setLayoutData(gd);
+               }
+
+               if (uiAttributes.get(UIElement.DESCRIPTION) != null){
+                       String tipText = uiAttributes.get(UIElement.DESCRIPTION);
+                       tipText = tipText.replaceAll("\\\\r\\\\n", "\r\n"); //$NON-NLS-1$ //$NON-NLS-2$
+                       label.setToolTipText(tipText);
+               }
+               text = getTextWidget(uiAttributes.get(UIElement.TYPE));
+               text.addModifyListener(this);
+               text.setData(".uid", uiAttributes.get(UIElement.ID)); //$NON-NLS-1$
+               text.setText(textValue);
+       }
+
+       /**
+        * call the dispose method on the widgets. This is to ensure that the
+        * widgets are properly disposed.
+        */
+       @Override
+       public void disposeWidget() {
+               label.dispose();
+               text.dispose();
+       }
+
+       /**
+        * evaluate the text entered by the user against the pattern associated with
+        * this widget. checks the text entered. On violation of pattern associated
+        * for this widget, by the user entered text. A pattern event is fired to
+        * the container. If this widget has attribute 'checkproject' set to true,
+        * the value entered in this widget is treated as project name. The same is
+        * verified if there is a directory by the same name in workspace,
+        * PatternEvent is thrown to Container.
+        * 
+        * @param pattern
+        */
+       public void evaluatePattern(String labelText, String userInputText, String pattern) {
+               String message = labelText + InputUIElement.CONTENTS;
+               Pattern pattern2 = Pattern.compile(pattern);
+               Matcher matcher = pattern2.matcher(userInputText);
+               if (!matcher.matches()) {
+                       String[] failed = pattern2.split(userInputText);
+                       for (int i = 1; i < failed.length; i++)
+                               message = message + " " + failed[i]; //$NON-NLS-1$
+                       message += InputUIElement.ISINVALID;
+                       message += " Expected pattern is \"" + pattern + "\""; //$NON-NLS-1$ //$NON-NLS-2$
+                       if (uiComposite != null)
+                               uiComposite.firePatternEvent(new PatternEvent(this, message, false));
+
+               } else {
+                       String checkproject = uiAttributes.get(InputUIElement.CHECKPROJECT);
+                       if ((checkproject != null) && (checkproject.equalsIgnoreCase(TemplateEngineHelper.BOOLTRUE))
+                                       && TemplateEngineHelper.checkDirectoryInWorkspace(userInputText)) {
+
+                               message = userInputText + Messages.getString("UITextWidget.0"); //$NON-NLS-1$
+                               uiComposite.firePatternEvent(new PatternEvent(this, message, false));
+                       } else {
+                               if (uiComposite != null)
+                                       uiComposite.firePatternEvent(new PatternEvent(this, message, true));
+                       }
+               }
+       }
+
+       /**
+        * Method from ModifyListener. Extracts the Text from the widget. calls
+        * evaluatePattern.
+        */
+       public void modifyText(ModifyEvent e) {
+               String patternName = uiAttributes.get(InputUIElement.INPUTPATTERN);
+
+               if (patternName == null) {
+                       patternValue = null;
+               } else if (patternName.equals(IPatternMatchingTable.FREETEXT) ||
+                                patternName.equals(IPatternMatchingTable.TEXT) ||
+                                patternName.equals(IPatternMatchingTable.FILENAME)) {
+
+                       patternValue = getPatternValue(patternName);
+               } else {
+                       patternValue = patternName;
+               }
+
+               // Get the source from event. This is done because this class can be
+               // extended by
+               // other classes, having Text widget. They can just make use of
+               // modifyText,
+               // evaluatePattern and isValid.
+               textValue = text.getText();
+
+               if ((patternValue == null) || (textValue == null)) 
+                       return;
+               
+               String mandatory = uiAttributes.get(InputUIElement.MANDATORY);
+               if ((mandatory == null || !mandatory.equalsIgnoreCase("true")) && textValue.equals("")) { //$NON-NLS-1$ //$NON-NLS-2$
+                       return;
+               }
+
+               evaluatePattern(label.getText(), textValue, patternValue);
+       }
+
+       /**
+        * Returns the Pattern Value for the widget.
+        * @param patternName
+        * @return
+        */
+       private String getPatternValue(String patternName) {
+
+               if (patternName.equals(IPatternMatchingTable.TEXT)) {
+                       patternValue = IPatternMatchingTable.TEXTPATTERNVALUE;
+               }
+
+               if (patternName.equals(IPatternMatchingTable.FREETEXT)) {
+                       patternValue = IPatternMatchingTable.FREETEXTPATTERNVALUE;
+               }
+
+               if (patternName.equals(IPatternMatchingTable.FILENAME)) {
+                       patternValue = IPatternMatchingTable.FILEPATTERNVALUE;
+               }
+               return patternValue;
+
+       }
+
+       /**
+        * Based on the sate of this Widget return true or false. This return value
+        * will be used by the UIPage to update its(UIPage) state. Return value
+        * depends on the value contained in TextWidget. If value contained is null, ""
+        * and Mandatory value from attributes.
+        * 
+        * @return boolean.
+        */
+       @Override
+       public boolean isValid() {
+               boolean retVal = true;
+               String mandatory = uiAttributes.get(InputUIElement.MANDATORY);
+
+               if (((mandatory != null) && (mandatory.equalsIgnoreCase(TemplateEngineHelper.BOOLTRUE)))
+                               && ((textValue == null) || (textValue.equals("")) || //$NON-NLS-1$
+                               (textValue.trim().length() < 1))) {
+
+                       retVal = false;
+               }
+               return retVal;
+       }
+
+       /**
+        * Based on Input Type Text widget is created. The Text widget created can
+        * be of Type SINGLE or MULTI.
+        * 
+        * @param type
+        *            of Text widget required.
+        * @return Text.
+        */
+       private Text getTextWidget(String type) {
+               Text retTextWidget = null;
+
+               Composite textConatiner = new Composite(uiComposite, SWT.NONE | SWT.NO_REDRAW_RESIZE);
+
+               textConatiner.setLayout(new GridLayout());
+
+               if (type.equalsIgnoreCase(InputUIElement.INPUTTYPE)) {
+                       GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
+                       gridData.widthHint = 70;
+                       textConatiner.setLayoutData(gridData);
+                       retTextWidget = new Text(textConatiner, SWT.SINGLE | SWT.BORDER);
+                       retTextWidget.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               }
+               if (type.equalsIgnoreCase(InputUIElement.MULTILINETYPE)) {
+
+                       GridData multiTextData = new GridData(GridData.FILL_HORIZONTAL);
+                       multiTextData.widthHint = 70;
+                       String line = uiAttributes.get(InputUIElement.SIZE);
+                       int cnt = 1;
+                       if (line != null) {
+                               cnt = Integer.parseInt(line);
+                               if (cnt <= 0)
+                                       cnt = 1;
+
+                       }
+                       multiTextData.heightHint = 30 + 12 * cnt;
+                       textConatiner.setLayoutData(multiTextData);
+
+                       retTextWidget = new Text(textConatiner, SWT.WRAP | SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);
+                       GridData textData = new GridData(SWT.FILL, SWT.FILL, true, true);
+                       retTextWidget.setLayoutData(textData);
+
+               }
+
+               return retTextWidget;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/AbstractCScanner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/AbstractCScanner.java
new file mode 100644 (file)
index 0000000..668cde4
--- /dev/null
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Andrew Ferguson (Symbian)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
+import org.eclipse.jface.text.rules.IRule;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+import org.eclipse.cdt.ui.IPropertyChangeParticipant;
+
+/**
+ * Convenience implementation for {@link ICTokenScanner}.
+ * Subclasses need to initialize scanner rules by calling {@link #setRules(IRule[])} or {@link #setRules(List)}.
+ * <p>
+ * Clients may instantiate and extend this class.
+ * </p>
+ * 
+ * @since 5.1
+ */
+public abstract class AbstractCScanner extends BufferedRuleBasedScanner implements ICTokenScanner {
+       private List<IPropertyChangeParticipant> fParticipants;
+       final protected ITokenStore fTokenStore;
+       
+       /**
+        * Create a new scanner for the given token store with default buffer size.
+        * 
+        * @param tokenStore
+        */
+       public AbstractCScanner(ITokenStore tokenStore) {
+               fTokenStore= tokenStore;
+               fParticipants= new ArrayList<IPropertyChangeParticipant>();
+       }
+       
+       /**
+        * Create a new scanner for the given token store and buffer size.
+        * 
+        * @param tokenStore
+        * @param size
+        */
+       public AbstractCScanner(ITokenStore tokenStore, int size) {
+               this(tokenStore);
+               setBufferSize(size);
+       }
+       
+       protected void addPropertyChangeParticipant(IPropertyChangeParticipant participant) {
+               fParticipants.add(participant);
+       }
+       
+       /**
+        * Convenience method for setting the scanner rules with a list rather
+        * than an array.
+        * @param rules
+        */
+       public final void setRules(List<IRule> rules) {
+               if(rules==null) {
+                       setRules((IRule[])null);
+               } else {
+                       IRule[] result= new IRule[rules.size()];
+                       rules.toArray(result);
+                       setRules(result);               
+               }
+       }
+
+       /*
+        * @see org.eclipse.jface.text.rules.RuleBasedScanner#nextToken()
+        */
+       @Override
+       public IToken nextToken() {
+               fTokenStore.ensureTokensInitialised();
+               return super.nextToken();
+       }
+       
+       public IToken getToken(String key) {
+               return fTokenStore.getToken(key);
+       }
+       
+       public IPreferenceStore getPreferenceStore() {
+               return fTokenStore.getPreferenceStore();
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.IPropertyChangeParticipant#adaptToPreferenceChange(org.eclipse.jface.util.PropertyChangeEvent)
+        */
+       public void adaptToPreferenceChange(PropertyChangeEvent event) {
+               if(fTokenStore.affectsBehavior(event)) {
+                       fTokenStore.adaptToPreferenceChange(event);
+               }
+               for (IPropertyChangeParticipant propertyChangeParticipant : fParticipants) {
+                       propertyChangeParticipant.adaptToPreferenceChange(event);
+               }
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.IPropertyChangeParticipant#affectsBehavior(org.eclipse.jface.util.PropertyChangeEvent)
+        */
+       public boolean affectsBehavior(PropertyChangeEvent event) {
+               boolean result= fTokenStore.affectsBehavior(event);
+               for(Iterator<IPropertyChangeParticipant> i= fParticipants.iterator(); !result && i.hasNext(); ) {
+                       result |= (i.next()).affectsBehavior(event);
+               }
+               return result;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/AsmSourceViewerConfiguration.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/AsmSourceViewerConfiguration.java
new file mode 100644 (file)
index 0000000..e7d8fb5
--- /dev/null
@@ -0,0 +1,381 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text;
+
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.presentation.IPresentationReconciler;
+import org.eclipse.jface.text.presentation.PresentationReconciler;
+import org.eclipse.jface.text.reconciler.IReconciler;
+import org.eclipse.jface.text.reconciler.MonoReconciler;
+import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
+import org.eclipse.jface.text.rules.RuleBasedScanner;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPathEditorInput;
+import org.eclipse.ui.editors.text.ILocationProvider;
+import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
+import org.eclipse.ui.ide.ResourceUtil;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.AssemblyLanguage;
+import org.eclipse.cdt.core.model.IAsmLanguage;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.LanguageManager;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.ILanguageUI;
+
+import org.eclipse.cdt.internal.ui.editor.asm.AsmCodeScanner;
+import org.eclipse.cdt.internal.ui.editor.asm.AsmPreprocessorScanner;
+import org.eclipse.cdt.internal.ui.editor.asm.AsmReconcilingStrategy;
+import org.eclipse.cdt.internal.ui.text.CCommentScanner;
+import org.eclipse.cdt.internal.ui.text.PartitionDamager;
+import org.eclipse.cdt.internal.ui.text.SingleTokenCScanner;
+import org.eclipse.cdt.internal.ui.text.TokenStore;
+
+/**
+ * Configuration for a source viewer which shows Assembly code.
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ *
+ * @noextend This class is not intended to be subclassed by clients.
+ * 
+ * @since 5.1
+ */
+public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration {
+
+       private ITextEditor fTextEditor;
+       /**
+        * The code scanner.
+        */
+       private AbstractCScanner fCodeScanner;
+       /**
+        * The C multi-line comment scanner.
+        */
+       private AbstractCScanner fMultilineCommentScanner;
+       /**
+        * The C single-line comment scanner.
+        */
+       private AbstractCScanner fSinglelineCommentScanner;
+       /**
+        * The C string scanner.
+        */
+       private AbstractCScanner fStringScanner;
+       /**
+        * The preprocessor scanner.
+        */
+       private AbstractCScanner fPreprocessorScanner;
+       /**
+        * The color manager.
+        */
+       private IColorManager fColorManager;
+       /**
+        * The document partitioning.
+        */
+       private String fDocumentPartitioning;
+       
+       /**
+        * Creates a new assembly source viewer configuration for viewers in the given editor
+        * using the given preference store, the color manager and the specified document partitioning.
+        *
+        * @param colorManager the color manager
+        * @param preferenceStore the preference store, can be read-only
+        * @param editor the editor in which the configured viewer(s) will reside, or <code>null</code> if none
+        * @param partitioning the document partitioning for this configuration, or <code>null</code> for the default partitioning
+        */
+       public AsmSourceViewerConfiguration(IColorManager colorManager, IPreferenceStore preferenceStore, ITextEditor editor, String partitioning) {
+               super(preferenceStore);
+               fColorManager= colorManager;
+               fTextEditor= editor;
+               fDocumentPartitioning= partitioning;
+               initializeScanners();
+       }
+
+       /**
+        * Initializes the scanners.
+        */
+       private void initializeScanners() {
+               fMultilineCommentScanner= new CCommentScanner(getTokenStoreFactory(), ICColorConstants.C_MULTI_LINE_COMMENT);
+               fSinglelineCommentScanner= new CCommentScanner(getTokenStoreFactory(), ICColorConstants.C_SINGLE_LINE_COMMENT);
+               fStringScanner= new SingleTokenCScanner(getTokenStoreFactory(), ICColorConstants.C_STRING);
+       }
+
+       /**
+        * Returns the ASM multiline comment scanner for this configuration.
+        *
+        * @return the ASM multiline comment scanner
+        */
+       public RuleBasedScanner getMultilineCommentScanner() {
+               return fMultilineCommentScanner;
+       }
+       
+       /**
+        * Returns the ASM singleline comment scanner for this configuration.
+        *
+        * @return the ASM singleline comment scanner
+        */
+       public RuleBasedScanner getSinglelineCommentScanner() {
+               return fSinglelineCommentScanner;
+       }
+       
+       /**
+        * Returns the ASM string scanner for this configuration.
+        *
+        * @return the ASM string scanner
+        */
+       public RuleBasedScanner getStringScanner() {
+               return fStringScanner;
+       }
+
+       /**
+        * Returns the assembly preprocessor scanner for this configuration.
+        * @param language
+        *
+        * @return the assembly preprocessor scanner
+        */
+       public RuleBasedScanner getPreprocessorScanner(ILanguage language) {
+               if (fPreprocessorScanner != null) {
+                       return fPreprocessorScanner;
+               }
+               AbstractCScanner scanner= null;
+               if (language instanceof IAsmLanguage) {
+                       scanner= new AsmPreprocessorScanner(getTokenStoreFactory(), (IAsmLanguage)language);
+               }
+               if (scanner == null) {
+                       scanner= new AsmPreprocessorScanner(getTokenStoreFactory(), AssemblyLanguage.getDefault());
+               }
+               fPreprocessorScanner= scanner;
+               return fPreprocessorScanner;
+       }
+
+       /**
+        * @param language
+        * @return the assembly code scanner for the given language
+        */
+       public RuleBasedScanner getCodeScanner(ILanguage language) {
+               if (fCodeScanner != null) {
+                       return fCodeScanner;
+               }
+               RuleBasedScanner scanner= null;
+               if (language instanceof IAsmLanguage) {
+                       IAsmLanguage asmLang= (IAsmLanguage)language;
+                       scanner = new AsmCodeScanner(getTokenStoreFactory(), asmLang);
+               } else if (language != null) {
+                       ILanguageUI languageUI = (ILanguageUI)language.getAdapter(ILanguageUI.class);
+                       if (languageUI != null)
+                               scanner = languageUI.getCodeScanner();
+               }
+               if (scanner == null) {
+                       scanner = new AsmCodeScanner(getTokenStoreFactory(), AssemblyLanguage.getDefault());
+               }
+               if (scanner instanceof AbstractCScanner) {
+                       fCodeScanner= (AbstractCScanner)scanner;
+               }
+               return scanner;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getConfiguredDocumentPartitioning(org.eclipse.jface.text.source.ISourceViewer)
+        */
+       @Override
+       public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) {
+               if (fDocumentPartitioning != null)
+                       return fDocumentPartitioning;
+               return super.getConfiguredDocumentPartitioning(sourceViewer);
+       }
+
+       /*
+        * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getPresentationReconciler(org.eclipse.jface.text.source.ISourceViewer)
+        */
+       @Override
+       public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
+
+               PresentationReconciler reconciler= new PresentationReconciler();
+
+               ILanguage language= getLanguage();
+               DefaultDamagerRepairer dr= new DefaultDamagerRepairer(getCodeScanner(language));
+               reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
+               reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
+
+               dr= new DefaultDamagerRepairer(getMultilineCommentScanner());           
+               reconciler.setDamager(dr, ICPartitions.C_MULTI_LINE_COMMENT);
+               reconciler.setRepairer(dr, ICPartitions.C_MULTI_LINE_COMMENT);
+               
+               dr= new DefaultDamagerRepairer(getSinglelineCommentScanner());          
+               reconciler.setDamager(dr, ICPartitions.C_SINGLE_LINE_COMMENT);
+               reconciler.setRepairer(dr, ICPartitions.C_SINGLE_LINE_COMMENT);
+
+               dr= new DefaultDamagerRepairer(getStringScanner());             
+               reconciler.setDamager(dr, ICPartitions.C_STRING);
+               reconciler.setRepairer(dr, ICPartitions.C_STRING);
+
+               dr= new DefaultDamagerRepairer(getStringScanner());             
+               reconciler.setDamager(dr, ICPartitions.C_CHARACTER);
+               reconciler.setRepairer(dr, ICPartitions.C_CHARACTER);
+
+               dr= new DefaultDamagerRepairer(getPreprocessorScanner(language));               
+               reconciler.setDamager(new PartitionDamager(), ICPartitions.C_PREPROCESSOR);
+               reconciler.setRepairer(dr, ICPartitions.C_PREPROCESSOR);
+
+               reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
+               return reconciler;
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getConfiguredContentTypes(org.eclipse.jface.text.source.ISourceViewer)
+        */
+       @Override
+       public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
+               return new String[] {   
+                               IDocument.DEFAULT_CONTENT_TYPE, 
+                               ICPartitions.C_MULTI_LINE_COMMENT,
+                               ICPartitions.C_SINGLE_LINE_COMMENT,
+                               ICPartitions.C_STRING,
+                               ICPartitions.C_CHARACTER,
+                               ICPartitions.C_PREPROCESSOR};
+       }
+
+       /*
+        * @see org.eclipse.ui.editors.text.TextSourceViewerConfiguration#getReconciler(org.eclipse.jface.text.source.ISourceViewer)
+        */
+       @Override
+       public IReconciler getReconciler(ISourceViewer sourceViewer) {
+               if (fTextEditor != null) {
+                       MonoReconciler reconciler= new MonoReconciler(new AsmReconcilingStrategy(fTextEditor), false);
+                       reconciler.setIsIncrementalReconciler(false);
+                       reconciler.setProgressMonitor(new NullProgressMonitor());
+                       reconciler.setDelay(500);
+                       return reconciler;
+               }
+               return super.getReconciler(sourceViewer);
+       }
+
+       /**
+        * Determines whether the preference change encoded by the given event
+        * changes the behavior of one of its contained components.
+        *
+        * @param event the event to be investigated
+        * @return <code>true</code> if event causes a behavioral change
+        */
+       public boolean affectsTextPresentation(PropertyChangeEvent event) {
+               if (fMultilineCommentScanner.affectsBehavior(event)
+                               || fSinglelineCommentScanner.affectsBehavior(event)
+                               || fStringScanner.affectsBehavior(event)) {
+                               return true;
+                       }
+               if (fCodeScanner != null && fCodeScanner.affectsBehavior(event)) {
+                       return true;
+               }
+               if (fPreprocessorScanner != null && fPreprocessorScanner.affectsBehavior(event)) {
+                       return true;
+               }
+               return false;
+       }
+
+       /**
+        * Adapts the behavior of the contained components to the change
+        * encoded in the given event.
+        * <p>
+        * Clients are not allowed to call this method if the old setup with
+        * text tools is in use.
+        * </p>
+        *
+        * @param event the event to which to adapt
+        * @see CSourceViewerConfiguration#CSourceViewerConfiguration(IColorManager, IPreferenceStore, ITextEditor, String)
+        */
+       public void handlePropertyChangeEvent(PropertyChangeEvent event) {
+               if (fCodeScanner != null && fCodeScanner.affectsBehavior(event))
+                       fCodeScanner.adaptToPreferenceChange(event);
+               if (fMultilineCommentScanner.affectsBehavior(event))
+                       fMultilineCommentScanner.adaptToPreferenceChange(event);
+               if (fSinglelineCommentScanner.affectsBehavior(event))
+                       fSinglelineCommentScanner.adaptToPreferenceChange(event);
+               if (fStringScanner.affectsBehavior(event))
+                       fStringScanner.adaptToPreferenceChange(event);
+               if (fPreprocessorScanner != null && fPreprocessorScanner.affectsBehavior(event))
+                       fPreprocessorScanner.adaptToPreferenceChange(event);
+       }
+
+       /**
+        * Returns the color manager for this configuration.
+        *
+        * @return the color manager
+        */
+       public IColorManager getColorManager() {
+               return fColorManager;
+       }
+
+       public ILanguage getLanguage() {
+               if (fTextEditor == null) {
+                       return AssemblyLanguage.getDefault();
+               }
+               ICElement element = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(fTextEditor.getEditorInput());
+               if (element instanceof ITranslationUnit) {
+                       try {
+                               return ((ITranslationUnit)element).getLanguage();
+                       } catch (CoreException e) {
+                               CUIPlugin.log(e);
+                       }
+               } else {
+                       // compute the language from the plain editor input
+                       IContentType contentType = null;
+                       IEditorInput input = fTextEditor.getEditorInput();
+                       IFile file = ResourceUtil.getFile(input);
+                       if (file != null) {
+                               contentType = CCorePlugin.getContentType(file.getProject(), file.getName());
+                       } else if (input instanceof IPathEditorInput) {
+                               IPath path = ((IPathEditorInput)input).getPath();
+                               contentType = CCorePlugin.getContentType(path.lastSegment());
+                       } else {
+                               ILocationProvider locationProvider = (ILocationProvider)input.getAdapter(ILocationProvider.class);
+                               if (locationProvider != null) {
+                                       IPath path = locationProvider.getPath(input);
+                                       contentType = CCorePlugin.getContentType(path.lastSegment());
+                               }
+                       }
+                       if (contentType != null) {
+                               return LanguageManager.getInstance().getLanguage(contentType);
+                       }
+               }
+               // fallback
+               return AssemblyLanguage.getDefault();
+       }
+
+       /**
+        * Reset cached language dependent scanners.
+        */
+       public void resetScanners() {
+               fCodeScanner= null;
+               fPreprocessorScanner= null;
+       }
+
+       private ITokenStoreFactory getTokenStoreFactory() {
+               return new ITokenStoreFactory() {
+                       public ITokenStore createTokenStore(String[] propertyColorNames) {
+                               return new TokenStore(getColorManager(), fPreferenceStore, propertyColorNames);
+                       }
+               };
+       }
+}
+
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/CSourceViewerConfiguration.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/CSourceViewerConfiguration.java
new file mode 100644 (file)
index 0000000..b712e85
--- /dev/null
@@ -0,0 +1,1057 @@
+/*******************************************************************************
+ *  Copyright (c) 2005, 2010 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     Anton Leherbauer (Wind River Systems)
+ *     Sergey Prigogin (Google)
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text;
+
+import java.util.Arrays;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+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.content.IContentType;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.AbstractInformationControlManager;
+import org.eclipse.jface.text.DefaultInformationControl;
+import org.eclipse.jface.text.DefaultTextDoubleClickStrategy;
+import org.eclipse.jface.text.IAutoEditStrategy;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IInformationControl;
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.ITextDoubleClickStrategy;
+import org.eclipse.jface.text.ITextHover;
+import org.eclipse.jface.text.ITextViewerExtension2;
+import org.eclipse.jface.text.contentassist.ContentAssistant;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.text.contentassist.IContentAssistant;
+import org.eclipse.jface.text.formatter.IContentFormatter;
+import org.eclipse.jface.text.formatter.MultiPassContentFormatter;
+import org.eclipse.jface.text.information.IInformationPresenter;
+import org.eclipse.jface.text.information.IInformationProvider;
+import org.eclipse.jface.text.information.InformationPresenter;
+import org.eclipse.jface.text.presentation.IPresentationReconciler;
+import org.eclipse.jface.text.quickassist.IQuickAssistAssistant;
+import org.eclipse.jface.text.reconciler.IReconciler;
+import org.eclipse.jface.text.reconciler.MonoReconciler;
+import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
+import org.eclipse.jface.text.rules.RuleBasedScanner;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationHover;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IPathEditorInput;
+import org.eclipse.ui.editors.text.ILocationProvider;
+import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
+import org.eclipse.ui.ide.ResourceUtil;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
+import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICLanguageKeywords;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.model.LanguageManager;
+import org.eclipse.cdt.ui.CElementContentProvider;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.ILanguageUI;
+import org.eclipse.cdt.ui.text.doctools.DefaultMultilineCommentAutoEditStrategy;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration;
+
+import org.eclipse.cdt.internal.core.model.ProgressMonitorAndCanceler;
+import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
+
+import org.eclipse.cdt.internal.ui.editor.CDocumentProvider;
+import org.eclipse.cdt.internal.ui.text.CAutoIndentStrategy;
+import org.eclipse.cdt.internal.ui.text.CCodeScanner;
+import org.eclipse.cdt.internal.ui.text.CCommentScanner;
+import org.eclipse.cdt.internal.ui.text.CCompositeReconcilingStrategy;
+import org.eclipse.cdt.internal.ui.text.CDoubleClickSelector;
+import org.eclipse.cdt.internal.ui.text.CFormattingStrategy;
+import org.eclipse.cdt.internal.ui.text.COutlineInformationControl;
+import org.eclipse.cdt.internal.ui.text.CPreprocessorScanner;
+import org.eclipse.cdt.internal.ui.text.CPresentationReconciler;
+import org.eclipse.cdt.internal.ui.text.CReconciler;
+import org.eclipse.cdt.internal.ui.text.CStringAutoIndentStrategy;
+import org.eclipse.cdt.internal.ui.text.CStringDoubleClickSelector;
+import org.eclipse.cdt.internal.ui.text.HTMLAnnotationHover;
+import org.eclipse.cdt.internal.ui.text.PartitionDamager;
+import org.eclipse.cdt.internal.ui.text.SingleTokenCScanner;
+import org.eclipse.cdt.internal.ui.text.TokenStore;
+import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverDescriptor;
+import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverProxy;
+import org.eclipse.cdt.internal.ui.text.c.hover.CInformationProvider;
+import org.eclipse.cdt.internal.ui.text.c.hover.CMacroExpansionExplorationControl;
+import org.eclipse.cdt.internal.ui.text.c.hover.CMacroExpansionInformationProvider;
+import org.eclipse.cdt.internal.ui.text.contentassist.CContentAssistProcessor;
+import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
+import org.eclipse.cdt.internal.ui.text.correction.CCorrectionAssistant;
+import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
+import org.eclipse.cdt.internal.ui.typehierarchy.THInformationControl;
+import org.eclipse.cdt.internal.ui.typehierarchy.THInformationProvider;
+
+
+/**
+ * Configuration for a <code>SourceViewer</code> which shows C/C++ code.
+ * <p>
+ * This class may be instantiated and subclassed by clients.
+ * </p>
+ * 
+ * @since 5.1
+ */
+public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
+       
+       protected ITextEditor fTextEditor;
+       /**
+        * The document partitioning.
+        */
+       protected String fDocumentPartitioning;
+       /**
+        * The code scanner.
+        */
+       protected AbstractCScanner fCodeScanner;
+       /**
+        * The C multi-line comment scanner.
+        */
+       protected ICTokenScanner fMultilineCommentScanner;
+       /**
+        * The C single-line comment scanner.
+        */
+       protected ICTokenScanner fSinglelineCommentScanner;
+       /**
+        * The C multi-line doc comment scanner.
+        */
+       protected ICTokenScanner fMultilineDocCommentScanner;
+       /**
+        * The C single-line doc comment scanner.
+        */
+       protected ICTokenScanner fSinglelineDocCommentScanner;
+       /**
+        * The C string scanner.
+        */
+       protected AbstractCScanner fStringScanner;
+       /**
+        * The preprocessor scanner.
+        */
+       protected AbstractCScanner fPreprocessorScanner;
+       /**
+        * The color manager.
+        */
+       protected IColorManager fColorManager;
+       
+       /**
+        * Creates a new C source viewer configuration for viewers in the given editor
+        * using the given preference store, the color manager and the specified document partitioning.
+        *
+        * @param colorManager the color manager
+        * @param preferenceStore the preference store, can be read-only
+        * @param editor the editor in which the configured viewer(s) will reside, or <code>null</code> if none
+        * @param partitioning the document partitioning for this configuration, or <code>null</code> for the default partitioning
+        */
+       public CSourceViewerConfiguration(IColorManager colorManager, IPreferenceStore preferenceStore, ITextEditor editor, String partitioning) {
+               super(preferenceStore);
+               fColorManager= colorManager;
+               fTextEditor= editor;
+               fDocumentPartitioning= partitioning;
+               initializeScanners();
+       }
+
+       /**
+        * Returns the C string scanner for this configuration.
+        *
+        * @return the C string scanner
+        */
+       protected RuleBasedScanner getStringScanner() {
+               return fStringScanner;
+       }
+
+       /**
+        * Returns the preprocessor scanner for this configuration.
+        *
+        * @return the preprocessor scanner
+        */
+       protected RuleBasedScanner getPreprocessorScanner(ILanguage language) {
+               if (fPreprocessorScanner != null) {
+                       return fPreprocessorScanner;
+               }
+               AbstractCScanner scanner= null;
+               ICLanguageKeywords keywords = language == null ? null : (ICLanguageKeywords) language.getAdapter(ICLanguageKeywords.class);
+               if (keywords != null) {
+                       scanner = new CPreprocessorScanner(getTokenStoreFactory(), keywords);
+               }
+               if (scanner == null) {
+                       keywords = (ICLanguageKeywords) GPPLanguage.getDefault().getAdapter(ICLanguageKeywords.class);
+                       scanner= new CPreprocessorScanner(getTokenStoreFactory(), keywords);
+               }
+               fPreprocessorScanner= scanner;
+               return fPreprocessorScanner;
+       }
+       
+       /**
+        * Returns the color manager for this configuration.
+        *
+        * @return the color manager
+        */
+       protected IColorManager getColorManager() {
+               return fColorManager;
+       }
+
+       /**
+        * Returns the editor in which the configured viewer(s) will reside.
+        *
+        * @return the enclosing editor
+        */
+       public ITextEditor getEditor() {
+               return fTextEditor;
+       }
+
+    /**
+     * Creates outline presenter.
+     * @return Presenter with outline view.
+     */
+    public IInformationPresenter getOutlinePresenter(ISourceViewer sourceViewer) {
+        final IInformationControlCreator outlineControlCreator = getOutlineControlCreator();
+        final InformationPresenter presenter = new InformationPresenter(outlineControlCreator);
+        presenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
+               presenter.setAnchor(AbstractInformationControlManager.ANCHOR_GLOBAL);
+               final IInformationProvider provider = new CElementContentProvider(getEditor());
+               String[] contentTypes= getConfiguredContentTypes(sourceViewer);
+               for (int i= 0; i < contentTypes.length; i++)
+                       presenter.setInformationProvider(provider, contentTypes[i]);
+        presenter.setSizeConstraints(50, 20, true, false);
+        return presenter;
+    }
+
+    /**
+     * Creates type hierarchy presenter.
+     * @return Presenter with type hierarchy view.
+     */
+    public IInformationPresenter getHierarchyPresenter(ISourceViewer sourceViewer) {
+        final IInformationControlCreator hierarchyControlCreator = getHierarchyControlCreator();
+        final InformationPresenter presenter = new InformationPresenter(hierarchyControlCreator);
+        presenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
+               presenter.setAnchor(AbstractInformationControlManager.ANCHOR_GLOBAL);
+               final IInformationProvider provider = new THInformationProvider(getEditor());
+               String[] contentTypes= getConfiguredContentTypes(sourceViewer);
+               for (int i= 0; i < contentTypes.length; i++)
+                       presenter.setInformationProvider(provider, contentTypes[i]);
+        presenter.setSizeConstraints(50, 20, true, false);
+        return presenter;
+    }
+    
+       /**
+        * Initializes language independent scanners.
+        */
+       protected void initializeScanners() {
+               fStringScanner= new SingleTokenCScanner(getTokenStoreFactory(), ICColorConstants.C_STRING);
+               fMultilineCommentScanner= new CCommentScanner(getTokenStoreFactory(),  ICColorConstants.C_MULTI_LINE_COMMENT);
+               fSinglelineCommentScanner= new CCommentScanner(getTokenStoreFactory(),  ICColorConstants.C_SINGLE_LINE_COMMENT);
+       }
+
+    /**
+     * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getPresentationReconciler(org.eclipse.jface.text.source.ISourceViewer)
+        */
+    @Override
+       public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
+               CPresentationReconciler reconciler= new CPresentationReconciler();
+               reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
+
+               ILanguage language= getLanguage();
+               RuleBasedScanner scanner = getCodeScanner(language);
+
+               DefaultDamagerRepairer dr= new DefaultDamagerRepairer(scanner);
+
+               reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
+               reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
+               
+               dr= new DefaultDamagerRepairer(getSinglelineCommentScanner());
+               reconciler.setDamager(dr, ICPartitions.C_SINGLE_LINE_COMMENT);
+               reconciler.setRepairer(dr, ICPartitions.C_SINGLE_LINE_COMMENT);
+
+               dr= new DefaultDamagerRepairer(getMultilineCommentScanner());
+               reconciler.setDamager(dr, ICPartitions.C_MULTI_LINE_COMMENT);
+               reconciler.setRepairer(dr, ICPartitions.C_MULTI_LINE_COMMENT);
+               
+               ICTokenScanner docCommentSingleScanner= getSinglelineDocCommentScanner(getProject());
+               if(docCommentSingleScanner!=null) {
+                       dr= new DefaultDamagerRepairer(docCommentSingleScanner);
+                       reconciler.setDamager(dr, ICPartitions.C_SINGLE_LINE_DOC_COMMENT);
+                       reconciler.setRepairer(dr, ICPartitions.C_SINGLE_LINE_DOC_COMMENT);
+               }
+       
+               ICTokenScanner docCommentMultiScanner= getMultilineDocCommentScanner(getProject());
+               if(docCommentMultiScanner!=null) {
+                       dr= new DefaultDamagerRepairer(docCommentMultiScanner);
+                       reconciler.setDamager(dr, ICPartitions.C_MULTI_LINE_DOC_COMMENT);
+                       reconciler.setRepairer(dr, ICPartitions.C_MULTI_LINE_DOC_COMMENT);
+               }
+               
+               dr= new DefaultDamagerRepairer(getStringScanner());
+               reconciler.setDamager(dr, ICPartitions.C_STRING);
+               reconciler.setRepairer(dr, ICPartitions.C_STRING);
+               
+               dr= new DefaultDamagerRepairer(getStringScanner());
+               reconciler.setDamager(dr, ICPartitions.C_CHARACTER);
+               reconciler.setRepairer(dr, ICPartitions.C_CHARACTER);
+               
+               dr= new DefaultDamagerRepairer(getPreprocessorScanner(language));
+               reconciler.setDamager(new PartitionDamager(), ICPartitions.C_PREPROCESSOR);
+               reconciler.setRepairer(dr, ICPartitions.C_PREPROCESSOR);
+               
+               return reconciler;
+       }
+
+       /**
+        * Returns the C multi-line comment scanner for this configuration.
+        *
+        * @return the C multi-line comment scanner
+        */
+       protected ICTokenScanner getMultilineCommentScanner() {
+               return fMultilineCommentScanner;
+       }
+
+       /**
+        * Returns the C single-line comment scanner for this configuration.
+        *
+        * @return the C single-line comment scanner
+        */
+       protected ICTokenScanner getSinglelineCommentScanner() {
+               return fSinglelineCommentScanner;
+       }
+
+       /**
+        * Returns the C multi-line doc comment scanner for this configuration.
+        *
+        * @return the C multi-line doc comment scanner
+        */
+       protected ICTokenScanner getMultilineDocCommentScanner(IResource resource) {
+               if (fMultilineDocCommentScanner == null) {
+                       if (resource == null) {
+                               resource= ResourcesPlugin.getWorkspace().getRoot();
+                       }
+                       IDocCommentViewerConfiguration owner= DocCommentOwnerManager.getInstance().getCommentOwner(resource).getMultilineConfiguration();
+                       fMultilineDocCommentScanner= owner.createCommentScanner(getTokenStoreFactory());
+                       if (fMultilineDocCommentScanner == null) {
+                               // fallback: normal comment highlighting
+                               fMultilineDocCommentScanner= fMultilineCommentScanner;
+                       }
+               }
+               return fMultilineDocCommentScanner;
+       }
+
+       /**
+        * Returns the C single-line doc comment scanner for this configuration.
+        *
+        * @return the C single-line doc comment scanner
+        */
+       protected ICTokenScanner getSinglelineDocCommentScanner(IResource resource) {
+               if (fSinglelineDocCommentScanner == null) {
+                       if (resource == null) {
+                               resource= ResourcesPlugin.getWorkspace().getRoot();
+                       }
+                       IDocCommentViewerConfiguration owner= DocCommentOwnerManager.getInstance().getCommentOwner(resource).getSinglelineConfiguration();
+                       fSinglelineDocCommentScanner= owner.createCommentScanner(getTokenStoreFactory());
+                       if (fSinglelineDocCommentScanner == null) {
+                               // fallback: normal comment highlighting
+                               fSinglelineDocCommentScanner= fSinglelineCommentScanner;
+                       }
+               }
+               return fSinglelineDocCommentScanner;
+       }
+    
+       /**
+        * @return the code scanner for the given language
+        */
+       protected RuleBasedScanner getCodeScanner(ILanguage language) {
+               if (fCodeScanner != null) {
+                       return fCodeScanner;
+               }
+               RuleBasedScanner scanner= null;
+               
+               if(language != null) {
+                       ICLanguageKeywords keywords = (ICLanguageKeywords) language.getAdapter(ICLanguageKeywords.class);
+                       if(keywords != null) {
+                               scanner = new CCodeScanner(getTokenStoreFactory(), keywords);
+                       }
+                       else {
+                               ILanguageUI languageUI = (ILanguageUI)language.getAdapter(ILanguageUI.class);
+                               if (languageUI != null)
+                                       scanner = languageUI.getCodeScanner();
+                       }
+               }
+               
+               if (scanner == null) {
+                       scanner = new CCodeScanner(getTokenStoreFactory(), GPPLanguage.getDefault());
+               }
+               if (scanner instanceof AbstractCScanner) {
+                       fCodeScanner= (AbstractCScanner)scanner;
+               }
+               return scanner;
+       }
+
+       /*
+        * @see SourceViewerConfiguration#getContentAssistant(ISourceViewer)
+        */
+       @Override
+       public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
+               if (getEditor() == null) {
+                       return null;
+               }
+
+               ContentAssistant assistant = new ContentAssistant();
+               assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
+
+               assistant.setRestoreCompletionProposalSize(getSettings("completion_proposal_size")); //$NON-NLS-1$
+               
+               IContentAssistProcessor processor = new CContentAssistProcessor(getEditor(), assistant, IDocument.DEFAULT_CONTENT_TYPE);
+               assistant.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
+
+               processor = new CContentAssistProcessor(getEditor(), assistant, ICPartitions.C_MULTI_LINE_COMMENT);
+               assistant.setContentAssistProcessor(processor, ICPartitions.C_MULTI_LINE_COMMENT);
+
+               processor = new CContentAssistProcessor(getEditor(), assistant, ICPartitions.C_SINGLE_LINE_COMMENT);
+               assistant.setContentAssistProcessor(processor, ICPartitions.C_SINGLE_LINE_COMMENT);
+
+               processor = new CContentAssistProcessor(getEditor(), assistant, ICPartitions.C_MULTI_LINE_DOC_COMMENT);
+               assistant.setContentAssistProcessor(processor, ICPartitions.C_MULTI_LINE_DOC_COMMENT);
+
+               processor = new CContentAssistProcessor(getEditor(), assistant, ICPartitions.C_SINGLE_LINE_DOC_COMMENT);
+               assistant.setContentAssistProcessor(processor, ICPartitions.C_SINGLE_LINE_DOC_COMMENT);
+
+               processor = new CContentAssistProcessor(getEditor(), assistant, ICPartitions.C_STRING);
+               assistant.setContentAssistProcessor(processor, ICPartitions.C_STRING);
+
+               processor = new CContentAssistProcessor(getEditor(), assistant, ICPartitions.C_PREPROCESSOR);
+               assistant.setContentAssistProcessor(processor, ICPartitions.C_PREPROCESSOR);
+
+               ContentAssistPreference.configure(assistant, fPreferenceStore);
+               
+               assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
+               assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
+               assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
+
+               return assistant;
+       }
+
+       /**
+        * Returns the settings for the given section.
+        *
+        * @param sectionName the section name
+        * @return the settings
+        * @since 4.0
+        */
+       protected IDialogSettings getSettings(String sectionName) {
+               IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings().getSection(sectionName);
+               if (settings == null)
+                       settings= CUIPlugin.getDefault().getDialogSettings().addNewSection(sectionName);
+
+               return settings;
+       }
+       
+       /*
+        * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getQuickAssistAssistant(org.eclipse.jface.text.source.ISourceViewer)
+        * @since 5.0
+        */
+       @Override
+       public IQuickAssistAssistant getQuickAssistAssistant(ISourceViewer sourceViewer) {
+               if (getEditor() != null)
+                       return new CCorrectionAssistant(getEditor());
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.ui.editors.text.TextSourceViewerConfiguration#getReconciler(org.eclipse.jface.text.source.ISourceViewer)
+        */
+       @Override
+       public IReconciler getReconciler(ISourceViewer sourceViewer) {
+               if (fTextEditor != null) {
+                       //Delay changed and non-incremental reconciler used due to
+                       //PR 130089
+                       CCompositeReconcilingStrategy strategy=
+                               new CCompositeReconcilingStrategy(sourceViewer, fTextEditor, getConfiguredDocumentPartitioning(sourceViewer));
+                       MonoReconciler reconciler= new CReconciler(fTextEditor, strategy);
+                       reconciler.setIsIncrementalReconciler(false);
+                       reconciler.setProgressMonitor(new ProgressMonitorAndCanceler());
+                       reconciler.setDelay(500);
+                       return reconciler;
+               }
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getAutoEditStrategies(org.eclipse.jface.text.source.ISourceViewer, java.lang.String)
+        */
+       @Override
+       public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) {
+               String partitioning= getConfiguredDocumentPartitioning(sourceViewer);
+               
+               IDocCommentOwner owner= DocCommentOwnerManager.getInstance().getCommentOwner(getProject());
+               IAutoEditStrategy single= owner.getSinglelineConfiguration().createAutoEditStrategy();
+               IAutoEditStrategy multi= owner.getMultilineConfiguration().createAutoEditStrategy();
+               
+               IAutoEditStrategy[] NONE= new IAutoEditStrategy[0];
+               
+               if (ICPartitions.C_MULTI_LINE_COMMENT.equals(contentType))
+                       return new IAutoEditStrategy[] { new DefaultMultilineCommentAutoEditStrategy() };
+               if (ICPartitions.C_SINGLE_LINE_DOC_COMMENT.equals(contentType))
+                       return single!=null ? new IAutoEditStrategy[] {single} : NONE;
+               else if (ICPartitions.C_MULTI_LINE_DOC_COMMENT.equals(contentType))
+                       return multi!=null? new IAutoEditStrategy[] {multi} : NONE;
+               else if (ICPartitions.C_STRING.equals(contentType))
+                       return new IAutoEditStrategy[] { /*new SmartSemicolonAutoEditStrategy(partitioning),*/ new CStringAutoIndentStrategy(partitioning, getCProject()) };
+               else
+                       return new IAutoEditStrategy[] { new CAutoIndentStrategy(partitioning, getCProject()) };
+       }
+       
+       /**
+        * @see SourceViewerConfiguration#getDoubleClickStrategy(ISourceViewer, String)
+        */
+       @Override
+       public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) {
+               if (ICPartitions.C_MULTI_LINE_COMMENT.equals(contentType) ||
+                               ICPartitions.C_SINGLE_LINE_COMMENT.equals(contentType)) {
+                       return new DefaultTextDoubleClickStrategy();
+               } else if (ICPartitions.C_SINGLE_LINE_DOC_COMMENT.equals(contentType)) {
+                       IDocCommentOwner owner= DocCommentOwnerManager.getInstance().getCommentOwner(getProject());
+                       ITextDoubleClickStrategy single= owner.getSinglelineConfiguration().createDoubleClickStrategy();
+                       return single != null ? single : new DefaultTextDoubleClickStrategy();
+               } else if(ICPartitions.C_MULTI_LINE_DOC_COMMENT.equals(contentType)) {
+                       IDocCommentOwner owner= DocCommentOwnerManager.getInstance().getCommentOwner(getProject());
+                       ITextDoubleClickStrategy multi= owner.getMultilineConfiguration().createDoubleClickStrategy();
+                       return multi!=null ? multi : new DefaultTextDoubleClickStrategy();
+               } else if (ICPartitions.C_STRING.equals(contentType) ||
+                               ICPartitions.C_CHARACTER.equals(contentType)) {
+                       return new CStringDoubleClickSelector(getConfiguredDocumentPartitioning(sourceViewer));
+               } else if (ICPartitions.C_PREPROCESSOR.equals(contentType)) {
+                       return new CStringDoubleClickSelector(getConfiguredDocumentPartitioning(sourceViewer), new CDoubleClickSelector());
+               }
+               return new CDoubleClickSelector();
+       }
+
+       /**
+        * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getDefaultPrefixes(ISourceViewer, String)
+        */
+       @Override
+       public String[] getDefaultPrefixes(ISourceViewer sourceViewer, String contentType) {
+               return new String[] { "//", "//!", "" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+       }
+
+       /*
+        * @see SourceViewerConfiguration#getIndentPrefixes(ISourceViewer, String)
+        */
+       @Override
+       public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) {
+               ICProject project= getCProject();
+               final int tabWidth= CodeFormatterUtil.getTabWidth(project);
+               final int indentWidth= CodeFormatterUtil.getIndentWidth(project);
+               boolean allowTabs= tabWidth <= indentWidth;
+               
+               String indentMode;
+               if (project == null)
+                       indentMode= CCorePlugin.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
+               else
+                       indentMode= project.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, true);
+
+               boolean useSpaces= CCorePlugin.SPACE.equals(indentMode) || DefaultCodeFormatterConstants.MIXED.equals(indentMode);
+               
+               // assert allowTabs || useSpaces;
+               
+               if (!allowTabs)
+                       return new String[] { getStringWithSpaces(indentWidth), "" }; //$NON-NLS-1$
+               else if  (!useSpaces)
+                       return getIndentPrefixesForTab(tabWidth);
+               else
+                       return getIndentPrefixesForSpaces(tabWidth);
+       }
+
+       /**
+        * Computes and returns the indent prefixes for space indentation
+        * and the given <code>tabWidth</code>.
+        * 
+        * @param tabWidth the display tab width
+        * @return the indent prefixes
+        * @see #getIndentPrefixes(ISourceViewer, String)
+        */
+       protected String[] getIndentPrefixesForSpaces(int tabWidth) {
+               String[] indentPrefixes= new String[tabWidth + 2];
+               indentPrefixes[0]= getStringWithSpaces(tabWidth);
+               
+               for (int i= 0; i < tabWidth; i++) {
+                       String spaces= getStringWithSpaces(i);
+                       if (i < tabWidth)
+                               indentPrefixes[i+1]= spaces + '\t';
+                       else
+                               indentPrefixes[i+1]= new String(spaces);
+               }
+               
+               indentPrefixes[tabWidth + 1]= ""; //$NON-NLS-1$
+
+               return indentPrefixes;
+       }
+
+       /**
+        * Creates and returns a String with <code>count</code> spaces.
+        * 
+        * @param count the space count
+        * @return the string with the spaces
+        */
+       protected static String getStringWithSpaces(int count) {
+               char[] spaceChars= new char[count];
+               Arrays.fill(spaceChars, ' ');
+               return new String(spaceChars);
+       }
+
+       /**
+        * Returns the ICProject associated with this CSourceViewerConfiguration, or null if
+        * no ICProject could be determined
+        * @return the ICProject or <code>null</code>
+        */
+       protected ICProject getCProject() {
+               ITextEditor editor= getEditor();
+               if (editor == null)
+                       return null;
+
+               ICElement element= null;
+               IEditorInput input= editor.getEditorInput();
+               IDocumentProvider provider= editor.getDocumentProvider();
+               if (provider instanceof CDocumentProvider) {
+                       CDocumentProvider cudp= (CDocumentProvider) provider;
+                       element= cudp.getWorkingCopy(input);
+               }
+
+               if (element == null)
+                       return null;
+
+               return element.getCProject();
+       }
+
+       /*
+        * @see SourceViewerConfiguration#getTabWidth(ISourceViewer)
+        */
+       @Override
+       public int getTabWidth(ISourceViewer sourceViewer) {
+               return CodeFormatterUtil.getTabWidth(getCProject());
+       }
+
+       /**
+        * Returns the configured indent width for this viewer.
+        * @param sourceViewer
+        * @return the indent width
+        */
+       public int getIndentWidth(ISourceViewer sourceViewer) {
+               return CodeFormatterUtil.getIndentWidth(getCProject());
+       }
+
+       /**
+        * Returns whether spaces should be used exclusively for indentation.
+        * 
+        * @param sourceViewer
+        * @return <code>true</code> if spaces should be used for indentation
+        */
+       public boolean useSpacesOnly(ISourceViewer sourceViewer) {
+               ICProject project= getCProject();
+               String option;
+               if (project == null)
+                       option= CCorePlugin.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
+               else
+                       option= project.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, true);
+               return CCorePlugin.SPACE.equals(option);
+       }
+       
+       /**
+        * @see SourceViewerConfiguration#getAnnotationHover(ISourceViewer)
+        */
+       @Override
+       public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
+               return new HTMLAnnotationHover() {
+                       @Override
+                       protected boolean isIncluded(Annotation annotation) {
+                               return isShowInVerticalRuler(annotation);
+                       }
+               };
+       }
+
+       /*
+        * @see SourceViewerConfiguration#getConfiguredTextHoverStateMasks(ISourceViewer, String)
+        * @since 2.1
+        */
+       @Override
+       public int[] getConfiguredTextHoverStateMasks(ISourceViewer sourceViewer, String contentType) {
+               CEditorTextHoverDescriptor[] hoverDescs= CUIPlugin.getDefault().getCEditorTextHoverDescriptors();
+               int stateMasks[]= new int[hoverDescs.length];
+               int stateMasksLength= 0;
+               for (CEditorTextHoverDescriptor hoverDesc : hoverDescs) {
+                       if (hoverDesc.isEnabled()) {
+                               int j= 0;
+                               int stateMask= hoverDesc.getStateMask();
+                               while (j < stateMasksLength) {
+                                       if (stateMasks[j] == stateMask)
+                                               break;
+                                       j++;
+                               }
+                               if (j == stateMasksLength)
+                                       stateMasks[stateMasksLength++]= stateMask;
+                       }
+               }
+               if (stateMasksLength == hoverDescs.length)
+                       return stateMasks;
+               
+               int[] shortenedStateMasks= new int[stateMasksLength];
+               System.arraycopy(stateMasks, 0, shortenedStateMasks, 0, stateMasksLength);
+               return shortenedStateMasks;
+       }
+       
+       /*
+        * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String, int)
+        * @since 2.1
+        */
+       @Override
+       public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) {
+               CEditorTextHoverDescriptor[] hoverDescs= CUIPlugin.getDefault().getCEditorTextHoverDescriptors();
+               int i= 0;
+               while (i < hoverDescs.length) {
+                       if (hoverDescs[i].isEnabled() &&  hoverDescs[i].getStateMask() == stateMask)
+                               return new CEditorTextHoverProxy(hoverDescs[i], getEditor());
+                       i++;
+               }
+
+               return null;
+       }
+
+       /*
+        * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String)
+        */
+       @Override
+       public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
+               return getTextHover(sourceViewer, contentType, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
+       }
+
+       /**
+        * @see SourceViewerConfiguration#getConfiguredContentTypes(ISourceViewer)
+        */
+       @Override
+       public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
+               return new String[] {
+                               IDocument.DEFAULT_CONTENT_TYPE,
+                               ICPartitions.C_MULTI_LINE_COMMENT,
+                               ICPartitions.C_SINGLE_LINE_COMMENT,
+                               ICPartitions.C_STRING,
+                               ICPartitions.C_CHARACTER,
+                               ICPartitions.C_PREPROCESSOR,
+                               ICPartitions.C_SINGLE_LINE_DOC_COMMENT,
+                               ICPartitions.C_MULTI_LINE_DOC_COMMENT
+               };
+       }
+       
+       /**
+        * @see SourceViewerConfiguration#getContentFormatter(ISourceViewer)
+        */
+       @Override
+       public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
+               
+               final MultiPassContentFormatter formatter =
+                       new MultiPassContentFormatter(getConfiguredDocumentPartitioning(sourceViewer),
+                               IDocument.DEFAULT_CONTENT_TYPE);
+               
+               formatter.setMasterStrategy(new CFormattingStrategy());
+               return formatter;
+       }
+       
+       public boolean affectsBehavior(PropertyChangeEvent event) {
+               if ((fMultilineDocCommentScanner != null && fMultilineDocCommentScanner.affectsBehavior(event))
+                       || (fSinglelineDocCommentScanner != null && fSinglelineDocCommentScanner.affectsBehavior(event))
+                       || fMultilineCommentScanner.affectsBehavior(event)
+                       || fSinglelineCommentScanner.affectsBehavior(event)
+                       || fStringScanner.affectsBehavior(event)) {
+                       return true;
+               }
+               if (fCodeScanner != null && fCodeScanner.affectsBehavior(event)) {
+                       return true;
+               }
+               if (fPreprocessorScanner != null && fPreprocessorScanner.affectsBehavior(event)) {
+                       return true;
+               }
+               return false;
+       }
+
+       /*
+        * @see SourceViewerConfiguration#getHoverControlCreator(ISourceViewer)
+        * @since 2.0
+        */
+       @Override
+       public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) {
+               return new IInformationControlCreator() {
+                       public IInformationControl createInformationControl(Shell parent) {
+                               return new DefaultInformationControl(parent, false);
+                       }
+               };
+       }
+
+       /**
+        * Returns the information presenter control creator. The creator is a factory creating the
+        * presenter controls for the given source viewer. This implementation always returns a creator
+        * for <code>DefaultInformationControl</code> instances.
+        *
+        * @param sourceViewer the source viewer to be configured by this configuration
+        * @return an information control creator
+        * @since 5.0
+        */
+       protected IInformationControlCreator getInformationPresenterControlCreator(ISourceViewer sourceViewer) {
+               return new IInformationControlCreator() {
+                       public IInformationControl createInformationControl(Shell parent) {
+                               return new DefaultInformationControl(parent, true);
+                       }
+               };
+       }
+
+       /*
+        * @see SourceViewerConfiguration#getInformationPresenter(ISourceViewer)
+        * @since 2.0
+        */
+       @Override
+       public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) {
+               InformationPresenter presenter= new InformationPresenter(getInformationPresenterControlCreator(sourceViewer));
+               presenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
+               
+               // Register information provider
+               IInformationProvider provider= new CInformationProvider(getEditor());
+               String[] contentTypes= getConfiguredContentTypes(sourceViewer);
+               for (String contentType : contentTypes)
+                       presenter.setInformationProvider(provider, contentType);
+               
+               presenter.setSizeConstraints(60, 10, true, true);
+               return presenter;
+       }
+    
+       /**
+        * Determines whether the preference change encoded by the given event
+        * changes the behavior of one of its contained components.
+        *
+        * @param event the event to be investigated
+        * @return <code>true</code> if event causes a behavioral change
+        */
+       public boolean affectsTextPresentation(PropertyChangeEvent event) {
+               return affectsBehavior(event);
+       }
+
+       /**
+        * Adapts the behavior of the contained components to the change
+        * encoded in the given event.
+        * <p>
+        * Clients are not allowed to call this method if the old setup with
+        * text tools is in use.
+        * </p>
+        *
+        * @param event the event to which to adapt
+        * @see CSourceViewerConfiguration#CSourceViewerConfiguration(IColorManager, IPreferenceStore, ITextEditor, String)
+        */
+       public void handlePropertyChangeEvent(PropertyChangeEvent event) {
+               if (fCodeScanner != null && fCodeScanner.affectsBehavior(event))
+                       fCodeScanner.adaptToPreferenceChange(event);
+               if (fMultilineDocCommentScanner!=null && fMultilineDocCommentScanner.affectsBehavior(event))
+                       fMultilineDocCommentScanner.adaptToPreferenceChange(event);
+               if (fSinglelineDocCommentScanner!=null && fSinglelineDocCommentScanner.affectsBehavior(event))
+                       fSinglelineDocCommentScanner.adaptToPreferenceChange(event);
+               if (fMultilineCommentScanner.affectsBehavior(event))
+                       fMultilineCommentScanner.adaptToPreferenceChange(event);
+               if (fSinglelineCommentScanner.affectsBehavior(event))
+                       fSinglelineCommentScanner.adaptToPreferenceChange(event);
+               if (fStringScanner.affectsBehavior(event))
+                       fStringScanner.adaptToPreferenceChange(event);
+               if (fPreprocessorScanner != null && fPreprocessorScanner.affectsBehavior(event))
+                       fPreprocessorScanner.adaptToPreferenceChange(event);
+       }
+
+       /*
+        * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getConfiguredDocumentPartitioning(org.eclipse.jface.text.source.ISourceViewer)
+        */
+       @Override
+       public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) {
+               if (fDocumentPartitioning != null)
+                       return fDocumentPartitioning;
+               return super.getConfiguredDocumentPartitioning(sourceViewer);
+       }
+
+       /**
+     * Creates control for outline presentation in editor.
+     * @return Control.
+     */
+    protected IInformationControlCreator getOutlineControlCreator() {
+        final IInformationControlCreator conrolCreator = new IInformationControlCreator() {
+            /**
+             * @see org.eclipse.jface.text.IInformationControlCreator#createInformationControl(org.eclipse.swt.widgets.Shell)
+             */
+            public IInformationControl createInformationControl(Shell parent) {
+                int shellStyle= SWT.RESIZE;
+                int treeStyle= SWT.V_SCROLL | SWT.H_SCROLL;
+                return new COutlineInformationControl(parent, shellStyle, treeStyle);
+            }
+        };
+        return conrolCreator;
+    }
+
+       /**
+     * Creates control for outline presentation in editor.
+     * @return Control.
+     */
+    protected IInformationControlCreator getHierarchyControlCreator() {
+        final IInformationControlCreator conrolCreator = new IInformationControlCreator() {
+            /**
+             * @see org.eclipse.jface.text.IInformationControlCreator#createInformationControl(org.eclipse.swt.widgets.Shell)
+             */
+            public IInformationControl createInformationControl(Shell parent) {
+                int shellStyle= SWT.RESIZE;
+                int treeStyle= SWT.V_SCROLL | SWT.H_SCROLL;
+                return new THInformationControl(parent, shellStyle, treeStyle);
+            }
+        };
+        return conrolCreator;
+    }
+
+       protected ILanguage getLanguage() {
+               if (fTextEditor == null) {
+                       return GPPLanguage.getDefault();
+               }
+               ICElement element = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(fTextEditor.getEditorInput());
+               if (element instanceof ITranslationUnit) {
+                       try {
+                               return ((ITranslationUnit)element).getLanguage();
+                       } catch (CoreException e) {
+                               CUIPlugin.log(e);
+                       }
+               } else {
+                       // compute the language from the plain editor input
+                       IContentType contentType = null;
+                       IEditorInput input = fTextEditor.getEditorInput();
+                       IFile file = ResourceUtil.getFile(input);
+                       if (file != null) {
+                               contentType = CCorePlugin.getContentType(file.getProject(), file.getName());
+                       } else if (input instanceof IPathEditorInput) {
+                               IPath path = ((IPathEditorInput)input).getPath();
+                               contentType = CCorePlugin.getContentType(path.lastSegment());
+                       } else {
+                               ILocationProvider locationProvider = (ILocationProvider)input.getAdapter(ILocationProvider.class);
+                               if (locationProvider != null) {
+                                       IPath path = locationProvider.getPath(input);
+                                       if (path != null) {
+                                               contentType = CCorePlugin.getContentType(path.lastSegment());
+                                       }
+                               }
+                       }
+                       if (contentType != null) {
+                               return LanguageManager.getInstance().getLanguage(contentType);
+                       }
+               }
+               // fallback
+               return GPPLanguage.getDefault();
+       }
+       
+       /**
+        * Reset cached language dependent scanners.
+        */
+       public void resetScanners() {
+               fCodeScanner= null;
+               fMultilineDocCommentScanner= null;
+               fSinglelineDocCommentScanner= null;
+               fPreprocessorScanner= null;
+       }
+       
+       /**
+        * Creates macro exploration presenter.
+        * @param sourceViewer
+        * @return Presenter with macro exploration view.
+        * 
+        * @since 5.0
+        */
+       public IInformationPresenter getMacroExplorationPresenter(ISourceViewer sourceViewer) {
+        final IInformationControlCreator controlCreator= getMacroExplorationControlCreator();
+        final InformationPresenter presenter = new InformationPresenter(controlCreator);
+        presenter.setRestoreInformationControlBounds(getDialogSettings(CMacroExpansionExplorationControl.KEY_CONTROL_BOUNDS), true, true);
+        presenter.setSizeConstraints(320, 120, true, false);
+        presenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
+               presenter.setAnchor(AbstractInformationControlManager.ANCHOR_GLOBAL);
+               final IInformationProvider provider = new CMacroExpansionInformationProvider(getEditor());
+               String[] contentTypes= getConfiguredContentTypes(sourceViewer);
+               for (int i= 0; i < contentTypes.length; i++)
+                       presenter.setInformationProvider(provider, contentTypes[i]);
+        presenter.setSizeConstraints(50, 20, true, false);
+        return presenter;
+       }
+
+       protected IDialogSettings getDialogSettings(String sectionName) {
+               if (sectionName == null) {
+                       return null;
+               }
+               IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings().getSection(sectionName);
+               if (settings == null) {
+                       settings= CUIPlugin.getDefault().getDialogSettings().addNewSection(sectionName);
+               }
+               return settings;
+       }
+       
+       /**
+     * Creates control for macro exploration in editor.
+     * @return Control.
+     */
+    protected IInformationControlCreator getMacroExplorationControlCreator() {
+        final IInformationControlCreator conrolCreator = new IInformationControlCreator() {
+            public IInformationControl createInformationControl(Shell parent) {
+                return new CMacroExpansionExplorationControl(parent);
+            }
+        };
+        return conrolCreator;
+    }
+       
+    /**
+        * @return the IProject associated with this CSourceViewerConfiguration, or null if
+        * no IProject could be determined
+        */
+       protected IProject getProject() {
+               ICProject cproject= getCProject();
+               return cproject!=null ? cproject.getProject() :null;
+       }
+
+       protected ITokenStoreFactory getTokenStoreFactory() {
+               return new ITokenStoreFactory() {
+                       public ITokenStore createTokenStore(String[] propertyColorNames) {
+                               return new TokenStore(getColorManager(), fPreferenceStore, propertyColorNames);
+                       }
+               };
+       }
+
+       /*
+        * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getHyperlinkDetectorTargets(org.eclipse.jface.text.source.ISourceViewer)
+        */
+       @Override
+       protected Map<String, IAdaptable> getHyperlinkDetectorTargets(ISourceViewer sourceViewer) {
+               @SuppressWarnings("unchecked")
+               Map<String, IAdaptable> targets= super.getHyperlinkDetectorTargets(sourceViewer);
+               targets.put("org.eclipse.cdt.ui.cCode", fTextEditor); //$NON-NLS-1$
+               return targets;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICColorConstants.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICColorConstants.java
new file mode 100644 (file)
index 0000000..9ba6363
--- /dev/null
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     IBM Corporation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text;
+
+
+/**
+ * Color keys used for syntax highlighting C/C++ and Assembly code
+ * A <code>IColorManager</code> is responsible for mapping
+ * concrete colors to these keys.
+ * <p>
+ * This interface declares static final fields only; it is not intended to be
+ * implemented.
+ * </p>
+ * @see org.eclipse.cdt.ui.text.IColorManager
+ * 
+ * @since 5.1
+ *
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
+ */
+public interface ICColorConstants {
+       /** The color key for multi-line comments in C code. */
+       String C_MULTI_LINE_COMMENT= "c_multi_line_comment"; //$NON-NLS-1$
+       /** The color key for single-line comments in C code. */
+       String C_SINGLE_LINE_COMMENT= "c_single_line_comment"; //$NON-NLS-1$
+       /** The color key for keywords in C code. */
+       String C_KEYWORD= "c_keyword"; //$NON-NLS-1$
+       /** The color key for builtin types in C code. */
+       String C_TYPE= "c_type"; //$NON-NLS-1$
+       /** The color key for string and character literals in C code. */
+       String C_STRING= "c_string"; //$NON-NLS-1$
+    /** The color key for operators. */
+    String C_OPERATOR= "c_operators"; //$NON-NLS-1$
+    /** The color key for braces. */
+    String C_BRACES= "c_braces"; //$NON-NLS-1$
+    /** The color key for numbers. */
+    String C_NUMBER= "c_numbers"; //$NON-NLS-1$
+    /** The color key for everthing in C code for which no other color is specified. */
+       String C_DEFAULT= "c_default"; //$NON-NLS-1$
+
+       /** The color key for preprocessor directives. */
+       String PP_DIRECTIVE= "pp_directive"; //$NON-NLS-1$
+       /** The color key for preprocessor text not colored otherwise. */
+       String PP_DEFAULT= "pp_default"; //$NON-NLS-1$
+    /** The color key for preprocessor include files. */
+    String PP_HEADER= "pp_header"; //$NON-NLS-1$
+
+       /** The color key for keywords in assembly code. */
+       String ASM_DIRECTIVE= "asm_directive"; //$NON-NLS-1$
+    /** The color key for assembly labels. */
+    String ASM_LABEL= "asm_label"; //$NON-NLS-1$
+
+    /**
+     * The color key for task tags in C comments
+     * (value <code>"c_comment_task_tag"</code>).
+     */
+    String TASK_TAG= "c_comment_task_tag"; //$NON-NLS-1$
+}
+
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICCompletionProposal.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICCompletionProposal.java
new file mode 100644 (file)
index 0000000..ce4368d
--- /dev/null
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.cdt.ui.text;
+
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+
+/**
+ * CompletionProposal with a relevance value.
+ * The relevance value is used to sort the completion proposals. Proposals with higher relevance
+ * should be listed before proposals with lower relevance.
+ * <p>
+ * This interface can be implemented by clients.
+ * </p>
+ */
+public interface ICCompletionProposal extends ICompletionProposal {
+       
+       /**
+        * Returns the relevance of the proposal.
+        */
+       int getRelevance();
+
+    /**
+     * Returns an id string that uniquely identifies this proposal. For most things this is the
+     * same as the display name. For functions, this strips off the parameter names and the
+     * return type.
+     * 
+     * @return the string that uniquely identifies this proposal
+     */
+    String getIdString();
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICHelpInvocationContext.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICHelpInvocationContext.java
new file mode 100644 (file)
index 0000000..b498f0b
--- /dev/null
@@ -0,0 +1,38 @@
+/**********************************************************************
+ * Copyright (c) 2004, 2009 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *     Intel Corporation - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.ui.text;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.core.resources.IProject;
+
+/**
+ * Invocation context for the CHelpProviderManager.
+ * 
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * 
+ * @see IHoverHelpInvocationContext
+ * @see IContentAssistHelpInvocationContext
+ */
+public interface ICHelpInvocationContext {
+       
+       /**
+        * @return the project
+        */
+       IProject getProject();
+
+       /**
+        * @return ITranslationUnit or null
+        */
+       ITranslationUnit getTranslationUnit();
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICPartitions.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICPartitions.java
new file mode 100644 (file)
index 0000000..d315f4b
--- /dev/null
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Andrew Ferguson (Symbian)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text;
+
+/**
+ * Definition of C partitioning and its partitions.
+ * 
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @since 4.0
+ */
+public interface ICPartitions {
+
+       /**
+        * The identifier of the C partitioning.
+        */
+       String C_PARTITIONING= "___c_partitioning";  //$NON-NLS-1$
+
+       /**
+        * The identifier of the single-line comment partition content type.
+        */
+       String C_SINGLE_LINE_COMMENT= "__c_singleline_comment"; //$NON-NLS-1$
+
+       /**
+        * The identifier multi-line comment partition content type.
+        */
+       String C_MULTI_LINE_COMMENT= "__c_multiline_comment"; //$NON-NLS-1$
+
+       /**
+        * The identifier of the C string partition content type.
+        */
+       String C_STRING= "__c_string"; //$NON-NLS-1$
+
+       /**
+        * The identifier of the C character partition content type.
+        */
+       String C_CHARACTER= "__c_character";  //$NON-NLS-1$
+
+       /**
+        * The identifier of the C preprocessor partition content type.
+        */
+       String C_PREPROCESSOR= "__c_preprocessor";  //$NON-NLS-1$
+       
+       /**
+        * The identifier of the single-line documentation tool comment partition content type.
+     * @since 5.0
+        */
+       String C_SINGLE_LINE_DOC_COMMENT= "__c_singleline_doc_comment"; //$NON-NLS-1$
+
+       /**
+        * The identifier multi-line comment documentation tool partition content type.
+     * @since 5.0
+        */
+       String C_MULTI_LINE_DOC_COMMENT= "__c_multiline_doc_comment"; //$NON-NLS-1$
+       
+       /**
+        * All defined CDT editor partitions.
+        * @since 5.0
+        */
+       String[] ALL_CPARTITIONS= {
+                       ICPartitions.C_MULTI_LINE_COMMENT,
+                       ICPartitions.C_SINGLE_LINE_COMMENT,
+                       ICPartitions.C_STRING,
+                       ICPartitions.C_CHARACTER,
+                       ICPartitions.C_PREPROCESSOR,
+                       ICPartitions.C_SINGLE_LINE_DOC_COMMENT,
+                       ICPartitions.C_MULTI_LINE_DOC_COMMENT
+       };
+       
+       /**
+        * Array of all assembly partitions.
+        * @since 5.1
+        */
+       String[] ALL_ASM_PARTITIONS= new String[] {
+                       ICPartitions.C_MULTI_LINE_COMMENT,
+                       ICPartitions.C_SINGLE_LINE_COMMENT,
+                       ICPartitions.C_STRING,
+                       ICPartitions.C_CHARACTER,
+                       ICPartitions.C_PREPROCESSOR
+       };
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICTokenScanner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ICTokenScanner.java
new file mode 100644 (file)
index 0000000..ca28dcb
--- /dev/null
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text;
+
+import org.eclipse.jface.text.rules.ITokenScanner;
+import org.eclipse.cdt.ui.IPropertyChangeParticipant;
+
+/**
+ * Interface for CDT Scanners. Scanners used in CDT must additionally be
+ * IPropertyChangeParticipant's.
+ * <p>
+ * Clients may implement this interface.
+ * </p>
+ *
+ * @since 5.0
+ */
+public interface ICTokenScanner extends ITokenScanner, IPropertyChangeParticipant {
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IColorManager.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IColorManager.java
new file mode 100644 (file)
index 0000000..0cd0879
--- /dev/null
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text;
+
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+
+
+
+/**
+ * Manages SWT color objects for the given color keys and
+ * given <code>RGB</code> objects. Until the <code>dispose</code>
+ * method is called, the same color object is returned for
+ * equal keys and equal <code>RGB</code> values.
+ *
+ * <p>
+ * This interface may be implemented by clients.
+ * </p>
+ *
+ * @see org.eclipse.cdt.ui.text.ICColorConstants
+ * 
+ * @since 5.1
+ */
+public interface IColorManager {
+       
+       /**
+        * Returns a color object for the given key. The color objects 
+        * are remembered internally; the same color object is returned 
+        * for equal keys.
+        *
+        * @param key the color key
+        * @return the color object for the given key
+        */
+       Color getColor(String key);
+       
+       /**
+        * Returns the color object for the value represented by the given
+        * <code>RGB</code> object.
+        *
+        * @param rgb the rgb color specification
+        * @return the color object for the given rgb value
+        */
+       Color getColor(RGB rgb);        
+       
+       /**
+        * Disposes all color objects remembered by this color manager.
+        */
+       void dispose();
+
+       /**
+        * Remembers the given color specification under the given key.
+        *
+        * @param key the color key
+        * @param rgb the color specification
+        * @throws UnsupportedOperationException if there is already a
+        *      color specification remembered under the given key
+        */
+       void bindColor(String key, RGB rgb);
+       
+       
+       /**
+        * Forgets the color specification remembered under the given key.
+        * @param key the color key
+        */
+       void unbindColor(String key);
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IContentAssistHelpInvocationContext.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IContentAssistHelpInvocationContext.java
new file mode 100644 (file)
index 0000000..95c5560
--- /dev/null
@@ -0,0 +1,35 @@
+/**********************************************************************
+ * Copyright (c) 2009 Red Hat Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *     Red Hat Inc. - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.ui.text;
+
+import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
+
+/**
+ * Invocation context for content assist.
+ * 
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @since 5.1
+ */
+public interface IContentAssistHelpInvocationContext extends ICHelpInvocationContext {
+       
+       /**
+        * @return the offset of the content assist.
+        */
+       int getInvocationOffset();
+       
+       /**
+        * @return the AST completion node or null.
+        */
+       IASTCompletionNode getCompletionNode();
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IHoverHelpInvocationContext.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IHoverHelpInvocationContext.java
new file mode 100644 (file)
index 0000000..351ec1b
--- /dev/null
@@ -0,0 +1,30 @@
+/**********************************************************************
+ * Copyright (c) 2009 Red Hat Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors: 
+ *     Red Hat Inc. - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.ui.text;
+
+import org.eclipse.jface.text.IRegion;
+
+/**
+ * Invocation context for the CHelpProviderManager.
+ * 
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @since 5.1
+ */
+public interface IHoverHelpInvocationContext extends ICHelpInvocationContext {
+       
+       /**
+        * @return the hover region or null
+        */
+       IRegion getHoverRegion();
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IInvocationContext.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IInvocationContext.java
new file mode 100644 (file)
index 0000000..b1355c7
--- /dev/null
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2008 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+/**
+ * Context information for quick fix and quick assist processors.
+ * <p>
+ * Note: this interface is not intended to be implemented.
+ * </p>
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
+ */
+public interface IInvocationContext {
+       /**
+        * @return Returns the offset of the current selection
+        */
+       int getSelectionOffset();
+
+       /**
+        * @return Returns the length of the current selection
+        */
+       int getSelectionLength();
+       
+       /**
+        * @return ITranslationUnit or null
+        */
+       ITranslationUnit getTranslationUnit();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IProblemLocation.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IProblemLocation.java
new file mode 100644 (file)
index 0000000..9854199
--- /dev/null
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2008 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text;
+
+/**
+ * Problem information for quick fix and quick assist processors.
+ * 
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
+ */
+public interface IProblemLocation {
+       /**
+        * Returns the start offset of the problem.
+        *
+        * @return the start offset of the problem
+        */
+       int getOffset();
+
+       /**
+        * Returns the length of the problem.
+        *
+        * @return the length of the problem
+        */
+       int getLength();
+
+       /**
+        * Returns the marker type of this problem.
+        *
+        * @return The marker type of the problem.
+        */
+       String getMarkerType();
+       
+       /**
+        * Returns the id of problem. Note that problem ids are defined per problem marker type.
+        *
+        * @return The id of the problem.
+        */
+       int getProblemId();
+
+       /**
+        * Returns the original arguments recorded into the problem.
+        *
+        * @return String[] Returns the problem arguments.
+        */
+       String[] getProblemArguments();
+
+       /**
+        * Returns if the problem has error severity.
+        *
+        * @return <code>true</code> if the problem has error severity
+        */
+       boolean isError();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IQuickAssistProcessor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IQuickAssistProcessor.java
new file mode 100644 (file)
index 0000000..91a6b95
--- /dev/null
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2008 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text;
+
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * Interface to be implemented by contributors to the extension point
+ * <code>org.eclipse.cdt.ui.quickAssistProcessors</code>.
+ *
+ * @since 5.1
+ */
+public interface IQuickAssistProcessor {
+
+       /**
+        * Evaluates if quick assists can be created for the given context. This evaluation must be precise.
+        *
+        * @param context The invocation context
+        * @return Returns <code>true</code> if quick assists can be created
+        * @throws CoreException CoreException can be thrown if the operation fails
+        */
+       boolean hasAssists(IInvocationContext context) throws CoreException;
+
+       /**
+        * Collects quick assists for the given context.
+        *
+        * @param context Defines current translation unit, position and a shared AST
+        * @param locations The locations of problems at the invocation offset. The processor can decide to only
+        *                      add assists when there are no errors at the selection offset.
+        * @return Returns the assists applicable at the location or <code>null</code> if no proposals
+        *                      can be offered.
+        * @throws CoreException CoreException can be thrown if the operation fails
+        */
+       ICCompletionProposal[] getAssists(IInvocationContext context, IProblemLocation[] locations) throws CoreException;
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IQuickFixProcessor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/IQuickFixProcessor.java
new file mode 100644 (file)
index 0000000..ecf71e0
--- /dev/null
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text;
+
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+/**
+ * Interface to be implemented by contributors to the extension point
+ * <code>org.eclipse.cdt.ui.quickFixProcessors</code>.
+ * 
+ * @since 5.0
+ */
+public interface IQuickFixProcessor {
+       /**
+        * Returns <code>true</code> if the processor has proposals for the given problem. This test should be an
+        * optimistic guess and be very cheap.
+        *
+        * @param unit the compilation unit
+        * @param problemId the problem Id. The id is of a problem of the problem type(s) this processor specified in
+        * the extension point.
+        * @return <code>true</code> if the processor has proposals for the given problem
+        */
+       boolean hasCorrections(ITranslationUnit unit, int problemId);
+
+       /**
+        * Collects corrections or code manipulations for the given context.
+        *
+        * @param context Defines current compilation unit, position and a shared AST
+        * @param locations Problems are the current location.
+        * @return the corrections applicable at the location or <code>null</code> if no proposals
+        *                      can be offered
+        * @throws CoreException CoreException can be thrown if the operation fails
+        */
+       ICCompletionProposal[] getCorrections(IInvocationContext context,
+                       IProblemLocation[] locations) throws CoreException;
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ITokenStore.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ITokenStore.java
new file mode 100644 (file)
index 0000000..63b9d34
--- /dev/null
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.rules.IToken;
+
+import org.eclipse.cdt.ui.IPropertyChangeParticipant;
+import org.eclipse.cdt.ui.PreferenceConstants;
+
+/**
+ * An ITokenStore manages a set of tokens for a specified set of color property identifiers. Responsibilities include
+ * <ul>
+ * <li> Reacting to changes to preferences in a specified {@link IPreferenceStore}
+ * <li> Managing whether further styles (bold, italic, strikethrough, underline) should be applied
+ * <li> Coping with 
+ * </ul>
+ * 
+ * ITokenStore assumes style preferences are stored under the following names
+ * <p>
+ * Preference color key + {@link PreferenceConstants#EDITOR_BOLD_SUFFIX} are used
+ * to retrieve whether the token is rendered in bold.
+ * </p>
+ * <p>
+ * Preference color key + {@link PreferenceConstants#EDITOR_ITALIC_SUFFIX} are used
+ * to retrieve whether the token is rendered in italic.
+ * </p>
+ * <p>
+ * Preference color key + {@link PreferenceConstants#EDITOR_STRIKETHROUGH_SUFFIX} are used
+ * to retrieve whether the token is rendered in strikethrough.
+ * </p>
+ * <p>
+ * Preference color key + {@link PreferenceConstants#EDITOR_UNDERLINE_SUFFIX} are used
+ * to retrieve whether the token is rendered in underline.
+ * </p>
+ * <p>
+ * Clients may implement this interface.
+ * </p>
+ *
+ * @see ITokenStoreFactory
+ * @since 5.0
+ */
+public interface ITokenStore extends IPropertyChangeParticipant {
+       /**
+        * Ensures any IToken objects that will be <em>or have been</em> returned are
+     * initialized for display.
+        */
+       void ensureTokensInitialised();
+       
+       /**
+        * @param property
+        * @return a token for the specified property. The Token may not be suitable for use if the
+        * current Display is null. Clients should call ITokenStoreFactory#ensureTokensInitialised() at the
+        * point of token use in case this token store was originally initialized before a display was available.
+        */
+       IToken getToken(String property);
+       
+       /**
+        * @return The preference store used to read token styling preferences from.
+        */
+       IPreferenceStore getPreferenceStore();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ITokenStoreFactory.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/ITokenStoreFactory.java
new file mode 100644 (file)
index 0000000..edb1cb0
--- /dev/null
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text;
+
+/**
+ * A means of obtaining ITokenStore objects.
+ * <p>
+ * Clients may implement this interface.
+ * </p>
+ * @since 5.0
+ */
+public interface ITokenStoreFactory {
+       /**
+        * @param propertyColorNames
+        * @return a token store object initialized with the specified propertyColorNames
+        */
+       public ITokenStore createTokenStore(String[] propertyColorNames);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/SharedASTJob.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/SharedASTJob.java
new file mode 100644 (file)
index 0000000..befb5f0
--- /dev/null
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
+
+import org.eclipse.cdt.internal.ui.editor.ASTProvider;
+
+/**
+ * A Job specialized to give access to the shared AST of the currently active editor.
+ * Clients must implement {@link #runOnAST(ILanguage, IASTTranslationUnit)}.
+ * 
+ * @since 5.1
+ */
+public abstract class SharedASTJob extends Job {
+
+       /**
+        * The translation unit for which to access the AST.
+        */
+       protected final ITranslationUnit fUnit;
+
+       /**
+        * Create a shared AST job for the given translation unit.
+        * 
+        * @param name  the display name of this job
+        * @param tUnit  the translation unit to get the AST for
+        */
+       public SharedASTJob(String name, ITranslationUnit tUnit) {
+               super(name);
+               fUnit = tUnit;
+       }
+
+       /**
+        * Run an operation on the shared AST of the requested translation unit.
+        * This method will only be called if the requested translation unit is open 
+        * in the currently active editor. 
+        * 
+        * @param lang  the associated <code>ILanguage</code> of the translation unit
+        * @param ast  the AST object of the translation unit or <code>null</code>
+        * @return A <code>Status</code> object reflecting the result of the operation
+        * @throws CoreException
+        */
+       public abstract IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException;
+
+       @Override
+       protected final IStatus run(IProgressMonitor monitor) {
+               ASTProvider provider = CUIPlugin.getDefault().getASTProvider();
+               if (provider == null) {
+                       return Status.CANCEL_STATUS;
+               }
+               return provider.runOnAST(fUnit, ASTProvider.WAIT_ACTIVE_ONLY, monitor, new ASTRunnable() {
+                       public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
+                               return SharedASTJob.this.runOnAST(lang, ast);
+                       }});
+       }
+
+    @Override
+       public boolean shouldSchedule() {
+        return super.shouldSchedule() && PlatformUI.isWorkbenchRunning() && CUIPlugin.getDefault() != null;
+    }
+
+    @Override
+       public boolean shouldRun() {
+        return super.shouldRun() && PlatformUI.isWorkbenchRunning() && CUIPlugin.getDefault() != null;
+    }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/TaskTagRule.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/TaskTagRule.java
new file mode 100644 (file)
index 0000000..c4809a4
--- /dev/null
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ *  Copyright (c) 2000, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Sergey Prigogin  (Google)
+ *     Andrew Ferguson  (Symbian)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text;
+
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.IWordDetector;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.jface.text.rules.WordRule;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+import org.eclipse.cdt.core.CCorePreferenceConstants;
+import org.eclipse.cdt.ui.IPropertyChangeParticipant;
+
+/**
+ * Which words should be recognized as task tags is specified under {@link CCorePreferenceConstants#TODO_TASK_TAGS} as a
+ * comma delimited list.
+ * 
+ * @see CCorePreferenceConstants#TODO_TASK_TAGS
+ * @since 5.0
+ * @deprecated This class doesn't properly implement parsing of task tags
+ * (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=246846). It will be removed.
+ */
+@Deprecated
+public final class TaskTagRule extends WordRule implements IPropertyChangeParticipant {        
+       private static class TaskTagDetector implements IWordDetector {
+               public boolean isWordStart(char c) {
+                       return Character.isLetter(c);
+               }
+               public boolean isWordPart(char c) {
+                       return Character.isLetter(c);
+               }
+       }
+
+       /**
+        * Convenience method for extracting a list of words that should be recognized as 
+        * task labels from an {@link IPreferenceStore} and a backup {@link Preferences}
+        * @param preferenceStore
+        * @param corePreferences
+        * @return a list of words that should be recognized as task labels in the format
+        * expected by TaskTagRule
+        */
+       public static String getTaskWords(IPreferenceStore preferenceStore, Preferences corePreferences) {
+               String result= null;
+               if (preferenceStore.contains(CCorePreferenceConstants.TODO_TASK_TAGS)) {
+                       result= preferenceStore.getString(CCorePreferenceConstants.TODO_TASK_TAGS);
+               } else if (corePreferences != null) {
+                       result= corePreferences.getString(CCorePreferenceConstants.TODO_TASK_TAGS);
+               }
+               return result;
+       }
+
+       private IToken fToken;
+
+       /**
+        * Creates a new task tag rule
+        * @param token the token to return for words recognized as task tags
+        * @param taskWords a comma delimited list of words to recognize as task tags
+        */
+       public TaskTagRule(IToken token, String taskWords) {
+               super(new TaskTagDetector(), Token.UNDEFINED);
+               fToken= token;
+               if( taskWords!= null) {
+                       addTaskTags(taskWords);
+               }
+       }
+
+       /**
+        * Removes the current list of words that should be
+        * recognized as task tags.
+        */
+       public void clearTaskTags() {
+               fWords.clear();
+       }
+
+       /**
+        * Adds tags from the specified string as task tags.
+        * @param value a comma delimited list of words to recognize as task tags
+        */
+       public void addTaskTags(String value) {
+               String[] tasks= value.split(","); //$NON-NLS-1$
+               for (int i= 0; i < tasks.length; i++) {
+                       if (tasks[i].length() > 0) {
+                               addWord(tasks[i], fToken);
+                       }
+               }
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.IPropertyChangeParticipant#affectsBehavior(org.eclipse.jface.util.PropertyChangeEvent)
+        */
+       public boolean affectsBehavior(PropertyChangeEvent event) {
+               return event.getProperty().equals(CCorePreferenceConstants.TODO_TASK_TAGS);
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.IPropertyChangeParticipant#adaptToPreferenceChange(org.eclipse.jface.util.PropertyChangeEvent)
+        */
+       public void adaptToPreferenceChange(PropertyChangeEvent event) {
+               if (event.getProperty().equals(CCorePreferenceConstants.TODO_TASK_TAGS)) {
+                       Object value= event.getNewValue();
+
+                       if (value instanceof String) {
+                               clearTaskTags();
+                               addTaskTags((String) value);
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/c/hover/ICEditorTextHover.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/c/hover/ICEditorTextHover.java
new file mode 100644 (file)
index 0000000..3a2ad66
--- /dev/null
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui.text.c.hover;
+
+import org.eclipse.jface.text.ITextHover;
+import org.eclipse.ui.IEditorPart;
+
+/**
+ * Interface to be implemented by contributors to extension point
+ * "org.eclipse.cdt.ui.textHovers". Provides a hover popup which appears on top
+ * of an editor with relevant display information. If the text hover does not
+ * provide information no hover popup is shown.
+ * <p>
+ * Clients may implement this interface.
+ * </p>
+ */
+public interface ICEditorTextHover extends ITextHover {
+
+       /**
+        * Sets the editor on which the hover is shown.
+        * 
+        * @param editor the editor on which the hover popup should be shown
+        */
+       void setEditor(IEditorPart editor);
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ContentAssistInvocationContext.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ContentAssistInvocationContext.java
new file mode 100644 (file)
index 0000000..cfcdb25
--- /dev/null
@@ -0,0 +1,205 @@
+/*******************************************************************************
+ *  Copyright (c) 2005, 2009 IBM Corporation and others.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ * 
+ *  Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *     Bryan Wilkinson (QNX)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text.contentassist;
+
+import org.eclipse.core.runtime.Assert;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextViewer;
+
+/**
+ * Describes the context of an invocation of content assist in a text viewer. The context knows the
+ * document, the invocation offset and can lazily compute the identifier prefix preceding the
+ * invocation offset. It may know the viewer.
+ * <p>
+ * Subclasses may add information to their environment. For example, source code editors may provide
+ * specific context information such as an AST.
+ * </p>
+ * <p>
+ * Clients may instantiate.
+ * </p>
+ * @noextend This class is not intended to be subclassed by clients.
+ * @since 4.0
+ */
+public class ContentAssistInvocationContext {
+       
+       /* state */
+       private final ITextViewer fViewer;
+       private final IDocument fDocument;
+       private final int fOffset;
+       
+       /* cached additional info */
+       private CharSequence fPrefix;
+       
+       /**
+        * Equivalent to
+        * {@linkplain #ContentAssistInvocationContext(ITextViewer, int) ContentAssistInvocationContext(viewer, viewer.getSelectedRange().x)}.
+        * 
+        * @param viewer the text viewer that content assist is invoked in
+        */
+       public ContentAssistInvocationContext(ITextViewer viewer) {
+               this(viewer, viewer.getSelectedRange().x);
+       }
+
+       /**
+        * Creates a new context for the given viewer and offset.
+        * 
+        * @param viewer the text viewer that content assist is invoked in
+        * @param offset the offset into the viewer's document where content assist is invoked at
+        */
+       public ContentAssistInvocationContext(ITextViewer viewer, int offset) {
+               Assert.isNotNull(viewer);
+               fViewer= viewer;
+               fDocument= null;
+               fOffset= offset;
+       }
+       
+       /**
+        * Creates a new context with no viewer or invocation offset set.
+        */
+       protected ContentAssistInvocationContext() {
+               fDocument= null;
+               fViewer= null;
+               fOffset= -1;
+       }
+       
+       /**
+        * Creates a new context for the given document and offset.
+        * 
+        * @param document the document that content assist is invoked in
+        * @param offset the offset into the document where content assist is invoked at
+        */
+       public ContentAssistInvocationContext(IDocument document, int offset) {
+               Assert.isNotNull(document);
+               Assert.isTrue(offset >= 0);
+               fViewer= null;
+               fDocument= document;
+               fOffset= offset;
+       }
+       
+       /**
+        * Returns the invocation offset.
+        * 
+        * @return the invocation offset
+        */
+       public final int getInvocationOffset() {
+               return fOffset;
+       }
+       
+       /**
+        * Returns the viewer, <code>null</code> if not available.
+        * 
+        * @return the viewer, possibly <code>null</code>
+        */
+       public final ITextViewer getViewer() {
+               return fViewer;
+       }
+       
+       /**
+        * Returns the document that content assist is invoked on, or <code>null</code> if not known.
+        * 
+        * @return the document or <code>null</code>
+        */
+       public IDocument getDocument() {
+               if (fDocument == null) {
+                       if (fViewer == null)
+                               return null;
+                       return fViewer.getDocument();
+               }
+               return fDocument;
+       }
+       
+       /**
+        * Computes the identifier (as specified by {@link Character#isJavaIdentifierPart(char)}) that
+        * immediately precedes the invocation offset.
+        * 
+        * @return the prefix preceding the content assist invocation offset, <code>null</code> if
+        *         there is no document
+        * @throws BadLocationException if accessing the document fails
+        */
+       public CharSequence computeIdentifierPrefix() throws BadLocationException {
+               if (fPrefix == null) {
+                       IDocument document= getDocument();
+                       if (document == null)
+                               return null;
+                       int end= getInvocationOffset();
+                       int start= end;
+                       while (--start >= 0) {
+                               if (!Character.isJavaIdentifierPart(document.getChar(start)))
+                                       break;
+                       }
+                       start++;
+                       fPrefix= document.get(start, end - start);
+               }
+               
+               return fPrefix;
+       }
+       
+       /**
+        * Called upon completion of the content assist. Used to free any resources
+        * used by the context.
+        */
+       public void dispose() {
+       }
+       
+       /**
+        * Invocation contexts are equal if they describe the same context and are of the same type.
+        * This implementation checks for <code>null</code> values and class equality. Subclasses
+        * should extend this method by adding checks for their context relevant fields (but not
+        * necessarily cached values).
+        * <p>
+        * Example:
+        * 
+        * <pre>
+        * class MyContext extends ContentAssistInvocationContext {
+        *      private final Object fState;
+        *      private Object fCachedInfo;
+        * 
+        *      ...
+        * 
+        *      public boolean equals(Object obj) {
+        *              if (!super.equals(obj))
+        *                      return false;
+        *              MyContext other= (MyContext) obj;
+        *              return fState.equals(other.fState);
+        *      }
+        * }
+        * </pre>
+        * 
+        * </p>
+        * <p>
+        * Subclasses should also extend {@link Object#hashCode()}.
+        * </p>
+        * 
+        * @param obj {@inheritDoc}
+        * @return {@inheritDoc}
+        */
+       @Override
+       public boolean equals(Object obj) {
+               if (obj == null)
+                       return false;
+               if (!getClass().equals(obj.getClass()))
+                       return false;
+               ContentAssistInvocationContext other= (ContentAssistInvocationContext) obj;
+               return (fViewer == null && other.fViewer == null || fViewer != null && fViewer.equals(other.fViewer)) && fOffset == other.fOffset && (fDocument == null && other.fDocument == null || fDocument != null && fDocument.equals(other.fDocument));
+       }
+       
+       /*
+        * @see java.lang.Object#hashCode()
+        */
+       @Override
+       public int hashCode() {
+               return 23459213 << 5 | (fViewer == null ? 0 : fViewer.hashCode() << 3) | fOffset;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICEditorContentAssistInvocationContext.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICEditorContentAssistInvocationContext.java
new file mode 100644 (file)
index 0000000..1b40daf
--- /dev/null
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text.contentassist;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.ui.IEditorPart;
+
+import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+
+/**
+ * Describes the context of a content assist invocation in a C/C++ editor.
+ * 
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface ICEditorContentAssistInvocationContext {
+
+       /**
+        * Returns the translation unit that content assist is invoked in, <code>null</code> if there
+        * is none.
+        * 
+        * @return the translation unit that content assist is invoked in, possibly <code>null</code>
+        */
+       ITranslationUnit getTranslationUnit();
+
+       /**
+        * Returns the project of the translation unit that content assist is invoked in,
+        * <code>null</code> if none.
+        * 
+        * @return the current C project, possibly <code>null</code>
+        */
+       ICProject getProject();
+
+       /**
+        * Returns the IASTCompletionNode of the location where content assist was invoked.
+        * @return the IASTCompletionNode of the location where context assist was invoked.
+        */
+       IASTCompletionNode getCompletionNode();
+
+       /**
+        * Returns the offset which was used to compute the IASTCompletionNode when content
+        * assist was invoked.
+        * @return the offset used to compute the IASTCompletionNode.
+        */
+       int getParseOffset();
+
+       /**
+        * Returns the offset where context information starts.
+        * @return the offset where context information (parameter hints) starts.
+        */
+       int getContextInformationOffset();
+
+       /**
+        * Get the editor content assist is invoked in.
+        * 
+        * @return the editor, may be <code>null</code>
+        */
+       IEditorPart getEditor();
+
+       /**
+        * Returns the viewer, <code>null</code> if not available.
+        * 
+        * @return the viewer, possibly <code>null</code>
+        */
+       ITextViewer getViewer();
+       
+       /**
+        * Returns the invocation offset.
+        * 
+        * @return the invocation offset
+        */
+       int getInvocationOffset();
+       
+       /**
+        * Returns <code>true</code> if the current content assist invocation
+        * is for revealing context information, or <code>false</code> otherwise.
+        * 
+        * @return <code>true</code> if the current content assist invocation
+        * is for revealing context information.
+        */
+       boolean isContextInformationStyle();
+       
+       /**
+        * Returns the document that content assist is invoked on, or <code>null</code> if not known.
+        * 
+        * @return the document or <code>null</code>
+        */
+       IDocument getDocument();
+       
+       /**
+        * Computes the identifier (as specified by {@link Character#isJavaIdentifierPart(char)}) that
+        * immediately precedes the invocation offset.
+        * 
+        * @return the prefix preceding the content assist invocation offset, <code>null</code> if
+        *         there is no document
+        * @throws BadLocationException if accessing the document fails
+        */
+       CharSequence computeIdentifierPrefix() throws BadLocationException;
+}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICompletionContributor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICompletionContributor.java
new file mode 100644 (file)
index 0000000..9bed2c9
--- /dev/null
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text.contentassist;
+
+import java.util.List;
+
+import org.eclipse.jface.text.ITextViewer;
+
+import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
+import org.eclipse.cdt.core.model.IWorkingCopy;
+
+/**
+ * This interface must be implemented by clients extending the extension point
+ * <tt>org.eclipse.cdt.core.completionContributors</tt>.
+ * 
+ * @deprecated Clients should extend the new extension point
+ *             <tt>completionProprosalComputer</tt> and implement interface
+ *             {@link ICompletionProposalComputer}
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+@Deprecated
+public interface ICompletionContributor {
+
+       /**
+        * This method allows the contributor to add to the list of proposals
+        * 
+        * @param viewer the text viewer where completion is occuring
+        * @param offset the offset into the text where the completion is occuring
+        * @param completionNode the completion node produced by the parser for the offset
+        * @param proposals the current list of proposals. This method should add any additional
+        * proposals to this list.
+        */
+       @SuppressWarnings("rawtypes") // no need to change, it's deprecated
+       void contributeCompletionProposals(ITextViewer viewer,
+                                                                          int offset,
+                                                                          IWorkingCopy workingCopy,
+                                                                          ASTCompletionNode completionNode,
+                                       String prefix,
+                                                                          List proposals);
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICompletionProposalComputer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICompletionProposalComputer.java
new file mode 100644 (file)
index 0000000..499afb6
--- /dev/null
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text.contentassist;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+
+/**
+ * Computes completions and context information displayed by the C/C++ editor content assistant.
+ * <p>
+ * Contributions to the <tt>org.eclipse.cdt.ui.completionProposalComputer</tt> extension point
+ * must implement this interface.
+ * </p>
+ * 
+ * @since 4.0
+ */
+public interface ICompletionProposalComputer {
+       /**
+        * Informs the computer that a content assist session has started. This call will always be
+        * followed by a {@link #sessionEnded()} call, but not necessarily by calls to
+        * {@linkplain #computeCompletionProposals(ContentAssistInvocationContext, IProgressMonitor) computeCompletionProposals}
+        * or
+        * {@linkplain #computeContextInformation(ContentAssistInvocationContext, IProgressMonitor) computeContextInformation}.
+        */
+       void sessionStarted();
+
+       /**
+        * Returns a list of completion proposals valid at the given invocation context.
+        * 
+        * @param context the context of the content assist invocation
+        * @param monitor a progress monitor to report progress. The monitor is private to this
+        *        invocation, i.e. there is no need for the receiver to spawn a sub monitor.
+        * @return a list of completion proposals (element type: {@link ICompletionProposal})
+        */
+       List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor);
+
+       /**
+        * Returns context information objects valid at the given invocation context.
+        * 
+        * @param context the context of the content assist invocation
+        * @param monitor a progress monitor to report progress. The monitor is private to this
+        *        invocation, i.e. there is no need for the receiver to spawn a sub monitor.
+        * @return a list of context information objects (element type: {@link IContextInformation})
+        */
+       List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor);
+
+       /**
+        * Returns the reason why this computer was unable to produce any completion proposals or
+        * context information.
+        * 
+        * @return an error message or <code>null</code> if no error occurred
+        */
+       String getErrorMessage();
+
+       /**
+        * Informs the computer that a content assist session has ended. This call will always be after
+        * any calls to
+        * {@linkplain #computeCompletionProposals(ContentAssistInvocationContext, IProgressMonitor) computeCompletionProposals}
+        * and
+        * {@linkplain #computeContextInformation(ContentAssistInvocationContext, IProgressMonitor) computeContextInformation}.
+        */
+       void sessionEnded();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/IProposalFilter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/IProposalFilter.java
new file mode 100644 (file)
index 0000000..461f6bc
--- /dev/null
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 Norbert Ploett and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Norbert Ploett (Siemens) - Initial Contribution
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text.contentassist;
+
+import org.eclipse.cdt.ui.text.ICCompletionProposal;
+
+
+/**
+ * Filters completion proposals displayed by the C/C++ editor content assistant.
+ * <p>
+ * Contributions to the <tt>org.eclipse.cdt.ui.ProposalFilter</tt> extension point
+ * must implement this interface.
+ * </p>
+ */
+public interface IProposalFilter {
+
+       /**
+        * Filter a list of ICCompletionProposals <br>
+        * - Change the order of entries <br>
+        * - Remove undesired (duplicate) entries <br>
+        * - Supplement existing entries with additional information
+        * @param proposals The List of proposals
+        * @return The filtered list of proposals as array
+        */
+       ICCompletionProposal[] filterProposals(ICCompletionProposal[] proposals) ;
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/DefaultMultilineCommentAutoEditStrategy.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/DefaultMultilineCommentAutoEditStrategy.java
new file mode 100644 (file)
index 0000000..82ce3ae
--- /dev/null
@@ -0,0 +1,421 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Andrew Ferguson (Symbian) - Initial implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text.doctools;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.StringReader;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DocumentCommand;
+import org.eclipse.jface.text.DocumentRewriteSession;
+import org.eclipse.jface.text.DocumentRewriteSessionType;
+import org.eclipse.jface.text.IAutoEditStrategy;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentExtension4;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.cdt.core.dom.ast.ASTVisitor;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTNode;
+import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
+import org.eclipse.cdt.core.dom.ast.IASTNodeSelector;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.IWorkingCopyManager;
+import org.eclipse.cdt.ui.text.ICPartitions;
+
+/**
+ * This class provides default behaviors for multi-line comment auto-editing.
+ * 
+ * This class is intended to be sub-classed.
+ * 
+ * @since 5.0
+ */
+public class DefaultMultilineCommentAutoEditStrategy implements IAutoEditStrategy {
+       protected static final String MULTILINE_START = "/*"; //$NON-NLS-1$#
+       protected static final String MULTILINE_MID = " * "; //$NON-NLS-1$
+       protected static final String MULTILINE_END = "*/"; //$NON-NLS-1$
+       private static String fgDefaultLineDelim = "\n"; //$NON-NLS-1$
+       
+       public DefaultMultilineCommentAutoEditStrategy() {
+       }
+       
+       /**
+        * @see org.eclipse.jface.text.IAutoEditStrategy#customizeDocumentCommand(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.DocumentCommand)
+        */
+       public void customizeDocumentCommand(IDocument doc, DocumentCommand cmd) {
+               fgDefaultLineDelim = TextUtilities.getDefaultLineDelimiter(doc);
+               if (doc instanceof IDocumentExtension4) {
+                       boolean forNewLine= cmd.length == 0 && cmd.text != null && endsWithDelimiter(doc, cmd.text);
+                       boolean forCommentEnd= "/".equals(cmd.text); //$NON-NLS-1$
+                       
+                       if (forNewLine || forCommentEnd) {
+                               IDocumentExtension4 ext4= (IDocumentExtension4) doc;
+                               DocumentRewriteSession drs= ext4.startRewriteSession(DocumentRewriteSessionType.UNRESTRICTED_SMALL);
+                               try {
+                                       if (forNewLine) {
+                                               customizeDocumentAfterNewLine(doc, cmd);
+                                       } else if (forCommentEnd) {
+                                               customizeDocumentForMultilineCommentEnd(doc, cmd);
+                                       }
+                               } finally {
+                                       ext4.stopRewriteSession(drs);
+                               }
+                       }
+               }
+       }
+       
+       /**
+        * This implements a rule that when in a multi-line comment context typing a forward slash with
+        * one white space after the "*" will move eliminate the whitespace.
+        * @param doc
+        * @param command
+        */
+       protected void customizeDocumentForMultilineCommentEnd(IDocument doc, DocumentCommand command) {
+               if (command.offset < 2 || doc.getLength() == 0) {
+                       return;
+               }
+               try {
+                       if ("* ".equals(doc.get(command.offset - 2, 2))) { //$NON-NLS-1$
+                               // modify document command
+                               command.length++;
+                               command.offset--;
+                       }                                       
+               } catch (BadLocationException excp) {
+                       // stop work
+               }
+       }
+       
+       /**
+        * Copies the indentation of the previous line and adds a star.
+        * If the comment just started on this line adds also a blank.
+        *
+        * @param doc the document to work on
+        * @param c the command to deal with
+        */
+       public void customizeDocumentAfterNewLine(IDocument doc, final DocumentCommand c) {
+               int offset= c.offset;
+               if (offset == -1 || doc.getLength() == 0)
+                       return;
+               
+               String lineDelim = TextUtilities.getDefaultLineDelimiter(doc);
+               final StringBuilder buf= new StringBuilder(c.text);
+               try {
+                       // find start of line
+                       IRegion line= doc.getLineInformationOfOffset(c.offset);
+                       int lineStart= line.getOffset();
+                       int firstNonWS= findEndOfWhiteSpaceAt(doc, lineStart, c.offset);
+
+                       IRegion prefix= findPrefixRange(doc, line);
+                       String indentation= doc.get(prefix.getOffset(), prefix.getLength());
+                       int lengthToAdd= Math.min(offset - prefix.getOffset(), prefix.getLength());
+                       buf.append(indentation.substring(0, lengthToAdd));
+                       
+                       boolean commentAtStart= firstNonWS < c.offset && doc.getChar(firstNonWS) == '/'; 
+                       if (commentAtStart) {
+                               // comment started on this line
+                               buf.append(MULTILINE_MID);
+                       }
+
+                       c.shiftsCaret= false;
+                       c.caretOffset= c.offset + buf.length();
+
+                       if (commentAtStart && shouldCloseMultiline(doc, c.offset)) {
+                               try {
+                                       doc.replace(c.offset, 0, indentation+" "+MULTILINE_END); // close the comment in order to parse //$NON-NLS-1$
+                                       buf.append(lineDelim);
+
+                                       // as we are auto-closing, the comment becomes eligible for auto-doc'ing
+                                       IASTDeclaration dec= null;
+                                       IASTTranslationUnit ast= getAST();
+                                       
+                                       if (ast != null) {
+                                               dec= findFollowingDeclaration(ast, offset);
+                                               if (dec == null) {
+                                                       IASTNodeSelector ans= ast.getNodeSelector(ast.getFilePath());
+                                                       IASTNode node= ans.findEnclosingNode(offset, 0);
+                                                       if (node instanceof IASTDeclaration) {
+                                                               dec= (IASTDeclaration) node;
+                                                       }
+                                               }
+                                       }
+                                                                               
+                                       if (dec != null) {
+                                               ITypedRegion partition= TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING /* this! */, offset, false);
+                                               StringBuilder content= customizeAfterNewLineForDeclaration(doc, dec, partition);
+                                               buf.append(indent(content, indentation + MULTILINE_MID, lineDelim));
+                                       }
+
+                               } catch(BadLocationException ble) {
+                                       ble.printStackTrace();
+                               }
+                       }
+
+                       c.text= buf.toString();
+
+               } catch (BadLocationException excp) {
+                       // stop work
+               }       
+       }
+
+       protected StringBuilder customizeAfterNewLineForDeclaration(IDocument doc, IASTDeclaration dec, ITypedRegion region) {
+               return new StringBuilder();
+       }
+       
+       /*
+        * Utilities
+        */
+       
+       /**
+        * Locates the {@link IASTDeclaration} most immediately following the specified offset
+        * @param unit the translation unit, or null (in which case the result will also be null)
+        * @param offset the offset to begin the search from
+        * @return the {@link IASTDeclaration} most immediately following the specified offset, or null if there
+        * is no {@link IASTDeclaration}
+        */
+       public static IASTDeclaration findFollowingDeclaration(IASTTranslationUnit unit, final int offset) {
+               final IASTDeclaration[] dec= new IASTDeclaration[1];
+               final ASTVisitor av= new ASTVisitor() {
+                       {
+                               shouldVisitTranslationUnit= true;
+                               shouldVisitDeclarations= true;
+                       }
+                       
+                       /**
+                        * Holds the 
+                        */
+                       IASTDeclaration stopWhenLeaving;
+                       
+                       @Override
+                       public int visit(IASTDeclaration declaration) {
+                               IASTNodeLocation loc= declaration.getFileLocation();
+                               if (loc != null) {
+                                       int candidateOffset= loc.getNodeOffset();
+                                       int candidateEndOffset= candidateOffset+loc.getNodeLength();
+
+                                       if (offset <= candidateOffset) {
+                                               dec[0]= declaration;
+                                               return PROCESS_ABORT;
+                                       }
+
+                                       boolean candidateEnclosesOffset= (offset >= candidateOffset) && (offset < candidateEndOffset);
+                                       if (candidateEnclosesOffset) {
+                                               stopWhenLeaving= declaration;
+                                       }
+                               }
+                               return PROCESS_CONTINUE;
+                       }
+                       @Override
+                       public int leave(IASTDeclaration declaration) {
+                               if (declaration == stopWhenLeaving) 
+                                       return PROCESS_ABORT;
+                               return PROCESS_CONTINUE;
+                       }
+               };
+               
+               if (unit != null) {
+                       unit.accept(av);
+               }
+               return dec[0];
+       }
+       
+       /**
+        * @return the AST unit for the active editor, or <code>null</code> if there is no active editor, or
+        * the AST could not be obtained.
+        */
+       public IASTTranslationUnit getAST() {
+               final ITranslationUnit unit= getTranslationUnit();
+               try {
+                       if (unit != null) {
+                               IASTTranslationUnit ast= unit.getAST(null, ITranslationUnit.AST_SKIP_ALL_HEADERS);
+                               return ast;
+                       }
+               } catch (CModelException e) {
+                       CUIPlugin.log(e);
+               } catch (CoreException e) {
+                       CUIPlugin.log(e);
+               }
+               return null;
+       }
+
+       /**
+        * Assuming the offset is within a multi-line comment, returns a guess as to
+        * whether the enclosing multi-line comment is a new comment. The result is undefined if
+        * the offset does not occur within a multi-line comment.
+        *
+        * @param document the document
+        * @param offset the offset
+        * @return <code>true</code> if the comment should be closed, <code>false</code> if not
+        */
+       /*
+        * Adapted from JDT
+        */
+       public boolean shouldCloseMultiline(IDocument document, int offset) {
+               try {
+                       IRegion line= document.getLineInformationOfOffset(offset);
+                       ITypedRegion partition= TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, false);
+                       int partitionEnd= partition.getOffset() + partition.getLength();
+                       if (line.getOffset() >= partitionEnd)
+                               return false;
+
+                       String comment= document.get(partition.getOffset(), partition.getLength());
+                       if (comment.indexOf(MULTILINE_START, offset - partition.getOffset()) != -1) 
+                               return true; // enclosed another comment -> probably a new comment
+
+                       if (document.getLength() == partitionEnd) {
+                               return !comment.endsWith(MULTILINE_END);
+                       }
+                       
+                       return false;
+
+               } catch (BadLocationException e) {
+                       return false;
+               }
+       }
+
+       /**
+        * @return the ITranslationUnit for the active editor, or null if no active
+        * editor could be found.
+        */
+       /*
+        * Cloned from JDT
+        */
+       protected static ITranslationUnit getTranslationUnit() {
+               IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+               if (window == null)
+                       return null;
+
+               IWorkbenchPage page= window.getActivePage();
+               if (page == null)
+                       return null;
+
+               IEditorPart editor= page.getActiveEditor();
+               if (editor == null)
+                       return null;
+
+               IWorkingCopyManager manager= CUIPlugin.getDefault().getWorkingCopyManager();
+               ITranslationUnit unit= manager.getWorkingCopy(editor.getEditorInput());
+               if (unit == null)
+                       return null;
+
+               return unit;
+       }
+       
+       /**
+        * Returns a new buffer with the specified indent string inserted at the beginning
+        * of each line in the specified input buffer
+        * @param buffer
+        * @param indent
+        * @param lineDelim 
+        * @since 5.3
+        */
+       protected static final StringBuilder indent(StringBuilder buffer, String indent, String lineDelim) {
+               StringBuilder result= new StringBuilder();
+               BufferedReader br= new BufferedReader(new StringReader(buffer.toString()));
+               try {
+                       for (String line= br.readLine(); line != null; line= br.readLine()) {
+                               result.append(indent).append(line).append(lineDelim);
+                       }
+               } catch(IOException ioe) {
+                       throw new AssertionError(); // we can't get IO errors from a string backed reader
+               }
+               return result;
+       }
+       
+       /**
+        * Returns a new buffer with the specified indent string inserted at the beginning
+        * of each line in the specified input buffer
+        * @param buffer
+        * @param indent
+        * 
+        * @deprecated Use {{@link #indent(StringBuilder, String, String)} instead.
+        */
+       @Deprecated
+       protected static final StringBuilder indent(StringBuilder buffer, String indent) {
+               return indent(buffer, indent, fgDefaultLineDelim);
+       }
+       
+       /**
+        * Returns the offset of the first non-whitespace character in the specified document, searching
+        * right/downward from the specified start offset up to the specified end offset. If there is
+        * no non-whitespace then the end offset is returned.
+        * @param document
+        * @param offset
+        * @param end
+        * @throws BadLocationException
+        */
+       protected static int findEndOfWhiteSpaceAt(IDocument document, int offset, int end) throws BadLocationException {
+               while (offset < end) {
+                       char c= document.getChar(offset);
+                       if (c != ' ' && c != '\t') {
+                               return offset;
+                       }
+                       offset++;
+               }
+               return end;
+       }
+       
+       /**
+        * Returns the range of the comment prefix on the given line in
+        * <code>document</code>. The prefix greedily matches the following regex
+        * pattern: <code>\s*\*\S*\s*</code>, that is, any number of whitespace
+        * characters, followed by an asterisk ('*'), followed by any number of
+        * non-whitespace characters, followed by any number of whitespace characters.
+        *
+        * @param document the document to which <code>line</code> refers
+        * @param line the line from which to extract the prefix range
+        * @return an <code>IRegion</code> describing the range of the prefix on
+        *         the given line
+        * @throws BadLocationException if accessing the document fails
+        */
+       protected static IRegion findPrefixRange(IDocument document, IRegion line) throws BadLocationException {
+               int lineOffset= line.getOffset();
+               int lineEnd= lineOffset + line.getLength();
+               int indentEnd= findEndOfWhiteSpaceAt(document, lineOffset, lineEnd);
+               if (indentEnd < lineEnd && document.getChar(indentEnd) == '*') {
+                       indentEnd++;
+                       while (indentEnd < lineEnd && !isWhitespace(document.getChar(indentEnd)))
+                               indentEnd++;
+                       while (indentEnd < lineEnd && isWhitespace(document.getChar(indentEnd)))
+                               indentEnd++;
+               }
+               return new Region(lineOffset, indentEnd - lineOffset);
+       }
+       
+       private static boolean isWhitespace(char ch) {
+               return ch == ' ' || ch == '\t';
+       }
+
+       /**
+        * Returns whether the text ends with one of the specified IDocument object's
+        * legal line delimiters.
+        */
+       protected static boolean endsWithDelimiter(IDocument d, String txt) {
+               String[] delimiters= d.getLegalLineDelimiters();
+               for (int i= 0; i < delimiters.length; i++) {
+                       if (txt.endsWith(delimiters[i]))
+                               return true;
+               }
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentDictionary.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentDictionary.java
new file mode 100644 (file)
index 0000000..b155bcd
--- /dev/null
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text.doctools;
+
+/**
+ * This interface is a place-holder for the future. Clients should implement the most
+ * appropriate sub-interface (provided by CDT). Currently {@link IDocCommentSimpleDictionary} is
+ * the only provided sub-interface, but it is expected a more subtle way of integrating spell-checking
+ * will be available in the future.
+ * @since 5.0
+ */
+public interface IDocCommentDictionary {}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentOwner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentOwner.java
new file mode 100644 (file)
index 0000000..da4a687
--- /dev/null
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text.doctools;
+
+/**
+ * A comment owner provides {@link IDocCommentViewerConfiguration} to
+ * the CDT c/c++ editor.<p>
+ * 
+ * In future it may also provide a point for providing
+ * <ul>
+ * <li>access an implementation of a documentation comment validation mechanism
+ * <li>owner specific preference/property pages
+ * <li>information for code generation e.g. default single and multi-line comment
+ * delimiting prefix/post-fixes
+ * </ul>
+ *  
+ * @since 5.0
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface IDocCommentOwner {
+       /**
+        * @return the non-null unique identifier for this comment owner. If contributed via the
+        * extension point, the ID corresponds to that in plugin.xml. 
+        */
+       String getID();
+       
+       /**
+        * @return a non-null human-readable name for this comment owner. If contributed via plugin.xml
+        * this name can be localized using the plug-in externalization mechanism.
+        */
+       String getName();
+
+       /**
+        * @return a non-null {@link IDocCommentViewerConfiguration} suitable for a multi-line comment context
+        */
+       IDocCommentViewerConfiguration getMultilineConfiguration();
+       
+       /**
+        * @return a non-null {@link IDocCommentViewerConfiguration} suitable for a single-line comment context
+        */
+       IDocCommentViewerConfiguration getSinglelineConfiguration();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentOwnershipListener.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentOwnershipListener.java
new file mode 100644 (file)
index 0000000..ac7dd83
--- /dev/null
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text.doctools;
+
+import org.eclipse.core.resources.IResource;
+
+/**
+ * Implemented by clients interested in documentation comment ownership change events. These are generated
+ * when the association between resource or workspace and documentation comment owner is set.
+ * @since 5.0
+ */
+public interface IDocCommentOwnershipListener {
+       /**
+        * Called when document comment ownership has changed at a particular resource level.
+        * @param resource the resource the ownership has changed for
+        * @param submappingsRemoved whether child resource mappings have been removed
+        * @param oldOwner the previous document comment owner
+        * @param newOwner the new document comment owner
+        */
+       public void ownershipChanged(IResource resource, boolean submappingsRemoved, IDocCommentOwner oldOwner, IDocCommentOwner newOwner);
+       
+       /**
+        * Called when workspace-scope document comment owner changes.
+        * @param oldOwner the previous document comment owner
+        * @param newOwner the new document comment owner
+        */
+       public void workspaceOwnershipChanged(IDocCommentOwner oldOwner, IDocCommentOwner newOwner);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentSimpleDictionary.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentSimpleDictionary.java
new file mode 100644 (file)
index 0000000..56acb21
--- /dev/null
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text.doctools;
+
+/**
+ * This interface is a simplified means of obtaining spelling support. 
+ * @since 5.0
+ */
+public interface IDocCommentSimpleDictionary extends IDocCommentDictionary {
+       /**
+        * @return an array of words that should be regarded as correct. These
+        * words will be considered in addition to those provided by existing dictionaries.
+        */
+       public String[] getAdditionalWords();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentViewerConfiguration.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/IDocCommentViewerConfiguration.java
new file mode 100644 (file)
index 0000000..4a1cf6d
--- /dev/null
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text.doctools;
+
+import org.eclipse.jface.text.IAutoEditStrategy;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextDoubleClickStrategy;
+
+import org.eclipse.cdt.ui.text.ICPartitions;
+import org.eclipse.cdt.ui.text.ICTokenScanner;
+import org.eclipse.cdt.ui.text.ITokenStoreFactory;
+import org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer;
+
+/**
+ * An IDocCommentViewerConfiguration aggregates a collection of editor tools that can be contributed to
+ * the CDT editor. The tools will be active for CEditor partitions of type {@link ICPartitions#C_MULTI_LINE_DOC_COMMENT} or 
+ * {@link ICPartitions#C_SINGLE_LINE_DOC_COMMENT} when the {@link IDocCommentOwner} this instance originated from is active.
+ * 
+ * @see org.eclipse.jface.text.source.SourceViewerConfiguration (in analogy to)
+ * @since 5.0
+ */
+public interface IDocCommentViewerConfiguration {
+       /**
+        * @param doc the document to examine
+        * @param offset the offset of the start of the region (inclusive)
+        * @param length the length of the region to examine
+        * @return whether the region specified is a documentation comment handled by this viewer configuration
+        */
+       boolean isDocumentationComment(IDocument doc, int offset, int length);
+       
+       /**
+        * @return a ICTokenScanner for tokenising/coloring the appropriate comment region. May return null.
+        */
+       ICTokenScanner createCommentScanner(ITokenStoreFactory tokenStoreFactory);
+       
+       /**
+        * @return an auto edit strategy suitable for the appropriate comment region. May return null
+        * in the case where no auto-edit-strategy is required.
+        */
+       IAutoEditStrategy createAutoEditStrategy();
+       
+       /**
+        * @return a double click strategy suitable for the associated comment-region. May return null in
+        * the case where no double-click-strategy is required.
+        */
+       ITextDoubleClickStrategy createDoubleClickStrategy();
+       
+       /**
+        * @return a completion proposal computer suitable for the associated comment-region. May return null in
+        * the case where no proposal-computer is required.
+        */
+       ICompletionProposalComputer createProposalComputer();
+       
+       /**
+        * @return a {@link IDocCommentDictionary} suitable for spell-checking. May return null
+        * in the case where no additional dictionary is required.
+        */
+       IDocCommentDictionary getSpellingDictionary();
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenHelper.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenHelper.java
new file mode 100644 (file)
index 0000000..1ae0336
--- /dev/null
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text.doctools.doxygen;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.swt.graphics.RGB;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.doctools.generic.GenericDocTag;
+
+/**
+ * Makes available information for Doxygen support.
+ * 
+ * @since 5.0
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class DoxygenHelper extends AbstractPreferenceInitializer {
+       private static final IPath TAGS_CSV= new Path("doxygenTags.csv"); //$NON-NLS-1$
+       private static GenericDocTag[] fTags;
+       
+       public static final String DOXYGEN_TAG_RECOGNIZED= "org.eclipse.cdt.internal.ui.text.doctools.doxygen.recognizedTag"; //$NON-NLS-1$
+       public static final String DOXYGEN_SINGLE_TOKEN= "org.eclipse.cdt.internal.ui.text.doctools.doxygen.single"; //$NON-NLS-1$
+       public static final String DOXYGEN_MULTI_TOKEN= "org.eclipse.cdt.internal.ui.text.doctools.doxygen.multi"; //$NON-NLS-1$
+       
+       /**
+        * @return The tags which are understood by default by the doxygen tool.
+        */
+       public static GenericDocTag[] getDoxygenTags() {
+               if(fTags==null) {
+                       try {
+                               List<GenericDocTag> temp= new ArrayList<GenericDocTag>();
+                               InputStream is= FileLocator.openStream(CUIPlugin.getDefault().getBundle(), TAGS_CSV, false);
+                               BufferedReader br= new BufferedReader(new InputStreamReader(is));
+                               StringBuffer content= new StringBuffer();
+                               for(String line= br.readLine(); line!=null; line= br.readLine()) {
+                                       content.append(line+"\n"); //$NON-NLS-1$
+                               }
+                               String[] values= (content.toString()+"dummy-for-split").split("(\\s)*,(\\s)*"); //$NON-NLS-1$ //$NON-NLS-2$
+                               
+                               for(int i=0; i+1<values.length; i+=2) {
+                                       temp.add(new GenericDocTag(values[i], values[i+1]));
+                               }
+                               fTags= temp.toArray(new GenericDocTag[temp.size()]);
+                       } catch(IOException ioe) {
+                               fTags= new GenericDocTag[0];
+                               CUIPlugin.log(ioe);
+                       }
+               }
+               return fTags;
+       }
+
+       /*
+        * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
+        */
+       @Override
+       public void initializeDefaultPreferences() {
+               IPreferenceStore cuis= CUIPlugin.getDefault().getPreferenceStore();
+               PreferenceConverter.setDefault(cuis, DoxygenHelper.DOXYGEN_MULTI_TOKEN, new RGB(63, 95, 191));
+               PreferenceConverter.setDefault(cuis, DoxygenHelper.DOXYGEN_SINGLE_TOKEN, new RGB(63, 95, 191));
+               PreferenceConverter.setDefault(cuis, DoxygenHelper.DOXYGEN_TAG_RECOGNIZED, new RGB(127, 159, 191));
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineAutoEditStrategy.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineAutoEditStrategy.java
new file mode 100644 (file)
index 0000000..d288187
--- /dev/null
@@ -0,0 +1,312 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Andrew Ferguson (Symbian) - Initial implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text.doctools.doxygen;
+
+import java.util.LinkedHashSet;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IAutoEditStrategy;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.TextUtilities;
+
+import org.eclipse.cdt.core.dom.ast.ExpansionOverlapsBoundaryException;
+import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
+import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
+import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
+import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
+import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
+import org.eclipse.cdt.core.parser.IToken;
+import org.eclipse.cdt.ui.text.doctools.DefaultMultilineCommentAutoEditStrategy;
+
+/**
+ * {@link IAutoEditStrategy} for adding Doxygen tags for comments.
+ * 
+ * @since 5.0
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class DoxygenMultilineAutoEditStrategy extends DefaultMultilineCommentAutoEditStrategy {
+       private static final String SINGLELINE_COMMENT_PRECEDING = "//!< "; //$NON-NLS-1$
+       private static final String PARAM = "@param "; //$NON-NLS-1$
+       private static final String RETURN = "@return"; //$NON-NLS-1$
+
+       protected boolean documentPureVirtuals= true;
+       protected boolean documentDeclarations= true;
+       
+       private String fLineDelimiter;
+       
+       public DoxygenMultilineAutoEditStrategy() {
+       }
+       
+       /**
+        * @param decl the function declarator to document
+        * @param ds the function specifier to document
+        * @return content describing the specified function
+        */
+       protected StringBuilder documentFunction(IASTFunctionDeclarator decl, IASTDeclSpecifier ds) {
+               StringBuilder result= new StringBuilder();
+               
+               result.append(documentFunctionParameters(getParameterDecls(decl)));
+               
+               boolean hasReturn= true;
+               if(ds instanceof IASTSimpleDeclSpecifier) {
+                       IASTSimpleDeclSpecifier sds= (IASTSimpleDeclSpecifier) ds;
+                       if(sds.getType() == IASTSimpleDeclSpecifier.t_void ||
+                                       sds.getType() == IASTSimpleDeclSpecifier.t_unspecified) {
+                               hasReturn= false;
+                       }
+               }
+               if(hasReturn) {
+                       result.append(documentFunctionReturn());
+               }
+
+               return result;
+       }
+       
+       /**
+        * Returns the comment content to add to the documentation comment.
+        * @param decls The parameter declarations to describe
+        * @return a buffer containing the comment content to generate to describe the parameters of
+        * the specified {@link IASTParameterDeclaration} objects.
+        */
+       protected StringBuilder documentFunctionParameters(IASTParameterDeclaration[] decls) {
+               StringBuilder result= new StringBuilder();
+               for(int i=0; i<decls.length; i++) {
+                       if(!isVoidParameter(decls[i])) {
+                               result.append(PARAM).append(getParameterName(decls[i])).append(getLineDelimiter());
+                       }
+               }
+               return result;
+       }
+       
+       /**
+        * Get the default line delimiter for the currently customized document
+        * which should be used for new lines.
+        * 
+        * @return the default line delimiter
+        */
+       private String getLineDelimiter() {
+               return fLineDelimiter;
+       }
+
+       /**
+        * @param decl
+        * @return the name of the parameter
+        */
+       String getParameterName(IASTParameterDeclaration decl) {
+               IASTDeclarator dtor= decl.getDeclarator();
+               for(int i=0; i<8 && dtor.getName().getRawSignature().length()==0 && dtor.getNestedDeclarator() != null; i++) {
+                       dtor= dtor.getNestedDeclarator();
+               }
+               return dtor.getName().getRawSignature();
+       }
+       
+       /**
+        * @param decl
+        * @return true if the specified parameter declaration is of void type
+        */
+       boolean isVoidParameter(IASTParameterDeclaration decl) {
+               if(decl.getDeclSpecifier() instanceof IASTSimpleDeclSpecifier) {
+                       if(((IASTSimpleDeclSpecifier)decl.getDeclSpecifier()).getType() == IASTSimpleDeclSpecifier.t_void) {
+                               IASTDeclarator dtor= decl.getDeclarator();
+                               if(dtor.getPointerOperators().length == 0) {
+                                       if(!(dtor instanceof IASTFunctionDeclarator) && !(dtor instanceof IASTArrayDeclarator)) {
+                                               return true;
+                                       }
+                               }
+                       }
+               }
+               return false;
+       }
+
+       /**
+        * @return the comment content to describe the return
+        */
+       protected StringBuilder documentFunctionReturn() {
+               return new StringBuilder(RETURN).append(getLineDelimiter());
+       }
+
+       /**
+        * @param decl the function declarator to analyze
+        * @return the parameter declarations for the specified function definition
+        */
+       protected IASTParameterDeclaration[] getParameterDecls(IASTFunctionDeclarator decl) {
+               IASTParameterDeclaration[] result;
+               if (decl instanceof IASTStandardFunctionDeclarator) {
+                       IASTStandardFunctionDeclarator standardFunctionDecl= (IASTStandardFunctionDeclarator)decl;
+                       result= standardFunctionDecl.getParameters();
+               } else /*if (def instanceof ICASTKnRFunctionDeclarator) {
+                       ICASTKnRFunctionDeclarator knrDeclarator= (ICASTKnRFunctionDeclarator)decl;
+                       result= knrDeclarator.getParameterDeclarations();
+               } else */{
+                       result= new IASTParameterDeclaration[0];
+               }
+               return result;
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.doctools.DefaultMultilineCommentAutoEditStrategy#customizeAfterNewLineForDeclaration(org.eclipse.jface.text.IDocument, org.eclipse.cdt.core.dom.ast.IASTDeclaration, org.eclipse.jface.text.ITypedRegion)
+        */
+       @Override
+       protected StringBuilder customizeAfterNewLineForDeclaration(IDocument doc, IASTDeclaration dec, ITypedRegion partition) {
+               fLineDelimiter = TextUtilities.getDefaultLineDelimiter(doc);
+
+               IASTDeclaration declToDocument = dec;
+               
+               if(declToDocument instanceof ICPPASTLinkageSpecification) {
+                       ICPPASTLinkageSpecification linkageSpecification = (ICPPASTLinkageSpecification)declToDocument;
+                       IASTDeclaration[] declarations = linkageSpecification.getDeclarations();
+                       
+                       if(declarations.length == 1) {
+                               
+                               boolean isCurlyExtern = false;
+                               IToken token = null;
+                               
+                               try {
+                                       token = declarations[0].getTrailingSyntax();
+                               } catch (UnsupportedOperationException e) {
+                                       return new StringBuilder();
+                               } catch (ExpansionOverlapsBoundaryException e) {
+                                       return new StringBuilder();
+                               }
+                               
+                               if(token != null && token.getType() == IToken.tRBRACE) {
+                                       isCurlyExtern = true;
+                               }
+                               
+                               if(!isCurlyExtern) {
+                                       declToDocument = declarations[0];       
+                               }
+                       }
+               }
+               
+               while(declToDocument instanceof ICPPASTTemplateDeclaration) /* if? */
+                       declToDocument= ((ICPPASTTemplateDeclaration)declToDocument).getDeclaration(); 
+
+               if(declToDocument instanceof IASTFunctionDefinition) {
+                       IASTFunctionDefinition fd= (IASTFunctionDefinition) declToDocument;
+                       return documentFunction(fd.getDeclarator(), fd.getDeclSpecifier());
+               }
+
+               if(declToDocument instanceof IASTSimpleDeclaration) {
+                       IASTSimpleDeclaration sdec= (IASTSimpleDeclaration) declToDocument;
+                       StringBuilder result= new StringBuilder();
+                       
+                       if(sdec.getDeclSpecifier() instanceof IASTCompositeTypeSpecifier) {
+                               return result;
+                       } else {
+                               IASTDeclarator[] dcs= sdec.getDeclarators();
+                               if(dcs.length == 1 && dcs[0] instanceof IASTFunctionDeclarator) {
+                                       IASTFunctionDeclarator fdecl = (IASTFunctionDeclarator)dcs[0];
+                                       boolean shouldDocument= documentDeclarations;
+                                       if(documentPureVirtuals && dcs[0] instanceof ICPPASTFunctionDeclarator) {
+                                               ICPPASTFunctionDeclarator cppfdecl= (ICPPASTFunctionDeclarator) dcs[0];
+                                               shouldDocument = shouldDocument || cppfdecl.isPureVirtual();
+                                       }
+                                       
+                                       if(shouldDocument) {
+                                               return documentFunction(fdecl, sdec.getDeclSpecifier());
+                                       }
+                               }
+                       }
+               }
+
+               try {
+                       alterDoc(doc, declToDocument);
+               } catch(BadLocationException ble) {
+                       /*ignore*/
+               }
+
+               return new StringBuilder();
+       }
+
+       /*
+        * Add post-declaration comments to enumerators, after initializing a doc-comment on an enumeration
+        */
+       private void alterDoc(IDocument doc, IASTDeclaration dec) throws BadLocationException {
+               if(dec instanceof IASTSimpleDeclaration && ((IASTSimpleDeclaration)dec).getDeclSpecifier() instanceof IASTEnumerationSpecifier) {
+                       IASTEnumerationSpecifier spc= (IASTEnumerationSpecifier)  ((IASTSimpleDeclaration)dec).getDeclSpecifier();
+                       IASTEnumerator[] enms= spc.getEnumerators();
+
+                       class Entry {
+                               final int offset, length;
+                               StringBuilder comment;
+                               Entry(int offset, int length, String comment) {
+                                       this.offset= offset;
+                                       this.length= length;
+                                       this.comment= new StringBuilder(comment);
+                               }
+                               @Override
+                               public int hashCode() {
+                                       return offset;
+                               }
+                               @Override
+                               public boolean equals(Object obj) {
+                                       if(obj instanceof Entry) {
+                                               Entry other= (Entry) obj;
+                                               return offset == other.offset;
+                                       }
+                                       return false;
+                               }
+                       }
+
+                       boolean noCollisions= true;
+                       LinkedHashSet<Entry> entries= new LinkedHashSet<Entry>();
+                       for(IASTEnumerator enumerator : enms) {
+                               IASTNodeLocation loc= enumerator.getName().getFileLocation();
+                               if(loc != null) {
+                                       int nodeOffset= loc.getNodeOffset()+loc.getNodeLength();
+                                       String cmt= SINGLELINE_COMMENT_PRECEDING+enumerator.getName();
+                                       IRegion line= doc.getLineInformationOfOffset(nodeOffset);
+                                       if(!doc.get(line.getOffset(), line.getLength()).contains("//")) { //$NON-NLS-1$
+                                               noCollisions &= entries.add(new Entry(line.getOffset(),line.getLength(), cmt));
+                                       }
+                               }
+                       }
+
+                       /*
+                        * Only auto-insert comments if each enumerator is declared on a unique line
+                        */
+                       if(noCollisions) {
+                               int max= Integer.MIN_VALUE;
+                               for(Entry e : entries) {
+                                       if(e.length > max)
+                                               max= e.length;
+                               }
+
+                               int addedLength=0;
+                               for(Entry e : entries) {
+                                       // pad with whitespace
+                                       int toAdd= max-e.length;
+                                       for(int j=0; j<toAdd; j++) {
+                                               e.comment.insert(0, " "); //$NON-NLS-1$
+                                       }
+                                       doc.replace(e.offset+e.length+addedLength, 0, e.comment.toString());
+                                       addedLength+= e.comment.length();
+                               }
+                       }
+               }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineConfiguration.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineConfiguration.java
new file mode 100644 (file)
index 0000000..e8b5f5f
--- /dev/null
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text.doctools.doxygen;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IAutoEditStrategy;
+import org.eclipse.jface.text.IDocument;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration;
+import org.eclipse.cdt.ui.text.doctools.generic.AbstractGenericTagDocCommentViewerConfiguration;
+import org.eclipse.cdt.ui.text.doctools.generic.GenericDocTag;
+
+/**
+ * {@link IDocCommentViewerConfiguration} implementation for doxygen multi-line documentation comments.
+ * <em>This class may be sub-classed by clients</em>
+ * @since 5.0
+ */
+public class DoxygenMultilineConfiguration extends AbstractGenericTagDocCommentViewerConfiguration {
+       /**
+        * Default constructor
+        */
+       public DoxygenMultilineConfiguration() {
+               super(DoxygenHelper.getDoxygenTags(), new char[] {'@','\\'}, DoxygenHelper.DOXYGEN_MULTI_TOKEN, DoxygenHelper.DOXYGEN_TAG_RECOGNIZED);
+       }
+
+       /**
+        * Constructor intended for use by sub-classes.
+        * @param tags a non-null array of tags this configuration should recognize
+        * @param tagMarkers a non-null array of characters used to prefix the tags (e.g. @ or \)
+        * @param defaultToken the default scanner token id
+        * @param tagToken the scanner token to use to mark used by this configuration
+        * @see AbstractGenericTagDocCommentViewerConfiguration
+        */
+       protected DoxygenMultilineConfiguration(GenericDocTag[] tags, char[] tagMarkers, String defaultToken, String tagToken) {
+               super(tags, tagMarkers, defaultToken, tagToken);
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration#createAutoEditStrategy()
+        */
+       public IAutoEditStrategy createAutoEditStrategy() {
+               return new DoxygenMultilineAutoEditStrategy();
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration#isDocumentationComment(org.eclipse.jface.text.IDocument, int, int)
+        */
+       public boolean isDocumentationComment(IDocument doc, int offset, int length) {
+               try {
+                       if(offset+2 < doc.getLength()) {
+                               char c= doc.getChar(offset+2);
+                               return c == '*' || c == '!';
+                       }
+               } catch(BadLocationException ble) {
+                       CUIPlugin.log(ble);
+               }
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenSingleConfiguration.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenSingleConfiguration.java
new file mode 100644 (file)
index 0000000..65c9c89
--- /dev/null
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text.doctools.doxygen;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy;
+import org.eclipse.jface.text.IAutoEditStrategy;
+import org.eclipse.jface.text.IDocument;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration;
+import org.eclipse.cdt.ui.text.doctools.generic.AbstractGenericTagDocCommentViewerConfiguration;
+import org.eclipse.cdt.ui.text.doctools.generic.GenericDocTag;
+
+/**
+ * {@link IDocCommentViewerConfiguration} implementation for doxygen single-line documentation comments.
+ * <em>This class may be sub-classed by clients</em>
+ * @since 5.0
+ */
+public class DoxygenSingleConfiguration extends AbstractGenericTagDocCommentViewerConfiguration {
+       /**
+        * Default constructor
+        */
+       public DoxygenSingleConfiguration() {
+               super(DoxygenHelper.getDoxygenTags(), new char[] {'@','\\'}, DoxygenHelper.DOXYGEN_SINGLE_TOKEN, DoxygenHelper.DOXYGEN_TAG_RECOGNIZED);
+       }
+       
+       /**
+        * Constructor intended for use by sub-classes.
+        * @param tags a non-null array of tags this configuration should recognize
+        * @param tagMarkers a non-null array of characters used to prefix the tags (e.g. @ or \)
+        * @param defaultToken the default scanner token id
+        * @param tagToken the scanner token to use to mark used by this configuration
+        */
+       protected DoxygenSingleConfiguration(GenericDocTag[] tags, char[] tagMarkers, String defaultToken, String tagToken) {
+               super(tags, tagMarkers, defaultToken, tagToken);
+       }
+       
+       /*
+        * @see org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration#createAutoEditStrategy()
+        */
+       public IAutoEditStrategy createAutoEditStrategy() {
+               return new DefaultIndentLineAutoEditStrategy();
+       }
+       
+       /*
+        * @see org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration#isDocumentationComment(org.eclipse.jface.text.IDocument, int, int)
+        */
+       public boolean isDocumentationComment(IDocument doc, int offset, int length) {
+               try {
+                       if(offset+2 < doc.getLength()) {
+                               char c= doc.getChar(offset+2);
+                               return c == '/' || c == '!';
+                       }
+               } catch(BadLocationException ble) {
+                       CUIPlugin.log(ble);
+               }
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/AbstractGenericTagDocCommentViewerConfiguration.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/AbstractGenericTagDocCommentViewerConfiguration.java
new file mode 100644 (file)
index 0000000..d32e76e
--- /dev/null
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text.doctools.generic;
+
+import org.eclipse.jface.text.ITextDoubleClickStrategy;
+
+import org.eclipse.cdt.ui.text.ICTokenScanner;
+import org.eclipse.cdt.ui.text.ITokenStoreFactory;
+import org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentDictionary;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentSimpleDictionary;
+import org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration;
+
+/**
+ * An abstract base-class for documentation tool contributions using the 'generic tag' framework
+ * @since 5.0
+ */
+public abstract class AbstractGenericTagDocCommentViewerConfiguration implements IDocCommentViewerConfiguration {
+       protected GenericDocTag[] fTags;
+       protected char[] fTagMarkers;
+       
+       protected ITextDoubleClickStrategy fDCStrategy;
+       protected ICompletionProposalComputer fCPComputer;
+       protected String fDefaultToken;
+       protected String fTagToken;
+       protected IDocCommentSimpleDictionary fDictionary;
+       
+       /**
+        * 
+        * @param tags a non-null array of tags this configuration should recognize
+        * @param tagMarkers a non-null array of characters used to prefix the tags (e.g. @ or \)
+        * @param defaultToken the default scanner token id
+        * @param tagToken the scanner token to use to mark used by this configuration
+        */
+       public AbstractGenericTagDocCommentViewerConfiguration(GenericDocTag[] tags, char[] tagMarkers, String defaultToken, String tagToken) {
+               fTags= tags;
+               fTagMarkers= tagMarkers;
+               fDCStrategy= new GenericTagDoubleClickStrategy(tagMarkers);
+               fCPComputer= new GenericTagCompletionProposalComputer(fTags, tagMarkers);
+               fDefaultToken= defaultToken;
+               fTagToken= tagToken;
+               fDictionary= new GenericTagSimpleDictionary(fTags, fTagMarkers);
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration#createCommentScanner(org.eclipse.cdt.ui.text.ITokenStoreFactory, java.lang.String)
+        */
+       public ICTokenScanner createCommentScanner(ITokenStoreFactory tokenStoreFactory) {
+               return new GenericTagCommentScanner(fTags, fTagMarkers, tokenStoreFactory, fDefaultToken, fTagToken);
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration#createDoubleClickStrategy()
+        */
+       public ITextDoubleClickStrategy createDoubleClickStrategy() {
+               return fDCStrategy;
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration#createProposalComputer()
+        */
+       public ICompletionProposalComputer createProposalComputer() {
+               return fCPComputer;
+       }
+       
+       /*
+        * @see org.eclipse.cdt.ui.text.doctools.IDocCommentViewerConfiguration#getSpellingDictionary()
+        */
+       public IDocCommentDictionary getSpellingDictionary() {
+               return fDictionary;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericDocTag.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericDocTag.java
new file mode 100644 (file)
index 0000000..e44eb19
--- /dev/null
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text.doctools.generic;
+
+/**
+ * Record class for a generic documentation tool tag.
+ * @since 5.0
+ */
+public class GenericDocTag {
+       protected final String name, description;
+       
+       /**
+        * Create a tag
+        * @param name
+        * @param description
+        */
+       public GenericDocTag(String name, String description) {
+               this.name= name;
+               this.description= description;
+       }
+       
+       /**
+        * @return the tag name (without any prefix e.g. no at or backslash)
+        */
+       public String getTagName() {
+               return name;
+       }
+       
+       /**
+        * @return a human readable description of the tag. May be null.
+        */
+       public String getTagDescription() {
+               return description;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagCommentScanner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagCommentScanner.java
new file mode 100644 (file)
index 0000000..3a5e1fc
--- /dev/null
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text.doctools.generic;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
+import org.eclipse.jface.text.rules.IRule;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.IWordDetector;
+import org.eclipse.jface.text.rules.WordRule;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.ICTokenScanner;
+import org.eclipse.cdt.ui.text.ITokenStore;
+import org.eclipse.cdt.ui.text.ITokenStoreFactory;
+
+import org.eclipse.cdt.internal.ui.text.TaskTagRule;
+
+/**
+ * ICTokenScanner which recognizes a specified set of tags, starting with a specified name.
+ * It is assumed this will be used within a single-line or multi-line comment context.
+ * @since 5.0
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class GenericTagCommentScanner extends BufferedRuleBasedScanner implements ICTokenScanner {
+       protected TaskTagRule fTaskTagRule;
+       protected IPreferenceStore fCorePreferenceStore;
+       protected String fDefaultTokenProperty;
+       protected String fTagToken;
+
+       protected GenericDocTag[] fTags;
+       protected char[] fTagMarkers;
+       protected ITokenStore fTokenStore;
+
+       /**
+        * @param tags the tags to be recognized and highlighted by this scanner
+        * @param tagMarkers the character prefixes that denote the start of a tag
+        * @param tokenStoreFactory the token store factory used to store tokens
+        * @param docToken the token id associated with the enclosing comment
+        * @param tagToken the token id associated with highlighting any recognized tags
+        */
+       public GenericTagCommentScanner(GenericDocTag[] tags, char[] tagMarkers, ITokenStoreFactory tokenStoreFactory, String docToken, String tagToken) {
+               Assert.isNotNull(tags);
+               Assert.isNotNull(tagMarkers);
+               
+               fTags= tags;
+               fTagMarkers= tagMarkers;
+               fTagToken= tagToken;
+
+               fTokenStore= tokenStoreFactory.createTokenStore(mkArray(docToken, tagToken));
+               fDefaultTokenProperty= docToken;
+
+               setRules(createRules());
+       }
+
+       /*
+        * @see org.eclipse.jface.text.rules.RuleBasedScanner#nextToken()
+        */
+       @Override
+       public IToken nextToken() {
+               fTokenStore.ensureTokensInitialised();
+               return super.nextToken();
+       }
+
+       /**
+        * @return the rules to use in this scanner
+        */
+       protected IRule[] createRules() {
+               List<IRule> result= new ArrayList<IRule>();
+
+               class TagDetector implements IWordDetector {
+                       public boolean isWordStart(char c) {
+                               for (int i= 0; i < fTagMarkers.length; i++)
+                                       if (fTagMarkers[i] == c)
+                                               return true;
+                               return false;
+                       }
+                       public boolean isWordPart(char c) {
+                               return c == '.' || Character.isJavaIdentifierPart(c);
+                       }
+               }
+
+               setDefaultReturnToken(fTokenStore.getToken(fDefaultTokenProperty));
+               WordRule wr= new WordRule(new TagDetector(), fDefaultReturnToken);
+               for (int i= 0; i < fTags.length; i++) {
+                       String wd= fTags[i].getTagName();
+                       for (int j= 0; j < fTagMarkers.length; j++) {
+                               wr.addWord(fTagMarkers[j] + wd, fTokenStore.getToken(fTagToken));
+                       }
+               }
+               result.add(wr);
+
+               // Add rule for Task Tags.
+               fTaskTagRule= new TaskTagRule(fTokenStore.getToken(PreferenceConstants.EDITOR_TASK_TAG_COLOR),
+                               fDefaultReturnToken, fTokenStore.getPreferenceStore(), fCorePreferenceStore);
+               result.add(fTaskTagRule);
+
+               return result.toArray(new IRule[result.size()]);
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.AbstractJavaScanner#affectsBehavior(org.eclipse.jface.util.PropertyChangeEvent)
+        */
+       public boolean affectsBehavior(PropertyChangeEvent event) {
+               return fTaskTagRule.affectsBehavior(event) || fTokenStore.affectsBehavior(event);
+       }
+
+       /*
+        * @see org.eclipse.cdt.internal.ui.text.AbstractJavaScanner#adaptToPreferenceChange(org.eclipse.jface.util.PropertyChangeEvent)
+        */
+       public void adaptToPreferenceChange(PropertyChangeEvent event) {
+               if (fTokenStore.affectsBehavior(event)) {
+                       fTokenStore.adaptToPreferenceChange(event);
+               }
+               fTaskTagRule.adaptToPreferenceChange(event);
+       }
+       
+       private static String[] mkArray(String defaultTokenProperty, String tagToken) {
+               return new String[] { defaultTokenProperty, tagToken, PreferenceConstants.EDITOR_TASK_TAG_COLOR };
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagCompletionProposalComputer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagCompletionProposalComputer.java
new file mode 100644 (file)
index 0000000..a344d5b
--- /dev/null
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text.doctools.generic;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+
+import org.eclipse.cdt.ui.text.ICPartitions;
+import org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext;
+import org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer;
+
+import org.eclipse.cdt.internal.ui.text.contentassist.CCompletionProposal;
+
+/**
+ * CompletionProposalComputer based on a specified set of GenericTag objects.
+ * @since 5.0
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class GenericTagCompletionProposalComputer implements ICompletionProposalComputer {
+       protected GenericDocTag[] tags;
+       protected char[] tagMarkers;
+       
+       /**
+        * Constructs a proposal computer for the specified tags
+        * @param tags
+        */
+       public GenericTagCompletionProposalComputer(GenericDocTag[] tags, char[] tagMarkers) {
+               this.tags= tags;
+               this.tagMarkers= tagMarkers;
+       }
+       
+       /**
+        * @param c the character to test
+        * @return whether the specified character is a tag prefix marker 
+        */
+       protected boolean isTagMarker(char c) {
+               for(char candidate : tagMarkers)
+                       if(c == candidate)
+                               return true;
+               return false;
+       }
+       
+       /*
+        * @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#computeCompletionProposals(org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
+        */
+       public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+               IDocument doc= context.getDocument();
+               int ivcOffset= context.getInvocationOffset();
+               try {
+                       ITypedRegion tr= TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, ivcOffset, false);
+                       int firstNonWS= ivcOffset;
+                       while(firstNonWS-1> tr.getOffset() && !Character.isWhitespace(doc.get(firstNonWS-1, 1).charAt(0)))
+                               firstNonWS--;
+                       String prefix= doc.get(firstNonWS, ivcOffset-firstNonWS);
+                       if(prefix.length()>0 && isTagMarker(prefix.charAt(0))) {
+                               List<ICompletionProposal> proposals= new ArrayList<ICompletionProposal>();
+                               char tagMarker= prefix.charAt(0);
+                               for (GenericDocTag tag2 : tags) {
+                                       String tag= tag2.getTagName();
+                                       if(tag.toLowerCase().startsWith(prefix.substring(1).toLowerCase())) {                                           
+                                               CCompletionProposal proposal= new CCompletionProposal(tagMarker+tag, ivcOffset-prefix.length(), prefix.length(), null, tagMarker+tag, 1, context.getViewer()); 
+                                               String description= tag2.getTagDescription();
+                                               if(description!=null && description.length()>0) {
+                                                       proposal.setAdditionalProposalInfo(description);
+                                               }
+                                               proposals.add(proposal);
+                                       }
+                               }
+                               return proposals;
+                       }
+               } catch(BadLocationException ble) {
+                       // offset is zero, ignore
+               }
+               return Collections.emptyList();
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#computeContextInformation(org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
+        */
+       public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+               return Collections.emptyList();
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#getErrorMessage()
+        */
+       public String getErrorMessage() {
+               return null;
+       }
+
+       /*
+        * @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#sessionEnded()
+        */
+       public void sessionEnded() {}
+       
+       /*
+        * @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#sessionStarted()
+        */
+       public void sessionStarted() {}
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagDoubleClickStrategy.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagDoubleClickStrategy.java
new file mode 100644 (file)
index 0000000..dc2e36d
--- /dev/null
@@ -0,0 +1,260 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text.doctools.generic;
+
+import com.ibm.icu.text.BreakIterator;
+import java.text.CharacterIterator;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextDoubleClickStrategy;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Region;
+
+/**
+ * A double-click strategy for words starting with specified tag markers.
+ * @since 5.0
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+/*
+ * Cloned and tweaked from JDT's javadoc double click strategy
+ */
+public class GenericTagDoubleClickStrategy implements ITextDoubleClickStrategy {
+       protected char[] fTagMarkers;
+       
+       /**
+        * A double-click strategy that additionally understands tag markers form part of a
+        * selectable word.
+        * @param tagMarkers the set of characters to additionally consider part of a word
+        */
+       public GenericTagDoubleClickStrategy(char[] tagMarkers) {
+               fTagMarkers= new char[tagMarkers.length];
+               System.arraycopy(tagMarkers, 0, fTagMarkers, 0, tagMarkers.length);
+       }
+       
+       /**
+        * Implements a character iterator that works directly on
+        * instances of <code>IDocument</code>. Used to collaborate with
+        * the break iterator.
+        *
+        * @see IDocument
+        * @since 2.0
+        */
+       static class DocumentCharacterIterator implements CharacterIterator {
+
+               /** Document to iterate over. */
+               private IDocument fDocument;
+               /** Start offset of iteration. */
+               private int fOffset= -1;
+               /** End offset of iteration. */
+               private int fEndOffset= -1;
+               /** Current offset of iteration. */
+               private int fIndex= -1;
+
+               /** Creates a new document iterator. */
+               public DocumentCharacterIterator() {
+               }
+
+               /**
+                * Configures this document iterator with the document section to be visited.
+                *
+                * @param document the document to be iterated
+                * @param iteratorRange the range in the document to be iterated
+                */
+               public void setDocument(IDocument document, IRegion iteratorRange) {
+                       fDocument= document;
+                       fOffset= iteratorRange.getOffset();
+                       fEndOffset= fOffset + iteratorRange.getLength();
+               }
+
+               /*
+                * @see CharacterIterator#first()
+                */
+               public char first() {
+                       fIndex= fOffset;
+                       return current();
+               }
+
+               /*
+                * @see CharacterIterator#last()
+                */
+               public char last() {
+                       fIndex= fOffset < fEndOffset ? fEndOffset -1 : fEndOffset;
+                       return current();
+               }
+
+               /*
+                * @see CharacterIterator#current()
+                */
+               public char current() {
+                       if (fOffset <= fIndex && fIndex < fEndOffset) {
+                               try {
+                                       return fDocument.getChar(fIndex);
+                               } catch (BadLocationException x) {
+                               }
+                       }
+                       return DONE;
+               }
+
+               /*
+                * @see CharacterIterator#next()
+                */
+               public char next() {
+                       ++fIndex;
+                       int end= getEndIndex();
+                       if (fIndex >= end) {
+                               fIndex= end;
+                               return DONE;
+                       }
+                       return current();
+               }
+
+               /*
+                * @see CharacterIterator#previous()
+                */
+               public char previous() {
+                       if (fIndex == fOffset)
+                               return DONE;
+
+                       if (fIndex > fOffset)
+                               -- fIndex;
+
+                       return current();
+               }
+
+               /*
+                * @see CharacterIterator#setIndex(int)
+                */
+               public char setIndex(int index) {
+                       fIndex= index;
+                       return current();
+               }
+
+               /*
+                * @see CharacterIterator#getBeginIndex()
+                */
+               public int getBeginIndex() {
+                       return fOffset;
+               }
+
+               /*
+                * @see CharacterIterator#getEndIndex()
+                */
+               public int getEndIndex() {
+                       return fEndOffset;
+               }
+
+               /*
+                * @see CharacterIterator#getIndex()
+                */
+               public int getIndex() {
+                       return fIndex;
+               }
+
+               /*
+                * @see CharacterIterator#clone()
+                */
+               @Override
+               public Object clone() {
+                       DocumentCharacterIterator i= new DocumentCharacterIterator();
+                       i.fDocument= fDocument;
+                       i.fIndex= fIndex;
+                       i.fOffset= fOffset;
+                       i.fEndOffset= fEndOffset;
+                       return i;
+               }
+       }
+
+
+       /**
+        * The document character iterator used by this strategy.
+        * @since 2.0
+        */
+       private DocumentCharacterIterator fDocIter= new DocumentCharacterIterator();
+
+       /*
+        * @see org.eclipse.jface.text.ITextDoubleClickStrategy#doubleClicked(org.eclipse.jface.text.ITextViewer)
+        */
+       public void doubleClicked(ITextViewer text) {
+
+               int position= text.getSelectedRange().x;
+
+               if (position < 0)
+                       return;
+
+               IRegion word= getWordRegion(text.getDocument(), position);
+
+               if (word != null)
+                       text.setSelectedRange(word.getOffset(), word.getLength());
+       }
+
+       /**
+        * Returns a region describing the word around <code>position</code>.
+        *
+        * @param document the document
+        * @param position the offset around which to return the word
+        * @return the word's region, or <code>null</code> for no selection
+        */
+       private IRegion getWordRegion(IDocument document, int position) {
+               try {
+
+                       IRegion line= document.getLineInformationOfOffset(position);
+                       if (position == line.getOffset() + line.getLength())
+                               return null;
+
+                       fDocIter.setDocument(document, line);
+
+                       BreakIterator breakIter= BreakIterator.getWordInstance();
+                       breakIter.setText(fDocIter);
+
+                       int start= breakIter.preceding(position);
+                       if (start == BreakIterator.DONE)
+                               start= line.getOffset();
+
+                       int end= breakIter.following(position);
+                       if (end == BreakIterator.DONE)
+                               end= line.getOffset() + line.getLength();
+
+                       if (breakIter.isBoundary(position)) {
+                               if (end - position > position- start)
+                                       start= position;
+                               else
+                                       end= position;
+                       }
+
+                       if (start > 0 && isTagMarker(document.getChar(start - 1)) && Character.isJavaIdentifierPart(document.getChar(start))
+                                       && (start == 1 || Character.isWhitespace(document.getChar(start - 2)) || document.getChar(start - 2) == '{')) {
+                               // double click after @ident
+                               start--;
+                       } else if (end == position && end == start + 1 && end < line.getOffset() + line.getLength() && document.getChar(end) == '@') {
+                               // double click before " @ident"
+                               return getWordRegion(document, position + 1);
+                       }
+
+                       if (start == end)
+                               return null;
+                       return new Region(start, end - start);
+
+               } catch (BadLocationException x) {
+                       return null;
+               }
+       }
+
+
+       protected boolean isTagMarker(char c) {
+               for(int i=0; i<fTagMarkers.length; i++) {
+                       if(c == fTagMarkers[i])
+                               return true;
+               }
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagSimpleDictionary.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/generic/GenericTagSimpleDictionary.java
new file mode 100644 (file)
index 0000000..f7f4aa0
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2009 Symbian Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Andrew Ferguson (Symbian) - Initial implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.text.doctools.generic;
+
+import org.eclipse.cdt.ui.text.doctools.IDocCommentSimpleDictionary;
+
+/**
+ * An implementation of a simple dictionary to allow the spelling engine
+ * to not flag documentation tool tags.
+ * @since 5.0
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class GenericTagSimpleDictionary implements IDocCommentSimpleDictionary {
+       protected String[] fTags;
+
+       /**
+        * @param tags the tags that should be recognized as correct
+        * @param tagMarkers the characters that may delimit the start of a tag
+        */
+       public GenericTagSimpleDictionary(GenericDocTag[] tags, char[] tagMarkers) {
+               fTags= new String[tags.length];
+
+               for(int j=0; j<tags.length; j++) {
+                       fTags[j]= tags[j].getTagName();
+               }
+       }
+
+       /**
+        * @return an array of non-null words to be added to the dictionary when spell-checking
+        */
+       public String[] getAdditionalWords() {
+               return fTags;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/folding/ICFoldingPreferenceBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/folding/ICFoldingPreferenceBlock.java
new file mode 100644 (file)
index 0000000..c13e3d8
--- /dev/null
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui.text.folding;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * Contributors to the <code>org.eclipse.cdt.ui.foldingStructureProvider</code> extension point
+ * can specify an implementation of this interface to be displayed on the C/C++ &gt; Editor &gt; 
+ * Folding preference page.
+ * <p>
+ * Clients may implement this interface.
+ * </p>
+ * 
+ */
+public interface ICFoldingPreferenceBlock {
+
+       /**
+        * Creates the control that will be displayed on the C/C++ &gt; Editor &gt; Folding
+        * preference page.
+        * 
+        * @param parent the parent composite to which to add the preferences control
+        * @return the control that was added to <code>parent</code> 
+        */
+       Control createControl(Composite parent);
+
+       /**
+        * Called after creating the control. Implementations should load the 
+        * preferences values and update the controls accordingly.
+        */
+       void initialize();
+
+       /**
+        * Called when the <code>OK</code> button is pressed on the preference
+        * page. Implementations should commit the configured preference settings
+        * into their form of preference storage.
+        */
+       void performOk();
+
+       /**
+        * Called when the <code>Defaults</code> button is pressed on the
+        * preference page. Implementation should reset any preference settings to
+        * their default values and adjust the controls accordingly.
+        */
+       void performDefaults();
+
+       /**
+        * Called when the preference page is being disposed. Implementations should
+        * free any resources they are holding on to.
+        */
+       void dispose();
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/folding/ICFoldingStructureProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/folding/ICFoldingStructureProvider.java
new file mode 100644 (file)
index 0000000..ae94b60
--- /dev/null
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.ui.text.folding;
+
+import org.eclipse.jface.text.source.projection.ProjectionViewer;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+/**
+ * Contributors to the
+ * <code>org.eclipse.cdt.ui.foldingStructureProvider</code> extension
+ * point must specify an implementation of this interface which will create and
+ * maintain {@link org.eclipse.jface.text.source.projection.ProjectionAnnotation} objects
+ * that define folded regions in the the {@link org.eclipse.jface.text.source.projection.ProjectionViewer}.
+ * <p>
+ * Clients may implement this interface.
+ * </p>
+ * 
+ */
+public interface ICFoldingStructureProvider {
+
+       /**
+        * Installs this structure provider on the given editor and viewer.
+        * Implementations should listen to the projection events generated by
+        * <code>viewer</code> and enable / disable generation of projection
+        * structure accordingly.
+        * 
+        * @param editor the editor that this provider works on
+        * @param viewer the projection viewer that displays the annotations created
+        *        by this structure provider
+        */
+       public abstract void install(ITextEditor editor, ProjectionViewer viewer);
+
+       /**
+        * Uninstalls this structure provider. Any references to editors or viewers
+        * should be cleared.
+        */
+       public abstract void uninstall();
+
+       /**
+        * (Re-)initializes the structure provided by the receiver.
+        */
+       public abstract void initialize();
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CCProjectWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CCProjectWizard.java
new file mode 100644 (file)
index 0000000..7adce42
--- /dev/null
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *     IBM Corporation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.wizards;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+
+import org.eclipse.cdt.core.CCProjectNature;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.CProjectNature;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * The wizard to create new MBS C++ Project.
+ */
+public class CCProjectWizard extends CDTCommonProjectWizard {
+
+       public CCProjectWizard() {
+               super(Messages.NewModelProjectWizard_2, Messages.NewModelProjectWizard_3); 
+       }
+       
+       @Override
+       public String[] getNatures() {
+               return new String[] { CProjectNature.C_NATURE_ID, CCProjectNature.CC_NATURE_ID };
+       }
+       
+       @Override
+       protected IProject continueCreation(IProject prj) {
+               if (continueCreationMonitor == null) {
+                       continueCreationMonitor = new NullProgressMonitor();
+               }
+               
+               try {
+                       continueCreationMonitor.beginTask(Messages.CCProjectWizard_0, 2); 
+                       CProjectNature.addCNature(prj, new SubProgressMonitor(continueCreationMonitor, 1));
+                       CCProjectNature.addCCNature(prj, new SubProgressMonitor(continueCreationMonitor, 1));
+               } catch (CoreException e) {}
+               finally {continueCreationMonitor.done();}
+               return prj;
+       }
+       
+       @Override
+       public String[] getContentTypeIDs() {
+               return new String[] { CCorePlugin.CONTENT_TYPE_CXXSOURCE, CCorePlugin.CONTENT_TYPE_CXXHEADER };
+       }
+       
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTCommonProjectWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTCommonProjectWizard.java
new file mode 100644 (file)
index 0000000..e2bf380
--- /dev/null
@@ -0,0 +1,410 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2009 Rational Software Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Rational Software - Initial API and implementation
+ * Intel corp - rework for New Project Model
+ *******************************************************************************/
+package org.eclipse.cdt.ui.wizards;
+
+
+import java.lang.reflect.InvocationTargetException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileInfo;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.core.runtime.content.IContentTypeManager;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
+import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
+import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ILanguage;
+import org.eclipse.cdt.core.model.LanguageManager;
+import org.eclipse.cdt.core.settings.model.ICProjectDescription;
+import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+import org.eclipse.cdt.internal.ui.wizards.ICDTCommonProjectWizard;
+
+public abstract class CDTCommonProjectWizard extends BasicNewResourceWizard 
+implements IExecutableExtension, IWizardWithMemory, ICDTCommonProjectWizard
+{
+       private static final String PREFIX= "CProjectWizard"; //$NON-NLS-1$
+       private static final String OP_ERROR= "CProjectWizard.op_error"; //$NON-NLS-1$
+       private static final String title= CUIPlugin.getResourceString(OP_ERROR + ".title"); //$NON-NLS-1$
+       private static final String message= CUIPlugin.getResourceString(OP_ERROR + ".message"); //$NON-NLS-1$
+       private static final String[] EMPTY_ARR = new String[0]; 
+       
+       protected IConfigurationElement fConfigElement;
+       protected CDTMainWizardPage fMainPage;
+       
+       protected IProject newProject;
+       private String wz_title;
+       private String wz_desc;
+       
+       private boolean existingPath = false;
+       private String lastProjectName = null;
+       private URI lastProjectLocation = null;
+       private CWizardHandler savedHandler = null;
+
+       public CDTCommonProjectWizard() {
+               this(Messages.NewModelProjectWizard_0,Messages.NewModelProjectWizard_1); 
+       }
+
+       public CDTCommonProjectWizard(String title, String desc) {
+               super();
+               setDialogSettings(CUIPlugin.getDefault().getDialogSettings());
+               setNeedsProgressMonitor(true);
+               setForcePreviousAndNextButtons(true);
+               setWindowTitle(title);
+               wz_title = title;
+               wz_desc = desc;
+       }
+       
+       @Override
+       public void addPages() {
+               fMainPage= new CDTMainWizardPage(CUIPlugin.getResourceString(PREFIX));
+               fMainPage.setTitle(wz_title);
+               fMainPage.setDescription(wz_desc);
+               addPage(fMainPage);
+       }
+
+       /**
+        * @return true if user has changed settings since project creation
+        */
+       private boolean isChanged() {
+               if (savedHandler != fMainPage.h_selected)
+                       return true;
+
+               if (!fMainPage.getProjectName().equals(lastProjectName))
+                       return true;
+                       
+               URI projectLocation = fMainPage.getProjectLocation();
+               if (projectLocation == null) {
+                       if (lastProjectLocation != null)
+                               return true;
+               } else if (!projectLocation.equals(lastProjectLocation))
+                       return true;
+               
+               return savedHandler.isChanged(); 
+       }
+
+       public IProject getProject(boolean defaults) {
+               return getProject(defaults, true);
+       }
+
+       public IProject getProject(boolean defaults, boolean onFinish) {
+               if (newProject != null && isChanged()) 
+                       clearProject(); 
+               if (newProject == null) {
+            existingPath = false;
+                       try {
+                               IFileStore fs;
+                               URI p = fMainPage.getProjectLocation();
+                               if (p == null) { 
+                                       fs = EFS.getStore(ResourcesPlugin.getWorkspace().getRoot().getLocationURI());
+                                   fs = fs.getChild(fMainPage.getProjectName());
+                               } else
+                                       fs = EFS.getStore(p);
+                               IFileInfo f = fs.fetchInfo();
+                               if (f.exists() && f.isDirectory()) {
+                                       if (fs.getChild(".project").fetchInfo().exists()) { //$NON-NLS-1$
+                                               if (!MessageDialog.openConfirm(getShell(), Messages.CDTCommonProjectWizard_0, Messages.CDTCommonProjectWizard_1))
+                                       return null;
+                       }
+                       existingPath = true;
+                               }
+               } catch (CoreException e) {
+                       CUIPlugin.log(e.getStatus());
+               }
+                       savedHandler = fMainPage.h_selected;
+                       savedHandler.saveState();
+                       lastProjectName = fMainPage.getProjectName();
+                       lastProjectLocation = fMainPage.getProjectLocation();
+                       // start creation process
+                       invokeRunnable(getRunnable(defaults, onFinish)); 
+               } 
+               return newProject;
+       }
+
+       /**
+        * Remove created project either after error
+        * or if user returned back from config page. 
+        */
+       private void clearProject() {
+               if (lastProjectName == null) return;
+               try {
+                       ResourcesPlugin.getWorkspace().getRoot().getProject(lastProjectName).delete(!existingPath, true, null);
+               } catch (CoreException ignore) {}
+               newProject = null;
+               lastProjectName = null;
+               lastProjectLocation = null;
+       }
+       
+       private boolean invokeRunnable(IRunnableWithProgress runnable) {
+               IRunnableWithProgress op= new WorkspaceModifyDelegatingOperation(runnable);
+               try {
+                       getContainer().run(true, true, op);
+               } catch (InvocationTargetException e) {
+                       CUIPlugin.errorDialog(getShell(), title, message, e.getTargetException(), true);
+                       clearProject();
+                       return false;
+               } catch  (InterruptedException e) {
+                       clearProject();
+                       return false;
+               }
+               return true;
+       }
+
+       @Override
+       public boolean performFinish() {
+               boolean needsPost = (newProject != null && !isChanged());
+               // create project if it is not created yet
+               if (getProject(fMainPage.isCurrent(), true) == null) 
+                       return false;
+               fMainPage.h_selected.postProcess(newProject, needsPost);
+               try {
+                       setCreated();
+               } catch (CoreException e) {
+                       e.printStackTrace();
+                       return false;
+               }
+               BasicNewProjectResourceWizard.updatePerspective(fConfigElement);
+               selectAndReveal(newProject);
+               return true;
+       }
+       
+       protected boolean setCreated() throws CoreException {
+               ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
+               
+               ICProjectDescription des = mngr.getProjectDescription(newProject, false);
+               
+               if(des == null ) {
+                       return false;
+               }
+               
+               if(des.isCdtProjectCreating()){
+                       des = mngr.getProjectDescription(newProject, true);
+                       des.setCdtProjectCreated();
+                       mngr.setProjectDescription(newProject, des, false, null);
+                       return true;
+               }
+               return false;
+       }
+       
+    @Override
+       public boolean performCancel() {
+       clearProject();
+        return true;
+    }
+
+       public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
+               fConfigElement= config;
+       }
+
+       private IRunnableWithProgress getRunnable(boolean _defaults, final boolean onFinish) {
+               final boolean defaults = _defaults;
+               return new IRunnableWithProgress() {
+                       public void run(IProgressMonitor imonitor) throws InvocationTargetException, InterruptedException {
+                               final Exception except[] = new Exception[1];
+                               getShell().getDisplay().syncExec(new Runnable() {
+                                       public void run() {
+                                               IRunnableWithProgress op= new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() {
+                                                       public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+                                                               final IProgressMonitor fMonitor;
+                                                               if (monitor == null) {
+                                                                       fMonitor= new NullProgressMonitor();
+                                                               } else {
+                                                                       fMonitor = monitor;
+                                                               }
+                                                               fMonitor.beginTask(CUIPlugin.getResourceString("CProjectWizard.op_description"), 100); //$NON-NLS-1$
+                                                               fMonitor.worked(10);
+                                                               try {                                                   
+                                                                       newProject = createIProject(lastProjectName, lastProjectLocation, new SubProgressMonitor(fMonitor, 40));
+                                                                       if (newProject != null) 
+                                                                               fMainPage.h_selected.createProject(newProject, defaults, onFinish, new SubProgressMonitor(fMonitor, 40));
+                                                                       fMonitor.worked(10);
+                                                               } catch (CoreException e) {     CUIPlugin.log(e); }
+                                                               finally {
+                                                                       fMonitor.done();
+                                                               }
+                                                       }
+                                               });
+                                               try {
+                                                       getContainer().run(false, true, op);
+                                               } catch (InvocationTargetException e) {
+                                                       except[0] = e;
+                                               } catch (InterruptedException e) {
+                                                       except[0] = e;
+                                               }
+                                       }
+                               });
+                               if (except[0] != null) {
+                                       if (except[0] instanceof InvocationTargetException) {
+                                               throw (InvocationTargetException)except[0];
+                                       }
+                                       if (except[0] instanceof InterruptedException) {
+                                               throw (InterruptedException)except[0];
+                                       }
+                                       throw new InvocationTargetException(except[0]);
+                               }                                       
+                       }
+               };
+       }
+       
+       public IProject createIProject(final String name, final URI location) throws CoreException{
+               return createIProject(name, location, new NullProgressMonitor());
+       }
+       
+       /**
+        * @since 5.1
+        */
+       protected IProgressMonitor continueCreationMonitor;
+
+       /**
+        * @param monitor 
+        * @since 5.1
+        * 
+        */     
+       public IProject createIProject(final String name, final URI location, IProgressMonitor monitor) throws CoreException{
+               
+               monitor.beginTask(Messages.CDTCommonProjectWizard_creatingProject, 100); 
+               
+               if (newProject != null) return newProject;
+               
+               IWorkspace workspace = ResourcesPlugin.getWorkspace();
+               IWorkspaceRoot root = workspace.getRoot();
+               final IProject newProjectHandle = root.getProject(name);
+               
+               if (!newProjectHandle.exists()) {
+//                     IWorkspaceDescription workspaceDesc = workspace.getDescription();
+//                     workspaceDesc.setAutoBuilding(false);
+//                     workspace.setDescription(workspaceDesc);
+                       IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName());
+                       if(location != null)
+                               description.setLocationURI(location);
+                       newProject = CCorePlugin.getDefault().createCDTProject(description, newProjectHandle, new SubProgressMonitor(monitor,25));
+               } else {
+                       IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
+                               public void run(IProgressMonitor monitor) throws CoreException {
+                                       newProjectHandle.refreshLocal(IResource.DEPTH_INFINITE, monitor);
+                               }
+                       };
+                       workspace.run(runnable, root, IWorkspace.AVOID_UPDATE, new SubProgressMonitor(monitor,25));
+                       newProject = newProjectHandle;
+               }
+        
+               // Open the project if we have to
+               if (!newProject.isOpen()) {
+                       newProject.open(new SubProgressMonitor(monitor,25));
+               }
+               
+               continueCreationMonitor = new SubProgressMonitor(monitor,25);
+               IProject proj = continueCreation(newProject);
+               
+               monitor.done();
+               
+               return proj;    
+       }
+       
+       protected abstract IProject continueCreation(IProject prj); 
+       public abstract String[] getNatures();
+       
+       @Override
+       public void dispose() {
+               fMainPage.dispose();
+       }
+       
+    @Override
+       public boolean canFinish() {
+       if (fMainPage.h_selected != null) {
+               if(!fMainPage.h_selected.canFinish())
+                       return false;
+               String s = fMainPage.h_selected.getErrorMessage();
+               if (s != null) return false;
+       }
+       return super.canFinish();
+    }
+    /**
+     * Returns last project name used for creation
+     */
+       public String getLastProjectName() {
+               return lastProjectName;
+       }
+
+       public URI getLastProjectLocation() {
+               return lastProjectLocation;
+       }
+
+       public IProject getLastProject() {
+               return newProject;
+       }
+
+       // Methods below should provide data for language check
+       public String[] getLanguageIDs (){
+               String[] contentTypeIds = getContentTypeIDs();
+               if(contentTypeIds.length > 0) {
+                       IContentTypeManager manager = Platform.getContentTypeManager();
+                       List<String> languageIDs = new ArrayList<String>();
+                       for(int i = 0; i < contentTypeIds.length; ++i) {
+                               IContentType contentType = manager.getContentType(contentTypeIds[i]);
+                               if(null != contentType) {
+                                       ILanguage language = LanguageManager.getInstance().getLanguage(contentType);
+                                       if(!languageIDs.contains(language.getId())) {
+                                               languageIDs.add(language.getId());
+                                       }
+                               }
+                       }
+                       return languageIDs.toArray(new String[languageIDs.size()]);
+               }
+               return EMPTY_ARR;
+       }
+       public String[] getContentTypeIDs (){
+               return EMPTY_ARR;
+       }
+       public String[] getExtensions (){
+               String[] contentTypeIds = getContentTypeIDs();
+               if(contentTypeIds.length > 0) {
+                       IContentTypeManager manager = Platform.getContentTypeManager();
+                       List<String> extensions = new ArrayList<String>();
+                       for(int i = 0; i < contentTypeIds.length; ++i) {
+                               IContentType contentType = manager.getContentType(contentTypeIds[i]);
+                               if(null != contentType) {
+                                       String[] thisTypeExtensions = contentType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
+                                       extensions.addAll(Arrays.asList(thisTypeExtensions));
+                               }
+                       }
+                       return extensions.toArray(new String[extensions.size()]);
+               }
+               return EMPTY_ARR;
+       }
+       
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTMainWizardPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTMainWizardPage.java
new file mode 100644 (file)
index 0000000..d6ec655
--- /dev/null
@@ -0,0 +1,493 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *     IBM Corporation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.wizards;
+       import java.net.URI;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileInfo;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.osgi.util.TextProcessor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleAdapter;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
+
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.newui.CDTPrefUtil;
+import org.eclipse.cdt.ui.newui.PageLayout;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+       public class CDTMainWizardPage extends WizardNewProjectCreationPage implements IWizardItemsListListener {
+               private static final Image IMG_CATEGORY = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_SEARCHFOLDER);
+               private static final Image IMG_ITEM = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_VARIABLE);
+
+               public static final String PAGE_ID = "org.eclipse.cdt.managedbuilder.ui.wizard.NewModelProjectWizardPage"; //$NON-NLS-1$
+
+               private static final String EXTENSION_POINT_ID = "org.eclipse.cdt.ui.CDTWizard"; //$NON-NLS-1$
+               private static final String ELEMENT_NAME = "wizard"; //$NON-NLS-1$
+               private static final String CLASS_NAME = "class"; //$NON-NLS-1$
+               public static final String DESC = "EntryDescriptor"; //$NON-NLS-1$ 
+
+           // widgets
+           private Tree tree;
+           private Composite right;
+           private Button show_sup;
+           private Label right_label;
+   
+           public CWizardHandler h_selected = null;
+               private Label categorySelectedLabel;
+
+           /**
+            * Creates a new project creation wizard page.
+            *
+            * @param pageName the name of this page
+            */
+           public CDTMainWizardPage(String pageName) {
+               super(pageName);
+               setPageComplete(false);
+           }
+
+           /** (non-Javadoc)
+            * Method declared on IDialogPage.
+            */
+           @Override
+               public void createControl(Composite parent) {
+               super.createControl(parent);
+               
+               createDynamicGroup((Composite)getControl()); 
+                       switchTo(updateData(tree, right, show_sup, CDTMainWizardPage.this, getWizard()),
+                                       getDescriptor(tree));
+
+                       setPageComplete(validatePage());
+               setErrorMessage(null);
+               setMessage(null);
+           }
+           
+           private void createDynamicGroup(Composite parent) {
+               Composite c = new Composite(parent, SWT.NONE);
+               c.setLayoutData(new GridData(GridData.FILL_BOTH));
+               c.setLayout(new GridLayout(2, true));
+               
+               Label l1 = new Label(c, SWT.NONE);
+               l1.setText(Messages.CMainWizardPage_0); 
+               l1.setFont(parent.getFont());
+               l1.setLayoutData(new GridData(GridData.BEGINNING));
+               
+               right_label = new Label(c, SWT.NONE);
+               right_label.setFont(parent.getFont());
+               right_label.setLayoutData(new GridData(GridData.BEGINNING));
+               
+               tree = new Tree(c, SWT.SINGLE | SWT.BORDER);
+               tree.setLayoutData(new GridData(GridData.FILL_BOTH));
+               tree.addSelectionListener(new SelectionAdapter() {
+                               @Override
+                               public void widgetSelected(SelectionEvent e) {
+                                       TreeItem[] tis = tree.getSelection();
+                                       if (tis == null || tis.length == 0) return;
+                                       switchTo((CWizardHandler)tis[0].getData(), (EntryDescriptor)tis[0].getData(DESC));
+                                       setPageComplete(validatePage());
+                               }});
+               tree.getAccessible().addAccessibleListener(
+                                        new AccessibleAdapter() {                       
+                                @Override
+                                               public void getName(AccessibleEvent e) {
+                                        for (int i = 0; i < tree.getItemCount(); i++) {
+                                                if (tree.getItem(i).getText().equals(e.result))
+                                                        return;
+                                        }
+                                e.result = Messages.CMainWizardPage_0; 
+                                }
+                            }
+                                );
+               right = new Composite(c, SWT.NONE);
+               right.setLayoutData(new GridData(GridData.FILL_BOTH));
+               right.setLayout(new PageLayout());
+
+               show_sup = new Button(c, SWT.CHECK);
+               show_sup.setText(Messages.CMainWizardPage_1); 
+               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = 2;
+               show_sup.setLayoutData(gd);
+               show_sup.addSelectionListener(new SelectionAdapter() {
+                               @Override
+                               public void widgetSelected(SelectionEvent e) {
+                                       if (h_selected != null)
+                                               h_selected.setSupportedOnly(show_sup.getSelection());
+                                       switchTo(updateData(tree, right, show_sup, CDTMainWizardPage.this, getWizard()),
+                                                       getDescriptor(tree));
+                               }} );
+
+               // restore settings from preferences
+                       show_sup.setSelection(!CDTPrefUtil.getBool(CDTPrefUtil.KEY_NOSUPP));
+           }
+           
+           @Override
+               public IWizardPage getNextPage() {
+                       return (h_selected == null) ? null : h_selected.getSpecificPage();
+           }           
+
+           public URI getProjectLocation() {
+               return useDefaults() ? null : getLocationURI();
+           }
+
+           /**
+            * Returns whether this page's controls currently all contain valid 
+            * values.
+            *
+            * @return <code>true</code> if all controls are valid, and
+            *   <code>false</code> if at least one is invalid
+            */
+           @Override
+               protected boolean validatePage() {
+               setMessage(null);
+               if (!super.validatePage())
+                       return false;
+
+               if (getProjectName().indexOf('#') >= 0) {
+                   setErrorMessage(Messages.CDTMainWizardPage_0);                   
+                   return false;
+               }
+               
+               boolean bad = true; // should we treat existing project as error
+               
+               IProject handle = getProjectHandle();
+               if (handle.exists()) {
+                       if (getWizard() instanceof IWizardWithMemory) {
+                               IWizardWithMemory w = (IWizardWithMemory)getWizard();
+                               if (w.getLastProjectName() != null && w.getLastProjectName().equals(getProjectName()))
+                                       bad = false;
+                       }
+                       if (bad) { 
+                               setErrorMessage(Messages.CMainWizardPage_10); 
+                           return false;
+                       }
+               }
+
+               if (bad) { // skip this check if project already created 
+                       try {
+                               IFileStore fs;
+                               URI p = getProjectLocation();
+                               if (p == null) {
+                                       fs = EFS.getStore(ResourcesPlugin.getWorkspace().getRoot().getLocationURI());
+                                       fs = fs.getChild(getProjectName());
+                               } else
+                                       fs = EFS.getStore(p);
+                               IFileInfo f = fs.fetchInfo();
+                               if (f.exists()) {
+                                       if (f.isDirectory()) {
+                                               setMessage(Messages.CMainWizardPage_7, IMessageProvider.WARNING); 
+                                       } else {
+                                               setErrorMessage(Messages.CMainWizardPage_6); 
+                                               return false;
+                                       }
+                               }
+                       } catch (CoreException e) {
+                               CUIPlugin.log(e.getStatus());
+                       }
+               }
+               
+               if (!useDefaults()) {
+                   IStatus locationStatus = ResourcesPlugin.getWorkspace().validateProjectLocationURI(handle,
+                               getLocationURI());
+                   if (!locationStatus.isOK()) {
+                       setErrorMessage(locationStatus.getMessage());
+                       return false;
+                   }
+               }
+
+               if (tree.getItemCount() == 0) {
+                       setErrorMessage(Messages.CMainWizardPage_3); 
+                       return false;
+               }
+               
+               // it is not an error, but we cannot continue
+               if (h_selected == null) {
+                   setErrorMessage(null);
+                       return false;                   
+               }
+
+               String s = h_selected.getErrorMessage(); 
+                       if (s != null) {
+                       setErrorMessage(s);
+                       return false;
+               }
+               
+            setErrorMessage(null);
+               return true;
+           }
+
+           /**
+            * 
+            * @param tree
+            * @param right
+            * @param show_sup
+            * @param ls
+            * @param wizard
+            * @return : selected Wizard Handler.
+            */
+               public static CWizardHandler updateData(Tree tree, Composite right, Button show_sup, IWizardItemsListListener ls, IWizard wizard) {
+                       // remember selected item
+                       TreeItem[] selection = tree.getSelection();
+                       TreeItem selectedItem = selection.length>0 ? selection[0] : null; 
+                       String savedLabel = selectedItem!=null ? selectedItem.getText() : null;
+                       String savedParentLabel = getParentText(selectedItem);
+                       
+                       tree.removeAll();
+                       IExtensionPoint extensionPoint =
+                                   Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_ID);
+                       if (extensionPoint == null) return null;
+                       IExtension[] extensions = extensionPoint.getExtensions();
+                       if (extensions == null) return null;
+                       
+                       List<EntryDescriptor> items = new ArrayList<EntryDescriptor>();
+                       for (int i = 0; i < extensions.length; ++i)     {
+                               IConfigurationElement[] elements = extensions[i].getConfigurationElements();
+                               for (IConfigurationElement element : elements) {
+                                       if (element.getName().equals(ELEMENT_NAME)) {
+                                               CNewWizard w = null;
+                                               try {
+                                                       w = (CNewWizard) element.createExecutableExtension(CLASS_NAME);
+                                               } catch (CoreException e) {
+                                                       System.out.println(Messages.CMainWizardPage_5 + e.getLocalizedMessage()); 
+                                                       return null; 
+                                               }
+                                               if (w == null) return null;
+                                               w.setDependentControl(right, ls);
+                                               for (EntryDescriptor ed : w.createItems(show_sup.getSelection(), wizard))       
+                                                       items.add(ed);
+                                       }
+                               }
+                       }
+                       // If there is a EntryDescriptor which is default for category, make sure it 
+                       // is in the front of the list.
+                       for (int i = 0; i < items.size(); ++i)
+                       {
+                               EntryDescriptor ed = items.get(i);
+                               if (ed.isDefaultForCategory())
+                               {
+                                       items.remove(i);
+                                       items.add(0, ed);
+                                       break;
+                               }                               
+                       }
+                       
+                       // bug # 211935 : allow items filtering.
+                       if (ls != null) // NULL means call from prefs
+                               items = ls.filterItems(items);
+                       addItemsToTree(tree, items);
+                       
+                       if (tree.getItemCount() > 0) {
+                               TreeItem target = null;
+                               // try to search item which was selected before
+                               if (savedLabel!=null) {
+                                       target = findItem(tree, savedLabel, savedParentLabel);
+                               }
+                               if (target == null) {
+                                       target = tree.getItem(0);
+                                       if (target.getItemCount() != 0)
+                                               target = target.getItem(0);
+                               }
+                               tree.setSelection(target);
+                               return (CWizardHandler)target.getData();
+                       }
+                       return null;
+               }
+
+               private static String getParentText(TreeItem item) {
+                       if (item==null || item.getParentItem()==null)
+                               return ""; //$NON-NLS-1$
+                       return item.getParentItem().getText();
+               }
+
+               private static TreeItem findItem(Tree tree, String label, String parentLabel) {
+                       for (TreeItem item : tree.getItems()) {
+                               TreeItem foundItem = findTreeItem(item, label, parentLabel);
+                               if (foundItem!=null)
+                                       return foundItem;
+                       }
+                       return null;
+               }
+
+               private static TreeItem findTreeItem(TreeItem item, String label, String parentLabel) {
+                       if (item.getText().equals(label) && getParentText(item).equals(parentLabel))
+                               return item;
+                       
+                       for (TreeItem child : item.getItems()) {
+                               TreeItem foundItem = findTreeItem(child, label, parentLabel);
+                               if (foundItem!=null)
+                                       return foundItem;
+                       }
+                       return null;
+               }
+
+               private static void addItemsToTree(Tree tree, List<EntryDescriptor> items) {
+               //  Sorting is disabled because of users requests       
+               //      Collections.sort(items, CDTListComparator.getInstance());
+                       
+                       ArrayList<TreeItem> placedTreeItemsList = new ArrayList<TreeItem>(items.size());
+                       ArrayList<EntryDescriptor> placedEntryDescriptorsList = new ArrayList<EntryDescriptor>(items.size());
+                       for (EntryDescriptor wd : items) {
+                               if (wd.getParentId() == null) {
+                                       wd.setPath(wd.getId());
+                                       TreeItem ti = new TreeItem(tree, SWT.NONE);
+                                       ti.setText(TextProcessor.process(wd.getName()));
+                                       ti.setData(wd.getHandler());
+                                       ti.setData(DESC, wd);
+                                       ti.setImage(calcImage(wd));
+                                       placedTreeItemsList.add(ti);
+                                       placedEntryDescriptorsList.add(wd);
+                               }
+                       }
+                       while(true) {
+                               boolean found = false;
+                               Iterator<EntryDescriptor> it2 = items.iterator();
+                               while (it2.hasNext()) {
+                                       EntryDescriptor wd1 = it2.next();
+                                       if (wd1.getParentId() == null) continue;
+                                       for (int i = 0; i< placedEntryDescriptorsList.size(); i++) {
+                                               EntryDescriptor wd2 = placedEntryDescriptorsList.get(i);
+                                               if (wd2.getId().equals(wd1.getParentId())) {
+                                                       found = true;
+                                                       wd1.setParentId(null);
+                                                       CWizardHandler h = wd2.getHandler();
+                                                       /* If neither wd1 itself, nor its parent (wd2) have a handler
+                                                        * associated with them, and the item is not a category,
+                                                        * then skip it. If it's category, then it's possible that
+                                                        * children will have a handler associated with them.
+                                                        */
+                                                       if (h == null && wd1.getHandler() == null && !wd1.isCategory())
+                                                               break;
+
+                                                       wd1.setPath(wd2.getPath() + "/" + wd1.getId()); //$NON-NLS-1$
+                                                       wd1.setParent(wd2);
+                                                       if (h != null) {
+                                                               if (wd1.getHandler() == null && !wd1.isCategory())
+                                                                       wd1.setHandler((CWizardHandler)h.clone());
+                                                               if (!h.isApplicable(wd1))
+                                                                       break;
+                                                       }
+                                                       
+                                                       TreeItem p = placedTreeItemsList.get(i);
+                                                       TreeItem ti = new TreeItem(p, SWT.NONE);
+                                                       ti.setText(wd1.getName());
+                                                       ti.setData(wd1.getHandler());
+                                                       ti.setData(DESC, wd1);
+                                                       ti.setImage(calcImage(wd1));
+                                                       placedTreeItemsList.add(ti);
+                                                       placedEntryDescriptorsList.add(wd1);
+                                                       break;
+                                               }
+                                       }
+                               }
+                               // repeat iterations until all items are placed.
+                               if (!found) break;
+                       }
+                       // orphan elements (with not-existing parentId) are ignored
+               }
+
+               private void switchTo(CWizardHandler h, EntryDescriptor ed) {
+                       if (h == null) 
+                               h = ed.getHandler();
+                       if (ed.isCategory())
+                               h = null;
+                       try {
+                               if (h != null) 
+                                       h.initialize(ed);
+                       } catch (CoreException e) { 
+                               h = null;
+                       }
+                       if (h_selected != null) 
+                               h_selected.handleUnSelection();
+                       h_selected = h;
+                       if (h == null) {
+                               if (ed.isCategory()) {
+                                       if (categorySelectedLabel == null) {
+                                               categorySelectedLabel = new Label(right, SWT.WRAP);
+                                               categorySelectedLabel.setText(
+                                                               Messages.CDTMainWizardPage_1);  
+                                               right.layout();
+                                       }
+                                       categorySelectedLabel.setVisible(true);
+                               }
+                               return;
+                       }
+                       right_label.setText(h_selected.getHeader());
+                       if (categorySelectedLabel != null)
+                               categorySelectedLabel.setVisible(false);
+                       h_selected.handleSelection();
+                       h_selected.setSupportedOnly(show_sup.getSelection());
+               }
+
+
+               public static EntryDescriptor getDescriptor(Tree _tree) {
+                       TreeItem[] sel = _tree.getSelection();
+                       if (sel == null || sel.length == 0) 
+                               return null;
+                       return (EntryDescriptor)sel[0].getData(DESC);
+               }
+               
+               public void toolChainListChanged(int count) {
+                       setPageComplete(validatePage());
+                       getWizard().getContainer().updateButtons();
+               }
+
+               public boolean isCurrent() { return isCurrentPage(); }
+               
+               private static Image calcImage(EntryDescriptor ed) {
+                       if (ed.getImage() != null) return ed.getImage();
+                       if (ed.isCategory()) return IMG_CATEGORY;
+                       return IMG_ITEM;
+               }
+
+               @SuppressWarnings({ "unchecked", "rawtypes" })
+               public List filterItems(List items) {
+                       List<EntryDescriptor> ret = new ArrayList<EntryDescriptor>();
+                       
+                       for(Object item: items) {
+                               if(item instanceof EntryDescriptor) {
+                                       if(((EntryDescriptor)(item)).getId().contains("samsung") == true || ((EntryDescriptor)(item)).getId().contains("tizen") == true) {                                              
+                                       }
+                                       else {
+                                               ret.add((EntryDescriptor)item);
+                                       }
+                               }
+                       }
+                       return ret;
+               }
+}
+
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTProjectWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CDTProjectWizard.java
new file mode 100644 (file)
index 0000000..d6f8eb0
--- /dev/null
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.wizards;
+
+import org.eclipse.core.resources.IProject;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+public class CDTProjectWizard extends CDTCommonProjectWizard {
+
+       public CDTProjectWizard() {
+               super(Messages.NewModelProjectWizard_0, Messages.NewModelProjectWizard_1); 
+       }
+       
+       @Override
+       public String[] getNatures() {
+               return new String[0];
+       }
+
+       @Override
+       protected IProject continueCreation(IProject prj) {
+               return prj;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CNewWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CNewWizard.java
new file mode 100644 (file)
index 0000000..58c62d8
--- /dev/null
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.wizards;
+
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.swt.widgets.Composite;
+
+
+/**
+ * Interface to be used by extension point:
+ * org.eclipse.cdt.managedbuilder.ui.CDTWizard
+ * 
+ * Implementors should provide 1 or more
+ * items in "Project types" list (left pane on
+ * the 1st page in any CDT new project wizard) 
+ */
+public abstract class CNewWizard {
+       /**
+        * Creates tree items to be displayed in left pane.
+        * 
+        * Method should add 1 or more tree items, 
+        * each of them should have data object attached,
+        * data should be lt;ICProjectTypeHandler&gt; 
+     *
+        * @param supportedOnly - whether display supported types only
+        * @param wizard - New Project wizard to be passed to ICWizardHandler 
+        */
+       public abstract EntryDescriptor[] createItems(boolean supportedOnly, IWizard wizard);
+       
+       /**
+        * Implementor will be informed about widget where additional
+        * data should be displayed. Normally, it is right pane in the
+        * 1st Wizard page.
+        * 
+        * @param parent - composite where widgets are to be created
+        * @param page   - reference to object which will be informed
+        *                 about changes (usually 1st page in Wizard)
+        *                 May be null if notification is not required
+        *                 or implementor does not really support it. 
+        */
+       public void setDependentControl(Composite parent, IWizardItemsListListener page){
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CProjectWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CProjectWizard.java
new file mode 100644 (file)
index 0000000..0652277
--- /dev/null
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *     IBM Corporation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.wizards;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.CProjectNature;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * The wizard to create new MBS C Project.
+ */
+public class CProjectWizard extends CDTCommonProjectWizard {
+
+       public CProjectWizard() {
+               super(Messages.NewModelProjectWizard_4, Messages.NewModelProjectWizard_5);
+       }
+
+       @Override
+       public String[] getNatures() {
+               return new String[] { CProjectNature.C_NATURE_ID };
+       }
+       
+       @Override
+       protected IProject continueCreation(IProject prj) {
+               if (continueCreationMonitor == null) {
+                       continueCreationMonitor = new NullProgressMonitor();
+               }
+               
+               try {
+                       continueCreationMonitor.beginTask(Messages.CProjectWizard_0, 1);
+                       CProjectNature.addCNature(prj, new SubProgressMonitor(continueCreationMonitor, 1));
+               } catch (CoreException e) {}
+               finally {continueCreationMonitor.done();}
+               return prj;
+       }
+
+       @Override
+       public String[] getContentTypeIDs() {
+               return new String[] { CCorePlugin.CONTENT_TYPE_CSOURCE, CCorePlugin.CONTENT_TYPE_CHEADER };
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CWizardHandler.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/CWizardHandler.java
new file mode 100644 (file)
index 0000000..c1356f5
--- /dev/null
@@ -0,0 +1,302 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *     IBM Corporation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.wizards;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.newui.CDTPrefUtil;
+
+/**
+ * This class is basic implementation for ICWizardHandler interface.
+ * It is independent of managed build system, and, so, almost useless
+ * It creates "empty" project with no specific.
+ * 
+ * Its descendants should overwrite some methods,
+ * including createProject() and handleSelection()
+ * 
+ * This object is created per each Project type
+ * on the left pane of New Project Wizard page 
+ *  
+ * It is responsible for:
+ * - corresponding line in left pane of 1st wizard page
+ * - whole view of right pane
+ * - processing preferred items, if any.
+ * - providing data for ConfigPage
+ * - processing data received from config page 
+ *
+ */
+public class CWizardHandler implements Cloneable {
+       protected static final Image IMG0 = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_EMPTY);
+       protected static final Image IMG1 = CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_PREFERRED);
+       
+       protected String head;
+       protected String name;
+       protected Composite parent;
+       protected Table table;
+       protected boolean supportedOnly = true;
+       
+       public CWizardHandler(Composite _parent, String _head, String _name) {
+               parent = _parent;
+               head = _head;
+               name = _name;
+       }
+
+       /**
+        * Called when user selects corresponding item in wizard tree
+        * 
+        * @parame pane - parent for handler-specific data    
+        */
+       public void handleSelection() {
+               List<String> preferred = CDTPrefUtil.getPreferredTCs();
+               if (table == null) {
+                       table = new Table(parent, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);
+                       TableItem ti = new TableItem(table, SWT.NONE);
+                       ti.setText("---"); //$NON-NLS-1$
+                       ti.setImage(IMG0);
+                       table.select(0);
+               }
+               updatePreferred(preferred);
+               table.setVisible(true);
+               parent.layout();
+       }
+
+       /**
+        * Called when user leaves corresponding item in wizard tree 
+        */
+       public void handleUnSelection() {
+               if (table != null) {
+                       table.setVisible(false);
+               }
+       }
+       
+       /**
+        * @return text for label above handler-specific pane
+        */
+       public String getHeader() { return head; }
+
+       /**
+        * @return text for label in left tree
+        */
+       public String getName() { return name; }
+
+       /**
+        * @return null if data is consistent
+        *         else returns error message 
+        */
+       public String getErrorMessage() { return null; }
+
+       /**
+        * Defines whether only supported project types and toolchains are displayed
+        * @param supp 
+        */
+       public void setSupportedOnly(boolean supp) { supportedOnly = supp;}
+
+       /**
+        * @return true if only supported project types and toolchains are displayed
+        */
+       public boolean supportedOnly() { return supportedOnly; }
+
+       /**
+        * @return true if handler is able to process preferred toolchains
+        */
+       public boolean supportsPreferred() { return false; }
+
+       /**
+        * @return 1st handler-specific page
+        */
+       public IWizardPage getSpecificPage() { return null; }
+
+       /**
+        * Asks handler to update its data according to preferred list.
+        * Usually, marks preferred toolchains somehow (icon, font etc)
+        * @param prefs - list of strings (preferred Toolchain IDs)
+        */
+       public void updatePreferred(List<String> prefs) {}
+
+       /**
+        * Creates project
+        * 
+        * @param proj - simple project to be used as base
+        * @param defaults - true if called from 1st Wizard page
+        * @throws CoreException
+        */
+       public void createProject(IProject proj, boolean defaults)
+                       throws CoreException {}
+
+       /**
+        * Creates project
+        * 
+        * @param proj - simple project to be used as base
+        * @param defaults - true if called from 1st Wizard page
+        * @param onFinish - true when the project creation is performed on finish. false -otherwise
+        * false means that the project created is actually a temporary one that can be removed in case cancel is pressed
+        * 
+        * @throws CoreException
+        */
+       public void createProject(IProject proj, boolean defaults, boolean onFinish)
+                       throws CoreException {
+               createProject(proj, defaults);
+       }
+       
+
+       /**
+        * Creates project
+        * 
+        * @param proj - simple project to be used as base
+        * @param defaults - true if called from 1st Wizard page
+        * @param monitor - progress monitor to track the creation process
+        * @throws CoreException
+        * @since 5.1
+        */
+       public void createProject(IProject proj, boolean defaults, IProgressMonitor monitor)
+                       throws CoreException {}
+
+       /**
+        * Creates project
+        * 
+        * @param proj - simple project to be used as base
+        * @param defaults - true if called from 1st Wizard page
+        * @param onFinish - true when the project creation is performed on finish. false -otherwise
+        * false means that the project created is actually a temporary one that can be removed in case cancel is pressed
+        * @param monitor - progress monitor to track the creation process
+        * 
+        * @throws CoreException
+        * @since 5.1
+        */
+       public void createProject(IProject proj, boolean defaults, boolean onFinish, IProgressMonitor monitor)
+                       throws CoreException {
+               createProject(proj, defaults, monitor);
+       }
+       
+       /**
+        * Converts an already created project
+        * 
+        * @param proj - the project to convert
+        * 
+        * @throws CoreException
+        * @since 5.1
+        */
+       public void convertProject(IProject proj, IProgressMonitor monitor) throws CoreException {}
+       
+       /**
+        * 
+        * @return true if settings were changed 
+        *         since last call to saveState()
+        */
+       public boolean isChanged() { return true; } 
+
+       /**
+        * Stores current internal settings 
+        */
+       public void saveState() {}
+
+       /**
+        * Called when Finish button pressed, 
+        * even if project was created before.
+        * 
+        * @param prj - affected project
+        * @param created - true if the project was created before
+        */
+       public void postProcess(IProject prj, boolean created) {
+               doTemplatesPostProcess(prj);
+               doCustom(prj);
+       }
+
+       /**
+        * Checks whether this item can be added to Wizard tree
+        * 
+        * @param data - Wizard Item data to be added 
+        *               as child to current Wizard item
+        * @return - true if item can be added.
+        */
+       public boolean isApplicable(EntryDescriptor data) { return true; }
+
+       /**
+        * Initializes the handler to be used for the specified entry
+        * 
+        * @param data - Wizard Item data to be handled 
+        * @throws CoreException
+        */
+       public void initialize(EntryDescriptor data) throws CoreException {}
+
+       public boolean canFinish() {return true;}
+
+       @Override
+       public Object clone() {
+               try {
+                       CWizardHandler clone = (CWizardHandler)super.clone();
+                       clone.parent = parent;
+                       clone.head = head;
+                       clone.name = name;
+                       return clone;
+               } catch (CloneNotSupportedException e) { return null; }
+       }
+       
+       /**
+        * @deprecated since CDT 6.1.
+        */
+       @Deprecated
+       public static String removeSpaces(String s) {
+               char[] cs = s.toCharArray();
+               StringBuffer sb = new StringBuffer();
+               for (int i=0; i<cs.length; i++) {
+                       if (Character.isWhitespace(cs[i])) 
+                               continue;
+                       sb.append(cs[i]);
+               }
+               return sb.toString();   
+       }
+       
+       /**
+        * Called after project creation in order to apply
+        * template-specific settings.
+        * 
+        * Can be called 2 or more times:
+        * - each time when user presses <Advanced Settings> button 
+        * - when user presses <Finish> button.
+        * If <Adv. settings> were not invoked, called once.
+        *   
+        * Since the project is cleared before each method call,
+        * no need to check whether it has been called before.
+        * 
+        * @param prj - affected project.
+        */
+protected void doTemplatesPostProcess(IProject prj) {}
+
+/**
+ * Called after project creation in order to apply
+ * settings from custom pages.
+ * 
+ * Can be called 2 or more times:
+ * - each time when user presses <Advanced Settings> button 
+ * - when user presses <Finish> button.
+ * If <Adv. settings> were not invoked, called once.
+ *
+ * Since the project is cleared before each doCustom() call,
+ * no need to check whether it has been called before.
+ * @param prj - affected project.
+ */
+       
+protected void doCustom(IProject prj) {}
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/EntryDescriptor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/EntryDescriptor.java
new file mode 100644 (file)
index 0000000..c8c1b6b
--- /dev/null
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.wizards;
+
+import org.eclipse.swt.graphics.Image;
+
+import org.eclipse.cdt.core.settings.model.util.CDataUtil;
+
+/**
+ * This class stores data for each tree item
+ * in "Project types" tree of New Project Wizard.
+ */
+public final class EntryDescriptor {
+       private String id = null;
+       private String name = null;
+       private boolean isCategory = false;
+       private String parentId = null;
+       private Image image = null;
+       private CWizardHandler handler = null;
+       private String path = null;
+       private EntryDescriptor parent = null;
+       private boolean isDefaultForCategory = false;
+
+       public EntryDescriptor(String _id, String _par, String _name, boolean _cat, CWizardHandler _h, Image _image) {
+               id = _id;
+               parentId = _par;
+               name = _name;
+               isCategory = _cat;
+               handler = _h;
+               image = _image;
+       }
+       // these parameters are set in constructor only
+       public String getId() {
+               return id;
+       }
+       public String getName() {
+               return name;
+       }
+       public boolean isCategory() {
+               return isCategory;
+       }
+       public Image getImage() {
+               return image;
+       }
+
+       // these parameters can be set anywhere
+       public void setParentId(String pId) {
+               parentId = pId;
+       }
+       public String getParentId() {
+               return parentId;
+       }
+       
+       public void setPath(String p) { 
+               path = p; 
+       }
+       public String getPath() { 
+               return path; 
+       }
+
+       public String[] getPathArray() { 
+               return CDataUtil.stringToArray(path, "/");  //$NON-NLS-1$
+       }
+
+       public void setParent(EntryDescriptor p) { 
+               parent = p; 
+       }
+       public EntryDescriptor getParent() { 
+               return parent; 
+       }
+
+       public void setHandler(CWizardHandler h) {
+               handler = h;
+       }
+       public CWizardHandler getHandler() {
+               return handler;
+       }
+       /**
+        * @since 5.1
+        */
+       public void setDefaultForCategory(boolean isDefaultForCategory) {
+               this.isDefaultForCategory = isDefaultForCategory;
+       }
+       /**
+        * @since 5.1
+        */
+       public boolean isDefaultForCategory() {
+               return isDefaultForCategory;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/ICPathContainerPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/ICPathContainerPage.java
new file mode 100644 (file)
index 0000000..cfba826
--- /dev/null
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.wizards;
+
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.jface.wizard.IWizardPage;
+
+/**
+ * A path container page allows the user to create a new or edit an 
+ * existing patch container entry.
+ * <p>
+ * Clients should implement this interface and include the name of their 
+ * class in an extension contributed to the cdt.ui's path container page 
+ * extension point (named <code>org.eclipse.cdt.ui.pathContainerPage
+ * </code>).
+ * </p>
+ * <p>
+ * Clients implementing this interface may subclass from 
+ * <code>org.eclipse.jface.wizard.WizardPage</code>.
+ * </p>
+ * 
+ * @deprecated - use IPathEntryContainerPage 
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+
+@Deprecated
+public interface ICPathContainerPage extends IWizardPage {
+
+       /**
+        * Method <code>initialize()</code> is called before  <code>ICPathContainerPage.setSelection</code>
+        * to give additional information about the context the path container entry is configured in. This information
+        * only reflects the underlying dialogs current selection state. The user still can make changes after the
+        * the classpath container pages has been closed or decide to cancel the operation.
+        * @param project The project the new or modified entry is added to. The project does not have to exist. 
+        * Project can be <code>null</code>.
+        * @param currentEntries The class path entries currently selected to be set as the projects classpath. This can also
+        * include the entry to be edited.
+        */
+       public void initialize(ICProject project, IPathEntry[] currentEntries);
+
+       /**
+        * Called when the classpath container wizard is closed by selecting 
+        * the finish button. Implementers typically override this method to 
+        * store the page result (new/changed path entry returned in 
+        * getSelection) into its model.
+        * 
+        * @return if the operation was succesful. Only when returned
+        * <code>true</code>, the wizard will close.
+        */
+       public boolean finish();
+       
+       /**     
+        * @return the classpath entries created on the page. 
+        */
+       public IPathEntry[] getContainerEntries();
+       
+       /**
+        * Sets the path container entry to be edited or <code>null</code> 
+        * if a new entry should be created.
+        * 
+        * @param containerEntry the classpath entry to edit or <code>null</code>.
+        * If unequals <code>null</code> then the classpath entry must be of
+        * kind <code>IClasspathEntry.CPE_CONTAINER</code>
+        */
+       public void setSelection(IPathEntry containerEntry);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/IPathEntryContainerPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/IPathEntryContainerPage.java
new file mode 100644 (file)
index 0000000..3ed2d2a
--- /dev/null
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2002, 2006 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.wizards;
+
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IContainerEntry;
+import org.eclipse.cdt.core.model.IPathEntry;
+import org.eclipse.jface.wizard.IWizardPage;
+
+/**
+ * A path container page allows the user to create a new or edit an 
+ * existing patch container entry.
+ * <p>
+ * Clients should implement this interface and include the name of their 
+ * class in an extension contributed to the cdt.ui's path container page 
+ * extension point (named <code>org.eclipse.cdt.ui.pathContainerPage
+ * </code>).
+ * </p>
+ * <p>
+ * Clients implementing this interface may subclass from 
+ * <code>org.eclipse.jface.wizard.WizardPage</code>.
+ * </p>
+ * 
+ * @deprecated as of CDT 4.0. This tab was used to set preferences/properties
+ * for 3.X style projects.
+ */
+
+@Deprecated
+public interface IPathEntryContainerPage extends IWizardPage {
+
+       /**
+        * Method <code>initialize()</code> is called before  <code>ICPathContainerPage.setSelection</code>
+        * to give additional information about the context the path container entry is configured in. This information
+        * only reflects the underlying dialogs current selection state. The user still can make changes after the
+        * the path container pages has been closed or decide to cancel the operation.
+        * @param project - The project the new or modified entry is added to. The project does not have to exist. 
+        * Project can be <code>null</code>.
+        * @param currentEntries - The path entries currently selected to be set as the projects path. This can also
+        * include the entry to be edited.
+        */
+       public void initialize(ICProject project, IPathEntry[] currentEntries);
+
+       /**
+        * Called when the path container wizard is closed by selecting 
+        * the finish button. Implementers typically override this method to 
+        * store the page result (new/changed path entry returned in 
+        * getSelection) into its model.
+        * 
+        * @return if the operation was succesful. Only when returned
+        * <code>true</code>, the wizard will close.
+        */
+       public boolean finish();
+
+       /**
+        * Method {@link #getNewContainers()} is called to get the the newly added containers. 
+        * @return the path entries created on this page. 
+        */
+       public IContainerEntry[] getNewContainers();
+
+       /**
+        * Sets the path container entry to be edited or <code>null</code> 
+        * if a new entry should be created.
+        * 
+        * @param containerEntry the path entry to edit or <code>null</code>.
+        * If unequals <code>null</code> then the path entry must be of
+        * kind <code>IPathEntry.CDT_CONTAINER</code>
+        */
+       public void setSelection(IContainerEntry containerEntry);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/IWizardItemsListListener.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/IWizardItemsListListener.java
new file mode 100644 (file)
index 0000000..144c616
--- /dev/null
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.wizards;
+
+import java.util.List;
+
+/**
+ * Interface should be implemented by some visible object
+ * (usually - 1st page in CDT New Project wizard) 
+ * to be informed about changes in tool chains selection 
+ * performed by ICNewWizard implementors.
+ */
+public interface IWizardItemsListListener {
+       /**
+        * Called by ICNewWizard instance when 
+        * user has changed tool chains selection
+        *  
+        * @param count - number of selected toolchains.
+        */
+       void toolChainListChanged(int count);
+       
+       /**
+        * @return true if this page is visible 
+        */
+       boolean isCurrent();
+
+       /**
+        * Ability to filter items which would be shown
+        * in the left pane of Main Wizard Page.
+        * Standard implementation: return unchanged list.
+        * When filtering, please note :
+        * - Each item has {@link}EntryDescriptor type
+        * - Items have hierarchical relations with others,
+        *   so removing some item(s) can break a tree. 
+        *  
+        * @param items - list of EntryDescriptor objects 
+        * @return - list with filtered items
+        */
+       List<EntryDescriptor> filterItems(List<? extends EntryDescriptor> items);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/IWizardWithMemory.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/IWizardWithMemory.java
new file mode 100644 (file)
index 0000000..8fefd31
--- /dev/null
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Intel Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.wizards;
+
+import java.net.URI;
+
+import org.eclipse.jface.wizard.IWizard;
+
+public interface IWizardWithMemory extends IWizard {
+       // returns name of last-created project
+       // or null if no projects were created
+       public String getLastProjectName(); 
+
+       public URI getLastProjectLocation(); 
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCCProjectWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCCProjectWizard.java
new file mode 100644 (file)
index 0000000..a5acabb
--- /dev/null
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.wizards;
+
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+
+/**
+ * @deprecated as of CDT 4.0. Being kept here for API compatibility only.
+ */
+@Deprecated
+public abstract class NewCCProjectWizard extends NewCProjectWizard {
+
+       public NewCCProjectWizard() {
+               super();
+               setDialogSettings(CUIPlugin.getDefault().getDialogSettings());
+       }
+
+       public NewCCProjectWizard(String title, String description) {
+               super(title, description);
+               setDialogSettings(CUIPlugin.getDefault().getDialogSettings());
+       }
+
+
+       @Override
+       protected void doRun(IProgressMonitor monitor) throws CoreException {
+               super.doRun(monitor);
+               // Add C++ Nature to the newly created project.
+        if (newProject != null){
+            CCorePlugin.getDefault().convertProjectFromCtoCC(newProject, monitor);
+        }
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizard.java
new file mode 100644 (file)
index 0000000..5c66f80
--- /dev/null
@@ -0,0 +1,349 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.wizards;
+
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+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.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
+import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+
+
+/**
+ * C Project wizard that creates a new project resource in
+ * a location of the user's choice.
+ */
+public abstract class NewCProjectWizard extends BasicNewResourceWizard implements IExecutableExtension {
+
+       private static final String OP_ERROR= "CProjectWizard.op_error"; //$NON-NLS-1$
+       private static final String OP_DESC= "CProjectWizard.op_description"; //$NON-NLS-1$
+
+       private static final String PREFIX= "CProjectWizard"; //$NON-NLS-1$
+       private static final String WZ_TITLE= "CProjectWizard.title"; //$NON-NLS-1$
+       private static final String WZ_DESC= "CProjectWizard.description"; //$NON-NLS-1$
+
+       private static final String WINDOW_TITLE = "CProjectWizard.windowTitle"; //$NON-NLS-1$
+       
+
+       private String wz_title;
+       private String wz_desc;
+//     private String op_error;
+
+       protected IConfigurationElement fConfigElement;
+       protected NewCProjectWizardPage fMainPage; 
+       protected IProject newProject;
+
+       public NewCProjectWizard() {
+               this(CUIPlugin.getResourceString(WZ_TITLE), CUIPlugin.getResourceString(WZ_DESC), 
+                       CUIPlugin.getResourceString(OP_ERROR));
+       }
+
+       public NewCProjectWizard(String title, String description) {
+               this(title, description, CUIPlugin.getResourceString(OP_ERROR));
+       }
+
+       public NewCProjectWizard(String title, String description, String error) {
+               super();
+               setDialogSettings(CUIPlugin.getDefault().getDialogSettings());
+               setNeedsProgressMonitor(true);
+               wz_title = title;
+               wz_desc = description;
+//             op_error = error;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.IWizard#addPages()
+        */             
+       @Override
+       public void addPages() {
+               fMainPage= new NewCProjectWizardPage(CUIPlugin.getResourceString(PREFIX));
+               fMainPage.setTitle(wz_title);
+               fMainPage.setDescription(wz_desc);
+               addPage(fMainPage);
+       }
+
+       protected abstract void doRunPrologue(IProgressMonitor monitor);
+
+       protected abstract void doRunEpilogue(IProgressMonitor monitor);
+
+       protected IStatus isValidName(String name) {
+               return new Status(IStatus.OK, CUIPlugin.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
+       }
+
+       /**
+        * Method isValidLocation.
+        * @param projectFieldContents
+        * @return IStatus
+        */
+       protected IStatus isValidLocation(String projectFieldContents) {
+               return new Status(IStatus.OK, CUIPlugin.PLUGIN_ID, 0, "", null); //$NON-NLS-1$
+       }
+
+       /**
+        * Gets the project location path from the main page
+        * Overwrite this method if you do not have a main page
+        */
+       protected IPath getLocationPath() throws UnsupportedOperationException {
+               if (null == fMainPage)
+                       throw new UnsupportedOperationException();
+               return fMainPage.getLocationPath();
+       }
+
+       /**
+        * Gets the project handle from the main page.
+        * Overwrite this method if you do not have a main page
+        */
+
+       public IProject getProjectHandle() throws UnsupportedOperationException {
+               if (null == fMainPage)
+                       throw new UnsupportedOperationException();
+               return fMainPage.getProjectHandle();
+       }
+
+       /**
+        * Returns the C project handle corresponding to the project defined in
+        * in the main page.
+        *
+        * @returns the C project
+        */    
+       public IProject getNewProject() {
+               return newProject;
+       }
+
+       protected IResource getSelectedResource() {
+               return getNewProject();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.IWizard#performFinish()
+        */             
+       @Override
+       public boolean performFinish() {
+               if (!invokeRunnable(getRunnable())) {
+                       return false;
+               }
+               BasicNewProjectResourceWizard.updatePerspective(fConfigElement);
+               IResource resource = getSelectedResource();
+               selectAndReveal(resource);
+               if (resource != null && resource.getType() == IResource.FILE) {
+                       IFile file = (IFile)resource;
+                       // Open editor on new file.
+                       IWorkbenchWindow dw = getWorkbench().getActiveWorkbenchWindow();
+                       if (dw != null) {
+                               try {
+                                       IWorkbenchPage page = dw.getActivePage();
+                                       if (page != null)
+                                               IDE.openEditor(page, file, true);
+                               } catch (PartInitException e) {
+                                       MessageDialog.openError(dw.getShell(),
+                                               CUIPlugin.getResourceString(OP_ERROR), e.getMessage());
+                               }
+                       }
+               }
+               return true;
+       }
+
+       /**
+        * Stores the configuration element for the wizard.  The config element will be used
+        * in <code>performFinish</code> to set the result perspective.
+        *
+        * @see IExecutableExtension#setInitializationData
+        */
+       public void setInitializationData(IConfigurationElement cfig, String propertyName, Object data) {
+               fConfigElement= cfig;
+       }
+       
+       /*
+        * Reimplemented method from superclass
+        */
+       @Override
+       protected void initializeDefaultPageImageDescriptor() {
+               setDefaultPageImageDescriptor(CPluginImages.DESC_WIZABAN_NEW_PROJ);
+       }
+
+       /* (non-Javadoc)
+        * Method declared on IWorkbenchWizard.
+        */
+       @Override
+       public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
+               super.init(workbench, currentSelection);
+               setWindowTitle(CUIPlugin.getResourceString(WINDOW_TITLE));
+       }
+
+       public IRunnableWithProgress getRunnable() {
+               return new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() {
+                       public void run(IProgressMonitor imonitor) throws InvocationTargetException, InterruptedException {
+                               final Exception except[] = new Exception[1];
+                               // ugly, need to make the wizard page run in a non ui thread so that this can go away!!!
+                               getShell().getDisplay().syncExec(new Runnable() {
+                                       public void run() {
+                                               IRunnableWithProgress op= new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() {
+                       public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+                               final IProgressMonitor fMonitor;
+                               if (monitor == null) {
+                                       fMonitor= new NullProgressMonitor();
+                               } else {
+                                       fMonitor = monitor;
+                               }
+                               fMonitor.beginTask(CUIPlugin.getResourceString(OP_DESC), 3);
+                                               doRunPrologue(new SubProgressMonitor(fMonitor, 1));
+                                               try {
+                                                       doRun(new SubProgressMonitor(fMonitor, 1));
+                                               }
+                                               catch (CoreException e) {
+                                                       except[0] = e;
+                                               }
+                                               doRunEpilogue(new SubProgressMonitor(fMonitor, 1));
+                                                               fMonitor.done();
+                                       }
+                               });
+                                               try {
+                                                       getContainer().run(false, true, op);
+                                               } catch (InvocationTargetException e) {
+                                                       except[0] = e;
+                                               } catch (InterruptedException e) {
+                                                       except[0] = e;
+                                               }
+                                       }
+                               });
+                               if (except[0] != null) {
+                                       if (except[0] instanceof InvocationTargetException) {
+                                               throw (InvocationTargetException)except[0];
+                                       }
+                                       if (except[0] instanceof InterruptedException) {
+                                               throw (InterruptedException)except[0];
+                                       }
+                                       throw new InvocationTargetException(except[0]);
+                               }
+       }
+               });
+       }
+
+       /**
+        * Utility method: call a runnable in a WorkbenchModifyDelegatingOperation
+        */
+       protected boolean invokeRunnable(IRunnableWithProgress runnable) {
+               IRunnableWithProgress op= new WorkspaceModifyDelegatingOperation(runnable);
+               try {
+                       getContainer().run(true, true, op);
+               } catch (InvocationTargetException e) {
+                       Shell shell= getShell();
+                       String title= CUIPlugin.getResourceString(OP_ERROR + ".title"); //$NON-NLS-1$
+                       String message= CUIPlugin.getResourceString(OP_ERROR + ".message"); //$NON-NLS-1$
+                       
+                       Throwable th= e.getTargetException();
+                       CUIPlugin.errorDialog(shell, title, message, th, false);
+                       try {
+                               getProjectHandle().delete(false, false, null);
+                       } catch (CoreException ignore) {
+                       } catch (UnsupportedOperationException ignore) {
+                       }
+                       return false;
+               } catch  (InterruptedException e) {
+                       return false;
+               }
+               return true;
+       }
+
+       protected void doRun(IProgressMonitor monitor) throws CoreException {
+               createNewProject(monitor);
+       }       
+
+       /**
+        * Creates a new project resource with the selected name.
+        * <p>
+        * In normal usage, this method is invoked after the user has pressed Finish on
+        * the wizard; the enablement of the Finish button implies that all controls
+        * on the pages currently contain valid values.
+        * </p>
+        * <p>
+        * Note that this wizard caches the new project once it has been successfully
+        * created; subsequent invocations of this method will answer the same
+        * project resource without attempting to create it again.
+        * </p>
+        *
+        * @return the created project resource, or <code>null</code> if the project
+        *    was not created
+        */
+       protected IProject createNewProject(IProgressMonitor monitor) throws CoreException {
+
+               if (newProject != null)
+                       return newProject;
+
+               // get a project handle
+               IProject newProjectHandle = null;
+               try {
+                       newProjectHandle = getProjectHandle();
+               } catch (UnsupportedOperationException e) {
+                       throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, e.getMessage(), null));
+               }
+
+               // get a project descriptor
+               IPath defaultPath = Platform.getLocation();
+               IPath newPath = getLocationPath();
+               if (defaultPath.equals(newPath))
+                       newPath = null;
+               IWorkspace workspace = ResourcesPlugin.getWorkspace();
+               IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName());
+               description.setLocation(newPath);
+
+               if(getBuildSystemId() != null)
+                       newProject = CCorePlugin.getDefault().createCDTProject(description, newProjectHandle, getBuildSystemId(), monitor);
+               else
+                       newProject = CCorePlugin.getDefault().createCProject(description, newProjectHandle, monitor, getProjectID());
+               
+               return newProject;
+       }
+
+
+       /**
+        * Method getID.
+        * @return String
+        */
+       public abstract String getProjectID();
+       
+       public String getBuildSystemId(){
+               return null;
+       }
+
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizardOptionPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizardOptionPage.java
new file mode 100644 (file)
index 0000000..7da60da
--- /dev/null
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Markus Schorn (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.wizards;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.widgets.Composite;
+
+import org.eclipse.cdt.ui.dialogs.ICOptionContainerExtension;
+import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
+
+/**
+ * @deprecated as of CDT 4.0. This abstract was used for New Project Wizards
+ * for 3.X style projects.
+ */
+@Deprecated
+public abstract class NewCProjectWizardOptionPage extends WizardPage implements ICOptionContainerExtension {
+
+       private TabFolderOptionBlock fOptionBlock;
+
+       public NewCProjectWizardOptionPage(String pageName) {
+               this(pageName, null, null);
+       }
+
+       public NewCProjectWizardOptionPage(String pageName, String title, ImageDescriptor titleImage) {
+               super(pageName, title, titleImage);
+       }
+
+       protected abstract TabFolderOptionBlock createOptionBlock();
+
+       public void createControl(Composite parent) {
+               fOptionBlock = createOptionBlock();
+               setControl(fOptionBlock.createContents(parent));
+       }
+
+       @Override
+       public void setVisible(boolean visible) {
+               super.setVisible(visible);
+               fOptionBlock.setVisible(visible);
+               updateContainer();
+       }
+
+       public void updateContainer() {
+               fOptionBlock.update();
+               setPageComplete(fOptionBlock.isValid());
+               setErrorMessage(fOptionBlock.getErrorMessage());
+       }
+
+       public void performApply(IProgressMonitor monitor) {
+               fOptionBlock.performApply(monitor);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.ui.dialogs.ICOptionContainer#getPreferenceStore()
+        */
+       public abstract Preferences getPreferences();
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.ui.dialogs.ICOptionContainer#getProject()
+        */
+       public IProject getProject() {
+               return ((NewCProjectWizard)getWizard()).getNewProject();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.cdt.ui.dialogs.ICOptionContainer#getProject()
+        */
+       public IProject getProjectHandle() {
+               return ((NewCProjectWizard)getWizard()).getProjectHandle();
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizardPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewCProjectWizardPage.java
new file mode 100644 (file)
index 0000000..a18e882
--- /dev/null
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *******************************************************************************/
+package org.eclipse.cdt.ui.wizards;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
+
+/**
+ * Standard main page for a wizard that is creates a project resource.
+ * <p>
+ * This page may be used by clients as-is; it may be also be subclassed to suit.
+ * </p>
+ * <p>
+ * Example useage:
+ * <pre>
+ * mainPage = new CProjectWizardPage("basicCProjectPage");
+ * mainPage.setTitle("Project");
+ * mainPage.setDescription("Create a new project resource.");
+ * </pre>
+ * </p>
+ */
+public class NewCProjectWizardPage extends WizardNewProjectCreationPage {
+
+       /**
+        *  Unique string ID for this page.  Used by Managed Build's custom page manager to refer to this page.
+        */
+       public static final String PAGE_ID = "org.eclipse.cdt.ui.wizard.basicPage"; //$NON-NLS-1$
+       
+       /* TODO: Implement proper data publishing from this wizard page.
+        * 
+        * The following items would in theory be used to publish the project name and location with
+        * the managed build system's custom wizard page manager.  However, this would create a dependency
+        * on MBS by the core, which is not very attractive.  It seems like it might be worthwhile in the future
+        * to move the data publishing capabilities of the page manager out into another, more generic class
+        * in the core.
+        * 
+        * For now, interested parties can obtain the IWizard page of this page from the page manager, cast it
+        * to a NewCProjectWizardPage, and obtain the data via its public methods.  Messy, but it avoids
+        * the unwanted dependency. 
+        * 
+        * 
+       public static final String PROJECT_NAME = "projectName"; //$NON-NLS-1$
+       public static final String PROJECT_LOCATION = "projectLocation"; //$NON-NLS-1$
+       */
+       
+       
+       public NewCProjectWizardPage(String pageName) {
+               super(pageName);
+       }
+
+       /**
+        * Returns whether this page's controls currently all contain valid 
+        * values.
+        *
+        * @return <code>true</code> if all controls are valid, and
+        *   <code>false</code> if at least one is invalid
+        */
+       @Override
+       protected boolean validatePage() {
+               if (super.validatePage() == true) {
+
+                       // Give a chance to the wizard to do its own validation
+                       IStatus validName = ((NewCProjectWizard) getWizard()).isValidName(getProjectName());
+                       if (!validName.isOK()) {
+                               setErrorMessage(validName.getMessage());
+                               return false;
+                       }
+
+                       // Give a chance to the wizard to do its own validation
+                       IStatus validLocation = ((NewCProjectWizard) getWizard()).isValidLocation(getLocationPath().toOSString());
+                       if (!validLocation.isOK()) {
+                               setErrorMessage(validLocation.getMessage());
+                               return false;
+                       }
+                       
+                       
+                       return true;
+               }
+               return false;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewClassCreationWizardPage.java
new file mode 100644 (file)
index 0000000..ae4f034
--- /dev/null
@@ -0,0 +1,2166 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2011 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *     IBM Corporation
+ *     Warren Paul (Nokia) - 174238
+ *     Sergey Prigogin (Google)
+ *******************************************************************************/
+package org.eclipse.cdt.ui.wizards;
+
+import java.net.URI;
+import java.util.List;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+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.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.MultiStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.MessageDialog;
+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.osgi.util.NLS;
+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.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+
+import org.eclipse.cdt.core.CConventions;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.browser.AllTypesCache;
+import org.eclipse.cdt.core.browser.IQualifiedTypeName;
+import org.eclipse.cdt.core.browser.ITypeInfo;
+import org.eclipse.cdt.core.browser.ITypeSearchScope;
+import org.eclipse.cdt.core.browser.QualifiedTypeName;
+import org.eclipse.cdt.core.browser.TypeSearchScope;
+import org.eclipse.cdt.core.browser.TypeUtil;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
+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.parser.IScannerInfo;
+import org.eclipse.cdt.core.parser.IScannerInfoProvider;
+import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.utils.PathUtil;
+
+import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
+import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
+import org.eclipse.cdt.internal.ui.util.SWTUtil;
+import org.eclipse.cdt.internal.ui.wizards.NewElementWizardPage;
+import org.eclipse.cdt.internal.ui.wizards.SourceFolderSelectionDialog;
+import org.eclipse.cdt.internal.ui.wizards.classwizard.BaseClassInfo;
+import org.eclipse.cdt.internal.ui.wizards.classwizard.BaseClassesListDialogField;
+import org.eclipse.cdt.internal.ui.wizards.classwizard.ConstructorMethodStub;
+import org.eclipse.cdt.internal.ui.wizards.classwizard.DestructorMethodStub;
+import org.eclipse.cdt.internal.ui.wizards.classwizard.IBaseClassInfo;
+import org.eclipse.cdt.internal.ui.wizards.classwizard.IMethodStub;
+import org.eclipse.cdt.internal.ui.wizards.classwizard.MethodStubsListDialogField;
+import org.eclipse.cdt.internal.ui.wizards.classwizard.NamespaceSelectionDialog;
+import org.eclipse.cdt.internal.ui.wizards.classwizard.NewBaseClassSelectionDialog;
+import org.eclipse.cdt.internal.ui.wizards.classwizard.NewClassCodeGenerator;
+import org.eclipse.cdt.internal.ui.wizards.classwizard.NewClassWizardMessages;
+import org.eclipse.cdt.internal.ui.wizards.classwizard.NewClassWizardPrefs;
+import org.eclipse.cdt.internal.ui.wizards.classwizard.NewClassWizardUtil;
+import org.eclipse.cdt.internal.ui.wizards.classwizard.SourceFileSelectionDialog;
+import org.eclipse.cdt.internal.ui.wizards.classwizard.NewBaseClassSelectionDialog.ITypeSelectionListener;
+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.IListAdapter;
+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.ListDialogField;
+import org.eclipse.cdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
+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;
+
+public class NewClassCreationWizardPage extends NewElementWizardPage {
+    protected static final String PAGE_NAME = "NewClassWizardPage"; //$NON-NLS-1$
+    protected static final int MAX_FIELD_CHARS = 50;
+
+    // Dialog setting keys.
+    private static final String KEY_NAMESPACE_SELECTED = "namespaceSelected"; //$NON-NLS-1$
+    private static final String KEY_NAMESPACE = "namespace"; //$NON-NLS-1$
+    private static final String KEY_TEST_FILE_SELECTED = "testFileSelected"; //$NON-NLS-1$
+    private static final String KEY_STUB_SELECTED = "stubSelected"; //$NON-NLS-1$
+    private static final String KEY_STUB_VIRTUAL = "stubVirtual"; //$NON-NLS-1$
+    private static final String KEY_STUB_INLINE = "stubInline"; //$NON-NLS-1$
+    
+       // Field IDs
+    protected static final int SOURCE_FOLDER_ID = 1;
+    protected static final int NAMESPACE_ID = 2;
+    protected static final int CLASS_NAME_ID = 4;
+    protected static final int BASE_CLASSES_ID = 8;
+    protected static final int METHOD_STUBS_ID = 16;
+    protected static final int HEADER_FILE_ID = 32;
+    protected static final int SOURCE_FILE_ID = 64;
+    /** @since 5.3 */
+    protected static final int TEST_FILE_ID = 128;
+    protected static final int ALL_FIELDS = SOURCE_FOLDER_ID | NAMESPACE_ID
+            | CLASS_NAME_ID | BASE_CLASSES_ID | METHOD_STUBS_ID
+            | HEADER_FILE_ID | SOURCE_FILE_ID | TEST_FILE_ID;
+       protected int fLastFocusedField = 0;
+
+    protected StringButtonDialogField fSourceFolderDialogField;
+    protected SelectionButtonDialogField fNamespaceSelection;
+    protected StringButtonDialogField fNamespaceDialogField;
+    protected StringDialogField fClassNameDialogField;
+    protected BaseClassesListDialogField fBaseClassesDialogField;
+    protected MethodStubsListDialogField fMethodStubsDialogField;
+    protected StringButtonDialogField fHeaderFileDialogField;
+       protected StringButtonDialogField fSourceFileDialogField;
+    /** @since 5.3 */
+    protected StringButtonDialogField fTestFileDialogField;
+    /** @since 5.3 */
+    protected SelectionButtonDialogField fTestFileSelection;
+    /** @since 5.3 */
+    protected boolean fHeaderFileDerivedFromClassName;
+    /** @since 5.3 */
+    protected boolean fSourceFileDerivedFromClassName;
+    /** @since 5.3 */
+    protected boolean fTestFileDerivedFromClassName;
+
+       protected IStatus fSourceFolderStatus;
+       protected IStatus fNamespaceStatus;
+       protected IStatus fClassNameStatus;
+       protected IStatus fBaseClassesStatus;
+       protected IStatus fMethodStubsStatus;
+       protected IStatus fHeaderFileStatus;
+       protected IStatus fSourceFileStatus;
+       /** @since 5.3 */
+       protected IStatus fTestFileStatus;
+       protected final IStatus STATUS_OK = new StatusInfo();
+
+    protected IFile fCreatedHeaderFile;
+    protected IFile fCreatedSourceFile;
+    /** @since 5.3 */
+    protected IFile fCreatedTestFile;
+    protected ICElement fCreatedClass;
+    
+    /**
+     * This flag isFirstTime is used to keep a note
+     * that the class creation wizard has just been 
+     * created.
+     */
+    private boolean isFirstTime = false;
+    
+    
+       /**
+        * Constructor for NewClassCreationWizardPage
+        */
+       public NewClassCreationWizardPage() {
+               super(PAGE_NAME);
+               setTitle(NewClassWizardMessages.NewClassCreationWizardPage_title);
+               setDescription(NewClassWizardMessages.NewClassCreationWizardPage_description);
+               
+               SourceFolderFieldAdapter sourceFolderAdapter = new SourceFolderFieldAdapter();
+               fSourceFolderDialogField = new StringButtonDialogField(sourceFolderAdapter);
+               fSourceFolderDialogField.setDialogFieldListener(sourceFolderAdapter);
+               fSourceFolderDialogField.setLabelText(NewClassWizardMessages.NewClassCreationWizardPage_sourceFolder_label);
+               fSourceFolderDialogField.setButtonLabel(NewClassWizardMessages.NewClassCreationWizardPage_sourceFolder_button);
+
+               NamespaceFieldAdapter namespaceAdapter = new NamespaceFieldAdapter();
+               fNamespaceSelection = new SelectionButtonDialogField(SWT.CHECK);
+               fNamespaceSelection.setDialogFieldListener(namespaceAdapter);
+               fNamespaceSelection.setLabelText(NewClassWizardMessages.NewClassCreationWizardPage_namespace_label);
+
+               fNamespaceDialogField = new StringButtonDialogField(namespaceAdapter);
+               fNamespaceDialogField.setDialogFieldListener(namespaceAdapter);
+               fNamespaceDialogField.setButtonLabel(NewClassWizardMessages.NewClassCreationWizardPage_namespace_button);
+
+               ClassNameFieldAdapter classAdapter = new ClassNameFieldAdapter();
+               fClassNameDialogField = new StringDialogField();
+               fClassNameDialogField.setDialogFieldListener(classAdapter);
+               fClassNameDialogField.setLabelText(NewClassWizardMessages.NewClassCreationWizardPage_className_label);
+               
+               BaseClassesFieldAdapter baseClassesAdapter = new BaseClassesFieldAdapter();
+               fBaseClassesDialogField = new BaseClassesListDialogField(NewClassWizardMessages.NewClassCreationWizardPage_baseClasses_label, baseClassesAdapter);
+               
+               MethodStubsFieldAdapter methodStubsAdapter = new MethodStubsFieldAdapter();
+               fMethodStubsDialogField = new MethodStubsListDialogField(NewClassWizardMessages.NewClassCreationWizardPage_methodStubs_label, methodStubsAdapter);
+           
+               FileGroupFieldAdapter fileGroupAdapter = new FileGroupFieldAdapter();
+               fHeaderFileDialogField = new StringButtonDialogField(fileGroupAdapter);
+               fHeaderFileDialogField.setDialogFieldListener(fileGroupAdapter);
+               fHeaderFileDialogField.setLabelText(NewClassWizardMessages.NewClassCreationWizardPage_headerFile_label);
+               fHeaderFileDialogField.setButtonLabel(NewClassWizardMessages.NewClassCreationWizardPage_headerFile_button);
+               fSourceFileDialogField = new StringButtonDialogField(fileGroupAdapter);
+               fSourceFileDialogField.setDialogFieldListener(fileGroupAdapter);
+               fSourceFileDialogField.setLabelText(NewClassWizardMessages.NewClassCreationWizardPage_sourceFile_label);
+               fSourceFileDialogField.setButtonLabel(NewClassWizardMessages.NewClassCreationWizardPage_sourceFile_button);
+               fTestFileSelection = new SelectionButtonDialogField(SWT.CHECK);
+               fTestFileSelection.setDialogFieldListener(fileGroupAdapter);
+               fTestFileSelection.setLabelText(NewClassWizardMessages.NewClassCreationWizardPage_testFile_label);
+               fTestFileDialogField = new StringButtonDialogField(fileGroupAdapter);
+               fTestFileDialogField.setDialogFieldListener(fileGroupAdapter);
+               fTestFileDialogField.setButtonLabel(NewClassWizardMessages.NewClassCreationWizardPage_testFile_button);
+
+           fHeaderFileDerivedFromClassName = true;
+           fSourceFileDerivedFromClassName = true;
+           fTestFileDerivedFromClassName = true;
+
+               fSourceFolderStatus = STATUS_OK;
+               fNamespaceStatus = STATUS_OK;
+               fClassNameStatus = STATUS_OK;
+               fBaseClassesStatus = STATUS_OK;
+               fMethodStubsStatus = STATUS_OK;
+               fHeaderFileStatus = STATUS_OK;
+               fSourceFileStatus = STATUS_OK;
+               fTestFileStatus = STATUS_OK;
+               fLastFocusedField = 0;
+               
+               isFirstTime = true;
+       }
+       
+       // -------- UI Creation ---------
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+     */
+    public void createControl(Composite parent) {
+        initializeDialogUnits(parent);
+        
+        Composite composite = new Composite(parent, SWT.NONE);
+        int nColumns = 4;
+        
+        GridLayout layout = new GridLayout();
+        layout.numColumns = nColumns;
+        composite.setLayout(layout);
+               composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+               composite.setFont(parent.getFont());
+        
+        createSourceFolderControls(composite, nColumns);
+        createNamespaceControls(composite, nColumns);
+        
+        createSeparator(composite, nColumns);
+        
+        createClassNameControls(composite, nColumns);
+        createBaseClassesControls(composite, nColumns);
+        createMethodStubsControls(composite, nColumns);
+        
+        createSeparator(composite, nColumns);
+        
+        createFileControls(composite, nColumns);
+        
+               composite.layout();                     
+
+               setErrorMessage(null);
+               setMessage(null);
+               setControl(composite);
+    }
+       
+       /**
+        * Creates a separator line. Expects a <code>GridLayout</code> 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 <code>GridLayout</code> 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 namespace field. Expects a <code>GridLayout</code> with at 
+        * least 4 columns.
+        * 
+        * @param composite the parent composite
+        * @param nColumns number of columns to span
+        */             
+       protected void createNamespaceControls(Composite composite, int nColumns) {
+               Composite tabGroup= new Composite(composite, SWT.NONE);
+               GridLayout layout= new GridLayout();
+               layout.marginWidth= 0;
+               layout.marginHeight= 0;
+               tabGroup.setLayout(layout);
+
+               fNamespaceSelection.doFillIntoGrid(tabGroup, 1);
+
+               Text textControl= fNamespaceDialogField.getTextControl(composite);
+               GridData gd= new GridData(GridData.FILL_HORIZONTAL);
+               gd.widthHint= getMaxFieldWidth();
+               gd.horizontalSpan= 2;
+               textControl.setLayoutData(gd);
+               textControl.addFocusListener(new StatusFocusListener(NAMESPACE_ID));
+               
+               Button button= fNamespaceDialogField.getChangeControl(composite);
+               gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               gd.widthHint = SWTUtil.getButtonWidthHint(button);
+               button.setLayoutData(gd);
+       }       
+
+       /**
+        * Creates the controls for the class name field. Expects a <code>GridLayout</code> with at 
+        * least 2 columns.
+        * 
+        * @param composite the parent composite
+        * @param nColumns number of columns to span
+        */             
+       protected void createClassNameControls(Composite composite, int nColumns) {
+               fClassNameDialogField.doFillIntoGrid(composite, nColumns - 1);
+               DialogField.createEmptySpace(composite);
+               Text textControl = fClassNameDialogField.getTextControl(null);
+               LayoutUtil.setWidthHint(textControl, getMaxFieldWidth());
+               textControl.addFocusListener(new StatusFocusListener(CLASS_NAME_ID));
+       }
+
+       /**
+        * Creates the controls for the base classes field. Expects a <code>GridLayout</code> with 
+        * at least 3 columns.
+        * 
+        * @param composite the parent composite
+        * @param nColumns number of columns to span
+        */                     
+       protected void createBaseClassesControls(Composite composite, int nColumns) {
+           fBaseClassesDialogField.doFillIntoGrid(composite, nColumns);
+           Control listControl = fBaseClassesDialogField.getListControl(null);
+           LayoutUtil.setVerticalGrabbing(listControl, false);
+               listControl.addFocusListener(new StatusFocusListener(BASE_CLASSES_ID));
+       }
+       
+       /**
+        * Creates the controls for the method stubs field. Expects a <code>GridLayout</code> with 
+        * at least 4 columns.
+        * 
+        * @param composite the parent composite
+        * @param nColumns number of columns to span
+        */                     
+       protected void createMethodStubsControls(Composite composite, int nColumns) {
+               fMethodStubsDialogField.doFillIntoGrid(composite, nColumns);
+           Control listControl = fMethodStubsDialogField.getListControl(null);
+           LayoutUtil.setHeightHint(listControl,
+                       convertHeightInCharsToPixels(6) + convertHeightInCharsToPixels(1) / 2);
+           LayoutUtil.setVerticalGrabbing(listControl, false);
+               listControl.addFocusListener(new StatusFocusListener(METHOD_STUBS_ID));
+       }
+       
+       /**
+        * Creates the controls for the file name fields. Expects a <code>GridLayout</code> with 
+        * at least 4 columns.
+        * 
+        * @param composite the parent composite
+        * @param nColumns number of columns to span
+        */             
+       protected void createFileControls(Composite composite, int nColumns) {
+               fHeaderFileDialogField.doFillIntoGrid(composite, nColumns);
+               Text textControl = fHeaderFileDialogField.getTextControl(null);
+               LayoutUtil.setWidthHint(textControl, getMaxFieldWidth());
+               textControl.addFocusListener(new StatusFocusListener(HEADER_FILE_ID));
+               
+               fSourceFileDialogField.doFillIntoGrid(composite, nColumns);
+               textControl = fSourceFileDialogField.getTextControl(null);
+               LayoutUtil.setWidthHint(textControl, getMaxFieldWidth());
+               textControl.addFocusListener(new StatusFocusListener(SOURCE_FILE_ID));
+               
+               Composite tabGroup = new Composite(composite, SWT.NONE);
+               GridLayout layout = new GridLayout();
+               layout.marginWidth = 0;
+               layout.marginHeight = 0;
+               tabGroup.setLayout(layout);
+
+               fTestFileSelection.doFillIntoGrid(tabGroup, 1);
+               
+               textControl = fTestFileDialogField.getTextControl(composite);
+               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.widthHint = getMaxFieldWidth();
+               gd.horizontalSpan = 2;
+               textControl.setLayoutData(gd);
+               textControl.addFocusListener(new StatusFocusListener(TEST_FILE_ID));
+               
+               Button button = fTestFileDialogField.getChangeControl(composite);
+               gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+               gd.widthHint = SWTUtil.getButtonWidthHint(button);
+               button.setLayoutData(gd);
+       }       
+       
+    /**
+     * 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) {
+       if (fDialogSettings == null) {
+                       fDialogSettings = getDialogSettings().getSection(PAGE_NAME);
+                       if (fDialogSettings == null) {
+                               fDialogSettings = getDialogSettings().addNewSection(PAGE_NAME);
+                       }
+       }
+
+               ICElement celem = getInitialCElement(selection);
+        
+        String namespace = null;
+        if (celem != null) {
+            ICElement ns = NewClassWizardUtil.getNamespace(celem);
+            if (ns != null) {
+                namespace = TypeUtil.getFullyQualifiedName(ns).toString();
+                if (namespace != null && namespace.length() == 0) {
+                    namespace = null;
+                }
+            }
+        }
+        if (namespace == null) {
+               namespace = fDialogSettings.get(KEY_NAMESPACE);
+        }
+
+        setNamespaceText(namespace, false);
+        setNamespaceSelection(namespace != null || fDialogSettings.getBoolean(KEY_NAMESPACE_SELECTED),
+                       true);
+        
+        IPath folderPath = null;
+        if (celem != null) {
+            ICContainer folder = NewClassWizardUtil.getSourceFolder(celem);
+            if (folder == null) {
+                ICProject cproject = celem.getCProject();
+                if (cproject != null) {
+                    folder = NewClassWizardUtil.getFirstSourceRoot(cproject);
+                }
+            }
+            if (folder != null) {
+                folderPath = folder.getResource().getFullPath();
+            }
+        }
+        setSourceFolderFullPath(folderPath, false);
+    
+        String className = null;
+        ITextSelection textSel = getEditorTextSelection();
+        if (textSel != null) {
+            String text = textSel.getText();
+            if (text != null && text.length() > 0 && CConventions.validateClassName(text).isOK()) {
+                className = text;
+            }
+        }
+        setClassName(className, false);
+        
+        IMethodStub[] stubs = getDefaultMethodStubs();
+        for (int i = 0; i < stubs.length; ++i) {
+               IMethodStub stub = stubs[i];
+               if (stub.canModifyVirtual()) {
+                       stub.setVirtual(getBooleanSettingWithDefault(KEY_STUB_VIRTUAL + i, stub.isVirtual()));
+               }
+               if (stub.canModifyInline()) {
+                       stub.setInline(getBooleanSettingWithDefault(KEY_STUB_INLINE + i, stub.isInline()));
+               }
+            addMethodStub(stub, getBooleanSettingWithDefault(KEY_STUB_SELECTED + i, true));
+        }
+        
+        setTestFileSelection(fDialogSettings.getBoolean(KEY_TEST_FILE_SELECTED), true);
+        handleFieldChanged(ALL_FIELDS);
+    }
+
+    private boolean getBooleanSettingWithDefault(String key, boolean defaultValue) {
+       String value = fDialogSettings.get(key);
+       if (value == null) {
+               return defaultValue;
+       }
+       return Boolean.valueOf(value);
+    }
+
+    /**
+     * Attempts to extract a C Element from the initial selection.
+     * 
+     * @param selection the initial selection
+     * @return a C Element, or <code>null</code> if not available
+     */
+    protected ICElement getInitialCElement(IStructuredSelection selection) {
+        ICElement celem = NewClassWizardUtil.getCElementFromSelection(selection);
+        if (celem == null) {
+            celem = NewClassWizardUtil.getCElementFromEditor();
+        }
+        if (celem == null || celem.getElementType() == ICElement.C_MODEL) {
+            try {
+                ICProject[] projects = CoreModel.create(NewClassWizardUtil.getWorkspaceRoot()).getCProjects();
+                if (projects.length == 1) {
+                    celem = projects[0];
+                }
+            } catch (CModelException e) {
+                CUIPlugin.log(e);
+            }
+        }
+        return celem;
+    }
+       
+    /**
+        * 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 text selection of the current editor. <code>null</code> is returned
+     * when the current editor does not have focus or does not return a text selection.
+     *
+     * @return the selection of the current editor, or <code>null</code>.
+     */
+    protected ITextSelection getEditorTextSelection() {
+        IWorkbenchPage page = CUIPlugin.getActivePage();
+        if (page != null) {
+               IWorkbenchPart part = page.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;
+    }
+       
+    /**
+     * Returns the method stubs to display in the wizard.
+     * 
+     * @return array of method stubs
+     */
+    protected IMethodStub[] getDefaultMethodStubs() {
+        return new IMethodStub[] {
+            new ConstructorMethodStub(),
+            new DestructorMethodStub()
+        };
+    }
+    
+    /**
+     * Returns the text entered into the source folder input field.
+     * 
+     * @return the source folder
+     */
+    public String getSourceFolderText() {
+        return fSourceFolderDialogField.getText().trim();
+    }
+    
+    /**
+     * Sets the text of the source folder input field.
+     * 
+     * @param folder the folder name
+     * @param update <code>true</code> if the dialog should be updated
+     */ 
+    public void setSourceFolderText(String folder, boolean update) {
+        fSourceFolderDialogField.setTextWithoutUpdate(folder != null ? folder : ""); //$NON-NLS-1$
+        if (update) {
+            fSourceFolderDialogField.dialogFieldChanged();
+        }
+    }
+    
+    /**
+     * Returns the current source folder as a path.
+     * 
+     * @return the source folder path
+     */
+    protected IPath getSourceFolderFullPath() {
+        String text = getSourceFolderText();
+        if (text.length() > 0)
+            return new Path(text).makeAbsolute();
+        return null;
+    }
+    
+    /**
+     * Sets the source folder from the given path.
+     * 
+     * @param folderPath the source folder path
+     * @param update <code>true</code> if the dialog should be updated
+     */
+    protected void setSourceFolderFullPath(IPath folderPath, boolean update) {
+        String str = (folderPath != null) ? folderPath.makeRelative().toString() : ""; //.makeRelative().toString(); //$NON-NLS-1$
+        setSourceFolderText(str, update);
+    }
+    
+    /**
+     * Returns the current project, based on the current source folder.
+     * 
+     * @return the current project
+     */
+    protected ICProject getCurrentProject() {
+        IPath folderPath = getSourceFolderFullPath();
+        if (folderPath != null) {
+            return toCProject(PathUtil.getEnclosingProject(folderPath));
+        }
+        return null;
+    }
+
+       private ICProject toCProject(IProject enclosingProject) {
+               if (enclosingProject != null)
+                       return CoreModel.getDefault().create(enclosingProject);
+               return null;
+       }
+
+    /**
+     * Returns the text entered into the namespace input field.
+     * 
+     * @return the namespace
+     */
+    public String getNamespaceText() {
+        return fNamespaceDialogField.getText().trim();
+    }
+
+    /**
+     * Sets the text of the namespace input field.
+     * 
+     * @param namespace the namespace name
+     * @param update <code>true</code> if the dialog should be updated
+     */ 
+    public void setNamespaceText(String namespace, boolean update) {
+        fNamespaceDialogField.setTextWithoutUpdate(namespace != null ? namespace : ""); //$NON-NLS-1$
+        if (update) {
+            fNamespaceDialogField.dialogFieldChanged();
+        }
+    }
+    
+    /**
+     * Returns the selection state of the namespace checkbox.
+     * 
+     * @return the selection state of the namespace checkbox
+     */
+    public boolean isNamespaceSelected() {
+        return fNamespaceSelection.isSelected();
+    }
+    
+    /**
+     * Sets the namespace checkbox's selection state.
+     * 
+     * @param isSelected the checkbox's selection state
+     * @param canBeModified if <code>true</code> the checkbox is
+     * modifiable; otherwise it is read-only.
+     */
+    public void setNamespaceSelection(boolean isSelected, boolean canBeModified) {
+        fNamespaceSelection.setSelection(isSelected);
+        fNamespaceSelection.setEnabled(canBeModified);
+        updateNamespaceEnableState();
+    }
+    
+    /**
+     * Updates the enable state of the namespace button.
+     */
+    private void updateNamespaceEnableState() {
+        fNamespaceDialogField.setEnabled(isNamespaceSelected());
+    }
+    
+    /**
+     * Returns the class name entered into the class input field.
+     * 
+     * @return the class name
+     */
+    public String getClassName() {
+        return fClassNameDialogField.getText().trim();
+    }
+
+    /**
+     * Sets the text of the class name input field.
+     * 
+     * @param name the new class name
+     * @param update <code>true</code> if the dialog should be updated
+     */ 
+    public void setClassName(String name, boolean update) {
+        fClassNameDialogField.setTextWithoutUpdate(name != null ? name : ""); //$NON-NLS-1$
+        if (update) {
+            fClassNameDialogField.dialogFieldChanged();
+        }
+    }
+    
+    /**
+     * Returns the currently selected (checked) method stubs.
+     * 
+     * @return array of <code>IMethodStub</code> or empty array if none selected.
+     */
+    protected IMethodStub[] getSelectedMethodStubs() {
+        return fMethodStubsDialogField.getCheckedMethodStubs();
+    }
+
+    /**
+     * Adds a method stub to the method stubs field.
+     * @param methodStub the method stub to add
+     * @param selected <code>true</code> if the stub is initially selected (checked)
+     */
+    protected void addMethodStub(IMethodStub methodStub, boolean selected) {
+        fMethodStubsDialogField.addMethodStub(methodStub, selected);
+    }
+
+    /**
+     * Returns the contents of the base classes field.
+     * 
+     * @return array of <code>IBaseClassInfo</code>
+     */
+    protected IBaseClassInfo[] getBaseClasses() {
+        List<IBaseClassInfo> classesList = fBaseClassesDialogField.getElements();
+        return classesList.toArray(new IBaseClassInfo[classesList.size()]);
+    }
+    
+    /**
+     * Adds a base class to the base classes field.
+     * @param newBaseClass the new base class
+     * @param access the access visibility (public/private/protected)
+     * @param isVirtual <code>true</code> if the inheritance is virtual
+     */
+    protected void addBaseClass(ITypeInfo newBaseClass, ASTAccessVisibility access, boolean isVirtual) {
+        // check if already exists
+        List<IBaseClassInfo> baseClasses = fBaseClassesDialogField.getElements();
+        if (baseClasses != null) {
+            for (IBaseClassInfo baseClassInfo : baseClasses) {
+                BaseClassInfo info = (BaseClassInfo) baseClassInfo;
+                if (info.getType().equals(newBaseClass)) {
+                    // already added
+                    return;
+                }
+            }
+        }
+
+        if (verifyBaseClasses()) {
+            NewClassWizardUtil.resolveClassLocation(newBaseClass, getContainer());
+        }
+
+        fBaseClassesDialogField.addBaseClass(new BaseClassInfo(newBaseClass, access, isVirtual));
+    }
+
+    /**
+     * Sets the use test file creation checkbox's selection state.
+     * 
+     * @param isSelected the checkbox's selection state
+     * @param canBeModified if <code>true</code> the checkbox is
+     * modifiable; otherwise it is read-only.
+     * @since 5.3
+     */
+    public void setTestFileSelection(boolean isSelected, boolean canBeModified) {
+       fTestFileSelection.setSelection(isSelected);
+       fTestFileSelection.setEnabled(canBeModified);
+       updateTestFileEnableState();
+    }
+
+    /**
+     * Updates the enable state of test file name text box.
+     */
+    private void updateTestFileEnableState() {
+        fTestFileDialogField.setEnabled(fTestFileSelection.isSelected());
+    }
+    
+    /**
+     * Returns the text entered into the header file input field.
+     * 
+     * @return the header file
+     */
+    public String getHeaderFileText() {
+        return fHeaderFileDialogField.getText().trim();
+    }
+    
+    /**
+     * Sets the text of the header file input field.
+     * 
+     * @param header the header file name
+     * @param update <code>true</code> if the dialog should be updated
+     */ 
+    public void setHeaderFileText(String header, boolean update) {
+       setFileText(fHeaderFileDialogField, header, update);
+    }
+
+    /**
+     * Returns the current header file as a path.
+     * 
+     * @return the header file path
+     */
+    protected IPath getHeaderFileFullPath() {
+       return getFilePath(getHeaderFileText());
+    }
+    
+    /**
+     * Sets the header file from the given path.
+     * 
+     * @param path the header file path
+     * @param update <code>true</code> if the dialog should be updated
+     */
+    protected void setHeaderFileFullPath(IPath path, boolean update) {
+       setFileFullPath(fHeaderFileDialogField, path, update);
+    }
+
+    /**
+     * Returns the text entered into the source file input field.
+     * 
+     * @return the source file
+     */
+    public String getSourceFileText() {
+        return fSourceFileDialogField.getText().trim();
+    }
+    
+    /**
+     * Sets the text of the source file input field.
+     * 
+     * @param source the source file name
+     * @param update <code>true</code> if the dialog should be updated
+     */ 
+    public void setSourceFileText(String source, boolean update) {
+       setFileText(fSourceFileDialogField, source, update);
+    }
+    
+    /**
+     * Returns the current source file as a path.
+     * 
+     * @return the source file path
+     */
+    protected IPath getSourceFileFullPath() {
+       return getFilePath(getSourceFileText());
+    }
+    
+    /**
+     * Sets the source file from the given path.
+     * 
+     * @param path the source file path
+     * @param update <code>true</code> if the dialog should be updated
+     */
+    protected void setSourceFileFullPath(IPath path, boolean update) {
+       setFileFullPath(fSourceFileDialogField, path, update);
+    }
+
+    /**
+     * Returns the text entered into the source file input field.
+     * 
+     * @return the source file
+     * @since 5.3
+     */
+    public String getTestFileText() {
+       return fTestFileDialogField.isEnabled() ? fTestFileDialogField.getText().trim() : null;
+    }
+
+    /**
+     * Sets the text of the test file input field.
+     * 
+     * @param testFile the test file name
+     * @param update <code>true</code> if the dialog should be updated
+     * @since 5.3
+     */ 
+    public void setTestFileText(String testFile, boolean update) {
+       setFileText(fTestFileDialogField, testFile, update);
+    }
+
+    /**
+     * Returns the current test file as a path. Returns {@code null} if creation of test file
+     * is disabled.
+     * 
+     * @return the test file path, or {@code null} if creation of test file is disabled.
+     * @since 5.3
+     */
+    protected IPath getTestFileFullPath() {
+       return getFilePath(getTestFileText());
+    }
+
+    /**
+     * Returns a path corresponding to a file name.
+     * @param filename the name of a header, a source, or a test file. Can be {@code null}.
+     * @return the corresponding path, or {@code null} if the filename is {@code null}.
+     */
+       private IPath getFilePath(String filename) {
+               if (filename == null || filename.length() == 0) {
+               return null;
+       }
+       IPath path = new Path(filename);
+               if (!path.isAbsolute()) {
+                       IPath folderPath = getSourceFolderFullPath();
+                       if (folderPath != null)
+                               path = folderPath.append(path);
+               }
+       return path;
+       }
+
+    /**
+     * Sets a file name field to a given value.
+     * 
+     * @param field the field to set
+     * @param filename the new value of the field
+     * @param update <code>true</code> if the dialog should be updated
+     */
+    private void setFileText(StringButtonDialogField field, String filename, boolean update) {
+       field.setTextWithoutUpdate(filename != null ? filename : ""); //$NON-NLS-1$
+        if (update) {
+               field.dialogFieldChanged();
+        }
+    }
+
+    /**
+     * Sets a file name field from the given path.
+     * 
+     * @param path the file path
+     * @param update <code>true</code> if the dialog should be updated
+     */
+    private void setFileFullPath(StringButtonDialogField field, IPath path, boolean update) {
+        String str = null;
+        if (path != null) {
+            IPath sourceFolder = getSourceFolderFullPath();
+            if (sourceFolder != null) {
+                IPath relativePath = PathUtil.makeRelativePath(path, sourceFolder);
+                if (relativePath != null)
+                    path = relativePath;
+            }
+            str = path.makeRelative().toString();
+        }
+        setFileText(field, str, update);
+    }
+
+    /**
+     * Sets the test file from the given path.
+     * 
+     * @param path the test file path
+     * @param update <code>true</code> if the dialog should be updated
+     * @since 5.3
+     */
+    protected void setTestFileFullPath(IPath path, boolean update) {
+       setFileFullPath(fTestFileDialogField, path, update);
+    }
+
+    /*
+     * @see WizardPage#becomesVisible
+     */
+    @Override
+       public void setVisible(boolean visible) {
+        super.setVisible(visible);
+        if (visible) {
+            setFocus();
+        }
+    }
+
+    /**
+     * Sets the focus on the class name input field.
+     */     
+    protected void setFocus() {
+        fClassNameDialogField.setFocus();
+    }
+    
+    // ----------- UI Validation ----------
+    
+    /**
+     * Causes doStatusUpdate() to be called whenever the focus changes.
+     * Remembers the last focused field.
+     */
+    private final class StatusFocusListener implements FocusListener {
+        private int fieldID;
+
+        public StatusFocusListener(int fieldID) {
+            this.fieldID = fieldID;
+        }
+
+        public void focusGained(FocusEvent e) {
+            if (fLastFocusedField != this.fieldID) {
+                fLastFocusedField = this.fieldID;
+               if (isFirstTime) {
+                       isFirstTime = false;
+                       return;
+               }
+                doStatusUpdate();
+            }
+        }
+
+        public void focusLost(FocusEvent e) {
+            if (fLastFocusedField != 0) {
+                fLastFocusedField = 0;
+                doStatusUpdate();
+            }
+        }
+    }
+
+    /**
+     * handles changes to the source folder field
+     */
+    private final class SourceFolderFieldAdapter implements IStringButtonAdapter, IDialogFieldListener {
+               public void changeControlPressed(DialogField field) {
+                   IPath oldFolderPath = getSourceFolderFullPath();
+                       IPath newFolderPath = chooseSourceFolder(oldFolderPath);
+                       if (newFolderPath != null) {
+                               IPath headerPath = getHeaderFileFullPath();
+                               IPath sourcePath = getSourceFileFullPath();
+                               setSourceFolderFullPath(newFolderPath, false);
+                               if (oldFolderPath != null && oldFolderPath.matchingFirstSegments(newFolderPath) == 0) {
+                                   if (headerPath != null) {
+                                       headerPath = newFolderPath.append(headerPath.lastSegment());
+                                   }
+                                   if (sourcePath != null) {
+                                       sourcePath = newFolderPath.append(sourcePath.lastSegment());
+                                   }
+                               }
+                           // adjust the relative paths
+                           setHeaderFileFullPath(headerPath, false);
+                           setSourceFileFullPath(sourcePath, false);
+                               handleFieldChanged(SOURCE_FOLDER_ID|ALL_FIELDS);
+                       }
+               }
+               
+               public void dialogFieldChanged(DialogField field) {
+                       handleFieldChanged(SOURCE_FOLDER_ID|ALL_FIELDS);
+               }
+       }
+    
+    private IPath chooseSourceFolder(IPath initialPath) {
+        ICElement initElement = NewClassWizardUtil.getSourceFolder(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(NewClassWizardUtil.getWorkspaceRoot()));
+        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;
+    }   
+       
+    /**
+     * handles changes to the namespace field
+     */
+    private final class NamespaceFieldAdapter implements IStringButtonAdapter, IDialogFieldListener {
+               public void changeControlPressed(DialogField field) {
+               ITypeInfo ns = chooseNamespace();
+                   if (ns != null) {
+                       int changedFields = NAMESPACE_ID|CLASS_NAME_ID;
+                       IPath oldFolderPath = getSourceFolderFullPath();
+                       if (oldFolderPath == null) {
+                                       IPath headerPath = getHeaderFileFullPath();
+                                       IPath sourcePath = getSourceFileFullPath();
+                                       IPath testPath = getTestFileFullPath();
+                           IPath newFolderPath = updateSourceFolderFromPath(ns.getEnclosingProject().getProject().getFullPath());
+                               if (newFolderPath != null) {
+                                   changedFields |= SOURCE_FOLDER_ID | HEADER_FILE_ID | SOURCE_FILE_ID | TEST_FILE_ID;
+                                           setSourceFolderFullPath(newFolderPath, false);
+                                           // Adjust the relative paths
+                                           setHeaderFileFullPath(headerPath, false);
+                                           setSourceFileFullPath(sourcePath, false);
+                                           setTestFileFullPath(testPath, false);
+                               }
+                       }
+                       setNamespaceText(ns.getQualifiedTypeName().toString(), false);
+                               handleFieldChanged(changedFields);
+               }
+               }
+               
+               public void dialogFieldChanged(DialogField field) {
+               updateNamespaceEnableState();
+                       handleFieldChanged(NAMESPACE_ID|CLASS_NAME_ID);
+               }
+       }
+    
+    private IPath updateSourceFolderFromPath(IPath filePath) {
+        ICElement folder = NewClassWizardUtil.getSourceFolder(filePath);
+        if (folder instanceof ISourceRoot) {
+            ICProject cProject = folder.getCProject();
+            ISourceRoot projRoot = cProject.findSourceRoot(cProject.getProject());
+            if (projRoot != null && projRoot.equals(folder))
+                folder = cProject;
+        }
+        if (folder != null) {
+            return folder.getPath();
+        }
+        IProject proj = PathUtil.getEnclosingProject(filePath);
+        if (proj != null)
+            return proj.getFullPath(); 
+        return null;
+    }
+    
+    private ITypeInfo chooseNamespace() {
+        ITypeSearchScope scope;
+        ICProject project = getCurrentProject();
+        if (project != null) {
+            scope = new TypeSearchScope(project);
+        } else {
+            scope = new TypeSearchScope(true);
+        }
+
+        ITypeInfo[] elements = AllTypesCache.getNamespaces(scope, false);
+        if (elements == null || elements.length == 0) {
+            String title = NewClassWizardMessages.NewClassCreationWizardPage_getTypes_noNamespaces_title;
+            String message = NewClassWizardMessages.NewClassCreationWizardPage_getTypes_noNamespaces_message;
+            MessageDialog.openInformation(getShell(), title, message);
+            return null;
+        }
+        
+        NamespaceSelectionDialog dialog = new NamespaceSelectionDialog(getShell());
+        dialog.setElements(elements);
+        int result = dialog.open();
+        if (result == IDialogConstants.OK_ID) {
+            return (ITypeInfo) dialog.getFirstResult();
+        }
+        
+        return null;
+    }
+    
+    /**
+     * Handles changes to the class name field
+     */
+       private final class ClassNameFieldAdapter implements IDialogFieldListener {
+               public void dialogFieldChanged(DialogField field) {
+                   int changedFields = CLASS_NAME_ID;
+                       updateFilesFromClassName(fClassNameDialogField.getText().trim());
+                       changedFields |= HEADER_FILE_ID | SOURCE_FILE_ID | TEST_FILE_ID;
+                       handleFieldChanged(changedFields);
+               }
+       }
+    
+    /**
+     * Handles changes to the base classes field
+     */
+       private final class BaseClassesFieldAdapter implements IListAdapter<IBaseClassInfo> {
+        public void customButtonPressed(ListDialogField<IBaseClassInfo> field, int index) {
+            if (index == 0) {
+                chooseBaseClasses();
+            }
+            handleFieldChanged(BASE_CLASSES_ID);
+        }
+
+        public void selectionChanged(ListDialogField<IBaseClassInfo> field) {
+        }
+
+        public void doubleClicked(ListDialogField<IBaseClassInfo> field) {
+        }
+    }
+    
+    private void chooseBaseClasses() {
+        List<IBaseClassInfo> oldContents = fBaseClassesDialogField.getElements();
+        NewBaseClassSelectionDialog dialog = new NewBaseClassSelectionDialog(getShell());
+        dialog.addListener(new ITypeSelectionListener() {
+            public void typeAdded(ITypeInfo newBaseClass) {
+                addBaseClass(newBaseClass, ASTAccessVisibility.PUBLIC, false);
+            }
+        });
+        int result = dialog.open();
+        if (result != IDialogConstants.OK_ID) {
+            // Restore the old contents
+            fBaseClassesDialogField.setElements(oldContents);
+        }
+    }
+    
+    /**
+     * Handles changes to the method stubs field
+     */
+       private final class MethodStubsFieldAdapter implements IListAdapter<IMethodStub> {
+
+        public void customButtonPressed(ListDialogField<IMethodStub> field, int index) {
+        }
+
+        public void selectionChanged(ListDialogField<IMethodStub> field) {
+        }
+
+        public void doubleClicked(ListDialogField<IMethodStub> field) {
+        }
+    }
+
+    /**
+     * handles changes to the file name fields
+     */
+    private final class FileGroupFieldAdapter implements IStringButtonAdapter, IDialogFieldListener {
+               public void changeControlPressed(DialogField field) {
+                   IPath filePath = null;
+                       IPath headerPath = getHeaderFileFullPath();
+                       IPath sourcePath = getSourceFileFullPath();
+                       IPath testPath = getTestFileFullPath();
+                   if (field == fHeaderFileDialogField) {
+                       filePath = chooseFile(NewClassWizardMessages.NewClassCreationWizardPage_ChooseHeaderFileDialog_title,
+                               getHeaderFileFullPath());
+                       if (filePath != null) {
+                           headerPath = filePath;
+                       }
+                   } else if (field == fSourceFileDialogField) {
+                               filePath = chooseFile(NewClassWizardMessages.NewClassCreationWizardPage_ChooseSourceFileDialog_title,
+                               getSourceFileFullPath());
+                       if (filePath != null) {
+                           sourcePath = filePath;
+                       }
+                   } else if (field == fTestFileDialogField) {
+                               filePath = chooseFile(NewClassWizardMessages.NewClassCreationWizardPage_ChooseTestFileDialog_title,
+                               getTestFileFullPath());
+                       if (filePath != null) {
+                           testPath = filePath;
+                       }
+                   }
+                   if (filePath != null) {
+                       IPath folderPath = null;
+                           int changedFields = 0;
+                   int headerSegments = 0;
+                   int sourceSegments = 0;
+                   int testSegments = 0;
+                   if (headerPath != null)
+                       headerSegments = filePath.matchingFirstSegments(headerPath);
+                   if (sourcePath != null)
+                       sourceSegments = filePath.matchingFirstSegments(sourcePath);
+                   if (testPath != null)
+                       testSegments = filePath.matchingFirstSegments(testPath);
+                   int segments = Math.min(Math.min(headerSegments, sourceSegments), testSegments);
+                   if (segments > 0) {
+                       IPath newFolderPath = filePath.uptoSegment(segments);
+                           folderPath = updateSourceFolderFromPath(newFolderPath);
+                   }
+                       if (folderPath != null) {
+                           changedFields |= SOURCE_FOLDER_ID | HEADER_FILE_ID | SOURCE_FILE_ID | TEST_FILE_ID;
+                                   // Adjust the relative paths
+                           setSourceFolderFullPath(folderPath, false);
+                                   setHeaderFileFullPath(headerPath, false);
+                                   setSourceFileFullPath(sourcePath, false);
+                                   setTestFileFullPath(testPath, false);
+                       }
+                           if (field == fHeaderFileDialogField) {
+                           setHeaderFileFullPath(filePath, false);
+                           changedFields |= HEADER_FILE_ID;
+                       } else if (field == fSourceFileDialogField) {
+                           setSourceFileFullPath(filePath, false);
+                           changedFields |= SOURCE_FILE_ID;
+                       } else if (field == fTestFileDialogField) {
+                           setTestFileFullPath(filePath, false);
+                           changedFields |= TEST_FILE_ID;
+                       }
+                               handleFieldChanged(changedFields);
+                   }
+               }
+               
+               public void dialogFieldChanged(DialogField field) {
+                   int changedFields = 0;
+                   if (field == fTestFileSelection) {
+                       boolean enabled = fTestFileSelection.isSelected();
+                       fTestFileDialogField.setEnabled(enabled);
+                       if (enabled) {
+                               fTestFileDerivedFromClassName = true;
+                               updateFilesFromClassName(fClassNameDialogField.getText().trim());
+                       } else {
+                               fTestFileDialogField.setTextWithoutUpdate(""); //$NON-NLS-1$
+                       }
+                       changedFields = TEST_FILE_ID;
+                           updateTestFileEnableState();
+                           handleFieldChanged(SOURCE_FOLDER_ID);
+                   }
+                   if (field == fHeaderFileDialogField) {
+                   changedFields |= HEADER_FILE_ID;
+                   fHeaderFileDerivedFromClassName = false;
+               } else if (field == fSourceFileDialogField) {
+                   changedFields |= SOURCE_FILE_ID;
+                   fSourceFileDerivedFromClassName = false;
+               } else if (field == fTestFileDialogField) {
+                   changedFields |= TEST_FILE_ID;
+                   fTestFileDerivedFromClassName = false;
+               }
+                       handleFieldChanged(changedFields);
+               }
+       }
+    
+    private IPath chooseFile(String title, IPath initialPath) {
+        SourceFileSelectionDialog dialog = new SourceFileSelectionDialog(getShell());
+        dialog.setTitle(title);
+        ICElement input = CoreModel.create(NewClassWizardUtil.getWorkspaceRoot());
+        ICProject project = getCurrentProject();
+        if (project != null)
+            input = project;
+        dialog.setInput(input);
+
+        IPath filePath = initialPath;
+        if (filePath != null) {
+            String folderName = filePath.removeLastSegments(1).toString();
+            String fileName = filePath.lastSegment();
+            dialog.setInitialSelection(folderName, fileName);
+        } else {
+            filePath = getSourceFolderFullPath();
+            if (filePath != null) {
+                dialog.setInitialSelection(filePath.toString(), null);
+            }
+        }
+        
+        if (dialog.open() == Window.OK) {
+            return dialog.getFilePath();
+        }
+        return null;
+    }   
+
+    /**
+     * update header and source file fields from the class name
+     */
+    private void updateFilesFromClassName(String className) {
+        String headerName = ""; //$NON-NLS-1$
+        String sourceName = ""; //$NON-NLS-1$
+        String testName = ""; //$NON-NLS-1$
+        IPath folder = getSourceFolderFullPath();
+        if (className != null && className.length() > 0) {
+            String[] names = generateFileNames(className, folder);
+            if (names != null && names.length == 3) {
+                headerName = names[0];
+                sourceName = names[1];
+                testName = names[2];
+            }
+        }
+        if (fHeaderFileDerivedFromClassName)
+               fHeaderFileDialogField.setTextWithoutUpdate(headerName);
+        if (fSourceFileDerivedFromClassName)
+               fSourceFileDialogField.setTextWithoutUpdate(sourceName);
+        if (fTestFileDerivedFromClassName && fTestFileDialogField.isEnabled())
+               fTestFileDialogField.setTextWithoutUpdate(testName);
+    }
+    
+    private static final int MAX_UNIQUE_CLASSNAME = 99;
+       private IDialogSettings fDialogSettings;
+
+    /**
+     * Returns the names of the header file and source file which will be
+     * used when this class is created, e.g. "MyClass" -> ["MyClass.h","MyClass.cpp"]
+     * Note: the file names should be unique to avoid overwriting existing files.
+     * 
+     * @param className the class name
+     * @param folder the folder where the files are to be created, or <code>null</code>
+     * @return an array of 2 Strings, containing the header file name and
+     * source file name, respectively.
+     */
+    protected String[] generateFileNames(String className, IPath folder) {
+        String headerName = null;
+        String sourceName = null;
+        String testName = null;
+        
+        if (folder == null) {
+            headerName = NewSourceFileGenerator.generateHeaderFileNameFromClass(className);
+            sourceName = NewSourceFileGenerator.generateSourceFileNameFromClass(className);
+            testName = NewSourceFileGenerator.generateTestFileNameFromClass(className);
+        } else {
+            // make sure the file names are unique
+            String currName = className;
+            int count = 0;
+            String separator = ""; //$NON-NLS-1$
+            if (Character.isDigit(className.charAt(className.length() - 1)))
+                separator = "_"; //$NON-NLS-1$
+            while (count < MAX_UNIQUE_CLASSNAME) {
+                String header = NewSourceFileGenerator.generateHeaderFileNameFromClass(currName);
+                IPath path = folder.append(header);
+                if (!path.toFile().exists()) {
+                    String source = NewSourceFileGenerator.generateSourceFileNameFromClass(currName);
+                    path = folder.append(source);
+                    if (!path.toFile().exists()) {
+                        String test = NewSourceFileGenerator.generateTestFileNameFromClass(currName);
+                        path = folder.append(test);
+                        if (!path.toFile().exists()) {
+                               headerName = header;
+                               sourceName = source;
+                               testName = test;
+                               // we're done
+                               break;
+                        }
+                    }
+                }
+                ++count;
+                currName = className + separator + count; 
+            }
+        }
+        
+        return new String[] { headerName, sourceName, testName };
+    }
+    
+    /**
+     * 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, NAMESPACE_ID)) {
+            fNamespaceStatus = namespaceChanged();
+        }
+        if (fieldChanged(fields, CLASS_NAME_ID)) {
+            fClassNameStatus = classNameChanged();
+        }
+        if (fieldChanged(fields, BASE_CLASSES_ID)) {
+            fBaseClassesStatus = baseClassesChanged();
+        }
+        if (fieldChanged(fields, METHOD_STUBS_ID)) {
+            fMethodStubsStatus = methodStubsChanged();
+        }
+        if (fieldChanged(fields, HEADER_FILE_ID)) {
+            fHeaderFileStatus = headerFileChanged();
+        }
+        if (fieldChanged(fields, SOURCE_FILE_ID)) {
+            fSourceFileStatus = sourceFileChanged();
+        }
+        if (fieldChanged(fields, TEST_FILE_ID)) {
+            fTestFileStatus = testFileChanged();
+        }
+        doStatusUpdate();
+    }
+
+    private boolean fieldChanged(int fields, int fieldID) {
+        return ((fields & fieldID) != 0);
+    }
+
+    /**
+     * Updates the status line and the ok button according to the status of the fields
+     * on the page. The most severe error is taken, with the last-focused field being
+     * evaluated first. 
+     */
+    protected void doStatusUpdate() {
+        // do the last focused field first
+        IStatus lastStatus = getLastFocusedStatus();
+
+        final boolean isClassNameWarning = fClassNameStatus.getSeverity() == IStatus.WARNING;
+        // status of all used components
+               IStatus[] status = new IStatus[] {
+            lastStatus,
+            (fSourceFolderStatus != lastStatus) ? fSourceFolderStatus : STATUS_OK,
+            (fNamespaceStatus != lastStatus) ? fNamespaceStatus : STATUS_OK,
+
+            // Give priority to file-level warnings over class name warnings
+            (fHeaderFileStatus != lastStatus && isClassNameWarning) ? fHeaderFileStatus : STATUS_OK,
+            (fSourceFileStatus != lastStatus && isClassNameWarning) ? fSourceFileStatus : STATUS_OK,
+            (fTestFileStatus != lastStatus && isClassNameWarning) ? fTestFileStatus : STATUS_OK,
+                    
+            (fClassNameStatus != lastStatus) ? fClassNameStatus : STATUS_OK,
+            (fBaseClassesStatus != lastStatus) ? fBaseClassesStatus : STATUS_OK,
+            (fMethodStubsStatus != lastStatus) ? fMethodStubsStatus : STATUS_OK,
+            (fHeaderFileStatus != lastStatus) ? fHeaderFileStatus : STATUS_OK,
+            (fSourceFileStatus != lastStatus) ? fSourceFileStatus : STATUS_OK,
+            (fTestFileStatus != lastStatus) ? fTestFileStatus : STATUS_OK,
+        };
+        
+        // the mode severe status will be displayed and the ok button enabled/disabled.
+        updateStatus(status);
+    }
+
+    /**
+     * Returns the status of the last field which had focus.
+     * 
+     * @return status of the last field which had focus
+     */
+    protected IStatus getLastFocusedStatus() {
+        switch (fLastFocusedField) {
+        case SOURCE_FOLDER_ID:
+            return fSourceFolderStatus;
+        case NAMESPACE_ID:
+            return fNamespaceStatus;
+        case CLASS_NAME_ID:
+            return fClassNameStatus;
+        case BASE_CLASSES_ID:
+            return fBaseClassesStatus;
+        case METHOD_STUBS_ID:
+            return fMethodStubsStatus;
+        case HEADER_FILE_ID:
+            return fHeaderFileStatus;
+        case SOURCE_FILE_ID:
+            return fSourceFileStatus;
+        case TEST_FILE_ID:
+            return fTestFileStatus;
+        default:
+               return STATUS_OK;
+        }
+    }
+    
+    /**
+     * Hook method that gets called when the source folder has changed. The method validates the 
+     * source folder and returns the status of the validation.
+     * 
+     * @return the status of the validation
+     */
+       protected IStatus sourceFolderChanged() {
+               StatusInfo status = new StatusInfo();
+               
+               IPath folderPath = getSourceFolderFullPath();
+               if (folderPath == null) {
+                       status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_EnterSourceFolderName);
+                       return status;
+               }
+
+               IResource res = NewClassWizardUtil.getWorkspaceRoot().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(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_NotAFolder, folderPath));
+                                       return status;
+                               }
+                           if (!CoreModel.hasCCNature(proj) && !CoreModel.hasCNature(proj)) {
+                                       if (resType == IResource.PROJECT) {
+                                               status.setError(NewClassWizardMessages.NewClassCreationWizardPage_warning_NotACProject);
+                                               return status;
+                                       }
+                                       status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_warning_NotInACProject);
+                               }
+                           if (NewClassWizardUtil.getSourceFolder(res) == null) {
+                                       status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_NotASourceFolder, folderPath));
+                                       return status;
+                               }
+                       } else {
+                               status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_NotAFolder, folderPath));
+                               return status;
+                       }
+               } else {
+                       status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_FolderDoesNotExist, folderPath));
+                       return status;
+               }
+
+               return status;
+       }
+               
+       /**
+     * Hook method that gets called when the namespace has changed. The method validates the 
+     * namespace and returns the status of the validation.
+     * 
+     * @return the status of the validation
+     */
+       protected IStatus namespaceChanged() {
+               StatusInfo status = new StatusInfo();
+               if (!isNamespaceSelected()) {
+                   return status;
+               }
+
+               // must not be empty
+        String namespace = getNamespaceText();
+               if (namespace == null || namespace.length() == 0) {
+                       status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_EnterNamespace);
+                       return status;
+               }
+
+               IStatus val = CConventions.validateNamespaceName(namespace);
+               if (val.getSeverity() == IStatus.ERROR) {
+                       status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_InvalidNamespace, val.getMessage()));
+                       return status;
+               } else if (val.getSeverity() == IStatus.WARNING) {
+                       status.setWarning(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_warning_NamespaceDiscouraged, val.getMessage()));
+               }
+
+               IQualifiedTypeName typeName = new QualifiedTypeName(namespace);
+               ICProject project = getCurrentProject();
+
+               if (project != null) {
+                       /* search for parent name space first */
+                       int searchResult;
+                       if (typeName.isQualified()) {
+                               searchResult = NewClassWizardUtil.searchForCppType(typeName.getEnclosingTypeName(),project, ICPPNamespace.class);
+                               if (searchResult != NewClassWizardUtil.SEARCH_MATCH_FOUND_EXACT) {
+                                       status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_EnclosingNamespaceNotExists);
+                                       return status;
+                               }
+                       }
+                       searchResult = NewClassWizardUtil.searchForCppType(typeName, project, ICPPNamespace.class);
+                       switch(searchResult) {
+                       case NewClassWizardUtil.SEARCH_MATCH_FOUND_EXACT:
+                               status.setOK();
+                               return status;                          
+                       case NewClassWizardUtil.SEARCH_MATCH_FOUND_EXACT_ANOTHER_TYPE:
+                               status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_error_TypeMatchingNamespaceExists);
+                               return status;
+                       case NewClassWizardUtil.SEARCH_MATCH_FOUND_ANOTHER_NAMESPACE:
+                               status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_error_NamespaceExistsDifferentCase);
+                               return status;
+                       case NewClassWizardUtil.SEARCH_MATCH_FOUND_ANOTHER_TYPE:
+                               status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_error_TypeMatchingNamespaceExistsDifferentCase);
+                               return status;
+                       case NewClassWizardUtil.SEARCH_MATCH_NOTFOUND:
+                               status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_warning_NamespaceNotExists);
+                               break;
+                       }
+           }
+
+           val = CConventions.validateNamespaceName(typeName.lastSegment());
+               if (val.getSeverity() == IStatus.ERROR) {
+                       status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_InvalidNamespace, val.getMessage()));
+                       return status;
+               }
+           return status;
+       }
+       
+       /**
+        * Hook method that gets called when the class name has changed. The method validates the 
+        * class name and returns the status of the validation.
+        * 
+        * @return the status of the validation
+        */
+       protected IStatus classNameChanged() {
+           StatusInfo status = new StatusInfo();
+           
+           String className = getClassName();
+               // must not be empty
+               if (className == null || className.length() == 0) {
+                       status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_EnterClassName);
+                       return status;
+               }
+
+        IQualifiedTypeName typeName = new QualifiedTypeName(className);
+        if (typeName.isQualified()) {
+            status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_QualifiedClassName);
+            return status;
+        }
+    
+               IStatus val = CConventions.validateClassName(className);
+               if (val.getSeverity() == IStatus.ERROR) {
+                       status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_InvalidClassName, val.getMessage()));
+                       return status;
+               } else if (val.getSeverity() == IStatus.WARNING) {
+                       status.setWarning(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_warning_ClassNameDiscouraged, val.getMessage()));
+                       // continue checking
+               }
+       
+           ICProject project = getCurrentProject();
+           if (project != null) {
+                   IQualifiedTypeName fullyQualifiedName = typeName;
+                       if (isNamespaceSelected()) {
+                String namespace = getNamespaceText();
+                if (namespace != null && namespace.length() > 0) {
+                               fullyQualifiedName = new QualifiedTypeName(namespace).append(typeName);
+                           }
+                       }
+                       int searchResult = NewClassWizardUtil.searchForCppType(fullyQualifiedName, project, ICPPClassType.class);
+                       switch(searchResult) {
+                       case NewClassWizardUtil.SEARCH_MATCH_FOUND_EXACT:
+                               status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_ClassNameExists);
+                               return status;                          
+                       case NewClassWizardUtil.SEARCH_MATCH_FOUND_EXACT_ANOTHER_TYPE:
+                               status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_TypeMatchingClassExists);
+                               return status;
+                       case NewClassWizardUtil.SEARCH_MATCH_FOUND_ANOTHER_NAMESPACE:
+                               status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_error_ClassNameExistsDifferentCase);
+                               return status;
+                       case NewClassWizardUtil.SEARCH_MATCH_FOUND_ANOTHER_TYPE:
+                               status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_error_TypeMatchingClassExistsDifferentCase);
+                               return status;
+                       case NewClassWizardUtil.SEARCH_MATCH_NOTFOUND:
+                               break;
+                       }       
+           }
+               return status;
+       }
+    
+       /**
+        * Hook method that gets called when the list of base classes has changed. The method 
+        * validates the base classes and returns the status of the validation.
+        * 
+        * @return the status of the validation
+        */
+       protected IStatus baseClassesChanged() {
+        if (verifyBaseClasses()) {
+                       IPath folder = getSourceFolderFullPath();
+            ICProject project = getCurrentProject();
+                       if (project != null) {
+                IBaseClassInfo[] baseClasses = getBaseClasses();
+                // make sure all classes belong to the project
+                if (baseClasses != null && baseClasses.length > 0) {
+                    IStatus status = baseClassesChanged(project, folder, baseClasses);
+                    if (status.isMultiStatus()) {
+                        // we only want to show the most severe error
+                        return StatusUtil.getMostSevere(status.getChildren());
+                    }
+                    return status;
+                }
+            }
+        }
+               return Status.OK_STATUS;
+       }
+    
+    /**
+     * This method validates the base classes by searching through the project's
+     * include paths and checking if each base class is reachable.
+     * 
+     * @param project the current project
+     * @param sourceFolder the current source folder
+     * @param baseClasses an array of base classes
+     * 
+     * @return the status of the validation
+     */
+    protected IStatus baseClassesChanged(ICProject project, IPath sourceFolder, IBaseClassInfo[] baseClasses) {
+        MultiStatus status = new MultiStatus(CUIPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
+        IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project.getProject());
+        if (provider != null) {
+            //TODO get the scanner info for the actual source folder
+            IScannerInfo info = provider.getScannerInformation(project.getProject());
+            if (info != null) {
+                String[] includePaths = info.getIncludePaths();
+                for (int i = 0; i < baseClasses.length; ++i) {
+                    IBaseClassInfo baseClass = baseClasses[i];
+                    ITypeInfo baseType = baseClass.getType();
+                    StatusInfo baseClassStatus = new StatusInfo();
+                    if (!NewClassWizardUtil.isTypeReachable(baseType, project, includePaths)) {
+                        baseClassStatus.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_BaseClassNotExistsInProject,
+                                       baseType.getQualifiedTypeName().toString()));
+                    }
+                    status.add(baseClassStatus);
+                }
+            }
+        }
+        return status;
+    }
+
+    /**
+     * Checks if the base classes need to be verified (ie they must exist in the project)
+     * 
+     * @return <code>true</code> if the base classes should be verified
+     */
+    public boolean verifyBaseClasses() {
+        return NewClassWizardPrefs.verifyBaseClasses();
+    }
+    
+    /**
+     * Hook method that gets called when the list of method stubs has changed. The method 
+     * validates the method stubs and returns the status of the validation.
+     * 
+     * @return the status of the validation
+     */
+       protected IStatus methodStubsChanged() {
+        // do nothing
+        return Status.OK_STATUS;
+       }
+
+    /**
+     * Hook method that gets called when the header file has changed. The method 
+     * validates the header file and returns the status of the validation.
+     * 
+     * @return the status of the validation
+     */
+       protected IStatus headerFileChanged() {
+               StatusInfo status = new StatusInfo();
+               
+               IPath path = getHeaderFileFullPath();
+               if (path == null) {
+                       status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_EnterHeaderFileName);
+                       return status;
+               }
+               
+               IPath sourceFolderPath = getSourceFolderFullPath();
+               if (sourceFolderPath == null || !sourceFolderPath.isPrefixOf(path)) {
+                       status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_HeaderFileNotInSourceFolder);
+                       return status;
+               }
+               
+               // Make sure the file location is under a source root
+               if (NewClassWizardUtil.getSourceFolder(path) == null) {
+                       status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_HeaderFileNotInSourceFolder);
+                       return status;
+               }
+               
+               boolean fileExists = false;
+               // Check if the file already exists
+               IResource file = NewClassWizardUtil.getWorkspaceRoot().getFile(path);
+       if (file.getType() == IResource.FILE) {
+               if (!file.exists()) {
+                               URI location = file.getLocationURI();
+                               try {
+                                       IFileStore store = EFS.getStore(location);
+                                       fileExists = store.fetchInfo().exists();
+                               } catch (CoreException e) {
+                                       status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_LocationUnknown);
+                                       return status;
+                               }
+               } else {
+                       fileExists = true;
+               }
+               
+                       IProject proj = file.getProject();
+                       if (!proj.isOpen()) {
+                               status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_NotAFile, path));
+                               return status;
+                       }
+
+                   if (!CoreModel.hasCCNature(proj) && !CoreModel.hasCNature(proj)) {
+                               status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_warning_NotInACProject);
+                       } else if (fileExists) {
+                           status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_warning_HeaderFileExists);
+                       }
+       } else {
+               status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_NotAFile);
+               return status;
+       }
+               
+               // Check if folder exists
+               IPath folderPath = path.removeLastSegments(1).makeRelative();
+               IResource folder = NewClassWizardUtil.getWorkspaceRoot().findMember(folderPath);
+               if (folder == null || !folder.exists() || (folder.getType() != IResource.PROJECT && folder.getType() != IResource.FOLDER)) {
+                       status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_FolderDoesNotExist, folderPath));
+                       return status;
+               }
+
+               if (!fileExists) {
+                       IStatus val = CConventions.validateHeaderFileName(getCurrentProject().getProject(), path.lastSegment());
+                       if (val.getSeverity() == IStatus.ERROR) {
+                               status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_InvalidHeaderFileName, val.getMessage()));
+                               return status;
+                       } else if (val.getSeverity() == IStatus.WARNING) {
+                               status.setWarning(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_warning_HeaderFileNameDiscouraged, val.getMessage()));
+                       }
+               }
+               return status;
+       }
+
+    /**
+     * Hook method that gets called when the source file has changed. The method 
+     * validates the source file and returns the status of the validation.
+     * 
+     * @return the status of the validation
+     */
+       protected IStatus sourceFileChanged() {
+               StatusInfo status = new StatusInfo();
+               
+               IPath path = getSourceFileFullPath();
+               if (path == null) {
+                       status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_EnterSourceFileName);
+                       return status;
+               }
+               
+               IPath sourceFolderPath = getSourceFolderFullPath();
+               if (sourceFolderPath == null || !sourceFolderPath.isPrefixOf(path)) {
+                       status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_SourceFileNotInSourceFolder);
+                       return status;
+               }
+               
+               // Make sure the file location is under a source root
+               if (NewClassWizardUtil.getSourceFolder(path) == null) {
+                       status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_SourceFileNotInSourceFolder);
+                       return status;
+               }
+               
+               boolean fileExists = false;
+               // Check if file already exists
+               IResource file = NewClassWizardUtil.getWorkspaceRoot().getFile(path);
+       if (file.getType() == IResource.FILE) {
+               if (!file.exists()) {
+                               URI location = file.getLocationURI();
+                               try {
+                                       IFileStore store = EFS.getStore(location);
+                                       fileExists = store.fetchInfo().exists();
+                               } catch (CoreException e) {
+                                       status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_LocationUnknown);
+                                       return status;
+                               }
+               } else {
+                       fileExists = true;
+               }
+               
+                       IProject proj = file.getProject();
+                       if (!proj.isOpen()) {
+                               status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_NotAFile, path));
+                               return status;
+                       }
+
+                   if (!CoreModel.hasCCNature(proj) && !CoreModel.hasCNature(proj)) {
+                               status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_warning_NotInACProject);
+                       } else if (fileExists) {
+                           status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_warning_SourceFileExists);
+                       }
+       } else {
+               status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_NotAFile);
+               return status;
+       }
+               
+               // Check if folder exists
+               IPath folderPath = path.removeLastSegments(1).makeRelative();
+               IResource folder = NewClassWizardUtil.getWorkspaceRoot().findMember(folderPath);
+               if (folder == null || !folder.exists() || (folder.getType() != IResource.PROJECT && folder.getType() != IResource.FOLDER)) {
+                       status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_FolderDoesNotExist, folderPath));
+                       return status;
+               }
+
+               if (!fileExists) {
+                       IStatus val = CConventions.validateSourceFileName(getCurrentProject().getProject(), path.lastSegment());
+                       if (val.getSeverity() == IStatus.ERROR) {
+                               status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_InvalidSourceFileName, val.getMessage()));
+                               return status;
+                       } else if (val.getSeverity() == IStatus.WARNING) {
+                               status.setWarning(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_warning_SourceFileNameDiscouraged, val.getMessage()));
+                       }
+               }
+               return status;
+       }
+    
+    /**
+     * Hook method that gets called when the test file has changed. The method 
+     * validates the test file and returns the status of the validation.
+     * 
+     * @return the status of the validation
+     * @since 5.3
+     */
+       protected IStatus testFileChanged() {
+               StatusInfo status = new StatusInfo();
+
+               if (!fTestFileDialogField.isEnabled()) {
+                       return status;
+               }
+               IPath path = getTestFileFullPath();
+               if (path == null) {
+                       status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_EnterTestFileName);
+                       return status;
+               }
+
+               IPath sourceFolderPath = getSourceFolderFullPath();
+               if (sourceFolderPath == null || !sourceFolderPath.isPrefixOf(path)) {
+                       status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_TestFileNotInSourceFolder);
+                       return status;
+               }
+               
+               // Make sure the file location is under a source root
+               if (NewClassWizardUtil.getSourceFolder(path) == null) {
+                       status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_TestFileNotInSourceFolder);
+                       return status;
+               }
+               
+               boolean fileExists = false;
+               // Check if file already exists
+               IResource file = NewClassWizardUtil.getWorkspaceRoot().getFile(path);
+       if (file.getType() == IResource.FILE) {
+               if (!file.exists()) {
+                               URI location = file.getLocationURI();
+                               try {
+                                       IFileStore store = EFS.getStore(location);
+                                       fileExists = store.fetchInfo().exists();
+                               } catch (CoreException e) {
+                                       status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_LocationUnknown);
+                                       return status;
+                               }
+               } else {
+                       fileExists = true;
+               }
+               
+                       IProject proj = file.getProject();
+                       if (!proj.isOpen()) {
+                               status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_NotAFile, path));
+                               return status;
+                       }
+
+                   if (!CoreModel.hasCCNature(proj) && !CoreModel.hasCNature(proj)) {
+                               status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_warning_NotInACProject);
+                       } else if (fileExists) {
+                           status.setWarning(NewClassWizardMessages.NewClassCreationWizardPage_warning_TestFileExists);
+                       }
+       } else {
+               status.setError(NewClassWizardMessages.NewClassCreationWizardPage_error_NotAFile);
+               return status;
+       }
+               
+               // Check if folder exists
+               IPath folderPath = path.removeLastSegments(1).makeRelative();
+               IResource folder = NewClassWizardUtil.getWorkspaceRoot().findMember(folderPath);
+               if (folder == null || !folder.exists() || (folder.getType() != IResource.PROJECT && folder.getType() != IResource.FOLDER)) {
+                       status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_FolderDoesNotExist, folderPath));
+                       return status;
+               }
+
+               if (!fileExists) {
+                       IStatus val = CConventions.validateSourceFileName(getCurrentProject().getProject(), path.lastSegment());
+                       if (val.getSeverity() == IStatus.ERROR) {
+                               status.setError(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_error_InvalidTestFileName, val.getMessage()));
+                               return status;
+                       } else if (val.getSeverity() == IStatus.WARNING) {
+                               status.setWarning(NLS.bind(NewClassWizardMessages.NewClassCreationWizardPage_warning_TestFileNameDiscouraged, val.getMessage()));
+                       }
+               }
+               return status;
+       }
+    
+    // -------- Code Generation ---------
+    
+       /**
+        * Creates the new class 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 void createClass(IProgressMonitor monitor) throws CoreException, InterruptedException {
+               // Update dialog settings.
+               fDialogSettings.put(KEY_NAMESPACE_SELECTED, fNamespaceSelection.isSelected());
+               fDialogSettings.put(KEY_TEST_FILE_SELECTED, fTestFileSelection.isSelected());
+               String namespace = fNamespaceSelection.isSelected() ? getNamespaceText() : null;
+               fDialogSettings.put(KEY_NAMESPACE, namespace);
+        IMethodStub[] stubs = fMethodStubsDialogField.getMethodStubs();
+        for (int i = 0; i < stubs.length; ++i) {
+               IMethodStub stub = stubs[i];
+               if (stub.canModifyVirtual()) {
+                       fDialogSettings.put(KEY_STUB_VIRTUAL + i, stub.isVirtual());
+               }
+               if (stub.canModifyInline()) {
+                       fDialogSettings.put(KEY_STUB_INLINE + i, stub.isInline());
+               }
+               fDialogSettings.put(KEY_STUB_SELECTED + i, fMethodStubsDialogField.isChecked(stub));
+        }
+
+               fCreatedClass = null;
+        fCreatedHeaderFile = null;
+        fCreatedSourceFile = null;
+        fCreatedTestFile = null;
+
+        IPath headerPath = getHeaderFileFullPath();
+        IPath sourcePath = getSourceFileFullPath();
+        IPath testPath = getTestFileFullPath();
+        createClass(
+                       headerPath != null ? getCanonicalPath(headerPath) : null,
+                       sourcePath != null ? getCanonicalPath(sourcePath) : null,
+                testPath != null ? getCanonicalPath(testPath) : null,
+                getClassName(),
+                namespace,
+                getBaseClasses(),
+                getSelectedMethodStubs(), monitor);
+       }
+    
+    private IPath getCanonicalPath(IPath path) throws CoreException {
+       IWorkspaceRoot root = NewClassWizardUtil.getWorkspaceRoot();
+       IFile file = root.getFile(path);
+       URI location = file.getLocationURI();
+       URI canonicalLocation = EFS.getStore(location).toURI();
+       IFile[] files = root.findFilesForLocationURI(canonicalLocation);
+       if (files.length > 0) {
+               return files[0].getFullPath();
+       }
+       return null;
+       }
+
+       /**
+     * Returns whether the generated header and source files should be
+     * opened in editors after the finish button is pressed.
+     * 
+     * @return <code>true</code> if the header and source file should be
+     * displayed
+     */
+    public boolean openClassInEditor() {
+        return NewClassWizardPrefs.openClassInEditor();
+    }
+    
+    /**
+     * Creates a new class.
+     * 
+     * @param headerPath the header file path
+     * @param sourcePath the source file path
+     * @param testPath the test file path, can be {@code null}.
+     * @param className the class name
+     * @param namespace the namespace
+     * @param baseClasses array of base classes
+     * @param methodStubs array of method stubs
+     * @param monitor a progress monitor
+     * @throws CoreException if the creation failed
+     * @throws InterruptedException if the operation was cancelled
+     * @since 5.3
+     */
+    protected void createClass(IPath headerPath, IPath sourcePath, IPath testPath, String className,
+               String namespace, IBaseClassInfo[] baseClasses, IMethodStub[] methodStubs, IProgressMonitor monitor)
+               throws CoreException, InterruptedException {
+        NewClassCodeGenerator generator = new NewClassCodeGenerator(
+                headerPath,
+                sourcePath,
+                testPath,
+                className,
+                namespace,
+                baseClasses,
+                methodStubs);
+        generator.setForceSourceFileCreation(true);
+        generator.createClass(monitor);
+        
+        fCreatedClass = generator.getCreatedClass();
+        fCreatedHeaderFile = generator.getCreatedHeaderFile();
+        fCreatedSourceFile = generator.getCreatedSourceFile();
+        fCreatedTestFile = generator.getCreatedTestFile();
+    }
+       
+    protected void createClass(IPath headerPath, IPath sourcePath, String className, String namespace,
+               IBaseClassInfo[] baseClasses, IMethodStub[] methodStubs, IProgressMonitor monitor)
+               throws CoreException, InterruptedException {
+       createClass(headerPath, sourcePath, null, className, namespace, baseClasses, methodStubs,
+                       monitor);
+    }
+
+       /**
+        * Returns the created class. The method only returns a valid class 
+        * after <code>createClass</code> has been called.
+        * 
+        * @return the created class
+        * @see #createClass(IProgressMonitor)
+        */                     
+       public ICElement getCreatedClass() {
+        return fCreatedClass;
+       }
+    
+    /**
+     * Returns the created header file. The method only returns a valid file 
+     * after <code>createClass</code> has been called.
+     *
+     * @return the created header file
+     * @see #createClass(IProgressMonitor)
+     */         
+    public IFile getCreatedHeaderFile() {
+        return fCreatedHeaderFile;
+    }
+
+    /**
+     * Returns the created source file. The method only returns a valid file 
+     * after <code>createClass</code> has been called.
+     * 
+     * @return the created source file
+     * @see #createClass(IProgressMonitor)
+     */         
+    public IFile getCreatedSourceFile() {
+       return fCreatedSourceFile;
+    }
+
+    /**
+     * Returns the created test file. The method only returns a valid file 
+     * after <code>createClass</code> has been called.
+     * 
+     * @return the created test file
+     * @see #createClass(IProgressMonitor)
+     * @since 5.3
+     */         
+    public IFile getCreatedTestFile() {
+       return fCreatedTestFile;
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewFileCreationWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewFileCreationWizard.java
new file mode 100644 (file)
index 0000000..a0d9a25
--- /dev/null
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.wizards;
+
+import org.eclipse.ui.wizards.newresource.BasicNewFileResourceWizard;
+
+/**
+ * @deprecated Use {@link BasicNewFileResourceWizard} instead.
+ */
+@Deprecated
+public class NewFileCreationWizard extends BasicNewFileResourceWizard {
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewFolderCreationWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewFolderCreationWizard.java
new file mode 100644 (file)
index 0000000..5555185
--- /dev/null
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.wizards;
+
+import org.eclipse.ui.wizards.newresource.BasicNewFolderResourceWizard;
+
+/**
+ * @deprecated Use {@link BasicNewFolderResourceWizard} instead.
+ */
+@Deprecated
+public class NewFolderCreationWizard extends BasicNewFolderResourceWizard {
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewHeaderFileCreationWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewHeaderFileCreationWizard.java
new file mode 100644 (file)
index 0000000..37bba7d
--- /dev/null
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     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.NewHeaderFileCreationWizard_title); 
+    }
+    
+    /*
+     * @see Wizard#createPages
+     */
+    @Override
+       public void addPages() {
+        super.addPages();
+        fPage = new NewHeaderFileCreationWizardPage();
+        addPage(fPage);
+        fPage.init(getSelection());
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewSourceFileCreationWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewSourceFileCreationWizard.java
new file mode 100644 (file)
index 0000000..d419131
--- /dev/null
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2008 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     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.NewSourceFileCreationWizard_title); 
+    }
+    
+    /*
+     * @see Wizard#createPages
+     */
+    @Override
+       public void addPages() {
+        super.addPages();
+        fPage = new NewSourceFileCreationWizardPage();
+        addPage(fPage);
+        fPage.init(getSelection());
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewSourceFolderCreationWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewSourceFolderCreationWizard.java
new file mode 100644 (file)
index 0000000..59d9f25
--- /dev/null
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.wizards;
+
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.wizards.NewElementWizard;
+import org.eclipse.cdt.internal.ui.wizards.folderwizard.NewFolderWizardMessages;
+import org.eclipse.cdt.internal.ui.wizards.folderwizard.NewSourceFolderWizardPage;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+public class NewSourceFolderCreationWizard extends NewElementWizard {
+
+       private NewSourceFolderWizardPage fPage;
+
+       public NewSourceFolderCreationWizard() {
+               super();
+               setDefaultPageImageDescriptor(CPluginImages.DESC_WIZBAN_NEWSRCFOLDR);
+               setDialogSettings(CUIPlugin.getDefault().getDialogSettings());
+               setWindowTitle(NewFolderWizardMessages.NewSourceFolderCreationWizard_title);
+       }
+
+       /*
+        * @see Wizard#addPages
+        */     
+       @Override
+       public void addPages() {
+               super.addPages();
+               fPage= new NewSourceFolderWizardPage();
+               addPage(fPage);
+               fPage.init(getSelection());
+       }                       
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jdt.internal.ui.wizards.NewElementWizard#finishPage(org.eclipse.core.runtime.IProgressMonitor)
+        */
+       @Override
+       protected void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException {
+               fPage.createSourceRoot(monitor); // use the full progress monitor
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.IWizard#performFinish()
+        */
+       @Override
+       public boolean performFinish() {
+               boolean res= super.performFinish();
+               if (res) {
+                       selectAndReveal(fPage.getCorrespondingResource());
+               }
+               return res;
+       }
+               
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConversionWizard.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConversionWizard.java
new file mode 100644 (file)
index 0000000..67275ae
--- /dev/null
@@ -0,0 +1,167 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.wizards.conversion;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbench;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.wizards.NewCProjectWizard;
+
+/**
+ * ConversionWizard  This wizard provides a method by which the user can
+ * change the nature of their projects. This class cannot be implemented.  It
+ * is meant to be subclassed, with the subclasses providing the new labels,
+ * and pages.
+ * 
+ * @author Judy N. Green
+ * @since Aug 8, 2002
+ */
+public abstract class ConversionWizard
+    extends NewCProjectWizard {
+
+    // Titles and descriptions may be overwritten by subclasses through the accessor methods.
+    private static final String WZ_TITLE = "ConversionWizard.title"; //$NON-NLS-1$
+    private static final String WZ_DESC = "ConversionWizard.description"; //$NON-NLS-1$
+    private static final String PREFIX = "ConversionWizard"; //$NON-NLS-1$
+
+    // Window Title should be overwritten by subclasses
+    private static final String WINDOW_TITLE = "ConversionWizard.windowTitle"; //$NON-NLS-1$
+
+    // the wizards main page containing the list of projects that the user may select for conversion.
+    protected ConvertProjectWizardPage mainPage;
+
+    /**
+     * Conversion Wizard constructor
+     */
+    public ConversionWizard() {
+        this(getWindowTitleResource(), getWzDescriptionResource());
+    }
+
+    /**
+     * Conversion Wizard constructor
+     * 
+     * @param title
+     * @param desc
+     */
+    public ConversionWizard(String title, String desc) {
+        super(title, desc);
+    }
+
+    /* (non-Javadoc)
+     * Method declared on IWorkbenchWizard.
+     */
+    @Override
+       public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
+        super.init(workbench, currentSelection);
+        setWindowTitle(getWindowTitleResource());
+    }
+    
+    /**
+     * Method getWindowTitleResource, allows Wizard Title label value to be
+     * changed by subclasses
+     * 
+     * @return String
+     */
+    protected static String getWindowTitleResource() {
+
+        return CUIPlugin.getResourceString(WINDOW_TITLE);
+    }
+
+    /**
+     * Method getWzDescriptionResource,  allows Wizard description label value
+     * to be changed by subclasses
+     * 
+     * @return String
+     */
+    protected static String getWzDescriptionResource() {
+
+        return CUIPlugin.getResourceString(WZ_DESC);
+    }
+    
+    /**
+     * Method getWzTitleResource,  allows Wizard description label value
+     * to be changed by subclasses
+     * 
+     * @return String
+     */
+    protected static String getWzTitleResource() {
+
+        return CUIPlugin.getResourceString(WZ_TITLE);
+    }
+
+    /**
+     * Method getPrefix,  allows prefix value to be changed by subclasses
+     * 
+     * @return String
+     */
+    protected static String getPrefix() {
+
+        return PREFIX;
+    }
+
+    /**
+     * Method doRun calls the doRunPrologue and mainPage's  doRun method and the
+     * doRunEpliogue. Subclasses may overwrite to add further actions
+     */
+    @Override
+       protected void doRun(IProgressMonitor monitor) throws CoreException {
+        try{
+            mainPage.doRun(monitor, getProjectID(), getBuildSystemId());
+        } catch (CoreException ce){
+            CUIPlugin.log(ce);
+            throw ce;
+        } finally{
+            doRunEpilogue(monitor);
+            monitor.isCanceled();
+        }
+    }
+    /**
+     * Return the type of project that it is being converted to
+     * The default if a make project
+     */
+    @Override
+       public abstract String getProjectID();
+
+    /**
+     * Method addPages allows subclasses to add as many pages as they need. Overwrite
+     * to create at least one conversion specific page. <p>
+     * 
+     * i.e. <br>
+     *<pre> 
+     *   mainPage = new ConvertToStdMakeProjectWizardPage(getPrefix());
+     *   addPage(mainPage);
+     *</pre>
+     * 
+     * @see NewCProjectWizard#addPages
+     */
+    @Override
+       public abstract void addPages();
+
+    /**
+     * Required by superclass but with no implementation here
+     * 
+     * @param monitor 
+     */
+    @Override
+       protected void doRunPrologue(IProgressMonitor monitor) {}
+
+    /**
+     * Required by superclass but with no implementation here
+     * 
+     * @param monitor 
+     */
+    @Override
+       protected void doRunEpilogue(IProgressMonitor monitor) {}
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConvertProjectWizardPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/conversion/ConvertProjectWizardPage.java
new file mode 100644 (file)
index 0000000..2637231
--- /dev/null
@@ -0,0 +1,610 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     IBM Corporation
+ *******************************************************************************/
+package org.eclipse.cdt.ui.wizards.conversion;
+
+
+import java.util.Vector;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.accessibility.AccessibleAdapter;
+import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+
+import org.eclipse.cdt.core.CCProjectNature;
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.CProjectNature;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+
+import org.eclipse.cdt.internal.ui.CUIMessages;
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.util.SWTUtil;
+
+
+/**
+ * <p>
+ * ConvertProjectWizardPage  Standard main page for a wizard that converts a
+ * project's nature.<br> This class provides the UI components and populates
+ * the table with all  projects that meet the criteria specified by
+ * subclasses in the method  isCandidate(IProject). This class does the
+ * conversion through the method convertProjects([]Object), which is also
+ * defined by all subclasses.<br> Subclasses provide the methods that
+ * determine what files are displayed and what action is performed on them as
+ * well as the labels for the Wizard.</p>
+ * 
+ * Note: Only Projects that are open will be considered for conversion.
+ * 
+ * 
+ * @author Judy N. Green
+ * @since Aug 6, 2002 <p>
+ */
+public abstract class ConvertProjectWizardPage
+    extends WizardPage {
+
+       public static final String  KEY_TITLE = "ConvertionWizard.title"; //$NON-NLS-1$
+    public static final String  KEY_CONVERTING = "ConvertionWizard.converting"; //$NON-NLS-1$
+    private static final String PROJECT_LIST = "ConversionWizard.projectlist"; //$NON-NLS-1$
+
+       protected boolean convertToC = false;
+    protected boolean convertToCC = true;
+    protected Button cRadioButton;
+    protected Button ccRadioButton;
+   
+    // The Main widget containing the table and its list of candidate open projects
+    protected CheckboxTableViewer tableViewer;
+    
+    protected Button selectAllButton;
+    protected Button deselectAllButton;
+    
+    // We only need to calculate this once per instantiation of this wizard
+    protected Object[] listItems = null;
+
+    /**
+     * Constructor for ConvertProjectWizardPage.
+     * 
+     * @param pageName
+     */
+    public ConvertProjectWizardPage(String pageName) {
+        super(pageName);
+        setTitle(getWzTitleResource());
+        setDescription(getWzDescriptionResource());
+    }
+
+    // get methods to allow values to be changed by subclasses
+    protected abstract String getWzTitleResource();
+
+    protected abstract String getWzDescriptionResource();
+
+    /**
+     * Returns the elements that the user has checked
+     * 
+     * @return Object[]
+     */
+    protected Object[] getCheckedElements() {
+
+        return tableViewer.getCheckedElements();
+    }
+
+    /**
+     * Creates the main wizard page.
+     * 
+     * @see org.eclipse.jface.dialogs.IDialogPage#createControl(Composite)
+     */
+    public void createControl(Composite parent) {
+
+        Composite  container = new Composite(parent, SWT.NONE);
+        
+        GridLayout layout = new GridLayout();
+        layout.marginHeight = 0;
+        layout.marginWidth = 0;
+        container.setLayout(layout);
+        setControl(createAvailableProjectsGroup(container));  
+        addToMainPage(container);      
+        // will default to false until a selection is made
+        setPageComplete(validatePage());
+        PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.CONVERT_TO_CCPP_WIZARD_PAGE);
+    }
+    
+    /**
+     * Method addToMainPage allows subclasses to add 
+     * elements to the main page. 
+     * 
+     */
+    protected void addToMainPage(Composite container){
+       
+               // Add convert to C or C/C++ buttons
+               Composite area = ControlFactory.createGroup(container, CUIMessages.ConvertProjectWizardPage_convertTo, 2); 
+               
+
+               SelectionListener cListener =  new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent event) {                              
+                               convertToC = cRadioButton.getSelection();
+                               convertToCC = ccRadioButton.getSelection();     
+                               validatePage();
+                       }
+               };
+               cRadioButton = ControlFactory.createRadioButton(area, 
+                                                         CUIMessages.ConvertProjectWizardPage_CProject, 
+                                                         "C ", //$NON-NLS-1$
+                                                     cListener);
+               cRadioButton.setSelection(convertToC);                                                
+               ccRadioButton = ControlFactory.createRadioButton(area, 
+                                                         CUIMessages.ConvertProjectWizardPage_CppProject, 
+                                                         "C++", //$NON-NLS-1$
+                                                     cListener);       
+               ccRadioButton.setSelection(convertToCC);                                                      
+                               
+               area.addDisposeListener(new DisposeListener() {
+                       public void widgetDisposed(DisposeEvent event) {
+                               cRadioButton = null;
+                               ccRadioButton = null;
+                       }
+               });      
+    }
+
+    /**
+     * Creates a list of projects that can be selected by the user.
+     * 
+     * @param parent the parent composite
+     * @return Composite
+     */
+    private final Composite createAvailableProjectsGroup(Composite parent) {
+
+        // Add a label
+        Label label = new Label(parent, SWT.LEFT);
+        label.setText(CUIPlugin.getResourceString(PROJECT_LIST));
+        
+        Composite  container = new Composite(parent, SWT.NONE);
+        GridLayout layout = new GridLayout();
+        layout.marginHeight = 5;
+        layout.marginWidth = 5;
+        layout.numColumns = 2;
+        container.setLayout(layout);
+        GridData data = new GridData(GridData.FILL_BOTH);
+        container.setLayoutData(data);
+        
+        // create the table
+        Table    table = new Table(container, 
+                                   SWT.CHECK | SWT.BORDER | SWT.MULTI | 
+                                   SWT.SINGLE | SWT.H_SCROLL | 
+                                   SWT.V_SCROLL);
+        data = new GridData(GridData.FILL_BOTH);
+        table.setLayoutData(data);
+        table.setHeaderVisible(true);
+        table.setLinesVisible(false);
+        table.getAccessible().addAccessibleListener(
+            new AccessibleAdapter() {                       
+                @Override
+                               public void getName(AccessibleEvent e) {
+                        e.result = CUIPlugin.getResourceString(PROJECT_LIST);
+                }
+            }
+        );
+        
+        TableLayout tableLayout = new TableLayout();
+        table.setHeaderVisible(false);
+        table.setLayout(tableLayout);
+
+        // add a table viewer
+        tableViewer = new CheckboxTableViewer(table);
+        tableViewer.setLabelProvider(new ProjectLabelProvider());
+        tableViewer.setContentProvider(new ProjectContentProvider());
+
+        // set initial input
+        tableViewer.setInput(getElements());
+
+        // define and assign sorter
+        tableViewer.setSorter(new ViewerSorter() {
+            @Override
+                       public int compare(Viewer viewer, Object object1, Object object2) {
+
+                if ((object1 instanceof IProject) && (object2 instanceof IProject)) {
+                    IProject left = (IProject)object1;
+                    IProject right = (IProject)object2;
+                    int result = left.getName().compareToIgnoreCase(right.getName());
+
+                    if (result != 0) {
+                        return result;
+                    }
+                    return left.getName().compareToIgnoreCase(right.getName());
+                }
+                return super.compare(viewer, object1, object2);
+            }
+
+            @Override
+                       public boolean isSorterProperty(Object element, String property) {
+                return true;
+            }
+        });
+        tableViewer.setAllChecked(false);        
+        tableViewer.refresh();
+        
+        tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+            public void selectionChanged(SelectionChangedEvent e) {
+                // will default to false until a selection is made
+                setPageComplete(validatePage());
+                updateSelectionButtons();
+            }
+        });
+        // Add button panel
+        
+        Composite buttons= new Composite(container, SWT.NULL);
+        buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+        layout= new GridLayout();
+        layout.marginHeight= 0;
+        layout.marginWidth= 0;
+        layout.verticalSpacing = 8;
+        buttons.setLayout(layout);
+        
+        
+        selectAllButton= new Button(buttons, SWT.PUSH);
+        selectAllButton.setText(CUIMessages.ConvertProjectWizardPage_SelectAll); 
+        selectAllButton.setLayoutData(getButtonGridData(selectAllButton));
+        selectAllButton.addListener(SWT.Selection, new Listener() {
+            public void handleEvent(Event e) {
+                ConvertProjectWizardPage.this.tableViewer.setAllChecked(true);
+                // update the pageComplete status
+                setPageComplete(true);
+                updateSelectionButtons();                
+            }
+        });
+
+        deselectAllButton= new Button(buttons, SWT.PUSH);
+        deselectAllButton.setText(CUIMessages.ConvertProjectWizardPage_DeselectAll); 
+        deselectAllButton.setLayoutData(getButtonGridData(deselectAllButton));
+        deselectAllButton.addListener(SWT.Selection, new Listener() {
+            public void handleEvent(Event e) {
+                ConvertProjectWizardPage.this.tableViewer.setAllChecked(false);
+                // update the pageComplete status
+                setPageComplete(false);
+                updateSelectionButtons();
+            }
+        });
+        
+        // enable or disable selection buttons
+        Object[] elements = getElements();
+        boolean enableSelectionButtons = (elements != null) && (elements.length > 0);
+                
+        selectAllButton.setEnabled(enableSelectionButtons);
+        // we've called setAllChecked(false) earlier
+        deselectAllButton.setEnabled(false); 
+
+        return parent;
+    }
+       
+     /*
+      * Method updateSelectionButtons, enables/disables buttons
+      * dependent on what is selected
+      */
+      
+     protected void updateSelectionButtons() { 
+        
+        // update select and deselect buttons as required 
+        Object[] checkedObjects = getCheckedElements(); 
+        int totalItems = tableViewer.getTable().getItemCount();
+        boolean allSelected = checkedObjects.length == totalItems;
+        boolean noneSelected = checkedObjects.length == 0;            
+        selectAllButton.setEnabled(!allSelected);
+        deselectAllButton.setEnabled(!noneSelected);
+      }
+    /*
+     * Method  getButtonGridData creates 
+     * and returns a GridData for the given button
+     * 
+     * @GridData
+     */
+    private static GridData getButtonGridData(Button button) {
+        GridData data= new GridData(GridData.FILL_HORIZONTAL);
+        data.widthHint= SWTUtil.getButtonWidthHint(button);
+    
+        return data;
+    }
+
+    /**
+     * Returns whether this page's controls currently all contain valid values.
+     * 
+     * @return <code>true</code> if the user has selected at  least one
+     *         candidate project.
+     */
+    protected boolean validatePage() {
+
+        Object[] selection = getCheckedElements();
+
+        return ((selection != null) && (selection.length > 0));
+    }
+
+    /**
+     * Provides the contents for the list using the enclosing class's method
+     * getElements();
+     */
+    public class ProjectContentProvider
+        implements IStructuredContentProvider {
+        public Object[] getElements(Object parent) {
+             return listItems;                
+        }
+
+        public void dispose() {}
+
+        public void inputChanged(Viewer viewer, Object oldInput, 
+                                 Object newInput) {}
+    }
+
+    /**
+     * Provides labels for the listed items.  In this case it returns each
+     * project's name
+     */
+    public class ProjectLabelProvider
+        extends LabelProvider
+        implements ITableLabelProvider {
+        public String getColumnText(Object obj, int index) {
+
+            if (index == 0) {
+
+                return ((IProject)obj).getName();
+            }
+
+            return ""; //$NON-NLS-1$
+        }
+
+        public Image getColumnImage(Object obj, int index) {
+
+            return PlatformUI.getWorkbench().getSharedImages().getImage(
+                           IDE.SharedImages.IMG_OBJ_PROJECT);
+        }
+    }
+
+    /**
+     * Returns a list of open projects that are determined to be candidates
+     * through the method isCandidate().<br>
+     * 
+     * Note: Only Projects that are open will be considered for conversion.
+     * 
+     * @return Object[] which may be null
+     */
+    protected Object[] getElements() {
+
+        IWorkspace workspace = CUIPlugin.getWorkspace();
+        IProject[] projects = workspace.getRoot().getProjects();
+        Vector<IProject>     candidates = new Vector<IProject>(projects.length);
+        IProject   next = null;
+
+        // ensure we only present open, valid candidates to the user
+        for (IProject project : projects) {
+            next = project;
+
+            if ((next != null) 
+                    && next.isOpen() 
+                        && isCandidate(next)) {
+                candidates.addElement(next);
+            }
+
+            next = null;
+        }
+
+        // convert to an array for return
+        Object[] candidateArray = null;
+
+        if (candidates.size() > 0) {
+            candidateArray = new Object[candidates.size()];
+            candidates.copyInto(candidateArray);
+        }
+        // update the global variable that will 
+        // be returned by the ProjectContentProvider
+        listItems = candidateArray;
+        
+        return candidateArray;
+    }
+
+    /**
+     * doRun can be overwritten in subclasses to change behaviour, but this is
+     * generally not required. It is called from the corresponding Conversion
+     * Wizard
+     * 
+     * @param monitor
+     * @param projectID
+     * @exception CoreException
+     */
+    public void doRun(IProgressMonitor monitor, String projectID) throws CoreException {
+
+        Object[] selection = getCheckedElements();
+        int      totalSelected = selection.length;
+
+        if (totalSelected > 0) {
+            if (monitor == null) {
+                monitor = new NullProgressMonitor();
+            }
+            monitor.beginTask(CUIPlugin.getResourceString(KEY_TITLE), 1);
+            convertProjects(selection, monitor, projectID);
+        }
+    }
+    
+    public void doRun(IProgressMonitor monitor, String projectID, String bsId) throws CoreException {
+       if(bsId == null)
+               doRun(monitor, projectID);
+       else {
+               Object[] selection = getCheckedElements();
+               if (selection != null) {
+                       int      totalSelected = selection.length;
+
+                       if (totalSelected > 0) {
+                               if (monitor == null) {
+                                       monitor = new NullProgressMonitor();
+                               }
+                               monitor.beginTask(CUIPlugin.getResourceString(KEY_TITLE), 1);
+                               convertProjects(selection, bsId, monitor);
+                       }
+               }
+       }
+    }
+
+    /**
+     * convertProjects calls the convertProject() method on each project
+     * passed to it.
+     * 
+     * @param selected
+     * @param monitor
+     * @param projectID
+     * @throws CoreException
+     */
+    private void convertProjects(Object[] selected, IProgressMonitor monitor, String projectID)
+                          throws CoreException {
+        monitor.beginTask(CUIPlugin.getResourceString(KEY_CONVERTING), 
+                          selected.length);
+               try {
+               for (Object element : selected) {
+                   IProject project = (IProject)element;
+               convertProject(project, new SubProgressMonitor(monitor, 1), projectID);
+               }
+               } finally {
+               monitor.done();
+               }
+    }
+
+    private void convertProjects(Object[] selected, String bsId, IProgressMonitor monitor)
+                                               throws CoreException {
+               monitor.beginTask(CUIPlugin.getResourceString(KEY_CONVERTING), 
+                   selected.length);
+               try {
+                       for (Object element : selected) {
+                       IProject project = (IProject)element;
+                       convertProject(project, bsId, new SubProgressMonitor(monitor, 1));
+                       }
+               } finally {
+                       monitor.done();
+               }
+       }
+    /**
+     * Method finish we always finish successfully  :)
+     * 
+     * @return boolean
+     */
+    public boolean finish() {
+
+        return true;
+    }
+
+    /**
+     * Must be overwritten in subclasses to change behaviour Determines which
+     * projects will be displayed in the list
+     * 
+     * @param project
+     * @return boolean
+     */
+    public abstract boolean isCandidate(IProject project);
+
+    /**
+     * convertProject must be overwritten in subclasses to change behaviour
+     * 
+     * @param project
+     * @param monitor
+     * @param projectID
+     * @throws CoreException
+     */
+    public void convertProject(IProject project, 
+                                IProgressMonitor monitor, 
+                                String projectID)
+                                throws CoreException{
+        // Add the correct nature
+       if (convertToC) {
+               if (!project.hasNature(CProjectNature.C_NATURE_ID)){
+                       addCNature(project, monitor, true);             
+               } else {
+                       if (project.hasNature(CCProjectNature.CC_NATURE_ID)){
+                               // remove the C++ nature
+                               CCProjectNature.removeCCNature(project, monitor);
+                       }                       
+               }
+       } else {
+               if (convertToCC && !project.hasNature(CCProjectNature.CC_NATURE_ID)) {
+                       addCCNature(project, monitor, true);            
+               }                               
+       }                               
+    }
+
+    public void convertProject(IProject project,
+               String bsId,
+            IProgressMonitor monitor)
+            throws CoreException{
+               // Add the correct nature
+               if (convertToC) {
+                       if (!project.hasNature(CProjectNature.C_NATURE_ID)){
+                               addCNature(project, monitor, true);             
+                       } else {
+                               if (project.hasNature(CCProjectNature.CC_NATURE_ID)){
+                                               // remove the C++ nature
+                                               CCProjectNature.removeCCNature(project, monitor);
+                               }                       
+                       }
+               } else {
+                       if (convertToCC && !project.hasNature(CCProjectNature.CC_NATURE_ID)) {
+                               addCCNature(project, monitor, true);            
+                       }                               
+               }                               
+       }
+
+    protected void addCNature(IProject project, IProgressMonitor monitor, boolean addMakeBuilder) throws CoreException{
+               if ( getWizard() instanceof ConversionWizard) {
+                       ConversionWizard cw = (ConversionWizard)getWizard();
+                       if(cw.getBuildSystemId() != null)
+                               CCorePlugin.getDefault().convertProjectToNewC(project, cw.getBuildSystemId(), monitor);
+                       else
+                               CCorePlugin.getDefault().convertProjectToC(project, monitor, cw.getProjectID());
+               }
+     }
+     
+     protected void addCCNature(IProject project, IProgressMonitor monitor, boolean addMakeBuilder) throws CoreException{
+               if ( getWizard() instanceof ConversionWizard) {
+               if (project.hasNature(CProjectNature.C_NATURE_ID)) {                    
+                       CCorePlugin.getDefault().convertProjectFromCtoCC(project, monitor);
+               } else {
+                       ConversionWizard cw = (ConversionWizard)getWizard();
+                       if(cw.getBuildSystemId() != null)
+                       CCorePlugin.getDefault().convertProjectToNewCC(project, cw.getBuildSystemId(), monitor);
+                       else
+                               CCorePlugin.getDefault().convertProjectToCC(project, monitor, cw.getProjectID());
+               }
+               }
+     }
+    
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/utils/ui/controls/ControlFactory.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/utils/ui/controls/ControlFactory.java
new file mode 100644 (file)
index 0000000..7c6771c
--- /dev/null
@@ -0,0 +1,705 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *******************************************************************************/
+package org.eclipse.cdt.utils.ui.controls;
+
+import java.util.StringTokenizer;
+
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ */
+public class ControlFactory {
+
+       public static Control setParentColors(Control control) {
+               Composite parent = control.getParent();
+           control.setBackground(parent.getBackground());
+           control.setForeground(parent.getForeground());
+           return control;
+       }
+               
+       /**
+        * Creates composite control and sets the default layout data.
+        *
+        * @param parent  the parent of the new composite
+        * @param numColumns  the number of columns for the new composite
+        * @return the newly-created composite
+        */
+       public static Composite createComposite(Composite parent, int numColumns) {
+               return createCompositeEx(parent, numColumns, GridData.FILL_HORIZONTAL);
+       }
+
+       /**
+        * Creates composite control and sets the specified layout data.
+        *
+        * @param parent  the parent of the new composite
+        * @param numColumns  the number of columns for the new composite
+        * @param layoutMode - GridData modes that should be applied to this control
+        * @return the newly-created composite
+        */
+       public static Composite createCompositeEx(Composite parent, int numColumns, int layoutMode) {
+               Composite composite = new Composite(parent, SWT.NULL);
+               composite.setFont(parent.getFont());
+       
+               composite.setLayout(new GridLayout(numColumns, true));
+               composite.setLayoutData(new GridData(layoutMode));
+               return composite;
+       }
+
+       /**
+        * Creates thick separator.
+        *
+        * @param parent  the parent of the new composite
+        * @param color the separator color
+        * @return preferedThickness - the  preferred thickness of separator (or 2 if SWT.DEFAULT)
+        */
+       public static Composite createCompositeSeparator(Composite parent, Color color, int preferedHeight) {
+               Composite separator = createComposite(parent, 1);
+               GridData gd = (GridData) separator.getLayoutData();
+               gd.heightHint = ((SWT.DEFAULT == preferedHeight) ? 2 : preferedHeight);
+               separator.setLayoutData(gd);
+               separator.setBackground(color);
+               return separator;
+       }
+
+    /**
+     * Creates a composite with a highlighted Note entry and a message text.
+     * This is designed to take up the full width of the page.
+     * 
+     * @param font the font to use
+     * @param composite the parent composite
+     * @param title the title of the note
+     * @param message the message for the note
+     * @return the composite for the note
+     */
+    public static Composite createNoteComposite(Font font, Composite composite,
+            String title, String message) {
+        Composite messageComposite = new Composite(composite, SWT.NONE);
+        GridLayout messageLayout = new GridLayout();
+        messageLayout.numColumns = 2;
+        messageLayout.marginWidth = 0;
+        messageLayout.marginHeight = 0;
+        messageComposite.setLayout(messageLayout);
+        messageComposite.setLayoutData(new GridData(
+                GridData.HORIZONTAL_ALIGN_FILL));
+        messageComposite.setFont(font);
+
+        final Label noteLabel = new Label(messageComposite, SWT.BOLD);
+        noteLabel.setText(title);
+        noteLabel.setFont(JFaceResources.getFontRegistry().getBold(
+                               JFaceResources.DEFAULT_FONT));  
+        noteLabel
+                .setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+
+        final IPropertyChangeListener fontListener = new IPropertyChangeListener() {
+            public void propertyChange(PropertyChangeEvent event) {
+                if (JFaceResources.BANNER_FONT.equals(event.getProperty())) {
+                    noteLabel.setFont(JFaceResources
+                            .getFont(JFaceResources.BANNER_FONT));
+                }
+            }
+        };
+        JFaceResources.getFontRegistry().addListener(fontListener);
+        noteLabel.addDisposeListener(new DisposeListener() {
+            public void widgetDisposed(DisposeEvent event) {
+                JFaceResources.getFontRegistry().removeListener(fontListener);
+            }
+        });
+
+        Label messageLabel = new Label(messageComposite, SWT.WRAP);
+        messageLabel.setText(message);
+        messageLabel.setFont(font);
+        return messageComposite;
+    }
+
+       /**
+        * Creates a separator.
+        *
+        * @param parent  the parent of the new composite
+        * @param nCols number of columns to span
+        * @return a separator label
+        */
+       public static Label createSeparator(Composite parent, int nCols) {
+               Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
+               GridData data = new GridData(GridData.FILL_HORIZONTAL);
+               data.horizontalSpan = nCols;
+               separator.setLayoutData(data);
+               return separator;
+       }
+
+       /**
+        * Creates a spacer control.
+        * @param parent The parent composite
+        */             
+       public static Control createEmptySpace(Composite parent) {
+               return createEmptySpace(parent, 1);
+       }
+
+       /**
+        * Creates a spacer control with the given span.
+        * The composite is assumed to have <code>MGridLayout</code> as
+        * layout.
+        * @param parent The parent composite
+        */                     
+       public static Control createEmptySpace(Composite parent, int span) {
+               Label label= new Label(parent, SWT.LEFT);
+               GridData gd= new GridData();
+               gd.horizontalAlignment= GridData.BEGINNING;
+               gd.grabExcessHorizontalSpace= false;
+               gd.horizontalSpan= span;
+               gd.horizontalIndent= 0;
+               gd.widthHint= 0;
+               gd.heightHint= 0;
+               label.setLayoutData(gd);
+               return label;
+       }
+
+       /**
+        * Creates an new label (basic method)
+        *
+        * @param parent  parent object
+        * @param text  the label text
+        * @param widthHint - recommended widget width
+        * @param heightHint - recommended widget height
+        * @param style - control style
+        * @return the new label
+        */ 
+       public static Label createLabel(Composite parent, String text, int widthHint, int heightHint,
+                       int style) {
+               Label label = new Label(parent, style);         
+               label.setFont(parent.getFont());
+               label.setText(text);
+               GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+               gd.horizontalSpan = 1;
+               gd.widthHint = widthHint;
+               gd.heightHint = heightHint;
+               label.setLayoutData(gd);
+               return label;
+       }
+
+       /**
+        * Utility method that creates a label instance
+        * and sets the default layout data.
+        *
+        * @param parent  the parent for the new label
+        * @param text  the text for the new label
+        * @return the new label
+        */
+       public static Label createLabel(Composite parent, String text) {
+               return createLabel(parent, text, SWT.DEFAULT, SWT.DEFAULT, SWT.LEFT);
+       }
+
+    /**
+        * Utility method that creates a label instance
+        * and sets the default layout data and sets the 
+     * font attributes to be SWT.BOLD.
+        *
+        * @param parent  the parent for the new label
+        * @param text  the text for the new label
+        * @return the new label
+        */
+       public static Label createBoldLabel(Composite parent, String text) {
+               Label label = createLabel(parent, text);
+        FontData[] fd = label.getFont().getFontData();
+        fd[0].setStyle(SWT.BOLD);
+        Font font = new Font(Display.getCurrent(), fd[0]);
+        label.setFont(font);
+               return label;
+       }
+
+       /**
+        * Creates an new Wrapped label 
+        * 
+        *
+        * @param parent  parent object
+        * @param text  the label text
+        * @param widthHint - recommended widget width
+        * @param heightHint - recommended widget height
+        * @return the new label
+        */ 
+       public static Label createWrappedLabel(Composite parent, String text, int widthHint, int heightHint) {
+               return createLabel(parent, text, widthHint, heightHint, SWT.LEFT | SWT.WRAP);
+       }
+
+       /**
+        * Creates an new checkbox instance and sets the default
+        * layout data.
+        *
+        * @param group  the composite in which to create the checkbox
+        * @param label  the string to set into the checkbox
+        * @return the new checkbox
+        */ 
+       public static Button createCheckBox(Composite group, String label) {
+               Button button = new Button(group, SWT.CHECK | SWT.LEFT);
+               button.setFont(group.getFont());
+               button.setText(label);
+               GridData data = new GridData();
+               button.setLayoutData(data);
+           button.setBackground(group.getBackground());
+           button.setForeground(group.getForeground());
+               return button;
+       }
+
+       /**
+        * Creates an new checkbox instance and sets the default
+        * layout data.
+        *
+        * @param group  the composite in which to create the checkbox
+        * @param label  the string to set into the checkbox
+        * @return the new checkbox
+        */ 
+       public static Button createCheckBoxEx(Composite group, String label, int style) {
+               Button button = new Button(group, SWT.CHECK | style);
+               button.setFont(group.getFont());
+               button.setText(label);
+               GridData data = new GridData();
+               button.setLayoutData(data);
+           button.setBackground(group.getBackground());
+           button.setForeground(group.getForeground());
+               return button;
+       }
+
+       /**
+        * Creates an new radiobutton instance and sets the default
+        * layout data.
+        *
+        * @param group  the composite in which to create the radiobutton
+        * @param label  the string to set into the radiobutton
+        * @param value  the string to identify radiobutton
+        * @return the new checkbox
+        */ 
+       public static Button createRadioButton(Composite group, String label, String value,
+                       SelectionListener listener) {
+               Button button = new Button(group, SWT.RADIO | SWT.LEFT);
+               button.setFont(group.getFont());
+               button.setText(label);
+               button.setData((null == value) ? label : value);
+               GridData data = new GridData(GridData.FILL_HORIZONTAL);
+               data.horizontalAlignment = GridData.FILL;
+               data.verticalAlignment = GridData.BEGINNING;
+               button.setLayoutData(data);
+               if (null != listener)
+                       button.addSelectionListener(listener);
+               return button;
+       }
+       
+       /**
+        * Utility method that creates a push button instance
+        * and sets the default layout data.
+        *
+        * @param parent  the parent for the new button
+        * @param label  the label for the new button
+        * @return the newly-created button
+        */
+       public static Button createPushButton(Composite parent, String label) {
+               Button button = new Button(parent, SWT.PUSH);
+               button.setFont(parent.getFont());
+               button.setText(label);
+//             button.addSelectionListener(this);
+               GridData data = new GridData();
+               data.horizontalAlignment = GridData.FILL;
+               button.setLayoutData(data);
+               return button;
+       }
+       
+       /**
+        * Create a text field specific for this application
+        *
+        * @param parent  the parent of the new text field
+        * @return the new text field
+        */
+       public static Text createTextField(Composite parent) {
+               return createTextField(parent, SWT.SINGLE | SWT.BORDER);
+       }
+               
+       public static Text createTextField(Composite parent, int style) {
+               Text text = new Text(parent, style);
+               GridData data = new GridData();
+               data.horizontalAlignment = GridData.FILL;
+               data.grabExcessHorizontalSpace = true;
+               data.verticalAlignment = GridData.CENTER;
+               data.grabExcessVerticalSpace = false;
+               text.setLayoutData(data);
+               
+               return text;
+       }
+       
+       /**
+        * Create a group box
+        *
+        * @param parent  the parent of the new control
+        * @param label  the group box label
+        * @param nColumns - number of layout columns
+        * @return the new group box
+        */
+    public static Group createGroup(Composite parent, String label, int nColumns) {
+               Group group = new Group(parent, SWT.NONE);
+               group.setFont(parent.getFont());
+               group.setText(label);
+               GridLayout layout = new GridLayout();
+               layout.numColumns = nColumns;
+               group.setLayout(layout);
+               group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               
+        return group;          
+    }
+
+       /**
+        * Create a List box
+        *
+        * @param parent  the parent of the new control
+        * @param strdata  the data for the list, separated by commas
+        * @param selData - the item that shall be selected
+        * @return the new list box
+        */
+    public static List createList(Composite parent, String strdata, String selData) {
+               List list = new List(parent, SWT.SINGLE);
+               list.setFont(parent.getFont());
+               GridData data = new GridData();
+               list.setLayoutData(data);
+               StringTokenizer st = new StringTokenizer(strdata, ","); //$NON-NLS-1$
+               while (st.hasMoreTokens())
+                       list.add(st.nextToken());
+           if (selData == null) {
+               if (list.getItemCount() > 0)
+                               list.select(0);
+           } else {
+                       selectList(list, selData);
+           }
+               return list;
+       }
+
+       public static void selectList(List list, String selData)        {
+               int n_sel = list.indexOf(selData);
+               if (0 > n_sel)
+                       n_sel = 0;
+           list.select(n_sel);
+       }
+       
+       /**
+        *      Create this group's list viewer.
+        */
+       public static TableViewer createTableViewer(Composite parent, String[] opt_list, 
+           int width, int height, int style) {
+               TableViewer listViewer = new TableViewer(parent, SWT.BORDER | style);
+               GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
+               data.widthHint = width;
+               data.heightHint = height;
+               listViewer.getTable().setLayoutData(data);
+               if (null != opt_list)
+                       listViewer.add(opt_list);
+        return listViewer; 
+       }
+
+       /**
+        *      Create this group's list viewer.
+        */
+       public static TableViewer createTableViewer(Composite parent,  
+           int width, int height, int style, String[] columns, int[] colWidths) {
+               TableViewer listViewer = createTableViewer(parent, null, width, height, style);
+
+               Table table= listViewer.getTable();
+               
+               table.setHeaderVisible(true);
+               table.setLinesVisible(true);
+               
+               TableLayout tableLayout= new TableLayout();
+/*
+               TableColumn column= table.getColumn(0);
+               column.setText(columns[0]);         
+               tableLayout.addColumnData(new ColumnWeightData(colWidths[0], false));
+*/             
+               TableColumn column;
+               for (int i = 0; i < columns.length; ++i) {
+                       column= new TableColumn(table, SWT.NULL);
+                       column.setText(columns[i]);     
+                       tableLayout.addColumnData(new ColumnWeightData(colWidths[i], true));
+               }
+
+               table.setLayout(tableLayout);
+               
+        return listViewer; 
+       }
+
+       public static void deactivateCellEditor(TableViewer viewer) {
+               if (null == viewer)
+                       return;
+               CellEditor[] es = viewer.getCellEditors();
+               TableItem[] items = viewer.getTable().getSelection();
+               if (items.length >= 0)  {
+                       for (int i = 0; i < es.length; ++i) {
+                               CellEditor e = es[i];
+                               if (e.isActivated()) {
+                                       if (e.isValueValid()) {
+                                               Object[] properties = viewer.getColumnProperties();
+                                               Object value = e.getValue();
+                                               viewer.cancelEditing();
+                                               viewer.getCellModifier().modify(items[0],(String)properties[i], value);
+                                       } else
+                                               viewer.cancelEditing();
+                                       break;
+                               }
+                       }
+               }
+       }
+
+       /**
+        *      Create this group's list viewer.
+        */
+       public static CheckboxTableViewer createListViewer(Composite parent, String[] opt_list, 
+           int width, int height, int style) {
+               
+           Table table = new Table(parent, SWT.BORDER | SWT.CHECK);
+               table.setFont(parent.getFont());
+           CheckboxTableViewer listViewer = new CheckboxTableViewer(table);
+               GridData data = new GridData(style);
+               data.widthHint = width;
+               data.heightHint = height;
+               listViewer.getTable().setLayoutData(data);
+               if (null != opt_list)
+                       listViewer.add(opt_list);
+//             listViewer.setLabelProvider(listLabelProvider);
+//             listViewer.addCheckStateListener(this);
+        return listViewer; 
+       }
+
+       public static CheckboxTableViewer createListViewer(Composite parent,  
+           int width, int height, int style, String[] columns, int[] colWidths) {
+           CheckboxTableViewer listViewer = createListViewer(parent, null, 
+               width, height, style);
+               
+               Table table= listViewer.getTable();
+               table.setFont(parent.getFont());
+               
+               table.setHeaderVisible(true);
+               table.setLinesVisible(true);
+               
+               TableLayout tableLayout= new TableLayout();
+               table.setLayout(tableLayout);
+
+               TableColumn column= table.getColumn(0);
+               column.setText(columns[0]);         
+               tableLayout.addColumnData(new ColumnWeightData(colWidths[0], false));
+               
+               for (int i = 1; i < columns.length; ++i) {
+                       column= new TableColumn(table, SWT.NULL);
+                       column.setText(columns[i]);     
+                       tableLayout.addColumnData(new ColumnWeightData(colWidths[i], false));
+                       
+               }
+           
+        return listViewer; 
+       }
+  
+       /**
+        * Create a selection combo
+        *
+        * @param parent  the parent of the new text field
+        * @param strdata of comma separated tokens to fill selection list
+        * @param selData the item that shall be selected
+        * @return the new combo
+        */
+       public static CCombo createSelectCCombo(Composite parent, String strdata, String selData) {
+               return createSelectCCombo(parent, strdata, selData, 
+                       SWT.READ_ONLY | SWT.BORDER);
+       }
+               
+       public static CCombo createSelectCCombo(Composite parent, String strdata, String selData, int style) {
+               CCombo combo = new CCombo(parent, style);
+               combo.setFont(parent.getFont());
+               GridData data = new GridData(GridData.FILL_HORIZONTAL);
+               combo.setLayoutData(data);
+               StringTokenizer st = new StringTokenizer(strdata, ","); //$NON-NLS-1$
+               while (st.hasMoreTokens())
+                       combo.add(st.nextToken());
+           if (selData == null || selData.length() == 0) {
+               if (combo.getItemCount() > 0)
+                               combo.select(0);
+           } else {
+                       selectCCombo(combo, selData);
+           }
+               return combo;
+       }
+
+       /**
+        * Create a selection combo
+        *
+        * @param parent  the parent of the new text field
+        * @param strdata array of elements 
+        * @param selData selected element
+        * @return the new combo
+        */
+       public static CCombo createSelectCCombo(Composite parent, String[] strdata, String selData) {
+               return createSelectCCombo(parent, strdata, selData, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
+       }
+       
+       public static CCombo createSelectCCombo(Composite parent, String[] strdata, String selData,
+                       int style) {
+               CCombo combo = new CCombo(parent, style);
+               combo.setFont(parent.getFont());
+               GridData data = new GridData(GridData.FILL_HORIZONTAL);
+               combo.setLayoutData(data);
+               for (int i = 0; i < strdata.length; ++i) {
+                       combo.add(strdata[i]);
+               }
+           if (selData == null)
+                       combo.select(0);
+           else
+                       selectCCombo(combo, selData);       
+               return combo;
+       }
+
+       public static void selectCCombo(CCombo combo, String selData)   {
+               int n_sel = combo.indexOf(selData);
+               if (0 > n_sel)
+                       n_sel = 0;
+           combo.select(n_sel);
+       } 
+
+       /**
+        * Create a selection combo
+        *
+        * @param parent  the parent of the new text field
+        * @param strdata of comma separated tokens to fill selection list
+        * @param selData the item that shall be selected
+        * @return the new combo
+        */
+       public static Combo createSelectCombo(Composite parent, String strdata, String selData) {
+               return createSelectCombo(parent, strdata, selData, 
+                       SWT.READ_ONLY | SWT.BORDER);
+       }
+               
+       public static Combo createSelectCombo(Composite parent, String strdata, String selData, int style) {
+               Combo combo = new Combo(parent, style);
+               combo.setFont(parent.getFont());
+               GridData data = new GridData(GridData.FILL_HORIZONTAL);
+               combo.setLayoutData(data);
+               StringTokenizer st = new StringTokenizer(strdata, ","); //$NON-NLS-1$
+               while (st.hasMoreTokens())
+                       combo.add(st.nextToken());
+           if (selData == null || selData.length() == 0) {
+               if (combo.getItemCount() > 0)
+                               combo.select(0);
+           } else {
+                       selectCombo(combo, selData);
+           }
+               return combo;
+       }
+
+       /**
+        * Create a selection combo
+        *
+        * @param parent  the parent of the new text field
+        * @param strdata array of elements 
+        * @param selData selected element
+        * @return the new combo
+        */
+       public static Combo createSelectCombo(Composite parent, String[] strdata, String selData) {
+               return createSelectCombo(parent, strdata, selData, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER);
+       }
+       
+       public static Combo createSelectCombo(Composite parent, String[] strdata, String selData, int style) {
+               Combo combo = new Combo(parent, style);
+               combo.setFont(parent.getFont());
+               GridData data = new GridData(GridData.FILL_HORIZONTAL);
+               combo.setLayoutData(data);
+               for (int i = 0; i < strdata.length; ++i) {
+                       combo.add(strdata[i]);
+               }
+           if (selData == null)
+                       combo.select(0);
+           else
+                       selectCombo(combo, selData);        
+               return combo;
+       }
+
+       public static void selectCombo(Combo combo, String selData)     {
+               int n_sel = combo.indexOf(selData);
+               if (0 > n_sel) {
+                       if ((combo.getStyle() & SWT.READ_ONLY) == 0) {
+                               combo.setText(selData);
+                               return;
+                       }
+                       n_sel = 0;
+               }
+           combo.select(n_sel);
+       } 
+
+    /**
+        * Create a dialog shell, child to the top level workbench shell.
+        *
+        * @return The new Shell usable for a dialog.
+        */
+    public static Shell createDialogShell() {
+        Shell parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+        return new Shell(parent, SWT.DIALOG_TRIM);
+    }
+
+       public static Composite insertSpace(Composite parent, int nSpan, int height) {
+               Composite space = ControlFactory.createCompositeSeparator(parent, parent.getBackground(),
+                        (SWT.DEFAULT != height ? height : 5));
+               ((GridData) space.getLayoutData()).horizontalSpan = nSpan;
+               return space;
+       }
+
+    public static MessageBox createDialog(String title, String message, int style) {
+        MessageBox box = new MessageBox(createDialogShell(), style | SWT.APPLICATION_MODAL);
+        box.setText(title);
+        box.setMessage(message);
+        return box;
+    }
+
+    public static MessageBox createYesNoDialog(String title, String message) {
+        return createDialog(title, message, SWT.YES | SWT.NO | SWT.ICON_QUESTION);
+    }
+
+    public static MessageBox createOkDialog(String title, String message) {
+        return createDialog(title, message, SWT.OK | SWT.ICON_INFORMATION);
+    }
+
+    public static MessageBox createOkCancelDialog(String title, String message) {
+        return createDialog(title, message, SWT.OK | SWT.CANCEL | SWT.ICON_INFORMATION);
+    }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/utils/ui/controls/FileListControl.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/utils/ui/controls/FileListControl.java
new file mode 100644 (file)
index 0000000..7e8eeb4
--- /dev/null
@@ -0,0 +1,1086 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2010 BitMethods Inc and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     BitMethods Inc - initial API and implementation
+ *     Sascha Radike <sradike@ejectlag.com> - Support for workspace browsing and small improvements
+ *     James Blackburn (Broadcom Corp.)
+ *******************************************************************************/
+package org.eclipse.cdt.utils.ui.controls;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.operations.AbstractOperation;
+import org.eclipse.core.commands.operations.IOperationHistory;
+import org.eclipse.core.commands.operations.IUndoContext;
+import org.eclipse.core.commands.operations.IUndoableOperation;
+import org.eclipse.core.commands.operations.ObjectUndoContext;
+import org.eclipse.core.commands.operations.OperationHistoryFactory;
+import org.eclipse.core.filesystem.URIUtil;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+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.core.runtime.Status;
+import org.eclipse.core.variables.IStringVariableManager;
+import org.eclipse.core.variables.VariablesPlugin;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+import org.eclipse.swt.widgets.Widget;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
+import org.eclipse.ui.dialogs.ISelectionStatusValidator;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.eclipse.ui.swt.IFocusService;
+import org.eclipse.ui.views.navigator.ResourceComparator;
+
+import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
+import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
+import org.eclipse.cdt.ui.CDTSharedImages;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.newui.CDTStatusInfo;
+import org.eclipse.cdt.ui.newui.TypedCDTViewerFilter;
+import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver;
+import org.eclipse.cdt.utils.cdtvariables.IVariableContextInfo;
+import org.eclipse.cdt.utils.cdtvariables.IVariableSubstitutor;
+import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableManager;
+import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableSubstitutor;
+
+import org.eclipse.cdt.internal.core.resources.ResourceLookup;
+
+import org.eclipse.cdt.internal.ui.newui.Messages;
+
+/**
+ * Instances of this class allow the user to add, remove, delete, moveup and movedown
+ * the items in the list control.
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class FileListControl {
+
+       /**
+        * Constant copied from ManagedBuild IOption indicating that the entries in this
+        * FileListControl are neither files nor directories -- they're treated as a plain
+        * String list.
+        * 
+        * #see org.eclipse.cdt.managedbuilder.core.IOption#BROWSE_NONE
+        * @since 5.2
+        */
+       public static final int BROWSE_NONE = 0;
+       /**
+        * Constant copied from ManagedBuild IOption indicating that the entries in this
+        * FileListControl are Files.
+        * 
+        * #see org.eclipse.cdt.managedbuilder.core.IOption#BROWSE_FILE
+        * @since 5.2
+        */
+       public static final int BROWSE_FILE = 1;
+       /**
+        * Constant copied from ManagedBuild IOption indicating that the entries in this
+        * FileListControl are Directories.
+        * 
+        * #see org.eclipse.cdt.managedbuilder.core.IOption#BROWSE_DIR
+        * @since 5.2
+        */
+       public static final int BROWSE_DIR = 2;
+
+       /**
+        * Multi-purpose dialog to prompt the user for a value, path, or file.
+        *
+        * @since 2.0
+        */
+       class SelectPathInputDialog extends InputDialog {
+
+               private String[] values = new String[0];
+
+               private int type;
+               /* True if user successfully set the text value by a browse dialog */
+               private boolean fSetByBrowseDialog = false;
+
+               /**
+                * @param parentShell
+                * @param dialogTitle
+                * @param dialogMessage
+                * @param initialValue
+                * @param validator
+                * @param browseType
+                */
+               public SelectPathInputDialog(Shell parentShell, String dialogTitle, String dialogMessage, String initialValue, IInputValidator validator, int browseType) {
+                       super(parentShell, dialogTitle, dialogMessage, initialValue, validator);
+                       this.type = browseType;
+               }
+
+               /**
+                * Returns true if the value has been set by a browse dialog.
+                */
+               public boolean isValueSetByBrowse() {
+                       return fSetByBrowseDialog;
+               }
+
+               /**
+                * Allow this dialog to return multiple entires
+                * @return String[] represeting the collected values
+                */
+               public String[] getValues() {
+                       // If values only has one entry or fewer, then return getValue() to catch more recent changes to edit field
+                       if (values.length <= 1)
+                               return new String[] { getValue() };
+                       return values;
+               }
+
+               /* (non-Javadoc)
+                * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+                */
+               @Override
+               protected void createButtonsForButtonBar(Composite parent) {
+                       super.createButtonsForButtonBar(parent);
+
+                       if (((type == BROWSE_DIR) || (type == BROWSE_FILE)
+                                       ) && (fWorkspaceSupport)) {
+
+                               /* Browse button for workspace folders/files */
+                               final Button workspaceButton = createButton(parent, 3, WORKSPACEBUTTON_NAME, false);
+                               workspaceButton.addSelectionListener(new SelectionAdapter() {
+                                       @Override
+                                       public void widgetSelected(SelectionEvent ev) {
+                                               /* Before opening the browse dialog we try to convert the current
+                                                * path text to a valid workspace resource, so we can set it
+                                                * as initial selection in the dialog.
+                                                *
+                                                * First we remove all double-quotes. Then the build macro provider
+                                                * will resolve all macros/variables (like workspace_loc, ...).
+                                                *
+                                                * If the workspace location path is a prefix of our resolved path,
+                                                * we will remove that part and finally get a full path relative to the
+                                                * workspace. We can use that path to set the initially selected resource.
+                                                */
+
+                                               String currentPathText = getText().getText();
+
+                                               /* Remove double quotes */
+                                               currentPathText = currentPathText.replaceAll("\"", ""); //$NON-NLS-1$ //$NON-NLS-2$
+
+                                               /* Resolve variables */
+                                               IStringVariableManager variableManager = VariablesPlugin.getDefault().getStringVariableManager();
+
+                                               /* See if we can discover the project from the context *
+                                                * and check whether the path must be resolved... */
+                                               IProject project = null;
+                                               IResource resource = null;
+                                               if(contextInfo != null) {
+                                                       try {
+                                                               // Try to find the project
+                                                               ICdtVariable var = SupplierBasedCdtVariableManager.getVariable(PROJECTNAME_VAR, contextInfo, true);
+                                                               if (var != null && var.getValueType() == ICdtVariable.VALUE_TEXT)
+                                                                       project = ResourcesPlugin.getWorkspace().getRoot().getProject(var.getStringValue());
+
+                                                               // Try to resolve the currentPathText
+                                                               IVariableSubstitutor varSubs = new SupplierBasedCdtVariableSubstitutor(contextInfo, "", "");  //$NON-NLS-1$//$NON-NLS-2$
+                                                               String value = CdtVariableResolver.resolveToString(currentPathText, varSubs);
+                                                               if (!"".equals(value)) { //$NON-NLS-1$
+                                                                       IResource rs[] = ResourcesPlugin.getWorkspace().getRoot().findContainersForLocationURI(URIUtil.toURI(value));
+                                                                       if (rs == null || rs.length == 0)
+                                                                               resource = ResourceLookup.selectFileForLocation(new Path(value), null);
+                                                                       else
+                                                                               resource = rs[0];
+                                                               }
+                                                       } catch (CdtVariableException e) {
+                                                               // It's OK not to find the project... carry on as before
+                                                       }
+                                               }
+
+                                               /* Create workspace folder/file selection dialog and
+                                                * set initial selection */
+                                               ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(),
+                                                               new WorkbenchLabelProvider(), new WorkbenchContentProvider());
+
+                               dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
+                               dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
+
+                                               if (type == BROWSE_DIR) {
+                                                       dialog.setInitialSelection(resource);
+                                                       Class<?>[] filteredResources = {IContainer.class, IProject.class};
+                                                       dialog.addFilter(new TypedCDTViewerFilter(filteredResources));
+                                                       dialog.setTitle(WORKSPACE_DIR_DIALOG_TITLE);
+                                       dialog.setMessage(WORKSPACE_DIR_DIALOG_MSG);
+                                               } else {
+                                                       dialog.setInitialSelection(resource);
+                                                       dialog.setValidator(new ISelectionStatusValidator() {
+                                                           public IStatus validate(Object[] selection) {
+                                                               if (selection != null)
+                                                                       for (Object sel : selection)
+                                                                               if (!(sel instanceof IFile))
+                                                                                       return new CDTStatusInfo(IStatus.ERROR, WORKSPACE_FILE_DIALOG_ERR);
+                                                               return new CDTStatusInfo();
+                                                           }
+                                                       });
+                                                       dialog.setTitle(WORKSPACE_FILE_DIALOG_TITLE);
+                                       dialog.setMessage(WORKSPACE_FILE_DIALOG_MSG);
+                                               }
+
+                                               /* Open dialog and process result. 
+                                                * If a resource has been selected we create a workspace relative path for it.
+                                                * Use ${ProjName} if the full path is relative to the context's location */
+                                               if (dialog.open() == Window.OK) {
+                                                       fSetByBrowseDialog = true;
+
+                                                       Object[] rs = dialog.getResult();
+
+                                                       if (rs != null) {
+                                                               int i = 0;
+                                                               values = new String[rs.length];
+                                                               for (Object o : rs) {
+                                                                       resource = (IResource) o;
+                                                                       if (resource.getProject().equals(project))
+                                                                               values[i++] = variableManager.generateVariableExpression(WORKSPACELOC_VAR,
+                                                                                               PROJECTNAME_PATH.append(resource.getProjectRelativePath()).makeAbsolute().toString());
+                                                                       else
+                                                                               values[i++] = variableManager.generateVariableExpression(WORKSPACELOC_VAR,
+                                                                                               resource.getFullPath().toString());
+                                                               }
+                                                               // If only one entry, update the text field
+                                                               if (values.length == 1)
+                                                                       getText().setText(values[0]);
+                                                               else
+                                                                       // More then one item selected and OK pressed. Exit this edit dialog
+                                                                       buttonPressed(IDialogConstants.OK_ID);
+                                                       }
+                                               }
+                                       }
+                               });
+                       }
+
+                       if (type != BROWSE_NONE) {
+                               /* Browse button for external directories/files */
+                               final Button externalButton = createButton(parent, 4, FILESYSTEMBUTTON_NAME, false);
+                               externalButton.addSelectionListener(new SelectionAdapter() {
+                                       @Override
+                                       public void widgetSelected(SelectionEvent ev) {
+                                               String currentName;
+                                               String result;
+                                               switch (type) {
+                                                       case BROWSE_DIR :
+                                                               DirectoryDialog dialog = new DirectoryDialog(getParentShell(),
+                                                                               SWT.OPEN|SWT.APPLICATION_MODAL);
+                                                               currentName = getText().getText();
+                                                               if(currentName != null && currentName.trim().length() != 0) {
+                                                                       dialog.setFilterPath(currentName);
+                                                               } else if(FileListControl.this.filterPath != null) {
+                                                                       dialog.setFilterPath(FileListControl.this.filterPath);
+                                                               }
+                                                               dialog.setMessage(FILESYSTEM_DIR_DIALOG_MSG);
+                                                               result = dialog.open();
+                                                               if(result != null) {
+                                                                       fSetByBrowseDialog = true;
+                                                                       getText().setText(result);
+                                                               }
+                                                               break;
+                                                       case BROWSE_FILE:
+                                                               FileDialog browseDialog = new FileDialog(getParentShell());
+                                                               currentName = getText().getText();
+                                                               if (currentName != null && currentName.trim().length() != 0) {
+                                                                       browseDialog.setFilterPath(currentName);
+                                                               } else if (FileListControl.this.filterPath != null) {
+                                                                       browseDialog.setFilterPath(FileListControl.this.filterPath);
+                                                               }
+                                                               if (FileListControl.this.filterExtensions != null) {
+                                                                       browseDialog.setFilterExtensions(FileListControl.this.filterExtensions);
+                                                               }
+                                                               result = browseDialog.open();
+                                                               if (result != null) {
+                                                                       fSetByBrowseDialog = true;
+                                                                       getText().setText(result);
+                                                               }
+                                                               break;
+                                               }
+                                       }
+                               });
+                       }
+               }
+
+       }
+
+       /**
+        * An extended List control with support for cut / copy / paste & undo
+        * Needs to be public for the copy method to be called by the platform via reflection
+        * @since 5.2
+        * @noinstantiate This class is not intended to be instantiated by clients.
+        */
+       public final class ClipboardList extends List {
+               private Clipboard clipboard;
+
+               public ClipboardList(Composite parent, int style) {
+                       super (parent, style);
+               }
+               private String[] getClipboardContents() {
+                       Clipboard cp = getClipboard();
+                       String contents = (String)cp.getContents(TextTransfer.getInstance());
+                       if (contents != null) {
+                               String[] arr = contents.split("\n"); //$NON-NLS-1$
+                               return arr;
+                       }
+                       return new String[0];
+               }
+               public void copy() {
+                       String[] toCopy = getSelection();
+                       if (toCopy != null && toCopy.length > 0) {
+                               StringBuilder sb = new StringBuilder();
+                               for (String item : toCopy)
+                                       sb.append(item.trim()).append("\n"); //$NON-NLS-1$
+                               Clipboard cp = getClipboard();
+                               cp.setContents(new Object[]{sb.toString().trim()}, new Transfer[] {TextTransfer.getInstance()});
+                       }
+               }
+               public void cut() {
+                       copy();
+                       // Only remove from the list box if the cut was successful
+                       if (Arrays.equals(getClipboardContents(), getSelection()))
+                               removePressed();
+               }
+               public void paste() {
+                       String[] pasteBuffer = getClipboardContents();
+                       int i = getSelectionIndex();
+                       // insert items at the correct location
+                       for (String item : pasteBuffer)
+                               if (!item.trim().equals("")) //$NON-NLS-1$
+                                       add(item.trim(), ++i);
+                       checkNotificationNeeded();
+               }
+               public void undo() {
+                       try {
+                               operationHistory.undo(undoContext, null, null);
+                       } catch (ExecutionException e) {
+                               CUIPlugin.log(e);
+                       }
+               }
+               public void redo() {
+                       try {
+                               operationHistory.redo(undoContext, null, null);
+                       } catch (ExecutionException e) {
+                               CUIPlugin.log(e);
+                       }
+               }               
+               private Clipboard getClipboard() {
+                       if (clipboard == null)
+                               clipboard = new Clipboard(Display.getDefault());
+                       return clipboard;
+               }
+               @Override
+               public void dispose() {
+                       super.dispose();
+                       if (clipboard != null)
+                               clipboard.dispose();
+               }
+               /**
+                * Handle backspace / delete key
+                */
+               public void delete() {
+                       removePressed();
+               }
+               @Override
+               protected void checkSubclass() {
+                       // We're adding action handlers, override...
+               }
+       }
+
+
+       /* Variable names */
+       /* See CdtMacroSupplier: used for making absolute paths relative if desired */
+       private static final String WORKSPACELOC_VAR = "workspace_loc"; //$NON-NLS-1$
+       private static final String PROJECTNAME_VAR = "ProjName"; //$NON-NLS-1$
+       private static final IPath PROJECTNAME_PATH = new Path(VariablesPlugin.getDefault().getStringVariableManager().generateVariableExpression(PROJECTNAME_VAR, null));
+
+       /* Names, messages and titles */
+       private static final String WORKSPACEBUTTON_NAME = Messages.FileListControl_button_workspace; 
+       private static final String FILESYSTEMBUTTON_NAME = Messages.FileListControl_button_fs; 
+
+       private static final String ADD_STR = Messages.FileListControl_add; 
+       private static final String DEL_STR = Messages.FileListControl_delete; 
+       private static final String EDIT_STR = Messages.FileListControl_edit; 
+       private static final String MOVEUP_STR = Messages.FileListControl_moveup; 
+       private static final String MOVEDOWN_STR = Messages.FileListControl_movedown; 
+       private static final String FILE_TITLE_ADD = Messages.BrowseEntryDialog_file_title_add; 
+       private static final String DIR_TITLE_ADD = Messages.BrowseEntryDialog_dir_title_add;   
+       private static final String FILE_TITLE_EDIT = Messages.BrowseEntryDialog_file_title_edit;       
+       private static final String DIR_TITLE_EDIT = Messages.BrowseEntryDialog_dir_title_edit; 
+       private static final String WORKSPACE_DIR_DIALOG_TITLE = Messages.BrowseEntryDialog_wsp_dir_dlg_title;  
+       private static final String WORKSPACE_FILE_DIALOG_TITLE = Messages.BrowseEntryDialog_wsp_file_dlg_title;        
+       private static final String WORKSPACE_DIR_DIALOG_MSG = Messages.FileListControl_BrowseEntryDialog_wsp_dir_dlg_msg;      
+       private static final String WORKSPACE_FILE_DIALOG_MSG = Messages.FileListControl_BrowseEntryDialog_wsp_file_dlg_msg;    
+       private static final String WORKSPACE_FILE_DIALOG_ERR = Messages.FileListControl_BrowseEntryDialog_wsp_file_dlg_err;    
+       private static final String FILESYSTEM_DIR_DIALOG_MSG = Messages.BrowseEntryDialog_fs_dir_dlg_msg;      
+       private static final String FILE_MSG = Messages.BrowseEntryDialog_message_file; 
+       private static final String DIR_MSG = Messages.BrowseEntryDialog_message_directory;     
+       private static final String TITLE = Messages.BuildPropertyCommon_label_title;   
+
+       /** flag which prevents us from resetting the prompt for delete flag */
+       private boolean neverPromptForDelete;
+       /** Flag indicating whether the user should be prompted for delete */
+       private boolean promptForDelete;
+
+       //toolbar
+       private ToolBar toolBar;
+       // toolbar items
+       private ToolItem addItem, deleteItem, editItem, moveUpItem, moveDownItem;
+       // title label
+       private Label title;
+       // list control
+       private ClipboardList list;
+       private String compTitle;
+       private SelectionListener selectionListener;
+       private GridData tgdata, grid3, grid4, grid2;
+
+       // The type of browse support that is required
+       private int browseType;
+       private String filterPath;
+       private String[] filterExtensions;
+       /** The base path that should be used when adding new resources */
+       private IPath path = new Path(""); //$NON-NLS-1$
+
+       /* Workspace support */
+       private boolean fWorkspaceSupport = false;
+       private IVariableContextInfo contextInfo;
+       /** Undo support */
+       IUndoContext undoContext;
+       IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory();
+       
+       private java.util.List<IFileListChangeListener> listeners = new ArrayList<IFileListChangeListener>();
+       private String[] oldValue;
+
+       //images
+       private final Image IMG_ADD = CDTSharedImages.getImage(CDTSharedImages.IMG_FILELIST_ADD);
+       private final Image IMG_DEL = CDTSharedImages.getImage(CDTSharedImages.IMG_FILELIST_DEL);
+       private final Image IMG_EDIT = CDTSharedImages.getImage(CDTSharedImages.IMG_FILELIST_EDIT);
+       private final Image IMG_MOVEUP = CDTSharedImages.getImage(CDTSharedImages.IMG_FILELIST_MOVEUP);
+       private final Image IMG_MOVEDOWN = CDTSharedImages.getImage(CDTSharedImages.IMG_FILELIST_MOVEDOWN);
+
+       /**
+        * Constructor
+        *
+        * @param parent
+        * @param compTitle
+        * @param type
+        * @param promptForDelete indicates whether the user should be prompted on delete
+        * @see #FileListControl(Composite, String, int)
+        * @since 5.2
+        */
+       public FileListControl(Composite parent, String compTitle, int type, boolean promptForDelete) {
+               this(parent, compTitle, type);
+               this.promptForDelete = promptForDelete;
+               this.neverPromptForDelete = !promptForDelete;
+       }
+
+       /**
+        * Constructor
+        *
+        * This FileListControl only prompts the user on Delete for BROWSE_FILE and BROWSE_DIR
+        * @param parent
+        * @param compTitle
+        * @param type one of the IOption BROWSE types
+        * @see #BROWSE_NONE
+        * @see #BROWSE_FILE
+        * @see #BROWSE_DIR
+        */
+       public FileListControl(Composite parent, String compTitle, int type) {
+               promptForDelete = type == BROWSE_FILE || type == BROWSE_DIR;
+
+               // Default to no browsing
+               browseType = type;
+
+               //file panel
+               Composite filePanel = new Composite(parent, SWT.NONE);
+               GridLayout form1 = new GridLayout();
+               form1.numColumns = 1;
+               form1.horizontalSpacing = 0;
+               form1.verticalSpacing = 0;
+               form1.marginHeight = 0;
+               form1.marginWidth = 0;
+               filePanel.setLayout(form1);
+               filePanel.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+               // title panel
+               Composite titlePanel = new Composite(filePanel, SWT.BORDER);
+               GridLayout titleform = new GridLayout(2, false);
+               titleform.horizontalSpacing = 0;
+               titleform.verticalSpacing = 0;
+               titleform.marginHeight = 0;
+               titleform.marginWidth = 0;
+               titlePanel.setLayout(titleform);
+               tgdata = new GridData(GridData.FILL_HORIZONTAL);
+               tgdata.heightHint = IDialogConstants.BUTTON_BAR_HEIGHT;
+               titlePanel.setLayoutData(tgdata);
+               title = new Label(titlePanel, SWT.NONE | SWT.BOLD);
+               this.compTitle = "  " + compTitle; //$NON-NLS-1$
+               title.setText(this.compTitle);
+               grid2 = new GridData(GridData.FILL_HORIZONTAL);
+               title.setLayoutData(grid2);
+               //button panel
+               Composite buttonPanel = new Composite(titlePanel, SWT.NONE);
+               GridLayout form2 = new GridLayout();
+               form2.numColumns = 5;
+               form2.horizontalSpacing = 0;
+               form2.verticalSpacing = 0;
+               form2.marginWidth = 0;
+               form2.marginHeight = 0;
+               buttonPanel.setLayout(form2);
+               // toolbar
+               toolBar = new ToolBar(buttonPanel, SWT.HORIZONTAL | SWT.RIGHT
+                               | SWT.FLAT);
+               // add toolbar item
+               addItem = new ToolItem(toolBar, SWT.PUSH);
+               addItem.setImage(IMG_ADD);
+               addItem.setToolTipText(ADD_STR);
+               addItem.addSelectionListener(getSelectionListener());
+               // delete toolbar item
+               deleteItem = new ToolItem(toolBar, SWT.PUSH);
+               deleteItem.setImage(IMG_DEL);
+               deleteItem.setToolTipText(DEL_STR);
+               deleteItem.addSelectionListener(getSelectionListener());
+               // edit toolbar item
+               editItem = new ToolItem(toolBar, SWT.PUSH);
+               editItem.setImage(IMG_EDIT);
+               editItem.setToolTipText(EDIT_STR);
+               editItem.addSelectionListener(getSelectionListener());
+               // moveup toolbar item
+               moveUpItem = new ToolItem(toolBar, SWT.PUSH);
+               moveUpItem.setImage(IMG_MOVEUP);
+               moveUpItem.setToolTipText(MOVEUP_STR);
+               moveUpItem.addSelectionListener(getSelectionListener());
+               // movedown toolbar item
+               moveDownItem = new ToolItem(toolBar, SWT.PUSH);
+               moveDownItem.setImage(IMG_MOVEDOWN);
+               moveDownItem.setToolTipText(MOVEDOWN_STR);
+               moveDownItem.addSelectionListener(getSelectionListener());
+               grid3 = new GridData(GridData.FILL_HORIZONTAL
+                               | GridData.HORIZONTAL_ALIGN_END);
+               buttonPanel.setLayoutData(grid3);
+               // list control
+               list = new ClipboardList(filePanel, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.MULTI);
+               grid4 = new GridData(GridData.FILL_BOTH);
+               // force the list to be no wider than the title bar
+               Point preferredSize = titlePanel.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+               grid4.widthHint = preferredSize.x;
+               grid4.heightHint = preferredSize.y * 3;
+               grid4.horizontalSpan = 2;
+               list.setLayoutData(grid4);
+               list.addSelectionListener(getSelectionListener());
+               //Add a double-click event handler
+               list.addMouseListener(new MouseAdapter() {
+                       @Override
+                       public void mouseDoubleClick(MouseEvent e) {
+                               // Popup the editor on the selected item from the list
+                               editSelection();
+                       }
+               });
+               // Add a delete key listener
+               list.addKeyListener(new KeyAdapter() {
+                       /* (non-Javadoc)
+                        * @see org.eclipse.swt.events.KeyAdapter#keyPressed(org.eclipse.swt.events.KeyEvent)
+                        */
+                       @Override
+                       public void keyPressed(KeyEvent e) {
+                               switch (e.keyCode) {
+                               case SWT.BS:
+                               case SWT.DEL:
+                                       if (e.stateMask == SWT.NONE)
+                                               removePressed();
+                                       break;
+                               }
+                       }
+               });
+
+               // Set-up Undo history
+               undoContext = new ObjectUndoContext(this);
+               operationHistory.setLimit(undoContext, 50);
+
+               // Add command handlers for undo to the control
+               try {
+                       IFocusService fs = (IFocusService)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
+                                                               .getActivePart().getSite().getService(IFocusService.class);
+                       fs.addFocusTracker(list, "org.eclipse.cdt.ui.FileListControl"); //$NON-NLS-1$
+               } catch (Exception e) {
+                       // Any of the get* methods may return null. As this is in the UI constructor for this control
+                       // it shouldn't happen. Log and carry on.
+                       CUIPlugin.log(e);
+               }
+
+               selectionChanged();
+       }
+       
+       /**
+        * Set list values
+        *
+        * @param listVal
+        */
+       public void setList(String[] listVal) {
+               if (list != null) {
+                       list.removeAll();
+               }
+               for (String element : listVal) {
+                       list.add(element);
+               }
+               checkNotificationNeeded();
+       }
+
+       public void addChangeListener(IFileListChangeListener listener){
+               listeners.add(listener);
+       }
+
+       public void removeChangeListener(IFileListChangeListener listener){
+               listeners.remove(listener);
+       }
+
+       /**
+        * Checks whether a notification is needed, and notifies listeners
+        *
+        * Persist any changes in the undo history.
+        *
+        * This method must be called after every change to the contents of the list box
+        *
+        * At end of method oldValue.equals(list.getItems())
+        */
+       public void checkNotificationNeeded(){
+               final String items[] = getItems();
+               if(oldValue != null) {
+                       if (Arrays.equals(oldValue, items))
+                               return;
+       
+                       // Add some context to the undo history
+                       IUndoableOperation op = new AbstractOperation("") { //$NON-NLS-1$
+                               final String[] previousValue = oldValue;
+                               final String[] newValue = items;
+                               @Override
+                               public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+                                       list.setItems(previousValue);
+                                       notifyListeners(newValue, previousValue);
+                                       oldValue = previousValue;
+                                       return Status.OK_STATUS;
+                               }
+                               @Override
+                               public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+                                       list.setItems(newValue);
+                                       notifyListeners(previousValue, newValue);                               
+                                       oldValue = newValue;
+                                       return Status.OK_STATUS;
+                               }
+                               @Override
+                               public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+                                       return Status.CANCEL_STATUS;
+                               }
+                       };
+                       op.addContext(undoContext);
+                       operationHistory.add(op);
+                       System.arraycopy(items, 0, oldValue = new String[items.length], 0, items.length);
+                       notifyListeners(oldValue, items);
+                       list.setFocus(); // Ensure this control retains focus
+               } else
+                       System.arraycopy(items, 0, oldValue = new String[items.length], 0, items.length);
+       }
+
+       public void notifyListeners(String oldVal[], String newVal[]){
+               for (IFileListChangeListener listener: listeners) {
+                       listener.fileListChanged(this,oldVal,newVal);
+               }
+       }
+
+       /**
+        * Set selection
+        *
+        * @param sel
+        */
+       public void setSelection(int sel) {
+               if (list.getItemCount() > 0)
+                       list.setSelection(sel);
+               selectionChanged();
+       }
+       /**
+        * Set default selection
+        */
+       public void setSelection() {
+               if (list.getItemCount() > 0)
+                       list.setSelection(0);
+       }
+       /**
+        * removes all items from list control
+        */
+       public void removeAll() {
+               if (list != null){
+                       list.removeAll();
+                       checkNotificationNeeded();
+               }
+       }
+       /**
+        * get list items
+        */
+       public String[] getItems() {
+               return list.getItems();
+       }
+       /**
+        * Create selection listener for buttons
+        */
+       private void createSelectionListener() {
+               selectionListener = new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent event) {
+                               Widget widget = event.widget;
+                               if (widget == addItem) {
+                                       addPressed();
+                               } else if (widget == deleteItem) {
+                                       removePressed();
+                               } else if (widget == moveUpItem) {
+                                       upPressed();
+                               } else if (widget == moveDownItem) {
+                                       downPressed();
+                               } else if (widget == list) {
+                                       selectionChanged();
+                               } else if (widget == editItem) {
+                                       editSelection();
+                               }
+                       }
+               };
+       }
+       /**
+        * Returns selection listener
+        *
+        * @return
+        */
+       private SelectionListener getSelectionListener() {
+               if (selectionListener == null)
+                       createSelectionListener();
+               return selectionListener;
+       }
+
+       /**
+        * This method will be called when the add button is pressed
+        */
+       private void addPressed() {
+               // Prompt user for a new item
+               String[] input = getNewInputObject();
+
+               // Add it to the list
+               if (input.length > 0) {
+                       int index = list.getSelectionIndex();
+                       int i = 0;
+                       for (String s : input)
+                               list.add(s, index + ++i);
+                       list.setSelection(index + 1);
+                       checkNotificationNeeded();
+               }
+
+               selectionChanged();
+       }
+
+       /**
+        * This method will be called when the remove button is pressed
+        */
+       private void removePressed() {
+               if (list.getSelectionCount() == 0 || list.getSelectionIndex() == -1)
+                       return;
+               boolean delDir = true;
+               if (promptForDelete) {
+                       String quest = Messages.FileListControl_deletedialog_message; 
+                       String title = Messages.FileListControl_deletedialog_title; 
+                       delDir = MessageDialog.openQuestion(list.getShell(), title, quest);
+               }
+               if (delDir){
+                       int i;
+                       while ((i = list.getSelectionIndex()) != -1)
+                               list.remove(i);
+                       checkNotificationNeeded();
+               }
+               selectionChanged();
+       }
+       /**
+        * This method will be called when the move up button is pressed
+        */
+       private void upPressed() {
+               int index = list.getSelectionIndex();
+               String curSelList = list.getItem(index);
+               String preList = list.getItem(index - 1);
+               list.setItem(index - 1, curSelList);
+               list.setItem(index, preList);
+               list.setSelection(index - 1);
+               checkNotificationNeeded();
+               selectionChanged();
+       }
+       /**
+        * This method will be called when the move down button is pressed
+        */
+       private void downPressed() {
+               int index = list.getSelectionIndex();
+               String curSelList = list.getItem(index);
+               String nextList = list.getItem(index + 1);
+               list.setItem(index + 1, curSelList);
+               list.setItem(index, nextList);
+               list.setSelection(index + 1);
+               checkNotificationNeeded();
+               selectionChanged();
+       }
+       /**
+        * This method will be called when the edit button is pressed
+        */
+       private void editSelection() {
+               final int index = list.getSelectionIndex();
+               if (index != -1) {
+                       String selItem = list.getItem(index);
+                       if (selItem != null) {
+                               /* Use SelectPathInputDialog for IOption.BROWSE_DIR and
+                                * IOption.BROWSE_FILE. Use simple input dialog otherwise.
+                                */
+                               InputDialog dialog;
+                               if ((browseType == BROWSE_DIR) ||
+                                               (browseType == BROWSE_FILE)) {
+
+                                       String title;
+                                       String message;
+                                       if (browseType == BROWSE_DIR) {
+                                               title = DIR_TITLE_EDIT;
+                                               message = DIR_MSG;
+                                       } else {
+                                               title = FILE_TITLE_EDIT;
+                                               message = FILE_MSG;
+                                       }
+                                       dialog =  new SelectPathInputDialog(getListControl().getShell(), title, message, selItem, null, browseType);
+                               } else {
+                                       String title = Messages.FileListControl_editdialog_title; 
+                                       dialog = new InputDialog(null, title, compTitle, selItem, null);
+                               }
+
+                               if (dialog.open() == Window.OK) {
+                                       String[] newItems;
+
+                                       /* If newItem is a directory or file path we need to
+                                        * double-quote it if required. We only do this if the user
+                                        * selected a new path using a browse button. If he/she simply
+                                        * edited the text, we skip this so the user can remove quotes if he/she
+                                        * wants to.
+                                        */
+                                       if (dialog instanceof SelectPathInputDialog) {
+                                               SelectPathInputDialog selDialog = (SelectPathInputDialog)dialog;
+                                               newItems = selDialog.getValues();
+                                               if (selDialog.isValueSetByBrowse())
+                                                       for (int i = 0 ; i < newItems.length ; i++)
+                                                               newItems[i] = doubleQuotePath(newItems[i]);
+                                       } else
+                                               newItems = new String[] { dialog.getValue() };
+
+                                       // If no change, return
+                                       if (newItems.length == 1 && newItems[0].equals(selItem))
+                                               return;
+
+                                       // Replace the changed item & insert new items
+                                       list.setItem(index, newItems[0]);
+                                       for (int i = 1 ; i < newItems.length ; i++)
+                                               list.add(newItems[i], index + i);
+                                       checkNotificationNeeded();
+                                       selectionChanged();
+                               }
+                       }
+               }
+       }
+
+       /**
+        * This method will be called when the list selection changed
+        */
+       public void selectionChanged() {
+               int index = list.getSelectionIndex();
+               int size = list.getItemCount();
+               int selectionCount = list.getSelectionCount();
+               deleteItem.setEnabled(size > 0);
+               moveUpItem.setEnabled(size > 1 && index > 0 && selectionCount == 1);
+               moveDownItem.setEnabled(size > 1 && index >= 0 && index < size - 1 && selectionCount == 1);
+               editItem.setEnabled(selectionCount == 1);
+       }
+       /**
+        * Returns List control
+        */
+       public List getListControl() {
+               return list;
+       }
+
+       /**
+        * Sets the IPath of the project the field editor was
+        * created for.
+        *
+        * @param path The path to the
+        */
+       public void setPath(IPath path) {
+               this.path = path;
+       }
+
+       /**
+        * Set browseType
+        * @deprecated This class should be constructed with the correct type
+        */
+       @Deprecated
+       public void setType(int type) {
+               browseType = type;
+               if (!neverPromptForDelete)
+                       promptForDelete = type == BROWSE_FILE || type == BROWSE_DIR;
+       }
+
+       /**
+        * Sets the default filter-path for the underlying Browse dialog. Only applies when browseType is 'file' or 'dir'.
+        * @param filterPath
+        * 
+        * @since 5.2
+        */
+       public void setFilterPath(String filterPath) {
+               this.filterPath = filterPath;
+       }
+       
+       /**
+        * Sets the filter-extensions for the underlying Browse dialog. Only applies when browseType is 'file'.
+        * @param filterExtensions
+        * 
+        * @since 5.2
+        */
+       public void setFilterExtensions(String[] filterExtensions) {
+               this.filterExtensions = filterExtensions;
+       }
+       
+       /**
+        * Enable/Disable workspace support. If enabled, the workspace browse button
+        * will be visible in the SelectPathInputDialog.
+        * @param enable
+        */
+       public void setWorkspaceSupport(boolean enable) {
+               fWorkspaceSupport = enable;
+       }
+
+       /**
+        * Set the field editor context.
+        */
+       public void setContext(IVariableContextInfo info) {
+               contextInfo = info;
+               for(;info != null;info = info.getNext()){
+                       /*
+                       if(info.getContextType() == IBuildMacroProvider.CONTEXT_PROJECT){
+                               IManagedProject mngProj = (IManagedProject)info.getContextData();
+                               this.rc = mngProj.getOwner();
+                               break;
+                       }
+                       */
+               }
+       }
+
+       /**
+        * Returns the input dialog string
+        */
+       private String[] getNewInputObject() {
+               // Create a dialog to prompt for a new list item
+               String[] input = new String[0];
+               String title = ""; //$NON-NLS-1$
+               String message = ""; //$NON-NLS-1$
+               String initVal = ""; //$NON-NLS-1$
+
+               if (browseType == BROWSE_DIR) {
+                       title = DIR_TITLE_ADD;
+                       message = DIR_MSG;
+                       initVal = path.toString();
+               } else if (browseType == BROWSE_FILE) {
+                       title = FILE_TITLE_ADD;
+                       message = FILE_MSG;
+                       initVal = path.toString();
+               } else {
+                       title = TITLE;
+                       message = compTitle;
+               }
+
+               // Prompt for value
+               SelectPathInputDialog dialog = new SelectPathInputDialog(getListControl().getShell(), title, message, initVal, null, browseType);
+               if (dialog.open() == Window.OK) {
+                       input = dialog.getValues();
+
+                       /* Double-quote (if required) the text if it is a directory or file */
+                       if (input.length > 0) {
+                               if (browseType == BROWSE_DIR || browseType == BROWSE_FILE)
+                                       for (int i = 0 ; i < input.length ; i++)
+                                               input[i] = doubleQuotePath(input[i]);
+                       }
+               }
+
+               return input;
+       }
+
+       public Label getLabelControl(){
+               return title;
+       }
+
+       public void setEnabled(boolean enabled){
+               title.setEnabled(enabled);
+               toolBar.setEnabled(enabled);
+               list.setEnabled(enabled);
+       }
+
+       /**
+        * Double-quotes a path name if it contains white spaces, backslahes
+        * or a macro/variable (We don't know if a macro will contain spaces, so we
+        * have to be on the safe side).
+        * @param pathName The path name to double-quote.
+        * @return
+        */
+       private String doubleQuotePath(String pathName) {
+               /* Trim */
+               pathName = pathName.trim();
+
+               /* Check if path is already double-quoted */
+               boolean bStartsWithQuote = pathName.startsWith("\""); //$NON-NLS-1$
+               boolean bEndsWithQuote = pathName.endsWith("\""); //$NON-NLS-1$
+
+               /* Check for spaces, backslashes or macros */
+               int i = pathName.indexOf(" ") + pathName.indexOf("\\") //$NON-NLS-1$ //$NON-NLS-2$
+                       + pathName.indexOf("${"); //$NON-NLS-1$
+
+               /* If indexof didn't fail all three times, double-quote path */
+               if (i != -3) {
+                       if (!bStartsWithQuote)
+                               pathName = "\"" + pathName; //$NON-NLS-1$
+                       if (!bEndsWithQuote)
+                               pathName = pathName + "\""; //$NON-NLS-1$
+               }
+
+               return pathName;
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/utils/ui/controls/IFileListChangeListener.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/utils/ui/controls/IFileListChangeListener.java
new file mode 100644 (file)
index 0000000..8a56c20
--- /dev/null
@@ -0,0 +1,18 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Intel Corporation - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.utils.ui.controls;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public interface IFileListChangeListener {
+       void fileListChanged(FileListControl fileList, String oldValue[], String newValue[]);
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/utils/ui/controls/RadioButtonsArea.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/utils/ui/controls/RadioButtonsArea.java
new file mode 100644 (file)
index 0000000..ab4ee87
--- /dev/null
@@ -0,0 +1,241 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     QNX Software System
+ *     James Blackburn (Broadcom Corp.)
+ *******************************************************************************/
+package org.eclipse.cdt.utils.ui.controls;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * A field editor for an enumeration type preference.
+ * The choices are presented as a list of radio buttons.
+ * 
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class RadioButtonsArea extends Composite {
+
+       /**
+        * List of radio button entries of the form [label,value].
+        */
+       private String[][] labelsAndValues;
+
+       /**
+        * Number of columns into which to arrange the radio buttons.
+        */
+       private int numColumns;
+
+       /**
+        * Indent used for the first column of the radion button matrix.
+        */
+       //private int indent = 0;
+
+       /**
+        * The current value, or <code>null</code> if none.
+        */
+       protected String value = null;
+       
+       private SelectionListener listener;
+       
+       private List<SelectionListener> externalListeners = new ArrayList<SelectionListener>();
+
+       private Composite area = null; 
+       /**
+        * The radio buttons, or <code>null</code> if none
+        * (before creation and after disposal).
+        */
+       protected Button[] radioButtons;
+
+
+       public RadioButtonsArea(Composite parent, String labelText, int numColumns, String[][] labelAndValues) {
+               super(parent, SWT.NULL);
+               Assert.isTrue(checkArray(labelAndValues));
+               this.labelsAndValues = labelAndValues;
+               this.numColumns = numColumns;
+               createControl(parent, labelText);
+       }
+       
+       @Override
+       public void setEnabled(boolean enabled) {
+               for (Button radioButton : radioButtons) {
+                       radioButton.setEnabled(enabled);
+               }
+       }
+       
+       /**
+        * Checks whether given <code>String[][]</code> is of "type" 
+        * <code>String[][2]</code>.
+        *
+        * @return <code>true</code> if it is ok, and <code>false</code> otherwise
+        */
+       private boolean checkArray(String[][] table) {
+               if (table == null)
+                       return false;
+               for (String[] array : table) {
+                       if (array == null || array.length != 2)
+                               return false;
+               }
+               return true;
+       }
+
+       protected void fireSelectionEvent(SelectionEvent event) {
+               for (SelectionListener s : externalListeners) {
+                       s.widgetSelected(event);
+               }
+       }
+       
+       /**
+        * Create control area
+        */
+       protected void createControl(Composite parent, String labelText) {
+               GridLayout gl = new GridLayout();
+               this.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+               gl.marginWidth = 0;
+               gl.horizontalSpacing = 0;
+               this.setLayout(gl);
+       
+               if(null != labelText) { // Create group box
+                       area = ControlFactory.createGroup(this, labelText, numColumns);
+               } else {
+                       area = this;
+               }
+
+               radioButtons = new Button[labelsAndValues.length];
+               listener =  new SelectionAdapter() {
+                       @Override
+                       public void widgetSelected(SelectionEvent event) {
+                               value = (String) (event.widget.getData());
+                               fireSelectionEvent(event); // Infor any external listener
+                       }
+               };
+               
+               for (int i = 0; i < labelsAndValues.length; i++) {
+                       radioButtons[i] = ControlFactory.createRadioButton(area, 
+                                                         labelsAndValues[i][0],
+                                                         labelsAndValues[i][1],
+                                                     listener);
+               }
+               
+               area.addDisposeListener(new DisposeListener() {
+                       public void widgetDisposed(DisposeEvent event) {
+                               radioButtons = null;
+                       }
+               });
+
+       }
+       
+       /**
+        * Sets the indent used for the first column of the radion button matrix.
+        *
+        * @param indent the indent (in pixels)
+        */
+       public void setIndent(int indent) {
+               if(null == area)
+                       return;
+               if (indent < 0)
+                       indent = 0;
+               for(int i = 0; i < radioButtons.length; ++i) {
+                       ((GridData)(radioButtons[i].getLayoutData())).horizontalIndent = indent;
+               }
+       }
+
+       /**
+        * Select the radio button that conforms to the given value.
+        *
+        * @param selectedValue the selected value
+        */
+       public void setSelectValue(String selectedValue) {
+               this.value = selectedValue;
+               if (radioButtons == null)
+                       return;
+       
+               if (this.value != null) {
+                       boolean found = false;
+                       for (Button radio : radioButtons) {
+                               boolean selection = false;
+                               if (radio.getData().equals(this.value)) {
+                                       selection = true;
+                                       found = true;
+                               }
+                               radio.setSelection(selection);
+                       }
+                       if (found)
+                               return;
+               }
+       
+               // We weren't able to find the value. So we select the first
+               // radio button as a default.
+               if (radioButtons.length > 0) {
+                       radioButtons[0].setSelection(true);
+                       this.value = (String) radioButtons[0].getData();
+               }
+               return;
+       }
+
+    public void setSelectedButton(int index) {
+       Button b;
+       
+       if((index < 0) || (index >= radioButtons.length))
+               return;
+               
+               for(int i = 0; i < radioButtons.length; ++i) {
+                       b = radioButtons[i];
+                       boolean selected = b.getSelection();
+                       if(i == index) {
+                          if(selected)
+                               return;
+                       } else {
+                               if(selected)
+                                       b.setSelection(false);
+                       }
+               }
+
+               b = radioButtons[index];
+               this.value = (String)b.getData();
+               b.setSelection(true);
+    }
+       
+       public String getSelectedValue() {
+               return value;
+       }
+       
+       public int getSeletedIndex() {
+               if (radioButtons == null)
+                       return -1;
+       
+               if (value != null) {
+                       for (int i = 0; i < radioButtons.length; i++) {
+                               if (radioButtons[i].getData().equals(this.value)) 
+                                       return i;
+                       }
+               }
+               
+               return -1;
+       }
+       
+       public void addSelectionListener(SelectionListener s) {
+               if(externalListeners.contains(s))
+                       return;
+               externalListeners.add(s);
+       }
+}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/utils/ui/controls/TabFolderLayout.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/utils/ui/controls/TabFolderLayout.java
new file mode 100644 (file)
index 0000000..a951653
--- /dev/null
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.utils.ui.controls;
+
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Layout;
+
+/**
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class TabFolderLayout extends Layout {
+
+       @Override
+       protected Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache) {
+               if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT)
+                       return new Point(wHint, hHint);
+                       
+               Control [] children = composite.getChildren ();
+               int count = children.length;
+               int maxWidth = 0, maxHeight = 0;
+               for (int i=0; i<count; i++) {
+                       Control child = children [i];
+                       Point pt = child.computeSize (SWT.DEFAULT, SWT.DEFAULT, flushCache);
+                       maxWidth = Math.max (maxWidth, pt.x);
+                       maxHeight = Math.max (maxHeight, pt.y);
+               }
+               
+               if (wHint != SWT.DEFAULT)
+                       maxWidth= wHint;
+               if (hHint != SWT.DEFAULT)
+                       maxHeight= hHint;
+               
+               return new Point(maxWidth, maxHeight);  
+               
+       }
+       @Override
+       protected void layout (Composite composite, boolean flushCache) {
+               Rectangle rect= composite.getClientArea();
+       
+               Control[] children = composite.getChildren();
+               for (int i = 0; i < children.length; i++) {
+                       children[i].setBounds(rect);
+               }
+       }
+}
+
diff --git a/org.eclipse.cdt.ui/templates/default-codetemplates.xml b/org.eclipse.cdt.ui/templates/default-codetemplates.xml
new file mode 100644 (file)
index 0000000..7efcef2
--- /dev/null
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems)
+ *        Sergey Prigogin (Google)
+ *******************************************************************************/
+-->
+
+<templates>
+
+<template name="constructorcomment" id="org.eclipse.cdt.ui.text.codetemplates.constructorcomment" description="%CodeTemplates.constructorcomment" context="org.eclipse.cdt.ui.text.codetemplates.constructorcomment_context" enabled="true">/*
+ *
+ */</template>
+
+<template name="destructorcomment" id="org.eclipse.cdt.ui.text.codetemplates.destructorcomment" description="%CodeTemplates.destructorcomment" context="org.eclipse.cdt.ui.text.codetemplates.destructorcomment_context" enabled="true">/*
+ *
+ */</template>
+
+<template name="filecomment" id="org.eclipse.cdt.ui.text.codetemplates.filecomment" description="%CodeTemplates.filecomment" context="org.eclipse.cdt.ui.text.codetemplates.filecomment_context" enabled="true">/*
+ * ${file_name}
+ *
+ *  Created on: ${date}
+ *      Author: ${user}
+ */</template>
+
+<template name="typecomment" id="org.eclipse.cdt.ui.text.codetemplates.typecomment" description="%CodeTemplates.typecomment" context="org.eclipse.cdt.ui.text.codetemplates.typecomment_context" enabled="true">/*
+ *
+ */</template>
+<template name="fieldcomment" id="org.eclipse.cdt.ui.text.codetemplates.fieldcomment" description="%CodeTemplates.fieldcomment" context="org.eclipse.cdt.ui.text.codetemplates.fieldcomment_context" enabled="true">/*
+ *
+ */</template>
+<template name="methodcomment" id="org.eclipse.cdt.ui.text.codetemplates.methodcomment" description="%CodeTemplates.methodcomment" context="org.eclipse.cdt.ui.text.codetemplates.methodcomment_context" enabled="true">/*
+ *
+ */</template>
+
+<template name="%CodeTemplates.cppsourcefile" id="org.eclipse.cdt.ui.text.codetemplates.cppsourcefile" description="%CodeTemplates.cppsourcefile.desc" context="org.eclipse.cdt.core.cxxSource.contenttype_context" enabled="true">${filecomment}
+
+${includes}
+
+${namespace_begin}
+
+${declarations}
+
+${namespace_end}</template>
+
+<template name="%CodeTemplates.cpptestfile" id="org.eclipse.cdt.ui.text.codetemplates.cpptestfile" description="%CodeTemplates.cpptestfile.desc" context="org.eclipse.cdt.core.cxxSource.contenttype_context" enabled="true">${filecomment}
+
+${includes}
+
+${namespace_begin}
+
+${declarations}
+
+${namespace_end}</template>
+
+<template name="%CodeTemplates.cppheaderfile" id="org.eclipse.cdt.ui.text.codetemplates.cppheaderfile" description="%CodeTemplates.cppheaderfile.desc" context="org.eclipse.cdt.core.cxxHeader.contenttype_context" enabled="true">${filecomment}
+
+#ifndef ${include_guard_symbol}
+#define ${include_guard_symbol}
+
+${includes}
+
+${namespace_begin}
+
+${declarations}
+
+${namespace_end}
+#endif /* ${include_guard_symbol} */</template>
+
+<template name="%CodeTemplates.csourcefile" id="org.eclipse.cdt.ui.text.codetemplates.csourcefile" description="%CodeTemplates.csourcefile.desc" context="org.eclipse.cdt.core.cSource.contenttype_context" enabled="true">${filecomment}
+
+${includes}
+
+${declarations}</template>
+
+<template name="%CodeTemplates.cheaderfile" id="org.eclipse.cdt.ui.text.codetemplates.cheaderfile" description="%CodeTemplates.cheaderfile.desc" context="org.eclipse.cdt.core.cHeader.contenttype_context" enabled="true">${filecomment}
+
+#ifndef ${include_guard_symbol}
+#define ${include_guard_symbol}
+
+${includes}
+
+${declarations}
+
+#endif /* ${include_guard_symbol} */</template>
+
+<template name="namespace_begin" id="org.eclipse.cdt.ui.text.codetemplates.namespace_begin" description="%CodeTemplates.namespace_begin" context="org.eclipse.cdt.ui.text.codetemplates.namespace_context" enabled="true">namespace ${namespace_name} {</template>
+
+<template name="namespace_end" id="org.eclipse.cdt.ui.text.codetemplates.namespace_end" description="%CodeTemplates.namespace_end" context="org.eclipse.cdt.ui.text.codetemplates.namespace_context" enabled="true">} /* namespace ${namespace_name} */</template>
+
+<template name="class_body" id="org.eclipse.cdt.ui.text.codetemplates.class_body" description="%CodeTemplates.class_body" context="org.eclipse.cdt.ui.text.codetemplates.class_context" enabled="true">${declarations}</template>
+
+<template name="methodbody" id="org.eclipse.cdt.ui.text.codetemplates.methodbody" description="%CodeTemplates.methodstub" context="org.eclipse.cdt.ui.text.codetemplates.methodbody_context" enabled="true">&#9;// ${todo} %CodeTemplates.methodstub.tododesc
+&#9;${body_statement}</template>
+
+<template name="constructorbody" id="org.eclipse.cdt.ui.text.codetemplates.constructorbody" description="%CodeTemplates.constructorstub" context="org.eclipse.cdt.ui.text.codetemplates.constructorbody_context" enabled="true">&#9;// ${todo} %CodeTemplates.constructorstub.tododesc
+&#9;${body_statement}</template>
+
+<template name="destructorbody" id="org.eclipse.cdt.ui.text.codetemplates.destructorbody" description="%CodeTemplates.destructorstub" context="org.eclipse.cdt.ui.text.codetemplates.destructorbody_context" enabled="true">&#9;${body_statement}
+&#9;// ${todo} %CodeTemplates.destructorstub.tododesc</template>
+
+</templates>
diff --git a/org.eclipse.cdt.ui/templates/default-filetemplates.xml b/org.eclipse.cdt.ui/templates/default-filetemplates.xml
new file mode 100644 (file)
index 0000000..4cea755
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+/*******************************************************************************
+ * Copyright (c) 2007 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+-->
+
+<templates>
+
+<template name="%FileTemplates.asmsourcefile" id="org.eclipse.cdt.ui.text.codetemplates.asmsourcefile" description="%FileTemplates.asmsourcefile.desc" context="org.eclipse.cdt.core.asmSource.contenttype_context" enabled="true">${filecomment}
+</template>
+
+<template name="%FileTemplates.textfile" id="org.eclipse.cdt.ui.text.codetemplates.textfile" description="%FileTemplates.textfile.desc" context="org.eclipse.core.runtime.text.contenttype_context" enabled="true">${file_name}
+
+ Created on: ${date}
+     Author: ${user}
+
+</template>
+
+</templates>
diff --git a/org.eclipse.cdt.ui/templates/default-templates.properties b/org.eclipse.cdt.ui/templates/default-templates.properties
new file mode 100644 (file)
index 0000000..e4688b7
--- /dev/null
@@ -0,0 +1,73 @@
+###############################################################################
+# Copyright (c) 2000, 2007 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+#        Sergey Prigogin (Google)
+###############################################################################
+
+## NOTE TO TRANSLATORS:
+## The following code words should not be translated: for, do while, switch case, 
+## if, if else, else if, else, try catch, catch, main, class, using, namespace, author
+
+forLoop = for loop
+forLoopWithTempVar = for loop with temporary variable
+doWhileStmt = do while statement
+switchCaseStmt = switch case statement
+ifStmt = if statement
+ifElseStmt = if else statement
+## block is a noun
+elseIfBlock = else if block
+elseBlock = else block
+tryCatchBlock = try catch block
+catchBlock = catch block
+mainMethod = main method
+classDeclaration = class declaration
+usinganamespace = using a namespace
+namespaceDeclaration = namespace declaration
+createnewobject = create new object
+defaultmultilinecomment = default multiline comment
+printtostdout = print to standard output
+printtostderr = print to standard error
+authorname = author name
+commentText = To change this generated comment edit the template variable "comment":\n\
+\ * Window > Preferences > C/C++ > Editor > Templates.
+
+# strings in default code templates
+CodeTemplates.constructorcomment=Comment for created constructors
+CodeTemplates.destructorcomment=Comment for created destructors
+CodeTemplates.filecomment=Comment for created C/C++ files
+CodeTemplates.typecomment=Comment for created classes
+CodeTemplates.fieldcomment=Comment for fields
+CodeTemplates.methodcomment=Comment for methods
+
+CodeTemplates.cppsourcefile=Default C++ source template
+CodeTemplates.cppheaderfile=Default C++ header template
+CodeTemplates.cpptestfile=Default C++ test template
+CodeTemplates.csourcefile=Default C source template
+CodeTemplates.cheaderfile=Default C header template
+CodeTemplates.cppsourcefile.desc=Default template for newly created C++ source files
+CodeTemplates.cppheaderfile.desc=Default template for newly created C++ header files
+CodeTemplates.cpptestfile.desc=Default template for newly created C++ test files
+CodeTemplates.csourcefile.desc=Default template for newly created C source files
+CodeTemplates.cheaderfile.desc=Default template for newly created C header files
+
+CodeTemplates.namespace_begin=Beginning of namespace declaration
+CodeTemplates.namespace_end=End of namespace declaration
+CodeTemplates.class_body=Code in created class definitions
+CodeTemplates.methodstub=Code in created method stubs
+CodeTemplates.constructorstub=Code in created constructor stubs
+CodeTemplates.destructorstub=Code in created destructor stubs
+
+CodeTemplates.methodstub.tododesc=Auto-generated method stub
+CodeTemplates.constructorstub.tododesc=Auto-generated constructor stub
+CodeTemplates.destructorstub.tododesc=Auto-generated destructor stub
+
+FileTemplates.asmsourcefile=Default assembly template
+FileTemplates.asmsourcefile.desc=Default template for newly created assembly files
+FileTemplates.textfile=Default text file template
+FileTemplates.textfile.desc=Default template for newly created text files
diff --git a/org.eclipse.cdt.ui/templates/default-templates.xml b/org.eclipse.cdt.ui/templates/default-templates.xml
new file mode 100644 (file)
index 0000000..f0b57a9
--- /dev/null
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+
+###############################################################################
+# Copyright (c) 2000, 2007 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#     IBM Corporation - initial API and implementation
+###############################################################################
+
+-->
+
+<!-- NOTE TO TRANSLATOR:
+* This file should remain English as it produces compilable code. 
+-->
+
+<templates>
+<template name="for" description="%forLoop" context="org.eclipse.cdt.ui.text.templates.c" id="org.eclipse.cdt.ui.text.templates.c.for" enabled="true">for (${var} = 0; ${var} &lt; ${max}; ++${var}) {
+       ${line_selection}${cursor}
+}</template>
+
+<template name="for" description="%forLoopWithTempVar" context="org.eclipse.cdt.ui.text.templates.c" id="org.eclipse.cdt.ui.text.templates.cpp.for" enabled="true">for (int ${var} = 0; ${var} &lt; ${max}; ++${var}) {
+       ${line_selection}${cursor}
+}</template>
+<template name="do" description="%doWhileStmt" context="org.eclipse.cdt.ui.text.templates.c" id="org.eclipse.cdt.ui.text.templates.c.do" enabled="true">do {
+       ${line_selection}${cursor}
+} while (${condition});</template>
+<template name="switch" description="%switchCaseStmt" context="org.eclipse.cdt.ui.text.templates.c" id="org.eclipse.cdt.ui.text.templates.c.switch" enabled="true">switch (${key}) {
+       case ${value}:
+               ${cursor}
+               break;
+       default:
+               break;
+}</template>
+
+<template name="if" description="%ifStmt" context="org.eclipse.cdt.ui.text.templates.c" id="org.eclipse.cdt.ui.text.templates.c.if" enabled="true">if (${condition}) {
+       ${line_selection}${cursor}
+}</template>
+<template name="ifelse" description="%ifElseStmt" context="org.eclipse.cdt.ui.text.templates.c" id="org.eclipse.cdt.ui.text.templates.c.ifelse" enabled="true">if (${condition}) {
+       ${cursor}
+} else {
+       
+}</template>
+<template name="elseif" description="%elseIfBlock" context="org.eclipse.cdt.ui.text.templates.c" id="org.eclipse.cdt.ui.text.templates.c.elseif" enabled="true">else if (${condition}) {
+       ${cursor}
+}</template>
+<template name="else" description="%elseBlock" context="org.eclipse.cdt.ui.text.templates.c" id="org.eclipse.cdt.ui.text.templates.c.else" enabled="true">else {
+       ${cursor}
+}</template>
+<template name="try" description="%tryCatchBlock" context="org.eclipse.cdt.ui.text.templates.c" id="org.eclipse.cdt.ui.text.templates.cpp.try" enabled="true">try {
+       ${line_selection}${cursor}
+} catch (${Exception} e) {
+}</template>
+<template name="catch" description="%catchBlock" context="org.eclipse.cdt.ui.text.templates.c" id="org.eclipse.cdt.ui.text.templates.cpp.catch" enabled="true">catch (${Exception} e) {
+       ${cursor}
+}</template>
+<template name="main" description="%mainMethod" context="org.eclipse.cdt.ui.text.templates.c" id="org.eclipse.cdt.ui.text.templates.c.main" enabled="true">int main(int argc, char **argv) {
+       ${cursor}
+}
+</template>
+<template name="class" description="%classDeclaration" context="org.eclipse.cdt.ui.text.templates.c" id="org.eclipse.cdt.ui.text.templates.cpp.class" enabled="true">class ${name} {
+public:
+       ${cursor}
+
+private:
+};</template>
+<template name="using" description="%usinganamespace" context="org.eclipse.cdt.ui.text.templates.c" id="org.eclipse.cdt.ui.text.templates.cpp.using" enabled="true">using namespace ${name};
+</template>
+<template name="namespace" description="%namespaceDeclaration" context="org.eclipse.cdt.ui.text.templates.c" id="org.eclipse.cdt.ui.text.templates.cpp.namespace" enabled="true">namespace ${name} {
+
+${cursor}
+
+}  // namespace ${name}</template>
+<template name="new" description="%createnewobject" context="org.eclipse.cdt.ui.text.templates.c" id="org.eclipse.cdt.ui.text.templates.cpp.new" enabled="true">${type} ${name} = new ${type}(${arguments});</template>
+<template name="comment" description="%defaultmultilinecomment" context="org.eclipse.cdt.ui.text.templates.c" id="org.eclipse.cdt.ui.text.templates.c.comment" enabled="true">
+/*
+ * author ${user}
+ *
+ * %commentText
+ */
+</template>
+<template name="stdout" description="%printtostdout" context="org.eclipse.cdt.ui.text.templates.c" id="org.eclipse.cdt.ui.text.templates.c.printf" enabled="true">printf(${cursor});</template>
+<template name="stderr" description="%printtostderr" context="org.eclipse.cdt.ui.text.templates.c" id="org.eclipse.cdt.ui.text.templates.c.fprintf" enabled="true">fprintf(stderr, ${cursor});</template>
+<template name="author" description="%authorname" context="org.eclipse.cdt.ui.text.templates.comment" id="org.eclipse.cdt.ui.text.templates.comment.author" enabled="true">author ${user}</template>
+
+</templates>
diff --git a/org.eclipse.jst.pagedesigner.patch/src/org/eclipse/jst/pagedesigner/editors/HTMLEditor.java b/org.eclipse.jst.pagedesigner.patch/src/org/eclipse/jst/pagedesigner/editors/HTMLEditor.java
new file mode 100755 (executable)
index 0000000..20e2188
--- /dev/null
@@ -0,0 +1,1209 @@
+/*******************************************************************************\r
+ * Copyright (c) 2006 Sybase, Inc. and others.\r
+ *\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     Sybase, Inc. - initial API and implementation\r
+ *******************************************************************************/\r
+package org.eclipse.jst.pagedesigner.editors;\r
+\r
+import java.io.File;\r
+import java.io.InputStream;\r
+import java.util.ArrayList;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+\r
+import org.eclipse.core.resources.IFile;\r
+import org.eclipse.core.resources.IResource;\r
+import org.eclipse.core.runtime.CoreException;\r
+import org.eclipse.core.runtime.IConfigurationElement;\r
+import org.eclipse.core.runtime.IExtension;\r
+import org.eclipse.core.runtime.IExtensionPoint;\r
+import org.eclipse.core.runtime.IProgressMonitor;\r
+import org.eclipse.core.runtime.NullProgressMonitor;\r
+import org.eclipse.core.runtime.Platform;\r
+import org.eclipse.gef.DefaultEditDomain;\r
+import org.eclipse.gef.EditPart;\r
+import org.eclipse.gef.ui.views.palette.PalettePage;\r
+import org.eclipse.gef.ui.views.palette.PaletteViewerPage;\r
+import org.eclipse.jface.preference.IPreferenceStore;\r
+import org.eclipse.jface.text.IDocument;\r
+import org.eclipse.jface.text.TextSelection;\r
+import org.eclipse.jface.viewers.IPostSelectionProvider;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.jface.viewers.ISelectionChangedListener;\r
+import org.eclipse.jface.viewers.ISelectionProvider;\r
+import org.eclipse.jface.viewers.SelectionChangedEvent;\r
+import org.eclipse.jst.jsf.common.ui.internal.logging.Logger;\r
+import org.eclipse.jst.jsf.common.ui.internal.utils.ResourceUtils;\r
+import org.eclipse.jst.pagedesigner.IJMTConstants;\r
+import org.eclipse.jst.pagedesigner.PDPlugin;\r
+import org.eclipse.jst.pagedesigner.dnd.internal.DesignerSourceMouseTrackAdapter;\r
+import org.eclipse.jst.pagedesigner.editors.pagedesigner.PageDesignerResources;\r
+import org.eclipse.jst.pagedesigner.jsp.core.pagevar.IPageVariablesProvider;\r
+import org.eclipse.jst.pagedesigner.jsp.core.pagevar.adapter.IDocumentPageVariableAdapter;\r
+import org.eclipse.jst.pagedesigner.parts.DocumentEditPart;\r
+import org.eclipse.jst.pagedesigner.preview.PreviewHandlerNew;\r
+import org.eclipse.jst.pagedesigner.preview.WindowsIEBrowser;\r
+import org.eclipse.jst.pagedesigner.properties.WPETabbedPropertySheetPage;\r
+import org.eclipse.jst.pagedesigner.tools.RangeSelectionTool;\r
+import org.eclipse.jst.pagedesigner.ui.common.PartActivationHandler;\r
+import org.eclipse.jst.pagedesigner.ui.common.sash.SashEditorPart;\r
+import org.eclipse.jst.pagedesigner.ui.preferences.PDPreferences;\r
+import org.eclipse.jst.pagedesigner.utils.EditorUtil;\r
+import org.eclipse.jst.pagedesigner.utils.PreviewUtil;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.layout.FillLayout;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Display;\r
+import org.eclipse.ui.IEditorInput;\r
+import org.eclipse.ui.IEditorPart;\r
+import org.eclipse.ui.IEditorSite;\r
+import org.eclipse.ui.IFileEditorInput;\r
+import org.eclipse.ui.IPropertyListener;\r
+import org.eclipse.ui.IStorageEditorInput;\r
+import org.eclipse.ui.IWorkbench;\r
+import org.eclipse.ui.IWorkbenchPart;\r
+import org.eclipse.ui.IWorkbenchWindow;\r
+import org.eclipse.ui.PartInitException;\r
+import org.eclipse.ui.PlatformUI;\r
+import org.eclipse.ui.contexts.IContextService;\r
+import org.eclipse.ui.part.FileEditorInput;\r
+import org.eclipse.ui.part.MultiPageEditorPart;\r
+import org.eclipse.ui.part.MultiPageEditorSite;\r
+import org.eclipse.ui.part.MultiPageSelectionProvider;\r
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;\r
+import org.eclipse.ui.views.properties.IPropertySheetPage;\r
+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;\r
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;\r
+import org.eclipse.wst.sse.ui.StructuredTextEditor;\r
+import org.eclipse.wst.sse.ui.internal.provisional.extensions.ISourceEditingTextTools;\r
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;\r
+import org.eclipse.wst.xml.ui.internal.provisional.IDOMSourceEditingTextTools;\r
+import org.w3c.dom.Document;\r
+\r
+/**\r
+ * The HTMLEditor is a multi paged editor. It will use the StructuredTextEditor\r
+ * as the chief editor, and delegate most operations to it.\r
+ * \r
+ * @author mengbo\r
+ */\r
+public final class HTMLEditor extends MultiPageEditorPart implements\r
+               IPropertyListener, ITabbedPropertySheetPageContributor {\r
+       // private static final String PAGE_NAME_DESIGN = "Design"; //$NON-NLS-1$\r
+       // private static final String PAGE_NAME_SOURCE = "Source"; //$NON-NLS-1$\r
+       /**\r
+        * Tabbed property contributor id for WPE\r
+        */\r
+       public final static String TABBED_PROPERTIES_CONTRIBUTOR_ID = "org.eclipse.jst.pagedesigner.tabPropertyContributor"; //$NON-NLS-1$\r
+\r
+       // four different modes for the designer when displayed in a sash editor.\r
+       /**\r
+        * editor split is vertical\r
+        */\r
+       public static final int MODE_SASH_VERTICAL = 0;\r
+\r
+       /**\r
+        * editor split is horizontal\r
+        */\r
+       public static final int MODE_SASH_HORIZONTAL = 1;\r
+\r
+       /**\r
+        * no split, only designer canvas\r
+        */\r
+       public static final int MODE_DESIGNER = 2;\r
+\r
+       /**\r
+        * no split, only SSE source\r
+        */\r
+       public static final int MODE_SOURCE = 3;\r
+\r
+       private Logger _log = PDPlugin.getLogger(HTMLEditor.class);\r
+\r
+       private boolean _sash = true;\r
+\r
+       private int _mode = 0;\r
+\r
+       private SashEditorPart _sashEditorPart = null;\r
+\r
+       private int _previewPageIndex;\r
+\r
+       /** The design viewer */\r
+       private SimpleGraphicalEditor _designViewer;\r
+\r
+       /** The text editor. */\r
+       private StructuredTextEditor _textEditor;\r
+\r
+       private PartActivationHandler _partListener;\r
+\r
+       private PaletteViewerPage _paletteViewerPage;\r
+\r
+       private DefaultEditDomain _editDomain;\r
+\r
+       private WindowsIEBrowser _browser;\r
+       \r
+       private Composite _previewComposite;\r
+\r
+       private List PREVIEW_FILES_LIST = new ArrayList();\r
+\r
+       private IPropertySheetPage _tabbedPropSheet;\r
+\r
+       private ISelectionChangedListener _selChangedListener;\r
+\r
+    // TODO:This class is never used locally\r
+//     private class TextInputListener implements ITextInputListener {\r
+//             public void inputDocumentAboutToBeChanged(IDocument oldInput,\r
+//                             IDocument newInput) {\r
+//            // do nothing\r
+//             }\r
+//\r
+//             public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {\r
+//                     if (_designViewer != null && newInput != null)\r
+//                             _designViewer.setModel(getModel());\r
+//             }\r
+//     }\r
+\r
+       /**\r
+        * Default constructor\r
+        */\r
+       public HTMLEditor() {\r
+               super();\r
+       }\r
+\r
+       /*\r
+        * This method is just to make firePropertyChanged accessbible from some\r
+        * (anonomous) inner classes.\r
+        */\r
+       private void _firePropertyChange(int property) {\r
+               super.firePropertyChange(property);\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * \r
+        * @see com.ibm.xtools.common.ui.properties.ITabbedPropertySheetPageContributor#getContributorId()\r
+        */\r
+       public String getContributorId() {\r
+               return TABBED_PROPERTIES_CONTRIBUTOR_ID;\r
+       }\r
+\r
+       private void connectSashPage() {\r
+               ISelectionProvider selectionProvider = _sashEditorPart.getSite()\r
+                               .getSelectionProvider();\r
+               if (selectionProvider instanceof IPostSelectionProvider) {\r
+                       ((IPostSelectionProvider) selectionProvider)\r
+                                       .addPostSelectionChangedListener(getSelectionChangedListener(selectionProvider));\r
+               } else {\r
+                       selectionProvider\r
+                                       .addSelectionChangedListener(getSelectionChangedListener(selectionProvider));\r
+               }\r
+       }\r
+       \r
+       private void disconnectSashPage() {\r
+               //attempted fix for bug 283569... was not able to repro, but should protect against NPE\r
+               if (_sashEditorPart != null \r
+                               && _sashEditorPart.getSite() != null \r
+                               && _sashEditorPart.getSite().getSelectionProvider() != null\r
+                               && _selChangedListener != null) {\r
+                       \r
+                       final ISelectionProvider selectionProvider = _sashEditorPart.getSite()\r
+                                       .getSelectionProvider();\r
+                       if (selectionProvider != null) {\r
+                               if (selectionProvider instanceof IPostSelectionProvider) {\r
+                                       ((IPostSelectionProvider) selectionProvider)\r
+                                                       .removePostSelectionChangedListener(getSelectionChangedListener(selectionProvider));\r
+                               } else {\r
+                                       selectionProvider\r
+                                                       .removeSelectionChangedListener(getSelectionChangedListener(selectionProvider));\r
+                               }\r
+                       }\r
+               }               \r
+       }\r
+\r
+       private ISelectionChangedListener getSelectionChangedListener(ISelectionProvider selectionProvider) {\r
+               if (_selChangedListener  == null) {\r
+                       if (selectionProvider instanceof IPostSelectionProvider) {\r
+                               _selChangedListener =  new ISelectionChangedListener() {\r
+                               public void selectionChanged(SelectionChangedEvent event) {\r
+                                               ((MultiPageSelectionProvider) getSite()\r
+                                                               .getSelectionProvider())\r
+                                                               .firePostSelectionChanged(event);\r
+                                       }\r
+                               };\r
+                       }\r
+                       else {\r
+                               _selChangedListener =  new ISelectionChangedListener() {\r
+                                       public void selectionChanged(SelectionChangedEvent event) {\r
+                                                       ((MultiPageSelectionProvider) getSite()\r
+                                                                       .getSelectionProvider())\r
+                                                                       .firePostSelectionChanged(event);\r
+                                               }\r
+                                       };\r
+                       }\r
+               }\r
+               return _selChangedListener;\r
+       }\r
+\r
+       /**\r
+        * Creates the source page of the multi-page editor.\r
+        * @throws PartInitException \r
+        */\r
+       protected void sash_createAndAddDesignSourcePage() throws PartInitException {\r
+               // create source page\r
+               _textEditor = createTextEditor();\r
+               _textEditor.setEditorPart(this);\r
+               _textEditor.addPropertyListener(this);\r
+               // create design page\r
+               _designViewer = new SimpleGraphicalEditor(this, getEditDomain());\r
+\r
+               // create SashEditor\r
+               _sashEditorPart = new SashEditorPart() {\r
+                       protected void createPages() throws PartInitException {\r
+                               addPage(_designViewer, getEditorInput());\r
+                               addPage(_textEditor, getEditorInput());\r
+                       }\r
+               };\r
+               int sashIndex = addPage(_sashEditorPart, getEditorInput());\r
+\r
+               // Set the sash editor mode from the stored file property\r
+               // or the default preference\r
+               initDesignerMode();\r
+\r
+               setPageText(sashIndex, PDPlugin.getResourceString("HTMLEditor.Design")); //$NON-NLS-1$\r
+\r
+               // the update's critical, to get viewer selection manager and\r
+               // highlighting to work\r
+               _textEditor.update();\r
+\r
+               firePropertyChange(PROP_TITLE);\r
+\r
+               // Changes to the Text Viewer's document instance should also force an\r
+               // input refresh\r
+               // _textEditor.getTextViewer().addTextInputListener(new\r
+               // TextInputListener());\r
+               connectSashPage();\r
+       }\r
+\r
+       /**\r
+        * @see org.eclipse.ui.part.MultiPageEditorPart#createSite(org.eclipse.ui.IEditorPart)\r
+        */\r
+       protected IEditorSite createSite(IEditorPart editor) {\r
+               return new MultiPageEditorSite(this, editor);\r
+       }\r
+\r
+       private void tabbed_createAndAddDesignSourcePage()\r
+                       throws PartInitException {\r
+               // create source page\r
+               _textEditor = createTextEditor();\r
+               _textEditor.setEditorPart(this);\r
+               _textEditor.addPropertyListener(this);\r
+\r
+               // create design page\r
+               SimpleGraphicalEditor editor = new SimpleGraphicalEditor(this,\r
+                               getEditDomain());\r
+\r
+               // add design page\r
+               int designPageIndex = addPage(editor, null);\r
+\r
+               _designViewer = editor;\r
+               // // note: By adding the design page as a Control instead of an\r
+               // // IEditorPart, page switches will indicate\r
+               // // a "null" active editor when the design page is made active\r
+               setPageText(designPageIndex, PDPlugin\r
+                               .getResourceString("HTMLEditor.Design")); //$NON-NLS-1$\r
+\r
+               // add source page\r
+               int sourcePageIndex = addPage(_textEditor, getEditorInput());\r
+               setPageText(sourcePageIndex, PDPlugin\r
+                               .getResourceString("HTMLEditor.Source")); //$NON-NLS-1$\r
+               // the update's critical, to get viewer selection manager and\r
+               // highlighting to work\r
+               _textEditor.update();\r
+\r
+               firePropertyChange(PROP_TITLE);\r
+\r
+               // Changes to the Text Viewer's document instance should also force an\r
+               // input refresh\r
+               // _textEditor.getTextViewer().addTextInputListener(new\r
+               // TextInputListener());\r
+       }\r
+\r
+       private void createAndAddPreviewPage() {\r
+               _previewComposite = new Composite(getContainer(), 0);\r
+               FillLayout filllayout = new FillLayout();\r
+               _previewComposite.setLayout(filllayout);\r
+\r
+               _previewPageIndex = addPage(_previewComposite);\r
+               // JSPSourceEditor.Page.Preview.PageText=Preview\r
+               setPageText(_previewPageIndex, PageDesignerResources.getInstance()\r
+                               .getString("JSPSourceEditor.Page.Preview.PageText")); //$NON-NLS-1$\r
+               \r
+       }\r
+\r
+       private WindowsIEBrowser getPreviewBrowser() {\r
+               if (_browser == null) {\r
+                       _browser = new WindowsIEBrowser();\r
+                       if (_browser != null) {\r
+                               try {\r
+                                       // Support WEBKIT Browser\r
+                                       _browser.create(_previewComposite, SWT.WEBKIT);\r
+                               } catch (Error e) {\r
+                                       // If SWTError is logged, Eclipse asks to exit workbench.\r
+                                       _browser.create(_previewComposite, SWT.NONE);\r
+                               }\r
+                               _previewComposite.layout();\r
+                       }\r
+               }\r
+               return _browser;\r
+       }\r
+       /**\r
+        * Connects the design viewer with the viewer selection manager. Should be\r
+        * done after createSourcePage() is done because we need to get the\r
+        * ViewerSelectionManager from the TextEditor. setModel is also done here\r
+        * because getModel() needs to reference the TextEditor.\r
+        */\r
+       protected void connectDesignPage() {\r
+               if (_designViewer != null) {\r
+                       _designViewer.setModel(getModel());\r
+                       // _designViewer.getSynchronizer().listenToModel(getModel());\r
+                       ISelectionProvider designSelectionProvider = _designViewer\r
+                                       .getSite().getSelectionProvider();\r
+                       if (designSelectionProvider instanceof IPostSelectionProvider) {\r
+                               ((IPostSelectionProvider) designSelectionProvider)\r
+                                               .addPostSelectionChangedListener(new ISelectionChangedListener() {\r
+                                                       public void selectionChanged(\r
+                                                                       SelectionChangedEvent event) {\r
+                                                               if (getActiveEditor() != _textEditor) {\r
+                                                                       _designViewer.getSynchronizer()\r
+                                                                                       .selectionChanged(event);\r
+                                                               }\r
+                                                       }\r
+                                               });\r
+                       } else {\r
+                               designSelectionProvider\r
+                                               .addSelectionChangedListener(new ISelectionChangedListener() {\r
+                                                       public void selectionChanged(\r
+                                                                       SelectionChangedEvent event) {\r
+                                                               if (getActiveEditor() != _textEditor) {\r
+                                                                       _designViewer.getSynchronizer()\r
+                                                                                       .selectionChanged(event);\r
+                                                               }\r
+                                                       }\r
+                                               });\r
+                       }\r
+                       ISelectionProvider textSelectionProvider = _textEditor.getSite()\r
+                                       .getSelectionProvider();\r
+                       if (textSelectionProvider instanceof IPostSelectionProvider) {\r
+                               ((IPostSelectionProvider) textSelectionProvider)\r
+                                               .addPostSelectionChangedListener(new ISelectionChangedListener() {\r
+                                                       public void selectionChanged(\r
+                                                                       SelectionChangedEvent event) {\r
+                                                               if (event.getSelection() instanceof TextSelection) {\r
+                                                                       TextSelection textSelection = ((TextSelection) event\r
+                                                                                       .getSelection());\r
+                                                                       _designViewer\r
+                                                                                       .getSynchronizer()\r
+                                                                                       .textSelectionChanged(\r
+                                                                                                       textSelection.getOffset(),\r
+                                                                                                       textSelection.getOffset()\r
+                                                                                                                       + textSelection\r
+                                                                                                                                       .getLength());\r
+                                                               }\r
+                                                       }\r
+                                               });\r
+                       } else {\r
+                               textSelectionProvider\r
+                                               .addSelectionChangedListener(new ISelectionChangedListener() {\r
+                                                       public void selectionChanged(\r
+                                                                       SelectionChangedEvent event) {\r
+                                                               TextSelection textSelection = ((TextSelection) event\r
+                                                                               .getSelection());\r
+                                                               _designViewer.getSynchronizer()\r
+                                                                               .textSelectionChanged(\r
+                                                                                               textSelection.getOffset(),\r
+                                                                                               textSelection.getOffset()\r
+                                                                                                               + textSelection\r
+                                                                                                                               .getLength());\r
+                                                       }\r
+                                               });\r
+                       }\r
+               }\r
+       }\r
+\r
+       /**\r
+        * Creates the pages of this multi-page editor.\r
+        * <p>\r
+        * Subclasses of <code>MultiPageEditor</code> must implement this method.\r
+        * </p>\r
+        */\r
+       protected void createPages() {\r
+               try {\r
+                       // source page MUST be created before design page, now\r
+                       if (_sash) {\r
+                               sash_createAndAddDesignSourcePage();\r
+                       } else {\r
+                               tabbed_createAndAddDesignSourcePage();\r
+                       }\r
+                       connectDesignPage();\r
+                       createAndAddPreviewPage();\r
+                       DesignerSourceMouseTrackAdapter adapter = new DesignerSourceMouseTrackAdapter(\r
+                                       _textEditor, getEditDomain());\r
+                       _textEditor.getTextViewer().getTextWidget().addMouseListener(\r
+                                       adapter);\r
+                       _textEditor.getTextViewer().getTextWidget().addMouseMoveListener(\r
+                                       adapter);\r
+               } catch (PartInitException exception) {\r
+                       //$NON-NLS-1$ = "An error has occurred when initializing the input for the the editor's source page."\r
+                       if (_log != null) {\r
+                               // throw new SourceEditingRuntimeException(\r
+                               // "An error has occurred when initializing the input for the\r
+                               // the editor's source page.");\r
+                       }\r
+               }\r
+               // TODO: add a catch block here for any exception the design\r
+               // page throws and convert it into a more informative message.\r
+       }\r
+\r
+       /**\r
+        * Method createTextEditor.\r
+        * \r
+        * @return StructuredTextEditor\r
+        */\r
+       protected StructuredTextEditor createTextEditor() {\r
+               return new DesignerStructuredTextEditorJSP();\r
+       }\r
+\r
+       private void disconnectDesignPage() {\r
+               if (_designViewer != null) {\r
+                       _designViewer.setModel(null);\r
+                       _designViewer.dispose();\r
+               }\r
+       }\r
+\r
+       public void dispose() {\r
+               //System.out.println("dispose of HTML Editor");\r
+               deletePreviewFiles();\r
+               \r
+               disconnectSashPage();\r
+               disconnectDesignPage();\r
+               \r
+               IWorkbenchWindow window = getSite().getWorkbenchWindow();\r
+               window.getPartService().removePartListener(_partListener);\r
+               window.getShell().removeShellListener(_partListener);\r
+               getSite().getPage().removePartListener(_partListener);\r
+\r
+               if (_textEditor != null) {\r
+                       _textEditor.removePropertyListener(this);\r
+                       _textEditor.setEditorPart(null);\r
+                       _textEditor.dispose();\r
+               }\r
+               \r
+               // moved to last when added window ... seems like\r
+               // we'd be in danger of losing some data, like site,\r
+               // or something.\r
+               _sashEditorPart = null;\r
+               _tabbedPropSheet = null;\r
+               _partListener = null;\r
+               _editDomain = null;\r
+               _designViewer = null;\r
+               _browser = null;\r
+               _previewComposite = null;\r
+               _paletteViewerPage = null;\r
+               _log = null;\r
+               _selChangedListener = null;\r
+               _textEditor = null;\r
+               \r
+               super.dispose();\r
+               \r
+       }\r
+\r
+       public void doSave(IProgressMonitor monitor) {\r
+               _textEditor.doSave(monitor);\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc) Saves the contents of this editor to another object. <p>\r
+        * Subclasses must override this method to implement the open-save-close\r
+        * lifecycle for an editor. For greater details, see <code> IEditorPart\r
+        * </code></p>\r
+        * \r
+        * @see IEditorPart\r
+        */\r
+       public void doSaveAs() {\r
+               _textEditor.doSaveAs();\r
+       }\r
+\r
+       private void editorInputIsAcceptable(IEditorInput input)\r
+                       throws PartInitException {\r
+               if (input instanceof IFileEditorInput) {\r
+                       // verify that it can be opened\r
+                       CoreException[] coreExceptionArray = new CoreException[1];\r
+                       if (fileDoesNotExist((IFileEditorInput) input, coreExceptionArray)) {\r
+                               // todo use message formatter for {0}\r
+                               Throwable coreException = coreExceptionArray[0];\r
+\r
+                               // C.B: this is a strange piece of logic.  It was referenceing\r
+                               // the internal sub-class of CoreException, ResourceException.\r
+                               // need to review fileDoesNotExist.\r
+                               if (coreException instanceof CoreException) {\r
+                                       // I'm assuming this is always 'does not exist'\r
+                                       // we'll refresh local go mimic behavior of default\r
+                                       // editor, where the\r
+                                       // troublesome file is refreshed (and will cause it to\r
+                                       // 'disappear' from Navigator.\r
+                                       try {\r
+                                               ((IFileEditorInput) input).getFile()\r
+                                                               .refreshLocal(IResource.DEPTH_ZERO,\r
+                                                                               new NullProgressMonitor());\r
+                                       } catch (CoreException ce) {\r
+                                               if (_log != null) {\r
+                                                       _log.error("Error.HTMLEditor.0", ce); //$NON-NLS-1$\r
+                                               }\r
+                                       }\r
+                                       throw new PartInitException("Resource " + input.getName() //$NON-NLS-1$\r
+                                                       + " does not exist."); //$NON-NLS-1$\r
+                               }\r
+                throw new PartInitException("Editor could not be open on " //$NON-NLS-1$\r
+                               + input.getName());\r
+                       }\r
+               } else if (input instanceof IStorageEditorInput) {\r
+                       InputStream contents = null;\r
+                       try {\r
+                               contents = ((IStorageEditorInput) input).getStorage()\r
+                                               .getContents();\r
+                               if (contents == null) {\r
+                                       throw new PartInitException("Editor could not be open on " //$NON-NLS-1$\r
+                                                       + input.getName());\r
+                               }\r
+                       } catch (CoreException noStorageExc) {\r
+                               // Error in geting storage contents\r
+                               _log.error("Error.HTMLEditor.1", noStorageExc); //$NON-NLS-1$\r
+                       }\r
+                       finally\r
+                       {\r
+                               ResourceUtils.ensureClosed(contents);\r
+                       }\r
+               }\r
+       }\r
+\r
+       /**\r
+        * Initializes the editor part with a site and input. <p>\r
+        * Subclasses of <code> EditorPart </code> must implement this method.\r
+        * Within the implementation subclasses should verify that the input type is\r
+        * acceptable and then save the site and input. Here is sample code: </p><pre>\r
+        * if (!(input instanceof IFileEditorInput)) throw new\r
+        * PartInitException("Invalid Input: Must be IFileEditorInput");\r
+        * setSite(site); setInput(editorInput); </pre>\r
+        * @param input \r
+        * @param coreException \r
+        * @return true if the input doesn't exist \r
+        */\r
+       protected boolean fileDoesNotExist(IFileEditorInput input,\r
+                       Throwable[] coreException) {\r
+               boolean result = false;\r
+               InputStream inStream = null;\r
+               if ((!(input.exists())) || (!(input.getFile().exists()))) {\r
+                       result = true;\r
+               } else {\r
+                       try \r
+                       {\r
+                               inStream = input.getFile().getContents(true);\r
+                       } \r
+                       catch (CoreException e) \r
+                       {\r
+                               // very likely to be file not found\r
+                               result = true;\r
+                               coreException[0] = e;\r
+                               // The core has exception\r
+                               _log.error("Error.HTMLEditor.3", e); //$NON-NLS-1$\r
+                       } \r
+                       finally \r
+                       {\r
+                               ResourceUtils.ensureClosed(inStream);\r
+                       }\r
+               }\r
+               return result;\r
+       }\r
+\r
+       public Object getAdapter(Class key) {\r
+               Object result = null;\r
+               if (key == IDesignViewer.class) {\r
+                       result = _designViewer;\r
+               } else if (key == PalettePage.class) {\r
+                       return getPaletteViewerPage();\r
+               } else if (key == IPropertySheetPage.class) {\r
+                       // XXX: we can delegate this to the fTextEditor, but that use some\r
+                       // more\r
+                       // complicate mechanism, and don't work with page designer well, so\r
+                       // do it simple now, fix later.\r
+                       // return _textEditor.getAdapter(key);\r
+                       return getPropertySheetPage();\r
+               } else if (key == IContentOutlinePage.class) {\r
+                       if (_textEditor != null) {\r
+                               result = _textEditor.getAdapter(key);\r
+                       }\r
+               } else if (key == IPageVariablesProvider.class) {\r
+                       Object obj = ((IDOMModel) getModel()).getDocument().getAdapterFor(\r
+                                       IDocumentPageVariableAdapter.class);\r
+                       if (obj instanceof IPageVariablesProvider) {\r
+                               return obj;\r
+                       }\r
+            return null;\r
+               } else {\r
+                       // DMW: I'm bullet-proofing this because\r
+                       // its been reported (on 4.03 version) a null pointer sometimes\r
+                       // happens here on startup, when an editor has been left\r
+                       // open when workbench shutdown.\r
+                       if (_textEditor != null) {\r
+                               result = _textEditor.getAdapter(key);\r
+                       }\r
+               }\r
+               return result;\r
+       }\r
+\r
+\r
+       /**\r
+        * IExtendedSimpleEditor method\r
+        * @return IDocument\r
+        */\r
+       public IDocument getDocument() {\r
+               if (getTextEditor() == null) {\r
+                       return null;\r
+               }\r
+\r
+               Object apapter = _textEditor.getAdapter(ISourceEditingTextTools.class);\r
+               if (apapter != null) {\r
+                       return ((ISourceEditingTextTools) apapter).getDocument();\r
+               }\r
+\r
+               return null;\r
+       }\r
+\r
+       /**\r
+        * IExtendedMarkupEditor method\r
+        * @return the dom document\r
+        */\r
+       public Document getDOMDocument() {\r
+               if (getTextEditor() == null) {\r
+                       return null;\r
+               }\r
+\r
+               Object adapter = _textEditor.getAdapter(ISourceEditingTextTools.class);\r
+               if (adapter instanceof IDOMSourceEditingTextTools) {\r
+                       return ((IDOMSourceEditingTextTools) adapter).getDOMDocument();\r
+               }\r
+               return null;\r
+       }\r
+\r
+       /**\r
+        * IExtendedSimpleEditor method\r
+        * @return the editor part\r
+        */\r
+       public IEditorPart getEditorPart() {\r
+               return this;\r
+       }\r
+\r
+       /**\r
+        * @return the structured model\r
+        */\r
+       public IStructuredModel getModel() {\r
+               IStructuredModel model = null;\r
+               if (_textEditor != null) {\r
+                       model = ((DesignerStructuredTextEditorJSP) _textEditor).getModel();\r
+               }\r
+               return model;\r
+       }\r
+\r
+\r
+       /**\r
+        * @return the SSE editor delegate\r
+        */\r
+       public StructuredTextEditor getTextEditor() {\r
+               return _textEditor;\r
+       }\r
+\r
+\r
+       /*\r
+        * (non-Javadoc) Method declared on IWorkbenchPart.\r
+        */\r
+       public String getTitle() {\r
+               String title = null;\r
+               if (getTextEditor() == null) {\r
+                       if (getEditorInput() != null) {\r
+                               title = getEditorInput().getName();\r
+                       }\r
+               } else {\r
+                       title = getTextEditor().getTitle();\r
+               }\r
+               if (title == null) {\r
+                       title = getPartName();\r
+               }\r
+               return title;\r
+       }\r
+\r
+       public void init(IEditorSite site, IEditorInput input)\r
+                       throws PartInitException {\r
+               super.init(site, input);\r
+               editorInputIsAcceptable(input);\r
+               try {\r
+                       // super.init(site, input);\r
+                       // setSite(site);\r
+                       setInput(input);\r
+                       if (_partListener == null) {\r
+                               _partListener = new PartActivationHandler(this) {\r
+                                       public void handleActivation() {\r
+                                               safelySanityCheckState();\r
+                                       }\r
+                               };\r
+                       }\r
+                       // we want to listen for our own activation\r
+                       IWorkbenchWindow window = getSite().getWorkbenchWindow();\r
+                       window.getPartService().addPartListener(_partListener);\r
+                       window.getShell().addShellListener(_partListener);\r
+                       \r
+                       // TODO: is this the right place to do this?\r
+                       // enable our editor context\r
+                       IContextService contextService = (IContextService) getSite()\r
+                         .getService(IContextService.class);\r
+                       contextService.activateContext("org.eclipse.jst.pagedesigner.editorContext"); //$NON-NLS-1$\r
+\r
+               } catch (Exception e) {\r
+                       // Error in editor initialization\r
+                       _log.error("Error.HTMLEditor.5", e); //$NON-NLS-1$\r
+               }\r
+               setPartName(input.getName());\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc) Returns whether the "save as" operation is supported by\r
+        * this editor. <p> Subclasses must override this method to implement the\r
+        * open-save-close lifecycle for an editor. For greater details, see <code>\r
+        * IEditorPart </code></p>\r
+        * \r
+        * @see IEditorPart\r
+        */\r
+       public boolean isSaveAsAllowed() {\r
+               return _textEditor != null && _textEditor.isSaveAsAllowed();\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc) Returns whether the contents of this editor should be saved\r
+        * when the editor is closed. <p> This method returns <code> true </code> if\r
+        * and only if the editor is dirty ( <code> isDirty </code> ). </p>\r
+        */\r
+       public boolean isSaveOnCloseNeeded() {\r
+               // overriding super class since it does a lowly isDirty!\r
+               if (_textEditor != null) {\r
+                       return _textEditor.isSaveOnCloseNeeded();\r
+               }\r
+               return isDirty();\r
+       }\r
+\r
+       /**\r
+        * Posts the update code "behind" the running operation.\r
+        */\r
+       private void postOnDisplayQue(Runnable runnable) {\r
+               IWorkbench workbench = PlatformUI.getWorkbench();\r
+               IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();\r
+               if (windows != null && windows.length > 0) {\r
+                       Display display = windows[0].getShell().getDisplay();\r
+                       display.asyncExec(runnable);\r
+               } else {\r
+                       runnable.run();\r
+               }\r
+       }\r
+\r
+       /**\r
+        * Indicates that a property has changed.\r
+        * \r
+        * @param source\r
+        *            the object whose property has changed\r
+        * @param propId\r
+        *            the id of the property which has changed; property ids are\r
+        *            generally defined as constants on the source class\r
+        */\r
+       public void propertyChanged(Object source, int propId) {\r
+               switch (propId) {\r
+               // had to implement input changed "listener" so that\r
+               // strucutedText could tell it containing editor that\r
+               // the input has change, when a 'resource moved' event is\r
+               // found.\r
+               case IEditorPart.PROP_INPUT: {\r
+                       if (source == _textEditor) {\r
+                               if (_textEditor.getEditorInput() != getEditorInput()) {\r
+                                       setInput(_textEditor.getEditorInput());\r
+                                       // title should always change when input changes.\r
+                                       // create runnable for following post call\r
+                                       Runnable runnable = new Runnable() {\r
+                                               public void run() {\r
+                                                       _firePropertyChange(IWorkbenchPart.PROP_TITLE);\r
+                                               }\r
+                                       };\r
+                                       // Update is just to post things on the display queue\r
+                                       // (thread). We have to do this to get the dirty\r
+                                       // property to get updated after other things on the\r
+                                       // queue are executed.\r
+                                       postOnDisplayQue(runnable);\r
+                               }\r
+                       }\r
+                       break;\r
+               }\r
+               case IWorkbenchPart.PROP_TITLE: {\r
+                       // // update the input if the title is changed. why? It seems input\r
+                       // change event will be fired at last.\r
+                       // if (source == _textEditor)\r
+                       // {\r
+                       // if (_textEditor.getEditorInput() != getEditorInput())\r
+                       // {\r
+                       // setInput(_textEditor.getEditorInput());\r
+                       // }\r
+                       // }\r
+                       // break;\r
+               }\r
+               default: {\r
+                       // propagate changes. Is this needed? Answer: Yes.\r
+                       // PROP_PART_NAME, PROP_DIRTY etc.\r
+                       if (source == _textEditor) {\r
+                               firePropertyChange(propId);\r
+                       }\r
+                       break;\r
+               }\r
+               }\r
+\r
+       }\r
+\r
+       private void safelySanityCheckState() {\r
+               // If we're called before editor is created, simply ignore since we\r
+               // delegate this function to our embedded TextEditor\r
+               if (getTextEditor() == null) {\r
+                       return;\r
+               }\r
+\r
+               getTextEditor().safelySanityCheckState(getEditorInput());\r
+\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * \r
+        * @see org.eclipse.ui.part.EditorPart#setInput(org.eclipse.ui.IEditorInput)\r
+        */\r
+       protected void setInput(IEditorInput input) {\r
+               // If driven from the Source page, it's "model" may not be up to date\r
+               // with the input just yet. We'll rely on later notification from the\r
+               // TextViewer to set us straight\r
+               super.setInput(input);\r
+               if (_designViewer != null) {\r
+\r
+                       _designViewer.setModel(getModel());\r
+               }\r
+               setPartName(input.getName());\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * \r
+        * @see org.eclipse.ui.part.EditorPart#isDirty()\r
+        */\r
+       public boolean isDirty() {\r
+               if (getTextEditor() == null) {\r
+                       return false;\r
+               }\r
+               return getTextEditor().isDirty();\r
+       }\r
+\r
+       private IPropertySheetPage getPropertySheetPage()\r
+    {\r
+        if (_tabbedPropSheet == null || _tabbedPropSheet.getControl() == null \r
+                || _tabbedPropSheet.getControl().isDisposed())\r
+        {\r
+            IPropertySheetPageFactory factory = getPageFactory();\r
+            if (factory != null)\r
+            {\r
+                final IFile file = ((IFileEditorInput)getEditorInput()).getFile();\r
+                _tabbedPropSheet = factory.createPage(file);\r
+            }\r
+            else\r
+            {\r
+                _tabbedPropSheet = new WPETabbedPropertySheetPage(this,this);\r
+            }\r
+        }\r
+        return _tabbedPropSheet;\r
+    }\r
+\r
+    private IPropertySheetPageFactory getPageFactory()\r
+    {\r
+        //List<IElementEditFactory> result = new ArrayList<IElementEditFactory>();\r
+        IExtensionPoint extensionPoint = Platform.getExtensionRegistry()\r
+                .getExtensionPoint(PDPlugin.getPluginId(),\r
+                        IJMTConstants.EXTENSION_POINT_PAGEDESIGNER);\r
+        IExtension[] extensions = extensionPoint.getExtensions();\r
+\r
+        for (int i = 0; i < extensions.length; i++)\r
+        {\r
+            IExtension ext = extensions[i];\r
+            IConfigurationElement[] elementEditElement = ext\r
+                    .getConfigurationElements();\r
+\r
+            for (int j = 0; j < elementEditElement.length; j++)\r
+            {\r
+                final IConfigurationElement element = elementEditElement[j];\r
+                if (element.getName().equals(\r
+                        IJMTConstants.PROPERTY_PAGE_FACTORY))\r
+                {\r
+                    elementEditElement[j].getAttribute("class"); //$NON-NLS-1$\r
+                    Object obj;\r
+                    try\r
+                    {\r
+                        obj = elementEditElement[j]\r
+                                .createExecutableExtension("class"); //$NON-NLS-1$\r
+\r
+                        // TODO: we need a policy based solution here,\r
+                        // but this will do for now\r
+                        if (obj instanceof IPropertySheetPageFactory)\r
+                        {\r
+                            return (IPropertySheetPageFactory) obj;\r
+                        }\r
+                    } \r
+                    catch (CoreException e)\r
+                    {\r
+                        PDPlugin.log("Problem loading element edit extension for "+element.toString(), e); //$NON-NLS-1$\r
+                    }\r
+                }\r
+            }\r
+        }\r
+        return null;\r
+    }\r
+       \r
+    /**\r
+     * @return PaletteViewerPage\r
+     */\r
+    private PaletteViewerPage getPaletteViewerPage()\r
+    {\r
+        if (_paletteViewerPage == null)\r
+        {\r
+            _paletteViewerPage = _designViewer.createPaletteViewerPage();\r
+        }\r
+        return _paletteViewerPage;\r
+    }\r
+\r
+       /**\r
+        * @return the edit domain\r
+        */\r
+       public DefaultEditDomain getEditDomain() {\r
+               if (_editDomain == null) {\r
+                       _editDomain = new DefaultEditDomain(this);\r
+\r
+                       // XXX: if i don't do the following line, system will default use\r
+                       // SelectionTool. Don't know where else to set this. Since it is\r
+                       // kind of duplicate\r
+                       // to the DesignerPaletteRoot.\r
+                       _editDomain.setDefaultTool(new RangeSelectionTool());\r
+                       _editDomain.loadDefaultTool();\r
+\r
+                       // next config the _editDomain\r
+                       // _editDomain.setPaletteRoot(new JSFPaletteRoot());\r
+               }\r
+               return _editDomain;\r
+       }\r
+\r
+       /**\r
+        * (non-Javadoc)\r
+        * \r
+        * @see org.eclipse.ui.part.MultiPageEditorPart#pageChange(int)\r
+        */\r
+       protected void pageChange(int newPageIndex) {\r
+               super.pageChange(newPageIndex);\r
+\r
+               if (newPageIndex == _previewPageIndex) {\r
+                       // preview page activate, set the absoulte path of the current page URL.\r
+                       IEditorInput editorInput = this.getEditorInput();\r
+                       if (!(editorInput instanceof IFileEditorInput)) {\r
+                               return;\r
+                       }\r
+\r
+                       FileEditorInput fileInput = (FileEditorInput)editorInput;\r
+                       IFile file = fileInput.getFile();\r
+                       if (!file.exists()) {\r
+                               return;\r
+                       }\r
+\r
+                       try {\r
+                               String url = file.getLocationURI().toURL().toString();\r
+                               getPreviewBrowser().getBrowser().setUrl(url);\r
+                       } catch (Exception e) {\r
+                               getPreviewBrowser().getBrowser().setUrl("about:blank"); //$NON-NLS-1$\r
+                       }\r
+               }\r
+\r
+               /*\r
+               deletePreviewFiles();\r
+\r
+               if (newPageIndex == _previewPageIndex) {\r
+                       // preview page activate, need to regenerate the preview text and\r
+                       // display it.\r
+                       StringBuffer result = new StringBuffer();\r
+                       try {\r
+                               // PreviewHandler.generatePreview(this.getModel(),\r
+                               // this.getEditorInput(), result);\r
+                               DocumentEditPart part = (DocumentEditPart) this._designViewer\r
+                                               .getGraphicViewer().getContents();\r
+                               PreviewHandlerNew.generatePreview(part, result);\r
+                       } catch (Exception ex) {\r
+                               result = new StringBuffer();\r
+                               result\r
+                                               .append(this.getModel().getStructuredDocument()\r
+                                                               .getText());\r
+                               // Error in page changing\r
+                               _log.info("Error.HTMLEditor.6", ex); //$NON-NLS-1$\r
+                               ex.printStackTrace();\r
+                       }\r
+                       File file = PreviewUtil.toFile(result, getEditorInput());\r
+                       if (file != null) {\r
+                               PREVIEW_FILES_LIST.add(file);\r
+                               getPreviewBrowser().loadFile(file);\r
+                       } else {\r
+                               getPreviewBrowser().getBrowser().setUrl("about:blank"); //$NON-NLS-1$\r
+                       }\r
+               }\r
+               */\r
+       }\r
+\r
+       /**\r
+        * @return Returns the _designViewer.\r
+        */\r
+       public IDesignViewer getDesignViewer() {\r
+               return _designViewer;\r
+       }\r
+\r
+       /**\r
+        * @param mode\r
+        */\r
+       public void setDesignerMode(int mode) {\r
+               boolean requiresResynch = (_mode == MODE_SOURCE);\r
+               if (_sashEditorPart != null && _mode != mode) {\r
+                       switch (mode) {\r
+                       case MODE_SASH_HORIZONTAL:\r
+                               _sashEditorPart.setOrientation(SWT.HORIZONTAL);\r
+                               break;\r
+                       case MODE_DESIGNER:\r
+                               _sashEditorPart.setMaximizedEditor(this._designViewer);\r
+                               break;\r
+                       case MODE_SOURCE:\r
+                               _sashEditorPart.setMaximizedEditor(this._textEditor);\r
+                               break;\r
+                       case MODE_SASH_VERTICAL:\r
+                       default:\r
+                               _sashEditorPart.setOrientation(SWT.VERTICAL);\r
+                       }\r
+                       if (getEditorInput() != null) {\r
+                               EditorUtil.setEditorInputDesignModeProperty(getEditorInput(), String.valueOf(mode));\r
+                       }\r
+               }\r
+               this._mode = mode;\r
+               if (requiresResynch) {\r
+                       resynch();\r
+               }\r
+       }\r
+\r
+       /*\r
+        * Set the sash editor mode from the stored file property\r
+        * or the default preference.\r
+        */\r
+       private void initDesignerMode() {\r
+               int preferredMode = MODE_SASH_VERTICAL;\r
+\r
+               // If the user has already selected a mode for the file, use it.\r
+               String prop = null;\r
+               if (getEditorInput() != null) {\r
+                       prop = EditorUtil.getEditorInputDesignModeProperty(getEditorInput());\r
+               }\r
+               if (prop != null) {\r
+                       try {\r
+                               preferredMode = Integer.parseInt(prop);\r
+                       } catch (NumberFormatException e) {\r
+                               // do nothing;\r
+                       }\r
+               } else {\r
+                       // Otherwise, get the default mode from preferences.\r
+                       IPreferenceStore pStore = PDPlugin.getDefault().getPreferenceStore();\r
+                       preferredMode = pStore.getInt(PDPreferences.SASH_EDITOR_MODE_PREF);\r
+               }\r
+\r
+               setDesignerMode(preferredMode);\r
+       }\r
+\r
+       /**\r
+        * @return the current design mode\r
+        */\r
+       public int getDesignerMode() {\r
+               return this._mode;\r
+       }\r
+\r
+       private void resynch() {\r
+               if (_textEditor != null && _designViewer != null) {\r
+                       ISelectionProvider provider = _textEditor.getSelectionProvider();\r
+                       if (provider != null) {\r
+                               ISelection selection = provider.getSelection();\r
+                               if (selection instanceof TextSelection) {\r
+                                       TextSelection textSelection = (TextSelection)selection;\r
+                                       SelectionSynchronizer synchronizer = _designViewer.getSynchronizer();\r
+                                       if (synchronizer != null) {\r
+                                               synchronizer.textSelectionChanged(\r
+                                                               textSelection.getOffset(),\r
+                                                               textSelection.getOffset() + textSelection.getLength());\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+\r
+       public IEditorPart getActiveEditor() {\r
+               IEditorPart result = null;\r
+               if (_sash) {\r
+                       result = _sashEditorPart.getActiveEditor();\r
+               } else {\r
+                       if (_designViewer.getGraphicViewer().getControl().isFocusControl()) {\r
+                               result = _designViewer;\r
+                       } else if (_textEditor.getTextViewer().getControl()\r
+                                       .isFocusControl()) {\r
+                               result = _textEditor;\r
+                       }\r
+               }\r
+               return result;\r
+       }\r
+\r
+       public String getPartName() {\r
+               if (_textEditor != null) {\r
+                       return _textEditor.getPartName();\r
+               }\r
+        return super.getPartName();\r
+       }\r
+\r
+       private void deletePreviewFiles() {\r
+               Iterator itPreviewFiles = PREVIEW_FILES_LIST.iterator();\r
+               while (itPreviewFiles.hasNext()) {\r
+                       File file = (File)itPreviewFiles.next();\r
+                       if (file != null && file.exists()) {\r
+                               file.delete();\r
+                       }\r
+               }\r
+               PREVIEW_FILES_LIST.clear();\r
+       }\r
+\r
+       /**\r
+        * Refreshes the design page. Allows an external action to force a refresh\r
+        * after an external change, such as a DT skin change.\r
+        */\r
+       public void refreshDesignViewer() {\r
+               EditPart contentEditPart = _designViewer.getGraphicViewer().getRootEditPart().getContents();\r
+               if (contentEditPart instanceof DocumentEditPart) {\r
+                       ((DocumentEditPart)contentEditPart).styleChanged();\r
+               }\r
+       }\r
+\r
+}\r
index fdfcae0..2d2f718 100755 (executable)
Binary files a/org.eclipse.jst.pagedesigner/icons/PD_Toolbar_designer.gif and b/org.eclipse.jst.pagedesigner/icons/PD_Toolbar_designer.gif differ
index 4dae95d..9019095 100755 (executable)
Binary files a/org.eclipse.jst.pagedesigner/icons/PD_Toolbar_hsplit.gif and b/org.eclipse.jst.pagedesigner/icons/PD_Toolbar_hsplit.gif differ
index 86986df..73fc3ba 100755 (executable)
Binary files a/org.eclipse.jst.pagedesigner/icons/PD_Toolbar_source.gif and b/org.eclipse.jst.pagedesigner/icons/PD_Toolbar_source.gif differ
index 6564d07..440f7e6 100755 (executable)
Binary files a/org.eclipse.jst.pagedesigner/icons/PD_Toolbar_vsplit.gif and b/org.eclipse.jst.pagedesigner/icons/PD_Toolbar_vsplit.gif differ
index 8ca7f25..7cfed55 100644 (file)
@@ -2,12 +2,12 @@
 <feature
       id="org.tizen.base.feature"
       label="Tizen Base Feature"
-      version="0.20.0.qualifier"
+      version="1.0.0.qualifier"
       provider-name="Samsung"
       plugin="org.tizen.base.platform">
 
    <description>
-      Base Feature for Tizen SDK.
+      Common library for Tizen SDK.
    </description>
 
    <copyright>
@@ -57,14 +57,6 @@ BY CLICKING THE &quot;I AGREE&quot; BUTTON OR BY USING ANY PART OF TIZEN SDK, YO
          version="0.0.0"/>
 
    <includes
-         id="org.eclipse.cdt.platform"
-         version="0.0.0"/>
-
-   <includes
-         id="org.eclipse.cdt"
-         version="0.0.0"/>
-
-   <includes
          id="org.eclipse.datatools.connectivity.oda.feature"
          version="0.0.0"/>
 
@@ -244,6 +236,18 @@ BY CLICKING THE &quot;I AGREE&quot; BUTTON OR BY USING ANY PART OF TIZEN SDK, YO
          id="org.eclipse.wst.xml_userdoc.feature"
          version="0.0.0"/>
 
+   <includes
+         id="org.eclipse.egit"
+         version="0.0.0"/>
+
+   <includes
+         id="org.eclipse.jgit"
+         version="0.0.0"/>
+
+   <includes
+         id="org.eclipse.cdt.platform"
+         version="0.0.0"/>
+
    <plugin
          id="org.tizen.base.platform"
          download-size="0"
@@ -847,13 +851,6 @@ BY CLICKING THE &quot;I AGREE&quot; BUTTON OR BY USING ANY PART OF TIZEN SDK, YO
          unpack="false"/>
 
    <plugin
-         id="org.eclipse.cdt.ui"
-         download-size="0"
-         install-size="0"
-         version="0.0.0"
-         unpack="false"/>
-
-   <plugin
          id="org.eclipse.cdt"
          download-size="0"
          install-size="0"
old mode 100644 (file)
new mode 100755 (executable)
index c6eb270..b1647bb
@@ -1,14 +1,15 @@
 #!/bin/sh
 start_path=`pwd`
-__cwd=`dirname $0`
-cd "$__cwd"
-__cwd=`pwd`
 
-tizenpath=`grep TIZEN_SDK_INSTALLED_PATH ${HOME}/.TizenSDK/tizensdkpath`
-TIZEN_SDK_INSTALL_PATH=`echo $tizenpath | cut -f2- -d"="`
+IDE_PATH=`dirname $(readlink -f $0)`
+CONFIG_PATH="${HOME}/.TizenSDK/tizensdkpath"
 
-#TIZEN_SDK_INSTALL_PATH=$(dirname $(readlink -f $0))/../
-#slppath=`echo "TIZEN_SDK_INSTALLED_PATH=${TIZEN_SDK_INSTALL_PATH}" > ${HOME}/.TizenSDK/tizensdkpath`
+cd "${IDE_PATH}/.."
+TIZEN_SDK_INSTALL_PATH=`pwd`
+
+sed -e "s;\(^TIZEN_SDK_INSTALLED_PATH=\).*;\1${TIZEN_SDK_INSTALL_PATH};g" \
+< ${CONFIG_PATH} > ${CONFIG_PATH}.mod
+mv ${CONFIG_PATH}.mod ${CONFIG_PATH}
 
 export PATH=${PATH}:$TIZEN_SDK_INSTALL_PATH/SDK/build-system/bin
 export no_proxy=$no_proxy,"127.0.0.1"
@@ -29,6 +30,7 @@ fi
 
 
 ## Execute IDE
+cd ${IDE_PATH}
 if [ ${linux_name} = "ubuntu" ]
 then
        if [ ${linux_main_version} = "11.04" -o ${linux_main_version} = "11.10" ]
index 94dd1f5..c49cc9e 100644 (file)
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %Bundle-Name
 Bundle-SymbolicName: org.tizen.base.platform;singleton:=true
-Bundle-Version: 1.17.0.qualifier
+Bundle-Version: 0.20.0.qualifier
 Bundle-Activator: org.tizen.base.platform.Activator
 Bundle-Vendor: %Bundle-Vendor
 Require-Bundle: org.eclipse.ui,
index 8d2a9fd..b8ffbdc 100644 (file)
@@ -1,16 +1,22 @@
-#Properties file for org.tizen.base.platform
+#Properties file for org.tizen.base.platform 
 Bundle-Vendor = Samsung
 Bundle-Name = Tizen SDK
 
-perspective.name=Tizen Native
 product.name=Tizen IDE
-product.provider=Samsung
 product.description=\n\
-Tizen SDK\n\
-       \n\
-       Version: {0}\n\
-       Build id: {3}\n\
-       \n\
-       Copyright (c) 2010-2011, Samsung Electronics Co., LTD. All rights reserved.\n\
-       \n\
-       Visit https://developer.tizen.org\n
\ No newline at end of file
+{0}\n\
+\n\
+Version : {1}\n\
+Build id : {2}\n\
+{3}\n\
+\n\
+{4}
+windowImages=icons/branding/16_TIZEN_SDK_icon.png,icons/branding/32_TIZEN_SDK_icon.png,icons/branding/48_TIZEN_SDK_icon.png,icons/branding/64_TIZEN_SDK_icon.png,icons/branding/128_TIZEN_SDK_icon.png
+aboutImage=icons/branding/about_tizen_sdk.png
+featureImage=icons/branding/32_TIZEN_SDK_icon.png
+
+productIntroTitle = Welcome to Tizen SDK
+productIntroBrandingText = Samsung
+introDescription-overview = The Eclipse Platform is a kind of universal tool platform - an open extensible IDE for anything and nothing in particular. 
+introDescription-tutorials = Learn how to be productive using Eclipse by completing end-to-end tutorials that will guide you along the way.
+introDescription-samples = Explore Eclipse by installing prefabricated samples (may require Internet connection).
index 8d1cb97..1e8780a 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?pde version="3.5"?>
 
-<product name="Tizen Base Plugins" uid="org.tizen.base.product" id="org.tizen.base.platform.product" application="org.eclipse.ui.ide.workbench" version="0.20" useFeatures="true" includeLaunchers="false">
+<product name="Tizen IDE" uid="org.tizen.base.product" id="org.tizen.base.platform.product" application="org.eclipse.ui.ide.workbench" version="1.0.0.qualifier" useFeatures="true" includeLaunchers="false">
 
    <aboutInfo>
       <image path="/org.tizen.base.platform/icons/branding/about_tizen_sdk.png"/>
index 8d1cb97..1e8780a 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?pde version="3.5"?>
 
-<product name="Tizen Base Plugins" uid="org.tizen.base.product" id="org.tizen.base.platform.product" application="org.eclipse.ui.ide.workbench" version="0.20" useFeatures="true" includeLaunchers="false">
+<product name="Tizen IDE" uid="org.tizen.base.product" id="org.tizen.base.platform.product" application="org.eclipse.ui.ide.workbench" version="1.0.0.qualifier" useFeatures="true" includeLaunchers="false">
 
    <aboutInfo>
       <image path="/org.tizen.base.platform/icons/branding/about_tizen_sdk.png"/>
index 6c10b50..beea3b8 100644 (file)
@@ -7,25 +7,5 @@
 # Property "aboutText" contains blurb for "About" dialog (translated)
 aboutText=%blurb
 
-# Property "aboutImage" contains path to product image (500x330 or 115x164)
-# needed for primary features only
-aboutImage=%product.aboutImage
-
-# Property "windowImage" contains path to window icon (16x16)
-# needed for primary features only
-#windowImage=%product.windowImages
-
 # Property "featureImage" contains path to feature image (32x32)
-featureImage=icons/branding/32_TIZEN_SDK_icon.png
-
-# Property "welcomePerspective" contains the id of the perspective in which the
-# welcome page is to be opened.
-# optional
-#welcomePage=
-#welcomePerspective=
-
-# Property "appName" contains name of the application (translated)
-# needed for primary features only
-appName=%product.name
-
-tipsAndTricksHref=https://developer.tizen.org
\ No newline at end of file
+featureImage=icons/branding/32_TIZEN_SDK_icon.png
\ No newline at end of file
index e773a4c..24afbc9 100644 (file)
@@ -1,9 +1,10 @@
 # about.mappings
-# contains fill-ins for about.properties
+# contains fill-ins for about.properties and bundle.properties
 # java.io.Properties file (ISO 8859-1 with "\" escapes)
 # This file does not need to be translated.
 
-0=0
-1=ir#
-2=build#
-3=date-time
\ No newline at end of file
+0=Tizen SDK
+1=0
+2=date-time
+3=Copyright (c) 2010-2011 Samsung Electronics Co., LTD. All Rights Reserved.
+4=Visit https://developer.tizen.org\n
index d35507b..55bf0fb 100644 (file)
@@ -4,19 +4,10 @@
 # fill-ins are supplied by about.mappings
 # This file should be translated.
 
-blurb=Tizen SDK\n\
+blurb={0}\n\
 \n\
-Version: {0}\n\
-Build id: {3}\n\
+Version : {1}\n\
+Build id : {2}\n\
 \n\
-Copyright (c) 2010-2011, Samsung Electronics Co., LTD. All rights reserved.\n\
-\n\
-Visit https://developer.tizen.org\n
-product.windowImages=icons/branding/16_TIZEN_SDK_icon.png,icons/branding/32_TIZEN_SDK_icon.png,icons/branding/48_TIZEN_SDK_icon.png,icons/branding/64_TIZEN_SDK_icon.png,icons/branding/128_TIZEN_SDK_icon.png,product.windowImages256=icons/branding/256_TIZEN_SDK_icon.png
-product.aboutImage=icons/branding/about_tizen_sdk.png
-product.featureImage=icons/branding/32_TIZEN_SDK_icon.png
-productIntroTitle = Welcome to Tizen SDK
-productIntroBrandingText = Samsung
-introDescription-overview = The Eclipse Platform is a kind of universal tool platform - an open extensible IDE for anything and nothing in particular. 
-introDescription-tutorials = Learn how to be productive using Eclipse by completing end-to-end tutorials that will guide you along the way.
-introDescription-samples = Explore Eclipse by installing prefabricated samples (may require Internet connection).
\ No newline at end of file
+{3}\n\
+{4}\n
\ No newline at end of file
index b429ae9..bf4f4d8 100644 (file)
 </head>\r
 <body>\r
                <div style=" position:absolute; top:204px; left:75px; ">\r
-               <a href="http://org.eclipse.ui.intro/showHelpTopic?id=/org.tizen.help.gettingstarted/3244278.html">\r
+               <a href="http://org.eclipse.ui.intro/showHelpTopic?id=/org.tizen.help.gettingstarted/Platform Overview.html">\r
                                <img border="0" src="icon_01_normal.png" alt="Getting Started" onmouseover="on_01(this)" onmouseout="off_01(this)" />              \r
                </a>\r
                </div>            \r
                <div style=" position:absolute; top:204px; left:211px; ">\r
-               <a href="http://org.eclipse.ui.intro/showHelpTopic?id=/org.tizen.help.gettingstarted/3244288.html">\r
+               <a href="http://org.eclipse.ui.intro/showHelpTopic?id=/org.tizen.help.gettingstarted/Getting Started.html">\r
                                <img border="0" src="icon_02_normal.png" alt="Tizen Web Programming" onmouseover="on_02(this)" onmouseout="off_02(this)" />\r
                        </a>                            \r
-               </div>\r
+               </div>                  \r
                <div style=" position:absolute; top:204px; left:347px; ">\r
                        <a href="http://org.eclipse.ui.intro/close"> \r
                                <img border="0" src="icon_04_normal.png" alt="Closed" onmouseover="on_04(this)" onmouseout="off_04(this)" />             \r
index 0a8c149..61ded9e 100644 (file)
       <product
             application="org.eclipse.ui.ide.workbench"
             description="%product.description"
-            name="Tizen IDE">
+            name="%product.name">
          <property
                name="windowImages"
-               value="icons/branding/16_TIZEN_SDK_icon.png,icons/branding/32_TIZEN_SDK_icon.png,icons/branding/48_TIZEN_SDK_icon.png,icons/branding/64_TIZEN_SDK_icon.png,icons/branding/128_TIZEN_SDK_icon.png">
+               value="%windowImages">
          </property>
          <property
                name="aboutText"
@@ -45,7 +45,7 @@
          </property>
          <property
                name="aboutImage"
-               value="icons/branding/about_tizen_sdk.png">
+               value="%aboutImage">
          </property>
          <property
                name="preferenceCustomization"
@@ -53,7 +53,7 @@
          </property>
          <property
                name="appName"
-               value="Tizen IDE">
+               value="%product.name">
          </property>
          <property
                name="introTitle"
@@ -89,7 +89,7 @@
          </property>
          <property
                name="featureImage"
-               value="%product.featureImage">
+               value="%featureImage">
          </property>
          <property
                name="buildIdLocation"
index 411621d..abcd473 100755 (executable)
@@ -12,15 +12,15 @@ TIZEN_SDK_INSTALL_PATH=${INSTALLED_PATH}
 exepath=$TIZEN_SDK_INSTALL_PATH/${ide_path}/$exefile
 ide_resources_path=${TIZEN_SDK_INSTALL_PATH}/${ide_path}/resources
 ide_icons_path=${ide_resources_path}/icons
+ide_fonts_path=${ide_resources_path}/fonts
 categoryfile=${MENU_DIRECTORY_PATH}
 
 chmod 755 ${exepath}
 
-## Regist start menu
-${MAKESHORTCUT_PATH} -f "${desktopfile}" -e "${exepath}" -i "${ide_icons_path}/${iconfile}" -n "${name}" -c "${comment}"
-if [ $? gt 0 ]
+## Register start menu
+if [ -e ${MAKESHORTCUT_PATH} ]
 then
-       exit 10
+    ${MAKESHORTCUT_PATH} -f "${desktopfile}" -e "${exepath}" -i "${ide_icons_path}/${iconfile}" -n "${name}" -c "${comment}"
 fi
 
 exit 0
index 4d04979..e975724 100644 (file)
@@ -2,15 +2,17 @@
 set shortcut_name=Tizen IDE
 set execute_file=IDE.exe
 set icon_file=tizen-sdk-ide.ico
+set font_file=EcoSansMonoBD_110929.ttf
 set program_path=%INSTALLED_PATH%\IDE
 set execute_path=%program_path%\%execute_file%
 set icon_path=%program_path%\resources\icons
+set font_path=%program_path%\resources\fonts
 
 echo Setting shortcut...
 wscript.exe "%MAKESHORTCUT_PATH%" /shortcut:"%shortcut_name%" /target:"%execute_path%" /icon:"%icon_path%\%icon_file%"
 
-IF %ERRORLEVEL% GTR 0 (
-EXIT 10
-)
+echo Make shortcut success.
+:: Install Tizen font
+:: copy %font_path%\%font_file% %HOMEDRIVE%\Windows\Fonts
 
-EXIT 0
+exit 0
index 932ce9e..f0e2255 100755 (executable)
@@ -1,23 +1,12 @@
 #!/bin/bash -x
-
-## Remove p2 files ##
-ide_path=IDE
-rm -rf ${INSTALLED_PATH}/${ide_path}/p2
-
-if [ $? gt 0 ]
-then
-       exit 10
-fi
-## END Remove p2 files ##
-
-## Register .desktop file ##
+## Register .desktop file
 DESKTOP_FILE_PATH="${HOME}/.local/share/applications/tizen-sdk-ide.desktop"
 ${REMOVE_SHORTCUT} ${DESKTOP_FILE_PATH}
+#xdg-desktop-menu uninstall ${MENU_DIRECTORY_NAME} tizen-sdk-ide.desktop
+### END Register Menu ###
 
-if [ $? gt 0 ]
-then
-       exit 9
-fi
-## END Register Menu ##
+## Remove auto creating files
+ide_path=IDE
+rm -rf ${INSTALLED_PATH}/${ide_path}/p2
 
-exit 0
+### End ###
index 7e77d60..4d9c3d7 100644 (file)
@@ -2,18 +2,11 @@
 
 set shortcut_name="Tizen IDE"
 
-:: Remove p2 files
-rd/s/q "%INSTALLED_PATH%\IDE\p2"
-
-IF %ERRORLEVEL% GTR 0 (
-       EXIT 10
-)
-
-:: Remove shortcut menu
+:: delims is a TAB followed by a space
 %REMOVE_SHORTCUT% /shortcut:"%shortcut_name%"
 
-IF %ERRORLEVEL% GTR 0 (
-       EXIT 9 
-)
+rd/s/q "%INSTALLED_PATH%\IDE\p2"
+:: Uninstall Tizen font
+:: del %HOMEDRIVE%\Windows\Fonts\unnamed.ttf
+
 
-EXIT 0
index 9be4b7b..352efa5 100755 (executable)
@@ -32,10 +32,8 @@ __set_parameter()
 __set_build_parameter()
 {
        manifest_version=`grep Version: ${SRCDIR}/package/pkginfo.manifest | cut -f2 -d":" | head -n 1`
-       product_version="Beta"
-       build_major_version=`echo ${manifest_version} | cut -f1 -d"."`
-       build_minor_version=`echo ${manifest_version} | cut -f2 -d"."`
-       build_bugfix_version=`echo ${manifest_version} | cut -f3 -d"."`
+       #product_version=${manifest_version}
+       product_version="1.0 Larkspur"
        branding_path="org.tizen.base.platform"
        branding_file="TizenIDE_base_${platform}.product"
        
@@ -141,11 +139,9 @@ __set_product_version() {
        mv ${product_path}.mod ${product_path}
        
        about_mapping_path="${build_path}/plugins/${branding_path}/about.mappings"
-       about_major_version_parameter="0"
-       #about_ir_version_parameter="1"
-       #about_build_version_parameter="2"
-       about_build_time_parameter="3"
-       sed -e "s;\(^${about_major_version_parameter}=\).*;\1${product_version};g" \
+       about_version_parameter="1"
+       about_build_time_parameter="2"
+       sed -e "s;\(^${about_version_parameter}=\).*;\1${product_version};g" \
                -e "s;\(^${about_build_time_parameter}=\).*;\1${build_time};g" \
                < ${about_mapping_path} > ${about_mapping_path}.mod
        mv ${about_mapping_path}.mod ${about_mapping_path}
index a709002..649816f 100644 (file)
@@ -1,17 +1,17 @@
 Package:base-ide-product
-Version:0.20.14
+Version:1.0.21
 OS:linux
 Build-host-os:linux
 Build-dependency:indigo-pde [linux]
 Source:product
-Maintainer:Kangho Kim <kh5325.kim@samsung.com>, Yoonki Park, Taeyoung Son
+Maintainer:kangho kim <kh5325.kim@samsung.com>, yoonki park <yoonki.park@samsung.com>, hyunsik non <hyunsik.noh@samsung.com>, taeyoung son <taeyoung2.son@samsung.com>, gune Kim <gune.kim@samsung.com>, ho namkoong <ho.namkoong@samsung.com>, hyeongseok heo <hyeong-seok.heo@samsung.com>, gyeongseok seo <gyeongseok.seo@samsung.com>, jihoon song<jihoon80.song@samsung.com>, changhyun lee <changhyun1.lee@samsung.com>
 Description:Make base IDE
 
 Package:base-ide-product
-Version:0.20.14
+Version:1.0.21
 OS:windows
 Build-host-os:linux
 Build-dependency:indigo-winpde [windows]
 Source:product
-Maintainer:Kangho Kim <kh5325.kim@samsung.com>, Yoonki Park, Taeyoung Son
+Maintainer:kangho kim <kh5325.kim@samsung.com>, yoonki park <yoonki.park@samsung.com>, hyunsik non <hyunsik.noh@samsung.com>, taeyoung son <taeyoung2.son@samsung.com>, gune Kim <gune.kim@samsung.com>, ho namkoong <ho.namkoong@samsung.com>, hyeongseok heo <hyeong-seok.heo@samsung.com>, gyeongseok seo <gyeongseok.seo@samsung.com>, jihoon song<jihoon80.song@samsung.com>, changhyun lee <changhyun1.lee@samsung.com>
 Description:Make base IDE